Skip to content

Instantly share code, notes, and snippets.

@kennethreitz
kennethreitz / 0_urllib2.py
Created May 16, 2011 00:17
urllib2 vs requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
@DrSkippy
DrSkippy / urls.py
Created March 20, 2012 00:22
Lengthen Short URL with service longurl.org
#!/usr/bin/env python
#
# Scott Hendrickson
# 2012-03-18
#
import sys
import re
import urllib
import httplib2
@pudquick
pudquick / pipista.py
Created November 20, 2012 07:23
pipista - pip module (for installing other modules) for Pythonista
import os, os.path, sys, urllib2, requests
class PyPiError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
def _chunk_report(bytes_so_far, chunk_size, total_size):
if (total_size != None):
@cormacrelf
cormacrelf / OpenURL.py
Created January 20, 2013 13:35
open url in safari from pythonista
# a bit of a hack
# by Cormac Relf - cormacrelf.com - @cormacrelf
# Opens the url on the clipboard in Safari
# by opening Google Chrome with an x-callback-url
# that takes you to the same url in Safari.
# I guess you could just open it in googlechrome://
import webbrowser
anonymous
anonymous / Pypi.py
Created March 26, 2013 04:46
Pypi
import urllib
import tarfile
import shutil
import console
import os
class Installer(object):
name = None
version = None
firstLetter = None
@laurenarcher
laurenarcher / bitconvert.py
Last active June 14, 2022 07:28
Simple python bitcoin currency converter using the Bitcoin Charts API. Documentation here: http://bitcoincharts.com/about/markets-api/
import urllib2
import json
data = urllib2.urlopen("http://api.bitcoincharts.com/v1/weighted_prices.json")
def convert_to_bitcoin(amount, currency):
bitcoins = json.loads(data.read())
converted = float(bitcoins[currency]["24h"]) * amount
print converted
_ =r"""A(W//2,*M(3*G
*G*V(2*J%P),G,J,G)+((M((J-T)
*V((G-S)%P),S,T,G)if(S@(G,J))if(W%
2@(S,T)))if(W@(S,T);H=2**256;import&hash
lib&as&h,os,re,binas cii&as&k;J$:int(k.b2
a_hex(W),16);C$:C(W// 58) +[W%58]if(W@[];X
=h.new("ripemd1 60 ");Y$:h.sha256(W).
digest();I$d=32: I(W//256,d-1)+bytes
([W%256])if(d>0@b""; U$:J(k.a2b_base6
4(W));f=J(os.urandom (64))% (H-U(b"AUVRIxlQ
@nlitsme
nlitsme / curve_example.py
Last active April 9, 2024 16:48
example of bitcoin curve calculations in python
from __future__ import print_function, division
"""
Example of how calculations on the secp256k1 curve work.
secp256k1 is the name of the elliptic curve used by bitcoin
see http://bitcoin.stackexchange.com/questions/25382
"""
## the prime modules used in the elliptic curve coordinate calculations
p = 2**256 - 2**32 - 977
@kanzure
kanzure / bitcoin_spray.py
Created May 29, 2014 04:26
Send bitcoin from coinbase.com to a deterministic wallet by "spraying", so as to achieve a better distribution of eggs in baskets or something equally tasty.
"""
Bitcoin spray: distribute BTC from a coinbase.com account into many addresses
generated by a deterministic wallet (an electrum wallet).
1.0 BTC ->
0.01 BTC
0.01 BTC
0.01 BTC
etc..
@CoinWhisperer
CoinWhisperer / burn-btc
Last active November 2, 2021 17:38
A simple python program to create bitcoin burn addresses.
#! /usr/bin/env python
"""
burn-btc: create a bitcoin burn address
By James C. Stroud
This program requries base58 (https://pypi.python.org/pypi/base58/0.2.1).
Call the program with a template burn address as the only argument::