Skip to content

Instantly share code, notes, and snippets.

@rafarubert
rafarubert / calendar
Created July 11, 2011 22:13
calendar
#encoding: utf-8
module Atendente::AgendaHelper
def calendar(options={}, &block)
caption = String.new
contents = String.new
head = String.new
rows = String.new
options = {
//Controller
<?php
class BannersController extends AppController {
var $name = 'Banners';
var $uses = array('Banner');
var $paginate = array();
(function($) {
$.fn.poll = function(options){
var $this = $(this);
var opts = $.extend({}, $.fn.poll.defaults, options);
setInterval(update, opts.interval);
function update(){
$.ajax({
type: opts.type,
context "should validate presence of country fields if country not equal BRASIL" do
before do
Country.stub!(:find).with(2).and_return({:id => 2, :name => "ARGENTINA",:created_at => Time.now , :updated_at => Time.now})
end
it { should validate_presence_of :year_of_arrival }
it { should validate_presence_of :passport }
it { should validate_presence_of :type_visa }
it { should validate_presence_of :validity_visa }
end
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def method_missing(provider)
if !User.omniauth_providers.index(provider).nil?
#omniauth = request.env["omniauth.auth"]
omniauth = env["omniauth.auth"]
if current_user #or User.find_by_email(auth.recursive_find_by_key("email"))
current_user.user_tokens.find_or_create_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
#flash[:notice] = "Authentication successful"
redirect_to edit_user_registration_path
@rafarubert
rafarubert / gist:2557708
Created April 30, 2012 12:08
.osx, peguei de alguém e não acho a referencia
# Disable menu bar transparency
defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false
# Show remaining battery time; hide percentage
defaults write com.apple.menuextra.battery ShowPercent -string "NO"
defaults write com.apple.menuextra.battery ShowTime -string "YES"
# Always show scrollbars
defaults write NSGlobalDomain AppleShowScrollBars -string "Always"
def rescue_action_in_public(exception)
if exception
deliverer = self.class.exception_data
data = case deliverer
when nil then {}
when Symbol then send(deliverer)
when Proc then deliverer.call(self)
end
ExceptionNotifier.deliver_exception_notification(exception, self,request, data)
flash[:error] = "Blah";redirect_to '/'
@rafarubert
rafarubert / gist:3431527
Created August 23, 2012 02:30
functions php
<?php
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
}
function remove_footer_admin () {
echo 'Carnabral 2012.';
}
function change_footer_version() {
$app->post('/estabelecimento/categoria/:id/update', function ( $id ) use ( $app ) {
$params = $app->request->params();
$header = array('Content-Type: multipart/form-data');
$token = key( $_SESSION['current_user'] );
$current_user = json_decode( $_SESSION['current_user'][$token] );
if ( isset( $_FILES ) and isset( $_FILES['imagem'] ) ):
$params['imagem'] = '@'.$_FILES['imagem']['tmp_name'];
endif;
server {
listen 80;
server_name iphoneria.rubert.com.br;
client_max_body_size 500M;
location / {
root /usr/share/nginx/www/iphoneria;
access_log /var/log/nginx/iphoneria.rubert.com.br.domain_access.log;