Instantly share code, notes, and snippets.

View pre_vdb_ipdb.py
def debug_opcode(computation):
print('YOUR ARE HERE!')
import ipdb; ipdb.set_trace()
import evm
from evm.vm.opcode import as_opcode
from vyper.opcodes import opcodes as vyper_opcodes
from evm.vm.forks.byzantium.computation import ByzantiumComputation
opcodes = ByzantiumComputation.opcodes.copy()
View test_contract_pyethereum.py
from ethereum.tools import tester
from vyper import compiler
def test_merkle_proof_contract():
tester.languages['vyper'] = compiler.Compiler()
s = tester.Chain() # initialize test chain
contract_code = open('merkleproof.v.py').read() # get source code
contract = s.contract(contract_code, language='vyper') # compile code
View spotify_keybindings
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause" XF86AudioPlay
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop" XF86AudioStop
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next" XF86AudioNext
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous" XF86AudioPrevious
View pyethereum_set_trace_logging.py
from ethereum.slogging import configure_logging
configure_logging(':trace')
View hyperfido.txt
HyperFido - FIDO U2F Security Key
By Jonathan Williams
https://www.amazon.com/review/R1MX4254RVC97T/ref=cm_cr_dp_cmt?ie=UTF8&ASIN=B00WIX4JMC&channel=detail-glance&nodeID=541966&store=pc#wasThisHelpful
This HyperFIDO U2F key is small enough to keep in your pocket or purse at all times and never worry about it. It worked great after getting a fast reply from HyperSECU support about the linux udev rules needed (I don't use windows). I had it set up very quickly with Google services and it worked flawlessly. Hopefully, more services will support U2F in the future.
If you are wondering, here are the udev rules their awesome support recommended. I created a file /etc/udev/rules.d/96-hyperfido.rules and used the first example below because thankfully, I do not have to deal with systemd. If you are unfortunate enough to have to use systemd, please use the second example.
Example 1
View reverse_replace_x_newlines.py
def remove_extra_newlines(input_str, newlines_left=3):
number_of_newlines = input_str.count('\n')
if number_of_newlines > newlines_left:
amount_to_strip = number_of_newlines - newlines_left
return input_str[::-1].replace('\n', ' ', amount_to_strip)[::-1]
else:
return input_str
View fix_pdf.sh
cp original.pdf bak.pdf
gs -o original.pdf -sDEVICE=pdfwrite bak.pdf
View my_token.v.py
# Viper Port of MyToken
# Originally found at https://www.ethereum.org/token
# Public variables of the token
name: public(bytes32)
symbol: public(bytes32)
totalSupply: public(num)
decimals: public(num)
balanceOf: public(num256[address])
View memory_usage.py
import os
class MemoryUsage:
# thanks to http://code.activestate.com/recipes/286222/
def __init__(self):
self._proc_status = '/proc/%d/status' % os.getpid()
self._scale = {
'kB': 1024.0, 'mB': 1024.0 * 1024.0,
View get_filefield_models.py
from django.apps import apps
def get_models_with_file_fields():
for model in apps.get_models():
if any(field.__class__.__name__ in ('FileField', 'ImageField')
for field in model._meta.fields):
print(model)