Skip to content

Instantly share code, notes, and snippets.

View junfenglx's full-sized avatar
🏠
Working from home

junfeng_hu junfenglx

🏠
Working from home
View GitHub Profile
@junfenglx
junfenglx / mlstm_word_embedding_at_epoch7-8.log
Created June 2, 2016 05:01
SNLI accuracy of match LSTM with word2vec word embedding
Loading data ...
Loading dev ...
10000
10000
9842
Loading test ...
10000
10000
9824
num_epochs: 20
@junfenglx
junfenglx / compile_flag.sh
Created January 15, 2016 06:44
使用tesseract-ocr和opencv识别视频中文字
#!/bin/bash
g++ -std=c++11 `pkg-config --libs tesseract opencv lept` $1 -o ${1}.out
@junfenglx
junfenglx / test_trail0.py
Created September 1, 2015 02:42
factorial trailing zeros test
# coding: utf-8
cache = dict()
def f(n):
if n <= 0:
return 0
prev = cache.get(n-1)
if not prev:
s = 1;
for i in range(1, n+1):
s *= i
@junfenglx
junfenglx / grub_rescue.md
Created August 16, 2015 11:11
grub rescue. repost from douban

###grub rescue模式下修复

由于在rescue模式下,只有少量的基本命令可用,必须通过一定的操作才能加载正常模块,然后进入正常模式。

rescue模式下可使用的命令有:set,ls,insmod,root,prefix(设置启动路径)

先假设grub2的核心文件在(hd0,8)分区,再来看看怎样从 rescue模式进入从(hd0,8)启动的正常模式(normal)。

在 rescue模式下search命令不能用,对不清楚grub2文件处于哪个分区的,可以用ls命令查看,比如

@junfenglx
junfenglx / install_package.sh
Created August 16, 2015 11:06
Arch Linux: install needed packages at all_packages
#!/bin/bash
for p in `cat all_packages`;
do
yaourt -S $p --needed --noconfirm
done
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@junfenglx
junfenglx / replace_all.py
Created April 7, 2015 03:06
replace one word with another recursively
#!/usr/bin/env python
# encoding: utf-8
'''
replace one word with another recursively
'''
import os
import subprocess
import os.path
#include <iostream>
#include <vector>
#include <string>
void print(const std::string &s, size_t i) {
size_t len = s.length();
size_t space_count = i < len ? i : len;
for(size_t j = 0; j < space_count; ++j)
std::cout << " ";
if (space_count < len)
@junfenglx
junfenglx / test_virtual_func.cc
Created February 9, 2015 13:23
In class constructor and destructor call virtual functions
#include <iostream>
class Base {
public:
Base() {
std::cout << "Base Constructor" << std::endl;
ctor();
}
virtual ~Base() {
std::cout << "Base Destructor" << std::endl;
@junfenglx
junfenglx / cpp_move_copy.cc
Last active August 29, 2015 14:13
use push_back demonstrates
#include <iostream>
#include <ostream>
#include <string>
#include <vector>
//comment this define to see reallocate
#define F4
class Test {
public:
std::string tag;
Test(std::string &t) : tag(t) {