Skip to content

Instantly share code, notes, and snippets.

View BadgerBadgerBadgerBadger's full-sized avatar

Badger BadgerBadgerBadgerBadger

View GitHub Profile
@BadgerBadgerBadgerBadger
BadgerBadgerBadgerBadger / read-n-reset-request-body.go
Created August 23, 2022 09:43
Golang: Read full request body but reset it so downstream handlers can still use it.
func(w http.ResponseWriter, r *http.Request) {
body, err := io.ReadAll(r.Body)
if err != nil {
// do some error handling
return
}
r.Body.Close()
/*
* Kontra.js v5.0.4 (Custom Build on 2018-12-12) | MIT
* Build: https://straker.github.io/kontra/download?files=gameLoop+keyboard+sprite+assets+pool+pointer+quadtree+spriteSheet+tileEngine+store
*/
kontra={init(n){var t=this.canvas=document.getElementById(n)||n||document.querySelector("canvas");this.context=t.getContext("2d"),this._init()},_noop:new Function,_tick:new Function,_init:new Function};
kontra.gameLoop=function(e){let t,n,a,r,o=(e=e||{}).fps||60,i=0,p=1e3/o,c=1/o,s=!1===e.clearCanvas?kontra._noop:function(){kontra.context.clearRect(0,0,kontra.canvas.width,kontra.canvas.height)};function d(){if(n=requestAnimationFrame(d),a=performance.now(),r=a-t,t=a,!(r>1e3)){for(kontra._tick(),i+=r;i>=p;)m.update(c),i-=p;s(),m.render()}}let m={update:e.update,render:e.render,isStopped:!0,start(){t=performance.now(),this.isStopped=!1,requestAnimationFrame(d)},stop(){this.isStopped=!0,cancelAnimationFrame(n)}};return m};
!function(){let n={},t={},e={13:"enter",27:"esc",32:"space",37:"left",38:"up",39:"right",40
# Kills the process running at the port passed into the argument.
# `lsof -i :${1}` gets the processes running at the specified port.
# `awk NR==2` gets the second line which is the first record from lsof.
# `awk '{print $2}')` gets the second column, which is the pid of the process.
# This is evaluated and the result used as the arg for the `kill` command.
kill $(lsof -i :${1} | awk NR==2 | awk '{print $2}')
body, html{
background-image: image-url('blu-tex.png');
font-size: 100%;
}
a{
color: inherit;
text-decoration: inherit;
}
$(function() {
$('.nav-button').on('click', function() {
alert('lo');
});
});
<nav class = 'main-nav' id = "main_nav">
<div class = 'left-nav'>
<%= link_to 'HOME', '/', class: 'nav-button' %>
<%= link_to 'ABOUT', 'about', class: 'nav-button' %>