Skip to content

Instantly share code, notes, and snippets.

@tlewin
tlewin / solution.clj
Created February 13, 2019 20:12 — forked from skuro/readme.org
Meetup #111 solutions
(defn generate-row [n]
(map (fn [_]
(rand-int 2))
(range n)))
(defn generate-grid [n]
(map (fn [_] (generate-row n)) (range n)))
(generate-grid 5)
@tlewin
tlewin / har2csv.rb
Created March 1, 2015 00:20
Simple Ruby script to convert HAR files into CSV files
#! /usr/bin/env ruby
require 'oj'
require 'csv'
require 'uri'
unless ARGV.size == 2
puts 'USAGE:'
puts "\t har2csv.rb har_filename csv_filename"
exit 0
end
@tlewin
tlewin / Preferences.sublime-settings
Created January 5, 2015 23:23
My Sublime preferences
{
"color_scheme": "Packages/Dayle Rees Color Schemes/sublime/freshcut.tmTheme",
"draw_white_space": "all",
"font_face": "Courier New",
"font_size": 14,
"ignored_packages":
[
"Vintage"
],
"rulers":
@tlewin
tlewin / .zshrc
Last active August 29, 2015 14:12
My `.zshrc` file.
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="ys"
# Example aliases
require 'goliath'
module Goliath
class Request
old_post_process = instance_method(:post_process)
define_method(:post_process) do |results|
status, headers, body = *results
# Include any data here
# All requests will pass here
require 'goliath'
# require 'em-synchrony/activerecord'
class Hello < Goliath::API
def response env
[200, {}, 'Hello World']
end
end
@tlewin
tlewin / chat.rb
Last active March 28, 2018 22:57
#!/usr/bin/env ruby -I ../lib -I lib
# coding: utf-8
require 'rtoken'
require 'json'
require 'sinatra/base'
require 'thin'
class Chat < Sinatra::Base
@tlewin
tlewin / mysignal.c
Last active June 26, 2017 10:31
Force ruby extension process signals like Ctrl + C
#include <stdio.h>
#include <unistd.h>
#include <ruby.h>
/* Force ruby extension process signals like Ctrl + C */
void process_signal(int signal) {
VALUE pid;
/* force call any block on trap function */
pid = rb_funcall(rb_mProcess, rb_intern("pid"), 0);