Skip to content

Instantly share code, notes, and snippets.

View findscode's full-sized avatar
🗿

George Puisha findscode

🗿
View GitHub Profile
@findscode
findscode / camel-to-upper-snake.ts
Created April 21, 2022 18:21
TypeScript `CamelCase to UPPER_SNAKE_CASE` type
type CamelToUpperSnake<T extends string, P extends string = ''> = string extends Uncapitalize<T> ? string :
T extends `${infer C0}${infer R}` ?
CamelToUpperSnake<R, `${P}${C0 extends Uppercase<C0> ? '_' : ''}${Uppercase<C0>}`> : P;
// works with both camelCase and CamelCase
@findscode
findscode / track-name-beautifier.js
Created July 5, 2021 18:40
A track name beautifier used by me to manage around 1k of Liquid D&B files
const fs = require('fs');
const path = require('path');
const directory = './Liquid';
(async () => {
const files = await fs.promises.readdir(directory);
for (const file of files) {
const name = file
@findscode
findscode / get-bpm.rb
Created July 10, 2019 22:03
Sonic Pi: function that helps with sample BPM counting
define :getBpm do |samp, beats|
t = sample_duration samp
bps = t/beats
beatsPerMin = 60/bps
return beatsPerMin
end
puts getBpm(:loop_amen, 4)
@findscode
findscode / dnb.rb
Created July 10, 2019 22:01
My Drum&Bass template
samps = "C:/Program Files (x86)/Sonic Pi/etc/my-samples"
use_bpm 170
live_loop :metro do
sleep 1
cue :beat
sleep 7
cue :ambient
end
@findscode
findscode / index.js
Created June 9, 2019 21:43
Scrap Facebook events using puppeteer.js (now with infinite scrolling)
const puppeteer = require("puppeteer");
(async () => {
const autoScroll = async (page) => {
await page.evaluate(async () => {
await new Promise((resolve, reject) => {
let totalHeight = 0;
const distance = 100;
const timer = setInterval(async () => {
const scrollHeight = document.body.scrollHeight;
@findscode
findscode / index.js
Last active June 8, 2019 11:26
Scrap Facebook events via puppeteer.js (no scroll)
const puppeteer = require("puppeteer");
(async () => {
try {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto("https://www.facebook.com/events/discovery/?suggestion_token=%7B%22city%22%3A%22107677462599905%22%2C%22time%22%3A%22tomorrow%22%7D");
await page.waitForSelector("div.clearfix > div > div > div > div > div > a");
@findscode
findscode / README-Template.md
Created July 11, 2018 11:50 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@findscode
findscode / Max element of an array of objects
Created April 27, 2018 15:52
Max element of an array of objects
Math.max(...container.map((element) => element.field));