View todo.jsx
var React = require("react");
var allItems = []
allItems.push("Buy ingredients for Crock Pot");
allItems.push("Pick up chair at IKEA");
allItems.push("Go see mom");
class TodoList extends React.Component {
constructor(props){
super(props);
View attack.md

Tested with Chrome, Firefox and Safari.

The following code will not trigger an alert. target.innerHTML = "<script> alert('XSS Attack'); </script>";

The following code will trigger an alert. target.innerHTML = "<img src=x onerror=\"alert('XSS Attack')\" >";

View raspbian.md

Raspbian Strech Lite Quick setup

In order to enable SSH and wifi on first boot we need to add two files to the root folder on the SD card before inserting it into the raspberry.

First, create an empty file named ssh. Then, create a second file called wpa_supplicant.conf. The contents of this file should be

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
View about.md

NodeJS Streams

  • Current implementation is known as streams2.
  • Introduced in node v0.10.
  • "suck" streams instead of "spew" streams.
  • Instead of data events spewing, call read() to pull data from source.
  • When there isn't any data to consume, then read() will return undefined.
  • Adding a data event listener will switch the Readable stream into "old mode", where data is emitted as soon as it is available rather than waiting for you to call read() to consume it. This requires you to handle backpressure problems manually.
  • The pipe method helps write less code and handles back-pressure.
  • If you add an end listener and don't ever read() or pipe(), it'll never emit end.
View install-ruby-1.8.7.sh
#!/bin/sh
# The main issues with Ruby 1.8.7 are that it won't build with Clang,
# and the Net::HTTPS module won't work with modern versions of OpenSSL.
#
# This assumes you have already set up homebrew, and run: xcode-select --install
#brew install homebrew/dupes/apple-gcc42
#brew install libyaml libffi
brew install https://github.com/Homebrew/homebrew-versions/raw/586b7e9012a3ed1f9df6c43d0483c65549349289/openssl098.rb
export CC=/usr/local/bin/gcc-4.2
View a-seeds.exs
# In this example, Video has_many authors.
# Here is the code for creating a video with authors
# using a single call to Repo.insert
Enum.map([
%{"title" => "Elixir", "duration" => 123, "authors" => [
%{"name" => "José Valim"}
]
},
%{"title" => "JavaScript", "duration" => 666, "authors" => [
%{"name" => "Brendan Eich"}
View application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery
protected
def handle_unverified_request
super
raise ActionController::InvalidAuthenticityToken
end
View node.md

#Node.js and the Event Loop

Node.js is a framework for writing server-side JavaScript applications. It is built on top of the V8 JavaScript runtime and uses an event-driven, non-blocking I/O model that makes it perfectly suited for data-intensive real-time applications.

This blog post will describe what non-blocking I/O means and how working with the event loop can help your applications be more efficient.

##The Restaurant

"This [non-blocking I/O] model simplifies access to slow resources in a scalable way that is intuitive to JavaScript programmers and easy to learn for everyone else." - Node Up and Running.

View import_from_wp.rake
desc 'import from WordPress XML file'
task :import_from_wp => :environment do
require 'hpricot'
doc = Hpricot::XML(File.read('wp-export-file.xml'))
posts = (doc/:channel/:item)
posts.each do |post|
p "Post: #{post.at('link').inner_text}"
end
View cart.exs
# from ounce of elixir
#https://www.meetup.com/Women-Who-Code-Tampa/events/233014583/
ExUnit.start
defmodule CartTest do
use ExUnit.Case
test "starts with empty count" do
assert Cart.count_items([]) == 0