Skip to content

Instantly share code, notes, and snippets.

View tearf001's full-sized avatar
🎯
Focusing

Tiffiny Jenis tearf001

🎯
Focusing
View GitHub Profile
@tearf001
tearf001 / difference.js
Created June 16, 2022 04:38 — forked from Yimiprod/difference.js
Deep diff between two object, using lodash
/**
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
return _.transform(object, function(result, value, key) {
if (!_.isEqual(value, base[key])) {
@tearf001
tearf001 / joinload.py
Created August 12, 2021 16:15
sqlalchemy joinload
#! 作为数据延迟加载,但作为Instrument 此语法不支持... 包括Query也不支持跳
test = dashboard_dao.get_safe(role_id, joinedload=(Dashboard.portal, Dashboard.portal.project)) # !!! 执行失败
q = role_dao._buildQueryfields(joinedload=(Role.org, Organization.org_users)).filter(role_dao.model.id == role_id)
logger.info(f'{q}')
logger.info(f'{q.all()}') # 自动distinct ? 查询返回一条!
logger.info(f'{q.one_or_none()}') # 自动distinct ? 不会报错!
# 自定义
test = dashboard_dao.get_safe(role_id, joinedload=(Dashboard.portal, DashboardPortal.project)) # 多次预加载,但注意保持对象不得有多行
@tearf001
tearf001 / wsl2-network.ps1
Created February 1, 2021 09:28 — forked from daehahn/wsl2-network.ps1
WSL 2 TCP NETWORK FORWARDING
# WSL2 network port forwarding script v1
# for enable script, 'Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser' in Powershell,
# for delete exist rules and ports use 'delete' as parameter, for show ports use 'list' as parameter.
# written by Daehyuk Ahn, Aug-1-2020
# Display all portproxy information
If ($Args[0] -eq "list") {
netsh interface portproxy show v4tov4;
exit;
}
@tearf001
tearf001 / exception-future.dart
Created July 19, 2019 14:24
exception-future
import 'dart:async';
main() {
Future.value(10).then((_) {
Future(() => throw 'err').catchError((_){
print('innner $_');
throw 'no catch';
});
return _;
}).then((_) {
@tearf001
tearf001 / uri-api.dart
Last active July 18, 2019 12:23
uri-api
main() {
var p2 = '/Images/png/yw_icon.png';
var p3 = 'Images/png/yw_icon.png';
var rs = [
'http://61.183.0.23/gzzs/appstore.aspx?d=18',
'https://13.cn.123/root/',
'https://13.cn.123/api',
'ftp://123.23.132/',
'wx://123/23',
p2,
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src=https://unpkg.com/@reactivex/[email protected]/dist/global/rxjs.umd.js></script>
</head>
<body>
String deversion(String version){
if(version == null || version.compareTo("1.0.0")<0) return version;
var versions = version.split('.');
var s = int.parse(versions.first) -1;
versions[0] = s.toString();
return versions.join('.');
}
int versionValue(String version){
if(version == null) return null;
var versions = version.split('.');
String supplant(String o,map) {
RegExp r = RegExp(r"{([^{}]+)}");
return o.replaceAllMapped(r,(match){
//print('matched;${match.group(1)}');
return '${map[match.group(1)]}';
});
}
main(){
print(supplant('hello,{person},i will {do} u',{'person':'julie','do':['love','then','touch']}));
}
@tearf001
tearf001 / .sql
Last active July 25, 2018 16:37
动态查询引用三级
EXECUTE 'UPDATE tbl SET '
|| quote_ident(colname) --
|| ' = '
|| quote_nullable(newvalue)
|| ' WHERE key = '
|| quote_literal(keyvalue);
EXECUTE format('UPDATE tbl SET %I = %L '
'WHERE key = %L', colname, newvalue, keyvalue);
--实战用例:
path-to-oracle-client\BIN\sqlldr userid=用户名/密码@tns名 control=控制文件.ctl direct=y parallel=y readsize=10005008 errors=999999999
--控制文件.ctl内容:
load data
CHARACTERSET 'UTF8'
infile "webdata20180724_wh.txt"
Append into table xw_tmp_to_liuling_20180725
fields terminated by ","