This file contains hidden or 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 bash | |
| declare INDEX="$(cloud-init query ds.meta_data.meta.index)" | |
| declare TOTAL="$(cloud-init query ds.meta_data.meta.total)" | |
| echo "Hello, World! This is instance $(( INDEX + 1 )) of ${TOTAL}." \ | |
| | tee /root/hello.txt |
This file contains hidden or 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
| """ | |
| asyncio Demonstration | |
| MIT License | |
| Copyright (c) 2017 Genome Research Ltd. | |
| """ | |
| import asyncio | |
| from threading import Lock, Thread | |
| from typing import NamedTuple |
This file contains hidden or 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 awk -f | |
| # Convert LDIF into JSON | |
| # MIT License | |
| # Copyright (c) 2017 Christopher Harrison | |
| function json_string(str) { | |
| # Convert a string into an escaped JSON string, with enclosing quotes | |
| return "\"" gensub(/"/, "\\\\\"", "g", str) "\"" |
This file contains hidden or 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
| # Grammar: | |
| # expr = number | |
| # | "(" op expr+ ")" | |
| # op = "+" | "-" | "*" | "/" | |
| # number = "-"? DIGIT+ | |
| import re | |
| from functools import reduce | |
| from typing import Any, List, Optional, Tuple, Union |
This file contains hidden or 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
| import unittest | |
| from enum import Enum | |
| from typing import List, Union | |
| class Parens(Enum): | |
| brace = '()' | |
| curly = '{}' | |
| square = '[]' |
This file contains hidden or 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
| #lang racket/base | |
| (require rackunit | |
| racket/match | |
| "stack.rkt") | |
| ; Create stack | |
| (make-stack test-stack) | |
| ; Is it a stack? |
This file contains hidden or 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
| int bin2int(const char* s) { | |
| int out = 0; | |
| while (*s) { | |
| out <<= 1; | |
| if (*s == '1') ++out; | |
| ++s; | |
| } | |
| return out; |
This file contains hidden or 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
| #!/bin/bash | |
| # Change the group and group permissions for everything, recursively, in the cwd | |
| find . | tee >(xargs chgrp -h NEW_GROUP) | xargs chmod -h g+rw |
This file contains hidden or 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 <sys/types.h> | |
| /** | |
| @brief Human file size | |
| @param size File size in bytes | |
| @return Base 2 prefixed file size string | |
| This isn't as complete as Gnulib's `human_readable`, but it does the | |
| job without any allocation or messing around |
This file contains hidden or 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
| # Output | |
| TARGET = my_binary | |
| # OS X default is a GCC frontend to LLVM | |
| # Real GCC can be installed via, e.g., Homebrew | |
| CC = gcc | |
| LD = ld | |
| # List of library dependencies | |
| # pkg-config can be installed via, e.g., Homebrew |