Skip to content

Instantly share code, notes, and snippets.

View angeloped's full-sized avatar

Angeloped angeloped

  • Philippines
View GitHub Profile
@angeloped
angeloped / probability-distribution.py
Last active September 26, 2019 13:05
Random choice based on probability distribution.
import random
def weighted_choice(choices):
total = sum(w for c, w in choices)
r = random.uniform(0, total)
upto = 0
for c, w in choices:
if upto + w >= r:
break
upto += w
@angeloped
angeloped / aes.py
Created September 28, 2019 09:54 — forked from LuoZijun/aes.py
Python AES
#!/usr/bin/env python
#coding: utf8
import base64
import hashlib
import binascii
from Crypto import Random
from Crypto.Cipher import AES
from os import urandom
@angeloped
angeloped / distributed_key_processing.py
Last active November 22, 2019 12:09
Algorithm for secure multi-circuit encryption key distribution. This will add another extra layer of security when sharing encryption keys for every encrypted requests.
#!/bin/python
# -*- coding: utf-8 -*-
import os
from hashlib import md5
from operator import itemgetter
"""
name: secret_share.py
description: Algorithm for secure multi-circuit key distribution.
@angeloped
angeloped / data_compressor.py
Created October 2, 2019 11:41
Lossless data compression code snippet with the help of zlib DEFLATE (Lempel–Ziv 1977) compression algorithm.
#!/bin/python
import base64
import zlib
import sys
"""
name: data_compressor.py
description: Lossless data compression code snippet with the help of zlib DEFLATE (Lempel–Ziv 1977) compression algorithm.
author: Bryan Angelo Pedrosa
"""
@angeloped
angeloped / lotto.py
Last active October 27, 2019 12:56
lotto lucky number guesser... (for PCSO Lotto only)
#!/usr/bin/python
import time
from random import random
from bisect import bisect
def probdist_choice(choices):
values, weights = zip(*choices)
total = 0
cum_weights = []
@angeloped
angeloped / AnSyn_salary_microeconomics.py
Created October 31, 2019 09:21
Anarcho-Syndicalism/Anarcho-Collectivist salary distribution system. 100% legit no scam. Accurate calaculation.
#!/usr/bin/python
from __future__ import division
"""
name: AnSyn_salary_microeconomics.py
description: Anarcho-Syndicalism/Anarcho-Collectivist salary distribution system. 100% legit no scam. Accurate calaculation.
author: Bryan Angelo Pedrosa
min_salary - the standard minimum pay. no matter what happen.
peak_salary - highest pay if average income per worker reached peak.
@angeloped
angeloped / bcpirates.js
Created November 19, 2019 17:21
The bandcamp pirates. ;P
/*
* title: The bandcamp pirates.
* coded by: Bryan Angelo Pedrosa
* date: 19 November 2019
*/
/* to download album (free version) */
window.location=TralbumData["freeDownloadPage"]
@angeloped
angeloped / geoip.py
Created November 22, 2019 10:55
IP Tracking System with ip-api. Compatible in Python 2.x and 3.x. Try it!
import json
import requests
import webbrowser
def _input(form):
try:
return raw_input(form)
except:
return input(form)
@angeloped
angeloped / autocrop_center_square.php
Created December 16, 2019 06:24
Crop image from center and output a square cropped image; written in PHP language.
<?php
function cropAlign($image, $cropWidth, $cropHeight, $horizontalAlign = 'center', $verticalAlign = 'middle') {
$width = imagesx($image);
$height = imagesy($image);
$horizontalAlignPixels = calculatePixelsForAlign($width, $cropWidth, $horizontalAlign);
$verticalAlignPixels = calculatePixelsForAlign($height, $cropHeight, $verticalAlign);
return imageCrop($image, [
'x' => $horizontalAlignPixels[0],
'y' => $verticalAlignPixels[0],
'width' => $horizontalAlignPixels[1],
@angeloped
angeloped / puzzle.py
Last active December 29, 2019 21:20
Standard Problem Solver For Proof-of-Work System.
import os
from hashlib import sha512
def authBlock():
pass
# auth hash before inserting into blockchain
def authHashPOW(ref):
with open("HashPOWs","a+") as f:
for line in f: