Skip to content

Instantly share code, notes, and snippets.

@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>
@Lovesan
Lovesan / excel-interop.lisp
Created February 22, 2024 21:45
Excel interop using bike library
(eval-when (:compile-toplevel :load-toplevel :execute)
(unless (find-package 'bike)
(ql:quickload 'bike)))
(named-readtables:in-readtable bike:bike-syntax)
(bike:use-namespace 'System)
;; The below is required to overcome internal bike optimizations related to property retrieval,
;; which utilize Type.GetProperty internally, which does not work for COM objects.
;; Note that you should also use bike:reflection-invoke instead of invoke, for the same reasons.
@Lovesan
Lovesan / cbrf.lisp
Created January 25, 2024 21:04
Exchange rates & converter using russian central bank API
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
;;; Copyright (C) 2024, Dmitry Ignatiev <lovesan.ru at gmail.com>
;;; Permission is hereby granted, free of charge, to any person
;;; obtaining a copy of this software and associated documentation
;;; files (the "Software"), to deal in the Software without
;;; restriction, including without limitation the rights to use, copy,
;;; modify, merge, publish, distribute, sublicense, and/or sell copies
;;; of the Software, and to permit persons to whom the Software is
@Lovesan
Lovesan / IEnumerable.lisp
Created October 10, 2023 14:26
IEnumerable and IReadOnlyCollection<> implementation using bike library
(define-dotnet-callable-class (sequence-enumerator
(:interfaces (IEnumerator :object))) ()
"An implementation of IEnumerator<object> for CL sequences."
(parent :initform nil :initarg :parent :reader se-parent)
(seq :initform '() :initarg :sequence :reader se-sequence)
(idx :initform -1 :reader se-index)
(:property current :object :initform nil :reader se-current
:documentation "An element at current enumerator index")
(:defmethod move-next :bool ()
@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 / simd-pack-single.lisp
Last active March 15, 2022 05:05
SBCL SSE operations on single-float vectors
(in-package #:sb-vm)
(eval-when (:compile-toplevel :load-toplevel :execute)
(defknown %m128+ ((simd-pack single-float) (simd-pack single-float))
(simd-pack single-float)
(movable foldable flushable always-translatable)
:overwrite-fndb-silently t)
(define-vop (%m128+)
#overall:
#gmp
#mpfr
#mpc
#isl
#binutils
#mingw-w64
#gcc
#zlib (optional, only native)
using namespace System.IO;
$ErrorActionPreference = 'Stop'
function VideoToGif{
Param(
[Parameter(Mandatory=$true)][string] $InFile,
[Parameter(Mandatory=$true)][string] $OutFile,
[int]$Width=320,
[int]$Height=-1,
[double]$Start=0.0,
(set-macro-character #\→ (lambda (s c)
(declare (ignore s c))
(error "Unexpected '→'")))
(set-macro-character #\λ
(lambda (s c)
(declare (ignore c))
(loop :with arg = (read s t nil t)
:for next = (peek-char t s t nil t)
:until (eql next #\→)
@Lovesan
Lovesan / sehtest.lisp
Created June 6, 2019 15:39
SBCL test for SEH-utilizing C++ or .NET library
(sb-alien:load-shared-object "sehlib.dll")
(sb-alien:define-alien-routine
("catches_fn" catches-fn)
sb-alien:void)
(defun test-seh ()
(handler-case
(progn (catches-fn)
(format *error-output*