This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>br.com.projeto</groupId> | |
<artifactId>nomedoartefato</artifactId> | |
<packaging>jar</packaging> | |
<version>1.0-SNAPSHOT</version> | |
<name>nome do projeto</name> | |
<url>http://maven.apache.org</url> | |
<build> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Maps para copiar e colar no Vim | |
:vmap <C-c> "+y ; Ctrl+C, funciona em Visual Mode | |
:vmap <C-x> "+x ; Ctrl+X, funciona em Visual Mode | |
:imap <C-v> <ESC>"+gpA ; Ctrl+V, funciona em Insert Mode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void removeDirectory(String path) throws Exception { | |
Stack<File> dirs = new Stack<File>(); | |
File root = new File(path); | |
File currentDir = root; | |
dirs.add(root); | |
while(!dirs.empty()) { | |
currentDir = dirs.lastElement(); | |
File files[] = currentDir.listFiles(); | |
for(int i=0; i<files.length; i++) { | |
if(files[i].isDirectory()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // help is welcome | |
function generate_video_thumb($video_path, $image_target_path, $offset=0) { | |
$video_path = addcslashes($video_path, " "); // para videos com espaços no nome do arquivo | |
if(file_exists($video_path)) { | |
$position = ''; | |
if($offset > 0) { | |
$position = '-ss ' . $offset; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // help is welcome | |
function get_video_duration($video_path) { | |
$video_path = addcslashes($video_path, " "); // para videos com espaços no nome do arquivo | |
$command = "mplayer -vo null -ao null -frames 0 -nolirc -identify -cache 20480 {$video_path} 2>&-"; | |
exec($command, $output, $retcode); | |
if($retcode === 0) { | |
foreach($output as $line) { | |
if(preg_match('/^ID_LENGTH=([0-9]+(\.[0-9]+)?)$/', $line, $duration)) { | |
return floatval($duration[1]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // help is welcome | |
function attach_file($current_path, $desired_name, $to_post_id, $uploaded=true) { | |
if(!file_exists($current_path)) { | |
return false; | |
} | |
$uploads = wp_upload_dir(); | |
$file_name = preg_replace('/[^\w.]/', '-', remove_accents($desired_name)); | |
$file_path = $uploads['path'] . '/' . $file_name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Fractal</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
<script type="application/x-javascript"> | |
window.onload = function() { | |
var canvas = document.getElementById('canvas'); | |
var d = canvas.getContext('2d'); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git status --porcelain| | |
while read f; | |
do | |
[[ $f =~ ^\s*M\s*(.+\.php)$ ]] | |
php="${BASH_REMATCH[1]}"; | |
if [ `grep -v "^[ ]*$" <<< $php` ] | |
then | |
error=`php -l $php 2>&1`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** Return true if supplied cpf is valid or give an error message otherwise */ | |
function is_a_valid_cnpj($cnpj) { | |
$error = __("O CNPJ fornecido é inválido."); | |
$cnpj = preg_replace('/[^0-9]/', '', $cnpj); | |
if(strlen($cnpj) != 14) { | |
return $error; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** Return true if supplied cpf is valid or give an error message otherwise */ | |
function is_a_valid_cpf($cpf) { | |
$error = __("O CPF fornecido é inválido."); | |
$cpf = preg_replace('/[^0-9]/','',$cpf); | |
if(strlen($cpf) != 11 || preg_match('/^([0-9])\1+$/', $cpf)) { | |
return $error; | |
} |
OlderNewer