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 |
|---|---|---|---|---|---|---|
Escapes the string for inclusion in LaTeX files | def texescape(input)
input.gsub("#", "\\#")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def escape_latex string\n string.to_s.gsub(/[$\\\\{}_%#&~^\"]/) do |s|\n case s\n when '$'\n '\\$'\n when '\\\\'\n '\\synbs{}'\n when /[{}_%#&]/\n \"\\\\#{s}\"\n when /[~^]/\n \"\\\\#{s}{}\"\n when '\"'\n '\"{}'\n en... | [
"0.80147415",
"0.756782",
"0.7525451",
"0.7431314",
"0.7379028",
"0.73329026",
"0.72416204",
"0.72095263",
"0.71341795",
"0.7066923",
"0.7051678",
"0.70347625",
"0.7000537",
"0.6954449",
"0.688744",
"0.68768126",
"0.68768126",
"0.68768126",
"0.68768126",
"0.68768126",
"0.6876... | 0.68207836 | 56 |
Send a get request to the specified path. | def get(path)
req = Net::HTTP::Get.new(@base_url + path)
response = handle_request(req)
response.each {|k,v| puts "#{k}: #{v}"}
response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(path)\n request 'GET', path\n end",
"def get(path)\n request(:get, path, {})\n end",
"def get(path, options={})\n send_request 'get', path, options\n end",
"def get(path, params={})\n request(:get, path, params)\n end",
"def get(path, params={})\n request(:get, ... | [
"0.89210117",
"0.8714577",
"0.85441655",
"0.8219973",
"0.8219973",
"0.8219973",
"0.8219973",
"0.8219973",
"0.8219973",
"0.8219973",
"0.8219973",
"0.8219973",
"0.8219973",
"0.821809",
"0.8212274",
"0.8183756",
"0.8177972",
"0.8177972",
"0.8161371",
"0.8161371",
"0.80467427",
... | 0.81155074 | 20 |
Send the request to the server. If the response is unauthorized, an attempt to log in using http digest authentication is made. | def handle_request(request)
add_cookies!(request)
authenticate_request!(request)
response = @client.request(request)
set_cookies(response)
case response
when Net::HTTPUnauthorized
response = respond_to_challenge(request, response)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_login\n qop = ''\n case @qop\n when QOP_AUTH\n qop = 'auth'\n when QOP_AUTHINT\n qop = 'auth-int'\n when QOP_AUTH | QOP_AUTHINT\n qop = 'auth,auth-int'\n end\n\n @response.add_header('WWW-Authenticate', \"Di... | [
"0.68780607",
"0.6685646",
"0.66310793",
"0.6569068",
"0.64974284",
"0.6442476",
"0.6410493",
"0.64049894",
"0.64043194",
"0.6377079",
"0.63754964",
"0.63754964",
"0.6346481",
"0.63259995",
"0.62954664",
"0.6285119",
"0.6255445",
"0.6224594",
"0.61926794",
"0.61812997",
"0.61... | 0.6196134 | 18 |
Adds authentication information to the request based on the challenge from the response. | def respond_to_challenge(request, response)
authenticate_header = response['www-authenticate'].downcase
authenticate_header.sub!(/^digest /, '')
@authentication_params = authenticate_header.split(", ").inject({}) { |h, field|
key, value = field.split("=")
h[key] = value.gsub(/^"|"$/, '') # strip quotes.
h
}
add_cookies!(request)
authenticate_request!(request)
request.each{|k,v| puts "#{k}: #{v}" }
# Resend the request
@client.request(request)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def challenge(request, response)\n auth = Http::Auth::Bearer.new(\n @realm,\n request,\n response\n )\n auth.require_login\n end",
"def challenge(req, res)\n res[@response_field] = \"#{@auth_scheme} realm=\\\"#{@realm}\\\"\"\... | [
"0.73826385",
"0.6834293",
"0.6728466",
"0.6561607",
"0.65466154",
"0.6543275",
"0.6372046",
"0.63232297",
"0.62966216",
"0.6267182",
"0.62235886",
"0.6153276",
"0.6144353",
"0.6096307",
"0.6031068",
"0.6009908",
"0.59887373",
"0.59194124",
"0.5912835",
"0.58936375",
"0.58906... | 0.7717408 | 0 |
Does the legwork for HTTP Digest authentication (See | def authenticate_request!(request)
return if @authentication_params.empty?
puts "AUTHENTICATION PARAMS: #{@authentication_params.inspect}"
@nonce_count += 1
cnonce = Digest::MD5.hexdigest(Time.now.to_s + rand(65535).to_s)
a1 = "#{@http_login}:#{@authentication_params['realm']}:#{@password}"
a2 = "#{request.method}:#{request.path}"
response_digest = Digest::MD5.hexdigest(a1) << ':' <<
@authentication_params['nonce'] << ':' <<
('%08x' % @nonce_count) << ':' <<
cnonce << ':' <<
@authentication_params['qop'] << ':' <<
Digest::MD5.hexdigest(a2)
request['Authorization'] = "Digest username=\"#{@http_login}\", " <<
"realm=\"#{@authentication_params['realm']}\", " <<
"nonce=\"#{@authentication_params['nonce']}\", " <<
"uri=\"#{request.path}\", " <<
"nc=#{'%08x' % @nonce_count}, " <<
"qop=\"#{@authentication_params['qop']}\", " <<
"cnonce=\"#{cnonce}\", " <<
"response=\"#{Digest::MD5.hexdigest(response_digest)}\""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def digest_authenticate(req, url, param_string = \"\")\n raise \"Digest authentication requires a WWW-Authenticate header\" if param_string.empty?\n\n params = parse_wwwauth_digest(param_string)\n qop = params[:qop]\n\n user, pass = username_and_password_for_realm(url, params[:realm])\n\n ... | [
"0.8140084",
"0.80309665",
"0.8004133",
"0.79016984",
"0.7622488",
"0.7224383",
"0.7205974",
"0.71702135",
"0.7162832",
"0.6940238",
"0.68650156",
"0.67974234",
"0.67677224",
"0.6741412",
"0.6683184",
"0.666057",
"0.66482586",
"0.66218793",
"0.66158956",
"0.65318435",
"0.6476... | 0.6452887 | 21 |
Adds the cookie header. ConstantContact uses some sort of load balancer and requires cookies to keep track of session state. Without rudimentary cookie support, interfacing with the API is impossible. | def add_cookies!(request)
request['Cookie'] = @cookies.collect{|k, v| "#{k}=#{v}"}.join(", ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_cookie(cookie=nil)\n self.headers[\"Cookie\"] = cookie\n end",
"def cookie= cookie_str\n @headers['Cookie'] = cookie_str if @use_cookies\n end",
"def cookie= cookie_str\n @headers['Cookie'] = cookie_str if @use_cookies\n end",
"def add_cookie_if_needed(req)\n req.headers ... | [
"0.76521266",
"0.731316",
"0.731316",
"0.71901065",
"0.6801736",
"0.6801736",
"0.6748858",
"0.6699186",
"0.6677854",
"0.6647973",
"0.660693",
"0.65921175",
"0.65733856",
"0.6489146",
"0.6437071",
"0.6402867",
"0.6314517",
"0.63123614",
"0.6310303",
"0.62880844",
"0.628167",
... | 0.67925197 | 6 |
Stores cookies in the response for later use | def set_cookies(response)
cookie_str = response.header['set-cookie']
return if cookie_str.nil?
fields = cookie_str.split("; ").inject({}) { |h, field|
key, value = field.split("=")
h[key] = value
h
}
# This is obviously not a generalized cookie implementation. Heh.
fields.delete('path')
@cookies = fields
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect_cookies_from_response; end",
"def store_session(res)\n my_cookie = WEBrick::Cookie.new('_rails_lite_app', @cookies.to_json)\n res.cookies << my_cookie\n end",
"def add_cookies(response)\n return unless response.key?('set-cookie')\n response.get_fields('set-cookie').each do |cookie|\n ... | [
"0.80865437",
"0.7780333",
"0.7766894",
"0.77194995",
"0.7685288",
"0.76228493",
"0.7596847",
"0.7578727",
"0.7561802",
"0.7513666",
"0.7478621",
"0.74426687",
"0.73930377",
"0.73720825",
"0.73615545",
"0.734501",
"0.7330341",
"0.72812396",
"0.72805285",
"0.7259865",
"0.72598... | 0.76154774 | 6 |
Time Complexity O(1) Space Complexity O(n) | def fibonacci(n)
if n<0
raise ArgumentError
else
return fibonacci_helper(n, a=0 ,b=1)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\... | [
"0.677689",
"0.6584191",
"0.60779756",
"0.60185665",
"0.6002255",
"0.5985785",
"0.5982507",
"0.5940836",
"0.58860135",
"0.58682793",
"0.5835569",
"0.5820825",
"0.58189166",
"0.5818219",
"0.5810986",
"0.5785666",
"0.577747",
"0.5773797",
"0.57639724",
"0.5761223",
"0.57568467"... | 0.0 | -1 |
? => /menus ? POST | def create
name = params[:name]
new_menu = Menu.new(name: name)
new_menu.save
if new_menu.save
redirect_to menus_path
else
flash[:error] = new_menu.errors.full_messages.join(" , ")
redirect_to menus_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @menu = uhook_create_menu\n\n respond_to do |format|\n if @menu.valid?\n flash[:notice] = t(\"ubiquo.menu.created\")\n return if check_redirects(@menu)\n format.html { redirect_to(ubiquo.edit_menu_path(@menu)) }\n format.xml { render :xml => @menu, :status => :c... | [
"0.6824732",
"0.67232275",
"0.67095315",
"0.67000175",
"0.66686463",
"0.6667346",
"0.6628904",
"0.6604778",
"0.6592003",
"0.6591865",
"0.6565974",
"0.65308887",
"0.65236014",
"0.6500031",
"0.6490704",
"0.6490372",
"0.64705974",
"0.64705974",
"0.64705974",
"0.64662874",
"0.645... | 0.0 | -1 |
Aliases for location / name. | def parent
send(parent_type)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aliases\n\n end",
"def aliases\n end",
"def aliases; end",
"def aliases; end",
"def aliases; end",
"def aliases\n short ? [name, short] : [name]\n end",
"def alias_names; end",
"def aliases\n myAliases = \"\"\n if ['Mount ',' Mountain',' Peak'].any? {|word| self.name.inclu... | [
"0.7611454",
"0.7560629",
"0.75247693",
"0.75247693",
"0.75247693",
"0.73457843",
"0.7314379",
"0.70689887",
"0.70079315",
"0.6828475",
"0.6699012",
"0.6699012",
"0.6685604",
"0.6661808",
"0.6593854",
"0.65704715",
"0.6528307",
"0.65268236",
"0.65268236",
"0.65043515",
"0.645... | 0.0 | -1 |
Return parent's class name in lowercase, e.g. 'name' or 'location'. | def parent_type
type_tag.to_s.sub("_description", "")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent_class_name\n self.parent.class.name.downcase.pluralize\n end",
"def parent_name\n arr = self.name.split('::')\n arr[arr.length-2].downcase\n end",
"def parent_name\n self.class.parent_name\n end",
"def parent_class_name\n if custom_parent?\n ... | [
"0.84590805",
"0.781291",
"0.7807231",
"0.767081",
"0.75612146",
"0.75612146",
"0.7529664",
"0.71647626",
"0.71346045",
"0.71246874",
"0.71156335",
"0.70861655",
"0.70859665",
"0.7051254",
"0.702126",
"0.6946266",
"0.69053715",
"0.6902715",
"0.6892017",
"0.6878883",
"0.687849... | 0.0 | -1 |
Shorthand for "public && public_write" | def fully_public?
public && public_write
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_writer?\n options[:writer] == :public\n end",
"def public_write\n @public_write ||= public_write_was\n end",
"def public?\n !private\n end",
"def writable?() end",
"def public?\n self.mode == PUBLIC\n end",
"def writeable?\n !readonly?\n end",
"def public?\n ... | [
"0.7049207",
"0.69965374",
"0.69866514",
"0.6872203",
"0.6838355",
"0.6768611",
"0.6737977",
"0.6708214",
"0.66859204",
"0.6680215",
"0.66389877",
"0.6602248",
"0.6596751",
"0.6596751",
"0.6593567",
"0.65919363",
"0.65503883",
"0.6549893",
"0.6544702",
"0.6533534",
"0.6520825... | 0.81533474 | 0 |
Is this group writable by the general public? | def public_write
@public_write ||= public_write_was
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_write_was\n writer_group_ids == [UserGroup.all_users.id]\n end",
"def group_writable?(mode)\n mode & 00020 == 00020\n end",
"def public?\n # If it's not in a group, it's public\n if group\n !group.private\n else\n true\n end\n end",
"def may_read_groups?\n\t\t\tm... | [
"0.7726476",
"0.75593585",
"0.75536776",
"0.73978823",
"0.7220499",
"0.71027696",
"0.71027696",
"0.7004807",
"0.699765",
"0.6978275",
"0.69708526",
"0.6961961",
"0.6933053",
"0.6871112",
"0.68504506",
"0.68293786",
"0.6814611",
"0.68134564",
"0.6767741",
"0.6756707",
"0.67495... | 0.0 | -1 |
Get the initial state of +public_write+ before modification by form. | def public_write_was
writer_group_ids == [UserGroup.all_users.id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_write\n @public_write ||= public_write_was\n end",
"def readonly\n true\n end",
"def readonly?; true; end",
"def readonly?; true; end",
"def readonly?; true; end",
"def pub_state\n my_state = read_attribute(:pub_state)\n return my_state unless my_state.nil?\n\n my_state ... | [
"0.77478987",
"0.6171506",
"0.6081825",
"0.6081825",
"0.6081825",
"0.6062042",
"0.6032039",
"0.6032039",
"0.60052",
"0.59060866",
"0.58856785",
"0.58453465",
"0.5844713",
"0.581846",
"0.58177435",
"0.58177435",
"0.58177435",
"0.5812788",
"0.58107674",
"0.58050156",
"0.5794627... | 0.0 | -1 |
:section: Title/Name Formats Descriptive title including parent name, in plain text. | def text_name
put_together_name(:full).t.html_to_ascii
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def section_title(title)\n end",
"def section_title_for(node)\n title = nil\n\n while node && defined?(node.parent) && (node != body)\n if node.name == 'sec'\n title_node = node.css('> title')\n title = title_node.text if title_node.present? && title_node... | [
"0.7618753",
"0.73325616",
"0.71713096",
"0.70543045",
"0.696058",
"0.6904734",
"0.6881225",
"0.6843173",
"0.67505443",
"0.66713864",
"0.6638759",
"0.65846944",
"0.6569284",
"0.65415215",
"0.64929587",
"0.64789045",
"0.6471072",
"0.6471072",
"0.6471072",
"0.64535695",
"0.6431... | 0.0 | -1 |
Same as +text_name+ but with id tacked on. | def unique_text_name
string_with_id(text_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text_id\n \"#{name} (##{id})\"\n end",
"def unique_text_name\n text_name + \" (#{id || \"?\"})\"\n end",
"def unique_text_name\n text_name + \" (#{id || \"?\"})\"\n end",
"def unique_text_name\n real_text_name + \" (#{id || \"?\"})\"\n end",
"def name\n return text_get(0, id)\n... | [
"0.7986982",
"0.7801328",
"0.7801328",
"0.77976704",
"0.7374158",
"0.71130705",
"0.70515335",
"0.6913422",
"0.6885908",
"0.67652917",
"0.67263186",
"0.6708142",
"0.66662306",
"0.66662306",
"0.6622879",
"0.6621562",
"0.6620743",
"0.66189605",
"0.66104853",
"0.65862685",
"0.655... | 0.7290618 | 5 |
Descriptive title including parent name, in Textileformatted text. | def format_name
put_together_name(:full)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title\n return \"\" unless parent\n Array(parent.title).first.to_s\n end",
"def title_for_heading(parent_titles = Array.new)\n if parent_titles.length > 0\n [parent_titles, self.term_to_html(\"unittitle\")].join(\" >> \")\n else\n self.term_to_html(\"unittitle\")\n e... | [
"0.78629124",
"0.7790559",
"0.76672196",
"0.72764236",
"0.71312565",
"0.7124841",
"0.7099834",
"0.70995265",
"0.70884734",
"0.70606834",
"0.7042991",
"0.7042991",
"0.7042991",
"0.70378613",
"0.699966",
"0.698748",
"0.69793",
"0.69247895",
"0.6917242",
"0.6914277",
"0.6846791"... | 0.0 | -1 |
Same as +format_name+ but with id tacked on. | def unique_format_name
string_with_id(format_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_format_name\n format_name + \" (#{id || \"?\"})\"\n end",
"def unique_format_name\n display_name + \" (#{id || \"?\"})\"\n end",
"def unique_format_name\n title + \" (#{id || \"?\"})\"\n end",
"def unique_partial_format_name\n string_with_id(partial_format_name)\n end",
"def form... | [
"0.8623903",
"0.8175796",
"0.8014996",
"0.78277445",
"0.778792",
"0.74193877",
"0.74193877",
"0.7338339",
"0.72988826",
"0.7238947",
"0.72147614",
"0.71021295",
"0.7087537",
"0.7034134",
"0.703271",
"0.69954866",
"0.6799551",
"0.678007",
"0.6762309",
"0.67522067",
"0.67522067... | 0.8229673 | 1 |
Descriptive title without parent name, in plain text. | def partial_text_name
put_together_name(:part).t.html_to_ascii
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_title\n t = \"\"\n if parent\n t = parent.full_title + \"/\"\n end\n return t + title\n end",
"def title\n @descriptive_detail.title\n end",
"def title\n return \"\" unless parent\n Array(parent.title).first.to_s\n end",
"def title\n\t\tbase_title =... | [
"0.78973037",
"0.77650917",
"0.7712907",
"0.76960343",
"0.7591017",
"0.7564574",
"0.75311804",
"0.75311804",
"0.75311804",
"0.74850225",
"0.74826914",
"0.7481745",
"0.74762374",
"0.74724704",
"0.7471428",
"0.74663484",
"0.7458037",
"0.744272",
"0.7441694",
"0.74110985",
"0.73... | 0.0 | -1 |
Same as +partial_text_name+ but with id tacked on. | def unique_partial_text_name
string_with_id(partial_text_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def partial_text_name\n put_together_name(:part).t.html_to_ascii\n end",
"def text_id\n \"#{name} (##{id})\"\n end",
"def unique_text_name\n real_text_name + \" (#{id || \"?\"})\"\n end",
"def unique_text_name\n text_name + \" (#{id || \"?\"})\"\n end",
"def unique_text_name\n text_n... | [
"0.7489171",
"0.7369709",
"0.71538615",
"0.70609725",
"0.70609725",
"0.6977048",
"0.66406703",
"0.65177035",
"0.6517408",
"0.64556587",
"0.63567877",
"0.6286126",
"0.6286126",
"0.6286126",
"0.61330307",
"0.60118985",
"0.59641963",
"0.59144765",
"0.59062105",
"0.59052896",
"0.... | 0.79724365 | 0 |
Descriptive title without parent name, in Textileformatted text. | def partial_format_name
put_together_name(:part)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text_name\n title.to_s.t.html_to_ascii\n end",
"def title_brief\n return '' unless @marc_record && @marc_record['245']\n subfieldA = @marc_record['245']['a'] || ''\n title = subfieldA.strip\n # return the cleaned up title\n trim_punctuation(title)\n end",
"def title\n @descriptive_... | [
"0.750183",
"0.74823093",
"0.74739975",
"0.73729986",
"0.7356548",
"0.730458",
"0.7303377",
"0.7297251",
"0.7242838",
"0.72241795",
"0.71973395",
"0.7196658",
"0.7196658",
"0.7196658",
"0.71747494",
"0.71431696",
"0.71181166",
"0.7114219",
"0.7107462",
"0.7102454",
"0.7086741... | 0.0 | -1 |
Same as +partial_format_name+ but with id tacked on. | def unique_partial_format_name
string_with_id(partial_format_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_format_name\n format_name + \" (#{id || \"?\"})\"\n end",
"def partial_format_name\n put_together_name(:part)\n end",
"def unique_format_name\n display_name + \" (#{id || \"?\"})\"\n end",
"def unique_format_name\n string_with_id(format_name)\n end",
"def unique_format_name\n ... | [
"0.79678214",
"0.7906469",
"0.7731711",
"0.758865",
"0.74807924",
"0.69325715",
"0.6918187",
"0.6901638",
"0.6901638",
"0.67789215",
"0.67576563",
"0.673776",
"0.65637577",
"0.6549228",
"0.65298337",
"0.6363199",
"0.6362516",
"0.6331806",
"0.6330905",
"0.63198966",
"0.6294971... | 0.8659818 | 0 |
:section: Descriptions Are any of the descriptive text fields nonempty? | def notes?
result = false
self.class.all_note_fields.each do |field|
result = send(field).to_s.match(/\S/)
break if result
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def includes_description?\n !long_desc.empty? || !desc.empty?\n end",
"def descriptive_text\n description.blank? && taxon ? taxon.descriptive_text : description\n end",
"def has_description?\n true\n end",
"def generic_meta_description?\n [truncate(document.title, length: 3... | [
"0.7091663",
"0.6675248",
"0.6603432",
"0.65178055",
"0.6476238",
"0.6348571",
"0.6327523",
"0.6321117",
"0.6318996",
"0.6304335",
"0.6282118",
"0.6271227",
"0.62522614",
"0.62432814",
"0.62059134",
"0.6188833",
"0.61730695",
"0.617263",
"0.6162841",
"0.6162841",
"0.6161797",... | 0.0 | -1 |
Returns a Hash containing all the descriptive text fields. (See also the counterpart writermethod +all_notes=+.) | def all_notes
result = {}
self.class.all_note_fields.each do |field|
value = send(field).to_s
result[field] = value.presence
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def INFO_FIELDS\n %w(name created updated type ref user description comments)\n end",
"def descMetadata_display_fields\n [:identifier, :title, :alternative, :creator, :contributor, :description, :abstract,\n :toc, :publisher, :source, :date, :date_created, :date_copyrighted,\n :date_submitted,... | [
"0.6294499",
"0.6227788",
"0.6216737",
"0.61570185",
"0.61438",
"0.6032089",
"0.59499097",
"0.59088653",
"0.5904997",
"0.5897702",
"0.587941",
"0.5843357",
"0.58196956",
"0.581921",
"0.5804228",
"0.57735866",
"0.57711905",
"0.57700074",
"0.5764043",
"0.5763801",
"0.57572037",... | 0.64422196 | 0 |
Update all the descriptive text fields via Hash. hash = name.all_notes hash[:look_alikes] = "new value" name.all_notes = hash | def all_notes=(notes)
self.class.all_note_fields.each do |field|
send("#{field}=", notes[field])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notes=(value)\n @notes = value\n end",
"def notes=(value)\n @notes = value\n end",
"def notes=(value)\n @notes = value\n end",
"def notes=(value)\n @notes = value\n end",
"def update!(**args)\n ... | [
"0.588104",
"0.588104",
"0.588104",
"0.588104",
"0.5802742",
"0.57873756",
"0.5714335",
"0.56542444",
"0.55394685",
"0.5524737",
"0.55091524",
"0.5487705",
"0.54819363",
"0.54783964",
"0.5423867",
"0.5414819",
"0.5414819",
"0.5397254",
"0.5397254",
"0.537522",
"0.5366863",
... | 0.61266375 | 0 |
Find out how much descriptive text has been written for this object. Returns the number of fields filled in, and how many characters total. num_fields, total_length = name.note_status | def note_status
field_count = size_count = 0
all_notes.each_value do |v|
if v.present?
field_count += 1
size_count += v.strip_squeeze.length
end
end
[field_count, size_count]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_length\n name.length\n end",
"def length\n @fields.length\n end",
"def num_fields\n @fields.size\n end",
"def inspect_details\n\t\treturn %Q{%s -- %d headers, %0.2fK body (%p)} % [\n\t\t\tself.status_line,\n\t\t\tself.headers.length,\n\t\t\t(self.get_content_length / 1024.0),... | [
"0.5937865",
"0.59200543",
"0.5760106",
"0.5666546",
"0.5665476",
"0.5664266",
"0.56375414",
"0.56290567",
"0.5618939",
"0.5604621",
"0.5583017",
"0.5570458",
"0.5570094",
"0.5555435",
"0.5539693",
"0.553884",
"0.5536162",
"0.552772",
"0.54713106",
"0.54580325",
"0.5448924",
... | 0.71564275 | 0 |
Retreive object representing the source (if applicable). Presently, this only works for Project drafts and User's personal descriptions. All others return +nil+. | def source_object
case source_type
# (this may eventually be replaced with source_id)
when "project" then project
when "source" then nil # (haven't created "Source" model yet)
when "user" then user
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def source_object\n @source_object ||= load_source_object_from_params\n end",
"def source\n return @source\n end",
"def source\n return @source\n end",
"def source\n # force update if we only have part of source\n attrs.merge!(fetch) u... | [
"0.7247506",
"0.66357994",
"0.66357994",
"0.661893",
"0.6422995",
"0.6422995",
"0.62939125",
"0.62939125",
"0.6290268",
"0.62900406",
"0.62849873",
"0.62569153",
"0.6111213",
"0.6060943",
"0.6035761",
"0.5980306",
"0.5889795",
"0.5868077",
"0.58623666",
"0.58553004",
"0.58083... | 0.75499564 | 0 |
Does this Description belong to a given Project? | def belongs_to_project?(project)
(source_type == "project") &&
(project_id == project.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project?(p)\r\n projects.include?(p)\r\n end",
"def has_project?\n !project_id.nil? && project.visible\n end",
"def is_for_project?\n not self.project.nil?\n end",
"def project?\n ! @project.nil?\n end",
"def project?\n true\n end",
"def project_exists?(name)\n pr... | [
"0.76962286",
"0.726558",
"0.70722294",
"0.7044041",
"0.6984354",
"0.6905717",
"0.68513834",
"0.6663294",
"0.6540573",
"0.6504762",
"0.64169717",
"0.6400738",
"0.63710165",
"0.637062",
"0.6315698",
"0.6297305",
"0.6282142",
"0.6281135",
"0.62582123",
"0.62500346",
"0.6199254"... | 0.7785322 | 0 |
Wrapper around class method of same name | def admins_join_table
self.class.admins_join_table
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delegating_method; end",
"def around_method name, &block\n original_method = instance_method name\n _redefine_method name do |*args|\n instance_exec original_method, *args, &block\n end \n end",
"def original_method; end",
"def implement(method_name)\n ... | [
"0.7052142",
"0.6796785",
"0.67535836",
"0.67271453",
"0.665431",
"0.6650893",
"0.6632066",
"0.65957004",
"0.65957004",
"0.6594876",
"0.6557982",
"0.6557982",
"0.6557982",
"0.6557982",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
... | 0.0 | -1 |
Wrapper around class method of same name | def writers_join_table
self.class.writers_join_table
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delegating_method; end",
"def around_method name, &block\n original_method = instance_method name\n _redefine_method name do |*args|\n instance_exec original_method, *args, &block\n end \n end",
"def original_method; end",
"def implement(method_name)\n ... | [
"0.7052142",
"0.6796785",
"0.67535836",
"0.67271453",
"0.665431",
"0.6650893",
"0.6632066",
"0.65957004",
"0.65957004",
"0.6594876",
"0.6557982",
"0.6557982",
"0.6557982",
"0.6557982",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
... | 0.0 | -1 |
Wrapper around class method of same name | def readers_join_table
self.class.readers_join_table
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delegating_method; end",
"def around_method name, &block\n original_method = instance_method name\n _redefine_method name do |*args|\n instance_exec original_method, *args, &block\n end \n end",
"def original_method; end",
"def implement(method_name)\n ... | [
"0.7052142",
"0.6796785",
"0.67535836",
"0.67271453",
"0.665431",
"0.6650893",
"0.6632066",
"0.65957004",
"0.65957004",
"0.6594876",
"0.6557982",
"0.6557982",
"0.6557982",
"0.6557982",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
... | 0.0 | -1 |
List of all the admins for this description | def admins
group_users(admins_join_table)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_admins\n self._get_reviewers(\"admin\")\n end",
"def admins\n app_users.select(&:admin?)\n end",
"def admins\n ::Syncano::QueryBuilder.new(self, ::Syncano::Resources::Admin)\n end",
"def admins\n [self.user.email, self.study_shares.can_edit, User.where(admin: true).pluc... | [
"0.7602488",
"0.74937457",
"0.71806026",
"0.7174691",
"0.717119",
"0.71450937",
"0.7066944",
"0.70572853",
"0.6822781",
"0.6813221",
"0.6791414",
"0.6755497",
"0.67502207",
"0.67434037",
"0.66982454",
"0.6695976",
"0.66784686",
"0.664702",
"0.664702",
"0.664702",
"0.664702",
... | 0.6178298 | 64 |
List of all the writers for this description | def writers
group_users(writers_join_table)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writers\n find_related_frbr_objects( :is_written_by, :which_roles?) \n end",
"def writers\n parse_crew('Writing Credits')\n end",
"def index\n @writers = Writer.all\n end",
"def writers\n raise Locomotive::Mounter::ImplementationIsMissingException.new(\"[#{self.kind}]... | [
"0.7003905",
"0.6592244",
"0.65907246",
"0.64788765",
"0.61435896",
"0.59721965",
"0.588143",
"0.56146824",
"0.5484628",
"0.541108",
"0.54029256",
"0.52718836",
"0.52584815",
"0.52571106",
"0.5252471",
"0.5190333",
"0.5177292",
"0.51747453",
"0.5127192",
"0.5100604",
"0.50971... | 0.61688614 | 4 |
List of all the readers for this description | def readers
group_users(readers_join_table)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @readers = Reader.all\n end",
"def readers\n raise Locomotive::Mounter::ImplementationIsMissingException.new('readers are missing')\n end",
"def info\n @listers.collect {|l| [l.name, l.description] }\n end",
"def all_readings\n @readings.map do |reading|\n ... | [
"0.6529739",
"0.6487218",
"0.6049241",
"0.6024158",
"0.5960538",
"0.5886651",
"0.58518916",
"0.5730606",
"0.56995493",
"0.5600725",
"0.5538078",
"0.5525106",
"0.5490996",
"0.5489933",
"0.5425394",
"0.53876406",
"0.53449893",
"0.5259389",
"0.522137",
"0.52054566",
"0.5190789",... | 0.5962081 | 4 |
List of all the admins for this description, as ids. | def admin_ids
group_user_ids(admins_join_table)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin_ids\n @attributes[:admin_ids]\n end",
"def admin_ids\n ids = self.retrieve_elements(\"ADMINS/ID\")\n\n return [] if ids.nil?\n\n return ids.collect! {|x| x.to_i}\n end",
"def admins\n app_users.select(&:admin?)\n end",
"def get_admins\n s... | [
"0.77941406",
"0.73917234",
"0.71556675",
"0.70561725",
"0.7018986",
"0.6967707",
"0.69192386",
"0.6915428",
"0.68877655",
"0.67567545",
"0.67296904",
"0.6724348",
"0.6692731",
"0.6653966",
"0.66424686",
"0.64804184",
"0.6420057",
"0.64147574",
"0.6409",
"0.64042556",
"0.6362... | 0.7126273 | 3 |
List of all the writers for this description, as ids. | def writer_ids
group_user_ids(writers_join_table)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writers\n find_related_frbr_objects( :is_written_by, :which_roles?) \n end",
"def index\n @writers = Writer.all\n end",
"def writers\n group_users(writers_join_table)\n end",
"def index\n @expert_writers = ExpertWriter.all\n end",
"def list_ids\n @documents.keys\n en... | [
"0.6417494",
"0.630041",
"0.6018598",
"0.5694543",
"0.5693277",
"0.56871736",
"0.56491023",
"0.5479413",
"0.5411642",
"0.5390456",
"0.5327604",
"0.52752316",
"0.5240123",
"0.5211612",
"0.51640105",
"0.51636523",
"0.5144273",
"0.5143399",
"0.51323634",
"0.5101834",
"0.5101291"... | 0.6702613 | 0 |
List of all the readers for this description, as ids. | def reader_ids
group_user_ids(readers_join_table)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_ids\n @documents.keys\n end",
"def index\n @readers = Reader.all\n end",
"def identifier_uris\n return @identifier_uris\n end",
"def readers\n group_users(readers_join_table)\n end",
"def all_readings\n @readings.map do |reading|\n [rea... | [
"0.61472845",
"0.6024501",
"0.59517485",
"0.5912843",
"0.58371985",
"0.58128726",
"0.5662913",
"0.5625332",
"0.55959505",
"0.5571755",
"0.5564738",
"0.55548733",
"0.5513426",
"0.54963195",
"0.54736215",
"0.54735345",
"0.5450988",
"0.54486924",
"0.5445581",
"0.5376282",
"0.537... | 0.66206783 | 0 |
Is a given user an admin for this description? | def is_admin?(user)
permitted?(admins_join_table, user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_admin?(user)\n user.admin > 0\n end",
"def admin?(user)\n user.role_names.include?('cmsadmin')\n end",
"def is_admin?(user_id)\n\t\treturn admin == user_id\n\tend",
"def is_admin?(user)\r\n self.admins.one? { |email, admin| email == user.email }\r\n end",
"def admin_user?\n\t\tre... | [
"0.8482777",
"0.82945985",
"0.8256615",
"0.8245443",
"0.82209694",
"0.81923366",
"0.8178489",
"0.8164973",
"0.81641513",
"0.8135117",
"0.8134618",
"0.80921626",
"0.80820835",
"0.8080537",
"0.8059886",
"0.80450773",
"0.8037893",
"0.80276066",
"0.8010571",
"0.7999936",
"0.79861... | 0.80416274 | 16 |
Is a given user an writer for this description? | def writer?(user)
public_write || permitted?(writers_join_table, user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readable_by? user\n true\n end",
"def creatable_by?(creator)\n creator.administrator? || !administrator\n end",
"def canBeWrittenBy? user\n unless user.class == Modeles::User\n username = user.to_s\n user = Modeles::User.find_by_name username\n unless user\n @erro... | [
"0.73256534",
"0.7215667",
"0.71244144",
"0.70904756",
"0.7086124",
"0.7006786",
"0.69867325",
"0.6936943",
"0.6925994",
"0.6922083",
"0.6905442",
"0.69052166",
"0.68814886",
"0.6879818",
"0.6877545",
"0.68649095",
"0.68621093",
"0.6859863",
"0.6832547",
"0.67703986",
"0.6768... | 0.7896809 | 0 |
Is a given user an reader for this description? | def is_reader?(user)
public || permitted?(readers_join_table, user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_by?(user)\n\t user and self.readers.find_by_id(user.id)\n end",
"def is_reviewer?(user)\n review_result = self.design_review_results.detect { |drr| drr.reviewer == user }\n review_result != nil\n end",
"def readable?(_user)\n true\n end",
"def readable_by? user\n true\n end",
"def... | [
"0.7935975",
"0.74457484",
"0.72876996",
"0.72351986",
"0.7111891",
"0.7111891",
"0.7111891",
"0.7100824",
"0.70548874",
"0.6968953",
"0.6940173",
"0.69332594",
"0.6913268",
"0.6814002",
"0.67558503",
"0.6684775",
"0.6677316",
"0.664605",
"0.65852547",
"0.6579565",
"0.653642"... | 0.76218224 | 1 |
Give a User or UserGroup admin privileges. | def add_admin(arg)
chg_permission(admins, arg, :add)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin_user\n @group = Group.find(by_id)\n redirect_to @group unless @group.has_admin?(current_user)\n end",
"def set_as_admin\n self.role = USER_ROLES[:admin]\n end",
"def make_admin\n authorize! @user\n @user.roles = @user.roles + ['admin']\n @user.save\n redirect_to @user, no... | [
"0.707149",
"0.70289695",
"0.6964978",
"0.6943717",
"0.6941076",
"0.69249886",
"0.6842406",
"0.6791833",
"0.67640865",
"0.6751026",
"0.67500645",
"0.6725532",
"0.6697159",
"0.66841",
"0.6675297",
"0.6667297",
"0.6659703",
"0.6645084",
"0.6635761",
"0.6604771",
"0.65942305",
... | 0.6687903 | 13 |
Give a User or UserGroup writer privileges. | def add_writer(arg)
chg_permission(writers, arg, :add)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permits_write_access_for(user)\n end",
"def writer?(user)\n public_write || permitted?(writers_join_table, user)\n end",
"def can_write=(value)\n set_privileges('d', value) unless value\n set_privileges('w', value)\n end",
"def user_can_write(user)\n if (self.writing? or self.rejec... | [
"0.6684174",
"0.6661647",
"0.6607145",
"0.6030306",
"0.5999047",
"0.58052886",
"0.5783605",
"0.57647496",
"0.5731121",
"0.57253546",
"0.57219595",
"0.5712993",
"0.5708839",
"0.5677376",
"0.5641599",
"0.5641154",
"0.5625049",
"0.56211215",
"0.56158066",
"0.5602194",
"0.558604"... | 0.7183148 | 0 |
Give a User or UserGroup reader privileges. | def add_reader(arg)
chg_permission(readers, arg, :add)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assign_reader(user_id)\n add_user(user_id)\n end",
"def assign_reader(user_id)\n\t\tadd_user(user_id)\n\tend",
"def permits_read_acccess_for(user)\n end",
"def is_reader?(user)\n public || permitted?(readers_join_table, user)\n end",
"def grant_access(user_identifier)\n Scribd::Security... | [
"0.6733607",
"0.65807956",
"0.63644356",
"0.62446564",
"0.60599303",
"0.5910222",
"0.5858134",
"0.58206403",
"0.5796846",
"0.5728223",
"0.5716442",
"0.57161105",
"0.5694812",
"0.5605373",
"0.5599412",
"0.55444336",
"0.551846",
"0.5516621",
"0.54649436",
"0.54520494",
"0.54383... | 0.6599822 | 1 |
Revoke a User's or UserGroup's admin privileges. | def remove_admin(arg)
chg_permission(admins, arg, :remove)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def revoke_admin\n authorize! @user\n @user.roles = @user.roles - ['admin']\n @user.save\n redirect_to @user, notice: t('user.revoked_admin', name: @user.username)\n end",
"def revoke_admin_rights(member)\r\n fail \"#{member.email} is not a admin of this organisation\" unless admins[member.emai... | [
"0.78655076",
"0.7255248",
"0.7041714",
"0.6998136",
"0.68060064",
"0.6720279",
"0.6680363",
"0.65837175",
"0.65114397",
"0.648584",
"0.64757943",
"0.6449651",
"0.6442491",
"0.64257944",
"0.6407558",
"0.6336135",
"0.63146025",
"0.6228522",
"0.620599",
"0.62012726",
"0.6181732... | 0.6644865 | 7 |
Revoke a User's or UserGroup's writer privileges. | def remove_writer(arg)
chg_permission(writers, arg, :remove)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def revoke_admin\n authorize! @user\n @user.roles = @user.roles - ['admin']\n @user.save\n redirect_to @user, notice: t('user.revoked_admin', name: @user.username)\n end",
"def revoke_privileges(role_name, privileges, options = nil)\n policy = create_policy(options, AdminPolicy, default_admin_p... | [
"0.6460848",
"0.62574023",
"0.6123704",
"0.61066264",
"0.5954562",
"0.5946864",
"0.5877412",
"0.5857137",
"0.5718096",
"0.565587",
"0.5617169",
"0.55969906",
"0.5582123",
"0.5581712",
"0.5563368",
"0.55628145",
"0.55310524",
"0.5528573",
"0.5485884",
"0.5480639",
"0.54636854"... | 0.67918736 | 0 |
Revoke a User's or UserGroup's reader privileges. | def remove_reader(arg)
chg_permission(readers, arg, :remove)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def revoke_access(user_identifier)\n Scribd::Security.revoke_access user_identifier, self\n end",
"def revoke_admin\n authorize! @user\n @user.roles = @user.roles - ['admin']\n @user.save\n redirect_to @user, notice: t('user.revoked_admin', name: @user.username)\n end",
"def revoke\n ... | [
"0.7004909",
"0.6392618",
"0.63849384",
"0.6352084",
"0.61904573",
"0.61645865",
"0.6136987",
"0.60444313",
"0.600894",
"0.5999004",
"0.5993718",
"0.5942428",
"0.5939897",
"0.59338003",
"0.5882836",
"0.5847772",
"0.5840089",
"0.5823011",
"0.5779547",
"0.5763692",
"0.57550025"... | 0.63003385 | 4 |
Check if a given user has the given type of permission. | def permitted?(table, user)
if user.is_a?(User)
group_user_ids(table).include?(user.id)
elsif !user
group_ids(table).include?(UserGroup.all_users.id)
elsif user.try(:to_i)&.nonzero?
group_user_ids(table).include?(user.to_i)
else
raise(ArgumentError.new("Was expecting User instance, id or nil."))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user?\n permissions == 'user'\n end",
"def checkPermissionFor(type = :private)\n \n if(!@allow.nil?) then # if included in @allow list, true.\n return @allow.include?(type) ;\n elsif(!@disallow.nil?) then # if included in @disallow list, false.\n return !(@disallow.... | [
"0.76405",
"0.74002975",
"0.7302202",
"0.71909004",
"0.7122703",
"0.7122703",
"0.7060094",
"0.6965663",
"0.69597644",
"0.6934207",
"0.69318515",
"0.68962276",
"0.6890043",
"0.68846136",
"0.68816215",
"0.68740445",
"0.68721795",
"0.68384963",
"0.6836824",
"0.6824893",
"0.67875... | 0.0 | -1 |
Do minimal query to enumerate the users in a list of groups. Return as an Array of User instances. Caches result. | def group_users(table)
@group_users ||= {}
@group_users[table] ||= User.where(id: group_user_ids(table)).to_a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users\n Ecore::User.where(\"group_ids LIKE '%#{id}%'\").all\n end",
"def users\n Webmail::User.in(group_ids: id)\n end",
"def users\n users = []\n members.each do |member|\n if member.is_a? User\n users << member\n elsif member.is_a? UserGroup\n users + member.user... | [
"0.72953755",
"0.71286917",
"0.7051222",
"0.70300096",
"0.70154506",
"0.68671095",
"0.6644911",
"0.6596496",
"0.6553342",
"0.65501094",
"0.65167105",
"0.6513513",
"0.6504297",
"0.6499358",
"0.64936703",
"0.6443046",
"0.6415321",
"0.64068735",
"0.6405403",
"0.6395907",
"0.6375... | 0.66023695 | 7 |
Do minimal query to enumerate the users in a list of groups. Return as an Array of ids. Caches result. | def group_user_ids(table)
@group_user_ids ||= {}
@group_user_ids[table] ||=
table.to_s.classify.constantize.
joins(user_group: :user_group_users).
where("#{type_tag}_id" => id).
order(user_id: :asc).distinct.
pluck(:user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users\n Ecore::User.where(\"group_ids LIKE '%#{id}%'\").all\n end",
"def users\n Webmail::User.in(group_ids: id)\n end",
"def users\n Ecore::User.find(@user_id, :group_ids.like(\"%#{@id}%\")).receive(:all)\n end",
"def group_ids\n groups.pluck(:id)\n end",
"def get_users_in_... | [
"0.7370149",
"0.73389333",
"0.7115442",
"0.7065258",
"0.69778806",
"0.68778247",
"0.6683224",
"0.6653775",
"0.66495293",
"0.65970844",
"0.6554587",
"0.6529051",
"0.65022486",
"0.6501665",
"0.6434412",
"0.64094436",
"0.6372875",
"0.6357789",
"0.63193935",
"0.63113403",
"0.6297... | 0.63342065 | 18 |
Do minimal query to enumerate a list of groups. Return as an Array of ids. Caches result. (Equivalent to using association.ids, I think.) | def group_ids(table)
@group_ids ||= {}
@group_ids[table] ||=
table.to_s.classify.constantize.
where("#{type_tag}_id" => id).
order(user_group_id: :asc).distinct.
pluck(:user_group_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_ids\n groups.pluck(:id)\n end",
"def group_ids\n groups.map{|g| g.id}\n end",
"def group_ids_for(group)\n strong_memoize(:group_ids) do\n groups = groups_to_include(group)\n\n # Because we are sure that all groups are in the same hierarchy tree\n # we can preset root... | [
"0.78511167",
"0.7703417",
"0.7132754",
"0.7044208",
"0.69745225",
"0.6950946",
"0.68720907",
"0.68720907",
"0.68720907",
"0.66164225",
"0.6528312",
"0.6521525",
"0.64923316",
"0.649051",
"0.6470472",
"0.6464613",
"0.63149285",
"0.63149285",
"0.62968785",
"0.62528807",
"0.623... | 0.6278063 | 19 |
Wrapper around class method of same name | def authors_join_table
self.class.authors_join_table
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delegating_method; end",
"def around_method name, &block\n original_method = instance_method name\n _redefine_method name do |*args|\n instance_exec original_method, *args, &block\n end \n end",
"def original_method; end",
"def implement(method_name)\n ... | [
"0.7052142",
"0.6796785",
"0.67535836",
"0.67271453",
"0.665431",
"0.6650893",
"0.6632066",
"0.65957004",
"0.65957004",
"0.6594876",
"0.6557982",
"0.6557982",
"0.6557982",
"0.6557982",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
... | 0.0 | -1 |
Wrapper around class method of same name | def editors_join_table
self.class.editors_join_table
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delegating_method; end",
"def around_method name, &block\n original_method = instance_method name\n _redefine_method name do |*args|\n instance_exec original_method, *args, &block\n end \n end",
"def original_method; end",
"def implement(method_name)\n ... | [
"0.7052142",
"0.6796785",
"0.67535836",
"0.67271453",
"0.665431",
"0.6650893",
"0.6632066",
"0.65957004",
"0.65957004",
"0.6594876",
"0.6557982",
"0.6557982",
"0.6557982",
"0.6557982",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
"0.6520338",
... | 0.0 | -1 |
Is the given User an author? | def author?(user)
authors.member?(user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def author?(user)\n user && author.id == user.id\n end",
"def author?(user)\n self.user == user\n end",
"def current_user_is_author?\n current_user && current_user.is_author\n end",
"def has_author?(author)\n ret = false\n @authors.each{ |auth| ret = true if auth == author }\n ret\... | [
"0.89332795",
"0.8765247",
"0.83865756",
"0.8183136",
"0.80978",
"0.807365",
"0.80580676",
"0.7832285",
"0.77401567",
"0.76317245",
"0.7575179",
"0.7459884",
"0.7452254",
"0.7279688",
"0.7157843",
"0.7127489",
"0.702948",
"0.6986775",
"0.6982226",
"0.6972093",
"0.6970805",
... | 0.8925612 | 1 |
Is the given User an editor? | def editor?(user)
editors.member?(user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user_is_editor?(node)\n current_user_has_role?('editor', node)\n end",
"def edited_by?(user)\n return true if editors.include?(user)\n false\n end",
"def is_editor?\n role == \"editor\"\n end",
"def editor?\n has_role? :editor\n end",
"def editor?\n self[:editor] || ad... | [
"0.84314317",
"0.8376149",
"0.82757425",
"0.8126538",
"0.7926827",
"0.7918434",
"0.7855206",
"0.7744756",
"0.77002305",
"0.7697662",
"0.7608588",
"0.7578496",
"0.7545994",
"0.75184685",
"0.74401253",
"0.7428089",
"0.73473215",
"0.73250145",
"0.7292475",
"0.72890776",
"0.72637... | 0.90980387 | 0 |
Add a User on as an "author". Saves User if changed. Returns nothing. | def add_author(user)
return if authors.member?(user)
authors.push(user)
SiteData.update_contribution(:add, authors_join_table, user.id)
return unless editors.member?(user)
editors.delete(user)
SiteData.update_contribution(:del, editors_join_table, user.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_author\n add_author_editor \"author\"\n end",
"def add_author_or_editor\n return unless !@save_without_our_callbacks && (user = User.current)\n\n authors.empty? && author_worthy? ? add_author(user) : add_editor(user)\n end",
"def set_author\n @author = User.find(params[:id])\n ... | [
"0.74157155",
"0.7114053",
"0.68789184",
"0.6757846",
"0.6700198",
"0.6700198",
"0.6700198",
"0.6652552",
"0.65635043",
"0.65498966",
"0.65464115",
"0.65287846",
"0.65051913",
"0.6502722",
"0.650102",
"0.64896494",
"0.64849484",
"0.64849484",
"0.6482096",
"0.63033175",
"0.626... | 0.7802577 | 0 |
Demote a User to "editor". Saves User if changed. Returns nothing. | def remove_author(user)
return unless authors.member?(user)
authors.delete(user)
SiteData.update_contribution(:del, authors_join_table, user.id)
return unless !editors.member?(user) && user_made_a_change?(user)
editors.push(user)
SiteData.update_contribution(:add, editors_join_table, user.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assign_editor(user_id)\n add_user(user_id, true)\n end",
"def assign_editor(user_id)\n\t\tadd_user(user_id, true)\n\tend",
"def demote\n user = User.find(params[:id])\n\n redirect_to root_path if current_user.uid == user.uid\n\n return unless current_user.user_role.can_promote_demote && (user.... | [
"0.6170734",
"0.60589266",
"0.59883523",
"0.5838845",
"0.5679069",
"0.5647567",
"0.5638553",
"0.5589243",
"0.5537824",
"0.55084217",
"0.5438263",
"0.5438263",
"0.5409519",
"0.5379178",
"0.53029424",
"0.52997506",
"0.52826524",
"0.52805203",
"0.5268723",
"0.52589566",
"0.52577... | 0.0 | -1 |
Add a user on as an "editor". | def add_editor(user)
return unless !authors.member?(user) && !editors.member?(user)
editors.push(user)
SiteData.update_contribution(:add, editors_join_table, user.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assign_editor(user_id)\n add_user(user_id, true)\n end",
"def assign_editor(user_id)\n\t\tadd_user(user_id, true)\n\tend",
"def add_editor\n add_author_editor \"editor\"\n end",
"def add_editor!(name)\n Vedeu::Editor::Document.store(name: name)\n end",
"def add_author\n ... | [
"0.8382689",
"0.82146615",
"0.7783186",
"0.7151388",
"0.6811927",
"0.65949684",
"0.65701836",
"0.636815",
"0.63289",
"0.63150007",
"0.6128033",
"0.61255586",
"0.60336983",
"0.5973332",
"0.5971064",
"0.59547514",
"0.58989036",
"0.58846724",
"0.5845536",
"0.58339024",
"0.582919... | 0.78930765 | 2 |
:section: Callbacks Callback that updates editors and/or authors after a User makes a change. If the Name has no author and they've made sufficient contributions, they get promoted to author by default. In all cases make sure the user is added on as an editor. | def add_author_or_editor
return unless !@save_without_our_callbacks && (user = User.current)
authors.empty? && author_worthy? ? add_author(user) : add_editor(user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_editor(user)\n return unless !authors.member?(user) && !editors.member?(user)\n\n editors.push(user)\n SiteData.update_contribution(:add, editors_join_table, user.id)\n end",
"def add_author(user)\n return if authors.member?(user)\n\n authors.push(user)\n SiteData.update_contribution(:... | [
"0.6516556",
"0.64840055",
"0.6371271",
"0.62815714",
"0.6194216",
"0.61086464",
"0.6064158",
"0.606095",
"0.6017654",
"0.5987579",
"0.5984764",
"0.5870205",
"0.586114",
"0.586114",
"0.58566636",
"0.58293194",
"0.5824801",
"0.577044",
"0.57544994",
"0.5752118",
"0.5749067",
... | 0.67487556 | 0 |
When destroying an object, subtract contributions due to authorship/editorship. | def update_users_and_parent
# Update editors' and authors' contributions.
authors.each do |user|
SiteData.update_contribution(:del, authors_join_table, user.id)
end
editors.each do |user|
SiteData.update_contribution(:del, editors_join_table, user.id)
end
return unless parent.description_id == id
# Make sure parent doesn't point to a nonexisting object.
parent.description_id = nil
parent.save_without_our_callbacks
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n raise Codeplane::OwnershipError, \"you can only remove your own repositories\" unless mine?\n super\n end",
"def destroy\n self.deactivate\n if @affects\n @affects.dup.each do |affect|\n affect.clear(true)\n end\n end\n ... | [
"0.6238543",
"0.6106999",
"0.6017877",
"0.58815247",
"0.5880347",
"0.58549714",
"0.58549714",
"0.58278275",
"0.58167106",
"0.5816635",
"0.5800531",
"0.57782096",
"0.57274127",
"0.57160044",
"0.57147646",
"0.57120323",
"0.5675845",
"0.56664795",
"0.56626797",
"0.5656754",
"0.5... | 0.0 | -1 |
Descriptive subtitle for this description (when it is not necessary to include the title of the parent object), in plain text. [I'm not sure I like this here. It might violate MVC a bit too flagrantly... JPH] | def put_together_name(full_or_part)
tag = :"description_#{full_or_part}_title_#{source_type}"
user_name = begin
user.legal_name
rescue StandardError
"?"
end
args = {
text: source_name,
user: user_name
}
if full_or_part == :full
args[:object] = parent.format_name
elsif source_name.present?
tag = :"#{tag}_with_text"
end
tag.l(args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subtitle\n @descriptive_detail.subtitle\n end",
"def detailed_description\n \"#{parent.detailed_description} #{description}\".strip\n end",
"def subtitle\n {}\n end",
"def text\n self.title + \" -- \" + self.description\n end",
"def description; @text; end",
"def full_title su... | [
"0.8117024",
"0.7674786",
"0.71513724",
"0.7092079",
"0.70592344",
"0.70365196",
"0.6918752",
"0.6859945",
"0.6803786",
"0.67998415",
"0.6761956",
"0.6676819",
"0.6669246",
"0.6667094",
"0.666184",
"0.66116697",
"0.6609482",
"0.6582283",
"0.6569326",
"0.65591246",
"0.6557732"... | 0.0 | -1 |
Change a given User's or UserGroup's privileges. | def chg_permission(groups, arg, mode)
arg = UserGroup.one_user(arg) if arg.is_a?(User)
if (mode == :add) &&
groups.exclude?(arg)
groups.push(arg)
elsif (mode == :remove) &&
groups.include?(arg)
groups.delete(arg)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_privilege(user, group=user)\n Merb.logger.info \"Changing privileges to #{user}:#{group}\"\n \n uid, gid = Process.euid, Process.egid\n target_uid = Etc.getpwnam(user).uid\n target_gid = Etc.getgrnam(group).gid\n \n if uid != target_uid || gid != target_gid... | [
"0.7994836",
"0.7917318",
"0.7519735",
"0.7477421",
"0.7240177",
"0.7218914",
"0.6424384",
"0.6272503",
"0.60630244",
"0.59181756",
"0.5894621",
"0.5844101",
"0.5828992",
"0.5816531",
"0.5789739",
"0.5774821",
"0.57575333",
"0.56864345",
"0.5675206",
"0.5673839",
"0.5669403",... | 0.6280716 | 7 |
By default make first user to add any text an author. | def author_worthy?
notes?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_author\n add_author_editor \"author\"\n end",
"def add_author_or_editor\n return unless !@save_without_our_callbacks && (user = User.current)\n\n authors.empty? && author_worthy? ? add_author(user) : add_editor(user)\n end",
"def check_author\n if self.author.blank?\n self.au... | [
"0.76958305",
"0.7280693",
"0.6958008",
"0.69060904",
"0.68670166",
"0.68141496",
"0.672624",
"0.66647744",
"0.6655699",
"0.6641907",
"0.6632145",
"0.65999115",
"0.65192175",
"0.6497371",
"0.64922494",
"0.64802384",
"0.64488286",
"0.6411424",
"0.64106786",
"0.640214",
"0.6396... | 0.0 | -1 |
returns on of %i[ternary if unless elsif] | def style
keyword = loc_hash[:keyword]
keyword ? keyword.source.to_sym : :ternary
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def not_if(val) val ? :not_to : :to end",
"def conditionally(*) end",
"def conditionally(*) end",
"def ternary(statement, true_result, false_result)\n statement && true_result || false_result\nend",
"def switch(it)\n it == true ? false : true\nend",
"def foo a\r\n if a==1; \"one\" elsif a==2; \"two\" ... | [
"0.68683517",
"0.633276",
"0.633276",
"0.61857116",
"0.61130524",
"0.60441",
"0.60087055",
"0.5983689",
"0.5947374",
"0.58909607",
"0.5880925",
"0.58262503",
"0.58135486",
"0.5812732",
"0.5710531",
"0.5708556",
"0.56933373",
"0.56933373",
"0.5675759",
"0.563877",
"0.560573",
... | 0.0 | -1 |
def create HARD CODE.. just for testing purposes params[:customer][:town_id] = Town.first.id | def confirm_sales_return
@sales_return = SalesReturn.find_by_id params[:sales_return_id]
# add some defensive programming.. current user has role admin, and current_user is indeed belongs to the company
@sales_return.confirm( current_user )
@sales_return.reload
# sleep 5
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @town = Town.new(town_params)\n super\n end",
"def town_params\n params.require(:town).permit(:name, :township_id)\n end",
"def create\n @city = City.first\n @idcity= @city.id\n @zone = Zone.new(zone_params)\n @zone.city_id = @idcity\n if @zone.save \n render json: {... | [
"0.72106224",
"0.6933484",
"0.67468226",
"0.67303324",
"0.66912013",
"0.66912013",
"0.66850024",
"0.65953964",
"0.6578872",
"0.65488636",
"0.65455645",
"0.6511381",
"0.64895934",
"0.64895934",
"0.64727545",
"0.64619887",
"0.64408493",
"0.64266",
"0.64071155",
"0.6404924",
"0.... | 0.0 | -1 |
keytype can be :key_a or :key_b key hexadecimal string key representation like "FFFFFFFFFFFF" | def auth(block_num, key_type, key)
raise Mifare::Error, "Wrong key type" unless [:key_a, :key_b].include? key_type
raise Mifare::Error, "Wrong key length" unless [6, 12].include? key.size
key_ptr = FFI::MemoryPointer.new(:uchar, 6)
key_ptr.put_bytes(0, 6 == key.size ? key : [key].pack("H*"))
res = Mifare.mifare_classic_authenticate(@pointer, block_num, key_ptr,
key_type)
raise Mifare::Error, "Can't autenticate to block 0x%02x" % block_num if 0 != res
@auth_block = block_num
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_types; end",
"def key_types; end",
"def key_types=(_arg0); end",
"def key_type\r\n\t\treturn \" \" if repeat?(:SPACE)\r\n\t\tfor key in LETTERS\r\n\t\t\tnext unless repeat?(key)\r\n\t\t\treturn upcase? ? key.to_s[3].upcase : key.to_s[3].downcase\r\n\t\tend\r\n\t\tfor key in NUMBERS\r\n\t\t\treturn ke... | [
"0.7342737",
"0.7342737",
"0.7284891",
"0.70206654",
"0.70079076",
"0.68625766",
"0.68625766",
"0.6821866",
"0.68169105",
"0.67694515",
"0.67268634",
"0.67168117",
"0.6366496",
"0.6348431",
"0.6220874",
"0.6206214",
"0.6206214",
"0.6148869",
"0.6120079",
"0.61129415",
"0.6041... | 0.0 | -1 |
block number to read | def read(block_num = nil)
block_num ||= @auth_block
raise Mifare::Error, "Not authenticated" unless block_num
data_ptr = FFI::MemoryPointer.new(:uchar, 16)
res = Mifare.mifare_classic_read(@pointer, block_num, data_ptr)
raise Mifare::Error, "Can't read block 0x%02x" % block_num if 0 != res
data_ptr.get_bytes(0, 16).force_encoding("ASCII-8BIT")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def block_number\n request('getblocknumber')\n end",
"def getblocknumber\n request :getblocknumber\n end",
"def getblocknumber\n coind.getblocknumber\n end",
"def getblocknumber\n @api.request 'getblocknumber'\n end",
"def getblockcount\n coind.getblockcount\n end",
"def block_cou... | [
"0.78758854",
"0.746229",
"0.7339424",
"0.7269744",
"0.7141778",
"0.7025135",
"0.6846402",
"0.68111926",
"0.6790369",
"0.67076594",
"0.66905725",
"0.66005886",
"0.65945584",
"0.65658164",
"0.6549669",
"0.65402275",
"0.6487403",
"0.64450425",
"0.64450425",
"0.6431583",
"0.6368... | 0.65352714 | 16 |
Create value block structure and write it to block | def init_value(value, addr = nil, block_num = nil)
block_num ||= @auth_block
raise Mifare::Error, "Not authenticated" unless block_num
addr ||= 0
res = Mifare.mifare_classic_init_value(@pointer, block_num, value, addr)
raise Mifare::Error, "Can't init value block 0x%02x" % block_num if 0 != res
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_block(name, value)\n ContentBlock.find_or_create_by(name: name.to_s).update!(value: value)\n end",
"def store_data(ky, v = nil, &block)\n if block_given?\n vi.data_store.store_data(directive: name, key: ky, value: data_struct(&block))\n else\n vi... | [
"0.58903146",
"0.5861188",
"0.5852964",
"0.5846741",
"0.58180743",
"0.576991",
"0.5737456",
"0.57333434",
"0.56809866",
"0.56724894",
"0.5670763",
"0.56690943",
"0.5663423",
"0.56400466",
"0.5631061",
"0.5629042",
"0.5578527",
"0.55753475",
"0.55682635",
"0.54864794",
"0.5481... | 0.5451425 | 24 |
returns only value part of value block | def value(block_num = nil)
v, _ = value_with_addr(block_num)
v
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value\n @value ||= extract_value\n end",
"def process_field_value(value)\r\n value\r\n end",
"def raw_value; end",
"def parse_value; end",
"def get_value\n value\n end",
"def get_value\n value\n end",
"def value() end",
"def raw_value\n @value\n end",
"def value_read... | [
"0.6678275",
"0.64614433",
"0.64219344",
"0.63476545",
"0.6270926",
"0.6270926",
"0.62671334",
"0.6231581",
"0.62206393",
"0.6179265",
"0.61725265",
"0.6169654",
"0.61566406",
"0.61286974",
"0.60795116",
"0.6079091",
"0.6076884",
"0.60742074",
"0.60552114",
"0.6049564",
"0.60... | 0.67158556 | 0 |
returns value and addr | def value_with_addr(block_num = nil)
block_num ||= @auth_block
raise Mifare::Error, "Not authenticated" unless block_num
value_ptr = FFI::MemoryPointer.new(:int32, 1)
addr_ptr = FFI::MemoryPointer.new(:uchar, 1)
res = Mifare.mifare_classic_read_value(@pointer, block_num, value_ptr, addr_ptr)
raise Mifare::Error, "Can't read value block 0x%02x" % block_num if 0 != res
[value_ptr.get_int32(0), addr_ptr.get_uchar(0)]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value\n data[ address ]\n end",
"def value\n expand( address ).map { |ar| ar.map { |addr| data[ addr ] } }\n end",
"def address\n read_attribute(:value)\n end",
"def value(block_num = nil)\n \tv, _ = value_with_addr(block_num)\n \tv\n end",
"def address() @address; en... | [
"0.7244705",
"0.7076334",
"0.6979033",
"0.6818865",
"0.6553674",
"0.6435024",
"0.6435024",
"0.6417512",
"0.6215418",
"0.6109889",
"0.6103081",
"0.6103081",
"0.6092437",
"0.6067316",
"0.60466015",
"0.60466015",
"0.60466015",
"0.60466015",
"0.60268235",
"0.60029083",
"0.6000104... | 0.6929207 | 3 |
Needed for developer strategy | def create
user = User.find_or_create_from_auth_hash(auth_hash)
cookies.signed[:user_id] = user.id
redirect_to messages_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def strategy; end",
"def who_we_are\r\n end",
"def schubert; end",
"def suivre; end",
"def refutal()\n end",
"def implementation; end",
"def implementation; end",
"def c... | [
"0.79726994",
"0.70875525",
"0.69392306",
"0.69392306",
"0.69392306",
"0.69392306",
"0.6905697",
"0.6889591",
"0.68687683",
"0.6824747",
"0.67890316",
"0.6736028",
"0.6736028",
"0.6724556",
"0.6724556",
"0.65981853",
"0.6564458",
"0.6554731",
"0.6489286",
"0.64706916",
"0.644... | 0.0 | -1 |
Write out a cache of data | def cache(key, value, source = nil)
if key.nil? || value.nil?
raise ArgumentError, 'Missing key or value to store'
end
mycache = find_cache(key, source)
make_cache_path(mycache[:dir]) unless mycache[:dir].nil?
# don't use the Rubyist standard pattern so we can test with rspec
begin
out = File.open(mycache[:file], 'w')
YAML.dump({ key.to_s => value }, out)
out.close
rescue StandardError => e
Facter.debug("Unable to write to cache #{mycache[:file]}: #{e.backtrace[0]}: #{$ERROR_INFO}.")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_cache\n data = cache_data\n open(writable_file, \"wb\") do |f|\n\tf.puts Marshal.dump(data)\n end\n end",
"def write_cache\n File.write(CACHE_PATH, @data.to_json)\n end",
"def write_cache_file\n open(@cache_file, 'w') do |f|\n f.puts({ \n :userid => @userid,\n... | [
"0.8716462",
"0.84039193",
"0.76448786",
"0.7585536",
"0.75293905",
"0.74744594",
"0.7464213",
"0.7464213",
"0.7215313",
"0.7208699",
"0.71989673",
"0.7183229",
"0.70965505",
"0.7047877",
"0.70363396",
"0.701875",
"0.6990915",
"0.69248235",
"0.68626535",
"0.68523544",
"0.6844... | 0.0 | -1 |
The method should return the number of pairs of elements that sum to 0. | def pairs_to_zero(nums)
# Write your code here
c = []
a = nums.select { |n| c.push(n) if n < 0 }
nums.delete_if { |n| c.push(n) if n < 0 }
i = 0
pairs = 0
a = a.map { |n| n*-1 }
loop do
if nums.count(a[i]) > 0
pairs += 1
end
i += 1
break if i == a.length
end
return pairs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pairs_to_zero(nums)\n\n count = 0\n newArr = []\n\n for i in 0..nums.length do\n for j in 1..nums.length do\n if nums[i].to_i + nums[j].to_i == 0\n count = count + 1\n end\n end\n end\n return count-2\nend",
"def opposite_count(nums)\n pairs = 0... | [
"0.80429035",
"0.777874",
"0.75099903",
"0.7424152",
"0.73820204",
"0.7309957",
"0.7276644",
"0.72716993",
"0.7233506",
"0.72101665",
"0.7209892",
"0.719596",
"0.71955144",
"0.7182001",
"0.71734196",
"0.7156854",
"0.7144943",
"0.70880026",
"0.7020093",
"0.7007946",
"0.6960717... | 0.78253675 | 1 |
GET /users GET /users.json | def index
if params.has_key?(:email)
@user = User.where("email = ?", params[:email]).first
render json: @user.to_json
else
head :no_content
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end",
"def GetUsers params = {}\n\n para... | [
"0.82109934",
"0.7873764",
"0.7860689",
"0.78108346",
"0.78067017",
"0.7678852",
"0.76586664",
"0.76318866",
"0.7582366",
"0.75291824",
"0.7487637",
"0.74485743",
"0.7439024",
"0.7437192",
"0.7427442",
"0.73978853",
"0.73978853",
"0.73978853",
"0.73978853",
"0.7377353",
"0.73... | 0.0 | -1 |
PUT /users/1 PUT /users/1.json | def update
get_current_user
@user = User.find(params[:id])
return (render json: {errors: ["Je bent niet geauthoriseerd om dit te doen"]}, status: :unprocessable_entity) unless (@current_user.isAdmin || @current_user.id == @user.id)
respond_to do |format|
if @user.update_attributes(params[:user])
new_remember_token(@user) if @current_user.isStudent
format.json { head :no_content }
else
format.json { render json: {errors: @user.errors.full_messages}, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"de... | [
"0.74114245",
"0.73920554",
"0.73041475",
"0.7254177",
"0.7202618",
"0.70756376",
"0.70535713",
"0.7029043",
"0.70075685",
"0.69883573",
"0.6983195",
"0.694263",
"0.69409895",
"0.692315",
"0.6909438",
"0.687742",
"0.68486536",
"0.6834162",
"0.6821841",
"0.6801179",
"0.6770304... | 0.0 | -1 |
subtract attrs_skip from attrs | def ext_attrs(values, attrs_skip = [])
result = values.except *attrs_always_skip
return result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skip_name\n @attributes[:skip_name]\n end",
"def exclude_attrs(hash, attrs, must_exclude, associations)\n exclude = attrs + associations + must_exclude\n hash.except(*exclude)\n end",
"def skipped_attributes\n if model.respond_to?(:skipped_alchemy_resource_attributes)\n ... | [
"0.6426769",
"0.61645734",
"0.6150883",
"0.60867596",
"0.6056458",
"0.6052449",
"0.599769",
"0.599769",
"0.59952945",
"0.5987856",
"0.595818",
"0.5899168",
"0.5884298",
"0.58841485",
"0.5859921",
"0.58376354",
"0.57960564",
"0.57952917",
"0.57867104",
"0.5779215",
"0.5773433"... | 0.774333 | 0 |
take a map of symbol => value and convert to joined list of "symbol1 : value1, symbol2 : value2, ..." | def ext_attributes(values)
ext_attrib_list = []
values.each do |key, value|
ext_attrib_list << "#{key.to_s} : #{value}"
end
result = ext_attrib_list.join(",\n")
return result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s; map { |name, val| \"#{val['name']}=#{val}\" }.join(','); end",
"def comma_pair_list(hash)\n hash.inject([]) { |list, pair| list << \"#{pair.first} = #{pair.last}\" }.join(\", \")\n end",
"def values_to_s\n sorted_keys.map {|key| \"#{key} => #{values[key].inspect}\"}.join(\", \")\n ... | [
"0.6406042",
"0.62712353",
"0.59769785",
"0.5957746",
"0.5872467",
"0.584431",
"0.58382314",
"0.5757867",
"0.56499135",
"0.5649562",
"0.55994517",
"0.55804056",
"0.55741197",
"0.55741197",
"0.55741197",
"0.55741197",
"0.55741197",
"0.5564144",
"0.55518603",
"0.55478036",
"0.5... | 0.0 | -1 |
has_a_holiday? accepts a date creates an array of holidays for the module checks to see if the date is in the array | def holiday?(date)
all_holidays.any? { |holiday| holiday === date }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_holiday(date, holidays)\n holidays.include?(date)\n end",
"def is_a_2014_bank_holiday?(date)\n # e.g. year, month, day\n # date format: Time.local(1976, 8, 3)\n y = 2014\n # store array of bank holiday dates\n array = [Time.local(y,12,25),Time.local(y,12,26),Time.local(y,8,25),Time.loca... | [
"0.8694399",
"0.80473673",
"0.7989587",
"0.7935973",
"0.7905278",
"0.790463",
"0.78402185",
"0.78402185",
"0.7832536",
"0.7832296",
"0.7805948",
"0.77029645",
"0.7651575",
"0.7590602",
"0.75311035",
"0.74098754",
"0.7354943",
"0.7339798",
"0.71757865",
"0.7145868",
"0.7140745... | 0.80408525 | 2 |
TODO This is a temporary override of sufia to fix 101 This can be removed once sufia has a solution and we upgrade or batches are no longer used when sufia migrates to PCDM routed to /files/new | def new
@batch_id = Batch.create.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_files; end",
"def existing_files; end",
"def replaced_files; end",
"def new_by_mass_upload\n end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def obsolete_files; end",
"def file_uploads; end",
"def public_file_server... | [
"0.68108815",
"0.61197674",
"0.609095",
"0.6053759",
"0.581231",
"0.581231",
"0.581231",
"0.581231",
"0.581231",
"0.581231",
"0.5776208",
"0.5684958",
"0.54806",
"0.54806",
"0.54718393",
"0.5421152",
"0.54110634",
"0.54110634",
"0.5398515",
"0.5396567",
"0.5384946",
"0.5382... | 0.0 | -1 |
Run startup tasks, then start the functions framework server in the background. The startup tasks and target function will be looked up in the global registry. | def start target, &block
require "functions_framework/server"
if target.is_a? ::FunctionsFramework::Function
function = target
else
function = global_registry[target]
raise ::ArgumentError, "Undefined function: #{target.inspect}" if function.nil?
end
globals = function.populate_globals
server = Server.new function, globals, &block
global_registry.startup_tasks.each do |task|
task.call function, globals: globals, logger: server.config.logger
end
globals.freeze
server.respond_to_signals
server.start
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def work\n Logger.info \"Starting work...\"\n execute_startup(connections) {|c| c.future.connect}\n execute_startup(devices) {|d| d.future.start_device}\n execute_working_code\n end",
"def start!\n message \"Launching minimum_instances\"\n launch_minimum_instances\n message ... | [
"0.60056525",
"0.59079665",
"0.58106196",
"0.57933325",
"0.5769415",
"0.57481724",
"0.57481724",
"0.57481724",
"0.5702265",
"0.5702265",
"0.5702265",
"0.5671864",
"0.5635277",
"0.5633227",
"0.5622795",
"0.558078",
"0.55694795",
"0.5569316",
"0.5560733",
"0.55540943",
"0.55186... | 0.7279588 | 0 |
Run the functions framework server and block until it stops. The server will look up the given target function name in the global registry. | def run target, &block
server = start target, &block
server.wait_until_stopped
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start target, &block\n require \"functions_framework/server\"\n if target.is_a? ::FunctionsFramework::Function\n function = target\n else\n function = global_registry[target]\n raise ::ArgumentError, \"Undefined function: #{target.inspect}\" if function.nil?\n end\n ... | [
"0.7461704",
"0.61008304",
"0.56610084",
"0.55302966",
"0.54482913",
"0.54448956",
"0.54379016",
"0.5388982",
"0.5388982",
"0.53506696",
"0.52960145",
"0.5288701",
"0.5251265",
"0.5244282",
"0.5244282",
"0.5223534",
"0.5206386",
"0.5201746",
"0.51779854",
"0.51318",
"0.51318"... | 0.5973344 | 2 |
Classlevel client class config. Note: late evaluation of `client_class` blocks allows us using classlevel configs in those blocks, e.g.: class ConfigurableOnClassLevel < Netzke::Base class_attribute :title self.title = "Default" client_class do |c| c.title = self.title end end ConfigurableOnClassLevel.title = "Overridden" | def client_class_config
return @client_class_config if @client_class_config
@client_class_config = Netzke::Core::ClientClassConfig.new(self, called_from)
(@configure_blocks || []).each do |block, dir|
@client_class_config.dir = dir
block&.call(@client_class_config)
end
@client_class_config
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_client_class(cls)\n @@client_class = cls\n end",
"def class_constant(superclass=nil, opts={}, &block)\n symc = ((opts && opts[:preserve]) ? (\"#{self.camelcase}Class\") : \"PoolParty#{self.camelcase}Class\").classify\n\n kla=<<-EOE\n class #{symc} #{\"< #{superclass}\" if superclas... | [
"0.6208662",
"0.5702407",
"0.55793685",
"0.55435836",
"0.5534328",
"0.5418085",
"0.5378345",
"0.53714126",
"0.52870744",
"0.52784985",
"0.5205428",
"0.51389766",
"0.5063481",
"0.5063053",
"0.5034326",
"0.5025482",
"0.5014208",
"0.4975403",
"0.49713236",
"0.49398336",
"0.49367... | 0.7153891 | 0 |
Path to the dir with this component/extension's extra code (ruby modules, scripts, stylesheets) | def dir(cllr)
cllr.split('.rb:').first.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_load_path\n File.join(Plugins.site.source, Plugins.custom_dir, dir, File.dirname(file)).sub /\\/\\.$/, ''\n end",
"def bundled_path\n File.dirname Wisp::Source.bundled_path\n end",
"def extension_dir\n @extension_dir ||= File.expand_path(File.join(extensions_dir, full_name))... | [
"0.6678933",
"0.6673618",
"0.6414921",
"0.6330639",
"0.6330639",
"0.6274309",
"0.6274045",
"0.6197689",
"0.6196215",
"0.6175317",
"0.6157382",
"0.6144832",
"0.613333",
"0.61244726",
"0.611166",
"0.611166",
"0.611166",
"0.611166",
"0.611166",
"0.611166",
"0.611166",
"0.60555... | 0.0 | -1 |
Global id in the component tree, following the doubleunderscore notation, e.g. +books__config_panel__form+ | def js_id
@js_id ||= parent.nil? ? @item_id : [parent.js_id, @item_id].join('__')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dom_id\n \"#{self.class.name.gsub(/:+/,\"_\")}_#{self.object_id}\"\n end",
"def dom_id\n \"_#{self.object_id}\"\n end",
"def id_base\n \"#{@page_config.name}_#{parent_field_id}#{@field_name}\"\n end",
"def dom_id\n display_id = new_record? ? \"new\" : id\n prefix... | [
"0.7031049",
"0.69950145",
"0.69584197",
"0.67088157",
"0.6668455",
"0.66666585",
"0.6653173",
"0.6653173",
"0.6644294",
"0.6644294",
"0.66230524",
"0.66230524",
"0.6615821",
"0.65496635",
"0.6514409",
"0.64836836",
"0.644023",
"0.63965625",
"0.63965625",
"0.63965625",
"0.637... | 0.6100617 | 39 |
Ext.createByAlias may be used to instantiate the component. | def js_alias
self.class.client_class_config.class_alias
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alias_create(al)\n obj_create al, Alias\n end",
"def create_component(name)\n Backlogjp::Component.create(self, name)\n end",
"def [](name, *args)\n component = components[name.to_sym]\n\n component.klass.new(*args)\n end",
"def component(name, comp, &block)\n componen... | [
"0.65783465",
"0.60331947",
"0.5602545",
"0.5430911",
"0.54295826",
"0.537986",
"0.53421617",
"0.5314194",
"0.528274",
"0.5271293",
"0.5269714",
"0.5250058",
"0.52467203",
"0.5240313",
"0.5174109",
"0.5157544",
"0.51452374",
"0.51368344",
"0.509881",
"0.5097123",
"0.5091206",... | 0.0 | -1 |
Hash containing configuration for all child components to be instantiated at the JS side | def js_components
@js_components ||= eagerly_loaded_components.inject({}) do |out, name|
instance = component_instance(name.to_sym)
out.merge(name => instance.js_config)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def js_extend_properties\n {\n :init_component => js_init_component.l\n }\n end",
"def initial_components\n {}\n end",
"def initialize(args, kwargs = nil)\n super(args, kwargs)\n client_config[:child_components] = child_components || []\n client_config... | [
"0.68288743",
"0.6606852",
"0.6599132",
"0.6599132",
"0.645475",
"0.6347905",
"0.61376214",
"0.5947426",
"0.5925811",
"0.5888696",
"0.583883",
"0.5829227",
"0.578068",
"0.5765497",
"0.57645583",
"0.57635915",
"0.5725941",
"0.5715021",
"0.56984115",
"0.5687548",
"0.56468475",
... | 0.6792842 | 1 |
All the JScode required by this instance of the component to be instantiated in the browser, excluding cached code. It includes JSclasses for the parents, eagerly loaded child components, and itself. | def js_missing_code(cached = [])
code = dependency_classes.inject('') do |r, k|
cached.include?(k.client_class_config.xtype) ? r : r + k.client_class_config.code_with_dependencies
end
code.blank? ? nil : Netzke::Core::DynamicAssets.minify_js(code)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def js_components\n @js_components ||= eagerly_loaded_components.inject({}) do |out, name|\n instance = component_instance(name.to_sym)\n out.merge(name => instance.js_config)\n end\n end",
"def js_extend_properties\n {\n :init_component => js_init_component.l\n ... | [
"0.6987342",
"0.62005204",
"0.59476984",
"0.57031167",
"0.56941164",
"0.5689748",
"0.56699264",
"0.55704015",
"0.5471457",
"0.5460117",
"0.53911954",
"0.53889585",
"0.53390664",
"0.5331553",
"0.5321037",
"0.53018314",
"0.5296758",
"0.5288552",
"0.5284311",
"0.52685255",
"0.52... | 0.630698 | 1 |
Merges all the translations in the class hierarchy Note: this method can't be moved out to ClientClassConfig, because I18n is loaded only once, when other Ruby classes are evaluated; so, this must remain at instance level. | def js_i18n
@js_i18n ||= self.class.netzke_ancestors.inject({}) do |r, klass|
hsh = klass.client_class_config.translated_properties.inject({}) { |h, t| h.merge(t => I18n.t("#{klass.i18n_id}.#{t}")) }
r.merge(hsh)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def translatable\n self._translatable[base_name] ||= []\n end",
"def translations\n ::I18n.backend.instance_eval do\n init_translations unless initialize... | [
"0.6282833",
"0.6282833",
"0.5896506",
"0.57747215",
"0.5686837",
"0.5610382",
"0.55876637",
"0.55281645",
"0.5515838",
"0.5485491",
"0.54849905",
"0.5400106",
"0.53928703",
"0.5362537",
"0.5349425",
"0.5328034",
"0.52739805",
"0.513117",
"0.50863254",
"0.50747484",
"0.507378... | 0.5698219 | 4 |
with the same values except the vowels removed remove_vowels(%w(abcdefghijklmnopqrstuvwxyz)) == %w(bcdfghjklmnpqrstvwxyz) remove_vowels(%w(green YELLOW black white)) == %w(grn YLLW blck wht) remove_vowels(%w(ABC AEIOU XYZ)) == ['BC', '', 'XYZ'] create method remove_vowels that takes an array called strings iterate with map, and delete any occurence of "aeiouAEIOU" | def remove_vowels(strings)
strings.map { |string| string.delete "aeiouAEIOU" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_vowels(strings)\n strings.map { |str| str.gsub(/[aeiou]/i, '')}\nend",
"def remove_vowels(strings)\n strings.map { |string| string.delete('aeiouAEIOU') }\nend",
"def remove_vowels(strings)\n strings.map { |string| string.delete('aeiouAEIOU') }\nend",
"def remove_vowels_simple(strings)\n string... | [
"0.8641376",
"0.8540051",
"0.8540051",
"0.85351545",
"0.8497217",
"0.84227705",
"0.8411659",
"0.8399283",
"0.838643",
"0.83858603",
"0.837722",
"0.83602464",
"0.8357461",
"0.83537096",
"0.83397967",
"0.83214515",
"0.8316907",
"0.8313133",
"0.830906",
"0.8306005",
"0.83025485"... | 0.8548237 | 1 |
params: value is 2element array value[0] is the filename value[1] is the binary string of the image | def decode_from_ui(value)
Site::UploadUtils.uploadSingleFile value[0], Base64.decode64(value[1]) if value[1]
value[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pull_image(value)\n user_hash = pull_records(value)\n id = user_hash[0][\"id\"]\n image_name = user_hash[0][\"image\"]\n image = \"images/uploads/#{id}/#{image_name}\"\nend",
"def image_file_name= value\n super if value.present?\n end",
"def normalize_binary_values(params, field_name, values)\n ... | [
"0.6048974",
"0.6048543",
"0.60445374",
"0.60431546",
"0.5994502",
"0.59274113",
"0.5860368",
"0.58447707",
"0.5836948",
"0.5803834",
"0.57718784",
"0.5732084",
"0.5726559",
"0.5687376",
"0.56796515",
"0.567506",
"0.567506",
"0.5645373",
"0.563582",
"0.56187284",
"0.56068695"... | 0.5928575 | 5 |
Shows the form to create a new influencer | def new
@user = User.new
@user.role = 'influencer'
@user.build_influencer
@referrer = User.where(:id => session[:referrer_id]).first if session[:referrer_id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @influencer = Influencer.new(influencer_params)\n respond_to do |format|\n if @influencer.save\n format.html { redirect_to @influencer, notice: 'Influencer was successfully created.' }\n format.json { render :show, status: :created, location: @influencer }\n else\n ... | [
"0.7188554",
"0.67414635",
"0.634043",
"0.6326295",
"0.61766994",
"0.6171509",
"0.6159231",
"0.6152182",
"0.6126411",
"0.6118255",
"0.6091603",
"0.6089135",
"0.60621774",
"0.6056397",
"0.60484195",
"0.60212076",
"0.6016522",
"0.60105014",
"0.60094976",
"0.6007745",
"0.6006917... | 0.0 | -1 |
Creates a new influencer | def create
@user = User.new(params[:user])
@user.role = 'influencer'
# Account approved
@user.approved = true
# Assign twitter credentials
@user.twitter_linked = true
@user.twitter_screen_name = session['twitter_screen_name']
@user.twitter_uid = session['twitter_uid']
@user.twitter_token = session['twitter_token']
@user.twitter_secret = session['twitter_secret']
if @user.save
# Set the referrer commission
if session[:referrer_id]
@user.update_attribute(:referrer_commission, 5)
end
# Clear session values
session[:referrer_id] = session['twitter_screen_name'] = session['twitter_uid'] = session['twitter_token'] = session['twitter_secret'] = nil
# Login user
sign_in(:user, @user)
@influencer = current_user.influencer
if @influencer.audience.followers < 1000
@influencer.update_attribute( :approved , false)
@influencer.update_attribute(:need_approval , true)
@influencer.mail_need_approval
else
@influencer.update_attribute( :approved , true)
@influencer.update_attribute(:need_approval , false)
end
# Complete profiles
redirect_to action: :step_2
else
@referrer = User.where(:id => session[:referrer_id]).first if session[:referrer_id]
render action: :new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @influencer = Influencer.new(influencer_params)\n respond_to do |format|\n if @influencer.save\n format.html { redirect_to @influencer, notice: 'Influencer was successfully created.' }\n format.json { render :show, status: :created, location: @influencer }\n else\n ... | [
"0.6336661",
"0.5908171",
"0.5665371",
"0.5568177",
"0.530995",
"0.5210828",
"0.5202087",
"0.5154065",
"0.50803006",
"0.5075157",
"0.50303864",
"0.50208735",
"0.50208735",
"0.50096303",
"0.5006995",
"0.49999067",
"0.49531537",
"0.49514058",
"0.49514058",
"0.49514058",
"0.4951... | 0.0 | -1 |
Shows the second step for the registration | def step_2
@influencer = current_user.influencer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def second_step\n\t\trender :layout => 'signup' \n\t\tend",
"def new\n #showing the registration page\n end",
"def account_details_next_step\n return STEPS if AccountType.individual?(@account.account_type)\n\n accounts_registration_user_details_path\n end",
"def step2\n user = User.new\n ... | [
"0.7656952",
"0.66078496",
"0.6399284",
"0.6202302",
"0.61492914",
"0.6026653",
"0.601157",
"0.5997887",
"0.59729314",
"0.5954312",
"0.59086066",
"0.58838135",
"0.5882579",
"0.58749783",
"0.5864677",
"0.58415335",
"0.58291936",
"0.5821661",
"0.580713",
"0.58062404",
"0.579988... | 0.0 | -1 |
Process the second step for the registration | def process_step_2
@influencer = current_user.influencer
if @influencer.update_attributes(params[:influencer])
redirect_to action: :step_3
else
render action: :step_2
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finish_register\n end",
"def register\n # running successfully\n # class_name = params[:user_type].camelize\n # registration_stuff = params[\"#{params[:user_type].to_sym}\"]\n # template = \"#{params[:user_type].pluralize}/new\"\n # save_credentials(class_name, registration_stuff, template)... | [
"0.6728262",
"0.66782784",
"0.63841045",
"0.6291262",
"0.62422746",
"0.61941123",
"0.617963",
"0.6129918",
"0.6129193",
"0.6020003",
"0.60195583",
"0.5982972",
"0.59671754",
"0.5953941",
"0.5943399",
"0.59009945",
"0.5895869",
"0.5879699",
"0.5878053",
"0.58766854",
"0.586798... | 0.58120525 | 26 |
Shows the third step for the registration | def step_3
@influencer = current_user.influencer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def second_step\n\t\trender :layout => 'signup' \n\t\tend",
"def account_for\n wizard_step(STEPS) { { setup_step: :setup_step, next_step: :account_for_next_step } }\n end",
"def account_details_next_step\n return STEPS if AccountType.individual?(@account.account_type)\n\n accounts_registratio... | [
"0.6976361",
"0.6213946",
"0.6148486",
"0.609535",
"0.601955",
"0.59974146",
"0.59624296",
"0.5882699",
"0.5816199",
"0.5815662",
"0.5812021",
"0.5796674",
"0.57870287",
"0.57725704",
"0.5764742",
"0.5753965",
"0.57314724",
"0.57305187",
"0.5718489",
"0.57120144",
"0.5695343"... | 0.0 | -1 |
Process the third step for the registration | def process_step_3
@influencer = current_user.influencer
if @influencer.update_attributes(params[:influencer])
redirect_to influencer_dashboard_path
else
render action: :step_3
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register\n # running successfully\n # class_name = params[:user_type].camelize\n # registration_stuff = params[\"#{params[:user_type].to_sym}\"]\n # template = \"#{params[:user_type].pluralize}/new\"\n # save_credentials(class_name, registration_stuff, template)\n\n if(params[:user_type] == '... | [
"0.65403473",
"0.649233",
"0.61639345",
"0.6028734",
"0.6022147",
"0.59929883",
"0.5958204",
"0.59470737",
"0.5865953",
"0.5841621",
"0.58402544",
"0.5783937",
"0.5765125",
"0.57609355",
"0.57416904",
"0.57406723",
"0.5730389",
"0.5721868",
"0.57162064",
"0.57154447",
"0.5715... | 0.54654896 | 61 |
Ask the influencer to link his twitter account | def link_twitter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def twitter\n callback_from :twitter\n end",
"def twitter_link(player)\n if player.twitter_screen_name\n # clean up any bad characters in a player's twitter name\n twitter_user = player.twitter_screen_name.sub(/^.*[@\\/]/, '')\n\n link_to(\"@\" + twitter_user, \"http://twitter.com/#{twitter... | [
"0.78661543",
"0.73285854",
"0.7265497",
"0.7256906",
"0.7228",
"0.7225449",
"0.7190844",
"0.71783227",
"0.7130772",
"0.7085071",
"0.7058437",
"0.7017137",
"0.69061947",
"0.68787605",
"0.6850809",
"0.6839857",
"0.6756167",
"0.67295533",
"0.670247",
"0.67005837",
"0.6655384",
... | 0.7762805 | 1 |
Check that the user is logged in with twitter | def check_twitter_credentials
if session['twitter_token'].blank? || session['twitter_secret'].blank?
redirect_to new_user_registration_path, :error => "Debes linkear tu cuenta de twitter antes de continuar" and return
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def twitter_user?\n return true if is_logged_in? && (session[:request_token] && session[:request_token_secret] && session[:twitter_id])\n end",
"def twitter_login?\n\t\tself.uid ? true : false\n\tend",
"def connected_to_twitter?\n twitter_token && twitter_secret\n end",
"def twitter?\n self.twitte... | [
"0.8536491",
"0.80822074",
"0.80571604",
"0.7699492",
"0.7342331",
"0.73290724",
"0.7321295",
"0.72783655",
"0.7248837",
"0.722955",
"0.7156141",
"0.7115674",
"0.7006099",
"0.6995784",
"0.69734746",
"0.68619156",
"0.6844345",
"0.6838051",
"0.6817137",
"0.6770883",
"0.6752597"... | 0.7660423 | 4 |
Use callbacks to share common setup or constraints between actions. | def set_item
@item = Item.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 item_params
params.require(:item).permit(:name, :description, :category, :picture, :units_per_item, :weight, :active, item_price_attributes: [:price, :start_date])
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 |
GET /expenses GET /expenses.json | def index
@filters = {}
@expenses = Expense.all
@subtotal = calculate_subtotal(@expenses)
render :index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @expenses = find_expenses.all\n render json: @expenses\n end",
"def index\n @expenses = Expense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end",
"def expenses\n @expenses ||= Harvest::API::Expenses.n... | [
"0.8207424",
"0.7868928",
"0.7521715",
"0.7485303",
"0.7466285",
"0.73566276",
"0.72700804",
"0.71818566",
"0.7099663",
"0.70841765",
"0.70841765",
"0.70841765",
"0.70841765",
"0.70841765",
"0.7070414",
"0.6989723",
"0.69714546",
"0.6969409",
"0.6900681",
"0.6863176",
"0.6781... | 0.5898737 | 70 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.