Skip to content

Instantly share code, notes, and snippets.

@peltsippi
peltsippi / wake-up-light-alarm-with-sunrise-effect.yaml
Last active November 19, 2023 13:48 — forked from sbyx/wake-up-light-alarm-with-sunrise-effect.yaml
Home Assistant Blueprint: Wake-up light alarm with sunrise effect
blueprint:
name: Wake-up light alarm with sunrise effect
description: 'A wake-up light alarm with a brightness and color temperature sunrise
effect. Note: Requires date_time_iso sensor in configuration, not manually executable!'
domain: automation
input:
light_entity:
name: Wake-up light entity
description: 'The light to control. Turning it off during the sunrise will keep
it off. Color temperature range is auto-detected.'
#New sierpinski fractal animation:
#Code is sloppy, I'll probably clean it up later:
# coding: utf-8
from images2gif import writeGif
from PIL import Image, ImageDraw, ImageChops
import console
anonymous
anonymous / bip47.py
Created January 22, 2016 08:31
from bitcoin.pyspecials import *
from bitcoin.main import *
from bitcoin.deterministic import *
import re, hmac, hashlib
# Alice's wallet:
# Mnemonic (BIP39): [response seminar brave tip suit recall often sound stick owner lottery motion]
# Hex seed (BIP39): b7b8706d714d9166e66e7ed5b3c61048
@SamouraiDev
SamouraiDev / gist:6aad669604c5930864bd
Last active April 5, 2023 07:41
BIP47 test vectors

##BIP47 Reusable Payment Codes Test Vectors

Results obtained upon implementing BIP47. Payment codes are calculated assuming v1 specification without use of BitMessage.

###Alice's wallet:

Mnemonic (BIP39): [response seminar brave tip suit recall often sound stick owner lottery motion]

Raw entropy (BIP39): b7b8706d714d9166e66e7ed5b3c61048

@wizardofozzie
wizardofozzie / BitStats.py
Last active October 29, 2015 00:34
BitStats.py receives new transactions from Blockchain.info and displays overall stats about them.
import websocket, thread, time, json, datetime, sys, os
def set_exit_handler(func):
if os.name == "nt":
try:
import win32api
win32api.SetConsoleCtrlHandler(func, True)
except ImportError:
version = ".".join(map(str, sys.version_info[:2]))
raise Exception("pywin32 not installed for Python " + version)
#!/usr/bin/env python
import hashlib
import hmac
import time
import requests
import datetime
# Q. Do you have A Websocket API?
# A. Yes, and we strongly recommend you to use it. Please, check our JavaScript websocket implementation for our WebSocket API here:
# https://github.com/blinktrade/frontend/blob/master/jsdev/bitex/api/bitex.js
anonymous
anonymous / file1.py
Created August 26, 2015 10:52
Pasted from IPython
#!/usr/bin/python ## JORDAN arithmetic (OLD) rather than Jacobian ## ## from .py2specials import * from .py3specials import * import binascii import hashlib import re import sys import os import base64 import time import random import hmac from bitcoin.ripemd import * # Elliptic curve parameters (secp256k1) P = 2**256 - 2**32 - 977 N = 115792089237316195423570985008687907852837564279074904382605163141518161494337 A = 0 B = 7 Gx = 55066263022277343669578718895168534326250603453777594175500187360389116729240 Gy = 32670510020758816978083085130507043184471273380659243275938904335757337482424 G = (Gx, Gy) def change_curve(p, n, a, b, gx, gy): global P, N, A, B, Gx, Gy, G P, N, A, B, Gx, Gy = p, n, a, b, gx, gy G = (Gx, Gy) def getG(): return G # Extended Euclidean Algorithm def inv(a, n): lm, hm = 1, 0 low, high = a % n, n while low > 1: r = high//low nm, new = hm-lm*r, high-low*r lm, low, hm, high = nm, new, lm, low return lm % n # JSON access
@omz
omz / touchid.py
Last active November 15, 2023 23:35 — forked from alessaba/TouchID.py
TouchID.py
# coding: utf-8
from objc_util import *
import threading
NSBundle = ObjCClass('NSBundle')
LocalAuthentication = NSBundle.bundleWithPath_('/System/Library/Frameworks/LocalAuthentication.framework')
LocalAuthentication.load()
LAContext = ObjCClass('LAContext')
# authenticate() will raise one of these exceptions when authentication
@gubatron
gubatron / block_size_limit.py
Last active August 14, 2017 20:43
Function to propose accepted maximum block size limit in Bitcoin blockchain.
'''
INITIAL IDEA:
Just to illustrate idea on how I believe the maximum block size should be determined.
My idea stems from a simple scalability metric that affects real users and the desire to use Bitcoin:
Waiting times to get your transactions confirmed on the blockchain.
Anything past 45mins-1 hour should be unnacceptable.
Initially I wanted to measure the mean time for the transactions in blocks to go from being sent by the user
(initial broadcast into mempools) until the transaction was effectively
@wizardofozzie
wizardofozzie / ecmath.py
Created June 11, 2015 12:26
EC_math.py
# https://github.com/wobine/blackboard101
def EccMultiply(xs,ys,Scalar): # Double & add. EC Multiplication, Not true multiplication
if Scalar == 0 or Scalar >= N: raise Exception("Invalid Scalar/Private Key")
ScalarBin = str(bin(Scalar))[2:]
Qx,Qy=xs,ys
global itr
itr += 1
for i in range (1, len(ScalarBin)): # This is invented EC multiplication.
Qx,Qy=ECdouble(Qx,Qy); print "DUB", '%064x' % Qx; print