Substack https://aljamal.substack.com/p/homoiconic-python
atom=lambda x:not isinstance(x,list)
eq=lambda x,y:x == y
car=lambda x:x[0]
cdr=lambda x:x[1:]
Substack https://aljamal.substack.com/p/homoiconic-python
atom=lambda x:not isinstance(x,list)
eq=lambda x,y:x == y
car=lambda x:x[0]
cdr=lambda x:x[1:]
<!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/[email protected]/min/vs/editor/editor.main.css"> |
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) |
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: |
JSON.parse({a: { b: { c: 1 }}}.to_json, object_class: OpenStruct) | |
https://stackoverflow.com/questions/26809848/convert-hash-to-object |
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) |
#!/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) |
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 |
https://app.joincoup.com/api/v1/scooters.json | |
https://app.joincoup.com/api/v1/business_areas.json |
AllCops: | |
RunRailsCops: true | |
TargetRubyVersion: 2.4 | |
Style/Encoding: | |
Enabled: false | |
Metrics/LineLength: | |
Max: 120 |