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 |
|---|---|---|---|---|---|---|
Updates all target script phases for the current target, including creating or updating, deleting and reordering. | def add_user_script_phases
native_targets.each do |native_target|
TargetIntegrator.create_or_update_user_script_phases(target.target_definition.script_phases, native_target)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def script_phase(options)\n raise Informative, 'Script phases can only be added within target definitions.' if current_target_definition.root?\n raise Informative, 'Script phases cannot be added to abstract targets.' if current_target_definition.abstract?\n current_target_definition.store_scri... | [
"0.63579714",
"0.61931425",
"0.58182645",
"0.569193",
"0.5387635",
"0.5368888",
"0.5324073",
"0.5166562",
"0.5161826",
"0.5152414",
"0.5149767",
"0.51259726",
"0.509653",
"0.5056445",
"0.5055019",
"0.5053777",
"0.5039345",
"0.500798",
"0.5005767",
"0.4997562",
"0.49560797",
... | 0.62622136 | 1 |
Adds a shell script build phase responsible for checking if the Pods locked in the Pods/Manifest.lock file are in sync with the Pods defined in the Podfile.lock. | def add_check_manifest_lock_script_phase
phase_name = CHECK_MANIFEST_PHASE_NAME
native_targets.each do |native_target|
phase = TargetIntegrator.create_or_update_shell_script_build_phase(native_target, BUILD_PHASE_PREFIX + phase_name)
native_target.build_phases.unshift(phase).uniq! unless native_target.build_phases.first == phase
phase.shell_script = <<-SH.strip_heredoc
diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
if [ $? != 0 ] ; then
# print error to STDERR
echo "error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation." >&2
exit 1
fi
# This output is used by Xcode 'outputs' to avoid re-running this script phase.
echo "SUCCESS" > "${SCRIPT_OUTPUT_FILE_0}"
SH
phase.input_paths = %w(${PODS_PODFILE_DIR_PATH}/Podfile.lock ${PODS_ROOT}/Manifest.lock)
phase.output_paths = [target.check_manifest_lock_script_output_file_path]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_check_manifest_lock_script_phase\n phase_name = 'Check Pods Manifest.lock'\n native_targets.each do |native_target|\n next if native_target.shell_script_build_phases.any? { |phase| phase.name == phase_name }\n phase = native_target.project.new(Xcodeproj::Project::Obj... | [
"0.8060131",
"0.61538553",
"0.5682199",
"0.5630723",
"0.5587884",
"0.5550743",
"0.5519414",
"0.55132455",
"0.54747367",
"0.53839135",
"0.5336132",
"0.5320417",
"0.5279995",
"0.52783394",
"0.52426434",
"0.5242064",
"0.5242064",
"0.52115595",
"0.51987386",
"0.51917833",
"0.5174... | 0.78093374 | 1 |
Read the project from the disk to ensure that it is up to date as other TargetIntegrators might have modified it. | def user_project
target.user_project
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_load\n (project_dir = reachable_projects.first) || raise(InputError, \"Could not find a project file containing #{path}\")\n @project = ProjectCache.open(project_dir)\n end",
"def project_load\n project_dir = reachable_projects.first || abort(\"Could not find a project file containi... | [
"0.67098427",
"0.66306657",
"0.6172231",
"0.6025915",
"0.5955649",
"0.5888299",
"0.57617193",
"0.57176095",
"0.561057",
"0.56013095",
"0.5600888",
"0.5574852",
"0.5483389",
"0.5468534",
"0.54674596",
"0.54382515",
"0.54281783",
"0.5415009",
"0.54060835",
"0.53618103",
"0.5357... | 0.0 | -1 |
show all payments of user | def index
@payments = @user.payments.order("date desc").page( params[:page] ).per(10)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @payments = Payment.all_for_user(current_user)\n end",
"def index\n @payments = @user.payments\n end",
"def index\n if current_user.admin?\n @payments = Payment.order(updated_at: :desc).paginate(page: params[:page], per_page: 12)\n else\n @payments = Payment.order(updated_at... | [
"0.844051",
"0.83171374",
"0.78485864",
"0.78261",
"0.77858174",
"0.7509901",
"0.74950135",
"0.74512434",
"0.72589165",
"0.72369087",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",
"0.7190545",... | 0.7927198 | 2 |
Add extension to path if present do not add extra dot before extesion | def filename(id, extension)
path = filepath(id)
return path if extension.nil?
"#{path}.#{extension.gsub(/^\./, '')}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path_with_extname(path, options); end",
"def path_with_extname(path, options); end",
"def add_extension(path); end",
"def replace_ext(path, new_ext)\n path.sub(/\\..+$/, '.' + new_ext)\n end",
"def replace_extension path, ext\n base_name = File.basename(path, File.extname(path))\n Fil... | [
"0.8319581",
"0.8319581",
"0.827129",
"0.8154756",
"0.8091627",
"0.766852",
"0.7534236",
"0.73235595",
"0.73117393",
"0.7291221",
"0.72898513",
"0.71369547",
"0.7105219",
"0.7072652",
"0.70189625",
"0.69333935",
"0.69213",
"0.6872853",
"0.6868919",
"0.6859369",
"0.6759887",
... | 0.0 | -1 |
Convert string like `abcdefghi` to `ab/cd/ef/ghi` to represent location on file system | def filepath(id)
tokens = hmac(id).chars.each_slice(2).map(&:join)
result = []
nesting_depth.times { result << tokens.shift }
result << tokens.join
result.join('/')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def level_down(s)\nreturn s.split(\"/\").insert(-2, \"*\").join(\"/\")\nend",
"def dir_name string\n string.split('/')[0..-2].join('/')\nend",
"def simplify_path(str)\n directory_names = str.split('/')\n stack = Stack.new\n\n directory_names.each do |name|\n next if name == '.' || name.empty?\n next ... | [
"0.64209956",
"0.63464165",
"0.6341418",
"0.63336974",
"0.60376376",
"0.58481985",
"0.57632387",
"0.57549554",
"0.57315826",
"0.5699524",
"0.569912",
"0.56402403",
"0.56317985",
"0.5598191",
"0.55802023",
"0.5562177",
"0.5553768",
"0.5551075",
"0.5535505",
"0.55299276",
"0.55... | 0.0 | -1 |
def like(likeable) return false if likeable.blank? return false if likeable.like_by_user?(self) likeable.push(liked_user_ids: self.id) likeable.inc (likes_count: 1) likeable.touch end def unlike(likeable) return false if likeable.blank? return false if likeable.like_by_user?(self) likeable.pull(liked_user_ids: self.id) likeable.inc (likes_count: 1) likeable.touch end | def populer
# 流行 数据来源来自mysql
# redis 将存储数据
# 数据 包含 post 和 post 喜欢的人
@posts = Post.paginate(:page => params[:page])
render :status => :200,
:json => { :success => 200,
:info => "",
:data => @posts
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def like_by user\n likers << user && change_like_count(1)\n end",
"def unlike(model)\n if self.id != model.id && self.likes?(model)\n\n # this is necessary to handle mongodb caching on collection if unlike is following a like\n model.reload\n self.reload\n\n model.before_unli... | [
"0.77496785",
"0.746539",
"0.7444829",
"0.7408665",
"0.7324753",
"0.73113805",
"0.7242246",
"0.7135449",
"0.707977",
"0.70669466",
"0.7051708",
"0.7050466",
"0.7040351",
"0.7026188",
"0.70057744",
"0.69930905",
"0.6938517",
"0.6934798",
"0.69224286",
"0.6916944",
"0.6914971",... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_dog
@dog = Dog.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.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def dog_params
params.require(:dog).permit(:name, :breed, :age, :neighbor_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
Question 3: Alan wrote the following method, which was intended to show all of the factors of the input number: | def factors(number)
divisor = number
factors = []
begin
factors << number / divisor if number % divisor == 0
divisor -= 1
end until divisor == 0
factors
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factors(num)\n\nend",
"def factors(num)\n\nend",
"def factors(num)\n\nend",
"def factors(num)\n (1..Math::sqrt(num)).each do |x|\n if num % x == 0\n puts x\n puts num/x\n end\n end\n nil\nend",
"def factors_of(num)\n # Write your code here\nend",
"def factors(num)\n factors = P... | [
"0.8378287",
"0.8378287",
"0.8378287",
"0.8201097",
"0.8186601",
"0.8122372",
"0.80807006",
"0.8071275",
"0.8027347",
"0.80248845",
"0.80136937",
"0.80091006",
"0.8004312",
"0.7999205",
"0.79876035",
"0.798218",
"0.79782736",
"0.79654485",
"0.79632527",
"0.7962471",
"0.795918... | 0.77364075 | 91 |
=begin Alyssa noticed that this will fail if the input is 0, or a negative number, and asked Alan to change the loop. How can you make this work without using begin/end/until? Note that we're not looking to find the factors for 0 or negative numbers, but we just want to handle it gracefully instead of raising an exception or going into an infinite loop. =end | def factors(number)
divisor = number
factors = []
while divisor > 0 do
factors << number / divisor if number % divisor == 0
divisor -= 1
end
factors
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factors(number)\n return \"number must be greatr than zero\" if (number == 0 || number < 0 )\n \n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend",
"def factors(number)\n dividend = number\... | [
"0.780065",
"0.75567836",
"0.7471524",
"0.73657",
"0.733559",
"0.73110867",
"0.7230983",
"0.71877104",
"0.71671486",
"0.71591777",
"0.71459126",
"0.7145483",
"0.7145483",
"0.7145483",
"0.7145483",
"0.71439445",
"0.71120816",
"0.7086939",
"0.7082828",
"0.70712894",
"0.7069699"... | 0.6701012 | 60 |
Bonus 1: What is the purpose of the number % divisor == 0 ? it is the solution to finding the factors of the number that was passed into the method as an argument if number modulo by the divisor is equal to 0, then it is a factor of number is is pushed into the array 'factors' Bonus 2: What is the purpose of the secondtolast line (line 8) in the method (the factors before the method's end)? =begin This is what is the actual return value from the method. Recall that without an explicit return statement in the code, the return value of the method is the last statement executed. If we omitted this line, the code would execute, but the return value of the method would be nil. =end Question 4: =begin Alyssa was asked to write an implementation of a rolling buffer. Elements are added to the rolling buffer and if the buffer becomes full, then new elements that are added will displace the oldest elements in the buffer. She wrote two implementations saying, "Take your pick. Do you like << or + for modifying the buffer?". Is there a difference between the two, other than what operator she chose to use to add an element to the buffer? =end | def rolling_buffer1(buffer, max_buffer_size, new_element)
buffer << new_element
buffer.shift if buffer.size > max_buffer_size
buffer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factors(number)\n dividend = number\n divisors = [] # make an empty array called divisors\n begin\n # if the number / dividend is a whole number add it to the array\n divisors << number / dividend if number % dividend == 0\n # minus 1 from the dividend\n dividend -= 1\n # end when dividend is... | [
"0.74213076",
"0.7376787",
"0.7337819",
"0.73376524",
"0.7262693",
"0.7255039",
"0.7230122",
"0.7221738",
"0.72130316",
"0.7212513",
"0.7212513",
"0.72073495",
"0.72073495",
"0.72073495",
"0.72073495",
"0.72073495",
"0.7193636",
"0.7190664",
"0.71823895",
"0.7172062",
"0.7169... | 0.0 | -1 |
due to variable scope, a method definitions scope is selfcontained, it cannot access the local variable 'limit' outside of its definition. Therefore moving the variable 'limit' inside of the method 'fib' makes it accessible for use within the scope of the method 'fib' OR..... LS Solution: You can make limit an additional argument to the definition of the fib method and pass it in when you call fib. | def fib(first_num, second_num, limit)
while first_num + second_num < limit
sum = first_num + second_num
first_num = second_num
second_num = sum
end
sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fib(limit)\n\tfib = 0\n\tprev = 1\n\tcurrent = 1\n\twhile current < limit\n\t\tif (prev + current).even? && (current + prev) < limit\n\t\t\tfib += (prev + current)\n\t\tend\n\n\t\told_current = current\n\t\tcurrent = prev + current\n\t\tprev = old_current\n\tend\n\tfib\nend",
"def fib(first_num, second_num, ... | [
"0.77141535",
"0.75998026",
"0.75298756",
"0.7521875",
"0.74169844",
"0.7308885",
"0.7278338",
"0.7215116",
"0.72035474",
"0.72035474",
"0.72035474",
"0.7145171",
"0.70976573",
"0.7096679",
"0.7096679",
"0.7096679",
"0.7096679",
"0.7096679",
"0.7096679",
"0.7096679",
"0.70966... | 0.7016519 | 23 |
Did the family's data get ransacked? Why or why not? Yes, it has! Below I have copied LS's explanation I struggled to explain this :/ =begin Spot will find himself in the "dog" house for this one. The family's data is all in shambles now. Why? Remember that in Ruby, what gets passed to a method isn't the value of the object. Under the hood, Ruby passes the object_id of each argument to the method. The method stores these object_id's internally in locally scoped (private to the method) variables (named per the method definition's parameter list). So Spot's demo_hash starts off pointing to the munsters hash. His program could wind up replacing that with some other object id and then the family's data would be safe. In this case, the program does not reassign demo_hash it just uses it asis. So the actual hash object that is being messed with inside of the method IS the munsters hash. =end Question 8: Method calls can take expressions as arguments. Suppose we define a method called rps as follows, which follows the classic rules of rockpaperscissors game, but with a slight twist that it declares whatever hand was used in the tie as the result of that tie. | def rps(fist1, fist2)
if fist1 == "rock"
(fist2 == "paper") ? "paper" : "rock"
elsif fist1 == "paper"
(fist2 == "scissors") ? "scissors" : "paper"
else
(fist2 == "rock") ? "rock" : "scissors"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hashed_rooster\r\nend",
"def test_hash_crossing_search_found_something\n ruby_rush=RubyRush.new(1, 2, 3)\n doubled_prng = Minitest::Mock.new('doubled prng')\n def doubled_prng.rand(seed); 2; end\n ruby_rush.prng=doubled_prng\n ruby_rush.cur_real_rb=2\n ruby_rush.cur_... | [
"0.6364895",
"0.5974998",
"0.5673059",
"0.56286997",
"0.5624507",
"0.561475",
"0.56066096",
"0.5541112",
"0.5541112",
"0.55406326",
"0.5498184",
"0.54893255",
"0.5484093",
"0.54498416",
"0.5426625",
"0.5385213",
"0.5375753",
"0.53750026",
"0.5367389",
"0.53664887",
"0.5348015... | 0.0 | -1 |
Really lost on this one! My head is spinning trying to trace this! Running it in irb => "paper" =begin The outermost call is evaluated by determining the result of rps(rps("rock", "paper"), rps("rock", "scissors")) versus rock. In turn that means we need to evaluate the two separate results of rps("rock", "paper") and rps("rock", "scissors") and later combine them by calling rps on their individual results. Those innermost expressions will return "paper" and "rock", respectively. Calling rps on that input will return "paper". Which finally when evaluated against "rock" will return "paper". =end Question 9: Given these two methods: | def foo(param = "no")
"yes"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\n end",
"def rps(p1, p2)\n if p1 == \"scissors\" && ... | [
"0.7168028",
"0.71369135",
"0.6987199",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.6916933",
"0.69046956",
"0.69025373",
"0.686221",
"0.6724034",
"0.6557759",
... | 0.0 | -1 |
Public: Elevator, Sorts elevators based on the number of stops they have | def elevator
elevators.sort_by { |e| e.stop_count }.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_elevators\n @elevator_number.times do |i|\n floor_gap = @building.floors / @elevator_number * i\n elevator_list.append(Elevator.new(i, 1 + floor_gap, 1 + floor_gap))\n end\n end",
"def choose_elevator\n elevator_scores = []\n\n for elevator in @column.elevator_list do\n ... | [
"0.6298116",
"0.6162324",
"0.5863129",
"0.5796128",
"0.57165194",
"0.56179225",
"0.54705626",
"0.5448131",
"0.5425242",
"0.5390634",
"0.5317472",
"0.5293465",
"0.52821577",
"0.52778375",
"0.52574193",
"0.5252519",
"0.5249105",
"0.51937574",
"0.51047045",
"0.50997806",
"0.5088... | 0.7403369 | 0 |
Cause the identified items to be updated in the EMMA Unified Index. | def reindex(*entries)
list = Upload.get_relation(*entries).to_a
result = ingest_api.put_records(*list)
result.exec_report.error_messages.each { |e| $stderr.puts e }.blank?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_ion_indices\n ion = self.class.ion\n\n\n # Clear out previous indexes...\n ion.index_types.each { |i_type| i_type.deindex(self) }\n\n Ion.redis.multi\n # And add new ones\n ion.indices.each { |index| index.index(self) }\n Ion.redis.exec\n end",
"def update_in_index\n __elast... | [
"0.6704029",
"0.6561512",
"0.65048593",
"0.64639896",
"0.617644",
"0.60726136",
"0.5969441",
"0.59573597",
"0.59404886",
"0.59147817",
"0.5902834",
"0.5884477",
"0.5884345",
"0.5872946",
"0.5872946",
"0.5872946",
"0.5872946",
"0.5872946",
"0.5872946",
"0.5872946",
"0.5872946"... | 0.538517 | 84 |
Method to check the domain registration status. | def check_status(domain=nil)
begin
domain = self.fqdn if domain == nil
rescue NoMethodError
raise ArgumentError, "wrong number of arguments (0 for 1)"
end
@whois = parse_query(domain)
@whois['status']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_registration_status(domain)\n xml = send_recv(:GetRegistrationStatus, split_domain(domain))\n { :hold => xml.RegistrarHold?, :registration => xml.RegistrationStatus, :purchase => xml.PurchaseStatus }\n end",
"def valid?\n !domain.nil?\n end",
"def registered?\n begin\n se... | [
"0.6696315",
"0.66007185",
"0.65794474",
"0.651366",
"0.64911664",
"0.6426261",
"0.6426261",
"0.624149",
"0.6241229",
"0.6222592",
"0.618795",
"0.618795",
"0.61872554",
"0.6181001",
"0.6152879",
"0.6134844",
"0.6115462",
"0.6109446",
"0.6078349",
"0.60673165",
"0.60570025",
... | 0.6601201 | 1 |
Method to run the whois program with the domain and parse the output into a hash | def parse_query(domain=nil)
domain_file = "tmp/#{domain}_whois"
#puts("DEBUG >>> whois/parse_query called on domain #{domain}. Cache file will be stored in #{domain_file}")
begin
domain = self.fqdn if domain == nil
rescue NoMethodError
raise ArgumentError, "wrong number of arguments (0 for 1)"
end
if domain_is_cached(domain)
#puts("DEBUG >>> #{domain} is already cached, getting results from file.")
# If we have a valid cached file, we load that up and use it.
@whois = File.open(domain_file) {|f| Marshal.load(f)}
else
# We only actually run a WHOIS query if the domain is not cached - so we
# don't access WHOIS services too much.
#puts("DEBUG >>> #{domain} is not cached, making whois system call.")
whois_output = `whois -H #{domain} 2> /dev/null`
# Check that the whois query worked
if $?.exitstatus > 0
raise "WHOIS query was not successful - possible network error?"
end
# See how we should parse the output based on the TLD
case domain.split('.')[-1]
when 'biz'
#puts("DEBUG >>> .biz TLD. Using biz_parser")
biz_parser(whois_output)
when 'com'
#puts("DEBUG >>> .com TLD. Using com_parser")
com_parser(whois_output)
when 'info'
#puts("DEBUG >>> .info TLD. Using info_parser")
info_parser(whois_output)
when 'net'
#puts("DEBUG >>> .net TLD. Using net_parser")
net_parser(whois_output)
when 'org'
#puts("DEBUG >>> .org TLD. Using org_parser")
org_parser(whois_output)
when 'uk'
#puts("DEBUG >>> .uk TLD. Using uk_parser")
uk_parser(whois_output)
else
raise "This TLD (.#{domain.split('.')[-1]}) has no parser in Whois module."
end
# Marshal dump the @whois hash to a file
#puts("DEBUG >>> Writing the whois query results to cache file.")
File.open(domain_file, 'w') do |f|
Marshal.dump(@whois, f)
end
@whois
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def whois(domain)\n raise InvalidDomainError unless domain.to_s =~ /\\.nz\\z/i\n\n fetch_content domain\n self\n end",
"def whoisgem(domain)\n client = Whois::Client.new\n return client.lookup(domain) # returns the Whois::Record relevant to the domain\n end",
"def get_whois_n... | [
"0.7176516",
"0.70282465",
"0.6706688",
"0.6699175",
"0.6475335",
"0.63044935",
"0.62118024",
"0.6078173",
"0.59896564",
"0.5939859",
"0.58387315",
"0.5833264",
"0.5777313",
"0.5736887",
"0.57274336",
"0.5693436",
"0.5648879",
"0.5646573",
"0.5550882",
"0.5514687",
"0.5511142... | 0.76582336 | 0 |
Private method to see if we have a relevant cached query. | def domain_is_cached(domain)
domain_file = "tmp/#{domain}_whois"
if File.file?(domain_file)
if File.mtime(domain_file).to_time < 3.hours.ago
# Cached result file is too old
return false
else
return true
end
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache?\n val = @gapi.configuration.query.use_query_cache\n return false if val.nil?\n val\n end",
"def cache_query?\n false\nend",
"def cache_query?\n false\nend",
"def cacheable_request?\n (request.get? || request.head?) && (request.params[:cache] != 'false')\n ... | [
"0.7950755",
"0.7498267",
"0.7498267",
"0.7152269",
"0.71322614",
"0.7100893",
"0.7083884",
"0.7044111",
"0.7023682",
"0.70094377",
"0.699825",
"0.699825",
"0.6856534",
"0.6852669",
"0.6840964",
"0.68393874",
"0.68295044",
"0.6794054",
"0.6732888",
"0.6723752",
"0.6717033",
... | 0.0 | -1 |
Checke if it is possible to authenticate | def authenticated?
return true if @client.folders.count
rescue Viewpoint::EWS::Errors::UnauthorizedResponseError
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_for_authentication?; end",
"def valid_for_authentication?; end",
"def authenticate\n \t\tlogged_in? || access_denied\n \tend",
"def authenticate?\n @authentication_required\n end",
"def authok?\n @authok\n end",
"def authok?\n @authok\n end",
"def authok?\n @aut... | [
"0.79316914",
"0.79316914",
"0.7699964",
"0.7663511",
"0.7633985",
"0.7633985",
"0.7633985",
"0.7633985",
"0.76204276",
"0.7590559",
"0.75862694",
"0.7558347",
"0.7537479",
"0.7537479",
"0.7537479",
"0.7490932",
"0.7490799",
"0.74906796",
"0.74735194",
"0.7409206",
"0.7409206... | 0.0 | -1 |
each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place? | def rotate matrix
min = 0;
max = matrix.length-1
while min < max and max >= matrix.length/2
dif = 0
while min + dif < max
t1 = matrix[min][min+dif]
t2 = matrix[min+dif][max]
t3 = matrix[max][max-dif]
t4 = matrix[max-dif][min]
matrix[min][min+dif] = t4
matrix[min+dif][max] = t1
matrix[max][max-dif] = t2
matrix[max-dif][min] = t3
dif += 1
end
min += 1
max -= 1
end
matrix
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generic_rotate90(image)\n # Rotates a square image 90 degrees clockwise.\n d = image.length\n new_image = d.times.map { \"x\"*d }\n (0...d).each do |r|\n (0...d).each do |c|\n new_image[c][d-1-r] = image[r][c]\n end\n end\n new_image\nend",
"def rotate_image(image)\n\nend",
"def rotated_90... | [
"0.8023993",
"0.76115024",
"0.7385146",
"0.73238415",
"0.6866579",
"0.6862589",
"0.67585313",
"0.6679004",
"0.66644514",
"0.6662985",
"0.66064477",
"0.6573",
"0.648012",
"0.64334476",
"0.6395792",
"0.6378808",
"0.6374994",
"0.6373767",
"0.63570905",
"0.6327556",
"0.63184184",... | 0.55122894 | 91 |
def expired? self.expired_at < Time.zone.now end | def remove_in_progress_task
$redis.del("#{studio.studio_id}:#{ip}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expired?\n Time.now > self.to_be_expired_at\n end",
"def expired?\n DateTime.now.utc >= self.expires_at\n end",
"def expired?\n self.expires_at && Time.now.utc > self.expires_at\n end",
"def expired?\n self.expires_at && Time.now > self.expires_at\n end",
"def expired?\n Time.zone.to... | [
"0.94687057",
"0.9339752",
"0.9331974",
"0.92763996",
"0.9261029",
"0.92484343",
"0.91663575",
"0.9162526",
"0.9162526",
"0.91552657",
"0.9136963",
"0.91103196",
"0.91047287",
"0.9102409",
"0.9101769",
"0.90909016",
"0.9074122",
"0.9056781",
"0.9056781",
"0.90451163",
"0.9008... | 0.0 | -1 |
Building JSON Data for download | def objectify (point_cloud)
{
:id => point_cloud.id,
:name => point_cloud.name,
:data => point_cloud.data,
:created_at => point_cloud.created_at,
:updated_at => point_cloud.updated_at,
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json\n h = Hash.new\n\n h[\"description\"] = overview # add \"...\" if over certain size\n h[\"sources\"] = [full_name]\n h[\"subtitle\"] = \"(#{year}) #{genre}\"\n h[\"thumb\"] = poster\n h[\"art\"] = art\n\n t = name[0..32]\n t = t + \"..\" if t.size > 32\n h[\"title\"] = t\n\n ... | [
"0.6593848",
"0.6560064",
"0.6477827",
"0.64663625",
"0.6459084",
"0.64376944",
"0.6425473",
"0.6415667",
"0.6249833",
"0.6249833",
"0.61774796",
"0.6139515",
"0.61381006",
"0.6128678",
"0.6125907",
"0.6104432",
"0.6104432",
"0.6104432",
"0.6102278",
"0.6061218",
"0.605878",
... | 0.0 | -1 |
We are assuming that the style modifier is for the whole word. So this not support styling parts of a word. | def process_style_modifiers
@doc.css('b', 'i', 'em', 'strong', 'ins', 'u', 'del', 'cite').each do |node|
# We are getting the html of the children, we can't use {node.text} here
# because we would be missing all the other html tags.
text = node.children.to_s
replacement_value = MODIFIERS[node.name.to_sym]
node.replace(replacement_value + text.strip + replacement_value)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_style\n root = Document.new(Font.new(Font::ROMAN, 'Arial'))\n style = CharacterStyle.new\n style.bold = true\n\n assert(root.apply(style) != nil)\n assert(root.size == 1)\n assert(root[0].class == CommandNode)\n assert(root[0].prefix == '\\b')\n assert(root[0].suff... | [
"0.6091082",
"0.60830545",
"0.60539037",
"0.5978823",
"0.5978823",
"0.5978823",
"0.5910565",
"0.5844202",
"0.582488",
"0.57750523",
"0.5755645",
"0.5681169",
"0.56772906",
"0.5606135",
"0.56059647",
"0.5570531",
"0.55613095",
"0.55511254",
"0.5541017",
"0.5534038",
"0.5477025... | 0.5629745 | 13 |
For each root ul/ol we are going to process all children, and then replace the root ul/ol. | def process_lists
@doc.css('ul', 'ol').each do |list|
# If we get a list (ol/ul) which is not a root, we stop processing.
if list.ancestors('ul').count > 0 || list.ancestors('ol').count > 0
return
end
textile_list = []
list.css('li').each do |li|
process_li(li, textile_list)
end
list.replace("\n\n" + textile_list.join("\n") + "\n\n")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_child_nodes(node)\n node.xpath(\"./li/#{@list_tag}\").each do |list|\n # transfer attributes from parent now because the list tag will\n # no longer be a child and won't inheirit them as usual\n transfer_node_attributes(list.children, list.parent.attributes)\n ... | [
"0.62530977",
"0.6205985",
"0.62044185",
"0.61164755",
"0.60626346",
"0.60519624",
"0.6049954",
"0.60266316",
"0.5990934",
"0.59436643",
"0.5922585",
"0.58766913",
"0.5871193",
"0.5822433",
"0.58136374",
"0.57919",
"0.57919",
"0.5785689",
"0.5749788",
"0.5749248",
"0.5749038"... | 0.72732353 | 0 |
This should be in another class, we are not transforming to Textile, we are just removing the title tag. | def remove_title_if_present
@doc.css('title').each { |node| node.remove }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleansed_title\n self.title.gsub(/[\\t\\r\\n\\f:@]/, '')\n end",
"def cut_title\n self.title.sub(RUBY_FORMAT, '')\n# self.title.sub!(RHTML_FORMAT, '')\n# self.title.sub!(RJS_FORMAT, '')\n end",
"def titleless_content\n parse if fresh?\n @content.sub(/h\\d\\..+/, '')\n end",
"def titl... | [
"0.6486843",
"0.6468631",
"0.64637405",
"0.64043486",
"0.6299299",
"0.62575483",
"0.6213798",
"0.61520493",
"0.61520493",
"0.6104568",
"0.60666037",
"0.6061295",
"0.6042974",
"0.60358334",
"0.6032165",
"0.6028055",
"0.601616",
"0.601616",
"0.601616",
"0.6011499",
"0.6007132",... | 0.70244247 | 0 |
Supply Prowl defaults in a hash (:apikey, :providerkey, etc.), along with optional Typhoeus Hydra options. | def initialize(defaults = {}, hydra = {})
@defaults = defaults
@responses = []
@hydra = Typhoeus::Hydra.new(hydra)
@user_agent = USER_AGENT
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_key; @opts[:api_key]; end",
"def default_config\n data = {\n 'acr_values' => 'http://idmanagement.gov/ns/assurance/loa/1',\n 'client_id' => 'urn:gov:gsa:openidconnect:sp:sinatra',\n }\n\n if LoginGov::Hostdata.in_datacenter?\n # EC2 deployment defaults\n\n env =... | [
"0.6175032",
"0.6031856",
"0.59990984",
"0.59951645",
"0.59257764",
"0.5907216",
"0.5802565",
"0.57861054",
"0.5776028",
"0.57445747",
"0.5729467",
"0.5700546",
"0.56940365",
"0.56734604",
"0.56574047",
"0.5648762",
"0.5642558",
"0.5635029",
"0.55793554",
"0.5576615",
"0.5574... | 0.54787797 | 28 |
Queue a notification request in the Hydra. | def add(params = {})
@hydra.queue(request('add', params))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queue notification\n @notification_queue.unshift notification\n end",
"def queue(request)\n request.hydra = self\n queued_requests << request\n end",
"def will_notify\n #Resque.safe_enqueue Notification, to_user_id, id, APP::NOTIFICATIONS::MESSAGE\n end",
"def queued\n hyd... | [
"0.73767567",
"0.678501",
"0.64936423",
"0.6447023",
"0.63201845",
"0.62905234",
"0.6220999",
"0.61633766",
"0.61333746",
"0.6040526",
"0.60397565",
"0.60196996",
"0.6008436",
"0.59936816",
"0.5992344",
"0.5972296",
"0.59697366",
"0.5967277",
"0.5956669",
"0.5932285",
"0.5926... | 0.0 | -1 |
Modify this instance's defaults | def defaults(params)
@defaults = @defaults.merge(params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_defaults\n end",
"def set_defaults\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def set_defaults\n\n end",
"def defaults\n super\n end",
"def set_defaults\n super\n ... | [
"0.7836456",
"0.7836456",
"0.78169185",
"0.78169185",
"0.78169185",
"0.78169185",
"0.78169185",
"0.78169185",
"0.76169443",
"0.7473179",
"0.7473179",
"0.74016494",
"0.7273399",
"0.7273399",
"0.7273399",
"0.7273399",
"0.7273399",
"0.7273399",
"0.7273399",
"0.7273399",
"0.72733... | 0.67624235 | 50 |
Run all queued Hydra requests. | def run
@hydra.run
status
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queued\n hydra.queued_requests\n end",
"def execute\n @responses = {succeeded: [], failed: [], pending: [], succeeded_by_id: {}, requests_by_id: {}}\n @start = Time.now\n EventMachine.run do\n requests.each do |request|\n @responses[:pending] << request.process!\n ... | [
"0.685856",
"0.64856154",
"0.6398706",
"0.6398706",
"0.62887263",
"0.6245718",
"0.61392516",
"0.6111346",
"0.6085774",
"0.60237247",
"0.60234606",
"0.597978",
"0.5971494",
"0.59333783",
"0.59333783",
"0.591823",
"0.59097254",
"0.5868165",
"0.5866978",
"0.58467364",
"0.5844778... | 0.54150283 | 79 |
Change the useragent sent to the Prowl server. | def user_agent(user_agent)
@user_agent = user_agent
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_agent= user_agent\n @agent.user_agent = user_agent\n end",
"def user_agent=(user_agent); end",
"def user_agent= new_ua\n @headers['User-Agent'] =\n new_ua && Kronk.config[:user_agents][new_ua.to_s] ||\n new_ua || Kronk::DEFAULT_USER_AGENT\n end",
"def user_agent= new_ua\n ... | [
"0.7866124",
"0.7823937",
"0.7755849",
"0.7755849",
"0.7751693",
"0.7751693",
"0.7751693",
"0.7751693",
"0.7751693",
"0.7634683",
"0.7440789",
"0.7358134",
"0.7259788",
"0.7063613",
"0.70471495",
"0.70471495",
"0.70471495",
"0.70471495",
"0.70471495",
"0.70471495",
"0.7047149... | 0.74204785 | 11 |
Queue a verify API call in the Hydra. | def valid?
@hydra.queue(request('verify'))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify()\n # TODO\n end",
"def verify\n create_order\n start_challenge\n wait_verify_status\n check_verify_status\n rescue Acme::Client::Error => e\n retry_on_verify_error(e)\n end",
"def verify_response\n\n self.exec\n end",
"def verify_callback; end",
"def v... | [
"0.66038525",
"0.6555798",
"0.6433716",
"0.6430709",
"0.6430709",
"0.6425885",
"0.633897",
"0.62767875",
"0.62711334",
"0.61311936",
"0.6080868",
"0.6052273",
"0.6052273",
"0.60451573",
"0.5975101",
"0.5975101",
"0.5961242",
"0.5959812",
"0.5912138",
"0.5899672",
"0.58973867"... | 0.6897904 | 0 |
Setup and return a Typhoeus HTTP request | def request(action, params = {})
# Merge the default params with any custom ones
params = @defaults.merge(params) unless !@defaults
# Exception checks
if !params[:apikey] || (params[:apikey].is_a?(Array) && params[:apikey].size < 1)
raise MissingAPIKey
end
if params[:priority] && !PRIORITY_RANGE.include?(params[:priority])
raise PriorityOutOfRange
end
# Raise an exception if we're trying to use more API keys than allowed for this action
if params[:apikey].is_a?(Array) && ((action == 'verify' && params[:apikey].size > 1) || params[:apikey].size > MAX_API_KEYS)
raise TooManyAPIKeys
end
# If there are multiple API Keys in an array, merge them into a comma-delimited string
if params[:apikey].is_a?(Array)
params[:apikey] = params[:apikey].collect{|v| v + ',' }.to_s.chop
end
# Delete any empty key/value sets
params.delete_if {|key, value| value.nil? }
# Make the request
req = Typhoeus::Request.new(API_URL + action,
:user_agent => @user_agent,
:method => (action == 'add') ? :post : :get,
:params => (action == 'add') ? params : {:apikey => params[:apikey]}
)
# Typhoeus request on_complete method adds the HTTP code to an array
req.on_complete do |response|
@responses << response.code
end
# Return the request
req
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_request\n return Typhoeus::Request.new(\n endpoint_url,\n method: @method,\n params: @params,\n body: @body,\n headers: @headers)\n end",
"def make_request(url)\n res = Typhoeus::Request.new(\n url,\n method: :get,\n headers: ... | [
"0.8453924",
"0.7412816",
"0.7254225",
"0.72096765",
"0.7059429",
"0.6931954",
"0.6717415",
"0.6714135",
"0.6672244",
"0.66057146",
"0.65637875",
"0.655671",
"0.6556658",
"0.65307486",
"0.6511367",
"0.6485143",
"0.6446069",
"0.64418554",
"0.6429781",
"0.6414975",
"0.6404596",... | 0.0 | -1 |
Check to see if any notifications succeeded. Like the Prowl API with multiple API keys, we'll only return false if zero requests succeeded. | def status
return false if !@responses.include?(200)
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_succeeded?\n @errors.blank? && [200,0].member?(@response_code)\n end",
"def notify_success?\n result_status == \"QUERY_SUCCESS\"\n end",
"def notify_success?\n result_status == \"QUERY_SUCCESS\"\n end",
"def success?\n checks.all?(&:success?)\n end",
"def successful?... | [
"0.6952991",
"0.67574304",
"0.67574304",
"0.66165715",
"0.6468016",
"0.6468016",
"0.64526534",
"0.64526534",
"0.64488715",
"0.6410507",
"0.6383525",
"0.63483703",
"0.6346389",
"0.6345137",
"0.63392454",
"0.6336125",
"0.6331401",
"0.6330159",
"0.6329844",
"0.63232625",
"0.6302... | 0.6294327 | 21 |
Keyvalue representation of the error. Can be directly serialized into JSON. | def to_h
h = {
code: @code,
msg: @msg,
}
h[:meta] = @meta unless @meta.empty?
h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serializable_hash\n { errors: (super[:data] || []).map { |error| error[:attributes] } }\n end",
"def as_json(*)\n {\n error_type: error_type,\n error_message: error_message,\n meta: meta\n }\n end",
"def error\n\t\t{ \n\t\t\terror: { \n\t\t\t\tmessage: ... | [
"0.66824377",
"0.6638831",
"0.6605591",
"0.6546328",
"0.65115255",
"0.6292544",
"0.627261",
"0.62694836",
"0.62290907",
"0.6224939",
"0.62233377",
"0.62233377",
"0.61827135",
"0.61817557",
"0.6151883",
"0.60664773",
"0.605906",
"0.60453004",
"0.60240746",
"0.59965014",
"0.598... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_open_hour
@open_hour = OpenHour.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.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def open_hour_params
params.required(:open_hour).permit(:event_id, :day_of_the_week, :open_hour, :close_hour)
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.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Calculates automatically the total amount. There is a gotcha: If not all the payments are from the same money, this method won't calculate the total amount because this gem doesn't force the user to use a exchange service. | def total_amount
common_currency = calculate_common_currency
if common_currency.nil?
self[:total_amount]
else
self[:total_amount] ||= PaymentAmount[calculate_total, common_currency]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_payments\n total = 0\n payments.each{|payment| total += payment.amount}\n total\n end",
"def paid_total\n paid_total = 0\n unless self.payments.blank?\n for payment in self.payments\n paid_total += payment.amount.blank? ? 0 : payment.amount\n end\n end\n return pa... | [
"0.7728512",
"0.7668864",
"0.7522648",
"0.75194734",
"0.7499672",
"0.7485404",
"0.7406738",
"0.73492044",
"0.7337877",
"0.7318705",
"0.7199955",
"0.71560115",
"0.7152253",
"0.71406984",
"0.7124839",
"0.7035886",
"0.70224744",
"0.70153385",
"0.7010843",
"0.7010449",
"0.6980845... | 0.7700049 | 1 |
add the necessary class methods, attributes, etc. here to make the tests in spec/wordguesser_game_spec.rb pass. Get a word from remote "random word" service | def initialize(word)
@word = word
@guesses = ''
@wrong_guesses = ''
@word_with_guesses = ''
@wrong_word_with_guesses = ''
@check_win_or_lose
i = 0
while i < @word.length do
@word_with_guesses << '-'
i=i+1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize()\n @word = get_random_word\n @guesses = ''\n @wrong_guesses = ''\n end",
"def initialize(word)\n @url = \"https://www.google.com/search?q=define%3A+#{word}\"\n @noko = correct_site()\n @word_info = get_definition()\n end",
"def getRandomWord\n @word = Wordni... | [
"0.63192487",
"0.61587685",
"0.61230594",
"0.61190504",
"0.6044818",
"0.60241485",
"0.6006971",
"0.59786767",
"0.59680194",
"0.5951971",
"0.5836244",
"0.58284307",
"0.5783559",
"0.5782174",
"0.56847674",
"0.5656575",
"0.5648067",
"0.56467956",
"0.5631016",
"0.56278706",
"0.56... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_quizz
@quizz = Quizz.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.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from user, only allow the white list through. | def quizz_params
params.require(:quizz).permit(:title, :description, :difficulty)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_... | [
"0.7332092",
"0.70251495",
"0.69912875",
"0.6979885",
"0.68902034",
"0.67937815",
"0.6717389",
"0.6653924",
"0.6650712",
"0.6601131",
"0.65513307",
"0.65462005",
"0.6537341",
"0.65337366",
"0.65147483",
"0.6470548",
"0.64448416",
"0.6432828",
"0.64229804",
"0.6414409",
"0.636... | 0.0 | -1 |
init :: [string] > void | def init(args)
if (args.length != 1)
puts usage
return
end
command = args[0].downcase
if (command == "mount")
prompt_with_and_then("Mount", :list_mountable, :mount_command)
elsif (command == "unmount")
prompt_with_and_then("Unmount", :list_mounted, :unmount_command)
else
puts usage
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\r\n @strings = Array.new\r\n end",
"def initialize(z=\"\") end",
"def initialize(p0=\"\") end",
"def init(*args)\r\n \tunless args.nil? || args.empty?\r\n \t\t@ASCII = '0'\r\n \t\t@ASCII = args[0][:ASCII] if !args[0][:ASCII].nil?\r\n \t\t@things = []\r\n \t\t@owner = args[0][:owne... | [
"0.74555504",
"0.6888787",
"0.67866904",
"0.6751705",
"0.6611131",
"0.6597892",
"0.65366143",
"0.6486342",
"0.6468287",
"0.643961",
"0.64288414",
"0.64099824",
"0.64099824",
"0.64099824",
"0.64099824",
"0.64040923",
"0.63169944",
"0.63044506",
"0.63044506",
"0.63044506",
"0.6... | 0.0 | -1 |
prompt_with_and_then :: (string, symbol, symbol) > void | def prompt_with_and_then(prompt, items, action)
choice = `echo "#{self.send(items)}" | theme-dmenu -p "#{prompt}"`
if (choice.length > 0)
out, err, code = Open3.capture3(self.send(action, "#{mountable_path}/#{choice}"))
if (err.length > 0)
`notify-send -u critical Easymount "#{err}"`
else
`notify-send Easymount "#{out}"`
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prompt(string)\n puts \"==> #{string}\"\nend",
"def confirm(prompt); end",
"def prompt(str)\n puts \"=> #{str}\"\nend",
"def prompt(arg)\n puts(arg)\n gets.chomp\nend",
"def prepare_input(prompt); end",
"def prompt(question)\n puts question\n gets.chomp\nend",
"def ask_for_(thing)\n puts \... | [
"0.6979912",
"0.695627",
"0.6946157",
"0.69441956",
"0.6927728",
"0.6919798",
"0.68738115",
"0.686397",
"0.68070906",
"0.68022656",
"0.67956305",
"0.6787463",
"0.6772956",
"0.677013",
"0.677013",
"0.677013",
"0.677013",
"0.6706561",
"0.66919327",
"0.66919327",
"0.66919327",
... | 0.6561035 | 42 |
mount_command :: string > string | def mount_command(path)
"udisksctl mount --block-device #{path}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_mountstring\n mount = nil\n name = \"yaytest\"\n path = tmpdir\n assert_nothing_raised {\n mount = Puppet::Network::Handler.fileserver::Mount.new(name, path)\n }\n\n assert_equal(\"mount[#{name}]\", mount.to_s)\n end",
"def mount_path=(_arg0); end",
"def cmd(string)\n @com... | [
"0.61680084",
"0.6104018",
"0.6093119",
"0.6012799",
"0.5979571",
"0.59167814",
"0.5913823",
"0.58655703",
"0.5821163",
"0.5820151",
"0.5807807",
"0.579581",
"0.57951766",
"0.57951766",
"0.57951766",
"0.57951766",
"0.57951766",
"0.57951766",
"0.57941616",
"0.57668674",
"0.576... | 0.7148927 | 0 |
unmount_command :: string > string | def unmount_command(path)
"udisksctl unmount --block-device #{path}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unmount(name)\n mount_loc = File.join(KVM_MOUNT_POINT, name)\n if(system(\"umount #{mount_loc}\"))\n true\n else\n raise \"Failed to unmount kvm drive\"\n end\nend",
"def rm(path)\n cmd 'rm', path\nend",
"def unmount(opts)\n ct = lxc_ct(opts[:id])\n\n pid = ct.attach do\n next u... | [
"0.6148337",
"0.61282843",
"0.6105494",
"0.59178114",
"0.5895012",
"0.5881112",
"0.5808577",
"0.5798837",
"0.57206845",
"0.5710889",
"0.5691322",
"0.5689457",
"0.56493556",
"0.5548245",
"0.5541479",
"0.5524508",
"0.5514308",
"0.55064505",
"0.54871696",
"0.547982",
"0.54666984... | 0.7586523 | 0 |
Create a long lived server for the tests | def clc_test_server
puts "clc_test_server"
server = clc_service.servers.find { |s| s.Name == clc_server_name }
unless server
server = clc_service.servers.create({
:Name => clc_server_name
}.merge(clc_set_test_server_attributes))
server.wait_for { ready? }
end
server
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_server\n\n end",
"def start_server!\n httpd_root = \"#{__dir__}/fixtures/httpd\"\n\n # The command to start the server must reset the BUNDLE_GEMFILE environment\n # setting.\n # command = \"cd ../simple-httpd/ && BUNDLE_GEMFILE= PORT=12345 bin/simple-httpd start #{httpd_root} -q\" \n c... | [
"0.67443496",
"0.6631078",
"0.6616785",
"0.6594843",
"0.6535144",
"0.65292877",
"0.64969736",
"0.64552104",
"0.63713354",
"0.636591",
"0.6332696",
"0.6237494",
"0.6232441",
"0.6205914",
"0.61973155",
"0.61875737",
"0.6127939",
"0.6112675",
"0.6100854",
"0.6077142",
"0.6061919... | 0.6295105 | 11 |
Destroy the long lived server | def clc_test_server_destroy
server = clc_service.servers.find { |s| s.Name == clc_server_name }
server.destroy if server
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n data = Storm::Base::SODServer.remote_call '/Server/destroy',\n :uniq_id => @uniq_id\n data[:destroyed]\n end",
"def destroy_server(connection, server)\n server.destroy\n end",
"def stop\n @server.close\n end",
"... | [
"0.7429745",
"0.7354424",
"0.72947174",
"0.72772425",
"0.7116922",
"0.7084675",
"0.6995611",
"0.6987602",
"0.69845",
"0.6982915",
"0.69005394",
"0.686551",
"0.6832021",
"0.6823915",
"0.6815131",
"0.6762998",
"0.6721438",
"0.67164475",
"0.66993403",
"0.6696496",
"0.66946596",
... | 0.65516144 | 33 |
GET /resource/cancel Forces the session data which is usually expired after sign in to be expired now. This is useful if the user wants to cancel oauth signing in/up in the middle of the process, removing all OAuth session data. | def cancel
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registrat... | [
"0.76361334",
"0.76361334",
"0.76361334",
"0.76361334",
"0.76361334",
"0.76361334",
"0.7368125",
"0.7312355",
"0.7312355",
"0.7312355",
"0.7312355",
"0.7312355",
"0.7312355",
"0.7312355",
"0.7281023",
"0.71451616",
"0.6626427",
"0.65102315",
"0.65042484",
"0.6466236",
"0.6358... | 0.0 | -1 |
You can put the params you want to permit in the empty array. | def configure_sign_up_params
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :nationality_id ])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permitted_params\n []\n end",
"def additional_permitted_params\n []\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: fal... | [
"0.80368435",
"0.7541075",
"0.74603844",
"0.7257798",
"0.7257798",
"0.72326684",
"0.7149882",
"0.7099853",
"0.7041125",
"0.6992933",
"0.6952879",
"0.6906974",
"0.6879301",
"0.6855218",
"0.6844021",
"0.6841371",
"0.6808235",
"0.6803163",
"0.6794589",
"0.67901534",
"0.6788",
... | 0.0 | -1 |
You can put the params you want to permit in the empty array. | def configure_account_update_params
devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permitted_params\n []\n end",
"def additional_permitted_params\n []\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: fal... | [
"0.80368435",
"0.7541075",
"0.74603844",
"0.7257798",
"0.7257798",
"0.72326684",
"0.7149882",
"0.7099853",
"0.7041125",
"0.6992933",
"0.6952879",
"0.6906974",
"0.6879301",
"0.6855218",
"0.6844021",
"0.6841371",
"0.6808235",
"0.6803163",
"0.6794589",
"0.67901534",
"0.6788",
... | 0.0 | -1 |
The path used after sign up. | def after_sign_up_path_for(resource)
super(resource)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path\n root? ? boot_path : user_path\n end",
"def path\n root? ? boot_path : user_path\n end",
"def client_signed_up_path\n path_from_cookie(:after_account_signed_up_path) || path_from_cookie(:after_client_signed_up_path) || edit_user_client_path(current_user)\n end",
"def after_sign_... | [
"0.74486095",
"0.74486095",
"0.7348926",
"0.72428125",
"0.71978325",
"0.7191859",
"0.71229225",
"0.71229225",
"0.7114739",
"0.7110063",
"0.71050537",
"0.70890594",
"0.7078605",
"0.70710707",
"0.7039824",
"0.69836",
"0.69836",
"0.69836",
"0.69836",
"0.69687116",
"0.69687116",
... | 0.67457646 | 73 |
The path used after sign up for inactive accounts. | def after_inactive_sign_up_path_for(resource)
super(resource)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_inactive_sign_up_path_for(resource)\n respond_to?(:root_path) ? root_path : \"/\"\n end",
"def after_inactive_sign_up_path_for(resource)\n respond_to?(:root_path) ? root_path : \"/\"\n end",
"def after_inactive_sign_up_path_for(resource)\n respond_to?(:root_path) ? root_path : \"/\"\n ... | [
"0.7342214",
"0.7208575",
"0.7208575",
"0.7208575",
"0.7208575",
"0.7208575",
"0.72034144",
"0.7187855",
"0.71851933",
"0.71851933",
"0.7151745",
"0.7103472",
"0.7103472",
"0.71002626",
"0.71002626",
"0.7090088",
"0.70668596",
"0.70622385",
"0.70227474",
"0.701897",
"0.698111... | 0.6995652 | 34 |
def cost league = League.find_by_id(params[:id]) render plain: league.cost end def people_in_league league = League.find_by_id(params[:id]) render plain: league.people_in_league end | def show
@user = User.find(session[:user_id])
@league = League.find_by(id: params[:id])
respond_to do |form|
form.html{render :show}
form.json{render json: @league}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def team\n @team = Team.where('team_id = ?', params[:id])\n @active_stats = ActiveStat.where('team_id = ?', params[:id])\n\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def show\n @leaguemembers = League.find(params[:id]).users\n @matches = Match.where(:leagu... | [
"0.68495536",
"0.67788297",
"0.66406035",
"0.6617988",
"0.658224",
"0.65279543",
"0.6512413",
"0.6507493",
"0.64987785",
"0.6478145",
"0.63679284",
"0.6361654",
"0.63514453",
"0.6344323",
"0.63129306",
"0.6294987",
"0.6280963",
"0.6259406",
"0.6231762",
"0.6231762",
"0.621838... | 0.63398844 | 14 |
Return o generate new password | def password
@password ||= Password.new(password_hash)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_new_password\n chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'\n password = ''\n 10.times { password << chars[rand(chars.size)] }\n self.update_attributes(:encrypted_password => User.encrypt(password, self.salt))\n UserMailer.deliver_forgot_password_mail(self, password... | [
"0.8710023",
"0.8485628",
"0.8453982",
"0.844155",
"0.8274988",
"0.826289",
"0.82250094",
"0.8156477",
"0.8126085",
"0.811404",
"0.8072922",
"0.80485225",
"0.8037483",
"0.800008",
"0.7929134",
"0.79058325",
"0.7872217",
"0.7797423",
"0.7790051",
"0.7764938",
"0.77462035",
"... | 0.0 | -1 |
GET /testers GET /testers.json | def index
@testers = Tester.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @testers }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @tester = Tester.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tester }\n end\n end",
"def teachers\n url = drop_url_version + \"/count/teacherAssociations/#{params['edorg_id']}/teachers\"\n begin\n entities = Re... | [
"0.69367653",
"0.66942996",
"0.635389",
"0.6339862",
"0.6263857",
"0.6202649",
"0.61038965",
"0.6098523",
"0.60888034",
"0.60538757",
"0.59716266",
"0.59070766",
"0.59070766",
"0.59070766",
"0.5889392",
"0.5889392",
"0.5861978",
"0.5832927",
"0.5828665",
"0.5826435",
"0.58264... | 0.759817 | 0 |
GET /testers/1 GET /testers/1.json | def show
@tester = Tester.find(params[:id])
if @tester != current_tester
redirect_to current_tester, notice: 'You are not allow to see other profiles.'
end
#redirect_to current_tester, notice: 'You are not allow to see other profiles.'
#respond_to do |format|
# format.html # show.html.erb
# format.json { render json: @tester }
#end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @testers = Tester.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @testers }\n end\n end",
"def show\n @tester = Tester.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json... | [
"0.73209065",
"0.7289628",
"0.6448436",
"0.64104825",
"0.63615745",
"0.6324568",
"0.6324568",
"0.6265326",
"0.6211121",
"0.61205035",
"0.61042017",
"0.6085299",
"0.6078216",
"0.60519433",
"0.6051615",
"0.60374403",
"0.6033322",
"0.5939788",
"0.5939788",
"0.59379345",
"0.59367... | 0.0 | -1 |
GET /testers/new GET /testers/new.json | def new
@tester = Tester.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @tester }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @trainer = Trainer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trainer }\n end\n end",
"def new\n @taker = Taker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @taker }\n end\n... | [
"0.6962197",
"0.6915781",
"0.67971915",
"0.6740493",
"0.67219055",
"0.66921794",
"0.66775817",
"0.6666965",
"0.66543376",
"0.66265124",
"0.66245407",
"0.6603341",
"0.6600335",
"0.65905786",
"0.6590227",
"0.6590227",
"0.6575504",
"0.65586287",
"0.6549298",
"0.6535533",
"0.6528... | 0.7707012 | 1 |
POST /testers POST /testers.json | def create
@tester = Tester.new(params[:tester])
respond_to do |format|
if @tester.save
tester = @tester
session[:tester_id] = tester.id
format.html { redirect_to @tester, notice: 'Tester was successfully created.' }
format.json { render json: @tester, status: :created, location: @tester }
else
format.html { render action: "new" }
format.json { render json: @tester.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_testers\n\t\t@testers_data.shift\n\t\t@testers_data.each do |row|\n\t\t\ttester_id = row[0]\n\t\t\tfirst_name = row[1]\n\t\t\tlast_name = row[2] \n\t\t\tcountry = row[3]\n\t\t\tlast_login = row[4]\n\t\t\ttester = Tester.new(tester_id, first_name, last_name, country, last_login)\n\t\t\t@testers.push(test... | [
"0.62470764",
"0.62440044",
"0.60670966",
"0.59749275",
"0.595247",
"0.58003616",
"0.5776615",
"0.57670504",
"0.57129145",
"0.5675836",
"0.5675836",
"0.56390727",
"0.5621989",
"0.55856836",
"0.5566835",
"0.55240077",
"0.55219245",
"0.5514852",
"0.550431",
"0.5468431",
"0.5441... | 0.5996782 | 3 |
PUT /testers/1 PUT /testers/1.json | def update
@tester = Tester.find(params[:id])
respond_to do |format|
if @tester.update_attributes(params[:tester])
format.html { redirect_to @tester, notice: 'Tester was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @tester.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_put_success\n put \"/blah\", @test_obj do |response|\n assert response.ok?, \"Update test object failed\"\n end\n end",
"def test_update_successful\n data = {\n firstname: \"Anh\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Tha... | [
"0.61199856",
"0.60428333",
"0.6009719",
"0.599153",
"0.5939015",
"0.5874653",
"0.5859881",
"0.5837808",
"0.5810235",
"0.57881397",
"0.57473135",
"0.5744735",
"0.57092404",
"0.5698415",
"0.56830764",
"0.56617266",
"0.5657657",
"0.5647752",
"0.5647752",
"0.5647752",
"0.5647752... | 0.6563973 | 1 |
DELETE /testers/1 DELETE /testers/1.json | def destroy
@tester = Tester.find(params[:id])
@tester.destroy
respond_to do |format|
format.html { redirect_to testers_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @test = Test.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url }\n f... | [
"0.71065456",
"0.7083975",
"0.7083975",
"0.70367557",
"0.6883506",
"0.6862371",
"0.6860467",
"0.6860467",
"0.6860467",
"0.6860467",
"0.6860467",
"0.6860467",
"0.6860467",
"0.68592167",
"0.68464684",
"0.6819669",
"0.6817015",
"0.67892253",
"0.6787282",
"0.67779654",
"0.6773422... | 0.77072614 | 1 |
aqui dependiendo el tipo de usuario en este caso Subscribed para live ppe, y dependiendo el browser es el que vamos a usar. | def user_by_browser_tdc
puts $brow.to_s
if $brow == 'chrome'
return { "email" => $user_sus_lc_tdc_cr, "password" => $pass_sus_lc_tdc_cr }
elsif $brow == "safari"
return { "email" => $user_sus_lc_tdc_saf, "password" => $pass_sus_lc_tdc_saf }
elsif $brow == "mozilla"
return { "email" => $user_sus_lc_tdc_moz, "password" => $pass_sus_lc_tdc_moz }
else
fail(msg='No entro el case de usuarios por browser y Sus TDC')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def IsSubscribed=(arg0)",
"def IsSubscribed=(arg0)",
"def subscribe_to_default_channels\n #User.find_by_username(\"brevidy\").channels.where(:recommended => true).each { |c| c.subscribe!(self) } unless Rails.env.test?\n end",
"def registered(user)\n self.rsvped?(user) || self.isHost?(user)\n end"... | [
"0.5871801",
"0.5871801",
"0.57581586",
"0.5740071",
"0.56957805",
"0.553048",
"0.5509807",
"0.544696",
"0.54287183",
"0.53649026",
"0.53642726",
"0.5326135",
"0.5317751",
"0.5289472",
"0.5276018",
"0.5273561",
"0.5259264",
"0.51999974",
"0.5195822",
"0.5180352",
"0.5162782",... | 0.5417414 | 9 |
Get/set the number of seconds between heartbeat events. | def heartbeat_rate( new_rate=nil )
@heartbeat_rate = new_rate.to_f if new_rate
return @heartbeat_rate
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heartbeat_timeout\n data.heartbeat_timeout\n end",
"def seconds\n _nudge[2]\n end",
"def heartbeat_timeout; Float::INFINITY; end",
"def heartbeat_frequency\n server.cluster.heartbeat_interval\n end",
"def seconds\n @time\n end",
"def tests_poll_secs\n @game_info['... | [
"0.720737",
"0.6780744",
"0.6528011",
"0.6522499",
"0.6507858",
"0.644698",
"0.6412443",
"0.6408729",
"0.64073503",
"0.64004695",
"0.6233638",
"0.6232942",
"0.62159145",
"0.60415936",
"0.6037389",
"0.6030602",
"0.600216",
"0.5993413",
"0.5991755",
"0.59816355",
"0.5965898",
... | 0.5915085 | 22 |
Get/set the number of seconds between events before a client is disconnected | def idle_timeout( new_timeout=nil )
@idle_timeout = new_timeout if new_timeout
return @idle_timeout
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_timer\n if @connection.comm.connected? and Time.now - @var[:last_ping] >= 60\n begin\n _server_control(\"keepalive\")\n rescue\n _notice(\"The connection to the server has been lost\", :global)\n @connection.disconnect\n end\n end\nend",
"def client_disconnected\n end",
"def... | [
"0.6761682",
"0.6715481",
"0.66451854",
"0.66307455",
"0.6350368",
"0.63447726",
"0.6332372",
"0.6096921",
"0.6010563",
"0.5963997",
"0.5936235",
"0.5924616",
"0.59192073",
"0.58639413",
"0.58632684",
"0.58441955",
"0.5837549",
"0.57999885",
"0.5792706",
"0.57898974",
"0.5777... | 0.0 | -1 |
Inheritance hook inheriting classes inherit their parents' routes table. | def inherited( subclass )
super
subclass.instance_variable_set( :@idle_timeout, self.idle_timeout.dup )
subclass.instance_variable_set( :@heartbeat_rate, self.heartbeat_rate.dup )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inherited(subclass)\n super\n\n h = subclass.opts[:hash_branch_view_subdir_methods]\n opts[:hash_branch_view_subdir_methods].each do |namespace, routes|\n h[namespace] = routes.dup\n end\n end",
"def inherited(subclass)\n super\n nsr = s... | [
"0.6609033",
"0.6291236",
"0.6236855",
"0.61690086",
"0.60309947",
"0.60240835",
"0.60034657",
"0.591703",
"0.59136224",
"0.5840695",
"0.58118296",
"0.5743443",
"0.5743443",
"0.5743443",
"0.5743443",
"0.5743443",
"0.5743443",
"0.5743443",
"0.5743443",
"0.5743443",
"0.5743443"... | 0.0 | -1 |
Called by Mongrel2::Handler when it starts accepting requests. Overridden to start up the heartbeat thread. | def start_accepting_requests
self.start_heartbeat
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_heartbeat\n\t\tself.log.info \"Starting heartbeat timer.\"\n\t\t@heartbeat_timer = self.reactor.add_periodic_timer( self.class.heartbeat_rate ) do\n\t\t\tself.cull_idle_sockets\n\t\t\tself.ping_all_sockets\n\t\tend\n\tend",
"def start_heartbeat\n @hb_received_at = Time.now\n send_heartbea... | [
"0.7564895",
"0.72110647",
"0.6966699",
"0.688922",
"0.68513125",
"0.68230104",
"0.64901096",
"0.64671785",
"0.6271216",
"0.62344164",
"0.6221152",
"0.6127869",
"0.61002326",
"0.6076735",
"0.5988071",
"0.5980867",
"0.5975331",
"0.59176195",
"0.59176195",
"0.58216685",
"0.5803... | 0.8145583 | 0 |
Called by Mongrel2::Handler when the server is restarted. Overridden to restart the heartbeat thread. | def restart
self.stop_heartbeat
super
self.start_heartbeat
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_restart(&block); end",
"def restart\n client.restart\n end",
"def restart_server\n stop_server\n sleep 1\n start_server\n end",
"def start_heartbeat\n\t\tself.log.info \"Starting heartbeat timer.\"\n\t\t@heartbeat_timer = self.reactor.add_periodic_ti... | [
"0.6904999",
"0.68003976",
"0.6763715",
"0.669449",
"0.6671425",
"0.66584456",
"0.6590591",
"0.6571508",
"0.6565373",
"0.65432674",
"0.6542003",
"0.6502352",
"0.64218545",
"0.63798964",
"0.6370832",
"0.636443",
"0.63335013",
"0.62856543",
"0.6281572",
"0.6279329",
"0.6245739"... | 0.8183777 | 0 |
Called by Mongrel2::Handler when the server is shut down. Overridden to stop the heartbeat thread. | def shutdown
self.stop_heartbeat
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_heartbeat\n\t\tself.reactor.remove_timer( @heartbeat_timer )\n\tend",
"def signal_server_down\n interrupt_server_polling_sleep\n nil\n end",
"def shutdown\n @server_active = false\n end",
"def shut_down\n trigger(:shut_down_started)\n @server.stop(true) if @server\n ... | [
"0.79765886",
"0.7400563",
"0.7303974",
"0.7200122",
"0.6892235",
"0.6854887",
"0.6834558",
"0.6832956",
"0.6822465",
"0.6822465",
"0.6822465",
"0.6813245",
"0.6813245",
"0.6813245",
"0.6813245",
"0.6813245",
"0.6813245",
"0.6813245",
"0.6795474",
"0.67950827",
"0.6772762",
... | 0.7993101 | 0 |
Start a thread that will periodically ping connected sockets and remove any connections that don't reply | def start_heartbeat
self.log.info "Starting heartbeat timer."
@heartbeat_timer = self.reactor.add_periodic_timer( self.class.heartbeat_rate ) do
self.cull_idle_sockets
self.ping_all_sockets
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _start_updates\n\n t = Thread.new do\n packet_manager = PacketManager.instance\n loop do\n # update pacekts\n list_updated = packet_manager.update_streams\n # send\n @clients.each_index do |i|\n c = @clients[i]\n list_updated.each do |p|\n b... | [
"0.6908667",
"0.6601436",
"0.65812236",
"0.6537906",
"0.6459771",
"0.6271921",
"0.62182313",
"0.6136586",
"0.6116255",
"0.6054305",
"0.6037109",
"0.60358876",
"0.60267687",
"0.59418344",
"0.5920807",
"0.5912509",
"0.590164",
"0.5844894",
"0.58414453",
"0.5837747",
"0.5834702"... | 0.5352473 | 93 |
Tell the heartbeat thread to exit. | def stop_heartbeat
self.reactor.remove_timer( @heartbeat_timer )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exit\n ExitThread(0)\n end",
"def exit!\n @exiting = true\n @queue.push :__delivery_thread_exit_signal__\n end",
"def exit!\n @exiting = true\n @queue.push :__delivery_thread_exit_signal__\n end",
"def shutdown\n Thread.new do\n l... | [
"0.73675245",
"0.7190835",
"0.7190835",
"0.6891319",
"0.68544877",
"0.6777421",
"0.67723155",
"0.6766893",
"0.67489594",
"0.6716462",
"0.6660128",
"0.66244155",
"0.65971047",
"0.6585011",
"0.656145",
"0.654679",
"0.65341944",
"0.65341944",
"0.65341944",
"0.6514709",
"0.646672... | 0.6660239 | 10 |
Disconnect any sockets that haven't sent any frames for at least SOCKET_IDLE_TIMEOUT seconds. | def cull_idle_sockets
self.log.debug "Culling idle sockets."
earliest = Time.now - self.class.idle_timeout
self.connection_times.each do |sender_id, times|
times.each do |conn_id, lastframe|
next unless earliest > lastframe
self.log.warn "Timing out connection %s:%d: last seen %0.3fs ago." %
[ sender_id, conn_id, Time.now - lastframe ]
# Make a CLOSE frame
frame = Mongrel2::WebSocket::Frame.close
frame.set_status( CLOSE_EXCEPTION )
# Use the connection directly so we can send a frame and close the
# connection
self.conn.send( sender_id, conn_id, frame.to_s )
self.conn.send_close( sender_id, conn_id )
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_idle_sockets\n return if closed?\n return unless max_idle_time\n\n @lock.synchronize do\n i = 0\n while i < @available_connections.length\n connection = @available_connections[i]\n if last_checkin = connection.last_checkin\n if (Ti... | [
"0.6893426",
"0.6375546",
"0.6176038",
"0.61718494",
"0.61718494",
"0.61693037",
"0.60364634",
"0.60205466",
"0.60091364",
"0.59411675",
"0.59056914",
"0.58360547",
"0.5812672",
"0.579687",
"0.57572174",
"0.5739143",
"0.5730113",
"0.5686966",
"0.5680631",
"0.5609806",
"0.5573... | 0.70669025 | 0 |
Send a PING frame to all connected sockets. | def ping_all_sockets
return if self.connections.empty?
self.log.debug "Pinging %d connected sockets." % [ self.connections.length ]
self.connections.each do |sender_id, conn_ids|
frame = Mongrel2::WebSocket::Frame.new( sender_id, conn_id, '', {}, 'heartbeat' )
frame.opcode = :ping
frame.fin = true
self.log.debug " %s/%d: PING" % [ sender_id, conn_id ]
self.conn.reply( frame )
end
self.log.debug " done with pings."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_ping\n @connections.each do |socket|\n begin\n socket << \":\\n\"\n rescue Reel::SocketError\n @connections.delete(socket)\n end\n end\n end",
"def pong_everyone\n #log \"trying to pong\"\n if @sockets.length > 0 && !self.stopped?\n #log \"ponging\"\n ... | [
"0.71765536",
"0.64182895",
"0.64092845",
"0.62453675",
"0.62212956",
"0.61426455",
"0.6081005",
"0.5954288",
"0.59502035",
"0.59472543",
"0.59466946",
"0.5917659",
"0.5876896",
"0.577325",
"0.5772197",
"0.5748139",
"0.5626021",
"0.5625602",
"0.56120896",
"0.56100816",
"0.557... | 0.7254184 | 0 |
addition num1,num2 num1 and num2 are arguments | def addition num1,num2 #num1 and num2 are known as parameters
puts num1 + num2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(num1, num2)\r\n num1 + num2\r\n end",
"def add(num_1, num_2)\n\tresult = num_1 + num_2\n\treturn result\nend",
"def add(num_1, num_2)\n\treturn num_1 + num_2\nend",
"def add\n\t number_1 + number_2\n end",
"def addition (num1, num2)\n\tnum1 + num2\nend",
"def add(num1, num2)\n return num... | [
"0.8480702",
"0.83641124",
"0.8307389",
"0.8301309",
"0.82921886",
"0.82118493",
"0.81877893",
"0.81766295",
"0.8175005",
"0.8156116",
"0.8143135",
"0.8138902",
"0.81191194",
"0.8062816",
"0.8059181",
"0.8053745",
"0.8021621",
"0.8003152",
"0.7982453",
"0.7970628",
"0.7958727... | 0.79337364 | 28 |
Needed to properly handle undo. | def preloadJoint(type)
dir = File.dirname(__FILE__)
path = File.join(dir, "joints/#{type}.skp")
cd = Sketchup.active_model.definitions.load(path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def undo\n\t\t\n\tend",
"def undo\n\t\t\n\tend",
"def undo\n\t\t\t\t\n\t\t\tend",
"def onTransactionUndo(_)\n return if !tool_active? || @undone\n\n @undone = true # prevent recursion\n Sketchup.undo # call a second undo since new operation has already started\n update_comp\n refresh... | [
"0.8342604",
"0.8342604",
"0.8096284",
"0.74099743",
"0.7370062",
"0.7285018",
"0.7250229",
"0.7147068",
"0.7091712",
"0.7046041",
"0.6973567",
"0.69717723",
"0.69685024",
"0.6950134",
"0.69033325",
"0.69011426",
"0.69011426",
"0.68342555",
"0.6821937",
"0.68106717",
"0.68024... | 0.0 | -1 |
This is called when the user types a value into the VCB | def onUserText(text, view)
# The user may type in something that we can't parse as a length
# so we set up some exception handling to trap that
begin
value = text.to_l
rescue
# Error parsing the text
UI.beep
value = nil
Sketchup.set_status_text '', SB_VCB_VALUE
end
return unless value
case @state
when 1
# update the width
vec = @pts[1] - @pts[0]
if vec.length > 0.0
vec.length = value
@pts[1] = @pts[0].offset(vec)
view.invalidate
increment_state
end
when 2
# update the height
vec = @pts[3] - @pts[0]
if vec.length > 0.0
vec.length = value
@pts[2] = @pts[1].offset(vec)
@pts[3] = @pts[0].offset(vec)
increment_state
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_input key_value\n\n @key_value = key_value.to_sym\n changed\n notify_observers self\n\n end",
"def drb_input!\n Vedeu.bind(:_drb_input_) do |data, type|\n Vedeu.log(type: :drb, message: \"Sending input (#{type})\")\n\n case type\n when :command then Vedeu.t... | [
"0.67211837",
"0.61385584",
"0.6081012",
"0.60395366",
"0.60167617",
"0.5975911",
"0.5957361",
"0.58478045",
"0.5790815",
"0.5788589",
"0.5788589",
"0.5788589",
"0.57644635",
"0.57644635",
"0.5698706",
"0.56936586",
"0.5597294",
"0.55867267",
"0.5567435",
"0.5524521",
"0.5514... | 0.60324246 | 4 |
Using a private method to encapsulate the permissible parameters is a good pattern since you'll be able to reuse the same permit list between create and update. Also, you can specialize this method with peruser checking of permissible attributes. | def school_class_params
params.require(:school_class).permit(:title, :room_number)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::F... | [
"0.70143116",
"0.7008805",
"0.6857186",
"0.67885876",
"0.6709359",
"0.6684028",
"0.6672611",
"0.665639",
"0.6641643",
"0.6623889",
"0.661969",
"0.65919864",
"0.65918124",
"0.6576327",
"0.65567094",
"0.6537578",
"0.65306634",
"0.65237343",
"0.6518953",
"0.6488868",
"0.6474093"... | 0.0 | -1 |
children is an array of length 4 representing the child nodes of the node. index 0 is northeast (higher long and lat), 1 is south east, 2 is south west, 3 is north west | def initialize(longitude, latitude, location_id, parent)
@longitude = longitude
@latitude = latitude
@location_id = location_id
@parent = parent
@children = [nil,nil,nil,nil]
@total_leaves = if location_id.nil? then 0 else 1 end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n empty_squares.map { |pos| make_new_node(pos) }\n end",
"def children\n list = Array.new\n (0..2).each do |x|\n (0..2).each do |y|\n pos = [x,y]\n list << create_node(pos) if @board.empty?(pos)\n end\n end\n return list\n end",
"def make_children\n poss... | [
"0.6933356",
"0.6536344",
"0.64713585",
"0.64663315",
"0.6465529",
"0.64368016",
"0.6424321",
"0.64213395",
"0.6316889",
"0.6188804",
"0.6143499",
"0.6129925",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6087627",
"0.6087627",... | 0.5662716 | 99 |
Validates different types based on regexp and such | def validate(type,input)
if input.nil? then return false end
if !(input.is_a? String) then return false end
case type
when 'Integer'
return !(input.match(INTEGER_FORMAT).nil?)
when 'String'
return (input.length <= 1024)
when 'Mail'
return !(input.match(MAIL_FORMAT).nil?)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_type(type, context:); end",
"def valid_input?(owner, value)\n if value.nil?\n raise StandardError.new(\"Cannot validate null value\")\n end\n \n # Convert to string first\n value = value.to_s\n \n # Match depending on type\n case type\... | [
"0.68802184",
"0.6839543",
"0.6527269",
"0.64993024",
"0.64837825",
"0.6456251",
"0.641913",
"0.63899815",
"0.6378739",
"0.63780916",
"0.63386846",
"0.6270964",
"0.6194017",
"0.6101317",
"0.60903764",
"0.6088762",
"0.60780627",
"0.607773",
"0.6049135",
"0.60403526",
"0.601582... | 0.7350269 | 0 |
Perform Author: Aman Date: 30/05/2019 Reviewed By: | def perform
fail 'unimplemented perform'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def submission_decision_author(submission)\n @submission = submission\n\n @authors_text = @submission.get_authors_submitted.map{ |a| a.full_name }.join(', ')\n @title_text = @submission.get_text_submitted.title rescue ''\n\n @journal = @submission.journal\n @user = @submission.us... | [
"0.57207245",
"0.5714492",
"0.55773956",
"0.55771905",
"0.557615",
"0.557615",
"0.55631787",
"0.5537123",
"0.5510056",
"0.55007625",
"0.54789996",
"0.5440919",
"0.5426688",
"0.5418197",
"0.53833264",
"0.5369164",
"0.5347817",
"0.5331972",
"0.5326178",
"0.53240234",
"0.5322991... | 0.0 | -1 |
Validate and sanitize Author: Aman Date: 30/05/2019 Reviewed By: | def validate_and_sanitize
r = validate
return r unless r.success?
r = validate_parameters
return r unless r.success?
success
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_author()\n if not self.check_metatags('author')\n return false\n end\n author = @@metadata['author'].gsub(/\\./,'_').gsub(/\\&/,'').gsub(/\\-/,'_').gsub(/\\s/,'_').gsub(/\\,/,'_').gsub(/\\_\\_/,'_')\n I18n.enforce_available_locales = false\n I18n.transliterate(author).downcase # Normali... | [
"0.67398804",
"0.6682663",
"0.65829086",
"0.6436085",
"0.6432133",
"0.6413618",
"0.6316629",
"0.6260948",
"0.62156755",
"0.612929",
"0.6127945",
"0.610913",
"0.610774",
"0.61058235",
"0.60904783",
"0.6090337",
"0.604314",
"0.60429925",
"0.60406935",
"0.59963185",
"0.59697384"... | 0.0 | -1 |
Validate input params Author: Aman Date: 30/05/2019 Reviewed By: | def validate_parameters
r = validate_payment_nonce_uuid
return r unless r.success?
error_identifiers = []
error_identifiers << 'invalid_first_name' if @first_name.present? &&
(!Util::CommonValidateAndSanitize.is_string?(@first_name) || @first_name.length > 255)
error_identifiers << 'invalid_last_name' if @last_name.present? &&
(!Util::CommonValidateAndSanitize.is_string?(@last_name) || @last_name.length > 255)
error_identifiers << 'invalid_company' if @company.present? &&
(!Util::CommonValidateAndSanitize.is_string?(@company) || @company.length > 255)
error_identifiers << 'invalid_email' if @email.present? &&
(!Util::CommonValidateAndSanitize.is_valid_email?(@email))
error_identifiers << 'invalid_phone' if @phone.present? &&
(!Util::CommonValidateAndSanitize.is_string?(@phone) || @phone.length > 255)
error_identifiers << 'invalid_fax' if @fax.present? &&
(!Util::CommonValidateAndSanitize.is_string?(@fax) || @fax.length > 255)
error_identifiers << 'invalid_website' if @website.present? &&
(!Util::CommonValidateAndSanitize.is_valid_domain?(@website) || @website.length > 255)
return error_with_identifier('invalid_api_params',
'ra_c_c_vp_1',
error_identifiers
) if error_identifiers.present?
@customer_details[:first_name] = @first_name if @first_name.present?
@customer_details[:last_name] = @last_name if @last_name.present?
@customer_details[:company] = @company if @company.present?
@customer_details[:email] = @email if @email.present?
@customer_details[:phone] = @phone if @phone.present?
@customer_details[:fax] = @fax if @fax.present?
@customer_details[:website] = @website if @website.present?
success
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_params?; end",
"def validate_params(params)\n # This will be implemented by Validators which take parameters\n end",
"def check_params; true; end",
"def validate_params(hash)\n hash.include?('title') and hash.include?('body') and hash.include?('category')\n end",
"def vali... | [
"0.7024727",
"0.6987122",
"0.6628124",
"0.6600039",
"0.6598607",
"0.64964336",
"0.64749897",
"0.64416945",
"0.6434939",
"0.64314103",
"0.63845956",
"0.6336999",
"0.63078034",
"0.62965655",
"0.62453014",
"0.62178195",
"0.62049085",
"0.6152431",
"0.6144182",
"0.61429733",
"0.61... | 0.0 | -1 |
Validate payment_nonce_uuid if present Author: Aman Date: 30/05/2019 Reviewed By: | def validate_payment_nonce_uuid
return success if @payment_nonce_uuid.blank?
return error_with_identifier('invalid_api_params',
'ra_c_c_vpnu_1',
['invalid_payment_nonce_uuid']
) unless Util::CommonValidateAndSanitize.is_string?(@payment_nonce_uuid)
@gateway_nonce = GatewayNonce.get_from_memcache(@payment_nonce_uuid)
return error_with_identifier('invalid_api_params',
'ra_c_c_vpnu_2',
['invalid_payment_nonce_uuid']
) if @gateway_nonce.blank?
@ost_payment_token = @gateway_nonce.ost_payment_token
return error_with_identifier('invalid_api_params',
'ra_c_c_vpnu_3',
['invalid_payment_nonce_uuid']
) if (@ost_payment_token.client_id != @client.id) ||
(@gateway_nonce.status != GlobalConstant::GatewayNonce.active_status) ||
(@ost_payment_token.customer_id.present?)
success
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_nonce?(nonce, timestamp, consumer_key)\n \n end",
"def validate_nonce(request, value, seconds_to_timeout=5*60)\n t = ActiveSupport::Base64.decode64(value).split(\":\").first.to_i\n nonce(t) == value && (t - Time.now.to_i).abs <= seconds_to_timeout\n end",
"def validate(response)\n ... | [
"0.6798067",
"0.6088441",
"0.6086424",
"0.608403",
"0.59804237",
"0.5917215",
"0.5785835",
"0.57154334",
"0.5712858",
"0.5705686",
"0.56677246",
"0.5593132",
"0.55722463",
"0.5552786",
"0.55427426",
"0.5502488",
"0.5471665",
"0.54157007",
"0.536569",
"0.5360557",
"0.5360557",... | 0.7954449 | 0 |
Format service response Author: Aman Date: 30/05/2019 Reviewed By: | def service_response_data
fail 'unimplemented method service_response_data'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatAPA\n (prettyOutput(@authors.map { |x| x.to_s }) + \"(\" + @datee.year.to_s + \") \" + @title +\n \"\\n\\t(\" + @edition.to_s + \") \" +\n \"(\" + @editionnumber.to_s + \") \" +\n @url)\n end",
"def format_response response \n translate_response_hash_keys response_to_ha... | [
"0.66949934",
"0.6087984",
"0.6036213",
"0.603541",
"0.59979963",
"0.5923853",
"0.5872426",
"0.5838555",
"0.5817929",
"0.5817929",
"0.5706972",
"0.5640516",
"0.55819917",
"0.5543374",
"0.54951483",
"0.54870194",
"0.5483332",
"0.54500383",
"0.54500383",
"0.5435443",
"0.5429427... | 0.0 | -1 |
Retrieves cards that are in both deck and collection where deck qty != collection qty | def quantity_diff_query(coll_id, tracked_deck_id)
Card.joins(:external_deck_instances).joins(:collection_card_instances)
.where("collection_id = ? and external_deck_id = ? and
external_deck_instances.quantity !=
collection_card_instances.quantity and
collection_card_instances.quantity = 1",
coll_id, tracked_deck_id
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deck_not_collection_query(coll_id, tracked_deck_id)\n\t\tcards_in_collection = Card.joins(:collection_card_instances)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.where(\"collection_id = ?\", coll_id)\n\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t.select(\"cards.id\").to_sql\n\t\tCard.joins(:external_deck_instances)\n\t\t\t\t.where(\"ex... | [
"0.68230206",
"0.5959882",
"0.58532596",
"0.5819215",
"0.55439067",
"0.5456701",
"0.54545224",
"0.53686583",
"0.5356306",
"0.53508294",
"0.534702",
"0.53214866",
"0.529456",
"0.5200646",
"0.52005833",
"0.5157011",
"0.51557565",
"0.51116216",
"0.5102882",
"0.5072869",
"0.50661... | 0.69170415 | 0 |
Retrieves cards that are in the deck but not collection | def deck_not_collection_query(coll_id, tracked_deck_id)
cards_in_collection = Card.joins(:collection_card_instances)
.where("collection_id = ?", coll_id)
.select("cards.id").to_sql
Card.joins(:external_deck_instances)
.where("external_deck_id = ? and
cards.id NOT IN (#{cards_in_collection})", tracked_deck_id
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def non_trump_cards\n @cards.select {|c| c.suit != @trump_suit}\n end",
"def filter_cards(cards)\n cards = Array(cards) unless cards.respond_to?(:count) \n return cards.select { |card| Card.get(card.id).nil? } #TODO: move this to method\n end",
"def all_not_wild\n result = []\n for card in... | [
"0.7606907",
"0.71900344",
"0.70573133",
"0.69579625",
"0.6838108",
"0.65207887",
"0.64346135",
"0.6410397",
"0.63013524",
"0.6232891",
"0.62307066",
"0.61847264",
"0.61731243",
"0.6142808",
"0.61351234",
"0.611484",
"0.6111583",
"0.6087007",
"0.6083565",
"0.6060248",
"0.6021... | 0.72905326 | 1 |
Totals number of cards missing for tracked deck | def num_cards_owned(tracked_deck)
quantity_same_cards = quantity_same_query(coll_id, tracked_deck_id(tracked_deck))
quantity_diff_cards = quantity_diff_query(coll_id, tracked_deck_id(tracked_deck))
same_card_count = quantity_same_cards.inject(0) do |quantity, card|
quantity + card_quantity(card)
end
same_card_count + quantity_diff_cards.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_cards\n cards.count\n end",
"def numCards\n\t\t@cards.reduce(0) {|memo, card| memo += card.copies}\n\tend",
"def count\n @deck.count\n end",
"def count\n @deck.size\n end",
"def cards_in_deck\n Card.where(game_id: @game.id, owner: 0).size\n end",
"def no_of_cards\r\n @card_li... | [
"0.74861246",
"0.73736274",
"0.73668736",
"0.7309849",
"0.72209054",
"0.69569254",
"0.69569254",
"0.695109",
"0.6945925",
"0.6934842",
"0.6934842",
"0.6934842",
"0.6919808",
"0.6892707",
"0.6892707",
"0.6891934",
"0.688746",
"0.683361",
"0.68086827",
"0.6789684",
"0.6787599",... | 0.7677884 | 0 |
Returns quantity of specified card | def card_quantity(card)
ExternalDeckInstance.find_by(card_id: card.id).quantity
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quantity(card)\n external_deck_instances.find_by(card_id: card.id).quantity\n end",
"def card_quantity(card)\n c = instance_of(card.id)\n c.nil? ? 0 : c.quantity\n end",
"def collection_quantity(collection, card)\n return false unless collection && card\n\n if in_collection?(collection, ca... | [
"0.868132",
"0.845202",
"0.72160846",
"0.681336",
"0.67579466",
"0.67109716",
"0.6603903",
"0.65365624",
"0.6526348",
"0.65229255",
"0.6468193",
"0.6458887",
"0.6439727",
"0.6416867",
"0.6377191",
"0.63370013",
"0.6326407",
"0.632178",
"0.631865",
"0.63165057",
"0.6311675",
... | 0.8411033 | 2 |
Calculates dust needed to craft remainder of deck | def dust_needed(tracked_deck)
deck_not_collection_cards = deck_not_collection_query(coll_id, tracked_deck_id(tracked_deck))
quantity_diff_cards = quantity_diff_query(coll_id, tracked_deck_id(tracked_deck))
dust_total(quantity_diff_cards) + dust_total(deck_not_collection_cards)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def craft(dust, cards)\n\t\tn = 0\n\t\tfor card in cards\n\t\t\tif !card.complete?\n\t\t\t\tmissing = card.numMissing\n\t\t\t\tif missing * card.craft_cost <= dust\n\t\t\t\t\tdust -= missing * card.craft_cost\n\t\t\t\t\tcard.addCopies(missing)\n\t\t\t\t\tn += missing\n\t\t\t\telsif card.craft_cost <= dust\n\t\t\t\... | [
"0.7306968",
"0.7062871",
"0.67312354",
"0.6250499",
"0.6203436",
"0.6071911",
"0.5998456",
"0.59247434",
"0.58888775",
"0.5837822",
"0.5813173",
"0.576703",
"0.5750905",
"0.57507527",
"0.5738145",
"0.5713314",
"0.5705598",
"0.5689485",
"0.568548",
"0.56659275",
"0.5660439",
... | 0.7039593 | 2 |
Returns user's collection ID | def coll_id
current_user.collection.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_collection_id()\r\n return @coll_id\r\n end",
"def id\n @collection.id\n end",
"def set_collection\n @collection = User.find(current_user.id).collections.find(params[:id])\n end",
"def set_collection\n @collection = current_user.collections.find(params[:id])\n end"... | [
"0.787871",
"0.75485414",
"0.7346955",
"0.7140479",
"0.71065795",
"0.70943207",
"0.706617",
"0.6924091",
"0.6712702",
"0.65566456",
"0.6532065",
"0.6513397",
"0.65081376",
"0.6499959",
"0.6488324",
"0.64867777",
"0.64555883",
"0.6444607",
"0.6385404",
"0.6370033",
"0.6331714"... | 0.86051685 | 0 |
Returns tracked deck ID | def tracked_deck_id(tracked_deck)
tracked_deck.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_guessed_card\n current_round.guesses.last.card_id\nend",
"def card_id\n card.id\n end",
"def deck\n \"TK DECK\"\n end",
"def current_card\n @deck.cards[0]\n end",
"def current_card\n @deck.cards[@turns.count]\n end",
"def game_id\n @id\n end",
"def game_id\n service... | [
"0.6738969",
"0.6412447",
"0.62486315",
"0.61921483",
"0.6138566",
"0.61309654",
"0.61103064",
"0.6102644",
"0.6070289",
"0.6045724",
"0.6045724",
"0.6045724",
"0.6045724",
"0.5985913",
"0.594382",
"0.5891126",
"0.5863037",
"0.586269",
"0.5846808",
"0.58039325",
"0.57911664",... | 0.8802808 | 0 |
Returns dust total for cards | def dust_total(cards)
cards.inject(0) do |dust_total, card|
dust_total + dust_value(card.rarity)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if tot2 > 17\n return tot2\n elsif tot2 == 17\n unless @hit_soft_17\n return tot2\n end\n end\n end\n return tot\n end",
"def ... | [
"0.7352754",
"0.7171395",
"0.7079808",
"0.68658787",
"0.67936575",
"0.67681825",
"0.6722632",
"0.6616248",
"0.65452385",
"0.65284073",
"0.6528178",
"0.652529",
"0.6524382",
"0.65076166",
"0.6506992",
"0.6503395",
"0.64710736",
"0.64354193",
"0.64199483",
"0.63819104",
"0.6379... | 0.8612727 | 0 |
Returns the dust value associated with card's rarity | def dust_value(card_rarity)
case card_rarity
when "Free"
return 0
when "Common"
return 40
when "Rare"
return 100
when "Epic"
return 400
when "Legendary"
return 1600
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dust_total(cards)\n\t\tcards.inject(0) do |dust_total, card|\n\t\t\tdust_total + dust_value(card.rarity)\n\t\tend\n\tend",
"def randomRarity\n\t\tr = Random.rand\n\t\tfor rarity in RARITIES\n\t\t\tif r < DISTRIBUTION[rarity]\n\t\t\t\treturn rarity\n\t\t\tend\n\t\tend \n\tend",
"def rarity\r\n 6\r\n end... | [
"0.6842959",
"0.6626873",
"0.644227",
"0.627616",
"0.6265986",
"0.6092428",
"0.6080056",
"0.60292",
"0.5972159",
"0.5930678",
"0.5930015",
"0.58792806",
"0.5839148",
"0.58099556",
"0.5759916",
"0.5751199",
"0.5737049",
"0.5681297",
"0.5677197",
"0.5670033",
"0.5638383",
"0.... | 0.8876473 | 0 |
Dynamic title based on page | def full_title(page_title = '')
base_title = "Hearth Helper"
if page_title.empty?
base_title
else
page_title + " - " + base_title
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_page_title\n case @title\n when 'Winter', 'Spring', 'Summer', 'Fall'\n parent_content = Content.new(@parent_path)\n @page_title = @title + ' ' + parent_content.title\n else\n @page_title = @title\n end\n end",
"def page_title\n end",
"def title(page_title)\n \tcontent_... | [
"0.8088156",
"0.79689336",
"0.795719",
"0.7869999",
"0.78503656",
"0.7845735",
"0.7842397",
"0.7827057",
"0.7817457",
"0.77954257",
"0.77954257",
"0.77676636",
"0.7762432",
"0.776083",
"0.77586496",
"0.7753236",
"0.7731216",
"0.7724707",
"0.77206916",
"0.7694032",
"0.7690274"... | 0.0 | -1 |
Returns the current month | def current_month
Date.today.strftime("%B")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_month\n Time.now.strftime(\"%^b\")\n end",
"def time_month; Time.now.month; end",
"def current_month\n colspan = @options[:previous_month] || @options[:next_month] ? 3 : 7 # span across all 7 days if previous and next month aren't shown\n\n show_month(@days.first, @options[:current_mo... | [
"0.85755014",
"0.82750607",
"0.82561046",
"0.8227698",
"0.7905204",
"0.7657554",
"0.7653123",
"0.7520926",
"0.751522",
"0.7468684",
"0.7428697",
"0.7398828",
"0.73548764",
"0.7280612",
"0.7273064",
"0.7248864",
"0.7248864",
"0.7236135",
"0.72231627",
"0.71911114",
"0.71835196... | 0.8837745 | 0 |
def set_request_format_json request.format = :json end | def current_user
if auth_token && !@current_user
if @current_user = User.find_by_auth_token(auth_token)
@current_user = nil if @current_user.auth_token_expired?
end
end
@current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_default_format\n request.format = :json\n end",
"def set_default_format\n request.format = 'json'\n end",
"def set_default_format\n request.format = 'json'\n end",
"def set_default_response_format\n\t\t request.format = :json\n\t\tend",
"def set_default_response_format\... | [
"0.8735248",
"0.86770344",
"0.86574763",
"0.8134119",
"0.81194925",
"0.81194925",
"0.81113845",
"0.80337226",
"0.801793",
"0.7883056",
"0.7813645",
"0.779202",
"0.74033487",
"0.7020352",
"0.66627717",
"0.66150296",
"0.65191454",
"0.65140676",
"0.6500225",
"0.64760005",
"0.647... | 0.0 | -1 |
Set this to be true if you want to update entity user object without setting a title | def bypass_title_validation?
bypass_title_validation
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @user_name = args[:user_name] if args.key?(:user_name)\n end",
"def update!(**args)\n @user_name = args[:user_name] if args.key?(:user_name)\n end",
"def user_attributes=(attrs)\n self.user = User.where(attrs).first_or_initialize(attrs) \n @show_exist... | [
"0.63977045",
"0.63977045",
"0.62198687",
"0.61778176",
"0.6164568",
"0.6129842",
"0.6080536",
"0.60312086",
"0.60312086",
"0.60312086",
"0.6021958",
"0.60059375",
"0.60019237",
"0.5987889",
"0.59604645",
"0.593959",
"0.5919393",
"0.5909238",
"0.59076786",
"0.58976203",
"0.58... | 0.0 | -1 |
We implement this because it's required by DealOwner | def email_domain
user.email_domain
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(deal)\n @deal = deal\n super\n end",
"def bought_by(new_owner)\r\n self.owner = new_owner\r\n self.to_inactive\r\n end",
"def ink_deal\n if @ink_deal\n @ink_deal\n else\n @ink_deal = promotion.ink_deal\n end\n end"... | [
"0.62048924",
"0.568874",
"0.56704336",
"0.5668886",
"0.5549394",
"0.55223525",
"0.5502812",
"0.5502812",
"0.54942054",
"0.54335773",
"0.54231644",
"0.5380253",
"0.53558564",
"0.53518426",
"0.53518426",
"0.53448105",
"0.5335708",
"0.53322595",
"0.53130704",
"0.5287886",
"0.52... | 0.0 | -1 |
This method retrieves current logged in user details. | def current_user
@curr_user=User.find(session[:user_id])
rescue ActiveRecord::RecordNotFound
user = User.create
session[:user_id] = user.id
@curr_user = user
user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_info\n response = send_method(:get_user_info)\n user_from(response)\n end",
"def user\n\t\t\treturn nil if ! logged_in?\n\n\t\t\tPicombo::Session.instance.get('user')\n\t\tend",
"def get_current_user\n @user = User.find(params[:user_id])\n # @user = current_user\n end",
... | [
"0.82055825",
"0.7853838",
"0.77531147",
"0.773002",
"0.7723319",
"0.7723319",
"0.7722386",
"0.77183783",
"0.7692591",
"0.76631725",
"0.76631725",
"0.7636778",
"0.7634264",
"0.7606512",
"0.7590906",
"0.7590906",
"0.7589315",
"0.75891536",
"0.7568034",
"0.756519",
"0.75640917"... | 0.0 | -1 |
Validation check before performing validations. | def authorize
unless User.find_by_id(session[:user_id])
redirect_to :log_in, :notice => "Please log in"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate!\n # pass\n end",
"def validate\n # add errors if not validate\n end",
"def validate\r\n validate! rescue false\r\n end",
"def validate\n end",
"def validate\r\n\r\n end",
"def validate\n \n \n end",
"def validation; end",
"def validation; end",
"def... | [
"0.78240395",
"0.77709126",
"0.7769439",
"0.77296275",
"0.7666529",
"0.757846",
"0.75652814",
"0.75652814",
"0.75516564",
"0.7513819",
"0.7513819",
"0.7513819",
"0.7513819",
"0.7509371",
"0.7503909",
"0.7470459",
"0.7462313",
"0.7462313",
"0.7462313",
"0.74321747",
"0.7365997... | 0.0 | -1 |
Table view data source | def numberOfSectionsInTableView(tableView)
@month.keys.length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @contents = DataTable.all\n\n \n end",
"def index\n @datatable = ComplainsDatatable.new view_context\n end",
"def index\n @datat_table_data = DatatTableDatum.all\n end",
"def data_source=(val)\n PPCurses.implements_protocol( val, %w(number_of_rows_in_table object_value_for ))\n ... | [
"0.7092971",
"0.67255116",
"0.66212237",
"0.64762366",
"0.62949526",
"0.6291978",
"0.62858194",
"0.6163798",
"0.61115223",
"0.6096364",
"0.5997748",
"0.5997748",
"0.5997748",
"0.5997748",
"0.5985078",
"0.5895799",
"0.58901",
"0.5889067",
"0.58595294",
"0.58509016",
"0.5840576... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.