Skip to content

Instantly share code, notes, and snippets.

View lotabout's full-sized avatar

Jinzhou Zhang lotabout

View GitHub Profile
@lotabout
lotabout / send-to-download.js
Last active August 12, 2022 11:33
Greasemonkey script for send content to backend localhost.
// ==UserScript==
// @name Post test
// @namespace jinzhou
// @description Post Test
// @include *
// @version 1
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// ==/UserScript==
@lotabout
lotabout / simple_server.py
Last active December 18, 2015 10:22
A simple server based on BaseHTTPServer
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
from urlparse import parse_qs
PORT_NUMBER = 8000
class MyHandler(BaseHTTPRequestHandler):
@lotabout
lotabout / runner.py
Last active December 18, 2015 09:33
check the network speed of a running process(actually is IO speed) and if it is slow, restart the process. (the command should support continous download)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess as sp
import time
import re
import sys
import signal
# global configuration
@lotabout
lotabout / mail-executor.py
Created December 12, 2015 12:47
for Raspberry Pi: check mail and execute (download) tasks.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# We will need 3 threads
import os
import Queue
from os.path import isfile, join
import email
import re
@lotabout
lotabout / git-pick.sh
Created November 30, 2015 06:32
Pick current commit to other branches
#!/bin/bash
# This script will pick commits from current branch(default) to other
# specified branch.
# Usage:
# git-pick.sh -<num> -- pick <num> commits start from HEAD
# git-pick.sh <commit range, etc> -- pick the correspondidng commits
# git-pick.sh -- default: pick commits
#
--exclude=.git
--exclude=.hg
--exclude=log
--exclude=tmp
--languages=-javascript,sql
--langdef=clojure
--langmap=clojure:.clj
--regex-clojure=/\([ \t]*create-ns[ \t]+([-[:alnum:]*+!_:\/.?]+)/\1/n,namespace/
@lotabout
lotabout / settings.xml
Created April 21, 2015 07:14
.m2/settings.xml for maven glassfish plugin.
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>glassfish-context</id>
<properties>
<local.glassfish.home>C:\\glassfish3\\glassfish</local.glassfish.home>
<local.glassfish.user>admin</local.glassfish.user>
@lotabout
lotabout / maven-glassfish-plugin.pom.xml
Created April 21, 2015 07:14
Pom configuration for maven glassfish plugin
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>jp.co.worksap</groupId>
<artifactId>STBook</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>STBook Maven Webapp</name>
<url>http://maven.apache.org</url>
@lotabout
lotabout / hibernate3-maven-plugin.pom.xml
Created April 19, 2015 08:00
example pom.xml for hibernate3-maven-plugin
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mkyong.common</groupId>
<artifactId>Hibernate</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Hibernate</name>
@lotabout
lotabout / print_seq.c
Created April 2, 2015 12:22
print sequence in order.
#include <stdio.h>
#include <malloc.h>
#include <string.h>
void print_seq(int seq[], int len)
{
int *indices = (int *)malloc(sizeof(int) * (len+1));
memset(indices, 0, sizeof(int)*(len+1));
int i;