Skip to content

Instantly share code, notes, and snippets.

View nikuuchi's full-sized avatar

uchida nikuuchi

  • Tokyo, Japan
View GitHub Profile
@nikuuchi
nikuuchi / sendPost.php
Created March 28, 2013 07:01
file_get_contentsでPOSTする
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('send_post'))
{
function send_post($data,$url)
{
$header = array(
"Content-Type: application/x-www-form-urlencoded",
"Content-Length: ".strlen($data)
);
@nikuuchi
nikuuchi / demo.coffee
Created February 22, 2013 08:46
Web Audio APIを少し触ってみたコード片
$ () ->
ctx = document.getElementById("demo").getContext("2d")
ctx.strokeStyle = "#000"
ctx.fillStyle = "#000"
for x in [0..8]
ctx.strokeRect x*80,0,80,280
for x in [60,140,300,380,460]
ctx.fillRect x,0,40,170
player = new Simulator()
$("#play").click () ->
@nikuuchi
nikuuchi / ubuntu.sh
Last active December 13, 2015 19:58
Ubuntuで開発環境整える用。 Ubuntu 13.10で確認。
#!/bin/bash
cd $HOME
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install vim tmux zsh build-essential cmake cmake-curses-gui python-setuptools git tig subversion clang llvm emscripten default-jdk -y
# server
#sudo tasksel install lamp-server openssh-server
# Latex(for 12.10 or 13.04)
#sudo apt-get install texlive texlive-lang-cjk auctex xdvik-ja
@nikuuchi
nikuuchi / resolution_1600x900.sh
Created January 6, 2013 03:31
VMwareで1600x900の解像度をなぜか使えなかったから作った。2行目はcvtで生成。
#!/bin/sh
xrandr --newmode "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync
xrandr --addmode Virtual1 1600x900_60.00
xrandr --output Virtual1 --mode 1600x900_60.00
@nikuuchi
nikuuchi / hosts
Created November 5, 2012 07:37
東海道線
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.59.150 totsuka
192.168.59.151 ofuna
192.168.59.160 fujisawa
@nikuuchi
nikuuchi / dict.rb
Created November 2, 2012 07:48
辞書引くためにブラウザ使うのが面倒だったから。
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
dict = Nokogiri::HTML(open("http://ejje.weblio.jp/content/#{ARGV[0].downcase}")).search("div.Kejje")
dict.search("script").remove
dict.search("div.level0").each{|node| puts node.text.delete("\r")}
@nikuuchi
nikuuchi / fibo.ml
Created March 7, 2012 05:52
ocamloptとocamlcの速度の違いを見たかったのでフィボナッチ書いてみた。
let rec fibo n = if n < 2
then 1
else fibo(n-1)+fibo(n-2);;
print_int(fibo(36));;
print_string("\n");;
@nikuuchi
nikuuchi / closure.php
Created January 29, 2012 10:49
PHP5.3以降ならクロージャが使えると聞いて。
<?php
function f(){
$i=0;
return function() use(&$i){
return $i++;
};
};
$c = f();
foreach(range(0,10) as $a){
echo $c(),"\n";
@nikuuchi
nikuuchi / xss_helper.php
Created January 24, 2012 12:20
CodeIgniterでXSS対策のhtmlspecialcharsを使いやすくするだけのhelper
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('h'))
{
function h($str)
{
return htmlspecialchars($str,ENT_QUOTES,"UTF-8");
}
}
@nikuuchi
nikuuchi / emacsrun.sh
Created January 23, 2012 04:31
Emacsのデーモンを立ち上げる時に、既にデーモンが立ち上がっているときに早めに検出して無駄に立ち上げる時間を省く。
#!/usr/bin/env bash
num=`ps aux|grep emacs\ -nw\ --daemon|wc -l`
if [ $num = 1 ]
then
TERM=xterm-256color emacs -nw --daemon
else
echo 'Emacs is already running.'
fi