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
DELETE /plans/1 DELETE /plans/1.json
def destroy @plan = Plan.find(params[:id]) @plan.destroy respond_to do |format| format.html { redirect_to plans_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @plan.destroy\n respond_to do |format|\n format.html { redirect_to plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @plan.destroy\n respond_to do |format|\n format.html { redirect_to plans_url }\n format.json { head :no_content }\n e...
[ "0.7875514", "0.7875514", "0.7717366", "0.76824516", "0.76233137", "0.76049894", "0.75752383", "0.75752383", "0.75752383", "0.75752383", "0.75752383", "0.75752383", "0.75752383", "0.75752383", "0.7539571", "0.75216585", "0.7470493", "0.74592143", "0.7353298", "0.73428476", "0...
0.7855785
4
POST /links POST /links.json
def create @link = Link.new(params[:link]) @link.user_id = current_user_id respond_to do |format| if @link.save @post = Post.find(@link.post_id); format.html { redirect_to @link, notice: 'Link was successfully created.' } format.json { render json: @link, status: :created, location: @link } format.js {} else format.html { render action: "new" } format.json { render json: @link.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n if @link.save\n render json: @link, status: :created, location: @link\n else\n render json: @link.errors, status: :unprocessable_entity\n end\n end", "def test_should_create_link_via_API_JSON\r\n get \"/logout\"\r\n post \"/links.json\", :api_key => 'testapikey',\r\n ...
[ "0.7279239", "0.7042173", "0.6892667", "0.6849184", "0.67824477", "0.67146206", "0.6708206", "0.66861737", "0.66628766", "0.66427463", "0.66249496", "0.65540344", "0.6506658", "0.64941686", "0.6478123", "0.6459337", "0.64366543", "0.64365256", "0.6423571", "0.64210635", "0.64...
0.638552
23
DELETE /links/1 DELETE /links/1.json
def destroy @link = Link.find(params[:id]) @link.destroy respond_to do |format| format.xml { head :ok } format.js { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @link.destroy\n\n respond_to do |format|\n format.html { redirect_to links_url }\n format.json { head :ok }\n end\n end", "def destroy\n @link = Link.find(params[:id])\n @link.destroy\n\n respond_to do |format|\n format.html { redirect_to links_url }\n format....
[ "0.75310004", "0.74690264", "0.74529105", "0.74529105", "0.74529105", "0.73705393", "0.73705393", "0.73637277", "0.7292658", "0.7263792", "0.7260787", "0.72489226", "0.72376317", "0.72376317", "0.72376317", "0.72376317", "0.72376317", "0.72376317", "0.72376317", "0.72376317", ...
0.68148464
50
GET /events GET /events.json
def index if current_user @joined_event = [] @joined = EventUser.where(user_id: current_user.id) @joined.each do |x| @joined_event << Event.find(x.event_id) end @events = [] @joined_event_id = [] @joined.each do |y| @joined_event_id << y.event_id end Event.all.each do |x| if @joined_event_id.include? x.id # do nothing else @events << x end end else @events = Event.all end respond_to do |format| format.json format.html end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end", "def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end", "def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}...
[ "0.8337294", "0.82393", "0.7943906", "0.7928331", "0.77682066", "0.77408546", "0.76701826", "0.7665501", "0.76581633", "0.7642472", "0.76212007", "0.7615658", "0.7615658", "0.7612881", "0.75687", "0.7522498", "0.7488667", "0.74813455", "0.74698067", "0.7441679", "0.74408287",...
0.0
-1
GET /events/1 GET /events/1.json
def show @joined = EventUser.where(event_id:params[:id]).count @event = Event.find(params[:id]) @event_photos = @event.event_photos.all @styles = [] @event_tags = EventTag.where(event_id: @event.id) @event_tags.each do |x| temp = StyleTag.where(tag_id: x.tag_id) temp.each do |y| @styles << Style.find(y.style_id) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @event = Event.find(params[:id])\n render json: @event\n end", "def get(event_id)\n @client.request \"events/#{event_id}\"\n end", "def show\n event_id = params[:id]\n if event_id.present?\n @event = Com::Nbos::Events::Event.active_events.where(id: event_id, tenant_id: @use...
[ "0.75029767", "0.74019474", "0.7361382", "0.7348975", "0.73475033", "0.7338018", "0.7317425", "0.72875094", "0.72813755", "0.7246173", "0.72317284", "0.7219172", "0.7219172", "0.7218839", "0.7218839", "0.721464", "0.7204848", "0.71989256", "0.7196662", "0.71925515", "0.719221...
0.0
-1
POST /events POST /events.json
def create @event = Event.new(event_params) tag_array = event_params2['tags'].split(',') tag_array.each do |x| @tag = Tag.create(desc: x) @event.tags << @tag end EventTag.create(event_id: @event.id, tag_id: @tag.id) respond_to do |format| if @event.save params[:event]['images'].each do |a| @event_photo = @event.event_photos.create!(:image => a, :event_id => @event.id) end format.html { redirect_to @event, notice: 'Event was successfully created.' } format.json { render :show, status: :created, location: @event } else format.html { render :new } format.json { render json: @event.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_event event, data={}\n data[:event] = event\n post '/event', data\n end", "def create\n event = Event.new(event_params)\n event.save!\n render json: event\n end", "def create\n Rails.logger.debug(\"Received event #{params[:event]}\")\n head :ok\n end", "def crea...
[ "0.7714071", "0.7611226", "0.76028967", "0.7541319", "0.7444731", "0.73206913", "0.73138195", "0.728203", "0.7251226", "0.7235907", "0.7235907", "0.7215051", "0.71682763", "0.7150409", "0.7126664", "0.7118896", "0.7117831", "0.71162695", "0.70964044", "0.70907074", "0.7083036...
0.0
-1
PATCH/PUT /events/1 PATCH/PUT /events/1.json
def update tag_array = event_params2['tags'].split(',') tag_array.each do |x| if Tag.find_by(desc: x) @tag = Tag.find_by(desc: x) else @tag = Tag.create(desc: x) end @event.tags << @tag # EventTag.create(event_id: @event.id, tag_id: @tag.id) end respond_to do |format| store_photos if @event.update(event_params) format.html { redirect_to @event, notice: 'Event was successfully updated.' } format.json { render :show, status: :ok, location: @event } else format.html { render :edit } format.json { render json: @event.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch_event\n user_id = params[\"user_id\"]\n group_id = params[\"group_id\"]\n event_id = params[\"event_id\"]\n\n #TODO Handle 404 if event not found\n event = Event.find(event_id)\n\n json_body = JSON.parse(request.body.read)\n\n @@event_service.patch_event(j...
[ "0.75299805", "0.7372486", "0.71766764", "0.7172103", "0.7170955", "0.71424884", "0.70959055", "0.7082709", "0.7082709", "0.7057662", "0.70209146", "0.6989379", "0.69825095", "0.69775003", "0.69601995", "0.6954494", "0.6954494", "0.6951992", "0.692109", "0.692109", "0.692109"...
0.0
-1
DELETE /events/1 DELETE /events/1.json
def destroy @event.destroy respond_to do |format| format.html { redirect_to events_url, notice: 'Event was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @event = Event.using(:shard_one).find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_...
[ "0.76929694", "0.7688217", "0.7688217", "0.7688217", "0.7681325", "0.7585923", "0.75685203", "0.7560765", "0.7541314", "0.75410026", "0.75410026", "0.75410026", "0.75410026", "0.75410026", "0.75410026", "0.75410026", "0.75410026", "0.75410026", "0.75410026", "0.75410026", "0....
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_event @event = Event.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 event_params params.require(:event).permit(:title, :status, :description, :start_date, :end_date, :location, :start_time, :end_time, :age_limit, :price, :host_id, event_photos_attributes: [:id, :event_id, :image]) 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
If UPC changed, then fg_product_code must be recalculated and carton_template and carton_label_setup must be deleted and carton_setup's field 'labels_and_templates_created' must be set to nil
def production_schedule_code puts "psc attrib called" if @production_schedule_code == nil @production_schedule_code = self.carton_setup.production_schedule_code end return @production_schedule_code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def before_update\n \n #determine if size or class has changed, if so re-sequence old size-class group and set this record's\n #sequence as next val of the new size-class group to which this record now belongs to\n old_record_state = RebinSetup.find(self.id)\n if old_record_state.product_class_code ...
[ "0.66768676", "0.6263571", "0.6058759", "0.5994266", "0.57474315", "0.56360734", "0.56330943", "0.5451982", "0.54041976", "0.5355554", "0.53230166", "0.5319514", "0.5287526", "0.5280847", "0.5278837", "0.52290606", "0.5209021", "0.5203679", "0.5197748", "0.51958495", "0.51914...
0.0
-1
=========================== foreign key validations: ===========================
def set_pack_material_product pack_material_product = Product.find_by_product_code(self.pack_material_product_code) if pack_material_product != nil self.product = pack_material_product return true else errors.add_to_base("'pack_material_product_code' is invalid: not found in database") return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_all_foreign_keys_valid!\n end", "def check_foreign_key(field)\n val = self.send(field)\n if val.is_a? ForeignKey\n add_foreign_key_message_to_errors(val)\n end\n end", "def check_add_foreign_key(*args); end", "def foreign_key_present?\n false\n end", "def forei...
[ "0.7600098", "0.7280537", "0.72237355", "0.72103435", "0.72103435", "0.71699786", "0.70691454", "0.70154715", "0.6979766", "0.69792753", "0.6944212", "0.6933209", "0.6933209", "0.6887509", "0.6855989", "0.68030375", "0.6676975", "0.6676975", "0.66574645", "0.65902704", "0.657...
0.0
-1
Create a perconnection unique name.
def name [host, port, user, password, ssl].collect { |p| p.to_s }.join("/") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unique_name(name)\n \"#{name}_#{Time.now.to_i}\"\n end", "def unique_name(name)\n \"#{name}_#{Time.now.to_i}\"\n end", "def generate_unique_name\n SecureRandom.uuid\n end", "def unique_name(name)\n \"pedant_#{name}_#{pedant_suffix}\"\n end", "def unique_object_name_for(n...
[ "0.7433363", "0.7433363", "0.73311013", "0.7140584", "0.7114694", "0.6969206", "0.68975794", "0.68925333", "0.68126786", "0.6798704", "0.6728601", "0.6701192", "0.6684794", "0.6564183", "0.65391016", "0.6537211", "0.64997685", "0.64976496", "0.64867437", "0.63669336", "0.6366...
0.0
-1
Should we reset the connection?
def reset? reset end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_connection!\n @connection = nil\n end", "def reset_connection!\n @@socket = nil\n end", "def reset_connection\n #close if \n @socket_server = nil\n connect\n end", "def reset!\n reconnect!\n end", "def reset!\n return unless @connection.sta...
[ "0.82608", "0.82339865", "0.79557395", "0.7950673", "0.76238495", "0.7406251", "0.7377962", "0.7359639", "0.70434517", "0.7021228", "0.6978697", "0.6947996", "0.6940097", "0.6857148", "0.6824954", "0.67965984", "0.67963827", "0.67918843", "0.6707419", "0.6697876", "0.66937923...
0.0
-1
Start our ldap connection.
def start case ssl when :tls @connection = LDAP::SSLConn.new(host, port, true) when true @connection = LDAP::SSLConn.new(host, port) else @connection = LDAP::Conn.new(host, port) end @connection.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3) @connection.set_option(LDAP::LDAP_OPT_REFERRALS, LDAP::LDAP_OPT_ON) @connection.simple_bind(user, password) rescue => detail raise Puppet::Error, "Could not connect to LDAP: #{detail}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connect_to_ldap\r\n begin\r\n @ldap = Net::LDAP.new(:host => @ldap_host,\r\n :port => @ldap_port,\r\n :auth => { :method => :simple,\r\n :username => @ldap_username,\r\n :password => @ldap_password } )\r\n @logger.info \"Connectin...
[ "0.73750484", "0.7087649", "0.7007367", "0.6981125", "0.67752594", "0.6762021", "0.67023844", "0.6612316", "0.6554134", "0.65285385", "0.63858604", "0.62499756", "0.62245274", "0.621798", "0.6183765", "0.6140735", "0.613158", "0.6121836", "0.60908735", "0.60333157", "0.599834...
0.81234145
0
create logger based on a given configration
def create_logger(conf) name = self.class.to_s @logger = Patriot::Util::Logger::Factory.create_logger(name, conf) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configure_logger_for(classname)\n # handle case in which log path does not exists\n begin\n logger = Logger.new(@log_path)\n rescue Errno::ENOENT\n FileUtils.mkdir_p File.dirname @log_path\n retry\n end\n\n logger.progname = classname\n logge...
[ "0.7201467", "0.7174189", "0.7153063", "0.7153063", "0.7104416", "0.7085287", "0.69758666", "0.69046694", "0.6855649", "0.67630947", "0.6727744", "0.6727744", "0.6727744", "0.67004013", "0.66836214", "0.6658883", "0.6637589", "0.66343695", "0.6614507", "0.6614507", "0.6574427...
0.7555851
0
Returns the current state the object is in, as a Ruby symbol.
def current_state self.send(self.class.state_column).to_sym end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def state_sym\n return self.state.to_s.gsub(/_state$/, '').to_sym\n end", "def state\n @@states[@state]\n end", "def infer_current_state(obj)\n begin\n obj.to_sym\n rescue\n nil\n end\n end", "def state\n @current_state\n end", "def state\n object.state_code\n...
[ "0.778936", "0.72638017", "0.7260074", "0.7217795", "0.7191846", "0.7173205", "0.7173205", "0.71211797", "0.7112003", "0.69318074", "0.69161254", "0.69120365", "0.69120365", "0.6888226", "0.6789236", "0.6771563", "0.67655486", "0.6736034", "0.6736034", "0.67151237", "0.670748...
0.7734311
1
Returns what the next state for a given event would be, as a Ruby symbol.
def next_state_for_event(event) ns = next_states_for_event(event) ns.empty? ? nil : ns.first.to end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_state(state, event)\n transition = next_state_instruction(state, event)\n ns = transition ? transition[:next] : nil\n (ns.is_a?Symbol) ? ns : ns && ns[:state]\n end", "def getNextState(label = nil)\n\tsym = ''\n\tname = $nextState.to_s\n\twhile name.length < NameLength\n\t\tname = '0' ...
[ "0.765051", "0.7568404", "0.7270385", "0.72466797", "0.72374386", "0.71847266", "0.6862314", "0.68410224", "0.68410224", "0.67528284", "0.67362434", "0.6606392", "0.65116817", "0.64542085", "0.64346105", "0.6432778", "0.6376666", "0.6345473", "0.63103014", "0.6292266", "0.629...
0.77427125
0
Define an event. This takes a block which describes all valid transitions for this event. Example: class Order :open state :open state :closed event :close_order do transitions :to => :closed, :from => :open end end +transitions+ takes a hash where :to is the state to transition to and :from is a state (or Array of states) from which this event can be fired. This creates an instance method used for firing the event. The method created is the name of the event followed by an exclamation point (!). Example: order.close_order!.
def event(event, opts={}, &block) tt = read_inheritable_attribute(:transition_table) et = read_inheritable_attribute(:event_table) e = et[event.to_sym] = SupportingClasses::Event.new(event, opts, tt, &block) define_method("#{event.to_s}!") { e.fire(self) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def event(name, transitions={}, &block)\n event = SupportingClasses::Event.new(name, self, transitions, &block)\n @events[name] = event\n define_method(\"#{name}!\") { event.fire(self) }\n end", "def event( name, options={}, &block )\n options.symbolize_keys!\n valid_i...
[ "0.7317736", "0.6678503", "0.66279995", "0.65139604", "0.64212835", "0.64212835", "0.6385954", "0.6333159", "0.61570853", "0.60141623", "0.59990335", "0.5941764", "0.592445", "0.58313775", "0.57225674", "0.5719424", "0.56938046", "0.5691537", "0.5680461", "0.5646694", "0.5634...
0.6194993
8
Wraps ActiveRecord::Base.find to conveniently find all records in a given state. Options: +number+ This is just :first or :all from ActiveRecord +find+ +state+ The state to find +args+ The rest of the args are passed down to ActiveRecord +find+
def find_in_state(number, state, *args) with_state_scope state do find(number, *args) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find(*args)\n select(*args)\n\n=begin\n\n options = args.last.is_a?(Hash) ? args.pop : {}\n case args.first\n when :all then find_every options\n when :first then find_initial options\n else find_from_ids args, options\n end...
[ "0.69839525", "0.64989495", "0.6392795", "0.63673633", "0.63639873", "0.6340224", "0.63326794", "0.6332438", "0.6316403", "0.623563", "0.61677784", "0.6044358", "0.6009866", "0.59865075", "0.59576285", "0.59454346", "0.59383976", "0.59116054", "0.58815", "0.5869502", "0.58695...
0.81210935
0
Wraps ActiveRecord::Base.count to conveniently count all records in a given state. Options: +state+ The state to find +args+ The rest of the args are passed down to ActiveRecord +find+
def count_in_state(state, *args) with_state_scope state do count(*args) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count(options = {})\n calculate('COUNT(*)', options).to_i\n end", "def count **args\n\t\tquery( **( { projection: 'COUNT(*)' }.merge args )).execute(reduce: true){|x| x[:\"COUNT(*)\"]}\n end", "def count(opts={})\n all(opts).size\n end", "def count(*args)\n # Ignore first arg if...
[ "0.7143123", "0.7084454", "0.7006995", "0.6997248", "0.6854008", "0.6771326", "0.6687586", "0.66181296", "0.6571682", "0.65249074", "0.6493478", "0.6474774", "0.6473509", "0.64730525", "0.6429741", "0.6408593", "0.64036316", "0.6393429", "0.6387125", "0.63504285", "0.6336637"...
0.82572156
0
Wraps ActiveRecord::Base.calculate to conveniently calculate all records in a given state. Options: +state+ The state to find +args+ The rest of the args are passed down to ActiveRecord +calculate+
def calculate_in_state(state, *args) with_state_scope state do calculate(*args) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate calculation, *args, &block\n\t\toptions = args.extract_options!.dup\n\t\tscope_options = extract_scope_options_from options\n\t\tsource = source_with_applied_scopes(scope_options)\n\t\tsource = block.call(source, data_source.scopes) if block_given?\n\t\tsource.send *([calculation] + args + [options])...
[ "0.62893724", "0.61536515", "0.59827906", "0.58819133", "0.5778155", "0.56244314", "0.55733603", "0.550482", "0.52351105", "0.5217666", "0.5212539", "0.52098787", "0.51863086", "0.51831865", "0.5165161", "0.5144857", "0.5126815", "0.5121101", "0.51094466", "0.51025283", "0.50...
0.8006063
0
that combines all elements from both Array argumentss, with the elements taken in alternation. You may assume that both input Arrays are nonempty, and that they have the same number of elements. Example: interleave([1, 2, 3], ['a', 'b', 'c']) == [1, 'a', 2, 'b', 3, 'c']
def interleave(arr1, arr2) combined_arr = [] counter = 0 arr1.size.times do combined_arr << arr1[counter] combined_arr << arr2[counter] counter += 1 end combined_arr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def interleave(array1, array2)\n array1.zip(array2).flatten\nend", "def interleave(array1, array2)\n array1.zip(array2).flatten\nend", "def interleave(array1, array2)\n array1.zip(array2).flatten\nend", "def interleave2(array1, array2)\n array1.zip(array2).flatten\nend", "def interleave(array1, array2)...
[ "0.8620759", "0.8620759", "0.8620759", "0.8531865", "0.8522724", "0.8516027", "0.84994674", "0.8497621", "0.84844714", "0.84708506", "0.84708506", "0.84532154", "0.84461194", "0.8440136", "0.8428092", "0.8428092", "0.8428092", "0.8428092", "0.8428092", "0.8428092", "0.8405889...
0.818656
33
Function that create channel with rest_api and check if channel exsists first
def create_channel(channel) puts "running create_channel, channel = #{channel.inspect}" key_check = RestClient.get "#{$base_url}/channels/#{channel["key"]}" #space should be escaped :) if key_check.nil? || key_check['key'].nil? #params = { 'key' => channel["key"], 'name' => channel["name"], 'description' => channel["description"] }, result = RestClient.post "#{$base_url}/channels/create", channel.to_json, :content_type => :json puts result.inspect # Test for checking that request is valid else puts "Error, Channel is already exsists - #{key_check.inspect}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_channel\n if channel.nil?\n begin\n transaction do\n channel = Channel.new\n channel.save!\n self.channel_id = channel.id\n self.save!\n end\n rescue ActiveRecord::RecordInvalid\n false\n end\n else\n false\n end\n e...
[ "0.7200751", "0.71752787", "0.71222967", "0.6728761", "0.66624796", "0.66301906", "0.6560772", "0.6477684", "0.6455959", "0.6449972", "0.64413565", "0.64413565", "0.63831985", "0.6381928", "0.6373809", "0.6362438", "0.6326484", "0.6276095", "0.6210122", "0.62037414", "0.62003...
0.82708055
0
hope this is enough
def current_user return nil unless cookies[:remember_token] @current_user ||= User.find_by( remember_token: Digest::SHA1.hexdigest(cookies[:remember_token]) ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def schubert; end", "def formation; end", "def suivre; end", "def stderrs; end", "def terpene; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def malts; end", "def anchored; end", "def offences_by; end", "def pa...
[ "0.6766162", "0.6633198", "0.6506568", "0.63531375", "0.620139", "0.61950445", "0.6034499", "0.60307664", "0.60307664", "0.60307664", "0.60307664", "0.60064465", "0.59831", "0.5963129", "0.5949148", "0.5949148", "0.5949148", "0.59318495", "0.59154457", "0.5911645", "0.5891998...
0.0
-1
GET /suppliers GET /suppliers
def index respond_to do |format| format.html { @reorder_url = reorder_suppliers_url @suppliers = Supplier.paginate(:page => params[:page]) flash[:notice] = "Suppliers found (#{@suppliers.size})." } format.xml { render :xml => Supplier.all } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @suppliers = Supplier.all\n end", "def index\n @suppliers = Supplier.all\n end", "def index\n @suppliers = Supplier.all\n end", "def list_suppliers\n @company = Company.find(params[:company_id])\n @pagetitle = \"#{@company.name} - Suppliers\"\n \n if(@company.can_view(getUse...
[ "0.7540829", "0.7540829", "0.7540829", "0.74203867", "0.73335725", "0.7236145", "0.71825635", "0.7122791", "0.6916378", "0.68421507", "0.6803352", "0.671319", "0.67001146", "0.6698133", "0.6673493", "0.6651716", "0.66170615", "0.6613713", "0.6573086", "0.6555708", "0.6546961"...
0.661952
16
GET /suppliers/1 GET /suppliers/1.xml
def show @supplier = Supplier.find(params[:id]) @products = @supplier.products.paginate(:page => params[:page]) @reorder_url = reorder_suppliers_url flash[:notice] = "Supplier has (#{@products.size}) products." respond_to do |format| format.html # show.html.erb format.xml { render :xml => @supplier } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @supplier = Supplier.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @supplier }\n end\n end", "def show\n @supplier = Supplier.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n for...
[ "0.71382135", "0.71382135", "0.6661791", "0.66293323", "0.6600005", "0.6547385", "0.6440835", "0.6343119", "0.6325836", "0.6307414", "0.62475604", "0.62263876", "0.62263876", "0.62263876", "0.6176407", "0.6172926", "0.61599475", "0.6146069", "0.6108928", "0.61079293", "0.6096...
0.63670397
7
GET /suppliers/new GET /suppliers/new.xml
def new flash[:notice] = nil @supplier = Supplier.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @supplier } format.js { render :partial => 'supplier', :locals => {:supplier => @supplier}, :layout => false } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @supplier = Supplier.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @supplier }\n end\n end", "def new\n @catalogs_supply = Catalogs::Supply.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { re...
[ "0.76818675", "0.70917785", "0.702146", "0.7002726", "0.6997581", "0.69179076", "0.6893392", "0.6777723", "0.6770007", "0.67295957", "0.67295957", "0.6723935", "0.6701708", "0.6700818", "0.6694123", "0.66906226", "0.6673501", "0.66487217", "0.6647804", "0.66471726", "0.663799...
0.64180744
80
POST /suppliers POST /suppliers.xml
def create @supplier = Supplier.new(params[:supplier]) @reorder_url = reorder_suppliers_url respond_to do |format| if @supplier.save flash[:notice] = 'Supplier was successfully created.' format.html { redirect_to suppliers_url } format.xml { render :xml => @supplier, :status => :created, :location => @supplier } format.js { @suppliers = Supplier.paginate(:page => params[:page]) } else flash[:notice] = "Creating supplier failed due to errors." format.html { render :action => "new" } format.xml { render :xml => @supplier.errors, :status => :unprocessable_entity } format.js { render :action => 'new', :layout => false } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @supplier = Supplier.new(params[:supplier])\n \n respond_to do |format|\n if @supplier.save\n flash.now[:notice] = 'Supplier was successfully created.'\n format.html { redirect_to(suppliers_path) }\n format.xml { render :xml => @supplier, :status => :created, :locat...
[ "0.66206014", "0.6446516", "0.62613267", "0.61770946", "0.6129488", "0.6125736", "0.61216307", "0.6079917", "0.60690737", "0.6047322", "0.6008493", "0.5885715", "0.5875238", "0.58715147", "0.5847204", "0.57826024", "0.57712686", "0.5752866", "0.5734006", "0.5703061", "0.56898...
0.6028054
10
PUT /suppliers/1 PUT /suppliers/1.xml
def update @supplier = Supplier.find(params[:id]) @reorder_url = reorder_suppliers_url respond_to do |format| if @supplier.update_attributes(params[:supplier]) flash[:notice] = 'Supplier was successfully updated.' format.html { redirect_to suppliers_url } format.xml { head :ok } format.js { render :text => @supplier.reload.send(params[:supplier].keys.first) } else flash[:notice] = "Updating supplier failed due to errors." format.html { render :action => "edit" } format.xml { render :xml => @supplier.errors, :status => :unprocessable_entity } format.js { render :action => 'edit', :layout => false } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @pagetitle = \"Edit supplier\"\n \n @supplier = Supplier.find(params[:id])\n\n respond_to do |format|\n if @supplier.update_attributes(params[:supplier])\n format.html { redirect_to(@supplier, :notice => 'Supplier was successfully updated.') }\n format.xml { head :ok }\...
[ "0.6662371", "0.6547709", "0.6525773", "0.65177065", "0.64906967", "0.6401195", "0.6172407", "0.61698604", "0.61642784", "0.61593014", "0.6123787", "0.6121013", "0.6095022", "0.60845506", "0.6034941", "0.6033795", "0.6014588", "0.59880537", "0.5981467", "0.5955426", "0.594904...
0.5997061
17
DELETE /suppliers/1 DELETE /suppliers/1.xml
def destroy @supplier = Supplier.find(params[:id]) @reorder_url = reorder_suppliers_url respond_to do |format| if(@supplier.destroy) flash[:notice] = "Suppliers deleted (1)." format.html { redirect_to suppliers_url } format.xml { head :ok } format.js else flash[:notice] = "Deleting supplier failed due to errors." format.html { redirect_to suppliers_url } format.xml { head :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @supplier = Supplier.find(params[:id])\n @supplier.destroy\n\n respond_to do |format|\n format.html { redirect_to(suppliers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @supplier = Supplier.find(params[:id])\n \n # Erase supplier id for products fro...
[ "0.7136486", "0.6819872", "0.6665441", "0.6603871", "0.6577297", "0.6561226", "0.6549864", "0.64586115", "0.64328575", "0.6419727", "0.63677555", "0.6363091", "0.6324733", "0.6306946", "0.6306317", "0.62671214", "0.6236824", "0.6236824", "0.6236824", "0.6236492", "0.6230663",...
0.61676055
31
DELETE /suppliers/remove DELETE /suppliers/remove.xml
def remove @reorder_url = reorder_suppliers_url @ids = selected_ids(:supplier_ids) respond_to do |format| if(Supplier.remove(@ids)) flash[:notice] = "Suppliers removed (#{@ids.size})." format.html { redirect_to suppliers_url } format.xml { head :ok } format.js { @suppliers = Supplier.paginate(:page => params[:page]) } else flash[:notice] = "Removing suppliers failed due to errors." format.html { redirect_to suppliers_url } format.xml { head :unprocessable_entity } format.js end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @supplier = Supplier.find(params[:id])\n @supplier.destroy\n\n respond_to do |format|\n format.html { redirect_to(suppliers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @supplier = Supplier.find(params[:id])\n \n # Erase supplier id for products fro...
[ "0.70255274", "0.6807066", "0.6622152", "0.66165084", "0.6560411", "0.6507958", "0.6507929", "0.6418024", "0.6394611", "0.6339065", "0.63216144", "0.63144445", "0.6306959", "0.6299604", "0.6285878", "0.6268688", "0.624745", "0.6244051", "0.623926", "0.6235318", "0.62293833", ...
0.68095964
1
POST /suppliers/remove POST /suppliers/remove.xml
def reorder @reorder_url = reorder_suppliers_url @ids = selected_ids(:all_suppliers) respond_to do |format| if(Supplier.reorder(@ids)) flash[:notice] = "Suppliers reordered (#{@ids.size})." format.html { redirect_to suppliers_url } format.xml { head :ok } format.js else flash[:notice] = "Reordering suppliers failed due to errors." format.html { redirect_to suppliers_url } format.xml { head :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove\n @reorder_url = reorder_suppliers_url\n @ids = selected_ids(:supplier_ids)\n respond_to do |format|\n if(Supplier.remove(@ids))\n flash[:notice] = \"Suppliers removed (#{@ids.size}).\"\n format.html { redirect_to suppliers_url }\n format.xml { head :ok }\n for...
[ "0.725452", "0.6507281", "0.6449714", "0.6305555", "0.6237706", "0.6200551", "0.6194405", "0.61782175", "0.6129188", "0.60697913", "0.6023439", "0.6023439", "0.6023439", "0.6018366", "0.5996862", "0.5988238", "0.5968411", "0.5957808", "0.59575313", "0.595543", "0.595433", "...
0.0
-1
Default role is "Registered"
def setup_role if self.role_ids.empty? self.role_ids = [2] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def role; end", "def role; end", "def set_default_role\n add_role :user\n end", "def check_default_role\n roles << :user if roles.empty?\n end", "def set_default_role\n self.add_role :merchant\n end", "def resource_name\n\t\t\"role\"\n\tend", "def default_role\n self.role ||= Roles::US...
[ "0.7417596", "0.7417596", "0.7228715", "0.71749336", "0.7132338", "0.70743525", "0.70688635", "0.7032179", "0.7032179", "0.7017553", "0.6979593", "0.69676715", "0.69223356", "0.6914152", "0.6906071", "0.6901876", "0.6888237", "0.68881744", "0.68857217", "0.68757975", "0.68635...
0.0
-1
This method is called when starting.
def start super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def startup\n end", "def startup\n end", "def startup\n end", "def startup\n end", "def start\n super\n end", "def start\n\t\tinit\n\t end", "def startup\nend", "def onStart\r\n end", "def startup_hook; end", "def start\n\t\tend", "def start()\n\n\t\ten...
[ "0.8125362", "0.8043801", "0.8043801", "0.8043801", "0.79271466", "0.7816131", "0.7760315", "0.7723705", "0.76990306", "0.7635503", "0.76038164", "0.7540961", "0.74999744", "0.74690527", "0.74420434", "0.74309736", "0.74309736", "0.74309736", "0.74309736", "0.74309736", "0.74...
0.79078555
9
This method is called when shutting down.
def shutdown super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shut_down\n end", "def shutdown; end", "def shutdown; end", "def shutdown; end", "def shutdown; end", "def shutdown; end", "def shutdown; end", "def shutdown; end", "def shutdown\n end", "def shutdown\n end", "def shutdown\n end", "def shutdown\n end", "def shutdown\n...
[ "0.81754565", "0.80923635", "0.80923635", "0.80923635", "0.80923635", "0.80923635", "0.80923635", "0.80923635", "0.7992111", "0.7968249", "0.7968249", "0.7968249", "0.7968249", "0.7936938", "0.78437644", "0.777939", "0.77662414", "0.7761701", "0.7761701", "0.7761701", "0.7756...
0.78591704
20
some rules can be customized with extra data at runtime, see CustomTextRule as an example
def needs_customization? return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rules; end", "def rules; end", "def rules; end", "def rules; end", "def rules; end", "def rules; end", "def rules; end", "def rule; end", "def rule; end", "def rule; end", "def rules_by_name; end", "def subsequent_rules(*args); end", "def subsequent_rules(*args); end", "def textual_ru...
[ "0.6829549", "0.6829549", "0.6829549", "0.6829549", "0.6829549", "0.6829549", "0.6829549", "0.68055016", "0.68055016", "0.68055016", "0.65457916", "0.65172493", "0.65172493", "0.63771755", "0.61990774", "0.6129069", "0.6110325", "0.6110325", "0.6066379", "0.59922874", "0.5984...
0.0
-1
some rules can be customized with extra data at runtime, see CustomTextRule as an example
def customize_with_data(data: nil) not_implemented(__method__) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rules; end", "def rules; end", "def rules; end", "def rules; end", "def rules; end", "def rules; end", "def rules; end", "def rule; end", "def rule; end", "def rule; end", "def rules_by_name; end", "def subsequent_rules(*args); end", "def subsequent_rules(*args); end", "def textual_ru...
[ "0.6827708", "0.6827708", "0.6827708", "0.6827708", "0.6827708", "0.6827708", "0.6827708", "0.68030465", "0.68030465", "0.68030465", "0.6544377", "0.6515646", "0.6515646", "0.63779074", "0.6198019", "0.61293447", "0.61068046", "0.61068046", "0.6065457", "0.5991552", "0.598382...
0.0
-1
some rules only support specific fields, by default, all fields are supported unless restricted by providing a list of symbols matching the item_name as defined as the ItemToCheck is generated
def supported_fields_symbol_set return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check (workitem)\n\n raise(\n ArgumentError.new(\"'parameter'/'param' without a 'field' attribute\")\n ) unless @field\n\n field_value = workitem.attributes[@field]\n field_value ||= @default\n\n raise(\n ArgumentError.new(\"field '#{@field}' is missing\")\n ) unless...
[ "0.6059962", "0.5998676", "0.59893894", "0.59388214", "0.58195126", "0.5793032", "0.57630557", "0.56377", "0.5637653", "0.5578449", "0.557213", "0.55442476", "0.5539647", "0.5530641", "0.55295163", "0.5524762", "0.5503136", "0.5481726", "0.54680526", "0.5458211", "0.5397052",...
0.0
-1
each rule can define what type of ItemToCheck subclass they support override this method and return true or false
def handle_item?(item) not_implemented(__method__) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def matches?(actual)\n return false unless super\n\n return false unless presence_matches?(actual)\n\n return false unless item_type_matches?(actual)\n\n true\n end", "def works_with\n self.class.use_with_class_names.include? item_type\n end", "def include?(item, kind)\n case kind...
[ "0.7199556", "0.65871763", "0.65623105", "0.64821714", "0.6423121", "0.6380109", "0.63722146", "0.62673265", "0.62325644", "0.62267405", "0.6196136", "0.6099579", "0.6079162", "0.60213596", "0.60175353", "0.5984287", "0.5984234", "0.59811175", "0.597005", "0.59379464", "0.593...
0.0
-1
GET /elections GET /elections.json
def index @state = params[:state] if params[:state] @elections = Election.where(state: params[:state]) else @elections = Election.all end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @elections = Election.all\n end", "def elections(key = api_key)\n uri = \"#{base_path}/elections\"\n handle_timeouts do\n self.class.get(uri, query: { key: key })\n end\n end", "def index\n\t\trequire_admin!\n\t\t@elections = Election.all\n\tend", "def index\n @elections = cu...
[ "0.7780098", "0.77682763", "0.72844106", "0.71355355", "0.7003232", "0.70017797", "0.69516623", "0.6786767", "0.6610371", "0.65956116", "0.6556072", "0.6525988", "0.64702976", "0.64702976", "0.64702976", "0.64702976", "0.6420639", "0.6391928", "0.6388434", "0.63804954", "0.63...
0.66492295
8
GET /elections/1 GET /elections/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @elections = Election.all\n end", "def elections(key = api_key)\n uri = \"#{base_path}/elections\"\n handle_timeouts do\n self.class.get(uri, query: { key: key })\n end\n end", "def show\n @election_type = ElectionType.find(params[:id])\n\n respond_to do |format|\n for...
[ "0.7436889", "0.7174234", "0.70149934", "0.7007073", "0.6995031", "0.6905394", "0.6901018", "0.68842626", "0.6879076", "0.6879076", "0.6879076", "0.6879076", "0.68149805", "0.6809367", "0.680807", "0.6786753", "0.6722419", "0.6703747", "0.66840523", "0.66739404", "0.66038513"...
0.0
-1
POST /elections POST /elections.json
def create args = election_params.slice(:eligible_seats, :title, :description, :election_type, :scope_type, :scope_id_region) if election_params[:election_type] != 'resolution' args[:preparation_starts_at] = parse_datetime_params(election_params, :preparation_starts_at) args[:preparation_ends_at] = parse_datetime_params(election_params, :preparation_ends_at) end args[:voting_starts_at] = parse_datetime_params(election_params, :voting_starts_at) args[:voting_ends_at] = parse_datetime_params(election_params, :voting_ends_at) @election = Election.new(args) @election.ballot_box @election.participant_list @election.candidate_list #vygeneruje novy par verejny/soukromy klic public_key, private_key = Encryption::Keypair.generate( 4096 ) @election.public_key = public_key.to_s @shown_private_key = private_key.to_s saved = (@election.save && @election.ballot_box.save && @election.participant_list.save && @election.candidate_list.save && @election.election_protocol.save) if saved then if @election.election_type != 'resolution' then ElectionTransitionWorker.perform_at(@election.preparation_starts_at, @election.id.to_s, :start_preparation!) ElectionTransitionWorker.perform_at(@election.preparation_ends_at, @election.id.to_s, :stop_preparation!) end ElectionTransitionWorker.perform_at(@election.voting_starts_at, @election.id.to_s, :start_voting!) ElectionTransitionWorker.perform_at(@election.voting_ends_at, @election.id.to_s, :stop_voting!) end respond_to do |format| if saved format.html { render :show_created, notice: 'Volby byly vytvořeny.'} format.json { render :show, status: :created, location: @election } else format.html { render :new } format.json { render json: @election.errors, status: :unprocessable_entity } end end @shown_private_key = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @election = Election.new(election_params)\n\n respond_to do |format|\n if @election.save\n format.html { redirect_to @election, notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html...
[ "0.76360077", "0.76360077", "0.76199955", "0.7467465", "0.74270487", "0.70828575", "0.68453354", "0.6564084", "0.6504218", "0.64873856", "0.64801544", "0.64780587", "0.6462062", "0.644764", "0.64272034", "0.641588", "0.63750076", "0.6365462", "0.6360134", "0.6360134", "0.6360...
0.64343196
14
Use callbacks to share common setup or constraints between actions.
def set_election @election = Election.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 election_params params.require(:election).permit({ :state => ['preparation', 'voting', 'votes_counted']}, :election_type, :eligible_seats, :state, :title, :description, :scope_type, :scope_id_region, :preparation_starts_at, :preparation_ends_at, :voting_starts_at, :voting_ends_at, :public_key, :private_key) 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
convert long text into short form
def short_text_display content, path text = ((content.length > 90) ? HTML_Truncator.truncate(content, 3) : content ) ((content.length > text.length) ? (text + "<a href='#{path}' class='btn-link'> (more) </a>") : text).html_safe end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def short_text(text, max_length)\n short = text\n if text.present? && text.length > max_length\n short_array = text.slice(0, max_length).split(' ')\n short_array.pop\n short = short_array.join(' ') + ' ...'\n end\n short\n end", "def notebooktext_sh...
[ "0.7277528", "0.677715", "0.65798736", "0.6545205", "0.65228367", "0.6507387", "0.6436305", "0.63691306", "0.63422364", "0.62325287", "0.6168971", "0.6151906", "0.6134038", "0.6126016", "0.6086849", "0.6068986", "0.6066771", "0.6051664", "0.6047692", "0.60316026", "0.60092944...
0.0
-1
Used by tests so that the test run can complete (background threads prevent JVM exit)
def shutdown if @executor @executor.shutdown # We want this long enough to not have threading issues terminationWaitInSeconds = 10 terminatedInTime = @executor.awaitTermination(terminationWaitInSeconds, java.util.concurrent.TimeUnit::SECONDS) if !terminatedInTime raise "Did not shut down within #{terminationWaitInSeconds} seconds" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finalize_exec\n thread_mgr.threads.each(&:join)\n end", "def sleepy_run; end", "def go_run_tests\n @status = :running\n Thread.new do\n begin\n test_cases = @test_suite.sources\n\n @mutex.synchronize do\n @test_cases = test_cases\n @test_results = {}\n ...
[ "0.6796394", "0.6669419", "0.65606177", "0.65511644", "0.65062857", "0.6394781", "0.63544923", "0.63531065", "0.63316876", "0.632382", "0.62747276", "0.62497574", "0.62497574", "0.62497574", "0.6243986", "0.62370247", "0.62166226", "0.62013125", "0.61896855", "0.61598027", "0...
0.588546
49
"The value of avgLoad(s_i), in case of plugbased prediction, is calculated as the average of all load values reported by the given plug with timestamps in s_i."
def get_plug_avgLoad(s_i, h_id = house_id, hh_id = household_id, p_id = plug_id) query = "SELECT load FROM AveragePlugLoads WHERE house_id = %d " \ "AND household_id = %d "\ "AND plug_id = %d "\ "AND slice_index = %d" % [h_id, hh_id, p_id, s_i] results = execute_query(query) if results.count != 1 puts "Invalid number of results for slice_index (#{s_i})! #{results.map{|r| [r]}}" raise Exception end load = results.first["load"] puts "EXECUTED: #{query}, GOT #{load}" if DEBUG load end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_house_avgLoad(s_i)\n query = \"SELECT load FROM AveragePlugLoads WHERE house_id = %d \" \\\n \"AND slice_index = %d\" % [house_id, s_i]\n\n results = execute_query(query)\n loads = results.map{|row| row[\"load\"]}\n puts \"EXECUTED: #{query}, GOT #{loads}\" if DEBUG\n sum(loads)\n...
[ "0.7070309", "0.6514944", "0.5715062", "0.5703592", "0.56761414", "0.56139916", "0.55925155", "0.55877936", "0.5546139", "0.5539602", "0.5539602", "0.5480567", "0.54735357", "0.54427886", "0.54272914", "0.5405264", "0.5363349", "0.5356967", "0.5348985", "0.53477824", "0.53259...
0.7381988
0
"In case of a housebased prediction the avgLoad(s_i) is calculated as a sum of average values for each plug within the house."
def calculate_house_avgLoad(s_i) query = "SELECT load FROM AveragePlugLoads WHERE house_id = %d " \ "AND slice_index = %d" % [house_id, s_i] results = execute_query(query) loads = results.map{|row| row["load"]} puts "EXECUTED: #{query}, GOT #{loads}" if DEBUG sum(loads) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_plug_avgLoad(s_i, h_id = house_id, hh_id = household_id, p_id = plug_id)\n query = \"SELECT load FROM AveragePlugLoads WHERE house_id = %d \" \\\n \"AND household_id = %d \"\\\n \"AND plug_id = %d \"\\\n \"AND slice_index = %d\" % [h_id, hh_id, p_id, s_i]\n results = execute_query(quer...
[ "0.70620567", "0.67588174", "0.64534056", "0.6196577", "0.6170093", "0.6051528", "0.5949087", "0.5929447", "0.5897647", "0.58920723", "0.5872867", "0.5865916", "0.5852233", "0.5850626", "0.58442944", "0.5807122", "0.57988685", "0.57956445", "0.57865053", "0.5776777", "0.57497...
0.7835278
0
Called when a new tuple arrives at the plug_bolt
def update_current_plug_load set_instantaneous_plug_load(timestamp, value) s_i = slice_index load = calculate_plug_avgLoad(s_i) set_plug_avgLoad(s_i, load) # invalidate any future slices (none should exist; do a sanity check) invalidate_future_results end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def consume_tuple(tuple)\n obj = self.new\n fields.each do |field|\n if field[:type].respond_to?(:consume_tuple)\n val = field[:type].consume_tuple(tuple)\n else\n val = tuple.shift\n end\n obj.send(\"receive_#{field[:name]}\",...
[ "0.6263957", "0.5832949", "0.58224064", "0.56998885", "0.5660956", "0.55405194", "0.5511445", "0.5511445", "0.5476294", "0.5468317", "0.5455474", "0.5343325", "0.53002673", "0.522728", "0.52041525", "0.5058884", "0.5020271", "0.4999881", "0.49882787", "0.4985329", "0.4962137"...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_report @report = Report.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 report_params params.require(:report).permit(:title, :description, :status_id, :email, :image, :lat, :lng, :observation) 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
wookay.noh at gmail.com L lowercase letters. D words in this language. A pattern consists of exactly L tokens Each token is either a single lowercase letter (the scientists are very sure that this is the letter) or a group of unique lowercase letters surrounded by parenthesis ( and ). The first line of input contains 3 integers, L, D and N separated by a space. D lines follow, each containing one word of length L. These are the words that are known to exist in the alien language. N test cases then follow, each on its own line and each consisting of a pattern as described above. You may assume that all known words provided are unique.
def make_pattern pattern state = :close rule = '' last_ch = '' pattern.split('').each do |ch| case ch when '(' state = :open rule << '(' when ')' state = :close rule << ')' else case state when :open case last_ch when '(' else rule << '|' end rule << ch when :close rule << "[#{ch}]" end end last_ch = ch end Regexp.new rule end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def word_pattern(pattern, input)\n \nend", "def count_letters(line, all_inputs)\n freq = Hash.new\n line.chars do |c|\n if freq.has_key?(c)\n freq[c] += 1\n else\n freq[c] = 1\n end\n end\n if freq.value?(2)\n two_letters = 1\n else\n two_letters = 0\n end\n if freq.value?(3)\n...
[ "0.59454364", "0.57457006", "0.558616", "0.55285203", "0.55157197", "0.5494069", "0.5478071", "0.5461846", "0.5461123", "0.5448228", "0.54403496", "0.5431292", "0.5410543", "0.5399359", "0.5397531", "0.5386211", "0.53667355", "0.53567934", "0.5324131", "0.5309046", "0.5309046...
0.0
-1
Creates a new instance of the OpenLDAP database object
def initialize(model, database_id = nil, &block) super instance_eval(&block) if block_given? @name ||= 'ldap' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_database # :nodoc:\n @db = HDB.new\n if !@db.open(@path, default_flags)\n raise CorpusError.new(\"Error creating the database: #{@db.errmsg(@db.ecode)}\")\n end\n end", "def construct_new_object(db_object)\n end", "def new_db(options = {})\n cached = find_cached(options)...
[ "0.67422557", "0.65469146", "0.6430557", "0.6192397", "0.6164515", "0.6162977", "0.60991275", "0.60809743", "0.60582924", "0.604873", "0.604873", "0.6021682", "0.6002606", "0.5958396", "0.5955227", "0.5951017", "0.59422135", "0.593788", "0.5931088", "0.5929862", "0.59049326",...
0.53611016
86
Performs the slapcat command and outputs the data to the specified path based on the 'trigger'
def perform! super pipeline = Pipeline.new dump_ext = 'ldif' pipeline << slapcat model.compressor.compress_with do |command, ext| pipeline << command dump_ext << ext end if model.compressor pipeline << "#{ utility(:cat) } > " + "'#{ File.join(dump_path, dump_filename) }.#{ dump_ext }'" pipeline.run if pipeline.success? log!(:finished) else raise Error, "Dump Failed!\n" + pipeline.error_messages end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_output\r\n\t\t@output = File.open(File.join(\"log\", \"#{@server}_#{@db}_#{snow}.output\"), \"w\")\t\tif @run_cmds\r\n\t\t@output_cmds = File.open(File.join(\"log\", \"#{@server}_#{@db}_#{snow}.cmd\"), \"w\")\t\tif @log_cmds\t\r\n\tend", "def logs\n @file = \"crowbar-logs-#{ctime}.tar.bz2\"\n ...
[ "0.5404625", "0.53372204", "0.53372204", "0.5179338", "0.5031343", "0.4993796", "0.49444872", "0.48482412", "0.48330644", "0.48245716", "0.47924212", "0.47623256", "0.47581285", "0.47035185", "0.46931297", "0.46880606", "0.46862188", "0.46706164", "0.4645195", "0.4643588", "0...
0.44909462
25
Show invalid properties with the reasons. Usually used together with valid?
def list_invalid_properties invalid_properties = Array.new invalid_properties end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil....
[ "0.7648941", "0.7648941", "0.7648941", "0.7648941", "0.7636562", "0.7636562", "0.7636562", "0.7636562", "0.7636562", "0.7636562", "0.7636562", "0.7636562", "0.73556465", "0.7333955", "0.72676647", "0.72381455", "0.72310346", "0.72247696", "0.72072345", "0.7175248" ]
0.7169149
94
Check to see if the all the properties in the model are valid
def valid? true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_properties\n true\n end", "def validate_properties\n true\n end", "def validate\n super\n\n check_optional_property :collection, String\n check_optional_property :create, String\n check_optional_property :delete, String\n check_optional_property :...
[ "0.78992486", "0.78992486", "0.70971805", "0.70782334", "0.7032205", "0.7031276", "0.69510347", "0.6869891", "0.6858077", "0.6858077", "0.68287027", "0.6823878", "0.6820306", "0.68144894", "0.6794656", "0.6752167", "0.66843414", "0.6676546", "0.6667755", "0.66296124", "0.6618...
0.0
-1
Checks equality by comparing each attribute.
def ==(o) return true if self.equal?(o) self.class == o.class && commseq_postcard_uuid == o.commseq_postcard_uuid && commseq_step_uuid == o.commseq_step_uuid && commseq_uuid == o.commseq_uuid && conversion_dts == o.conversion_dts && cost == o.cost && customer_uuid == o.customer_uuid && delivered_dts == o.delivered_dts && from_address_line1 == o.from_address_line1 && from_address_line2 == o.from_address_line2 && from_city == o.from_city && from_name == o.from_name && from_state == o.from_state && from_zip == o.from_zip && mailed_dts == o.mailed_dts && order_id == o.order_id && postcard_tracking_uuid == o.postcard_tracking_uuid && status == o.status && submit_dts == o.submit_dts && to_address_line1 == o.to_address_line1 && to_address_line2 == o.to_address_line2 && to_city == o.to_city && to_name == o.to_name && to_state == o.to_state && to_zip == o.to_zip && tracking_description == o.tracking_description end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ==(other)\n attributes == other.attributes\n end", "def ==(other) # :nodoc:\n @attrs == other.attrs\n end", "def eql?(other)\n return true if self == other\n @@ATTRIBUTES.each do |att|\n return false unless self.send(att).eql?(other.send(att))\n end\n true\n en...
[ "0.7291717", "0.7188103", "0.70395297", "0.7007927", "0.68874705", "0.6861532", "0.6707156", "0.6660597", "0.66147524", "0.658478", "0.6584619", "0.6580019", "0.65543133", "0.6543933", "0.65068495", "0.6479513", "0.6456241", "0.6415999", "0.6412208", "0.6412208", "0.6412208",...
0.0
-1
Calculates hash code according to all attributes.
def hash [commseq_postcard_uuid, commseq_step_uuid, commseq_uuid, conversion_dts, cost, customer_uuid, delivered_dts, from_address_line1, from_address_line2, from_city, from_name, from_state, from_zip, mailed_dts, order_id, postcard_tracking_uuid, status, submit_dts, to_address_line1, to_address_line2, to_city, to_name, to_state, to_zip, tracking_description].hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash\n code = 17\n code = 37*code + @x.hash\n code = 37*code + @y.hash\n ...
[ "0.7118691", "0.70400536", "0.70400536", "0.70400536", "0.70400536", "0.70400536", "0.70400536", "0.70400536", "0.68960655", "0.67847186", "0.6707762", "0.670052", "0.6688737", "0.66705376", "0.6489735", "0.6462376", "0.6462376", "0.64444333", "0.6413127", "0.6395483", "0.638...
0.0
-1
Builds the object from hash
def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build(hash)\n obj = new\n hash.each_pair do |k,v|\n obj[k] = v if variables[k]\n end\n return obj\n end", "def build_from_hash(attributes)\n\n end", "def build_from_hash(hash)\n instance = self.new\n\n # Add the instance attributes dynamically ...
[ "0.8011074", "0.7470833", "0.7457607", "0.7256629", "0.72455454", "0.70060325", "0.6973257", "0.6955014", "0.69459796", "0.69398683", "0.69363195", "0.6917627", "0.6872358", "0.6796184", "0.6783521", "0.67575246", "0.67575246", "0.67560464", "0.67514306", "0.67136854", "0.666...
0.0
-1
Deserializes the data based on type
def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model temp_model = UltracartClient.const_get(type).new temp_model.build_from_hash(value) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s...
[ "0.7330926", "0.7274019", "0.72504056", "0.7245751", "0.7218884", "0.7213926", "0.71909", "0.7183136", "0.71796805", "0.71796805", "0.71796805", "0.71796805", "0.71796805", "0.71796805", "0.71796805", "0.71791923", "0.71791923", "0.71791923", "0.71791923", "0.71791923", "0.71...
0.72291344
14
Returns the string representation of the object
def to_s to_hash.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n @object.to_s\n end", "def to_s\n object.to_s\n end", "def serialize(object)\n object.to_s\n end", "def to_s\n self.inspect\n end", "def to_s\n @string || @object.to_s('F')\n end", "def to_s\n @string || @object.to_s('F')\n end", "de...
[ "0.901024", "0.89506465", "0.84703195", "0.83409667", "0.8337169", "0.8337169", "0.8332247", "0.82546586", "0.8145818", "0.8144667", "0.81357557", "0.812714", "0.8093436", "0.8086725", "0.8073356", "0.8039774", "0.80308646", "0.80064154", "0.80064154", "0.80064154", "0.800641...
0.0
-1
to_body is an alias to to_hash (backward compatibility)
def to_body to_hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_body\r\n to_hash\r\n end", "def to_body\n to_hash\nend", "def to_body\n to_hash\nend" ]
[ "0.84283537", "0.8347048", "0.8347048" ]
0.0
-1
Returns the object in the form of hash
def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_hash\n object\n end", "def hash\r\n return to_s.hash\r\n end", "def hash\n to_a.hash\n end", "def hash\n [_hash, name, owner].hash\n end", "def hash\n return to_s.hash\n end", "def hash\n @hash\n end", "def hash\n @hash.hash\n end", "def hash\n ...
[ "0.8270299", "0.78767854", "0.78726953", "0.7802364", "0.7789188", "0.77806795", "0.7775915", "0.7767511", "0.7760525", "0.7760525", "0.77559966", "0.7731286", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916",...
0.0
-1
Outputs nonarray value in the form of hash For object, use to_hash. Otherwise, just return the value
def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash\n [value].hash\n end", "def hash\n [value].hash\n end", "def hash\n\t\tvalue.hash\n\tend", "def hash\n value.hash\n end", "def hash\n @value.hash\n end", "def hash\r\n return to_s.hash\r\n end", "def to_hash\n @value\n end", "def to_hash\n @va...
[ "0.67215663", "0.67215663", "0.667063", "0.66587114", "0.65893066", "0.64536744", "0.6416161", "0.6416161", "0.63835067", "0.6348215", "0.6302799", "0.6224555", "0.6153449", "0.61035556", "0.6080278", "0.6080278", "0.6073062", "0.6036816", "0.6020006", "0.59388083", "0.590294...
0.0
-1
links to months we have posts for with year prepended
def oz_archived_months(sep = ', ') year, string = 0, '' months = {} years = [] Post.archived_months.map do |month| date = Time.parse(month) if date.year > year year = date.year months[year] = [] years << year end months[year] << month_link(date.strftime('%B').downcase, month) end years.map { |y| "#{y}: " << months[year].join(sep) }.join('<br/>') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def month_link(text, date)\r\n date = date.respond_to?(:strftime) ? date : Time.parse(date)\r\n link_to text, :controller => 'post', :action => 'list_by_date',\r\n :year => date.strftime('%Y'), :month => date.strftime('%m')\r\n end", "def month_link(text, date)\n date = date.respond_to...
[ "0.76234406", "0.7537615", "0.72031504", "0.6979876", "0.6979876", "0.6821073", "0.6797417", "0.67060155", "0.6702161", "0.6481583", "0.645893", "0.6443325", "0.64114654", "0.63687116", "0.63066125", "0.6231729", "0.62121993", "0.62121993", "0.62004703", "0.61839044", "0.6183...
0.6706203
7
return linked post types
def oz_post_types(sep = ', ') TYPES.dup.keys.map { |type| post_type_link(type + 's', type) }.join(sep) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def oz_post_types(sep = ', ')\r\n TYPES.dup.keys.map { |type| post_type_link(type + 's', type) }.join(sep)\r\n end", "def get_link_types\n Occi::Log.debug(\"Getting link types ...\")\n collection = @model.get Occi::Core::Link.kind\n collection.kinds.collect { |kind| kind.term }\n ...
[ "0.7156962", "0.7088653", "0.68233806", "0.67045814", "0.65610915", "0.64026326", "0.6255818", "0.6213766", "0.61743385", "0.61743385", "0.6111263", "0.6068886", "0.6057794", "0.60248953", "0.6008169", "0.5977859", "0.59611046", "0.59472966", "0.59381604", "0.59350204", "0.59...
0.71292436
1
the 5 most recent tags
def oz_recent_tags(sep = ' . ', limit = 5) Tag.find(:all, :order => "updated_at DESC", :limit => limit).map { |t| tag_link(t.name) }.join(sep) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tfivetags\n tag_array = self.tags\n sort_array = tag_array.sort!{|a,b| a.reputation_for(:votes) <=> b.reputation_for(:votes)}\n sort_array.reverse!\n topfive = sort_array.take(5)\n topfive\n end", "def five_recent_posts\n self.posts.sort_by(&:created_at).reverse.take(5)\n end", "def fiv...
[ "0.79760534", "0.7713672", "0.72729623", "0.7115842", "0.7090314", "0.7058849", "0.69521636", "0.6893585", "0.67047393", "0.6604371", "0.6582051", "0.6535917", "0.6453843", "0.643888", "0.64336616", "0.6401717", "0.63879156", "0.637273", "0.6330401", "0.63250625", "0.62283397...
0.69552964
6
popular tags (by frequency)
def oz_popular_tags(sep = ' . ', limit = 5) Tag.find_most_popular(limit).map { |t| tag_link(t.name) }.join(sep) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tags_with_counts\n counts = Hash.new(0)\n Tag.all(:id => taggings, :select => 'word').collect(&:word).each{|val|counts[val]+=1}\n counts.sort{|a,b| a[1] <=> b[1]}.reverse\n end", "def popular_tags\n normalize_key('popular_tags')\n end", "def tags_with_counts\n counts = model_...
[ "0.7504907", "0.7428212", "0.7386362", "0.7208343", "0.7086211", "0.7086211", "0.70664907", "0.7000885", "0.69873154", "0.6976928", "0.6923178", "0.6865302", "0.68368536", "0.675724", "0.6726501", "0.6615195", "0.6540756", "0.65224737", "0.64749825", "0.6398224", "0.6381463",...
0.6258742
24
display all the tags
def oz_all_tags(sep = ' ', plus_tag_link = true) tags = params[:tag].split(' ') if params[:tag] Tag.find(:all, :order => 'name ASC').map { |t| (plus_tag_link ? add_tag_link(t.name) : '') << tag_link(t.name) }.join(sep) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_tags\n tag_list = \"\"\n self.tags.each do |t|\n tag_list << \"#{t.name} \"\n end\n tag_list\n end", "def tags; end", "def tags; end", "def tags; end", "def tags; end", "def tags; end", "def return_all_tags\n @tags.uniq.each { |tag| puts tag }\n end", "def all\n Tag....
[ "0.8447252", "0.7285741", "0.7285741", "0.7285741", "0.7285741", "0.7285741", "0.7235664", "0.7233174", "0.72048527", "0.7124927", "0.7078345", "0.70675534", "0.69751513", "0.69300306", "0.6921667", "0.6882117", "0.6881989", "0.6881989", "0.68562746", "0.68506086", "0.6850608...
0.0
-1
builds a link to a list of posts for a type
def post_type_link(text, type = nil) type = text if type.nil? link_to text, :controller => 'tumble', :action => 'list_by_post_type', :type => type end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_type_link(text, type = nil)\r\n type = text if type.nil?\r\n link_to text, :controller => 'post', :action => 'list_by_type',\r\n :type => type\r\n end", "def url_for_list(type); end", "def link_for(type)\n if link = self.links.find { |link| link.type == type }\n ...
[ "0.78964734", "0.6718187", "0.6492731", "0.62836146", "0.61639243", "0.588572", "0.5879869", "0.5848769", "0.5816558", "0.5801572", "0.57999563", "0.5773242", "0.5702805", "0.57008135", "0.56912184", "0.56751776", "0.5673303", "0.5637062", "0.5597933", "0.5595053", "0.5589458...
0.7851966
1
builds a link to a month
def month_link(text, date) date = date.respond_to?(:strftime) ? date : Time.parse(date) link_to text, :controller => 'tumble', :action => 'list_by_date', :year => date.strftime('%Y'), :month => date.strftime('%m') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def month_link(text, month, opts={})\n link_to(text, \"#{simple_calendar_path}?month=#{month.month}&year=#{month.year}\", opts)\n end", "def month_link(text, month, opts={})\n link_to(text, \"#{simple_calendar_path}?month=#{month.month}&year=#{month.year}\", opts)\n end", "def month_link(text, ...
[ "0.83118796", "0.83118796", "0.80879515", "0.8009943", "0.7299689", "0.7207915", "0.71327704", "0.6569534", "0.6282154", "0.6248201", "0.6217607", "0.6216095", "0.61969125", "0.6193716", "0.610899", "0.6107332", "0.6089631", "0.6089631", "0.6023947", "0.59996164", "0.596472",...
0.8072775
3
if we're looking at a tag, give the option to add (or remove) another tag
def tag_link(t) link_to(t, {:controller => 'tumble', :action => 'tag', :tag => t}, { :rel => 'tag', :class => 'tag-link' }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tag(new_tag); end", "def add_tags(tag)\n remove_previous_tags\n if @page.find(input_elements[:tag_input_field]).present?\n @page.find(input_elements[:tag_input_field]).set(tag)\n else\n @page.find(input_elements[:tag_input_field2]).set(tag)\n end\n @page.find(input_elements[:t...
[ "0.78166324", "0.75497645", "0.7346228", "0.7092504", "0.7092504", "0.693287", "0.693287", "0.6888679", "0.68871707", "0.68549407", "0.6826857", "0.6826172", "0.681336", "0.67444336", "0.6702428", "0.6654872", "0.66439956", "0.66341406", "0.6621138", "0.66108274", "0.6599901"...
0.0
-1
add a + or in front of tags if we're looking at a tag's listing
def add_tag_link(tag) cur_tag = params[:tag] if cur_tag and !cur_tag.split.select { |x| x =~ /^#{tag}$/ }.empty? link = cur_tag.split if link.size == 1 link_to('-', { :controller => 'tumble', :action => 'list' }, :class => 'remove-tag') else link = link.reject { |x| x =~ /^#{tag}$/ } * '+' link_to('-', {:controller => 'tumble', :action => 'tag', :tag => link}, { :class => 'remove-tag' }).gsub(/%2B/,'+') end elsif cur_tag link = "#{cur_tag.gsub(' ','+')}+#{tag}" # the gsub below is an annoying hack to fight against the uri encoding. # need to find a way to turn it off.. link_to('+', {:controller => 'tumble', :action => 'tag', :tag => link}, { :class => 'add-tag', :rel => 'nofollow' }).gsub(/%2B/,'+') else "" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_tag_link(tag)\r\n cur_tag = params[:tag]\r\n if cur_tag and !cur_tag.split.select { |x| x =~ /^#{tag}$/ }.empty?\r\n link = cur_tag.split\r\n if link.size == 1\r\n link_to('-', '/', :class => 'remove-tag')\r\n else\r\n link = link.reject { |x| x =~ /^#{tag}$/ } * '+'\r\n ...
[ "0.6413991", "0.629976", "0.629976", "0.6215002", "0.6023971", "0.60063547", "0.60063547", "0.5989124", "0.59389716", "0.5931349", "0.5931349", "0.59080946", "0.59080946", "0.5887412", "0.58698356", "0.5790172", "0.5770041", "0.5764147", "0.5727113", "0.5710332", "0.56976235"...
0.66517746
0
for feed titles, mostly. strip out the textile markup.
def strip_textile(x) x = x.gsub(/<.+?>/,'') x = x.gsub(/\"(.*?)\":http:\/\/([^ ]*)( )?/,'\1 ') unless x.blank? x end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def titleless_content\n parse if fresh?\n @content.sub(/h\\d\\..+/, '')\n end", "def cleansed_title\n self.title.gsub(/[\\t\\r\\n\\f:@]/, '')\n end", "def meta_title\n\t\tread_attribute('title').gsub(/<\\/?[^>]*>/, \"\")\n\tend", "def cleanup_title(single_line)\n\tif single_line =~ /[^>]*$/ #Star...
[ "0.6973946", "0.6938864", "0.68825454", "0.68196434", "0.6743358", "0.67012954", "0.66756994", "0.6613748", "0.6578426", "0.656972", "0.6516673", "0.6485194", "0.6439823", "0.6431085", "0.6431085", "0.6422142", "0.63751256", "0.6366586", "0.6364359", "0.6362758", "0.6356592",...
0.62172705
26
Freeze nested_attributes_module when freezing model class.
def freeze @nested_attributes_module.freeze if @nested_attributes_module super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deep_freeze!\n replace deep_thaw.deep_freeze\n end", "def freeze\n @attributes.freeze; self\n end", "def freeze\n @attributes.freeze; self\n end", "def freeze\n @attributes.freeze\n self\n end", "def freeze\n freeze!\n attributes.freeze\n super\n end",...
[ "0.71698904", "0.7078661", "0.7078661", "0.69842154", "0.692393", "0.6695365", "0.6554488", "0.64775944", "0.6406256", "0.63707834", "0.6354136", "0.6287913", "0.6227343", "0.614261", "0.6055234", "0.60322404", "0.6015884", "0.60072005", "0.60026133", "0.6002393", "0.59924805...
0.8264114
0
Allow nested attributes to be set for the given associations. Options: :destroy :: Allow destruction of nested records. :fields :: If provided, should be an Array or proc. If it is an array, restricts the fields allowed to be modified through the association_attributes= method to the specific fields given. If it is a proc, it will be called with the associated object and should return an array of the allowable fields. :limit :: For _to_many associations, a limit on the number of records that will be processed, to prevent denial of service attacks. :reject_if :: A proc that is given each attribute hash before it is passed to its associated object. If the proc returns a truthy value, the attribute hash is ignored. :remove :: Allow disassociation of nested records (can remove the associated object from the parent object, but not destroy the associated object). :transform :: A proc to transform attribute hashes before they are passed to associated object. Takes two arguments, the parent object and the attribute hash. Uses the return value as the new attribute hash. :unmatched_pk :: Specify the action to be taken if a primary key is provided in a record, but it doesn't match an existing associated object. Set to :create to create a new object with that primary key, :ignore to ignore the record, or :raise to raise an error. The default is :raise. If a block is provided, it is used to set the :reject_if option.
def nested_attributes(*associations, &block) include(@nested_attributes_module ||= Module.new) unless @nested_attributes_module opts = associations.last.is_a?(Hash) ? associations.pop : {} reflections = associations.map{|a| association_reflection(a) || raise(Error, "no association named #{a} for #{self}")} reflections.each do |r| r[:nested_attributes] = opts r[:nested_attributes][:unmatched_pk] ||= ( if opts.has_key?(:strict) Sequel::Deprecation.deprecate("The nested_attributes :strict option", "Use the :unmatched_pk option instead") end opts.delete(:strict) == false ? :ignore : :raise) r[:nested_attributes][:reject_if] ||= block def_nested_attribute_method(r) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accepts_nested_attributes_for(*args)\n options = args.extract_options!.dup\n options[:autosave] = true if options[:autosave].nil?\n\n options[:reject_if] = REJECT_ALL_BLANK_PROC if options[:reject_if] == :all_blank\n args.each do |name|\n meth = \"#{name}_attribut...
[ "0.66340685", "0.6249431", "0.61148727", "0.6038243", "0.6037746", "0.60309494", "0.59992594", "0.5982055", "0.5842697", "0.58088535", "0.5784925", "0.5766009", "0.56795037", "0.56550705", "0.56430876", "0.5637941", "0.5517001", "0.55024666", "0.5501969", "0.54762983", "0.545...
0.7377025
0
Add a nested attribute setter method to a module included in the class.
def def_nested_attribute_method(reflection) @nested_attributes_module.class_eval do define_method("#{reflection[:name]}_attributes=") do |v| set_nested_attributes(reflection[:name], v) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define_writer_method(mod)\n writer_method_name = \"#{name}=\"\n attribute = self\n\n mod.send(:define_method, writer_method_name) { |value| attribute.set(self, value) }\n mod.send(writer_visibility, writer_method_name)\n\n self\n end", "def struct_writer(method)\n ...
[ "0.622819", "0.6096109", "0.60876536", "0.6043854", "0.6002986", "0.6002986", "0.59794307", "0.5798184", "0.5788058", "0.5777639", "0.5699977", "0.56934685", "0.56852794", "0.5669649", "0.56505597", "0.5646062", "0.56087625", "0.5593785", "0.55887556", "0.5585697", "0.5552459...
0.6476925
0
Check that the keys related to the association are not modified inside the block. Does not use an ensure block, so callers should be careful.
def nested_attributes_check_key_modifications(meta, obj) reflection = meta[:reflection] keys = reflection.associated_object_keys.map{|x| obj.get_column_value(x)} yield unless keys == reflection.associated_object_keys.map{|x| obj.get_column_value(x)} raise(Error, "Modifying association dependent key(s) when updating associated objects is not allowed") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def should_not_contain!(*keys, **options, &block)\n before_validation do\n JSONAPIonify::Continuation.new(**options).check(self) do\n keys += self.keys.select(&block) if block_given?\n invalid_keys = self.keys.map(&:to_sym) & keys.map(&:to_sym)\n i...
[ "0.58898985", "0.5704086", "0.5695653", "0.5616347", "0.55527675", "0.55387884", "0.55334777", "0.55042857", "0.54869545", "0.5468377", "0.54384565", "0.5421087", "0.54160994", "0.5405678", "0.5369046", "0.5341875", "0.5341875", "0.5341875", "0.5341875", "0.5332967", "0.53165...
0.73244625
0
Create a new associated object with the given attributes, validate it when the parent is validated, and save it when the object is saved. Returns the object created.
def nested_attributes_create(meta, attributes) reflection = meta[:reflection] obj = reflection.associated_class.new nested_attributes_set_attributes(meta, obj, attributes) delay_validate_associated_object(reflection, obj) if reflection.returns_array? send(reflection[:name]) << obj after_save_hook{send(reflection.add_method, obj)} else associations[reflection[:name]] = obj # Because we are modifying the associations cache manually before the # setter is called, we still want to run the setter code even though # the cached value will be the same as the given value. @set_associated_object_if_same = true # Don't need to validate the object twice if :validate association option is not false # and don't want to validate it at all if it is false. if reflection[:type] == :many_to_one before_save_hook{send(reflection.setter_method, obj.save(:validate=>false))} else after_save_hook{send(reflection.setter_method, obj)} end end add_reciprocal_object(reflection, obj) obj end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(attributes = {})\n resource = build(attributes)\n @parent.attributes[@name] = resource if resource.save\n resource\n end", "def create\n if self.send(self.class.parent_association_name).valid?\n self.send(self.class.parent_association_name).sav...
[ "0.73552406", "0.7254941", "0.6739345", "0.6440872", "0.63741684", "0.6313175", "0.6298682", "0.62771875", "0.6223499", "0.6217998", "0.6185822", "0.61726373", "0.6151971", "0.61385816", "0.61385816", "0.6130515", "0.6127512", "0.612502", "0.60935736", "0.60935736", "0.607902...
0.6865113
2
Take an array or hash of attribute hashes and set each one individually. If a hash is provided it, sort it by key and then use the values. If there is a limit on the nested attributes for this association, make sure the length of the attributes_list is not greater than the limit.
def nested_attributes_list_setter(meta, attributes_list) attributes_list = attributes_list.sort_by(&:to_s).map{|k,v| v} if attributes_list.is_a?(Hash) if (limit = meta[:limit]) && attributes_list.length > limit raise(Error, "number of nested attributes (#{attributes_list.length}) exceeds the limit (#{limit})") end attributes_list.each{|a| nested_attributes_setter(meta, a)} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_attributes_on_list(sorted_list, attribute_list, options={})\n \n unless attribute_list.blank?\n 0.upto(sorted_list.length - 1) {|idx|\n if sorted_list[idx]\n if (attr = attribute_list[idx].delete_if{|x, y| x.to_s == 'number'}).any?\n sorted_lis...
[ "0.6355446", "0.6297687", "0.623617", "0.61620045", "0.60875994", "0.6040318", "0.60176504", "0.59778804", "0.5956897", "0.5947333", "0.594544", "0.59200746", "0.59190184", "0.5916739", "0.59060603", "0.5904806", "0.5894702", "0.58890367", "0.5873946", "0.5846756", "0.5835919...
0.7359234
0
Remove the given associated object from the current object. If the :destroy option is given, destroy the object after disassociating it (unless destroying the object would automatically disassociate it). Returns the object removed.
def nested_attributes_remove(meta, obj, opts=OPTS) reflection = meta[:reflection] if !opts[:destroy] || reflection.remove_before_destroy? before_save_hook do if reflection.returns_array? send(reflection.remove_method, obj) else send(reflection.setter_method, nil) end end end after_save_hook{obj.destroy} if opts[:destroy] if reflection.returns_array? associations[reflection[:name]].delete(obj) end obj end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_associated_object(opts, o)\n raise(Sequel::Error, 'model object does not have a primary key') unless pk\n raise(Sequel::Error, 'associated object does not have a primary key') if opts.need_associated_primary_key? && !o.pk\n return if run_association_callbacks(opts, :before_remove, o) == f...
[ "0.68566453", "0.670379", "0.60688907", "0.58702296", "0.5775985", "0.5736648", "0.5661395", "0.5659584", "0.55869853", "0.556587", "0.5460751", "0.546013", "0.5414304", "0.5389991", "0.5369234", "0.5365703", "0.53530765", "0.534593", "0.53153175", "0.5282319", "0.5274116", ...
0.56790835
6
Set the fields in the obj based on the association, only allowing specific :fields if configured.
def nested_attributes_set_attributes(meta, obj, attributes) if fields = meta[:fields] fields = fields.call(obj) if fields.respond_to?(:call) obj.set_fields(attributes, fields, :missing=>:skip) else obj.set(attributes) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_fields(obj, type, request, params)\n columns_for(type, request).each do |col|\n column = col\n\n if association?(col)\n ref = model.association_reflection(col)\n ds = ref.associated_dataset\n if model_class = associated_model_class(col)\n ...
[ "0.6757878", "0.66669315", "0.64883757", "0.6448049", "0.62770987", "0.62217134", "0.6095843", "0.6041518", "0.6034894", "0.60215867", "0.5990014", "0.59239376", "0.58525735", "0.5816646", "0.58002603", "0.5741782", "0.5731197", "0.5686231", "0.5636953", "0.5618733", "0.56105...
0.6087927
7
Modify the associated object based on the contents of the attributes hash: If a :transform block was given to nested_attributes, use it to modify the attribute hash. If a block was given to nested_attributes, call it with the attributes and return immediately if the block returns true. If a primary key exists in the attributes hash and it matches an associated object: If _delete is a key in the hash and the :destroy option is used, destroy the matching associated object. If _remove is a key in the hash and the :remove option is used, disassociated the matching associated object. Otherwise, update the matching associated object with the contents of the hash. If a primary key exists in the attributes hash but it does not match an associated object, either raise an error, create a new object or ignore the hash, depending on the :unmatched_pk option. If no primary key exists in the attributes hash, create a new object.
def nested_attributes_setter(meta, attributes) if a = meta[:transform] attributes = a.call(self, attributes) end return if (b = meta[:reject_if]) && b.call(attributes) modified! reflection = meta[:reflection] klass = reflection.associated_class sym_keys = Array(klass.primary_key) str_keys = sym_keys.map(&:to_s) if (pk = attributes.values_at(*sym_keys)).all? || (pk = attributes.values_at(*str_keys)).all? pk = pk.map(&:to_s) obj = Array(send(reflection[:name])).find{|x| Array(x.pk).map(&:to_s) == pk} end if obj attributes = attributes.dup.delete_if{|k,v| str_keys.include? k.to_s} if meta[:destroy] && klass.db.send(:typecast_value_boolean, attributes.delete(:_delete) || attributes.delete('_delete')) nested_attributes_remove(meta, obj, :destroy=>true) elsif meta[:remove] && klass.db.send(:typecast_value_boolean, attributes.delete(:_remove) || attributes.delete('_remove')) nested_attributes_remove(meta, obj) else nested_attributes_update(meta, obj, attributes) end elsif pk.all? && meta[:unmatched_pk] != :create if meta[:unmatched_pk] == :raise raise(Error, "no matching associated object with given primary key (association: #{reflection[:name]}, pk: #{pk})") end else nested_attributes_create(meta, attributes) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nested_attributes_update_attributes(meta, obj, attributes)\n nested_attributes_check_key_modifications(meta, obj) do\n nested_attributes_set_attributes(meta, obj, attributes)\n end\n end", "def assign_to_or_destroy_nested_attributes_record(association_name, id, attributes,...
[ "0.6240173", "0.59159535", "0.57222104", "0.5692711", "0.5418203", "0.5380863", "0.53000736", "0.5299417", "0.5286306", "0.5257881", "0.52307266", "0.52283514", "0.5124065", "0.5121437", "0.50969493", "0.5055096", "0.50542754", "0.50444853", "0.5017012", "0.5012849", "0.50127...
0.74003685
0
Update the given object with the attributes, validating it when the parent object is validated and saving it when the parent is saved. Returns the object updated.
def nested_attributes_update(meta, obj, attributes) nested_attributes_update_attributes(meta, obj, attributes) delay_validate_associated_object(meta[:reflection], obj) # Don't need to validate the object twice if :validate association option is not false # and don't want to validate it at all if it is false. after_save_hook{obj.save_changes(:validate=>false)} obj end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_attributes(params = {})\n super validate_attributes(params)\n end", "def update\n @parent = Parent.find(params[:id])\n\n respond_to do |format|\n if @parent.update_attributes(params[:parent])\n format.html { redirect_to parents_url, notice: 'Parent was successfully updated.' ...
[ "0.6521088", "0.647589", "0.6450124", "0.6450124", "0.6450124", "0.6450124", "0.6450124", "0.6357503", "0.6339492", "0.6300395", "0.6243063", "0.6239758", "0.62191135", "0.6045024", "0.60401714", "0.60230273", "0.60063726", "0.5993975", "0.5990598", "0.5988608", "0.5970228", ...
0.70474374
0
Update the attributes for the given object related to the current object through the association.
def nested_attributes_update_attributes(meta, obj, attributes) nested_attributes_check_key_modifications(meta, obj) do nested_attributes_set_attributes(meta, obj, attributes) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(related, parent, options)\n parent.send(\"#{options.foreign_key}=\", related.id); related\n end", "def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'i...
[ "0.67194754", "0.6605826", "0.6560135", "0.64835095", "0.6363863", "0.62058526", "0.61278695", "0.6105834", "0.6080326", "0.60776484", "0.603967", "0.5993503", "0.5934125", "0.59305644", "0.591177", "0.5833793", "0.58145577", "0.5801272", "0.57930726", "0.5790311", "0.5782347...
0.64583796
4
This method handles the drag/drop Annotations sorting
def update_positions unless request.post? head :ok return end @assignment = Assignment.find(params[:assignment_id]) @annotation_categories = @assignment.annotation_categories position = 0 params[:annotation_category].each do |id| if id != '' position += 1 AnnotationCategory.update(id, position: position) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_entries; end", "def drag_to_order( dimension, items )\n positions = Array.new\n items.each_index do |n|\n item=$driver.find_element( items[n][0].to_sym, items[n][1] )\n positions[n] = item.location.send( dimension )\n end\n positions.sort!\n $debug and print \"In drag_to_order: ...
[ "0.5604882", "0.54383445", "0.543168", "0.53719014", "0.5359752", "0.52716094", "0.52626735", "0.52372867", "0.52372867", "0.523476", "0.5215427", "0.5196332", "0.518342", "0.5171724", "0.5162718", "0.5145436", "0.51241565", "0.5099913", "0.50548506", "0.50359267", "0.5035926...
0.0
-1
rewritten to use Chris Pine's shuffle algorithm
def music_shuffle filenames return [] if filenames.empty? # get the empty case out of the way # initialise shuffle filenames.sort! len = filenames.length # do the shuffle 2.times do leftpile = filenames[0..(len/2 - 1)] rightpile = filenames[len/2..-1] filenames = [] while !leftpile.empty? do filenames << rightpile.shift filenames << leftpile.shift end filenames = filenames + rightpile # adds final 'card' if len is odd end #cut the 'deck' at random cutpoint = rand(len) filenames = filenames[cutpoint..-1] + (cutpoint == 0 ? [] : filenames[0..(cutpoint-1)]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shuffle()\n \n end", "def shuffle!\r\n\t\trandomize!\r\n\tend", "def shuffle()\n @x.shuffle\n \n end", "def shuffled(seq)\n return shuffle(seq)\nend", "def shuffle\n shuf = @nums.clone\n l = shuf.length\n (0...l).each do |i|\n rand = rand(i...l)\n shuf[i], ...
[ "0.8366071", "0.803719", "0.79911965", "0.7976702", "0.7946226", "0.7862807", "0.78124607", "0.77964735", "0.77765524", "0.7735645", "0.77219987", "0.76980245", "0.76825017", "0.7640332", "0.7630003", "0.7596412", "0.75822526", "0.75822526", "0.7560521", "0.75503594", "0.7539...
0.69823265
97
this one shuffles avoiding consecutive tunes of the same genre wherever possible first we pick tunes at random but always switching genre when we can no longer do this we insert the remaining tunes in random places
def my_music_shuffle filenames return [] if filenames.empty? # get the empty case out of the way # split each filename into [path, file] filenames.map! {|name| Pathname.new(name).split} filenames.map! {|name| [name[0].to_s, name[1].to_s]} # initialise shuffle shufflednames = [] tailend_flag = false pick = rand(filenames.length) # do the shuffling while !(filenames == []) do # stick pick on the end unless tailend flag is raised, in which case insert randomly if !tailend_flag then shufflednames << filenames[pick] else shufflednames.insert(rand(shufflednames.length), filenames[pick]) end filenames.delete_at(pick) # set 'masknames' to list everything of a different genre masknames = filenames.select {|name| name[0] != shufflednames[-1][0]} # find a new pick, raising the tailend flag if we only have one genre left if !filenames.empty? then if !masknames.empty? then pickname = masknames.sample # pick a tune from a different genre pick = filenames.index(pickname) # find it in 'filenames' and point 'pick' to it else pick = rand(filenames.length) # pick any tune tailend_flag = true end end end # ends while loop #output the filenames merged back into strings shufflednames.map! {|name| name[0].to_s + '/' + name[1].to_s} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shuffle()\n \n end", "def shuffleTreasures\n @unusedTreasures.shuffle!\n end", "def shuffle_treasures\n @unused_treasures = @unused_treasures.shuffle\n end", "def shuffle!()\n\t\treplace(shuffle)\n\tend", "def shuffle!\n @rep.shuffle!\n end", "def shuffle!()\n r...
[ "0.69257", "0.68224263", "0.6793162", "0.6748999", "0.66832346", "0.66519207", "0.66178143", "0.6540294", "0.65383124", "0.65175396", "0.64697385", "0.6422126", "0.636073", "0.6351674", "0.63411367", "0.6338644", "0.6338148", "0.63287586", "0.6304159", "0.6281793", "0.625867"...
0.66663414
5
Convert VAR=value list into hash
def get_vars_hash(vars) tab_vars = {} vars.each do |var| tab_vars[var.split('=')[0]] = var.split('=')[1] end tab_vars end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_hash\n split(\"|\").map_hash{|e|e2 = e.split(\"=\") ; [e2[0].to_sym, e2[1]]}\n end", "def values_hash\n hashify(:value)\n end", "def argumentos(args)\n\thash = Hash.new\n\targs.each do |arg| \n\t\thash[arg.split('=').first] = arg.split('=').second\n\tend \n\treturn hash\nend", "def param...
[ "0.70034057", "0.64612544", "0.6361388", "0.63295335", "0.6311713", "0.6234085", "0.6140914", "0.59516126", "0.59516126", "0.5945612", "0.5938704", "0.592223", "0.5864505", "0.582698", "0.582651", "0.5824244", "0.578957", "0.57894546", "0.57695234", "0.57619613", "0.5756717",...
0.64138794
2
usage: devise_install do |config| config.mailer_sender = '' end
def devise_install(&block) if block_given? Devise.setup do |config| block.call config end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_devise_notification(notification, *args)\n if Rails.env.development?\n devise_mailer.send(notification, self, *args).deliver_later\n else\n super\n end\n end", "def send_devise_notification(notification, *args)\n devise_mailer.send(notification, self, *args).deliver_now\n end", ...
[ "0.705171", "0.6720137", "0.66501665", "0.66501665", "0.66501665", "0.66501665", "0.66501665", "0.66501665", "0.66501665", "0.66501665", "0.66501665", "0.66501665", "0.66501665", "0.66501665", "0.66501665", "0.66501665", "0.66501665", "0.66501665", "0.66501665", "0.66501665", ...
0.6087393
32
create safe string representation of event struct
def serialize Base64.encode64(@data.to_yaml) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def event_str\n if (event == nil)\n event_str = \"unknown event\"\n else\n event_str = event.to_s\n end\n event_str\n end", "def to_s\n ret = \"--- #{@attrs[:event_name]} ---\\n\"\n attrs = @attrs.collect { |k,v| [k.to_s, v] }\n attrs.reject! { |k,_| k == 'event_name' }\n ...
[ "0.8015162", "0.7610613", "0.75190175", "0.7240155", "0.6985674", "0.69046503", "0.6499882", "0.64271814", "0.6412298", "0.6392821", "0.6352262", "0.633003", "0.63012326", "0.6287609", "0.6230534", "0.6199138", "0.61772543", "0.6136022", "0.6113742", "0.60515654", "0.60446763...
0.0
-1
parse string representation of event
def deserialize( eventdata ) @data = YAML.load( Base64.decode64(eventdata) ) return self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_event!\n raise Dyno::MalformedInputError unless @raw.has_section?('Header')\n\n @event = Dyno::Event.new( :game => @raw['Header']['Game'] )\n @event.time = Time.parse( @raw['Header']['TimeString'] )\n @event.game_version = @raw['Header']['Version']\n\n # Extract the track name fr...
[ "0.69913566", "0.67869806", "0.6433418", "0.6327325", "0.62694514", "0.6258592", "0.62559175", "0.62032944", "0.62001914", "0.616552", "0.6161064", "0.61391824", "0.6114467", "0.6070342", "0.6070342", "0.60630506", "0.6037535", "0.59949315", "0.5980474", "0.59635496", "0.5780...
0.5287419
55
call processing for the given events list and release locks
def process( events, process_stat, settings = { :keep_processed => true} ) successfull = [] unsuccessfull = [] process_stat.start( events.length ) events.each do |event| begin if yield event # should be commented to keep processed records @conn.exec("delete from queues where eventid=#{event.dbid}") unless settings[:keep_processed] successfull.push( event.dbid ) else unsuccessfull.push( event.dbid ) end rescue unsuccessfull.push( event.dbid ) end end @conn.exec("update queues set status=#{EV_PROCESSED} where eventid in (#{ successfull.join(?,) })") if (successfull.length > 0 ) && settings[:keep_processed] @conn.exec("update queues set status=#{EV_READY} where eventid in (#{ unsuccessfull.join(?,) })") if unsuccessfull.length > 0 process_stat.finish( successfull.length, unsuccessfull.length ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process!\n events.each(&:process!)\n end", "def process_events\n until @dead\n event = next_event\n notify_listeners(event)\n event.dispatch\n end\n rescue Exception => ex\n Logger.error \"Error while running event: #{Logger.format_error(ex)}\"\n end", "def...
[ "0.6489524", "0.6303103", "0.61641574", "0.6073796", "0.5972219", "0.59443325", "0.59201324", "0.58429927", "0.5834331", "0.5813353", "0.5778142", "0.5761723", "0.57330734", "0.5663585", "0.5633827", "0.562309", "0.5611884", "0.55648714", "0.5477105", "0.54553384", "0.5454675...
0.6582892
0
add QueueProcessor::Event to queue
def put( queueid, event ) if @connected res = @conn.exec("insert into queues (queueid, event, status ) values ( #{queueid}, '#{event.serialize}', #{EV_READY} )") else raise DBError, "Not connected" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push_event event\n @event_queue << event\n end", "def push(event:)\n super\n\n @queue << event\n end", "def add_event(event)\n @queue[event.key] = EventData.new(event)\n end", "def <<(event)\n @mutex.synchronize { @queue << event }\n self\n end", "def post(ev)\n\t\t@...
[ "0.85388654", "0.8276026", "0.789019", "0.7700782", "0.745221", "0.70571834", "0.7008044", "0.6934125", "0.6890178", "0.6839048", "0.68159795", "0.6680301", "0.6672348", "0.6642022", "0.6580695", "0.6538453", "0.6538257", "0.6513672", "0.64731896", "0.6464429", "0.64470863", ...
0.64702183
19
codecite alias codecite wrap
def first=(val) puts "Setting first='#{val}'" self.old_first=val end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wrapper; end", "def wrappers(*args, &block); end", "def wrapper(name); end", "def transproc\n Functions[:wrap, key, selector]\n end", "def wrap(object); end", "def encoder=(_arg0); end", "def wrap(thing)\n thing\n end", "def wrapped_in=(_arg0); end", "def wrapper\n self...
[ "0.6266002", "0.5852986", "0.5827565", "0.5651534", "0.5616101", "0.5557209", "0.5556537", "0.54559463", "0.5383998", "0.5317606", "0.53173107", "0.5298658", "0.52961147", "0.5263007", "0.5244968", "0.523207", "0.52226734", "0.52154285", "0.52119637", "0.5196738", "0.5165213"...
0.0
-1
ex. arr=[1, 3, 5] and Y=2 should count 2
def greater_than(arr, y) count = 0 arr.each { |i| count +=1 if i > y} count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_elements(arr)\n count = 0\n\n arr.each do |x|\n if arr.include?(x+1)\n count += 1\n end\n end\n \n count\nend", "def cnts a\n r = []\n found = false\n a.each do |x|\n r.each do |y|\n if y[0] === x\n y[1] += 1\n found = true\n break...
[ "0.69431204", "0.6666747", "0.6640746", "0.6620456", "0.660547", "0.6603589", "0.6593531", "0.6537413", "0.6530336", "0.649244", "0.64908916", "0.64778155", "0.6476009", "0.64711833", "0.6465165", "0.6452966", "0.644211", "0.64341027", "0.6419104", "0.6412472", "0.6399966", ...
0.6749362
1
Default settings for resource properties.
def parsed_sv_bin return new_resource.sv_bin if new_resource.sv_bin '/usr/bin/sv' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_default_properties\n keys = @resource_config[:model].keys\n if keys.include?(\"_id\")\n property :id, :w => :nobody\n end\n if keys.include?(\"created_at\")\n property :created_at, :w => :nobody\n end\n if keys.include?(\"updated_at\")\n ...
[ "0.7791127", "0.71882576", "0.71354145", "0.71088034", "0.67550135", "0.65812206", "0.6577254", "0.64348817", "0.63388044", "0.63366956", "0.6252983", "0.6249934", "0.6222951", "0.6220998", "0.62168884", "0.62027687", "0.6148203", "0.6148203", "0.6115105", "0.6107411", "0.610...
0.0
-1
Override this method so that we can provide a fake file name. Several views depend on the datastream label, which is just the the original_filename of the file. This allows you to effectively change what label is displayed in those views. Otherwise, you will see the same label for every file.
def original_filename fake_file_name || super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_name\n self.name ||= File.basename(data_file.filename, '.*').titleize if data_file.filename && !self.name\n end", "def filename= name\n #This is a stub, used for indexing\n end", "def label_for(file)\n if file.is_a?(Hyrax::UploadedFile) # filename not pres...
[ "0.68464684", "0.6685372", "0.6605989", "0.65241575", "0.65241575", "0.6507999", "0.6501411", "0.64688045", "0.64307356", "0.64101726", "0.64101726", "0.6382542", "0.62657756", "0.6256786", "0.62493485", "0.62307256", "0.6227845", "0.6227813", "0.6227725", "0.6198651", "0.619...
0.7238634
0
Creates a new user without duplicating usernames
def create_user(email, name, pw) user = User.find_or_create_by(username: name) do |u| u.email = email u.username = name u.password = pw u.password_confirmation = pw end user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_user(details)\n puts \"Checking for #{details[:user_name]} user...\"\n\n db_user = User.where(:user_name => details[:user_name]).first\n\n if db_user.blank?\n db_user = User.create(details)\n db_user.creator_id = db_user.id\n db_user.updater_id = db_user.id\n\n db_user.skip_user_name_excl...
[ "0.7531183", "0.7463292", "0.74456", "0.74442875", "0.7403469", "0.7296265", "0.7292907", "0.72430664", "0.71827203", "0.71803135", "0.714634", "0.7112384", "0.7074396", "0.7054161", "0.7042033", "0.70174944", "0.70008093", "0.6994034", "0.6976228", "0.6957233", "0.69315636",...
0.6820119
31