Skip to content

Instantly share code, notes, and snippets.

const foo = async function() {
const timeAtBeginning = new Date().getTime();
const vals = [];
for(let a of [1, 2, 3]) {
vals.push(
await new Promise( r => setTimeout(r, 1000, a * 2) )
);
}
const timeAtEnd = new Date().getTime() - timeAtBeginning;
@doubleOrt
doubleOrt / Caesar-cipher.js
Last active February 9, 2018 17:12
Vanilla JavaScript implementation of the Caesar Cipher
const CaesarCipher = (function() {
const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split("");
const encrypt = function encrypt(msg, key) {
if ( !typeof msg == 'string' || !Number.isInteger(key) ) {
return false;
}
return Array.from(msg)
/* Converts a decimal number to its hexadecimal equivalent. Pre-ES6 version
(or just convert it yourself, using https://babeljs.io): https://goo.gl/7xpMdf
Or, you could just use "Number.prototype.toString" */
const integer = 220;
const decimalToBase16Equivalent = function decimalToBase16Equivalent(num) {
if(num >= 10) {
num = {
'10': 'A',
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Simple Snake Game</title>
<!-- Basic styling, centering of the canvas. -->
<style>
canvas {
display: block;
<?php
namespace Ortify;
use Ratchet\ConnectionInterface;
use Ratchet\Wamp\WampServerInterface;
include_once "/../../../components/db_connection.php";
class Pusher implements WampServerInterface {
/**
<!DOCTYPE html>
<html>
<head>
<!--
These are JQuery and Materialize, however they wouldn't work since they are local directoreis, you will have to include your own.
<script src="dependencies/jquery/jquery.min.js"></script>
<script src="dependencies/jquery/jquery-ui.min.js" type="text/javascript"></script>