Skip to content

Instantly share code, notes, and snippets.

View shakirullahi's full-sized avatar
🔆
hakuna matata

Sakirullahi Puthenchirakkal shakirullahi

🔆
hakuna matata
View GitHub Profile
/**
* r-proto-class.js
* Ruby's semantics
*
* Features:
* - super calls
* - using Object.create for inheritance
* - Class.new is a wrapper over Class.allocate and Class.initialize
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
angular.module('waitForAuth', [])
/**
* A service that returns a promise object, which is resolved once angularFireAuth
* is initialized (i.e. it returns login, logout, or error)
*/
.service('waitForAuth', function($rootScope, $q, $timeout) {
var def = $q.defer(), subs = [];
subs.push($rootScope.$on('angularFireAuth:login', fn));
subs.push($rootScope.$on('angularFireAuth:logout', fn));
// pros: does not fetch entire record set
// cons: grabs the last record which needs to be ignored
var first = true;
var ref = new Firebase(...);
ref.endAt().limit(1).on("child_added", function(snap) {
if( first ) {
first = false;
}
else {
console.log('new record', snap.val());
@shakirullahi
shakirullahi / gist:8093974
Created December 23, 2013 09:22
Setting priority while pushing in firebase //credit:kato
var ref = new Firebase('https://<example>.firebaseio.com/rewards').push();
ref.setWithPriority({
name: 'apple',
otherKey: 'somevalue',
...
}, 'apple', function(err) {
if( error ) { console.error(err); }
else {
fetchValue();
@shakirullahi
shakirullahi / detectIE
Created February 1, 2014 02:13
Detecting IE in javascript
//Return IE version or if not IE return false
function isIE () {
var myNav = navigator.userAgent.toLowerCase();
return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;
}
//Example:
if (isIE () == 8) {
@shakirullahi
shakirullahi / gist:8764646
Created February 2, 2014 08:16
jquery slector for input value
http://stackoverflow.com/questions/5060652/jquery-selector-for-input-value
#!/bin/bash
# change docRoot
docRoot=~/src/shakir/
for semester in */;
do
semester="${semester%?}"
cd "$docRoot/$semester/"
for branch in */;
adb logcat | grep `adb shell ps | grep com.app.package | cut -c10-15`
@shakirullahi
shakirullahi / exp.html
Last active July 15, 2016 19:05
Experience calculator : create a html file and put this code and run
<input type="text" id="from" placeholder="Starting date dd-mm-yyyy">
<input type="text" id="to" placeholder="Ending date dd-mm-yyyy">
<button onclick="calculate()">Calculate</button>
<script>
function calculate(){
var from = document.getElementById('from').value;
var to = document.getElementById('to').value;
from = from.split('-');
var from_day = parseInt(from[0]);
@shakirullahi
shakirullahi / verify.php
Created July 16, 2016 11:08
e-treasury : Verification defacement
<?php
$url = 'http://103.251.43.79/echallan/challan/models/frmgrnverificationdefacement.php';
$myvars = 'GRN=KL000001500201415E&USERID=abc';
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);