db.students.find({ email: "oclockvn@gmail.com" }) // ==> []
db.students.findOne({ studentId: 1 }) // ==> {}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Insert | |
var p1 = new Product { /*...*/ }; | |
Products.InsertOnSubmit(p); | |
SubmitChanges(); | |
# Update | |
var p2 = Product.First(x => x.Id == 10); | |
p.Name = "From linqpad"; | |
SubmitChanges(); |
NewerOlder