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 |
|---|---|---|---|---|---|---|
this function will remove all key/value pairs in the hash where the key is greater than xval the return is a hash of only key/value pairs that satisfy this condition | def removePastX myhash, xval
rtn = Hash.new
myhash.each do |key, value|
if key < xval
rtn.store(key, value)
end
end
rtn
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_h2\n hash = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9}\n hash.keep_if do |x, y|\n y < 5\n end\n hash\nend",
"def delete_h3\n hash = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9}\n hash.select! do |x, y|\n y < 5\n end\n hash\nend",
"def hash_delete(groce... | [
"0.7011022",
"0.6691159",
"0.6603633",
"0.6594395",
"0.65642244",
"0.6548213",
"0.6483263",
"0.6409515",
"0.6175602",
"0.60584855",
"0.6022216",
"0.60083884",
"0.5976026",
"0.5842326",
"0.58352584",
"0.5817863",
"0.5786013",
"0.5767304",
"0.5761495",
"0.5759027",
"0.57130325"... | 0.8035165 | 0 |
make sure that all of these values make sense TODO: test the output | def getSystemVars stress, pstress, tstrain, hardstress, neckingpoint, gauge, fitparam, youngs
#get the index of the last point
neckindex = hardstress.length - 1
df = getLastPoint(pstrain)[0]
dn = tstrain.sort[neckindex]
sigma_n = pstress[neckingpoint]
laststresspoint = getLastPoint(stress)
sigma_ef = laststresspoint[1]
eps_en = laststresspoint[0]
df_dn = ((E**df) * gauge) - ((E**dn) *gauge)
eps_f = Math.log(eps_en + 1 + (df_dn/fitparam))
sigma_f = sigma_ef * (eps_en + 1 + (df_dn/fitparam))
eps_pf = eps_f - (sigma_f/youngs)
return [eps_pf, neck, sigma_f, sigma_n]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expected_value; end",
"def expected_value; end",
"def check_values\n check_numericity\n check_zip_code\n end",
"def check_data_values(data)\n data.each do |id, values|\n out, back = values[values.keys[0]], values[values.keys[1]]\n if back > out\n puts \"+%s+\" % [\"-\" * ... | [
"0.65998405",
"0.65998405",
"0.62124497",
"0.6108468",
"0.60654366",
"0.6044652",
"0.6042582",
"0.60355586",
"0.59688026",
"0.5818258",
"0.5814756",
"0.5793971",
"0.5793607",
"0.5683171",
"0.56665653",
"0.56565887",
"0.56457657",
"0.5604027",
"0.55853856",
"0.5571284",
"0.557... | 0.0 | -1 |
remove all points after the necking point eps_pn = x value pstrain at necking point (this is our necking point attr) df = last pstrain value (x) dn = tstrain necking point (x) sigma_n is tstress at necking point (y) TODO separate TSTRESS and PSTRESS functions sigma_ef = stress (y) at last point (normal graph) eps_en = strain (x) at last point (normal graph) hardstress/strain is graph after removing past necking point df_dn = ((Edf) gaugelength) ((Edn) gaugelength) eps_f = Math.log(eps_en + 1 + (df_dn)/fittingparam sigma_f = sigma_ef (eps_en + 1 + (df_dn)/fittingparam) eps_pf = eps_f (sigma_f/youngsmod) plus = fittingparam(1+(accuracy/100)) minus = fittingparam(1(accuracy/100)) get two sets of new values for eps_f, sigma_f, eps_pf (plus/minus) solve the system of equations 3 times | def createSwiftPoints firstX, totalpoints, currentsize, swiftsco
#we want evenly spaced points and their corresponding swift values
rtn = Hash.new
#get the spacing for the x values
spacing = (1 - firstX) / (totalpoints - currentsize)
for i in 0..(totalpoints - currentsize)
#create a series of equally spaced points using swift equation as y's
#y = k * (eps_o + x)**n
xval = firstX + (i * spacing)
yval = swiftsco[2] * (swiftsco[0] + xval)**swiftsco[1]
rtn.store(xval, yval)
end
rtn
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSystemVars stress, pstress, tstrain, hardstress, neckingpoint, gauge, fitparam, youngs\n\t\t#get the index of the last point \n\t\tneckindex = hardstress.length - 1\n\t\tdf = getLastPoint(pstrain)[0]\n\t\tdn = tstrain.sort[neckindex]\n\t\tsigma_n = pstress[neckingpoint]\n\t\tlaststresspoint = getLastPoint(s... | [
"0.5894561",
"0.5027783",
"0.5025915",
"0.47233805",
"0.46673352",
"0.46430865",
"0.4623791",
"0.4544549",
"0.45419106",
"0.4505251",
"0.44744205",
"0.44633567",
"0.4444839",
"0.44354197",
"0.4430761",
"0.44070378",
"0.44027385",
"0.43856668",
"0.43828735",
"0.4381373",
"0.43... | 0.0 | -1 |
TODO: Handle meths mixed in from other modules | def search_access_instance_variable_in_module
modules_with_use_of_instance_variables(modules_to_look_at).each do |modul|
instance_variables_defined_outside_of(
modul,
instance_variables_accessed_by_module(modul)
).each do |instance_variable|
reporter << Weakpoint.new(instance_variable.method, "accesses instance variable #{instance_variable.name}")
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def methods() end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end... | [
"0.7367311",
"0.7122713",
"0.7122713",
"0.7122713",
"0.7122713",
"0.6568169",
"0.6568169",
"0.6568169",
"0.6568169",
"0.6568169",
"0.6568169",
"0.6568169",
"0.6568169",
"0.6568169",
"0.6568169",
"0.6568169",
"0.6568169",
"0.65414846",
"0.65193605",
"0.6503753",
"0.6503753",
... | 0.0 | -1 |
Returns instance variables that are used in other than the given module and is one of the given instance variables | def instance_variables_defined_outside_of(modul, instance_variables, root = object_repository.root)
log("instance_variables_defined_outside_of: #{modul}")
return [] if modul == root
variables = []
root.children.each do |child|
variables.concat instance_variables_defined_outside_of(modul, instance_variables, child)
end if root.respond_to?(:children)
variables.concat class_or_module_uses_variables(modul, root, instance_variables)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_access_instance_variable_in_module\n modules_with_use_of_instance_variables(modules_to_look_at).each do |modul|\n instance_variables_defined_outside_of(\n modul,\n instance_variables_accessed_by_module(modul)\n ).each do |instance_variable|\n reporter << Wea... | [
"0.7271964",
"0.63170755",
"0.6219123",
"0.6179934",
"0.61396444",
"0.6122815",
"0.6005672",
"0.59954065",
"0.58475107",
"0.5836055",
"0.58260524",
"0.5813921",
"0.57715243",
"0.57533455",
"0.5747344",
"0.57238364",
"0.56853074",
"0.56681776",
"0.55529046",
"0.54994184",
"0.5... | 0.6578677 | 1 |
translates an array of words and outputs and array of the tranlations | def translate(lang_from = @lang_from, lang_to = @lang_to, words)
return [] if words.size == 0
all_translated = [] #array of all translated words
words.each_slice(800) do |slice| #slice into 1000 words doing >1000 runs into problems
words_string = slice.join("&text=")
uri = "https://translate.yandex.net/api/v1.5/tr.json/translate?key=APIkey&lang=FROM-TO&text=WORD"
uri = uri.sub("WORD",words_string).sub("FROM", lang_from).sub("TO", lang_to).sub("APIkey", @key)
uri = URI.escape(uri) #escape unsafe characters in uri
begin
#puts uri
#puts '****************************'
json = open(uri).read #open uri of yandex translation
rescue => e
puts e.message
end
translated = JSON.parse(json)["text"]
#should probably check to make sure translated != nil
if translated.nil?
puts "PROBLEM TRANSLATING - returned nil (URI may be too long)"
else
all_translated += translated
end
end
all_translated #return array of all translations
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def translate\n words\n words_array = []\n pig_latin_words_array = []\n @words_array.each do |word|\n if starts_with_vowel?(word)\n word += 'way'\n elsif !starts_with_vowel?(word[1..-1])\n word = word[2..-1] + word[0] + word[1] + 'ay'\n else\n word = word[1..-1] + wo... | [
"0.7933318",
"0.71837026",
"0.7143351",
"0.71375304",
"0.70748436",
"0.70735",
"0.7058782",
"0.7002162",
"0.69449794",
"0.69060683",
"0.6894148",
"0.6877984",
"0.67857796",
"0.6765749",
"0.67304313",
"0.67271894",
"0.6703801",
"0.6703801",
"0.66217667",
"0.65990734",
"0.65962... | 0.6580223 | 22 |
Loads the Rails console into the current TkConsole Inspired by | def rails_console
say 'Loading Rails console...'
Tk.update
require "#{Dir.pwd}/config/boot"
if File.exists?("#{Dir.pwd}/config/application.rb")
Object.const_set :APP_PATH, File.expand_path("#{Dir.pwd}/config/application")
require APP_PATH
require 'rails/console/app'
require 'rails/console/helpers'
if defined?(Rails::ConsoleMethods)
self.class.include Rails::ConsoleMethods
end
::Rails.application.require_environment!
else
["#{Dir.pwd}/config/environment", 'console_app', 'console_with_helpers'].each {|e| require e }
end
say 'Rails console loaded!'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_console(app = T.unsafe(nil)); end",
"def load_console(app = T.unsafe(nil)); end",
"def set_console\n @console = Console.find(params[:id])\n end",
"def set_console\n @console = Console.find(params[:id])\n end",
"def console\n @console ||= set_console\n @console\n end",
"d... | [
"0.70587933",
"0.70587933",
"0.68526393",
"0.6845202",
"0.6745794",
"0.64476043",
"0.6281355",
"0.6253475",
"0.62350124",
"0.6231241",
"0.6214223",
"0.6136644",
"0.612601",
"0.61112094",
"0.6097654",
"0.6033812",
"0.6033812",
"0.60082203",
"0.6008071",
"0.590996",
"0.590726",... | 0.8056916 | 0 |
GET /skill_catagories GET /skill_catagories.json | def index
@skill_catagories = SkillCatagory.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @skills = Skill.all\n\n render json: @skills\n end",
"def list_skills\n\t\trender json: Skill.where(language_id: params[:language_id]).to_json\n\tend",
"def index\n @issue_skills = IssueSkill.all\n render json: @issue_skills\n end",
"def index\n @culinary_skills = CulinarySkill.a... | [
"0.7158367",
"0.68855214",
"0.6850532",
"0.67059803",
"0.6647558",
"0.6643378",
"0.66418594",
"0.65569353",
"0.6514686",
"0.64440906",
"0.64136475",
"0.64136475",
"0.6391822",
"0.6377537",
"0.63686424",
"0.6307629",
"0.6231032",
"0.6185179",
"0.6185179",
"0.61653507",
"0.6157... | 0.7283937 | 0 |
GET /skill_catagories/1 GET /skill_catagories/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @skills = Skill.all\n\n render json: @skills\n end",
"def index\n @skill_catagories = SkillCatagory.all\n end",
"def show\n @skill = Skill.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skill }\n end\n end",
... | [
"0.72277635",
"0.70650434",
"0.6944071",
"0.6923606",
"0.69212925",
"0.6829618",
"0.67043465",
"0.6689957",
"0.66873825",
"0.6672148",
"0.6596658",
"0.6545317",
"0.6538417",
"0.6508933",
"0.6498258",
"0.6485378",
"0.64435816",
"0.64425737",
"0.6433909",
"0.6433909",
"0.640359... | 0.0 | -1 |
POST /skill_catagories POST /skill_catagories.json | def create
@skill_catagory = SkillCatagory.new(skill_catagory_params)
respond_to do |format|
if @skill_catagory.save
format.html { redirect_to @skill_catagory, notice: 'Skill catagory was successfully created.' }
format.json { render :show, status: :created, location: @skill_catagory }
else
format.html { render :new }
format.json { render json: @skill_catagory.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @skill = Skill.new(skill_params)\n\n if @skill.save\n render json: @skill, status: :created, location: @skill\n else\n render json: @skill.errors, status: :unprocessable_entity\n end\n end",
"def create\n byebug\n @admin_skill = Admin::Skill.new(admin_skill_params)\n\n ... | [
"0.71728647",
"0.69313073",
"0.6804729",
"0.67875063",
"0.6741346",
"0.67228204",
"0.6689411",
"0.6660299",
"0.66521776",
"0.6630705",
"0.65810645",
"0.6560821",
"0.6550172",
"0.6543222",
"0.65084326",
"0.6504404",
"0.6480103",
"0.64697105",
"0.6454168",
"0.64435625",
"0.6411... | 0.7440628 | 0 |
PATCH/PUT /skill_catagories/1 PATCH/PUT /skill_catagories/1.json | def update
respond_to do |format|
if @skill_catagory.update(skill_catagory_params)
format.html { redirect_to @skill_catagory, notice: 'Skill catagory was successfully updated.' }
format.json { render :show, status: :ok, location: @skill_catagory }
else
format.html { render :edit }
format.json { render json: @skill_catagory.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @skill = Skill.find(params[:id])\n\n if @skill.update(skill_params)\n head :no_content\n else\n render json: @skill.errors, status: :unprocessable_entity\n end\n end",
"def update\n @skill = Skill.find(params[:id])\n\n respond_to do |format|\n if @skill.update_attri... | [
"0.7464696",
"0.72459084",
"0.71500206",
"0.7078378",
"0.7051112",
"0.7051112",
"0.7038388",
"0.698602",
"0.6932753",
"0.6899209",
"0.6845128",
"0.6841107",
"0.68290794",
"0.679503",
"0.67755014",
"0.6771616",
"0.6770551",
"0.6769739",
"0.67668676",
"0.6703406",
"0.66772836",... | 0.7306646 | 1 |
DELETE /skill_catagories/1 DELETE /skill_catagories/1.json | def destroy
@skill_catagory.destroy
respond_to do |format|
format.html { redirect_to skill_catagories_url, notice: 'Skill catagory was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @skill = Skill.find(params[:id])\n @skill.destroy\n\n respond_to do |format|\n format.html { redirect_to skills_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @skill.destroy\n\n head :no_content\n end",
"def destroy\n @skillset.destroy\n ... | [
"0.75820076",
"0.74880224",
"0.7423262",
"0.7419286",
"0.74175566",
"0.73334223",
"0.73111475",
"0.72927433",
"0.7284893",
"0.7275112",
"0.72430015",
"0.7224056",
"0.72035336",
"0.7166078",
"0.7162355",
"0.7155025",
"0.7152861",
"0.71434563",
"0.7132876",
"0.70900315",
"0.707... | 0.76285315 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_skill_catagory
@skill_catagory = SkillCatagory.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 skill_catagory_params
params.require(:skill_catagory).permit(:name, :description)
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.6981606",
"0.6784227",
"0.6746523",
"0.67439264",
"0.67361516",
"0.6593381",
"0.6506166",
"0.64994407",
"0.6483518",
"0.64797056",
"0.64578557",
"0.6441216",
"0.63811713",
"0.63773805",
"0.6366333",
"0.63217646",
"0.6301816",
"0.63009787",
"0.6294436",
"0.62940663",
"0.629... | 0.0 | -1 |
warmup Write a recursive method, range, that takes a start and an end and returns an array of all numbers in that range, exclusive. | def range(start, stop)
return [] if stop < start
return [stop] if start == stop
[start] + range(start+1, stop)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def range(start_num, end_num)\n range_array = []\n range_array << start_num\n\n if(start_num < end_num)\n range_array += range(start_num + 1, end_num)\n end\n\n range_array\nend",
"def range(start, ending)\n return [] if start >= ending - 1\n retu_arr = range(start, ending - 1)\n retu_arr << ending -... | [
"0.76350296",
"0.76329124",
"0.7480004",
"0.747388",
"0.7458357",
"0.7398958",
"0.7383578",
"0.7375112",
"0.7371598",
"0.7354345",
"0.7336554",
"0.7312647",
"0.72985965",
"0.729442",
"0.7273462",
"0.72669846",
"0.7226398",
"0.72184056",
"0.71997833",
"0.7197181",
"0.7172215",... | 0.7066623 | 25 |
p range(0, 5) p range(3, 1) p range(3, 1) Write both a recursive and iterative version of sum of an array. recursive | def sum_array_recur(array)
return nil if array.empty?
return array[0] if array.length == 1
array[0] + sum_array_recur(array[1..-1])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_recur(array)\n #base case\n return 0 if array.empty?\n #iterative step\n array.first + sum_recur(array[1..-1])\nend",
"def recursive_sum(array)\n return array[0] if array.length == 1\n\n array[0] + recursive_sum(array[1..-1])\nend",
"def recursive_sum(array)\n if array.length == 0\n return 0\... | [
"0.8269839",
"0.82021797",
"0.81169343",
"0.8047988",
"0.80173695",
"0.79912066",
"0.7969289",
"0.7926822",
"0.78254026",
"0.78006816",
"0.7773879",
"0.77513236",
"0.7729245",
"0.7722168",
"0.7689651",
"0.7679144",
"0.76692015",
"0.76691824",
"0.7656134",
"0.7633853",
"0.7624... | 0.7626188 | 20 |
puts sum_array_recur([1, 2, 3]) puts sum_array_recur([11, 0, 3]) puts sum_array_recur([]) iterative | def sum_array_iter(array)
return nil if array.empty?
sum = 0
array.each do |el|
sum += el
end
sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_recur(array)\n return 0 if array.empty?\n \n array[0] + sum_recur(array[1..-1])\nend",
"def sum_recur(array)\n#for array = []\n return 0 if array == []\n\n first_el = array.shift\n recursive_call = sum_recur(array)\n first_el + recursive_call\n\nend",
"def sum_recur(array)\n #base case\n retur... | [
"0.8543648",
"0.85331047",
"0.852692",
"0.849755",
"0.8445533",
"0.82541835",
"0.81791633",
"0.8161235",
"0.8129149",
"0.81262803",
"0.8123971",
"0.8109939",
"0.80856633",
"0.80525005",
"0.79463065",
"0.78917813",
"0.78917813",
"0.7838436",
"0.7817617",
"0.76997644",
"0.76809... | 0.0 | -1 |
puts sum_array_iter([1, 2, 3]) puts sum_array_iter([11, 0, 3]) puts sum_array_iter([]) exponentiation Write two versions of exponent that use two different recursions. recursion 1 | def exp_1(base, exp)
return 1 if exp == 0
base * exp_1(base, exp-1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_array_iterative(arr)\n arr.inject(0) {|sum, el| sum + el}\nend",
"def iterative_sum(array)\n sum = 0\n array.each do |ele|\n sum += ele\n end\n sum\nend",
"def iterative_sum(array)\n sum = 0\n array.each do |ele|\n sum += ele\n end\n sum\nend",
"def sum_recur(array)\n#for... | [
"0.71925133",
"0.7023608",
"0.7003676",
"0.69662523",
"0.68676966",
"0.6802275",
"0.67637205",
"0.6741112",
"0.66854197",
"0.6655353",
"0.66436136",
"0.66234154",
"0.6555764",
"0.65476966",
"0.65378857",
"0.6494963",
"0.6493781",
"0.6474719",
"0.6469016",
"0.6460827",
"0.6436... | 0.0 | -1 |
puts exp_1(3, 0) puts exp_1(3, 3) puts exp_1(3, 5) recursion 2 | def exp_2(base, exp)
return 1 if exp == 0
return base if exp == 1
if exp % 2 == 0
even = exp_2(base, exp / 2)
even * even
else
odd = exp_2(base, (exp - 1) / 2)
base * odd * odd
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exp1(base, power)\n puts \"exp1\"\n return 1 if power == 0\n base * exp1(base, power - 1)\nend",
"def exp_1(base, exp)\n return 1 if exp == 0\n\n base * exp_1(base, exp-1)\nend",
"def exp1(base, n)\n return 1 if n == 0 \n\n base * exp1(base, n-1)\nend",
"def recursive_exponent_1(base, ex... | [
"0.7933972",
"0.7555524",
"0.7534131",
"0.74627006",
"0.729329",
"0.72245824",
"0.71850455",
"0.7183511",
"0.7124202",
"0.7052946",
"0.7046438",
"0.70195514",
"0.70185477",
"0.70134056",
"0.6996249",
"0.69929945",
"0.69828665",
"0.6972971",
"0.6968954",
"0.68556607",
"0.68318... | 0.67441803 | 25 |
a = [1, [2], [3, [4]]] b = a.deep_dup b[1] b = [1, [2, 3], [3, [4]]] p a => a = [1, [2], [3, [4]]] b[2] b = [1, [2, 3], [3, [4], [1, 0]]] p a => a = [1, [2], [3, [4]]] fibonacci Write a recursive and an iterative Fibonacci method. The method should take in an integer n and return the first n Fibonacci numbers in an array. recursive | def fibonacci_recur(n)
return 0 if n == 1
return 1 if n == 2
fibonacci_recur(n - 1) + fibonacci_recur(n - 2)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive_fibonacci(n)\nreturn [1] if n == 1 \nreturn [1,1] if n== 2\n# a = recursive_fibonacci(n-1)\n# b = a[-1]\n# c=a[-2]\n# a+=(b+c)\nrecursive_fibonacci(n-1)+([recursive_fibonacci(n-1)[-2]+recursive_fibonacci(n-1)[-1]])\n# +([recursive_fibonacci(n-1)[-1]]+[recursive_fibonacci(n-1)[-2]])\n#fibonacci(n)=fib... | [
"0.76179284",
"0.759022",
"0.7555454",
"0.75407743",
"0.7515527",
"0.75152636",
"0.7491462",
"0.7487885",
"0.74665856",
"0.7446489",
"0.74424934",
"0.74255216",
"0.7424535",
"0.73895967",
"0.73890257",
"0.7372767",
"0.7370346",
"0.73654264",
"0.73552215",
"0.7351849",
"0.7351... | 0.0 | -1 |
puts fibonacci_recur(5) puts fibonacci_recur(7) puts fibonacci_recur(9) | def fibonacci_iter(n)
first_prev = 1
second_prev = 0
fib_num = 0
(n-2).times do
fib_num = first_prev + second_prev
second_prev = first_prev
first_prev = fib_num
end
fib_num
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fibonacci( n )\r\n fib_nums = []\r\n return n if n <= 1\r\n fib_nums << fibonacci( n - 1 )\r\n fib_nums << fibonacci( n - 2 )\r\n p \"#{fib_nums}\"\r\nend",
"def fibonacci_recur(n)\n return 0 if n == 1\n return 1 if n == 2\n\n fibonacci_recur(n - 1) + fibonacci_recur(n - 2)\nend",
"def ... | [
"0.8227644",
"0.796738",
"0.7943164",
"0.7924976",
"0.79161924",
"0.7908871",
"0.79058427",
"0.7895782",
"0.78953254",
"0.78883314",
"0.7866411",
"0.78633434",
"0.78626394",
"0.7860305",
"0.78452176",
"0.78417754",
"0.7841275",
"0.7835014",
"0.7829161",
"0.7820506",
"0.781994... | 0.0 | -1 |
puts fibonacci_iter(5) puts fibonacci_iter(7) puts fibonacci_iter(9) | def bsearch(array, target)
return nil if array == []
mid_idx = array.length / 2
case array[mid_idx] <=> target
when -1
right_idx = bsearch(array[mid_idx+1..-1], target)
mid_idx + right_idx + 1 unless right_idx == nil
when 0
mid_idx
when 1
bsearch(array[0...mid_idx], target)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fibonacci( n )\r\n fib_nums = []\r\n return n if n <= 1\r\n fib_nums << fibonacci( n - 1 )\r\n fib_nums << fibonacci( n - 2 )\r\n p \"#{fib_nums}\"\r\nend",
"def fibonacci\n Enumerator.new do |y|\n a = b = 1\n while true\n y << a\n a, b = b, a + b\n end\n end\nend",
"d... | [
"0.7967339",
"0.7957394",
"0.78946507",
"0.78784287",
"0.78335696",
"0.7814967",
"0.7796653",
"0.77947944",
"0.77737373",
"0.77066016",
"0.7690009",
"0.768605",
"0.76688904",
"0.76332456",
"0.7616543",
"0.76144886",
"0.75828326",
"0.7578025",
"0.757294",
"0.7568803",
"0.75679... | 0.0 | -1 |
puts bsearch([1, 2, 3], 1) => 0 puts bsearch([2, 3, 4, 5], 3) => 1 puts bsearch([2, 4, 6, 8, 10], 6) => 2 puts bsearch([1, 3, 4, 5, 9], 5) => 3 puts bsearch([1, 2, 3, 4, 5, 6], 6) => 5 puts bsearch([1, 2, 3, 4, 5, 6], 0) => nil puts bsearch([1, 2, 3, 4, 5, 7], 6) => nil merge sort Implement a method merge_sort that sorts an Array. | def merge_sort(array)
return array if array.length <= 1
mid_idx = (array.length/2)
left_side = array[0...mid_idx]
right_side = array[mid_idx..-1]
sort_left = merge_sort(left_side)
sort_right = merge_sort(right_side)
merge_halves(sort_left, sort_right)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bsearch(array, target)\n return nil if !array.include?(target)\n arr = array.sort\n\n mid = arr.length / 2\n\n\n if arr[mid] == target\n return mid\n elsif arr[mid] < target\n mid + bsearch(arr[mid..-1], target)\n else\n bsearch(arr[0..mid-1], target)\n end\nend",
"d... | [
"0.7872042",
"0.77249545",
"0.77163434",
"0.7681764",
"0.76584643",
"0.7656277",
"0.7636765",
"0.7591698",
"0.7566299",
"0.75595975",
"0.7525594",
"0.7522135",
"0.75198615",
"0.7483509",
"0.74800587",
"0.7474232",
"0.746787",
"0.74650526",
"0.7459069",
"0.7450352",
"0.7449596... | 0.0 | -1 |
p merge_sort([38, 27, 43, 3, 9, 82, 10]) array subsets Write a method subsets that will return all subsets of an array. | def subsets(array)
return [[]] if array == []
sets = subsets(array[0...-1])
sets + sets.map { |el| el += [array.last] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subsets(array)\n\nend",
"def subsets(array)\n\nend",
"def subsets(array)\n\nend",
"def subsets(nums)\n result = []\n subsets_helper(nums, [], result, 0)\n result\nend",
"def subsets(array)\n if array.length <= 1\n return array\n end\n subset_array = []\n (0..array.length - 1).each... | [
"0.7976805",
"0.7976805",
"0.7976805",
"0.7729354",
"0.7671415",
"0.76699054",
"0.7511467",
"0.7474441",
"0.7473976",
"0.74702704",
"0.74353635",
"0.7435001",
"0.74190927",
"0.73856056",
"0.7377639",
"0.7375041",
"0.7352822",
"0.73257065",
"0.72988456",
"0.7209475",
"0.719352... | 0.70601803 | 30 |
form for creating new user | def new
@user = User.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n\t\t @user = User.new\t\t#lo devo passare nella form per la create\n\tend",
"def new\n\t@user = User.new\n\t@title = \"Sign up\"\n end",
"def new\n\t@title = \"Sign Up\"\n\t@user = User.new\n end",
"def new\n @myuser = User.new # Create a new user in memory, whose params will be filled by ... | [
"0.81603163",
"0.80912846",
"0.8003513",
"0.7940693",
"0.79398304",
"0.7889191",
"0.7882382",
"0.7735318",
"0.770737",
"0.77027106",
"0.7668408",
"0.7666458",
"0.7646207",
"0.76438665",
"0.76345456",
"0.76248074",
"0.7607365",
"0.7602963",
"0.7588322",
"0.7587141",
"0.7575021... | 0.0 | -1 |
form for updating user(similar to new) use partial users/:id/edit | def edit
@user = User.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n #similar to the NEW action, but instead of create a empty user, we will find a user by its id and than\n # send its params to the partial form, so the params can be edited. Please note the partial form\n # for details, as the column admin can be edited only buy logged users with admin privilege... | [
"0.812515",
"0.8096047",
"0.7964317",
"0.79338217",
"0.78881925",
"0.78212464",
"0.78047717",
"0.7736468",
"0.7713344",
"0.7697714",
"0.76854014",
"0.7681681",
"0.7662712",
"0.7656616",
"0.76537895",
"0.76527625",
"0.7585663",
"0.7585663",
"0.7585663",
"0.7585663",
"0.7569999... | 0.744188 | 71 |
Get slot value by its name: document[:slot_1] If slot was not found, it will return nil | def [](slotname)
@slots[slotname.to_s].value rescue nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slot_number\n if slot.present?\n slot.number\n else\n nil\n end\n end",
"def get_slot(slot)\n equipments[slot]\n end",
"def slot\n Item.find(item_id).slot\n end",
"def get_slotname_by_key(key)\n @slots[keyslot(key)][:name] rescue nil\n end",
"def slot_number_for_... | [
"0.6411528",
"0.6277378",
"0.6063189",
"0.5933859",
"0.59247357",
"0.5895346",
"0.5631334",
"0.56137824",
"0.55804425",
"0.5413555",
"0.54066527",
"0.5401997",
"0.5376529",
"0.53675103",
"0.5325554",
"0.5295709",
"0.5290113",
"0.5238456",
"0.50925726",
"0.50925726",
"0.509257... | 0.7251265 | 0 |
Set slot value by its name: document[:slot_1] = "some value" | def []=(slotname, value)
slotname = slotname.to_s
(@slots[slotname] ||= Slot.new(self, slotname)).value = value
update_version!(slotname)
value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_slot_name\n @slot_name = SlotName.find(params[:id])\n end",
"def []=(name, value)\n @slots[name] = value\n end",
"def update!(**args)\n @slot_name = args[:slot_name] if args.key?(:slot_name)\n end",
"def set_slot\n @slot = Slot.find(params[:id])\n end",
"def ... | [
"0.67041147",
"0.6613204",
"0.6422406",
"0.63966763",
"0.63966763",
"0.63966763",
"0.6375207",
"0.63624424",
"0.63100296",
"0.63100296",
"0.61500233",
"0.61261547",
"0.60416573",
"0.60098106",
"0.59673333",
"0.58414996",
"0.5834652",
"0.5727364",
"0.5718556",
"0.5656125",
"0.... | 0.7060446 | 0 |
Checks slot presence. Unlike Documentslotnames it allows you to find even 'virtual slots' that could be computed runtime by associations or when_slot_found callbacks document.has_slot?(:slotname) | def has_slot?(slotname)
v = send(slotname)
(v.nil? && slotnames.include?(slotname.to_s)) ? true : !!v
rescue SlotNotFoundError
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_slot?(slot)\n slots.include? valid_slot_name!(slot)\n end",
"def check_slot(day, slot)\n\t\t\tevents = Event.where(day: day)\n\t\t\tused_slots = events.pluck(:slot)\n\n\t\t\tif used_slots.include? slot\n\t\t\t\treturn false\n\t\t\telse\n\t\t\t\treturn true\n\t\t\tend \n\t\tend",
"def slot_val... | [
"0.77595454",
"0.6803732",
"0.67840093",
"0.64517325",
"0.6393658",
"0.635091",
"0.6323228",
"0.6191751",
"0.5983401",
"0.5948756",
"0.56854993",
"0.56503475",
"0.56208783",
"0.5594806",
"0.558432",
"0.55154294",
"0.5503784",
"0.5503784",
"0.5503784",
"0.5467087",
"0.5432877"... | 0.7634592 | 1 |
Returns an Array of explicitely defined slots document.slotnames => ["version","name","language","authors"] | def slotnames
@slots.keys
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slots\n if !@slot_checkboxes.empty?\n @slot_checkboxes.keys.map do |k|\n k if Native(@slot_checkboxes[k]).elm.checked\n end.compact\n elsif @slot_dropdown\n [Native(@slot_dropdown).elm.value]\n end\n end",
"def pistaa_slot_items(slot)\n Pista... | [
"0.60174155",
"0.6011336",
"0.5877767",
"0.5646772",
"0.5596379",
"0.555948",
"0.5435869",
"0.54225546",
"0.5327552",
"0.53208274",
"0.5319528",
"0.5309544",
"0.5304167",
"0.52839303",
"0.5227472",
"0.52154535",
"0.5127851",
"0.5106827",
"0.5091779",
"0.50672805",
"0.5031641"... | 0.6277155 | 0 |
Returns string with Document's JSON representation | def to_json
to_raw.to_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json\n { :document => document, :signature => signature }.to_json\n end",
"def body\n @document.to_s\n end",
"def to_s\n return @doc.to_s\n end",
"def to_s\n @doc.to_s\n end",
"def to_s\n buf = [\"Document {\"]\n self.keys.sort_by {|key| key.to_s}.each do |k... | [
"0.7284291",
"0.71740824",
"0.7144786",
"0.71028286",
"0.6886882",
"0.6852263",
"0.6849104",
"0.68485355",
"0.6806806",
"0.678321",
"0.6750078",
"0.67464554",
"0.6607872",
"0.66035026",
"0.65700114",
"0.6569886",
"0.6526733",
"0.6512215",
"0.65029734",
"0.64943224",
"0.648808... | 0.62803936 | 32 |
Returns string with Document's XML representation | def to_xml(opts = {})
to_raw.to_xml({ :root => 'document', :dasherize => true }.merge(opts))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_xml\n return @doc.to_s\n end",
"def to_s\n document.xml? ? to_xml : to_html\n end",
"def xml_document\n @root_node.to_s\n end",
"def xml_document\n @root_node.to_s\n end",
"def to_s\n @xml\n end",
"def to_s\n return... | [
"0.84484637",
"0.81674397",
"0.79614156",
"0.79614156",
"0.79204506",
"0.7808129",
"0.766296",
"0.766296",
"0.7641724",
"0.7641314",
"0.7569301",
"0.75655276",
"0.75655276",
"0.7450314",
"0.7443277",
"0.74225533",
"0.73987",
"0.73838925",
"0.736464",
"0.73581797",
"0.7338988"... | 0.66653866 | 56 |
Reloads head of the same document from store. All unsaved changes will be lost! | def reload
new? ? self : store.find(uuid)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def head\n document.new? ? document.clone.extend(VersionedDocument) : document.store.find(document.uuid)\n end",
"def reloads\n load_page\n end",
"def reload\n self.replace( CouchDB.get( uri ) )\n end",
"def head\n render 'head.html'\n end",
"def update\n... | [
"0.62901026",
"0.62637687",
"0.58981884",
"0.57863325",
"0.57760566",
"0.57760566",
"0.5735172",
"0.56784385",
"0.5677318",
"0.5631745",
"0.56238496",
"0.56238496",
"0.5604476",
"0.55747074",
"0.55432075",
"0.5526341",
"0.5526341",
"0.5524933",
"0.5518994",
"0.55187994",
"0.5... | 0.0 | -1 |
Returns true if this is a document that has never been saved. | def new?
!!@new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saved?\n !new? && !@content\n end",
"def new_document?; not saved?; end",
"def in_a_document?\n state = false\n state = true if document_lines.count > 0\n return state\n end",
"def saved?\n !!@saved\n end",
"def saved?\n saved_at != nil\n end",
"def saved?\n ... | [
"0.72028667",
"0.7155293",
"0.6793787",
"0.675621",
"0.6691788",
"0.6686905",
"0.667022",
"0.66527694",
"0.6651447",
"0.66250545",
"0.6622341",
"0.6622341",
"0.6622341",
"0.6622341",
"0.6622341",
"0.6622341",
"0.6622341",
"0.6622341",
"0.6622341",
"0.6622341",
"0.6622341",
... | 0.0 | -1 |
Returns true if this document is a latest version of document being saved to a respective store | def head?
return false if new? || is_a?(VersionedDocument)
store.head_version(uuid) == version
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def latest?\n revision == latest_revision\n end",
"def saved_version_changes?\n track_altered_attributes ? (version_if_changed - saved_changes.keys).length < version_if_changed.length : saved_changes? # rubocop:disable Layout/LineLength\n end",
"def is_latest_version?\n if self.new_quote?\n fir... | [
"0.71696687",
"0.6739678",
"0.6717116",
"0.6596411",
"0.6560389",
"0.65323937",
"0.6505531",
"0.64276063",
"0.6368871",
"0.63120407",
"0.6305075",
"0.6303082",
"0.62567675",
"0.62421364",
"0.6237435",
"0.62327206",
"0.6213747",
"0.61997604",
"0.6196427",
"0.6192106",
"0.61730... | 0.5675614 | 86 |
Updates slots with specified hash and returns itself. | def update_slots(hash)
hash.each do |k, v|
self[k] = v
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_slots!(hash)\n update_slots(hash).save!\n end",
"def update!(**args)\n @slots = args[:slots] if args.key?(:slots)\n end",
"def update!(**args)\n @slots = args[:slots] if args.key?(:slots)\n end",
"def update(hash); end",
"def update!(**args)\n @sl... | [
"0.7917135",
"0.6672826",
"0.6672826",
"0.6208307",
"0.6153095",
"0.6011812",
"0.59411836",
"0.590194",
"0.58285075",
"0.575431",
"0.575431",
"0.5748707",
"0.5747634",
"0.57324404",
"0.57246196",
"0.571946",
"0.57090336",
"0.5707464",
"0.57018757",
"0.57018757",
"0.57018757",... | 0.8035544 | 0 |
Same as update_slots, but also saves the document. | def update_slots!(hash)
update_slots(hash).save!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def book_slot\n slot.state = 1\n slot.save!\n end",
"def write_to_slot(slot, tag, blocks)\n if slot.is_dirty == 1\n write_to_main_memory(slot)\n end\n slot.is_valid = 1\n slot.tag = tag\n slot.saved_blocks = blocks\n end",
"def update\n save_doc\n end",
"def ... | [
"0.6491626",
"0.62278455",
"0.616713",
"0.59953076",
"0.59379387",
"0.5903249",
"0.5844309",
"0.5844309",
"0.58204454",
"0.5716284",
"0.563141",
"0.5613488",
"0.5610675",
"0.55258906",
"0.54962593",
"0.5493545",
"0.5461719",
"0.5458705",
"0.5451845",
"0.54416215",
"0.54405063... | 0.6927686 | 0 |
Returns document's metadocument (if any). In case if document has more than one metadocument, it will combine all metadocuments into one 'virtual' metadocument | def meta
unless (m = self[:meta]).kind_of? Array
# simple case
return m || Document.new(@store)
end
return m.first if m.size == 1
mm = m.clone
collected_meta = mm.shift.clone
names = collected_meta[:name].split(',') rescue []
mm.each do |next_meta|
next_meta = next_meta.clone
collected_meta += next_meta
names << next_meta.name if next_meta[:name]
end
collected_meta.name = names.uniq.join(',')
collected_meta.make_immutable!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_metadata\n if (@document == nil)\n return false\n end\n \n @msdata = get_document_metadata(@document)\n #md_index = get_md_index() #Gets metadata index for (ace/dec) sorting \n #sort_metadata(md_index) #Sorts metadata (ace/dec)\n end",
"def get_document_metadata(d)\n md = []\n ... | [
"0.57119125",
"0.5634069",
"0.557425",
"0.54191273",
"0.5395234",
"0.5392256",
"0.5378833",
"0.5355876",
"0.53202945",
"0.53169596",
"0.52811617",
"0.52671826",
"0.525497",
"0.5253374",
"0.5225956",
"0.5215474",
"0.5190551",
"0.5187814",
"0.5169173",
"0.5169173",
"0.5154853",... | 0.64087456 | 0 |
Instantiate a composite document | def +(document)
original, target = [to_raw, document.to_raw].map{ |raw| raw.except(*%w(uuid version previous_version)) }
Document.new(@store, original.merge(target).merge(:uuid => Util.random_uuid), true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build(attrs = {}, &block)\n create_document(:new, attrs, &block)\n end",
"def initialize(name, document); end",
"def initialize(document)\n @document = document\n end",
"def new\n @document = Document.new\n end",
"def new_instance_doc(options={})\n return if self.instance_class... | [
"0.6859276",
"0.6729767",
"0.6334086",
"0.633329",
"0.6228844",
"0.6228844",
"0.6214472",
"0.6208834",
"0.61851853",
"0.6170444",
"0.61608917",
"0.61007977",
"0.6089786",
"0.6089048",
"0.6051602",
"0.60500574",
"0.6030842",
"0.6024971",
"0.60145634",
"0.59945965",
"0.5963206"... | 0.0 | -1 |
Should be used to add metadocuments on the fly: document.metas << Buyer document.metas << Buyer.document Please not that it accept both meta modules and their documents, there is no difference | def metas
@metas ||= Metas.new(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_document_metaform(document_id, mf_id)\n if (document_id == nil or document_id == \"\" or \n mf_id == nil or mf_id == \"\")\n return false\n end\n \n metaform = Metaform.find(mf_id)\n document = Document.find(document_id)\n\n if (document.stuffing_metadata == nil or document.st... | [
"0.68408525",
"0.6057685",
"0.59923995",
"0.59029543",
"0.5806038",
"0.560828",
"0.560828",
"0.5605323",
"0.5593266",
"0.55878305",
"0.5579389",
"0.557255",
"0.546031",
"0.54494846",
"0.5441402",
"0.5428147",
"0.5417891",
"0.5402666",
"0.5398791",
"0.5393382",
"0.538222",
"... | 0.0 | -1 |
Returns document's version (which is stored in version slot) | def version
self[:version]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version # :nodoc:\n if document.present?\n document.version\n else\n @metadata[:version]\n end\n end",
"def version\n solr_document.fetch('_version_', nil)\n end",
"def version\n @version ||= @doc.at('/document/@SSLyzeVersion').value.split(' ',2).last\n end",
"def doc... | [
"0.8204421",
"0.78823894",
"0.7484113",
"0.73921657",
"0.7283741",
"0.7235509",
"0.72246057",
"0.7198738",
"0.71950155",
"0.7187266",
"0.71647966",
"0.71486324",
"0.71217406",
"0.7110675",
"0.70885086",
"0.7088358",
"0.7088358",
"0.708272",
"0.70242906",
"0.6996415",
"0.69943... | 0.67929655 | 40 |
Returns document's previous version (which is stored in previous_version slot) | def previous_version
self[:previous_version]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def previous\n self[document.previous_version]\n end",
"def previous\n versionable.versions.previous_version( self.number )\n end",
"def previous_version\n @previous_version ||= previous_versions[0]\n end",
"def previous_version\n current_version - 1\n end",
"def previous_versio... | [
"0.88584596",
"0.83317983",
"0.83047163",
"0.80978817",
"0.805415",
"0.805415",
"0.8003524",
"0.798696",
"0.7958724",
"0.79173744",
"0.7683431",
"0.7617149",
"0.7448142",
"0.7405797",
"0.7376684",
"0.7362883",
"0.7339352",
"0.72195125",
"0.7216441",
"0.7116997",
"0.7002718",
... | 0.8308395 | 2 |
Returns an instance of Document::Versions | def versions
@versions ||= Versions.new(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def versions\n link = data.xpath(\"at:link[@rel = 'version-history']/@href\", NS::COMBINED)\n if link = link.first\n Collection.new(repository, link) # Problem: does not in fact use self\n else\n # The document is not versionable\n [self]\n end\n end",
"def versions\n ... | [
"0.77871627",
"0.75367165",
"0.7244133",
"0.717014",
"0.7134484",
"0.7133571",
"0.7043537",
"0.6967151",
"0.6787103",
"0.663377",
"0.65274936",
"0.6488089",
"0.64236754",
"0.63435525",
"0.6327078",
"0.63076985",
"0.62944543",
"0.62757397",
"0.623646",
"0.6226527",
"0.61930794... | 0.7844784 | 1 |
documents are hashed by their UUID | def hash #:nodoc:
uuid.hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n guid.hash\n end",
"def hash\n \tcustom_unique_id.hash\n end",
"def doc_id\n Indexer.index.search(Ferret::Search::TermQuery.new(:probably_unique_id,probably_unique_id)).hits.first.doc\n end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",... | [
"0.64346474",
"0.6375773",
"0.6082161",
"0.5970405",
"0.5970405",
"0.5970405",
"0.5970405",
"0.5970405",
"0.5970405",
"0.5970405",
"0.59389246",
"0.59173745",
"0.59173745",
"0.5896235",
"0.58786273",
"0.5856874",
"0.585583",
"0.5848677",
"0.5844485",
"0.5822882",
"0.5817844",... | 0.64063007 | 1 |
value of the last called callback is returned when executing callbacks (or nil if none found) | def execute_callbacks(name, *args) #:nodoc:
(callbacks[name.to_s] || []).inject(nil) do |prev_value, callback|
callback.call(self, *args)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callback\n @callback ||= :value.to_proc\n end",
"def get_CallbackID()\n \t return @outputs[\"CallbackID\"]\n \tend",
"def get_CallbackID()\n \t return @outputs[\"CallbackID\"]\n \tend",
"def get_CallbackID()\n \t return @outputs[\"CallbackID\"]\n \tend",
"def get_Ca... | [
"0.6965818",
"0.6342119",
"0.6342119",
"0.6342119",
"0.6342119",
"0.6340995",
"0.6315941",
"0.6098293",
"0.60951406",
"0.6078837",
"0.6041892",
"0.59711844",
"0.5911927",
"0.5889013",
"0.5864316",
"0.5864316",
"0.5861978",
"0.5815096",
"0.5810942",
"0.57897395",
"0.57804066",... | 0.0 | -1 |
initialize the document. initialize_raw is true when document is initialized from a raw serialized form | def do_initialize(store, slots={}, initialize_raw = false) #:nodoc:
@callbacks = {}
@store = store
if initialize_raw
initialize_raw_slots slots
@saved = true
else
@new = true
initialize_slots slots
self[:uuid] = Util.random_uuid unless self[:uuid]
generate_new_version! unless self[:version]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(document, field_config, opt = nil)\n super(document, field_config)\n @raw = opt&.fetch(:raw, false)\n end",
"def initialize(document)\n @document=document\n end",
"def initialize(document)\n @document = document\n end",
"def initialize(raw_content... | [
"0.70341676",
"0.66306424",
"0.64894557",
"0.64462334",
"0.63744044",
"0.63714445",
"0.63575226",
"0.63183063",
"0.6303811",
"0.6296794",
"0.62891096",
"0.6177554",
"0.59050167",
"0.58820754",
"0.5878498",
"0.58218414",
"0.58172303",
"0.5788619",
"0.5767793",
"0.5741912",
"0.... | 0.0 | -1 |
initialize slots for a new, just created document | def initialize_slots(slots) #:nodoc:
@slots = {}
slots = slots.stringify_keys
# there is a reason for meta slot is initialized separately —
# we need to setup coercions before initializing actual slots
if meta = slots['meta']
meta = [meta] unless meta.is_a?(Array)
meta.each {|m| metas.add_meta(m) }
end
slots.except('meta').each {|name,value| self[name] = value }
# now, when we have all slots initialized, we can run initialization callbacks
execute_callbacks :on_initialization
execute_callbacks :on_new_document
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize:\n\t\t@slots = []",
"def initialize(name, document); end",
"def create_new\n create_doc_keys(true)\n @radlib_fillin_id = @docs[:fillin] unless @radlib_fillin_id && @radlib_fillin_id.length > 0 # if only the radlib_id and fillin_index were passed, set the @radlib_fillin_id\n create_defau... | [
"0.6226447",
"0.61228555",
"0.6097152",
"0.6093024",
"0.6027019",
"0.5992883",
"0.59678364",
"0.59198266",
"0.58594126",
"0.5853645",
"0.58051866",
"0.5769017",
"0.575864",
"0.5721413",
"0.5719666",
"0.5718664",
"0.56901056",
"0.56202716",
"0.56116354",
"0.5608793",
"0.557039... | 0.6938616 | 0 |
initialize slots from a raw representation | def initialize_raw_slots(slots) #:nodoc:
@slots = {}
slots.each do |name,value|
s = Slot.new(self, name)
s.raw_value = value
@slots[name.to_s] = s
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize:\n\t\t@slots = []",
"def initialize_slots(slots) #:nodoc:\n @slots = {}\n slots = slots.stringify_keys\n\n # there is a reason for meta slot is initialized separately — \n # we need to setup coercions before initializing actual slots\n if meta = slots['meta']\n meta... | [
"0.6856678",
"0.68041587",
"0.6306608",
"0.61869466",
"0.61869466",
"0.59157217",
"0.5837224",
"0.5830598",
"0.5824325",
"0.58107656",
"0.5806177",
"0.56984836",
"0.5659025",
"0.5578833",
"0.5508101",
"0.5479305",
"0.5438742",
"0.54315376",
"0.54139256",
"0.5390689",
"0.53714... | 0.7812239 | 0 |
Vectors here is an array of pairs to fill vector_float2 structs. Any '.reverse.flatten(1)' should have happened before this. | def make_vectors_pointer(vectors)
ptr = Pointer.new("{_vector_float2=ff}", vectors.length)
vectors.each_with_index { |e, i| ptr[i] = e }
ptr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vector_to(point2)\n end",
"def collect2_nz(v) # :yield: e1, e2\n SparseVector.Raise ErrDimensionMismatch if size != v.size\n return to_enum(:collect2_nz, v) unless block_given?\n\n keys = (nz_indicies + v.nz_indicies).uniq.sort\n\n array = Array.new(size)\n keys.each do |i|\n array[i] ... | [
"0.6178068",
"0.5648154",
"0.55999124",
"0.5586077",
"0.5541371",
"0.5520465",
"0.54914016",
"0.5405273",
"0.53660285",
"0.5364582",
"0.5348552",
"0.52741116",
"0.52650267",
"0.52391523",
"0.5203407",
"0.5200533",
"0.51712644",
"0.51626045",
"0.51559025",
"0.51461333",
"0.512... | 0.6017994 | 1 |
Expects 3d arrays (pairs in rows in an outer array) with the row holding the top vertices first. | def make_warp_grid(from_vertices, to_vertices)
columns = from_vertices[0].length - 1
rows = from_vertices.length - 1
src_ptr = make_vectors_pointer(from_vertices.reverse.flatten(1))
dest_ptr = make_vectors_pointer(to_vertices.reverse.flatten(1))
SKWarpGeometryGrid.gridWithColumns(columns,
rows: rows,
sourcePositions: src_ptr,
destPositions: dest_ptr)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_with_irregular_array3D2; show([[[0,0,0]],\n [[0,0,0],[1,1,1]]]) end",
"def test_with_irregular_array3D1; show([[[0,0,0],[1,1,1]],\n [[0,0,0]]]) end",
"def test_with_irregular_array3D3; show([[[0,1]]]) end",
"def my_tra... | [
"0.61519563",
"0.6074987",
"0.5825666",
"0.5715672",
"0.5669898",
"0.5598071",
"0.55589974",
"0.5431991",
"0.5424274",
"0.5399526",
"0.5314088",
"0.53087264",
"0.5274375",
"0.52604663",
"0.5253725",
"0.5246253",
"0.5245925",
"0.52454954",
"0.5244353",
"0.5242495",
"0.52278334... | 0.0 | -1 |
Layout to print the data in this model This defines the sections that are to be printed and the content and layout of those sections | def print_layout # rubocop:disable Metrics/MethodLength
[{ code: :linked_transactions, # section code
divider: false, # should we have a section divider
display_title: false, # Is the title to be displayed
type: :list, # type list = the list of attributes to follow
list_items: [{ code: :return_reference,
key_scope: %i[returns lbtt_transactions linked_transactions] },
{ code: :consideration_amount, format: :money, when: :convey, is: [true],
key_scope: %i[returns lbtt_transactions linked_transactions] },
{ code: :npv_inc, format: :money, when: :convey, is: [false],
key_scope: %i[returns lbtt_transactions linked_transactions] },
{ code: :premium_inc, format: :money, when: :convey, is: [false],
key_scope: %i[returns lbtt_transactions linked_transactions] }] }]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_layout # rubocop:disable Metrics/MethodLength\n [{ code: :property_details, # section code\n divider: true, # should we have a section divider\n key: :title, # key for the title translation\n key_scope: %i[returns lbtt_properties about_the_property], # scope for the t... | [
"0.7614065",
"0.7467545",
"0.7424805",
"0.69326437",
"0.68641543",
"0.6693271",
"0.65571624",
"0.6512766",
"0.6479622",
"0.63259614",
"0.6243063",
"0.62375367",
"0.6233803",
"0.61367524",
"0.6130812",
"0.60877204",
"0.6065702",
"0.6000994",
"0.59604686",
"0.59424686",
"0.5896... | 0.7387932 | 3 |
Use callbacks to share common setup or constraints between actions. | def set_order
@order = Order.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 trusted parameter "white list" through. | def order_params
params.require(:order).permit(:title, :content, :car_id, :client_id, :worker_id, :finished_at, :created_at, :mileage, :status)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
Features of a show for recommendations based on previous shows | def features
hash = {}
hash['price_range'] = [(our_price_range_low / 100).floor,
(our_price_range_high / 100).floor]
hash['locality'] = venue.locality
hash['category'] = categories
return hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n #Suficiente con el set_training en el before_action\n end",
"def show\n #without IP_adress\n impressionist(@featured)\n set_meta_tags title: @featured.f_title,\n # site: 'Aveneu71::감성 큐레이팅 Shop',\n revierse: true,\n description: @featured... | [
"0.61190414",
"0.57995456",
"0.5783959",
"0.56888914",
"0.5660531",
"0.56298655",
"0.56231225",
"0.5594242",
"0.55921024",
"0.55741346",
"0.5562704",
"0.55312604",
"0.5527862",
"0.55088115",
"0.54803044",
"0.5477453",
"0.5463395",
"0.5441361",
"0.542327",
"0.5417002",
"0.5391... | 0.0 | -1 |
returns formated string of prices specified by whose | def price_format(whose)
#Helper method
def cent_string(cents)
cents = cents.to_i
if cents == 0
return "Free"
elsif cents == -1
return "Sold Out"
end
output = (cents % 100).to_s
if output.length != 2
output += '0'
end
output = "$" + (cents / 100).floor.to_s + "." + output
return output
end
if whose == 'full'
low = cent_string(full_price_range_low)
high = cent_string(full_price_range_high)
else
low = cent_string(our_price_range_low)
high = cent_string(our_price_range_high)
end
output = low
if high != low
output = "#{output} - #{high}"
end
return output
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def price_as_string()\n return \"$%0.2f\" %[@price]\n end",
"def price_string\n\n money = self.price || 0\n copper = money % 100\n amount = (money - copper) / 100\n silver = amount % 100\n gold = (amount - silver) / 100\n\n parts = []\n parts << \"#{number_with_delimiter(gold.to_i)}g\" i... | [
"0.68436956",
"0.683054",
"0.6577819",
"0.65541667",
"0.6527031",
"0.6507601",
"0.64947116",
"0.6481269",
"0.6470955",
"0.6450138",
"0.6394507",
"0.6392333",
"0.63611925",
"0.6357367",
"0.6301693",
"0.62865824",
"0.62732744",
"0.6268818",
"0.62309206",
"0.6221784",
"0.6218495... | 0.7204551 | 0 |
returns a string from the first to last date for this show | def date_string
times = []
showtimes.all.each do |time|
times << time.date_time
end
times = times.sort
first_date = times.first.to_date.strftime('%m/%d')
last_date = times.last.to_date.strftime('%m/%d')
output = first_date
if last_date != first_date
output += " - " + last_date
end
return output
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n return last_day if start_date == end_date\n \n format = ELEMENTS\n format = format.chomp(' %Y') if start_date.year == end_date.year\n format = format.chomp(' %b') if start_date.month == end_date.month\n first_day = start_date.strftime(format)\n first_day + ' - ' + last_day\n end",
... | [
"0.7012307",
"0.685821",
"0.66053814",
"0.6576306",
"0.6380346",
"0.63704044",
"0.6366503",
"0.63662314",
"0.6275553",
"0.6258564",
"0.62433296",
"0.621168",
"0.6211231",
"0.61867195",
"0.614361",
"0.6114647",
"0.61015487",
"0.6090968",
"0.6084228",
"0.6081731",
"0.6063809",
... | 0.7932527 | 0 |
These values should influence the signature but not appear in the url | def defaulted_populated_params
default_params = { "secret" => Authsig.house_secret }.merge(defaults.params)
default_params.merge(populated_params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signature_base_string\n \"#{method.to_s.upcase}&#{full_uri}&#{normalise_signature_params}\"\n end",
"def stored_signature; end",
"def signature_key; end",
"def previous_signature?; end",
"def signature\n # FIXME merb keeps mangling this by replacing \"+\" with \"\\s\" \n ... | [
"0.6543095",
"0.6511577",
"0.650887",
"0.6432868",
"0.64062583",
"0.6391432",
"0.6391432",
"0.6387034",
"0.6387034",
"0.63362336",
"0.63256717",
"0.6295297",
"0.62690544",
"0.62674737",
"0.6247307",
"0.6223335",
"0.6219724",
"0.6207382",
"0.6163583",
"0.6161374",
"0.61479694"... | 0.0 | -1 |
.freeze SEQUEL5 DATA_TYPE.each_value(&:freeze) SEQUEL5 | def initialize(row)
@row = row
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def freeze_data!\n @data = @data.to_smash(:freeze).freeze\n end",
"def freeze\n dataset_module.freeze\n overridable_methods_module.freeze\n\n @finder_loaders.freeze # SEQUEL5: Remove\n\n if @dataset\n @dataset.freeze\n @instance_dataset.freeze\n ... | [
"0.63500977",
"0.620381",
"0.6059409",
"0.59360325",
"0.5889822",
"0.57258123",
"0.56847435",
"0.5631569",
"0.5631569",
"0.562912",
"0.55323696",
"0.5436527",
"0.537906",
"0.5361349",
"0.5354873",
"0.53330714",
"0.5298675",
"0.5294695",
"0.524058",
"0.5230397",
"0.5226551",
... | 0.0 | -1 |
Remove cached schema after altering a table, since otherwise it can be cached incorrectly in the rename column case. | def alter_table(name, *)
super
remove_cached_schema(name)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_cached_schema(table)\n k = quote_schema_table(table)\n Sequel.synchronize{@indexes.delete(k)}\n super\n end",
"def remove_cached_schema(table)\n tab = quote_schema_table(table)\n Sequel.synchronize do\n @primary_keys.delete(tab)\n @primary_key_sequence... | [
"0.7668888",
"0.7593437",
"0.7430946",
"0.7402773",
"0.69651884",
"0.6945798",
"0.69312614",
"0.68813044",
"0.6787911",
"0.67783326",
"0.6587358",
"0.63941276",
"0.63376623",
"0.63376623",
"0.63034916",
"0.6229779",
"0.6209497",
"0.6186364",
"0.6180512",
"0.6167993",
"0.60935... | 0.8523531 | 0 |
Access doesn't let you disconnect if inside a transaction, so try rolling back an existing transaction first. | def disconnect_connection(conn)
conn.RollbackTrans rescue nil
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rollback_db_transaction() end",
"def rollback_db_transaction() end",
"def rollback_db_transaction\n execute(\"ROLLBACK\")\n end",
"def rollback_db_transaction\n execute(\"ROLLBACK\")\n end",
"def rollback_db_transaction\n log('rollback transaction', nil) { @conn... | [
"0.7489606",
"0.7489606",
"0.7067758",
"0.7067758",
"0.6893323",
"0.6873586",
"0.68284047",
"0.67704284",
"0.67425406",
"0.67425406",
"0.67293215",
"0.67293215",
"0.67293215",
"0.67293215",
"0.67293215",
"0.6720507",
"0.6720507",
"0.6719374",
"0.67073363",
"0.6700157",
"0.668... | 0.75443745 | 0 |
Note OpenSchema returns compound indexes as multiple rows | def indexes(table_name,opts=OPTS)
m = output_identifier_meth
idxs = ado_schema_indexes(table_name).inject({}) do |memo, idx|
unless idx["PRIMARY_KEY"]
index = memo[m.call(idx["INDEX_NAME"])] ||= {
:columns=>[], :unique=>idx["UNIQUE"]
}
index[:columns] << m.call(idx["COLUMN_NAME"])
end
memo
end
idxs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indexes(table_name, name = nil) #:nodoc:\n schemas = schema_search_path.split(/,/).map { |p| quote(p) }.join(',')\n result = query(<<-SQL, name)\nSELECT i.relname, d.indisunique, a.attname\nFROM pg_class t, pg_class i, pg_index d, pg_attribute a, pg_namespace n\nWHERE i.relkind = 'i'\nAND d.index... | [
"0.6846706",
"0.68076766",
"0.66504264",
"0.6617386",
"0.65966886",
"0.65752584",
"0.65749776",
"0.652114",
"0.65024364",
"0.6495913",
"0.6415207",
"0.6322772",
"0.6312266",
"0.62569696",
"0.6247105",
"0.6233158",
"0.61949277",
"0.6190948",
"0.61562115",
"0.6149003",
"0.61490... | 0.6290566 | 13 |
Note OpenSchema returns compound foreign key relationships as multiple rows | def foreign_key_list(table, opts=OPTS)
m = output_identifier_meth
fks = ado_schema_foreign_keys(table).inject({}) do |memo, fk|
name = m.call(fk['FK_NAME'])
specs = memo[name] ||= {
:columns => [],
:table => m.call(fk['PK_TABLE_NAME']),
:key => [],
:deferrable => fk['DEFERRABILITY'],
:name => name,
:on_delete => fk['DELETE_RULE'],
:on_update => fk['UPDATE_RULE']
}
specs[:columns] << m.call(fk['FK_COLUMN_NAME'])
specs[:key] << m.call(fk['PK_COLUMN_NAME'])
memo
end
fks.values
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect_foreign_key_references(metadata, foreign_keys, row)\n schema = metadata.tableSchema\n\n # Add row as foreignKey source\n Array(schema ? schema.foreignKeys : []).each do |fk|\n colRef = Array(fk['columnReference'])\n\n # Referenced cells, in order\n cells = colRef.map... | [
"0.64272726",
"0.5998624",
"0.59364897",
"0.5914102",
"0.5889213",
"0.58664507",
"0.58257246",
"0.58031744",
"0.58018017",
"0.57821023",
"0.5749767",
"0.5747611",
"0.57124394",
"0.57124394",
"0.5681692",
"0.5672603",
"0.56388295",
"0.56318605",
"0.56144416",
"0.5612803",
"0.5... | 0.563596 | 17 |
Emulate rename_column by adding the column, copying data from the old column, and dropping the old column. | def alter_table_sql(table, op)
case op[:op]
when :rename_column
unless sch = op[:schema]
raise(Error, "can't find existing schema entry for #{op[:name]}") unless sch = op[:schema] || schema(table).find{|c| c.first == op[:name]}
sch = sch.last
end
[
alter_table_sql(table, :op=>:add_column, :name=>op[:new_name], :default=>sch[:ruby_default], :type=>sch[:db_type], :null=>sch[:allow_null]),
from(table).update_sql(op[:new_name]=>op[:name]),
alter_table_sql(table, :op=>:drop_column, :name=>op[:name])
]
when :set_column_null, :set_column_default
raise(Error, "can't find existing schema entry for #{op[:name]}") unless sch = op[:schema] || schema(table).find{|c| c.first == op[:name]}
sch = sch.last
sch = if op[:op] == :set_column_null
sch.merge(:allow_null=>op[:null])
else
sch.merge(:ruby_default=>op[:default])
end
[
alter_table_sql(table, :op=>:rename_column, :name=>op[:name], :new_name=>:sequel_access_backup_column, :schema=>sch),
alter_table_sql(table, :op=>:rename_column, :new_name=>op[:name], :name=>:sequel_access_backup_column, :schema=>sch)
]
else
super
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rename_column(table_name, column_name, new_column_name) #:nodoc:\n clear_cache!\n execute \"ALTER TABLE #{quote_table_name(table_name)} RENAME COLUMN #{quote_column_name(column_name)} TO #{quote_column_name(new_column_name)}\"\n end",
"def rename_column(table_name, column_name, new_c... | [
"0.7480561",
"0.74374586",
"0.7427472",
"0.7373873",
"0.7269542",
"0.71505076",
"0.7108095",
"0.7108095",
"0.709661",
"0.70788157",
"0.70338196",
"0.70045024",
"0.69418436",
"0.68759567",
"0.6820348",
"0.6820348",
"0.64653647",
"0.64653647",
"0.640283",
"0.6326338",
"0.623535... | 0.0 | -1 |
This is like execute() in that it yields an ADO RecordSet, except instead of an SQL interface there's this OpenSchema call cf. | def execute_open_ado_schema(type, criteria=[])
ado_schema = AdoSchema.new(type, criteria)
synchronize(opts[:server]) do |conn|
begin
r = log_connection_yield("OpenSchema #{type.inspect}, #{criteria.inspect}", conn) {
if ado_schema.criteria.empty?
conn.OpenSchema(ado_schema.type)
else
conn.OpenSchema(ado_schema.type, ado_schema.criteria)
end
}
yield(r) if block_given?
rescue ::WIN32OLERuntimeError => e
raise_error(e)
end
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query(sql)\r\n\t\trecordset = WIN32OLE.new('ADODB.Recordset')\r\n\t\trecordset.Open(sql, @connection)\r\n\t\t@fields = []\r\n\t\trecordset.Fields.each do |field|\r\n\t\t\t@fields << field.Name\r\n\t\tend\r\n\r\n\t\tbegin\r\n\t\t\t# Transpose to have array of rows\r\n\t\t\t@data = recordset.GetRows.transpose\r\... | [
"0.631602",
"0.61491966",
"0.61454666",
"0.6143857",
"0.6102319",
"0.60999084",
"0.6083727",
"0.6016388",
"0.5927323",
"0.59190047",
"0.59048426",
"0.58057064",
"0.5765645",
"0.5730282",
"0.5706597",
"0.57065946",
"0.5689044",
"0.5686395",
"0.56756634",
"0.56136715",
"0.56124... | 0.614728 | 2 |
count one list's todos | def test_outstanding_count_list__list_exists
count = outstanding_count_list(@lists, "Personal")
assert_equal(2, count)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def todos_count(list)\n list[:todos].size\n end",
"def todos_count\n todos.count\n end",
"def todos_remaining(list)\n list[:todos].count { |todo| !todo[:complete] }\n end",
"def count\n\t\t\t\tlist.count\n\t\t\tend",
"def total_task_lists_count\n task_lists.count\n end",
"def todo_counts(... | [
"0.8828862",
"0.828179",
"0.72488964",
"0.7116027",
"0.70401585",
"0.6991933",
"0.6827437",
"0.6716428",
"0.6562856",
"0.6517037",
"0.6444789",
"0.64442414",
"0.6383711",
"0.635924",
"0.635326",
"0.62788945",
"0.6264049",
"0.62607",
"0.62581414",
"0.62265265",
"0.6205066",
... | 0.5814622 | 45 |
count all lists' todos | def test_outstanding_count_global
count = outstanding_count_global(@lists)
assert_equal(4, count)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def todos_count(list)\n list[:todos].size\n end",
"def todos_count\n todos.count\n end",
"def total_task_lists_count\n task_lists.count\n end",
"def todos_remaining(list)\n list[:todos].count { |todo| !todo[:complete] }\n end",
"def todo_counts(list, mode)\n mode ?\n \"#{list[:todos... | [
"0.8600423",
"0.81493586",
"0.7336759",
"0.7112294",
"0.6994756",
"0.68657786",
"0.68069124",
"0.6575727",
"0.6510797",
"0.64736927",
"0.64157635",
"0.63869613",
"0.6375059",
"0.6352071",
"0.63223803",
"0.63150156",
"0.63056445",
"0.6208176",
"0.61869353",
"0.6156944",
"0.615... | 0.56108874 | 72 |
return oustanding todos in a list | def test_outstanding_todos_list
todos = outstanding_todos_list(@lists, "CodeClan")
assert_equal( Array, todos.class)
assert_equal( 1, todos.count)
todos = outstanding_todos_list(@lists, "Personal")
assert_equal( Array, todos.class)
assert_equal( 2, todos.count)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def todos\n remaining_todos + completed_todos\n end",
"def index\n\t\t@list = current_user.lists.find(params[:list_id])\n @todos = @list.todos\n end",
"def my_todos\r\n\t\t\t\t\tself.authored_todos | self.assigned_todos\r\n\t\t\t\tend",
"def index\n @todos = @list.todos.all\n end",
"def tod... | [
"0.7321689",
"0.70994216",
"0.69190943",
"0.6877518",
"0.67753696",
"0.67566794",
"0.66939366",
"0.6657261",
"0.6625384",
"0.6608304",
"0.6561006",
"0.6546901",
"0.65435076",
"0.65141284",
"0.6467574",
"0.637237",
"0.6355847",
"0.6329099",
"0.6327982",
"0.63049656",
"0.627641... | 0.64906514 | 14 |
return all outstanding todos | def test_outstanding_todos_global
todos = outstanding_todos_global(@lists)
assert_equal( Array, todos.class)
assert_equal( 3, todos.count)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def todos\n remaining_todos + completed_todos\n end",
"def all_available_todos\n (global_available_todos + local_available_todos).uniq\n end",
"def all_todos\n (global_todos.where(language: I18n.locale).to_a.delete_if{ |gt| local_todos.map(&:title).include?(gt.title) } + local_todos)\n... | [
"0.77517986",
"0.7262846",
"0.6999832",
"0.69751734",
"0.69564414",
"0.6838853",
"0.6795067",
"0.67091715",
"0.6627633",
"0.65406847",
"0.65116185",
"0.64945906",
"0.64366317",
"0.6432232",
"0.6426397",
"0.64226353",
"0.64136934",
"0.63500476",
"0.630561",
"0.6279806",
"0.626... | 0.60122585 | 42 |
Locks the cache to prevent further modification | def lock
@locked = true
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lock!; end",
"def lock; end",
"def lock; end",
"def lock; end",
"def lock\n end",
"def update_cache\n Rails.logger.debug \"Updating cache for... #{@@cache_file}\"\n fp = File.new(@@cache_file, 'w')\n if fp\n # acquire an exclusive lock (writer)\n if fp.floc... | [
"0.7291443",
"0.7272932",
"0.7272932",
"0.7272932",
"0.7136675",
"0.7037374",
"0.7014543",
"0.69967353",
"0.6964176",
"0.69128704",
"0.69036496",
"0.6902791",
"0.6876395",
"0.682763",
"0.681953",
"0.681953",
"0.681953",
"0.681953",
"0.681953",
"0.681953",
"0.681953",
"0.680... | 0.67986214 | 22 |
Is the cache locked? | def locked?
@locked
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locked?\n end",
"def is_locked?\n locked\n end",
"def locked?\n @mutex.locked?\n end",
"def access_locked?\n !!locked_at && !lock_expired?\n end",
"def cache?\n caching && true\n end",
"def locked?(obj)\n RedisMutexer.config.redis.exists(key(obj))\n end",
"d... | [
"0.79227924",
"0.7774619",
"0.7717192",
"0.7693617",
"0.76391876",
"0.76097095",
"0.7555248",
"0.7550194",
"0.7526112",
"0.75028235",
"0.7497256",
"0.7491735",
"0.74798906",
"0.746563",
"0.7414039",
"0.7410467",
"0.7374576",
"0.73509854",
"0.7326745",
"0.7318903",
"0.7308855"... | 0.74665654 | 15 |
Clears all entries in the cache | def clear
return if check_locked
@entries.clear
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_cache\n @all = nil\n end",
"def clear\n @cache.clear\n entries.clear\n self\n end",
"def clear\n cache.clear\n end",
"def clear_all!\n @cache = Cache.new\n end",
"def clear\n @cache.clear\n end",
"def clear!\n @cache = {}\n end",
"def clea... | [
"0.86471695",
"0.85894954",
"0.8572298",
"0.8536581",
"0.8520986",
"0.8429863",
"0.83912176",
"0.83724606",
"0.8347009",
"0.83200073",
"0.83193386",
"0.82721066",
"0.82721066",
"0.8247825",
"0.8214191",
"0.8082804",
"0.7995058",
"0.7973338",
"0.7958852",
"0.7925329",
"0.78411... | 0.7493525 | 39 |
Yields each key value pair in the cache | def each_pair(&block)
@entries.each_pair(&block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each\n store.each { |(key, value)| yield key, value }\n end",
"def each\n @internal_hash.each { |k,_| yield k }\n end",
"def cache\n yield\n end",
"def each\n pos = hash_size\n hoff0 = @hashes[0]\n while pos < hoff0\n key, value = *read_entry(pos)\n ... | [
"0.72458535",
"0.7001266",
"0.69676954",
"0.6950771",
"0.69102937",
"0.6869243",
"0.6837932",
"0.68155557",
"0.6807438",
"0.6789981",
"0.67683434",
"0.6761879",
"0.6674241",
"0.66686",
"0.6624651",
"0.66223735",
"0.6572121",
"0.65534616",
"0.65422153",
"0.6537206",
"0.6526497... | 0.5826762 | 88 |
similar solution time: O(n) space: O(n) | def rotate(s1, s2)
return false if s1.length != s2.length
s1.length.times do |i|
if s1 == s2
return true
else
s1 = s1[1..-1] + s1[0]
end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\... | [
"0.7002391",
"0.6970467",
"0.6667135",
"0.66625416",
"0.6449699",
"0.64200324",
"0.6419295",
"0.6395345",
"0.6390226",
"0.638819",
"0.6379092",
"0.63774204",
"0.63774204",
"0.63725483",
"0.6363486",
"0.63613987",
"0.63546365",
"0.6350561",
"0.6329683",
"0.63118243",
"0.630224... | 0.0 | -1 |
Create a new MDI child window | def createTestWindow(x, y, w, h)
mdichild = FXMDIChild.new(@mdiclient, "Child", @mdiicon, @mdimenu,
0, x, y, w, h)
scrollwindow = FXScrollWindow.new(mdichild, 0)
scrollwindow.verticalScrollBar.setLine(@font.fontHeight)
btn = FXButton.new(scrollwindow, TYGER, nil, nil, 0,
LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT, 0, 0, 600, 1000)
btn.font = @font
btn.backColor = FXColor::White
mdichild
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createWindow\r\n \r\n end",
"def create_details_window\n x = @items_window.right_corner\n y = @items_window.y\n width = Graphics.width / 2\n height = Graphics.height - y\n @details_window = Window_ItemInfo.new(x, y, width, height)\n @items_window.info_window = @details_window\n end",
... | [
"0.62848437",
"0.625486",
"0.6239166",
"0.61830044",
"0.6078029",
"0.60749435",
"0.6045461",
"0.59826154",
"0.5977747",
"0.5961269",
"0.590643",
"0.5819099",
"0.5813773",
"0.5795749",
"0.57928663",
"0.5766198",
"0.57619125",
"0.5746789",
"0.57424307",
"0.5719007",
"0.56869864... | 0.73614293 | 0 |
Sets the current invitation in the session from the invitation fixtures. | def login_as_survey_invitation(invitation)
@request.session[:external_survey_invitation_id] = invitation ? invitation.object_id : nil
controller.stub!(:requires_login).and_return(true)
controller.stub!(:requires_login_or_survey_invitation).and_return(true)
controller.stub!(:current_survey_invitation).and_return(invitation)
controller.stub!(:current_organization_or_survey_invitation).and_return(invitation)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_invitation\n @invitation = Invitation.find_by(id: params[:id])\n end",
"def set_invitation\n @invitation = Invitation.find(params[:id])\n end",
"def set_invitation\n @invitation = Invitation.find(params[:id])\n end",
"def set_invitation\n @invitation = Invitation.find... | [
"0.73757344",
"0.7366813",
"0.7366813",
"0.7366813",
"0.7366813",
"0.7366813",
"0.7366813",
"0.7366813",
"0.7366813",
"0.7366813",
"0.7366813",
"0.7366813",
"0.7366813",
"0.7366813",
"0.7366813",
"0.7366813",
"0.7366813",
"0.7366813",
"0.7216008",
"0.71888304",
"0.71052253",
... | 0.6173335 | 48 |
Logs in as the specified entity, depending on the type. | def login_as(entity)
if entity.is_a?(Organization)
login_as_organization(entity)
elsif entity.is_a?(Association)
login_as_association(entity)
else
login_as_survey_invitation(entity)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n ret = super\n sign_in(resource.type.underscore, resource.type.constantize.send(:find, resource.id)) unless resource.type.nil?\n ret\n end",
"def login\n redirect_to(root_url) && return if logged_in?\n @user = User.new params[:user]\n if meth = params[:type]\n usr = @user.send... | [
"0.6031237",
"0.599312",
"0.5958953",
"0.5957027",
"0.5942018",
"0.5942018",
"0.5855086",
"0.58072615",
"0.5795096",
"0.57680666",
"0.5746826",
"0.5657225",
"0.564689",
"0.5630769",
"0.56289953",
"0.5626851",
"0.56156176",
"0.5581909",
"0.5562917",
"0.5562686",
"0.5562234",
... | 0.71450335 | 0 |
binary search on a sorted array returns index | def search_index(arr, target, left = 0, right = arr.length - 1)
return -1 if left > right # -1 means no found
half = (left + right) / 2
case target <=> arr[half]
when 0
half
when -1
search_index(arr, target, left, half - 1)
when 1
search_index(arr, target, half + 1, right)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binary_search(ary, value); end",
"def binary_search(array, key)\n low, high = 0, array.length - 1\n while low <= high\n mid = (low + high) >> 1\n case key <=> array[mid] # if key < array[mid] then return -1 if key = array[mid] then 0 else return 1\n\t when 1\n low = mid + 1\n ... | [
"0.83255583",
"0.8310246",
"0.81538296",
"0.8150904",
"0.81479573",
"0.81343293",
"0.81290424",
"0.8099964",
"0.8052815",
"0.80485356",
"0.7996238",
"0.7943295",
"0.79141843",
"0.7902846",
"0.7901359",
"0.78783",
"0.7856081",
"0.78279674",
"0.7822902",
"0.781747",
"0.78150004... | 0.0 | -1 |
binary search on a sorted array returns true/false | def search_bool(arr, target)
return false if arr.empty?
half = arr.length / 2
return true if arr[half] == target
if target < arr[half]
search_bool(arr[0...half], target)
else
search_bool(arr[(half + 1)...arr.length], target)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binary_search(key,array)\n\tlow = 0\n\thigh = array.sort.length - 1\n\treturn -1 if low>high\n\tmid = (low+high)/2\n\treturn mid if array[mid]==key\n\t\tif array[mid]>key\n\t\t\thigh=mid-1\n\t\t\tmid=(low+high)/2\n\t\telse\n\t\t\tlow=mid+1\n\t\t\tmid=(low+high)/2\n\t\tend\nend",
"def binary_search(array, key... | [
"0.7896241",
"0.7844755",
"0.78106475",
"0.7752079",
"0.7714464",
"0.7709328",
"0.7691007",
"0.76820195",
"0.76586664",
"0.7641854",
"0.7636891",
"0.76336795",
"0.7630892",
"0.75744385",
"0.75722635",
"0.7564349",
"0.756265",
"0.7553666",
"0.7552347",
"0.7551111",
"0.75192183... | 0.70034504 | 91 |
I worked on this challenge [by myself]. Your Solution Below | def array_concat(array_1, array_2)
array_2.each {|x| array_1.push(x).to_a}
return array_1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution4(input)\n end",
"def challenge; end",
"def isLucky(n)\r\nhalf1 = []\r\nhalf2 = []\r\nn_string = n.to_s\r\n\r\n\r\nfirsthalf = (n_string.length / 2) - 1\r\nsecondhalfstart = (n_string.length / 2)\r\nsecondhalfend = (n_string.length - 1)\r\n(0..firsthalf).each do |idx|\r\n half1 << n_string[idx]... | [
"0.6521425",
"0.6285902",
"0.61204535",
"0.60482454",
"0.6030281",
"0.5995338",
"0.5991868",
"0.598491",
"0.5907525",
"0.59036726",
"0.58979195",
"0.5895741",
"0.5893064",
"0.5880777",
"0.58719397",
"0.5861705",
"0.5861557",
"0.5859783",
"0.58570546",
"0.5854972",
"0.5850453"... | 0.0 | -1 |
If the record wasn't changed, we need to reset the changed_attributes. If there were previous changes, then reset the changes to the last ones. Otherwise, just delete that empty key/value from the hash. | def reset_changes_if_unchanged(record, name, previous)
if record.versioned_changes.empty?
name = name.to_s
if previous
__compat_set_attribute_was(name, previous)
else
__compat_clear_attribute_changes(name)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_changes!\n remove_instance_variable(:@original_hash) if defined?(@original_hash)\n end",
"def clear_changes\n versioned_columns.each do |key|\n changed_attributes.delete(key)\n end\n end",
"def clear_changes\n @previously_changed = changes\n @... | [
"0.7338497",
"0.73237073",
"0.7295997",
"0.7208904",
"0.71859",
"0.71283275",
"0.70887965",
"0.70680034",
"0.6950611",
"0.6832286",
"0.67345",
"0.67144084",
"0.6699097",
"0.6630523",
"0.65792143",
"0.6432332",
"0.6432332",
"0.6396074",
"0.63711697",
"0.62403363",
"0.62353027"... | 0.6273906 | 19 |
This is just a proxy to association_will_change! the before/after_add/remove callbacks pass an object, but we don't need it, so this method accepts and throws away that argument. | def prepare_to_change_association(object)
name = association_name(object)
send("#{name}_will_change!")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def association_changed?(associtaion_name) # :nodoc:\n raise 'Not implemented!'\n end",
"def association_changed(record)\n\t\ttouch if persisted?\n\tend",
"def after_update\n super\n touch_associations\n end",
"def _set_associated_object(opts, o)\n a = associations[opts[... | [
"0.6520753",
"0.6517236",
"0.6304115",
"0.6240942",
"0.60850537",
"0.60280937",
"0.59605587",
"0.58846486",
"0.587568",
"0.58042824",
"0.57579875",
"0.5748366",
"0.5721353",
"0.5720091",
"0.5719939",
"0.56948245",
"0.5691306",
"0.5674713",
"0.5663828",
"0.5611563",
"0.5603097... | 0.7511887 | 0 |
Essentially, rearrange the digits to create the highest possible number. Examples : Input: 21445 Output: 54421 Input: 145263 Output: 654321 Input: 1254859723 Output: 9875543221 | def descending_order(n)
n.to_s.split("").sort.reverse.join("").to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_number(n)\nn = n.to_s\narr = []\n n.length.times do |i|\n arr << n[i].to_i\n end\narr.sort!.reverse!\nstr= \"\"\narr.each do |i| str = str + \"#{i}\"\nend\nstr.to_i\nend",
"def maxNumber(num)\n \n num.digits.sort {|a,b| b <=> a}.join.to_i\n \nend",
"def solution(digits)\n\tstop = digits.length... | [
"0.7449216",
"0.74449223",
"0.7431454",
"0.7386949",
"0.7337433",
"0.7336711",
"0.72921956",
"0.72798383",
"0.7225382",
"0.72086287",
"0.71965706",
"0.7174346",
"0.71591824",
"0.71423405",
"0.71230596",
"0.71161306",
"0.7104659",
"0.7096248",
"0.70788866",
"0.70740426",
"0.70... | 0.0 | -1 |
goodcard.double goodcard.sum true_test = goodcard.check_card 4. Convert your driver test code from that challenge into Assert Statements | def assert
raise "Assertion failed!" unless yield
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_card\n\t\tsplit_cc = @cc.to_s.split(\"\")\n\n# -- Convert string to an array of integers\n\t\t\tl = split_cc.length - 1\n\t\tfor num in 0..l\n\t\t\t@split_cc_integers << split_cc[num].to_i\n\t\tend\n\n# -- Now we split the original array of integers into two arrays of even indices and odd indices \n\t\tl... | [
"0.6963475",
"0.6928107",
"0.687314",
"0.6801077",
"0.6739713",
"0.6737503",
"0.6730182",
"0.67293596",
"0.6658856",
"0.6651955",
"0.66210604",
"0.6596115",
"0.6596001",
"0.65895134",
"0.653387",
"0.6526517",
"0.6520338",
"0.6495968",
"0.6485439",
"0.6473241",
"0.6467181",
... | 0.0 | -1 |
goodcard.double goodcard.sum true_test = goodcard.check_card 4. Convert your driver test code from that challenge into Assert Statements | def assert
raise "Assertion failed!" unless yield
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_card\n\t\tsplit_cc = @cc.to_s.split(\"\")\n\n# -- Convert string to an array of integers\n\t\t\tl = split_cc.length - 1\n\t\tfor num in 0..l\n\t\t\t@split_cc_integers << split_cc[num].to_i\n\t\tend\n\n# -- Now we split the original array of integers into two arrays of even indices and odd indices \n\t\tl... | [
"0.6964629",
"0.6929484",
"0.68730795",
"0.68006295",
"0.67393386",
"0.67368823",
"0.673063",
"0.6729627",
"0.66592634",
"0.6653268",
"0.66199315",
"0.65960693",
"0.6595753",
"0.6589201",
"0.65340936",
"0.6526652",
"0.65205073",
"0.6496236",
"0.6485072",
"0.64731914",
"0.6467... | 0.0 | -1 |
GET /family_units/1 GET /family_units/1.json | def show
@family_unit = FamilyUnit.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @family_unit }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def foods_units\n get('/foods/units.json')\n end",
"def show\n @unit_of_measure = UnitOfMeasure.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit_of_measure }\n end\n end",
"def show\n @family = get_family(params[:id])\n... | [
"0.78296226",
"0.67436814",
"0.67195284",
"0.65898985",
"0.64310414",
"0.64310414",
"0.64310414",
"0.6389442",
"0.63727367",
"0.63597876",
"0.6304374",
"0.62947696",
"0.62920827",
"0.62779224",
"0.62126726",
"0.621033",
"0.6199294",
"0.6166236",
"0.6127918",
"0.6066309",
"0.6... | 0.7518632 | 1 |
GET /family_units/new GET /family_units/new.json | def new
@family_unit = FamilyUnit.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @family_unit }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @family = Family.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @family }\n end\n end",
"def create\n @family_unit = FamilyUnit.new(params[:family_unit])\n\n respond_to do |format|\n if @family_unit.save\n format.html { red... | [
"0.74923354",
"0.7472652",
"0.7313679",
"0.7313679",
"0.7313679",
"0.73000383",
"0.70406616",
"0.70406616",
"0.69959635",
"0.6984613",
"0.6984556",
"0.69816715",
"0.69496274",
"0.6927082",
"0.6923024",
"0.69032",
"0.6881852",
"0.6853153",
"0.6843869",
"0.6813281",
"0.6809398"... | 0.81684715 | 0 |
POST /family_units POST /family_units.json | def create
@family_unit = FamilyUnit.new(params[:family_unit])
respond_to do |format|
if @family_unit.save
format.html { redirect_to @family_unit, notice: 'Family unit was successfully created.' }
format.json { render json: @family_unit, status: :created, location: @family_unit }
else
format.html { render action: "new" }
format.json { render json: @family_unit.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def foods_units\n get('/foods/units.json')\n end",
"def new\n @family_unit = FamilyUnit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @family_unit }\n end\n end",
"def create\n @unit_of_measure = UnitOfMeasure.new(params[:unit_of_measure... | [
"0.64520127",
"0.6175709",
"0.5971847",
"0.5966968",
"0.5821121",
"0.5794448",
"0.5784129",
"0.57637364",
"0.5763136",
"0.57624465",
"0.5762333",
"0.5758429",
"0.57549196",
"0.57549196",
"0.5731729",
"0.5708506",
"0.5695827",
"0.56924623",
"0.5678475",
"0.56573856",
"0.563138... | 0.7109877 | 0 |
PUT /family_units/1 PUT /family_units/1.json | def update
@family_unit = FamilyUnit.find(params[:id])
respond_to do |format|
if @family_unit.update_attributes(params[:family_unit])
format.html { redirect_to @family_unit, notice: 'Family unit was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @family_unit.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n params.require(%i[id units])\n retrieve_and_validate_put.update!(units: params[:units])\n head :no_content\n end",
"def update\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n query = {\n 'name' => params[:name]\n }\n response = HTTParty.put(url, :query... | [
"0.71424454",
"0.6598723",
"0.6279849",
"0.6260263",
"0.6185675",
"0.61786544",
"0.6173698",
"0.6155059",
"0.6153631",
"0.6150954",
"0.61462545",
"0.6131897",
"0.61063653",
"0.6101945",
"0.6078503",
"0.60670006",
"0.60608196",
"0.60371065",
"0.5999531",
"0.5981803",
"0.595963... | 0.7186251 | 0 |
DELETE /family_units/1 DELETE /family_units/1.json | def destroy
@family_unit = FamilyUnit.find(params[:id])
@family_unit.destroy
respond_to do |format|
format.html { redirect_to family_units_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n response = HTTParty.delete(url, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n redirect_to units_url, notice: 'Unit was successfully deleted.'\n end",
"def destroy\n @base_unit.destroy\n respond_to do ... | [
"0.71656835",
"0.71531093",
"0.70731795",
"0.70688736",
"0.70205104",
"0.6997632",
"0.69913244",
"0.6972924",
"0.6972924",
"0.6972924",
"0.6972924",
"0.69693536",
"0.69513476",
"0.6939074",
"0.69262284",
"0.6901609",
"0.6895119",
"0.6881044",
"0.6855988",
"0.6850053",
"0.6829... | 0.7612234 | 0 |
GET /file_systems GET /file_systems.json | def index
if current_user.rol.admin_doc
@file_systems = FileSystem.where(level: 0, folder_id: 0).search(params[:search])
else
@file_systems = Rol.find(current_user.rol.id).file_systems.where(level: 0, folder_id: 0).search(params[:search])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @drive_system = DriveSystem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @drive_system }\n end\n end",
"def get_firmware_files\n response = request(:get, \"/devmgr/v2/firmware/cfw-files/\")\n status(response, ... | [
"0.6321181",
"0.6290178",
"0.612036",
"0.61009353",
"0.6097938",
"0.60844165",
"0.60494536",
"0.602994",
"0.59527075",
"0.5942315",
"0.5895834",
"0.5883496",
"0.5876866",
"0.586764",
"0.58510435",
"0.5805547",
"0.57974005",
"0.5772047",
"0.57532203",
"0.5722718",
"0.5676323",... | 0.53818315 | 54 |
GET /file_systems/1 GET /file_systems/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @drive_system = DriveSystem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @drive_system }\n end\n end",
"def show\n @system = System.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ... | [
"0.6497286",
"0.6236252",
"0.6221437",
"0.614115",
"0.6098523",
"0.6077964",
"0.6052133",
"0.6028602",
"0.6019524",
"0.60060626",
"0.597785",
"0.5919837",
"0.59155804",
"0.59098953",
"0.59094346",
"0.5907348",
"0.5901311",
"0.5826159",
"0.5822143",
"0.57738155",
"0.57683706",... | 0.0 | -1 |
POST /file_systems POST /file_systems.json | def create
@file_system = FileSystem.new(file_system_params)
respond_to do |format|
if @file_system.save
if @file_system.level == 0
@file_system.route = 0
@file_system.save
else
@file = FileSystem.find(@file_system.folder_id).route
@file_system.route = @file + "," + @file_system.folder_id
@file_system.save
end
format.html { redirect_to (@file_system.level == 0 ? file_systems_path : sub_folder_path(@file_system.level, @file_system.folder_id)) , notice: 'File system was successfully created.'
}
format.json { render :show, status: :created, location: @file_system }
else
format.html { render :new }
format.json { render json: @file_system.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_system_params\n params.require(:file_system).permit(:name, :type_file, :file, :level, :folder_id, :user_id, :code, :route,:rol_ids => [])\n end",
"def create\n @system = System.new(params[:system])\n\n respond_to do |format|\n if @system.save\n format.html { redirect_to @system... | [
"0.5987678",
"0.58597505",
"0.58160627",
"0.58151037",
"0.5796012",
"0.5785208",
"0.5762309",
"0.569269",
"0.56546456",
"0.5641979",
"0.5613225",
"0.5598376",
"0.5596973",
"0.55842257",
"0.5573809",
"0.55690944",
"0.5567501",
"0.5529997",
"0.5521306",
"0.5517305",
"0.55038613... | 0.6343362 | 0 |
PATCH/PUT /file_systems/1 PATCH/PUT /file_systems/1.json | def update
respond_to do |format|
if @file_system.update(file_system_params)
format.html { redirect_to (@file_system.level == 0 ? file_systems_path : sub_folder_path(@file_system.level, @file_system.folder_id)) , notice: 'File system was successfully created.'
}
format.json { render :show, status: :ok, location: @file_system }
else
format.html { render :edit }
format.json { render json: @file_system.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(path = '/files/', params = {})\n request :put, path, params\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\... | [
"0.6262875",
"0.6165582",
"0.6135055",
"0.61183333",
"0.6088902",
"0.6023985",
"0.5953877",
"0.59049416",
"0.58992964",
"0.58938825",
"0.58873117",
"0.58704823",
"0.5853685",
"0.5822295",
"0.581453",
"0.580963",
"0.58034474",
"0.57701296",
"0.57475835",
"0.5733851",
"0.572528... | 0.61369354 | 2 |
DELETE /file_systems/1 DELETE /file_systems/1.json | def destroy
@fs = @file_system.level
@fs1 = @file_system.folder_id
@fs2 = FileSystem.where("level > ?" , @file_system.level)
@fs2.each do |i|
@array = []
@array = i.route.split(",").map { |s| s.to_i }
if @array.include?(@file_system.id)
FileSystem.find(i.id).destroy
end
end
puts FileSystem.where()
@file_system.destroy
respond_to do |format|
format.html { redirect_to (@file_system.level == 0 ? file_systems_path : sub_folder_path(@fs, @fs1)) , notice: 'File system was successfully created.'
}
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end",
"def b2_delete_file(file)\n\n if parse_fi... | [
"0.6852718",
"0.6824364",
"0.6801786",
"0.67452234",
"0.6720529",
"0.67184734",
"0.6702349",
"0.6698557",
"0.6687074",
"0.6678581",
"0.6670246",
"0.6665519",
"0.6662795",
"0.66552716",
"0.66477746",
"0.66430503",
"0.6625674",
"0.66195536",
"0.66134393",
"0.66134393",
"0.66125... | 0.6537364 | 28 |
Use callbacks to share common setup or constraints between actions. | def set_file_system
@file_system = FileSystem.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 file_system_params
params.require(:file_system).permit(:name, :type_file, :file, :level, :folder_id, :user_id, :code, :route,:rol_ids => [])
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.6980244",
"0.6782812",
"0.6745103",
"0.6741142",
"0.6733961",
"0.65925",
"0.6503602",
"0.64967257",
"0.64822173",
"0.64796996",
"0.6456357",
"0.6439594",
"0.63803256",
"0.6376499",
"0.63644457",
"0.6319286",
"0.6299465",
"0.6298051",
"0.62935406",
"0.62923044",
"0.6291212"... | 0.0 | -1 |
Generate and send json to server from hash | def send_hash(cmd_hash)
json = JSON.generate(cmd_hash)
send_json()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_json(hash)\n data = MultiJson.dump(hash)\n send(data)\n end",
"def recieve_hash\n\t\t#recvd_json = params[:q_data]\n\t\t#p recvd_json\n\n\tend",
"def set_hash_and_json\n @hash = {header: @header, payload: @payload, signature: encode(@signature)}\n @json = \"#{@... | [
"0.6699092",
"0.6376683",
"0.6312932",
"0.62043",
"0.61915076",
"0.61744183",
"0.6105809",
"0.6102344",
"0.60018116",
"0.5997841",
"0.5970724",
"0.5965241",
"0.5891366",
"0.58816785",
"0.5835066",
"0.5810519",
"0.5805097",
"0.5805097",
"0.5805097",
"0.57988673",
"0.57988673",... | 0.78228724 | 0 |
uses regex to clear out everything but the brackets and proceeds to check whether or not they close by using the symmetric reverse method i added to the string class | def check_closed(string)
str = string.gsub(/[^(\[<{}>\])]/,"")
print str == str.reverse_brackets
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nested(s)\n return true if s.empty?\n return false if s.length.odd?\n \n return false if s[0] != \"(\" || s[-1] != \")\"\n return nested(s[1...-1])\n # To do this without creating new strings, make a helper method\n # that accepts additional parameters for left_char and right_char and increments\n # th... | [
"0.69062483",
"0.6492718",
"0.6266372",
"0.625138",
"0.620224",
"0.62006325",
"0.61943334",
"0.61699784",
"0.6117957",
"0.6054503",
"0.6031009",
"0.6002921",
"0.5978043",
"0.59472203",
"0.59268963",
"0.59013605",
"0.5898726",
"0.5898101",
"0.58895874",
"0.58869296",
"0.588076... | 0.8043026 | 0 |
a mod 2^n if 0 <= a < 2^2n | def reduce_2n1(a, n)
b = a >> n
a = a & ((1 << n) - 1)
r = a - b
if r < 0
return r + (1 << n) + 1
end
return r
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve(a,b,n)\n (b*a.inverse_modulo(n)) % n\nend",
"def raiseToModulus a, b, n\n b < 0 and raise ArgumentError, \"negative exponent\"\n prod = 1\n a %= n\n until b.zero? do\n if b.odd?\n prod = (prod * a) % n\n end\n b /= 2\n a = (a ** 2) % n\n end\n pro... | [
"0.75711244",
"0.7298231",
"0.7298231",
"0.72650987",
"0.7254355",
"0.71595454",
"0.7142973",
"0.71175605",
"0.7095687",
"0.6997426",
"0.6964675",
"0.6915325",
"0.6896372",
"0.68487895",
"0.6810505",
"0.68084383",
"0.676747",
"0.6759148",
"0.67241335",
"0.6716361",
"0.6675775... | 0.0 | -1 |
Computes ary[0] + ary[1] 2^ik ... ary[size1] 2^((size1)ik) mod 2^n + 1 | def fft_array(ary, k, n)
size = ary.size
if (size & (-size)) != size
raise Exception.new("ary.size = #{size} is not power of 2")
end
output = Array.new(size)
fft_array_sub(ary, k, 0, 1, size, output, 0, n)
return output
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def power(arr_in)\n\treturn nil if arr_in.length != 2\n\ttotal = 1\n\tarr_in.last.times { total*= arr_in.first }\n\ttotal\nend",
"def index_multiplier_method\n #@multiplied_integer_array = []\n @reversed_array.each_with_index do |value, index|\n if index.odd? == true\n value = value * 2\n ... | [
"0.6318522",
"0.6223565",
"0.60831994",
"0.60761964",
"0.60564715",
"0.60010326",
"0.6000225",
"0.59909666",
"0.5954656",
"0.59441423",
"0.5934223",
"0.5929906",
"0.5898147",
"0.5866702",
"0.5834307",
"0.5832028",
"0.5831304",
"0.5829042",
"0.5828033",
"0.58220714",
"0.580310... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.