Skip to content

Instantly share code, notes, and snippets.

@schaitanya
schaitanya / cheat_sheet.org.sh
Last active July 11, 2016 22:02
Linux Cheat Sheet
# From https://github.com/WilliamHackmore/linuxgems
# cheat_sheet.org
# (C) William Hackmore, 2010
# The contents of this file are released under the GNU General Public License. Feel free to reuse the contents of this work, as long as the resultant works give proper attribution and are made publicly available under the GNU General Public License.
# Last updated 8/14/2012
# Best viewed in emacs org-mode.
* Command Reference:
** Basics:
*** Getting help:

OSX (built in)

list the directories in the current directory
ls -d */
get or set kernel state
sysctl
TCP window scale option
sysctl net.inet.tcp.rfc1323
shows date in historyfile
export HISTTIMEFORMAT="%h/%d - %H:%M:%S "
show wan-ip

#!/bin/sh
host=localhost:9200
curl -X DELETE "${host}/test"
curl -X PUT "${host}/test" -d '{
"settings" : { "index" : { "number_of_shards" : 1, "number_of_replicas" : 0 }}
}'
@schaitanya
schaitanya / package.json
Last active December 17, 2015 15:10
Create backup, and re-index elastic search data with scan and scroll
{
"name": "re-index",
"version": "0.0.1",
"description": "Create backup, and re-index elastic search data with scan and scroll",
"main": "re-index.coffee",
"author": "Chaitanya Surapaneni",
"license": "MIT",
"dependencies": {
"request": "~2.21.0",
"async": "~0.2.8",
{
"query": {
"custom_filters_score": {
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"field": {
@schaitanya
schaitanya / asyc.coffee
Created September 13, 2013 16:24
Async whilst
@loop: (method, data, callback) ->
results = []
data.pageNumber ?= 1
@[method] data, (err, res) =>
# totalResults = res?.totalNumberOfElements
# numberOfElements = res?.numberOfElements
totalPages = parseInt(res[0]?.result?.totalPages)
results.push res[0]?.result?.resultSet
async.whilst ->
return data.pageNumber isnt totalPages
request = require 'request'
async = require 'async'
url = "http://letsrevolutionizetesting.com/challenge.json"
id = null
message = null
async.whilst ->
not message?
, (callback) ->
oUurl = url

Awesome PHP

A curated list of amazingly awesome PHP libraries, resources and shiny things.

Composer

Composer Related

I agree the point you’re making here, 100%. However, a slight correction about Node’s APIs.

First of all, process.nextTick is actually first in, first out. Proof:

$ node -e 'process.nextTick(console.log.bind(console, 1)); process.nextTick(console.log.bind(console, 2))'
1
2
@schaitanya
schaitanya / better-nodejs-require-paths.md
Created March 3, 2017 20:20 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions