Skip to content

Instantly share code, notes, and snippets.

@ktkaushik
ktkaushik / cmd.sh
Created June 22, 2016 10:03 — forked from kelvinn/cmd.sh
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/
@ktkaushik
ktkaushik / Gruntfile.js
Last active January 21, 2016 04:53
primary grunt file
/**
*
*/
module.exports = function(grunt) {
var timestamp = new Date().getTime() + '';
var pkg = grunt.file.readJSON('package.json');
// 1. All configuration goes here
@ktkaushik
ktkaushik / splitTextAmongNodes.js
Created January 13, 2016 11:25
Split text among nodes in POJS.
var node = Util.getSelectionStart()
var text = p.childNodes[0];
var at = 5;
// create new span node with content
var span = document.createElement("span");
span.appendChild(document.createTextNode('ipsum'));
// Split the text node into two and add new span
p.insertBefore(span, text.splitText(at));
@ktkaushik
ktkaushik / index.html
Created September 5, 2015 06:43
zvxmwE
<svg xmlns="SVG namespace" width="600" height="250">
<g stroke-width="16" fill="none">
<path d="M173 102a51 51 0 1 1-13-30m20 37h-53" stroke="#4a87ee"/>
<circle cx="227" cy="128" r="32" stroke="#d83038"/>
<circle cx="313" cy="128" r="32" stroke="#f4c022"/>
<path d="M401 160a31 31 0 1 1 0-61m-4 0a24 29 0 1 1 0 61m26-67v79m-1-12a20 20 0 1 1-52 17" stroke="#4a87ee"/>
<path stroke="#4ab95a" d="M449 51v115"/>
<path d="M529 118a30 30 0 1 0-2 24m5-32l-62 28" stroke="#d83038"/>
</g>
@ktkaushik
ktkaushik / redis.sh
Created June 25, 2015 12:09
LUA Eval script to Delete/Expire multiple keys in Redis
EVAL "for i, name in ipairs(redis.call('KEYS', 'author_*')) do redis.call('expire', name, 0); end" 0
@ktkaushik
ktkaushik / spineModel.js
Created April 1, 2015 08:15
A simple Model
/*
var model = new BackboneModel({
key : value
})
model.add("key", "value")
model.listen("key", function(){
})
*/
@ktkaushik
ktkaushik / bash_profile.sh
Created January 15, 2015 10:18
bash profile file
source ~/.bash_settings/.paths
#export PATH="/usr/local/Cellar/postgresql/9.2.3/bin/:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
source ~/.bash_settings/.bash_pretty
source ~/.bash_settings/.aliases
# {{{
# Node Completion - Auto-generated, do not touch.
@ktkaushik
ktkaushik / error.js
Created April 3, 2014 22:13
socket parse error nodejs
events.js:72
throw er; // Unhandled 'error' event
^
Error: Parse Error
at Socket.socketOnData (http.js:1583:20)
at TCP.onread (net.js:525:27)
4 Apr 03:41:51 - [nodemon] app crashed - waiting for file changes before starting...
@ktkaushik
ktkaushik / feed.js
Created February 20, 2014 12:23
admin feed.js
posts.adminFeed = function(req, res, next) {
var perPage = 10
, page = req.params.page > 0 ? req.params.page : 0;
console.log("looking for admin feed ************************");
var query = req.query.from;
Post
.find(req.query)
@ktkaushik
ktkaushik / homeController.js
Created January 24, 2014 20:15
filters in rendr controller
/**
*
*/
var _ = require('underscore')
, async = require('async');
function originalFilter(actionHandler) {
return function () {
actionHandler.apply(this, arguments);