Skip to content

Instantly share code, notes, and snippets.

View amireh's full-sized avatar

Ahmad Amireh amireh

View GitHub Profile
/usr/local/pgsql-9.3/bin/pg_ctl -s -D ${PGDATA} start -w -t 120 -o "-p $PGPORT -k /run/postgresql-9.3"
@amireh
amireh / karma-electron-bidi.conf.js
Created April 22, 2017 11:17
Example of how to set up a testing environment for Electron backend (main) and front-end (renderer) modules with 1) source files being processed by Webpack 2) tests run by Mocha 3) tests launched by Karma.
const path = require('path');
module.exports = function (config) {
config.set({
plugins: [
'karma-electron',
'karma-mocha',
'karma-spec-reporter',
'karma-sourcemap-loader',
'karma-webpack',
@amireh
amireh / ManualRSVPQueue.js
Created October 27, 2015 14:51
Shows how to build a controllable RSVP promise queue that you can flush at any point to run all pending Promise callbacks.
// This code assumes you're not using any module loader, and that
// Ember is available on `window`. Tune accordingly if you are
// using a module loader.
var Ember = window.Ember;
var RSVP = Ember.RSVP;
var Backburner;
var queue; // our backburner queue
// here we tell RSVP to let us queue the promise callbacks
const assign = require('utils/assign');
/**
* @private
*
* Attach a "mutator" to a component's `props` object, allowing setting of
* dynamic properties that will persist through the component's lifecycle hooks.
*
* This is useful if you want to achieve the effect of calling #setProps()
* directly on an element even though you might not be able to if it's not the
@amireh
amireh / async-props.md
Last active August 29, 2015 14:19
Different approaches to resolve remote (or "async") props and inject them into React components.

This bit is shared among all approaches, the actual prop definition.

var Actions = require('actions');
var CourseStore = require('stores/CourseStore');

var asyncProps = {
  course: {
    // We load the course from a remote backend and trigger a redirect to
    // a different page if the resource was not found.
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
require "bundler/setup"
load Gem.bin_path("bridge_cli", "bridge_cli")
rescue LoadError
# no spring, we'll run the command directly
@amireh
amireh / canvas-backbone-deps.js
Created August 23, 2014 08:37
This script shows the dependencies we need to pull in to use the extended version of Backbone Canvas defines.
requirejs.config({
map: {
'canvas/Backbone': {
'vendor/backbone': 'canvas/vendor/backbone',
'compiled/backbone-ext/Backbone.syncWithMultipart': 'canvas/compiled/backbone-ext/Backbone.syncWithMultipart',
'compiled/backbone-ext/View': 'canvas/compiled/backbone-ext/View',
'compiled/backbone-ext/Model': 'canvas/compiled/backbone-ext/Model',
'compiled/backbone-ext/Collection': 'canvas/compiled/backbone-ext/Collection',
},
@amireh
amireh / quirky_interpreter_spec.rb
Created December 19, 2013 12:25
Really weird interpreter issue going on with ruby 1.9.3 and rspec 1.3.2. In the first spec, the call to `expect({}).to()` is not receiving the `raise_error()` as an argument since it's on a second line, and I don't know what it's taking for an argument. If we move the `to` directive down to the `raise_error` line as in spec#2, it works!
describe 'Smelly RSpec 1.3.2' do
it "should fail, but doesn't" do
# this will pass, even though it should fail
expect { raise ArgumentError, 'bar' }.to
raise_error(ArgumentError, /foo/i)
end
it "should fail, and it does" do
# and this would work -.-'
expect { raise ArgumentError, 'bar' }.
@amireh
amireh / student_session_alert_view.js
Created February 18, 2013 17:50
some modal i'd like to use in a view
define [
'jquery'
'underscore'
'Backbone'
'views/BaseDialogView'
], (I18n, $, _, Backbone, BaseDialogView) ->
class StudentSessionAlertView extends BaseDialogView
initialize: ->
@amireh
amireh / gerrit-push.sh
Last active December 12, 2015 05:48
pushing to gerrit hangs
$ git push -v origin HEAD:refs/for/master/docs
Pushing to ssh://[email protected]:29418/canvas-lms
Counting objects: 42, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (26/26), 4.46 KiB, done.
Total 26 (delta 9), reused 0 (delta 0)
Write failed: Broken pipe
fatal: The remote end hung up unexpectedly
fatal: recursion detected in die handler