Skip to content

Instantly share code, notes, and snippets.

View snehesht's full-sized avatar

Snehesh snehesht

View GitHub Profile
@snehesht
snehesht / coro.py
Last active August 29, 2015 14:16 — forked from keis/coro.py
# Coroutines Demo using asyncio
import asyncio
@asyncio.coroutine
def waiting(r):
print("hello from waiting -", r)
yield from asyncio.sleep(2)
print("bye from waiting -", r)
return r
@snehesht
snehesht / Concurrent HTTP Requests with Python3 and asyncio
Last active October 20, 2020 19:00
Concurrent HTTP Requests with Python3 and asyncio
#http://geekgirl.io/concurrent-http-requests-with-python3-and-asyncio/
Concurrent HTTP Requests with Python3 and asyncio
My friend who is a data scientist had wipped up a script that made lots (over 27K) of queries to the Google Places API. The problem was that it was synchronous and thus took over 2.5hours to complete.
Given that I'm currently attending Hacker School and get to spend all day working on any coding problems that interests me, I decided to go about trying to optimise it.
I'm new to Python so had to do a bit of groundwork first to determine which course of action was best.
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* AES Counter-mode implementation in JavaScript (c) Chris Veness 2005-2014 / MIT Licence */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* jshint node:true *//* global define, escape, unescape, btoa, atob */
'use strict';
if (typeof module!='undefined' && module.exports) var Aes = require('./aes'); // CommonJS (Node.js)
/**
// Go to menue:
// find->find in files
// Switch on reg_ex button
// Find:
^(.*)$
// Where:
c:\your_folder\,*.php,*.phtml,*.js,*.inc,*.html, -*/folder_to_exclude/*
// Then click on the find button
// Be careful to not click on Replace!!!
@snehesht
snehesht / Nginx SSL Config.txt
Last active August 29, 2015 14:18
Nginx SSL Config
Optimizing HTTPS on Nginx https://bjornjohansen.no/optimizing-https-nginx
Now that you have secured Nginx with HTTPS and enabled SPDY, it’s time to improve both the security and the performance of the server.
Nginx out-of-the-box is already performing quite well, and as far as I know, is the only web server with forward secrecy (FS) enabled by default (more on FS support in servers and clients here). There is still a few things we can configure to make Nginx faster and more secure.
NOTE: All of the configuration directives explained here will be for your server block in your Nginx config.
Step 1: Connection credentials caching
@snehesht
snehesht / gist:ab1f9279bd61cebd5a81
Created April 6, 2015 18:16
proxy loadbalancing
Src : http://stackoverflow.com/questions/17590816/kernel-based-linux-data-relay-between-two-tcp-sockets
# With Nginx
TCP Connections load-balancing
# With HAProxy
Using Linux TCP Splicing with HAProxy
Willy Tarreau <w@1wt.eu>
- 2007/01/06 -
#!/usr/bin/python
import sys #for cmd line argv
#take command line args as the input string
input_string = sys.argv
#remove the program name from the argv list
input_string.pop(0)
#convert to google friendly url (with + replacing spaces)
@snehesht
snehesht / Python logging for every day.txt
Last active August 29, 2015 14:20
Python logging for every day
http://www.lexev.org/en/2013/python-logging-every-day/
Python logging for every day
Gist
When writing a small python program or script, it is sometimes needed to output debug message or maybe event. It is known, that python has logging module exactly for that purpose. But in my case usually such thing happens: it is lack of time and hands just writes print instead of logging, because i can't remember all those complicated logging settings. But then, if script is launched often or i must provide it to customer, i have to replace all prints with logging, because it is better to log all messages to file. So, not to keep in my head all these settings, i am writing this post.
Logging requirements will be the following:
All logs must be written to file and in console (duplicated)
Log file is rotated (not exceed specified size)
All third party libraries logs are also handled
@snehesht
snehesht / arXiv popularity scoring.ipynb
Last active September 7, 2015 04:59 — forked from nebw/arXiv popularity scoring.ipynb
Popularity scoring for arXiv publications
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
https://github.com/SoftEtherVPN/SoftEtherVPN/
http://www.softether.org/
http://www.softether-download.com/files/softether/v4.18-9570-rtm-2015.07.26-tree/Linux/SoftEther_VPN_Server/32bit_-_ARM_EABI/
sudo apt-get install libreadline-dev libssl-dev
git clone https://github.com/SoftEtherVPN/SoftEtherVPN.git
cd SoftEtherVPN
./configure