Skip to content

Instantly share code, notes, and snippets.

View ufo22940268's full-sized avatar
🎯
Focusing

Chao Cheng ufo22940268

🎯
Focusing
View GitHub Profile
WITH orders AS (
SELECT review, channel, t.product._id pid, t.product.martspec, t.product.costprice, t.product.price, "create"
FROM (SELECT * FROM db_orders WHERE "create" BETWEEN timestamp '2020-11-01 00:00:00' AND timestamp '2020-11-30 23:59:00' AND paid = TRUE) orders
CROSS JOIN unnest(products) AS t(product)
)
-- 2018-03-21 12:29:05
, reviews AS (
SELECT r.name reviewName, c.name channelName, m._id mid, r._id rid
FROM db_reviews r
@tuzaiz
tuzaiz / app.js
Created December 10, 2019 09:13
Sign in with Apple Server Handler
const express = require('express')
const request = require('request')
const jwt = require('jsonwebtoken')
const jose = require('jose')
const app = express()
let client_id = "AppBundleID" // Maybe from client
function generateClientSecret() {
let private_key = "-----BEGIN PRIVATE KEY-----\n......\n-----END PRIVATE KEY-----" // Should store in a safe place on server side
@ufo22940268
ufo22940268 / findAny.js
Last active June 5, 2018 02:24
Find with any key in mongo shell
function findAny(collection, value) {
var cursor = db[collection].find()
while (cursor.hasNext()) {
var o = cursor.next()
if (Object.keys(o).filter(key => o[key] == value).length) {
print(tojson(o))
}
}
}
SELECT date,id,name,if(defalutinterest_num is null,0,defalutinterest_num),
if(one_unsubscribe_num is null,0,one_unsubscribe_num),
if(three_unsubscribe_sum is null,0,three_unsubscribe_sum),
if(seven_unsubscribe_sum is null,0,seven_unsubscribe_sum),
if(avg_quguan_rate is null,0,avg_quguan_rate),
if(next_active_rate is null,0,next_active_rate),
if(valid_num is null,0,valid_num),
if(valid_num /defalutinterest_num is null,0,valid_num /defalutinterest_num),
if(nextread_num is null,0,nextread_num),
if(nextread_num/valid_num is null,0,nextread_num/valid_num),
@wilon
wilon / vim-surround使用指南.MD
Last active April 18, 2024 01:40
vim-surround使用指南,vim-surround如何使用

普通模式

命令 说明 + 示例
ds 删除括号
ds " "Hello world!" =>
Hello world!
cs 替换括号
cs "( "Hello world!" =>
(Hello world!)
cS 替换括号,括号内文本做新一行
cS "{ "Hello world!" => {     Hello world! }
@xcatliu
xcatliu / (已失效)中国区用户在开启 GitHub 两步验证中遇到的问题
Last active March 7, 2024 02:53
(已失效)中国区用户在开启 GitHub 两步验证中遇到的问题
2023.8.28
据多名网友回复,此方法已失效。
最新解决办法请参考此贴:[v2ex: 请问 github 的两步验证(two-factor authentication)大家是怎么做的?](https://www.v2ex.com/t/967533)
https://www.v2ex.com/t/967533
---
@jrudolph
jrudolph / TestMultipartFileUpload.scala
Last active February 13, 2023 18:09
akka-http Multipart file-upload client + server example
package akka.http.scaladsl
import java.io.File
import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.util.ByteString
import scala.concurrent.duration._
import akka.actor.ActorSystem
@eyecatchup
eyecatchup / hammerhead-from-lrx21o-to-lrx22c.md
Last active November 1, 2023 08:35
A step-by-step guide how to manually flash the Android 5.0.1 (LRX22C) OTA-Update on a Nexus 5 with modified system (custom recovery/kernel, rooted, modified framework etc.)..

Update: For those interested, here's the version for updating from Android 5.1.0 (LMY47D/LMY47I) to Android 5.1.1 (LMY48B):
https://gist.github.com/eyecatchup/dab5cf7977008e504213


  UPDATE `NEXUS 5` 
     SET `VERSION`='5.0.1', `BUILD`='LRX22C', `RECOVERY`='CUSTOM', `ROOTED`=1 
   WHERE `VERSION`='5.0' && `BUILD`='LRX21O' && `RECOVERY`='CUSTOM' && `ROOTED`=1 
         && `WANNA_KEEP_USERDATA`=1;
@stormzhang
stormzhang / adbwifi.sh
Created August 28, 2014 00:52
shell script for adb wifi
#!/bin/bash
#Modify this with your IP range
MY_IP_RANGE="192\.168\.1"
#You usually wouldn't have to modify this
PORT_BASE=5555
#List the devices on the screen for your viewing pleasure
adb devices
@antoniolg
antoniolg / SwipeRefreshActivity.java
Last active July 29, 2019 11:59
An activity that uses a SwipeRefreshLayout as a container for the layout of the classes that extend it.
/*
* Copyright (C) 2014 Antonio Leiva Gordillo.
*
* 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
*
* Unless required by applicable law or agreed to in writing, software