Skip to content

Instantly share code, notes, and snippets.

@stephanbogner
stephanbogner / 1-pico8-godot-shader.shader
Last active January 30, 2024 19:23
PICO-8 color palette (or any other) shader for Godot (with the .html file below you can easily adjust the shader to any color palette)
// Adapted from "How to Limit Color Output with Shaders in Godot"
// By TheBuffED
// On https://www.youtube.com/watch?v=Scrdv4oSeNw
// Type of shader https://docs.godotengine.org/en/3.0/tutorials/shading/shading_language.html#shader-types
shader_type canvas_item;
// The shader strength which between 0 (not applied) and 1 (fully applied) because I want to fade the shader in and out
// Can be changed from node via `get_material().set_shader_param("shaderStrength", newValue)`
uniform float shaderStrength = 1.0;
@stephanbogner
stephanbogner / index.html
Created March 4, 2021 14:23
Simple example of sending files (images in my case) with jQuery (or HTML form) to a NodeJS Express backend using Multer
// Code for client
// Should be put inside a folder called 'public', so Express serves it (see line 12 in index.js)
<input id="hiddenFileInput" style="display:none;" type="file" multiple>
<button id="button">Upload files</button>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script type="text/javascript">
$('#button').on('pointerdown', () => {
$('#hiddenFileInput').click(); //Used so we can use a custom button for file upload
@stephanbogner
stephanbogner / example.html
Last active December 28, 2022 08:45
Extract hex color codes from a string (e.g. text, SVG, HTML, XML) using a regex in JS
<script type="text/javascript">
let testString = ''
testString += '<div style="color: #00A9F8"></div><div style="color: #12345"></div>';
testString += '<div style="color: 00A9F8"></div><div style="color: #123456"></div>';
testString += '<div style="color: #fff"></div><div style="color: #000"></div>';
let regularExpression = /#(?:[0-9a-fA-F]{3}){1,2}/g // btw: this is the same as writing RegExp(/#(?:[0-9a-fA-F]{3}){1,2}/, 'g')
let extractedHexCodes = testString.match(regularExpression);
@stephanbogner
stephanbogner / Formulas.md
Last active January 25, 2021 09:12
Create date range in Google Sheets from calendar week (with 00:00 on the first date and 23:59 on the end date)

Screenshot 2021-01-25 at 09 53 22

Formula start date (year 2021 hardcoded in my case)

=TEXT(DATE(2021; 1; -3 + 7 * SPLIT( LOWER($A2) ; "abcdefghijklmnopqrstuvwxyz " ) - WEEKDAY(DATE(2021; 1; 4); 2) + 1); "dd.mm.yyyy 00:00")

Formula end date (year 2021 hardcoded in my case)

=TEXT(DATE(2021; 1; -3 + 7 + 7 * SPLIT( LOWER($A2) ; "abcdefghijklmnopqrstuvwxyz " ) - WEEKDAY(DATE(2021; 1; 4); 2)); "dd.mm.yyyy 23:59")

Note

Not all would be necessary just for the date range, but I wanted to write "CW XYZ" and needed the time as well for some calculation

@stephanbogner
stephanbogner / index.html
Created January 21, 2021 13:35
My simple template/boilerplate/skeleton/foundation/... for parsing CSV data with javascript (via PapaParse) to e.g. do some quick data analysis
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Data analysis</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
@stephanbogner
stephanbogner / easeInOutQuad.js
Created February 17, 2019 20:30
Easing function
// Different structure of an easing formula from https://github.com/danro/jquery-easing/blob/master/jquery.easing.js for better understanding
function easeInOutQuad (currentTime, duration, fromValue, toValue) {
var t = currentTime;
var b = fromValue;
var c = toValue - fromValue;
var d = duration;
if ((t/=d/2) < 1) return c/2*t*t + b;
return -c/2 * ((--t)*(t-2) - 1) + b;
}
@stephanbogner
stephanbogner / gist:d0f84a6a54128d19b3829c3ac788f2a2
Created August 22, 2018 16:34
Egrep command to find unwanted symbols in a text file
egrep -nh '[^[:alnum:][:punct:]\ \nöäüÜÄÖß]' --color=always
@stephanbogner
stephanbogner / Paperlike.css
Created August 8, 2018 16:06
A theme for MacDown which is inspired by Dropbox Paper
/* Version from 180808 */
* {
margin: 0;
padding: 0;
}
@media only screen and (max-width: 320px) {
p,h1,h2,h3,h4,h5,ul,ol,hr {
padding-left: 0.5rem;
@stephanbogner
stephanbogner / index.html
Created June 25, 2018 20:36
Native like pinch and zoom of div with HammerJs
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HammerJS Pinch Zoom and Drag</title>
<style type="text/css">
body{
margin: 0;
@stephanbogner
stephanbogner / index.js
Created May 30, 2018 09:54
Most simple example to pass data from child to parent in react
class Parent extends React.Component{
useDataFromChild = (value) => {
console.log(value)
}
render() {
return (
<div>
<Child name="Option: Little" onReceiveData={this.useDataFromChild}/>
<Child name="Option: Many" onReceiveData={this.useDataFromChild}/>