Skip to content

Instantly share code, notes, and snippets.

View williamdes's full-sized avatar
🚀
Catching up on GitHub notifications

William Desportes williamdes

🚀
Catching up on GitHub notifications
View GitHub Profile
@williamdes
williamdes / DOCKER_OPENVPN_IPTABLES.sh
Last active October 31, 2017 19:44
Docker & OPENVPN iptables rules
#!/bin/bash
#
# Docker OR OPENVPN rules
#
#Reset rules
iptables -F
iptables -X
iptables -t nat -F
@williamdes
williamdes / mysql_backup.sh
Last active April 7, 2018 11:25
Backup your MySQL/MariaDB server ( data, users, grants, views, triggers, routines, events )
# See : https://github.com/williamdes/sql-backup
@williamdes
williamdes / androidcertificate_fingerprint.java
Created June 27, 2017 13:24
Get a fingerprint (String SHA-256) from a android.content.pm.Signature Object
/**
* Get fingerprint from a certificate in android.content.pm.Signature
* @return String fingerprint that contains the SHA-256 digest
*/
private static String getFingerprint(android.content.pm.Signature ce){
String certificate = "";
InputStream input = new ByteArrayInputStream(ce.toByteArray());
CertificateFactory cf = null;
try {
@williamdes
williamdes / base64_encode_decode.cpp
Created June 20, 2017 16:40
c++ 11 encoding and decoding base64
//FROM
//https://stackoverflow.com/a/34571089/5155484
typedef unsigned char uchar;
static const std::string b = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";//=
static std::string base64_encode(const std::string &in) {
std::string out;
int val=0, valb=-6;
for (uchar c : in) {
@williamdes
williamdes / object_to-from_shared_preferences.java
Created May 24, 2017 21:41
Save and Restore an object from android sharedpreferences
private static ExampleObject getObject(Context c,String db_name){
SharedPreferences sharedPreferences = c.getSharedPreferences(db_name, Context.MODE_PRIVATE);
ExampleObject o = new ExampleObject();
Field[] fields = o.getClass().getFields();
try {
for (Field field : fields) {
Class<?> type = field.getType();
try {
final String name = field.getName();
if (type == Character.TYPE || type.equals(String.class)) {