Skip to content

Instantly share code, notes, and snippets.

View unyo's full-sized avatar

Cody Moniz unyo

View GitHub Profile
@unyo
unyo / vite-create.sh
Last active January 25, 2024 05:57
Vite + SWC + styled-components displayName
#!/usr/bin/zsh
npm create vite@latest # choose template react, js + swc
npm i --save-dev @vitejs/plugin-legacy terser @vitejs/plugin-react-swc @swc/plugin-styled-components@1.5.111 # downgrade @swc/plugin-styled-components to 1.5.111 https://github.com/vitejs/vite-plugin-react-swc/issues/190#issuecomment-1907977402
npm i --save styled-components
# edit vite.config.js:
cat <<EOF > vite.config.js
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import legacy from '@vitejs/plugin-legacy'
@unyo
unyo / ExampleDialog.java
Last active April 25, 2023 03:01 — forked from codinginflow/ExampleDialog.java
Simple AlertDialog Tutorial
package com.example.myapplication;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatDialogFragment;
public class ExampleDialog extends AppCompatDialogFragment {
@unyo
unyo / curl-to-form.js
Last active September 2, 2022 20:52
Curl to Form
// https://jsbin.com/datafudezo/1/edit?js,output
const input = ``; // paste your curl from chrome here
const action = input.match(/curl '([^']+)'/)[1];
const data = input.match(/data-raw '([^']+)'/)[1].split('&');
const inputs = data.map(function(keyval) {
const [key, val] = keyval.split('=');
return '<label for="'+key+'">'+key+'</label><br /><input type="text" id="'+key+'" name="'+key+'" value="'+val+'" /><br />';
});
document.write('<form action="'+action+'">'+inputs.join('\n')+'<input type="submit" /></form>');
@unyo
unyo / .zshrc
Created April 14, 2021 02:27
.zshrc with fnm
# fnm
eval "$(fnm env)"
# add fnm autocomplete
fnm completions --shell=zsh > ~/.config/zsh/completions/_fnm # you can run this once and then comment out
fpath+=~/.config/zsh/completions/_fnm
autoload -U compinit
compinit
# autoload .nvmrc
@unyo
unyo / foodcycler.md
Last active September 11, 2020 21:37
FoodCycler foods

Foods that work well in the FoodCycler from experience. Certain foods do not work well in the FoodCycler (starches, sugars), and it seems like this might be related to the digestion issues cured by a ketogenic diet + intermittent fasting.

GOOD:

  • Coffee Grounds (caffeine cooked into the air may cause you to stay awake)

OKAY:

  • Egg Shells
  • Tomatoes
  • Eggplant
  • Banana Peels

LESS OKAY:

  • Papaya Skins (sugar makes the compost smell sweet, it seems to be the only smell that survives digestion)
@unyo
unyo / build-extras.gradle
Created July 18, 2020 08:12
Fix missing _next folder in Cordova. net::ERR_FILE_NOT_FOUND, file:///android_asset/www/_next/*
// this allows cordova to import folders under _next, which are by default ignored for some reason
// copy this file to platforms/android/build-extras.gradle
// https://stackoverflow.com/questions/9206117/how-to-workaround-autoomitting-fiiles-folders-starting-with-underscore-in/55299304#55299304
// https://issues.apache.org/jira/browse/CB-9448?focusedCommentId=15033508&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-15033508
ext.postBuildExtras = {
android {
aaptOptions {
ignoreAssetsPattern "!._"
}
}
[
{
"metadata": {
"id": "fa57ae0e-d21e-40d8-a0bb-a58b5fd9ead3",
"publisherId": "ms-vscode.atom-keybindings",
"publisherDisplayName": "ms-vscode"
},
"name": "atom-keybindings",
"publisher": "ms-vscode",
"version": "3.0.6"
@unyo
unyo / get-object-keys.js
Last active March 23, 2019 03:07
get all object keys js
const getObjectKeys = (obj, prefix = '') => {
return Object.entries(obj).reduce((collector, [key, val]) => {
const newKeys = [ ...collector, prefix ? `${prefix}.${key}` : key ]
if (Object.prototype.toString.call(val) === '[object Object]') {
const newPrefix = prefix ? `${prefix}.${key}` : key
const otherKeys = getObjectKeys(val, newPrefix)
return [ ...newKeys, ...otherKeys ]
}
return newKeys
}, [])
https://keithclark.co.uk/articles/pure-css-parallax-websites/demo1/
Basically, the idea is:
Top-level page container element (contains navbar body footer, the level which the main scrollbar will be) requires:
#___gatsby {
perspective: 1px;
overflow: auto;
height: 100%;
@unyo
unyo / gatsby-ssr.js
Created January 29, 2019 00:49
Remove gatsby FOUC (flash of unstyled content / text)
// apparently there is some hidden settings at https://www.gatsbyjs.org/docs/debugging-replace-renderer-api/#fixing-the-replacerenderer-error
import React from "react"
import { renderToString } from "react-dom/server"
import { ServerStyleSheet, StyleSheetManager } from "styled-components"
export const replaceRenderer = ({
bodyComponent,
replaceBodyHTMLString,
setHeadComponents,
}) => {