klenwell information services : CocktailNapkin2013

Wiki source for CocktailNapkin2013


Show raw source

=====2013 Cocktail Napkin=====
Return to SpecialCocktailNapkin

**Ansible Setup**
~- MySQL: [[https://github.com/fourkitchens/server-playbooks | github.com]] [[http://stackoverflow.com/q/16444306/1093087 | stackoverflow.com]]
~- PHP
~- phpinfo script
~- db script
~- ##mkdir -pv deployment/roles/common/{tasks,handlers,templates,files,vars}##
~- ##mkdir -pv deployment/roles/{system,webserver,rails}/{tasks,handlers,templates,files,vars}##

**++Un++published Comment**
response to https://news.ycombinator.com/item?id=6571678
----
Here's an interesting point made about Arab Spring:

//While the poor struggle to survive from day to day, disappointed middle-class people are much more likely to engage in political activism to get their way.

This dynamic was evident in the Arab Spring, where regime-changing uprisings were led by tens of thousands of relatively well-educated young people. Both Tunisia and Egypt had produced large numbers of college graduates over the past generation. But the authoritarian governments of Zine El Abidine Ben Ali and Hosni Mubarak were classic crony-capitalist regimes, in which economic opportunities depended heavily on political connections. Neither country, in any event, had grown fast enough economically to provide jobs for ever-larger cohorts of young people. The result was political revolution.

None of this is a new phenomenon. The French, Bolshevik and Chinese Revolutions were all led by discontented middle-class individuals, even if their ultimate course was later affected by peasants, workers and the poor.//

I think both Occupy and Tea Party movements fit this model. College kids mired in debt who can't find decent jobs. Aging white middle class conservatives watching the financial class run away with the lion's share of economic growth (while being led to believe that's it's being siphoned off by immigrants, welfare queens, and gay married couples).

Also brings to mind the old "Revolution to Conserve" idea I was introduced to back in AP American History:

http://en.wikipedia.org/wiki/Clinton_Rossiter
----

**Kinetic Scaling**
~- For dragbounds, see https://github.com/ericdrowell/KineticJS/issues/216
~- Demo: http://www.html5canvastutorials.com/kineticjs/html5-canvas-kineticjs-scale-animation-tutorial/
~- Phonegap: http://w2davids.wordpress.com/html5-mobile-web-canvas-animation-using-phonegap-kinetic-js/
~- Scaling Demos
~~- http://stackoverflow.com/a/13663169/1093087
~~- http://stackoverflow.com/a/13895418/1093087

**Parasitic Simulation with KineticJS**
http://jsfiddle.net/klenwell/JvG2Z/
HTML
%%
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Sim</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="basic.css">
</head>

<body>
<div id="app-stage"></div>
<button id="stop-button">stop</button>

<!-- Javascript Here -->
<script src="kinetic-v4.7.1.js"></script>
<script src="fiddle.js"></script>
</body>
</html>
%%
CSS: basic.css
%%
div#app-stage .kineticjs-content {
margin:0 auto;
background-color:#EEEEEE;
border:1px solid #DDDDDD;
}
%%

** HocObject Neo-Parasitic Inheritance**
http://jsfiddle.net/klenwell/RV4a3/
http://jsfiddle.net/klenwell/MsTay/

**Javascript Parasitic Instance Inference**
I'm trying to develop a simple parasitic interface for my javascript classes modelled after Crockford and I'd like to implement some basic introspective methods. Given the class hierarchy below, how can I write class_name and is_a methods that correctly identify the object class? ... This question provides some additional information about my approach.
~- Stack Overflow: http://stackoverflow.com/q/18922197/1093087
~- Question: http://jsfiddle.net/xhcC2/
~- Solution: http://jsfiddle.net/F98Jz/1/

**Javascript Inheritance**
http://jsfiddle.net/AvdK2/4/
http://jsfiddle.net/SSDgv/23/
http://stackoverflow.com/questions/18776989/
~- http://www.crockford.com/javascript/inheritance.html
~- http://stackoverflow.com/questions/8165181/
~- http://stackoverflow.com/questions/5842654/
~- http://stackoverflow.com/questions/812961/
~- http://javascriptweblog.wordpress.com/2010/11/15/extending-objects-with-javascript-getters/
~- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty
~- https://github.com/ericdrowell/KineticJS/blob/master/src/Global.js

**Weather Data**
~- Requires token for NOAA (they're free): http://www.ncdc.noaa.gov/cdo-web/token
~- Data Services: http://www.ncdc.noaa.gov/cdo-services/services/datasets?token=Uvz...
~- Location Search: http://www.ncdc.noaa.gov/cdo-services/services/datasets/GHCND/locationsearch?_type=json&latitude=33.7408&longitude=-117.8814&radius=10&token=Uvz...
~- Data Types for Zip: http://www.ncdc.noaa.gov/cdo-services/services/datasets/GHCND/locations/ZIP:92701/datatypes?_type=json&token=Uvz...
~- Daily Historical Data by Zip: http://www.ncdc.noaa.gov/cdo-services/services/datasets/GHCND/locations/ZIP:92705/data?_type=json&year=1972&month=05&startday=22&endday=22&token=Uvz...
~- Daily Historical Data by Station: http://www.ncdc.noaa.gov/cdo-services/services/datasets/GHCND/stations/GHCND:USC00047888/data?_type=json&year=1972&month=05&startday=22&endday=22&token=Uvz...
~- Historical Daily High Temp for Month (Tenths of C): http://www.ncdc.noaa.gov/cdo-services/services/datasets/GHCND/stations/GHCND:USC00047888/datatypes/TMAX/data?_type=json&year=1972&month=05&token=Uvz...

%%(python)
"""
Get high temperatures from a given weather station
"""
from datetime import datetime
import time
import requests
from pprint import pprint


noaa_url = 'http://www.ncdc.noaa.gov/cdo-services/services'
noaa_service_f = 'datasets/GHCND/stations/%s/datatypes/TMAX/data'
token = 'YOUR TOKEN HERE'
station_id = 'GHCND:USC00047888'
api_rate_limit = 1.25 # seconds




def c10_to_f(value):
c = value / 10.0
f = c * (9.0 / 5) + 32
return '%.1f' % (f)


def get_tmax_data(station_id, start, stop=None):
records = []
start_year, start_month = start

if stop:
stop_year, stop_month = stop
else:
now = datetime.now()
stop_year, stop_month = now.year, now.month

months = range(1,13)
years = range(start_year, stop_year+1)

qstring_f = '_type=json&year=%d&month=%02d&token=%s'

noaa_service = noaa_service_f % (station_id)
base_url = '%s/%s' % (noaa_url, noaa_service)

ymd_f = '%Y-%m-%d'
min_date = datetime.strptime('%d-%02d-01' % (start_year, start_month), ymd_f)
max_date = datetime.strptime('%d-%02d-01' % (stop_year, stop_month+1), ymd_f)

for y in years:
for m in months:
# skip if date is too early
my_date = datetime.strptime('%d-%02d-15' % (y,m), '%Y-%m-%d')
if my_date < min_date:
continue

# stop if date is too late
if my_date > max_date:
break

qstring = qstring_f % (y, m, token)
request_url = '%s?%s' % (base_url, qstring)
print y, m, request_url

r = requests.get(request_url)
data = r.json()['dataCollection']['data']

for i,datum in enumerate(data):
dated = datum['date'].split('T')[0]
value = datum['value']
f = c10_to_f(value)
record = (dated, '%.1f' % (value), f)
records.append(record)

time.sleep(api_rate_limit)

return records


#
# Tests
#
pprint(get_tmax_data(station_id, (2013,8)))
%%

**Colors**
~- http://jsfiddle.net/SMrLk/1/

**Wine Recommendation**
~- http://www.chateaustjean.com/ (Sue, 2012.11.09)

**jTable Factory**
http://jsfiddle.net/rHmh6/1/

**Wikka Tasks Interface**
~- A ##tasks.php## script to run tasks in backend.
~- A ##tasks## directory in which to place them
~- A Tasks interface, like Actions, by which to define them

**CSS Balls**
http://jsfiddle.net/ZCR2H/17/

**jQuery $.when**
http://jsfiddle.net/3b2t9/4/
http://stackoverflow.com/a/9865124/1093087
http://stackoverflow.com/a/755913/1093087

**Javascript: String Objects vs String Literals**
http://stackoverflow.com/questions/3297867/
http://jsfiddle.net/E8DAW/1/

**Browser Storage Options**
~- [[http://csimms.botonomy.com/2011/05/html5-storage-wars-localstorage-vs-indexeddb-vs-web-sql.html | localStorage v. IndexedDB v. Web SQL]] (csimms.botonomy.com)
~- http://diveintohtml5.info/storage.html
~- http://stackoverflow.com/questions/5924485/

**Jenkins Variables**
$WORKSPACE
$VIRTUAL_ENV
[[https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-JenkinsSetEnvironmentVariables | Others]]

**Android Browser Translation App**
I'm looking for one: http://android.stackexchange.com/q/46414/35024

**The Locust Economy**
~- http://www.ribbonfarm.com/2013/04/03/the-locust-economy/
//There seems to be an implicit holier-than-thou assumption among sharing economy evangelists that social sharing is primarily about virtuous behaviors like generosity, empathy, minding the planet, conserving resources, avoiding waste and so forth. Only secondarily do they see it as a zero-sum/negative-sum adaptation to recessionary conditions -- Bruce Sterling's favela chic.//
~- Wage Service Scheduling Siphon: [[http://www.nytimes.com/2012/10/28/business/a-part-time-life-as-hours-shrink-and-shift-for-american-workers.html?pagewanted=all&_r=0 | A Part-Time Life, as Hours Shrink and Shift (nytimes.com)]]
~- High Frequency Trading Algorithms
~- Ticket Bots: [[http://www.nytimes.com/2013/05/27/business/media/bots-that-siphon-off-tickets-frustrate-concert-promoters.html | Concert Industry Struggles With 'Bots' That Siphon Off Tickets (nytimes.com)]]

**Personal Breathalyzers**
Was joking we need an app for this with talk of lowering legal BAC limit. Then it occurred to me to google it. Found:
~- [[http://www.pcmag.com/article2/0,2817,2417229,00.asp | Coming Smartphone Dongle (pcmag.com)]]
~- [[http://www.wired.com/reviews/2010/04/pr_roundup_breathalyzers/ | Wired Article from 2010 (wired.com)]]

**Red/Blue/Mainstream Marketing**
Listening to KUSC classical public radio fundraiser where they mentioned some dead commercial classical radio stations. Why have commercial classical radio stations died? Because, I'm guessing, blue (affluent, college-educated, progressive/liberalish) listeners won't listen to commercials. //Unless// they come in the form of discreet underwriting.

Surely upscale advertisers want to reach this blue audience as much as they ever have. It's just that blue audience will be receptive to them only under certain conditions, which exclude the sort crude advertisements listeners of mainstream and talk radio are prepared to endure.

How does underwriting revenue compare to old traditional commercial advertising revenue? Significantly less? More? Factor in difference between profit and not-for-profit station setups. Is it roughly comparable? My guess is that it is as lucrative, in terms of providing income for actual employees, as it ever was. But probably a slimmed-down operation (e.g., much smaller advertising dept that now goes under a different name) and no investors involved (so they will look elsewhere for their passive income.)

**An Introduction to the Raphael JS Library**
[[http://net.tutsplus.com/tutorials/javascript-ajax/an-introduction-to-the-raphael-js-library/ | http://net.tutsplus.com/]]
http://jsfiddle.net/htH9j/6/
http://jsfiddle.net/rKMq5/1/
http://jsfiddle.net/6nxdV/1/

**Google App Engine 1.7.6**
~- "a new requirement for the new dev_appserver is [[http://pythonhosted.org/pyobjc/install.html | PyObjC]]" ([[http://www.reddit.com/r/AppEngine/comments/1am9f8/app_engine_176_released/c8z06k8 | reddit.com]])
~- http://code.google.com/p/appengine-devappserver2-experiment/issues/list

**(Un)Discarded Comments**
[[https://news.ycombinator.com/item?id=5456940 | response]] to [[https://news.ycombinator.com/item?id=5456640 | HN comment]]
----
The point here is that these drugs haven't been tested for their safety, much less their efficacy. They are still at an early testing stage. The researchers seem to have a reasonable theory for why they believe they will be effective. But molecular biology is complicated and the risk for harmful effects in humans is not trivial.

Ben Goldacre's book Bad Pharma details the serious personal and social costs that come with poor drug trials. Everyone urging the abandonment of caution here seems to assume this new drug already works or, at the very least, the effects of its usage could not be worse than the grim prognosis patients already confront. But that's what proper trials are meant to establish. Snake oil can come in pill form, too. And even with the current regulations, we've ended up with a number of ineffective, expensive, and sometimes deadly drugs on the market.
----

**Python Chess Icons**
[[http://en.wikipedia.org/wiki/Chess_symbols_in_Unicode | White icons]]
%%(python)
>>> icons = ['\xe2\x99\x94', '\xe2\x99\x95', '\xe2\x99\x96', '\xe2\x99\x97', '\xe2\x99\x98', '\xe2\x99\x99']
>>> icons
['\xe2\x99\x94', '\xe2\x99\x95', '\xe2\x99\x96', '\xe2\x99\x97', '\xe2\x99\x98', '\xe2\x99\x99']
>>> print ' '.join(icons)
%%
As html: ♔ ♕ ♖ ♗ ♘ ♙

**Call For Companies that Do Developer Training**
~- [[http://www.reddit.com/r/learnprogramming/comments/1am1qi/im_trying_to_find_recommendations_for_companies/ | Reddit thread]]
~- [[https://news.ycombinator.com/item?id=5408577 | Hacker News thread]]

**Tar with Absolute Paths**
see http://klenwell.com/press/2013/03/tar-with-absolute-paths/

**Discarded Comments**
response to [[http://news.ycombinator.com/item?id=5280149 | HN comment]]
----
//One solution that's been proposed is the increased use of HSAs + high deductible policies. That way people are paying their expenses out of pocket (for the day-to-day things at least), and are therefore more likely to shop around.//

This is a solution that's being implemented: the corporation I work for started pushing these a couple years ago and I signed up because they are much cheaper than the HMO alternatives (whose premiums significantly jumped that year). Corp also offered a sort of signing bonus ($500 in your HSA). Plus I'm single, in good health, and plan to do everything I can to avoid using the medical system.

You can't really comparison shop serious procedures and if I actually thought I needed real medical care, I would have signed up for one of the more expensive HMOs.

These HSA plans seem better designed to make consumers more conscious of the costs as a way to discourage gratuitous procedures (a big problem that was focus of recent Time article) and promote more preventative care.
----

response to [[http://news.ycombinator.com/item?id=5279584 | HN comment]]
----
I help manage my grandmother's finances. Her health care is covered under Kaiser through the large corporation with which he retired.

I would guess over the last 5 years the amount that has been billed for her medical care has outstripped the amount of money I've made. Easily. The truth is: I have no idea. I don't think she's ever seen a medical bill in that time, apart from an incidental co-pay perhaps. Kaiser handles everything and I'm guessing pulls the money directly from Medicare.

I'm glad to see attention finally being given to the issue of transparency. There seems to be a media swell building around this recent Time article. And in my own experience, I signed up for a cheaper, high deductible plan at work that my company strongly pushed -- I suspect, in large part, because it made costs more tangible.

Like calorie counts posted on menus, it won't solve the issue, but I expect it will help nibble at the edges.
----

**Online Mysql Designer**
http://ondras.zarovi.cz/sql/demo/

**Group Overlapping Circles**
http://stackoverflow.com/q/14607317/1093087

%%(python)
center_pts = [(-2,2), (-2,2), (0,0), (4,1), (6,2), (7,1)]

overlapping_circle_pts = [
(center_pts[0], center_pts[1]),
(center_pts[0], center_pts[2]),
(center_pts[1], center_pts[0]),
(center_pts[1], center_pts[2]),
(center_pts[2], center_pts[0]),
(center_pts[2], center_pts[1]),
(center_pts[2], center_pts[3]),
(center_pts[3], center_pts[2]),
(center_pts[4], center_pts[5]),
(center_pts[5], center_pts[4]),
]

expected_clusters = [
((-2,2), (-2,2), (0,0), (2,1)),
((6,2), (7,1))
]


def cluster_overlaps(nodes, adjacency_list):
connections = []

while len(nodes):
node = nodes[0]
path = dfs(node, adjacency_list, nodes)

# append path to connected_nodes
connections.append(path)

# remove all nodes from
for pt in path:
nodes.remove(pt)

return connections


def dfs(start, adjacency_list, nodes):
"""ref:
http://code.activestate.com/recipes/576723-dfs-and-bfs-graph-traversal/"""
path = []
q = [start]
while q:
node = q.pop(0)

# cycle detection
if path.count(node) >= nodes.count(node):
continue

path = path + [node]

# get next nodes
next_nodes = [p2 for p1,p2 in adjacency_list if p1 == node]
q = next_nodes + q

return path

print cluster_overlaps(center_pts, overlapping_circle_pts)
%%

**Centroid**
%%(python)
def centroid(pts):
fl = lambda n: float(n)
ir = lambda n: int(round(n))

xs = [fl(x) for x,y in pts]
ys = [fl(y) for x,y in pts]

x,y = (sum(xs) / len(pts), sum(ys) / len(pts))
return (ir(x), ir(y))
%%

**Discarded Comment**
In response to [[http://news.ycombinator.com/item?id=5126731 | HN comment]] on [[http://chronicle.com/article/I-Will-Ruin-Him/136693/ | article]]:
----
I'd be cautious extending this guy too much sympathy. He makes his stalker out to be something like Sean Hannity's incarnation of evil (a foul-mouthed female radical Iranian Islamo-extremist) where the truth, as others have pointed out, is probably less salacious: she's mentally ill. Moreover, I don't know about you, but most Persians I've met haunting the MFA programs of this country aren't Muslim jihadis but more like the Kardashians.
----

**Discarded Comment**
In response to this [[http://news.ycombinator.com/item?id=5104331 | HN comment]]:
----
One of the interesting things I learned taking anthropology class as an undergraduate was the difference between sharing and gift-exchange. We studied some indigenous cultures in Papua New Guinea and where before I would have looked at their cultural practices and naively classified them as some form of communal sharing, I was taught to see them as involving elaborate forms of gift exchange. Gift exchange seemed to me much more complicated and personally taxing than more commercial forms of exchange using money.

If "disruptive online services" can filter out some of the social and emotional complexity involved in exchanging services, I think they've more than earned their fee. But I don't think the transition between loaning your couch to a friend and renting it out to him is as straight forward as suggested. I suspect the difference in the way money gets distributed among the various parties is among the least important factors that enters into such a bargain.

But then I see your point. Where before you might feel obligated to help out a friend down on his luck and needing a bit of assistance, Airbnb gives you a ready pretext for doing something more impersonal and efficient.
----

**A Statistical Survey of Small Business Openings and Closings Correlated by Storefront Address**
----

**The Legal and Logical Implications of the Word Only in English Colloquial Usage**
----