Skip to content

Instantly share code, notes, and snippets.

View rootcss's full-sized avatar
🎯
Focusing

Shekhar Singh rootcss

🎯
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am rootcss on github.
  • I am rootcss (https://keybase.io/rootcss) on keybase.
  • I have a public key whose fingerprint is E39D A481 351E 3C2C FD3D 5EA2 8605 5CD9 0FEB 4148

To claim this, I am signing this object:

@rootcss
rootcss / python_debugger.py
Created November 11, 2016 12:11
Python debugger - similar to "pry" in ruby
import code
some_var = 100
code.interact(local=dict(globals(), **locals()))
print some_var
@rootcss
rootcss / SparkCopyPostgres.scala
Created April 10, 2017 09:58 — forked from longcao/SparkCopyPostgres.scala
COPY Spark DataFrame rows to PostgreSQL (via JDBC)
import java.io.InputStream
import org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils
import org.apache.spark.sql.{ DataFrame, Row }
import org.postgresql.copy.CopyManager
import org.postgresql.core.BaseConnection
val jdbcUrl = s"jdbc:postgresql://..." // db credentials elided
val connectionProperties = {
"""
Fetches key paths and values of a dictionary
"""
def dict_path(path, my_dict):
for k,v in my_dict.iteritems():
if isinstance(v, dict):
dict_path(path + "_" + k, v)
else:
output.append('key: {}_{}, val: {}'.format(path, k, v))
import subprocess
from threading import Thread
def call_subprocess(cmd):
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = proc.communicate()
if err:
print(err)
thread = Thread(target=call_subprocess, args=['pip install --upgrade pip && pip install pysftp'])
body { background: #222; color: #e6e6e6; }
a { color: #949494; }
a:link, a:visited { color: #949494; }
a:hover, a:active, a:focus { color: #c7c7c7; }
hr { border-bottom: 1px solid #424242; border-top: 1px solid #222; }
@rootcss
rootcss / iterm2-solarized.md
Created October 7, 2018 13:15 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

@rootcss
rootcss / postgres_queries_and_commands.sql
Created March 26, 2019 09:57 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@rootcss
rootcss / apache_bench.md
Created April 25, 2019 08:57
Apache Bench Examples

Installation:

sudo apt-get install apache2-utils

GET example

ab -n 10 -c 2 http://dummy.restapiexample.com/api/v1/employees
@rootcss
rootcss / jupyter_dark_theme_and_notify.js
Last active August 22, 2019 05:50
Have a dark mode for jupyter and also integrate notify; which notifies when a command is executed. Not a very sophisticated script.
$("head").append(`<style>
body,
body.notebook_app.command_mode {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.CodeMirror pre,
.CodeMirror-dialog,
.CodeMirror-dialog .CodeMirror-search-field,
.terminal-app .terminal {