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> | |
<head> | |
<title>Frontend Playground</title> | |
<meta charset=utf8> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<meta name="robots" content="noindex, nofollow"> | |
<meta name="googlebot" content="noindex, nofollow"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" type="text/css" data-name="vs/editor/editor.main" href="https://unpkg.com/monaco-editor@0.8.3/min/vs/editor/editor.main.css"> |
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 'gitlab' | |
require 'json' | |
require 'time' | |
require 'csv' | |
Gitlab.endpoint = 'https://gitlab.com/api/v4' | |
Gitlab.private_token = '<ENTER YOUR PRIVATE TOKEN>' | |
PROJECT_ID = 123 # ENTER YOUR PROJECT_ID | |
def parse_times(items) |
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 td_in_words(s, skip: 1) | |
words = [['years',0], ['months',1], ['days',1], ['hours',0], ['minutes',0], ['seconds',0]] | |
vals = (Time.mktime(0)+s).strftime("%Y %m %d %H %M %S").split(' ').map(&:to_i) | |
skip.times{ words.pop && vals.pop } | |
str = vals.zip(words).select{|v,(w,n)| v!=n}.map{|v,(w,n)| [v-n, (v-n)==1 ? w[0..-2] : w]}.map{|v,w| "#{v} #{w}"}.join(' ') | |
str = "0 #{words.last[0]}" if str.empty? | |
str | |
end | |
#usage: |
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
JSON.parse({a: { b: { c: 1 }}}.to_json, object_class: OpenStruct) | |
https://stackoverflow.com/questions/26809848/convert-hash-to-object |
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 'mechanize' | |
require 'open-uri' | |
require 'json' | |
require 'time' | |
def mechanize_session | |
browser = Mechanize.new | |
#browser.history_added = Proc.new { sleep 0.5 } | |
browser.user_agent = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36' | |
yield(browser) |
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 'chronic' | |
require 'time' | |
require 'securerandom' | |
abort('notify-send not installed') if `which notify-send`.empty? | |
ts = ARGV.join(' ') | |
t = Chronic.parse(ts) |
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
VALID_CHOICES = { | |
'rock' => %w(scissors lizard), | |
'paper' => %w(rock spock), | |
'scissors' => %w(paper lizard), | |
'lizard' => %w(paper spock), | |
'spock' => %w(rock scissors) | |
} | |
last_player_choice = nil | |
strategy_modifier = rand(0.2..0.8) | |
player_score = 0 |
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
https://app.joincoup.com/api/v1/scooters.json | |
https://app.joincoup.com/api/v1/business_areas.json |
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
AllCops: | |
RunRailsCops: true | |
TargetRubyVersion: 2.4 | |
Style/Encoding: | |
Enabled: false | |
Metrics/LineLength: | |
Max: 120 |
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
module Hooks | |
def before(*method_names, &block) | |
to_prepend = Module.new do | |
method_names.each do |name| | |
define_method(name) do |*args, &blk| | |
yield(name, *args) | |
super(*args, &blk) | |
end | |
end | |
end |
NewerOlder