Skip to content

Instantly share code, notes, and snippets.

View ivanpierre's full-sized avatar
😥
A little ill for some time... but work still in progress as possible... ;)

Ivan Pierre ivanpierre

😥
A little ill for some time... but work still in progress as possible... ;)
View GitHub Profile
;; All the OO stuff
(define (object selector-names . all-selectors)
(define (apply-it selector selector-names selectors parameters)
(cond ((null? selectors) '(I cant do that Dave!))
((equal? selector (car selector-names)) (apply (car selectors) parameters))
(#t (apply-it selector (cdr selector-names) (cdr selectors) parameters))))
(lambda (selector . parameters)
(apply-it selector selector-names all-selectors parameters)))
;; Defining a new object type
@tonious
tonious / hash.c
Last active June 21, 2024 00:57
A quick hashtable implementation in c.
/* Read this comment first: https://gist.github.com/tonious/1377667#gistcomment-2277101
* 2017-12-05
*
* -- T.
*/
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <stdlib.h>
#include <stdio.h>
/*
Here are some methods that work very efficiently and acts as fallback to many fast ass DOM libraries
*/
document.querySelector('selector'); // selector is same as in querySelectorAll()
/*
Usage:
var firstP = document.querySelector('p'); - It gives first 'p' element in Document.
var firstPinsideDiv = someDiv.querySelector('p'); - It gives first 'p' element in someDiv.
@walkermatt
walkermatt / fizzbuzz.clj
Last active July 12, 2017 14:08
fizzbuzz without conditionals in Clojure
;; fizzbuzz without conditionals in Clojure
; Simple patten matching using a single map lookup
(defn fizzbuzz [x]
(let [v [(= (mod x 3) 0) (= (mod x 5) 0)]]
({[true false] "fizz"
[false true] "buzz"
[true true] "fizzbuzz"
[false false] x} v)))
@bishboria
bishboria / springer-free-maths-books.md
Last active June 8, 2024 06:39
Springer made a bunch of books available for free, these were the direct links

Clojure is for Aristotelians

I was reading ["Clojure is for Type B Personalities"][2] and it sparked some thoughts I had about the intersection of western philosophy and programming.

One could say Mathematics is an extension of Epistemology. And all theory about computability are an extension of mathematics. I reckon how one thinks about computability and how one writes computable functions are a reflection of a person's natural epistemological tendencies. This is going to be just as unscientific as ["Clojure is for Type B Personalities"][2], but hopefully another

@jasongilman
jasongilman / atom_clojure_setup.md
Last active May 11, 2024 02:25
This describes how I setup Atom for Clojure Development.

Atom Clojure Setup

This describes how I setup Atom for an ideal Clojure development workflow. This fixes indentation on newlines, handles parentheses, etc. The keybinding settings for enter (in keymap.cson) are important to get proper newlines with indentation at the right level. There are other helpers in init.coffee and keymap.cson that are useful for cutting, copying, pasting, deleting, and indenting Lisp expressions.

Install Atom

Download Atom

The Atom documentation is excellent. It's highly worth reading the flight manual.

# see https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
# core
brew install coreutils
# key commands
brew install binutils
brew install diffutils
brew install ed --default-names
brew install findutils --with-default-names
@reborg
reborg / most-used-fns.clj
Last active January 28, 2019 11:02
Clojure functions usage frequencies
;; The list of (almost) all Clojure public functions and macros ordered by usage. Source: Github code search for Clojure repositories.
(["ns" 394490]
["defn" 293918]
["require" 279210]
["let" 237654]
["def" 172983]
["refer" 163654]
["map" 159781]
["fn" 154482]
@cemerick
cemerick / foo.clj
Last active March 9, 2017 12:20
slightly saner printing for Clojure fns
(defn delegate-printing-for
"Registers the necessary methods to delegate printing of instances of [class] to [fn]."
[class fn]
#?@(:clj [(defmethod print-method class
[x writer]
(.write ^java.io.Writer writer (fn x)))
(defmethod print-dup class
[x writer]
(print-method x writer))
(#'clojure.pprint/use-method