Skip to content

Instantly share code, notes, and snippets.

@CraZySacX
CraZySacX / handler.clj
Created May 7, 2014 18:23
Sorting by int value rather than String value in a mixed sequence
(ns wgetjava.handler
(:require [clojure.java.io :as io]
[clojure.string :as str]
[org.ozias.cljlibs.shell.shell :refer :all]
[org.ozias.cljlibs.utils.core :refer :all])
(:import (clojure.lang PersistentArrayMap PersistentVector)))
(def ^{:private true :doc "cookies temp file path"}
cookies-path (to-path (tmpdir) "cookies.txt"))
@CraZySacX
CraZySacX / target.clj
Created April 30, 2014 16:03
Clojure to Haskell
(defn- target
"generate a target from a user and host string.
If user and host are nil, evaluates to localhost.
If host is nil, evaluates to user@localhost.
If user is nil, evaluates to host.
Otherwise evaluates to user@host."
[user host]
(let [host (if (string? host) host "localhost")
user (if (string? user) (str user "@") "")]
(str user host)))
@CraZySacX
CraZySacX / max.scala
Last active August 29, 2015 14:00
I think an anon function would work, but can't seem to find the proper syntax...
// Original....
def max(xs: List[Int]): Int = {
def findMax(curr: Int, l: List[Int]): Int = {
if (l.isEmpty)
curr
else if (l.head > curr)
findMax(l.head, l.tail)
else
findMax(curr, l.tail)
}
@CraZySacX
CraZySacX / merger.py
Created February 19, 2014 14:24
Python script that aids with merging upstream projects with origin. Useful for github forks.
#!/usr/bin/python3
import argparse
import os
from os import environ
from subprocess import check_call
# Store the current directory
owd = os.getcwd()
# Setup the supported command-line arguments