Skip to content

Instantly share code, notes, and snippets.

View oclockvn's full-sized avatar

Quang Phan oclockvn

View GitHub Profile
@oclockvn
oclockvn / dictionary.js
Created January 25, 2018 20:54
find a word contains letter
var source = ["the",
"of",
"and",
"to",
"a",
"in",
"for",
"is",
"on",
"that",
// 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 / How to upload file using dropzone js.md
Last active October 6, 2023 06:20
How to upload file using dropzone js

http://www.dropzonejs.com/

Template

<div class="col-md-6">
    <div class="drop flex flex-column">
        <div class="text-center p text-muted drop-guide">
            <span>Click to browser files or drag 'n drop files here (1MB/file)</span>
        </div>
@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 / ffmpeg-command.js
Last active July 25, 2023 01:09
Bookmarklet to download ffmpeg
(function() {
const link = window.prompt(`Enter the link`);
if (!link) {
return;
}
const parts = link.split(' ');
prompt('Result:', `ffmpeg -i ${parts[1]} -map p:2? -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 "E${parts[0]}.mp4"`);
})();
@oclockvn
oclockvn / ubuntu-service.md
Created August 4, 2019 11:14
ubuntu service

Ubuntu service

  1. list all services
service --status-all
  1. to start a service
@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");