Skip to content

Instantly share code, notes, and snippets.

View ChengzhiZhao's full-sized avatar

Chengzhi Zhao ChengzhiZhao

View GitHub Profile
@ChengzhiZhao
ChengzhiZhao / gist:5295168
Created April 2, 2013 19:02
For the book Introduction to Algorithm 2.1-2
public static int [] getIncrease(int[] original){
for(int j=1;j<original.length;j++){
for(int i=0;i<original.length;i++){
if(original[i]>original[j]&&original[i]>0){
//Without using temp to reduce space complexity
original[i]=original[j]-original[i];
original[j]=original[j]-original[i];
original[i]=original[i]+original[j];
}
}
package main
import (
"fmt"
"log"
"os"
nats "github.com/nats-io/go-nats"
"github.com/satori-com/satori-rtm-sdk-go/rtm"
"github.com/satori-com/satori-rtm-sdk-go/rtm/pdu"
@ChengzhiZhao
ChengzhiZhao / airflow_blog_liveness_scheduler.yaml
Last active August 13, 2018 21:10
airflow_blog_liveness_scheduler
livenessProbe:
exec:
command:
- test
- '`find /usr/src/Airflow/Airflow_scheduler_liveness.txt -mmin -10`'
initialDelaySeconds: 30
periodSeconds: 1200
@ChengzhiZhao
ChengzhiZhao / airflow_blog_liveness_webserver.yaml
Created August 13, 2018 21:13
airflow_blog_liveness_webserver
livenessProbe:
httpGet:
path: /admin/versionview
port: 8080
initialDelaySeconds: 30
timeoutSeconds: 5
periodSeconds: 30
@ChengzhiZhao
ChengzhiZhao / airflow_blog_clear_queued_task.yaml
Created August 13, 2018 21:14
airflow_blog_clear_queued_task.yaml
for task in session.query(TaskInstance) \
.filter(TaskInstance.dag_id == dag) \
.filter(TaskInstance.execution_date == expected_date_time) \
.filter((TaskInstance.state == 'queued') | (TaskInstance.state == 'shutdown')):
if task.task_id in pre_tasks:
clear_task(dag, task.task_id, date, date_tomorrow)
@ChengzhiZhao
ChengzhiZhao / bikesharing-pub.go
Last active September 6, 2018 23:26
pub.go file blog post
package main
import (
"fmt"
"log"
"os"
nats "github.com/nats-io/go-nats"
"github.com/satori-com/satori-rtm-sdk-go/rtm"
"github.com/satori-com/satori-rtm-sdk-go/rtm/pdu"
@ChengzhiZhao
ChengzhiZhao / async-sub.go
Created August 31, 2018 01:58
bikeshare async-sub.go
package main
// Import Go and NATS packages
import (
"encoding/json"
"log"
"runtime"
"github.com/go-redis/redis"
"github.com/nats-io/go-nats"
@ChengzhiZhao
ChengzhiZhao / airflow-volumes-kubernetes-executor.yaml
Last active October 9, 2018 00:39
Airflow Volumes Kubernetes Executor
kind: PersistentVolume
apiVersion: v1
metadata:
name: airflow-dags
namespace: airflow
spec:
capacity:
storage: 16Gi
volumeMode: Filesystem
accessModes:
@ChengzhiZhao
ChengzhiZhao / mount-volume.yaml
Last active October 9, 2018 00:46
mount volume to airflow-deployment.yaml
volumes:
- name: airflow-dags
persistentVolumeClaim:
claimName: airflow-dags
- name: airflow-logs
persistentVolumeClaim:
claimName: airflow-logs
@ChengzhiZhao
ChengzhiZhao / test_kubernetes_executor.yaml
Created October 9, 2018 00:56
Test Kubernetes Executor
from airflow.operators.python_operator import PythonOperator
from airflow.models import DAG
from datetime import datetime
import time
import os
args = {
'owner': 'airflow',
"start_date": datetime(2018, 10, 4),
}