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 |
|---|---|---|---|---|---|---|
TODO(jon): Make the search form fill better than openstruct impl. Temporarily preserve most search form values. This will break if someone wants to search for "20140905" as a string :( | def set_q_for_form_values
if params[:q]
q_hash = params[:q].dup
q_hash.each do |key, value|
if value.to_s.match(/[0-9]{4}\-[0-9]{2}\-[0-9]{2}/)
q_hash[key] = DateTime.parse(value)
end
end
@q = OpenStruct.new(q_hash)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_search_for_value(inv_keys)\n\t\tregx_search = Regexp.new('[12]\\d\\d\\d')\n\t\tsearch_info = {\n\t\t\tsearch_keys: ['title','name','chapters'],\n\t\t\ttypes: inv_keys\n\t\t}\n\t\tfound_data = @helpers.make_hohoa\n\t\treturned_hash = nil\n\t\tcounter = 0\n\t\tnames_with_years = nil\t\n\n\t\treturn counter... | [
"0.544088",
"0.5350648",
"0.5284637",
"0.5179762",
"0.5178104",
"0.5176092",
"0.51591474",
"0.51563525",
"0.50769454",
"0.5036817",
"0.50316507",
"0.502441",
"0.50224274",
"0.49930757",
"0.49842748",
"0.49739656",
"0.4939908",
"0.493401",
"0.4921299",
"0.49165082",
"0.4908240... | 0.5078706 | 8 |
TODO(jon): Figure out a better way to do transforms that is easy to extend. | def transform(transforms, key, value)
split = transforms[key].split('#')
klass = eval(split[0])
method = split[1]
return klass.send(method, value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transforms; end",
"def transform; end",
"def transform\n end",
"def transformation\n end",
"def transformations; end",
"def transform(transform)\n end",
"def transform(transformation)\n end",
"def apply_custom_transformation\n end",
"def transform!\n raise NotImplementedError, \... | [
"0.8603482",
"0.8401353",
"0.82809573",
"0.8136617",
"0.79939467",
"0.7782055",
"0.7755684",
"0.77082825",
"0.734179",
"0.71710676",
"0.712064",
"0.7085596",
"0.7085596",
"0.69879735",
"0.6922067",
"0.6898412",
"0.68260807",
"0.67068833",
"0.65906334",
"0.6569768",
"0.6534104... | 0.6205526 | 34 |
GET /properties GET /properties.json | def index
@properties = Property.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @properties }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_properties()\n resp = conn.get('/users/'+name+'/props/')\n \n case resp.code.to_i\n when 200\n return JSON.parse(resp.body)\n when 404\n raise RestAuthUserNotFound.new( resp )\n else\n raise RestAuthUnknownStatus.new( rest )\n end\n end",
"def get_properties\n xm... | [
"0.75018007",
"0.7475009",
"0.746873",
"0.7341186",
"0.73298395",
"0.728888",
"0.728888",
"0.7288875",
"0.71567196",
"0.7149775",
"0.71148396",
"0.7105831",
"0.7083838",
"0.7083838",
"0.7083838",
"0.7083838",
"0.70709115",
"0.70466745",
"0.70451057",
"0.70230925",
"0.70224357... | 0.7455118 | 3 |
GET /properties/1 GET /properties/1.json | def show
@property = Property.find(params[:id])
@json = @property.to_gmaps4rails
respond_to do |format|
format.html # show.html.erb
format.json { render json: @property }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @property = Property.find(params[:id])\n\n render json: @property\n end",
"def show\n property = Property.find params[:id]\n respond_to do |format|\n format.html {}\n format.json { render :json => property}\n end\n end",
"def show\n @property = Property.find(params[:i... | [
"0.7496478",
"0.7347074",
"0.7304781",
"0.72560406",
"0.7233263",
"0.7233263",
"0.7233263",
"0.7233263",
"0.7187529",
"0.71720874",
"0.71457875",
"0.7129162",
"0.70889425",
"0.70887244",
"0.70887244",
"0.70553535",
"0.7040372",
"0.69893247",
"0.6987463",
"0.6971353",
"0.69394... | 0.65524054 | 49 |
GET /properties/new GET /properties/new.json | def new
@property = Property.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @property }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @property = Property.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @property }\n end\n end",
"def new\n @property = Property.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @property ... | [
"0.7802905",
"0.7802905",
"0.7802905",
"0.7802905",
"0.7802905",
"0.7799518",
"0.77899367",
"0.77023524",
"0.7676439",
"0.7641626",
"0.7340625",
"0.7294141",
"0.72753036",
"0.72743183",
"0.7229975",
"0.7199456",
"0.71836406",
"0.70413727",
"0.6951421",
"0.6927972",
"0.6655688... | 0.780913 | 0 |
POST /properties POST /properties.json | def create
params[:property][:price] = Money.from_string(params[:property][:price], params[:property][:currency])
params[:property][:currency] = nil
@property = Property.new(params[:property])
respond_to do |format|
if @property.save
format.html { redirect_to [:admin, @property], notice: 'Nuevo inmueble creado.' }
format.json { render json: @property, status: :created, location: [:admin, @property] }
else
format.html { render action: "new" }
format.json { render json: @property.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @property = Property.new(property_params)\n\n if @property.save\n render json: @property, status: :created, location: @property\n else\n render json: @property.errors, status: :unprocessable_entity\n end\n end",
"def property_params\n params.require(:property).permit!\n ... | [
"0.7252889",
"0.70592815",
"0.704662",
"0.7033797",
"0.7011505",
"0.6940878",
"0.69251686",
"0.69003457",
"0.68883616",
"0.68742",
"0.68607503",
"0.6831917",
"0.6831917",
"0.6831917",
"0.6831917",
"0.6831917",
"0.6831917",
"0.6831917",
"0.6801031",
"0.67961967",
"0.67936516",... | 0.0 | -1 |
PUT /properties/1 PUT /properties/1.json | def update
@property = Property.find(params[:id])
unless params[:property][:photos_attributes].nil?
params[:property][:photos_attributes].each_key { |key|
if params[:property][:photos_attributes][key.to_sym][:remove_file] == "1"
@photo = Photo.find(params[:property][:photos_attributes][key.to_sym][:id])
@photo.remove_file!
@photo.destroy
params[:property][:photos_attributes].delete(key.to_sym)
end
}
end
respond_to do |format|
if @property.update_attributes(params[:property])
format.html { redirect_to [:admin, @property], notice: 'Inmueble actualizado.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @property.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @property = Property.find(params[:id])\n\n if @property.update(property_params)\n head :no_content\n else\n render json: @property.errors, status: :unprocessable_entity\n end\n end",
"def update\n @property = Property.find(params[:id])\n\n if @property.update(params[:pro... | [
"0.71732235",
"0.71470046",
"0.70486635",
"0.69714004",
"0.6937445",
"0.6937445",
"0.6937445",
"0.6937445",
"0.6937445",
"0.6879232",
"0.68430614",
"0.6842351",
"0.6835369",
"0.6835369",
"0.6835369",
"0.6799251",
"0.6795511",
"0.6795511",
"0.67801327",
"0.67801327",
"0.678013... | 0.0 | -1 |
DELETE /properties/1 DELETE /properties/1.json | def destroy
@property = Property.find(params[:id])
property_address = @property.address
@property.destroy
respond_to do |format|
format.html do
flash[:success] = "El inmueble ubicado en #{property_address.upcase} fue eliminado correctamente."
redirect_to admin_root_path(:anchor => 'properties')
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n #@property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_... | [
"0.7364613",
"0.73575217",
"0.73575217",
"0.73561615",
"0.73561615",
"0.73491865",
"0.73491865",
"0.7317726",
"0.7288179",
"0.727353",
"0.7259411",
"0.7255245",
"0.72499126",
"0.7248999",
"0.72075725",
"0.7179407",
"0.71657205",
"0.7145741",
"0.711052",
"0.711052",
"0.711052"... | 0.65210307 | 72 |
Create a new Camapign | def create(options=nil)
valid_param?(:options, options, Hash, true)
if not options[:brand_id]
raise_invalid_request("brand_id must be provided")
end
if not options[:vertical]
raise_invalid_request("vertical must be provided")
end
if not options[:usecase]
raise_invalid_request("usecase must be provided")
end
if not options[:message_flow]
raise_invalid_request("message_flow must be provided")
end
if not options[:help_message]
raise_invalid_request("help_message must be provided")
end
if not options[:optout_message]
raise_invalid_request("optout_message must be provided")
end
perform_create(options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def camCreate _obj, _args\n \"_obj camCreate _args;\" \n end",
"def create\n @camino = Camino.new(camino_params)\n\n respond_to do |format|\n if @camino.save\n format.html { redirect_to @camino, notice: 'Camino was successfully created.' }\n format.json { render :show, status: :c... | [
"0.64293593",
"0.63894695",
"0.63406765",
"0.6328831",
"0.62295043",
"0.6181105",
"0.61537945",
"0.6140979",
"0.6105808",
"0.61028767",
"0.6064084",
"0.60603863",
"0.6033622",
"0.60092276",
"0.59952116",
"0.59749913",
"0.5955507",
"0.5954376",
"0.5927891",
"0.5922227",
"0.591... | 0.0 | -1 |
Reset all associated sheets total_response_count to nil to trigger refresh of sheet answer coverage | def reset_sheet_total_response_count
sheets.where(missing: false).update_all(response_count: nil, total_response_count: nil, percent: nil)
sheets.where(missing: true).update_all(response_count: 0, total_response_count: 0, percent: 100)
SubjectEvent.where(id: sheets.select(:subject_event_id)).update_all(
unblinded_responses_count: nil,
unblinded_questions_count: nil,
unblinded_percent: nil,
blinded_responses_count: nil,
blinded_questions_count: nil,
blinded_percent: nil
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset\n @results = @hits = @verified_hits = @total = @solr_response = @doc_ids = nil\n end",
"def reset\n @results = @hits = @verified_hits = @total = @solr_response = @doc_ids = nil\n end",
"def reset\n total_calls.clear\n total_success_calls.clear\n total_failed_cal... | [
"0.6726427",
"0.6726427",
"0.66224194",
"0.6501848",
"0.6456136",
"0.6179454",
"0.61737",
"0.6166184",
"0.6092449",
"0.6084171",
"0.6077026",
"0.6005463",
"0.5977864",
"0.5970744",
"0.59525883",
"0.59525883",
"0.5930283",
"0.5920953",
"0.5910665",
"0.5909001",
"0.59019107",
... | 0.8666964 | 0 |
Constructor which initializes only logger | def initialize
@logger = RubyConfigr::AppLogger.get_logger();
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n @log = Logging::Logger[self]\n @options = self.default_options\n end",
"def initialize\n @logger = Logging::Logger[self]\n end",
"def initialize\n @log = Logging::Logger[self]\n end",
"def initialize logger = Nacreon.log\n\t\t\tself.log = logger\n\t\tend",
"def initial... | [
"0.8202202",
"0.8191563",
"0.80274665",
"0.80038434",
"0.79815876",
"0.7904817",
"0.79038453",
"0.78801125",
"0.78716683",
"0.7868313",
"0.7838396",
"0.7796416",
"0.7783396",
"0.77636755",
"0.7743999",
"0.7734923",
"0.7669375",
"0.7668466",
"0.75839615",
"0.7573425",
"0.75410... | 0.7693135 | 16 |
GET /api/favourites curl v u admin:admin | def index
respond_to do |format|
format.json { render :json => jsonp(favourites_to_json(current_user.favourites)) }
format.xml { render :xml => favourites_to_xml(current_user.favourites) }
format.text { render :text => text_not_supported }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n end",
"def index\n authorize! :index, Spree::Favorite\n @favorites = spree_current_user.favorites\n respond_to do |format|\n format.html\n format.json { render json: @favorites }\n end\n end",
... | [
"0.7208633",
"0.71372694",
"0.7017088",
"0.6844159",
"0.6830898",
"0.6809243",
"0.67928225",
"0.678399",
"0.675279",
"0.6748336",
"0.6748336",
"0.6748336",
"0.6748336",
"0.67432666",
"0.67227274",
"0.6711299",
"0.66841656",
"0.66807073",
"0.6680474",
"0.66593146",
"0.66286314... | 0.6227884 | 53 |
POST /api/favourites?key= curl X POST v u admin:admin | def create
favourite=current_user.add_favourite(params[:key])
if favourite
respond_to do |format|
format.json { render :json => jsonp(favourites_to_json([favourite])) }
format.xml { render :xml => favourites_to_xml([favourite]) }
format.text { render :text => text_not_supported }
end
else
render_error('Favourite not found', 404)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_favorite(id)\n post \"favorites/create/#{id}\", {}\n end",
"def favorite(action, value)\n raise ArgumentError, \"Invalid favorite action provided: #{action}\" unless @@FAVORITES_URIS.keys.member?(action)\n value = value.to_i.to_s unless value.is_a?(String)\n uri = \"#{@@FAVORITES_URIS[act... | [
"0.6387259",
"0.6329252",
"0.6308692",
"0.6107945",
"0.60683686",
"0.60001296",
"0.5972972",
"0.5876344",
"0.5863978",
"0.58421916",
"0.5823987",
"0.58015203",
"0.5791557",
"0.5779967",
"0.57413447",
"0.57254255",
"0.56926626",
"0.5689076",
"0.56798154",
"0.56775385",
"0.5673... | 0.6386259 | 1 |
DELETE /api/favourites/ curl X DELETE v u admin:admin | def destroy
ok=current_user.delete_favourite(params[:id])
render_success(ok ? "Favourite deleted" : "Favourite not found")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @fav = Fav.find(params[:id])\n @fav.destroy\n\n respond_to do |format|\n format.html { redirect_to favs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @favourites = Favourite.find(params[:id])\n @favourites.destroy\n\n respond_to do |format|\n for... | [
"0.71868145",
"0.7178901",
"0.70330167",
"0.70132256",
"0.69874495",
"0.69737864",
"0.6942786",
"0.69347465",
"0.6932927",
"0.6925335",
"0.6883672",
"0.6881248",
"0.68453246",
"0.68253446",
"0.68133926",
"0.68103534",
"0.6797247",
"0.6782409",
"0.6780309",
"0.67772985",
"0.67... | 0.6968506 | 6 |
Description Sets that the notification has been seen by the user (see Notificationhas_been_seen) Mode Ajax Specific filters NotificationsControllerinitialize_notification_with_owner | def seen
if @ok
@ok = @notification.has_been_seen
end
@new_notifications = current_user.number_notifications_not_seen
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saw_notification\n current_user.notice_seen = true\n current_user.save\n end",
"def notifications_count\n notifications_count ||= self.notifications_to_show_user.where(:seen_by_user => false).count\n end",
"def show\n @notification.seen = true\n @notification.save\n end",
"def notificat... | [
"0.6892667",
"0.66317225",
"0.65939784",
"0.63638735",
"0.61339563",
"0.59575915",
"0.59058136",
"0.58849347",
"0.5855978",
"0.5805134",
"0.5784054",
"0.5756029",
"0.5728686",
"0.5715061",
"0.5695581",
"0.56925845",
"0.5641947",
"0.56171817",
"0.5608322",
"0.5569345",
"0.5559... | 0.70680195 | 0 |
Description Deletes a notification Mode Ajax Specific filters NotificationsControllerinitialize_notification_with_owner NotificationsControllerinitialize_notification_offset | def destroy
if @ok
resp = current_user.destroy_notification_and_reload(@notification.id, @offset_notifications)
if !resp.nil?
@offset_notifications = resp[:offset]
@next_notification = resp[:last]
@new_notifications = current_user.number_notifications_not_seen
@tot_notifications = current_user.tot_notifications_number
else
@error = I18n.t('activerecord.errors.models.notification.problem_destroying')
end
else
@error = I18n.t('activerecord.errors.models.notification.problem_destroying')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @notification_restriction = NotificationRestriction.find(params[:id])\n @notification_restriction.destroy\n\n respond_to do |format|\n format.html { redirect_to notification_restrictions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @admin_notification.dest... | [
"0.67668676",
"0.67038316",
"0.6692421",
"0.65806526",
"0.6568857",
"0.65445143",
"0.6529771",
"0.65158004",
"0.6507634",
"0.6472982",
"0.6446379",
"0.64380604",
"0.64301336",
"0.633237",
"0.6328472",
"0.6328472",
"0.6328472",
"0.6328472",
"0.6322939",
"0.6322049",
"0.6309058... | 0.65759385 | 4 |
Description Pagination with infinite scroll Mode Ajax Specific filters NotificationsControllerinitialize_notification_offset | def get_new_block
@notifications = current_user.notifications_visible_block @offset_notifications, NOTIFICATIONS_LOADED_TOGETHER
@offset_notifications += @notifications.length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_index_notification_by_limit_by_offset\n @notifications = Notification.order(\"updated_at desc\").limit(params[:limit]).offset(params[:offset])\n respond_to do |format|\n format.json { render json: @notifications }\n end\n end",
"def paginate_at ()\n return 8\n end",
"def initialize_... | [
"0.6507309",
"0.649626",
"0.64614606",
"0.6230897",
"0.62101585",
"0.61293805",
"0.6113088",
"0.6046998",
"0.6020789",
"0.60065055",
"0.5994652",
"0.5975834",
"0.5940254",
"0.59293747",
"0.5896611",
"0.5889158",
"0.5885517",
"0.58691007",
"0.58340436",
"0.58269864",
"0.578828... | 0.0 | -1 |
Description Reloads the notifications Mode Ajax | def reload
@notifications = current_user.notifications_visible_block 0, SETTINGS['notifications_loaded_together']
@new_notifications = current_user.number_notifications_not_seen
@offset_notifications = @notifications.length
@tot_notifications = current_user.tot_notifications_number
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notify_reloading\n notify(\"RELOADING=1\")\n end",
"def notifications\n end",
"def json_reload(notice: nil)\n self.notice(notice) if notice\n json_response 'reload'\n end",
"def update\n respond_to do |format|\n if @notification.update(notification_params)\n format.html { r... | [
"0.6492369",
"0.6262972",
"0.6181112",
"0.61580825",
"0.6157248",
"0.6097662",
"0.60796624",
"0.58724767",
"0.5869404",
"0.58647823",
"0.586097",
"0.58326864",
"0.58181334",
"0.5797232",
"0.5751939",
"0.571645",
"0.57088757",
"0.56689227",
"0.56669784",
"0.56524646",
"0.56311... | 0.5616177 | 21 |
Initializes the notifications offset | def initialize_notification_offset
@offset_notifications = (correct_integer?(params[:offset]) ? params[:offset].to_i : NOTIFICATIONS_LOADED_TOGETHER)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_notifications\n @notifications = Notification.all\n end",
"def init_position\n @init_position\n end",
"def set_notifications\n\t\t@notifications = Notification.where(reciever_id: current_user).order(\"created_at DESC\")\n\tend",
"def offset!(offset)\n @offset = offset || 0\... | [
"0.5799061",
"0.57546103",
"0.5683678",
"0.5666489",
"0.5606115",
"0.55998945",
"0.5530408",
"0.55098337",
"0.55013764",
"0.54930305",
"0.54706126",
"0.54706126",
"0.54706126",
"0.5445654",
"0.5392907",
"0.53885037",
"0.53631544",
"0.53539306",
"0.5348342",
"0.5306498",
"0.53... | 0.84568256 | 0 |
Checks if the owner of the notification is correct | def initialize_notification_with_owner
@notification_id = correct_integer?(params[:notification_id]) ? params[:notification_id].to_i : 0
@notification = Notification.find_by_id @notification_id
update_ok(!@notification.nil? && current_user.id == @notification.user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_mail_owner\n return if params[:id].blank? or @login_user.nil?\n\n begin\n owner_id = Email.find(params[:id]).user_id\n rescue\n owner_id = -1\n end\n if !@login_user.admin?(User::AUTH_MAIL) and owner_id != @login_user.id\n Log.add_check(request, '[check_mail_owner]'+request.... | [
"0.69734174",
"0.68720585",
"0.6851387",
"0.6836907",
"0.6831485",
"0.68280834",
"0.678406",
"0.67624694",
"0.67619294",
"0.67489856",
"0.6721482",
"0.671365",
"0.67074805",
"0.670104",
"0.6677937",
"0.66641307",
"0.66480726",
"0.6645395",
"0.66423506",
"0.6620568",
"0.660551... | 0.6444585 | 38 |
GET /locations/1 GET /locations/1.json GET /locations/1.xml | def show
Project.hit 4
@location = Location.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @location, callback: params[:callback] }
format.xml { render xml: @location }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locations\n get('locations')\n end",
"def locations(place)\n get :loc => place\n end",
"def index\n @api_v1_locations = Api::V1::Location.all\n respond_to do |format|\n format.html { @api_v1_locations }\n format.json { render json: {results: @api_v1_locations, message: 'Locations ha... | [
"0.76494104",
"0.7084628",
"0.7073745",
"0.7052324",
"0.6992383",
"0.6992383",
"0.6929134",
"0.68663377",
"0.6859151",
"0.6854235",
"0.6850819",
"0.6741951",
"0.674001",
"0.67131823",
"0.6699596",
"0.668567",
"0.6675169",
"0.6645048",
"0.6542486",
"0.6508795",
"0.64978045",
... | 0.64870346 | 23 |
Without a document, the document cannot be signed. Generate the document once, and then set document and recall to_token | def document
return nil if @document.nil?
@document.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def salt_document\n raise ESignatureException, 'Document salt requires timestamp ms to be set' unless @signed_at_timestamp_ms\n\n @document_salt = generate_salt\n set_document_tag :esignuniquecode, @document_salt\n @document_salt\n end",
"def create\n @document = Document.new(params[:do... | [
"0.6707589",
"0.63097113",
"0.6230448",
"0.61852044",
"0.6107902",
"0.6086259",
"0.60673976",
"0.60008085",
"0.59369826",
"0.58871096",
"0.58871096",
"0.58620447",
"0.58585876",
"0.5852365",
"0.5836483",
"0.5831261",
"0.58296484",
"0.58296484",
"0.5812042",
"0.57936126",
"0.5... | 0.0 | -1 |
Cache "now" so that digests match... TODO: figure out how we might want to expire this cache... | def now
@now ||= Time.now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def now\n cache\n end",
"def now\n cache\n end",
"def now\n cache\n end",
"def expires_now; end",
"def cache_valid_from\n if caching_enabled?\n @cache_valid_from ||= Time.now\n else\n invalidate_cache!\n end\n @cache_vali... | [
"0.7746037",
"0.7746037",
"0.77393186",
"0.6729138",
"0.65105015",
"0.64688563",
"0.62893474",
"0.62785625",
"0.62239736",
"0.6201604",
"0.6172106",
"0.6172106",
"0.61532724",
"0.61470747",
"0.60668766",
"0.6062118",
"0.6062118",
"0.6048711",
"0.60390973",
"0.5999325",
"0.599... | 0.59951276 | 21 |
Updates the last visited | def last_visited
Deck.find(params[:id]).update_attribute(:last_visited, DateTime.now)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visited\n self.visited_at = Time.now\n self.save!\n end",
"def visited!\n self.count = self.count.to_i + 1\n self.last_used = Time.now\n save!\n end",
"def visit\n self.update(last_visit: DateTime.now);\n self.update(visit_count: (self.visit_count + 1));\n end",
"def update_... | [
"0.73839927",
"0.721183",
"0.66453266",
"0.6333308",
"0.5924842",
"0.5876325",
"0.58687824",
"0.58549196",
"0.58478695",
"0.5814965",
"0.57685786",
"0.56967264",
"0.56853765",
"0.5658096",
"0.565176",
"0.55385536",
"0.5486038",
"0.5485777",
"0.54771256",
"0.54714674",
"0.5465... | 0.7327326 | 1 |
Checks if the owner of the deck is visiting or it is shared | def correct_user
unless current_user.id == Deck.find(params[:id]).user_id or Deck.find(params[:id]).share == true
flash[:error] = "You do not have permission to look at this deck"
redirect_to root_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def owner?(user)\n user == owner || owners.include?(user)\n end",
"def owned?\n user.present?\n end",
"def owned_by?(current_user)\n current_user && user_id == current_user.id\n end",
"def owner_of_dog?\n dog_has_owner? && current_user ? dog_owner.id == current_user.id : false\... | [
"0.68147546",
"0.6808663",
"0.6804204",
"0.67969203",
"0.6776396",
"0.67683697",
"0.6692686",
"0.6688245",
"0.6687429",
"0.66767997",
"0.6665103",
"0.6662769",
"0.6652151",
"0.6644697",
"0.66243875",
"0.6616203",
"0.65908605",
"0.6567708",
"0.6551893",
"0.6547483",
"0.6543075... | 0.6216556 | 73 |
Checks if the current user is the creator of the deck | def creator?
unless current_user.id == Deck.find(params[:id]).user_id
flash[:error] = "You do not have permission to modify this deck"
redirect_to root_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def owned?(user_to_check = current_user)\n user_to_check ? self.creator == user_to_check : false\n end",
"def creator?(object)\n current_user == object.user ? true : false\n \n end",
"def created_by?(user)\n unless user.nil?\n userid = user.send(BigbluebuttonRails.configuration.user_attr_id)\... | [
"0.77848387",
"0.77739817",
"0.7398696",
"0.73590356",
"0.7240787",
"0.7201834",
"0.7200356",
"0.71779436",
"0.7176693",
"0.7141878",
"0.7140763",
"0.7075012",
"0.70477724",
"0.70252395",
"0.7017225",
"0.69944763",
"0.6974815",
"0.6963963",
"0.6956399",
"0.6948928",
"0.691777... | 0.82552415 | 0 |
TODO: check the order. there must be a mistake! | def show
@preliminaries = Match.preliminary.group_by { |m| m.group.to_s }.sort_by { |group, m| group }
@finals = Match.final.group_by { |m| m.round }
@tips = current_user.tips
@user = current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def suivre; end",
"def refutal()\n end",
"def offences_by; end",
"def formation; end",
"def verdi; end",
"def operations; end",
"def operations; end"... | [
"0.747789",
"0.6767733",
"0.6710782",
"0.64697677",
"0.64697677",
"0.64697677",
"0.64697677",
"0.6323662",
"0.61580604",
"0.609032",
"0.60478675",
"0.6039025",
"0.59935194",
"0.59935194",
"0.59913284",
"0.59497976",
"0.59312123",
"0.59312123",
"0.5914885",
"0.58985066",
"0.58... | 0.0 | -1 |
TODO: check the order. there must be a mistake! | def edit
@user = current_user
Match.all.each do |match|
logger.info "''''''''''''''''''''''''inlcude match? #{@user.tips.select{ |t| t.match_id == match.id }.empty?}"
@user.tips.build :match => match if @user.tips.select{ |t| t.match_id == match.id }.empty?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def suivre; end",
"def refutal()\n end",
"def offences_by; end",
"def formation; end",
"def verdi; end",
"def operations; end",
"def operations; end"... | [
"0.747789",
"0.6767733",
"0.6710782",
"0.64697677",
"0.64697677",
"0.64697677",
"0.64697677",
"0.6323662",
"0.61580604",
"0.609032",
"0.60478675",
"0.6039025",
"0.59935194",
"0.59935194",
"0.59913284",
"0.59497976",
"0.59312123",
"0.59312123",
"0.5914885",
"0.58985066",
"0.58... | 0.0 | -1 |
used primarily to return a collection of comments to display on the notes/show page that does NOT contain the new | def persisted
select(&:persisted?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comments\n pull_comments\n @comments_list\n end",
"def comments\n c = Comment.where(:resource_id => self.id).all\n if c\n return c\n end\n end",
"def show_comments\r\n @comments = Comment.find_by_sql(\"select * from comments where subject_id order by created_at DESC\")\r\n @repl... | [
"0.7203484",
"0.7025203",
"0.6994349",
"0.696327",
"0.69566864",
"0.6915436",
"0.68940264",
"0.6866209",
"0.6836639",
"0.6799224",
"0.6791873",
"0.6772854",
"0.6772854",
"0.673972",
"0.6733322",
"0.67041814",
"0.66987246",
"0.6682594",
"0.66804934",
"0.66804934",
"0.6663787",... | 0.0 | -1 |
for correct ordering TODO (vl): refactor this | def similar_ids=(similar_ids = [])
similar_ids.each_with_index do |id, index|
similar_courses.find_by(similar_id: id).try(:update_column, :position, index + 1)
end
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def order; end",
"def order; end",
"def original_order\n end",
"def ordered_values; end",
"def arrange\n\t\t\n\tend",
"def offences_by; end",
"def order=(_arg0); end",
"def entry_order; end",
"def ordered_list; end",
"def order\n end",
"def by_priority; end",
"def sort_entries; end",
... | [
"0.7231808",
"0.7231808",
"0.6543743",
"0.6360671",
"0.6334258",
"0.62163144",
"0.6199087",
"0.612103",
"0.6107077",
"0.5971253",
"0.5855722",
"0.57995784",
"0.57680655",
"0.5757197",
"0.57554954",
"0.5754048",
"0.57365704",
"0.56071424",
"0.55809206",
"0.55809206",
"0.552500... | 0.0 | -1 |
Smoke test to make sure we aren't doing any additional and unnecessary queries | def check_collection_loaded!
raise "Collection wasn't loaded?" if @collection.is_a?(ActiveRecord::Relation) && !@collection.loaded?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_single_item_result\n while_logged_in do\n with_queries do\n pass\n #assert_nothing_raised{ @conn.tasks(query:@single_page_query) }\n end\n end\n end",
"def test_for_empty_DB\n\t\tputs \"TEST 1\"\n\t\tassert( @db.empty? , \"DB is not empty\")\n\tend",
"def test_empty_resu... | [
"0.6893275",
"0.6532672",
"0.6508345",
"0.643524",
"0.6320033",
"0.6311966",
"0.63020587",
"0.62561435",
"0.6253245",
"0.62308127",
"0.61367905",
"0.6124775",
"0.60921454",
"0.6061542",
"0.6059192",
"0.60482204",
"0.5998247",
"0.5985875",
"0.59646964",
"0.5953646",
"0.5948542... | 0.0 | -1 |
App to be used | def app
@app ||= LiuLunch
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app; @app; end",
"def app; end",
"def app; end",
"def app; end",
"def app; end",
"def app; end",
"def app; end",
"def app; end",
"def app; end",
"def app; end",
"def app; end",
"def initialize(app); end",
"def main\n @app.main\n end",
"def app\n @app\n end",
"def ini... | [
"0.7370201",
"0.7216344",
"0.7216344",
"0.7216344",
"0.7216344",
"0.7216344",
"0.7216344",
"0.7216344",
"0.7216344",
"0.7216344",
"0.7216344",
"0.69914156",
"0.68465066",
"0.66528857",
"0.6635969",
"0.6575808",
"0.6565965",
"0.6470923",
"0.6467761",
"0.6439747",
"0.6424906",
... | 0.6307323 | 24 |
Rails 5.2 moved from a unary Migrator class to MigrationContext, that can be scoped to a given path. Rails 6.0 requires the schema migration object as an argument. | def migration_context
klass = ActiveRecord::MigrationContext
case klass.instance_method(:initialize).arity
when 1
klass.new(migration_path)
else
klass.new(migration_path, schema_migration)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def migration(&block)\n if caller[0].rindex(/\\/(?:[0-9]+)_([_a-z0-9]*).rb:\\d+(?::in `.*')?$/)\n m = Object.const_set $1.camelize, Class.new(ActiveRecord::Migration)\n m.class_eval(&block) # 3.1\n else\n raise ArgumentError, \"Could not create migration at: #{caller[0]}\"\n end\n end",
... | [
"0.60223454",
"0.5730504",
"0.5651764",
"0.55012083",
"0.54448247",
"0.5438543",
"0.53481907",
"0.52664554",
"0.52230257",
"0.5205954",
"0.5120648",
"0.50873554",
"0.50873554",
"0.5083134",
"0.50599277",
"0.5045491",
"0.50440073",
"0.5040061",
"0.5036226",
"0.50357646",
"0.49... | 0.6889356 | 0 |
The base class for migrations moves around a lot | def migration_class
if defined?(ActiveRecord::Migration::Compatibility)
"ActiveRecord::Migration[#{ActiveRecord::PGEnum.enabled_version}]"
else
"ActiveRecord::Migration"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def migrate\n raise NotImplementedError\n end",
"def migration\n end",
"def migrations\n raise(ArgumentError, \"Can't set migrations while using :version option\") if @using_deprecated_version_setting\n yield\n end",
"def migrate\n run_migrations pending_migrations, :up\n end",... | [
"0.80467063",
"0.779476",
"0.6900259",
"0.6781609",
"0.6747884",
"0.6635985",
"0.66356254",
"0.65382075",
"0.6526705",
"0.6520311",
"0.6506896",
"0.64863575",
"0.6481912",
"0.6462839",
"0.6438326",
"0.6438326",
"0.6419203",
"0.6377266",
"0.637397",
"0.63457024",
"0.6300016",
... | 0.0 | -1 |
Write a value array to multiple pwm ports (or a single port if the param is a hash) | def write(values)
if values.is_a? Hash # TODO: hacky - refactor
fail "wrong hash format, expected the keys 'port' and 'value'" unless values.key?(:port) && values.key?(:value)
write_to_port(values[:port], values[:value])
elsif values.is_a? Array
log.error('more values than configured lamps') && return if values.size > @ports.size
values.map! { |x| x.to_i > 255 ? 255 : x.to_i }
client.pwm_write_registers(start_index: @ports.sort.first, values: values)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_to_port(port, value)\n value = value.to_i\n @values[port.to_i] = value\n # log.debug \"write bar #{port} value #{value}\"\n client.pwm_write(@ports[port.to_i], value)\n end",
"def pwm(value)\n GPIO.write \"gpio#{@number}/value\", value\n end",
"def ports *ports\n @port... | [
"0.7004192",
"0.5874171",
"0.5744025",
"0.5642534",
"0.5557398",
"0.5477633",
"0.5468817",
"0.54197204",
"0.5395847",
"0.53791815",
"0.53435653",
"0.5329575",
"0.53013176",
"0.5265486",
"0.52597994",
"0.5255402",
"0.51564205",
"0.51431113",
"0.5107263",
"0.5103409",
"0.508473... | 0.7972539 | 0 |
Write a value to a pwm port | def write_to_port(port, value)
value = value.to_i
@values[port.to_i] = value
# log.debug "write bar #{port} value #{value}"
client.pwm_write(@ports[port.to_i], value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pwm(value)\n GPIO.write \"gpio#{@number}/value\", value\n end",
"def pwm(v)\n regdata = @@i2c.read(0x08, 1)\n @@i2c.write([0x08, regdata[0] | (1 << @id)])\n @@i2c.write([@ion, v])\n @@i2c.write([0x08, regdata[0]])\n end",
"def update(value)\n @serial_port.puts value\... | [
"0.87874556",
"0.76924926",
"0.70983934",
"0.7093962",
"0.69010884",
"0.67103577",
"0.6678591",
"0.6648178",
"0.6571475",
"0.6500164",
"0.6472061",
"0.64682066",
"0.64077723",
"0.6370701",
"0.62217563",
"0.61374813",
"0.6110579",
"0.6110504",
"0.60622525",
"0.60194933",
"0.59... | 0.8472275 | 1 |
GET /days/1 GET /days/1.xml | def show
@trip = Trip.find(params[:trip_id])
@day = Day.find(params[:id])
@unit_system = current_user ? current_user.unit_system : "IMPERIAL"
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @day }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n\t\t@directory = Directory.find(params[:id])\n\t\t@days = params[:days].blank? ? 31 : params[:days].to_i\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.xml\t{ render :xml => @directory }\n\t\tend\n\tend",
"def get(days,start_cep,end_cep)\n self.class.get(\"/api/v1/q... | [
"0.6683263",
"0.6506859",
"0.6258706",
"0.61942285",
"0.6165048",
"0.6161881",
"0.6141359",
"0.6044935",
"0.60158896",
"0.5989748",
"0.5987863",
"0.59637064",
"0.5928411",
"0.58782166",
"0.5869498",
"0.58694786",
"0.5866582",
"0.58652276",
"0.5859573",
"0.58589494",
"0.583339... | 0.0 | -1 |
GET /days/new GET /days/new.xml | def new
@trip = Trip.find(params[:trip_id])
@prev_day = @trip.days[-1]
@day = Day.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @day }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @the_day = TheDay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @the_day }\n end\n end",
"def new\n @user_day = UserDay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_day }... | [
"0.7310398",
"0.69277835",
"0.6785754",
"0.67822",
"0.6775603",
"0.6694091",
"0.65848374",
"0.65452087",
"0.64741373",
"0.64677095",
"0.6448222",
"0.64481646",
"0.64406395",
"0.63979113",
"0.63979113",
"0.63979113",
"0.63979113",
"0.63979113",
"0.6370935",
"0.63697785",
"0.63... | 0.70595556 | 1 |
PUT /days/1 PUT /days/1.xml | def update
@trip = Trip.find(params[:trip_id])
@day = Day.find(params[:id])
@day.assign(params[:day])
respond_to do |format|
if @day.save
format.html { redirect_to(trip_day_path(@trip, @day), :notice => 'Day was successfully updated.') }
format.xml { head :ok }
else
format.html { redirect_to(edit_trip_day_path(@trip, @day)) }
format.xml { render :xml => @day.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n respond_to do |format|\n if @trip.update(trip_params)\n format.html { redirect_to @trip, notice: 'Trip was successfully updated.' }\n format.jso... | [
"0.6422212",
"0.6157",
"0.6116079",
"0.6007998",
"0.5909085",
"0.5905952",
"0.5859865",
"0.57983536",
"0.578816",
"0.576036",
"0.57457757",
"0.5732893",
"0.5727385",
"0.5689735",
"0.56728023",
"0.5625911",
"0.56028223",
"0.55909604",
"0.55894",
"0.55828106",
"0.5580935",
"0... | 0.6023378 | 3 |
DELETE /days/1 DELETE /days/1.xml | def destroy
@trip = Trip.find(params[:trip_id])
@day = Day.find(params[:id])
prev_d = @day.prev_day
next_d = @day.next_day
if prev_d and next_d
prev_d.next_id = next_d.id
next_d.prev_id = prev_d.id
elsif prev_d
prev_d.next_id = nil
elsif next_d
next_d.prev_id = nil
else
# In this case we've deleted the last day
end
respond_to do |format|
if user_can_modify(@trip) and @day.destroy
prev_d.save if prev_d
next_d.save if next_d
format.html { redirect_to(trip_days_path) }
format.xml { head :ok }
format.json { head :ok }
else
flash[:error] = "It appears you attempted to delete a suggestion that you did not create. Perhaps you need to log in?"
format.html { redirect_to root_path }
format.xml { head :ok }
format.json { head :ok }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @bday = Bday.find(params[:id])\n @bday.destroy\n\n respond_to do |format|\n format.html { redirect_to(bdays_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @the_day = TheDay.find(params[:id])\n @the_day.destroy\n\n respond_to do |format|\n format.... | [
"0.67869854",
"0.67378235",
"0.669461",
"0.65612894",
"0.64693326",
"0.6444572",
"0.637604",
"0.6345075",
"0.63399255",
"0.63117194",
"0.63059914",
"0.6303592",
"0.6298902",
"0.6284396",
"0.628365",
"0.6253887",
"0.62378323",
"0.62081444",
"0.62074393",
"0.6193774",
"0.614200... | 0.0 | -1 |
Query the API server for the root device | def root_device
begin
@root_device = open('http://instance-data/latest/meta-data/block-device-mapping/root').read
rescue
message.fatal 'Could not get the root device!'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root_device_name\n data[:root_device_name]\n end",
"def root_device_type\n data[:root_device_type]\n end",
"def query_device_management\n @devices = query(\"select * from device_management \")\n end",
"def get_root\n http = Net::HTTP.start(@server_ip, @server_port)\n request... | [
"0.6693326",
"0.6457548",
"0.61086637",
"0.59151244",
"0.5870444",
"0.5663838",
"0.5659754",
"0.56459373",
"0.56307954",
"0.5594551",
"0.55858386",
"0.5581615",
"0.55655944",
"0.55509573",
"0.55283517",
"0.5521352",
"0.5515588",
"0.5510941",
"0.5438437",
"0.5416547",
"0.54066... | 0.7180721 | 0 |
Autodetect Devise scope using +Devise.default_scope+. Used to make the linkhelpers smart if like in most cases only one devise scope will be used, e.g. "user" or "account". | def auto_detect_scope(*args)
options = args.extract_options!
if options.key?(:for)
options[:scope] = options[:for]
::ActiveSupport::Deprecation.warn("DEPRECATION: " <<
"Devise scope :for option is deprecated. " <<
"Use: facebook_*_link(:some_scope), or facebook_*_link(:scope => :some_scope)")
end
scope = args.detect { |arg| arg.is_a?(Symbol) } || options[:scope] || ::Devise.default_scope
mapping = ::Devise.mappings[scope]
if mapping.for.include?(:facebook)
scope
else
error_message =
"%s" <<
" Did you forget to devise facebook_connect in your model? Like this: devise :facebook_connectable." <<
" You can also specify scope explicitly, e.g.: facebook_*link :for => :customer."
error_message %=
if scope.present?
"#{scope.inspect} is not a valid facebook devise scope. " <<
"Loaded modules for this scope: #{mapping.for.inspect}."
else
"Could not auto-detect any facebook_connectable devise scope."
end
raise error_message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_scope\n @default_scope ||= 'entitlements'\n end",
"def devise_scope(scope); end",
"def selected_scope\n (params[:scope] || :default).to_sym\n end",
"def default_search_scope\n @default_search_scope ||= default_search_scopes[controller_name.to_sym][:actions][action_name.to_sym] ... | [
"0.66070735",
"0.6594775",
"0.6593576",
"0.63586944",
"0.63586944",
"0.63369197",
"0.62723523",
"0.62362134",
"0.59804624",
"0.59734815",
"0.59291697",
"0.5908682",
"0.58899844",
"0.5889887",
"0.5889887",
"0.5771757",
"0.57378805",
"0.57091737",
"0.57091737",
"0.5700931",
"0.... | 0.73611414 | 0 |
Generate agnostic hidden sign in/out (connect) form for Facebook Connect. | def facebook_connect_form(scope, options = {})
sign_out_form = options.delete(:sign_out)
options.reverse_merge!(
:id => (sign_out_form ? 'fb_connect_sign_out_form' : 'fb_connect_sign_in_form'),
:style => 'display:none;'
)
scope = ::Devise::Mapping.find_by_path(request.path).name rescue scope
url = sign_out_form ? destroy_session_path(scope) : session_path(scope)
form_for(scope, :url => url, :html => options) { |f| }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fb_sign_out_tab\n %{\n <form action=\"/users/sign_out\" id=\"fb_connect_sign_out_form\" method=\"get\" style=\"display:none;\"></form>\n <li><a href=\"#\" onclick=\"FB.Connect.logoutAndRedirect('/users/sign_out')\"><span>Sign out</span></a></li>\n }\n end",
"def html_logout_form(cgi_dir)\n ... | [
"0.6992346",
"0.5685852",
"0.5656324",
"0.5525541",
"0.53849596",
"0.5353388",
"0.5326352",
"0.53056586",
"0.5285196",
"0.5282517",
"0.5274615",
"0.5268719",
"0.5264819",
"0.52586305",
"0.52490914",
"0.5213328",
"0.52072877",
"0.5185584",
"0.5177293",
"0.5154246",
"0.51484555... | 0.75580984 | 0 |
Test data: (;PB[Honinbo Shusaku]BR[6d]PW[Honinbo Shuwa]WR[8d]) | def test_data_hash
[{
'PB' => 'Honinbo Shusaku',
'BR' => '6d',
'PW' => 'Honinbo Shuwa',
'WR' => '8d',
'GC' => 'game from Hikaru no Go chapter 2, this version only in the anime',
'RE' => 'W+4'
}]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_DR_PDB\n data = \"DR PDB; 1NB3; X-ray; A/B/C/D=116-335, P/R/S/T=98-105.\"\n sp = SPTR.new(data)\n assert_equal([[\"1NB3\", \"X-ray\", \"A/B/C/D=116-335, P/R/S/T=98-105\"]],\n sp.dr['PDB'])\n end",
"def strand; @data[8]; end",
"def process_data(data)\n ... | [
"0.55512685",
"0.53138405",
"0.52826405",
"0.5220785",
"0.5218726",
"0.5201712",
"0.5189527",
"0.5176986",
"0.51764995",
"0.5163787",
"0.5154532",
"0.5125206",
"0.506041",
"0.5060026",
"0.5042854",
"0.50314355",
"0.50238216",
"0.49907583",
"0.49907136",
"0.4989221",
"0.496920... | 0.60254514 | 0 |
Append 'phrase' and 'translation'. If this 'phrase' already exists as key, then simply append 'translation' to the value array. | def append(phrase, translation)
phrase.strip!
translation.strip!
if @value_hash[phrase].nil?
@value_hash[phrase] = [translation]
else
@value_hash[phrase] << translation
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_translation(first, second)\r\n @dictionary[second] = first\r\n @dictionary[first] = second\r\n end",
"def add_translation(from, to)\n @dictionary[to] = from\n @dictionary[from] = to\n end",
"def add_word word #Function shovels individual strings into ... | [
"0.6549509",
"0.58722985",
"0.58677083",
"0.5681713",
"0.5624002",
"0.5559441",
"0.55037403",
"0.55037403",
"0.55036044",
"0.54069334",
"0.5338864",
"0.5314179",
"0.5296966",
"0.526507",
"0.5226372",
"0.5176444",
"0.5171205",
"0.5166237",
"0.5166237",
"0.5161603",
"0.51430196... | 0.83789486 | 0 |
Encodes this RDictCcEntry as string which is used to store entries as values of the DBM database. | def to_s
s = ""
# The results should be listed from shortest (exact) to longest match. So
# we store it that way.
ary = @value_hash.sort { |a, b| a[0].size <=> b[0].size }
ary.each do |elem|
s << "#{elem[0]}=<>"
elem[1].each do |val|
s << "#{val}:<>:"
end
s.gsub!(/:<>:$/, '#<>#')
end
s << "\n"
s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kv_encode(h); h.map {|k,v| k.to_s + \":\" + v.to_s + 10.chr }.join end",
"def to_s\n \"#<#{self.class}:0x%016x index=%d, id=%d, codec_type=:%s>\" %\n [ object_id, self[:index], self[:id], self[:codec][:codec_type] ]\n end",
"def to_json_string\n MARC::JSONLWriter.encode(self)\n ... | [
"0.61991245",
"0.6130495",
"0.60597193",
"0.60180986",
"0.59948546",
"0.5968452",
"0.5955391",
"0.5950876",
"0.5893985",
"0.5850701",
"0.57998234",
"0.57888377",
"0.57490796",
"0.5737047",
"0.57274705",
"0.56926113",
"0.56893575",
"0.56762636",
"0.5676261",
"0.5636676",
"0.56... | 0.0 | -1 |
Imports the dict.cc file given in the constructor and builds/writes the database files. | def import
read_dict_file(:langA)
write_database(:langA)
read_dict_file(:langB)
write_database(:langB)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(file)\n\t\t#Initializes superclass -- creates database.\n\t\tsuper\n\t\t#Creates tables if they not exist\n\t\tTABLES.each do |table|\n\t\t\tsql = \"CREATE TABLE IF NOT EXISTS #{table.header} (\"\n\t\t\ttable.columns.each {|column| sql += \"#{column.header} \" +\n\t\t\t\t\"#{column.type_constraint},... | [
"0.6305885",
"0.6237008",
"0.6169982",
"0.6139616",
"0.60817873",
"0.60049087",
"0.5991264",
"0.5945808",
"0.5920002",
"0.5895195",
"0.5876167",
"0.5869841",
"0.5865554",
"0.5822463",
"0.58046085",
"0.5761357",
"0.5747154",
"0.5736692",
"0.56692624",
"0.564758",
"0.5620761",
... | 0.66139275 | 0 |
Cause the CSVfile contains phrases we cannot be sure what is the most important word. This method strikes out everything between parenthesis, and if multiple words stay over, simply takes the longes one. | def extract_word( phrase )
w = phrase.gsub(/(\([^(]*\)|\{[^{]*\}|\[[^\[]*\])/, '').strip.downcase
return nil if w.empty? # No empty strings
# Now return the longest word, hoping that it's the most important, too
ary = w.gsub(/[.,\-<>]/, ' ').strip.split do |i| i.strip! end
ary.sort!{ |x,y| y.length <=> x.length }
ary[0] # The longest element is the first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_ambigious_words(file_name)\n File.open(file_name, 'w') do |f|\n sentences.each do |s|\n s.words.each do |w|\n tag_strings = w.get_correct_tags().collect { |t| t.clean_out_tag }\n f.puts w.string + \"\\t\" + tag_strings.sort.join(\"\\t\") if tag_strings.count > 1\n e... | [
"0.56514716",
"0.5527386",
"0.5458064",
"0.54185283",
"0.5280017",
"0.5211028",
"0.51405776",
"0.5105221",
"0.5092543",
"0.5079871",
"0.5069431",
"0.5043012",
"0.5033231",
"0.5020461",
"0.5016071",
"0.49755785",
"0.49654907",
"0.49645582",
"0.49581897",
"0.49507964",
"0.49314... | 0.5826419 | 0 |
Opens each database and yields the given block, handing over the data base handle. | def read_db
for file in [$dict_file_a, $dict_file_b] do
if file == $dict_file_a
puts "====================[ A => B ]===================="
else
puts "====================[ B => A ]===================="
end
DBM.open(file, nil, DBM::READER) do |dbm|
yield dbm
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def database(dbname=nil, &block)\n dbname ||= database_name\n if dbname then\n repository dbname, &block\n else\n yield\n end\n end",
"def each(&block)\n @db.each_key{|key|yield key, @db[key]}\n end",
"def open(opts)\n db = Database.new(opts)\n yield db if... | [
"0.7159878",
"0.70285666",
"0.66747665",
"0.65297025",
"0.6359071",
"0.62822795",
"0.62490904",
"0.62386113",
"0.62386113",
"0.62386113",
"0.62386113",
"0.62386113",
"0.62386113",
"0.62386113",
"0.61385626",
"0.6086385",
"0.6051412",
"0.6014187",
"0.60030675",
"0.5982554",
"0... | 0.59579825 | 20 |
Delegates queries according to query type. | def query( query )
query.downcase!
case query
when /^:r:/ then query_regexp query.gsub(/^:r:/, '')
when /^:f:/ then query_fulltext_regexp query.gsub(/^:f:/, '')
else query_simple query
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run()\n if @type.nil?\n output_available_query_types\n else\n output_query_results\n end\n end",
"def query_methods(result_type); end",
"def query(query)\n case query\n when RangeQuery\n get(\"query_range\", query.to_h)\n when SnapshotQuery\n g... | [
"0.6551042",
"0.6384838",
"0.6276502",
"0.62545526",
"0.6172853",
"0.61648154",
"0.6105809",
"0.60704255",
"0.605146",
"0.605146",
"0.6017838",
"0.6017838",
"0.599544",
"0.599323",
"0.59543794",
"0.5952474",
"0.5886743",
"0.58487505",
"0.58082247",
"0.57764053",
"0.574419",
... | 0.5101083 | 67 |
Simple hash lookup. Complexity: O(1) | def query_simple( query )
read_db do |dbm|
puts RDictCcEntry.format_str(dbm[query]) if !dbm[query].nil?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash(key); end",
"def hash(*) end",
"def my_hash_finding_method(source, thing_to_find)\n answer = Hash.new\n source.each do |key, value|\n if value == thing_to_find\n answer.store(key, value)\n end\n end\n p answer.keys\nend",
"def hash() end",
"def hash() end",
"def hash() end",
"de... | [
"0.6977181",
"0.6733928",
"0.66706455",
"0.66574436",
"0.66574436",
"0.66574436",
"0.66574436",
"0.66574436",
"0.66574436",
"0.66574436",
"0.65837216",
"0.6547274",
"0.65019864",
"0.6438475",
"0.63978076",
"0.6380903",
"0.63701254",
"0.63479716",
"0.63391304",
"0.63361657",
"... | 0.0 | -1 |
Regexp lookup. Complexity: O(n) | def query_regexp( query )
read_db do |dbm|
dbm.each_key do |key|
puts RDictCcEntry.format_str(dbm[key]) if key =~ /#{query}/
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(regexp); end",
"def match(pattern); end",
"def matching_lines(regex); end",
"def regexp; end",
"def regexp; end",
"def regexp_matcher regexp\n lambda do |string, index = 0, counts:|\n found = regexp.match(string, index)\n result_string = found.to_s\n\n if found... | [
"0.73179525",
"0.67580336",
"0.67422414",
"0.6416007",
"0.6416007",
"0.6344963",
"0.6338384",
"0.6328133",
"0.6328133",
"0.6288313",
"0.62152493",
"0.61807865",
"0.61125094",
"0.610289",
"0.6040123",
"0.6001946",
"0.6001755",
"0.5988799",
"0.5987731",
"0.5979083",
"0.5978514"... | 0.0 | -1 |
Fulltext regexp lookup. Complexity: O(n) | def query_fulltext_regexp( query )
read_db do |dbm|
dbm.each_value do |raw_val|
val = RDictCcEntry.format_str(raw_val)
match_line_found = false
val.each_line do |line|
if line =~ /^\s+/
if match_line_found
puts line
else
# Skip lines starting with blanks, because these are already
# translations and they don't belong to the matching line.
next
end
else
match_line_found = false
end
if line.downcase =~ /#{query}/
puts line
match_line_found = true
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(regexp); end",
"def match(keyword); end",
"def make_regexp\n @intent = self.intent\n regexp = self.pattern.dup.downcase\n words = regexp.split(\" \")\n words.each do |word|\n if word.include? '/'\n regexp = regexp.gsub(word,\"(#{word})\")\n\n end\n\n end\n regexp = ... | [
"0.68299747",
"0.6342473",
"0.62648624",
"0.61767787",
"0.617327",
"0.61730075",
"0.61099666",
"0.60797215",
"0.6057485",
"0.6057485",
"0.60552454",
"0.60254884",
"0.600918",
"0.5985297",
"0.5951371",
"0.59369147",
"0.59265125",
"0.59112245",
"0.59112245",
"0.58205426",
"0.57... | 0.68641853 | 0 |
Public: Add new rawdata to parser data String the request headers data Returns nothing | def <<(data)
@parser << data
@buffer << data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(data)\n\t\t\t\tif @finished # Header finished, can only be some more body\n\t\t\t\t\t@body << data\n\t\t\t\telse # Parse more header using the super parser\n\t\t\t\t\t@data << data\n\t\t\t\t\tif data =~ /\\r?\\n\\r?\\n/\n\t\t\t\t\t\theaders, @body = @data.split(/\\r?\\n\\r?\\n/,2)\n\t\t... | [
"0.6606611",
"0.63224226",
"0.6096258",
"0.58922434",
"0.5847437",
"0.5771832",
"0.57594454",
"0.5759046",
"0.5736888",
"0.5650954",
"0.56470305",
"0.5614342",
"0.56004924",
"0.5599062",
"0.5591024",
"0.5565687",
"0.55576813",
"0.55539644",
"0.5548405",
"0.5548405",
"0.554814... | 0.0 | -1 |
Public: Setup callback on headers parsing complete block Block the block of code Examples headers = HttpProxy::HeadersParser.new headers.process do |parsing_result| p parsing_result["UserAgent"] end Returns nothing | def process(&block)
@parser.on_headers_complete = block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parser_init\n @http = Http::Parser.new\n @http.on_headers_complete = proc do\n p @http.headers\n end\n @http.on_body = proc do |chunk|\n # One chunk of the body\n p chunk\n end\n\n @http.on_message_complete = proc do |env|\n # Headers and body is all pa... | [
"0.7018227",
"0.69397557",
"0.692272",
"0.66465926",
"0.65960246",
"0.6448536",
"0.61827725",
"0.61497754",
"0.61497754",
"0.61497754",
"0.61497754",
"0.60907024",
"0.59932834",
"0.596692",
"0.59114987",
"0.5881159",
"0.58745456",
"0.58024544",
"0.5777607",
"0.5706517",
"0.56... | 0.83165455 | 0 |
Change the number of columns in the main window. | def spawn_panes(num)
main.number_of_panes = num
@current_row = @current_page = 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def columns; IO.console.winsize[1] rescue 80; end",
"def columns=(n)\n @columns = n\n end",
"def columns=(integer); end",
"def ListView_SetColumnWidth(hwnd, iCol, cx)\n send_listview_message(hwnd, :SETCOLUMNWIDTH, wparam: iCol, lparam: MAKELPARAM(cx, 0))\n end",
"def switch_windows\n t... | [
"0.64864033",
"0.63125116",
"0.6250382",
"0.60696",
"0.6048492",
"0.60479534",
"0.59623027",
"0.5933511",
"0.59149873",
"0.57982916",
"0.579712",
"0.57804483",
"0.57195246",
"0.56635034",
"0.56495506",
"0.563061",
"0.56280065",
"0.56041455",
"0.55989176",
"0.55983967",
"0.558... | 0.51670164 | 81 |
Number of times to repeat the next command. | def times
(@times || 1).to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cycle_count\n put('o^')\n get.strip.to_i\n end",
"def count number\r\n number.times do\r\n number += 1\r\n end\r\nend",
"def increment_tries\n @tries += 1\n end",
"def times num\n @count = num\n self\n end",
"def repeat_yourself(word, count)\n count.... | [
"0.67411965",
"0.67273045",
"0.668447",
"0.66117305",
"0.6541622",
"0.64984715",
"0.6408484",
"0.6353681",
"0.6341251",
"0.632535",
"0.6278638",
"0.62735426",
"0.6249874",
"0.6230514",
"0.62286985",
"0.6225942",
"0.6222806",
"0.62163365",
"0.62163365",
"0.62163365",
"0.621534... | 0.6427643 | 6 |
The file or directory on which the cursor is on. | def current_item
items[current_row]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_file\n @view[@cursor]\nend",
"def current_file_path\n current_file.to_path\n end",
"def current_dir\n File.dirname(file_path)\n end",
"def current_dir; end",
"def current_file\n @path || @parent.current_file rescue nil\n end",
"def current_path\n fi... | [
"0.7390515",
"0.68972135",
"0.6853903",
"0.6800115",
"0.6719103",
"0.66615504",
"0.6481221",
"0.64487165",
"0.63464165",
"0.6289791",
"0.6285747",
"0.62845814",
"0.62453586",
"0.62375176",
"0.61845165",
"0.61819404",
"0.6158958",
"0.6149144",
"0.6148188",
"0.6145312",
"0.6099... | 0.0 | -1 |
marked files and directories. | def marked_items
items.select(&:marked?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def marks_dir\n dir \"/tmp/marks\"\n end",
"def modified_files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def test_marked\n end",
"def mark; end",
"def markerDir _args\n \"markerDir _args;\" \n end",
"def ma... | [
"0.5902551",
"0.5838147",
"0.5793395",
"0.5793395",
"0.5793395",
"0.5793395",
"0.5793395",
"0.5793395",
"0.57748294",
"0.5764185",
"0.57475203",
"0.57220906",
"0.5694817",
"0.56722283",
"0.5594392",
"0.5544779",
"0.5463387",
"0.5430009",
"0.5430009",
"0.54261637",
"0.53945386... | 0.5386966 | 22 |
Marked files and directories or Array(the current file or directory). . and .. will not be included. | def selected_items
((m = marked_items).any? ? m : Array(current_item)).reject {|i| %w(. ..).include? i.name}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def referenced_files\r\n\t\t(\r\n\t\t\t[file] +\r\n\t\t\t%w[sourcepath importfile].flat_map do |att|\r\n\t\t\t\tfind(att=>/./).flat_map do |asset|\r\n\t\t\t\t\tasset[att].values.compact.map do |path|\r\n\t\t\t\t\t\tpath.sub!(/#.+/,'')\r\n\t\t\t\t\t\tabsolute_path(path) unless path.empty?\r\n\t\t\t\t\tend.compact\r... | [
"0.5985589",
"0.5861694",
"0.58194774",
"0.57821",
"0.57643884",
"0.5762127",
"0.57152206",
"0.57152206",
"0.5693926",
"0.56917053",
"0.56917053",
"0.56917053",
"0.56917053",
"0.56917053",
"0.56917053",
"0.5686094",
"0.5632464",
"0.561607",
"0.55936986",
"0.55614895",
"0.5511... | 0.0 | -1 |
Move the cursor to specified row. The main window and the headers will be updated reflecting the displayed files and directories. The row number can be out of range of the current page. | def move_cursor(row = nil)
if row
if (prev_item = items[current_row])
main.draw_item prev_item
end
page = row / max_items
switch_page page if page != current_page
main.activate_pane row / maxy
@current_row = row
else
@current_row = 0
end
item = items[current_row]
main.draw_item item, current: true
main.display current_page
header_l.draw_current_file_info item
@current_row
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def goto_row(row)\n \n set RGhost::Cursor.goto_row(row) \n end",
"def jump_rows(row)\n @rows+=row\n set RGhost::Cursor.jump_rows(row)\n end",
"def select_row(row_number = 0)\n set_cursor(Gtk::TreePath.new(row_number), nil, false)\n end",
"def update_head_vertical_location(row)\n l... | [
"0.72010726",
"0.68817645",
"0.6806795",
"0.64135754",
"0.64131194",
"0.6307145",
"0.6255472",
"0.6245421",
"0.62252295",
"0.61407685",
"0.60533386",
"0.6020533",
"0.59794873",
"0.5968704",
"0.5912319",
"0.5890729",
"0.5836306",
"0.583052",
"0.5828907",
"0.58208406",
"0.58069... | 0.84249705 | 0 |
Change the current directory. | def cd(dir = '~', pushd: true)
dir = load_item path: expand_path(dir) unless dir.is_a? Item
unless dir.zip?
Dir.chdir dir
@current_zip = nil
else
@current_zip = dir
end
@dir_history << current_dir if current_dir && pushd
@current_dir, @current_page, @current_row = dir, 0, nil
main.activate_pane 0
ls
@current_dir
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chdir; end",
"def change_dir f\n unless File.directory? f\n perror \"#{f} is not a directory, or does not exist.\"\n return\n end\n\n # before leaving a dir we save it in the list, as well as the cursor\n # position, so we can restore that position when we return\n @visited_dirs.insert(0, Dir.pwd)... | [
"0.7232564",
"0.70640314",
"0.70472205",
"0.70143205",
"0.697366",
"0.6961057",
"0.68245286",
"0.681888",
"0.6814806",
"0.6777482",
"0.6768993",
"0.6763502",
"0.66206026",
"0.65494037",
"0.6513547",
"0.6508767",
"0.6496187",
"0.6493231",
"0.6448512",
"0.6431163",
"0.63857627"... | 0.56651044 | 59 |
cd to the previous directory. | def popd
cd @dir_history.pop, pushd: false if @dir_history.any?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cd( path = File.expand_path('~') )\n new_last_path = FileUtils.pwd\n if path == '-'\n if @last_path\n path = @last_path\n else\n warn 'Sorry, there is no previous directory.'\n return\n end\n end\n cd path\n @last_path = new_last_path\n ls\n end",
"def c... | [
"0.77334416",
"0.7546548",
"0.68178266",
"0.62805855",
"0.62805855",
"0.61458087",
"0.6110539",
"0.6103584",
"0.6085886",
"0.60841215",
"0.6080295",
"0.602286",
"0.5983547",
"0.5953504",
"0.58955216",
"0.5882706",
"0.58667815",
"0.5858816",
"0.58165073",
"0.58141476",
"0.5794... | 0.6052459 | 11 |
Fetch files from current directory. Then update each windows reflecting the newest information. | def ls
fetch_items_from_filesystem_or_zip
sort_items_according_to_current_direction
@current_page ||= 0
draw_items
move_cursor (current_row ? [current_row, items.size - 1].min : nil)
draw_marked_items
draw_total_items
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh\n list.clear\n\n Ginatra.load_config[\"git_dirs\"].map do |git_dir|\n if Dir.exist?(git_dir.chop)\n dirs = Dir.glob(git_dir).sort\n else\n dir = File.expand_path(\"../../../#{git_dir}\", __FILE__)\n dirs = Dir.glob(dir).sort\n end\n\n dir... | [
"0.5996507",
"0.59421897",
"0.5928477",
"0.58682674",
"0.58014375",
"0.57655156",
"0.5755845",
"0.5695688",
"0.5673214",
"0.5561599",
"0.55521715",
"0.54958373",
"0.5395383",
"0.53856426",
"0.53328204",
"0.5331938",
"0.53183925",
"0.5289763",
"0.52758867",
"0.52729386",
"0.52... | 0.0 | -1 |
Sort the whole files and directories in the current directory, then refresh the screen. ==== Parameters +direction+ Sort order in a String. nil : order by name r : reverse order by name s, S : order by file size sr, Sr: reverse order by file size t : order by mtime tr : reverse order by mtime c : order by ctime cr : reverse order by ctime u : order by atime ur : reverse order by atime e : order by extname er : reverse order by extname | def sort(direction = nil)
@direction, @current_page = direction, 0
sort_items_according_to_current_direction
switch_page 0
move_cursor 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_items_according_to_current_direction\n case @direction\n when nil\n @items = items.shift(2) + items.partition(&:directory?).flat_map(&:sort)\n when 'r'\n @items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort.reverse}\n when 'S', 's'\n @it... | [
"0.6753547",
"0.62339425",
"0.6180216",
"0.605791",
"0.5885136",
"0.57776505",
"0.5731589",
"0.57272637",
"0.5712036",
"0.5698475",
"0.5698475",
"0.5698475",
"0.5698475",
"0.5698475",
"0.56878465",
"0.56710196",
"0.56634325",
"0.56546617",
"0.56546617",
"0.5644094",
"0.564409... | 0.7013775 | 0 |
Change the file permission of the selected files and directories. ==== Parameters +mode+ Unix chmod string (e.g. +w, gr, 755, 0644) | def chmod(mode = nil)
return unless mode
begin
Integer mode
mode = Integer mode.size == 3 ? "0#{mode}" : mode
rescue ArgumentError
end
FileUtils.chmod mode, selected_items.map(&:path)
ls
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chmod(mode) File.chmod(mode, path) end",
"def chmod(mode, options={})\n #list = list.to_a\n fileutils.chmod(mode, list, options)\n end",
"def chmod(file, mode)\n if File.stat(file).mode != mode\n FileUtils.chmod(mode, file, :verbose => verbose?) \n end\n end",
"def c... | [
"0.7961633",
"0.79208547",
"0.79111606",
"0.7789717",
"0.7640511",
"0.76338196",
"0.7572123",
"0.75515854",
"0.7550537",
"0.7530089",
"0.751246",
"0.7440374",
"0.7425923",
"0.7330557",
"0.72711575",
"0.724482",
"0.7224371",
"0.72054064",
"0.72024363",
"0.7167651",
"0.7126878"... | 0.7932743 | 1 |
Change the file owner of the selected files and directories. ==== Parameters +user_and_group+ user name and group name separated by : (e.g. alice, nobody:nobody, :admin) | def chown(user_and_group)
return unless user_and_group
user, group = user_and_group.split(':').map {|s| s == '' ? nil : s}
FileUtils.chown user, group, selected_items.map(&:path)
ls
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_owner(username, group, path)\n %x(sudo chown -R #{Shellwords.escape(username)}:#{Shellwords.escape(group)} #{path})\n\n $?.success?\n end",
"def set_owner\n user = @conf['user'] || Process.uid\n group = @conf['group'] || Process.gid\n\n begin\n FileUtils.chown_R(use... | [
"0.7031798",
"0.6613002",
"0.64483887",
"0.6332136",
"0.63318396",
"0.63233644",
"0.62693286",
"0.62464225",
"0.6110811",
"0.61022156",
"0.5947538",
"0.5878171",
"0.58744186",
"0.5788736",
"0.5786735",
"0.57764375",
"0.5693316",
"0.5679787",
"0.5665396",
"0.5661425",
"0.56358... | 0.7470499 | 0 |
Fetch files from current directory or current .zip file. | def fetch_items_from_filesystem_or_zip
unless in_zip?
@items = Dir.foreach(current_dir).map {|fn|
load_item dir: current_dir, name: fn
}.to_a.partition {|i| %w(. ..).include? i.name}.flatten
else
@items = [load_item(dir: current_dir, name: '.', stat: File.stat(current_dir)),
load_item(dir: current_dir, name: '..', stat: File.stat(File.dirname(current_dir)))]
zf = Zip::File.new current_dir
zf.each {|entry|
next if entry.name_is_directory?
stat = zf.file.stat entry.name
@items << load_item(dir: current_dir, name: entry.name, stat: stat)
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main_files\n retrieve_files_in_main_dir\n end",
"def retrieve_files_in_main_dir\n ensure_file_open!\n @file.glob('*').map do |entry|\n next if entry.directory?\n\n entry_file_name = Pathname.new(entry.name)\n [entry_file_name, entry.get_input_stream(&:read)]\n end.compact.to_h\n ... | [
"0.6927383",
"0.6580163",
"0.65114397",
"0.6503587",
"0.64773613",
"0.6402373",
"0.62845725",
"0.62720746",
"0.6225117",
"0.6222155",
"0.62179345",
"0.6168878",
"0.6163954",
"0.61059165",
"0.60978436",
"0.6096858",
"0.6085929",
"0.6067498",
"0.606264",
"0.6007258",
"0.600525"... | 0.7121194 | 0 |
Focus at the first file or directory of which name starts with the given String. | def find(str)
index = items.index {|i| i.index > current_row && i.name.start_with?(str)} || items.index {|i| i.name.start_with? str}
move_cursor index if index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def goto_entry_starting_with fc=nil\n unless fc\n fc = get_single \"Entries starting with: \"\n #fc = get_char\n end\n return if fc.size != 1\n ## this is wrong and duplicates the functionality of /\n # It shoud go to cursor of item starting with fc\n $patt = \"^#{fc}\"\nend",
"def goto_entry_starti... | [
"0.629924",
"0.6214372",
"0.5710704",
"0.5511469",
"0.55052716",
"0.543554",
"0.54007345",
"0.5346526",
"0.52422345",
"0.5239791",
"0.51687235",
"0.51587117",
"0.515527",
"0.515292",
"0.5113687",
"0.50899833",
"0.5076208",
"0.50661314",
"0.50547785",
"0.50547785",
"0.50547785... | 0.6091004 | 2 |
Focus at the last file or directory of which name starts with the given String. | def find_reverse(str)
index = items.reverse.index {|i| i.index < current_row && i.name.start_with?(str)} || items.reverse.index {|i| i.name.start_with? str}
move_cursor items.size - index - 1 if index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def goto_entry_starting_with fc=nil\n unless fc\n fc = get_single \"Entries starting with: \"\n #fc = get_char\n end\n return if fc.size != 1\n ## this is wrong and duplicates the functionality of /\n # It shoud go to cursor of item starting with fc\n $patt = \"^#{fc}\"\nend",
"def goto_entry_starti... | [
"0.6061495",
"0.5999916",
"0.57862",
"0.55568165",
"0.5336453",
"0.53053707",
"0.52757347",
"0.52642554",
"0.516325",
"0.5075195",
"0.4979139",
"0.4971363",
"0.49225742",
"0.49115813",
"0.48719105",
"0.48719105",
"0.4858131",
"0.48076108",
"0.47774366",
"0.4776951",
"0.475320... | 0.5768489 | 3 |
Height of the currently active pane. | def maxy
main.maxy
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visible_height\n @win.maxy - 2\n end",
"def scroll_height\n self.scroll_size[:y]\n end",
"def canvas_height\n cur_page.canvas_height\n end",
"def height\n bounds[:bottom] - bounds[:top]\n end",
"def height\n bounds[:bottom] - bounds[:top]\n end",
"def height\n ... | [
"0.69569707",
"0.6799751",
"0.6683992",
"0.6670261",
"0.6670261",
"0.6637877",
"0.66238713",
"0.6597761",
"0.659663",
"0.65309435",
"0.6519484",
"0.65040433",
"0.6472639",
"0.646519",
"0.64370257",
"0.6421143",
"0.6421143",
"0.6389279",
"0.63730705",
"0.63664573",
"0.63664573... | 0.0 | -1 |
Number of files or directories that the current main window can show in a page. | def max_items
main.max_items
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_window_count\n return @browser.windows.count\n end",
"def TreeView_GetVisibleCount(hwnd) send_treeview_message(hwnd, :GETVISIBLECOUNT) end",
"def visible_tabs\n count = 0\n @tab_names.each { |x| count += 1 if x.visible? }\n count\n end",
"def num_pages\n if order_bw_pages && orde... | [
"0.6558865",
"0.65131193",
"0.64951456",
"0.6390861",
"0.6306491",
"0.6246783",
"0.61858934",
"0.61601436",
"0.6110007",
"0.605916",
"0.6039908",
"0.6034674",
"0.6034674",
"0.6027493",
"0.60273004",
"0.6017438",
"0.6015979",
"0.60118747",
"0.6000388",
"0.59907424",
"0.5989372... | 0.0 | -1 |
Update the main window with the loaded files and directories. Also update the header. | def draw_items
main.newpad items
@displayed_items = items[current_page * max_items, max_items]
main.display current_page
header_l.draw_path_and_page_number path: current_dir.path, current: current_page + 1, total: total_pages
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n\t\t\t\tprotect_runtime_errors do\n\t\t\t\t\tif @clear_history\n\t\t\t\t\t\t@history_cache = nil \n\t\t\t\t\t\tGC.start\n\t\t\t\t\tend\n\t\t\t\t\t# -- update files as necessary\n\t\t\t\t\t# need to try and load a new file,\n\t\t\t\t\t# as loading is the only way to escape this state\n\t\t\t\t\tdynamic_... | [
"0.6987807",
"0.6553647",
"0.5624093",
"0.55575454",
"0.5541597",
"0.55272865",
"0.54683095",
"0.53603464",
"0.53359485",
"0.53323233",
"0.52772456",
"0.52727616",
"0.5262025",
"0.5256193",
"0.5247116",
"0.5247116",
"0.5245147",
"0.5195178",
"0.5167212",
"0.5167212",
"0.51371... | 0.0 | -1 |
Sort the loaded files and directories in already given sort order. | def sort_items_according_to_current_direction
case @direction
when nil
@items = items.shift(2) + items.partition(&:directory?).flat_map(&:sort)
when 'r'
@items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort.reverse}
when 'S', 's'
@items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort_by {|i| -i.size}}
when 'Sr', 'sr'
@items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort_by(&:size)}
when 't'
@items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort {|x, y| y.mtime <=> x.mtime}}
when 'tr'
@items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort_by(&:mtime)}
when 'c'
@items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort {|x, y| y.ctime <=> x.ctime}}
when 'cr'
@items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort_by(&:ctime)}
when 'u'
@items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort {|x, y| y.atime <=> x.atime}}
when 'ur'
@items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort_by(&:atime)}
when 'e'
@items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort {|x, y| y.extname <=> x.extname}}
when 'er'
@items = items.shift(2) + items.partition(&:directory?).flat_map {|arr| arr.sort_by(&:extname)}
end
items.each.with_index {|item, index| item.index = index}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort!\n #N Without this, the immediate sub-directories won't get sorted\n dirs.sort_by! {|dir| dir.name}\n #N Without this, files contained immediately in this directory won't get sorted\n files.sort_by! {|file| file.name}\n #N Without this, files and directories contained within sub-d... | [
"0.78199565",
"0.75464207",
"0.75356585",
"0.7188391",
"0.7112423",
"0.70286685",
"0.69724226",
"0.68332887",
"0.6674414",
"0.66667503",
"0.6597997",
"0.6596036",
"0.65643376",
"0.6438283",
"0.6356633",
"0.63212144",
"0.627526",
"0.6259553",
"0.62087935",
"0.62084305",
"0.616... | 0.661246 | 10 |
Search files and directories from the current directory, and update the screen. +pattern+ Search pattern against file names in Ruby Regexp string. === Example a : Search files that contains the letter "a" in their file name .\.pdf$ : Search PDF files | def grep(pattern = '.*')
regexp = Regexp.new(pattern)
fetch_items_from_filesystem_or_zip
@items = items.shift(2) + items.select {|i| i.name =~ regexp}
sort_items_according_to_current_direction
draw_items
draw_total_items
switch_page 0
move_cursor 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_file_by_text (start_dir, file_mask=\"*.*\", text_pattern='')\n match_files = Dir[ File.join(start_dir.split(/\\\\/), \"**\", file_mask)]\n if match_files.length > 0\n file_path = nil\n match_files.each do |file|\n matching_text = File.read(file).include?(text_pattern) rescue false\n... | [
"0.71102583",
"0.70537454",
"0.69636136",
"0.6890982",
"0.6890982",
"0.6862031",
"0.68156797",
"0.67984957",
"0.67558163",
"0.67547935",
"0.6715535",
"0.67140937",
"0.6664562",
"0.66150063",
"0.6609749",
"0.646694",
"0.64667517",
"0.64667517",
"0.64593613",
"0.6457223",
"0.64... | 0.5876553 | 54 |
Copy selected files and directories to the destination. | def cp(dest)
unless in_zip?
src = (m = marked_items).any? ? m.map(&:path) : current_item
FileUtils.cp_r src, expand_path(dest)
else
raise 'cping multiple items in .zip is not supported.' if selected_items.size > 1
Zip::File.open(current_zip) do |zip|
entry = zip.find_entry(selected_items.first.name).dup
entry.name, entry.name_length = dest, dest.size
zip.instance_variable_get(:@entry_set) << entry
end
end
ls
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_directory(source, destination)\n FileUtils.cp_r(FileSyncer.glob(\"#{source}/*\"), destination)\n end",
"def copy_directory(source, destination)\n FileUtils.cp_r(FileSyncer.glob(\"#{source}/*\"), destination)\n end",
"def copy(source, destination, **options); end",
"def copy_files(sou... | [
"0.7220369",
"0.7220369",
"0.7103961",
"0.7088442",
"0.7067693",
"0.70432603",
"0.69822156",
"0.69538707",
"0.69121385",
"0.68227917",
"0.68054414",
"0.6801442",
"0.678095",
"0.6729905",
"0.67170745",
"0.6699256",
"0.6699256",
"0.6694657",
"0.66882753",
"0.66835344",
"0.66779... | 0.64731747 | 35 |
Move selected files and directories to the destination. | def mv(dest)
unless in_zip?
src = (m = marked_items).any? ? m.map(&:path) : current_item
FileUtils.mv src, expand_path(dest)
else
raise 'mving multiple items in .zip is not supported.' if selected_items.size > 1
rename "#{selected_items.first.name}/#{dest}"
end
ls
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_folders(orig,dest)\n \n puts \"Moving #{orig} -> #{dest}\" if @verbose\n FileUtils.mv orig,dest\n end",
"def move(*froms, to)\n froms.each do |from|\n FileUtils.mv(from, to)\n end\n end",
"def move_files\n source_dir = Item.new(Path.new(params[:source]))\n dest_dir... | [
"0.6859827",
"0.6606791",
"0.6572775",
"0.6546143",
"0.6479555",
"0.6472012",
"0.632854",
"0.631716",
"0.62550193",
"0.61580855",
"0.6144936",
"0.6136502",
"0.6132095",
"0.6090147",
"0.6088836",
"0.6050799",
"0.60287106",
"0.6001828",
"0.6001828",
"0.59924895",
"0.5978038",
... | 0.62577605 | 8 |
Rename selected files and directories. ==== Parameters +pattern+ new filename, or a shash separated Regexp like string | def rename(pattern)
from, to = pattern.sub(/^\//, '').sub(/\/$/, '').split '/'
if to.nil?
from, to = current_item.name, from
else
from = Regexp.new from
end
unless in_zip?
selected_items.each do |item|
name = item.name.gsub from, to
FileUtils.mv item, current_dir.join(name) if item.name != name
end
else
Zip::File.open(current_zip) do |zip|
selected_items.each do |item|
name = item.name.gsub from, to
zip.rename item.name, name
end
end
end
ls
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rename_all(pattern, replace)\n Dir.new('.').each do |f|\n File.rename(f, f.gsub(pattern, replace)) if f.match(pattern)\n end\nend",
"def rename(root, pattern, replacement, force: false, excluding: nil)\n options = {force: force, excluding: excluding}\n\n ::Find.find(root) do |path|\n ... | [
"0.6490024",
"0.6006657",
"0.5734607",
"0.57127804",
"0.5549183",
"0.5548546",
"0.55439925",
"0.55129874",
"0.5512433",
"0.5495125",
"0.54512054",
"0.5416406",
"0.5378884",
"0.53518045",
"0.53289044",
"0.52556765",
"0.5229619",
"0.5212441",
"0.51935375",
"0.51900387",
"0.5175... | 0.736625 | 0 |
Soft delete selected files and directories. If the OS is not OSX, performs the same as `delete` command. | def trash
unless in_zip?
if osx?
FileUtils.mv selected_items.map(&:path), File.expand_path('~/.Trash/')
else
#TODO support other OS
FileUtils.rm_rf selected_items.map(&:path)
end
else
return unless ask %Q[Trashing zip entries is not supported. Actually the files will be deleted. Are you sure want to proceed? (y/n)]
delete
end
@current_row -= selected_items.count {|i| i.index <= current_row}
ls
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deleteFW (path)\n choose = prompt(text: \"delete \" + path.to_s + \"?\\n press 1 to continue, 0 to exit: \").to_i\n if choose.to_i == 0 \n abort UI.user_error!(\"program was forced exit by user\")\nelse\n sh(\"rm -rf \" + path.to_s)\n end\nend",
"def delete!\n execute_as_user(\"rm -rf #... | [
"0.64282566",
"0.6282635",
"0.602814",
"0.594366",
"0.59373796",
"0.5831294",
"0.5826206",
"0.58152723",
"0.57829547",
"0.5756551",
"0.5752344",
"0.572216",
"0.5710559",
"0.56992394",
"0.56853217",
"0.5682244",
"0.56820023",
"0.5668327",
"0.566779",
"0.5658412",
"0.56524175",... | 0.56475526 | 21 |
Delete selected files and directories. | def delete
unless in_zip?
FileUtils.rm_rf selected_items.map(&:path)
else
Zip::File.open(current_zip) do |zip|
zip.select {|e| selected_items.map(&:name).include? e.to_s}.each do |entry|
if entry.name_is_directory?
zip.dir.delete entry.to_s
else
zip.file.delete entry.to_s
end
end
end
end
@current_row -= selected_items.count {|i| i.index <= current_row}
ls
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_files(options)\n if '' == options['base-dir'].to_s\n raise ArgumentError.new(\"Missing options['base-dir']\")\n end\n if '' == options['file-selector'].to_s\n raise ArgumentError.new(\"Missing options['file-selector']\")\n end\n if '' == options['file... | [
"0.728795",
"0.6934576",
"0.68912596",
"0.6837461",
"0.6753595",
"0.67225724",
"0.67041534",
"0.668328",
"0.66563135",
"0.6639564",
"0.6619389",
"0.6466952",
"0.6466952",
"0.6430786",
"0.6407656",
"0.63818574",
"0.6344212",
"0.63083327",
"0.62737864",
"0.6265299",
"0.6262813"... | 0.6416039 | 14 |
Create a new directory. | def mkdir(dir)
unless in_zip?
FileUtils.mkdir_p current_dir.join(dir)
else
Zip::File.open(current_zip) do |zip|
zip.dir.mkdir dir
end
end
ls
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_directory\n remove_dir(@name) if Dir.exist?(@name)\n Dir.mkdir(@name)\n end",
"def create_directory(path)\n FileUtils.mkdir_p(path)\n path\n end",
"def create_directory\n return if File.directory?(DIRECTORY_PATH)\n\n FileUtils.mkdir_p(DIRECTORY_PATH)\n en... | [
"0.8423674",
"0.8154918",
"0.8083509",
"0.7989395",
"0.78419983",
"0.78292114",
"0.78061426",
"0.778486",
"0.7742616",
"0.7733162",
"0.76817423",
"0.76738566",
"0.766087",
"0.7651575",
"0.76507926",
"0.76419747",
"0.7618168",
"0.7614387",
"0.75946254",
"0.7591316",
"0.7565832... | 0.0 | -1 |
Create a new empty file. | def touch(filename)
unless in_zip?
FileUtils.touch current_dir.join(filename)
else
Zip::File.open(current_zip) do |zip|
# zip.file.open(filename, 'w') {|_f| } #HAXX this code creates an unneeded temporary file
zip.instance_variable_get(:@entry_set) << Zip::Entry.new(current_zip, filename)
end
end
ls
move_cursor items.index {|i| i.name == filename}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_new_file(file_name)\n puts \"Creating %s...\" % [file_name]\n make_dir_for_path(file_name)\n new_file = File.new(file_name, File::WRONLY|File::TRUNC|File::CREAT)\n end",
"def safe_make_empty_file(path)\n if File.exist? path\n File.open(path, ... | [
"0.72574633",
"0.70511127",
"0.7020004",
"0.7008989",
"0.69761014",
"0.6812042",
"0.6792093",
"0.6748911",
"0.6748911",
"0.6744718",
"0.6725702",
"0.66820747",
"0.6544405",
"0.6531527",
"0.6511505",
"0.65081686",
"0.6497183",
"0.64909166",
"0.64867103",
"0.64854693",
"0.64324... | 0.0 | -1 |
Create a symlink to the current file or directory. | def symlink(name)
FileUtils.ln_s current_item, name
ls
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_symlink( old ) File.symlink( old, expand_tilde ) end",
"def create_symlink(dest_path); end",
"def make_symlink(old) File.symlink(old, path) end",
"def create_symlink(source = nil, dest = nil)\n end",
"def create_symlink(old_name, new_name)\n File.symlink(old_name, new_name)\n en... | [
"0.8406103",
"0.83937025",
"0.82942986",
"0.8160836",
"0.81487143",
"0.81487143",
"0.7827746",
"0.77428675",
"0.7571918",
"0.7520523",
"0.7410269",
"0.73941237",
"0.73205286",
"0.73108166",
"0.7256173",
"0.7232844",
"0.71921474",
"0.7190729",
"0.7186848",
"0.71772164",
"0.704... | 0.6736993 | 29 |
Change the timestamp of the selected files and directories. ==== Parameters +timestamp+ A string that can be parsed with `Time.parse`. Note that this parameter is not compatible with UNIX `touch t`. | def touch_t(timestamp)
FileUtils.touch selected_items, mtime: Time.parse(timestamp)
ls
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modified_at(file, timestamp = nil)\n require 'date'\n time = timestamp ? DateTime.parse(\"#{timestamp}\") : DateTime.now\n timestamp = time.strftime('%Y%m%d%H%M')\n execute(\"/bin/touch -mt #{timestamp} #{file}\")\n end",
"def timestamp=(timestamp)\n @timestamp = _check_timestamp(timestamp)... | [
"0.6365125",
"0.6343466",
"0.6308022",
"0.6152845",
"0.5780877",
"0.5666242",
"0.5505432",
"0.53912926",
"0.5374339",
"0.52755016",
"0.5058137",
"0.50204706",
"0.5016717",
"0.5002579",
"0.49970952",
"0.49921483",
"0.49688482",
"0.49676868",
"0.49618778",
"0.4936849",
"0.49342... | 0.7202312 | 0 |
Yank selected file / directory names. | def yank
@yanked_items = selected_items
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_from_list\n\n # XXX key to invoke this is difficult. make it easier\n selfiles = current_or_selected_files\n sz = selfiles.size\n print \"Remove #{sz} files from used list (y)?: \"\n key = get_char\n return if key != 'y'\n\n # arr = @selected_files.map { |path| File.expand_path(path) }\n # @log.... | [
"0.58841217",
"0.56182814",
"0.5609983",
"0.5533741",
"0.53973764",
"0.5345183",
"0.5327483",
"0.5327483",
"0.53068775",
"0.52916586",
"0.5250795",
"0.52463955",
"0.5224868",
"0.52206403",
"0.5190112",
"0.5166",
"0.513031",
"0.512064",
"0.5102785",
"0.5078216",
"0.50732267",
... | 0.54911417 | 4 |
Paste yanked files / directories here. | def paste
if @yanked_items
if current_item.directory?
FileUtils.cp_r @yanked_items.map(&:path), current_item
else
@yanked_items.each do |item|
if items.include? item
i = 1
while i += 1
new_item = load_item dir: current_dir, name: "#{item.basename}_#{i}#{item.extname}", stat: item.stat
break unless File.exist? new_item.path
end
FileUtils.cp_r item, new_item
else
FileUtils.cp_r item, current_dir
end
end
end
ls
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blacklisted_dir_entries\n %w[. ..]\n end",
"def replicate_dir(f)\n out_original = f.sub($queue,$original)\n out_watermarked = f.sub($queue,$watermarked)\n if !File.exist?(out_original) && !File.exist?(out_watermarked)\n FileUtils.mkdir(out_original)\n FileUtils.mkdir(out_watermarke... | [
"0.563246",
"0.5365304",
"0.53574353",
"0.53080815",
"0.5290943",
"0.5287722",
"0.5275275",
"0.52750075",
"0.52619284",
"0.52032536",
"0.5198403",
"0.51540506",
"0.513296",
"0.5128863",
"0.5099883",
"0.50897795",
"0.50862366",
"0.50715935",
"0.5070146",
"0.5068272",
"0.506636... | 0.7160363 | 0 |
Copy selected files and directories' path into clipboard on OSX. | def clipboard
IO.popen('pbcopy', 'w') {|f| f << selected_items.map(&:path).join(' ')} if osx?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_clipboard_copy\n return nil unless sel=@selection and dat=@data[sel]\n # XXX i feel dirty\n if Wx::PLATFORM == \"WXMAC\"\n IO.popen(\"pbcopy\", \"w\") {|io| io.write dat}\n stat = $?.success?\n else\n dobj = RawDataObject.new(dat)\n stat = Wx::Clipboard.open {... | [
"0.7115079",
"0.7002764",
"0.69583875",
"0.6808353",
"0.6765171",
"0.6653057",
"0.663103",
"0.6491936",
"0.64842623",
"0.64713055",
"0.6452405",
"0.6452405",
"0.64059824",
"0.6365171",
"0.6360526",
"0.63305914",
"0.63264066",
"0.6302481",
"0.62640446",
"0.61834943",
"0.611143... | 0.8589144 | 0 |
Archive selected files and directories into a .zip file. | def zip(zipfile_name)
return unless zipfile_name
zipfile_name += '.zip' unless zipfile_name.end_with? '.zip'
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
selected_items.each do |item|
next if item.symlink?
if item.directory?
Dir[item.join('**/**')].each do |file|
zipfile.add file.sub("#{current_dir}/", ''), file
end
else
zipfile.add item.name, item
end
end
end
ls
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def archive\n files.each do |path|\n path_obj = Pathname.new(path)\n path_name = path_obj.dirname.to_s\n compress = Kellerkind::Compress.new(:target_path => out,\n :source_path => path,\n :tarball_pr... | [
"0.74123836",
"0.7021671",
"0.6955902",
"0.68239886",
"0.6787721",
"0.65796155",
"0.654845",
"0.6525048",
"0.645605",
"0.64537454",
"0.6448565",
"0.64361745",
"0.6404247",
"0.63789654",
"0.6362273",
"0.6362273",
"0.63601446",
"0.6352382",
"0.6322369",
"0.6287762",
"0.6287762"... | 0.61296415 | 33 |
Unarchive .zip and .tar.gz files within selected files and directories into current_directory. | def unarchive
unless in_zip?
zips, gzs = selected_items.partition(&:zip?).tap {|z, others| break [z, *others.partition(&:gz?)]}
zips.each do |item|
FileUtils.mkdir_p current_dir.join(item.basename)
Zip::File.open(item) do |zip|
zip.each do |entry|
FileUtils.mkdir_p File.join(item.basename, File.dirname(entry.to_s))
zip.extract(entry, File.join(item.basename, entry.to_s)) { true }
end
end
end
gzs.each do |item|
Zlib::GzipReader.open(item) do |gz|
Gem::Package::TarReader.new(gz) do |tar|
dest_dir = current_dir.join (gz.orig_name || item.basename).sub(/\.tar$/, '')
tar.each do |entry|
dest = nil
if entry.full_name == '././@LongLink'
dest = File.join dest_dir, entry.read.strip
next
end
dest ||= File.join dest_dir, entry.full_name
if entry.directory?
FileUtils.mkdir_p dest, mode: entry.header.mode
elsif entry.file?
FileUtils.mkdir_p dest_dir
File.open(dest, 'wb') {|f| f.print entry.read}
FileUtils.chmod entry.header.mode, dest
elsif entry.header.typeflag == '2' # symlink
File.symlink entry.header.linkname, dest
end
unless Dir.exist? dest_dir
FileUtils.mkdir_p dest_dir
File.open(File.join(dest_dir, gz.orig_name || item.basename), 'wb') {|f| f.print gz.read}
end
end
end
end
end
else
Zip::File.open(current_zip) do |zip|
zip.select {|e| selected_items.map(&:name).include? e.to_s}.each do |entry|
FileUtils.mkdir_p File.join(current_zip.dir, current_zip.basename, File.dirname(entry.to_s))
zip.extract(entry, File.join(current_zip.dir, current_zip.basename, entry.to_s)) { true }
end
end
end
ls
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unpack( archive, into = Dir.pwd )\n Dir.chdir( into ) do \n if archive.match( /\\.tar\\.gz\\Z/ ) or archive.match(/\\.tgz\\Z/) then\n tgz = ::Zlib::GzipReader.new( File.open( local_source, 'rb') )\n ::Archive::Tar::Minitar.unpack( tgz, into )\n elsif archive.match( /\\.gem\... | [
"0.62768906",
"0.61366785",
"0.598008",
"0.5943704",
"0.59319764",
"0.59226274",
"0.58503044",
"0.5823995",
"0.5799449",
"0.57321995",
"0.5729694",
"0.5718601",
"0.5682455",
"0.567469",
"0.5632223",
"0.56250256",
"0.557718",
"0.5564379",
"0.5561875",
"0.55276746",
"0.5514639"... | 0.70867246 | 0 |
Current page is the first page? | def first_page?
current_page == 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_page?\n current_page == 1\n end",
"def first_page?\n current_page == 1\n end",
"def first_page?\n current_page == 1\n end",
"def first_page?\n current_page == 1\n end",
"def first_page?\n current_page == 1\n end",
"def first_page?\n current_pag... | [
"0.9004532",
"0.9004532",
"0.9004532",
"0.9004532",
"0.89854574",
"0.89854574",
"0.897027",
"0.881746",
"0.8721724",
"0.8525082",
"0.8479245",
"0.8342261",
"0.7762188",
"0.77414465",
"0.76476043",
"0.7501462",
"0.74949086",
"0.7410818",
"0.7331915",
"0.720844",
"0.7178685",
... | 0.89650315 | 7 |
Do we have more pages? | def last_page?
current_page == total_pages - 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def more_pages?\n return false if start_index == 0\n (self.start_index + self.page_length) -1 < self.total_result_count\n end",
"def more?\n @current < @pages\n end",
"def page_count()\n if @pages >= 500\n return true\n end\n else\n return false\n end",
"def next?\n retur... | [
"0.8560216",
"0.849319",
"0.82227594",
"0.80433965",
"0.802607",
"0.7800313",
"0.7765027",
"0.7711835",
"0.7630382",
"0.7561847",
"0.7557496",
"0.7537642",
"0.75276613",
"0.7525138",
"0.744869",
"0.7440024",
"0.73971605",
"0.7381684",
"0.7375007",
"0.73486936",
"0.7313391",
... | 0.70128536 | 49 |
Number of pages in the current directory. | def total_pages
(items.size - 1) / max_items + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_pages\n pages.size\n end",
"def num_pages\n n, rest = @num_entries.divmod(@entries_per_page)\n if rest > 0 then n + 1 else n end\n end",
"def number_of_pages\n return @number_of_pages\n end",
"def page_count\n @total_pages\n end",
"def page... | [
"0.76017255",
"0.7576334",
"0.7550106",
"0.7510014",
"0.74603564",
"0.73714846",
"0.7366279",
"0.7283027",
"0.72618014",
"0.7257561",
"0.7248634",
"0.7248634",
"0.7248634",
"0.7248634",
"0.71996856",
"0.7180941",
"0.717446",
"0.71704954",
"0.71568584",
"0.71267605",
"0.712166... | 0.68678087 | 36 |
Move to the given page number. ==== Parameters +page+ Target page number | def switch_page(page)
main.display (@current_page = page)
@displayed_items = items[current_page * max_items, max_items]
header_l.draw_path_and_page_number path: current_dir.path, current: current_page + 1, total: total_pages
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_page(num)\n add_actions \"MovePage(#{num})\"\n end",
"def move_to(x, y)\n cur_page.move_to(x, y)\n end",
"def go_to_page(page)\n get_total_pages unless @total_pages\n return nil if page.to_i < 1 || page.to_i > @total_pages\n ISBNdb::ResultSet.new(\"#{@uri}&page_numbe... | [
"0.7515494",
"0.73650265",
"0.69876534",
"0.6969776",
"0.69144964",
"0.6897104",
"0.6790838",
"0.6601568",
"0.6497327",
"0.64367515",
"0.6436707",
"0.6426241",
"0.6379423",
"0.63667774",
"0.6322878",
"0.6249541",
"0.624047",
"0.62356037",
"0.6229421",
"0.6211219",
"0.6193853"... | 0.65823364 | 8 |
Update the header information concerning currently marked files or directories. | def draw_marked_items
items = marked_items
header_r.draw_marked_items count: items.size, size: items.inject(0) {|sum, i| sum += i.size}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh()\n self.contents.clear\n @cHeaders.each() { |cHeader| cHeader.draw() }\n end",
"def generate_header\n \n self.reload\n self.headers.reload\n \n layout_path = self.current_layout.relative_path unless self.current_layout.nil?\n \n # Default header values\n yaml_headers =... | [
"0.55350065",
"0.5534353",
"0.5378518",
"0.52742654",
"0.52684754",
"0.52577955",
"0.51829416",
"0.51422334",
"0.5125846",
"0.51111484",
"0.5093663",
"0.5080094",
"0.5074215",
"0.50631094",
"0.5048142",
"0.50269586",
"0.5026468",
"0.49961203",
"0.49961203",
"0.49961203",
"0.4... | 0.0 | -1 |
Update the header information concerning total files and directories in the current directory. | def draw_total_items
header_r.draw_total_items count: items.size, size: items.inject(0) {|sum, i| sum += i.size}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put_header\n @io.puts 'Calculating -------------------------------------'\n end",
"def files\n @header.dirindexes.map { |idx|\n @header.dirnames[idx]\n }.zip(@header.basenames).map { |dir, name|\n ::File.join(dir, name)\n }.zip(@header.filesizes).map { |path, size... | [
"0.547578",
"0.54075986",
"0.5406179",
"0.5378685",
"0.53776205",
"0.5325878",
"0.52247036",
"0.5188903",
"0.5131183",
"0.50979203",
"0.50925696",
"0.50591403",
"0.50585264",
"0.50526154",
"0.50321597",
"0.50317526",
"0.5029053",
"0.5016175",
"0.5000742",
"0.49981356",
"0.497... | 0.48428681 | 30 |
Swktch on / off marking on the current file or directory. | def toggle_mark
main.toggle_mark current_item
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark!\n\t\t\t\t@marked = true\n\t\t\tend",
"def edl_mark \n send_cmd(\"edl_mark\")\n end",
"def flags; changeset.flags(@path); end",
"def toggle\n if on?\n off\n else\n on\n end\n end",
"def switch_flag\n\t\t@flag = !@flag\n\tend",
"def turn_on\n 'If the thermoc... | [
"0.57452375",
"0.56885517",
"0.5654512",
"0.5560023",
"0.55504096",
"0.5456111",
"0.54291165",
"0.540916",
"0.53911823",
"0.5383848",
"0.5345398",
"0.53184044",
"0.5282469",
"0.5273503",
"0.5237769",
"0.5228008",
"0.5194415",
"0.51476866",
"0.5141669",
"0.51280946",
"0.510652... | 0.5859266 | 0 |
Get a char as a String from user input. | def get_char
c = Curses.getch
c if (0..255) === c.ord
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_character_from_user\n puts \" Please enter your name: \"\n gets.chomp.to_str\n puts \"\"\n end",
"def get_character_from_user\n puts \"Please enter a character\"\n character = gets.chomp.downcase\nend",
"def get_character_from_user\n puts \"Please enter a character:\"\n return gets.cho... | [
"0.7871303",
"0.7673719",
"0.75132406",
"0.71197957",
"0.7078796",
"0.69755065",
"0.69755065",
"0.69593936",
"0.69462353",
"0.69060874",
"0.67512596",
"0.6746199",
"0.6716986",
"0.65987957",
"0.6577152",
"0.6457742",
"0.64533496",
"0.6435029",
"0.6423935",
"0.64192325",
"0.64... | 0.65854675 | 14 |
Accept user input, and directly execute it as a Ruby method call to the controller. ==== Parameters +preset_command+ A command that would be displayed at the command line before user input. +default_argument+ A default argument for the command. | def process_command_line(preset_command: nil, default_argument: nil)
prompt = preset_command ? ":#{preset_command} " : ':'
command_line.set_prompt prompt
cmd, *args = command_line.get_command(prompt: prompt, default: default_argument).split(' ')
if cmd && !cmd.empty? && respond_to?(cmd)
ret = self.public_send cmd, *args
clear_command_line
ret
end
rescue Interrupt
clear_command_line
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process(raw_input)\n clean_input, verbosity = sanitize_input raw_input\n\n if clean_input.length > 0\n command = find_command(clean_input) || @modes.current_mode.dynamic_command(clean_input) || @modes.global_mode.command_not_found\n user_args = extract_user_args command, cle... | [
"0.5753752",
"0.5311514",
"0.52760154",
"0.5255442",
"0.5209559",
"0.52045923",
"0.5193481",
"0.5190856",
"0.512851",
"0.5098161",
"0.5068501",
"0.50610435",
"0.505512",
"0.5027248",
"0.50228804",
"0.49825186",
"0.49575496",
"0.4947826",
"0.49460825",
"0.49459407",
"0.4941197... | 0.80562204 | 0 |
Accept user input, and directly execute it in an external shell. | def process_shell_command
command_line.set_prompt ':!'
cmd = command_line.get_command(prompt: ':!')[1..-1]
execute_external_command pause: true do
system cmd
end
rescue Interrupt
ensure
command_line.clear
command_line.noutrefresh
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_with_input(shell_command, input_query=/^Password/, response=nil)\n handle_command_with_input(:run, shell_command, input_query, response)\nend",
"def run_with_input(shell_command, input_query=/^Password/, response=nil)\n handle_command_with_input(:run, shell_command, input_query, response)\n end",
... | [
"0.7645436",
"0.7439496",
"0.7439496",
"0.6826866",
"0.68079025",
"0.665073",
"0.6628359",
"0.6615934",
"0.65914255",
"0.6584348",
"0.65698004",
"0.65551454",
"0.65296143",
"0.6454558",
"0.64445966",
"0.63904905",
"0.6388665",
"0.6372787",
"0.633815",
"0.6322621",
"0.63027275... | 0.6692589 | 5 |
Let the user answer y or n. ==== Parameters +prompt+ Prompt message | def ask(prompt = '(y/n)')
command_line.set_prompt prompt
command_line.refresh
while (c = Curses.getch)
next unless [?N, ?Y, ?n, ?y, 3, 27] .include? c # N, Y, n, y, ^c, esc
clear_command_line
break (c == 'y') || (c == 'Y')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yes?(prompt)\n begin\n answer = ask(\"#{prompt} [y/n]: \") { |q| q.limit = 1; q.case = :downcase }\n end until %w(y n).include? answer\n answer == 'y'\n end",
"def confirm(prompt)\n return true if config[:yes]\n valid_responses = %w[yes no y n]\n response = nil\n 3.... | [
"0.80290097",
"0.7902345",
"0.7898017",
"0.7848584",
"0.7838065",
"0.78200847",
"0.7800907",
"0.7713918",
"0.76968974",
"0.7657936",
"0.7621666",
"0.7616819",
"0.7614349",
"0.7606154",
"0.7588236",
"0.7578107",
"0.7577071",
"0.75265247",
"0.744422",
"0.7440114",
"0.7406236",
... | 0.78442377 | 4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.