Skip to content

Instantly share code, notes, and snippets.

View nicerobot's full-sized avatar
๐Ÿค–
โ˜ฏ๏ธ โ˜ฎ๏ธ ๐Ÿถ ๐Ÿพ ๐Ÿ‘พ ๐ŸŽฎ ๐ŸŽผ ๐ŸŽถ ๐Ÿ•บ ๐ŸŽง ๐ŸŒป ๐ŸŒฑ ๐Ÿž ๐ŸŒŠ ๐ŸŒ” ๐ŸŒŽ

nicerobot

๐Ÿค–
โ˜ฏ๏ธ โ˜ฎ๏ธ ๐Ÿถ ๐Ÿพ ๐Ÿ‘พ ๐ŸŽฎ ๐ŸŽผ ๐ŸŽถ ๐Ÿ•บ ๐ŸŽง ๐ŸŒป ๐ŸŒฑ ๐Ÿž ๐ŸŒŠ ๐ŸŒ” ๐ŸŒŽ
View GitHub Profile
@nicerobot
nicerobot / 02.01.signum.scala
Created May 19, 2012 13:46
Answers to Scala for the Impatient
def signum[N](i:N)(implicit n:Numeric[N]):Int = n.compare(i,n.fromInt(0))
def signum[N](i:N)(implicit n:Numeric[N]):Int = n.signum(i)
@nicerobot
nicerobot / jquid2data.sh
Created May 27, 2012 05:46
Convert references to image files into data URIs
#!/bin/sh
# Assumes pngs are in images/ under ./*.css
# Edits the files in-place. Make backups.
CSSD=${1:-${CSSD:-.}}
for c in $(ls ${CSSD}/*.css 2>/dev/null); do
for i in ${CSSD}/images/*.png; do
p=$(basename $i)
b="$(base64 ${i})"
perl -pi -e "s|images/${p}|data:image/png;base64,${b}|" ${c}
done
@nicerobot
nicerobot / how-pure-should-work.html
Created May 27, 2012 08:17
This is how Pure should work. Please do away with javascript directives and implement them declaratively as HTML.
<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="https://raw.github.com/pure/pure/master/libs/pure_min.js"></script>
</head>
<body>
<!--
data-pure-declare are converted into Pure directives and
@nicerobot
nicerobot / t._.sh
Created July 9, 2012 16:16
Problems with nanoTime in Java under Linux
#!/bin/sh
cd /tmp
cat >t.java <<CLASS
class t { public static void main(String...args) {
System.out.println(System.currentTimeMillis()+"\n"+System.nanoTime()); } }
CLASS
uname -rvsp
date -u
date +%s
javac t.java && java -cp . t
@nicerobot
nicerobot / local-new.git.sh
Created July 14, 2012 13:34
Create new server and local repository
#!/bin/sh
# 1. Configure ~/.ssh/config with a "git" host.
# 2. curl https://raw.github.com/gist/3111363/server-config.git.sh | sh
# - step 2 will download this local script here and place the remote script
# Usage: ./local-new.git.sh project-name
[ "${1}" ] || {
echo "Usage: $0 repository-name"
exit 1
}
@nicerobot
nicerobot / sortedSystemProperties.scala
Created July 18, 2012 04:46
There has to be a simpler solution!
import scala.collection.JavaConversions.propertiesAsScalaMapimport
(scala.collection.SortedMap[String,String]() ++ System.getProperties()) map(s=>printf("%%%ds | %%s\n".format(System.getProperties().toMap.keySet.foldLeft(0)((i,s) => i max s.length)),s._1,s._2))
@nicerobot
nicerobot / jenkins.sh
Created October 14, 2012 21:18
Create Jenkins group/user on Mac OS X
#!/bin/sh
# curl -Lks https://raw.github.com/gist/3889839/jenkins.sh | sudo sh -s
# from http://mattonrails.wordpress.com/2011/06/08/jenkins-homebrew-mac-daemo/
# open http://localhost:8080
brew list jenkins || brew install jenkins
mkdir /var/jenkins
/usr/sbin/dseditgroup -o create -r 'Jenkins CI Group' -i 600 _jenkins
dscl . -append /Groups/_jenkins passwd "*"
dscl . -create /Users/_jenkins
dscl . -append /Users/_jenkins RecordName jenkins
@nicerobot
nicerobot / db.sh
Created October 17, 2012 16:22
PostgreSQL OS X
#!/bin/sh
# curl -Lk https://gist.github.com/raw/3906498/db.sh | sh -s mydb myuser
db=${1:-mydb}; shift
us=${1:-auser}; shift
createdb ${db}
psql -d ${db}
createuser -s -e ${us}
@nicerobot
nicerobot / tomcat.sh
Created October 25, 2012 01:10
Create Tomcat group/user on Mac OS X
#!/bin/sh
curl -Lks https://raw.github.com/gist/3962627/add.sh | sudo sh -s tomcat
@nicerobot
nicerobot / add.sh
Created October 27, 2012 01:50
Create Mac OS X user/group
#!/bin/sh
# e.g.
# curl -Lks https://raw.github.com/gist/3962627/add.sh | sudo sh -s tomcat
user=${1}
mkdir /var/${user}
/usr/sbin/dseditgroup -o create -r "${user} Group" -i 700 _${user}
dscl . -append /Groups/_${user} passwd "*"
dscl . -create /Users/_${user}
dscl . -append /Users/_${user} RecordName ${user}
dscl . -append /Users/_${user} RealName "${user}"