Inspired by http://madebyevan.com/obscure-cpp-features/. Compile and run using g++
or clang++
.
$ g++ -std=c++11 -Wall -pedantic -Wextra wat.cpp
$ ./a.out
hello! I'm called ./a.out and 5 + 3 is 8
<?php | |
// To the extent possible under law, I (Stephan Sokolow) waive all copyright and related or | |
// neighbouring rights to this code snippet. (Though it'd still be nice if you mention me) | |
// If we're running under `php -S` with PHP 5.4.0+ | |
if (php_sapi_name() == 'cli-server') { | |
// Replicate the effects of basic "index.php"-hiding mod_rewrite rules | |
// Tested working under FatFreeFramework 2.0.6 through 2.0.12. | |
$_SERVER['SCRIPT_NAME'] = str_replace(__DIR__, '', __FILE__); |
Inspired by http://madebyevan.com/obscure-cpp-features/. Compile and run using g++
or clang++
.
$ g++ -std=c++11 -Wall -pedantic -Wextra wat.cpp
$ ./a.out
hello! I'm called ./a.out and 5 + 3 is 8
This post also appears on lisper.in.
Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.
Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):
The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.
;; -*- mode: lisp -*- | |
;; | |
;; A quick and dirty tree shaker for SBCL. Basically, it destroys the | |
;; package system and does a gc before saving the lisp image. Gives | |
;; about a 40% reduction in image size on a basic hello world test. | |
;; Would like to hear how it works on larger projects. | |
;; | |
;; Original idea from: https://groups.google.com/d/msg/comp.lang.lisp/6zpZsWFFW18/WMy4PyA9B4kJ | |
;; | |
;; Burton Samograd |
#!/usr/bin/env python | |
import random | |
import struct | |
import sys | |
# Most of the Fat32 class was cribbed from https://gist.github.com/jonte/4577833 | |
def ppNum(num): | |
return "%s (%s)" % (hex(num), num) |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <gmp.h> | |
char * polynomial="-74101463560860539810482394216134472786413399/404009590666424903383979388988167534591844018460526499864038804741201731572423877094984692537474105135297393596654648304117684895744000000000000000000000*x^99 + 1786563401621773217421750502452955853226339781/1943688752347061390850759947022111850270039951356484879070977067483444756705819339975871373032521468004867185688372878439054154137600000000000000000000*x^98 - 27321291157050372775340569532625689973429185264741/12024094960310264981666053243695462339042976739896622019763059664916718201560234437350734896948634081407660523709959770955883479040000000000000000000000*x^97 + 4936870031754926645682423836151042176171669450909/1336493173680525187613977630110369004256312194947800263402124063124652591386915768177479078216982141485276408003996973457735680000000000000000000000*x^96 - 24473118674386691114350902920738421254018653211816783/55093218603941649400531744530105211175454647 |
#!/bin/bash | |
command -v kdeconnect-cli >/dev/null 2>&1 || { echo >&2 "kdeconnect is not installed. Aborting."; exit 1; } | |
if [ $# -eq 0 ]; then | |
echo "Usage: $0 <message>" | |
exit 1 | |
fi | |
device=`kdeconnect-cli -a --id-only 2>/dev/null | head` |
# | |
# Copyright (C) Andrei Belov ([email protected]) | |
# | |
# This is an example of direnv [1] .envrc file approaching the way | |
# of using awscli [2] with MFA-enabled accounts in a (more or less) | |
# secure manner. | |
# | |
# The following assumptions are expected: | |
# | |
# a) there should be two files, key.asc and skey.asc, containing |
#!/bin/bash | |
# run exes on the same environment as the game, for modding purposes and such | |
#replace with the id of the game | |
ID=205100 | |
#adjust to the proper path | |
GAMELIBDIR=/media/raydj/extra/SteamLibrary | |
COMPATDIR=${GAMELIBDIR}/steamapps/compatdata/${ID} |
import os | |
import sys | |
""" | |
This (pure!) python script streams a gzip-compressed YUV4MPEG video to stdout. | |
It easily runs at 1080p60fps on my machine. | |
Pipe it into a media player like this: | |
python3 gzip_swar_life.py | mbuffer | gunzip - | mpv - |