Skip to content

Instantly share code, notes, and snippets.

@maxme
maxme / get_balance.py
Created May 22, 2013 14:54
get_balance electrum script
#!/usr/bin/env python
import sys
from electrum import Interface
from electrum import bitcoin, Transaction
def get_transactions(addr):
interface = Interface({'server':'electrum.be:50001:t'})
interface.start()
@maxme
maxme / up.plugin.sh
Last active December 25, 2015 02:39
Quick and dirty up completion for zsh
_up () {
compadd $(up -h|grep " "|tr -s " "|tr "," "\n"|sed -E "s/ ([a-zA-Z-]+)[ ,].*/\1/")
_arguments -s "*:files:_files"
}
compdef _up up
@maxme
maxme / lang_detection.py
Created November 1, 2013 16:31
Language detection algorithm
from collections import defaultdict
def detect_language(scores, input_str):
tokens = input_str.split()
results = defaultdict(int)
for token in tokens:
if token in scores:
language, score = scores[token][0]
results[language] += score
max_lang, max_score = max(results.items(), key=lambda x:x[1])
function reduce_tqr_time_font_size() {
var a = document.querySelectorAll("tr span");
var i = 0;
for (i = 0; i < a.length; i++) {
a[i].setAttribute("style", "font-size: 0.7em");
}
}
@maxme
maxme / ndk-build.gradle
Created November 12, 2013 17:21
A gradle build file for Android NDK - uses a trick to put *so files in a jar and add that jar as a project dependency
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
task androidJar(type:Exec) {
commandLine = ['jar', 'cf', 'build/EmailChecker.jar', '-C', 'build/classes/release', '.', 'libs/native-libs-0.1.jar']
}
#!/bin/sh
CURDATE=$(date -Iseconds)
adb shell screencap -p /sdcard/screencap-$CURDATE.png
adb pull /sdcard/screencap-$CURDATE.png
adb shell rm /sdcard/screencap-$CURDATE.png
#!/bin/sh
# Example inputs:
# dashicon_admin_site 
# dashicon_admin_users 
# dashicon_lock 
# dashicon_edit 
# dashicon_email 
if [ x$2 == x ]; then
#!/bin/sh
CURDATE=$(date -Iseconds | sed s/:/-/g)
adb shell screencap -p /sdcard/screencap-$CURDATE.png
adb pull /sdcard/screencap-$CURDATE.png 2> /dev/null > /dev/null
adb shell rm /sdcard/screencap-$CURDATE.png
echo screencap-$CURDATE.png
@maxme
maxme / codeStyleSettings.xml
Created April 10, 2014 09:39
codeStyleSettings.xml for IDEA IntelliJ - WPAndroid
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value>
<option name="LAYOUT_STATIC_IMPORTS_SEPARATELY" value="false" />
<option name="INSERT_INNER_CLASS_IMPORTS" value="true" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">