Skip to content

Instantly share code, notes, and snippets.

@dysinger
dysinger / idris
Last active August 29, 2015 13:56
HELP I'M NEW TO HASKELL AND CABAL IS KILLING ME!!!
# REMOVE ANYTHING CABAL HAS EVER DROPPED ONTO YOUR SYSTEM
rm -rf ~/.{ghc,cabal}
# UPDATE CABAL
cabal update
# UPGRADE CABAL TO 1.18 (BECAUSE THEY ADDED SANDBOXES)
cabal install cabal-install
export PATH=~/.cabal/bin:$PATH ;# PUT THIS IN YOUR PROFILE

Tools

  • Cabal
    • Starting a new project
    • Sandboxes
      • Creating
      • Deleting
    • Adding dependencies
    • Installing dependencies
    • Adding one or more test suites
@shinzui
shinzui / connection_fix.rb
Created December 6, 2009 06:18 — forked from defunkt/connection_fix.rb
MySQL automatic reconnect
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
###
# Read in XML as a stream, write out JSON as a stream. As little information
# is kept in memory as possible.
require 'nokogiri'
require 'psych'
class JSONTranslator < Nokogiri::XML::SAX::Document
attr_reader :emitter
def initialize emitter
@natan
natan / archive-desktop.rb
Last active October 11, 2015 05:17
Move everything on your desktop into ~/Dropbox/Documents/Desktops/<yyyy-mm-dd>/
#!/usr/bin/env ruby
require 'FileUtils'
require 'date'
def create_dir_if_necessary(path)
Dir.mkdir(path) unless File.directory?(path)
end
desktops_path = File.expand_path("~/Dropbox/Documents/Desktops")
(def cds (collection))
;; interact with database
(go
(>! (:in cds)
{:op :create
:val {:title "Soft Machine Vol. 1"
:artist "Soft Machine"
:year 1969}})
(defn take-until
([pred-sentinel in] (take-until pred-sentinel in (chan)))
([pred-sentinel in out]
(go (loop []
(if-let [v (<! in)]
(do
(>! out v)
(if-not (pred-sentinel v)
(recur)
(close! out)))
@hsjunnesson
hsjunnesson / log
Created September 5, 2013 21:28
Update: I've made a more thorough example of embedding Clojure logic in an iPhone app. Toes, a tic-tac-toe game in clojure on the iPhone. https://github.com/hsjunnesson/toes
2013-09-05 23:24:37.777 Prime[4204:c07] 1
2013-09-05 23:24:37.779 Prime[4204:c07] 0.732028842267092
2013-09-05 23:24:37.780 Prime[4204:c07] 0.2530017011838238
2013-09-05 23:24:37.781 Prime[4204:c07] 0.22892546997679017
2013-09-05 23:24:37.781 Prime[4204:c07] 0.5423003204364027
2013-09-05 23:24:37.782 Prime[4204:c07] 0.6065306597126334
2013-09-05 23:24:37.783 Prime[4204:c07] 0.44399788140114904
2013-09-05 23:24:37.783 Prime[4204:c07] 0.15345314921321815
2013-09-05 23:24:37.784 Prime[4204:c07] 0.13885046809469812
2013-09-05 23:24:37.784 Prime[4204:c07] 0.32892187595578626
@c-spencer
c-spencer / core.clj
Last active December 23, 2015 02:49
Simple demo of type construction from Datomic with core.typed and a little glue
(defn create-type
"Extract a type from provided field idents stored in Datomic database at uri."
[uri type-name overrides]
(let [c (d/connect uri)
d (d/db c)
datomic-type-map {:db.type/string 'String
:db.type/ref 'Any}
mt (dt/q> :- [EntityID]
'[:find ?e
:in $ ?t-name
@nz
nz / named pipe queues.sh
Created October 9, 2013 05:31
Nerd sniped by named pipes
#!/bin/sh
# clear old pipe and lock
rmdir worklock 2>/dev/null
rm work
if [[ ! -p work ]]; then
mkfifo work
else
dd if=work of=/dev/null