Skip to content

Instantly share code, notes, and snippets.

View danyshaanan's full-sized avatar

Dany Shaanan danyshaanan

View GitHub Profile
@danyshaanan
danyshaanan / snippets.js
Last active December 19, 2015 19:38
Javascript snippets
'use strict'
// Create a random color:
function color() {
return '#'+(Math.random().toString(16) + '000000').slice(2, 8)
}
for (var i=0; i<10; i++) console.log(color())
@danyshaanan
danyshaanan / RSA_encryption.py
Created September 2, 2013 20:13
Python example of implementation of RSA encryption.
#!/usr/bin/python
from random import choice
# from fractions import gcd #this is slower than the implementation below!!
def gcd(a, b):
while b != 0:
a, b = b, a%b
return a
def coprime(a, b):

July 27th, 2014

Chess and bereavement in Cairo


I've been to Cairo twice. Once in April 2005, and once in September 2010, three months before the events that sparked the Arab Spring. Before we arrived to Cairo, we decided that in public we will speak only English (even though our native tongue is Hebrew) and that we will tell people that we are from Budolina, which is an imaginary kingdom from a book by the same name. We quickly realised, however, that there was no need for any of that. We introduced ourselves as Israelis, and discovered a welcoming, happy people living in a vibrant and wonderful city.

We couldn’t find that file to show.
We couldn’t find that file to show.
'use strict'
const fib = m => (h => h(h, m))((g, n) => n < 2 ? n : g(g, n - 1) + g(g, n - 2))
console.log([0,1,2,3,4,5,6,7].map(fib))
@danyshaanan
danyshaanan / Snake Cube
Last active December 12, 2016 21:26
A Python script to solve the snake cube puzzle: http://en.wikipedia.org/wiki/Snake_cube
We couldn’t find that file to show.
We couldn’t find that file to show.
@danyshaanan
danyshaanan / rip_gists
Last active January 1, 2017 09:35
A NodeJS script to clone/pull all of your public gists at gist.github.com: `node rip_gists.js danyshaanan`.
We couldn’t find that file to show.

Git basics and data structure

Learning Git basics and structure

What is Git?

Git is a Version Control system - a way to manage the changes and progress of a project, so that:

  • We'd know when each change was made, by whom, and why.
  • We'd be able to revert specific changes, even if they were done a while ago.