Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View beginor's full-sized avatar
💭
Coding for code!

beginor beginor

💭
Coding for code!
View GitHub Profile
using System.Xml;
using AutoMapper;
namespace AutoMapperTest;
public class Entity {
public XmlDocument Statement { get; set; }
}
public class Model {
@beginor
beginor / pnpm-ng-cli.sh
Created November 16, 2021 02:59
Create angular app with pnpm package manager.
#!/bin/bash -e
mv ng-seed-cli/.git _git
rm -rf ng-seed-cli
pnpm --package=@angular/cli dlx ng new ng-seed-cli --create-application false --skip-git --minimal --package-manager pnpm
cd ng-seed-cli
cp ../ng-seed/.eslintrc.json ./
cp ../ng-seed/.editorconfig ./
pnpm exec ng add @angular-eslint/schematics@next --skip-confirmation
pnpm exec ng g @angular-eslint/schematics:lib app-shared
pnpm exec ng g @angular-eslint/schematics:app handset --style scss --routing true --skip-tests true
@beginor
beginor / fix-geometries.py
Created April 13, 2021 00:05 — forked from jsanz/fix-geometries.py
Python - QGIS - Fix geometries
"""
Small script to fix geometries of the first file argument
using the native QGIS processing algorithm. You may need
to adjust the path to you installation.
"""
import sys
sys.path.append('/usr/share/qgis/python/plugins')
from processing.core.Processing import Processing
@beginor
beginor / dynamic-query.md
Last active December 3, 2020 09:38
dynamic query demo
public void SearchUser(
    string userName,
    int? age
) {
    // 以 NHibernate 的动态查询示例
    ISession session = OpenSession();
    IQueryable<User> query = session.Query<User>();
    // 根据参数动态构建表达式树
 if (userName.IsNotNullOrEmpty()) {
@beginor
beginor / JavaScript 面试题.md
Created November 28, 2018 02:24
JavaScript 面试题

基本的 JavaScript 问题

  1. 让下面的代码可以运行:

    const a = [1, 2, 3, 4, 5];
    // Implement this
    a.multiply();
    console.log(a); // [1, 2, 3, 4, 5, 1, 4, 9, 16, 25]
@beginor
beginor / 2018年,最常见的26个JavaScript面试题和答案.md
Created November 28, 2018 02:23
2018年,最常见的26个JavaScript面试题和答案

2018年,最常见的26个JavaScript面试题和答案

Q1:JavaScript 中的强制转型(coercion)是指什么?

难度:0

在 JavaScript 中,两种不同的内置类型间的转换被称为强制转型。强制转型在 JavaScript 中有两种形式:显式和隐式。

这是一个显式强制转型的例子:

@beginor
beginor / pg-find-table-foreign-keys.sql
Last active July 19, 2019 16:48
[查找表的外键关联] find a table's foreign keys postgresql #PostgreSQL
SELECT
tc.table_schema,
tc.constraint_name,
tc.table_name,
kcu.column_name,
ccu.table_schema AS foreign_table_schema,
ccu.table_name AS foreign_table_name,
ccu.column_name AS foreign_column_name
FROM
information_schema.table_constraints AS tc
@beginor
beginor / turn-on-wifi-hot-spot.sh
Created November 4, 2018 09:18
Trun on wifi spot by adb.
# open setting
adb shell am start -n com.android.settings/.TetherSettings
# down
adb shell input keyevent 20
# enter
adb shell input keyevent 66
@beginor
beginor / pg-var.sql
Last active September 27, 2018 07:40
postgresql variables
DO $$
DECLARE
counter INTEGER := 1;
first_name VARCHAR(50) := 'John';
last_name VARCHAR(50) := 'Doe';
payment NUMERIC(11, 2) := 20.5;
BEGIN
RAISE NOTICE '% % % has been paid % USD.', counter, first_name, last_name, payment;
END $$;
@beginor
beginor / snowflake-id.sql
Last active April 18, 2024 20:13
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;