Skip to content

Instantly share code, notes, and snippets.

View emersonbroga's full-sized avatar
:octocat:
Let's code!

Emerson Brôga emersonbroga

:octocat:
Let's code!
View GitHub Profile
@robskillington
robskillington / gist:e310ba0627293e2df91e
Created June 3, 2014 15:16
Swift synchronous request
class Request : NSObject {
func send(url: String, f: (String)-> ()) {
var request = NSURLRequest(URL: NSURL(string: url))
var response: NSURLResponse?
var error: NSErrorPointer = nil
var data = NSURLConnection.sendSynchronousRequest(request, returningResponse: &response, error: error)
var reply = NSString(data: data, encoding: NSUTF8StringEncoding)
f(reply)
}
@emersonbroga
emersonbroga / contato.html
Created August 31, 2012 19:25
Emerson Carvalho.com >> Formulário de contato em php + ajax (snippet 2)
<!DOCTYPE html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
@hengkiardo
hengkiardo / gist:4142221
Created November 25, 2012 03:01
QR Code for the Current URL with PHP and Google Charts
function saveImage($your_url, $width, $height, $file) {
$your_url = urlencode($your_url);
$url = 'http://chart.apis.google.com/chart?chs='.$width.'x'.$height.'&cht=qr&chl='.$your_url';
// initialize cURL settings
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
@eminetto
eminetto / install.sh
Created April 23, 2013 01:23
Script de instalação de pacotes do Vagrant - php5
apt-get update
apt-get install -y php5 php5-cli php5-xdebug php5-mysql phpunit php-apc php5-imagick php5-mcrypt php5-memcache php5-suhosin php-pear curl imagemagick php5-dev php5-curl php5-sqlite phpmyadmin mysql-server libapache2-mod-php5 apache2 memcached vim git-core subversion
#!/bin/bash
# Simple script to backup MySQL databases
# Parent backup directory
backup_parent_dir="/var/backups/mysql"
# MySQL settings
mysql_user="root"
mysql_password=""
@sydlawrence
sydlawrence / much better way for ajax urls
Created December 2, 2010 10:03
using history pushState
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title>window.history.pushState Example</title>
</head>
<body>
<h1>window.history.pushState Example</h1>
@robdehaven
robdehaven / flickr-list-photosets
Created August 27, 2011 14:41
Flickr List Photosets (coreylib)
<?php require_once('coreylib.php'); ?>
<?php if ($photos = coreylib('http://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=[ENTER-API-KEY]&user_id=[ENTER-USER-ID]&format=rest')) { ?>
<ul>
<?php foreach($photos->get('photosets/photoset') as $photoset) { ?>
<a href="http://www.flickr.com/photos/[ENTER-USERNAME]/sets/<?php echo $photoset['id'] ?>">
<img src="http://farm<?php echo $photoset['farm'] ?>.static.flickr.com/<?php echo $photoset['server'] ?>/<?php echo $photoset['primary'] ?>_<?php echo $photoset['secret'] ?>_s.jpg" /><br />
<?php echo $photoset->get('title') ?></a>
</a>
<?php } ?>
</ul>
@laracasts
laracasts / test.php
Last active July 10, 2018 16:33
Transactions for functional/integration tests.
<?php
class ExampleTest extends TestCase {
public function setUp()
{
parent::setUp();
DB::beginTransaction();
}
@lukeocodes
lukeocodes / QuickGit.php
Last active December 11, 2018 08:06
Current git version.
<?php
class QuickGit
{
/** @var int */
private $major = 1;
/** @var int */
private $minor = 0;
/*
what it does:
Wraps objects to respond to data path strings separated by '/'
ex: vpFoo['path/to/0/property'] <= same as => foo.path.to[0].property
usage:
const foo = {
bar: 12,
something: [
{ baz: 14 }
]