Skip to content

Instantly share code, notes, and snippets.

View truongngoclinh's full-sized avatar
🎯
Focusing

Trương Ngọc Linh truongngoclinh

🎯
Focusing
  • Tokyo
View GitHub Profile
@truongngoclinh
truongngoclinh / actionlist.vim
Created July 2, 2018 07:42 — forked from zchee/actionlist.vim
IdeaVim actionlist
--- Actions ---
$Copy <M-C>
$Cut <M-X> <S-Del>
$Delete <Del> <BS> <M-BS>
$LRU
$Paste <M-V>
$Redo <M-S-Z> <A-S-BS>
$SearchWeb <A-S-G>
$SelectAll <M-A>
$Undo <M-Z>
@truongngoclinh
truongngoclinh / actionlist.vim
Created July 2, 2018 07:42 — forked from zchee/actionlist.vim
IdeaVim actionlist
--- Actions ---
$Copy <M-C>
$Cut <M-X> <S-Del>
$Delete <Del> <BS> <M-BS>
$LRU
$Paste <M-V>
$Redo <M-S-Z> <A-S-BS>
$SearchWeb <A-S-G>
$SelectAll <M-A>
$Undo <M-Z>
@truongngoclinh
truongngoclinh / actionlist.vim
Created July 2, 2018 07:42 — forked from zchee/actionlist.vim
IdeaVim actionlist
--- Actions ---
$Copy <M-C>
$Cut <M-X> <S-Del>
$Delete <Del> <BS> <M-BS>
$LRU
$Paste <M-V>
$Redo <M-S-Z> <A-S-BS>
$SearchWeb <A-S-G>
$SelectAll <M-A>
$Undo <M-Z>
@truongngoclinh
truongngoclinh / pyDes.py
Created January 3, 2018 09:58 — forked from eigenein/pyDes.py
A pure python implementation of the DES and TRIPLE DES encryption algorithms
#############################################################################
# Documentation #
#############################################################################
# Author: Todd Whiteman
# Date: 16th March, 2009
# Verion: 2.0.0
# License: Public Domain - free to do as you wish
# Homepage: http://twhiteman.netfirms.com/des.html
#
@truongngoclinh
truongngoclinh / mysql2sqlite.sh
Created October 30, 2017 03:06 — forked from cabbiepete/mysql2sqlite.sh
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
class TZUtils:
def is_maintainance_time(self):
local_tz = timezone.get_current_timezone()
now = timezone.localtime(timezone.now()).time()
start = timezone.localtime(local_tz.localize(timezone.datetime.strptime('16:00', '%H:%M'))).time()
end = timezone.localtime(local_tz.localize(timezone.datetime.strptime('17:00', '%H:%M'))).time()
logger.info("is_maintainance_time: start - end - now: %s - %s - %s ", start, end, now)
if "BankName" == models.BankTokenization.BANKS_LIST[self.api_req.bank_id]:
return now < start or now > end
return False
from django.contrib.humanize.templatetags.humanize import intcomma
// use lib
val = _("%s dong") % intcomma(credit_pay_amount)})
val = '{0:,.3f}'.format(float(p['value'])/1000) + _('d')
@truongngoclinh
truongngoclinh / UITextFieldMaxLengths.m
Created July 12, 2017 10:41
Set maxLength = 2 to UITextField
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
// Prevent crashing undo bug
if(range.length + range.location > textField.text.length)
{
return NO;
}
NSUInteger newLength = [textField.text length] + [string length] - range.length;
return newLength <= 2;
@truongngoclinh
truongngoclinh / BottomDatePicker.m
Created July 12, 2017 04:51
Show a UIDatePicker on bottom and attached with UITextField.
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
datePicker.backgroundColor = [UIColor whiteColor];
datePicker.datePickerMode = UIDatePickerModeDate;
[datePicker setMinimumDate:[self.dateFormatter dateFromString:@"1980-01-01"]];
[datePicker setMaximumDate:[self.dateFormatter dateFromString:@"2050-01-01"]];
[datePicker setLocale:[NSLocale localeWithLocaleIdentifier:[CPLanguage sharedInstance].currentLanguageCode]];
self.dateFormatter = [[CPDateFormatter alloc] init];
[self.dateFormatter setDateFormat:@"dd-MM-yyyy"];
@truongngoclinh
truongngoclinh / vertical_dotted_line.xml
Last active June 26, 2017 11:11
Create drawable vertical dotted line, its the bottom edge of the rectangle.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:top="-2.5dp"
android:bottom="-2dp"
android:right="-2dp">
<shape>
<solid android:color="@android:color/transparent"/>
<stroke
android:width="2dp"