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: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
@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() {
#include <iostream>
#include "rumo.h"
using namespace std;
int main()
{
Rumo r;
// Definindo um valor qualquer para "Rumo"
r.setValor(70);
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$
$.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]');
function runArray(arr, callback) {
for(i in arr) {
callback(arr[i]);
}
}
a = ['alfa', 'beta', 'delta', 'omega'];
runArray(a, function(val) {
alert(val);
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
@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 ||
var g_link_amigos = ['http://chav.in/1wh', 'http://chav.in/1CO'];
jQuery(function() {
jQuery(".link-amigos").attr('href', g_link_amigos[(Math.floor(Math.random()*g_link_amigos.length))]);
});
@Chavao
Chavao / gist:2485583
Created April 25, 2012 02:22
Remover todos os tweets que foram enviados como replies/mention.
$('.js-tweet-text').each(function() { if($(this).text().match(/^@/g)) $(this).closest('.tweet').remove(); });