Skip to content

Instantly share code, notes, and snippets.

View drblue's full-sized avatar
🔥
All Your Memes Are Belong To Me

Johan Nordström drblue

🔥
All Your Memes Are Belong To Me
View GitHub Profile
@drblue
drblue / netlify.toml
Last active May 23, 2024 12:27
Netlify Config for Vite React apps
# Netlify Config for Vite React apps
#
# See <https://docs.netlify.com/configure-builds/file-based-configuration/>
# for more info on configuring this file.
[build]
command = "tsc && vite build"
functions = "netlify/functions"
publish = "dist"
[[redirects]]
@drblue
drblue / .bashrc
Created November 15, 2022 14:32
Git-prompt for bash
function git-branch-name {
git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3
}
function git-branch-prompt {
local branch=`git-branch-name`
if [ $branch ]; then printf " [%s]" $branch; fi
}
PS1="\u@\h \[\033[0;36m\]\w\[\033[0m\]\[\033[0;32m\]\$(git-branch-prompt)\[\033[0m\] \$ "
@drblue
drblue / products.js
Created March 29, 2022 09:13
Array reduce + map
const products = [
{ name: "Product 1", price: 42 },
{ name: "Product 2", price: 20 },
{ name: "Product 3", price: 1337 },
];
const totalValue = products
.filter(product => product.price > 30)
.reduce( (sum, product) => {
return sum + product.price
@drblue
drblue / classes.js
Last active March 29, 2022 08:54
Classes in JavaScript
class Rectangle {
constructor(rooms, jacuzzi, solarPanels = true) {
if (typeof height !== "number") {
throw new Error("Height is not a number")
}
this.height = height
this.width = width
}
area() {
@drblue
drblue / class.MyWidgetSkeleton.php
Last active June 17, 2021 08:00
A skeleton of a widget.
<?php
class MyWidgetSkeleton extends WP_Widget {
/**
* Construct a new widget instance.
*/
public function __construct() {
parent::__construct(
'my-widget-skeleton', // Base ID
@drblue
drblue / http.js
Created April 6, 2020 15:28
node.js http server example
/**
* http
*/
const http = require('http');
const server = http.createServer();
server.on('request', function (req, res) {
// code here
res.writeHead(200, {
'Content-Type': 'text/html',
@drblue
drblue / events.js
Created April 6, 2020 15:12
node.js event emitter demo (es6)
/**
* events
*/
const events = require('events');
class Person extends events.EventEmitter{
constructor(name){
super();
this.name = name;
}
<?
/////////////////////
// slack2html
// by @levelsio
/////////////////////
//
/////////////////////
// WHAT DOES THIS DO?
/////////////////////
//

Keybase proof

I hereby claim:

  • I am drblue on github.
  • I am dr_blue (https://keybase.io/dr_blue) on keybase.
  • I have a public key ASCKkpIa863N8bf1ZF_o_gLedB3ii5VYUhnRkFZ5fgzqOgo

To claim this, I am signing this object:

@drblue
drblue / class.StarWarsWidget.php
Created May 22, 2019 13:02
Empty StarWars Widget
<?php
/**
* Adds StarWarsWidget widget.
*/
class StarWarsWidget extends WP_Widget {
/**
* Register widget with WordPress.