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 / 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)) {
@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 / 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 / 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 / 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 / firewall.sh
Last active February 15, 2018 09:51
Parefeu
#!/bin/sh
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin":$PATH
#echo $PATH
INPUT_PORTS="22,21,20,80,443,3306,8006"
FORWARD_PORTS="3306,80,443,8080"
cd /sbin/
echo "[IpTables] Reset..."
sleep 1
iptables -F
iptables -X
@williamdes
williamdes / README.md
Last active March 14, 2024 13:12
easy update your phpMyAdmin !

phpMyAdmin install/upgrade/reinstall (last released version)

Supports :

  • install
  • upgrade

Keeps your config !

TLDR / Short mode

Uses default arguments !

Keybase proof

I hereby claim:

  • I am williamdes on github.
  • I am williamdes (https://keybase.io/williamdes) on keybase.
  • I have a public key whose fingerprint is C4D9 1FDF CEF6 B4A3 C653 FD78 90A0 EF1B 8251 A889

To claim this, I am signing this object:

@williamdes
williamdes / import_branch_to_tag.sh
Created September 10, 2019 11:50
Import git branch as a tag from existing branch with same name
#!/bin/bash
# git: Having a branch/tag with the same name (error: dst refspec matches more than one.)
# run git branch --all and use a text editor to create a batch of commands
git tag -m "[imported from branch]" --force --sign "release/2019-09-10-1" $(git show-ref --hash "refs/remotes/origin/release/2019-09-10-1")
# https://markhneedham.com/blog/2013/06/13/git-having-a-branchtag-with-the-same-name-error-dst-refspec-matches-more-than-one/
# Delete ref from remote
git push origin :"refs/heads/release/2019-09-10-1"
@williamdes
williamdes / sirene_data_StockEtablissement_utf8.sql
Created September 16, 2019 21:30
SQL schema for StockEtablissement_utf8 in september-2019
-- Comments from: https://marmelab.com/blog/2017/01/09/sirene-import-sql.html
CREATE TABLE sirene_data (
`siren` INT(9) UNSIGNED NOT NULL COMMENT "Identifiant de l’entreprise",
`nic` SMALLINT(5) UNSIGNED NOT NULL COMMENT "Numéro interne de classement de l'établissement",
`siret` BIGINT(10) UNSIGNED NOT NULL PRIMARY KEY COMMENT "Identifiant de l’entreprise",
`statutDiffusionEtablissement` ENUM('O') NOT NULL COMMENT "Statut de diffusion de l’établissement",
`dateCreationEtablissement` VARCHAR(10) NOT NULL COMMENT "Date de création de l’entreprise",
`trancheEffectifsEtablissement` ENUM('NN', '00', '01', '02', '03', '11', '12', '21', '22', '31', '32', '41', '42', '51', '52', '53') NOT NULL COMMENT "Tranche d’effectif salarié de l’établissement",
`anneeEffectifsEtablissement` VARCHAR(4) NOT NULL COMMENT "Année de validité de la tranche d’effectif salarié de l’établissement",
`activitePrincipaleRegistreMetiersEtablissement` VARCHAR(6) NOT NULL COMMENT "Activité exercée par l’artisan