Skip to content

Instantly share code, notes, and snippets.

View riccardobl's full-sized avatar

Riccardo Balbo riccardobl

View GitHub Profile
@riccardobl
riccardobl / KwallH
Last active August 29, 2015 14:19
A script that can be used with ScriptedWallpaper to pick a random image from Wallhaven and set it as background for kde.
A script that can be used with ScriptedWallpaper to pick a random image from Wallhaven and set it as background for kde.
All the code is released under public domain.
import com.jme3.app.SimpleApplication;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
@riccardobl
riccardobl / updateCloudflare.sh
Created July 12, 2015 15:19
Update records' ips of cloudflare using bash
#!/bin/sh
ip=$(curl https://wtfismyip.com/text)
# For api documentation see https://www.cloudflare.com/docs/client-api.html
curl https://www.cloudflare.com/api_json.html \
-d 'a=rec_edit' \
-d 'tkn=XXXXXXXXXXXXXXXXXXXX' \
-d 'email=XXXXXXXXXXXXXXXXXXXX' \
-d 'z=XXXXXXXXXXXXXXXXXXXX' \
-d 'id=XXXXXXXXXXXXXXXXXXXX' \
@riccardobl
riccardobl / Openstack-SecurityRules-from-CIDR-list.sh
Last active August 29, 2015 14:26
Read cidrs from provided urls and add them to a nova openstack's security group
SECURITY_GROUP='xxxxxx' #EDIT ME
REGION='xxxxxx' #EDIT ME
RC_FILE='xxxxxx' #EDIT ME
CIDR_LISTS=("https://gist.githubusercontent.com/riccardobl/28a616180d8d7ad44473/raw/telecom-italia-ips.txt")
DELETE_OLD_RULES=true
DELAY_BETWEEN_REQUESTS=2
source "$RC_FILE"
export OS_REGION_NAME="$REGION"
80.253.32.0/20
217.172.192.0/19
81.72.0.0/14
82.104.0.0/14
82.88.0.0/14
80.104.0.0/15
37.205.128.0/17
195.120.0.0/16
195.31.0.0/16
195.103.0.0/16
# ip2cidr = http://www.linuxweblog.com/blogs/sandip/20080515/ip-range-cidr-conversion
echo "">$1.cidr
while read -r line
do
parts=($(echo $line))
start=${parts[0]}
end=${parts[1]}
echo $start,$end
ip2cidr $start-$end >> $1.cidr
done < <(cat $1)
package cl.test.simpletest;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.util.LinkedList;
import java.util.List;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.PointerBuffer;
@riccardobl
riccardobl / firefox-kde.sh
Last active November 28, 2015 23:00
Per-activity firefox profile under kde.
#!/bin/bash
echo 'qdbus org.kde.kactivitymanagerd /ActivityManager/Activities CurrentActivity'>/usr/bin/echo_current_activity
chmod +x /usr/bin/echo_current_activity
echo "Activity for default profile: "
read default_activity
echo '
#!/bin/bash
'>/usr/bin/firefox-kde
@riccardobl
riccardobl / micloopback.sh
Created January 20, 2016 16:29
Enable/Disable mic looback with pulseaudio
function enable {
pactl load-module module-loopback latency_msec=1 > ~/.micloopback.id
}
function disable {
pactl unload-module `cat ~/.micloopback.id`
}
if [ -f ~/.micloopback.id ]; then
@riccardobl
riccardobl / Video2GIF.sh
Last active February 4, 2016 17:24
Convert a video to a gif file.
#!/bin/bash
#
# Usage: video2gif myvideo.mp4
#
temp_dir=/tmp/video2gif-`tr -dc A-Za-z0-9 < /dev/urandom | head -c 8`
echo "Using temp directory $temp_dir"
mkdir "$temp_dir"
ffmpeg -i "$1" -r 15 -vf scale=-1:-1 "$temp_dir/frame-%04d.gif"
convert -delay 1x15 -loop 0 "$temp_dir/frame-*.gif" "$temp_dir/animation.gif"