Skip to content

Instantly share code, notes, and snippets.

@jdfight
jdfight / core.clj
Last active January 4, 2023 03:16
Clojure web scraper: Scrape Nasa Apod and download the image
;;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"]))
@jdfight
jdfight / posttool.rb
Created August 31, 2016 22:48
Ruby shell script to test get/post form data to web apis
#!/usr/bin/env ruby
require "uri"
require "net/http"
require "optparse"
options = {}
optparse = OptionParser.new do|opts|
@jdfight
jdfight / IsConnectedWeb.cs
Created April 3, 2015 15:16
Useful as a quick check to see if a client has an active internet connection.
//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);
@jdfight
jdfight / 0_reuse_code.js
Last active August 29, 2015 14:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jdfight
jdfight / FindObjectsTiled.js
Last active January 6, 2018 17:19
Phaser - Creating objects from Tiled Map Object layers
//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