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
| class Tiddler | |
| # @ is shorthand for this.title = title | |
| constructor: (@title, @bag) -> | |
| # Other properties attached to prototype | |
| text: "" | |
| tags: [] | |
| # toString() function returns properties | |
| # Fat arrow ensures 'this' inside the function is always bound to the instance |
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
| function NewPane(sub, socketuri, dontcache) { | |
| var type = sub.charAt(0), | |
| uri = '/search?q=', | |
| cached = localStorage.getItem('tapas'), | |
| socket, title, el; | |
| cached = (cached && cached.split(',')) || []; | |
| cached.push(sub); | |
| if (!dontcache) { | |
| localStorage.setItem('tapas', cached.join(',')); | |
| } |
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
| var injector = angular.element('[data-ng-app="myAppName"]').injector(); | |
| var dependency = injector.get('myDependencyName'); | |
| dependency.doSomething(); |
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
| var hands = [ | |
| 'rock', | |
| 'paper', | |
| 'scissors', | |
| 'water', | |
| 'dynamite' | |
| ]; | |
| var opponents = [] |
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
| puts gets.to_i.to_s(2) | |
| # | |
| # Best solution found: | |
| # | |
| #puts"%b"%gets |
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
| App.MyModel.eachRelationship (name, relationship) -> | |
| relationshipInstance = modelInstance.get name | |
| if relationshipInstance | |
| if relationship.kind is 'belongsTo' | |
| relationshipInstance.rollback() | |
| else if relationshipInstance.content and relationship.kind is 'hasMany' | |
| relationshipInstance.content.forEach (record) -> | |
| record.rollback() |
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
| # Ember data does not dirty the parent model if any of it's children change so | |
| # no rollback can occur for a child. This fixes this by resetting a child's | |
| # data to the internal data tracked by the parent model. | |
| DS.Model.reopen | |
| rollbackBelongsTo: (relationshipName) -> | |
| thisName = @constructor.typeKey | |
| relationshipInstance = @get relationshipName | |
| # Rollback any attributes that were changed in the relationship | |
| relationshipInstance.rollback() |
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
| require 'csv' | |
| csv_contents = CSV.read('Data.csv') | |
| # Shift 3 rows of headers to get to the data | |
| csv_contents.shift | |
| csv_contents.shift | |
| csv_contents.shift | |
| set1 = [] | |
| set2 = [] |
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
| require 'csv' | |
| # Iterate through each CSV file in the current folder | |
| Dir.glob('*.csv') do |csv_filename| | |
| # Create and open a new file to store the modified rows | |
| csv_output_file = CSV.open("modified-#{csv_filename}", 'wb') | |
| # Open the current file by filename | |
| CSV.open(csv_filename, 'r') do |csv_contents| | |
| # Iterate through each row in the CSV file | |
| csv_contents.each do |row| |
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
| $tooltipProvider.setTriggers({ | |
| // other trigger config | |
| 'customOpen':'customClose' | |
| }); |