Skip to content

Instantly share code, notes, and snippets.

View shouhei's full-sized avatar

Shouhei shouhei

  • japan
View GitHub Profile
@shouhei
shouhei / Rippotai.php
Created June 17, 2014 13:47
Object Oriented PHP
<?php
class Rippotai {
private $tate;
private $yoko;
private $takasa;
public function __construct($tate,$yoko,$takasa){
$this->tate = $tate;
@shouhei
shouhei / calc.js
Created June 19, 2014 13:29
calc.js
var payment_type = <?php json_encode(array('hogehoge'=>array('payment'=>'金額'))); ?>;
$('select[name="product_name"]').on('change',function(){
change_tax();
$('#price').val(get_price()).change();
});
var get_tax = function(){
return $('input[name=taxation]:checked').val() == 0?0:0.08;
}
@shouhei
shouhei / historygrep.awk
Created June 28, 2014 12:53
histoyr grep
history | grep hogehoge | awk 'BEGIN{ORS=""}{a=split($0,array,",");for(i=2;i<a;i++){print array[i] ","} print array[i] "\n"}'
@shouhei
shouhei / move_rename.pl
Last active August 29, 2015 14:04
ファイルを移動してリネームする。CLIからの第一引数が移動先でのファイル名、第二引数が移動対象の拡張子
#!/usr/bin/perl
binmode STDOUT,":utf8";
use strict;
use warnings;
use utf8;
use File::Copy;
my $class_name = $ARGV[0];
@shouhei
shouhei / ctfed.pl
Created July 17, 2014 23:14
指定したファイルを、カレントディレクトリ直下の全ディレクトリにコピーする
#!/usr/bin/perl
binmode STDOUT,":utf8";
use strict;
use warnings;
use utf8;
use File::Copy;
my $file = $ARGV[0];
@shouhei
shouhei / post_json.py
Last active August 29, 2015 14:05
jsonをパースしてpostするやーつ
# coding:utf-8
import urllib
import urllib2
import json
import sys
args = sys.argv
argc = len(args)
if (argc != 3):
print 'Usage: arg is url and filename'
@shouhei
shouhei / php-cs-fixer.el
Created September 11, 2014 03:27
PHP CS fixerをemacsから使うための関数
(defun php-cs-fixer ()
(interactive)
(setq filename (buffer-file-name (current-buffer)))
(call-process "php-cs-fixer" nil nil nil "fix" filename )
(revert-buffer t t)
)
@shouhei
shouhei / subnetmaskipv4.py
Created November 7, 2014 13:01
To generate ipv4 subnet mast
def generate(len):
bin = ("1"* len) + ("0"* (32 - len))
return '.'.join(map(str,[ int(bin[i:i+8],2) for i in range(0,32,8)]))
@shouhei
shouhei / rege.pl
Created December 7, 2014 08:34
htmlタグを抜き去るやーつ
my $example = "<a href='http://example.com'>example</a>";
$example =~ s/<[a-zA-Z'"=:\/\. ]*>//g;
print $example;
@shouhei
shouhei / object_verification.rb
Last active August 29, 2015 14:11
ObjectVerification
plain_a = ['fizz']
plain_b = plane_a
plain_a << 'buzz'
p plain_a
#["fizz", "buzz"]
p plain_b