Skip to content

Instantly share code, notes, and snippets.

View jbbn's full-sized avatar
🌮
Typing as fast as I can

João Bueno jbbn

🌮
Typing as fast as I can
View GitHub Profile
@jbbn
jbbn / README.md
Last active July 15, 2024 20:44
Slugify the current git commit, appending the year and the current week number

Slugify commit script

Setup

curl -L https://gist.github.com/jbbn/b4ddec6775668b7fe0553c9a4f06d328/raw/install.sh | bash

Usage

@jbbn
jbbn / cloc--no-node_modules.sh
Last active April 13, 2022 21:42
Utilities for stats on codebases
cloc --exclude-dir=node_modules .
@jbbn
jbbn / git-status.sh
Created March 28, 2022 20:18
Bash: check the git status of all repositories of a [group] folder
find .. -name .git -type d -execdir sh -c 'echo "\033[92m $(pwd) \033[0m"; git fetch --all; git status; echo ""' \;
@jbbn
jbbn / pipe.php
Last active June 8, 2020 13:42
[draft] improvised php pipe function
<?php
function pipe ($fns) {
return function ($value) use ($fns) {
return array_reduce(
$fns
, function ($previousValue, $fn) {
return call_user_func($fn, $previousValue);
}
, $value
);
@jbbn
jbbn / EMPHASIS.md
Last active March 5, 2019 23:03
Linking Words in English

Emphasis

  • Undoubtedly
  • Indeed
  • Obviously
  • Particularly / In particular
  • Especially
  • Clearly
  • Importantly
  • Absolutely
@jbbn
jbbn / slugify.js
Last active June 18, 2023 00:45 — forked from codeguy/slugify.js
Create slug from string in #javascript
function string_to_slug (str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâãèéëêìíïîòóöôõùúüûñç·/_,:;";
var to = "aaaaaeeeeiiiiooooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@jbbn
jbbn / anagrams.alternate.js
Last active December 11, 2023 22:22
BairesDev Anagrams
const fs = require('fs')
const { log, splitByBreakline } = require('./utils')
const { getAnagramsFromWordsWith } = require('./utils.anagrams')
const logAnagramsFromFile = (filepath, target) => {
const getAnagramsForTargetFromWords = getAnagramsFromWordsWith(target)
// splitByBreakline | getAnagramsForTargetFromWords | log
const handleFileCallback = (err, words) => log(
getAnagramsForTargetFromWords(
@jbbn
jbbn / index.js
Last active February 6, 2018 15:42
One Source of Truth - Redux + Vue + React
import { createStore, combineReducers, bindActionCreators} from 'redux'
import Revue from 'revue'
import { Provider, connect } from 'react-redux'
import React from 'react'
import ReactDOM from 'react-dom'
const counter = (state = 0, action) => {
@jbbn
jbbn / inactivityTime_snippet.js
Last active January 2, 2017 12:39
SNIPPET - Inactivity time
// http://stackoverflow.com/questions/667555/detecting-idle-time-in-javascript-elegantly
var inactivityTime = function () {
var t;
window.onload = resetTimer;
// DOM Events
document.onmousemove = resetTimer;
document.onkeypress = resetTimer;
function logout() {
alert("You are now logged out.")
@jbbn
jbbn / tinydump.php
Last active August 29, 2015 14:24 — forked from ceckoslab/tinydump
<?php
define('DS', DIRECTORY_SEPARATOR);
function _getExtractSchemaStatement($sqlFileName, $db)
{
$dumpSchema = 'mysqldump' . ' ';
$dumpSchema .= '--no-data' . ' ';
$dumpSchema .= '-u ' . $db['user'] . ' ';
$db['pass'] = (string) $db['pass'];