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 myApp = { | |
| todos: [ | |
| { | |
| id: 1, | |
| text: 'learn javascript', | |
| complete: false | |
| }, | |
| { | |
| id: 2, | |
| text: 'eat pizza', |
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 someData = '05/15/16'; | |
| var testDate = /\d{2}\/\d{2}\/\d{2}/; | |
| // var someMath = "100 * 33456789"; | |
| // var findMath = /^\d+\s*[\+\-\/\*]\s*\d+$/; | |
| // console.log(findMath.test(someMath)); |
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
| // Use a Person constructor function that must be called with the `new` keyword. | |
| // Prototype link between instances and Person.prototype is implicitly created by calling the Person function with the `new` keyword. | |
| function Person(firstName, lastName) { | |
| this.firstName = firstName; | |
| this.lastName = lastName; | |
| this.isActive = true; | |
| } | |
| Person.prototype.sayName = function() { |
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 pluggedInEvent = new CustomEvent('batterystatus', {'detail': {level: 'low', isPlugged: false}}); | |
| var unpluggedEvent = new CustomEvent('batterystatus', {'detail': {level: 'high', isPlugged: true}}); | |
| window.addEventListener("batterysatatus", onBatteryStatus, false); | |
| function onBatteryStatus(info) { | |
| // The battery level and plugged/unplugged status | |
| // NOTE: the actual event has the level and isPlugged properties directly on the `info` attribute, so when using on device, remove the `detail` attribute so it's like: `info.level` and `info.isPlugged` |
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 "Hi there, what can I do for you?" | |
| while true do | |
| print ">> " | |
| input = gets.chomp.split | |
| command = input[0] | |
| args = input[1..input.length] | |
| case command |
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 Note | |
| attr_accessor :content | |
| def initialize(content) | |
| @content = content | |
| end | |
| def preview | |
| if @content.length < 30 | |
| @content |
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 './todo' | |
| require './todos_list' | |
| todo1 = Todo.new("View RailsGuides", true, :high) | |
| todo2 = Todo.new("Check out the Stack Overflow ruby-on-rails tag", false, :high) | |
| todo3 = Todo.new("Watch 'Game of Thrones' because the books are just too long", true) | |
| todo4 = Todo.new("Read 'Hitchhiker's Guide to the Galaxy'", false) | |
| todos = [todo1, todo2, todo3, todo4] |
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
| todos = {"Check out Ruby docs on String" => "complete", "Check out Ruby docs on Fixnum" => "complete", "Check out Ruby docs on Array" => "incomplete", "Check out Ruby docs on Hash" => "incomplete"} | |
| todos.each do |todo, status| | |
| puts "#{todo}: #{status}" | |
| end | |
| puts "I have a total of #{todos.count} todos." |
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
| #! /bin/bash | |
| tmux start-server | |
| cd ./apprennet-com | |
| tmux new-session -d -s apprennet | |
| # Code window | |
| tmux rename-window -t apprennet:0 code | |
| tmux new-window -t apprennet:1 -n git |
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 ROT13 | |
| def self.translate(string) | |
| output = string.split('').map do |character| | |
| if alphabet.include? character | |
| alphabet[(alphabet.index(character) + 13) % 26] | |
| else | |
| character | |
| end | |
| end.join | |