Skip to content

Instantly share code, notes, and snippets.

View gmodarelli's full-sized avatar

Giuseppe Modarelli gmodarelli

View GitHub Profile
@gmodarelli
gmodarelli / be_a_valid_api_response.rb
Last active August 29, 2015 14:00
Testing API with RSpec
RSpec::Matchers.define :be_a_valid_api_response do
match do |json_response|
json_response['version'] == '1.0' &&
json_response['response']['status'] == 0 &&
json_response['response']['reason'] == 'Request successfully processed'
end
end
@gmodarelli
gmodarelli / Gemfile
Last active August 29, 2015 14:00
XML2JSON
gem 'xml2json', git: 'git@github.com:monksoftware/xml2json.git'
var request = require('supertest'),
should = require('should'),
app = require('../server');
var Cookies;
describe('Functional Test <Sessions>:', function () {
it('should create user session for valid user', function (done) {
request(app)
.post('/v1/sessions')
@gmodarelli
gmodarelli / default_value.rb
Last active August 29, 2015 14:08
Source Code Reading
define_method(abbr) { |date = nil| DatePart.new(abbr, date) }
@gmodarelli
gmodarelli / category.rb
Last active August 29, 2015 14:14
Migrating from a 1-to-many association to a many-to-many association
class Category < ActiveRecord::Base
# Old association
belongs_to :topic
# New association
has_and_belongs_to_many :topics
end
@gmodarelli
gmodarelli / .env
Last active August 29, 2015 14:14
ESC #1: Dotenv
MY_SECRET_ID=jkdsa89jkldas8y9p21bjl
MY_SECRET_TOKEN=jdskalhiop12jldaskd
@gmodarelli
gmodarelli / image.html
Last active August 29, 2015 14:15
AngularJS Promises
<div ng-controller="ImageCtrl">
<div class="ddarea" ng-file-drop="onFileDropped($files)" ng-file-drag-over-class="dropping">
<p>Drag & Drop your design image here</p>
</div>
<div class="layers">
<div class="layer" ng-class="{ active : layer.active }" ng-repeat="layer in layers">
<div style="background-image: url({{layer.thumb}})"></div>
<a ng-click="removeLayer(layer)">Remove</a>
</div>
@gmodarelli
gmodarelli / delay.xml
Created February 19, 2015 15:38
MongooseIM contribution
<x xmlns='jabber:x:delay' from='capulet.com' stamp='20020910T23:08:25'>Offline Storage</x>
@gmodarelli
gmodarelli / gist:3803704
Created September 29, 2012 11:03 — forked from RaVbaker/gist:2967695
[HOWTO] Ubuntu 12.04 Ruby on Rails Development Environment

Ubuntu 12.04 Ruby on Rails Development Environment

I haven't set up an install guide for the latest ubuntu release, largely because the last set of instructions worked pretty closely with the latest and greatest Ubuntu, 12.04 Precise Pangolin, however when installing today, I found that there were enough differences in the way that I configure my setup to justify an update, so here it goes. Yes, I'm late to the party, but a quick google search didn't find anything that I felt was as complete for my requirements as my previous install guides, so here I go.

As always with my install guides, I have included here is just about everything you'll need (and then some) to get started with ruby on rails development with Ubuntu 12.04 as a platform. These are my settings and preferences, and this is certainly not the only way of doing things, so keep that in mind.

Step 1: Get the repos ready and run updates.

sudo apt-get update && sudo apt-get upgrade
@gmodarelli
gmodarelli / setup.sh
Created November 2, 2016 16:12 — forked from Gazler/setup.sh
sysctl -w fs.file-max=12000500
sysctl -w fs.nr_open=20000500
ulimit -n 4000000
sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
sysctl -w net.ipv4.tcp_rmem='1024 4096 16384'
sysctl -w net.ipv4.tcp_wmem='1024 4096 16384'
sysctl -w net.core.rmem_max=16384
sysctl -w net.core.wmem_max=16384
wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb