Skip to content

Instantly share code, notes, and snippets.

View dmerejkowsky's full-sized avatar
🍵
418 - I'm a teapot

Dimitri Merejkowsky dmerejkowsky

🍵
418 - I'm a teapot
View GitHub Profile
Update: found it: it's the OSX.pirrit virus, see here:
http://www.cybereason.com/cybereason-labs-analysis-the-minds-behind-the-osx-pirrit/
Saw a bunch of those running (as root) in htop:
$ ls /etc/*.sh
/etc/Dicyemida.sh*
/etc/Fulah.sh*
/etc/Gothism.sh*
/etc/audile.sh*
@dmerejkowsky
dmerejkowsky / set-cwd-after-vim-exits.sh
Last active May 21, 2016 20:07
Set working dir after (neo)vim exits
function vim() {
/usr/bin/vim $*
cd $(cat /tmp/nvim-cwd)
}
@dmerejkowsky
dmerejkowsky / neovim-cwd-wokrflow.vim
Created April 30, 2016 14:24
Neovim cwd workflow
function! OnTabEnter(path)
if isdirectory(a:path)
let dirname = a:path
else
let dirname = fnamemodify(a:path, ":h")
endif
execute "tcd ". dirname
endfunction()
autocmd TabNewEntered * call OnTabEnter(expand("<amatch>"))
@dmerejkowsky
dmerejkowsky / autorefresh-neovim-chromium.py
Last active April 20, 2016 16:16
Autorefresh chromium from a neovim key binding
#!/usr/bin/env python
""" Usage:
* Start neovim with NVIM_LISTEN_ADDRESS=/tmp/neovim
* Install selenium and neovim Python packages from pypi
* Run autorefresh URL
* In neovim, map a kep to send the event:
nnoremap ,m :w<cr>:call rpcnotify(0, "refresh")<cr>
" One argument:
function! Foo(foo)
" Do something with a:foo
endfunction
command! -nargs=1 -complete=file Foo :call Foo("<args>") " <- note the quotes
" Two arguments:
function! Foo2(foo, bar)
" Do something with a:foo and a:bar
endfunction
@dmerejkowsky
dmerejkowsky / call-private.java
Created March 18, 2016 23:16
Calling private methods in Java
import java.lang.reflect.Method;
Foo foo = new Foo();
Method method = Foo.class.getDeclaredMethod("private")
method.setAccessible(true);
method.invoke(foo);
@dmerejkowsky
dmerejkowsky / source-date-epoch-from-git.sh
Created March 16, 2016 12:18
source-date-epoch-from-git
export SOURCE_DATE_EPOCH=$(git log -1 --format=%ct)
# This sets SOURCE_DATE_EPOCH to the date of the last commit, (it's even better if it's a
# signed tag of course), which is perfect for reproducible builds.
# See here for more info : https://reproducible-builds.org/
@dmerejkowsky
dmerejkowsky / logs
Last active April 20, 2016 14:28
jenkins strange return code on Windows for CreateProcess
# From the command line:
c:\pouet.exe
segfault
Exit code: 0xc0000005
# From a jenkins slave connected as a Windows service:
c:\Users\xxxx\jenkins\workspace\pouet>C:\pouet.exe
segfault
Exit code: 0xff
@dmerejkowsky
dmerejkowsky / git-history-stats.py
Last active February 29, 2016 13:08
Get git history statistics
import sys
import subprocess
import packaging.version
import tabulate
out = subprocess.check_output(["git", "tag"]).decode("UTF-8")
current_branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"])
if not current_branch:
sys.exit("Not on a branch")
@dmerejkowsky
dmerejkowsky / test.py
Created January 27, 2016 13:01
py.test rocks
# in test_qibuild_configure.py
def test_qibuild_configure(tmpdir):
# do stuff in tmpdir
assert rc == 0