Skip to content

Instantly share code, notes, and snippets.

View tientq64's full-sized avatar
🧋
Chill with code

Tran Quang Tien tientq64

🧋
Chill with code
View GitHub Profile
@tanaikech
tanaikech / submit.md
Last active January 5, 2025 06:09
Simple Script of Resumable Upload with Google Drive API for Node.js

Simple Script of Resumable Upload with Google Drive API for Node.js

This is a simple sample script for achieving the resumable upload to Google Drive using Node.js. In order to achieve the resumable upload, at first, it is required to retrieve the location, which is the endpoint of upload. The location is included in the response headers. After the location was retrieved, the file can be uploaded to the location URL.

In this sample, a PNG file is uploaded with the resumable upload using a single chunk.

Sample script

Before you use this, please set the variables.

@mdciotti
mdciotti / encodeURIComplete.js
Last active August 1, 2022 03:26
Completely encode all characters of a string into a URL escape sequence.
// NOTE: This is overkill. I wrote this and then quickly realized there is a better way to do it. See below.
/**
* https://tc39.es/ecma262/#leading-surrogate
* @param {number} codeUnit
*/
function isLeadingSurrogate(codeUnit) {
return 0xD800 <= codeUnit && codeUnit <=0xDBFF;
}
@JerryLokjianming
JerryLokjianming / Crack Sublime Text Windows and Linux.md
Last active August 27, 2025 13:21
Crack Sublime Text 3.2.2 Build 3211 and Sublime Text 4 Alpha 4098 with Hex

How to Crack Sublime Text 3.2.2 Build 3211 with Hex Editor (Windows | Without License) ↓

  1. Download & Install Sublime Text 3.2.2 Build 3211
  2. Visit https://hexed.it/
  3. Open file select sublime_text.exe
  4. Offset 0x8545: Original 84 -> 85
  5. Offset 0x08FF19: Original 75 -> EB
  6. Offset 0x1932C7: Original 75 -> 74 (remove UNREGISTERED in title bar, so no need to use a license)
@FujiHaruka
FujiHaruka / latest_commit_hash_of_file.graphql
Created May 11, 2019 10:57
GraphQL query to get latest commit hash of a file
{
repository(name: "TypeScript", owner: "Microsoft") {
ref(qualifiedName: "master") {
target {
... on Commit {
history(first: 1, path: "tslint.json") {
edges {
node {
oid
}
@maksymx
maksymx / PASCAL.sublime-build
Last active August 8, 2023 14:21
Sublime Text build system for Pascal project
{
"cmd": ["fpcbuild.bat", "$file"], "quiet": true
}
@tonY1883
tonY1883 / ValidateYoutubeVideoId.js
Created September 14, 2017 02:18
A small trick to check if youtube video exist with its id.
function validVideoId(id) {
var img = new Image();
img.src = "http://img.youtube.com/vi/" + id + "/mqdefault.jpg";
img.onload = function () {
checkThumbnail(this.width);
}
}
function checkThumbnail(width) {
//HACK a mq thumbnail has width of 320.
@alexpsi
alexpsi / asyncChunkedMap.js
Created February 25, 2017 20:31
Like Promise.all but executed in chunks, so you can have some async concurrency control.
const chunks = (arr, chunkSize) => {
let results = [];
while (arr.length) results.push(arr.splice(0, chunkSize));
return results;
};
module.exports = (xs, f, concurrency) => {
if (xs.length == 0) return Promise.resolve();
return Promise.all(chunks(xs, concurrency).reduce(
(acc, chunk) => acc.then(() => Promise.all(chunk.map(f))),
// Dependencies =========================
var
twit = require('twit'),
config = require('./config');
var Twitter = new twit(config);
// RETWEET BOT ==========================

Why I hate TypeScript

Warning: These views are highly oppinated and might have some slightly incorrect facts. My experience with typescript was about 2 weeks in Node and a week in angular2.

Not Standard

TypeScript is implementing their own take on JavaScript. Some of the things they are writing will likely never make it in an official ES* spec either.

Technologies that have competing spec / community driven development have a history of failing; take: Flash, SilverLight, CoffeeScript, the list goes on. If you have a large code base, picking TypeScript is something your going to be living with for a long time. I can take a bet in 3 years JavaScript will still be around without a doubt.

Its also worth noting that they have built some things like module system and as soon as the spec came out they ditched it and started using that. Have fun updating!