Skip to content

Instantly share code, notes, and snippets.

@wagnerpinheiro
wagnerpinheiro / unique_css_colors.sh
Created January 25, 2013 14:29
Finding unique CSS colors with grep and perl
#!/bin/bash
#Finding unique CSS colors with grep and perl
#Just a tiny one-liner I’ve found useful to get unique CSS color values in a style sheet:
#source: http://www.itopen.it/2012/02/14/finding-unique-css-values-with-grep-and-perl/
#------------------
egrep -r '#[a-fA-F0-9]{3,6}+(\s|;)' *.css|perl -ne 'if (m/(#[a-fA-F0-9]{3,6}+)(\s|;)/){print "$1\n";}'|sort|uniq
@wagnerpinheiro
wagnerpinheiro / firewall-state.bat
Last active December 12, 2015 00:38
Disable/Enable windows server 2008 firewall
@echo off
rem Disable/Enable windows server 2008 firewall
if [%1]==[] goto usage
netsh firewall set opmode %1
goto :eof
:usage
@echo firewall-state [enable|disable]
//open links with '#_blank' anchor in a new page
function addBlankTargetForLinks () {
$('a[href^="http"],a[href*="#_blank"]').each(function(){
$(this).attr('target', '_blank');
});
}
$(document).bind('DOMNodeInserted', function(event) {
addBlankTargetForLinks();
});
@wagnerpinheiro
wagnerpinheiro / recode-to-utf8.sh
Last active August 29, 2015 13:57
recode all php files from iso-8859-1 to utf-8
#!/bin/bash
find . -type f -name "*.php" -exec recode iso-8859-1..utf-8 '{}' \;
@wagnerpinheiro
wagnerpinheiro / gist:9813301
Created March 27, 2014 17:34
Quick MD5 hash of a string
echo -n 'the_password' | md5sum -
@wagnerpinheiro
wagnerpinheiro / backup_mysql_users.sh
Created April 10, 2014 13:47
backup mysql users
mysql -BNe "select concat('\'',user,'\'@\'',host,'\'') from mysql.user where user != 'root'" | \
while read uh; do mysql -BNe "show grants for $uh" | sed 's/$/;/; s/\\\\/\\/g'; done > grants.sql
@wagnerpinheiro
wagnerpinheiro / extract-methods-perl-module.bash
Last active August 29, 2015 14:04
extract methods from perl modules
#!/bin/bash
# extract methods from perl modules
# author: Wagner Pinheiro
# public
grep "^sub .*.{" *
grep -h "^sub .*.{" * | sed 's/^sub /+/g' | sed 's/ {//g' | sed 's/{//g' | sed 's/\+\_/\-\_/g' | sort
# private
grep "^my .*.{" *
grep -h "^my .*.{" * | sed 's/^my /-/g' | sed 's/ \= sub {//g'
#Based on https://cwiki.apache.org/confluence/display/DRILL/Compiling+Drill+from+source
wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
yum install apache-maven
ln -s /usr/share/apache-maven/bin/mvn /usr/bin/
yum install java-1.7.0-openjdk.x86_64
yum install java-1.7.0-openjdk-devel

Let's say you're using Ubuntu 13.04 (Raring Ringtail, released in April 2013) and it just went End-of-Life on you, because it's supported for only 6 months, and the deprecated packages are taken down after 12 months.

You'll probably figure this out the hard way. When you run sudo apt-get update, it will eventually report these errors:

Ign http://archive.ubuntu.com raring-updates/universe Sources/DiffIndex
Err http://security.ubuntu.com raring-security/main Sources
  404  Not Found [IP: 91.189.91.15 80]
Err http://security.ubuntu.com raring-security/universe Sources
  404  Not Found [IP: 91.189.91.15 80]

Let's say you're using Ubuntu 13.04 (Raring Ringtail, released in April 2013) and it just went End-of-Life on you, because it's supported for only 6 months, and the deprecated packages are taken down after 12 months.

You'll probably figure this out the hard way. When you run sudo apt-get update, it will eventually report these errors:

Ign http://archive.ubuntu.com raring-updates/universe Sources/DiffIndex
Err http://security.ubuntu.com raring-security/main Sources
  404  Not Found [IP: 91.189.91.15 80]
Err http://security.ubuntu.com raring-security/universe Sources
  404  Not Found [IP: 91.189.91.15 80]