Skip to content

Instantly share code, notes, and snippets.

View namchuai's full-sized avatar

NamH namchuai

View GitHub Profile
@namchuai
namchuai / uuid.jinja
Created January 4, 2023 16:15 — forked from benwalio/uuid.jinja
create a basic uuid using jinja2
{%- set ns = namespace(uuid = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx') %}
{%- set ns.new_uuid = '' %}
{%- for x in ns.uuid %}
{%- set ns.new_uuid = [ns.new_uuid,(x | replace('x', [0,1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f'] | random ))] | join %}
{%- endfor %}
{{ ns.new_uuid }}
@namchuai
namchuai / show_dialog.java
Created May 8, 2020 04:55
Android: Showing System popup from service
AlertDialog alertDialog = new AlertDialog.Builder(this)
.setTitle("Title")
.setMessage("Are you sure?")
.create();
alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
alertDialog.show();
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
@namchuai
namchuai / roman_converter.dart
Created April 24, 2020 05:02
Roman converter
void main() {
final VALUES = {
'I': 1,
'V': 5,
'X': 10,
'L': 50,
'C': 100,
'D': 500,
'M': 1000
};
@namchuai
namchuai / command.sql
Created March 25, 2020 04:00
Some postgresql command
# truncate the table and reset the index
truncate table <table_name> restart identity
@namchuai
namchuai / install virtualenv ubuntu 16.04.md
Created February 7, 2020 15:56 — forked from frfahim/install virtualenv ubuntu 16.04.md
How to install virtual environment on ubuntu 16.04

How to install virtualenv:

Install pip first

sudo apt-get install python3-pip

Then install virtualenv using pip3

sudo pip3 install virtualenv 
@namchuai
namchuai / Threads.cpp
Created October 15, 2019 17:19
Modified android audioflinger
/*
**
** Copyright 2012, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
@namchuai
namchuai / Getting board id mac
Created August 7, 2019 15:32
Getting board id mac
Just paste the line to terminal. I'm not created the script. Just a note for me or someone when needed.
var_ID=$(ioreg -p IODeviceTree -r -n / -d 1 | grep board-id);var_ID=${var_ID##*<\"};var_ID=${var_ID%%\">};echo $var_ID\n
@namchuai
namchuai / Getting board id mac
Created August 7, 2019 15:32
Getting board id mac
Just paste the line to terminal. I'm not created the script. Just a note for me or someone when needed.
var_ID=$(ioreg -p IODeviceTree -r -n / -d 1 | grep board-id);var_ID=${var_ID##*<\"};var_ID=${var_ID%%\">};echo $var_ID\n
@namchuai
namchuai / Getting board id mac
Created August 7, 2019 15:32
Getting board id mac
Just paste the line to terminal. I'm not created the script. Just a note for me or someone when needed.
var_ID=$(ioreg -p IODeviceTree -r -n / -d 1 | grep board-id);var_ID=${var_ID##*<\"};var_ID=${var_ID%%\">};echo $var_ID\n
@namchuai
namchuai / Getting board id mac
Created August 7, 2019 15:32
Getting board id mac
Just paste the line to terminal. I'm not created the script. Just a note for me or someone when needed.
var_ID=$(ioreg -p IODeviceTree -r -n / -d 1 | grep board-id);var_ID=${var_ID##*<\"};var_ID=${var_ID%%\">};echo $var_ID\n