Skip to content

Instantly share code, notes, and snippets.

View shoken0x's full-sized avatar
🔶

Shoken shoken0x

🔶
View GitHub Profile
@shoken0x
shoken0x / app_icon_set_sips.sh
Last active August 28, 2018 13:24
Create appiconset for iOS App for Mac
#!/bin/bash
## Usage
## app_icon_set_sips.sh Icon.png
mkdir -p icons 2>/dev/null
sips -z 20 20 --out icons/[email protected] $1
sips -z 40 40 --out icons/[email protected] $1
sips -z 60 60 --out icons/[email protected] $1
sips -z 29 29 --out icons/[email protected] $1
sips -z 58 58 --out icons/[email protected] $1
@shoken0x
shoken0x / puppeteer_sample.js
Last active December 15, 2017 01:10
puppeteer sample
// Usage
// yarn add puppeteer
// node puppeteer_sample.js
const puppeteer = require('puppeteer');
puppeteer.launch({
headless: false, // フルバージョンのChromeを使用
slowMo: 300 // 何が起こっているかを分かりやすくするため遅延
}).then(async browser => {
@shoken0x
shoken0x / gh-header-meta.css
Last active November 19, 2017 01:48
highlight branch name without master in GitHub Pull Request
.gh-header-meta .commit-ref:first-of-type:not([title*='master']) {
background: #dbab09;
}
@shoken0x
shoken0x / github_webhook_server.rb
Last active June 9, 2016 06:55
Github Webhook Server for deploy
# rails_restart.sh is simple shell program. you can get somewhere.
require 'webrick'
require 'json'
server = WEBrick::HTTPServer.new(Port: 8000, ServerType: WEBrick::Daemon)
server.mount_proc '/' do |req, res|
req_json = JSON.parse(req.body)
if req_json["ref"] == "refs/heads/master"
@shoken0x
shoken0x / increment_offset.html
Last active May 6, 2016 16:20
invrement data-offset by click button
<html>
<head>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('#more_load').bind('click', function() {
var offset = $(this).data('offset');
var limit = $(this).data('limit');
@shoken0x
shoken0x / ext_euclidean.rb
Created November 25, 2015 09:09
PCC Book: Extended Euclidean algorithm
def extgcd(a, b)
if b.zero?
{x: 1, y: 0, gcd: a}
else
prev = extgcd(b, a % b)
{ x: prev[:y],
y: prev[:x] - (a / b) * prev[:y],
gcd: prev[:gcd] }
end
end
@shoken0x
shoken0x / euclidean.rb
Last active November 25, 2015 09:08
PCC Book: Euclidean algorithm
def gcd(a, b)
return a if b.zero?
gcd(b, a % b)
end
puts gcd(1071, 1029) # => 21
@shoken0x
shoken0x / dijkstra.rb
Created November 23, 2015 12:23
PCC Book: Dijkstra's algorithm
MAX_V = 10
INF = 100_000_000
$d = Array.new(MAX_V, INF) # 頂点sからの最短距離
$used = Array.new(MAX_V, false) # すでに使われたかのフラグ
$V = 7
# | i\j | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
# |-----|---|---|---|---|---|---|---|
# | 0 | 0 | 2 | 5 |INF|INF|INF|INF|
# | 1 | 2 | 0 | 4 | 6 |10 |INF|INF|
@shoken0x
shoken0x / bellman_ford.rb
Last active November 23, 2015 09:40
PCC Book: Shortest Path Problem, Bellman-Ford algorithm
class Edge
# 頂点fromから頂点toへのコストcostの辺
attr_accessor :from, :to, :cost
def initialize(from, to, cost)
@from, @to, @cost = from, to, cost
end
end
MAX_V = 10
$INF = 100_000_000
@shoken0x
shoken0x / union_find.rb
Created November 22, 2015 09:11
PCC Book: Union-Find
# Union-Find木
MAX_N = 100
$parent = Array.new(MAX_N)
$rank = Array.new(MAX_N, 0)
def init(n)
n.times do |i|
$parent[i] = i
end
end