Skip to content

Instantly share code, notes, and snippets.

View matiskay's full-sized avatar

Edgar Marca matiskay

View GitHub Profile
@matiskay
matiskay / README.md
Created January 4, 2012 23:47
PHP Tips and Tricks
@matiskay
matiskay / frequency.pl
Created January 5, 2012 03:44
How many times do you use your commands
#!/usr/bin/perl
my %counts = () ;
while (my $cmd = <STDIN>) {
chomp $cmd ;
if (!$counts{$cmd}) {
$counts{$cmd} = 1 ;
} else {
$counts{$cmd}++ ;
}
require 'rubygems'
require 'oauth'
require 'yaml'
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
def get_access_token
p "get_access_token: Initializing Consumer"
consumer = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, {
@matiskay
matiskay / spider.py
Created January 5, 2012 20:52
A spider using scrapy
from scrapy import log
from scrapy.spider import BaseSpider
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.selector import HtmlXPathSelector
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from icone.items import Product
class IconeSpider(CrawlSpider):
@matiskay
matiskay / README.md
Created January 6, 2012 01:19
Idea to get the spider works
@matiskay
matiskay / clean.py
Created January 10, 2012 22:40
Refactoring the clean function
# After
def clean(i_list):
"""
Generate a string from a list stripped all the extra whitespace
"""
r_list = [string.strip() for string in i_list]
return ' '.join(r_list)
# Before
@matiskay
matiskay / rsync.sh
Created January 11, 2012 18:43
Rsync
#!/bin/bash
# Always use -n to test
# Variables
REMOTE_PATH=''
SSH=''
LOCAL_PATH=''
rsync -a -z -v --progress --delete -e ssh $SSH:$REMOTE_PATH $LOCAL_PATH
@matiskay
matiskay / README.md
Created January 11, 2012 20:24
Change mysql prompt

Change your mysql prompt

Use an environment variable. You can set the MYSQL_PS1 environment variable to a prompt string. For example:

  export MYSQL_PS1="(\u@\h) [\d]> "

More info

@matiskay
matiskay / backup.sh
Created January 13, 2012 17:12
Backuping script
#!/bin/bash
date_stamp=$(date +%y-%m-%d-%H-%M-%S)
WP_PATH=''
DB_NAME=''
DB_USER=''
DB_PASS=''
BACKUP_PATH=''
mkdir ${BACKUP_PATH}/${date_stamp}
@matiskay
matiskay / wp-dbmigration.sh
Created February 22, 2012 14:33
Wordpress migration sql
#! /bin/bash
# I hate wordpress </3
# http://www.oldsiteurl.com
# http://www.newsiteurl.com
if [[ $# -lt 2 ]]; then
echo 'Please, provide the following parameters: [old_url] [new_url]'
echo ''
echo 'For example: '