Skip to content

Instantly share code, notes, and snippets.

View raelga's full-sized avatar
🐱
Learning

Rael Garcia raelga

🐱
Learning
View GitHub Profile
@raelga
raelga / rdd-to-sql
Last active October 30, 2021 05:23
Export munin data to SQL.
echo 'DROP TABLE munin;' > munin.sql
echo 'CREATE TABLE munin (id SERIAL PRIMARY KEY, node VARCHAR(10), data VARCHAR(50), value FLOAT, time TIMESTAMP WITH TIME ZONE);' >> munin.sql;
echo 'BEGIN;' >> munin.sql;
for rrd in *rrd;
do
rrdtool dump $rrd $rrd.xml;
host=`echo $rrd | sed 's/\(.*\)_\(.*\)\.rrd/\1/'`;
data=`echo $rrd | sed 's/\(.*\)_\(.*\)\.rrd/\2/'`;
sed -n "s@.*-- \(.* CEST\).*<v>\(.*\)</v></row>@INSERT INTO munin (node,data,value,time) VALUES (\'$host\',\'$data\',\'\2\',\'\1\');@p" $rrd.xml >> munin.sql;
@raelga
raelga / gist:6000743
Last active December 19, 2015 18:39
Divide and look for badblocks
#!/bin/bash
if [ -z $1 ]
then
echo "Usage: $0 sdx"
exit
elif [ `echo $1 | grep -c '/dev/'` -eq 0 ]
<?php
$source_file = "test_image.jpg";
// histogram options
$maxheight = 300;
$barwidth = 2;
$im = ImageCreateFromJpeg($source_file);
@raelga
raelga / gist:7211025
Last active December 26, 2015 20:48
Java
for i in `find /usr/lib/jvm/last-jdk/bin/`;
do
b=`basename $i`;
update-alternatives --remove $b $i;
update-alternatives --install /usr/bin/$b $b $i 90000;
update-alternatives --set java $i;
done
unlink /opt/google/chrome/plugins/libnpjp2.so
unlink /usr/lib/mozilla/plugins/libnpjp2.so
@raelga
raelga / install-firefox
Last active August 29, 2015 14:00
Install Last Firefox
#!/bin/bash
export URL="http://releases.mozilla.org/pub/mozilla.org/firefox/releases/latest/linux-x86_64/en-GB/";
mkdir -p /opt/mozilla/;
curl -L `curl -L $URL | sed -n 's@.*\(firefox-.*tar.bz2\)<.*@'$URL'/\1@p'` | sudo tar -jx -C /opt/mozilla/;
@raelga
raelga / sp
Last active August 29, 2015 14:23 — forked from wandernauta/sp
#!/bin/bash
#
# This is sp, the command-line Spotify controller. It talks to a running
# instance of the Spotify Linux client over dbus, providing an interface not
# unlike mpc.
#
# Put differently, it allows you to control Spotify without leaving the comfort
# of your command line, and without a custom client or Premium subscription.
#
import hashlib
for i in hashlib.algorithms_available:
t = "sophie1";
h = hashlib.new(i);
h.update(t);
th = h.hexdigest();
print(t+" > "+i+" > "+h.hexdigest());
@raelga
raelga / disk_usage.sh
Created March 31, 2016 07:45
Disk usage inspection
#!/bin/bash
# Get current disk usage
df -h
# Get the top 5 disk consuming folders
du -hxS / 2> /dev/null | sort -rh | head -n5
<script src="https://unpkg.com/vue"></script>
<main id="app" class="site">
<header class="menu">Twister</header>
<aside class="profile">
Profile Information
</aside>
@raelga
raelga / authorized_keys
Last active May 14, 2018 15:39
authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCtamh2f6em6LhjwR8kaTPZ4RerPmjVeJEJr5t81GtGKQW6+9gr4e8Ou6LPsMn2XplQCDNGZYBWpvQI6YEYzA2DuzWPfOVomvqjwddjsJ01cvyQ2JZejz4qFoAD0g6eMEOgzViquDCWvEmB1PUIHMsjdA4oqtZhGMaSjgG3IcE1NuyGbABFYUiITdzn6CUQBMAnSS34gC4Z6Q2wqUYCjs4wBw5eZsCj3VYR4SonwXF9aMf2JTLZtKaS8xjvURjiY+2wdRYpkExuyUnGB3ycyi6oLCOY4FH0e0o5GQo2VHw+eYu+rJHoIGBFHG9sDof2AR8KHz/l8AJBXtZXaAQb5wU8CsmCQBLEGkg1gq/iIgDkbOpyciZyH5vX4MbaqhsIu3PdgQ0TgwIbaa+xLtSHOdZDw/EIaSfgsvCdwuNa0wy8uNtJqrpvTmA+yfs1AEgeXAZJsJdwG3J9wKXuljwelSBipPyscgQ7FWzAy772mIdcUd0wt+8l3pMEQ482dbJ18sfFYUPZG/f8GGlE4W3XttDIa1lmWD1Y2V8kRB3t1VD3+E6i5x6zxq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