Skip to content

Instantly share code, notes, and snippets.

View matrush's full-sized avatar

Chaoshuai Lü matrush

View GitHub Profile
Simplify[RSolve[{a[n] == (B + 1) a[n - 1] - a[n - 2], a[0] == 0, a[1] == B}, a[n], n]]
Block[{B = 2}, Simplify[Table[a[n] /. First[%], {n, 10}]]]
@syllog1sm
syllog1sm / gist:10343947
Last active November 7, 2023 13:09
A simple Python dependency parser
"""A simple implementation of a greedy transition-based parser. Released under BSD license."""
from os import path
import os
import sys
from collections import defaultdict
import random
import time
import pickle
SHIFT = 0; RIGHT = 1; LEFT = 2;
@namuol
namuol / INSTALL.md
Last active July 24, 2023 11:53
rage-quit support for bash

rage-quit support for bash

HOW TO INSTALL

Put flip somewhere in your $PATH and chmod a+x it.

Copy fuck into ~/.bashrc.

@matthiaswenz
matthiaswenz / gist:8088229
Last active January 1, 2016 03:49
UISearchBar customize Keyboard Return button type (iOS 7)
for (UIView *subview in searchBar.subviews) {
for (UIView *subSubview in subview.subviews) {
if ([subSubview conformsToProtocol:@protocol(UITextInputTraits)]) {
UIView<UITextInputTraits> *textInputField = (UIView<UITextInputTraits> *)subSubview;
textInputField.returnKeyType = UIReturnKeyDone;
break;
}
}
}
@rcabaco
rcabaco / gist:6765778
Created September 30, 2013 15:45
UITextView subclass to handle up/down cursor movement
// Code to handle up/down cursor motion in a UITextView.
//
// Based on code from OmniGroup's OUITextView
// https://github.com/omnigroup/OmniGroup/blob/master/Frameworks/OmniUI/iPad/OUITextView.m
//
#import "TextView.h"
@interface TextView ()
@nbremer
nbremer / .block
Last active August 14, 2023 23:44
D3.js - Radar Chart or Spider Chart - Adjusted from radar-chart-d3
height: 650
license: mit
@mckelvin
mckelvin / 1.sh
Last active December 18, 2015 13:48
#!/bin/sh
# 1.切换到工程目录
# 2.用gource-gravatar-getter将头像下载到.git/avatar,格式类似 .git/avatar/mckelvin.png
#
gource --seconds-per-day 0.6 \
--user-image-dir .git/avatar \
--multi-sampling -1360x760 \
--output-ppm-stream /tmp/vis_tmp.ppm \
--disable-progress \
--hide mouse \
@siqin
siqin / gist:4201667
Created December 4, 2012 07:57
Remove Emoji in NSString
// XCode 4.2.1
@implementation NSString(EmojiExtension)
- (NSString*)removeEmoji {
__block NSMutableString* temp = [NSMutableString string];
[self enumerateSubstringsInRange: NSMakeRange(0, [self length]) options:NSStringEnumerationByComposedCharacterSequences usingBlock:
^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop){
@jeewamp
jeewamp / hierholzersAlgorithm.java
Created December 1, 2012 14:21
Hierholzers' Algorithm to find Eulerian Trail
/**
* @param adjacencyList, oddVertices, EulerianPath.
*/
public <P extends Integer, Q extends ArrayList<P>> ArrayList<P>
hierholzersAlgorithm(HashMap<P, Q> adjacencyList, ArrayList<P> oddVertices, ArrayList<P> path) {
P currentVertex=null;
//If path is not empty, the start vertex should be in the path.
//Check if Semi-Eulerian. If yes, start traversing from one of them.
if(oddVertices.size()==2) {
@zolunx10
zolunx10 / .gitignore
Last active December 24, 2023 15:14
Rime用颜文字(及符号)字典. 个人都绑定到v键开头了, 请下载kaomoji*并酌情修改字典文件.dict.yaml; 另如果要在当前输入法中直接嵌入, 请参考luna_pinyin_simp.custom.yaml前半段修改您的输入法设置.
*
!.gitignore
!alternative.yaml
!*.custom.yaml
!kaomoji.*.yaml