Skip to content

Instantly share code, notes, and snippets.

View nightscape's full-sized avatar

Martin Mauch nightscape

  • Regensburg, Germany
  • 02:33 (UTC +02:00)
View GitHub Profile
@nightscape
nightscape / Json.xtext
Last active December 27, 2022 10:30
Xtext grammar for JSON documents
grammar org.json.Json with org.eclipse.xtext.common.Terminals
generate json "http://www.json.org/"
Object:
'{' ((members+=Member) (',' members+=Member)*)? '}';
Member:
key=STRING ':' value=Value;
@nightscape
nightscape / update
Created February 21, 2011 13:47
Server side Git update hook which rejects pushes without prior pulls from master
refname="$1"
oldrev="$2"
newrev="$3"
# Find out revision of master
masterref=`git show-ref --hash --heads master`
# Find out common merge base of master and the checked in revision.
mergebase=`git merge-base $masterref $newrev`
if [[ $mergebase != $masterref && ( $refname == *development* || $refname == *feature* ) ]]
then
echo "Cannot push changes. Merge base is $mergebase, master is $masterref. Please type 'git pull origin master' and merge any conflicts first before$
@casualjim
casualjim / resque.scala
Created March 17, 2011 17:40
A resque implementation in scala with akka actors and scala-redis
package com.mojolly.backchat
package redis
package resque
import com.mojolly.backchat.redis.resque.Resque.{ResqueWorkerActor}
import net.liftweb.json._
import JsonAST._
import JsonDSL._
import java.net.InetAddress
import com.redis.ds.{ RedisDeque, RedisDequeClient }
@jorgeortiz85
jorgeortiz85 / PrivateMethodCaller.scala
Created April 7, 2011 15:41
Calling private methods in Scala
// Usage:
// p(instance)('privateMethod)(arg1, arg2, arg3)
class PrivateMethodCaller(x: AnyRef, methodName: String) {
def apply(_args: Any*): Any = {
val args = _args.map(_.asInstanceOf[AnyRef])
def _parents: Stream[Class[_]] = Stream(x.getClass) #::: _parents.map(_.getSuperclass)
val parents = _parents.takeWhile(_ != null).toList
val methods = parents.flatMap(_.getDeclaredMethods)
val method = methods.find(_.getName == methodName).getOrElse(throw new IllegalArgumentException("Method " + methodName + " not found"))
@antony
antony / Xephyr.groovy
Created November 30, 2011 10:43
Running functional tests with Xephyr
includeTargets << grailsScript("_GrailsInit")
display = ':65'
resolution = '-screen 1024x768'
target('default': "Run tests with xephyr") {
List parsedArgs = args.split() as List
exec (executable: 'Xephyr', spawn: true) {

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@paulp
paulp / The Signs of Soundness
Last active June 17, 2021 06:48
The Signs of Soundness
Hello scala, my old friend
I've come to take you home again
Because a feature slowly creeping
left me plagued with doubts and weeping
and the version that was tagged in the repo
just has to go
it lacks the signs of soundness
On sleepless nights I hacked alone
applying ant and other tools of stone
@Andrewpk
Andrewpk / OSX-junos_pulse_listenToMe.sh
Last active July 11, 2024 20:22
wtf juniper.Anyone else find it irritating that junos pulse services and pulse tray must always running in OS X regardless of whether or not you're currently connected?Yeah, me too.I added the following as aliases to my shell to fix this problem.Be sure to change your /Library/LaunchAgents/net.juniper.pulsetray.plist file to reflect the `KeepAli…
#################################################################################
# start and stop the vpn from the command line from now on with these two commands
#################################################################################
startvpn() {
sudo launchctl load -w /Library/LaunchDaemons/net.pulsesecure.AccessService.plist
launchctl load -w /Library/LaunchAgents/net.pulsesecure.pulsetray.plist
}
quitvpn() {
launchctl unload -w /Library/LaunchAgents/net.pulsesecure.pulsetray.plist
sudo launchctl unload -w /Library/LaunchDaemons/net.pulsesecure.AccessService.plist
/**
* R functions to create and manipulate Breeze matrices. This should go into
* Breeze or a sub-project of Breeze eventually.
*/
object RFunc {
import breeze.linalg._
import breeze.stats.distributions._
import breeze.stats.DescriptiveStats._
/**
@kevinwright
kevinwright / scaladays2014.md
Last active March 8, 2018 20:25
Scaladays 2014 slides

As compiled by Kevin Wright a.k.a @thecoda

(executive producer of the movie, and I didn't even know it... clever huh?)

please, please, please - If you know of any slides/code/whatever not on here, then ping me on twitter or comment this Gist!

This gist will be updated as and when I find new information. So it's probably best not to fork it, or you'll miss the updates!

Monday June 16th