Skip to content

Instantly share code, notes, and snippets.

public class Program {
private static async System.Threading.Tasks.Task Listen(System.Net.HttpListener listener) {
while (true) {
try {
System.Net.HttpListenerContext context =
await listener.GetContextAsync().ConfigureAwait(false);
System.Net.HttpListenerRequest request = context.Request;
System.Net.HttpListenerResponse response = context.Response;
string text = System.Web.HttpUtility.UrlDecode(request.Url.AbsolutePath).Substring(1);
System.Console.WriteLine(text);
#include <stdio.h>
#include <time.h>
unsigned long Rand(const unsigned long x) {
return ((x << 16) + (x << 1) + x) & 0x7FFFFFFF;
}
unsigned long RandInt(const unsigned long x, const unsigned long a,
const unsigned long b) {
return a + x / (0x7FFFFFFF / (b - a + 1) + 1);
}
#include <iostream>
#include <iterator>
#include <stack>
#include <string>
#include <vector>
class BruteForceIterator
: public std::iterator<std::input_iterator_tag, std::string> {
public:
BruteForceIterator() : length(0), done(true) {}
BruteForceIterator(int length, const std::vector<std::string>& strings)
#include <ctype.h>
#include <stdio.h>
unsigned char IsSafe(const unsigned char *const board, const unsigned char pos,
const unsigned char num) {
const unsigned char row = pos / 9, col = pos % 9, row_start = row / 3 * 27,
col_start = col / 3 * 3;
unsigned char i;
for (i = 0; i < 9; ++i)
if (board[row * 9 + i] == num || board[i * 9 + col] == num ||
board[row_start + i % 3 * 9 + col_start + i / 3] == num)
@warm-ice0x00
warm-ice0x00 / xor_cipher.c
Last active March 29, 2023 15:34
Known plaintext attack XOR cipher.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const size_t kMaxKeyLen = 8;
unsigned char *hex_to_bytes(const char *hex, const size_t len) {
size_t final_len = len / 2 + (len % 2 != 0);
unsigned char *const result = (unsigned char *)malloc(final_len), *p = result;
if (result == NULL) {
perror("malloc");
exit(EXIT_FAILURE);
#include <iostream>
template <class T>
class Rational {
public:
Rational(T a, T b) : p(a), q(b) {
if (b == 0) throw std::domain_error("ZeroDivisionError");
while (b) {
T t = b;
b = a % b;
a = t;
@warm-ice0x00
warm-ice0x00 / Upload-Files.ps1
Last active August 18, 2021 02:43
Universal Git Script (PowerShell Version)
[CmdletBinding()] param([Parameter(Mandatory = $true)] [string]$Url)
$dotGitPath = Join-Path -Path $PWD -ChildPath .git
Remove-Item -LiteralPath $dotGitPath -Force -Recurse -ErrorAction SilentlyContinue
& git init
& git remote add origin $Url
& git add -A
& git reset $MyInvocation.MyCommand.Definition
& git commit -am 'Initial commit'
& git push -f origin master
Remove-Item -LiteralPath $dotGitPath -Force -Recurse
@warm-ice0x00
warm-ice0x00 / upload.sh
Last active January 8, 2022 20:00
Universal Git Script
#!/bin/sh
[ -z "$1" ] && echo 'No repository URL provided!' >&2 && exit 1
rm -rf .git
git init
git remote add origin "$1"
git add -A
git reset "$0"
git commit -am 'Initial commit'
git push -f origin master
rm -rf .git