Skip to content

Instantly share code, notes, and snippets.

View fujimura's full-sized avatar

Daisuke Fujimura fujimura

View GitHub Profile
import matplotlib.pyplot as plt
import subprocess
import datetime
raw = (
subprocess.Popen(
'git log --pretty=" %at, %h" --reverse --after "2020/01/01" .rubocop_todo.yml',
shell=True,
stdout=subprocess.PIPE,
)
@fujimura
fujimura / nippou_matome.rb
Created December 27, 2018 06:23
一年分の日報から「本日の作業内容」を抜き出してまとめて出力
i = 1
entries = []
name = 'fujimura'
until entries.length > 0 && entries.last['full_name'] =~ %r{2017/12}
r = HTTPClient.get(
'https://api.esa.io/v1/teams/proper-inc/posts',
access_token: ENV['ESA_TOKEN'],
q: "in:日報 user:#{name}",
page: i
@fujimura
fujimura / debt.md
Last active December 18, 2019 07:39
技術的負債とは何だったのか、技術的負債はなくならないのか
require 'cli/ui'
unless ActiveRecord::SchemaMigration.table_exists?
abort "Schema migrations table does not exist yet."
end
def migrations
ActiveRecord::Base.connection.migration_context.migrations_status.map do |status, version, name|
"#{status.ljust(8)} #{version.ljust(14)} #{name}"
end
@fujimura
fujimura / markdown_to_html_slide_to_pdf.js
Created March 12, 2018 13:40
markdown_to_html_slide_to_pdf.js
const fs = require("fs");
const { execSync } = require("child_process");
const path = require("path");
const puppeteer = require("puppeteer");
const htmlToPdf = async src => {
const browser = await puppeteer.launch();
try {
const dest = `${path.basename(src)}.pdf`;
require 'json'
def get_lonlat_in_spiral(i)
v = Complex.polar i, i/4.9 * Math::PI/2
angle = v.angle
magnitude = v.magnitude
[magnitude * Math.cos(angle), magnitude * Math.sin(angle)]
end
r = 10.upto(30).map { |i| get_lonlat_in_spiral(i) }
SELECT
ST_ASText(
ST_GeometryN(
ST_GeneratePoints(
ST_GeomFromText('MULTIPOLYGON (((102.7687 35.07, 104.4969 35.07, 104.4969 35.06, 102.7687 35.06, 102.7687 35.07)))', 4326),
1
),
1
)
)
@fujimura
fujimura / pre-commit
Created December 6, 2017 10:39
pre-commit hook to run prettier
#!/bin/sh
# Taken from https://prettier.io/docs/en/precommit.html#option-3-bash-script and added (s)css as target
jsfiles=$(git diff --cached --name-only --diff-filter=ACM "*.js" "*.jsx" "*.css" "*.scss" | tr '\n' ' ')
[ -z "$jsfiles" ] && exit 0
# Prettify all staged .js files
echo "$jsfiles" | xargs yarn run prettier --write
# Add back the modified/prettified files to staging
echo "$jsfiles" | xargs git add
// @flow
type A = {
x: number,
y: number,
type: "A"
};
type B = {
x: number,
module Match
def self.define_matchers!(m)
m.constants.each {|c|
eval "class #{c} < StandardError; end"
}
end
def self.match! obj
raise self.const_get(obj.class.to_s).new(obj)
end