Skip to content

Instantly share code, notes, and snippets.

@dipakc
dipakc / ShellScriptingTips.md
Created September 29, 2019 22:20
Shell scripting tips

Accessing arugments from previous commands

echo a b c d
a b c d

echo !:2
b

If you press tab after !:2, it is expanded to 2nd argument from the previous command.

@dipakc
dipakc / AWKSnippets.md
Created September 29, 2019 20:20
AWK Snippets

Print columns 1 and 3

echo "x:y:z#a:b:c" | awk 'BEGIN {RS="#";FS=":"} {print $1,$3}' 
x z
a c
@dipakc
dipakc / waitpid
Created May 18, 2018 06:33
Wait for a pid to finish
#!/bin/bash
pid=$1
me="$(basename $0)($$):"
if [ -z "$pid" ]
then
echo "$me a PID is required as an argument" >&2
exit 2
fi
name=$(ps -p $pid -o comm=)
name: np
channels:
- defaults
dependencies:
- bokeh=0.12.13=py36h2f9c1c0_0
- ca-certificates=2017.08.26=h1d4fec5_0
- certifi=2018.1.18=py36_0
- cffi=1.11.4=py36h9745a5d_0
- click=6.7=py36h5253387_0
- cloudpickle=0.5.2=py36h84cdd9c_0
{
"image_index": 0,
"program": [
{
"inputs": [],
"function": "scene",
"value_inputs": []
},
{
"inputs": [
{
"split": "train",
"image_index": 0,
"image_filename": "CLEVR_train_000000.png",
"directions": {
"right": [ 0.6563112735748291, 0.7544902563095093, -0.0 ],
"behind": [ -0.754490315914154, 0.6563112735748291, 0.0 ],
"above": [ 0.0, 0.0, 1.0 ],
"below": [ -0.0, -0.0, -1.0 ],
"left": [ -0.6563112735748291, -0.7544902563095093, 0.0 ],
@dipakc
dipakc / using_logging_filter.py
Created November 6, 2017 23:31
Python logging. Using filter
import logging
def foo():
lfoo = logging.getLogger('abc')
lfoo.info('Foo: message')
def bar():
lbar = logging.getLogger('abc')
lbar.info('Bar: message')

File structure

├── app.js
├── index.html
├── lib
│   ├── modules
│   │   └── template.js
│   ├── require.js
│   └── underscore.js
@dipakc
dipakc / .gitignore
Last active September 8, 2015 13:22 — forked from kogakure/.gitignore
Git: .gitignore file for LaTeX projects
*.aux
*.glo
*.idx
*.log
*.toc
*.ist
*.acn
*.acr
*.alg
*.bbl
@dipakc
dipakc / RefactoringOptListFlatten.scala
Created November 9, 2012 05:46
RefactoringOptListFlatten
object OptListFlatten {
///////////////
val aList = List(Some(10), None, Some(20))
for {
x <- aList
if (x.isDefined)
} yield {
x.get
}
//-------------