Skip to content

Instantly share code, notes, and snippets.

View nncl's full-sized avatar

Cauê Almeida nncl

View GitHub Profile
@fgilio
fgilio / axios-catch-error.js
Last active April 11, 2024 19:02
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 😨
@antoniocsoares
antoniocsoares / findDuplicateItemsArrays.js
Last active July 28, 2022 02:28
Find duplicate items in arrays using ES6
// ES6
// Count duplicate items
const names = ['Mike', 'Matt', 'Nancy', 'Adam', 'Jenny', 'Nancy', 'Carl']
const count = names =>
names.reduce((a, b) =>
Object.assign(a, {[b]: (a[b] || 0) + 1}), {})
const duplicates = dict =>
@KostyaEsmukov
KostyaEsmukov / _ express-redirect-platform-location.md
Last active October 20, 2023 20:55
HTTP redirects with Angular SSR

HTTP redirects with Angular Server Side Rendering

This service assumes that you followed the SSR receipt at ng-cli (i.e. you use the '@nguniversal/express-engine' package).

How to add an image to a gist

  1. Create a gist if you haven't already.
  2. Clone your gist:
    # make sure to replace `<hash>` with your gist's hash
    git clone https://gist.github.com/<hash>.git # with https
    git clone git@gist.github.com:<hash>.git     # or with ssh
@dtomasi
dtomasi / getWeek.js
Created August 15, 2016 13:42
Get Week of Year in Javascript
Date.prototype.getWeek = function() {
var jan4th = new Date(this.getFullYear(),0,4);
return Math.ceil((((this - jan4th) / 86400000) + jan4th.getDay()+1)/7);
}
var now = new Date();
var weekNumber = now.getWeek();
console.log(weekNumber);
@maciekish
maciekish / resetXcode.sh
Created August 10, 2016 10:13
Reset Xcode. Clean, clear module cache, Derived Data and Xcode Caches. You can thank me later.
#!/bin/bash
killall Xcode
xcrun -k
xcodebuild -alltargets clean
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
open /Applications/Xcode.app
@connected
connected / bxslider-drag.js
Last active October 12, 2022 23:37
bxSlider mouse drag extension
/**
* Include this code right after bxSlider.
* Use "mouseDrag" options upon bxSlider initialization to enable mouse drag:
* $('#slider').bxSlider({
* mouseDrag: true
* });
*/
(function ($) {
var bxSlider = jQuery.fn.bxSlider;

Favicon

Como gerar?: http://www.favicon-generator.org/

Link sobre: http://tableless.com.br/favicons/

<!--Tamanhos para desktop e Android-->
<link rel="shortcut icon" href="/favicon.ico">
<link rel="icon" sizes="192x192"  href="/favicon-192x192.png">
<link rel="icon" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" sizes="96x96" href="/favicon-96x96.png">
@richardtorres314
richardtorres314 / flexbox.scss
Last active May 4, 2024 06:31
CSS Flexbox - Sass Mixins
// --------------------------------------------------
// Flexbox SASS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Flexbox display
@mixin flexbox {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
@ayamflow
ayamflow / gist:b602ab436ac9f05660d9c15190f4fd7b
Created May 9, 2016 19:10
Safari border-radius + overflow: hidden + CSS transform fix
// Add on element with overflow
-webkit-mask-image: -webkit-radial-gradient(white, black);