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 / updatejs.sh
Created May 28, 2013 07:17
Updates the frequently used javascript files for a backbone application and creates an app.js file.
#!/bin/bash
# ------------------------------------------------------------
# Bash script to download the latest versions of the
# frequently used javascript libraries
#
# - /jquery/jquery.js|jquery.min.js
# - /backbone/backbone.js|backbone.min.js
# - /underscore/underscore.js|underscore.min.js
#
@musaid
musaid / MySQLAuthAdapter.php
Last active December 18, 2015 03:38
Zend Auth Adapter for local db of TRay
<?php
use \Doctrine\ORM;
class RayTemp_Auth_MySQLAuthAdapter implements Zend_Auth_Adapter_Interface {
private $username;
private $password;
public function __construct($username, $password) {
$this->username = $username;
$this->password = $password;
// includes bindings for fetching/fetched
PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
this.page = 1;
},
fetch: function(options) {
options || (options = {});
this.trigger("fetching");
@musaid
musaid / require-bootstrap.js
Created July 18, 2013 03:42
Include bootstap files using require js
requirejs.config({
appDir: ".",
baseUrl: "js",
paths: {
/* Load jquery from google cdn. On fail, load local file. */
'jquery': ['//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min', 'libs/jquery-min'],
/* Load bootstrap from cdn. On fail, load local file. */
'bootstrap': ['//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min', 'libs/bootstrap-min']
},
shim: {
@musaid
musaid / login.php
Last active October 21, 2023 16:23
Slim Login :: A crude example
<?php
require 'vendor/autoload.php';
$app = new \Slim\Slim();
$app->add(new \Slim\Middleware\SessionCookie(array('secret' => 'myappsecret')));
$authenticate = function ($app) {
return function () use ($app) {
if (!isset($_SESSION['user'])) {
@musaid
musaid / output.php
Created August 11, 2013 07:04
Fix TCPDF Output Error
public function Output($name = '', $dest = false) {
// close the pdf and clean up
$this->_cleanUp();
// if on debug mode
if ($this->_debugActif) {
$this->_DEBUG_add('Before output';);
$this->pdf->Close();
exit;
}
namespace.views.MyWizard = Backbone.Views.extend({
initialize: function() {
_.bindAll(this, 'render', 'wizardMethod');
}
render: function() {
this.wizardMethod();
return this;
},
_.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")
@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>

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