Skip to content

Instantly share code, notes, and snippets.

View juniovitorino's full-sized avatar
🏠
Working from home

Junio Vitorino juniovitorino

🏠
Working from home
View GitHub Profile
@mrrooijen
mrrooijen / carrierwave_tasks.rb
Created June 2, 2010 00:27
Rake Tasks for Carrier Wave for reprocessing versions.
##
# CarrierWave Amazon S3 File Reprocessor Rake Task
#
# Written (specifically) for:
# - CarrierWave
# - Ruby on Rails 3
# - Amazon S3
#
# Works with:
# - Any server of which you have write-permissions in the Rails.root/tmp directory
@ghickman
ghickman / _contact.rb
Created July 4, 2010 17:23
Jekyll Contact Form with Sinatra
require 'rubygems'
require 'sinatra'
require 'pony'
require 'haml'
set :haml, {:format => :html5}
set :public, File.dirname(__FILE__)
set :views, File.dirname(__FILE__)
# Create the page class and give it a title of Contact for the layout
@rafaelsachetto
rafaelsachetto / gist:758655
Created December 29, 2010 15:53
Dica para ambiente usando RVM (pushd/popd)
# hack to rvm invoke .rvmrc
cd_with_pushd()
{
if [ $# -eq 0 ]; then
DIR="${HOME}"
else
DIR="$1"
fi
pushd "${DIR}"
filenames = Dir.glob(Rails.application.paths.app.models.collect { |path| File.join(path, "**/*.rb") })
$class_names = []
filenames.each do |filename|
$class_names += File.read(filename).scan(/class ([\w\d_\-:]+)/).flatten
end
@jphpsf
jphpsf / application.html.erb
Created July 16, 2011 05:48
Reuse of the Rails Admin layout for the whole application
# app/views/layouts/application.html.erb
<% head_style 'styles' %>
<% head_javascript 'application' %>
<%= render :file => 'layouts/rails_admin/main' %>
@cballou
cballou / wordpress-multi-env-configphp-setup.php
Created August 15, 2011 13:54
Wordpress Multi-Environment wp-config.php Setup
<?php
/**
* This code is intended to be added to your wp-config.php file just below the top comment block.
* It should replace the existing define('DB_*') statements. You can add or remove sections
* depending on the number of environments you intend to setup. You should change all values of
* DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST for each environment, making them all distinct
* for security purposes.
*/
// determine the current environment
@macdonst
macdonst / sqltest.js
Created December 21, 2011 21:43
Create DB from .sql file
if (localStorage.getItem("dbCreated") != true) {
html5sql.openDatabase("ScratchDB", "Scratch DB", 3 * 1024 * 1024);
var request = new XMLHttpRequest();
request.open("GET", "file:///android_asset/www/create.sql", true);
request.onreadystatechange = function(){
if (request.readyState == 4) {
if (request.status == 200 || request.status == 0) {
html5sql.process(request.responseText,
function(){
console.log("Win!");
@scottnix
scottnix / gist:10430003
Last active August 14, 2016 04:38
Gulpfile.js Sample, latest
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
rename = require('gulp-rename'),
notify = require('gulp-notify'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
markdown = require('gulp-markdown'),
@danwit
danwit / passport_node_acl_example.js
Created May 1, 2014 23:23
Authentication and authorization with passportjs + node_acl + mongo + express
/**
* Simple authentication and authorization example with passport, node_acl,
* MongoDB and expressjs
*
* The example shown here uses local userdata and sessions to remember a
* logged in user. Roles are persistent all the way and applied to user
* after logging in.
*
* Usage:
* 1. Start this as server
@viniciusrtf
viniciusrtf / lenura_empty_cart_before_add.php
Last active February 1, 2024 12:32
WooCommerce Hook: Empty cart before adding a new product to cart WITHOUT throwing woocommerce_cart_is_empty
<?php
/**
* Hook: Empty cart before adding a new product to cart WITHOUT throwing woocommerce_cart_is_empty
*/
add_action ('woocommerce_add_to_cart', 'lenura_empty_cart_before_add', 0);
function lenura_empty_cart_before_add() {
global $woocommerce;
// Get 'product_id' and 'quantity' for the current woocommerce_add_to_cart operation