Skip to content

Instantly share code, notes, and snippets.

@mugyu
mugyu / gist.rb
Created August 19, 2012 12:51
RubyでGistの一覧を出力したり個別の内容を出力したり
#!/usr/bin/env ruby
# vim: fileencoding=utf-8
require 'net/https'
require 'uri'
require 'json'
class GistIDNotFound < RuntimeError;end
def get(url)
@mugyu
mugyu / gist:3473233
Last active October 9, 2015 08:57
gitの個人的虎の巻

git虎の巻

カレントディレクトリを作業ツリーにする

カレントディレクトリを作業ツリーにする。 具体的には .gitディレクトリが生成される。 まったく何もない状態から始めるならここから。

@mugyu
mugyu / gist:3730822
Created September 16, 2012 02:40
C#のDataSet, DataTable関係メモ
using System;
using System.Data;
using System.Linq;
class Program
{
static void Main()
{
// dataset 作成
var db = new DataSet();
@mugyu
mugyu / gist:5280418
Created March 31, 2013 12:09
jQuery で drop it on me
$('#drop_it_on_me')
.attr('dropzone', 'copy')
.on('dragenter', function(){event.preventDefault();return false})
.on('dragover', function(){event.preventDefault();return false})
.on('drop', function(event){
event.preventDefault();
var data = event.originalEvent.dataTransfer.items[0];
if (data.kind === 'string') {
data.getAsString(function(str){
aret(str);
@mugyu
mugyu / merger.rb
Created January 16, 2014 04:38
二つのEnumeratorを外部イテレーターの機能で突き合わせを行いマージする
class Merger
def initialize(master, tran)
@master = master
@tran = tran
end
def match(master, tran)
puts " match: #{master}, #{tran}"
end
@mugyu
mugyu / gist:8681927
Last active January 4, 2016 21:39
php で未定義のプロパティに値をセットしたりゲットしたり。これで ruby みたいな getter や setter が作れる。けど面倒くさいなぁ
<?
class Hoge
{
private $message = 'hello, world!';
function __get($var)
{
switch ($var) {
case 'message':
print $this->message . PHP_EOL;
break;
@mugyu
mugyu / gist:9540603
Last active August 29, 2015 13:57
Win32 FILETIMEとUNIX時間とを相互に変換する
# Win32 FILETIMEとUNIX時間とを相互に変換する
class Time
WINDOWS_TICK = 10000000
SEC_TO_UNIX_EPOCH = 11644473600
def self.at_wtime(wtime)
self.at(wtime / WINDOWS_TICK - SEC_TO_UNIX_EPOCH)
end
@mugyu
mugyu / 0_reuse_code.js
Created March 20, 2014 23:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mugyu
mugyu / is_cli.php
Created March 31, 2014 01:15
PHPでコマンドラインから起動したか判断する
if (php_sapi_name() === 'cli' || defined('STDIN'))
{
set_time_limit(0);
}
@mugyu
mugyu / say.php
Created March 31, 2014 02:10
CodeIgniter のコントローラーをコマンドラインから起動する
// # CodeIgniter のコントローラーをコマンドラインから起動する
//
// 1. `application/controllers/say.php` を作成(このファイル)
// 2. `localhost/say/hello` とかのURLでアクセスすると
// hello, world! とブラウザーで閲覧出来る。
// 3. コマンドラインで `php index.php say hello "hoge"` と入力すると
// hello, hoge! と標準出力に出力される。
<?php
class Say extends CI_Controller {