A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| - (NSAttributedString *)loadContent { | |
| NSString *filePath = [[NSBundle mainBundle] pathForResource:@"input" ofType:@"html"]; | |
| NSData *htmlData = [NSData dataWithContentsOfFile:filePath]; | |
| NSDictionary *options = @{ | |
| NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, | |
| NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding) | |
| }; | |
| // clang -fobjc-arc -framework Foundation runtime-class.m | |
| #import <Foundation/Foundation.h> | |
| #import <objc/runtime.h> | |
| @interface Person : NSObject | |
| - (id)initWithFirstName: (NSString *)firstName lastName: (NSString *)lastName age: (NSUInteger)age; |
| static Boolean PSPDFCaseInsensitiveEqualCallback(const void *a, const void *b) { | |
| id objA = (__bridge id)a, objB = (__bridge id)b; | |
| Boolean ret = FALSE; | |
| if ([objA isKindOfClass:NSString.class] && [objB isKindOfClass:NSString.class]) { | |
| ret = ([objA compare:objB options:NSCaseInsensitiveSearch|NSLiteralSearch] == NSOrderedSame); | |
| }else { | |
| ret = [objA isEqual:objB]; | |
| } | |
| return ret; | |
| } |
| // C++11 lambdas aren't terribly useful at producing art. | |
| // Source below is valid C++11. VS2013 takes about a minute at it (Release config), | |
| // reaches almost 4GB of memory usage and then gives a | |
| // | |
| // 1>ConsoleApplication1.cpp(34): fatal error C1001: An internal error has occurred in the compiler. | |
| // 1> (compiler file 'msc1.cpp', line 1325) | |
| // 1> To work around this problem, try simplifying or changing the program near the locations listed above. | |
| // 1> Please choose the Technical Support command on the Visual C++ | |
| // 1> Help menu, or open the Technical Support help file for more information | |
| // 1> This error occurred in injected text: |
| # alias to edit commit messages without using rebase interactive | |
| # example: git reword commithash message | |
| reword = "!f() {\n GIT_SEQUENCE_EDITOR=\"sed -i 1s/^pick/reword/\" GIT_EDITOR=\"printf \\\"%s\\n\\\" \\\"$2\\\" >\" git rebase -i \"$1^\";\n git push -f;\n}; f" | |
| # release alias with tagging | |
| # usage: git release v2.3.0 "Finalized API and added documentation" ./docs.zip | |
| release = !f() { tag="$1"; title="$2"; shift 2; gh release create "$tag" --target $(git rev-parse HEAD) -t "$title" --generate-notes "$@"; }; f | |
| # usage gh lockdown | |
| # git alias to disable wikis, issues, projects for existing repos |
| #!/bin/sh | |
| # | |
| # Trigger an update of MAS (and softwareupdate) apps | |
| # | |
| # This seems to be all that's needed to schedule an immediate update of | |
| # MAS apps. This should be run as a normal user. You can run this and | |
| # tail the install log to get an idea of what's happening. | |
| # | |
| # You can also take a look at this user's ~/Library/Caches/com.apple.storagent | |
| # directory to get a report on what apps were available, installable, etc. |
| // Continuously changing GIST of UIWebView 'tweaks' I use. Might be useful to others, | |
| // hope Google finds this. Some of these already passed Review, but one never knows ;). | |
| // Happy coding! | |
| - (void)ScrollView_setContentOffset:(CGPoint)offset { | |
| // Prevent superfluous scrolling animations (eg when toggling keyboard) by completely disabling scrolling. We achieve scrolling through inner scroll views (overflowing html elements). | |
| } | |
| - (id)WebBrowserView_inputAccessoryView { | |
| // Make the keyboard accessory view (next/prev,submit buttons) optional, it really takes up to much screen estate in a normal app. |
| struct S0<V> { | |
| typealias F = () -> V | |
| } | |
| struct S1<T1,V>{ | |
| typealias F = (T1) -> V | |
| } | |
| //0, 0 | |
| func curry<T1, V>(f: S1<T1, V>.F, a1:T1) -> S0<V>.F { |
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| #!/usr/bin/env bash | |
| # Xcode scripting does not invoke rvm. To get the correct ruby, | |
| # we must invoke rvm manually. This requires loading the rvm | |
| # *shell function*, which can manipulate the active shell-script | |
| # environment. | |
| # cf. http://rvm.io/workflow/scripting | |
| # Load RVM into a shell session *as a function* | |
| if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then |