Skip to content

Instantly share code, notes, and snippets.

@maripiyoko
maripiyoko / app.yaml
Last active December 9, 2017 05:48
gcp instance up, down, check status by GAE
runtime: go
api_version: go1
handlers:
- url: /.*
script: _go_app
@maripiyoko
maripiyoko / gitcheats.txt
Created April 7, 2016 06:03 — forked from chrismccoy/gitcheats.txt
git cheats
# shortform git commands
alias g='git'
# count relevant lines of shell code in a git repo
egrep -v '^\s*($|#)' $(git grep -l '#!/bin/.*sh' *) | wc -l
# push all remotes
for i in `git remote`; do git push $i; done;
# cherry pick range of commits, starting from the tip of 'master', into 'preview' branch
@maripiyoko
maripiyoko / gist:c8f66633e9cf1f2138d6
Created January 21, 2016 13:14 — forked from afeld/gist:5704079
Using Rails+Bower on Heroku
@maripiyoko
maripiyoko / better_errors.rb
Last active September 1, 2015 01:51
Railsのデバッグを助けるgems ref: http://qiita.com/mm36/items/b88c165a8be9b70c998f
BetterErrors.editor = :macvim if defined? BetterErrors
@maripiyoko
maripiyoko / file0.txt
Created August 27, 2015 11:18
AngularJS で Promise (defer)を使ってファイルシステムからファイルを読み込む (cordova filesystem) ref: http://qiita.com/mm36/items/a9869a2066ace1aed0a8
function slowCall() {
var df = $q.defer();
// 非同期処理を担当する関数を定義
function fn() {
var msg = 'now : ' + new Date().getTime();
alert('inside async function.');
df.resolve(msg);
};
$timeout(fn, 1000);
return df.promise;
@maripiyoko
maripiyoko / matrix.rb
Created May 25, 2015 23:15
Matrix-like Computation in Ruby
# coding: utf-8
class MatrixSum
def self.sumup_numbers(input)
# 行の合計を計算
input_with_row_sum = input.map do |list|
append_sum_to_last(list)
end
@maripiyoko
maripiyoko / patatokukashi.rb
Created February 12, 2015 00:57
パタトクカシー問題
def patatokukashi(words)
line1 = []
line2 = []
words.chars.each_slice(2) do |a,b|
line1.push(a)
line2.push(b)
end
line1.join("") + line2.join("")
end
@maripiyoko
maripiyoko / tcp-socketio-sample.js
Last active June 7, 2021 11:48
Node.js Tcp server & Socket.io
// socket io
var app = require('http').createServer(handler),
io = require('socket.io').listen(app),
fs = require('fs');
app.listen(3000, function() {
console.log('Socket IO Server is listening on port 3000');
});
function handler(req, res) {
@maripiyoko
maripiyoko / serial_read.c
Created November 11, 2014 04:09
serial port read by c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <termios.h>
#include <time.h>
#define DEV_NAME "/dev/tty.usbmodem621"
#define BAUD_RATE B9600
@maripiyoko
maripiyoko / SushiParty.java
Last active August 29, 2015 14:07
Blog post Java reference about null
for(int i=0; i < numMember; i++) {
Sushi sushi = new Sushi(); // 勝手にランダムな寿司が出来上がるものとする
dishes.add(sushi);
sushi = null; // ここでどうなる?
}