Skip to content

Instantly share code, notes, and snippets.

View marcosfreitas's full-sized avatar
🔥
Looking forward

Marcos Freitas marcosfreitas

🔥
Looking forward
View GitHub Profile
@gaearon
gaearon / modern_js.md
Last active April 18, 2024 15:01
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav

Cheat sheet: JavaScript Array methods

Deriving a new Array from an existing Array:

['■','●','▲'].slice(1, 3)           ['●','▲']
['■','●','■'].filter(x => x==='■')  ['■','■']
    ['▲','●'].map(x => x+x)         ['▲▲','●●']
    ['▲','●'].flatMap(x => [x,x])   ['▲','▲','●','●']
@mcaskill
mcaskill / Function.Array-Group-By.php
Last active January 3, 2024 10:15
PHP : Groups an array by a given key
<?php
if (!function_exists('array_group_by')) {
/**
* Groups an array by a given key.
*
* Groups an array into arrays by a given key, or set of keys, shared between all array members.
*
* Based on {@author Jake Zatecky}'s {@link https://github.com/jakezatecky/array_group_by array_group_by()} function.
* This variant allows $key to be closures.
@adilsoncarvalho
adilsoncarvalho / tapi_mac.js
Last active April 9, 2021 12:53
MercadoBitcoin - Calculando o TAPI-MAC em NodeJS
const TAPI_SECRET = '1ebda7d457ece1330dff1c9e04cd62c4e02d1835968ff89d2fb2339f06f73028';
const EXPECTED_TAPI_MAC = '7f59ea8749ba596d5c23fa242a531746b918e5e61c9f6c8663a699736db503980f3a507ff7e2ef1336f7888d684a06c9a460d18290e7b738a61d03e25ffdeb76';
const MESSAGE = '/tapi/v3/?tapi_method=list_orders&tapi_nonce=1';
const crypto = require('crypto');
const hmac = crypto.createHmac('sha512', TAPI_SECRET);
hmac.update(MESSAGE);
const TAPI_MAC = hmac.digest('hex');
@BBlackwo
BBlackwo / kraken.fish
Created March 1, 2017 08:05
Open GitKraken from the terminal
## Forked from https://gist.github.com/dersam/0ec781e8fe552521945671870344147b
## Also received help from https://twitter.com/gitkraken/status/691675309725368321
## Open GitKraken using the current repo directory.
## This code is for fish shell. The same thing can be done in bash
## by creating an alias with the command below.
## `1>/dev/null` directs logs from the terminal
## `&` allows use of the same terminal instance to do other things
@guimadaleno
guimadaleno / brazilStates.html
Last active June 8, 2019 15:22
Select com os estados do Brasil - Select with Brazilian states
<select>
<option value="">Selecione</option>
<option value="AC">Acre</option>
<option value="AL">Alagoas</option>
<option value="AP">Amapá</option>
<option value="AM">Amazonas</option>
<option value="BA">Bahia</option>
<option value="CE">Ceará</option>
<option value="DF">Distrito Federal</option>
<option value="ES">Espirito Santo</option>
@zenorocha
zenorocha / mussum-ipsum.sublime-snippet
Created October 2, 2012 18:48
Mussum Ipsum - Snippet para Sublime Text
<!-- Fonte: mussumipsum.com -->
<snippet>
<content><![CDATA[
Mussum ipsum cacilds, vidis litro abertis. Consetis adipiscings elitis. Pra lá , depois divoltis porris, paradis. Paisis, filhis, espiritis santis. Mé faiz elementum girarzis, nisi eros vermeio, in elementis mé pra quem é amistosis quis leo. Manduma pindureta quium dia nois paga. Sapien in monti palavris qui num significa nadis i pareci latim. Interessantiss quisso pudia ce receita de bolis, mais bolis eu num gostis.
Suco de cevadiss, é um leite divinis, qui tem lupuliz, matis, aguis e fermentis. Interagi no mé, cursus quis, vehicula ac nisi. Aenean vel dui dui. Nullam leo erat, aliquet quis tempus a, posuere ut mi. Ut scelerisque neque et turpis posuere pulvinar pellentesque nibh ullamcorper. Pharetra in mattis molestie, volutpat elementum justo. Aenean ut ante turpis. Pellentesque laoreet mé vel lectus scelerisque interdum cursus velit auctor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam ac mauris lectus, non scelerisque augu
@dwiash
dwiash / modify-woocommerce-breadcrumb.md
Created November 13, 2012 09:26
How to modify breadcrumb appearance in WooCommerce

How to modify breadcrumb appearance in WooCommerce

There are two files you need look around if you want to change your breadcrumb's appearance in WooCommerce. You'll find those files in your WooCommerce plugin directory:

  1. The first file: /woocommerce/woocommerce-template.php, this file contains function definition for woocommerce_breadcrumb()
  if ( ! function_exists( 'woocommerce_breadcrumb' ) ) {

	/**
 * Output the WooCommerce Breadcrumb
@isGabe
isGabe / wordpress-force-login.php
Created June 21, 2013 16:10
WordPress: force log in to view any page, with redirect to requested URL#snippet #WordPress
<?php
/*
* Password protect a WordPress site, with a redirect to the requested URL after successful login
*
* Based on:
* http://wordpress.stackexchange.com/a/64999
* http://kovshenin.com/2012/current-url-in-wordpress/
*
**/