Skip to content

Instantly share code, notes, and snippets.

View GianpaMX's full-sized avatar

Juan Russell GianpaMX

View GitHub Profile
@GianpaMX
GianpaMX / gist:1066203
Created July 5, 2011 23:28
Scccript para borrar tablas
for i in `mysql -u root -p123456 activation -B -e "show tables" | grep core `; do mysql -u root -p123456 activation -e "drop table $i"; done
@GianpaMX
GianpaMX / gist:1122958
Created August 3, 2011 15:46
Trac-Admin
sudo trac-admin /var/lib/trac2/activation initenv
Path to repository [/path/to/repos]> /var/lib/subversion/repositorios/activation
sudo chmod a+rwx -R /var/lib/trac2/activation/
sudo nano -w /etc/apache2/sites-available/trac_sidi
sudo /etc/init.d/apache2 reload
sudo trac-admin /var/lib/trac2/activation permission add pablo WIKI_ADMIN
sudo trac-admin /var/lib/trac2/activation permission add pablo MILESTONE_ADMIN
sudo trac-admin /var/lib/trac2/activation permission add pablo PERMISSION_ADMIN
<?php
require_once 'PAMI/Autoloader/Autoloader.php';
PAMI\Autoloader\Autoloader::register();
ini_set('include_path', implode(PATH_SEPARATOR, array(
'phar://pami.phar', '/usr/share/php/log4php', ini_get('include_path')
)));
@GianpaMX
GianpaMX / bubble.cpp
Created August 8, 2012 23:00
C++ Bubble
#include <iostream> // para usar cout
#include <cstdlib> // para usar EXIT_SUCCESS
#include <vector> // para usar vectores (son como arrays)
// Para no tener que escribir std::cout, vector cada vez que se usen
using namespace std;
// Definición de funciones útiles
void printData(const vector<int> &data);
void swap(int *a, int *b);
@GianpaMX
GianpaMX / gist:3437880
Created August 23, 2012 15:45
m4a to mp3
for i in *.m4a; do mplayer -quiet -ao pcm:fast:waveheader:file=output.wav "$i" && lame --quiet -h -b 320 output.wav "$i.mp3" && mv "$i.mp3" "`echo "$i.mp3" | sed -e 's/m4a.mp3/mp3/'`" && rm output.wav && rm "$i"; done
@GianpaMX
GianpaMX / update.php
Created October 18, 2012 21:48
Automatically updating a hosts file for dynamic dns
<?php
if(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == ""){
$redirect = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
header("Location: $redirect");
}
class Host {
private $ip;
private $hosts;
@GianpaMX
GianpaMX / cmdownloader.php
Created March 11, 2013 09:19
Script para bajar música un playlistde Corona Music. Necesitas rtmpdump y avconv Para ejecutarlo: cat response.json | php cmdownloader.php | sh Donde response.json contiene el playlist bajado de coronamusic con el firebug
<?php
$json = file_get_contents("php://stdin");
$playlist = json_decode($json);
foreach($playlist->items as $index => $item) {
$artist = $item->artistName;
$album = $item->albumTitle;
$title = $item->name;
@GianpaMX
GianpaMX / overload-functions.cpp
Created April 12, 2013 14:54
How to ovearload functions in C++ and PHP
#include <iostream>
#include <string>
using namespace std;
class A {
public:
void f(const string &arg1, const string &arg2) {
cout << arg1 << ", " << arg2 << endl;
}
@GianpaMX
GianpaMX / imap-addressess-extractor.php
Created August 1, 2013 22:35
PHP Script to extract all email addresses from a mail box over IMAP protocol Usage: ./imap-addressess-extractor.php INBOX 0 1000 first parameter is the mailbox name second is the offset third is the quantity message to scan
#!/usr/bin/php
<?php
class Contact {
public $name;
public $email;
public function __construct($name = "", $email = "") {
$this->name = $name;
$this->email = $email;
@GianpaMX
GianpaMX / remove-old-kernels.sh
Created November 11, 2013 05:14
Remove old kernels on Debian / Ubuntu. Move it to /sbin/ and add execution permision.
#!/bin/bash
dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get -y purge