Skip to content

Instantly share code, notes, and snippets.

@abhi1010
abhi1010 / grunt-hugo-lunrjs.md
Created November 4, 2015 16:17 — forked from sebz/grunt-hugo-lunrjs.md
hugo + gruntjs + lunrjs = <3 search
@abhi1010
abhi1010 / config.js
Created April 13, 2016 04:14 — forked from johnlindquist/config.js
RxJS + Angular 2 with 14 different Rx operators all chained together
SystemJS.config({
transpiler: "typescript",
typescriptOptions: {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
},
map: {
"rxjs": "https://npmcdn.com/rxjs",
"angular2": "https://npmcdn.com/angular2",
"@ngrx": "https://npmcdn.com/@ngrx",
@abhi1010
abhi1010 / shutdown_script.sh
Created September 2, 2016 16:19
shutdown script
ubuntu@ip-172-31-51-67  ~  cat /var/shutdown_scripts
#!/bin/bash
shutdown_if_long()
{
TOO_LONG=${1:-30}
echo -e "too long = $TOO_LONG"
d1=$(last | head -1 | sed -e 's/.* //g' -e 's/ (.*//g' -e 's/..... - //g' -e 's/.* //g' | xargs -I {} date -d {})
d_now=$(date)
@abhi1010
abhi1010 / inv_pylib_build.py
Created January 26, 2017 08:55
how to write invoke commands that reach other folders
@task
def find():
with cd('../../pylib/gh_hazardous_sol/'):
print('finding tasks')
res = check_output(['/opt/py27env/bin/invoke', '-l'])
print('results = {}'.format(res))
if 'build' in res:
print('we got build command')
# currently all build code is common across all pylibs, through pylib/tasks.py.
# folders like gh_hazardous_sol simply call pylib/tasks.py->build function if it exists
@abhi1010
abhi1010 / cpp_time_ostream.log
Last active April 23, 2019 06:12
print std::chrono::duration
edit mode | history
10 hours
36000 seconds
60000 intervals of 0.600000 (3/5) seconds each
@abhi1010
abhi1010 / expand_url.py
Created January 6, 2018 16:18 — forked from vgoklani/expand_url.py
Expand shortened URLs in Python
# http://stackoverflow.com/questions/748324/python-convert-those-tinyurl-bit-ly-tinyurl-ow-ly-to-full-urls
#############
# urllib2
import urllib2
fp = urllib2.urlopen('http://bit.ly/rgCbf')
fp.geturl()
# ==> 'http://webdesignledger.com/freebies/the-best-social-media-icons-all-in-one-place'
@abhi1010
abhi1010 / icecream.sh
Last active May 17, 2018 09:47
icecream setup
sudo dnf install -y icecream.x86_64 icemon.x86_64
# On Main Scheduler server - run both
sudo icecc-scheduler -d
sudo iceccd -d
# On Build Farm Clients
sudo iceccd -d
@abhi1010
abhi1010 / logging_config.py
Created June 19, 2018 03:07
python logging to console and file
import logging
FORMAT = '%(asctime)-15s %(filename)s <%(lineno)s> %(message)s'
logging.basicConfig(
filename='log-myreport.log', level=logging.DEBUG, format=FORMAT)
stdoutLogger = logging.StreamHandler()
stdoutLogger.setFormatter(logging.Formatter(logging.BASIC_FORMAT))
logging.getLogger().addHandler(stdoutLogger)
@abhi1010
abhi1010 / popen_examples.py
Created June 20, 2018 00:29
run bash commands in python using Popen
def _run_cmd_with_prints(cmd):
proc = subprocess.Popen(
cmd,
bufsize=1,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
for line in proc.stdout.readline():
print('output = {}'.format(line))
@abhi1010
abhi1010 / create-class-diagram.md
Last active October 12, 2018 08:57
class diagram from code