Skip to content

Instantly share code, notes, and snippets.

View martinellimarco's full-sized avatar

Marco Martinelli martinellimarco

View GitHub Profile
@wandernauta
wandernauta / sp
Last active May 14, 2024 16:49
sp is a command-line client for Spotify's dbus interface. Play, pause, skip and search tracks from the comfort of your command line.
#!/usr/bin/env 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.
#

Trashing the Vodafone Station

How to replace the Vodafone Station with your very own router

Vodafone forces its customers to use their modem/router, the "Vodafone Station": using any other router is impossible because authentication is being done via a custom PPPoE setup.
In the PPPoE packet there is a field named Host-Uniq which is used to separate packets from different PPPoE sessions: Vodafone requires the Station serial number to be put in this field as authentication.

Hardware setup

A Linux router with root access is needed to replace the Station with. With an xDSL connection a modem with a custom firmware like OpenWrt has to be used, most likely one based on a Lantiq SoC.
For a FTTH internet connection then every machine with at least two gigabit ethernet interface and a decent CPU will do it.

@matoakley
matoakley / gist:1092571
Created July 19, 2011 14:38
MySQL to convert a string into a slug
LOWER(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(TRIM('My String'), ':', ''), ')', ''), '(', ''), ',', ''), '\\', ''), '\/', ''), '\"', ''), '?', ''), '\'', ''), '&', ''), '!', ''), '.', ''), ' ', '-'), '--', '-'), '--', '-')) AS `post_name`
@Mariovc
Mariovc / ImagePicker.java
Last active February 7, 2024 23:33
Utility for picking an image from Gallery/Camera with Android Intents
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
@fuweichin
fuweichin / index.html
Last active January 30, 2024 15:09
Power Saving Mode detection
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Power Saving Mode detection</title>
</head>
<body>
<div>Power Saving Mode? <code id="powerSavingMode"></code></div>
<script type="module">
//http://gamedev.stackexchange.com/questions/59797/glsl-shader-change-hue-saturation-brightness
vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
@tanaikech
tanaikech / submit.md
Last active December 12, 2023 23:41
Retrieving Access Token using Service Account for PHP without using googleapis

Retrieving Access Token using Service Account for PHP without using googleapis

This is a sample PHP script to retrieve the access token from Service Account of Google without using googleapis.

Sample script

<?php

$private_key = "-----BEGIN PRIVATE KEY-----\n###-----END PRIVATE KEY-----\n"; // private_key of JSON file retrieved by creating Service Account
@dvdpearson
dvdpearson / function.php
Last active November 22, 2023 20:58
Temporary disable WPML's adjust_id functionality in order to let me choose the right locale
global $sitepress;
$translated_term_id = icl_object_id($term_id, $taxonomy, true, $language_code);
remove_filter( 'get_term', array( $sitepress, 'get_term_adjust_id' ), 1 );
$translated_term_object = get_term_by('id', $translated_term_id, $taxonomy);
add_filter( 'get_term', array( $sitepress, 'get_term_adjust_id' ), 1, 1 );
@Leowbattle
Leowbattle / TransitionScreen.java
Created March 3, 2018 15:49
Simple fade-in fade-out screen transition for libGDX
package leo.sortorsplode;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
public class TransitionScreen implements Screen {
private Screen currentScreen;
private Screen nextScreen;