text:
import cryptoRandomString from 'crypto-random-string';
import findUp from 'find-up';
import * as upath from 'upath';
import { XmlDocument } from 'xmldoc';
import * as datasourceNuget from '../../datasource/nuget';
import { logger } from '../../logger';
import { readFile } from '../../util/fs';
import type { Registry } from './types';

async function readFileAsXmlDocument(file: string): Promise<XmlDocument> {
  try {
    return new XmlDocument(await readFile(file, 'utf8'));
  } catch (err) {
    logger.debug({ err }, `failed to parse '${file}' as XML document`);
    return undefined;
  }
}

/* istanbul ignore next */
export function getRandomString(): string {
  return cryptoRandomString({ length: 16 });
}

export function getDefaultRegistries(): Registry[] {
  return datasourceNuget.defaultRegistryUrls.map(
    (registryUrl) =>
      ({
        url: registryUrl,
      } as Registry)
  );
}

export async function getConfiguredRegistries(
  packageFile: string,
  localDir: string
): Promise<Registry[] | undefined> {
  // Valid file names taken from https://github.com/NuGet/NuGet.Client/blob/f64621487c0b454eda4b98af853bf4a528bef72a/src/NuGet.Core/NuGet.Configuration/Settings/Settings.cs#L34
  const nuGetConfigFileNames = ['nuget.config', 'NuGet.config', 'NuGet.Config'];
  // normalize paths, otherwise startsWith can fail because of path delimitter mismatch
  const normalizedLocalDir = upath.normalizeSafe(localDir);
  const nuGetConfigPath = await findUp(nuGetConfigFileNames, {
    cwd: upath.dirname(upath.join(normalizedLocalDir, packageFile)),
    type: 'file',
  });

  if (
    !nuGetConfigPath ||
    upath.normalizeSafe(nuGetConfigPath).startsWith(normalizedLocalDir) !== true
  ) {
    return undefined;
  }

  logger.debug({ nuGetConfigPath }, 'found NuGet.config');
  const nuGetConfig = await readFileAsXmlDocument(nuGetConfigPath);
  if (!nuGetConfig) {
    return undefined;
  }

  const packageSources = nuGetConfig.childNamed('packageSources');
  if (!packageSources) {
    return undefined;
  }

  const registries = getDefaultRegistries();
  for (const child of packageSources.children) {
    if (child.type === 'element') {
      if (child.name === 'clear') {
        logger.debug(`clearing registry URLs`);
        registries.length = 0;
      } else if (child.name === 'add') {
        const isHttpUrl = /^https?:\/\//i.test(child.attr.value);
        if (isHttpUrl) {
          let registryUrl = child.attr.value;
          if (child.attr.protocolVersion) {
            registryUrl += `#protocolVersion=${child.attr.protocolVersion}`;
          }
          logger.debug({ registryUrl }, 'adding registry URL');
          registries.push({
            name: child.attr.key,
            url: registryUrl,
          });
        } else {
          logger.debug(
            { registryUrl: child.attr.value },
            'ignoring local registry URL'
          );
        }
      }
      // child.name === 'remove' not supported
    }
  }
  return registries;
}


text:
@interface UserRegisterNotificationViewController()
{
    IBOutlet UITableView* notificationTableView_;
}
@end

@implementation UserRegisterNotificationViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
}

- (void)viewWillAppear:(BOOL)animated
{
    [notificationTableView_ reloadData];
}

- (void)onSuccess:(AFHTTPRequestOperation *)operation responseObject:(id)responseObject
{
    [super onSuccess:operation responseObject:responseObject];

    [[UserViewData singleton] reset];
    [[UserViewData singleton] setJsonDictionaryData:responseObject];

    [notificationTableView_ reloadData];
}

- (void)onFail:(AFHTTPRequestOperation *)operation error:(NSError*)error
{
    [super onFail:operation error:error];

    [[UserViewData singleton] reset];
    [notificationTableView_ reloadData];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark -
#pragma mark Table View Data Source Methods
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    int count = [[UserViewData singleton] getNotificationCount];
    return count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"cellIdentifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil)
    {
        cell = [self getTableViewCellbyLoadingNib];
    }

    NSUInteger row = [indexPath row];

    NSMutableDictionary* dataItemEelements =  [[UserViewData singleton] getNotificationItem:(int)row];
    AdminPublishTableViewCell* adminPublishTableViewCell = (AdminPublishTableViewCell*)cell;

    NSString* className = [NotificationDataItem getClassName:dataItemEelements];
    NSString* classTime = [NotificationDataItem getClassTime:dataItemEelements];
    if (classTime == nil)
    {
        classTime = @"";
    }

    [adminPublishTableViewCell setClassName:className];
    [adminPublishTableViewCell setClassTime:classTime];
    return cell;
}

- (UITableViewCell*)getTableViewCellbyLoadingNib
{
    NSString* personTableViewCell = @"AdminPublishTableViewCell";

    AdminPublishTableViewCell *cell;
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:personTableViewCell
                                                 owner:self
                                               options:nil];
    for (id oneObject in nib)
    {
        if ([oneObject isKindOfClass:[AdminPublishTableViewCell class]])
        {
            cell = (AdminPublishTableViewCell *)oneObject;
        }
    }
    return cell;
}

-(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath
{
    return [self getTableViewCellbyLoadingNib].frame.size.height;
}

#pragma mark -
#pragma mark Table Delegate Methods
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
    NSUInteger row = [indexPath row];
    NSMutableDictionary* dataItem =  [[UserViewData singleton] getNotificationItem:(int)row];
    if (dataItem == nil)
    {
        return;
    }

    NotificationDataItem* notificationDataItem =  [[NotificationDataItem alloc] init];
    [notificationDataItem setDataItemEelements:dataItem];

    NotificationPublishViewController* notificationPublishViewController = [[NotificationPublishViewController alloc] init];
    [notificationPublishViewController setEditType:EditType_View];
    [notificationPublishViewController setNotificationDataItem:notificationDataItem];
    [self.navigationController pushViewController:notificationPublishViewController animated:YES];

}

@end

redpajama_set_name: RedPajamaGithub


text:
========
Usage
========

Add ``djfractions`` to ``settings.INSTALLED_APPS``

Model Fields
------------

DecimalFractionField
--------------------

.. code-block:: python

    djfractions.models.DecimalFractionField(verbose_name=None,
                                            name=None,
                                            max_digits=None,
                                            decimal_places=None,
                                            limit_denominator=None,
                                            coerce_thirds=True,
                                            **kwargs)

Takes a :class:`fractions.Fraction` value, stores it as a decimal value,
and then returns it as a :class:`fractions.Fraction`. This field is highly
based on Django's :class:`models.DecimalField` implementation and so
the `max_digits` and `decimal_places` arguments are required.

:param str verbose_name: The verbose name of the field
:param str name: Name of the field
:param int max_digits: Maximum number of digits to use for the Decimal representation
:param int decimal_places: Maximum number of decimal places to use for the Decimal representation
:param int limit_denominator:  Limits the fraction's denominator to this value if it is set.
:paraam bool coerce_thirds: If True, then when values which appear to be Decimal values which started as 1/3 or 2/3 will be forced back to 1/3 or 2/3 when retrieved from the database.

Form Fields
-----------

FractionField
________________________________________

.. code-block:: python

    FractionField(max_value=None,
                  min_value=None,
                  coerce_thirds=True,
                  limit_denominator=None,
                  use_mixed_numbers=True)

Returns a :class:`fractions.Fraction` instance.  Takes a string formatted
as a fraction such as 1/4, 1 1/4, 1-1/4, 1 and 1/4, or -1/4 as input in a form.

:param Decimal max_value: The maximum value allowed for this field
:param Decimal min_value: The minimum value allowed for this field
:param int limit_denominator:  Limits the fraction's denominator to this value if it is set.
:param bool coerce_thirds: If True, then when values which appear to be Decimal values which started as 1/3 or 2/3 will be forced back to 1/3 or 2/3 when retrieved from the database.
:param bool use_mixed_numbers: If True initial values which are decimals and floats greater than 1 will be converted to a mixed number such as `1 1/2` in the form field's value.  If False then improper fractions such as `3/2` will be created. Defaults to True.

Example::

  from django import forms
  from djfractions.forms import FractionField

  class MyForm(forms.Form):
      a_fraction = FractionField()

DecimalFractionField
________________________________________

.. code-block:: python

    DecimalFractionField(max_value=None,
                         min_value=None,
                         coerce_thirds=True,
                         limit_denominator=None,
                         use_mixed_numbers=True,
                         max_digits=None,
                         decimal_places=None)

Returns a :class:`decimal.Decimal` instance.  Takes a string formatted
as a fraction such as 1/4, 1 1/4, 1-1/4, 1 and 1/4, or -1/4 as input in a form.

:param bool coerce_thirds: Defaults to True.  If True then .3 repeating is forced to 1/3 rather than 3/10, 33/100, etc. and .66 and .67 are forced to 2/3.
:param int limit_denominator: Set a maximum denominator to be used on fractions created from the field input.
:param bool use_mixed_numbers: If True initial values which are decimals and floats greater than 1 will be converted to a mixed number such as `1 1/2` in the form field's value.  If False then improper fractions such as `3/2` will be created. Defaults to True.
:param max_value: The maximum value allowed
:param min_value: The minimum value allowed
:param int decimal_places: The maximum number of decimal places the resulting Decimal value may have
:param int max_digits: The maximum number of digits, including decimal places, the resulting Decimal may have.

Example::

    from django import forms
    from djfractions.forms import DecimalFractionField

    class MyForm(forms.Form):
        a_fraction = DecimalFractionField()

Template Tags
-------------

display_fraction
________________

``{% display_fraction value limit_denominator allow_mixed_numbers coerce_thirds %}``

The display_fraction tag displays a formatted fraction in an HTML template.  It takes
a value and optional parameters to limit the denominator, allow mixed numbers, and
adjust decimal/float values which usually are the result of rounding thirds back to
thirds based fractions.

The output of this tag can be changed by overriding the ``djfractions/display_fraction.html``
template.  This is because there are a number of style choices you might make depending
on needs.  In some cases  and  tags may cause issues with screen readers.  You
may just want to add css classes for easier styling.  The template context also includes
a ``unicode_entity`` value which has the html entity for the unicode value of a fraction
if one is available.  The unicode html entity is preferred by some people, but only a
small number of fractions are supported (particularly if you must support very old browsers)
and the styling is frequently difficult to match up exactly with  and  tags.::

    {% load fractions %}
    {% display_fraction 1.5 %}

Would output::

    1 1⁄2

The template context:

whole_number
    The whole number part of a fraction.  If ``allow_mixed_numbers`` is False then
    this will always be 0.

numerator
    The numerator of a fraction.  For values which are only a whole number the
    numerator will be 0.

denominator
    The denominator of a fraction.  For values which are only a whole number the
    denominator will be 1 for a fraction of 0/1.

unicode_entity
    The unicode_entity is the html entity for the unicode fraction if one exists.

allow_mixed_numbers
    The value passed to the tag for ``allow_mixed_numbers``.  Knowing this can be
    useful in template display logic.

The following unicode fraction HTML entities are supported by django-fractions.
They may not all be supported by your browser.

+----------+-------+------------+-----------+
| Entity   | IE 11 | Firefox 39 | Chrome 44 |
+==========+=======+============+===========+
| ½ | Yes   | Yes        | Yes       |
+----------+-------+------------+-----------+
| ⅓ | Yes   | Yes        | Yes       |
+----------+-------+------------+-----------+
| ⅔ | Yes   | Yes        | Yes       |
+----------+-------+------------+-----------+
| ¼ | Yes   | Yes        | Yes       |
+----------+-------+------------+-----------+
| ¾ | Yes   | Yes        | Yes       |
+----------+-------+------------+-----------+
| ⅕ | Yes   | Yes        | Yes       |
+----------+-------+------------+-----------+
| ⅖ | Yes   | Yes        | Yes       |
+----------+-------+------------+-----------+
| ⅗ | Yes   | Yes        | Yes       |
+----------+-------+------------+-----------+
| ⅘ | Yes   | Yes        | Yes       |
+----------+-------+------------+-----------+
| ⅙ | Yes   | Yes        | Yes       |
+----------+-------+------------+-----------+
| ⅚ | Yes   | Yes        | Yes       |
+----------+-------+------------+-----------+
| &frac17; | No    | No         | Yes       |
+----------+-------+------------+-----------+
| ⅛ | Yes   | Yes        | Yes       |
+----------+-------+------------+-----------+
| ⅜ | Yes   | Yes        | Yes       |
+----------+-------+------------+-----------+
| ⅝ | Yes   | Yes        | Yes       |
+----------+-------+------------+-----------+
| ⅞ | Yes   | Yes        | Yes       |
+----------+-------+------------+-----------+

display_improper_fraction
_________________________

``{% display_improper_fraction value limit_denominator coerce_thirds %}``

The display_improper_fraction tag works the same as display_fraction with
its allow_mixed_numbers set to False.  It is just a shortcut for a common
use case.::

    {% load fractions %}
    {% display_improper_fraction 1.5 %}

Would output::

    3⁄2


text:
/* ###
 * IP: GHIDRA
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package ghidra.program.database.symbol;

import static org.junit.Assert.*;

import java.util.Iterator;

import org.junit.*;

import ghidra.program.database.ProgramBuilder;
import ghidra.program.database.ProgramDB;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.*;
import ghidra.program.model.mem.MemoryBlock;
import ghidra.program.model.symbol.*;
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
import ghidra.util.task.TaskMonitorAdapter;

/**
 */
public class NamespaceManagerTest extends AbstractGhidraHeadedIntegrationTest {

	private NamespaceManager namespaceManager;
	private SymbolTable symbolMgr;
	private FunctionManager functionMgr;
	private ProgramDB program;
	private AddressSpace space;
	private int transactionID;
	private Namespace globalNamespace;

	/**
	 * Constructor for NamespaceManagerTest.
	 * @param arg0
	 */
	public NamespaceManagerTest() {
		super();
	}

	@Before
	public void setUp() throws Exception {
		program = createDefaultProgram("Test", ProgramBuilder._TOY, this);
		space = program.getAddressFactory().getDefaultAddressSpace();
		namespaceManager = program.getNamespaceManager();
		symbolMgr = program.getSymbolTable();
		functionMgr = program.getFunctionManager();
		globalNamespace = namespaceManager.getGlobalNamespace();
		transactionID = program.startTransaction("Test");
		addBlock("BlockOne", addr(0), 0x1000);
		addBlock("BlockTwo", addr(0x2000), 0x4000);
	}

	@After
	public void tearDown() throws Exception {
		program.endTransaction(transactionID, true);
		program.release(this);
	}

	@Test
	public void testCreateSubNamespace() throws Exception {
		GhidraClass gc =
			symbolMgr.createClass(globalNamespace, "classNamespace", SourceType.USER_DEFINED);
		AddressSet set = new AddressSet();
		set.addRange(addr(0), addr(0x30));
		set.addRange(addr(0x250), addr(0x310));
		set.addRange(addr(0x500), addr(0x520));

		Function f1 = functionMgr.createFunction("fun", addr(0x300), set, SourceType.USER_DEFINED);
		f1.setParentNamespace(gc);

		AddressSet set2 = new AddressSet();
		set2.addRange(addr(0x100), addr(0x130));
		Function f2 = functionMgr.createFunction("TextFunctionNamespace", addr(0x100), set2,
			SourceType.USER_DEFINED);
		f2.setParentNamespace(gc);

		assertTrue(gc.getBody().hasSameAddresses(set.union(set2)));

		assertEquals(f1, namespaceManager.getNamespaceContaining(addr(0x12)));
		assertEquals(f1, namespaceManager.getNamespaceContaining(addr(0x255)));
		assertEquals(f1, namespaceManager.getNamespaceContaining(addr(0x502)));

		assertEquals(f2, namespaceManager.getNamespaceContaining(addr(0x110)));
	}

	@Test
	public void testGetBody() throws Exception {
		GhidraClass classNamespace =
			symbolMgr.createClass(null, "TestNamespaceClass", SourceType.USER_DEFINED);
		AddressSet set = new AddressSet();
		set.addRange(addr(0), addr(0x30));
		set.addRange(addr(0x250), addr(0x310));
		set.addRange(addr(0x500), addr(0x520));
		Function function =
			functionMgr.createFunction("Function1", addr(0x300), set, SourceType.USER_DEFINED);
		function.setParentNamespace(classNamespace);

		assertEquals(function, symbolMgr.getNamespace(addr(0x510)));

		AddressSet set2 = new AddressSet();
		set2.addRange(addr(0x800), addr(0x900));
		set2.addRange(addr(0x2000), addr(0x2050));

		Function function2 =
			functionMgr.createFunction("Function2", addr(0x850), set2, SourceType.USER_DEFINED);
		function2.setParentNamespace(classNamespace);

		assertEquals(function2, symbolMgr.getNamespace(addr(0x810)));

		AddressSet set3 = new AddressSet();
		set3.addRange(addr(0x3000), addr(0x3500));
		set3.addRange(addr(0x4000), addr(0x5000));

		Function function3 =
			functionMgr.createFunction("Function3", addr(0x3000), set3, SourceType.USER_DEFINED);
		function3.setParentNamespace(classNamespace);

		assertEquals(function3, symbolMgr.getNamespace(addr(0x3100)));

		AddressSetView gcSet = classNamespace.getBody();
		AddressSet newSet = set.union(set2);
		newSet = newSet.union(set3);
		assertTrue(gcSet.hasSameAddresses(newSet));
	}

	@Test
	public void testFullName() throws Exception {
		GhidraClass classNamespace =
			symbolMgr.createClass(null, "TestNamespaceClass", SourceType.USER_DEFINED);
		AddressSet set = new AddressSet();
		set.addRange(addr(0), addr(0x30));
		set.addRange(addr(0x250), addr(0x310));
		set.addRange(addr(0x500), addr(0x520));
		Function f1 = functionMgr.createFunction("F1", addr(0x300), set, SourceType.USER_DEFINED);
		f1.setParentNamespace(classNamespace);

		AddressSet set2 = new AddressSet();
		set2.addRange(addr(0x2000), addr(0x2200));
		set2.addRange(addr(0x2500), addr(0x2800));

		Function f2 = functionMgr.createFunction("F2", addr(0x2000), set2, SourceType.USER_DEFINED);
		f2.setParentNamespace(classNamespace);

		AddressSet set3 = new AddressSet();
		set3.addRange(addr(0x3100), addr(0x3150));

		Function f3 = functionMgr.createFunction("F3", addr(0x3100), set3, SourceType.USER_DEFINED);
		f3.setParentNamespace(classNamespace);

		assertEquals("TestNamespaceClass::F1", f1.getName(true));
		assertEquals("TestNamespaceClass::F2", f2.getName(true));
		assertEquals("TestNamespaceClass::F3", f3.getName(true));
	}

	@Test
	public void testRemoveNamespace() throws Exception {

		GhidraClass classNamespace =
			symbolMgr.createClass(null, "TestNamespaceClass", SourceType.USER_DEFINED);

		AddressSet set = new AddressSet();
		set.addRange(addr(0), addr(0x30));
		set.addRange(addr(0x250), addr(0x310));
		set.addRange(addr(0x500), addr(0x520));

		Function f1 = functionMgr.createFunction("F1", addr(0x300), set, SourceType.USER_DEFINED);
		f1.setParentNamespace(classNamespace);

		AddressSet set2 = new AddressSet();
		set2.addRange(addr(0x2000), addr(0x2200));
		set2.addRange(addr(0x2500), addr(0x2800));

		Function f2 = functionMgr.createFunction("F2", addr(0x2000), set2, SourceType.USER_DEFINED);
		f2.setParentNamespace(classNamespace);
		long id2 = f2.getID();

		AddressSet set3 = new AddressSet();
		set3.addRange(addr(0x3100), addr(0x3150));

		Function f3 = functionMgr.createFunction("F3", addr(0x3100), set3, SourceType.USER_DEFINED);
		f3.setParentNamespace(classNamespace);
		long id3 = f3.getID();

		// delete class; its namespaces should be removed
		symbolMgr.removeSymbolSpecial(classNamespace.getSymbol());

		assertNull(functionMgr.getFunction(id2));
		assertNull(functionMgr.getFunction(id3));
		assertEquals(globalNamespace, namespaceManager.getNamespaceContaining(addr(0x2500)));
		assertEquals(globalNamespace, namespaceManager.getNamespaceContaining(addr(0x100)));
		assertEquals(globalNamespace, namespaceManager.getNamespaceContaining(addr(0x255)));

		Assert.assertTrue("Function 2 should be marked as deleted!", f2.isDeleted());
		Assert.assertTrue("Function 3 should be marked as deleted!", f3.isDeleted());
	}

	@Test
	public void testMoveNamespace() throws Exception {
		GhidraClass classNamespace =
			symbolMgr.createClass(null, "TestNamespaceClass", SourceType.USER_DEFINED);
		GhidraClass classNamespace2 =
			symbolMgr.createClass(null, "TestNamespaceClass2", SourceType.USER_DEFINED);
		GhidraClass classNamespace3 =
			symbolMgr.createClass(null, "TestNamespaceClass3", SourceType.USER_DEFINED);

		AddressSet set = new AddressSet();
		set.addRange(addr(0), addr(0x30));
		set.addRange(addr(0x250), addr(0x310));
		set.addRange(addr(0x500), addr(0x520));

		Function f1 = functionMgr.createFunction("F1", addr(0x300), set, SourceType.USER_DEFINED);
		f1.setParentNamespace(classNamespace);

		AddressSet set2 = new AddressSet();
		set2.addRange(addr(0x100), addr(0x130));

		Function f2 = functionMgr.createFunction("F2", addr(0x100), set2, SourceType.USER_DEFINED);
		f2.setParentNamespace(classNamespace2);

		assertEquals(classNamespace2, f2.getParentNamespace());
		assertTrue(classNamespace2.getBody().hasSameAddresses(set2));
		AddressSetView view = classNamespace2.getBody();
		assertTrue(view.hasSameAddresses(f2.getBody()));

		f2.setParentNamespace(classNamespace3);
		assertEquals(classNamespace3, f2.getParentNamespace());
	}

	@Test
	public void testMoveAddressRange() throws Exception {
		GhidraClass classNamespace =
			symbolMgr.createClass(null, "TestNamespaceClass", SourceType.USER_DEFINED);

		AddressSet set = new AddressSet();
		set.addRange(addr(0), addr(0x30));
		set.addRange(addr(0x250), addr(0x310));
		set.addRange(addr(0x500), addr(0x520));
		Function f1 = functionMgr.createFunction("F1", addr(0x300), set, SourceType.USER_DEFINED);
		f1.setParentNamespace(classNamespace);

		AddressSet set2 = new AddressSet();
		set2.addRange(addr(0x100), addr(0x130));

		Function f2 = functionMgr.createFunction("F2", addr(0x100), set2, SourceType.USER_DEFINED);
		f2.setParentNamespace(classNamespace);

		MemoryBlock[] blocks = program.getMemory().getBlocks();
		namespaceManager.moveAddressRange(blocks[0].getStart(), addr(0x1000), blocks[0].getSize(),
			TaskMonitorAdapter.DUMMY_MONITOR);

		set = new AddressSet();
		set.addRange(addr(0x1000), addr(0x1030));
		set.addRange(addr(0x1250), addr(0x1310));
		set.addRange(addr(0x1500), addr(0x1520));
		set.addRange(addr(0x1100), addr(0x1130));

		assertTrue(classNamespace.getBody().hasSameAddresses(set));

		set2 = new AddressSet();
		set2.addRange(addr(0x1100), addr(0x1130));
		assertTrue(f2.getBody().hasSameAddresses(set2));
	}

	@Test
	public void testMoveAddressRange2() throws Exception {
		GhidraClass classNamespace =
			symbolMgr.createClass(null, "TestNamespaceClass", SourceType.USER_DEFINED);

		AddressSet set = new AddressSet();
		set.addRange(addr(0), addr(0x30));
		set.addRange(addr(0x250), addr(0x310));
		set.addRange(addr(0x500), addr(0x520));
		Function f1 = functionMgr.createFunction("F1", addr(0x300), set, SourceType.USER_DEFINED);
		f1.setParentNamespace(classNamespace);

		AddressSet set2 = new AddressSet();
		set2.addRange(addr(0x100), addr(0x130));
		Function f2 = functionMgr.createFunction("F2", addr(0x100), set2, SourceType.USER_DEFINED);
		f2.setParentNamespace(classNamespace);

		namespaceManager.moveAddressRange(addr(0x300), addr(0x1000), 0x100,
			TaskMonitorAdapter.DUMMY_MONITOR);

		set = new AddressSet();
		set.addRange(addr(0), addr(0x30));
		set.addRange(addr(0x100), addr(0x130));
		set.addRange(addr(0x250), addr(0x2ff));
		set.addRange(addr(0x500), addr(0x520));
		set.addRange(addr(0x1000), addr(0x1010));

		assertTrue(classNamespace.getBody().hasSameAddresses(set));

		assertTrue(f2.getBody().hasSameAddresses(set2));
	}

	@Test
	public void testDeleteAddressRange() throws Exception {
		GhidraClass classNamespace =
			symbolMgr.createClass(null, "TestNamespaceClass", SourceType.USER_DEFINED);

		AddressSet set = new AddressSet();
		set.addRange(addr(0), addr(0x30));
		set.addRange(addr(0x250), addr(0x310));
		set.addRange(addr(0x500), addr(0x520));
		Function f1 = functionMgr.createFunction("F1", addr(0x300), set, SourceType.USER_DEFINED);
		f1.setParentNamespace(classNamespace);

		AddressSet set2 = new AddressSet();
		set2.addRange(addr(0x100), addr(0x130));
		Function f2 = functionMgr.createFunction("F2", addr(0x100), set2, SourceType.USER_DEFINED);
		f2.setParentNamespace(classNamespace);

		functionMgr.removeFunction(addr(0x300));
		AddressSet classSet = new AddressSet(classNamespace.getBody());
		AddressSet newSet = classSet.subtract(set);
		assertTrue(newSet.hasSameAddresses(namespaceManager.getAddressSet(f2)));

		assertEquals(globalNamespace, namespaceManager.getNamespaceContaining(addr(0)));
	}

	@Test
	public void testIsOverlappedNamespace() throws Exception {
		GhidraClass classNamespace =
			symbolMgr.createClass(null, "TestNamespaceClass", SourceType.USER_DEFINED);

		AddressSet set = new AddressSet();
		set.addRange(addr(0), addr(0x30));
		set.addRange(addr(0x250), addr(0x310));
		set.addRange(addr(0x500), addr(0x520));
		functionMgr.createFunction("F1", addr(0x300), set, SourceType.USER_DEFINED);

		AddressSet set2 = new AddressSet();
		set2.addRange(addr(0x100), addr(0x130));
		Function f2 = functionMgr.createFunction("F2", addr(0x100), set2, SourceType.USER_DEFINED);
		f2.setParentNamespace(classNamespace);

		set2 = new AddressSet();
		set2.addRange(addr(0x20), addr(0x50));
		set2.addRange(addr(0x1000), addr(0x3000));

		if (namespaceManager.overlapsNamespace(set2) == null) {
			Assert.fail("Should overlap!");
		}

		set2 = new AddressSet();
		set2.addRange(addr(0xff), addr(0x101));
		set2.addRange(addr(0x1000), addr(0x3000));

		if (namespaceManager.overlapsNamespace(set2) == null) {
			Assert.fail("Should overlap!");
		}

		set2 = new AddressSet();
		set.addRange(addr(0x200), addr(0x210));
		set.addRange(addr(0x55), addr(0xff));
		set2.addRange(addr(0x1000), addr(0x3000));
		if (namespaceManager.overlapsNamespace(set2) != null) {
			Assert.fail("Should not overlap!");
		}
	}

	@Test
	public void testNamespaceIteratorForOverlaps() throws Exception {
		GhidraClass classNamespace =
			symbolMgr.createClass(null, "TestNamespaceClass", SourceType.USER_DEFINED);

		AddressSet set = new AddressSet();
		set.addRange(addr(0), addr(0x30));
		set.addRange(addr(0x250), addr(0x310));
		set.addRange(addr(0x500), addr(0x520));
		Function f1 = functionMgr.createFunction("F1", addr(0x300), set, SourceType.USER_DEFINED);
		f1.setParentNamespace(classNamespace);

		AddressSet set2 = new AddressSet();
		set2.addRange(addr(0x100), addr(0x130));
		Function f2 = functionMgr.createFunction("F2", addr(0x100), set2, SourceType.USER_DEFINED);
		f2.setParentNamespace(classNamespace);

		AddressSet set3 = new AddressSet();
		set3.addRange(addr(0x600), addr(0x700));
		set3.addRange(addr(0x750), addr(0x760));
		set3.addRange(addr(0x770), addr(0x780));
		Function f3 = functionMgr.createFunction("F3", addr(0x600), set3, SourceType.USER_DEFINED);
		f3.setParentNamespace(classNamespace);

		AddressSet set4 = new AddressSet();
		set4.addRange(addr(0x900), addr(0x950));
		set4.addRange(addr(0x960), addr(0x980));
		set4.addRange(addr(0x1000), addr(0x1020));
		set4.addRange(addr(0x1030), addr(0x1050));
		Function f4 = functionMgr.createFunction("F4", addr(0x900), set4, SourceType.USER_DEFINED);
		f4.setParentNamespace(classNamespace);

		AddressSet testSet = new AddressSet();
		testSet.addRange(addr(0x500), addr(0x501));
		testSet.addRange(addr(0x1025), addr(0x1070));

		// should get back only TestFunctionNamespace and TestFunctionNamespace4
		Iterator<Namespace> iter = namespaceManager.getNamespacesOverlapping(testSet);
		assertTrue(iter.hasNext());
		Namespace namespace = iter.next();
		assertNotNull(namespace);
		assertEquals("F1", namespace.getName());

		assertTrue(iter.hasNext());
		namespace = iter.next();
		assertNotNull(namespace);
		assertEquals("F4", namespace.getName());

		assertTrue(!iter.hasNext());

	}

	@Test
	public void testNamespaceIteratorForOverlaps2() throws Exception {
		GhidraClass classNamespace =
			symbolMgr.createClass(null, "TestNamespaceClass", SourceType.USER_DEFINED);

		AddressSet set = new AddressSet();
		set.addRange(addr(0), addr(0x30));
		set.addRange(addr(0x250), addr(0x310));
		set.addRange(addr(0x500), addr(0x520));
		Function f1 = functionMgr.createFunction("F1", addr(0x300), set, SourceType.USER_DEFINED);
		f1.setParentNamespace(classNamespace);

		AddressSet set2 = new AddressSet();
		set2.addRange(addr(0x100), addr(0x130));
		Function f2 = functionMgr.createFunction("F2", addr(0x100), set2, SourceType.USER_DEFINED);
		f2.setParentNamespace(classNamespace);

		AddressSet set3 = new AddressSet();
		set3.addRange(addr(0x600), addr(0x700));
		set3.addRange(addr(0x750), addr(0x760));
		set3.addRange(addr(0x770), addr(0x780));
		Function f3 = functionMgr.createFunction("F3", addr(0x600), set3, SourceType.USER_DEFINED);
		f3.setParentNamespace(classNamespace);

		AddressSet set4 = new AddressSet();
		set4.addRange(addr(0x900), addr(0x950));
		set4.addRange(addr(0x960), addr(0x980));
		set4.addRange(addr(0x1000), addr(0x1020));
		set4.addRange(addr(0x1030), addr(0x1050));
		Function f4 = functionMgr.createFunction("F4", addr(0x900), set4, SourceType.USER_DEFINED);
		f4.setParentNamespace(classNamespace);

		AddressSet testSet = new AddressSet();
		testSet.addRange(addr(0x101), addr(0x101));
		testSet.addRange(addr(0x105), addr(0x110));
		testSet.addRange(addr(0x771), addr(0x772));
		testSet.addRange(addr(0x755), addr(0x757));
		testSet.addRange(addr(0x601), addr(0x602));

		// should get back only TestFunctionNamespace2 and TestFunctionNamespace3
		Iterator<Namespace> iter = namespaceManager.getNamespacesOverlapping(testSet);
		assertTrue(iter.hasNext());
		Namespace namespace = iter.next();
		assertNotNull(namespace);
		assertEquals("F2", namespace.getName());

		assertTrue(iter.hasNext());
		namespace = iter.next();
		assertNotNull(namespace);
		assertEquals("F3", namespace.getName());

		assertTrue(!iter.hasNext());
	}

	private Address addr(long offset) {
		return space.getAddress(offset);
	}

	private void addBlock(String name, Address addr, int length) throws Exception {
		program.getMemory()
				.createInitializedBlock(name, addr, length, (byte) 0,
					TaskMonitorAdapter.DUMMY_MONITOR, false);
	}
}


text:
layout: archive
lang: en
ref: turtlebot3_deeplearning
read_time: true
share: true
author_profile: false
permalink: /docs/en/platform/turtlebot3/deeplearning/
sidebar:
  title: TurtleBot3
  nav: "turtlebot3"
---

# [Tensorflow](#Tensorflow)

Install tensorflow https://www.tensorflow.org/install. I recommand installing with Virtualenv for python3.

Activate the Virtualenv environment by issuing one of the following commands:

``` bash
$ source ~/tensorflow/bin/activate # bash, sh, ksh, or zsh
$ source ~/tensorflow/bin/activate.csh  # csh or tcsh
```

install pip3 packages.
``` bash
pip3 install Keras numpy pandas matplotlib Pillow gym h5py scikit-image
```

install rospkg with pycham.

[File] -> [settings] -> [Project:FILE.py] -> [Project Interpreter]. Change Project Interpreter to python3.5.

Install setuptools and rospkg.

## [TurtleBot3 Fake Node Implementation](#turtlebot3-fake-node-implementation)

**Tip :** The terminal application can be found with the Ubuntu search icon on the top left corner of the screen. Shortcut key for terminal is `Ctrl`-`Alt`-`T`.
{: .notice--info}

Install dependent packages for TurtleBot3 Simulation.

**Note :** turtlebot3_simulation package requires [**TurtleBot3**](http://turtlebot3.robotis.com/en/latest/pc_software.html#install-dependent-packages) package as a prerequisite.
{: .notice--info}

``` bash
$ cd ~/catkin_ws/src/
$ git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
$ cd ~/catkin_ws && catkin_make
```


text:
module AzureDirectUpload
  class Engine < ::Rails::Engine
    isolate_namespace AzureDirectUpload

    config.generators do |g|
      g.test_framework :rspec
    end

    config.to_prepare do
      Dir.glob(Rails.root + "app/decorators/**/*_decorator*.rb").each do |c|
        require_dependency(c)
      end
    end
  end
end


text:
this.Guide_Diagnostic = (function() {
  function Guide_Diagnostic(el) {
    this.$el = $(el);
    this.loadData();
    this.render();
  }

  Guide_Diagnostic.prototype.loadData = function() {
    var dataStr = this.$el.find(".guide-diagnostic-data").text();
    this.data = JSON.parse(dataStr);
  }

  Guide_Diagnostic.prototype.render = function() {
    var self = this;
    var $chart = this.$el.find(".guide-diagnostic-chart");

    $chart.on("click", ".node", function(ev) {
      var props = self.data[ev.currentTarget.id];
      if (props && props.url) {
        window.open(props.url, '_blank').focus();
      }
    });
    $chart.on("click", ".edgeLabel", function(ev) {
      var props = self.data[ev.currentTarget.id];
      if (props && props.url) {
        window.open(props.url, '_blank').focus();
      }
    });
  }

  return Guide_Diagnostic;
})();


text:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.delegatednetwork.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.delegatednetwork.fluent.models.DelegatedControllerInner;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** An array of Delegated controller resources. */
@Fluent
public final class DelegatedControllers {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(DelegatedControllers.class);

    /*
     * An array of Delegated controller resources.
     */
    @JsonProperty(value = "value", required = true)
    private List<DelegatedControllerInner> value;

    /*
     * The URL to get the next set of controllers.
     */
    @JsonProperty(value = "nextLink", access = JsonProperty.Access.WRITE_ONLY)
    private String nextLink;

    /**
     * Get the value property: An array of Delegated controller resources.
     *
     * @return the value value.
     */
    public List<DelegatedControllerInner> value() {
        return this.value;
    }

    /**
     * Set the value property: An array of Delegated controller resources.
     *
     * @param value the value value to set.
     * @return the DelegatedControllers object itself.
     */
    public DelegatedControllers withValue(List<DelegatedControllerInner> value) {
        this.value = value;
        return this;
    }

    /**
     * Get the nextLink property: The URL to get the next set of controllers.
     *
     * @return the nextLink value.
     */
    public String nextLink() {
        return this.nextLink;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (value() == null) {
            throw logger
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property value in model DelegatedControllers"));
        } else {
            value().forEach(e -> e.validate());
        }
    }
}


text:
.slick-pager {
  width: 100%;
  height: 26px;
  border: 1px solid gray;
  border-top: 0;
  vertical-align: middle;
}

.slick-pager .slick-pager-status {
  display: inline-block;
  padding: 6px;
}

.slick-pager .ui-icon-container {
  display: inline-block;
  margin: 2px;
  border-color: gray;
}

.slick-pager .slick-pager-nav {
  display: inline-block;
  float: left;
  padding: 2px;
}

.slick-pager .slick-pager-settings {
  display: block;
  float: right;
  padding: 2px;
}

.slick-pager .slick-pager-settings * {
  vertical-align: middle;
}

.slick-pager .slick-pager-settings a {
  padding: 2px;
  text-decoration: underline;
  cursor: pointer;
}


text:
(function($) {
    // jQuery version selector

    $("#version").change(function() {
        location.hash = $(this).val();
        location.reload();
    });

    // Tests

    var resizeTimeout = 1000; // make sure browser has enough time to resize the window

    module('window');

    asyncTest("afterresize", function() {
        expect(4);

        var eventcount = 0;

        equals(eventcount, 0, "event not yet fired");

        // bind event

        $(window).bind("afterresize", function() {
            eventcount++;
        });

        window.resizeBy(10, 10);
        window.setTimeout(function() {
            equals(eventcount, 1, "event should fire once");

            // test event triggering

            $(window).afterresize();

            equals(eventcount, 2, "event should fire once");

            // unbind event

            $(window).unbind("afterresize");

            window.resizeBy(-10, -10);
            window.setTimeout(function() {
                equals(eventcount, 2, "no event should've been catched");
                start();
            }, resizeTimeout);
        }, resizeTimeout);
    });

    module('shorthand');

    asyncTest("afterresize", function() {
        expect(2);

        var eventcount = 0;

        equals(eventcount, 0, "event not yet fired");

        // bind event

        $(window).afterresize(function() {
            eventcount++;
        });

        window.resizeBy(10, 10);
        window.setTimeout(function() {
            equals(eventcount, 1, "event should fire once");

            // clean up
            $(window).unbind("afterresize");
            window.resizeBy(-10, -10);

            start();
        }, resizeTimeout);
    });

    module('element');

    asyncTest("afterresize", function() {
        expect(4);

        var div = $("<div/>").appendTo('body');

        var eventcount = 0;

        equals(eventcount, 0, "event not yet fired");

        // bind event

        div.bind("afterresize", function() {
            eventcount++;
        });

        window.resizeBy(10, 10);
        window.setTimeout(function() {
            equals(eventcount, 1, "event should fire once");

            // test event triggering

            div.afterresize();

            equals(eventcount, 2, "event should fire once");

            // unbind event

            div.unbind("afterresize");

            window.resizeBy(-10, -10);
            window.setTimeout(function() {
                equals(eventcount, 2, "no event should've been catched");
                start();
            }, resizeTimeout);
        }, resizeTimeout);
    });
})(jQuery);


text:
<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Ajax extends CI_Controller {

    public function staff()
    {
        //Load our library EditorLib
        $this->load->library('EditorLib');

        //`Call the process method to process the posted data
        $this->editorlib->process($_POST);
    }
}


text:
	$r.translate("registration.title.registered")

#elseif ($isRegisteredStatistics)

	$r.translate("registration.title.partialregistered")

#else

	$r.translate("registration.title.notregistered")

#end

		$r.translate("registration.statistics")

		$r.translate("registration.sustainability")

		$r.translate("registration.website")

		$r.translate("registration.thanks", "www.olat.org")

	<fieldset><legend>$r.translate("registration.title")</legend>

$r.render("registration.publishWebSiteSelection")

$r.translate("registration.publishWebSiteSelection", "$webSiteURL")

	#if ($f.isVisible("registration.webSiteDescription"))

		$r.translate("registration.webSiteDescription", "$webSiteURL")
		$r.render("registration.webSiteDescription")
		$r.translate("registration.location")
		$r.render("registration.location")
		$r.render("registration.location_EXAMPLE")

	#end

$r.render("registration.addToAnnounceListSelection")

$r.translate("registration.addToAnnounceListSelection")

	#if ($f.isVisible("registration.email"))

$r.render("registration.email")

$r.render("registration.email_LABEL")

	        	#if($f.hasError("registration.email"))
					$r.render("registration.email_ERROR")
				#end

	#end

			$r.render("save")

	</fieldset>

 ## FF fieldset fix

			$r.translate("registration.summary")

$r.render("registration.summary")


text:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Usuarios extends CI_Controller {

	function __construct(){
		parent::__construct();
		$this->load->model('usuarios_model');
	}

	public function login()
	{
		$usuario = $this->input->post('usuario');
		$contrasena = $this->input->post('contrasena');
		if($this->usuarios_model->validar_credenciales($usuario,$contrasena)){
			$user = $this->usuarios_model->getUser($usuario);

			$_SESSION['user_id'] 		= (int)$user->id_usuario;
			$_SESSION['nombre'] 		= (string)$user->nombres;
			$_SESSION['logged_in']    	= (bool)true;
			redirect(base_url());
		}
		else{
			//Creando un mensaje de error con flashdata
			$this->session->set_flashdata('msgError','El usuario o contraseña es incorrecto');
			redirect(base_url());
		}
	}

	public function logout() {
		// Si la llave logged_in existe y es true la session sigue activa y se destruye manualmente
		if (isset($_SESSION['logged_in'])) {

			$this->session->sess_destroy();
			redirect(base_url());
		} else {

			// Cuando la sesion ha expirado y el usuario llama al método la llave logged_in ya no existe
			// por lo que ya no se puede destruir la sesion y se redirecciona a la pagina principal
			redirect(base_url());
		}
	}

	public function gestionarUsuarios(){
		$this->load->view('plantillas/header');
		$this->load->view('plantillas/sidebar');
		$this->load->view('front_end/gestionar_usuarios');
		$this->load->view('plantillas/footer');
	}

	public function nuevoUsuario(){
		$this->load->helper('form');
		$this->load->view('plantillas/header');
		$this->load->view('plantillas/sidebar');
		$this->load->view('front_end/nuevo_usuario');
		$this->load->view('plantillas/footer');
	}

	public function agregarUsuario(){
		$data = array(
			'nombres' => $this->input->post('nombres'),
			'apellidos' => $this->input->post('apellidos'),
			'nick' => $this->input->post('nick'),
			'contrasena' =>md5($this->input->post('contrasena'))
			);
		$this->usuarios_model->crearUsuario($data);
		redirect(base_url('Usuarios/gestionarUsuarios'));
	}

	public function verUsuarios(){
		$data['usuarios'] = $this->usuarios_model->obtenerUsuarios();
		$this->load->view('plantillas/header');
		$this->load->view('plantillas/sidebar');
		$this->load->view('front_end/ver_usuarios',$data);
		$this->load->view('plantillas/footer');
	}

	public function editarUsuario($id){
		if($_SESSION['user_id'] == 1){
		$this->load->helper('form');
		$data['usuario'] = $this->usuarios_model->getUsuario($id);
		$this->load->view('plantillas/header');
		$this->load->view('plantillas/sidebar');
		$this->load->view('front_end/editar_usuario',$data);
		$this->load->view('plantillas/footer');
		}
		else{
			$this->load->view('plantillas/header');
			$this->load->view('plantillas/sidebar');
			$this->load->view('front_end/gestionar_usuarios');
			$this->load->view('plantillas/footer');
		}
	}

	public function actualizarUsuario(){
		$id = $this->input->post('id');
		$contrasena = $this->input->post('contrasena');
		if(is_null($contrasena))
		{
			$data = array(
			'nombres' => $this->input->post('nombres'),
			'apellidos' => $this->input->post('apellidos'),
			'nick' => $this->input->post('nick'),
			'contrasena' =>$this->input->post('anteriorcontrasena')
			);
		}
		else
		{
			$data = array(
			'nombres' => $this->input->post('nombres'),
			'apellidos' => $this->input->post('apellidos'),
			'nick' => $this->input->post('nick'),
			'contrasena' =>md5($contrasena)
			);
		}
		$this->usuarios_model->actualizarUsuario($data,$id);
		redirect(base_url());
	}

	public function eliminarUsuario($id){
		if($_SESSION['user_id'] == 1){
			$this->usuarios_model->borrarUsuario($id);
			redirect(base_url('Usuarios/gestionarUsuarios'));
		}
		else{
			$this->load->view('plantillas/header');
			$this->load->view('plantillas/sidebar');
			$this->load->view('front_end/error_contenido');
			$this->load->view('plantillas/footer');
		}
	}

	public function perfil(){
		$this->load->helper('form');
		$data['usuario'] = $this->usuarios_model->getUsuario($_SESSION['user_id']);
		$this->load->view('plantillas/header');
		$this->load->view('plantillas/sidebar');
		$this->load->view('front_end/perfil',$data);
		$this->load->view('plantillas/footer');
	}
}


text:
/* $Id: SUPR0IdcClientStubs.c $ */
/** @file
 * VirtualBox Support Driver - IDC Client Lib, Stubs for SUPR0 APIs.
 */

/*
 * Copyright (C) 2008-2015 Oracle Corporation
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 *
 * The contents of this file may alternatively be used under the terms
 * of the Common Development and Distribution License Version 1.0
 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
 * VirtualBox OSE distribution, in which case the provisions of the
 * CDDL are applicable instead of those of the GPL.
 *
 * You may elect to license modified versions of this file under the
 * terms and conditions of either the GPL or the CDDL or both.
 */

/*******************************************************************************
*   Header Files                                                               *
*******************************************************************************/
#include "SUPR0IdcClientInternal.h"
#include <VBox/err.h>
#include <iprt/asm.h>

/**
 * Resolves a symbol.
 *
 * @returns Pointer to the symbol on success, NULL on failure.
 *
 * @param   pHandle     The IDC handle.
 * @param   pszName     The name of the symbol.
 */
static void supR0IdcGetSymbol(PSUPDRVIDCHANDLE pHandle, PFNRT *ppfn, const char *pszName)
{
    SUPDRVIDCREQGETSYM Req;
    int rc;

    /*
     * Create and send a get symbol request.
     */
    Req.Hdr.cb = sizeof(Req);
    Req.Hdr.rc = VERR_WRONG_ORDER;
    Req.Hdr.pSession = pHandle->s.pSession;
    Req.u.In.pszSymbol = pszName;
    Req.u.In.pszModule = NULL;
    rc = supR0IdcNativeCall(pHandle, SUPDRV_IDC_REQ_GET_SYMBOL, &Req.Hdr);
    if (RT_SUCCESS(rc))
        ASMAtomicWritePtr((void * volatile *)ppfn, Req.u.Out.pfnSymbol);
}

/**
 * Resolves a symbol.
 *
 * @returns Pointer to the symbol on success, NULL on failure.
 *
 * @param   pHandle     The IDC handle.
 * @param   pszName     The name of the symbol.
 */
static void supR0IdcGetSymbolBySession(PSUPDRVSESSION pSession, PFNRT *ppfn, const char *pszName)
{
    PSUPDRVIDCHANDLE pHandle = supR0IdcGetHandleFromSession(pSession);
    if (pHandle)
        supR0IdcGetSymbol(pHandle, ppfn, pszName);
}

SUPR0DECL(void *) SUPR0ObjRegister(PSUPDRVSESSION pSession, SUPDRVOBJTYPE enmType, PFNSUPDRVDESTRUCTOR pfnDestructor, void *pvUser1, void *pvUser2)
{
    static DECLCALLBACKPTR(void *, s_pfn)(PSUPDRVSESSION /* pSession */, SUPDRVOBJTYPE /* enmType */, PFNSUPDRVDESTRUCTOR /* pfnDestructor */, void * /* pvUser1 */, void * /* pvUser2 */);
    DECLCALLBACKPTR(void *,          pfn)(PSUPDRVSESSION /* pSession */, SUPDRVOBJTYPE /* enmType */, PFNSUPDRVDESTRUCTOR /* pfnDestructor */, void * /* pvUser1 */, void * /* pvUser2 */);
    pfn = s_pfn;
    if (!pfn)
    {
        supR0IdcGetSymbolBySession(pSession, (PFNRT *)&s_pfn, "SUPR0ObjRegister");
        pfn = s_pfn;
        if (!pfn)
            return NULL;
    }

    return pfn(pSession, enmType, pfnDestructor, pvUser1, pvUser2);
}

SUPR0DECL(int) SUPR0ObjAddRef(void *pvObj, PSUPDRVSESSION pSession)
{
    static DECLCALLBACKPTR(int, s_pfn)(void * /* pvObj */, PSUPDRVSESSION /* pSession */);
    DECLCALLBACKPTR(int,          pfn)(void * /* pvObj */, PSUPDRVSESSION /* pSession */);
    pfn = s_pfn;
    if (!pfn)
    {
        supR0IdcGetSymbolBySession(pSession, (PFNRT *)&s_pfn, "SUPR0ObjAddRef");
        pfn = s_pfn;
        if (!pfn)
            return VERR_NOT_SUPPORTED;
    }

    return pfn(pvObj, pSession);
}

SUPR0DECL(int) SUPR0ObjRelease(void *pvObj, PSUPDRVSESSION pSession)
{
    static DECLCALLBACKPTR(int, s_pfn)(void * /* pvObj */, PSUPDRVSESSION /* pSession */);
    DECLCALLBACKPTR(int,          pfn)(void * /* pvObj */, PSUPDRVSESSION /* pSession */);
    pfn = s_pfn;
    if (!pfn)
    {
        supR0IdcGetSymbolBySession(pSession, (PFNRT *)&s_pfn, "SUPR0ObjRelease");
        pfn = s_pfn;
        if (!pfn)
            return VERR_NOT_SUPPORTED;
    }

    return pfn(pvObj, pSession);
}

SUPR0DECL(int) SUPR0ObjVerifyAccess(void *pvObj, PSUPDRVSESSION pSession, const char *pszObjName)
{
    static DECLCALLBACKPTR(int, s_pfn)(void * /* pvObj */, PSUPDRVSESSION /* pSession */, const char * /* pszObjName */);
    DECLCALLBACKPTR(int,          pfn)(void * /* pvObj */, PSUPDRVSESSION /* pSession */, const char * /* pszObjName */);
    pfn = s_pfn;
    if (!pfn)
    {
        supR0IdcGetSymbolBySession(pSession, (PFNRT *)&s_pfn, "SUPR0ObjVerifyAccess");
        pfn = s_pfn;
        if (!pfn)
            return VERR_NOT_SUPPORTED;
    }

    return pfn(pvObj, pSession, pszObjName);
}


text:
package org.shaf.core.io.emulator;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapreduce.MRJobConfig;

/**
 * A {@link RecordReader}, which writes key-value pairs to the binary files.
 *
 *

 * The behavior of the {@code SequenceWriter} is similar to the behavior of the
 * Hadoop IO class {@code SequenceFileOutputFormat}.
 *

 *
 *

 * The record format:
 *

 *

 *
Key type: Writable

 *
Value type: Writable

 *

 *
 * @author Mykola Galushka
 */
public class SequenceWriter extends FileWriter<Writable, Writable> {

	/**
	 * The key class.
	 */
	private final Class<?> keyClass;

	/**
	 * The value class.
	 */
	private final Class<?> valueClass;

	/**
	 * Constructs a new sequence file writer.
	 *
	 * @param config
	 *            the writer configuration.
	 * @throws IOException
	 *             if the writer has failed to initialize.
	 */
	public SequenceWriter(Configuration config) throws IOException {
		super(config);

		try {
			this.keyClass = Class.forName(config
					.get(MRJobConfig.OUTPUT_KEY_CLASS));
			this.valueClass = Class.forName(config
					.get(MRJobConfig.OUTPUT_VALUE_CLASS));

			super.out.writeUTF(this.keyClass.getCanonicalName());
			super.out.writeUTF(this.valueClass.getCanonicalName());

		} catch (ClassNotFoundException exc) {
			throw new IOException(exc);
		}
	}

	/**
	 * Writes a {@link Record record} to the sequence files.
	 */
	@Override
	public void writeRecord(Record<Writable, Writable> record)
			throws IOException {
		record.getKey().write(super.out);
		record.getValue().write(super.out);
	}
}


text:
package com.google.code.beanmatchers;

import static java.util.Collections.singleton;

import java.util.Random;
import java.util.Set;

class SetGenerator implements ValueGenerator<Set> {

  private final Random random;

  public SetGenerator(Random random) {
    this.random = random;
  }

  public Set generate() {
    return singleton(random.nextInt());
  }
}


text:
If this gem actually talked to a service, you could use it in your Ruby
project. To do so, you would add this line to your application's Gemfile:

    gem 'kiik-api'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install kiik-api

## Usage

```ruby
require 'kiik-api'

```

Enjoy!


text:
<?php

namespace Oro\Bundle\DraftBundle\Doctrine;

use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Query\Filter\SQLFilter;
use Oro\Bundle\DraftBundle\Entity\DraftableInterface;

/**
 * All drafts should be removed from all queries
 */
class DraftableFilter extends SQLFilter
{
    public const FILTER_ID = 'draftable';

    /**
     * Gets the SQL query part to add to a query.
     *
     * @param ClassMetaData $targetEntity
     * @param string $targetTableAlias
     *
     * @return string The constraint SQL if there is available, empty string otherwise.
     */
    public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
    {
        if (!$this->isDraftableEntity($targetEntity)) {
            return '';
        }

        $platform = $this->getConnection()->getDatabasePlatform();

        return $platform->getIsNullExpression($targetTableAlias . '.' . $targetEntity->getColumnName('draftUuid'));
    }

    /**
     * @param ClassMetadata $targetEntity
     * @return bool
     */
    private function isDraftableEntity(ClassMetadata $targetEntity): bool
    {
        return $targetEntity->reflClass->implementsInterface(DraftableInterface::class)
            && $targetEntity->hasField('draftUuid');
    }
}


text:
class AddCommentToRegistration < ActiveRecord::Migration[4.2]
  def change
    add_column :registrations, :comment, :text
  end
end


text:
require 'spec_helper'

describe DynportTools::Features do
  let(:redis) { Redis.new }

  before(:each) do
    DynportTools::Features.features = nil
    keys = redis.keys("features*")
    redis.multi do
      keys.each do |key|
        redis.del(key)
      end
    end
    DynportTools::Features.redis = redis
  end

  describe "defining features" do
    it "adds the features to an array" do
      DynportTools::Features.feature :solr
      DynportTools::Features.feature :sphinx
      DynportTools::Features.features.should == [:solr, :sphinx]
    end

    it "adds the *_enabled_for? method" do
      DynportTools::Features.feature :solr
      DynportTools::Features.should respond_to(:solr_enabled_for?)
    end

    it "returns true when user included in users set" do
      user = double("user", :id => 2)
      DynportTools::Features.feature :solr
      DynportTools::Features.add_user(:solr, user)
      DynportTools::Features.solr_enabled_for?(user).should == true
    end

    it "returns false when user not included in user set" do
      user = double("user", :id => 2)
      DynportTools::Features.feature :solr
      DynportTools::Features.solr_enabled_for?(user).should == false
    end

    it "returns false when user is nil" do
      DynportTools::Features.feature :solr
      DynportTools::Features.solr_enabled_for?(nil).should == false
    end

    it "executes the block given when enabled" do
      user = double("user", :id => 2)
      DynportTools::Features.feature :solr
      DynportTools::Features.add_user(:solr, user)
      called = false
      DynportTools::Features.solr_enabled_for?(user) do
        called = true
      end.should == true
      called.should == true
    end

    it "does not execute the block given when not enabled" do
      DynportTools::Features.feature :solr
      called = false
      DynportTools::Features.solr_enabled_for?(nil) do
        called = true
      end.should == false
      called.should == false
    end
  end

  it "allows setting a redis instance" do
    r = double("my r")
    DynportTools::Features.redis = r
    DynportTools::Features.redis.should == r
  end

  describe "add_user" do
    before(:each) do
      DynportTools::Features.feature :solr
    end

    it "raises an error when feature not defined" do
      lambda {
        DynportTools::Features.add_user(:some_other, double("user", :id => 2))
      }.should raise_error
    end

    it "adds the user id to the specific group" do
      DynportTools::Features.add_user(:solr, double("user", :id => 2))
      DynportTools::Features.add_user(:solr, double("user", :id => 2))
      DynportTools::Features.add_user(:solr, double("user", :id => 4))
      redis.smembers("features/solr/users").should == %w(2 4)
    end
  end

  describe "remove_user" do
    it "correctly removes users" do
      DynportTools::Features.feature :solr
      DynportTools::Features.add_user(:solr, double("user", :id => 2))
      redis.smembers("features/solr/users").should == %w(2)
      DynportTools::Features.remove_user(:solr, double("user", :id => 2))
      redis.smembers("features/solr/users").should == %w()
    end
  end
end


text:
/**
 *	viva.table.js
 *		version 1.0
 *
 */
jQuery.fn.exists = function(){return this.length>0;};

(function($){
	var	VivaTable = function(_table, _table_option){
		this.init( _table , _table_option);
	};

	VivaTable.prototype = {
		constructor:VivaTable,

		_$table:null,
		_$tableBody: null, //Reference to  in the table (jQuery object)
		_table_width : -1,

		mTableOption:null,

		_defaultOption : {		// default Option
				firstColumnCheck: true,

				paging			: true, 		//Enable paging
        		pageSize		: 10, 			//Set page size (default: 10)
        		pageCount		: 5,

        		sorting			: true, 		//Enable sorting
		  		defaultSorting	: '', 			//Set default sorting

		},

		init:function( _table, _table_option ){
			this._$table = _table;

			console.log( "_table_option.sorting", _table_option.sorting );
			//this.mTableOption = $.extend( _table_option, this._defaultOption);
			this.mTableOption = $.extend(  this._defaultOption, _table_option);

			console.log( "this.mTableOption.sorting", this.mTableOption.sorting );

			this._buildTableHeader();
			this._$tableBody = $('

').appendTo(this._$table);

			console.log( "this.mTableOption.pageCount  > " + this.mTableOption.pageCount );
			this._buildClickEvent();
			this._buildSorting();
			this._buildOptionsFromCodes();

			var	self = this;
			$(window).resize(function() {
				console.log("WINDOWS RESIZE");
				self._buildTableContent();
				self._table_width = -1;
				self._adjustTableWidth();
			});
		},

		/*
		 * load data from TableOption.action.listAction
		 */
		load:function() {
			// console.log( this._$table );
			var parameter =  this._getRequestParameter();
			// console.log( parameter );
			this._load(parameter);
			this._adjustTableWidth();
		},

		/*
		 * OpenCreateForm
		 */
		openCreateForm:function() {
			alert("CreateFROM");
		},

		doCheckedCallback:function(){
			console.log("doCheckedCallback called.");

			if( this.mTableOption.checkRecordCallback ) {
				var index = 0;
				var	self = this;

				$(this._$table).find("input[type='checkbox']").each(function(){
					if ($(this).is(":checked")){
						self.mTableOption.checkRecordCallback(self.mTableOption._records[index]);
					}
					index++;
				});
			}
		},

		setFieldOfCreatedialog : function (record) {
			this._setField(record);
		},

		//-----------------------------------------------------------------------------------------------
		//
		// private method.
		//
		_load:function(parameter){
			var	self = this;
			$.ajax({
				  dataType: "json"
				  ,"url": this.mTableOption.actions.listAction
				  ,async: false
				  ,data: parameter
				  ,success: function( data ) {
					  if( data.Result == "OK"){
						  self.mTableOption.totalRecordCount = data.TotalRecordCount;
						  self.mTableOption._records = data.Records;
						  self._buildTableContent(data.Records);
						} else {
							alert(data.ErrorReason);
						}
				  }
				  ,error : function (jqXHR,textStatus,errorThrown  ){
					  alert("System Errorr");
				  }
				});
		},

		_buildTableHeader:function() {
			if( $(this._$table).has("thead").length == 0 ) {
				console.log("TABLE thead has to be build");

				var $thead = $("

");
				$thead.appendTo( this._$table);

				var $tr = $("

");
				$tr.appendTo( $thead );

				// first column
				if(  this.mTableOption.firstColumnCheck ){
					var $th = $("	");
					$th.appendTo( $tr );
					$th.width( 24 );
				}

				// console.log("this.mTableOption.fields.length", this.mTableOption.fields.length);
				for ( var field in this.mTableOption.fields ){
//					console.log(this.mTableOption.fields[field].title);

					var $th = $("	");
					$th.appendTo( $tr );
					$th.attr("vivatable-field", field );
					$th.text(this.mTableOption.fields[field].title);
				}

				// add delete, update column
				var $th = $("	");
				$th.appendTo( $tr );
				$th.width( 24 );

				$del_th = $("	");
				$del_th.appendTo( $tr );
				$del_th.width(24);
			}

		},

		_adjustTableWidth:function() {
			console.log( $(this._$table).width() , $(this._$table).parent().width() , $(this._$table).parent().parent().width()
					,$(this._$table).outerWidth(true) , $(this._$table).parent().outerWidth(true) , $(this._$table).parent().parent().outerWidth(true));

			if( $(this._$table).width() <  $(this._$table).parent().width() ) {
				if( this._table_width < 0 ) {
					this._table_width = $(this._$table).parent().width() ;
				}
				$(this._$table).width( this._table_width );
			}
		},

		/*
		 * build click event for list and delete.
		 */
		_buildClickEvent:function(){

			var self = this;
			$("[vivatable-load]").each(function(){
				if($(this).attr("vivatable-load") == self._$table.selector)  $(this).on({"click":$.proxy(self.load, self)});
			});

			// vivatable-create  for POPUP CREATE FORM
			$("[vivatable-create]").each(function(){
				if($(this).attr("vivatable-create") == self._$table.selector)  $(this).on({"click":$.proxy(self.openCreateForm, self)});
			});

			$("[vivatable-do-checked]").each(function(){
				if($(this).attr("vivatable-do-checked") == self._$table.selector)  $(this).on({"click":$.proxy(self.doCheckedCallback, self)});
			});

		},

		_buildSorting:function() {
			if(!this.mTableOption.sorting ) {
				console.log("SORTING FALSE");
				return ;
			}

			console.log("SORTING TRUE");

			var self = this;
			$(this._$table).find("th[vivatable-field]").each(function(){

				$(this).append("

");
				$(this).css("cursor", "pointer");
				$(this).click(function(){

					var	click_th = this;
					$(self._$table).find("th[vivatable-field]").each(function(){
						if( click_th != this ){
							$(this).removeClass("vivatable-sort-asc");
							$(this).removeClass("vivatable-sort-desc");
						}
					});

					if ( $(this).hasClass("vivatable-sort-asc") ) {
						self.mTableOption.defaultSorting = $(this).attr("vivatable-field") + " DESC";
						$(this).removeClass("vivatable-sort-asc");
						$(this).addClass("vivatable-sort-desc");
					} else {
						self.mTableOption.defaultSorting = $(this).attr("vivatable-field") + " ASC";
						$(this).removeClass("vivatable-sort-desc");
						$(this).addClass("vivatable-sort-asc");
					}
					self.load();
				});
			});
		},

		_buildOptionsFromCodes:function() {
			this._addCodeWithFields();
			this._addCodeWithSelectTag();
			this._requestCode();
			this._setFieldOptionWithCodeValue();
			this._fillSelectWithCode();
		},

		/*
		 * build table body area.
		 */
		_buildTableContent:function( ){
			this._$tableBody.empty();
			this._addUpdateDeleteHeader();

			for ( var i=0; i<this.mTableOption._records.length; i++) {
				this._addRow(this.mTableOption._records[i], i);
			}
			this._buildPageContainer(1, 10, 54);

			// check the width of th
			//Find data columns
            var headerCells = this._$table.find('>thead th');
            //Calculate total width of data columns
            var totalWidthInPixel = 0;
            var theaorical_total_width = 0;

            // normalize column width
            var self = this;
            headerCells.each(function () {
                var $cell = $(this);
                if ($cell.is(':visible') && $cell.attr('vivatable-field') ) {
                	var field = $cell.attr('vivatable-field');
                	// console.log( 'self.mTableOption.fields[field].width : ' + self.mTableOption.fields[field].width );

                	$cell.width(self.mTableOption.fields[field].width);

                	theaorical_total_width += self.mTableOption.fields[field].width;
                    totalWidthInPixel += $cell.outerWidth();
                    // console.log( '$cell.outerWidth() : ' + $cell.outerWidth());
                }
            });
            // console.log( 'totalWidthInPixel : ' + totalWidthInPixel);
            this._$table.width( theaorical_total_width );
		},

		/**
		 * add a column for Update and Delete button.
		 */
		_addUpdateDeleteHeader:function(){
			if( this.mTableOption.didAddUpdateDeleteColumn ) return ;

			this._addHeaderColumn();
			this._addHeaderColumn();

			this.mTableOption.didAddUpdateDeleteColumn = true;
		},
		/**
		 *
		 */
		_addHeaderColumn:function() {
			var count_rows = this._$table.find('>thead tr').size();

			if( count_rows > 1 ){
				this._$table.find(">thead>tr:first-child").each( function(){
//					console.log( "attache count_rows>" + count_rows );
					var $cell = $("	");
					$cell.appendTo( $(this) ).attr("rowspan", count_rows );
					$cell.width(24);
				});
			} else {
				// this._$table.find(">thead>tr:first-child")
			}
		},
		/**
		 *
		 * @param record
		 */
		_addRow:function( record, index ){
			var	$tr = $("

");
			this._$tableBody.append($tr);
			this._addFirstColumnCheckbox($tr);
			this._addCell($tr, record);
			this._addUpdateCell($tr);
			this._addDeleteCell($tr);
			$tr.data("rec-index", index);
		},

		/**
		 *
		 * @param $tr
		 */
		_addFirstColumnCheckbox:function($tr){
			if( this.mTableOption.firstColumnCheck ) {
				var $checkbox_col = $("<input type='checkbox'>	").appendTo($tr);
			}
		},

		_addUpdateCell:function($tr){
			var self = this;
			var $update_cell = $("	").appendTo($tr);
			var $row = $tr;
			$update_cell.click(function(e){
				//self._handleUpdateAction( $(this).parent().data('rec-index') );
				var $dialog = self._popupUpdateForm( $(this).parent().data('rec-index') );

				var rec_index = $(this).parent().data('rec-index');
				var data = new Object();
				data.form      = $("#vivatable-update-popup");
				data.formType  = 'edit';
				data.record    = self.mTableOption._records[ rec_index];
				data.row       = $row;

				if( self.mTableOption.formCreated ) {
					self.mTableOption.formCreated(e,  data);
				}

				$dialog.find("#vivatable-update-button").click(function(e){
					self._handleUpdateAction( rec_index );
					if( self.mTableOption.formClosed ) self.mTableOption.formClosed(e,  data);
				});

			});
		},

		//-------------------------------------------------------------------
		// update FORM part
		//-------------------------------------------------------------------
		_popupUpdateForm:function(index){
			var	$dialog = this._makeupDialogFrame();

			var	$dialog_content = $dialog.find(".modal-body");

			for (var field in this.mTableOption.fields ) {
				    fieldContents = this.mTableOption.fields[field];
				    if( this.mTableOption.fields[field].key){
				    	this._makeupJustField( this.mTableOption.fields[field].title, field, this.mTableOption._records[index][field], 	$dialog_content );
				    } else {
				    	this._makeupTextInput ( this.mTableOption.fields[field].title, field, this.mTableOption._records[index][field], 	$dialog_content );
				    }
			}

			$dialog.modal({
				backdrop: false,
  				keyboard: false
			});

			return $dialog;
		},

		_makeupDialogFrame:function() {
			if( $("body div#vivatable-dialog").exists() ) {
				return $("body div#vivatable-dialog");
			};

			var template = "
"
				+ "
"
				+"<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>"
				+"
Dialog
"
				+"
"
				+"
"
				+"
"
				+"
"
				+"<button class='btn' data-dismiss='modal' aria-hidden='true'>Close</button>"
				+"<button id='vivatable-update-button' class='btn btn-primary'>Update</button>"
				+"

";

				return $(template).appendTo("body");
		},

		_makeupJustField:function(label, name, value, parent_selector) {
			if( value == undefined ) value = null;

			var row_markup = "
" +   label + "" + value + "";
			parent_selector.append( row_markup );
		},
		_makeupTextInput:function( label, name, value, parent_selector ){
			if( value == undefined ) value = "";

			var row_markup = "
" +   label + "<input type='text' name='"+name+"' value='" + value + "'>
";
			parent_selector.append( row_markup );
		},

		_makeupCodeSelect:function(label, name, value, parent_selector ){

		},

		_makeupRadio:function(label, name, value, parent_selector ) {

		},
		//--------------------------------------------------------------------

		_handleUpdateAction:function( rec_index){
			console.log("_handleUpdateAction called", rec_index);
			var parameter = this._getKeyParameter(rec_index);
			parameter
			$.ajax({
				  dataType: "json"
				  ,"url": this.mTableOption.actions.updateAction
				  ,async: false
				  ,data: parameter
				  ,success: function( data ) {
					  if( data.Result == "OK"){
						  this.load();
						} else {
							alert(data.ErrorReason);
						}
				  }
				  ,error : function (jqXHR,textStatus,errorThrown  ){
					  alert("System Errorr");
				  }
				});
		},

		_addDeleteCell:function($tr){
			var self = this;

			var $delete_cell = $("	").appendTo($tr);
			$delete_cell.click(function(){
				self._popupDeleteConfirmDialog( $(this).parent().data("rec-index"));
			});
		},

		_popupDeleteConfirmDialog:function( rec_index ){
			if( confirm("Delete"))
					this._handleDeleteAction( rec_index );
		},

		_handleDeleteAction:function( rec_index){
			console.log("_handleDeleteAction called", rec_index);
			var parameter = this._getKeyParameter(rec_index);
			parameter
			$.ajax({
				  dataType: "json"
				  ,"url": this.mTableOption.actions.deleteAction
				  ,async: false
				  ,data: parameter
				  ,success: function( data ) {
					  if( data.Result == "OK"){
						  this.load();
						} else {
							alert(data.ErrorReason);
						}
				  }
				  ,error : function (jqXHR,textStatus,errorThrown  ){
					  alert("System Errorr");
				  }
				});
		},

		/**
		 *
		 * @param $tr
		 * @param record
		 */
		_addCell:function($tr, record){
			for (var field in this.mTableOption.fields ) {
				$td = $("	").appendTo($tr);

				if( this.mTableOption.fields[field].listClass ){
					$td.addClass(this.mTableOption.fields[field].listClass);
				}

				var cell_text = "";
				if( this.mTableOption.fields[field].options ){
					for ( var i=0; i < this.mTableOption.fields[field].options.length; i++ ){
						// console.log( "_addCell", this.mTableOption.fields[field].options[i].Value, record[field]);

						if(  this.mTableOption.fields[field].options[i].Value == record[field]) {
							cell_text = this.mTableOption.fields[field].options[i].DisplayText;
							//console.log( "_addCell yes", cell_text );
						}
					}
				} else if( this.mTableOption.fields[field].display ) {
					cell_text = this.mTableOption.fields[field].display( record );
				}
				else{
					cell_text = record[field];
				}

				$td.html(cell_text);

				// option
				// add click event handler
				if( this.mTableOption.fields[field].clickHandler ){
					var self = this;
					var cell_click_handler = this.mTableOption.fields[field].clickHandler ;
					$td.click( function(){
						var data = new Object();
						data.self = self;
						data.record = record;
						cell_click_handler(data);
					});
				}
			}
		},

		_buildPageContainer:function( ) {
			// if( this.mTableOption.paging ) return ;
			var	self = this;

			$("div.vivatable-page-container").each(function(){
				$(this).empty();
				var	$page_div = $("

").appendTo( $(this)) ;
				var $page_box = $("

").appendTo($page_div);

				var total_pages = ( self.mTableOption.totalRecordCount - 1) / self.mTableOption.pageSize + 1;

				var	first_page  = parseInt( (self.mTableOption.page-1) / self.mTableOption.pageCount ) * self.mTableOption.pageCount + 1;
				var	last_page   = first_page + self.mTableOption.pageCount > total_pages ? total_pages : first_page + self.mTableOption.pageCount-1;

				if( self.mTableOption.page  > 1 )
					$("
«
").appendTo($page_box).on({"click":$.proxy(self._loadPrevPage, self)});

				for ( var page = first_page ; page <= last_page; page++){
					if ( page == self.mTableOption.page )  {
						$("
" + page + "
").appendTo($page_box);
					} else {
						$("
" + page + "
").appendTo($page_box).on({"click":$.proxy(self._loadPage, self, page )});
					}
				}

				if ( self.mTableOption.page < total_pages )
					$("
»
").appendTo($page_box).on({"click":$.proxy(self._loadNextPage, self)});

			});
		},

		/**
		 * build request parameter
		 *	jtPageSize : paging size.
		 *	jtStartIndex : start 0 for the first record.
		 * @returns {Object}
		 */
		_getRequestParameter:function(){
			var	param = new Object();

			for (var field in this.mTableOption.fields ) {
				    fieldContents = this.mTableOption.fields[field];
				    if( fieldContents.conditionInputID && $(fieldContents.conditionInputID).val() ){
				    	param[field] = $(fieldContents.conditionInputID).val();
				    }
			}

			if( ! this.mTableOption.page ) this.mTableOption.page = 1;
			param["jtPageSize"]   =  this.mTableOption.pageSize ;
			param["jtStartIndex"] =  (this.mTableOption.page-1) *  this.mTableOption.pageSize ;

			// for sorting
			if( this.mTableOption.sorting ){
				param["jtSorting"] = this.mTableOption.defaultSorting;
			}
			return param;
		},

		_getKeyParameter:function(index){
			var	param = new Object();

			for (var field in this.mTableOption.fields ) {
				    fieldContents = this.mTableOption.fields[field];
				    if( fieldContents.key ){
				    	param[field] = this.mTableOption._records[index][field] ;
				    }
			}
			return param;
		},

		_loadPage:function(page) {
			this.mTableOption.page = page;
			this.load();
		},

		_loadPrevPage:function(){
			if(this.mTableOption.page <= 1 ) {
				this.mTableOption.page = 1 ;
				return ;
			}
			this.mTableOption.page--;
			this.load();
		},

		_loadNextPage:function(){
			/*
			if(this.mTableOption.page > 1 ) {
				this.mTableOption.page = 1 ;
				return ;
			}
			*/
			this.mTableOption.page++;
			this.load();
		},

		//######################   code option  begin ######################
		_codeExpress : null,
		_codes  	 : null,

		_addCodeWithFields : function() {
			for (var field in this.mTableOption.fields ) {
				if( this.mTableOption.fields[field].codeOption ) {
					this._addCode ( this.mTableOption.fields[field].codeOption );
				}
			}
		},

		_addCodeWithSelectTag : function () {
			var self = this;
			if( this.mTableOption.createDialogID ){
				$( this.mTableOption.createDialogID ).find("select").each(function(){
//					console.log("_addCodeWithSelectTag  >> " , this );
					var code = $(this).attr("vivatable-code");
					if( code != undefined && code != null ){
						self._addCode(code);
					}
				});
			}
		},

		_addCode : function(code){
			if( this._codeExpress == null || this._codeExpress.length == 0 ){
				this._codeExpress = "'" + code + "'";
			} else {
				this._codeExpress += ",'" + code + "'";
			}
			return ;
		},

		_setField : function( record ){
			if( this.mTableOption.createDialogID == undefined ) return ;

			$( this.mTableOption.createDialogID).find("input").each( function(){
				if( $(this).attr('viva-field')) {
					$(this).val( record [$(this).attr('viva-field')] );
				}
			});
		},

		_requestCode : function() {

			if( this._codeExpress == null ) return ;
			if( this._codeExpress.length == 0 ) return ;

			var self= this;
			var	parameter = new Object();
			parameter.Code  = this._codeExpress;

			$.ajax({
				  dataType: "json"
				  , "url":"/vivaCCP/s/code"
				  , async: false
				  , data: parameter
				  , success: function( data ) {
					  if( data.Result == "OK"){
							console.log("data.Options", data.Options);
							self._codes = data.Options;
						} else {
							alert(data.ErrorReason);
						}
				  }
				  ,error : function (jqXHR,textStatus,errorThrown  ){
					  alert("System Errorr");
				  }
				});
		},

		_setFieldOptionWithCodeValue : function() {
			for (var field in this.mTableOption.fields ) {
				if( this.mTableOption.fields[field].codeOption ) {
					this.mTableOption.fields[field].options = this._getCertainCode(this.mTableOption.fields[field].codeOption);
				}
			}
		},

		_getCertainCode : function( code_name ){
			var	code_arr = new Array();
			for ( var i=0; i<this._codes.length; i++){
				if( this._codes[i].Code == code_name) {
					code_arr.push( this._codes[i] );
				}
			}
			return code_arr;
		},

		_fillSelectWithCode : function( ){
			if( this._codes == null ) return;

			for ( var i=0; i< this._codes.length; i++ ){
				var	code_rec = this._codes[i];
				$(this.mTableOption.createDialogID).find("select[vivatable-code='" + code_rec.Code +"']").append("<option value='" + code_rec.Value + "'>" + code_rec.DisplayText );
			}
		}

		//######################   code option  end   ######################
	};

	$.fn.vivaTable = function( _table_otpion){
		// console.log("viva table Yap", _table_otpion );
		var $this = $(this),     vivatable = $this.data('vivatable');
		if( ! vivatable  ){
			// console.log("NO viva table instance", _table_otpion.sorting );
			vivatable = new VivaTable($this, _table_otpion);
			$this.data('vivatable', vivatable);
		}
		return vivatable;
	};
})(jQuery);


text:
package org.jgrades.rest.admin.structures;

import org.jgrades.admin.api.structures.AcademicYearMgntService;
import org.jgrades.data.api.entities.AcademicYear;
import org.jgrades.lic.api.aop.CheckLicence;
import org.jgrades.logging.JgLogger;
import org.jgrades.logging.JgLoggerFactory;
import org.jgrades.monitor.api.aop.CheckSystemDependencies;
import org.jgrades.rest.api.admin.structures.IAcademicYearService;
import org.jgrades.rest.common.AbstractRestCrudPagingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/academicyear", produces = MediaType.APPLICATION_JSON_VALUE)
@CheckSystemDependencies
@CheckLicence
public class AcademicYearService extends AbstractRestCrudPagingService<AcademicYear, Long, AcademicYearMgntService> implements IAcademicYearService {
    private static final JgLogger LOGGER = JgLoggerFactory.getLogger(AcademicYearService.class);

    @Autowired
    protected AcademicYearService(AcademicYearMgntService crudService) {
        super(crudService);
    }

    @Override
    @RequestMapping(value = "/active", method = RequestMethod.GET)
    @PreAuthorize("isAuthenticated()")
    public AcademicYear getActive() {
        getLogger().trace("Getting active academic year");
        return crudService.getActiveAcademicYear();
    }

    @Override
    @RequestMapping(value = "/{id}/active", method = RequestMethod.POST)
    @PreAuthorize("hasAnyRole('ADMINISTRATOR','MANAGER')")
    public void setActive(@PathVariable Long id) {
        getLogger().trace("Setting as active an academic year with id {}", id);
        crudService.setActiveAcademicYear(crudService.getWithId(id));
    }

    @Override
    protected JgLogger getLogger() {
        return LOGGER; //NOSONAR
    }
}


text:
Nemo
====

Nemo is a scripting, interpreted, statically and strongly typed programming (well, that's the plan) language written in ANSI C.

**Note** I'm rewriting Nemo from the ground up. There's not much to see right now.

Install
=======

**1**. Obtain the sources

```sh
$ git clone https://github.com/semahawk/nemo.git
```

**2**. Compile

```sh
$ cmake . \
    [-DDEBUG=ON|YES|1] \
    [-DBINDIR=/where/to/install/binaries]  \
    [-DINCDIR=/where/to/install/headers]   \
    [-DLIBDIR=/where/to/install/libraries] \
$ make
$ sudo make install
```

The default values for the specific options are:

```sh
DEBUG:  0
BINDIR: "/usr/local/bin"
INCDIR: "/usr/local/include"
LIBDIR: "/usr/local/lib"
```

Dependencies
============

* C99 compatible C compiler
* CMake
* make

What's what
===========

  cmake/
  CMake build-only related files

  ext/
  External files/libraries, sometimes replacements for existing libc functions

  ast.c
  AST related stuff - node creation, execution etc.

  lexer.c
  The lexer, tokenizing, keywords list etc.

  mem.c
  Basically just malloc/realloc/calloc wrappers

  nemo.c
  The main file of the executable, contains main(), the REPL

  parser.c
  The (recursive-descent) parser and all the grammar

  utf8.c
  Handful of handy functions to help with UTF-8

  util.c
  Handful of handy functions to help with anything else

License
=======

This code is licensed under the New / Modified (3 clause) BSD License.
For more details, please visit the LICENSE file.


text:
using System;
using Alteridem.GitHub.Extension.Interfaces;
using Alteridem.GitHub.Model;
using Alteridem.Tfs.Model;
using Octokit;

namespace Alteridem.GitHub.Extension.Test.Mocks
{
    public class IssueEditorMock : IIssueEditor
    {
        private Issue _issue;

        public void Close()
        {
        }

        public bool? ShowModal()
        {
            _issue.Title = "new title";
            _issue.Body = "new body";

            var api = Factory.Get<GitHubApiBase>();
            api.Issue = _issue;

            return true;
        }

        public bool IsEnabled { get; set; }

        /// <summary>
        /// Sets the issue to add/edit
        /// </summary>
        /// <param name="issue">The issue.</param>
        public void SetIssue(Issue issue)
        {
            _issue = issue ?? new Issue();
        }

        public void SetTfsIssue(TfsWorkItem issue)
        {
            throw new NotImplementedException();
        }
    }
}