Skip to content

Instantly share code, notes, and snippets.

View mmizutani's full-sized avatar

Minoru Mizutani mmizutani

  • Tokyo
  • 01:09 (UTC +09:00)
View GitHub Profile
@cpylua
cpylua / datediff.c
Created April 22, 2012 14:19
computing the day difference between two dates
/* this code is from http://c-faq.com/lib/calendar.br.html */
#define DayOfWeek(d,m,y) (int)(DaysElapsed(d,m,y) % 7)
long DaysElapsed(int d,int m,int y) {
static int cd[]={0,31,59,90,120,151,181,212,243,273,304,334};
long n=365L*(y-1);
if (m<3) y--;
return n+y/4-y/100+y/400+cd[m-1]+d;
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 7, 2024 06:03
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@earthgecko
earthgecko / bash.generate.random.alphanumeric.string.sh
Last active April 2, 2024 15:59
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1
@stevenworthington
stevenworthington / ipak.R
Created July 25, 2012 19:44
Install and load multiple R packages at once
# ipak function: install and load multiple R packages.
# check to see if packages are installed. Install them if they are not, then load them into the R session.
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
@rosylilly
rosylilly / gist:3401612
Created August 20, 2012 06:40
先輩と覚える HTTP ステータスコード

先輩に学ぶ HTTP Status Code

超雑にまとめました。修正してください。

登場人物

  • アプリケーション先輩: いつも忙しい。横に広がるのが得意(デブじゃない)。
  • 後輩: 頼んでばっかしで役に立たない。
  • サーバー先輩: アプリケーション先輩と仲がいい。Unix Socket でつながるくらい仲良し。
  • プロクシ先輩: アプリケーション先輩とかサーバー先輩と後輩の間を取り持って代わりに伝えたりしてくれる。たまに勝手にレスポンスを書き換える。
@Gab-km
Gab-km / github-flow.ja.md
Last active April 25, 2024 04:01 — forked from juno/github-flow.ja.md
GitHub Flow (Japanese translation)
@sasaki-shigeo
sasaki-shigeo / gist:3727810
Created September 15, 2012 13:18
Conversion from/to Numeric Type in Scala (Scala における数値型の変換)
import math._
1L // Long型の 1
1:Long // Long型の 1
127:Byte // Byte型の 127
32767:Short // Short型の 32767
(1+2).toLong // Long型への変換
(2+3) toLong // Long型への変換
@nateware
nateware / nginx.conf
Last active November 23, 2021 10:54
Nginx sample config for EC2
#
# Sample nginx.conf optimized for EC2 c1.medium to xlarge instances.
# Also look at the haproxy.conf file for how the backend is balanced.
#
user "nginx" "nginx";
worker_processes 10;
error_log /var/log/nginx_error.log info;
@digitaljhelms
digitaljhelms / gist:5247192
Last active September 17, 2020 11:01
A faster, less buggy alternative to "python -m SimpleHTTPServer"
$ npm install -g http-server
$ http-server -p 8000 -a foo.bar.com

Would serve PWD at http://foo.bar.com/

@visenger
visenger / install_scala_sbt.sh
Last active January 31, 2023 19:10
Scala and sbt installation on ubuntu 12.04
#!/bin/sh
# one way (older scala version will be installed)
# sudo apt-get install scala
#2nd way
sudo apt-get remove scala-library scala
wget http://www.scala-lang.org/files/archive/scala-2.11.4.deb
sudo dpkg -i scala-2.11.4.deb
sudo apt-get update