Skip to content

Instantly share code, notes, and snippets.

View tesfabpel's full-sized avatar

Fabrizio Pelosi tesfabpel

  • CostaSoft
View GitHub Profile
@tesfabpel
tesfabpel / proxy.rb
Last active August 29, 2015 14:01 — forked from torsten/proxy.rb
#!/usr/bin/env ruby
# A quick and dirty implementation of an HTTP proxy server in Ruby
# because I did not want to install anything.
#
# Copyright (C) 2009 Torsten Becker <torsten.becker@gmail.com>
require 'optparse'
require 'socket'
require 'uri'
@tesfabpel
tesfabpel / get_relative_path.php
Created October 14, 2014 07:32
Returns a relative path base on two absolute paths (not including files)
function getRelativePath($base = '/', $target = '/')
{
$out = array();
$base_ex = explode('/', $base);
$target_ex = explode('/', $target);
//Find common ancestor
$max = min(count($base_ex), count($target_ex));
for($i = 0; $i < $max; $i++)
#!/usr/bin/env ruby
require 'shellwords'
$LAST_MOD_FILE = 'GDRIVE_SYNC_LAST_MOD'
# date "+%s"
$LAST_MOD = Time.at 0
# Find the last modification time
@tesfabpel
tesfabpel / ClearBitmapData.cs
Last active October 3, 2015 08:22
Clear Bitmap Data
void ClearBitmapData(BitmapData bd, byte[] color)
{
var pf = bd.PixelFormat;
var size = sizeof(byte);
if(pf == PixelFormat.Format16bppRgb555)
size *= 2;
else if(pf == PixelFormat.Format24bppRgb)
size *= 3;
else if (pf == PixelFormat.Format32bppArgb)
@tesfabpel
tesfabpel / applet.js
Created May 4, 2012 17:50
Cinnamon power applet MOD
const Applet = imports.ui.applet;
const Gio = imports.gi.Gio;
const DBus = imports.dbus;
const Lang = imports.lang;
const St = imports.gi.St;
const PopupMenu = imports.ui.popupMenu;
const BUS_NAME = 'org.gnome.SettingsDaemon';
const OBJECT_PATH = '/org/gnome/SettingsDaemon/Power';
@tesfabpel
tesfabpel / PKGBUILD
Created June 7, 2016 06:34
solvespace-git PKGBUILD
# Maintainer: Kyle Keen <keenerd@gmail.com>
pkgname='solvespace-git'
pkgver=r795.1e2f199
pkgrel=1
pkgdesc="SOLVESPACE is a parametric 3d CAD program."
arch=('i686' 'x86_64')
url='http://solvespace.com/'
license=('GPL3')
depends=('libpng' 'json-c' 'glew' 'gtkmm')
@tesfabpel
tesfabpel / PKGBUILD
Created August 7, 2016 12:16
rpcs3 cereal fix
# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
pkgname=rpcs3-git
pkgver=0.0.0.9.r262.b7eda71
pkgrel=1
pkgdesc='A Sony PlayStation 3 emulator'
arch=('x86_64')
url='https://github.com/DHrpcs3/rpcs3'
license=('GPL2')
depends=('boost-libs' 'gcc-libs' 'glew' 'glibc' 'libgl' 'libx11' 'openal'
<!DOCTYPE html>
<html>
<head>
<script src='js/jquery.js'></script>
<script src='js/bicubicInterpolation.js'></script> <!-- https://github.com/sukhoi1/ie-bicubic-img-interpolation-plugin -->
<script type='text/javascript'>
$(function() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');
import time
import subprocess as sp
enc = 'UTF-8'
p = sp.Popen(['dialog', '--gauge', 'hello', '6', '75', '0'], stdin=sp.PIPE)
for i in range(0, 100):
p.stdin.write(bytes(str(i)+"\n", enc))
p.stdin.flush()
@tesfabpel
tesfabpel / lock.py
Created May 24, 2018 06:47
plasmashell lock
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib
i=0
def func(obj):
global i
win.set_title("i: %d" % i)