Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View stewartcelani's full-sized avatar
🙂

Stewart Celani stewartcelani

🙂
  • Adelaide, South Australia
View GitHub Profile
@stewartcelani
stewartcelani / node-base64-to-database-via-fs.js
Last active December 27, 2015 03:52
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.
// 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 August 24, 2016 00:36
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
//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 13:19
Extract Root Domain
<!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">