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
expect.extend({
toContainObject(received, argument) {
const pass = this.equals(received,
expect.arrayContaining([
expect.objectContaining(argument)
])
)
if (pass) {
@joyrexus
joyrexus / README.md
Last active December 30, 2024 01:37
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@aurbano
aurbano / Gemfile
Last active November 8, 2023 01:39
Post code coverage as a comment to a Github PR from Circle CI
source "https://rubygems.org"
gem "octokit"
gem "nokogiri"
gem "json"
@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@joshnuss
joshnuss / app.js
Last active February 18, 2025 15:49
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./authorization"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
@strann
strann / SassMeister-input.scss
Created March 31, 2014 19:45
An example of bad coding practice - deeply nested Sass leading to over-qualified CSS.
// ----
// Sass (v3.3.4)
// Compass (v1.0.0.alpha.18)
// ----
// This code sucks.
.module-container {
background-color: red;
@Chocksy
Chocksy / nr_format.coffee
Created October 28, 2013 18:31
This is a simple angularjs filter that makes big numbers into short format. 1 milion becomes 1m and 1122 becomes 1.1k
@app = angular.module 'myApp', []
@app.filter "nrFormat", ->
(number) ->
if number!=undefined
console.log number
abs = Math.abs(number)
if abs >= Math.pow(10, 12)
# trillion
number = (number / Math.pow(10, 12)).toFixed(1)+"t"
else if abs < Math.pow(10, 12) and abs >= Math.pow(10, 9)
@codeguy
codeguy / slugify.js
Created September 24, 2013 13:19
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 = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@cyranix
cyranix / template.user.js
Last active February 7, 2024 02:32
Example for easy dependency loading in user-scripts, compatible with Firefox (Greasemonkey) and Chrome (native; haven't tried Tampermonkey). Because Chrome doesn't allow `@require`, this technique is useful if you're too lazy to sync up a homebrew Chrome extension with an equivalent Greasemonkey script.
// ==UserScript==
// @name <name>
// @match <URL patterns for activation>
// @description <description>
// ==/UserScript==
/**
* Outermost IIFE for bootstrapper.
* @param main Function encapsulating the real work of the script [required]
* @param dep_urls Array of URLs to dependencies [default: empty array]
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active May 22, 2025 08:10
A badass list of frontend development resources I collected over time.