Skip to content

Instantly share code, notes, and snippets.

View xiaom's full-sized avatar
:octocat:

Xiao Meng xiaom

:octocat:
  • Goldsky
  • Canada
  • 16:04 (UTC -07:00)
View GitHub Profile
@senko
senko / maybe.py
Last active January 28, 2022 09:16
A Pythonic implementation of the Maybe monad
# maybe.py - a Pythonic implementation of the Maybe monad
# Copyright (C) 2014. Senko Rasic <senko.rasic@goodcode.io>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
@ZenBowman
ZenBowman / example.java
Last active April 24, 2017 07:30
Using the Hive Thrift Client in Java and Scala - an example
import junit.framework.TestCase;
import org.apache.hadoop.hive.service.HiveClient;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import java.util.List;
/**
#!/bin/zsh
#
# Highlight a given file and copy it as RTF.
#
# Simon Olofsson <simon@olofsson.de>
#
set -o errexit
set -o nounset
@nolanlawson
nolanlawson / completion-for-gradle.md
Last active April 5, 2024 07:43
Gradle tab completion for Bash. Works on both Mac and Linux.

Gradle tab completion script for Bash

A tab completion script that works for Bash. Relies on the BSD md5 command on Mac and md5sum on Linux, so as long as you have one of those two commands, this should work.

Usage

$ gradle [TAB]
@mushkevych
mushkevych / Dockerfile
Last active December 30, 2015 07:39
Docker CDH 4.5
FROM ubuntu:precise
MAINTAINER Bohdan Mushkevych
# Installing Oracle JDK
RUN apt-get -y install python-software-properties ;\
add-apt-repository ppa:webupd8team/java ;\
apt-get update && apt-get -y upgrade ;\
echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections ;\
apt-get -y install oracle-java7-installer && apt-get clean ;\
update-alternatives --display java ;\
@bmabey
bmabey / simple.clj
Last active December 29, 2015 18:59
(ns simple-sim
(require [clojure.core.async :as async]
[clojure.tools.logging :as log]
criterium.core
[com.benmabey.clj-sim :as sim]))
;; Andreas' code
(defn event [env type val]
(let [rc (async/chan)]
@jboner
jboner / akka-cluster-implementation-notes.md
Last active March 4, 2023 22:30
Akka Cluster Implementation Notes

Akka Cluster Implementation Notes

Slightly disorganized but reasonably complete notes on the algorithms, strategies and optimizations of the Akka Cluster implementation. Could use a lot more links and context etc., but was just written for my own understanding. Might be expanded later.

Links to papers and talks that have inspired the implementation can be found on the 10 last pages of this presentation.

Akka Gossip

Gossip state

This is the Gossip state representation:

#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
// add this to <profile>/static/custom/custom.js to load vim keybindings:
$.getScript("/static/components/codemirror/keymap/vim.js", function() {
if (! IPython.Cell) return;
IPython.Cell.options_default.cm_config.keyMap = "vim";
});
@lukerosiak
lukerosiak / mlb.py
Last active April 2, 2018 00:39
Parse MLB transactions and injuries into a spreadsheet.
#This web site lists recent injuries for MLB players in HTML format, but requires you to click each team, etc.
#http://mlb.mlb.com/mlb/fantasy/injuries/
#To do real data analysis, we want a shitton and don't have time to click everywhere.
#So our exercise is to get all available injuries into one easy to use spreadsheet.
#By looking at "view source" on the web site, I found that the web site actually hits another web site, which provides the injuries, trades and other info in a computer-readable format called JSON, which is basically
#the same as python's dictionary type. You can only get one month at a time bc there are so many. See it here:
#http://mlb.mlb.com/lookup/json/named.transaction_all.bam?start_date=20120301&end_date=20120401&sport_code='mlb'
#Our code will hit this web site repeatedly for different dates, convert the web site's content into a python object, and then write certain fields from that object to a file of the CSV format