Skip to content

Instantly share code, notes, and snippets.

@zemadi
zemadi / coderbyte
Last active April 16, 2024 21:30
Python answers to CoderByte challenges
#My solutions to challenges from CoderByte.com. Their Python interpreter is buggy.
#1 Using the Python language, have the function FirstReverse(str) take the str parameter being passed and return the string in reversed order.
def FirstReverse(str):
print str[::-1]
#2 Using the Python language, have the function FirstFactorial(num) take the num parameter being passed and return the factorial of it (ie. if num = 4, return (4 * 3 * 2 * 1)). For the test cases, the range will be between 1 and 18.
def FirstFactorial(num):
@zemadi
zemadi / server.r
Created September 14, 2013 20:09
This was a partially successful attempt to use the R package Shiny, which creates interactive web applications. The data is from sfdata.org, and is a list of trees planted in San Francisco. I got the data points up but couldn't get a map to display on the main panel. Apparently, Shiny can't handle certain types of maps, so I'm looking at other o…
library(shiny)
library(ggmap)
library(ggplot2)
SFTrees <- read.csv("~/R/win-library/3.0/Projects/SF Trees/SFTrees.csv")
na.omit(SFTrees$PlantDate)
na.omit(SFTrees$Longitude)
na.omit(SFTrees$Latitude)
@zemadi
zemadi / Name
Created September 14, 2013 20:02
These gists are from an intro to Python class I took in July 2013.
#This assignment was to play with text.
# 1) Ask the user for their name
# 2) Print their name backwards
# 3) Print their name 10 times with spaces between each name.
#name = raw_input ("What is your name?")
name = "Zhila"
print name[::-1]
#print name[1:]
@zemadi
zemadi / RefugeePopulations
Last active December 20, 2015 15:59
This is my first successful R project. It's a simple map using data from the Office of the United Nations High Commissioner for Refugees and the World Bank, which shows the percent of each country's population that are refugees.
library(rworldmap)
library(RColorBrewer)
#I had the data as .CSV and loaded it into RStudio, then did a little editing. I had a dataset with ISO country codes added in already, and fortunately, the World Bank populates that automatically with data exports.
Country_Pop <- read.csv("~/R/win-library/3.0/Ref_Pop/Country_Pop.csv")
RefRes <- read.csv("~/R/win-library/3.0/Ref_Pop/RefRes.csv")
#Merge datasets on the ISO code variable
Mig_Total <- merge(Country_Pop,RefRes,by=c("Code","Code"))
#Remove any duplicate columns.