Skip to content

Instantly share code, notes, and snippets.

Avatar

Avand Amiri avand

View GitHub Profile
View twitter_controller.rb
require 'oauth/consumer'
require 'json'
class TwitterController < ApplicationController
before_filter :require_no_authentication
TWITTER_AUTH_KEY = '...'
TWITTER_AUTH_SECRET = '...'
TWITTER_AUTH_URL = 'http://twitter.com'
View gist:59cef760acb2adfd1e8fea017e779a30
Stream URL: rtmp://rtmp-api.facebook.com:80/rtmp/389171898089182?ds=1&s_l=1&a=ATipJJZm6SMHA-jU
Server URL: rtmp://rtmp-api.facebook.com:80/rtmp/
Stream Key: 389171898089182?ds=1&s_l=1&a=ATipJJZm6SMHA-jU
View movie-favorites-event-2.js
var aladdin = document.querySelector(".aladdin");
var terminator = document.querySelector(".terminator");
aladdin.addEventListener("click", getMovie);
terminator.addEventListener("click", getMovie);
// ...and so on for each movie
// One event handler to rule them all...
function getMovie(event) {
var clickedMovie = event.target;
View movie-favorites-event-1.js
// Assuming there's an <img class="aladdin"> on the page...
var aladdin = document.querySelector(".aladdin");
aladdin.addEventListener("click", getAladdin);
// You'll have multiple event handlers...
function getAladdin(event) {
$.get("http://omdbapi.com/?i=tt0103639", displayResults);
}
View movie-favorites-ajax.js
$.get("http://omdbapi.com/?i=tt0103639", displayResults);
function displayResults(results) {
console.log(results.Title);
console.log(results.Year);
console.log(results.Rated);
console.log(results.Runtime);
console.log(results.Plot);
}
View movie-favorites-jquery.html
<head>
<meta charset="utf-8">
<title>Movie Favorites</title>
<link rel="stylesheet" href="styles.css" media="screen">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
View avand.json
{
"name": "Avand Amiri",
"bio": "Hi there, my name is Avand!",
"image": "http://avandamiri.com/images/avand.jpg"
}
View split.js
// This is a string... (looks like a list but still a string)
var animalsString = "cow,dog,horse,moose,rooster";
// Turn the string into an array...
var animalsArray = animalsString.split(",");
// Now you can go about looping, like normal...
for (var i = 0; i < animalsArray.length; i++) {
// animalsArray[i]
}
View todo-list-item.css
input:checked + span {
opacity: 0.2;
text-decoration: line-through;
}
View arrays.js
var arr = [];
arr.push("a");
arr.push("b");
arr.push("c");
arr[0]; // => "a"
arr[1]; // => "b"
arr[2]; // => "c"
arr[3]; // => undefined