Skip to content

Instantly share code, notes, and snippets.

View dawncold's full-sized avatar
🎯
Focusing

Zhen Tian dawncold

🎯
Focusing
View GitHub Profile
@dawncold
dawncold / debug.py
Created June 22, 2021 00:16
How to debug Twisted TLS with wireshark
# 1. setup environment SSLKEYLOGFILE, value is a file path, I set it to /tmp/.ssl-key.log
# 2. put /tmp/.ssl-key.log to wireshark TLS pre-master key path
# 3. use following code, setup pyOpenSSL key log callback
certificateOptions = OpenSSLCertificateOptions(
trustRoot=platformTrust(),
acceptableProtocols=[b'h2'],
)
ctx = certificateOptions.getContext()
@dawncold
dawncold / resources.yaml
Created May 12, 2021 23:33
k8s secret and cronjob
apiVersion: v1
kind: Secret
metadata:
name: app-secret
type: Opaque
stringData:
dbconnstr: this-is-db-connection-string-in-secret
username: admin
password: KuBeRnEtEs
---
@dawncold
dawncold / ga.js
Last active April 23, 2021 15:21
ga and pendo install script explain
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
function installGA() {

DefaultKeyBinding.dict in your ~/Library/KeyBindings

{
  "\UF729"  = moveToBeginningOfParagraph:; // home
  "\UF72B"  = moveToEndOfParagraph:; // end
  "$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home
  "$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end
  "^\UF729" = moveToBeginningOfDocument:; // ctrl-home
 "^\UF72B" = moveToEndOfDocument:; // ctrl-end
@dawncold
dawncold / pms.sh
Last active January 10, 2022 23:15
Plex media server script for FreeBSD
#! /bin/sh
. /etc/rc.subr
name=plexmediaserver
rcvar=plexmediaserver_enable
load_rc_config $name
: ${plexmediaserver_enable:=NO}
command=/usr/sbin/daemon

Keybase proof

I hereby claim:

  • I am dawncold on github.
  • I am dawncold (https://keybase.io/dawncold) on keybase.
  • I have a public key whose fingerprint is 260E 9341 3205 CA34 573E 0670 74B6 B0F5 536B B58C

To claim this, I am signing this object:

@dawncold
dawncold / remove_orphan_tasks.py
Created September 7, 2017 05:50
tasktiger remove orphan tasks
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function, division
import sys
from redis import Redis
def check():
r = Redis()
task_keys = set()
for key in r.scan_iter(match='t:task:*'):
function Foo() {
getName = function () { alert (1); };
return this;
}
Foo.getName = function () { alert (2);};
Foo.prototype.getName = function () { alert (3);};
var getName = function () { alert (4);};
function getName() { alert (5);}
//请写出以下输出结果:
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: (module, count) => {
var userRequest = module.userRequest;
if (typeof userRequest !== 'string') {
return false;
}
return userRequest.indexOf('node_modules') >= 0;
<Route path="/" getComponent={() => System.import('./BaseLayout').then(c => c.BaseLayout)} hideHeader="false" hideFooter="false">
<IndexRoute getComponent={() => System.import('./Index').then(c => c.Index)}/>
</Route>