Skip to content

Instantly share code, notes, and snippets.

View dukex's full-sized avatar
✔️
Verified Account

Duke dukex

✔️
Verified Account
View GitHub Profile
#!/bin/bash
echo "Automated VPS Setup for Ubuntu 10.04 LTS (Lucid) - Rails with Nginx"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
#!/usr/env ruby
# vim:fileencoding=utf-8
require "rubygems"
require "mechanize"
id = "example@example.com"
pwd = "password"
agent = Mechanize.new
@tomas-stefano
tomas-stefano / before_changes.rb
Created October 21, 2010 19:18
before_changes
module BeforeChanges
def before_changes
before_change_object = self.clone
changes.each do |changed_field, change|
before_change_object.send("#{changed_field}=", change[0])
end
before_change_object
end
end
@PotHix
PotHix / gist:640517
Created October 22, 2010 13:19
remarkable -> shoulda sed helpers :P
grep "should_have_many" spec/* -Ril | xargs sed -i "s/should_have_many\(.*\)/it { should have_many\1 }/g"
grep "should_have_one" spec/* -Ril | xargs sed -i "s/should_have_one\(.*\)/it { should have_one\1 }/g"
grep "should_belong_to" spec/* -Ril | xargs sed -i "s/should_belong_to\(.*\)/it { should belong_to\1 }/g"
grep "should_validate_presence_of.*" spec/* -Ril | xargs sed -i "s/should_validate_presence_of\(.*\)/it { should validate_presence_of\1 }/g"
grep "should_validate_uniqueness_of.*" spec/* -Ril | xargs sed -i "s/should_validate_uniqueness_of\(.*\)/it { should validate_uniqueness_of\1 }/g"
grep "should_validate_numericality_of.*" spec/* -Ril | xargs sed -i "s/should_validate_numericality_of\(.*\)/it { should validate_numericality_of\1 }/g"
grep "should_validate_acceptance_of.*" spec/* -Ril | xargs sed -i "s/should_validate_acceptance_of\(.*\)/it { should validate_acceptance_of\1 }/g"
grep "should have_many :.*through.*" spec/* -Ril | xargs sed -i 's/should have_many :\([a-z_=>]*\),.*:through => :\(.*\)
@vinibaggio
vinibaggio / call4paperz api
Created March 2, 2011 01:24
Api do call 4 paperz
# Index
http://www.call4paperz.com/events.json
# Show do evento
http://www.call4paperz.com/events/1.json
# Show da proposta
http://www.call4paperz.com/events/1/proposals/1.json
# Evento com JSONP (preste atenção no p no formato)
@dcrec1
dcrec1 / respond-to.sass
Created August 23, 2012 21:17
respond-to mixin
$mediaPhone: 480px !default
$mediaTablet: 768px !default
$mediaDesktop: 980px !default
$mediaLarge: 1200px !default
=respond-to($media)
@if $media == phone
@media only screen and (max-width: $mediaPhone)
@content
@else if $media == tablet
@jensgro
jensgro / gist:3816624
Created October 2, 2012 06:06
The Current State Of Remote Debugging For Mobile

source: Addy Osmani https://plus.google.com/u/0/115133653231679625609/posts/Px3bQdQ2HDu

Remote debugging allows us to execute and capture code in remote devices, providing a way to inspect HTML, CSS and JavaScript and make live changes. In terms of mobile, this means a way for us to communicate with mobile devices so we can debug code on them directly rather than just relying on emulators.

The landscape for remote debugging your apps on mobile is quite strong at the moment.

Chrome for Android supports remote debugging via USB and allows you to debug using the Chrome Developer Tools. (See: https://developers.google.com/chrome/mobile/docs/debugging and Chrome for Android Remote Debugging for +Boris Smus's video walkthrough)

Opera has had support for remote debugging since 2008 and Dragonfly can remotely connect to Opera Mobile. (Tut: http://www.codegeek.net/blog/2012/mobile-debugging-with-opera-dragonfly/)

@wnuqui
wnuqui / gist:4653064
Last active December 11, 2015 20:09
3 bare bone rails applications using 3 jruby application servers (all running in heroku cedar)
# JAVA_OPTS and Procfiles
JAVA_OPTS: -Djruby.memory.max=384m -Xmx384m -Xms256m -Xss512k -XX:+UseCompressedOops -XX:+PrintGCDetails
# puma backed app's Procfile
web: bundle exec rails server puma -p $PORT -e $RACK_ENV
# torquebox-lite backed app's Procfile
web: bin/torquebox-lite -b 0.0.0.0 -p $PORT --max-threads=8
@tcjr
tcjr / messages.json
Last active December 25, 2015 06:59
Basic pagination with Ember
// The API accepts the page parameter and returns the pagination info in meta
{
"messages": [ ... ],
"meta": {
"pagination": {
"total_pages": 3,
"current_page": 1,
"total_count": 55
}
@dcrec1
dcrec1 / centos
Last active March 24, 2017 11:52
ubuntu/centos nginx
cd /tmp
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm -Uhv rpmforge-release*.rf.i386.rpm
yum install readline-dev htop