Skip to content

Instantly share code, notes, and snippets.

@JoshAshby
JoshAshby / XKCD login
Created August 27, 2011 15:07
What my XKCD random script generates....
Linux vps 2.6.18-238.12.1.el5.028stab091.1 #1 SMP Wed Jun 1 13:20:25 MSD 2011 i686
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
No mail.
Last login: Sat Aug 27 02:03:27 2011 from c-98-245-46-242.hsd1.co.comcast.net
@JoshAshby
JoshAshby / gist:1164054
Created August 23, 2011 01:11 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
Day job:
Student, quite boring really, and doesn't pay well...
Favorite Python project:
Inventory Management API
Favorite Conference:
Haven't sadly been able to go to one yet.
Python Experience Level:
Welcome root, to joshashby.com
Current uptime: 23:12:43 up 7 days, 15:14, 5 users, load average: 0.01, 0.02, 0.00
Random XKCD...
Perspective
Narrator: Sometimes, when I first wake up, I am caught in the horrible grip of perspective.
A person sitting up in bed
Person: It may be a jewel of open source, but Firefox is JUST A BROWSER. It shows WEBPAGES. What the hell is WRONG with us?
Narrator: Fortunately, this subsides quickly.
I wonder what I was dreaming to prompt that. I hope it wasn't the Richard Stallman Cirque de Soleil thing again.
http://xkcd.com/198/
@JoshAshby
JoshAshby / useradmin
Created July 27, 2011 08:49
Quick hack to manage users and sites on my VPS, just missing the DNS records and it'll be done...
#!/bin/sh
#Quick hack to try out making users and doing a few things with their accounts for my VPS
#2011 JoshAshby
#http://joshashby.com
#released (possibly) under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
#[email protected]
#Enjoy!
interact()
{
vps:~# cat /etc/maradns/mararc
csv2 = {}
csv2["joshashby.com."] = "db.joshashby.com"
cvs2["kariashby.com."] = "db.kariashby.com"
bind_address = "64.31.21.80"
chroot_dir = "/etc/maradns"
min_ttl = 60
min_ttl_cname = 300
vps:~# cat /etc/maradns/db.joshashby.com
vps:~# dig @64.31.21.80 joshashby.com
; <<>> DiG 9.6-ESV-R3 <<>> @64.31.21.80 joshashby.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31513
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
[joshua@Loki ~]$ dig @64.31.21.80 kariashby.com
; <<>> DiG 9.8.0-P4 <<>> @64.31.21.80 kariashby.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 48092
;; flags: qr rd; QUERY: 0, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available
$cat /etc/maradns/db.kariashby.com
kariashby.com. SOA kariashby.com. [email protected]. 1 7200 3600 604800 1800
kariashby.com. NS ns1.kariashby.com.
ns1.kariashby.com. A 64.31.21.80
kariashby.com. NS ns2.kariashby.com.
ns2.kariashby.com. A 64.31.21.80
kariashby.com. A 64.31.21.80
The Python bit:
m = len(query)
for i in range(m-1):
if (query[i]['quantity'] < query[i+1]['quantity']):
quantity.append(int(query[i]['quantity']))
date.append(time.mktime(query[i]['date'].timetuple()).as_integer_ratio()[0])
else:
break
@JoshAshby
JoshAshby / gist:945723
Created April 28, 2011 03:07
Computes a graphs the last period interval of a dataset with design \|\|\|\ and computes the line of best fit
library(ggplot2)
mydata = read.csv("/home/joshua/Downloads/test_data.csv", header = TRUE)
m = length(mydata$x)
theta = matrix(c(0,0), nrow=1)
ux = matrix(c(rep(1,m), mydata$x), ncol=2)
uy= matrix(mydata$y, ncol=1)
delta = function(x,y,th) {
delta = (t(x) %*% ((x %*% t(th)) - y))
return(t(delta))