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 / update.txt
Created March 28, 2017 14:17
Update PHP to 7.1 on mac os 10.11
brew update
brew unlink php55
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install php71 --with-httpd24
brew install php71-memcached
brew install php71-tidy
@sawantuday
sawantuday / APAI_Webtask.js
Created March 25, 2017 16:10
Webtask module for Amazon Products API
module.exports = function (cb) {
var amazon = require('amazon-product-api');
var client = amazon.createClient({
awsId: "Affiliate ID",
awsSecret: "AWS Secret",
awsTag: "affiliate-tag",
locale: "IN"
});
client.itemLookup({

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@sawantuday
sawantuday / SharedMemory.php
Last active January 13, 2017 14:08
A simple wrapper around PHP shm_* functions with semaphores. Any data structure that supports serialisation can be stored in shared memory and accessed across two or more processes.
<?php
class SharedMemory {
private $shmID;
private $semaphoreID;
public function __construct($token, $memSize=10000){
$this->shmID = shm_attach($token, $memSize);
$this->semaphoreID = sem_get($token);
if($this->shmID === false){
error_log("Failed to create shared memory segment");
@sawantuday
sawantuday / iptables_rules.sh
Created December 5, 2016 09:58 — forked from virtualstaticvoid/iptables_rules.sh
25 Most Frequently Used Linux IPTables Rules Examples
# Modify this file accordingly for your specific requirement.
# http://www.thegeekstuff.com
# 1. Delete all existing rules
iptables -F
# 2. Set default chain policies
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
@sawantuday
sawantuday / Readme.md
Last active December 2, 2016 14:16
Selenium quick start with Python
  1. Create virtual environment and activate it (optional)
  2. install selenium with $ pip install selenium
  3. Download chrome driver (or geako for firefox or ghostdriver for phanotm)
  4. Use following code to get started
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
@sawantuday
sawantuday / udplb.py
Created November 16, 2016 15:24 — forked from obormot/udplb.py
Simple UDP load balancer
#!/usr/bin/env python
#------------------------------------------------------------------------------
# UDP Load Balancer featuring simple round robin with session affinity.
#------------------------------------------------------------------------------
import sys
import signal
import logging
from socket import *
@sawantuday
sawantuday / amazon.rb
Created November 4, 2016 14:55 — forked from upvalue/amazon.rb
Amazon affiliate filters for jekyll.
# amazon.rb - amazon affiliate links for jekyll
# assumes that you have a configuration variable called 'amazon_associate_id' with your associate id
# usage: {{ asin | amazon_product_href }}
# returns url of a product
# usage: {{ asin | amazon_image_href: 'M' }}
# returns image of the product, size argument can be S, M, or L, default M
# usage: {{ asin | amazon_product: 'A Product' }}
@sawantuday
sawantuday / angular-seo-server.js
Created September 23, 2016 10:36
PhantomJS script for Angular JS sites.
var system = require('system');
if (system.args.length < 3) {
console.log("Missing arguments.");
phantom.exit();
}
var server = require('webserver').create();
var port = parseInt(system.args[1]);
var urlPrefix = system.args[2];
@sawantuday
sawantuday / Syslog.php
Created September 22, 2016 12:58 — forked from coderofsalvation/Syslog.php
static php class for syslog-style logging to local syslogdaemon (native php), remote syslog server, or papertrailapp
/*
* PLEASE DO NOT USE THIS CODE, BUT GO TO: https://github.com/coderofsalvation/syslog-flexible
*/
// local, remote and papertrail compatible syslogclass
class Syslog{
public static $hostname = false;
public static $port = 514;
public static $program = "[]";