This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function curPageURL() { | |
$pageURL = 'http'; | |
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} | |
$pageURL .= "://"; | |
if ($_SERVER["SERVER_PORT"] != "80") { | |
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; | |
} else { | |
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import socket | |
import threading | |
import select | |
import sys | |
terminateAll = False | |
class ClientThread(threading.Thread): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Very simple HTTP server in python (Updated for Python 3.7) | |
Usage: | |
./dummy-web-server.py -h | |
./dummy-web-server.py -l localhost -p 8000 | |
Send a GET request: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dns.resolver import Resolver | |
# make a system resolver using /etc/resolv.conf | |
sys_r = Resolver() | |
dns = ['ns1.dreamhost.com', 'ns2.dreamhost.com', 'ns3.dreamhost.com'] | |
dreamhost_dns = [ item.address for server in dns for item in sys_r.query(server) ] | |
# a resolver using dreamhost dns server | |
dreamhost_r = Resolver() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
import json | |
data = urllib2.urlopen("http://api.bitcoincharts.com/v1/weighted_prices.json") | |
def convert_to_bitcoin(amount, currency): | |
bitcoins = json.loads(data.read()) | |
converted = float(bitcoins[currency]["24h"]) * amount | |
print converted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# keydown data from the web | |
# http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes | |
map = | |
backspace: 8 | |
tab: 9 | |
enter: 13 | |
shift: 16 | |
ctrl: 17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir -p ~/.ssh | |
# generate new personal ed25519 ssh keys | |
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "rob thijssen <[email protected]>" | |
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_robtn -C "rob thijssen <[email protected]>" | |
# generate new host cert authority (host_ca) ed25519 ssh key | |
# used for signing host keys and creating host certs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/ | |
# generate server.xml with the following command: | |
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes | |
# run as follows: | |
# python simple-https-server.py | |
# then in your browser, visit: | |
# https://localhost:4443 | |
import BaseHTTPServer, SimpleHTTPServer | |
import ssl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'Few years ago, I remember fucking around with this so called "Hacked By Godzilla" virus. | |
'It was a Visual Basic Script with a filename MS32DLL.dll.vbs that fucks up Internet | |
'Explorer title bar. | |
'I have been into writing simple Windows OS viruses before the time I learned about | |
'this fucking VBS virus. | |
'We all know that the famous "I LOVE YOU" virus was a Visual Basic Script (VBS) too | |
'and it gave me an idea to test | |
'if that scripting language can still be reliable to fuck up peoples computer that time. | |
'What I did was, I only replaced "MS32DLL" with "FS6519", pressing Ctrl + H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def calcPi(): | |
q, r, t, k, n, l = 1, 0, 1, 1, 3, 3 | |
while True: | |
if 4*q+r-t < n*t: | |
yield n | |
nr = 10*(r-n*t) | |
n = ((10*(3*q+r))//t)-10*n | |
q *= 10 |
OlderNewer