This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// show go module dependencies as an indented tree | |
// usage: go mod graph | go run gt.go | |
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"strings" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%{ | |
#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; }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BABY(1fun) BABY(1fun) | |
NAME | |
baby — create new process from two parents | |
SYNOPSIS | |
baby −sex [m|f] [−name name] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 +))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html { | |
lang: en; | |
head { | |
title { | |
"hello world" | |
} | |
} | |
body { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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: "-" } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# simple expression evaluator | |
import ast | |
import operator | |
import contextlib | |
OPERATORS = { | |
ast.Add: operator.add, | |
ast.And: operator.and_, | |
ast.Or: operator.or_, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import sys | |
from PIL import Image | |
BRAILLE_OFFSET = 0x2800 | |
def braillify(image_path, threshold): |
NewerOlder