Skip to content

Instantly share code, notes, and snippets.

View oclockvn's full-sized avatar

Quang Phan oclockvn

View GitHub Profile
// See https://aka.ms/new-console-template for more information
using System.Text.Json;
using System.Text.Json.Serialization;
namespace ConsoleApp2;
public class Program
{
static List<Product> products = null;
static void Main(string[] args)
// See https://aka.ms/new-console-template for more information
using System.Text.Json;
using System.Text.Json.Serialization;
namespace ConsoleApp2;
public class Program
{
static void Main(string[] args)
{
@oclockvn
oclockvn / vietnam_bank_list.json
Last active August 27, 2023 05:56
Vietnam bank list
[
{
"name": "Ngân hàng Chính sách xã hội",
"nameEn": "Vietnam Bank for Social Policies",
"code": "NHCSXH/VBSP"
},
{
"name": "Ngân hàng Phát triển Việt Nam",
"nameEn": "Vietnam Development Bank",
"code": "VDB"
@oclockvn
oclockvn / mimetype.cs
Last active September 10, 2020 07:59
Get mime type from image url
//
// detect mime type based on hex code of the bytes
// https://en.wikipedia.org/wiki/List_of_file_signatures
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
//
public static string GetImageMimeType(byte[] bytes)
{
var code = BitConverter.ToString(bytes);
if (code.StartsWith("89-50-4E-47-0D-0A-1A-0A"))
@oclockvn
oclockvn / ruler.js
Created September 1, 2020 09:07
Tips for checking element size
function dragElement(elmnt) {
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
if (document.getElementById(elmnt.id + "header")) {
// if present, the header is where you move the DIV from:
document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown;
} else {
// otherwise, move the DIV from anywhere inside the DIV:
elmnt.onmousedown = dragMouseDown;
}
@oclockvn
oclockvn / angularjs_scope_inspector.js
Created August 26, 2020 00:02
Angularjs Scope Inspector
javascript: (function() {
var selector = prompt('Enter selector: ');
if (!selector) return;
var element = angular.element(selector);
var scope = element.scope();
var controller = element.controller();
if (!!scope.$root && !!scope.$root.$$childTail) scope = scope.$root.$$childTail;
console.log(scope);
console.log(controller);
console.log("Try window.scope and window.controller");
@oclockvn
oclockvn / mongodb_playground.md
Last active August 13, 2020 09:56
Mongodb playground

Query

Find:

db.students.find({ email: "oclockvn@gmail.com" }) // ==> []
db.students.findOne({ studentId: 1 }) // ==> {}
var yesterdayProducts = Products.Where(x => x.CreatedAt == DateTime.Now.AddDays(-1));
foreach (var p in yesterdayProducts)
{
p.Title = p.Title.RemoveMark();
p.UpdatedAt = DateTime.Now;
}
SubmitChanges();
# Insert
var p1 = new Product { /*...*/ };
Products.InsertOnSubmit(p);
SubmitChanges();
# Update
var p2 = Product.First(x => x.Id == 10);
p.Name = "From linqpad";
SubmitChanges();
@oclockvn
oclockvn / emulator-install-using-avdmanager.md
Created April 11, 2020 11:32 — forked from mrk-han/emulator-install-using-avdmanager.md
Installing and creating Emulators with AVDMANAGER (For Continuous Integration Server or Local Use)

Install and Create Emulators using AVDMANAGER and SDKMANAGER

TL;DR

For generic skin emulator with default apis (without google apis):

  1. List All System Images Available for Download: sdkmanager --list | grep system-images

  2. Download Image: sdkmanager --install "system-images;android-29;default;x86"