Skip to content

Instantly share code, notes, and snippets.

View simform-solutions's full-sized avatar

Simform simform-solutions

View GitHub Profile
account add app backup can categori data expens incom manag money month person report spend track use will
5 0 1 0 2 2 1 4 1 4 1 0 2 2 0 1 4 1
3 4 0 1 1 2 2 4 0 1 0 0 0 1 1 3 5 1
3 1 3 2 2 3 2 5 3 4 5 2 1 1 8 4 2 3
3 1 4 3 4 5 3 6 1 2 0 3 1 3 0 4 0 0
0 0 0 1 4 1 0 4 2 0 2 3 0 3 0 1 1 1
1 2 4 1 2 3 2 18 6 3 0 4 1 0 1 5 0 0
9 0 1 3 13 3 3 8 1 15 11 2 5 1 2 2 1 0
0 0 0 0 3 1 3 2 0 2 2 1 0 0 1 1 0 2
1 4 5 0 0 1 1 5 0 1 1 1 3 1 1 4 0 3
@simform-solutions
simform-solutions / LocationUpdateFragment.java
Last active April 21, 2017 05:09
LocationUpdateFragment - Android
package com.places;
import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.content.IntentSender;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
# Updates the f_index and l_index
def update_fal_balance():
index_with_value = []
for data in address_data:
if data["balance"] > 0:
index = data["index"]
index_with_value.append(index)
if len(index_with_value) > 0:
# Writes the index, address and balance, as well as the checksum of address + seed into the account file
def write_address_data(index, address, balance):
address = address_checksum(address)
for p in address_data:
if p["address"] == address:
p["balance"] = balance
with open(file_name, 'w') as account_data:
json.dump(raw_account_data, account_data)
return
# Takes a address (81 Characters) and converts it to an address with checksum (90 Characters)
def address_checksum(address):
bytes_address = bytes(address)
addy = Address(bytes_address)
address = str(addy.with_valid_checksum())
return address
# Takes an address with checksum and verifies if the address matches with the checksum
def is_valid_address(address_with_checksum):
address = address_with_checksum[:81]
import getpass
import hashlib
import json
import time
import datetime
import re
import os
import RPi.GPIO as GPIO
from operator import itemgetter
# Creates a unique file name by taking the first 12 characters of the sha256 hash from a seed
def create_file_name():
seed_hash = create_seed_hash(seed)
file_name = seed_hash[:12]
file_name += ".txt"
return file_name
# The login screen; Will make sure that only a valid seed is enterd
def log_in():
# Will try to open the account file. In case the file doesn't exist it will create a new account file.
def read_account_data():
try:
with open(file_name, 'r') as account_data:
data = json.load(account_data)
return data
except:
with open(file_name, 'w') as account_data:
data = {}
# Takes the f_index and/or the l_index and saves them in the account file
# "f_index" is the index of the first address with balance and "l_index" is the index of the last address with balance
def write_fal_balance(f_index=0, l_index=0):
if f_index > 0 and l_index > 0:
fal_balance[0]["f_index"] = f_index
fal_balance[0]["l_index"] = l_index
elif f_index > 0:
fal_balance[0]["f_index"] = f_index
elif l_index > 0:
# Sends a request to the IOTA node and gets the current confirmed balance
def address_balance(address):
api = Iota(iota_node)
gna_result = api.get_balances([address])
balance = gna_result['balances']
return balance[0]
# Checks all addresses that are saved in the account file and updates there balance
# start_index can be set in order to ignore all addresses befor the start index