Skip to content

Instantly share code, notes, and snippets.

Avatar

Stewart Celani stewartcelani

View GitHub Profile
@stewartcelani
stewartcelani / node-base64-to-database-via-fs.js
Last active Dec 27, 2015
Simple nodejs javascript example (using native ES6 promises in node) of saving base64 string to filesystem and getting path and filesize ready to persist metadata to datasource.
View node-base64-to-database-via-fs.js
// NODEJS BASE64 TO FILESYSTEM
// ======================================================================================================================
// This will create a file called 5.jpeg in the screenshots directory - requires 'fs' and 'path' - picture of my dog below
var addScreenshot = base64ToFile("data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/7QA2UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAABkcAmcAFE45OGY1SlcxNnJjcUdaTmJCV1BxAP/iAhxJQ0NfUFJPRklMRQABAQAAAgxsY21zAhAAAG1udHJSR0IgWFlaIAfcAAEAGQADACkAOWFjc3BBUFBMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD21gABAAAAANMtbGNtcwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACmRlc2MAAAD8AAAAXmNwcnQAAAFcAAAAC3d0cHQAAAFoAAAAFGJrcHQAAAF8AAAAFHJYWVoAAAGQAAAAFGdYWVoAAAGkAAAAFGJYWVoAAAG4AAAAFHJUUkMAAAHMAAAAQGdUUkMAAAHMAAAAQGJUUkMAAAHMAAAAQGRlc2MAAAAAAAAAA2MyAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHRleHQAAAAARkIAAFhZWiAAAAAAAAD21gABAAAAANMtWFlaIAAAAAAAAAMWAAADMwAAAqRYWVogAAAAAAAAb6IAADj1AAADkFhZWiA
@stewartcelani
stewartcelani / 0_reuse_code.js
Created Aug 24, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View new_gist_file_0
//Get the room:
var room = io.sockets.adapter.rooms[roomId] || {};
//Declaration of number of users variable
var numUsers;
//If there are any user connected in the room, create the object
if(room.user===undefined)
room.user = {};
//If you join the room and have another opened session, increase the number of sessions
@stewartcelani
stewartcelani / index.html
Created May 17, 2017
Extract Root Domain
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">