Skip to content

Instantly share code, notes, and snippets.

View elrikdante's full-sized avatar

Dante Haskell Elrik elrikdante

View GitHub Profile
var EventType = {
MessagePosted: 1,
MessageEdited: 2,
UserEntered: 3,
UserLeft: 4,
RoomNameChanged: 5,
MessageStarred: 6,
DebugMessage: 7,
UserMentioned: 8,
MessageFlagged: 9,

Standardized Ladder of Functional Programming

The LambdaConf Ladder of Functional Programming (LOFP) is a standardized progression of different concepts and skills that developers must master on their journey to becoming expert-level functional programmers. LOFP can be used to rank workshops, talks, presentations, books, and courseware, so that aspiring functional programmers have a better understanding of what material is appropriate for them given their current experience.

Novice

Concepts

  • Immutable Data
  • Second-order Functions
@elrikdante
elrikdante / quick_sort.c
Created September 19, 2016 03:25 — forked from mbalayil/quick_sort.c
Quick Sort using recursion in C
/** Divide : Partition the array A[low....high] into two sub-arrays
* A[low....j-1] and A[j+1...high] such that each element
* of A[low....j-1] is less than or equal to A[j], which
* in turn is is less than or equal to A[j+1...high]. Compute
* the index j as part of this partitioning procedure.
* Conquer : Sort the two sub-arrays A[low....j-1] and A[j+1....high]
* by recursive calls to quicksort
**/
#include<stdio.h>
#
#= dump database to yaml for fixtures
#
# originated by elm200 <http://d.hatena.ne.jp/elm200/20070928/1190947947>
#
#== install
#
# move this file to RAILS_ROOT/lib/tasks/extract_fixtures.rake
#
namespace :db do
@elrikdante
elrikdante / index.html
Created May 25, 2016 06:17 — forked from RickWong/react.html
Write React apps in 1 HTML file.
<html>
<body>
<div id="react-root"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react-with-addons.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react-dom.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.5.2/redux.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.7.7/babel.min.js"></script>
<script id="App" type="text/template">
const App = ({name}) => {
@elrikdante
elrikdante / geocode_coordinates.rb
Created May 1, 2016 02:09 — forked from ole/geocode_coordinates.rb
Geocodes addresses on the command line and print the geo coordinates (latitude and longitude). See http://oleb.net/blog/2014/01/geocoding-automator-service/ for more info on how I am using this script.
#!/usr/bin/env ruby
# Determines the coordinates (latitude and longitude) of the places or
# addresses passed as arguments (either on the command line or via stdin)
# and prints the results.
# This script requires the Ruby Geocoder gem by Alex Reisner
# (http://www.rubygeocoder.com).
# To install the gem, run this command from a Terminal session:
#
@elrikdante
elrikdante / ShopifyAPICallLimit.rb
Created April 12, 2016 04:51 — forked from resistorsoftware/ShopifyAPICallLimit.rb
Hacking ActiveResource::Connection for Shopify API in order to read HTTP response header 'http_x_shopify_api_call_limit'. Simply require this code after your gems have been loaded.
class ActiveResource::Connection
# HACK 1: Add an attr_reader for response
attr_reader :response
def request(method, path, *arguments)
result = ActiveSupport::Notifications.instrument("request.active_resource") do |payload|
payload[:method] = method
payload[:request_uri] = "#{site.scheme}://#{site.host}:#{site.port}#{path}"
payload[:result] = http.send(method, path, *arguments)
end
@elrikdante
elrikdante / shallow_nested_routes.rb
Created April 12, 2016 04:48 — forked from slamotte/shallow_nested_routes.rb
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.
@elrikdante
elrikdante / Accommodation.rb
Created April 12, 2016 04:47 — forked from jeroenr/Accommodation.rb
Use ActiveResource with non-Rails REST API
class Accommodation < ActiveResource::Base
class << self
def element_path(id, prefix_options = {}, query_options = nil)
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
"#{prefix(prefix_options)}#{collection_name}/#{id}#{query_string(query_options)}"
end
def collection_path(prefix_options = {}, query_options = nil)
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
"#{prefix(prefix_options)}#{collection_name}#{query_string(query_options)}"
@elrikdante
elrikdante / get_messages_off_rabbitmq.rb
Created March 30, 2016 13:46 — forked from natritmeyer/get_messages_off_rabbitmq.rb
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