Skip to content

Instantly share code, notes, and snippets.

View samuraisam's full-sized avatar

Samuel Sutch samuraisam

View GitHub Profile
@samuraisam
samuraisam / deep_eq.py
Last active March 29, 2024 22:17
Deep Equality Test for Nested Python Structures
#Copyright (c) 2010-2013 Samuel Sutch [samuel.sutch@gmail.com]
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in
@samuraisam
samuraisam / parse_accept.py
Created May 16, 2012 21:43
Parse an accept header in Python w/ support for vendor types
# The author disclaims copyright to this source code. In place of a legal
# notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
# It is based on a snipped found in this project:
# https://github.com/martinblech/mimerender
@samuraisam
samuraisam / builder.py
Created June 16, 2014 16:13
Python: Fluent Builder Pattern
class ObjectPermissions(object):
perms_map = {}
specific_object_perms = ()
@classmethod
def require(cls, *new_perms):
class SpecificObjectPermissions(cls):
specific_object_perms = new_perms
return SpecificObjectPermissions
package org.brd.blockchaindb.chaindata.cassandra.cql;
import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@samuraisam
samuraisam / genvendor.py
Created April 12, 2017 03:38
Generates a Go vendor directory in a bazel workspace
#!/usr/bin/env python3
import ast
import collections
import os
import subprocess
import sys
import time
{
"transaction_id": "bitcoin-testnet:e6d0bbd26772456dc0e64221701e734854737476fcb23a0f77d721e5f27a9685",
"identifier": "e6d0bbd26772456dc0e64221701e734854737476fcb23a0f77d721e5f27a9685",
"hash": "5c6fb67fc71a80dbb0853db1b00f7a608426bbaf1d8a63125a70fe524cdbe5b7",
"blockchain_id": "bitcoin-testnet",
"timestamp": "1970-01-19T03:18:15.847+0000",
"_embedded": {
"transfers": [
{
"transfer_id": "bitcoin-testnet:e6d0bbd26772456dc0e64221701e734854737476fcb23a0f77d721e5f27a9685:0",
{
"_embedded": {
"blockchains": [
{
"name": "Bitcoin Cash",
"id": "bitcoincash-mainnet",
"native_currency_id": "bitcoincash-mainnet:__native__",
"fee_estimates": [
{
"fee": {
@samuraisam
samuraisam / models.py
Last active February 22, 2019 21:50
Using STS (Security Token Service) to grant access for a federated user to a s3 bucket prefix
import json
import boto
from django.db import models
from django.conf import settings
from django.contrib.auth.models import User
class UploadToken(models.Model):
user = models.ForeignKey(User)
created = models.DateTimeField(auto_now_add=True)
pragma solidity ^0.4.18;
// File: contracts/zeppelin-solidity-1.4/Ownable.sol
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
ETHERSCAN:
0x60606040526000600360146101000a81548160ff0219169083151502179055506040805190810160405280600b81526020017f427265616420546f6b656e000000000000000000000000000000000000000000815250600490805190602001906200006c92919062000107565b506040805190810160405280600381526020017f425244000000000000000000000000000000000000000000000000000000000081525060059080519060200190620000ba92919062000107565b50601260065533600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550620001b6565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200014a57805160ff19168380011785556200017b565b828001600101855582156200017b579182015b828111156200017a5782518255916020019190600101906200015d565b5b5090506200018a91906200018e565b5090565b620001b391905b80821115620001af57600081600090555060010162000195565b5090565b90565b61181080620001c66000396000f3006060604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463fffff