Skip to content

Instantly share code, notes, and snippets.

@spacelis
spacelis / run.vim
Created November 15, 2012 21:11
pymode-run
" DESC: Save file if it modified and run python code
fun! pymode#run#JumpToCurrentError() "{{{
let a:err = []
sil!substitute /File\s\"\(.*\)\"\zs/\=add(a:err, submatch(1))[1:0]/
sil!substitute /,\sline\s\(\d\+\)\zs/\=add(a:err,submatch(1))[1:0]/
wincmd k
if len(a:err) > 0
if filereadable(fnamemodify('.', ':p') . a:err[0])
exe "next " . fnamemodify('.', ':p') . a:err[0]
exe "normal " . a:err[1] . "gg"
@spacelis
spacelis / Bashtest.java
Created February 22, 2013 12:21
Run any bash commandlines from Java
package nl.tudelft.dmirlab.pydo;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
public class Bashtest {
@spacelis
spacelis / watchdog.sh
Last active December 14, 2015 18:59
Sending out notifications when either the daemon or the target process stop running.
#!/usr/bin/env bash
if [[ $# < 2 ]]; then
echo "Usage: watchdog <pcs> <email>"
exit 1
fi
svr="$(hostname)"
pcs=$1
pcsdetail=$(ps --no-heading -p $pcs)
@spacelis
spacelis / python-mode.patch
Created April 23, 2013 14:07
A temporary workaround of AttributeError when uses code checking
diff --git a/pylibs/pylama/pylint/checkers/logging.py b/pylibs/pylama/pylint/checkers/logging.py
index 4c78d8f..f25b893 100644
@@ -90,6 +90,8 @@ class LoggingChecker(checkers.BaseChecker):
and ancestor.parent.name == 'logging')])]
except astng.exceptions.InferenceError:
return
+ except AttributeError:
+ return
if (node.func.expr.name != self._logging_name and not logger_class):
return
@spacelis
spacelis / ljson2mongo.py
Created July 6, 2013 12:18
A small script for importing file with json per line into mongodb.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File: ljson2mongo.py
Author: SpaceLis
Email: Wen.Li@tudelft.nl
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
File: stratified.py
Author: SpaceLis
Email: Wen.Li@tudelft.nl
Github: http://github.com/spacelis
Description:
Sampling in a stratified way. That is sampling from each subpopulation to
make the sample set more representative than simple random sampling. For
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Testing API module.
File: test_api.py
Author: SpaceLis
Email: Wen.Li@tudelft.nl
GitHub: http://github.com/spacelis
Description:
Testing API Module.
EMAILPTN = re.compile("^[-!#$%&'*+/0-9=?A-Z^_a-z{|}~]"
"(\.?[-!#$%&'*+/0-9=?A-Z^_a-z{|}~])*"
"@[a-zA-Z](-?[a-zA-Z0-9])*"
"(\.[a-zA-Z](-?[a-zA-Z0-9])*)+$")
--- __init__.old.py 2014-10-07 01:26:24.682034979 +0200
+++ __init__.py 2014-10-07 01:26:30.558034775 +0200
@@ -4272,7 +4272,7 @@
return self.imshow(imread(urllib2.urlopen(basemap_url)),origin='upper')
def wmsimage(self,server,\
- xpixels=400,ypixels=None,\
+ xpixels=400,ypixels=None,togray=False,\
format='png',verbose=False,**kwargs):
"""
--- __init__.py.old 2014-10-07 01:26:24.682034979 +0200
+++ __init__.py 2014-10-07 14:48:02.542868362 +0200
@@ -4272,7 +4272,7 @@
return self.imshow(imread(urllib2.urlopen(basemap_url)),origin='upper')
def wmsimage(self,server,\
- xpixels=400,ypixels=None,\
+ xpixels=400,ypixels=None,togray=False,\
format='png',verbose=False,**kwargs):
"""