Skip to content

Instantly share code, notes, and snippets.

View danhper's full-sized avatar

Daniel Perez danhper

View GitHub Profile
@danhper
danhper / Vagrantfile
Last active August 30, 2015 11:51
Vagrantfile to reproduce issue in Phoenix configuration reload
# Start the VM with `vagrant up`
# After everything runs, enter the VM with `vagrant ssh`
# The app lives in the `blog` directory
# After running `mix deps.get && mix ecto.create`, `mix phoenix.server` should work
# The page will be accessible at 192.168.50.4:4000 from the host machine
#
# Some utility scripts are available in the project directory:
#
# * break_it.sh: breaks the app by modifying web/controllers/page_controller.ex
# * fix_it.sh: undo break_it.sh changes
@danhper
danhper / check-main-tag.js
Created August 27, 2015 07:22
Check what tag is used for `main`
'use strict';
var async = require('async');
var _ = require('lodash');
var cheerio = require('cheerio');
var phantom = require('phantom');
var userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1';
var urls = [
@danhper
danhper / common-js-to-es6
Created August 26, 2015 09:49
Transform CommonJS module import to ES6 syntax
# Transform var AAA = require('BBB'); into import AAA from 'BBB';
ls $DIR/**/*.js | xargs sed -i -r "s/var (.*?) = require\('(.*?)'\);/import \1 from '\2';/"
@danhper
danhper / add-use-strict.sh
Created August 26, 2015 09:34
Add 'use strict' to all js files
find $DIR -iname '*.js' -exec sed -i "1 i\'use strict';\n" {} \;
@danhper
danhper / index.js
Created June 6, 2015 11:48
Bug with koa-router nested routes with prefix
'use strict';
const koa = require('koa');
const Router = require('koa-router');
let app = koa();
let router = new Router({
prefix: '/prefix'
});
@danhper
danhper / foo.h
Created May 13, 2015 09:40
Template specialization
class foo
{
public:
foo() {}
};
class bar
{
public:
bar() {}
@danhper
danhper / main.py
Created February 10, 2015 10:37
Python RQ worker
from foo import add
from time import sleep
job = add.delay(1, 2)
print("i do some other stuff")
sleep(3)
@danhper
danhper / prefectures.sql
Last active August 29, 2015 14:13
prefecture Japan
use tabelog_data;
INSERT INTO `prefectures` (`name`)
VALUES ('北海道'), ('青森'), ('岩手'), ('宮城'), ('秋田'), ('山形'),
('福島'), ('茨城'), ('栃木'), ('群馬'), ('埼玉'), ('千葉'),
('東京'), ('神奈川'), ('新潟'), ('富山'), ('石川'), ('福井'),
('山梨'), ('長野'), ('岐阜'), ('静岡'), ('愛知'), ('三重'),
('滋賀'), ('京都'), ('大阪'), ('兵庫'), ('奈良'), ('和歌山'),
('鳥取'), ('島根'), ('岡山'), ('広島'), ('山口'), ('徳島'),
('香川'), ('愛媛'), ('高知'), ('福岡'), ('佐賀'), ('長崎'),
@danhper
danhper / Vagrantfile
Created December 30, 2014 00:03
Vagrant file for i18next clean run
Vagrant.configure(2) do |config|
config.vm.box = "precise64"
config.vm.provision "shell", inline: <<-SHELL
apt-get install -y curl make g++ git
curl -sL https://deb.nodesource.com/setup | bash -
apt-get install -y nodejs
git clone https://github.com/i18next/i18next-node.git
cd i18next-node && npm install && cd ..
chown -R vagrant:vagrant i18next-node
@danhper
danhper / grunt.hooks.coffee
Created November 5, 2014 17:28
Leaves hooks for Dart.
path = require 'path'
fs = require 'fs-extra'
_ = require 'lodash'
request = require 'request'
baseOutput = path.join __dirname, '.build'
module.exports = (grunt) ->
reloadPort = grunt.config.get('watch.livereload.options.livereload.port')