Skip to content

Instantly share code, notes, and snippets.

View feload's full-sized avatar

Felipe feload

View GitHub Profile
@feload
feload / p.js
Last active October 30, 2017 16:19
Formats a string into a paragraph string.
export const p = (str = "") => {
if(!str || str.length < 1) return "";
str = str.replace('_', ' ');
return str.split(" ").map((word, index) => {
if(index == 0) {
const wordChunks = word.toLocaleLowerCase().split('');
wordChunks[0] = wordChunks[0].toUpperCase();
return wordChunks.join('');
}else{
return word.toLowerCase();
@feload
feload / headless.md
Created October 3, 2017 15:57 — forked from addyosmani/headless.md
So, you want to run Chrome headless.

Update May 2017

Eric Bidelman has documented some of the common workflows possible with headless Chrome over in https://developers.google.com/web/updates/2017/04/headless-chrome.

Update

If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md

Windows and Mac users might find using Justin Ribeiro's Docker setup useful here while full support for these platforms is being worked out.

@feload
feload / toTop.js
Created August 28, 2017 18:56
toTop.js Send certain objects to the top of the stack.
/**
* toTop()
* Send certain objects to top of the stack.
*/
const toTop = (col, what, where) => {
const ttop = [];
const tail = [];
col.forEach((i) => {
@feload
feload / round.js
Created August 22, 2017 19:37
Round JS function
function round(value, decimals) {
return Number(Math.round(value+'e'+decimals)+'e-'+decimals);
}
@feload
feload / money.regexp
Created June 2, 2017 21:15
Money regexp.
'([1-9]+[0-9]?)(,)([1-9]+[0-9])(,)([\d]+)(\.)([\d]+)'|'([1-9]+[0-9]?)(,)([\d]+)(\.)([\d]+)'|'([\d]+)(.)(\.)(.)([\d]+)'
@feload
feload / DataTableToList.cs
Created April 27, 2017 15:00
Convert DataTable to a generic list - extension method
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Web;
namespace helper
{
/// <summary>
@feload
feload / DooD.txt
Created April 22, 2017 05:37
DooD
docker run -it -v /var/run/docker.sock:/var/run/docker.sock ubuntu:latest sh -c "apt-get update ; apt-get install docker.io -y ; bash"
@feload
feload / node-npm-in-docker.sh
Created April 21, 2017 16:03 — forked from artemgordinskiy/node-npm-in-docker.sh
Run Node/NPM in a Docker container
# For example, run "npm install"
docker run -v "$PWD":/usr/src/app -w /usr/src/app node:4 npm install
# This command creates a container (downloading one first if you don't have it locally), runs the command in a current directory and quits the container
# Great Success!
@feload
feload / Git push deployment in 7 easy steps.md
Created April 21, 2017 15:56 — forked from thomasfr/Git push deployment in 7 easy steps.md
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
@feload
feload / bumpversion.sh
Created March 16, 2017 03:13 — forked from pete-otaqui/bumpversion.sh
Bump a software project's VERSION, add the CHANGES, and tag with GIT
#!/bin/bash
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3"
# this script will display the current version, automatically
# suggest a "minor" version update, and ask for input to use
# the suggestion, or a newly entered value.