Skip to content

Instantly share code, notes, and snippets.

View jasonblanchard's full-sized avatar

Jason jasonblanchard

View GitHub Profile
var myApp = {
todos: [
{
id: 1,
text: 'learn javascript',
complete: false
},
{
id: 2,
text: 'eat pizza',
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));
// 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() {
@jasonblanchard
jasonblanchard / batterystatus_mock.js
Last active August 29, 2015 14:21
custom batterystatus event
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`
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
class Note
attr_accessor :content
def initialize(content)
@content = content
end
def preview
if @content.length < 30
@content
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]
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."
#! /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
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