Skip to content

Instantly share code, notes, and snippets.

View MarcoCiaramella's full-sized avatar

Marco Ciaramella MarcoCiaramella

View GitHub Profile
@MarcoCiaramella
MarcoCiaramella / BarcodeScannerActivity.java
Last active May 19, 2023 08:33
Barcode scanner using CameraX and MLKit
import android.media.Image;
import android.os.Bundle;
import android.util.Size;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.OptIn;
import androidx.appcompat.app.AppCompatActivity;
import androidx.camera.core.Camera;
import androidx.camera.core.CameraSelector;
@MarcoCiaramella
MarcoCiaramella / swap_endianess.c
Created May 28, 2022 10:56
swap endianess of unsigned int (32bit) and unsigned long long (64bit)
#define swap_endianess32(val) (((val>>24) & 0xffu) | ((val>>8) & 0xff00u) | ((val<<8) & 0xff0000u) | ((val<<24) & 0xff000000u))
#define swap_endianess64(val) (((val>>56) & 0xffull) | ((val>>40) & 0xff00ull) | ((val>>24) & 0xff0000ull) | ((val>>8) & 0xff000000ull) | ((val<<8) & 0xff00000000ull) | ((val<<24) & 0xff0000000000ull) | ((val<<40) & 0xff000000000000ull) | ((val<<56) & 0xff00000000000000ull))
@MarcoCiaramella
MarcoCiaramella / walletConnect.js
Last active September 22, 2022 17:00
How to use Walletconnect v2.0 with Stellar network
// see https://docs.walletconnect.com/2.0/quick-start/dapps/client
import WalletConnectClient from "@walletconnect/client";
import { CLIENT_EVENTS } from "@walletconnect/client";
const TESTNET = 'stellar:testnet';
const PUBNET = 'stellar:pubnet';
const STELLAR_METHODS = {
SIGN: 'stellar_signAndSubmitXDR',
@MarcoCiaramella
MarcoCiaramella / UDP.java
Last active April 22, 2023 13:07
UDP sender and receiver for Android.
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
@MarcoCiaramella
MarcoCiaramella / fs_pixellation.glsl
Last active April 18, 2020 19:23
A fragment shader for glsl v1.0 that create a pixellation effect.
#version 100
precision mediump float;
uniform sampler2D u_texId;
// render target width
uniform float u_rt_w;
// render target height
uniform float u_rt_h;
// width of a low resolution pixel
@MarcoCiaramella
MarcoCiaramella / addSystemService.py
Last active February 7, 2019 10:30
System utility written in python that create a background service from executable. Service created will be run as: sudo service MyService {start|stop|restart|status}
#########
# System utility written in python that create a background service from executable.
# Service created will be run as: sudo service MyService {start|stop|restart|status}
# Run: sudo python addSystemService.py [executable name] [service name] [user]
# Example: sudo python addSystemService.py ./project/my_project.py MyPorjectService root options
#########
from sys import argv
import os
import stat
@MarcoCiaramella
MarcoCiaramella / cpAsync.js
Last active July 13, 2016 07:50
Nodejs function for copying a source to a destination file asynchronously
function cpAsync(srcPath,destPath,callback){
var rs = fs.createReadStream(srcPath);
var ws = fs.createWriteStream(destPath);
rs.on('error', function(err) {
console.log(err);
});
ws.on('error', function(err) {
console.log(err);