Skip to content

Instantly share code, notes, and snippets.

View trinnguyen's full-sized avatar

Tri Nguyen trinnguyen

View GitHub Profile
@trinnguyen
trinnguyen / FileCrypto.cs
Last active September 20, 2020 11:39
File encryption with Tink iOS
using System;
using System.Diagnostics;
using Foundation;
using Tink;
namespace TnnCrypto
{
public class FileCrypto
{
private readonly ITINKAead _aead;
@trinnguyen
trinnguyen / DefaultKeychain.cs
Created September 13, 2020 16:40
Simple wrapper for iOS Keychain usage for key-value
using Foundation;
using Security;
namespace TnnCrypto
{
public class DefaultKeychain
{
static DefaultKeychain()
{
string id = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleIdentifier")?.ToString() ?? "";
@trinnguyen
trinnguyen / AesGcmAead.cs
Created September 13, 2020 16:37
C# Encrypt/Decrypt with BouncyCastle
using System;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Modes;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Security;
namespace TnnCrypto
{
public class AesGcmAead
{
@trinnguyen
trinnguyen / msbuild_xamarin_android.md
Created September 14, 2019 09:04
MSBuild targets for Xamarin.Android

Xamarin.Android msbuild tasks

msbuild /t:Clean
msbuild /t:Build
msbuild /t:Rebuild
msbuild /t:Install
msbuild /t:UpdateAndroidResources
@trinnguyen
trinnguyen / resize.sh
Created September 7, 2019 14:56
Bash script to resize ios icons for cordova project (personal usage)
#!/usr/bin/env bash
# usage: sh resize.sh [PATH_TO_ICON_FOLDER]
export MAGICK_HOME="$HOME/opt/ImageMagick-7.0.8"
export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib/"
src=$1
originfilepath="${src}/180x180.png"
sizes=('20' '29' '40' '50' '57' '60' '58' '80' '72' '76' '87' '100' '114' '120' '144' '152' '167' '180' '1024')
if test -f ${originfilepath}; then
for s in ${sizes[@]}; do
@trinnguyen
trinnguyen / gist:b37daa22bef2b3293fcbe08b0d4b22c6
Created April 6, 2019 10:00
Commands sequence to fix Foxit Reader in Fedora 29
cd ~/opt/foxitsoftware/foxitreader
rm lib/libssl.so.10
rm lib/libcrypto.so.10
ln -s /lib64/libssl.so.10 lib/libssl.so.10
ln -s /lib64/libcrypto.so.10 lib/libcrypto.so.10
@trinnguyen
trinnguyen / keyboard_helper_activity.cs
Last active March 15, 2019 12:58
Simply approach to detech keyboard visibility changed on Xamarin.Android, based on blog of PDFKit (https://pspdfkit.com/blog/2016/keyboard-handling-on-android/#)
private void AddKeyboardVisibilityHandler()
{
var decorView = Window.DecorView;
decorView.ViewTreeObserver.GlobalLayout += OnViewTreeObserverGlobalLayoutChange;
}
private void RemoveKeyboardVisibilityHandler()
{
var decorView = Window.DecorView;
decorView.ViewTreeObserver.GlobalLayout -= OnViewTreeObserverGlobalLayoutChange;
@trinnguyen
trinnguyen / IosHelpers.cs
Created July 15, 2018 09:00
Xamarin ios check wether a ViewController is presented as Modal. Support NavigationController (not TabBar)
public static bool CheckIsModalVC(UIViewController viewController)
{
// find root
var vc = viewController;
while (vc.NavigationController != null)
{
vc = vc.NavigationController;
}
// check cur
@trinnguyen
trinnguyen / xamarin tools
Last active December 8, 2017 04:17
Path of Frameworks in macOS (Mono.framework, Xamarin.* frameworks
Framework path: /Library/Frameworks
VSTool Commandline tool of VS4Mac: /Applications/Visual Studio.app/Contents/MacOS/vstool
Available tools:
- build: Project build tool
- dbgen: Parser database generation tool
- project-export: Project conversion tool
- gsetup: Graphical extension setup utility
- archive: Project archiving tool
- account: Xamarin account tool
@trinnguyen
trinnguyen / styles.xml
Last active March 18, 2020 14:56
Android style for Splash screen with status bar and navigation bar are transparent, API 21+
<style name="AppTheme.Splash">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>