Skip to content

Instantly share code, notes, and snippets.

@AmineS
AmineS / Octave benchmarks CLI
Created August 15, 2013 00:17
To run it: chmod 0755 cholesky.m ./cholesky 1000 3
#!/usr/bin/octave -qf
arg_list = argv ();
scale = str2num(arg_list{1});
iteration = str2num(arg_list{2});
cumulate = 0; b = 0;
for i = 1:iteration
a = randn(scale, scale);
a = a'*a;
@AmineS
AmineS / Waterfall using promises
Created August 11, 2013 23:14
A simple example of how to create a waterfall using promises.
var Q = require('q');
function runTasksSequentially(tasks) {
function run(task) {
var deferred = Q.defer();
setTimeout(function () {
console.log(task);
deferred.resolve(task + 1);
}, 1000);
@AmineS
AmineS / d3 in node
Created August 2, 2013 04:50
Using d3 in node
require("../../test/env");
var fs = require("fs"),
util = require("util"),
Canvas = require("canvas");
var w = 1920,
h = 1080;
var projection = d3.geo.albersUsa()
@AmineS
AmineS / Error handling in Q
Last active December 20, 2015 13:19
Is Q the answer for our error handling? p.s if any method in the chain throws an error it's caught it at the end by fail. This means that you don't need to worry about error handling at every step.
var Q = require('q')
, fs = require('fs');
function add (num1, num2) {
return num1 + num2;
}
function triple (num) {
return num * f3();
}
var Sequelize = require("sequelize");
var sequelize = new Sequelize('db', 'root', 'root', {dialect: 'mysql'});
var Project = sequelize.define('Project', {
title: Sequelize.STRING,
description: Sequelize.TEXT
});
var Task = sequelize.define('Task', {
title: Sequelize.STRING,
@AmineS
AmineS / AES.java
Created July 10, 2013 17:19 — forked from ymnk/AES.java
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/**
* This program will demonstrate how to use "aes128-cbc".
*
*/
import com.jcraft.jsch.*;
import java.awt.*;
import javax.swing.*;
public class AES{