Skip to content

Instantly share code, notes, and snippets.

@FerraBraiZ
FerraBraiZ / PHP POST Webhook
Last active June 28, 2023 16:52
POST Webhook
<?php
if ('POST' !== $_SERVER['REQUEST_METHOD']) {
http_response_code(405);
exit( json_encode([ 'Client Error 405' => 'Method not allowed!' ]) );
}
try {
@FerraBraiZ
FerraBraiZ / jQuery_ajax_promise_when_then.js
Last active April 27, 2021 12:32
jQuery $.ajax promise, $.when then()
let promisedData = function() {
let deferredQuery = $.Deferred();
$.ajax({
type: "GET",
crossDomain: true,
dataType: "json",
cache: false,
data: "data=data",
@FerraBraiZ
FerraBraiZ / sql
Last active April 27, 2018 13:10
MySQL - 5.6.5 2, 2 TIMESTAMP column / CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
Why there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause?
in MySQL 5.6.5 (2012-04-10, Milestone 8) is possible to have 2 fields, as follows:
CREATE TABLE `foo` (
`id` INT(10) UNSIGNED NOT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at ` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=INNODB;
@FerraBraiZ
FerraBraiZ / .htaccess
Last active July 1, 2019 02:18
HTACCESS
# Allow with + or - listing folder's content
Options +Indexes
##enable CORS and credentials
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Origin http://www.vknyvz.com
Header set Access-Control-Allow-Credentials true
</IfModule>
@FerraBraiZ
FerraBraiZ / php
Last active April 27, 2018 13:06
PHP CURL
<?php
$curl = curl_init();
$url = 'http://localhost:6969/ws/';
$opts = [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_CUSTOMREQUEST => "POST",
@FerraBraiZ
FerraBraiZ / js
Last active June 29, 2019 04:23
DropZone stub
try{
Dropzone.autoDiscover = false;
const fileTypesWhiteList = "jpeg|jpg|gif|png|bmp|pdf|doc|docx|txt|odt";
let dropZoneFileUploader = new Dropzone("#dz-custom-file-upload-form",{
autoDiscover: false,
autoProcessQueue:false,
uploadMultiple: true,
@FerraBraiZ
FerraBraiZ / eventemitter.js
Created November 20, 2018 18:19 — forked from mudge/eventemitter.js
A very simple EventEmitter in pure JavaScript (suitable for both node.js and browsers).
/* Polyfill indexOf. */
var indexOf;
if (typeof Array.prototype.indexOf === 'function') {
indexOf = function (haystack, needle) {
return haystack.indexOf(needle);
};
} else {
indexOf = function (haystack, needle) {
var i = 0, length = haystack.length, idx = -1, found = false;
@FerraBraiZ
FerraBraiZ / multi_clone_repos_organization.sh
Last active June 12, 2019 15:57
Shell script to clone every repo ( that u have access that is ;D ) of a github organization
#!/bin/bash
## extracted from https://askubuntu.com/questions/976145/shell-script-to-clone-every-repo-of-a-github-organization
## original author is in the post, all credits goes to him/her/it
for i in $(curl "https://api.github.com/orgs/[organization]/repos?access_token=[access_token]" | sed '/[ ]*"clone_url":/!d;s/[^:]*: "//;s/",$//'); do
echo git clone $i
done
@FerraBraiZ
FerraBraiZ / GIT-APPT-v2.sh
Created June 22, 2019 17:17
One bash script to fetch from origin and do a hard reset on several branches, this script is useful if u work on several projects at same time and need to sync your local master's with your remote origin, usually github
#!/bin/bash
# EN - GIT AAPT stands for update the whole danm thing
# PT-BR - GIT AAPT significa Atualiza a porra toda
#
REPOSITORIES="$( cd /home/${USER}/public_html/ && pwd )"
IFS=$'\n'
for REPO in `ls "$REPOSITORIES/"`
do