Skip to content

Instantly share code, notes, and snippets.

View andregoncalves's full-sized avatar
🏠
Working from home

Andre Goncalves andregoncalves

🏠
Working from home
View GitHub Profile
@andregoncalves
andregoncalves / css.json
Last active November 24, 2016 17:19
vscode css user snippets
{
"boot": {
"prefix": "css",
"body": [
"/**",
" *",
" * Copyright 2016 Andre Goncalves. All rights reserved.",
" *",
"*/",
"",
@andregoncalves
andregoncalves / html.json
Last active December 29, 2016 16:13
vscode html user snippets
{
"html boilerplate": {
"prefix": "html",
"body": [
"<doctype html>",
"<head>",
"\t<meta charset=\"utf-8\">",
"\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">",
"\t<meta name=\"author\" content=\"Andre Goncalves\" />",
"\t<meta name=\"viewport\" content=\"width=device-width,minimum-scale=1\">",
@andregoncalves
andregoncalves / php.json
Last active September 13, 2016 08:23
vscode php user snippets
{
"comment block": {
"prefix": "comment",
"body": [
"/* ",
" * --------------------------------------------------------------------",
" * ${title}",
" * --------------------------------------------------------------------",
" * ${description}",
" *",
@andregoncalves
andregoncalves / settings.json
Created August 22, 2016 12:28
vscode settings.json
// Place your settings in this file to overwrite the default settings
{
"editor.insertSpaces": false,
"editor.fontFamily": "Menlo, Monaco, Menlo, 'Courier New', monospace",
"editor.fontSize": 14,
"workbench.editor.enablePreviewFromQuickOpen": false,
"editor.fontSize": 12,
"editor.rulers": [120],
}
@andregoncalves
andregoncalves / keybindings.json
Created August 22, 2016 12:29
vscode keybindings
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+t",
"command": "workbench.action.quickOpen"
},
{
"key": "cmd+p",
"command": "workbench.action.showAllSymbols"
},
@andregoncalves
andregoncalves / create_user.sql
Last active August 30, 2016 16:45
Create mysql user for app access
create user <user>@localhost;
set password for <user>@localhost = PASSWORD("xxx");
grant all privileges on wordpress_<app>.* to <user>@localhost identified by "xxx";
flush privileges;
@andregoncalves
andregoncalves / slack.php
Created December 19, 2016 17:12
Send a slack webhook notification in php
<?php
// (string) $message - message to be passed to Slack
// (string) $room - room in which to write the message, too
// (string) $icon - You can set up custom emoji icons to use with each message
public static function slack($message, $room = "engineering", $icon = ":longbox:") {
$room = ($room) ? $room : "engineering";
$data = "payload=" . json_encode(array(
"channel" => "#{$room}",
"text" => $message,
@andregoncalves
andregoncalves / jquery-es6-compat.js
Last active November 18, 2017 12:04
jQuery like syntax with ES6 #es6
/**
* --------------------------------------------------------------------
* jQuery compatibility layer
* --------------------------------------------------------------------
*/
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
};
NodeList.prototype.on = NodeList.prototype.addEventListener = function (name, fn) {
@andregoncalves
andregoncalves / request.js
Created July 10, 2017 07:09
HTTP Request Retry with exponential backoff with Async
function wait (timeout) {
return new Promise((resolve) => {
setTimeout(() => {
resolve()
}, timeout)
})
}
async function requestWithRetry (url) {
const MAX_RETRIES = 10
@andregoncalves
andregoncalves / recaptcha.php
Last active November 18, 2017 11:59
Verify google recaptcha with PHP
# Verify captcha
$post_data = http_build_query(
array(
'secret' => CAPTCHA_SECRET,
'response' => $_POST['g-recaptcha-response'],
'remoteip' => $_SERVER['REMOTE_ADDR']
)
);
$opts = array('http' =>
array(