Skip to content

Instantly share code, notes, and snippets.

% add and remove path
addpath(folder_name)
% generate recursive paths within a folder
genpath(folder_name)
% add all sub-directories in MATLAB path within a folder
addpath(genpath(folder_name))
### Comment
@vaibhaw
vaibhaw / python-scripts.py
Created December 3, 2014 21:23
some useful Python scripts for everyday tasks
def get_subdirs_in_folder(folder):
# subdir_list = []
# for path, subdirs, files in os.walk(folder):
# subdir_list.extend(subdirs)
dir_files = [os.path.join(folder,files) for files in os.listdir(folder)]
subdir_list = filter(os.path.isdir, dir_files)
return subdir_list
@vaibhaw
vaibhaw / Java-snippets.java
Created December 9, 2014 10:16
Java Code snippets for everyday tasks
// ======> get path of running jar file
// Solutions act funny for non-file locations
// Solution:1
String path = MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath(); // gives path, acts funny if path has spaces
String decodedPath = URLDecoder.decode(path, "UTF-8"); // to solve problem related to whitespaces in path
// Solution:2
// URLDecoder does not work for many special characters
// toURI is vital here as it takes care of URL encoding/decoding
String path = MyClass.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();‌
@vaibhaw
vaibhaw / jar-location.java
Last active August 29, 2015 14:11
Get location of jar file which is being run
package com.vaibhaw.imagesimilarity
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;
public class Searcher {
static String jarPath = ".";
@vaibhaw
vaibhaw / windows.bat
Created December 15, 2014 19:21
Windows utility scripts
for %a in ("%path:;=";"%") do @echo %~a
($env:Path).Replace(';',"`n")
# based on https://gist.github.com/amirsani/d2aa0763cc138902bf73
# Read this two also
# http://stackoverflow.com/questions/11443302/compiling-numpy-with-openblas-integration/14391693#14391693
# http://osdf.github.io/blog/numpyscipy-with-openblas-for-ubuntu-1204-second-try.htmlhttp://osdf.github.io/blog/numpyscipy-with-openblas-for-ubuntu-1204-second-try.html
# OS dependencies
sudo apt-get install -y build-essential gfortran
sudo apt-get install -y git curl vim
# Python dependencies
# search and replace strings
grep -rl search_string directory | xargs sed -i 's/string_to_replace/replace_string/g'
# bulk rename files in a folder
a=1
for i in *.jpg; do
new=$(printf "sofa_%04d.jpg" "$a") #04 pad to length of 4
mv -- "$i" "$new"
let a=a+1
done
# path_tools.bash
# Ref - http://stackoverflow.com/a/294025
# A set of tools for manipulating ":" separated lists like the
# canonical $PATH variable.
#
# /bin/sh compatibility can probably be regained by replacing $( )
# style command expansion with ` ` style
###############################################################################
# Usage:
#
# fix the broken pipe problem || keep the server connection alive
http://www.howtogeek.com/howto/linux/keep-your-linux-ssh-session-from-disconnecting/
solver.prototxt
1. net:
2. snapshot_prefix:
3. solver_mode:
Optional
test_interval:
max_iter:
snapshot: