Skip to content

Instantly share code, notes, and snippets.

View slugbyte's full-sized avatar
⌨️

Duncan Marsh slugbyte

⌨️
View GitHub Profile
hash = (value) => {
if(isNaN(value)) return btoa("NaN" + Number.toString() + Number.name + Number.length)
switch(typeof value){
case 'function':
return btoa(value.name + value.length + value.toString())
default:
return btoa(JSON.stringify(value))
}

cool hello world

Enhance your *nix manuals with colors using this bash functoin

To install all you need to do is

  1. Add the following code to your bash config and then source it
  2. Then look at a manual i.e. $ man man
man() {
  env \
 LESS_TERMCAP_mb=$(printf "\e[1;31m") \

Day 6 with the space heater.

最後我家裡很舒服,可以再玩.

(Skip to the next headding for #dev-diaries you don't want read #me-diaries)

Until recently I have been on an accidental haiatus from writing code for my self for about a year. No regrets here, life just got complicated and I had to focus my attention elsewhere. I had been peddling div tags part time, but due to the life things my head wasn't in it and I wasn't having fun, BUT FOR ME CODING ISSSS FUNNN! I think probbly even the FUNERISTEST. It always was before and now it is again, whoot.

The good news is I have so many new curiosities, and I'm really excited about finding ways to write me-code that will be fun and useful for more that me-peeps. For the near future my biggest intention is to slam my fingers on the keyboard to get my chops back, but I plan on doing a better job of documenting my processes, writing better docs and commit messages, and maybe even capture some video tutorials. My 真的 future plans are to dig in to some open-source projects an

// TEST SPEEDS OF DIFFERINT TYPES OF OBEJCT INSTANTIATION
// Im working on github.com/slugbyte/data-structures and have been testing out differnt coding styles for
// implamenting my ADSs. At first I was mosly intresed in the asthetics of my coding, because I
// have been intrested for a while in expiermenting with coding style. But I recenlty started reading about diffrent
// Speed implications using functions like Object.prototype and Object.create so I decited to go ahead write my self
// some SPEED TESTS!
// I created the following simple note using each instationation method
// {type: 'todo', value: 'get eggs'}
testSpeed = ({cb, tries=10, iterations=Math.pow(2, 20)}) => {
let state = {
tries,
iterations,
results: []
}
for (var t =0; t < tries; t++){
let startTime = Date.now()
for(var i = 0; i < iterations; i++){
cb()
// worst names ever but it shows that instantionation with the new keyword is many orders of magnitude faster than
// using object.create or object.setPrototypeOf or Object.defineProperties :(
// WHYYYYYY
class cls {
constructor(){
this.x = 'x'
this.y = 'y'
this.z = 'z'
}
// server certs
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
// client cert
echo quit | openssl s_client -showcerts -servername localhost -connect localhost:3000 > cacert.pem
let trampoline = (fn) => (...args) => {
let next = fn(...args)
while(next instanceof Function)
next = next()
return next
}
let range = (start, end, result=[]) => {
result.push(start)
if(start === end) return result
_main
OUT 1 0
JMP _on
_loop
JGT A 64 _flip
OUT x80 A
ADD 1 A
JMP _loop