cloudmesh.common package¶
Subpackages¶
Submodules¶
cloudmesh.common.Benchmark module¶
-
class
cloudmesh.common.Benchmark.
Benchmark
[source]¶ Bases:
object
-
static
file
(path, n)[source]¶ create a file of given size in MB, the MB here is in binary not SI units. e.g. 1,048,576 Bytes
- Example: s = BenchmarkFiles.size(“./sise.txt”, 2)
print(s)
- Parameters
path (string) – the filename and path
n (integer) – the size in binary MB
- Returns
size in MB
- Return type
-
static
cloudmesh.common.DateTime module¶
-
class
cloudmesh.common.DateTime.
DateTime
[source]¶ Bases:
object
This class provides some simple date time functions so we can use all the same format. Here is a simple example
start = DateTime.now() stop = DateTime.now() + DateTime.delta(1)
print (“START”, start) print (“STOP”, stop) print(“HUMANIZE STOP”, DateTime.humanize(stop - start)) print (“LOCAL”, DateTime.local(start)) print(“UTC”, DateTime.utc(start)) print(“NATURAL”, DateTime.natural(start)) print(“WORDS”, DateTime.words(start)) print(“TIMEZONE”, DateTime.timezone)
This will result in
START 2019-08-03 21:34:14.019147 STOP 2019-08-03 21:34:15.019150 HUMANIZE STOP a second ago LOCAL 2019-08-03 17:34:14 EST UTC 2019-08-03 21:34:14.019147 UTC NATURAL 2019-08-03 21:34:14.019147 UTC WORDS Sat 6 Aug 2019, 21:34:14 UTC TIMEZONE EST
-
timezone
= 'EST'¶
-
cloudmesh.common.DictList module¶
-
class
cloudmesh.common.DictList.
DictList
(entries=None, key='name', position='x')[source]¶ Bases:
dict
A class to convert lists of dicts to dicts.
Example:
data = [ {“name”: “vm1”, “status”: “on”}, {“name”: “vm2”, “status”: “on”}, {“name”: “vm3”, “status”: “on”}, {“name”: “vm4”, “status”: “on”}, ]
d = DictList(data) pprint (d)
# {‘vm1’: {‘name’: ‘vm1’, ‘status’: ‘on’, ‘x’: 0}, # ‘vm2’: {‘name’: ‘vm2’, ‘status’: ‘on’, ‘x’: 1}, # ‘vm3’: {‘name’: ‘vm3’, ‘status’: ‘on’, ‘x’: 2}, # ‘vm4’: {‘name’: ‘vm4’, ‘status’: ‘on’, ‘x’: 3}}
print (d[‘vm1’]) # {‘name’: ‘vm1’, ‘status’: ‘on’, ‘x’: 0} # print (d.list()) # [{‘name’: ‘vm1’, ‘status’: ‘on’, ‘x’: 0}, # {‘name’: ‘vm2’, ‘status’: ‘on’, ‘x’: 1}, # {‘name’: ‘vm3’, ‘status’: ‘on’, ‘x’: 2}, # {‘name’: ‘vm4’, ‘status’: ‘on’, ‘x’: 3}]
cloudmesh.common.FlatDict module¶
-
class
cloudmesh.common.FlatDict.
FlatDict
(d, sep='__')[source]¶ Bases:
dict
A data structure to manage a flattened dict. It is initialized by passing the dict at time of initialization.
-
property
dict
¶ returns the dict :return: dict
-
search
(key, value=None)[source]¶ returns from a flatdict all keys that match the given pattern and have the given value. If the value None is specified or ommitted, all keys are returned regardless of value.
Example:
search(“cloudmesh.cloud.*.cm.active”, True)
- Parameters
key – The key pattern to be searched (given as regex)
value – The value
- Returns
keys matching the vakue in flat dict format.
-
property
-
class
cloudmesh.common.FlatDict.
FlatDict2
[source]¶ Bases:
object
-
classmethod
convert
(obj, flatten=True)[source]¶ This function converts object into a Dict optionally Flattening it :param obj: Object to be converted :param flatten: boolean to specify if the dict has to be flattened :return dict: the dict of the object (Flattened or Un-flattened)
-
primitive
= (<class 'int'>, <class 'str'>, <class 'bool'>, <class 'str'>, <class 'bytes'>, <class 'dict'>, <class 'list'>)¶
-
classmethod
-
cloudmesh.common.FlatDict.
flatten
(d, parent_key='', sep='__')[source]¶ flattens the dict into a one dimensional dictionary
- Parameters
d – multidimensional dict
parent_key – replaces from the parent key
sep – the separation character used when fattening. the default is __
- Returns
the flattened dict
-
cloudmesh.common.FlatDict.
key_prefix_replace
(d, prefix, new_prefix='')[source]¶ replaces the list of prefix in keys of a flattened dict
- Parameters
d – the flattened dict
prefix (list of str) – a list of prefixes that are replaced with a new prefix. Typically this will be “”
new_prefix – The new prefix. By default it is set to “”
- Returns
the dict with the keys replaced as specified
cloudmesh.common.Host module¶
-
class
cloudmesh.common.Host.
Host
[source]¶ Bases:
object
-
static
check
(hosts=None, username=None, key='~/.ssh/id_rsa.pub', processors=3)[source]¶ - Parameters
hosts – a list of hosts to be checked
username – the usernames for the hosts
key – the key for logging in
processors – the number of parallel checks
- Returns
list of dicts representing the ping result
-
static
ping
(hosts=None, count=1, processors=3)[source]¶ ping a list of given ip addresses
- Parameters
hosts – a list of ip addresses
count – number of pings to run per ip
processors – number of processors to Pool
- Returns
list of dicts representing the ping result
-
static
ssh
(hosts=None, command=None, username=None, key='~/.ssh/id_rsa.pub', processors=3)[source]¶ - Parameters
command – the command to be executed
hosts – a list of hosts to be checked
username – the usernames for the hosts
key – the key for logging in
processors – the number of parallel checks
- Returns
list of dicts representing the ping result
-
static
cloudmesh.common.Printer module¶
Convenient methods and classes to print tables.
-
class
cloudmesh.common.Printer.
Printer
[source]¶ Bases:
object
A simple Printer class with convenient methods to print dictionary, tables, csv, lists
-
classmethod
attribute
(d, header=None, order=None, sort_keys=True, humanize=None, output='table')[source]¶ prints a attribute/key value table
- Parameters
d – A a dict with dicts of the same type. Each key will be a column
order – The order in which the columns are printed. The order is specified by the key names of the dict.
header (A list of string) – The Header of each of the columns
sort_keys (string or a tuple of string (for sorting with multiple columns)) – Key(s) of the dict to be used for sorting. This specify the column(s) in the table for sorting.
output – the output format table, csv, dict, json
-
classmethod
csv
(d, order=None, header=None, humanize=None, sort_keys=True)[source]¶ prints a table in csv format
- Parameters
- Returns
a string representing the table in csv format
-
classmethod
dict
(d, order=None, header=None, output='table', sort_keys=True, humanize=None, show_none='', max_width=48)[source]¶ - Parameters
d (dict) – A a dict with dicts of the same type.
order (list) – The order in which the columns are printed. The order is specified by the key names of the dict.
header (list or tuple of field names) – The Header of each of the columns
output (string) – type of output (table, csv, json, yaml or dict)
sort_keys (bool) – list
show_none (string) – prints None if True for None values otherwise “”
max_width (int) – maximum width for a cell
- Returns
-
classmethod
dict_table
(d, order=None, header=None, sort_keys=True, show_none='', humanize=None, max_width=48)[source]¶ prints a pretty table from an dict of dicts
- Parameters
d – A a dict with dicts of the same type. Each key will be a column
order – The order in which the columns are printed. The order is specified by the key names of the dict.
header (A list of string) – The Header of each of the columns
sort_keys (string or a tuple of string (for sorting with multiple columns)) – Key(s) of the dict to be used for sorting. This specify the column(s) in the table for sorting.
show_none (string) – prints None if True for None values
max_width (int) – maximum width for a cell
-
classmethod
flatwrite
(table, order=None, header=None, output='table', sort_keys=True, show_none='', humanize=None, sep='.', max_width=48)[source]¶ writes the information given in the table :param table: the table of values :param order: the order of the columns :param header: the header for the columns :param output: the format (default is table, values are raw, csv, json, yaml, dict :param sort_keys: if true the table is sorted :param show_none: passed along to the list or dict printer :param sep: uses sep as the separator for csv printer :param max_width: maximum width for a cell :type max_width: int :return:
-
classmethod
list
(l, order=None, header=None, output='table', sort_keys=True, humanize=None, show_none='', max_width=48)[source]¶ - Parameters
l – l is a list not a dict
order –
header –
output –
sort_keys –
show_none –
max_width (int) – maximum width for a cell
- Returns
-
classmethod
print_list
(l, output='table')[source]¶ prints a list :param l: the list :param output: the output, default is a table :return:
-
classmethod
row_table
(d, order=None, labels=None)[source]¶ prints a pretty table from data in the dict.
- Parameters
d – A dict to be printed
order – The order in which the columns are printed. The order is specified by the key names of the dict.
labels – The array of labels for the column
-
classmethod
write
(table, order=None, header=None, output='table', sort_keys=True, humanize=None, show_none='', max_width=48)[source]¶ writes the information given in the table :param table: the table of values :param order: the order of the columns :param header: the header for the columns :param output: the format (default is table, values are raw, csv, json, yaml, dict :param sort_keys: if true the table is sorted :param show_none: passed along to the list or dict printer :param max_width: maximum width for a cell :type max_width: int :return:
-
classmethod
cloudmesh.common.Shell module¶
A convenient method to execute shell commands and return their output. Note: that this method requires that the command be completely execute before the output is returned. FOr many activities in cloudmesh this is sufficient.
-
class
cloudmesh.common.Shell.
Shell
[source]¶ Bases:
object
The shell class allowing us to conveniently access many operating system commands. TODO: This works well on Linux and OSX, but has not been tested much on Windows
-
classmethod
VBoxManage
(*args)[source]¶ executes VboxManage with the given arguments :param args: :return:
-
classmethod
blockdiag
(*args)[source]¶ executes blockdiag with the given arguments :param args: :return:
-
classmethod
check_output
(*args, **kwargs)[source]¶ Thin wrapper around
subprocess.check_output()
-
classmethod
check_python
()[source]¶ checks if the python version is supported :return: True if it is supported
-
classmethod
cm_grep
(lines, what)[source]¶ returns all lines that contain what :param lines: :param what: :return:
-
command
= {'darwin': {}, 'linux': {}, 'windows': {}}¶
-
classmethod
distribution
()[source]¶ executes lsb_release command :param args: :return:
TODO: needs testing
-
classmethod
execute
(cmd, arguments='', shell=False, cwd=None, traceflag=True, witherror=True)[source]¶ Run Shell command
- Parameters
witherror – if set to False the error will not be printed
traceflag – if set to true the trace is printed in case of an error
cwd – the current working directory in which the command is
supposed to be executed. :param shell: if set to true the subprocess is called as part of a shell :param cmd: command to run :param arguments: we do not know yet :return:
-
classmethod
find_lines_with
(lines, what)[source]¶ returns all lines that contain what :param lines: :param what: :return:
-
classmethod
get_python
()[source]¶ returns the python and pip version :return: python version, pip version
-
classmethod
keystone
(*args)[source]¶ executes keystone with the given arguments :param args: :return:
-
classmethod
mkdir
(directory)[source]¶ creates a directory with all its parents in ots name :param directory: the path of the directory :return:
-
classmethod
ping
(host=None, count=1)[source]¶ execute ping :param host: the host to ping :param count: the number of pings :return:
-
classmethod
rackdiag
(*args)[source]¶ executes rackdiag with the given arguments :param args: :return:
-
classmethod
remove_line_with
(lines, what)[source]¶ returns all lines that do not contain what :param lines: :param what: :return:
-
static
run
(command, exit='; exit 0', encoding='utf-8')[source]¶ executes the command and returns the output as string :param command: :param encoding: :return:
-
static
run2
(command, encoding='utf-8')[source]¶ executes the command and returns the output as string. This command also allows execution of 32 bit commands.
- Parameters
command – the program or command to be executed
encoding – encoding of the output
- Returns
-
static
run_timed
(label, command, encoding=None, service=None)[source]¶ runs teh command and uses the StopWatch to time it :param label: name of the StopWatch :param command: the command to be executed :param encoding: the encoding :param service: a prefix to the stopwatch label :return:
-
classmethod
-
class
cloudmesh.common.Shell.
Subprocess
(cmd, cwd=None, stderr=-1, stdout=-1, env=None)[source]¶ Bases:
object
Executes a command. This class should not be directly used, but instead you should use Shell.
cloudmesh.common.StopWatch module¶
Class for starting and stopping named timers.
-
class
cloudmesh.common.StopWatch.
StopWatch
[source]¶ Bases:
object
A class to measure times between events.
-
classmethod
benchmark
(sysinfo=True, csv=True, prefix='#csv', tag=None)[source]¶ prints out all timers in a convenient benchmark table :return: :rtype:
-
debug
= False¶
-
classmethod
get
(name, digits=None)[source]¶ returns the time of the timer.
- Parameters
name (string) – the name of the timer
- Return type
the elapsed time
-
classmethod
get_status
(name)[source]¶ stops the timer with a given name.
- Parameters
name (string) – the name of the timer
-
classmethod
print
(*args)[source]¶ prints a timer. The first argument is the label if it exists, the last is the timer :param args: label, name :return:
-
classmethod
start
(name)[source]¶ starts a timer with the given name.
- Parameters
name (string) – the name of the timer
-
classmethod
status
(name, value)[source]¶ starts a timer with the given name.
- Parameters
name (string) – the name of the timer
status (bool) – the name of a status
-
classmethod
stop
(name)[source]¶ stops the timer with a given name.
- Parameters
name (string) – the name of the timer
-
timer_elapsed
= {}¶
-
timer_end
= {}¶
-
timer_start
= {}¶
-
timer_status
= {}¶
-
verbose
= True¶
-
classmethod
cloudmesh.common.TableParser module¶
-
class
cloudmesh.common.TableParser.
TableParser
(output='dict', header=True, index=None, change=None, strip=True, lower=True, strip_seperator=True, seperator='|', comment_chars='+#')[source]¶ Bases:
object
-
classmethod
convert
(table=None, output='dict', header=True, index=None, change=None, strip=True, lower=True, strip_seperator=True, seperator='|', comment_chars='+#')[source]¶
-
classmethod
cloudmesh.common.console module¶
Printing messages in a console
-
class
cloudmesh.common.console.
Console
[source]¶ Bases:
object
A simple way to print in a console terminal in color. Instead of using simply the print statement you can use special methods to indicate warnings, errors, ok and regular messages.
Example Usage:
Console.warning("Warning") Console.error("Error") Console.info("Info") Console.msg("msg") Console.ok("Success")
One can switch the color mode off with:
Console.color = False Console.error("Error")
The color will be switched on by default.
-
static
TODO
(message, prefix=True, traceflag=True)[source]¶ prints an TODO message
- Parameters
message – the message
prefix – if set to true it prints TODO: as prefix
traceflag – if true the stack trace is retrieved and printed
- Returns
-
static
bullets
(elements)[source]¶ prints elemnets of a list as bullet list
- Parameters
elements – the list
-
color
= True¶
-
static
cprint
(color='BLUE', prefix='', message='')[source]¶ prints a message in a given color
- Parameters
color – the color as defined in the theme
prefix – the prefix (a string)
message – the message
- Returns
-
debug
= True¶
-
classmethod
error
(message, prefix=True, traceflag=False)[source]¶ prints an error message
- Parameters
message – the message
prefix – a prefix for the message
traceflag – if true the stack trace is retrieved and printed
- Returns
-
static
get
(name)[source]¶ returns the default theme for printing console messages
- Parameters
name – the name of the theme
- Returns
-
static
info
(message)[source]¶ prints an informational message
- Parameters
message – the message
- Returns
-
classmethod
set_debug
(on=True)[source]¶ sets debugging on or of
- Parameters
on – if on debugging is set
- Returns
-
static
set_theme
(color=True)[source]¶ defines if the console messages are printed in color
- Parameters
color – if True its printed in color
- Returns
-
static
text
(color='RED', prefix=None, message=None)[source]¶ returns a message in a given color
- Parameters
color – the color as defined in the theme
prefix – the prefix (a string)
message – the message
- Returns
-
theme
= {'BLACK': '\x1b[30m', 'BLUE': '\x1b[34m', 'BOLD': '\x1b[1m', 'CYAN': '\x1b[36m', 'ENDC': '\x1b[0m', 'FAIL': '\x1b[31m', 'GREEN': '\x1b[32m', 'HEADER': '\x1b[35m', 'NORMAL': '\x1b[22m', 'OKBLUE': '\x1b[34m', 'OKGREEN': '\x1b[32m', 'RED': '\x1b[31m', 'WARNING': '\x1b[35m', 'WHITE': '\x1b[37m'}¶
-
theme_bw
= {'BLACK': '', 'BLUE': '', 'BOLD': '', 'CYAN': '', 'ENDC': '', 'FAIL': '', 'GREEN': '', 'HEADER': '', 'NORMAL': '', 'OKBLUE': '', 'OKGREEN': '', 'RED': '', 'WARNING': '', 'WHITE': ''}¶
-
theme_color
= {'BLACK': '\x1b[30m', 'BLUE': '\x1b[34m', 'BOLD': '\x1b[1m', 'CYAN': '\x1b[36m', 'ENDC': '\x1b[0m', 'FAIL': '\x1b[31m', 'GREEN': '\x1b[32m', 'HEADER': '\x1b[35m', 'NORMAL': '\x1b[22m', 'OKBLUE': '\x1b[34m', 'OKGREEN': '\x1b[32m', 'RED': '\x1b[31m', 'WARNING': '\x1b[35m', 'WHITE': '\x1b[37m'}¶
-
static
cloudmesh.common.debug module¶
-
cloudmesh.common.debug.
VERBOSE
(msg, label=None, color='BLUE', verbose=9, location=True, secrets=['OS_PASSWORD', 'OS_USERNAME', 'client_secret', 'client_id', 'project_id', 'AZURE_TENANT_ID', 'AZURE_SUBSCRIPTION_ID', 'AZURE_APPLICATION_ID', 'AZURE_SECRET_KEY: TBD', 'EC2_ACCESS_ID: TBD', 'EC2_SECRET_KEY', 'MONGO_PASSWORD'])[source]¶ Prints a data structure in verbose mode
- Parameters
msg – the msg to be printed, can be a data structure such as a dict
label – the label to be used, defaults to the name of the msg variable
color – the color
verbose – indicates when to print it. If verbose in cloudmesh is higher than the specified value it is printed
- Returns
cloudmesh.common.default module¶
cloudmesh.common.deprecated module¶
cloudmesh.common.dotdict module¶
cloudmesh.common.error module¶
A simple framework to handle error messages
-
class
cloudmesh.common.error.
Error
[source]¶ Bases:
object
A class to print error messages
-
classmethod
debug
(msg, debug=True)[source]¶ prints a debug message.
- Parameters
msg – the message
- Returns
-
classmethod
msg
(error=None, debug=True, trace=True)[source]¶ prints the error message
- Parameters
error – the error message
debug – only prints it if debug is set to true
trace – if true prints the trace
- Returns
-
classmethod
cloudmesh.common.locations module¶
class that specifies where we read the cloudmesh.yaml file from
-
cloudmesh.common.locations.
config_dir_setup
(filename)[source]¶ sets the config file and makes sure the directory exists if it has not yet been created. :param filename: :return:
-
cloudmesh.common.locations.
config_file
(filename)[source]¶ The location of the config file: ~/.cloudmesh/filename. ~ will be expanded :param filename: the filename
cloudmesh.common.logger module¶
simple logging convenience framework
-
cloudmesh.common.logger.
LOGGER
(filename)[source]¶ creates a logger with the given name.
You can use it as follows:
log = cloudmesh.common.LOGGER(__file__) log.error("this is an error") log.info("this is an info") log.warning("this is a warning")
cloudmesh.common.parameter module¶
-
class
cloudmesh.common.parameter.
Parameter
[source]¶ Bases:
object
-
classmethod
expand
("a[0-1]") → ["a0", "a1"][source]¶ - Parameters
parameter –
allow_duplicates –
sort –
- Returns
-
classmethod
cloudmesh.common.prettytable module¶
-
class
cloudmesh.common.prettytable.
PrettyTable
(field_names=None, **kwargs)[source]¶ Bases:
object
-
add_column
(fieldname, column, align='c', valign='t')[source]¶ Add a column to the table.
Arguments:
fieldname - name of the field to contain the new column of data column - column of data, should be a list with as many elements as the table has rows align - desired alignment for this column - “l” for left, “c” for centre and “r” for right valign - desired vertical alignment for new columns - “t” for top, “m” for middle and “b” for bottom
-
add_row
(row)[source]¶ Add a row to the table
Arguments:
row - row of data, should be a list with as many elements as the table has fields
-
property
align
¶
-
property
attributes
¶ A dictionary of HTML attribute name/value pairs to be included in the <table> tag when printing HTML
Arguments:
attributes - dictionary of attributes
-
property
border
¶ Controls printing of border around table
Arguments:
border - print a border around the table (True or False)
-
clear
()[source]¶ Delete all rows and field names from the table, maintaining nothing but styling options
-
del_row
(row_index)[source]¶ Delete a row to the table
Arguments:
row_index - The index of the row you want to delete. Indexing starts at 0.
-
property
end
¶ End index of the range of rows to print
Arguments:
end - index of last data row to include in output PLUS ONE (list slice style)
-
property
field_names
¶
-
property
fields
¶ List or tuple of field names to include in displays
Arguments:
fields - list or tuple of field names to include in displays
-
property
float_format
¶ Controls formatting of floating point data Arguments:
float_format - floating point format string
-
property
format
¶ Controls whether or not HTML tables are formatted to match styling options
Arguments:
format - True or False
-
get_html_string
(**kwargs)[source]¶ Return string representation of HTML formatted version of table in current state.
Arguments:
start - index of first data row to include in output end - index of last data row to include in output PLUS ONE (list slice style) fields - names of fields (columns) to include header - print a header showing field names (True or False) border - print a border around the table (True or False) hrules - controls printing of horizontal rules after rows. Allowed values: ALL, FRAME, HEADER, NONE vrules - controls printing of vertical rules between columns. Allowed values: FRAME, ALL, NONE int_format - controls formatting of integer data float_format - controls formatting of floating point data padding_width - number of spaces on either side of column data (only used if left and right paddings are None) left_padding_width - number of spaces on left hand side of column data right_padding_width - number of spaces on right hand side of column data sortby - name of field to sort rows by sort_key - sorting key function, applied to data points before sorting attributes - dictionary of name/value pairs to include as HTML attributes in the <table> tag
-
get_string
(**kwargs)[source]¶ Return string representation of table in current state.
Arguments:
start - index of first data row to include in output end - index of last data row to include in output PLUS ONE (list slice style) fields - names of fields (columns) to include header - print a header showing field names (True or False) border - print a border around the table (True or False) hrules - controls printing of horizontal rules after rows. Allowed values: ALL, FRAME, HEADER, NONE vrules - controls printing of vertical rules between columns. Allowed values: FRAME, ALL, NONE int_format - controls formatting of integer data float_format - controls formatting of floating point data padding_width - number of spaces on either side of column data (only used if left and right paddings are None) left_padding_width - number of spaces on left hand side of column data right_padding_width - number of spaces on right hand side of column data vertical_char - single character string used to draw vertical lines horizontal_char - single character string used to draw horizontal lines junction_char - single character string used to draw line junctions sortby - name of field to sort rows by sort_key - sorting key function, applied to data points before sorting reversesort - True or False to sort in descending or ascending order
-
property
header
¶ Controls printing of table header with field names
Arguments:
header - print a header showing field names (True or False)
-
property
header_style
¶ Controls stylisation applied to field names in header
Arguments:
header_style - stylisation to apply to field names in header (“cap”, “title”, “upper”, “lower” or None)
-
property
horizontal_char
¶ The charcter used when printing table borders to draw horizontal lines
Arguments:
horizontal_char - single character string used to draw horizontal lines
-
property
hrules
¶ Controls printing of horizontal rules after rows
Arguments:
hrules - horizontal rules style. Allowed values: FRAME, ALL, HEADER, NONE
-
property
int_format
¶ Controls formatting of integer data Arguments:
int_format - integer format string
-
property
junction_char
¶ The charcter used when printing table borders to draw line junctions
Arguments:
junction_char - single character string used to draw line junctions
-
property
left_padding_width
¶ The number of empty spaces between a column’s left edge and its content
Arguments:
left_padding - number of spaces, must be a positive integer
-
property
max_width
¶
-
property
padding_width
¶ The number of empty spaces between a column’s edge and its content
Arguments:
padding_width - number of spaces, must be a positive integer
-
property
reversesort
¶ Controls direction of sorting (ascending vs descending)
Arguments:
reveresort - set to True to sort by descending order, or False to sort by ascending order
-
property
right_padding_width
¶ The number of empty spaces between a column’s right edge and its content
Arguments:
right_padding - number of spaces, must be a positive integer
-
property
sort_key
¶ Sorting key function, applied to data points before sorting
Arguments:
sort_key - a function which takes one argument and returns something to be sorted
-
property
sortby
¶ Name of field by which to sort rows
Arguments:
sortby - field name to sort by
-
property
start
¶ Start index of the range of rows to print
Arguments:
start - index of first data row to include in output
-
property
valign
¶
-
property
vertical_char
¶ The charcter used when printing table borders to draw vertical lines
Arguments:
vertical_char - single character string used to draw vertical lines
-
property
vrules
¶ Controls printing of vertical rules between columns
Arguments:
vrules - vertical rules style. Allowed values: FRAME, ALL, NONE
-
-
class
cloudmesh.common.prettytable.
TableHandler
(**kwargs)[source]¶ Bases:
html.parser.HTMLParser
-
cloudmesh.common.prettytable.
from_html
(html_code, **kwargs)[source]¶ Generates a list of PrettyTables from a string of HTML code. Each <table> in the HTML becomes one PrettyTable object.
cloudmesh.common.todo module¶
A class to call a TODO message. Typically it will just raise na exception. However when using the TODO it allows to list the TODO in editors such as pycharm to easier find them.
cloudmesh.common.util module¶
-
cloudmesh.common.util.
HEADING
(txt=None, c='#', color='HEADER')[source]¶ Prints a message to stdout with #### surrounding it. This is useful for pytests to better distinguish them.
- Parameters
c – uses the given char to wrap the header
txt (string) – a text message to be printed
-
cloudmesh.common.util.
auto_create_requirements
(requirements)[source]¶ creates a requirement.txt file form the requirements in the list. If the file exists, it get changed only if the requirements in the list are different from the existing file
- Parameters
requirements – the requirements in a list
-
cloudmesh.common.util.
auto_create_version
(class_name, version, filename='__init__.py')[source]¶ creates a version number in the __init__.py file. it can be accessed with __version__ :param class_name: :param version: :param filename: :return:
-
cloudmesh.common.util.
backup_name
(filename)[source]¶ - Parameters
filename (string) – given a filename creates a backup name of the form filename.bak.1. If the filename already exists the number will be increased as much as needed so the file does not exist in the given location. The filename can consists a path and is expanded with ~ and environment variables.
- Return type
string
prints a banner of the form with a frame of # around the txt:
# -------------------------- # txt # --------------------------
- Parameters
color – prints in the given color
label – adds a label
debug – prints only if debug is true
txt (string) – a text message to be printed
c (character) – the character used instead of c
-
cloudmesh.common.util.
convert_from_unicode
(data)[source]¶ converts unicode data to a string :param data: the data to convert :return:
-
cloudmesh.common.util.
copy_files
(files_glob, source_dir, dest_dir)[source]¶ copies the files to the destination
- Parameters
files_glob – *.yaml
source_dir – source directory
dest_dir – destination directory
-
cloudmesh.common.util.
exponential_backoff
(fn, sleeptime_s_max=1800)[source]¶ Calls fn until it returns True, with an exponentially increasing wait time between calls
-
cloudmesh.common.util.
generate_password
(length=8, lower=True, upper=True, number=True)[source]¶ generates a simple password. We should not really use this in production. :param length: the length of the password :param lower: True of lower case characters are allowed :param upper: True if upper case characters are allowed :param number: True if numbers are allowed :return:
-
cloudmesh.common.util.
grep
(pattern, filename)[source]¶ Very simple grep that returns the first matching line in a file. String matching only, does not do REs as currently implemented.
-
cloudmesh.common.util.
path_expand
(text)[source]¶ returns a string with expanded variable.
- Parameters
text – the path to be expanded, which can include ~ and environment variables
text – string
-
cloudmesh.common.util.
readfile
(filename, mode='r')[source]¶ returns the content of a file :param filename: the filename :return:
-
cloudmesh.common.util.
search
(lines, pattern)[source]¶ return all lines that match the pattern #TODO: we need an example
- Parameters
lines –
pattern –
- Returns
prints a banner of the form with a frame of # around the txt:
# -------------------------- # txt # --------------------------
- Parameters
color – prints in the given color
label – adds a label
debug – prints only if debug is true
txt (string) – a text message to be printed
c (character) – the character used instead of c
-
cloudmesh.common.util.
tempdir
(*args, **kwargs)[source]¶ A contextmanager to work in an auto-removed temporary directory
Arguments are passed through to tempfile.mkdtemp
example:
>>> with tempdir() as path: ... pass
-
cloudmesh.common.util.
writefd
(filename, content, mode='w', flags=514, mask=384)[source]¶ writes the content into the file and control permissions :param filename: the full or relative path to the filename :param content: the content being written :param mode: the write mode (‘w’) or write bytes mode (‘wb’) :param flags: the os flags that determine the permissions for the file :param mask: the mask that the permissions will be applied to
cloudmesh.common.variables module¶
Module contents¶
common namespace.


Tutorial: Creating a simple application
In this tutorial, you will use the CDT to create a simple 'Hello World' application. This tutorial describes the process of creating a new C++ project where the build is automatically managed by the CDT, and running the program.
NOTE: In earlier versions of the CDT, there were two separate project types: Managed make (automatically generated a makefile) and Standard make (required the user's makefile to build). Now with CDT, you just select a project type, and that determines what build system to use.
To create a simple "Hello World" application using CDT, perform the following general steps:
Step 1: Creating a project
- Select File > New > Project.
- Select the type of project to create. For this tutorial, expand the C++ folder and select C++ Project and click Next.
-
The C++ Project wizard opens.
By default, the CDT filters the Toolchain and Project types that it displays in those lists based on the language support for the C++ Project wizard you selected for this tutorial.
- In the Project name field, type a name for the project, such as HelloWorld.
- From the Project type list, expand Executable and select Hello World C++ Project. This project type provides a simple Hello World application in C++, and the makefile is automatically created by the CDT.
- Select a required toolchain from the Toolchain list.
A toolchain is a set of tools (such as a compiler, linker, and assembler) intended to build your project. Additional tools, such as a debugger, can be associated with a toolchain. There can be several toolchains available, depending on the compilers installed on your system.
- Click Next.
- In the Project name field, type a name for the project, such as HelloWorld.
- Specify the Basic Properties for the new project, such as your author, copyright, and source information, then click Next.
-
The Select Configurations page displays a list of configurations based on the project type and toolchain(s) selected earlier.
OPTIONAL: If you want to change the default project settings, click Advanced Setting to open the Project Properties dialog for your new project allowing you change any of the project specific settings, such as includes paths, compiler options, and libraries.
Click Finish.
NOTE If the C++ perspective is not currently set as the default, you are prompted to determine if you would like to this project to be associated with the C/C++ perspective. Click Yes.
A project is created with the default settings and a full set of configurations based on the project type and toolchain you selected. You should now see the new project in Project Explorer view.
Step 2: Reviewing the code and building the project
- From the Project Explorer view, double-click the .cpp file created for your project, for example, HelloWorld.cpp. You'll find it within the project "src" folder.
This file opens in a default editor. It contains C++ template code for the Hello World example project you selected earlier. In addition, the Outline view has also been populated with objects created from your code.
NOTE: You can specify a different editor, and add or modify existing code templates in Window > Preferences.
OPTIONAL: You can type additional code in this file, and then save the changes by clicking File > Save, or pressing CTRL+S.
Next, you will need to build your project before you can run it.
- Build your project by pressing CTRL+B, or select the project in the Project Explorer view and select Project > Build Project.
NOTE: If a build generates any errors or warnings, you can see those in the Problems view. If you encounter difficulty, see the topics Building C/C++ projects and Before you begin
. - Read through the build messages in the Console view.
The project should build successfully.
You will also see the Outline view has also been populated with objects created from your code. If you select an item from the Outline view, the corresponding text in the editor is highlighted.
Step 3: Running the application
To run your application:
- Within the C/C++ Perspective, click Run > Run Configurations....
- Select C/C++ Application.
- Click New.
A new Run Configuration is created. Its name and path to the executable are provided by the project ('Hello World' in our case).
- Click Run.
Now, you should see the Hello World application running in the Console view. The Console also shows which application is running in a title bar.
- You can click the other views to see the information that they contain.


Computational Learning vs Computational Reality
introduction
DataViz #1
DataViz #2
Methodology
1
What are the most common words on the
K12 Standard
vs
the most common topics on Github
?


Update February 2019: This tutorial was updated to Unity 2018.3 by Ben MacKinnon. Original post by Kirill Muzykov.
[caption id="attachment_120645" align="alignright" width="256"] You will love getting gooey with Unity's new GUI![/caption]
Do you remember the old Unity UI system? It required you to write all your GUI code in OnGUI
. It was slow, inefficient and programmer-centric, going against the visual nature of Unity. Many developers chose instead to use third party tools such as NGUI.
Thankfully, Unity Technologies listened to community feedback and worked out a new system, released in Unity 4.6.
In this three-part series, you’ll explore Unity's new UI system by adding an interactive UI to a game called Rocket Mouse.
To satisfy users’ cravings for an engaging UI, you’ll also learn to:
- Animate buttons
- Create a settings dialog that slides into a scene
- Use more GUI controls like Text, Slider, Panel and Mask
Getting Started
This tutorial is aimed at those familiar with the Unity Editor. Go check out our Introduction to Unity series if this is your first rodeo. The great news is that as this tutorial focuses on the UI system, it is 95% script free!
Note: Keep in mind that this tutorial does not cover the creation of the game itself. The goal here is to provide an introduction to Unity's UI system and familiarize you with its components.
You’ll need some images for backgrounds, buttons and other UI elements, as well as a few fonts for the labels and buttons. Don’t worry, you won’t have to draw anything yourself or scour the web for the right assets. I’ve prepared a special package that has everything you need. You're welcome. :]
To get the package, and the starter project files, click on the Download Materials button at the top or bottom of this tutorial.
This is all you need!
Creating MenuScene
Open the Introduction to Unity UI Part 1 Starter project in Unity.
The RocketMouse game is already set up, and all the assets for it are in its own folder. You'll be working out of the RW folder, which contains a Scenes folder. Now, you’ll create a new scene to work with. From the menu bar, Select File ‣ New Scene to create a new empty scene.
It’s best to save the scene right away. Open the Save Scenes dialog by choosing File ‣ Save Scenes. Then, enter MenuScene as the scene name and save it to the RW / Scenes folder, right next to the RocketMouse scene.
Importing Images and Fonts
First on your to do list is to add assets to the scene, so unpack the UI Assets package in your file explorer. There you'll find two folders: Menu and Fonts.
Note: The
Menu folder contains background images, buttons, icons and other game art. The game art is provided by
Game Art Guppy, where you can find a lot of other game art for your practice games. In addition, two fonts from
DaFont. are in the
Fonts folder. You can thank Rodrigo Fuenzalida for the
Titan One font and Draghia Cornel for the
DCC Dreamer font.
It's nice to keep a tidy folder structure, so in the Project window, create a new folder inside RW named UI.
From your file explorer, drag the Menu and Fonts folders into the UI folder in the Project window:
Once the assets are in the project, check their import settings. Make sure all the assets in UI / Menu are set to the Sprite (2D and UI) texture setting.
Woo-hoo! You've finished the setup and you’re ready to create your first UI element using the Unity UI system.
Adding Your First UI Element
The first element you'll make is the background image for the menu scene.
From the top bar, select GameObject ‣ UI ‣ Image. This adds an object named Image to the scene. You should see it in the Hierarchy as a child of Canvas. All elements must be placed on a Canvas. If you don’t have one, Unity will create one for you automatically.
Select the Image and set its position to (X:0, Y:0). You've just discovered the Rect Transform:
Note: The Rect Transform is the UI equivalent to Transform. It positions, rotates and scales UI elements within a Canvas. You’ll use it often in this tutorial.
You’ll set the correct position and size in a moment. Right now, there are three things to be aware of. In the Hierarchy, you’ll see three new objects in the scene:
- Image
- Canvas
- EventSystem
The Image is a non-interactive control that displays a sprite, with many options for customization.
For instance, you can apply color to the image, assign a material to it, control how much of the image displays or even animate it on the screen using a clockwise wipe.
The Canvas is the root object for all your UI elements. Remember, Unity creates this for you when you add your first UI element. It has multiple properties that allow you to control how your UI renders.
The EventSystem processes and routes input events to objects within a scene. It's also responsible for managing raycasting. As with the Canvas, The UI requires the Event System, so Unity automatically adds it.
Setting Up the Menu Background Image
The first thing to do is rename your image. In the Hierarchy, select Image and rename it to Background.
Next, open RW ‣ UI ‣ Menu in the Project window and find the menu_background image. Drag it to the Source Image field of the Image component in Background in the Inspector:
Now you have a background image instead of the default white image. However, it’s not great! It’s too small and the aspect ratio is incorrect.
To fix this, find the Set Native Size button in the Inspector and click it to set the size to 1136 x 640.
Now it looks like a proper background.
Uh-oh. There’s still one problem.
Shrink your Scene view, and you’ll see that the white rectangle of the Canvas covers only part of the image. If you switch to the Game view, you’ll see only a part of the background image, as if the camera is too close to the image to capture it completely.
Note: The original game design was for iPhones with 3.5- and 4-inch displays. This is why all the game art supports 1136 x 640 and 960 x 640 resolutions. You’ll soon see how the UI can adapt to different game resolutions.
You'll tackle this issue by using a Canvas Scaler.
Using the Canvas Scaler
You’ll use the Canvas Scaler to adjust the background image display.
First, you need to know that the display is not the result of a bug. From Unity’s point of view, you have the Game view — or viewport — set to such a small size that it displays only the portion of the image that fits within the Game view.
If you were to run the game on a device with a large enough resolution or stretch the Game view to fit the whole image, you would see the entire background image.
Although Unity’s settings make sense in most scenarios, there are times when you need different behavior. An example is when you have a small monitor that doesn’t fit your target device’s resolution.
Additionally, many games support only one resolution. Designers use this reference resolution to dictate sizes, positions and other data. When you develop a game based on a single reference resolution, make sure to enter the designer’s specifications without additional calculations so that the user sees everything as intended.
If you’ve ever ignored your designer’s directions, you know there’s a price to pay. The user experience and varying resolutions are important, but try to keep your designer happy, too. :]
Canvas Scaler to the rescue! By default, every Canvas includes Canvas Scaler.
Select Canvas in the Hierarchy, and in the Inspector, you should see the Canvas Scaler component:
The Canvas Scaler has three scale modes:
- Constant Pixel Size: Makes UI elements retain the same pixel size, regardless of the screen size. This is the default value of the Canvas.
- Scale With Screen Size: Sizes and positions UI elements according to a referenced resolution. If the current resolution is larger than the referenced resolution, the Canvas will maintain the reference resolution, while scaling up the elements to match the target resolution.
- Constant Physical Size: Positions of the UI elements are specified in physical units such as millimeters or points. This requires the correct reporting of the screen DPI.
Change the component mode to Scale With Screen Size and set its Reference Resolution to (X:1136, Y:640). Also, slide the Match Width or Height all the way to the right, or simply enter 1 in the input field.
After making those changes, you'll see the full background image, even in a small Game view window.
Change the Game view resolution to see how your game might look in a different resolution, for example, on iPhone Wide 480x320. You'll notice it still looks good!
Note: If you don't see any of the iPhone options, chances are you’re building for a different platform. From the menu bar, select
File ‣ Build Settings. In the build settings dialog underneath the platform settings, make sure to select
iOS.
Unity will reprocess all your assets, and it may take a while. At the end, you should have access to the various iOS screen sizes.
Now switch to the Scene view, and you’ll see the Canvas’s size doesn’t change when you resize the Scene view. The side edges of the screen are neatly cropped while the central part is fully visible. This is the result of setting Match Width or Height to 1. It works perfectly for your target resolutions.
These designs are old! Modern phone screens are much wider in Landscape mode. Switch to iPhoneX Landscape mode and we have a whole new problem.
If you change the Match Width or Height value back to zero, it works for iPhone 5 and iPhoneX, but appears letterboxed on iPhone 4.
Fortunately, there are other solutions for this. While the Canvas Scaler has two other scaling modes, Expand and Shrink, there's another useful component that we can use specifically for background images.
Put the Canvas Scaler back to Match Width or Height with the value 1, and set the Game view to iPhoneX. It should like the image above again.
Now, select the Background and add an Aspect Ratio Fitter component. It will automatically set the Aspect Ratio value to the current ratio of the image's Rect Transform. Switch the Aspect Mode to Envelope Parent. The image will automatically resize to once again fill the whole screen.
Phew, that was a lot of work. And we've only added the background image! But getting the Canvas Scaler and background set up in the proper way is going to make everything easier going forward. After doing this a couple of times ,you'll find the setup so fast and easy that you'll barely have time to blink before you're done.
What about the buttons? What happens when they’re too close to the left or right edge of the screen? You don’t want to crop or hide them.
Fortunately, Unity has a feature that will help you sidestep this rookie mistake. You’ll learn about it soon.
Adding a Header Image
Before moving on to buttons and other UI controls, you’ll add the header image. For this exercise, you’ll use a non-fullscreen image to demonstrate a few other important concepts of Unity's new UI system.
Open the Scene view, and from the top bar, select GameObject ‣ UI ‣ Image. This will add another image as a child of Canvas:
Note: If you can't see the image in the Scene view, set its Pos X and Pos Y properties to 0 to center it.
Now, turn that white rectangle into an actual image by following these steps:
- Select Image in the Hierarchy and rename it to Header.
- Open the Menu folder in the Project window and search for the header_label image.
- Drag the image to the Source Image field on the Inspector.
- Click Set Native Size in the Inspector.
Now, you’ll work with the Rect Transform component to position the image.
Rect Transform, Anchors, Pivot and You
If you’ve worked with Unity before or completed other Unity tutorials on this website, you may have had some exposure to the Transform component. If not, that’s fine. Transform is a tool that can position, rotate and scale objects in a scene. Here’s what it looks like:
You’ll see the Transform component when you select any type of non-UI GameObject in your Hierarchy view. However, if you select any UI element, for example, Header, you’ll see a different component named Rect Transform.
As you can see, Transform and Rect Transform look different. Additionally, the Rect Transform can change the way it looks, depending on its anchor settings. For example, it can look like this:
Here, instead of Pos X, Pos Y, Width and Height, you have Left, Top, Right and Bottom.
Are you wondering about the anchor setting that changes the look of Rect Transform so dramatically? Keep reading!
Anchors
Setting anchors is a simple, elegant and powerful way to control the position and size of your UI elements relative to their parent. It’s especially handy when you have to resize the parents.
When you set anchors, you specify several positions in the parent, usually one in each corner of the parent's UI element Rect. When this happens, your UI element will try to maintain a uniform distance to the anchor points, forcing it to move or resize along with its parent.
To see different Anchors Presets, select Header in the Hierarchy and click on the rectangle above the Anchors field in the Rect Transform component.
After clicking, you’ll see various Anchors Presets. These are the most common settings for anchors, but you can customize them. You can also select different horizontal and vertical behavior for your UI element.
This will all make more sense once you work with it. If you look at the next image, which has the background image disabled, you’ll be able to see the Canvas size changes a bit better.
As you can see, the anchors settings control how your UI element adapts to screen size changes.
The four triangular handles representing anchors resemble a flower. Here’s how it looks with anchors set to the top-center preset:
Before you start experimenting with different settings, read through the next section. It’ll help you understand anchors a little better, and you’ll get more out of your experimentation.
Custom Anchors
You can manually move anchors to a custom position. The presets are just for your convenience.
Note: You might find yourself in a situation where the translation gizmo covers the anchor icon, making it impossible to select the anchor.
This is where another Unity UI tool comes in handy. If you are familiar with Unity, you’ll know that the keyboard shortcuts Q, W, E and R toggle the Hand, Move, Rotate and Scale tools respectively. With the new UI system, the RectTool was added under the shortcut T. With the RectTool selected, the Gizmo changes to a 2D scale/move box that acts as you would expect from any graphics editing software.
Now you can grab the anchors and move them around.
See how the image moves to the right when you resize the Canvas? It moves only a little in relation to the right edge of the Canvas because these anchors are set to 25% width of the Canvas.
Splitting Anchors
You can split anchors to make them stretch a UI Element horizontally, vertically or both.
Note: You're not actually resizing the Canvas when dragging one if its edges. In fact, you can't resize the Canvas this way.
Look for the word Preview next to the cursor when you try to resize it. Use this technique to experiment and see how your UI elements adapt to different screen sizes.
Rect Transform Depends on the Current Anchors Setting
Depending on the anchors setting, the Rect Transform provides different ways to control the size and position of your UI element.
If you set anchors to a single point without stretching, you’ll see the Pos X, Pos Y, Width and Height properties.
However, if you set anchors in a way that stretches your UI element, you’ll get Left and Right instead of Pos X and Width if you set it to stretch horizontally. You’ll get Top and Bottom instead of Pos Y and Height if you set it to stretch vertically.
In this screenshot, Header’s Anchors are set to middle-stretch. This means the image stays in the middle of the Canvas vertically and stretches horizontally.
Pivot
The final property to discuss in the Rect Transform component is Pivot.
The pivot is the point around which all transformations are made. In other words, if you change your UI element position, you also change the pivot point position. If you rotate your UI element, it’ll rotate around that point.
The pivot uses normalized coordinates. This means that it goes from 0 to 1 for both height and width, where (0, 0) is the bottom left corner and (1, 1) is the top right corner.
Note: You can also set Pivot outside the UI Element bounds. In this case, Pivot will be outside the (0, 0) – (1, 1) range. This can be useful. For example, you might want to rotate your object around some point in the scene. To alter the pivot, you must make sure the Pivot/Center button is toggled to Pivot like so:
You can change pivot in the Rect Transform component in the Inspector, or you can use the Rect Tool.
The following two images demonstrate a UI element with the same Pos X and Pos Y values, yet each shows different placement in the scene.
The first image shows the pivot at its default value of (0.5, 0.5), which is the center of the UI element. The position is set to (0, 0) and the anchors are set to top-left.
Note: It’s important to understand that the position of a UI element is set relative to the anchors. A (0, 0) position means the distance from anchors, which are set to the top-left corner of the Canvas.
Now, take a look at the second image. As you can see, the position is still at (0, 0), but since the pivot is set to the bottom-left corner (0, 0) you can see that the image’s bottom corner, and not the center, is now at the Canvas’s top-left.
It's harder to show how pivot affects rotation and size using a still image, so here are a few animations:
Notice how the image rotates around the pivot point, indicated by a blue circle, which is an element you can freely move.
Note: Hold down the Option / ALT key while scaling to scale around the pivot point.
As you can see, the pivot also affects how your UI Element resizes.
Note: When you change the size of a UI element, you don’t change its scale. Instead, you change its size using Width and Height or Top, Right, Left, and Bottom paddings.
Be aware that there are a few differences between size and scale. For example, size can’t be negative, but scale can be. Also, using a negative scale value will flip your UI element. In most cases, you should only change the size of your UI elements.
Placing a Header Image
Phew! That was a lot of information about Rect Transform, Anchors and Pivot. Believe me, you’ll be grateful you spent the time working through the exercise, as these concepts are essential to creating awesome UI in your games.
Going forward, you’ll concentrate on creating the menu scene. The rest of this tutorial will go by in the blink of an eye!
All those manipulations exhausted the poor little header. It’s time to place it where it should be and leave it alone to recover.
Before you continue, re-enable Background if you disabled it to see the Canvas border.
Select Header in the Hierarchy and set its properties in the Inspector as follows:
- Click Set Native Size to reset the size, as you probably messed with it while playing around with the pivot.
- Set Anchors to top-center.
- Set Pos X to 0 and Pos Y to -100.
You should see something like this in your Scene view:
That's it! Now, leave the header image alone. It's a little tired, too. :]
Now that you know about anchors and pivots, go back to the background image. Did you notice that when you added the aspect ratio fitter, some of the floor texture is now cropped off screen? We can use the Aspect Ratio Fitter in combination with the pivot to fix this:
- Disable the Aspect Ratio Fitter
- Set the Pivot to (X:0.5, Y:0)
- Re-enable the Aspect Ratio Fitter
Now, not only does the background always fit the size of the phone, the floor part will always stay in view!
Adding the Start Button
Now, that your game has a nice background with a label, it's time to add some buttons.
From the top bar, choose GameObject ‣ UI ‣ Button. This will add a Button object to the scene. You should see it in the Hierarchy. If you expand it in the Hierarchy, you’ll see that the button contains a Text child — you’ll learn about these later.
Look at the button in the Inspector, and you’ll see it has the same Image component you used to add the background and the header label.
Additionally, there's a Button component. In other words, a button is just an image with a child Text element and an attached button script.
Note: The Text element is optional, so if you have a button image with text drawn right into the image, you can delete it.
Positioning the Button
Now it’s all about positioning and resizing the button. Follow these steps:
- Select Button in the Hierarchy view and rename it to StartButton.
- Set its Anchors to bottom-stretch, since you want it to stretch horizontally if the screen size changes. Tip: Hold Alt/Cmd and Shift when selecting the anchor to also set the position and pivot.
- To further customize the anchors, set the X to (Min:0.2, Max:0.8)
- Set both Left and Right to 123.
- Set the Pivot to (X:0.5, Y:0)
- Set Height to 80.
- Set Pos Y to 300.
Then select the nested Text element and set its Text to Start Game. Change the Font Size to 32 to make the text of the button larger.
This is what you should see in the Scene view:
Now you have a button, but it needs a facelift! To make the button look good, you’ll set an image as its background and then use a fancier font.
9-Slice Scaling
You set the image for buttons and images in the same way. After all, they use the same component. However, images rarely scale, especially non-uniformly. Buttons, on the other hand, often come in different sizes.
You could create a background image for every single button size in your game, but why waste all that space? You’ll use a technique called 9-Slice scaling, which allows you to provide one small image that scales to fit all sizes.
There’s no magic involved here. This technique works by creating different images for each of nine zones, all of which scale differently.
This ensures the image will look good at any scale.
Preparing Button Images
Before you can use a sliced image, you need to set its nine zones. To do this, open the Menu folder in the Project window and select btn_9slice_normal image.
In the Inspector’s Import Settings, set Texture Type to Sprite (2D and UI) and apply the change. Next, click on the Sprite Editor button to open the Sprite Editor view.
In the Sprite Editor, set the Border values to L:14, R:14, B:16, T:16. Remember to click Apply!
Repeat the same process for the btn_9slice_highlighted and btn_9slice_pressed images, which you'll use for different button states.
Setting Button Images
After preparing all your images, drag them to the corresponding fields in the Inspector. Select StartButton in the Hierarchy and follow these steps:
- Change Image Type to Sliced in the Image component.
- Change the Transition property in the Button component to SpriteSwap.
- Drag btn_9slice_normal to Source Image in the Image component.
- Drag btn_9slice_highlighted to Highlighted Sprite in the Button component.
- Drag btn_9slice_pressed to Pressed Sprite in the Button component.
Note: If you encounter this error message, you probably forgot to set the Border in the Sprite Editor in the Import Settings.
Before running the scene and enjoying your cool buttons, you’re going to change the font used by the nested Text label. This will make the button mega-awesome.
Setting a Custom Font for the Button
Using a custom font is easy. Remember the Fonts folder in the package you downloaded and added to the project? Now it's time to break it out and use one of those fonts.
Select the Text element nested within StartButton in the Hierarchy. Then open the Fonts folder in the Project window and drag the TitanOne-Regular font into the Font field. Also set the Color to white.
Now run the scene and enjoy your new mega-awesome button! :]
Adding the Settings Button
There are a few things left to do. First, add the Settings button.
You can probably do this yourself, so you’re only getting the size and position of the button to start. The rest is almost identical to they way you created the Start Game button.
Note: The easiest way is to duplicate the button and adjust some properties, but try creating the button from scratch this time.
These properties of the Settings button are different:
- Name: SettingsButton
- Rect Transform: Left and Right are 400, Height is 70 and Pos Y is 180
- Text: Settings
- Fontsize: 24
[spoiler title="Solution Inside: Need help creating the Settings button?"]
If you couldn't quite do it, just follow these steps:
- From the top bar, select GameObject ► UI ► Button. This will create a Button object in the scene.
- Select Button in the Hierarchy view and rename it to SettingsButton.
- Set the button Anchors to bottom-stretch. Then update the X to (Min:0.2, Max:0.8)
- Set the Pivot to (X:0.5, Y:0)
- Set both Left and Right in Rect Transform to 173.
- Set Height to 70 and Pos Y to 180.
- Set Transition in the Button component to Sprite Swap.
- Make sure to set Image Type in the Image component to Sliced.
- Open the Menu folder in the Project Browser and drag btn_9slice_normal to Source Image.
- Then drag btn_9slice_highlighted to Highlighted Sprite.
- And finally, drag btn_9slice_pressed to Pressed Sprite.
- Double-click on Color inside the Image component and check if A is set to 255 to remove any transparency.
- Select the nested Text label.
- Change Text to Settings.
- Set Font Size to 24.
- Change Color to White.
- Open the Fonts folder in the Project window and drag the TitanOne-Regular font into the Font field in the Inspector view.
[/spoiler]
This is what you should see in the Scene view after adding the Settings button:
Now Save your scene.
Starting the Game
The final task for this part is to click the Start Game button and run the second scene in the game itself.
Adding Scenes to Build
Before you can run different scenes, you need to add them to the Scenes in Build list in the Project Settings.
To do this, on the menu select File ‣ Build Settings. This will open the Build Settings dialog. Then open the Scenes folder in the Project browser. First, drag the MenuScene and then the RocketMouse scene to the Scenes in Build list.
Finally, close the Build Settings dialog.
Creating UIManager
Here comes the 5% code part of the tutorial!
When you add an event handler to the button, you need to specify which method to call when you click the button. Since you can’t use static methods, you’ll need to select a public method from a script attached to a GameObject.
From the top bar, choose GameObject ‣ Create Empty. Then select GameObject in the Hierarchy view and rename it to UIManager.
Create a Scripts folder inside RW and then create a new C# script in it named UIManager. Once Unity compiles it, attach it as a component to your UIManager GameObject.
This is what you should see in the Hierarchy view and the Inspector view:
Double-click on the UIManagerScript in the Inspector to open the script in MonoDevelop. Once the script loads, remove both Start()
and Update()
.
Next add the following statement underneath the previous using
statements.
using UnityEngine.SceneManagement;
This allows you to load other scenes. Now, add the following:
public void StartGame()
{
SceneManager.LoadScene("RocketMouse");
}
Save the script and move on to the next step:
Calling StartGame When the Button is Clicked
Switch back to Unity and follow these steps:
- Select StartButton in the Hierarchy and scroll down in the Inspector to the On Click() list.
- Click the + button to add a new item.
- Drag UIManager from the Hierarchy to the newly added item in the list.
- Click on the dropdown to select the function. Right now, it’s set to No Function.
- In the opened menu, select UIManagerScript and the select StartGame () in the menu that opens next.
Save the scene and then click the Play button to run the game. Click the Start Game button in the menu. This should open the game scene.
Where to Go From Here?
Stuck on any issues? Feel free to download the completed project for this part using the Download Materials button at the top or bottom of this tutorial.
It might feel like you didn’t do much in this last section, but take another look: You set up the UI, added images and buttons, and even wrote the code that starts the game when you click on the button!
In many games, that’s all that comprises the UI.
You also learned a lot about Rect Transform, Anchors and Pivot. Now that you understand them, you’ll be able to move much faster when you apply these skills to your own projects.
In part two of this series, you’ll learn how to animate UI elements, create dialogs, and use controls like Slider and Toggle. By the end of the series, you’ll have a working menu scene.
If you have any questions or comments please leave them below! See you in Part 2!


{% load i18n l10n marcus_tags %} {% for article in articles %} {% with article|translate:language as article %}


JIL allows for audio to be played using the Device.Multimedia.AudioPlayer object.
Let's specify the location of our audio file. If you're writing the code, you'll need to open the file first and then you can use the play, pause, resume, and stop controls.


Quantum neural networks
(This post requires a background in the basics of quantum computing (and neural networks). Please have a read of the first part of Introduction to quantum computing and the surface code if you’d like to get up to speed on the quantum parts, Neural networks and Deep Learning is a good introduction to the other part.)
Recently, I’ve been spending a lot of time thinking about machine learning, and in particular deep learning. But before that, I was mostly concerning myself with quantum computing, and specifically the algorithmic/theory side of quantum computing.
In the last few days there’s been a flurry of papers on quantum machine learning/quantum neural networks, and related topics. Infact, there’s been a fair bit of research in the last few years (see the Appendix at the end for a few links), and I thought I’d take this opportunity to have a look at what people are up to.
The papers we’ll be discussing are:
- arXiv:1612.01045 - Quantum generalisation of feedforward neural networks by Wan, Dahlsten, Kristjánsson, Gardner and Kim.
- arXiv:1612.01789 - Quantum gradient descent and Newton’s method for constrained polynomial optimization by Rebentrost, Schuld, Petruccione and Lloyd,
- arXiv:1612.02806 - Quantum autoencoders for efficient compression of quantum data by Romero, Olson and Aspuru-Guzik,
But first, let’s take a look at the paper that got me interested in machine learning in the first place!
arXiv:1307.0411 - Quantum algorithms for supervised and unsupervised machine learning
The paper, Quantum algorithms for supervised and unsupervised machine learning by Lloyd, Mohseni and Rebentrost in 2013, was one of my first technical exposures to machine learning. It’s an interesting one because it demonstrates that for certain types of clustering algorithms there is a quantum algorithm that exhibits an exponential speed-up over the classical counterpart.
Aside: Gaining complexity-theoretic speed-ups is the central task of (quantum) complexity theory. The speedup in this paper is interested, but it “only” demonstrates a speed-up on a problem that is already known to be efficient1 for classical computers, so it doesn’t provide evidence that quantum computers are fundamentally more powerful than classical ones, by the standard notions in computer science.
The Supervised clustering
problem that is tackled in the paper is as
follows:
Given some vector u⃗ ∈ ℝN, and two sets of vectors V and W, then given M representative samples from V: v⃗j ∈ V and w⃗k ∈ W, figure out which set u⃗ should go in to, by comparing the distances to these vectors.
In pictures it looks like so:
Classically, if we think about where we’d like to put u⃗, we could compare the distance to all the points $\vec{v_1}, \vec{v_2}, \vec{v_3}$ and to all the points $\vec{w_1}, \vec{w_2},\vec{w_3}$. In the specific example I’ve drawn, doing so will show that, out of the two sets, u⃗ belongs in V.
In general, we can see that, using this approach, we would need to look at all M data points, and we’d need to compare each dimension of the N dimensions of each vector $\vec{v_j}, \vec{w_k}, \vec{u}$; i.e. we’d need to look at at least M × N pieces of information. In other words, we’d compute the distance
By looking at the problem slightly more formally, we find that classically the
best known algorithm takes “something like”2 pol
y(M×N) steps,
where “poly
” means that the true running time is a polynomial of
M × N.
Quantumly, the paper demonstrates an algorithm that lets us solve this problem in “something like” log (M×N) time steps. This is a significant improvement, in a practical sense. To get an idea, if we took 100 samples from a N = 350-dimensional space, then M × N = 35, 000 and log (M×N) ≈ 10.
The quantum algorithm works by constructing a state in a certain state so that, when measured, the distance that we wanted, d(u⃗,V), is the probability that we achieve a certain measurement outcome. In this way, we can build this certain state, and measure it, several times, and use this information to approximate the required distances. And, the paper shows that this whole process can be done in “something like” a running time of log (M×N).
There’s more contirbutions in the paper than just this; so it’s worth a look if you’re interested.
arXiv:16.12.01045 - Quantum generalisation of feedforward neural networks
So this paper is pretty cool. We can get a feel for what it’s doing by first considering the following network:
This network has two inputs, x1, x2, three learnable weights, w1, w2, w3, one output value y, and an activation function f.
Classically one would feed in a series of training examples (x1,x2,y) and update the weights according to some loss function to achieve the best result for the given data.
Quantumly, there are some immediate problems with doing this, if we switch the inputs x to be quantum states, instead of classical real variables.
The problems are:
- Quantum operations need to be reversible; f as written is not (at the very least, it takes two inputs and squashes them down to one output).
- Quantum states need to be normalised; so multiplying them by a single arbitrary weight won’t be productive.
- You can’t copy arbitrary quantum states due to the No-Cloning theorem, so this restricts the type of networks that can be written down.
The way this paper solves these problems is to transition Figure 2 from a classical non-reversible network to a reversible quantum one:
The final network takes in an arbitrary quantum state of two qubits, x1, x2, and then adjoins an ancilla state |0⟩, applies some unitary operation U, and emits a combined final state |ψ⟩x1, x2, yOut where the final qubit y contains the result we’re interested in.
At this point, one might reasonably ask: How is this different to a quantum circuit? It appears to me that the only difference is that U is actually unknown, and it is trainable! Note that this is also a somewhat radical difference from classical neural networks: there, we don’t normally think of the activation functions (defined as f above) as trainable parameters; but quantumly, in this paper, that’s exactly how we think of them!
It turns out that unitary matrices can be parameterised by a collection of real variables α. Consider an arbitrary unitary matrix operating on two qubits, then U can be written as:
where σi, i ∈ 1, 2, 3 are the usual Pauli
matrices and σ0 is the
2 × 2 identity matrix. So one can then make these parameters
αj1, j2 the trainable parameters! It turns out that in the paper
they don’t train these parameters explicitly, instead they pick a less general
way of writing down unitary matricies, and they construct, by hand, a unitary
for two qubits. It’s not clear why they’ve done this, and it would not be fun
to have to build a special trainable unitary matrix for each node/neuron of
your architecture depending on its input.
Update: Kwok-Ho kindly corrected me that they do indeed train directly on this form of unitary matricies, and that the simplification they do in the paper is used to investigate the loss surface.
In any case, the main contribution of this paper seems to me to be the idea that we can learn unitary matricies for our particular problem. They go on to demonstrate that this idea works to build a quantum autoencoder, and to make a neural network discover unitary matricies that perform the quantum teleportation protocol.
One view is that trying to learn arbitrary unitary matrices that perform a task really well will become too hard as the number neurons grows. If we had a large network, with potentially millions of internal, neurons (and hence unitaries) to learn, then it might be more effective to fix unitaries and instead focus on learning the weights.
However, it’s a promising technique that would be fun to try out.
arXiv:1612.01789 - Quantum gradient descent and Newton’s method for constrained polynomial optimization
Those of you familiar with neural networks will know that the central idea used to train them is Gradient Descent. We recall that gradient descent lets us known how to modify some vector x so that it does “better” when evaluated with some cost function C(x,y) where y is some known good answer. I.e. x might be a probability of liking some object, and y might be the true probability, and C(x,y) = |x−y|2.
The paper supposes we have some quantum state $|x\rangle = \sum_{j=1}^N x_j |j\rangle$ (where |j⟩ is the j’th computational-basis state), and some cost function C(|x⟩,|y⟩) that tells us how good |x⟩ is. The question is, given we can evaluate C(|x⟩,|y⟩), how can we best work out to modify |x⟩ to do better?
If this was entirely classical, we could just calculate the gradient of C with respect to the variables xj, and then propose a new set of xj’s. However, we can’t inspect all these values quantumly, so we need to do something else.
In the paper, they demonstrate an approach that requires a few copies of the current state |x(t)⟩, but will produce a new state |x(t+1)⟩ such that (with objective/loss function f):
for some step size η. That is, it’s a step in the (hopefully) right direction, as per normal gradient descent!
So one direction to take this paper would be to build a “fully quantum” neural network like so:
where we make the weights quantum states, and the weights are multiplied onto
the inputs as a dot-product. This would require that the weight state is the
same size as the input state; but that should be possible because we’re the
ones building the network structure.
Update: The idea about multiplying weights in didn’t make any sense; a much more sensible idea would be to prepare something like |wi⟩⟨wi| and enact this on the input |xk and then apply the fixed unitary.
We could then not worry about learning unitary matrices, and analogously to standard neural networks, just pick some unitary U that “works well” in practice, maybe by just defining quantum analogues of some common activation functions, perhaps say the ReLU or ELU.
Overall I think that the quantum gradient descent algorithm should be useful for training neural networks, and maybe some cool things will come from it. There are some natural direct extensions of this work; namely to extend the implementation to the more practical variations.
1612.02806 - Quantum autoencoders for efficient compression of quantum data
This paper came out only a few days after the Wan et al paper that we covered above, that also discussed autoencoders, so I thought it was worth a glance to see if this team did things differently.
This paper again takes the approach of not concerning itself with weights and instead focuses on learning a good unitary matrix U with a specific cost function.
They take a different approach in how they build their unitaries. Here they have a “programmable” quantum circuit, where they consider the parameters defining this circuit as the ones that can be trained. Given that these parameters are classical, and loss function they calculate is classical, no special optimisation techniques are needed.
Final thoughts
It appears that the building blocks are being put together to start doing some serious work on quantum machine learning/quantum deep networks. Google and Microsoft are already heavily investing in quantum computers, Google in particular has something it calls the “Quantum A.I. Lab”, and there are even independent quantum computer manufacturing groups.
It seems like there are lots of options on which way to direct efforts in the quantum ML world, and with these recent developments on quantum ML techniques, the time appears to be right to be getting into quantum deep learning!
Appendix
More interesting quantum machine learning papers:
- 1611.09347 - Quantum Machine Learning (most recent review)
- 1610.08251 - Quantum-enhanced machine learning
- 1605.05370 - Training A Quantum Optimizer
- 1603.08675 - Quantum Recommender Systems
- 1512.06069 - Demonstration of quantum advantage in machine learning
- 1512.02900 - Advances in quantum machine learning
- 1611.08104 - Quantum Enhanced Inference in Markov Logic Networks
- 1609.02542 - Quantum-assisted learning of graphical models with arbitrary pairwise connectivity
- 1609.06935 - Quantum Neural Machine Learning - Backpropagation and Dynamics
- 1606.02318 - Solving the Quantum Many-Body Problem with Artificial Neural Networks
- even more: SciRate - quantum machine learning!
Here efficient means that the problem is in the complexity class caled P. Problems that are efficient for quantum computers are in the complexity class BQP. One of the main outstanding questions in the field is “Are quantum computers more powerful than classical ones?” and this can be phrased as comparing the class P and BQP.↩
“Something like” x here is a very informal term for the more formal statement that the running time is O(x). See Big O Notation for more.↩


|
URI: http://www.cxpartners.co.uk/wp-content/themes/cxpartners/style.css |
a |
| 78 |
|
|
Property -webkit-appearance is an unknown vendor extension
|
a |
| 82 |
|
|
Property -webkit-appearance is an unknown vendor extension
|
a |
| 82 |
|
|
Property -moz-box-sizing is an unknown vendor extension
|
a |
| 82 |
|
|
Property -webkit-box-sizing is an unknown vendor extension
|
a |
| 84 |
|
|
::-webkit-search-decoration is an unknown vendor extended pseudo-element
|
a |
| 84 |
|
|
Property -webkit-appearance is an unknown vendor extension
|
a |
| 86 |
|
|
::-moz-focus-inner is an unknown vendor extended pseudo-element
|
a |
| 86 |
|
|
::-moz-focus-inner is an unknown vendor extended pseudo-element
|
a |
| 99 |
|
|
Property -webkit-text-size-adjust is an unknown vendor extension
|
a |
| 99 |
|
|
Property -ms-text-size-adjust is an unknown vendor extension
|
a |
| 99 |
|
|
Property -webkit-tap-highlight-color is an unknown vendor extension
|
a |
| 113 |
|
|
::-moz-selection is an unknown vendor extended pseudo-element
|
a |
| 119 |
|
|
Property -moz-transition is an unknown vendor extension
|
a |
| 119 |
|
|
Property -o-transition is an unknown vendor extension
|
a |
| 119 |
|
|
Property -webkit-transition is an unknown vendor extension
|
a |
| 210 |
|
|
Property -pre-wrap is an unknown vendor extension
|
a |
| 210 |
|
|
Property -o-pre-wrap is an unknown vendor extension
|
a |
| 210 |
|
|
Property -moz-pre-wrap is an unknown vendor extension
|
a |
| 210 |
|
|
Property -hp-pre-wrap is an unknown vendor extension
|
a |
| 243 |
|
|
Property -moz-border-radius is an unknown vendor extension
|
a |
| 243 |
|
|
Property -webkit-border-radius is an unknown vendor extension
|
a |
| 246 |
|
|
Property -moz-box-shadow is an unknown vendor extension
|
a |
| 246 |
|
|
Property -o-box-shadow is an unknown vendor extension
|
a |
| 246 |
|
|
Property -webkit-box-shadow is an unknown vendor extension
|
a |
| 360 |
|
|
Property -moz-box-shadow is an unknown vendor extension
|
a |
| 360 |
|
|
Property -o-box-shadow is an unknown vendor extension
|
a |
| 360 |
|
|
Property -webkit-box-shadow is an unknown vendor extension
|
a |
| 476 |
|
|
Property -moz-border-radius is an unknown vendor extension
|
a |
| 476 |
|
|
Property -webkit-border-radius is an unknown vendor extension
|
a |
| 476 |
|
|
Property -moz-transform is an unknown vendor extension
|
a |
| 476 |
|
|
Property -o-transform is an unknown vendor extension
|
a |
| 476 |
|
|
Property -webkit-transform is an unknown vendor extension
|
a |
| 491 |
|
|
Property -moz-box-shadow is an unknown vendor extension
|
a |
| 491 |
|
|
Property -o-box-shadow is an unknown vendor extension
|
a |
| 491 |
|
|
Property -webkit-box-shadow is an unknown vendor extension
|
a |
| 504 |
|
|
Property -moz-box-shadow is an unknown vendor extension
|
a |
| 504 |
|
|
Property -o-box-shadow is an unknown vendor extension
|
a |
| 504 |
|
|
Property -webkit-box-shadow is an unknown vendor extension
|
a |
| 524 |
|
|
Property -moz-box-shadow is an unknown vendor extension
|
a |
| 524 |
|
|
Property -o-box-shadow is an unknown vendor extension
|
a |
| 524 |
|
|
Property -webkit-box-shadow is an unknown vendor extension
|
a |
| 585 |
|
|
Property -moz-box-shadow is an unknown vendor extension
|
a |
| 585 |
|
|
Property -o-box-shadow is an unknown vendor extension
|
a |
| 585 |
|
|
Property -webkit-box-shadow is an unknown vendor extension
|
a |
| 589 |
|
.gallery .right .wp-caption-text
|
Same color for background-color and border-top-color
|
a |
| 589 |
|
.gallery .right .wp-caption-text
|
Same color for background-color and border-top-color
|
a |
| 589 |
|
.gallery .right .wp-caption-text
|
Same color for background-color and border-top-color
|
a |
| 602 |
|
.secondary .wp-caption-text
|
Same color for background-color and border-top-color
|
a |
| 709 |
|
|
Property -pre-wrap is an unknown vendor extension
|
a |
| 709 |
|
|
Property -o-pre-wrap is an unknown vendor extension
|
a |
| 709 |
|
|
Property -moz-pre-wrap is an unknown vendor extension
|
a |
| 709 |
|
|
Property -hp-pre-wrap is an unknown vendor extension
|
a |
| 721 |
|
|
Property -moz-border-radius is an unknown vendor extension
|
a |
| 721 |
|
|
Property -webkit-border-radius is an unknown vendor extension
|
a |
| 759 |
|
.contact .directions
|
Same color for background-color and border-top-color
|
a |
| 759 |
|
.contact .directions
|
Same color for background-color and border-right-color
|
a |
| 759 |
|
.contact .directions
|
Same color for background-color and border-bottom-color
|
a |
| 759 |
|
.contact .directions
|
Same color for background-color and border-left-color
|
a |
| 813 |
|
|
Property -moz-box-shadow is an unknown vendor extension
|
a |
| 813 |
|
|
Property -o-box-shadow is an unknown vendor extension
|
a |
| 813 |
|
|
Property -webkit-box-shadow is an unknown vendor extension
|
a |
| 817 |
|
|
Property -moz-box-shadow is an unknown vendor extension
|
a |
| 817 |
|
|
Property -o-box-shadow is an unknown vendor extension
|
a |
| 817 |
|
|
Property -webkit-box-shadow is an unknown vendor extension
|
a |
| 858 |
|
|
Property -moz-border-radius-bottomleft is an unknown vendor extension
|
a |
| 858 |
|
|
Property -moz-border-radius-bottomright is an unknown vendor extension
|
a |
| 858 |
|
|
Property -webkit-border-bottom-left-radius is an unknown vendor extension
|
a |
| 858 |
|
|
Property -webkit-border-bottom-right-radius is an unknown vendor extension
|
a |
| 865 |
|
|
Property -moz-box-shadow is an unknown vendor extension
|
a |
| 865 |
|
|
Property -webkit-box-shadow is an unknown vendor extension
|
a |
| 868 |
|
|
Property -webkit-border-radius is an unknown vendor extension
|
a |
| 868 |
|
|
Property -moz-border-radius is an unknown vendor extension
|
a |
| 930 |
|
|
Property -moz-box-shadow is an unknown vendor extension
|
a |
| 930 |
|
|
Property -o-box-shadow is an unknown vendor extension
|
a |
| 930 |
|
|
Property -webkit-box-shadow is an unknown vendor extension
|
a |
| 954 |
|
.primary .wp-caption-text
|
Same color for background-color and border-top-color
|
a |
| 961 |
|
|
Property -moz-border-radius is an unknown vendor extension
|
a |
| 961 |
|
|
Property -webkit-border-radius is an unknown vendor extension
|
a |
| 1238 |
|
|
Property -moz-box-shadow is an unknown vendor extension
|
a |
| 1238 |
|
|
Property -o-box-shadow is an unknown vendor extension
|
a |
| 1238 |
|
|
Property -webkit-box-shadow is an unknown vendor extension
|
a |
| 1346 |
|
|
Property -moz-transform is an unknown vendor extension
|
a |
| 1346 |
|
|
Property -o-transform is an unknown vendor extension
|
a |
| 1346 |
|
|
Property -webkit-transform is an unknown vendor extension
|
a |


-
Stripe: Apple Pay
stripe.com
Stripe is a suite of APIs that powers commerce for businesses of all sizes.
-
Apple - Privacy
www.apple.com
At Apple, we respect your privacy and protect it with strong encryption, plus strict policies that govern how all data is handled.
-
Breaking News, World News & Multimedia
www.nytimes.com
The New York Times: Find breaking news, multimedia, reviews & opinion on Washington, business, sports, movies, travel, books, jobs, education, real ...
-
Stripe Lands Apple in Quest for $720 Billion in Payments - Bloomberg
www.bloomberg.com
Stripe Lands Apple in Quest for $720 Billion in Payments
-
The Boring Designer • Cap Watkins
blog.capwatkins.com
Whenever I’m looking at a product designer’s work, I find myself continuously asking the same question: which solution is the boring one? Maybe it’s ...
-
The New Establishment 2014
www.vanityfair.com
For the 20th anniversary of Vanity Fair's New Establishment, we broke down this year’s 93 members, by metrics from astrological sign to relationship ...
-
Health Insurance Marketplace, Affordable Care Act
www.healthcare.gov
Learn how the health care law affects you at Healthcare.gov. The official site of the Health Insurance Marketplace. See your health insurance choices.
-
Scott Hurff
scotthurff.com
I'm Scott Hurff, and I love to help you build better products. I'm on the founding team of a Kleiner Perkins-backed mobile startup, created a course ...
-
1Password - Password Manager and Secure Wallet
itunes.apple.com
Get 1Password - Password Manager and Secure Wallet on the App Store. See screenshots and ratings, and read customer reviews.
-
A Watch Guy's Thoughts On The Apple Watch After Seeing It In The Metal ...
www.hodinkee.com
I'm not even sure we can call it a watch. Okay, it goes on the wrist, and it happens to tell the time, but that's about where the similarities ...
-
Flight: Twitter's Mobile Developer Conference
www.twitterflight.com
Flight is a gathering built by developers, for developers. You'll be right at home if you live, breathe and occasionally dream in Java, Objective-C, ...
-
Medium’s CSS is actually pretty f***ing good.
medium.com
Some notes on Medium’s CSS, the steps we’ve taken to get it to where it is, and the world we live in today.
-
WIRED
www.wired.com
Get in-depth coverage of current and future trends in technology, and how they are shaping business, entertainment, communications, science, ...
-
Eric Robinson sur Twitter : "brb gonna stare at this Apple Watch ...
twitter.com
Mot de passe oublié ? Vous utilisez déjà Twitter via SMS ?
-
How quitting my corporate job for my startup dream f*cked my life up
medium.com
And five questions I wish I had asked myself at the very beginning
-
Microsoft Near Deal to Buy Minecraft Maker Mojang
online.wsj.com
Microsoft is in serious discussions to buy Mojang, the Swedish company behind the popular "Minecraft" videogame, according to a person with knowledge ...
-
If programming languages were weapons • Bjorn Tipling
bjorn.tipling.com
C is an M1 Garand standard issue rifle, old but reliable. C++ is a set of nunchuks, powerful and impressive when wielded but takes many years of pain ...
-
Twitter Testing Buy Button as E-Commerce Plans Take Shape
www.bloomberg.com
For Twitter Inc., a tweet will soon be more than a form of communication or an ad -- it will be an invitation to buy.
-
This is why your Internet is slow. And it’ll get worse. Unless you take 1 ...
www.battleforthenet.com
You’re our only hope.
-
M6.0 - 6km NW of American Canyon, California (BETA) 2014-08-24 10:20:44 UTC
comcat.cr.usgs.gov
USGS Earthquake Hazards Program, responsible for monitoring, reporting, and researching earthquakes and earthquake hazards
-
iPhone camera evolution: How does the iPhone 6 camera compare to previous ...
snapsnapsnap.photos
How does the iPhone 6 camera stack up against previous hardware? In her ongoing series, professional iPhone photographer Lisa Bettany takes a hard ...
-
Some iPhone 6 Plus Owners Accidentally Bending Their iPhones in Pockets
www.macrumors.com
As highlighted in a few reports shared in the MacRumors forums, a small but growing number of iPhone 6 Plus owners have reportedly bent their ...
-
Talko | Talko is the best way to use your voice to get things done.
www.talko.com
TALK. SHARE. DO. Amazing things can happen when we talk with each other. Thoughts are shared, ideas formed and problems solved. Talko is the best way ...
-
How I Pranked My Roommate With Eerily Targeted Facebook Ads
mysocialsherpa.com
This is the chronicle of the most epic retaliation and how I pranked my roommate with targeted Facebook Ads to the point of complete paranoia and ...
-
News Feed FYI: Showing More Timely Stories from Friends and Pages | ...
newsroom.fb.com
Our latest update to News Feed ranking looks at two new factors to determine if a story is more important in the moment than other types of updates.
-
Meet Blue Bottle at Home
www.gv.com
In this Google Ventures profile, Blue Bottle founder and CEO James Freeman shares his vision for Blue Bottle at Home, a new e-commerce destination ...


|
Order Details
|
|
Newark Ref:
|
3/17/20 22.41 PM
|
|
Your Order Number:
|
3/17/20 22.41 PM
|
|
Date of Order:
|
Mar 17, 2020
|
|
|
Newark Part No.
|
Qty Ordered
|
Mftr. Part No
|
Your Part No
|
Manufacturer / Description
|
|
08N6813
|
10
|
2226A-02
|
|
MULTICOMP PRO 2226A-02
Connector Housing, 2226 Series, Receptacle, 2 Positions, 2.54 mm
|
|
08N6834
|
20
|
2226TG
|
|
MULTICOMP PRO 2226TG Contact,
2226 Series, Socket, Crimp, 24 AWG, Gold Plated Contacts, Wire-to-Board Crimp Housings
|
|
22AC8322
|
4
|
MC01007
|
|
MULTICOMP PRO MC01007
Prototype Board, Phenolic, 1.6 mm, 72 mm, 47 mm
|
|
54W2650
|
4
|
161
|
|
ADAFRUIT 161 Photo Cell, CDS
Photoresistor
|
|
91K7219
|
10
|
D103M29Z5UH6UJ5R
|
|
VISHAY D103M29Z5UH6UJ5R
Ceramic Disc Capacitor, 10000 pF, 100 V, D Series, Â± 20%, Z5U, 5 mm
|
|
16N942
|
4
|
8459-0674
|
|
MULTICOMP 8459-0674 Battery
Holder, PP3 (9V) x 1, Strap
|
|
28T0874
|
5
|
C503C-WAN-CBBDB151
|
|
CREE C503C-WAN-CBBDB151
LED, Cool White, Through Hole, T-1 3/4 (5mm), 20 mA, 3.2 V, 46.1 cd
|
|
78Y4341
|
3
|
PSG91114
|
|
PRO ELEC PSG91114 Battery, 9 V,
PP3, Alkaline, 565 mAh, Snap Contact
|
|
94C4986
|
25
|
SFR2500002200FR500
|
|
VISHAY
SFR2500002200FR500 Through Hole Resistor, 220 ohm, SFR25 Series, 400 mW, Â± 1%, Axial Leaded, 250
V
|
|
65R1982
|
10
|
UHE1H101MPD1TD
|
|
NICHICON
UHE1H101MPD1TD Electrolytic Capacitor, Miniature, 100 ÂµF, 50 V, HE Series, Â± 20%,
Radial Leaded, 8 mm
|
|
53M5115
|
25
|
SFR2500001002FR500
|
|
VISHAY
SFR2500001002FR500 Through Hole Resistor, 10 kohm, SFR25 Series, 400 mW, Â± 1%, Axial Leaded, 250
V
|
|
82K7786
|
4
|
SPC15494
|
|
MULTICOMP SPC15494 IC
& Component Socket, 8 Contacts, DIP Socket, 2.54 mm, 7.62 mm, Phosphor Bronze
|
|
|
Billing Method:
|
Credit/Debit Card
|
|
Shipping Method:
|
USPS Domestic Priority Mail (For same day dispatch order by by 2:30 PM EST)
|
|
|
Once again, thank you for ordering from Newark. We look forward to serving you again soon.
|
|
Regards,
|
|
The Newark team
|
|
|
|
|
|
|
Newark
|
|
300 S. Riverside Plaza, Suite 2200, Chicago, Illinois, 60606-6765 | Newark
|
|
An Avnet Company Copyright Â©2019 Premier Farnell Ltd, All Rights Reserved.
|
********************************Disclaimer***********************************
The preceding e-mail message (including any attachments) contains
information that may be confidential, be protected by the attorney-client
or other applicable privileges, or constitute non-public information. It
is intended to be conveyed only to the designated recipient(s). If you are
not an intended recipient of this message, please notify the sender by
replying to this message and then delete it from your system. Use,
dissemination, distribution, or reproduction of this message by unintended
recipients is not authorized and may be unlawful.
*****************************************************************************