Skip to content

Instantly share code, notes, and snippets.

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

Leonan LeonanCarvalho

🏠
Working from home
View GitHub Profile
DROP TABLE IF EXISTS time_dimension;
CREATE TABLE time_dimension (
id INTEGER PRIMARY KEY, -- year*10000+month*100+day
db_date DATE NOT NULL,
year INTEGER NOT NULL,
month INTEGER NOT NULL, -- 1 to 12
day INTEGER NOT NULL, -- 1 to 31
quarter INTEGER NOT NULL, -- 1 to 4
week INTEGER NOT NULL, -- 1 to 52/53
day_name VARCHAR(9) NOT NULL, -- 'Monday', 'Tuesday'...
@LeonanCarvalho
LeonanCarvalho / animationFrame
Last active August 29, 2015 14:20
Ativar request animationFrame para todos os navegadores.
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|| window[vendors[x]+'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame)
window.requestAnimationFrame = function(callback, element) {
@LeonanCarvalho
LeonanCarvalho / getClientHostname.php
Last active August 29, 2015 14:27
Get client using ip address, works fine in intranet and DNS and reverse proxyes
$proxy = (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : false;
$hostname = "";
if (!!$proxy) {
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
$hostname .= "Proxy: ";
} else {
$ipaddress = $_SERVER['REMOTE_ADDR']; //
}
if ($ipaddress == $hostname) {
$hostname .= "Unknown";
@LeonanCarvalho
LeonanCarvalho / mysql_linux_backup.php
Last active December 11, 2015 13:07
PHP Script That provide a easy way to safe backup your databases
<?php
/* =========================================================
* Script to Generate MySQL dumps With PHP
* =========================================================
* Copyright 2015 Leonan Carvalho @leonancarvalho
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
<?php
/**
* Description of ResultSet:
* This class handler a paginated Cassandra\FutureRows
*
* @author Leonan Carvalho
*/
class ResultSet {
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.servlet.http.HttpServletRequest;
//...
This file has been truncated, but you can view the full file.
Downloading/unpacking argparse==1.4.0 (from -r default/src/ckan/requirements.txt (line 7))
Getting page https://pypi.python.org/simple/argparse/
URLs to search for versions for argparse==1.4.0 (from -r default/src/ckan/requirements.txt (line 7)):
* https://pypi.python.org/simple/argparse/1.4.0
* https://pypi.python.org/simple/argparse/
Getting page https://pypi.python.org/simple/argparse/1.4.0
Could not fetch URL https://pypi.python.org/simple/argparse/1.4.0: HTTP Error 404: Not Found
Will skip URL https://pypi.python.org/simple/argparse/1.4.0 when looking for download links for argparse==1.4.0 (from -r default/src/ckan/requirements.txt (line 7))
Analyzing links from page https://pypi.python.org/simple/argparse/
@LeonanCarvalho
LeonanCarvalho / ckan_lighttpd_vhost.conf
Last active February 8, 2017 20:24
Solr 5.5.3 CKAN core schemas
# CKAN lighttpd vhost
# server.modules += ( "mod_proxy" )
$HTTP["host"] == "ckan.example.com"{
proxy.server = ( "" =>
( "" =>
("host" => "127.0.0.1", "port" => 5000)
)
)
}
{
"id": "df72dc57-1eb9-42a3-88a9-8647ecc954b4",
"type": "GenericEntity",
"dateCreated": {
"value": "2017-02-10T19:20+10:03",
"type": "DateTime"
},
"dateModified": {
"value": "2017-02-15T22:02+01:51",
"type": "DateTime"
<?php
namespace Application\WebServices;
/**
*
* @author LeonanCarvalho <j.leonancarvalho@gmail.com>
*/
abstract class AbstractSoapClient {