Skip to content

Instantly share code, notes, and snippets.

@seifsallam
seifsallam / authentication_initializer.coffee
Created February 17, 2014 10:49
Authentication initializer using ember-simple-auth — https://github.com/simplabs/ember-simple-auth/
###*
* Authentication Initializer
###
Authorizer = Ember.SimpleAuth.Authorizers.Base.extend(
authorize: (jqXHR, requestOptions) ->
unless Ember.isEmpty @get('session.auth_token')
jqXHR.setRequestHeader 'x-authentication-token', @get('session.auth_token')
)
// A PromiseAction is an action set on the controller,
// but not in the actions hash, which allows it to be
// passed in directly to the component. The component
// just sees it as a function that it can call that
// returns a promise. This is nice for when the component
// needs to emit some action that can fail; if it fails
// it can clean up after itself.
// Example:
// export default Controller.extend({
@seifsallam
seifsallam / 0_reuse_code.js
Created June 3, 2014 13:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@seifsallam
seifsallam / Passwordless SSH.md
Last active December 18, 2015 12:39
login using SSH with no password

Login using SSH with no password

  1. Create or Copy Development machine's public RSA located ~/.ssh/id_rsa.pub
  2. Login to server and paste it in vim ~/.ssh/authorized_keys
  3. Ensure that /etc/ssh/sshd_config contains PubkeyAuthentication yes and RSAAuthentication yes uncommented
  4. Finally set chmod go-w ~/, chmod 700 ~/.ssh, and chmod 600 ~/.ssh/authorized_keys to make sure that permissions are set correctly
@seifsallam
seifsallam / Deployment Setup.md
Last active December 18, 2015 12:39
asknative server deployment setup

Deployment Setup

  1. Create user deployer added to root and www-data groups
  2. Setup github deploy keys. Guide
  3. Setup rbenv on deployer, install ruby 1.9.3 or 2.0, and bundler
  4. Install rbenv plugins rbenv-sudo, rbenv-rehash, and rbenv-vars
  5. Add Environment variables to rbevn vars,
  6. Install Nginx
  7. Comment # [ -z "$PS1" ] && return from bashrc, so using su - deployer in an non-interactive shell loads rbenv
  8. Fix locale problems by adding export LC_ALL="en_US.UTF-8" into ~/.bashrc
  9. Use sudo visudo append %deployer ALL=(ALL) ALL for allowing sudo command for group deployer, and deployer ALL=NOPASSWD: ALL no password for user deployer
@seifsallam
seifsallam / asknative gems.md
Last active December 18, 2015 12:39
Gems used for asknative's Ruby on Rails API

Gemfile

  • Mongoid for mongodb communication
  • Devise for authentication and oAuth
  • Active Model Serializer for JSON formatting. Alot cleaner and faster than hash views solutions like RABL
  • Api versions for versioning API
  • Sidekiq for background jobs. Awesome dashboard and alot easier (with less bugs) than resque
  • HTTParty for sending push notifications to pushbots
  • SendGrid for sending emails
  • LetterOpener for viewing emails in the browser (Development)
  • Roadie for compiling css to be inline for emails
@seifsallam
seifsallam / Default (OSX).sublime-keymap.json
Last active December 18, 2015 12:49
SublimeText 2 Configuration
[
{
"keys": ["ctrl+shift+t"],
"command": "delete_trailing_spaces"
},
{
"keys": ["ctrl+shift+d"],
"command": "toggle_trailing_spaces"
},
{
@seifsallam
seifsallam / Moving from ember-rails to Yeoman.md
Last active December 18, 2015 14:39
If you were using ember-rails and want to move it out to its own app. Here are the steps using Yeoman

Using Yo Ember instead of Ember-Rails

First Generate Ember application using Yo Ember generator

  1. Install yeoman npm install -g yo grunt-cli bower
  2. Install ember-generator npm install -g generator-ember
  3. Create your project mkdir webapp && cd webapp
  4. Generate ember template yo ember
  5. Run itgrunt server
@seifsallam
seifsallam / Deploying Ember on heroku.md
Last active December 18, 2015 14:48
Deploying ember on heroku using yeoman

Deploying Ember on Heroku using Yeoman

  1. I'm going to assume here that you have an ember application ready that you want to deploy.
  2. Install Generator Heroku using the steps there, and don't forget to add the block of code to your gruntfile.js. You should find the copy tag already there, just append to it
  3. The run grunt build command to generate the /dist folder. That will complie everything and generate your web-app
  4. If you want you can test it using grunt server:dist
  5. Now go to /dist folder
  6. Create a heroku app heroku create
  7. Commit everything in the dist folder (Don't go up to your root direcotry, you want to commit update to heroku) I used github to add local repo and manage everything from there.
@seifsallam
seifsallam / .bashrc
Last active December 19, 2015 10:29 — forked from joequery/gist:1607063
Enable disable a Nginx configuration from `/sites-available`
##
## NGINX helpers
##
# Kill and restart nginx
function restart_nginx(){
pids=$(pidof nginx)
if [[ -n $pids ]];
then
sudo kill -9 $pids