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 |
|---|---|---|---|---|---|---|
Opens a file for reading in the storage. | def open(path, &block)
# :nocov:
raise(Errno::ENOENT, path)
# :nocov:
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_file(filename)\n File.open(filename, 'r')\n end",
"def _open(filename)\n File.open(filename, 'rb')\n end",
"def open(_filename, _mode = 'r')\n raise NotImplementedError\n end",
"def open_in_file(filepath)\n File.open(filepath, 'rb')\n end",
"def openFile... | [
"0.7423558",
"0.72899514",
"0.7265127",
"0.719588",
"0.71845937",
"0.7179765",
"0.69886655",
"0.6893543",
"0.6880851",
"0.6852488",
"0.6837664",
"0.677244",
"0.675515",
"0.6714227",
"0.6708297",
"0.66920376",
"0.6634811",
"0.6614728",
"0.65923095",
"0.6562873",
"0.6559601",
... | 0.0 | -1 |
Returns an enumerator that enumerates the files contained in a directory. | def foreach(path)
# :nocov:
raise(Errno::ENOENT, path)
# :nocov:
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enumerate_files(directory)\n return directory.\n children.\n reject(&:directory?).\n map(&:expand_path)\n end",
"def enumerate_files search_path\n Enumerator.new do |e|\n Dir\n .glob(search_path)\n .each do |filename|\n if File.file?(filename)\n $std... | [
"0.7805349",
"0.7047516",
"0.6769093",
"0.6759356",
"0.67106533",
"0.66972744",
"0.663739",
"0.65795916",
"0.65795916",
"0.65591353",
"0.6559123",
"0.65543175",
"0.64846224",
"0.62846035",
"0.6205992",
"0.6194468",
"0.61525375",
"0.6134605",
"0.60913",
"0.6071524",
"0.6068210... | 0.0 | -1 |
Invoked when the storage is no longer needed. The default implementation does nothing. | def close; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear\n @storage.empty\n end",
"def purge!\n\n fetch_all({}).each { |hwi| @context.storage.delete(hwi) }\n end",
"def delete\n fast_storage.delete\n warehouse_storage.delete\n end",
"def purge!\n @data = nil\n end",
"def purge!\n @data = nil\n end",
... | [
"0.6773202",
"0.65455526",
"0.6511147",
"0.6389298",
"0.6389298",
"0.6338673",
"0.6269487",
"0.626759",
"0.6257628",
"0.6231949",
"0.621815",
"0.6202903",
"0.61842453",
"0.6159364",
"0.61571103",
"0.61374766",
"0.6132199",
"0.61183006",
"0.61087203",
"0.6096167",
"0.6049785",... | 0.0 | -1 |
A function which checks if the current user is an admin | def is_admin
# Firstly checks if the user is signed in at all
if user_signed_in?
# And then verifies if the user is not an admin
# The function is used to grant access to specific views
if not current_user.admin?
# If the user is not an admin they will be redirected back to home page
# with an error message
flash[:alert] = I18n.t('messages.unauthorized')
redirect_to root_url
end
else
redirect_to new_user_session_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin_user?\n (current_user.role == 'admin') if logged_in?\n end",
"def user_admin?\n user_logged_in? && @current_user.type == 'Admin'\n end",
"def is_admin?(user)\n user.admin > 0\n end",
"def admin_user?\n if current_user != nil\n !!current_user.admin\n end\n end",
... | [
"0.8914026",
"0.88926333",
"0.8885924",
"0.888563",
"0.88500124",
"0.8844975",
"0.8809463",
"0.88039124",
"0.8794138",
"0.87907654",
"0.87790585",
"0.8754934",
"0.8746",
"0.87249047",
"0.8715171",
"0.8714708",
"0.8712481",
"0.8707717",
"0.8699219",
"0.8696928",
"0.8691679",
... | 0.0 | -1 |
Gets a list of the tasks in the working lists | def task_names
Helpers::DATABASE[:Tasks].join(:Task_list, :Tasks__Id => :Task_list__Task_Id).join(
:Lists, :Lists__Id => :Task_list__List_id).select(:Tasks__Id, :Tasks__Task_number,
:Tasks__Name, :Tasks__Completed, :Tasks__Priority).filter(:Lists__Name => Config[:working_list_name])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tasks\n task_list.tasks\n end",
"def task_lists\n\t\t@task_lists ||= fetch_latest_task_lists\n\tend",
"def work_tasks\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:task, RDF.type, Ruta::Class.task],\n [:task, Ruta::Property.has_worker, uri]\n )\n tasks = []\n query.... | [
"0.80045867",
"0.7808935",
"0.7782248",
"0.75925845",
"0.75121146",
"0.74679774",
"0.7451371",
"0.7431075",
"0.7431075",
"0.7431075",
"0.73806614",
"0.73341936",
"0.72792804",
"0.72470415",
"0.7244164",
"0.7232665",
"0.7232665",
"0.7215228",
"0.71542466",
"0.7137778",
"0.7128... | 0.68501335 | 31 |
GET /accounttypes/1 GET /accounttypes/1.xml | def show
@accounttype = Accounttype.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @accounttype }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @account_type = AccountType.find(params[:id])\n \n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @account_type.to_xml }\n end\n end",
"def index\n @account_types = AccountType.find(:all, :order => 'position ASC')\n\n respond_to do |format... | [
"0.7130717",
"0.6799314",
"0.66732347",
"0.6504237",
"0.63799113",
"0.6279763",
"0.6279763",
"0.6279763",
"0.6218826",
"0.6203775",
"0.6198638",
"0.61867046",
"0.61593986",
"0.6142988",
"0.6119069",
"0.60913825",
"0.6081201",
"0.6069506",
"0.60603243",
"0.6052674",
"0.6020229... | 0.7067696 | 1 |
GET /accounttypes/new GET /accounttypes/new.xml | def new
@accounttype = Accounttype.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @accounttype }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @account = User::Account.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account }\n end\n end",
"def create\n @accounttype = Accounttype.new(params[:accounttype])\n\n respond_to do |format|\n if @accounttype.save\n forma... | [
"0.6947659",
"0.69147575",
"0.68614787",
"0.68614787",
"0.68614787",
"0.6860368",
"0.68547446",
"0.6829248",
"0.6772195",
"0.6731019",
"0.67172027",
"0.66814774",
"0.66628414",
"0.6625797",
"0.6609838",
"0.6579814",
"0.6563624",
"0.6544663",
"0.652106",
"0.65072167",
"0.64893... | 0.7586216 | 0 |
POST /accounttypes POST /accounttypes.xml | def create
@accounttype = Accounttype.new(params[:accounttype])
respond_to do |format|
if @accounttype.save
format.html { redirect_to(@accounttype, :notice => 'Accounttype was successfully created.') }
format.xml { render :xml => @accounttype, :status => :created, :location => @accounttype }
else
format.html { render :action => "new" }
format.xml { render :xml => @accounttype.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_account_type_params\n if params[:account][:account_type]\n params.require(:account).require(:account_type).permit(AccountType.attribute_list)\n else\n {}\n end\n end",
"def create\n @admin_account_type = AccountType.new(admin_account_type_params)\n\n respond_to do |format|\... | [
"0.6313554",
"0.6228297",
"0.59386796",
"0.5778738",
"0.57579684",
"0.56877005",
"0.5637547",
"0.56311864",
"0.5593848",
"0.5575904",
"0.5558983",
"0.5548971",
"0.5519951",
"0.54932904",
"0.5484068",
"0.5484068",
"0.5474263",
"0.54736197",
"0.5471184",
"0.54622805",
"0.546228... | 0.6404553 | 0 |
PUT /accounttypes/1 PUT /accounttypes/1.xml | def update
@accounttype = Accounttype.find(params[:id])
respond_to do |format|
if @accounttype.update_attributes(params[:accounttype])
format.html { redirect_to(@accounttype, :notice => 'Accounttype was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @accounttype.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_account_type\n @account_type = AccountType.find(params[:id])\n end",
"def update\n authorize! :update, @account_type\n respond_to do |format|\n if @account_type.update(account_type_params)\n format.html { redirect_to @account_type, notice: 'Account type was successfully updated.... | [
"0.62853",
"0.6280919",
"0.62211764",
"0.60901326",
"0.6026529",
"0.5929957",
"0.5876703",
"0.5874321",
"0.5822997",
"0.58127964",
"0.5801451",
"0.57691604",
"0.5767919",
"0.57287335",
"0.5715074",
"0.571186",
"0.5686156",
"0.5675308",
"0.561886",
"0.56170744",
"0.56035227",
... | 0.6654542 | 0 |
DELETE /accounttypes/1 DELETE /accounttypes/1.xml | def destroy
@accounttype = Accounttype.find(params[:id])
@accounttype.destroy
respond_to do |format|
format.html { redirect_to(accounttypes_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @account_type = AccountType.find(params[:id])\n @account_type.destroy\n \n respond_to do |format|\n format.html { redirect_to admin_account_types_url }\n format.xml { render :nothing => true }\n end\n end",
"def delete_account\n @connection.request({\n ... | [
"0.7339356",
"0.7012527",
"0.69082046",
"0.6721021",
"0.6640306",
"0.66314924",
"0.6593917",
"0.6532977",
"0.65221024",
"0.65191203",
"0.6518164",
"0.6505582",
"0.64954376",
"0.64807576",
"0.64787304",
"0.645368",
"0.6434444",
"0.6427911",
"0.64271593",
"0.64271593",
"0.64106... | 0.7477929 | 0 |
This should be deprovated | def check_password(survey)
can_access = false
if is_admin?
can_access = true
elsif survey.password.nil? || survey.password.empty?
can_access = true
elsif current_user.id == survey.course.teacher_id
can_access = true
elsif params[:pass] == survey.password
can_access = true
end
redirect_to course_path(survey.course), notice: "The password you entered was not valid or you
aren't authorized to visit this quiz" unless can_access
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def refutal()\n end",
"def suivre; end",
"def implementation; end",
"def implementation; end",
"def formation; end",
"def internal; end",
"def custom... | [
"0.8313248",
"0.71409976",
"0.70270026",
"0.68856335",
"0.68856335",
"0.68856335",
"0.68856335",
"0.6763433",
"0.6630774",
"0.6562895",
"0.6562895",
"0.6558284",
"0.65011495",
"0.647076",
"0.647076",
"0.635704",
"0.635704",
"0.6352919",
"0.6289418",
"0.62689775",
"0.6263559",... | 0.0 | -1 |
GET /rooms/1 GET /rooms/1.json | def show
cookies[:room_id] = @room.slug
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\t\t@rooms = Room.order(updated_at: :desc)\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @rooms }\n\t\tend\n\tend",
"def index\n @rooms = Room.all\n respond_to do | format |\n format.html\n format.json\n end\n \n end",
"def index\n @rooms ... | [
"0.74791723",
"0.74694896",
"0.74580145",
"0.74171317",
"0.7339656",
"0.7338611",
"0.7338611",
"0.7338611",
"0.72950053",
"0.71323436",
"0.7077669",
"0.7033066",
"0.7013328",
"0.6949826",
"0.6912503",
"0.6889643",
"0.6889487",
"0.6889487",
"0.6889487",
"0.6889487",
"0.6889487... | 0.0 | -1 |
POST /rooms POST /rooms.json | def create
if 'true' == params[:bulk]
params[:room][:stories_attributes] = bulk_import_params
end
@room = Room.new(room_params.merge(created_by: current_user.id))
respond_to do |format|
if @room.save
set_user_room_moderator
format.html { redirect_to room_path(@room.slug), notice: 'Room was successfully created.' }
format.json { render :show, status: :created, location: @room }
else
format.html { render :new }
format.json { render json: @room.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @room = Room.new(params[:room])\n\n if @room.save\n render :json => @room, :status => :created, :location => @room\n else\n render :json => @room.errors, :status => :unprocessable_entity\n end\n end",
"def create\n @user=User.find(params[:user_id])\n @room = @user.rooms.... | [
"0.7205094",
"0.7079678",
"0.6965091",
"0.6931828",
"0.6896531",
"0.6896531",
"0.6835706",
"0.6807692",
"0.6762218",
"0.6762218",
"0.6762218",
"0.67154557",
"0.6680471",
"0.66675544",
"0.6650434",
"0.66451526",
"0.6636018",
"0.6628381",
"0.65890825",
"0.6562031",
"0.65547556"... | 0.0 | -1 |
PATCH/PUT /rooms/1 PATCH/PUT /rooms/1.json | def update
respond_to do |format|
if @room.update_attributes(room_params)
format.html { redirect_to room_path(@room.slug), notice: 'Room was successfully updated.' }
format.json { render :show, status: :ok, location: @room }
else
format.html { render :edit }
format.json { render json: @room.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @room = Room.find(params[:id])\n\n if @room.update_attributes(params[:room])\n head :ok\n else\n render :json => @room.errors, :status => :unprocessable_entity \n end\n end",
"def update\n if @room.update(room_params)\n render json: @room, status: :ok, serializer: Room... | [
"0.71671927",
"0.7049237",
"0.699943",
"0.6995195",
"0.6966581",
"0.69269025",
"0.69258416",
"0.69258416",
"0.69059575",
"0.68662304",
"0.68116236",
"0.6795441",
"0.6791917",
"0.67734885",
"0.67436135",
"0.673438",
"0.6731134",
"0.67005306",
"0.67005306",
"0.67005306",
"0.670... | 0.67427593 | 15 |
DELETE /rooms/1 DELETE /rooms/1.json | def destroy
@room.destroy
respond_to do |format|
format.html { redirect_to rooms_url, notice: 'Room was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { redirect_to rooms_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @room = Room.find(params[:id])\n @room.destroy\n\n respond_to do |format|\n format.html { re... | [
"0.7635934",
"0.7620118",
"0.761992",
"0.7589228",
"0.7583094",
"0.7565785",
"0.7555699",
"0.75015026",
"0.7446661",
"0.7445735",
"0.7438515",
"0.73450273",
"0.7341036",
"0.7299027",
"0.7295218",
"0.72534937",
"0.72534937",
"0.725146",
"0.72453046",
"0.72278804",
"0.72278804"... | 0.72336674 | 27 |
Never trust parameters from the scary internet, only allow the white list through. | def room_params
params.require(:room).permit(
:name, :pv, :timer, :style,
stories_attributes: [:id, :link, :desc, :_destroy]
)
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.6979893",
"0.6781746",
"0.6746611",
"0.6742344",
"0.6735229",
"0.6592651",
"0.65027124",
"0.6498011",
"0.648163",
"0.647716",
"0.64556813",
"0.64386255",
"0.63784456",
"0.63756156",
"0.636574",
"0.6319542",
"0.63004524",
"0.6299559",
"0.62925464",
"0.62923217",
"0.6289894"... | 0.0 | -1 |
Hay que declararlo antes que cualquier otro before_action en los controladores que lo necesiten | def set_obra
@obra = params[:obra_id].present? ? Obra.find(params[:obra_id]) : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_action \n end",
"def before\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def before\n\t\t\ttrue\n\t\tend",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def before_dispatch(env); end",
"d... | [
"0.7164",
"0.6739",
"0.6725383",
"0.6684243",
"0.66753894",
"0.6656778",
"0.6625221",
"0.66209954",
"0.6466342",
"0.64583915",
"0.6448088",
"0.6418523",
"0.63878834",
"0.63626844",
"0.6350837",
"0.6329802",
"0.62693596",
"0.623859",
"0.6237715",
"0.61952937",
"0.61792105",
... | 0.0 | -1 |
para cargar las columnas porque ordenar | def set_order
sort = params[:sort].present? ? params[:sort] : 'id'
# FIXME cambiar puntos por guiones para tener automagia
if sort == 'terceros_nombre'
sort = 'terceros.nombre'
end
ord = params[:order].present? ? params[:order].upcase() : 'ASC'
@order = sort + ' ' + ord
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def columnas(tablero)\r\n\t#Columnas0\r\n\t\te = 0\r\n\t\t@columna0 = Array.new\r\n\t\twhile e < 6\r\n\t\t\t@columna0 << tablero[e,0]\r\n\t\t\te += 1\r\n\t\tend\r\n\r\n\t#Columnas1\r\n\t\te = 0\r\n\t\t@columna1 = Array.new\r\n\t\twhile e < 6\r\n\t\t\t@columna1 << tablero[e,1]\r\n\t\t\te += 1\r\n\t\tend\r\n\r\n\t#C... | [
"0.662202",
"0.6469677",
"0.6292812",
"0.6273797",
"0.6230907",
"0.61459255",
"0.6127123",
"0.60996056",
"0.60596937",
"0.6052092",
"0.60361093",
"0.60340095",
"0.6033572",
"0.6012916",
"0.5999899",
"0.5989019",
"0.5988713",
"0.5916604",
"0.5880884",
"0.58679515",
"0.5867785"... | 0.0 | -1 |
No dejar que el usuario hax0r invente causas | def causas_conocidas
%w{ cheque-propio cheque-de-terceros efectivo transferencia retenciones }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ha_accedido?\n\t\t!usuario_actual.nil?\n\tend",
"def user_have\n unless current_user\n redirect_to root_path, :alert => \"Зарегистрируйтесь или войдите\"\n end\n end",
"def inicio_sesion?\n usuario_id.blank?\n end",
"def exibe_para_usuario?\n \t\tif usuario_signed_in?\n \t\t\tif current... | [
"0.6911467",
"0.6477279",
"0.6416356",
"0.6198759",
"0.60914195",
"0.60902715",
"0.6090109",
"0.6068393",
"0.606042",
"0.600077",
"0.5993608",
"0.596924",
"0.59630775",
"0.59561265",
"0.5955868",
"0.5947268",
"0.5945654",
"0.5944962",
"0.59354734",
"0.5914366",
"0.59136546",
... | 0.0 | -1 |
obtener los parametros requeridos para cada causa | def causa_params
if params[:causa].present? && params[:causa_tipo].present?
case params[:causa_tipo]
when 'cheque-de-terceros', 'cheque-propio'
# copiado de app/controllers/cheques_controller.rb#cheque_params
params[:causa].permit(:situacion, :numero, :monto,
:monto_centavos, :monto_moneda, :fecha_vencimiento,
:fecha_emision, :beneficiario, :banco, :estado, :chequera_id,
:cuenta_id, :obra_id, :cheque_id)
when 'retenciones'
params[:causa].permit(:retencion_id, :monto, :documento, :factura_id, :fecha_vencimiento, :situacion)
when 'transferencia', 'efectivo'
params[:causa].permit(:monto_moneda, :monto_aceptado_moneda, :monto_aceptado, :monto, :caja_id,
:caja, :caja_destino_id)
else
{}
end
else
{}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conta_params\n params.fetch(:conta, {})\n end",
"def get_parameters(rft)\n # API supports oclcnum, isbn, or lccn, and can provide more than one of each. \n get_bibkey_parameters(rft) do |isbn, lccn, oclcnum| \n keys = Array.new\n \n keys << \"oclc:\" + CGI.esc... | [
"0.5986478",
"0.57551926",
"0.56527597",
"0.5607525",
"0.5600484",
"0.55726993",
"0.5572676",
"0.55670804",
"0.55331427",
"0.5529017",
"0.55263144",
"0.55263144",
"0.55017996",
"0.54920906",
"0.54682547",
"0.54102516",
"0.5405779",
"0.53907233",
"0.53888506",
"0.5370702",
"0.... | 0.58706784 | 1 |
Updating the balance of the invoice from Financial Transactions | def update_purchase_balance
update(balance: financial_transactions.sum(:total_amount))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @invoice.invoice_type == InvoiceType.deposit\n if @invoice.update(invoice_params)\n @balance_invoice = @invoice.project.balance_invoice\n @balance_invoice.amount = @invoice.project.price - @invoice.amount\n @balance_invoice.save!\n ... | [
"0.768905",
"0.7681836",
"0.7677212",
"0.7675942",
"0.7598036",
"0.74927884",
"0.7365681",
"0.72751075",
"0.7238648",
"0.70918024",
"0.70584756",
"0.70450073",
"0.6972706",
"0.69637513",
"0.69199014",
"0.690423",
"0.68913406",
"0.6870845",
"0.6850513",
"0.6841666",
"0.6840024... | 0.79265314 | 0 |
Updating customer Sale balance which is offset by receipts | def update_customer_purchase_balance
if contact.present?
new_positve_balance = self.amount.to_f + contact.purchase_balance.to_f
contact.update_attributes(purchase_balance: new_positve_balance)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_purchase_balance\n update(balance: financial_transactions.sum(:total_amount))\n end",
"def update_customer_total\n \t current_total = self.customer.total_repair\n \t repair = Repair.find(self.id)\n \t customer = self.customer\n \tif current_total\n \t\tcustomer.total_repair -= repair.total_ch... | [
"0.7251866",
"0.68869483",
"0.6756888",
"0.67140096",
"0.65224564",
"0.6492995",
"0.6440358",
"0.6422067",
"0.63970196",
"0.63750684",
"0.637301",
"0.6368578",
"0.63563114",
"0.6339403",
"0.6297501",
"0.62844676",
"0.6267068",
"0.6267068",
"0.62661135",
"0.62660915",
"0.62095... | 0.69418555 | 1 |
Calculating the gross amount & Vat Amount of Purchase through the purchase_entries | def update_amount
self.amount = purchase_entries
.find_all(&:price?)
.sum { |journal_entry| journal_entry.price * journal_entry.quantity }
self.vat_amount = purchase_entries
.find_all(&:vat_amount?)
.sum { |journal_entry| journal_entry.vat_amount * journal_entry.quantity }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gross_revenue\n purchases.to_a.sum(&:gross_revenue)\n end",
"def gross_revenue\n item.price * count\n end",
"def generate_total_billing\n total = 0\n self.ur_invoices.each do |ur_invoice|\n total += ur_invoice.final_total\n end\n\n self.invoice_items.each do |invoice_item|\n t... | [
"0.70370287",
"0.6955961",
"0.67330575",
"0.6686019",
"0.6664781",
"0.66008985",
"0.65776795",
"0.65501237",
"0.65501237",
"0.65391827",
"0.6518457",
"0.6493546",
"0.6478166",
"0.6448633",
"0.6447997",
"0.64265704",
"0.64139074",
"0.64106536",
"0.6386152",
"0.6370529",
"0.636... | 0.7182197 | 0 |
A helpful method to generate the javascript code necessary for the web browser to communicate with the universal DOM remote | def javascript()
"
var ws = new WebSocket('ws://127.0.0.1:55000/');
ws.onopen = function() {
console.log('CONNECT');
ws.send('subscribe to topic: udr/controller');
};
ws.onclose = function() {
console.log('DISCONNECT');
};
ws.onmessage = function(event) {
var a = event.data.split(/: +/,2);
console.log(a[1]);
try {
r = eval(a[1]);
}
catch(err) {
r = err.message;
}
ws.send('udr/browser: ' + r);
};
"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_detection_html(user_agent)\n ua_info = fingerprint_user_agent(user_agent)\n os = ua_info[:os_name]\n client = ua_info[:ua_name]\n\n code = ERB.new(%Q|\n <%= js_base64 %>\n <%= js_os_detect %>\n <%= js_ajax_post %>\n <%= js_misc_addons_detect %>\n <%= js_ie... | [
"0.6361478",
"0.6215909",
"0.6161905",
"0.61591566",
"0.61164325",
"0.60436386",
"0.60299426",
"0.5856432",
"0.58450603",
"0.58167994",
"0.5752779",
"0.5710374",
"0.5709474",
"0.5688238",
"0.56862164",
"0.5683966",
"0.55934215",
"0.5579022",
"0.55311865",
"0.5515856",
"0.5515... | 0.61422855 | 5 |
used by the callback routine | def ontopic(topic, msg)
a = topic.split('/')
sender = a.pop
puts "%s: %s" % [sender, msg] if @debug
@received << msg
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callback\n end",
"def callback\n\n end",
"def callbacks; end",
"def callbacks; end",
"def callback\n\tend",
"def callback=(_arg0); end",
"def callback_type; end",
"def callback &block\n super\n end",
"def callback &block\n super\n end",
"def handle; end",
"def finished; ... | [
"0.7779175",
"0.76567316",
"0.75077665",
"0.75077665",
"0.742766",
"0.7180294",
"0.6319881",
"0.63133997",
"0.63133997",
"0.6274935",
"0.6266337",
"0.6264956",
"0.6247712",
"0.6225275",
"0.6222952",
"0.6210703",
"0.6210304",
"0.6193063",
"0.6171662",
"0.6156028",
"0.60681564"... | 0.0 | -1 |
send the instruction to the web browser | def send(s, timeout: 30)
t = Time.now + timeout
super(s)
sleep 0.1 until @received.any? or Time.now > t
raise UniversalDomRemoteException, 'recv::timeout' if Time.now > t
r = @received.last
@received = []
return r
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def go()\n\t@selenium.open @url\n end",
"def visit\n @browser.goto(URL)\n end",
"def send_page\n send_message(\"page\")\n end",
"def visit url\n @agent.get url\n @agent.page.form&.submit\n end",
"def go_to_url (url)\n\t\t@browser.goto (url)\n\tend",
"def go_to_page(url)\n Logbo... | [
"0.667511",
"0.6475335",
"0.6409171",
"0.6407214",
"0.63391125",
"0.630217",
"0.620067",
"0.61547804",
"0.6118256",
"0.6050061",
"0.6034057",
"0.60307395",
"0.60307395",
"0.59761566",
"0.59457034",
"0.59234554",
"0.5921017",
"0.59006876",
"0.5861596",
"0.58591455",
"0.5853733... | 0.0 | -1 |
"SOURCE /channels/input HTTP/1.0\r\nAuthorization: Basic Og==\r\nUserAgent: libshout/2.3.1\r\nContentType: audio/mpeg\r\nicename: test\r\nicepublic: 1\r\niceurl: Live Mix\r\niceaudioinfo: bitrate=128\r\nicedescription: \r\n\r\n" | def receive_data(data)
if data.match 'SOURCE'
p data
send_data("HTTP 200 OK\r\n\r\n")
else
# require 'pry'; binding.pry
p data.size
@channel.push(data.bytes)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_stream_title\n stream_title = nil\n Open3.popen3(@mplayer_cmd) do |stdin, stdout, stderr, wait_thr|\n while line = stdout.gets\n if line.match('ICY Info:')\n stream_title = line.split('=')[1].tr(\"';\",'')\n end\n end\n end\n return stream_title\n end",
"def ... | [
"0.59919333",
"0.5907164",
"0.54944617",
"0.5456719",
"0.54312545",
"0.53998727",
"0.5349281",
"0.5285932",
"0.5277352",
"0.52532333",
"0.5180346",
"0.51763225",
"0.51628065",
"0.51568353",
"0.5147874",
"0.51440537",
"0.5132076",
"0.51270944",
"0.5123391",
"0.5106782",
"0.503... | 0.5118706 | 19 |
The id of this container | def id
raise "Method 'id' must be defined"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id\n container.id\n end",
"def id\n container_info.ids[0] if container_info.entries.length == 1\n end",
"def container_id\n @container_info[\"Id\"]\n end",
"def container_id\n return @container_id\n end",
"def container_id\n super.to_i rescue nil... | [
"0.84144336",
"0.8319826",
"0.8253721",
"0.795505",
"0.77786666",
"0.7627126",
"0.73988515",
"0.7290838",
"0.7242238",
"0.72064346",
"0.7181587",
"0.715953",
"0.71008116",
"0.70999485",
"0.70919317",
"0.7090886",
"0.70877874",
"0.70810163",
"0.70714587",
"0.70714587",
"0.7071... | 0.0 | -1 |
The root directory of the application | def root
find_single_directory || @droplet.root
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root\n find_single_directory || @app_dir\n end",
"def root_dir\n is_rails? ? Rails.root.to_s : Dir.pwd.to_s\n end",
"def root\n self.config[:root] || Dir.pwd rescue Dir.pwd\n end",
"def root\n Pathname.new(ENV[\"RAILS_ROOT\"] || Dir.pwd)\n end",
"def root\n self... | [
"0.85877013",
"0.8404429",
"0.831308",
"0.8272025",
"0.82600045",
"0.82187045",
"0.82032686",
"0.8182676",
"0.8147685",
"0.8147685",
"0.81157327",
"0.8073351",
"0.8073351",
"0.8063547",
"0.80581313",
"0.8047936",
"0.80266756",
"0.79950345",
"0.7973803",
"0.79565364",
"0.79360... | 0.7232586 | 75 |
Whether or not this component supports this application | def supports?
raise "Method 'supports?' must be defined"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supported?\n false\n end",
"def supported?\n supports_platform? && supports_runtime?\n end",
"def supports?\n web_inf? && !JavaBuildpack::Util::JavaMainUtils.main_class(@application)\n end",
"def supports?\n !@version.nil?\n end",
"def supports?\n fail \"Method 'supports?' ... | [
"0.77523255",
"0.768223",
"0.75862384",
"0.74048257",
"0.7378796",
"0.73709804",
"0.72819",
"0.7183484",
"0.7058739",
"0.70426524",
"0.70426524",
"0.70426524",
"0.69184256",
"0.69127756",
"0.6897206",
"0.68480426",
"0.6809878",
"0.68049496",
"0.6751974",
"0.6751974",
"0.67357... | 0.75410414 | 3 |
Converts a given +object+ to an XML value. | def to_xml_value(object, escape_xml = true)
if DateTime === object
object.strftime XS_DATETIME_FORMAT
elsif String === object
escape_xml ? CGI.escapeHTML(object) : object
elsif object.respond_to?(:to_datetime)
to_xml_value object.to_datetime
elsif object.respond_to?(:call)
to_xml_value object.call
else
object.to_s
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_xml(obj)\n obj.to_xml\n end",
"def toXmlStr(otObject, depth=1)\n tempDb = XMLDatabase.new\n tempObjectService = @otrunk.createObjectService(tempDb)\n newObj = tempObjectService.copyObject(otObject, depth)\n tempDb.setRoot(newObj.getGlobalId)\n outStream = ByteArrayOutputStream.n... | [
"0.7370758",
"0.6295903",
"0.6155708",
"0.61464465",
"0.61070454",
"0.6099847",
"0.5908511",
"0.5848501",
"0.5839575",
"0.58386445",
"0.57861453",
"0.5723918",
"0.5706927",
"0.5639065",
"0.5633559",
"0.5629986",
"0.56278425",
"0.5627838",
"0.56134844",
"0.5587148",
"0.5572766... | 0.71906424 | 1 |
See end of this file for an example request | def create
Reading.create! reading_params
head :created
rescue ActiveRecord::RecordInvalid
head :bad_request
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def req\n \n end",
"def request_data; end",
"def http; end",
"d... | [
"0.7848348",
"0.7848348",
"0.7848348",
"0.7848348",
"0.7848348",
"0.7848348",
"0.7848348",
"0.7848348",
"0.7848348",
"0.7848348",
"0.7848348",
"0.74830896",
"0.7116448",
"0.6985064",
"0.6975582",
"0.693879",
"0.69251084",
"0.6866981",
"0.6862886",
"0.6811384",
"0.67490417",
... | 0.0 | -1 |
Parse the table at the current location. | def parse_table
return false unless after_block_boundary?
saved_pos = @src.save_pos
orig_pos = @src.pos
table = new_block_el(:table, nil, nil, alignment: [], location: @src.current_line_number)
leading_pipe = (@src.check(TABLE_LINE) =~ /^\s*\|/)
@src.scan(TABLE_SEP_LINE)
rows = []
has_footer = false
columns = 0
add_container = lambda do |type, force|
if !has_footer || type != :tbody || force
cont = Element.new(type)
cont.children, rows = rows, []
table.children << cont
end
end
until @src.eos?
break unless @src.check(TABLE_LINE)
if @src.scan(TABLE_SEP_LINE)
if rows.empty?
# nothing to do, ignoring multiple consecutive separator lines
elsif table.options[:alignment].empty? && !has_footer
add_container.call(:thead, false)
table.options[:alignment] = @src[1].scan(TABLE_HSEP_ALIGN).map do |left, right|
(left.empty? && right.empty? && :default) || (right.empty? && :left) ||
(left.empty? && :right) || :center
end
else # treat as normal separator line
add_container.call(:tbody, false)
end
elsif @src.scan(TABLE_FSEP_LINE)
add_container.call(:tbody, true) unless rows.empty?
has_footer = true
elsif @src.scan(TABLE_ROW_LINE)
trow = Element.new(:tr)
# parse possible code spans on the line and correctly split the line into cells
env = save_env
cells = []
@src[1].split(/(<code.*?>.*?<\/code>)/).each_with_index do |str, i|
if i.odd?
(cells.empty? ? cells : cells.last) << str
else
reset_env(src: Kramdown::Utils::StringScanner.new(str, @src.current_line_number))
root = Element.new(:root)
parse_spans(root, nil, [:codespan])
root.children.each do |c|
if c.type == :raw_text
f, *l = c.value.split(/(?<!\\)\|/, -1).map {|t| t.gsub(/\\\|/, '|') }
(cells.empty? ? cells : cells.last) << f
cells.concat(l)
else
delim = (c.value.scan(/`+/).max || '') + '`'
tmp = +"#{delim}#{' ' if delim.size > 1}#{c.value}#{' ' if delim.size > 1}#{delim}"
(cells.empty? ? cells : cells.last) << tmp
end
end
end
end
restore_env(env)
cells.shift if leading_pipe && cells.first.strip.empty?
cells.pop if cells.last.strip.empty?
cells.each do |cell_text|
tcell = Element.new(:td)
tcell.children << Element.new(:raw_text, cell_text.strip)
trow.children << tcell
end
columns = [columns, cells.length].max
rows << trow
else
break
end
end
unless before_block_boundary?
@src.revert_pos(saved_pos)
return false
end
# Parse all lines of the table with the code span parser
env = save_env
l_src = ::Kramdown::Utils::StringScanner.new(extract_string(orig_pos...(@src.pos - 1), @src),
@src.current_line_number)
reset_env(src: l_src)
root = Element.new(:root)
parse_spans(root, nil, [:codespan, :span_html])
restore_env(env)
# Check if each line has at least one unescaped pipe that is not inside a code span/code
# HTML element
# Note: It doesn't matter that we parse *all* span HTML elements because the row splitting
# algorithm above only takes <code> elements into account!
pipe_on_line = false
while (c = root.children.shift)
next unless (lines = c.value)
lines = lines.split("\n")
if c.type == :codespan
if lines.size > 2 || (lines.size == 2 && !pipe_on_line)
break
elsif lines.size == 2 && pipe_on_line
pipe_on_line = false
end
else
break if lines.size > 1 && !pipe_on_line && lines.first !~ /^#{TABLE_PIPE_CHECK}/o
pipe_on_line = (lines.size > 1 ? false : pipe_on_line) || (lines.last =~ /^#{TABLE_PIPE_CHECK}/o)
end
end
@src.revert_pos(saved_pos) and return false unless pipe_on_line
add_container.call(has_footer ? :tfoot : :tbody, false) unless rows.empty?
if table.children.none? {|el| el.type == :tbody }
warning("Found table without body on line #{table.options[:location]} - ignoring it")
@src.revert_pos(saved_pos)
return false
end
# adjust all table rows to have equal number of columns, same for alignment defs
table.children.each do |kind|
kind.children.each do |row|
(columns - row.children.length).times do
row.children << Element.new(:td)
end
end
end
if table.options[:alignment].length > columns
table.options[:alignment] = table.options[:alignment][0...columns]
else
table.options[:alignment] += [:default] * (columns - table.options[:alignment].length)
end
@tree.children << table
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_table\n @parse_table ||= parse_table_for_rule(start)\n end",
"def parse_table; end",
"def parse_table\n advance\n table = Element.new(:table)\n table = parse_attributes(table)\n table = parse_caption(table)\n while match?(:table_row, :table_header, :table_data)\n ... | [
"0.7195813",
"0.694976",
"0.6772426",
"0.67232114",
"0.6700339",
"0.62925553",
"0.622609",
"0.6059307",
"0.5995355",
"0.58043367",
"0.5659293",
"0.55723995",
"0.54558873",
"0.5418021",
"0.5403914",
"0.53842527",
"0.5374057",
"0.5353513",
"0.5308209",
"0.52617836",
"0.5258255"... | 0.6010952 | 8 |
Run the defined postprocessors on the given question. Useful when you need to postprocess questions at a higher level. | def postprocess_question(question)
unless @_question_postprocessors.nil?
@_question_postprocessors.each do |postprocessor|
postprocessor.call(question)
end
end
question
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_processors\n @post_processors ||= []\n end",
"def process\n self.read_layouts\n self.transform_pages\n if options['also_copy']\n self.transform_pages('', options['also_copy'])\n end\n self.write_posts\n end",
"def post_process(answer)\n answer\n end",... | [
"0.530494",
"0.52825665",
"0.5269834",
"0.5224095",
"0.51755345",
"0.51749855",
"0.511768",
"0.5099696",
"0.5099369",
"0.5080347",
"0.50729364",
"0.50497574",
"0.4995019",
"0.4906147",
"0.49046752",
"0.48648506",
"0.48231402",
"0.48163158",
"0.48079833",
"0.47935423",
"0.4793... | 0.8640335 | 0 |
Give a new question. | def question(name, text, attrs={}, &instance_block)
q = Question.new(name, text, self, attrs, &instance_block)
(@_questions||=[]) << q
postprocess_question(q)
return q
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_question\n question_hash = Adapter.quiz_api(difficulty) #use adapter method, with difficulty passes into the url as a variable, to gnerate a new list of questions.\n new_question = Question.new #make a new question instance\n new_question.save #save now so we can store the question's id in the ... | [
"0.74169356",
"0.73423696",
"0.7323511",
"0.7323511",
"0.7323511",
"0.7323511",
"0.72800606",
"0.72598517",
"0.72357816",
"0.7231482",
"0.72226965",
"0.7134999",
"0.7054893",
"0.70454013",
"0.6948183",
"0.69204986",
"0.69150406",
"0.68828076",
"0.68139756",
"0.680329",
"0.679... | 0.0 | -1 |
Get the array of all noted questions for this class and its superclasses. | def questions
qs = []
qs |= superclass.questions if superclass.respond_to? :questions
qs |= (@_questions||=[])
qs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def questions\n qs = []\n qs |= self.class.questions if self.class.respond_to? :questions\n qs |= (@_questions||=[])\n qs.map{|q| q.for_instance(self) }\n end",
"def ordered_subclasses\n [Question]\n end",
"def questions\n return nil unless self.id?\n SurveyQuestion.subclas... | [
"0.77090484",
"0.73424006",
"0.7041203",
"0.6806482",
"0.67320603",
"0.67292774",
"0.6512431",
"0.6323985",
"0.62298894",
"0.6213279",
"0.61269104",
"0.61204314",
"0.60834926",
"0.6023453",
"0.60153204",
"0.591841",
"0.5896503",
"0.58580166",
"0.58030957",
"0.5753199",
"0.568... | 0.7725869 | 0 |
Get the array of all noted questions for this instance and its class (and all of its superclasses), bound to this instance. All questions will be bound to the instance on which `questions` is called, so their `instance_block`s, if provided, will be evaluated in its context. | def questions
qs = []
qs |= self.class.questions if self.class.respond_to? :questions
qs |= (@_questions||=[])
qs.map{|q| q.for_instance(self) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def questions\n qs = []\n qs |= superclass.questions if superclass.respond_to? :questions\n qs |= (@_questions||=[])\n qs\n end",
"def questions\n return nil unless self.id?\n SurveyQuestion.subclasses.collect do |table|\n table.where(survey: self)\n end.compact.flatten.sort_... | [
"0.6418706",
"0.59709024",
"0.5869277",
"0.5683634",
"0.5649234",
"0.5636541",
"0.56081736",
"0.54983217",
"0.54278815",
"0.5413627",
"0.5398911",
"0.5375784",
"0.53618544",
"0.53332895",
"0.5322348",
"0.5283816",
"0.5216621",
"0.5185363",
"0.5184353",
"0.51444936",
"0.511068... | 0.7135444 | 0 |
Given an array of numbers, add 2 elements at a time in order and return the resulting array. ex: input = [1,2,4,3,6,2,3] output = [3,7,8,3] | def ary_add(array)
if array.length.even?
ary_couples = array.each_slice(2)
final_ary = []
ary_couples.each do |duo|
ary_sum = duo[0] + duo[-1]
final_ary << ary_sum
end
return final_ary
else
last_obj = array.pop
ary_couples = array.each_slice(2)
final_ary = []
ary_couples.each do |duo|
ary_sum = duo[0] + duo[-1]
final_ary << ary_sum
end
return final_ary << last_obj
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_numbers(array)\n#add first in array to next in array. replace next in array\n#until array.length < 1\n return array[0] if array.length <= 1\n num1, num2 = array.pop, array.pop\n sum = num1.to_i + num2.to_i\n array.unshift(sum)\n add_numbers(array)\nend",
"def running_total1(array)\n array_new = []\... | [
"0.7196513",
"0.7115752",
"0.6855108",
"0.68447787",
"0.6757677",
"0.6747513",
"0.66778904",
"0.6673251",
"0.66711265",
"0.6600686",
"0.6578315",
"0.6565511",
"0.65595996",
"0.6556553",
"0.6547929",
"0.6547625",
"0.65403306",
"0.6527635",
"0.6514145",
"0.64900106",
"0.6487639... | 0.6692471 | 6 |
Find if a string is a palindrome of a 2nd string. Restrictions Do better than 1 itteration through a string. input: noon, noon output: true | def palindrome_match?(str1, str2)
# split the word in half to check if even
# check if even check first half against second half reversed
# return true if match
num_check = str1.length/2
if num_check.even?
ary_1 = str1.chars.each_slice(str1.length/2)
ary_2 = str2.chars.each_slice(str2.length/2)
return true if str1[0] == str2[0]
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def palindrome?(str)\n length = str.length\n half1 = str.slice(0, length/2)\n if length.odd?\n half2 = str.slice(length/2 + 1, length)\n else\n half2 = str.slice(length/2, length)\n end\n half1 === half2.reverse\nend",
"def palindrome?\n str = self.to_s\n len = str.size\n\n if len.odd?\n ... | [
"0.83694696",
"0.83510226",
"0.83228767",
"0.8238432",
"0.8200719",
"0.8197536",
"0.814443",
"0.8130498",
"0.81217796",
"0.81179565",
"0.81115323",
"0.81115323",
"0.81115323",
"0.8103244",
"0.8090152",
"0.8089115",
"0.8082614",
"0.8074233",
"0.80740404",
"0.80740404",
"0.8074... | 0.79928905 | 38 |
pass a proc object instead of a block | def greeting(&block)
puts 'good morning'
text = block.call('hello')
puts text
puts 'good evening'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def block_to_proc(&p)\n\tp.call\nend",
"def run_block\n p = Proc.new # <1>\n p.call\nend",
"def run_block\n p = Proc.new\n p.call\nend",
"def call_a_proc(&block)\n block.call\nend",
"def proc_method(&my_proc)\n puts \"method start\"\n my_proc.call\n puts \"method end\"\nend",
"def process... | [
"0.7966231",
"0.76181275",
"0.7592291",
"0.7555428",
"0.74372315",
"0.7372135",
"0.73340386",
"0.7294752",
"0.72736204",
"0.7273542",
"0.7269346",
"0.7268291",
"0.7268291",
"0.7207631",
"0.7202567",
"0.7185484",
"0.71805257",
"0.7103807",
"0.7058137",
"0.69637495",
"0.693419"... | 0.0 | -1 |
=> Proc good morning hellohello good evening | def greeting(&block)
puts 'good morning'
text = block.call('hello')
puts text
puts 'good evening'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batman_ironman_proc #will return batman will win\n victor = Proc.new { |n| return \"Batman will win!#{n}\" }\n victor.call(3)\n \"Iron Man will win!\"\nend",
"def speak\n p \"Ho, ho, ho! Haaaappy holidays!\"\n end",
"def speak\n print \"Ho, ho, ho! Haaaappy holidays!\"\nend",
"def speak\n \tputs... | [
"0.63077444",
"0.6300635",
"0.6251569",
"0.62458366",
"0.6234747",
"0.6217882",
"0.620937",
"0.6167968",
"0.61532533",
"0.61238194",
"0.61228293",
"0.6122273",
"0.61185354",
"0.6111193",
"0.61062145",
"0.60758907",
"0.60758907",
"0.6072209",
"0.60687774",
"0.6030082",
"0.6028... | 0.0 | -1 |
=> good morning hellohello good evening pass a proc object as an ordinary argument takes a proc object as an argument,not a block | def greeting(arrange_proc)
puts 'good morning'
text = arrange_proc.call('hello')
puts text
puts 'good evening'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def proc_example\n\tsay_hi = proc {|name| puts \"Hi #{name}\"}\n\tsay_hi.call(\"Ganesh\")\nend",
"def talk_about(name, &myproc) #so ruby (and us) know we are adding a proc prefix it with a ambersand &\n puts \"Let me tell you about #{name}\"\n myproc.call(name) #in the body it doesnt need a ambersand & only in... | [
"0.80833423",
"0.7571391",
"0.72904086",
"0.7256792",
"0.7226314",
"0.72124434",
"0.71750456",
"0.7156844",
"0.71440876",
"0.71402323",
"0.7039937",
"0.7005401",
"0.69836795",
"0.6981435",
"0.6981435",
"0.69795644",
"0.6967455",
"0.6957681",
"0.6951043",
"0.6869943",
"0.68699... | 0.74703777 | 2 |
=> good morning hellohello good evening | def greeting(proc_1, proc_2, proc_3)
puts proc_1.call('good morning')
puts proc_2.call('hello')
puts proc_3.call('good evening')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_first_text_message\n%(Today, I want to feel:\nPassionate\nEnergized\nConnected\nHopeful\nAligned\n)\n end",
"def greet_two(name, time_of_day)\n return \"Good #{time_of_day}, #{name.capitalize()}\"\nend",
"def greet(name,time_of_day)\n return \"Good #{ time_of_day} , #{name.capitalize()}\"\n\nen... | [
"0.6689213",
"0.6616058",
"0.6548102",
"0.643706",
"0.6408939",
"0.63820946",
"0.63792586",
"0.63699687",
"0.633059",
"0.6315317",
"0.62760174",
"0.62597305",
"0.6255403",
"0.61763924",
"0.61714745",
"0.6154203",
"0.6149178",
"0.6130006",
"0.6122531",
"0.61027455",
"0.6098553... | 0.0 | -1 |
We export the ipa into this directory, as we can't specify the ipa file directly | def temporary_output_path
Gym.cache[:temporary_output_path] ||= File.join("/tmp", Time.now.to_i.to_s)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ipa_path\n File.join(BuildCommandGenerator.build_path, \"#{Gym.config[:output_name]}.ipa\")\n end",
"def ipa_generated(ipa)\n puts green(\"IPA saved to: #{ipa}\")\n end",
"def ipa_path\n generator.ipa_path\n end",
"def file_in_ipa_path(filename)\n File.join('publi... | [
"0.72539616",
"0.71605027",
"0.7024144",
"0.6642581",
"0.58272547",
"0.57150894",
"0.57014495",
"0.5695347",
"0.56537485",
"0.56367064",
"0.55056804",
"0.5467511",
"0.546177",
"0.54334706",
"0.5377167",
"0.53495544",
"0.53088343",
"0.52630615",
"0.5262867",
"0.5241337",
"0.51... | 0.0 | -1 |
The path the the dsym file for this app. Might be nil | def dsym_path
Dir[BuildCommandGenerator.archive_path + "/**/*.app.dSYM"].last
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dsym_path\n Dir[BuildCommandGenerator.archive_path + \"/**/*.dsym\"].last\n end",
"def appDataPath\n \"#{SIMULATORS_ROOT}/#{@guid}/#{DEVICE_APP_DATA_RELATIVE_PATH}\"\n end",
"def spool_dir\n return pretty_path(File.join(Dir::COMMON_APPDATA, 'RightScale', 'spool'))\n end",
... | [
"0.78393877",
"0.6743991",
"0.65449226",
"0.6473035",
"0.6418063",
"0.6271321",
"0.6203868",
"0.61562115",
"0.61520225",
"0.60973376",
"0.6084478",
"0.60774904",
"0.60660416",
"0.6042821",
"0.6037051",
"0.6012099",
"0.5985188",
"0.59814775",
"0.59771943",
"0.59719026",
"0.596... | 0.8000692 | 1 |
The path the config file we use to sign our app | def config_path
Gym.cache[:config_path] ||= "/tmp/gym_config_#{Time.now.to_i}.plist"
return Gym.cache[:config_path]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configuration_file_path; end",
"def config_file\n File.join AppRoot, ConfigFile\n end",
"def app_config_path\n Pathname.new('.').join('config')\n end",
"def config_path\n @config_path ||= local_config_path\n end",
"def config_file\n CONFIG_FILE\n end",
"def con... | [
"0.7458007",
"0.7439474",
"0.7316962",
"0.7180603",
"0.7087025",
"0.7071275",
"0.69940585",
"0.6942324",
"0.68112075",
"0.6796078",
"0.6771021",
"0.6763915",
"0.6756101",
"0.673636",
"0.664946",
"0.664946",
"0.6636701",
"0.662314",
"0.6617171",
"0.66078943",
"0.65978223",
"... | 0.70719254 | 5 |
take an input stream and convert all wikka syntax to markdown syntax | def run
migrated_body = @body.dup
migrated_body.gsub!(/\|[\t ]*\r?[\n]/, "|\n")
migrated_body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def markdownify(input); end",
"def to_md\n # Usually ruby is extremely readable, but I think \"-1\" means \"give me all the \n # trailing blank lines\" is surprisingly opaque. That's what the -1 does...\n lines = @text.split(\"\\n\", -1)\n lines.collect do |line|\n result = line\n \n ... | [
"0.7497325",
"0.7160362",
"0.69076717",
"0.68232715",
"0.67079955",
"0.6631623",
"0.6615612",
"0.6547824",
"0.6511645",
"0.6495009",
"0.64688843",
"0.64688843",
"0.6424576",
"0.6392905",
"0.63409895",
"0.63056725",
"0.62957454",
"0.6251162",
"0.624606",
"0.6244168",
"0.623842... | 0.0 | -1 |
Metodo necesario como parte del contrato de los proveedores dinamicos Aqui se define la implementacion de cada proveedor. | def call
tracking_number = args["tracking_number"]
carrier = args["carrier"]
response = {}
response[:tracking_number] = tracking_number
shipment = Shipment.validates_existence_of_shipment(tracking_number, carrier)
if shipment.nil?
begin
new_shipment = Shipment.generate_shipment(tracking_number, carrier)
event_details = call_api(tracking_number)
details = new_shipment.generate_shipment_details(event_details)
response[:details] = new_shipment.get_shipment_details
respomse[:status] = new_shipment.shipment_details.first.status
OpenStruct.new({
success?: true,
payload: response
})
rescue => ex
response[:error] = ex
new_shipment.update_errors_from_request(ex)
OpenStruct.new({
success?: false,
error: response
})
end
else
response[:details] = shipment.get_shipment_details
OpenStruct.new({
success?: true,
payload: response
})
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def puertos\n raise 'implement please!'\n end",
"def probers; end",
"def relatorios\n end",
"def pasosProximo(estrategia1,estrategia2)\n if !estrategia1.is_a?(Manual)\n estrategia1.prox()\n else\n puts \"Jugador1\"\n m=preguntaManual()\n estrateg... | [
"0.59183705",
"0.5721453",
"0.56266993",
"0.5600407",
"0.55866206",
"0.5545135",
"0.5526154",
"0.5478663",
"0.54634076",
"0.5439591",
"0.543107",
"0.5414862",
"0.5413306",
"0.5402442",
"0.5402442",
"0.5402442",
"0.5402442",
"0.5400551",
"0.53964025",
"0.53961337",
"0.5382679"... | 0.0 | -1 |
TODO this wouldn't have to be a special case if we'd match for inclusion, no equality on job.exclude | def env
env = job[:env]
env = env - (config[:env].is_a?(Hash) && config[:env][:global] || []) if env
env = env - config[:global_env] if config[:global_env].is_a?(Array)
env
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def include?(job)\n jobs.keys.include?(job.key)\n end",
"def not_qualified?\r\n job_status != JobStatus::COMPLETED and job_status != JobStatus::INCOMPLETED and job_status != JobStatus::EXCLUDED\r\n end",
"def ignored(job)\n @processed_job_ids << job.job_id\n end",
... | [
"0.6316855",
"0.62287056",
"0.59492433",
"0.56654733",
"0.56103265",
"0.54975826",
"0.5448736",
"0.5432065",
"0.5399789",
"0.5395836",
"0.53939277",
"0.53939277",
"0.5393013",
"0.53797835",
"0.53427047",
"0.5314057",
"0.5304282",
"0.529337",
"0.5270538",
"0.525517",
"0.524027... | 0.0 | -1 |
GET /pago_facturas GET /pago_facturas.json | def index
@pago_facturas = PagoFactura.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pagarFactura(factura)\n sist = Sistema.new;\n proveedor = Grupo.find_by(idGrupo: factura[0][\"proveedor\"])[\"idBanco\"]\n response = JSON.parse(sist.transferir(factura[0][\"total\"],sist.idBanco,proveedor))\n return response\n end",
"def index\n @factura = Factura.find(params[:factura_id])\n... | [
"0.69660914",
"0.6935979",
"0.6870611",
"0.6846726",
"0.68293935",
"0.6750144",
"0.67259014",
"0.66397434",
"0.65822953",
"0.6541778",
"0.6537961",
"0.64810693",
"0.64755887",
"0.64665693",
"0.6454003",
"0.6421142",
"0.64105386",
"0.64092946",
"0.63796866",
"0.63617",
"0.6357... | 0.75545937 | 0 |
GET /pago_facturas/1 GET /pago_facturas/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pago_facturas = PagoFactura.all\n end",
"def index\n @factura = Factura.find(params[:factura_id])\n @renglon_facturas = @factura.renglon_facturas\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @renglon_facturas }\n end\n end",
"de... | [
"0.72419924",
"0.6909408",
"0.681037",
"0.67712104",
"0.6706714",
"0.6674688",
"0.66695744",
"0.6666268",
"0.65496415",
"0.65409666",
"0.65409666",
"0.65409666",
"0.6539391",
"0.6491466",
"0.64836955",
"0.6469798",
"0.6461488",
"0.6448233",
"0.64477503",
"0.6446235",
"0.64460... | 0.0 | -1 |
POST /pago_facturas POST /pago_facturas.json | def create
@pago_factura = PagoFactura.new(pago_factura_params)
respond_to do |format|
if @pago_factura.save
format.html { redirect_to @pago_factura, notice: 'Pago factura creado con éxito.' }
format.json { render :show, status: :created, location: @pago_factura }
else
format.html { render :new }
format.json { render json: @pago_factura.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pago_factura_params\n params.require(:pago_factura).permit(:compra_id, :monto_pago)\n end",
"def create\n @comerciante = find_comerciante\n @factura = @comerciante.facturas.build(params[:factura])\n\n respond_to do |format|\n if @factura.save\n format.html { redirect_to @factura,... | [
"0.6804477",
"0.67397344",
"0.6738404",
"0.65898067",
"0.6541427",
"0.6521809",
"0.64485806",
"0.63712674",
"0.635598",
"0.63440657",
"0.6333674",
"0.632668",
"0.63181823",
"0.6313349",
"0.6266349",
"0.6247617",
"0.62081987",
"0.62028915",
"0.61895674",
"0.6153547",
"0.608817... | 0.7039927 | 0 |
PATCH/PUT /pago_facturas/1 PATCH/PUT /pago_facturas/1.json | def update
respond_to do |format|
if @pago_factura.update(pago_factura_params)
format.html { redirect_to compra_id_detalle_path(@pago_factura.compra_id), notice: 'Pago factura actualizado con éxito.' }
format.json { render :show, status: :ok, location: @pago_factura }
else
format.html { render :edit }
format.json { render json: @pago_factura.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end",
"def update\n respond_to do |format|\n if @pagos_servicio.update(pagos_servicio_params)\n format.html { redirect_to @pagos_servicio, notice: 'Pagos servicio was successfully updated.' }\n format.json { re... | [
"0.66145843",
"0.6563951",
"0.6524145",
"0.6505069",
"0.6499187",
"0.64919126",
"0.64885354",
"0.64725244",
"0.64622957",
"0.64461184",
"0.6426981",
"0.6392677",
"0.63908017",
"0.63525593",
"0.63500375",
"0.6346342",
"0.634531",
"0.6338909",
"0.63382226",
"0.6326851",
"0.6323... | 0.6880184 | 0 |
DELETE /pago_facturas/1 DELETE /pago_facturas/1.json | def destroy
@pago_factura.destroy
respond_to do |format|
format.html { redirect_to pago_facturas_url, notice: 'Pago factura eliminado con éxito.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end",
"def destroy\n @detalle_factura.destroy\n respond_to do |format|\n format.html { redirect_to detal... | [
"0.7419256",
"0.7327296",
"0.7289265",
"0.72488785",
"0.7204124",
"0.72031283",
"0.71657217",
"0.71657217",
"0.714424",
"0.71412754",
"0.7116565",
"0.7115115",
"0.7112921",
"0.7112293",
"0.7099874",
"0.7098617",
"0.7096491",
"0.7088505",
"0.7076987",
"0.7062486",
"0.7038172",... | 0.74504673 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_pago_factura
@pago_factura = PagoFactura.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 pago_factura_params
params.require(:pago_factura).permit(:compra_id, :monto_pago)
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.6979893",
"0.6781746",
"0.6746611",
"0.6742344",
"0.6735229",
"0.6592651",
"0.65027124",
"0.6498011",
"0.648163",
"0.647716",
"0.64556813",
"0.64386255",
"0.63784456",
"0.63756156",
"0.636574",
"0.6319542",
"0.63004524",
"0.6299559",
"0.62925464",
"0.62923217",
"0.6289894"... | 0.0 | -1 |
TODO crawl should not receive the first argument it should know if the social network is empty or if it was unmarshaled | def crawl users_to_crawl = @seed, infinity: false
user = users_to_crawl.to_a.sample
twitter_catcher_main_block do
crawl_user( user )
users_to_crawl = @sn.users_to_crawl if infinity
crawl( users_to_crawl.delete( user ) ) if users_to_crawl.size > 0
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_link; end",
"def scrape(site)\n base_url = \"#{site}/page/\"\n\n url_list = Array.new\n post_links = Array.new\n\n # Grabbing all the pages\n (1..14).each do |i|\n url_list << base_url + i.to_s\n puts \"Getting page \" + i.to_s\n end\n\n # Going through individual pages\n url_list.each do... | [
"0.5610479",
"0.55846244",
"0.5529645",
"0.55261356",
"0.54522645",
"0.5446156",
"0.5424227",
"0.5400959",
"0.54004836",
"0.54004836",
"0.5388498",
"0.5360588",
"0.53192735",
"0.53109354",
"0.53019655",
"0.52831864",
"0.5274924",
"0.526786",
"0.52519023",
"0.5248444",
"0.5240... | 0.0 | -1 |
safely load all the rake tasks in the `tasks` directory | def safe_load(file)
begin
load file
rescue LoadError => ex
puts "Error loading rake tasks from '#{file}' but will continue..."
puts ex.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_tasks\n RakeLoader.new.load_tasks\n end",
"def load_tasks(tasks)\n load File.join(File.dirname(__FILE__), 'tasks', \"#{tasks}.rb\")\nend",
"def load_tasks\n return if @loaded\n\n # By convention, the '*_helper.rb' files are helpers and need to be loaded first. Load\n # them int... | [
"0.8343681",
"0.7934116",
"0.7837977",
"0.7801473",
"0.75893486",
"0.7473606",
"0.74454516",
"0.7362616",
"0.7289403",
"0.71963334",
"0.71057606",
"0.71057606",
"0.7074584",
"0.7074584",
"0.70742667",
"0.69594216",
"0.69311",
"0.6899633",
"0.6843638",
"0.6821956",
"0.681949",... | 0.68530375 | 18 |
Use callbacks to share common setup or constraints between actions. | def set_destination
@destination = Destination.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def destination_params
params.require(:destination).permit(:name, :weather, :description, :timezone, :cityimage, :landingtime, :boardingtime)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.71213365",
"0.70527846",
"0.6947171",
"0.6901663",
"0.67342883",
"0.6717481",
"0.668679",
"0.667654",
"0.6660948",
"0.655484",
"0.6525947",
"0.64567953",
"0.64502525",
"0.6450165",
"0.6446098",
"0.6433068",
"0.64118934",
"0.64118934",
"0.63903046",
"0.6379847",
"0.6379847"... | 0.0 | -1 |
Returns a new DeadlockLogger Object | def initialize()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_logger()\n sleep $options[:log_delay]\n return $logger\nend",
"def new(context)\n dup.tap do |logger|\n logger.context = \"#{logger.context}#{context_separator}#{context}\"\n end\n end",
"def logger\n @logger ||= create_logger\n end",
"def logger\n @logger ||= creat... | [
"0.5671171",
"0.5557756",
"0.55455005",
"0.55455005",
"0.5542055",
"0.5506377",
"0.5471144",
"0.54626465",
"0.5420387",
"0.5355932",
"0.5325293",
"0.5322889",
"0.5297022",
"0.5295032",
"0.52939314",
"0.52861506",
"0.52759373",
"0.5271367",
"0.5247815",
"0.52384216",
"0.523119... | 0.0 | -1 |
GET /proposals GET /proposals.json | def index
@proposals = current_user.proposals
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @proposals = listing.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @proposals }\n end\n end",
"def index\n @proposals = current_user.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json... | [
"0.80825967",
"0.80394423",
"0.7662229",
"0.74502605",
"0.7016849",
"0.7016849",
"0.6909577",
"0.68931156",
"0.68671674",
"0.6863437",
"0.6778867",
"0.67788464",
"0.65703124",
"0.6505699",
"0.6408625",
"0.64041877",
"0.63257915",
"0.63080645",
"0.6293524",
"0.62870103",
"0.62... | 0.781896 | 2 |
GET /proposals/1 GET /proposals/1.json | def show
@proposal = Proposal.find(params[:id])
@amendments = @proposal.amendments.order(confidence: :desc)
@comments = @proposal.comments.order(confidence: :desc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @proposals = listing.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @proposals }\n end\n end",
"def index\n @proposals = current_user.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json... | [
"0.7832009",
"0.76690304",
"0.7424044",
"0.7381567",
"0.72371256",
"0.72371256",
"0.7174376",
"0.702216",
"0.7009332",
"0.6876048",
"0.6743336",
"0.6630963",
"0.658735",
"0.650641",
"0.6462005",
"0.6460089",
"0.6460089",
"0.6460089",
"0.6388582",
"0.63833135",
"0.6377948",
... | 0.6047344 | 40 |
POST /proposals POST /proposals.json | def create
@proposal = current_user.proposals.build(proposal_params)
respond_to do |format|
if @proposal.save
# publish to the feed
current_user.feed_items.publish(@proposal)
format.html { redirect_to @proposal, notice: 'Proposal was successfully created.' }
format.json { render action: 'show', status: :created, location: @proposal }
else
format.html { render action: 'new' }
format.json { render json: @proposal.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @proposal = listing.proposals.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @proposal }\n end\n end",
"def create\n @proposal = Proposal.new(params[:proposal])\n\n respond_to do |format|\n if @proposal.save\n format.html... | [
"0.6877192",
"0.68499225",
"0.6847708",
"0.67816985",
"0.6737204",
"0.6729939",
"0.67260087",
"0.67234087",
"0.664859",
"0.6648297",
"0.65541375",
"0.6548025",
"0.6474186",
"0.64545494",
"0.643011",
"0.6389518",
"0.638647",
"0.6385991",
"0.63527733",
"0.631158",
"0.6278203",
... | 0.6532908 | 12 |
Never trust parameters from the scary internet, only allow the white list through. | def proposal_params
params.require(:proposal).permit(:subject, :body)
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 |
QUIZ METHODS WELCOMING METHOD message & explanation of how to complete the quiz | def quiz_instructions
puts "This is a quiz that you can take to test out your programming knowledge and earn valuable spa points, which can be used at the Coder Detox Spa.\n\n".blue
puts "You will be presented with a statement on a number of programming concepts, in which you will have provide a response.\n
If you believe a statement is correct, please type in 'true'.\n
On the other hand, if you believe a statement to be incorrect, please type in 'false'.\n\n".blue
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quiz\n end",
"def take_quiz\n end",
"def run_quiz\n self.questions_explanation\n self.display_questions\n self.skipped_questions_explanation\n self.skipped_questions\n self.answers_explanation\n self.display_results\n self.show_score\n end",
"def questions\n \n end",
"def in... | [
"0.80758107",
"0.75796545",
"0.73062676",
"0.69071305",
"0.6872996",
"0.6742612",
"0.6623853",
"0.66161597",
"0.6539605",
"0.6539605",
"0.64990556",
"0.6496958",
"0.6492392",
"0.64309037",
"0.64273137",
"0.6411354",
"0.63992614",
"0.6377767",
"0.63647014",
"0.63635343",
"0.63... | 0.61257285 | 30 |
QUESTIONNAIRE METHOD which loops through questions array and conditionally assigns points | def questionnaire(questions)
answer = ""
score = 0
for question in questions
puts question.question
answer = gets.strip.downcase.to_s
if answer == question.answer
score += question.score
elsif answer == question.incorrect
score += 0
else
# method raises an error message if true or false input is entered
invalid_input(answer)
end
end
return score
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(questions)\n @playing_questions = questions.sample(NUMBER_OF_QUESTIONS)\n @points = 0\n @correct_answers = 0\n end",
"def add_points(points)\n @correct_answers += 1\n @points += points\n end",
"def answer_question(i, answer)\n @answers[i] = answer\n end",
"def evaluate_ans... | [
"0.64063966",
"0.6241196",
"0.6214583",
"0.62045544",
"0.60066134",
"0.5938109",
"0.59285766",
"0.58453757",
"0.5804248",
"0.5785593",
"0.5725299",
"0.56964886",
"0.56615293",
"0.56495255",
"0.5598233",
"0.5595258",
"0.55749416",
"0.55287206",
"0.55189323",
"0.54829407",
"0.5... | 0.51293075 | 86 |
CONGRATULATIONS METHOD provides the user with a final quiz score | def congratulations
arter = Artii::Base.new
puts arter.asciify("Congratulations!")
arter = Artii::Base.new
puts arter.asciify("You have earned #{$wallet.wallet} spa points.")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_score(content, quiz_id)\n @total_correct_choices = 0\n choices.each do |key, value|\n @total_correct_choices += 1 if value\n end\n\n @full_credit = full_credit(quiz_id)\n @points_per_choice = @full_credit / @total_correct_choices\n\n @correct_choices = Array.new\n @incorrect... | [
"0.72294533",
"0.70204914",
"0.6998371",
"0.6928324",
"0.6888926",
"0.6812521",
"0.6789813",
"0.6782709",
"0.67635566",
"0.67578423",
"0.67162293",
"0.67058426",
"0.6651217",
"0.66198766",
"0.65911883",
"0.65634173",
"0.65499306",
"0.6490788",
"0.6490101",
"0.64726734",
"0.64... | 0.0 | -1 |
TREATMENT METHODS DISPLAY ALL TREATMENTS METHOD cycle through all treatment to print to the screen | def display_all_treatments(treatments)
for treatment in treatments
puts treatment.name
puts "\n"
puts treatment.description
puts "\n"
puts treatment.price
puts "\n"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_individual_treatments(treatment)\n puts \"Treatment: #{treatment.name}\\n\\n\".magenta \n puts \"The Package: #{treatment.description}\\n\\n\" \n puts \"The Cost: #{treatment.price} spa points\\n\\n\\n\".green\nend",
"def print_stations_and_trains\n show_all_trains_on_stations_header\n ... | [
"0.668818",
"0.61095744",
"0.58364666",
"0.5821325",
"0.58166134",
"0.5789917",
"0.57008976",
"0.5686166",
"0.5606817",
"0.5581662",
"0.5558011",
"0.55499095",
"0.55422133",
"0.55051124",
"0.54946834",
"0.5493964",
"0.5478003",
"0.5451779",
"0.54433405",
"0.54333836",
"0.5428... | 0.6762774 | 0 |
DISPLAY INDIVIDUAL TREATMENTS METHOD user can see individual treatments for convenience | def display_individual_treatments(treatment)
puts "Treatment: #{treatment.name}\n\n".magenta
puts "The Package: #{treatment.description}\n\n"
puts "The Cost: #{treatment.price} spa points\n\n\n".green
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_all_treatments(treatments)\n for treatment in treatments\n puts treatment.name\n puts \"\\n\"\n puts treatment.description\n puts \"\\n\"\n puts treatment.price\n puts \"\\n\"\n end\nend",
"def index\n @treatments = Treatment.all\n end",
"def mode... | [
"0.67246723",
"0.6224538",
"0.6109595",
"0.60064787",
"0.5981864",
"0.58985263",
"0.5840102",
"0.5791929",
"0.5715064",
"0.5636876",
"0.5616202",
"0.5613996",
"0.5584427",
"0.5538671",
"0.55227625",
"0.55196273",
"0.5517726",
"0.5489752",
"0.54751456",
"0.5457689",
"0.5443796... | 0.7431469 | 0 |
Returns true if already submitted | def submitted?
!self.submitted_at.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def submitted\n submitted?\n end",
"def submitted?\n ! @pbsid.nil?\n end",
"def auto_submit?\n false\n end",
"def submitted?\n self.state == 'submitted'\n end",
"def submitted?\n self.status.to_i > status_enum['unsubmitted']\n end",
"def submit?\n self.type == :subm... | [
"0.78231037",
"0.76687473",
"0.7506466",
"0.74395233",
"0.73730564",
"0.7363013",
"0.7300045",
"0.7237571",
"0.71470624",
"0.71465117",
"0.71251595",
"0.70743966",
"0.7068284",
"0.70565706",
"0.70338273",
"0.6982604",
"0.6982595",
"0.69558007",
"0.694445",
"0.68668103",
"0.68... | 0.7210872 | 8 |
List extra unmanaged storage volumes | def get_paths
id = @data.delete('id')
storage_volume_attachment = get_single_resource_instance
if id
get_path_by_id(storage_volume_attachment, id)
else
get_all_paths(storage_volume_attachment)
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def related_storage_volumes\n related_volumes.find_all do |volume|\n volume.provider_name == \"compellent\" || volume.provider_name == \"vnx\"\n end\n end",
"def extra_volumes(base_name)\n configs = []\n\n config[:extra_volumes].each_with_index do |data, index|\n ... | [
"0.69722456",
"0.6878082",
"0.68696415",
"0.67775047",
"0.67177224",
"0.65825933",
"0.6562121",
"0.65573746",
"0.65536505",
"0.6421424",
"0.64054435",
"0.6343411",
"0.62194544",
"0.6195",
"0.6191322",
"0.6186459",
"0.61637187",
"0.6153291",
"0.6148977",
"0.61165684",
"0.61002... | 0.0 | -1 |
Saves model to default store. | def save!
set_default_id_if_needed
raise StoreError, 'No store provided' unless self.store
error_ptr = Pointer.new(:id)
self.store.addObject(self, error: error_ptr)
raise StoreError, error_ptr[0].description if error_ptr[0]
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n @model = register_model\n end",
"def store(model)\n model\n end",
"def save\n super save\n end",
"def store\n Model.model_store.store(self)\n end",
"def save\n SAVE\n end",
"def save\n self.class.save(self)\n end",
"def persist_model(model)\n ... | [
"0.7684653",
"0.71442544",
"0.68185455",
"0.6763839",
"0.66192514",
"0.6611376",
"0.6585452",
"0.6578684",
"0.6578684",
"0.65727353",
"0.65370196",
"0.6531895",
"0.6508213",
"0.6497009",
"0.6459409",
"0.6406624",
"0.63715243",
"0.63715243",
"0.63618517",
"0.6320275",
"0.63005... | 0.6083767 | 46 |
Removed model from default store. | def delete
raise StoreError, 'No store provided' unless self.store
error_ptr = Pointer.new(:id)
self.store.removeObject(self, error: error_ptr)
raise StoreError, error_ptr[0].description if error_ptr[0]
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete!\n Model.model_store.delete!(self)\n end",
"def delete\n self.store -= self\n end",
"def delete(model)\n redis.srem(key, model.id)\n end",
"def clear_model\n class_eval do\n # Remove event models\n events.each_key do ... | [
"0.74596405",
"0.7009552",
"0.68631405",
"0.68436307",
"0.68395793",
"0.67459905",
"0.6743315",
"0.6681964",
"0.6649764",
"0.66445667",
"0.65384066",
"0.6493607",
"0.64932245",
"0.6480644",
"0.6474004",
"0.6470457",
"0.63296294",
"0.6260798",
"0.623792",
"0.6221849",
"0.62064... | 0.5799119 | 53 |
Assigns attributes to model | def assign_attributes(new_attributes, options = {})
attributes = new_attributes.symbolize_keys
attributes.each do |k, v|
if has_attribute?(k)
assign_attribute(k, v) unless options[:skip_nil_values] && v.nil?
elsif options[:validate_attribute_presence]
raise(StoreError, "unknown attribute: '#{k}'")
else
Prime.logger.info("unknown attribute: #{k}")
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assign_attributes(model_instance, attributes)\n attributes.each_pair do |k, v|\n model_instance.send(:\"#{k}=\", v)\n end\n end",
"def assign_attributes\n @data.each do |attribute, value|\n self.class.send(:attr_accessor, attribute)\n set(attribute, value)\n ... | [
"0.775927",
"0.7530254",
"0.7374184",
"0.7343407",
"0.72818905",
"0.7250346",
"0.71429455",
"0.7073919",
"0.7064338",
"0.70605725",
"0.69658774",
"0.6951104",
"0.6879872",
"0.68782616",
"0.68214196",
"0.6754934",
"0.67373",
"0.6719831",
"0.6719548",
"0.67111486",
"0.6708012",... | 0.0 | -1 |
Assigns attribute to model | def assign_attribute(name, value)
self.send("#{name}=", value) if has_attribute?(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_attribute(name, value); end",
"def set_attribute\n @attribute = Attribute.find(params[:id])\n end",
"def set_attribute\n @attribute = Attribute.find(params[:id])\n end",
"def set_attr\n @attr = Attr.find(params[:id])\n end",
"def set_attr\n @attr = Attr.find(params[:id]... | [
"0.73588794",
"0.7231239",
"0.7231239",
"0.72247624",
"0.72247624",
"0.6772272",
"0.6750584",
"0.673816",
"0.6736387",
"0.66890985",
"0.66733265",
"0.6607619",
"0.65952885",
"0.6566874",
"0.6566342",
"0.6550723",
"0.65413713",
"0.6521306",
"0.65044206",
"0.64667463",
"0.64412... | 0.71605456 | 5 |
Check if model has attribute | def has_attribute?(name)
respond_to?("#{name}=")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attributes_exist?\n\tend",
"def is_attribute?; end",
"def has_attribute?(name)\n attributes.has_key?(name)\n end",
"def has_attribute?(attr_name)\n self.attribute_names.include?(attr_name.to_s)\n end",
"def attribute?\n false\n end",
"def has_attribute?(attr_... | [
"0.75875914",
"0.74840134",
"0.74539644",
"0.7448694",
"0.74453336",
"0.7301194",
"0.7285148",
"0.7257613",
"0.72529125",
"0.72430605",
"0.7220222",
"0.7219837",
"0.71822405",
"0.7168407",
"0.71391493",
"0.7138088",
"0.7121353",
"0.71182483",
"0.7087804",
"0.70860624",
"0.706... | 0.71231353 | 16 |
Hash of all attributes in model | def attributes_hash
self.info.to_hash.symbolize_keys
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n attributes.hash\n end",
"def hash\n attributes.hash\n end",
"def hash\n attributes.hash\n end",
"def hash\n @attrs\n end",
"def to_hash\n attributes\n end",
"def to_hash\n self.class.attributes.inject({}) { |memo, name| memo[name] = send(name); me... | [
"0.8078835",
"0.8078835",
"0.8078835",
"0.80437744",
"0.78588295",
"0.78018254",
"0.7730433",
"0.7678819",
"0.7671828",
"0.76687264",
"0.76428777",
"0.76385146",
"0.7616341",
"0.7544518",
"0.754315",
"0.7504995",
"0.7440046",
"0.7422381",
"0.7399228",
"0.7369401",
"0.7351616"... | 0.7980135 | 4 |
Checks if model has been saved in server (have an ID) | def new_record?
id.blank?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n create_or_update\n _id.present?\n end",
"def saved_already?\n @id != \"\" && @id != nil\n end",
"def saved?\n user_id?\n end",
"def persisted?\n self[:id].present?\n end",
"def persisted?\n !self.id.nil?\n end",
"def persisted?\n !id.nil?\n end",
... | [
"0.72308534",
"0.713812",
"0.68220335",
"0.68206894",
"0.6769777",
"0.6756724",
"0.6727428",
"0.67009145",
"0.66761893",
"0.6664368",
"0.6647522",
"0.6644008",
"0.6644008",
"0.6635763",
"0.663562",
"0.6611482",
"0.65995663",
"0.65995663",
"0.65961486",
"0.6595359",
"0.6569417... | 0.6293662 | 41 |
Checks if model has been saved in server (have an ID) | def persisted?
!new_record?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n create_or_update\n _id.present?\n end",
"def saved_already?\n @id != \"\" && @id != nil\n end",
"def saved?\n user_id?\n end",
"def persisted?\n self[:id].present?\n end",
"def persisted?\n !self.id.nil?\n end",
"def persisted?\n !id.nil?\n end",
... | [
"0.72301286",
"0.7138514",
"0.6822019",
"0.682162",
"0.6770049",
"0.67571336",
"0.6728179",
"0.6701839",
"0.6676759",
"0.66648984",
"0.6648084",
"0.66445273",
"0.66445273",
"0.6636521",
"0.66359574",
"0.6611707",
"0.66001225",
"0.66001225",
"0.6596371",
"0.65956676",
"0.65696... | 0.0 | -1 |
Returns jsonformatted representation of model | def inspect
inspection = self.info.keys.map { |name|
"#{name}: #{attribute_for_inspect(name)}"
}.compact.join(", ")
"#<#{self.class}:0x#{self.object_id.to_s(16)} #{inspection}>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json\n\t\t\t{name: @name, ar_model: @ar_model.to_json, api_model: @api_model.to_json}\n\t\tend",
"def tojson\n\t\tend",
"def to_json\n\t\tto_h.to_json\n\tend",
"def to_json\n\t\tto_h.to_json\n\tend",
"def to_json\n Formatter::JSON.render(self)\n end",
"def to_json\n\n end",
"def to_... | [
"0.7654271",
"0.74397415",
"0.7370916",
"0.7370916",
"0.7337054",
"0.7289133",
"0.7287622",
"0.7286519",
"0.726516",
"0.7206139",
"0.7206139",
"0.71823335",
"0.71683717",
"0.71630627",
"0.71607935",
"0.71607935",
"0.7157279",
"0.7110966",
"0.71072876",
"0.7105634",
"0.7093919... | 0.0 | -1 |
Returns a clone of the record with empty bags | def clone
self.class.new(self.info.select { |key, value| !key.to_s.ends_with?('_bag') })
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone\n bag_clone = Bag.new\n bag_clone.copy_all(self)\n bag_clone\n end",
"def clone\n self.class.new(@attributes.except(:_id).except(:versions).dup)\n end",
"def unfiltered\n clone(:where => nil, :having => nil)\n end",
"def deep_clone\n b = dup\n b.generat... | [
"0.677227",
"0.6689173",
"0.6518058",
"0.6294976",
"0.62757707",
"0.62745816",
"0.62411594",
"0.623848",
"0.6236213",
"0.61675495",
"0.60939336",
"0.60668576",
"0.6045493",
"0.6045493",
"0.6045493",
"0.6045493",
"0.6045493",
"0.60451084",
"0.6038311",
"0.6029547",
"0.6021445"... | 0.69944423 | 0 |
Initialize a new object and save it to store | def create(data = {})
object = self.new(data)
object.save
object
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n save\n end",
"def initialize \n save\n end",
"def initialize (name)\n @name = name\n save\n end",
"def initialize (name)\n @name = name\n save\n end",
"def initialize\n self.save\n end",
"def initialize(name)\n @name = name\n save\n end",
"def ... | [
"0.7786351",
"0.7722547",
"0.7096504",
"0.70195323",
"0.70174253",
"0.675946",
"0.675946",
"0.65337527",
"0.6530387",
"0.65188825",
"0.6500858",
"0.6422799",
"0.6421949",
"0.64210224",
"0.63955474",
"0.635074",
"0.6350221",
"0.63473684",
"0.6329888",
"0.63104224",
"0.6301301"... | 0.63448775 | 18 |
Set and/or return all model attribute names | def attributes(*attrs)
if attrs.size > 0
attrs.each{|attr| attribute attr}
end
@attributes ||= []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attribute_names\n @attribute_names ||= attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"def attribute_names\n @attributes.keys\n end",
"d... | [
"0.7620675",
"0.755514",
"0.755514",
"0.755514",
"0.755514",
"0.7551499",
"0.75037223",
"0.7459977",
"0.74022144",
"0.735922",
"0.735746",
"0.7272255",
"0.72618103",
"0.72334903",
"0.7195484",
"0.71725893",
"0.7114874",
"0.70959437",
"0.7041049",
"0.70405334",
"0.70342237",
... | 0.0 | -1 |
Return store associated with model class, or shared store by default | def store
@store ||= MotionPrime::Store.shared_store
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store\n return self.class.store\n end",
"def store\n @store ||= Store.first || Store.create\n end",
"def store\n @store ||= Store.find(options[:store]).new(options[:source])\n end",
"def store\n @store ||= storage.new self\n end",
"def fetch_store\n @store ||= self.... | [
"0.75368685",
"0.7534609",
"0.7432702",
"0.7331187",
"0.7290844",
"0.72685426",
"0.7168007",
"0.716793",
"0.7167806",
"0.70364493",
"0.6950365",
"0.6916861",
"0.690811",
"0.6897423",
"0.66585416",
"0.6644751",
"0.6638528",
"0.66294944",
"0.66122156",
"0.65772974",
"0.65772974... | 0.6456551 | 26 |
Define store associated with model class | def store=(store)
@store = store
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store(model)\n model\n end",
"def store\n Model.model_store.store(self)\n end",
"def store\n self.class.store\n end",
"def store\n @store ||= Store.find(options[:store]).new(options[:source])\n end",
"def store\n @store ||= Store.new\n end",
"def store\n ... | [
"0.77696735",
"0.7718228",
"0.7472937",
"0.7316477",
"0.72785",
"0.72006434",
"0.716806",
"0.7098929",
"0.7098929",
"0.70113003",
"0.6946535",
"0.6923904",
"0.6841868",
"0.67573375",
"0.6756738",
"0.67465395",
"0.67172664",
"0.670574",
"0.6697059",
"0.6695865",
"0.6695659",
... | 0.6960078 | 10 |
Delete objects from store by given options | def delete(*args)
if args.blank?
raise "Using delete with no args is not allowed. Please use delete_all to delete all records"
end
keys = find_keys(*args)
self.store.delete_keys(keys)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aws_obj_delete(opts)\n opts[:obj].delete\n end",
"def delete options\n rest_request({ method: :delete }.merge(options))\n end",
"def delete options\n rest_request({ method: :delete }.merge(options))\n end",
"def delete options\n table = DB.from(@table)\n \n if options[:wh... | [
"0.67783695",
"0.6699044",
"0.6699044",
"0.66406643",
"0.65813607",
"0.6561518",
"0.6491528",
"0.643568",
"0.6397812",
"0.63711834",
"0.63190323",
"0.63167536",
"0.6290556",
"0.62750125",
"0.6274081",
"0.62637633",
"0.62468356",
"0.6242647",
"0.6214846",
"0.6175255",
"0.61675... | 0.67203057 | 1 |
Delete all objects with this Prime::Model | def delete_all
self.store.delete_keys(find_keys)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_all\n self.destroy\n end",
"def delete_all\n @objects.each do |o|\n o.delete \n end\n\n @objects.clear\n end",
"def destroy_all\n all.each do |n|\n n.destroy\n end\n end",
"def destroy_all\n all.each(&:destroy)\n end",
"d... | [
"0.77905285",
"0.77706325",
"0.7583361",
"0.7557678",
"0.741073",
"0.74060714",
"0.73301196",
"0.7195133",
"0.7180087",
"0.7178269",
"0.71052384",
"0.7083185",
"0.706741",
"0.7041447",
"0.70058584",
"0.6954549",
"0.68916327",
"0.6823717",
"0.67655706",
"0.67644864",
"0.675413... | 0.70148456 | 14 |
Methods that act as queries are often named with a trailing ? | def who_am_i?
"#{self.class.name} (\##{self.object_id}): #{self.to_s}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query; end",
"def _query(*params)\n fail 'not implemented'\n end",
"def query\n end",
"def find(query); end",
"def find(query); end",
"def query(_tql)\n raise NotImplementedError.new\n end",
"def connection_execute_method\n :query\n end",
"def connection_execute_metho... | [
"0.73617905",
"0.724704",
"0.7100923",
"0.68337363",
"0.68337363",
"0.6776709",
"0.6536056",
"0.6536056",
"0.6436341",
"0.640449",
"0.6394539",
"0.6391443",
"0.63854766",
"0.63502645",
"0.6347747",
"0.63252324",
"0.62990505",
"0.62842816",
"0.6281567",
"0.6277283",
"0.6271238... | 0.0 | -1 |
exports scholarships by corridor and month | def export_scholarship(specialization)
beg = Date.parse(TermsCalculator.starting_in(2008)) - 1.month
fin = beg + 1.month
sql = 'payed_on > ? and payed_on < ? and index_id = ?'
indices = Index.find_for_scholarship(User.find_by_login('ticha'),
:conditions => ["specialization_id = ?", specialization],
:paying_date => fin)
unless indices.empty?
(1..13).each do |month|
filename = '%s_%s.csv' % [specialization.code, fin.strftime('%m_%y')]
File.open(filename, 'wb') do |outfile|
CSV::Writer.generate(outfile, ';') do |csv|
csv << [specialization.name, beg.strftime('%Y-%m-%d'),
fin.strftime('%Y-%m-%d'), '', '']
csv << ['name', 'type', 'amount', 'disponent', 'payed_on']
indices.each do |index|
if scholarships = Scholarship.find(:all, :conditions =>
[sql, beg, fin, index.id])
scholarships.each do |scholarship|
csv << [scholarship.index.student.display_name,
scholarship.type.to_s[0, 1], scholarship.amount, scholarship.disponent,
scholarship.payed_on.strftime('%Y-%m-%d')]
end
end
end
end
end
@@mylog.debug 'Exported' + filename
system 'iconv -f utf-8 -t cp1250 %s > %s' % [filename, filename.gsub(/\.csv/, '.win.csv')]
system 'rm %s' % filename
beg += 1.month
fin = beg + 1.month
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @periods = Period.all\n @all_scholarships = Array.new\n @periods.each do |p|\n @all_scholarships << {\"sesiune\" => p, \"burse\" => Domain.where(:period_id => p.id)}\n end\n end",
"def index\n @scholarship_periods = ScholarshipPeriod.all\n end",
"def index\n @scholars = Sch... | [
"0.6281573",
"0.57002705",
"0.5676201",
"0.5676201",
"0.5626547",
"0.55759233",
"0.5543213",
"0.55223846",
"0.5479509",
"0.5384267",
"0.5381568",
"0.53511274",
"0.53243065",
"0.5286813",
"0.5270035",
"0.52560365",
"0.52355736",
"0.52291596",
"0.5219036",
"0.52025414",
"0.5189... | 0.7177134 | 0 |
exports all students for vice dean | def students_for_dean(dean_user)
indices = Index.find_for(dean_user)
@@mylog.info("There is %i students" % indices.size)
File.open("students.csv", 'wb') do |outfile|
CSV::Writer.generate(outfile, ';') do |csv|
csv << ['uic', 'name', 'enrolled', 'finished/absolved', 'form', 'status',
'department', 'specialization', 'program', 'faculty', 'tutor',
'title', 'title_en', 'nominal_length']
indices.each do |index|
row = []
@@mylog.info("Adding %s" % index.student.display_name)
row << index.student.uic
row << index.student.display_name
row << index.enrolled_on.strftime('%d. %m. %Y')
if index.finished?
row << index.finished_on.strftime('%d. %m. %Y')
elsif index.absolved?
row << index.disert_theme.defense_passed_on.strftime('%d. %m. %Y')
else
row << ''
end
row << index.study.name
row << index.status
row << index.department.name
row << index.specialization.name
row << index.specialization.program.name
row << index.faculty.name
row << index.tutor.try(:display_name)
row << index.disert_theme.try(:title)
row << index.disert_theme.try(:title_en)
row << index.nominal_length
csv << row
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export_students_to_csv\n CSV.generate(headers: true) do |csv|\n csv << %w[perm email first_name last_name github_username]\n\n roster_students.each do |user|\n csv << [\n user.perm,\n user.email,\n user.first_name,\n user.last_name,\n user.userna... | [
"0.6672098",
"0.65983397",
"0.6375877",
"0.6330671",
"0.6229459",
"0.61906475",
"0.6182686",
"0.6180917",
"0.61158144",
"0.60740197",
"0.60740197",
"0.6046566",
"0.6043871",
"0.60400045",
"0.6038907",
"0.6038907",
"0.6038907",
"0.6038907",
"0.6038907",
"0.6038907",
"0.6038907... | 0.69877017 | 0 |
exports all students for vice dean with attributes for accreditation committee | def students_for_accreditation_committee(dean_user)
indices = Index.find_for(dean_user)
@@mylog.info("There is %i students" % indices.size)
File.open("students.csv", 'wb') do |outfile|
CSV::Writer.generate(outfile, ';') do |csv|
indices.each do |index|
row = []
row << index.student.display_name
row << index.status
if index.status == 'absolvoval'
row << index.disert_theme.defense_passed_on
else
row << ''
end
row << index.year
row << index.study_name
row << index.department.short_name
row << index.specialization.code
row << index.enrolled_on
row << index.final_exam_passed_on || index.study_plan.try(:status) || "nemá"
row << index.disert_theme.try(:title)
row << index.tutor.try(:display_name)
csv << row
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def students_for_dean(dean_user)\n indices = Index.find_for(dean_user)\n @@mylog.info(\"There is %i students\" % indices.size)\n File.open(\"students.csv\", 'wb') do |outfile|\n CSV::Writer.generate(outfile, ';') do |csv|\n csv << ['uic', 'name', 'enrolled', 'finished/absolved', 'for... | [
"0.6808192",
"0.6697971",
"0.6405123",
"0.63243943",
"0.6109139",
"0.59973806",
"0.5932005",
"0.59310627",
"0.5930966",
"0.59273964",
"0.5889517",
"0.5844081",
"0.58404416",
"0.58255124",
"0.58189535",
"0.5807222",
"0.5781946",
"0.57797724",
"0.57520264",
"0.5739381",
"0.5736... | 0.76252365 | 0 |
exports absolved students by faculties with study times | def absolved_students_with_years
is = Index.find_for(User.find_by_login('ticha'))
is = is.select {|i| i.absolved?}.sort {|i, j| i.semester <=> j.semester}
isd = is.group_by(&:faculty)
isd.each do |faculty|
File.open("absolved_%s.csv" % faculty.first.short_name, 'wb') do |outfile|
CSV::Writer.generate(outfile, ';') do |csv|
csv << ['student', 'semestr', 'start', 'konec']
faculty.last.each do |index|
csv << [index.student.display_name, index.semester, index.enrolled_on.to_date, index.disert_theme.defense_passed_on.to_date]
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def absolved_students_with_address\n is = Index.find_for(User.find_by_login('ticha'))\n is = is.select {|i| i.absolved?}.sort {|i, j| i.semester <=> j.semester}\n File.open('absolved_with_address.csv', 'wb') do |outfile|\n CSV::Writer.generate(outfile, ';') do |csv|\n csv << ['absolv... | [
"0.62791884",
"0.6191345",
"0.6106719",
"0.6030006",
"0.58804315",
"0.5822681",
"0.57852775",
"0.5747222",
"0.5710029",
"0.5637771",
"0.5620763",
"0.56159085",
"0.55870295",
"0.5549148",
"0.552014",
"0.54956466",
"0.5489787",
"0.5488165",
"0.5465577",
"0.5453042",
"0.5436722"... | 0.7494946 | 0 |
exports absolved students by faculties with study times | def absolved_students_with_address
is = Index.find_for(User.find_by_login('ticha'))
is = is.select {|i| i.absolved?}.sort {|i, j| i.semester <=> j.semester}
File.open('absolved_with_address.csv', 'wb') do |outfile|
CSV::Writer.generate(outfile, ';') do |csv|
csv << ['absolvoval', 'titul pred', 'jmeno', 'prijmeni', 'titul za', 'ulice', 'mesto', 'psc']
is.each do |index|
s = index.student
if a = s.address and a.street
csv << [index.disert_theme.defense_passed_on.to_date,
s.title_before ? s.title_before.label : 'Ing.', s.firstname, s.lastname,
s.title_after ? s.title_after.label : '', a.street + " " + (a.desc_number or a.orient_number or ''), a.city, a.zip]
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def absolved_students_with_years\n is = Index.find_for(User.find_by_login('ticha'))\n is = is.select {|i| i.absolved?}.sort {|i, j| i.semester <=> j.semester}\n isd = is.group_by(&:faculty)\n isd.each do |faculty|\n File.open(\"absolved_%s.csv\" % faculty.first.short_name, 'wb') do |outf... | [
"0.7494946",
"0.6191345",
"0.6106719",
"0.6030006",
"0.58804315",
"0.5822681",
"0.57852775",
"0.5747222",
"0.5710029",
"0.5637771",
"0.5620763",
"0.56159085",
"0.55870295",
"0.5549148",
"0.552014",
"0.54956466",
"0.5489787",
"0.5488165",
"0.5465577",
"0.5453042",
"0.5436722",... | 0.62791884 | 1 |
filter VCF based on: 1.DP4 >= 2,2 2. PV4>= 0.001 for het 3. CLR>20 for somatic default values | def main
settings = {}
settings["--dp4"]=2
settings["--pv41"]=0.0001
settings["--pv42"]=0.0001
settings["--pv43"]=0.0001
settings["--pv44"]=0.0001
settings["--clr"]=20
settings["--normal"]=1
optHash = getopt()
vcf = optHash["--vcf"]
settings.keys.sort.each do |s|
if optHash.key?(s)
settings[s] = optHash[s].to_f
end
end
nsample=countSamples(vcf)
filterVCF(vcf,settings,nsample) # gt: gene -> pos -> sample -> genotype,
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main \n settings = {}\n settings[\"--dp4\"]=2\n settings[\"--pv41\"]=0\n settings[\"--pv42\"]=0\n settings[\"--pv43\"]=0\n settings[\"--pv44\"]=0\n settings[\"--clr\"]=20\n settings[\"--normal\"]=0 ## default: tumor is first, normal is second. \n settings[\"--minPL\"] = 40\n optHash = getopt()\n vc... | [
"0.5911208",
"0.5705137",
"0.5671287",
"0.560436",
"0.5573411",
"0.55699027",
"0.5542602",
"0.5492488",
"0.5408436",
"0.5389244",
"0.53873986",
"0.53873986",
"0.53602076",
"0.5330991",
"0.5330991",
"0.5330064",
"0.52966315",
"0.52966315",
"0.52865446",
"0.52821636",
"0.526368... | 0.5855923 | 1 |
Setup the application group. Currently this functions calls find_applications which finds all running instances of the application and populates the application array. | def setup
@applications = find_applications(pidfile_dir)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_applications\n application_names = (settings['applications'] || '').split(',').flatten.compact.map(&:strip).uniq\n self.applications = []\n application_names.each do |app_name|\n app = Application.find(:name => app_name, :host_id => host.id)\n if app\n self.appl... | [
"0.6948352",
"0.6840615",
"0.6815588",
"0.6704251",
"0.6158384",
"0.5962447",
"0.5888414",
"0.5888414",
"0.5861186",
"0.5830363",
"0.57999927",
"0.57898873",
"0.572233",
"0.5721211",
"0.57020354",
"0.5683251",
"0.56717837",
"0.5667647",
"0.56667584",
"0.56642854",
"0.56642854... | 0.6804726 | 3 |
TODO: identifiy the monitor process | def find_applications_by_app_name(app_name)
pids = []
begin
x = `ps auxw | grep -v grep | awk '{print $2, $11, $12}' | grep #{app_name}`
if x && x.chomp!
processes = x.split(/\n/).compact
processes = processes.delete_if do |p|
_pid, name, add = p.split(/\s/)
# We want to make sure that the first part of the process name matches
# so that app_name matches app_name_22
app_name != name[0..(app_name.length - 1)] and not add.include?(app_name)
end
pids = processes.map { |p| p.split(/\s/)[0].to_i }
end
rescue ::Exception
end
pids.map do |f|
app = Application.new(self, {}, PidMem.existing(f))
setup_app(app)
app
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def monitor; end",
"def monitor\n raise NotImplementedError\n end",
"def report_pid\n @process[:report_pid]\n end",
"def start_monitor\n self.monitor = monitor_thread if not self.monitor\n end",
"def report_pid\n @process[:report_pid]\n end",
"def watch_process(cmd = nil, &block)\... | [
"0.7532336",
"0.6639605",
"0.645212",
"0.6413061",
"0.6402413",
"0.63236374",
"0.62789553",
"0.62777704",
"0.6206816",
"0.6206816",
"0.6206816",
"0.6202644",
"0.6200459",
"0.6185442",
"0.6175318",
"0.6175318",
"0.6175318",
"0.6166578",
"0.61261433",
"0.6108339",
"0.61005455",... | 0.0 | -1 |
Check whether at least one of the applications in the group is running. If yes, return true. | def running?
@applications.each { |a| return true if a.running? }
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def running?\n result = true\n SERVICES.each do |_, check|\n result &&= check.call\n end\n result\n end",
"def running?\n\t\t\t\t@group.running?\n\t\t\tend",
"def running?\n !running.empty?\n end",
"def running?\n return false if pid == 0\n begin\n P... | [
"0.72282356",
"0.7197891",
"0.68865025",
"0.6850907",
"0.681305",
"0.66826457",
"0.66230994",
"0.6584578",
"0.6568788",
"0.655725",
"0.65474695",
"0.6518934",
"0.6516063",
"0.6516063",
"0.6516063",
"0.6516022",
"0.64799404",
"0.6478157",
"0.6459899",
"0.64137584",
"0.63835",
... | 0.81304497 | 0 |
return checkbox values for slots (if any) | def slots
if !@slot_checkboxes.empty?
@slot_checkboxes.keys.map do |k|
k if Native(@slot_checkboxes[k]).elm.checked
end.compact
elsif @slot_dropdown
[Native(@slot_dropdown).elm.value]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_checked_items\n find_all { | i | checked?(i) } \n end",
"def box_set_results_for(set_of_boxes)\n set_of_boxes.map { |box| is_there_a_check_on(box) }\nend",
"def pistaa_slot_items(slot)\n Pistaa[slot].item_keys\n end",
"def radio_check(table)\n table.radios.each{|x| if x.checked? then ... | [
"0.6082036",
"0.5852395",
"0.5816626",
"0.57595074",
"0.5710174",
"0.56419915",
"0.5611058",
"0.550393",
"0.5497064",
"0.54722506",
"0.5400631",
"0.5372294",
"0.53603",
"0.53561664",
"0.53354496",
"0.5287385",
"0.5260055",
"0.51784986",
"0.51759213",
"0.51643187",
"0.51585835... | 0.8039226 | 0 |
need to abstract due to corporations owning minors owning trains | def other_owner(other)
@step.respond_to?(:real_owner) ? @step.real_owner(other) : other.owner
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def masteries; end",
"def train_owner(train)\n (@supertrains[train] || train)&.owner\n end",
"def buyable_private_mines(entity)\n if entity == @hw\n @minors.select { |m| (!m.owner || @players.include?(m.owner)) && @minor_info[m][:vor_harzer] }\n else\n @m... | [
"0.61559683",
"0.60781944",
"0.607534",
"0.59090567",
"0.5850945",
"0.585076",
"0.5773139",
"0.5678428",
"0.55983317",
"0.5562023",
"0.5510401",
"0.55028605",
"0.5332897",
"0.5298564",
"0.52741903",
"0.52539414",
"0.5222764",
"0.52137095",
"0.52099067",
"0.51893836",
"0.51784... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.