Skip to content

Instantly share code, notes, and snippets.

View matin's full-sized avatar

Matin Tamizi matin

View GitHub Profile
import asyncio
import time
from functools import partial
from typing import Any, Callable, Optional
async def create_awaitable(func: Callable, *args, **kwargs) -> Any:
loop = asyncio.get_running_loop()
return await loop.run_in_executor(None, partial(func, *args, **kwargs))
@matin
matin / certificar_stp.py
Created December 30, 2019 15:01
dar de alta nueva cuenta y registrar un orden
import datetime as dt
from stpmex import Client
PKEY = """Bag Attributes
friendlyName: prueba
localKeyID: 54 69 6D 65 20 31 33 32 34 35 39 35 30 31 35 33 33 30
Key Attributes: <No Attributes>
-----BEGIN ENCRYPTED PRIVATE KEY-----
@matin
matin / clabe_enums.py
Created September 10, 2018 23:57
validate bank code for CLABE
from enum import Enum
class BankCode(Enum):
BANAMEX = '002'
BBVA_BANCOMER = '012'
SANTANDER = '014'
def validate_bank_code(bank_code: str) -> bool:
### Keybase proof
I hereby claim:
* I am matin on github.
* I am matin (https://keybase.io/matin) on keybase.
* I have a public key ASCViy2GV3VMclPpFPFveI1Nh2vpy4uUw_60r4P7LML9-Ao
To claim this, I am signing this object:
@matin
matin / gist:4585229
Last active December 11, 2015 10:18
override default selector style
/* month / year expiry stuff */
.select {
height: 24px;
border: 1px solid #ccc;
border-top: 1px solid #888;
padding: 0px 0 0 0px;
background: url(https://www.poundpay.com/images/dropdown.png) no-repeat right #fff;
-webkit-appearance: none;
-moz-appearance: none;
overflow: hidden;
require 'balanced'
# create a test marketplace
api_key = Balanced::ApiKey.new.save
Balanced.configure(api_key.secret)
marketplace = Balanced::Marketplace.new.save
# charge $100.00 on a card
buyer = Balanced::Account.new(
:email_address => "[email protected]",
@matin
matin / test-psql-ondelete-cascade.py
Created December 10, 2010 22:46
Test SQLAlchemy use of PostgreSQL ON DELETE CASCADE
import unittest
from sqlalchemy import create_engine
from sqlalchemy import Column, Integer
from sqlalchemy import String
from sqlalchemy import Text
from sqlalchemy import ForeignKey
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import scoped_session
from sqlalchemy.orm import relationship
@retry(3)
def fails_sometimes():
...
def retry(tries):
def decorator(function):
def decorated_function(*args, **kwargs):
tried = 0
while tried <= tries:
try:
return function(*args, **kwargs)
except Exception, exc:
tried += 1
raise exc
import unittest
import copy
from sqlalchemy import create_engine, Column, Integer, PickleType
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base
from mechanize import Browser
from mechanize._clientcookie import CookieJar