Skip to content

Instantly share code, notes, and snippets.

View Ste1io's full-sized avatar

Stelio Kontos Ste1io

View GitHub Profile
@SamChristy
SamChristy / gist:1395840
Created November 26, 2011 15:17
A simple high-resolution stopwatch class for timing your programs in a Windows environment.
/////////////////////////////////////////////////////////////////////////
/// Title: Stopwatch Class
/// Author: Sam Christy
/// Date: 26/11/2011
/// Licence: GNU GPL
///
/// This class is a simple, high-resolution stopwatch for timing the
/// execution of C++ programs in a Windows eviroment. This class
/// emulates the Stopwatch class of the .NET framework and uses the
/// Windows API to time events. Its precision is much greater than any
@rutger1140
rutger1140 / gist:3794491
Created September 27, 2012 15:03
Wordpress: filter on custom post type taxonomy in admin
function my_restrict_manage_posts() {
global $typenow;
$args=array( 'public' => true, '_builtin' => false );
$post_types = get_post_types($args);
if ( in_array($typenow, $post_types) ) {
$filters = get_object_taxonomies($typenow);
foreach ($filters as $tax_slug) {
$tax_obj = get_taxonomy($tax_slug);
wp_dropdown_categories(array(
'show_option_all' => __('Show All '.$tax_obj->label ),
@eternnoir
eternnoir / gist:9777420
Last active May 3, 2022 05:25
Ftp Client With C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
namespace Lib.Common
{
public class FtpClient
@catchouli
catchouli / offset
Created January 4, 2015 14:57
a relic from the deepest darkest corners of c++
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;
}
@gafferongames
gafferongames / delta_compression.cpp
Last active May 13, 2024 06:38
Delta Compression
/*
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>
@catchouli
catchouli / header.hpp
Created June 18, 2015 19:30
pimpl - dont forget your copy constructors and shit
#pragma once
class SomeClass
{
public:
SomeClass();
~SomeClass();
SomeClass(const SomeClass&);
SomeClass& SomeClass(const SomeClass&);
@DanielSWolf
DanielSWolf / Program.cs
Last active July 16, 2024 20:29
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
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);
@tzutalin
tzutalin / timer-c++03.cpp
Last active March 11, 2023 12:25 — forked from gongzhitaao/CppTimer.md
Simple high resolution timer in C++
#include <iostream>
#include <ctime>
class Timer
{
public:
Timer() { clock_gettime(CLOCK_REALTIME, &beg_); }
double elapsed() {
clock_gettime(CLOCK_REALTIME, &end_);
@tkouba
tkouba / DisposableList.cs
Created September 27, 2016 11:22
Generic list with automatic dispose
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.
@miguelmota
miguelmota / openssl_certs.sh
Created September 2, 2018 04:47
OpenSSL generate self-signed certificate authority (CA) and certificate (CRT)
# 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