Skip to content

Instantly share code, notes, and snippets.

View HRezaei's full-sized avatar

Hosein Rezaei HRezaei

View GitHub Profile
ECPy==1.2.5
eth_keys==0.3.3
eth_utils==1.10.0
nacl==0.0.0
PyNaCl==1.4.0
requests==2.26.0
stellar_sdk==7.0.0
import binascii
import json
import os
import subprocess
from time import sleep
import ed25519
from ecpy.curves import Curve
from solana.publickey import PublicKey
@HRezaei
HRezaei / GenerateRandomBinaryCode.sql
Created March 25, 2017 11:31
Generate random bit strings in MySQL
DELIMITER $$
CREATE DEFINER=`root`@`localhost` FUNCTION `random_str`() RETURNS char(16) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci
BEGIN
DECLARE chars varchar(16);
DECLARE rs varchar(16);
SET rs = '';
SET chars = 'ABCDEF1234567890';
WHILE (LENGTH(rs) < 16) DO
SET rs = CONCAT(rs, SUBSTRING(chars, RAND() * LENGTH(chars), 1));
END WHILE;
@HRezaei
HRezaei / GenerateRandomBinaryCode.sh
Created March 25, 2017 11:28
Generate random bit strings in bash
cat /dev/urandom | tr -dc 'A-F0-9' | fold -w 16 | head -n 5 | sed -e "s/^/('/" | sed -e "s/$/'),/g" > /tmp/codes.txt
@HRezaei
HRezaei / SolarCalendarDays.sparql
Created January 14, 2017 11:38
Retrieves Days of Solar Calendar in wikidata, try it here: http://tinyurl.com/ztk8fq3
PREFIX entity: <http://www.wikidata.org/entity/>
SELECT * WHERE {
?subject wdt:P361 entity:Q950135.
?subject rdfs:label ?label.
# SERVICE wikibase:label { bd:serviceParam wikibase:language "persian" . }
FILTER (langMatches(lang(?label), "FA"))
}
LIMIT 1000
@HRezaei
HRezaei / IranCities.sparql
Created November 10, 2016 18:12
A sample SPARQL query to fetch cities of Iran with population over 10,000
SELECT DISTINCT ?city ?cityLabel (SAMPLE(?location) AS ?location) (MAX(?population) AS ?population) (SAMPLE(?layer) AS ?layer)
WHERE
{
?city wdt:P31/wdt:P279* wd:Q515;
wdt:P625 ?location;
wdt:P1082 ?population.
FILTER(?population >= 10000).
?city wdt:P17 wd:Q794.
BIND(
IF(?population < 1000000, "<1M",
@HRezaei
HRezaei / hamming_distance.sql
Created November 6, 2016 16:49
Computes hamming distance of two hexadecimal integers
select bit_count((conv('7c0c8e868ee0e988', 16, 10) ^ conv('183e3c1c1e587e02', 16, 10)))