Skip to content

Instantly share code, notes, and snippets.

View fsvehla's full-sized avatar

Ferdinand Svehla fsvehla

View GitHub Profile
root@tel1:/etc/network# id
uid=0(root) gid=0(root) groups=0(root)
root@tel1:/etc/network# rm -f interfaces
rm: cannot remove `interfaces': Operation not permitted
root@tel1:/etc/network# ls -halps interfaces
4.0K -rw-r--r-- 1 root root 285 Jul 10 2011 interfaces
#!/bin/bash
# For the duration of this script, don’t run .rvmrcs
unset rvm_project_rvmrc
orig_pwd=$PWD
find . -name '*.git' -type d | while read repo; do
# Starts a subshell, and thereby resetting pwd every time
cd "$orig_pwd/$repo"
(defn wait-a-bi []
(do (println "waiting a bit")
(. Thread (sleep 200))))
(first ((wait-a-bit) (wait-a-bit))
(defn run-process
"Runs the process"
[args]
(->>
(new ProcessBuilder args)
(.start)
))
(defn exec
"Returns the ouput of the command, which is assumed to smallish and non-binary."
daemon off;
pid /tmp/nginx-80-to-8888.pid;
events {
worker_connections 102480;
multi_accept on;
}
http {
server {
var http = require('http');
var server = http.createServer(function (req, res) {
res.end('hullo');
});
server.listen(1250, function () {
console.log('Listening on 1250');
});
@fsvehla
fsvehla / gist:4149387
Created November 26, 2012 17:07
SMC Reset
Shut down the computer.
- Plug in the MagSafe power adapter to a power source, connecting it to the Mac if its not already connected.
- On the built-in keyboard, press the (left side) Shift-Control-Option keys and the power button at the same time.
- Release all the keys and the power button at the same time.
- Press the power button to turn on the computer.
Note: The LED on the MagSafe power adapter may change states or temporarily turn off when you reset the SMC.
#!/bin/bash
set -e
difftool=diff
[[ -f /usr/local/bin/ksdiff ]] && difftool=ksdiff
lname=$(echo $1 | tr '/' '-')
rname=$(echo $2 | tr '/' '-')
def transformKeys[A,B,C](m: Map[A, B], transformFunc: (A => C)): Map[C, B] = {
m.foldLeft(Map.empty[C, B]) { (acc, entry) =>
acc + (transformFunc(entry._1) -> entry._2)
}
}
val numMap: Map[Int, String] = Map(1 -> "Two", 2 -> "Four", 3 -> "Six")
val transformed = transformKeys(numMap, { (key:Int) => key * 2 })
// without (key:Int) = error: missing parameter type
function jdk7 () {
export JVM_VERSION='1.7.0_51'
# Java
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk${JVM_VERSION}.jdk/Contents/Home"
export PATH="${JAVA_HOME}/bin:${PATH}"
}
function jdk8 () {
export JVM_VERSION='1.8.0_20'