Skip to content

Instantly share code, notes, and snippets.

@davidfurlong
davidfurlong / JSON.stringify-replacer-sort-keys.js
Last active May 5, 2024 05:54
JSON.stringify replacer function for having object keys sorted in output (supports deeply nested objects)
// Spec http://www.ecma-international.org/ecma-262/6.0/#sec-json.stringify
const replacer = (key, value) =>
value instanceof Object && !(value instanceof Array) ?
Object.keys(value)
.sort()
.reduce((sorted, key) => {
sorted[key] = value[key];
return sorted
}, {}) :
value;
@hassansin
hassansin / eloquent-cheatsheet.php
Last active May 5, 2024 05:53
Laravel 5 Eloquent CheatSheet #laravel #eloquent
Model::
/*Select*/
select('col1','col2')
->select(array('col1','col2'))
->select(DB::raw('businesses.*, COUNT(reviews.id) as no_of_ratings, IFNULL(sum(reviews.score),0) as rating'))
->addSelect('col3','col4')
->distinct() // distinct select
/*From*/
@machikoyasuda
machikoyasuda / diy-e-bike-conversion-readme.md
Last active May 5, 2024 05:52
diy-e-bike-conversion-readme.md

D.I.Y. E-bike conversion

image

Components

  1. Front G311 Kit - Front wheel pre-laced with geared hub motor - $300
  2. Motor controller, C4820-GR_Higo - $100
  3. Thumb throttle, attached to handlebars - $15
  4. G311 Torque Arm, attached to front dropouts - $20
@taylorza
taylorza / GO-Fillslice.md
Last active May 5, 2024 05:51
Golang - Fill slice/array with a pattern

Filling an array or slice with a repeated pattern

Looking for an efficient pure GO approach to copy repeating patterns into a slice, for a toy project, I ran a few tests and discovered a neat approach to significantly improve performance. For the toy project, I am using this to fill a background buffer with a specific RGB color pattern, so improving this performance significantly improved my acheivable framerate.

All the test were run with a buffer of 73437 bytes, allocated as follows

var bigSlice = make([]byte, 73437, 73437)

Fill the slice with the value 65 by looping through each element and setting the value

@Sukhendra523
Sukhendra523 / Portfolio.md
Last active May 5, 2024 05:49
My Portfolio

Hello <πšŒπš˜πšπšŽπš›πšœ/>!, I'm Sukhendra Rajawat

A passionate MERN Stack developer from India

@Chainso
Chainso / league-of-legends-install.yml
Created May 19, 2019 23:25
League of Legends Lutris Install
name: "League of Legends"
runner: "wine"
version: "Installer"
slug: "league of legends"
game_slug: "league of legends"
script:
files:
- lol_installer: https://riotgamespatcher-a.akamaihd.net/releases/live/installer/deploy/League%20of%20Legends%20installer%20NA.exe
game:
exe: drive_c/Riot Games/League of Legends/LeagueClient.exe
@OrionReed
OrionReed / dom3d.js
Last active May 5, 2024 05:42
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // Β―\\_(ツ)_/Β―
@palewire
palewire / README.md
Last active May 5, 2024 05:41
How to push tagged Docker releases to Google Artifact Registry with a GitHub Action

How to push tagged Docker releases to Google Artifact Registry with a GitHub Action

Here's how I configured a GitHub Action so that a new version issued by GitHub's release interface will build a Dockerfile, tag it with the version number and upload it to Google Artifact Registry.

Before you attempt the steps below, you need the following:

  • A GitHub repository that contains a working Dockerfile
  • The Google Cloud SDK tool gcloud installed and authenticated

Create a Workload Identity Federation

@bradtraversy
bradtraversy / js_linked_list.js
Last active May 5, 2024 05:37
JS Linked List Class
// Construct Single Node
class Node {
constructor(data, next = null) {
this.data = data;
this.next = next;
}
}
// Create/Get/Remove Nodes From Linked List
class LinkedList {
@Drallas
Drallas / High Available Pi-hole failover cluster using Keepalived and Orbital Sync.md
Last active May 5, 2024 05:36
High Available Pi-hole failover cluster using Keepalived and Orbital Sync