Skip to content

Instantly share code, notes, and snippets.

View bilthon's full-sized avatar

Bilthon bilthon

  • Lima
View GitHub Profile
## Period 1
p1_btc = 25.
p1_usd = 75.
p1_t = p1_btc + p1_usd
print('period 1: usd {0}, btc: {1}, total: {2}'.format(p1_usd, p1_btc, p1_t))
## Period 2 (Before rebalancing)
p2_btc = p1_btc * 10
p2_usd = p1_usd
p2_t = p2_btc + p2_usd
@bilthon
bilthon / index.py
Created April 22, 2019 22:13
Satoshi's Treasure address lookup script
import requests
filename = 'candidates.txt'
host = 'https://satoshistreasure.xyz/'
with open(filename, 'r') as f:
for address in f:
url = host + address
try:
r = requests.get(url)
@bilthon
bilthon / CustomAppBarLayoutBehavior.java
Created January 3, 2018 23:42
Custom behavior for an AppBarLayout that we want to prevent from scrolling
import android.content.Context;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
/**
* Behavior used to manually switch on and off the scrolling behavior of an AppBarLayout
*/
@bilthon
bilthon / keybase.md
Created February 14, 2017 19:55
Keybase github proof

Keybase proof

I hereby claim:

  • I am bilthon on github.
  • I am bilthon (https://keybase.io/bilthon) on keybase.
  • I have a public key ASCmAeh_sU6peyKuFJTHhC3G0OQjKi_fij63LhSUu8x9uAo

To claim this, I am signing this object:

@bilthon
bilthon / MockLocationProvider
Last active August 29, 2015 13:57
MockLocationProvider
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.os.SystemClock;
import android.util.Log;
public class MockLocationProvider {
private String TAG = "MockLocationProvider";
String providerName;
Context ctx;
@bilthon
bilthon / LocationAwareActivity
Last active August 29, 2015 13:57
Activity that uses the MockLocationProvider
public class LocationAwareActivity {
/* Mock location provider that will emulate the taxi driver movements */
private MockLocationProvider mock;
private Handler mHandler;
private int index = 0;
private double[][] locations = {{-22.9191000,-43.2193167},
{-22.9195167,-43.2202167},
{-22.9195833,-43.2202167},
{-22.9200000,-43.2208167},
#!/bin/env python
import numpy as np
# Code with some functions to help calculate the closest distance from a point
# to a line segment. Here we take into account the fact that the line has finite
# length, so if the closest point to the infinite line containing the two given
# points (the projection) falls beyond the end of the segment, we just take the
# closest segment endpoint.
#