Skip to content

Instantly share code, notes, and snippets.

Avatar
💯
Going deep with design systems

Ryosuke whoisryosuke

💯
Going deep with design systems
View GitHub Profile
@whoisryosuke
whoisryosuke / whoisryosuke-v1.osm.json
Created May 17, 2022
Oh My Posh - My Custom Theme (based on powerlevel10k + night-owl)
View whoisryosuke-v1.osm.json
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"background": "#ffffff",
"foreground": "#000000",
"leading_diamond": "",
View index.html
<div id="output" style="background:green;min-height:40px">
</div>
View useKeyPress.tsx
import { useEffect, useState } from "react"
// Modified the useKeyPress from useHooks: https://usehooks.com/useKeyPress/
// Takes a `pressMethod` that will run continuously "every frame" (1/60 second - not locked tho)
// And also accepts a `downMethod` and `upMethod` for a single call
// And still returns a simple true/false for the keypress for convenience/use in React
// Ideally all the methods should be an properties of 1 object so user doesn't have to set noop functions to get deeper params
export default function useKeyPress(targetKey: string, pressMethod?: () => void, downMethod?: () => void, upMethod?: () => void): boolean {
// State for keeping track of whether key is pressed
const [keyPressed, setKeyPressed] = useState(false)
@whoisryosuke
whoisryosuke / platform-check.js
Created Dec 29, 2021
JS - Check user platform OS - client side / frontend only - https://stackoverflow.com/a/19176790
View platform-check.js
var OSName = "Unknown";
if (window.navigator.userAgent.indexOf("Windows NT 10.0")!= -1) OSName="Windows 10";
if (window.navigator.userAgent.indexOf("Windows NT 6.3") != -1) OSName="Windows 8.1";
if (window.navigator.userAgent.indexOf("Windows NT 6.2") != -1) OSName="Windows 8";
if (window.navigator.userAgent.indexOf("Windows NT 6.1") != -1) OSName="Windows 7";
if (window.navigator.userAgent.indexOf("Windows NT 6.0") != -1) OSName="Windows Vista";
if (window.navigator.userAgent.indexOf("Windows NT 5.1") != -1) OSName="Windows XP";
if (window.navigator.userAgent.indexOf("Windows NT 5.0") != -1) OSName="Windows 2000";
if (window.navigator.userAgent.indexOf("Mac") != -1) OSName="Mac/iOS";
if (window.navigator.userAgent.indexOf("X11") != -1) OSName="UNIX";
@whoisryosuke
whoisryosuke / index.html
Created Dec 28, 2021 — forked from vhashimotoo/index.html
Dialog Invoke Example
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dialog Example</title>
</head>
<body>
<h1>Dialog Example</h1>
<button id="execute-dialog">Click to show dialog</button>
@whoisryosuke
whoisryosuke / fetch-post-request.js
Created Nov 29, 2021
JS - Fetch POST request as async function
View fetch-post-request.js
(async () => {
const rawResponse = await fetch('https://httpbin.org/post', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({a: 1, b: 'Textual content'})
});
const content = await rawResponse.json();
@whoisryosuke
whoisryosuke / gist:3c482e593dee25e2b9d52f0f850b91ba
Created Nov 22, 2021 — forked from kany/gist:3714996
Git Repo changes ssh fingerprint - how to update your known_hosts file
View gist:3c482e593dee25e2b9d52f0f850b91ba
1) Open known_hosts file and look for the invalid host
nano ~/.ssh/known_hosts
2) Remove the line that has the invalid host. Should be the same host in your .git/config of your repo
ssh-keygen -R [dev.blahblah.com]:1234
3) Pull from repo
git pull
4) You should see something similar to this. Answer 'yes' when asked.
@whoisryosuke
whoisryosuke / MouseLook.cs
Last active Nov 18, 2021
Unity - Basic 3D/FPS Character and Camera Movement + Jumping - based on Brackeyes video: https://www.youtube.com/watch?v=_QajrabyTJc
View MouseLook.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseLook : MonoBehaviour
{
private bool mouseLock = true;
public float mouseSensitivity = 100f;
public Transform playerBody;
@whoisryosuke
whoisryosuke / PointerExample.cs
Created Nov 18, 2021
Unity - Detect input on canvas elements using EventSystem event interfaces (e.g. IPointerClickHandler) -- via: http://answers.unity.com/answers/1095070/view.html
View PointerExample.cs
using UnityEngine;
using UnityEngine.EventSystems; // 1
public class PointerExample : MonoBehaviour
, IPointerClickHandler // 2
, IDragHandler
, IPointerEnterHandler
, IPointerExitHandler
// ... And many more available!
{
@whoisryosuke
whoisryosuke / CheckClicks.cs
Created Nov 18, 2021
Unity - Detect click on canvas using graphic raycaster -- via: http://answers.unity.com/answers/1526703/view.html
View CheckClicks.cs
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class CheckClicks : MonoBehaviour
{
// Normal raycasts do not work on UI elements, they require a special kind
GraphicRaycaster raycaster;