This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'em-http' | |
require 'eventmachine' | |
url = ARGV[0] | |
puts "going to try to download #{url}" | |
EventMachine.run do | |
req = EventMachine::HttpRequest.new(url).get | |
File.unlink("really_big_file") if File.exist?("really_big_file") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns chaotic-god.core | |
(:require [goog.dom :as dom] | |
[goog.Timer :as timer] | |
[goog.events :as events] | |
[goog.events.EventType :as event-type] | |
[goog.events.KeyCodes :as key-codes] | |
[chaotic-god.utils :as utils] | |
[cljs.core.async :refer [>! <! chan put! close! timeout]]) | |
(:require-macros [cljs.core.async.macros :refer [go alt!]])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NullObject | |
def method_missing(*args, &block) | |
self | |
end | |
def nil?; true; end | |
end | |
def Maybe(value) | |
value.nil? ? NullObject.new : value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HODOR | |
module.exports = (robot) -> | |
robot.hear /hodor/i, (msg) -> | |
msg.send "HODOR" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> (def some-hash {:hello {:name "john" :aliases [{:text "woot"} {:name "lala"}]}}) | |
#'user/some-hash | |
user=> (some-> some-hash :hello :name) | |
"john" | |
user=> (some-> some-hash :hello :age) | |
nil | |
user=> (some-> some-hash :byebye :name) | |
nil | |
user=> (some-> some-hash :hello :aliases first) | |
{:text "woot"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>minimalism</title> | |
<script type="text/javascript" src="../closure/closure/goog/base.js"></script> | |
<script type="text/javascript" src="minimalism.js"></script> | |
</head> | |
<body onload="minimalism.start()"></body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def status-params | |
{:count 200}) | |
(defn tweets | |
"Get the user's tweets | |
params contains params to override the defaults, such as :since_id" | |
[params] | |
(:body (statuses-home-timeline :oauth-creds my-creds | |
:params (merge status-params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'RMagick' | |
def generate_image(name, size) | |
puts "#{name}: generate #{size}x#{size} image" | |
Magick::Image::read('logo.png').first.resize(size, size).write(name) | |
end | |
[144, 120, 114, 100, 72, 60, 58, 57, 50, 29].each do |size| | |
generate_image("icon-#{size}x#{size}.png", size) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'pickup' | |
gem 'riemann-client' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(streams | |
(where (and metric (service "app1")(tagged "sign_in") | |
; We want to get alerted about failed sign ins. However we expect that there will be failures | |
; due to incorect passwords etc. So we only want to get alerted if more than 50% of the signins | |
; in a 60 second period are failures. The app tags failed signins with a warning state. | |
(fixed-time-window 60 | |
(smap (fn [events] | |
; count all warnings and count all received events and work out the percentage | |
(let [percent (/ (count (filter #(= (:state %) "warning") events)) | |
(count events))] |