Skip to content

Instantly share code, notes, and snippets.

export NOTIFY_TIME=10
function timer_start {
previous_command=$this_command
if [ "$BASH_COMMAND" != "timer_stop" ]
then
this_command=$BASH_COMMAND
fi
timer=${timer:-$SECONDS}
@xaviershay
xaviershay / ruby_live_gc_stats.rb
Created November 10, 2013 21:17
naive jstat proof-of-concept for ruby
Thread.new do
GC::Profiler.enable
current_message = ""
epoch = Time.now
total_time = 0
gc_events = 0
heap_use = 0
heap_size = 0
fmt = "%7s %5s %15s %15s %10s"
@xaviershay
xaviershay / befunge_compiler_prototype.rb
Created July 17, 2013 03:59
A very quick sketch of a befunge compiler.
class ValueObject < Struct
def self.[](*args)
if args.length > 0
new(*args)
else
new(:null)
end
end
def [](*args)
@headius
headius / gist:3491618
Created August 27, 2012 19:34
JVM + Invokedynamic versus CLR + DLR

Too much for teh twitterz :)

JVM + invokedynamic is in a completely different class than CLR + DLR, for the same reasons that JVM is in a different class than CLR to begin with.

CLR can only do its optimization up-front, before executing code. This is a large part of the reason why C# is designed the way it is: methods are non-virtual by default so they can be statically inlined, types can be specified as value-based so their allocation can be elided, and so on. But even with those language features CLR simply cannot optimize code to the level of a good, warmed-up JVM.

The JVM, on the other hand, optimizes and reoptimizes code while it runs. Regardless of whether methods are virtual/interface-dispatched, whether objects are transient, whether exception-handling is used heavily...the JVM sees through the surface and optimizes code appropriate for how it actually runs. This gives it optimization opportunities that CLR will never have without adding a comparable profiling JIT.

So how does this affect dynamic

@caseycrites
caseycrites / AsyncTest.Java
Created July 10, 2012 15:52
Properly test async Android code
/*
I've been writing tests for Android code that uses Handlers to communicate with background threads.
I couldn't get my callbacks to be called back to.
I got angry.
I finally found the solution...after way too much looking.
Here it is.
*/
package com.caseycrites.android.testexample
@bshepherdson
bshepherdson / gist:2301301
Created April 4, 2012 14:01
Mirah build error
> jruby -S rake jar ~/src/mirah
mkdir -p dist
mkdir -p build
Compiling Ruby sources
Compiling Mirah sources
Parsing...
org/mirah/class_loader.mirah
org/mirah/isolated_resource_loader.mirah
org/mirah/ant/compile.mirah
duby/lang/compiler/interfaces.duby
@mbbx6spp
mbbx6spp / README.md
Created February 7, 2012 17:58
Websockets with Netty (Scala translation) - WORK IN PROGRESS! Currently it expects an integer and will respond with its square. It isn't very interesting but it serves as a boilerplate/skeleton.

Experimentation with Netty and Scala's Types

Status

  • Only first pass complete: raw translation from Java example to Scala.
  • Second pass [incomplete]: abstracting to make server and client specific code composable.

TODO:

  • Create declarative and composable Pipeline definition
@BPScott
BPScott / readme.md
Last active February 7, 2024 16:16
Github suggestion: Per-organization email overrides

This totally happened, y'all can stop +1ing this now. GitHub Blog post. Direct link to settings where you can set this.


#Per-organization / per-repo email overrides - A feature suggestion

Here the concepts "organization" and "user" are interchangeable, I'm talking about an entity that owns a repo, whether it is jQuery or John Resig. I'll stick to using organization as it best represents my original use-case.

##TL;DR

@headius
headius / gist:1234935
Created September 22, 2011 14:38
OS X 'pickjdk' command with single-command selection and updated JDK location
#!/bin/bash
#
# Provides a function that allows you to choose a JDK. Just set the environment
# variable JDKS_ROOT to the directory containing multiple versions of the JDK
# and the function will prompt you to select one. JAVA_HOME and PATH will be cleaned
# up and set appropriately.
_macosx()
{
if [ $(uname -s) = Darwin ]; then
@jcasimir
jcasimir / api.markdown
Created September 12, 2011 20:08
Exposing an API in Rails 3

Exposing an API

APIs are becoming an essential feature of modern web applications. Rails does a good job of helping your application provide an API using the same MVC structure you're accustomed to.

In the Controller

Let's work with the following example controller:

class ArticlesController &lt; ApplicationController