Skip to content

Instantly share code, notes, and snippets.

Guy Smoilov guysmoilov

  • Israel
Block or report user

Report or block guysmoilov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@guysmoilov
guysmoilov / gdrive_download.sh
Created Feb 28, 2019
Bash script to download large zip files from google drive while confirming the virus scan warning
View gdrive_download.sh
#!/bin/sh
# Usage: gdrive_download 123-abc ./output.zip
function gdrive_download () {
CONFIRM=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate "https://drive.google.com/uc?export=download&id=$1" -O- | sed -En 's/.*confirm=([0-9A-Za-z_]+).*/\1/p')
wget --load-cookies /tmp/cookies.txt "https://drive.google.com/uc?export=download&confirm=$CONFIRM&id=$1" -O $2
rm -f /tmp/cookies.txt
}
View Mystery.java
import java.util.Comparator;
import java.util.List;
/**
???
**/
public class Mystery<T extends Comparable<? super T>> implements Comparator<List<T>> {
@Override
public int compare(List<T> l1, List<T> l2) {
@guysmoilov
guysmoilov / save-js-blob.js
Last active Jul 30, 2017
Saves an octet-stream returned from a REST call as a file
View save-js-blob.js
var toSend = {};
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "https://myserver.com/path", true);
xmlhttp.responseType="blob";
xmlhttp.setRequestHeader("Content-Type", "application/json");
xmlhttp.overrideMimeType('application/octet-stream');
xmlhttp.onload = function() {
console.log('success');
console.log(xmlhttp.response);
window.open(URL.createObjectURL(xmlhttp.response)).focus();
@guysmoilov
guysmoilov / ListComparator.java
Last active May 7, 2018
Java lexicographical comparator for lists
View ListComparator.java
import java.util.Comparator;
import java.util.List;
/**
* Compares {@link Comparable} list instances lexicographically.
* Assumes that the lists are not null, that they contain no null elements, and that they are optimized for random access!
*
* <p>
* Created by Tolstoyevsky on 08/02/2017.
* </p>
@guysmoilov
guysmoilov / TopicChangingMirrorMakerMessageHandler.scala
Created Nov 30, 2016
Topic transforming Kafka mirror maker handler
View TopicChangingMirrorMakerMessageHandler.scala
package kafka.tools
import java.util
import java.util.Collections
import kafka.consumer.BaseConsumerRecord
import kafka.tools.MirrorMaker.MirrorMakerMessageHandler
import org.apache.kafka.clients.producer.ProducerRecord
import scala.util.matching.Regex
@guysmoilov
guysmoilov / watch-list.sh
Created Aug 23, 2016
Watch command for long-term monitoring
View watch-list.sh
echo "Watching $1 command"
PREV=""
while sleep 1; do
CURRENT=`eval $1`
if [ "$CURRENT" != "$PREV" ]; then
echo "[`date`]: $CURRENT"
PREV=$CURRENT
fi
done
View generate-random-lines.sh
# Usage: arg 1 is number of random lines to generate, arg 2 is length of each line
# Stolen from: https://gist.github.com/earthgecko/3089509
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $2 | head -n $1
View no-proxy.bat
set http-proxy=
set https-proxy=
set http_proxy=
set https_proxy=
start cmd
View kill-android-process.py
import subprocess
import sys
pslist = subprocess.check_output("adb shell ps " + sys.argv[1]).decode("utf-8").split()
if len(pslist) > 8:
pid = pslist[9]
print("killing " + pid)
subprocess.check_call("adb shell kill " + pid)
@guysmoilov
guysmoilov / reinstall-apk.py
Created Jun 13, 2016
Python script to reinstall an apk
View reinstall-apk.py
import subprocess
import sys
import re
apkpath = sys.argv[1]
print('checking packagename')
head = subprocess.check_output('aapt d badging "' + apkpath + '"').decode("utf-8").split("\n")[0]
packagename = re.match(r'^package: name=\'([A-Za-z0-9\.]+)\'', head).group(1)
print('uninstalling ' + packagename)
subprocess.check_call("adb uninstall " + packagename)
You can’t perform that action at this time.