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 string2ByteArray($string) { | |
return unpack('C*', $string); | |
} | |
function byteArray2String($byteArray) { | |
$chars = array_map("chr", $byteArray); | |
return join($chars); | |
} |
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 | |
$host = "127.0.0.1"; | |
$port = 3000; | |
set_time_limit(0); | |
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); | |
$result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n"); | |
$result = socket_listen($socket, 3) or die("Could not set up socket listener\n"); | |
while(true) { | |
$spawn = socket_accept($socket) or die("Could not accept incoming connection\n"); |
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
# Creating a new CA | |
# 1. create the CA key | |
#openssl genrsa -out ca-key.pem 1024 -config openssl.cnf | |
openssl genrsa -des3 -out ca-key.pem 1024 -config openssl.cnf | |
openssl rsa -in ca-key.pem -out ca-key.pem # rm pass | |
# 2. create a certificate signing request | |
openssl req -days 365 -new -key ca-key.pem -out ca.csr -config openssl.cnf |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace MyCollections | |
{ | |
/// <summary> | |
/// Represents a strongly typed list of disposable objects that can be accessed by index. | |
/// Provides methods to search, sort, and manipulate lists and disposes all contained objects. |
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 <ctime> | |
class Timer | |
{ | |
public: | |
Timer() { clock_gettime(CLOCK_REALTIME, &beg_); } | |
double elapsed() { | |
clock_gettime(CLOCK_REALTIME, &end_); |
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
using System; | |
using System.Threading; | |
static class Program { | |
static void Main() { | |
Console.Write("Performing some task... "); | |
using (var progress = new ProgressBar()) { | |
for (int i = 0; i <= 100; i++) { | |
progress.Report((double) i / 100); |
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
#pragma once | |
class SomeClass | |
{ | |
public: | |
SomeClass(); | |
~SomeClass(); | |
SomeClass(const SomeClass&); | |
SomeClass& SomeClass(const SomeClass&); |
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
/* | |
Delta Compression by Glenn Fiedler. | |
This source code is placed in the public domain. | |
http://gafferongames.com/2015/03/14/the-networked-physics-data-compression-challenge/ | |
*/ | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <assert.h> | |
#include <string.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
template <typename T, typename F> | |
size_t offset(F T::* ptr) | |
{ | |
T* typePtr = (T*)nullptr; | |
F* memberPtr = &(typePtr->*ptr); | |
uintptr_t offset = (uintptr_t)memberPtr - (uintptr_t)typePtr; | |
return offset; | |
} |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.IO; | |
using System.Net; | |
namespace Lib.Common | |
{ | |
public class FtpClient |
NewerOlder