Skip to content

Instantly share code, notes, and snippets.

// show go module dependencies as an indented tree
// usage: go mod graph | go run gt.go
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
%{
#include <stdio.h>
#include <stdlib.h>
int words = 0, lines = 0, chars = 0;
%}
%%
\n { chars += yyleng; lines += 1; };
[ \t]+ { chars += yyleng; };
[^ \t\n]+ { chars += yyleng; words += 1; };
BABY(1fun) BABY(1fun)
NAME
baby — create new process from two parents
SYNOPSIS
baby −sex [m|f] [−name name]
(defmacro rpn (&rest tokens)
(let ((st (list)))
(dolist (x tokens (pop st))
(if (symbolp x)
(let* ((op2 (pop st))
(op1 (pop st)))
(push (list x op1 op2) st))
(push x st)))))
(assert (equal 3 (rpn 1 2 +)))
def rawsql(queryset):
compiler = queryset.query.get_compiler(using=queryset.db)
sql, params = compiler.as_sql()
with compiler.connection.cursor() as cursor_wrapper:
cursor = cursor_wrapper.cursor
cursor_type = str(type(cursor)).lower()
if 'psycopg2' in cursor_type or 'pymysql' in cursor_type:
return cursor.mogrify(sql, params)
elif 'mysqldb' in cursor_type:
db = cursor._get_db()
html {
lang: en;
head {
title {
"hello world"
}
}
body {
/* Tcl in ~ 500 lines of code.
*
* Copyright (c) 2007-2016, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
@for $i from 1 through 100 {
@if $i % 15 == 0 {
#{$i} { is: "fizzbuzz"}
} @else if $i % 3 == 0 {
#{$i} { is: "fizz" }
} @else if $i % 5 == 0 {
#{$i} { is: "buzz" }
} @else {
#{$i} { is: "-" }
}
# simple expression evaluator
import ast
import operator
import contextlib
OPERATORS = {
ast.Add: operator.add,
ast.And: operator.and_,
ast.Or: operator.or_,
#!/usr/bin/env python3
import os
import sys
from PIL import Image
BRAILLE_OFFSET = 0x2800
def braillify(image_path, threshold):