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
let hillChart = document.querySelector(".hill-chart__svg"); | |
hillChart.setAttribute("viewBox", "150 -50 300 300"); |
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
Superhero = Struct.new(:name, :real_name, :keyword_init => true) do | |
def introduce_self | |
"Hi, I'm #{name}, but my friends call me #{real_name}." | |
end | |
end | |
batman = Superhero.new(real_name: "Bruce", name: "Batman") | |
puts batman.introduce_self | |
#=> Hi, I'm Batman, but my friends call me Bruce. |
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 'httparty' | |
def notify(title: "Buildkite", message:, icon:, web_url:) | |
command = "terminal-notifier -title '#{title}' -message '#{message}' -appIcon ~/.buildkite/#{icon}.png" | |
command += " -open '#{web_url}'" if web_url | |
`#{command}` | |
end |
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
INITIALIZATION ========== | |
Warming up -------------------------------------- | |
PointStruct 224.769k i/100ms | |
PointClass 168.605k i/100ms | |
Hash 63.197k i/100ms | |
OpenStruct 81.934k i/100ms | |
Calculating ------------------------------------- | |
PointStruct 4.279M (±12.8%) i/s - 20.679M in 5.016227s | |
PointClass 3.143M (± 5.0%) i/s - 15.680M in 5.003189s | |
Hash 840.233k (± 5.6%) i/s - 4.234M in 5.055979s |
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
#!/bin/bash | |
set -euo pipefail | |
date=2016-07-27 | |
while [ "$date" != 2016-08-20 ]; do | |
image=$(curl http://www.imagebrief.com/api/v1.5/daily_image?date=$date | jq .imagePath) | |
wget http:$(echo $image | tr -d '"') | |
date=$(date -I -d "$date + 1 day") |
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 | |
# pingpongninja_expected_results -- simulate a series of games on pingpongninja | |
# | |
# algorithm extracted from | |
# https://github.com/jdennes/pingpongapp/blob/master/pingpong/rankings.py | |
def new_ranks(rank1, rank2, points1, points2) | |
decay_factor = 10 | |
game_ranking_points = (rank1 + rank2) / 2 | |
ranking_change1 = game_ranking_points + (points1 - points2) * 100 / [points1, points2].max | |
ranking_change2 = game_ranking_points + (points2 - points1) * 100 / [points1, points2].max |
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 Foo | |
end | |
Foo.class_eval do | |
def bar | |
"Bar from class eval" | |
end | |
end | |
Foo.instance_eval do |
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
click_on "Add new person" | |
last_nested_fields = all('.fields').last | |
within(last_nested_fields) do | |
fill_in "Name", with: "Ricardo" | |
fill_in "Age", with: 27 | |
end |
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
RSpec.configure do |config| | |
config.before(:suite) do | |
ActiveRecord::Base.observers.disable :all | |
end | |
end |
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
sed -i.bkp s/Factory\(\:/FactoryGirl.create\(\:/g spec/**/*.rb | |
sed -i.bkp s/Factory\ \:/FactoryGirl.create\ \:/g spec/**/*.rb | |
sed -i.bkp s/Factory\.build\ \:/FactoryGirl.build\ \:/g spec/**/*.rb | |
sed -i.bkp s/Factory\.build\(\:/FactoryGirl.build\(\:/g spec/**/*.rb | |
sed -i.bkp s/Factory\.next/FactoryGirl\.generate/g spec/**/*.rb | |
rm -rf spec/**/*.bkp |
NewerOlder