Skip to content

Instantly share code, notes, and snippets.

Avatar

kyontan kyontan

View GitHub Profile
@kyontan
kyontan / pamove
Created Jun 2, 2020
PulseAudio sink-output changer
View pamove
#!/usr/bin/env ruby
class String
def to_i_first
self.match(/\d+/)[0].to_i
end
def unquote_str
self.match(/"(.*)"/)[1]
end
@kyontan
kyontan / lazy_product.rb
Created Jun 7, 2019
lazy edition of Enumerable.product
View lazy_product.rb
class LazyProduct
include Enumerable
def initialize(array)
@array = array
end
def self.from(array)
new(array)
end
@kyontan
kyontan / keynote.scpt
Last active Nov 20, 2019 — forked from lambdamusic/keynote.scpt
Apple Keynote: export presenter notes
View keynote.scpt
-- HOWTO:
-- after saving it, open with Script Editor (default) and run it
-- PREREQUISITES:
-- make sure your Keynote presentation is open in the background
set presenterNotes to ""
set slideNumber to 1
tell application "Keynote"
@kyontan
kyontan / merge.sql
Last active Jul 26, 2020
BigQuery MERGE DML to merge {source} into {destination} with having same primary keys also having newer updated_at
View merge.sql
MERGE {destination} T
USING (
SELECT * EXCEPT(rn)
FROM (
SELECT
*,
row_number() over (PARTITION BY {primary_keys} ORDER BY updated_at DESC) AS rn
FROM {source})
WHERE rn = 1
) S
@kyontan
kyontan / README.md
Last active Apr 14, 2019
Enabling ECDSA in PKCS#11 support for ssh-agent for OpenSSH 7.9p1 (ref: https://bugzilla.mindrot.org/show_bug.cgi?id=2474)
View README.md
@kyontan
kyontan / docker-compose.yml
Created Mar 8, 2019
ICTSC2018 それはアクセスできないようにしたはずなのに…… 問題環境
View docker-compose.yml
version: '2'
services:
db:
container_name: database
image: mariadb:10.2.22
ports:
- "3306:3306"
volumes:
- ./db:/var/lib/mysql
View error
$ embulk run -b ./ -l debug test.yaml.liquid -c test_diff.yaml
2019-02-27 15:22:24.626 +0000: Embulk v0.8.18
2019-02-27 15:22:26.115 +0000 [INFO] (0001:transaction): Loaded plugin embulk-input-mysql (0.9.3)
2019-02-27 15:22:26.144 +0000 [INFO] (0001:transaction): Loaded plugin embulk-output-gcs (0.4.3)
2019-02-27 15:22:26.175 +0000 [INFO] (0001:transaction): JDBC Driver = /some_path/vendor/bundle/jruby/2.3.0/gems/embulk-input-mysql-0.9.3/default_jdbc_driver/mysql-connector-java-5.1.44.jar
2019-02-27 15:22:26.183 +0000 [INFO] (0001:transaction): Fetch size is 10000. Using server-side prepared statement.
2019-02-27 15:22:26.184 +0000 [INFO] (0001:transaction): Connecting to jdbc:mysql://xxx options {useCompression=true, socketTimeout=3600000, useSSL=..., user=..., useLegacyDatetimeCode=..., tcpKeepAlive=..., useCursorFetch=..., connectTimeout=..., password=***, zeroDateTimeBehavior=convertToNull}
2019-02-27 15:22:26.436 +0000 [INFO] (0001:transaction): Using JDBC Driver mysql-co
View ip_addr_regexp_to_subnet.rb
#!/usr/bin/env ruby
require "json"
require "ipaddress"
patterns = [
"10\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))",
"172\\.(1[6-9]|2[0-9]|3[0-1])\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))",
"192\\.168\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))",
]
View atom_map.rb
# [1, 2].atom_map{|x| Integer === x ? x * 2 : x }
# => [2, 4]
#
# [1, 2, [3, 4]].atom_map{|x| Integer === x ? x * 2 : x }
# => [2, 4, [6, 8]]
#
# [1, 2, [3, {k: 4, v: 3}]].atom_map{|x| Integer === x ? x * 2 : x }
# => [2, 4, [6, {:k=>8, :v=>6}]]
#
@kyontan
kyontan / test.sql
Last active Apr 22, 2018
keep BigQuery running
View test.sql
#standardSQL
-- ref: https://gist.github.com/campoy/122f5e24740488e6ea3c973ab195e158
CREATE TEMPORARY FUNCTION twice(x INT64)
RETURNS INT64
LANGUAGE js AS """
const memory = new WebAssembly.Memory({ initial: 256, maximum: 256 });
const env = {
'abortStackOverflow': _ => { throw new Error('overflow'); },
You can’t perform that action at this time.