text:
////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2015 the original author or authors.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
////////////////////////////////////////////////////////////////////////////////

package com.puppycrawl.tools.checkstyle;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Set;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import com.google.common.collect.Sets;
import com.google.common.io.Closeables;
import com.puppycrawl.tools.checkstyle.api.AbstractLoader;
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
import com.puppycrawl.tools.checkstyle.utils.CommonUtils;

/**
 * Loads a list of package names from a package name XML file.
 * @author Rick Giles
 */
public final class PackageNamesLoader
    extends AbstractLoader {
    /** The public ID for the configuration dtd. */
    private static final String DTD_PUBLIC_ID =
        "-//Puppy Crawl//DTD Package Names 1.0//EN";

    /** The resource for the configuration dtd. */
    private static final String DTD_RESOURCE_NAME =
        "com/puppycrawl/tools/checkstyle/packages_1_0.dtd";

    /** Name of default checkstyle package names resource file.
     * The file must be in the classpath.
     */
    private static final String CHECKSTYLE_PACKAGES =
        "checkstyle_packages.xml";

    /** Qualified name for element 'package'. */
    private static final String PACKAGE_ELEMENT_NAME = "package";

    /** The temporary stack of package name parts. */
    private final Deque<String> packageStack = new ArrayDeque<>();

    /** The fully qualified package names. */
    private final Set<String> packageNames = Sets.newLinkedHashSet();

    /**
     * Creates a new {@code PackageNamesLoader} instance.
     * @throws ParserConfigurationException if an error occurs
     * @throws SAXException if an error occurs
     */
    private PackageNamesLoader()
        throws ParserConfigurationException, SAXException {
        super(DTD_PUBLIC_ID, DTD_RESOURCE_NAME);
    }

    @Override
    public void startElement(String uri,
                             String localName,
                             String qName,
                             Attributes attributes) {
        if (PACKAGE_ELEMENT_NAME.equals(qName)) {
            //push package name, name is mandatory attribute with not empty value by DTD
            final String name = attributes.getValue("name");
            packageStack.push(name);
        }
    }

    /**
     * Creates a full package name from the package names on the stack.
     * @return the full name of the current package.
     */
    private String getPackageName() {
        final StringBuilder buf = new StringBuilder();
        final Iterator<String> iterator = packageStack.descendingIterator();
        while (iterator.hasNext()) {
            final String subPackage = iterator.next();
            buf.append(subPackage);
            if (!CommonUtils.endsWithChar(subPackage, '.')) {
                buf.append('.');
            }
        }
        return buf.toString();
    }

    @Override
    public void endElement(String uri,
                           String localName,
                           String qName) {
        if (PACKAGE_ELEMENT_NAME.equals(qName)) {

            packageNames.add(getPackageName());
            packageStack.pop();
        }
    }

    /**
     * Returns the set of package names, compiled from all
     * checkstyle_packages.xml files found on the given class loaders
     * classpath.
     * @param classLoader the class loader for loading the
     *          checkstyle_packages.xml files.
     * @return the set of package names.
     * @throws CheckstyleException if an error occurs.
     */
    public static Set<String> getPackageNames(ClassLoader classLoader)
            throws CheckstyleException {

        Set<String> result;
        try {
            //create the loader outside the loop to prevent PackageObjectFactory
            //being created anew for each file
            final PackageNamesLoader namesLoader = new PackageNamesLoader();

            final Enumeration<URL> packageFiles = classLoader.getResources(CHECKSTYLE_PACKAGES);

            while (packageFiles.hasMoreElements()) {
                final URL packageFile = packageFiles.nextElement();
                InputStream stream = null;

                try {
                    stream = new BufferedInputStream(packageFile.openStream());
                    final InputSource source = new InputSource(stream);
                    namesLoader.parseInputSource(source);
                }
                catch (IOException e) {
                    throw new CheckstyleException("unable to open " + packageFile, e);
                }
                finally {
                    Closeables.closeQuietly(stream);
                }
            }

            result = namesLoader.packageNames;

        }
        catch (IOException e) {
            throw new CheckstyleException("unable to get package file resources", e);
        }
        catch (ParserConfigurationException | SAXException e) {
            throw new CheckstyleException("unable to open one of package files", e);
        }

        return result;
    }
}


text:
{-

  Set up an example Sqlite database and execute a couple of example queries
	-- Toon Nolten

-}

import Database.HDBC
import Database.HDBC.Sqlite3 (connectSqlite3)
import Data.List

create_TopGear_table :: IConnection conn => conn -> IO Integer
create_TopGear_table conn =
    run conn
	"CREATE TABLE lap_times (Model CHAR(20), Time CHAR(6), Wet BOOL)"
	[]

prepare_insert_rows :: IConnection conn => conn -> IO Statement
prepare_insert_rows conn =
    prepare conn "INSERT INTO lap_times VALUES (?, ?, ?)"

initial_rows :: [[SqlValue]]
initial_rows = zipWith3 (\model time wet ->
			  [toSql model, toSql time, toSql wet])
		   ["Ascari A10", "Koenigsegg CCX",
		    "Pagani Zonda C12 F", "Maserati MC12"]
		   ["1:17.3", "1:17.6", "1:18.4", "1:18.9"]
		   [False, True, False, False]

main = handleSqlError $ do
	conn <- connectSqlite3 "TopGear.sqlite"
	create_TopGear_table conn
	insert_stmt <- prepare_insert_rows conn
	executeMany insert_stmt initial_rows
	r <- quickQuery' conn "SELECT Model, Time, Wet from lap_times ORDER BY Time" []
	let stringRows = map convRow r
	mapM_ putStrLn stringRows
	commit conn
	disconnect conn
	where convRow :: [SqlValue] -> String
	      convRow [sqlModel, sqlTime, sqlWet] =
		show model ++ " -- " ++ time ++ " -- " ++ wet
		where model = case fromSql sqlModel of
				Just x -> x
				Nothing -> "NULL"
		      time = case fromSql sqlTime of
				Just x -> x
				Nothing -> "NULL"
		      wet = fromSql sqlWet
	      convRow x = fail $ "Unexpected result: " ++ show x

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <gradient
     android:startColor="@color/es_white"
     android:endColor="@color/es_white"
     />

    <padding
        android:left="0dp"
        android:top="0dp"
        android:right="0dp"
        android:bottom="0dp" />

</shape>


text:
/**
   Extremely simple singly-linked list of int-keyed data items.
 */

#ifndef LIST_IP_H
#define LIST_IP_H

#include <stdbool.h>
#include <stdio.h>

// Maximum size of a list_ip datum
#define LIST_IP_MAX_DATUM 100

struct list_ip_item
{
  int   key;
  void* data;
  struct list_ip_item* next;
};

struct list_ip
{
  struct list_ip_item* head;
  struct list_ip_item* tail;
  int size;
};

void list_ip_init(struct list_ip* target);

struct list_ip* list_ip_create(void);

void list_ip_append(struct list_ip* target, int key, void* data);

bool list_ip_add(struct list_ip* target, int key, void* data);

//struct list_ip_item* list_ip_replace(struct list_ip* target,
//                                 int key, void* data);

bool list_ip_contains(const struct list_ip* target, int key);

bool list_ip_matches(const struct list_ip* target,
                     int (*cmp)(void*,void*), void* data);

struct list_ip_item* list_ip_ordered_insert(struct list_ip* target,
                                        int key, void* data);
struct list_ip_item*
list_ip_ordered_insert_unique(struct list_ip* target,
                            int (*cmp)(void*,void*),
                            int key, void* data);

void* list_ip_pop(struct list_ip* target);

void* list_ip_poll(struct list_ip* target);

void* list_ip_get(struct list_ip* target, int i);

void* list_ip_search(struct list_ip* target, int key);

void list_ip_free(struct list_ip* target);

void list_ip_free_callback(struct list_ip* target, bool free_root,
                           void (*callback)(int, void*));

void list_ip_destroy(struct list_ip* target);

void* list_ip_remove(struct list_ip* target, int key);

//// Output methods...
void list_ip_dump(char* (f)(void*), struct list_ip* target);
void list_ip_printf(char* format, struct list_ip* target);
void list_ip_fdump(FILE* file, char* (f)(void*), struct list_ip* target);
void list_ip_fprintf(FILE* file, char* format, struct list_ip* target);
void list_ip_dumpkeys(struct list_ip* target);
void list_ip_xdumpkeys(struct list_ip* target);
void list_ip_fdumpkeys(FILE* file, struct list_ip* target);
void list_ip_output(char* (*f)(void*), struct list_ip* target);
size_t list_ip_snprintf(char* str, size_t size,
                      const char* format,
                      const struct list_ip* target);
/* size_t list_ip_marshal(char* str, size_t size, */
/*                     char* (f)(void*), struct list_ip* target); */
char* list_ip_serialize_ptrs(struct list_ip* target);

#endif


text:
package org.jkiss.dbeaver.model.sql.translate;

import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.create.table.ColumnDefinition;
import net.sf.jsqlparser.statement.create.table.CreateTable;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore;
import org.jkiss.dbeaver.model.sql.SQLDialect;
import org.jkiss.dbeaver.model.sql.SQLQuery;
import org.jkiss.dbeaver.model.sql.SQLScriptElement;
import org.jkiss.dbeaver.model.sql.SQLSyntaxManager;
import org.jkiss.dbeaver.model.sql.format.SQLFormatUtils;
import org.jkiss.utils.CommonUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

/**
 * SQL translator
 */
final class SQLTranslateContext {

    @NotNull
    private final SQLDialect sourceDialect;
    @NotNull
    private final SQLDialect targetDialect;
    @NotNull
    private final DBPPreferenceStore preferenceStore;
    @NotNull
    private final SQLSyntaxManager syntaxManager;

    public SQLTranslateContext(
        @NotNull SQLDialect sourceDialect,
        @NotNull SQLDialect targetDialect,
        @NotNull DBPPreferenceStore preferenceStore)
    {
        this.sourceDialect = sourceDialect;
        this.targetDialect = targetDialect;
        this.preferenceStore = preferenceStore;

        syntaxManager = new SQLSyntaxManager();
        syntaxManager.init(targetDialect, preferenceStore);
    }

    @NotNull
    public SQLDialect getSourceDialect() {
        return sourceDialect;
    }

    @NotNull
    public SQLDialect getTargetDialect() {
        return targetDialect;
    }

    @NotNull
    public DBPPreferenceStore getPreferenceStore() {
        return preferenceStore;
    }

    @NotNull
    public SQLSyntaxManager getSyntaxManager() {
        return syntaxManager;
    }

    List<? extends SQLScriptElement> translateCommand(
        @NotNull SQLScriptElement element) throws DBException {

        if (element instanceof SQLQuery) {
            return translateQuery((SQLQuery)element);
        }

        return Collections.singletonList(element);
    }

    private List<? extends SQLScriptElement> translateQuery(@NotNull SQLQuery query) throws DBException
    {
        Statement statement = query.getStatement();
        if (statement != null) {
            return translateStatement(query, statement);
        }
        return Collections.singletonList(query);
    }

    private List<? extends SQLScriptElement> translateStatement(
        @NotNull SQLQuery query,
        @NotNull Statement statement) throws DBException
    {
        // FIXME: currently it is a dummy translator to PostgreSQL dialect
        List<SQLScriptElement> extraQueries = null;

        if (statement instanceof CreateTable) {
            boolean defChanged = false;
            CreateTable createTable = (CreateTable)statement;
            for (ColumnDefinition cd : createTable.getColumnDefinitions()) {

                String newDataType = null;
                switch (cd.getColDataType().getDataType().toUpperCase(Locale.ENGLISH)) {
                    case "CLOB":
                        newDataType = "varchar";
                        break;
                }
                if (newDataType != null) {
                    cd.getColDataType().setDataType(newDataType);
                    defChanged = true;
                }
                if (!CommonUtils.isEmpty(cd.getColumnSpecs())) {
                    for (String cSpec : new ArrayList<>(cd.getColumnSpecs())) {
                        switch (cSpec.toUpperCase(Locale.ENGLISH)) {
                            case "AUTO_INCREMENT":
                            case "IDENTITY":
                                if (!targetDialect.supportsColumnAutoIncrement()) {
                                    String sequenceName = CommonUtils.escapeIdentifier(createTable.getTable().getName()) +
                                        "_" + CommonUtils.escapeIdentifier(cd.getColumnName());

                                    cd.getColumnSpecs().remove(cSpec);
                                    cd.getColumnSpecs().add("DEFAULT");
                                    cd.getColumnSpecs().add("NEXTVAL('" + sequenceName + "')");
                                    defChanged = true;

                                    String createSeqQuery = "CREATE SEQUENCE " + sequenceName;

                                    if (extraQueries == null) {
                                        extraQueries = new ArrayList<>();
                                    }
                                    extraQueries.add(new SQLQuery(null, createSeqQuery));
                                }
                                break;
                        }
                    }
                }
            }
            if (defChanged) {
                String newQueryText = SQLFormatUtils.formatSQL(null, syntaxManager, createTable.toString());
                query.setText(newQueryText);

                if (extraQueries == null) {
                    extraQueries = new ArrayList<>();
                }
                extraQueries.add(query);
            }
        }
        if (extraQueries == null) {
            return Collections.singletonList(query);
        }
        return extraQueries;
    }

}


text:
const {
    ABSTRACTION_LEVELS,
    createFlowTreeBuilder,
    convertFlowTreeToSvg
} = window.js2flowchart;

const flowTreeBuilder = createFlowTreeBuilder();

//you can pass one level or multiple levels in [] as well
flowTreeBuilder.setAbstractionLevel([
    ABSTRACTION_LEVELS.IMPORT,
    ABSTRACTION_LEVELS.EXPORT
]);

const flowTree = flowTreeBuilder.build(code),
    svg = convertFlowTreeToSvg(flowTree);

document.getElementById('svgImage').innerHTML = svg;


text:
const User = require('../models/User.js');

const getUser = async (req, res) => {
  console.log('getUser', req.params.username);
  if (!req.user) return res.status(401).send();

  const { username } = req.user;

  const user = await User.findOne({ username });

  res.json(user);
};

const saveJob = async (req, res) => {
  const { jobId } = req.params;

  if (!req.user) return res.status(401).send();

  const { username } = req.user;

  const user = await User.findOne({ username });
  const jobIndex = user.savedJobs.indexOf(jobId);

  !~jobIndex ? user.savedJobs.push(jobId) : user.savedJobs.splice(jobIndex, 1);

  const result = await user.save();
  // Temp status for testing
  const status = ~result.savedJobs.indexOf(jobId) ? 'saved to' : 'removed from';
  res.send(`Job ${jobId} ${status} ${username} profile.`);
};

const selectJobAction = (req, res) => {
  // Use req.query.hasOwnProperty() to select different method
  // Default to 'save'
  return saveJob(req, res);
};

module.exports = {
  getUser,
  selectJobAction,
};


text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/cloud/talent/v4/common.proto

package com.google.cloud.talent.v4;

public interface BatchOperationMetadataOrBuilder
    extends
    // @@protoc_insertion_point(interface_extends:google.cloud.talent.v4.BatchOperationMetadata)
    com.google.protobuf.MessageOrBuilder {

  /**
   *
   *
   *

   * The state of a long running operation.
   *

   *
   * .google.cloud.talent.v4.BatchOperationMetadata.State state = 1;
   *
   * @return The enum numeric value on the wire for state.
   */
  int getStateValue();
  /**
   *
   *
   *

   * The state of a long running operation.
   *

   *
   * .google.cloud.talent.v4.BatchOperationMetadata.State state = 1;
   *
   * @return The state.
   */
  com.google.cloud.talent.v4.BatchOperationMetadata.State getState();

  /**
   *
   *
   *

   * More detailed information about operation state.
   *

   *
   * string state_description = 2;
   *
   * @return The stateDescription.
   */
  java.lang.String getStateDescription();
  /**
   *
   *
   *

   * More detailed information about operation state.
   *

   *
   * string state_description = 2;
   *
   * @return The bytes for stateDescription.
   */
  com.google.protobuf.ByteString getStateDescriptionBytes();

  /**
   *
   *
   *

   * Count of successful item(s) inside an operation.
   *

   *
   * int32 success_count = 3;
   *
   * @return The successCount.
   */
  int getSuccessCount();

  /**
   *
   *
   *

   * Count of failed item(s) inside an operation.
   *

   *
   * int32 failure_count = 4;
   *
   * @return The failureCount.
   */
  int getFailureCount();

  /**
   *
   *
   *

   * Count of total item(s) inside an operation.
   *

   *
   * int32 total_count = 5;
   *
   * @return The totalCount.
   */
  int getTotalCount();

  /**
   *
   *
   *

   * The time when the batch operation is created.
   *

   *
   * .google.protobuf.Timestamp create_time = 6;
   *
   * @return Whether the createTime field is set.
   */
  boolean hasCreateTime();
  /**
   *
   *
   *

   * The time when the batch operation is created.
   *

   *
   * .google.protobuf.Timestamp create_time = 6;
   *
   * @return The createTime.
   */
  com.google.protobuf.Timestamp getCreateTime();
  /**
   *
   *
   *

   * The time when the batch operation is created.
   *

   *
   * .google.protobuf.Timestamp create_time = 6;
   */
  com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder();

  /**
   *
   *
   *

   * The time when the batch operation status is updated. The metadata and the
   * [update_time][google.cloud.talent.v4.BatchOperationMetadata.update_time] is refreshed every minute otherwise cached data is
   * returned.
   *

   *
   * .google.protobuf.Timestamp update_time = 7;
   *
   * @return Whether the updateTime field is set.
   */
  boolean hasUpdateTime();
  /**
   *
   *
   *

   * The time when the batch operation status is updated. The metadata and the
   * [update_time][google.cloud.talent.v4.BatchOperationMetadata.update_time] is refreshed every minute otherwise cached data is
   * returned.
   *

   *
   * .google.protobuf.Timestamp update_time = 7;
   *
   * @return The updateTime.
   */
  com.google.protobuf.Timestamp getUpdateTime();
  /**
   *
   *
   *

   * The time when the batch operation status is updated. The metadata and the
   * [update_time][google.cloud.talent.v4.BatchOperationMetadata.update_time] is refreshed every minute otherwise cached data is
   * returned.
   *

   *
   * .google.protobuf.Timestamp update_time = 7;
   */
  com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder();

  /**
   *
   *
   *

   * The time when the batch operation is finished and
   * [google.longrunning.Operation.done][google.longrunning.Operation.done] is set to `true`.
   *

   *
   * .google.protobuf.Timestamp end_time = 8;
   *
   * @return Whether the endTime field is set.
   */
  boolean hasEndTime();
  /**
   *
   *
   *

   * The time when the batch operation is finished and
   * [google.longrunning.Operation.done][google.longrunning.Operation.done] is set to `true`.
   *

   *
   * .google.protobuf.Timestamp end_time = 8;
   *
   * @return The endTime.
   */
  com.google.protobuf.Timestamp getEndTime();
  /**
   *
   *
   *

   * The time when the batch operation is finished and
   * [google.longrunning.Operation.done][google.longrunning.Operation.done] is set to `true`.
   *

   *
   * .google.protobuf.Timestamp end_time = 8;
   */
  com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder();
}


text:
distributed create table part to 256 on p_partkey as virtual
select
  cast(c1 as int) as p_partkey,
  cast(c2 as text) as p_name,
  cast(c3 as text) as p_mfgr,
  cast(c4 as text) as p_brand,
  cast(c5 as text) as p_type,
  cast(c6 as float) as p_size,
  cast(c7 as text) as p_container,
  cast(c8 as float) as p_retailprice,
  cast(c9 as text) as p_comment
from (file 'fast:1' '/home/exa/tpch-kit/datasets/part.tbl.gz' delimiter:|);


text:
cask "jamovi" do
  version "1.6.16.0"
  sha256 "bad4c86854b9932889d5cb03d42647a1bd89f001443eb6718b28d094c55d8f4a"

  url "https://www.jamovi.org/downloads/jamovi-#{version}-macos.dmg"
  name "jamovi"
  desc "Free and open statistical software"
  homepage "https://www.jamovi.org/"

  livecheck do
    url "https://www.jamovi.org/download.html"
    strategy :page_match
    regex(%r{href=.*?/jamovi-(\d+(?:\.\d+)*)-macos\.dmg}i)
  end

  auto_updates true

  app "jamovi.app"

  zap trash: [
    "~/Library/Application Support/jamovi/",
    "~/Library/Logs/jamovi",
    "~/Library/Preferences/org.jamovi.jamovi.plist",
    "~/Library/Saved Application State/org.jamovi.jamovi.savedState/",
  ]
end


text:
> [Verb](https://github.com/verbose/verb) helper for [Bower](http://bower.io/). List dependencies.

## Examples

See https://www.npmjs.com/package/magnificent#load for example output from my [Magnificent.js](https://github.com/AndersDJohnson/magnificent.js) project via its [.verb.md#load](https://github.com/AndersDJohnson/magnificent.js/blob/master/.verb.md#load) and [verbfile.js](https://github.com/AndersDJohnson/magnificent.js/blob/master/verbfile.js).


text:
DECLARE_string(log_dir);

namespace tera {
namespace utils {

std::string GetBinaryLocationDir() {
    char exec_full_path[1024] = {'\0'};
    readlink("/proc/self/exe", exec_full_path, 1024);
    VLOG(5) << "current binary location: " << exec_full_path;

    std::string full_dir;
    SplitStringPath(exec_full_path, &full_dir, NULL);
    return full_dir;
}

std::string GetCurrentLocationDir() {
    char current_path[1024] = {'\0'};
    std::string current_dir;

    if (getcwd(current_path, 1024)) {
        current_dir = current_path;
    }
    return current_dir;
}

std::string GetValueFromeEnv(const std::string& env_name) {
    if (env_name.empty()) {
        return "";
    }

    const char* env = getenv(env_name.c_str());
    if (!env) {
        VLOG(5) << "fail to fetch from env: " << env_name;
        return "";
    }
    return env;
}

std::string ConvertByteToString(const uint64_t size) {
    std::string hight_unit;
    double min_size;
    const uint64_t kKB = 1024;
    const uint64_t kMB = kKB * 1024;
    const uint64_t kGB = kMB * 1024;
    const uint64_t kTB = kGB * 1024;
    const uint64_t kPB = kTB * 1024;

    if (size == 0) {
        return "0 ";
    }

    if (size > kPB) {
        min_size = (1.0 * size) / kPB;
        hight_unit = "P";
    } else if (size > kTB) {
        min_size = (1.0 * size) / kTB;
        hight_unit = "T";
    } else if (size > kGB) {
        min_size = (1.0 * size) / kGB;
        hight_unit = "G";
    } else if (size > kMB) {
        min_size = (1.0 * size) / kMB;
        hight_unit = "M";
    } else if (size > kKB) {
        min_size = (1.0 * size) / kKB;
        hight_unit = "K";
    } else {
        min_size = size;
        hight_unit = " ";
    }

    if ((int)min_size - min_size == 0) {
        return StringFormat("%d%s", (int)min_size, hight_unit.c_str());
    } else {
        return StringFormat("%.2f%s", min_size, hight_unit.c_str());
    }
}

bool ExecuteShellCmd(const std::string cmd, std::string* ret_str) {
    char output_buffer[80];
    FILE *fp = popen(cmd.c_str(), "r");
    if (!fp) {
        LOG(ERROR) << "fail to execute cmd: " << cmd;
        return false;
    }
    fgets(output_buffer, sizeof(output_buffer), fp);
    pclose(fp);
    if (ret_str) {
        *ret_str = std::string(output_buffer);
    }
    return true;
}

std::string GetLocalHostAddr() {
    std::string cmd =
        "/sbin/ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'";
    std::string addr;
    if (!ExecuteShellCmd(cmd, &addr)) {
        LOG(ERROR) << "fail to fetch local host addr";
    } else if (addr.length() > 1) {
        addr.erase(addr.length() - 1, 1);
    }
    return addr;
}

std::string GetLocalHostName() {
    char str[kMaxHostNameSize + 1];
    if (0 != gethostname(str, kMaxHostNameSize + 1)) {
        LOG(FATAL) << "gethostname fail";
        exit(1);
    }
    std::string hostname(str);
    return hostname;
}

void SetupLog(const std::string& name) {
    // log info/warning/error/fatal to tera.log
    // log warning/error/fatal to tera.wf

    std::string program_name = "tera";
    if (!name.empty()) {
        program_name = name;
    }

    std::string log_filename = FLAGS_log_dir + "/" + program_name + ".INFO.";
    std::string wf_filename = FLAGS_log_dir + "/" + program_name + ".WARNING.";
    google::SetLogDestination(google::INFO, log_filename.c_str());
    google::SetLogDestination(google::WARNING, wf_filename.c_str());
    google::SetLogDestination(google::ERROR, "");
    google::SetLogDestination(google::FATAL, "");

    google::SetLogSymlink(google::INFO, program_name.c_str());
    google::SetLogSymlink(google::WARNING, program_name.c_str());
    google::SetLogSymlink(google::ERROR, "");
    google::SetLogSymlink(google::FATAL, "");
}

} // namespace utils
} // namespace tera


text:
import _ from 'lodash';
import moment from 'moment';
import ajax from '../ajax';

const id = 'tampere';
const name = 'Tampere';
const latitude = 61.487881;
const longitude = 23.7810259;
const apiUrl = 'http://data.itsfactory.fi/siriaccess/vm/json';

function fetch() {
    return ajax(apiUrl).then(_transform);
}

function _transform(data) {
    const vehicles = data.Siri.ServiceDelivery.VehicleMonitoringDelivery[0].VehicleActivity;
    return _.map(vehicles, _transformVehicle.bind(this, data));
}

function _transformVehicle(data, vehicle) {
    const journey = vehicle.MonitoredVehicleJourney;

    return {
        id: journey.VehicleRef.value,
        type: 'bus',
        line: journey.LineRef.value,
        latitude: journey.VehicleLocation.Latitude,
        longitude: journey.VehicleLocation.Longitude,
        rotation: journey.Bearing,
        responseTime: moment(data.Siri.ServiceDelivery.ResponseTimestamp).toISOString()
    };
}

export default {
    id,
    name,
    latitude,
    longitude,
    fetch
};


text:
Mae copi o'r lexicon hefyd ar gael o

http://techiaith.cymru/htk/lexicon


text:
dryIceApp
=========

Titanium Alloy app with Node.js API and Cloudant backend


text:
import React from 'react'
import Section from '../section'
import Quotes from './quotes'
import Logos from './logos'
import screenSizes from '../../../lib/screen-sizes'

const Community = () => (

Loved by the community

Designers, developers, project managers. They all use Kap.

        <Logos />

      <Quotes />

)

export default Community


text:
package ca.uhn.fhir.util;

import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.context.RuntimeSearchParam;
import ca.uhn.fhir.i18n.Msg;
import org.apache.commons.lang3.Validate;
import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IPrimitiveType;

import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public class SearchParameterUtil {

	public static List<String> getBaseAsStrings(FhirContext theContext, IBaseResource theResource) {
		Validate.notNull(theContext, "theContext must not be null");
		Validate.notNull(theResource, "theResource must not be null");
		RuntimeResourceDefinition def = theContext.getResourceDefinition(theResource);

		BaseRuntimeChildDefinition base = def.getChildByName("base");
		List<IBase> baseValues = base.getAccessor().getValues(theResource);
		List<String> retVal = new ArrayList<>();
		for (IBase next : baseValues) {
			IPrimitiveType<?> nextPrimitive = (IPrimitiveType<?>) next;
			retVal.add(nextPrimitive.getValueAsString());
		}

		return retVal;
	}

	/**
	 * Given the resource type, fetch its patient-based search parameter name
	 * 1. Attempt to find one called 'patient'
	 * 2. If that fails, find one called 'subject'
	 * 3. If that fails, find find by Patient Compartment.
	 *    3.1 If that returns >1 result, throw an error
	 *    3.2 If that returns 1 result, return it
	 */
	public static Optional<RuntimeSearchParam> getOnlyPatientSearchParamForResourceType(FhirContext theFhirContext, String theResourceType) {
		RuntimeSearchParam myPatientSearchParam = null;
		RuntimeResourceDefinition runtimeResourceDefinition = theFhirContext.getResourceDefinition(theResourceType);
		myPatientSearchParam = runtimeResourceDefinition.getSearchParam("patient");
		if (myPatientSearchParam == null) {
			myPatientSearchParam = runtimeResourceDefinition.getSearchParam("subject");
			if (myPatientSearchParam == null) {
				myPatientSearchParam = getOnlyPatientCompartmentRuntimeSearchParam(runtimeResourceDefinition);
			}
		}
		return Optional.ofNullable(myPatientSearchParam);
	}

	/**
	 * Search the resource definition for a compartment named 'patient' and return its related Search Parameter.
	 */
	public static RuntimeSearchParam getOnlyPatientCompartmentRuntimeSearchParam(FhirContext theFhirContext, String theResourceType) {
		RuntimeResourceDefinition resourceDefinition = theFhirContext.getResourceDefinition(theResourceType);
		return getOnlyPatientCompartmentRuntimeSearchParam(resourceDefinition);
	}

	public static RuntimeSearchParam getOnlyPatientCompartmentRuntimeSearchParam(RuntimeResourceDefinition runtimeResourceDefinition) {
		RuntimeSearchParam patientSearchParam;
		List<RuntimeSearchParam> searchParams = runtimeResourceDefinition.getSearchParamsForCompartmentName("Patient");
		if (searchParams == null || searchParams.size() == 0) {
			String errorMessage = String.format("Resource type [%s] is not eligible for this type of export, as it contains no Patient compartment, and no `patient` or `subject` search parameter", runtimeResourceDefinition.getId());
			throw new IllegalArgumentException(Msg.code(1774) + errorMessage);
		} else if (searchParams.size() == 1) {
			patientSearchParam = searchParams.get(0);
		} else {
			String errorMessage = String.format("Resource type %s has more than one Search Param which references a patient compartment. We are unable to disambiguate which patient search parameter we should be searching by.", runtimeResourceDefinition.getId());
			throw new IllegalArgumentException(Msg.code(1775) + errorMessage);
		}
		return patientSearchParam;
	}

	public static List<RuntimeSearchParam> getAllPatientCompartmentRuntimeSearchParams(FhirContext theFhirContext, String theResourceType) {
		RuntimeResourceDefinition runtimeResourceDefinition = theFhirContext.getResourceDefinition(theResourceType);
		return getAllPatientCompartmentRuntimeSearchParams(runtimeResourceDefinition);

	}

	private static List<RuntimeSearchParam> getAllPatientCompartmentRuntimeSearchParams(RuntimeResourceDefinition theRuntimeResourceDefinition) {
		List<RuntimeSearchParam> patient = theRuntimeResourceDefinition.getSearchParamsForCompartmentName("Patient");
		return patient;
	}

	@Nullable
	public static String getCode(FhirContext theContext, IBaseResource theResource) {
		return getStringChild(theContext, theResource, "code");
	}

	@Nullable
	public static String getExpression(FhirContext theFhirContext, IBaseResource theResource) {
		return getStringChild(theFhirContext, theResource, "expression");
	}

	private static String getStringChild(FhirContext theFhirContext, IBaseResource theResource, String theChildName) {
		Validate.notNull(theFhirContext, "theContext must not be null");
		Validate.notNull(theResource, "theResource must not be null");
		RuntimeResourceDefinition def = theFhirContext.getResourceDefinition(theResource);

		BaseRuntimeChildDefinition base = def.getChildByName(theChildName);
		return base
			.getAccessor()
			.getFirstValueOrNull(theResource)
			.map(t -> ((IPrimitiveType<?>) t))
			.map(t -> t.getValueAsString())
			.orElse(null);
	}
}


text:
var paths = {
    scripts: ['./sources/js/jquery.js', './sources/js/bootstrap.js',
        './sources/js/jquery-easing.js', './sources/js/classie.js',
        './sources/js/cbpAnimatedHeader.js', './sources/js/page-scroll.js',
        './sources/js/contactForm.js'],
    less: './sources/less/agency.less'
};

var gulp = require('gulp');
var less = require('gulp-less');
var path = require('path');
var minify = require('gulp-minify-css');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');

gulp.task('js', function() {
    gulp.src(paths.scripts)
        .pipe(concat('picoprime.js'))
        .pipe(uglify())
        .pipe(gulp.dest('./js/'))
});

gulp.task('less', function () {
    gulp.src(paths.less)
        .pipe(less({
            paths: [ path.join(__dirname, 'less') ]
        }))
        .pipe(minify({keepSpecialComments:0}))
        .pipe(gulp.dest('./css'));
});

gulp.task('watch', function() {
    gulp.watch(paths.scripts, ['js']);
    gulp.watch(paths.less, ['less']);
});

gulp.task('default', ['watch', 'js', 'less']);