Skip to content

Instantly share code, notes, and snippets.

View KyeRussell's full-sized avatar
🪴

Kye Russell KyeRussell

🪴
View GitHub Profile
<?php
/* my model */
class News_model extends Model {
function get_recent_stories() {
$query = $this->db->get('news_entries');
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $row;
@KyeRussell
KyeRussell / gist:1055899
Created June 30, 2011 09:08
Python OOP Example
def main():
class Avatar (object):
def __init__(self, name, category):
self.name = name
self.cat = category
self.health = 100
self.magic = 25
def stats (self):
print("---[ Avatar Stats ]---")
print("Name:\t\t", self.name)
@KyeRussell
KyeRussell / gist:1057683
Created July 1, 2011 01:20
Python IRC Environment
class IRCChannel (object):
""" Simulate an IRC channel environment """
def __init__ (self, chan_name, topic):
self.chan_name = chan_name # Channel name
self.topic = topic # Channel topic
self.users = [] # User list
# Prints joining messages
self.system_msg("You have joined " + self.chan_name)
self.system_msg("Topic for " + self.chan_name + " is: " + self.topic)
@KyeRussell
KyeRussell / pickler.py
Created July 3, 2011 01:35
Python Pickler Example
import pickle
import random
# Opening a file handler.
fh = open('obj.txt', 'w')
# Create a new object.
eggs = {'green eggs': 'ham',
'sam' : 'i am'}
@KyeRussell
KyeRussell / dummy.py
Created July 4, 2011 00:52
Python Dummy Example
class HerpDerp (object):
def __init__(self, foo, bar, baz):
self.foo = foo
self.barbaz = bar + " " + baz
self.mylist = ['hey', 'awesome' 12]
self.dict = {'green eggs': 'ham',
'sam': 'i am'}
def foo_bar_baz(self):
return self.foo + " " + self.barbaz
<title>Laugh</title><?php
$file = "output.txt";
$number = "a";
$number2 = "z";
$yes = array('file', 'number', 'number2');
$file = fopen('/output.txt', 'w', 'a');
fwrite($file, $yes);
@KyeRussell
KyeRussell / commands.py
Created July 6, 2011 13:10
Python Shell Emulator
def help():
print("HELP!!!")
def account_info():
print("account infoz:!!!")
@KyeRussell
KyeRussell / prompt.py
Created July 9, 2011 15:07
Prompt Method
def prompt(message, password=False):
"""
Prompt the user for information.
message - what you're prompting the user for.
password - whether you want a password (invokes getpass instead of vanilla raw_input()).
returns the text returned by the user.
"""
# We don't want a password.
@KyeRussell
KyeRussell / tweet.py
Created July 13, 2011 09:29
[JOKE] - Kye's Apple-related Tweet Algo
from twitter import user, tweet
Kye = twitter.userbase.new("KyeRussell", "Kye Russell")
while True:
if Kye.is_tweeting = True:
Kye.tweeting_about = 'Apple'
@KyeRussell
KyeRussell / tweet.py
Created July 13, 2011 09:41
Bogan Tweets
from twitter import user
UncleMark = twitter.user('Markedw', 'Mark Edwards') # instnatise new Twitter.User object.
tweet_list = UncleMark.stream() # Write tweet list to variable
for tweet in tweet_list: # cycle through tweet list
if tweet.location == 'Bunbury': # if tweet is in bunbury
if 'football' not in tweet.text: # if tweet doesn't contain 'football' str.
tweet.subject = "Bogans" # tweet subject is 'bogans'.
else: # tweet contains 'football'.