Skip to content

Instantly share code, notes, and snippets.

(in-package #:cl-user)
(defpackage #:rwa-contest
(:use #:cl)
(:export
#:address
#:address-value
#:book
#:parse-ranges
#:parse-ips
@Lovesan
Lovesan / pegc.lisp
Created November 2, 2011 10:39
simple parser combinator library
(in-package :cl-user)
(defpackage #:peg-combinators
(:use #:cl)
(:nicknames #:pegc)
(:export
#:defparser
#:defrule
#:result
private def metaExists(id: Id[DocumentMeta]): Rx[Boolean] = {
metaDir.fileExists(id.value) mapToRx {
case Failure(_) => false
case Success(exists) => exists
}
}
private def dataExists(id: Id[DocumentMeta]): Rx[Boolean] = {
dir.fileExists(id.value) mapToRx {
case Failure(_) => false
(defconstant +byte-count+ (* 2 1024 1024 1024))
(defconstant +page-size+ 4096)
(defconstant +page-count+ (/ +byte-count+ +page-size+))
(defvar *a* (make-array +byte-count+ :element-type '(unsigned-byte 8)))
(dotimes (i +page-count+) (incf (elt *a* (* i +page-size+))))
@Lovesan
Lovesan / fftutorial.cs
Created February 3, 2017 23:32
FFmpeg & SDL2 - play audio & video
#define __STDC_CONSTANT_MACROS
#include <stdint.h>
#include <inttypes.h>
#include <windows.h>
#include <stdio.h>
extern "C"
{
#include <libavfilter/avfilter.h>
#define __STDC_CONSTANT_MACROS
#include <stdint.h>
#include <inttypes.h>
#include <windows.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C"
{
@Lovesan
Lovesan / ffexample.c
Last active June 6, 2020 07:13
FFmpeg-based console audio/video player (e.g. ffplay analogue)
// build like e.g.
// cl.exe /nologo /O2 /I../ffmpeg-3.2.2-win64-lgpl/include /I../SDL2-2.0.5/include /MT ffexample.c SDL2.lib avcodec.lib avdevice.lib avformat.lib avutil.lib swresample.lib swscale.lib /link /libpath:../SDL2-2.0.5/lib/x64 /libpath:../ffmpeg-3.2.2-win64-lgpl/lib
#define __STDC_CONSTANT_MACROS
#ifndef UNICODE
#define UNICODE
#endif
#ifndef _UNICODE
@Lovesan
Lovesan / ComUtils.hpp
Created April 21, 2017 16:28
COM utils
#ifndef __COM_UTILS_HPP__
#define __COM_UTILS_HPP__
#include <oleidl.h>
template<class T>
class ComPtr
{
public:
ComPtr()
@Lovesan
Lovesan / get-commits.sh
Created March 19, 2019 15:12
Get your commits for a repo
#!/bin/bash
set -e
DATE_START=`date +%Y-%m-01`
DATE_END=`date +%Y-%m-%d`
USER_NAME=`git config user.name`
REPO_DIR=`realpath ./`
BRANCH_NAME='origin/master'
if [ -t 0 -a -t 1 ]; then
@Lovesan
Lovesan / sehlib.cxx
Created June 6, 2019 15:37
Example C++ library which internally throws an exception and catches it
// g++ -O0 -shared -o sehlib.dll sehlib.cxx
// OR
// cl.exe /nologo /Od /MD /EHac /LD /Fe:sehlib.dll sehlib.cxx
#include <iostream>
#include <exception>
void throws_fn()
{
std::cerr << "C++ throws exception" << std::endl;
throw std::exception();