Skip to content

Instantly share code, notes, and snippets.

View matheusgontijo's full-sized avatar

Matheus Gontijo matheusgontijo

View GitHub Profile
@carcinocron
carcinocron / debugger pause beforeunload
Last active July 22, 2025 08:53
Chrome: pause before redirect
// Run this in the F12 javascript console in chrome
// if a redirect happens, the page will pause
// this helps because chrome's network tab's
// "preserve log" seems to technically preserve the log
// but you can't actually LOOK at it...
// also the "replay xhr" feature does not work after reload
// even if you "preserve log".
window.addEventListener("beforeunload", function() { debugger; }, false)
@kinncj
kinncj / Dilmas.php
Last active June 6, 2017 13:54
Dilmas Currency
<?php
class Dilmas extends \SplFloat
{
public function __construct($value)
{
$currency = json_decode(file_get_contents('http://api.fixer.io/latest?base=USD&symbols=BRL'), true);
$brl =(float) $currency['rates']['BRL'];
parent::__construct(((float) round($value / $brl, 2)));
@mmmries
mmmries / 00.Description.md
Last active August 18, 2019 12:26
3 Trvial Concurrency Examples in Elixir

These are my solutions to the three concurrency exercises from Katrina Owen's Go Post.

I'm posting here with example output in the hopes that someone call tell me how to do it better

@fbrnc
fbrnc / AjaxLoader.ino
Last active May 3, 2018 00:22
Hardware AJAX Loader using an Attiny85, 3 potentiometers and a 24 RGB LED ring
#include <FastLED.h>
#define NUM_LEDS 24
#define NUM_DOTS 3
#define DATA_PIN 0
#define MAX_SPEED 60
using namespace std;
CRGB leds[NUM_LEDS];
@antillean
antillean / letsencrypt-cli.ini
Last active July 9, 2025 21:51
Sample letsencrypt-cli.ini file
# Becomes /etc/letsencrypt/cli.ini.
# This is an example of the kind of things you can do in a configuration file.
# All flags used by the client can be configured here. Run Let's Encrypt with
# "--help" to learn more about the available options.
# Use a 4096 bit RSA key instead of 2048
rsa-key-size = 4096
# Uncomment and update to register with the specified e-mail address
alias Rebirth.Subscription
alias Ecto.Query
Subscription |> Query.where([s], not is_nil(s.user_id))
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active January 9, 2025 12:22
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@thagxt
thagxt / mage2-multiweb-subdir.md
Last active May 2, 2024 14:03
Set up Magento 2 multiple websites in sub directories

Set up Magento 2 multiple websites in sub directories

  1. Go to Admin > Stores > All Stores
  2. Click > Create Web Site
  3. In the Name field, enter store name.
    • e.g. Japan
  4. In the Code field, enter a unique string without spaces and > Save Web Site
    • e.g. super_jp
  5. Create Store
  6. Create Store View
@Nav-Appaiya
Nav-Appaiya / gist:892d759c1749fb9241ce169afe213f68
Created September 6, 2016 08:55
Magento 2 get all attributes from the default products attribute set (id: 4)
<?php
/** @var $coll \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection */
$coll = $this->_objectManager->create(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::class);
// add filter by entity type to get product attributes only
// '4' is the default type ID for 'catalog_product' entity - see 'eav_entity_type' table)
// or skip the next line to get all attributes for all types of entities
$coll->addFieldToFilter(\Magento\Eav\Model\Entity\Attribute\Set::KEY_ENTITY_TYPE_ID, 4);
$attrAll = $coll->load()->getItems();
@molotovbliss
molotovbliss / mysql-large-db-import
Created November 29, 2016 18:05
Importing Large DB faster MySQL Settings
Source: https://dba.stackexchange.com/questions/83125/mysql-any-way-to-import-a-huge-32-gb-sql-dump-faster
innodb_buffer_pool_size = 4G
innodb_log_buffer_size = 256M
innodb_log_file_size = 1G
innodb_write_io_threads = 16
innodb_flush_log_at_trx_commit = 0
Why these settings ?
innodb_buffer_pool_size will cache frequently read data