Skip to content

Instantly share code, notes, and snippets.

View zjiekai's full-sized avatar
🐼
Home Sweet Home

zjiekai

🐼
Home Sweet Home
View GitHub Profile
URxvt.termName: rxvt-256color
URxvt.reverseVideo: True
URxvt.font: xft:inconsolata:pixelsize=18
! Low contrast theme, based on Zenburn <http://slinky.imukuppi.org/zenburnpage/>
! ! Modified from <https://gist.github.com/564084>
URxvt.foreground: #0c0c0c
URxvt.color0: #3f3f3f
URxvt.color1: #705050
URxvt.color2: #00b45a
@zjiekai
zjiekai / basic_auth_nodejs_test.js
Created October 18, 2016 07:40 — forked from charlesdaniel/basic_auth_nodejs_test.js
Example of HTTP Basic Auth in NodeJS
var http = require('http');
var server = http.createServer(function(req, res) {
// console.log(req); // debug dump the request
// If they pass in a basic auth credential it'll be in a header called "Authorization" (note NodeJS lowercases the names of headers in its request object)
var auth = req.headers['authorization']; // auth is in base64(username:password) so we need to decode the base64
console.log("Authorization Header is: ", auth);
<body><script>
var B = 'B', Y = 'Y', R = 'R';
var init_state = [[B], [R], [R], [Y], [Y], [Y], [R], [R], [B]];
function equalCol(c0, c1) {
if (c0.length === c1.length) {
for (var i = 0; i < c0.length; ++i) {
/*
Original highlight.js style (c) Ivan Sagalaev <maniac@softwaremaniacs.org>
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
@zjiekai
zjiekai / sshpass.py
Created August 8, 2016 13:52 — forked from virtuald/sshpass.py
Simple python wrapper to give SSH a password for automation purposes (with output capture)
#!/usr/bin/env python3
import os
import sys
_b = sys.version_info[0] < 3 and (lambda x:x) or (lambda x:x.encode('utf-8'))
def ssh_exec_pass(password, args, capture_output=False):
'''
Wrapper around openssh that allows you to send a password to
@zjiekai
zjiekai / gist:7afabcd8b50714b89ed281d776b271f6
Created July 6, 2016 08:41
How does angular-material select work
The problem: When clicking, how should the select dropdown be closed?
The angular-material solution:
Use a backdrop
https://github.com/angular/material/blob/c13feb76bd05d026a71fc8e7c4a556a1ebd56831/src/components/backdrop/backdrop.scss
0 info it worked if it ends with ok
1 verbose cli [ '/opt/software/node-v4.4.5-linux-x64/bin/node',
1 verbose cli '/opt/software/node-v4.4.5-linux-x64/bin/npm',
1 verbose cli 'install' ]
2 info using npm@2.15.5
3 info using node@v4.4.5
4 verbose readDependencies loading dependencies from /home/zjk/dev/github/vscode/package.json
5 verbose readDependencies npm-shrinkwrap.json is overriding dependencies
6 info shrinkwrap file "/home/zjk/dev/github/vscode/npm-shrinkwrap.json"
7 verbose readDependencies returned deps { 'agent-base': 'https://registry.npmjs.org/agent-base/-/agent-base-1.0.2.tgz',
import SimpleHTTPServer
class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def translate_path(self, path):
if path == '/lightwallet' or path == '/lightwallet/login' or path[:19] == '/lightwallet/wallet':
path = '/lightwallet/index.html'
p0 = SimpleHTTPServer.SimpleHTTPRequestHandler.translate_path(self, path)
return p0
////////////////////////////////////////////////////////////////////////////////
// Lab 6
////////////////////////////////////////////////////////////////////////////////
// Include the checkoff program:
.include "checkoff.uasm"
// Leave the following as zero to run ALL the test cases, and get your solution
// validated if all pass. If you have trouble with test case N, set it to N
// to run JUST that test case (for easier debugging):
@zjiekai
zjiekai / relay.py
Created February 18, 2016 08:47
tcp relay
#!/usr/bin/python
import logging
import socket
from threading import Thread
class PipeThread(Thread):
pipes = []