Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / wordcount.clj
Created January 13, 2012 19:45
Reliable word-count topology
(ns topologies.core
(:import [backtype.storm StormSubmitter LocalCluster])
(:require [clojure.test :as test])
(:use [backtype.storm clojure config])
(:gen-class))
(def id-count (atom 0)) ;; tuple counter for debugging -- something to make ids out of
(defspout sentence-spout ["sentence"]
@kamermans
kamermans / sessionclean
Created August 13, 2014 00:08
Replacement PHP session cleaner for Ubuntu (place inside /usr/lib/php5/)
#!/bin/sh
# check if file-based sessions are enabled
file_storage=$(/usr/lib/php5/sessionstorage | grep '^files$' -c)
if [ "$file_storage" = "0" ]; then
exit 0
fi
# first find all used files and touch them (hope it's not massive amount of files)
@josevalim
josevalim / sample output
Created May 24, 2012 17:53 — forked from alco/sample output
Updated Elixir chat demo
defmodule Chat.Client do
# In all of the following functions 'server' stands for the server's pid
def join(server) do
send server, :join
end
def say(server, message) do
send server, { :say, message }
end
@freeman-lab
freeman-lab / StreamingKMeans.scala
Last active February 26, 2019 07:13
Spark Streaming + MLLib integration examples
package thunder.streaming
import org.apache.spark.{SparkConf, Logging}
import org.apache.spark.rdd.RDD
import org.apache.spark.SparkContext._
import org.apache.spark.streaming._
import org.apache.spark.streaming.dstream.DStream
import org.apache.spark.mllib.clustering.KMeansModel
import scala.util.Random.nextDouble
@upsuper
upsuper / bgmrank.rb
Last active May 14, 2019 03:40
统计 Bangumi 上一个用户的收藏的评分分布情况,已移至 https://github.com/upsuper/bgmrank
#!/usr/bin/env ruby
require 'optparse'
require 'net/http'
CATEGORIES = [:anime, :book, :music, :game, :real]
STATES = [:wish, :collect, :do, :on_hold, :dropped]
progress = true
options = {
@keltia
keltia / migrate-gems.sh
Created April 10, 2017 11:41
Migrate all gems from one Ruby version to another, useful when using `rbenv`
#!/bin/zsh -i
# if you're using ZSH, change the shebang above to "#!/bin/zsh -i"
eval "$(rbenv init -)"
if [ ${#} -ne 2 ]; then
echo >&2 Usage: $(basename ${0}) old-version new-version
exit 1
fi
@baoshan
baoshan / install-pypy.sh
Created April 24, 2012 11:23
Install PyPy on CentOS
# yum list \*openssl\*
yum install -y openssl098e
yum install -y zlib
ln -s /usr/lib64/libssl.so.0.9.8e /usr/lib64/libssl.so.0.9.8
ln -s /usr/lib64/libcrypto.so.0.9.8e /usr/lib64/libcrypto.so.0.9.8
ln -s /lib64/libbz2.so.1 /lib64/libbz2.so.1.0
wget https://bitbucket.org/pypy/pypy/downloads/pypy-1.8-linux64.tar.bz2
tar -xf pypy-1.8-linux64.tar.bz2
cp -r pypy-1.8 /opt
ln -s /opt/pypy-1.8/bin/pypy /usr/local/bin
@mbejda
mbejda / openssl.ssh
Created April 12, 2016 12:37
Installing OpenSSL 1.0.2 on Ubuntu 14
openssl version -a
sudo add-apt-repository ppa:0k53d-karl-f830m/openssl
sudo apt-get update
sudo apt-get install openssl
openssl version -a
@abhin4v
abhin4v / Fibonacci.java
Created November 24, 2009 18:46
Python-style Generator in Java
package net.abhinavsarkar.util;
/**
* A (infinite) Fibonacci number generator.
*
* @author Abhinav Sarkar
*/
public class Fibonacci extends Generator<Integer> {
@numberoverzero
numberoverzero / async_value.py
Created July 6, 2015 02:50
Variable that can be `await`ed on to reach a certain value, without blocking an event loop
import asyncio
missing = object()
class Value:
'''
Simple class that enables `await value.wait_for(foo)` to wait until the
variable is set to the expected value, without blocking the event loop.
Loosely modeled after asyncio.Event and asyncio.Condition