Skip to content

Instantly share code, notes, and snippets.

<?php
/*
By Marco Arment <me@marco.org>.
This code is released in the public domain.
THERE IS ABSOLUTELY NO WARRANTY.
Usage example:
// In a registration or password-change form:
// Usage example:
// input image: http://f.cl.ly/items/3v0S3w2B3N0p3e0I082d/Image%202011.07.22%2011:29:25%20PM.png
//
// UIImage *buttonImage = [UIImage ipMaskedImageNamed:@"UIButtonBarAction.png" color:[UIColor redColor]];
// .h
@interface UIImage (IPImageUtils)
+ (UIImage *)ipMaskedImageNamed:(NSString *)name color:(UIColor *)color;
@end
@jasonsilberman
jasonsilberman / UILocalNotiication.m
Created March 7, 2014 01:12
Here is my helper function for sending a UILocalNotification, when it gets called while the app is in the background, it does not fire the notification.
- (void)setLocalNotificationForType:(SPKLocalNotificationType)notificationType fromUser:(NSString *)userName withMessageText:(NSString *)msgText {
NSLog(@"setLocalNotificationForType:fromUser:withMessageText:");
if (! useNotifications) { return; }
NSLog(@"setting notif...");
UILocalNotification *notif = [UILocalNotification new];
notif.userInfo = @{@"handle": _convoHandle, @"room": _convoName};
notif.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;
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);
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;
@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

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:

Note *note = // .. original note
Note *noteCopy = [note copy];
Note *secondNoteCopy = [note copy];
// Are noteCopy and secondNoteCopy equal?
module.exports = function (grunt) {
// MAIN
grunt.initConfig({
uglify: {
build: {
src: 'assets/js/app.js',
dest: 'build/js/app.min.js'
}
},
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'));
});