Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Stamatiou stammy

View GitHub Profile
@stammy
stammy / wp_list_articles_function.php
Created Oct 29, 2008
function to list all wordpress blog entries, by month.. for archives
View wp_list_articles_function.php
<?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);
View gist:60892
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())}}})();
View submenu code
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 Apr 8, 2009
installing twitter_auth and it's..
View gist:91927
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
View rewrite acts_as_taggable_on migration for apps previously using acts_as_taggable_on_steriods
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
View gist:103935
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
View 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
View .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"
View 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
View post-Skribit launch #FollowFriday
@danielbru
@dougaitken
@theiBlog
@mike_wilt
@duncanfreeman
@sanjay
@Michaelmontano
@GoKTGo
@colinake
@lessallan
You can’t perform that action at this time.