Skip to content

Instantly share code, notes, and snippets.

View josephdunn's full-sized avatar

Joseph Dunn josephdunn

View GitHub Profile
library(xts)
library(crypto2)
coins <- crypto_list(only_active = TRUE)
btc_hist <- data.frame(crypto_history(coins, limit = 1, start_date = '20180101',
end_date = '20220101', interval = 'daily', finalWait = FALSE))
# intervals <- c(5, 10, 20, 50, 200)
intervals <- seq(10, 100, 10)
@josephdunn
josephdunn / android-adb-pull-apk.md
Created November 5, 2021 22:56 — forked from ctrl-freak/android-adb-pull-apk.md
Retrieve APK from Non-Rooted Android Device through ADB

https://stackoverflow.com/a/18003462/348146

None of these suggestions worked for me, because Android was appending a sequence number to the package name to produce the final APK file name (this may vary with the version of Android OS). The following sequence of commands is what worked for me on a non-rooted device:

  1. Determine the package name of the app, e.g. com.example.someapp. Skip this step if you already know the package name.

    adb shell pm list packages

    Look through the list of package names and try to find a match between the app in question and the package name. This is usually easy, but note that the package name can be completely unrelated to the app name. If you can't recognize the app from the list of package names, try finding the app in Google Play using a browser. The URL for an app in Google Play contains the package name.

#!/usr/bin/env python
# Duplicates an already-running process. Argument should be PID of running process.
import sys
import subprocess
import psutil
try:
p = psutil.Process(int(sys.argv[1]))
#!/usr/bin/env python
#
# To use:
#
# 1. Run this script, it will generate pywhole.hosts
# 2. Get pywhole.hosts copied into /tmp on your DD-WRT router
# 3. Add the following line to your "Additional DNSMasq Options" in Services section of your DD-WRT admin interface:
#
# addn-hosts=/tmp/pywhole.hosts
winProb <- 0.525
numBets <- c(1, 50, 1000, 10000, 100000)
runTimes <- 1000
pl <- function(bets)
{
sum(rbinom(bets, 1, winProb) - 0.5)
}
runs <- do.call(rbind, lapply(1:runTimes, function(x) { sapply(numBets, pl) }))
import numpy as np
ndays = int(1e5)
ntradesday = 7*60*10
pl = np.sum((np.random.binomial(1, 0.525, (ndays, ntradesday))-0.5)*2, 1)
1.0 / (len(pl[pl < 0]) / float(ndays) * 252)
# original idea: http://mcarreira.typepad.com/mc_notes/2014/03/a-simple-model-for-the-pl-of-a-market-maker-how-many-losing-days-in-a-year.html
ndays <- 1e5; pl <- unlist(lapply(1:ndays, function(x) { sum((rbinom(7*60*10, 1, 0.525) - 0.5) * 2) })) ; 1 / (length(pl[pl < 0]) / ndays * 252)
# updated code demonstrating win vs. loss asymmetry with M/T. thanks @marascio and @MarcosCarreira for the suggestions.
# wins are 1.00, losses are -1.05 (normalized)
ndays <- 1e5; pl <- unlist(lapply(1:ndays, function(x) { sum(ifelse((rbinom(7*60*10, 1, 0.525) - 0.5) * 2 == -1, -1.05, 1)) })) ; 1 / (length(pl[pl < 0]) / ndays * 252)
# same as above - ifelse() is slow compared to writing the vector correctly the first time, but this is more cryptic.
# wins are 1.00, losses are -1.05 (normalized)
ndays <- 1e5; pl <- unlist(lapply(1:ndays, function(x) { sum(((1-rbinom(7*60*10, 1, 0.525))*-2.05)+1) })) ; 1 / (length(pl[pl < 0]) / ndays * 252)
import time
import random
import datetime
from flask import Flask
# app
app = Flask(__name__)
app.config.from_pyfile('config.py')
#!/usr/bin/python
# Depends on wget, swftools, and ImageMagick.
import os
import sys
import re
import requests
from bs4 import BeautifulSoup
#!/usr/bin/env python
# Joric/bitcoin-dev, june 2012, public domain
import hashlib
import ctypes
import ctypes.util
import sys
ssl = ctypes.cdll.LoadLibrary (ctypes.util.find_library ('ssl') or 'libeay32')