text:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cobbyhole;

/**
 *
 * @author miguel
 */
public class Consumidor extends Thread{
    private Contenedor contenedor;

    public Consumidor(Contenedor c){
        contenedor = c;
    }

    public void run(){
        int value = 0;
        for(int i = 0; i < 10; i++){
            value = contenedor.get();
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>DSite</title>
<meta name="date" content="2014-11-11">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

org.drupal.project.computing

Class DSite

java.lang.Object

org.drupal.project.computing.DSite

Direct Known Subclasses:

DDrushSite, DServicesSite

public abstract class DSite
extends java.lang.Object

This is the super class to model a Drupal site. A Drupal Computing application will use a DSite class to connect
 to Drupal sites. The suggested way to pass data between applications and Drupal site is through the DRecord objects
 (maps to a Computing Entity). You would have your Drupal module write input data to a record, and then your
 application read it and write results back to the output field in the record, and your Drupal module can read data
 back to the database.

Here we don't require DSite to offer nodeLoad(), nodeSave(), or userLoad(), which might be defined in
 DSiteExtended. If your application needs to read nodes, the Drupal part of your application will write the node info
 into the "input" field of computing_record, and then your Java application can read it. However, we don't prevent
 subclasses to provide a nodeLoad() method. If you use DDrushSite in particular, you can call any Drupal API with
 drush. Also, you can use DDatabase to access Drupal database directly, but it's not recommended.

Some sub-class implementations: DServicesSite, DDrushSite

Field Summary

Fields

Modifier and Type
Field and Description

protected java.util.logging.Logger
logger

Constructor Summary

Constructors

Constructor and Description

DSite()

Method Summary

Methods

Modifier and Type
Method and Description

boolean
checkConnection()

Check whether connection to Drupal site is established.

abstract DRecord
claimRecord(java.lang.String appName)

Get one available computing record from Drupal to process.

abstract long
createRecord(DRecord record)

Save the new record Drupal using the data in the parameter.

abstract void
finishRecord(DRecord record)

After agent finishes computation, return the results to Drupal.

abstract java.lang.String
getDrupalVersion()

abstract long
getTimestamp()

abstract DRecord
loadRecord(long id)

Load one record according to its ID.

abstract void
updateRecord(DRecord record)

Save the updated record in the database.

abstract void
updateRecordField(DRecord record,
                 java.lang.String fieldName)

Update only the specified field of the record.

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

logger

protected java.util.logging.Logger logger

Constructor Detail

DSite

public DSite()

Method Detail

claimRecord

public abstract DRecord claimRecord(java.lang.String appName)
                             throws DSiteException,
                                    DNotFoundException

Get one available computing record from Drupal to process. Drupal will handle the logic of providing the record.
 If there's no record to return, throw DNotFoundException.

Parameters:

appName - the Application name to claim a record.

Returns:

A computing record to handle, or NULL is none is found.

Throws:

DSiteException

DNotFoundException

finishRecord

public abstract void finishRecord(DRecord record)
                           throws DSiteException

After agent finishes computation, return the results to Drupal.

Parameters:

record - the record to mark as finished and send back results.

Throws:

DSiteException

updateRecord

public abstract void updateRecord(DRecord record)
                           throws DSiteException

Save the updated record in the database.

Parameters:

record - The computing record to be saved.

Throws:

DSiteException

updateRecordField

public abstract void updateRecordField(DRecord record,
                     java.lang.String fieldName)
                                throws DSiteException

Update only the specified field of the record.

Parameters:

record - The computing record to be updated.

fieldName - The field to be updated.

Throws:

DSiteException

createRecord

public abstract long createRecord(DRecord record)
                           throws DSiteException

Save the new record Drupal using the data in the parameter.

Parameters:

record - The newly created record. record.isSave() has too be true.

Returns:

The database record ID of the newly created record.

Throws:

DSiteException

loadRecord

public abstract DRecord loadRecord(long id)
                            throws DSiteException

Load one record according to its ID. This is expected to return a valid DRecord.
 If id is invalid, this function will throw an exception.

Parameters:

id - The id of computing record.

Returns:

the loaded DRecord.

Throws:

DSiteException

checkConnection

public boolean checkConnection()

Check whether connection to Drupal site is established.

Returns:

true if the connection is valid. will not throw exceptions.

getDrupalVersion

public abstract java.lang.String getDrupalVersion()
                                           throws DSiteException

Returns:

The version of Drupal for this site.

Throws:

DSiteException

getTimestamp

public abstract long getTimestamp()
                           throws DSiteException

Returns:

Drupal site's current timestamp. Equivalent to PHP time().

Throws:

DSiteException

Overview

Package

Class

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method


text:
NS_ASSUME_NONNULL_BEGIN

@class SentryScope, SentryCrashWrapper;

static NSString *const SentryDeviceContextFreeMemoryKey = @"free_memory";

@interface SentryCrashIntegration : NSObject <SentryIntegrationProtocol>

+ (void)enrichScope:(SentryScope *)scope crashWrapper:(SentryCrashWrapper *)crashWrapper;

@end

NS_ASSUME_NONNULL_END


text:
![Test perspective](https://github.com/nex3/perspective-el/actions/workflows/test-perspective.yml/badge.svg)

The Perspective package provides multiple named workspaces (or "perspectives")
in Emacs, similar to multiple desktops in window managers like Awesome and
XMonad, and Spaces on the Mac.

Each perspective has its own buffer list and its own window layout, along with
some other isolated niceties, like the
[xref](https://www.gnu.org/software/emacs/manual/html_node/emacs/Xref.html)
ring. This makes it easy to work on many separate projects without getting lost
in all the buffers. Switching to a perspective activates its window
configuration, and when in a perspective, only its buffers are available (by
default).

Each Emacs frame has a distinct list of perspectives.

Perspective supports saving its state to a file, so long-lived work sessions may
be saved and recovered as needed.

At long last this project has a
[changelog](https://github.com/nex3/perspective-el/blob/master/CHANGELOG.md);
please refer to it for release notes.

<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
- [Sample Use Cases](#sample-use-cases)
    - [Multiple Projects](#multiple-projects)
    - [Yak Shaving](#yak-shaving)
    - [Perspective Merging](#perspective-merging)
- [Similar Packages](#similar-packages)
- [Compatibility](#compatibility)
- [Installation](#installation)
- [Usage](#usage)
    - [Buffer Switchers](#buffer-switchers)
    - [Notes on `completing-read` Enhancements](#notes-on-completing-read-enhancements)
- [Saving Sessions to Disk](#saving-sessions-to-disk)
- [Customization](#customization)
- [Some Musings on Emacs Window Layouts](#some-musings-on-emacs-window-layouts)
<!-- markdown-toc end -->

## Sample Use Cases

### Multiple Projects

Working on multiple projects can become difficult to organize as their buffer
lists mix together during a long-running Emacs session. Searching for a buffer
by name works well if you know what to search for, but sometimes picking from a
list is easier — in which case, keeping the list well-pruned for relevant
buffers becomes an important source of efficiency in file and buffer management.
Perspective helps out by letting you keep separate named buffer lists and window
layouts.

This use case works really well in conjunction with
[Projectile](https://github.com/bbatsov/projectile). Projectile helps with
buffer navigation (and other project-specific tasks) in cases when a project has
a well-defined root directory. Perspective then steps in to help manage
unrelated buffers: shells, REPLs, `dired` buffers visiting directories outside
the project, or files relevant to the project not under the same root as the
rest of the source. It also helps deal with the situation of one project with
multiple source repositories where having a shared window layout or buffer list
makes sense.

### [Yak Shaving](http://catb.org/jargon/html/Y/yak-shaving.html)

Suppose you're developing feature X in perspective `feature-X`. This keeps you
working with one set of files and windows. You then realize that this feature
requires you to fix a bug in an unrelated set of files. You don't want to lose
all the context you have built up for feature X, so you open a new perspective,
`bugfix-Y`, letting you open new files and buffers without disturbing your work
on `feature-X`. Then you are asked to urgently look into something related to
development of feature Z, but again: you don't want to lose context. So you open
a new perspective `feature-Z`, and fill it with a whole bunch of new files and
windows — all without losing any of the context for your work on bug Y or
feature X.

When you finish looking at Z, you close perspective `feature-Z`, and return to
`bugfix-Y`, and restore its window layout and buffer list. When you finish with
Y, you close perspective `bugfix-Y` and return to `feature-X`.

(Hint: this workflow works best with the `persp-sort` variable set to `'created`
— see documentation below.)

### Perspective Merging

Yak shaving is useful for working on projects that are largely unrelated but
sometimes you are working on multiple projects that are very much related, to
the point that you want to view files from both projects at the same time. This
is where perspective merging comes in.

Suppose you are working on a project that requires developing multiple auxiliary
libraries. It may get messy to develop both the main project and all the
libraries from the same perspective so instead you put each library in its own
perspective so you can work on them in isolation. All of a sudden though you
wish to see library code from the main projects perspective. Instead of
switching back and forth between the library and main projects perspectives you
can run `M-x persp-merge` and import the buffers from the libraries perspective.
When you are done you can run remove the imported buffers with
`M-x persp-unmerge`.

The purpose of perspective merging is to combine the buffer lists of different
perspectives while keeping a clear distinction of which buffers belong to which
perspective.

- You can merge together as many perspectives as you want.
- Merging is one directional so if you merge A into B, B's buffers will not be
available in A.
- Merging is not transitive so if you merge A into B, then B into C, the buffers
in A will not be available in C.
- The merge state is saved across sessions when using [persp-state-{save,load}](#saving-sessions-to-disk).

## Similar Packages

The following Emacs packages implement comparable functionality:

- [persp-mode](https://github.com/Bad-ptr/persp-mode.el): A Perspective
  fork, which implements perspective sharing between Emacs frames. It also has a
  different approach to saving state and different configuration options. There
  has been some
  [interest](https://github.com/nex3/perspective-el/issues/88#issuecomment-513996542)
  [expressed](https://github.com/nex3/perspective-el/issues/111) in merging the
  two projects. _Due to conflicting function names, `persp-mode.el` and
  Perspective cannot be installed simultaneously._
- [Workgroups 2](https://github.com/pashinin/workgroups2): Similar to
  Perspective in terms of features. Its [original
  codebase](https://github.com/tlh/workgroups.el) seems to predate Emacs
  acquiring a native ability to serialize window layouts, so it has custom
  serialization code.
- [eyebrowse](https://github.com/wasamasa/eyebrowse): Supports window layouts
  but not buffer lists.
- [wconf](https://github.com/ilohmar/wconf): Supports window layouts but not
  buffer lists.
- [ElScreen](https://github.com/knu/elscreen): Supports window layouts but not
  buffer lists; seems unmaintained.
- [Burly](https://github.com/alphapapa/burly.el): An approach to persisting window and frame configurations using Emacs bookmarks.

Emacs 27 includes two new buffer and window organizing features: Tab Line
(`global-tab-line-mode`) and Tab Bar (`tab-bar-mode`).
- Tab Line maintains a list of buffers which had been opened in a given window,
  and anchors it to that window. It is analogous to tabs as used in web browsers
  and other text editors, and therefore orthogonal to Perspective.
- Tab Bar maintains window layouts (with optional names). In this, it is similar
  to Perspective. Unlike Perspective, it does not support buffer lists. Using
  Perspective and Tab Bar at the same time is not recommended at this time,
  since the tab list is global (i.e., will show up in all perspectives) and is
  likely to cause confusion. It would be an interesting future feature for
  Perspective to adopt the tab bar and allow keeping a distinct set of tabs
  per-perspective.

## Compatibility

Perspective does not work with [Emacs
`desktop.el`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Saving-Emacs-Sessions.html).
This is because Perspective state stores buffer and window information in frame
parameters, and `desktop-save-mode` does not support saving those types of data.

Instead, Perspective provides its own [disk save and
load](#saving-sessions-to-disk) feature, which cleanly saves perspectives.

## Installation

You should install Perspective from [MELPA](https://melpa.org/) or [MELPA Stable](https://stable.melpa.org/).

Users of [`use-package`](https://github.com/jwiegley/use-package) can install Perspective as follows:

```elisp
(use-package perspective
  :bind
  ("C-x C-b" . persp-list-buffers)         ; or use a nicer switcher, see below
  :custom
  (persp-mode-prefix-key (kbd "C-c M-p"))  ; pick your own prefix key here
  :init
  (persp-mode))
```

Replace the binding for `C-x C-b`, the default Emacs buffer switcher, with one
of the nicer implementations described in the [Buffer
switchers](#buffer-switchers) section.

If not using `use-package`, put `perspective.el` from this source repository
somewhere on your load path, and use something similar to this:

```elisp
(require 'perspective)
(global-set-key (kbd "C-x C-b") 'persp-list-buffers)
(customize-set-variable 'persp-mode-prefix-key (kbd "C-c M-p"))
(persp-mode)
```

Users of Debian 9 or later or Ubuntu 16.04 or later may simply `apt-get install
elpa-perspective`, though be aware that the stable version provided in these
repositories is likely to be (extremely) outdated.

## Usage

To activate Perspective, use `(persp-mode)`. This creates a single default
`main` perpsective.

> :information_source: Since the release of Emacs 28, Perspective no longer
> ships with a default command prefix. Users should pick a prefix comfortable
> for them. In the days of Emacs 27 and earlier, the default prefix was `C-x x`.
> This conflicts with bindings built into Emacs 28.

To set a prefix key for all Perspective commands, customize
`persp-mode-prefix-key`. Reasonable choices include `C-x x` (for users who don't
care about the Emacs buffer-related commands this shadows), `C-z` (for users who
don't suspend Emacs to shell background), `C-c C-p` (for users who don't mind
the conflicting keys with `org-mode` and `markdown-mode`), `C-c M-p` (for users
who don't mind the slightly awkward chord), and `H-p` (for users who don't mind
relying exclusively on a non-standard Hyper modifier).

The actual command keys (the ones pressed after the prefix) are defined in
`perspective-map`. Here are the main commands defined in `perspective-map`:

- `s` — `persp-switch`: Query a perspective to switch to, or create
- `` ` `` — `persp-switch-by-number`: Switch to perspective by number, or switch
  quickly using numbers `1, 2, 3.. 0` as prefix args; note this will probably be
  most useful with `persp-sort` set to `'created`
- `k` — `persp-remove-buffer`: Query a buffer to remove from current perspective
- `c` — `persp-kill` : Query a perspective to kill
- `r` — `persp-rename`: Rename current perspective
- `a` — `persp-add-buffer`: Query an open buffer to add to current perspective
- `A` — `persp-set-buffer`: Add buffer to current perspective and remove it from all others
- `b` - `persp-switch-to-buffer`: Like `switch-to-buffer`; includes all buffers
  from all perspectives; changes perspective if necessary
- `i` — `persp-import`: Import a given perspective from another frame.
- `n`, `<right>` — `persp-next`: Switch to next perspective
- `p`, `<left>` — `persp-prev`: Switch to previous perspective
- `m` — `persp-merge`: Temporarily merge the buffers from one perspective into another
- `u` — `persp-unmerge`: Undo the effects of a `persp-merge`
- `g` — `persp-add-buffer-to-frame-global`: Add buffer to a frame-specific "global" perspective
- `C-s` — `persp-state-save`: Save all perspectives in all frames to a file
- `C-l` — `persp-state-load`: Load all perspectives from a file

### Buffer Switchers

Since Perspective maintains distinct buffer lists for each perspective, it helps
to use a Perspective-aware buffer switcher.

When using one of the following buffer switchers, you will only be prompted for
buffers in the current perspective and the frame-specific "global" shared
perspective. (The `persp-add-buffer-to-frame-global` command adds a buffer to
this special frame-specific perspective, whose name is determined by
`persp-frame-global-perspective-name` and defaults to `GLOBAL`.)

**Ido**: [Interactive Do (Ido,
`ido-mode`)](https://www.gnu.org/software/emacs/manual/html_node/ido/index.html),
in particular its `ido-switch-buffer` command, is automatically
Perspective-aware when `persp-mode` is enabled.

**list-buffers / buffer-menu**: Perspective provides wrappers for the similar
[`list-buffers` and
`buffer-menu`](https://www.gnu.org/software/emacs/manual/html_node/emacs/List-Buffers.html):
`persp-list-buffers` and `persp-buffer-menu`. (Note that Emacs binds `C-x C-b`
to `list-buffers` by default.) When these functions are called normally, they
show the buffer menu filtered by the current perspective. With a prefix
argument, they show the buffer menu of all the buffers in all perspectives. (The
difference between `list-buffers` and `buffer-menu`: the former calls
`display-buffer`, i.e., may split windows depending on `display-buffer-alist`,
and the latter calls `switch-to-buffer`, i.e., flips the current window to the
buffer list buffer.)

**`bs.el`**: Perspective provides a wrapper for
[`bs-show`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Buffer-Menus.html):
`persp-bs-show`. When this function is called normally, it shows a list of
buffers filtered by the current perspective. With a prefix argument, it shows a
list of buffers in all perspectives.

**IBuffer**: Perspective provides a wrapper for
[`ibuffer`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Buffer-Menus.html):
`persp-ibuffer`. When this function is called normally, it shows a list of
buffers filtered by the current perspective. With a prefix argument, it shows a
list of buffers in all perspectives.

If you want to group buffers by persp-name in ibuffer buffer, use
`persp-ibuffer-set-filter-groups`. Or, make it the default:
```
(add-hook 'ibuffer-hook
          (lambda ()
            (persp-ibuffer-set-filter-groups)
            (unless (eq ibuffer-sorting-mode 'alphabetic)
              (ibuffer-do-sort-by-alphabetic))))
```

**Helm**: Perspective ships with buffer-listing advice for Helm, so Helm's
buffer listing code should be automatically Perspective-aware when `persp-mode`
is enabled. (Older versions of Helm relied on the machinery of `ido-mode` for
listing buffers, so they did not require this advice; see [`this Helm
commit`](https://github.com/emacs-helm/helm/commit/f7fa3a9e0ef1f69c42e0c513d02c9f76ea9a4344)
and [`this Perspective
commit`](https://github.com/nex3/perspective-el/commit/c2d3542418967b55f05d5b5ba71c9fbfe4cd3d4f)
for details.) If `helm-buffers-list` is called with a prefix argument, it will
show buffers in all perspectives. In addition, Perspective adds actions to
`helm-buffers-list` to add buffers to the current perspective (mainly relevant
to the prefix-argument version) and to remove buffers from the current
perspective.

**Consult**: Perspective provides `persp-consult-source` source that will list
buffers in current perspective. You can hide default buffer source
and add `persp-consult-source` to `consult-buffer-sources` for consult
to only list buffers in current perspective like so:

```emacs-lisp
(consult-customize consult--source-buffer :hidden t :default nil)
(add-to-list 'consult-buffer-sources persp-consult-source)
```
Note that you can still access list of all buffers in all perspectives by
[narrowing](https://github.com/minad/consult#narrowing-and-grouping)
using prefix `b`.

**Ivy / Counsel**: Perspective provides two commands for listing buffers using
Ivy and Counsel: `persp-ivy-switch-buffer` and `persp-counsel-switch-buffer`.
When these functions are called normally, they show a list of buffers filtered
by the current perspective. With a prefix argument, they shows a list of buffers
in all perspectives. The distinction between the `ivy` and `counsel` versions is
the same as between `ivy-switch-buffer` and `counsel-switch-buffer`: the latter
shows a preview of the buffer to switch to, and the former does not.

It is a good idea to bind one these helper functions with the `:bind` form of
`use-package`. Or, if you do not use `use-package`, it can also be bound
globally, e.g.:

```emacs-lisp
(global-set-key (kbd "C-x C-b") (lambda (arg)
                                  (interactive "P")
                                  (if (fboundp 'persp-bs-show)
                                      (persp-bs-show arg)
                                    (bs-show "all"))))
```

### Notes on `completing-read` Enhancements

Users of a `completing-read` enhancement framework (such as Ivy,
[Selectrum](https://github.com/raxod502/selectrum), or
[Vertico](https://github.com/minad/vertico)) may wish to use the following two
functions:
- `persp-switch-to-buffer*` replaces `switch-to-buffer`
- `persp-kill-buffer*` replaces `kill-buffer`

Both these functions behave like the built-ins, but use `completing-read`
directly. When called normally, they list buffers filtered by the current
perspective. With a prefix argument, they list buffers in all perspectives.

The following sample `use-package` invocation changes Emacs default key bindings
to use the replacements:

```
(use-package perspective
  :bind (("C-x b" . persp-switch-to-buffer*)
         ("C-x k" . persp-kill-buffer*))
  :config
  (persp-mode))
```

## Saving Sessions to Disk

A pair of functions, `persp-state-save` and `persp-state-load`, implement
perspective durability on disk. When called interactively, they prompt for files
to save sessions to and restore from.

A custom variable, `persp-state-default-file`, sets a default file to use for
saving and restoring perspectives. When it is set, `persp-state-save` may be
called non-interactively without an argument and it will save to the file
referenced by that variable. This makes it easy to automatically save
perspective sessions when Emacs exits:

```
(add-hook 'kill-emacs-hook #'persp-state-save)
```

A limitation of `persp-state-save` and `persp-state-load` is that they do not
attempt to deal with non-file-visiting buffers with non-trivial state. Saving
shell, REPL, and `compilation-mode` buffers is not supported. When saved to a
file, any windows pointing to them are changed to point to the perspective's
`*scratch*` buffer. (Live windows are, of course, left alone.)

## Customization

Perspective supports several custom variables (see its section in `M-x
customize`). The following are likely to be of most interest:

- `persp-sort`: Select the order in which to sort perspectives when calling
  `persp-switch`. Defaults to `'name` (alphabetical), but `'access` (by most
  recently accessed) and `'created` (by order created) are available. Note that
  `persp-switch-by-number` is likely to be confusing when this is set to
  `'access`, as the numbers associated with a perspective will change all the time.
- `persp-interactive-completion-function`: Used for prompting for a perspective
  name. `completing-read` is the default, with `ido-completing-read` enabled
  with `ido-mode`. `ivy-completing-read` is broadly compatible, but
  unfortunately sorts alphabetically and therefore breaks the `persp-sort`
  setting. Helm, unfortunately, does not have a `completing-read` compatible
  implementation out of the box (`helm-completing-read-default-1` purports to be
  this but does not have the same `&optional` defaults). _`ido-completing-read`
  is the recommended setting here unless a `completing-read` enhancement
  framework is used._
- `persp-mode-prefix-key`: Changes the default key prefix for Perspective
  commands.
- `persp-state-default-file`: Changes the default file to use for saving and
  loading Perspective state.
- `persp-show-modestring`: Determines if Perspective should show its status in
  the modeline. It defaults to `t`, but can also be `nil` (turning off the
  modeline status display) or `'header` (which uses the header line instead of
  the modeline).
- `persp-modestring-short`: When set to `t`, show a shortened modeline string
  with only the current perspective instead of the full list. Defaults to `nil`.
- `persp-purge-initial-persp-on-save`: When set to `t`, will kill all buffers
  of the initial perspective upon calling `perps-state-save`. The buffers whose name
  match a regexp in the list `persp-purge-initial-persp-on-save-exceptions` won't
  get killed. This allows using the initial perspective as a kind of scratch space.

To change keys used after the prefix key, with `use-package` you can do:

    ;; remap n to N to switch to next perspective
    (use-package perspective
      :bind (
        :map perspective-map
          ("n" . nil)
          ("N" . persp-next)))

Or without `use-package`:

    (define-key perspective-map (kbd "n") nil)
    (define-key perspective-map (kbd "N") 'persp-next)

## Some Musings on Emacs Window Layouts

The following discussion exceeds the needs of documenting Perspective, but it
falls in the category of helping users learn to manage Emacs sessions, and
therefore will likely help potential users of Perspective make the experience
smoother.

Emacs has bad default behavior when it comes to window handling: many commands
and modes have a habit of splitting existing windows and changing the user's
carefully thought-out window layout. This tends to be a more serious problem for
people who run Emacs on large displays (possibly in full-screen mode): the
greater amount of screen real estate makes it easy to split the frame into many
smaller windows, making any unexpected alterations more disruptive.

As a result of indiscriminate-seeming window splits and buffer switching in
existing windows, new Emacs users can get into the habit of expecting Emacs and
its packages to lack basic respect for their layouts. Hence the popularity of
things like `winner-mode`, and packages like
[shackle](https://github.com/wasamasa/shackle).

This may make the value of Perspective seem questionable: why bother with
carefully preserving window layouts if Emacs just throws them away on a `M-x
compile`? The answer is to fix the broken defaults. This is fairly easy:

```emacs-lisp
(customize-set-variable 'display-buffer-base-action
  '((display-buffer-reuse-window display-buffer-same-window)
    (reusable-frames . t)))

(customize-set-variable 'even-window-sizes nil)     ; avoid resizing
```

These settings do the following:

1. Tell `display-buffer` to reuse existing windows as much as possible,
   including in other frames. For example, if there is already a `*compilation*`
   buffer in a visible window, switch to that window. This means that Emacs will
   usually switch windows in a "do what I mean" manner for a warmed-up workflow
   (one with, say, a couple of source windows, a compilation output window, and
   a Magit window).
2. Prevent splits by telling `display-buffer` to switch to the target buffer in
   the _current_ window. For example, if there is no `*compilation*` buffer
   visible, then the buffer in whichever window was current when `compile` was
   run will be replaced with `*compilation*`. This may seem intrusive, since it
   changes out the current buffer, but keep in mind that most buffers popped up
   in this manner are easy to dismiss, either with a dedicated keybinding (often
   `q`) or the universally-applicable `kill-buffer`. This is easier than
   restoring window arrangements. It is also easier to handle for pre-arranged
   window layouts, since the appropriate command can simply be run in a window
   prepared for it in advance. (If this is a step too far, then replace
   `display-buffer-same-window` with `display-buffer-pop-up-window`.)

(An earlier version of this hint modified `display-buffer-alist` instead of
`display-buffer-base-action`. This was [too
aggressive](https://debbugs.gnu.org/cgi/bugreport.cgi?bug=49069#25) and can
impact packages which may legitimately want to split windows.)

[Documentation of the Emacs framework responsible for "pop-up" windows,
`display-buffer`](https://www.gnu.org/software/emacs/manual/html_node/elisp/Displaying-Buffers.html#Displaying-Buffers),
is dense and difficult to read, so there have been attempts to summarize the
most important bits:

- https://ess.r-project.org/Manual/ess.html#Controlling-buffer-display
- https://old.reddit.com/r/emacs/comments/cpdr6m/any_additional_docstutorials_on_displaybuffer_and/ews94n1/
- https://www.masteringemacs.org/article/demystifying-emacs-window-manager


text:
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import { list as babelHelpersList } from 'babel-helpers';

export default {
	input: 'index.js',
	name: 'codeErrorFragment',
	output: {
		file: 'build.js',
		format: 'umd'
	},
	plugins: [
		commonjs(),
		resolve(),
		babel({
			exclude: 'node_modules/**',
			presets: [
				['es2015', {
					modules: false
				}],
				'stage-3'
			],
			plugins: [
				'external-helpers',
				'transform-object-assign'
			],
			// fixing temporary rollup's regression, remove when https://github.com/rollup/rollup/issues/1595 gets solved
			externalHelpersWhitelist: babelHelpersList.filter(helperName => helperName !== 'asyncGenerator'),
		})
	],
	watch: {
		include: '*.js',
		exclude: 'node_modules/**'
	}
}


text:
from __future__ import absolute_import, print_function, unicode_literals
from builtins import dict, str
import pickle
from indra.databases import relevance_client
from indra.assemblers.pysb import PysbAssembler

def get_subnetwork(statements, nodes, relevance_network=None,
                   relevance_node_lim=10):
    """Return a PySB model based on a subset of given INDRA Statements.

    Statements are first filtered for nodes in the given list and other nodes
    are optionally added based on relevance in a given network. The filtered
    statements are then assembled into an executable model using INDRA's
    PySB Assembler.

    Parameters
    ----------
    statements : list[indra.statements.Statement]
        A list of INDRA Statements to extract a subnetwork from.
    nodes : list[str]
        The names of the nodes to extract the subnetwork for.
    relevance_network : Optional[str]
        The UUID of the NDEx network in which nodes relevant to the given
        nodes are found.
    relevance_node_lim : Optional[int]
        The maximal number of additional nodes to add to the subnetwork
        based on relevance.

    Returns
    -------
    model : pysb.Model
        A PySB model object assembled using INDRA's PySB Assembler from
        the INDRA Statements corresponding to the subnetwork.
    """
    if relevance_network is not None:
        relevant_nodes = _find_relevant_nodes(nodes, relevance_network,
                                              relevance_node_lim)
        all_nodes = nodes + relevant_nodes
    else:
        all_nodes = nodes
    filtered_statements = _filter_statements(statements, all_nodes)
    pa = PysbAssembler()
    pa.add_statements(filtered_statements)
    model = pa.make_model()
    return model

def _filter_statements(statements, agents):
    """Return INDRA Statements which have Agents in the given list.

    Only statements are returned in which all appearing Agents as in the
    agents list.

    Parameters
    ----------
    statements : list[indra.statements.Statement]
        A list of INDRA Statements to filter.
    agents : list[str]
        A list of agent names that need to appear in filtered statements.

    Returns
    -------
    filtered_statements : list[indra.statements.Statement]
        The list of filtered INDRA Statements.
    """
    filtered_statements = []
    for s in stmts:
        if all([a is not None for a in s.agent_list()]) and \
            all([a.name in agents for a in s.agent_list()]):
            filtered_statements.append(s)
    return filtered_statements

def _find_relevant_nodes(query_nodes, relevance_network, relevance_node_lim):
    """Return a list of nodes that are relevant for the query.

    Parameters
    ----------
    query_nodes : list[str]
        A list of node names to query for.
    relevance_network : str
        The UUID of the NDEx network to query relevance in.
    relevance_node_lim : int
        The number of top relevant nodes to return.

    Returns
    -------
    nodes : list[str]
        A list of node names that are relevant for the query.
    """
    all_nodes = relevance_client.get_relevant_nodes(relevance_network,
                                                    query_nodes)
    nodes = [n[0] for n in all_nodes[:relevance_node_lim]]
    return nodes

if __name__ == '__main__':
    genes = ['EGF', 'EGFR', 'ERBB2', 'GRB2', 'SOS1', 'HRAS', 'RAF1',
            'MAP2K1', 'MAPK1']

    with open('models/rasmachine/rem/model.pkl', 'rb') as f:
        model = pickle.load(f)
    stmts = []
    for k, v in model.items():
        stmts += v

    rasmachine_network = '50e3dff7-133e-11e6-a039-06603eb7f303'
    model = get_subnetwork(stmts, genes, rasmachine_network)


text:
package proto

import (
	"bufio"
	"github.com/coraldane/logger"
	"github.com/coraldane/toolkits/encode"
	"net"
	"time"
)

// TcpSession represent a user connection's context
type TcpSession struct {
	Conn               *net.TCPConn // socket
	BR                 *bufio.Reader
	GmtConnect         time.Time
	RemoteAddr         string
	UniqueKey          string
	ConnectionListener Connection
	userId             int64
	hasClosed          bool
}

func NewTcpSession(conn *net.TCPConn, connListener Connection) *TcpSession {
	inst := &TcpSession{}
	inst.Conn = conn
	inst.BR = bufio.NewReader(conn)
	inst.GmtConnect = time.Now()
	inst.RemoteAddr = conn.RemoteAddr().String()
	inst.UniqueKey = encode.GetUUID()

	inst.ConnectionListener = connListener

	if nil != connListener {
		inst.ConnectionListener.OnConnected(inst)
		if _, ok := connListener.(AuthConnection); ok {
			//15秒内如果用户不登陆,则将连接断开
			time.AfterFunc(time.Duration(15)*time.Second, inst.CheckIfLogined)
		}
	}
	return inst
}

func (this *TcpSession) SetUserId(userId int64) {
	this.userId = userId
}

func (this *TcpSession) GetUserId() int64 {
	return this.userId
}

func (this *TcpSession) CheckIfLogined() {
	if this.hasClosed || 0 < this.userId || nil == this.ConnectionListener {
		return
	}
	this.CloseSafely()
}

func (this *TcpSession) IsClosed() bool {
	return this.hasClosed
}

// return false will close the conn
func (this *TcpSession) Read() *Message {
	this.Conn.SetReadDeadline(time.Now().Add(time.Minute))
	defer this.Conn.SetReadDeadline(time.Time{})

	msg := &Message{}
	err := msg.Decode(this.BR)
	if nil != err {
		return nil
	}
	return msg
}

// when write data error, close the connection
func (this *TcpSession) Write(msg *Message) error {
	this.Conn.SetWriteDeadline(time.Now().Add(time.Minute))
	defer this.Conn.SetWriteDeadline(time.Time{})

	msg.Length = len(msg.Body)

	if PING != msg.Cmd {
		logger.Debug("write userId: %d, head: %v, body: %s", this.userId, msg.MsgHead, string(msg.Body))
	}

	data := msg.Encode()

	var err error
	for i := 0; i < 3; i++ { //最多重试3次
		_, err = this.Conn.Write(data)
		if nil == err {
			return err
		}
		time.Sleep(100 * time.Millisecond)
	}

	logger.Error("error: %v", err)
	return err
}

func (this *TcpSession) WriteError(msg *Message, body string) error {
	msg.Body = []byte(body)
	msg.Cmd = uint8(ERR)
	return this.Write(msg)
}

func (this *TcpSession) Close() {
	if this.hasClosed {
		return
	}
	this.hasClosed = true

	// net.Conn可以多次关闭
	this.Conn.Close()

	if nil != this.ConnectionListener {
		this.ConnectionListener.OnDisconnected(this)
	}
}

func (this *TcpSession) CloseSafely() {
	if this.hasClosed {
		return
	}

	msg := NewMessage()
	msg.Cmd = CLOSE
	msg.MsgId = encode.Md5Hex(encode.GetUUID())
	this.Write(msg)

	this.hasClosed = true
	if nil != this.ConnectionListener {
		this.ConnectionListener.OnDisconnected(this)
	}

	//1秒后再关闭连接
	time.AfterFunc(time.Second, func() {
		// net.Conn可以多次关闭
		this.Conn.Close()
	})
}


text:
<chapter xmlns="http://docbook.org/ns/docbook"  xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="sec-installation">
  <title>Installing NixOS</title>
  <section xml:id="sec-installation-booting">
    <title>Booting from the install medium</title>
    <para>
      To begin the installation, you have to boot your computer from the
      install drive.
    </para>
    <orderedlist numeration="arabic">
      <listitem>
        <para>
          Plug in the install drive. Then turn on or restart your
          computer.
        </para>
      </listitem>
      <listitem>
        <para>
          Open the boot menu by pressing the appropriate key, which is
          usually shown on the display on early boot. Select the USB
          flash drive (the option usually contains the word
          <quote>USB</quote>). If you choose the incorrect drive, your
          computer will likely continue to boot as normal. In that case
          restart your computer and pick a different drive.
        </para>
        <note>
          <para>
            The key to open the boot menu is different across computer
            brands and even models. It can be <keycap>F12</keycap>, but
            also <keycap>F1</keycap>, <keycap>F9</keycap>,
            <keycap>F10</keycap>, <keycap>Enter</keycap>,
            <keycap>Del</keycap>, <keycap>Esc</keycap> or another
            function key. If you are unsure and don't see it on the
            early boot screen, you can search online for your computers
            brand, model followed by <quote>boot from usb</quote>. The
            computer might not even have that feature, so you have to go
            into the BIOS/UEFI settings to change the boot order. Again,
            search online for details about your specific computer
            model.
          </para>
          <para>
            For Apple computers with Intel processors press and hold the
            <keycap>⌥</keycap> (Option or Alt) key until you see the
            boot menu. On Apple silicon press and hold the power button.
          </para>
        </note>
        <note>
          <para>
            If your computer supports both BIOS and UEFI boot, choose
            the UEFI option.
          </para>
        </note>
        <note>
          <para>
            If you use a CD for the installation, the computer will
            probably boot from it automatically. If not, choose the
            option containing the word <quote>CD</quote> from the boot
            menu.
          </para>
        </note>
      </listitem>
      <listitem>
        <para>
          Shortly after selecting the appropriate boot drive, you should
          be presented with a menu with different installer options.
          Leave the default and wait (or press <keycap>Enter</keycap> to
          speed up).
        </para>
      </listitem>
      <listitem>
        <para>
          The graphical images will start their corresponding desktop
          environment and the graphical installer, which can take some
          time. The minimal images will boot to a command line. You have
          to follow the instructions in
          <xref linkend="sec-installation-manual" /> there.
        </para>
      </listitem>
    </orderedlist>
  </section>
  <section xml:id="sec-installation-graphical">
    <title>Graphical Installation</title>
    <para>
      The graphical installer is recommended for desktop users and will
      guide you through the installation.
    </para>
    <orderedlist numeration="arabic">
      <listitem>
        <para>
          In the <quote>Welcome</quote> screen, you can select the
          language of the Installer and the installed system.
        </para>
        <tip>
          <para>
            Leaving the language as <quote>American English</quote> will
            make it easier to search for error messages in a search
            engine or to report an issue.
          </para>
        </tip>
      </listitem>
      <listitem>
        <para>
          Next you should choose your location to have the timezone set
          correctly. You can actually click on the map!
        </para>
        <note>
          <para>
            The installer will use an online service to guess your
            location based on your public IP address.
          </para>
        </note>
      </listitem>
      <listitem>
        <para>
          Then you can select the keyboard layout. The default keyboard
          model should work well with most desktop keyboards. If you
          have a special keyboard or notebook, your model might be in
          the list. Select the language you are most comfortable typing
          in.
        </para>
      </listitem>
      <listitem>
        <para>
          On the <quote>Users</quote> screen, you have to type in your
          display name, login name and password. You can also enable an
          option to automatically login to the desktop.
        </para>
      </listitem>
      <listitem>
        <para>
          Then you have the option to choose a desktop environment. If
          you want to create a custom setup with a window manager, you
          can select <quote>No desktop</quote>.
        </para>
        <tip>
          <para>
            If you don't have a favorite desktop and don't know which
            one to choose, you can stick to either GNOME or Plasma. They
            have a quite different design, so you should choose
            whichever you like better. They are both popular choices and
            well tested on NixOS.
          </para>
        </tip>
      </listitem>
      <listitem>
        <para>
          You have the option to allow unfree software in the next
          screen.
        </para>
      </listitem>
      <listitem>
        <para>
          The easiest option in the <quote>Partitioning</quote> screen
          is <quote>Erase disk</quote>, which will delete all data from
          the selected disk and install the system on it. Also select
          <quote>Swap (with Hibernation)</quote> in the dropdown below
          it. You have the option to encrypt the whole disk with LUKS.
        </para>
        <note>
          <para>
            At the top left you see if the Installer was booted with
            BIOS or UEFI. If you know your system supports UEFI and it
            shows <quote>BIOS</quote>, reboot with the correct option.
          </para>
        </note>
        <warning>
          <para>
            Make sure you have selected the correct disk at the top and
            that no valuable data is still on the disk! It will be
            deleted when formatting the disk.
          </para>
        </warning>
      </listitem>
      <listitem>
        <para>
          Check the choices you made in the <quote>Summary</quote> and
          click <quote>Install</quote>.
        </para>
        <note>
          <para>
            The installation takes about 15 minutes. The time varies
            based on the selected desktop environment, internet
            connection speed and disk write speed.
          </para>
        </note>
      </listitem>
      <listitem>
        <para>
          When the install is complete, remove the USB flash drive and
          reboot into your new system!
        </para>
      </listitem>
    </orderedlist>
  </section>
  <section xml:id="sec-installation-manual">
    <title>Manual Installation</title>
    <para>
      NixOS can be installed on BIOS or UEFI systems. The procedure for
      a UEFI installation is broadly the same as for a BIOS
      installation. The differences are mentioned in the following
      steps.
    </para>
    <para>
      The NixOS manual is available by running
      <literal>nixos-help</literal> in the command line or from the
      application menu in the desktop environment.
    </para>
    <para>
      To have access to the command line on the graphical images, open
      Terminal (GNOME) or Konsole (Plasma) from the application menu.
    </para>
    <para>
      You are logged-in automatically as <literal>nixos</literal>. The
      <literal>nixos</literal> user account has an empty password so you
      can use <literal>sudo</literal> without a password:
    </para>
    <programlisting>
$ sudo -i
</programlisting>
    <para>
      You can use <literal>loadkeys</literal> to switch to your
      preferred keyboard layout. (We even provide neo2 via
      <literal>loadkeys de neo</literal>!)
    </para>
    <para>
      If the text is too small to be legible, try
      <literal>setfont ter-v32n</literal> to increase the font size.
    </para>
    <para>
      To install over a serial port connect with
      <literal>115200n8</literal> (e.g.
      <literal>picocom -b 115200 /dev/ttyUSB0</literal>). When the
      bootloader lists boot entries, select the serial console boot
      entry.
    </para>
    <section xml:id="sec-installation-manual-networking">
      <title>Networking in the installer</title>
      <para>
        <anchor xml:id="sec-installation-booting-networking" />
        <!-- legacy anchor -->
      </para>
      <para>
        The boot process should have brought up networking (check
        <literal>ip a</literal>). Networking is necessary for the
        installer, since it will download lots of stuff (such as source
        tarballs or Nixpkgs channel binaries). It's best if you have a
        DHCP server on your network. Otherwise configure networking
        manually using <literal>ifconfig</literal>.
      </para>
      <para>
        On the graphical installer, you can configure the network, wifi
        included, through NetworkManager. Using the
        <literal>nmtui</literal> program, you can do so even in a
        non-graphical session. If you prefer to configure the network
        manually, disable NetworkManager with
        <literal>systemctl stop NetworkManager</literal>.
      </para>
      <para>
        On the minimal installer, NetworkManager is not available, so
        configuration must be perfomed manually. To configure the wifi,
        first start wpa_supplicant with
        <literal>sudo systemctl start wpa_supplicant</literal>, then run
        <literal>wpa_cli</literal>. For most home networks, you need to
        type in the following commands:
      </para>
      <programlisting>
> add_network
0
> set_network 0 ssid "myhomenetwork"
OK
> set_network 0 psk "mypassword"
OK
> set_network 0 key_mgmt WPA-PSK
OK
> enable_network 0
OK
</programlisting>
      <para>
        For enterprise networks, for example
        <emphasis>eduroam</emphasis>, instead do:
      </para>
      <programlisting>
> add_network
0
> set_network 0 ssid "eduroam"
OK
> set_network 0 identity "myname@example.com"
OK
> set_network 0 password "mypassword"
OK
> set_network 0 key_mgmt WPA-EAP
OK
> enable_network 0
OK
</programlisting>
      <para>
        When successfully connected, you should see a line such as this
        one
      </para>
      <programlisting>
<3>CTRL-EVENT-CONNECTED - Connection to 32:85:ab:ef:24:5c completed [id=0 id_str=]
</programlisting>
      <para>
        you can now leave <literal>wpa_cli</literal> by typing
        <literal>quit</literal>.
      </para>
      <para>
        If you would like to continue the installation from a different
        machine you can use activated SSH daemon. You need to copy your
        ssh key to either
        <literal>/home/nixos/.ssh/authorized_keys</literal> or
        <literal>/root/.ssh/authorized_keys</literal> (Tip: For
        installers with a modifiable filesystem such as the sd-card
        installer image a key can be manually placed by mounting the
        image on a different machine). Alternatively you must set a
        password for either <literal>root</literal> or
        <literal>nixos</literal> with <literal>passwd</literal> to be
        able to login.
      </para>
    </section>
    <section xml:id="sec-installation-manual-partitioning">
      <title>Partitioning and formatting</title>
      <para>
        <anchor xml:id="sec-installation-partitioning" />
        <!-- legacy anchor -->
      </para>
      <para>
        The NixOS installer doesn't do any partitioning or formatting,
        so you need to do that yourself.
      </para>
      <para>
        The NixOS installer ships with multiple partitioning tools. The
        examples below use <literal>parted</literal>, but also provides
        <literal>fdisk</literal>, <literal>gdisk</literal>,
        <literal>cfdisk</literal>, and <literal>cgdisk</literal>.
      </para>
      <para>
        The recommended partition scheme differs depending if the
        computer uses <emphasis>Legacy Boot</emphasis> or
        <emphasis>UEFI</emphasis>.
      </para>
      <section xml:id="sec-installation-manual-partitioning-UEFI">
        <title>UEFI (GPT)</title>
        <para>
          <anchor xml:id="sec-installation-partitioning-UEFI" />
          <!-- legacy anchor -->
        </para>
        <para>
          Here's an example partition scheme for UEFI, using
          <literal>/dev/sda</literal> as the device.
        </para>
        <note>
          <para>
            You can safely ignore <literal>parted</literal>'s
            informational message about needing to update /etc/fstab.
          </para>
        </note>
        <orderedlist numeration="arabic">
          <listitem>
            <para>
              Create a <emphasis>GPT</emphasis> partition table.
            </para>
            <programlisting>
# parted /dev/sda -- mklabel gpt
</programlisting>
          </listitem>
          <listitem>
            <para>
              Add the <emphasis>root</emphasis> partition. This will
              fill the disk except for the end part, where the swap will
              live, and the space left in front (512MiB) which will be
              used by the boot partition.
            </para>
            <programlisting>
# parted /dev/sda -- mkpart primary 512MB -8GB
</programlisting>
          </listitem>
          <listitem>
            <para>
              Next, add a <emphasis>swap</emphasis> partition. The size
              required will vary according to needs, here a 8GB one is
              created.
            </para>
            <programlisting>
# parted /dev/sda -- mkpart primary linux-swap -8GB 100%
</programlisting>
            <note>
              <para>
                The swap partition size rules are no different than for
                other Linux distributions.
              </para>
            </note>
          </listitem>
          <listitem>
            <para>
              Finally, the <emphasis>boot</emphasis> partition. NixOS by
              default uses the ESP (EFI system partition) as its
              <emphasis>/boot</emphasis> partition. It uses the
              initially reserved 512MiB at the start of the disk.
            </para>
            <programlisting>
# parted /dev/sda -- mkpart ESP fat32 1MB 512MB
# parted /dev/sda -- set 3 esp on
</programlisting>
          </listitem>
        </orderedlist>
        <para>
          Once complete, you can follow with
          <xref linkend="sec-installation-manual-partitioning-formatting" />.
        </para>
      </section>
      <section xml:id="sec-installation-manual-partitioning-MBR">
        <title>Legacy Boot (MBR)</title>
        <para>
          <anchor xml:id="sec-installation-partitioning-MBR" />
          <!-- legacy anchor -->
        </para>
        <para>
          Here's an example partition scheme for Legacy Boot, using
          <literal>/dev/sda</literal> as the device.
        </para>
        <note>
          <para>
            You can safely ignore <literal>parted</literal>'s
            informational message about needing to update /etc/fstab.
          </para>
        </note>
        <orderedlist numeration="arabic">
          <listitem>
            <para>
              Create a <emphasis>MBR</emphasis> partition table.
            </para>
            <programlisting>
# parted /dev/sda -- mklabel msdos
</programlisting>
          </listitem>
          <listitem>
            <para>
              Add the <emphasis>root</emphasis> partition. This will
              fill the the disk except for the end part, where the swap
              will live.
            </para>
            <programlisting>
# parted /dev/sda -- mkpart primary 1MB -8GB
</programlisting>
          </listitem>
          <listitem>
            <para>
              Set the root partition's boot flag to on. This allows the
              disk to be booted from.
            </para>
            <programlisting>
# parted /dev/sda -- set 1 boot on
</programlisting>
          </listitem>
          <listitem>
            <para>
              Finally, add a <emphasis>swap</emphasis> partition. The
              size required will vary according to needs, here a 8GB one
              is created.
            </para>
            <programlisting>
# parted /dev/sda -- mkpart primary linux-swap -8GB 100%
</programlisting>
            <note>
              <para>
                The swap partition size rules are no different than for
                other Linux distributions.
              </para>
            </note>
          </listitem>
        </orderedlist>
        <para>
          Once complete, you can follow with
          <xref linkend="sec-installation-manual-partitioning-formatting" />.
        </para>
      </section>
      <section xml:id="sec-installation-manual-partitioning-formatting">
        <title>Formatting</title>
        <para>
          <anchor xml:id="sec-installation-partitioning-formatting" />
          <!-- legacy anchor -->
        </para>
        <para>
          Use the following commands:
        </para>
        <itemizedlist>
          <listitem>
            <para>
              For initialising Ext4 partitions:
              <literal>mkfs.ext4</literal>. It is recommended that you
              assign a unique symbolic label to the file system using
              the option <literal>-L label</literal>, since this makes
              the file system configuration independent from device
              changes. For example:
            </para>
            <programlisting>
# mkfs.ext4 -L nixos /dev/sda1
</programlisting>
          </listitem>
          <listitem>
            <para>
              For creating swap partitions: <literal>mkswap</literal>.
              Again it's recommended to assign a label to the swap
              partition: <literal>-L label</literal>. For example:
            </para>
            <programlisting>
# mkswap -L swap /dev/sda2
</programlisting>
          </listitem>
          <listitem>
            <para>
              <emphasis role="strong">UEFI systems</emphasis>
            </para>
            <para>
              For creating boot partitions: <literal>mkfs.fat</literal>.
              Again it's recommended to assign a label to the boot
              partition: <literal>-n label</literal>. For example:
            </para>
            <programlisting>
# mkfs.fat -F 32 -n boot /dev/sda3
</programlisting>
          </listitem>
          <listitem>
            <para>
              For creating LVM volumes, the LVM commands, e.g.,
              <literal>pvcreate</literal>, <literal>vgcreate</literal>,
              and <literal>lvcreate</literal>.
            </para>
          </listitem>
          <listitem>
            <para>
              For creating software RAID devices, use
              <literal>mdadm</literal>.
            </para>
          </listitem>
        </itemizedlist>
      </section>
    </section>
    <section xml:id="sec-installation-manual-installing">
      <title>Installing</title>
      <para>
        <anchor xml:id="sec-installation-installing" />
        <!-- legacy anchor -->
      </para>
      <orderedlist numeration="arabic">
        <listitem>
          <para>
            Mount the target file system on which NixOS should be
            installed on <literal>/mnt</literal>, e.g.
          </para>
          <programlisting>
# mount /dev/disk/by-label/nixos /mnt
</programlisting>
        </listitem>
        <listitem>
          <para>
            <emphasis role="strong">UEFI systems</emphasis>
          </para>
          <para>
            Mount the boot file system on <literal>/mnt/boot</literal>,
            e.g.
          </para>
          <programlisting>
# mkdir -p /mnt/boot
# mount /dev/disk/by-label/boot /mnt/boot
</programlisting>
        </listitem>
        <listitem>
          <para>
            If your machine has a limited amount of memory, you may want
            to activate swap devices now
            (<literal>swapon device</literal>). The installer (or
            rather, the build actions that it may spawn) may need quite
            a bit of RAM, depending on your configuration.
          </para>
          <programlisting>
# swapon /dev/sda2
</programlisting>
        </listitem>
        <listitem>
          <para>
            You now need to create a file
            <literal>/mnt/etc/nixos/configuration.nix</literal> that
            specifies the intended configuration of the system. This is
            because NixOS has a <emphasis>declarative</emphasis>
            configuration model: you create or edit a description of the
            desired configuration of your system, and then NixOS takes
            care of making it happen. The syntax of the NixOS
            configuration file is described in
            <xref linkend="sec-configuration-syntax" />, while a list of
            available configuration options appears in
            <xref linkend="ch-options" />. A minimal example is shown in
            <link linkend="ex-config">Example: NixOS
            Configuration</link>.
          </para>
          <para>
            The command <literal>nixos-generate-config</literal> can
            generate an initial configuration file for you:
          </para>
          <programlisting>
# nixos-generate-config --root /mnt
</programlisting>
          <para>
            You should then edit
            <literal>/mnt/etc/nixos/configuration.nix</literal> to suit
            your needs:
          </para>
          <programlisting>
# nano /mnt/etc/nixos/configuration.nix
</programlisting>
          <para>
            If you're using the graphical ISO image, other editors may
            be available (such as <literal>vim</literal>). If you have
            network access, you can also install other editors – for
            instance, you can install Emacs by running
            <literal>nix-env -f '<nixpkgs>' -iA emacs</literal>.
          </para>
          <variablelist>
            <varlistentry>
              <term>
                BIOS systems
              </term>
              <listitem>
                <para>
                  You <emphasis>must</emphasis> set the option
                  <xref linkend="opt-boot.loader.grub.device" /> to
                  specify on which disk the GRUB boot loader is to be
                  installed. Without it, NixOS cannot boot.
                </para>
                <para>
                  If there are other operating systems running on the
                  machine before installing NixOS, the
                  <xref linkend="opt-boot.loader.grub.useOSProber" />
                  option can be set to <literal>true</literal> to
                  automatically add them to the grub menu.
                </para>
              </listitem>
            </varlistentry>
            <varlistentry>
              <term>
                UEFI systems
              </term>
              <listitem>
                <para>
                  You must select a boot-loader, either system-boot or
                  GRUB. The recommended option is systemd-boot: set the
                  option
                  <xref linkend="opt-boot.loader.systemd-boot.enable" />
                  to <literal>true</literal>.
                  <literal>nixos-generate-config</literal> should do
                  this automatically for new configurations when booted
                  in UEFI mode.
                </para>
                <para>
                  You may want to look at the options starting with
                  <link linkend="opt-boot.loader.efi.canTouchEfiVariables"><literal>boot.loader.efi</literal></link>
                  and
                  <link linkend="opt-boot.loader.systemd-boot.enable"><literal>boot.loader.systemd-boot</literal></link>
                  as well.
                </para>
                <para>
                  If you want to use GRUB, set
                  <xref linkend="opt-boot.loader.grub.device" /> to
                  <literal>nodev</literal> and
                  <xref linkend="opt-boot.loader.grub.efiSupport" /> to
                  <literal>true</literal>.
                </para>
                <para>
                  With system-boot, you should not need any special
                  configuration to detect other installed systems. With
                  GRUB, set
                  <xref linkend="opt-boot.loader.grub.useOSProber" /> to
                  <literal>true</literal>, but this will only detect
                  windows partitions, not other linux distributions. If
                  you dual boot another linux distribution, use
                  system-boot instead.
                </para>
              </listitem>
            </varlistentry>
          </variablelist>
          <para>
            If you need to configure networking for your machine the
            configuration options are described in
            <xref linkend="sec-networking" />. In particular, while wifi
            is supported on the installation image, it is not enabled by
            default in the configuration generated by
            <literal>nixos-generate-config</literal>.
          </para>
          <para>
            Another critical option is <literal>fileSystems</literal>,
            specifying the file systems that need to be mounted by
            NixOS. However, you typically don't need to set it yourself,
            because <literal>nixos-generate-config</literal> sets it
            automatically in
            <literal>/mnt/etc/nixos/hardware-configuration.nix</literal>
            from your currently mounted file systems. (The configuration
            file <literal>hardware-configuration.nix</literal> is
            included from <literal>configuration.nix</literal> and will
            be overwritten by future invocations of
            <literal>nixos-generate-config</literal>; thus, you
            generally should not modify it.) Additionally, you may want
            to look at
            <link xlink:href="https://github.com/NixOS/nixos-hardware">Hardware
            configuration for known-hardware</link> at this point or
            after installation.
          </para>
          <note>
            <para>
              Depending on your hardware configuration or type of file
              system, you may need to set the option
              <literal>boot.initrd.kernelModules</literal> to include
              the kernel modules that are necessary for mounting the
              root file system, otherwise the installed system will not
              be able to boot. (If this happens, boot from the
              installation media again, mount the target file system on
              <literal>/mnt</literal>, fix
              <literal>/mnt/etc/nixos/configuration.nix</literal> and
              rerun <literal>nixos-install</literal>.) In most cases,
              <literal>nixos-generate-config</literal> will figure out
              the required modules.
            </para>
          </note>
        </listitem>
        <listitem>
          <para>
            Do the installation:
          </para>
          <programlisting>
# nixos-install
</programlisting>
          <para>
            This will install your system based on the configuration you
            provided. If anything fails due to a configuration problem
            or any other issue (such as a network outage while
            downloading binaries from the NixOS binary cache), you can
            re-run <literal>nixos-install</literal> after fixing your
            <literal>configuration.nix</literal>.
          </para>
          <para>
            As the last step, <literal>nixos-install</literal> will ask
            you to set the password for the <literal>root</literal>
            user, e.g.
          </para>
          <programlisting>
setting root password...
New password: ***
Retype new password: ***
</programlisting>
          <note>
            <para>
              For unattended installations, it is possible to use
              <literal>nixos-install --no-root-passwd</literal> in order
              to disable the password prompt entirely.
            </para>
          </note>
        </listitem>
        <listitem>
          <para>
            If everything went well:
          </para>
          <programlisting>
# reboot
</programlisting>
        </listitem>
        <listitem>
          <para>
            You should now be able to boot into the installed NixOS. The
            GRUB boot menu shows a list of <emphasis>available
            configurations</emphasis> (initially just one). Every time
            you change the NixOS configuration (see
            <link linkend="sec-changing-config">Changing
            Configuration</link>), a new item is added to the menu. This
            allows you to easily roll back to a previous configuration
            if something goes wrong.
          </para>
          <para>
            You should log in and change the <literal>root</literal>
            password with <literal>passwd</literal>.
          </para>
          <para>
            You'll probably want to create some user accounts as well,
            which can be done with <literal>useradd</literal>:
          </para>
          <programlisting>
$ useradd -c 'Eelco Dolstra' -m eelco
$ passwd eelco
</programlisting>
          <para>
            You may also want to install some software. This will be
            covered in <xref linkend="sec-package-management" />.
          </para>
        </listitem>
      </orderedlist>
    </section>
    <section xml:id="sec-installation-manual-summary">
      <title>Installation summary</title>
      <para>
        <anchor xml:id="sec-installation-summary" />
        <!-- legacy anchor -->
      </para>
      <para>
        To summarise, <link linkend="ex-install-sequence">Example:
        Commands for Installing NixOS on
        <literal>/dev/sda</literal></link> shows a typical sequence of
        commands for installing NixOS on an empty hard drive (here
        <literal>/dev/sda</literal>). <link linkend="ex-config">Example:
        NixOS Configuration</link> shows a corresponding configuration
        Nix expression.
      </para>
      <anchor xml:id="ex-partition-scheme-MBR" />
      <para>
        <emphasis role="strong">Example: Example partition schemes for
        NixOS on <literal>/dev/sda</literal> (MBR)</emphasis>
      </para>
      <programlisting>
# parted /dev/sda -- mklabel msdos
# parted /dev/sda -- mkpart primary 1MB -8GB
# parted /dev/sda -- mkpart primary linux-swap -8GB 100%
</programlisting>
      <anchor xml:id="ex-partition-scheme-UEFI" />
      <para>
        <emphasis role="strong">Example: Example partition schemes for
        NixOS on <literal>/dev/sda</literal> (UEFI)</emphasis>
      </para>
      <programlisting>
# parted /dev/sda -- mklabel gpt
# parted /dev/sda -- mkpart primary 512MB -8GB
# parted /dev/sda -- mkpart primary linux-swap -8GB 100%
# parted /dev/sda -- mkpart ESP fat32 1MB 512MB
# parted /dev/sda -- set 3 esp on
</programlisting>
      <anchor xml:id="ex-install-sequence" />
      <para>
        <emphasis role="strong">Example: Commands for Installing NixOS
        on <literal>/dev/sda</literal></emphasis>
      </para>
      <para>
        With a partitioned disk.
      </para>
      <programlisting>
# mkfs.ext4 -L nixos /dev/sda1
# mkswap -L swap /dev/sda2
# swapon /dev/sda2
# mkfs.fat -F 32 -n boot /dev/sda3        # (for UEFI systems only)
# mount /dev/disk/by-label/nixos /mnt
# mkdir -p /mnt/boot                      # (for UEFI systems only)
# mount /dev/disk/by-label/boot /mnt/boot # (for UEFI systems only)
# nixos-generate-config --root /mnt
# nano /mnt/etc/nixos/configuration.nix
# nixos-install
# reboot
</programlisting>
      <anchor xml:id="ex-config" />
      <para>
        <emphasis role="strong">Example: NixOS Configuration</emphasis>
      </para>
      <programlisting>
{ config, pkgs, ... }: {
  imports = [
    # Include the results of the hardware scan.
    ./hardware-configuration.nix
  ];

  boot.loader.grub.device = "/dev/sda";   # (for BIOS systems only)
  boot.loader.systemd-boot.enable = true; # (for UEFI systems only)

  # Note: setting fileSystems is generally not
  # necessary, since nixos-generate-config figures them out
  # automatically in hardware-configuration.nix.
  #fileSystems."/".device = "/dev/disk/by-label/nixos";

  # Enable the OpenSSH server.
  services.sshd.enable = true;
}
</programlisting>
    </section>
  </section>
  <section xml:id="sec-installation-additional-notes">
    <title>Additional installation notes</title>
    <xi:include href="installing-usb.section.xml" />
    <xi:include href="installing-pxe.section.xml" />
    <xi:include href="installing-kexec.section.xml" />
    <xi:include href="installing-virtualbox-guest.section.xml" />
    <xi:include href="installing-from-other-distro.section.xml" />
    <xi:include href="installing-behind-a-proxy.section.xml" />
  </section>
</chapter>


text:
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.34014
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace DnsExitClient.Properties {

    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {

        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));

        public static Settings Default {
            get {
                return defaultInstance;
            }
        }

        [global::System.Configuration.UserScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.DefaultSettingValueAttribute("http://ip.dnsexit.com")]
        public string IpWhoIsUrl {
            get {
                return ((string)(this["IpWhoIsUrl"]));
            }
            set {
                this["IpWhoIsUrl"] = value;
            }
        }

        [global::System.Configuration.UserScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.DefaultSettingValueAttribute("inomba.com;audisport.es;elpp.es;elpsoe.es;")]
        public string MyDomains {
            get {
                return ((string)(this["MyDomains"]));
            }
            set {
                this["MyDomains"] = value;
            }
        }

        [global::System.Configuration.UserScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.DefaultSettingValueAttribute("fabriciom")]
        public string Login {
            get {
                return ((string)(this["Login"]));
            }
            set {
                this["Login"] = value;
            }
        }

        [global::System.Configuration.UserScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.DefaultSettingValueAttribute("hackthis")]
        public string Password {
            get {
                return ((string)(this["Password"]));
            }
            set {
                this["Password"] = value;
            }
        }

        [global::System.Configuration.UserScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.DefaultSettingValueAttribute("http://update.dnsexit.com/RemoteUpdate.sv?login=$MyLogin&password=$MyPassword&hos" +
            "t=$MyDomains&myip=$MyIp")]
        public string UpdateUrl {
            get {
                return ((string)(this["UpdateUrl"]));
            }
            set {
                this["UpdateUrl"] = value;
            }
        }

        [global::System.Configuration.UserScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.DefaultSettingValueAttribute("C:\\Temp\\MyIp.txt")]
        public string IpTempFile {
            get {
                return ((string)(this["IpTempFile"]));
            }
            set {
                this["IpTempFile"] = value;
            }
        }
    }
}


text:
tk-jbd-changeworkspace
======================

Application to change the sg workspace based on what spaces exist on the local server.

This avoids the need to open the existing file manager which can be slow with lots of assets.

####Dependencies:

**https://github.com/shotgunsoftware/python-api**

####General application notes:

It is important to note using dev path will cause some **cross platform** issues because you'll end up with a hard coded path.<br
To avoid this you can copy the application into the [YOURCONFIGNAME]/install/apps/manual/ directory and use:

`location: {name: tk-jbd-submit-mayaplayblast, type: manual, version: v0.0.1}`

Further reading on manual install: https://toolkit.shotgunsoftware.com/entries/23797786#Apps%20in%20git%20%28and%20github%29

#APPLICATION INSTALL NOTES:
* **You must have the python-api installed for shotgun!**
* Folders should exist for assets/shots you want to change workspaces into.
* You must uncomment and change the lines in the python/lib/CONST.py file to be the correct information for your shotgun setup!

        SHOTGUN_CONFIG_NAME     = YOURCONFIGNAME
        SHOTGUN_URL             = INSERT YOUR URL HERE eg https://mystudio.shotgunstudio.com AS A STRING
        SHOTGUN_TOOLKIT_NAME    = INSERT YOUR SCRIPTNAME eg Toolkit
        SHOTGUN_TOOLKIT_API_KEY = INSERT YOUR API KEY HERE eg 724eea86a7hhhe4816b8f24833112eacf42834a2b5cb85f814f125e96078a3b3
        ASSETS_FOLDER_NAME      = The name of your assets folder on disk if you have changed this entity in shotgun
        SEQUENCES_FOLDER_NAME   = The name of your sequences folder on disk if you have changed this entity in shotgun eg: episodes

* Adding to the asset_step and shot_step:
    Manual Install:

    Download the releases manually for now until I figure out how to get a github release working in the yml.

    It refuses to work for me at this time.

    Check https://toolkit.shotgunsoftware.com/entries/23797786#Apps%20in%20git%20%28and%20github%29

    ```
      tk-changeworkspace:

        display_name:               Change Workspace
        location:                  {"type": "manual", "name": "tk-jbd-workspace", "version": "v0.x.x"}
    ```

Clicking on an asset or a shot will query SGun for valid tasks / steps to change to


text:
package org.openbaton.vnfm.generic.repository;

import org.openbaton.catalogue.mano.common.Event;
import org.openbaton.vnfm.generic.model.VNFRErrorStatus;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
@Transactional
public interface VNFRErrorRepository extends CrudRepository<VNFRErrorStatus, String> {
  VNFRErrorStatus findFirstByVnfrId(String vnfrId);

  VNFRErrorStatus findByVnfrIdAndEventAndScriptIndex(
      String vnfrId, Event event, Integer scriptIndex);

  void deleteByVnfrId(String vnfrId);
}


text:
package software.amazon.awssdk.modulepath.tests.mocktests;

import java.io.ByteArrayInputStream;
import java.util.concurrent.CompletionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.http.AbortableInputStream;
import software.amazon.awssdk.http.HttpExecuteResponse;
import software.amazon.awssdk.http.SdkHttpResponse;

/**
 * Base classes to mock sync and async api calls.
 */
public abstract class BaseMockApiCall {

    private static final Logger logger = LoggerFactory.getLogger(BaseMockApiCall.class);

    protected final MockHttpClient mockHttpClient;
    protected final MockAyncHttpClient mockAyncHttpClient;
    private final String protocol;

    public BaseMockApiCall(String protocol) {
        this.protocol = protocol;
        this.mockHttpClient = new MockHttpClient();
        this.mockAyncHttpClient = new MockAyncHttpClient();
    }

    public void successfulApiCall() {
        logger.info("stubing successful api call for {} protocol", protocol);
        mockHttpClient.stubNextResponse(successResponse(protocol));
        runnable().run();
        mockHttpClient.reset();
    }

    public void failedApiCall() {
        logger.info("stubing failed api call for {} protocol", protocol);
        mockHttpClient.stubNextResponse(errorResponse(protocol));

        try {
            runnable().run();
        } catch (AwsServiceException e) {
            logger.info("Received expected service exception", e.getMessage());
        }

        mockHttpClient.reset();
    }

    public void successfulAsyncApiCall() {
        logger.info("stubing successful async api call for {} protocol", protocol);
        mockAyncHttpClient.stubNextResponse(successResponse(protocol));
        asyncRunnable().run();
        mockAyncHttpClient.reset();
    }

    public void failedAsyncApiCall() {
        logger.info("stubing failed async api call for {} protocol", protocol);
        mockAyncHttpClient.stubNextResponse(errorResponse(protocol));

        try {
            asyncRunnable().run();
        } catch (CompletionException e) {
            if (e.getCause() instanceof AwsServiceException) {
                logger.info("expected service exception {}", e.getMessage());
            } else {
                throw new RuntimeException("Unexpected exception is thrown");
            }
        }

        mockAyncHttpClient.reset();
    }

    abstract Runnable runnable();

    abstract Runnable asyncRunnable();

    private HttpExecuteResponse successResponse(String protocol) {
        return HttpExecuteResponse.builder()
                                  .response(SdkHttpResponse.builder()
                                                           .statusCode(200)
                                                           .build())
                                  .responseBody(generateContent(protocol))
                                  .build();
    }

    private HttpExecuteResponse errorResponse(String protocol) {
        return HttpExecuteResponse.builder()
                                  .response(SdkHttpResponse.builder()
                                                           .statusCode(500)
                                                           .build())
                                  .responseBody(generateContent(protocol))
                                  .build();
    }

    private AbortableInputStream generateContent(String protocol) {
        String content;
        switch (protocol) {
            case "xml":
                content = "<foo></foo>";
                break;
            default:
            case "json":
                content = "{}";
        }

        return AbortableInputStream.create(new ByteArrayInputStream(content.getBytes()));
    }
}


text:
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require File.expand_path("../command_helper", __FILE__)

describe "github admin" do
  include CommandHelper

  specify "admin should open the project admin page" do
    running :admin do
      setup_url_for
      @helper.should_receive(:open_url).once.with("https://github.com/user/project/admin")
    end
  end

  specify "admin drnic should open the home page of drnic's fork" do
    running :admin, "drnic" do
      setup_url_for
      @helper.should_receive(:open_url).once.with("https://github.com/drnic/project/admin")
    end
  end
end


text:
using System;
using System.Threading.Tasks;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Office365.Discovery;

namespace Office365Api.Helpers.Office365
{
    public class DiscoveryHelper : BaseOffice365Helper
    {
        public DiscoveryHelper(AuthenticationHelper authenticationHelper) :
            base(authenticationHelper)
        {
            DiscoveryClient discoveryClient =
                new DiscoveryClient(
                    Office365ServicesUris.DiscoveryServiceEndpointUri,
                                    async () =>
                                    {
                                        var discoveryAuthResult =
                                            await this.AuthenticationHelper.AuthenticationContext.AcquireTokenSilentAsync(
                                                Office365ServicesUris.DiscoveryServiceResourceId,
                                                AuthenticationHelper.ClientId,
                                                new UserIdentifier(
                                                    this.AuthenticationHelper.AuthenticationResult.UserInfo.UniqueId,
                                                    UserIdentifierType.UniqueId));

                                        return discoveryAuthResult.AccessToken;
                                    });

            this.DiscoveryClient = discoveryClient;
        }

        public DiscoveryClient DiscoveryClient
        {
            get;
            private set;
        }

        private async Task<CapabilityDiscoveryResult> DiscoverCapabilityInternalAsync(String capabilityName)
        {
            if (DiscoveryClient == null)
            {
                throw new ApplicationException("Missing the DiscoveryClient object!");
            }

            var dcr = await DiscoveryClient.DiscoverCapabilityAsync(capabilityName);
            return dcr;
        }

        // Discovery service supports MyFiles, Mail, Contacts and Calendar
        public async Task<CapabilityDiscoveryResult> DiscoverMail()
        {
            return (await DiscoverCapabilityInternalAsync(Office365Capabilities.Mail.ToString()));
        }

        public async Task<CapabilityDiscoveryResult> DiscoverContacts()
        {
            return (await DiscoverCapabilityInternalAsync(Office365Capabilities.Contacts.ToString()));
        }

        public async Task<CapabilityDiscoveryResult> DiscoverCalendar()
        {
            return (await DiscoverCapabilityInternalAsync(Office365Capabilities.Calendar.ToString()));
        }

        public async Task<CapabilityDiscoveryResult> DiscoverMyFiles()
        {
            return (await DiscoverCapabilityInternalAsync(Office365Capabilities.MyFiles.ToString()));
        }
    }
}


text:
package local.tomo.medi.ormlite;

import android.content.Context;
import android.content.res.Resources;
import android.os.AsyncTask;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.j256.ormlite.android.apptools.OpenHelperManager;
import com.j256.ormlite.dao.Dao;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.List;

import local.tomo.medi.R;
import local.tomo.medi.ormlite.data.Drug;
import lombok.SneakyThrows;

import static local.tomo.medi.ormlite.data.Drug.D_PACKAGE_ID;

public class DatabaseDataCreator extends AsyncTask<Void, Void, Void> {

    private final Resources resources;
    private final DatabaseHelper databaseHelper;

    public DatabaseDataCreator(Resources resources, Context context) {
        this.resources = resources;
        this.databaseHelper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
    }

    @Override
    protected Void doInBackground(Void... voids) {

        getDrugsFromFile().forEach(this::save);

        return null;
    }

    @SneakyThrows
    private void save(Drug drug) {

        Dao<Drug, Integer> drugsDataAccess = databaseHelper.getDrugsDataAccess();

        if (drugNotExist(drug)) {

            drugsDataAccess.create(drug);
        }
    }

    @SneakyThrows
    private boolean drugNotExist(Drug drug) {

        return databaseHelper.getDrugsDataAccess()
                .queryBuilder()
                .where()
                .eq(D_PACKAGE_ID, drug.getPackageID())
                .countOf() == 0;
    }

    private List<Drug> getDrugsFromFile() {

        InputStream inputStream = resources.openRawResource(R.raw.drugs_small);
        Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);

        return new Gson().fromJson(reader, new TypeToken<List<Drug>>(){}.getType());
    }
}


text:
%Notes by Harsh Mistry
%CS 241
%based on Template from : https://www.cs.cmu.edu/~ggordon/10725-F12/template.tex

\documentclass{article}
\setlength{\oddsidemargin}{0.25 in}
\setlength{\evensidemargin}{-0.25 in}
\setlength{\topmargin}{-0.6 in}
\setlength{\textwidth}{6.5 in}
\setlength{\textheight}{8.5 in}
\setlength{\headsep}{0.75 in}
\setlength{\parindent}{0 in}
\setlength{\parskip}{0.1 in}
\usepackage{amsfonts,graphicx, amssymb}
\usepackage[fleqn]{amsmath}
\usepackage{fixltx2e}
\usepackage{color}
\usepackage{tcolorbox}
\usepackage{lipsum}
\usepackage{listings}
\usepackage{scrextend}
\tcbuselibrary{skins,breakable}
\usetikzlibrary{shadings,shadows}
\newcounter{lecnum}
\renewcommand{\thepage}{\thelecnum-\arabic{page}}
\renewcommand{\thesection}{\thelecnum.\arabic{section}}
\renewcommand{\theequation}{\thelecnum.\arabic{equation}}
\renewcommand{\thefigure}{\thelecnum.\arabic{figure}}
\renewcommand{\thetable}{\thelecnum.\arabic{table}}
\newcommand{\lecture}[4]{
   \pagestyle{myheadings}
   \thispagestyle{plain}
   \newpage
   \setcounter{lecnum}{#1}
   \setcounter{page}{1}

%Info Box
   \begin{center}
   \framebox{
      \vbox{\vspace{2mm}
    \hbox to 6.28in { {\bf CS 241 - Foundations of Sequential Programs
	\hfill Spring 2017} }
       \vspace{4mm}
       \hbox to 6.28in { {\Large \hfill Lecture #1: #2  \hfill} }
       \vspace{2mm}
       \hbox to 6.28in { {\it Lecturer: #3 \hfill Notes By: #4} }
      \vspace{2mm}}
   }
   \end{center}

   \markboth{Lecture #1: #2}{Lecture #1: #2}

}

\renewcommand{\cite}[1]{[#1]}
\def\beginrefs{\begin{list}%
        {[\arabic{equation}]}{\usecounter{equation}
         \setlength{\leftmargin}{2.0truecm}\setlength{\labelsep}{0.4truecm}%
         \setlength{\labelwidth}{1.6truecm}}}
\def\endrefs{\end{list}}
\def\bibentry#1{\item[\hbox{[#1]}]}

\newcommand{\fig}[3]{
			\vspace{#2}
			\begin{center}
			Figure \thelecnum.#1:~#3
			\end{center}
	}

	\newcommand{\bs}{
		\texttt{\char`\\ \hspace{0.1cm}}
	}

\newcommand{\pipe}{\(\mid\)}
\newcommand{\ctr}{\(\wedge\)}

\newtheorem{theorem}{Theorem}[lecnum]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{ex}[theorem]{Example}
\newtheorem{expx}[theorem]{Problem}
\newtheorem{prop}[theorem]{Proposition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{definition}[theorem]{Definition}
\newenvironment{proof}{{\bf Proof:}}{\hfill\rule{2mm}{2mm}}
\newcommand\E{\mathbb{E}}

%color definitions :
\definecolor{darkred}{rgb}{0.55, 0.0, 0.0}
\definecolor{lightcoral}{rgb}{0.94, 0.5, 0.5}
\definecolor{tomato}{rgb}{1.0, 0.39, 0.28}
\definecolor{lightgray}{rgb}{.9,.9,.9}
\definecolor{darkgray}{rgb}{.4,.4,.4}
\definecolor{purple}{rgb}{0.65, 0.12, 0.82}
\definecolor{lightgreen}{rgb}{0.56, 0.93, 0.56}
\definecolor{darkgreen}{rgb}{0.0, 0.2, 0.13}
\definecolor{limegreen}{rgb}{0.2, 0.8, 0.2}
\definecolor{lightblue}{rgb}{0.68, 0.85, 0.9}
\definecolor{darkblue}{rgb}{0.0, 0.0, 0.55}

%Environments
\newenvironment{exblock}[1]{%
    \tcolorbox[beamer,%
    noparskip,breakable,
    colback=lightgreen,colframe=darkgreen,%
    colbacklower=limegreen!75!lightgreen,%
    title=#1]}%
    {\endtcolorbox}

\newenvironment{ablock}[1]{%
    \tcolorbox[beamer,%
    noparskip,breakable,
    colback=lightcoral,colframe=darkred,%
    colbacklower=tomato!75!lightcoral,%
    title=#1]}%
    {\endtcolorbox}

\newenvironment{cblock}[1]{%
    \tcolorbox[beamer,%
    noparskip,breakable,
    colback=lightblue,colframe=darkblue,%
    colbacklower=darkblue!75!lightblue,%
    title=#1]}%
    {\endtcolorbox}

%Languages
\lstdefinelanguage{JavaScript}{
  keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break},
  keywordstyle=\color{blue}\bfseries,
  ndkeywords={class, export, boolean, throw, implements, import, this},
  ndkeywordstyle=\color{darkgray}\bfseries,
  identifierstyle=\color{black},
  sensitive=false,
  comment=[l]{//},
  morecomment=[s]{/*}{*/},
  commentstyle=\color{purple}\ttfamily,
  stringstyle=\color{red}\ttfamily,
  morestring=[b]',
  morestring=[b]"
}

%Listings
\lstset{
   language=JavaScript,
   backgroundcolor=\color{lightgray},
   extendedchars=true,
   basicstyle=\footnotesize\ttfamily,
   showstringspaces=false,
   showspaces=false,
   numbers=left,
   numberstyle=\footnotesize,
   numbersep=9pt,
   tabsize=2,
   breaklines=true,
   showtabs=false,
   captionpos=b
}

%Start
\begin{document}

\lecture{18, 19}{July 4 - July 6, 2017}{Kevin Lanctot}{Harsh Mistry}

\section{Code Generation}
The purposes of code generation is to actually generate machine code based on the given code

Key issues include
\begin{itemize}
\item Correctness
\item Efficiency
\item Efficiency of the compiled code
\end{itemize}

To solve these key issues we approach this using \textbf{Syntax Direct Translation}

\begin{itemize}
\item create a translation function for each syntactic category, e.g.
for loops, if-else statements, assignment, expressions
\item translation closely follows the syntactic structure of the code
\item recursively traverse the parse tree to gather the needed
information
\item first you must understand exactly what we mean by …
\end{itemize}

\subsection*{Storing Variables}
\begin{itemize}
\item[(a)] Store variables in Registers
\item[(b)] Store variables in RAM
\item[(c)] Store Variables in Stack
\end{itemize}

\begin{center}
\textcolor{red}{
\textbf{Note : } Majority of this weeks classes was mostly spent going over examples explaining how to complete A9 and A10. Please refer to the official course notes for these examples}
\end{center}

\end{document}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>GNU Compiler Collection (GCC) Internals: Torture Tests</title>

<meta name="description" content="GNU Compiler Collection (GCC) Internals: Torture Tests">
<meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Torture Tests">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Testsuites.html#Testsuites" rel="up" title="Testsuites">
<link href="Options.html#Options" rel="next" title="Options">
<link href="compat-Testing.html#compat-Testing" rel="prev" title="compat Testing">

Previous: compat Testing, Up: Testsuites   [Contents][Index]

7.10 Support for torture testing using multiple options

Throughout the compiler testsuite there are several directories whose
tests are run multiple times, each with a different set of options.
These are known as torture tests.
<samp>lib/torture-options.exp</samp> defines procedures to
set up these lists:

torture-init

Initialize use of torture lists.

set-torture-options

Set lists of torture options to use for tests with and without loops.
Optionally combine a set of torture options with a set of other
options, as is done with Objective-C runtime options.

torture-finish

Finalize use of torture lists.

The <samp>.exp</samp> file for a set of tests that use torture options must
include calls to these three procedures if:

 It calls gcc-dg-runtest and overrides <var>DG_TORTURE_OPTIONS</var>.

 It calls <var>${tool}</var>-torture or
<var>${tool}</var>-torture-execute, where <var>tool</var> is c,
fortran, or objc.

 It calls dg-pch.

It is not necessary for a <samp>.exp</samp> file that calls gcc-dg-runtest
to call the torture procedures if the tests should use the list in
<var>DG_TORTURE_OPTIONS</var> defined in <samp>gcc-dg.exp</samp>.

Most uses of torture options can override the default lists by defining
<var>TORTURE_OPTIONS</var> or add to the default list by defining
<var>ADDITIONAL_TORTURE_OPTIONS</var>.  Define these in a <samp>.dejagnurc</samp>
file or add them to the <samp>site.exp</samp> file; for example

set ADDITIONAL_TORTURE_OPTIONS  [list \
  { -O2 -ftree-loop-linear } \
  { -O2 -fpeel-loops } ]