Skip to content

Instantly share code, notes, and snippets.

// http://stackoverflow.com/q/3454526
function getNodeXPath(node, prefix) {
prefix = prefix ? prefix + ":" : "";
var getNodeName = function(node) {
return {
1: prefix + node.nodeName.toLowerCase(), // instanceof Element
3: "text()"
}[node.nodeType];
};
package com.example.jsonrpc;
import android.content.Context;
import android.util.Log;
import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
@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.
*/
@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 / 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;
//
// 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 / 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]
@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に吐いているので
{
"name": "github.com/s-shin/sample",
"dependencies": [
"github.com/gorilla/mux"
]
}
<?php
class Foo
{
public $bar;
function __construct()
{
$this->bar = 'bar';
}