Skip to content

Instantly share code, notes, and snippets.

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

Henri Cavalcante henricavalcante

🏠
Working from home
View GitHub Profile
@henricavalcante
henricavalcante / redirect.js
Created September 28, 2012 15:02
JS-script de redirecionamento com google analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxx-x']);
_gaq.push(['_trackPageview']);
_gaq.push(function(){window.location = "http://www.newlocation.com";});
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
@henricavalcante
henricavalcante / gist:3892299
Created October 15, 2012 12:51
spritely correction
spStop: function(bool) {
$(this).each(function() {
var el_id = $(this).attr('id');
//modificação para evitar erros de stop
if($._spritely.instances[el_id] && $._spritely.instances[el_id]['options'])
{
if ($._spritely.instances[el_id]['options']['fps']) {
$._spritely.instances[el_id]['_last_fps'] = $._spritely.instances[el_id]['options']['fps'];
}
$._spritely.instances[el_id]['_stopped'] = true;
@henricavalcante
henricavalcante / gist:3947712
Created October 24, 2012 17:58
SQL SERVER - Used disk space - Espaço usado por tabela em disco
SELECT object_name(id) AS name,
indid,
rowcnt AS rows,
reserved * 8 AS reserved_kb,
dpages * 8 AS data_kb,
(sum(used) * 8) - (dpages * 8) AS index_size_kb,
(sum(reserved) * 8) - (sum(used) * 8) AS unused_kb
FROM sysindexes
WHERE indid IN (0,1) -- cluster e não cluster
AND OBJECTPROPERTY(id, 'IsUserTable') = 1
@henricavalcante
henricavalcante / gist:3947850
Created October 24, 2012 18:21
SQL SERVER - Log manager - Gerenciamento de log
--DBCC SQLPERF (LOGSPACE)
USE database_name;
GO
ALTER DATABASE database_name SET RECOVERY SIMPLE;
GO
DBCC SHRINKFILE (database_log, 1);
GO
ALTER DATABASE database_name SET RECOVERY FULL;
GO
USE [master]
@henricavalcante
henricavalcante / gist:6866565
Created October 7, 2013 11:51
Listar Queryes mais pesadas. MSSQL
SELECT TOP 10 SUBSTRING(qt.TEXT, (qs.statement_start_offset/2)+1,
((CASE qs.statement_end_offset
WHEN -1 THEN DATALENGTH(qt.TEXT)
ELSE qs.statement_end_offset
END - qs.statement_start_offset)/2)+1),
qs.execution_count,
qs.total_logical_reads as total_leitura_memoria, qs.last_logical_reads as ultima_leitura_memoria,
qs.total_logical_writes as total_escrita_memoria, qs.last_logical_writes as ultima_escrita_memoria,
qs.total_physical_reads as total_leitura_disco, qs.last_physical_reads as ultima_leitura_disco,
qs.total_worker_time as tempo_CPU_total, qs.last_worker_time as ultimo_tempo_CPU,
@henricavalcante
henricavalcante / danubia.sql
Last active December 25, 2015 18:49
GERALEARNING
select c.nome as curso, g.nome, g.cidd,
g.tel, g.email, gat.localCNPJ, gat.localRazaoSoc, gat.localConv
from tbglobal g
inner join tbGlobATNTicket gat on g.id_glob = gat.id_glob
inner join tbglobcur gc on g.id_glob = gc.id_glob
inner join TBSEQCUR sc on gc.id_seqcur = sc.ID_SEQCUR
inner join TBCURSOS c on sc.id_cur = c.id_cur
where sc.id_fase = 108 and
g.datcad between '2014-07-01 00:00:00' and '2014-07-31 23:59:59'
order by c.nome, g.nome, g.cidd,
@henricavalcante
henricavalcante / latlon2dist.js
Created April 2, 2014 23:10
Cálculo de distancia entre 2 latitude e longitude
function getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) {
var R = 6371; // Raio da terra
var dLat = deg2rad(lat2-lat1);
var dLon = deg2rad(lon2-lon1);
var a =
Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
Math.sin(dLon/2) * Math.sin(dLon/2)
;
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
@henricavalcante
henricavalcante / 0_reuse_code.js
Created July 24, 2014 20:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@henricavalcante
henricavalcante / ir_remote.ino
Last active August 29, 2015 14:04
ARDUINO Samples
/*
* IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/
#define IR_POWER 0xFFA25D
#define IR_MODE 0xFF629D
#define IR_MUTE 0xFFE21D
@henricavalcante
henricavalcante / scripts.sh
Created October 7, 2014 14:07
Shell Script Utils
#download all links in text file
for i in `cat /testcurl.txt` ; do curl -O $i ; done