Skip to content

Instantly share code, notes, and snippets.

View lucemia's full-sized avatar

David Chen lucemia

View GitHub Profile
@lucemia
lucemia / gist:7cc5c1e0b2468f24288a
Created June 21, 2015 14:00
藏頭詩產生器簡單版
#-*- coding:utf-8 -*-
import json
from collections import defaultdict
x = json.load(open('gram_select_small.json'))
words = x["1"]
words = words.items()
words.sort(key=lambda i: i[1], reverse=True)
grams = defaultdict(dict)
from console.models import *
cs = Creative.objects.all()
keys = [
'css:.img_footer_body ul .img_footer_page img:width',
'css:.img_footer_body ul .img_footer_page img:height',
'css:.thumb:width',
'css:.thumb:height'
]
notifications:
slack: ''
language: python
python:
- '2.7'
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq libxml2-dev libxslt1-dev
<?xml version='1.0' encoding='UTF-8' ?><!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'><html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'><head><title>Pretty Diff - The difference tool</title><meta name='robots' content='index, follow'/> <meta name='DC.title' content='Pretty Diff - The difference tool'/> <link rel='canonical' href='http://prettydiff.com/' type='application/xhtml+xml'/><meta http-equiv='Content-Type' content='application/xhtml+xml;charset=UTF-8'/><meta http-equiv='Content-Style-Type' content='text/css'/><style type='text/css'>body{font-family:'Arial';font-size:10px;overflow-y:scroll}#announcement.big{color:#00c;font-weight:bold;height:auto;left:14em;margin:0;overflow:hidden;position:absolute;text-overflow:ellipsis;top:4.5em;white-space:nowrap;width:50%;z-index:5}#announcement.big strong.duplicate{display:block}#announcement.big span{display:block}#announcement.normal{color:#000;font-weight:normal;height:2.5em;margin:0 -5em -4.75em;position
(function(d) {
if (typeof tagtoo_advertiser_id != "undefined") {
var tagtooIframe = d.createElement("iframe");
tagtooIframe.src = "//ad.tagtoo.co/static/ad/html/track.html#ad=" + tagtoo_advertiser_id + "&p=" + encodeURIComponent(document.location.href);
tagtooIframe.scrolling = "no";
tagtooIframe.width = 1;
tagtooIframe.height = 1;
tagtooIframe.marginheight = 0;
tagtooIframe.marginwidth = 0;
tagtooIframe.frameborder = 0;
@lucemia
lucemia / gist:2587d8106cc64da58bd4
Created August 7, 2014 17:57
defaultdict with key
from collections import defaultdict
class vdict(defaultdict):
def __missing__(self, key):
return self.default_factory(key)
#!/usr/bin/env python
import dio
import fileinput
import json
from itertools import product
import re
re_name = re.compile(r'\.([\w]+)(.*)')
re_index = re.compile(r'\.\[([\d]*):?([\d]*):?([\d]*)\](.*)')
<link rel="import" href="../google-map/google-map.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
def load_pipeline(cls_path):
module_path, class_name = ".".join(cls_path.split('.')[:-1]), cls_path.split('.')[-1]
mod = __import__(module_path, fromlist=[class_name])
return getattr(mod, class_name)
class TriggerHandler(ApiHandler):
def get(self):
import sys
from collections import defaultdict
def shorten(p):
new_p = [p[0]]
last = p[0]
for c in p:
if c == last:
continue
last = c