Skip to content

Instantly share code, notes, and snippets.

# implementation
from pymouse import PyMouseEventMeta
import systembridge
from threading import Thread
class PyMouseEvent(PyMouseEventMeta):
def __init__(self):
click_tap = systembridge.get_event_tap(mousepress | mouserelease)
move_tap = systembridge.get_event_tap(mousemove)
@jgomezdans
jgomezdans / random.py
Created May 15, 2010 23:24
Random colormap for matplotli
import matplotlib,numpy
import pylab
# A random colormap for matplotlib
cmap = matplotlib.colors.ListedColormap ( numpy.random.rand ( 256,3))
pylab.imshow ( Z, cmap = cmap)
pylab.show()
@mbostock
mbostock / .block
Last active May 9, 2020 16:58
Polymaps + D3
license: gpl-3.0
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@Plutor
Plutor / pinary.py
Last active October 21, 2020 10:56
Decimal to pinary conversion
"""Convert decimal numbers to pinary (base pi).
Fractional and even irrational bases are possible, but aren't really useful for
anything. Base pi has four digits: 0, 1, 2, and 3. What's interesting is that
there's some "space" between the highest digit and the base, which means that
there are numbers with multiple valid representations. You'll notice:
decimal 7.000000 = pinary 20.2021120021
decimal 8.000000 = pinary 21.2021120021
decimal 9.000000 = pinary 22.2021120021
@HaiyangXu
HaiyangXu / Server.py
Created May 18, 2014 14:00
A simper python http server can handle mime type properly
# -*- coding: utf-8 -*-
#test on python 3.4 ,python of lower version has different module organization.
import http.server
from http.server import HTTPServer, BaseHTTPRequestHandler
import socketserver
PORT = 8080
Handler = http.server.SimpleHTTPRequestHandler
/*
Foundation Tip Contract
Address: 0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359
Bitcoin Shapeshift Address: 1GyczDXWjFbmhx2Qau4ham3zJqNEP8UcEG (if transaction fails it is sent to 39BaMQCphFXyYAvcoGpeKtnptLJ9v6cdFY instead)
Interface: [{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"proposals","outputs":[{"name":"recipient","type":"address"},{"name":"amount","type":"uint256"},{"name":"description","type":"string"},{"name":"votingDeadline","type":"uint256"},{"name":"executed","type":"bool"},{"name":"proposalPassed","type":"bool"},{"name":"numberOfVotes","type":"uint256"},{"name":"currentResult","type":"int256"},{"name":"proposalHash","type":"bytes32"}],"type":"function"},{"constant":false,"inputs":[{"name":"proposalNumber","type":"uint256"},{"name":"transactionBytecode","type":"bytes"}],"name":"executeProposal","outputs":[{"name":"result","type":"int256"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"memberId","outputs":[{"name":"","type":"uint
@srph
srph / oauth.js
Created February 21, 2016 13:50
axios: interceptor which includes your oauth token in every request as an Authorization header
import axios from 'axios';
// You can use any cookie library or whatever
// library to access your client storage.
import cookie from 'cookie-machine';
axios.interceptors.request.use(function(config) {
const token = cookie.get(__TOKEN_KEY__);
if ( token != null ) {
config.headers.Authorization = `Bearer ${token}`;
@kiran
kiran / lisp_parser.py
Created June 7, 2016 02:01
writing a simple lisp parser in python
#!/usr/bin/python
# turn lisp statements into an AST
# going off a super basic grammar:
# - atoms are numbers or symbols
Number = (int, float)
Symbol = str
Atom = (Number, Symbol)
from astropy.coordinates import EarthLocation,SkyCoord
from astropy.time import Time
from astropy import units as u
from astropy.coordinates import AltAz
observing_location = EarthLocation(lat='52.2532', lon='351.63910339111703', height=100*u.m)
observing_time = Time('2017-02-05 20:12:18')
aa = AltAz(location=observing_location, obstime=observing_time)
coord = SkyCoord('4h42m', '-38d6m50.8s')