Skip to content

Instantly share code, notes, and snippets.

Example = {};
Example.button = function(el) {
el.onclick = this.click;
}
Example.button.prototype.click = function() {
alert('YOU CLICK DA BUTTON');
}
@jpoz
jpoz / User.m
Created October 21, 2011 19:49
#import "User.h"
@implementation User
@synthesize name = _name;
@synthesize email = _email;
@synthesize device_id = _device_id;
+ (User*) current_user {
def cipher(mode, salt, pepper, iv)
@cipher = OpenSSL::Cipher::Cipher.new('aes-128-cbc')
if mode
@cipher.encrypt
else
@cipher.decrypt
end
# @cipher.padding=1
key = Digest::SHA1.hexdigest(salt + pepper)
static VALUE
ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode)
{
EVP_CIPHER_CTX *ctx;
unsigned char key[EVP_MAX_KEY_LENGTH], *p_key = NULL;
unsigned char iv[EVP_MAX_IV_LENGTH], *p_iv = NULL;
VALUE pass, init_v;
if(rb_scan_args(argc, argv, "02", &pass, &init_v) > 0){
/*
@key = EzCrypto::Key.with_password "special", "secretzz"
info = @key.encrypt("sensitive information")
encrypted = Base64.encode64(info)
var current_date = new Date;
// Thu Jun 23 2011 11:35:42 GMT-0700 (PDT)
current_date - 3600000 // minus an hour
// => 1308850542267
current_date + 3600000 // plus an hour
// => "Thu Jun 23 2011 11:35:42 GMT-0700 (PDT)3600000" ARE YOU KIDDING ME!!!
current_date - (-3600000) // plus an hour wtfjs
function valididate_dependent(select, textarea, hidden) {
if (select.val() == 'No' || textarea.val() != "" ) {
hidden.val('N/A');
textarea.removeClass('error');
} else {
hidden.val('');
textarea.addClass('error');
}
}
var kiwi = require('kiwi'),
redis = kiwi.require('redis-client'),
client = redis.createClient(),
sys = require('sys');
client.rpush("rev::revisions", "party", function(err, value) {
client.lrange("rev::revisions", 0, 1, function(err, data) {
sys.puts( JSON.stringify(data) ) // [{"0":112,"1":97,"2":114,"3":116,"4":121,"length":5}]
client.close();
})
var kiwi = require('kiwi')
kiwi.require('express')
get('/', function(){
this.redirect('/hello/world')
})
get('/hello/world', function(){
return 'Hello World'
})
We couldn’t find that file to show.