type StringBool = "true"|"false";
interface AnyNumber { prev?: any, isZero: StringBool };
interface PositiveNumber { prev: any, isZero: "false" };
type IsZero<TNumber extends AnyNumber> = TNumber["isZero"];
type Next<TNumber extends AnyNumber> = { prev: TNumber, isZero: "false" };
type Prev<TNumber extends PositiveNumber> = TNumber["prev"];
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 http.server | |
| import socketserver | |
| from http import HTTPStatus | |
| class Handler(http.server.SimpleHTTPRequestHandler): | |
| def do_GET(self): | |
| self.send_response(HTTPStatus.OK) | |
| self.end_headers() | |
| self.wfile.write(b'Hello world') |
This guide assumes you are using Ubuntu and have some basic linux command-line know-how.
Download the server https://www.factorio.com/download-headless/stable:
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 python2 | |
| import SimpleHTTPServer | |
| import SocketServer | |
| import logging | |
| PORT = 8000 | |
| class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): |
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 | |
| sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport | |
| sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport |
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 | |
| ##################################################### | |
| # Name: Bash CheatSheet for Mac OSX | |
| # | |
| # A little overlook of the Bash basics | |
| # | |
| # Usage: | |
| # | |
| # Author: J. Le Coupanec | |
| # Date: 2014/11/04 |
This should help you get Sendmail installed with basic configuration on Ubuntu.
- If sendmail isn't installed, install it:
sudo apt-get install sendmail - Configure
/etc/hostsfile:nano /etc/hosts - Make sure the line looks like this:
127.0.0.1 localhost yourhostname - Run Sendmail's config and answer 'Y' to everything:
sudo sendmailconfig - Restart apache
sudo service apache2 restart
Say you're running a virtual machine on your work computer. Say this machine, for whatever reason, can only connect to the internet over NAT - as in, it does not get it's own IP address. Say this VM is running a webserver, and you need a device outside of your computer to connect to it.
If only there was a way to get your work computer to 'share' it's network, so that you could get at that VM… Here's how you do it!
For all instructions, I assume your work computer is a mac
- Get your computer's IP address:
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
| // This program is an example of how to run a command such as | |
| // ps aux | grep root | grep sbin | |
| // using C and Unix. | |
| #include <stdlib.h> | |
| #include <unistd.h> | |
| int pid; | |
| int pipe1[2]; | |
| int pipe2[2]; |
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
| from json import load, JSONEncoder | |
| from optparse import OptionParser | |
| from re import compile | |
| float_pat = compile(r'^-?\d+\.\d+(e-?\d+)?$') | |
| charfloat_pat = compile(r'^[\[,\,]-?\d+\.\d+(e-?\d+)?$') | |
| parser = OptionParser(usage="""%prog [options] | |
| Group multiple GeoJSON files into one output file. |
NewerOlder