Skip to content

Instantly share code, notes, and snippets.

View tuyen-vuduc's full-sized avatar
🎯
Focusing

Tuyen VU tuyen-vuduc

🎯
Focusing
View GitHub Profile
@tuyen-vuduc
tuyen-vuduc / csharp-namespace-helper.js
Created August 28, 2023 23:51
Convert C# filenamespace to legacy namespace
const fs = require("fs");
const path = require("path");
var folderPath = "./";
var files = fs.readdirSync(folderPath, { recursive: true })
.filter(x => x.endsWith('.cs'))
.map((fileName) => {
return path.join(folderPath, fileName);
})
@tuyen-vuduc
tuyen-vuduc / gist:ee3899143afcb06cbf57ef65f12ffecc
Created October 1, 2020 03:26
flutter-carapp-practice.dart
import 'package:flutter/material.dart';
class ShopScreen extends StatefulWidget {
@override
ShopScreenState createState() => ShopScreenState();
}
class ShopScreenState extends State<StatefulWidget> {
@override
Widget build(BuildContext context) {
@tuyen-vuduc
tuyen-vuduc / sample-usage.xaml
Last active August 10, 2018 00:34
Custom control with public command
<ContentPage x:name="page">
<ListView>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<CustomControl Command="{Binding BindingContext.ShowItemCommand, Source={Reference page}}" />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
@tuyen-vuduc
tuyen-vuduc / SharedPreferencesExtensions.kt
Created March 25, 2018 04:38
SharedPreferencesExtensions - Kotlin
import android.content.SharedPreferences
inline fun <reified T> SharedPreferences.get(key: String, defaultValue: T): T {
when(T::class) {
Boolean::class -> return this.getBoolean(key, defaultValue as Boolean) as T
Float::class -> return this.getFloat(key, defaultValue as Float) as T
Int::class -> return this.getInt(key, defaultValue as Int) as T
Long::class -> return this.getLong(key, defaultValue as Long) as T
String::class -> return this.getString(key, defaultValue as String) as T
else -> {
@tuyen-vuduc
tuyen-vuduc / example.nuget.config
Last active January 7, 2019 04:45
Project based nuget.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="this-project" value="nugets" />
<add key="syncfusion" value="http://nuget.syncfusion.com/nuget_xamarin/nuget/getsyncfusionpackages/xamarin" />
<add key="private-remote-nugets" value="http://my-private-server.com" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
@tuyen-vuduc
tuyen-vuduc / class-template.cs
Last active November 12, 2017 18:10
CSharp class template
public class ClassSample
{
pubic static readonly string StatidFieldA;
pubic static readonly string StatidFieldZ;
private static readonly string StatidFieldA;
private static readonly string StatidFieldZ;
public event EventHandler EventA;
public event EventHandler EventZ;
@tuyen-vuduc
tuyen-vuduc / bprop-create-bindable-property.cs
Created November 12, 2017 15:30
MVVM - C# Snippets (Visual Studio for Mac)
public static readonly BindableProperty $Name$Property = BindableProperty.Create(
nameof($Name$),
typeof($Type$),
typeof($Class$),
default($Type$),
BindingMode.$Mode$);
public $Type$ $Name$
{
get { return ($Type$)GetValue($Name$Property); }
set { SetValue($Name$Property, value); }
@tuyen-vuduc
tuyen-vuduc / HttpContentExtensions.cs
Created October 20, 2017 08:30
Parse JSON from HttpContent with JSON.NET
static class HttpContentExtensions
{
public static async Task<T> DeserializeJsonObjectAsync<T>(this HttpContent content)
{
using (var stream = await content.ReadAsStreamAsync())
{
using (var textReader = new StreamReader(stream))
{
using (var jsonReader = new JsonTextReader(textReader))
{
@tuyen-vuduc
tuyen-vuduc / Calabash-ios-scroll-to-top-or-bottom.rb
Last active November 7, 2019 15:32
UITests - iOS - ScrollToBottom
def scroll_to_edge(uiquery, direction)
allowed_directions = [:up, :down]
dir_symbol = direction.to_sym
unless allowed_directions.include?(dir_symbol)
raise ArgumentError, "Expected '#{direction} to be one of #{allowed_directions}"
end
lastYOffset = 99999999.0 * (dir_symbol == :up ? 1 : -1)
while true
@tuyen-vuduc
tuyen-vuduc / AppWithPopupEnabledNavigationService.cs
Created July 18, 2017 15:10
Prism with PopupPage integration
public partial class App : PrismApplication
{
public App(IPlatformInitializer initializer = null) : base(initializer)
{
}
protected override Prism.Navigation.INavigationService CreateNavigationService()
{
var applicationProvider = Container.Resolve<IApplicationProvider>();