tag:blogger.com,1999:blog-40579064050030009722023-11-16T06:26:13.466-05:00Compile You? I Don't Even Know You!Dan Rosenstark, Author of <a href="http://mididesigner.com">MIDI Designer</a>, muses about all things tech. Particularly: Notes on software development in Swift, Objective-C, and many non-Apple languages. Also: lots of random technology notes on OS X and iOS. <br><br>
<a href="http://twitter.com/dr2050">Twitter</a> | <a href="https://www.linkedin.com/in/dr2050">LinkedIn</a> | <a href="http://stackoverflow.com/users/8047/dan-rosenstark">Stack Overflow</a>Dan Rosenstarkhttp://www.blogger.com/profile/12477764482153529031noreply@blogger.comBlogger168125tag:blogger.com,1999:blog-4057906405003000972.post-56163961777508792552017-08-21T15:45:00.001-04:002017-08-21T15:45:16.500-04:00Moving from Blogger to Postachio<p>Discovering <a href="https://stackedit.io/">StackEdit</a> has been absolutely brilliant (and the confusing Beta of <a href="http://classeur.io/">Classeur App</a>, too, but I’m moving to my blogging to <a href="http://postach.io">Postachio</a> for now.</p>
<h2 id="please-check-me-out-at-my-new-location-when-you-can">Please check me out at my <strong><a href="http://blog.dr2050.com">new location</a></strong> when you can.</h2>
<blockquote>
<p>Written with <a href="https://stackedit.io/">StackEdit</a>.</p>
</blockquote>Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-84356991210363509982017-08-16T16:16:00.000-04:002017-08-16T16:18:16.174-04:00Swift 2 to 3, Method Calls, Magic First Parameters and Automatic Conversion Woes<iframe src="https://www.evernote.com/shard/s6/sh/4ae03112-c5fb-46b5-87bf-ad664bf48616/db74423eceb874eb.html" style="width: 100%; height: 4500px" height="4500px"></iframe>Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-50105885571082576142017-08-05T14:05:00.000-04:002017-08-05T19:38:45.058-04:00Color Syntax Highlighting for Code in EvernoteThis solution doesn't give you dynamic code syntax highlighting, but it's pretty useful anyway. I use Evernote to avoid going insane as I work on many things at the same time.
<BR><BR>
<iframe border="0" height="2250px" src="https://www.evernote.com/shard/s6/sh/e21f2c7e-3ea1-4c3b-b4af-188d94f67d82/76f48c64f39847ad.html" width="100%"></iframe>
Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-20262489202376801082017-05-08T16:10:00.001-04:002017-05-08T16:13:09.623-04:00Fast Stuff on a Background GCD QueueI realize this is not a popular position, but the truth of the matter is that for many (most) situations, you can just do stuff on a background queue and then dispatch the main queue. It's pretty hard (but not impossible) to clog up the main dispatch queue.<br />
<br />
<h3>
NSTimer Replacement: Faster!</h3>
Here's my timer for running stuff in the background. Generally, this is all you need. Dispatch to main from within your callback as needed:<br />
<br />
<script src="https://gist.github.com/drosenstark/0a19e4e6c549e4142d4280a757c58576.js"></script>
<br />
<h3>
Get on Main Queue the Right Way</h3>
On the other hand, if you want to do this right and <b>never </b>risk clogging up the main queue, you need to use a dispatch source. See <a href="http://stackoverflow.com/a/39949292/8047">Rob's stuff here on SO</a>, particularly the last part where he discusses a progressIndicator.<br />
<br />
<h3>
GameLoop for MainQueue Dispatch Tied to Frame Rate</h3>
On the other hand, if you want something to update every time the main loop goes around, you can use this Game Loop:<br />
<br />
<script src="https://gist.github.com/drosenstark/bb0dbc50d51699dfa0666f6c676306f0.js"></script>Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-11757978676814086812017-03-20T17:02:00.000-04:002017-03-20T17:02:59.748-04:00Locks with GCD and Swift 3Even in a Playground it's easy to see how locks work. When <span style="font-family: Courier New, Courier, monospace;">useLocks</span> is set to <span style="font-family: Courier New, Courier, monospace;">false</span>, a fatal error is thrown before the <span style="font-family: Courier New, Courier, monospace;">counter</span> even gets to 5! When it's set to <span style="font-family: Courier New, Courier, monospace;">true</span>, the <span style="font-family: Courier New, Courier, monospace;">counter</span> can get to its natural endpoint (200).
<BR><BR>
<script src="https://gist.github.com/drosenstark/64bd538eed5a9382f1fede9e880b3947.js"></script>Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-78290066598452944692017-03-18T21:23:00.001-04:002017-03-18T21:28:41.922-04:00Simple Stuff with Storyboards, Navigation and UnwindingWritten with Xcode 8.2.1, Swift 3.0
<hr>
<iframe border="0" height="5150px" src="https://www.evernote.com/shard/s6/sh/acd8b28e-60ae-4651-8128-be0f389e6992/2735657abe5cdaf8.html" width="100%"></iframe>
Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-18812977192717386702016-11-10T14:51:00.000-05:002016-12-06T14:18:20.570-05:00Associated Object Support for Swift 2.3 and 3.x<h1>Swift 3.x</h1>
<iframe src="https://www.evernote.com/shard/s6/sh/189d44bf-b6a4-4db1-aef4-10793d3988d4/ab981bceaaf561bc.html" width="100%" height="910px"></iframe>
<HR>
<h1>Swift 2.3</h1>
<iframe src="https://www.evernote.com/shard/s6/sh/a7aa4fd3-ec09-4a38-8c80-b432a54fc62f/59e118a1ab17eaf1.html" width="100%" height="910px"></iframe>
Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-90366150696671995552016-09-16T15:08:00.000-04:002016-09-16T17:07:25.053-04:00Dan's Rudimentary Understanding of Bundle IDs, App IDs, Private/Public Keys and Provisioning Profiles<iframe width="100%" height="910" src="https://workflowy.com/s/fQgi37hw2z" frameborder="1" allowfullscreen style=""></iframe>Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-81857422175755912612016-07-08T15:45:00.002-04:002016-07-08T15:53:27.446-04:00Bidirectional MIDI Solutions for Lightning Port that Charge Your iPad, iPhone or iPod touch<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAAaATMkJRogERyt64GgT7Ph3CPan8IkocWfjdGBH0ak9AGK-MkEGP9r4dhBIknWOLGkRSZnlZ88vC2R47IMVOuVnMiW6ysn1YO3TlZZMx1aifYpeRsIOqr1xncmAxhk77loSPNitNHjTL/s1600/Lightning-Cable.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAAaATMkJRogERyt64GgT7Ph3CPan8IkocWfjdGBH0ak9AGK-MkEGP9r4dhBIknWOLGkRSZnlZ88vC2R47IMVOuVnMiW6ysn1YO3TlZZMx1aifYpeRsIOqr1xncmAxhk77loSPNitNHjTL/s200/Lightning-Cable.png" width="200" height="185" /></a></div><BR>
<iframe allowfullscreen="" frameborder="1" height="910" src="https://workflowy.com/s/j9eiYVhZnG" width="100%"></iframe>
Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-46199304666336746632016-07-08T15:45:00.001-04:002016-07-08T15:48:36.585-04:00Bidirectional iOS MIDI<iframe width="100%" height="910" src="https://workflowy.com/s/j9eiYVhZnG" frameborder="1" allowfullscreen style=""></iframe>
Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-5527953879149764432016-07-05T14:14:00.000-04:002016-07-05T14:17:40.980-04:00Making a Bookmarklet in Chrome for Workflowy<iframe width="100%" height="910" src="https://workflowy.com/s/I8P2E9vp9Z" frameborder="1" allowfullscreen style=""></iframe>Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-89291012878089218262016-06-16T11:22:00.001-04:002016-06-16T13:16:19.255-04:00My Workflowy Hacks for MacA lot of the stuff here can be used on Windows and Linux, too.
<iframe width="100%" height="910" src="https://workflowy.com/s/K4NPPttrmW" frameborder="1" allowfullscreen style=""></iframe>Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-86453280190155413962016-06-15T13:39:00.000-04:002016-06-15T13:46:25.105-04:00Embed Images and iFrames in Workflowy<h2>
The Workflowy Embed JavaScript, a Modification (WorkflowyPlus Refac)</h2>
I finally got around to modifying <a href="http://code.wizmann.tk/Home/Code?guid=6019504a-71d5-42b6-951c-5f60ccac3061">a script that I've been using for Workflowy to embed images and iframes</a>.<br />
<br />
Mine has three basic differences:<br />
<ol>
<li>No more markdown tags. The tags are now <span style="font-family: "courier new" , "courier" , monospace;">image:</span> or <span style="font-family: "courier new" , "courier" , monospace;">iframe:</span>, e.g., <span style="font-family: "courier new" , "courier" , monospace;">image:http://example.com/image.jpg</span>. </li>
<li>There's a Show (and Hide) button to toggle the image or iframe's visibility </li>
<li>The images and iframes start as hidden by default, which is less disruptive of WF's normal behavior. </li>
</ol>
I'm loving it, but developers do tend to get addicted to things they make (or even modify). Enjoy!<br />
<br />
<h2>
The Workflowy Embed JavaScript in Pictures</h2>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://camo.githubusercontent.com/fc909f6d964d38e13b4bde09d3e4090f533a4561/687474703a2f2f692e696d6775722e636f6d2f6669677a494e532e706e67" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="325" src="https://camo.githubusercontent.com/fc909f6d964d38e13b4bde09d3e4090f533a4561/687474703a2f2f692e696d6775722e636f6d2f6669677a494e532e706e67" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The Script in Action</td></tr>
</tbody></table>
<br />
<h2>
The Workflowy Embed JavaScript for Use in Tampermonkey</h2>
<br />
<script src="https://gist.github.com/drosenstark/66a40d35d32eaa28ec9727e38125fed5.js"></script>
Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-75482855948549652062016-06-10T14:41:00.000-04:002016-06-15T13:41:40.631-04:00Embed Google Docs in Blogger Etc.<iframe id="google-doc-iframe" src="http://dr2050.com/blankPage.html" style="width: 100%; height: 1100px; border: 0px"></iframe>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
var $j = jQuery.noConflict();
var iFrameSelector = "#google-doc-iframe";
var iFrameUrl = "https://docs.google.com/document/d/16S_b2IpkDEBz9NM5dFI4rzq-a_OWDGIMW7Ryld9lHtI/pub?embedded=true";
$j(function() {
$j.get(iFrameUrl, function(html) {
$j(iFrameSelector).attr("srcdoc", html);
setTimeout(function() {
$j(iFrameSelector).contents().find('a[href^="http://"]').attr("target", "_blank");
$j(iFrameSelector).contents().find('a[href^="https://"]').attr("target", "_blank");
}, 1000);
});
});
</script>
Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-50309545367725412832016-06-08T13:41:00.000-04:002016-06-15T13:42:21.164-04:00Punching with Photoshop Using Layer Masks<iframe width="100%" height="1500" src="https://www.evernote.com/shard/s6/sh/4ba7f2a5-377b-4d2f-9f14-c5855fc0c530/f7ac8abe6275aaf8.html" frameborder="0" allowfullscreen></iframe>Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-91801732815074264192016-05-25T14:11:00.002-04:002016-05-25T14:11:44.203-04:00Photoshop CC 2015 Punching with Shapes<iframe width="100%" height="1500" src="https://www.evernote.com/shard/s6/sh/c7658df7-cee6-4c76-8a91-a5f8495efd11/563f29e6ac5930d6.html" frameborder="0" allowfullscreen></iframe>Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-33689769192238144972016-05-25T14:06:00.000-04:002016-06-16T13:16:33.718-04:00Embed Evernote Notes in an iFrame<iframe width="100%" height="910" src="https://workflowy.com/s/QED64GQpkv" frameborder="1" allowfullscreen style=""></iframe>Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-6116844459562224402016-05-25T14:02:00.000-04:002016-05-25T14:03:30.984-04:00Punching with Photoshop Using Layer Masks<iframe width="100%" height="1500" src="https://www.evernote.com/shard/s6/sh/4ba7f2a5-377b-4d2f-9f14-c5855fc0c530/f7ac8abe6275aaf8.html" frameborder="0" allowfullscreen></iframe>Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-57314611483783028922016-05-08T16:03:00.000-04:002016-06-16T13:16:19.249-04:00Pseudo-unique ID script for OSXI use this to get unique IDs that I write on paper and link me back to Workflowy.<BR>
<script src="https://gist.github.com/drosenstark/245a4d4e545ce96969a57dee9cef6d52.js"></script>
It's pretty simple but extremely useful.
<img src="http://dr2050.com/automatic-images/psuedo-unique-id.png" width="500"/>Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-57695095355573610392016-03-30T20:51:00.000-04:002016-03-30T20:51:30.528-04:00Closures and Weak Capture Semantics in Swift<iframe width="100%" height="910" src="https://workflowy.com/s/sarFLQOMIM" frameborder="1" allowfullscreen style=""></iframe>Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-87880545300636900382015-10-17T15:59:00.000-04:002016-11-30T17:58:23.262-05:00Import Swift to Objective-C, Multiple Modules<iframe width="100%" height="1500" frameborder="0" src="https://www.evernote.com/shard/s6/sh/6e114e28-66f4-4aa1-b1ea-63da0c20da95/60d1cfe591deca22.html"></iframe>Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com2tag:blogger.com,1999:blog-4057906405003000972.post-58957064052548586032015-09-17T11:39:00.000-04:002015-09-17T11:45:16.717-04:00Password Assistant on OSX<ul>
<li>Open Keychain Access</li><li>File -> New Password Item</li><li>Turn on "Show Typing" and Click the "Password" link</li><li>Fiddle with the settings and then you can copy it</li>
<img src="http://dr2050.com/notes/Password%20Assistant%20on%20OSX.resources/984D7E27-1ACB-40AB-BFE3-D0FAA7380249.png" width="500" />
</ul>
Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-69119834002314633472015-08-24T15:44:00.000-04:002016-06-16T13:16:33.730-04:00Use Markdown in Evernote<h3>
<span style="background-color: white;">New Instructions </span></h3>
<div>
<span style="background-color: white;"><i>Updated 2015-08-24: textutil needs to be informed of input format and Evernote has changed.</i></span><br />
<span style="background-color: white;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimP4uHD4gNf4DB0vitocY6EoyAxjA5OQc88ToHKfyLz2a4Mcpc3FnzzNz-chIVn4TwFMlZyHre65RZsDAG7J8TeiXtC5f3BKCuZbZBt619w7LEFrL9rrDXezyU-BWGeTL2I2lKB5eKsd26/s1600/markdown.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimP4uHD4gNf4DB0vitocY6EoyAxjA5OQc88ToHKfyLz2a4Mcpc3FnzzNz-chIVn4TwFMlZyHre65RZsDAG7J8TeiXtC5f3BKCuZbZBt619w7LEFrL9rrDXezyU-BWGeTL2I2lKB5eKsd26/s1600/markdown.png" /></a></div>
<span style="background-color: white;"><br /></span>
<span style="background-color: white;"><br /></span>
<span style="background-color: white;">I love Brett Terpstra's <a href="http://markedapp.com/">Marked</a>, and its integration with Evernote is barebones and cool. Anyway, the instructions are:</span><br />
<div>
<ol>
<li><span style="background-color: white;">Get the </span><span style="font-family: Courier New, Courier, monospace;">everwatch-turbo.rb</span> script and put it in your <span style="font-family: Courier New, Courier, monospace;">~/scripts</span> directory (below or <a href="https://gist.github.com/drosenstark/a95519298d915cd85c51">here on GitHub</a>)</li>
<li><span style="background-color: white;">Create a directory called <span style="font-family: Courier New, Courier, monospace;">~/evernote-to-marked</span></span></li>
<li><span style="background-color: white;">Run it in the background by using this in terminal (adjust if your directory is different)</span><span style="background-color: white;"><br /><span style="font-family: courier new, monospace;"><span style="line-height: 18px;">~/scripts/everwatch-turbo.rb &</span></span></span></li>
</ol>
</div>
</div>
<script src="https://gist.github.com/drosenstark/a95519298d915cd85c51.js"></script>
Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0tag:blogger.com,1999:blog-4057906405003000972.post-6151027202011712502015-05-27T13:22:00.000-04:002015-05-27T13:28:21.636-04:00One of Them, One of Those, or Nothing in SwiftThis is a simple data structure in swift which will store one of these -- an NSObject -- one of those (a String) or nothing at all (nil).
<br /><br/>
<script src="https://gist.github.com/drosenstark/60e54c1aa38234fa6133.js"></script>
Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0New York, NY, USA40.7127837 -74.00594130000001840.3275822 -74.651388300000022 41.097985200000004 -73.360494300000013tag:blogger.com,1999:blog-4057906405003000972.post-3093986355414234062015-05-20T16:17:00.001-04:002015-07-15T17:55:26.713-04:00MMWormhole in Swift<a href="http://stackoverflow.com/a/30359529/8047">My Answer on Stack Overflow
<img src="http://dr2050.com/automatic-images/ios_-_How_do_I_exactly_use_MMWormhole_with_Swift__-_Stack_Overflow.png" width="500"/>
</a>Dan Rosenstarkhttp://www.blogger.com/profile/00767517859104928654noreply@blogger.com0