Skip to content

Instantly share code, notes, and snippets.

View carlosrberto's full-sized avatar
:octocat:

Carlos Roberto Gomes Junior carlosrberto

:octocat:
View GitHub Profile
let binarySearch = function (array, valueSearch) {
let start = 0;
let end = array.length - 1;
return function search(start, end) {
let mid = Math.round((start + end) / 2);
let length = end - start;
if (length < 0) return -1;
@carlosrberto
carlosrberto / read-and-learn.md
Last active November 12, 2018 17:58
Things to read and learn (JavaScript, React, Redux, React Native, Funcional Programming)
@fgilio
fgilio / axios-catch-error.js
Last active August 15, 2024 01:45
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@gvergnaud
gvergnaud / lazy-list.js
Last active September 13, 2024 23:03
Lazy List, implemented with es6 generators
/* ----------------------------------------- *
Lazy List Implementation
* ----------------------------------------- */
// Haskell-like infinite List, implemented with es6 generators
// Lazyness lets you do crazy stuff like
List.range(0, Infinity)
.drop(1000)
.map(n => -n)
@alexhawkins
alexhawkins / nativeJavaScript.js
Last active November 1, 2024 12:00
Implementation of Native JavaScript Methods (forEach, Map, Filter, Reduce, Every, Some)
'use strict';
/*****************NATIVE forEACH*********************/
Array.prototype.myEach = function(callback) {
for (var i = 0; i < this.length; i++)
callback(this[i], i, this);
};
//tests
@carlosrberto
carlosrberto / README.md
Last active August 15, 2016 19:40
jQuery onlynumber

jQuery onlynumber

$('input').onlynumber();
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@hlung
hlung / How to connect PS3 controller to a Mac or PC.md
Last active July 22, 2024 21:41
How to connect PS3 controller to a Mac or PC

How to connect PS3 controller to a Mac or PC

This is how you connect PS3 controller to Mac OSX, PC, etc. when previously connected to a PS3. You will need a Mini USB cable. Overcome your laziness, get up of your chair, and go get one!

A big misconception is that keep holding PS button will reset the controller's pairing. It DOES NOT! From my testings, the controller keeps paring with the last machine it was CONNECTED VIA A USB CABLE.

Here are the steps:

@carlosrberto
carlosrberto / commithook.md
Last active December 22, 2015 06:09
Tire uma foto sua a cada commit

##Tirando uma foto na hora do commit com Mercurial!

Instale o imagesnap

brew install imagesnap

No arquivo ~/.hgrc