Skip to content

Instantly share code, notes, and snippets.

View caisback's full-sized avatar

caisback

View GitHub Profile
@caisback
caisback / Simple File Writing.cs
Created May 9, 2022 23:47
c# - Simple file writing
async Task fileWriteLineAsync(string lineToWrite, string fileWhereToWrite)
{
// Always new file:
// using StreamWriter file = new(fileWhereToWrite);
// Create new file or Append if exists:
using StreamWriter file = new(fileWhereToWrite, append: true);
await file.WriteLineAsync(lineToWrite);
}
@caisback
caisback / ListToArray.cs
Last active May 9, 2022 23:35
c# - You can not add new item to an array, used List() instead with ToArray()
// You can't add items to an array, since it has fixed length.
// What you're looking for is a List<string>, which can later be turned to an array using list.ToArray()
List<string> list = new List<string>();
list.Add("Add New Item Hear");
String[] str = list.ToArray();
// Alternatively, you can resize the array.
@caisback
caisback / ForeachIf_to_LINQ.cs
Last active May 7, 2022 22:37
C# - Array filtering from Old School (foreach and if) to New School (LINQ)
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
//ShowListOfList_01();
/*
tvg-country="US"
tvg-country="UK" tvg-language="English"
tvg-country="CA" tvg-language="English"
@caisback
caisback / C# - Calling API with Deserialize to Class.cs
Created April 28, 2022 22:43
C# - Calling API with Deserialize to Class
// var cultureInfo = new CultureInfo("en-US");
// // cultureInfo.NumberFormat.CurrencySymbol = "P";
// CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
// CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
const string REST_API = "https://api.domain.com/v1/markets";
//List<Market> markets;
// import_json_appsscript.js
// https://gist.github.com/allenyllee/c764c86ed722417948fc256b7a5077c4
//
// Changelog:
// (Oct. 16 2019) tag: allenyllee-20191016
// 1. Fixed google script error: urlfetchapp - service invoked too many times https://stackoverflow.com/questions/10598179/google-apps-script-urlfetchapp-service-invoked-too-many-times
// (Jul. 16 2018) tag: allenyllee-20180716
// 1. Fixed the issue "If you try to query /arrayA[k]/arrayB[n]/arrayC[m]/.../member, you will always get /arrayA[k]/arrayB[k]/arrayC[k]/.../member."
// (Nov. 30 2017) tag: allenyllee-20171130
// 1. Add the ability to query array elements by using xpath like "/array[n]/member" where "n" is array index
@caisback
caisback / ca's git cheatsheet.md
Last active July 11, 2021 21:29
ca's git cheatsheet

git create branch and checkout one command

$ git checkout -b 20200712-NavBar

git get the current branch name

git branch --show-current
@caisback
caisback / Apache Camel Accessing 3rd Party API (https). md
Created July 6, 2021 12:37
Apache Camel Accessing 3rd Party API (https).
AHC / camel-ahc
HTTP4 / camel-http4
@caisback
caisback / Trimming the json response data.md
Created June 29, 2021 07:56
Trimming the json response data, get only what you need
@caisback
caisback / Flutter - How to install on Ubuntu 21_04.md
Created June 22, 2021 22:02
Flutter - How to install on Ubuntu 21.04
  • $ sudo snap install flutter --classic
flutter 0+git.e75662a from Flutter Team✓ installed
  • $ flutter sdk-path
Initializing Flutter
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  136k  100  136k    0     0   123k      0  0:00:01  0:00:01 --:--:--  123k