Skip to content

Instantly share code, notes, and snippets.

@sergioccrr
sergioccrr / gist:9840c7677b8dd5873b84
Last active August 29, 2015 14:02
human implode
<?php
function human_implode($items) {
$last = array_pop($items);
$str = implode(', ', $items);
if (!empty($items)) {
$str .= ' y ';
}
$str .= $last;
return $str;
var https = require('https'),
crypto = require('crypto'),
url = require('url'),
querystring = require('querystring');
const CONSUMER_KEY = 'xxxxxxxxxxxxxxxxxxxx';
const CONSUMER_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
const ACCESS_TOKEN = 'xxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
const ACCESS_TOKEN_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
* {
margin: 0;
padding: 0;
outline: none;
}
html {
min-height: 100%;
overflow-y: scroll;
}
@sergioccrr
sergioccrr / greader.py
Last active December 19, 2015 03:58
Download Google Reader feeds.
# -*- coding: utf-8 -*-
import requests
import urllib, time, sys
import string
def filename_string(feed):
valid_chars = "-_() %s%s" % (string.ascii_letters, string.digits)
return ''.join(c for c in feed if c in valid_chars)
def save(feed):
@sergioccrr
sergioccrr / anti-magic-quotes.php
Created April 14, 2013 03:53
Anti Magic Quotes
<?php
if (get_magic_quotes_gpc()) {
$_GET = array_map('stripslashes', $_GET);
$_POST = array_map('stripslashes', $_POST);
}
@sergioccrr
sergioccrr / t2t.php
Created February 10, 2013 04:16
Tweetbot2Twitpic
<?php
define('API_KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
function _header($code) {
$code = (int) $code;
$codes = array(
403=>'Forbidden',
404=>'Not Found',
@sergioccrr
sergioccrr / youtube_id.php
Last active October 3, 2015 02:07
Extract the youtube ID from a URL
<?php
function youtube_id($url) {
$parsed = parse_url($url);
if (!is_array($parsed)) {
return false;
}
if (preg_match('#(^|\.)youtu\.be$#', $parsed['host']) && !empty($parsed['path'])) {
return substr($parsed['path'], 1);
@sergioccrr
sergioccrr / login.sh
Created April 1, 2012 14:48
Google Wave Backup
#!/bin/bash
read -p 'Email: ' user
read -s -p 'Password: ' pass
echo
rLogin=$(curl --silent --data "Email=$user&Passwd=$pass&service=wave" --write-out '%{http_code}' https://www.google.com/accounts/ClientLogin)
cLogin=$(echo $rLogin | awk '{print $NF}')
if [ $cLogin != '200' ]; then
echo 'Error en el login :-('
@sergioccrr
sergioccrr / bot.pl
Created March 15, 2012 15:29
Verdana
#!/usr/bin/perl
use strict;
use IO::Socket;
use LWP::UserAgent;
use HTTP::Request;
### Config
my $SERVER = 'calvino.freenode.net';
my $PORT = 6667;