Skip to content

Instantly share code, notes, and snippets.

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

Gaurav cggaurav

🏠
Working from home
View GitHub Profile
QQ = angular.module 'QQ', []
# Enables Angular 1.3.x-like $q functionality. Example:
# qq (resolve, reject, notify) ->
# obj = doSomething 'parameter', resolve, reject
# obj.onprogress = notify
QQ.factory 'qq', ($q) ->
qq = (fn) ->
deferred = $q.defer()
fn deferred.resolve, deferred.reject, deferred.notify
app-LxnSsOkFZMk1NCa6qHJOxw
@cggaurav
cggaurav / change_display.sh
Created February 17, 2012 10:04
Change Display
xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode VGA1 1920x1080_60.00
xrandr --output VGA1 --mode 1920x1080_60.00
@cggaurav
cggaurav / index.html
Created March 21, 2012 15:07 — forked from mbostock/README.md
Interactive Tree (D3)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Node-Link Tree</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.25.0"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?1.25.0"></script>
<style type="text/css">
circle.node {
@cggaurav
cggaurav / moveInput.js
Created October 7, 2015 17:12
Move Input with the cordova plugin
var moveInput = function(height) {
if (ionic.Platform.isAndroid()) {
// console.info('moveInput()', height, "Wait, what is $scope.keyboardHeight", $scope.keyboardHeight)
height = height || 0;
// if (height === 0) {
// document.getElementById('message-footer').setAttribute('style', 'margin-bottom: 0px;');
// document.getElementById('message-wrapper').setAttribute('style', 'height: auto');
// } else {
// document.getElementById('message-footer').setAttribute('style', ['margin-bottom: ', height.toString(), 'px;'].join(''));
// document.getElementById('message-wrapper').setAttribute('style', ['height: ', window.innerHeight - $scope.keyboardHeight - 90, 'px;'].join(''));
@cggaurav
cggaurav / README.markdown
Created September 9, 2012 04:01 — forked from gudbergur/README.markdown
Bootstrap's Typeahead plugin extended (allowing for AJAX functionality) among other things

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
@cggaurav
cggaurav / .powrc
Created October 11, 2012 16:56
PowRC configuration
if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".rvmrc" ]; then
source "$rvm_path/scripts/rvm"
source ".rvmrc"
fi
@cggaurav
cggaurav / threadscore.js
Created October 17, 2015 11:14
Age and Format
function calcAge(isodatestring) {
if (isodatestring)
return Math.round(new Date() - Date.parse(isodatestring)) / (24*60*60*1000);
return 0;
}
function formatAge(age) {
var ret2 = '';
var mins_ago = age * 24 * 60;
if (mins_ago <= 1) {
@cggaurav
cggaurav / chat.js
Created October 18, 2015 19:54
Everybody shuffling?
Chat.shuffle = function() {
_chatThreads.forEach(function(t) {
t.latest_snippet.created_at = (new Date().getTime()) + Math.random() * 1000000;
});
Chat.notifyThreadsChanged();
}