Skip to content

Instantly share code, notes, and snippets.

View daubac402's full-sized avatar
🇻🇳
🎄

NguyenTheAnh daubac402

🇻🇳
🎄
View GitHub Profile
@meeDamian
meeDamian / shorten.php
Created December 20, 2011 08:39
[ PHP | api | google ] goo.gl link shortenter
<?
// add it to config file:
$google_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
// add this to libs file:
function shorten($url) {
$gurl = "https://www.googleapis.com/urlshortener/v1/url?key=" . $GLOBALS['google_key'];
$url = json_encode(array("longUrl" => $url));
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@niksumeiko
niksumeiko / git.migrate
Last active July 1, 2025 18:41
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@daubac402
daubac402 / Numpad_plus_TOGGLE_w_button.ahk
Last active October 17, 2023 08:49
Toggle Auto holding W key (accelerator key) for GTA Online (turn on/off by Numpad Add key) (require: AutoHotkey)
timer_cb:
{
SetKeyDelay, -1
if (toggle_flag) {
Send, {Blind}{w DownTemp}
} else {
SetTimer, timer_cb, OFF
Send, {Blind}{w UP}
}
}
@daubac402
daubac402 / self-signed-certificate-with-custom-ca.md
Last active April 7, 2021 05:45 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

1. Create Root CA (Done once)

1.1. Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@daubac402
daubac402 / minification.md
Created April 9, 2021 08:42 — forked from gaearon/minification.md
How to Set Up Minification

In production, it is recommended to minify any JavaScript code that is included with your application. Minification can help your website load several times faster, especially as the size of your JavaScript source code grows.

Here's one way to set it up:

  1. Install Node.js
  2. Run npm init -y in your project folder (don't skip this step!)
  3. Run npm install terser

Now, to minify a file called like_button.js, run in the terminal:

@daubac402
daubac402 / [Vietnamese] 0.1 + 0.2 == 0.3 return FALSE.md
Last active August 28, 2025 00:23
[Vietnamese] 0.1 + 0.2 == 0.3 return FALSE?

Tại sao 0.1 + 0.2 không bằng 0.3?

Ngắn gọn

Vấn đề này liên quan đến cách mà máy tính lưu trữ và xử lý số thực (floating-point numbers). Trong nhiều ngôn ngữ lập trình, số thực được lưu trữ theo chuẩn IEEE 754, và không phải tất cả các số thực đều có thể được biểu diễn chính xác trong hệ nhị phân. Do đó, khi thực hiện các phép toán như 0.1 + 0.2, kết quả có thể không chính xác như mong đợi.

Khi nào thì một số thực không được biểu diễn chính xác?

Một số chỉ có thể biểu diễn chính xác trong IEEE-754 nếu và chỉ nếu nó có thể viết dưới dạng: x = k / (2^n) với k và n là số nguyên. Nói cách khác, mẫu số của số đó chỉ có thể chứa các thừa số nguyên tố 2 (không có 3, 5, 7, ...).