Skip to content

Instantly share code, notes, and snippets.

View ondreian's full-sized avatar
🎯
Focusing

Benjamin Clos ondreian

🎯
Focusing
View GitHub Profile
require 'ostruct'
class Bounty
class Parser
@@task_assignment_regexs = {
/It appears they have a creature problem they'd like you to solve/ => :cull,
/It appears they need your help in tracking down some kind of lost heirloom/ => :heirloom,
/The local furrier .+ has an order to fill and wants our help/ => :skins,
/The local gem dealer, [^,]+, has an order to fill and wants our help/ => :gem,
# /to provide a protective escort/ => :escort,
load 'bounty_parser.lic'
class Bounty
describe Parser, "#parse" do
it "can tell when we don't have a task" do
bounty = described_class.parse "You are not currently assigned a task."
bounty[:task].should == :taskmaster
bounty[:requirements].should be_nil
bounty[:status].should be_nil
end
require 'ostruct'
class Bounty
class Parser
@@task_assignment_regexs = {
/It appears they have a creature problem they'd like you to solve/ => :cull,
/It appears they need your help in tracking down some kind of lost heirloom/ => :heirloom,
/The local furrier .+ has an order to fill and wants our help/ => :skins,
/The local gem dealer, [^,]+, has an order to fill and wants our help/ => :gem,
# /to provide a protective escort/ => :escort,
require 'ostruct'
def variable
["running_in_spec"]
end
def echo(*args)
puts *args if debug
end
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@webcss
webcss / eventsmixin.js
Last active August 9, 2016 12:44
PubSub mixin using CustomEvents
// utilizes the browser eventsystem
// usefull in cases where you need communication between independent components
// registered events are automatically removed onunload with preserving any other onunload handler
var eventsMixin = function(target) {
var _subscriptions = [];
target.broadcast = function(type, payload) {
var ev = new CustomEvent(type, {
detail: payload,
@mprymek
mprymek / gist:8379066
Last active July 22, 2022 09:18
Elixir metaprogramming example
# This is an example of metaprogramming in the Elixir language.
#
# We will define a domain specific language (DSL) for the definition
# of a service which is watched by several sensors.
# Each sensor watches some property/functionality of the service and
# returns the result of the check.
#
# To determine if the service is functioning properly, we need functions
# to run all the sensors' code and gather the returned data.
#
@isstaif
isstaif / client.js
Last active June 9, 2016 21:09
TCP public chat, Node.js
var net = require('net')
, encryption = require('./../encryption')
, ursa = require('ursa')
, exec = require('child_process').exec
, fs = require('fs')
, sh = require('execSync')
var stdin = process.openStdin()
var username, password, connection, privateKey, publicKey, otherPublicKey = false, userNames = [], certificate = false, myId, isNew = true
@TeWu
TeWu / gist:1234573
Last active February 2, 2022 20:23
TCP client and multithreaded server in 14 lines of Ruby code

TCP client and multithreaded server in 14 lines of Ruby code

Server:

require "socket"
server = TCPServer.open(2626)
loop do
	Thread.fork(server.accept) do |client| 
 client.puts("Hello, I'm Ruby TCP server", "I'm disconnecting, bye :*")
@aaronshaf
aaronshaf / es.sh
Created September 3, 2011 03:53
Install ElasticSearch on Ubuntu 11.04
cd ~
sudo apt-get update
sudo apt-get install unzip curl python-software-properties -y
#sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.18.7.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz