Skip to content

Instantly share code, notes, and snippets.

View khalilgharbaoui's full-sized avatar
🎯
Focusing

Khalil Gharbaoui khalilgharbaoui

🎯
Focusing
View GitHub Profile
@khalilgharbaoui
khalilgharbaoui / form_submit.js
Created June 29, 2016 00:02 — forked from lingceng/form_submit.js
JavaScript request like a form submit
// http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit
// form_submit('/contact/', {name: 'Johnny Bravo'});
function form_submit(path, params, method) {
method = method || "post"; // Set method to post by default if not specified.
// The rest of this code assumes you are not using a library.
// It can be made less wordy if you use one.
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
@khalilgharbaoui
khalilgharbaoui / DragonFireCubes.js
Created July 18, 2016 01:25
RiftSketch - Dragon Fire Cubes - Tree.js
var t3 = THREE;
var light = new t3.PointLight();
light.position.set(20, 10, 10);
scene.add(light);
var makeCube = function(x, y, z) {
var cube = new t3.Mesh(
@khalilgharbaoui
khalilgharbaoui / ActionMailer-and-Sidekiq-Redis.md
Last active October 22, 2016 10:35 — forked from maxivak/00.md
Sending emails with ActionMailer and Sidekiq

Sending emails with ActionMailer and Sidekiq

Send email asynchroniously using Sidekiq.

ActionMailer

Create your mailer us usual:

@khalilgharbaoui
khalilgharbaoui / Dockerfile
Created October 23, 2016 12:16 — forked from yefim/Dockerrun.aws.json
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
# Example Dockerfile
FROM hello-world
# shortform git commands
alias g='git'
# push changes to an empty git repository for the first time
git push --set-upstream origin master
# remove untracked files in a git repository
git status -su | cut -d' ' -f2- | tr '\n' '\0' | xargs -0 rm
# get most modified files and counts
@khalilgharbaoui
khalilgharbaoui / alias_matchers.md
Created April 23, 2018 02:33 — forked from JunichiIto/alias_matchers.md
List of alias matchers in RSpec 3

This list is based on aliases_spec.rb.

You can see also Module: RSpec::Matchers API.

matcher aliased to description
a_truthy_value be_truthy a truthy value
a_falsey_value be_falsey a falsey value
be_falsy be_falsey be falsy
a_falsy_value be_falsey a falsy value
@khalilgharbaoui
khalilgharbaoui / validate_with_matcher.rb
Last active May 20, 2018 18:55 — forked from pcrglennon/validate_with_matcher.rb
RSpec matcher for validates_with
# RSpec matcher for validates_with.
# https://gist.github.com/2032846
# Usage:
#
# describe User do
# it { should validate_with CustomValidator }
# end
#
# describe User do
# it do
@khalilgharbaoui
khalilgharbaoui / swiss locales for faker
Last active May 20, 2018 22:52
swiss locals: cities, postal codes, phone numbers
de:
faker:
locales:
locale: [de, en, fr]
salutations:
de: [Herr, Frau]
en: [Mr, Mrs]
fr: [M., Mme]
address:
country_code: [CH, CH, CH, DE, AT, US, LI, US, HK, VN]
  1. Add gem 'rails_12factor' to your Gemfile. This will add error logging and the ability for your app to serve static assets.
  2. bundle
  3. Run RAILS_ENV=production rake db:create db:migrate db:seed
  4. Run rake secret and copy the output
  5. From the command line: export SECRET_KEY_BASE=output-of-rake-secret
  6. To precompile your assets, run rake assets:precompile. This will create a folder public/assets that contains all of your assets.
  7. Run RAILS_ENV=production rails s and you should see your app.

Remember to clobber your assets (rake assets:clobber) and re-precompile (rake assets:precompile) if you make changes.

@khalilgharbaoui
khalilgharbaoui / delay_worker.rb
Created October 23, 2018 00:36 — forked from dwkoogt/delay_worker.rb
Delay worker with delay handler and Rails adapter for Sneakers
#
# enqueue with following parameters hash:
# - headers
# - work_at - time of execution
# - work_queue - destination queue for actually doing the work
#
class DelayWorker
include Sneakers::Worker
from_queue :treadmill, { handler: Sneakers::Handlers::Delay }