Skip to content

Instantly share code, notes, and snippets.

View georapbox's full-sized avatar

George Raptis georapbox

View GitHub Profile
@georapbox
georapbox / README
Last active August 29, 2015 14:03 — forked from joelambert/README
Drop in replace functions for setTimeout() & setInterval() that
make use of requestAnimationFrame() for performance where available
http://www.joelambert.co.uk
Copyright 2011, Joe Lambert.
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php
@georapbox
georapbox / fillLocalStorage.js
Created November 9, 2016 11:56 — forked from tbassetto/fillLocalStorage.js
Fill localStorage until the last byte possible
// Only count bytes inserted as values, not counting keys...
(function() {
localStorage.clear();
var nbBytes = 5000, // about 0.5Mb
oneByte = 'x',
i = 0,
totalBytesInserted = 0;
function repeat(string, length) {
@georapbox
georapbox / client.js
Created May 15, 2017 12:51 — forked from crtr0/client.js
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
@georapbox
georapbox / readFileInChunks.js
Last active June 13, 2019 12:23 — forked from alediaferia/tiny_uploader.js
A tiny snippet for reading files chunk by chunk in plain JavaScript
/**
* Read files chunk by chunk.
*
* @param {File} file The file object to read in chunks.
* @param {Object} [options={}] Options object to override defaults.
* @param {Number} [chunkSize= 64 * 1024] The chunk size (in bytes) to be used. Default is 64KB.
* @param {Boolean} [binary=false] If true chunks will be read through FileReader.readAsArrayBuffer otherwise as FileReader.readAsText. Default is `false`.
* @param {Function} [chunkReadCallback=()=>{}] Optional function that accepts the read chunk as its only argument.
* If `binary` option is set to `true`, this function will receive an instance of `ArrayBuffer`, otherwise a `String`.
* @param {Function} [chunkErrorCallback=()=>{}] Optional function that accepts an object of type `FileReader.error`.

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.

function partition(inputArray, callback) {
const result = {};
for (const [indexOfValue, value] of inputArray.entries()) {
const propertyKey = callback(value, indexOfValue);
if (propertyKey === null || propertyKey === '') {
continue;
}
if (!{}.hasOwnProperty.call(result, propertyKey)) {
result[propertyKey] = [];
}
@georapbox
georapbox / easings.css
Created September 28, 2020 07:43 — forked from argyleink/easings.css
Handy CSS properties for easing functions
:root {
--ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
--ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);
--ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22);
--ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);
--ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);
--ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335);
--ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
--ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
--ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
@georapbox
georapbox / commands.sh
Created November 26, 2020 08:01 — forked from dstranz/commands.sh
nice option to use bundler on macOS Catalina without playing with sudo or rvm like before
# install bundler in user space
gem install bundler --user-install
# then add following lines to ~/.zshrc on Catalina or ~/.bash_profile on older:
# - to set default bundle install directory
export BUNDLE_PATH=$(ls -t -U | ruby -e 'puts Gem.user_dir')
# - to add user gem directory to $PATH
export PATH="$PATH:$BUNDLE_PATH/bin"

ServiceWorker for github pages

This is a ServiceWorker template to turn small github pages into offline ready app.

Why ?

Whenever I make small tools & toys, I create github repo and make a demo page using github pages (like this one).
Often these "apps" are just an index.html file with all the nessesary CSS and JavaScript in it (or maybe 2-3 html/css/js files). I wanted to cache these files so that I can access my tools offline as well.

Notes

Make sure your github pages have HTTPS enforced, you can check Settings > GitHub Pages > Enforce HTTPS of your repository.

@georapbox
georapbox / pre-commit.sh
Created April 14, 2021 20:02 — forked from dahjelle/pre-commit.sh
Pre-commit hook for eslint, linting *only* staged changes.
#!/bin/bash
for file in $(git diff --cached --name-only | grep -E '\.(js|jsx)$')
do
git show ":$file" | node_modules/.bin/eslint --stdin --stdin-filename "$file" # we only want to lint the staged changes, not any un-staged changes
if [ $? -ne 0 ]; then
echo "ESLint failed on staged file '$file'. Please check your code and try again. You can run ESLint manually via npm run eslint."
exit 1 # exit with failure status
fi
done