Skip to content

Instantly share code, notes, and snippets.

@mdciotti
mdciotti / scrape.coffee
Created December 15, 2012 00:36
Scrape HAC for grades, uses an ugly hierarchical method that probably is broken right now
# casperjs ~/dev/scrape.coffee --ignore-ssl-errors=true
utils = require('utils')
casper = require('casper').create
remoteScripts: [
'//cdnjs.cloudflare.com/ajax/libs/zepto/1.0rc1/zepto.min.js'
]
verbose: true
logLevel: "debug"
loadImages: false

Keybase proof

I hereby claim:

  • I am mdciotti on github.
  • I am mdciotti (https://keybase.io/mdciotti) on keybase.
  • I have a public key whose fingerprint is 5B7A 9BBE C0E3 9EE3 322F 011C 8AC8 D94E 8A1C 957D

To claim this, I am signing this object:

#include <stdio.h>
#include <stdlib.h>
unsigned long long int reduce (unsigned long long int n)
{
unsigned long long int result, d;
result = 1;
while (n > 0) {
function hash (s) {
var h = 7;
var letters = "acdegilmnoprstuw";
for (var i = 0; i < s.length; i++) {
h = (h * 37 + letters.indexOf(s[i]));
}
return h;
}
@mdciotti
mdciotti / hexconverter.js
Created October 16, 2015 06:22
Converts hexadecimal-formatted strings to numbers and back
Number.prototype.toHex = function (padSize) {
if (padSize == undefined) padsize = 1;
var hex = this.toString(16).toUpperCase();
while (padSize > hex.length) {
hex = "0" + hex;
}
return hex;
};
String.prototype.toHex = function () {
/* SEARCH QUERY BISON SOURCE */
%left '|'
%left '&' '!'
%left '(' ')'
%start file
%%
require 'set'
require 'json'
class QueryHandler
def initialize (indexPath, tagPath)
index_get indexPath
tags_get tagPath
end
def parse_json (path)
@mdciotti
mdciotti / lattice-paths.c
Created October 16, 2015 06:39
Calculates the number of paths in a n*n (square) lattice
#import <stdio.h>
#import <stdlib.h>
#import <math.h>
// Retuns the number of paths in a n*n (square) lattice
// Paths can only move rightward or downward
// Paths start at top left and end at bottom right
// Receives an argument `n` which is the length of one side of the square lattice
@mdciotti
mdciotti / fib.cpp
Created September 12, 2016 18:48
Fibonacci Number Generators
// Recursive 1
int rFibNum(int a, int b, int n)
{
if (n == 1)
return a;
else if (n == 2)
return b;
else
return rFibNum(a, b, n - 1) + rFibNum(a, b, n - 2);
}
@mdciotti
mdciotti / FakeAPI.js
Created April 26, 2019 14:45
Mock API for testing
/**
* Simulates asynchronous data loading by wrapping setTimeout in a Promise.
* @param {Number} ms the delay in milliseconds to wait before resolving
* @param {any} data the data to resolve with
* @returns {Promise} a promise that resolves with `data` in `ms` milliseconds
*/
async function asyncData(ms, data) {
await new Promise(r => setTimeout(r, ms));
return data;
}