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
`Artistpaintings` Returns an `array` all the paintings by an artist
def paintings Painting.all.select {|painting| painting.artist == self} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def paintings\n Painting.all.select {|p| p.artist == self}\n end", "def artists\n paintings.map do |painting|\n painting.artist\n end\n end", "def list_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end", "def paintings()\n Painting.all.sele...
[ "0.84607595", "0.82069206", "0.816819", "0.81664306", "0.81405145", "0.8131609", "0.81113607", "0.80971444", "0.8091022", "0.8091022", "0.80855423", "0.8032074", "0.7967333", "0.7951043", "0.7870006", "0.782786", "0.7246184", "0.7230459", "0.7198175", "0.7178665", "0.7017886"...
0.8169067
4
`Artistgalleries` Returns an `array` of all the galleries that an artist has paintings in
def galleries galleries_array = paintings.map {|painting| painting.gallery} galleries_array.uniq end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def galleries\n paintings.map {|p| p.gallery}\n end", "def galleries\n Painting.all.map do |painting_instance| \n if painting_instance.artist == self\n painting_instance.gallery\n end\n end.compact.uniq\n end", "def all_artists_by_gallery\n paintings = Painting.all.select { |...
[ "0.8114489", "0.8106908", "0.8078521", "0.7907956", "0.7882467", "0.7860047", "0.7839884", "0.7803364", "0.7803364", "0.7803364", "0.7798533", "0.76875746", "0.7647573", "0.76244587", "0.7619043", "0.73032504", "0.7296289", "0.7279144", "0.7064477", "0.7060904", "0.69959146",...
0.7721163
11
`Artistcities` Return an `array` of all cities that an artist has paintings in
def cities galleries.map {|gallery| gallery.city} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cities\n Painting.all.map do |painting_instance| \n if painting_instance.artist == self\n painting_instance.gallery.city\n end\n end.compact.uniq\n end", "def cities\n galleries.map {|g| g.city}\n end", "def cities\n galleries.map do |c|\n c.city\n end\n end"...
[ "0.76366496", "0.76303303", "0.7403811", "0.7291418", "0.7201101", "0.71257883", "0.71034634", "0.7080263", "0.7080263", "0.70631045", "0.70404536", "0.7006217", "0.69975644", "0.69390637", "0.69269794", "0.6924301", "0.68993986", "0.68741655", "0.68523127", "0.68202174", "0....
0.7228009
5
This is for both loggedin users home page and site general home page. If user logged in then it will show his home page or site general home page
def index if params[:auth_token] and params[:next] redirect_to facebook_path return end if current_user.nil? if params[:fb_sig_app_id] render :template => "facebook/home", :layout => false else render :action => "general_home" end else # @quick_messages = current_user.quick_messages.all(:limit => 5) @profile_viewers = current_user.profile_viewed_by.all(:select => "users.*, profile_viewers.viewed_at") @profile_visitors = current_user.profile_viewed.all(:select => "users.*, profile_viewers.viewed_at") @available_users = User.where("users.id != #{current_user.id} and users.available_today = true") @notifications = User.recent_notifications(current_user).paginate(:per_page => 5, :page => params[:page]) render :partial => "ajax_recent_notifications", :layout => false if request.xhr? end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def home_page\n if current_user.guest?\n user_signup_url\n elsif current_user.administrator?\n admin_films_path\n elsif current_user.judge?\n judging_categories_path\n else\n obejct_url current_user\n end\n end", "def home\n if current_user\n redirect_to '/dashboard'\n...
[ "0.79486066", "0.7557329", "0.75196624", "0.7517346", "0.7379176", "0.72768646", "0.7251237", "0.7244335", "0.71501005", "0.71232265", "0.71073735", "0.7067422", "0.7003538", "0.69858396", "0.6973379", "0.69544727", "0.6946686", "0.69169754", "0.69169754", "0.6906558", "0.683...
0.0
-1
Most of the input will be in USASCII, but an encoding can be set per buffer for the input. For just about all purposes, UTF8 should be what you want to input, and it's what Tk can handle best.
def string(text) common_string(text, text.event.unicode) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_encoding(string)\n ## removing newline (needed for pty/expect newlines)\n string[0, 2] = '' if string.start_with? \"\\r\\n\"\n string[0, 3] = '' if string.start_with? \"\\r\\r\\n\"\n string.gsub!(\"\\r\\n\", \"\\n\")\n # string.chomp!\n string\n end", "def fo...
[ "0.6207397", "0.6174371", "0.616584", "0.61619467", "0.61529595", "0.612684", "0.6125398", "0.61142004", "0.6113161", "0.60845214", "0.6082875", "0.6082875", "0.6082875", "0.6082875", "0.6082875", "0.6080573", "0.6063931", "0.6054179", "0.6050378", "0.6025572", "0.6025572", ...
0.0
-1
GET /historic_refinancings GET /historic_refinancings.json
def index @historic_refinancings = HistoricRefinancing.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_historic_refinancing\n @historic_refinancing = HistoricRefinancing.find(params[:id])\n end", "def index\n @references = Reference.all\n\n render json: @references\n end", "def index\n @historics = Historic.all\n end", "def historic_refinancing_params\n params.require(:historic...
[ "0.6679897", "0.6276674", "0.61682594", "0.6033269", "0.600502", "0.5963873", "0.59627885", "0.59627885", "0.5921279", "0.59022856", "0.5896239", "0.5891962", "0.5828762", "0.5826448", "0.5825007", "0.5810189", "0.5803172", "0.5767679", "0.57618016", "0.57435864", "0.57411623...
0.78506756
0
GET /historic_refinancings/1 GET /historic_refinancings/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @historic_refinancings = HistoricRefinancing.all\n end", "def set_historic_refinancing\n @historic_refinancing = HistoricRefinancing.find(params[:id])\n end", "def referrers id, date = Date.today.to_s, page = 1\n uri = \"#{BASE_URL}/gauges/#{id}/referrers?date=#{date}&page=#{page}\...
[ "0.7786745", "0.70019656", "0.6244649", "0.6200222", "0.61179954", "0.6011931", "0.5970553", "0.5944887", "0.5858455", "0.5854896", "0.58521676", "0.58392966", "0.5839278", "0.58319813", "0.5816641", "0.5816641", "0.5809151", "0.57389265", "0.5737709", "0.5737709", "0.5733248...
0.0
-1
POST /historic_refinancings POST /historic_refinancings.json
def create @historic_refinancing = HistoricRefinancing.new(historic_refinancing_params) respond_to do |format| if @historic_refinancing.save format.html { redirect_to @historic_refinancing, notice: 'Historic refinancing was successfully created.' } format.json { render :show, status: :created, location: @historic_refinancing } else format.html { render :new } format.json { render json: @historic_refinancing.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def historic_refinancing_params\n params.require(:historic_refinancing).permit(:authorization_origin_id, :refinancing_id, :authorization_new_id)\n end", "def index\n @historic_refinancings = HistoricRefinancing.all\n end", "def set_historic_refinancing\n @historic_refinancing = HistoricRefinan...
[ "0.68560433", "0.663042", "0.64377725", "0.6044653", "0.59601253", "0.58686686", "0.57772774", "0.5725821", "0.56502956", "0.5550992", "0.5529344", "0.55148697", "0.5500039", "0.54774064", "0.54580665", "0.5450763", "0.5448483", "0.54398125", "0.54305255", "0.53979397", "0.53...
0.7055928
0
PATCH/PUT /historic_refinancings/1 PATCH/PUT /historic_refinancings/1.json
def update respond_to do |format| if @historic_refinancing.update(historic_refinancing_params) format.html { redirect_to @historic_refinancing, notice: 'Historic refinancing was successfully updated.' } format.json { render :show, status: :ok, location: @historic_refinancing } else format.html { render :edit } format.json { render json: @historic_refinancing.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_historic_refinancing\n @historic_refinancing = HistoricRefinancing.find(params[:id])\n end", "def historic_refinancing_params\n params.require(:historic_refinancing).permit(:authorization_origin_id, :refinancing_id, :authorization_new_id)\n end", "def update\n historial_params = para...
[ "0.6527517", "0.6449359", "0.61183727", "0.60717916", "0.5939832", "0.5939832", "0.59144276", "0.58989024", "0.5894244", "0.5889878", "0.5816665", "0.5805775", "0.580559", "0.5790423", "0.5789844", "0.5786501", "0.57146406", "0.5713382", "0.57125044", "0.57085586", "0.5679003...
0.7208107
0
DELETE /historic_refinancings/1 DELETE /historic_refinancings/1.json
def destroy @historic_refinancing.destroy respond_to do |format| format.html { redirect_to historic_refinancings_url, notice: 'Historic refinancing was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @historial = Historial.find(params[:id])\n @historial.destroy\n\n respond_to do |format|\n format.html { redirect_to historials_url }\n format.json { head :ok }\n end\n end", "def destroy\n @historic.destroy\n respond_to do |format|\n format.html { redirect_to hist...
[ "0.69355845", "0.6913891", "0.68512756", "0.67205346", "0.6715586", "0.6675957", "0.6669397", "0.6656227", "0.6639925", "0.66202974", "0.658203", "0.65631723", "0.6547526", "0.65273255", "0.6521165", "0.6515599", "0.65093327", "0.65016603", "0.6486856", "0.64694613", "0.64662...
0.7747361
0
Use callbacks to share common setup or constraints between actions.
def set_historic_refinancing @historic_refinancing = HistoricRefinancing.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def historic_refinancing_params params.require(:historic_refinancing).permit(:authorization_origin_id, :refinancing_id, :authorization_new_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
method to see if input is zero. num will be an integer by this point.
def zero_check(num) if num == 0 return true else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zero_check(num)\n\tif num == 0\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def zero_check(num)\n\tif num == 0\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def zero?\n end", "def zero?() end", "def zero?() end", "def maint?\n ck_valid\n return true if @num.to_i == 0\n...
[ "0.8232179", "0.8232179", "0.7674024", "0.7631737", "0.7631737", "0.76182723", "0.76136786", "0.75571", "0.7535163", "0.747269", "0.7432967", "0.7372669", "0.72873527", "0.7280025", "0.7280025", "0.7224258", "0.7200751", "0.7200751", "0.71854687", "0.7140504", "0.7137328", ...
0.7769893
2
method to get a number, use out float check and zero check methods
def take_number puts "Give me a number" num = gets.chomp if float_check(num) puts "That's a float, we need an integer" take_number else #gotta convert to Integer before zero-checking! num = num.to_i if zero_check(num) puts "Please provide a non-zero number." take_number else return num end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def numeric_check(first_num)\n Float(first_num) != nil rescue false\nend", "def check_number( num )\n if num.to_f != 0 || [\"0\", \"0.0\"].include?(num)\n is_float = false\n if num.include? \".\"\n is_float = true\n end\n if is_float\n as_number = num.to_f\n else\n as_number = num...
[ "0.72461104", "0.7072708", "0.6958549", "0.69386786", "0.6818317", "0.67287636", "0.67221653", "0.6700966", "0.66916794", "0.66840875", "0.6594276", "0.6577746", "0.6571427", "0.65697074", "0.65496683", "0.6518238", "0.6490327", "0.6471091", "0.647094", "0.6438567", "0.643151...
0.71282065
1
This renders the tag without sanitizing the ERB for our purposes. Only applies to our tags.
def render content end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render\n ignore = [ComfortableMexicanSofa::Tag::Partial, ComfortableMexicanSofa::Tag::Helper].member?(self.class)\n ComfortableMexicanSofa::Tag.sanitize_irb(content, ignore)\n end", "def handle_raw_html_tag(name); end", "def non_content_tag(tag, options = {})\n \"<#{tag}#{build_options(...
[ "0.7646507", "0.71517384", "0.65892196", "0.6502344", "0.6460767", "0.64405257", "0.63982624", "0.62895685", "0.6270404", "0.6257153", "0.6232073", "0.6213095", "0.6186665", "0.61834675", "0.6159811", "0.61528397", "0.61373836", "0.60720444", "0.60280746", "0.6004983", "0.599...
0.0
-1
GET /pay_items GET /pay_items.json
def index @pay_items = PayItem.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @items = Item.all\n @budget = Budget.find params[:budget_id]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end", "def index\n @items = @deal.items\n\n respond_to do |format|\n format.html # index.html.erb\n ...
[ "0.6698777", "0.6626402", "0.6586372", "0.6493468", "0.6489306", "0.64768225", "0.6461535", "0.6390293", "0.6349214", "0.6347588", "0.63030314", "0.6301663", "0.62759084", "0.62592155", "0.6225462", "0.6203149", "0.6198835", "0.6186378", "0.6186058", "0.617747", "0.6173079", ...
0.7323202
0
GET /pay_items/1 GET /pay_items/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @pay_items = PayItem.all\n end", "def index\n @items = Item.all\n @budget = Budget.find params[:budget_id]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end", "def show\n @items = Item.find(params[:id])\n ren...
[ "0.7056145", "0.6729322", "0.65348345", "0.65135676", "0.6501135", "0.64672774", "0.6436504", "0.6435178", "0.6356337", "0.6337632", "0.6326768", "0.6323306", "0.63163745", "0.631252", "0.6301862", "0.62987506", "0.6283048", "0.6251984", "0.625145", "0.6231431", "0.6193354", ...
0.0
-1
POST /pay_items POST /pay_items.json
def create @pay_item = PayItem.new(pay_item_params) respond_to do |format| if @pay_item.save format.html { redirect_to @pay_item, notice: 'Pay item was successfully created.' } format.json { render :show, status: :created, location: @pay_item } else format.html { render :new } format.json { render json: @pay_item.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pay_item\n Payjp.api_key = ENV[\"PAYJP_SECRET_KEY\"] # 自身のPAY.JPテスト秘密鍵を記述しましょう\n Payjp::Charge.create(\n amount: @item.price, # 商品の値段\n card: addresse_params[:token], # カードトークン\n currency: 'jpy' # 通貨の種類(日本円)\n )\n end", "def createItemOfList\n result...
[ "0.69954276", "0.67568636", "0.67464757", "0.67375886", "0.65722436", "0.6521712", "0.6521712", "0.65019155", "0.6442183", "0.63883674", "0.63790244", "0.6351111", "0.6342587", "0.63326836", "0.62851375", "0.62692964", "0.62597716", "0.6255499", "0.62399656", "0.62380457", "0...
0.7323779
0
PATCH/PUT /pay_items/1 PATCH/PUT /pay_items/1.json
def update respond_to do |format| if @pay_item.update(pay_item_params) format.html { redirect_to @pay_item, notice: 'Pay item was successfully updated.' } format.json { render :show, status: :ok, location: @pay_item } else format.html { render :edit } format.json { render json: @pay_item.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n\n if @api_v1_item.update(api_v1_item_params)\n render json: @api_v1_item\n else\n render json: @api_v1_item.errors\n end\n end", "def update\n\n #update the item of request_item\n if (params[:request_item].present?)\n @request_item.item = params[:request_item][:item].p...
[ "0.6872686", "0.6865382", "0.67721766", "0.6750225", "0.6729274", "0.67230606", "0.6651114", "0.6650124", "0.66047144", "0.6580418", "0.6554102", "0.65218574", "0.64895916", "0.64565796", "0.64287704", "0.642756", "0.6415182", "0.6410529", "0.64046925", "0.63976014", "0.63931...
0.7096462
0
DELETE /pay_items/1 DELETE /pay_items/1.json
def destroy @pay_item.destroy respond_to do |format| format.html { redirect_to pay_items_url, notice: 'Pay item was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @apiv1_item.destroy\n respond_to do |format|\n format.html { redirect_to apiv1_items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def delete\n respons...
[ "0.7206485", "0.7157227", "0.70917577", "0.7074875", "0.70119387", "0.7002367", "0.6994303", "0.6989763", "0.69590914", "0.694973", "0.6925678", "0.69170296", "0.690285", "0.6881687", "0.6867613", "0.68647504", "0.6852357", "0.6847898", "0.68217963", "0.6813169", "0.6812382",...
0.7499568
0
Use callbacks to share common setup or constraints between actions.
def set_pay_item @pay_item = PayItem.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163927", "0.6046165", "0.59465253", "0.59167755", "0.58904207", "0.58346355", "0.577713", "0.5703502", "0.5703502", "0.56531286", "0.56215113", "0.54224145", "0.5410795", "0.5410795", "0.5410795", "0.53924775", "0.5379919", "0.53580743", "0.53401667", "0.53397506", "0.533...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def pay_item_params params.require(:pay_item).permit(:id, :code, :name, :pay_item_details_attributes => [:id,:pay_item_id,:key,:value]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6980957", "0.6783065", "0.6747844", "0.6741468", "0.67356336", "0.6592548", "0.65036845", "0.64978707", "0.64825076", "0.64795035", "0.64560914", "0.64397955", "0.6379666", "0.6376688", "0.6366702", "0.6319728", "0.6300833", "0.6300629", "0.6294277", "0.6293905", "0.629117...
0.0
-1
Call setup once to pass in config variable with DB_KEY attribute
def setup(base_key) @base_key = base_key end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup!\n ActiveRecord::Base.configurations[configuration_name] = db_config\n ActiveRecord::Base.establish_connection(configuration_name).connection\n self\n end", "def setup!\n configuration = RfmAdaptor::Configuration.new(:database)\n database = configuration.__send__(self.database_n...
[ "0.68716687", "0.66743773", "0.64723265", "0.6297237", "0.62572205", "0.62529737", "0.6217905", "0.61280257", "0.61073536", "0.609962", "0.6042578", "0.60274315", "0.5974975", "0.5960831", "0.5955447", "0.5947973", "0.59315467", "0.59307325", "0.5919087", "0.5918249", "0.5911...
0.63159007
3
Encrypt with no checks
def base_encrypt(plaintext) simple_box = RbNaCl::SimpleBox.from_secret_key(key) simple_box.encrypt(plaintext) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encrypt; end", "def encrypt()\n cipher_type = \"aes-128-ecb\"\n data = password;\n key = master_password;\n \n self.encrypted_password = aes_encrypt(data,key,nil,cipher_type).to_s\n end", "def _encrypt\n cryptor_files(@encrypting)\n end", "def encrypt(*args, &block)\n crypt :encryp...
[ "0.84232396", "0.7463283", "0.73744917", "0.7315878", "0.72395307", "0.7201767", "0.7188846", "0.7160551", "0.7150453", "0.7134476", "0.7133877", "0.71092343", "0.7078616", "0.7035969", "0.70117515", "0.6996427", "0.6994424", "0.6977989", "0.69774085", "0.69542116", "0.695157...
0.70756483
13
Decrypt with no checks
def base_decrypt(ciphertext) simple_box = RbNaCl::SimpleBox.from_secret_key(key) simple_box.decrypt(ciphertext).force_encoding('UTF-8') # For an unknown reason, the decrypted result is default # to be of 'ASCII-8BIT', so we have to transform it into # UTF-8 by ourself!! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decrypt; end", "def decrypt\n self\n end", "def decrypt(txt)\n x = -1\n return txt.unpack('U*').pack('S*').unpack(\"U*\").collect do |i| \n x += 1\n x %= CRYPT.size\n i - CRYPT[x].unpack('U').first > 0 ? i - CRYPT[x].unpack('U').first : i\n end.pack('U*')\n end"...
[ "0.8668962", "0.77297175", "0.7726588", "0.7655281", "0.7591508", "0.75327796", "0.7418767", "0.7418767", "0.7418436", "0.7364942", "0.7358721", "0.73582834", "0.73411024", "0.732046", "0.73061275", "0.73018557", "0.7293156", "0.72879434", "0.72726005", "0.7271944", "0.726868...
0.68377686
58
yield a store configuration object
def store options = {}, &block @store ||= store_clazz.new @store.adapter_class ||= default_adapter_class @store.default_options = options yield @store if block_given? @store end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def config_store; end", "def configure\n\t\t\tyield configuration\n\t\tend", "def configure\n yield config\n end", "def configure\n yield config\n end", "def configure\n yield configuration\n end", "def configure\n yield configuration\n end", "def configu...
[ "0.71248466", "0.70023406", "0.6985837", "0.6985837", "0.6967441", "0.6967441", "0.6967441", "0.6967441", "0.6959279", "0.6959279", "0.6959279", "0.69570863", "0.69570863", "0.69570863", "0.69570863", "0.69570863", "0.69570863", "0.69570863", "0.69231164", "0.6878191", "0.687...
0.66063553
50
Returns a proc that accepts a hashtag and returns true/false.
def hashtag_validator context[:hashtag_validator] || ->(_hashtag) { true } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hashtag?(word)\n return false if config.include_hashtags\n !(word =~ /#(\\w+)/).nil?\n end", "def hashtag(str)\n return false if str.strip.empty?\n str = str.split(\" \").map(&:capitalize).join.prepend(\"#\")\n str.length > 30 ? false : str\nend", "def hashtag(str)\n return_string ...
[ "0.6384619", "0.61934495", "0.59491503", "0.58838457", "0.57967925", "0.574179", "0.57170844", "0.56708574", "0.5619965", "0.55519414", "0.5494064", "0.54477096", "0.5421633", "0.53473014", "0.52771825", "0.5239888", "0.5224098", "0.51864874", "0.5180065", "0.51736253", "0.51...
0.6710203
0
Returns a proc that accept a hashtag and returns an HTML string.
def hashtag_tag_buider context[:hashtag_tag_builder] || ->(hashtag) { %(<span class="hashtag-#{hashtag}">#{hashtag}</span>) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hashtag(str)\n \"##{str.to_s.sub(/\\s/, '')}\"\n end", "def hashtag(match)\n raise NotImplementedError\n end", "def hashtagify(sentence, words)\r\n\r\nend", "def hashtagify(sentence, tags)\n\nend", "def get_hash_tags\n self.text.gsub(/#(([a-z_\\-]+[0-9_\\-]*[a-z0-9_\\-]+)|([0-9_\\-]+[a-z...
[ "0.650164", "0.63160443", "0.62474674", "0.6179179", "0.6150106", "0.6081633", "0.58664674", "0.5796243", "0.5784532", "0.5783036", "0.5763252", "0.570302", "0.57010233", "0.56760806", "0.56444067", "0.56444067", "0.5620897", "0.5549236", "0.5526534", "0.54853636", "0.5440861...
0.656583
0
Replace hashtags in text with specific markup indicating a hashtag. text String text to replace hashtags in. Returns a string with hashtags replaced with HTML. All HTML will have a CSS class name attached for styling.
def hashtag_link_filter(text) self.class.hashtags_in(text) do |match, hashtag| result[:hashtags] |= [hashtag] link = if hashtag_validator.call(hashtag) hashtag_tag_buider.call(hashtag) else "##{hashtag}" end link ? match.sub("##{hashtag}", link) : match end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_for_hashtags(text)\n tags = []\n text.gsub(/\\#([\\w_\\-\\.]+)/) do\n tags << $1\n end\n tags\n end", "def auto_link_hashtags(text, options = {}, &block) # :yields: hashtag_text\n auto_link_entities(text, Extractor.extract_hashtags_with_indices(text), options, &bloc...
[ "0.71555346", "0.63828254", "0.6369482", "0.60536575", "0.59984994", "0.59545577", "0.59057397", "0.5859029", "0.5804496", "0.5795771", "0.57435584", "0.5724497", "0.5701529", "0.56847024", "0.56792045", "0.56771564", "0.5663432", "0.5652423", "0.5577726", "0.5470609", "0.543...
0.6854327
1
Assume both the given number and the number of times to count will be positive numbers greater than 0. Return the results as an array (or list in Python or Haskell.) Examples: count_by(1,10) should return [1,2,3,4,5,6,7,8,9,10] count_by(2,5) should return [2,4,6,8,10]
def count_by_x (num1, num2) array = (num1..num1 * num2).to_a array.select do |num| num % num1 == 0 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_to(num)\n arr = []\n num = num.to_int\n num > 0 ? 0.upto(num){|i| arr.push(i)} : 0.upto(-num){|i| arr.push(-i)}\n return arr\n end", "def array_nums(arr)\n\n result = []\n count = 0\n\n arr.each { |num| num!=0 ? result << num : count += 1 }\n count.times { result.push(0) }\n ...
[ "0.7604712", "0.71464854", "0.71261144", "0.7041396", "0.70303553", "0.69028103", "0.6870694", "0.68526524", "0.685261", "0.68447137", "0.68052095", "0.6793581", "0.6637527", "0.65696484", "0.65461", "0.6527136", "0.6519865", "0.65076333", "0.6503637", "0.64999485", "0.648260...
0.6600454
13
take away: parameter ( ) should be next to method name without space other answers
def count_by(x, n) (1..n).map{|i| i*x} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method_name=(_arg0); end", "def method_name=(_arg0); end", "def meth(\n\n\n\n *args)\n\nend", "def method ( a ,b ,c ) \nend", "def method(arg0)\n end", "def method(arg0)\n end", "def do_something(something, something_else, another_thing)\n\nend", "def what_am_i arg arg2\n \nend", "def...
[ "0.7195773", "0.7195773", "0.70473224", "0.6948513", "0.69151866", "0.69151866", "0.6908276", "0.6830636", "0.6810895", "0.6810895", "0.6810895", "0.6810895", "0.6810895", "0.6810895", "0.6810895", "0.6810895", "0.6810895", "0.6810895", "0.6810895", "0.6810895", "0.6783322", ...
0.0
-1
Do the thing that the item does.
def do_action if self.affects == "world" then player_tile = self.character.tile # an aoe effect is represented as a list of objects, # each one representing the effect on one tile ITEM_PROPERTIES[self.item_type]["aoe"].each do |aoe| dx = aoe["xCoordPlus"] dy = aoe["yCoordPlus"] tile_becomes = aoe["tileBecomes"] Tile.tile_at(player_tile.x + dx, player_tile.y + dy).become tile_becomes end elsif self.affects == "player" then dx = self.moves_player_x dy = self.moves_player_y # Move me to the place this item takes me if (dx != 0 or dy != 0) then target_tile = Tile.tile_at(self.character.tile.x + dx, self.character.tile.y + dy) if target_tile self.character.tile = target_tile end end self.character.heal(self.health_effect) self.character.charge(self.battery_effect) end if self.consumable then self.character.item = nil self.destroy end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def saw_item(item); end", "def process_item(item)\n raise NotImplementedError\n end", "def after_item(item)\n item\n end", "def item; end", "def item; end", "def item; end", "def item; end", "def item; end", "def item; @item; end", "def item; @item; end", "def closed_item(it...
[ "0.6732272", "0.6573746", "0.6487412", "0.63330346", "0.63330346", "0.63330346", "0.6332948", "0.6332948", "0.6310323", "0.6310323", "0.62617713", "0.62525254", "0.61334395", "0.60421216", "0.59889686", "0.5956895", "0.5951337", "0.58943105", "0.58488005", "0.5840312", "0.582...
0.600852
14
The method should return a new str where streaks of consecutive characters are compressed. For example "aaabbc" is compressed to "3a2bc".
def compress_str(str) comp_str = "" (0..str.length - 1).each do |i| if str[i + 1] != nil if str[i] == str[i+1] if comp_str[-1] == str[i] # add one on the existing val = comp_str[-2].to_i + 1 comp_str[-2] = val.to_s else comp_str += "2"+str[i] end else if comp_str[-1] != str[i] comp_str += str[i] end end else if comp_str[-1] != str[i] comp_str += str[i] end end end return comp_str end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compress(str)\n compressed = ''\n chars = str.split('')\n idx = 0\n\n while idx <= chars.length-1\n streak = 1\n char = chars[idx]\n while chars[idx] == chars[idx+1]\n streak += 1\n idx+= 1\n end\n idx += 1\n if streak > 1\n compressed += char + streak.to_s\n else\n ...
[ "0.83493584", "0.8134053", "0.8078203", "0.801563", "0.7973104", "0.7876303", "0.78326935", "0.7754331", "0.7753845", "0.77417135", "0.7663354", "0.7661357", "0.76564944", "0.76150846", "0.75982404", "0.7583838", "0.7581263", "0.75707674", "0.7568592", "0.75315326", "0.752326...
0.6934707
53
Initialize state used for reading.
def init @inputs = {} @outputs = {} @triggers = [] @filters = [] @songs = {} # key = name, value = song end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(state); end", "def read_state\n end", "def initialize\n\t\t@current_state = {:A1 => nil, :A2 => nil, :A3 => nil,\n\t\t :B1 => nil, :B2 => nil, :B3 => nil, \n\t\t :C1 => nil, :C2 => nil, :C3 => nil}\n @over = false\n end", "def define_state_initializ...
[ "0.7214005", "0.68972236", "0.66900015", "0.6667511", "0.66566", "0.6638813", "0.66218084", "0.6543068", "0.65326595", "0.6478339", "0.64619905", "0.6461364", "0.6461364", "0.642674", "0.6414132", "0.6414132", "0.6353717", "0.6340366", "0.6323871", "0.6314507", "0.6314507", ...
0.5849639
80
in_chan can be skipped, so "connection :foo, :bar, 1" is the same as "connection :foo, nil, :bar, 1".
def connection(in_sym, in_chan, out_sym, out_chan=nil) input = @inputs[in_sym] if in_chan.kind_of? Symbol out_chan = out_sym out_sym = in_chan in_chan = nil end raise "can't find input instrument #{in_sym}" unless input output = @outputs[out_sym] raise "can't find outputput instrument #{out_sym}" unless output @conn = Connection.new(input, in_chan, output, out_chan) @patch << @conn yield @conn if block_given? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ignore_disconnect=(_arg0); end", "def test_nil_connparms\n @conn.disconnect\n #\n assert_nothing_raised do\n @conn = Stomp::Connection.open(nil, nil, host, port, false, 5, nil)\n end\n checkEmsg(@conn)\n end", "def recvfrom_nonblock(*rest) end", "def recvfrom_nonblock(*rest) end", ...
[ "0.5840783", "0.55254537", "0.5272181", "0.5272181", "0.52388054", "0.5193079", "0.51917094", "0.5147353", "0.51427567", "0.49973512", "0.49886435", "0.4978735", "0.497081", "0.49595866", "0.49546838", "0.4951399", "0.49220046", "0.4880338", "0.48769915", "0.48750508", "0.485...
0.527994
2
If only +bank_or_prog+ is specified, then it's a program change. If both, then it's bank number.
def prog_chg(bank_or_prog, prog=nil) if prog @conn.bank = bank_or_prog @conn.pc_prog = prog else @conn.pc_prog = bank_or_prog end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pay_bank\n case result\n when :player_win\n player.increase_bank(game_bank)\n when :dealer_win\n dealer.increase_bank(game_bank)\n else\n return_bank\n end\n end", "def proceeding_or_congress\n if record.leader[12] == '1' || (record['008'] && record['008'].value[29] == '...
[ "0.5402256", "0.52354336", "0.5218853", "0.5190249", "0.5138523", "0.51176167", "0.50791764", "0.50433946", "0.5021465", "0.49777356", "0.49739745", "0.49411097", "0.4922977", "0.48978367", "0.48892963", "0.48567986", "0.4852901", "0.48351878", "0.48272893", "0.48255196", "0....
0.7462571
0
If +start_or_range+ is a Range, use that. Else either or both params may be nil.
def zone(start_or_range=nil, stop=nil) @conn.zone = if start_or_range.kind_of? Range start_or_range elsif start_or_range == nil && stop == nil nil else ((start_or_range || 0) .. (stop || 127)) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def range_begin_and_end(range_or_span)\n rbegin, rend = range_or_span.kind_of?(Range) ? split_range(range_or_span) : split_span(range_or_span)\n raise ArgumentError.new(\"negative offset specified: #{PP.singleline_pp(range_or_span,'')}\") if rbegin < 0\n rend += rbegin\n \n [rbegin, rend]\...
[ "0.6279687", "0.6118772", "0.59641075", "0.5919182", "0.589778", "0.5714475", "0.5688208", "0.56202704", "0.5582047", "0.55593425", "0.55586725", "0.5558505", "0.55577993", "0.55019563", "0.54982185", "0.5489078", "0.5467642", "0.5433889", "0.54210055", "0.54210055", "0.53856...
0.0
-1
Extremely simple block text reader. Relies on indentation to detect end of code block.
def read_block_text(name, containers, contents) i = -1 in_block = false block_indentation = nil block_end_token = nil contents.each_line do |line| if line =~ /^(\s*)#{name}\s*.*?(({|do|->\s*{|lambda\s*{)(.*))/ block_indentation, text = $1, $2 i += 1 containers[i].text = text + "\n" in_block = true block_end_token = case text when /^{/ "}" when /^do\b/ "end" when /^(->|lambda)\s*({|do)/ $2 == "{" ? "}" : "end" else "}|end" # regex end elsif in_block line =~ /^(\s*)(.*)/ indentation, text = $1, $2 if indentation.length <= block_indentation.length if text =~ /^#{block_end_token}/ containers[i].text << line end in_block = false else containers[i].text << line end end end containers.each { |thing| thing.text.strip! if thing.text } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_block_text(name, containers, contents)\n i = -1\n in_block = false\n block_indentation = nil\n block_end_token = nil\n chunk = nil\n contents.each_line do |line|\n if line =~ /^(\\s*)#{name}\\s*.*?(({|do|->\\s*{|lambda\\s*{)(.*))/\n block_indentation, text = $1, $2\n i...
[ "0.7685842", "0.6659547", "0.6607828", "0.6547711", "0.645204", "0.6364593", "0.6362941", "0.635615", "0.63357824", "0.63309664", "0.6321288", "0.6290178", "0.6225824", "0.6184942", "0.6097379", "0.6084647", "0.6082936", "0.60515267", "0.6040758", "0.5997457", "0.5911156", ...
0.7546723
1
GET /ads GET /ads.json
def index @ads = Ad.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @ads = Ad.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ads }\n end\n end", "def index\n @ads = Ad.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ads }\n end\n end", "def...
[ "0.7752131", "0.7749316", "0.7291679", "0.726539", "0.7224467", "0.712877", "0.712877", "0.712877", "0.7110715", "0.6884924", "0.68810844", "0.68610626", "0.6854222", "0.68104106", "0.67929673", "0.67929673", "0.6782109", "0.6770735", "0.67337316", "0.6730005", "0.6673539", ...
0.71702427
8
GET /ads/1 GET /ads/1.json
def show @ad = Ad.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @ads = Ad.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ads }\n end\n end", "def index\n @ads = Ad.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ads }\n end\n end", "def...
[ "0.75970733", "0.7587807", "0.730965", "0.730965", "0.730965", "0.71618325", "0.7091579", "0.7060379", "0.698387", "0.698387", "0.698387", "0.698387", "0.698387", "0.6965706", "0.69487184", "0.6883612", "0.68527615", "0.6832596", "0.6781336", "0.6744042", "0.67338634", "0.6...
0.67248225
22
POST /ads POST /ads.json
def create @ad = Ad.new(ad_params) if @ad.save redirect_to @ad else render 'new' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @ad = Ad.new(ad_params)\n\n if @ad.save\n render :show, status: :created, location: @ad\n else\n render json: @ad.errors, status: :unprocessable_entity\n end\n end", "def create\n @ad = Ad.new(ad_params)\n\n respond_to do |format|\n if @ad.save\n format.html ...
[ "0.71053267", "0.7015489", "0.70129645", "0.6978938", "0.6959221", "0.6880752", "0.6797544", "0.6730011", "0.66874087", "0.664503", "0.6628324", "0.64958876", "0.64636236", "0.64588016", "0.64285856", "0.6422988", "0.6417705", "0.63306296", "0.63092023", "0.6309034", "0.62962...
0.6006261
46
PATCH/PUT /ads/1 PATCH/PUT /ads/1.json
def update @ad = Ad.find(params[:id]) if @ad.update_attributes(ad_params) redirect_to @ad else render 'edit' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @ad = Ad.find(params[:id])\n\n respond_to do |format|\n if @ad.update_attributes(params[:ad])\n format.html { redirect_to @ad, notice: 'Ad was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n form...
[ "0.6941293", "0.6941293", "0.67223084", "0.6673", "0.6673", "0.6673", "0.6645192", "0.6614588", "0.65788114", "0.6550533", "0.65486884", "0.6514856", "0.65075403", "0.64893997", "0.6478953", "0.6460785", "0.64602375", "0.64601386", "0.64575773", "0.64546096", "0.6449106", "...
0.61607695
47
DELETE /ads/1 DELETE /ads/1.json
def destroy Ad.find(params[:id]).destroy redirect_to ads_url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @ad = Ad.find(params[:id])\n @ad.destroy\nrender json: 1\n end", "def destroy\n @ad = Ad.find(params[:id])\n @ad.destroy\n\n respond_to do |format|\n format.html { redirect_to ads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @home_indices_...
[ "0.7637339", "0.7542011", "0.75137264", "0.73285", "0.72981167", "0.7294329", "0.7290231", "0.7290231", "0.72807807", "0.72807807", "0.7275584", "0.7233481", "0.72154176", "0.72154176", "0.72154176", "0.72122157", "0.7211167", "0.7211167", "0.7211167", "0.7201754", "0.7187984...
0.7100949
30
Use callbacks to share common setup or constraints between actions.
def set_ad @ad = Ad.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def ad_params params.require(:ad).permit(:body, :img, :price, :url, :picture) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6978086", "0.6780264", "0.6742658", "0.6738813", "0.67338693", "0.65908474", "0.6501793", "0.6495506", "0.64796513", "0.64755446", "0.6454826", "0.6437561", "0.6377127", "0.63722163", "0.6364058", "0.63178706", "0.62979764", "0.62968165", "0.62913024", "0.6289789", "0.6289...
0.0
-1
The long way def fibonacci(position) return 1 if position == 1 || position == 2 return 2 if position == 3 first = 1 second = 1 fibonacci = first + second counter = 3 loop do first = second second = fibonacci fibonacci = first + second counter +=1 break if counter == position end fibonacci end The refactored way
def fibonacci(position) first, last = [1, 1] 3.upto(position) do first, last = [last, first + last] end last end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fibonacci(position)\n return 1 if position <= 2 \n fibonacci(position - 1) + fibonacci(position - 2)\nend", "def fibonacci_table_2(position)\n return 1 if position == 1 || position == 2\n\n prev_1 = 1\n prev_2 = 1\n\n (3..position).map do |index|\n result = prev_1 + prev_2\n\n prev_1 = prev_2\n ...
[ "0.8973942", "0.8251928", "0.81690407", "0.81679213", "0.8140632", "0.8136118", "0.8136118", "0.8135908", "0.812331", "0.81115997", "0.8086898", "0.8069257", "0.8069257", "0.8069257", "0.8069257", "0.80661976", "0.8062581", "0.8058001", "0.8056078", "0.8052697", "0.80517083",...
0.847325
1
GET /subsedes GET /subsedes.json
def index @subsedes = Subsede.all respond_to do |format| format.html # index.html.erb format.json { render json: @subsedes } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trades\n Client.current.get(\"#{resource_url}/trades\")\n end", "def subaccounts()\n get('subAccounts')\n end", "def get_subcategory\n @subcategories = EventCategoryMaster.find_subcategory(params[:id])\n respond_to do |format|\n format.json { render :json => @subcategories }\n ...
[ "0.6672206", "0.6159205", "0.6052206", "0.58815944", "0.5759145", "0.57336265", "0.5699563", "0.5600906", "0.55811775", "0.55168414", "0.54955447", "0.5439873", "0.5428683", "0.53740585", "0.5361216", "0.53501874", "0.5337079", "0.5296117", "0.5255743", "0.5209044", "0.520090...
0.7671792
0
GET /subsedes/1 GET /subsedes/1.json
def show @subsede = Subsede.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @subsede } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @subsedes = Subsede.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subsedes }\n end\n end", "def get_subcategory\n @subcategories = EventCategoryMaster.find_subcategory(params[:id])\n respond_to do |format|\n format.json ...
[ "0.7634547", "0.6315139", "0.6229804", "0.61797225", "0.60672444", "0.5910954", "0.58819133", "0.57632047", "0.5761183", "0.57564217", "0.5722033", "0.57210296", "0.5716337", "0.5701361", "0.5654879", "0.5649569", "0.5635392", "0.56090504", "0.5597982", "0.554515", "0.5536157...
0.660069
1
GET /subsedes/new GET /subsedes/new.json
def new @subsede = Subsede.new respond_to do |format| format.html # new.html.erb format.json { render json: @subsede } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @subsede = Subsede.new(params[:subsede])\n\n respond_to do |format|\n if @subsede.save\n format.html { redirect_to @subsede, notice: 'Subsede was successfully created.' }\n format.json { render json: @subsede, status: :created, location: @subsede }\n else\n format....
[ "0.64904326", "0.64836603", "0.6480606", "0.6458485", "0.6412106", "0.6400963", "0.6375592", "0.6237675", "0.61864424", "0.614493", "0.6125312", "0.61203694", "0.6077097", "0.60264474", "0.60133344", "0.6003896", "0.5992812", "0.59882957", "0.5985208", "0.594908", "0.5915483"...
0.7175156
0
POST /subsedes POST /subsedes.json
def create @subsede = Subsede.new(params[:subsede]) respond_to do |format| if @subsede.save format.html { redirect_to @subsede, notice: 'Subsede was successfully created.' } format.json { render json: @subsede, status: :created, location: @subsede } else format.html { render action: "new" } format.json { render json: @subsede.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @subsedes = Subsede.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subsedes }\n end\n end", "def trades\n Client.current.get(\"#{resource_url}/trades\")\n end", "def new\n @subsede = Subsede.new\n\n respond_to do |format...
[ "0.64683187", "0.5403426", "0.5265004", "0.49996507", "0.49778998", "0.49577346", "0.49060202", "0.48734495", "0.4853653", "0.48440176", "0.48432654", "0.484051", "0.48361108", "0.48280734", "0.48039824", "0.47719365", "0.47704795", "0.47602877", "0.47380465", "0.47330835", "...
0.62414056
1
PUT /subsedes/1 PUT /subsedes/1.json
def update @subsede = Subsede.find(params[:id]) respond_to do |format| if @subsede.update_attributes(params[:subsede]) format.html { redirect_to @subsede, notice: 'Subsede was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @subsede.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @subsidy = Subsidy.find(params[:id])\n\n respond_to do |format|\n if @subsidy.update_attributes(params[:subsidy])\n format.html { redirect_to @subsidy, notice: 'Заявка на материальную выплату успешно обновлена.' }\n format.json { head :no_content }\n else\n format....
[ "0.603363", "0.60021627", "0.58569366", "0.5773086", "0.56634325", "0.5612475", "0.5561106", "0.55511135", "0.55255127", "0.55080026", "0.5500562", "0.5493579", "0.5466312", "0.5447754", "0.54415846", "0.54266715", "0.5411663", "0.5405853", "0.53917754", "0.53857493", "0.5355...
0.63716424
0
DELETE /subsedes/1 DELETE /subsedes/1.json
def destroy rol = Role.where(:id=>current_user.role).first if rol.nombre == "ACRM" @subsede = Subsede.find(params[:id]) @subsede.destroy else flash[:error] ='No tienes permiso para realizar esta accion' end respond_to do |format| format.html { redirect_to subsedes_url } format.json { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\",...
[ "0.71762305", "0.67040414", "0.6697854", "0.6689113", "0.6684735", "0.6604387", "0.6568902", "0.65512097", "0.65378094", "0.6515093", "0.65095013", "0.64904076", "0.6472413", "0.6462959", "0.6455148", "0.64451855", "0.6428347", "0.642557", "0.6414221", "0.6371533", "0.6355958...
0.0
-1
Given an array a, find its inversion count. Since this number could be quite large, take it modulo 109 + 7. Example For a = [3, 1, 5, 6, 4], the output should be countInversions(a) = 3. The three inversions in this case are: (3, 1), (5, 4), (6, 4). O(n log n) using merge_sort
def countInversions(a) def merge arr,*new return [0,arr] if arr.size == 1 inv_merge = i = j = 0 inv_left, left = merge(arr[0...mid = arr.size / 2]) inv_right, right = merge(arr[mid..-1]) while i < mid && j < right.size if right[j] < left[i] inv_merge += mid - i new << right[j] j += 1 else new << left[i] i += 1 end end [inv_left + inv_merge + inv_right, new + (i < mid ? left[i..-1] : right[j..-1]) ] end merge(a)[0] % (10 ** 9 + 7) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calc_inversions arr\n n = arr.length\n return [0, arr] if n == 1\n half = n.even? ? n / 2 : (n + 1) / 2\n left_inversions, left_arr = calc_inversions(arr[0, half])\n right_inversions, right_arr = calc_inversions(arr[half, n])\n num_inversions, sorted_arr = count_and_sort_split_inversions(left_arr, right...
[ "0.77413183", "0.76733434", "0.76511395", "0.7640608", "0.75471836", "0.74249804", "0.6996806", "0.6797436", "0.6586148", "0.6562585", "0.654298", "0.65028524", "0.6421788", "0.639694", "0.63956743", "0.6370991", "0.6319143", "0.62900347", "0.62720746", "0.62564045", "0.62143...
0.8242521
0
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.vin_cod_notifier.received.subject
def received(vin_cod) @vin_cod = vin_cod mail to: "falcon.vinnica@gmail.com", subject: 'Запрос по vin коду на Falcon motors' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subject\n self['subject'] || msg['subject']\n end", "def message_subject=(value)\n @message_subject = value\n end", "def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end", "def subject=(subject); @message_impl.setSubject subject; e...
[ "0.7267883", "0.71876305", "0.6838267", "0.6820112", "0.66261905", "0.6602714", "0.6602339", "0.65971935", "0.6563343", "0.6497121", "0.6374895", "0.63012147", "0.63012147", "0.63012147", "0.63012147", "0.63012147", "0.63012147", "0.6279886", "0.6229175", "0.6114526", "0.6101...
0.0
-1
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.vin_cod_notifier.shipped.subject
def shipped end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end", "def subject\n self['subject'] || msg['subject']\n end", "def translate(mapping, key)\n I18n.t(:\"#{mapping.name}_subje...
[ "0.6680246", "0.66052216", "0.65949005", "0.65249217", "0.63013834", "0.6273864", "0.6249147", "0.62321764", "0.6166794", "0.61611646", "0.61535764", "0.6128379", "0.6112418", "0.611064", "0.61073655", "0.6094869", "0.60456353", "0.6026351", "0.6024838", "0.59947413", "0.5985...
0.0
-1
Usage: SideKiq, Mailroom, CI Runner, Workhorse, push services
def redis_queues_cleanup! Gitlab::Redis::Queues.with(&:flushdb) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main()\n\t@home_directory=\"/home/ubuntu\"\n\t@curl_path =\"/usr/bin\"\n\t@curl_command = \"curl\"\n\t@dummy_directory=\"/opt/cloudfoundry/dummy\"\n\t@project = \"redis\"\n\t@zip_path = \"/opt/cloudfoundry/gitzip/#{@project}\"\n\t@project_directory = \"/opt/cloudfoundry/project\"\n\t@git_url =\"https://github....
[ "0.6090111", "0.5951816", "0.58853817", "0.5794052", "0.5762635", "0.5720659", "0.57162184", "0.5713657", "0.5705145", "0.5699208", "0.56854594", "0.56668496", "0.5656947", "0.56537426", "0.56423354", "0.562954", "0.56174535", "0.5617125", "0.5607879", "0.5568908", "0.5565219...
0.0
-1
Usage: session state, rate limiting
def redis_shared_state_cleanup! Gitlab::Redis::SharedState.with(&:flushdb) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def session_rate_limit\n SessionTracker.where(session_id: request.session.id, created_at:(Date.today.beginning_of_day..Date.today.end_of_day)).count\n end", "def rate_limit_sessions(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"rate-limit sessions \" +...
[ "0.67835796", "0.6548063", "0.6371116", "0.6371116", "0.6371116", "0.6371116", "0.63233614", "0.63233614", "0.616242", "0.61279166", "0.6100856", "0.60760015", "0.59837556", "0.59824306", "0.5974538", "0.59136486", "0.59128654", "0.5883614", "0.5844092", "0.5839629", "0.58269...
0.0
-1
Usage: CI trace chunks
def redis_trace_chunks_cleanup! Gitlab::Redis::TraceChunks.with(&:flushdb) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(chunk_id, logger)\n @logger = logger\n logger.info \"\\n(#{chunk_id}) Processing backtest with a #{et_name} entry trigger and #{es_name} entry with #{xt_name} trigger and #{xs_name} exit against #{scan_name}\"\n\n @chunk_id = chunk_id\n @etrigger_decl = et_name && $analytics.find_etrigge...
[ "0.6046587", "0.6007516", "0.5935073", "0.57423824", "0.57120043", "0.568769", "0.5649726", "0.5641693", "0.55726564", "0.55464053", "0.55417293", "0.55324477", "0.5521259", "0.5452181", "0.54280156", "0.5391124", "0.5326364", "0.5326364", "0.5319327", "0.53142023", "0.531412...
0.0
-1
Usage: rate limiting state (for Rack::Attack)
def redis_rate_limiting_cleanup! Gitlab::Redis::RateLimiting.with(&:flushdb) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def throttle_api\n Rate::Limiter.new(request.env['REMOTE_ADDR'], request.env['REQUEST_PATH']).set\n end", "def throttled_response; end", "def rate_limit\n new_request=RequestLimit.new({ip:request.remote_ip.to_s})\n\n # create a new record of RequestLimit to keep count of the incomming requests\n n...
[ "0.74972504", "0.6790294", "0.6649531", "0.6647896", "0.6627824", "0.6618208", "0.6563615", "0.6555933", "0.65532494", "0.6540208", "0.6516489", "0.64877087", "0.64640504", "0.64626074", "0.6456751", "0.64008087", "0.6365426", "0.63613313", "0.633696", "0.63222736", "0.632194...
0.0
-1
Usage: reset cached instance config
def redis_clear_raw_config!(instance_class) instance_class.remove_instance_variable(:@_raw_config) rescue NameError # raised if @_raw_config was not set; ignore end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset\n @@config_instance = nil\n end", "def reset\n @config = Config.new\n end", "def reset\n @config = nil\n end", "def reset!\n @config = Configuration.new\n end", "def reset_config\n\t\t\t@config = {}\n\t\tend", "def reset\n Configuration.new\n end", "def res...
[ "0.83397305", "0.7769293", "0.7756875", "0.76475227", "0.7573723", "0.7521207", "0.7517122", "0.74965245", "0.7471938", "0.73608667", "0.7313416", "0.72594523", "0.72327733", "0.7198237", "0.7128226", "0.7126185", "0.7118482", "0.711749", "0.71141356", "0.71109134", "0.707514...
0.6583181
61
Validates context keys in the ruby Hash. Any unknown key raises an Exception. public method for testing purposes.
def validate_ctx(ctx) logger.debug 'Validating %s' % ctx.keys.inspect # any unknown key raises an Exception invalid_keys = (ctx.keys | context_keys) - context_keys if invalid_keys.any? msg = 'Invalid keys: %s' % invalid_keys.inspect logger.debug msg raise Exception, msg end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_keys(*valid_keys)\n valid_keys.flatten!\n @hash.each_key do |k|\n unless valid_keys.include?(k)\n raise ArgumentError.new(\"Unknown key: #{k.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}\")\n end\n end\n end", "def verify_key(key, context ...
[ "0.7334264", "0.6459851", "0.6424663", "0.63717186", "0.62911737", "0.6258876", "0.62213856", "0.61878353", "0.6162263", "0.61325896", "0.6115989", "0.6114281", "0.6069887", "0.60267186", "0.6016784", "0.596645", "0.5960104", "0.5956408", "0.5954517", "0.5947793", "0.5933274"...
0.79656994
0
Initializes context and requests the JavaBean Home. Params: jndi_name (String) bean_home_class (String) If class narrowing is needed to locate the proper Home object, define bean_home_class
def lookup(jndi_name,bean_home_class=nil) logger.debug 'Lookup of %s' % jndi_name home = @context.lookup(jndi_name) #logger.debug 'HomeObject found: %s (%s)' % [ jndi_name,bean_home_class ] if bean_home_class ### Same Host, Different Context: Remote Home # # Note: unlike the Local Home Interface example, the reference to the Remote Home Interface is a conventional JNDI # name that is generated by WSAD and is visible in the object's Deployment Desciptor. It is because WSAD generates # a JNDI name to this interface, not the Local interface, that one must use the Reference form shown above. # # Note also, that the object obtained is a stub delivered through IIOP, a CORBA protocol used to support # remote procedure calls. Consequently, it must be converted to a conventional Java object from its CORBA form; # this is done through the process of narrowing. # # http://www.cs.unc.edu/Courses/jbs/lessons/enterprise/ejb_jndi/ return PortableRemoteObject.narrow( home, Kernel.const_get(bean_home_class).java_class ) else return home end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_home\n end", "def set_user_home\n @user_home = UserHome.find(params[:id])\n end", "def render_home_class\n if request.original_fullpath == '/'\n ' home'\n end\n end", "def set_home\n @home = Home.find(params[:id])\n end", "def set_home\n @home = Home.find(params[...
[ "0.47399926", "0.45524517", "0.45367843", "0.4534411", "0.4534411", "0.4534411", "0.4534411", "0.4534411", "0.4534411", "0.4534411", "0.44964892", "0.44964892", "0.4472379", "0.4471048", "0.44192937", "0.43349084", "0.42838508", "0.42413196", "0.42347512", "0.42347512", "0.42...
0.75319886
0
Sets up an initial context that can be used for looking up JNDI names.
def initial_context(ctx) InitialContext.new(self.properties(ctx)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def context\n init\n @context\n end", "def lookup_context=(_arg0); end", "def setup(_context)\n end", "def initialize_context(**opt)\n ctx = opt.delete(:context)&.merge(opt) || opt\n ctx[:controller] &&= ctx[:controller].to_sym\n ctx[:action] &&= ctx[:action].to_sym\n ...
[ "0.6061553", "0.5934442", "0.5867617", "0.5723814", "0.5705469", "0.5705469", "0.5705469", "0.56690115", "0.56395423", "0.5622796", "0.5622796", "0.5617724", "0.5594186", "0.5572045", "0.5523717", "0.5509633", "0.55045676", "0.5500078", "0.54431003", "0.5439948", "0.5397916",...
0.69250923
0
Converts the ruby context Hash to java.util.Properties.
def properties(ctx) properties = Properties.new() ctx.each { |key, value| properties.put(key, value) } return properties end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def properties_hash\n hash = {}\n password_keys = $SERVICE_TYPES[self.service_type][PrismeService::TYPE_PROPS].reject do |e| !e[PrismeService::TYPE_TYPE].eql? PrismeService::TYPE_PASSWORD end.map do |e| e['key'] end\n self.service_properties.each do |sp|\n key = sp.key\n value = sp.value\n ...
[ "0.5777328", "0.5598935", "0.557906", "0.5543061", "0.55364394", "0.5530488", "0.5528515", "0.54810494", "0.5479729", "0.5467654", "0.54667753", "0.54528767", "0.54528767", "0.544966", "0.5443887", "0.5396633", "0.5388512", "0.5388512", "0.53807944", "0.5379407", "0.53695345"...
0.65293074
0
Lookup, and cache, a RePEc ID for the given pub. We cache to speed the case of checking and immediately updating the metadata.
def lookupRepecID(elemPubID) if !$repecIDs.key?(elemPubID) # The only way we know of to get the RePEc ID is to ask the Elements API. apiHost = ENV['ELEMENTS_API_URL'] || raise("missing env ELEMENTS_API_URL") resp = HTTParty.get("#{apiHost}/publications/#{elemPubID}", :basic_auth => { :username => ENV['ELEMENTS_API_USERNAME'] || raise("missing env ELEMENTS_API_USERNAME"), :password => ENV['ELEMENTS_API_PASSWORD'] || raise("missing env ELEMENTS_API_PASSWORD") }) resp.code == 404 and return nil # sometimes Elements does meta update on non-existent pub, e.g 2577213. Weird. resp.code == 410 and return nil # sometimes Elements does meta update on deleted pub, e.g 2564054. Weird. resp.code == 200 or raise("Updated message : Got error from Elements API #{apiHost} for pub #{elemPubID}: #{resp}") data = Nokogiri::XML(resp.body).remove_namespaces! repecID = data.xpath("//record[@source-name='repec']").map{ |r| r['id-at-source'] }.compact[0] $repecIDs.size >= MAX_USER_ERRORS and $repecIDs.shift $repecIDs[elemPubID] = repecID end return $repecIDs[elemPubID] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pub_id(doc)\n # anchor(doc).gsub(\".\", \" \")\n fetch_doi(doc).split(\"/\")[1..].join(\"/\").gsub(\".\", \" \").sub(/^nist\\sir/, \"NIST IR\")\n end", "def pub_id\n\t\treturn self.id\n\tend", "def _find_citation_id_in_db(pmid, name, authors, year)\n # PMID is a string. Do a little clean-up...
[ "0.61732936", "0.6062297", "0.59607357", "0.5939616", "0.589731", "0.5560479", "0.5374209", "0.53079545", "0.5281652", "0.526364", "0.52252007", "0.5221888", "0.52163696", "0.5187675", "0.5180443", "0.5175671", "0.51191276", "0.5106002", "0.5093104", "0.50922316", "0.5086962"...
0.7294648
0
Take feed XML from Elements and make an eschol JSON record out of it. Note that if you pass existing eschol data in, it will be retained if Elements doesn't override it.
def elementsToJSON(oldData, elemPubID, submitterEmail, metaHash, ark, feedFile) # eSchol ARK identifier (provisional ID minted previously for new items) data = oldData ? oldData.clone : {} data[:id] = ark # Identify the source system data[:sourceName] = 'elements' data[:sourceID] = elemPubID data[:sourceFeedLink] = "#{$submitServer}/bitstreamTmp/#{feedFile}" # Object type, flags, status, etc. elementsPubType = metaHash.delete('object.type') || raise("missing object.type") elementsPubStatus = metaHash['publication-status'] || nil elementsIsReviewed = metaHash.delete('is-reviewed') || nil data[:isPeerReviewed] = getDefaultPeerReview(elementsIsReviewed, elementsPubType, elementsPubStatus) data[:type] = convertPubType(elementsPubType) data[:isPeerReviewed] = true # assume all Elements items are peer reviewed if (elementsPubType == 'preprint' || (elementsPubType == 'journal-article' && (elementsPubStatus == 'In preparation' || elementsPubStatus == 'Submitted' || elementsPubStatus == 'Unpublished') ) ) data[:isPeerReviewed] = false # assume preprints are not peer reviewed end data[:pubRelation] = convertPubStatus(metaHash.delete('publication-status')) data[:embargoExpires] = assignEmbargo(metaHash) # Author and editor metadata. metaHash['authors'] && data[:authors] = transformPeople(metaHash.delete('authors'), nil) if metaHash['editors'] || metaHash['advisors'] contribs = [] metaHash['editors'] and contribs += (transformPeople(metaHash.delete('editors'), 'EDITOR') || []) metaHash['advisors'] and contribs += (transformPeople(metaHash.delete('advisors'), 'ADVISOR') || []) !contribs.empty? and data[:contributors] = contribs end # Other top-level fields metaHash.key?('title') and data[:title] = sanitizeHTML(metaHash.delete('title')).gsub(/\s+/, ' ').strip metaHash.key?('abstract') and data[:abstract] = sanitizeHTML(metaHash.delete('abstract')) data[:localIDs] = [] metaHash.key?('doi') and data[:localIDs] << { id: metaHash.delete('doi'), scheme: 'DOI' } data[:localIDs] << {id: elemPubID, scheme: 'OA_PUB_ID'} metaHash.key?('fpage') and data[:fpage] = metaHash.delete('fpage') metaHash.key?('lpage') and data[:lpage] = metaHash.delete('lpage') metaHash.key?('keywords') and data[:keywords] = convertKeywords(metaHash.delete('keywords')) if metaHash.key?('requested-reuse-licence.short-name') if metaHash['requested-reuse-licence.short-name'] != "No Licence" ccCode = metaHash.delete('requested-reuse-licence.short-name') data[:rights] = "https://creativecommons.org/licenses/#{ccCode.sub("CC ", "").downcase}/4.0/" end end metaHash.key?('funder-name') and data[:grants] = convertFunding(metaHash) #metaHash.key?('funder-type-display-name') # Context assignSeries(data, getCompletionDate(data, metaHash), metaHash) lookupRepecID(elemPubID) and data[:localIDs] << { scheme: 'OTHER_ID', subScheme: 'repec', id: lookupRepecID(elemPubID) } metaHash.key?("report-number") and data[:localIDs] << { scheme: 'OTHER_ID', subScheme: 'report', id: metaHash.delete('report-number') } metaHash.key?("issn") and data[:issn] = metaHash.delete("issn") metaHash.key?("isbn-13") and data[:isbn] = metaHash.delete("isbn-13") # for books and chapters metaHash.key?("journal") and data[:journal] = metaHash.delete("journal") metaHash.key?("proceedings") and data[:proceedings] = metaHash.delete("proceedings") metaHash.key?("volume") and data[:volume] = metaHash.delete("volume") metaHash.key?("issue") and data[:issue] = metaHash.delete("issue") metaHash.key?("parent-title") and data[:bookTitle] = metaHash.delete("parent-title") # for chapters metaHash.key?("oa-location-url") and convertOALocation(ark, metaHash, data) data[:ucpmsPubType] = elementsPubType # History data[:published] = convertPubDate(metaHash.delete('publication-date')) data[:submitterEmail] = submitterEmail # Custom Citation Field metaHash.key?("custom-citation") and data[:customCitation] = metaHash.delete("custom-citation") # All done. return data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convertXML(xml)\n\t\n\t# Start up the JSON string we'll eventually return\n\tjson = \"{\"\n\t\n\t# Start the loop\n\txml.search(\"/\").each do |element|\n\t\t\n\t\t# Only get elements, not text or comments\n\t\tif (element.is_a?(Hpricot::Elem))\n\t\t\t\n\t\t\t# If it's not a block element\n\t\t\tif (!/^block./...
[ "0.57341266", "0.55942506", "0.54840463", "0.54806757", "0.54610115", "0.54068375", "0.52999157", "0.5296733", "0.5289285", "0.52419615", "0.52294", "0.5227479", "0.52212393", "0.5220934", "0.5160554", "0.5124641", "0.50971097", "0.5091318", "0.509055", "0.50348717", "0.50183...
0.6402438
0
Goal is to run a function 10 different ways
def flipFlop(cost, color) case color.downcase when "yellow" puts "Order the AK-47 flip flop for $#{cost}" when "red" puts "Order the Tuck Tuck flip flop for $#{cost}" when "blue" puts "Order the Posidon flip flop for $#{cost}" when "black" puts "Order the Bombshell Dark flip flop for $#{cost}" else puts "As of 22MAR14 they didn't have #{color}. Check their site for updates." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_stuff more_actions=[], num_actions=5\n actions = []\n num_actions.times do\n actions.push ((['move', 'eat', 'nap'] + more_actions).sample)\n end\n actions.each do |action|\n m = method action\n m.call\n end\n puts \"#{@name} is done doing stuff!\"\n end", "def perform\n ...
[ "0.6483298", "0.62098247", "0.62096477", "0.62096477", "0.62068456", "0.62068456", "0.6192233", "0.6190872", "0.6143699", "0.61396253", "0.60227233", "0.59470564", "0.59387714", "0.59173995", "0.5912312", "0.5912312", "0.5889219", "0.5885885", "0.5864744", "0.58583283", "0.58...
0.0
-1
completed 2/1/17 times out on test 4 because insertion sort is not efficient enough.
def index_for_insert(element, arr) arr.each_with_index { |num,i| if element <= num then return i end} -1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insertion_sort(array)\n # Takes n passes here.\n (1...array.size).each{ |i|\n j = i\n # and this also takes n, but the distance of the count decreases\n # each time.\n while j > 0 and array[j - 1] > array[j]\n temp = array[j]\n array[j] = array[j-1]\n array[j-1] = temp\n\n j -...
[ "0.79225075", "0.77891994", "0.7723855", "0.76675916", "0.76350534", "0.76270676", "0.76196384", "0.76024115", "0.75824744", "0.75660795", "0.7560894", "0.75288963", "0.7511074", "0.75082976", "0.749607", "0.7487954", "0.74648917", "0.7463597", "0.746155", "0.7457391", "0.745...
0.0
-1
Compute shipping for one variant
def compute_for_one_variant(variant) value = variant.price * self.preferred_flat_percent / 100.0 (value * 100).round.to_f / 100 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shipping\n total_quantity = items.inject(0) {|q, item| q + item.quantity}\n if total_quantity == 1\n return items.first.product.base_shipping\n else\n return items.inject(0) {|total, item|\n total + (item.product.add_on_shipping * item.quantity)\n }\n end\n end", "def shipp...
[ "0.75462157", "0.72585976", "0.71461636", "0.7119823", "0.70697755", "0.6988027", "0.6829477", "0.67798245", "0.67114836", "0.66881555", "0.6650676", "0.66354954", "0.66120887", "0.6591673", "0.658657", "0.6570773", "0.6559552", "0.64800656", "0.64580166", "0.64472365", "0.64...
0.0
-1
GET /albums GET /albums.xml
def index @albums = @other_user.shared_albums(@login_user.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @albums = @user.albums\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end", "def get_albums(url)\n # should return albums\n # List of Hashes\n \n # must implement \n # - custom site parser\n end", "def...
[ "0.7665928", "0.74048996", "0.7335424", "0.73116463", "0.72841454", "0.72841454", "0.7142097", "0.7098227", "0.7085205", "0.7046763", "0.7004486", "0.6919333", "0.68507844", "0.678011", "0.67730576", "0.6769612", "0.6769612", "0.6769612", "0.67547905", "0.6747963", "0.6739619...
0.0
-1
GET /albums/1 GET /albums/1.xml
def show @album = Album.find(:all,:conditions=>["user_id=?",@login_user.id]) @curr_album = Album.find(params[:id]) #@pictures = Picture.find(:all,:conditions=>["album_id=?",params[:id]]) #@pictures = @curr_album.shared_pictures(@login_user.id) @pictures = @curr_album.shared_pictures(@login_user.id,1) @is_current_user = @other_user respond_to do |format| format.html end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @albums = @user.albums\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end", "def index\n @albums = Album.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => ...
[ "0.7584732", "0.7344882", "0.72845834", "0.72845834", "0.7218744", "0.70814866", "0.70309854", "0.7029295", "0.6976127", "0.6976127", "0.6976127", "0.69676244", "0.6954994", "0.69119257", "0.68749785", "0.680347", "0.6736614", "0.67209744", "0.6713891", "0.67040205", "0.66929...
0.0
-1
Created on: 13/02/2012 Purpose: To create album ++
def create_album @other_user=@login_user @albums = @login_user.albums @album = Album.new(:name=>params[:album][:name], :user_id=>@login_user.id, :share_type => 0) @notice = @album.save ? "Album created successfully.": activerecord_error_list(@album.errors) respond_to do |format| format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_album(set_albumName, params = {})\n params = { :cmd => 'new-album', :set_albumName => set_albumName }.merge(params)\n send_request(params)\n end", "def create_album(person_id, caption, location='', privacy='Everyone')\n @restv9.create_albumv9(person_id, caption, location, privacy)\n ...
[ "0.7249264", "0.7231963", "0.7208498", "0.72079366", "0.71732086", "0.71288055", "0.71166945", "0.71074283", "0.7014076", "0.6985704", "0.69807285", "0.69763887", "0.69670784", "0.6947165", "0.69185936", "0.69153684", "0.69124043", "0.6898694", "0.6898694", "0.6898694", "0.68...
0.0
-1
Created on: 13/02/2012 Purpose: To delete album ++
def delete_album @album = Album.find(params[:id]) @album.destroy respond_to do |format| format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete()\n sql = \"DELETE FROM albums\n WHERE id = $1;\"\n values = [@id]\n SqlRunner.run( sql, values )\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n redirect_to root_url\n end", "def destroy\n @palbum = Palbum.find(params[:id])\n @palbum.destroy\n...
[ "0.80011797", "0.7673968", "0.7548741", "0.7509204", "0.7482032", "0.7481534", "0.7440488", "0.7425243", "0.74166715", "0.74166244", "0.7411274", "0.74055445", "0.7386805", "0.73700356", "0.7357715", "0.73495346", "0.7347964", "0.73268574", "0.7261764", "0.7257527", "0.724349...
0.67813015
81
Created on: 13/02/2012 Purpose: To edit album ++
def edit_album @album = Album.find(params[:album][:id]) @notice = @album.update_attributes(:name=> params[:album][:name]) ? "Album name updated successfully." : activerecord_error_list(@album.errors) #redirect_to :back respond_to do |format| format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit\n @album = Album.find(params[:id])\n render :edit\nend", "def edit\n @album = Album.includes(:images, :creator).find(params[:id])\n render :edit\n end", "def edit\n @album= Album.find(params[:id])\n render :edit\n end", "def set_album\n @album = Admin::Album.find(params[:id]...
[ "0.69696164", "0.6807785", "0.6729275", "0.6672956", "0.6672956", "0.6639897", "0.6638596", "0.65839124", "0.65687525", "0.6561913", "0.6561913", "0.6561913", "0.6561913", "0.6561913", "0.6548863", "0.64677066", "0.64677066", "0.64677066", "0.64677066", "0.64677066", "0.64677...
0.622959
58
Created on: 14/02/2012 Purpose:This method is used to set album as public ++
def share_album_in_group if request.post? @group_ids = params[:group_ids] @album = Album.find(params[:album_id]) if params[:photos][:share_type].to_i == 2 @pre_group_ids = Array.new @login_user.groups_having_album_shared(params[:album_id]).each do |g| @pre_group_ids<< g.id end if !@login_user.groups_having_album_shared(params[:album_id]).blank? @pre_group_ids.each do |g_id| SharedTab.delete_all("shareable_id=#{@album.id} AND shareable_type='#{@album.class.to_s}' AND group_id=#{g_id}") if g_id and !@group_ids.include?(g_id) end if !@pre_group_ids.blank? and !@group_ids.blank? @group_ids.each do |g_id| SharedTab.create(:shareable_id => params[:album_id].to_i, :shareable_type => @album.class.to_s, :group_id => g_id) end if !@group_ids.blank? if(@group_ids.blank?) flash[:notice]="At least one group must be selected to share the album." end else SharedTab.delete_all("shareable_id=#{@album.id} AND shareable_type='#{@album.class.to_s}'") end @album.update_attribute(:share_type, params[:photos][:share_type].to_i) flash[:notice]="#{@album.name} album shared successfully." if params[:photos][:share_type].to_i == 2 flash[:notice]="#{@album.name} album is set to public." if params[:photos][:share_type].to_i == 0 flash[:notice]="#{@album.name} album is set to private." if params[:photos][:share_type].to_i == 1 redirect_to :back else @album = Album.find(params[:id]) render :partial=>"share_album_with_group", :locals=>{:album=>@album}, :layout=>false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def album=(v)\n if @album != v\n @needs_commit = true\n @album = v\n end\n end", "def album(value)\n @ole.Album = value\n nil\n end", "def set_album\n @album = Album.find(params[:album_id])\n end", "def set_album\n @album = Album.find(params[:album_id])\n end", ...
[ "0.7889983", "0.7881587", "0.77306664", "0.77306664", "0.76933736", "0.76933736", "0.76933736", "0.76933736", "0.76933736", "0.76933736", "0.76933736", "0.76933736", "0.76933736", "0.76933736", "0.76933736", "0.76933736", "0.76933736", "0.76933736", "0.76933736", "0.76933736", ...
0.0
-1
Created on: 14/02/2012 Purpose:This method is used to set photo as public ++
def share_photo_in_group if request.post? @group_ids = params[:group_ids] @picture = Picture.find(params[:pic_id]) if params[:photos][:share_type].to_i == 2 @pre_group_ids = Array.new @login_user.groups_having_photo_shared(params[:id]).each do |g| @pre_group_ids<< g.id end if !@login_user.groups_having_photo_shared(params[:id]).blank? @pre_group_ids.each do |g_id| SharedTab.delete_all("shareable_id=#{@picture.id} AND shareable_type='#{@picture.class.to_s}' AND group_id=#{g_id}") if g_id and !@group_ids.include?(g_id) end if !@pre_group_ids.blank? and !@group_ids.blank? @group_ids.each do |g_id| SharedTab.create(:shareable_id => params[:pic_id].to_i, :shareable_type => @picture.class.to_s, :group_id => g_id) end if !@group_ids.blank? if(@group_ids.blank?) flash[:notice]="At least one group must be selected to share the album." end else SharedTab.delete_all("shareable_id=#{@picture.id} AND shareable_type='#{@picture.class.to_s}'") end @picture.update_attribute(:share_type, params[:photos][:share_type].to_i) flash[:notice]="Picture shared successfully." if params[:photos][:share_type].to_i == 2 flash[:notice]="Picture is set to public." if params[:photos][:share_type].to_i == 0 flash[:notice]="Picture is set to private." if params[:photos][:share_type].to_i == 1 redirect_to :back else @picture = Picture.find(params[:id]) render :partial=>"share_photo_with_group", :locals=>{:picture=>@picture}, :layout=>false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_img\n\n end", "def set_photo\n# @photo = Photo.find(params[:id])\n end", "def set_photo\r\n @photo = Photo.find(params[:id])\r\n end", "def set_photo\n @image = Photo.find(params[:id])\n end", "def set_photo\n @photo = photo.find(params[:id])\n end", "def set_ph...
[ "0.774485", "0.77211773", "0.75518316", "0.753353", "0.7527781", "0.75103146", "0.74976665", "0.74637014", "0.74637014", "0.74637014", "0.74637014", "0.74637014", "0.74637014", "0.74637014", "0.74637014", "0.74637014", "0.74637014", "0.74637014", "0.74637014", "0.74637014", "...
0.0
-1
Created on: 15/02/2012 Purpose: add photo from system ++
def add_photo_from_system @photo = Picture.new(params[:photos]) if @photo.save @group_ids = params[:group_ids] @group_ids.each do |grp| SharedTab.create(:shareable_id=>@photo.id,:group_id=>grp.to_i,:shareable_type=>"Picture") end if !@group_ids.blank? flash[:notice] = "Photo added successfully." end flash[:notice] = @photo.errors.first[1] if !@photo.errors.blank? redirect_to :back end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_image(pic, img_loc_text, stock_images=nil)\n pic.photo = File.open(Rails.root.join('db', 'images', get_stock_image(img_loc_text, stock_images)))\n pic\n end", "def add_picture(picture)\n end", "def create_image(title, description, parent_id, mime_type, file_name)\n\t insert_file(title, descr...
[ "0.7251711", "0.7182736", "0.71192664", "0.7088164", "0.70388", "0.69210005", "0.6906399", "0.6894329", "0.6863161", "0.68532836", "0.681027", "0.67262733", "0.67229193", "0.6696616", "0.6694619", "0.66892743", "0.66556627", "0.66492325", "0.664808", "0.66396475", "0.6619155"...
0.61582434
99
Created on: 14/04/2012 Purpose: ++ This method is used to create the multiple photos on a album while multiple image upload.
def create_multiple_photos session[:current_images] = (0...8).map{65.+(rand(25)).chr}.join unless session[:current_images] @photo = Picture.new(:photo => params[:picture][:path], :photo_detail => "#{session[:current_images]}", :share_type => "99", :album_id => "") if @photo.save @group_ids = params[:group_ids] @group_ids.each do |grp| SharedTab.create(:shareable_id=>@photo.id,:group_id=>grp.to_i,:shareable_type=>"Picture") end if !@group_ids.blank? flash[:notice] = "Photo added successfully." if @photo.save respond_to do |format| format.html { #(html response is for browsers using iframe sollution) render :json => [@photo.to_jq_upload].to_json, :content_type => 'text/html', :layout => false } format.json { render :json => [@photo.to_jq_upload].to_json } end else render :json => [{:error => "custom_failure"}], :status => 304 end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def batch_upload(images, album_id)\n upload_url = get_upload_url(album_id) \n vk_options = { url: upload_url }\n \n images.slice(0, 5).each_with_index do |image, i|\n vk_options[\"file#{i+1}\"] = get_image_metadata(image)\n end\n \n puts vk_options.inspect\n upload_response = ...
[ "0.75330025", "0.7369873", "0.7034707", "0.7031321", "0.69188076", "0.69042796", "0.68869925", "0.68521684", "0.6827884", "0.6799083", "0.6775102", "0.6727726", "0.6714925", "0.6688347", "0.6677308", "0.66184646", "0.6550814", "0.6524815", "0.648547", "0.6439943", "0.6432946"...
0.75888234
0
Created on: 14/04/2012 Purpose: ++ This method is used to save the multiple photos.
def save_multiple_photos params[:photo_id].each do |i| photo = Picture.find(i.to_i) description = params["photo_detail_#{i}"].blank? ? "comment" : params["photo_detail_#{i}"] photo.update_attributes(:photo_detail => description, :share_type => params[:photos][:share_type], :album_id => params[:photos][:album_id]) end if !params[:photo_id].nil? redirect_to :back end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_images\n photos.each do |image|\n if image.should_destroy?\n image.destroy\n else\n if (!image.user_id) \n image.user_id = self.user_id\n end\n image.save(false)\n end\n end\n end", "def create_multiple_photos\n session[:current_images] = (0....
[ "0.6968243", "0.69428235", "0.6939934", "0.6847256", "0.65995365", "0.6575136", "0.65558106", "0.647961", "0.64295393", "0.64204884", "0.6393866", "0.6344382", "0.63103586", "0.6309926", "0.62824845", "0.6279026", "0.62678885", "0.6259053", "0.6208164", "0.62074274", "0.61743...
0.75856864
0
Created on: 11/02/2012 Purpose: add photo options ++
def find_photo begin post_agent = Mechanize.new @html = post_agent.get(params[:site_url]).body url_host =URI.parse(params[:site_url]).host rescue => e end render :text=>@html end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def picture_options\n {purpose: nil, variant: nil}\n end", "def photo_format; end", "def extra_images(options)\n {}\n end", "def image_options\n if height.blank?\n # save_image_dimensions\n end\n image_options = {\n :height => Nivo::Config.file['slideshow_dimensions']...
[ "0.6939314", "0.6474289", "0.6435981", "0.64153504", "0.6379718", "0.620878", "0.620878", "0.61835223", "0.6150094", "0.6085049", "0.60563236", "0.6006407", "0.60015136", "0.5974523", "0.5962874", "0.5962874", "0.5886227", "0.58723116", "0.5862858", "0.58503366", "0.5847124",...
0.0
-1
Created on: 11/02/2012 Purpose: add photos_from_site ++
def add_photos_from_site if(params[:photo_url]) @url = params[:photo_url] @album = Album.find(:all,:conditions=>["user_id=?",@login_user.id]) render :action=>"add_photos_from_site", :layout=>false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_photo(img_url)\n self.photos << img_url\n end", "def build_urls(photos)\n if photos.is_a?(Array)\n new_photos = photos.map {|photo| \"http://farm#{photo['farm']}.staticflickr.com/#{photo['server']}/#{photo['id']}_#{photo['secret']}.jpg\"}\n else\n \"http://farm#{photos['farm']}.static...
[ "0.69109905", "0.6542414", "0.631213", "0.627651", "0.6273982", "0.6213206", "0.6147841", "0.6128562", "0.6111362", "0.61094755", "0.6106155", "0.610423", "0.6100119", "0.6084022", "0.60712016", "0.60678077", "0.60078466", "0.59787726", "0.59481025", "0.59378135", "0.5921202"...
0.7266672
0
Created on: 11/02/2012 Purpose: load all groups of login user ++
def load_my_groups @groups = Group.find(:all,:conditions=>["user_id=?",@login_user.id]) flash[:notice] = "Groups are not Created." if @groups.nil? render :partial=> "load_my_groups", :locals=>{:groups=>@groups} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def retrieve_groups_from_ldap\n LdapUser.retrieve_groups self.login\n end", "def load_users\n user_set = Set[]\n @users_config.each_key do |provider|\n @users_config[provider].each do |a|\n add_user(a, user_set, provider)\n end\n end\n add_users_to_group(user_set)\n end", "def...
[ "0.731187", "0.70156467", "0.69298464", "0.6801826", "0.6741959", "0.6687128", "0.66801333", "0.66691875", "0.6663677", "0.66424716", "0.6615681", "0.6599297", "0.6581238", "0.6548929", "0.65326893", "0.6461102", "0.64542174", "0.6432542", "0.64175266", "0.64088273", "0.64003...
0.6787656
4
Created on: 15/02/2012 Purpose: load full details of photo ++
def load_photo_full_detail @picture = Picture.find(params[:id]) render :partial=>"photo_full_detail", :locals=>{:pic=>@picture} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_photo_full_detail\n @picture = Image.find(params[:id])\n render :partial=>\"discussion_groups/image_partials/photo_full_detail\", :locals=>{:pic=>@picture}\n end", "def load_photo photo_id, info_level = \"Full\"\n\t\t\t@response = api_request 'LoadPhoto', [photo_id, info_level]\n\t\t\traise Zenfo...
[ "0.7152817", "0.7021988", "0.70196915", "0.6796966", "0.6795603", "0.6784973", "0.6784973", "0.6759337", "0.6692628", "0.66462076", "0.6598962", "0.6587542", "0.65677875", "0.65559936", "0.6553466", "0.655241", "0.6520417", "0.6511232", "0.6501469", "0.6486398", "0.64832973",...
0.71844834
0
Created on: 15/02/2012 Purpose: to like the photo ++
def like_picture @like = Like.new(:user_id=>@login_user.id,:likable_id=>params[:id],:likable_type=>"Picture") @pic = Picture.find(params[:id]) if @like.save respond_to do |format| format.js end else render :text=>"Fail" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def picture_list\n end", "def photograph?\n true\n end", "def images; end", "def photo_format; end", "def current_image\n image || (owner && owner.respond_to?(:image) && owner.image) || (laws_i_like? && Image.laws_i_like)\n end", "def image; end", "def edit_real_picture\n end", "def i...
[ "0.61513144", "0.61380315", "0.60463864", "0.5968092", "0.5959149", "0.59554744", "0.5860416", "0.58553165", "0.5849851", "0.5816648", "0.58116454", "0.57559824", "0.56897956", "0.56560916", "0.5649023", "0.5648087", "0.563771", "0.56243294", "0.56228954", "0.56185114", "0.56...
0.52858144
65
Created on: 15/02/2012 Purpose: to like the photo ++
def unlike_picture @pic = Picture.find(params[:id]) @like = Like.find(:last,:conditions=>["user_id=? and likable_id=? and likable_type=?",@login_user.id,params[:id],"Picture"]) if @like.destroy respond_to do |format| format.js end else render :text=>"Fail" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def picture_list\n end", "def photograph?\n true\n end", "def images; end", "def photo_format; end", "def current_image\n image || (owner && owner.respond_to?(:image) && owner.image) || (laws_i_like? && Image.laws_i_like)\n end", "def image; end", "def edit_real_picture\n end", "def i...
[ "0.61505944", "0.61374915", "0.60441", "0.5965159", "0.59599215", "0.59535444", "0.5858983", "0.5854265", "0.5849411", "0.58178467", "0.58107287", "0.5755724", "0.5688885", "0.5654315", "0.56490654", "0.564566", "0.5636415", "0.56241316", "0.5623829", "0.5619886", "0.5616525"...
0.0
-1
Created on: 15/02/2012 Purpose: delete picture ++
def delete_picture @pic = Picture.find(params[:id]) if @pic.album.user_id==@login_user.id if @pic.destroy render :text=>"Success" else render :text=>"Fail" end else render :text=>"Not your photo" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_picture(picture)\n end", "def removeImage\n @groof = Greenroof.find(params[:id])\n if not (@groof.images.first.nil?)\n\n\n directory = \"/public/greenroofs/photos/\" + params[:id]\n photoFilename = @groof.images.first.photo\n thumbFilename = @groof.images.first.thumb\n pho...
[ "0.7998623", "0.756027", "0.75278866", "0.737767", "0.7369133", "0.73206955", "0.7303501", "0.7179795", "0.7179795", "0.71335423", "0.71296394", "0.7094314", "0.7088146", "0.7075793", "0.7003937", "0.6987445", "0.6956144", "0.6916086", "0.69109064", "0.6892811", "0.68633425",...
0.68439
22
Created on: 15/02/2012 Purpose: post comment ++
def post_photo_comment @pic = Picture.find(params[:picture_id].to_i) @comment = PhotoComment.new(:comment=>params[:comment],:user_id=>@login_user.id,:discussable_id=>params[:picture_id],:discussable_type=>"Picture") if @comment.save respond_to do |format| format.js end else render :text => "Fail" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def com...
[ "0.7557791", "0.7557791", "0.7557791", "0.7557791", "0.7557791", "0.7557791", "0.7557791", "0.7557791", "0.7557791", "0.7557791", "0.7557791", "0.7557791", "0.7557791", "0.7557791", "0.7557791", "0.7557791", "0.7557791", "0.7341735", "0.7341735", "0.7244707", "0.7244707", "...
0.0
-1
Created on: 16/02/2012 Purpose: delete comment ++
def delete_picture_comment @comm = PhotoComment.find(params[:id]) @pic = Picture.find(@comm.discussable_id) if @pic.album.user_id==@login_user.id or @comm.user_id==@login_user.id if @comm.destroy respond_to do |format| format.js end else render :text=>"Fail" end else render :text=>"Not your photo" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_comment\n Jhead.call(\"-dc\", @match, @pattern)\n end", "def del_comment\n @comment = ''\n end", "def delete_comments\n end", "def clear_comment\n @comment = ''\n end", "def remove_comment comment\n return if @comments.empty?\n\n case @comments\n when Array then\n ...
[ "0.7856031", "0.76752573", "0.74739337", "0.67724526", "0.67414314", "0.67122525", "0.67001146", "0.67001146", "0.67001146", "0.67001146", "0.6698562", "0.6698562", "0.6698562", "0.6698562", "0.6698562", "0.6698562", "0.6698562", "0.6698562", "0.6698562", "0.6698562", "0.6698...
0.0
-1
Created on: 16/02/2012 Purpose: delete comment ++
def import_picture if request.post? @album = Album.find(:all,:conditions=>["user_id=?",@login_user.id]) @current_album_id = params[:current_album_id] if(params[:photo_url]) @photo = Picture.new url = params[:photo_url] @photo.photo_detail = params[:photo_detail] url_host =URI.parse(url).host @photo.site_name = url_host @photo.share_type= params[:share_type] @photo.album_id = params[:album_id] @photo.upload_image(url) @group_ids = params[:group_ids] @group_ids.each do |grp| SharedTab.create(:shareable_id=>@photo.id,:group_id=>grp.to_i,:shareable_type=>"Picture") end if !@group_ids.blank? end respond_to do |format| format.js end else @pic= Picture.find(params[:id]) @photo_url = "http://"+request.host_with_port + @pic.photo(:original) @album = Album.find(:all,:conditions=>["user_id=?",@login_user.id]) render :partial=>"import_picture" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_comment\n Jhead.call(\"-dc\", @match, @pattern)\n end", "def del_comment\n @comment = ''\n end", "def delete_comments\n end", "def clear_comment\n @comment = ''\n end", "def remove_comment comment\n return if @comments.empty?\n\n case @comments\n when Array then\n ...
[ "0.785418", "0.76740754", "0.74727315", "0.6771015", "0.6739702", "0.6710224", "0.6699906", "0.6699906", "0.6699906", "0.6699906", "0.66992617", "0.66992617", "0.66992617", "0.66992617", "0.66992617", "0.66992617", "0.66992617", "0.66992617", "0.66992617", "0.66992617", "0.66...
0.0
-1
Created on: 16/02/2012 Purpose: photo discussion page ++
def photo_discussions @album = Album.find(:all,:conditions=>["user_id=?",@login_user.id]) from = Time.now-30.days to = Time.now page = 1 order_by_rating = false @pictures = @login_user.all_visible_pictures(from, to, page,order_by_rating,0,0) #@pictures = Picture.paginate(:page => 1, :per_page => 5) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def images; end", "def picture_list\n end", "def event_photo(photos)\n speakers = find_speaker(photos)\n if speakers.empty?\n photo = photos.shuffle[0]\n else\n photo = speakers[0]\n end\n src = photo['photo_link']\n name = photo['member']['name']\n \"<img src=\\\"#{src}\\\" class=\\\"event-pho...
[ "0.6033655", "0.59849495", "0.5937628", "0.5882285", "0.58336854", "0.58200324", "0.5728855", "0.57207906", "0.5691684", "0.5672505", "0.56465864", "0.5642271", "0.56227267", "0.5619875", "0.5618797", "0.5603422", "0.5589161", "0.55706537", "0.5550861", "0.5548371", "0.554728...
0.6236846
0
Created on: 16/02/2012 Purpose: load discussion photos on scrolling/sorting (ajax) ++
def load_photos_discussions @page = params[:page] ? params[:page].to_i : 1 from = case params[:time_span] when "30min" then Time.now - 30.minutes when "day" then Time.now - 1.day when "week" then Time.now - 1.week when "year" then Time.now - 1.year else Time.now - 30.day end to = Time.now #order_by_rating = params[:sort_by]== "rates" ? true : false order = params[:sort_by]=="recent" ? nil : (params[:sort_by]=="rates") group_id = params[:group_id] == "" ? 0 : params[:group_id].to_i crowd_id = params[:crowd_id] == "" ? 0 : params[:crowd_id].to_i @pictures = @login_user.all_visible_pictures(from, to, @page,order,group_id, crowd_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_pictures\n page = params[:page].to_i\n per_page = 20\n off = (page-1)*per_page\n @discussion_group = DiscussionGroup.find(params[:id])\n @pictures = @discussion_group.images.offset(off).limit(10).order(\"photo_updated_at DESC \")\n end", "def photo_discussions\n @album = Album.find(:a...
[ "0.7509254", "0.6640483", "0.6440726", "0.6376813", "0.6244387", "0.6133032", "0.59551847", "0.5938794", "0.58711684", "0.5835043", "0.5832468", "0.580754", "0.58036673", "0.5744512", "0.5727649", "0.5701103", "0.569532", "0.56896293", "0.5683902", "0.567933", "0.5652026", ...
0.75586444
0
Created on: 16/02/2012 Purpose: load album photos on scrolling page(ajax) ++
def load_album_photos # @pictures = Picture.paginate(:page => params[:page], :per_page => 5) @curr_album = Album.find(params[:id]) @pictures = @curr_album.shared_pictures(@login_user.id,params[:page].to_i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_pictures\n page = params[:page].to_i\n per_page = 20\n off = (page-1)*per_page\n @discussion_group = DiscussionGroup.find(params[:id])\n @pictures = @discussion_group.images.offset(off).limit(10).order(\"photo_updated_at DESC \")\n end", "def photos\n @album = Album.find(params[:id])\...
[ "0.66610646", "0.6636049", "0.65122217", "0.6467579", "0.6439582", "0.63984096", "0.6327973", "0.63175654", "0.6277753", "0.6275416", "0.62537736", "0.62346673", "0.6221162", "0.61735946", "0.6152441", "0.6027438", "0.5992535", "0.5981696", "0.59763217", "0.5949791", "0.59486...
0.7385305
0
Create a new X.500 attribute. The name format will always be set to URI.
def initialize(name = nil, value = nil) # if they pass an OID, infer the friendly name friendly_name = OIDS[name] unless friendly_name # if they pass a friendly name, infer the OID proper_name = FRIENDLY_NAMES[name] if proper_name friendly_name = name name = proper_name end end super(name, value, friendly_name, NameFormats::URI) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method_missing (name, *args, &block)\n add_attribute(name, *args, &block)\n end", "def method_missing (name, *args, &block)\n add_attribute(name, *args, &block)\n end", "def method_missing (name, *args, &block)\n add_attribute(name, *args, &block)\n end", "def name_attribute(suffix = nil)\n ...
[ "0.50856745", "0.50856745", "0.50856745", "0.5079459", "0.5014633", "0.5012669", "0.5012669", "0.5012669", "0.49414006", "0.49281135", "0.492477", "0.49105784", "0.48728722", "0.48530412", "0.48324516", "0.48217484", "0.48032376", "0.48027432", "0.47384357", "0.47316223", "0....
0.0
-1
basically executes a sql script in certain database
def exec_sql_script_in_db(db_name, db_user, db_pass, sql_script) # connecting to the given database conn = PG.connect( :dbname => db_name, :user => db_user, :password => db_pass) # actually executing the script conn.exec(sql_script) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_sql_script(path, adapter = dss, ctx = {})\n sql = ErbHelper.new.process(path, ctx)\n puts sql\n adapter.run sql\n end", "def execute sql\n db[sql]\n end", "def source_sql\n system \"psql -d #{@base_name} -f #{@sql_path}\"\n end", "def execute(sql)\n @database_handle.execu...
[ "0.7344114", "0.7307601", "0.7232265", "0.7103532", "0.7046475", "0.7033309", "0.6977539", "0.69645643", "0.6935681", "0.6887758", "0.6876568", "0.68097043", "0.6781284", "0.67753434", "0.6747236", "0.67303616", "0.6717069", "0.66515845", "0.66199005", "0.6598621", "0.6565573...
0.8438376
0
Method for iteration of users with notifications. Takes a block And passes back the entire batch of users one at at time
def batch_iterate_users_with_notifications(params = {}) per_batch = params.fetch(:batch_size, 1000) 0.step(users.count, per_batch) do |offset| users_batch = users.where("this.notifications && this.notifications.length > 0").skip(offset).limit(per_batch) yield users_batch if block_given? end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def block_users\n request('/block/users', {body: {}})\n end", "def each &block\n @json_data['users'].each{ |user| yield( User.new(user) )}\n end", "def process_notifications(users, plan)\r\n users.each{| user |\r\n #KS- if they have email notification on, check their notification settin...
[ "0.66642255", "0.6600644", "0.652566", "0.6466436", "0.64180446", "0.63283765", "0.6100036", "0.60723126", "0.6054401", "0.6036563", "0.602548", "0.59873956", "0.59840924", "0.5969677", "0.59656304", "0.59202856", "0.59095526", "0.59094906", "0.58917123", "0.58700246", "0.586...
0.75846136
0
Returns a hash of APN device id => timestamp_at_which_it_failed NOTE: this uses an external resource Always memoize or save in a variable because once .feedback is called the data is cleared on Apple's side
def get_apn_feedback apple_feedback = get_pushmeup_apn_feedback.sort_by{|f| f[:timestamp]} apple_feedback.reduce({}){|feedback_hash, array_value| feedback_hash.merge({array_value[:token] => array_value[:timestamp]}) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def failures\n Hash[status.map { |device_key, v| [device_key, v[\"message\"]] } ]\n end", "def feedback\n fhost = HOST.gsub('gateway','feedback')\n fsock = TCPSocket.new(fhost, 2196)\n fssl = OpenSSL::SSL::SSLSocket.new(fsock, context)\n fssl.connect\n\n ...
[ "0.58327276", "0.57213646", "0.55085063", "0.5479566", "0.54664737", "0.53097963", "0.52991885", "0.51710546", "0.5126038", "0.5035649", "0.50073904", "0.49943924", "0.49919394", "0.49857205", "0.4984983", "0.4982894", "0.49672934", "0.49353832", "0.4925046", "0.49142656", "0...
0.6361583
0
Wrap the method on the PushMeUp gem to be safe
def get_pushmeup_apn_feedback apn_connection.feedback end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push(notif)\n\n end", "def push\n end", "def camaleon_mailchimp_on_upgrade(plugin)\n end", "def push(arg0)\n end", "def push(cmd); end", "def push\n hg 'push'\n end", "def push msg\n end", "def create_push\n PushNotification.push_to_user!(uid: @spot.priest.id, payload: push_payl...
[ "0.624701", "0.58914167", "0.58896863", "0.58876526", "0.57624906", "0.57032776", "0.56823385", "0.56192386", "0.5607395", "0.56041956", "0.5603085", "0.5590671", "0.55855095", "0.5578949", "0.55645764", "0.55502903", "0.5539966", "0.5525137", "0.5486796", "0.54817605", "0.54...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_group @group = Enrollment.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def group_params params.require(:group).permit(:id, :course_id, :name, :description, :location_description, :latitude, :longitude, :address, :image, :file) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Save the secret, so that the tests can be rerun
def two_step_verification_secret_file_name "tmp/user_#{number}_two_step_verification_secret" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refresh_secret!\n set_secret\n save!\n end", "def secret\n decrypt_secret\n end", "def secret\n decrypt_secret\n end", "def set(secret)\n if File.exist?(path)\n backup_path = \"#{path}.bak\"\n Simple::CLI.logger.info \"Backing up secret in #{backup_path}\"\n ...
[ "0.77327764", "0.7167345", "0.7167345", "0.7122601", "0.7074259", "0.70211375", "0.69984686", "0.69984686", "0.69984686", "0.69984686", "0.6953225", "0.6925156", "0.69227356", "0.6918072", "0.69077116", "0.6871736", "0.6871736", "0.6871736", "0.6871736", "0.68160784", "0.6778...
0.0
-1