Skip to content

Instantly share code, notes, and snippets.

@liamlah
liamlah / rsnippets.R
Last active July 29, 2023 10:02
R snippets
library(readr)
library(ggplot2)
library(dplyr)
library(tidyverse)
# Read the HtnData.csv file with specified column types
HtnData <- read_csv("HtnData.csv", col_types = cols(
row.names = col_integer(),
### Keybase proof
I hereby claim:
* I am liamlah on github.
* I am liamlah (https://keybase.io/liamlah) on keybase.
* I have a public key ASD-cMTAx5jI7Tzfq24IzSB4a2sZSzEFFqQt3sEjBZgtjgo
To claim this, I am signing this object:
@liamlah
liamlah / simszorkalt.py
Created March 4, 2012 04:26
alternattivezorksims
class kitchenclass:
fridgefull = 1
drawerfull = 1
petdog = 1
placedescript = 1
kitchenobject=kitchenclass()
##def start():
## print"you find yourself in the kitchen, you see a fridge, a drawer, and a dog. Exits are to the front room, or up the stairs"
## print "what would you like to do?"
@liamlah
liamlah / simszork.yp
Created March 4, 2012 04:25
zorksims
class kitchenclass:
fridgefull = 1
drawerfull = 1
petdog = 1
placedescript = 1
kitchenobject=kitchenclass()
def start():
print"you find yourself in the kitchen, you see a fridge, a drawer, and a dog. Exits are to the front room, or up the stairs"
print "what would you like to do?"
@liamlah
liamlah / superkod
Created February 16, 2012 08:05
source of superkod. Not mine
/*
* Program made by Safety, ripped some from kod.c and gnutt.c
* Credits goes to dekadish(bjurr =)) for gnutt.c.
*
* This compiles on unix, should compile on windows too with cygwin.
* SuperKoD v1.1
* You must run this as r00t.
*/
#include <stdio.h>
@liamlah
liamlah / lorentz.py
Created February 11, 2012 07:57
Lorentz mass equation
import math
speedoflight = 3e8
print "lets work out the mass of something moving at a speed near the speed of light (C)"
print "what is the initial mass of your object in kg?"
initmass = float(raw_input())
print "what is the velocity of your object in m/s?\n(note: C is 3e8, your input can have up to 17 digits before rounding.)"
velocity = float(raw_input())
if velocity == 3e8:
print "Watch out, you are trying to divide by zero! Try again."
else:
@liamlah
liamlah / wavelengths0.8.py
Created February 9, 2012 06:58
Python Frequency/wavelength converter
print "This script can convert wavelengths to frequencies or vice versa."
speedlight = raw_input("Would you like an (1)exact value of the speed of light, or the (2)rounded value?\n" )
if speedlight == "1":
sol = 299792458.00
elif speedlight == "2":
sol = 3e8
else:
print "Please choose a valid option."
#sol = 299792458.00 #this is the speed of light in m/s
#sol = 3e8 #this is the speed of light in m/s rounded
@liamlah
liamlah / wavelengths0.7.py
Created February 9, 2012 04:23
Python Frequency/wavelength converter
print "This script can convert wavelengths to frequencies or vice versa."
sol = 299792458.00 #this is the speed of light in m/s
#ol = 300000000.00 #this is the speed of light in m/s
def wavelength():
print "Ok, Please enter your wavelength in Metres. (do not use scientific notation)"
wavelength = float(raw_input ())
answerfreq = sol / wavelength
print "the frequency is %rhz" % answerfreq
if wavelength >=1000:
@liamlah
liamlah / Wavelengths0.6.py
Created February 6, 2012 03:08
Python Frequency/wavelength converter
print "This script can convert wavelengths to frequencies or vice versa."
sol = 299792458.00 #this is the speed of light in m/s
#sol = 300000000.00 #this is the speed of light in m/s
print "do you have a (1) a wavelength or (2) a frequency?"
choice = raw_input()
if choice == "1":
print "Ok, Please enter your wavelength in Metres. (do not use scientific notation)"
wavelength = float(raw_input ())