Skip to content

Instantly share code, notes, and snippets.

@bubach
bubach / bundlelessApplication.m
Created February 11, 2021 08:18 — forked from karstenBriksoft/bundlelessApplication.m
NSApplication without Bundle
// compile using: clang -fobjc-arc -framework AppKit bundlelessApplication.m -o bundleLess
//
// opens a NSApplication with dock icon and menu bar. NSRunningApplication will return no bundleURL for it
//
// via http://stackoverflow.com/questions/8137538/cocoa-applications-from-the-command-line
// and http://casperbhansen.wordpress.com/2010/08/15/dev-tip-nibless-development/
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
@bubach
bubach / example_usage.c
Created July 7, 2020 02:50
C-code showcasing macro DSL, it's old (-89), weird, but strangely awesome
/*
* Example structure definition
*/
Structure DTA_struct
BeginStructure
byte DOS_reserved[21];
bit_8 attribute;
bit_16 time_stamp;
bit_16 date_stamp;
bit_32 file_size;
@bubach
bubach / fire.html
Created April 16, 2020 21:26
Fire!
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="/js/lib/dummy.js"></script>
@bubach
bubach / cors.html
Created February 20, 2020 18:28
Dicking around with Content Security Policy meta-tags and CORS-bs
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>v86.js</title>
<style type="text/css">
#screen {
white-space: pre;
@bubach
bubach / es6.ebnf
Created December 30, 2019 08:05
EMCAScript 6 EBNF
/* ebnf file for es 6 */
Grammar::= Statement
/* Lexical grammar */
SourceCharacter ::= #x0000-#x10FFFF
InputElementDiv ::= WhiteSpace | LineTerminator | Comment | CommonToken | DivPunctuator | RightBracePunctuator
InputElementRegExp ::= WhiteSpace | LineTerminator | Comment | CommonToken | RightBracePunctuator | RegularExpressionLiteral
InputElementRegExpOrTemplateTail ::= WhiteSpace | LineTerminator | Comment | CommonToken | RegularExpressionLiteral | TemplateSubstitutionTail
InputElementTemplateTail ::= WhiteSpace | LineTerminator | Comment | CommonToken | DivPunctuator | TemplateSubstitutionTail
WhiteSpace ::= "<TAB>" | "<VT>" | "<FF>" | "<SP>" | "<NBSP>" | "<ZWNBSP>" | "<USP>"
@bubach
bubach / bnf-story-parser-fixed.php
Created November 16, 2019 12:00 — forked from ShayCichocki/bnf-story-parser-fixed.php
BNF form parser, exampled with story generating bnf
<?php
class BNFParserGenerator {
private $defs = [];
/**
* This converts the BNF string into a set of generator definitions
* that we can use later
* @param string $string
@bubach
bubach / PdfObject.php
Last active October 2, 2019 09:35
Simple PDF
<?php
namespace PdfBuilder\Document;
use PdfBuilder\Interfaces\FilterInterface;
use PdfBuilder\Interfaces\StructureInterface;
use PdfBuilder\Interfaces\StreamInterface;
/**
* PdfObject, class to build and parse PDF COS-format.
*
@bubach
bubach / base85.php
Created September 26, 2019 13:43
base85.php
<?PHP
#error_reporting(E_ALL);
// Examples:
// $str = base85::encode("Hello world!");
// $str = base85::decode(":e4D*;K$&\Er");
class base85
{
@bubach
bubach / Parser.php
Last active May 5, 2019 18:12
Very compact TrueType Font subsetting
<?php
namespace PdfBuilder\Font;
use PdfBuilder\Exception\PdfException;
use PdfBuilder\Stream\Stream;
use Exception;
/**
* TTF parser, sub-setter & metrics extractor
*
@bubach
bubach / tokenizer-iterator.php
Created October 2, 2018 22:26 — forked from mmstick/tokenizer-iterator.php
PHP String Tokenizer: Practicing with PHP
#!/bin/php
<?php
/// TODO:
/// - Implement Backslash escapes
// An ADT-like type that can either be a normal value or a variable.
class Token {
// 0 = Normal; 1 = Variable; 2 = Error; 3 = None
public $kind = 0;
// Contains the string for the associated type.