Skip to content

Instantly share code, notes, and snippets.

View mumoshu's full-sized avatar
🏠
Working from home

Yusuke Kuoka mumoshu

🏠
Working from home
View GitHub Profile
@rhenning
rhenning / opsworks_blue_green_deploy_test_long_version
Created February 13, 2014 01:11
AWS OpsWorks full-stack blue/green deploy test
$ aws opsworks describe-stacks
{
"Stacks": [
{
"ServiceRoleArn": "arn:aws:iam::047170177871:role/aws-opsworks-service-role",
"StackId": "575e1389-1df3-427d-99d3-d60f89a41442",
"DefaultRootDeviceType": "ebs",
"Name": "rhenning_test",
"ConfigurationManager": {
"Version": "11.4",
@vvakame
vvakame / idobata-api.js
Last active May 16, 2019 14:57
idobataはAPIのドキュメントがないので頑張って調べた https://idobata.io/
var http = require("https");
var qs = require('querystring');
var Pusher = require('pusher-client');
var urlBase = "https://idobata.io";
var token = "xxxxx"; // ここにBOTのtokenいれる
var pusherKey = "44ffe67af1c7035be764";
function request(method, path, params) {
@dergachev
dergachev / squid-deb-proxy_on_docker.md
Last active May 25, 2023 03:55
Caching debian package installation with docker

TLDR: I now add the following snippet to all my Dockerfiles:

# If host is running squid-deb-proxy on port 8000, populate /etc/apt/apt.conf.d/30proxy
# By default, squid-deb-proxy 403s unknown sources, so apt shouldn't proxy ppa.launchpad.net
RUN route -n | awk '/^0.0.0.0/ {print $2}' > /tmp/host_ip.txt
RUN echo "HEAD /" | nc `cat /tmp/host_ip.txt` 8000 | grep squid-deb-proxy \
  && (echo "Acquire::http::Proxy \"http://$(cat /tmp/host_ip.txt):8000\";" > /etc/apt/apt.conf.d/30proxy) \
  && (echo "Acquire::http::Proxy::ppa.launchpad.net DIRECT;" >> /etc/apt/apt.conf.d/30proxy) \
  || echo "No squid-deb-proxy detected on docker host"
@wlmcewen
wlmcewen / gist:8106602
Created December 23, 2013 23:28
Override the default environment settings in Capistrano 3.0.1
# Using set here doesn't work, as the git tasks are loaded later.
# set :git_environmental_variables, ->() {
# ...
task :override_defaults
set :git_environmental_variables, ->() {
{
git_askpass: "/bin/echo",
git_ssh: "/home/deploy/util/gitkey/wrapper"

二分木データ構造をScalaで実装する

以下の前提のもと、下記機能を実現する実装を記述せよ。

diagram

  • 木にはブランチ(枝)とリーフ(葉)があるものとする。ブランチとリーフをノードとし、以下の型階層を前提とする。
trait Node {
@comilab
comilab / CanvasFont.html
Last active January 7, 2017 13:53
canvas要素を使って文字を綺麗に描画してみる
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<style type="text/css">
body {
font-size: 22px;
}
@comilab
comilab / TwitterModoki.html
Last active December 21, 2015 15:29
AngularJSでTwitterもどきを作る
<!DOCTYPE html>
<html lang="ja">
<head>
<title>Twitterもどき</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
</head>
<body ng-app ng-init="tweets = []; t='';">
<form name="tweetForm">
<textarea required="required" name="t" ng-model="t" ng-maxlength="140"></textarea>
<span>{{t.length}} / 140</span>
@bakins
bakins / gist:6280468
Created August 20, 2013 11:55
horrible docker wrapper for runit/chef
#!/opt/chef/embedded/bin/ruby
require 'net/http'
require 'json'
require 'yaml'
STDOUT.sync = true
config = YAML.load_file(ARGV[0])
http = Net::HTTP.new("127.0.0.1", 4243)
@jroper
jroper / Global.scala
Last active December 20, 2015 19:38
Transparent HEAD request handling in Play 2.1. Note that it may be more efficient to implement HEAD support in an action directly, as this may avoid unnecessary opening of resources or rendering things.
import play.api.libs.iteratee.{Done, Iteratee, Enumerator}
import play.api.mvc._
import play.api._
import play.api.libs.concurrent.Execution.Implicits._
object Global extends GlobalSettings {
override def onRouteRequest(req: RequestHeader) = {
// Lookup handler
super.onRouteRequest(req) match {
@xeno-by
xeno-by / gist:5967900
Created July 10, 2013 16:38
Macro-powered structural types
import scala.annotation.StaticAnnotation
import scala.reflect.macros.Macro
import language.experimental.macros
class body(tree: Any) extends StaticAnnotation
trait Macros extends Macro {
import c.universe._
def selFieldImpl = {