Skip to content

Instantly share code, notes, and snippets.

View dilawar's full-sized avatar
🦖
w**king

Dilawar Singh dilawar

🦖
w**king
View GitHub Profile
@dilawar
dilawar / .clang-format
Created December 16, 2021 07:48
Official .clang-format of SubconsciousCompute
---
BasedOnStyle: Webkit
SortIncludes: false
ColumnLimit: 80
AlignTrailingComments: true
AlignConsecutiveMacros: true
AllowShortFunctionsOnASingleLine: false
...
@dilawar
dilawar / docker-compose-backup.sh
Created July 4, 2021 07:06 — forked from pirate/docker-compose-backup.sh
Backup a docker-compose project, including all images, named and unnamed volumes, container filesystems, config, logs, and databases.
#!/usr/bin/env bash
### Bash Environment Setup
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
# set -o xtrace
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
@dilawar
dilawar / README.md
Created August 5, 2018 06:00 — forked from andyshinn/README.md
pbcopy over SSH

Install

  • Add pbcopy.plist to your ~/Library/LaunchAgents/ folder.
  • Launch the listener with launchctl load ~/Library/LaunchAgents/pbcopy.plist.
  • Add RemoteForward 2224 127.0.0.1:2224 in your ~/.ssh/config file under your Host * or specific hosts sections.
  • Add [ -n "$SSH_CLIENT" ] && alias pbcopy="nc localhost 2224" to your remote ~/.bash_profile or other shell profile.
  • Enjoy pbcopy remotely!
@dilawar
dilawar / pgfplots.md
Last active July 31, 2018 06:07
My PGFPLOTS notes

Labels

  1. Attach label on axis by relative position \node[yshift=3mm0] at (rel axis cs:0,1) {\bf A};. Always put this line outsize axis environment. Otherwise, it will be clipped.

\addlegendentry inside \foreach loop

\foreach \x in {1,2,3}
{
@dilawar
dilawar / compress.py
Last active September 26, 2017 12:46
Compress/decompress a file using Huffman code
#!/usr/bin/env python
from __future__ import print_function, division
__author__ = "Dilawar Singh"
__copyright__ = "Copyright 2017-, Dilawar Singh"
__version__ = "1.0.0"
__maintainer__ = "Dilawar Singh"
__email__ = "dilawars@ncbs.res.in"
@dilawar
dilawar / Packaging_Example.sh
Created November 4, 2015 19:47 — forked from asmaloney/Packaging_Example.sh
This is an example of script to package up and create a DMG for a Mac OS X app. Details may be found here: http://asmaloney.com/2013/07/howto/packaging-a-mac-os-x-application-using-a-dmg/
#!/bin/bash
# by Andy Maloney
# http://asmaloney.com/2013/07/howto/packaging-a-mac-os-x-application-using-a-dmg/
# make sure we are in the correct dir when we double-click a .command file
dir=${0%/*}
if [ -d "$dir" ]; then
cd "$dir"
fi
#!/bin/bash
SEPARATOR='_'
find . -maxdepth 1 -type f -name "*" -print0 | while read -d $'\0' file
do
IFS=$SEPARATOR read -a _file <<< "$file"
STUDENTDIR="${_file[0]}"
STUDENTDIR="${STUDENTDIR// /_}"
mkdir -p $STUDENTDIR
echo "Moving $file to $STUDENTDIR"
mv "$file" $STUDENTDIR
# A text book example from MacKay.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.lines as mlines
import matplotlib.patches as mpatches
def plotLetter(letter, itr):
black = '#000000'; white='#FFFFFF'; gray='#AAAAAA'
squareSide = 0.03
@dilawar
dilawar / count_spikes.py
Created June 23, 2015 07:44
count spikes in a list.
def count_spikes(tables, threshold):
'''Count the number of spikes, also pupulate the spikeTables '''
nSpikes = 0
spikeBegin = False
spikeEnds = False
clock = moose.Clock('/clock')
for tname in tables:
t = tables[tname]
dt = clock.currentTime / len(t.vector)
spikeList = []
@dilawar
dilawar / query.py
Created March 10, 2015 10:15
query.py file for ARIDNI
"""query.py:
Searches each row of query sheet in columns of database sheet.
"""
__author__ = "Dilawar Singh"
__copyright__ = "Copyright 2015, Dilawar Singh and NCBS Bangalore"
__credits__ = ["NCBS Bangalore"]
__license__ = "GNU GPL"