Skip to content

Instantly share code, notes, and snippets.

View musaid's full-sized avatar
🏠
Working from home

musaid musaid

🏠
Working from home
View GitHub Profile
@musaid
musaid / .vimrc
Last active August 29, 2015 13:57 — forked from JeffreyWay/.vimrc
" execute pathogen plugins
execute pathogen#infect()
syntax on
filetype plugin indent on
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
@musaid
musaid / add-delete-ubuntu-user.sh
Created February 24, 2014 10:50
Add/Delete Ubuntu users.
# to add a new user (fill in the details as prompted)
sudo adduser username
# grant root priviledges to a user
sudo /usr/sbin/visudo
# add this after the line that says "root ALL=(ALL:ALL) ALL"
username ALL=(ALL:ALL) ALL
# if you want to change the password later
@musaid
musaid / bypass-amazon-pem.sh
Created February 24, 2014 10:46
Commands to bypass PEM usage in newly created AWS EC2 instances.
# Turn on password authentication
sudo sed -i ‘s/^PasswordAuthentication.*/PasswordAuthentication yes/’ /etc/ssh/sshd_config
# Reload SSH/SSHd configuration
sudo service ssh reload
# Set a password for the ubuntu (for ubuntu instances, otherwise use the default username for that instance type)
sudo passwd ubuntu
@musaid
musaid / cors.php
Created January 14, 2014 23:00
CORS Helpers
/**
* An example CORS-compliant method. It will allow any GET, POST, or OPTIONS requests from any
* origin.
*
* In a production environment, you probably want to be more restrictive, but this gives you
* the general idea of what is involved. For the nitty-gritty low-down, read:
*
* - https://developer.mozilla.org/en/HTTP_access_control
* - http://www.w3.org/TR/cors/
*
var DEBUG_MODE = true; // Set this value to false for production
if(typeof(console) === 'undefined') {
console = {}
}
if(!DEBUG_MODE || typeof(console.log) === 'undefined') {
// FYI: Firebug might get cranky...
console.log = console.error = console.info = console.debug = console.warn = console.trace = console.dir = console.dirxml = console.group = console.groupEnd = console.time = console.timeEnd = console.assert = console.profile = function() {};
}
@musaid
musaid / model.js
Last active December 21, 2015 05:39
A utility function to detect changes in input fields and update them on the Backbone Model associated with the view. Model attributes are decided upon the name of the fields. If you want to chain the attributes, i.e. include objects as attributes, use square brackets as specified.
// rest of the model specs
// ...
/**
* Save the changes to the model on input change.
*
* USAGE: events: { "change input, select, checkbox, textarea": "changed" }
*
* LICENSE: This function is subject to version 3 of the GNU General
* Public License that is available through the world-wide-web at the
* following URI: http://opensource.org/licenses/gpl-3.0.html. If you

This is a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

For example, process typeahead list asynchronously and return objects

  # This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function
    source: (typeahead, query) ->
 # this function receives the typeahead object and the query string
@musaid
musaid / extend-sample-input.html
Created August 17, 2013 04:11
extending Backbone.Validation library to use with Bootstrap/Flatstrap
<!-- Full Name -->
<div class="control-group">
<label class="control-label" for="name">Full Name</label>
<div class="controls">
<div class="input-prepend">
<span class="add-on">
<i class="icon-certificate"></i>
</span>
<input id="name" name="clients[name]" type="text" class="input" placeholder="Allied Insurance" data-error-style="inline">
</div>
_.extend Backbone.Validation.callbacks,
valid: (view, attr, selector) ->
control = view.$('[' + selector + '=' + attr + ']')
group = control.parents(".control-group")
group.removeClass("error")
if control.data("error-style") == "tooltip"
# CAUTION: calling tooltip("hide") on an uninitialized tooltip
# causes bootstraps tooltips to crash somehow...
control.tooltip "hide" if control.data("tooltip")
namespace.views.MyWizard = Backbone.Views.extend({
initialize: function() {
_.bindAll(this, 'render', 'wizardMethod');
}
render: function() {
this.wizardMethod();
return this;
},