Skip to content

Instantly share code, notes, and snippets.

@ahomu
ahomu / jqtmpl2php.php
Last active December 17, 2015 09:08
不毛.php
<?php
$content = file_get_contents('./test.txt');
$config = array(
'assocArray' => true,
);
$content = preg_replace_callback('/(\$\{(.*?)\}|\{\{\w+\s(.*?)\}\})/s', function($m) use($config) {
$subject = $m[1];
@ahomu
ahomu / extendClass.js
Last active December 16, 2015 17:50
継承脳乙
'use strict'
var DEFINE_NOT_WRITABLE = {writable: false};
/**
* Base Class of OOP feature
*
// e.g 1
var Klass = klass.of({
constructor: function() {
@ahomu
ahomu / shots_from_listed_urls.js
Last active December 16, 2015 12:28
スクリーンショットをガンガン撮るぞくん require phantomjs >1.7, async.js >0.2.7
var PARALLEL_LIMIT = 3;
var Page = require('webpage');
var async = require('./async.js');
var i = 0, iz;
var urls = [
"http://css.studiomohawk.com",
"http://inkdesign.jp",
"http://t32k.me/mol",
"http://havelog.ayumusato.com",
"http://aho.mu"
class ArticleActivity extends Activity with TypedActivity {
override def onCreate(savedInstanceState: Bundle) {
super.onCreate(savedInstanceState)
val details: EntryFragment = new EntryFragment()
details.setArguments(getIntent().getExtras())
getFragmentManager().beginTransaction().add(android.R.id.content, details).commit()
}
}
@ahomu
ahomu / chikoque.js
Last active December 16, 2015 03:39
かきすて しかし、気がつけばスクロール同期+キュー管理へ。
/**
* Chikoque
*
* @author ahomu
*/
(function(win, doc, _) {
'use strict';
var defaults = {
@ahomu
ahomu / reach.js
Last active December 16, 2015 03:19
かきすて
/**
* Reach element when triggered custom events
*
* @dependency underscore or lodash
* @Inspired by https://github.com/alexblack/infinite-scroll
* @author ahomu
*/
(function(win, doc, _) {
'use strict';
@ahomu
ahomu / models_createjs.js
Created February 5, 2013 11:23
CreateJSのプリロードと適用周りをむりやりModelっぽくしてみたりウーン...
/**
* CreatejsModel
*
* 大雑把にこんな???
* var scene01 = new CreatejsModel({animationName: 'scene01'});
* scene01.apply($('canvas#sceneStage'));
*/
define(['backbone', 'anim', 'createjs'], function(Backbone, Anim, createjs) {
return Backbone.model.extend({
url: 'resource-manifests.json',
@ahomu
ahomu / gist:4700664
Created February 3, 2013 05:44
Difference of between 1.4.3 and 1.4.4 (Underscore.js)
diff --git a/underscore1.4.3.js b/underscore1.4.4.js
index 4d83099..6642c09 100644
--- a/underscore1.4.3.js
+++ b/underscore1.4.4.js
@@ -1,6 +1,6 @@
-// Underscore.js 1.4.3
+// Underscore.js 1.4.4
// http://underscorejs.org
-// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
+// (c) 2009-2013 Jeremy Ashkenas, DocumentCloud Inc.
@ahomu
ahomu / totsuzen.js
Created January 30, 2013 11:12
% totsuzen 突然の死 | pbcopy
#!/bin/node
// via http://starwing.net/suddenly_death.html
String.prototype.lengthByte = function()
{
var str = this;
var r = 0;
for (var i = 0; i < str.length; i++) {
var c = str.charCodeAt(i);
@ahomu
ahomu / fill_expand_files.js
Last active December 11, 2015 08:58
0.4.0rc系で削除されたので、応急処置的にgrunt.file.expandFilesを復活させるときのサンプル
// 自作タスクの中だけの場合
// usage: `expandFiles(patternString)`
var expandFiles;
if (grunt.file.expandFiles) {
expandFiles = grunt.file.expandFiles;
} else {
expandFiles = function(filesPattern) {
return grunt.file.expand({filter: 'isFile'}, filesPattern);