Skip to content

Instantly share code, notes, and snippets.

View ganeshan's full-sized avatar

Ganeshan Venkataraman ganeshan

  • Sterling,MA
View GitHub Profile
@ganeshan
ganeshan / elasticsearchIndexing.py
Last active August 29, 2015 14:27 — forked from scottrice10/elasticsearchIndexing.py
Indexing health provider data listed in NPI database using Elasticsearch.
#!/usr/bin/env python2.7
import csv
from pyes import *
reader = csv.reader(open('npidata_20050523-20130811.csv', 'rb'))
conn = ES('localhost:9200', timeout=20.0)
counter = 0
for row in reader:
@ganeshan
ganeshan / README.md
Created December 21, 2015 14:42 — forked from joyrexus/README.md
form-data vs -urlencoded

Nice answer on stackoverflow to the question of when to use one or the other content-types for POSTing data, viz. application/x-www-form-urlencoded and multipart/form-data.

“The moral of the story is, if you have binary (non-alphanumeric) data (or a significantly sized payload) to transmit, use multipart/form-data. Otherwise, use application/x-www-form-urlencoded.”


Matt Bridges' answer in full:

The MIME types you mention are the two Content-Type headers for HTTP POST requests that user-agents (browsers) must support. The purpose of both of those types of requests is to send a list of name/value pairs to the server. Depending on the type and amount of data being transmitted, one of the methods will be more efficient than the other. To understand why, you have to look at what each is doing

@ganeshan
ganeshan / XMLSitemap.cshtml
Created March 15, 2016 23:54 — forked from alindgren/XMLSitemap.cshtml
XML sitemap for Umbraco 7 (based on Cultiv Search Engine Sitemap package). See http://www.alexlindgren.com/archive/dynamically-generated-xml-sitemaps-with-umbraco-7/
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using System.Linq;
@{
Layout = null;
Response.ContentType = "text/xml";
}<?xml version='1.0' encoding='UTF-8' ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemalocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
@ListChildNodes(Umbraco.TypedContent(UmbracoContext.Current.PageId).AncestorOrSelf(1))
@ganeshan
ganeshan / T4TS.tt
Created March 17, 2016 17:11 — forked from alexdresko/T4TS.tt
T4 template to generate TypeScript interface definitions with BreezeJS support.
<#@ template language="C#" debug="true" hostspecific="true" #>
<#@ output extension=".d.ts" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="Microsoft.VisualStudio.Shell.Interop.8.0" #>
<#@ assembly name="EnvDTE" #>
<#@ assembly name="EnvDTE80" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="EnvDTE" #>
@ganeshan
ganeshan / statsd.md
Created April 2, 2016 12:45 — forked from trusche/statsd.md
Installing graphite and statsd on OS X Yosemite

Prerequisites

  • Homebrew
  • Python 2.7
  • Git

Graphite

Install Cairo

There's an issue with cairo 14.x that results in the axis fonts on the graphs being HUUUUUGE. Downgrading to 12.6 helps:

@ganeshan
ganeshan / bkadb-data-gen.sh
Created October 20, 2016 21:44 — forked from cmerrick/bkadb-data-gen.sh
Better Know a Database - Redshift Load Data Formats
#!/bin/sh
# OS: Ubuntu 14.01
# Generate data - produces about 200GB on disk, takes a while
DATADIR=tpch-dbgen
SCALE=1000
git clone https://github.com/electrum/tpch-dbgen.git
cd $DATADIR && make && ./dbgen -f -v -C 16 -S 1 -s $SCALE && cd -
@ganeshan
ganeshan / app.js
Created November 19, 2016 23:54 — forked from rnkoaa/app.js
A simple angularjs with angular-ui modal form which includes validation on the client side. Thanks http://scotch.io/tutorials/javascript/angularjs-form-validation
var app = angular.module("modalFormApp", ['ui.bootstrap']);
app.controller("modalAccountFormController", ['$scope', '$modal', '$log',
function ($scope, $modal, $log) {
$scope.showForm = function () {
$scope.message = "Show Form Button Clicked";
console.log($scope.message);
var modalInstance = $modal.open({
PRINT N'Creating TwilightSparkle database'
CREATE DATABASE TwilightSparkle
GO
USE TwilightSparkle
GO
PRINT N'Creating TwilightSparkle objects:'
PRINT N'Creating [dbo].[tblTheSame]'
CREATE TABLE [dbo].[tblTheSame]
(
[Numbers] [int] NULL,
@ganeshan
ganeshan / gist:9083af5f8462cf0d9cd18562376b6f3e
Created December 12, 2016 10:38 — forked from mikeyk/gist:1329319
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@ganeshan
ganeshan / AuthorService.cs
Created December 18, 2016 13:10 — forked from mythz/AuthorService.cs
1 class in ServiceStack
/*
With no other C# or config other than OrmLite DB config in AppHost below - this web service provides all the screenshots attached, out-of-the-box, for free.
container.Register<IDbConnectionFactory>(
new OrmLiteConnectionFactory(ConfigUtils.GetConnectionString("AppDb"), //ConnectionString in Web.Config
SqlServerOrmLiteDialectProvider.Instance) {
ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current) });
-- Code-first Simplicity at Great Speed - http://www.servicestack.net/benchmarks/