Skip to content

Instantly share code, notes, and snippets.

View minichiello's full-sized avatar

Gerson Minichiello minichiello

  • Como, Italy
View GitHub Profile
@minichiello
minichiello / Argument_list_too_long.sh
Created May 16, 2009 21:06
Argument_list_too_long.sh
#!/bin/bash
# rm -f *.xml
# -bash: /bin/rm: Argument list too long
find . -name '*.xml' | xargs rm -f
30 13 * * * /home/username/run-me.sh >/dev/null 2>&1
0 * * * * curl --silent --compressed http://example.com/cron.php >/dev/null 2>&1
crontab filename Install filename as your crontab file,
crontab -e Edit your crontab file, or create one if it doesn’t already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -v Display the last time you edited your crontab file.
@minichiello
minichiello / Shebang PHP5 Dreamhost
Created May 16, 2009 21:48
Shebang PHP5 Dreamhost
#!/usr/local/php5/bin/php -q
// Note "-q" in shebang used to suppress header output
// PHP4:
// /usr/local/bin/php
@minichiello
minichiello / Windows Update Fail
Created July 26, 2009 01:55
Windows Update Fail
net stop wuauserv
net stop bits
net stop cryptsvc
ren %systemroot%\System32\Catroot2 oldcatroot2
net start cryptsvc
ren %systemroot%\SoftwareDistribution SoftwareDistribution.old
regsvr32 wuapi.dll /s
@minichiello
minichiello / getUrlVars.js
Created September 21, 2009 22:58
GET params Javascript
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
@minichiello
minichiello / RemoverAcentos.py
Created September 27, 2009 15:31
Python Remover Acentos
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from unicodedata import normalize
def remover_acentos(txt, codif='utf-8'):
''' Devolve cópia de uma str substituindo os caracteres
acentuados pelos seus equivalentes não acentuados.
@minichiello
minichiello / edit_page_online.js
Created November 19, 2009 14:28
Javascript Edit a page online
javascript:void(document.body.contentEditable=(document.body.contentEditable!='true'))
@minichiello
minichiello / prevents_thecopying_of_texts.js
Created December 12, 2009 02:31
Prevents the copying of texts
<script type="text/javascript">
document.oncontextmenu = function(){return false}
document.onselectstart = function(){
if (event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type != "password")
return false;
else
return true;
};
if (window.sidebar){
@minichiello
minichiello / .htaccess
Created December 12, 2009 15:23
Hotlink Protection with .htaccess
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]
-OR-
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]
@minichiello
minichiello / post_wordpress.php
Created December 23, 2009 00:18
PHP - Post on WordPress
function wpPostXMLRPC($title, $body, $rpcurl, $username, $password, $category, $keywords='', $encoding='UTF-8') {
$title = htmlentities($title,ENT_NOQUOTES,$encoding);
$keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);
$content = array(
'title'=>$title,
'description'=>$body,
'mt_allow_comments'=>0, // 1 to allow comments
'mt_allow_pings'=>0, // 1 to allow trackbacks
'post_type'=>'post',