Skip to content

Instantly share code, notes, and snippets.

@komsit37
komsit37 / migrate_hdb.q
Last active August 29, 2015 14:13
migrate hdb from old server to new server. runs this in new server
//run this on q session in a new server
h: hopen`$":192.241.231.75:5012::";
h ({tables `.}; ());
sel: {[t; d] select from t where date=d};
getdata: {[src; dst; query; transform; d] dst set transform delete date from h (query; src; d)};
write: {[dst; d] .Q.dpft[`:/apps/bnb/data; d; `id; dst]};
chrome: "/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome "
.nv.t1: {.j.j {{`key`values!(y;`x`y xcol (x,'y)#z)}[;;x]/:[c[0];1_c:cols x]} x}
.chart.libpath: "/" sv (getenv `QHOME;"ext";"chart")
.chart.template: {hsym `$"/" sv (.chart.libpath;"template";string ` sv (x;`html))}
.chart.tempfile: {hsym `$"/" sv (.chart.libpath;"tmp";string ` sv (`$-3_(string .z.Z) except ".:";`html))}
plot:{[template; data]
lines: read0 .chart.template template;
@komsit37
komsit37 / install_IR_kernel.R
Last active August 29, 2015 14:21
install IR kernel
library(devtools)
install_local('/workspace/github/rzmq')
install_github('IRkernel/repr')
install_github("IRkernel/IRdisplay")
install_github("IRkernel/IRkernel")
IRkernel::installspec()
system.file("kernelspec", package="IRkernel")
> system.file("kernelspec", package="IRkernel")
@komsit37
komsit37 / qmagic.py
Last active August 29, 2015 14:21
ipython magic function to call q cell
from IPython.core.magic import (register_cell_magic)
from qpython import qconnection
@register_cell_magic
def q(con, cell=None):
"""
execute q statements in jupyter cell. Required qpython https://github.com/exxeleron/qPython
:param con: connection string (default 'localhost:5555')
:type con: str
{
"cmd": ["/usr/local/bin/q32", "test/$file_name"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"working_dir": "${file_path}/..",
"selector": "source.q",
"env":
{
"QPREFIX":"/usr/local",
"QHOME":"/usr/local/lib/q",
"QLIB":"/Users/komsit/lib/q",
//log alias for .qunit namespace
INFO: (value`.)[`INFO];
var express = require('express');
var app = express();
app.use(express.static('public'));
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
@komsit37
komsit37 / 0_reuse_code.js
Created November 5, 2015 09:56
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@komsit37
komsit37 / quill_update.scala
Last active June 3, 2016 01:00
scala quill - update sql without explicitly setting all fields
case class DbOrg(id: Int, name: String, a: String, b: Int, c: Long)
val q = quote {
(id: Int, orgName: String) =>
query[DbOrg].filter(_.id == id).filter(_.name == orgName).update
}
val d = DbOrg(1, "n", "a", 1, 2L)
mirrorSource.run(q(lift(d.id), lift(d.name)))(d)
#put this file in ~/
unbind C-b
set -g prefix C-a
bind C-a send-prefix
set -sg escape-time 1 # quicker responses
set -g base-index 1 # Numbering of windows
setw -g pane-base-index 1 # Numbering of Panes
bind \ split-window -h # Split panes horizontal