Skip to content

Instantly share code, notes, and snippets.

View davidalves1's full-sized avatar

David Alves de Souza davidalves1

View GitHub Profile
@wupsbr
wupsbr / gist:7086748
Created October 21, 2013 16:29
Exemplo de como fazer uma chamada AJAX (XMLHttpRequest) no Firefox OS em um domínio diferente da aplicação, evitando o erro de Cross-Origin. Aplicação completa em https://github.com/robnyman/Firefox-OS-Boilerplate-App
var xhr = new XMLHttpRequest({mozSystem: true});
xhr.open("GET", "http://robnyman.github.com/Firefox-OS-Boilerplate-App/README.md", true);
xhr.onreadystatechange = function ()
{
if (xhr.status === 200 && xhr.readyState === 4)
{
crossDomainXHRDisplay.innerHTML = "<h4>Result from Cross-domain XHR</h4>" + xhr.response;
crossDomainXHRDisplay.style.display = "block";
}
}
@rrosiek
rrosiek / install_mysql.sh
Last active October 1, 2024 03:05
Vagrant provision script for php, Apache, MySQL, phpMyAdmin, Laravel, and javascript helpers. Tested with Ubuntu 16.04.
#! /usr/bin/env bash
###
#
# install_mysql.sh
#
# This script assumes your Vagrantfile has been configured to map the root of
# your application to /vagrant and that your web root is the "public" folder
# (Laravel standard). Standard and error output is sent to
# /vagrant/vm_build.log during provisioning.
@petemcw
petemcw / 01-README.md
Last active February 2, 2024 11:50
Mac OS X LEMP Configuration

Mac OS X LEMP Configuration

This Gist is a collection of configuration files that can be used to easily setup a Homebrew-based LEMP stack on Mac OS X.

Files in this repository are numbered and named for ordering purposes only. At the top of each file is a section of metadata that denote what component the file belongs to and the default name & location of the file. Feel free to implement it however you want.

Note: some configuration files have hard-coded paths to my user directory -- fix it for your setup

Setup

@rdeavila
rdeavila / git-update-fork.sh
Last active November 5, 2024 09:31
Git: como atualizar um fork com as mudanças do original?
#!/bin/bash
# Adicione um novo remote; pode chamá-lo de "upstream":
git remote add upstream https://github.com/usuario/projeto.git
# Obtenha todos os branches deste novo remote,
# como o upstream/master por exemplo:
git fetch upstream
@pawitp
pawitp / server.php
Created April 6, 2014 06:21
Example for array/struct with nuSOAP
<?php
date_default_timezone_set('Asia/Bangkok');
require_once "lib/nusoap.php";
// Create SOAP Server
$server = new soap_server();
$server->configureWSDL("Test_Service", "http://www.example.com/test_service");
// Example "hello" function
function hello($username) {
@kohnmd
kohnmd / flatten.php
Last active September 20, 2021 12:48
Function to recursively flatten multidimensional PHP array.
<?php
// Requires PHP 5.3+
// Found here: http://stackoverflow.com/a/1320156
function flatten_array(array $array) {
$flattened_array = array();
array_walk_recursive($array, function($a) use (&$flattened_array) { $flattened_array[] = $a; });
return $flattened_array;
}
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@poeticninja
poeticninja / index.html
Created October 28, 2014 14:32
base64 to file blob, very basic example.
<!doctype html>
<html>
<head>
<title>File Upload Page</title>
</head>
<body>
<h1 onClick="sendFormData()">Send it!</h1>
<script type="text/javascript">
@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active July 26, 2024 20:17
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@danharper
danharper / CatchAllOptionsRequestsProvider.php
Last active August 3, 2024 16:44
Lumen with CORS and OPTIONS requests
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
/**
* If the incoming request is an OPTIONS request
* we will register a handler for the requested route
*/
class CatchAllOptionsRequestsProvider extends ServiceProvider {