Skip to content

Instantly share code, notes, and snippets.

View radum's full-sized avatar
🚀
I can see what you see not

Radu Micu radum

🚀
I can see what you see not
View GitHub Profile
@radum
radum / commands.zsh
Last active February 14, 2018 20:22
Useful CLI stuff
# Windows copy with permissions
# https://www.maketecheasier.com/12-things-you-must-do-when-running-a-solid-state-drive-in-windows-7/
Robocopy.exe H:\Internet M:\Internet /MIR /copyall /dcopy:T /W:30
# Change how many max files the system can use
# https://superuser.com/questions/827984/open-files-limit-does-not-work-as-before-in-osx-yosemite
# https://blogs.progarya.dk/blog/how-to-persist-ulimit-settings-in-osx/
sudo sysctl -w kern.maxfiles=65000
sysctl kern.maxfiles
<!doctype html>
<!--
The Annoying Site
https://theannoyingsite.com
Author:
Feross Aboukhadijeh
https://feross.org
@radum
radum / unistore.js
Created March 6, 2018 09:01
developit/unistore Example
import createStore from "unistore";
function mapActions(actions, store) {
if (typeof actions === "function") actions = actions(store);
let mapped = {};
for (let i in actions) {
mapped[i] = store.action(actions[i]);
}
return mapped;
}

Enter your desired gross annual salary

£80,000

Your day rate should be: £540 Hourly, that's: £67

See how we calculated this (it’s not £80,000/365). You can change all of these variables to whatever works for you.

@radum
radum / devtools-monitor.js
Created May 11, 2018 08:58
Devtools protocol monitor in JS
const ws = new WebSocket('http://localhost:9222/json');
ws.on('open', () => {
ws.send(JSON.stringify({
id: 1,
method: 'Runtime.evaluate',
params: {
expression: 'document.title'
}
}));
@radum
radum / error.js
Created September 6, 2018 09:41
Creating Custom Error Objects In Node.js With Error.captureStackTrace()
// Require our core node modules.
var util = require( "util" );
// Export the constructor function.
exports.AppError = AppError;
// Export the factory function for the custom error object. The factory function lets
// the calling context create new AppError instances without calling the [new] keyword.
exports.createAppError = createAppError;
@radum
radum / http2.js
Created September 22, 2018 14:43 — forked from davidgilbertson/http2.js
HTTP2 server with compression and caching
const http2 = require('http2');
const fs = require('fs');
const path = require('path');
const zlib = require('zlib');
const brotli = require('brotli'); // npm package
const PORT = 3032;
const BROTLI_QUALITY = 11; // slow, but we're caching so who cares
const STATIC_DIRECTORY = path.resolve(__dirname, '../dist/');
const cache = {};
@radum
radum / localStorage-proxy.js
Created September 24, 2018 14:32
localStorage Proxy
Object.defineProperty(window, 'localStorage', {
configurable: true,
enumerable: true,
value: new Proxy(localStorage, {
set: function (ls, prop, value) {
console.log(`direct assignment: ${prop} = ${value}`);
debugger;
ls[prop] = value;
return true;
},
@radum
radum / z-index.scss
Created September 27, 2018 14:28
z-index management
// From my boilerplate here: https://github.com/radum/webapp-boilerplate/blob/develop/src/styles/tools/_tools.z-index.scss
/**
* Check if map has nested keys
* @param {string} $map Key to find
* @param {object} $keys... Object of keys to look into
* @return {boolean} Return true or false if map has nested keys
*/
@function map-has-nested-keys($map, $keys...) {
@each $key in $keys {
@radum
radum / getOverlap.js
Created October 18, 2018 19:08 — forked from pankajpatel/getOverlap.js
Function to get the overlap between two elements
/**
* isOverlapping() returns the overlapping status between two elements
* based on the passed in Element objects
*
* @param {Element, Element} Element object of DOM
* @return {Boolean|null} overlap status or null if native objet not received
*/
function isOverlapping(e1, e2){
if( e1.length && e1.length > 1 ){
e1 = e1[0];