Skip to content

Instantly share code, notes, and snippets.

@tk3
tk3 / gist:1670430
Created January 24, 2012 14:28
LDAP server(tentative)
#!/opt/ruby/bin/ruby
require "socket"
require "pp"
gs = TCPServer.open(1500)
addr = gs.addr
addr.shift
printf("server is on %s\n", addr.join(":"))
@tk3
tk3 / ffi_sample.c
Created July 19, 2012 13:16
FFI library Sample
#include <ffi.h>
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
int test_call_puts(void);
int invoke_puts(void *func);
int test_call_strcpy(void);
int invoke_strcpy(void *func);
@tk3
tk3 / gist:3159695
Created July 22, 2012 13:35
gdb cfunc_test -c core
$ gdb cfunc_test -c core.7700
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-50.el6)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
@tk3
tk3 / Mrb.c
Created September 13, 2012 16:11
F# meets mruby
#include "Mrb.h"
#include "mruby.h"
#include "mruby/proc.h"
#include "mruby/array.h"
#include "mruby/string.h"
#include "mruby/compile.h"
#include "mruby/dump.h"
using namespace Mrb;
@tk3
tk3 / abcd.rb
Last active December 10, 2015 12:28
#!mruby
db = SQLite3::Database.new('example/foo.db')
begin
db.execute_batch(
'drop table foo;' + \
'drop table bar;' \
)
rescue RuntimeError
$ valgrind --dsymutil=yes ../../../bin/mruby example/example.rb
==82019== Memcheck, a memory error detector
==82019== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==82019== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==82019== Command: ../../../bin/mruby example/example.rb
==82019==
==82019== WARNING: Support on MacOS 10.8 is experimental and mostly broken.
==82019== WARNING: Expect incorrect results, assertions and crashes.
==82019== WARNING: In particular, Memcheck on 32-bit programs will fail to
==82019== WARNING: detect any errors associated with heap-allocated data.
@tk3
tk3 / gist:5917458
Created July 3, 2013 12:21
Install chocolatey
C:\Users\foo>@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\choc
olatey\bin
Downloading http://chocolatey.org/api/v2/package/chocolatey/ to C:\Users\foo\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip
Extracting C:\Users\foo\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to ...
Installing chocolatey on this machine
Creating ChocolateyInstall as a User Environment variable and setting it to 'C:\Chocolatey'
We are setting up the Chocolatey repository for NuGet packages that should be at the machine level. Think executables/application packages, not library packages.
That is what Chocolatey NuGet goodness is for.
The repository is set up at 'C:\Chocolatey'.
The packages themselves go to 'C:\Chocolatey\lib' (i.e. C:\Chocolatey\lib\yourPackageName).
@tk3
tk3 / gist:0f2a6d9979902cbf67f6
Created February 4, 2015 15:54
Selenium F# memo
#light
open System
open OpenQA.Selenium
open OpenQA.Selenium.Remote
// DesiredCapabilities.InternetExplorer
// let capability = DesiredCapabilities.Chrome()
@tk3
tk3 / build_ngx_mruby.sh
Last active August 29, 2015 14:15
ngx_mruby on CentOS 6.5 (x86_64)
#!/bin/sh
#
# CentOS release 6.5 (Final)
#
sudo yum -y install readline-devel libyaml-devel openssl-devel
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
@tk3
tk3 / create_build_config.sh
Last active August 29, 2015 14:15
create build_config.sh
mgem add mruby-redis
mgem add mruby-curl
mgem config << __CONFIG__
gcc
y
y
y
y
y