Skip to content

Instantly share code, notes, and snippets.

View xcompass's full-sized avatar

Pan Luo xcompass

  • University of British Columbia
  • Vancouver, BC
View GitHub Profile
@xcompass
xcompass / sort.sh
Created February 14, 2020 00:06
Sort apache logs
# change position 5 if date time field is not on that position
sort -t ' ' -k 5.9,5.12n -k 5.5,5.7M -k 5.2,5.3n -k 5.14,5.15n -k 5.17,5.18n -k 5.20,5.21n access_log > access_log_sorted
#!/system/bin/sh
iptables -A bw_FORWARD -i !lo+
iptables -A natctrl_FORWARD -j RETURN -i rmnet+ -o wlan0 -m state --state RELATED,ESTABLISHED
iptables -A natctrl_FORWARD -j DROP -i wlan0 -o rmnet+ -m state --state INVALID
iptables -A natctrl_FORWARD -j RETURN -i wlan0 -o rmnet+
iptables -A natctrl_FORWARD -j DROP
iptables -A natctrl_nat_POSTROUTING -t nat -o rmnet+ -j MASQUERADE

Keybase proof

I hereby claim:

  • I am xcompass on github.
  • I am compass (https://keybase.io/compass) on keybase.
  • I have a public key ASCpd0I19F3cPgGkDcl9Lq1jOQHUgU-bmx4df8P_EnS_Owo

To claim this, I am signing this object:

kind: Namespace
apiVersion: v1
metadata:
name: $KUBE_NAMESPACE
aaa: $TEST
ttt: ttt
@xcompass
xcompass / gist:56366a9ed1e016ba9198fceadcf3ee3c
Last active August 12, 2016 20:50
Github project stats
# Total number of ubc org repos
for i in `seq 0 6`; do curl -s https://api.github.com/organizations/1396118/repos\?page\=$i | jq '.[] | .name'; done | wc -l
# Sort by creating date
for i in `seq 0 6`; do curl -s https://api.github.com/organizations/1396118/repos\?page\=$i | jq '.[] | .created_at'; done | sort
@xcompass
xcompass / questrade_updater.js
Last active July 31, 2020 20:40
Questrade Updater
// ==UserScript==
// @name Questrade Updater
// @namespace http://tampermonkey.net/
// @version 0.4
// @description Auto refresh Questrade trading UI
// @author Pan Luo
// @match https://my.questrade.com/Trading/*
// @updateURL https://gist.githubusercontent.com/xcompass/697fd581e5c39b5e6c54/raw/questrade_updater.js
// @grant none
// ==/UserScript==
@xcompass
xcompass / outcome_tp.py
Created September 2, 2015 04:39
simple outcome post testing client for LTI outcome service
from requests_oauthlib import OAuth1
import requests
oauth = OAuth1(client_key='test',client_secret='secret', signature_method='HMAC-SHA1', signature_type='auth_header', force_include_body=True)
# this is the lis_result_sourcedid from LTI launch request
sourcedid = 'bmhfv6lUfM0S/dRmgVQ6EfmPCXRW1Lgyfv83FZDsdPg=:_3_1:_14_1:ltiapps:student1'
url = 'http://localhost:9876/webapps/osc-BasicLTI-BBLEARN/service'
body = '<?xml version = "1.0" encoding = "UTF-8"?> <imsx_POXEnvelopeRequest xmlns = "http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0"> <imsx_POXHeader> <imsx_POXRequestHeaderInfo> <imsx_version>V1.0</imsx_version> <imsx_messageIdentifier>55e63bdb526ec</imsx_messageIdentifier> </imsx_POXRequestHeaderInfo> </imsx_POXHeader> <imsx_POXBody> <replaceResultRequest> <resultRecord> <sourcedGUID> <sourcedId>'+sourcedid+'</sourcedId> </sourcedGUID> <result> <resultScore> <language>en-US</language> <textString>1</textString> </resultScore> </result> </resultRecord> </replaceResultRequest> </imsx_POXBody> </i
@xcompass
xcompass / pwmtest.c
Created January 9, 2015 05:45
cc2530 pwm on contiki using timer1 and P1_1 and etimer for delay
#include "contiki.h"
#include "contiki-lib.h"
#include "contiki-net.h"
#include <string.h>
#include <stdio.h>
#include "dev/leds.h"
#include "dev/button-sensor.h"
#include "debug.h"
@xcompass
xcompass / pwmtest.c
Created January 9, 2015 04:39
cc2530 pwm on contiki using timer1 and P1_1
#include "contiki.h"
#include "contiki-lib.h"
#include "contiki-net.h"
#include <string.h>
#include <stdio.h>
#include "dev/leds.h"
#include "dev/button-sensor.h"
#include "debug.h"
@xcompass
xcompass / lcd
Created October 19, 2014 04:30
LCD I2C test
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h> // F Malpartida's NewLiquidCrystal library
#define I2C_ADDR 0x3F // Define I2C Address for controller
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0