Skip to content

Instantly share code, notes, and snippets.

/* ~/Library/KeyBindings/DefaultKeyBinding.dict */
{
/*
* Keybindings for emacs emulation.
*
* WARNING! After Mountain Lion, this file cannot be symbolic linked to another file,
* you need to put this file in ~/Library/KeyBindings/DefaultKeyBinding.dict directly
*
* Reference:
@mawaldne
mawaldne / gist:6272854
Last active August 5, 2021 11:33
Read the first line of a file in groovy
def line
new File("test.txt").withReader { line = it.readLine() }
println line
@mawaldne
mawaldne / postgres_queries_and_commands.sql
Last active March 3, 2021 21:11 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (9.2)
SELECT pid, client_addr, age(clock_timestamp(), query_start), usename, query, state
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- kill running query
SELECT pg_cancel_backend(procpid);
-- kill idle query
@mawaldne
mawaldne / process.go
Last active September 15, 2020 02:52
Monitor a process in golang
package main
import (
"log"
"os/exec"
"syscall"
"time"
)
type Process struct {
@mawaldne
mawaldne / TokenAuthentication.scala
Last active January 22, 2020 19:37
Token Authentication example for Scalatra
package yourpackage
import org.scalatra.auth.strategy.BasicAuthSupport
import org.scalatra.auth.{ScentryConfig, ScentryStrategy, ScentrySupport}
import org.scalatra.{ScalatraBase, Unauthorized}
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
import java.util.Locale
class TokenAuthRequest(r: HttpServletRequest) {
@mawaldne
mawaldne / gist:ed33840e9a6d55918ad2d7631159f450
Created August 17, 2016 15:00
Audible Books as of Aug 17, 2016
The Phoenix Project
Meditations
Ego Is the Enemy
Smarter Faster Better
Flash Boys: A Wall Street Revolt
Fiction:
On Writing (Stephen King)
Masters of Doom
Hackers: Heroes of the computing revolution
Sci fi:
Ready Player One
Cryptonomicon
Old Mans War
@mawaldne
mawaldne / gist:7832688
Last active December 30, 2015 12:59
Time methods using closures in groovy
def timeMethod(method, message) {
def startTime = System.currentTimeMillis()
method()
def totalTime = System.currentTimeMillis() - startTime
log.info "${message} ${totalTime} ms"
}
...
timeMethod({ someMethod() }, "someMethod Time:")
...
@mawaldne
mawaldne / gist:7831963
Created December 6, 2013 20:56
Kramdown test
require 'kramdown'
puts Kramdown::Document.new(File.open('test.md').read).to_html
@mawaldne
mawaldne / gist:6275270
Last active December 21, 2015 07:59
Utility method to update semantic version number. Useful when tagging a new version.
def updateBuildVersion(currentVersion, updateType) {
def versionMatcher = currentVersion =~ /^(\d+)\.(\d+)\.(\d+)$/
def major = versionMatcher[0][1].toInteger()
def minor = versionMatcher[0][2].toInteger()
def patch = versionMatcher[0][3].toInteger()
if (updateType == 'patch')
patch += 1
else if (updateType == 'minor')
minor += 1