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 / Phantom_renderer.js
Created April 26, 2016 11:02
Another approach for dynamic waiting timeouts to allow the page to fully load before rendering. Instead of waiting fixed amount of time before rendering, It give a short time for the page to make additional requests.
// PhantomJS script
// Takes screeshot of a given page. This correctly handles pages which
// dynamically load content making AJAX requests.
// Instead of waiting fixed amount of time before rendering, we give a short
// time for the page to make additional requests.
// Origin https://github.com/kimmobrunfeldt/url-to-image/blob/master/src/url-to-image.js
// Phantom internals
@sawantuday
sawantuday / Phantom_server.js
Created April 25, 2016 16:40
PhantomJS based web server which accepts URL and return parsed html document. Use parameter href=url to pass in url.
var system = require("system")
var webserver = require("webserver")
var webpage = require("webpage")
var port = '8001';
var blockedRes = [
"google-analytics.com",
"api.mixpanel.com",
"fonts.googleapis.com",
"stats.g.doubleclick.net",
"mc.yandex.ru",
@sawantuday
sawantuday / ReclaimSpace.sql
Created April 25, 2016 16:16
Reclaim unused space from large partitioned MySQL tables.
create table tempUrls like urls;
insert into tempUrls;
select * from urls where id < 100;
delete from urls where id < 100 limit 50;
alter table urls REBUILD PARTITION p000;
alter table urls ANALYZE PARTITION p000;
insert ignore into urls select * from tempUrls;
drop table tempUrls;
@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; }
@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 / 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.
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 / 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].
@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 / 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