Skip to content

Instantly share code, notes, and snippets.

View kapv89's full-sized avatar

kapil verma kapv89

  • Bangalore, India
  • 13:43 (UTC +05:30)
View GitHub Profile
@kapv89
kapv89 / sandBox.js
Last active December 13, 2015 20:18
An untested concept of a sandbox for client side dev
// needs underscore and Backbone.Events( really didn't want to code that stuff up :P)
window.sandBoxFactory = function () {
var vent = _.extend({}, Backbone.Events); // The event aggregator for the sandbox
var communicatorEvents = [];
var broadCasters = {};
var sandBox = {
http://vimeo.com/53221560
http://vimeo.com/53221558
http://vimeo.com/49718712
http://www.youtube.com/watch?v=f6kdp27TYZs
@kapv89
kapv89 / oop.js
Last active December 17, 2015 00:29
OOP in JS without "this" and "new" shit
//class definition + constructor
function FooFactory(bar, baz) {
/* return an object with a set of properties and functionalities
tied together using closuers and lexical scoping */
}
// actual object construction
var foo = FooFactory(bar, baz);
//inheritance (via as many object as you want)
@kapv89
kapv89 / compound.py
Last active December 17, 2015 00:49
a simple script to calculate the total amount accumulated over a span of years at a given interest rate and an yearly instalment
"""
for a given instalment, interest, and number of years, calculate the compounded amount.
USAGE:
python compound.py instalment interest, years
"""
import sys
@kapv89
kapv89 / query-logger.php
Last active January 8, 2019 15:21
Log Queries in L4
<?php
Event::listen('illuminate.query', function($query, $bindings, $time) {
static $count;
if(App::make('env') === 'local')
{
$logFile = __DIR__.'/../storage/logs/queries';
ob_start();
var_dump($bindings, $query);
$str = ob_get_clean();
if($count === null)
@kapv89
kapv89 / gist:5656794
Last active December 17, 2015 18:59 — forked from whisher/gist:5656791
<?php
Route::get('/', function()
{
return View::make('home.index');
});
Route::controller('home');
@kapv89
kapv89 / gist:5684342
Last active December 17, 2015 22:48
Compile time error
public class Gen {
public static void main(String[] args) {
Foo<Integer> a = new Foo<Integer>(123);
// Baz b = new Baz("aha");
System.out.println(a.bar.toString());
// System.out.println(b.bar);
@kapv89
kapv89 / gist:5817622
Created June 19, 2013 20:11
a sample router
angular.module('sorter').config(function ($routeProvider, $locationProvider) {
// code fuplicated here, cos can't find a way to use custom service in config
var $uri = (function () {
var pageBase = '/admin/classification/sorter/app/', tmplBase = '/js/sorter/tmpls/',
apiBase = '/admin/classification/sorter/api/'
return {
page: function (uri) { return pageBase + uri; },
tmpl: function (uri) { return tmplBase + uri; },
api: function (uri) { return apiBase + uri; }
<div class="row sorter-container" ng-app="sorter" ng-controller="AppCtrl">
<div class="span10">
<div class="row">
<div class="span10">
<ul class="nav nav-pills">
<li ng-repeat="item in navItems" ng-class="item.isActive() && 'active' || ''">
<a href="{{item.uri}}">{{item.title}}</a>
</li>
</ul>
</div>
angular.module('sorter').controller('AppCtrl', function ($scope, $uri, $route, $location, $window) {
var navItem = function (slug) {
var item = {
title : slug[0].toUpperCase() + slug.slice(1),
slug : slug,
uri : $uri.page(slug)
};
item.isActive = function () {