Skip to content

Instantly share code, notes, and snippets.

View chuckis's full-sized avatar
🔍
In the beginning was the Word,

chuckis

🔍
In the beginning was the Word,
  • 12:38 (UTC +03:00)
View GitHub Profile
@valpackett
valpackett / dijkstra.clj
Created August 27, 2011 16:28
Dijkstra's algorithm in Clojure
; http://www.algolist.com/Dijkstra's_algorithm
(defn dijkstra [g src]
(loop [dsts (assoc (zipmap (keys g) (repeat nil)) src 0)
curr src
unvi (apply hash-set (keys g))]
(if (empty? unvi)
dsts
(let [unvi (disj unvi curr)
nextn (first (sort-by #(% dsts) unvi))
@basarat
basarat / insertionsort.py
Created July 31, 2012 13:01
Insertion sort in python
def insertionsort(A):
#we start loop at second element (index 1) since the first item is already sorted
for j in range(1,len(A)):
key = A[j] #The next item we are going to insert into the sorted section of the array
i = j-1 #the last item we are going to compare to
#now we keep moving the key back as long as it is smaller than the last item in the array
while (i > -1) and key < A[i]: #if i == -1 means that this key belongs at the start
A[i+1]=A[i] #move the last object compared one step ahead to make room for key
i=i-1 #observe the next item for next time.
@krisajenkins
krisajenkins / fizzbuzz.clj
Created August 12, 2012 18:57
Fizzbuzz in clojure.
(clojure.pprint/pprint
(map vector
(range 25)
(cycle [:fizz :_ :_])
(cycle [:buzz :_ :_ :_ :_])))
; Credit to http://clojure-and-me.blogspot.co.uk/2012/08/functional-fizzbuzz.html, code rewritten a little by me.
@jdkanani
jdkanani / notepad.html
Last active June 16, 2024 13:44 — forked from jakeonrails/Ruby Notepad Bookmarklet
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">.e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div class="e" id="editor"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("editor");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
<!--
For other language: Instead of `ace/mode/ruby`, Use
Markdown -> `ace/mode/markdown`
Python -> `ace/mode/python`
C/C++ -> `ace/mode/c_cpp`
Javscript -> `ace/mode/javascript`
Java -> `ace/mode/java`
Scala- -> `ace/mode/scala`
@JosefJezek
JosefJezek / how-to-use-pelican.md
Last active May 12, 2024 11:19
How to use Pelican on GitHub Pages
@kylemcdonald
kylemcdonald / InboxUnread.php
Created August 12, 2013 12:57
Inbox Unread reports inbox statistics hourly in the form of a Twitter avatar.
<!--
Inbox Unread reports inbox statistics hourly in the form of a Twitter avatar.
To run Inbox Unread first copy this php script to your server. Put your background
avatar adjacent to this file as "input.jpeg". Mine is 548x548 and all the positions
are setup for that size. Next go to http://script.google.com/ and sign in. Click
"Create a script for GMail" and replace the template with this code:
function processInbox() {
var unreadCount = GmailApp.getInboxUnreadCount();
;; Try it in the REPL or eval in Light Table
(require '[clojure.string :as string])
(def vowels [:a :e :i :o :u])
(defn char-is-consonant?
[char]
(not-any? #{(keyword char)} vowels))
@MaxLaumeister
MaxLaumeister / Grub_Powerup.md
Last active June 7, 2024 15:58
Grub Init Tune: Mario Bros. Mushroom Powerup

Grub Init Tune - Mario Bros. Mushroom Powerup

This Grub Init Tune will make your computer sound like a Super Mushroom every time you turn it on! This only works for the Grub bootloader - this generally means you need to have Linux (or other Grub-based OS) installed.

Here's the code, which goes in your /etc/default/grub file:

GRUB_INIT_TUNE="1750 523 1 392 1 523 1 659 1 784 1 1047 1 784 1 415 1 523 1 622 1 831 1 622 1 831 1 1046 1 1244 1 1661 1 1244 1 466 1 587 1 698 1 932 1 1195 1 1397 1 1865 1 1397 1"

Installation Instructions

@StuartGordonReid
StuartGordonReid / DistanceMetrics.py
Created June 15, 2015 14:36
Implementation of various distance metrics in Python
import math
import random
import csv
import cProfile
import numpy as np
import hashlib
memoization = {}
@vasanthk
vasanthk / System Design.md
Last active June 21, 2024 20:21
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?