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 |
|---|---|---|---|---|---|---|
SCHEMA STATEMENTS ======================================== Drops the database specified on the +name+ attribute and creates it again using the provided +options+. | def recreate_database(name, options = {})
drop_database(name)
sql = create_database(name, options)
reconnect!
sql
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recreate_database(name, options = {}) #:nodoc:\n drop_database(name)\n create_database(name, options)\n end",
"def recreate_database(name, options = {})\n drop_database(name)\n create_database(name, options)\n end",
"def create_database(name, _options = {})... | [
"0.7931576",
"0.78294027",
"0.77030593",
"0.75980514",
"0.7580308",
"0.7383198",
"0.7353716",
"0.72562236",
"0.725461",
"0.7170872",
"0.71346986",
"0.7134434",
"0.709759",
"0.7072147",
"0.70476526",
"0.703331",
"0.70186514",
"0.7012768",
"0.69775957",
"0.6954451",
"0.6935567"... | 0.7591042 | 4 |
Create a new MySQL database with optional :charset and :collation. Charset defaults to utf8mb4. Example: create_database 'charset_test', charset: 'latin1', collation: 'latin1_bin' create_database 'matt_development' create_database 'matt_development', charset: :big5 | def create_database(name, options = {})
if options[:collation]
execute "CREATE DATABASE #{quote_table_name(name)} DEFAULT COLLATE #{quote_table_name(options[:collation])}"
elsif options[:charset]
execute "CREATE DATABASE #{quote_table_name(name)} DEFAULT CHARACTER SET #{quote_table_name(options[:charset])}"
elsif row_format_dynamic_by_default?
execute "CREATE DATABASE #{quote_table_name(name)} DEFAULT CHARACTER SET `utf8mb4`"
else
raise "Configure a supported :charset and ensure innodb_large_prefix is enabled to support indexes on varchar(255) string columns."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_database(name, charset)\n database = ::MySQL::Database.create(name, charset)\n !database.nil?\n end",
"def create_database(name, options = {})\n options = { :encoding => 'utf8' }.merge!(options.symbolize_keys)\n\n option_string = options.sum do |key, value|\n case key\n ... | [
"0.77200854",
"0.7396388",
"0.73807687",
"0.7378632",
"0.7084339",
"0.70706314",
"0.69256747",
"0.69132864",
"0.68258864",
"0.67257595",
"0.67029697",
"0.6700407",
"0.6666678",
"0.66479194",
"0.645953",
"0.6403143",
"0.6230088",
"0.6229342",
"0.6154013",
"0.5953857",
"0.59388... | 0.79103875 | 0 |
Drops a MySQL database. Example: drop_database('sebastian_development') | def drop_database(name) # :nodoc:
execute "DROP DATABASE IF EXISTS #{quote_table_name(name)}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_mysql_database\n MysqlUtils.drop_mysql_database(database_name)\n end",
"def drop_database\n puts \"Droping database #{@db_name}...\"\n begin\n client = Mysql2::Client.new(:host => @db_host, :username => @db_user, :password => @db_pass)\n client.query(\"DROP DATABASE IF EXISTS... | [
"0.8537386",
"0.82828987",
"0.81969196",
"0.8188192",
"0.81238467",
"0.810776",
"0.8095662",
"0.79066145",
"0.78262025",
"0.77501255",
"0.7709589",
"0.75526017",
"0.75269306",
"0.743703",
"0.74115217",
"0.72846717",
"0.72797894",
"0.7238348",
"0.716385",
"0.71583617",
"0.7113... | 0.8096367 | 6 |
Returns the database character set. | def charset
show_variable "character_set_database"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def character_set_name\n @dbi.character_set_name\n end",
"def character_set_name\n @dbi.character_set_name\n end",
"def character_set\n @character_set ||= show_variable('character_set_connection') || 'utf8'\n end",
"def character_set_name\n @charset.... | [
"0.80107063",
"0.80107063",
"0.77831674",
"0.7339106",
"0.7111844",
"0.7111844",
"0.6903564",
"0.6662642",
"0.658275",
"0.65800947",
"0.6554453",
"0.65480626",
"0.6508591",
"0.6502078",
"0.64863807",
"0.6377788",
"0.6307382",
"0.6171894",
"0.6106703",
"0.6077168",
"0.60539293... | 0.8039727 | 0 |
Returns the database collation strategy. | def collation
show_variable "collation_database"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collation\n @collation ||= show_variable('collation_connection') || 'utf8_general_ci'\n end",
"def collation\n return @collation\n end",
"def collation\n select_value(\n \"SELECT pg_database.datcollate\" <<\n \" FROM pg_database\" <<\n \" ... | [
"0.75390023",
"0.7348966",
"0.70291835",
"0.69332683",
"0.6560546",
"0.6418619",
"0.6136279",
"0.5920985",
"0.58800715",
"0.58800715",
"0.57487476",
"0.5562531",
"0.5388366",
"0.53793466",
"0.53766054",
"0.52451473",
"0.5241892",
"0.52267635",
"0.519012",
"0.5150045",
"0.5099... | 0.7339151 | 2 |
Renames a table. Example: rename_table('octopuses', 'octopi') | def rename_table(table_name, new_name, **options)
validate_table_length!(new_name) unless options[:_uses_legacy_table_name]
schema_cache.clear_data_source_cache!(table_name.to_s)
schema_cache.clear_data_source_cache!(new_name.to_s)
execute "RENAME TABLE #{quote_table_name(table_name)} TO #{quote_table_name(new_name)}"
rename_table_indexes(table_name, new_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rename_table(*args)\n execute(rename_table_sql(*args))\n end",
"def rename_table(table_name, new_name)\n clear_cache!\n execute \"ALTER TABLE #{quote_table_name(table_name)} RENAME TO #{quote_table_name(new_name)}\"\n end",
"def rename_table(table_name, new_name)\n sch... | [
"0.84496796",
"0.820878",
"0.8120327",
"0.7903684",
"0.7766701",
"0.772739",
"0.772739",
"0.7667506",
"0.76294136",
"0.75355494",
"0.73548025",
"0.73298883",
"0.6908819",
"0.6874954",
"0.6786661",
"0.6528938",
"0.65020245",
"0.65020245",
"0.64599144",
"0.6281416",
"0.6281416"... | 0.81299496 | 2 |
Drops a table from the database. [:force] Set to +:cascade+ to drop dependent objects as well. Defaults to false. [:if_exists] Set to +true+ to only drop the table if it exists. Defaults to false. [:temporary] Set to +true+ to drop temporary table. Defaults to false. Although this command ignores most +options+ and the block if one is given, it can be helpful to provide these in a migration's +change+ method so it can be reverted. In that case, +options+ and the block will be used by create_table. | def drop_table(table_name, **options)
schema_cache.clear_data_source_cache!(table_name.to_s)
execute "DROP#{' TEMPORARY' if options[:temporary]} TABLE#{' IF EXISTS' if options[:if_exists]} #{quote_table_name(table_name)}#{' CASCADE' if options[:force] == :cascade}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_table_sql(name, options)\n \"DROP TABLE#{' IF EXISTS' if options[:if_exists]} #{quote_schema_table(name)}#{' CASCADE' if options[:cascade]}\"\n end",
"def destroy!\n drop_ddl = tables.map(&:name).map do |t|\n \"drop table if exists #{t};\\n\"\n end.join\n ActiveRecord::Base... | [
"0.70287",
"0.67377406",
"0.64704764",
"0.6361707",
"0.6212682",
"0.6212682",
"0.620601",
"0.6202963",
"0.6191556",
"0.6182046",
"0.6161013",
"0.61244553",
"0.6104909",
"0.59706134",
"0.5953467",
"0.5944827",
"0.59175855",
"0.58875805",
"0.5879335",
"0.58112174",
"0.5781739",... | 0.7411839 | 0 |
Builds a ChangeColumnDefinition object. This definition object contains information about the column change that would occur if the same arguments were passed to change_column. See change_column for information about passing a +table_name+, +column_name+, +type+ and other options that can be passed. | def build_change_column_definition(table_name, column_name, type, **options) # :nodoc:
column = column_for(table_name, column_name)
type ||= column.sql_type
unless options.key?(:default)
options[:default] = column.default
end
unless options.key?(:null)
options[:null] = column.null
end
unless options.key?(:comment)
options[:comment] = column.comment
end
if options[:collation] == :no_collation
options.delete(:collation)
else
options[:collation] ||= column.collation if text_type?(type)
end
unless options.key?(:auto_increment)
options[:auto_increment] = column.auto_increment?
end
td = create_table_definition(table_name)
cd = td.new_column_definition(column.name, type, **options)
ChangeColumnDefinition.new(cd, column.name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_column(column_id: nil, validate_data: false, format_pattern: 'NONE', name:, type:, table:)\n column_id ||= table.columns.size\n raise ArgumentError.new('Column ID must be Integer') unless column_id.is_a?(Integer)\n raise ArgumentError.new(\"Column type must be #{ AVAILABLE_COLUMN_TYPES }\") unle... | [
"0.6489515",
"0.6462893",
"0.6026478",
"0.5490518",
"0.5443929",
"0.53347087",
"0.53216994",
"0.53018355",
"0.5295448",
"0.52528685",
"0.5224405",
"0.51864296",
"0.51670146",
"0.51607186",
"0.5155693",
"0.5139097",
"0.5111737",
"0.5058465",
"0.5056207",
"0.50541234",
"0.50538... | 0.842165 | 0 |
SHOW VARIABLES LIKE 'name' | def show_variable(name)
query_value("SELECT @@#{name}", "SCHEMA")
rescue ActiveRecord::StatementInvalid
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_variable(name)\n query('SHOW VARIABLES WHERE `variable_name` = ?', name).first.value rescue nil\n end",
"def descriptor\n ConfigvarsRails.variable_descriptor name\n end",
"def value\n mysql('-NBe', \"show variables like '#{resource[:name]}'\").split(\"\\t\")[1].chomp\n end",
... | [
"0.74665225",
"0.588237",
"0.5671308",
"0.5519296",
"0.538434",
"0.5363477",
"0.53485644",
"0.5341013",
"0.5333825",
"0.52866757",
"0.52866757",
"0.5272169",
"0.5272169",
"0.5208399",
"0.52018386",
"0.5187096",
"0.5184854",
"0.5180399",
"0.5144479",
"0.51115614",
"0.51115614"... | 0.63253236 | 1 |
In MySQL 5.7.5 and up, ONLY_FULL_GROUP_BY affects handling of queries that use DISTINCT and ORDER BY. It requires the ORDER BY columns in the select list for distinct queries, and requires that the ORDER BY include the distinct column. See | def columns_for_distinct(columns, orders) # :nodoc:
order_columns = orders.compact_blank.map { |s|
# Convert Arel node to string
s = visitor.compile(s) unless s.is_a?(String)
# Remove any ASC/DESC modifiers
s.gsub(/\s+(?:ASC|DESC)\b/i, "")
}.compact_blank.map.with_index { |column, i| "#{column} AS alias_#{i}" }
(order_columns << super).join(", ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supports_distinct_on?\n true\n end",
"def true_eager_graph_limit_strategy\n if associated_class.dataset.supports_ordered_distinct_on? && !offset\n :distinct_on\n else\n super\n end\n end",
"def group_by_columns\n @group = \" GRO... | [
"0.52293396",
"0.51240957",
"0.49794465",
"0.4902737",
"0.48602208",
"0.48571762",
"0.48424357",
"0.48359713",
"0.48271644",
"0.48014584",
"0.4756107",
"0.4756107",
"0.47556338",
"0.47359815",
"0.46529257",
"0.4633993",
"0.462892",
"0.4621168",
"0.460874",
"0.45970824",
"0.45... | 0.41668966 | 68 |
Make sure we carry over any changes to ActiveRecord.default_timezone that have been made since we established the connection | def sync_timezone_changes(raw_connection)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate_timezones\n if new_record?\n self.created_at_timezone ||= Time.zone.name\n else\n if self.deleted?\n self.deleted_at_timezone ||= Time.zone.name\n end\n end\n end",
"def set_timezone\n Time.zone = Time.zone_default\n end",
"def before_setup\n @original_time_z... | [
"0.72063774",
"0.71469",
"0.7085934",
"0.69347745",
"0.69347745",
"0.69347745",
"0.69347745",
"0.69347745",
"0.68296355",
"0.6810101",
"0.6745839",
"0.67003363",
"0.6675422",
"0.66668737",
"0.65338117",
"0.6483802",
"0.6407198",
"0.63957036",
"0.6345897",
"0.6341086",
"0.6336... | 0.74166185 | 0 |
Produces a planet from Stargate. | def planet
fetch('stargate.planets')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_planet(name, mass, year_length, diameter, number_of_moons, distance_from_sun)\n return Planet.new(name, mass, year_length, diameter, number_of_moons, distance_from_sun)\nend",
"def planet\n fetch('dune.planets')\n end",
"def add_planet\n planet = Planet.new(get_planet_name, get_pla... | [
"0.7159391",
"0.6616675",
"0.6404045",
"0.6393684",
"0.6393615",
"0.6393615",
"0.6393615",
"0.6393615",
"0.6393615",
"0.616198",
"0.6131664",
"0.60030705",
"0.59741247",
"0.59675753",
"0.59631085",
"0.594851",
"0.59319174",
"0.5863729",
"0.5756633",
"0.5756148",
"0.57384753",... | 0.7374267 | 0 |
Produces a quote from Stargate. | def quote
fetch('stargate.quotes')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quote\n quote_of_the_day[0...second_to_last_index(quote_of_the_day, \"~\")].gsub(/(\\A[^a-zA-z0-9\"']*|\\s*\\z)/, \"\")\n end",
"def quote\n fetch('final_space.quotes')\n end",
"def quote\n fetch('simpsons.quotes')\n end",
"def quote; end",
"def quote; end",
... | [
"0.6427196",
"0.64128244",
"0.6374833",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
... | 0.7703826 | 0 |
Helps determine active menu item | def currentMenuItem(expected, controller, action)
return "class=active" if expected == (controller + "#" + action)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def active_item\n return @active_item if @active_item\n # Simple configuration means that name is returned immediately\n @active_item = get_value(controller_active_item_config)\n\n # If the configuration is a Hash then we need to find the first\n # menu item that has a passing condition\n if @act... | [
"0.76982325",
"0.763451",
"0.76050305",
"0.7596932",
"0.73686796",
"0.7286955",
"0.71070236",
"0.6879232",
"0.68591166",
"0.682274",
"0.6795854",
"0.6775279",
"0.6724239",
"0.66545695",
"0.66155607",
"0.65797734",
"0.65797734",
"0.65682334",
"0.6558391",
"0.65576816",
"0.6553... | 0.76013595 | 3 |
Note: We use find_by_id to avoid exeception being raised in case of empty search result | def current_merchant_store
@current_merchant_store ||= session[:current_merchant_store_id] &&
MerchantStore.find_by_id(session[:current_merchant_store_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_by_id(id)\n results = one.find_by_id_ne(id)\n results && !results['id'].blank? && new(results) || nil\n end",
"def find(id)\n find_result\n end",
"def find(id); end",
"def find(id); end",
"def find_by_id(id)\n results = many.find_with_attributes_ne(id)... | [
"0.744874",
"0.73801535",
"0.7300191",
"0.7300191",
"0.72902",
"0.7228066",
"0.72147083",
"0.70133287",
"0.6988539",
"0.6986306",
"0.6979294",
"0.69600546",
"0.69545156",
"0.6939753",
"0.69295317",
"0.6855026",
"0.6812868",
"0.67736167",
"0.66998",
"0.66641015",
"0.6662875",
... | 0.0 | -1 |
Note: We use find_by_id to avoid exeception being raised in case of empty search result | def current_merchant_user
@current_merchant_user ||= session[:current_user_id] &&
MerchantUser.find_by_id(session[:current_user_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_by_id(id)\n results = one.find_by_id_ne(id)\n results && !results['id'].blank? && new(results) || nil\n end",
"def find(id)\n find_result\n end",
"def find(id); end",
"def find(id); end",
"def find_by_id(id)\n results = many.find_with_attributes_ne(id)... | [
"0.744874",
"0.73801535",
"0.7300191",
"0.7300191",
"0.72902",
"0.7228066",
"0.72147083",
"0.70133287",
"0.6988539",
"0.6986306",
"0.6979294",
"0.69600546",
"0.69545156",
"0.6939753",
"0.69295317",
"0.6855026",
"0.6812868",
"0.67736167",
"0.66998",
"0.66641015",
"0.6662875",
... | 0.0 | -1 |
Note: We use find_by_id to avoid exeception being raised in case of empty search result | def current_member_user
@current_member_user ||= session[:current_user_id] &&
Member.find_by_id(session[:current_user_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_by_id(id)\n results = one.find_by_id_ne(id)\n results && !results['id'].blank? && new(results) || nil\n end",
"def find(id)\n find_result\n end",
"def find(id); end",
"def find(id); end",
"def find_by_id(id)\n results = many.find_with_attributes_ne(id)... | [
"0.7449511",
"0.7381067",
"0.73013794",
"0.73013794",
"0.7290445",
"0.7228518",
"0.7215376",
"0.70134956",
"0.6989107",
"0.6987005",
"0.6979678",
"0.69597614",
"0.6954456",
"0.69408077",
"0.69297165",
"0.6855992",
"0.6813805",
"0.6772662",
"0.6700463",
"0.66640663",
"0.666204... | 0.0 | -1 |
Index of provided node in children list | def index_of(child)
children.index(child)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_child_index\n return 0\n end",
"def own_child_index\n return nil if parent.nil? # self is root\n own_index = nil\n parent.children.each_with_index { |c,i|\n if self == c\n own_index = i\n break\n end\n }\n own_index\n end",
"def left_... | [
"0.76742184",
"0.7532127",
"0.7369772",
"0.7337128",
"0.7261996",
"0.72143",
"0.7148654",
"0.7115117",
"0.703771",
"0.70130855",
"0.69766545",
"0.6895524",
"0.6895524",
"0.6849534",
"0.6835928",
"0.6800404",
"0.6752169",
"0.6731827",
"0.6727014",
"0.6716052",
"0.6690258",
"... | 0.794102 | 0 |
Get List of Fax Receipts | def fax_receipt_list
# Prepare query url.
_query_builder = Configuration.base_uri.dup
_query_builder << '/fax/receipts'
_query_url = APIHelper.clean_url _query_builder
# Prepare and execute HttpRequest.
_request = @http_client.get(
_query_url
)
BasicAuth.apply(_request)
_context = execute_request(_request)
# Validate response against endpoint and global error codes.
return nil if _context.response.status_code == 404
validate_response(_context)
# Return appropriate response type.
_context.response.raw_body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def receipts_plist\n plist_virtual_attribute_get(:receipts)\n end",
"def fee_receipts\n unless params[:search].present?\n @start_date=@end_date=FedenaTimeSet.current_time_to_local_time(Time.now).to_date\n else\n @start_date=date_fetch('start_date_as')\n @end_date=date_fetch('end_date_as'... | [
"0.65498495",
"0.6437965",
"0.62711227",
"0.6176253",
"0.5866492",
"0.58204156",
"0.58074254",
"0.571122",
"0.5708426",
"0.5699477",
"0.56959105",
"0.56889147",
"0.56848586",
"0.5673113",
"0.56723094",
"0.56723094",
"0.56682193",
"0.5664647",
"0.562958",
"0.5618523",
"0.55921... | 0.83824164 | 0 |
Get a single fax receipt based on message id. | def get_fax_receipt(message_id)
# Validate required parameters.
validate_parameters(
'message_id' => message_id
)
# Prepare query url.
_query_builder = Configuration.base_uri.dup
_query_builder << '/fax/receipts/{message_id}'
_query_builder = APIHelper.append_url_with_template_parameters(
_query_builder,
'message_id' => message_id
)
_query_url = APIHelper.clean_url _query_builder
# Prepare and execute HttpRequest.
_request = @http_client.get(
_query_url
)
BasicAuth.apply(_request)
_context = execute_request(_request)
# Validate response against endpoint and global error codes.
return nil if _context.response.status_code == 404
validate_response(_context)
# Return appropriate response type.
_context.response.raw_body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(id)\n response = Network.get(['Faxes', id])\n Fax.new(response)\n end",
"def sms_receipts_by_message_id_get(message_id, opts = {})\n data, _status_code, _headers = sms_receipts_by_message_id_get_with_http_info(message_id, opts)\n data\n end",
"def get(message_id)\r\n ... | [
"0.6714761",
"0.62932956",
"0.5854769",
"0.5836609",
"0.5661811",
"0.5489899",
"0.5489551",
"0.5484675",
"0.5414108",
"0.5411747",
"0.53724015",
"0.5356397",
"0.5356246",
"0.5341058",
"0.53409344",
"0.5304023",
"0.52745706",
"0.5265222",
"0.5215288",
"0.5210394",
"0.51994467"... | 0.80186594 | 0 |
Get a list of Fax History. | def get_fax_history(date_from = nil,
date_to = nil,
q = nil,
order = nil)
# Prepare query url.
_query_builder = Configuration.base_uri.dup
_query_builder << '/fax/history'
_query_builder = APIHelper.append_url_with_query_parameters(
_query_builder,
{
'date_from' => date_from,
'date_to' => date_to,
'q' => q,
'order' => order
},
array_serialization: Configuration.array_serialization
)
_query_url = APIHelper.clean_url _query_builder
# Prepare and execute HttpRequest.
_request = @http_client.get(
_query_url
)
BasicAuth.apply(_request)
_context = execute_request(_request)
# Validate response against endpoint and global error codes.
return nil if _context.response.status_code == 404
validate_response(_context)
# Return appropriate response type.
_context.response.raw_body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fax_history_get(api_key, opts = {})\n fax_history_get_with_http_info(api_key, opts)\n return nil\n end",
"def filing_history_list(company_number, category = nil, items_per_page = nil, start_index = nil)\n params = {category: category}\n params[:items_per_page] = items_per_page if i... | [
"0.7071993",
"0.6696848",
"0.64732015",
"0.64437896",
"0.64348733",
"0.64341384",
"0.63811946",
"0.6302121",
"0.6215293",
"0.61590374",
"0.61559445",
"0.61515623",
"0.61515623",
"0.61101437",
"0.6091837",
"0.60236305",
"0.60084295",
"0.60033023",
"0.5991136",
"0.59829336",
"0... | 0.72762644 | 0 |
Calculate Total Price for Fax Messages sent | def calculate_price(fax_message)
# Validate required parameters.
validate_parameters(
'fax_message' => fax_message
)
# Prepare query url.
_query_builder = Configuration.base_uri.dup
_query_builder << '/fax/price'
_query_url = APIHelper.clean_url _query_builder
# Prepare headers.
_headers = {
'content-type' => 'application/json; charset=utf-8'
}
# Prepare and execute HttpRequest.
_request = @http_client.post(
_query_url,
headers: _headers,
parameters: fax_message.to_json
)
BasicAuth.apply(_request)
_context = execute_request(_request)
# Validate response against endpoint and global error codes.
return nil if _context.response.status_code == 404
validate_response(_context)
# Return appropriate response type.
_context.response.raw_body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subtotal\n fees = [ticket_fees_in_cents].sum\n\n discounted_total + fees\n end",
"def total\n conv_price_single * conv_quantity\n end",
"def fee_cents\n (fee.to_f * 100.0).round\n end",
"def total_price\n total = total_price_without_installments\n if promo... | [
"0.69317925",
"0.6917082",
"0.6870956",
"0.6869014",
"0.6849653",
"0.68239963",
"0.6803939",
"0.6763102",
"0.6750035",
"0.67435247",
"0.6719426",
"0.6698632",
"0.6697778",
"0.6692492",
"0.66778374",
"0.667088",
"0.66626585",
"0.66405225",
"0.66286045",
"0.6624391",
"0.6608973... | 0.681959 | 6 |
Send a fax using supplied supported filetypes. | def send_fax(fax_message)
# Validate required parameters.
validate_parameters(
'fax_message' => fax_message
)
# Prepare query url.
_query_builder = Configuration.base_uri.dup
_query_builder << '/fax/send'
_query_url = APIHelper.clean_url _query_builder
# Prepare headers.
_headers = {
'content-type' => 'application/json; charset=utf-8'
}
# Prepare and execute HttpRequest.
_request = @http_client.post(
_query_url,
headers: _headers,
parameters: fax_message.to_json
)
BasicAuth.apply(_request)
_context = execute_request(_request)
# Validate response against endpoint and global error codes.
return nil if _context.response.status_code == 404
validate_response(_context)
# Return appropriate response type.
_context.response.raw_body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_fax()\n begin\n bodyParams = {\n to: [{ phoneNumber: RECIPIENT }],\n # To send fax to multiple recipients, add more 'phoneNumber' object. E.g.\n #\n # to: [\n # { phoneNumber: \"Recipient1-Phone-Number\" },\n # { phoneNumber: \"Recipient2-Phone-Number\" }\n ... | [
"0.67132324",
"0.6406969",
"0.52849126",
"0.52494866",
"0.5208716",
"0.5202113",
"0.51866937",
"0.517508",
"0.5167899",
"0.5086146",
"0.5060718",
"0.4979663",
"0.4967141",
"0.49550492",
"0.49392366",
"0.4936976",
"0.4907853",
"0.4894837",
"0.48779792",
"0.48726094",
"0.485660... | 0.5084891 | 10 |
a dash in between odd digits. number = 2112 number = 201105742 =begin P how to put the dashes inside two sequence of odd numbers, and also return all the integers in string format E dasherizer(2112) == '2112' dasherizer(201105742) == '201105742' D array string integer A convert the integer to an array iterate through the array if the if else condition returns true =end C result = [] counter = 0 def sequential(number) number.digits.reverse.each_with_index do |num, idx| if idx == num +1 p idx end end end | def sequential(number)
# number.digits.reverse.each_with_index do |num, idx|
# if idx + 1 == num
# return true
# end
# end
number.digits.reverse.all? {|num| num.index + 1 == num }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dasherize_number(num)\n\n arr = num.to_s.split(\"\")\n arr.each do |x|\n if x[0].to_i.odd?\n puts x[0] + \"-\"\n end\nend\n\n # if arr[0].to_i.odd?\n # puts arr[0] + \"-\"\n # elsif arr[arr.length-1].to_i.odd?\n # puts \"-\" + arr[arr.length-1]\n # # elsif x.to_i % 2... | [
"0.7314747",
"0.72452223",
"0.7173576",
"0.71539015",
"0.715088",
"0.7134091",
"0.7093243",
"0.70316416",
"0.6994785",
"0.69769067",
"0.6965943",
"0.6960419",
"0.6958809",
"0.6955352",
"0.69474936",
"0.6919197",
"0.6861141",
"0.67893356",
"0.6719792",
"0.67084855",
"0.6693574... | 0.67874783 | 18 |
Write a method that takes a string, and returns a new string in which every character is doubled. input: string output: string with each character doubled new_str = '' string.chars each do |char| concat to new_str twice end new_str | def repeater(string)
new_string = ''
string.chars.each do |char|
new_string << char << char
end
new_string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def double_characters(string)\n doubled_string = ''\n string.chars.each do |char|\n doubled_string << char * 2\n end\n doubled_string\nend",
"def repeater(string)\n doubled_str = \"\"\n string.each_char do |char|\n doubled_str << char << char\n # doubled_str.concat(char*2)\n # doubled_str.conca... | [
"0.8291636",
"0.8118189",
"0.81104946",
"0.8098799",
"0.8052855",
"0.80496466",
"0.8026236",
"0.790758",
"0.7873894",
"0.7811499",
"0.7790134",
"0.77823216",
"0.7769536",
"0.77689385",
"0.7764012",
"0.776007",
"0.7747943",
"0.77419126",
"0.7723051",
"0.77046347",
"0.77003014"... | 0.7799947 | 10 |
Produces a random university prefix. | def prefix
fetch('university.prefix')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prefix\n (\"aa\"..\"zz\").to_a.sample(2).to_s\n end",
"def create_name\n prefix = ('A'...'Z').to_a.shuffle[0..1].join('')\n suffix = (100..1000).to_a.sample\n \"#{prefix}#{suffix}\"\n end",
"def name_prefix\n Faker::Name.prefix\n end",
"def name_prefix\n Faker::Name.prefi... | [
"0.67843586",
"0.6739261",
"0.67103356",
"0.67103356",
"0.66755575",
"0.6638696",
"0.6542381",
"0.64919627",
"0.64751035",
"0.6459034",
"0.64587235",
"0.6442107",
"0.6375788",
"0.6367254",
"0.63616246",
"0.6360397",
"0.6352027",
"0.63262033",
"0.6324436",
"0.63027674",
"0.627... | 0.69970393 | 0 |
Produces a random university suffix. | def suffix
fetch('university.suffix')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_suffix\n length = 10\n SecureRandom.random_number(36 ** length).to_s(36).rjust(length, '0')\n end",
"def name_suffix\n Faker::Name.suffix\n end",
"def name_suffix\n Faker::Name.suffix\n end",
"def create_name\n prefix = ('A'...'Z').to_a.shuffle[0..1].join('')\n ... | [
"0.7820027",
"0.7701956",
"0.7701956",
"0.71493447",
"0.7126056",
"0.7121794",
"0.69519734",
"0.6873504",
"0.68715507",
"0.6841452",
"0.68146306",
"0.67499286",
"0.67499286",
"0.6697289",
"0.66474015",
"0.66392887",
"0.6633015",
"0.6599822",
"0.65928555",
"0.65899706",
"0.658... | 0.75594825 | 3 |
Produces a random greek organization. | def greek_organization
Array.new(3) { |_| sample(greek_alphabet) }.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def greek_organization; end",
"def random_name\n (1..3).map {\"\" << rand(26) + 65}.to_s\n end",
"def rand_brancket\n (rand(2) == 0) ? \"【#{FFaker::Food.meat}】\" : ''\nend",
"def random_string\n (0...100).map { (\"a\"..\"z\").to_a[rand(26)] }.join\n end",
"def random_string\n (0...100).ma... | [
"0.70085377",
"0.63878703",
"0.6242443",
"0.62397784",
"0.62397784",
"0.6221738",
"0.62148243",
"0.61883605",
"0.61774874",
"0.6172007",
"0.61669487",
"0.6163203",
"0.615962",
"0.61050236",
"0.60813075",
"0.60620695",
"0.6050576",
"0.6020023",
"0.6017904",
"0.60037756",
"0.59... | 0.8013974 | 0 |
Initialize the nodes source from a hash | def from_hash(data)
@query = data["query"]
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n @nodes_hash = Hash.new\n end",
"def initialize()\n @node_cnt = 0;\n @hash_table = Hash.new(); # setup empty hash\n end",
"def initialize(hash)\n load_hash(hash)\n end",
"def initialize hash\n @hash = hash\n end",
"def initialize(source_hash = T.unsafe(nil... | [
"0.6939307",
"0.6699021",
"0.6477873",
"0.6472735",
"0.6459691",
"0.6426589",
"0.62991905",
"0.6249087",
"0.6224365",
"0.61986375",
"0.61808634",
"0.61592644",
"0.61537796",
"0.6144023",
"0.61425793",
"0.6131295",
"0.61296797",
"0.6096459",
"0.60719067",
"0.6054179",
"0.59945... | 0.0 | -1 |
Performs the PQL query and extracts certnames | def discover
choria.pql_query(@query, true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def certificate_list\n certificates = self.certs #[0].certificate.name\n list = certificates.collect! {|x| x.certificate.name + \"; \" }\n list.join()\n end",
"def list\n Puppet::SSL::Certificate.search(\"*\").collect { |c| c.name }\n end",
"def facts_for_node(certnames)\n return {}... | [
"0.64783525",
"0.6236605",
"0.61883014",
"0.60686946",
"0.5965756",
"0.58277935",
"0.57840174",
"0.57155144",
"0.56514424",
"0.5544667",
"0.5510741",
"0.5498993",
"0.547499",
"0.54639333",
"0.5434128",
"0.5349916",
"0.53064936",
"0.5272128",
"0.52515805",
"0.5228193",
"0.5184... | 0.0 | -1 |
but for 10 monkeys. Three little monkeys jumping on the bed, One fell off and bumped his head, Mama called the doctor and the doctor said, "No more monkeys jumping on the bed!" takes the number of monkeys 'n' and outputs a nusery rhyme | def monkey(n)
i = n
loop do
if i > 1
p "#{i} little monkeys jumping on the bed,"
p "One fell off and bumped his head,"
p "Mama called the doctor and the doctor said,"
p "No more monkeys jumping on the bed"
else
p "#{i} little monkey jumping on the bed,"
p "One fell off and bumped his head,"
p "Mama called the doctor and the doctor said,"
p "Get those monkeys right to bed!"
return 0
end
i -= 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def little_monkeys(num)\n i = num\n num.times do\n # For the last monkey, the nursery line is different\n if (i == 1)\n print \"#{i} little monkey jumping on the bed.\\n He fell off and bumped his head,\\n Mama called the doctor and the doctor said,\\n Get those monkeys right to bed!\\n\"\n else\n ... | [
"0.7396693",
"0.73712915",
"0.7323625",
"0.71249104",
"0.6897404",
"0.66471684",
"0.6636932",
"0.66321254",
"0.66190565",
"0.66132486",
"0.6589095",
"0.6560727",
"0.6492021",
"0.64732814",
"0.6451566",
"0.6419764",
"0.63660914",
"0.6364666",
"0.6345253",
"0.6327469",
"0.63067... | 0.7256068 | 3 |
puts "this is a debug message" | def solution(n)
open = false
current = 0
max = 0
begin
if n % 2 == 1
open = true
max = [max, current].max
current = 0
else
current += 1 if open
end
end while (n /= 2) > 0
max
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debug(msg)\n #puts msg\n end",
"def debug(s)\n\t#puts \"DEBUG: #{s}\"\nend",
"def print_debug(msg)\n puts msg if (@debug) \n STDOUT.flush\n end",
"def debug(message)\n puts message if debug?\n end",
"def debug(s) if $DEBUG then $stderr.print(\"#{s}\\n\") end end",
"def debug_ms... | [
"0.8406359",
"0.8268479",
"0.8211071",
"0.8138492",
"0.8107914",
"0.80671936",
"0.8004696",
"0.79987866",
"0.7975501",
"0.7975501",
"0.7975501",
"0.79284",
"0.78572273",
"0.78488684",
"0.7837523",
"0.7821288",
"0.7821288",
"0.7792199",
"0.7773948",
"0.7743215",
"0.7739327",
... | 0.0 | -1 |
Complete the makeAnagram function below. | def makeAnagram(a, b)
# Remove characters present in both strings
a.each_char do |chr|
if b.include?(chr)
a.sub!(chr,''); b.sub!(chr,'')
end
end
b.each_char do |chr|
if a.include?(chr)
a.sub!(chr,''); bsub!(chr,'')
end
end
# Return the length of both strings combined
return (a+b).length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_anagram(text)\n\nend",
"def combine_anagrams_method2(words)\n\ttemp1 = Array.new\n\ttemp1 = words.clone\t# making a deep copy of the input \n\tanagram = Array.new\t\n\ti = 0\n\twhile i < temp1.length\t\t\t\n\t\tcount = 0 # count the number of anagrams of a particular string say \"cars\"\n\t\tfor j in... | [
"0.8006553",
"0.75655043",
"0.7468529",
"0.74314684",
"0.7403261",
"0.7390342",
"0.7306981",
"0.72848207",
"0.72834307",
"0.728311",
"0.72682965",
"0.72609633",
"0.725796",
"0.7257263",
"0.72457916",
"0.7239651",
"0.72140956",
"0.72008026",
"0.71833676",
"0.7176667",
"0.71332... | 0.0 | -1 |
not yet supported tries to transform the encrypted file | def test_encrypt_variant
path = "test/support/image.png"
User.create!(avatar: {io: File.open(path), filename: "image.png", content_type: "image/png"})
user = User.last
error = assert_raises(Lockbox::Error) do
user.avatar.variant(resize: "500x500").processed
end
assert_equal "Variant not supported for encrypted files", error.message
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _encrypt\n cryptor_files(@encrypting)\n end",
"def encrypt_file(filename)\n #open the file by passing it the name and ..\n input = File.open(filename, 'r')\n #this is a string now so\n contents = input.read\n encrypted_contents = encrypt_string(contents)\n input.close\n output... | [
"0.7011238",
"0.66213244",
"0.6603866",
"0.64203644",
"0.63618094",
"0.62742245",
"0.62620693",
"0.62484926",
"0.5987304",
"0.5969199",
"0.59615564",
"0.5949683",
"0.59090906",
"0.5849061",
"0.57809436",
"0.573496",
"0.573496",
"0.5727793",
"0.5696474",
"0.56943",
"0.567588",... | 0.0 | -1 |
not yet supported tries to transform the encrypted file succeeds, but unreadable | def test_encrypt_preview
path = "test/support/doc.pdf"
User.create!(avatar: {io: File.open(path), filename: "doc.pdf", content_type: "application/pdf"})
user = User.last
error = assert_raises(Lockbox::Error) do
user.avatar.preview(resize: "500x500").processed.blob.download
end
assert_equal "Preview not supported for encrypted files", error.message
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _encrypt\n cryptor_files(@encrypting)\n end",
"def encrypt_file(filename)\n #open the file by passing it the name and ..\n input = File.open(filename, 'r')\n #this is a string now so\n contents = input.read\n encrypted_contents = encrypt_string(contents)\n input.close\n output... | [
"0.6493421",
"0.6412665",
"0.63822883",
"0.61049557",
"0.60796547",
"0.5963469",
"0.5852251",
"0.5852251",
"0.5851009",
"0.5799186",
"0.576298",
"0.5683427",
"0.56497097",
"0.5620898",
"0.5613746",
"0.5590169",
"0.5537592",
"0.55332536",
"0.55025697",
"0.5482787",
"0.5467161"... | 0.5301803 | 25 |
you must have this method for the restful server to work correctly | def next_messages_id
messages.max{|a,b| a[:id] <=> b[:id]}[:id] + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rest_endpoint; end",
"def rest_end_point; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def endpoint; en... | [
"0.73777914",
"0.7216175",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.68859977",
"0.68859977",
"0.68859977",
"0.68859977",
"0.6837594",
"0.6796331",
"0.67017716",
... | 0.0 | -1 |
=begin Populate the reports table =end | def add_report(database, hash)
sql = "INSERT INTO reports(reporter_name, reporter_state, reporter_phone, hero_seen, suspect_name, powers_displayed) VALUES (?,?,?,?,?,?)"
database.execute(sql, [ hash["reporter_name"], hash["reporter_state"], hash["reporter_phone"], hash["hero_seen"], hash["suspect_name"], hash["powers_displayed"]])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_report\n validate_required_fields\n @report = []\n @report << header\n\n (number_of_intervals - 1).times do |row|\n @report << build_row(row)\n end\n @report\n end",
"def create_report\n\tcreate_rep_heading\n \tcreate_product_data\n \tcreate_brand_data\nend",
"def reports... | [
"0.663138",
"0.66060215",
"0.6538197",
"0.6534105",
"0.6523132",
"0.6396172",
"0.63669175",
"0.63016564",
"0.6268179",
"0.6268179",
"0.62502116",
"0.62502116",
"0.62502116",
"0.62502116",
"0.62502116",
"0.6192223",
"0.61901",
"0.6127287",
"0.611253",
"0.60984886",
"0.60544926... | 0.5453618 | 89 |
Write methods to count entries in the database | def count_all_entries(database)
sql = <<-SQL
SELECT hero_seen, COUNT(*) c FROM reports GROUP BY hero_seen HAVING c > 1
SQL
p database.execute(sql)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count\n query.count\n end",
"def count\n query.count\n end",
"def count\n end",
"def count\n end",
"def count ; @count ||= table.count end",
"def count\n @rows.count\n end",
"def count; end",
"def count; end",
"def count; end",
"def count\n ensure_aggr... | [
"0.7699294",
"0.7699294",
"0.7676923",
"0.7676923",
"0.76268554",
"0.76157457",
"0.757475",
"0.757475",
"0.757475",
"0.7565778",
"0.7450868",
"0.74292016",
"0.74292016",
"0.74292016",
"0.7420494",
"0.7420494",
"0.7402095",
"0.7395923",
"0.7389295",
"0.7376843",
"0.726408",
... | 0.66495174 | 91 |
Write a method to assign investigators to reports | def assign_investigator(database)
sql = <<-SQL
UPDATE reports
SET investigator_id = (SELECT id
FROM investigators
WHERE jurisdiciton = reports.reporter_state)
SQL
database.execute(sql)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_report\n end",
"def reporters=(_arg0); end",
"def reporters=(_arg0); end",
"def reporters=(_arg0); end",
"def populate_reports\n\t\tauthor_id \t\t= [*1..40].sample\n\t\tsummary \t\t= Faker::Lorem.sentences(3).join(' ')\n\t\treason \t\t\t= [*0..4].sample # enum\n\t\t\n\t\t# Report on other users\n\... | [
"0.62604725",
"0.6214742",
"0.6214742",
"0.6214742",
"0.6019624",
"0.5996599",
"0.5996599",
"0.5996599",
"0.5996599",
"0.5996599",
"0.5986752",
"0.5965059",
"0.588282",
"0.57194006",
"0.56787777",
"0.56340384",
"0.5542408",
"0.55327743",
"0.5513858",
"0.5503708",
"0.54496783"... | 0.5369833 | 27 |
Use callbacks to share common setup or constraints between actions. | def set_condition
@condition = Condition.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def condition_params
params.require(:condition).permit(:name, :description, :page)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7122899",
"0.7054107",
"0.69478",
"0.6902101",
"0.67359334",
"0.67178756",
"0.66889167",
"0.6677724",
"0.6661157",
"0.6555896",
"0.6527207",
"0.64584696",
"0.64517015",
"0.6450208",
"0.644749",
"0.6435074",
"0.6413329",
"0.6413329",
"0.6391818",
"0.6380081",
"0.6380081",
... | 0.0 | -1 |
Public: Prevents sensitive data from being logged event An ActiveSupport::Notifications::Event Returns a boolean. | def sql(event)
payload = crypt_keeper_payload_parse(event.payload[:sql])
event.payload[:sql] = crypt_keeper_filter_postgres_log(payload)
super(event)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter\n # #YELLOW\n if @event['check']['alert'] == false # rubocop:disable GuardClause\n puts 'alert disabled -- filtered event ' + [@event['client']['name'], @event['check']['name']].join(' : ')\n exit 0\n end\n end",
"def eventless?\n ! @event\n end",
"def logged?;\n false\n ... | [
"0.5934395",
"0.58624554",
"0.5790343",
"0.57145536",
"0.5683298",
"0.5676754",
"0.5669113",
"0.56580365",
"0.5626442",
"0.56089544",
"0.5577541",
"0.5576838",
"0.55754256",
"0.55548155",
"0.55195886",
"0.5505172",
"0.5502863",
"0.5481289",
"0.5478906",
"0.5406223",
"0.539463... | 0.0 | -1 |
Private: Parses the payload to UTF. payload the payload string Returns a string. | def crypt_keeper_payload_parse(payload)
payload.encode('UTF-8', 'binary',
invalid: :replace, undef: :replace, replace: '')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_payload\n raise EmptyPayloadException.new unless payload\n raise PayloadEncodingException.new unless payload.encoding.to_s == \"UTF-8\"\n raise PayloadFormattingException.new if payload =~ / /\n end",
"def validate_payload_encoding\n\t\t\tif self.opcode == :binary\n\t\t\t\tself.log.debug \... | [
"0.62006783",
"0.58458453",
"0.5787604",
"0.5679404",
"0.5602987",
"0.55685115",
"0.5510762",
"0.54461074",
"0.54351884",
"0.5427805",
"0.5420967",
"0.5415065",
"0.535099",
"0.5347051",
"0.5338113",
"0.53340226",
"0.53127503",
"0.5300515",
"0.52610123",
"0.5240466",
"0.524046... | 0.7363163 | 0 |
Private: Filters the payload. payload the payload string Returns a string. | def crypt_keeper_filter_postgres_log(payload)
payload.gsub(FILTER) do |_|
"#{$~[:operation]}([FILTERED])"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter(val)\n raise \"filter requires a String.\" unless val.is_a? String\n @filter = val\n self\n end",
"def filter_string\n\t\treturn self.filter.to_s\n\tend",
"def filter(editable_payload, level, event_name)\n raise NotImplementedError,\n 'You must implement the met... | [
"0.57931453",
"0.5738752",
"0.56381243",
"0.5625995",
"0.55760115",
"0.5547066",
"0.5518767",
"0.5470776",
"0.5434641",
"0.5420411",
"0.5351926",
"0.5351926",
"0.53260195",
"0.5282426",
"0.52692515",
"0.5251239",
"0.52099776",
"0.5193109",
"0.5188539",
"0.5187708",
"0.5187708... | 0.66911334 | 0 |
Obter permissao por ID | def set_permissao
@permissao = Permissao.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_permissao\n @permissao = Permissao.find(params[:id])\n end",
"def id\r\n @id\r\n end",
"def id\n params[:id] \n end",
"def id\n @id\n end",
"def id\n @id\n end",
"def id\n @id\n end",
"def id\n @id\n end",
"def id\n @id\n end... | [
"0.701032",
"0.65891343",
"0.6481307",
"0.6470133",
"0.6470133",
"0.6470133",
"0.6470133",
"0.6469563",
"0.6430303",
"0.6430303",
"0.64282185",
"0.6416224",
"0.64067334",
"0.63816607",
"0.63799083",
"0.6365792",
"0.63585514",
"0.6351894",
"0.63220143",
"0.63129836",
"0.630654... | 0.69548637 | 2 |
Sets up this module to make API calls. The first argument is the developer's API key. The other three are the URLs corresponding to the three parts of the api. No API calls will work until this function is called. API objects will only be instantiated for URLs that are passed in. Arguments: api_key The developer's API key servers How the server URLs should be set. Must be :production, :test, or :custom restaurant_url The base url for the restaurant API. Can only be set if servers==:custom. user_url The base url for the user API. Can only be set if servers==:custom. order_url The base url for the order API. Can only be set if servers==:custom. | def initialize(api_key, servers, restaurant_url=nil, user_url=nil, order_url=nil)
@api_key = api_key
if servers!=:custom
unless restaurant_url.nil? and user_url.nil? and order_url.nil?
raise ArgumentError.new("Individual URL parameters can only be set if servers is set to :custom")
end
end
if servers==:production
restaurant_url = "https://r.ordr.in/"
user_url = "https://u.ordr.in/"
order_url = "https://o.ordr.in/"
elsif servers==:test
restaurant_url = "https://r-test.ordr.in/"
user_url = "https://u-test.ordr.in/"
order_url = "https://o-test.ordr.in/"
elsif servers!=:custom
raise ArgumentError.new("servers must be set to :production, :test, or :custom")
end
unless restaurant_url.nil?
@restaurant = RestaurantApi.new(api_key, restaurant_url)
end
unless user_url.nil?
@user = UserApi.new(api_key, user_url)
end
unless order_url.nil?
@order = OrderApi.new(api_key, order_url)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(api_url:, api_key:, verbose: false)\n self.api_url = api_url.is_a?(Addressable::URI) ? api_url : Addressable::URI.parse(api_url)\n self.api_key = api_key\n self.verbose = verbose\n end",
"def initialize(api_key:, url_prefix:)\n @api_key = api_key\n @url_prefix = url_pre... | [
"0.66801316",
"0.6490914",
"0.6483077",
"0.6398358",
"0.6366513",
"0.63611907",
"0.636038",
"0.6358908",
"0.6353611",
"0.6291196",
"0.6273451",
"0.62396616",
"0.62153476",
"0.6182823",
"0.6145325",
"0.6129982",
"0.6129982",
"0.6090915",
"0.60746026",
"0.606189",
"0.606037",
... | 0.77412903 | 0 |
GET /keystrokes/1 GET /keystrokes/1.json | def show
@keystroke = Keystroke.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @keystroke }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @keystroke = Keystroke.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @keystroke }\n end\n end",
"def destroy\n @keystroke = Keystroke.find(params[:id])\n @keystroke.destroy\n\n respond_to do |format|\n format.html { redirect_t... | [
"0.6878949",
"0.61304903",
"0.5849774",
"0.57377934",
"0.57247007",
"0.5721642",
"0.5517294",
"0.54333633",
"0.54104704",
"0.53931254",
"0.5384326",
"0.5371188",
"0.5366341",
"0.53542",
"0.5346104",
"0.5280844",
"0.5267479",
"0.5240085",
"0.52262574",
"0.52258515",
"0.5220722... | 0.7360926 | 0 |
GET /keystrokes/new GET /keystrokes/new.json | def new
@keystroke = Keystroke.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @keystroke }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @key = Key.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @key }\n end\n end",
"def create\n @keystroke = Keystroke.new(params[:keystroke])\n\n respond_to do |format|\n if @keystroke.save\n format.html { redirect_to @keystr... | [
"0.68736017",
"0.6770503",
"0.6457825",
"0.6423651",
"0.6397754",
"0.62544847",
"0.6229272",
"0.622481",
"0.6159139",
"0.6154632",
"0.61148155",
"0.6052795",
"0.6015635",
"0.5947372",
"0.59089154",
"0.5897333",
"0.58628786",
"0.58190656",
"0.58084196",
"0.5785126",
"0.5765239... | 0.80335706 | 0 |
POST /keystrokes POST /keystrokes.json | def create
@keystroke = Keystroke.new(params[:keystroke])
respond_to do |format|
if @keystroke.save
format.html { redirect_to @keystroke, notice: 'Keystroke was successfully created.' }
format.json { render json: @keystroke, status: :created, location: @keystroke }
else
format.html { render action: "new" }
format.json { render json: @keystroke.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @keystroke = Keystroke.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @keystroke }\n end\n end",
"def key_stroke(keycodeText)\n append_to_script \"key_stroke \\\"#{keycodeText}\\\"\"\n end",
"def keystroke(character, *special_keys)\n ... | [
"0.64852476",
"0.58864564",
"0.56439817",
"0.5606263",
"0.5569623",
"0.54804087",
"0.5454897",
"0.54340047",
"0.54230803",
"0.54145926",
"0.5387479",
"0.53107893",
"0.5290351",
"0.521464",
"0.5178139",
"0.517775",
"0.5176327",
"0.5139103",
"0.5129177",
"0.51184237",
"0.509775... | 0.67166984 | 0 |
PUT /keystrokes/1 PUT /keystrokes/1.json | def update
@keystroke = Keystroke.find(params[:id])
respond_to do |format|
if @keystroke.update_attributes(params[:keystroke])
format.html { redirect_to @keystroke, notice: 'Keystroke was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @keystroke.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @key.update(key_params)\n render json: @key\n else\n render json: @key.errors, status: :unprocessable_entity\n end\n end",
"def update\n @key = Key.find(params[:id])\n\n respond_to do |format|\n if @key.update_attributes(params[:key])\n format.html { redirect... | [
"0.6206077",
"0.6018809",
"0.5901821",
"0.58911437",
"0.5871408",
"0.5773485",
"0.57012445",
"0.5536976",
"0.55151796",
"0.5501271",
"0.5458104",
"0.54576004",
"0.54575896",
"0.5456714",
"0.5422416",
"0.5420822",
"0.54191434",
"0.54185015",
"0.5417782",
"0.54141974",
"0.54088... | 0.6978473 | 0 |
DELETE /keystrokes/1 DELETE /keystrokes/1.json | def destroy
@keystroke = Keystroke.find(params[:id])
@keystroke.destroy
respond_to do |format|
format.html { redirect_to keystrokes_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @key = Key.find(params[:id])\n @key.destroy\n\n respond_to do |format|\n format.html { redirect_to keys_url }\n format.json { head :no_content }\n end\n end",
"def delete(key)\n\n end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def de... | [
"0.653288",
"0.64250773",
"0.62421864",
"0.62421864",
"0.62421864",
"0.62421864",
"0.62421864",
"0.6230025",
"0.6228251",
"0.6226594",
"0.6204302",
"0.62005967",
"0.61666894",
"0.6131496",
"0.6129134",
"0.61017936",
"0.6052575",
"0.6027302",
"0.60168105",
"0.5990207",
"0.5968... | 0.76622117 | 0 |
Deep merges a hash into the current one. Does the replacement inline. | def deep_merge!(other_hash)
replace(deep_merge(other_hash))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deep_merge!(target, hash); end",
"def deep_merge!(target, hash); end",
"def deep_merge(source, hash); end",
"def deep_merge(source, hash); end",
"def _deep_merge(hash, other_hash); end",
"def deep_merge!(other_hash, &block); end",
"def deep_merge(other_hash, &blk)\n dup.deep_update(other_hash,... | [
"0.81512463",
"0.81512463",
"0.81166834",
"0.81166834",
"0.8034445",
"0.8010219",
"0.7981146",
"0.78501296",
"0.78128976",
"0.7785522",
"0.7775746",
"0.7736207",
"0.7617191",
"0.75860125",
"0.7501324",
"0.7501324",
"0.7501324",
"0.74578816",
"0.7442821",
"0.7440934",
"0.74401... | 0.775494 | 11 |
Recursively turns all Hash keys into strings and returns the new Hash. | def deep_stringify_keys
deep_transform_keys { |key| key.to_s }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursively_stringify_key\n recursively_transform_keys { |key| key.to_s rescue key }\n end",
"def stringify_keys_recursively!(object); end",
"def stringify_hash_keys(hash); end",
"def stringify_keys(hash)\n hash.keys.each do |key|\n hash[key.to_s] = hash.delete(key)\n end\n\n hash.value... | [
"0.72633404",
"0.71566606",
"0.70636654",
"0.7050045",
"0.6997724",
"0.6990818",
"0.69707817",
"0.69549423",
"0.69386655",
"0.69386655",
"0.69386655",
"0.69386655",
"0.68764436",
"0.68764436",
"0.68065816",
"0.6724441",
"0.6686069",
"0.6684792",
"0.66827816",
"0.6652935",
"0.... | 0.68121076 | 14 |
Same as deep_stringify_keys, but destructively alters the original Hash. | def deep_stringify_keys!
deep_transform_keys! { |key| key.to_s }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deep_stringify_keys(hash)\n hash.each_with_object({}) do |(key, value), new_hash|\n new_hash[key.to_s] = (value.respond_to?(:to_hash) ? deep_stringify_keys(value) : value)\n end\n end",
"def deep_stringify_keys(hash)\n transform_hash(hash, :deep => true) {|hash, key, value|\n hash[key... | [
"0.86015433",
"0.85657835",
"0.8476922",
"0.8421899",
"0.8348552",
"0.831608",
"0.831608",
"0.8256514",
"0.81885153",
"0.80194205",
"0.78287435",
"0.78104407",
"0.78015244",
"0.78015244",
"0.78015244",
"0.77969253",
"0.7758662",
"0.7617578",
"0.7515673",
"0.74928087",
"0.7473... | 0.8360348 | 4 |
Recursively turns all Hash keys into symbols and returns the new Hash. | def deep_symbolize_keys
deep_transform_keys { |key| key.to_sym rescue key }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive_symbolize_keys hash\n if !hash.is_a?(Hash)\n return hash\n end\n \n new_hash = {}\n hash.each_pair do |key, value|\n new_hash[key.to_sym] = recursive_symbolize_keys(value)\n end\n new_hash\n end",
"def symbolify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do ... | [
"0.73629147",
"0.726877",
"0.726877",
"0.726877",
"0.726877",
"0.70778453",
"0.7056075",
"0.7055467",
"0.70521283",
"0.7020765",
"0.70083773",
"0.6997562",
"0.69719225",
"0.6931987",
"0.69116884",
"0.69116884",
"0.6843562",
"0.6800844",
"0.6799091",
"0.6791407",
"0.67874247",... | 0.66206396 | 42 |
Same as deep_symbolize_keys, but destructively alters the original Hash. | def deep_symbolize_keys!
deep_transform_keys! { |key| key.to_sym rescue key }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deep_symbolize_keys!(hash)\n hash.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n hash[ks] = hash.delete(k)\n deep_symbolize_keys!(hash[ks]) if hash[ks].kind_of?(Hash)\n end\n\n hash\n end",
"def deep_symbolize_keys!(hash)\n hash.key... | [
"0.8645186",
"0.8645186",
"0.85175216",
"0.8473024",
"0.8473024",
"0.8470794",
"0.8439782",
"0.8371661",
"0.83615303",
"0.8325609",
"0.826378",
"0.82129043",
"0.81734806",
"0.81734806",
"0.7987722",
"0.7962561",
"0.7760612",
"0.7759983",
"0.7756569",
"0.7709715",
"0.77062535"... | 0.8461017 | 8 |
Generic method to perform recursive operations on a Hash. | def deep_transform_keys(&block)
_deep_transform_keys_in_object(self, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dehash(hash, depth); end",
"def recalculate_hash_at(node)\n return node._hash = node.value if node.value\n recalculate_hash_at(node.left) if node.left\n recalculate_hash_at(node.right) if node.right\n node._hash = self.class.hash_children(*node_subhashes(node))\n end",
"def recursive_hash_norm... | [
"0.6629245",
"0.6446206",
"0.6275461",
"0.61290985",
"0.60396487",
"0.59696573",
"0.59684175",
"0.59684175",
"0.5968182",
"0.5968182",
"0.5959937",
"0.587134",
"0.5853964",
"0.5846395",
"0.5825159",
"0.5822239",
"0.5783169",
"0.57701015",
"0.57627857",
"0.57343155",
"0.572865... | 0.0 | -1 |
Same as deep_transform_keys, but destructively alters the original Hash. | def deep_transform_keys!(&block)
_deep_transform_keys_in_object!(self, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deep_transform_keys!(hash, &block)\n _deep_transform_keys_in_object!(hash, &block)\n end",
"def deep_transform_keys!(&block)\n keys.each do |key|\n value = delete(key)\n self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value\n end\n self\n end",
"d... | [
"0.7925652",
"0.78578633",
"0.78578633",
"0.7820687",
"0.7645839",
"0.76293904",
"0.7611521",
"0.7605508",
"0.7597604",
"0.7543796",
"0.7543796",
"0.7289229",
"0.7184595",
"0.71616143",
"0.71616143",
"0.7098988",
"0.70942605",
"0.70734215",
"0.7041662",
"0.6975899",
"0.694385... | 0.772875 | 7 |
Allows for dotnotation getting/setting within a Hash. | def method_missing(meth, *args, &block)
meth_name = meth.to_s
if meth_name[-1,1] == '='
self[meth_name[0..-2].to_sym] = args[0]
else
self[meth] || self[meth_name]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dotify(h)\n h.use_dot_syntax = true; h.keys.each{|k| dotify(h[k]) if h[k].is_a?(::Hash)}\n end",
"def [](key)\n raise InvalidDot unless @@dots.keys.include? key.to_s\n dot = @@dots[key.to_s]\n dot.respond_to?(:call) ? dot.call : dot\n end",
"def dig(hashlike, key)\n return hashlike unles... | [
"0.6991673",
"0.66025126",
"0.64070123",
"0.6051455",
"0.59886587",
"0.59252495",
"0.5917571",
"0.58915424",
"0.58915424",
"0.58915424",
"0.58915424",
"0.5769708",
"0.5768234",
"0.57667917",
"0.5766441",
"0.5766174",
"0.5747382",
"0.57413435",
"0.5726385",
"0.570802",
"0.5675... | 0.5299494 | 95 |
Recursively searches a hash for the passed key and returns the value (if there is one). | def recursive_find_by_key(key)
# Create a stack of hashes to search through for the needle which
# is initially this hash
stack = [ self ]
# So long as there are more haystacks to search...
while (to_search = stack.pop)
# ...keep searching for this particular key...
to_search.each do |k, v|
# ...and return the corresponding value if it is found.
return v if (k == key)
# If this value can be recursively searched...
if (v.respond_to?(:recursive_find_by_key))
# ...push that on to the list of places to search.
stack << v
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(key)\n if @root.nil?\n return nil\n elsif @root.key == key\n return @root.value\n else\n find_helper(@root, key)\n end\n end",
"def nested_hash_value(obj, key)\n if obj.respond_to?(:key?) && obj.key?(key)\n obj[key]\n elsif obj.respond_to?(:each)\n r =... | [
"0.70975167",
"0.7043736",
"0.70150083",
"0.6986737",
"0.6805482",
"0.67907053",
"0.6748154",
"0.6737833",
"0.67356384",
"0.6659147",
"0.66122466",
"0.6604083",
"0.6591171",
"0.65721726",
"0.6565527",
"0.6554034",
"0.65409863",
"0.6517451",
"0.65037924",
"0.6502858",
"0.64837... | 0.71257895 | 0 |
Modification to deep_transform_keys that allows for the existence of arrays. | def _deep_transform_keys_in_object(object, &block)
case object
when Hash
object.each_with_object({}) do |(key, value), result|
result[yield(key)] = _deep_transform_keys_in_object(value, &block)
end
when Array
object.map { |e| _deep_transform_keys_in_object(e, &block) }
else
object
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deep_transform_keys(&block); end",
"def deep_transform_keys!(&block); end",
"def ensure_keys_are_arrays!(result)\n if result[:startkey] && !result[:startkey].is_a?(Array)\n result[:startkey] = [result[:startkey]] \n end\n if result[:endkey] && !result[:endkey].is_a?(Array)\n ... | [
"0.69917476",
"0.68667346",
"0.65220803",
"0.64828104",
"0.62346137",
"0.6214888",
"0.60685915",
"0.60174716",
"0.6002079",
"0.6002079",
"0.5975081",
"0.5874423",
"0.5874423",
"0.5874423",
"0.5874423",
"0.5810823",
"0.58036363",
"0.5742876",
"0.57329255",
"0.571946",
"0.57166... | 0.0 | -1 |
Same as _deep_transform_keys_in_object, but destructively alters the original Object. | def _deep_transform_keys_in_object!(object, &block)
case object
when Hash
object.keys.each do |key|
value = object.delete(key)
object[yield(key)] = _deep_transform_keys_in_object!(value, &block)
end
object
when Array
object.map! { |e| _deep_transform_keys_in_object!(e, &block) }
else
object
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _deep_transform_keys_in_object!(object, &block)\n case object\n when Hash\n object.keys.each do |key|\n value = object.delete(key)\n object[yield(key)] = _deep_transform_keys_in_object!(value, &block)\n end\n object\n when Array\n object.map! {|e| _deep_transform_keys... | [
"0.78892326",
"0.77043843",
"0.77043843",
"0.77043843",
"0.77043843",
"0.76552725",
"0.75506014",
"0.75368303",
"0.7516592",
"0.7516592",
"0.7516585",
"0.74636364",
"0.7456295",
"0.7442446",
"0.7335532",
"0.73181593",
"0.73181593",
"0.72149193",
"0.7202065",
"0.71459836",
"0.... | 0.7855041 | 1 |
Set type of the record class. | def set_type(name)
@type = name
ProcessRecord::TYPE_TABLE[name] = self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_type(val)\n self.type = val\n self\n end",
"def record_type(t)\n @type = t\n end",
"def class_type=(value)\n\t\tself[:type] = value\n\tend",
"def set_type(v)\n self.type = v\n self\n end",
"def set_type\n end",
"def record_type=(record_type)\n ... | [
"0.7840313",
"0.76835203",
"0.7612753",
"0.75990415",
"0.73978096",
"0.7242904",
"0.7220759",
"0.71676236",
"0.7134282",
"0.7063471",
"0.7063471",
"0.7063471",
"0.7063471",
"0.7063471",
"0.7063471",
"0.7063471",
"0.7057944",
"0.7048537",
"0.6989812",
"0.69888467",
"0.6975195"... | 0.7379305 | 5 |
Declare to append the named field into records. | def field(name)
unless (@fields ||= []).include?(name)
@fields << name
# field reader
define_method(name) do
instance_variable_get("@%s" % name)
end
# field writer
define_method("%s=" % name) do |val|
val = Time.parse(val) if name == :timestamp and val.kind_of?(String)
instance_variable_set("@%s" % name, val)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append_with(name)\n prepare do\n document[field] = [] unless document[field]\n docs = document.send(field).concat(value.__array__)\n execute(name)\n docs\n end\n end",
"def <<(field)\n list[field.name] = field\n end",
"def field(name)... | [
"0.7526918",
"0.68954945",
"0.6804112",
"0.6734768",
"0.6734768",
"0.6644679",
"0.6588441",
"0.64024127",
"0.6393955",
"0.6364608",
"0.63316226",
"0.6285384",
"0.62451446",
"0.62223333",
"0.61488223",
"0.6087286",
"0.6072084",
"0.60603654",
"0.6044775",
"0.60289073",
"0.59586... | 0.57112586 | 32 |
Subclass inherites superclass's fields. | def inherited(subclass)
subclass.instance_variable_set(:@__ignore_identities__, @__ignore_identities__.clone)
subclass.instance_variable_set(:@fields, @fields.clone)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inherited(subclass)\n super\n subclass.fields = fields.dup\n end",
"def inherited(subclass)\n subclass.instance_variable_set(\"@fields\", fields.dup)\n subclass.instance_variable_set(\"@relations\", relations.dup)\n end",
"def inherited(subclass)\n super\n... | [
"0.82873887",
"0.78663033",
"0.7751325",
"0.7615113",
"0.7586807",
"0.732785",
"0.7183797",
"0.71493727",
"0.70992875",
"0.69389707",
"0.69261026",
"0.69217896",
"0.69180936",
"0.68682444",
"0.68166894",
"0.67152816",
"0.6712096",
"0.6712096",
"0.67065984",
"0.6606857",
"0.65... | 0.80845064 | 1 |
Create a copy of the record and merge the data into it. | def merge(data)
ProcessRecord.build(to_hash).tap do |record|
data.each do |key, val|
record.send("%s=" % key, val)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge!(another_record)\n new_one = self.dup\n [:last, :first, :sex, :birthday, :age, :address, :phone, :email].each do |key|\n if new_val = another_record.send(key)\n self.send(\"#{key}=\", new_val)\n end\n end\n end",
"def update\n record.assign_attributes(data)... | [
"0.6531004",
"0.62242603",
"0.6178848",
"0.6129191",
"0.61047024",
"0.60965014",
"0.60790074",
"0.60671216",
"0.59986126",
"0.5986893",
"0.5986893",
"0.5944973",
"0.5940512",
"0.5869412",
"0.586248",
"0.58532983",
"0.5796624",
"0.5792037",
"0.5788421",
"0.57796067",
"0.575166... | 0.56871533 | 26 |
Format as a JSON string. | def format(log_id)
JSON.dump(to_hash.merge(log_id: log_id))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_json(*_args)\n to_s\n end",
"def formatJSON\n # @formattedContents = .... whatever puts it into JSON\n end",
"def to_nice_json\n JSON.pretty_generate to_hash\n end",
"def to_nice_json\n JSON.pretty_generate to_hash\n end",
"def as_json\n to_s.as_jso... | [
"0.7607748",
"0.74476594",
"0.7384055",
"0.7384055",
"0.7280277",
"0.72080034",
"0.7206955",
"0.71539444",
"0.7143885",
"0.71332574",
"0.7044647",
"0.70366114",
"0.70276845",
"0.7013362",
"0.69889325",
"0.69862163",
"0.696661",
"0.69483006",
"0.6933895",
"0.6916874",
"0.68901... | 0.0 | -1 |
Convert the record into a hash table. | def to_hash
fields.inject({type: type}) do |table, name|
table.tap do
if val = send(name)
val = val.iso8601(3) if name == :timestamp
table[name] = val
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def record_as_hash(record)\n encode_new_value(record)\n\n {\n table_name: record.table_name,\n record_id: record.record_id,\n attr: record.attr,\n new_value: record.new_value,\n updated_at: record.updated_at\n }\n end",
"def to_h\n @table.reduce({})... | [
"0.7533952",
"0.699359",
"0.6916222",
"0.6898092",
"0.68766785",
"0.6755341",
"0.667941",
"0.6667998",
"0.6650438",
"0.66418815",
"0.6616046",
"0.646839",
"0.6423536",
"0.6361429",
"0.6345645",
"0.63306224",
"0.6313461",
"0.6310359",
"0.62412333",
"0.62306815",
"0.61958",
"... | 0.64393026 | 12 |
method to find the index | def left_equal_right(array)
left = 0
right = array.reduce(:+)
array.each do |x|
right -= x
if left == right
p array.index(x)
end
left += x
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_index(arg)\n self.each_with_index do |ele,idx|\n if ele == arg\n return idx\n end\n end\n return nil\n end",
"def index ; @index ; end",
"def index\r\n @index ||= 0\r\n end",
"def index(element); end",
"def index; @index; end",
"... | [
"0.75985825",
"0.7406335",
"0.7341931",
"0.72795117",
"0.7243267",
"0.7222627",
"0.7219153",
"0.71993035",
"0.71993035",
"0.7134473",
"0.7102069",
"0.7094379",
"0.70919734",
"0.7006969",
"0.6988685",
"0.69208413",
"0.6913255",
"0.68878746",
"0.6882119",
"0.6868752",
"0.683327... | 0.0 | -1 |
cause the members to index the relationship | def local_update_members
if self.respond_to?(:members)
self.members.each do |member|
member.reload.update_index
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_relations(exclude_relations: []); end",
"def add_index_field(*) super end",
"def relink_indexes\n super\n sync_indexes\n end",
"def index\n @parent_proxy.columns.compact.index(self)\n end",
"def add_indexes\n if hereditary? && !index_keys.include?(self.di... | [
"0.6845094",
"0.6406147",
"0.6280703",
"0.61785835",
"0.6162755",
"0.6095876",
"0.6022503",
"0.6003696",
"0.5992911",
"0.59659636",
"0.5953254",
"0.5944076",
"0.59320116",
"0.5920856",
"0.5896518",
"0.5879308",
"0.58733654",
"0.58621234",
"0.5843888",
"0.5814747",
"0.57811797... | 0.6152168 | 6 |
should return 300 X REAL SOLUTION | def highest_product_of_3(array_of_ints)
raise ArgumentError, "Less than 3 numbers given" if array_of_ints.length < 3
highest = array_of_ints.first(2).max # of 1st 3 ints
lowest = array_of_ints.first(2).min
highest_product_of_2 = array_of_ints[0] * array_of_ints[1]
lowest_product_of_2 = array_of_ints[0] * array_of_ints[1]
highest_product_of_3 = array_of_ints[0] * array_of_ints[1] * array_of_ints[2]
# Walk through items, starting at index 2
# (we could slice the array but that would use n space).
array_of_ints.each_with_index do |current, index|
next if index < 2
# Do we have a new highest product of 3?
# It's either the current highest,
# or the current times the highest product of two,
# or the current times the lowest product of two.
highest_product_of_3 = [
highest_product_of_3,
current * highest_product_of_2,
current * lowest_product_of_2
].max
# Do we have a new highest product of two?
highest_product_of_2 = [
highest_product_of_2,
current * highest,
current * lowest
].max
# Do we have a new lowest product of two?
lowest_product_of_2 = [
lowest_product_of_2,
current * highest,
current * lowest
].min
# Do we have a new highest?
highest = [highest, current].max
# Do we have a new lowest?
lowest = [lowest, current].min
end
highest_product_of_3
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve\n return ((1..40).inject(:*) / ((1..20).inject(:*) ** 2))\nend",
"def solution\n (1..40).inject(:*) / (1..20).inject(:*)**2\nend",
"def solve(ingredients, part_two: false)\n score = 0\n max = 0\n\n (0..100).each do |i|\n (0..100 - i).each do |j|\n (0..100 - i - j).each do |k|\n ... | [
"0.6724764",
"0.66527724",
"0.62384665",
"0.6193403",
"0.6149259",
"0.61457956",
"0.6105641",
"0.6086502",
"0.6011727",
"0.5986332",
"0.5963917",
"0.5954246",
"0.5920353",
"0.58875805",
"0.5885025",
"0.5859763",
"0.58589005",
"0.58571494",
"0.58479816",
"0.58451223",
"0.58252... | 0.0 | -1 |
Print to_s all variables that are in this class | def status
stat = Hash.new("Empty!")
stat[:name] = @name
stat[:level] = @level
stat[:hp_cur] = @cur_health
stat[:hp_max] = @max_health
stat[:str] = @strength
stat[:exp_cur] = @cur_exp
stat[:exp_max] = @max_exp
return stat
#"Name: #{@name}\n" +
#"Level: #{@level}\n" +
#"Health: #{@cur_health}/#{@max_health}\n" +
#"Strength: #{@strength}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toString\n\t\tself.instance_variables.each do |i|\n\t\t\tputs \"#{i[1..-1]}: #{self.instance_variable_get(i)}\\n\"\n\t\tend\n\tend",
"def toString\n\t\tself.instance_variables.each do |i|\n\t\t\tputs \"#{i[1..-1]}: #{self.instance_variable_get(i)}\\n\"\n\t\tend\n\tend",
"def inspect\n instance_variabl... | [
"0.7952636",
"0.7952636",
"0.7754524",
"0.7328215",
"0.7098594",
"0.7098594",
"0.70246565",
"0.69472104",
"0.6943911",
"0.6943911",
"0.6905842",
"0.6860079",
"0.68441546",
"0.6813354",
"0.6758529",
"0.6753069",
"0.66753906",
"0.66298187",
"0.6579821",
"0.65565854",
"0.6556585... | 0.0 | -1 |
For the example flag its run metadata to true | def flag_example!
example.metadata[:run] = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_example?\n false\n end",
"def example_started(example)\n end",
"def rspec_example_metadata(cmd, stdout, stderr)\n return unless @example\n @example.metadata[:command] = cmd\n @example.metadata[:stdout] = stdout\n @example.metadata[:stderr] = stderr\n end"... | [
"0.6471989",
"0.64002866",
"0.6301712",
"0.60915303",
"0.59801346",
"0.5842643",
"0.58282197",
"0.58263654",
"0.57864195",
"0.5754388",
"0.5732268",
"0.5706813",
"0.5692208",
"0.5649717",
"0.5630308",
"0.5586831",
"0.55422276",
"0.5537149",
"0.551475",
"0.54888767",
"0.548815... | 0.8983358 | 0 |
Mock Rack and Sinatra methods | def session
@session ||= {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup\n @requester = Rack::MockRequest.new(SampleApp)\n end",
"def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra... | [
"0.7617458",
"0.7456221",
"0.7456221",
"0.7456221",
"0.72691345",
"0.7072761",
"0.7035643",
"0.7035643",
"0.7035643",
"0.7035643",
"0.69378203",
"0.6887972",
"0.6687272",
"0.66487974",
"0.6629535",
"0.6596757",
"0.65778905",
"0.6520177",
"0.6467522",
"0.634496",
"0.6322505",
... | 0.0 | -1 |
++ Creates a new instance, storing the Model name to which this instance it refers to. The name must be a String (not +nil+). No checks are performed to verify that the +table_name+ corresponds to an actual table on the database. === Supported options: :email_on_create => when true, an email for the first defined Admin will be delivered to notify the creation performed by the user associated to the model (if any). :email_on_destroy => same as above, but for a destroy action. | def initialize(table_name, options = {})
raise ArgumentError, 'UserContentLogger requires at least a table name as a parameter!' unless table_name.instance_of?(String)
@table_name = table_name
@log_filename = Rails.root.join(LOG_DESTINATION, "#{LOG_BASENAME}#{@table_name}.log")
@email_on_create = (options[:email_on_create] == true)
@email_on_destroy = (options[:email_on_destroy] == true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(name)\n self.new(name)\n end",
"def create_model(ns, model_name, options)\r\n model = super # create the model with defaulted model options\r\n create_timetable(model, options) if options[:create_timetable] == true\r\n model\r\n end",
"def create(name, table)\n Util... | [
"0.6343353",
"0.6130924",
"0.6093625",
"0.60791415",
"0.6079003",
"0.6056047",
"0.6046814",
"0.59508175",
"0.5893738",
"0.5810707",
"0.5807338",
"0.5772318",
"0.5708794",
"0.5696294",
"0.5682024",
"0.5659113",
"0.56524545",
"0.5640402",
"0.55921865",
"0.55921865",
"0.5517398"... | 0.5166273 | 77 |
++ Callback for when a new row from the model is created. Logs the action, the instance and the linked user, if available. | def after_create(record)
contents = to_sql_insert(record)
to_logfile(contents)
# Send a notification to the admin, if requested:
if @email_on_create
AgexMailer.action_notify_mail(
record.respond_to?(:user) ? record.user : nil,
"#{@table_name} row CREATED",
contents
).deliver
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_create\n if self.class.name == 'ParticipantsSportEntry'\n model = self.sport_entry\n action = 'UPDATE'\n else\n model = self\n action = 'CREATE'\n end\n\n ModelAuditJob.perform_now(model, action, audit_user_id)\n end",
"def on_creating_entry(state, event, *event_args)\n ... | [
"0.62272257",
"0.5960874",
"0.5947744",
"0.5945002",
"0.5897008",
"0.58801216",
"0.58084255",
"0.58036363",
"0.5776784",
"0.5671715",
"0.5650066",
"0.5642452",
"0.5640213",
"0.5640213",
"0.5626831",
"0.55788386",
"0.55644894",
"0.5503497",
"0.5462635",
"0.5462394",
"0.5462149... | 0.6346749 | 0 |
Callback for when a new row from the model is updated. Logs the action, the instance and the linked user, if available. | def after_update(record)
contents = to_sql_update(record)
to_logfile(contents)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_update_save(record); end",
"def handle_update\n obj = model.with_pk(normalized_type, request, request.id)\n model.set_fields(obj, :edit, request, model_params)\n model.hook(:before_update, request, obj)\n if model.save(obj)\n model.hook(:after_update, request, obj)\n r... | [
"0.57498336",
"0.5507759",
"0.5473898",
"0.53674656",
"0.5357804",
"0.53378946",
"0.5302665",
"0.529993",
"0.52961165",
"0.52807766",
"0.52375233",
"0.52245206",
"0.5206389",
"0.5195508",
"0.5173507",
"0.51321965",
"0.5115911",
"0.5087791",
"0.5081523",
"0.50685465",
"0.50650... | 0.52727777 | 10 |
Callback for when a new row from the model is destroyed. Logs the action, the instance and the linked user, if available. | def before_destroy(record)
contents = to_sql_delete(record)
to_logfile(contents)
# Send a notification to the admin, if requested:
if @email_on_destroy
AgexMailer.action_notify_mail(
record.respond_to?(:user) ? record.user : nil,
"#{@table_name} row DELETED",
contents
).deliver
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroyed!\n log('Deleted', resource_attributes)\n end",
"def destroy\n log_record('users/delete', current_user.id)\n super\n end",
"def handle_destroy\n obj = model.with_pk(normalized_type, request, request.id)\n model.hook(:before_destroy, request, obj)\n model.destroy(obj)\... | [
"0.6163764",
"0.604818",
"0.60187405",
"0.5830853",
"0.58195895",
"0.5803871",
"0.57457703",
"0.5743281",
"0.57260746",
"0.5681055",
"0.56410927",
"0.5628278",
"0.55908483",
"0.5580232",
"0.5573221",
"0.55651176",
"0.5528249",
"0.5522584",
"0.55110496",
"0.55110496",
"0.54665... | 0.5793896 | 6 |
++ Appends the specified contents on logfile. | def to_logfile(contents)
File.open(@log_filename, 'a') { |f| f.puts contents } unless contents.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append_log_file(str)\n append_file(@log_file, str)\n end",
"def add_in_logfile(date, adresse, utilisateur_id, description)\n fichier = \"app/../log/logs.txt\"\n if File.exist?(fichier)\n mode = 'a'\n check_logfile_size(fichier)\n else\n mode = 'w'\n end\n open(fichier, mode)... | [
"0.73818517",
"0.72938806",
"0.7093818",
"0.70292366",
"0.6922759",
"0.67276776",
"0.66566414",
"0.6652661",
"0.6609772",
"0.6551964",
"0.6502007",
"0.6463983",
"0.6455916",
"0.6449679",
"0.6423964",
"0.63783777",
"0.6368556",
"0.63674796",
"0.6358892",
"0.6338118",
"0.630324... | 0.7897593 | 0 |
TLSv1.3 reuse is always on | def test_off_tls1_3
skip 'TLSv1.3 unavailable' unless Puma::MiniSSL::HAS_TLS1_3 && CLIENT_HAS_TLS1_3
reused = run_session 'nil'
assert reused, 'TLSv1.3 session was not reused'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_tlsv1_1; end",
"def no_tlsv1; end",
"def tls?; end",
"def bad_tlsv1_3?; end",
"def start_tls(host, ssl_socket_class, ssl_context); end",
"def starttls_always?; end",
"def starttls_auto?; end",
"def starttls?; end",
"def use_dtls\n @MySocket = MySocket.new\n @MySocket.socket_type = ... | [
"0.70453817",
"0.69870096",
"0.69190705",
"0.6842957",
"0.68168056",
"0.66559935",
"0.66394794",
"0.6622664",
"0.65920067",
"0.6552831",
"0.6531199",
"0.64529127",
"0.6402497",
"0.6349706",
"0.6304761",
"0.6294923",
"0.6268668",
"0.6232452",
"0.62277454",
"0.62243193",
"0.613... | 0.7328142 | 0 |
SHOWS list of shows | def shows
res = call(
'shows',
{}
)
res.body['Itasa_Rest2_Server_Shows']['direct']['shows'].values
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @shows = Show.all\n end",
"def index\n @shows = Show.all\n end",
"def show_list\n process_show_list\n end",
"def index\n @showers = Shower.all\n end",
"def show_list\n\t\t\t@my_list.show\n\t\tend",
"def index\n @showings = Showing.all\n \n \n\n end",
"def index\n ... | [
"0.7756513",
"0.7756513",
"0.7478304",
"0.737432",
"0.7294748",
"0.72412145",
"0.72409934",
"0.72370285",
"0.7200809",
"0.7173827",
"0.7161398",
"0.7161398",
"0.7006228",
"0.6996063",
"0.69062775",
"0.6903133",
"0.6893256",
"0.68704957",
"0.68453175",
"0.6832978",
"0.6822627"... | 0.7166421 | 10 |
MYITASA list myItasa shows | def myitasa_shows
raise APIError, 'not logged in' if @authcode.nil?
res = call(
'myitasa/shows',
'authcode' => @authcode
)
res.body['Itasa_Rest2_Server_Myitasa']['shows']['shows'].values
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @akis = Aki.all\n end",
"def show\n @itens = @genero.itens.group(\"itens.id\").paginate(page: params[:page], :per_page => 30)\n end",
"def index\n @the_loai_saches = TheLoaiSach.all\n end",
"def index\n @avis = Avi.all\n end",
"def index\n @anuphats = Anuphat.all\n end",
"... | [
"0.6459813",
"0.6303081",
"0.6282277",
"0.6268951",
"0.6257568",
"0.6251671",
"0.6229449",
"0.6201208",
"0.61699325",
"0.6157011",
"0.6130558",
"0.60957867",
"0.6086649",
"0.60738844",
"0.6072564",
"0.606",
"0.60546863",
"0.6054395",
"0.60202044",
"0.601346",
"0.6007974",
"... | 0.6962708 | 0 |
show last myItasa subtitles | def myitasa_last_subtitles(page = nil)
raise APIError, 'not logged in' if @authcode.nil?
res = call(
'myitasa/lastsubtitles',
'authcode' => @authcode,
'page' => page
)
res.body['Itasa_Rest2_Server_Myitasa']['lastsubtitles']['subtitles'].values
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subtitle\n {}\n end",
"def full_title subtitle\n\n\t\tbase = \"Codewatch.pl\"\n\n\t\tif not @company.nil?\n\t\t\tbase = @company.name + \" :: \" + base\n\t\tend\n\n\t\tif not @project.nil? and !@project.new_record?\n\t\t\tbase = @project.name + \" :: \" + base\n\t\tend\n\n\t\tif subtitle.blank?\n\t\t\tba... | [
"0.63475686",
"0.6194585",
"0.61317194",
"0.60926104",
"0.6050513",
"0.60283554",
"0.5932728",
"0.592458",
"0.58801436",
"0.5863749",
"0.5824886",
"0.5820066",
"0.58137244",
"0.58023244",
"0.5790305",
"0.5775616",
"0.57693094",
"0.57647765",
"0.5764667",
"0.57557064",
"0.5692... | 0.7237585 | 0 |
add a show to myItasa | def myitasa_add_show(show_id, version)
raise APIError, 'not logged in' if @authcode.nil?
res = call(
'myitasa/addShowToPref',
'authcode' => @authcode,
'show_id' => show_id,
'version' => version
)
res.body['Itasa_Rest2_Server_Myitasa']['addShowToPref']['shows'].values
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show() end",
"def show() end",
"def show() end",
"def show \r\n end",
"def show\n\t\t end",
"def show\n \t\n end",
"def show\n \t\n end",
"def show!\n visible(true)\n end",
"def show!\n visible(true)\n end",
"def show\n \n end",
"def show\n \n end",... | [
"0.69521236",
"0.69521236",
"0.69521236",
"0.67624635",
"0.6714719",
"0.65808076",
"0.65808076",
"0.65358543",
"0.65358543",
"0.65144396",
"0.65144396",
"0.65144396",
"0.65144396",
"0.65144396",
"0.65144396",
"0.65144396",
"0.65144396",
"0.65144396",
"0.64824736",
"0.6397883",
... | 0.6633239 | 5 |
remove a show from myItasa | def myitasa_remove_show(show_id, version)
raise APIError, 'not logged in' if @authcode.nil?
res = call(
'myitasa/removeShowFromPref',
'authcode' => @authcode,
'show_id' => show_id,
'version' => version
)
res.body['Itasa_Rest2_Server_Myitasa']['removeShowFromPref']['shows'].values
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unfavorite_a_show(show_id)\n previous_clicks = Interest.where('user_id' => self.id,\n 'show_id' => show_id).all\n for elt in previous_clicks\n elt.destroy\n end\n end",
"def del\n\t\t#methode ruft show auf ==> !?! ==> err aber funktioniert\n\tend",
"def re... | [
"0.6954534",
"0.68472123",
"0.6779288",
"0.6446025",
"0.62399924",
"0.6151446",
"0.603143",
"0.603143",
"0.601403",
"0.5996378",
"0.58847344",
"0.5853025",
"0.5851104",
"0.5849674",
"0.58006966",
"0.58006966",
"0.58006966",
"0.58006966",
"0.5791528",
"0.5767778",
"0.574896",
... | 0.7420498 | 0 |
Handle a get or post request | def do_request(request, response)
body = make_request(request)
# Always 200. A simplification, but fine for user
# error messages.
response.status = 200
response['Content-Type'] = 'text/html'
response.body = body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle( request ) # note: all 'handle's return 'ml_response' in a chain\n\n ml_response =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n end",
"def GET; end",
"def view\n view_get if request.get?\n ... | [
"0.71467054",
"0.692409",
"0.6614243",
"0.6585935",
"0.6565535",
"0.6539034",
"0.65384936",
"0.6530305",
"0.6446488",
"0.64456356",
"0.6399955",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6327624",
... | 0.0 | -1 |
Handle a request to the server. Called by get and post. | def make_request(request)
puts "\n\n"
puts "==> Request, action='#{request.path}', params = #{request.query}..."
action = request.path.to_s.split("/")[-1]
if action && @app.valid?(action) then
response = @app.send(action.to_sym, request.query)
return response
end
return "Error: Unrecognised action: #{action}"
rescue Exception => e
$stderr.puts "*** [E]: #{e}\n#{e.backtrace.join("\n")}"
return "Error: #{e}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle( request ) # note: all 'handle's return 'ml_response' in a chain\n\n ml_response =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n end",
"def handle_request(request)\n if request =~ /^(\\w+)\\s+(.*... | [
"0.7231377",
"0.705429",
"0.6949259",
"0.68906724",
"0.68281966",
"0.66867894",
"0.6656232",
"0.6612332",
"0.6596408",
"0.6568847",
"0.65283144",
"0.64938843",
"0.64932656",
"0.6485996",
"0.648474",
"0.64813787",
"0.6429493",
"0.6413863",
"0.63899356",
"0.63875246",
"0.638728... | 0.590092 | 86 |
Initialise with a lexicon directory | def initialize(lexicon_dir = nil)
@tagparser = USASTools::SemTag::Parser.new(USASTools::SemTag::Taxonomy.new(TAXONOMY_FILE))
@lexicons = load_lexicons(lexicon_dir) if lexicon_dir
@valid_languages = Dir.glob(File.join(TEMPLATE_DIR, LANGUAGE_REF_DIR, '*.erb')).map{ |x| File.basename(x).gsub(/\.erb$/, '') }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n @lexicons = Hash.new {|hash, k| hash[k] = []}\n File.open(lexicon_path, 'r').each do |line|\n line = line.split\n @lexicons[line.shift] = line\n end\n end",
"def initialize(ngrams_path, lexicon_path, interpolations = nil)\n @ngrams_path = File.expan... | [
"0.72203845",
"0.68922275",
"0.64483106",
"0.6238303",
"0.61230874",
"0.5960258",
"0.59430695",
"0.5938836",
"0.59134763",
"0.5860554",
"0.5860554",
"0.5776075",
"0.57745945",
"0.57355803",
"0.57236266",
"0.57194513",
"0.56809",
"0.56761885",
"0.56683415",
"0.56601095",
"0.56... | 0.71702266 | 1 |
Is the action valid at this time? | def valid?(action)
self.respond_to?(action.to_sym) && VALID_ACTIONS.include?(action)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid?\n return false if @action.nil?\n return false if @repeat.nil?\n true\n end",
"def valid?\n \n \n if @action.nil?\n return false\n end\n\n \n \n allowed_values = [\"DELETE\", \"EXPORT\"]\n if @action && !allowed_values.include?(@action)\n... | [
"0.820898",
"0.7990239",
"0.77358377",
"0.7545089",
"0.75231314",
"0.7410604",
"0.734058",
"0.7271474",
"0.72609496",
"0.71714884",
"0.7143502",
"0.7086672",
"0.7085747",
"0.708552",
"0.70381063",
"0.7034114",
"0.6981208",
"0.6935682",
"0.692516",
"0.6924839",
"0.6924839",
... | 0.8120907 | 1 |
Check if a worker has done a word before | def check_worker_id(args)
# Load params
worker = args['worker'].to_s.strip
word = args['word'].to_s.strip.downcase
# Load hash of who has done what
worker_words = YAML::Store.new(AMT_WORKER_WORD_LIST)
previous_work = worker_words.transaction do (worker_words[worker] && worker_words[worker].include?(word)) end
return compose_template('previous_work', binding) if previous_work
return compose_template('no_previous_work', binding)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_worker_word(worker, word)\n # puts \"######### #{worker} ######## #{word}\"\n\n # Load hash of who has done what\n worker_words = YAML::Store.new(AMT_WORKER_WORD_LIST)\n worker_words.transaction do\n # Set to array if she be not exist and add the word to the list\n worker_words[wo... | [
"0.6134283",
"0.61342525",
"0.5825287",
"0.58099174",
"0.56204337",
"0.5619865",
"0.56002283",
"0.5587403",
"0.5570429",
"0.5555913",
"0.54384136",
"0.54368955",
"0.5432886",
"0.54173166",
"0.54097795",
"0.540072",
"0.5383527",
"0.53751",
"0.53508466",
"0.5345757",
"0.5342739... | 0.67582035 | 0 |
Show a debug form | def go(args)
return compose_template('go', binding)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n # debugger\n end",
"def show\n #debugger\n end",
"def show\n # byebug\n end",
"def show\n # binding.pry\n \n end",
"def show() end",
"def show() end",
"def show() end",
"def debug(message, options = { })\n ::Guard::UI.debug(message, options)\n e... | [
"0.7067696",
"0.7002051",
"0.6544137",
"0.64078385",
"0.6336204",
"0.6336204",
"0.6336204",
"0.62776357",
"0.6210443",
"0.6206953",
"0.6160108",
"0.613097",
"0.6063121",
"0.59878755",
"0.59878755",
"0.59828347",
"0.59723485",
"0.59639674",
"0.5962041",
"0.5962041",
"0.5962041... | 0.0 | -1 |
Store the results and serve a receipt | def add(args)
# Check input is valid
receipt_code, fail_reason = handle_input(args['word'].to_s.strip.downcase,
args['from'].to_s.strip.downcase,
args['tags'].to_s.strip,
args['time'].to_s.strip.downcase,
args['worker'].to_s.strip,
args['lang'].to_s.strip.downcase)
# Success page else failure page
return compose_template('receipt', binding) if receipt_code
return compose_template('fail', binding)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def results\n send_query\n end",
"def results\n send_query\n end",
"def work_received(results)\n\n # write results to disk\n results.each do |name,fasta,qual,comments|\n @@results.write_seq(name,fasta,qual,comments)\n end\n \n end",
"def work_received(results)\n # ... | [
"0.67222154",
"0.65625155",
"0.6434499",
"0.64179087",
"0.638662",
"0.6246635",
"0.6163863",
"0.6148315",
"0.6115132",
"0.6115132",
"0.60170686",
"0.597941",
"0.5799834",
"0.57645446",
"0.568017",
"0.5675045",
"0.56691736",
"0.56686985",
"0.5657112",
"0.56451696",
"0.5603401"... | 0.0 | -1 |
Load all lexicons from a directory and return them indexed by basename | def load_lexicons(dir)
require 'usastools/lexicon'
puts "Loading lexicons from #{dir}..."
pl = USASTools::Lexicon::Parser.new(
{semtag_parser: USASTools::SemTag::Parser.new(true, lambda{|*_| return true}, lambda{|*_| return true})},
{},
{
case_sensitive: false,
error_cb: lambda{ |line, msg, str|
# $stderr.puts " [E]#{line ? " line #{line} :--" : ''} #{msg} "
# $stderr.print " [E]#{str} \r"
return true }
}
)
lexicons = {}
Dir.glob( File.join(dir, '*_sw.usas') ).each do |fn|
basename = File.basename(fn).gsub(/_sw\.usas/, '')
puts " - #{basename}..."
lexicons[basename] = pl.parse( fn )
end
puts "Loaded #{lexicons.length} lexicon[s] (#{lexicons.keys.join(', ')})"
return lexicons
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n @lexicons = Hash.new {|hash, k| hash[k] = []}\n File.open(lexicon_path, 'r').each do |line|\n line = line.split\n @lexicons[line.shift] = line\n end\n end",
"def parse_lexicon!\n read(lexicon_path) do |values|\n values.compact!\n\n word, w... | [
"0.6495603",
"0.5862242",
"0.58618087",
"0.5815387",
"0.5785531",
"0.5778278",
"0.57340676",
"0.56956303",
"0.5683282",
"0.5580797",
"0.5575757",
"0.552552",
"0.5474527",
"0.547444",
"0.5452975",
"0.5448757",
"0.5446009",
"0.5418177",
"0.5397736",
"0.53865564",
"0.53850037",
... | 0.7640452 | 0 |
Using a lexicon, return a hash to be written into the page code | def load_tags(language, word)
return [] unless @lexicons[language]
selection = []
# Find tags for all senses
tags = []
senses = @lexicons[language].get_senses(word)
fail "No senses found for word: '#{word}' in lexicon for '#{language}'" unless senses
senses.each{ |s| tags += @lexicons[language].get(word, s) }
# build selection list from tags
tags.each do |t|
t = t.tags[0] if t.is_a?(USASTools::SemTag::CompoundSemTag)
selection << {prefix: t.stack.join('_'),
name: t.name,
positive: t.affinity >= 0
}
end
return selection.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash\n code.hash\n end",
"def hash\n code.hash\n end",
"def hash_for(expression)\n\n end",
"def token_hash=(_arg0); end",
"def hash\n @symbols.... | [
"0.6498564",
"0.6498564",
"0.6498564",
"0.6498564",
"0.6498564",
"0.6498564",
"0.6498564",
"0.64798135",
"0.63833606",
"0.6284001",
"0.62705046",
"0.6209027",
"0.6165168",
"0.61591387",
"0.6144806",
"0.61310875",
"0.60615295",
"0.6030117",
"0.6017065",
"0.60166466",
"0.599609... | 0.0 | -1 |
Parse input and save to disk (or return an error) | def handle_input(word, source, tags_field, time_field, worker=nil, lang=nil)
return nil, 'Invalid word returned!' if !check_string(word)
tags = nil
begin
tags = parse_tag_JSON(tags_field)
rescue StandardError => e
return nil, "Error parsing JSON: #{e}"
end
return nil, 'Invalid JSON submitted' if !tags
return nil, 'You must select at least one tag' if tags[:tags].length == 0
time = time_field.to_f / 60.0 / 1000.0 # convert to minutes
# return nil, "Invalid timeout field" if time > MAX_TIMEOUT || time < 0
# ---- validation done
# Now augment tag information with time, date, etc.
tags[:time] = Time.now
tags[:source] = source
tags[:word] = word.force_encoding("UTF-8")
tags[:lang] = lang if @valid_languages.include?(lang)
# Now generate unique IDs and write to disk
# Generate a filename by hashing the word
word_filename = Digest::MD5.hexdigest(word)
word_filepath = File.join(OUTPUT_DIR, word_filename)
# Code to identify this transaction
uuid = SecureRandom.uuid()
receipt_code = "#{word_filename}#{uuid}"
# Write the submission into the existing list
submissions = YAML::Store.new(word_filepath)
submissions.transaction do submissions[uuid] = tags end
# Lastly, maintain worker word list if worker ID is provided
set_worker_word(worker, word) if(worker && worker.length > 0)
# Return the code
return receipt_code, nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_input (input_file)\nend",
"def parse_input(input_file); end",
"def parse_input(input_file); end",
"def parse_output_data(filepath)\n # NOPE!\nend",
"def save_game\n save_data = YAML::dump(self)\n puts \"Please enter a name for your save game:\"\n prompt\n @filename = gets.chomp\n ... | [
"0.5950327",
"0.5902202",
"0.5902202",
"0.58504194",
"0.5777463",
"0.55937386",
"0.55903715",
"0.55783564",
"0.55637306",
"0.55583525",
"0.553807",
"0.5538039",
"0.5467865",
"0.5451845",
"0.54153013",
"0.5397291",
"0.5385051",
"0.5361439",
"0.53531826",
"0.53432393",
"0.53206... | 0.0 | -1 |
Parse JSON from the selection form. Ensures that the json is internallyconsistent, and strips all of the data out into a new, ordered, list of tags in descending order of preference. | def parse_tag_JSON(json)
obj = JSON.parse(json)
# Each tag should have
#
# prefix: prefix,
# name: name,
# positive: positive
#
# and each input json should have
# { order: [ prefix, prefix...]
# selection: { prefix: {tag as above},
# prefix: {tag as above}
# }
# }
#
raise 'No order information' unless obj['order'].is_a?(Array)
raise 'No tag information' unless obj['selection'].is_a?(Hash)
# Somewhere to store 'clean' copies of the data
out_of_order_tags = {}
# Check formats.
obj['selection'].each{|k, v|
# Check formats
raise "No prefix for item #{k}" unless v['prefix'].is_a?(String)
raise "No name for item #{k}" unless v['name'].is_a?(String)
raise "No positivity for item #{k}" unless !!v['positive'] == v['positive']
# Build the stack, converting numbers to numbers where possible
# This is necessary because my parser is insanely strict
stack = v['prefix'].split('_').map{ |x| x.to_s == x.to_i.to_s ? x.to_i : x.to_s }
tag = USASTools::SemTag::SemTag.new(stack, [], !!v['positive'] ? 0 : -1)
if @tagparser.valid?(tag)
tag = @tagparser.augment(tag)
else
raise "Invalid tag: #{tag}"
end
# Put in main hash
out_of_order_tags[v['prefix']] = tag
}
# Add to a hash in-order.
hash = {}
hash[:tags] = []
obj['order'].each{|prefix|
hash[:tags] << out_of_order_tags[prefix.to_s]
}
return hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def selected_tags=(data)\n self.tags.clear\n data.split('tag').each { |id| self.tags << Tag.find(id) if id.length > 0 }\n end",
"def parse_json(json)\n ::JSON.parse(json, :create_additions => false)\n end",
"def parse json; return JSON.parse File.read json end",
"def parse json; return JSON.pa... | [
"0.5351482",
"0.5288361",
"0.5216189",
"0.5216189",
"0.5092325",
"0.50148124",
"0.5013826",
"0.4950033",
"0.4943052",
"0.49019614",
"0.48892185",
"0.48752514",
"0.48743552",
"0.4853825",
"0.48045588",
"0.48043972",
"0.48008823",
"0.48008823",
"0.47211853",
"0.46948326",
"0.46... | 0.718916 | 0 |
Check a string to see if it is valid Must be over 0 length and contain only valid characters after removal of whitespace | def check_string(str)
str = str.strip
return false if str =~ /<>{}/
return false if str.length == 0
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_string(string)\n !string.match(/\\A[-a-zA-Z0-9]*\\z/).nil?\n end",
"def invalid_string(str)\n return true if str.strip! == ''\n return true unless str[0] =~ /[0-9\\+\\-]/\n false\nend",
"def string_is_valid(string)\n # Use lookahead to check for valid string\n string.match \"^(?=.... | [
"0.7883211",
"0.74574834",
"0.74038696",
"0.73164564",
"0.7041315",
"0.7039504",
"0.69279915",
"0.68790334",
"0.6846679",
"0.6846679",
"0.6809391",
"0.68088126",
"0.6690075",
"0.66593516",
"0.6612105",
"0.6582761",
"0.65704376",
"0.6549937",
"0.6542519",
"0.65382016",
"0.6536... | 0.7370419 | 3 |
Check if a worker has done a word before | def set_worker_word(worker, word)
# puts "######### #{worker} ######## #{word}"
# Load hash of who has done what
worker_words = YAML::Store.new(AMT_WORKER_WORD_LIST)
worker_words.transaction do
# Set to array if she be not exist and add the word to the list
worker_words[worker] = [] unless worker_words[worker]
worker_words[worker] << word if(!worker_words[worker].include?(word))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_worker_id(args)\n \n # Load params\n worker = args['worker'].to_s.strip\n word = args['word'].to_s.strip.downcase\n\n # Load hash of who has done what\n worker_words = YAML::Store.new(AMT_WORKER_WORD_LIST)\n previous_work = worker_words.transaction do (worker_words[worker] && worke... | [
"0.67582035",
"0.61342525",
"0.5825287",
"0.58099174",
"0.56204337",
"0.5619865",
"0.56002283",
"0.5587403",
"0.5570429",
"0.5555913",
"0.54384136",
"0.54368955",
"0.5432886",
"0.54173166",
"0.54097795",
"0.540072",
"0.5383527",
"0.53751",
"0.53508466",
"0.5345757",
"0.534273... | 0.6134283 | 1 |
Utilities for templates HTML escaping | def h(str)
CGI.escapeHTML(str.to_s)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def escape_html(html)\n html.to_s.gsub(/&/n, '&').gsub(/\\\"/n, '"').gsub(/>/n, '>').gsub(/</n, '<').gsub(/\\//, '/')\n end",
"def html_escape\n return to_s\n end",
"def html_escape\n return to_s\n end",
"def html_escape(options={})\n except = options[:except... | [
"0.7326803",
"0.7294057",
"0.7294057",
"0.7240767",
"0.7155972",
"0.71526974",
"0.71275294",
"0.70460063",
"0.70178854",
"0.70006114",
"0.69943637",
"0.6983795",
"0.69819814",
"0.69662976",
"0.6963998",
"0.6959248",
"0.69446814",
"0.69422096",
"0.6936382",
"0.6936382",
"0.691... | 0.61336476 | 86 |
Prettyprint number with commas (integer only) | def n(num)
num.to_s.reverse.gsub(/...(?=.)/,'\&,').reverse
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pretty_int(value)\n decimal = Integer(value).to_s\n # 讓 decimal 的長度為 3 的倍數,leader 為前面多出來的那幾個數字\n leader = decimal.slice!(0, decimal.length % 3)\n # 讓 decimal 每 3 位中間加逗號\n decimal.gsub!(/\\d{3}(?!$)/,'\\0,')\n decimal = nil if decimal.empty?\n leader = nil if leader.empty?\n [leader,decimal].compact.joi... | [
"0.7913227",
"0.7681492",
"0.7675833",
"0.72572845",
"0.72295135",
"0.72295135",
"0.71015114",
"0.7023472",
"0.6963635",
"0.69350034",
"0.6878977",
"0.6826603",
"0.6809569",
"0.67667174",
"0.6636354",
"0.6636354",
"0.6636354",
"0.6636354",
"0.6636354",
"0.6624185",
"0.661686"... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.