Skip to content

Instantly share code, notes, and snippets.

View Chavao's full-sized avatar
💻
Coding...

Diego Chavão Chavao

💻
Coding...
View GitHub Profile
@Chavao
Chavao / gist:2654905
Created May 10, 2012 18:29
Force numeric only
jQuery.fn.ForceNumericOnly = function() {
return this.each(function()
{
$(this).keydown(function(e)
{
var key = e.charCode || e.keyCode || 0;
// allow backspace, tab, delete, arrows, ctrl + a, numbers and keypad numbers ONLY
return (
key == 8 ||
key == 9 ||
chavao@ubuntu:~/Desktop/Simplate (master)$ phpunit --configuration tests/phpunit.xml
PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Cannot open file "bootstrap.php".
' in /usr/share/php/PHPUnit/Util/Fileloader.php:108
Stack trace:
#0 /usr/share/php/PHPUnit/TextUI/Command.php(786): PHPUnit_Util_Fileloader::load('bootstrap.php')
#1 /usr/share/php/PHPUnit/TextUI/Command.php(156): PHPUnit_TextUI_Command->handleArguments(Array)
#2 /usr/share/php/PHPUnit/TextUI/Command.php(147): PHPUnit_TextUI_Command->run(Array, true)
#3 /usr/bin/phpunit(52): PHPUnit_TextUI_Command::main()
#4 {main}
thrown in /usr/share/php/PHPUnit/Util/Fileloader.php on line 108
function runArray(arr, callback) {
for(i in arr) {
callback(arr[i]);
}
}
a = ['alfa', 'beta', 'delta', 'omega'];
runArray(a, function(val) {
alert(val);
$.fn.invertOnClick = function(context) {
return this.click(function(e) {
e.preventDefault();
context.each(function(i) {
if($(this).is(':visible'))
{
var inputCheck = $(this).find('input[type=checkbox]');
chavao@ubuntu:~/Desktop/cpp/proj$ g++ -c -g rumo.cpp
chavao@ubuntu:~/Desktop/cpp/proj$ g++ -g -g main.cpp
main.cpp: In function ‘int main()’:
main.cpp:8: error: aggregate ‘Rumo r’ has incomplete type and cannot be defined
chavao@ubuntu:~/Desktop/cpp/proj$
#include <iostream>
#include "rumo.h"
using namespace std;
int main()
{
Rumo r;
// Definindo um valor qualquer para "Rumo"
r.setValor(70);
@Chavao
Chavao / FileUploadComponent.php
Created August 6, 2012 01:30
File uploader for Cake PHP
<?php
class FileUploadComponent extends Component {
public $allowedTypes;
public $maxSize;
private $tmpFile;
public $uploadPath;
public function __construct() {
@Chavao
Chavao / gist:3404153
Created August 20, 2012 13:39
Elimina os arquivos com mais de 3 dias
#!/bin/bash
#
# Elimina os arquivos com mais de 3 dias;
#
for d in /home/chavao/Desktop/temp; do
find $d -type f -mtime +3 -exec rm --force "{}" \;
#
# Removemos os diretóios vazios
<?php
function get_data_uri($image_path) {
return 'data: '.mime_content_type($image_path).';base64,'.base64_encode(file_get_contents($image_path));
}
@Chavao
Chavao / gist:3776332
Created September 24, 2012 14:50
SNR / Atenuação
SNR Margin - Relação Sinal ruído:
- 5db ou menos = ruim, impossível sincronia, quedas frequentes
- 8db-13db = regular - sem problemas com sincronia do modem
- 14db-22db = muito bom
- 23db-28db = excelente
- 29db-35db = raro
Atenuação: