Skip to content

Instantly share code, notes, and snippets.

View v2e4lisp's full-sized avatar

Yan Wenjun v2e4lisp

View GitHub Profile
@v2e4lisp
v2e4lisp / *scratch*.txt
Last active December 11, 2015 20:39
Funny stuff
* checkout-these
- howdoi
- requests
- scraperwiki
- gittips
- html-parseing
- lxml
- pyquery
- d3.js
- paper.js
@v2e4lisp
v2e4lisp / hn.py
Created January 30, 2013 17:02
hackernews reader in 10 lines of python code
#!/usr/bin/python
# -*- coding: utf-8 -*-
import requests as rq
from pyquery import PyQuery as pq
hackernews = "http://news.ycombinator.com/rss"
rss = pq(rq.get(hackernews).text)
items = rss.find("item")
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@v2e4lisp
v2e4lisp / eg.py
Created February 1, 2013 10:33
php-lookup: find examples of php functions from official website
import requests as rq
from pyquery import PyQuery as pq
# helper
def unescape(string):
import re
entity_re = re.compile("&(#?)(\d{1,5}|\w{1,8});")
def substitute_entity(match):
from htmlentitydefs import name2codepoint as n2cp
@v2e4lisp
v2e4lisp / test.el
Created February 2, 2013 06:12
python-eval eval python code in the current buffer [Emacs]
(defun python-eval ()
" Eval python code in current buffer.
It seems that the default python-mode doesn't have this function"
(interactive)
(let ((script-py (buffer-file-name))
(tmp-script-py "/Users/wenjunyan/.test-code.py")
(output-buffer "*python-eval-output*"))
(defun save-as-euc-jp ()
(interactive)
(set-buffer-file-coding-system 'euc-jp)
(save-buffer))
(set-language-environment "Japanese")
(set-default-coding-systems 'euc-japan-unix)
(set-terminal-coding-system 'euc-japan-unix)
(set-keyboard-coding-system 'euc-japan-unix)
(set-buffer-file-coding-system 'euc-japan-unix)
(defun save-as-euc-jp ()
(interactive)
(set-buffer-file-coding-system 'euc-jp)
(save-buffer))
@v2e4lisp
v2e4lisp / week-todo-list.org
Last active December 13, 2015 20:48
programming todo list for this week

TODO-list

  • fix bugs of minimap (minimap-kill when kill-buffer)
  • fix bugs of color theme (add function plist-to-alist)
  • write script to auto upload and edit file to my vm
  • requests script to “start and stop work” from command line
  • backbone.js express.js for single page app (yet another HN reader)
  • upload hn.py as a repo
  • Coursera “programming language” homework of week2
  • finish ruby monk
  • find a ruby repo to hack
;; wenjun-yan
(defun get-current-minimap-bufrname ()
(interactive)
(message minimap-bufname))
;; wenjun-yan
(defun get-minimap-active-minimaps ()
(interactive)
(princ minimap-active-minimaps))
(defun adapt-minimap-to-current-buffer ()
(interactive)
(when (null minimap-bufname)
(close-all-minimap-buffer)
(minimap-new-minimap)))
(defun close-all-minimap-buffer ()
(interactive)
(let ((windows (window-list)))