Skip to content

Instantly share code, notes, and snippets.

View dineshsprabu's full-sized avatar

Dineshprabu S dineshsprabu

  • Bangalore, India.
View GitHub Profile
@dineshsprabu
dineshsprabu / docker.md
Last active October 24, 2017 14:09
[Docker] Useful docker commands

Docker commands

Creating building docker image. Create Dockerfile with below content. Run docker build -t <image-name> .

FROM steveny/predictionio
CMD ["python", "app.py"]
EXPOSE 8000

Running a docker with image. -i opens interactive shell.

@dineshsprabu
dineshsprabu / postgres_sql_commands.md
Created September 18, 2017 05:23
[POSTGRES][SQL] Useful Postgres Commands

Useful Postgres Commands

Listing users

\du

Creating new user(ROLE)

@dineshsprabu
dineshsprabu / form_submitted_arguments.py
Last active March 10, 2020 16:48
[Python][Tornado] Get all form submitted arguments and convert to dict
class Handler(tornado.web.RequestHandler):
def args_to_dict(self):
""" This method converts request arguments to
usable dict
"""
params = self.request.arguments
for k,v in params.items():
params[k] = v[0].decode("utf-8")
return params
@dineshsprabu
dineshsprabu / unix_commands_big_data.md
Last active September 7, 2017 14:26
[Unix] Useful Commands for Big Data

Useful Unix/Linux Commands for Big Data

Line count from a file or multiple files or any other stream.

cat input/*.csv | wc -l

Finding a particular string across files, on a directory.

@dineshsprabu
dineshsprabu / tornado_app_structure.md
Last active August 30, 2017 10:15
[Python] App Structure for Tornado with multiple handlers and a global Thread pool

App Structure for Tornado with multiple handlers and a global Thread pool between handlers

dir: handlers

# a_hander.py

from lib import global_for_handlers

def get_thread_pool():
@dineshsprabu
dineshsprabu / program_as_daemon_supervisor.md
Last active August 24, 2017 10:54
[Linux][Supervisor] How to use supervisor to run a program as daemon?

How to use supervisor to run a program as daemon?

Install the supervisor package

sudo apt-get install supervisor

Create a config file for your daemon at /etc/supervisor/conf.d/flashpolicyd.conf

@dineshsprabu
dineshsprabu / chrome_extension_storage.js
Created August 12, 2017 12:25
[Chrome Extension] Storage Lib
var AppStorage = function(select){
var self = this;
self.storageObject = chrome.storage.local;
if(select && select.settings && chrome.storage && chrome.storage.sync){
self.storageObject = chrome.storage.sync;
}
self.get = function(key){
return new Promise(function(resolve, reject){
@dineshsprabu
dineshsprabu / chrome_extension_helper.md
Last active May 1, 2024 21:11
[Chrome Extension] Chrome Extension Helper

Get current tab URL

Add below to permissions on manifest

"permissions": [
    "tabs",
 "http://*/*", 
@dineshsprabu
dineshsprabu / thread_pool_executor_examples.py
Created August 1, 2017 05:21
[Python][Async] Understanding Futures and ThreadPoolExecutor for Async
from concurrent import futures
import requests
def get_data(url):
if url == 0:
return "working"
return requests.get(url).text
# Running a blocking task on executor.
# Increasing ThreadPool size or setting it to None,
@dineshsprabu
dineshsprabu / chef_cookbook_helper.txt
Created June 12, 2017 11:18
[Chef][CookBook] Chef cookbook helper
Creates a local chef cookbook on the current dir.
chef generate cookbook nodejs-install .
Running a chef script local
chef-client --local-mode <receipe-name>.rb