Skip to content

Instantly share code, notes, and snippets.

Avatar

Vladimir Vissoultchev wqweto

  • Unicontsoft
  • Sofia, Bulgaria
View GitHub Profile
View ProtocolCombination.cpp
#define SECURITY_WIN32
#include <iostream>
#include <tuple>
#include <Windows.h>
#include <security.h>
#include <schannel.h>
#pragma comment(lib, "Secur32.lib")
static std::tuple<int, const char*> protocols[] = {
{ SP_PROT_PCT1_CLIENT, "PCT 1.0" },
@hasherezade
hasherezade / aes_crypt.cpp
Last active Nov 23, 2021
AES 128 - encrypt/decrypt using Windows Crypto API
View aes_crypt.cpp
#include <Windows.h>
#include <wincrypt.h>
#include <stdio.h>
#pragma comment(lib, "advapi32.lib")
#define AES_KEY_SIZE 16
#define IN_CHUNK_SIZE (AES_KEY_SIZE * 10) // a buffer must be a multiple of the key size
#define OUT_CHUNK_SIZE (IN_CHUNK_SIZE * 2) // an output buffer (for encryption) must be twice as big
//params: <input file> <output file> <is decrypt mode> <key>
@randrews
randrews / hoc4.lua
Created Jun 21, 2015
Toy calculator in Lua, version 4
View hoc4.lua
setmetatable(_ENV, { __index=lpeg })
Scopes = { {} }
function eval_expr(expr)
local accum = eval(expr[2]) -- because 1 is "expr"
for i = 3, #expr, 2 do
local operator = expr[i]
local num2 = eval(expr[i+1])
@sharwell
sharwell / CaseInsensitiveInputStream.java
Created Mar 8, 2014
Case insensitive input stream for ANTLR 4
View CaseInsensitiveInputStream.java
/*
* [The "BSD license"]
* Copyright (c) 2012 Terence Parr
* Copyright (c) 2012 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
@sharwell
sharwell / CaseInsensitiveStringStream.cs
Created Feb 19, 2014
Case-insensitive ANTLRStringStream for ANTLR 3
View CaseInsensitiveStringStream.cs
using Antlr.Runtime;
public class CaseInsensitiveStringStream : ANTLRStringStream
{
// the string used for lookahead (performance improvement by not having to call Char.ToLowerInvariant())
private readonly string _lastring;
public CaseInsensitiveStringStream(string input, string sourceName)
: base(input, sourceName)
{
@armornick
armornick / parser.lua
Last active Dec 21, 2015
Kaleidoscope parser made with LPeg
View parser.lua
-- debug helper function
function _dump (t)
local ttype = type(t)
if ttype == "table" then
local vals = {}
for k,v in pairs(t) do
table.insert(vals, _dump(k) .. " = " .. _dump(v))
end
return "{"..table.concat(vals, " , ").."}"
elseif ttype == "string" then
@mindplay-dk
mindplay-dk / StringSubstitutionExtension.cs
Created Mar 31, 2011
A static class that allows you to use name/value pairs from an dictionary to substitute string-representations of object values - this extension complements String.Format()
View StringSubstitutionExtension.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Mindplay.Extensions
{
/// <summary>
/// This extension provides an alternative to <see cref="String.Format"/> allowing the
/// use of an <see cref="IDictionary{String,Object}"/> to replace named (rather than