Skip to content

Instantly share code, notes, and snippets.

View VitorLuizC's full-sized avatar

Vitor L Cavalcanti VitorLuizC

View GitHub Profile
@mrosata
mrosata / fp-either-monad.js
Last active October 28, 2024 15:09
Functional JavaScript Monad Classes - (Maybe Just Nothing) - (Either Left Right) (IOMonad) and my type checking utils
import is from './is-util';
/**
* Either Monad class (from Functional Programming in JavaScript)
*/
class Either {
constructor(value) {
this._value = value;
}
get value () {
@lgarron
lgarron / copyToClipboard.html
Last active December 20, 2023 12:53
Simple `navigator.clipboard.writeText()` polyfill.
<script>
// A minimal polyfill for copying text to clipboard that works most of the time in most capable browsers.
// Note that:
// - You may not need this. `navigator.clipboard.writeText()` works directly in all modern browsers as of 2020.
// - In Edge, this may call `resolve()` even if copying failed.
// - In Safari, this may fail if there is nothing selected on the page.
// See https://github.com/lgarron/clipboard-polyfill for a more robust solution.
//
// License for this Gist: public domain / Unlicense
function writeText(str) {
@kimamula
kimamula / Optional.ts
Last active December 3, 2020 20:12
Implementation of Optional (Maybe) in TypeScript
class Some<A> implements Optional<A> {
constructor(private a: A) {
}
getOrElse(a: A) {
return this.a;
}
map<B>(func: (a: A) => B) {
return Optional(func(this.a));
}
match<B>(cases: {
@domenic
domenic / escape-vm.js
Created August 17, 2015 20:20
Escaping the vm sandbox
"use strict";
const vm = require("vm");
const sandbox = { anObject: {} };
const whatIsThis = vm.runInNewContext(`
const ForeignObject = anObject.constructor;
const ForeignFunction = ForeignObject.constructor;
const process = ForeignFunction("return process")();
const require = process.mainModule.require;
require("fs");
@PurpleBooth
PurpleBooth / README-Template.md
Last active July 21, 2025 15:21
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

@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
var apply = Function.prototype.apply;
var flatten = apply.bind([].concat, []);
Array.of = function (a) {
return [a];
};
Array.prototype.chain = function (f) {
return flatten(this.map(f));
};
@joncotton
joncotton / clippify.bookmarklet.js
Created May 29, 2012 21:46
Add Microsoft Clippy to any webpage
/**
* A bookmarklet to Clippify any webpage.
*
* All possible by: http://www.smore.com/clippy-js
*/
javascript:(function(){function c(a,b){console.log("dynamically loading-",a);if(a.readyState){a.onreadystatechange=function(){if(a.readyState=="loaded"||a.readyState=="complete"){a.onreadystatechange=null;if(b){b()}}}}else{a.onload=function(){if(b){b()}}}}function d(){console.log("launching clippy");clippy.load("Clippy",function(a){$(".clippy").css("position","fixed");$(".clippy").css("z-index",1e3);a.show();a.moveTo(100,100)})}function e(){b=document.createElement("script");b.src="https://raw.github.com/smore-inc/clippy.js/master/build/clippy.js";document.body.appendChild(b);var a=document.createElement("link");a.rel="stylesheet";a.type="text/css";a.media="all";a.href="https://raw.github.com/smore-inc/clippy.js/master/build/clippy.css";document.getElementsByTagName("head")[0].appendChild(a)}var a;var b;if(typeof jQuery=="undefined"||jQuery.fn.jquery<"1.7"){a=document.createElement("script");var f=/^https:/
@jed
jed / LICENSE.txt
Created May 20, 2011 13:27 — forked from 140bytes/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE