Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Wheeler AlexWheeler

View GitHub Profile
View flipper-moneta-performance.rb
require 'moneta'
require 'flipper'
load './lib/flipper/adapters/moneta.rb'
moneta = Moneta.build do
use :Logger
adapter :Memory
end
adapter = Flipper::Adapters::Moneta.new(moneta)
View content-type.rb
content_type = request["content-type"]
View open.rb
require 'gruff'
g = Gruff::Line.new(400)
g.maximum_value = 100
g.minimum_value = 0
g.y_axis_increment = 5
g.theme = {
:colors => %w(black red),
:marker_color => 'grey',
:font_color => 'black',
View mixin.rb
module Request
HEADERS = { 'Content-Type' => 'application/json' }.freeze
def self.add_headers(headers)
HEADERS.merge!(headers)
end
def get_request(path)
uri = URI.parse(path)
http = Net::HTTP.new(uri.host, uri.port)
View clj.clj
(defn- copy-nil-vals [[k v]]
(if (nil? v)
{k k}
{k v}))
(defn column-vals [column-mappings]
(->> column-mappings
(map #(select-keys % [:value :mapped_value]))
(map vals)
(map #(apply hash-map %))
View a_list.sql
WITH RECURSIVE tree AS (
SELECT id, ARRAY[]::INTEGER[] AS ancestors
FROM test WHERE parent_id IS NULL
UNION ALL
SELECT test.id, tree.ancestors || test.parent_id
FROM test, tree
WHERE test.parent_id = tree.id
View code.clj
;; project.clj
...
:dependencies [[org.clojure/clojure "1.8.0"]
[clj-ssh "0.5.14"]]
(ns csv-loader.csv
(:require [clj-ssh.ssh :as ssh]))
View public.rb
class Foo
def baz
log("some msg")
2
end
def bar(n)
n + baz
end
View gist:6aea1293a59b74d2472b59a6e565ac08
def m
enum = [1,2,3].each
loop do
enum.next
end
end
# m returns [1,2,3]
View gist:2e30e272bc2dfacb63711ffed3626111
<div id="player">Click ME FRITZ</div>
<script>
$(document).ready(function() {
player = new Audio("img/songs/test.mp3");
$('#player').click(function(){
player.play();
}
});
</script>