Skip to content

Instantly share code, notes, and snippets.

View Sun-Wukong's full-sized avatar

Jason Sun-Wukong

  • Dirty Jersey
View GitHub Profile
@Sun-Wukong
Sun-Wukong / RssParse.rb
Created July 25, 2014 14:14
rss parser for idealist.org
require 'open-uri'
require 'atom'
require 'rss'
url = 'http://http://www.idealist.org/search/v2/feeds?qs=QlpoOTFBWSZTWQ9xiVwAAFAfgAMAMAIBAAAAvuXfgCAAiQlNU2k000GRkAkiFPaJqekZPU9RjYc3Umi5ZZ3U6lROLCSMeYiTZpDlh2Zxx7nN2ZK5m0jZXPY2kqK5kMaJmtlmPTm4YhVwPU5IXBZKdOChLyRsT_jBOREpNY0YpeBSFD8XckU4UJAPcYlc'
open(url) do |rss|
feed = RSS::Parser.parse(rss)
puts "Title: #{feed.channel.title}"
feed.items.each.do |item|
-- Creating variables with Lua
weather = "Rainy"
mood = "lousy"
hungry = " yaaasss"
-- Getting the computer to "speak" our variables back to us
print(" Today's weather is pretty " .. weather ..", I'm feeling " .. mood .. ", and " .. hungry ..", I'm that hungry" )
-- teaching our computer to make decisions
-- To start, let's create some variables that track our input
print( "Hey, are you tired right now? ( type yes or no ) " )
tired = io.read() -- makes our tired variable what we type in
print( "I almost forgot, what's your name?" )
myName = io.read()
-- Now we add some basic conditions
-- How to create tables... or super variables and put them to use
-- Tables are containers for values
myTable = { 1, 2, 3, 4, 5, 6 }
-- now, let's walk through our table
for i = 1, 6 do
print( myTable[ i ] )-- i is the index or the current position in the table
end
-- Functions are special instructions packed into a function keyword
-- They allow you to pack complex instructions for reuse
local function addMe( a, b ) -- in this function, a and b are what's being fed in. We call these arguments
return a + b
end -- always end your functions with this word
print( "Enter a number " )
number1 = io.read()
number2 = io.read()
@Sun-Wukong
Sun-Wukong / ClassDemo.lua
Last active August 29, 2015 14:06
An overview of how classes are created in Lua
-- Creating a class, or the blueprints for our objects in games and apps
-- Making a class is just like a function
function animalFactory( name )
local animal = { -- a table with the values of our animal object
name = "kitteh",
says = "nyan",
position = { x = 0, y = 0 }
}
@Sun-Wukong
Sun-Wukong / ContionsNLoops.py
Created September 20, 2014 01:12
Creating conditionals and loops a la python
# Setting up conditional statement
print("Enter Your age")
myAge = raw_input()
if myAge >= 10: # The state of an if / else statement
print( "You're not a kid anymore." )
elif myAge <= 19: # Use elif for additional conditions... kinda like elseif
print( "You must be a teen!" )
print ( "Welcome, to the World of Games and I'm the god of this world people call Kami, other knows me as the Narrator." )
print ( "Oh, great adventure could I ask you your name? (Insert Name)" )
myName = raw_input()
if myName == 'Kami':
print ( "Hey my name is Kami you can't use this name!" ) # when using python, make sure to use 4 spaces
else: #colon was missing
print ( "Uhh, nice name I guess. Well let's get the show on the road, oh yeah can I ask you how old you are? (Insert Age)" )
@Sun-Wukong
Sun-Wukong / index.html
Last active August 29, 2015 14:07
Resume markup
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Jason Scoon</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="./css/style.css"/>
<!--[if lt IE 9]>
@Sun-Wukong
Sun-Wukong / bottle_app.py
Last active November 11, 2017 20:17
A collection CRUD services for scaffolding
import bottle
import pymongo
import os
from bottle import request, route, run, abort, response
client = pymongo.MongoClient( os.environ['MONGO_DB_ENDPOINT'], os.environ['MONGO_DB_PORT'] )
my_library = db.library # library collection
# Note: closing the connection to the MongoDB instance is highly recommended as per each API endpoint.