Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# ----------------------
# KUDU Deployment Script
# Version: 1.0.6
# ----------------------
# Helpers
# -------
DEVICE_NAME = ENV["DEVICE_NAME"]
SHARED_ACCESS_KEY = ENV["SHARED_ACCESS_KEY"]
HOST_NAME = ENV["HOST_NAME"]
REQUEST_PATH = "devices/#{DEVICE_NAME}/messages/events?api-version=2015-08-15-preview"
uri_with_port = "https://#{HOST_NAME}:443/#{REQUEST_PATH}"
expiry = Time.now.to_i + 60 * 60
s = "#{HOST_NAME}/devices/#{DEVICE_NAME}"
raw = Digest::HMAC.digest("#{s}\n#{expiry}",
require 'openssl'
require 'cgi'
require 'base64'
require 'time'
# CONNECTION_STRINGはiothub-explorerで生成した値
CONNECTION_STRING = ENV['CONNECTION_STRING']
CONNECTION_STRING.split(";").each do |elm|
key = elm[0, elm.index("=")].gsub(/([A-Z])/, "_\\1").gsub(/^_/, '').downcase
self.instance_variable_set("@#{key}".to_sym, elm[(elm.index('=') + 1), elm.length])
filename = ARGV[0]
lines = File.readlines(filename)
fix_footnote = lines.map { |line|
line.sub(/<div =class'footnotes'><ol>/, '').
gsub(/<a href=.+?>←<\/a><\/p><\/li>/, "\n").
sub(/<\/ol><\/div>/, '').
gsub(/<li id='fn(.+?)'><p>/) { '[^' + $1 + ']: '}.
gsub(/<sup id='fnref(.+?)'>.+<\/sup>/) { '[^' + $1 + ']' }
}
'/Applications/Postgres.app/Contents/Versions/9.3/bin'/psql -p5432
Last login: Thu Nov 3 02:00:37 on ttys000
[~]$ '/Applications/Postgres.app/Contents/Versions/9.3/bin'/psql -p5432
psql (9.3.5)
Type "help" for help.
miyohide=# create role hoge with createdb login password 'password';
CREATE ROLE
miyohide=#
@miyohide
miyohide / yokohamarb_70.rb
Created July 9, 2016 15:50
Yokohama.rb 70回で出題された問題の回答です。
// coding: utf-8
// http://nabetani.sakura.ne.jp/yokohamarb/2016.07.ront/
Tiles = [
{top: :left, left: :top, right: :down, down: :right},
{top: :right, left: :down, right: :top, down: :left},
{top: :down, left: :right, right: :left, down: :top},
{top: :death, left: :death, right: :death, down: :death}
]
def input2tiles(input)
require 'openssl'
require 'cgi'
require 'base64'
require 'time'
require 'net/https'
require 'json'
CONNECTION_STRING = ENV['CONNECTION_STRING']
CONNECTION_STRING.split(";").each do |elm|
@miyohide
miyohide / file_move.rb
Created April 23, 2016 09:04
Markdownファイルをディレクトリごとに移動する
(1..53).each do |i|
issue = "%04d" % i
Dir.glob("#{issue}*.md").each { |filename|
File.rename(filename.to_s, "markdowns/#{issue}/#{filename.to_s}")
}
end
@miyohide
miyohide / windowlicker_build.txt
Created March 23, 2013 05:04
windowlickerビルド
[~/work/windowlicker]$ svn export http://windowlicker.googlecode.com/svn/trunk
A trunk
A trunk/LICENSE.txt
A trunk/tools
A trunk/tools/tools.iml
A trunk/tools/apache-ant-1.7.0
A trunk/tools/apache-ant-1.7.0/WHATSNEW
A trunk/tools/apache-ant-1.7.0/LICENSE.dom
A trunk/tools/apache-ant-1.7.0/NOTICE
A trunk/tools/apache-ant-1.7.0/LICENSE
@miyohide
miyohide / gist:3946532
Created October 24, 2012 14:54
dynatreeサンプル
<!DOCTYPE HTML>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>Dynatree Sample</title>
<link rel="stylesheet" href="./src/skin/ui.dynatree.css" />
<script type="text/javascript" src="./jquery/jquery.js"></script>
<script type="text/javascript" src="./jquery/jquery-ui.custom.js"></script>
<script type="text/javascript" src="./jquery/jquery.cookie.js"></script>
<script type="text/javascript" src="./dist/jquery.dynatree.min.js"></script>