Skip to content

Instantly share code, notes, and snippets.

# git_svn_repo should be a clean svn repository
git_svn_repo=<path>
git_repo=<path>
git_remote_repo=<url>
git_user_email=<email>
git_user_name=<name>

cd $git_svn_repo
@hydra1983
hydra1983 / hexo_deploy.sh
Created February 28, 2014 02:27
Script to deploy blog generated by Hexo and source to same repository
#!/bin/bash
hexo clean
rm -rf .deploy
hexo deploy
git add -A .
git commit -m "Update sources"
git push
@hydra1983
hydra1983 / download_duokan_files.rb
Last active August 29, 2015 13:56
从多看阅读的 **wifi 传书** 中下载上传的文件
# encoding: utf-8
# ----------------------------------------
# 最终的解决方案是利用这个脚本生成的URL,
# 通过迅雷下载所有的文件
# ----------------------------------------
Encoding.default_internal = Encoding::UTF_8
Encoding.default_external = Encoding::UTF_8
#!/bin/bash
HOST=$(hostname)
function install_postfix() {
echo | sudo debconf-set-selections <<__EOF
postfix postfix/root_address string
postfix postfix/rfc1035_violation boolean false
postfix postfix/mydomain_warning boolean
postfix postfix/mynetworks string 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
height="100"
width="100">
<fx:Declarations>
<s:ArrayCollection id="damages">
<fx:Array>
<fx:Object damage="damage1"
@hydra1983
hydra1983 / JaroWinklerDistance.java
Last active December 28, 2015 15:39
Jaro-Winkler Distance
public class JaroWinklerDistance {
public static void main(String[] args) {
String s1 = "MARTHA";
String s2 = "MARHTA";
// String s1 = "MARTHA";
// String s2 = "MARHTA";
// int range = Math.floor(Math.max(s1.length(),s2.length())/2) - 1 = 2;
// int isMatched = (s1.charAt(row) == s2.charAt(col) && Math.abs(row - col) <= range) ? 0 : 1;
// 0 1 2 3 4 5 t
// M A R H T A
@hydra1983
hydra1983 / LongestCommonSubstring.java
Created November 18, 2013 06:27
Longest Common Substring
public class LongestCommonSubstring {
public static void main(String[] args) {
String str1 = "21232523311324";
String str2 = "312123223445";
String lcs = lcs(str1, str2);
System.out.println(lcs);
System.out.println(lcs.length());
}
@hydra1983
hydra1983 / LongestCommonSequence.java
Created November 17, 2013 10:10
Longest Common Sequence
public class LongestCommonSequence {
public static void main(String[] args) {
String str1 = "ABCBDAB";
String str2 = "BDCABA";
String lcs = lcs(str1, str2);
System.out.println(lcs);
System.out.println(lcs.length());
}
@hydra1983
hydra1983 / wildcard_matcher.java
Last active May 27, 2021 08:24
Convert wildcard pattern to regular expression to match strings
public class Main {
public static void main(String[] args) {
test("<html*", "<html></html>");
test("12*?", "12345");
test("12*4?", "12345");
}
private static void test(String pattern, String input) {
Pattern p = Pattern.compile(pattern);
System.out.println(pattern + " : " + input + " matches? "
@hydra1983
hydra1983 / progress-generator
Created August 7, 2013 06:53
An algorithm to generate progress info for tasks. Run with nodejs.
var num = 0;
var num2 = 0.0;
var num3 = 0.0;
var num4 = 0.0;
var num5 = 0.0;
console.log("part1");
var part1 = [{
batchCount : 5
},{