Skip to content

Instantly share code, notes, and snippets.

View tyler-smith's full-sized avatar

Tyler Smith tyler-smith

View GitHub Profile
@tyler-smith
tyler-smith / test.rb
Created April 15, 2013 19:56
"Reload" class breaks is_a?/kind_of?/instance_of?
class A;end
first = A.new
Object.send(:remove_const, 'A')
class A;end
second = A.new
require 'nokogiri'
a = Nokogiri::XML.parse('...')
a.xpath('/PAGES/PAGE[1]/FILES[1]/FILEDATA/FILENAMES[1]/FILENAME/FILE').text
$.ajax({
url: location.protocol+"//"+location.host+'/api/v1/oauth/request_token.json',
data: undefined,
dataType: 'json',
method: 'GET',
success: function(data){debugger;},
beforeSend: function(xhr) {
xhr.setRequestHeader('X-OAuth-Required', true);
var accessor = { consumerSecret: currentClient.client_secret };
63] pry> ::ActiveSupport::TimeZone.all.map{|tz| [tz.utc_offset / 3600.0, tz.local_to_utc(date), tz.to_s] }
=> [[-11.0,
Mon, 16 Dec 2013 11:00:00 UTC +00:00,
"(GMT-11:00) International Date Line West"],
[-11.0, Mon, 16 Dec 2013 11:00:00 UTC +00:00, "(GMT-11:00) Midway Island"],
[-11.0, Mon, 16 Dec 2013 11:00:00 UTC +00:00, "(GMT-11:00) Samoa"],
[-10.0, Mon, 16 Dec 2013 10:00:00 UTC +00:00, "(GMT-10:00) Hawaii"],
[-9.0, Mon, 16 Dec 2013 09:00:00 UTC +00:00, "(GMT-09:00) Alaska"],
[-8.0,
Mon, 16 Dec 2013 08:00:00 UTC +00:00,
package main
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/mattbaird/elastigo/api"
"github.com/mattbaird/elastigo/core"
"log"
)
import uservoice
c = uservoice.Client('danzar', API_KEY, API_SECRET)
owner = c.login_as_owner()
owner.post("/api/v1/articles.json", {'article': {'question': "test from uv", 'answer_html': "hiii ", 'published': False, 'topic_name': "foo"}})
type fixtureSet struct {
table string
columns []string
records []interface{}
}
type suggestionFixture struct {
// Id int64
SubdomainId int64
UserId int64
package uvtest
import (
"log"
"uv"
)
type userFixture struct {
SubdomainId int64
DisplayName string
func TestSuggestionsSorting(t *testing.T, uvc *uv.Context) {
// Get decending list
suggestions_desc := &SuggestionList{Context: uvc}
err := suggestions_desc.FindByListParams(decodeParams(url.Values{"sort": {"id"}}))
assertCorrectSuggestionIds(t, err, suggestions_desc, []int64{3, 2, 1})
// Get ascending list
suggestions_asc := &SuggestionList{Context: uvc}
err = suggestions_asc.FindByListParams(decodeParams(url.Values{"sort": {"-id"}}))
assertCorrectSuggestionIds(t, err, suggestions_asc, []int64{1, 2, 3})
var findByListParamsTests = []struct {
params url.Values
expectedIds []int64
}{
{url.Values{"sort": {"id"}}, []int64{3, 2, 1}},
{url.Values{"sort": {"-id"}}, []int64{1, 2, 3}},
{url.Values{"page": {"1"}, "per_page": {"2"}}, []int64{1, 2}},
{url.Values{"page": {"2"}, "per_page": {"1"}}, []int64{2}},
}