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 |
|---|---|---|---|---|---|---|
Use callbacks to share common setup or constraints between actions. | def set_unit_name
@unit_name = UnitName.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.6163754",
"0.6045816",
"0.5944853",
"0.59169096",
"0.58892167",
"0.58342934",
"0.5776148",
"0.57057375",
"0.57057375",
"0.56534296",
"0.56209534",
"0.54244673",
"0.54101455",
"0.54101455",
"0.54101455",
"0.53951085",
"0.5378493",
"0.53563684",
"0.53399915",
"0.5338049",
"0... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def unit_name_params
params.require(:unit_name).permit(:title, :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.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
a simple identifier without any versions, shouldn't be happening but it did on dev at least | def simple_identifier
{
id: @se_identifier.to_s,
message: 'identifier is missing required elements'
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def identifier; end",
"def identifier; end",
"def identifier_string\n name\n end",
"def full_name\n \"#{@name}-#{@version}\"\n end",
"def identifier\n \"#{self.namespace}/#{self.name}/#{self.snapshot}\"\n end",
"def identifier_string\n change_loggable.identifier_string rescue \"unknown\"\n... | [
"0.68797547",
"0.68797547",
"0.68373096",
"0.670752",
"0.66705436",
"0.6601058",
"0.65929085",
"0.6557423",
"0.6542205",
"0.6539154",
"0.65359277",
"0.6466991",
"0.6427045",
"0.63946944",
"0.639028",
"0.6388087",
"0.6388034",
"0.63838774",
"0.6368083",
"0.6368083",
"0.6344633... | 0.6045566 | 69 |
initialize variables and login | def initialize(username, password)
@agent = Mechanize.new
@valid_credentials = false
login(username, password)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize login\n self.login = login\n end",
"def initialize\n login = self.read_login_data\n @base_url = login['base_url']\n @user = login['user']\n @password = login['password']\n end",
"def login; end",
"def initialize\n @email_fld = {\"selector\" => :id, \"value\"=>\"emai... | [
"0.75879675",
"0.73520005",
"0.7310575",
"0.73061347",
"0.7299539",
"0.7146027",
"0.71435785",
"0.71425515",
"0.70975554",
"0.70666975",
"0.704505",
"0.7021752",
"0.69717443",
"0.69683754",
"0.69683754",
"0.69554585",
"0.69554585",
"0.69554585",
"0.69554585",
"0.69554585",
"0... | 0.0 | -1 |
Returns this month's trips. | def trips
@agent.get(TRIPS_URL)
# If session expires, re-login to citibikenyc.com. The site will redirect
# back to TRIPS_URL upon sign in (friendly forwarding)
login unless @agent.page.title == TRIPS_PAGE_TITLE
rows = Nokogiri::HTML(@agent.page.body).xpath('//table/tbody/tr')
# Reject bike... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trips\n trips = RideShare::Trip.trips_by_rider(@id)\n if trips != nil\n return trips\n else\n return []\n end\n end",
"def trips\n RideShare::Trip.find_all_for_rider(@id)\n end",
"def trips\n #will find upcoming trips/reservations for guests\n Res... | [
"0.69189566",
"0.69006765",
"0.6895926",
"0.68097997",
"0.6691936",
"0.66352564",
"0.66352564",
"0.66109204",
"0.6586651",
"0.6560952",
"0.6545969",
"0.6538493",
"0.65105414",
"0.6395644",
"0.6394784",
"0.6382854",
"0.632458",
"0.6215873",
"0.6213103",
"0.62118495",
"0.616854... | 0.58302486 | 28 |
Handle Citi Bike Website errors (e.x. Net::HTTPGatewayTimeOut) | def handle_error(error)
puts error.message
puts error.backtrace.join("\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_request_error(exception)\n end",
"def foreign_server_failure\n [ 503, {'Content-Type'=>'text/plain', 'Content-Length' => '23'},\n ['Foreign server failure.'] ]\n end",
"def robots_error(url); end",
"def handle_timeout\n err = \"No response from server: Timed out connecting... | [
"0.6500486",
"0.63781667",
"0.63343525",
"0.62978685",
"0.62947756",
"0.62911177",
"0.62911177",
"0.6243438",
"0.62027544",
"0.6190236",
"0.6156642",
"0.61504865",
"0.61418396",
"0.61281496",
"0.6126618",
"0.6110575",
"0.6109126",
"0.6101787",
"0.6083247",
"0.6081489",
"0.604... | 0.0 | -1 |
Convert HTML row into bike trip object | def row_to_trip(row)
trip = BikeTrip.new
trip_attributes = [:id, :start_location, :start_time, :end_location,
:end_time, :duration]
trip_attributes.each_with_index do |name, i|
trip.send("#{name}=", row.at_xpath("td[#{i + 1}]/text()").to_s.strip)
end
trip
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_row(row)\n cells = row.css('td')\n return nil if cells.nil?\n\n {\n \"volfdnr\" => extract_id(cells[0]),\n \"title\" => extract_text(cells[1]),\n \"presenter\" => extract_text(cells[3]),\n \"date\" => extract_text(cells[4]),\n \"type\" => extrac... | [
"0.6801548",
"0.6246424",
"0.6245239",
"0.6144672",
"0.61423165",
"0.6115157",
"0.58650935",
"0.57374907",
"0.5728098",
"0.5695871",
"0.5654466",
"0.56407607",
"0.55358595",
"0.55282396",
"0.55040777",
"0.5480128",
"0.54789174",
"0.5437178",
"0.5426308",
"0.5424181",
"0.54009... | 0.73356086 | 0 |
Make sure PNG sizes are determined correctly | def test_png_size_determined_correctly
assert_equal [120, 175], @page.get_png_size(@test_png)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_print_image_mask_size\n return if print_image_mask.blank?\n expect_width = (width / 25.4 * dpi).to_i\n expect_height = (height / 25.4 * dpi).to_i\n # FIXME: private API may broken in the future, but we really need it at this time\n actual_width, actual_height = print_image_mask.send(:get_d... | [
"0.6926651",
"0.66242486",
"0.65571195",
"0.655197",
"0.65366405",
"0.65335613",
"0.65187526",
"0.6511275",
"0.64375556",
"0.6408634",
"0.64060473",
"0.63689834",
"0.6362681",
"0.6345834",
"0.63226247",
"0.6310308",
"0.6310134",
"0.6298702",
"0.6196962",
"0.6194033",
"0.61641... | 0.7976059 | 0 |
Make sure legacy browsers are detected as such | def test_legacy_browser_detected
for browser in LEGACY_BROWSERS
@request.user_agent = browser
assert @page.legacy_browser?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def legacy_browser?\n request.user_agent =~ /MSIE\\s+(5\\.5|6\\.)/\n end",
"def browser_detection(http)\n if http.match(/MSIE 6|MSIE 7|MSIE 8.0/)\n content_tag(:div, \"For an optimal Tenon experience, please upgrade Internet Explorer to the #{link_to 'latest version', 'http://browsehappy.com/', t... | [
"0.7801116",
"0.69019973",
"0.68695",
"0.6815902",
"0.66904664",
"0.66765916",
"0.65428",
"0.6523734",
"0.64322937",
"0.6385321",
"0.6287144",
"0.6201563",
"0.61194617",
"0.6064128",
"0.60615784",
"0.60522646",
"0.6040523",
"0.5990378",
"0.59861577",
"0.5950873",
"0.5950873",... | 0.7419266 | 1 |
Make sure current browsers are detected as such | def test_current_browsers_detected
for browser in CURRENT_BROWSERS
@request.user_agent = browser
assert ! @page.legacy_browser?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def legacy_browser?\n request.user_agent =~ /MSIE\\s+(5\\.5|6\\.)/\n end",
"def good_browser?(agent = /Firefox|Safari|Chrome/)\n request.env['HTTP_USER_AGENT'] =~ agent\n end",
"def test_legacy_browser_detected\n for browser in LEGACY_BROWSERS\n @request.user_agent = browser\n assert @page... | [
"0.73392105",
"0.72671396",
"0.7221515",
"0.70728123",
"0.7061558",
"0.7013827",
"0.6956995",
"0.68868095",
"0.68029034",
"0.6788495",
"0.6735375",
"0.67222834",
"0.6720817",
"0.67121613",
"0.6580098",
"0.65686184",
"0.6547474",
"0.6485492",
"0.6460467",
"0.6422459",
"0.63967... | 0.78221273 | 0 |
Make sure that the images are replaced by DIVs on legacy browsers | def test_on_legacy_browsers
for legacy_browser in LEGACY_BROWSERS
@request.user_agent = legacy_browser
get :index
assert_response :success
assert_select 'div[style*=filter:progid:DXImageTransform.Microsoft.AlphaImageLoader]'
assert_select 'div[style*=height:175px]'
assert_select ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_manipulations(html_doc)\n html_doc.css('img').each do |img|\n # prepare image for lazy loading\n unless img['src'] == LOADING_IMAGE_GIF\n src = UrlNormalizer.normalize_entry_url img['src'], self\n img['src'] = LOADING_IMAGE_GIF\n img['data-src'] = src\n end\n end... | [
"0.608633",
"0.6034981",
"0.6034981",
"0.5961867",
"0.5793322",
"0.5708332",
"0.56825674",
"0.5606634",
"0.5575844",
"0.55656284",
"0.553688",
"0.5511767",
"0.5471668",
"0.5454639",
"0.5414888",
"0.5405968",
"0.53958476",
"0.5384579",
"0.5378159",
"0.536553",
"0.5351082",
"... | 0.5021376 | 53 |
Make sure the images are left untouched on current browsers | def test_on_current_browsers
for current_browser in CURRENT_BROWSERS
@request.user_agent = current_browser
get :index
assert_response :success
assert_select 'img[src*=painless_test.png]'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prune_images\n if self.images.present?\n self.assets.where('id <> ?',self.default_image_id).destroy_all\n end\n end",
"def remove_all_images\n self.cover_image.purge if self.cover_image.attached?\n self.images.each {|image| image.purge} if self.images.attached?\n en... | [
"0.65211594",
"0.62827533",
"0.6226742",
"0.6203548",
"0.60887814",
"0.60636747",
"0.60580075",
"0.6022626",
"0.6003478",
"0.5989532",
"0.5971208",
"0.5964154",
"0.5948861",
"0.5921798",
"0.59003067",
"0.5885584",
"0.5872373",
"0.5822893",
"0.5786865",
"0.57637775",
"0.574750... | 0.0 | -1 |
Make sure it also works when the "source" argument doesn't contain an extension (in which case Rails assumes it's a PNG). TODO: this feature will soon be deprecated in Rails | def test_also_works_without_png_extension
@request.user_agent = CURRENT_BROWSERS[0]
get :index, :src => "painless_test"
assert_response :success
assert_select "img[src*=painless_test.png]"
@request.user_agent = LEGACY_BROWSERS[0]
get :index, :src => "painless_test"
assert_response :succ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path_to_image(source, options = T.unsafe(nil)); end",
"def image_path(source, options = T.unsafe(nil)); end",
"def url_to_image(source, options = T.unsafe(nil)); end",
"def image_url(source, options = T.unsafe(nil)); end",
"def fix_src_url!\n fix_isgd_url!\n end",
"def path_to_image(sourc... | [
"0.73497546",
"0.6933891",
"0.6924788",
"0.68290704",
"0.6544254",
"0.64458853",
"0.6424307",
"0.6315113",
"0.6304269",
"0.62792146",
"0.6256729",
"0.6189494",
"0.60579145",
"0.6004567",
"0.60021776",
"0.6000562",
"0.5997467",
"0.59753",
"0.59753",
"0.5924251",
"0.58893573",
... | 0.0 | -1 |
Make sure nonPNG images remain untouched | def test_non_pngs_unaffacted
for image in %w(test.jpg test.jpeg test.gif test.bmp)
get :index, :src => image
assert_response :success
extension = image.gsub(/^.*\./, '')
assert_select "img[src*=test.#{extension}]"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def optimize_image!(original)\n original = ImagePath.new(original)\n if result = optimize_image(original)\n result.replace(original)\n true\n end\n end",
"def optimize_image!(original)\n original = ImagePath.new(original)\n if result = optimize_image(original)\n result.replace(orig... | [
"0.62188226",
"0.62188226",
"0.6155175",
"0.6148515",
"0.6148515",
"0.61401266",
"0.6133529",
"0.6126906",
"0.6081704",
"0.6081321",
"0.60571593",
"0.604292",
"0.6039256",
"0.5993187",
"0.5970599",
"0.59370244",
"0.59264517",
"0.5923615",
"0.5919417",
"0.59029984",
"0.5856984... | 0.5692409 | 40 |
A adding history record and save method. It accepts a parameter array which is collected any produced after the test completion. | def add_history_and_save(array = [total_score, correct_count, incorrect_count, type, quiz_name, user_name, mode])
if @history.nil?
creat_empty_history
new_history_Id = 1
elsif @history["Records"].empty?
new_history_Id = 1
else
new_history_Id = @history["Records"].map { |h| h['Id'] }.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_history(instance,args)\n invocation = instance.instance_variable_get(\"@_invocations\").to_a[0]\n classes = invocation[0].to_s\n name = invocation[1].first\n classes.gsub!(/Thor::Sandbox::/,\"\")\n classes.gsub!(/::/,\":\")\n classes.downcase!\n options = [args,instance... | [
"0.66080827",
"0.6577078",
"0.6457318",
"0.62957853",
"0.62927765",
"0.61151177",
"0.61056423",
"0.60634255",
"0.60488737",
"0.60334456",
"0.6013292",
"0.5995859",
"0.59507185",
"0.5916312",
"0.58972275",
"0.58949393",
"0.5874532",
"0.5862609",
"0.5862206",
"0.5853798",
"0.58... | 0.75326735 | 0 |
A method to restore enmpty history hash in case user mistakenly delete the history file. Being used in the relevant rescue block. | def creat_empty_history
new_history = {
"Records": []
}
@history = new_history
@history
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore\n return unless File.exist?(Setting[:histfile])\n\n File.readlines(Setting[:histfile]).reverse_each { |l| push(l.chomp) }\n end",
"def clear_history\n while ! Readline::HISTORY.empty? do\n Readline::HISTORY.pop\n end\n end",
"def invalidate_history!\n @hist... | [
"0.6401916",
"0.62128264",
"0.6176995",
"0.6073749",
"0.60626435",
"0.5997504",
"0.5997504",
"0.5985984",
"0.58875245",
"0.5881721",
"0.58767503",
"0.5866713",
"0.5755143",
"0.5707126",
"0.5707126",
"0.5662302",
"0.56337744",
"0.56337744",
"0.55603534",
"0.55603534",
"0.55099... | 0.52938634 | 37 |
Returns a string for the host/service/port/proto/service name combination in the pwdump file. This string is added to make it easier for a human to scan the file. | def format_service_for_login(login)
service = login.service
address = service.host.address.to_s
"#{address}:#{service.port}/#{service.proto} (#{service.name})"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def procfile_entry(service, profile, port = nil)\n name = service.name\n\n port = nil unless profile == 'server'\n\n [\n \"#{[name, profile].join('_')}:\",\n server_name_map[profile.to_sym],\n name,\n service_path(service),\n port\n ].compact.join ' '\n end",
"def ip_output_... | [
"0.63498116",
"0.5840328",
"0.5676481",
"0.55932367",
"0.53783095",
"0.53783095",
"0.53654397",
"0.53539425",
"0.53448504",
"0.5317548",
"0.53162026",
"0.53159267",
"0.52885354",
"0.52737904",
"0.52725214",
"0.5259209",
"0.52305496",
"0.52262646",
"0.52185535",
"0.5187371",
"... | 0.5642102 | 3 |
Returns the count of services in the group creds contained in +hash_array+ | def service_count_for_hashes(hash_array)
hash_array.collect(&:service).collect(&:id).uniq.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_elements(array)\n new_array = []\n\n array.each do |original_array_element|\n\n #now inside the array looking at each indv hash\n \tif new_array.empty?\n\n \t\tfirst_new_element = {name: original_array_element[:name], count: 1}\n \t\tnew_array.push(first_new_element)\n\n \telse\n name_found =... | [
"0.57439494",
"0.55539143",
"0.5543823",
"0.5496586",
"0.5496082",
"0.5487253",
"0.54748833",
"0.54748833",
"0.54577726",
"0.5456076",
"0.5444714",
"0.5394446",
"0.53940386",
"0.53874296",
"0.5360587",
"0.5341891",
"0.5339354",
"0.5336578",
"0.53260857",
"0.5300993",
"0.53003... | 0.8091971 | 0 |
Returns a hash containing the public and private or the canonical blank string | def data_for_login(login)
public = login.core.try(:public)
private = login.core.try(:private)
username = public.present? && public.username.present? ? public.username : BLANK_CRED_STRING
private_data = private.present? && private.data.present? ? private.data : BLANK_CRED_STRING
{
usernam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_key_hash(hex)\n\t\trmd160(sha256(hex))\n\tend",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash\n [anchor, cv, nullifier, proof, rk, spend_auth_sig].hash\n end",
"def create_hash(phrase = ''... | [
"0.6607075",
"0.65272284",
"0.65272284",
"0.65272284",
"0.65272284",
"0.65272284",
"0.65272284",
"0.65272284",
"0.64855194",
"0.6470491",
"0.6372164",
"0.6338893",
"0.63150215",
"0.62834424",
"0.62643945",
"0.6209124",
"0.6187113",
"0.6155134",
"0.61528414",
"0.6149928",
"0.6... | 0.0 | -1 |
determines if user can use system | def active_subscription
if company_exists?
@active_subscription ||= company.subscriptions.active.limit(1).order('ends_at DESC NULLS FIRST, id DESC').first
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_make_leaderbit_active?\n system_admin?\n end",
"def system?\n id == User::SYSTEM_USER_ID\n end",
"def system?\n id == User::SYSTEM_USER_ID\n end",
"def can?\n current_user\n end",
"def givemesystem\n\n # Statusing\n print_status(\"Checking if user is SYSTEM...\")\n\n # ... | [
"0.72769356",
"0.7238202",
"0.7238202",
"0.7238086",
"0.71781516",
"0.7084017",
"0.7080928",
"0.6921468",
"0.69119704",
"0.6884993",
"0.68526846",
"0.6832344",
"0.67865187",
"0.6775372",
"0.6724962",
"0.6717255",
"0.67038333",
"0.6679974",
"0.66635734",
"0.66408587",
"0.66255... | 0.0 | -1 |
determines if user should buy subscription | def active_remote_subscription
if company_exists?
@active_remote_subscription ||= company.subscriptions.active_remote.limit(1).order('ends_at DESC NULLS FIRST, id DESC').first
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_subscribable?\n is_partner_subscription? || is_premium_subscription?\n end",
"def bought?\n # paym\n end",
"def check_subscription\n !subscribed || subscription_present?\n end",
"def subscribed?(user)\n user.subscription.subscribed==true\n end",
"def can_request_purchase?\n true #... | [
"0.76087314",
"0.7585016",
"0.74264634",
"0.7328093",
"0.7300517",
"0.7174942",
"0.70906353",
"0.7044316",
"0.70064014",
"0.69881064",
"0.69544876",
"0.69410497",
"0.69249976",
"0.69058996",
"0.68052375",
"0.67845184",
"0.67664135",
"0.6756188",
"0.67456436",
"0.67384934",
"0... | 0.0 | -1 |
all public methods in here will be run in order | def add_views
output "I'm copying the default views into app/views/gem_displays for you.", :magenta
template "index.html.haml", "app/views/gem_displays/index.html.haml"
template "show.html.haml", "app/views/gem_displays/show.html.haml"
template "_widget.html.haml", "app/views/gem_displays/_widge... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def methods() end",
"def run_all()\n end",
"def run_all\n end",
"def run_all\n end",
"def executor; end",
"def executor; end",
"def executor; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def calls; end",
"def calls; end",
"def runnable_me... | [
"0.70689154",
"0.68238574",
"0.66385156",
"0.66385156",
"0.6575125",
"0.6575125",
"0.6575125",
"0.6571178",
"0.6571178",
"0.6571178",
"0.6571178",
"0.65645474",
"0.65645474",
"0.6535413",
"0.6535413",
"0.6445748",
"0.6445748",
"0.6445748",
"0.6445748",
"0.6445748",
"0.6445748... | 0.0 | -1 |
def authenticated?(remember_token) return false if remember_digest.nil? BCrypt::Password.new(remember_digest).is_password?(remember_token) end | def forget
update_attribute(:remember_digest,nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticated?(remember_token)\n if remember_digest.nil?\n false\n else\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end\n end",
"def authenticated?(remember_token)\n \treturn false if remember_digest.nil?\n BCrypt::Password.new(rememb... | [
"0.9864455",
"0.98347294",
"0.9819954",
"0.9819954",
"0.9819954",
"0.9819954",
"0.9798234",
"0.9792347",
"0.9768671",
"0.9768671",
"0.9768671",
"0.9768671",
"0.9768671",
"0.9768671",
"0.9768671",
"0.9768671",
"0.9768671",
"0.9768671",
"0.9768671",
"0.9768671",
"0.9768671",
... | 0.0 | -1 |
GET /activities GET /activities.json | def index
@activities = Activity.all
@recievers = Reciever.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activities\n get_call(\"1/activities.json\")\n end",
"def activities(params = {})\n scope 'default'\n get('activities/', params)\n end",
"def activity(id)\n get(\"/activities/#{id}.json\")\n end",
"def activity(id)\n get(\"/activities/#{id}.json\")\n end",
"def acti... | [
"0.87229973",
"0.8237991",
"0.8174613",
"0.8174613",
"0.81609166",
"0.8031665",
"0.7980325",
"0.79700005",
"0.795089",
"0.7611846",
"0.7541555",
"0.752615",
"0.7450007",
"0.74256104",
"0.74131006",
"0.7386156",
"0.73540217",
"0.7342527",
"0.7318892",
"0.7318892",
"0.72758335"... | 0.0 | -1 |
GET /activities/1 GET /activities/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activity(id)\n get(\"/activities/#{id}.json\")\n end",
"def activity(id)\n get(\"/activities/#{id}.json\")\n end",
"def activities\n get_call(\"1/activities.json\")\n end",
"def show\n begin\n @activity = PublicActivity::Activity.all.find(params[:id])\n rescue ActiveRec... | [
"0.83790696",
"0.83790696",
"0.8097305",
"0.76851153",
"0.76687473",
"0.76401865",
"0.760863",
"0.75713843",
"0.7532097",
"0.7451491",
"0.74324805",
"0.7332516",
"0.7310655",
"0.7286694",
"0.7285829",
"0.723009",
"0.72059745",
"0.72059745",
"0.71891934",
"0.718362",
"0.705786... | 0.0 | -1 |
POST /activities POST /activities.json | def create
# byebug
@activity = Activity.new(activity_params)
respond_to do |format|
if @activity.save
format.html { redirect_to root_path, notice: 'Activity was successfully created.' }
format.json { render :show, status: :created, location: @activity }
else
format.html... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @activity = @user.activities.create(activity_params)\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: 'Exercise event was successfully created.' }\n format.json { render :show, status: :created, location: @activity }\n else\n ... | [
"0.7249106",
"0.70048165",
"0.6964346",
"0.6956599",
"0.6929332",
"0.69046366",
"0.6889496",
"0.6862793",
"0.68420047",
"0.6838635",
"0.68081975",
"0.68079776",
"0.68079776",
"0.6798919",
"0.677082",
"0.6740217",
"0.67014927",
"0.6675203",
"0.6665923",
"0.6659741",
"0.6649729... | 0.69475126 | 4 |
PATCH/PUT /activities/1 PATCH/PUT /activities/1.json | def update
r = Reciever.where("name == ? ", activity_params[:reciever][:name].upcase)
r.empty? ? @reciever = Reciever.new(name: activity_params[:reciever][:name].upcase) : @reciever = r.first
respond_to do |format|
if @activity.update(activity_params.except(:reciever))
@reciever.save
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n @activity.status = Activity::SETTED if @activity.setting?\n if @activity.update(activity_params)\n format.html { redirect_to activities_url, notice: 'Activity was successfully updated.' }\n format.json { head :no_content }\n else\n format... | [
"0.68846226",
"0.6830872",
"0.68169534",
"0.6812194",
"0.6807588",
"0.6776597",
"0.67556393",
"0.67556393",
"0.67556393",
"0.67556393",
"0.67556393",
"0.6700775",
"0.66643053",
"0.66625977",
"0.66621685",
"0.6638061",
"0.6626543",
"0.6626543",
"0.6626543",
"0.66030794",
"0.65... | 0.63203424 | 42 |
DELETE /activities/1 DELETE /activities/1.json | def destroy
@activity.destroy
respond_to do |format|
format.html { redirect_to activities_url, notice: 'Activity was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @activity.destroy\n respond_to do |format|\n format.html { redirect_to activities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @activity.destroy\n respond_to do |format|\n format.html { redirect_to activities_url }\n format.json { head :n... | [
"0.7712568",
"0.7712568",
"0.7712568",
"0.7712568",
"0.7712568",
"0.76978153",
"0.7688336",
"0.7663404",
"0.7663404",
"0.76458544",
"0.76458544",
"0.7643713",
"0.7564872",
"0.75457203",
"0.745816",
"0.73909366",
"0.73904556",
"0.73481995",
"0.73416245",
"0.7341086",
"0.733206... | 0.73731923 | 22 |
Use callbacks to share common setup or constraints between actions. | def set_activity
@activity = Activity.find(params[:id])
@reciever = Reciever.find(@activity.reciever_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.6163754",
"0.6045816",
"0.5944853",
"0.59169096",
"0.58892167",
"0.58342934",
"0.5776148",
"0.57057375",
"0.57057375",
"0.56534296",
"0.56209534",
"0.54244673",
"0.54101455",
"0.54101455",
"0.54101455",
"0.53951085",
"0.5378493",
"0.53563684",
"0.53399915",
"0.5338049",
"0... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def activity_params
params.require(:activity).permit(:amount, :activity_date, :reciever_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
We replace the initialize methods and run a new method if signing or crypting is required | def initialize_with_sign_and_crypt(method_name, *parameters)
default_settings = {
sign: false,
crypt: false,
p12: nil,
crypt_cert: nil,
crypt_cipher: :des,
crypt_method: :smime,
passphrase: nil,
ca_cert: nil
}
initialize_without_sign_and... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_with_sign_and_crypt(method_name, *parameters)\n mail = initialize_without_sign_and_crypt(method_name, *parameters)\n\n x509_initvar()\n\n # If we need to sign the outgoing mail.\n if should_sign? or should_crypt?\n if logger\n logger.debug(\"actionmailer_x509: We ... | [
"0.69234926",
"0.69234926",
"0.6045965",
"0.5984887",
"0.5984887",
"0.5960743",
"0.59591615",
"0.59533036",
"0.59439045",
"0.59439045",
"0.5942917",
"0.59365636",
"0.5911711",
"0.58782446",
"0.5855317",
"0.58550406",
"0.581664",
"0.581149",
"0.5811318",
"0.5787338",
"0.578336... | 0.65655035 | 2 |
X509 SMIME signing and\or crypting | def x509_smime(mail)
if logger
logger.debug("actionmailer_x509: X509 SMIME signing with p12 #{@x509_settings[:p12]}") if should_sign?
logger.debug("actionmailer_x509: X509 SMIME crypt with cert #{@x509_settings[:crypt_cert]}") if should_crypt?
end
# We should set content_id, otherwise... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x509_smime(mail)\n if logger\n logger.debug(\"actionmailer_x509: X509 SMIME signing with cert #{@x509_cert} and key #{@x509_key}\") if should_sign?\n logger.debug(\"actionmailer_x509: X509 SMIME crypt with cert #{@x509_cert}\") if should_crypt?\n end\n\n # We should set content_id,... | [
"0.7409228",
"0.7396729",
"0.7009637",
"0.6917358",
"0.6859421",
"0.6524546",
"0.6524546",
"0.64920723",
"0.6477787",
"0.64448166",
"0.6403325",
"0.6397338",
"0.6379899",
"0.6371944",
"0.63402367",
"0.63012516",
"0.6254021",
"0.62538236",
"0.6208358",
"0.61730474",
"0.6164377... | 0.73431426 | 2 |
Shall we crypt the mail? | def should_crypt?
crypt = @x509_settings[:crypt] && @x509_settings[:crypt_cert]
logger.info "X509 crypting required, but no certificate file configured" unless crypt
crypt
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crypt(p0) end",
"def crypt_password\n # EmailNotify.send_user_create_notification self\n self[:password] =\n password_hash(password(true))\n @password = nil\n end",
"def test_crypted\n mail = Notifier.fufu_crypted(\"<destination@foobar.com>\", \"<demo@foobar.com>\")\n\n assert_equal ... | [
"0.6549864",
"0.6521118",
"0.6451112",
"0.62915385",
"0.6233332",
"0.6213978",
"0.6157464",
"0.6049771",
"0.6049243",
"0.60307467",
"0.60195994",
"0.59971434",
"0.5966467",
"0.59448195",
"0.5938277",
"0.58414835",
"0.5779629",
"0.57744056",
"0.5766191",
"0.5763315",
"0.575638... | 0.0 | -1 |
Hacks to support dynamic_model helpers | def to_model
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model; eval model_name; end",
"def model; eval model_name; end",
"def dynamic_model_class_name\n dynamic_model.implementation_class.name\n end",
"def dynamic_model(no_check: nil)\n return @dynamic_model if @dynamic_model\n\n schema_name, table_name = schema_and_table_name\n name = ... | [
"0.675851",
"0.675851",
"0.6627716",
"0.65990233",
"0.6542843",
"0.65426034",
"0.6532487",
"0.6431843",
"0.6320189",
"0.6282848",
"0.6282848",
"0.6282848",
"0.6282848",
"0.6260637",
"0.6240182",
"0.6240182",
"0.6240182",
"0.6240182",
"0.6240182",
"0.6240182",
"0.6240182",
"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_pokemon
@pokemon = Pokemon.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def pokemon_params
params.require(:pokemon).permit(:nome, :tipo, :sprint, :time_treinador_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
my application to the Ada Developers Academy I wanted to create a simulation of an AI not strictly a chat bot (I'm working on that, too), but something more controlled and well, scripted. | def listen()
STDIN.gets.chomp().downcase.gsub(/[^a-z\s]/, '')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mechanic_quest; end",
"def play_game\n\n $world.look\n while true\n print \"> \"\n $stdout.flush\n line = random_input\n puts \"#{line}\"\n\n args = line.split(' ')\n verb = args.first\n begin\n $world.__send__(verb.intern, *args[1..-1])\n rescue NoMethodError\n puts \"I d... | [
"0.66604686",
"0.6277541",
"0.62137204",
"0.61190057",
"0.60844713",
"0.60844713",
"0.6044971",
"0.6027189",
"0.59858704",
"0.5949857",
"0.59434",
"0.5919672",
"0.58557534",
"0.5831176",
"0.5818611",
"0.58122134",
"0.5810728",
"0.5810173",
"0.57733667",
"0.56965584",
"0.56949... | 0.0 | -1 |
Initialize a fulltext search index backend for JMdict | def initialize(path)
@dictionary_path = path
@index_path = File.dirname(@dictionary_path)
@pos_hash = {}
raise "No dictionary found at path #{@dictionary_path}" unless File.exists? @dictionary_path
@db_file = File.join(@index_path, "jdict.db")
initialize_db(@db_file)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_index\n @search = RSemantic::Search.new(@documents.map(&:text), @options)\n end",
"def initialize( opts={} )\n @@index_list = false unless defined?(@@index_list)\n if opts[:index_full_text] == true || opts[:index_full_text] == \"true\"\n @index_full_text = true \n else\n ... | [
"0.71521705",
"0.69740075",
"0.67971814",
"0.6485804",
"0.64281183",
"0.6426092",
"0.63641244",
"0.63447094",
"0.62986183",
"0.6276232",
"0.62158465",
"0.61826706",
"0.6158746",
"0.6059481",
"0.5962637",
"0.5948644",
"0.5934047",
"0.5913885",
"0.5899474",
"0.5899474",
"0.5886... | 0.0 | -1 |
Builds the fulltext search index | def build_index!(&block)
entries_added = do_build_index(&block) unless built?
#make the hash from abbreviated parts of speech to full definitions
@pos_hash ||= build_pos_hash
entries_added
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_index\n @search = RSemantic::Search.new(@documents.map(&:text), @options)\n end",
"def create_search_index\n Tire.index self.index_name\n end",
"def create_search_index\n #Notice the assoction on article.user.id\n TaggyMcFaggy.create_index :attribute_namespace => :article_text,\... | [
"0.83534974",
"0.71807355",
"0.7115932",
"0.6955458",
"0.69554496",
"0.69387776",
"0.6915822",
"0.68462026",
"0.6790756",
"0.6740862",
"0.666906",
"0.65721995",
"0.6482218",
"0.6471176",
"0.6470753",
"0.6470753",
"0.6458415",
"0.64003146",
"0.6391237",
"0.63846815",
"0.637666... | 0.70670277 | 3 |
Returns the search results as an array of +Entry+ | def search(term, opts = {})
raise "Index not found at path #{@index_path}" unless File.exists? @index_path
results = []
query = make_query(term, opts[:exact])
@index.execute("SELECT sequence_number, kanji, kana, senses, bm25(search) as score FROM search WHERE search MATCH ? LIMIT ?", query, o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entries\n return Array(@entries)\n end",
"def results\n numOfSearches = numEvents / @OFFSET #the number of searches we must make to return all values\n result = Array.new\n if (complete?)\n for i in 0..numOfSearches\n result.push( @client.get_request(\"/... | [
"0.7116394",
"0.68464947",
"0.68463135",
"0.67676854",
"0.6731072",
"0.6502844",
"0.64591473",
"0.6420351",
"0.6385514",
"0.63842964",
"0.63753784",
"0.63673764",
"0.6324371",
"0.6295658",
"0.6295658",
"0.6295658",
"0.6295658",
"0.6274125",
"0.62677383",
"0.62593645",
"0.6235... | 0.0 | -1 |
Retrieves the definition of a partofspeech from its abbreviation | def get_pos(pos)
build_pos_hash if @pos_hash.empty?
@pos_hash[pos_to_sym(pos)]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup(word)\r\n @word.each do |h|\r\n if h[:Word] == word.to_s\r\n return h[:Definition]\r\n end\r\n end\r\n end",
"def part_of_speech\n\t\treturn self.class.postype_table[ self.pos.to_sym ]\n\tend",
"def part_of_speech\n _response_word.fetch(\"pa... | [
"0.6063171",
"0.5924599",
"0.5856334",
"0.57205725",
"0.56751055",
"0.5663624",
"0.5561791",
"0.5542464",
"0.55181545",
"0.54764545",
"0.54410946",
"0.5436167",
"0.543377",
"0.5432892",
"0.5410671",
"0.54030454",
"0.5400326",
"0.5337099",
"0.5337099",
"0.5337099",
"0.5337099"... | 0.0 | -1 |
Creates the SQL schema for the Amalgalite database | def create_schema
schema = @index.schema
unless schema.tables['search']
@index.execute_batch <<-SQL
CREATE VIRTUAL TABLE search USING fts5(
sequence_number,
kanji,
kana,
senses
);
SQL
@index.reload_schema!
end
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_database_schema!\n \n if file_format.class.const_defined?('Database')\n @orm_module = file_format.class.const_get('Database')\n else\n @orm_module = file_format.class.const_set('Database', Module.new)\n end\n\n create_request_table_and_class\n create_warning_t... | [
"0.7708239",
"0.7416898",
"0.74102443",
"0.7409586",
"0.7318679",
"0.72739625",
"0.7187762",
"0.71644855",
"0.71599644",
"0.7144732",
"0.7115746",
"0.7081195",
"0.7059599",
"0.7042345",
"0.70349973",
"0.70188195",
"0.69005543",
"0.68558764",
"0.6842233",
"0.68048096",
"0.6786... | 0.6199753 | 57 |
Creates the hash of partofspeech symbols to full definitions from the dictionary | def build_pos_hash
indexer = NokogiriDictionaryIndexer.new @dictionary_path
indexer.parse_parts_of_speech
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n @symbols.hash + 37*positive?.hash\n end",
"def symbols_first_pass\n symbol_defs = {}\n @data.each do |address, byte|\n next unless byte.is_a? Hash\n symbol = byte.keys.first\n value = byte.values.first\n # Store the symbol and its address for the second pa... | [
"0.6571856",
"0.6471056",
"0.6284209",
"0.61668086",
"0.6149683",
"0.6063833",
"0.5950357",
"0.59287435",
"0.59287435",
"0.5891695",
"0.5873056",
"0.58644617",
"0.58565265",
"0.5849184",
"0.5824083",
"0.5824083",
"0.5824083",
"0.5824083",
"0.5824083",
"0.5824083",
"0.5824083"... | 0.5881083 | 10 |
Converts a partofspeech entity reference string into a symbol | def pos_to_sym(entity)
entity.gsub('-', '_').to_sym
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_symbol(str)\n case str\n when /'/\n \":'\" + str.to_s.gsub(\"'\"){ \"\\\\'\" } + \"'\"\n else\n ':' + str.to_s\n end\n end",
"def asm_symbol(s)\n sa = Word[s]\n return sa if !sa.nil?\n a = ['']\n s.each_char do |c|\n g = Graph[c]\n if g.nil?\n a[-1] << c... | [
"0.5848621",
"0.5833803",
"0.5807401",
"0.5751249",
"0.5666169",
"0.5612419",
"0.55595934",
"0.5550899",
"0.5509468",
"0.549357",
"0.54894185",
"0.54894185",
"0.5474345",
"0.5471836",
"0.54269224",
"0.5425649",
"0.54220366",
"0.5394074",
"0.53916156",
"0.5388434",
"0.5360268"... | 0.6335127 | 0 |
Space: no hash > O(1) Time: n comparisons, n lookups, n comparisons, n deletions > O(n^2) "Sliding window" approach | def remove_duplicates(nums)
return 0 if nums.length == 0
write = 0
read = 1
while read < nums.length
if nums[write] != nums[read]
write += 1
nums[write] = nums[read]
end
read += 1
end
write + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lazy_index(index)\n index -= @map.keys.select{|e| e < index}.size\n result = 0\n @deleted.each do |deleted_index|\n if deleted_index - result > index\n return result + index\n else\n index -= deleted_index - result\n result = deleted_index + 1\n en... | [
"0.60971403",
"0.60217613",
"0.5672413",
"0.55818343",
"0.5558222",
"0.55540407",
"0.5523893",
"0.54734755",
"0.5469442",
"0.5466916",
"0.5461019",
"0.5453899",
"0.5432506",
"0.5428281",
"0.54045945",
"0.5393907",
"0.5393907",
"0.5383741",
"0.53651",
"0.53149056",
"0.5307059"... | 0.0 | -1 |
Build a schema class name from the given +statement_name+. | def schema_name_for(statement_name)
unless statement_name =~ STATEMENT_NAME_REGEXP
raise ArgumentError, "statement '#{statement_name}' name must match #{STATEMENT_NAME_REGEXP.inspect}"
end
const_name = statement_name.to_s
if const_name == "schema"
"#{self.name}::Schema"
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classify(table_name)\n # strip out any leading schema name\n camelize(singularize(table_name.to_s.sub(/.*\\./, '')))\n end",
"def classify(table_name)\n # strip out any leading schema name\n camelize(singularize(table_name.to_s.sub(/.*\\./, '')))\n end",
"def classify(table_name)\... | [
"0.59264535",
"0.59264535",
"0.59243894",
"0.5860139",
"0.5758299",
"0.56544316",
"0.55759555",
"0.55724096",
"0.5532478",
"0.5523593",
"0.5516271",
"0.5500571",
"0.54511464",
"0.5429724",
"0.54251254",
"0.5335376",
"0.5335376",
"0.5271354",
"0.52661103",
"0.5262008",
"0.5255... | 0.799323 | 0 |
Test whether a schema is defined for the given +statement_name+. | def schema_defined_for?(statement_name)
!!schema_for(statement_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schema_exists?(name)\n select_value(\"SELECT COUNT(*) FROM pg_namespace WHERE nspname = '#{name}'\", 'SCHEMA').to_i > 0\n end",
"def schema_exists?(name)\n select_value(\"SELECT COUNT(*) FROM pg_namespace WHERE nspname = '#{name}'\", 'SCHEMA').to_i > 0\n end",
"def table_exists?(nam... | [
"0.74983025",
"0.7447625",
"0.6754343",
"0.6582494",
"0.6571959",
"0.64115703",
"0.63260335",
"0.61181873",
"0.60917443",
"0.60052013",
"0.60031086",
"0.5922754",
"0.58887744",
"0.5878384",
"0.58615524",
"0.582661",
"0.5824963",
"0.5771697",
"0.57526827",
"0.57150275",
"0.570... | 0.88603115 | 0 |
Turn the given string (assuming it is a constraint name) into a validator class name string. | def validator_name_for(constraint_name)
"#{self.name}::#{constraint_name.to_s.camelize}Validator"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validator_for(constraint_name)\n validator_name_for(constraint_name).safe_constantize\n end",
"def validate_class_name(name)\n only_basic_type(name) || name.gsub(/-/, \"_\").camelcase\n end",
"def variable_name_to_class_name(name)\n name.to_s.\n gsub(/\\/(.?)/) { \"::#{$1.upcase}\... | [
"0.7320014",
"0.64953375",
"0.6222377",
"0.6222377",
"0.5970231",
"0.5917286",
"0.5815122",
"0.57857156",
"0.57291675",
"0.57082146",
"0.57051307",
"0.56908566",
"0.56597894",
"0.56570804",
"0.56326294",
"0.56123346",
"0.56123346",
"0.5609353",
"0.5609353",
"0.5587551",
"0.55... | 0.70227677 | 1 |
Turn the given +constraint_name+ into a validator class symbol. Return +nil+ if the validator class does not exist. | def validator_for(constraint_name)
validator_name_for(constraint_name).safe_constantize
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validator_name_for(constraint_name)\n \"#{self.name}::#{constraint_name.to_s.camelize}Validator\"\n end",
"def require_validator(short_name)\n str_name = short_name.to_s\n validators.fetch(str_name) do\n Grape::Validations::Validators.const_get(\"#{str_name.camelize}Validator\")\n ... | [
"0.77552146",
"0.6123661",
"0.59670156",
"0.5963079",
"0.58564174",
"0.5630898",
"0.557244",
"0.55271775",
"0.5496936",
"0.54852283",
"0.54794836",
"0.5378583",
"0.53460616",
"0.53435266",
"0.53232706",
"0.52958214",
"0.52850443",
"0.5241684",
"0.5241684",
"0.5237509",
"0.523... | 0.82892984 | 0 |
Test whether a validator is defined for the given +constraint_name+. | def validator_defined_for?(constraint_name)
!!validator_for(constraint_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validator_for(constraint_name)\n validator_name_for(constraint_name).safe_constantize\n end",
"def validate_constraint(name)\n @operations << {:op => :validate_constraint, :name => name}\n end",
"def validator_name_for(constraint_name)\n \"#{self.name}::#{constraint_name.to_s.camel... | [
"0.72034264",
"0.6973433",
"0.68505955",
"0.64228797",
"0.6253316",
"0.62065387",
"0.608302",
"0.60588497",
"0.5957871",
"0.5957871",
"0.5920323",
"0.5919931",
"0.59194636",
"0.5903427",
"0.58928955",
"0.5855895",
"0.5677626",
"0.5677626",
"0.5665675",
"0.56559676",
"0.554463... | 0.8825786 | 0 |
GET /tableaus or /tableaus.json | def index
@tableaus = Tableau.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list(table)\n self.get(\"/#{table}\")\n end",
"def index\n current_admin_user\n @tablets = Tablet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tablets }\n end\n end",
"def index\n @timetables = Timetable.all\n\n respond_to do |... | [
"0.6880986",
"0.645847",
"0.6225563",
"0.6200715",
"0.5879445",
"0.58438015",
"0.5805822",
"0.57448506",
"0.57298815",
"0.5714629",
"0.5709946",
"0.5705703",
"0.5705703",
"0.5705703",
"0.56966424",
"0.5667778",
"0.56641984",
"0.5634567",
"0.5602724",
"0.55976826",
"0.55898887... | 0.6292833 | 2 |
GET /tableaus/1 or /tableaus/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list(table)\n self.get(\"/#{table}\")\n end",
"def index\n current_admin_user\n @tablets = Tablet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tablets }\n end\n end",
"def table_response(key, query = nil, *args)\n url = File.j... | [
"0.68564415",
"0.6264318",
"0.6261163",
"0.61699134",
"0.6167637",
"0.61581445",
"0.61581445",
"0.61581445",
"0.6028052",
"0.6022473",
"0.595431",
"0.59156907",
"0.5878905",
"0.58348775",
"0.5790195",
"0.5773925",
"0.57731956",
"0.57526",
"0.5741271",
"0.57264423",
"0.5707084... | 0.0 | -1 |
POST /tableaus or /tableaus.json | def create
@tableau = Tableau.new(tableau_params)
respond_to do |format|
if @tableau.save
format.html { redirect_to @tableau, notice: "Tableau was successfully created." }
format.json { render :show, status: :created, location: @tableau }
else
format.html { render :new, stat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @tableau = Tableau.new(tableau_params)\n\n respond_to do |format|\n if @tableau.save\n format.html { redirect_to @tableau, notice: 'Tableau was successfully created.' }\n format.json { render :show, status: :created, location: @tableau }\n else\n format.html { rend... | [
"0.6483934",
"0.586795",
"0.5853019",
"0.5830576",
"0.57702667",
"0.5706241",
"0.56232846",
"0.56159276",
"0.559495",
"0.5584071",
"0.55816233",
"0.55701643",
"0.55651873",
"0.55566543",
"0.552554",
"0.552025",
"0.5503748",
"0.5474411",
"0.5469795",
"0.54638",
"0.54608935",
... | 0.6475602 | 1 |
PATCH/PUT /tableaus/1 or /tableaus/1.json | def update
respond_to do |format|
if @tableau.update(tableau_params)
format.html { redirect_to @tableau, notice: "Tableau was successfully updated." }
format.json { render :show, status: :ok, location: @tableau }
else
format.html { render :edit, status: :unprocessable_entity }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @table = Table.find(params[:id])\n\n respond_to do |format|\n if @table.update_attributes(params[:table].permit(:name, :notes, :x, :y, :table_type, :guest_ids => []))\n format.html { redirect_to @table, notice: 'Table was successfully updated.' }\n format.json { head :no_conte... | [
"0.6522552",
"0.64836484",
"0.64475375",
"0.6388141",
"0.6279632",
"0.6277591",
"0.6225763",
"0.62201715",
"0.62112105",
"0.6179463",
"0.61213607",
"0.6076911",
"0.6064147",
"0.60497737",
"0.593035",
"0.5922849",
"0.5913312",
"0.5900036",
"0.58720887",
"0.582229",
"0.58065575... | 0.6409889 | 3 |
DELETE /tableaus/1 or /tableaus/1.json | def destroy
@tableau.destroy
respond_to do |format|
format.html { redirect_to tableaus_url, notice: "Tableau was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_table(table_id); delete(\"tables/#{table_id}\"); nil; end",
"def destroy\n @<%= singular_table_name %>.destroy\n respond_to do |format|\n format.html { redirect_to <%= table_name %>_url }\n format.json { head :no_content }\n end",
"def delete_aos_version(args = {}) \n delete(\"/ao... | [
"0.677682",
"0.6709245",
"0.65887797",
"0.6573286",
"0.6573286",
"0.65375906",
"0.653598",
"0.653598",
"0.653598",
"0.64706343",
"0.6437781",
"0.63814914",
"0.63504094",
"0.63158417",
"0.6311973",
"0.63055235",
"0.627536",
"0.627536",
"0.6273878",
"0.62566495",
"0.6239731",
... | 0.646752 | 10 |
Use callbacks to share common setup or constraints between actions. | def set_tableau
@tableau = Tableau.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def tableau_params
params.require(:tableau).permit(:title, :content, :image)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.6948629",
"0.6813401",
"0.68012834",
"0.67958814",
"0.6745398",
"0.67409563",
"0.6526744",
"0.65207636",
"0.6492359",
"0.6433316",
"0.6433316",
"0.6433316",
"0.639903",
"0.6355392",
"0.63544166",
"0.63463736",
"0.6344045",
"0.6337686",
"0.632862",
"0.632862",
"0.632862",
... | 0.0 | -1 |
list all posts GET /videos | def index
@videos = Video.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @video_posts = VideoPost.all\n end",
"def videos options={}\n response = client.get(\"/#{id}/videos\", options)\n end",
"def list\n @videos = Video.all\n\n respond_to do |format|\n format.html # list.html.erb\n format.json { render json: @videos }\n end\n end",
"de... | [
"0.7763636",
"0.77237326",
"0.7510046",
"0.74239343",
"0.7288024",
"0.7288024",
"0.7227585",
"0.71709025",
"0.71704507",
"0.7170112",
"0.7170056",
"0.71699417",
"0.71699417",
"0.71699417",
"0.71699417",
"0.7147295",
"0.7129892",
"0.71265864",
"0.7112899",
"0.70950645",
"0.704... | 0.7565632 | 14 |
show a single post GET /videos/:id | def show
@video = Video.find(params['id'])
@comment = @video.comments.new
@comments = @video.comments
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @videos = Video.all\n @video = @videos.find params[:id]\n end",
"def show\n @video = Video.find(params[:id])\n end",
"def show\n @videos = Video.find_by(id: params[:id])\n end",
"def show\n @video = Video.find_by(slug: params[:id])\n end",
"def show\n @video = Video.find(... | [
"0.79487795",
"0.7945811",
"0.790512",
"0.7713373",
"0.73360395",
"0.726726",
"0.72568274",
"0.7172477",
"0.7172477",
"0.7172477",
"0.7172477",
"0.7172477",
"0.7172477",
"0.7172477",
"0.71578836",
"0.7080945",
"0.7066463",
"0.70476806",
"0.7044025",
"0.70160353",
"0.6977892",... | 0.6743326 | 61 |
new post creation form GET /videos/new | def new
@video = Video.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n authorize! :create, @videos\n @videos = Video.new\n end",
"def new\n begin\n @active_page = \"videos\"\n @video = Video.new\n respond_with(@video)\n rescue Exception => e\n log_error(e, \"Error occured in New action of VideosController\")\n flash_error(t('videos.ne... | [
"0.77362496",
"0.76662195",
"0.76293355",
"0.76270276",
"0.75519633",
"0.75514495",
"0.7544438",
"0.75199485",
"0.75068116",
"0.73833925",
"0.73606503",
"0.7358875",
"0.7358875",
"0.7358875",
"0.7358875",
"0.7358875",
"0.7358875",
"0.7358875",
"0.7358875",
"0.7358875",
"0.735... | 0.7600093 | 5 |
create a new post POST /videos | def create
vid = Video.create(video_params)
redirect_to "/videos/#{vid.id}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n if current_user.permission.can_post_video?\n @video = Video.new(video_params)\n\n respond_to do |format|\n if @video.save\n format.html { redirect_to @video, notice: 'Video was successfully created.' }\n format.json { render :show, status: :created, location: @vid... | [
"0.75851345",
"0.72915107",
"0.72767377",
"0.72754973",
"0.7273937",
"0.7273937",
"0.7273937",
"0.7273937",
"0.7262454",
"0.7253339",
"0.7233985",
"0.7221902",
"0.7209715",
"0.7157206",
"0.71454036",
"0.7141846",
"0.7136834",
"0.7136834",
"0.7136834",
"0.7136834",
"0.7136834"... | 0.763134 | 0 |
edit post form GET /videos/:id/edit | def edit
@video = Video.find(params['id'])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n authorize! :update, @videos\n @videos = Video.find_by(id: params[:id])\n end",
"def edit\n @movie = Movie.find params[:id]\n end",
"def edit\n @movie = Movie.find params[:id]\n end",
"def edit\n @movie = Movie.find params[:id]\n end",
"def update\r\n @video = Video.find(par... | [
"0.81710076",
"0.7292028",
"0.7292028",
"0.7292028",
"0.7228826",
"0.7162943",
"0.7159703",
"0.71357137",
"0.71357137",
"0.71354115",
"0.71204096",
"0.71204096",
"0.71145713",
"0.7112005",
"0.7112005",
"0.7112005",
"0.7112005",
"0.7112005",
"0.7112005",
"0.7112005",
"0.710772... | 0.85527676 | 0 |
update an existing post PUT /videos/:id | def update
Video.find(params[:id]).update(video_params)
redirect_to "/videos/#{params[:id]}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n # @video = Video.find(params[:id])\n @video = current_user.videos.find(params[:id])\n\n respond_to do |format|\n if @video.update_attributes(params[:video])\n format.html { redirect_to @video, notice: 'Video was successfully updated.' }\n format.json { head :no_content }\n ... | [
"0.72831625",
"0.72510934",
"0.72510934",
"0.7249196",
"0.72432077",
"0.72258174",
"0.72258174",
"0.72258174",
"0.72258174",
"0.72258174",
"0.72258174",
"0.72258174",
"0.7217829",
"0.71383554",
"0.7114903",
"0.70552474",
"0.70494753",
"0.70441633",
"0.70441633",
"0.7020772",
... | 0.7709594 | 0 |
destroy an existing post DELETE /videos/:id | def destroy
Video.find(params[:id]).destroy
redirect_to "/videos"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @post = Post.find(params[:id])\n @videos = Video.where([\"post_id = ?\", params[:id]]).all\n @background = get_background_for @post\n \n @post.destroy\n @videos.each { |video| video.destroy }\n @background.destroy\n\n respond_to do |format|\n format.html { redirect_to pos... | [
"0.8222949",
"0.817699",
"0.7847628",
"0.7847628",
"0.7847628",
"0.7847628",
"0.78153884",
"0.77906525",
"0.77655447",
"0.7752665",
"0.7748631",
"0.7693395",
"0.7693395",
"0.76905334",
"0.7669993",
"0.7654003",
"0.7626168",
"0.7623121",
"0.75983834",
"0.75933987",
"0.7592468"... | 0.8025119 | 2 |
Only allow a trusted parameter "white list" through. | def word_params
params.require(:word).permit(
:word_class,
:lexical_form,
:translation
).merge(dictionary_id: @dictionary.id)
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.71207976",
"0.705222",
"0.69488335",
"0.69021654",
"0.67362636",
"0.6717561",
"0.6689192",
"0.6678948",
"0.66622657",
"0.6555007",
"0.6527569",
"0.64588845",
"0.64522904",
"0.6450812",
"0.6448551",
"0.6434285",
"0.6412147",
"0.6412147",
"0.6393719",
"0.6381976",
"0.6381976... | 0.0 | -1 |
GET /search_pages/1 GET /search_pages/1.json | def show
@search_page = SearchPage.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @search_page }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pages = Page.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n render json: @pages\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n ... | [
"0.75780404",
"0.7236756",
"0.7221203",
"0.7221203",
"0.7221203",
"0.7221203",
"0.7221203",
"0.7221203",
"0.7221203",
"0.7212069",
"0.7108786",
"0.70681345",
"0.6922521",
"0.6911047",
"0.69006073",
"0.6834708",
"0.68125224",
"0.673031",
"0.6720743",
"0.66971403",
"0.66548866"... | 0.72668946 | 1 |
GET /search_pages/new GET /search_pages/new.json | def new
@search_page = SearchPage.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @search_page }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @page = current_site.pages.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page }\n end... | [
"0.78667194",
"0.7529595",
"0.7529595",
"0.7529595",
"0.7529595",
"0.7529595",
"0.74910486",
"0.74853176",
"0.7479139",
"0.740969",
"0.73971254",
"0.7351789",
"0.7351789",
"0.7351789",
"0.7351789",
"0.7351789",
"0.7329548",
"0.727002",
"0.71549594",
"0.71470594",
"0.7116551",... | 0.8113328 | 0 |
POST /search_pages POST /search_pages.json | def create
@search_page = SearchPage.new(params[:search_page])
respond_to do |format|
if @search_page.save
format.html { redirect_to @search_page, notice: 'Search page was successfully created.' }
format.json { render json: @search_page, status: :created, location: @search_page }
el... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @search_page = SearchPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @search_page }\n end\n end",
"def index\n @pages = Page.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { ren... | [
"0.6511707",
"0.65087706",
"0.64334816",
"0.6308065",
"0.63034785",
"0.62335986",
"0.61432076",
"0.61432076",
"0.61432076",
"0.61432076",
"0.61432076",
"0.61432076",
"0.61432076",
"0.61431164",
"0.61043614",
"0.6100624",
"0.60965115",
"0.60767937",
"0.60766065",
"0.60733306",
... | 0.67143166 | 0 |
PUT /search_pages/1 PUT /search_pages/1.json | def update
@search_page = SearchPage.find(params[:id])
respond_to do |format|
if @search_page.update_attributes(params[:search_page])
format.html { redirect_to @search_page, notice: 'Search page was successfully updated.' }
format.json { head :no_content }
else
format.html {... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if page_params[:body]\n @page.versions << Version.new(body: page_params[:body], title: page_params[:title]).save\n page_params.delete :body\n end\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to controller: \"pages\", action: \"show\", ... | [
"0.6409728",
"0.6241531",
"0.62314403",
"0.61032486",
"0.60782754",
"0.6077068",
"0.6073707",
"0.60477793",
"0.60388154",
"0.6022636",
"0.59985095",
"0.5982613",
"0.59694177",
"0.5964319",
"0.5941096",
"0.5927508",
"0.5927508",
"0.59136647",
"0.591152",
"0.59067345",
"0.59043... | 0.6890708 | 0 |
DELETE /search_pages/1 DELETE /search_pages/1.json | def destroy
@search_page = SearchPage.find(params[:id])
@search_page.destroy
respond_to do |format|
format.html { redirect_to search_pages_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_page(id)\n @client.raw('delete', \"/content/pages/#{id}\")\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n ... | [
"0.72663337",
"0.7036327",
"0.7036327",
"0.7036327",
"0.7036327",
"0.70158154",
"0.70158154",
"0.70158154",
"0.70158154",
"0.70158154",
"0.70158154",
"0.70158154",
"0.70158154",
"0.7005134",
"0.7005134",
"0.7005134",
"0.69661313",
"0.6945257",
"0.69372916",
"0.6931014",
"0.69... | 0.7624745 | 0 |
Links package names based on regex. Example: link_regex(/(github:|:github =>)\s['"](?[^'"]+)['"]/) Will link `user/repo` in `github: "user/repo"` or `:github => "user/repo"` | def link_regex(regex, &url_proc)
highlighted_lines.map!.with_index do |rich_line, i|
marker = StringRegexMarker.new(plain_lines[i].chomp, rich_line.html_safe)
marker.mark(regex, group: :name) do |text, left:, right:|
url = yield(text)
url ? link_tag(text, url) : text... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _resolve_links(text)\n text.gsub(/L\\((\\w+)\\)/) { _link($1) }\nend",
"def linkify( text )\n s = text.to_s\n s.gsub!( @generic_URL_regexp, '\\1<a href=\"\\2\">\\2</a>' )\n s.gsub!( @starts_with_www_regexp, '\\1<a href=\"http://\\2\">\\2</a>' )\n s.gsub!( @starts_with_ftp_regexp, '\\1<a href=\"ftp://\\2... | [
"0.6079767",
"0.5786196",
"0.5602954",
"0.55957735",
"0.55941063",
"0.54702663",
"0.5376143",
"0.53515285",
"0.5330375",
"0.53174967",
"0.5284796",
"0.52834237",
"0.52828723",
"0.5276678",
"0.5266661",
"0.5258937",
"0.5248722",
"0.5234944",
"0.52341235",
"0.51975167",
"0.5189... | 0.6565399 | 0 |
this is where we see whether the track extends from LB, SP or both | def check_track_restrictions!(entity, old_tile, new_tile)
unless @game.loading
lb = uses_graph?(entity, @game.lb_graph, old_tile, new_tile)
sp = uses_graph?(entity, @game.sp_graph, old_tile, new_tile)
if lb && sp
@round.graph_id = 'BOTH'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_track_end\n return ( 'tracks' == @top_level_key ) &&\n \"/plist/dict/dict/dict\" == @breadcrumb\n end",
"def is_track_start\n return ( 'tracks' == @top_level_key ) &&\n \"/plist/dict/dict/key\" == @breadcrumb\n end",
"def supports_track_and_trace?\n case closest_track_trace_method\n... | [
"0.63574356",
"0.6330936",
"0.62212634",
"0.6136952",
"0.60710204",
"0.5911573",
"0.5889565",
"0.5889517",
"0.58787817",
"0.5676136",
"0.5675792",
"0.56635875",
"0.56179994",
"0.5594999",
"0.5569284",
"0.5529381",
"0.5529381",
"0.5501345",
"0.5498127",
"0.54385823",
"0.543066... | 0.60191846 | 5 |
Run a sample application or any user application with jruby | def run
return puts("usage example: glimmer run tictactoe") unless @name
# Search for the filename (and add the .rb extension if not provided), and run it
if File.exist?("#{@name}#{'.rb' unless @name =~ /.rb$/}")
command = "#{JRUBY_COMMAND} \"#{@name.gsub(/\\/, '/')}#{'.rb' unless @name =~ /.rb$/}... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_robot(args)\n cmd = (RUBY_PLATFORM == 'java') ? \"jruby -S rackup\" : \"rackup\"\n cmd += \" \" + args.join(\" \") if args\n exec(cmd)\nend",
"def jruby_oop(*args)\n prev_in_process = JRuby.runtime.instance_config.run_ruby_in_process\n JRuby.runtime.instance_config.run_ruby_in_process = false\... | [
"0.6685125",
"0.63199955",
"0.6002049",
"0.5985395",
"0.5975639",
"0.59386724",
"0.5888975",
"0.5888975",
"0.58574593",
"0.5846024",
"0.578367",
"0.57568187",
"0.57354033",
"0.57336956",
"0.5708296",
"0.5707937",
"0.56506175",
"0.5646123",
"0.5646123",
"0.5629255",
"0.5627278... | 0.6736338 | 0 |
This could be avoided by naming the main application like the directory (i.e. without underscores) | def fetch_app(name)
return name if SAMPLES[name].nil?
"#{name}/#{SAMPLES[name]}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app_name\n Dir.pwd.split(\"/\").last.gsub(/\\./, \"_\")\n end",
"def application_name\n Rails.root.to_s.split('/').last.underscore\n end",
"def app_name ; self.class.rootname.snake_case.to_sym ; end",
"def app_name\n @app_name ||= Rails.app_class.module_parent_name.demodulize.underscor... | [
"0.75504565",
"0.74159896",
"0.73571545",
"0.6959328",
"0.6927728",
"0.68757206",
"0.68027896",
"0.6729503",
"0.67259866",
"0.66513",
"0.66327393",
"0.66057235",
"0.65986204",
"0.65224713",
"0.6497794",
"0.64871544",
"0.6476877",
"0.6460014",
"0.64259547",
"0.6390947",
"0.638... | 0.6061626 | 41 |
the next three methods establish the user authentication | def password
@password
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_authentication\n end",
"def authenticate\n end",
"def auth\n end",
"def auth\n end",
"def authenticate!\n # Do nothing yet\n end",
"def authenticate!\n if params[:user]\n user = User.find_by(email: params[:user][:user_name])\n if user and user.loc... | [
"0.76925284",
"0.76105756",
"0.7496584",
"0.7496584",
"0.72820026",
"0.72267425",
"0.72255355",
"0.7222759",
"0.718933",
"0.7161685",
"0.7157303",
"0.71270746",
"0.71083987",
"0.7099676",
"0.70786124",
"0.7044591",
"0.7044591",
"0.70176965",
"0.7002355",
"0.6980134",
"0.69644... | 0.0 | -1 |
this method passes the user's password to BCrypt creating the password_digest that is saved in the database | def password=(new_password)
@password = new_password
self.password_digest = BCrypt::Password.create(new_password)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_password # We'll call this method in the seed file; from https://gist.github.com/mdang/7b6097cc13b07db82c78\n if password.present?\n self.password_digest = BCrypt::Password.create(password)\n end\n end",
"def create_hash_digest(password)\n BCrypt::Password.create(password)\nend",
"def p... | [
"0.8119369",
"0.80438423",
"0.8043453",
"0.801077",
"0.79632235",
"0.79345477",
"0.78782344",
"0.78782344",
"0.7870421",
"0.7832828",
"0.78133845",
"0.7812232",
"0.78039086",
"0.7783307",
"0.77744484",
"0.77670234",
"0.7724595",
"0.7724595",
"0.7724595",
"0.7724595",
"0.77245... | 0.0 | -1 |
this method tests the user's password against the user's entered password to authenticate the password upon logging in | def authenticate(test_password)
if BCrypt::Password.new(self.password_digest) == test_password
self
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate password\n if self.password == password\n true\n else\n false\n end\n end",
"def authenticate(attempted_password)\n if self.password == attempted_password\n true\n else\n false\n end\n end",
"def authenticate(attempted_password)\n if self.password == ... | [
"0.79132855",
"0.77467185",
"0.77467185",
"0.77239835",
"0.76835984",
"0.76822585",
"0.758966",
"0.7522987",
"0.74689686",
"0.74567205",
"0.7378198",
"0.7352632",
"0.7336743",
"0.7300324",
"0.72866094",
"0.7267331",
"0.7258918",
"0.72469705",
"0.7246189",
"0.7242417",
"0.7239... | 0.7203705 | 23 |
this method allows the user to call in the exact size of the image that is desired for a particular instance of that image | def avatar_url(size)
self.avatar.url(size)
# .gsub('s3.amazonaws.com/', 's3-us-west-2.amazonaws.com/')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_size\n end",
"def display_image \r\n self.image.variant(resize_to_limit: [1000, 1000]) \r\n end",
"def small(input) # Method that returns the image\n self.images[input].variant(resize: \"300x300\").processed # Resizing the image and return it\n en... | [
"0.7280176",
"0.7036305",
"0.7030499",
"0.7002891",
"0.69945365",
"0.69785994",
"0.68709874",
"0.68534046",
"0.67376274",
"0.6730934",
"0.67301077",
"0.6700638",
"0.6700638",
"0.66578126",
"0.6657339",
"0.66516066",
"0.66516066",
"0.66516066",
"0.66516066",
"0.66516066",
"0.6... | 0.0 | -1 |
Define the current_user method: | def current_user
# Look up the current user based on user_id in the session cookie:
#TIP: The ||= part ensures this helper doesn't hit the database every time a user hits a web page. It will look it up once, then cache it in the @current_user variable.
#This is called memoization and it helps make our app more efficien... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_method\n current_user\n end",
"def current_user\n raise NotImplementedError\n end",
"def current_user\n raise NotImplementedError\n end",
"def method_missing(method_name, *args, &block)\n if @current_user.respond_to?(method_name)\n @current_user.send(method_name, *args, &... | [
"0.8555043",
"0.8150536",
"0.8150536",
"0.8080081",
"0.78555256",
"0.783441",
"0.7726804",
"0.77206564",
"0.76928777",
"0.76780874",
"0.764933",
"0.75703",
"0.7568394",
"0.7491855",
"0.74732596",
"0.7437057",
"0.7421633",
"0.7418827",
"0.7418827",
"0.7418827",
"0.7418827",
... | 0.0 | -1 |
return 1 if it's already a palindrome or it's not possible selfexplanatory | def palindrome?(str)
str == str.reverse
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def palindrome?\n str = self.to_s\n len = str.size\n\n if len.odd?\n str[0, len/2] == str[len/2 + 1, len/2].reverse\n else\n str[0, len/2] == str[len/2, len/2].reverse\n end\n end",
"def is_palindrome(s)\n\tl = 0\n\tr = s.length - 1\n\treturn pal_helper(s, l, r)\nend",
"def palindrome... | [
"0.8047905",
"0.8009387",
"0.7910701",
"0.7910488",
"0.79099494",
"0.79015815",
"0.78965884",
"0.78935695",
"0.78696805",
"0.7867167",
"0.7847623",
"0.78038716",
"0.7800673",
"0.77829003",
"0.77720433",
"0.77720433",
"0.7767904",
"0.77673554",
"0.7765614",
"0.7760397",
"0.775... | 0.0 | -1 |
Add a formatting file for this method, modelcase from menu, etc | def to_table_format(table)
#change to format module
CliBuilder::Menu.modelcase(table).constantize
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indent()\n file = Tempfile.new(\"out\")\n infile = Tempfile.new(\"in\")\n file.write(self.to_s)\n file.flush\n bufc = \"FOO\"\n\n tmppos = @pos\n\n message(\"Auto format #{@fname}\")\n\n if [\"chdr\", \"c\", \"cpp\"].include?(get_file_type())\n\n #C/C++/Java/JavaScript/Objective-C/... | [
"0.634596",
"0.6332514",
"0.6325264",
"0.6039725",
"0.6032688",
"0.6032688",
"0.6032688",
"0.5996159",
"0.59522533",
"0.59522533",
"0.5937235",
"0.5838785",
"0.5835961",
"0.5770948",
"0.5770948",
"0.5770948",
"0.5770948",
"0.5770948",
"0.5770948",
"0.5770948",
"0.5770948",
... | 0.5165161 | 48 |
TODO: To print record info, iterate through column values and print wiht | | def write_record_method(menu, records, selected_record)
puts "I am record method #{self}"
menu.define_singleton_method :"#{selected_record}" do
puts "#{@@selected_table.find(selected_record.id)}"
case @@crud_type
when :view
puts... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def column_value(rec, drawer)\n rec.inspect\n end",
"def showTable(db, flag)\n fieldNames = db.fields \n rows = db.data\n \n case(flag)\n when \"f\" then puts(\"*** Field Names #{fieldNames.length} *** \\n\", fieldNames, \"\\n\")\n when \"r\" then puts(\"*** Records *** \\n\", rows)\n ... | [
"0.695223",
"0.6903341",
"0.6722543",
"0.6656824",
"0.6495174",
"0.6452063",
"0.6436871",
"0.6398242",
"0.6382556",
"0.6292755",
"0.6230497",
"0.6215913",
"0.62084424",
"0.6183295",
"0.6171444",
"0.61698675",
"0.6155319",
"0.61047304",
"0.6098877",
"0.6082473",
"0.60615796",
... | 0.0 | -1 |
Writes method to choose crud type | def write_crud_by_type(menu, crud_type)
column_names = @@selected_table.columns.map(&:name)
crud_by_options = [:all].concat(column_names)
crud_column_menu = CliBuilder::Menu.new(title: "Select Type of CRUD", menu_options: crud_by_options, menu_type: "crud")
menu.define_si... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type\r\n\t\t\t`#{BITS::BITSADMIN} /gettype {#{@id}}`\r\n\t\tend",
"def set_type\n end",
"def define_write_field_method(field_type)\n define_method \"#{field_type}=\" do |value|\n self[field_type] = value\n end\n end",
"def serialize(writer)\n raise StandardEr... | [
"0.59498966",
"0.5794261",
"0.5791191",
"0.57715297",
"0.5759824",
"0.56797117",
"0.56709343",
"0.5657986",
"0.56575245",
"0.5654803",
"0.5654803",
"0.5645809",
"0.5645809",
"0.5645809",
"0.5645809",
"0.5645809",
"0.5645809",
"0.5645809",
"0.5645809",
"0.5645809",
"0.5645809"... | 0.6956496 | 0 |
Time complexity: O(n) Space complexity: O(n) | def reverse_sentence(my_sentence)
if my_sentence.nil?
return nil
end
word_array = my_sentence.split(/\.?\s+/)
i = 0
end_position = word_array.length - 1
while i <= end_position
temp = word_array[i]
word_array[i] = word_array[end_position]
word_array[end_position] = temp
i += 1
... | {
"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.69327533",
"0.67202395",
"0.6281914",
"0.6208389",
"0.62076294",
"0.620188",
"0.61807215",
"0.61510706",
"0.6135327",
"0.6085616",
"0.608483",
"0.60819167",
"0.60750985",
"0.60721177",
"0.6068634",
"0.6021935",
"0.6014079",
"0.60035086",
"0.60033137",
"0.5994625",
"0.59720... | 0.0 | -1 |
Given a find on a model with a :select option, add to the :select statement any fields needed to finalize preload_associations and associate the records with their source records | def add_association_keys_to_select(options)
return options[:select] unless options[:include]
select_table_fields = split_table_fields(options[:select])
select_table_fields.concat add_association_keys_to_select_sub(self, options)
reform_select_from_fields(select_table_fields.uniq)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_from_select(model_handle, field_set, select_ds, override_attrs = {}, opts = {})\n # TODO: temp for debugging; there are top level objects that can mistakenly trigger this\n unless model_handle[:parent_model_name]\n unless (not Model.has_group_id_col?(model_handle)) || TOP_LEVEL_MO... | [
"0.60559916",
"0.60077125",
"0.5966258",
"0.58185005",
"0.5807966",
"0.571803",
"0.5682674",
"0.5655717",
"0.55879533",
"0.55877584",
"0.55479926",
"0.5388551",
"0.53813523",
"0.5360933",
"0.5351334",
"0.534307",
"0.5342079",
"0.5334125",
"0.5239931",
"0.5239605",
"0.5218153"... | 0.6670544 | 0 |
Given a find on a model with a :select option, add to the :select statement any fields needed to finalize preload_associations and associate the records with their source records | def add_association_keys_to_select_sub(klass, options)
select_table_fields = class_primary_key_fields(klass)
if options[:include].class == Symbol || options[:include].class == String
select_table_fields.concat association_keys_for(klass, options[:include].to_sym)
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_association_keys_to_select(options)\n return options[:select] unless options[:include]\n select_table_fields = split_table_fields(options[:select])\n select_table_fields.concat add_association_keys_to_select_sub(self, options)\n reform_select_from_fields(select_table_fie... | [
"0.6670425",
"0.60578966",
"0.6009634",
"0.59668404",
"0.5808845",
"0.5718704",
"0.5683452",
"0.5658337",
"0.5590163",
"0.55880123",
"0.55506015",
"0.53889173",
"0.5383406",
"0.5361201",
"0.5351448",
"0.5343533",
"0.534219",
"0.53356516",
"0.5240784",
"0.5239203",
"0.52183807... | 0.58175623 | 4 |
Given a class and an association (reflection), add the appropriate primary or foreign keys to the array of fields that must be returned for the association records to be attached to their source classes | def association_keys_for(klass, association_name)
select_table_fields = []
# make sure there is a reflection with this name
if r = klass.reflections[association_name]
if r.macro == :belongs_to
# A :belongs_to B => [a, r.primary_key], [b, b.primary_key]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_association_keys_to_select_sub(klass, options)\n select_table_fields = class_primary_key_fields(klass)\n \n if options[:include].class == Symbol || options[:include].class == String\n select_table_fields.concat association_keys_for(klass, options[:include].to_sym)\n ... | [
"0.6852206",
"0.660452",
"0.65815616",
"0.6224554",
"0.622008",
"0.62191784",
"0.6174764",
"0.6174764",
"0.6163706",
"0.61081845",
"0.60351306",
"0.60076445",
"0.60047513",
"0.5996933",
"0.59737194",
"0.59325874",
"0.5900406",
"0.58690566",
"0.5862227",
"0.57966405",
"0.57936... | 0.678149 | 1 |
return an array of a class's primary key fields eg: [[table, id]] or [[table, id1], [table, id2]] | def class_primary_key_fields(klass)
fields = []
if klass.primary_key.class == Array || klass.primary_key.class == CompositePrimaryKeys::CompositeKeys
klass.primary_key.each do |pk|
fields << [klass.table_name, pk.to_s]
end
else
fields << [k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primary_key(_table_name)\n []\n end",
"def primary_key\n fields.select { |f| f.key }.map(&:name)\n end",
"def primary_keys\n cached_fetch(:primary_keys){Array(primary_key)}\n end",
"def id\n if primary_key.is_a?(Array)\n id = Array.new\n primary_key.each ... | [
"0.7685692",
"0.7508689",
"0.7188251",
"0.71238244",
"0.7122814",
"0.7030387",
"0.69522387",
"0.68720067",
"0.684925",
"0.6840517",
"0.6831524",
"0.6826372",
"0.6819201",
"0.68038076",
"0.6758681",
"0.67503494",
"0.6733",
"0.67207503",
"0.66870487",
"0.66853434",
"0.66752905"... | 0.85519904 | 0 |
EOL: used to grab only the select fields that to pertain to this table given: User.find(:select => "name, `terms`.`definition`, friends.) returns: [['users', 'name'], ['terms', 'definition'], ['friends', '']] | def split_table_fields(select_statement, split_options = {})
return select_statement if select_statement.class != String
table_fields = []
select_statement.split(",").each do |tf|
# this will make:
# m[0] => 'table_name'
# m[1] => 'field_name'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parsed_select\n params[:select].split(',').map do |field|\n field if resource.column_names.include?(field)\n end\n rescue NoMethodError\n []\n end",
"def select\n (@select ||= (defaults[:select] || [])).collect { |c| c == '*' ? all_columns.keys : c }.flatten\n end",
"def as_select_value... | [
"0.6769199",
"0.65413654",
"0.65239316",
"0.6358885",
"0.6233642",
"0.6166992",
"0.61463577",
"0.6092205",
"0.60596365",
"0.60403913",
"0.5992141",
"0.5912687",
"0.5907256",
"0.590568",
"0.589932",
"0.58900106",
"0.58861935",
"0.5870371",
"0.5863814",
"0.5834142",
"0.5815741"... | 0.5274111 | 72 |
EOL: used to grab only the select fields that to pertain to this table given: [['users', 'name'], ['terms', 'definition', ' as term_d'], ['friends', '']] returns: `users`.`name`, `terms`.`definition` as term_d, `friends`. | def reform_select_from_fields(table_fields)
# if we're asking for * then ignore all other individual fields
table_fields.each do |tf|
if tf[1] == '*'
table_fields.delete_if {|k| k[0] == tf[0] && k[1] != '*'}
end
end
# re-form the s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parsed_select\n params[:select].split(',').map do |field|\n field if resource.column_names.include?(field)\n end\n rescue NoMethodError\n []\n end",
"def select\n (@select ||= (defaults[:select] || [])).collect { |c| c == '*' ? all_columns.keys : c }.flatten\n end",
"def arel_select_col... | [
"0.63277185",
"0.6110619",
"0.59936386",
"0.5947679",
"0.591459",
"0.5905814",
"0.5859568",
"0.5830928",
"0.58185256",
"0.5802095",
"0.5795466",
"0.57502526",
"0.5733505",
"0.57071644",
"0.5677721",
"0.5670504",
"0.56643385",
"0.5618248",
"0.5603194",
"0.55980927",
"0.5581603... | 0.67878675 | 0 |
GET /users GET /users.json | def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @users }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end",
"def GetUsers params = {}\n\n para... | [
"0.82109934",
"0.7873764",
"0.7860689",
"0.78108346",
"0.78067017",
"0.7678852",
"0.76586664",
"0.76318866",
"0.7582366",
"0.75291824",
"0.7487637",
"0.74485743",
"0.7439024",
"0.7437192",
"0.7427442",
"0.73978853",
"0.73978853",
"0.73978853",
"0.73978853",
"0.7377353",
"0.73... | 0.0 | -1 |
GET /users/1 GET /users/1.json | def show
@user = User.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @user }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ... | [
"0.81046426",
"0.7703556",
"0.77011716",
"0.76262826",
"0.7582106",
"0.74818",
"0.7461394",
"0.7446168",
"0.730656",
"0.7300699",
"0.72902125",
"0.72781444",
"0.72358584",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.722... | 0.0 | -1 |
GET /users/new GET /users/new.json | def new
@user = User.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @user }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @newuser = Newuser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newuser }\n end\n end",
"def new\n @usernew = Usernew.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usernew }\n ... | [
"0.82878774",
"0.8169478",
"0.8156354",
"0.8049527",
"0.80228055",
"0.80222774",
"0.8010335",
"0.7950992",
"0.7930627",
"0.7930627",
"0.7873535",
"0.7873535",
"0.7873535"
] | 0.7860988 | 85 |
POST /users POST /users.json | def create
@user = User.new(
username: params[:user][:username],
name: params[:user][:name],
email: params[:user][:email],
)
@user.password = params[:user][:password]
@user.password_confirmation = params[:user][:password_confirmation]
respond_to do |format|
if @user.save
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end",
"def post b... | [
"0.77179813",
"0.75206673",
"0.73831296",
"0.72405374",
"0.719841",
"0.7140812",
"0.71038526",
"0.7058827",
"0.7041636",
"0.70236504",
"0.7003128",
"0.70021695",
"0.70021695",
"0.70021695",
"0.69936967",
"0.6990463",
"0.6980393",
"0.6979075",
"0.69788617",
"0.69788617",
"0.69... | 0.0 | -1 |
PUT /users/1 PUT /users/1.json | def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to @user, notice: 'User was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.j... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"de... | [
"0.74114245",
"0.73920554",
"0.73041475",
"0.7254177",
"0.7202618",
"0.70756376",
"0.70535713",
"0.7029043",
"0.70075685",
"0.69883573",
"0.6983195",
"0.694263",
"0.69409895",
"0.692315",
"0.6909438",
"0.687742",
"0.68486536",
"0.6834162",
"0.6821841",
"0.6801179",
"0.6770304... | 0.0 | -1 |
DELETE /users/1 DELETE /users/1.json | def destroy
@user = User.find(params[:id])
@user.destroy
respond_to do |format|
format.html { redirect_to users_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
"def delete\n render json: Users.delete(params[\"id\... | [
"0.78750724",
"0.77518034",
"0.7713981",
"0.7610077",
"0.747295",
"0.74073994",
"0.74073994",
"0.7369968",
"0.7346072",
"0.7340465",
"0.7328618",
"0.7309635",
"0.73095363",
"0.7306841",
"0.7297868",
"0.72917855",
"0.7291585",
"0.7289111",
"0.7284347",
"0.7250935",
"0.7250935"... | 0.0 | -1 |
:callseq: autoken(id) autoken(:any) Returns user's token by primary key. Use :any to get random user. | def autoken(id)
ConsoleUtils.auto_token_for(id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token\n\t\t@token = ApiKey.find_by_user_id(self.id)\n\t\tif @token == nil\n\t\t\t\treturn ApiKey.create!(user: self)\n\t\telse\n\t\t\t\treturn @token\n\t\tend\n\tend",
"def generate_token\n #Token.generate_token(self.id)\n end",
"def generate_token\n begin\n token = Other::TokenGenerator.call(2... | [
"0.62783813",
"0.62511235",
"0.60346854",
"0.6006376",
"0.59903604",
"0.5986154",
"0.59342784",
"0.58839124",
"0.58815056",
"0.58657926",
"0.5840555",
"0.5742761",
"0.5742584",
"0.5731756",
"0.57012033",
"0.5684522",
"0.56364",
"0.56161696",
"0.5608838",
"0.5598864",
"0.55859... | 0.7369993 | 0 |
:callseq: remo(.get|.post|.put|...)(url, user_id = nil, params) Remote API requester context. See also: ConsoleUtils::RequestUtils::Remo ==== Examples: See +exap+ examples. | def remo
Remo.new(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform_request url, verb = :get, body = nil, options = {}\n options_id = options.inspect\n can_cache = [:post, :put].include?(verb) ? false : cached?\n if can_cache && result = store.get(\"#{clean_url(url)}#{options_id}\")\n return JSON.parse(result)\n end\n response = perform_... | [
"0.5234621",
"0.52338433",
"0.5148929",
"0.5103396",
"0.5102755",
"0.50385255",
"0.5006172",
"0.49980137",
"0.49176088",
"0.48486513",
"0.47331166",
"0.4713389",
"0.46504417",
"0.46485707",
"0.46411836",
"0.4634662",
"0.4627828",
"0.46226966",
"0.4618659",
"0.4616027",
"0.459... | 0.47256356 | 11 |
GET /api/v1/outcomes GET /api/v1/outcomes.json | def index
@api_v1_outcomes = Api::V1::Outcome.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def outcomes\n \t@outcomes ||= {}\n end",
"def outcomes=(value)\n @outcomes = value\n end",
"def outcomes\n return @outcomes\n end",
"def index\n @loot_outcomes = LootOutcome.all\n end",
"def set_api_v1_outcome\n @api_v1_outcome = Api::... | [
"0.7057023",
"0.7031233",
"0.68870074",
"0.6850016",
"0.68334824",
"0.6819471",
"0.67437613",
"0.66567177",
"0.65027106",
"0.6424138",
"0.6422092",
"0.6256869",
"0.6230399",
"0.6169061",
"0.61241007",
"0.6113518",
"0.6079254",
"0.6071441",
"0.599061",
"0.5914157",
"0.59085315... | 0.8433095 | 0 |
GET /api/v1/outcomes/1 GET /api/v1/outcomes/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @api_v1_outcomes = Api::V1::Outcome.all\n end",
"def set_api_v1_outcome\n @api_v1_outcome = Api::V1::Outcome.find(params[:id])\n end",
"def create\n @api_v1_outcome = Api::V1::Outcome.new(api_v1_outcome_params)\n\n respond_to do |format|\n if @api_v1_outcome.save\n for... | [
"0.8219772",
"0.75095415",
"0.7188658",
"0.6946725",
"0.68880045",
"0.6677891",
"0.66116196",
"0.6550321",
"0.64701724",
"0.6437876",
"0.63814205",
"0.63632494",
"0.63133717",
"0.6252698",
"0.6187861",
"0.6181492",
"0.6166014",
"0.6162269",
"0.6078107",
"0.6015897",
"0.592423... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.