Skip to content

Instantly share code, notes, and snippets.

View lucemia's full-sized avatar

David Chen lucemia

  • GliaCloud
  • Taipei / Vancouver
View GitHub Profile
@lucemia
lucemia / private-package-b's pyproject.toml
Created December 15, 2023 04:49
Poetry Dependency Resolution Issue while Dependency extras with source
[tool.poetry]
name = "private-package-b"
version = "0.0.0"
description = ""
[tool.poetry.dependencies]
private-package-a = { version = "*", source = "source-a" }
[[tool.poetry.source]]
name = "source-a"
from __future__ import absolute_import
import rules
from employee.rules import is_project_owner, is_director, is_g3, is_g4, is_bp, is_user, is_team_leader, is_division_manager, is_superuser, is_employee
from .models import Document, Project
from django.db.models import Q
from django.core.cache import cache
import json
def has_perm_projects(user__id):
#!/usr/bin/env python
import sys
from collections import Counter
import re
from blessings import Terminal
term = Terminal()
def show(counter):
with term.fullscreen():
from pyspark import SparkContext
logFile = "gs://tagtoo-track-log/log2bq-2014120100*"
sc = SparkContext()
logData = sc.textFile(logFile).cache()
print logData.count(), logData.first()
@lucemia
lucemia / gist:4a2e7a854caa7d6ec81f
Last active October 14, 2015 23:28
run mapreduce in bigquery
function mapper(row, emit) {
if(row.comment) {
keywords = row.comment.split(' ');
for(var i=0; i<keywords.length; i++) {
emit({keyword: keywords[i], count: 1});
}
}
}
function reducer(row, emit) {
def c(n, r):
print n, r
if r == 1: return n
if n == r: return 1
return c(n-1, r) + c(n-1, r-1)
# can compute it on time
print c(5, 2)
$('.link').on({
click: function(e) {
e.stopPropagation();
var id = $(this).parents('.item')[0].id;
id = parseInt(id.replace('item-', ''));
Ad.click(data[id]['url']);
}
});
Ad.statemachine = StateMachine.create({
initial: 'Slideshow',
error: function() {},
events: [{
name: 'Slideshow',
from: 'Detail',
to: 'Slideshow'
}, {
name: 'Slideshow',
from: 'Highlight',
var SlideShow = function(objs, option) {
/*
objs, the element to do the slide
*/
var index = 0;
var page_size = option.page_size;
var interval = option.interval || 1000;
var fade_time = option.fade_time || 300;
var timeout = option.timeout || 30000;
store = {}
def g(w, h, odd=True):
if w <= 0 or h <= 0:
if odd: return 0
return 1
if not odd:
return (h+1)**w - g(w, h)