This file contains hidden or 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
// ⚠ IMPORTANT: this is old and doesn't work for many different edge cases but I'll keep it as-is for any of you want it | |
// ⚠ IMPORTANT: you can find more robust versions in the comments or use a library implementation such as lodash's `merge` | |
// Merge a `source` object to a `target` recursively | |
const merge = (target, source) => { | |
// Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties | |
for (const key of Object.keys(source)) { | |
if (source[key] instanceof Object) Object.assign(source[key], merge(target[key], source[key])) | |
} |
This file contains hidden or 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
-- Remove the history from | |
rm -rf .git | |
-- recreate the repos from the current content only | |
git init | |
git add . | |
git commit -m "Initial commit" | |
-- push to the github remote repos ensuring you overwrite history | |
git remote add origin [email protected]:<YOUR ACCOUNT>/<YOUR REPOS>.git |
This file contains hidden or 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
{ | |
"workbench.iconTheme": "material-icon-theme", | |
"editor.fontSize": 18, | |
"workbench.startupEditor": "newUntitledFile", | |
"editor.wordSeparators": "`~!@#%^&*()=+[{]}\\|;:'\",.<>/?", | |
"explorer.confirmDragAndDrop": false, | |
"editor.tabSize": 2, | |
"emmet.syntaxProfiles": { | |
"javascript": "js" | |
}, |
This file contains hidden or 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
////////////////////////////////////////////////// Basic template | |
// PageFly ATC Helpers - Do not delete | |
try { | |
window.addEventListener('load', function() { | |
window.__pagefly_helper_store__ && window.__pagefly_helper_store__.subscribe(function(res) { | |
// Handle update cart here | |
}); | |
}); | |
} catch(e) { console.error("PF Error:: ", e) } |
This file contains hidden or 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
const toPlainEnglish = str => { | |
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a") | |
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e") | |
str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i") | |
str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, "o") | |
str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, "u") | |
str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, "y") | |
str = str.replace(/đ/g, "d") | |
str = str.replace(/À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ/g, "A") | |
str = str.replace(/È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ/g, "E") |
This file contains hidden or 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
numbers = [2018, 1, 5, 0, -10, 20, 15, -7] | |
sorted_numbers = [] | |
sorting = True | |
while sorting: | |
min_numb = min(numbers) | |
sorted_numbers.append(min_numb) | |
numbers.remove(min_numb) |
This file contains hidden or 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
low = 1 | |
high = 100 | |
playing = True | |
print('Guess your number game') | |
input('Now think of a number from 1 to 100, then press Enter') | |
print(""" | |
All you have to do is answer to my guess | |
'c' if my guess is correct |
This file contains hidden or 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
map = { | |
'size_x' : 5, | |
'size_y' : 5 | |
} | |
player = { | |
"x" : 3, | |
"y" : 4 | |
} |
This file contains hidden or 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
import mongoengine | |
#mongodb://<dbuser>:<dbpassword>@ds249798.mlab.com:49798/muadongkhonglanh | |
host = "ds249798.mlab.com" | |
port = 49798 | |
db_name = "muadongkhonglanh" | |
user_name = "admin" | |
password = "admin" |