Skip to content

Instantly share code, notes, and snippets.

View 44uk's full-sized avatar
♨️
ズイ₍₍(ง˘ω˘)ว⁾⁾ズイ

Yoshiyuki IEYAMA 44uk

♨️
ズイ₍₍(ง˘ω˘)ว⁾⁾ズイ
View GitHub Profile
@44uk
44uk / sticky_footer.scss
Created July 5, 2012 13:35
stiky footer
@44uk
44uk / gist:3384755
Created August 18, 2012 06:00
Ruby Class Initialize with attributes
class Hoe
# attr_accessor
def initialize(attributes = nil)
assign_attributes(attributes) if attributes
yield self if block_given?
end
def assign_attributes(new_attributes)
new_attributes.each do |k, v|
@44uk
44uk / rserver.rb
Created August 20, 2012 15:34
Ruby Simple Local Server
#!/usr/bin/env ruby
require 'webrick'
srv = WEBrick::HTTPServer.new(
:BindAddress => '127.0.0.1', # '0.0.0.0' allow remote access
:Port => (port = ARGV[0].to_i) === 0 ? 3000 : port,
:DocumentRoot => './',
:DoNotReverseLookup => true
)
trap(:INT){srv.shutdown}
srv.start
$('body').on('click', 'a', function(e) {
e.preventDefault();
$.get($(this).attr('href')).success(function(html) {
$('body').html('');
$('body').append($(html).find('body'));
})
});
@44uk
44uk / git-export-diff-between-revs
Created August 4, 2013 06:52
Export diff files between 2 revisions.
#!/usr/bin/env ruby
#
#= Export diff files between 2 revisions.
#
# export only commited files for SourceTree.
#
#== setup
#
# set this script to cunstom action.
# then, set "$REPO $SHA" in parameters.
@44uk
44uk / git-export-diff
Created August 5, 2013 05:45
Export diff files from git repository.
#!/usr/bin/env ruby
#
#= Export diff files between revs.
#
# export only commited files.
#
#== setup
#
# set this script to cunstom action.
# then, set "$SHA" in parameters.
/* 先頭行: 他のスクリプトでのセミコロン忘れに備え、且つ、予約語でないundefinedの書換えによる誤動作を防いでいる。*/
;(function($, undefined) {
"use strict";
$.fn.myPlugIn = function(option) {
var a, b, c;
//※未設定のオプション項目に初期値を設定
option = $.extend({
opt1: null,
@44uk
44uk / new_gist_file
Created August 27, 2013 05:45
カントリーコード(2文字)正規表現
(A[CDEFGILMNOQRSTUWZ]|B[ABDEFGHIJMNORSTVWYZ]|C[ACDFGHIKLMNORUVXYZ]|D[JKMOZCEGRST]|F[IJKMOR]|G[ABDEFGHILMNPQRSTUWY]|H[KMNRTU]|I[DELMNOQRST]|J[EMOP]|K[EGHIMNPRWYZ]|L[ABCIKRSTUVY]|M[ACDGHKLMNOPQRSTUVWXYZ]|N[ACEFGILOPRUZ]|OM|P[AEFGHKLMNRTWY]|QA|R[EOUW]|S[ABCDEGHIJKLMNORTUVYZ]|T[CDFGHJKMNOPRTVWZ]|U[AGKMSYZ]|V[ACEINU]|W[FS]|Y[ETU]|Z[AMRZW])
@44uk
44uk / Gruntfile.coffee
Created September 8, 2013 07:29
Gruntfile.coffee を書いてみた
# grunt install grunt-contrib --save-dev
# grunt install grunt-bower-task --save-dev
'use strict'
excludes = [
'!**/.DS_Store'
'!**/Thumbs.db'
'!**/*.coffee'
'!**/*.map'
@44uk
44uk / timeAgoInWords
Created September 10, 2013 03:58
timeAgoInWords
<?php
function timeAgoInWords($datetime, $now = null){
if($now === null){ $now = date('Y-m-d H:i:s'); }
$units = array(
'y' => 31104000,
'm' => 2592000,
'd' => 86400,
'h' => 3600,