Skip to content

Instantly share code, notes, and snippets.

@s-shin
s-shin / anchor.js
Last active August 29, 2015 14:17
Anchor Bookmarklet
(function() {
var elsWithId = document.querySelectorAll("*[id]");
var IGNORE_TAGS = {
SCRIPT: true,
IFRAME: true
};
for (var i = 0, len = elsWithId.length; i < len; ++i) {
var el = elsWithId[i];
>>> $dt1 = new DateTime()
=> <DateTime #000000007766f6860000000009e51d7d> {
date: "2015-02-09 12:13:50",
timezone_type: 3,
timezone: "Asia\/Tokyo"
}
>>> $dt2 = new DateTime('@'.$dt1->getTimestamp())
=> <DateTime #000000007766f6810000000009e51d7d> {
date: "2015-02-09 03:13:50",
timezone_type: 1,
<?php
class Foo
{
public $bar;
function __construct()
{
$this->bar = 'bar';
}
{
"name": "github.com/s-shin/sample",
"dependencies": [
"github.com/gorilla/mux"
]
}
@s-shin
s-shin / pre-commit.sample_for_php.pl
Last active August 29, 2015 14:10
Git pre-commit sample for PHP
#!/usr/bin/env perl
use strict;
use warnings;
use Term::ANSIColor;
use Term::ReadLine;
my $term = Term::ReadLine->new('pre-commit');
BEGIN {
# STDOUTに吐いても良い気もするが、pre-commit.sampleがSTDERRに吐いているので
@s-shin
s-shin / fizzbuzz
Created November 29, 2014 07:19
fizzbuzz one liner
fizzbuzz=(n)->["FizzBuzz",n,n,"Fizz",n,"Buzz","Fizz",n,n,"Fizz","Buzz",n,"Fizz",n,n][n%15]
//
// Behavior of NSString with NULL character tail-padding.
//
// **I thought this behavior is wrong, but now, I see it's correct as NSString.**
//
// Usage:
// $ gcc nsstring-null-tail-padding.m -framework Foundation
// $ ./a.out
//
#import <Foundation/Foundation.h>
@s-shin
s-shin / IntentUtil.java
Created September 7, 2014 08:59
Hotentorで作ったIntentユーティリティから抜粋。
package jp.hateblo.shin.hotentor.util;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import jp.hateblo.shin.hotentor.App;
@s-shin
s-shin / ViewUtil.java
Created September 7, 2014 08:49
Hotentorで使ったViewユーティリティから一部抜粋。
package jp.hateblo.shin.hotentor.util;
import android.annotation.TargetApi;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.TypedValue;
import android.view.View;
import jp.hateblo.shin.hotentor.App;
@s-shin
s-shin / LogUtil.java
Created September 7, 2014 08:46
Hotentorで使ったLogユーティリティ
package jp.hateblo.shin.hotentor.util;
import android.util.Log;
import jp.hateblo.shin.hotentor.BuildConfig;
/**
* ref: http://wada811.blogspot.com/2013/04/android-log-util.html
* Created by shin on 2014/08/30.
*/