Skip to content

Instantly share code, notes, and snippets.

@raym
raym / React Router multiple layer with outlet
Created December 21, 2023 16:32
Multiple Layer Page with React Router Outlets
import { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock'
import { isNil, isNotNil } from 'ramda'
import React, { useEffect, useRef } from 'react'
import { useOutlet } from 'react-router-dom'
import renderIfElse from '../../lib/renderIfElse'
import Overlay from '../../portals/Overlay'
const MyMultiLevelPageComponent = () => {
const outletWrapperRef = useRef(null)
const outlet = useOutlet()
@raym
raym / allCombinations.js
Created June 17, 2020 04:53
finding all combinations of musical things using Ramda
const chars = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
@raym
raym / strip_emojis.rb
Last active June 23, 2024 19:33
Strip emoji characters in Ruby
def strip_emojis(text)
text = text.force_encoding('utf-8').encode
clean = ""
# symbols & pics
regex = /[\u{1f300}-\u{1f5ff}]/
clean = text.gsub(regex, "")
# enclosed chars
regex = /[\u{2500}-\u{2BEF}]/
ffmpeg -i src.mp4 -c copy -metadata:s:v:0 rotate=180 dest.mp4
@raym
raym / node-express-stream-mp3
Last active July 23, 2018 12:56
Stream/proxy/pipe an mp3 file using express node.js web app framework.
var
_ = require('underscore'),
https = require('https'),
express = require('express'),
app = express()
;
app.get('/audioFile.mp3', function(req, res) {
https.get('https://example.com/any-mp3-file.mp3', function(audioFile) {
res.set(_.extend(_.pick(audioFile.headers, 'accept-ranges', 'content-type', 'content-length'), { 'Access-Control-Allow-Origin': '*' }));
@raym
raym / xyzprinting-da-vinci-1.0-calibration.md
Last active September 28, 2021 14:11
XYZprinting Da Vinci 1.0 Calibration

#TL;DR

- given that the "ideal" numbers are +255, +255, +255
- adjust screw A til #1 is close to +255
- adjust screw B til #2 & #3 are close to equal
  - this may require adjusting screw C if #2 or #3 start +ERR-ing
- adjust screw C til #2 & #3 are close to #1

@raym
raym / pebbles.js
Created April 26, 2015 05:06
a favorite visual pattern of mine. can be used in browser js console or as bookmarklet
p="";while(p.length<100000)p+=['o','O','0',')','('][Math.floor(Math.random()*5)];document.body.innerHTML=p
@raym
raym / getDomain.js
Created April 23, 2015 04:56
small js function to get the domain of a url
function getDomain(url) {
var a = document.createElement('a');
a.href = url;
return a.hostname;
}
@raym
raym / remove_git_commits.sh
Created April 11, 2015 15:37
ways to remove commits from git
# method 1
git reset --hard $rollback_to_hash # rollback locally
git push --force # force-push
# method 2
git reset --soft HEAD^ # remove commit locally
git push origin +master
# method 3
git reset HEAD^ # remove commit locally
@raym
raym / rename_remote_branch.sh
Created April 5, 2015 18:42
rename a branch that you've pushed to a remote
git push origin :oldname
git branch -m oldname newname
git push origin newname