The url has changed: https://odan.github.io/2017/01/07/basic-crud-operations-with-pdo.html
# Android SDK setup | |
## Install Java | |
```bash | |
sudo apt-get update | |
sudo dpkg --add-architecture i386 | |
sudo apt-get install libbz2-1.0:i386 | |
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 | |
sudo apt-get install openjdk-8-jdk openjdk-8-jre |
Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.
git revert {commit_id}
Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:
// Exemplo de requisição GET | |
var ajax = new XMLHttpRequest(); | |
// Seta tipo de requisição e URL com os parâmetros | |
ajax.open("GET", "minha-url-api.com/?name=Henry&lastname=Ford", true); | |
// Envia a requisição | |
ajax.send(); | |
// Cria um evento para receber o retorno. |
<?php | |
// A função abaixo demonstra o uso de uma expressão regular que identifica, de forma simples, telefones válidos no Brasil. | |
// Nenhum DDD iniciado por 0 é aceito, e nenhum número de telefone pode iniciar com 0 ou 1. | |
// Exemplos válidos: +55 (11) 98888-8888 / 9999-9999 / 21 98888-8888 / 5511988888888 | |
function phoneValidate($phone) | |
{ | |
$regex = '/^(?:(?:\+|00)?(55)\s?)?(?:\(?([1-9][0-9])\)?\s?)?(?:((?:9\d|[2-9])\d{3})\-?(\d{4}))$/'; | |
if (preg_match($regex, $phone) == false) { |
Note: This is an older post that I did back when I thought I might have time to be a blogger. Oh I was oh so wrong. However, it has proven useful for some folks on stackoverflow. Thus I'm keeping it alive here on Gist.
One of my past projects dealt heavily with an open source Apple technology called HTTP Live Streaming. It’s an HTTP based streaming protocol that at its most fundamental level provides a way to stream video and audio from just about any server with nothing but a few free software tools provided by Apple**. However, it has a few additional features that I think make it a really exciting tool. Yet, I haven’t seen HTTP Live Streaming used very much. This is probably mainly due to the combination of a lack of good/clear documentation, and Apple’s Live Streaming Developer Tools being command line based also make the barrier to entry higher than many developers want to deal with.
The hope is to share my understanding of how to use this technology to:
/* | |
In order to store the object we 'flatten' the object. This has strange results in the latest version of Safari (8) | |
*/ | |
navigator.geolocation.getCurrentPosition(function (geolocation) { | |
// in order to store the location in a cookie we 'flatten' the object to json | |
var cookieValue = JSON.stringify(geolocation); | |
}); |
<?php | |
// address to map | |
$map_address = ""; | |
$url = "http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=".urlencode($map_address); | |
$lat_long = get_object_vars(json_decode(file_get_contents($url))); | |
// pick out what we need (lat,lng) | |
$lat_long = $lat_long['results'][0]->geometry->location->lat . "," . $lat_long['results'][0]->geometry->location->lng; |
<?php | |
class Validate { | |
public $message = array(); | |
public $validate; | |
public function rules($data) { | |
foreach($data as $key => $value) { |
# | |
# geolocate points 50km around a defined latitude/longitude | |
# | |
$latitude = 42.45679; | |
$longitude = 8.345678; | |
$sql = "SELECT ID, 3956 * 2 * ASIN(SQRT(POWER(SIN((" . $latitude . " - LAT) * 0.0174532925 / 2), 2) + "; | |
$sql .= "COS(" . $latitude . " * 0.0174532925) * COS(LAT * 0.0174532925) * POWER(SIN((" . $longitude . " - LON) * 0.0174532925 / 2), 2) "; | |
$sql .= ")) as DISTANCE from houses having DISTANCE < 50 ORDER BY DISTANCE ASC "; |