Skip to content

Instantly share code, notes, and snippets.

View edwardinubuntu's full-sized avatar

Edward Chiang edwardinubuntu

View GitHub Profile
@edwardinubuntu
edwardinubuntu / deck.py
Last active October 5, 2022 06:14
Bingo game simulation run in python.
import random
import numpy as numpy
class Official:
@staticmethod
def non_repeat_numb(nums, minimum, maximus):
"""
Create un-repeat number
@edwardinubuntu
edwardinubuntu / install_gitlab.sh
Created May 6, 2021 21:42
Install Gitlab on Linux server
# yum update
sudo yum update -y
# Install docker
sudo amazon-linux-extras install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
exit
# Verify docker is ready
@edwardinubuntu
edwardinubuntu / worker.py
Created April 10, 2021 10:21
log to excel and update to AWS S3
@action(MessageAction.FUND_FUSE_BOMBER_LOGS_TO_URL)
def fuse_bomber_logs_to_url(payload, msg_id):
app_id = payload['app_id']
# Step 1. Get all bomber logs data
bomber_data = []
for service in BomberLogService.values():
json_ary = get_bomber_logs(app_id, service)
if json_ary:
bomber_data.extend(json_ary)
@edwardinubuntu
edwardinubuntu / home.dart
Created April 14, 2020 02:20
Round radius bottom navigation bar
Widget get bottomNavigationBar {
const double _iconSize = 36;
Widget _emptyText = Container(
width: 0,
height: 0,
);
if (Platform.isAndroid) {
_emptyText = Text('');
}
return ClipRRect(
@edwardinubuntu
edwardinubuntu / aws s3 presign.sh
Created October 11, 2019 02:11
aws s3 presign
$ aws s3 presign s3://your-buckets/path/file-v1.pdf --expires-in 604800
https://your-buckets.s3.amazonaws.com/path/file-v1.pdf?AWSAccessKeyId=AKIARUA7FGPTQ63QVG5Q&Signature=NvzndozlDrJbgf6cMDimM8uZxBA%3D&Expires=1571362899
$ aws s3 presign s3://your-buckets/path/file-v1.epub --expires-in 604800
https://your-buckets.s3.amazonaws.com/path/file-v1.epub?AWSAccessKeyId=AKIARUA7FGPTQ63QVG5Q&Signature=UmImdDRiLLURJMZ0QgSdaBBcrGs%3D&Expires=1571363011
@edwardinubuntu
edwardinubuntu / brew install awscli.sh
Created October 11, 2019 02:07
brew install awscli
$ brew install awscli
import json
sub_bills = {
"app": "Dana Mall",
"bc": "BNI",
"total": 1000000000
}
dict = {"code": 0,
"total": 1000,
@edwardinubuntu
edwardinubuntu / ac_to_sheet.py
Created November 11, 2017 15:07
pool and process
max_windows = browser_setting['max_windows']
logging.info('max_windows settings: ' + str(max_windows))
# pool = Pool(processes=len(event_list))
for event in event_list[:max_windows]:
logging.debug('Event before submit, name: ' + event['text'])
# pool.apply_async(func=parse_event_sale_info, args=(event,))
p = Process(target=parse_event_sale_info, args=(event,))
p.start()
p.join()
// Check if support contact in chat
if (!TextUtils.isEmpty(new TripTime(getContext()).getContactInChatUrl())) {
final UserPreferencesManager userPreferencesManager = new UserPreferencesManager(getContext());
final String roomId = userPreferencesManager.getMember().getUserId() + "-triptime-contact";
progressDialog.setTitle(getString(R.string.check_room_with_id));
progressDialog.setMessage(getString(R.string.loading));
progressDialog.show();
// Find room id
IMKit.instance().getRoom(roomId, new IMRestCallback<Room>() {

Original: food_amounts = [{"sugar_grams":245,"carbohydrate":83,"fiber":67},{"carbohydrate":74,"sugar_grams":52,"fiber":26},{"fiber":47,"carbohydrate":93,"sugar_grams":6}]

/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/bin/python3.6 /Users/edward_chiang/python_projects/sort/sort.py
food_amounts by sugar_grams: [{'sugar_grams': 245, 'carbohydrate': 83, 'fiber': 67}, {'carbohydrate': 74, 'sugar_grams': 52, 'fiber': 26}, {'fiber': 47, 'carbohydrate': 93, 'sugar_grams': 6}]
food_amounts by carbohydrate: [{'fiber': 47, 'carbohydrate': 93, 'sugar_grams': 6}, {'sugar_grams': 245, 'carbohydrate': 83, 'fiber': 67}, {'carbohydrate': 74, 'sugar_grams': 52, 'fiber': 26}]
food_amounts by fiber: [{'sugar_grams': 245, 'carbohydrate': 83, 'fiber': 67}, {'fiber': 47, 'carbohydrate': 93, 'sugar_grams': 6}, {'carbohydrate': 74, 'sugar_grams': 52, 'fiber': 26}]

Process finished with exit code 0