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> | |
<head> | |
<link href="https://fonts.googleapis.com/css2?family=Fira+Code&display=swap" rel="stylesheet"> | |
<style> | |
pre { | |
font-family: 'Fira Code'; | |
margin: 0; | |
} | |
#outer { | |
background-color: #abb8c3; |
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> | |
#include <time.h> | |
// Must be a multiply of 8 | |
const int TOTAL = 1000000; | |
int main() { | |
struct timespec start; | |
clock_gettime(CLOCK_REALTIME, &start); |
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
# GNU Assembler, Intel syntax, x86_64 Linux | |
# This program decrements the binary coded number on the tape and prints the | |
# contents of the tape (byte for byte). | |
# Compile: clang -nostdlib -fno-integrated-as -Wa,-msyntax=intel,-mnaked-reg -s bin_decrement.s -o bin_decrement | |
# Run: ./bin_decrement | od -t d1 | |
.data |
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
transitions = [ | |
// ['state', 'symbol', 'new_state', 'new_symbol', 'direction'] | |
['q0', 'a', 'q1', 'b', 'r'], | |
['q1', 'b', 'q2', 'c', 'l'] | |
] | |
console.log( | |
// Map each transition to its bits started by ## | |
transitions.map(transition => '##' + transition | |
// Map each parameter in the transition to its bits |
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
// Compile: g++ -std=c++17 generic_lambda.cpp | |
#include <iostream> | |
using namespace std; | |
// This function prints a value with a generic type. | |
template<typename T> | |
void printFunction(T value) { | |
cout << value << endl; |
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
import dataclasses | |
import json | |
import sys | |
from dataclasses import dataclass | |
from datetime import datetime, timedelta | |
from typing import Any, Tuple, TypeVar, Optional | |
T = TypeVar('T') | |
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 <iostream> | |
using namespace std; | |
int main() { | |
// A big number | |
float big = 123456.0f; | |
// A medium number | |
float medium = 1234.0f; | |
// A small number |
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 <iostream> | |
#include <string> | |
// Assume we have a class 'MyClass` and the following code: | |
// | |
// 1. MyClass a; | |
// 2. MyClass b = a; | |
// 3. b = a; | |
// |
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
# https://stackoverflow.com/questions/39712599/redirect-all-requests-to-single-page | |
# Redirect all requests to reverse_proxy.php and append the requested path. | |
# Note: You need to activate the RewriteEngine with `a2enmod rewrite`. | |
RewriteEngine on | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.*)$ /reverse_proxy.php?path=$1 [NC,L,QSA] |
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
import string | |
from itertools import zip_longest | |
from typing import TypeVar, Iterable, Optional, Iterator, List, Union, Any | |
T = TypeVar('T') | |
def grouper(iterable: Iterable[T], chunk_size: int, fill_value: Optional[T] = None) -> Iterator[List[T]]: | |
"""Collect data into fixed-length chunks or blocks. |
OlderNewer