Skip to content

Instantly share code, notes, and snippets.

View Jell's full-sized avatar

Jean-Louis Giordano Jell

View GitHub Profile
@Jell
Jell / timetravel.rb
Created November 15, 2020 11:02
Fun with callcc
require "continuation"
class Hash
alias_method :_original_lookup, :[]
def [](key)
_original_lookup(key).tap do
callcc { |cc| $hash_cc = [cc]; nil }&.tap do |value_from_future|
self[key] = value_from_future
$hash_cc.pop.call(self)
@Jell
Jell / thor_autocomplete.rb
Last active April 12, 2020 23:39
Thor autocomplete
#!/usr/bin/env ruby
# Complete thor tasks script for bash
# Save it somewhere and then add
# complete -C path/to/script -o default thor
# to your ~/.bashrc
require 'fileutils'
THORFILES = ['thorfile', 'Thorfile', 'thorfile.rb', 'Thorfile.rb', '*.thor']
@Jell
Jell / Assignment.md
Last active November 25, 2019 15:53

Programming Assignment

Write a script/program that reads a sequence of mathematical expressions from a file and prints the result of evaluating all expressions in the order they appear.

The file consists of a series of expressions, one per line.

Each line is in the format function <value>. ADD 5, for example, adds 5 to the current value. The initial value when the program starts is 0. A file contains maximum ten rows.

The following functions shall be supported:

# Install java and make sure JAVA_HOME is properly set.
# Make sure those dependencies are present:
sudo apt-get install g++ uuid-dev libtool autoconf automake
cd ~
# install zeromq
wget http://download.zeromq.org/zeromq-2.1.7.tar.gz
tar -xzf zeromq-2.1.7.tar.gz
module Test
import TestProvider
%default total
%language TypeProviders
add : Int -> Int -> Int
add x y = 0
%provide (result : String) with compileTest [
{-# LANGUAGE Rank2Types #-}
import Control.Lens hiding (element)
import Data.Text as T (splitOn
, concat
, Text
, pack
, toTitle
, toLower)
twiceLens :: String -> Iso' Text (String, Text)
@Jell
Jell / dinghy-connect.sh
Last active August 17, 2017 15:00
Recipe for SSH forwarding with dinghy (https://github.com/codekitchen/dinghy)
function dinghy-connect {
# Make sure SSH agent is running
ssh-add -K
# Make sure dinghy is up and running
dinghy create 2> /dev/null || echo "dinghy VM already created"
dinghy up 2> /dev/null || echo "dinghy VM already running"
# Check if SSH forwarding is already in place
DINGHY_SSH_SOCK=$(dinghy ssh find -type f /tmp/ssh-*/agent.* 2> /dev/null || echo "missing")
@Jell
Jell / cljs.test.repl.clj
Created August 30, 2016 17:37
CLJS run single test var
(ns cljs.test.repl
(:require [cljs.analyzer.api :as ana-api]
[cljs.analyzer :as ana]
[cljs.test]))
(defmacro run-single-test [[quote var :as form]]
(let [ns (or (some-> var namespace symbol)
ana/*cljs-ns*)]
`(cljs.test/run-block
(concat
@Jell
Jell / storm.yaml
Last active December 16, 2015 11:39
---
nimbus.host: "192.168.1.106"
storm.zookeeper.servers:
- "192.168.1.106"
storm.local.dir: "/mnt/storm"
worker.childopts: "-Xmx128m"
supervisor.childopts: "-Xmx128m"
supervisor.slots.ports:
- 6700
at_exit do
ActiveRecord::Base.clear_all_connections!
java.lang.Thread.all_stack_traces.key_set.each do |t|
t.synchronized do
if t.name.include?("Abandoned connection cleanup thread")
t.class.shutdown
end
end
end
end