Skip to content

Instantly share code, notes, and snippets.

@codemilan
codemilan / database_cleaner.rb
Created April 6, 2016 05:28 — forked from jsteiner/database_cleaner.rb
Database Cleaner
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do
@codemilan
codemilan / registrations_controller.rb
Created May 2, 2016 12:31 — forked from evanbeard/registrations_controller.rb
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@codemilan
codemilan / Mercator.rb
Created May 10, 2016 05:54 — forked from humanzz/Mercator.rb
Ruby implementation for GMercatorProjection
# This is a port of the javascript code found in the following link
#http://groups.google.com/group/Google-Maps-API/browse_thread/thread/a45947d72c27cc73
class Mercator
#offset is defined at zoom level 21 which means that this Mercator is valid for 21 zoom levels
OFFSET = 268435456
RADIUS = OFFSET / Math::PI
def self.lng_to_x(lng, zoom)
(OFFSET + RADIUS * lng * Math::PI / 180).to_i >> (21 - zoom)
@codemilan
codemilan / flexible interface.rb
Created May 13, 2016 15:58 — forked from theHamdiz/flexible interface.rb
Learn how to build flexible interfaces using instance_eval in #ruby
class Person
def name(n)
@name = n
self
end
def age(a)
@age = a
self
end
@codemilan
codemilan / nginx.conf
Created June 7, 2016 10:41 — forked from billie66/nginx.conf
Deploy Rails on Ubuntu server 12.04 with Nginx, Unicorn, Mongodb, Mongoid
# This file should be placed on the directory of ~/blog/config
upstream unicorn {
server unix:/tmp/unicorn.todo.socket fail_timeout=0;
}
server {
listen 80 default;
#server_name example.com;
root /home/username/blog/public;
@codemilan
codemilan / Capfile
Created June 14, 2016 07:37 — forked from chrisbloom7/Capfile
Open a Rails console via Capistrano 3 (requires capistrano-rvm gem)
require 'capistrano/rvm'
@codemilan
codemilan / deploy.rb
Created June 14, 2016 12:37 — forked from toobulkeh/deploy.rb
Updated for Capistrano 3.
# encoding: UTF-8
# Place in config/deploy.rb
namespace :rails do
desc "Open the rails console on each of the remote servers"
task :console do
on roles(:app) do |host| #does it for each host, bad.
rails_env = fetch(:stage)
execute_interactively "ruby #{current_path}/script/rails console #{rails_env}"
@codemilan
codemilan / commands.sh
Created December 19, 2016 05:28 — forked from ryana/commands.sh
Monkey patch Sprockets so that non-digest assets will be generated when ENV['SPROCKETS_NON_DIGEST'] is present
# Run locally
$ SPROCKETS_NON_DIGEST=true RAILS_ENV=production rake assets:precompile
# Heroku setup
$ heroku labs:enable user-env-compile
$ heroku config:add SPROCKETS_NON_DIGEST=true
@codemilan
codemilan / css_resources.md
Created July 22, 2017 15:19 — forked from maxivak/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@codemilan
codemilan / leafFileSync.php
Created July 25, 2017 11:13 — forked from mungurs/leafFileSync.php
elFinder file sync. with db
<?php
class leafFileSync{
private $enableLog = false;
public function __construct($logSynchronization = false){
$this->enableLog = $logSynchronization;
}
public function sync($cmd, $result, $args, elFinder $elFinder, elFinderVolumeDriver $volume){