Skip to content

Instantly share code, notes, and snippets.

Avatar

Joe H. Rahme joehakimrahme

  • Red Hat
  • Milano
View GitHub Profile
View gist:593b2ce886f4ff8ca24a04c939ab433e
~/src/Game_of_Life% git diff
diff --git a/script.js b/script.js
index a57a343..5045273 100644
--- a/script.js
+++ b/script.js
@@ -14,12 +14,12 @@ c.lineWidth=2;
function addsquare(){
- c.fillRect(302,302,46,46);
View gist:787a24a148d3066c432e753aa6255c60
// Write a function that prints the n first even numbers starting with 0
function printPilou(y) {
function partialPilou(n, i) {
if (n == 0) {
return
}
console.log(i);
partialPilou(n-1, i+2);
}
partialPilou(y, 0);
View mkjail.sh
#!/bin/sh
# name: mkjail.sh
# Creates a minimal environment based on the host binaries. So far
# this has only been tested on Fedora27
set -xe
default_bins="ls bash env cat less"
@joehakimrahme
joehakimrahme / Random theme loader
Last active Jun 8, 2017
I created this function to apply a random theme to Emacs.
View Random theme loader
(defun load-random-theme ()
"Load any random theme from the available ones."
(interactive)
;; disable any previously set theme
(if (boundp 'theme-of-the-day)
(progn
(disable-theme theme-of-the-day)
(makunbound 'theme-of-the-day)))
View index.rst

Bienvenue à la documentation de Hy !

Hy logo

@joehakimrahme
joehakimrahme / staticweb blog
Created Sep 18, 2013
Create 3 files and upload them to a Swift container
View staticweb blog
$ cat index.html
<h1>Index file</h1>
<p>This is the index.html file.</p>
$ cat listing.css
h1 {color: red;}
$ cat 404error.html
<h1>404 File not found!</h1>
<p>We couldn't locate the file you're asking for.</p>
View gist:5885156
(defn trampoline [func]
(defn trampolined-func [*args]
(setv f (func *args))
(while (callable f)
(setv f (f)))
f)
trampolined-func)
(with-decorator trampoline
View gist:5853968

yield without the do

=> (defn foo [n]
... (if (< n 10) (yield n)))
Traceback (most recent call last):
  File "/Users/joehakimrahme/.venv/hy/lib/python2.7/site-packages/hy/importer.py", line 45, in ast_compile
    return compile(ast, filename, mode, __future__.CO_FUTURE_DIVISION)
SyntaxError: 'return' with argument inside generator (<console>, line 2)
@joehakimrahme
joehakimrahme / game_life.js
Created Sep 18, 2012
Conway's Game of life
View game_life.js
function draw_matrix(context, matrix, startx, starty, cellsize)
{
var x = startx;
var y = starty;
var colors = ['yellow', 'red'];
for (var i=0; i<matrix.length; ++i) {
line = matrix[i];
for (var j=0; j<line.length; ++j) {
@joehakimrahme
joehakimrahme / inc_rand_mat.js
Created Sep 18, 2012
Incremental random matrix
View inc_rand_mat.js
function draw_matrix(context, matrix, startx, starty, cellsize)
{
var x = startx;
var y = starty;
var colors = ['yellow', 'red'];
for (var i=0; i<matrix.length; ++i) {
line = matrix[i];
for (var j=0; j<line.length; ++j) {