This file contains 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
;;Scrape Nasa Apod webpage and download the image. | |
;; This is a quick project to familiarize myself with Clojure and Enlive | |
(ns apod-scraper.core | |
(:require [net.cgrand.enlive-html :as html]) | |
(:require [clojure.string :as str]) | |
(:gen-class)) | |
(def apod-base-url "https://apod.nasa.gov/apod/") | |
(def apod-url (apply str [apod-base-url "astropix.html"])) |
This file contains 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
#!/usr/bin/env ruby | |
require "uri" | |
require "net/http" | |
require "optparse" | |
options = {} | |
optparse = OptionParser.new do|opts| | |
This file contains 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
//Adapted from http://answers.unity3d.com/questions/534873/testing-for-active-internet-connection.html | |
public static bool IsConnectedWeb(string checkurl = "http://www.google.com") | |
{ | |
System.Net.WebClient client = null; | |
System.IO.Stream stream = null; | |
try | |
{ | |
client = new System.Net.WebClient(); | |
stream = client.OpenRead(checkurl); |
This file contains 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 Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains 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
//From http://www.gamedevacademy.org/html5-phaser-tutorial-top-down-games-with-tiled/ | |
//find objects in a Tiled layer that containt a property called "type" equal to a certain value | |
findObjectsByType: function(type, map, layer) { | |
var result = new Array(); | |
map.objects[layer].forEach(function(element) { | |
console.log(element); | |
if (element.properties.type === type) { | |
//Phaser uses top left, Tiled bottom left so we have to adjust the y position | |
//also keep in mind that the cup images are a bit smaller than the tile which is 16x16 |