Skip to content

Instantly share code, notes, and snippets.

@matthijn
matthijn / proxy.sh
Created February 22, 2016 02:59
Socks Proxy OSX easy terminal script
#!/bin/bash
#Change OSX Wifi settings to use socks proxy
sudo networksetup -setsocksfirewallproxy "Wi-Fi" localhost 2000
#Setup a socks proxy over ssh to a server (will ask for password and block further execution untill connection is closed)
ssh -N -g -D 2000 user@someserver.com
#Stop using OSX Wifi proxy
sudo networksetup -setsocksfirewallproxystate "Wi-Fi" off
@matthijn
matthijn / whoop.swift
Last active January 21, 2016 18:53
Woop
var foo =
{
get
{
return 10
}
set
{
foo = newValue
}
@matthijn
matthijn / Delay js
Last active November 11, 2015 11:30
/**
* Helper for delaying certain callbacks
* @param callback
* @param delay
* @constructor
*/
define('Delay', [], function()
{
return function(callback, delay)
@matthijn
matthijn / gist:40d2402a75c976a160c7
Created November 26, 2014 20:25
Ruby like regular expression matching for Swift
// Ruby like regular expression matching
infix operator =~ {}
func =~ (input: String, pattern: String) -> Bool
{
return input.rangeOfString(pattern, options: .RegularExpressionSearch) != nil
}
// Example
if "foobaar" =~ "[a-z]*"
{
@matthijn
matthijn / AECurl
Created January 3, 2014 18:42
Curl emulator for App Engine. This is in no way a complete emulation, but it is enough to make the Podio PHP API Client work.
<?php
/* A quick emulator for common curl function so code based on CURL works on AppEngine */
if(!function_exists('curl_init'))
{
// The curl option constants, when there is no curl they are not defined so we define them here
// Some options don't do anything, they just prefent crashes when they are here (see the setOpt method for the support of different options)
define('CURLOPT_RETURNTRANSFER', 'CURLOPT_RETURNTRANSFER');
define('CURLOPT_SSL_VERIFYPEER', 'CURLOPT_SSL_VERIFYPEER');