This file contains 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 | |
function merge_sort($my_array){ | |
echo "chamou merge_sort\n"; | |
if(count($my_array) == 1 ) { | |
return $my_array; | |
} | |
$mid = count($my_array) / 2; | |
This file contains 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 | |
$dir = '/Users/flaviosilveira/Dropbox/php-mentors/manuscript'; | |
$result = array(); | |
foreach(scandir($dir) as $file){ | |
switch ($file){ | |
case '.': | |
case '..': |
This file contains 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 | |
for file in `grep -ril 'pattern-match' . | grep -v 'script'` | |
do | |
sed -i '/pattern-match/ d' $file | |
done |
This file contains 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 | |
#Function to Encode | |
# Thanks to https://gist.github.com/cdown/1163649/8a35c36fdd24b373788a7057ed483a5bcd8cd43e | |
encode() { | |
local _length="${#1}" | |
for (( _offset = 0 ; _offset < _length ; _offset++ )); do | |
_print_offset="${1:_offset:1}" | |
case "${_print_offset}" in | |
[a-zA-Z0-9.~_-]) printf "${_print_offset}" ;; |
This file contains 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
// Inicia Casper, simulando User Agent | |
var casper = require('casper').create({ | |
pageSettings: { | |
userAgent: 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36' | |
} | |
} | |
); | |
// Vai até o endereço | |
casper.start('https://www.google.com.br/search?q=tuk%20tuk%20curitiba&*', function() { |
This file contains 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/sh | |
date=2015-01-01 | |
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do | |
if [ $(git log $branch --since $date | wc -l) -eq 0 ]; then | |
# echo "DELETAR $branch" | |
git push --delete origin $(echo $branch | sed 's/^\s*//' | sed 's/^origin\///') | |
#else | |
# echo "NAO $branch" |
This file contains 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
var value = { "aaa": "111", "bbb": "222", "ccc": "333" }; | |
var blkstr = []; | |
$.each(value, function(idx2,val2) { | |
var str = idx2 + ":" + val2; | |
blkstr.push(str); | |
}); | |
console.log(blkstr.join(", ")); |
This file contains 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 | |
function img_resize($ini_path, $dest_path, $params = array()) | |
{ | |
$width = !empty($params['width']) ? $params['width'] : null; | |
$height = !empty($params['height']) ? $params['height'] : null; | |
$constraint = !empty($params['constraint']) ? $params['constraint'] : false; | |
$rgb = !empty($params['rgb']) ? $params['rgb'] : 0xFFFFFF; | |
$quality = !empty($params['quality']) ? $params['quality'] : 100; | |
$aspect_ratio = isset($params['aspect_ratio']) ? $params['aspect_ratio'] : true; |
This file contains 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 | |
$image = $_FILES["file"]; | |
if(preg_match("/^image\/(pjpeg|jpeg|png|gif|bmp)$/", $image["type"])) | |
{ | |
// Mime Type | |
preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext); | |
// File name | |
$name = md5(uniqid(time())) . "." . $ext[1]; |