Skip to content

Instantly share code, notes, and snippets.

@felclef
felclef / clf-p2browser.sh
Created December 13, 2012 18:37
Created for MacOS, so you might need change something here... This script helps a log when you try to read errors printed as HTML, e.g. PHP's XDebug output inside a image src's attribute. Just copy the content and p2browser to read it with at least a drop of dignity.
#!/bin/bash
function p2browser() {
pbpaste > /var/tmp/clf-output.html && open /var/tmp/clf-output.html && sleep 3 && rm /var/tmp/clf-output.html
}
@felclef
felclef / clf-better-ping.sh
Created December 12, 2012 17:36
Better ping cuz I hate when I need to select part of a URL to ping. And it gets worse when it comes to Chrome, which copies the http:// stuff :P Put this on you bash/zsh rc file or whatever you want...
#!/bin/bash
function ping() {
lph=`echo $1 | sed 's#https*://\([^/]*\)/.*#\1#'`
/sbin/ping $lph
}
@felclef
felclef / ez-install.sh
Created December 5, 2012 20:29
install deb package from url # this script was once shamelessly copy-pasted from a gTalk conversation by the awful filipekiss faget, who uploaded here -> https://gist.github.com/4219057 <- before I could ever think of do the same. So I made this tribute <
#!/bin/bash
# once know as clf-ez-install.sh
# install deb package from url
# this script was once shamelessly copy-pasted from a gTalk conversation by the awful filipekiss faget,
# who uploaded here -> https://gist.github.com/4219057 <-
# before I could ever think of do the same. So I made this tribute <3
pkg=$( echo $1 | sed -r 's/^.+\/([^\/]+\.deb)/\1/g' )
wget $1 && dpkg -i $pkg
@felclef
felclef / httpd-vhosts.conf
Created July 5, 2012 19:12
httpd-vhosts.conf
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
@felclef
felclef / httpd.conf
Created July 5, 2012 19:11
httpd.conf
#
# Mac OS X / Mac OS X Server
# The <IfDefine> blocks segregate server-specific directives
# and also directives that only apply when Web Sharing or
# server Web Service (as opposed to other services that need Apache) is on.
# The launchd plist sets appropriate Define parameters.
# Generally, desktop has no vhosts and server does; server has added modules,
# custom virtual hosts are only activated when Web Service is on, and
# default document root and personal web sites at ~username are only
# activated when Web Sharing is on.
@felclef
felclef / felclef.zsh-theme
Created July 4, 2012 19:33
oh my zsh theme o' mine etc (based on don-not-remember-sorry-halp)
# hints got at http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
function collapse_pwd {
echo $(pwd | sed -e "s,^$HOME,~,")
}
function prompt_char {
git branch >/dev/null 2>/dev/null && echo '±' && return
hg root >/dev/null 2>/dev/null && echo '‚òø' && return
# echo '‚óã'
@felclef
felclef / felclef.zsh-theme
Created June 11, 2012 23:52
felclef's zsh theme (based on something I cant remember, sorry)
# hints got at http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
function collapse_pwd {
echo $(pwd | sed -e "s,^$HOME,~,")
}
function prompt_char {
git branch >/dev/null 2>/dev/null && echo '±' && return
hg root >/dev/null 2>/dev/null && echo '☿' && return
# echo '○'
@felclef
felclef / within-group-prog-count.sql
Created May 16, 2012 20:08
Simulating an partition-by-ordered-count (lol) in MySQL
-- olc: select id_quadro, user_hash from ( select iq.id_quadro, user_hash, if( @prev <> iq.id_quadro, @rownum := 1, @rownum := @rownum+1 ) as g_rank, @prev := iq.id_quadro from r7_inscricoes_quadros iq order by id_quadro, data_cadastro ) sq where g_rank <= 4
-- the sample uses some database wich I have not luvd... yet...
select
id_quadro,
user_hash
from
(
select
@felclef
felclef / ellano_links.html
Created March 21, 2012 19:42
Just talkin about links :P
@felclef
felclef / ora_sh_t_solver.sql
Created December 2, 2011 16:54
workaround etc... plsql could really do what you guys think you cant with yer rb, py, php, etc
declare
entity_count integer := 0;
type t_ct_cur is ref cursor;
ct_cur t_ct_cur;
type t_codmat is table of varchar2(255);
blk_codmat t_codmat;