Skip to content

Instantly share code, notes, and snippets.

View zavakid's full-sized avatar
🍑
hungry

Zava zavakid

🍑
hungry
View GitHub Profile
@mxcl
mxcl / colbalt.xml
Created June 28, 2010 12:29
A nice color scheme for Java in IntelliJ.
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="Colbalt" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.1" />
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Monaco" />
<colors>
<option name="CARET_COLOR" value="ffffff" />
<option name="CARET_ROW_COLOR" value="133d61" />
<option name="FOLDING_TREE_COLOR" value="466a8a" />
<option name="INDENT_GUIDE" value="123b5f" />
@rednaxelafx
rednaxelafx / DumpClassURL.java
Created December 7, 2011 05:48
Using the ProtectionDomain of an InstanceKlass to see where it was loaded from
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.memory.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.tools.*;
public class DumpClassURL extends Tool {
public void run() {
@zavakid
zavakid / gist:1574212
Created January 7, 2012 08:39
rails resource control and path

Rails用這套慣例來大大簡化了路由設定。那程式該怎麼寫呢? 我們在config/routes.rb加入以下一行程式:

resources :events

如此就會自動建立四個命名路由(named routes),搭配四個HTTP動詞,對應到七個Actions。它的實際作用,就如同以下的設定:

get    '/events'          => "events#index",   :as => "events"
post   '/events'          => "events#create",  :as => "events"
get    '/events/:id'      => "events#show",    :as => "event"
put '/events/:id' => "events#update", :as => "event"

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 16, 2024 16:59
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@helena
helena / CloudExtension.scala
Last active December 21, 2015 00:29
Simple (and truncated) example of the CloudExtension's load-time ordered provisioning and ordered graceful shutdown. Unfortunately this had to be written in an older version of scala and akka - for now. MyNodeGuardian.scala is started in CloudExtension.register() and is a sample of using ProvisioningGuardian which extends OrderedGracefulShutdown.
/**
* CloudExtension and factory for creating CloudExtension instances.
* Example:
* {{{
* val application = CloudExtension(system, config)
* }}}
*
* @author Helena Edelson
*/
object CloudExtension extends ExtensionId[CloudExtension] with ExtensionIdProvider {
@helena
helena / ProvisioningActor.scala
Last active December 21, 2015 04:39
Rough, initial cut of a trait to mixin when an Actor requires initalization, where the initialization is long and arduous (for example, data initialization related). This strategy allows the implementing actor to delegate the work to another Actor, on a separate, dedicated Dispatcher, and not block any other related Actors in load-time.
import scala.collection.immutable
import scala.collection.immutable.Queue
import akka.actor._
/**
* Rough, initial cut of a trait to mixin when an Actor requires
* initalization, where the initialization is long and arduous (for
* example, data initialization related). This strategy allows the
* implementing actor to delegate the work to another Actor, on a
* separate, dedicated Dispatcher, and not block any other related
@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: