Skip to content

Instantly share code, notes, and snippets.

@andrewpedia
andrewpedia / rust.md
Created November 29, 2021 12:42 — forked from niklasad1/rust.md
Rust, cargo commands

Expand macros

$ cargo rustc -- --pretty expanded -Z unstable-options

Emit asm

$ cargo rustc -- --emit asm && cat target/debug/deps/project_name-hash.s

Emit llvm-ir

$ cargo rustc -- --emit llvm-ir && cat target/debug/deps/project_name-hash.ll

Emit HIR

@andrewpedia
andrewpedia / setup-theos-on-cygwin.sh
Created October 25, 2021 09:40 — forked from supermamon/setup-theos-on-cygwin.sh
Script to install theos on windows/cygwin
# Script is available at https://github.com/supermamon/install-theos
# Or if you trust me run
curl -LO https://git.io/install-theos && bash install-theos
@andrewpedia
andrewpedia / aria2c_webUI.md
Created July 7, 2021 13:11 — forked from GAS85/aria2c_webUI.md
Aria2 + Ubuntu 18.04 + Apache2 + Web UI
OS: Ubuntu 18.04 Apache/2.4.18 1.0.2g-1ubuntu4.10
Aim: to install Aria2 with WebUI and secure Token.
IP Addr of your Aria2 server is 192.168.0.111
Your local IP network is 192.168.0.0/24

Aria 2

1. Installation

Install aria2 package:

@andrewpedia
andrewpedia / data_loading_utils.py
Created March 24, 2021 08:39 — forked from iyvinjose/data_loading_utils.py
Read large files line by line without loading entire file to memory. Supports files of GB size
def read_lines_from_file_as_data_chunks(file_name, chunk_size, callback, return_whole_chunk=False):
"""
read file line by line regardless of its size
:param file_name: absolute path of file to read
:param chunk_size: size of data to be read at at time
:param callback: callback method, prototype ----> def callback(data, eof, file_name)
:return:
"""
def read_in_chunks(file_obj, chunk_size=5000):
@andrewpedia
andrewpedia / gist:90c63452e3cb30595e5a9eaa05e2bd8f
Created February 12, 2021 05:18 — forked from eliben/gist:5797351
Generic regex-based lexer in Python
#-------------------------------------------------------------------------------
# lexer.py
#
# A generic regex-based Lexer/tokenizer tool.
# See the if __main__ section in the bottom for an example.
#
# Eli Bendersky ([email protected])
# This code is in the public domain
# Last modified: August 2010
#-------------------------------------------------------------------------------
@andrewpedia
andrewpedia / revprox.go
Created February 6, 2021 12:05 — forked from thurt/revprox.go
Simple reverse proxy in Go (forked from original to use a struct instead of a closure)
package main
import(
"log"
"net/url"
"net/http"
"net/http/httputil"
)
func main() {
@andrewpedia
andrewpedia / revprox.go
Created February 6, 2021 12:05 — forked from JalfResi/revprox.go
Simple reverse proxy in Go
package main
import(
"log"
"net/url"
"net/http"
"net/http/httputil"
)
func main() {
@andrewpedia
andrewpedia / RSA_example.py
Created October 31, 2020 05:46 — 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
@andrewpedia
andrewpedia / genesis.json
Created October 30, 2020 13:20 — forked from dickolsson/genesis.json
Example genesis.json for an Ethereum blockchain
{
"config": {
"chainId": 33,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"nonce": "0x0000000000000033",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
@andrewpedia
andrewpedia / nginx
Created October 16, 2020 12:44 — forked from brunoqs/gist:219f5e9852b718d831bce502bdd2e511
Easy deploy Django Nginx + gunicorn and Vuejs or Reactjs
---------------- Django Nginx + gunicorn ----------------
Primeiro rode o gunicorn no repositorio do projeto:
$ gunicorn --bind 0.0.0.0:8000 my_academic.wsgi &
Depois crie a seguinte configuração no Nginx (/etc/nginx/sites-available):
server {
access_log /home/user/code_back/logs/access.log;
error_log /home/user/code_back/logs/error.log;