Skip to content

Instantly share code, notes, and snippets.

@Asoul
Asoul / bitfinex-lending-bot.py
Last active October 30, 2023 09:28
Bitfinex lending bot
import time
import base64
import json
import hmac
import hashlib
import requests
URL = 'https://api.bitfinex.com'
API_VERSION = '/v1'
API_KEY = ''
@Asoul
Asoul / ripgrep 13.0.0 doc
Created July 7, 2022 13:33
ripgrep 13.0.0 doc
ripgrep 13.0.0
Andrew Gallant <jamslam@gmail.com>
ripgrep (rg) recursively searches the current directory for a regex pattern.
By default, ripgrep will respect gitignore rules and automatically skip hidden
files/directories and binary files.
Use -h for short descriptions and --help for more details.
Project home page: https://github.com/BurntSushi/ripgrep
window.i18n = window.i18n || {};
i18n._langCache = {}
i18n._availableLangs = [
'en',
'zh-TW',
'ja'
]
@Asoul
Asoul / crontab
Created July 30, 2020 16:41
Ptt daily auto login script
3 5 * * * /opt/apps/ptt.sh
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# Execute function in prompt
setopt PROMPT_SUBST
# Enable color in prompt
good_nums = {1,
3,
5,
6,
7,
8,
11,
13,
15,
16,
@Asoul
Asoul / flask_pymongo_retry_on_reconnect_error.py
Created June 24, 2018 13:20 — forked from inactivist/flask_pymongo_retry_on_reconnect_error.py
Simple decorator for flask and mongoengine/pymongo to auto-retry with delay on pymongo.errors.AutoReconnect exception in a view or other function
"""
Simple view decorator for flask and mongoengine/pymongo to auto-retry with delay on
pymongo.errors.AutoReconnect exception.
"""
from functools import wraps
import time
from pymongo.errors import AutoReconnect
import flask
@Asoul
Asoul / RSA_example.py
Created June 5, 2018 15:11 — forked from syedrakib/RSA_example.py
An example of asymmetric encryption in python using a public/private keypair - utilizes RSA from PyCrypto library
# Inspired from http://coding4streetcred.com/blog/post/Asymmetric-Encryption-Revisited-(in-PyCrypto)
# PyCrypto docs available at https://www.dlitz.net/software/pycrypto/api/2.6/
from Crypto import Random
from Crypto.PublicKey import RSA
import base64
def generate_keys():
# RSA modulus length must be a multiple of 256 and >= 1024
modulus_length = 256*4 # use larger value in production

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@Asoul
Asoul / flask_context.py
Created December 19, 2017 20:45 — forked from guyskk/flask_context.py
理解Flask上下文环境
import flask
from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
return "hello"