Skip to content

Instantly share code, notes, and snippets.

View martinellimarco's full-sized avatar

Marco Martinelli martinellimarco

View GitHub Profile
@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">
@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
@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;
@jonathanlurie
jonathanlurie / arrayFunction.cpp
Created March 10, 2017 20:56
Emscripten and float arrays v2
#include <math.h>
// otherwise C++ function names are mangled
extern "C" {
void float_multiply_array(float *data, int w, int h, int ncpp) {
int length = w*h;
int currentPixelIndex = 0;

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.

@adamierymenko
adamierymenko / zerotier_rules_example.ztrd
Last active June 13, 2023 17:57
An example of what an advanced ZeroTier network rule set might look like
# This is an example from a work in progress, so final versions might
# be slightly different. Don't use as a guide after release!
# Define rule set macros
# Whitelist a TCP destination port on the network. Use this as a template to
# make your own rule sets for more advanced criteria like tag matches, etc.
# This works for both IPv4 and IPv6. Add an ethertype match to restrict it to
# one or the other.
macro tcp_whitelist_dest_port($port)
@qinshulei
qinshulei / ConvertAndroidVectorDrawable2png.md
Last active September 20, 2022 07:29
Convert Android VectorDrawable to png

转换方法:

  1. Convert Android VectorDrawable to SVG:

使用附件中的java程序。命令如下:

cp Vector2Svg.java path/to/xml_dir
javac Vector2Svg.java
java Vector2Svg ./*.xml
mkdir svg_dir
@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;
@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 );