Skip to content

Instantly share code, notes, and snippets.

View 0xqd's full-sized avatar
🚀
Buidl web3

jn 0xqd

🚀
Buidl web3
View GitHub Profile
@0xqd
0xqd / Gemfile
Created August 7, 2012 03:54
Rails gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.7'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
@0xqd
0xqd / rails_backbone.rb
Created August 18, 2012 11:46
Blog: rails + backbone
>rails new Railsbackbone
>cd backbone_rails
#edit Gemfile
gem 'rails-backbone'
>bundle install
>rails g scaffold Post title:string content:string
>rake db:migrate
@0xqd
0xqd / remove_files.php
Created August 22, 2012 07:56
php - remove all files and subdirs in a folder
<?php
$dir = './images/';//note the trailing slashes
foreach (new DirectoryIterator($dir) as $fileInfo)
if(!$fileInfo->isDot()) {
if ($fileInfo->isFile())
unlink($fileInfo->getFilename());
if ($fileInfo->isDir())
rmdir($fileInfo->getPath().'/'.$fileInfo->getFilename().'/');
}
@0xqd
0xqd / omniauth.rb
Created August 26, 2012 06:13 — forked from dira/omniauth.rb
OmniAuth strategy for a custom provider
# config/initializers/omniauth.rb
module OmniAuth
module Strategies
# tell OmniAuth to load our strategy
autoload :Pixelation, 'lib/pixelation_strategy'
end
end
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, "app_name", "secret"
@0xqd
0xqd / example.rb
Created August 26, 2012 13:50 — forked from henrik/example.rb
Simple memoize method for Ruby now that ActiveSupport::Memoizable is deprecated. Memoizes per argument set, handles falsy values.
def my_method(foo, bar)
memoize(:my_method, foo, bar) do
foo * bar
end
end
@0xqd
0xqd / ruby-memoization.rb
Created August 26, 2012 19:20 — forked from rfelix/gist:79500
Ruby Self-Modification Example - Memoize
require 'benchmark'
class Fib
def fib(n)
return n if n < 2
return fib(n-1) + fib(n-2)
end
end
def memoize(className, methodName)
@0xqd
0xqd / package.json
Created August 30, 2012 13:53 — forked from gquental/package.json
Nodejs - Package.json
{
"name": "app-name",
"version": "0.1.0",
"author": "nXqd",
"description": "app-description",
"dependencies": {
"request": "*",
"connect": "*"
},
"engines": {
@0xqd
0xqd / _html5boilerplate.css.sass
Created August 31, 2012 08:30 — forked from richardvenneman/_html5boilerplate.css.sass
HTML5 Boilerplate HAML & SASS
/*
* HTML5 ✰ Boilerplate
*
* What follows is the result of much research on cross-browser styling.
* Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
* Kroc Camen, and the H5BP dev community and team.
*
* Detailed information about this CSS: h5bp.com/css
*
* ==|== normalize ==========================================================
@0xqd
0xqd / change_default_message.js
Created August 31, 2012 08:35
jQuery validation cheatsheet
// Change the default message of jquery validation
jQuery.extend(jQuery.validator.messages, {
required: "This field is required.",
remote: "Please fix this field.",
email: "Please enter a valid email address.",
url: "Please enter a valid URL.",
date: "Please enter a valid date.",
dateISO: "Please enter a valid date (ISO).",
number: "Please enter a valid number.",
digits: "Please enter only digits.",
@0xqd
0xqd / recipes.rb
Created August 31, 2012 09:03
My ruby recipes
# back button
<%= link_to 'Back', :back %>