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
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); |
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
#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); | |
} |
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
#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) |
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
#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) |
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
#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); |
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
#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; |
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
[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 |
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/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 |