Skip to content

Instantly share code, notes, and snippets.

@hugodias
hugodias / gist:4026227
Last active October 12, 2015 12:27
Remove files recursive in tree mode unix
# Will remove all .mp3 files starting in current directory and will search in each folder
find . -name '._*' -exec rm -f {} \;
@hugodias
hugodias / gist:4031128
Created November 7, 2012 12:14
Load multiple videos from youtube using JSON
<script type="text/javascript">
function loadVideoInfo(ID) {
var i = 1;
return $.getJSON('http://gdata.youtube.com/feeds/api/videos/'+ID+'?v=2&alt=jsonc',function(data,status,xhr){
var template,thumbnail,nome,ul;
thumbnail = data.data.thumbnail.hqDefault;
nome = data.data.title;
if( i%5 === 0 ) {
@hugodias
hugodias / ArquivoComponent.php
Created November 13, 2012 11:40
Arquivo Component for cakePHP
<?php
# Componente para Upload e Downlload de arquivos.
class ArquivoComponent extends Component
{
public function extensao($arquivoNome)
{
$extencao = explode('.', $arquivoNome);
$extencao = end($extencao);
@hugodias
hugodias / gist:4278062
Created December 13, 2012 17:16
How to Defer parsing javascript
<script defer="defer" type="text/javascript">
window.onload=function(){
var mycode;
mycode=document.createElement("script");
mycode.type="text/javascript";
mycode.src="<?php bloginfo('template_url') ?>/js/your_script.js";
document.getElementsByTagName("head")[0].appendChild(mycode);
}
</script>
@hugodias
hugodias / rename.sh
Last active October 14, 2015 01:28
Rename multiple files in sequential numbers shell
j=1
for i in *.jpg;
do
mv "$i" "$j.jpg";
((j++))
done
@hugodias
hugodias / app.js
Created December 17, 2012 15:45
Retrieve all gists from user
// https://github.com/ajaxorg/node-github
var GitHubApi = require("github");
var github = new GitHubApi({
version: "3.0.0"
});
github.gists.getFromUser({
user: "hugodias"
}, function(err, res) {
console.log(JSON.stringify(res));
@hugodias
hugodias / slufigy.php
Last active December 13, 2015 21:28
Slugfy function for php
public function slufigy($string)
{
$table = array(
'Š'=>'S', 'š'=>'s', 'Đ'=>'Dj', 'đ'=>'dj', 'Ž'=>'Z', 'ž'=>'z', 'Č'=>'C', 'č'=>'c', 'Ć'=>'C', 'ć'=>'c',
'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O',
'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss',
'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e',
'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o',
'ô'=>'o', 'õ'=>'o', 'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b',
@hugodias
hugodias / gist:5038281
Created February 26, 2013 13:07
Parents
<?php
// AppController.php
class AppController extends Controller {
// ...
}
// AppUsersController.php
class AppUsersController extends AppController {
public function funcaoTeste(){
// ...
@hugodias
hugodias / gist:5107717
Created March 7, 2013 12:31
Datepicker no WeekendsOrMondays
$(document).ready(function() {
// Apenas dias a partir do dia atual poderão ser escolhidos
var dateMin = new Date();
// Função para bloquear finais de semana e segunda-feira
function noWeekendsOrMondays(date) {
var day = date.getDay();
// Remove finais de semana do calendário
@hugodias
hugodias / gist:5107754
Created March 7, 2013 12:38
Specific days datepicker
var availableDates = ["9-5-2011","14-5-2011","15-5-2011"];
function available(date) {
dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
console.log(dmy+' : '+($.inArray(dmy, availableDates)));
if ($.inArray(dmy, availableDates) != -1) {
return [true, "","Available"];
} else {
return [false,"","unAvailable"];
}