Skip to content

Instantly share code, notes, and snippets.

@bryanjhv
bryanjhv / private.php
Created November 7, 2016 23:30
Get private variable of object in PHP 5.3+
<?php
/**
* Get a private variable from any object.
*
* @param mixed $obj
* @param string $name
* @return mixed
*/
function get_private_var($obj, $name) {

XSD TO JAVA

Simple proof of concept for converting XSD schemas into pure Java classes at runtime and by using reflection. It can be improved to, for example, build intelligent JAX-RS console or GUI clients without knowledge of the domain model, by querying application.wadl and looking for the schema. The classes are transpiled, compiled and appended to the path at runtime so they are always updated. Other things missing is fetching the schema from network instead of a file, not depending on JXC and Javax Tools, building a schema and creating an automatic CLI client for it, between other tree of possibilities.

#--
# MAIN MODULE -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#++
module Simplex
#--
# UTILITIES -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#++
module Util
@bryanjhv
bryanjhv / README.md
Created May 5, 2019 06:40
Script to copy apps between android devices.

Installation

cd
mkdir -p apks
wget https://gist.githubusercontent.com/bryanjhv/f5b19a3622b8f1a2f9bcb31c315c3014/raw/copy.sh -O apks/copy
chmod +x apks/copy

Usage

@bryanjhv
bryanjhv / pifind.sh
Created May 16, 2019 06:28
Pure bash RPi IP address finder
#!/usr/bin/bash
ifaces=($(ip link | grep '^[0-9]' | cut -d: -f2 | sed '1d;s/ //'))
iface=${ifaces[0]}
if [ $# -gt 0 ]; then
found=0
for i in ${ifaces[@]}; do
if [ $1 == $i ]; then
found=1
break
@bryanjhv
bryanjhv / WenzVPNDecrypt.java
Last active July 6, 2019 04:12
Decrypt locked configuration from Wenz VPN for Android.
import java.util.Map;
import java.util.HashMap;
import java.util.Base64;
import java.util.Map.Entry;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.SecretKeyFactory;
@bryanjhv
bryanjhv / README.md
Created August 6, 2019 07:36 — forked from franciscocpg/README.md
Import mitm certificate to CA in arch linux
  1. After installing mitmproxy run it (just type mitmproxy) in a terminal session and quit. This will create the necessaries certificates files at ~/.mitmproxy.

  2. Extract the certificate to .crt format:
    openssl x509 -in ~/.mitmproxy/mitmproxy-ca.pem -inform PEM -out ca.crt

  3. Trust the certificate into CA:
    sudo trust anchor ca.crt

  4. Run the mitmproxy again

@bryanjhv
bryanjhv / micronucleus-for-android-arm.sh
Last active August 8, 2019 08:36
Compile micronucleus uploader for Android armv7
set -x
mkdir -p src usr
# Set variables
export PREFIX=$PWD/usr
export HOST_TAG=linux-x86_64
export NDK=$HOME/Android/Sdk/ndk-bundle
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/$HOST_TAG
export AR=$TOOLCHAIN/bin/arm-linux-androideabi-ar
export AS=$TOOLCHAIN/bin/arm-linux-androideabi-as
@bryanjhv
bryanjhv / ssd1306.py
Last active August 20, 2019 03:45
Simplified Adafruit Python SSD1306 for Raspberry Pi 3B+ (I2C only)
from __future__ import division
from smbus import SMBus
SSD1306_ADDRESS = 0x3C
SSD1306_MEMORYMODE = 0x20
SSD1306_COLUMNADDR = 0x21
SSD1306_PAGEADDR = 0x22
SSD1306_SETCONTRAST = 0x81
@bryanjhv
bryanjhv / vsceext.bash
Created August 25, 2019 08:10
Bash script for downloading VSCode extensions faster
#!/usr/bin/env bash
if [[ $# -lt 2 ]]; then
echo "ERR: Missing arguments."
# requires an SSH server
# arg1: {package}.{extension}@{version}
# arg2 {host}
exit 1
fi