Skip to content

Instantly share code, notes, and snippets.

View sawantuday's full-sized avatar

Uday R Sawant sawantuday

  • J.P. Morgan Chase & Co
  • India
View GitHub Profile
@sawantuday
sawantuday / simple-php-crawler.php
Last active August 29, 2015 14:25 — forked from ScottPhillips/simple-php-crawler.php
Simple PHP Crawleer
<?php
function crawl_page($url, $depth = 5)
{
static $seen = array();
if (isset($seen[$url]) || $depth === 0) {
return;
}
$seen[$url] = true;
@sawantuday
sawantuday / bling.js
Last active August 29, 2015 14:26 — forked from paulirish/bling.js
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@sawantuday
sawantuday / plot.p
Last active August 29, 2015 14:27 — forked from garethrees/plot.p
Graphing apache benchmark results with gnuplot
# Output to a jpeg file
set terminal jpeg size 1280,720
# Set the aspect ratio of the graph
set size 1, 1
# The file to write to
set output "timeseries.jpg"
# The graph title
@sawantuday
sawantuday / dovecot-10-auth.conf
Last active August 29, 2015 14:27 — forked from barryo/dovecot-10-auth.conf
Configuration Files for ViMbAdmin on Ubuntu 13.10 with Dovecot and Postfix - referenced from https://github.com/opensolutions/ViMbAdmin3/wiki/Mail-System-Install-on-Ubuntu
auth_mechanisms = plain login digest-md5 cram-md5 ntlm apop
!include auth-sql.conf.ext
@sawantuday
sawantuday / preprocessor_fun.h
Last active August 29, 2015 14:27 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@sawantuday
sawantuday / on-demand-resize.php
Last active September 3, 2015 12:13 — forked from janfabry/on-demand-resize.php
WordPress On-Demand image resizer plugin (first public attempt)
<?php
/*
Plugin Name: On-Demand image resizer
Plugin URI: http://www.monkeyman.be
Description: Create and store images in different sizes on demand
Version: 1.0
Author: Jan Fabry
This plugins monitors 404 requests to the uploads directory and created new images of a requested size. They are saved as new files in the upload directory, not cached somewhere, so future requests are served directly by the server. This allows you to eliminate the creation of intermediate image sizes [see monkeyman-virtual-intermediate-images] or resize images based on the size used in the editor [see monkeyman-resize-image-tags].
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.api.ops.BaseAccumulation;
import org.nd4j.linalg.api.ops.impl.accum.distances.EuclideanDistance;
import org.nd4j.linalg.dataset.api.DataSet;
import org.nd4j.linalg.factory.Nd4j;
/**
* Requires RC1<br/>
* This is a sample implementation of K-Nearest Neighbor. KNN doesn't create a latent/hidden model, nor does it train. It simply uses it's dataset as a look up table.
* Then grabs the closest k data point/records. From there it is able to look at the labels for the K nearest neighbors and make a decision on what label to predict the incoming
@sawantuday
sawantuday / tsws
Last active September 6, 2015 18:12 — forked from dfletcher/tsws
Totally simple web server using Bash and netcat (nc)
#!/bin/bash
# --------------------------------
# Totally Simple Web Server (TSWS)
# --------------------------------
#
# (c) 2015 Dave Fletcher
# All Rights Reserved
#
# This is free and unencumbered software released into the public domain.
@sawantuday
sawantuday / percona-sysbench-test.sh
Created January 24, 2016 12:37 — forked from chetan/percona-sysbench-test.sh
percona sysbench script
#!/bin/sh
# script for batch running sysbench I/O tests for mysql workload
# http://www.mysqlperformanceblog.com/2009/08/06/ec2ebs-single-and-raid-volumes-io-bencmark/
set -u
set -x
set -e
for size in 256M 16G; do
@sawantuday
sawantuday / dom-filter.js
Created February 4, 2016 06:36 — forked from archagon/dom-filter.js
The start of a generic DOM filtering bookmarklet, along with sample code. Useful if a website's filters aren't specific enough. SEL is the selector for the main list item and COND is a filtering function that you can customize.
var PRINT = false;
var LOG = 1;
var SEL = ".pin";
var COND = function($node) {
var ret = true;
ret = checkNum($node, ".pinPrice", ">=", 10);
if (!ret) { return false; }