Skip to content

Instantly share code, notes, and snippets.

@jclosure
jclosure / query_ldap_with_python_debugging
Created September 26, 2015 02:54
query ldap with python - ipython debugging from repl or cli
#!/usr/local/bin/python
# coding: utf-8
# for windows get ldap module here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
# python_ldap‑2.4.21‑cp27‑none‑win_amd64.whl
## debugging in ipython: https://github.com/gotcha/ipdb
# debug in in ipython repl with: run -d 'test_ldap2.py' or %run ...
# debug it in ipython repl with: ipdb.runcall(run_filter, Server, DN, Secret, un)
@jclosure
jclosure / gist:8e5fb6cac4b4a0059b52
Created November 8, 2015 19:49
Rebased forked repository
In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:
# Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git
# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:
git fetch upstream
@jclosure
jclosure / gist:b34753a2a781487a33a4
Last active November 8, 2015 19:54
Programmatically determine if a class is a singleton_class.
x = MyClass
# pre ruby 2.0
def eigenclass?
Class === x && x.ancestors.first != x
end
# post ruby 2.0
def eigenclass?
@jclosure
jclosure / 3_fingered_claw.sh
Created December 10, 2015 08:01
3 fingered claw - sourcible bash execution harness
# usage:
#
# . 3_fingered_claw.sh
# try command1
# try command2
yell() { echo "$0: $*" >&2; }
die() { yell "$*"; exit 111; }
try() { "$@" || die "cannot $*"; }
@jclosure
jclosure / vertx_daemon_start.sh
Created December 16, 2015 20:10
Start Vertx as a daemon on Linux
# If you are going to deploy say on a debian linux box with upstart you can use my script from the juju charm:
cat /etc/init/app_name.conf
description "app_name Vert.x server"
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [!2345]
@jclosure
jclosure / terminal.sh
Last active June 5, 2016 21:51 — forked from Rpsl/terminal.sh
Open iTerm terminal from PhpStorm ( NativeNeighbourhood plugin );
cd ~/Library/Application\ Support/IntelliJIdea2016.1/NativeNeighbourhood/classes/org/intellij/plugins/nativeNeighbourhood/icons/macosx
echo '#!/bin/sh
#
# Reveal a directory in the Terminal.
#
# The script takes one argument, the qualified name of a directory.
#
# Note that the script is necessary because osascript before osx 10.4 could not
# pass arguments.
@jclosure
jclosure / npm_make_clean.sh
Created January 2, 2016 22:50
Remove all npm_modules directories recursively
find . -name "node_modules" -exec rm -rf '{}' +
@jclosure
jclosure / log4j.properties
Created April 3, 2016 07:55 — forked from xkr47/log4j.properties
log4j configuration with different colors for different log levels - also works with Eclipse Ansi Console: http://mihai-nita.net/2013/06/03/eclipse-plugin-ansi-in-console/
log4j.debug=false
# Default level is INFO
log4j.rootLogger=INFO,StdoutErrorFatal,StdoutWarn,StdoutInfo,StdoutDebug,StdoutTrace
# and for com.some.package.* log everything
log4j.logger.com.some.package=TRACE
log4j.appender.StdoutErrorFatal=org.apache.log4j.ConsoleAppender
log4j.appender.StdoutErrorFatal.layout=org.apache.log4j.PatternLayout
annotations could be fine for your purpose.
@FileProperties(desc="data file")
public class DataFile extends XFile { ... }
FileProperties props = DataFile.class.getAnnotation(FileProperties.class);
String desc = props.desc();
Accessing the info still requires reflection, however it's a little better than using static field/method.
Java compiler does not enforce that all subclasses are annotated as such. You can add your logic to the compiler (using annotation processing) but that's too complicated. It's ok to check it at runtime.
If we view the series of events as a “sentence”, we could use this technique to vectorize them:
https://cs.stanford.edu/~quocle/paragraph_vector.pdf
Very good svm introductory text:
http://karpathy.github.io/neuralnets/
This site is also good:
http://deeplearning4j.org