Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
// Alternative JavaScript Syntax | |
Person = :(name, address) { @name!, @address! } | |
Person::inspect = :{ <: "{@name} lives at {@address}" } | |
tj := Person('TJ', '314 Bessborough ave') | |
bob := Person('Bob', 'Some place') | |
[tj, bob].each(:(person){ print(person.inspect()) }) |
# Author: Pieter Noordhuis | |
# Description: Simple demo to showcase Redis PubSub with EventMachine | |
# | |
# Update 7 Oct 2010: | |
# - This example does *not* appear to work with Chrome >=6.0. Apparently, | |
# the WebSocket protocol implementation in the cramp gem does not work | |
# well with Chrome's (newer) WebSocket implementation. | |
# | |
# Requirements: | |
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby |
var flattenObject = function(ob) { | |
var toReturn = {}; | |
for (var i in ob) { | |
if (!ob.hasOwnProperty(i)) continue; | |
if ((typeof ob[i]) == 'object') { | |
var flatObject = flattenObject(ob[i]); | |
for (var x in flatObject) { | |
if (!flatObject.hasOwnProperty(x)) continue; |
package main | |
import ( | |
"fmt" | |
"io" | |
"log" | |
"net/http" | |
"os" | |
) |
# JSONP callback for tweets fetched later than current (max_id) | |
window.twitterTimelineLaterCallback = (data) -> | |
window.app.twitterTimeline.receivedData(data, false) | |
# JSONP callback for tweets fetched earlier than current (since_id) | |
window.twitterTimelineEarlierCallback = (data) -> | |
window.app.twitterTimeline.receivedData(data, true) | |
class window.TwitterTimeline | |
# Distance from the bottom that we ask for more tweets, distance from the |
#!/usr/bin/python | |
# All SSH libraries for Python are junk (2011-10-13). | |
# Too low-level (libssh2), too buggy (paramiko), too complicated | |
# (both), too poor in features (no use of the agent, for instance) | |
# Here is the right solution today: | |
import subprocess | |
import sys |
#! /usr/bin/env python | |
import redis | |
import random | |
import pylibmc | |
import sys | |
r = redis.Redis(host = 'localhost', port = 6389) | |
mc = pylibmc.Client(['localhost:11222']) |
""" Run with: | |
gunicorn -k gevent -b 0.0.0.0:8080 test_mc:app | |
or | |
gunicorn -k sync -b 0.0.0.0:8080 test_mc:app | |
""" | |
import memcache as memcache | |
# toggle to try pylibmc instead | |
# import pylibmc as memcache | |
client = memcache.Client(["127.0.0.1:11222", "127.0.0.1:11223"]) |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Wed, 21 Sep 2022 till Thu, 21 Sep 2023.
Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:
githubUsers
.filter(user => user.followers > 1000)