Skip to content

Instantly share code, notes, and snippets.

View LamboCreeper's full-sized avatar
🤔

Lambo LamboCreeper

🤔
View GitHub Profile
@LamboCreeper
LamboCreeper / useAttributesHook.js
Last active September 10, 2020 17:47
A React style hook for easily getting custom attributes when working with web components
function useAttributes(context) {
const attributes = Object.assign({}, Object.keys(context.attributes)
.map(key => context.attributes[key])
.map(data => ({
name: data.name,
value: data.value
}))
);
Object.keys(attributes).forEach((key) => {
{
"auto_close_tags": false,
"auto_complete": false,
"auto_match_enabled": false,
"color_scheme": "Packages/ayu/ayu-dark.tmTheme",
"dictionary": "Packages/Language - English/en_GB.dic",
"font_size": 11,
"ignored_packages":
[
"ColorPicker",
@LamboCreeper
LamboCreeper / capture-material-fixer.py
Created July 18, 2020 11:45
Flips, splits and swaps around an image so that it is in a format that Capture will render correctly.
from sys import argv
from PIL import Image
args = argv
args.remove(args[0])
try:
original_image = Image.open(args[0])
half_width = int(original_image.width / 2)
const CORNERS = {
NORTH_EAST: "┐",
NORTH_WEST: "┌",
SOUTH_WEST: "└",
SOUTH_EAST: "┘"
};
const LINES = {
VERTICAL: "│",
HORIZONTAL: "─"
@LamboCreeper
LamboCreeper / Apple Music Library Contents.scpt
Created May 27, 2020 15:55
Generate a text file with your Apple Music / iTunes library contents (might not work in Catalina)
tell application "iTunes"
set results to ""
repeat with _track in every track
set results to results & (name of _track) & " by " & (artist of _track) & "
"
try
set results_file to ((path to desktop folder) as text) & "Apple Music Library Contents.txt" as text
set the open_results_file to open for access file results_file with write permission
set eof of the open_results_file to 0
write results to the open_results_file starting at eof

REST

  • Representational State Transfer
  • You should always get the most up-to-date data back

Rules of REST

  • A REST API must be stateless
    • Requests do not affect one another
    • You must authenticate yourself on every request
  • Requests must be made via one of four HTTP methods
  • POST - Used for creating new data
import React, { Component, createContext } from "react";
import firebaseApp from "../services/FirebaseService";
export const AuthContext = createContext();
export class AuthProvider extends Component {
state = {
pending: true,
user: {}
};
@LamboCreeper
LamboCreeper / firebase-functions-at-hosting.json
Created January 6, 2020 11:46
Run firebase functions on the same domain as a single page Firebase Hosting.
{
"hosting": {
...,
"rewrites": [{
"source": "/?*",
"function": "default"
}, {
"source": "**",
"destination": "/index.html"
}]