Skip to content

Instantly share code, notes, and snippets.

View frankhale's full-sized avatar
🎮
writing games

Frank Hale frankhale

🎮
writing games
View GitHub Profile
@frankhale
frankhale / IF-NOTES.txt
Last active March 21, 2017 14:44
IF NOTES
***The 'properties' property is for anything that is game specific***
-IF SCHEMA BELOW-
Player
- current room
- moves
- score
- items
- properties (eg. health, gold, etc...)
@frankhale
frankhale / list-weeks-of-year.js
Last active December 22, 2016 20:21
Print a list of weeks of the year starting on Jan 1
const moment = require("moment"),
_ = require("lodash");
function getWeeksOfYearList(startDate, endDate) {
let dates = [],
keepGoing = true,
start = moment(startDate),
end = moment(endDate),
rolling = start;
@frankhale
frankhale / youtube-search.js
Last active July 7, 2016 18:09
Proposed fix for issue #15 on YouTube Search
var querystring = require('querystring')
var xhr = require('xhr')
if (!xhr.open) xhr = require('request')
var allowedProperties = [
'fields',
'channelId',
'channelType',
'eventType',
@frankhale
frankhale / project.clj
Created January 13, 2014 17:42
Barebones project.clj for Clojurescript
(defproject your-project "0.0.1-SNAPSHOT"
:description "Describe your app here"
:url "http://somewhere.com"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/clojurescript "0.0-2138"]]
:plugins [[lein-cljsbuild "1.0.1"]]
:cljsbuild
{:builds
@frankhale
frankhale / map-fun.clj
Last active December 30, 2015 23:59
More map fun!
(def data (atom []))
;(def data1 [{:abc "123"}{:bcd "234"}])
;swap! data conj {:foo "bar"})
;(swap! data into data1)
(def more-data ["foo" "bar" "hello" "world"])
(swap! data into (map #(conj {} {:name %}) more-data))
(swap! data conj {:hello "1234"})
@frankhale
frankhale / implement-interface.clj
Last active December 30, 2015 19:29
Can't figure out how to implement an interface in Clojure CLR
; This does not work, boo! Don't know how to tell Clojure that IsReusable is a property
(System.Reflection.Assembly/LoadWithPartialName "System.Web")
(defn foo-handler []
(reify System.Web.IHttpHandler
(IsReusable [] false)
(ProcessRequest [context] ())))
@frankhale
frankhale / map-test.clj
Last active December 29, 2015 23:49
Playing with maps in Clojure
; Playing here, trying to figure out how to work with vectors of maps, my brain synapses are connecting but
; this code doesn't totally reflect the connections made. This will be rectified within 24 hours! HAHA!
;(def buffers (atom []))
;(swap! buffers conj {:file-name "one.txt" :file-text "first file"}
; {:file-name "two.txt" :file-text "second file"}
; {:file-name "three.txt" :file-text "third file"}
; {:file-name "four.txt" :file-text "fourth file"})
(defn actions [array-of-funcs]
(doseq [func array-of-funcs] (func)))
@frankhale
frankhale / node-webkit-menu-clojurescript.cljs
Last active December 29, 2015 03:29
Trying to learn Clojurescript by creating a menubar with a menu in Node-Webkit. I know this can be done better and more succinctly, this is really rough but it works.
(def gui (js/require "nw.gui"))
(def window (.get (.-Window gui)))
(def m (.-Menu gui))
(def mi (.-MenuItem gui))
(defn create [obj opts]
(obj. (clj->js opts)))
(def menubar (create m {:type "menubar"}))
(def menu1 (create m {:type "contextmenu"}))
@frankhale
frankhale / get-filenames.clj
Last active December 28, 2015 10:59
(still learning!) Returns a map of filenames for a series of file paths past in.
;;
;; Part of some learning exercises I'm doing. This returns a map of filenames for a series of file paths passed in
;;
(defn get-filenames-from-paths [& paths]
(map #(-> %
(.getFileName)
(.toString))
(map #(java.nio.file.Paths/get (.toURI (java.io.File. %))) paths)))