Skip to content

Instantly share code, notes, and snippets.


Newton Samin Urbanetz nsrau

View GitHub Profile
nievesj / caprover-develop.yml
Created Nov 18, 2020
CapRover Action example
View caprover-develop.yml
- develop
runs-on: ubuntu-latest
- name: Checkout
uses: actions/checkout@v2
souporserious / getTextWidth.js
Created Jan 21, 2019
Get the width for a single line of text
View getTextWidth.js
* Get the width for a single line of text
* @param {String} text - the string of text to be measured
* @param {Object|HTMLElement} font - optional font styles or node to pull font styles from
* @return {Number} the width of the text passed in
const expando = 'text-width' + new Date().getTime()
const canvas =
typeof document === 'undefined' ? null : document.createElement('canvas')
const context = canvas && canvas.getContext('2d')
cecilemuller /
Last active Oct 18, 2021
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

View Template IISNode Web.config
<?xml version="1.0" encoding="utf-8"?>
<!-- Virtual Directory Setup
assign virtualDirPath below a value like '/{path}'
Add below to your app code and then prepend routes with virtualDirPath
var virtualDirPath = process.env.virtualDirPath || ''; -->
austinhyde /
Last active Sep 23, 2021
Vanilla JavaScript Data Binding


You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5
myusuf3 /
Created Nov 3, 2014
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
pbojinov / jquery.deferred.promise.js
Last active Feb 28, 2021
simple jQuery Deferred example
View jquery.deferred.promise.js
function getData() {
var deferred = $.Deferred();
'url': '',
'success': function(data) {
'error': function(error) {
nathansmith / cache.js
Last active Sep 27, 2018
Example of self-clearing cache using window.localStorage
View cache.js
// Set up "namespace."
var APP = APP || {};
// `Shared settings.
APP.config = APP.config || {};
// How long to keep cache, in minutes.
APP.config.cache_duration = APP.config.cache_duration || 15;
thomasfr / Git push deployment in 7 easy
Last active Oct 1, 2021
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
View Git push deployment in 7 easy
GuillaumeJasmin / extract.js
Last active Oct 6, 2021
Extract substring between two strings
View extract.js
String.prototype.extract = function(prefix, suffix) {
s = this;
var i = s.indexOf(prefix);
if (i >= 0) {
s = s.substring(i + prefix.length);
else {
return '';
if (suffix) {