Skip to content

Instantly share code, notes, and snippets.

@abesto
abesto / dependency-report.gradle
Created July 24, 2015 14:06
Gradle: multi-project dependency graph
task dependencyReport {
doLast {
def file = new File("project-dependencies.dot")
file.delete()
file << "digraph {\n"
file << "splines=ortho\n"
rootProject.childProjects.each { item ->
def from = item.value
from.configurations.compile.dependencies
.matching { it in ProjectDependency }
import logging
dict(filter(lambda x: x[1], [(name, [h for h in logging.getLogger(name).handlers if 'Stream' in h.__class__.__name__]) for name, logger in logging.Logger.manager.loggerDict.iteritems()]))
@abesto
abesto / keybase.md
Created April 12, 2014 10:05
keybase.md

Keybase proof

I hereby claim:

  • I am abesto on github.
  • I am abesto (https://keybase.io/abesto) on keybase.
  • I have a public key whose fingerprint is F633 DCF7 81E5 A3C8 3010 6CC4 04E1 88BC 5D45 BDEE

To claim this, I am signing this object:

// in app.js:
ss.api.log = winston.info;
console.log = ss.api.log;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
public class Gy2_1 {
static class Point {
private Integer x, y;
Point(Integer x, Integer y) {
log4j.appender.Console.layout.conversionPattern = %d %h %c %p %m using a config from the web%n
app.post '/tab', (req, res) ->
redis.incr 'tab', (err, id) ->
return res.send 500, err if err
key = tabKey(id)
json = JSON.stringify {id: id, text: req.body.text}
redis.set key, json, (err) ->
return res.send 500, err if err
redis.rpush tabsListKey, id, (err) ->
return res.send 500, err if err
res.send 201, json
@abesto
abesto / curry.bash
Last active February 28, 2024 18:32
Partial application in Bash
function curry() {
exportfun=$1; shift
fun=$1; shift
params=$*
cmd=$"function $exportfun() {
more_params=\$*;
$fun $params \$more_params;
}"
eval $cmd
}
@abesto
abesto / gist:3476594
Created August 26, 2012 09:27
Go: Newton's method for square root
/*
A Tour of Go: page 44
http://tour.golang.org/#44
Exercise: Loops and Functions
As a simple way to play with functions and loops, implement the square root function using Newton's method.
In this case, Newton's method is to approximate Sqrt(x) by picking a starting point z and then repeating: z - (z*z - x) / (2 * z)
@abesto
abesto / lzw.hs
Created June 29, 2012 08:13
Haskell LZW compression
-- Could use a few rounds of cleanup...
import Data.Char
import Data.List
dictionary :: [String]
dictionary = [[chr c] | c <- [0 .. 127]]
prefixes :: [String] -> String -> [(Int, String)]
prefixes xs y = [(i, xs !! i) | i <- [0 .. (length xs) -1], xs !! i `isPrefixOf` y]