Skip to content

Instantly share code, notes, and snippets.

View grundmanise's full-sized avatar
🔮
It's magic

Edgar grundmanise

🔮
It's magic
View GitHub Profile
@alexanderisora
alexanderisora / finishJson5.ts
Created May 11, 2023 15:28
function to complete an unfinished JSON.
export const finishJson5 = (unfinishedJson5: string) => {
let stack = [];
let inDoubleQuotes = false;
let inSingleQuotes = false;
let inSingleLineComment = false;
for (let i = 0; i < unfinishedJson5.length; i++) {
const currentChar = unfinishedJson5[i];
const nextChar = unfinishedJson5[i + 1];
let prevChar;
@getify
getify / 1.js
Last active August 4, 2023 06:24
Converting English number sentences ("one hundred forty two point three") to numeric digits ("142.3")
convert("one hundred five"); // "105"
convert("six hundred and fifty three"); // "653"
convert("zero zero one two three"); // "123"
convert("twelve o three"); // "1203"
convert("thirteen zero nine"); // "1309"
convert("fifteen sixteen"); // "1516"
convert("fourteen ninety two"); // "1492"
convert("nineteen ten"); // "1910"
convert("twelve hundred"); // "1200"
convert("twenty three hundred"); // "2300"
@gragland
gragland / stripe-webhook.js
Last active January 18, 2024 22:20
Next.js Stripe Webhook from divjoy.com
const getRawBody = require("raw-body");
const { updateUserByCustomerId } = require("./_db.js");
const stripe = require("stripe")(process.env.STRIPE_SECRET_KEY, {
apiVersion: process.env.STRIPE_API_VERSION,
});
// Disable next.js body parsing (stripe needs the raw body to validate the event)
export const config = {
api: {

What Hiring Should Look Like

This is definitely not the first time I've written about this topic, but I haven't written formally about it in quite awhile. So I want to revisit why I think technical-position interviewing is so poorly designed, and lay out what I think would be a better process.

I'm just one guy, with a bunch of strong opinions and a bunch of flaws. So take these suggestions with a grain of salt. I'm sure there's a lot of talented, passionate folks with other thoughts, and some are probably a lot more interesting and useful than my own.

But at the same time, I hope you'll set aside the assumptions and status quo of how interviewing is always done. Just because you were hired a certain way, and even if you liked it, doesn't mean that it's a good interview process to repeat.

If you're happy with the way technical interviewing currently works at your company, fine. Just stop, don't read any further. I'm not going to spend any effort trying to convince you otherwise.

@ireade
ireade / sw.js
Last active October 7, 2023 20:56
Handle broken images with the service worker
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open("precache").then((cache) => cache.add("/broken.png"))
);
});
function isImage(fetchRequest) {
return fetchRequest.method === "GET" && fetchRequest.destination === "image";
}
@authenticsebastian
authenticsebastian / click.js
Created May 16, 2018 15:26
Click on unfolded files in Github
[].slice.call(document.querySelectorAll('.js-file-header'))
.filter((item) => item.dataset.path.indexOf('{file-name-part}') > -1 && !item.parentNode.classList.contains('Details--on'))
.map((header) => header.querySelector('.js-details-target'))
.forEach((item) => item.click())
pragma solidity ^0.4.11;
// @calvin_claus' contract
// @neuling2k didn't do anything
contract CryptoLambo {
address public dev1;
address public dev2;
@authenticsebastian
authenticsebastian / fizz-buzz.js
Last active February 12, 2018 11:25
Functional take on FizzBuzz
const processNumber = (data, condition, message) => data + (condition ? message : '');
const hasNoRemainder = (number, divider) => number % divider === 0;
const rule = (value, message) => (number, data) =>
processNumber(data, hasNoRemainder(number, value), message);
const rules = [
rule(3, 'Fizz'),
rule(5, 'Buzz')
@bvaughn
bvaughn / eager-prefetching-async-data-example.js
Last active November 30, 2022 21:16
Advanced example for eagerly prefetching async data in a React component.
// This is an advanced example! It is not intended for use in application code.
// Libraries like Relay may make use of this technique to save some time on low-end mobile devices.
// Most components should just initiate async requests in componentDidMount.
class ExampleComponent extends React.Component {
_hasUnmounted = false;
state = {
externalData: null,
};