text:
package com.google.common.collect;

import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.testing.features.CollectionFeature;
import com.google.common.collect.testing.features.CollectionSize;
import com.google.common.collect.testing.features.MapFeature;
import com.google.common.collect.testing.google.BiMapTestSuiteBuilder;
import com.google.common.collect.testing.google.TestStringBiMapGenerator;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

/**
 * Tests for {@link HashBiMap}.
 *
 * @author Mike Bostock
 */
@GwtCompatible(emulated = true)
public class HashBiMapTest extends TestCase {

  public static final class HashBiMapGenerator extends TestStringBiMapGenerator {
    @Override
    protected BiMap<String, String> create(Entry<String, String>[] entries) {
      BiMap<String, String> result = HashBiMap.create();
      for (Entry<String, String> entry : entries) {
        result.put(entry.getKey(), entry.getValue());
      }
      return result;
    }
  }

  @GwtIncompatible("suite")
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(BiMapTestSuiteBuilder.using(new HashBiMapGenerator())
      .named("HashBiMap")
      .withFeatures(CollectionSize.ANY,
          CollectionFeature.SERIALIZABLE,
          MapFeature.ALLOWS_NULL_KEYS,
          MapFeature.ALLOWS_NULL_VALUES,
          MapFeature.GENERAL_PURPOSE)
      .createTestSuite());
    suite.addTestSuite(HashBiMapTest.class);
    return suite;
  }

  public void testMapConstructor() {
    /* Test with non-empty Map. */
    Map<String, String> map = ImmutableMap.of(
        "canada", "dollar",
        "chile", "peso",
        "switzerland", "franc");
    HashBiMap<String, String> bimap = HashBiMap.create(map);
    assertEquals("dollar", bimap.get("canada"));
    assertEquals("canada", bimap.inverse().get("dollar"));
  }

  private static final int N = 1000;

  public void testBashIt() throws Exception {
    BiMap<Integer, Integer> bimap = HashBiMap.create(N);
    BiMap<Integer, Integer> inverse = bimap.inverse();

    for (int i = 0; i < N; i++) {
      assertNull(bimap.put(2 * i, 2 * i + 1));
    }
    for (int i = 0; i < N; i++) {
      assertEquals(2 * i + 1, (int) bimap.get(2 * i));
    }
    for (int i = 0; i < N; i++) {
      assertEquals(2 * i, (int) inverse.get(2 * i + 1));
    }
    for (int i = 0; i < N; i++) {
      int oldValue = bimap.get(2 * i);
      assertEquals(2 * i + 1, (int) bimap.put(2 * i, oldValue - 2));
    }
    for (int i = 0; i < N; i++) {
      assertEquals(2 * i - 1, (int) bimap.get(2 * i));
    }
    for (int i = 0; i < N; i++) {
      assertEquals(2 * i, (int) inverse.get(2 * i - 1));
    }
    Set<Entry<Integer, Integer>> entries = bimap.entrySet();
    for (Entry<Integer, Integer> entry : entries) {
      entry.setValue(entry.getValue() + 2 * N);
    }
    for (int i = 0; i < N; i++) {
      assertEquals(2 * N + 2 * i - 1, (int) bimap.get(2 * i));
    }
  }

  public void testBiMapEntrySetIteratorRemove() {
    BiMap<Integer, String> map = HashBiMap.create();
    map.put(1, "one");
    Set<Map.Entry<Integer, String>> entries = map.entrySet();
    Iterator<Map.Entry<Integer, String>> iterator = entries.iterator();
    Map.Entry<Integer, String> entry = iterator.next();
    entry.setValue("two"); // changes the iterator's current entry value
    assertEquals("two", map.get(1));
    assertEquals(Integer.valueOf(1), map.inverse().get("two"));
    iterator.remove(); // removes the updated entry
    assertTrue(map.isEmpty());
  }
}


text:
package com.dangdang.ddframe.job.lite.internal.server;

import com.dangdang.ddframe.job.lite.internal.schedule.JobRegistry;
import com.dangdang.ddframe.job.lite.internal.storage.JobNodePath;
import com.dangdang.ddframe.job.util.env.IpUtils;

import java.util.regex.Pattern;

/**
 * 服务器节点路径.
 *
 * @author zhangliang
 */
public final class ServerNode {

    /**
     * 服务器信息根节点.
     */
    public static final String ROOT = "servers";

    private static final String SERVERS = ROOT + "/%s";

    private final String jobName;

    private final JobNodePath jobNodePath;

    public ServerNode(final String jobName) {
        this.jobName = jobName;
        jobNodePath = new JobNodePath(jobName);
    }

    /**
     * 判断给定路径是否为作业服务器路径.
     *
     * @param path 待判断的路径
     * @return 是否为作业服务器路径
     */
    public boolean isServerPath(final String path) {
        return Pattern.compile(jobNodePath.getFullPath(ServerNode.ROOT) + "/" + IpUtils.IP_REGEX).matcher(path).matches();
    }

    /**
     * 判断给定路径是否为本地作业服务器路径.
     *
     * @param path 待判断的路径
     * @return 是否为本地作业服务器路径
     */
    public boolean isLocalServerPath(final String path) {
        return path.equals(jobNodePath.getFullPath(String.format(SERVERS, JobRegistry.getInstance().getJobInstance(jobName).getIp())));
    }

    String getServerNode(final String ip) {
        return String.format(SERVERS, ip);
    }
}

redpajama_set_name: RedPajamaGithub


text:
$cacct=Read-Host 'Enter 1 to add an Azure account, or press Enter to continue with current account'
if ($cacct -eq 1)
{
  Add-AzureAccount
}
Write-Host 'Current Development environment is:'
Get-AzureSubscription -Current | Select SubscriptionName, SupportedModes, DefaultAccount | Format-Table

$csubscr=Read-Host 'Enter 1 to change, or press Enter to continue with current Subscription'
if ($csubscr -eq 1)
{
  Write-Host 'All available Azure Subscriptions are: '
  Get-AzureSubscription | Sort SubscriptionName | Select SubscriptionName, DefaultAccount | Format-Table
  #, DefaultAccount | Format-Table
  Write-Host '---------------------------------------------'
  $subscr= Read-Host 'What is the Azure Subscription Name to use' #"Infotech Demo and Development Environment"
  Select-AzureSubscription -SubscriptionName $subscr -Current
  Write-Host 'Current Development environment is now set to:'
  Get-AzureSubscription -Current | Select SubscriptionName, SupportedModes | Format-Table
}


text:
<?php

namespace Network\Curl;

/**
 * Curl
 *
 * Simple cURL wrapper for basic HTTP requests. Support available
 * for GET, POST, PUT, PATCH and DELETE
 *
 * @author    dsyph3r <d.syph.3r@gmail.com>
 */
class Curl
{
    /**
     * Constants for available HTTP methods
     */
    const GET     = 'GET';
    const POST    = 'POST';
    const PUT     = 'PUT';
    const PATCH   = 'PATCH';
    const DELETE  = 'DELETE';

    /**
     * @var cURL handle
     */
    private $curl;

    /**
     * Create the cURL resource
     */
    public function __construct()
    {
        $this->curl = curl_init();
    }

    /**
     * Clean up the cURL handle
     */
    public function __destruct()
    {
        if (is_resource($this->curl))
        {
            curl_close($this->curl);
        }
    }

    /**
     * Get the cURL handle
     *
     * @return  cURL            cURL handle
     */
    public function getCurl()
    {
        return $this->curl;
    }

    /**
     * Make a HTTP GET request
     *
     * @param   string  $url          Full URL including protocol
     * @param   array   $params       Any GET params
     * @param   array   $options      Additional options for the request
     * @return  array                 Response
     */
    public function get($url, $params = array(), $options = array())
    {
        return $this->request($url, self::GET, $params, $options);
    }

    /**
     * Make a HTTP POST request
     *
     * @param   string  $url          Full URL including protocol
     * @param   array   $params       Any POST params
     * @param   array   $options      Additional options for the request
     * @return  array                 Response
     */
    public function post($url, $params = array(), $options = array())
    {
        return $this->request($url, self::POST, $params, $options);
    }

    /**
     * Make a HTTP PUT request
     *
     * @param   string  $url          Full URL including protocol
     * @param   array   $params       Any PUT params
     * @param   array   $options      Additional options for the request
     * @return  array                 Response
     */
    public function put($url, $params = array(), $options = array())
    {
        return $this->request($url, self::PUT, $params, $options);
    }

    /**
     * Make a HTTP PATCH request
     *
     * @param   string  $url          Full URL including protocol
     * @param   array   $params       Any PATCH params
     * @param   array   $options      Additional options for the request
     * @return  array                 Response
     */
    public function patch($url, $params = array(), $options = array())
    {
        return $this->request($url, self::PATCH, $params, $options);
    }

    /**
     * Make a HTTP DELETE request
     *
     * @param   string  $url          Full URL including protocol
     * @param   array   $params       Any DELETE params
     * @param   array   $options      Additional options for the request
     * @return  array                 Response
     */
    public function delete($url, $params = array(), $options = array())
    {
        return $this->request($url, self::DELETE, $params, $options);
    }

    /**
     * Make a HTTP request
     *
     * @param   string  $url          Full URL including protocol
     * @param   string  $method       HTTP method
     * @param   array   $params       Any params
     * @param   array   $options      Additional options for the request
     * @return  array                 Response
     */
    protected function request($url, $method = self::GET, $params = array(), $options = array())
    {
        curl_setopt($this->curl, CURLOPT_HEADER, true);
        curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);

        curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($this->curl, CURLOPT_URL, $url);
        curl_setopt($this->curl, CURLOPT_POSTFIELDS, http_build_query($params));

        // Check for custom headers
        if (isset($options['headers']) && count($options['headers']))
            curl_setopt($curl, CURLOPT_HTTPHEADER, $options['headers']);

        // Check for basic auth
        if (isset($options['auth']['type']) && "basic" === $options['auth']['type'])
            curl_setopt($curl, CURLOPT_USERPWD, $options['auth']['username'] . ':' . $options['auth']['password']);

        $response = $this->doCurl();

        // Separate headers and body
        $responseSplit = preg_split('/((?:\\r?\\n){2})/', $response['response']);
        $responseCount = count($responseSplit);

        $results = array(
            'curl_info'     => $response['curl_info'],
            'status'        => $response['curl_info']['http_code'],
            'headers'       => $this->splitHeaders($responseSplit[$responseCount-2]),
            'data'          => $responseSplit[$responseCount-1],
        );

        return $results;
    }

    /**
     * Split the HTTP headers
     *
     * @param   string  $rawHeaders     Raw HTTP headers
     * @return  array                   Key/Value headers
     */
    protected function splitHeaders($rawHeaders)
    {
        $headers = array();

        $headerLines = explode("\n", $rawHeaders);
        $headers['HTTP'] = array_shift($headerLines);
        foreach ($headerLines as $line) {
            $header = explode(":", $line, 2);
            $headers[trim($header[0])] = trim($header[1]);
        }

        return $headers;
    }

    /**
     * Perform the Curl request
     *
     * @param   cURL Handle     $curl       The cURL handle to use
     * @return  array                       cURL response
     */
    protected function doCurl()
    {
        $response     = curl_exec($this->curl);
        $curlInfo     = curl_getinfo($this->curl);

        $results = array(
            'curl_info'     => $curlInfo,
            'response'      => $response,
        );

        return $results;
    }

}

/**
 * General Curl Exception
 */
class CurlException extends \Exception
{
}


text:
id: 56533eb9ac21ba0edf2244dc
title: Chaining If Else Statements
challengeType: 1
videoUrl: https://scrimba.com/c/caeJgsw
forumTopicId: 16772
localeTitle: Связывание с другими сообщениями
---

## Description

if/else утверждения могут быть объединены вместе для сложной логики. Вот <dfn>псевдокод</dfn> операторов с несколькими цепями if / else if :
 если ( условие 1 ) {
 statement1
 } else if ( условие2 ) {
 оператор2
 } else if ( условие 3 ) {
 оператор3
 , , ,
 } else {
 statementN
 }

## Instructions

Напишите прикованные if / else if выражения для выполнения следующих условий: num < 5 - return "Tiny"
 num < 10 - возврат "Small"
 num < 15 - возврат "Средний"
 num < 20 - возврат "Большой"
 num >= 20 - возврат "Огромный"

## Tests

```yml
tests:
  - text: You should have at least four <code>else</code> statements
    testString: assert(code.match(/else/g).length > 3);
  - text: You should have at least four <code>if</code> statements
    testString: assert(code.match(/if/g).length > 3);
  - text: You should have at least one <code>return</code> statement
    testString: assert(code.match(/return/g).length >= 1);
  - text: <code>testSize(0)</code> should return "Tiny"
    testString: assert(testSize(0) === "Tiny");
  - text: <code>testSize(4)</code> should return "Tiny"
    testString: assert(testSize(4) === "Tiny");
  - text: <code>testSize(5)</code> should return "Small"
    testString: assert(testSize(5) === "Small");
  - text: <code>testSize(8)</code> should return "Small"
    testString: assert(testSize(8) === "Small");
  - text: <code>testSize(10)</code> should return "Medium"
    testString: assert(testSize(10) === "Medium");
  - text: <code>testSize(14)</code> should return "Medium"
    testString: assert(testSize(14) === "Medium");
  - text: <code>testSize(15)</code> should return "Large"
    testString: assert(testSize(15) === "Large");
  - text: <code>testSize(17)</code> should return "Large"
    testString: assert(testSize(17) === "Large");
  - text: <code>testSize(20)</code> should return "Huge"
    testString: assert(testSize(20) === "Huge");
  - text: <code>testSize(25)</code> should return "Huge"
    testString: assert(testSize(25) === "Huge");

```

## Challenge Seed

```js
function testSize(num) {
  // Only change code below this line

  return "Change Me";
  // Only change code above this line
}

// Change this value to test
testSize(7);

```

## Solution

```js
function testSize(num) {
  if (num < 5) {
    return "Tiny";
  } else if (num < 10) {
    return "Small";
  } else if (num < 15) {
    return "Medium";
  } else if (num < 20) {
    return "Large";
  } else {
    return "Huge";
  }
}
```


text:
function getHealth(callback) {
  $.ajax({
    url: '/api/health',
    type: 'GET',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(health, status, jqXHR) {
      callback(health);
    }
  });
}

function getChannels(callback) {
  $.ajax({
    url: '/api/lineup/channels',
    type: 'GET',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(channels, status, jqXHR) {
      callback(channels);
    }
  });
}

function saveChannels(channels, callback) {
  $.ajax({
    url: '/api/lineup/channels',
    type: 'PUT',
    contentType: "application/json; charset=utf-8",
    data: JSON.stringify(channels),
    dataType: "json",
    success: function(data, status, jqXHR) {
      toastr.success('Your channels have been successfully updated');
      callback();
    }
  });
}

function getProfiles(callback) {
  $.ajax({
    url: '/api/profiles?all=true',
    type: 'GET',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(profiles, status, jqXHR) {
      callback(profiles);
    }
  });
}

function saveProfile(profile, callback) {
  $.ajax({
    url: '/api/profiles/' + profile.title,
    type: 'PATCH',
    contentType: "application/json; charset=utf-8",
    data: JSON.stringify(profile),
    dataType: "json",
    success: function(data, status, jqXHR) {
      toastr.success(profile.title + ' has been saved');
      callback();
    }
  });
}

function deleteProfile(profileTitle, callback) {
  $.ajax({
    url: '/api/profiles/' + profileTitle,
    type: 'DELETE',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(data, status, jqXHR) {
      toastr.success(profileTitle + ' has been deleted');
      callback();
    }
  });
}

function getProfile(profileTitle, callback) {
  $.ajax({
    url: '/api/profiles/' + profileTitle,
    type: 'GET',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(profile, status, jqXHR) {
      callback(profile);
    }
  });
}

function saveProfileImage(profileTitle, file, callback) {
  var formData = new FormData();
  formData.append('file', file);

  $.ajax({
    type:'POST',
    url: "/api/profiles/" + profileTitle + "/image",
    data: formData,
    cache: false,
    contentType: false,
    processData: false,
    success: function(data) {
      callback();
    }
  });
}

function getLibraryCategories(profileTitle, callback) {
  getProfile(profileTitle, function(profile) {
    $.ajax({
      headers: {
        'token': profile.token
      },
      url: '/api/library/categories',
      type: 'GET',
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      success: function(categories, status, jqXHR) {
        callback(categories);
      }
    });
  });
}

function createDevice(device, callback) {
  $.ajax({
    url: '/api/devices',
    type: 'POST',
    contentType: "application/json; charset=utf-8",
    data: JSON.stringify(device),
    dataType: "json",
    success: function(data, status, jqXHR) {
      callback();
    }
  });
}

function scanDevice(deviceId, callback) {
  $.ajax({
    url: '/api/devices/' + deviceId + "/scan",
    type: 'POST',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(data, status, jqXHR) {
      callback();
    }
  });
}

function getDevices(callback) {
  $.ajax({
    url: '/api/devices',
    type: 'GET',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(devices, status, jqXHR) {
      callback(devices);
    }
  });
}

function getGrabberConfig(callback) {
  $.ajax({
    url: '/api/grabber',
    type: 'GET',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(grabberConfig, status, jqXHR) {
      callback(grabberConfig);
    }
  });
}

function saveGrabberConfig(grabberConfig, callback) {
  $.ajax({
    url: '/api/grabber',
    type: 'PUT',
    contentType: "application/json; charset=utf-8",
    data: JSON.stringify(grabberConfig),
    dataType: "json",
    success: function(data, status, jqXHR) {
      callback();
    }
  });
}

function getGrabberLineups(countryCode, postalCode, callback) {
  $.ajax({
    url: '/api/grabber/lineups/' + countryCode + '/' + postalCode,
    type: 'GET',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(lineups, status, jqXHR) {
      callback(lineups);
    }
  });
}

function saveDevice(device, callback) {
  $.ajax({
    url: '/api/devices',
    type: 'PATCH',
    contentType: "application/json; charset=utf-8",
    data: JSON.stringify(device),
    dataType: "json",
    success: function(data, status, jqXHR) {
      callback();
    }
  });
}


text:
.w-tabs-sm {border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; width: 100%;}
.w-tabs-sm .btn {border-radius: 0; border-bottom: none; border-top: none; padding: 4px 10px 3px; overflow: hidden; font-size: 14px;}
.w-tabs-sm .btn:first-child {border-left: none;}

.w-btn-group-sm {border-bottom: 1px solid #ccc; width: 100%;}
.w-btn-group-sm .btn {padding: 3px 10px 2px!important; border-radius: 0; border-top: none; border-bottom: none;}
.w-btn-group-sm .btn:first-child {border-left: none;}
.w-btn-group-sm.small .btn {padding: 0 8px!important; font-size: 12px; line-height: 16px;}


text:
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 330772 $ -->

<refentry xml:id="uconverter.geterrormessage" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>UConverter::getErrorMessage</refname>
  <refpurpose>Get last error message on the object</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
   <methodsynopsis>
   <modifier>public</modifier> <type>string</type><methodname>UConverter::getErrorMessage</methodname>
   <void />
   </methodsynopsis>
  <para>

  </para>

  &warn.undocumented.func;

 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  &no.function.parameters;
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>

  </para>
 </refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->


text:
#region Copyright
//
// DotNetNuke® - http://www.dotnetnuke.com
// Copyright (c) 2002-2017
// by DotNetNuke Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#endregion
#region Usings

using System;

#endregion

namespace DotNetNuke.Collections.Internal
{
    internal class MonitorLock : IDisposable, ISharedCollectionLock
    {
        private ExclusiveLockStrategy _lockStrategy;

        public MonitorLock(ExclusiveLockStrategy lockStrategy)
        {
            _lockStrategy = lockStrategy;
        }

        #region "IDisposable Support"

        // To detect redundant calls
        private bool _isDisposed;

        // IDisposable

        //override Finalize() only if Dispose(ByVal disposing As Boolean) above has code to free unmanaged resources.
        //Protected Overrides Sub Finalize()
        //    ' Do not change this code.  Put cleanup code in Dispose(ByVal disposing As Boolean) above.
        //    Dispose(False)
        //    MyBase.Finalize()
        //End Sub

        // This code added by Visual Basic to correctly implement the disposable pattern.
        public void Dispose()
        {
            // Do not change this code.  Put cleanup code in Dispose(ByVal disposing As Boolean) above.
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (!_isDisposed)
            {
                if (disposing)
                {
                    _lockStrategy.Exit();
                    _lockStrategy = null;
                }

                // TODO: free unmanaged resources (unmanaged objects) and override Finalize() below.
                // TODO: set large fields to null.
            }
            _isDisposed = true;
        }

        #endregion
    }
}


text:
#ifndef __COUCH_DB_EXCEPTION_HPP__
#define __COUCH_DB_EXCEPTION_HPP__

#include <string>

#include "couchdb/export.hpp"

namespace CouchDB
{

class COUCHDB_API Exception : public std::exception
{
public:
    Exception(const std::string&);
    virtual ~Exception() throw();
    virtual const char* what() const throw();

private:
    std::string message;
};

} //namespace CouchDB

#endif


text:
package br.com.fourdev.orderfood.dto;

public class VendaMesDTO {

	private String mes;

	private Integer total;

	public VendaMesDTO() {
	}

	public VendaMesDTO(String mes, Integer total) {
		this.mes = mes;
		this.total = total;
	}

	public String getMes() {
		return mes;
	}

	public void setMes(String mes) {
		this.mes = mes;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}

}


text:
> A JS Framework for creating realtime and scalable applications. Based on Emily.js and socket.io.

> _[Olives.js - flams.github.io/olives](http://flams.github.io/olives)_

## Learning Olives.js

The [Olives.js website](http://flams.github.io/olives) is a great resource for getting started.

Here are some links you may find helpful:

* [Documentation](http://flams.github.io/olives/docs/latest)
* [Applications built with Olives.js](http://flams.github.io/olives/#liveexamples)
* [Olives.js on GitHub](https://github.com/flams/olives)

_If you have other helpful links to share, or find any of the links above no longer work, please [let us know](https://github.com/tastejs/todomvc/issues)._

## Building the app

As this application is using node's module system, `browserify` or similar tool is required to package it for the browser. To build the app, simply do:

```
npm run build
```

To automatically rebuild the application as you make changes to the source code, you can do:

```
npm run watch
```

Make sure that you've installed all the dependencies first:

```
npm install
```


text:
package com.tvd12.ezyfox.bean.testing.configuration;

import com.tvd12.ezyfox.bean.EzyBeanContext;
import com.tvd12.ezyfox.bean.EzyPrototypeSupplier;
import com.tvd12.ezyfox.bean.impl.EzySimpleConfigurationLoader;
import com.tvd12.test.base.BaseTest;
import org.testng.annotations.Test;

public class ConfigurationTest2 extends BaseTest {

    @Test
    public void test() {
        EzyBeanContext context = EzyBeanContext.builder()
            .addSingletonClass(Singleton0.class)
            .addSingletonClass(SingletonA1.class)
            .build();
        context.getSingletonFactory().addSingleton(new Singleton1());
        context.getPrototypeFactory().addSupplier(new EzyPrototypeSupplier() {

            @Override
            public Object supply(EzyBeanContext context) {
                return new PrototypeEx11();
            }

            @Override
            public Class<?> getObjectType() {
                return PrototypeEx11.class;
            }
        });

        context.getPrototypeFactory().addSupplier(new EzyPrototypeSupplier() {

            @Override
            public Object supply(EzyBeanContext context) {
                return new PrototypeEx12();
            }

            @Override
            public Class<?> getObjectType() {
                return PrototypeEx12.class;
            }
        });

        new EzySimpleConfigurationLoader()
            .clazz(ConfigClassA2.class)
            .context(context)
            .load();
    }
}


text:
<!DOCTYPE html>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="description" content="conveying info on (mostly) politics and sports using data through programming and visualizations">
<meta name="keywords" content="politics,sports,development,conflict,R,Python,baseketball,sixers">

<base href="https://wtmatthias.com/">

<title>William Matthias</title>

<meta name="generator" content="Hugo 0.29" />

  <link href="Page%28%22William%20Matthias%22%29" rel="alternate" type="application/rss+xml" title="William Matthias" />
  <link href="Page%28%22William%20Matthias%22%29" rel="feed" type="application/rss+xml" title="William Matthias" />

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atelier-forest-light.min.css">

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:300,400|Open+Sans:300,300i,400,400i,600,600i,700|Oswald:400,500,600|Rufina">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
<link rel="stylesheet" href="https://wtmatthias.com/css/main.css">

<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/manifest.json">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="theme-color" content="#ffffff">

William Matthias

PhD Student at UT-Austin

Data. Politics & Development. Sports.

blog

about

projects


text:
<!DOCTYPE html>

    <meta http-equiv="refresh" content="0;URL=type.N705.html">

Redirecting to type.N705.html...


text:
CharacterDevice & CharacterDevice::operator << (uint32_t value)
{
  char buffer[12];
  size_t len = Numeric::toString(buffer, sizeof(buffer), value, 10);
  for(size_t i = 0; i < len; i++) {
    this->write(buffer[i]);
  }
  return *this;
}

CharacterDevice & CharacterDevice::operator << (int32_t value)
{
  char buffer[13];
  size_t len = Numeric::toString(buffer, sizeof(buffer), value, 10);
  for(size_t i = 0; i < len; i++) {
    this->write(buffer[i]);
  }
  return *this;
}

CharacterDevice & CharacterDevice::operator << (void *value)
{
  char buffer[13];
  size_t len = Numeric::toString(buffer, sizeof(buffer), reinterpret_cast<uint32_t>(value), 16);
  for(size_t i = 0; i < len; i++) {
    this->write(buffer[i]);
  }
  return *this;
}

CharacterDevice & CharacterDevice::operator << (bool value)
{
  if(value == true) {
    *this << "true";
  } else {
    *this << "false";
  }
  return *this;
}

#define NUMERIC_FMT_HANDLER char buffer[13]; \
	size_t prefixlen = this->printNumericPrefix(fmt.base); \
  size_t len = Numeric::toString(buffer, sizeof(buffer), fmt.value, fmt.base); \
	int delta = prefixlen + len; \
	if(fmt.padding < 0 && delta < -fmt.padding) { \
		this->putrep(fmt.padchar, -fmt.padding - delta); \
	} \
  for(size_t i = 0; i < len; i++) { \
    this->write(buffer[i]); \
  } \
	if(fmt.padding > 0 && delta < fmt.padding) { \
		this->putrep(fmt.padchar, fmt.padding - delta); \
	} \
  return *this

template<>
CharacterDevice & CharacterDevice::operator << <uint32_t>(const NumericFormat<uint32_t> & fmt)
{
  NUMERIC_FMT_HANDLER;
}

template<>
CharacterDevice & CharacterDevice::operator << <int32_t>(const NumericFormat<int32_t> & fmt)
{
  NUMERIC_FMT_HANDLER;
}

template<>
CharacterDevice & CharacterDevice::operator << <uint64_t>(const NumericFormat<uint64_t> & fmt)
{
  NUMERIC_FMT_HANDLER;
}

template<>
CharacterDevice & CharacterDevice::operator << <int64_t>(const NumericFormat<int64_t> & fmt)
{
  NUMERIC_FMT_HANDLER;
}

uint32_t CharacterDevice::printNumericPrefix(uint32_t base)
{
	switch(base) {
		case 2: *this << "0b"; return 2;
		case 8: *this << "0o"; return 2;
		case 10: return 0;
		case 16: *this << "0x"; return 2;
		default:
			*this << "[" << base << "]x";
			if(base < 10) return 4;
			if(base < 100) return 5;
			return 6;
	}
}

void CharacterDevice::putrep(char c, uint32_t repetitions)
{
	for(uint32_t i = 0; i < repetitions; i++)
		this->write(c);
}


text:
require_relative 'primitive_consul_lock'

module Choregraphie
  # This primitive is based on optimistic concurrency (using compare-and-swap) rather than consul sessions.
  # It allows to support the unavailability of the local consul agent (for reboot, reinstall, ...)
  # It is based on the notion of rack: all nodes inside a rack can take the lock at the same time. We only
  # allow a given number of racks to take the lock at the same time.
  # Note: this lock does not guarantee that all nodes of a given rack will be done at the same time.
  class ConsulRackLock < ConsulLock
    def initialize(options = {}, &block)
      @options = Mash.new(options)
      validate!(:rack, String) # id of the rack
      raise ArgumentError, '`service` option is not supported for consul_rack_lock' if @options[:service]

      super
    end

    def register(choregraphie)
      choregraphie.before do
        wait_until(:enter) { semaphore.enter(name: @options[:rack], server: @options[:id]) }
      end

      choregraphie.finish do
        # HACK: We can ignore failure there since it is only to release
        # the lock. If there is a temporary failure, we can wait for the
        # next run to release the lock without compromising safety.
        # The reason we have to be a bit more relaxed here, is that all
        # chef run including a choregraphie with this primitive try to
        # release the lock at the end of a successful run
        wait_until(:exit, max_failures: 5) { semaphore.exit(name: @options[:rack], server: @options[:id]) }
      end
    end

    def semaphore_class
      SemaphoreByRack
    end
  end

  class SemaphoreByRack < Semaphore
    def already_entered?(opts)
      name, server = validate_and_split!(opts)
      super && holders[name.to_s].key?(server.to_s)
    end

    def can_enter_lock?(opts)
      name, _server = validate_and_split!(opts)

      # we can always enter if our rack has the lock
      return true if holders.key?(name.to_s)

      super # we can enter if our rack can enter the lock
    end

    def enter_lock(opts)
      name, server = validate_and_split!(opts)
      holders[name.to_s] ||= {}
      holders[name.to_s][server.to_s] ||= Time.now
    end

    def exit_lock(opts)
      name, server = validate_and_split!(opts)
      holders[name.to_s].delete(server.to_s)
      holders.delete(name.to_s) if holders[name.to_s].empty?
    end

    private

    def validate_and_split!(opts)
      raise 'Must have a :name entry filled with rack identifier' unless opts[:name] && !opts[:name].empty?
      raise 'Must have a :server entry filled with server identifier' unless opts[:server] && !opts[:server].empty?

      [opts[:name], opts[:server]]
    end
  end
end


text:
package testCasesExecutables;

import com.jpeterson.x10.X10Util;

public class testCase17 {

	public static void main(String[] args) {
	X10Util util = new X10Util();

	System.out.print(util.deviceCode2byte(7));

	}

}


text:
/*
 * Licensed under MIT (https://github.com/ligoj/ligoj/blob/master/LICENSE)
 */
package org.ligoj.app.plugin.prov.model;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import lombok.Getter;
import lombok.Setter;

/**
 * Test class of {@link RoundSerializer}
 */
class RoundSerializerTest {

	@Getter
	@Setter
	static class Bean {
		@JsonSerialize(using = RoundSerializer.class)
		private Double nullable;

		@JsonSerialize(using = RoundSerializer.class)
		private double primary;
	}

	@Test
	void serializeNotNull() throws JsonProcessingException {
		final var bean = new Bean();
		bean.setNullable(1d);
		bean.setPrimary(2d);
		Assertions.assertEquals("{\"nullable\":1.0,\"primary\":2.0}", new ObjectMapper().writeValueAsString(bean));
	}

	@Test
	void serializeNull() throws JsonProcessingException {
		final var bean = new Bean();
		bean.setPrimary(2d);
		Assertions.assertEquals("{\"nullable\":null,\"primary\":2.0}", new ObjectMapper().writeValueAsString(bean));
	}
}


text:
<?php
namespace ARIPD\CMSBundle\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

/**
 * This is the class that manages ARIPDCMSBundle:File
 *
 * @Route("/file")
 */
class FileController extends Controller {

	/**
	 * Finds and displays an entity
	 *
	 * @param number $id
	 *
	 * @Route("/{id}/download", requirements={"id" = "\d+"}, name="aripd_cms_file_download")
	 * @Template()
	 */
	public function downloadAction($id) {
		$user = $this->container->get('security.context')->getToken()
				->getUser();

		$em = $this->getDoctrine()->getManager();

		$entity = $em->getRepository('ARIPDCMSBundle:File')
				->createQueryBuilder('f')->leftJoin('f.post', 'p')
				->where('f.id = ?1')->setParameter(1, $id)
				->andWhere('p.user = ?2')->setParameter(2, $user->getId())
				->getQuery()->getOneOrNullResult();

		if (!$entity) {
			throw $this->createNotFoundException('Unable to find');
		}

		$mime = $em->getRepository('ARIPDDefaultBundle:Mime')
				->findOneByExtension($entity->getExtension());

		$headers = array('Content-Type' => $mime->getType(),
				'Content-Disposition' => 'attachment; filename="'
						. $entity->getPath() . '"');

		$filename = $entity->getUploadRootDir() . '/' . $entity->getPath();

		return new Response(file_get_contents($filename), 200, $headers);
	}

}


text:
import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'

import { appLocation } from '../routes'
import Thanks from './thanks'

class CreateFinished extends React.Component {
  componentDidMount() {
    if (!this.props.hasSubmittedPetition) appLocation.push('/create_start.html')
  }

  render() {
    if (!this.props.hasSubmittedPetition) return null // We will also redirect in componentDidMount
    return (
      <div className='moveon-petitions share container background-moveon-white bump-top-1'>
        <Thanks isCreator petition={this.props.petition} />
      </div>
    )
  }
}

function mapStateToProps({ petitionCreateStore }) {
  return {
    hasSubmittedPetition: !!(petitionCreateStore && petitionCreateStore.submitted),
    petition: petitionCreateStore.petition
  }
}

CreateFinished.propTypes = {
  hasSubmittedPetition: PropTypes.bool,
  petition: PropTypes.object
}

export default connect(mapStateToProps)(CreateFinished)


text:
module GoogleGenomics
	class Read
	end
end


text:
package com.u6f6o.apps.hazelnate.application.rest.transformer;

import com.fasterxml.jackson.databind.ObjectMapper;
import spark.ResponseTransformer;

import java.io.IOException;

public class JsonTransformer implements ResponseTransformer {
    private static final ObjectMapper JACKSON_MAPPER = new ObjectMapper();

    @Override
    public String render(Object model) throws Exception {
        return JACKSON_MAPPER.writeValueAsString(model);
    }

    public <T> T parse(String content, Class<T> modelClazz) {
        try {
            return JACKSON_MAPPER.readValue(content, modelClazz);
        } catch (IOException e) {
            throw new IllegalStateException("Cannot parse json content", e);
        }
    }
}


text:
UPDATE images SET protected = 0 WHERE protected is NULL;
UPDATE image_members SET status = 'pending' WHERE status is NULL;

CREATE TEMPORARY TABLE images_backup (
  id VARCHAR(36) NOT NULL,
  name VARCHAR(255),
  size INTEGER,
  status VARCHAR(30) NOT NULL,
  is_public BOOLEAN NOT NULL,
  created_at DATETIME NOT NULL,
  updated_at DATETIME,
  deleted_at DATETIME,
  deleted BOOLEAN NOT NULL,
  disk_format VARCHAR(20),
  container_format VARCHAR(20),
  checksum VARCHAR(32),
  owner VARCHAR(255),
  min_disk INTEGER,
  min_ram INTEGER,
  protected BOOLEAN NOT NULL DEFAULT 0,
  virtual_size INTEGER,
  PRIMARY KEY (id),
  CHECK (is_public IN (0, 1)),
  CHECK (deleted IN (0, 1))
);

INSERT INTO images_backup
  SELECT id, name, size, status, is_public, created_at, updated_at, deleted_at, deleted, disk_format, container_format, checksum, owner, min_disk, min_ram, protected, virtual_size
  FROM images;

DROP TABLE images;

CREATE TABLE images (
  id VARCHAR(36) NOT NULL,
  name VARCHAR(255),
  size INTEGER,
  status VARCHAR(30) NOT NULL,
  is_public BOOLEAN NOT NULL,
  created_at DATETIME NOT NULL,
  updated_at DATETIME,
  deleted_at DATETIME,
  deleted BOOLEAN NOT NULL,
  disk_format VARCHAR(20),
  container_format VARCHAR(20),
  checksum VARCHAR(32),
  owner VARCHAR(255),
  min_disk INTEGER NOT NULL,
  min_ram INTEGER NOT NULL,
  protected BOOLEAN NOT NULL DEFAULT 0,
  virtual_size INTEGER,
  PRIMARY KEY (id),
  CHECK (is_public IN (0, 1)),
  CHECK (deleted IN (0, 1))
);

CREATE INDEX ix_images_deleted ON images (deleted);
CREATE INDEX ix_images_is_public ON images (is_public);
CREATE INDEX owner_image_idx ON images (owner);
CREATE INDEX checksum_image_idx ON images (checksum);

INSERT INTO images
  SELECT id, name, size, status, is_public, created_at, updated_at, deleted_at, deleted, disk_format, container_format, checksum, owner, min_disk,  min_ram, protected, virtual_size
  FROM images_backup;

DROP TABLE images_backup;

CREATE TEMPORARY TABLE image_members_backup (
  id INTEGER NOT NULL,
  image_id VARCHAR(36) NOT NULL,
  member VARCHAR(255) NOT NULL,
  can_share BOOLEAN NOT NULL,
  created_at DATETIME NOT NULL,
  updated_at DATETIME,
  deleted_at DATETIME,
  deleted BOOLEAN NOT NULL,
  status VARCHAR(20) NOT NULL DEFAULT 'pending',
  PRIMARY KEY (id),
  UNIQUE (image_id, member),
  CHECK (can_share IN (0, 1)),
  CHECK (deleted IN (0, 1)),
  FOREIGN KEY(image_id) REFERENCES images (id)
);

INSERT INTO image_members_backup
  SELECT id, image_id, member, can_share, created_at, updated_at, deleted_at, deleted, status
  FROM image_members;

DROP TABLE image_members;

CREATE TABLE image_members (
  id INTEGER NOT NULL,
  image_id VARCHAR(36) NOT NULL,
  member VARCHAR(255) NOT NULL,
  can_share BOOLEAN NOT NULL,
  created_at DATETIME NOT NULL,
  updated_at DATETIME,
  deleted_at DATETIME,
  deleted BOOLEAN NOT NULL,
  status VARCHAR(20) NOT NULL DEFAULT 'pending',
  PRIMARY KEY (id),
  UNIQUE (image_id, member),
  CHECK (can_share IN (0, 1)),
  CHECK (deleted IN (0, 1)),
  FOREIGN KEY(image_id) REFERENCES images (id),
  CONSTRAINT image_members_image_id_member_deleted_at_key UNIQUE (image_id, member, deleted_at)
);

CREATE INDEX ix_image_members_deleted ON image_members (deleted);
CREATE INDEX ix_image_members_image_id ON image_members (image_id);
CREATE INDEX ix_image_members_image_id_member ON image_members (image_id, member);

INSERT INTO image_members
  SELECT id, image_id, member, can_share, created_at, updated_at, deleted_at, deleted, status
  FROM image_members_backup;

DROP TABLE image_members_backup;

CREATE TEMPORARY TABLE image_properties_backup (
  id INTEGER NOT NULL,
  image_id VARCHAR(36) NOT NULL,
  name VARCHAR(255) NOT NULL,
  value TEXT,
  created_at DATETIME NOT NULL,
  updated_at DATETIME,
  deleted_at DATETIME,
  deleted BOOLEAN NOT NULL,
  PRIMARY KEY (id)
);

INSERT INTO image_properties_backup
  SELECT id, image_id, name, value, created_at, updated_at, deleted_at, deleted
  FROM image_properties;

DROP TABLE image_properties;

CREATE TABLE image_properties (
  id INTEGER NOT NULL,
  image_id VARCHAR(36) NOT NULL,
  name VARCHAR(255) NOT NULL,
  value TEXT,
  created_at DATETIME NOT NULL,
  updated_at DATETIME,
  deleted_at DATETIME,
  deleted BOOLEAN NOT NULL,
  PRIMARY KEY (id),
  CHECK (deleted IN (0, 1)),
  UNIQUE (image_id, name),
  FOREIGN KEY(image_id) REFERENCES images (id),
  CONSTRAINT ix_image_properties_image_id_name UNIQUE (image_id, name)
);

CREATE INDEX ix_image_properties_deleted ON image_properties (deleted);
CREATE INDEX ix_image_properties_image_id ON image_properties (image_id);

INSERT INTO image_properties (id, image_id, name, value, created_at, updated_at, deleted_at, deleted)
  SELECT id, image_id, name, value, created_at, updated_at, deleted_at, deleted
  FROM image_properties_backup;

DROP TABLE image_properties_backup;


text:
/**
 * Created by Dima Kostrub on 24.12.15.
 */

(function () {
    'use strict';

    var event, eventName = 'backbutton';

    if (document.createEvent) {
        event = document.createEvent("HTMLEvents");
        event.initEvent(eventName, true, true);
    } else {
        event = document.createEventObject();
        event.eventType = eventName;
    }

    event.eventName = eventName;

    if (document.createEvent) {
        document.dispatchEvent(event);
    } else {
        document.fireEvent('on' + event.eventType, event);
    }

    return eventName;

}());


text:
package com.emitrom.touch4j.client.core;

/**
 * An interface that enum icons should implement.
 */
public interface Icons {
    public String getValue();
}