View factorio_basic_rules.md

Factorio basic rules

  1. Don't be a dick
    • a. The player that hosts has to retrieve the most recent save
    • b. The player that originally hosted has to replace the old save with the new one at the end of the match
    • c. The player whose responsibility is to replace the old save can delegate the job to someone else upon agreement
  2. Destroying property requires consent to those that put it down
  3. Don't kill other players
  4. Autosave period must be set to 15 minutes
View driving_slots.sql
1 2 3 4 5 6 7 8 9 10
create view total_driving_slots as (
select week_day,
time,
count(id) as total_count
from driving_slots
group by week_day, time
);
 
create view free_driving_slots as (
select week_day,
View gist:ff65a668206b9cdd86a3
1 2 3 4 5 6 7
function signin_required($login_page, $fn) {
return function($db) use ($fn, $login_page) {
if (array_key_exists('user_id', $_SESSION))
$fn($db);
else engine\redirect($login_page);
};
}
View quick_sort.cpp
1 2 3 4 5 6 7 8 9 10
namespace detail {
 
template<typename It>
It partition(It begin, It end) {
if (begin == end) return end;
auto pivot = *(end - 1);
auto left = begin; // left partion past the end
for (auto right = begin; right != end; ++right) {
if (*right <= pivot) {
std::iter_swap(left, right);
View gist:7f6d4ce58edbceec5f16
1 2 3 4 5 6 7 8 9
#!/usr/bin/python
 
import ninja_syntax
import itertools
import os
import fnmatch
import re
import sys
import argparse
View filetoobig.md

The asymmetries of C++

This is lighthearted collection of asymmetries of the C++ language. This is not, in any way, intended as a critic.


Partial specialization is allowed for class templates but not for function templates

§14.5.5 [temp.class.spec] describes the semantic and syntax for class template partial specialization such as, given:

View equal100.hs
1 2 3 4 5 6 7 8 9 10
-- Write a program that outputs all possibilities to put + or - or nothing
-- between the numbers 1, 2, ..., 9 (in this order) such that the result is
-- always 100. For example: 1 + 2 + 34 – 5 + 67 – 8 + 9 = 100.
 
import Control.Monad (replicateM)
 
ints :: [String]
ints = map (\i -> [i]) ['1'..'9']
 
inbetweens :: [[String]]
View Vec.elm
1 2 3 4 5 6 7 8 9 10
type alias Unit = Float
type Vec2 = Vec2 Unit Unit
 
(|+|) : Vec2 -> Vec2 -> Vec2
(Vec2 ax ay) |+| (Vec2 bx by) = Vec2 (ax + bx) (ay + by)
 
negate : Vec2 -> Vec2
negate (Vec2 x y) = Vec2 (-x) (-y)
 
(|-|) : Vec2 -> Vec2 -> Vec2
View a8.cpp
1 2 3 4 5 6 7 8 9 10
#include <iostream>
#include <fstream>
#include <map>
#include <stdexcept>
#include <vector>
 
namespace a8 {
 
// aliases
using word = std::string;
View ngrams.hs
1 2 3 4 5 6 7 8 9 10
groupEvery :: Int -> [a] -> [[a]]
groupEvery n lst
| length lst < n = []
| otherwise = take n lst : groupEvery n (tail lst)
 
ngrams :: Int -> String -> [String]
ngrams n = concatMap (groupEvery n . fillWord '_') . words
where fillWord f w = f : (w ++ replicate (n - 1) f)
 
main :: IO ()
Something went wrong with that request. Please try again.