Skip to content

Instantly share code, notes, and snippets.

View nightscape's full-sized avatar

Martin Mauch nightscape

View GitHub Profile
@nightscape
nightscape / x
Created November 18, 2008 10:51
CmdUtils.makeSearchCommand({
name: "pickaxe",
url: "http://www.google.com/search?q=site:http://whytheluckystiff.net/ruby/pickaxe/%20{QUERY}&btnG=Search&btnI=3564",
icon: "http://whytheluckystiff.net/favicon.ico",
description: "Searches 'Programming Ruby The Pragmatic Programmer's Guide' for your words.",
preview: function(pblock, directObject) {
var searchTerm = directObject.text;
var pTemplate = "Searches 'Programming Ruby The Pragmatic Programmer's Guide' for ${query}";
var pData = {query: searchTerm};
pblock.innerHTML = CmdUtils.renderTemplate(pTemplate, pData);
@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$
@nightscape
nightscape / gist:2329188
Created April 7, 2012 14:01
Macro - Bulk import images into Powerpoint slides
' Slightly modified from http://www.pptfaq.com/FAQ00352_Batch_Insert_a_folder_full_of_pictures-_one_per_slide.htm
Sub InsertImages()
Dim strTemp As String
Dim strPath As String
Dim strFileSpec As String
Dim oSld As Slide
Dim oPic As Shape
' Edit these to suit:
@nightscape
nightscape / sexp.peg
Created August 16, 2012 18:27
S-Expression grammar for PEG.js
/*
* Grammar to generate an S-Expressions parser for Javascript using http://pegjs.majda.cz/
*/
start
= expression*
integer "integer"
= digits:[0-9]+ { return parseInt(digits.join(""), 10); }
@nightscape
nightscape / Gui.scala
Created November 29, 2012 01:44 — forked from fnumatic/Gui.scala
Simple Swing Application with scala.react * github.com/ingoem/scala-react
import MySwingDomain._
object Gui extends ReactiveSwingApp {
val button = new MyButton("test")
def top = new MainFrame {
contents = new FlowPanel {
contents += button
}
}
@nightscape
nightscape / Gui.scala
Created November 29, 2012 01:44 — forked from fnumatic/Gui.scala
Simple Swing Application with scala.react * github.com/ingoem/scala-react
import MySwingDomain._
object Gui extends ReactiveSwingApp {
val button = new MyButton("test")
def top = new MainFrame {
contents = new FlowPanel {
contents += button
}
}
author = "joe"
repos = Dir["**/.git/"].map {|r| r.gsub('.git','') }
stats = repos.map {|r| [r, `cd #{r} && git log --author=#{author} --format=format:"%ad %s" --date=short`.split("\n")]}
commits = stats.flat_map {|r, cs| cs.map {|c| d,cm = c.match(/(\d{4}-\d{2}-\d{2}) (.*)/).to_a[1..2]; [d, File.basename(r), cm]}}
str = commits.sort_by(&:first).map {|c| c.join("\t")}.join("\n")
File.open("commits_#{author}.txt", 'w') {|f| f.puts str}
import com.google.appsscript.adwords._
import com.google.appsscript.base.Logger
import com.google.appsscript.spreadsheet._
object ScalaJSExample extends js.JSApp{
def main(): Unit = {
val adsIterator = AdWordsApp.ads()
.withCondition("ApprovalStatus = DISAPPROVED")
.get()
@nightscape
nightscape / ConvertUtils.scala
Created March 31, 2015 23:46
Parquet to CSV
import ComparisonChain._
import java.io.BufferedInputStream
import java.io.BufferedOutputStream
import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.Closeable
import java.io.File
import java.io.File
import java.io.FileInputStream
import java.io.FilenameFilter