Skip to content

Instantly share code, notes, and snippets.

@socksy
socksy / gist:4743803
Created February 9, 2013 04:14
Finding out the duplicate colour names
>>>> import csv
>>>> f = open("colors.txt")
>>>> ramalan = csv.reader(f, delimiter=',')
>>>> colours = []
>>>> for x in ramalan:
... colours.append(x)
...
# Here we get rid of some malformed entries
>>>> colours = [c for c in colours if len(c) == 2]
@socksy
socksy / gist:4743817
Created February 9, 2013 04:20
Duplicate colours on wikipedia's list of colours
Pale turquoise with Pale blue (AFEEEE)
Pale violet-red with Pale red-violet (DB7093)
Plum (web)]] with Pale plum]] (DDA0DD)
Prune with Persian plum (701C1C)
Psychedelic purple with Phlox (DF00FF)
Purple (HTML/CSS)]] with Patriarch (800080)
Royal yellow with Naples yellow (FADA5E)
Sandy taupe with Sand dune (967117)
Stil de grain yellow with Naples yellow (FADA5E)
Stil de grain yellow with Royal yellow (FADA5E)
@socksy
socksy / traversal.clj
Last active December 26, 2015 22:49
Post-order traversal with a zipper in clojure
;WARNING: this puts your entire tree in memory, so if you're using zippers
;to avoid that, do not use this.
;Also, potentially terrible clojure. I only learned this a few days ago
;couldn't find any way to do this online except for a single
;stackoverflow that didn't actually use zippers
(require '[clojure.zip :as zip])
(defn zip-down [loc]
"Zips to the bottom of the tree from this loc"
(loop [p loc]
(if (zip/branch? p)
java.lang.OutOfMemoryError: Requested array size exceeds VM limit
at java.util.Arrays.copyOf (Arrays.java:2367)
java.lang.AbstractStringBuilder.expandCapacity (AbstractStringBuilder.java:130)
java.lang.AbstractStringBuilder.ensureCapacityInternal (AbstractStringBuilder.java:114)
java.lang.AbstractStringBuilder.append (AbstractStringBuilder.java:587)
java.lang.StringBuffer.append (StringBuffer.java:332)
java.io.StringWriter.write (StringWriter.java:77)
java.io.StringWriter.append (StringWriter.java:202)
java.io.StringWriter.append (StringWriter.java:41)
clojure.core/fn (core_print.clj:181)
@socksy
socksy / huffman.py
Created November 18, 2014 10:19
An example of how to implement huffman in python
#!/usr/bin/env python
#author 100004004
#Huffman encoding
import random
import math
#Constant for the end of transmission symbol
EOT = chr(4)
def get_source_weights():
{ config, pkgs, ... }:
# Enable the X11 windowing system.
{
services.xserver = {
enable = true;
layout = "gb";
xkbVariant = "mac";
xkbOptions = "caps:escape,compose:escape";
Xft.dpi: 220
Xft.autohint: 0
Xft.rgba: rgb
Xft.antialias: 1
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintfull
Xft.hinting: 1
{ config, pkgs, ... }:
{
# Use the gummiboot efi boot loader.
# n.b. no GRUB settings like everyone tells you to do
boot.loader.gummiboot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.enableB43Firmware = true;
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
@socksy
socksy / .conky_dzen
Created April 18, 2016 23:30
xmonad stuff
background yes
out_to_console yes
out_to_x no
# Update interval in seconds
update_interval 1
user_spacer left
pad_percents 2
lua_load ~/.xmonad/.conky_lua_scripts.lua
TEXT