Skip to content

Instantly share code, notes, and snippets.

View joncasdam's full-sized avatar

Jonatas CD joncasdam

View GitHub Profile
@rponte
rponte / show-database-size.sql
Created February 19, 2020 12:27
PostgreSQL: showing the size of your databases
select db.datname as name
,pg_size_pretty(pg_database_size(db.datname)) as size
from pg_database db;
@anapaulagomes
anapaulagomes / conftest.py
Created February 27, 2019 10:55
pytest-grilo: your consciousness remembering you to take care of yourself
import random
def choose_action():
actions = [
"It's time to drink water!",
"Have you stretched on the last hour?",
"You should walk around a bit",
]
return random.choice(actions)
@klzns
klzns / picture-in-picture.js
Last active July 2, 2018 15:11
Adicione esse script para abrir a transmissão da copa em picture in picture no Safari.
(function () {
var video = document.querySelector('video:not([title="Advertisement"])')
if (!video.webkitSupportsPresentationMode || typeof video.webkitSetPresentationMode !== 'function') {
console.error('Esse código só funciona no Safari!')
return
}
var scoreX = document.querySelector('.placar__equipes')
var button = document.createElement('button')
@rochacbruno
rochacbruno / rochacbruno_open_source.md
Last active August 10, 2019 13:38
Contribute to Open Source Projects
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active March 26, 2024 10:34
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@perlguy99
perlguy99 / Alamofire.request.error.handling.swift
Last active January 16, 2023 19:52
Alamofire Request Error Handling - From their documentation
Alamofire.request(urlString).responseJSON { response in
guard case let .failure(error) = response.result else { return }
if let error = error as? AFError {
switch error {
case .invalidURL(let url):
print("Invalid URL: \(url) - \(error.localizedDescription)")
case .parameterEncodingFailed(let reason):
print("Parameter encoding failed: \(error.localizedDescription)")
print("Failure Reason: \(reason)")
@nrollr
nrollr / MySQL_macOS_Sierra.md
Last active January 31, 2024 14:45
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :

@jianwu
jianwu / static_server.js
Last active February 9, 2023 22:38 — forked from ryanflorence/static_server.js
Node.JS static file web server, also provides CORSProxy, Http/Https proxy function. Put it in your path to fire up servers in any directory, takes an optional port argument. If provide second https port argument, it will also start https. For https to work, need to put key and cert file in the folder.
#!/usr/bin/env node
const { argv } = require('process');
/**
Static http server implemented with NodeJS.
Features:
1. No external dependencies
@baxeico
baxeico / allow_cors_mixin.py
Last active August 6, 2020 13:40
Simple mixin to add CORS headers in a Django View
from django.http import HttpResponse
class AllowCORSMixin(object):
def add_access_control_headers(self, response):
response["Access-Control-Allow-Origin"] = "*"
response["Access-Control-Allow-Methods"] = "GET, OPTIONS"
response["Access-Control-Max-Age"] = "1000"
response["Access-Control-Allow-Headers"] = "X-Requested-With, Content-Type"
@benlinton
benlinton / multiple_mysql_versions_for_development.md
Last active September 23, 2023 09:38
Multiple MySQL Versions with Homebrew

Multiple MySQL Versions for Development

Options included below:

  • Using Docker docker-compose
  • Using Homebrew brew

Using Docker (recommended)

This gist was originally created for Homebrew before the rise of Docker, yet it may be best to avoid installing mysql via brew any longer. Instead consider adding a barebones docker-compose.yml for each project and run docker-compose up to start each project's mysql service.