Hi, my name is Daniel Skantze, I work as Head of Tech at Greatworks. I had lots of stuff I wanted to jot down and I didn't really know where so I started this page. As it turns out it has become more focused on code (primarily IOS, PHP, Wordpress, Javascript and Python) but you will also see stuff such as my flickr feed here. I am also into music production (fingertwister@soundcloud) as well photography (my photo blog here).
Don't wanna be here? Send us removal request.
Link
Nice inspiration on how to write command line tools in nodejs
3 notes
·
View notes
Link
Unqiue conditions for CoreData
2 notes
·
View notes
Link
I wrote my first Chrome Plugin. I use a Garmin FR 235 watch to track my runs. Through Garmin's apps each run is saved to Garmin Connect - their cloud platform. I use many apps to analyze my training data and I usually export activities as .tcx-files which is a general format for training data containing a sequence of GPS coordinates, heart rate data and some more.
It is possible to export to TCX from Garmin Connect but unfortunately it is only possible to export one activity at a time.
So there is where the chrome plugin comes into the picture. With it, you can select a bunch of activities and download them as a zip-file.
https://chrome.google.com/webstore/detail/garmin-activity-downloade/himhggflahpnjikoddlngaopcigalcjh
2 notes
·
View notes
Text
iOS Simulator / CoreData - sqlite document folder
Pretty often I use Sqlite Manager for Firefox to check the CoreData sqlite files that I create in apps I build. It is quite a struggle to find out the document folder of the simulator apps since the path is pretty deep and there are some uuids involved.
So I wrote the following scripts to make this process a bit easier:
List the last 10 modified simulator sqlite files:
#!/bin/bash SIMULATOR_FOLDER=~/Library/Developer/CoreSimulator/Devices find $SIMULATOR_FOLDER -name "*.sqlite" -print0 | \ xargs -0 stat -f '%i -- %N' |\`` sort | \ grep Application | \ tail -n 10 | \ sed -e 's/[0123456789]* -- \(.*\)/\1/'
Copy the folder of the last modified sqlite file to the clipboard
#!/bin/bash SIMULATOR_FOLDER=~/Library/Developer/CoreSimulator/Devices \ LAST_FOLDER=$(find $SIMULATOR_FOLDER -name "*.sqlite" -print0 | \ xargs -0 stat -f '%i -- %N' | sort | grep Application | tail -n 1 | \ sed -e 's/[0123456789]* -- \(.*\)/\1/' | \ xargs -0 dirname) echo $LAST_FOLDER | pbcopy echo $LAST_FOLDER " was copied to clipboard"
0 notes
Text
Saving an iPod Shuffle
I recently found my old iPod Shuffle in a drawer. It came in very handy since I do a lot of running and I no longer use my iPhone to track my runs (the battery drain for a 1 hour+ run is just insane - can't take it anymore so I now use a Garmin watch instead).
But there was a minor issue... While the music on the iPod played fine iTunes refused to recognize it. It showed up in the device manager and all but no luck with iTunes.
Without being able to change music on it I was pretty much out of luck.
I got the feeling that Apple had done this on purpose to make me buy a new one (this one was about 8 years old) so it really bugged me.
So anyway, I was thinking I maybe could access it from Linux instead. I found the GTKPod-package. After hassling a bit with booting my Mac from a Linux USB stick I was good to go.
I accidentally installed Ubuntu 16 and apparently it was missing some of the repositories for gtkpod. I tried to compile it but it turned out to be easier just to add the missing repository (the link below should contain the link to the repository)
But I was still out of luck. It turned out to be the libgpod version - the newer versions does not seem to support the iPod Shuffle 2nd generation properly. I found the answer in this thread: http://ubuntuforums.org/showthread.php?t=1333161
In particular it is Br0ziliy reply that gave me the answer: First install gtkpod:
sudo apt-get install gtkpod
Then install the old version of libgpod:
sudo apt-get install intltool libglib2.0-dev libplist-dev wget "http://sourceforge.net/projects/gtkpod/files/libgpod/\ libgpod-0.7.9x/libgpod-0.7.90.tar.gz/download" mv download libgpod-0.7.90.tar.gz tar zxvf libgpod-0.7.90.tar.gz cd libgpod-0.7.90/ ./configure --prefix=/opt/ make sudo make install
And then create a start script:
cat > /tmp/gtkpod<<EOF #!/bin/bash LD_PRELOAD=/opt/lib/libgpod.so.4.2.0 /usr/bin/gtkpod.bin EOF chmod 755 /tmp/gtkpod sudo mv /usr/bin/gtkpod /usr/bin/gtkpod.bin sudo mv /tmp/gtkpod /usr/bin/gtkpod
0 notes
Link
Note to self - remember to set kSecAttrAccount and kSecAttrService when working with the keychain.
1 note
·
View note
Text
I was building a paged scrollview where I needed to temporarily suspend the scroll in one direction. More specifically, I was building some signup forms and I wanted to disable swipe to the next page until the user has entered all data for the current page.
For various reasons I needed to populate the entire scroll view with all pages in advance so just adding stuff to it as the user wen along was not really an option.
Here is the code snippet I came up with.
The basic idea is to check if we are at the last available page, check the direction the user scrolled in. If the user tried to scroll past the last avaialble page, reset the scroll view content offset to the offset of the current page.
The scrollEnabled stunt is needed to avoid the page scroll deceleration offsetting the scroll view (try to remove it and you will see what I mean).
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
// disable scroll to next page if needed if (self.numAvailablePages <= (self.pageControl.currentPage + 1)) { if (self.scrollView.contentOffset.x >= self.currentScrollOffset.x) { self.scrollView.contentOffset = self.currentScrollOffset; UIScrollView* sv = self.scrollView; sv.scrollEnabled = NO; [[NSOperationQueue mainQueue] addOperationWithBlock:^{ sv.scrollEnabled = YES; }]; } } }
0 notes
Link
In short: Game changer in the ssl world. May actually make ssl available for everyone.
0 notes
Link
I cannot believe I missed this.
0 notes
Text
Cocoapods assertion failure
In XCode 7.0 I needed to update my pods. I ran:
pod update
But got the following error
ruby[13920:2020230] [MT] DVTAssertions: ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-8227/IDEFoundation/Initialization/IDEInitialization.m:590 Details: Assertion failed: _initializationCompletedSuccessfully Function: BOOL IDEIsInitializedForUserInteraction() Thread: <nsthread:>{number = 1, name = main} Hints: None Backtrace: 0 0x000000010917aa5c -[DVTAssertionHandler handleFailureInFunction:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in DVTFoundation) 1 0x000000010917a1e9 _DVTAssertionHandler (in DVTFoundation) 2 0x000000010917a455 _DVTAssertionFailureHandler (in DVTFoundation) 3 0x000000010917a3b7 _DVTAssertionFailureHandler (in DVTFoundation) 4 0x000000010ae42f5c IDEIsInitializedForUserInteraction (in IDEFoundation) 5 0x000000010da59eb9 +[PBXProject projectWithFile:errorHandler:readOnly:] (in DevToolsCore) 6 0x000000010da5ba3e +[PBXProject projectWithFile:errorHandler:] (in DevToolsCore) 7 0x00007fff8eb3bf44 ffi_call_unix64 (in libffi.dylib)
I tried gem install xcodeproj, xcode-select -r and a few other things but nothing solved it.
It turned out I needed to re-install cocoapods from scratch:
sudo gem uninstall cocoapods
sudo gem install cocoapods
pod install
0 notes
Text
ffmpeg downscaling command
The ffmpeg scale filter parameters are not very well documented. Especially not how to add them as filter_complex params, there are not many examples and so on.
Downscaling is an interesting topic and the difference is HUGE if you compare downscaling out of the box with downscaling using tweaked parameters.
This snippet scales input.mov to 960x540 using a lanczos algorithm doing full chroma interpolation and so on.
ffmpeg -i input.mov \ -filter_complex 'scale=w=960:h=540:'\ 'flags=lanczos+full_chroma_int+full_chroma_inp+accurate_rnd:'\ 'src_range=0:dst_range=1' \ -c:v libx264 \ -preset slow \ -crf 20 \ output.mp4
(To be honest I am not entirely sure on what the src_range and dst_range parameters do but configuring them this way seemed to give a better result, deeper colors or punchier contrast or something like that)
UPDATE: Add this flag to add compatibility with QuickTime player
-pix_fmt yuv420p
0 notes
Link
A presentation on how to render water using webgl
1 note
·
View note
Link
JSON Web Token (JWT) is a compact URL-safe means of representing claims to be transferred between two parties. The claims in a JWT are encoded as a JSON object that is digitally signed using JSON Web Signature (JWS).
2 notes
·
View notes