Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| // This file contains utilities for creating bound helpers | |
| // For reference: https://github.com/wagenet/ember.js/blob/ac66dcb8a1cbe91d736074441f853e0da474ee6e/packages/ember-handlebars/lib/views/bound_property_view.js | |
| Ember.Handlebars.BoundHelperView = Ember.View.extend(Ember._Metamorph, { | |
| context: null, | |
| options: null, | |
| property: null, | |
| // paths of the property that are also observed | |
| propertyPaths: [], |
| /* description: Basic multi-line calculator */ | |
| %lex | |
| %% | |
| [^\n\S]+ /* ignore whitespace */ | |
| [0-9]+ { return 'INT' } | |
| (\n|\;) { return 'TERMINATOR' } | |
| "-" { return '-' } | |
| "+" { return '+' } |
| #!/usr/bin/env sh | |
| ## | |
| # This is script with usefull tips taken from: | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # | |
| # install it: | |
| # curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
| # |
I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.
If you want to roll up all of these into a single jQuery plugin check out Sharrre
Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.
(rough-cut for Backbone Fundamentals)
As we learned earlier in the book, the validate method on a Model is called before set and save, and is passed the model attributes updated with the values from these methods.
By default, where we define a custom validate method, Backbone passes all of a Model's attributes through this validation each time, regardless of which model attributes are being set.
This means that it can be a challenge to determine which specific fields are being set or validated without being concerned about the others that aren't being set at the same time.
| @media only screen and (min-width: 320px) { | |
| /* Small screen, non-retina */ | |
| } | |
| @media | |
| only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px), | |
| only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px), | |
| only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px), |
| <?php | |
| // Install me via cron: | |
| // MAILTO=somewhere@important.com | |
| // * * * * * /usr/local/bin/php /home/someaccount/loadwatch.php | |
| $fields = explode(' ', file_get_contents('/proc/loadavg')); | |
| $avg = $fields[0]; | |
| $last = @file_get_contents("/home/gps/cpulast.txt"); |
| /** | |
| * The MIT License (MIT) | |
| * | |
| * Copyright (c) 2013 Thom Seddon | |
| * Copyright (c) 2010 Google | |
| * | |
| * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| * of this software and associated documentation files (the "Software"), to deal | |
| * in the Software without restriction, including without limitation the rights | |
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| # install dependencies | |
| sudo apt-get install libcurl4-openssl-dev libncurses5-dev pkg-config automake yasm | |
| # clone cpuminer | |
| git clone https://github.com/pooler/cpuminer.git | |
| # compile | |
| cd cpuminer | |
| ./autogen.sh | |
| ./configure CFLAGS="-O3" |