Skip to content

Instantly share code, notes, and snippets.

View hmphu's full-sized avatar
🎯
Focusing

Hoang Manh Phu hmphu

🎯
Focusing
View GitHub Profile
@hmphu
hmphu / Free_Beyond_Compare.md
Created January 4, 2024 16:44 — forked from njleonzhang/Free_Beyond_Compare.md
Free Beyond Compare by unlimited trail

1 . goto beyond compare folder

 cd "/Applications/Beyond Compare.app/Contents/MacOS/"

2 . rename BCompare to BCompare.real

 mv BCompare BCompare.real
@hmphu
hmphu / how-to-restore.md
Created February 28, 2022 07:54 — forked from AmazingTurtle/how-to-restore.md
restore access to unifi controller

Restore access to a unifi controller

When you are unable to login to the unifi controller or forgot admin password, you can restore access using SSH and manipulating mongodb directly.

Warning

Do not uninstall unifi controller - most of the data is not stored in mongodb. In case you thought a mongodb backup would be sufficient, you may have fucked up already, just like me. However I managed to write this "tutorial" for anyone to not run into the same trap.

Steps

@hmphu
hmphu / elasticsearch.md
Created January 17, 2022 08:37 — forked from dominicsayers/elasticsearch.md
Configuring ElasticSearch to use less memory

What I actually did

/etc/security/limits.conf

elasticsearch hard memlock 100000

/etc/default/elasticsearch

@hmphu
hmphu / navicat_reset_trial.sh
Created December 14, 2021 09:33 — forked from tuxity/navicat_premium_reset_trial.sh
Reset Navicat Premium 15/16 remaining trial days
#!/bin/bash
set -e
file=$(defaults read /Applications/Navicat\ Premium.app/Contents/Info.plist)
regex="CFBundleShortVersionString = \"([^\.]+)"
[[ $file =~ $regex ]]
version=${BASH_REMATCH[1]}
/*
Before Septemper 15 2018, Vietnam has phone number start with 09*, 01(2|6|8|9).
After that, the phone number can start with 03, 05, 07 or 08.
So this function provide a way to validate the input number is a Vietnamese phone number
*/
function isVietnamesePhoneNumber(number) {
return /(03|05|07|08|09|01[2|6|8|9])+([0-9]{8})\b/.test(number);
}
DaxIamRole:
Type: AWS::IAM::Role
Properties:
RoleName: ${self:service.name}dax
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
Service:
@hmphu
hmphu / remove-slack-settings.sh
Created December 16, 2020 16:30 — forked from skoji/remove-slack-settings.sh
remove Slack settings (OS X)
rm -rf ~/Library/Application\ Support/Slack/
rm -rf ~/Library/Containers/com.tinyspeck.slackmacgap/
rm -rf ~/Library/Preferences/com.tinyspeck.slackmacgap.plist
rm -rf ~/Library/Saved\ Application\ State/com.tinyspeck.slackmacgap.savedState
rm ~/Library/Safari/LocalStorage/*slack*
@hmphu
hmphu / git aliases.sh
Created November 27, 2020 09:28 — forked from tj/git aliases.sh
Some helpful git aliases
alias gd="git diff"
alias gc="git clone"
alias ga="git add"
alias gbd="git branch -D"
alias gst="git status"
alias gca="git commit -a -m"
alias gpt="git push --tags"
alias gp="git push"
alias gpr="git pull-request"
alias grh="git reset --hard"
@hmphu
hmphu / README.md
Created October 15, 2020 16:29 — forked from plindberg/README.md
How to set up an AWS Lambda function for returning S3 pre-signed URLs for uploading files.

README

Granted, this is little more than an obfuscated way of having a publicly writable S3 bucket, but if you don’t have a server which can pre-sign URLs for you, this might be an acceptable solution.

For this to work, you take the following steps:

  1. Create a Lambda func, along with a new IAM role, keeping the default code.
  2. Create an API in the API Gateway.
@hmphu
hmphu / 01_utils.py
Created September 29, 2020 03:56 — forked from mbrochh/01_utils.py
Using pagination with Django, graphene and Apollo
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
# First we create a little helper function, becase we will potentially have many PaginatedTypes
# and we will potentially want to turn many querysets into paginated results:
def get_paginator(qs, page_size, page, paginated_type, **kwargs):
p = Paginator(qs, page_size)
try:
page_obj = p.page(page)
except PageNotAnInteger: