Skip to content

Instantly share code, notes, and snippets.

View elrikdante's full-sized avatar

Dante Haskell Elrik elrikdante

View GitHub Profile
@slamotte
slamotte / shallow_nested_routes.rb
Last active March 21, 2018 12:06
Allows ActiveResource to be used with shallow nested routes.
module ShallowNestedRoutes
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
# Pass in the name of the parent class
def set_shallow_nested_route_parent(parent)
parent = parent.to_s
# Override these methods so they set the prefix path before a call and reset it afterward.
@rbresearch
rbresearch / Quandl_rev1.R
Last active January 21, 2016 04:40
Revised quandl to allow for loading multiple symbols
library(RJSONIO)
library(xts)
Quandl <- function(code, env = .GlobalEnv, type = c('raw', 'ts', 'zoo', 'xts'), start_date, end_date, transformation = c('', 'diff', 'rdiff', 'normalize', 'cumul'), collapse = c('', 'weekly', 'monthly', 'quarterly', 'annual'), rows, authcode = Quandl.auth()) {
## Flag to indicate frequency change due to collapse
freqflag = FALSE
# remove everything before the "/" for assigning the symbols to variable names
sym.names <- gsub(".*/", "", code)
@ekmett
ekmett / ekmett_conf.log
Created April 1, 2013 04:30
#haskell-lens log from ekmett_conf
[00:24] fumieval ([email protected]) joined the channel.
[00:25] nushio3 (7c277e42@gateway/web/freenode/ip.124.39.126.66) joined the channel.
[00:25] nushio3: hi there!
[00:26] edwardk: hello, hello!
[00:27] hiratara ([email protected]) joined the channel.
[00:27] fumieval: hi
[00:28] carter: hello everyone! Wait, is this the presentation room now?
[00:30] edwardk: Yep
[00:30] carter: enjoy!
[00:30] tanakh_ ([email protected]) joined the channel.
@mariovisic
mariovisic / microlancer_wbench.txt
Created May 20, 2013 07:53
wbench test for microlancer.com after async loading web fonts.
Testing http://www.microlancer.com/
At Mon May 20 17:52:07 2013
10 loops
Fastest Median Slowest Std Dev
---------------------------------------------------------------------------
Server performance:
Total application time 71ms 115ms 482ms 121ms
Host latency:
@acowley
acowley / VectorByteString.hs
Created June 7, 2013 16:21
Data.Vector.Storable and Data.ByteString
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Monad ((>=>))
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
import qualified Data.ByteString.Unsafe as B
import Data.Vector.Storable (Vector)
import qualified Data.Vector.Storable as V
import Foreign.C.String (CStringLen)
import Foreign.Ptr (castPtr)
import Foreign.Storable (Storable(sizeOf))
@natritmeyer
natritmeyer / get_messages_off_rabbitmq.rb
Last active February 16, 2024 13:52
Get messages off a RabbitMQ... Queue!
require 'httparty'
require 'json'
class QueueInspector
include HTTParty
basic_auth "guest", "guest"
base_uri "http://192.168.0.1:55672"
def messages
body = {'count' => 5,'requeue' => true, 'encoding' => 'auto', 'truncate' => 50000}.to_json
@yantonov
yantonov / mgdb.sh
Created July 24, 2013 01:49
mongod start script
#/bin/bash
function start {
$MONGODB_HOME/bin/mongod --config=$MONGODB_HOME/bin/mongo.conf
}
case $1 in
start)
start
;;
@jamesejr
jamesejr / ruby-pack.txt
Created August 25, 2013 18:56
A list of Ruby directives for 'pack' e.g. [1,2,3].pack("CCn") => "\x01\x02\x00\x03"
Integer | Array |
Directive | Element | Meaning
---------------------------------------------------------------------------
C | Integer | 8-bit unsigned (unsigned char)
S | Integer | 16-bit unsigned, native endian (uint16_t)
L | Integer | 32-bit unsigned, native endian (uint32_t)
Q | Integer | 64-bit unsigned, native endian (uint64_t)
| |
c | Integer | 8-bit signed (signed char)
s | Integer | 16-bit signed, native endian (int16_t)
require 'dfp_api'
require 'httparty'
require 'oauth2'
CLIENT_ID = 'MY CLIENT ID'
CLIENT_SECRET = 'MY CLIENT SECRET'
NETWORK_CODE = 'MY NETWORK CODE'
dfp = DfpApi::Api.new({
authentication: {
@dillera
dillera / hack.sh
Last active September 25, 2021 22:37 — forked from erikh/hack.sh
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://gist.github.com/dillera/8108813/raw/ed65b97d3b910cb3536c3e522d4baebd442ff512/hack.sh | sh
#