Skip to content

Instantly share code, notes, and snippets.

View carloscarucce's full-sized avatar
:octocat:

Carlos Alberto Bertholdo Carucce carloscarucce

:octocat:
View GitHub Profile
@carloscarucce
carloscarucce / Foca no código
Last active September 4, 2015 13:26 — forked from zenorocha/Foca no código
Foca no código
/* Véi, foca no código
.---.
/o o\
__(= " =)__
//\'-=-'/\\
) (_
/ `"=-._
/ \ ``"=.
@carloscarucce
carloscarucce / WebserverRequest.java
Last active November 18, 2015 18:47
Android - webserver request with JSON response
package com.xxnoobmanxx.util;
import android.util.Pair;
import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
@carloscarucce
carloscarucce / pdo-example.php
Created December 2, 2015 10:56
This makes pdo object returns a custom class object statement
$pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('MyProject\PDOStatement', array()));
<?php
/**
* This gist was based on a comment by yura_imbp at php.net
* http://php.net/manual/pt_BR/function.readfile.php#83653
*/
$local_file = 'file.zip';
$download_file = 'name.zip';
// set the download rate limit (=> 20,5 kb/s)
@carloscarucce
carloscarucce / GPS.java
Created April 13, 2016 18:55
Obtem a localização do gps
package com.xxnoobmanxx.util;
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.Bundle;
@carloscarucce
carloscarucce / pagination.blade.php
Last active January 27, 2023 03:10
Pagination template for laravel 5
@if (isset($paginator) && $paginator->lastPage() > 1)
<ul class="pagination">
<?php
$interval = isset($interval) ? abs(intval($interval)) : 3 ;
$from = $paginator->currentPage() - $interval;
if($from < 1){
$from = 1;
}
class ExampleAdapter extends PagerAdapter {
private List<String> strings;
private Context context;
public ExampleAdapter(Context context){
this.context = context;
strings = new ArrayList<String>();
@carloscarucce
carloscarucce / haversine_geo_distance.sql
Last active September 6, 2016 14:53
Retus the distance based in two geo points (latitude/longitude)
DELIMITER $$
CREATE FUNCTION haversine_geo_distance (lat1 REAL, lon1 REAL, lat2 REAL, lon2 REAL)
RETURNS REAL
BEGIN
DECLARE RR LONG;
DECLARE o1 REAL;
DECLARE o2 REAL;
DECLARE Ao REAL;
DECLARE AA REAL;
@carloscarucce
carloscarucce / export_to_xls.php
Last active October 31, 2016 14:11
Exports associative array to xls file
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");;
header("Content-Transfer-Encoding: binary ");
header("Content-Disposition: attachment; filename=\"file.xls\"");
header("Pragma: no-cache");
header("Expires: 0");
$out = fopen("php://output", 'w');
@carloscarucce
carloscarucce / custom-checkbox.css
Created March 13, 2017 13:52
Custom checkbox (css + js)
[type="checkbox"].custom-checkbox {
display: none;
}
[type="checkbox"].custom-checkbox + label.custom-checkbox-placeholder {
display: inline-block;
width: 15px;
height: 15px;
margin: 0 5px;
border: 1px solid #444444;