Skip to content

Instantly share code, notes, and snippets.

@jasonsilberman
jasonsilberman / server.swift
Created July 26, 2016 22:59
Pseudo code for how I would like to write a server in Swift
var server = Squid.Server()
var router = Squid.Router()
router.get('/login') {
return Authentication.Login(originalURL: $0.originalURL)
}
router.get('/post/:int') {
return Post.Single(postID: $1) // $1 has type of Int
require 'openssl'
require 'Base64'
key = "secret-key"
data = "some data to be signed"
Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), key, data)).strip()
@interface Window : UIWindow
@end
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
sass = require('gulp-sass');
gulp.task('compress-js', function () {
gulp.src('assets/js/*.js')
.pipe(uglify())
.pipe(gulp.dest('build/js'));
});
module.exports = function (grunt) {
// MAIN
grunt.initConfig({
uglify: {
build: {
src: 'assets/js/app.js',
dest: 'build/js/app.min.js'
}
},
Note *note = // .. original note
Note *noteCopy = [note copy];
Note *secondNoteCopy = [note copy];
// Are noteCopy and secondNoteCopy equal?

Keybase proof

I hereby claim:

  • I am jasonsilberman on github.
  • I am j99 (https://keybase.io/j99) on keybase.
  • I have a public key whose fingerprint is 9AB7 51EC F6A8 8867 C786 8570 D748 8E25 43EF 3451

To claim this, I am signing this object:

@jasonsilberman
jasonsilberman / crash
Created August 7, 2014 16:40
Chocolate Crash Gist
Application Specific Information:
objc[7413]: garbage collection is ON
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSPopover showRelativeToRect:ofView:preferredEdge:]: nil view provided. You must supply a view.'
terminating with uncaught exception of type NSException
abort() called
Application Specific Backtrace 1:
0 CoreFoundation 0x00007fff8941fbec __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff88ef670e objc_exception_throw + 43
2 AppKit 0x00007fff8c7c19ae -[NSPopover showRelativeToRect:ofView:preferredEdge:] + 2435
class DB {
protected static $dbn;
public static function connect() {
$p = Config::valueForKeyPath('db');
static::$dbn = new PDO('mysql:host=' . $p['host'] . ';dbname=' . $p['database'], $p['user'], $p['pass']);
static::$dbn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return true;
}
public static function close() {
static::$dbn = null;
var crypto = require('crypto');
var assert = require('assert');
var algorithm = 'aes256'; // or any other algorithm supported by OpenSSL
var key = 'password';
var text = 'I love kittens';
var cipher = crypto.createCipher(algorithm, key);
var encrypted = cipher.update(text, 'utf8', 'hex') + cipher.final('hex');
var decipher = crypto.createDecipher(algorithm, key);