Skip to content

Instantly share code, notes, and snippets.

@vincenttone
vincenttone / rob.py
Created March 9, 2018 12:03
你是一个盗窃专家,某一天晚上你要去盗窃某一条街道的一排房子。这些房子都有相连的防盗系统,如果你把相邻的两家都偷了那么就会触发报警器。 用一个数组来表示这些房子的金钱数量,请你完成 rob 函数,计算出在不触发报警器的情况下最多能偷多少钱。
#!/usr/bin/env python
def rob(x):
print 'rob: ', x
return most(x, 0, 2)
def most(x, n, r):
l = len(x)
pre = 0
pre_keys = []
for i in range(0, r): # nums need to count
<?php
$str = "*4\r\n$-1\r\n$2\r\nb2\r\n$2\r\nb3\r\n$2\r\nb1\r\n"
."*5\r\n$2\r\na2\r\n$6\r\n*:+-:$\r\n$2\r\na1\r\n$2\r\na3\r\n$-1\r\n*0\r\n";
$r = read_pipeline_str_v2($str);
print_r($r);
function read_pipeline_str_v2($str)
{
$stat_strs = ['-', '+'];
(defun v-php-doc (func-name)
"show php doc by region"
; take your php html doc file to doc-dir
; need nero https://code.google.com/p/nero-el/
; about browser: http://www.emacswiki.org/emacs/CategoryWebBrowser
(interactive (list
(read-string (format "Enter the word (%s): "
(thing-at-point 'symbol)
)
nil 1 (thing-at-point 'symbol))
@vincenttone
vincenttone / auto-ssh.sh
Created June 9, 2013 02:26
平时用来自动登录ssh的脚本
#!/usr/bin/env expect
set host [lindex $argv 0]
set user [lindex $argv 1]
set passwd [lindex $argv 2]
spawn ssh $user@$host
expect "*password:"
send $passwd
send "\r"
interact
@vincenttone
vincenttone / luna-ever.rb
Last active December 17, 2015 02:39
曾经给lunae写的月亮,那时候刚学ruby,牛刀小试。
module Vince
class Moon
#Get a circle
def getCircle(r, p = false)
# (x - a)^2 + ( y -b)^2 = r^2
range = 2 * r + 1
circle = Array.new(range){Array.new(range, 1)}
@vincenttone
vincenttone / snaky walking.rb
Last active December 17, 2015 01:49
随便写的,简单测了下,似乎没问题……
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
def map_init(c)
arr = []
c[1].times do
arr.push Array.new(c[0], 0)
end
arr
end
@vincenttone
vincenttone / vince-emacs-funcion.el
Last active December 16, 2015 20:39
自己写的几个方法
;; Translating by ydcv
(defun ydcv (string)
"vincen's elisp ydcv"
(interactive "sEnter the word: ")
(shell-command (concat "~/bin/ydcv '" string "'"))
)
;; Checking php syntax by "php -l"
(defun plint ()
"Checking php syntax by php -l"
(interactive)
@vincenttone
vincenttone / .emacs-vince.el
Last active October 11, 2015 02:57
.emacs备份
(global-linum-mode 1)
(setq make-backup-files nil)
(add-to-list 'load-path "~/plugin/emacs/mode")
(load "php-mode")
(load "markdown-mode")
(load "coffee-mode")
(add-to-list 'auto-mode-alist '("\\.coffee$" . coffee-mode))
(add-to-list 'auto-mode-alist '("\\.md$" . markdown-mode))