#慣用的なJavaScript, 矛盾しないコードの書き方
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // isDefined(window, 'google'); | |
| // isDefined(window, 'google.maps.places'); | |
| var isDefined = function(parent, name) { | |
| var parts = name.split('.'); | |
| var part = parts.shift(); | |
| var cur = parent; | |
| while (part) { | |
| if (cur[part]) { | |
| cur = cur[part]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="control-group"> | |
| <label class="control-label">Location</label> | |
| <div class="controls"> | |
| <input name="location" type="text" placeholder="City, State, Country" value=""> | |
| <input name="location_city" type="hidden" value=""> | |
| <input name="location_state" type="hidden" value=""> | |
| <input name="location_country" type="hidden" value=""> | |
| <input name="location_lat" type="hidden"> | |
| <input name="location_lng" type="hidden"> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <style> | |
| .w100percent { | |
| } | |
| .w1280px { | |
| } | |
| .w900px { | |
| } | |
| .w768px { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <form id="coursera-form" action="/api/save" enctype="multipart/form-data" method="POST" class="form-horizontal"> | |
| <!-- form inputs here --> | |
| <div class="form-actions"><button type="submit" data-default-message="Save Changes" data-inflight-message="Saving..." data-success-message="Saved!" class="coursera-save-button btn btn-primary" disabled="disabled">Saved!</button></div> | |
| </form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0"?> | |
| <restaurants> | |
| <restaurant name="Pan Africa Market" address="1521 1st Ave, Seattle, WA" lat="47.608940" lng="-122.340141" type="sitdown"/> | |
| <restaurant name="Buddha Thai & Bar" address="2222 2nd Ave, Seattle, WA" lat="47.613590" lng="-122.344391" type="bar"/> | |
| <restaurant name="The Melting Pot" address="14 Mercer St, Seattle, WA" lat="47.624561" lng="-122.356445" type="sitdown"/> | |
| <restaurant name="Ipanema Grill" address="1225 1st Ave, Seattle, WA" lat="47.606365" lng="-122.337654" type="sitdown"/> | |
| <restaurant name="Sake House" address="2230 1st Ave, Seattle, WA" lat="47.612823" lng="-122.345673" type="bar"/> | |
| <restaurant name="Crab Pot" address="1301 Alaskan Way, Seattle, WA" lat="47.605961" lng="-122.340363" type="sitdown"/> | |
| <restaurant name="Mama's Mexican Kitchen" address="2234 2nd Ave, Seattle, WA" lat="47.613976" lng="-122.345467" type="bar"/> | |
| <restaurant name="Wingdome" address="1416 E Olive Way, Seattle, WA" lat="47.617214" lng="-122.326584" type="bar"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0"?> | |
| <nutrition> | |
| <daily-values> | |
| <total-fat units="g">65</total-fat> | |
| <saturated-fat units="g">20</saturated-fat> | |
| <cholesterol units="mg">300</cholesterol> | |
| <sodium units="mg">2400</sodium> | |
| <carb units="g">300</carb> | |
| <fiber units="g">25</fiber> | |
| <protein units="g">50</protein> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Also requires jQuery pasted in the top in Chrome | |
| function loadHearts() { | |
| $('#speakers').hide(); | |
| $('#scene').hide(); | |
| $('#schedule td').each(function() { | |
| var $talkCell = $(this); | |
| var rateLink = $talkCell.find('a'); | |
| if (!rateLink.length) return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urllib | |
| import settings | |
| try: | |
| import json | |
| except ImportError: | |
| import simplejson as json | |
| class YahooException(Exception): | |
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| input_path = 'application/templates' | |
| output_path = 'application/static/js/templates' | |
| os.system('mkdir %s' % output_path) | |
| dir_list = os.listdir(input_path) | |
| for file_name in dir_list: | |
| if file_name.endswith('.handlebars'): | |
| cmd = 'handlebars %s/%s -f %s/%s' % (input_path, file_name, output_path, file_name.replace('handlebars', 'js')) |