Skip to content

Instantly share code, notes, and snippets.

Avatar

Sandro Pasquali sandro-pasquali

View GitHub Profile
View API.swift
//
// API.swift
//
// Created by Taro Minowa on 6/10/14.
// Copyright (c) 2014 Higepon Taro Minowa. All rights reserved.
//
import Foundation
typealias JSONDictionary = Dictionary<String, AnyObject>
View web_crypto_api_example.js
var string = new Uint8Array([0x01, 0x02]);
var data = new Uint8Array([0x03, 0x04, 0x05]);
var handle_error = function (error) {
cnosole.log("Error:");
console.log(err);
};
window.crypto.subtle.digest({name: "SHA-256"}, string).then(function (hash) {
console.log("SHA-256:");
View gist:b6b3dd1cd5dcff310b23

Code example using WebCrypto, File API, indexedDB, createObjectURL and Workers.

<input type="file" onsubmit="process_upload">
var workerjs=' \
  onmessage=function(evt) { \
		var encrypt=crypto.workersubtle.encrypt({name:"AES-CBC",iv:new Uint8Array(16)},evt.data[0]); \
		var buffer=evt.data[1]; \
View ordered permutations
function powerSet(list) {
var set = [];
var listSize = list.length;
var combinationsCount = 1 << listSize;
var combination;
var i = 1;
var j;
for(; i < combinationsCount; i++ ) {
@sandro-pasquali
sandro-pasquali / css
Created Sep 13, 2013
Cross-browser CSS-loaded detector, without browser sniffing.
View css
#targ {
position: absolute;
}
View twitter_streaming.js
var util = require('util'),
http = require('http'),
events = require('events');
var Twitter = function(opts) {
this.username = opts.username;
this.password = opts.password;
this.track = opts.track;
this.data = '';
};
View nrmp php
<?
class Match {
public $candidatearray;
public $programarray;
public function __construct($candidatearray, $programarray) {
$this->candidatearray = $candidatearray;
@sandro-pasquali
sandro-pasquali / example2.js
Created Nov 15, 2012 — forked from thefonso/example2.js
MongoDB map reduce example 2
View example2.js
// suggested shell cmd line to run this:
//
// mongo --shell example2.js
//
// Note: the { out : … } parameter is for mongodb 1.8+
db.things.insert( { _id : 1, tags : ['dog', 'cat'] } );
db.things.insert( { _id : 2, tags : ['cat'] } );
db.things.insert( { _id : 3, tags : ['mouse', 'cat', 'dog'] } );
db.things.insert( { _id : 4, tags : [] } );
View mies.subscribing
mies.subscribe("/my/route")
You can’t perform that action at this time.