Operator | Stack effect | notes |
---|---|---|
+ |
a b -- |
|
- |
a b -- |
|
* |
a b -- |
|
/ |
a b -- |
|
% |
a b -- |
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 'date' | |
require 'securerandom' | |
require 'optparse' | |
def header() | |
<<~EOS | |
BEGIN:VCALENDAR | |
CALSCALE:GREGORIAN | |
PRODID:-//SENCJW Heavy Industries, Ltd.//CalBot//EN |
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 lang="en-US"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>OpenStreetMap with Leaflet.js</title> | |
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" | |
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" | |
crossorigin=""/> | |
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" | |
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" |
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
-- list types and their enum values | |
SELECT | |
pg_type.typname AS enumtype, | |
array_agg(pg_enum.enumlabel) AS enumlabels | |
FROM | |
pg_type | |
JOIN pg_enum ON pg_enum.enumtypid = pg_type.oid | |
GROUP BY pg_type.typname; |
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
# Run with: | |
# $ rackup app.ru | |
require 'bundler/inline' | |
gemfile(true) do | |
source 'https://rubygems.org' | |
gem 'rails', '~> 7.0.5' | |
gem 'puma' | |
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
(defun cjw-git-grep (my-word) | |
"Use git-grep for search in current project (vc-root-dir). Default | |
search term uses symbol under cursor" | |
(interactive | |
(list | |
(read-string | |
(format "Search (%s): " (thing-at-point 'symbol)) ; prompt | |
nil ; initial input | |
nil ; history list | |
(thing-at-point 'symbol) ; evaluated. will be default |
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 computus(year) | |
a = year % 19 # year in the 19-year metonic cycle | |
k = year / 100 # century index | |
p = (13 + 8*k) / 25 # shift of metonic cycle, add a day offset every 300 years | |
q = k / 4 # correction for non-observed leap days | |
m = (15 - p + k - q) % 30 # correction to starting point each century | |
d = (19*a + m) % 30 # num of days from 3/21 until full moon | |
n = (4 + k - q) % 7 # find next sunday; century-based offset in weekly calc. | |
b = year % 4 # correct for leap days | |
c = year % 7 # correct for leap days |
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 'optparse' | |
require 'base64' | |
require 'json' | |
require 'openssl' | |
require 'set' | |
options = {} | |
OptionParser.new do |parser| |
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 | |
# Just reformats the input into Postgres inclusive range syntax in CSV: | |
# 2-4,6-8 => "[2,4]","[6,8]" | |
File.readlines('input_04.txt').each do |line| | |
r1, r2 = line.split(',') | |
a, b = r1.split('-') | |
x, y = r2.chomp.split('-') | |
puts "\"[#{a},#{b}]\",\"[#{x},#{y}]\"" | |
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
drop table if exists rucksacks; | |
create table rucksacks ( | |
id serial primary key, | |
content text | |
); | |
copy rucksacks (content) from '/Users/cjw/Documents/aoc22/input_03.txt' | |
with csv; | |
create or replace function letter_value(letter char) returns integer as $$ |
NewerOlder