Skip to content

Instantly share code, notes, and snippets.

View xunzhang's full-sized avatar
🗝️
勋章

Hong Wu xunzhang

🗝️
勋章
View GitHub Profile
@ilblackdragon
ilblackdragon / seq2seq.py
Last active May 22, 2022 21:42
Example of Seq2Seq with Attention using all the latest APIs
import logging
import numpy as np
import tensorflow as tf
from tensorflow.contrib import layers
GO_TOKEN = 0
END_TOKEN = 1
UNK_TOKEN = 2
@bishboria
bishboria / springer-free-maths-books.md
Last active October 3, 2024 09:17
Springer made a bunch of books available for free, these were the direct links
@chenshuo
chenshuo / word_freq.cc
Created January 12, 2013 19:03
sort words by frequencies.
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <vector>
typedef std::unordered_map<std::string, int> WordCount;
struct Greater
{
bool operator()(const std::pair<int, WordCount::iterator>& lhs,
@anopheles
anopheles / router.py
Created September 12, 2012 13:34
Router Dealer example with bidirectional communication
# encoding: utf-8
import zmq
from collections import defaultdict
context = zmq.Context()
client = context.socket(zmq.ROUTER)
client.bind("tcp://*:5556")
poll = zmq.Poller()
@schlamar
schlamar / !Python serialization
Created July 18, 2012 05:32
Python serializer benchmark: json, simplejson, cPickle, messagepack, simpleubjson, marshal, literal_eval
System
======
Windows 7
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]
Small data
==========
@batok
batok / paramiko_example.py
Created April 10, 2012 16:11
Paramiko example using private key
import paramiko
k = paramiko.RSAKey.from_private_key_file("/Users/whatever/Downloads/mykey.pem")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print "connecting"
c.connect( hostname = "www.acme.com", username = "ubuntu", pkey = k )
print "connected"
commands = [ "/home/ubuntu/firstscript.sh", "/home/ubuntu/secondscript.sh" ]
for command in commands:
print "Executing {}".format( command )
@zyxar
zyxar / exercise.tour.go
Last active September 24, 2024 23:24
tour.golang exercise solutions
/* Exercise: Loops and Functions #43 */
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := float64(2.)
@hrldcpr
hrldcpr / tree.md
Last active September 1, 2024 07:04
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@mloskot
mloskot / boost_property_tree_json_array.cpp
Created December 22, 2011 11:11
Simple example of parsing and consuming JSON array with boost::property_tree
#ifdef _MSC_VER
#include <boost/config/compiler/visualc.hpp>
#endif
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/foreach.hpp>
#include <cassert>
#include <exception>
#include <iostream>
#include <sstream>