Skip to content

Instantly share code, notes, and snippets.

@kumatch
kumatch / bootstrap.php
Created July 15, 2010 05:29
Stagehand_Testrunner prepare scripts for CakePHP.
<?php
if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
trigger_error("CakePHP core could not be found.", E_USER_ERROR);
}
Configure::write('debug', 0);
$version = Configure::version();
if (preg_match('/^1.2/', $version)) {
$corePath = Configure::corePaths('cake');
@kumatch
kumatch / nginx
Created October 20, 2010 15:14
Nginx init script for CentOS (source build)
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: 35 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# config: /etc/sysconfig/nginx
@kumatch
kumatch / gist:2392366
Created April 15, 2012 12:10
async.js forEach block
var doTask = function (value, callback) {
setTimeout(callback(value), 10);
};
var list_count = 100000;
var check_count = list_count / 10;
var list = [];
for (var i = 0; i < list_count; i++) list.push(i);
@kumatch
kumatch / daemon.js
Created March 25, 2013 01:49
Node.js daemon example
var fs = require('fs');
var INTERVAL = 1000;
var cycle_stop = false;
var daemon = false;
var timer;
process.argv.forEach(function (arg) {
if (arg === '-d') daemon = true;
@kumatch
kumatch / Gruntfile.js
Last active March 1, 2018 17:44
A browserify simple example.
module.exports = function(grunt) {
var pkg = grunt.file.readJSON('package.json');
grunt.initConfig({
browserify: {
dist: {
src: 'main.js',
dest: 'build.js'
}
}
@kumatch
kumatch / app.js
Last active August 29, 2015 14:01
Browserify + AngularJS module example
var angular = require('angular');
module.exports = angular.module('myapp', [
require('./item').name,
require('./sample').name
]);
@kumatch
kumatch / 0_reuse_code.js
Created May 23, 2014 04:03
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
@kumatch
kumatch / rails_resources.md
Created May 23, 2014 04:03 — forked from jookyboi/rails_resources.md
Rails-related Gems and guides to accelerate your web project.

Gems

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second.
  • [factory_girl](h
@kumatch
kumatch / bench.txt
Created August 6, 2018 08:23
go map access
# go test -bench . -benchmem
goos: darwin
goarch: amd64
BenchmarkMap1-4 100000 24314 ns/op 2800 B/op 280 allocs/op
BenchmarkMap2-4 50000 25083 ns/op 2800 B/op 280 allocs/op
@kumatch
kumatch / format_routes.rb
Last active August 1, 2019 05:10
list rails controller_path, action from routes.
#!/usr/bin/env ruby
ARGF.each do |line|
case line.chomp
when /^\s+Prefix/, "" then
# header
when /^Routes for /
# fin routes.
break
when /^\s*(?:(\w+) )?(GET|POST|PUT|PATCH|DELETE)\s+(\S+)\s+([\w\/]+)#(\w+)/ then