query stringlengths 16 255 | pos sequence | neg sequence | task stringclasses 1 value | instruction dict |
|---|---|---|---|---|
Computes the new parent id for the node being moved.
@return int | [
"protected function parentId()\n\t{\n\t\tswitch ( $this->position )\n\t\t{\n\t\t\tcase 'root':\n\t\t\t\treturn null;\n\n\t\t\tcase 'child':\n\t\t\t\treturn $this->target->getKey();\n\n\t\t\tdefault:\n\t\t\t\treturn $this->target->getParentId();\n\t\t}\n\t}"
] | [
"final void initDocument(int documentNumber)\n {\n // save masked DTM document handle\n m_docHandle = documentNumber<<DOCHANDLE_SHIFT;\n\n // Initialize the doc -- no parent, no next-sib\n nodes.writeSlot(0,DOCUMENT_NODE,-1,-1,0);\n /... | codesearchnet | {
"query": "Represent the instruction about Computer Science:",
"pos": "Represent the code about Computer Science:",
"neg": "Represent the code:"
} |
// SetWinSize overwrites the playlist's window size. | [
"func (p *MediaPlaylist) SetWinSize(winsize uint) error {\n\tif winsize > p.capacity {\n\t\treturn errors.New(\"capacity must be greater than winsize or equal\")\n\t}\n\tp.winsize = winsize\n\treturn nil\n}"
] | [
"def transform_cb(self, setting, value):\n \"\"\"\"\"\"\n self.make_callback('transform')\n\n # whence=0 because need to calculate new extents for proper\n # cutout for rotation (TODO: always make extents consider\n # room for rotation)\n whence = 0\n self.redraw(wh... | codesearchnet | {
"query": "Represent the text:",
"pos": "Represent the code:",
"neg": "Represent the code:"
} |
Show the sidebar and squish the container to make room for the sidebar.
If hideOthers is true, hide other open sidebars. | [
"function() {\n var options = this.options;\n\n if (options.hideOthers) {\n this.secondary.each(function() {\n var sidebar = $(this);\n\n if (sidebar.hasClass('is-expanded')) {\n sidebar.toolkit('offCanvas', 'hide');\n }\n ... | [
"function showDropdown(position) {\n // If the dropdown is already visible, just return (so the root click handler on html\n // will close it).\n if ($dropdown) {\n return;\n }\n\n Menus.closeAll();\n\n $dropdown = $(renderList())\n .css({\n ... | codesearchnet | {
"query": "Represent the description:",
"pos": "Represent the code:",
"neg": "Represent the code:"
} |
Decide the fate of the cells | [
"def nextGen(self):\n \n self.current_gen += 1\n self.change_gen[self.current_gen % 3] = copy.copy(self.grid)\n grid_cp = copy.copy(self.grid)\n\n for cell in self.grid:\n y, x = cell\n y1 = (y - 1) % self.y_grid\n y2 = (y + 1) % self.y_grid\n ... | [
"function showIntro() {\n write(\"Welcome to the Recognizer's Sample console application!\");\n write(\"To try the recognizers enter a phrase and let us show you the different outputs for each recognizer or just type 'exit' to leave the application.\");\n write();\n write(\"Here are some examples you co... | codesearchnet | {
"query": "Represent the Github text:",
"pos": "Represent the Github code:",
"neg": "Represent the Github code:"
} |
Return the kind specified by a given __property__ key.
Args:
key: key whose kind name is requested.
Returns:
The kind specified by key. | [
"def key_to_kind(cls, key):\n \n if key.kind() == Kind.KIND_NAME:\n return key.id()\n else:\n return key.parent().id()"
] | [
"def persistent_id(self, obj):\n \"\"\"\"\"\"\n if isinstance(obj, Element):\n # Here, our persistent ID is simply a tuple, containing a tag and\n # a key\n return obj.__class__.__name__, obj.symbol\n else:\n # If obj does not have a persistent ID, re... | codesearchnet | {
"query": "Represent the comment about programming:",
"pos": "Represent the code about programming:",
"neg": "Represent the code:"
} |
Gets a recursive list of traits used by a class
@param string $class Full class name
@return array | [
"private function getRecursiveTraits($class = null)\n {\n if (null == $class) {\n $class = get_class($this);\n }\n\n $reflection = new \\ReflectionClass($class);\n $traits = array_keys($reflection->getTraits());\n\n foreach ($traits as $trait) {\n $traits ... | [
"def build(self):\n \"\"\"\"\"\"\n from ambry.orm.config import BuildConfigGroupAccessor\n\n # It is a lightweight object, so no need to cache\n return BuildConfigGroupAccessor(self.dataset, 'buildstate', self._session)"
] | codesearchnet | {
"query": "Represent the instruction about Software Development:",
"pos": "Represent the code about Software Development:",
"neg": "Represent the code:"
} |
// SetMaxRecords sets the MaxRecords field's value. | [
"func (s *DescribeSnapshotCopyGrantsInput) SetMaxRecords(v int64) *DescribeSnapshotCopyGrantsInput {\n\ts.MaxRecords = &v\n\treturn s\n}"
] | [
"def from_bucket(cls, connection, bucket):\n \"\"\"\"\"\"\n if bucket is None:\n raise errors.NoContainerException\n\n # It appears that Amazon does not have a single-shot REST query to\n # determine the number of keys / overall byte size of a bucket.\n return cls(conne... | codesearchnet | {
"query": "Represent the Github sentence about programming:",
"pos": "Represent the Github code about programming:",
"neg": "Represent the Github code about AWS S3:"
} |
Check if the current position of the pointer is valid
@return bool True if the pointer position is valid | [
"public function valid() : bool\n {\n if ($this->pointer >= 0 && $this->pointer < count($this->members)) {\n return true;\n }\n return false;\n }"
] | [
"private void init() {\n // defaults for internal bookkeeping\n index = 0; // internal index always starts at 0\n count = 1; // internal count always starts at 1\n status = null; // we clear status on release()\n item = null; // item w... | codesearchnet | {
"query": "Represent the text about programming:",
"pos": "Represent the code about programming:",
"neg": "Represent the code about Computer Science:"
} |
Creates a new {@link TopicProducer}. The producer accepts arbitrary objects and uses the Jackson object mapper to convert them into
JSON and sends them as a text message. | [
"public TopicProducer<Object> createTopicJsonProducer(final String topic)\n {\n Preconditions.checkState(connectionFactory != null, \"connection factory was never injected!\");\n return new TopicProducer<Object>(connectionFactory, jmsConfig, topic, producerCallback);\n }"
] | [
"public static String getDefaultMediaType(ResultType expectedType) {\n ResponseFormat format = (expectedType != null) ? defaultTypeFormats.get(expectedType) : null;\n \n // If the expected type is unknown, we should let the server decide, otherwise we could\n // wind up requesting a response type that d... | codesearchnet | {
"query": "Represent the description about Software development:",
"pos": "Represent the code about Software development:",
"neg": "Represent the code about programming:"
} |
Dynamically add an array of setting items
@param string $owner
@param array $definitions | [
"public function addSettingItems($owner, array $definitions)\n {\n foreach ($definitions as $code => $definition) {\n $this->addSettingItem($owner, $code, $definition);\n }\n }"
] | [
"public function updateConfigOptions()\n {\n //search the config menu for our item\n $options = $this->searchMenu($this->name);\n\n //override the config's options\n $this->getConfig()->setOptions($options);\n }"
] | codesearchnet | {
"query": "Represent the comment about Software development:",
"pos": "Represent the code about Software development:",
"neg": "Represent the code:"
} |
Update brand group of parameters. | [
"def update_brand(self) -> None:\n \"\"\"\"\"\"\n self.update(path=URL_GET + GROUP.format(group=BRAND))"
] | [
"def post_build(self, p, pay):\n \n p += pay\n if self.auxdlen != 0:\n print(\"NOTICE: A properly formatted and complaint V3 Group Record should have an Auxiliary Data length of zero (0).\")\n print(\" Subsequent Group Records are lost!\")\n return p"
] | codesearchnet | {
"query": "Represent the summarization:",
"pos": "Represent the code:",
"neg": "Represent the code:"
} |
construct a string of space-delimited control keys based on properties of this class.
@param bool $disconnect
@return string | [
"protected function getControlKey($disconnect = false)\n {\n $key = '';\n\n if ($disconnect) {\n return \"*immed\";\n }\n\n /*\n if(?) *justproc\n if(?) *debug\n if(?) *debugproc\n if(?) *nostart\n if(?) *rpt*/\n\n // Idle timeout s... | [
"def _enter(self):\n \"\"\"\"\"\"\n command = self.command\n logger.log(5, \"Snippet keystroke `Enter`.\")\n # NOTE: we need to set back the actions (mode_off) before running\n # the command.\n self.mode_off()\n self.run(command)"
] | codesearchnet | {
"query": "Represent the text about programming:",
"pos": "Represent the code about programming:",
"neg": "Represent the code:"
} |
Need to refactor, fukken complicated conditions. | [
"def check_symbol_to_proc\n return unless method_call.block_argument_names.count == 1\n return if method_call.block_body.nil?\n return unless method_call.block_body.sexp_type == :call\n return if method_call.arguments.count > 0\n\n body_method_call = MethodCall.new(method_call.block_body)\n... | [
"def start(self, timeout=None):\n \n\n started = super(Node, self).start(timeout=timeout)\n if started:\n # TODO : return something produced in the context manager passed\n return self._svc_address # returning the zmp url as a way to connect to the node\n # CAR... | codesearchnet | {
"query": "Represent the description:",
"pos": "Represent the code:",
"neg": "Represent the code about programming:"
} |
Helper method to lookup a DAO if it has already been associated with the table-config. Otherwise this returns
null. | [
"public synchronized static <D extends Dao<T, ?>, T> D lookupDao(ConnectionSource connectionSource,\n\t\t\tDatabaseTableConfig<T> tableConfig) {\n\t\tif (connectionSource == null) {\n\t\t\tthrow new IllegalArgumentException(\"connectionSource argument cannot be null\");\n\t\t}\n\t\tTableConfigConnectionSource key =... | [
"public FunctionHandle resolveFunction(Session session, QualifiedName name, List<TypeSignatureProvider> parameterTypes)\n {\n // TODO Actually use session\n // Session will be used to provide information about the order of function namespaces to through resolving the function.\n // This is l... | codesearchnet | {
"query": "Represent the Github instruction about Software Development:",
"pos": "Represent the Github code about Software Development:",
"neg": "Represent the Github code about Software development:"
} |
// Provided for compatibility with the Transformer interface. Since Caser has no
// special treatment of bytes, the bytes are converted to and from strings.
// Will treat the entirety of src as ONE variable name. | [
"func (c Caser) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {\n\tnSrc = len(src) // Always read all the bytes of src\n\tresult := c.Bytes(src)\n\tif len(result) > len(dst) {\n\t\terr = transform.ErrShortDst\n\t}\n\tnDst = copy(dst, result)\n\treturn\n}"
] | [
"public FunctionHandle resolveFunction(Session session, QualifiedName name, List<TypeSignatureProvider> parameterTypes)\n {\n // TODO Actually use session\n // Session will be used to provide information about the order of function namespaces to through resolving the function.\n // This is l... | codesearchnet | {
"query": "Represent the comment about programming:",
"pos": "Represent the code about programming:",
"neg": "Represent the code about Software development:"
} |
Creates (or updates) a new ProjectStatus for the given build and
returns it. | [
"def create_or_update(cls, build):\n \n\n test_summary = build.test_summary\n metrics_summary = MetricsSummary(build)\n now = timezone.now()\n test_runs_total = build.test_runs.count()\n test_runs_completed = build.test_runs.filter(completed=True).count()\n test_runs... | [
"@Override\n public void addElement(Map<String, Object> e, Map<String, AggregatorFactory> a)\n {\n // since we return a constant, no need to read from the event\n }"
] | codesearchnet | {
"query": "Represent the Github text about programming:",
"pos": "Represent the Github code about programming:",
"neg": "Represent the Github code:"
} |
Static pressure.
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
int: static pressure in hPa | [
"def p44(msg):\n \n d = hex2bin(data(msg))\n\n if d[34] == '0':\n return None\n\n p = bin2int(d[35:46]) # hPa\n\n return p"
] | [
"def create_response_pdu(self, data):\n \n log.debug('Create single bit response pdu {0}.'.format(data))\n bytes_ = [data[i:i + 8] for i in range(0, len(data), 8)]\n\n # Reduce each all bits per byte to a number. Byte\n # [0, 0, 0, 0, 0, 1, 1, 1] is intepreted as binary en is deci... | codesearchnet | {
"query": "Represent the summarization about text processing:",
"pos": "Represent the code about text processing:",
"neg": "Represent the code about Software development:"
} |
Trace TCP flows.
Keyword arguments:
* fout -- str, output path
* format -- str, output format
* byteorder -- str, output file byte order
* nanosecond -- bool, output nanosecond-resolution file flag | [
"def trace(fout=None, format=None, byteorder=sys.byteorder, nanosecond=False):\n \n str_check(fout or '', format or '')\n return TraceFlow(fout=fout, format=format, byteorder=byteorder, nanosecond=nanosecond)"
] | [
"def _writer_factory(name, format, def_fs, descr):\n \n def basic_writer(data, filename, fs = def_fs, enc = format.encoding):\n \"\"\"Common \"template\" to all write functions.\"\"\"\n if np.ndim(data) <= 1:\n nc = 1\n elif np.ndim(data) == 2:\n nc = data.... | codesearchnet | {
"query": "Represent the comment about programming:",
"pos": "Represent the code about programming:",
"neg": "Represent the code about File management:"
} |
Sets the URL to navigate to when the menu item is invoked.
@param url the url to set. | [
"public void setUrl(final String url) {\n\t\tMenuItemModel model = getOrCreateComponentModel();\n\t\tmodel.url = url;\n\t\tmodel.action = null;\n\t}"
] | [
"public void discardHeaderClick(ClickEvent event) {\n if (event == null) return;\n\n // Example: we use radioset on collapsible header, so stopPropagation() is needed\n // to suppress collapsible open/close behavior.\n // But preventDefault() is not needed, otherwise radios won't switch.... | codesearchnet | {
"query": "Represent the Github sentence:",
"pos": "Represent the Github code:",
"neg": "Represent the Github code:"
} |
// SetSecurityGroupArns sets the SecurityGroupArns field's value. | [
"func (s *Ec2Config) SetSecurityGroupArns(v []*string) *Ec2Config {\n\ts.SecurityGroupArns = v\n\treturn s\n}"
] | [
"function(apiClient) {\n this.apiClient = apiClient || Configuration.default.getDefaultApiClient() || ApiClient.instance;\n\n\n this.setApiClient = function(apiClient) {\n this.apiClient = apiClient;\n };\n\n this.getApiClient = function() {\n return this.apiClient;\n };\n\n\n /**\n ... | codesearchnet | {
"query": "Represent the Github text about Programming:",
"pos": "Represent the Github code about Programming:",
"neg": "Represent the Github code about Software development:"
} |
Does not perform {@link PrivilegedAction} unless necessary.
@param javaClass
@param fieldName
@return a field from the class
@throws NoSuchMethodException | [
"static Field lookupField(Class<?> javaClass, String fieldName) throws NoSuchFieldException {\n if (System.getSecurityManager() != null) {\n try {\n return AccessController.doPrivileged(new FieldLookupAction(javaClass, fieldName));\n } catch (PrivilegedActionException e) ... | [
"public @CheckForNull PropertyType getPropertyType(@Nonnull Object instance, @Nonnull String field) {\n // in global.jelly, instance==descriptor\n return instance==this ? getGlobalPropertyType(field) : getPropertyType(field);\n }"
] | codesearchnet | {
"query": "Represent the Github comment about programming:",
"pos": "Represent the Github code about programming:",
"neg": "Represent the Github code:"
} |
migrate the retry jobs of a queue
@param string $queue
@return array | [
"protected function migrateRetryJobs($queue)\n {\n $luaScript = <<<LUA\n-- Get all of the jobs with an expired \"score\"...\nlocal val = redis.call('zrangebyscore', KEYS[1], '-inf', ARGV[1])\n\n-- If we have values in the array, we will remove them from the first queue\n-- and add them onto the destinatio... | [
"def build(self):\n \"\"\"\"\"\"\n from ambry.orm.config import BuildConfigGroupAccessor\n\n # It is a lightweight object, so no need to cache\n return BuildConfigGroupAccessor(self.dataset, 'buildstate', self._session)"
] | codesearchnet | {
"query": "Represent the summarization about Software development:",
"pos": "Represent the code about Software development:",
"neg": "Represent the code:"
} |
Dump the payload to JSON | [
"def jsonify_payload(self):\n \n # Assume already json serialized\n if isinstance(self.payload, string_types):\n return self.payload\n return json.dumps(self.payload, cls=StandardJSONEncoder)"
] | [
"def post_build(self, p, pay):\n \n p += pay\n if self.auxdlen != 0:\n print(\"NOTICE: A properly formatted and complaint V3 Group Record should have an Auxiliary Data length of zero (0).\")\n print(\" Subsequent Group Records are lost!\")\n return p"
] | codesearchnet | {
"query": "Represent the instruction about Technology:",
"pos": "Represent the code about Technology:",
"neg": "Represent the code:"
} |
Get system backtrace in formated view
@param bool $trace Custom php backtrace
@param bool $addObject Show objects in result
@return JBDump | [
"public static function trace($trace = null, $addObject = false)\r\n {\r\n if (!self::isDebug()) {\r\n return false;\r\n }\r\n\r\n $_this = self::i();\r\n\r\n $trace = $trace ? $trace : debug_backtrace($addObject);\r\n unset($trace[0]);\r\n\r\n $result = $_thi... | [
"function make_event(event, target) {\n return string_p(event)? Event.make(event, target)\n : /* otherwise */ event }"
] | codesearchnet | {
"query": "Represent the Github instruction about programming:",
"pos": "Represent the Github code about programming:",
"neg": "Represent the Github code:"
} |
Get a short value from the form, and place it in <code>attribute</code>.
@param name attribute name
@param attribute attribute to put value
@since 1.11.1 | [
"@Api\n\tpublic void getValue(String name, ShortAttribute attribute) {\n\t\tattribute.setValue(toShort(formWidget.getValue(name)));\n\t}"
] | [
"protected function setupObject()\n {\n $this->name = $this->getAttribute(\"name\");\n $this->value = $this->getAttribute(\"value\");\n $this->classname = $this->getAttribute(\"class\");\n\n /*\n * Set some default values if they are not specified.\n * This is especially... | codesearchnet | {
"query": "Represent the sentence about Programming:",
"pos": "Represent the code about Programming:",
"neg": "Represent the code about Software development:"
} |
Submits the {@link org.apache.gobblin.metrics.GobblinTrackingEvent} to the {@link org.apache.gobblin.metrics.MetricContext}.
@param name Name of the event.
@param additionalMetadata Additional metadata to be added to the event. | [
"public void submit(String name, Map<String, String> additionalMetadata) {\n if(this.metricContext.isPresent()) {\n Map<String, String> finalMetadata = Maps.newHashMap(this.metadata);\n if(!additionalMetadata.isEmpty()) {\n finalMetadata.putAll(additionalMetadata);\n }\n\n // Timestamp... | [
"@Override\n public <T extends Metric> T register(String name, T metric) throws IllegalArgumentException {\n // For MP Metrics 1.0, MetricType.from(Class in) does not support lambdas or proxy classes\n return register(name, metric, new Metadata(name, from(metric)));\n }"
] | codesearchnet | {
"query": "Represent the Github instruction about Data management:",
"pos": "Represent the Github code about Data management:",
"neg": "Represent the Github code about programming:"
} |
// FallbackAddr is a functional option that allows callers of NewInvoice to set
// the Invoice's fallback on-chain address that can be used for payment in case
// the Lightning payment fails | [
"func FallbackAddr(fallbackAddr btcutil.Address) func(*Invoice) {\n\treturn func(i *Invoice) {\n\t\ti.FallbackAddr = fallbackAddr\n\t}\n}"
] | [
"func (h Handler) GetE(cmd common.GetRequest) (<-chan common.GetEResponse, <-chan error) {\n\t// Being minimalist, not lazy. The chunked handler is not meant to be used with a\n\t// backing store that supports the GetE protocol extension. It would be a waste of\n\t// time and effort to support it here if it would \... | codesearchnet | {
"query": "Represent the Github comment:",
"pos": "Represent the Github code:",
"neg": "Represent the Github code about Software development:"
} |
Get our daemon script path. | [
"def get_manager_cmd(self):\n \"\"\"\"\"\"\n cmd = os.path.abspath(os.path.join(os.path.dirname(__file__), \"server\", \"notebook_daemon.py\"))\n assert os.path.exists(cmd)\n return cmd"
] | [
"def postloop(self):\n \n cmd.Cmd.postloop(self) # Clean up command completion\n d1_cli.impl.util.print_info(\"Exiting...\")"
] | codesearchnet | {
"query": "Represent the post:",
"pos": "Represent the code:",
"neg": "Represent the code about Software development:"
} |
// SetMaxHumanLabeledObjectCount sets the MaxHumanLabeledObjectCount field's value. | [
"func (s *LabelingJobStoppingConditions) SetMaxHumanLabeledObjectCount(v int64) *LabelingJobStoppingConditions {\n\ts.MaxHumanLabeledObjectCount = &v\n\treturn s\n}"
] | [
"private Counter<L> logProbabilityOfRVFDatum(RVFDatum<L, F> example) {\r\n // NB: this duplicate method is needed so it calls the scoresOf method\r\n // with an RVFDatum signature!! Don't remove it!\r\n // JLS: type resolution of method parameters is static\r\n Counter<L> scores = scoresOfRVFDatum(exam... | codesearchnet | {
"query": "Represent the Github sentence about programming:",
"pos": "Represent the Github code about programming:",
"neg": "Represent the Github code:"
} |
Create a default {@link FeatureInfoWidget} with a {@link ZoomToObjectAction}
to allow zooming to selected features.
@param mapPresenter The map presenter used by the action(s).
@return A feature info widget with actions. | [
"public FeatureInfoWithActions getFeatureInfoWidgetWithActions(MapPresenter mapPresenter) {\n\t\tFeatureInfoWithActions widgetWithActions = new FeatureInfoWithActions();\n\t\twidgetWithActions.addHasFeature(new ZoomToObjectAction(mapPresenter));\n\n\t\treturn widgetWithActions;\n\t}"
] | [
"function WidgetDef(config, endFunc, out) {\n this.type = config.type; // The widget module type name that is passed to the factory\n this.id = config.id; // The unique ID of the widget\n this.config = config.config; // Widget config object (may be null)\n this.state = config.state; // Widget state obje... | codesearchnet | {
"query": "Represent the text about programming:",
"pos": "Represent the code about programming:",
"neg": "Represent the code:"
} |
// SetError sets the Error field's value. | [
"func (s *TaskFailedEventDetails) SetError(v string) *TaskFailedEventDetails {\n\ts.Error = &v\n\treturn s\n}"
] | [
"NameAndType nameType(Symbol sym) {\n return new NameAndType(sym.name, sym.externalType(types), types);\n // the NameAndType is generated from a symbol reference, and the\n // adjustment of adding an additional this$n parameter needs to be made.\n }"
] | codesearchnet | {
"query": "Represent the Github text about Programming:",
"pos": "Represent the Github code about Programming:",
"neg": "Represent the Github code about programming:"
} |
Access the Monitor Twilio Domain
:returns: Monitor Twilio Domain
:rtype: twilio.rest.monitor.Monitor | [
"def monitor(self):\n \n if self._monitor is None:\n from twilio.rest.monitor import Monitor\n self._monitor = Monitor(self)\n return self._monitor"
] | [
"def plan(self):\n \n import ns1.rest.account\n return ns1.rest.account.Plan(self.config)"
] | codesearchnet | {
"query": "Represent the Github comment about Twilio:",
"pos": "Represent the Github code about Twilio:",
"neg": "Represent the Github code:"
} |
// ExecuteRaw receives, parse and executes raw source template contents
// it's super-simple function without options and funcs, it's not used widely
// implements the EngineRawExecutor interface | [
"func (p *Engine) ExecuteRaw(src string, wr io.Writer, binding interface{}) (err error) {\n\tset := pongo2.NewSet(\"\", pongo2.DefaultLoader)\n\tset.Globals = getPongoContext(p.Config.Globals)\n\ttmpl, err := set.FromString(src)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn tmpl.ExecuteWriter(getPongoContext(bi... | [
"public FunctionHandle resolveFunction(Session session, QualifiedName name, List<TypeSignatureProvider> parameterTypes)\n {\n // TODO Actually use session\n // Session will be used to provide information about the order of function namespaces to through resolving the function.\n // This is l... | codesearchnet | {
"query": "Represent the Github sentence about programming:",
"pos": "Represent the Github code about programming:",
"neg": "Represent the Github code about Software development:"
} |
Returns a parameter value in the specified array, if not in, returns the
first element instead
@param string $name The parameter name
@param array $array The array to be search
@return mixed The parameter value | [
"public function getInArray($name, array $array)\n {\n $value = $this->get($name);\n return in_array($value, $array) ? $value : $array[key($array)];\n }"
] | [
"public function singlePcmlToParam(\\SimpleXmlElement $dataElement)\n {\n $tagName = $dataElement->getName();\n \n // get attributes of this element.\n $attrs = $dataElement->attributes();\n \n // both struct and data have name, count (optional), usage\n $name = (isset($a... | codesearchnet | {
"query": "Represent the Github text about programming:",
"pos": "Represent the Github code about programming:",
"neg": "Represent the Github code about programming:"
} |
Sets metainfo properties as JCR properties to node. | [
"private void setJCRProperties(NodeImpl parent, Properties props) throws Exception\n {\n if (!parent.isNodeType(\"dc:elementSet\"))\n {\n parent.addMixin(\"dc:elementSet\");\n }\n\n ValueFactory vFactory = parent.getSession().getValueFactory();\n LocationFactory lFactory = parent.... | [
"private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {\n GetField fields = in.readFields();\n beginDefaultContext = fields.get(BEGIN_DEFAULT, true);\n\n // Note that further processing is required in JEEMetadataContextProviderImpl.deserializeThreadCo... | codesearchnet | {
"query": "Represent the comment about Software Development:",
"pos": "Represent the code about Software Development:",
"neg": "Represent the code about programming:"
} |
Get profiles grouped by account and webproperty
TODO Handle "(403) User does not have any Google Analytics account."
@return array | [
"protected function getGroupedProfiles()\n {\n $this->analytics->requireAuthentication();\n\n $groupedProfiles = [];\n $accounts = $this->analytics->management_accounts->listManagementAccounts();\n foreach ($accounts as $account) {\n $groupedProfiles[$account->getId()]['lab... | [
"def create(self, **kwargs):\n \n raise exceptions.MethodNotImplemented(method=self.create, url=self.url, details='GUID cannot be duplicated, to create a new GUID use the relationship resource')"
] | codesearchnet | {
"query": "Represent the Github summarization about accounts.authinfo:",
"pos": "Represent the Github code about accounts.authinfo:",
"neg": "Represent the Github code about Natural Language Processing:"
} |
// addValueToMap adds the given value to the map on which the method is run.
// This allows us to merge maps such as {foo: {bar: baz}} and {foo: {baz: faz}}
// into {foo: {bar: baz, baz: faz}}. | [
"func addValueToMap(keys []string, value interface{}, target map[string]interface{}) {\n\tnext := target\n\n\tfor i := range keys {\n\t\t// If we are on last key set or overwrite the val.\n\t\tif i == len(keys)-1 {\n\t\t\tnext[keys[i]] = value\n\t\t\tbreak\n\t\t}\n\n\t\tif iface, ok := next[keys[i]]; ok {\n\t\t\tsw... | [
"function(newValues, oldValues, paths) {\n var name, method, called = {};\n for (var i in oldValues) {\n // note: paths is of form [object, path, object, path]\n name = paths[2 * i + 1];\n method = this.observe[name];\n if (method) {\n var ov = oldValues[i], nv = newVa... | codesearchnet | {
"query": "Represent the instruction:",
"pos": "Represent the code:",
"neg": "Represent the code about programming:"
} |
// Run parses arguments from the command line and passes them to RunCommand. | [
"func (s *Service) Run() {\n\tflag.Usage = s.Usage\n\tflag.Parse()\n\targs := flag.Args()\n\tif len(args) == 0 && s.defaultCommand != \"\" {\n\t\targs = append([]string{s.defaultCommand}, args...)\n\t}\n\tif len(args) == 0 {\n\t\ts.Usage()\n\t\tBootPrintln()\n\t\treturn\n\t}\n\terr := s.RunCommand(args[0], args[1:]... | [
"def start(self, timeout=None):\n \n\n started = super(Node, self).start(timeout=timeout)\n if started:\n # TODO : return something produced in the context manager passed\n return self._svc_address # returning the zmp url as a way to connect to the node\n # CAR... | codesearchnet | {
"query": "Represent the sentence about programming:",
"pos": "Represent the code about programming:",
"neg": "Represent the code about programming:"
} |
store one item in database | [
"def _put_one(self, item):\n ''' \n '''\n # prepare values\n values = []\n for k, v in item.items():\n if k == '_id':\n continue\n if 'dblite_serializer' in item.fields[k]:\n serializer = item.fields[k]['dblite_serializer']\n ... | [
"public String filePath(int index, String savePath) {\n // not calling the corresponding swig function because internally,\n // the use of the function GetStringUTFChars does not consider the case of\n // a copy not made\n return savePath + File.separator + fs.file_path(index);\n }"
] | codesearchnet | {
"query": "Represent the Github instruction:",
"pos": "Represent the Github code:",
"neg": "Represent the Github code about programming:"
} |
Computes the theta & phi angles of the vector.
@memberof Vec3#
@returns {object} ret
@returns {Number} ret.theta - angle from the xz plane
@returns {Number} ret.phi - angle from the y axis | [
"function() {\n return {\n theta: Math.atan2(this.z, this.x),\n phi: Math.asin(this.y / this.length())\n };\n }"
] | [
"def alignment_matrix_3D(u, v):\n '''\n \n '''\n # normalize both vectors:\n u = normalize(u)\n v = normalize(v)\n # get the cross product of u cross v\n w = np.cross(u, v)\n # the angle we need to rotate\n th = vector_angle(u, v)\n # we rotate around this vector by the angle betwee... | codesearchnet | {
"query": "Represent the Github description about mathematics:",
"pos": "Represent the Github code about mathematics:",
"neg": "Represent the Github code:"
} |
CArray with evenly spaced numbers over a specified interval.
@param $start The starting value of the sequence.
@param $stop The end value of the sequence
@param int $num Number of samples to generate. Default is 50.
@return \CArray | [
"public static function linspace($start, $stop, int $num): \\CArray\n {\n return parent::linspace($start, $stop, $num);\n }"
] | [
"static int getRandomValueFromInterval(\n double randomizationFactor, double random, int currentIntervalMillis) {\n double delta = randomizationFactor * currentIntervalMillis;\n double minInterval = currentIntervalMillis - delta;\n double maxInterval = currentIntervalMillis + delta;\... | codesearchnet | {
"query": "Represent the instruction:",
"pos": "Represent the code:",
"neg": "Represent the code:"
} |
// Digests hashes each segment of each key fragment 26 times and returns them.
// Optionally takes the SpongeFunction to use. Default is Kerl. | [
"func Digests(key Trits, spongeFunc ...SpongeFunction) (Trits, error) {\n\tvar err error\n\tfragments := int(math.Floor(float64(len(key)) / KeyFragmentLength))\n\tdigests := make(Trits, fragments*HashTrinarySize)\n\tbuf := make(Trits, HashTrinarySize)\n\n\th := GetSpongeFunc(spongeFunc, kerl.NewKerl)\n\tdefer h.Res... | [
"@Override\n public void addElement(Map<String, Object> e, Map<String, AggregatorFactory> a)\n {\n // since we return a constant, no need to read from the event\n }"
] | codesearchnet | {
"query": "Represent the Github post about programming:",
"pos": "Represent the Github code about programming:",
"neg": "Represent the Github code:"
} |
Loading hparams from json; can also start from hparams if specified. | [
"def create_hparams_from_json(json_path, hparams=None):\n \"\"\"\"\"\"\n tf.logging.info(\"Loading hparams from existing json %s\" % json_path)\n with tf.gfile.Open(json_path, \"r\") as f:\n hparams_values = json.load(f)\n # Prevent certain keys from overwriting the passed-in hparams.\n # TODO(trandusti... | [
"def list_nodes(self):\n \"\"\"\"\"\"\n self.add_environment_file(user='stack', filename='stackrc')\n ret, _ = self.run(\"ironic node-list --fields uuid|awk '/-.*-/ {print $2}'\", user='stack')\n # NOTE(Gonéri): the good new is, the order of the nodes is preserved and follow the one from... | codesearchnet | {
"query": "Represent the sentence about programming:",
"pos": "Represent the code about programming:",
"neg": "Represent the code about Technology:"
} |
Sort an collection by values using a user-defined comparison function
@param \Closure $callback
@param bool $save_keys maintain index association
@return static | [
"public function sortBy( \\Closure $callback, bool $save_keys = true )\n\t{\n\t\t$items = $this->items;\n\t\t$save_keys ? uasort($items, $callback) : usort($items, $callback);\n\t\treturn new static($items);\n\t}"
] | [
"public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)\n {\n // @todo: Is it possible to store a default value in the DB?\n $fieldDef->defaultValue = new FieldValue();\n $fieldDef->defaultValue->data = array('text' => null);\n }"
] | codesearchnet | {
"query": "Represent the Github post about Programming:",
"pos": "Represent the Github code about Programming:",
"neg": "Represent the Github code:"
} |
Attempts to upload the Docker image for a given tool to
`DockerHub <https://hub.docker.com>`_. | [
"def upload(self, tool: Tool) -> bool:\n \n return self.__installation.build.upload(tool.image)"
] | [
"def create_logstash(self, **kwargs):\n \n logstash = predix.admin.logstash.Logging(**kwargs)\n logstash.create()\n logstash.add_to_manifest(self)\n\n logging.info('Install Kibana-Me-Logs application by following GitHub instructions')\n logging.info('git clone https://githu... | codesearchnet | {
"query": "Represent the Github summarization:",
"pos": "Represent the Github code:",
"neg": "Represent the Github code:"
} |
SET CHECK
@param string $name
@param string $arg
@return $this | [
"public function checks($name, $arg = null) {\n if (empty($arg)) {\n $this->checks[] = $name;\n } else {\n $this->checks[$name] = $arg;\n }\n return $this;\n }"
] | [
"final static function f($op) {return dfcf(function(OP $op) {\n\t\t$c = df_con_hier($m = df_ar(dfpm($op), M::class), __CLASS__); /** @var string $c */ /** @var M $m */\n\t\treturn new $c($m);\n\t}, [dfp($op)]);}"
] | codesearchnet | {
"query": "Represent the sentence about programming:",
"pos": "Represent the code about programming:",
"neg": "Represent the code about programming:"
} |
From a list of top level trees, return the list of contained class definitions | [
"List<JCClassDecl> listClasses(List<JCCompilationUnit> trees) {\n List<JCClassDecl> result = new ArrayList<>();\n for (JCCompilationUnit t : trees) {\n for (JCTree def : t.defs) {\n if (def.hasTag(JCTree.Tag.CLASSDEF))\n result.add((JCClassDecl)def);\n ... | [
"def register (g):\n \n assert isinstance(g, Generator)\n id = g.id()\n\n __generators [id] = g\n\n # A generator can produce several targets of the\n # same type. We want unique occurence of that generator\n # in .generators.$(t) in that case, otherwise, it will\n # be tried twice and we'll... | codesearchnet | {
"query": "Represent the post about programming:",
"pos": "Represent the code about programming:",
"neg": "Represent the code:"
} |
-------------------------------------------------------------------------------------------- | [
"@Override\n\tpublic void configure(Configuration parameters) {\n\n\t\t// enforce sequential configuration() calls\n\t\tsynchronized (CONFIGURE_MUTEX) {\n\t\t\tif (mapreduceInputFormat instanceof Configurable) {\n\t\t\t\t((Configurable) mapreduceInputFormat).setConf(configuration);\n\t\t\t}\n\t\t}\n\t}"
] | [
"public static function run($speech = null)\n\t{\n\t\tif ( ! isset($speech))\n\t\t{\n\t\t\t$speech = 'KILL ALL HUMANS!';\n\t\t}\n\n\t\t$eye = \\Cli::color(\"*\", 'red');\n\n\t\treturn \\Cli::color(\"\n\t\t\t\t\t\\\"{$speech}\\\"\n\t\t\t _____ /\n\t\t\t /_____\\\\\", 'blue').\"\\n\"\n.\\Cli::col... | codesearchnet | {
"query": "Represent the instruction about language and writing:",
"pos": "Represent the code about language and writing:",
"neg": "Represent the code about programming:"
} |
Parses the requested parameter from the given state.<p>
@param state the state
@param paramName the parameter name
@return the parameter value | [
"public static String getParamFromState(String state, String paramName) {\n\n String prefix = PARAM_SEPARATOR + paramName + PARAM_ASSIGN;\n if (state.contains(prefix)) {\n String result = state.substring(state.indexOf(prefix) + prefix.length());\n if (result.contains(PARAM_SEPARA... | [
"@SuppressWarnings(\"unchecked\")\n public <T> Param<T> get(int index) {\n // TODO: Provide a more type safe API. E.g. make index a pojo typed on T which is aligned with the Param<T>\n return (Param<T>) params[index];\n }"
] | codesearchnet | {
"query": "Represent the text about text processing:",
"pos": "Represent the code about text processing:",
"neg": "Represent the code about Software development:"
} |
// intIf returns a if cnd is true, otherwise b | [
"func intIf(cnd bool, a, b int) int {\n\tif cnd {\n\t\treturn a\n\t}\n\treturn b\n}"
] | [
"def rs_calc_syndromes(msg, nsym, fcr=0, generator=2):\n '''\n '''\n # Note the \"[0] +\" : we add a 0 coefficient for the lowest degree (the constant). This effectively shifts the syndrome, and will shift every computations depending on the syndromes (such as the errors locator polynomial, errors evaluato... | codesearchnet | {
"query": "Represent the comment about programming:",
"pos": "Represent the code about programming:",
"neg": "Represent the code about Natural Language Processing:"
} |
Create a writer builder for Ebi41InvoiceType.
@return The builder and never <code>null</code> | [
"@Nonnull\n public static EbInterfaceWriter <Ebi41InvoiceType> ebInterface41 ()\n {\n final EbInterfaceWriter <Ebi41InvoiceType> ret = EbInterfaceWriter.create (Ebi41InvoiceType.class);\n ret.setNamespaceContext (EbInterface41NamespaceContext.getInstance ());\n return ret;\n }"
] | [
"def build(self):\n \"\"\"\"\"\"\n from ambry.orm.config import BuildConfigGroupAccessor\n\n # It is a lightweight object, so no need to cache\n return BuildConfigGroupAccessor(self.dataset, 'buildstate', self._session)"
] | codesearchnet | {
"query": "Represent the Github summarization:",
"pos": "Represent the Github code:",
"neg": "Represent the Github code:"
} |
// SetKey sets the Key field's value. | [
"func (s *GetObjectLegalHoldInput) SetKey(v string) *GetObjectLegalHoldInput {\n\ts.Key = &v\n\treturn s\n}"
] | [
"function Rule(rules) {\n this.rules = rules;\n // Identifies individual rule\n this.name = \"\";\n // Identifies the grammar that this rule belongs to \n this.grammarName = \"\";\n // Identifies types of rules. Rules can have \"types\" that are diff... | codesearchnet | {
"query": "Represent the Github instruction about Programming:",
"pos": "Represent the Github code about Programming:",
"neg": "Represent the Github code:"
} |
// Range check string's length | [
"func Range(str string, params ...string) bool {\n\tif len(params) == 2 {\n\t\tvalue, _ := ToFloat(str)\n\t\tmin, _ := ToFloat(params[0])\n\t\tmax, _ := ToFloat(params[1])\n\t\treturn InRange(value, min, max)\n\t}\n\n\treturn false\n}"
] | [
"private static String keyToGoWithElementsString(String label, DuplicateGroupedAndTyped elements) {\n /*\n * elements.toString(), which the caller is going to use, includes the homogeneous type (if\n * any), so we don't want to include it here. (And it's better to have it in the value, rather\n * tha... | codesearchnet | {
"query": "Represent the description about 32-bit integers:",
"pos": "Represent the code about 32-bit integers:",
"neg": "Represent the code about programming:"
} |
Add command arguments | [
"def add_arguments(self, parser):\n \"\"\"\"\"\"\n parser.add_argument(self._source_param, **self._source_kwargs)\n parser.add_argument('--base', '-b', action='store',\n help= 'Supply the base currency as code or a settings variable name. '\n 'The default is take... | [
"def star_sep_check(self, original, loc, tokens):\n \"\"\"\"\"\"\n return self.check_py(\"3\", \"keyword-only argument separator (add 'match' to front to produce universal code)\", original, loc, tokens)"
] | codesearchnet | {
"query": "Represent the text:",
"pos": "Represent the code:",
"neg": "Represent the code:"
} |
Grab values from the $_SERVER global.
@param mixed $index The index that we will be searching for.
@param boolean $xss_clean Whether we want to clean it or not.
@since 1.0.0
@return mixed | [
"public function server(string $index = '', $xss_clean = false)\n {\n return $this->fetchFromArray($_SERVER, $index, $xss_clean);\n }"
] | [
"private function filter($variable, $filter, $options = null)\n {\n\n //gets a specific external variable and filter it\n //determine what variable name is being used here;\n $this->sanitized = true;\n\n //@TODO To trust or not to trust?\n return filter_var($variable, $filter, ... | codesearchnet | {
"query": "Represent the Github post about programming:",
"pos": "Represent the Github code about programming:",
"neg": "Represent the Github code about programming:"
} |
Get a server by calling {@link AbstractServerPredicate#chooseRandomlyAfterFiltering(java.util.List, Object)}.
The performance for this method is O(n) where n is number of servers to be filtered. | [
"@Override\n public Server choose(Object key) {\n ILoadBalancer lb = getLoadBalancer();\n Optional<Server> server = getPredicate().chooseRoundRobinAfterFiltering(lb.getAllServers(), key);\n if (server.isPresent()) {\n return server.get();\n } else {\n return null... | [
"@Override\n public <T> Streamlet<T> applyOperator(IStreamletOperator<R, T> operator) {\n checkNotNull(operator, \"operator cannot be null\");\n\n // By default, NoneStreamGrouping stategy is used. In this stategy, tuples are forwarded\n // from parent component to a ramdon one of all the instances of the... | codesearchnet | {
"query": "Represent the Github text about Computer Science:",
"pos": "Represent the Github code about Computer Science:",
"neg": "Represent the Github code about Programming:"
} |
Validate that an attribute is greater than another attribute.
@param string $attribute
@param mixed $value
@param array $parameters
@return bool | [
"public function validateGt($attribute, $value, $parameters)\n {\n $this->requireParameterCount(1, $parameters, 'gt');\n\n $comparedToValue = $this->getValue($parameters[0]);\n\n $this->shouldBeNumeric($attribute, 'Gt');\n\n if (is_null($comparedToValue) && (is_numeric($value) && is_n... | [
"protected function setupObject()\n {\n $this->name = $this->getAttribute(\"name\");\n $this->value = $this->getAttribute(\"value\");\n $this->classname = $this->getAttribute(\"class\");\n\n /*\n * Set some default values if they are not specified.\n * This is especially... | codesearchnet | {
"query": "Represent the instruction about Software development:",
"pos": "Represent the code about Software development:",
"neg": "Represent the code about Software development:"
} |
// SetErrorCode returns source code that sets return parameters. | [
"func (r *Rets) SetErrorCode() string {\n\tconst code = `if r0 != 0 {\n\t\t%s = %sErrno(r0)\n\t}`\n\tif r.Name == \"\" && !r.ReturnsError {\n\t\treturn \"\"\n\t}\n\tif r.Name == \"\" {\n\t\treturn r.useLongHandleErrorCode(\"r1\")\n\t}\n\tif r.Type == \"error\" {\n\t\treturn fmt.Sprintf(code, r.Name, syscalldot())\n... | [
"NameAndType nameType(Symbol sym) {\n return new NameAndType(sym.name, sym.externalType(types), types);\n // the NameAndType is generated from a symbol reference, and the\n // adjustment of adding an additional this$n parameter needs to be made.\n }"
] | codesearchnet | {
"query": "Represent the instruction about Natural Language Processing:",
"pos": "Represent the code about Natural Language Processing:",
"neg": "Represent the code about programming:"
} |
// StartPlugins starts all plugins in the correct order. | [
"func (co *Coordinator) StartPlugins() {\n\t// Launch routers\n\tfor _, router := range co.routers {\n\t\tlogrus.Debug(\"Starting \", reflect.TypeOf(router))\n\t\tif err := router.Start(); err != nil {\n\t\t\tlogrus.WithError(err).Errorf(\"Failed to start router of type '%s'\", reflect.TypeOf(router))\n\t\t}\n\t}\n... | [
"def start(self, timeout=None):\n \n\n started = super(Node, self).start(timeout=timeout)\n if started:\n # TODO : return something produced in the context manager passed\n return self._svc_address # returning the zmp url as a way to connect to the node\n # CAR... | codesearchnet | {
"query": "Represent the Github post:",
"pos": "Represent the Github code:",
"neg": "Represent the Github code about programming:"
} |
Get a consumer for a connection. | [
"def consumer(self, conn):\n \"\"\"\"\"\"\n return Consumer(\n connection=conn,\n queue=self.queue.name,\n exchange=self.exchange.name,\n exchange_type=self.exchange.type,\n durable=self.exchange.durable,\n auto_delete=self.exchange.aut... | [
"@Override\n\tpublic void validateSetup(Server server, Query query) throws ValidationException {\n\t\tlogger.info(\"Starting Stackdriver writer connected to '{}', proxy {} ...\", gatewayUrl, proxy);\n\t}"
] | codesearchnet | {
"query": "Represent the instruction:",
"pos": "Represent the code:",
"neg": "Represent the code about Programming:"
} |
Returns the generator reactive power variable set. | [
"def _get_qgen_var(self, generators, base_mva):\n \n Qg = array([g.q / base_mva for g in generators])\n\n Qmin = array([g.q_min / base_mva for g in generators])\n Qmax = array([g.q_max / base_mva for g in generators])\n\n return Variable(\"Qg\", len(generators), Qg, Qmin, Qmax)"
] | [
"def post_build(self, p, pay):\n \n p += pay\n if self.auxdlen != 0:\n print(\"NOTICE: A properly formatted and complaint V3 Group Record should have an Auxiliary Data length of zero (0).\")\n print(\" Subsequent Group Records are lost!\")\n return p"
] | codesearchnet | {
"query": "Represent the comment:",
"pos": "Represent the code:",
"neg": "Represent the code:"
} |
Associations labels getter.
@param \Cake\Datasource\RepositoryInterface $table Table instance
@return mixed[] | [
"public function getAssociationLabels(RepositoryInterface $table) : array\n {\n /** @var \\Cake\\ORM\\Table */\n $table = $table;\n\n $result = [];\n foreach ($table->associations() as $association) {\n if (!in_array($association->type(), $this->searchableAssociations)) {\n... | [
"public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)\n {\n // @todo: Is it possible to store a default value in the DB?\n $fieldDef->defaultValue = new FieldValue();\n $fieldDef->defaultValue->data = array('text' => null);\n }"
] | codesearchnet | {
"query": "Represent the text about Software development:",
"pos": "Represent the code about Software development:",
"neg": "Represent the code:"
} |
Return matched comments
@param int $page
@return array | [
"public function get_comments($page = '') {\n global $DB, $CFG, $USER, $OUTPUT;\n if (!$this->can_view()) {\n return false;\n }\n if (!is_numeric($page)) {\n $page = 0;\n }\n $params = array();\n $perpage = (!empty($CFG->commentsperpage))?$CFG->... | [
"final protected function c() {return dfc($this, function() {/** @var int|null $id $id */return\n\t\t!($id = $this->o()->getCustomerId()) ? null : df_customer($id)\n\t;});}"
] | codesearchnet | {
"query": "Represent the summarization about programming:",
"pos": "Represent the code about programming:",
"neg": "Represent the code about programming:"
} |
End of preview. Expand
in Data Studio
- Downloads last month
- 5