Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
cd /tmp
rm -rf /tmp/Dux
git clone https://github.com/abhibeckert/Dux.git
cd Dux
xcodebuild -target Dux -configuration Release
rm -r /Applications/Dux.app
mv build/Release/Dux.app /Applications/Dux.app
open /Applications/Dux.app
@abhibeckert
abhibeckert / Sublime Mac Keys
Created February 1, 2013 05:25
Preferences and Key Bindings to make Sublime Text on Linux (and probably Windows) behave like a mac text editor.
// Preferences
{
"drag_text": true,
"find_selected_text": false,
"move_to_limit_on_up_down": true,
}
// Key Bindings
@abhibeckert
abhibeckert / gist:5053904
Created February 28, 2013 03:18
takes an image and crops it to f it your displays on OS X
//
// main.m
// span-image-across-displays
//
// Created by Abhi Beckert on 2013-2-19.
// Copyright (c) 2013 Abhi Beckert. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@import <Foundation/CPObject.j>
@import "PageView.j"
@import "PhotoInspector.j"
@implementation AppController : CPObject
{
}
#import <Foundation/Foundation.h>
#import <Carbon/Carbon.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
// get list of running apps
NSMutableArray *runningApps = [NSMutableArray array];
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[self update];
self.backgroundTaskIdentifier =
[application beginBackgroundTaskWithExpirationHandler:^(void) {
@autoreleasepool {
NSLog(@"begin in background after 10 minutes");
[motionManager stopAccelerometerUpdates];
motionManager.accelerometerUpdateInterval = 0.2f;
[self update2];
//
// DuxTextView.m
// DuxTextView
//
// Created by Abhi Beckert on 19/10/2013.
// Copyright (c) 2013 Abhi Beckert. All rights reserved.
//
#import "DuxTextView.h"
$imgData = file_get_contents($path);
// determine mime type
$magicNumbersToMimeTypes = array(
'474946383761'=>'image/gif', // GIF87a type gif
'474946383961'=>'image/gif', // GIF89a type gif
'89504E470D0A1A0A'=>'image/png', // png
'FFD8FFE0'=>'image/jpeg', // JFIF jpeg
'FFD8FFE1'=>'image/jpeg', // EXIF jpeg
'FFD8FFE8'=>'image/jpeg', // SPIFF jpeg
<?php
$substitution = '5tv0WiPg2YoSNCRzzBUZc7Bozp2WhLmODSMmc8qlTNh8MdUJVyPx9lj3vngJzFn';
$regexPattern = str_replace('*', $substitution, $customRulePattern); // replace "*" with random substitution, to avoid being preg_quote() escaped
$regexPattern = preg_quote($regexPattern); // escape all regex syntax
$regexPattern = str_replace('/', '\/', $regexPattern); // also escape the "/" character, since we are using that as the preg delimiter
$regexPattern = str_replace($substitution, '.*', $regexPattern); // convert $substitution into the correct regex pattern
$regexPattern = "/$regexPattern/s"; // wrap in / and add the "DOTALL" flag
func foo(closure: Void -> Void)
{
closure()
}
// correct syntax
foo({
println("Hello")
})