Skip to content

Instantly share code, notes, and snippets.

View notcod's full-sized avatar
💭
I may be slow to respond.

notcod

💭
I may be slow to respond.
View GitHub Profile
<VirtualHost *:80>
ServerName default.example.com
Redirect permanent / https://default.example.com/
</VirtualHost>
<VirtualHost *:443>
ServerAdmin [email protected]
ServerName default.example.com
DocumentRoot /var/www/default
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
@notcod
notcod / header_http_status_codes.php
Created February 17, 2023 18:48 — forked from phoenixg/header_http_status_codes.php
PHP header() for sending HTTP status codes
<?php
/*
参考自:
http://darklaunch.com/2010/09/01/http-status-codes-in-php-http-header-response-code-function
http://snipplr.com/view/68099/
*/
function HTTPStatus($num) {
$http = array(
@notcod
notcod / auto_git_file.md
Created December 30, 2022 22:08 — forked from darencard/auto_git_file.md
Automatic file git commit/push upon change

Please see the most up-to-date version of this protocol on my blog at https://darencard.net/blog/.

Automatically push an updated file whenever it is changed

Linux

  1. Make sure inotify-tools is installed (https://github.com/rvoicilas/inotify-tools)
  2. Configure git as usual
  3. Clone the git repository of interest from github and, if necessary, add file you want to monitor
  4. Allow username/password to be cached so you aren't asked everytime
import hashlib
import binascii
def hashIt(firstTxHash, secondTxHash):
# Reverse inputs before and after hashing
# due to big-endian
unhex_reverse_first = binascii.unhexlify(firstTxHash)[::-1]
unhex_reverse_second = binascii.unhexlify(secondTxHash)[::-1]
concat_inputs = unhex_reverse_first+unhex_reverse_second
from hashlib import sha256
def litEndian(hexa):
return int.from_bytes(bytearray.fromhex(hexa.replace('0x', '')), byteorder='little')
def Format_8(m):
return str('{0:08x}'.format(litEndian('{0:08x}'.format(m))))
def Format_64(m):
return str('{0:064x}'.format(litEndian('{0:064x}'.format(m))))
def secp256k1(z):
z = str(bin(z))[2:]
l = len(z)
p = 115792089237316195423570985008687907853269984665640564039457584007908834671663
x = Gx = 55066263022277343669578718895168534326250603453777594175500187360389116729240
y = Gy = 32670510020758816978083085130507043184471273380659243275938904335757337482424
for i in range(1, l):
lm, hm = 1, 0
lw, hi = 2*y % p, p
while lw > 1:
@notcod
notcod / ProofOfExistence.sol
Created September 17, 2021 21:36 — forked from ageyev/ProofOfExistence.sol
This smartcontract is used to store documents text on the Ethereum blockchain and to get the document by document's hash (sha256).
/*
This smartcontract is used to store documents text on the Ethereum blockchain
and to get the document by document's hash (sha256).
*/
contract ProofOfExistence{
/* ---- Public variables: */
string public created;
@notcod
notcod / s
Created August 1, 2021 09:54
def func():
z = "01010011100101"
l = len(z)
p = 115792089237316195423570985008687907853269984665640564039457584007908834671663
x = Gx = 55066263022277343669578718895168534326250603453777594175500187360389116729240
y = Gy = 32670510020758816978083085130507043184471273380659243275938904335757337482424
for i in range(1, l):
lm, hm = 1, 0
lw, hg = 2*y % p, p
while lw > 1:
@notcod
notcod / Simple ETH gen Python
Created August 1, 2021 00:22
Simple ETH gen Python
from operator import xor
from functools import reduce
from random import randrange
Rc = [
0x0000000000000001, 0x0000000000008082, 0x800000000000808A, 0x8000000080008000,
0x000000000000808B, 0x0000000080000001, 0x8000000080008081, 0x8000000000008009,
0x000000000000008A, 0x0000000000000088, 0x0000000080008009, 0x000000008000000A,
0x000000008000808B, 0x800000000000008B, 0x8000000000008089, 0x8000000000008003,
0x8000000000008002, 0x8000000000000080, 0x000000000000800A, 0x800000008000000A,
@notcod
notcod / Python3 create random ethereum addresses
Created August 1, 2021 00:13
Python3 create random ethereum addresses
from operator import xor
from functools import reduce
from random import randrange
from web3.auto.infura import w3
Rc = [
0x0000000000000001, 0x0000000000008082, 0x800000000000808A, 0x8000000080008000,
0x000000000000808B, 0x0000000080000001, 0x8000000080008081, 0x8000000000008009,
0x000000000000008A, 0x0000000000000088, 0x0000000080008009, 0x000000008000000A,
0x000000008000808B, 0x800000000000008B, 0x8000000000008089, 0x8000000000008003,