Skip to content

Instantly share code, notes, and snippets.

@psema4
psema4 / gist:a8003f1f09d77743e85750e6aefb7a65
Created August 8, 2018 04:06 — forked from borismus/gist:1032746
Convert a base64 string into a binary Uint8 Array
var BASE64_MARKER = ';base64,';
function convertDataURIToBinary(dataURI) {
var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
var base64 = dataURI.substring(base64Index);
var raw = window.atob(base64);
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
for(i = 0; i < rawLength; i++) {
@psema4
psema4 / prover.js
Created May 20, 2017 17:56 — forked from othiym23/prover.js
Simple proof-of-work server for Node.js.
'use strict';
/* To test:
* echo -n <input> | nc localhost 1337
*
* Results are <input>:<nonce>
*
* Passing e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e should get back
* e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e:2c8
*/
@psema4
psema4 / slackpost
Created February 4, 2017 21:48 — forked from dopiaza/slackpost
Post a message to a Slack channel
#!/bin/bash
# Usage: slackpost <token> <channel> <message>
# Enter the name of your slack host here - the thing that appears in your URL:
# https://slackhost.slack.com/
slackhost=PUT_YOUR_HOST_HERE
token=$1
@psema4
psema4 / tmux_cheatsheet.markdown
Created November 22, 2016 19:21 — forked from henrik/tmux_cheatsheet.markdown
tmux cheatsheet

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@psema4
psema4 / TerrainGenerator.cs
Created September 1, 2016 03:59 — forked from Coac/TerrainGenerator.cs
A basic procedural terrain generation make in Unity3D
using UnityEngine;
using System.Collections;
public class TerrainGenerator : MonoBehaviour {
public Texture2D grassTexture;
public Texture2D rockTexture;
void Start()
@psema4
psema4 / readme.md
Created July 23, 2016 18:17 — forked from xem/readme.md
Maths & trigonometry cheat sheet for 2D & 3D games

Conventions

  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

@psema4
psema4 / example.md
Created July 7, 2016 00:35 — forked from ericclemmons/example.md
HTML5 <details> in GitHub

Using <details> in GitHub

Suppose you're opening an issue and there's a lot noisey logs that may be useful.

Rather than wrecking readability, wrap it in a <details> tag!

<details>
 <summary>Summary Goes Here</summary>
@psema4
psema4 / ep_app.js
Created June 16, 2016 16:13 — forked from focusaurus/ep_app.js
Example of how a main express app can mount sub-applications on a mount point with app.use('/mount-point', subapp); If you GET /, you'll see the main_app's '/' response. If you GET /ep_app, you'll see the ep_app's '/' response.
var express = require("express");
var app = express();
app.get('/', function (req, res) {
res.send("This is the '/' route in ep_app");
});
module.exports = app;
@psema4
psema4 / slim-container-examples.php
Created May 12, 2016 03:07 — forked from akrabat/slim-container-examples.php
Example uses of Slim 3's container
<?php
// All file paths relative to root
chdir(dirname(__DIR__));
require "vendor/autoload.php";
$settings = ['foo' => 'FOO', 'bar' => 'BAR'];
$app = new \Slim\App($settings);
// Set some things into the container