Skip to content

Instantly share code, notes, and snippets.

<?php
$startDate = new DateTime('2014-11-12 12:00:00');
$endDate = clone $startDate;
$endDate->add(new DateInterval('P5D'));
$days = iterator_to_array(new DatePeriod($startDate, new DateInterval('P1D'), $endDate));
#!/bin/sh
set -u
echo "Branch name:"
read BRANCH_NAME
git checkout -b "$BRANCH_NAME"
git commit --allow-empty -m "create wip"
#!/bin/sh
bfg --delete-files $@ $(git rev-parse --show-toplevel)
@technolize
technolize / gist:565a0339aa2c0198ee8f
Last active August 29, 2015 14:03
OS X のデスクトップアイコンの表示・非表示を切り替えるやつ
#!/bin/sh
hide_desktop() {
echo "change configuration to hide desktop icons."
defaults write com.apple.finder CreateDesktop -boolean false
}
show_desktop() {
echo "change configuration to display desktop icons."
defaults delete com.apple.finder CreateDesktop
#!/bin/sh
git log --stat --after `date +'%F' --date '1 day ago'`
@technolize
technolize / UIImage+R4.h
Last active December 24, 2015 01:39
4inch retina専用画像を利用するためのやつ
#import <UIKit/UIKit.h>
@interface UIImage (R4)
+ (UIImage *)imageNamedR4:(NSString *)name;
@end
@technolize
technolize / ts.go
Last active December 23, 2015 23:49
Unix タイムスタンプを取得するコマンド
package main
import (
"fmt"
"os"
"log"
"strconv"
"strings"
"time"
)
>> sysctl -w net.inet.ip.scopedroute=0
sysctl: oid 'net.inet.ip.scopedroute' is read only
Updating kernel boot flags.
>> defaults read /Library/Preferences/SystemConfiguration/com.apple.Boot Kernel Flags
>> defaults write /Library/Preferences/SystemConfiguration/com.apple.Boot Kernel Flags net.inet.ip.scopedroute=0
s: Ready: 1 r=[4] w=[] x=[]
s: < channel=0 cmd=PING len=7
s: > channel=0 cmd=PONG len=7 (fullness=53)
s: mux wrote: 15/15
s: Waiting: 1 r=[4] w=[] x=[] (fullness=60/0)
@technolize
technolize / outdated.py
Last active October 11, 2015 02:58
更新されたパッケージをチェックする pip のサブコマンド
import pkg_resources
try:
import xmlrpc.client as xmlrpclib
except ImportError:
import xmlrpclib
import pip
import pip.download
from pip.log import logger
from pip.basecommand import Command
from pip.util import get_installed_distributions
/* fetch local IP address */
err = net_default_source_addr_get(AF_INET, &laddr);
if (err) {
re_fprintf(stderr, "local address error: %s\n", strerror(err));
goto out;
}
inet_aton("127.0.0.1", &(laddr.u.in.sin_addr));