Skip to content

Instantly share code, notes, and snippets.

View WORMSS's full-sized avatar

WORMSS WORMSS

View GitHub Profile
@WORMSS
WORMSS / Blink.c
Last active August 29, 2015 13:56
No Delay Blink for Multiple L.E.Ds
@WORMSS
WORMSS / Blink.c
Created February 17, 2014 09:33
Blink for Multiple LEDs with durations.
@WORMSS
WORMSS / pi startup
Last active March 29, 2016 20:08
First things to do when setting up the RaspberryPi
## Installing Chrome on Rasbian ##
# https://www.raspberrypi.org/forums/viewtopic.php?t=121195 #
wget https://dl.dropboxusercontent.com/u/87113035/chromium-browser-l10n_48.0.2564.82-0ubuntu0.15.04.1.1193_all.deb -P ~/Downloads/
wget https://dl.dropboxusercontent.com/u/87113035/chromium-browser_48.0.2564.82-0ubuntu0.15.04.1.1193_armhf.deb -P ~/Downloads/
wget https://dl.dropboxusercontent.com/u/87113035/chromium-codecs-ffmpeg-extra_48.0.2564.82-0ubuntu0.15.04.1.1193_armhf.deb -P ~/Downloads/
sudo dpkg -i ~/Downloads/chromium-codecs-ffmpeg-extra_48.0.2564.82-0ubuntu0.15.04.1.1193_armhf.deb
sudo dpkg -i ~/Downloads/chromium-browser-l10n_48.0.2564.82-0ubuntu0.15.04.1.1193_all.deb ~/Downloads/chromium-browser_48.0.2564.82-0ubuntu0.15.04.1.1193_armhf.deb
## So Chrome shows up in the Application Launch Bar ##
@WORMSS
WORMSS / index.js
Created February 17, 2017 14:35
A snippet of my Express.Route for OAuth
/*
Some extra stuff for setting up the server
*/
// Setting up bare passport. No Auth Strategy.
const passport = require("./middlewear/my-passport-init");
app.use(passport.initialize());
app.use(passport.session());
// Setting up passport Strategies and Routes
@WORMSS
WORMSS / flitetest.js
Created February 17, 2017 14:43
View parts of Express.Route
const Router = require("express").Router;
///........
const ensuredLoggedIn = require('connect-ensure-login').ensureLoggedIn();
var app = new Router();
app.get("/", ensuredLoggedIn, (req, res) => {
// .............
});
@WORMSS
WORMSS / micro-rest-api-server.js
Last active April 18, 2017 13:27
micro-rest-api-server
// imports
const Express = require("express");
const bodyParser = require("body-parser");
// Some datastore to play with.
const bookDb = initDb();
// Set up express app.
const app = new Express();
@WORMSS
WORMSS / index.js
Last active April 28, 2017 08:20
Express MethodOverride
const Express = require("express");
const methodOverride = require("method-override");
const app = new Express();
const router = new Express.Router();
//app.use(methodOverride("_method", {"methods": ["POST", "GET"]})); // Works too.
router.use(methodOverride("_method", {"methods": ["POST", "GET"]})); // on route so only the following use the method override.
router.get("/:id", all("get"));
@WORMSS
WORMSS / MongoUtils.js
Last active July 5, 2017 13:50
Mongo Connection Sharing
var _db;
module.exports = {
connect: function ({host = "localhost", port = 27017, dbname = "exampleDb"} = {}) {
return require("mongodb").MongoClient.connect(`mongodb://${host}:${port}/${dbname}`)
.then(db => _db = db);
},
collection: function (col_name) {
if ( !_db ) {
return null;
@WORMSS
WORMSS / express-upload-multer-example
Created July 7, 2017 12:32
Example code for uploading a file with express and multer
const express = require("express");
const multer = require("multer");
const upload = multer({"dest": "./mult"});
const app = express();
app.get("/", indexHandler);
app.post("/save", upload.single("fileField"), saveHandler);
@WORMSS
WORMSS / octopus_merge.sh
Last active April 27, 2018 10:09
Octopus Merge
# Make octopus from current commit/index
commit_id=$(git commit-tree $(git write-tree) -p commit1 -p commit2 -p commit3 -m "Octopus Message")
git branch -f "tmp/octopus" "$commit_id"