Skip to content

Instantly share code, notes, and snippets.

View agrison's full-sized avatar

Alexandre Grison agrison

View GitHub Profile
@agrison
agrison / gems-one-liner.clj
Created September 27, 2016 06:44
HackerRank gems-one-liner.clj
(use '[clojure.string :only (split-lines)]
'[clojure.set :only (intersection)])
(->> (slurp *in*) split-lines rest (map set) (apply intersection) count println)
@agrison
agrison / gems.clj
Created September 27, 2016 06:43
HackerRank gems.clj
(use '[clojure.string :only (split-lines)]
'[clojure.set :only (intersection)])
(->> split-lines (slurp *in*)
rest
(map set)
(apply intersection)
count
println)
@agrison
agrison / foo.sh
Created March 3, 2016 08:43
Create a Dash dockset from ricostacruz.com/cheatsheets
# Download it all
wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains ricostacruz.com \
--no-parent \
@agrison
agrison / generate-meta-model.neo4j.cql
Last active September 28, 2015 13:28
Create a meta model of nodes and relationship already in Neo4J.
MATCH (n1)-[r]->(n2)
WITH labels(n1) AS node1_labels, type(r) AS relation_type, labels(n2) AS node2_labels
UNWIND node1_labels as node1_label
UNWIND node2_labels as node2_label
MERGE (n1:Meta_Node {name: node1_label})
MERGE (n2:Meta_Node {name: node2_label})
MERGE (n1)-[:META_RELATIONSHIP {name:relation_type}]->(n2)
@agrison
agrison / foomt.go
Created July 23, 2015 08:25
Sample Go App to mass insert 1M keys in redis using goroutines and unix socket
package main
import (
"fmt"
"log"
"net"
"runtime"
"sync"
"time"
@agrison
agrison / foo.go
Created July 23, 2015 07:42
Sample Go app to mass import 1M keys in redis
package main
import (
"fmt"
"log"
"net"
"runtime"
"time"
"github.com/garyburd/redigo/redis"
@agrison
agrison / OpenHFTImport.java
Created July 22, 2015 14:40
Sample OpenHFT import using spring boot
package me.grison.openhft.foo;
import net.openhft.collections.SharedHashMap;
import net.openhft.collections.SharedHashMapBuilder;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@agrison
agrison / RedisMassInport.java
Created July 22, 2015 14:14
Simple spring boot app with Jedis inserting 1M keys in redis using pipelining and multi-threading
package me.grison.redis.foo;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.Jedis;
@agrison
agrison / RedisMassImport.java
Last active August 29, 2015 14:25
Simple spring boot app that inserts 1M random key into redis using one connection and pipelining
package me.grison.redis.foo;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.context.annotation.*;
import redis.clients.jedis.*;
import java.util.UUID;
@ComponentScan
@agrison
agrison / gen-redis-proto.py
Last active August 29, 2015 14:25
Generate 1M redis SET commands using redis protocol
from __future__ import print_function
import uuid, sys
def redis_protocol(cmd):
proto = "*%d\r\n" % len(cmd.split(' '))
for arg in cmd.split(' '):
proto += "$%d\r\n%s\r\n" % (len(arg), arg)
return proto
sample = ""