Skip to content

Instantly share code, notes, and snippets.

@funkotron
funkotron / docker_create_treeio.sh
Last active December 18, 2019 17:56
Using Docker (requires docker to be installed http://www.docker.io/gettingstarted/ ), spawn a postgresql instance and a dynamically configured treeio instance.
#!/bin/bash
# Description: Using Docker (requires docker to be installed http://www.docker.io/gettingstarted/ ), spawn a postgresql instance and a dynamically configured treeio instance
# Also requires postgresql client tools http://www.postgresql.org/download/linux/ubuntu/
# Run chmod +x to make this file executable then run it: ./docker_create_treeio.sh
# Author: Adam Awan
# Email: adam@tree.io
# Set the port to forward for Tree.io
TREEIO_PORT="80"
@funkotron
funkotron / init
Last active December 20, 2015 00:39
Modified init script to keep existing password if arg given and keep existing /data dir if non empty for persistence of database
#!/bin/sh
set -e
mkdir -p /usr/share/zoneinfo /data
chown default /data
if [ $# -eq 1 ]
then
echo $1 > /pwfile
else
head -c 16 /dev/urandom | sha1sum | cut -c1-10 > /pwfile
fi
@funkotron
funkotron / gist:7473547
Created November 14, 2013 20:12
Query Git for a list of repos - change the URL username
(ns crash-course-clojure.github
(:require [clj-http.client :as http]
[cheshire.core :refer [parse-string]]
[clojure.pprint :refer [pprint]]))
(defn query-github
"Run an arbitrary query agains Github's API."
[query]
(parse-string (:body (http/get "https://api.github.com/users/funkotron/repos"
@funkotron
funkotron / github-lang-count.clj
Created November 14, 2013 20:13
GitHub API Language Count
(ns crash-course-clojure.github
(:require [clj-http.client :as http]
[cheshire.core :refer [parse-string]]
[clojure.pprint :refer [pprint]]))
(defn query-github
"Run an arbitrary query agains Github's API."
[query]
(parse-string (:body (http/get "https://api.github.com/users/funkotron/repos"
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout somewhen, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
#!/bin/bash
#Set up external monitor if connected
EXTERNAL=`xrandr | grep -i "HDMI1 disconnected"`
if [ -z $EXTERNAL ]; then
xrandr --output HDMI1 --auto --left-of eDP1
fi
sleep 1
#Set up main monitor
xrandr --output eDP1 --auto
#!/bin/bash
Dir="/home/a/Dropbox/wallpaper"
if [ ! -d "$Dir" ]; then
echo "Not Exist $Dir"
exit 1
fi
SetBG () {
@funkotron
funkotron / euler4.clj
Created February 15, 2014 02:52
Problem 4 of Project Euler in Clojure
(defn palindrome?
"Is x the same read backwards?"
[x]
(let [s (seq (str x))]
(= s (reverse s))))
(def three-digit-products
"All the products of two three-digit numbers"
(for [x (range 100 999)
@funkotron
funkotron / all_your_base.clj
Created February 15, 2014 03:54
Solution to "All Your Base" Google Codejam contest in Clojure http://code.google.com/codejam/contest/189252/dashboard#s=p0
(ns jam.all-your-base
(:require [clojure.math.numeric-tower :as math]))
(def in (rest (clojure.string/split (slurp "A-large-practice.in") #"\n")))
(defn p [x y]
(math/expt x y))
(defn next-index [x]
(cond
@funkotron
funkotron / all_your_base.py
Created February 15, 2014 03:57
Solution to "All Your Base" Google Codejam contest in Python http://code.google.com/codejam/contest/189252/dashboard#s=p0
#!/usr/bin/python
def distinct(j):
seen = set()
for i in j:
if i not in seen:
seen.add(i)
return seen
def next_index(c):