Skip to content

Instantly share code, notes, and snippets.

View weird-coon's full-sized avatar
🦝
Surprise!

Quyen Luu weird-coon

🦝
Surprise!
View GitHub Profile
@weird-coon
weird-coon / Count lines in Git repo
Created August 9, 2022 02:47 — forked from mandiwise/Count lines in Git repo
A command to calculate lines of code in all tracked files in a Git repo
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository
$ git ls-files | xargs wc -l
@weird-coon
weird-coon / validation_date.js
Created October 9, 2020 09:58
Date is valid with Javascript
/**
* Get the number of days in any particular month
* @link https://stackoverflow.com/a/1433119/1293256
* @param {integer} m The month (valid: 0-11)
* @param {integer} y The year
* @return {integer} The number of days in the month
*/
var daysInMonth = function (m, y) {
switch (m) {
case 1 :
@weird-coon
weird-coon / intersectionObserverAPI.js
Created September 29, 2020 09:50
add animate class when element in viewport
animateClass() {
const scroll = window.requestAnimationFrame || function(callback) { window.setTimeout(callback, 1000 / 60) }
const elementsToShow = document.querySelectorAll('.animate')
const _self = this
Array.prototype.forEach.call(elementsToShow, function(element) {
if (_self.isElementInViewport(element)) {
element.classList.add('is-visible')
}
})
@weird-coon
weird-coon / iphone_media_query.md
Last active October 19, 2021 01:25
CSS media query iPhone breakpoint

iPhone 11

/* 1792x828px at 326ppi */
@media only screen 
    and (device-width: 414px) 
    and (device-height: 896px) 
    and (-webkit-device-pixel-ratio: 2) { }

This media query is also for: iPhone XR

@weird-coon
weird-coon / singleElement.js
Created June 26, 2020 03:06
Get single Element
getSpSingleItems(petState: TextValue[]): string[] {
const filterState: TextValue[] = [...petState].reverse()
let i: number = filterState.length
while (i--) {
if (i - 1 >= 0) { // remove element if 2 continue is normal item
if (!filterState[i].longText && !filterState[i - 1].longText) {
filterState.splice(i, 1)
filterState.splice(i - 1, 1)
i = i - 1
@weird-coon
weird-coon / auto_increase.sql
Created June 19, 2020 03:51
Generate auto increment field in select query
SELECT @n := @n + 1 n,
first_name,
last_name
FROM table1, (SELECT @n := 0) m
ORDER BY user_id
@weird-coon
weird-coon / Procedure_vs_Function.md
Last active November 18, 2019 02:13
Different between the Procedure and Function / Sự khác nhau giữa procedure và function trong SQL
_. Procedure _. Function
Được sử dụng chủ yếu để thực hiện quy trình nhất định Được sử dụng chủ yếu để thực hiện một số tính toán
Không thể gọi trong câu lệnh SELECT Có thể được gọi là trong câu lệnh SELECT (không chứa DML)
Sử dụng tham số OUT để trả về giá trị Sử dụng RETURN để trả về giá trị
Không bắt buộc trả về giá trị Bắt buộc trả về giá trị
RETURN chỉ đơn giản là sẽ thoát khỏi sự kiểm soát từ chương trình con. RETURN sẽ thoát khỏi sự kiểm soát từ chương trình con và cũng trả về giá trị
datatype trở lại sẽ không được quy định tại thời điểm tạo ra datatype là bắt buộc tại thời điểm tạo ra
// Classification is adopted eight regional division
var regions = [
{id:1, name:"北海道", kana:"ホッカイドウ", en:"hokkaido", neighbor:[2]},
{id:2, name:"東北", kana:"トウホク", en:"tohoku", neighbor:[1]},
{id:3, name:"関東", kana:"カントウ", en:"kanto", neighbor:[2, 4]},
{id:4, name:"中部", kana:"チュウブ", en:"chubu", neighbor:[2, 3, 5]},
{id:5, name:"近畿", kana:"キンキ", en:"kinki", neighbor:[4, 6, 7]},
{id:6, name:"中国", kana:"チュウゴク", en:"chugoku", neighbor:[5, 7, 8]},
{id:7, name:"四国", kana:"シコク", en:"shikoku", neighbor:[5, 6, 8]},
{id:8, name:"九州", kana:"キュウシュウ", en:"kyusyu", neighbor:[6, 7]}
@weird-coon
weird-coon / pref.py
Created February 21, 2019 02:29
Python JP prefecture
pref = {
1: '北海道',
2: '青森県',
3: '岩手県',
4: '宮城県',
5: '秋田県',
6: '山形県',
7: '福島県',
8: '茨城県',
9: '栃木県',