This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tweet < ActiveRecord::Base | |
def self.fetch_new | |
# attempt to connect and authenticate to Twitter | |
httpauth = Twitter::HTTPAuth.new(ENV['TWITTER_USR'], ENV['TWITTER_PWD']) | |
client = Twitter::Base.new(httpauth) | |
# fetch a new tweet, cache it to the database, and then return it | |
Tweet.create :text => client.user_timeline.first.text | |
client.user_timeline.first.text | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// =========================================================================================================== | |
// NAME | |
// | |
// DESCRIPTION GOES HERE | |
// | |
// Example | |
// Mootools style: var *name* = new *NAME*('.tooltip', {'options':'hash', 'syntax':'example'}); | |
// jQuery style: $(element).*name*({'options':'hash', 'syntax':'example'}); | |
// | |
// Options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!bash | |
# | |
# bash completion support for core Git. | |
# | |
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> | |
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). | |
# Distributed under the GNU General Public License, version 2.0. | |
# | |
# The contained completion routines provide support for completing: | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
:update_sources: true | |
:bulk_threshold: 1000 | |
:verbose: true | |
:backtrace: false | |
:benchmark: false | |
gem: --no-ri --no-rdoc | |
:sources: | |
- http://gems.rubyforge.org/ | |
- http://gemcutter.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TRUNCATE BY WORD COUNT | |
def snippet (text, wordcount, separator="...") | |
text.split[0..(wordcount-1)].join(" ") + (text.split.size > wordcount ? separator : "") | |
end | |
## EXAMPLE USAGE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[PHP] | |
;;;;;;;;;;; | |
; WARNING ; | |
;;;;;;;;;;; | |
; This is the default settings file for new PHP installations. | |
; By default, PHP installs itself with a configuration suitable for | |
; development purposes, and *NOT* for production purposes. | |
; For several security-oriented considerations that should be taken | |
; before going online with your site, please consult php.ini-recommended |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This is the main Apache HTTP server configuration file. It contains the | |
# configuration directives that give the server its instructions. | |
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information. | |
# In particular, see | |
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html> | |
# for a discussion of each configuration directive. | |
# | |
# Do NOT simply read the instructions in here without understanding | |
# what they do. They're here only as hints or reminders. If you are unsure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
httpauth = Twitter::HTTPAuth.new( current_account.twitter_username, current_account.twitter_password ) | |
client = Twitter::Base.new(httpauth) | |
# TO DO -- Yep, should filter the request to only get tweets since the last check | |
client.friends_timeline.each do |tweet| | |
# TO DO -- Yep, need to check to see if the tweet is already in there | |
status = Status.create( | |
:status_created_at => tweet.status_created_at, | |
:status_id => tweet.id, | |
:message => tweet.text, | |
:source => tweet.source, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- ============================================================== --> | |
<!-- = Code Snippets from Mobile Webkit Development Talk on 11/16 = --> | |
<!-- ============================================================== --> | |
<!-- =========================== --> | |
<!-- = Conditional Stylesheets = --> | |
<!-- =========================== --> | |
<link media="only screen and (max-device-width: 480px)" href="small-device.css" type= "text/css" rel="stylesheet"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################### | |
# place in /app/helpers/application_helper.rb # | |
############################################### | |
def bodytag_id | |
a = controller.class.to_s.underscore.gsub(/_controller$/, '') | |
b = controller.action_name.underscore | |
"#{a}-#{b}".gsub(/_/, '-') | |
end | |