Skip to content

Instantly share code, notes, and snippets.

View RichardBray's full-sized avatar
😎
Fix bug , drink milkshake, code feature, repeat.

Richard Oliver Bray RichardBray

😎
Fix bug , drink milkshake, code feature, repeat.
View GitHub Profile
@RichardBray
RichardBray / glsl_circle.frag
Last active March 19, 2024 19:14
Simple GLSL circle example
#ifdef GL_ES
precision mediump float;
#endif
// Being in values from the CPU
// Read only value sent to all the threads/processes
uniform vec2 u_resolution; // Global vector shader variable
float circleShape(float radius, vec2 position) {
// distance(p1, p2) - returns the distance between two points
@RichardBray
RichardBray / index.ts
Created February 7, 2024 17:21
Simple Hono Api
import { Hono } from 'hono';
import logger from './utils/logger';
const app = new Hono();
const fakeDB: Array<{ text: string; id: number }> = [];
app.get('/', (c) => c.text('Simple Wishlist API'));
app.get('/wishlist', (c) => {
return c.json([...fakeDB], 200);
{
"items": [
{
"name": "Blue T-Shirt",
"price": 19.99,
"description": "A classic blue t-shirt made from soft cotton.",
"image_url": "https://images.pexels.com/photos/11830106/pexels-photo-11830106.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2"
},
{
"name": "Red Hoodie",
@RichardBray
RichardBray / old-gulpfile.js
Last active February 24, 2023 13:13
Old Gulpfile for article/tutorial moving from Gulp to Webpack
var gulp = require('gulp'),
gutil = require('gulp-util'),
sass = require('gulp-ruby-sass'),
minifyCSS = require('gulp-minify-css'),
concat = require('gulp-concat'),
webserver = require('gulp-webserver'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
minifyHTML = require('gulp-minify-html'),
imagemin = require('gulp-imagemin'),
@RichardBray
RichardBray / gulp-to-webpack.md
Last active November 3, 2022 18:51
Moving from Gulp to Webpack

Moving from Gulp to webpack

I've been avoiding learning Webpack for a while now as I never thought I needed to learn another build tool, Gulp does everything I'd ever need from a build tool now or in the future. However, ever since we've moved from AngularJS to Angular (or Angular 2+) as well as introducing standards such as; TypeScript instead of Javascript and a Jasmine/Karma combo for UI testing, but also Webpack as an initial build tool. I've avoided it for long enough and now, in September 2017, I thought it's time to finally move on from my old friend Gulp.

Good Old Gulpfile

If you've never heard of Gulp before, this isn't the post to learn, there are plenty of good tutorials out there a Google search away. Then again, you don't really need to know Gulp to understand what's going on so feel free to continue reading nevertheless.

[Here's wh

@RichardBray
RichardBray / base64pdf.js
Last active July 21, 2021 05:26
Downloading a base 64 pdf code
/**
* Creates an anchor element `<a></a>` with
* the base64 pdf source and a filename with the
* HTML5 `download` attribute then clicks on it.
* @param {string} pdf
* @return {void}
*/
function downloadPDF(pdf) {
const linkSource = `data:application/pdf;base64,${pdf}`;
const downloadLink = document.createElement("a");

Keybase proof

I hereby claim:

  • I am richardbray on github.
  • I am richbray (https://keybase.io/richbray) on keybase.
  • I have a public key ASCLyjIa-d-1ov2SDJYGL9OPmfg6vaAPc8igJnyf9Wrpago

To claim this, I am signing this object:

@RichardBray
RichardBray / shader.frag
Last active September 17, 2020 09:41
Simple fragment shader for beginners with explanations
// # = Preprocessor macros
#ifdef GL_ES // OpenGL Embedded systems needed for openGL on web and mobile devices
precision mediump float; // level of precision for float https://stackoverflow.com/questions/13780609/what-does-precision-mediump-float-mean
// Lower precision means faster compilation but lower quality, above sets all floats to medium precision
#endif
void main() // Main entry point function like c/c++
{
// gl_FragColor = built in global variable to determine pixel color
// werid because you don't see it imported or extended it just exists
@RichardBray
RichardBray / FlxFSM-example.hx
Last active September 1, 2020 09:01
An example file on how to use FlxFSM. A bit simpler than the example from the demo on the HaxeFlixel site.
import flixel.FlxG;
import flixel.FlxObject;
import flixel.FlxSprite;
import flixel.addons.util.FlxFSM;
/**
* Example of how to use the FlxFSM addon.
* For more informtaion on this file check this youtube video.
*
* @see Video-TBA
import { Provider } from "react-redux";
import configureStore from "redux-mock-store";
// ...
describe('App', () => {
// ...
describe('Question', () => {
// - setup redux store