Skip to content

Instantly share code, notes, and snippets.

View lewdev's full-sized avatar

Lewis Nakao lewdev

View GitHub Profile
@lewdev
lewdev / #README.md
Last active September 23, 2024 01:42
💀 Dweetegem Hero #helldivers #strategem as a Dweet

💀 Dweetegem Hero #helldivers #strategem as a Dweet

I love the new Helldivers 2 game and made a Dweet-sized version of Strategem Hero.

a="⬅⬆➡⬇"
t?c.width=99:n=b=0
x.fillText((s=[...Object.keys(this)[n]].map(v=>a[v.charCodeAt()%4]).join``).substr(b),1,9)
onkeyup=e=>a[(e.keyCode-5)%4]==s[b]&&++b>=s.length&&(b=0,n++)
@lewdev
lewdev / README.md
Last active November 15, 2024 03:24
🤏 Dweet/Tiny Code Tips

🤏 Dweet/Dwitter/Tiny Code/Code Golf Tips

A collection of tips when writing tinycode or dweets. It's getting hard for me to find the dweets that have neat tricks. I'll add more as I find more.

👉 Tip 1: Math.floor equivalents: value|0, value>>0, and ~~(value)

For example when rounding down a value multiplied by Math.random, you can add |0.

Example getting a random integer from 0 to 254 (inclusive):

@lewdev
lewdev / #README.md
Last active December 28, 2024 22:55
🏯💳 Dungeon Generator on a business card #bookmarklet
@lewdev
lewdev / readme.md
Created December 22, 2023 05:14
💎 Link's Awakening DX HD PC Port
@lewdev
lewdev / Install⁄Update Xone
Created December 1, 2023 09:13 — forked from cdleveille/Install⁄Update Xone
Install or update xone driver for Steam Deck (desktop shortcut and bash script)
[Desktop Entry]
Comment[en_US]=
Comment=
Exec=bash $HOME/xone_install_or_update.sh
GenericName[en_US]=
GenericName=
Icon=preferences-desktop-gaming
MimeType=
Name[en_US]=Install⁄Update Xone
Name=Install⁄Update Xone
@lewdev
lewdev / tank-movement.html
Last active November 23, 2023 02:33
🚗 Tank Movement in JavaScript Canvas
<style>html,body{background:#222;display:flex;justify-content:center;align-items:center;height:100%;margin:0}#c{background:white;max-height:100%;max-width:100%}</style><canvas id=c width=1080 height=1080></canvas><script>x=c.getContext`2d`,lfr=1,S=Math.sin,C=Math.cos,T=Math.tan,R=(r,g,b,a=1)=>`rgba(${r|0},${g|0},${b|0},${a})`,t=f=nfm=0;
const vec2 = (x,y=x)=>new Vec2(x, y);
class Vec2 {
constructor(x = 0, y = 0) { this.x = x; this.y = y; }
copy() { return vec2(this.x, this.y); }
scale(s) { return vec2(this.x * s, this.y * s); }
add(v) { return vec2(this.x + v.x, this.y + v.y); }
subtract(v) { return vec2(this.x - v.x, this.y - v.y); }
@lewdev
lewdev / replace-canvas-color.html
Created October 29, 2023 02:59
🖼 Replace Canvas Color
<!doctype html>
<head><title>Replace Canvas color with transparent one</title></head>
<p>This code demonstrates taking "imageData" from the canvas and evaluating each pixel color and replacing it with an alpha value of "0".</p>
<p>This also can change the given color (#0F0, green, in this case) with another color.</p>
<p>This is useful when you can also get a PNG image to do this on.</p>
<canvas id="c"></canvas>
@lewdev
lewdev / Retro games for 4 players.md
Created October 22, 2023 08:34
🕹 List of retro games for 4 players

🕹 List of retro games for 4 players

Source

NES:

  • Anticipation
  • 8-Bit Xmas 2011
  • Bomberman II
  • Championship Bowling [3]
  • Danny Sullivan's Indy Heat
@lewdev
lewdev / #lodash-uniq-implementations.md
Last active October 13, 2023 01:40
👨‍💻 Three Implementations of `lodash` `_.uniq` (shortest being 22 chars)

👨‍💻 Three Implementations of lodash _.uniq

I was writing tiny code and attempted to get all unique values of an array.

I totally forgot the best implementation, but I thought my first 2 implementations use some interesting code golfing techniques.

The html file demonstrates its uses on an array of primitive values.

👉 Method 1 (46b): find its duplicate in an array and add or not using the reduce method

@lewdev
lewdev / fire-emoji.html
Created October 8, 2023 10:48
🔥 Making a fire-particle effect using emojis
<style>html,body{background:#222;display:flex;justify-content:center;align-items:center;height:100%;margin:0}#c{background:white;max-height:100%;max-width:100%}</style>
<canvas id=c width=1080 height=1080></canvas>
<script>
x=c.getContext`2d`,lfr=1,S=Math.sin,C=Math.cos,T=Math.tan,R=(r,g,b,a=1)=>`rgba(${r|0},${g|0},${b|0},${a})`,t=f=nfm=0;z=t=>{
c.width|=0
t||(e=500,R=Math.random,a=new Array(e).fill({X:e,Y:e,}).map((b,i)=>({...b,Z:R()*(-Math.PI),T:0})))
x.font="1in'"
for(d of a)(t>d.T?(d.T=t+R(),d.X=e,d.Y=e):0,x.fillText('🔥',d.X+=C(d.Z),d.Y+=S(d.Z)*3))