Skip to content

Instantly share code, notes, and snippets.

View ThinhPhan's full-sized avatar
🎯
Focusing

Thinh Phan ThinhPhan

🎯
Focusing
View GitHub Profile
@ThinhPhan
ThinhPhan / mobile_attendance.py
Created March 19, 2024 08:12
Odoo Snippet Code
import json
from odoo import models, fields, api
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
from datetime import datetime
class mobile_attendance(models.Model):
_name = 'mobile_attendance.mobile_attendance'
def _default_employee(self):
return self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
@ThinhPhan
ThinhPhan / extract_urls.js
Created March 8, 2024 03:56
Extract all URLs from a webpage
// How to use
// Paste this script into Developer Console to run it
// Ref: https://www.datablist.com/learn/scraping/extract-urls-from-webpage
const results = [
['Url', 'Anchor Text', 'External']
];
var urls = document.getElementsByTagName('a');
for (urlIndex in urls) {
const url = urls[urlIndex]
@ThinhPhan
ThinhPhan / ssh_keys.md
Created August 4, 2023 04:35
SSH Keys Cheatsheet Commands

Cheatsheet Commands for SSH Keys

Create

Checking

For checking the SSH keys are adding and working properly.

  • eval "$(ssh-agent -s)" - Check if SSH Agent is running
  • ssh-add ~/.ssh/private_keys - Add the Keys to SSH Agent (can add multiple keys at once)
@ThinhPhan
ThinhPhan / ssh-remote-server-passless.md
Last active February 28, 2023 08:10
Copy SSH Key to Remote Server

SSH to Remote Server without input password

Add your SSH key into the server, then next time you don't have to input password when ssh

  • Option 1 cat-ing the file to authorized_keys:

cat id_rsa.pub | ssh username@hostname ' cat >>.ssh/authorized_keys'

  • Option 2
@ThinhPhan
ThinhPhan / cheatsheet-permissions.md
Created February 9, 2023 09:51
Permissions on Linux
Number Octal Permission Representation Ref
0 No permission ---
1 Execute permission --x
2 Write permission -w-
3 Execute and write permission: 1 (execute) + 2 (write) = 3 -wx
4 Read permission r--
5 Read and execute permission: 4 (read) + 1 (execute) = 5 r-x
6 Read and write permission: 4 (read) + 2 (write) = 6 rw-
7 All permissions: 4 (read) + 2 (write) + 1 (execute) = 7 rwx
@ThinhPhan
ThinhPhan / isValid.md
Created September 29, 2022 02:17
Moment

Check date is valid

moment/moment#1639

moment(undefined).isValid() return true?

moment(someString || null).isValid()

@ThinhPhan
ThinhPhan / css-util
Last active September 7, 2022 18:44
Css Util
# Utility CSS
```css
// Create a vertical line center
.vertical-line {
background: linear-gradient(#000, #000) no-repeat center/2px 100%;
}
```
`background: linear-gradient(#000, #000) no-repeat center/2px 100%;`
@ThinhPhan
ThinhPhan / ssh-setup.sh
Last active October 29, 2019 07:52
This utility creates an SSH key, copies the public key to the Raspberry Pi, and updates the OpenSSH config file.
#!/bin/bash
echo
echo 'Purpose: This utility creates an SSH key, copies the public key to the Raspberry Pi, and updates the OpenSSH config file.'
echo 'Platform: Linux and macOS'
echo 'Version: 1.0, September 2019'
echo 'Author: Dave Glover, http://github.com/gloveboxes'
echo 'Licemce: MIT. Free to use, modify, no liability accepted'
echo
echo
@ThinhPhan
ThinhPhan / javascript-datetime-format.md
Created October 4, 2019 09:20
Javascript code snippets - Date Time Format to String

As toISOString() will only return current UTC time , not local time. We have to make a date by using .toString() function to get date in yyyy-MM-dd format like

let now = new Date(new Date().toString().split('GMT')[0]+' UTC').toISOString().split('T')[0];
// 2019-10-04

To get date and time into in yyyy-MM-ddTHH:mm:ss format