Skip to content

Instantly share code, notes, and snippets.

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

Taishi taishikato

🏠
Working from home
View GitHub Profile
@taishikato
taishikato / mojbake.rb
Created March 19, 2014 06:21
Excelで開いたときの文字化け防止
if value.instance_of?(String)
value = value.tosjis
end
time = DateTime.now
prefix = time.strftime("%Y%m%d%H%M")
file_name = File.basename(url)
open(file_name, 'wb') do |output|
open(url) do |data|
output.write(data.read)
end
end
CSV.open(file_name, "w") do |csv|
csv << @element.keys
csv << @element.values
end
#<< の引数には配列を与える
@taishikato
taishikato / create_file.rb
Created March 3, 2014 08:05
Ruby ハッシュをもとにファイルを生成
File.open("./test.tsv", "w") do |file|
@element.each do |key, val|
file.write("#{key} #{val}\n")
end
end
$(function() {
var nav = $('#glo-navi'),
offset = nav.offset();
$(window).scroll(function () {
if($(window).scrollTop() > offset.top) {
nav.addClass('fixed');
} else {
nav.removeClass('fixed');
}
@taishikato
taishikato / fade_in_out.js
Created December 27, 2013 15:13
スタンダードだけど、きれいにフェードインアウトするjQuery
$(function() {
$('#report-map a').hover(
function() {
var keyid = $(this).attr('id');
$('.'+keyid).animate({opacity: "show"}, "slow");
},
function() {
var keyid = $(this).attr('id');
$('.'+keyid).animate({opacity: "hide"}, "fast");
}
@taishikato
taishikato / wp_tips.php
Created December 27, 2013 10:03
WordPress 良く使うコード
<?php
/**
* タイトル
*/
?>
<title><?php bloginfo('name'); ?><?php wp_title( '|', true, 'left' ); ?></title>
@taishikato
taishikato / reset.css
Created December 19, 2013 05:05
Reset CSS
@charset "UTF-8";
/* style reset */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
@taishikato
taishikato / create_csv_line_array.php
Last active December 29, 2015 01:39
CSV 行毎に配列を生成する
<?php
function createCsvLineArray ($csv_file) {
$file = $csv_file;
$data = file_get_contents($file);
$data = mb_convert_encoding($data, 'UTF-8', 'sjis');
$temp = tmpfile();
$csv = array();
fwrite($temp, $data);