Skip to content

Instantly share code, notes, and snippets.

Avatar

Cédric Deltheil deltheil

View GitHub Profile
@deltheil
deltheil / torch-test.sh
Created Jan 13, 2016
Run a single Torch7 test
View torch-test.sh
# Example: to run `torchtest.topK` do
luajit -ltorch -e "torch.test('topK')"
@deltheil
deltheil / lsqlite3.sh
Created Jan 9, 2016
LuaRocks: path-related variables for external dependencies
View lsqlite3.sh
# e.g. with lsqlite3
#
# see https://github.com/keplerproject/luarocks/blob/7a7c124/src/luarocks/deps.lua#L522-L529
luarocks SQLITE_INCDIR=/usr/local/opt/sqlite/include SQLITE_LIBDIR=/usr/local/opt/sqlite/lib install lsqlite3
@deltheil
deltheil / info.c
Created Nov 25, 2015
Check if libcurl was built with async DNS support
View info.c
#include <stdio.h>
#include <curl/curl.h>
int
main(void)
{
curl_version_info_data *info = curl_version_info(CURLVERSION_NOW);
printf("async DNS: %d\n", !!(info->features & CURL_VERSION_ASYNCHDNS));
return 0;
}
@deltheil
deltheil / argcheck.lua
Created Nov 12, 2015
Playing with torch/argcheck
View argcheck.lua
require 'torch'
local argcheck = require 'argcheck'
local env = require 'argcheck.env'
function env.istype(obj, typename)
if typename == 'torch.Tensor' then
-- could also check the storage type!
return torch.isTensor(obj)
else
View convert.lua
require 'torch'
-- pre-req: luarocks install csv
local csv = require "csv"
local inputs, labels = {}, {}
local f, i = csv.open("data.csv"), 0
for fields in f:lines() do
if i > 0 then -- skip header
inputs[i] = {unpack(fields, 1, 18)}
@deltheil
deltheil / jq.sh
Last active Aug 29, 2015
Use jq command-line JSON processor to filter out a nested hash. See also: https://github.com/stedolan/jq/wiki/jq%20Cookbook
View jq.sh
# http://stedolan.github.io/jq/
json='{"foo": {"genre":"deep house"}, "bar": {"genre": "progressive house"}, "baz": {"genre": "dubstep"}}'
echo "$json" | jq '[to_entries | .[] | select(.value.genre | contains("house"))] | from_entries'
# {
# "bar": {
# "genre": "progressive house"
# },
# "foo": {
# "genre": "deep house"
@deltheil
deltheil / torch-svm.md
Created Nov 28, 2014
A quick'n'dirty work around to install koraykv/torch-svm
View torch-svm.md

torch-svm

Here's a quick'n'dirty work around to install torch-svm:

Clone the repo

git clone git@github.com:koraykv/torch-svm.git && cd torch-svm
@deltheil
deltheil / luajit-valgrind.md
Created Jul 16, 2014
LuaJIT + Valgrind (linux x64)
View luajit-valgrind.md
  1. use Valgrind 3.8.1 since 3.9.0 broke LuaJIT
  2. build LuaJIT with the following options:
diff --git a/src/Makefile b/src/Makefile
index c558003..39676b8 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -57,7 +57,7 @@ CCOPT_mips=
 #
@deltheil
deltheil / build-cfsm.sh
Last active Aug 29, 2015
cfsm - Finite State Machine compiler
View build-cfsm.sh
# -------
# cfsm
# -------
# see: http://www.mindrot.org/projects/cfsm/
# Build (tested on Mac OS X 10.9.3)
cvs -d :ext:anoncvs@anoncvs.mindrot.org:/cvs checkout cfsm mtemplate
make -C mtemplate
make -C cfsm CPPFLAGS='-D_FORTIFY_SOURCE=0'
mkdir /usr/local/share/cfsm