text:
<!DOCTYPE html>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<meta charset="utf-8">
<title>Phing API Documentation » \TabToSpaces</title>
<meta name="author" content="Mike van Riel">
<meta name="description" content="">
<link href="../css/template.css" rel="stylesheet" media="all">
<link rel="shortcut icon" href="../img/favicon.ico">
<link rel="apple-touch-icon" href="../img/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="../img/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="../img/apple-touch-icon-114x114.png">

Phing API Documentation

                                    API Documentation

Packages

 Default

 JSMin

 Parallel

 Phing

 phing

                                    Charts

 Class hierarchy diagram

                                    Reports

 Errors
                2573

 Markers

todo
                15

fixme
                8

 Deprecated elements
                11

Back to top

                            Javascript is disabled; several features are only available
                            if Javascript is enabled.

<button class="btn public active" title="Show public elements">Public</button><button class="btn protected" title="Show protected elements">Protected</button><button class="btn private" title="Show private elements">Private</button><button class="btn inherited active" title="Show inherited elements">Inherited</button>

<button class="btn details" title="Show descriptions and method names"></button><button class="btn simple" title="Show only method names"></button>

 Methods

Constructor used by Phing's introspection mechanism.
__construct()

Creates a new TabsToSpaces using the passed in
Reader for instantiation.
chain()

Close stream.
close()

Returns whether the end of file has been reached with input stream.
eof()

Returns the initialized status.
getInitialized()

getParameters()

getParameters()

Returns the project this filter is part of.
getProject()

Returns the filename, url, etc.
getResource()

Returns the tab length.
getTablength()

Convenience method to support logging in filters.
log()

If supported, places a "marker" (like a bookmark) at current stream position.
mark()

Whether marking is supported.
markSupported()

Returns stream after converting tabs to the specified number of spaces.
read()

Reads a line of text ending with '\n' (or until the end of the stream).
readLine()

Is stream ready for reading.
ready()

Reset the current position in stream to beginning or last mark (if supported).
reset()

Sets the initialized status.
setInitialized()

setParameters()

setParameters()

Sets the project to work with.
setProject()

setReader()

setReader()

Sets the tab length.
setTablength()

Move stream position relative to current pos.
skip()

» Private

Parses the parameters to set the tab length.
_initialize()

 Properties

» Protected

$_parameters

$in

$initialized

$project

» Private

$tabLength

 Constants

The default tab length.
DEFAULT_TAB_LENGTH

Parameter name for the length of a tab.
TAB_LENGTH_KEY

\

global

\TabToSpaces

Converts tabs to spaces.

Example:

<tabtospaces tablength="8">

Or:

<filterreader classname="phing.filters.TabsToSpaces">
  <param name="tablength" value="8">
</filterreader>

author
Yannick Lecaillez

author
Hans Lellelid

version
$Id$

see
\global\BaseParamFilterReader

package
phing.filters

copyright
2003 seasonfive. All rights reserved

 Methods

Constructor used by Phing's introspection mechanism.

__construct(\Reader $in)

Inherited

The original filter reader is only used for chaining
purposes, never for filtering purposes (and indeed
it would be useless for filtering purposes, as it has
no real data to filter). ChainedReaderHelper uses
this placeholder instance to create a chain of real filters.

inherited_from
\BaseFilterReader::__construct()

inherited_from
\BaseParamFilterReader::__construct()

Parameters

$in

\Reader

Creates a new TabsToSpaces using the passed in
Reader for instantiation.

chain(\Reader $reader) : \Reader

Parameters

$reader

\Reader
A Reader object providing the underlying stream. Must not be null.

Returns

\ReaderA new filter based on this configuration, but filtering
        the specified reader

Close stream.

close()

Inherited

inherited_from
\FilterReader::close()

inherited_from
\BaseFilterReader::close()

inherited_from
\BaseParamFilterReader::close()

Exceptions

\IOException
if there is an error closing stream

Returns whether the end of file has been reached with input stream.

eof() : boolean

Inherited

inherited_from
\BaseFilterReader::eof()

inherited_from
\BaseParamFilterReader::eof()

Returns

boolean

Returns the initialized status.

getInitialized() : boolean

Inherited

inherited_from
\BaseFilterReader::getInitialized()

inherited_from
\BaseParamFilterReader::getInitialized()

Returns

booleanwhether or not the filter is initialized

getParameters()

getParameters()

Inherited

inherited_from
\BaseParamFilterReader::getParameters()

Returns the project this filter is part of.

getProject() : object

Inherited

inherited_from
\BaseFilterReader::getProject()

inherited_from
\BaseParamFilterReader::getProject()

Returns

objectThe project this filter is part of

Returns the filename, url, etc.

getResource() : string

Inherited

that is being read from.
This is critical for, e.g., ExpatParser's ability to know
the filename that is throwing an ExpatParserException, etc.

inherited_from
\FilterReader::getResource()

inherited_from
\BaseFilterReader::getResource()

inherited_from
\BaseParamFilterReader::getResource()

Returns

string

Returns the tab length.

getTablength() : int

Returns

intThe number of spaces used when converting a tab

Convenience method to support logging in filters.

log(string $msg, int $level)

Inherited

inherited_from
\BaseFilterReader::log()

inherited_from
\BaseParamFilterReader::log()

Parameters

$msg

string
Message to log.

$level

int
Priority level.

If supported, places a "marker" (like a bookmark) at current stream position.

mark()

Inherited

A subsequent call to reset() will move stream position back
to last marker (if supported).

inherited_from
\Reader::mark()

inherited_from
\FilterReader::mark()

inherited_from
\BaseFilterReader::mark()

inherited_from
\BaseParamFilterReader::mark()

Whether marking is supported.

markSupported() : boolean

Inherited

inherited_from
\Reader::markSupported()

inherited_from
\FilterReader::markSupported()

inherited_from
\BaseFilterReader::markSupported()

inherited_from
\BaseParamFilterReader::markSupported()

Returns

boolean

Returns stream after converting tabs to the specified number of spaces.

read(\off $len) : \the

FIXME: Clean up this function signature, as it a) params aren't being used
and b) it doesn't make much sense.

exception
IOException if the underlying stream throws an IOException
           during reading

Parameters

$len

\off
Offset at which to start storing characters.

Exceptions

\IOException
If an I/O error occurs

Returns

\theresulting stream, or -1
        if the end of the resulting stream has been reached

Reads a line of text ending with '\n' (or until the end of the stream).

readLine() : \the

Inherited

The returned String retains the '\n'.

inherited_from
\BaseFilterReader::readLine()

inherited_from
\BaseParamFilterReader::readLine()

Exceptions

\IOException
if the underlying reader throws one during
                       reading

Returns

\theline read, or null if the end of the
stream has already been reached

Is stream ready for reading.

ready() : boolean

Inherited

inherited_from
\Reader::ready()

inherited_from
\FilterReader::ready()

inherited_from
\BaseFilterReader::ready()

inherited_from
\BaseParamFilterReader::ready()

Returns

boolean

Reset the current position in stream to beginning or last mark (if supported).

reset()

Inherited

inherited_from
\FilterReader::reset()

inherited_from
\BaseFilterReader::reset()

inherited_from
\BaseParamFilterReader::reset()

Sets the initialized status.

setInitialized(boolean $initialized)

Inherited

inherited_from
\BaseFilterReader::setInitialized()

inherited_from
\BaseParamFilterReader::setInitialized()

Parameters

$initialized

boolean
Whether or not the filter is initialized.

setParameters()

setParameters($parameters)

Inherited

inherited_from
\BaseParamFilterReader::setParameters()

Parameters

$parameters

Sets the project to work with.

setProject(\Project $project)

Inherited

inherited_from
\BaseFilterReader::setProject()

inherited_from
\BaseParamFilterReader::setProject()

Parameters

$project

object
The project this filter is part of. Should not be null.

setReader()

setReader(\Reader $in)

Inherited

inherited_from
\FilterReader::setReader()

inherited_from
\BaseFilterReader::setReader()

inherited_from
\BaseParamFilterReader::setReader()

Parameters

$in

Sets the tab length.

setTablength(int $tabLength)

Parameters

$tabLength

int
The number of spaces to be used when converting a tab.

Move stream position relative to current pos.

skip(int $n)

Inherited

inherited_from
\FilterReader::skip()

inherited_from
\BaseFilterReader::skip()

inherited_from
\BaseParamFilterReader::skip()

Parameters

$n

int

Parses the parameters to set the tab length.

_initialize()

 Properties

$_parameters

Inherited

inherited_from
\BaseParamFilterReader::$$_parameters

$in : \Reader

Inherited

inherited_from
\FilterReader::$$in

inherited_from
\BaseFilterReader::$$in

inherited_from
\BaseParamFilterReader::$$in

$initialized

Inherited

inherited_from
\BaseFilterReader::$$initialized

inherited_from
\BaseParamFilterReader::$$initialized

$project

Inherited

inherited_from
\BaseFilterReader::$$project

inherited_from
\BaseParamFilterReader::$$project

$tabLength : int

 Constants

The default tab length.

DEFAULT_TAB_LENGTH : int

Parameter name for the length of a tab.

TAB_LENGTH_KEY : string

            Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.

            Documentation is powered by phpDocumentor 2.0.0a11 and

            generated on 2012-11-20T07:50:48+01:00.


text:
package org.apache.lens.cube.parse;

import static org.apache.lens.cube.parse.CandidateTablePruneCause.CandidateTablePruneCode.FACT_NOT_AVAILABLE_IN_RANGE;
import static org.apache.lens.cube.parse.CubeTestSetup.*;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

import org.apache.lens.server.api.error.LensException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.parse.ParseException;

import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class TestTimeRangeResolver extends TestQueryRewrite {

  private final String cubeName = CubeTestSetup.TEST_CUBE_NAME;

  private Configuration conf;

  @BeforeTest
  public void setupDriver() throws Exception {
    conf = new Configuration();
    conf.set(CubeQueryConfUtil.DRIVER_SUPPORTED_STORAGES, "C1,C2");
    conf.setBoolean(CubeQueryConfUtil.DISABLE_AUTO_JOINS, true);
    conf.setBoolean(CubeQueryConfUtil.ENABLE_SELECT_TO_GROUPBY, true);
    conf.setBoolean(CubeQueryConfUtil.ENABLE_GROUP_BY_TO_SELECT, true);
    conf.setBoolean(CubeQueryConfUtil.DISABLE_AGGREGATE_RESOLVER, false);
  }

  @Override
  public Configuration getConf() {
    return new Configuration(conf);
  }

  @Test
  public void testFactValidity() throws ParseException, LensException, HiveException, ClassNotFoundException {
    LensException e =
      getLensExceptionInRewrite("cube select msr2 from " + cubeName + " where " + LAST_YEAR_RANGE,
        getConf());
    PruneCauses.BriefAndDetailedError causes = extractPruneCause(e);
    assertTrue(causes.getBrief().contains("Columns [msr2] are not present in any table"));
    assertEquals(causes.getDetails().size(), 2);
    assertEquals(causes.getDetails().values().iterator().next().size(), 1);
    assertEquals(causes.getDetails().values().iterator().next().iterator().next().getCause(),
      FACT_NOT_AVAILABLE_IN_RANGE);
  }

  @Test
  public void testAbsoluteValidity() throws ParseException, HiveException, LensException {
    CubeQueryContext ctx =
      rewriteCtx("cube select msr12 from basecube where " + TWO_DAYS_RANGE + " or " + TWO_DAYS_RANGE_BEFORE_4_DAYS,
        getConf());
    assertEquals(ctx.getFactPruningMsgs().get(ctx.getMetastoreClient().getCubeFact("testfact_deprecated")).size(), 1);
    CandidateTablePruneCause pruningMsg =
      ctx.getFactPruningMsgs().get(ctx.getMetastoreClient().getCubeFact("testfact_deprecated")).get(0);
    // testfact_deprecated's validity should be in between of both ranges. So both ranges should be in the invalid list
    // That would prove that parsing of properties has gone through successfully
    assertEquals(pruningMsg.getCause(), FACT_NOT_AVAILABLE_IN_RANGE);
    assertTrue(pruningMsg.getInvalidRanges().containsAll(ctx.getTimeRanges()));
  }
}

redpajama_set_name: RedPajamaGithub


text:
#include "../../SDL_internal.h"

extern int SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color);
extern int SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color);

/* vi: set ts=4 sw=4 expandtab: */


text:
require_relative 'all_jobs_shared'

class CopySourceJob < Remi::Job
  source :source_data do
    fields(
      {
        :some_field => {},
        :some_date => { type: :date, format: '%Y-%m-%d' }
      }
    )
  end

  target :target_data

  transform :main do
    target_data.df = source_data.df.dup
  end
end


text:
**Please read https://github.com/inorichi/tachiyomi/blob/master/.github/CONTRIBUTING.md before posting**

Remove line above and describe your issue here. Fill out version below. Use Preview.

Version: r000 or v0.0.0
(other relevant info like OS)


text:
#import "SBVolumePressBandit-Protocol.h"

@protocol SBTestRecipe <SBVolumePressBandit>
+ (id)title;
@end


text:
class BrownProperty < ColouredProperty
  after_initialize :set_colour

  private

  def set_colour
    self.colour = :brown
  end
end


text:
package org.mybatis.scala.samples.select

import org.mybatis.scala.mapping._
import org.mybatis.scala.config._
import org.mybatis.scala.session._
import org.mybatis.scala.samples.util._

// Model beans =================================================================

class Person {
  var id : Int = _
  var firstName : String = _
  var lastName : String = _
}

// Data access layer ===========================================================

object DB {

  // Simple select function
  val findAll = new SelectListBy[String,Person] {
    def xsql =
      """
        SELECT
          id_ as id,
          first_name_ as firstName,
          last_name_ as lastName
        FROM
          person
        WHERE
          first_name_ LIKE #{name}
      """
  }

  // Datasource configuration
  val config = Configuration(
    Environment(
      "default",
      new JdbcTransactionFactory(),
      new PooledDataSource(
        "org.hsqldb.jdbcDriver",
        "jdbc:hsqldb:mem:scala",
        "sa",
        ""
      )
    )
  )

  // Add the data access method to the default namespace
  config += findAll
  config ++= DBSchema
  config ++= DBSampleData

  // Build the session manager
  lazy val context = config.createPersistenceContext

}

// Application code ============================================================

object SelectSample {

  // Do the Magic ...
  def main(args : Array[String]) : Unit = {
    DB.context.transaction { implicit session =>

      DBSchema.create
      DBSampleData.populate

      DB.findAll("%a%").foreach { p =>
        println( "Person(%d): %s %s".format(p.id, p.firstName, p.lastName) )
      }

    }
  }

}


text:
package ru.job4j.controllers;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.FileCleanerCleanup;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.FileCleaningTracker;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import ru.job4j.dao.BodyDAO;
import ru.job4j.dao.BrandDAO;
import ru.job4j.dao.CarDAO;
import ru.job4j.dao.EngineDAO;
import ru.job4j.dao.ImageDAO;
import ru.job4j.dao.ModelDAO;
import ru.job4j.dao.OrderDAO;
import ru.job4j.dao.TransmissionDAO;
import ru.job4j.models.Body;
import ru.job4j.models.Brand;
import ru.job4j.models.Car;
import ru.job4j.models.Engine;
import ru.job4j.models.Image;
import ru.job4j.models.Model;
import ru.job4j.models.Order;
import ru.job4j.models.Transmission;
import ru.job4j.models.User;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

/**
 * operation on add page(add order).
 */
@Controller
public class AddOrderController {
    /**
     * Logger.
     */
    private static final Logger LOG = LoggerFactory.getLogger(AddOrderController.class);

    /**
     * orderDAO.
     */
    private final OrderDAO orderDAO;
    /**
     * brandDAO.
     */
    private final BrandDAO brandDAO;
    /**
     * modelDAO.
     */
    private final ModelDAO modelDAO;
    /**
     * engineDAO.
     */
    private final EngineDAO engineDAO;
    /**
     * transmissionDAO.
     */
    private final TransmissionDAO transmissionDAO;
    /**
     * bodyDAO.
     */
    private final BodyDAO bodyDAO;
    /**
     * imageDAO.
     */
    private final ImageDAO imageDAO;
    /**
     * carDAO.
     */
    private final CarDAO carDAO;

    /**
     * Constructor.
     * @param orderDAO - orderDAO.
     * @param brandDAO - brandDAO.
     * @param modelDAO - modelDAO.
     * @param engineDAO - engineDAO.
     * @param transmissionDAO - transmissionDAO.
     * @param bodyDAO - bodyDAO.
     * @param imageDAO - imageDAO.
     * @param carDAO - carDAO.
     */
    @Autowired
    public AddOrderController(OrderDAO orderDAO, BrandDAO brandDAO,
                              ModelDAO modelDAO, EngineDAO engineDAO,
                              TransmissionDAO transmissionDAO, BodyDAO bodyDAO,
                              ImageDAO imageDAO, CarDAO carDAO) {
        this.orderDAO = orderDAO;
        this.brandDAO = brandDAO;
        this.modelDAO = modelDAO;
        this.engineDAO = engineDAO;
        this.transmissionDAO = transmissionDAO;
        this.bodyDAO = bodyDAO;
        this.imageDAO = imageDAO;
        this.carDAO = carDAO;
    }

    /**
     * show add page.
     * @return - add.jsp.
     * @throws IOException = exc.
     */
    @RequestMapping(value = "/add", method = RequestMethod.GET)
    public String showUsers() throws IOException {
        return "add";
    }

    /**
     * add order.
     * @param request - req.
     * @param session - session.
     * @return - add.jsp.
     */
    @Transactional
    @PostMapping(value = "/addOrder", consumes = "application/json;charset=UTF-8")
    public String addOrder(HttpServletRequest request, HttpSession session) {

        String jsonBody = "fff";
        // interesting part for control request content.
        try {
            jsonBody = IOUtils.toString(request.getInputStream());
        } catch (IOException e) {
            LOG.error(e.getMessage(), e);
        }

        ObjectMapper mapper = new ObjectMapper();
        Order obj = null;
        try {
            obj = mapper.readValue(jsonBody, Order.class);
        } catch (IOException e) {
            LOG.error(e.getMessage(), e);
        }
        obj.setDate(new Timestamp(System.currentTimeMillis()));
        obj.setUser((User) session.getAttribute("user"));
        Car car = obj.getCar();
        Model md = modelDAO.getModelByName(car.getModel().getName());
        Body bd = bodyDAO.getBodyByName(car.getBody().getName());
        Transmission td = transmissionDAO.getTransmissionByName(car.getTransmission().getName());
        Engine ed = engineDAO.getEngineByName(car.getEngine().getName());
        car.setBody(bd);
        car.setModel(md);
        car.setTransmission(td);
        car.setEngine(ed);
        carDAO.save(car);
        int orderId = orderDAO.save(obj).getId();
        session.setAttribute("order_id", orderId);

        return "add";
    }

    /**
     * add image.
     * @param session - session.
     * @param req - req.
     * @return - true, if success operation.
     * @throws IOException - exc.
     * @throws ServletException - exc.
     */
    @ResponseBody
    @PostMapping(value = "/addImage")
    public String addImage(HttpSession session, HttpServletRequest req) throws IOException, ServletException {
        boolean isMultipartContent = ServletFileUpload.isMultipartContent(req);
        Integer userId = (int) session.getAttribute("user_id");
        Integer orderId = (int) session.getAttribute("order_id");
        Order order = null;
        if (orderDAO.findById(orderId).isPresent()) {
            order = orderDAO.findById(orderId).get();
        }

        ObjectMapper mapper = new ObjectMapper();
        ObjectNode node = mapper.createObjectNode();
        node.put("success", false);

        if (isMultipartContent && userId != -1 && orderId != -1) {
            DiskFileItemFactory factory = new DiskFileItemFactory();
            ServletContext context = ((ServletRequestAttributes) RequestContextHolder.
                    getRequestAttributes()).getRequest().getServletContext();

            FileCleaningTracker tracker = FileCleanerCleanup.getFileCleaningTracker(context);
            factory.setFileCleaningTracker(tracker);
            File repository = (File) context.getAttribute("javax.servlet.context.tempdir");
            factory.setRepository(repository);

            ServletFileUpload upload = new ServletFileUpload(factory);
            try {
                List<FileItem> items = upload.parseRequest(req);
                for (FileItem item : items) {
                    byte[] imageData = item.get();
                    Image image = new Image();
                    image.setData(imageData);
                    image.setOrder(order);
                    imageDAO.save(image);
                    order.getImages().add(image);

                }
                node.put("success", true);
            } catch (FileUploadException fue) {
                fue.printStackTrace();
            }
        }

        return mapper.writeValueAsString(node);
    }

    /**
     * get all brands from db.
     * @return - brands.
     * @throws IOException - exc.
     */
    @RequestMapping(value = "/getBrands", method = RequestMethod.GET, produces = "application/json")
    @ResponseBody
    public String getBrands() throws IOException {
        List<Brand> list = (List<Brand>) brandDAO.findAll();
        ObjectMapper mapper = new ObjectMapper();
        return mapper.writeValueAsString(list);
    }

    /**
     * get all transmissions from db.
     * @return - transmissions.
     * @throws IOException - exc.
     */
    @RequestMapping(value = "/getTransmissions", method = RequestMethod.GET, produces = "application/json")
    @ResponseBody
    public String getTransmissions() throws IOException {
        List<Transmission> list = (List<Transmission>) transmissionDAO.findAll();
        ObjectMapper mapper = new ObjectMapper();
        return mapper.writeValueAsString(list);
    }
    /**
     * get all models from db.
     * @param brand - brand.
     * @return - models.
     * @throws IOException - exc.
     */
    @RequestMapping(value = "/getModels", method = RequestMethod.GET, produces = "application/json")
    @ResponseBody
    public String getModels(@RequestParam("brand") String brand) throws IOException {
        List<Model> list = (List<Model>) modelDAO.findAll();
        List<Model> newlist = new ArrayList<>();
        for (Model next : list) {
            if (next.getBrand().getName().equals(brand)) {
                newlist.add(next);
            }
        }
        ObjectMapper mapper = new ObjectMapper();
        return mapper.writeValueAsString(newlist);
    }
    /**
     * get all engines from db.
     * @return - engines.
     * @throws IOException - exc.
     */
    @RequestMapping(value = "/getEngines", method = RequestMethod.GET, produces = "application/json")
    @ResponseBody
    public String getEngines() throws IOException {
        List<Engine> list = (List<Engine>) engineDAO.findAll();
        ObjectMapper mapper = new ObjectMapper();
        return mapper.writeValueAsString(list);
    }
    /**
     * get all bodies from db.
     * @return - bodies.
     * @throws IOException - exc.
     */
    @RequestMapping(value = "/getBodies", method = RequestMethod.GET, produces = "application/json")
    @ResponseBody
    public String getBodies() throws IOException {
        List<Body> list = (List<Body>) bodyDAO.findAll();
        ObjectMapper mapper = new ObjectMapper();
        return mapper.writeValueAsString(list);
    }
}


text:
from mongoengine import Document, StringField
from mongoengine import BooleanField, DynamicEmbeddedDocument
from django.conf import settings

from crits.core.crits_mongoengine import CritsBaseAttributes, CritsDocument
from crits.core.crits_mongoengine import CritsDocumentFormatter, CritsSourceDocument
from crits.core.crits_mongoengine import CritsActionsDocument, MartiRFIDocument
from crits.domains.migrate import migrate_domain

class TLD(CritsDocument, Document):
    """
    TLD class for adding TLDs to the database.
    """

    meta = {
        "collection": settings.COL_EFFECTIVE_TLDS,
        "crits_type": 'TLD',
        "latest_schema_version": 1,
        "schema_doc": {
            'tld': 'The domain TLD',
        },
    }

    tld = StringField(required=True)

class EmbeddedWhoIs(DynamicEmbeddedDocument, CritsDocumentFormatter):
    """
    EmbeddedWhoIs Class.
    """

    meta = {
        'allow_inheritance': False
    }

class Domain(CritsBaseAttributes, CritsSourceDocument, CritsActionsDocument,
             Document, MartiRFIDocument):
    """
    Domain Class.
    """

    meta = {
        "collection": settings.COL_DOMAINS,
        "crits_type": 'Domain',
        "latest_schema_version": 3,
        "schema_doc": {
            'analyst': 'Analyst who added/modified this domain',
            'domain': 'The domain name of this domain',
            'type': 'Record type of this domain',
            'watchlistEnabled': 'Boolean - whether this is a domain to watch',
        },
        "jtable_opts": {
                         'details_url': 'crits.domains.views.domain_detail',
                         'details_url_key': 'domain',
                         'default_sort': "domain ASC",
                         'searchurl': 'crits.domains.views.domains_listing',
                         'fields': [ "domain", "modified", "source",
                                     "campaign", "status", "id"],
                         'jtopts_fields': [ "details",
                                            "domain",
                                            "modified",
                                            "source",
                                            "campaign",
                                            "status",
                                            "favorite",
                                            "id"],
                         'hidden_fields': [],
                         'linked_fields': ["source", "campaign"],
                         'details_link': 'details',
                         'no_sort': ['details']
                       }

    }

    domain = StringField(required=True)
    record_type = StringField(default="A", db_field="type")
    watchlistEnabled = BooleanField(default=False)
    analyst = StringField()

    def get_url_key(self):
        """
        Return the identifier for this item
        """
        return self.domain

    def migrate(self):
        """
        Migrate to the latest schema version.
        """

        migrate_domain(self)

    def _custom_save(self, force_insert=False, validate=True, clean=False,
        write_concern=None, cascade=None, cascade_kwargs=None,
        _refs=None, username=None, **kwargs):
        """
        Custom save. Overrides default core custom save function.
        """

        #TODO: parse for potential root domain and add it as well?
        # - would require adding relationships between the two as well
        return super(self.__class__, self)._custom_save(force_insert, validate,
            clean, write_concern, cascade, cascade_kwargs, _refs, username)


text:
<?php

namespace app\modules\Weixin;

class Module extends \yii\base\Module
{
    public $controllerNamespace = 'app\modules\Weixin\controllers';

    public static  $abc='affdadsf';
    public function init()
    {
        parent::init();

        // custom initialization code goes here
    }

    public static function  getUser(){
    	echo 'users';
    }
}


text:
#ifndef _CLINK_MEDIA_FORMAT_H_
#define _CLINK_MEDIA_FORMAT_H_

#include <cybergarage/io/File.h>

namespace CyberLink {

class FormatObject;

class Format
{
	////////////////////////////////////////////////
	//	Constructor
	////////////////////////////////////////////////

public:
		Format()
		{
		}

		virtual ~Format()
		{
		}

	////////////////////////////////////////////////
	//	abstruct methods
	////////////////////////////////////////////////

public:

	virtual FormatObject *createObject(CyberIO::File *file) = 0;
	virtual bool equals(CyberIO::File *file) = 0;
	virtual const char *getMimeType() = 0;
	virtual const char *getMediaClass() = 0;
};

}

#endif


text:
cd terraform
terraform init
terraform apply -auto-approve


text:
module Interface.LpSolve where

-- standard modules

-- local modules
import Helpful.Process

--import Data.Time.Clock (diffUTCTime, getCurrentTime)
--import Debug.Trace

zeroObjective :: String -> Maybe Bool
zeroObjective p = case head answer of
    "This problem is infeasible" -> Nothing
    "This problem is unbounded" -> Just False
    otherwise -> do
        let (chattering, value) = splitAt 29 (answer!!1)
        if chattering == "Value of objective function: " then
            if (read value :: Float) == 0.0 then
                Just True
            else
                Just False
        else
            error $ "lp_solve answered in an unexpected way.\n" ++
                "Expected Answer: \"Value of objective function: " ++
                "NUMBER\"\nActual Answer: " ++ lpAnswer
  where
    lpAnswer = unsafeReadProcess "lp_solve" [] p
    answer = lines lpAnswer

-- old version
--zeroObjective :: String -> Maybe Bool
--zeroObjective p = unsafePerformIO $ do
----    start <- getCurrentTime
--    (_, clpAnswer, _) <- readProcessWithExitCode "lp_solve" [] p
--    let answer = lines clpAnswer
----    end <- getCurrentTime
----    print $ (show (end `diffUTCTime` start) ++ " elapsed. ") ++ clpAnswer
--    case head answer of
--        "This problem is infeasible" -> return Nothing
--        "This problem is unbounded" -> return $ Just False
--        otherwise -> do
--            let (chattering, value) = splitAt 29 (answer!!1)
--            if chattering == "Value of objective function: " then
--                if (read value :: Float) == 0.0 then
--                    return $ Just True
--                else
--                    return $ Just False
--            else
--                error $ "lp_solve answered in an unexpected way.\n" ++
--                    "Expected Answer: \"Value of objective function: " ++
--                    "NUMBER\"\nActual Answer: " ++ clpAnswer
--{-# NOINLINE zeroObjective #-}


text:
module HarassForCash
  class App < Sinatra::Base
    include Helpers

    get '/hackers' do
      @hackers = Hacker.all
      slim :hackers
    end

    get '/hackers/current' do
      @hackers = Event.current.hackers
      slim :hackers
    end

    get '/hackers/new/:qr' do |qr|
      halt(500, "Bad Registration Code") unless Code.first(code: qr)

      @qr = qr
      slim :new_hacker
    end

    post '/hackers' do #CREATE HACKER
      code = Code.first code: params[:qr]
      halt 404 unless code

      new_hacker = Hacker.create name: params[:full_name], email: params[:email], phone: params[:phone], school: params[:school], qr: code.code, event: current_or_next_event
      if new_hacker.present?
        code.destroy
        flash[:success] = "Hacker Created."
        enter_hacker new_hacker
        redirect '/hackers/current'
      else
        flash[:danger] = "Something went wrong while trying to save the hacker. Try again."
        redirect "/hackers/new/#{params[:qr]}"
      end
    end

    private
      def enter_hacker(hacker)
        raffle = current_or_next_event.raffles.detect { |r| is_current?(r) }
        raffle ||= current_or_next_event.raffles.where(:start_time.gte => Time.now.utc).sort(:start_time).first
        unless raffle.entries.any? { |h| h["id"] == hacker.id}
          raffle.entries << { id: hacker.id, email: hacker.email, phone: hacker.phone }
          raffle.save
        end
      end

      def current_or_next_event
        @event ||= get_current_or_next_event
      end

      def get_current_or_next_event
        if Event.current.present?
          Event.current
        else
          Event.where(:start_time.gte => Time.now.utc).sort(:start_time).first
        end
      end

  end
end


text:
import matplotlib.pyplot as plt
import numpy as np
from thermo import *
from fluids.numerics import logspace
from math import log10

obj = PRTranslatedConsistent(Tc=190.564, Pc=4599000.0, omega=0.008, T=300., P=1e5)
obj.volume_errors(show=True, plot=True, pts=7)


text:
"""
Implementations of standard WordPress XML-RPC APIs.
"""
from wordpress_xmlrpc.methods import posts
from wordpress_xmlrpc.methods import pages
from wordpress_xmlrpc.methods import demo
from wordpress_xmlrpc.methods import users
from wordpress_xmlrpc.methods import options
from wordpress_xmlrpc.methods import comments


text:
package org.jenkins.ci.plugins.jenkinslint.check;

import hudson.model.Item;
import org.jenkins.ci.plugins.jenkinslint.model.AbstractCheck;

/**
 * @author Victor Martinez
 */
public class JobNameChecker extends AbstractCheck{

    public JobNameChecker() {
        super();
        this.setDescription("When creating Jenkins Jobs you must avoid whitespace. In order to comply with the style " +
                            "guide");
        this.setSeverity("High");
    }

    public boolean executeCheck(Item item) {
        return item.getName().contains(" ");
    }
}


text:
from kivy_ios.toolchain import CythonRecipe

class PyobjusRecipe(CythonRecipe):
    version = "master"
    url = "https://github.com/kivy/pyobjus/archive/{version}.zip"
    library = "libpyobjus.a"
    depends = ["python"]
    pre_build_ext = True

recipe = PyobjusRecipe()