Skip to content

Instantly share code, notes, and snippets.

View yfwu's full-sized avatar

Yu-Fu Wu yfwu

View GitHub Profile
@insin
insin / bash_prompt.sh
Created December 3, 2011 01:49 — forked from woods/git_svn_bash_prompt.sh
Set color bash prompt according to active virtualenv, git branch and return status of last command.
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
@matthewp
matthewp / gist:2324447
Created April 7, 2012 01:43
String Split in Scheme
;;; str-split : Apr 2006 Doug Hoyte, hcsw.org.
;;; ----
;;; Splits a string 'str into a list of strings
;;; that were separated by the delimiter character 'ch
;;; ----
;;; Efficient as possible given that we can't count on
;;; 'str being an immutable string.
(define (str-split str ch)
(let ((len (string-length str)))
@bmabey
bmabey / user_agent.clj
Created October 24, 2012 15:55
Example of using the java lib UserAgentUtils in clojure to parse user agent strings
(ns rbl.feature-extraction.user-agent
(:use [clojure.core.memoize :only [memo]])
(:require [clojure.tools.logging :as log])
(:import [nl.bitwalker.useragentutils UserAgent DeviceType Browser OperatingSystem]))
(defn str->features [string]
(try
(let [user-agent (UserAgent. (or string ""))]
{:browser_group (-> user-agent .getBrowser .getGroup .getName)
:os_group (-> user-agent .getOperatingSystem .getGroup .getName)
@pudquick
pudquick / pipista.py
Created November 20, 2012 07:23
pipista - pip module (for installing other modules) for Pythonista
import os, os.path, sys, urllib2, requests
class PyPiError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
def _chunk_report(bytes_so_far, chunk_size, total_size):
if (total_size != None):
@yfwu
yfwu / cqx001.py
Last active December 27, 2015 03:39
底下的程式碼用於取得以 utf-8 編碼的網頁原始碼以即截取出內涵的資料。
#!/usr/bin/env python
import re
from urllib.request import urlopen
# Get the webpage's source html code
source = 'http://www.goodinfo.tw/stockinfo/StockDividendSchedule.asp?STOCK_ID='
ID = '2002'
filename = ID+'.html'
result = urlopen(source+ID).read().decode("big5")#.encode("utf8")
@withr
withr / server.R
Last active June 12, 2024 23:52
Encrypt password with md5 for Shiny-app.
library(shiny)
library(datasets)
Logged = FALSE;
PASSWORD <- data.frame(Brukernavn = "withr", Passord = "25d55ad283aa400af464c76d713c07ad")
# Define server logic required to summarize and view the selected dataset
shinyServer(function(input, output) {
source("www/Login.R", local = TRUE)
observe({
if (USER$Logged == TRUE) {
@10long
10long / geeknote.el
Created February 17, 2014 03:39
geeknote call inside emacs
;; geeknote ==============================================================
(defun geeknote-mode ()
(interactive)
(eshell-command "python ~/geeknote/geeknote.py settings --editor /Applications/Emacs.app/Contents/MacOS/bin/emacsclient")
)
(defun geeknote-create (newnote)
(interactive "sname: ")
(eshell-command
(format "python ~/geeknote/geeknote.py create --content WRITE --title %s" newnote))
import subprocess
import select
from threading import Thread
from cStringIO import StringIO
def read_stream(stream, output_stream, log_func):
while True:
r, w, x = select.select([stream.fileno()], [], [], 1.0)
if not r:
@emallson
emallson / nodejs-repl-eval.el
Created May 30, 2014 02:30
Evaluation functions for the `nodejs-repl' Emacs package.
;;; nodejs-repl-eval.el --- Summary
;;; Commentary:
;;;
;;; Evaluation functions for the `nodejs-repl' package. Written on a stormy
;;; night between days of node hacking.
;;;
;;; Code:
(require 'js2-mode)
(require 'nodejs-repl)
@kanru
kanru / diary-sync-ical.el
Created January 22, 2015 11:54
Sync icalendar to diary file
;;; diary-sync-ical.el --- Sync iCalendar to diary -*- lexical-binding: t; -*-
;; Copyright (C) 2015 Kan-Ru Chen (陳侃如)
;; Author: Kan-Ru Chen (陳侃如) <kanru@kanru.info>
;; Keywords:
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or