This file contains hidden or 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
def update | |
@post = Post.find(params[:id]) | |
@post.published_at = @post.update_published(params[:published], @post.published_at) | |
if @post.update_attributes(params[:post]) | |
redirect_to @post, :notice => "Post has been updated." | |
else | |
flash[:alert] = "Post has not been updated." | |
render :action => "edit" |
This file contains hidden or 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 Post < ActiveRecord::Base | |
def update_published(published, published_at) | |
if published == true and published_at.nil? == true | |
Time.now | |
elsif published == false | |
nil | |
elsif published == true and published_at.nil? == false | |
published_at | |
end | |
end |
This file contains hidden or 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 Post < ActiveRecord::Base | |
before_save :published_at_value | |
private | |
# TODO: Needs Refactoring | |
def published_at_value | |
if self.published == true and self.published_at.nil? == true | |
self.published_at = Time.now | |
elsif self.published == false |
This file contains hidden or 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 TagsController < ApplicationController | |
def index | |
@tags = Post.published_posts.tag_counts.where("name like ?", "%#{params[:q]}%").order(:name) | |
@json = [] | |
@tags.each do |tag| | |
@json << {:tag => tag.name, :freq => tag.count} | |
end |
This file contains hidden or 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
#!/bin/sh | |
# | |
# init.d script with LSB support. | |
# | |
# Copyright (c) 2007 Javier Fernandez-Sanguino <[email protected]> | |
# | |
# This is free software; you may redistribute it and/or modify | |
# it under the terms of the GNU General Public License as | |
# published by the Free Software Foundation; either version 2, | |
# or (at your option) any later version. |
This file contains hidden or 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
function path() | |
{ | |
var args = arguments, | |
result = [] | |
; | |
for(var i = 0; i < args.length; i++) | |
result.push(args[i].replace('@', '/javascripts/')); | |
return result |
This file contains hidden or 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 Github | |
def initialize(username) | |
@username = username | |
end | |
def get_repos | |
base_url = "http://github.com/api/v2/json/repos/show/" | |
url = "#{base_url}#{@username}" | |
resp = Net::HTTP.get_response(URI.parse(url)) | |
data = resp.body |
This file contains hidden or 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
require "typhoeus" | |
require "json" | |
require "./Constants" | |
include Constants | |
include Typhoeus | |
class Github | |
def auth | |
request = Request.new("https://api.github.com", | |
:username => USERNAME, |
This file contains hidden or 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
require "typhoeus" | |
require "json" | |
require "./Constants" | |
include Constants | |
include Typhoeus | |
class Gist | |
def build_gist | |
gist = { :description => "This is a test", |
This file contains hidden or 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
find . -name '*erb' | xargs ruby -e 'ARGV.each { |i| puts "html2haml -r #{i} #{i.sub(/erb$/,"haml")};rm #{i}"}' | bash |
OlderNewer