Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'csv'
require 'json'
if ARGV.size != 2
puts 'Usage: csv_to_json input_file.csv output_file.json'
puts 'This script uses the first line of the csv file as the keys for the JSON properties of the objects'
exit(1)
end
@enriclluelles
enriclluelles / dabblet.css
Created September 4, 2013 15:14
Rounded arrows with CSS (SO)
/**
* Rounded arrows with CSS (SO)
* http://stackoverflow.com/questions/12461441/rounded-arrows-with-css/12461582#12461582
*/
.arrow {
width: 100px;
height: 100px;
border-radius: 0 0 10% 0;
border: none;
margin: 2em 2.5em;
@enriclluelles
enriclluelles / gist:2775500
Created May 23, 2012 14:24
Multithreaded seeds
Rails.configuration.cache_classes = true
Rails.configuration.threadsafe!
Rails.configuration.allow_concurrency = true
require "#{Rails.root}/test/factories"
Dir.glob(File.join(Rails.root, 'app', '{lib,app}', '*.rb')).each{|f| require f}
Rails.application.eager_load!
puts "Creating users..."
users = []
@enriclluelles
enriclluelles / main.go
Created January 27, 2017 02:44
Trigger reset by peer
package main
import (
"fmt"
"net"
"log"
)
func main() {
addr, _ := net.ResolveTCPAddr("tcp", ":3456")
@enriclluelles
enriclluelles / dyndns.py
Created February 22, 2016 23:21
poor man's dyndns using route53
from __future__ import print_function
import boto3
import botocore
import requests
import re
import sys
ip = requests.get("https://api.ipify.org").text
if not re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$",ip):
print("Fail getting the ip", file=sys.stderr)
@enriclluelles
enriclluelles / keybase.md
Created February 18, 2016 16:40
keybase.md

Keybase proof

I hereby claim:

  • I am enriclluelles on github.
  • I am enriclluelles (https://keybase.io/enriclluelles) on keybase.
  • I have a public key whose fingerprint is A0ED 7FB2 DE48 E28D 3864 D6C8 05E7 B98A E739 EED1

To claim this, I am signing this object:

function national_flag(a, p) {
function swap(i, j) {
// console.log("swapping a[" + i + "]:" + a[i] + " a[" + j + "]:" + a[j]);
var aux = a[i];
a[i] = a[j];
a[j] = aux;
}
var value = a[p];
@enriclluelles
enriclluelles / dabblet.css
Created September 4, 2013 15:14
Rounded arrows with CSS (SO)
/**
* Rounded arrows with CSS (SO)
* http://stackoverflow.com/questions/12461441/rounded-arrows-with-css/12461582#12461582
*/
body {
padding-top: 5em;
background: linear-gradient(left, plum 50%, transparent 50%);
background-size: 5.1em 1px
}
.arrow {
['~>3.2.0', '~>4.0.0rc1'].each do |ver|
pid = fork do
puts ver
gem 'rails', ver
require 'rails/all'
require_relative './lib/route_translator'
routes = ActionDispatch::Routing::RouteSet.new
class PeopleController < ActionController::Base
v=0207;eval$s=%q~d=%!^Lcf<LK8, _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
4ZojjV)O>qIH1/n[|2yE[>:ieC "#######% .#" 97N-A&Kj_K_><wS5rtWk@*a+Y5
yH?b[F^e7C/56j|pmRe+:)B "##########: : " O98(Zh)'Iof*nm.,$C5Nyt=
PPu01Avw^<IiQ=5$'D-y? "#############. " g6`YT+qLw9k^ch|K'),tc
6ygIL8xI#LNz3v}T=4W "############: . " lL27FZ0ij)7TQCI)P7u
}RT5-iJbbG5P-DHB<. "############# . " R,YvZ_rnv6ky-G+4U'
$*are@b4U351Q-ug5 "############## " 00x8RR%`Om7VDp4M5
PFixrPvl&<p[]1IJ "# %######### " EGgDt8Lm#;bc4zS^
y]0`_PstfUxOC(q " %#: %##: : " /,}.YOIFj(k&q_V
zcaAi?]^lCVYp!; " #. .:#. . " ;s="v=%04o;ev"%