Skip to content

Instantly share code, notes, and snippets.

View wittawasw's full-sized avatar

Wittawas W wittawasw

View GitHub Profile
# First configure your models to use Amazon s3 as storage option and setup the associated S3 config.
# Then add the classes your want to migrate in the klasses array below.
# Then run rake paperclip_migration:migrate_to_s3
# Should work but this is untested and may need some tweaking - but it did the job for me.
namespace :paperclip_migration do
desc "migrate files from filesystem to s3"
task :migrate_to_s3 => :environment do
klasses = [:model_1, :model_2] # Replace with your real model names. If anyone wants to this could be picked up from args or from configuration.
klasses.each do |klass_key|
./configure \
--user=nginx \
--group=nginx \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# pidfile: /var/run/nginx.pid
package server
//just one line is enough to host static site
application: your-app-id-here
version: 1
runtime: go
api_version: go1
handlers:
- url: /
static_files: index.html
upload: index\.html
user nginx;
worker_processes 32;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@wittawasw
wittawasw / application.js
Last active August 29, 2015 14:02
Web Worker concept
(function() {
var worker = new Worker("js/worker.js");
worker.onmessage = function(e) {
alert("worker: " + e.data);
}
worker.postMessage('start');
// send msg the worker.
@wittawasw
wittawasw / home_controller.rb
Created September 24, 2014 17:48
Rails jsonp request with angular
class HomeController < ApplicationController
def testtest
puts '########################################'
response = params[:test]
render :json => response.to_json, :callback => params['callback']
end
end
@wittawasw
wittawasw / rails_admin.th.yml
Created April 26, 2015 07:32
Thai locale for rails_admin
th:
admin:
js:
true: ถูก
false: ผิด
is_present: มีอยู่?
is_blank: ว่าง?
date: วันที่ ...
between_and_: ระหว่าง ... และ ...
today: วันนี้
@wittawasw
wittawasw / fizzbuzz.rb
Last active July 2, 2016 12:18
fizzbuzz module in Ruby
module FizzBuzz
class << self
def out(range: 1..100)
range.map { |num| print(num) }
end
private
def print(i)
if fizzbuzz?(i)