Skip to content

Instantly share code, notes, and snippets.

View avand's full-sized avatar

Avand Amiri avand

View GitHub Profile
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
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;
// 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);
}
$.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);
}
<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>
{
"name": "Avand Amiri",
"bio": "Hi there, my name is Avand!",
"image": "http://avandamiri.com/images/avand.jpg"
}
@avand
avand / split.js
Created September 30, 2016 16:11
// 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]
}
input:checked + span {
opacity: 0.2;
text-decoration: line-through;
}
document.querySelector("form").addEventListener("submit", search);
function search(event) {
event.preventDefault();
var query = document.querySelector("#query").value;
var url = "http://omdbapi.com/?s=" + query;
// Check local storage to see if the results have already been
// retrieved with the URL as the key...
// This would be so much easier to read and write...
var position = navigator.geolocation.getCurrentPosition();
console.log(position.coords.latitude);
// So why in the world do we have to write this?
navigator.geolocation.getCurrentPosition(function(position) {
console.log(position.coords.latitude);
});