Skip to content

Instantly share code, notes, and snippets.

std::vector<std::string> split(const std::string &text, char sep) {
std::vector<std::string> tokens;
std::size_t start = 0, end = 0;
while ((end = text.find(sep, start)) != std::string::npos) {
tokens.push_back(text.substr(start, end - start));
start = end + 1;
}
tokens.push_back(text.substr(start));
return tokens;
}
@divegeek
divegeek / otp.py
Created August 18, 2015 20:31
Trivial one-time pad implementation
#!/usr/bin/python
import sys
if __name__ == "__main__":
if len(sys.argv) != 3:
print "Usage: otp.py <plaintext> <pad>"
exit(1)
plaintext = sys.argv[1].upper()
pad = sys.argv[2].upper()
@divegeek
divegeek / adb-setdev.sh
Last active August 29, 2015 14:26 — forked from ncornette/gist:3272344
An interactive Bash function that allow you to select an Android device in a list then Sets ANDROID_SERIAL
# Display a list of all connected Android devices
# Set ANDROID_SERIAL environment from selected item
# Example of use : # adb-setdev && adb install -r myapp.apk
function adb-setdev()
{
devices=($(adb devices|grep "device$"|cut -f1))
devices_count=${#devices[*]}
if [ "$devices_count" -eq "0" ]
then
unset ANDROID_SERIAL