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
Never trust parameters from the scary internet, only allow the white list through.
def casefile_params params.require(:casefile).permit(:client, :matter, :file_number, :date_opened, :date_closed, :location) 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.6981537", "0.67835593", "0.6748275", "0.67436063", "0.6736311", "0.65937173", "0.6503359", "0.6498499", "0.6482832", "0.6478776", "0.645703", "0.6439998", "0.63802195", "0.6377008", "0.6366287", "0.632018", "0.63016284", "0.63011277", "0.62932974", "0.62919617", "0.6290564...
0.0
-1
Write a method that computes the difference between the square of the sum of the first n positive integers and the sum of the squares of the first n positive integers. Examples: sum_square_difference(3) == 22 > (1 + 2 + 3)2 (12 + 22 + 32) sum_square_difference(10) == 2640 sum_square_difference(1) == 0 sum_square_differ...
def sum_square_difference(int) first_n_ints = (1..int).to_a sum_1 = first_n_ints.sum sum_2 = first_n_ints.map{|int| int**2}.sum (sum_1**2) - sum_2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_square_difference(n)\n integers = (1..n).to_a\n\n square_of_sum = integers.sum ** 2\n sum_of_squares = integers.map { |n| n ** 2 }.sum\n\n square_of_sum - sum_of_squares\nend", "def sum_square_difference(n)\n \n sum = 0 \n for i in 0..n\n sum += i\n end\n \n sq_sum = 0\n for i in 0..n\n ...
[ "0.8366812", "0.83645856", "0.83304584", "0.82736987", "0.82603633", "0.82307", "0.81877726", "0.81494385", "0.8137678", "0.8061961", "0.80465215", "0.7995344", "0.78739655", "0.78300565", "0.7821157", "0.77725255", "0.7747849", "0.77237827", "0.7700112", "0.7692559", "0.7680...
0.7827587
14
Check for the presence of the passed role_name in the User's Roles and the User's Hyrax::Group's Roles.
def has_group_aware_role?(role_name) # rubocop:disable Naming/PredicateName return false if current_user.new_record? return true if current_user.has_role?(role_name, Site.instance) current_user.hyrax_groups.each do |group| return true if group.has_site_role?(role_name) end false ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_role?(role_name)\n if user_roles\n roles = user_roles.data.map do |role|\n role.name\n end\n\n roles.include?(role_name)\n end\n end", "def has_role? (role_name)\n self.role ? self.role.name==(role_name.to_s) : false\n end", "def has_role? (role_name)\n self.role ? s...
[ "0.7728154", "0.7393355", "0.7393355", "0.7384652", "0.7347232", "0.7271353", "0.72338384", "0.7227127", "0.71745116", "0.71592337", "0.7119259", "0.7117048", "0.7077453", "0.7008619", "0.6992254", "0.6992045", "0.6962424", "0.69305843", "0.6899201", "0.68873966", "0.68806964...
0.67127585
25
PATCH/PUT /friendships/1 PATCH/PUT /friendships/1.json
def update @friendship = Friendship.where(friend_id: current_user, user_id: params[:id]).first @friendship.update(approved: true) if @friendship.save redirect_to root_url, :notice => "Successfully confirmed friend!" else redirect_to root_url, :notice => "Sorry! Could not confirm frie...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def friendships_update(options = {})\n @req.post(\"/1.1/friendships/update.json\", options)\n end", "def update\n @friendship = @user.friendships.find(params[:id])\n\n respond_to do |format|\n if @friendship.update_attributes(params[:friendship])\n format.html { redirect_to [@game, ...
[ "0.75791544", "0.7365749", "0.7171268", "0.7171268", "0.7102057", "0.7068277", "0.7033859", "0.7033859", "0.694694", "0.69351727", "0.68741876", "0.68689406", "0.68521154", "0.6838455", "0.6769694", "0.6747497", "0.66983867", "0.66889864", "0.66092294", "0.65870005", "0.65728...
0.5912657
91
DELETE /friendships/1 DELETE /friendships/1.json
def destroy @friendship = Friendship.where(friend_id: [current_user, params[:id]]).where(user_id: [current_user, params[:id]]).last @friendship.destroy flash[:notice] = "Removed friendship." redirect_to :back end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @friendship = @user.friendships.find(params[:id])\n @friendship.destroy\n\n respond_to do |format|\n format.html { redirect_to game_user_friendships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @friendship = Friendship.find(params[:id])\n @frien...
[ "0.82213545", "0.8085286", "0.7987493", "0.78764236", "0.77679914", "0.7734046", "0.7714994", "0.7688572", "0.76853836", "0.7672835", "0.7641123", "0.7634573", "0.76024175", "0.75810933", "0.7569731", "0.7563636", "0.7549181", "0.7496315", "0.7490295", "0.74828875", "0.747877...
0.72315925
32
Runs psql on the application database
def psql_on_app_db(*args) psql_on_db(fetch(:pg_database), *args) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def psql_db_command__cli psql_db\n psql_db_command__program \"psql\", psql_db\n end", "def psql\n uri = generate_ingress_uri(\"Connecting\")\n ENV[\"PGPASSWORD\"] = uri.password\n ENV[\"PGSSLMODE\"] = 'require'\n system \"psql -U #{uri.user} -h #{uri.host} -p #{uri.port || 5432} #...
[ "0.8087017", "0.79908466", "0.7861306", "0.7557225", "0.7508216", "0.7504287", "0.74906385", "0.7336784", "0.71099037", "0.70515144", "0.70318145", "0.6965342", "0.69645697", "0.69596624", "0.6959588", "0.6936609", "0.69263273", "0.69022125", "0.6888391", "0.6866571", "0.6842...
0.7949116
2
NOTE: This resource override this method to enable 'prerelease' option.
def installed_gems gems = [] cmd = [attributes.gem_binary, 'list', '-l'] cmd << '--prerelease' if attributes.prerelease run_command(cmd).stdout.each_line do |line| next unless /\A([^ ]+) \(([^\)]+)\)\z/ =~ line.strip name = $1 versions = $2.split(', ') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_prerelease\n fail AlreadyPreRelease if prerelease?\n @special = PRE_RELEASE.first\n end", "def prerelease=(allow_prerelease)\n super\n\n sets.each do |set|\n set.prerelease = allow_prerelease\n end\n end", "def test_prerelease?(_)\n false\n end", "def prerelea...
[ "0.761738", "0.75585824", "0.74746907", "0.74622726", "0.74336725", "0.73521996", "0.7200369", "0.6910125", "0.6895839", "0.6856355", "0.6724506", "0.67188805", "0.64286995", "0.6174856", "0.6140875", "0.6056898", "0.6005716", "0.59734905", "0.5970346", "0.591629", "0.5880574...
0.0
-1
NOTE: This resource override this method to enable 'prerelease' option.
def install! cmd = [attributes.gem_binary, 'install'] cmd << '-v' << attributes.version if attributes.version cmd << '--source' << attributes.source if attributes.source cmd << '--prerelease' if attributes.prerelease cmd << attributes.package_name run_command(cmd) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_prerelease\n fail AlreadyPreRelease if prerelease?\n @special = PRE_RELEASE.first\n end", "def prerelease=(allow_prerelease)\n super\n\n sets.each do |set|\n set.prerelease = allow_prerelease\n end\n end", "def test_prerelease?(_)\n false\n end", "def prerelea...
[ "0.761738", "0.75585824", "0.74746907", "0.74622726", "0.74336725", "0.73521996", "0.7200369", "0.6910125", "0.6895839", "0.6856355", "0.6724506", "0.67188805", "0.64286995", "0.6174856", "0.6140875", "0.6056898", "0.6005716", "0.59734905", "0.5970346", "0.591629", "0.5880574...
0.0
-1
Autocorrection note: Commas are a bit tricky to handle when the method call is embedded in another expression. Here's an example: [ first_array_value, foo(<<SQL, 123, 456, SELECT FROM db SQL ), third_array_value, ] The "internal" trailing comma is after `456`. The "external" trailing comma is after `)`. To autocorrect,...
def autocorrect(corrector, node) fix_closing_parenthesis(node, corrector) remove_internal_trailing_comma(node, corrector) if internal_trailing_comma?(node) fix_external_trailing_comma(node, corrector) if external_trailing_comma?(node) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method_with_parentheses(a, b, c = [foo,bar,baz]) hello, world = [1,2] end", "def oxford_comma(array)\n case array.length \nwhen 1\n \"#{array[0]}\"\nwhen 2\n array[0..1].join(\" and \")\nelse \n array[0...-1].join(\", \") << \", and #{array[-1]}\"\nend \nend", "def method_with_parentheses(a, b, c = [fo...
[ "0.6079559", "0.58613914", "0.56805277", "0.557694", "0.55124635", "0.54772925", "0.54640156", "0.54396343", "0.5421172", "0.54205644", "0.54122615", "0.54012287", "0.53410155", "0.5337653", "0.53240496", "0.5297174", "0.5275223", "0.5266132", "0.5261258", "0.5260041", "0.523...
0.46566343
67
Internal trailing comma helpers.
def remove_internal_trailing_comma(node, corrector) offset = internal_trailing_comma_offset_from_last_arg(node) last_arg_end_pos = node.children.last.source_range.end_pos corrector.remove( range_between( last_arg_end_pos, last_arg_end_pos + offset ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_internal_trailing_comma(node, corrector); end", "def fix_external_trailing_comma(node, corrector); end", "def internal_trailing_comma_offset_from_last_arg(node); end", "def fix_external_trailing_comma(node, corrector)\n remove_incorrect_external_trailing_comma(node, corrector)\n ...
[ "0.73561", "0.7260334", "0.6576319", "0.6483412", "0.643054", "0.6396485", "0.63734394", "0.6254184", "0.61691904", "0.61263293", "0.6093103", "0.60676634", "0.6002569", "0.59910744", "0.5957863", "0.5920374", "0.59198356", "0.5913422", "0.58791596", "0.5848203", "0.5824631",...
0.64786047
4
Returns nil if no trailing internal comma.
def internal_trailing_comma_offset_from_last_arg(node) source_after_last_arg = range_between( node.children.last.source_range.end_pos, node.loc.end.begin_pos ).source first_comma_offset = source_after_last_arg.index(',') first_new_line_offset = source_aft...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_internal_trailing_comma(node, corrector); end", "def fix_external_trailing_comma(node, corrector); end", "def internal_trailing_comma_offset_from_last_arg(node); end", "def external_trailing_comma_offset_from_loc_end(node); end", "def external_trailing_comma_offset_from_loc_end(node)\n ...
[ "0.66538316", "0.64922494", "0.6282248", "0.6195266", "0.6083423", "0.58154637", "0.58142227", "0.5728177", "0.57073337", "0.554362", "0.55080605", "0.54715925", "0.54125625", "0.531503", "0.52832735", "0.52601725", "0.5257798", "0.5227903", "0.5227903", "0.52188903", "0.5218...
0.60372514
5
External trailing comma helpers.
def fix_external_trailing_comma(node, corrector) remove_incorrect_external_trailing_comma(node, corrector) add_correct_external_trailing_comma(node, corrector) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fix_external_trailing_comma(node, corrector); end", "def remove_internal_trailing_comma(node, corrector); end", "def decommafy\n gsub(/(.+), (.+)/) { |s| \"#{$2} #{$1}\" }.strip.squeeze(' ')\n end", "def for_commas\n each_line! do |line| \n begin\n line.gsub! /,(\\S)/, ', \\1' unless...
[ "0.7552917", "0.7356879", "0.6623072", "0.6427134", "0.63881195", "0.6369861", "0.629539", "0.62850064", "0.619766", "0.61788225", "0.61788225", "0.616897", "0.6120952", "0.60886514", "0.6045351", "0.6041482", "0.60134125", "0.60090053", "0.6001239", "0.5985027", "0.5957293",...
0.69535697
2
Returns nil if no trailing external comma.
def external_trailing_comma_offset_from_loc_end(node) end_pos = node.source_range.end_pos offset = 0 limit = 20 offset += 1 while offset < limit && space?(end_pos + offset) char = processed_source.buffer.source[end_pos + offset] return unless char == ',' ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fix_external_trailing_comma(node, corrector); end", "def remove_internal_trailing_comma(node, corrector); end", "def fix_external_trailing_comma(node, corrector)\n remove_incorrect_external_trailing_comma(node, corrector)\n add_correct_external_trailing_comma(node, corrector)\n end...
[ "0.66094506", "0.639163", "0.6022985", "0.5984305", "0.5829612", "0.5722989", "0.56955314", "0.55809563", "0.5445914", "0.5388725", "0.5369245", "0.5317042", "0.5286642", "0.52648604", "0.5227699", "0.52182573", "0.5203226", "0.51562333", "0.5151491", "0.5147494", "0.51233095...
0.6077084
2
user > host > string if there is nothing else to return we always return an empty string, this way we can still examine contents and always return one thing while providing a type guarantee of some sort
def submit_command_running_host(user, command) operational_hosts = find_working_server(node['hadoop_smoke_tests']['oozie_hosts'], user) if operational_hosts.length > 0 then Chef::Log.debug('Identified live oozie server(s) ' + operational_hosts.to_s) oozie_cmd = "sudo -u #...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def host_as_string; end", "def string?; end", "def string_message2(string)\n return \"It's an empty string!\" if string.empty?\n return \"The string is nonempty.\"\n end", "def get_host_and_user(host, options = {})\n\t\thostname = host.split(\"@\").last\n\t\tif host.split(\"@\").size > 1\n\t\t\tuser =...
[ "0.607118", "0.5762099", "0.57148117", "0.5586197", "0.5565937", "0.55060035", "0.54794896", "0.54652315", "0.543942", "0.5437784", "0.53911304", "0.53879595", "0.53507036", "0.5347977", "0.5345679", "0.53218824", "0.53218824", "0.53218824", "0.53218824", "0.53218824", "0.532...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_task @task = Task.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def task_params params.require(:task).permit(:name, :completed, :due_date, :list_id) 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
Access data from Skyscanner API
def access_api(url) http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE file = File.open('bin/key.rb') request = Net::HTTP::Get.new(url) request["x-rapidapi-host"] = 'skyscanner-skyscanner-flight-search-v1.p.rapidapi.com' request["x-rapi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def darksky_response\n connect_darksky.get(\"/forecast/#{ENV[\"DARK_SKY_API_KEY\"]}/#{@lat},#{@lng}\")\n end", "def call_api\n\t\tputs \"Getting info on elected officials for zipcode: #{zip_code}\"\n\t\t@api_data_on_electeds = JSON.load RestClient.get \"https://congress.api.sunlightfoundation.com/legislators...
[ "0.70558393", "0.69722", "0.6888817", "0.6773497", "0.6737958", "0.6711474", "0.6454662", "0.6441882", "0.63703424", "0.62749696", "0.62308186", "0.6203948", "0.61992717", "0.6188404", "0.6171141", "0.61576307", "0.6157054", "0.614057", "0.6137729", "0.6122986", "0.6104", "...
0.6699131
6
Places in the Skyscanner API have codes (ex. Seattle is SEAsky), so this method gets the code of an input location
def get_place(query) url = URI("https://rapidapi.p.rapidapi.com/apiservices/autosuggest/v1.0/US/USD/en-US/?query=#{query}") response_hash = access_api(url) if response_hash == nil || response_hash["Places"] == nil || response_hash["Places"][0] == nil return nil end response_hash["Places"][0...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def location_code\n # find the closest location\n location = area || city || province\n location.post_code\n end", "def country_code\n Geocoder.search(hotel.city).first.country_code\n rescue Exception\n 'CZ'\n end", "def folio_location_code\n @folio_location_code ||= FolioLocationMap.folio...
[ "0.71984565", "0.699277", "0.6900716", "0.6583984", "0.65765077", "0.6551276", "0.6492664", "0.64570427", "0.6455546", "0.6452226", "0.6416868", "0.6409425", "0.634704", "0.63219684", "0.6320785", "0.6276958", "0.62553054", "0.62422425", "0.61639875", "0.6150625", "0.61122733...
0.0
-1
Gets flight infor from the API given an origin, destination, and departure date
def get_api(origin, destination, departure) origin = get_place(origin) destination = get_place(destination) if origin == nil || destination == nil return nil end url = URI("https://rapidapi.p.rapidapi.com/apiservices/browseroutes/v1.0/US/USD/en-US/#{origin}/#{destination}/#{departure}?inboun...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_flight_info(origin, destination, departure)\n results = []\n\n origin = origin\n destination = destination\n info_hash = get_api(origin, destination, departure)\n if info_hash == nil || info_hash[\"Quotes\"] == nil\n return nil\n end\n\n flights = info_hash[\"Quotes\"].select {|...
[ "0.7755239", "0.72202826", "0.6681299", "0.66351694", "0.6353375", "0.6337952", "0.6270033", "0.620971", "0.6158512", "0.6065435", "0.5958128", "0.5952927", "0.5847759", "0.58409935", "0.58155924", "0.57866865", "0.5785058", "0.5782224", "0.5770933", "0.57650113", "0.57246304...
0.6752187
2
This method is called when an user searches for flights. It returns a list of available flights that matches the user's search requirements
def get_flight_info(origin, destination, departure) results = [] origin = origin destination = destination info_hash = get_api(origin, destination, departure) if info_hash == nil || info_hash["Quotes"] == nil return nil end flights = info_hash["Quotes"].select {|f| f["Outbo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flights\n result = Search.search_flights(params)\n if result\n # The search gave us something so we can return it\n render json: result\n else\n # Something went wrong, return a 500 error with no body\n render status: 500, json: nil\n end\n end", "def index\n @airport_opti...
[ "0.7160793", "0.68872094", "0.68484986", "0.6648523", "0.660117", "0.65809643", "0.64967036", "0.6448672", "0.62064826", "0.6141048", "0.6119245", "0.60779566", "0.60462546", "0.6035941", "0.6032133", "0.6000965", "0.59988606", "0.59874356", "0.5937424", "0.5937424", "0.59246...
0.6737343
3
For duplicate bot names xcode server appends a version bot_short_name_v, bot_short_name_v1, bot_short_name_v2. This method converts bot_short_name_v2 to bot_short_name_v
def bot_short_name_without_version(pr) bot_short_name(pr).sub(/_v\d*$/, '_v') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_bot_data(name_version_pairs)\n \n # Bot name and version\n bot_names = %w:bot google bing yahoo:\n bot_name, bot_version = name_version_pairs.find do |name, version|\n bot_names.any? {|bot_name| name =~ /#{bot_name}/i}\n end\n \n # Change underscores to periods in m_version\n b...
[ "0.6032906", "0.5975868", "0.5750813", "0.56735814", "0.566767", "0.56325895", "0.5545893", "0.5545356", "0.5539021", "0.5537693", "0.5537693", "0.553631", "0.5534178", "0.5471622", "0.5432231", "0.5393991", "0.5357928", "0.5324348", "0.53151774", "0.53002536", "0.52995795", ...
0.71410316
0
Returns a perthread Faraday connection for this object.
def faraday_connection(url=nil) url ||= self.root key = "faraday_connection_#{url}" return Thread.current[key] if Thread.current[key] fc = Faraday.new(:url => url) fc.headers.merge!('User-Agent' => "HyperResource #{HyperResource::VERSION}") fc.headers.merge!(self.headers || {}) if ba=self.a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connection\n @connection ||= faraday(config, logger)\n end", "def connection\n @connection ||= Faraday.new(request: { timeout: ForecastIO.timeout })\n end", "def connection\n @connection ||= begin\n Faraday.new(:url => \"http://#{configuration.server}:#{configuration.port}\"...
[ "0.79636735", "0.77740246", "0.77152866", "0.7713358", "0.771191", "0.7641407", "0.75719416", "0.7569664", "0.7567365", "0.7563825", "0.75122243", "0.7511663", "0.7486885", "0.7470939", "0.7470939", "0.7470939", "0.7470939", "0.7468041", "0.746302", "0.7435399", "0.74197364",...
0.7881973
1
returns true if the roommate can be matched with the target apartment if the apartment already has enough roommates, or was not found then return false
def match(params) if params[:address].blank? || params[:unit_id].blank? return false end listing = ResidentialListing.joins(:unit) .where(unit_id: params[:unit_id]).limit(1).first if listing && listing.roommates.count < listing.beds listing.roommates << self self.archive ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_on_union?\n for battler in $game_troop.enemies\n return true if battler.union_members.include?(self)\n end\n return false\n end", "def lives_in?(apartment)\n if apartment.instance_of? Apartment\n self.apartment_id == apartment.id\n else\n self.apartment_id == apart...
[ "0.6259441", "0.6224493", "0.6182771", "0.6085704", "0.6064661", "0.6037907", "0.6036773", "0.5942387", "0.5931027", "0.5926487", "0.588979", "0.58873963", "0.5860816", "0.58593446", "0.58416694", "0.5838149", "0.5817662", "0.58011293", "0.5799523", "0.5794673", "0.57910895",...
0.7088307
0
Used to define if user is on mobile browser
def set_variant if request.user_agent =~ /mobile|android|touch|webos|hpwos|iphone|iPhone|iPad|ipod| android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile| ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/ request.variant = :mobile else request.variant = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mobile?\n true\n end", "def mobile?\n true\n end", "def mobile?\n os_parser.mobile?\n end", "def is_mobile_browser?\n Handset.is_mobile? request.user_agent\n end", "def mobile_device?\n request.user_agent =~ /Mobile|webOS/\n end", "def mobile?\n is_mobile_de...
[ "0.85371417", "0.85371417", "0.84094566", "0.8396711", "0.832337", "0.83151054", "0.8298097", "0.8293438", "0.82398987", "0.82193995", "0.8170406", "0.8125758", "0.8065254", "0.80631113", "0.7987435", "0.7968155", "0.7968155", "0.79425377", "0.79209316", "0.7883044", "0.78702...
0.65897566
83
Makes browsers not think site is sketchy when ssl turned off. Disable this when ssl back on
def expire_hsts response.headers["Strict-Transport-Security"] = 'max-age=0' if Rails.env.production? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def disable_ssl; end", "def force_ssl; end", "def force_ssl; end", "def disable_ssl?\n # We don't need/want SSL encryption in a development environment, or when testing.\n Rails.application.config.consider_all_requests_local || !Settler[:ssl_enabled]\n end", "def force_ssl?\n @force_ssl || fals...
[ "0.77507204", "0.7514594", "0.7514594", "0.7205509", "0.70249087", "0.69658834", "0.6930055", "0.69298995", "0.6929195", "0.6895385", "0.6895385", "0.6828106", "0.6808272", "0.680173", "0.67871404", "0.6775026", "0.6684583", "0.6660892", "0.66300845", "0.6627996", "0.6572878"...
0.0
-1
OVERRIDE THE walk method
def walk puts "Hmm.. not in a mood to walk..." super # parent 'walk' method end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def walk; end", "def walk(path); end", "def walk(&block)\n instance_eval(&block)\nend", "def traverse; end", "def walk(*args) walk_direction[*args] end", "def walk(arg=true, &block)\n children do |child|\n if ch_arg = block.call(arg, child)\n child.walk(ch_arg, &block)\n ...
[ "0.86159205", "0.7257943", "0.6945841", "0.690657", "0.68776023", "0.68282384", "0.68121815", "0.67761695", "0.6702786", "0.6670141", "0.649008", "0.6403017", "0.63881236", "0.63881236", "0.6309263", "0.6281791", "0.6240909", "0.618776", "0.6152898", "0.6152898", "0.6040959",...
0.7469668
1
todo kill this unholy bastard
def id object.id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def schubert; end", "def suivre; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def anchored; end", "def formation; end", "def terpene; end", "def stderrs; end", "def berlioz; end", "def malts; end", "def verdi;...
[ "0.7300715", "0.6961342", "0.6707985", "0.6603661", "0.6501273", "0.6501273", "0.6501273", "0.6501273", "0.6310958", "0.6302909", "0.62470675", "0.61790913", "0.60912085", "0.6084346", "0.6066827", "0.6023803", "0.60004234", "0.59916234", "0.5985989", "0.5942497", "0.59388983...
0.0
-1
Accessing Helpers You can access any helper via a proxy Normal Usage: helpers.number_to_currency(2) Abbreviated : h.number_to_currency(2) Or, optionally enable "lazy helpers" by including this module: include Draper::LazyHelpers Then use the helpers with no proxy: number_to_currency(2) Defining an Interface Control acc...
def thumbnail_url company.image.url(:thumbnail) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def helper_method(*methods); end", "def helpers; end", "def helpers; end", "def helpers; end", "def helper\n @helper ||= Helpers.new\n end", "def helper\n @helper\n end", "def helper\n @helper\n end", "def helper(_method)\n ActionController::Base.helpers.met...
[ "0.6870163", "0.6750954", "0.6750954", "0.6750954", "0.61770564", "0.61659384", "0.61659384", "0.6161165", "0.6130569", "0.6075169", "0.6068408", "0.6046258", "0.60416394", "0.59921247", "0.5983012", "0.59027565", "0.58697724", "0.5852476", "0.5765426", "0.5737512", "0.573157...
0.0
-1
Takes url provided from configuration or uses default one.
def url @url || API_ENDPOINT end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_url\n @url = DEFAULT_URL\n end", "def url\n SETTINGS[:url] || raise(\"Must provide URL - please edit file\")\nend", "def url\n SETTINGS[:url] || raise(\"Must provide URL - please edit file\")\nend", "def url\n SETTINGS[:url] || raise(\"Must provide URL - please edit file\")\nend", "def defau...
[ "0.7566803", "0.7162715", "0.7162715", "0.7162715", "0.71290547", "0.71246916", "0.70323265", "0.6940115", "0.6939252", "0.6907637", "0.6903932", "0.6852857", "0.68383026", "0.677816", "0.6766529", "0.672453", "0.672453", "0.67099017", "0.668657", "0.6685845", "0.6685845", ...
0.0
-1
Takes user agent from configuration or uses default one.
def user_agent @user_agent || USER_AGENT end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_agent(value)\n value || DEFAULT_USER_AGENT\n end", "def user_agent=(name)\n @user_agent = USER_AGENT[name] || USER_AGENT['bot']\n end", "def default_user_agent\n \"#{NAME}/#{VERSION} (Ruby/#{RUBY_VERSION})\"\n end", "def user_agent (value = nil)\n\t\tif value\n\t\...
[ "0.7789162", "0.7647512", "0.75944424", "0.7565554", "0.74980295", "0.7492259", "0.73782235", "0.73752797", "0.73492205", "0.7330755", "0.7321668", "0.7213197", "0.7213197", "0.7213197", "0.7213197", "0.7213197", "0.7167967", "0.71617025", "0.71332806", "0.7111489", "0.710141...
0.7498351
5
GET /pending_titles_for_collections/1 GET /pending_titles_for_collections/1.xml
def show @pending_titles_for_collection = PendingTitlesForCollection.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @pending_titles_for_collection } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @pending_titles_for_collection = PendingTitlesForCollection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pending_titles_for_collection }\n end\n end", "def index\n @titles = Title.all\n\n respond_to do |format|\n format.html ...
[ "0.66224337", "0.6171857", "0.60159844", "0.6002106", "0.5989198", "0.59765595", "0.5956073", "0.59292525", "0.5870766", "0.5801758", "0.5762439", "0.56698865", "0.56620896", "0.5657079", "0.5618087", "0.56012654", "0.5572337", "0.5560369", "0.5515419", "0.55017984", "0.54651...
0.76067644
0
GET /pending_titles_for_collections/new GET /pending_titles_for_collections/new.xml
def new @pending_titles_for_collection = PendingTitlesForCollection.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @pending_titles_for_collection } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @pending_titles_for_collection = PendingTitlesForCollection.new(params[:pending_titles_for_collection])\n\n respond_to do |format|\n if @pending_titles_for_collection.save\n format.html { redirect_to(@pending_titles_for_collection, :notice => 'Pending titles for collection was succes...
[ "0.7340198", "0.6698009", "0.6487977", "0.6487977", "0.6338915", "0.63344646", "0.6302592", "0.6204491", "0.61571914", "0.61318904", "0.6107359", "0.60840046", "0.6073763", "0.5991754", "0.5983117", "0.596856", "0.5965386", "0.59458065", "0.59261674", "0.5911647", "0.5910516"...
0.8022603
0
POST /pending_titles_for_collections POST /pending_titles_for_collections.xml
def create @pending_titles_for_collection = PendingTitlesForCollection.new(params[:pending_titles_for_collection]) respond_to do |format| if @pending_titles_for_collection.save format.html { redirect_to(@pending_titles_for_collection, :notice => 'Pending titles for collection was successfully cre...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @pending_titles_for_collection = PendingTitlesForCollection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pending_titles_for_collection }\n end\n end", "def destroy\n @pending_titles_for_collection = PendingTitlesForCollection.find(pa...
[ "0.64246535", "0.6032576", "0.60235345", "0.57985896", "0.57985896", "0.5796414", "0.57640827", "0.5674942", "0.5299469", "0.52844536", "0.51681685", "0.5121535", "0.506433", "0.50438327", "0.5034774", "0.5027589", "0.49835685", "0.49676466", "0.49529168", "0.49442276", "0.49...
0.71977866
0
PUT /pending_titles_for_collections/1 PUT /pending_titles_for_collections/1.xml
def update @pending_titles_for_collection = PendingTitlesForCollection.find(params[:id]) respond_to do |format| if @pending_titles_for_collection.update_attributes(params[:pending_titles_for_collection]) format.html { redirect_to(@pending_titles_for_collection, :notice => 'Pending titles for coll...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @pending_titles_for_collection = PendingTitlesForCollection.find(params[:id])\n @pending_titles_for_collection.destroy\n\n respond_to do |format|\n format.html { redirect_to(pending_titles_for_collections_url) }\n format.xml { head :ok }\n end\n end", "def create\n @pendi...
[ "0.61522335", "0.6129664", "0.60747164", "0.5785209", "0.54987997", "0.54619145", "0.54216146", "0.53989446", "0.5376498", "0.53578866", "0.53578866", "0.52900726", "0.52645403", "0.5262945", "0.52607274", "0.524889", "0.5231177", "0.51963466", "0.5155735", "0.5146726", "0.51...
0.71548367
0
DELETE /pending_titles_for_collections/1 DELETE /pending_titles_for_collections/1.xml
def destroy @pending_titles_for_collection = PendingTitlesForCollection.find(params[:id]) @pending_titles_for_collection.destroy respond_to do |format| format.html { redirect_to(pending_titles_for_collections_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @collection = Collection.find(params[:id])\n @collection.destroy\n\n respond_to do |format|\n format.html { redirect_to(collections_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @collection.destroy\n \n respond_to do |format|\n format.html { red...
[ "0.66461194", "0.6643683", "0.652664", "0.65029013", "0.6434785", "0.6399988", "0.6361746", "0.6312055", "0.62628174", "0.62269086", "0.6209581", "0.6203103", "0.6188474", "0.6154162", "0.6153621", "0.6132829", "0.60946083", "0.6085051", "0.6069419", "0.60666573", "0.60491544...
0.7665983
0
retrieve the variable signified by the given key
def get(key) @variables[key.to_sym] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_var(key)\n @varset.get_var(key)\n end", "def lookup_variable(key)\n\n fexp.lookup_variable(key)\n end", "def get(key)\n @ivar.each_with_index do |ele, i|\n if ele[0] == key \n return ele[1]\n end\n end\n end", "def get(key)\n ca...
[ "0.81901985", "0.81807804", "0.79638916", "0.7495405", "0.7332101", "0.7288013", "0.72752106", "0.72457194", "0.72394663", "0.7227757", "0.7215927", "0.7200394", "0.7189667", "0.71821994", "0.71821994", "0.71821994", "0.71821994", "0.71752", "0.715803", "0.715737", "0.7129268...
0.8300684
0
cache the value at the given key
def set(key, value) @variables[key.to_sym] = value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cache(key, value)\n @cache[key] = value\n end", "def get(key)\n return -1 unless @cache.key?(key)\n val = @cache[key]\n @cache.delete(key)\n @cache[key] = val\n val\n end", "def get(key)\n @cache[key]\n end", "def write(key, value)\n @cache[key] = value\n end",...
[ "0.8036148", "0.7839654", "0.7800979", "0.7781909", "0.77546096", "0.7738186", "0.7719607", "0.76718235", "0.75820595", "0.74279547", "0.74214184", "0.73567635", "0.7320935", "0.7282958", "0.7282543", "0.72599447", "0.7238136", "0.7202605", "0.71933544", "0.71789294", "0.7178...
0.0
-1
Called after every test method runs. Can be used to tear down fixture information.
def teardown ActiveRecord::Base.clear_all_connections! #File.delete "test.sqlite" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_teardown; end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def tear...
[ "0.8024264", "0.79538834", "0.79538834", "0.7856468", "0.7844743", "0.7844743", "0.7844743", "0.7844743", "0.7844743", "0.7844743", "0.7844743", "0.7844743", "0.7833327", "0.7833327", "0.77498436", "0.7747629", "0.7747629", "0.77339005", "0.77123624", "0.7711064", "0.7711064"...
0.0
-1
outputs: true or false checks if string reads same forwards and backwards. Case, punctuation and space matter approach compare string to string reversed if they are == return true, if not return false
def palindrome?(string) string == string.reverse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def palindrome?(string)\n string_forward = string.downcase.gsub(/[^a-z]/, '')\n string_backwards = string.reverse.downcase.gsub(/[^a-z]/, '')\n \n trace \"#{string_forward} == #{string_backwards}\"\n \n return string_forward == string_backwards\nend", "def palindrome string #func param: string, name: pali...
[ "0.79321784", "0.77313983", "0.7708944", "0.76050574", "0.7598671", "0.75948185", "0.7588276", "0.75716126", "0.7568801", "0.7568801", "0.7512134", "0.74977803", "0.74938434", "0.7467358", "0.7467358", "0.7467358", "0.7437437", "0.74321866", "0.74321866", "0.74321866", "0.742...
0.72534364
65
Only allow a trusted parameter "white list" through.
def current_resource @current_resource ||= @daily end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
Write a solution that returns the first student using the built in .first method
def last_student_by_method STUDENT_NAMES.last end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first_student_by_index\n return STUDENT_NAMES[0]\n end", "def first() end", "def caar; first.first end", "def first!\n fail_not_found_if_nil(first)\n end", "def first\n self.take(1)[0]\n end", "def first\n\n wi(fetch_all({}).first)\n end", "def last_student_by_method\n ...
[ "0.7417495", "0.71234787", "0.6980102", "0.69454867", "0.6655555", "0.66220856", "0.6568655", "0.6560089", "0.6555028", "0.65499586", "0.65499586", "0.654449", "0.6537348", "0.6525055", "0.6513831", "0.65070564", "0.6489298", "0.6474413", "0.64532965", "0.6453185", "0.6429223...
0.0
-1
Write a solution that returns the first student using the built in .last method
def first_second_and_third_students STUDENT_NAMES[0..2] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def last_student_by_method\n # Write a solution that returns the first student using the built in .last method\n STUDENT_NAMES.last\n # Write a solution that returns the first student in the array student_names\nend", "def last_student_by_method\n STUDENT_NAMES.last\nend", "def first_student_by_index\n ...
[ "0.84931785", "0.75596946", "0.6802604", "0.64426154", "0.63041145", "0.63026863", "0.6296611", "0.62720156", "0.6252815", "0.6218024", "0.62082314", "0.61980546", "0.6127126", "0.60677654", "0.59795123", "0.59435636", "0.59435636", "0.59435636", "0.59276044", "0.59154654", "...
0.0
-1
Looks only in Item for existing values...
def get_matches_with_coordinates(spatial_term) Item.connection.select_all(" SELECT DISTINCT * FROM ( SELECT unnest(dcterms_spatial) spatial FROM items ) s WHERE spatial LIKE $$#{spatial_term}%, %.%, %.%$$; ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_items(item)\r\n result = false\r\n\r\n if(self.items.size > 0)\r\n self.items.each {|val|\r\n if (val.get_name == item.get_name )\r\n return true\r\n else\r\n result = false\r\n end\r\n }\r\n else\r\n result = false\r\n ...
[ "0.64816713", "0.6311854", "0.6309447", "0.6276276", "0.6270485", "0.6193428", "0.6192663", "0.61920047", "0.61767757", "0.61431456", "0.6123629", "0.6123629", "0.6083746", "0.6037851", "0.6023746", "0.6023746", "0.60172755", "0.6012829", "0.598546", "0.59571105", "0.5937355"...
0.0
-1
Define presentationspecific methods here. Helpers are accessed through `helpers` (aka `h`). You can override attributes, for example: def created_at helpers.content_tag :span, class: 'time' do object.created_at.strftime("%a %m/%d/%y") end end
def description_markdown markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, space_after_headers: true) markdown.render(description).html_safe end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def created_at_tag\n\t\th.content_tag :span, class: \"time\" do\n\t\t\th.record_time(self.created_at)\n\t\tend\n\tend", "def time_to_show\n \n end", "def helper_attr(*attrs); end", "def helpers; end", "def helpers; end", "def helpers; end", "def helper_method(*methods); end", "def generic_datetim...
[ "0.56286985", "0.5593575", "0.55797184", "0.5576006", "0.5576006", "0.5576006", "0.5482654", "0.54653054", "0.5421507", "0.5387966", "0.53863305", "0.53246915", "0.525996", "0.52592176", "0.52575964", "0.5257258", "0.52538645", "0.52440757", "0.5242184", "0.52390766", "0.5229...
0.0
-1
Find the most frequently used words in tweet
def word_frequency(params={}) # Set default options options = { tweets: [@statuses_count, 1000].min, include_rts: true, exclude_replies: true } # Combine the options the user has set options.merge!(params) result = {} # Get the tweets which will be in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_most_frequent_word(words, title_text)\n word_counts = Hash.new\n words.each { |word| word_counts[word] = title_text.scan(word).count }\n if word_counts.values.count(word_counts.values.max) == 1\n word_counts.max_by { |_, v| v }.first\n else\n nil\n end\n end", "def most_frequent...
[ "0.743616", "0.7356704", "0.7353075", "0.730467", "0.7177772", "0.7132588", "0.69952613", "0.6966138", "0.69596934", "0.6912139", "0.6850733", "0.68217", "0.68084", "0.6781514", "0.67736906", "0.674214", "0.6733017", "0.6733017", "0.6722197", "0.67166054", "0.6691303", "0.6...
0.7062237
6
Get user's timeline Constraints: Can only retrieve 200 tweets at a time Can only return up to 3200 tweets
def get_timeline(count=1000) # Max number of tweets is 3200 count = [count, 3200].min options = {} # Cache timeline array if @timeline.count < count while @timeline.count < count # Can only retrieve 200 per request options[:count] = [200, count - @timeline.cou...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_user_timeline\n statuses = client.user_timeline(user_timeline_options)\n tweets = TweetMaker.many_from_twitter(statuses, project: project, twitter_account: self, state: :posted)\n update_max_user_timeline_twitter_id(tweets.map(&:twitter_id).max)\n tweets\n # If there's an error, just skip ex...
[ "0.8009518", "0.7485785", "0.74115866", "0.73731667", "0.7330702", "0.7327903", "0.7327801", "0.72796506", "0.7266357", "0.71874326", "0.7077233", "0.69573236", "0.6955059", "0.6920676", "0.69049597", "0.6902738", "0.6894435", "0.6869847", "0.6869429", "0.6863503", "0.6852087...
0.7389189
3
Creates a logger when necessary
def logger(level = Logger::WARN) @logger ||= ::Logger.new(STDERR).tap{ |l| l.level = level } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_logger\n raise \"You should create your own `create_logger` method\"\n end", "def create_logger\n raise \"You should create your own `create_logger` method\"\n end", "def logger\n return @logger if defined?(@logger) && !@logger.nil?\n path = log_path\n FileUtils.mkdir_...
[ "0.803474", "0.803474", "0.75659746", "0.7530686", "0.75250906", "0.75250906", "0.7416804", "0.7416804", "0.7411354", "0.7348862", "0.732811", "0.7314186", "0.7291901", "0.7291901", "0.7291901", "0.7266348", "0.7250761", "0.72507596", "0.72507596", "0.72098166", "0.7208211", ...
0.0
-1
copies over all files in all child directories of the given directory name
def recursive_copy_files dirname, record_object dirs, files = recursive_find_directories_and_files(dirname) dirs.each do |dir| record_object.directory(dir) end files.each do |filename| record_object.file(filename, filename) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_directory(dir)\n output_base = dir.gsub(@template_dir.path, '').gsub(@template, @project)\n output_dir = File.join(@output_dir.path, output_base)\n FileUtils.mkdir_p(output_dir)\n\n dir = Dir.new(dir)\n files = dir.entries.reject do |d|\n /^(\\.|\\.\\.)$/.match(d)\n e...
[ "0.6704576", "0.6525706", "0.64782614", "0.64325804", "0.6427958", "0.6405296", "0.63754547", "0.62958115", "0.62958115", "0.6286263", "0.6226514", "0.6187898", "0.61308634", "0.6128939", "0.6103498", "0.6102425", "0.60642797", "0.6051927", "0.6041125", "0.60374916", "0.60316...
0.7300395
0
unpleasant... just want to return a list of relative paths of all directories and files under the specified directory. e.g. recursive_find_directories_and_files 'public' returns a recursive array of directories and a recursive array of files of everything under templates/public
def recursive_find_directories_and_files dirname base_path = self.class.lookup('ExtAdminSection').path + "/templates/" directories = [] files = [] Find.find(File.join(base_path, dirname)) do |path| if FileTest.directory?(path) directories << path.gsub(base_path, '') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_files_recursive (base_directory, relative_path)\n result = []\n directory = File.join(base_directory, relative_path)\n Dir.foreach(directory) do |file|\n relative_file = relative_path.empty? ? file : File.join(relative_path, file)\n if matchesFilt...
[ "0.7733921", "0.75378376", "0.73461735", "0.7268519", "0.7223623", "0.7180694", "0.716393", "0.7162293", "0.7156935", "0.7148352", "0.71359617", "0.7059724", "0.6997889", "0.6946407", "0.692533", "0.69166464", "0.69065464", "0.69041646", "0.6902569", "0.689898", "0.689107", ...
0.80376816
0
See README.md for instructions on how to do this
def fizzbuzz(int) if int % 3 == 0 && int % 5 == 0# if the number int is divisible by 3 "FizzBuzz" # Go fizz elsif int % 5 == 0 "Buzz" elsif int % 3 == 0 "Fizz" else int = nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main\n\n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def main; end", "def main\n end", "def run; end", "def run; end", "def run; end", "de...
[ "0.676847", "0.6704021", "0.6704021", "0.6704021", "0.6704021", "0.6704021", "0.6704021", "0.6704021", "0.66992676", "0.66937244", "0.66691405", "0.66691405", "0.66691405", "0.66691405", "0.66691405", "0.66691405", "0.66691405", "0.66691405", "0.66691405", "0.6658017", "0.665...
0.0
-1
enum status: [ :active, :inactive ] after_initialize :set_default_role, :if => :new_record?
def faculty_profile url = "https://beta.digitalmeasures.com/login/service/v4/UserSchema/USERNAME:#{self.username}/INDIVIDUAL-ACTIVITIES-Business" RestClient::Request.execute method: :get, url: url, user: 'ua/fac_reports', password: 'UA$51973' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\r\n self.status = 'inactive'\r\n end", "def set_default_status\n self['status'] = 'active' if status.blank?\n end", "def default_status\n\n self.status = \"active\"\n\n end", "def setup_role\n #get_statuses(@role)\n #set_default_status(@role)\n end", "def...
[ "0.69761795", "0.685078", "0.6814732", "0.6745931", "0.6730205", "0.6680559", "0.6677831", "0.65578294", "0.65229917", "0.6477715", "0.6403403", "0.6365772", "0.63556314", "0.6320658", "0.6269903", "0.62665474", "0.62641203", "0.6242006", "0.620122", "0.620122", "0.61797833",...
0.0
-1
Getter and Setter for all_tags vertial attribute
def all_expertises=(names) self.expertises = names.split(",").map do |name| Expertise.where(name: name.strip).first_or_create! end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tags\n attributes.fetch(:tags)\n end", "def tags\n attributes.fetch(:tags)\n end", "def tags\n normal[:tags] = Array(normal[:tags])\n normal[:tags]\n end", "def tags\n attributes[:tags] || []\n end", "def tags=(value)\n @tags = value\n...
[ "0.76836324", "0.76836324", "0.7271992", "0.7258013", "0.72539735", "0.72539735", "0.72539735", "0.70862746", "0.70862746", "0.70862746", "0.7043511", "0.7003246", "0.69912946", "0.69905454", "0.6983017", "0.69692653", "0.6951493", "0.69481623", "0.69428927", "0.6934179", "0....
0.0
-1
get input from user
def user_input(array, spaces, array2) loop do space = count_spaces(array, spaces) puts "Enter the Element: " element = gets.chomp.to_i puts "Enter the Row: " row = gets.chomp.to_i puts "Enter the Column: " column = gets.chomp.to_i check_user_input = validate_user_input(element, row, co...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_input\n\tgets\nend", "def get_input\n @input = gets.strip\n end", "def get_input\n input = gets\n return input\nend", "def get_input\n gets.chomp\n end", "def get_input\n #Get input from the user\nend", "def get_input(*msg)\n print *msg\n return gets.strip\n end", ...
[ "0.8503742", "0.8177774", "0.8143774", "0.81407535", "0.8119008", "0.80338013", "0.8013323", "0.80114824", "0.7979625", "0.7954935", "0.7954935", "0.7953204", "0.79311484", "0.78802246", "0.7869948", "0.7846718", "0.7845499", "0.7841442", "0.77544993", "0.7718724", "0.7696288...
0.0
-1
Background probability for smoothing reciprocal of the vocabulary size
def bg_prob @bg_prob ||= 1.0 / @size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fog\n ( words_per_sentence + percent_fog_complex_words ) * 0.4\n end", "def smoothing\n 0.9\n end", "def smoothing; end", "def weighted_probability(word)\n word = (Word === word ? word : get(word))\n\n p = BigDecimal.new(1)\n p = p * probability(word)\n p = p * fi...
[ "0.5934887", "0.59219885", "0.5647237", "0.55440354", "0.5482445", "0.54476976", "0.54346675", "0.5425954", "0.5362075", "0.5316465", "0.52989", "0.52863526", "0.5239543", "0.52330357", "0.521428", "0.5193948", "0.5147092", "0.514102", "0.51403826", "0.51118165", "0.50602597"...
0.7045096
0
Calculate tfidf vector of current LM
def tfidf(df, doc_no) @f.map_hash{|k,v|[k, v * Math.log(doc_no.to_f/df[k])]} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tf_idf\n tf.each do |tf_k, tf_v|\n idf_v = idf[tf_k]\n tfidf[tf_k] = bigdecimal(tf_v * idf_v)\n end\n tfidf\n end", "def tf_idf\n tf_idf = tf.clone\n \n tf.each_with_index do |document, index|\n document.each_pair do |term, tf_score|\n tf_idf[index][term] = tf_score *...
[ "0.798126", "0.79437655", "0.7806569", "0.74635446", "0.7404489", "0.7267545", "0.6764991", "0.66705143", "0.65834856", "0.6478042", "0.62998694", "0.6262178", "0.6251207", "0.6054367", "0.598736", "0.59813166", "0.5908296", "0.58760774", "0.58751386", "0.5846533", "0.5799435...
0.6846855
6
Note that these tests aren't totally "logical", since sometimes even when below an edge is "rec", there might not be a msgedge value between them both ways, although in real data there should be
def test_messages_per_degree_in msgs = {1 => 10.0, 2 => 13.0, 3 => 15.0} degs = {1 => 2.0, 2 => 1.0, 3 => 3.0 } msgedges = { [1,2] => 5.0, [2,3] => 6.0, [1,3] => 7.0 } r = ReciprocityHeuristics::MessagesPerDegreeDecision.new(@c, msgs, degs, msgedges, :in) assert_equal(0.0,r.result(1,2,:rec)) ass...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_delta2\n (0...@nvertex).each do |v|\n next unless @label[@in_blossom[v]] == MWMGeneral::LBL_FREE\n bd = nil\n bk = nil\n @neighb_end[v].each do |p|\n k = p / 2 # Note: floor division\n w = @endpoint[p]\n next unless @label[@in_bl...
[ "0.6005453", "0.5991491", "0.59384006", "0.59305465", "0.59227914", "0.5789905", "0.57520884", "0.57243437", "0.5677344", "0.55577505", "0.5536172", "0.5486075", "0.53705674", "0.53488326", "0.5328462", "0.5327736", "0.53127044", "0.5292778", "0.5277332", "0.5272495", "0.5269...
0.49054402
71
TODO: specify all attributes
def initialize(attr={}) super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes=(_arg0); end", "def att...
[ "0.7825243", "0.7825243", "0.7825243", "0.7825243", "0.7825243", "0.7825243", "0.7825243", "0.7825243", "0.7825243", "0.7825243", "0.7825243", "0.76181227", "0.7560538", "0.7445268", "0.7277447", "0.72428274", "0.7181552", "0.7178615", "0.7178615", "0.7141955", "0.7125239", ...
0.0
-1
simplify standard calls for grouped items
def fancytree_group_select_hash(groups, items, labelling) fancytree_grouped_hash(groups, items, nil, true, true, &labelling) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def group_by\n end", "def group_by\n\n end", "def group(*) end", "def test_it_can_group_by\n groups = FinderClass.group_by(@items.all, :merchant_id)\n assert_instance_of Hash, groups\n assert_equal 12334141, groups.keys.first\n assert_instance_of Item, groups.values.first.first\n end", "de...
[ "0.70513815", "0.70102024", "0.6850218", "0.66336715", "0.662699", "0.6593316", "0.6552576", "0.65259314", "0.6482276", "0.6470457", "0.6444053", "0.63713163", "0.63276154", "0.6320239", "0.629488", "0.62904", "0.6289883", "0.6289883", "0.6258883", "0.62257093", "0.6205847", ...
0.56624264
60
returns the state object
def state State.instance end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def state\n @state ||= getStateData()\n end", "def state\n @state\n end", "def state\n @state\n end", "def state\n @state\n end", "def state\n return @state\n end", "def state\n return @state\n end", "def state\n ...
[ "0.826833", "0.82110596", "0.8185787", "0.8098409", "0.80693305", "0.80693305", "0.80693305", "0.80693305", "0.80693305", "0.80693305", "0.80693305", "0.80693305", "0.80693305", "0.80693305", "0.8035772", "0.8031286", "0.80129564", "0.7836618", "0.78185385", "0.7783778", "0.7...
0.8412263
0
debugs a single line state
def dump_state $log.debug "State: [#{state.to_pretty_s}]" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fresh_line?; end", "def throw_away_meaningless_line\n\t\tputs \"I have no idea what you are talking about\"\n\tend", "def handle_interrupt\n if @buffer\n @buffer.pop; @buffer_info.pop; history.pop\n if @buffer.empty?\n @buffer = @buffer_info = nil\n print '[buffer empty...
[ "0.6502563", "0.6292705", "0.628994", "0.6191539", "0.6119424", "0.611095", "0.60919875", "0.60414296", "0.60414296", "0.60365564", "0.59816474", "0.59699047", "0.58610404", "0.5842884", "0.57941324", "0.57872295", "0.57872295", "0.57717514", "0.5748291", "0.57050216", "0.569...
0.0
-1
+outputs+ writes a message to stdout, in given style params: +type+ 1st column as type, i.e. "model" or "network" or "OK" +msg+ message to print +style+ coloring etc, supported: :plain (default), :err (red), :ok (green) return nil :reek:ControlParameter
def outputs(type, msg, style = :plain) line = "#{type}> #{msg}" line = line.color(:red) if (style == :err) || (style == :error) line = line.color(:green) if style == :ok line = line.color(:cyan) if style == :ok2 $stdout.puts line end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def output(message, type)\n puts \"\\e[31m[ ✘ ]\\e[0m #{message}\" if type == 'error'\n puts \"\\e[32m[ ✔︎ ]\\e[0m #{message}\" if type == 'success'\n puts \"\\e[33m[ ✻ ]\\e[0m #{message}\" if type == 'info'\nend", "def output(output_type, function_to_call, text)\n case output_type\n when 'print'\n ...
[ "0.68618196", "0.6230171", "0.6153212", "0.60733795", "0.56789786", "0.5535466", "0.5526471", "0.5476224", "0.5403408", "0.5377952", "0.5364538", "0.5269248", "0.51849174", "0.51053864", "0.50737584", "0.50240326", "0.5005856", "0.50012785", "0.49898168", "0.4985931", "0.4985...
0.80354595
0
Issues a warning if we do not run as root.
def check_user (ENV['USER'] != 'root') && $log.warn("Not running as root. Make sure user #{ENV['USER']} has sudo configured.") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_root\n\t# Make sure we are running as root\n\tprint_status(\"Checking if running as root\")\n\tif Process.uid != 0\n\t\tprint_error(\"You are not running as Root!\")\n\t\texit\n\tend\n\t# Make sure we are running in Linux\n\tif not RUBY_PLATFORM =~ /linux/\n\t\tprint_error(\"This script only works in lin...
[ "0.780493", "0.73454267", "0.7260789", "0.71984434", "0.6869797", "0.6834249", "0.6689728", "0.6600954", "0.6561741", "0.6561741", "0.6329625", "0.6329625", "0.6260498", "0.62017417", "0.6184656", "0.61734325", "0.6168754", "0.61674064", "0.6135896", "0.6114755", "0.6083498",...
0.8008414
0
retrieve all objects of given +type_name+ in zone (by +zone_name+) returns: [Hash] of model subpart with elements of given type
def objects_in_zone(type_name, zone_name) return {} unless @project.element?(type_name) objects = @project.get_element type_name || {} objects.select { |_, data| data[:zone] == zone_name } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_records zone, name\n result = {}\n get_all_records_for_zone(zone).each do |rec|\n if rec['display_name'] == name && rec['zone_name'] == zone\n result[rec['rec_id']] = rec\n end\n end\n result\n end", "def get_zones_per_space_type(space_t...
[ "0.6172689", "0.5967671", "0.5880958", "0.58167666", "0.57962817", "0.5751274", "0.5671355", "0.56624", "0.5527691", "0.5517591", "0.54724646", "0.5433879", "0.5406388", "0.53829765", "0.5371321", "0.53464806", "0.5289336", "0.52161616", "0.5191744", "0.5167574", "0.5167192",...
0.8170809
0
runs the command, according to parameters
def run(params = {}) check_user @params = params target_dir = @params[:target_dir] outputs 'model', "Loading model in #{target_dir}" # load it first begin loader = ProjectYamlLoader.new @project = loader.load_project(target_dir) # try to load state file. ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_cmd(cmd)\n\tend", "def call(*command); end", "def run\n # TODO: include a parse step here and remove duplicate parsing code from\n # individual commands\n execute\n end", "def execute(command)\n end", "def run\n \n if parsed_options?\n \n process_command\n...
[ "0.7498958", "0.72768116", "0.7141079", "0.7141068", "0.7128803", "0.7120982", "0.7108249", "0.7108249", "0.710588", "0.7069291", "0.6954022", "0.689798", "0.683662", "0.6826486", "0.68045217", "0.6794529", "0.6783141", "0.67828494", "0.6730947", "0.67139554", "0.67092043", ...
0.0
-1
if the hostip is not in cidr, take netmask from network entry, add to hostip params: +host_ip+ i.e. 192.168.10.1 +network_data+ network data object, to take netmask from :network element
def ensure_hostip_netmask(host_ip, network_data) return host_ip if host_ip =~ /[0-9\.]+\/[0-9]+/ match_data = network_data[:network].match(/[0-9\.]+(\/[0-9]+)/) if match_data && match_data.size >= 2 netmask = match_data[1] $log.debug "Adding netmask #{netmask} to host-ip #{host_ip}" ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ip_address_with_mask\n ip_address.try(:to_cidr_s)\n end", "def ceph_chef_ip4_address_in_network?(ip, params, net)\n net.contains?(ip) && params.key?('broadcast')\nend", "def to_hash\n { :ip => ip, :netmask => netmask, :dhcp => dhcp && dhcp.to_hash }\n end", "def public_networks(vm, host)\n if h...
[ "0.6610428", "0.6489781", "0.6386799", "0.6386183", "0.6321903", "0.6316563", "0.6316563", "0.6316563", "0.63136715", "0.63136715", "0.6311166", "0.6310188", "0.61975545", "0.619664", "0.619315", "0.6119273", "0.6112274", "0.6084", "0.60741794", "0.6013554", "0.6011348", "0...
0.7490174
0
brings given +resource+ up by first asking if its up?. If not, call up. Writes states, outputs state Params: ++resource++: Resource object, i.e. BridgeResource ++resource_type++: Resource type symbol, i.e. :bridge ++resource_desc_str++: Description to dump out ++action++: one of :up, :down
def default_handle_resource(resource, resource_type, resource_desc_str, action) question = "#{action}?".to_sym output_method = action.to_s.upcase b_ok = false if resource.send(question) outputs output_method, "#{resource_desc_str} is already #{action}.", :ok2 b_ok = true ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resource_up_to_date(resource, action)\n end", "def write_state; end", "def write_state; end", "def resource_up_to_date(resource, action)\n # Output should be green\n resource_exec_time = Time.now.to_f - @resource_start_time\n puts(\" * #{resource} action #{action} (#{resource_e...
[ "0.53463274", "0.53279054", "0.53279054", "0.5235199", "0.5199008", "0.50577784", "0.4879761", "0.48723653", "0.48373997", "0.48145252", "0.47215512", "0.466328", "0.46412644", "0.4620697", "0.4590165", "0.45880732", "0.4572563", "0.4561162", "0.4553633", "0.45457792", "0.453...
0.5030616
6
Save state to state file
def handle_state_save # dump state $log.debug? && dump_state state.save rescue => save_exception $stderr.puts "Error saving state, #{save_exception}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save\n unless @changed\n $log.debug 'Not saving state, nothing changed'\n return\n end\n statefile_filename = state_filename\n $log.debug \"Saving state to #{statefile_filename}\"\n File.open(statefile_filename, 'w') do |file|\n file.puts state.to_yaml\n end\n...
[ "0.8436714", "0.80099565", "0.77985626", "0.77079767", "0.76682717", "0.75443655", "0.7537573", "0.75125355", "0.7470928", "0.73353136", "0.73316574", "0.7287358", "0.72498256", "0.7111642", "0.7111642", "0.710118", "0.69295853", "0.6876762", "0.6810497", "0.66786224", "0.667...
0.7153497
13
Load state from state file
def handle_state_load state.load # dump state $log.debug? && dump_state rescue => load_exception $stderr.puts "Error loading state, #{load_exception}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load\n statefile_filename = state_filename\n if File.exist?(statefile_filename) &&\n File.file?(statefile_filename) &&\n File.readable?(statefile_filename)\n $log.debug \"Loading state from #{statefile_filename}\"\n @state = YAML.load_file(statefile_filename)\n el...
[ "0.86065936", "0.78259504", "0.7684779", "0.76419115", "0.75507987", "0.7448075", "0.73067254", "0.7291862", "0.72396487", "0.7177205", "0.69696045", "0.685984", "0.6802772", "0.66884595", "0.66826123", "0.6490105", "0.6473069", "0.63723713", "0.6321882", "0.6321882", "0.6242...
0.7353019
6
Invoke `Puppet::Util::Execution.execpipe` or `Puppet::Util.execpipe` depending on which one is available first.
def execpipe(command, *args) # Puppet 2.7 would join with '', but we wish ' ' (spaces) between args.. command_str = command.respond_to?(:join) ? command.join(' ') : command execpipe_method.call(command_str, *args) { |pipe| yield pipe } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execpipe(*args, &block)\n Puppet::Util::Execution.execpipe(*args, &block)\n end", "def execute_and_handle(command, outpipe, errpipe)\n Open3.popen3(command) do |_, stdout, stderr|\n if (outpipe)\n outpipe.call(stdout)\n end\n if (errpipe)\n errpipe.call(stderr)\n end\n end\nend", ...
[ "0.7740824", "0.66900784", "0.65256006", "0.6431327", "0.6381365", "0.63201755", "0.6295495", "0.6044728", "0.60207546", "0.59869766", "0.59764177", "0.59721446", "0.5948019", "0.58566004", "0.5829682", "0.57702047", "0.5757772", "0.57552314", "0.57509243", "0.5730948", "0.57...
0.70132226
1
Execute command via execpipe
def execute_command(command, options = {}) executor = options[:execpipe] || method(:execpipe) args = [command] args << options[:failonfail] if options.include?(:failonfail) executor.call(*args) { |pipe| yield pipe } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execpipe(*args, &block)\n Puppet::Util::Execution.execpipe(*args, &block)\n end", "def execpipe(command, *args)\n # Puppet 2.7 would join with '', but we wish ' ' (spaces) between args..\n command_str = command.respond_to?(:join) ? command.join(' ') : command\n execpipe_method.call(command_str, ...
[ "0.77262545", "0.75246894", "0.73036015", "0.70752555", "0.6978683", "0.696582", "0.6920176", "0.67703414", "0.6658321", "0.6652898", "0.66476583", "0.6608136", "0.6541804", "0.65271854", "0.6491255", "0.64883554", "0.6444634", "0.6413298", "0.64008665", "0.6369111", "0.63613...
0.6834174
7
Initialize new instance of Digest. Options ignore Instance of Ignore for filtering unwanted files. [Ignore] mark Name of digest to load. [String]
def initialize(system) @system = system #@name = (options[:name] || MASTER_NAME).to_s #@ignore = options[:ignore] @filename = system.state_file @current = Hash.new{ |h,k| h[k.to_s] = {} } @saved = Hash.new{ |h,k| h[k.to_s] = {} } read refresh end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n super('Digest')\n @auth = {}\n @nonce_count = 0\n end", "def initialize(args = {})\n @file = args[:file] if args[:file]\n @dictionary = args[:dictionary] if args[:dictionary]\n end", "def initialize(options = {})\n @filename = options[:file]\n @...
[ "0.56407833", "0.550457", "0.5480103", "0.5415661", "0.5395092", "0.5387056", "0.5344347", "0.52986795", "0.52344656", "0.52173865", "0.52146274", "0.5208754", "0.51914984", "0.51572937", "0.5148669", "0.50976306", "0.50721824", "0.5071246", "0.5058162", "0.5052383", "0.50435...
0.0
-1
Get current digest for a given ruleset.
def [](ruleset) for_ruleset(ruleset) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def digest\n @digest ||= DEFAULT_DIGEST_PROC\n end", "def digest\n metadata[:digest]\n end", "def digest\n @digest ||= Digest::MD5.hexdigest(self.attributes[self.class.config[:digest]])[0, 8]\n end", "def checksum\n source[digest_type]\n end", "def digest_algorithm\n @diges...
[ "0.6422415", "0.6124016", "0.58005303", "0.56989217", "0.56763434", "0.55076647", "0.54438806", "0.54196745", "0.5347047", "0.5261344", "0.5259442", "0.52397585", "0.52352256", "0.52296853", "0.52138984", "0.5206271", "0.5184574", "0.5152136", "0.51483107", "0.51483107", "0.5...
0.0
-1
The digest file's path. Returns [String]
def filename @filename end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def full_digest_path\n File.join(@load_path, digest_path)\n end", "def digest\n OpenSSL::Digest::SHA256.file(path).hexdigest\n end", "def digest_path\n logical_path.sub(/\\.(\\w+)$/) { |ext| \"-#{digest}#{ext}\" }\n end", "def digest\n assert_file!\n Digest::SHA256.hexdigest...
[ "0.84353316", "0.784273", "0.77747774", "0.7714625", "0.76257056", "0.72308046", "0.72152936", "0.71718234", "0.71718234", "0.71419674", "0.7078038", "0.70708966", "0.69986844", "0.69460845", "0.69339263", "0.6920491", "0.6778253", "0.67696923", "0.6723979", "0.66652054", "0....
0.0
-1
Load digest from file system. Returns nothing.
def read return unless File.exist?(filename) name = DEFAULT_NAME save = Hash.new{ |h,k| h[k.to_s] = {} } File.read(filename).lines.each do |line| if md = /^\[(\w+)\]$/.match(line) name = md[1] end if md = /^(\w+)\s+(.*?)$/.match(line) save[name][md[2...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_digest\n begin\n return MultiJson.load(File.read(digest_file))\n rescue => ex\n end\n nil\n end", "def full_digest_path\n File.join(@load_path, digest_path)\n end", "def digest\n OpenSSL::Digest::SHA256.file(path).hexdigest\n end", "def digest\n assert_file!\n ...
[ "0.7509763", "0.71726704", "0.67631865", "0.6638167", "0.6409129", "0.6257708", "0.6243191", "0.6225908", "0.61853814", "0.61248463", "0.610778", "0.59359723", "0.58980024", "0.5886368", "0.58124864", "0.57959", "0.57633674", "0.5745905", "0.57428604", "0.5612765", "0.5611491...
0.58980083
12
Refresh current digest for a given ruleset, or all rulesets if not given. Returns nothing.
def refresh(ruleset=nil) if ruleset ruleset = getruleset(ruleset) current[ruleset.name.to_s] = ruleset.watchlist.digest else system.rulesets.each do |name, ruleset| refresh(ruleset) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refresh_all!\n self.size!\n refresh_all_digests! if respond_to?(:refresh_all_digests!)\n self.mimetype!\n self\n end", "def refresh!\n self.size! if @size\n refresh_digests! if respond_to?(:refresh_all_digests!)\n self.mimetype! if @mimetype\n self\n end", "def update!(**args)\n ...
[ "0.60876817", "0.59963155", "0.56942284", "0.5297937", "0.52230185", "0.52098584", "0.5154831", "0.51115054", "0.4914319", "0.4898179", "0.4875847", "0.48039216", "0.4803158", "0.4803158", "0.47715795", "0.47472996", "0.47285643", "0.46774134", "0.4666939", "0.4639256", "0.46...
0.7610787
0
Save current digest. Returns nothing.
def save(ruleset=nil) if ruleset ruleset = getruleset(ruleset) refresh(ruleset) saved[ruleset.name.to_s] = current[ruleset.name.to_s] else refresh saved = current end dir = File.dirname(filename) FileUtils.mkdir_p(dir) unless File.directory?(dir) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save(attrs)\n sha = git.set(:blob, JSON.generate(attrs))\n cache[sha] = attrs\n sha\n end", "def digest()\n @stomach.clear\n end", "def save_fingerprint; end", "def save\n unless saved?\n # TODO: decide whether or not I should perform validations like this at\n # save-t...
[ "0.6302608", "0.61029166", "0.59499985", "0.59208614", "0.58508563", "0.5774476", "0.5729772", "0.5702607", "0.56873995", "0.5634079", "0.5624388", "0.5619198", "0.5608516", "0.5562796", "0.5557499", "0.5555946", "0.5555946", "0.5516144", "0.5500386", "0.5494229", "0.546303",...
0.0
-1
Produce the representation of the digest that is stored to disk. Returns digest file format. [String]
def to_s s = "" saved.each do |name, list| s << "[#{name}]\n" list.each do |path, id| s << "#{id} #{path}\n" end s << "\n" end s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n digest.to_s\n end", "def to_str\n digest.to_str\n end", "def digest\n digest = ''\n @entries.each { |entry| digest << entry.digest << ' ' }\n digest\n end", "def digest\n assert_file!\n Digest::SHA256.hexdigest(@name + Digest::SHA256.file(@path).to_s)\n ...
[ "0.73309547", "0.7232354", "0.69911826", "0.67054754", "0.6625343", "0.6625343", "0.6577033", "0.6571043", "0.6459126", "0.645105", "0.63078094", "0.6241654", "0.62357074", "0.6225792", "0.6085779", "0.6060816", "0.59943706", "0.59673256", "0.57750064", "0.5773684", "0.577348...
0.0
-1
Compute the sha1 identifer for a file. file path to a file Returns [String] SHA1 digest string.
def checksum(file) sha = ::Digest::SHA1.new File.open(file, 'r') do |fh| fh.each_line do |l| sha << l end end sha.hexdigest end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_sha(file)\n\n sha1 = Digest::SHA1.file file\n return sha1\n\nend", "def filehash(filepath)\n sha1 = Digest::SHA1.new\n File.open(filepath) do|file|\n buffer = ''\n # Read the file 512 bytes at a time\n while not file.eof\n file.read(512, buffer)\n s...
[ "0.7984952", "0.7977343", "0.7904093", "0.770929", "0.7503721", "0.7455953", "0.74499", "0.73907924", "0.73863614", "0.73779374", "0.73389226", "0.7332525", "0.7285815", "0.7144016", "0.7056217", "0.7051515", "0.70403475", "0.70208937", "0.7009122", "0.69825715", "0.6963639",...
0.7436912
7
Filter files. Return [Array]
def filter(files) ruleset.watchlist.filter(files) #case ruleset.ignore #when Ignore # ruleset.ignore.filter(list) #when Array # list.reject!{ |path| ignore.any?{ |ig| /^#{ig}/ =~ path } } #else # list #end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filtered(files); end", "def files_filtering files\n return files unless @file_regexp\n f = files.select do |file|\n test_name_by_date file\n end\n f\n end", "def files &filter_block\n Dir[File.join(path, '**/*')].\n rejec...
[ "0.81299305", "0.78020674", "0.728831", "0.7132304", "0.7044555", "0.68621576", "0.67525357", "0.66808456", "0.66672", "0.66672", "0.66672", "0.665902", "0.66565496", "0.6631806", "0.6571714", "0.6560126", "0.6554327", "0.6518655", "0.6500275", "0.6453005", "0.6436956", "0....
0.6783243
6
Convert a user provided cop name into a properly namespaced name
def qualified_cop_name(name, path, warn: true) badge = Badge.parse(name) print_warning(name, path) if warn && department_missing?(badge, name) return name if registered?(badge) potential_badges = qualify_badge(badge) case potential_badges.size when 0 then name # No name...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def naming_convention name=nil \n nc = name.present?? name.to_s : ref_name\n if namespace_prefix.present?\n \t nc.split(namespace_prefix).last.camelize\n else\n nc.camelize\n end\n\trescue\n\t\tnil\n end", "def normalize_name(name, prefixes); end", "def cop_name; end", "def cop_nam...
[ "0.6798634", "0.6475402", "0.6422112", "0.6422112", "0.6382555", "0.6354722", "0.6231302", "0.6202936", "0.6202936", "0.6166008", "0.61576396", "0.6155505", "0.61461794", "0.61362344", "0.61362344", "0.60818565", "0.6034994", "0.59944457", "0.5939806", "0.5938734", "0.5930882...
0.62485653
6
Changes the image encoding format to the given format
def convert!(image, format, page = nil, &block) with_minimagick(image) do |img| img.format(format.downcase, page, &block) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert(format)\n manipulate! do |img|\n img.manipulate!(:format => format.to_s.downcase)\n img = yield(img) if block_given?\n img\n end\n end", "def encode(format, options = {})\n # Sorry .jpeg lovers, I'm one of you too but the standard is jpg\n format = 'jpg' if for...
[ "0.6775238", "0.6551879", "0.6551502", "0.6479869", "0.64785403", "0.60637105", "0.60629356", "0.5990764", "0.5957139", "0.5890756", "0.5890756", "0.5874873", "0.5870444", "0.57899183", "0.57204056", "0.55888945", "0.5561051", "0.554809", "0.5545402", "0.5514534", "0.5453759"...
0.5992198
7
Adjusts the image so that its orientation is suitable for viewing.
def auto_orient!(image) with_minimagick(image) do |img| img.combine_options do |cmd| yield cmd if block_given? cmd.auto_orient end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auto_orient\n manipulate! do |img|\n img.auto_orient\n img\n end\n end", "def auto_orient\n manipulate! do |image|\n image.auto_orient\n image\n end\n end", "def auto_orient\n manipulate! do |image|\n image.tap(&:au...
[ "0.73939323", "0.7379739", "0.715688", "0.715688", "0.715688", "0.7040914", "0.68806726", "0.67864984", "0.6723834", "0.6658586", "0.6657687", "0.6636678", "0.657258", "0.65522826", "0.65070194", "0.6447372", "0.6417111", "0.6290577", "0.6143408", "0.61429507", "0.5970627", ...
0.6389364
17
Resize the image to fit within the specified dimensions while retaining the original aspect ratio. Will only resize the image if it is larger than the specified dimensions. The resulting image may be shorter or narrower than specified in either dimension but will not be larger than the specified values.
def resize_to_limit!(image, width, height) with_minimagick(image) do |img| img.combine_options do |cmd| yield cmd if block_given? cmd.resize "#{width}x#{height}>" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resize_to_fit(width, height)\n manipulate! do |image|\n resize_image image, width, height\n end\n self\n end", "def resize_to_fit(new_width, new_height)\n manipulate! do |image|\n resize_image(image,new_width,new_height)\n end\n end", "def resize_to_fi...
[ "0.7157078", "0.6980273", "0.6980273", "0.6923517", "0.68759763", "0.6855186", "0.68322396", "0.6818844", "0.6764048", "0.6756573", "0.6748155", "0.6710429", "0.66757274", "0.66586405", "0.66231066", "0.6590715", "0.65212756", "0.65105593", "0.64290017", "0.64068955", "0.6400...
0.65821445
16
Resize the image to fit within the specified dimensions while retaining the original aspect ratio. The image may be shorter or narrower than specified in the smaller dimension but will not be larger than the specified values.
def resize_to_fit!(image, width, height) with_minimagick(image) do |img| img.combine_options do |cmd| yield cmd if block_given? cmd.resize "#{width}x#{height}" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resize_to_fit(width, height)\n manipulate! do |image|\n resize_image image, width, height\n end\n self\n end", "def resize_to_fit(new_width, new_height)\n manipulate! do |image|\n resize_image(image,new_width,new_height)\n end\n end", "def resize_to_fi...
[ "0.7253364", "0.7236887", "0.7236887", "0.71547836", "0.70768404", "0.70679206", "0.70393926", "0.7013658", "0.69696355", "0.6932938", "0.692422", "0.6860192", "0.685455", "0.6853321", "0.68528944", "0.6845617", "0.68098164", "0.67742944", "0.67506015", "0.67222756", "0.67149...
0.7138835
4
Resize the image so that it is at least as large in both dimensions as specified, then crops any excess outside the specified dimensions. The resulting image will always be exactly as large as the specified dimensions. By default, the center part of the image is kept, and the remainder cropped off, but this can be chan...
def resize_to_fill!(image, width, height, gravity: "Center") with_minimagick(image) do |img| img.combine_options do |cmd| yield cmd if block_given? cmd.resize "#{width}x#{height}^" cmd.gravity gravity cmd.background "rgba(255,255,255,0.0)" # transparent cm...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def crop_to(width, height)\n # Checks that crop area is defined and crop should be done.\n if ((crop_args[0] == crop_args[2]) || (crop_args[1] == crop_args[3]))\n # If not creates default image and saves it's dimensions.\n resize_to_fill_and_save_dimensions(width, height)\n else\n args = cr...
[ "0.68701506", "0.6633877", "0.6448676", "0.6428223", "0.6349555", "0.63144773", "0.62405515", "0.6237561", "0.6201224", "0.61515635", "0.611998", "0.6087164", "0.6071363", "0.6068973", "0.6004327", "0.5983968", "0.5965916", "0.596252", "0.5954932", "0.59062386", "0.5872872", ...
0.5660056
32
Resample the image to fit within the specified resolution while retaining the original image size. The resulting image will always be the same pixel size as the source with an adjusted resolution dimensions.
def resample!(image, width, height) with_minimagick(image) do |img| img.combine_options do |cmd| yield cmd if block_given? cmd.resample "#{width}x#{height}" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resample inimage, dpi, outimage=nil\n m_begin \"resample\"\n img = get_image(inimage)\n old_dpi = (image_dpi inimage)[0]\n if old_dpi != dpi then\n if false\n out = img.resample(dpi)\n elsif \n old_dpi = (image_dpi inimage)[0]\n ratio = dpi / old_dpi\n out = im...
[ "0.73315686", "0.66412765", "0.65436137", "0.6510312", "0.6037193", "0.59971195", "0.5976486", "0.594025", "0.594025", "0.5915156", "0.589878", "0.5887346", "0.5823377", "0.5801078", "0.5773068", "0.57241505", "0.57191753", "0.5706844", "0.5696309", "0.56804866", "0.56651354"...
0.7060042
1
Crops the image to be the defined area.
def crop!(image, width, height, x_offset = 0, y_offset = 0, gravity: "NorthWest") with_minimagick(image) do |img| img.combine_options do |cmd| yield cmd if block_given? cmd.gravity gravity cmd.crop "#{width}x#{height}+#{x_offset}+#{y_offset}" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cut\n rmagick_img.crop_resized!(@x, @y, gravity)\n end", "def crop image, x0 = 0, y0 = 0, w = 100, h = 100, scale = 1\n x0 = (x0.to_f * scale).to_i\n y0 = (y0.to_f * scale).to_i\n\n w = (w.to_f * scale).to_i\n h = (h.to_f * scale).to_i\n\n image.crop \"#{ w }x#{ h }+#{ x0 }+#{ y0 }\"\n...
[ "0.7960092", "0.75075835", "0.7403351", "0.7287515", "0.72614646", "0.71835953", "0.71283257", "0.70859575", "0.6902604", "0.6901864", "0.68652666", "0.6861155", "0.68141156", "0.6794962", "0.6757118", "0.6757118", "0.6756688", "0.67533726", "0.67497224", "0.66519004", "0.663...
0.6804461
13
Returns whether the image is corrupt.
def corrupted?(image) ::MiniMagick::Tool::Identify.new do |identify| identify.verbose identify.regard_warnings identify << image.path end false rescue ::MiniMagick::Error true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def corrupt?\n checksum_invalid? || torn? || misplaced?\n end", "def image?\n return ( VALID_HEADERS.include? @hdr_reader )\n end", "def valid_file?\n if @image.size.zero?\n errors.add_to_base(\"Please enter an image filename\")\n return false\n end\n unless @image.content_type =~ /^...
[ "0.76601", "0.6581273", "0.639309", "0.62398696", "0.62134427", "0.6189678", "0.61257195", "0.61029094", "0.60986", "0.60232687", "0.6018354", "0.600338", "0.59955215", "0.5978993", "0.5978993", "0.5977392", "0.5890472", "0.5872528", "0.5862165", "0.5833997", "0.5833997", "...
0.75987995
1
Convert an image into a MiniMagick::Image for the duration of the block, and at the end return a File object.
def with_minimagick(image) image = ::MiniMagick::Image.new(image.path, image) image = image.layers.first if image.layers.any? image = image.pages.first if image.pages.any? yield image tempfile = image.instance_variable_get("@tempfile") tempfile.open if tempfile.is_a?(Tempfile) # for ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def image\n MiniMagick::Image.open(filename)\n rescue MiniMagick::Invalid\n # Proceed as if this is not an image\n nil\n end", "def process\n result = Tempfile.new([\"\", self.extension])\n result.binmode\n begin\n parameters = []\n parameters << self.path\n ...
[ "0.6476795", "0.6431595", "0.6403769", "0.624632", "0.6171707", "0.6130127", "0.6125931", "0.6103474", "0.6070471", "0.60237825", "0.5935539", "0.5934812", "0.5915493", "0.58292156", "0.5812899", "0.5803313", "0.5799282", "0.57889724", "0.5775957", "0.5737695", "0.56491673", ...
0.716071
0
Creates a copy of the file and stores it into a Tempfile. Works for any IO object that responds to `read(length = nil, outbuf = nil)`.
def _copy_to_tempfile(file) args = [File.basename(file.path, ".*"), File.extname(file.path)] if file.respond_to?(:path) tempfile = Tempfile.new(args || "image", binmode: true) IO.copy_stream(file, tempfile.path) file.rewind tempfile end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_temp_file\n copy_to_temp_file full_filename\n end", "def tempfile\n unless @tempfile\n @tempfile = Tempfile.new(binmode: true)\n @tempfile.write(@read || read_from(closest))\n @tempfile.open\n end\n @tempfile\n end", "def _copy_to_temp...
[ "0.7128775", "0.7101267", "0.71007985", "0.6872193", "0.67215997", "0.6668425", "0.6515665", "0.65132225", "0.64456445", "0.6380366", "0.63772774", "0.636504", "0.6348985", "0.6280085", "0.6248815", "0.6248815", "0.6245838", "0.62082994", "0.6204536", "0.6190656", "0.6186546"...
0.7113533
1
sum = fav1.to_i + fav2.to_i + fav3.to_i end
def age_num_conditional(age, sum, name, fav1, fav2, fav3) if age > sum "Your age of #{age} is greater than #{sum}, Which is the sum of your favorite numbers." else "Your age of #{age} is less than #{sum}, Which is the sum of your favorite numbers." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum(n1, n2, n3)\n sum = n1.to_i + n2.to_i + n3.to_i\nend", "def throwing_total\n self.rating_1 +\n self.rating_2 +\n self.rating_3 +\n self.rating_4 +\n self.rating_5\n end", "def total ( numbers )\r\n\r\n\treturn numbers.reduce(:+);\r\n\r\nend", "def total(numbers)\n\tnumbers.inject(:+)...
[ "0.7530236", "0.72090006", "0.6961947", "0.69111747", "0.6871598", "0.6805249", "0.6795286", "0.67870015", "0.67858976", "0.67758167", "0.6772888", "0.6759149", "0.67512894", "0.67399675", "0.6728632", "0.67216104", "0.671475", "0.6709539", "0.6665675", "0.66604567", "0.66483...
0.0
-1
Method called indicating if the last action called on this resource resulted in an update
def updated_by_last_action(true_or_false) super # If this file has been updated, notify our parent that a restart is required notifies :restart, parent if updated? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_failed?\n @update_failed\n end", "def is_update?(action_name)\n action_name == 'update'\n end", "def last_request_update_allowed?\n if controller.respond_to?(:last_request_update_allowed?, true)\n controller.send(:last_request_update_allowed?)\n e...
[ "0.737145", "0.7334922", "0.72912407", "0.72361237", "0.70838994", "0.7068587", "0.7057456", "0.7029689", "0.6955882", "0.69400454", "0.6897771", "0.68732005", "0.68604594", "0.6810589", "0.67881787", "0.67881787", "0.67687523", "0.6751368", "0.6747556", "0.6729108", "0.67151...
0.61363214
73
Executes a get request through the toplevel path E.g. GET '/configurations'
def get raise_method_not_available(__method__, 'is nested asset') if nested_asset? assets = client.get(asset_type) assets.map { |data| self.new_from_payload(data) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get\n Iterable.request(conf, base_path).get\n end", "def get\n Iterable.request(conf, base_path).get\n end", "def get(path)\n request 'GET', path\n end", "def get\n start { |connection| connection.request http :Get }\n end", "def get(path, params = {})\n execute :get,...
[ "0.7116817", "0.7116817", "0.6581332", "0.645376", "0.6409204", "0.63701826", "0.63603246", "0.6352381", "0.6352381", "0.6343215", "0.6315944", "0.6288807", "0.62650996", "0.62012196", "0.61863184", "0.6169241", "0.6168061", "0.61461276", "0.6134683", "0.6125529", "0.61219496...
0.0
-1
Executes a get request through the nested asset path E.g. GET 'organizations/:organization_id/relationships/configurations'
def get_nested(parent) raise_method_not_available(__method__, 'is top-level asset') unless parent_type path_options = { parent: parent } assets = client.get(asset_type, path_options) assets.map { |data| self.new_from_payload(data) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get\n Iterable.request(conf, base_path).get\n end", "def get\n Iterable.request(conf, base_path).get\n end", "def find_resource\n get params[:resource_path]\n end", "def get\n raise_method_not_available(__method__, 'is nested asset') if nested_asset?\n assets = c...
[ "0.592536", "0.592536", "0.5622692", "0.5584988", "0.553234", "0.5506897", "0.5482759", "0.5481596", "0.5470634", "0.5447618", "0.5419797", "0.5411878", "0.54080164", "0.5397069", "0.53901225", "0.5388424", "0.53845954", "0.53797907", "0.53788215", "0.5356644", "0.5354613", ...
0.5853498
2
Executes a get request through the toplevel path, with a filter query E.g. GET '/configurations?filter[name]=HP01'
def filter(filter) raise_method_not_available(__method__, 'is nested asset') if nested_asset? assets = client.get(asset_type, {}, { query: { filter: filter } }) assets.map { |data| self.new_from_payload(data) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(path='', filter=nil)\n # remove the leading slash\n path = path.gsub(/\\A\\//, '')\n\n response = if filter\n categories = filter.categories.collect { |category| category.to_text }.join(',')\n attributes = filter.entities.collect { |ent...
[ "0.57287514", "0.56234974", "0.5589436", "0.557759", "0.55742055", "0.54935116", "0.54935116", "0.54789734", "0.54483485", "0.54399866", "0.5394856", "0.5393904", "0.53897375", "0.5368242", "0.5355888", "0.5351393", "0.53512555", "0.53480357", "0.53405964", "0.5334805", "0.53...
0.0
-1
Executes a get request through the toplevel path for a specific asset E.g. GET '/configurations/1'
def find(id) data = client.get(asset_type, id: id ) self.new_from_payload(data) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get\n Iterable.request(conf, base_path).get\n end", "def get\n Iterable.request(conf, base_path).get\n end", "def show\n repo = assets_repo\n @v_asset = repo.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_asset }\...
[ "0.61289716", "0.61289716", "0.59863496", "0.5948347", "0.588085", "0.5866587", "0.5864358", "0.5836759", "0.58219635", "0.57940084", "0.57927924", "0.57643515", "0.5761471", "0.573813", "0.56652665", "0.5648515", "0.56231254", "0.5623003", "0.55960584", "0.55840176", "0.5577...
0.0
-1
Returns true if the given token matches the digest.
def authenticated?(attribute, token) digest = send("#{attribute}_digest") # no need for self.send as we're in the user model return false if digest.nil? # verify the token matches the digest BCrypt::Password.new(digest).is_password?(token) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticated?(digest, token)\n digest = send(\"#{digest}_digest\")\n # Use metaprogramming to select the appropriate token attribute based on\n # the parameter digest.\n return false if digest.nil? # Digest does not exist in the database.\n BCrypt::Password.new(digest).is_password?(token)\n ...
[ "0.7842602", "0.76165974", "0.7406353", "0.72883755", "0.71430063", "0.71426356", "0.71426356", "0.70272154", "0.69849735", "0.6905191", "0.6859699", "0.68429166", "0.68239975", "0.67971325", "0.67884177", "0.6774615", "0.6765093", "0.6751053", "0.6746409", "0.67432356", "0.6...
0.6964177
9
Sends activation mail to user
def send_activation_mail UserMailer.account_activation(self).deliver_now end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def activation_needed_email(user)\n @user = user\n @activation_url = activate_url(token: user.activation_token)\n mail to: user.email\n end", "def activation(user)\n setup_email(user)\n @subject += 'Your account has been activated!'\n @body[:url] = \"http://#{AppConfig.app_url}/\"\n end",...
[ "0.86880004", "0.8607407", "0.8602955", "0.85990465", "0.85948336", "0.8581133", "0.8540501", "0.85192513", "0.8491755", "0.8486823", "0.84819824", "0.84752727", "0.8467382", "0.84633946", "0.845698", "0.8451193", "0.8451193", "0.84333104", "0.83990425", "0.8387617", "0.83816...
0.83072007
36
Sends password reset email
def send_password_reset_email UserMailer.password_reset(self).deliver_now end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_password_reset_email\n\t\tUserMailer.password_reset(id, self.reset_token).deliver_later\n \tend", "def send_password_reset_email\r\n UserMailer.password_reset(self).deliver_now\r\n end", "def send_password_reset_email\n \t\tUserMailer.password_reset(self).deliver_now\n \tend", "def send_passwor...
[ "0.8759024", "0.8589757", "0.8561465", "0.85592717", "0.8558216", "0.8558216", "0.8552138", "0.8549339", "0.85482574", "0.8546839", "0.8533984", "0.85277253", "0.85274255", "0.85274255", "0.85274255", "0.85274255", "0.85274255", "0.85274255", "0.85274255", "0.85274255", "0.85...
0.0
-1
Activates a user's account
def activate # update_attribute(:activated, true) # update_attribute(:activated_time, Time.zone.now) update_columns(activated: true, activated_time: Time.zone.now) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def activate_user(user_id)\n post(\"/users/#{user_id}/activate\")\n end", "def activate\r\n Marketplace::Database.instance.delete_deactivated_user(self)\r\n Marketplace::Database.instance.add_user(self)\r\n Marketplace::Activity.create(Activity.USER_REACTIVATE, self, \"#{self.name} has bee...
[ "0.8075512", "0.7980131", "0.79154605", "0.7889773", "0.7766912", "0.77440095", "0.77258104", "0.76691395", "0.76311845", "0.7585787", "0.74899054", "0.74245274", "0.74215055", "0.7384791", "0.7376241", "0.73735", "0.7361487", "0.7352146", "0.7346893", "0.734675", "0.73425233...
0.0
-1