Eclipse sensiNact
Introduction
Eclipse sensiNact aims at helping coders working with data streams from deployed “IoT” devices without the need to complex API configuration.
Using Eclipse sensiNact, experimenters can find Internet of Things devices which are deployed in the city, and understand the data streams that they provide. The Eclipse sensiNact IDE allows the creation of applications using a scripting tool (with Code Assist functionality). These applications might set up alerts for when variables in the data streams reach certain levels, or can aggregate data from many devices, creating virtual devices which provide coarse data that might be more useful to an experiment.
The following schema summaries the way Eclipse sensiNact integrates with the OrganiCity Experimentation as a Service facility.
The Organicity EaaS facility collects and stores data from the federated sites (Santander, Aarhus and London, on this schema). Eclipse sensiNact Gateway is connected to this platform, and is notifed when IoT devices is added, removed, or when sensed data is updated. Eclipse sensiNact studio provides a graphical UI to the gateway. It ease discovering devices, and provides an editor to write applications using IoT devices.
Installation
To use Eclipse sensiNact, you need a gateway, and the studio. The easier solution is to install both on your onw computer (running Linux 64 bits) with the following procedure.
First, you will need to add the Eclipse sensiNact repository to /etc/apt/sources.list
configuration file.
echo "deb http://debian.organicity.eu ./" | sudo tee -a /etc/apt/sources.list
Then, you can install both studio and gateway.
sudo apt-get update --yes
sudo apt-get install --yes --allow-unauthenticated sensinact
sudo apt-get install --yes --allow-unauthenticated sensinact-studio
Configuration
Because Eclipse sensiNact is a modular runtime, you will need to choose the parts (bundles) you want to have up and running.
First, you need to stop your Gateway: sudo service sensinact stop
Then, you can select the bundles: /opt/sensinact/sensinact -c
Here are the one to choose for discovering Eclispe sensiNact.
- application (Application manager)
- http (HTTP stack)
- organicity (For connecting Organicity EaaS)
- rest (HTTP callbacks)
Now, you just need to resttart the service : sudo service sensinact start
Optional : If you want this service to be automaticaly launched at startup, execute the following command : sudo bash update-rc.d sensinact defaults
Eclipse sensiNact Studio
To start Eclipse sensiNact Studio, just run sensinact-studio
.
Eclipse sensiNact Studio allows an easy interaction with the OrganiCity devices and the creation of applications. The Studio is based on the Eclipse platform [Eclipse] and built as a rich client platform application. The Graphical User Interface (GUI) is developed using the views mechanism from Eclipse. Thus, it proposes views for browsing devices, locating devices on a map and interacting with them, i.e., getting value from sensors or performing actions on actuators. The Studio is also targeted to ease the creation of IoT application following the Event-Condition-Action (ECA) pattern.
The GUI includes different views: navigator, deployment, properties views, as well as a Domain Specific Language (DSL) editor.
Browsing devices
Before users can use the studio for managing devices and applications, they need to connect a Eclipse sensiNact gateway. This action is performed by clicking on the plus sign icon on the device navigator. Then, gateway information have to be provided. If you have installed the gateway locally, you can use the following configuration:
- Address : localhost
- Port : 8080
- Timeout : 10000
Once the information have been provided and the dialog validated, the Gateway is added to the Navigator View. To display and browse the available devices imported by this gateway, connecting to it is needed. This action is performed using the connect button.
The device Navigator View is then populated, and pin points are displayed on the map. By clicking on attributes names, it is possible to get the current value for the considered attribute. It is also possible to see attributes values on the map, clicking on the pin points.
Application management
Application creation
The Eclipse sensiNact Studio allows the creation of applications to be executed on the gateway. Creating an application is performed by writing a script using a dedicated syntax, and deploying this script to the gateway.
On the figure above, a project has been created on the project explorer view (on the left). In this project, a script named speed-limit.sna
has been created, and is being edited. As the figures shows, the editor provides code highlighting (some keywords are displayed in a special font), code completion (with popups) and a syntax validator which displays red crosses on the script margin in case of error.
The dedicated syntax, a Domain Specific Language, is composed by the following blocks:
- The shortcut block: each resource is accessible through a unique URI, which can be quite long. This block aims at creating shortcut for the next blocks.
- The event block: the developer defines on which resources the application is triggered. When an event is thrown and is a valid trigger, the conditional block is executed.
- The conditional block: once the application has been triggered, and before any action can be executed, the data from the resource has to satisfy the conditional block. The keyword for this block is if followed by the conditions to be validated.
- The actions statements: if the conditional block is satisfied, actions are performed in the order that they are listed. The actions can be physical actions on actuators or virtual actions such as changing the format of a data using a mathematical function. The available actions, also named functions, are listed below:
- Basic functions: addition, subtraction, division, multiplication, modulo, string concatenation, substring, various operators (e.g., equals, greater than, lesser than, different), ACT and SET methods on Eclipse sensiNact resources.
- Complex Event Processing functions (using the Esper1 library): after, before, coincides, average, average deviation, count, max, min, median, standard deviation and sum.
The following table shows the basic structure for writing a script.
| [resource |
Shortcut block, which must contains at least one statement. |
| on |
The event block, lists the events triggering the script. At least one event must be provided. |
| [if [ [else do]? [ end if; |
The conditional block, which lists actions to be performed based on conditions. |
Application example
For this example, we are going to use simulated devices.
Let's run a gateway with the simulated devices.
sudo service sensinact stop
stops the gateway- with
sudo /opt/sensinact/sensinact -c
add the simulation bundle - restart the gateway with
sudo /opt/sensinact/sensinact
It's important to run the gateway this way, and not using the service to have the simulated devices UI linked to your current graphical session.
Now, in the project explorer view:
- new project creation:
File > New > Project
- right click on the created folder in the Project Explorer View.
New > File
. Choose a name with the ending with.sna
- Add XText Nature to the project (a popup will automatically be displayed).
You can now edit your sna file with the following content:
resource slider=[OrganiCity/slider/cursor/position]
resource light_on = [OrganiCity/light/switch/turn_on]
resource light_off = [OrganiCity/light/switch/turn_off]
on slider.subscribe()
if slider.get() < 500 do
light_off.act()
else do
light_on.act()
end if
This script will be triggered each time the slider position will be updated (on slider.subscribe()
statement). The light will be turned on or off depending on the slider position value.
Application deployment
Once the script has been written, it can be deployed to the gateway where it will be executed. This is performed using a right click on the script file.
Application monitoring
After the application has been deployed, a new set of resources is automatically created under the AppManager device. You can browse those resources into the Device Navigator View.
First of all, a new service is created with the name of the sna file (without the extension). In our example, it is speed-limit
. This service representing the application always contains a standard set of resources.
| Resource | Type | Description |
|---|---|---|
| autorestart | property | In case of failure, decides if the application should be automatically started again |
| content | property | Script file content |
| EXCEPTION | action | Deprecated |
| location | property | GPS location which can be used if it makes sense |
| maxinstances | property | Number of parallel instances which should be started |
| resetOnStop | property | On Stop, decides if the generated resources by the application should be destroyed or kept |
| START | action | Starts the application |
| status | state variable | Current status of the application: START/STOP/... |
| STOP | action | Stops the application |
| UNINSTALL | action | Removes the application |
To start the application, simply double click on the START
resource. This will launch the start action, which will run the script.
The figure shows that the application is up and running on the server. The studio can be used to check if the application has the expected behavior, by querying the resources. The studio can also be shutted down, since the applications are executed on the gateway.
Conclusion
In this section, we have presented the way Eclipse sensiNact Studio can gives an overview of the available devices in the OrganiCity context. We have also shown the creation process of IoT application following the Event-Condition-Action (ECA) pattern.
Gateway
Introduction
The Eclipse sensiNact Gateway allows the interconnection of heterogeneous devices and services into a consistent model. This one is presented to the Eclipse sensiNact Studio which can monitor the devices ecosystem and design application to be executed on the gateway.
More precisely, the Eclipse sensiNact Gateway integrates with the OC Platform using the Asset Discovery Service. Thereby, the gateway is aware of the assets provided by the OC Platform. On the other hand, the gateway has dedicated interfaces to directly connect to third parties devices and API. As a result, the gateway can interact with a lot of resources, which can be local or remote.
The gateway architecture
The interactions between the gateway and other entities are performed through a set of northbound and southbound bridges. The goal of the bridges is to manage the communication with devices and services, which can be local or remote. On one hand, southbound bridges are in charge of collecting data from sensors and services, and to send orders which will be performed by actuators. On the other hand, northbound bridges are specialized in interacting with remote systems. Thanks to those bridges, it is possible to make third party systems aware of devices & virtual resources known by the gateway.
In terms of connectivity, on the southbound side the Eclipse sensiNact gateway allows to cope both with “physical device” protocols and “virtual device” ones, allowing a uniform and transparent access to an XBee network, or an HTTP Restful web service for example. Here's a non-exhaustive list of supported protocols:
- **EnOcean [EnOcean],** energy harvesting wireless sensor technology (ultra-low-power radio technology for free wireless sensors), and protocols in use to interact with those sensors;
- **Bluetooth Low Energy.** Part of the Bluetooth specification version 4 [Bluetooth4], it is a personal area network, low power protocol designed mainly for healthcare or entertainment type of applications;
- **MQTT [MQTT],** which is a machine-to-machine protocol, lightweight publish/subscribe messaging transport, useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium;
- **ZigBee [ZigBee]** based protocols (XBee for example);
- **CoAP [RFC7252],** which is a REST application protocol, designed to be “the HTTP for constrained networks and devices” whose concept originated from the idea that "the Internet Protocol could and should be applied even to the smallest devices," and that low-power devices with limited processing capabilities should be able to participate in the Internet of Things; it is usually used on top of a 6LoWPAN network, but it may travel regular IP networks as well (it is used by the OMA LWM2M protocol, for instance).
On the northbound side the Eclipse sensiNact gateway provides both client/server and publish/subscribe access protocols: MQTT [MQTT], JSON-RPC (1.0 and 2.0) [JSON-RPC], HTTP RESTful, CDMI [CDMI].
All the communications of Eclipse sensiNact gateway are converging to a central piece: the core. This element is in charge of the overall coordination of information, involving two managers: the device manager and the application manager.
The device manager, with its associated database (the OSGi registry) stores all the information regarding devices. This include devices availability, and also devices properties, location, etc.
The application manager is a bit more complex. It manages the applications, following devices availability and updating applications life cycle. It offers a plug-in facility, to extend its behaviour. The two main plugins are the Event Condition Action plugin, and the Complex Event Processor plugin. The Event Condition Action plugin provides the basic structure for creating applications. It allows the triggering of rules, based on event. Then, a condition can be evaluated, and actions performed accordingly. Of course, events, conditions and actions are related to devices, using the device manager. Using the Esper Engine, the Complex Event Processor plugin is able to generate high level events based on low level ones. For example, it is possible to know that two events occur in a given time interval, with a given order. The events generated by the CEP plug-in can be used in the ECA plugin.
Eclipse sensiNact resource model
It is important to understand the internal model of the Eclipse sensiNact Gateway , since it is used everywhere in the Eclipse sensiNact ecosystem. That is why, a clear understanding of the concepts and relationships between them can even help using the Studio introduced previously.
All the devices and their related informations are represented using a standard resource model. It is structured around three main concepts: Service Provider, Service and Resource. A Service Provider représents an entity, which can be a device or something more abstract such as an API endpoint. This Service Provider can have several Services, which are a meaningful aggregate of resources based on a common purpose. A resource is the place where information is stored. For example, on a weather station, a temperature sensor will be a resource providing the temperature.
Based on its purpose, a resource can be a Property, a Sensor Data, a State Variable, or an Action. The differences among them is detailed in the following table.
| Type | Description |
|---|---|
| Property | Property exposed by a service. This is information which is likely to be static (owner, model, vendor, static location, etc.). In some cases, this property can be allowed to be modified. |
| Sensor Data | Sensory data provided by a service. This is real-time information provided, for example, by the SmartObject that measures physical quantities. |
| State Variable | Information representing a SmartObject state variable of the service. This variable is most likely to be modified by an action (turn on light modifies the light state, opening door changes the door state, etc.) but also to intrinsic conditions associated to the working procedure of the service. |
| Action | Functionality provided by a service. This is mostly an actuation on the physical environment via an actuator SmartObject supporting this functionality (turn on light, open door, etc.) but can also be a request to do a virtual action (play a multimedia on a TV, make a parking space reservation, etc.) |
Since it is not possible to directly interact with resources, Eclipse sensiNact provides access methods. The access methods that can be associated to a resource depend on the resource type, for example, a GET method can only be associated to resources of type Property, State Variable and SensorData. A SET method can only be associated to State Variable and modifiable Property resources. An ACT method can only be associated to an Action resource. SUBSCRIBE and UNSUBSCRIBE methods can be associated to any resources.
| Type | Description |
|---|---|
| GET | Gets the value attribute of the resource. |
| SET | Sets a given new value as the data value of the resource. |
| ACT | Invokes the resource (method execution) with a set of defined parameters. |
| SUBSCRIBE | Subscribes to the resource with optional condition and periodicity. |
| UNSUBSCRIBE | Remove an existing subscription. |
Conclusion
We have presented the architecture of the Eclipse sensiNact Gateway, and the way it is integrated into the OC Platform. We also have introduced its resource model, since it is used in the studio as well.
To help experimenters start easily using the Studio, we are providing “Gateways as a Service” for the OrganiCity project. They are Gateways available in the cloud, and configured for interacting with OrganiCity devices.


APK method count
output per-package method counts
Drop file here to load content or click on this box to open file dialog.
No file will be uploaded - uses only JavaScript HTML5 FileReader.
output per-package method counts


--- layout: post date: 2010-05-14 time: "09:00:00" authors: ["Greg Wilson"] title: "Day 10: Closed Captioning" tags: ["Content"] ---
Our latest screencast, on NULL values in SQL, is now online. [Original link no longer active; more recent screencast on NULL values.] Unlike its predecessors, this one has closed captions (as well as a transcript in the enclosing page). Please let us know what you think: are the captions helpful, or do you find them distracting?


Buttons
Buttons are by default shadowed. You can create a flat button by adding the `flat` attribute
You can make it a link element by providing a href
attribute.
Default buttons
primary
secondary
success
warning
danger
info
light
grey
dark
Outline buttons
primary
secondary
success
warning
danger
info
light
grey
dark
Flat buttons
Flat
Flat outline
Block level buton
Yo!
home


Hello, {{profile_company}}
We found you a match!
|
|
Hi I'm {{post_name}}!
I'm a {{post_position}}
Looking for a job in {{post_location}}
If you would like to contact this job seeker, visit the link
below and click the
interested
button found in the lower right corner of
the job posting.
The number next to the interested link is a counter to let you know how
many other companies are interested in this candidate.
Timing is of the essence! Candidates usually respond
to companies in order of first contact.
Best Regards,
The Jobayan Team
|
|
Questions? Concerns? Email us at<EMAIL_ADDRESS>Mandala Park, 1552 Shaw Blvd, Pleasant Hills Mandaluyong |
|
Copyright © 2017 All Rights Reserved
Jobayan PH ·
Our Privacy Policy
|


Education
Haidian
Peking University is a comprehensive and national key university. The campus, known as "Yan Yuan"（the garden of Yan）, is situated at Haidian District in the western suburb of Beijing, with a total area of 2,743,532 square metres (or 274 hectares). It stands near to the Yuanmingyuan Garden and the Summer Palace.
Thus Peking University has become a center for teaching and research and a university of a new type, embracing diverse branches of learning such as basic and applied sciences, social sciences and the humanities, and sciences of medicine, management, and education. Its aim is to rank among the world's best universities in the future.


"""distutils.util Miscellaneous utility functions -- anything that doesn't fit into one of the other *util.py modules. """ import os import re import importlib.util import string import sys from distutils.errors import DistutilsPlatformError from distutils.dep_util import newer from distutils.spawn import spawn from distutils import log from distutils.errors import DistutilsByteCompileError from .py35compat import _optim_args_from_interpreter_flags def get_host_platform(): """Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information included depends on the OS; eg. on Linux, the kernel version isn't particularly important. Examples of returned values: linux-i586 linux-alpha (?) solaris-2.6-sun4u Windows will return one of: win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc) win32 (all others - specifically, sys.platform is returned) For other non-POSIX platforms, currently just returns 'sys.platform'. """ if os.name == 'nt': if 'amd64' in sys.version.lower(): return 'win-amd64' if '(arm)' in sys.version.lower(): return 'win-arm32' if '(arm64)' in sys.version.lower(): return 'win-arm64' return sys.platform # Set for cross builds explicitly if "_PYTHON_HOST_PLATFORM" in os.environ: return os.environ["_PYTHON_HOST_PLATFORM"] if os.name != "posix" or not hasattr(os, 'uname'): # XXX what about the architecture? NT is Intel or Alpha, # Mac OS is M68k or PPC, etc. return sys.platform # Try to distinguish various flavours of Unix (osname, host, release, version, machine) = os.uname() # Convert the OS name to lowercase, remove '/' characters, and translate # spaces (for "Power Macintosh") osname = osname.lower().replace('/', '') machine = machine.replace(' ', '_') machine = machine.replace('/', '-') if osname[:5] == "linux": # At least on Linux/Intel, 'machine' is the processor -- # i386, etc. # XXX what about Alpha, SPARC, etc? return "%s-%s" % (osname, machine) elif osname[:5] == "sunos": if release[0] >= "5": # SunOS 5 == Solaris 2 osname = "solaris" release = "%d.%s" % (int(release[0]) - 3, release[2:]) # We can't use "platform.architecture()[0]" because a # bootstrap problem. We use a dict to get an error # if some suspicious happens. bitness = {2147483647:"32bit",<PHONE_NUMBER>854775807:"64bit"} machine += ".%s" % bitness[sys.maxsize] # fall through to standard osname-release-machine representation elif osname[:3] == "aix": from .py38compat import aix_platform return aix_platform(osname, version, release) elif osname[:6] == "cygwin": osname = "cygwin" rel_re = re.compile (r'[\d.]+', re.ASCII) m = rel_re.match(release) if m: release = m.group() elif osname[:6] == "darwin": import _osx_support, distutils.sysconfig osname, release, machine = _osx_support.get_platform_osx( distutils.sysconfig.get_config_vars(), osname, release, machine) return "%s-%s-%s" % (osname, release, machine) def get_platform(): if os.name == 'nt': TARGET_TO_PLAT = { 'x86' : 'win32', 'x64' : 'win-amd64', 'arm' : 'win-arm32', } return TARGET_TO_PLAT.get(os.environ.get('VSCMD_ARG_TGT_ARCH')) or get_host_platform() else: return get_host_platform() def convert_path (pathname): """Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can actually use them in the filesystem. Raises ValueError on non-Unix-ish systems if 'pathname' either starts or ends with a slash. """ if os.sep == '/': return pathname if not pathname: return pathname if pathname[0] == '/': raise ValueError("path '%s' cannot be absolute" % pathname) if pathname[-1] == '/': raise ValueError("path '%s' cannot end with '/'" % pathname) paths = pathname.split('/') while '.' in paths: paths.remove('.') if not paths: return os.curdir return os.path.join(*paths) # convert_path () def change_root (new_root, pathname): """Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS. """ if os.name == 'posix': if not os.path.isabs(pathname): return os.path.join(new_root, pathname) else: return os.path.join(new_root, pathname[1:]) elif os.name == 'nt': (drive, path) = os.path.splitdrive(pathname) if path[0] == '\\': path = path[1:] return os.path.join(new_root, path) else: raise DistutilsPlatformError("nothing known about platform '%s'" % os.name) _environ_checked = 0 def check_environ (): """Ensure that 'os.environ' has all the environment variables we guarantee that users can use in config files, command-line options, etc. Currently this includes: HOME - user's home directory (Unix only) PLAT - description of the current platform, including hardware and OS (see 'get_platform()') """ global _environ_checked if _environ_checked: return if os.name == 'posix' and 'HOME' not in os.environ: try: import pwd os.environ['HOME'] = pwd.getpwuid(os.getuid())[5] except (ImportError, KeyError): # bpo-10496: if the current user identifier doesn't exist in the # password database, do nothing pass if 'PLAT' not in os.environ: os.environ['PLAT'] = get_platform() _environ_checked = 1 def subst_vars (s, local_vars): """Perform shell/Perl-style variable substitution on 'string'. Every occurrence of '$' followed by a name is considered a variable, and variable is substituted by the value found in the 'local_vars' dictionary, or in 'os.environ' if it's not in 'local_vars'. 'os.environ' is first checked/augmented to guarantee that it contains certain values: see 'check_environ()'. Raise ValueError for any variables not found in either 'local_vars' or 'os.environ'. """ check_environ() def _subst (match, local_vars=local_vars): var_name = match.group(1) if var_name in local_vars: return str(local_vars[var_name]) else: return os.environ[var_name] try: return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, s) except KeyError as var: raise ValueError("invalid variable '$%s'" % var) # subst_vars () def grok_environment_error (exc, prefix="error: "): # Function kept for backward compatibility. # Used to try clever things with EnvironmentErrors, # but nowadays str(exception) produces good messages. return prefix + str(exc) # Needed by 'split_quoted()' _wordchars_re = _squote_re = _dquote_re = None def _init_regex(): global _wordchars_re, _squote_re, _dquote_re _wordchars_re = re.compile(r'[^\\\'\"%s ]*' % string.whitespace) _squote_re = re.compile(r"'(?:[^'\\]|\\.)*'") _dquote_re = re.compile(r'"(?:[^"\\]|\\.)*"') def split_quoted (s): """Split a string up according to Unix shell-like rules for quotes and backslashes. In short: words are delimited by spaces, as long as those spaces are not escaped by a backslash, or inside a quoted string. Single and double quotes are equivalent, and the quote characters can be backslash-escaped. The backslash is stripped from any two-character escape sequence, leaving only the escaped character. The quote characters are stripped from any quoted string. Returns a list of words. """ # This is a nice algorithm for splitting up a single string, since it # doesn't require character-by-character examination. It was a little # bit of a brain-bender to get it working right, though... if _wordchars_re is None: _init_regex() s = s.strip() words = [] pos = 0 while s: m = _wordchars_re.match(s, pos) end = m.end() if end == len(s): words.append(s[:end]) break if s[end] in string.whitespace: # unescaped, unquoted whitespace: now words.append(s[:end]) # we definitely have a word delimiter s = s[end:].lstrip() pos = 0 elif s[end] == '\\': # preserve whatever is being escaped; # will become part of the current word s = s[:end] + s[end+1:] pos = end+1 else: if s[end] == "'": # slurp singly-quoted string m = _squote_re.match(s, end) elif s[end] == '"': # slurp doubly-quoted string m = _dquote_re.match(s, end) else: raise RuntimeError("this can't happen (bad char '%c')" % s[end]) if m is None: raise ValueError("bad string (mismatched %s quotes?)" % s[end]) (beg, end) = m.span() s = s[:beg] + s[beg+1:end-1] + s[end:] pos = m.end() - 2 if pos >= len(s): words.append(s) break return words # split_quoted () def execute (func, args, msg=None, verbose=0, dry_run=0): """Perform some action that affects the outside world (eg. by writing to the filesystem). Such actions are special because they are disabled by the 'dry_run' flag. This method takes care of all that bureaucracy for you; all you have to do is supply the function to call and an argument tuple for it (to embody the "external action" being performed), and an optional message to print. """ if msg is None: msg = "%s%r" % (func.__name__, args) if msg[-2:] == ',)': # correct for singleton tuple msg = msg[0:-2] + ')' log.info(msg) if not dry_run: func(*args) def strtobool (val): """Convert a string representation of truth to true (1) or false (0). True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if 'val' is anything else. """ val = val.lower() if val in ('y', 'yes', 't', 'true', 'on', '1'): return 1 elif val in ('n', 'no', 'f', 'false', 'off', '0'): return 0 else: raise ValueError("invalid truth value %r" % (val,)) def byte_compile (py_files, optimize=0, force=0, prefix=None, base_dir=None, verbose=1, dry_run=0, direct=None): """Byte-compile a collection of Python source files to .pyc files in a __pycache__ subdirectory. 'py_files' is a list of files to compile; any files that don't end in ".py" are silently skipped. 'optimize' must be one of the following: 0 - don't optimize 1 - normal optimization (like "python -O") 2 - extra optimization (like "python -OO") If 'force' is true, all files are recompiled regardless of timestamps. The source filename encoded in each bytecode file defaults to the filenames listed in 'py_files'; you can modify these with 'prefix' and 'basedir'. 'prefix' is a string that will be stripped off of each source filename, and 'base_dir' is a directory name that will be prepended (after 'prefix' is stripped). You can supply either or both (or neither) of 'prefix' and 'base_dir', as you wish. If 'dry_run' is true, doesn't actually do anything that would affect the filesystem. Byte-compilation is either done directly in this interpreter process with the standard py_compile module, or indirectly by writing a temporary script and executing it. Normally, you should let 'byte_compile()' figure out to use direct compilation or not (see the source for details). The 'direct' flag is used by the script generated in indirect mode; unless you know what you're doing, leave it set to None. """ # Late import to fix a bootstrap issue: _posixsubprocess is built by # setup.py, but setup.py uses distutils. import subprocess # nothing is done if sys.dont_write_bytecode is True if sys.dont_write_bytecode: raise DistutilsByteCompileError('byte-compiling is disabled.') # First, if the caller didn't force us into direct or indirect mode, # figure out which mode we should be in. We take a conservative # approach: choose direct mode *only* if the current interpreter is # in debug mode and optimize is 0. If we're not in debug mode (-O # or -OO), we don't know which level of optimization this # interpreter is running with, so we can't do direct # byte-compilation and be certain that it's the right thing. Thus, # always compile indirectly if the current interpreter is in either # optimize mode, or if either optimization level was requested by # the caller. if direct is None: direct = (__debug__ and optimize == 0) # "Indirect" byte-compilation: write a temporary script and then # run it with the appropriate flags. if not direct: try: from tempfile import mkstemp (script_fd, script_name) = mkstemp(".py") except ImportError: from tempfile import mktemp (script_fd, script_name) = None, mktemp(".py") log.info("writing byte-compilation script '%s'", script_name) if not dry_run: if script_fd is not None: script = os.fdopen(script_fd, "w") else: script = open(script_name, "w") with script: script.write("""\ from distutils.util import byte_compile files = [ """) # XXX would be nice to write absolute filenames, just for # safety's sake (script should be more robust in the face of # chdir'ing before running it). But this requires abspath'ing # 'prefix' as well, and that breaks the hack in build_lib's # 'byte_compile()' method that carefully tacks on a trailing # slash (os.sep really) to make sure the prefix here is "just # right". This whole prefix business is rather delicate -- the # problem is that it's really a directory, but I'm treating it # as a dumb string, so trailing slashes and so forth matter. #py_files = map(os.path.abspath, py_files) #if prefix: # prefix = os.path.abspath(prefix) script.write(",\n".join(map(repr, py_files)) + "]\n") script.write(""" byte_compile(files, optimize=%r, force=%r, prefix=%r, base_dir=%r, verbose=%r, dry_run=0, direct=1) """ % (optimize, force, prefix, base_dir, verbose)) cmd = [sys.executable] cmd.extend(_optim_args_from_interpreter_flags()) cmd.append(script_name) spawn(cmd, dry_run=dry_run) execute(os.remove, (script_name,), "removing %s" % script_name, dry_run=dry_run) # "Direct" byte-compilation: use the py_compile module to compile # right here, right now. Note that the script generated in indirect # mode simply calls 'byte_compile()' in direct mode, a weird sort of # cross-process recursion. Hey, it works! else: from py_compile import compile for file in py_files: if file[-3:] != ".py": # This lets us be lazy and not filter filenames in # the "install_lib" command. continue # Terminology from the py_compile module: # cfile - byte-compiled file # dfile - purported source filename (same as 'file' by default) if optimize >= 0: opt = '' if optimize == 0 else optimize cfile = importlib.util.cache_from_source( file, optimization=opt) else: cfile = importlib.util.cache_from_source(file) dfile = file if prefix: if file[:len(prefix)] != prefix: raise ValueError("invalid prefix: filename %r doesn't start with %r" % (file, prefix)) dfile = dfile[len(prefix):] if base_dir: dfile = os.path.join(base_dir, dfile) cfile_base = os.path.basename(cfile) if direct: if force or newer(file, cfile): log.info("byte-compiling %s to %s", file, cfile_base) if not dry_run: compile(file, cfile, dfile) else: log.debug("skipping byte-compilation of %s to %s", file, cfile_base) # byte_compile () def rfc822_escape (header): """Return a version of the string escaped for inclusion in an RFC-822 header, by ensuring there are 8 spaces space after each newline. """ lines = header.split('\n') sep = '\n' + 8 * ' ' return sep.join(lines) # 2to3 support def run_2to3(files, fixer_names=None, options=None, explicit=None): """Invoke 2to3 on a list of Python files. The files should all come from the build area, as the modification is done in-place. To reduce the build time, only files modified since the last invocation of this function should be passed in the files argument.""" if not files: return # Make this class local, to delay import of 2to3 from lib2to3.refactor import RefactoringTool, get_fixers_from_package class DistutilsRefactoringTool(RefactoringTool): def log_error(self, msg, *args, **kw): log.error(msg, *args) def log_message(self, msg, *args): log.info(msg, *args) def log_debug(self, msg, *args): log.debug(msg, *args) if fixer_names is None: fixer_names = get_fixers_from_package('lib2to3.fixes') r = DistutilsRefactoringTool(fixer_names, options=options) r.refactor(files, write=True) def copydir_run_2to3(src, dest, template=None, fixer_names=None, options=None, explicit=None): """Recursively copy a directory, only copying new and changed files, running run_2to3 over all newly copied Python modules afterward. If you give a template string, it's parsed like a MANIFEST.in. """ from distutils.dir_util import mkpath from distutils.file_util import copy_file from distutils.filelist import FileList filelist = FileList() curdir = os.getcwd() os.chdir(src) try: filelist.findall() finally: os.chdir(curdir) filelist.files[:] = filelist.allfiles if template: for line in template.splitlines(): line = line.strip() if not line: continue filelist.process_template_line(line) copied = [] for filename in filelist.files: outname = os.path.join(dest, filename) mkpath(os.path.dirname(outname)) res = copy_file(os.path.join(src, filename), outname, update=1) if res[1]: copied.append(outname) run_2to3([fn for fn in copied if fn.lower().endswith('.py')], fixer_names=fixer_names, options=options, explicit=explicit) return copied class Mixin2to3: '''Mixin class for commands that run 2to3. To configure 2to3, setup scripts may either change the class variables, or inherit from individual commands to override how 2to3 is invoked.''' # provide list of fixers to run; # defaults to all from lib2to3.fixers fixer_names = None # options dictionary options = None # list of fixers to invoke even though they are marked as explicit explicit = None def run_2to3(self, files): return run_2to3(files, self.fixer_names, self.options, self.explicit)


Octal representation
An octal representation is a number written using Base 8. Each digit may have only one of eight possible values (0 through 7). In computing, octal representations are most often encountered in the context of file system permissions where three or four digit octal numbers are used to denote the access permissions of the user, group and others.
The octal representation of the positive integers is the same as decimal up until the eight digit:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 10 (in the decimal system, 8)
All positive integers (and 0) may be written in octal representation.
Appending a zero to the right-hand side of a binary representation multiplies it by 8.


The w3-color classes defines background colors for HTML elements:
London is the most populous city in the United Kingdom, with a metropolitan area of over 9 million inhabitants.
London is the most populous city in the United Kingdom, with a metropolitan area of over 9 million inhabitants.
London is the most populous city in the United Kingdom, with a metropolitan area of over 9 million inhabitants.
London is the most populous city in the United Kingdom, with a metropolitan area of over 9 million inhabitants.


Preparation time
over 2 hours
Cooking time
30 mins to 1 hour
Serves
Serves 4
Dripping cake is rich, sweet and laced with dried fruit - very similar to lardy cakes. James serves his as a dessert with a light panna cotta and roasted rhubarb.
For the panna cotta, chill a large jug or bowl in the freezer.
Heat the double cream, vanilla pod and seeds and sugar in a saucepan until just boiling. Remove the pan from heat, add the soaked gelatine and buttermilk and whisk until well combined
Pass the mixture through a fine sieve into the chilled jug, and then stir in the vodka.
Return the jug to the fridge and whisk the mixture every five minutes until it begins to set.
Pour the mixture into dariole moulds and chill in the fridge for at least two hours, or until completely set.
For the dripping cake, preheat the oven to 180C/350F/Gas 4. Grease and line an 18cm/7in cake tin.
Put the sugar, dripping, dried fruit and candied peel into a saucepan. Add 225ml/8fl oz water and bring to the boil. Simmer gently for 10 minutes, then allow to cool in the pan.
Sift the dry ingredients together in a large bowl. Make a well in the middle and add the cooled dried-fruit mixture. Stir with a wooden spoon, gradually drawing in the flour from around the edge of the well, until you have a smooth batter.
Spoon the batter into the prepared tin and bake for about 40 minutes, or until a skewer inserted in the centre comes out clean.
Leave in the tin for five minutes before turning out on to a wire rack to cool completely.
For the roasted rhubarb, preheat the oven to 200C/400F/Gas 6.
Place the rhubarb on a roasting tray, sprinkle over the sugar then drizzle over the apple juice. Roast in the oven for 8-12 minutes, or until just tender.
Blend 125g/4½oz of the roasted rhubarb to a purée in a food processor. Reserve the remaining roasted rhubarb.
To serve, remove the panna cotta from their moulds, by briefly dipping the base of each mould into a bowl of boiled water. Gently slide a knife around the edge of each panna cotta and turn out into the centre of a serving plate. Serve with the rhubarb purée, a slice of dripping cake and roasted rhubarb.


This simulation shows the heat transfer throughout various kinds of meat. In the first section, you can input the starting values for the meat. The default is a 3cm piece of steak at room temperature (73°F or 23°C). The maximum meat thickness is 30 cm since we are assuming you're not trying to cook a whole cow. The initial temperature must be above absolute zero(-460 °F or -273°C). If the physical steak you're cooking is starting out at a temperature outside of this range, please contact the National Journal of Physics.
Next, you can input the specific instructions for the steak. Use the + buttons to add a row to the bottom and the x button to delete the given row. There is no maximum duration of time, as long as you are patient enough. The calculation for two days lasts approximately two seconds. You can cook the steak at any temperature above absolute zero. If you want to explore what a steak below absolute zero would look like, we suggest inventing a new theory of thermodynamics. In this example, the steak was cooked for 60 minutes at 60 degrees on both sides and then seared at 180 degrees on each side for a minute each.
The graph below is updated when you press the Cook button. It shows how the internal protein state of a thin slice of the center of the steak changes over time. The flame represents which side of the steak the heat is applied. Inside the flame is the temperature of the heat source for that side. When you mouseover a slice of steak, the legend highlights the information pertaining to the position of your mouse. In addition, the state at the point of your mouse is displayed in a tooltip.
You can also see the temperature of your meat over time by clicking the "Temperature" button next to "Protein State". This shows the temperature at every point in the meat over time. The mouseover tooltip now displays the temperature of the point in the meat.
If you wish to compare the differences between two recipes, you can select them from the dropdowns at the bottom of the page. When a recipe is selected, the final "slice" of the meat with color-coded protein states is shown.
Created by: MIT students Kate Roe, Laura Breiman, and Marissa Stephens
Advised by: Rob Miller, Fredo Durand, Michael Brenner, and Pia Sorenson
Developed for the 2013 edX course Science and Cooking: From Haute Cuisine to Soft Matter Science. It demonstrates the heat diffusion through meat over time. This heat diffusion is calculated by modeling the meat using the diffusion constant of water. The heat at each point in the meat is calculated at each time step by using a Crank-Nicolson scheme to solve the heat equation.
The temperatures for the different stages of protein denaturization come from Harold McGee's On Food and Cooking: The Science and Lore of the Kitchen (pages 152 and 210). It is important to note, however, that these temperatures are estimates and not completely universal. This simulation is not a perfect model for cooking actual meat. Stove temperatures, pan types, and meat consistency are variable from case to case. Please be certain to check that your meat is thoroughly cooked before consumption unless you enjoy getting food posioning.
Please send questions and comments to cookmymeat@mit.edu


order today! 1-800-jan-vincent
Nutrition Information
protien
56g
sugar
16g
potassium
23g
fat
39g
amounts are per serving
suggested serving size is one Jan Michael Vincent per quadrant


Double-checked locking tries to initialize a field on demand and in a thread-safe manner, while avoiding the cost of synchronization.
Unfortunately it is not thread safe when used on a field that is not declared volatile
.
When using Java 1.4 or older, double-checked locking doesn't work even with a volatile
field.
See the article for an explanation of the problem.
Example:
class Foo {
private Helper helper = null
Helper getHelper() {
if (helper == null)
synchronized(this) {
if (helper == null) {
helper = new Helper()
}
}
}
return helper;
}
}


czech cemetery exhibits bridge fabricated of ultra-lightweight black concrete
by kat barandya collaboration between AOC architects and klokner institute at CTU in prague sees the fabrication of the ultra-lightweight concrete ‘bridge over the dřetovice stream.’ the project is situated across a walking trail leading to a cemetery outside the czech village of vrapice. the picturesque wildness of its natural context serves to contrast the urban atmosphere of the village. the meadowed landscape surrounding the bridge is subject to constant changes due to the floods. the design of the bridge is driven by the ethereal concept as a ‘portal between the world of the living and the dead’ and investigates the limits of its extremely lightweight and technologically advanced material.
designers at AOC architects and klokner institute at CTU in prague make use of advanced concrete casting technology in the development of the bridge over the dřetovice stream. with a ten meter span, the structure is fabricated of freeze-resistant, fiber-reinforced, ultra-high performance concrete (UHPC). the subtlety of the form together with the length of its span is overcome with a doubly-curved geometry, stabilizing the construction and easily bracing the bridge in both directions. with a cross-sectional width of 1.5 meters and a total material usage of 1.4 cubic meters, the bridge weights approximately 3.5 tons.
during the verification of the structural design and the concrete casting technology, a prototype was built and subjected to load testing. pigment was added into the concrete mixture, surface patina etched and the key details hand sanded. opposite the bridge is ‘the guardian,’ a sculpture designed by the studio of jan hendrych. among other fields, the artist is a leading expert on baroque sculpture within the context of bridges and landscapes. the sculpture is based on the original baroque archetypes and situated within the landscape to complete the entire spatial composition of the bridge.
project info:
project title: bridge over the dřetovice stream
architecture: AOC architects, klokner institute at CTU in prague
lead designers: ondřej císler (aoc architects) and petr tej (klokner institute at CTU in prague)
location: kladno, vrapice, czech republic
material: ultra-high performance concrete
client: city of kladno
sculpture: jan hendrych
casting technology: jiří kolísko
manufacturer: kš prefa
area: 19.5 square meters
completion: 2019
photography: boysplaynice