query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102 values |
|---|---|---|---|---|---|---|
determine the present value required to acheive a future value with given interest rate over time periods number of periods (years) that the interest is cumulated rate the annual rate of return future_value the value at the end of the period | def present_value(rate,periods,future_value)
present_value = future_value / (1+rate)**periods
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def future_given_present(present_value, interest, term)\n (present_value.to_f * (1 + interest.to_f) ** term).round(4)\n end",
"def compound_return(periods,present_value,future_value)\n pv = present_value.to_d\n fv = future_value.to_d\n n = periods.to_d\n rate = ((fv / pv)**(1/n))-1\n e... | [
"0.74859816",
"0.7460934",
"0.73605585",
"0.70097977",
"0.69373226",
"0.67010456",
"0.65248215",
"0.65005285",
"0.64793396",
"0.6350233",
"0.62822175",
"0.62789625",
"0.62492776",
"0.6179234",
"0.61650795",
"0.6115266",
"0.6107985",
"0.6103223",
"0.60859317",
"0.60255533",
"0... | 0.7800808 | 0 |
determine the rate of return over a period periods number of periods (years) that the interest is cumulated present_value the value at the start of the period future_value the value at the end of the period | def compound_return(periods,present_value,future_value)
pv = present_value.to_d
fv = future_value.to_d
n = periods.to_d
rate = ((fv / pv)**(1/n))-1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def present_value(rate,periods,future_value)\n present_value = future_value / (1+rate)**periods\n end",
"def future_value(rate,periods,present_value,compound_frequency = 1)\n compound_frequency = resolve_compound_frequency!(compound_frequency)\n if compound_frequency == :continuous\n ret... | [
"0.78171325",
"0.69233257",
"0.68300253",
"0.6731517",
"0.6698266",
"0.6611931",
"0.6558443",
"0.64138514",
"0.6395259",
"0.635134",
"0.6257746",
"0.62558013",
"0.62553144",
"0.623989",
"0.62014925",
"0.6158807",
"0.6115589",
"0.6073032",
"0.6028322",
"0.6027582",
"0.5992313"... | 0.79168487 | 0 |
determine the investment horizon (length of time) required to create a future value given a present value and interest rate present_value the value at the start of the period future_value the value at the end of the period rate the annual rate of return | def investment_horizon(rate,present_value,future_value)
pv = present_value.to_d
fv = future_value.to_d
periods = Math.log(fv/pv) / Math.log(1+rate)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def present_value(rate,periods,future_value)\n present_value = future_value / (1+rate)**periods\n end",
"def future_given_present(present_value, interest, term)\n (present_value.to_f * (1 + interest.to_f) ** term).round(4)\n end",
"def present_given_future(future_value, interest, term)\n (future... | [
"0.73584276",
"0.7230214",
"0.6933694",
"0.66302454",
"0.6504473",
"0.61318266",
"0.5859032",
"0.5783148",
"0.5606104",
"0.55674577",
"0.556436",
"0.5499632",
"0.54799885",
"0.54791063",
"0.5467902",
"0.54229295",
"0.5418428",
"0.5403856",
"0.5395165",
"0.5387388",
"0.528683"... | 0.78798425 | 0 |
determine the effective annual rate for a given simple interest rate compounded over a given number of periods rate simple annual rate compound_per_period compound / period | def effective_annual_rate(rate,compound_frequency)
compound_frequency = resolve_compound_frequency!(compound_frequency)
if compound_frequency == :continuous
return continuous_effective_annual_rate(rate)
end
m= compound_frequency
e_rate = (1 + rate/m)**m -1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anticipated_interest(rate, periods)\n\t\t (1 - (( 1 / ( rate.to_f + 1 )) ** (1.0 / periods)))\n\t\tend",
"def compound_interest(rate, count = 1, period = 12)\n Money.new(cents * ((1 + rate / 100.0 / period) ** count - 1))\n end",
"def calculate_loan(rate, n_periods, total_loan_amount)\n fixed_payment... | [
"0.6941773",
"0.6785467",
"0.6609534",
"0.65379953",
"0.6418716",
"0.6287261",
"0.627252",
"0.6134057",
"0.6099594",
"0.60314786",
"0.6006965",
"0.59807014",
"0.59512377",
"0.5846905",
"0.58282346",
"0.5824809",
"0.58177525",
"0.5814894",
"0.57970273",
"0.5775244",
"0.5764877... | 0.757776 | 0 |
role :servers, 'ec26720233100.compute1.amazonaws.com', 'ec2672026067.compute1.amazonaws.com' | def call_describe_instances
`ec2-describe-instances >> #{EC2_DESCRIBE_INSTANCES_OUTPUT}`
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def role(role, server)\n @roles[role] ||= []\n @roles[role] << server\n end",
"def serversForCapRoles(roles)\n find_servers(:roles => roles).collect { |x| x.host }\nend",
"def roles(host)\n roles = [ \"network\" ]\n case host\n when /^node/\n roles << \"compute\"\n when /^login/\n ... | [
"0.6746659",
"0.65605664",
"0.6216241",
"0.6099661",
"0.6055757",
"0.59555304",
"0.59527224",
"0.5915317",
"0.58803904",
"0.5860618",
"0.5837443",
"0.5830239",
"0.57658935",
"0.57559943",
"0.5696148",
"0.56837744",
"0.56789553",
"0.56000584",
"0.555622",
"0.5514585",
"0.55006... | 0.0 | -1 |
Migrating this to `authorizerhomerooms` | def authorized_homerooms
if EnvironmentVariable.is_true('ENABLE_HOMEROOM_AUTHORIZATION_V2')
authorizer.homerooms
else
authorizer.allowed_homerooms_DEPRECATED(acknowledge_deprecation: true)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorized_by(authorizer)\n authorizer.to_s.camelize.constantize # get authorizer loaded\n alias_method :old_users, :users\n alias_method :old_method_missing, :method_missing\n include TransitiveAuthorization::Authorizee::InstanceMethods\n self.cattr_accessor :transitive_authorizer\n ... | [
"0.6965431",
"0.63082737",
"0.62287205",
"0.61290187",
"0.59146535",
"0.59146535",
"0.5896997",
"0.5896997",
"0.58728963",
"0.5806797",
"0.5795525",
"0.57881975",
"0.57546115",
"0.5666361",
"0.5666361",
"0.5648755",
"0.563015",
"0.5618461",
"0.559866",
"0.55767435",
"0.556891... | 0.7283598 | 0 |
Query for students through homeroom, but scoped within studentlevel authorization check. This is essentially doublewrapping the authorizaiton checks; the homeroom authorization check should separately only allow access when the educator can access all students in the homeroom. | def authorized_students(homeroom)
authorized do
homeroom.students
.active
.includes(:event_notes, :interventions, :homeroom)
.to_a
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def school_students(query={})\n self.simple_client.get(\"/api/v1/schools/my/students?#{query.to_query}\")\n end",
"def query_student(hQuery)\n result = []\n\n hQuery[:status] = :active unless hQuery.key?(:status)\n\n @data[:students].each do |hValue|\n elem = hValue\n hQuery.each do |query... | [
"0.63462687",
"0.6304662",
"0.61484975",
"0.57862616",
"0.56988627",
"0.5667931",
"0.56361127",
"0.5581746",
"0.5519501",
"0.5499715",
"0.54860336",
"0.5476777",
"0.5427626",
"0.5418739",
"0.5410691",
"0.53927666",
"0.5379627",
"0.53769565",
"0.53667456",
"0.533562",
"0.53337... | 0.77949256 | 0 |
Serializes a Student into a hash with other fields joined in (that are used to perform filtering and slicing in the UI). This may be slow if you're doing it for many students without eager includes. | def fat_student_hash(student)
HashWithIndifferentAccess.new(student.as_json({
except: [
:primary_phone,
:primary_email,
:student_address
]
}).merge({
has_photo: student.has_photo,
discipline_incidents_count: student.most_recent_school_year_discipline_incidents_count,
absences_count: student.most_recent_school_year_absences_count,
tardies_count: student.most_recent_school_year_tardies_count,
homeroom_name: student.try(:homeroom).try(:name),
event_notes_without_restricted: student.event_notes_without_restricted,
interventions: student.interventions,
sped_data: sped_data(student)
}))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize_students(student_ids, section)\n students = Student\n .active\n .where(id: student_ids)\n .includes(:student_section_assignments)\n\n students.map do |student|\n grade_numeric = student.student_section_assignments.find_by_section_id(section.id).grade_numeric\n student.a... | [
"0.74007237",
"0.7180264",
"0.7028448",
"0.69895357",
"0.6417459",
"0.63001305",
"0.6236654",
"0.62192965",
"0.6130004",
"0.60334575",
"0.5991246",
"0.59414005",
"0.59389347",
"0.59350747",
"0.5875466",
"0.5874363",
"0.5831538",
"0.57497793",
"0.5737095",
"0.56373227",
"0.561... | 0.7238609 | 1 |
This only matches on homeroom_id, not `slug`, since this has led to bugs from type coercion and from collisions on ids and slugs. Works around FriendlyId, which we should move away from. Type coercion can lead to bugs like: > Homeroom.find_by_id('7263') => So ensure that this any id lookup is really an integer and manually convert these types. See for more. | def find_homeroom_by_id(homeroom_id)
strict_homeroom_id = homeroom_id.to_i.to_s.to_i
if homeroom_id.to_s == strict_homeroom_id.to_s
homeroom = Homeroom.find_by_id(strict_homeroom_id) # FriendlyId patches #find, so this is more explicit
return homeroom if homeroom.present? && homeroom.id == strict_homeroom_id
end
raise ActiveRecord::RecordNotFound
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_better_id?\n slug and found_using_numeric_id? || found_using_outdated_friendly_id?\n end",
"def normalize_friendly_id(string)\n if slug.blank?\n super\n else\n super(slug)\n end\n end",
"def bad_slug?(object)\n params[:id] != object.to_param\n end",
"def bad_slug?(object)\... | [
"0.64700574",
"0.6356033",
"0.6177835",
"0.6177835",
"0.614941",
"0.6125775",
"0.6081726",
"0.6028007",
"0.60253155",
"0.60057575",
"0.60057575",
"0.60057575",
"0.5969563",
"0.5931023",
"0.59244037",
"0.58928925",
"0.58928925",
"0.58928925",
"0.58888435",
"0.5870374",
"0.5867... | 0.6300812 | 2 |
SpEd Data as defined by Somerville Schools | def sped_data(student)
{
sped_level: sped_level(student),
sped_tooltip_message: sped_tooltip_message(student),
sped_bubble_class: sped_bubble_class(student)
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sld; end",
"def sp\n\t\t# --Stallция Preφιcς--\n\t\ts = ['S', 'Z', 'C', 'S']\n\t\tt = ['t', 'zt', 'ct', 'st']\n\t\ta = ['a', 'å', 'ä', 'ą']\n\t\tl = ['l', 'll', 'л', 'лл', 'lъ', 'llъ', 'лъ', 'ллъ',]\n\t\tc = ['c', 'z', 's', 'c', 'z', 'ц']\n\t\ti = ['i', '', 'и']\n\t\tja = ['a', 'ja', 'ya', 'ia', 'иa','я', 'ѧ... | [
"0.57599723",
"0.5654223",
"0.5592384",
"0.55232763",
"0.5443806",
"0.5325148",
"0.5241047",
"0.52281827",
"0.52018094",
"0.5200175",
"0.5169785",
"0.5169777",
"0.51659054",
"0.5161655",
"0.515208",
"0.5147694",
"0.5135845",
"0.5131139",
"0.5131139",
"0.51245856",
"0.511807",... | 0.640719 | 0 |
some helper methods that may be generally useful | def real_close(r1,r2)
(r1 - r2).abs < GeometryExpression::Epsilon
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def helpers; end",
"def helpers; end",
"def helpers; end",
"def probers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def who_we_are\r\n end",
"def schubert; end",
"def custom; end",
"def custom; end",
"def formation; end",
"def... | [
"0.7047123",
"0.6436291",
"0.6436291",
"0.6436291",
"0.6331897",
"0.62676924",
"0.62676924",
"0.62676924",
"0.62676924",
"0.6073839",
"0.60599875",
"0.60171413",
"0.60171413",
"0.5975093",
"0.59681225",
"0.5929333",
"0.58616954",
"0.5861506",
"0.5861506",
"0.5793562",
"0.5788... | 0.0 | -1 |
two_points_to_line could return a Line or a VerticalLine | def two_points_to_line(x1,y1,x2,y2)
if real_close(x1,x2)
VerticalLine.new x1
else
m = (y2 - y1).to_f / (x2 - x1)
b = y1 - m * x1
Line.new(m,b)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def two_points_to_line(x1,y1,x2,y2)\n if real_close(x1,x2)\n VerticalLine.new x1\n else\n m = (y2 - y1).to_f / (x2 - x1)\n b = y1 - m * x1\n Line.new(m,b)\n end\n end",
"def two_points_to_line(x1,y1,x2,y2) \n if real_close(x1,x2)\n VerticalLine.new x1\n else... | [
"0.8462112",
"0.8452559",
"0.8433226",
"0.8380715",
"0.7575376",
"0.6964064",
"0.6899736",
"0.66776496",
"0.6625103",
"0.64518577",
"0.64518577",
"0.63937855",
"0.6326386",
"0.6274274",
"0.62541175",
"0.6214541",
"0.6125935",
"0.6125211",
"0.6080139",
"0.60770565",
"0.6035400... | 0.84063846 | 3 |
we put this in this class so all subclasses can inherit it: the intersection of self with a NoPoints is a NoPoints object | def intersectNoPoints np
np # could also have NoPoints.new here instead
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end",
"def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end",
"def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end",
"def points; end",
"def points #:nodoc:\n ... | [
"0.704855",
"0.704855",
"0.704855",
"0.6201722",
"0.6112243",
"0.6112243",
"0.6092155",
"0.57806504",
"0.57174975",
"0.5679841",
"0.56783336",
"0.5502878",
"0.54234487",
"0.54140586",
"0.5407734",
"0.5407371",
"0.5377398",
"0.5372",
"0.53660744",
"0.5349252",
"0.533825",
"0... | 0.70432645 | 4 |
we put this in this class so all subclasses can inhert it: the intersection of self with a LineSegment is computed by first intersecting with the line containing the segment and then calling the result's intersectWithSegmentAsLineResult with the segment | def intersectLineSegment seg
line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))
line_result.intersectWithSegmentAsLineResult seg
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersectWithSegmentAsLineResult seg\n # self is the intersection \n self\n end",
"def intersectLineSegment seg\n # this is the intersect defined in method calling on \n # intersectlinesegment\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n ... | [
"0.8360925",
"0.80786705",
"0.8031761",
"0.7940218",
"0.7940218",
"0.7940218",
"0.78853285",
"0.78853285",
"0.78853285",
"0.72723234",
"0.724494",
"0.6960971",
"0.66799736",
"0.65041506",
"0.64518094",
"0.64140725",
"0.63947743",
"0.6331563",
"0.6331269",
"0.63063204",
"0.630... | 0.7969675 | 3 |
if self is the intersection of (1) some shape s and (2) the line containing seg, then we return the intersection of the shape s and the seg. seg is an instance of LineSegment | def intersectWithSegmentAsLineResult seg
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersectWithSegmentAsLineResult seg\n # self is the intersection \n self\n end",
"def intersectLineSegment seg\n # this is the intersect defined in method calling on \n # intersectlinesegment\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n ... | [
"0.814633",
"0.7911066",
"0.7835549",
"0.78199613",
"0.78199613",
"0.78199613",
"0.7744339",
"0.7744339",
"0.7744339",
"0.70674366",
"0.69469726",
"0.69240534",
"0.689842",
"0.6804724",
"0.68035567",
"0.677119",
"0.67384416",
"0.6578319",
"0.6516282",
"0.643319",
"0.64209926"... | 0.7803643 | 6 |
verificar token de mierda | def token_verify
#render json: {id: params["user"]["id"], params: params}
user_tmp = User.find(params[:id])
if user_tmp.authentication_token == params[:authentication_token]
$granted = true
render json: false
else
render json: false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token; end",
"def token; end",
"def token; end",
"def token; end",
"def token; end",
"def token; end",
"def token\n end",
"def check_token\n end",
"def token\n @token\n end",
"def token\n @token\n end",
"def token_type; end",
"def token?(token)\n return false\n end",... | [
"0.7870095",
"0.7870095",
"0.7870095",
"0.7870095",
"0.7870095",
"0.7870095",
"0.78079665",
"0.77833176",
"0.7138758",
"0.71051854",
"0.70247096",
"0.6982789",
"0.69513744",
"0.69513744",
"0.6917075",
"0.68719935",
"0.68583953",
"0.68527526",
"0.6833904",
"0.68053216",
"0.676... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def user_params
params.require(:user).permit(:user_id, :title, :body, :password_confirmation, :password, :perimission_level,:email,:name,:score)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7120904",
"0.70538116",
"0.69469863",
"0.6901261",
"0.67348766",
"0.6717708",
"0.66874576",
"0.6676195",
"0.66601187",
"0.65563625",
"0.6525127",
"0.64565873",
"0.64494514",
"0.644928",
"0.64452374",
"0.6433947",
"0.6412815",
"0.6412815",
"0.6391939",
"0.63792473",
"0.6379... | 0.0 | -1 |
GET /featured_clients GET /featured_clients.json | def index
@featured_clients = FeaturedClient.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_featured_client\n @featured_client = FeaturedClient.find(params[:id])\n end",
"def index\n @clients = current_user.clients\n render json: @clients\n end",
"def show\n render json: @client\n end",
"def get_featured\n render json: Event.where(is_featured: true), status: :ok\n end... | [
"0.6933652",
"0.683633",
"0.67539525",
"0.6728703",
"0.66623473",
"0.6645311",
"0.6645311",
"0.6645311",
"0.6645311",
"0.6645311",
"0.6645311",
"0.6645311",
"0.6604498",
"0.65847147",
"0.6570766",
"0.656262",
"0.6558943",
"0.6556442",
"0.6501677",
"0.64970773",
"0.6423044",
... | 0.78416455 | 0 |
GET /featured_clients/1 GET /featured_clients/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @featured_clients = FeaturedClient.all\n end",
"def set_featured_client\n @featured_client = FeaturedClient.find(params[:id])\n end",
"def show\n client = Client.retrieve_by_id(params[:id])\n\n render json: client, serializer: SingleClientSerializer\n end",
"def show\n @clie... | [
"0.7750333",
"0.71369797",
"0.70712596",
"0.7000369",
"0.7000369",
"0.7000369",
"0.7000369",
"0.7000369",
"0.7000369",
"0.7000369",
"0.6965878",
"0.69514996",
"0.6828995",
"0.68106806",
"0.6802026",
"0.67406523",
"0.6735485",
"0.67273724",
"0.6662405",
"0.66607916",
"0.665218... | 0.0 | -1 |
POST /featured_clients POST /featured_clients.json | def create
@featured_client = FeaturedClient.new(featured_client_params)
respond_to do |format|
if @featured_client.save
format.html { redirect_to @featured_client, notice: 'Featured client was successfully created.' }
format.json { render :show, status: :created, location: @featured_client }
else
format.html { render :new }
format.json { render json: @featured_client.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_featured_client\n @featured_client = FeaturedClient.find(params[:id])\n end",
"def update_features(client_id)\n response = self.class.put(\"https://app.klipfolio.com/api/1.0/clients/#{client_id}/features\", basic_auth: @auth, headers: { \"Content-Type\" => \"application/json\" },\n body: {\... | [
"0.67577773",
"0.6596986",
"0.6583391",
"0.6533749",
"0.6523827",
"0.6325813",
"0.6287912",
"0.6286387",
"0.62818676",
"0.62335885",
"0.6210315",
"0.62056553",
"0.62049633",
"0.6194312",
"0.6185106",
"0.61788565",
"0.61700845",
"0.6154021",
"0.6149242",
"0.6149242",
"0.614924... | 0.7798717 | 0 |
PATCH/PUT /featured_clients/1 PATCH/PUT /featured_clients/1.json | def update
respond_to do |format|
if @featured_client.update(featured_client_params)
format.html { redirect_to @featured_client, notice: 'Featured client was successfully updated.' }
format.json { render :show, status: :ok, location: @featured_client }
else
format.html { render :edit }
format.json { render json: @featured_client.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_features(client_id)\n response = self.class.put(\"https://app.klipfolio.com/api/1.0/clients/#{client_id}/features\", basic_auth: @auth, headers: { \"Content-Type\" => \"application/json\" },\n body: {\n features:[{\"name\":\"public_dashboards\",\"enabled\":true},\n {\"name\":\"publishe... | [
"0.7180061",
"0.71587324",
"0.67126924",
"0.6706564",
"0.6624684",
"0.66181684",
"0.66181684",
"0.657036",
"0.6560939",
"0.6560939",
"0.6537225",
"0.6521621",
"0.6474115",
"0.64677155",
"0.64466053",
"0.64425135",
"0.64348674",
"0.6433545",
"0.64225364",
"0.64199555",
"0.6416... | 0.7571402 | 0 |
DELETE /featured_clients/1 DELETE /featured_clients/1.json | def destroy
@featured_client.destroy
respond_to do |format|
format.html { redirect_to featured_clients_url, notice: 'Featured client was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_ur... | [
"0.75142395",
"0.745067",
"0.745067",
"0.745067",
"0.745067",
"0.745067",
"0.745067",
"0.745067",
"0.745067",
"0.745067",
"0.744217",
"0.7420447",
"0.7420447",
"0.7416775",
"0.7321803",
"0.73160225",
"0.7283156",
"0.7262876",
"0.7257515",
"0.7226291",
"0.72083664",
"0.71967... | 0.79933196 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_featured_client
@featured_client = FeaturedClient.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.533008... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def featured_client_params
params.require(:featured_client).permit(:image, :website_name, :testimonial)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
Convert value to bit array to_multi_bit( '0b101010', 6 ) => [1,0,1,0,1,0] to_multi_bit( '0b101010', 10 ) => [1,0,1,0,1,0,0,0,0,0] to_multi_bit( '0b101010', 3 ) => [1,0,1] to_multi_bit( '0b01010' ) => [1,0,1,0] minimum array size for val to_multi_bit( '' ) => [0] null string is equivalent to 0 | def to_multi_bit( val, array_size=-1 )
array_size = Integer(array_size) unless array_size.kind_of?(Integer)
if val == '' then
val = '0'
end
begin
val = Integer(val).to_s(2)
rescue => e
raise ParameterError, "#{__method__} contains invalid string for number"
end
arr = val.scan(/./).map{ |b| b.to_i(2) }
return arr if array_size < 0
return _fit_array_length( arr, array_size )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_bit_array\n BitMapping.number_to_bit_array(number)\n end",
"def input_to_bitstring( value )\r\n value\r\n end",
"def number_to_bit_array(number, minimum_binary_places = 0)\n assert_non_negative(number)\n array = []\n while number > 0\n array << (number & 1)\n ... | [
"0.71019197",
"0.64645636",
"0.6271918",
"0.6154316",
"0.6136181",
"0.61169845",
"0.60882556",
"0.6005125",
"0.59984744",
"0.5980631",
"0.59593886",
"0.5871188",
"0.58386976",
"0.5829",
"0.58206475",
"0.5820063",
"0.5797414",
"0.5794982",
"0.57928",
"0.56683254",
"0.56529534"... | 0.7963539 | 0 |
class_exsits?("String") => ture class_exists?("djfakf20dak") => false | def class_exists?(classname)
str = classname.to_s
eval("defined?(#{str}) && #{str}.is_a?(Class)") == true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_exists? string\n\tc = Object.const_get string\n\treturn c.is_a? Class\nrescue NameError\n\treturn false\nend",
"def class_exists?(class_name)\n begin\n class_name.constantize\n true\n rescue NameError => ne\n false\n end\n end",
"def class_exists?(class_name)\n klass = Modul... | [
"0.8096085",
"0.76872027",
"0.7647681",
"0.7635851",
"0.75350523",
"0.74830174",
"0.7474969",
"0.7474969",
"0.7474969",
"0.7412033",
"0.73887044",
"0.7370037",
"0.72096604",
"0.71148914",
"0.7091627",
"0.70484865",
"0.7038288",
"0.69804",
"0.69743073",
"0.6939178",
"0.6915956... | 0.8161565 | 0 |
Returns info for the specified venue. | def venue(id)
options = { :venue_id => id }
get('/venue_info', options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def venue(id)\n get(\"venues/#{id}\").venue\n end",
"def venue(vid, options = {})\n options.merge!({ :query => { :key => @api_key } })\n self.class.get(\"/venues/#{vid}\", options)\n end",
"def venue\n \t@events = Event.where(:venue => params[:venue])\n\n \trespond_to do |format|\n \t\tif... | [
"0.7556617",
"0.72925836",
"0.71240777",
"0.6950226",
"0.69235957",
"0.6780076",
"0.6749551",
"0.6677567",
"0.66518515",
"0.6548156",
"0.64478546",
"0.6389568",
"0.63407123",
"0.63203627",
"0.63155055",
"0.6270055",
"0.62002933",
"0.6194573",
"0.616607",
"0.61569226",
"0.6144... | 0.79124004 | 0 |
GET /communities/1 GET /communities/1.json | def show
@community = Community.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @community }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @communities = Community.all\n render json: {items: @communities}\n end",
"def show\n @community = @district.communities.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @community }\n end\n end",
"def index\n @communities = @dist... | [
"0.75319916",
"0.743811",
"0.73624486",
"0.7266786",
"0.7266786",
"0.7210947",
"0.7142459",
"0.70275843",
"0.7001811",
"0.6939018",
"0.68679535",
"0.6789699",
"0.6706936",
"0.67003244",
"0.66298616",
"0.6583088",
"0.6502852",
"0.63781494",
"0.6237151",
"0.6207699",
"0.607654"... | 0.6814191 | 11 |
GET /communities/new GET /communities/new.json | def new
@community = Community.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @community }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @community = @district.communities.new\n\n respond_to do |format|\n format.html\n format.json { render json: @community }\n end\n end",
"def create\n @community = @district.communities.new(params[:community])\n\n respond_to do |format|\n if @community.save\n format... | [
"0.7959961",
"0.71575254",
"0.7025313",
"0.7009266",
"0.6981981",
"0.695217",
"0.6947142",
"0.68749774",
"0.68749774",
"0.6841163",
"0.6815259",
"0.67953557",
"0.6756949",
"0.6732288",
"0.6707693",
"0.66622007",
"0.6636089",
"0.66074175",
"0.6576715",
"0.65577555",
"0.65519",... | 0.7494975 | 1 |
POST /communities POST /communities.json | def create
@community = Community.new(params[:community])
respond_to do |format|
if @community.save
format.html { redirect_to @community, notice: 'Community was successfully created.' }
format.json { render json: @community, status: :created, location: @community }
else
format.html { render action: "new" }
format.json { render json: @community.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @community = @district.communities.new(params[:community])\n\n respond_to do |format|\n if @community.save\n format.html { redirect_to admin_district_communities_url, notice: 'Community was successfully created.' }\n format.json { render json: @community, status: :created, loc... | [
"0.70707315",
"0.66136265",
"0.6542512",
"0.6542512",
"0.65264356",
"0.6512408",
"0.6478941",
"0.64413625",
"0.642376",
"0.6319061",
"0.6268977",
"0.62562805",
"0.62562805",
"0.6253957",
"0.6224876",
"0.61537445",
"0.6138845",
"0.6112662",
"0.6100711",
"0.6098621",
"0.6066858... | 0.6584072 | 2 |
PUT /communities/1 PUT /communities/1.json | def update
@community = Community.find(params[:id])
respond_to do |format|
if @community.update_attributes(params[:community])
format.html { redirect_to @community, notice: 'Community was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @community.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @community = current_user.own_communities.find(params[:id])\n flash[:notice] = 'Community was successfully updated.' if @community.update_attributes(update_params)\n respond_with(@community)\n end",
"def update\n if @community.update(community_params)\n render :show, status: :ok, l... | [
"0.70225936",
"0.67517334",
"0.67264223",
"0.6724205",
"0.6630993",
"0.65974313",
"0.65974313",
"0.65297955",
"0.6431997",
"0.6372459",
"0.6371188",
"0.6314842",
"0.6314842",
"0.62161005",
"0.6210379",
"0.6209496",
"0.6209496",
"0.6209496",
"0.6209496",
"0.6209496",
"0.620949... | 0.67545354 | 1 |
DELETE /communities/1 DELETE /communities/1.json | def destroy
@community = Community.find(params[:id])
@community.destroy
respond_to do |format|
format.html { redirect_to communities_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @community.destroy\n respond_to do |format|\n format.html { redirect_to communities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @community = Community.find(params[:id])\n @community.destroy\n\n respond_to do |format|\n format.html { redire... | [
"0.77494264",
"0.7628726",
"0.758887",
"0.7582639",
"0.75190085",
"0.75190085",
"0.75190085",
"0.75190085",
"0.7345361",
"0.7032567",
"0.6991609",
"0.6987676",
"0.6948728",
"0.69379205",
"0.69283324",
"0.6902466",
"0.6833026",
"0.68261915",
"0.6721534",
"0.67208093",
"0.66859... | 0.77372575 | 1 |
Load appium.txt (toml format) into system ENV the basedir of this file + appium.txt is what's used | def load_appium_txt opts
raise 'opts must be a hash' unless opts.kind_of? Hash
opts.each_pair { |k,v| opts[k.to_s.downcase.strip.intern] = v }
opts = {} if opts.nil?
file = opts.fetch :file, nil
raise 'Must pass file' unless file
verbose = opts.fetch :verbose, false
# Check for env vars in .txt
parent_dir = File.dirname file
toml = File.expand_path File.join parent_dir, 'appium.txt'
puts "appium.txt path: #{toml}" if verbose
# @private
def update data, *args
args.each do |name|
var = data[name]
ENV[name] = var if var
end
end
toml_exists = File.exists? toml
puts "Exists? #{toml_exists}" if verbose
data = nil
if toml_exists
require 'toml'
puts "Loading #{toml}" if verbose
# bash requires A="OK"
# toml requires A = "OK"
#
# A="OK" => A = "OK"
data = File.read toml
data = data.split("\n").map do |line|
line.sub /([^\s])\=/, "\\1 = "
end.join "\n"
data = TOML::Parser.new(data).parsed
ap data unless data.empty? if verbose
update data, 'APP_PATH', 'APP_APK', 'APP_PACKAGE',
'APP_ACTIVITY', 'APP_WAIT_ACTIVITY',
'DEVICE'
# ensure app path is resolved correctly from the context of the .txt file
ENV['APP_PATH'] = Appium::Driver.absolute_app_path ENV['APP_PATH']
end
# return list of require files as an array
# nil if require doesn't exist
if data && data['require']
r = data['require']
r = r.kind_of?(Array) ? r : [ r ]
# ensure files are absolute
r.map! do |file|
file = file.include?(File::Separator) ? file :
File.join(parent_dir, file)
file = File.expand_path file
File.exists?(file) ? file : nil
end
r.compact! # remove nils
files = []
# now expand dirs
r.each do |item|
unless File.directory? item
# save file
files << item
next # only look inside folders
end
Dir.glob(File.join(item, '**/*.rb')) do |file|
# do not add folders to the file list
files << File.expand_path(file) unless File.directory? file
end
end
files
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_driver\n return if $driver\n caps = Appium.load_appium_txt file: File.join(Dir.pwd, 'appium.txt')\n $driver = Appium::Driver.new caps\n # debug \"setting up driver using #{caps.to_yaml}\"\nend",
"def root_dir\n __FILE__.match(%r{.*(appium-test-runner)}).to_s\n end",
"def run_android test_file... | [
"0.5981987",
"0.5774271",
"0.56039727",
"0.55971855",
"0.55521613",
"0.54813564",
"0.543904",
"0.541871",
"0.54058915",
"0.5370258",
"0.5336662",
"0.5312171",
"0.5307017",
"0.5273903",
"0.527349",
"0.5264785",
"0.5259214",
"0.5235099",
"0.5223799",
"0.52233565",
"0.519876",
... | 0.81331265 | 0 |
Returns the server's version string | def server_version
status['value']['build']['version']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_server_version\n server_info[:server_version]\n end",
"def version\n @version ||= exec('SHOW server_version')[0]['server_version'].split[0]\n end",
"def server_version\n request(auth: false, expects: 200)['version']\n rescue => ex\n error { \"Server version exception\" }\n ... | [
"0.81980455",
"0.818916",
"0.79347074",
"0.7893697",
"0.77782583",
"0.7761562",
"0.77331555",
"0.77269936",
"0.7645589",
"0.752514",
"0.7523649",
"0.7523649",
"0.7495116",
"0.7490963",
"0.7465442",
"0.73399574",
"0.7339925",
"0.7339925",
"0.7330919",
"0.7274454",
"0.72268337"... | 0.75308967 | 9 |
Get the server url for sauce or local based on env vars. | def server_url
return @custom_url if @custom_url
if !@sauce_username.nil? && !@sauce_access_key.nil?
"http://#{@sauce_username}:#{@sauce_access_key}@ondemand.saucelabs.com:80/wd/hub"
else
"http://127.0.0.1:#{@port}/wd/hub"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def site_url\n if Rails.env.production?\n # Place your production URL in the quotes below\n \"http://www.ezonline.com/\"\n else\n # Our dev & test URL\n \"http://ezonline-dev.com:3000\"\n end\n end",
"def host\n return @@nfg_urls['sandbox']['host'] if @use_sandbox\n @@nfg_... | [
"0.7494612",
"0.7353119",
"0.7247557",
"0.71140593",
"0.7103848",
"0.7103848",
"0.7079462",
"0.7078015",
"0.70766836",
"0.7011295",
"0.70039564",
"0.69781536",
"0.6976606",
"0.6950521",
"0.6943098",
"0.6860118",
"0.68076366",
"0.6805368",
"0.6766746",
"0.6763752",
"0.67558944... | 0.7927469 | 0 |
Takes a png screenshot and saves to the target path. Example: screenshot '/tmp/hi.png' | def screenshot png_save_path
@driver.save_screenshot png_save_path
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_screenshot(png_path)\n extension = File.extname(png_path).downcase\n if extension != '.png'\n ::Appium::Logger.warn 'name used for saved screenshot does not match file type. ' \\\n 'It should end with .png extension'\n end\n File.open(png... | [
"0.7713248",
"0.73897016",
"0.7361552",
"0.7261436",
"0.72201663",
"0.71657145",
"0.71561575",
"0.7147954",
"0.7093388",
"0.7071087",
"0.7060184",
"0.7058387",
"0.70374185",
"0.70342076",
"0.7021363",
"0.69934297",
"0.69775933",
"0.69728357",
"0.6949938",
"0.69415283",
"0.691... | 0.8234669 | 0 |
Creates a new global driver and quits the old one if it exists. | def start_driver
@client = @client || Selenium::WebDriver::Remote::Http::Default.new
@client.timeout = 999999
begin
@driver = Selenium::WebDriver.for :remote, http_client: @client, desired_capabilities: capabilities, url: server_url
# Load touch methods. Required for Selendroid.
@driver.extend Selenium::WebDriver::DriverExtensions::HasTouchScreen
# export session
if @export_session
begin
File.open('/tmp/appium_lib_session', 'w') do |f|
f.puts @driver.session_id
end
rescue
end
end
rescue Errno::ECONNREFUSED
raise 'ERROR: Unable to connect to Appium. Is the server running?'
end
# Set timeout to a large number so that Appium doesn't quit
# when no commands are entered after 60 seconds.
# broken on selendroid: https://github.com/appium/appium/issues/513
mobile :setCommandTimeout, timeout: 9999 unless @device == 'Selendroid'
# Set implicit wait by default unless we're using Pry.
@driver.manage.timeouts.implicit_wait = @default_wait unless defined? Pry
@driver
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_driver\n @new_driver ||= run_context.chef_provisioning.driver_for(new_resource.driver)\n end",
"def create_driver name\n\t\tdriver = Driver.new name\n\t\t@drivers[driver.name] = driver\n\t\tdriver\t\t\n\tend",
"def reset_driver\n\t\t\t@driver.quit if @driver\n\t\t\t@driver = nil\n\t\tend",
... | [
"0.61282456",
"0.609435",
"0.596046",
"0.59585905",
"0.5870247",
"0.5737365",
"0.57364815",
"0.5728515",
"0.57254726",
"0.56848717",
"0.5647045",
"0.55671555",
"0.55487204",
"0.5531377",
"0.5495244",
"0.5397843",
"0.53778654",
"0.53486824",
"0.53267455",
"0.5323303",
"0.52947... | 0.45938253 | 90 |
Set implicit wait and default_wait to zero. | def no_wait
@last_waits = [@default_wait, 0]
@default_wait = 0
@driver.manage.timeouts.implicit_wait = 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_wait\n @default_wait\n end",
"def set_implicit_wait_by_default(wait)\n return if @default_wait.nil?\n\n @driver.manage.timeouts.implicit_wait = wait\n rescue ::Selenium::WebDriver::Error::UnknownError => e\n unless e.message.include?('The operation requested is not y... | [
"0.76416105",
"0.7500537",
"0.721602",
"0.65911514",
"0.65868926",
"0.6399924",
"0.6341235",
"0.63308007",
"0.6221979",
"0.6141044",
"0.60687554",
"0.60397017",
"0.60141146",
"0.5988994",
"0.5857542",
"0.5737748",
"0.5725504",
"0.5707285",
"0.5707285",
"0.5707285",
"0.5680033... | 0.7951602 | 0 |
Set implicit wait and default_wait to timeout, defaults to 30. if set_wait is called without a param then the second to last wait will be used. ```ruby` set_wait 2 set_wait 3 set_wait 2 ```` | def set_wait timeout=nil
if timeout.nil?
# puts "timeout = @default_wait = @last_wait"
# puts "timeout = @default_wait = #{@last_waits}"
timeout = @default_wait = @last_waits.first
else
@default_wait = timeout
# puts "last waits before: #{@last_waits}"
@last_waits = [@last_waits.last, @default_wait]
# puts "last waits after: #{@last_waits}"
end
@driver.manage.timeouts.implicit_wait = timeout
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_implicit_wait_by_default(wait)\n return if @default_wait.nil?\n\n @driver.manage.timeouts.implicit_wait = wait\n rescue ::Selenium::WebDriver::Error::UnknownError => e\n unless e.message.include?('The operation requested is not yet implemented')\n raise ::Appium::Core::Er... | [
"0.7200762",
"0.6679357",
"0.65788174",
"0.6443681",
"0.6226858",
"0.596722",
"0.59339607",
"0.58681065",
"0.5848157",
"0.5846182",
"0.58411944",
"0.58411944",
"0.58140564",
"0.5790305",
"0.57674325",
"0.57514125",
"0.57201034",
"0.5716633",
"0.56703126",
"0.5669643",
"0.5607... | 0.8285323 | 0 |
Returns the default client side wait. This value is independent of what the server is using | def default_wait
@default_wait
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_timeout\n @wait_timeout ||= options[:wait_timeout] || DEFAULT_WAIT_TIMEOUT\n end",
"def set_implicit_wait_by_default(wait)\n return if @default_wait.nil?\n\n @driver.manage.timeouts.implicit_wait = wait\n rescue ::Selenium::WebDriver::Error::UnknownError => e\n unle... | [
"0.6918232",
"0.60194534",
"0.59551215",
"0.588512",
"0.5776252",
"0.57113725",
"0.5703889",
"0.56906146",
"0.56605303",
"0.56548905",
"0.5632716",
"0.5559097",
"0.54802066",
"0.5451355",
"0.54511195",
"0.5442161",
"0.5430147",
"0.5423666",
"0.540995",
"0.5396949",
"0.5383813... | 0.7904518 | 0 |
Helper method for mobile gestures driver.execute_script 'mobile: swipe', endX: 100, endY: 100, duration: 0.01 becomes mobile :swipe, endX: 100, endY: 100, duration: 0.01 | def mobile method, *args
raise 'Method must not be nil' if method.nil?
raise 'Method must have .to_s' unless method.respond_to? :to_s
@driver.execute_script "mobile: #{method.to_s}", *args
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swipe(opts)\n start_x = opts.fetch :start_x, 0\n start_y = opts.fetch :start_y, 0\n end_x = opts.fetch :end_x, 0\n end_y = opts.fetch :end_y, 0\n duration = opts.fetch :duration, 2\n\n \n action = Appium::TouchAction.new.press(x: start_x, y: start_y).move_to(x: end_x, y: end_y).release \n actio... | [
"0.7361401",
"0.7070836",
"0.65706843",
"0.6538832",
"0.63910407",
"0.63701206",
"0.6151815",
"0.6132001",
"0.6125521",
"0.6123976",
"0.58873904",
"0.58606666",
"0.57438546",
"0.54728895",
"0.5465492",
"0.5428572",
"0.5262703",
"0.52456886",
"0.5206053",
"0.5147923",
"0.51385... | 0.65246856 | 4 |
Quit the driver and Pry. quit and exit are reserved by Pry. | def x
driver_quit
exit # exit pry
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quit!\n quit\n exit!\n end",
"def quit_driver()\n @driver.shutdown\n end",
"def quit\r\n @@driver.quit\r\n end",
"def quit\n\t\t@driver.quit\n\tend",
"def quit\n exit(1)\n end",
"def quit\n @ui.close\n @player.close\n @logger.close\n exit\n end",
"d... | [
"0.7649962",
"0.75097275",
"0.7461979",
"0.7409583",
"0.7335107",
"0.7230508",
"0.7230508",
"0.7108723",
"0.70328236",
"0.703234",
"0.70131856",
"0.6982187",
"0.69693995",
"0.6916052",
"0.68841213",
"0.68841213",
"0.68736315",
"0.683998",
"0.6834304",
"0.682177",
"0.6782976",... | 0.784934 | 0 |
Defining an each method for looping through each node | def each
node = @head
while node
yield node
node = node.next_node
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each(node, &block); end",
"def each\n self.traverse_down { |node| yield(node) }\n end",
"def each(node, &block)\n visit(node, &block)\n end",
"def each_node(&block)\n\t\t\tnodes.each(&block)\n\t\tend",
"def each_node(&block)\n nodes.each(&block)\n end",
"def each_node(&block)\... | [
"0.8541049",
"0.8030135",
"0.80074793",
"0.7959448",
"0.7943027",
"0.7941357",
"0.7941357",
"0.7824405",
"0.78107595",
"0.7760559",
"0.7760559",
"0.7612355",
"0.7590659",
"0.75728285",
"0.75364065",
"0.75364065",
"0.7455355",
"0.7450453",
"0.74457455",
"0.73965573",
"0.739494... | 0.7566883 | 14 |
Finds and returns the 1st node whose value is 'value' | def find(value)
self.each {|node| return node if node.value == value}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(value)\n node = @head\n while node\n if node.value == value\n return node\n end\n node = node.next\n end\n\n return nil\n end",
"def find_node(value)\n current = @anchor.next_node\n while current != @anchor\n return current if current.value == va... | [
"0.80587685",
"0.80214393",
"0.7959897",
"0.7671774",
"0.764562",
"0.764562",
"0.74783874",
"0.74122894",
"0.7408482",
"0.73552215",
"0.73340523",
"0.7307569",
"0.7260175",
"0.7225086",
"0.7193016",
"0.7160144",
"0.713884",
"0.7131601",
"0.7126046",
"0.71244234",
"0.7061111",... | 0.81960785 | 0 |
find_all(value) finds and return (in an array) all the nodes whose value is 'value' | def find_all(value)
nodes = []
self.each {|node| nodes << node if node.value == value}
nodes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def elements_by_xpath(value)\n find_by_xpath(value)\n end",
"def find_all_nodes(xpath, select_result_value=false)\n if self.feed_data_type != :xml\n raise \"The feed data type is not xml.\"\n end\n return FeedTools::XmlHelper.try_xpaths_all(self.channel_node, [xpath],\n :... | [
"0.73790395",
"0.6820984",
"0.67537713",
"0.62753576",
"0.62564236",
"0.6141319",
"0.61087537",
"0.6062094",
"0.6044982",
"0.60254693",
"0.59540236",
"0.58442485",
"0.5819881",
"0.5805825",
"0.5749595",
"0.5743802",
"0.57175523",
"0.57110125",
"0.5671111",
"0.56692845",
"0.56... | 0.859019 | 0 |
push(value) adds a value 'value' to the end of the linked list | def push(value)
last.next_node = Node.new(value, nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push(value)\n @head = LinkedListNode.new(value, @head)\n end",
"def push(value)\n\t\t\t\tif @length == 0\n\t\t\t\t\t@head = @tail = newNode(nil, value, nil)\n\t\t\t\telse\n\t\t\t\t\t@tail.next = newNode(@tail, value, nil)\n\t\t\t\t\t@tail = @tail.next\n\n\t\t\t\t\tif @length == 1\n\t\t\t\t\t\t@head... | [
"0.8621315",
"0.8543513",
"0.8484303",
"0.8457438",
"0.8457438",
"0.84379774",
"0.84340274",
"0.84340274",
"0.84321713",
"0.8428468",
"0.84120625",
"0.84027535",
"0.8401683",
"0.8401683",
"0.83994704",
"0.83962727",
"0.83738476",
"0.8365877",
"0.83572245",
"0.8356332",
"0.835... | 0.86422974 | 0 |
Adds a node of value 'value' at the beginning of the linked list | def unshift(value)
@head = Node.new(value, @head)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepend( value )\n new_node = Node.new value\n\n # Whatever node was at the start of the list, it\n # is now the 'next' node for our newly created node\n new_node.next = @head\n\n # The new head of the list is set to be the new\n # node that we just created\n @head = new_node\n end",
"d... | [
"0.8733416",
"0.8733416",
"0.8685038",
"0.86434394",
"0.8640737",
"0.86390406",
"0.85841787",
"0.8580805",
"0.85779417",
"0.8562475",
"0.85408056",
"0.85397273",
"0.8533522",
"0.8485086",
"0.84842336",
"0.84461373",
"0.84382164",
"0.84378195",
"0.8435319",
"0.8422685",
"0.840... | 0.7564068 | 67 |
Returns the last element of the linked list | def last
self.each {|node| return node if node.next_node == nil}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last\n node = @head;\n return node if node.next.nil?\n until (node.next.nil?) #until end of list\n node = node.next\n return node if node.next.nil?\n end\n end",
"def get_last\r\n # return nil if the linked list is empty\r\n if @head.nil?\r\n return nil\r\n end\r\n \r\... | [
"0.86631894",
"0.86070114",
"0.85368365",
"0.85224015",
"0.8517871",
"0.85147595",
"0.8500174",
"0.8498962",
"0.8478527",
"0.8453789",
"0.8438831",
"0.842848",
"0.84145886",
"0.83945376",
"0.83919555",
"0.83919555",
"0.83917606",
"0.838296",
"0.8368591",
"0.83079076",
"0.8302... | 0.7898516 | 31 |
Returns the length of the linked list | def length
count = 0
node = @head
while node
count += 1
node = node.next_node
end
count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length\n # calculates the length of the list\n counter = @head ? 1 : 0\n node = @head\n while node.next_node\n node = node.next_node\n end\n counter\n end",
"def length\n current_node = @head\n return 0 unless current_node\n list_length = 0\n until current_node.nil?\n ... | [
"0.89962983",
"0.8955834",
"0.8725703",
"0.8650639",
"0.86448807",
"0.86381394",
"0.85893565",
"0.85469913",
"0.85440654",
"0.8532601",
"0.8526588",
"0.8516422",
"0.849366",
"0.8490331",
"0.84609723",
"0.8437055",
"0.8402402",
"0.8385143",
"0.83397275",
"0.82935214",
"0.82833... | 0.8568018 | 7 |
The unique name of this Dependency Manager. In general, the name should follow the `_ is the value of DependencyManagertype is the name of the dependency manager. | def name
raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#name` method")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_for(dependency)\n dependency.name\n end",
"def name_for(dependency)\n dependency.name\n end",
"def name_for(dependency)\n dependency.name\n end",
"def manager_name\n manager.name\n end",
"def name()\n return self.manager.dictionary[self]\n end",
"def name_... | [
"0.68291986",
"0.68291986",
"0.68291986",
"0.66925323",
"0.6687717",
"0.6595005",
"0.65885156",
"0.65880954",
"0.6515661",
"0.6497887",
"0.6472964",
"0.6430907",
"0.63553137",
"0.6346615",
"0.63086575",
"0.630731",
"0.629868",
"0.62757766",
"0.6240983",
"0.62269354",
"0.62268... | 0.6398306 | 12 |
The "type" of dependencies this manager manages. This can be the language, tool, etc. | def type
raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#type` method")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type\n @klass.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Class) ? \"class\" : \"module\"\n end",
"def type\n @type ||= self.class.name.split('::').last\n end",
"def dependency name, version, type = :runtime\n raise \"Unknown dependency type: #{type}\" unless\n [:runtime, :dev, :de... | [
"0.6768606",
"0.64739126",
"0.64718497",
"0.6274962",
"0.61399627",
"0.61187696",
"0.608098",
"0.60559875",
"0.60549706",
"0.60549706",
"0.60549706",
"0.601348",
"0.6011569",
"0.59861875",
"0.59820884",
"0.59820884",
"0.59820884",
"0.59811634",
"0.59806734",
"0.5944626",
"0.5... | 0.7233944 | 0 |
A humanreadable description of the files/folders that indicate this dependency manager is in use. | def signature
raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#signature` method")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def describe\n\t\t\"Shows the folder and files of the present working directory.\"\n\tend",
"def file_name_list\n @target.source_build_phase.file_display_names\n end",
"def fs_description\n repo_paths = root_paths || [ File.dirname(child_paths[\"cookbooks\"][0]) ]\n result = \"reposit... | [
"0.6525566",
"0.64706236",
"0.62717277",
"0.6154704",
"0.5927859",
"0.5830693",
"0.58079696",
"0.58079696",
"0.58079696",
"0.5676699",
"0.5674685",
"0.5625328",
"0.56200796",
"0.5604361",
"0.559843",
"0.5549027",
"0.5549027",
"0.5543946",
"0.55379945",
"0.5514648",
"0.5461196... | 0.0 | -1 |
Whether or not we were able to detect that this dependency manager is currently in use in our directory | def detected?
raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#detected?` method")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dependencies_satisfied?\n missing_dependencies.empty?\n end",
"def dependency_met?\n true\n end",
"def dependencies_resolved?\n !@resolved_dependencies.nil?\n end",
"def exist?\n ruby_gems_fetcher.started?\n end",
"def dependencies_met?\n @dependencies_met ||= c... | [
"0.687721",
"0.6756084",
"0.6721105",
"0.66868156",
"0.66477644",
"0.66351885",
"0.66005546",
"0.65266544",
"0.65060323",
"0.64795166",
"0.6398061",
"0.6378547",
"0.63436997",
"0.6313732",
"0.6296466",
"0.6296143",
"0.62767833",
"0.62705517",
"0.62301517",
"0.62250626",
"0.62... | 0.61650556 | 28 |
The command to run to install dependency if one or more is missing | def install_command
raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#install_command` method")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_requirement(requirement)\n if paths_for_extconf = Creosote::Package.installed(requirement, :default_only => true)\n puts \"requirement #{requirement} is already installed at #{paths_for_extconf.inspect}.\"\n paths_for_extconf = [paths_for_extconf].flatten\n add_extconf_args_for requirem... | [
"0.68881327",
"0.67534816",
"0.6500015",
"0.6431194",
"0.6401981",
"0.6361711",
"0.6311167",
"0.6275268",
"0.62538075",
"0.62434673",
"0.62385434",
"0.6215292",
"0.6120765",
"0.6111655",
"0.6102539",
"0.6102082",
"0.60575306",
"0.6020774",
"0.6020774",
"0.6009196",
"0.599297"... | 0.6348831 | 6 |
Implementation's of this method in subclasses are the methods that are responsible for all the heavylifting when it comes to determining the dependencies (and their licenses). They should return an array of `LicenseScout::Dependency`. | def dependencies
[]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def licenses\n licenses = []\n uris = metadata[dataset_uri][dct.license.to_s]\n if uris.nil?\n []\n else\n uris.each do |uri|\n l = metadata[uri]\n licenses << License.new(:uri => uri, :name => l[dct.title.to_s])\n end\n return l... | [
"0.6979492",
"0.68642575",
"0.6855722",
"0.6850754",
"0.6844061",
"0.684021",
"0.67019534",
"0.6685572",
"0.66536504",
"0.65131265",
"0.6511361",
"0.6506128",
"0.64482623",
"0.64454293",
"0.64454293",
"0.64454293",
"0.64454293",
"0.643095",
"0.6416843",
"0.63927746",
"0.63927... | 0.69650996 | 1 |
A helper that allows you to quickly create a new Dependency (with the type) | def new_dependency(name, version, path)
LicenseScout::Log.debug("[#{type}] Found #{name} #{version}#{" #{path}" unless path.nil?}")
Dependency.new(name, version, path, type)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def d(*args)\n Dependency.new(*args)\n end",
"def as_a_dependency\n Aws::Templates::Utils::Dependency.new(object)\n end",
"def add_dependency_with_type(dependency, type, requirements)\n requirements = if requirements.empty?\n Gem::Requirement.default\n else\n req... | [
"0.70160085",
"0.6388023",
"0.62843645",
"0.61787224",
"0.6020573",
"0.59608924",
"0.5925612",
"0.5895755",
"0.5841771",
"0.5823852",
"0.5804395",
"0.57698995",
"0.5739764",
"0.5675239",
"0.567129",
"0.5561659",
"0.55614346",
"0.5532884",
"0.5526409",
"0.5510601",
"0.54771894... | 0.694366 | 1 |
Creates and returns a new RecBack MazeHelper object. Many options are supported: [:width] The number of columns in the maze. [:height] The number of rows in the maze. [:seed] The maze algorithm to use. This should be a class, | def initialize(options = {})
@width = (options[:width] || 10).to_i
@height = (options[:height] || @width).to_i
@seed = (options[:seed] || rand(0xFFFF_FFFF)).to_i
@grid = Array.new(height) {Array.new(width, 0)}
srand(@seed)
# start carving the maze passage from the upper-left corner
carve_passages_from(0, 0, @grid)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redesign\r\n\t\tm = MazeMaker.new(@n,@m)\r\n\t\t@maze = m.make_maze\r\n\tend",
"def get_maze(full=true)\n Maze.new(@width, @height, @start_p, @end_p, full)\n end",
"def generate\n carve maze.cell_at(0,0)\n maze\n end",
"def initialize(options = {})\n @width = (options[:width] || 10).t... | [
"0.60306096",
"0.5867004",
"0.5722799",
"0.5674609",
"0.55316454",
"0.5510154",
"0.54470944",
"0.5416506",
"0.5395136",
"0.5344716",
"0.5318697",
"0.52820045",
"0.5241874",
"0.5171722",
"0.5171573",
"0.5103918",
"0.5090913",
"0.5081683",
"0.5038239",
"0.49908844",
"0.49598753... | 0.680969 | 0 |
3. The recursivebacktracking algorithm itself | def carve_passages_from(cx, cy, grid)
# the list of directions the algorithm will be moving to carve the maze passage
# the array is randomized to minimize bias
directions = [N, S, E, W].shuffle
# the algorithm iterates over all the direction (for a given cell coordinate)
directions.each do |direction|
# determines the cell coordinate in the given direction
nx = cx + DX[direction]
ny = cy + DY[direction]
# checking if the selected cell is valid or not
# - it should be within the grid boundaries of the maze
# - AND it should not have been visited before (zero-valued coordinate)
unless ny.between?(0, grid.length - 1) && nx.between?(0, grid[ny].length - 1) && grid[ny][nx] == 0
next
end
# carve the cell passage out of the current cell to the next
grid[cy][cx] |= direction
grid[ny][nx] |= OPPOSITE[direction]
# recursively call the function to the new cell
carve_passages_from(nx, ny, grid)
end
@grid = grid
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive_solution\n\n end",
"def backtrack(nums, cur_array, result)\n if cur_array.size == nums.size\n result << cur_array.clone\n\n return\n end\n\n (0..nums.length - 1).each do |i|\n next if cur_array.include?(nums[i])\n\n cur_array << nums[i]\n\n backtrack(nums, cur_array, result)\n\n ... | [
"0.7402316",
"0.66856354",
"0.66034263",
"0.6580423",
"0.6365315",
"0.6355879",
"0.6336874",
"0.62735224",
"0.62715316",
"0.6267701",
"0.62094975",
"0.6182158",
"0.61466336",
"0.6127211",
"0.6094551",
"0.5991565",
"0.59739006",
"0.59681904",
"0.59101814",
"0.5901398",
"0.5893... | 0.0 | -1 |
Returns the value of the given option. If the value responds to `call` the method is invoked and the return value of this call is returned. | def option(name, default = nil)
value = self.class.options[name.to_sym]
value = default if default and !value
if value.respond_to? :call then value.call else value end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method_missing(method, *args)\n if opt = get(method)\n opt.value\n else\n raise NoMethodError, method\n end\n end",
"def value\n options_hash[option_id]\n end",
"def value(op)\n raise \"Option '#{op}' not accepted\" if !accepts? op\n raise \"Option ... | [
"0.69873524",
"0.6936445",
"0.68559176",
"0.66902703",
"0.66789705",
"0.66745156",
"0.66509557",
"0.6608145",
"0.6527887",
"0.6506515",
"0.647163",
"0.6436",
"0.6361123",
"0.6308047",
"0.6226083",
"0.6215216",
"0.62105024",
"0.61020684",
"0.61020684",
"0.61020684",
"0.6102068... | 0.6426646 | 12 |
Sets a number of options based on the given Hash. | def set_multiple(options)
options.each do |option, value|
set(option, value)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def options(hash)\n @options.merge! hash\n end",
"def set_options(hash)\n hash.keys.each do |key|\n var = '@' << key.to_s\n # = 1.9.* Fix\n # The map method applied on instance_variables is used to force elements to be String\n # because on 1.9.* Ruby versions, these elem... | [
"0.73296225",
"0.7243865",
"0.7079869",
"0.7010588",
"0.68728894",
"0.66257674",
"0.66257674",
"0.65781736",
"0.6542026",
"0.6473097",
"0.64149195",
"0.6387717",
"0.63875043",
"0.62927765",
"0.6228895",
"0.61993",
"0.6193409",
"0.6168272",
"0.61671865",
"0.61397",
"0.6136911"... | 0.56712615 | 70 |
Returns browser windows array. | def windows(opts = {})
WindowCollection.new self, opts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def windows\n @driver.getWindowList.map do |java_window|\n QuickWindow.new(self,java_window)\n end.to_a\n end",
"def firefox_windows(w = nil)\n\t\t\tcollection = []\n\t\t\twindows = nil\n\t\t\tif w\n\t\t\t\twindows = [w]\n\t\t\telse\n\t\t\t\twindows = X11::Display.instance.screens.collect{|s|... | [
"0.80504346",
"0.7693145",
"0.74637604",
"0.7219841",
"0.69462866",
"0.6905145",
"0.6712737",
"0.638947",
"0.62823224",
"0.6171416",
"0.61342996",
"0.6094918",
"0.60554004",
"0.6004392",
"0.5973957",
"0.58912444",
"0.58742243",
"0.5839404",
"0.5808513",
"0.57563937",
"0.57413... | 0.59955376 | 14 |
Returns original window if defined, current window if not See Windowuse | def original_window
@original_window ||= window
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_window; @window; end",
"def window\r\n return $window\r\n end",
"def window\n @session.request(:vim_get_current_window)\n end",
"def window\n @win\n end",
"def usable_window\n window = @windows.last\n window if window.loaded?\n end",
"def active_window\n window... | [
"0.787422",
"0.7749725",
"0.7462729",
"0.7365655",
"0.73364246",
"0.7200005",
"0.7185287",
"0.7107227",
"0.7069621",
"0.7069621",
"0.7031164",
"0.69700843",
"0.695627",
"0.6947236",
"0.69061977",
"0.6901702",
"0.6901667",
"0.68819124",
"0.68757325",
"0.6871016",
"0.68509674",... | 0.82171977 | 0 |
Waits for and returns second window if present See Windowuse | def switch_window
current_window = window
wins = windows
wait_until { (wins = windows) && wins.size > 1 } if wins.size == 1
raise StandardError, 'Unable to determine which window to switch to' if wins.size > 2
wins.find { |w| w != current_window }.use
window
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def window(title, timeout = 0)\n timeout = 30 if timeout == 0\n $webdriver.switch_to.default_content \n if not $marathon.windowMatchingTitle(title)\n bmark = MyBenchMark.new\n bmark.report(\"Waiting for window '\" + title + \"'\") {\n wait = Wait.new(:timeout => timeout, :message => \"Waiting for win... | [
"0.68915147",
"0.6578523",
"0.65782666",
"0.6577984",
"0.6564619",
"0.6564619",
"0.64832425",
"0.63045776",
"0.61994475",
"0.6193892",
"0.6170813",
"0.611071",
"0.6102286",
"0.6099346",
"0.60870767",
"0.6080209",
"0.59825706",
"0.59752125",
"0.59729826",
"0.5947358",
"0.59305... | 0.6465405 | 7 |
copied from Learnco lab | def get_programs
uri = URI.parse(URL)
response = Net::HTTP.get_response(uri)
response.body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notes_from_training\n end",
"def nn\n end",
"def no_learn\n 8\n end",
"def probers; end",
"def operations; end",
"def operations; end",
"def labels; end",
"def cops; end",
"def cops; end",
"def cops; end",
"def samples; end",
"def samples; end",
"def private; end",
... | [
"0.61483425",
"0.6135703",
"0.59213567",
"0.58859855",
"0.5854494",
"0.5854494",
"0.58193946",
"0.5817524",
"0.5817524",
"0.5817524",
"0.5776534",
"0.5776534",
"0.575989",
"0.5726117",
"0.57078665",
"0.5706091",
"0.56539047",
"0.564158",
"0.5598436",
"0.558321",
"0.5569446",
... | 0.0 | -1 |
Returns estimated effort for a ProjectPhase by calculating the sum of the estimated effort for each StockDeliverableType and CustomDeliverableType | def estimated_effort
total_estimated_effort = 0
self.project_phase_deliverables.each do |deliverable|
total_estimated_effort += deliverable.estimated_effort.to_f unless deliverable.nil?
end
return total_estimated_effort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_phase_actual_effort(project_id, phase)\n @hours = 0\n @dataset = Deliverable.find_all_by_phase_and_project_id(phase, project_id)\n puts @dataset\n if @dataset.nil?\n return 0\n else\n @dataset.each do |d|\n @hours += d.hours_logged\n end\n return @hours\n ... | [
"0.6394787",
"0.62272865",
"0.5798721",
"0.56754416",
"0.5484788",
"0.5387674",
"0.536942",
"0.53105897",
"0.52936953",
"0.5292658",
"0.52565676",
"0.5237736",
"0.51657087",
"0.51464784",
"0.51193655",
"0.5102273",
"0.50990856",
"0.5075204",
"0.5070166",
"0.5062832",
"0.50492... | 0.7271085 | 0 |
function to get the total logged effort for this deliverable | def logged_effort
total_logged_effort = 0
self.project_phase_deliverables.each do |deliverable|
total_logged_effort += deliverable.logged_effort.to_f unless deliverable.nil?
end
return total_logged_effort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def estimated_effort\n total_estimated_effort = 0\n\n self.project_phase_deliverables.each do |deliverable|\n total_estimated_effort += deliverable.estimated_effort.to_f unless deliverable.nil?\n end\n\n return total_estimated_effort\n end",
"def total\n count = 0\n self.total_time_exer... | [
"0.7250742",
"0.6434303",
"0.6432553",
"0.6411589",
"0.64055353",
"0.6349569",
"0.6248869",
"0.6048537",
"0.6018238",
"0.5975668",
"0.5954886",
"0.5953312",
"0.5903224",
"0.5894547",
"0.58932376",
"0.58912987",
"0.588154",
"0.585457",
"0.58411676",
"0.583361",
"0.58333963",
... | 0.82118356 | 0 |
function to return the aggregated project phase deliverables with both stock and custom | def project_phase_deliverables
project_phase_deliverables = []
stock_deliverable_types.each do |stock|
stock.deliverables.each do |d|
project_phase_deliverables << d
end
end
custom_deliverable_types.each do |custom|
custom.deliverables.each do |d|
project_phase_deliverables << d
end
end
project_phase_deliverables
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deliverables\n return Deliverable.where(project_id: @project.id)\n end",
"def getDeliverableTypes\n @projectPhase = ProjectPhase.find(@project_phase_id)\n @deliverableTypes = DeliverableType.find_all_by_lifecycle_phase_id(@projectPhase.lifecycle_phase_id)\n @deliverableTypesArray = []\n @deli... | [
"0.65836674",
"0.6328863",
"0.6298275",
"0.60927415",
"0.60913974",
"0.60671175",
"0.6051786",
"0.60024947",
"0.59516114",
"0.58622426",
"0.5858245",
"0.58278084",
"0.57256776",
"0.5671447",
"0.56512403",
"0.55656505",
"0.554246",
"0.5535978",
"0.55007213",
"0.54706866",
"0.5... | 0.806633 | 0 |
gets the current theme or returns default if it comes back blank | def get_theme
use_theme = Preference.get_setting('CURRENT_THEME')
(use_theme == '' ? 'default' : use_theme).downcase
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_theme\n nil\n end",
"def get_theme\n\t\tif @current_user and @current_user.theme\n\t\t\t@current_theme = @current_user.theme.css_class\n\t\telse\n\t\t\t@current_theme = \"pond\"\n\t\tend\n\tend",
"def theme\n @theme || 'plastik'\n end",
"def current_theme(passed_theme = nil)\n... | [
"0.83288646",
"0.79230934",
"0.7906802",
"0.78816706",
"0.77404493",
"0.7739274",
"0.7630222",
"0.75294083",
"0.74879324",
"0.73766637",
"0.7246554",
"0.70597017",
"0.70159614",
"0.67778724",
"0.6729735",
"0.65933573",
"0.65707153",
"0.6463578",
"0.6463578",
"0.6463578",
"0.6... | 0.85378844 | 0 |
in the case of an http error | def handle_unknown_request
$params = request.request_uri # the requested URI
# we're still going to build the 'about' block, so let's get that data
@posts = Post.find_current
@tags = Post.tag_counts(:order => 'name asc')
$page_title = Preference.get_setting('ERROR_PAGE_TITLE')
@error = true # for use later
render :template => 'errors/unknown_request'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_error(http)\n error = http.error\n fail(error, *@deferrable_args)\n end",
"def on_error(http)\n error = http.error\n fail(error, *@deferrable_args)\n end",
"def error(url); end",
"def http_error?\n http_error.pres... | [
"0.79031616",
"0.79031616",
"0.7682189",
"0.7532429",
"0.74699533",
"0.7452467",
"0.73794985",
"0.73670566",
"0.7354882",
"0.73332906",
"0.729328",
"0.72313225",
"0.7132746",
"0.71001506",
"0.70032364",
"0.699925",
"0.699735",
"0.6958664",
"0.69418263",
"0.693496",
"0.6896912... | 0.0 | -1 |
implement BFS method, this is shortest path problem with unweighted graph, BFS is best solution | def bradth_first_search_colors(start_vertex, stop_vertex)
queue = Array.new()
queue << search_vertex(start_vertex)
until queue.empty?
temp_vertex = queue.shift()
break if temp_vertex.value == stop_vertex #found stop condition
vertex_edges = temp_vertex.edges.head
until vertex_edges == nil
current_vertex = search_vertex(vertex_edges.value)
if current_vertex.color == 'white'
current_vertex.color = 'gray' #indicates that shorter path is available if found again
current_vertex.distance = temp_vertex.distance + 1
current_vertex.parent = temp_vertex.value
queue << current_vertex
end
vertex_edges = vertex_edges.link
end
temp_vertex.color = 'black' #completly explored tree
end
graph_traversal(start_vertex, stop_vertex)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bfs(graph, s)\n queue = [s]\n @visited[s] = true\n @dist[s] = 0\n w = nil\n while not queue.empty?\n w = queue.delete_at(0)\n graph.adj(v).each do |edge|\n w = edge.to\n if not @visited[w]\n @path[w] = v\n... | [
"0.7821317",
"0.7783775",
"0.7655907",
"0.7561982",
"0.74678147",
"0.7439531",
"0.7432345",
"0.7280656",
"0.72553843",
"0.717093",
"0.7112583",
"0.7100397",
"0.7040671",
"0.69938123",
"0.6933733",
"0.692333",
"0.6912769",
"0.68775815",
"0.6867509",
"0.67230695",
"0.67045087",... | 0.0 | -1 |
Public: Determines if this scenario can be loaded. | def loadable?
Api::Area.code_exists?(area_code)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadable?\n %w(test development).include?(Rails.env) || !loaded?\n end",
"def loaded?\n true\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n ... | [
"0.7016242",
"0.6803629",
"0.6759745",
"0.6759745",
"0.6759745",
"0.6759745",
"0.6759745",
"0.6759745",
"0.67440385",
"0.6740174",
"0.6740174",
"0.6701838",
"0.6697548",
"0.6697176",
"0.669248",
"0.6688106",
"0.6674858",
"0.6674858",
"0.6666693",
"0.65276355",
"0.65257347",
... | 0.62746537 | 29 |
The JSON request returns a string. Let's make it a DateTime object | def parsed_created_at
DateTime.parse(created_at) if created_at
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_date\n start_time.to_i\n end",
"def date\n Date.parse(@obj['date'])\n end",
"def to_datetime\n @_to_datetime = proc do |dt|\n begin\n DateTime.iso8601(dt.to_s)\n rescue ArgumentError\n raise Intermodal::BadRequest\n end\n end\n... | [
"0.7441295",
"0.6730717",
"0.6662277",
"0.65524375",
"0.6502525",
"0.6502525",
"0.6448631",
"0.64075744",
"0.63948345",
"0.6387967",
"0.6386055",
"0.6363418",
"0.6275118",
"0.6251853",
"0.6251853",
"0.62270695",
"0.62264305",
"0.62264305",
"0.6211145",
"0.6211145",
"0.6187502... | 0.6120484 | 22 |
Returns an HTTParty::Reponse object with a hash of the scenario user_values | def all_inputs
HTTParty.get(self.class.url_to("#{ id }/inputs"))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def service_response_data\n {\n user: @user.get_hash\n }\n end",
"def success_response_data_for_client\n {\n user: user_data,\n user_kyc_data: user_kyc_data\n }\n end",
"def user_hash\n response_hash.key?(:user) ? response_hash[:user] : {}\n ... | [
"0.5917605",
"0.5801616",
"0.5529489",
"0.5388547",
"0.5348963",
"0.533305",
"0.53063893",
"0.52115864",
"0.5190619",
"0.5175631",
"0.51479566",
"0.51427794",
"0.5064472",
"0.5058336",
"0.50544626",
"0.5039075",
"0.50381523",
"0.5016776",
"0.49970564",
"0.49776086",
"0.497570... | 0.0 | -1 |
The value which is used for sorting. Used on the preset scenario list | def sorting_value
respond_to?(:ordering) ? ordering : 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valueOrder(obj)\n if obj.tutors.exists?\n obj.tutors.sort_by {|t| t.pname }.first.pname\n else\n \"_\"\n end\n end",
"def default_sort_attribute\n ::Mincer.config.sorting.sort_attribute\n end",
"def calculate_sort_value options\n dummy_time = dummy_time_for_day openin... | [
"0.6464138",
"0.63776237",
"0.63436735",
"0.6317916",
"0.6288007",
"0.6167908",
"0.61620027",
"0.61186767",
"0.6088003",
"0.59630585",
"0.5926655",
"0.59065783",
"0.58935887",
"0.5840346",
"0.58377767",
"0.5814039",
"0.5781655",
"0.57744765",
"0.57550967",
"0.57550967",
"0.57... | 0.65542465 | 0 |
GET /tweets GET /tweets.json | def index
@tweets = current_user.tweets
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tweets\n user = User.find(params[:id])\n render json: user.list_tweets, status: :ok\n end",
"def index\n @tweets = @user.tweets.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tweets }\n end\n end",
"def show_user_tweets\n @user_twee... | [
"0.81149495",
"0.7980108",
"0.78602517",
"0.77103835",
"0.76598436",
"0.7516168",
"0.74348384",
"0.7411584",
"0.7408587",
"0.73615396",
"0.7359439",
"0.73008704",
"0.72418225",
"0.718084",
"0.7124409",
"0.7104599",
"0.7093725",
"0.7082312",
"0.7082312",
"0.7082312",
"0.708231... | 0.7095569 | 16 |
GET /tweets/1 GET /tweets/1.json | def show
puts current_user.is_admin?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tweets\n user = User.find(params[:id])\n render json: user.list_tweets, status: :ok\n end",
"def index\n @tweets = @user.tweets.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tweets }\n end\n end",
"def show_user_tweets\n @user_twee... | [
"0.7779338",
"0.7740531",
"0.75970775",
"0.74841213",
"0.746445",
"0.74599075",
"0.74334455",
"0.72242004",
"0.71207714",
"0.70800984",
"0.70530766",
"0.7043736",
"0.70432067",
"0.7039998",
"0.7039422",
"0.6973632",
"0.6973632",
"0.6967428",
"0.69544315",
"0.69518745",
"0.695... | 0.0 | -1 |
POST /tweets POST /tweets.json | def create
puts params[:post_now]
if params[:post_now] == "1"
client = Twitter::REST::Client.new do |config|
config.consumer_key = TWITTER_API_KEY
config.consumer_secret = TWITTER_API_SECRECT
config.access_token = current_user.access_token
config.access_token_secret = current_user.access_token_secret
end
content = params[:tweet][:content]
end
@tweet = current_user.tweets.build(tweet_params)
respond_to do |format|
if @tweet.save
if client.update("#{content}")
puts @tweet.update(tweeted: true)
flash[:notice] = "Successfully posted "
else
flash[:notice] = "not updated "
end
format.html { redirect_to @tweet, notice: 'Tweet was successfully created.' }
format.json { render :show, status: :created, location: @tweet }
else
format.html { render :new }
format.json { render json: @tweet.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n user = user_from_token\n @tweet = user.tweets.new()\n @tweet.tweet = params[:tweet]\n if @tweet.save\n render :json => @tweet, :status => :created\n else\n render :json => @tweet.errors, :status => :unprocessable_entity\n end\n end",
"def create\n @tweet = current_use... | [
"0.7703366",
"0.72558355",
"0.71856695",
"0.7130213",
"0.705414",
"0.7018085",
"0.7003551",
"0.6994446",
"0.698963",
"0.69707346",
"0.69707346",
"0.6893714",
"0.68830514",
"0.6881277",
"0.6819126",
"0.67953306",
"0.678633",
"0.6756683",
"0.6734242",
"0.6720373",
"0.67184824",... | 0.69071674 | 11 |
PATCH/PUT /tweets/1 PATCH/PUT /tweets/1.json | def update
respond_to do |format|
if @tweet.update(tweet_params)
format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }
format.json { render :show, status: :ok, location: @tweet }
else
format.html { render :edit }
format.json { render json: @tweet.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n if @tweet.update_attributes(params[:tweet])\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit... | [
"0.71972436",
"0.71972436",
"0.71972436",
"0.7189728",
"0.71033686",
"0.70858943",
"0.70805454",
"0.70317155",
"0.6947886",
"0.6947886",
"0.6947886",
"0.6947886",
"0.6911463",
"0.6911463",
"0.6911463",
"0.68916214",
"0.68813294",
"0.6845525",
"0.68304396",
"0.6797358",
"0.679... | 0.69473106 | 12 |
DELETE /tweets/1 DELETE /tweets/1.json | def destroy
@tweet.destroy
respond_to do |format|
format.html { redirect_to tweets_url, notice: 'Tweet was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n user = user_from_token\n user.tweets.destroy(params[:id])\n head :no_content\n end",
"def destroy\n @tweet = Tweet.find(params[:id])\n @tweet.destroy\n\n respond_to do |format|\n format.html { redirect_to tweets_url }\n format.json { head :no_content }\n end\n end",... | [
"0.76199996",
"0.7450857",
"0.7450857",
"0.7447384",
"0.7429406",
"0.7330124",
"0.73026913",
"0.7290236",
"0.7262342",
"0.72382593",
"0.72135663",
"0.72135663",
"0.72135663",
"0.72135663",
"0.72135663",
"0.72135663",
"0.7211454",
"0.7209999",
"0.7209999",
"0.7209999",
"0.7209... | 0.6927889 | 38 |
Use callbacks to share common setup or constraints between actions. | def set_tweet
@tweet = Tweet.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def tweet_params
params.require(:tweet).permit(:content, :send_at)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6980384",
"0.6782743",
"0.6746196",
"0.6742575",
"0.6736",
"0.6594004",
"0.65037984",
"0.6496699",
"0.64819324",
"0.64791185",
"0.6456292",
"0.64403296",
"0.63795286",
"0.6375975",
"0.6365291",
"0.63210756",
"0.6300542",
"0.6299717",
"0.62943304",
"0.6292561",
"0.6290683",... | 0.0 | -1 |
after reviewing LS solution, and recognizing that my original solution is too redundant | def uuid_generator
uuid = []
segments = [8, 4, 4, 4, 12]
segments.each do |num|
uuid << CHARS.sample(num).join
end
p uuid.join('-')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hook_solution?(a); end",
"def recursive_solution\n\n end",
"def anchored; end",
"def solution4(input)\n end",
"def dpll\n\t\t#need to count degree, best_guess, assignments and such heuristic stuff somewhere... makes sense to do it here\n\t\t#should make a version without heuristics aswell\n##########... | [
"0.6125088",
"0.6057885",
"0.6032047",
"0.596112",
"0.5855799",
"0.5728863",
"0.5724712",
"0.5719958",
"0.56593394",
"0.5632929",
"0.5628762",
"0.56110376",
"0.5605961",
"0.5596298",
"0.5592266",
"0.5574005",
"0.5560274",
"0.5557256",
"0.5544934",
"0.5530675",
"0.5527182",
... | 0.0 | -1 |
Creates the four required columns that constitutes a single cascading namespace settings attribute. This helper is only appropriate if the setting is not already present as a noncascading attribute. Creates the `setting_name` column along with the `lock_setting_name` column in both `namespace_settings` and `application_settings`. This helper is not reversible and must be defined in conjunction with `remove_cascading_namespace_setting` in separate up and down directions. setting_name The name of the cascading attribute same as defined in `NamespaceSetting` with the `cascading_attr` method. type The column type for the setting itself (:boolean, :integer, etc.) options Standard Rails column options hash. Accepts keys such as `null` and `default`. `null` and `default` options will only be applied to the `application_settings` column. In most cases, a nonnull default value should be specified. | def add_cascading_namespace_setting(setting_name, type, **options)
lock_column_name = "lock_#{setting_name}".to_sym
check_cascading_namespace_setting_consistency(setting_name, lock_column_name)
namespace_options = options.merge(null: true, default: nil)
add_column(:namespace_settings, setting_name, type, **namespace_options)
add_column(:namespace_settings, lock_column_name, :boolean, default: false, null: false)
add_column(:application_settings, setting_name, type, **options)
add_column(:application_settings, lock_column_name, :boolean, default: false, null: false)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setting_class\n @setting_class ||= case orm\n when :activerecord\n require 'settler/orm/activerecord/setting'\n Settler::ORM::Activerecord::Setting\n else\n require 'settler/orm/ruby/setting'\n Settler::ORM::Ruby::Setting\n end\n end",
"def setting_params\n ... | [
"0.49649224",
"0.4823334",
"0.47971034",
"0.46413702",
"0.4559991",
"0.4529144",
"0.45199347",
"0.450397",
"0.44972235",
"0.44927645",
"0.44905928",
"0.44677636",
"0.44619715",
"0.44599438",
"0.44313174",
"0.4407542",
"0.43775278",
"0.43568566",
"0.4345559",
"0.43305054",
"0.... | 0.80753994 | 0 |
Because pagy gem method pagy_next_url return url base on request url, but sometime we want specify base url. So this is what this method doing. | def next_url_for_path(path, pagy)
return unless pagy.next
url = URI.parse(path); url_query = Rack::Utils.parse_query url.query
url.query = Rack::Utils.build_query url_query.merge(pagy.vars[:page_param].to_s => pagy.next)
url.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_page_url\n \"#{request.path}?page=#{@page + 1}\"\n end",
"def next_url_str\n \"#{@url_base_str}?#{QUERY_STRING_PART1}&#{@query_str_next_page}\"\n end",
"def next_page_path; end",
"def next_page_url\n current_page = params[:page].try(:to_i) || 1\n if request.path.match /\\/page\\/(\... | [
"0.7240253",
"0.72379565",
"0.71005315",
"0.6989908",
"0.6839695",
"0.674903",
"0.66792136",
"0.6646795",
"0.6597067",
"0.6586699",
"0.6576461",
"0.6576461",
"0.65652233",
"0.65496325",
"0.65496325",
"0.6504919",
"0.6459087",
"0.6459087",
"0.6455604",
"0.6445155",
"0.6340858"... | 0.73391056 | 0 |
Check for valid request token and return user | def authorize_request
@current_user = (AUTHORIZER.new(request.headers).call)[:user]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_authentication_token\n \n @user = User.find_by_services_authentification_token(params[:auth_token])\n bad_request if @user.nil?\n end",
"def authenticate_user_from_token!\n user_token = params[:auth_token].presence\n user = user_token && User.find_by_authentication_token(user_t... | [
"0.7766165",
"0.76144505",
"0.74394107",
"0.740302",
"0.7395052",
"0.7388174",
"0.73447704",
"0.7312916",
"0.7312101",
"0.72916806",
"0.7257882",
"0.7255303",
"0.7249056",
"0.7247693",
"0.7243509",
"0.71877116",
"0.7186487",
"0.7179645",
"0.71792054",
"0.7157877",
"0.7157877"... | 0.0 | -1 |
transform to json format | def json
@@id += 1
"{" +
"\"type\": \"LEX_SELECT\", \"id\": \"S#{@@id}\", " +
"\"offset\": #{@offset}, \"length\": #{@length}, " +
"\"value\": [" + @candidates.map{|elem| elem.json}.join(",") +
"]}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tojson\n\t\tend",
"def to_json\n\t\tto_h.to_json\n\tend",
"def to_json\n\t\tto_h.to_json\n\tend",
"def to_json\n to_parsed.to_json\n end",
"def to_json\n to_h.to_json\n end",
"def to_json\n to_h.to_json\n end",
"def to_json\r\n to_hash.to_json\r\n end",
"def to_json\n ... | [
"0.7705823",
"0.769111",
"0.769111",
"0.7574801",
"0.7439115",
"0.7439115",
"0.74229664",
"0.7371268",
"0.73579794",
"0.7331206",
"0.7321626",
"0.72884166",
"0.72716767",
"0.726922",
"0.7227323",
"0.7227323",
"0.7227323",
"0.7227323",
"0.7227323",
"0.7227323",
"0.7227323",
... | 0.0 | -1 |
GET /magic_item_names GET /magic_item_names.json | def index
@magic_item_names = MagicItemName.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_item_names\n items = []\n Static.get_item_list.values.each do |f|\n items << f[\"name\"]\n end\n items\n end",
"def name_list\n begin\n @products = Product.pluck(:name)\n render json: { names: @products }, status: 200\n rescue => exception\n render json: {... | [
"0.73406905",
"0.67368335",
"0.66846734",
"0.65237606",
"0.63395196",
"0.63226616",
"0.63028604",
"0.6240045",
"0.61300594",
"0.60667986",
"0.60667986",
"0.60496145",
"0.60417163",
"0.59857535",
"0.5984824",
"0.59831995",
"0.59586614",
"0.5957465",
"0.5909478",
"0.58989453",
... | 0.7702119 | 0 |
GET /magic_item_names/1 GET /magic_item_names/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @magic_item_names = MagicItemName.all\n end",
"def get_item_names\n items = []\n Static.get_item_list.values.each do |f|\n items << f[\"name\"]\n end\n items\n end",
"def item_name\n params['item_name']\n end",
"def index\n @material_item_names = Mater... | [
"0.7534825",
"0.68902236",
"0.6624686",
"0.6471059",
"0.64435923",
"0.64435923",
"0.6442859",
"0.6419516",
"0.63064563",
"0.6299243",
"0.62249994",
"0.6216738",
"0.61759204",
"0.61327213",
"0.61228824",
"0.6092892",
"0.6037217",
"0.6016646",
"0.60059625",
"0.5969734",
"0.5867... | 0.0 | -1 |
POST /magic_item_names POST /magic_item_names.json | def create
@magic_item_name = MagicItemName.new(magic_item_name_params)
respond_to do |format|
if @magic_item_name.save
format.html { redirect_to @magic_item_name, notice: 'Magic item name was successfully created.' }
format.json { render :show, status: :created, location: @magic_item_name }
else
format.html { render :new }
format.json { render json: @magic_item_name.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @magic_item_names = MagicItemName.all\n end",
"def magic_item_name_params\n params.require(:magic_item_name).permit(:name, :affix)\n end",
"def item_name\n params['item_name']\n end",
"def set_magic_item_name\n @magic_item_name = MagicItemName.find(params[:id]... | [
"0.65030557",
"0.64285296",
"0.6226741",
"0.61364675",
"0.59521884",
"0.58190954",
"0.5768685",
"0.5681343",
"0.56139356",
"0.5612835",
"0.5602044",
"0.55766296",
"0.55756",
"0.55729985",
"0.5565371",
"0.5503138",
"0.548819",
"0.5464174",
"0.5464174",
"0.54093695",
"0.53995",... | 0.6748295 | 0 |
PATCH/PUT /magic_item_names/1 PATCH/PUT /magic_item_names/1.json | def update
respond_to do |format|
if @magic_item_name.update(magic_item_name_params)
format.html { redirect_to @magic_item_name, notice: 'Magic item name was successfully updated.' }
format.json { render :show, status: :ok, location: @magic_item_name }
else
format.html { render :edit }
format.json { render json: @magic_item_name.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_names\n\t\tparams[:item].each do |key, item|\n\t\t\tcurrent_item = Item.find(key)\n\t\t\tcurrent_item.update(:claimed_by => item[:claimed_by])\n\t\tend\n\t\tflash[:success] = \"Names updated.\"\n\t\tredirect_to(:back)\n\tend",
"def set_magic_item_name\n @magic_item_name = MagicItemName.find(param... | [
"0.6601336",
"0.6478073",
"0.63877803",
"0.63482547",
"0.63341767",
"0.6286458",
"0.62237185",
"0.622177",
"0.6183182",
"0.61792547",
"0.61488265",
"0.6087684",
"0.6069304",
"0.603378",
"0.6031951",
"0.6026903",
"0.5998217",
"0.5994053",
"0.5974475",
"0.5969632",
"0.5966828",... | 0.7312591 | 0 |
DELETE /magic_item_names/1 DELETE /magic_item_names/1.json | def destroy
@magic_item_name.destroy
respond_to do |format|
format.html { redirect_to magic_item_names_url, notice: 'Magic item name was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @itemname = Itemname.find(params[:id])\n @itemname.destroy\n\n respond_to do |format|\n format.html { redirect_to itemnames_url }\n format.json { head :no_content }\n end\n end",
"def delete_item(item_id)\n response = Unirest.delete CONNECT_HOST + '/v1/' + LOCATION_ID + '/it... | [
"0.712925",
"0.70415443",
"0.6835347",
"0.6801185",
"0.6763019",
"0.6763019",
"0.6760498",
"0.6754438",
"0.67372817",
"0.66783565",
"0.66700804",
"0.6613633",
"0.66009676",
"0.65984744",
"0.65813076",
"0.6577654",
"0.6559557",
"0.6520968",
"0.6520809",
"0.64875764",
"0.648374... | 0.7403804 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_magic_item_name
@magic_item_name = MagicItemName.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def magic_item_name_params
params.require(:magic_item_name).permit(:name, :affix)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6980384",
"0.6782743",
"0.6746196",
"0.6742575",
"0.6736",
"0.6594004",
"0.65037984",
"0.6496699",
"0.64819324",
"0.64791185",
"0.6456292",
"0.64403296",
"0.63795286",
"0.6375975",
"0.6365291",
"0.63210756",
"0.6300542",
"0.6299717",
"0.62943304",
"0.6292561",
"0.6290683",... | 0.0 | -1 |
3 ways to register filter 1. builtin filter filter.add_filter(:mtime, :passed, 30, :days) 2. custom filter filter.add_filter(my_filter) (my_filter must implements match?(path) method) 3. block filter filter.add_filter do |path| filter operations end | def add_filter(*args, &block)
# 3. block filter
if block_given?
filter = File::Visitor::Filter::Proc.new(block)
@filters.push(filter)
return true
end
# 2. custom filter
if (1 == args.size)
custom_filter = args.shift
unless (custom_filter.respond_to?(:match?))
raise ArgumentError,
"custom_filter must implement match?()"
end
@filters.push(custom_filter)
return true
end
# 1. built-in filter
filter_class = File::Visitor::FilterDispatcher.dispatch(args.shift)
@filters.push(filter_class.new(*args))
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_filter(mod); end",
"def add_filter(type, path = nil, **options, &block)\n source_location = block.respond_to?(:source_location) ?\n block.source_location.first : caller_files[1]\n result = super\n watch_element(source_location, :\"#{type}_filter\", filters[type].last)\n... | [
"0.70155233",
"0.6996598",
"0.68954813",
"0.6658535",
"0.663216",
"0.658385",
"0.6567839",
"0.6495973",
"0.64650005",
"0.6464861",
"0.6454527",
"0.6416924",
"0.6345174",
"0.6312059",
"0.6290705",
"0.6290705",
"0.6271176",
"0.6257901",
"0.6233235",
"0.62192565",
"0.6142459",
... | 0.7337683 | 0 |
dir: target directory mode: file visit all files dir visit directory only handler: proc to call | def visit_with_mode(dir, mode, &handler)
assert_directory(dir)
entries = Dir.entries(dir)
.sort_by { |filename| filename }
if @direction == :desc
entries.reverse!
end
entries.each do |entry|
next if (dot_dir?(entry) && !@visit_dot_dir)
abs_path = File.join(dir, entry)
if File.directory?(abs_path)
mode == :dir && handler.call(abs_path)
visit_with_mode(abs_path, mode, &handler)
else
if mode == :file && target?(abs_path)
handler.call(abs_path)
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_directory(dir, files, rec)\n dir.children(true).each do |f|\n # ignore sub-directories\n if f.directory?\n if rec == false\n next\n else\n process_directory(f.expand_path, files, rec)\n end\n end\n pro... | [
"0.7269948",
"0.72344595",
"0.7196083",
"0.67955124",
"0.6779908",
"0.67796755",
"0.6704745",
"0.6700345",
"0.6700345",
"0.6691016",
"0.66885805",
"0.66692245",
"0.66111976",
"0.660302",
"0.6600337",
"0.65905225",
"0.6588868",
"0.658193",
"0.6553596",
"0.64825714",
"0.6463325... | 0.76961493 | 0 |
def random_quote random_quote = Quote.all.sample game = Game.find(...) game.random_question render json: random_quote, include: [:author] end def start_game instantiate new game get 10 random quotes for each quote, get a random author render json: [quote1, quote2..., quote10] end | def end_game
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n quotes = OriginalQuote.all\n @quote = quotes.sample\n render json: @quote, status: 200\n end",
"def index\n @jokes = Joke.offset(rand(Joke.count)).first\n @random_joke = Joke.all.shuffle\n @random_quote = Quote.all.shuffle\n @quotes = Quote.offset(rand(Quote.count)).first\n end"... | [
"0.71403",
"0.6931888",
"0.6931158",
"0.6839698",
"0.6745061",
"0.67166954",
"0.66780484",
"0.66424185",
"0.6592468",
"0.6538297",
"0.65339357",
"0.64561725",
"0.64355725",
"0.63954216",
"0.6292724",
"0.62890536",
"0.6255388",
"0.6254601",
"0.6192117",
"0.61052734",
"0.606051... | 0.0 | -1 |
Result updated_at should propagate to Event updated_at but does not yet | def results_updated_at
Result.where(race_id: races.map(&:id)).maximum(:updated_at)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updated_at\n dateChanged\n end",
"def update \n update = object.updated_at\n end",
"def updated_on\n updated_at\n end",
"def updated_at\n Time.at @updated rescue nil\n end",
"def updated_at\n created_at\n end",
"def unchanged?\n created_at == updated_at\n end",
"def bump... | [
"0.6952121",
"0.69037646",
"0.6732456",
"0.6504944",
"0.6415278",
"0.6391613",
"0.6327927",
"0.6280748",
"0.628016",
"0.62776387",
"0.62690896",
"0.62477964",
"0.6210264",
"0.61881995",
"0.61763245",
"0.6165476",
"0.61480963",
"0.6117819",
"0.61164325",
"0.6059061",
"0.605474... | 0.0 | -1 |
Will return falsepositive if there are only overall series results, but those should only exist if there _are_ "real" results. The results page should show the results in that case. | def any_results?
races.any?(&:any_results?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_results?\n true\n end",
"def more_results?()\n #This is a stub, used for indexing\n end",
"def hasResults?\n ! @results.empty?\n end",
"def no_results\n print \"0 results found. \\n\"\n end",
"def results?() ! find(locator(:no_results_message)) end"... | [
"0.6628638",
"0.66195565",
"0.6285563",
"0.6235919",
"0.6127702",
"0.61047447",
"0.5931168",
"0.58871675",
"0.58763725",
"0.58066195",
"0.5726213",
"0.5715045",
"0.5712045",
"0.5678092",
"0.5662458",
"0.5601473",
"0.55778867",
"0.5548455",
"0.55397034",
"0.55061316",
"0.54799... | 0.54496306 | 22 |
Will return falsepositive if there are only overall series results, but those should only exist if there _are_ "real" results. The results page should show the results in that case. | def any_results_including_children?
races.any?(&:any_results?) || children.any?(&:any_results_including_children?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_results?\n true\n end",
"def more_results?()\n #This is a stub, used for indexing\n end",
"def hasResults?\n ! @results.empty?\n end",
"def no_results\n print \"0 results found. \\n\"\n end",
"def results?() ! find(locator(:no_results_message)) end"... | [
"0.6627425",
"0.661909",
"0.6284414",
"0.6235429",
"0.6126472",
"0.610397",
"0.5930444",
"0.58869624",
"0.58753353",
"0.5806088",
"0.57264924",
"0.5713771",
"0.5711489",
"0.56771517",
"0.56608605",
"0.5600434",
"0.5578196",
"0.5548319",
"0.5539034",
"0.55057716",
"0.546758",
... | 0.54794616 | 20 |
Returns only the children with +results+ | def children_with_results
children.select(&:any_results_including_children?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n\t\treturn self.search( :one, '(objectClass=*)' )\n\tend",
"def any_results_including_children?\n races.any?(&:any_results?) || children.any?(&:any_results_including_children?)\n end",
"def pull_out(parent_hash)\n return parent_hash[\"results\"]\n rescue\n return []\n ... | [
"0.6459362",
"0.6355265",
"0.63484645",
"0.6250594",
"0.6238641",
"0.5964827",
"0.59176993",
"0.5885458",
"0.5861433",
"0.5841403",
"0.5840733",
"0.5839581",
"0.57967174",
"0.57507205",
"0.5739048",
"0.5718785",
"0.5714855",
"0.56983995",
"0.5697021",
"0.5694411",
"0.5668937"... | 0.8369089 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.