Skip to content

Instantly share code, notes, and snippets.

Avatar

Ross Harrison rharriso

View GitHub Profile
@rharriso
rharriso / configure-local-build.sh
Created Feb 14, 2018
Installing Nginx Locally
View configure-local-build.sh
From https://www.vultr.com/docs/how-to-compile-nginx-from-source-on-ubuntu-16-04
./configure --prefix=/home/myusename/nginx/share/nginx \
--sbin-path=/home/myusename/bin/nginx \
--modules-path=/home/myusename/nginx/lib/nginx/modules \
--conf-path=/home/myusename/nginx/nginx.conf \
--error-log-path=/home/myusename/nginx/log/nginx/error.log \
--http-log-path=/home/myusename/nginx/log/nginx/access.log \
--pid-path=/run/nginx.pid \
--lock-path=/home/myusename/nginx/lock/nginx.lock \
@rharriso
rharriso / settings.json
Created Aug 15, 2017
Visual Studio Code Editor Settings
View settings.json
// Place your settings in this file to overwrite the default settings
{
"editor.fontFamily": "Fira Code",
"editor.fontSize": 12,
"editor.fontLigatures": true,
"editor.lineNumbers": "relative",
"workbench.colorTheme": "Tomorrow Night Blue",
"vim.disableAnnoyingNeovimMessage": true,
"editor.tabSize": 2,
"C_Cpp.intelliSenseEngine": "Default"
@rharriso
rharriso / launch.json
Created Jul 28, 2017
VSCode Node debug config
View launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
View fillCells.py
available_options = (1..9)
def fillCells:
doFillCells(0)
def doFillCells (index):
cell = board.cells[index]
neighbor_values = cell.neighbors.map((neighbor) => neighbor.values)
remaining_options = available_options \ neighbor_values
View sudoku-solved.txt
----------------------------------
| 3 6 9 | 1 2 4 | 5 8 7 |
| 7 2 8 | 6 5 9 | 3 1 4 |
| 1 4 5 | 7 3 8 | 2 6 9 |
----------------------------------
| 2 9 7 | 3 6 1 | 8 4 5 |
| 5 8 3 | 9 4 2 | 6 7 1 |
| 6 1 4 | 5 8 7 | 9 2 3 |
----------------------------------
| 9 7 2 | 8 1 5 | 4 3 6 |
View sudoku-backtrack.txt
----------------------------------
| 3 6 9 | 1 2 4 | 5 8 7 |
| 7 2 8 | 6 5 9 | 3 1 4 |
| 1 4 5 | 7 3 8 | 2 6 9 |
----------------------------------
| 2 9 7 | 3 6 1 | 8 4 5 |
| 5 8 3 | 9 4 2 | 6 7 1 |
| 6 1 4 | 5 8 7 | 9 2 3 |
----------------------------------
| 9 7 2 | 8 1 5 | 4 3 6 |
View filll-updates.cpp
using cellQueue = std::deque<SudokuCell>;
class SudokuBoard {
/*
* fill the board with valid solution
*/
void fillCells() {
auto remaininCells = cellQueue{cells};
if(!doFillCells(remaininCells)) {
View fail-output.txt
----------------------------------
| 7 9 1 | 6 8 4 | 3 2 5 |
| 4 3 8 | 5 2 7 | 9 1 6 |
| 2 6 5 | 3 1 9 | 8 4 7 |
----------------------------------
| 5 4 2 | 7 9 3 | 1 6 8 |
| 6 1 7 | 2 4 8 | 5 |
| | | |
----------------------------------
| | | |
View fill-cells-initial.cpp
bool fillCells() {
for(auto cell : this->cells()) {
// get first cell and tail
auto cell = remainingCells.front();
remainingCells.pop_front();
set<int> neighborValues = {};
View generate-all-neigbors.cpp
class SudokuBoard {
void generateAllNeighbors () {
// generate row & col neighbors
for (int n = 0; n < 9; ++n) {
neighbors.insert({n, pos.j});
neighbors.insert({pos.i, n});
}
auto iFloor = (pos.i / 3) * THIRD;
auto jFloor = (pos.j / 3) * THIRD;