Skip to content

Instantly share code, notes, and snippets.

View codescv's full-sized avatar
🎯
Focusing

Chi Zhang codescv

🎯
Focusing
View GitHub Profile
@codescv
codescv / 12306.applescript
Created November 13, 2019 06:00
script to add calendar item from 12306 sms
on theSplit(theString, theDelimiter)
-- save delimiters to restore old settings
set oldDelimiters to AppleScript's text item delimiters
-- set delimiters to delimiter to be used
set AppleScript's text item delimiters to theDelimiter
-- create the array
set theArray to every text item of theString
-- restore the old setting
set AppleScript's text item delimiters to oldDelimiters
-- return the result
@codescv
codescv / lr-dist.py
Last active May 22, 2018 09:13
Distributed tensorflow code
def build_model(filename):
# ... same as before
global_step = tf.train.get_or_create_global_step()
train_op = optimizer.minimize(loss, global_step=global_step)
summary = tf.summary.merge_all()
global_vars = tf.global_variables()
uninitialized = tf.report_uninitialized_variables(tf.global_variables())
global_init = tf.global_variables_initializer()
@codescv
codescv / lr-single.py
Created May 6, 2018 12:17
Single node tensorflow model
import tensorflow as tf
_CSV_COLUMNS = [
'age', 'workclass', 'fnlwgt', 'education', 'education_num',
'marital_status', 'occupation', 'relationship', 'race', 'gender',
'capital_gain', 'capital_loss', 'hours_per_week', 'native_country',
'income_bracket'
]
import java.util.LinkedList;
import java.lang.Thread;
class Test {
class BlockingQueue {
public BlockingQueue(int size) {
this.size = size;
}
@codescv
codescv / fonts.conf
Created January 17, 2014 08:58
fonts.conf
<?xml version='1.0'?>
<!-- GistID: 8470342 -->
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="font">
<edit mode="assign" name="rgba">
<const>rgb</const>
</edit>
</match>
<match target="font">
// GistID: 7984760
// KMP substring search && FSM substring search
#include <string>
#include <iostream>
#include <vector>
using namespace std;
typedef vector<vector<int> > FSMType;
#!/usr/bin/perl -w
# GistID: 7316128
# example: argparse.pl arg1 arg2 arg3 --long-param x -l hh -a arg4 arg5
# params = {"long"=>"x", "short"=>"hh", "switch-a":1}
# args = ("arg1", "arg2", "arg3", "arg4", "arg5")
use strict;
use 5.010;
# GistID: 7287953
startup_message off
escape ^X^X
caption always "%?%F%{-b 5w}%:%{-b bb}%? %H | %l | %m-%d %c |%?%F%{-b 4w}%?%L=%-Lw%45>%{-b w4}%n%f* %t%{-}%+Lw%-0<"
@codescv
codescv / cm10.1-py-patch
Created September 16, 2013 01:35
Allow searching pinyin in the T9 dialer in non-Chinese locales on cm10.1
┌──[chi@mint]──[~/android/system/packages/apps/Contacts]── (8e9a5fb...) * ────────
$ git diff
diff --git a/src/com/android/contacts/dialpad/util/NameToNumberFactory.java b/src/com/android/contacts/dial
index c0adef6..3ca285b 100644
--- a/src/com/android/contacts/dialpad/util/NameToNumberFactory.java
+++ b/src/com/android/contacts/dialpad/util/NameToNumberFactory.java
@@ -34,13 +34,15 @@ public class NameToNumberFactory {
// Check locale and returns matched class inherited from NameToNumber class.
NameToNumber instance;
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
using namespace std;
int fact(int n) {