Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000| #include <iostream> | |
| #include <tuple> | |
| template<typename Tuple, int Size, int Index=0> | |
| struct Apply | |
| { | |
| void operator()(Tuple t) const | |
| { | |
| std::cout << std::get<Index>(t) << std::endl; | |
| Apply<Tuple, Size, Index + 1>().operator()(t); |
| #include <iostream> | |
| #define ENSURE(x) do { \ | |
| if (not (x)) {std::cerr << __FILE__ << " " << __PRETTY_FUNCTION__ << ":" << __LINE__ << " " << #x << " assert failed!\n";} \ | |
| } while(false) | |
| void f(int x) | |
| { | |
| ENSURE(x > 0); | |
| } |
| #include <iostream> | |
| #include <functional> | |
| #include <vector> | |
| template<typename Container, typename Function> | |
| void f(Container&& c, Function&& f) | |
| { | |
| for (const auto& e : c) { | |
| f(e); | |
| } |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000| #!/bin/bash | |
| # copied from https://jvns.ca/blog/2017/06/11/log-structured-storage/ | |
| db_set() { | |
| echo "$1,$2" >> database | |
| } | |
| db_get() { | |
| grep "^$1," database | sed -e "s/^$1,//" | tail -n 1 |
| import redis | |
| import threading | |
| class Listener(threading.Thread): | |
| def __init__(self, r, channels): | |
| threading.Thread.__init__(self) | |
| self.redis = r | |
| self.pubsub = self.redis.pubsub() | |
| self.pubsub.subscribe(channels) | |
| Silver 0.18 | |
| Gold 0.47 | |
| Helium 1.000036 | |
| Hydrogen (gas) 1.00014 | |
| Water (gas) 1.000261 | |
| Oxygen (gas) 1.000276 | |
| Argon 1.000281 | |
| Air 1.0002926 | |
| Nitrogen (gas) 1.000297 | |
| Carbon Dioxide (gas) 1.000449 |
| ///bin/true;COMPILER_OPTIONS="-g -Wall -Wextra --std=c99 -O1 -fsanitize=address,undefined";THIS_FILE="$(cd "$(dirname "$0")"; pwd -P)/$(basename "$0")";OUT_FILE="/tmp/build-cache/$THIS_FILE";mkdir -p "$(dirname "$OUT_FILE")";test "$THIS_FILE" -ot "$OUT_FILE" || $(which clang || which gcc) $COMPILER_OPTIONS -xc "$THIS_FILE" -o "$OUT_FILE" || exit;exec "$OUT_FILE" "$@" | |
| #include <stdio.h> | |
| int main() { | |
| printf("Hello world!\n"); | |
| return 0; | |
| } |
| #!/bin/bash | |
| diff=$(cargo fmt -- --check) | |
| result=$? | |
| if [[ ${result} -ne 0 ]] ; then | |
| cat <<\EOF | |
| There are some code style issues, run `cargo fmt` first. | |
| EOF | |
| exit 1 |
| #!/bin/bash | |
| n=$1 | |
| g++ -o ${n} ${n}.cpp -std=c++14 -O2 | |
| for i in {0..10} ; do | |
| if [[ -e ${n}${i}.in ]] ; then | |
| ./${n} < ${n}${i}.in > ${n}${i}.xd | |
| diff -w -q ${n}${i}.xd ${n}${i}.out |