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
| # add this file as config/initializers/will_paginate_postgresql_count.rb | |
| # in a Rails application | |
| module WillPaginate | |
| module Finder | |
| module ClassMethods | |
| # add '1=1' to paginate conditions as marker such that the select from the pg_class | |
| # is used to approximate simple rows count, e.g. | |
| # Foo.paginate(:page => params[:page], :conditions => "1=1") |
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
| Remote.WithJsValidation = $.klass(Remote.Base, { | |
| initialize: function() { | |
| $(this.element).validate(); | |
| }, | |
| onsubmit: function(event) { | |
| if ($(this.element).valid()) { | |
| return true; | |
| } else { | |
| event.preventDefault(); | |
| return 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
| /* Compile Me With | |
| gcc -O3 flatten.c -o flatten -L/oracle/rdbms/9.2.0/orax011/lib32 -lclntsh -lclntst9 | |
| */ | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <ctype.h> | |
| #define MAX_VNAME_LEN 30 | |
| #define MAX_INAME_LEN 30 |
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
| var to; | |
| $(function() { | |
| // initialize timer to update div every 5 seconds | |
| to = setTimeout(message_load(), 5000); | |
| }); | |
| function message_load() { | |
| $.get("/messages",function(data) { | |
| if (data.VERIFICA_SE_TEM_CONTEUDO) { | |
| alert(data.conteudo); |
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
| # is it risky to trust on updated_at ? | |
| # Summary: all products with no price on API should be disabled. | |
| start_time = Time.now | |
| Product.transaction do | |
| ProductApi.each do |e| | |
| Product.find(e.code).update_attribute :price, e.price | |
| 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
| start_date = Time.now | |
| Variant.transaction do | |
| 100.times do | |
| puts Variant.count :conditions => ['updated_at > ?', start_date] | |
| sleep(1) | |
| 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 Utf8Header < Thor | |
| desc "add", "Add Content UTF-8 on top of all .rb/.feature files" | |
| # copy & pasted from https://gist.github.com/738245 | |
| def add | |
| files = Array.new | |
| ["*.rb", "*.rake","*.feature"].each do |extension| | |
| files.concat(Dir[ File.join(Dir.getwd.split(/\\/), "**", extension) ]) | |
| end | |
| files.each do |file| |
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 'rubygems' | |
| require 'mechanize' | |
| if ARGV.size < 3 | |
| puts %q{Usage: ruby xcode.rb USERNAME PASSWORD "DOWNLOAD_URL" [WGET_PARAMS]} | |
| puts %q{Example: ruby xcode.rb myusername@apple.com 123456 "https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4_and_ios_sdk_4.3__final/xcode_4_and_ios_sdk_4.3__final.dmg" } | |
| exit | |
| end | |
| a = Mechanize.new { |agent| |
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
| # id : serial | |
| # check_digit : integer | |
| class Client | |
| set_primary_key :id | |
| before_create :define_check_digit | |
| private |
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
| diff --git a/unactest1.c b/unactest1.c | |
| index 519691d..00aafbf 100644 | |
| --- a/unactest1.c | |
| +++ b/unactest1.c | |
| @@ -26,415 +26,9 @@ | |
| #include "unac.h" | |
| -static char* longstr_expected = " | |
| +static char* longstr_expected = ""; |