Skip to content

Instantly share code, notes, and snippets.

View dgamepuzzle's full-sized avatar

mrxbell dgamepuzzle

View GitHub Profile
@dgamepuzzle
dgamepuzzle / 10 Minute Game.cs
Created November 23, 2020 10:12 — forked from nns2009/10 Minute Game.cs
Polished maze game made in under 10 minutes with Unity
// Made from scratch in just 8 minutes 23 seconds
// Watch this video to see how:
// https://youtu.be/aP9eKrnyxe4
// Play online here:
// https://nns2009.itch.io/just-maze
using Cinemachine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@dgamepuzzle
dgamepuzzle / mongodb_3.2.x_logging.md
Created December 19, 2019 02:03 — forked from leommoore/mongodb_3.2.x_logging.md
MongoDB 3.2.x Logging

MongoDB 3.2.x Logging

The main log file is the mongod.log. You can specify the log file location when you are starting the mongod process but if you have installed on Ubuntu from a package then you log file will normally be located in /var/log/mongodb/mongod.log.

You can tail the log file using:

tail -f /var/log/mongodb/mongod.log

From the Mongo shell you can also view the log file using:

show logs

@dgamepuzzle
dgamepuzzle / download-file.js
Created January 16, 2019 03:24 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
<?php
/**
* 1. create project at https://console.developers.google.com/project
* 2. enable 'Analytics API' under 'APIs & auth' / APIs
* 3. create 'NEW CLIENT ID' (OAuth client) under 'APIs & auth' / Credentials
* i. select 'Service account'
* ii. save generated key file to 'key.p12'
* iii. remember CLIENT ID
* 4. under GA account add 'Read & Analyze' access to newly generated email (access to GA Account not Property nor View)
@dgamepuzzle
dgamepuzzle / gist:d84d2061f7fb9ca69dde402e5a723cef
Last active August 20, 2018 08:59 — forked from sarciszewski/gist:88a7ed143204d17c3e42
Javascript CSPRNG for Integers
/**
* License: WTFPL, CC0, ZAP (Zero For 0wned Anti-copyright Pledge), etc
*/
function secure_rand(min, max) {
var i = rval = bits = bytes = 0;
var range = max - min;
if (range < 1) {
return min;
}
if (window.crypto && window.crypto.getRandomValues) {
@dgamepuzzle
dgamepuzzle / app.js
Created July 23, 2018 04:18 — forked from joshnuss/app.js
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./permission"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
@dgamepuzzle
dgamepuzzle / easing.js
Created May 10, 2018 09:24 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
@dgamepuzzle
dgamepuzzle / server_time_sync.js
Created May 8, 2018 01:37 — forked from ethaizone/server_time_sync.js
Sync server time to client browser with JS. Implement follow Network Time Protocol.
// Thanks http://stackoverflow.com/questions/1638337/the-best-way-to-synchronize-client-side-javascript-clock-with-server-date
var serverTimeOffset = false;
function getServerTime(callback) {
if (serverTimeOffset === false) {
var scripts = document.getElementsByTagName("script"),
URL = scripts[scripts.length - 1].src;
var clientTimestamp = Date.parse(new Date().toUTCString());
@dgamepuzzle
dgamepuzzle / animLoopX.js
Created May 4, 2018 10:17 — forked from louisremi/animLoopX.js
Animation loop with requestAnimationFrame
// Cross browser, backward compatible solution
(function( window, Date ) {
// feature testing
var raf = window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame;
window.animLoop = function( render, element ) {
var running, lastFrame = +new Date;
@dgamepuzzle
dgamepuzzle / .eslintrc.js
Created October 30, 2017 06:34 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {