Skip to content

Instantly share code, notes, and snippets.

View patrickfav's full-sized avatar
🐿️
Nam nam nam

Patrick Favre patrickfav

🐿️
Nam nam nam
View GitHub Profile
@patrickfav
patrickfav / MultipleOrientationSlidingDrawer.java
Created August 20, 2013 16:56
My solution for a Sliding Drawer that can come from Top: I extracted SlidingTray from this lib http://aniqroid.sileria.com/doc/api/ (by Ahmed Shakil) and refactored it a bit since it had some quirks needed to be used within this lib. It consists of 1 class and you have to add atts in your attrs.xml. Other than that it has pretty much the same us…
package your.app;
/*
* Copyright (c) 2001 - 2012 Sileria, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@patrickfav
patrickfav / sigma-js-angular-app.js
Last active February 25, 2023 13:12
Simple Sigma.js AngularJs Directive: Since I did not find any angularjs directive for angularjs I created a little simple of my own. This is by no means a ready-for-all solutions, but all the features I needed at the time; it is easily extended to your needs and maybe sometimes somebody will do a full-blown directive for sigma.js Tested: angular…
/*
* Copyright 2017 Patrick Favre-Bulle
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@patrickfav
patrickfav / convert_cmyk.bat
Last active August 29, 2015 14:16
Windows Batch Imagemagick png to pdf wrapped cmyk-jpeg: pass path as paramter like so: .\convert_cmyk.bat C:\my-path-to-pngs\
@echo off
echo This script converts png files to cmyk colorspaced jpgs wrapped in pdf for latex
echo Start converting...
echo.
for %%f in (%~1*) do if /i %%~xf==.png (
echo Converting %%f to cmyk jpeg compressed %%~nf.pdf
convert %%f +profile "*" -profile "path/to/rgb.icc" -profile "path/to/cmyk.icc" -strip -sampling-factor 1x1 -quality 95 -compress JPEG %%~pf\%%~nf.pdf
)
@patrickfav
patrickfav / ImageUtil.java
Last active October 3, 2017 20:11
StackOverflow Question 36029295
/*
* Copyright 2017 Patrick Favre-Bulle
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2017 Patrick Favre-Bulle
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@patrickfav
patrickfav / KeyStoreHelper.java
Created September 21, 2016 10:24 — forked from alphamu/KeyStoreHelper.java
Using Android KeyStore to generate a password. The code create a public/private key pair and uses the base64 encoded form of the certificate to as the password. The code modified the KeystoreHelper class from AOSP demo projects.
/*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@patrickfav
patrickfav / AndroidManifest.xml
Created January 30, 2017 21:17
Example for how to reproduce the restart bug in Seismic
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.company.seismicbug"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
@patrickfav
patrickfav / gist:d3ea9bfcb1669389f0bb52240bace1f3
Created March 3, 2017 22:50
Read out all Security Provider
MessageDigest digest = null;
try {
digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest("hallo".getBytes(Charset.forName("UTF-8")));
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
Provider[] providers = Security.getProviders();
for (Provider provider : providers) {
@patrickfav
patrickfav / RandomOrgUtil.java
Last active August 18, 2020 17:44
Random.org Signed Response Verification (Java)
/*
Copyright 2017 Patrick Favre-Bulle
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software