Skip to content

Instantly share code, notes, and snippets.

View pistatium's full-sized avatar
🚲
Cycling

kimihiro_n pistatium

🚲
Cycling
View GitHub Profile
@pistatium
pistatium / php_foreach.php
Last active December 19, 2015 09:09
foreach trap
<?php
$arr = array(
"first" => 1,
"second" => 2,
);
echo "\nBefore \n";
print_r($arr);
@pistatium
pistatium / TableBuilder.js
Last active December 19, 2015 13:39
= Table Builder = JSON等から手っ取り早くTableタグを生成する用の関数
/*
データを手っ取り早くテーブルにして表示するための関数
何を表示するかを定義したheaderと、
配列形式で複数行のデータが入ったdataを渡すと
テーブルのHTMLを返す
*/
var tableBuilder = function(header, data) {
var html = '<table class="table"><thead><tr>';
for (var key in header) {
html += '<th id="label_' + key + '">' + header[key] + '</th>';
@pistatium
pistatium / hexTo64.py
Created November 14, 2013 10:41
MD5のような16進数の文字列をA-Z a-z 0-9 + _ の64文字で表すための関数
#!/usr/local/bin/python2.7
import md5
def hexTo64(hex):
result = []
for i in range(8):
# 16 * 16 / 4 = 64
tmp = int(hex[i * 2: i * 2 + 2],16) / 4
if tmp < 26:
# A-Z
@pistatium
pistatium / DailyScheduler.java
Created November 15, 2013 09:12
DailyScheduler
package com.appspot.pistatium.tomorrow.service;
import java.util.Calendar;
import java.util.TimeZone;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import markdown
md = markdown.Markdown()
sample_makedown = '''
An h1 header
============
Paragraphs are separated by a blank line.
@pistatium
pistatium / AndroidManifest.xml
Created January 10, 2014 01:29
ActiveAndroidをContentProvider経由で使うメモ ref: http://qiita.com/pistatium@github/items/0092a2c4758e12481df9
<provider
android:name="com.activeandroid.content.ContentProvider"
android:authorities="APKのパッケージ名" />
@pistatium
pistatium / file0.php
Created January 21, 2014 10:02
XMLからJSON形式への変換メモ(PHP) ref: http://qiita.com/pistatium@github/items/7cfcd4ccb91c6f4c43e9
$obj = simplexml_load_string($xml);
$json = json_encode($obj);
@pistatium
pistatium / file0.html
Created January 24, 2014 10:37
Django Templateのif-elseを短く書く ref: http://qiita.com/pistatium@github/items/f85e44d29d36982480aa
{% if param.status == 1 %}
<!-- 特定の条件の場合activeというクラス名をつける -->
<li class="active">
{% else %}
<li>
{% endif %}
<a href="#">Active</a>
</li>
……
@pistatium
pistatium / 0_reuse_code.js
Created March 20, 2014 05:52
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
@pistatium
pistatium / javascript_resources.md
Created March 20, 2014 05:52 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage