Skip to content

Instantly share code, notes, and snippets.

View sandro-pasquali's full-sized avatar

Sandro Pasquali sandro-pasquali

View GitHub Profile
//
// 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>
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:");

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]; \
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 September 13, 2013 14:59
Cross-browser CSS-loaded detector, without browser sniffing.
#targ {
position: absolute;
}
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 = '';
};
@sandro-pasquali
sandro-pasquali / nrmp php
Created November 21, 2012 03:24
nrmp in php
<?
class Match {
public $candidatearray;
public $programarray;
public function __construct($candidatearray, $programarray) {
$this->candidatearray = $candidatearray;
@sandro-pasquali
sandro-pasquali / example2.js
Created November 15, 2012 18:33 — forked from thefonso/example2.js
MongoDB map reduce example 2
// 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 : [] } );
@sandro-pasquali
sandro-pasquali / mies.subscribing
Created November 15, 2012 18:09
Subscribing with Mies
mies.subscribe("/my/route")