Skip to content

Instantly share code, notes, and snippets.

@samuelchen
samuelchen / windows-keys.md
Created November 3, 2024 16:51 — forked from rvrsh3ll/windows-keys.md
Windows Product Keys

NOTE

These are NOT product / license keys that are valid for Windows activation.
These keys only select the edition of Windows to install during setup, but they do not activate or license the installation.

Index

# install_certifi.py
#
# sample script to install or update a set of default Root Certificates
# for the ssl module. Uses the certificates provided by the certifi package:
# https://pypi.python.org/pypi/certifi
import os
import os.path
import ssl
import stat
#coding=utf8
import re, sys, time, os
from ctypes import Structure, c_short, windll, byref
try:
from shutil import get_terminal_size
except:
from backports.shutil_get_terminal_size import get_terminal_size
CN_REGEX = re.compile(u'[\u4e00-\u9fff]')
@samuelchen
samuelchen / python-nameserver.py
Created October 27, 2020 15:38 — forked from dustyfresh/python-nameserver.py
DNS nameserver implemented in python
#!/usr/bin/env python3
import sys
from datetime import datetime
import time
from time import sleep
from dnslib import DNSLabel, QTYPE, RD, RR, RCODE
from dnslib import A, AAAA, CNAME, MX, NS, SOA, TXT
from dnslib.server import DNSServer
@samuelchen
samuelchen / change_sshd_port_allowusers.sh
Last active March 28, 2024 16:00
To change sshd port, add allow users, prevent root to login.
#!/usr/local/env sh
PORT="30022"
sudo sed -i "s/#Port 22/Port ${PORT}/g" /etc/ssh/sshd_config
sudo sed -i "s/#PermitRootLogin yes/PermitRootLogin no/g" /etc/ssh/sshd_config
echo ""|sudo tee -a /etc/ssh/sshd_config
echo "AllowUsers samuel"|sudo tee -a /etc/ssh/sshd_config
echo ""|sudo tee -a /etc/ssh/sshd_config
@samuelchen
samuelchen / install_fail2ban.sh
Last active April 29, 2019 08:46
Install fail2ban on centos 7
#!/bin/sh
# disable firewalld
systemctl stop firewalld
systemctl mask firewalld
# disable selinux (required if change sshd port)
# don't change /etc/sysconfig/selinux, its softlink. "sed -i" will make softlink a real file.
# sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
# setenforce 0
@samuelchen
samuelchen / encoding_encryption.py
Last active January 14, 2019 05:20
BASE4, MD5, SHA1, SHA256, AES, RSA encoding and encryption sample and benchmark in python
#!/user/env python
# by Samuel <me@samuelchen.net>
import json
import base64
import hashlib
import datetime
from Crypto.Cipher import AES, PKCS1_v1_5
from Crypto.PublicKey import RSA, DSA
from Crypto import Random
@samuelchen
samuelchen / server.py
Created November 26, 2018 16:48 — forked from herberthamaral/server.py
Django + Tornado example
#!/usr/bin/python
import django.core.handlers.wsgi
import os, signal, functools, time
import tornado.httpserver
import tornado.ioloop
import tornado.wsgi
from tornado.options import options, define
try:
define("port", default=8888, help="run on the given port", type=int)
/*jslint undef: true, nomen: true, eqeqeq: true, plusplus: true, newcap: true, immed: true, browser: true, devel: true, passfail: false */
/*global window: false, readConvertLinksToFootnotes: false, readStyle: false, readSize: false, readMargin: false, Typekit: false, ActiveXObject: false */
var dbg = (typeof console !== 'undefined') ? function(s) {
console.log("Readability: " + s);
} : function() {};
/*
* Readability. An Arc90 Lab Experiment.
* Website: http://lab.arc90.com/experiments/readability
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal