This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import imaplib | |
import email | |
import os | |
parser = argparse.ArgumentParser(description = 'Backup GMail mailbox. Turn on less secure apps before running https://www.google.com/settings/security/lesssecureapps') | |
parser.add_argument('--username', required = True) | |
parser.add_argument('--password', required = True) | |
parser.add_argument('-o', default = '.') | |
parser.add_argument('--label', default = 'INBOX') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import psutil | |
import subprocess | |
import datetime | |
import time | |
bashScriptPath = sys.argv[1] | |
stdoutPath, stderrPath = sys.argv[2:] or (None, None) | |
peakRssBytes = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$deviceManager = new-object -ComObject WIA.DeviceManager | |
$device = $deviceManager.DeviceInfos.Item(1).Connect() | |
$wiaFormatPNG = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}" | |
foreach ($item in $device.Items) { | |
$image = $item.Transfer($wiaFormatPNG) | |
} | |
if($image.FormatID -ne $wiaFormatPNG) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Usage example: bash install_ubuntu_package_locally_without_root.sh libopencv-dev ~/deb | |
# Author: Vadim Kantorov | |
# Add the following exports to your .bashrc or .profile to use the unpacked packages | |
# export PATH=$HOME/deb/usr/bin:$PATH | |
# export LD_LIBRARY_PATH=$HOME/deb/usr/lib:$HOME/deb/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH | |
# export CPATH=$HOME/deb/usr/include:$CPATH | |
# export LIBRARY_PATH=$LIBRARY_PATH:$LD_LIBRARY_PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Usage example: bash pip.sh ipython | |
# Add the following export to your .bashrc or .profile to use the unpacked packages | |
# export PYTHONPATH=$HOME/user_lib/pip_user/lib/python2.7/site-packages:$PYTHONPATH | |
INSTALL_DIR=$HOME/user_lib/pip_user | |
mkdir -p $INSTALL_DIR | |
PYTHONUSERBASE=$INSTALL_DIR pip install --user "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Microsoft.FSharp.Data.UnitSystems.SI.UnitNames | |
open Microsoft.FSharp.Data.UnitSystems.SI.UnitSymbols | |
[<Measure>] | |
type mm = | |
static member perMeter = 1e+3<mm/m> | |
let pi = System.Math.PI | |
let epsilon_0 = 8.854187817e-12<F m^-1> | |
let elementary_charge = 1.602176565e-19<coulomb> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = figure(); | |
plot(1:10, 1:10); | |
rgbData = figToImStream('figHandle', f, 'imageFormat', 'jpg', 'outputType', 'uint8'); | |
%print(f, '-djpg', '/tmp/vis.jpg'); rgbData = fread(fopen('/tmp/vis.jpg'), 'uint8=>uint8'); % replace previous line by this line in case of failure | |
fprintf('<img src="data:image/jpeg;base64,%s" />', char(org.apache.commons.codec.binary.Base64.encodeBase64(rgbData))'); | |
close(f); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- example for an AlexNet-like model | |
--model, unconverted = loadmatconvnet('/path/to/somemodel.mat', { | |
-- conv2 = {groups = 2}, | |
-- conv4 = {groups = 2}, | |
-- conv5 = {groups = 2}, | |
-- fc6 = {fc_kH = 6, fc_kW = 6, type = 'nn.Linear'}, --ONE MAY NEED TO BE CAREFUL, these fc_kH, fc_kW are for 1x36 (or 36x1, don't remember) saved weights | |
-- fc7 = {type = 'nn.Linear'}, | |
--}) | |
matio = require 'matio' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local torch_repl = repl | |
function repl(restoreGlobals) | |
-- copied from http://stackoverflow.com/questions/33068607/how-can-i-use-the-torch-repl-for-debugging | |
require 'trepl' | |
restoreGlobals = restoreGlobals or false | |
-- optionally make a shallow copy of _G | |
local oldG = {} | |
if restoreGlobals then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias timejson='/usr/bin/time -f '"'"'{"exit_code" : %x, "time_user_seconds" : %U, "time_system_seconds" : %S, "time_wall_clock_seconds" : %e, "rss_max_kbytes" : %M, "rss_avg_kbytes" : %t, "page_faults_major" : %F, "page_faults_minor" : %R, "io_inputs" : %I, "io_outputs" : %O, "context_switches_voluntary" : %w, "context_switches_involuntary" : %c, "cpu_percentage" : "%P", "signals_received" : %k}'"'" |
OlderNewer