Skip to content

Instantly share code, notes, and snippets.

View polidog's full-sized avatar
🌎

Ryota Mochizuki polidog

🌎
View GitHub Profile
@polidog
polidog / gulpfile.coffee
Created July 12, 2014 18:01
gulpでcoffee,jade,stylusを変換するやつ
# 人生初gulpfile
gulp = require "gulp"
coffee = require "gulp-coffee"
jade = require "gulp-jade"
stylus = require "gulp-stylus"
del = require "del"
paths =
coffee: 'src/coffee/*.coffee'
@polidog
polidog / Capfile
Last active August 29, 2015 14:02
Capistrano3でSymfony2をデプロイする ref: http://qiita.com/polidog/items/47ea1ca1f642a47c6091
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
++ # Include Symfony2 tasks
++ require 'capistrano/symfony'
@polidog
polidog / not_foreach.php
Last active August 29, 2015 13:57
foreachを使わないで配列をループさせる昔懐かしき方法。たしかメモリ節約出来るって話があったような気もしなくもない。
<?php
$data = ["type" => "php", "method" => "hoge", "action" => "aaaaa"];
while (list($key, $value) = each($data)) {
echo "key::$key\n";
echo "key::$value\n";
}
@polidog
polidog / hoge.html.twig
Created March 22, 2014 15:08
TwigをつかってBackboneのModelとかCollectionとかでリクエスト先のURLを指定する
<script>
var HogeModel = Backbone.Model.extend({
methodToURL: {
'read' : '{{ path("get_hoge") }}',
'create': '{{ path("post_hoge") }}',
'update': '{{ path("put_hoge", {"id": "id"}) }}',
'delete': '{{ path("delete_hoge", {"id": "id"}) }}'
},
defaults: function() {
return {};
<?php
class DataObject
{
public $a;
public $b;
public function __toString()
{
return (string)$this->a . ','. $this->b;
}
@polidog
polidog / con.php
Created February 28, 2014 10:22
phpでの文字コードを変換するときに再起的に行う
<?php
array_walk_recursive($_GET, function(&$value){
$value = mb_convert_encoding($value, 'UTF_8', 'SJIS-win');
});
# app/alt/controllers/index.coffee
doClick = (e)->
alert $.label.text
$.index.open()
@polidog
polidog / alloy.jmk
Created January 2, 2014 16:16
coffee+jade+yamlのalloy.jmk
task("pre:compile", function(event,logger) {
var wrench = require("wrench"),
fs = require("fs"),
jade = require("jade"),
jade_root = event.dir.home + "/alt/views",
coffee_root = event.dir.home + "/alt",
yml_root = event.dir.home + "/alt/styles",
view_root = event.dir.views,
js_root = event.dir.models,
tss_root = event.dir.home + "/styles",
@polidog
polidog / example.html
Last active December 20, 2015 22:19
leapMotionでスワイプがleftかrightかupかdownかを判定するためのjQueryプラグイン
<!DOCTYPE html>
<html lang="ja">
<head>
<title>example</title>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
</head>
<body>
<div id="name">
/*
html2image 0.0.1 <http://html2canvas.hertzen.com>
Copyright (c) 2013 Ryota Mochizuki (@polidog)
Fork by
html2canvas 0.4.0 <http://html2canvas.hertzen.com>
Copyright (c) 2013 Niklas von Hertzen (@niklasvh)
Released under MIT License
*/