Skip to content

Instantly share code, notes, and snippets.

@stammy
stammy / wp_list_articles_function.php
Created October 29, 2008 19:15
function to list all wordpress blog entries, by month.. for archives
<?php function list_articles(){
global $month, $wpdb, $wp_version;
$now = current_time('mysql');
if(version_compare($wp_version, '2.1', '<')){$current_posts = "post_date < '$now'";} else {$current_posts = "post_type='post'";}
$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM " . $wpdb->posts . " WHERE post_status='publish' AND $current_posts AND post_password='' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC");
if($arcresults){
foreach($arcresults as $arcresult) {
$url = get_month_link($arcresult->year, $arcresult->month);
javascript:void(function(){var%20i,a,s;a=document.getElementsByTagName('link');for(i=0;i%3Ca.length;i++){s=a[i];if(s.rel.toLowerCase().indexOf('stylesheet')%3E=0&&s.href)%20{var%20h=s.href.replace(/(&|%5C?)forceReload=\d+/,'');s.href=h+(h.indexOf('?')%3E=0?'&':'?')+'forceReload='+(new%20Date().valueOf())}}})();
var submenuTimerId = 0;
var last_menu;
function submenuOver(id){
$(id+'_link').setStyle({zIndex:50});
$(id).appear({duration: 0.3});
clearTimeout(submenuTimerId);
if ( ( typeof( window[ 'last_menu' ] ) != "undefined" ) && !(id == last_menu) ){
submenuClose(last_menu);
}
}
@stammy
stammy / gist:91927
Created April 8, 2009 18:50
installing twitter_auth and it's..
Aurora:skribit Paul$ script/generate twitter_auth
done loading services
The name 'User' is either already used in your application or reserved by Ruby on Rails.
Please choose an alternative and run this generator again.
Suggestions:
exploiter
drug user
substance abuser
class ActsAsTaggableOnMigration < ActiveRecord::Migration
def self.up
change_table :taggings do |t|
t.column :tagger_id, :integer
t.column :tagger_type, :string
t.column :context, :string
end
add_index :taggings, :context
end
SELECT count(DISTINCT blogs.*) AS count_distinct_blogs_all FROM `blogs` LEFT OUTER JOIN taggings blogs_taggings ON blogs_taggings.taggable_id = blogs.id AND blogs_taggings.taggable_type = 'Blog' LEFT OUTER JOIN tags blogs_tags ON blogs_tags.id = blogs_taggings.tag_id WHERE (context = 'tags' AND blogs_tags.name LIKE 'Technology') ORDER BY created_at DESC LIMIT 0, 15
@stammy
stammy / db.rake
Created May 25, 2009 20:59 — forked from evizitei/db.rake
namespace :db do
desc "abort rake if using bad memory techniques"
task :safety_migrate => :environment do
path = "#{RAILS_ROOT}/db/migrate/"
migration_directory = Dir.new(path)
proceed = true
migration_directory.each do |file|
if file != "." and file != ".."
migration = File.open("#{path}#{file}")
text = migration.read
@stammy
stammy / .bashrc
Created August 17, 2009 22:44 — forked from justintv/.bashrc
# If you work with git, you've probably had that nagging sensation of not knowing what branch you are on. Worry no longer!
export PS1="\\w:\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\$ "
# This will change your prompt to display not only your working directory but also your current git branch, if you have one. Pretty nifty!
# ~/code/web:beta_directory$ git checkout master
# Switched to branch "master"
# ~/code/web:master$ git checkout beta_directory
# Switched to branch "beta_directory"
@stammy
stammy / url_dsl.rb
Created December 14, 2009 19:37 — forked from defunkt/url_dsl.rb
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
@danielbru
@dougaitken
@theiBlog
@mike_wilt
@duncanfreeman
@sanjay
@Michaelmontano
@GoKTGo
@colinake
@lessallan