text:
namespace llvm {

/// Tracking metadata reference.
///
/// This class behaves like \a TrackingVH, but for metadata.
class TrackingMDRef {
  Metadata *MD = nullptr;

public:
  TrackingMDRef() = default;
  explicit TrackingMDRef(Metadata *MD) : MD(MD) { track(); }

  TrackingMDRef(TrackingMDRef &&X) : MD(X.MD) { retrack(X); }
  TrackingMDRef(const TrackingMDRef &X) : MD(X.MD) { track(); }

  TrackingMDRef &operator=(TrackingMDRef &&X) {
    if (&X == this)
      return *this;

    untrack();
    MD = X.MD;
    retrack(X);
    return *this;
  }

  TrackingMDRef &operator=(const TrackingMDRef &X) {
    if (&X == this)
      return *this;

    untrack();
    MD = X.MD;
    track();
    return *this;
  }

  ~TrackingMDRef() { untrack(); }

  Metadata *get() const { return MD; }
  operator Metadata *() const { return get(); }
  Metadata *operator->() const { return get(); }
  Metadata &operator*() const { return *get(); }

  void reset() {
    untrack();
    MD = nullptr;
  }
  void reset(Metadata *MD) {
    untrack();
    this->MD = MD;
    track();
  }

  /// Check whether this has a trivial destructor.
  ///
  /// If \c MD isn't replaceable, the destructor will be a no-op.
  bool hasTrivialDestructor() const {
    return !MD || !MetadataTracking::isReplaceable(*MD);
  }

  bool operator==(const TrackingMDRef &X) const { return MD == X.MD; }
  bool operator!=(const TrackingMDRef &X) const { return MD != X.MD; }

private:
  void track() {
    if (MD)
      MetadataTracking::track(MD);
  }

  void untrack() {
    if (MD)
      MetadataTracking::untrack(MD);
  }

  void retrack(TrackingMDRef &X) {
    assert(MD == X.MD && "Expected values to match");
    if (X.MD) {
      MetadataTracking::retrack(X.MD, MD);
      X.MD = nullptr;
    }
  }
};

/// Typed tracking ref.
///
/// Track refererences of a particular type.  It's useful to use this for \a
/// MDNode and \a ValueAsMetadata.
template <class T> class TypedTrackingMDRef {
  TrackingMDRef Ref;

public:
  TypedTrackingMDRef() = default;
  explicit TypedTrackingMDRef(T *MD) : Ref(static_cast<Metadata *>(MD)) {}

  TypedTrackingMDRef(TypedTrackingMDRef &&X) : Ref(std::move(X.Ref)) {}
  TypedTrackingMDRef(const TypedTrackingMDRef &X) : Ref(X.Ref) {}

  TypedTrackingMDRef &operator=(TypedTrackingMDRef &&X) {
    Ref = std::move(X.Ref);
    return *this;
  }

  TypedTrackingMDRef &operator=(const TypedTrackingMDRef &X) {
    Ref = X.Ref;
    return *this;
  }

  T *get() const { return (T *)Ref.get(); }
  operator T *() const { return get(); }
  T *operator->() const { return get(); }
  T &operator*() const { return *get(); }

  bool operator==(const TypedTrackingMDRef &X) const { return Ref == X.Ref; }
  bool operator!=(const TypedTrackingMDRef &X) const { return Ref != X.Ref; }

  void reset() { Ref.reset(); }
  void reset(T *MD) { Ref.reset(static_cast<Metadata *>(MD)); }

  /// Check whether this has a trivial destructor.
  bool hasTrivialDestructor() const { return Ref.hasTrivialDestructor(); }
};

using TrackingMDNodeRef = TypedTrackingMDRef<MDNode>;
using TrackingValueAsMetadataRef = TypedTrackingMDRef<ValueAsMetadata>;

// Expose the underlying metadata to casting.
template <> struct simplify_type<TrackingMDRef> {
  using SimpleType = Metadata *;

  static SimpleType getSimplifiedValue(TrackingMDRef &MD) { return MD.get(); }
};

template <> struct simplify_type<const TrackingMDRef> {
  using SimpleType = Metadata *;

  static SimpleType getSimplifiedValue(const TrackingMDRef &MD) {
    return MD.get();
  }
};

template <class T> struct simplify_type<TypedTrackingMDRef<T>> {
  using SimpleType = T *;

  static SimpleType getSimplifiedValue(TypedTrackingMDRef<T> &MD) {
    return MD.get();
  }
};

template <class T> struct simplify_type<const TypedTrackingMDRef<T>> {
  using SimpleType = T *;

  static SimpleType getSimplifiedValue(const TypedTrackingMDRef<T> &MD) {
    return MD.get();
  }
};

} // end namespace llvm

#endif // LLVM_IR_TRACKINGMDREF_H

redpajama_set_name: RedPajamaGithub


text:
import pytest
from marshmallow import Schema, fields
from sqlalchemy import Column, Integer, String

from flask_resty import Api, GenericModelView
from flask_resty.testing import assert_response

# -----------------------------------------------------------------------------

@pytest.fixture
def models(db):
    class Widget(db.Model):
        __tablename__ = "widgets"

        id_1 = Column(Integer, primary_key=True)
        id_2 = Column(Integer, primary_key=True)
        name = Column(String, nullable=False)

    db.create_all()

    yield {"widget": Widget}

    db.drop_all()

@pytest.fixture
def schemas():
    class WidgetSchema(Schema):
        id_1 = fields.Integer(as_string=True)
        id_2 = fields.Integer(as_string=True)
        name = fields.String(required=True)

    return {"widget": WidgetSchema()}

@pytest.fixture(autouse=True)
def routes(app, models, schemas):
    class WidgetViewBase(GenericModelView):
        model = models["widget"]
        schema = schemas["widget"]
        id_fields = ("id_1", "id_2")

    class WidgetListView(WidgetViewBase):
        def get(self):
            return self.list()

        def post(self):
            return self.create(allow_client_id=True)

    class WidgetView(WidgetViewBase):
        def get(self, id_1, id_2):
            return self.retrieve((id_1, id_2))

        def patch(self, id_1, id_2):
            return self.update((id_1, id_2), partial=True)

        def delete(self, id_1, id_2):
            return self.destroy((id_1, id_2))

    api = Api(app)
    api.add_resource(
        "/widgets", WidgetListView, WidgetView, id_rule="<int:id_1>/<int:id_2>"
    )

@pytest.fixture(autouse=True)
def data(db, models):
    db.session.add_all(
        (
            models["widget"](id_1=1, id_2=2, name="Foo"),
            models["widget"](id_1=1, id_2=3, name="Bar"),
            models["widget"](id_1=4, id_2=5, name="Baz"),
        )
    )
    db.session.commit()

# -----------------------------------------------------------------------------

def test_list(client):
    response = client.get("/widgets")
    assert_response(
        response,
        200,
        [
            {"id_1": "1", "id_2": "2", "name": "Foo"},
            {"id_1": "1", "id_2": "3", "name": "Bar"},
            {"id_1": "4", "id_2": "5", "name": "Baz"},
        ],
    )

def test_retrieve(client):
    response = client.get("/widgets/1/2")
    assert_response(response, 200, {"id_1": "1", "id_2": "2", "name": "Foo"})

def test_create(client):
    response = client.post(
        "/widgets", data={"id_1": "4", "id_2": "6", "name": "Qux"}
    )
    assert response.headers["Location"] == "http://localhost/widgets/4/6"

    assert_response(response, 201, {"id_1": "4", "id_2": "6", "name": "Qux"})

def test_update(client):
    response = client.patch(
        "/widgets/1/2", data={"id_1": "1", "id_2": "2", "name": "Qux"}
    )
    assert_response(response, 200, {"id_1": "1", "id_2": "2", "name": "Qux"})

def test_destroy(client):
    destroy_response = client.delete("/widgets/1/2")
    assert_response(destroy_response, 204)

    retrieve_response = client.get("/widgets/1/2")
    assert_response(retrieve_response, 404)


text:
title: Build Binary Package
authors: alonbl, dneary, ranglust
wiki_title: Build Binary Package
wiki_revision_count: 7
wiki_last_updated: 2014-07-01
---

# Build Source Package

Most components of oVirt project use standard sequence to build rpms.

Summary of sequence is:

`git clone `<repository>
`cd `<repository>
      [ -r configure.ac ] && autoreconf -ivf
      [ -r configure ] && ./configure
      make dist                # <-- will output source tarball

Note: If autoreconf is required, install autoconf, automake optionally gettext-devel packages.

# Build RPM Package

      rpmbuild -tb `<tarball>`   # <-- will output rpms

Another useful command is createrepo which scans directory and prepare rpm repository that can be added to yum via /etc/yum.repos.d/xxx.repo

      [xxx]
      name=xxx
`baseurl=`[`file:///location/of/repository`](file:///location/of/repository)
      enabled=1
      gpgcheck=0

Author: --Alon Bar-Lev (Alonbl) ([talk](User talk:Alonbl)) 02:22, 1 July 2014 (GMT)


text:
layout: single
title: How to setup an SSH server on ZyXEL NSA320
date: '2013-06-29 16:45:03'
tags:
- modding
aliases: [/how-to-setup-an-ssh-server-on-zyxel-nsa320/index.html]
---

Hi there,

some days ago I bought a very kind NAS for myself after the (terrible) adventure with WD My Book World Edition II. Not that it was so bad but...after three years it was very old (Kernel 2.6.24) and not so much apps were supported nowadays. So, I thought to get a new one which is [community supported](http://archlinuxarm.org/platforms/armv5/zyxel-nsa320 "Arch Linux ARM for ZyXEL NSA320") (at last) but some kind hardware with a very low budget, and then I found this one: [ZyXEL NSA320](http://www.zyxel.com/products_services/nsa320.shtml?t=p "ZyXEL NSA320").

This is a VERY GOOD NAS, best choice out there (imho) and has a lot of things built-in and already configured for the low-end users. But, as you may know already, I'm not satisfied until I'm the root of anything I own so, I asked myself: how to get SSH on this box? (unfortunatelly it isn't already built-in).

After some search on Google [I found that there's something called FFP](http://zyxel.nas-central.org/wiki/FFP-stick "FFP-stick for ZyXEL NSA320"), a custom USB with a very-small OS made up already to boot a [Telnet](http://en.wikipedia.org/wiki/Telnet "Telnet Interface") interface, and after that an SSH one. So I used this guide to accomplish this but...I didn't work. I have to admit I'm on the latest firmware (until today, 4.60) so probably It wasn't tested already there but I didn't lose the hope to have the SSHd.

So, searching again in the deep, [I found this topic which talked about FFP that could be installed as a Package](http://forum.nas-central.org/viewtopic.php?f=249&t=6315#p27531 "FFP as a Package into ZyXEL NSA320") with the built-it package manager inside of NSA320\. So, to keep it simple, to get your SSH running within a minute you have to do this:

1.  With any PC (Windows/Mac/Linux) point to this directory (I'll write it down in Windows notation): `\\YOUR_NAS_IP\\admin\zy-pkgs`
2.  Create a file called `web_prefix`
3.  Write inside of that file `ftp://ftp.zyxel-tech.de/2.new_mirror/` and save it
4.  Login into the Web Admin interface (through a Web Browser), go into the Package Manager and choose `ffp`, click over it and after the big green plus called `Install/Update`
5.  Wait for it to install and enjoy!

Now you can login with `root` and your `admin` account password you're actually using. That's it.

I hope you'll find this useful. See you next time!


text:
/* tslint:disable:max-line-length */
import { CompletionItem, CompletionItemKind } from 'vscode-languageserver-types';

const builtIn = [
  {
    name: 'red(color[, value])',
    desc:
      'Return the red component of the given color, or set the red component to the optional second value argument.',
    insertText: 'red'
  },
  {
    name: 'green(color[, value])',
    desc:
      'Return the green component of the given color, or set the green component to the optional second value argument.',
    insertText: 'green'
  },
  {
    name: 'blue(color[, value])',
    desc:
      'Return the blue component of the given color, or set the blue component to the optional second value argument.',
    insertText: 'blue'
  },
  {
    name: 'alpha(color[, value])',
    desc:
      'Return the alpha component of the given color, or set the alpha component to the optional second value argument.',
    insertText: 'alpha'
  },
  {
    name: 'dark(color)',
    desc: 'Check if color is dark:',
    insertText: 'dark'
  },
  {
    name: 'light(color)',
    desc: 'Check if color is light:',
    insertText: 'light'
  },
  {
    name: 'hue(color[, value])',
    desc: 'Return the hue of the given color, or set the hue component to the optional second value argument.',
    insertText: 'hue'
  },
  {
    name: 'saturation(color[, value])',
    desc:
      'Return the saturation of the given color, or set the saturation component to the optional second value argument.',
    insertText: 'saturation'
  },
  {
    name: 'lightness(color[, value])',
    desc:
      'Return the lightness of the given color, or set the lightness component to the optional second value argument.',
    insertText: 'lightness'
  },
  {
    name: 'push(expr, args…)',
    desc: 'Push the given args to expr.',
    insertText: 'push'
  },
  {
    name: 'pop(expr)',
    desc: 'Pop a value from expr.',
    insertText: 'pop'
  },
  {
    name: 'shift(expr)',
    desc: 'Shift an element from expr.',
    insertText: 'shift'
  },
  {
    name: 'unshift(expr, args…)',
    desc: 'Unshift the given args to expr.',
    insertText: 'unshift'
  },
  {
    name: 'index(list, value)',
    desc: 'Returns the index (zero-based) of a value within a list.',
    insertText: 'index'
  },
  {
    name: 'keys(pairs)',
    desc: 'Return keys in the given pairs:',
    insertText: 'keys'
  },
  {
    name: 'values(pairs)',
    desc: 'Return values in the given pairs:',
    insertText: 'values'
  },
  {
    name: 'list-separator(list)',
    desc: 'Return the separator of the given list.',
    insertText: 'list-separator'
  },
  {
    name: 'typeof(node)',
    desc: 'Return type of node as a string.',
    insertText: 'typeof'
  },
  {
    name: 'unit(unit[, type])',
    desc: 'Return a string for the type of unit or an empty string, or assign the given type without unit conversion.',
    insertText: 'unit'
  },
  {
    name: 'percentage(num)',
    desc: 'Convert a num to a percentage.',
    insertText: 'percentage'
  },
  {
    name: 'abs(unit)',
    desc: '  abs(-5px)\n  // => 5px\n\n  abs(5px)\n  // => 5px\n',
    insertText: 'abs'
  },
  {
    name: 'ceil(unit)',
    desc: '  ceil(5.5in)\n  // => 6in\n',
    insertText: 'ceil'
  },
  {
    name: 'floor(unit)',
    desc: '  floor(5.6px)\n  // => 5px\n',
    insertText: 'floor'
  },
  {
    name: 'round(unit)',
    desc: '  round(5.5px)\n  // => 6px\n\n  round(5.4px)\n  // => 5px\n',
    insertText: 'round'
  },
  {
    name: 'sin(angle)',
    desc:
      'Returns the value of sine for the given angle. If the angle is given as a degree unit, like 45deg, it is treated as a degree, otherwise it is treated as radians.',
    insertText: 'sin'
  },
  {
    name: 'cos(angle)',
    desc:
      'Returns the value of cosine for the given angle. If the angle is given as a degree unit, like 45deg, it is treated as a degree, otherwise it is treated as radians.',
    insertText: 'cos'
  },
  {
    name: 'tan(angle)',
    desc:
      'Returns the value of tangent for the given angle. If the angle is given as a degree unit, like 45deg, it is treated as a degree, otherwise it is treated as radians.',
    insertText: 'tan'
  },
  {
    name: 'min(a, b)',
    desc: '  min(1, 5)\n  // => 1\n',
    insertText: 'min'
  },
  {
    name: 'max(a, b)',
    desc: '  max(1, 5)\n  // => 5\n',
    insertText: 'max'
  },
  {
    name: 'even(unit)',
    desc: '  even(6px)\n  // => true\n',
    insertText: 'even'
  },
  {
    name: 'odd(unit)',
    desc: '  odd(5mm)\n  // => true\n',
    insertText: 'odd'
  },
  {
    name: 'sum(nums)',
    desc: '  sum(1 2 3)\n  // => 6\n',
    insertText: 'sum'
  },
  {
    name: 'avg(nums)',
    desc: ' avg(1 2 3)\n // => 2\n',
    insertText: 'avg'
  },
  {
    name: 'range(start, stop[, step])',
    desc:
      'Returns a list of units from start to stop (included) by given step. If step argument is omitted, it defaults to 1. The step must not be zero.',
    insertText: 'range'
  },
  {
    name: 'base-convert(num, base, width)',
    desc: 'Returns a Literal num converted to the provided base, padded to width with zeroes (default width is 2)',
    insertText: 'base-convert'
  },
  {
    name: 'match(pattern, string[, flags])',
    desc: 'Retrieves the matches when matching a val(string) against a pattern(regular expression).',
    insertText: 'match'
  },
  {
    name: 'replace(pattern, replacement, val)',
    desc: 'Returns string with all matches of pattern replaced by replacement in given val',
    insertText: 'replace'
  },
  {
    name: 'join(delim, vals…)',
    desc: 'Join the given vals with delim.',
    insertText: 'join'
  },
  {
    name: 'split(delim, val)',
    desc:
      'The split()` method splits a string/ident into an array of strings by separating the string into substrings.',
    insertText: 'split'
  },
  {
    name: 'substr(val, start, length)',
    desc:
      'The substr() method returns the characters in a string beginning at the specified location through the specified number of characters.',
    insertText: 'substr'
  },
  {
    name: 'slice(val, start[, end])',
    desc: 'The slice() method extracts a section of a string/list and returns a new string/list.',
    insertText: 'slice'
  },
  {
    name: 'hsla(color | h,s,l,a)',
    desc: 'Convert the given color to an HSLA node, or h,s,l,a component values.',
    insertText: 'hsla'
  },
  {
    name: 'hsl(color | h,s,l)',
    desc: 'Convert the given color to an HSLA node, or h,s,l,a component values.',
    insertText: 'hsl'
  },
  {
    name: 'rgba(color | r,g,b,a)',
    desc: 'Return RGBA from the r,g,b,a channels or provide a color to tweak the alpha.',
    insertText: 'rgba'
  },
  {
    name: 'rgb(color | r,g,b)',
    desc: 'Return a RGBA from the r,g,b channels or cast to an RGBA node.',
    insertText: 'rgb'
  },
  {
    name: 'blend(top[, bottom])',
    desc:
      'Blends the given top color over the bottom one using the normal blending. The bottom argument is optional and is defaulted to #fff.',
    insertText: 'blend'
  },
  {
    name: 'lighten(color, amount)',
    desc:
      'Lighten the given color by amount. This function is unit-sensitive, for example supporting percentages as shown below.',
    insertText: 'lighten'
  },
  {
    name: 'darken(color, amount)',
    desc:
      'Darken the given color by amount.This function is unit-sensitive, for example supporting percentages as shown below.',
    insertText: 'darken'
  },
  {
    name: 'desaturate(color, amount)',
    desc: 'Desaturate the given color by amount.',
    insertText: 'desaturate'
  },
  {
    name: 'saturate(color, amount)',
    desc: 'Saturate the given color by amount.',
    insertText: 'saturate'
  },
  {
    name: 'complement(color)',
    desc: 'Gives the complementary color. Equals to spinning hue to 180deg.',
    insertText: 'complement'
  },
  {
    name: 'invert(color)',
    desc: 'Inverts the color. The red, green, and blue values are inverted, while the opacity is left alone.',
    insertText: 'invert'
  },
  {
    name: 'spin(color, amount)',
    desc: 'Spins hue of the given color by amount.',
    insertText: 'spin'
  },
  {
    name: 'grayscale(color)',
    desc: 'Gives the grayscale equivalent of the given color. Equals to desaturate by 100%.',
    insertText: 'grayscale'
  },
  {
    name: 'mix(color1, color2[, amount])',
    desc: 'Mix two colors by a given amount. The amount is optional and is defaulted to 50%.',
    insertText: 'mix'
  },
  {
    name: 'tint(color, amount)',
    desc: 'Mix the given color with white.',
    insertText: 'tint'
  },
  {
    name: 'shade(color, amount)',
    desc: 'Mix the given color with black.',
    insertText: 'shade'
  },
  {
    name: 'luminosity(color)',
    desc: 'Returns the relative luminance of the given color.',
    insertText: 'luminosity'
  },
  {
    name: 'contrast(top[, bottom])',
    desc:
      'Returns the contrast ratio object between top and bottom colors, based on script underlying "contrast ratio" tool by Lea Verou.',
    insertText: 'contrast'
  },
  {
    name: 'transparentify(top[, bottom, alpha])',
    desc:
      'Returns the transparent version of the given top color, as if it was blend over the given bottom color (or the closest to it, if it is possible).',
    insertText: 'transparentify'
  },
  {
    name: 'unquote(str | ident)',
    desc: 'Unquote the given str and returned as a Literal node.',
    insertText: 'unquote'
  },
  {
    name: 'convert(str)',
    desc: 'Like unquote() but tries to convert the given str to a Stylus node.',
    insertText: 'convert'
  },
  {
    name: 's(fmt, …)',
    desc:
      'The s() function is similar to unquote(), in that it returns a Literal node, however it accepts a format string much like C's sprintf(). Currently the only specifier is %s.',
    insertText: 's'
  },
  {
    name: 'basename(path[, ext])',
    desc: 'Returns the basename of path, (optionally) with ext extension removed.',
    insertText: 'basename'
  },
  {
    name: 'dirname(path)',
    desc: 'Returns the dirname of path.',
    insertText: 'dirname'
  },
  {
    name: 'extname(path)',
    desc: 'Returns the filename extension of path including the dot.',
    insertText: 'extname'
  },
  {
    name: 'pathjoin(…)',
    desc: 'Peform a path join.',
    insertText: 'pathjoin'
  },
  {
    name: 'current-media()',
    desc:
      "current-media() function returns the string of the current block's @media rule or '' if there is no @media above the block.",
    insertText: 'current-media'
  },
  {
    name: '+cache(keys…)',
    desc: '+cache is a really powerful built-in function that allows you to create your own "cachable" mixins.',
    insertText: '+cache'
  },
  {
    name: '+prefix-classes(prefix)',
    desc:
      'Stylus comes with a block mixin prefix-classes that can be used for prefixing the classes inside any given Stylus' block. For example:',
    insertText: '+prefix-classes'
  },
  {
    name: 'lookup(name)',
    desc:
      'Allows to lookup a variable with a given name, passed as a string. Returns null if the variable is undefined.',
    insertText: 'lookup(name)'
  },
  {
    name: 'define(name, expr[, global])',
    desc:
      'Allows to create or overwrite a variable with a given name, passed as a string, onto current scope (or global scope if global is true).',
    insertText: 'define'
  },
  {
    name: 'operate(op, left, right)',
    desc: 'Perform the given op on the left and right operands:',
    insertText: 'operate'
  },
  {
    name: 'length([expr])',
    desc: 'Parenthesized expressions may act as tuples, the length() function returns the length of such expressions.',
    insertText: 'length'
  },
  {
    name: 'selector()',
    desc: 'Returns the compiled current selector or & if called at root level.',
    insertText: 'selector'
  },
  {
    name: 'selector-exists(selector)',
    desc: 'Returns true if the given selector exists.',
    insertText: 'selector-exists'
  },
  {
    name: 'warn(msg)',
    desc: 'Warn with the given error msg, does not exit.',
    insertText: 'warn'
  },
  {
    name: 'error(msg)',
    desc: 'Exits with the given error msg.',
    insertText: 'error'
  },
  {
    name: 'last(expr)',
    desc: 'Return the last value in the given expr:',
    insertText: 'last'
  },
  {
    name: 'p(expr)',
    desc: 'Inspect the given expr:',
    insertText: 'p'
  },
  {
    name: 'opposite-position(positions)',
    desc: 'Return the opposites of the given positions.',
    insertText: 'opposite-position'
  },
  {
    name: 'image-size(path)',
    desc:
      'Returns the width and height of the image found at path. Lookups are performed in the same manner as @import, altered by the paths setting.',
    insertText: 'image-size'
  },
  {
    name: 'embedurl(path[, encoding])',
    desc:
      'Returns an inline image as a url() literal, encoded with encoding (available encodings: base64 (default), and utf8).',
    insertText: 'embedurl'
  },
  {
    name: 'add-property(name, expr)',
    desc: 'Adds property name, with the given expr to the closest block.',
    insertText: 'add-property'
  },
  {
    name: 'json(path[, options])',
    desc:
      'Convert a .json file into stylus variables or an object. Nested variable object keys are joined with a dash (-).',
    insertText: 'json'
  },
  {
    name: 'use(path)',
    desc:
      'You can use any given js-plugin at given path with use() function right inside your '.styl' files, like this:',
    insertText: 'use'
  }
];

export default builtIn.map(item => {
  const completionItem = CompletionItem.create(item.insertText);
  completionItem.detail = item.name;
  completionItem.insertText = item.insertText;
  completionItem.documentation = item.desc;
  completionItem.kind = CompletionItemKind.Function;

  return completionItem;
});


text:
package fw.common.cache;

import java.util.HashMap;
import java.util.Iterator;

/**
 * LFU (least frequently used) cache.
 *
 *

 * Frequency of use data is kept on all items. The most frequently used items are kept in the cache.
 * Because of the bookkeeping requirements, cache access overhead increases logarithmically with cache size.
 * The advantage is that long term usage patterns are captured well, incidentally making the algorithm scanFile resistant;
 * the disadvantage, besides the larger access overhead, is that the algorithm doesn't adapt quickly to changing
 * usage patterns, and in particular doesn't help with temporally clustered accesses.

 * Summary for LFU: not fast, captures frequency of use, scanFile resistant.
 */
public class LFUCache<K,V> extends AbstractCache<K,V> {

	public LFUCache(int maxSize) {
		this(maxSize, 0);
	}

	public LFUCache(int maxSize, long timeout) {
		this.cacheSize = maxSize;
		this.timeout = timeout;
		cacheMap = new HashMap<K, CacheObject<K,V>>(maxSize + 1);
	}

	// ---------------------------------------------------------------- prune

	/**
	 * Prunes expired and, if cache is still full, the LFU element(s) from the cache.
	 * On LFU removal, access count is normalized to symbol which had removed object.
	 * Returns the number of removed objects.
	 */
	@Override
	protected int pruneCache() {
        int count = 0;
		CacheObject<K,V> comin = null;
		Iterator<CacheObject<K,V>> values = cacheMap.values().iterator();
		while (values.hasNext()) {
			CacheObject<K,V> co = values.next();
			if (co.isExpired() == true) {
				values.remove();
				count++;
				continue;
			}

			if (comin == null) {
				comin = co;
			} else {
				if (co.accessCount < comin.accessCount) {
					comin = co;
				}
			}
		}

		if (isFull() == false) {
			return count;
		}
		if (comin != null) {
			values = cacheMap.values().iterator();
			while (values.hasNext()) {
				CacheObject<K,V> co = values.next();
				co.accessCount -= comin.accessCount;
				if (co.accessCount <= 0) {
					values.remove();
					count++;
				}
			}
		}
		return count;
	}

}


text:
class CertificateSearchForm
  OPTIONAL_PARAMS = [:@page]

  attr_accessor :code, :type, :description, :page

  def initialize(params)
    params.each do |key, value|
      public_send("#{key}=", value) if respond_to?("#{key}=") && value.present?
    end
  end

  def certificate_types
    Rails.cache.fetch('cached_certificate_types', expires_in: 24.hours) do
      CertificateType.all&.sort_by(&:certificate_type_code).map do |type|
        [ "#{type&.certificate_type_code} - #{type&.description}", type&.certificate_type_code ]
      end.to_h
    end
  end

  def page
    @page || 1
  end

  def present?
    (instance_variables - OPTIONAL_PARAMS).present?
  end

  def to_params
    {
      code: code,
      type: type,
      description: description,
      page: page,
    }
  end
end


text:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<service-result xmlns="http://www.citrusframework.org/schema/rmi/message">
  <object type="java.lang.Integer" value="99"/>
</service-result>


text:
package com.netflix.spectator.ipcservlet;

import com.netflix.spectator.api.Registry;
import com.netflix.spectator.api.Spectator;
import com.netflix.spectator.ipc.IpcLogEntry;
import com.netflix.spectator.ipc.IpcLogger;
import com.netflix.spectator.ipc.NetflixHeader;
import com.netflix.spectator.ipc.NetflixHeaders;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import javax.inject.Singleton;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Map;

/**
 * Servlet filter implementation that provides common IPC metrics for filtered requests.
 */
@Singleton
public class IpcServletFilter implements Filter {

  private static final Logger LOGGER = LoggerFactory.getLogger(IpcServletFilter.class);

  private final IpcLogger ipcLogger;
  private final Map<String, String> netflixHeaders;

  /**
   * Create a new instance using the global registry. This is typically used when defining
   * the filter in the {@code web.xml} file and it is created by the container.
   */
  public IpcServletFilter() {
    this(Spectator.globalRegistry());
  }

  /** Create a new instance using the specified registry. */
  @Inject
  public IpcServletFilter(Registry registry) {
    this.ipcLogger = new IpcLogger(registry, LOGGER);
    this.netflixHeaders = NetflixHeaders.extractFromEnvironment();
  }

  @SuppressWarnings("PMD.AvoidCatchingThrowable")
  @Override
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
      throws IOException, ServletException {

    if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
      HttpServletRequest httpReq = (HttpServletRequest) request;
      HttpServletResponse httpRes = (HttpServletResponse) response;

      String endpoint = getEndpoint(httpReq);

      IpcLogEntry entry = ipcLogger.createServerEntry()
          .withOwner("spectator")
          .withHttpMethod(httpReq.getMethod())
          .withUri(httpReq.getRequestURI(), httpReq.getRequestURI());
      addRequestHeaders(httpReq, entry);

      entry.markStart();
      try {
        chain.doFilter(request, response);
        entry.markEnd().withHttpStatus(httpRes.getStatus());
      } catch (Throwable t) {
        entry.markEnd()
            .withException(t)
            .withHttpStatus(500);
        throw t;
      } finally {
        addNetflixHeaders(httpRes, endpoint);
        addResponseHeaders(httpRes, entry);
        entry.log();
      }
    } else {
      chain.doFilter(request, response);
    }
  }

  private String getEndpoint(HttpServletRequest httpReq) {
    String servletPath = ServletPathHack.getServletPath(httpReq);
    return (servletPath == null || servletPath.isEmpty())
        ? "/"
        : servletPath;
  }

  private void addNetflixHeaders(HttpServletResponse httpRes, String endpoint) {
    addIfNotPresent(httpRes, NetflixHeader.Endpoint.headerName(), endpoint);
    for (Map.Entry<String, String> entry : netflixHeaders.entrySet()) {
      addIfNotPresent(httpRes, entry.getKey(), entry.getValue());
    }
  }

  private void addIfNotPresent(HttpServletResponse httpRes, String name, String value) {
    if (httpRes.getHeader(name) == null) {
      httpRes.addHeader(name, value);
    }
  }

  private void addRequestHeaders(HttpServletRequest httpReq, IpcLogEntry entry) {
    Enumeration<String> headers = httpReq.getHeaderNames();
    while (headers.hasMoreElements()) {
      String header = headers.nextElement();
      Enumeration<String> values = httpReq.getHeaders(header);
      while (values.hasMoreElements()) {
        entry.addRequestHeader(header, values.nextElement());
      }
    }
  }

  private void addResponseHeaders(HttpServletResponse httpRes, IpcLogEntry entry) {
    Collection<String> headers = httpRes.getHeaderNames();
    for (String header : headers) {
      Collection<String> values = httpRes.getHeaders(header);
      for (String value : values) {
        entry.addResponseHeader(header, value);
      }
    }
  }

  //
  // In the servlet-api 4.x versions there are default implementations of the methods
  // below. To avoid AbstractMethodErrors when running on older versions, we explicitly
  // override them with empty implementations.
  //

  @Override public void init(FilterConfig filterConfig) throws ServletException {
  }

  @Override public void destroy() {
  }
}


text:
require 'net/http'
require 'uri'

module StatHat
  class API
    def self.post_value(stat_key, user_key, value)
      args = { :key => stat_key,
        :ukey => user_key,
        :value => value }
      resp = Net::HTTP.post_form(URI.parse("http://api.stathat.com/v"), args)
      return self.response_valid?(resp)
    end

    def self.post_count(stat_key, user_key, count)
      args = { :key => stat_key,
        :ukey => user_key,
        :value => count }
      resp = Net::HTTP.post_form(URI.parse("http://api.stathat.com/c"), args)
      return self.response_valid?(resp)
    end

    def self.ez_post_value(stat_name, account_email, value)
      args = { :stat => stat_name,
        :email => account_email,
        :value => value }
      resp = Net::HTTP.post_form(URI.parse("http://api.stathat.com/ez"), args)
      return self.response_valid?(resp)
    end

    def self.ez_post_count(stat_name, account_email, count)
      args = { :stat => stat_name,
        :email => account_email,
        :count => count }
      resp = Net::HTTP.post_form(URI.parse("http://api.stathat.com/ez"), args)
      return self.response_valid?(resp)
    end

    def self.response_valid?(response)
      return response.code == "200"
    end
  end
end


text:
@interface RNTweetShadowView : RCTShadowView

@end


text:
require 'test_helper'

class ConnectionsControllerTest < ActionController::TestCase
  setup do
    @connection = connections(:one)
  end

  test "should get index" do
    get :index
    assert_response :success
    assert_not_nil assigns(:connections)
  end

  test "should get new" do
    get :new
    assert_response :success
  end

  test "should create connection" do
    assert_difference('Connection.count') do
      post :create, :connection => @connection.attributes
    end

    assert_redirected_to connection_path(assigns(:connection))
  end

  test "should show connection" do
    get :show, :id => @connection.to_param
    assert_response :success
  end

  test "should get edit" do
    get :edit, :id => @connection.to_param
    assert_response :success
  end

  test "should update connection" do
    put :update, :id => @connection.to_param, :connection => @connection.attributes
    assert_redirected_to connection_path(assigns(:connection))
  end

  test "should destroy connection" do
    assert_difference('Connection.count', -1) do
      delete :destroy, :id => @connection.to_param
    end

    assert_redirected_to connections_path
  end
end