This file contains 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 A;end | |
first = A.new | |
Object.send(:remove_const, 'A') | |
class A;end | |
second = A.new |
This file contains 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 'nokogiri' | |
a = Nokogiri::XML.parse('...') | |
a.xpath('/PAGES/PAGE[1]/FILES[1]/FILEDATA/FILENAMES[1]/FILENAME/FILE').text |
This file contains 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
$.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 }; |
This file contains 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
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, |
This file contains 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
package main | |
import ( | |
"database/sql" | |
"fmt" | |
_ "github.com/go-sql-driver/mysql" | |
"github.com/mattbaird/elastigo/api" | |
"github.com/mattbaird/elastigo/core" | |
"log" | |
) |
This file contains 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
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"}}) |
This file contains 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
type fixtureSet struct { | |
table string | |
columns []string | |
records []interface{} | |
} | |
type suggestionFixture struct { | |
// Id int64 | |
SubdomainId int64 | |
UserId int64 |
This file contains 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
package uvtest | |
import ( | |
"log" | |
"uv" | |
) | |
type userFixture struct { | |
SubdomainId int64 | |
DisplayName string |
This file contains 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
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}) |
This file contains 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 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}}, | |
} |