text:
Text Indexation & Query Algorithms Playground

![Demo](https://github.com/xia0ben/iqplayground/blob/master/app-overview/iqplayground_test.gif)

## Aim

This project offers a graphical playground for discovering Text Indexation & Query Algorithms, and playing around with the many parameters to see how it may influence performance in terms of speed and memory consumption.

Since this is also a class project, we wanted to learn the several things from it :

- Learn Python (at the beginning, we were four out of five never to have programmed a full project in this language), and how to write decent python as compliant as possible with PEP8,
- Implement many of the Indexation & Query Algorithms that are used nowadays in most software,
- Think about how the activation and parameterizing of these algorithms influenced the overall performance,
- And naturally spend time trying to understand each other and work together as a team.

## Running the project:

### Prerequisites

	- Python 3.6
	- Git
	- Ideally, a GNU/Linux based operating system, though the code is meant to be portable

### Installation

- Clone the project:
```bash
git pull https://github.com/Xia0ben/IQPlayground.git
```
- If you have access to the "latimes" archive with all the files, you may want to uncompress it in the project's root (careful to remove the MACOSX subfolder and put all the content in the main latimes folder, and remove the .txt files manually : the files shouldn't be in "latimes/latimes" but in "latimes").
- Install PyGObject, GTK+ and their dependencies following the instructions at the following link : http://pygobject.readthedocs.io/en/latest/getting_started.html
- Install nltk and gi (using the python interpreter provided by the previous link):
```python
>>> import nltk
>>> import gi
>>> nltk.download()
```
- Install the numpy and sortedcontainers librairies with pip :
```bash
pip install numpy --index-url=http://pypi.python.org/simple/ --trusted-host pypi.python.org
pip install sortedcontainers
```

> If at execution time, the project fails and says that you are missing the "pickles" and "invertedfiles" folders in the project's root directory, create them manually.

### Execution

- Console mode:
	+ access the project repository in the console
	+ run "console_mode_launch.py" with the python interpreter in you installed everything.

- Graphical mode:
  + run "launch.py" with the python interpreter in you installed everything.

## Description of the packages

+ Algorithm:

	- Contains classes for each algorithm

  - Each algorithm is derived from the baseAlgorithm class

  - naiveAlgorithm : a naive query algorithm based on parallel scan of the posting lists

  - FA_Algorithm : Fagin's top-k query algorithm

  - TA_Algorithm : Fagin's thershold algorithm

+ Executable

	- Contains an executable class which act as a controller for the project

+ Files

  - Contains multiple classes which act with the memory and the hard drive

  - document : a memory based representation of a document

  - fileToPostingList : read a pl FILE to generate memory based posting lists when needed

  - invertedFile : memory based inverted file, which do a merge based creation of the posting lists

  - postingList : a memory based representation of the posting lists with 3 access :
    + randomaccess : return the score of a doc id in log(n) time
    + alphaaccess : return the doc_id and score ordered by doc_id
    + orderedaccess : return the doc_id and score ordered by score

  - reader : read a file and returns documents

  - stemmer : implementation of porter's algorithm

  - variableByte : encoding and decoding of variable byte integers

> Explaining Encoding :
  + Get the last seven bits from the binary code 1100001001 is 0001001,
  + Add 1 as the "head" bit (0001001 -> 10001001)
  + Because there are still 3 bits left in the original binary code.
    Get the remain 3 bits, this time use 0 as the "head" bit (110 -> 00000110)
  + Because there is no remain in the original binary code
    put these two bytes together 0000011010001001 is the VB code.

+ RandomIndexing

  - Contains classes used for the random indexing of terms

  - randomIndex : Contains a class with different functions to get context vector for a term

  - vectorsSimilarity : Contains functions to calculate Cosinus distance between context vectors
    this distance is in the interval [0-2]

+ Stats

  - Contains classes which allow to get stats on indexing and querying

+ UI

  - Contains files used to generate the user interface

## Project Preparation

### Learning prerequisites

Learn Python 3 :

+ [Quickstart](https://learnxinyminutes.com/docs/python3/)
+ [Style Guide](https://www.python.org/dev/peps/pep-0008/)
+ [Official Documentation](https://docs.python.org/3/)
+ [If you want to suffer](https://learncodethehardway.org/more-python/)
+ [CheatSheet 1](http://overapi.com/python)
+ [CheatSheet 2](https://devhints.io/python)

To test and use quickly without an IDE :

+ [Online code tester](https://tio.run/)

Use Pycharm :

+ [To install it quickly on Ubuntu](https://itsfoss.com/install-pycharm-ubuntu/)

### Feature Goals

#### Indexing :

+ Parse pseudo-xml files into usable objects
+ Tokenization of each of the documents : use the [nltk Python library](http://www.nltk.org/api/nltk.tokenize.html)
+ Stemming : may help save place but is useless outside of this scope -> use a library. Allow user to activate or deactivate it.
+ Stop words removal : use a library. Allow user to activate or deactivate it.
+ Inverted file : Implement this mapping between vocabulary of terms (VOC) and posting lists (PL).
+ Merge-based algorithm To build the IF : to research and implement
+ PL Compression : to research and implement
+ Variable Byte : Implement following [this proposition](https://github.com/utahta/pyvbcode).
+ Score computation : To be implemented with variations that the user can play with.
+ Random indexing : Search pseudo-code and implement

#### Querying :

+ Fagin's top-k query algorithm (FA) : To implement with possibilities for variations.

#### Graphical User interface

Simple graphical user interface with search bar(s), some checkboxes to activate some other options, and a text area where results can be displayed (list of articles with id, title, file name). When you click on it, displays

### First iteration 06/10/2017 -> 08/10/2017

- Alexis writes a basic implementation to get everyone started :

	+ Parse pseudo-xml files into usable objects without library : make each document into a separate object, removing all the XML markup and considering all the rest as text
	+ Simple tokenization of each of the documents using nltk (space-based rule with some exceptions managed by the library)
	+ Basic fully in-memory inverted file, with scores computed as the product of the term-frequency and inverse-document-frequency, with posting-lists ordered by DOCID
	+ For queries, input the query in terminal
	+ Parallel scan all posting-lists to find each DOCID that has all search terms at least once
	+ Consider all queries are only conjunctive and aggregate the scores as a simple sum of the score of each term for each document
	+ Sort document list by score and output DOCIDs of the 5 first ones in terminal

- All others learn Python through at least the QuickStart and the PEP8 (ideally with Learn Python the hard way if they can)

### First code review 09/10/2017 from 10 to 12 a.m.

+ Discussion around a nice cup of tea/chocolate/coffee.

+ Alexis presents the basic structure of the project and the strategy for expanding the different elements (packages, classes, functions, ...).

+ Affectation of the elements for the second iteration.

### Second iteration 09/10/2017 -> 15/10/2017

> Important note : For each feature, think about parameterizing it so that it is possible to play with it in the GUI (for example, change the ponderation of words that are in the document title when computing the inverted file).

+ Simple GUI using [PyGObject](https://pygobject.readthedocs.io/en/latest/), [Kivy](https://kivy.org/) or [PySide](http://wiki.qt.io/PySide)
	-> SHOTGUN By Benoit :D

+ Better parse the different XML elements of the file so that it is possible to ponderate the computation of the scores in the inverted file depending on whether the terms are the title or if they must agree with a particular date, ...
	-> TODO By Zakaria

+ Deactivable (through UI) stemming and stop words removal that is going to influence the creation of the
	-> TODO By Omar

+ Merge-based creation of the inverted file (see slide 24 of teacher's slideshow)
	-> TODO By Alexis

+ PL Compression : Variable Byte Encoding (see slides 26 to 29 of teacher's slideshow)
	-> TODO By Bachir

### Second code review 16/10/2017 from 8 to 10 a.m.

+ Discussion around a nice cup of tea/chocolate/coffee.

+ Presentation of each person's work for 20 minutes max.

+ Affectation of the elements for the third iteration in the remaining time.

### Third iteration 16/10/2017 -> 19/10/2017

+ Fagin's threshold algorithm (TA) (Top-k improvement, so we don't do the FA before) (see slides 16 to 18, then 19 to 21 of teacher's slideshow), with Espilon-approximation of Top-K Answers (see slide 22 of teacher's slideshow)
	-> TODO By Zakaria

+ Random Indexing (see slide 32 of teacher's slideshow)
	-> TODO By Bachir

+ Allow OR clause instead of only AND
	-> TODO By Alexis

+ Improvement of the GUI : Logging of queries ad associated results + performance indicators (processor time, memory used, number of reads of posting-lists...)
	-> SHOTGUN By Benoit :D

### Third code review 19/10/2017 from 4:30 to 6:30 p.m.

+ Discussion around a nice cup of tea/chocolate/coffee.

+ Presentation of each person's work for 20 minutes max.

+ Bug fixes.

### Preparation of the presentation 19/10/2017 from 6:30 to 8:30 p.m.

+ Overall bug fixes

+ Preparation of slideshow and oral presentation.

### Preparation of the presentation 20/10/2017 from 10 to 17 a.m

+ Overall bug fixes

+ Preparation of slideshow and oral presentation.

### Presentation 20/10/2017 from 17 to 18 a.m

+ BE AWESOME ! :D


text:
/**
 * @fileoverview Java Script Builtins for windows properties.
 *
 * @externs
 */

 /**
 * @see https://cocos2d-x.org
 */

/**
 * cocos2d-html5-only.
 * @type {string}
 */
CSSProperties.prototype._super;

/**
 * cocos2d-html5-only. We need this because the cc.Class.extend's new
 * infrastructure requires it.
 * @type {string}
 */
CSSProperties.prototype.ctor;

/**
 * cocos2d-html5-only.
 * @type {string}
 */
CSSProperties.prototype.Inflate;

/**
 * cocos2d-html5-only.
 * @type {string}
 */
CSSProperties.prototype.decompress;

/**
 * Accelerometer api
 * cocos2d-html5-only.
 * @type {string}
 */
CSSProperties.prototype.DeviceOrientationEvent;
CSSProperties.prototype.DeviceMotionEvent;
CSSProperties.prototype.accelerationIncludingGravity;
CSSProperties.prototype.gamma;
CSSProperties.prototype.beta;
CSSProperties.prototype.alpha;

var gl = gl || {};
CSSProperties.prototype.gl;

CSSProperties.prototype.AudioContext;
CSSProperties.prototype.webkitAudioContext;
CSSProperties.prototype.mozAudioContext;
CSSProperties.prototype.createBufferSource;
CSSProperties.prototype.createGain;
CSSProperties.prototype.createGainNode;
CSSProperties.prototype.destination;
CSSProperties.prototype.decodeAudioData;
CSSProperties.prototype.gain;
CSSProperties.prototype.connect;

redpajama_set_name: RedPajamaGithub


text:
package com.microsoft.azure.management.logic;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * Defines values for SkuName.
 */
public enum SkuName {
    /** Enum value NotSpecified. */
    NOT_SPECIFIED("NotSpecified"),

    /** Enum value Free. */
    FREE("Free"),

    /** Enum value Shared. */
    SHARED("Shared"),

    /** Enum value Basic. */
    BASIC("Basic"),

    /** Enum value Standard. */
    STANDARD("Standard"),

    /** Enum value Premium. */
    PREMIUM("Premium");

    /** The actual serialized value for a SkuName instance. */
    private String value;

    SkuName(String value) {
        this.value = value;
    }

    /**
     * Parses a serialized value to a SkuName instance.
     *
     * @param value the serialized value to parse.
     * @return the parsed SkuName object, or null if unable to parse.
     */
    @JsonCreator
    public static SkuName fromString(String value) {
        SkuName[] items = SkuName.values();
        for (SkuName item : items) {
            if (item.toString().equalsIgnoreCase(value)) {
                return item;
            }
        }
        return null;
    }

    @JsonValue
    @Override
    public String toString() {
        return this.value;
    }
}


text:
from subprocess import check_call, STDOUT

check_call('pip install wheel', stderr = STDOUT)
check_call('python setup.py bdist_wheel', stderr = STDOUT)


text:
package ru.stqa;

import org.junit.Assert;
import org.openqa.selenium.Keys;
import org.openqa.selenium.support.ui.Select;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import java.io.File;
import java.util.List;
import java.util.NoSuchElementException;

/**
 * Created by Zhanna on 13.03.2017.
 * Тест для задания №12
 */
public class AddNewGood extends TestBase {
    File file = new File("src/test/java/ru/stqa/kettlebell.jpg");
    public boolean isElementPresent(By locator) {
        try {
            driver.findElement(locator);
            return true;
        }
        catch (NoSuchElementException e) {
            return false;
        }
    }

    @Test
    public void newGood() throws Exception{
        driver.get("http://localhost/litecart/admin");
        driver.findElement(By.name("username")).sendKeys("admin");
        driver.findElement(By.name("password")).sendKeys("admin");
        driver.findElement(By.name("login")).click();
        List<WebElement> categories = driver.findElements(By.cssSelector("li#app-"));
        for (int i = 0; i < categories.size(); i++){
            if(categories.get(i).getText().equals("Catalog")){
                categories.get(i).click();
                break;
            }
        }
        driver.findElement(By.cssSelector("a[href*='edit_product']")).click();
        WebElement enabled = driver.findElement(By.cssSelector("input[name=status][value='1']"));
        enabled.click();
        Assert.assertTrue(enabled.isSelected());
        driver.findElement(By.cssSelector("input[name='name[en]']")).sendKeys("Some Name");
        driver.findElement(By.cssSelector("input[name='code']")).sendKeys("Some Code");
        driver.findElement(By.cssSelector("input[type=checkbox][value='0']")).click();
        driver.findElement(By.cssSelector("input[type=checkbox][value='1']")).click();
        Select defaultCategory = new Select(driver.findElement(By.cssSelector("select[name=default_category_id]")));
        defaultCategory.selectByVisibleText("Rubber Ducks");
        WebElement gender = driver.findElement(By.cssSelector("input[value='1-3']"));
        gender.click();
        Assert.assertTrue(gender.isSelected());
        WebElement quantity = driver.findElement(By.cssSelector("input[name='quantity']"));
        quantity.clear();
        quantity.sendKeys("100");
        Select soldOutStatusId = new Select(driver.findElement(By.cssSelector("select[name=sold_out_status_id]")));
        soldOutStatusId.selectByVisibleText("Temporary sold out");
        //Загрузка изображения с преобразование относительного пути в абсолютный
        driver.findElement(By.cssSelector("input[name*=new_images]")).sendKeys(file.getAbsolutePath());
        driver.findElement(By.cssSelector("input[name='date_valid_from']")).sendKeys("01012015");
        driver.findElement(By.cssSelector("input[name='date_valid_to']")).sendKeys("01012020");
        //Переход на страницу Information
        driver.findElement(By.xpath("//a[contains(text(),'Information')]")).click();
        Select manufacturer_id = new Select(driver.findElement(By.cssSelector("select[name=manufacturer_id]")));
        manufacturer_id.selectByVisibleText("ACME Corp.");
        driver.findElement(By.cssSelector("input[name=keywords]")).sendKeys("Some Keywords");
        driver.findElement(By.cssSelector("input[name*=short_description]")).sendKeys("Some Description");
        driver.findElement(By.cssSelector("div.trumbowyg-editor")).sendKeys("Some Description Too");
        driver.findElement(By.cssSelector("input[name*=head_title]")).sendKeys("Some Title");
        driver.findElement(By.cssSelector("input[name*=meta_description]")).sendKeys("Some Meta Description");
        //Переход на страницу Prices
        driver.findElement(By.xpath("//a[contains(text(),'Prices')]")).click();
        WebElement purchasePrice = driver.findElement(By.cssSelector("input[name=purchase_price]"));
        purchasePrice.clear();
        purchasePrice.sendKeys("1500");
        Select priceSelect = new Select(driver.findElement(By.cssSelector("select[name=purchase_price_currency_code]")));
        priceSelect.selectByVisibleText("US Dollars");
        driver.findElement(By.cssSelector("input[name*=USD]")).sendKeys("1500");
        driver.findElement(By.cssSelector("input[name*=EUR]")).sendKeys("1407");
        driver.findElement(By.cssSelector("a#add-campaign")).click();
        WebElement startDate = driver.findElement(By.cssSelector("input[name*=start_date]"));
        startDate.sendKeys("13032000");
        startDate.sendKeys(Keys.TAB);
        startDate.sendKeys("1830");
        WebElement endDate = driver.findElement(By.cssSelector("input[name*=end_date]"));
        endDate.sendKeys("13033000");
        endDate.sendKeys(Keys.TAB);
        endDate.sendKeys("0630");
        List<WebElement> listOfUsd = driver.findElements(By.cssSelector("input[name*=USD]"));
        listOfUsd.get(listOfUsd.size()-1).sendKeys("1500");
        //Создание товара
        driver.findElement(By.cssSelector("button[name=save]")).click();
        //Проверка наличия товара
        driver.findElement(By.xpath("//a[contains(text(),'Rubber Ducks')]")).click();
        Assert.assertEquals("Some Name", driver.findElement(By.xpath("//a[contains(text(),'Some Name')]")).getText());
        isElementPresent(By.xpath("//a[contains(text(),'Some Name')]"));
    }
}


text:
Option Explicit On
Option Strict On

Imports NUnit.Framework

Namespace CompuMaster.Test.Data

    <TestFixture(Category:="TextTables")> Public Class TextCellTest

        <Test> Public Sub LineBreaksCount()
            Dim DbNullText As String = "<NULL>"
            Dim TabText As String = "    "
            Dim Cell As CompuMaster.Data.TextCell

            Cell = New CompuMaster.Data.TextCell("Line 1" & ControlChars.CrLf & ControlChars.Tab & "- Line 2 (with extra chars)" & ControlChars.Cr & "Line 3" & ControlChars.Lf & "Line 4")
            Assert.AreEqual(3, Cell.LineBreaksCount)
            Assert.AreEqual(4, Cell.TextLines(DbNullText, TabText).Length)
            Assert.AreEqual(New String() {
                            "Line 1", "    - Line 2 (with extra chars)", "Line 3", "Line 4"
                            }, Cell.TextLines(DbNullText, TabText))
            Assert.AreEqual(31, Cell.MaxWidth(DbNullText, TabText))
        End Sub

    End Class

End Namespace


text:
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace Krystal.Core
{
    /// <summary>
    /// Plays a powerpoint on the commands of "powerpoint" and "presentation".
    /// </summary>
    public class PlayPowerpointCommand: FileCommand,ICommand
    {
        #region Constructors
        /// <summary>
        /// Initializes a new instance of the <see cref="Krystal.Core.PlayPowerpointCommand"/> class.
        /// picks a random powerpoint to play from the user's My Documents Directory, recognizes
        /// "powerpoint" and "presentation"
        /// </summary>
        public PlayPowerpointCommand()
        {
            Commands= new List<String>(new [] {"powerpoint","presentation"});
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Krystal.Core.PlayPowerpointCommand"/> class.
        /// plays the powerpoint passed in by the path.  Recognizes "powerpoint" and "presentation"
        /// </summary>
        /// <param name="path">Path.</param>
        public PlayPowerpointCommand(String path):this()
        {
            CheckFileExists(path);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Krystal.Core.PlayPowerpointCommand"/> class.
        /// plays the powerpoint passed in by the path, and utilizes the commands passed in, it is
        /// recommended you use an anonymous type.
        /// </summary>
        /// <param name="path">Path.</param>
        /// <param name="commands">Commands.</param>
        public PlayPowerpointCommand(String path, String[] commands)
        {
            CheckFileExists(path);
            Commands.AddRange(commands);
        }
        #endregion

        #region Methods
        public override void Execute()
        {
            if(PlayPath == null)
            {
                var files = new List<String>(Directory.GetFiles(
                    Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)));

                //strain out the files that aren't powerpoints
                var temp = from file in files
                        where file.Contains(".pptx") || file.Contains(".ppt") || file.Contains(".odp")
                    select file;

                files = new List<String>(temp);
                ExecuteRandomFile(files);
            }
            else
            {
                Execute(PlayPath);
            }
        }
        #endregion
        #region Properties
        public List<String> Commands
        {
            get;
            private set;
        }
        #endregion
    }
}


text:
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
from blog.views import common

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^blog/', include('blog.urls')),
<<<<<<< HEAD
    url(r'^$', common.index, name='main_index'),
=======
    url(r'^$', views.index, name='main_index'),
>>>>>>> 98adf8242f75a50d948056c25c0a6dc59ffc2b33

)

if not settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_PATH)

if settings.DEBUG:
    urlpatterns += patterns(
        'django.views.static',
        (r'^media/(?P<path>.*)',
         'serve',
         {'document_root': settings.MEDIA_ROOT})

    )


text:
<?php

namespace Strider2038\ImgCache\Exception;

use Strider2038\ImgCache\Enum\HttpStatusCodeEnum;

/**
 * @author Igor Lazarev <strider2038@rambler.ru>
 */
class ImageSourceNotFoundException extends ApplicationException
{
    public function __construct(
        string $message = '',
        int $code = HttpStatusCodeEnum::NOT_FOUND,
        \Throwable $previous = null
    ) {
        parent::__construct($message, $code, $previous);
    }
}


text:
<module>
  <inherits name="com.google.gwt.user.User" />
  <inherits name="com.google.api.gwt.oauth2.OAuth2" />
  <inherits name="com.google.common.collect.Collect" />
  <inherits name="com.google.web.bindery.autobean.AutoBean" />
  <inherits name="com.google.gwt.json.JSON" />

  <entry-point class="com.google.api.explorer.client.ExplorerEntryPoint" />

  <!-- Use Cross-site IFrame linker. -->
  <add-linker name="xsiframe" />
</module>


text:
package com.javiertarazaga.instasearch.presentation;

import com.javiertarazaga.instasearch.domain.executor.PostExecutionThread;
import io.reactivex.Scheduler;
import io.reactivex.android.schedulers.AndroidSchedulers;
import javax.inject.Inject;
import javax.inject.Singleton;

/**
 * MainThread (UI Thread) implementation based on a {@link Scheduler}
 * which will execute actions on the Android UI thread
 */
@Singleton
public class UIThread implements PostExecutionThread {

  @Inject
  UIThread() {}

  @Override public Scheduler getScheduler() {
    return AndroidSchedulers.mainThread();
  }
}


text:
// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

using System.Collections.Generic;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.CSharp.Symbols;

namespace Microsoft.CodeAnalysis.CSharp
{
    /// <summary>
    /// This binder is for binding the argument to typeof.  It traverses
    /// the syntax marking each open type ("unbound generic type" in the
    /// C# spec) as either allowed or not allowed, so that BindType can
    /// appropriately return either the corresponding type symbol or an
    /// error type.  It also indicates whether the argument as a whole
    /// should be considered open so that the flag can be set
    /// appropriately in BoundTypeOfOperator.
    /// </summary>
    internal sealed class TypeofBinder : Binder
    {
        private readonly Dictionary<GenericNameSyntax, bool> _allowedMap;
        private readonly bool _isTypeExpressionOpen;

        internal TypeofBinder(ExpressionSyntax typeExpression, Binder next)
            // Unsafe types are not unsafe in typeof, so it is effectively an unsafe region.
            : base(next, next.Flags | BinderFlags.UnsafeRegion)
        {
            OpenTypeVisitor.Visit(typeExpression, out _allowedMap, out _isTypeExpressionOpen);
        }

        internal bool IsTypeExpressionOpen { get { return _isTypeExpressionOpen; } }

        protected override bool IsUnboundTypeAllowed(GenericNameSyntax syntax)
        {
            bool allowed;
            return _allowedMap != null && _allowedMap.TryGetValue(syntax, out allowed) && allowed;
        }

        /////// <summary>
        /////// Returns the list of the symbols which represent the argument of the nameof operator. Ambiguities are not an error for the nameof.
        /////// </summary>
        ////internal ImmutableArray<Symbol> LookupForNameofArgument(ExpressionSyntax left, IdentifierNameSyntax right, string name, DiagnosticBag diagnostics, bool isAliasQualified, out bool hasErrors)
        ////{
        ////    ArrayBuilder<Symbol> symbols = ArrayBuilder<Symbol>.GetInstance();
        ////    Symbol container = null;
        ////    hasErrors = false;

        ////    // We treat the AliasQualified syntax different than the rest. We bind the whole part for the alias.
        ////    if (isAliasQualified)
        ////    {
        ////        container = BindNamespaceAliasSymbol((IdentifierNameSyntax)left, diagnostics);
        ////        var aliasSymbol = container as AliasSymbol;
        ////        if (aliasSymbol != null) container = aliasSymbol.Target;
        ////        if (container.Kind == SymbolKind.NamedType)
        ////        {
        ////            diagnostics.Add(ErrorCode.ERR_ColColWithTypeAlias, left.Location, left);
        ////            hasErrors = true;
        ////            return symbols.ToImmutableAndFree();
        ////        }
        ////    }
        ////    // If it isn't AliasQualified, we first bind the left part, and then bind the right part as a simple name.
        ////    else if (left != null)
        ////    {
        ////        // We use OriginalDefinition because of the unbound generic names such as List<>, Dictionary<,>.
        ////        container = BindNamespaceOrTypeSymbol(left, diagnostics, null, false).OriginalDefinition;
        ////    }

        ////    this.BindNonGenericSimpleName(right, diagnostics, null, false, (NamespaceOrTypeSymbol)container, isNameofArgument: true, symbols: symbols);
        ////    if (CheckUsedBeforeDeclarationIfLocal(symbols, right))
        ////    {
        ////        Error(diagnostics, ErrorCode.ERR_VariableUsedBeforeDeclaration, right, right);
        ////        hasErrors = true;
        ////    }
        ////    else if (symbols.Count == 0)
        ////    {
        ////        hasErrors = true;
        ////    }
        ////    return symbols.ToImmutableAndFree();
        ////}

        /// <summary>
        /// This visitor walks over a type expression looking for open types.
        /// Open types are allowed if an only if:
        ///   1) There is no constructed generic type elsewhere in the visited syntax; and
        ///   2) The open type is not used as a type argument or array/pointer/nullable
        ///        element type.
        /// </summary>
        private class OpenTypeVisitor : CSharpSyntaxVisitor
        {
            private Dictionary<GenericNameSyntax, bool> _allowedMap;
            private bool _seenConstructed;
            private bool _seenGeneric;

            /// <param name="typeSyntax">The argument to typeof.</param>
            /// <param name="allowedMap">
            /// Keys are GenericNameSyntax nodes representing unbound generic types.
            /// Values are false if the node should result in an error and true otherwise.
            /// </param>
            /// <param name="isUnboundGenericType">True if no constructed generic type was encountered.</param>
            public static void Visit(ExpressionSyntax typeSyntax, out Dictionary<GenericNameSyntax, bool> allowedMap, out bool isUnboundGenericType)
            {
                OpenTypeVisitor visitor = new OpenTypeVisitor();
                visitor.Visit(typeSyntax);
                allowedMap = visitor._allowedMap;
                isUnboundGenericType = visitor._seenGeneric && !visitor._seenConstructed;
            }

            public override void VisitGenericName(GenericNameSyntax node)
            {
                _seenGeneric = true;

                SeparatedSyntaxList<TypeSyntax> typeArguments = node.TypeArgumentList.Arguments;
                if (node.IsUnboundGenericName)
                {
                    if (_allowedMap == null)
                    {
                        _allowedMap = new Dictionary<GenericNameSyntax, bool>();
                    }
                    _allowedMap[node] = !_seenConstructed;
                }
                else
                {
                    _seenConstructed = true;
                    foreach (TypeSyntax arg in typeArguments)
                    {
                        Visit(arg);
                    }
                }
            }

            public override void VisitQualifiedName(QualifiedNameSyntax node)
            {
                bool seenConstructedBeforeRight = _seenConstructed;

                // Visit Right first because it's smaller (to make backtracking cheaper).
                Visit(node.Right);

                bool seenConstructedBeforeLeft = _seenConstructed;

                Visit(node.Left);

                // If the first time we saw a constructed type was in Left, then we need to re-visit Right
                if (!seenConstructedBeforeRight && !seenConstructedBeforeLeft && _seenConstructed)
                {
                    Visit(node.Right);
                }
            }

            public override void VisitAliasQualifiedName(AliasQualifiedNameSyntax node)
            {
                Visit(node.Name);
            }

            public override void VisitArrayType(ArrayTypeSyntax node)
            {
                _seenConstructed = true;
                Visit(node.ElementType);
            }

            public override void VisitPointerType(PointerTypeSyntax node)
            {
                _seenConstructed = true;
                Visit(node.ElementType);
            }

            public override void VisitNullableType(NullableTypeSyntax node)
            {
                _seenConstructed = true;
                Visit(node.ElementType);
            }
        }
    }
}


text:
Lean eBay Trading API client. It implements only a few methods of the API, the ones that we need for CollectPlus.

## Installation

Add this line to your application's Gemfile:

    gem 'ebay', git: 'https://github.com/CPlus/ebay-cplus'

## Configuration

In Rails just create a file at `config/ebay.yml` with the following
content:

``` yaml
development: &dev
  dev_id:  ...
  app_id:  ...
  cert:    ...
  ru_name: ...
  use_sandbox: yes

staging:
  <<: *dev

production: &prod
  dev_id:  ...
  app_id:  ...
  cert:    ...
  ru_name: ...
  use_sandbox: no
```

Also, you might want to download [eBay's latest
WSDL](http://developer.ebay.com/webservices/latest/eBaySvc.wsdl) and
save it to `config/eBaySvc.wsdl` during development. This file will also
be picked up automatically in a Rails application.  It's not recommended
to do this in production as it can degrade performance of API requests.

When not using the gem within a Rails app, or if you want to configure
it manually, you can use any of the following methods:

``` ruby
# 1. Configure from a YAML file
# env is only needed if YAML file contains configuration for multiple environments
Ebay::Api.configure_from_yaml(path, env)

# 2. Configure with a hash of options
Ebay::Api.configure dev_id: '...', app_id: '...', cert: '...',
                    ru_name: '...', use_sandbox: true

# 3. Set everything separately
Ebay::Api.dev_id = 'your-ebay-dev-id'
Ebay::Api.app_id = 'your-ebay-app-id'
Ebay::Api.cert = 'your-ebay-auth-cert'
Ebay::Api.ru_name = "your-ru-name"
Ebay::Api.use_sandbox = true
```

## Usage

``` ruby
# wsdl is optional, and recommended only with a local copy and during
# development, otherwise it might slow down the request/response cycle
client = Ebay::Api.new wsdl: './eBaySvc.wsdl'

sid = client.get_session_id
Ebay::Api.ru_url(sid.session_id) # => "https://signin.sandbox.ebay.com/ws/eBayISAPI.dll?...
# visit this url and authorize the application
token = client.fetch_token(sid.session_id)

client = Ebay::Api.new auth_token: token.ebay_auth_token

client.get_orders number_of_days: 7
```

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request


text:
<?php
return array (
  'Permalink to this post' => 'Lien permanent vers cette publication',
  'Close' => 'Fermer',
  'Permalink' => 'Lien permanent',
);


text:
<!DOCTYPE html>

  <meta charset="utf-8">

  <title>page1 | Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description">
<meta property="og:type" content="website">
<meta property="og:title" content="page1">
<meta property="og:url" content="http://yoursite.com/page1/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description">
<meta property="og:updated_time" content="2016-03-11T13:49:02.232Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="page1">
<meta name="twitter:description">

    <link rel="alternate" href="/atom.xml" title="Hexo" type="application/atom+xml">

    <link rel="icon" href="/favicon.png">

    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">

  <link rel="stylesheet" href="/css/style.css">

        Hexo

          Home

          Archives

        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit"></button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>

  <time datetime="2016-03-11T13:49:02.000Z" itemprop="datePublished">2016-03-11</time>

      page1

      Delen

Archieven

March 2016

Recente berichten

            my blog3

            my blog2

            my first blog

            Hello World

      © 2016 John Doe

      Powered by Hexo

    Home

    Archives

  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">


text:
<?php
/*
 Plugin Name: Debug Bar Extender
 Plugin URI: http://wordpress.org/extend/plugins/debug-bar-extender/
 Description: A minimalistic profiler / debugging class that hooks into the debug bar and can be implemented easily
 Author: Thorsten Ott, Automattic
 Version: 0.5
 Author URI: http://hitchhackerguide.com
 */

/**
 * Usage example to debug the loop of a theme:
 *
 *
 * In the index.php add your checkpoints
 *
 * ...
 * <?php if (have_posts()) : ?>
 *
 * <?php dbgx_checkpoint('loop start'); ?>
 *
 * <?php while (have_posts()) : the_post(); ?>
 *
 * <?php dbgx_trace_var( $post ); ?>
 * <?php dbgx_checkpoint('loop1'); ?>
 *
 * <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
 * <?php //before_post(); ?>
 *
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?>

 * <?php the_time(get_option('date_format')) ?> by <?php the_author() ?>
 *

 * <?php the_content(__('Read the rest of this entry »', 'kubrick')); ?>
 *

 *
<?php the_tags(__('Tags:', 'kubrick') . ' ', ', ', '
'); ?> <?php printf(__('Posted in %s', 'kubrick'), get_the_category_list(', ')); ?> | <?php edit_post_link(__('Edit', 'kubrick'), '', ' | '); ?> <?php comments_popup_link(__('No Comments »', 'kubrick'), __('1 Comment »', 'kubrick'), __('% Comments »', 'kubrick')); ?>

 * <?php after_post(); ?>
 *

 *
 * <?php dbgx_checkpoint('loop2'); ?>
 *
 * <?php endwhile; ?>
 *
 * <?php dbgx_checkpoint('loop end'); ?>
 *
 *

 *
<?php next_posts_link(__('« Older Entries', 'kubrick')) ?>

 *
<?php previous_posts_link(__('Newer Entries »', 'kubrick')) ?>

 *

 * <?php else : ?>
 * ...
 *
 */
class Debug_Bar_Extender {

	private static $__instance = NULL;

	private $start_time = 0;
	private $previous_time = 0;
	private $current_time = 0;
	private $elapsed_time = 0;
	private $end_time = 0;

	private $use_error_log = false;

	private $settings = array();
	private $default_settings = array();
	private $settings_texts = array();

	private $profile_data = array();
	private $memcache_lookup = array();
	private $variable_lookup = array();

	public function __construct() {
		add_action( 'admin_init', array( &$this, 'register_setting' ) );
		add_action( 'admin_menu', array( &$this, 'register_settings_page' ) );

		$this->default_settings = (array) apply_filters( 'debugbarextender_default_settings', array(
			'enable_profiler'				=> 1,
			'enable_variable_lookup'		=> 1,
			'track_default_vars'			=> 1,
			'add_default_checkpoints'		=> 1,
			'savequeries_debugmode_enable'	=> 1,
			'use_error_log'					=> 0,
			'allow_url_settings'			=> 0,
			'enable_admin_bar_menu'			=> 0,
		) );

		$this->settings_texts = (array) apply_filters( 'debugbarextender_settings_texts', array(
			'enable_profiler'				=> array( 'label' => 'Enable profiler', 'desc' => 'You can measure runtimes between checkpoints via Debug_Bar_Extender::instance()->start( $note="" ), Debug_Bar_Extender::instance()->checkpoint( $note="" ),  Debug_Bar_Extender::instance()->end( $note="" ) or by using the wrapper function dbgx_checkpoint( $note="" ).' ),
			'enable_variable_lookup'		=> array( 'label' => 'Enable variable lookup', 'desc' => 'You can screen variables via Debug_Bar_Extender::instance()->trace_var( $value, $var_name = false ) or via dbgx_trace_var( $value, $var_name = false ). Omitting the $var_name will let the script look it up. Please be aware that sizes are approximate based on strlen(serialize())' ),
			'track_default_vars'			=> array( 'label' => 'Track default variables', 'desc' => 'Track various useful variables useful for the regular debugging.' ),
			'add_default_checkpoints'		=> array( 'label' => 'Add default checkpoints', 'desc' => 'Enabling this option will add various default checkpoints to be used with the profiler.' ),
			'savequeries_debugmode_enable'	=> array( 'label' => 'Try setting debug mode', 'desc' => 'Try setting WP_DEBUG and SAVEQUERIES variables to enable additional debug menus. This should be generally done via wp-config.php, but this setting is worth a shot.' ),
			'use_error_log'					=> array( 'label' => 'Use error_log() reporting', 'desc' => 'Log the results using error_log() as well. This helps when debugging sessions which are not producing any admin bar output.' ),
			'allow_url_settings'			=> array( 'label' => 'Allow setting alteration via query parameters', 'desc' => 'Allow dbgx_use_error_log, dbgx_track_default_vars, dbgx_add_default_checkpoints to be added as query strings in order to enable respective features. Combinations are possible - for example: ' . add_query_arg( array( 'dbgx_use_error_log' => 1, 'dbgx_add_default_checkpoints' => 1, 'dbgx_track_default_vars' => 1 ) ) ),
			'enable_admin_bar_menu'			=> array( 'label' => 'Enable admin bar menu', 'desc' => 'Adds a menu to your admin bar to allow access to the url query parameters to control debug bar behaviour, only useful with allow_url_settings enabled' ),
		) );

		$user_settings = get_option( 'debugbarextender_settings' );
		if ( false === $user_settings )
			$user_settings = array();

		$this->settings = wp_parse_args( $user_settings, $this->default_settings );
	}

	public static function init() {
		if ( 1 == Debug_Bar_Extender::instance()->settings['savequeries_debugmode_enable'] ) {
			if ( !defined( 'SAVEQUERIES' ) )
				define( 'SAVEQUERIES', true );
			if ( !defined( 'WP_DEBUG' ) )
				define( 'WP_DEBUG', true );
		}

		if ( 1 == Debug_Bar_Extender::instance()->settings['use_error_log'] || ( 1 == Debug_Bar_Extender::instance()->settings['allow_url_settings'] && isset( $_GET['dbgx_use_error_log'] ) && 1 == $_GET['dbgx_use_error_log'] ) ) {
			Debug_Bar_Extender::instance()->use_error_log = true;
		}

		if ( Debug_Bar_Extender::instance()->use_error_log )
			error_log( 'Starting debug session for ' . $_SERVER['REQUEST_URI'] );

		Debug_Bar_Extender::instance()->prepare_debug_menu();
	}

	/*
	 * Use this singleton to address methods
	 */
	public static function instance() {
		if ( self::$__instance == NULL ) self::$__instance = new Debug_Bar_Extender;
		return self::$__instance;
	}

	/*
	 * Enable logging of results to php error log
	 */
	public static function use_error_log() {
		Debug_Bar_Extender::instance()->use_error_log = true;
	}

	/*
	 * Call this function once from your functions.php to prepare the debug menu
	 */
	public function prepare_debug_menu() {
		if ( 1 == $this->settings['enable_profiler'] )
			add_filter( 'debug_bar_panels', array( &$this, 'add_profiler_menu' ) );

		if ( 1 == $this->settings['enable_variable_lookup'] )
			add_filter( 'debug_bar_panels', array( &$this, 'add_var_menu' ) );

		add_action( 'admin_bar_menu', array( &$this, 'debug_action_admin_bar_menu' ), 101 );
		add_action( 'init', array( &$this, 'add_design_parts' ) );

		if ( 1 == $this->settings['track_default_vars'] || ( 1 == Debug_Bar_Extender::instance()->settings['allow_url_settings'] && isset( $_GET['dbgx_track_default_vars'] ) && 1 == $_GET['dbgx_track_default_vars'] ) ) {
			add_action( 'parse_request', array( &$this, 'trace_var_request' ), 1000 );
			add_action( 'after_setup_theme', array( &$this, 'trace_var_template' ), 1000 );
			add_action( 'posts_request', array( &$this, 'trace_var_posts_request' ), 1000 );
			//add_action( 'posts_results', array( &$this, 'trace_var_found_post_ids' ), 1000 );
			add_action( 'pre_get_posts', array( &$this, 'trace_var_wp_query' ), 1000 );
			add_action( 'wp_redirect', array( &$this, 'trace_var_redirect' ), 1000, 2 );
			add_action( 'wp_footer', array( &$this, 'trace_var_cron_array' ) );
		}

		if ( 1 == $this->settings['add_default_checkpoints'] || ( 1 == Debug_Bar_Extender::instance()->settings['allow_url_settings'] && isset( $_GET['dbgx_add_default_checkpoints'] ) && 1 == $_GET['dbgx_add_default_checkpoints'] ) ) {

			$checkpoint_actions = apply_filters( 'debugbarextender_default_checkpoint_actions', array(
											'widgets_init',
											'register_sidebar',
											'wp_register_sidebar_widget',
											'wp_loaded',
											'parse_request',
											'send_headers',
											'parse_query',
											'pre_get_posts',
											'posts_selection',
											'wp',
											'template_redirect',
											'get_header',
											'wp_head',
											'wp_enqueue_scripts',
											'wp_print_styles',
											'wp_print_scripts',
											'get_template_part_loop',
											'loop_start',
											'the_post',
											'loop_end',
											'get_sidebar',
											'dynamic_sidebar',
											'get_search_form',
											'wp_meta',
											'get_footer',
											'twentyten_credits',
											'wp_footer',
											'wp_print_footer_scripts',
											'shutdown',
											'auth_redirect',
											'wp_default_scripts',
											'_admin_menu',
											'admin_menu',
											'admin_init',
											'load-edit.php',
											'admin_xml_ns',
											'wp_default_styles',
											'admin_enqueue_scripts',
											'admin_print_styles-edit.php',
											'admin_print_styles',
											'admin_print_scripts-edit.php',
											'admin_print_scripts',
											'admin_head-edit.php',
											'admin_head',
											'in_admin_header',
											'adminmenu',
											'admin_notices',
											'restrict_manage_posts',
											'the_post',
											'in_admin_footer',
											'admin_footer',
											'admin_print_footer_scripts',
											'admin_footer-edit.php',
									) );

			foreach( $checkpoint_actions as $action_hook ) {
				add_action( $action_hook, create_function( '$in=NULL', 'dbgx_checkpoint("' . $action_hook . ' action");if ( $in ) return $in;' ) );
			}
		}
	}

	/*
	 * Receive start time
	 */
	public function get_start_time() {
		return $this->start_time;
	}

	/*
	 * Receive end time
	 */
	public function get_time() {
		return $this->current_time;
	}

	/*
	 * Enqueue Styles and Scripts
	 */
	public function add_design_parts() {
		wp_enqueue_style( 'debug-bar-extender', plugins_url( "css/debug-bar-extender.css", __FILE__ ), array('debug-bar'), '20110302' );
		wp_enqueue_script( 'debug-bar-extender', plugins_url( "js/debug-bar-extender.js", __FILE__ ), array('debug-bar'), '20110302', true );
	}

	/*
	 * This function starts a profiling block. Currently you can have only one
	 */
	public function start( $note='' ) {
		$this->profile_data = array();

		$this->start_time = $this->current_time = microtime( true );
		$this->previous_time = $this->start_time;

		$this->log();
	}

	/*
	 * This function ends the profiling block
	 */
	public function end( $note='' ) {
		$this->end_time = $this->current_time = microtime( true );
		$this->elapsed_time = $this->current_time - $this->previous_time;
		$this->previous_time = $this->end_time;

		$this->log();
	}

	/*
	 * Add a checkpoint somewhere in your code
	 */
	public function checkpoint( $note='' ) {
		$this->current_time = microtime( true );

		$this->elapsed_time = $this->current_time - $this->previous_time;

		$this->previous_time = $this->current_time;

		$this->log();
	}

	/*
	 * Trace the content of a variable
	 */
	public function trace_var( $value, $var_name = false ) {
		if ( is_object( $value ) )
			$value_cp = clone $value;
		else
			$value_cp = $value;

		$mem_usage = $this->guess_variable_size( $value );
		$trace = debug_backtrace();
		if ( !empty( $trace[1]['function'] ) && 'dbgx_trace_var' == $trace[1]['function'] )	// usage of dbgx_trace_var() shortcut function
			array_shift( $trace );

		$result = array(
			'file' => $trace[0]['file'],
			'line' => $trace[0]['line'],
			'function' => ( !empty( $trace[1]['function'] ) ) ? $trace[1]['function'] . '()' : '',
			'args' => ( !empty( $trace[1]['args'] ) ) ? $trace[1]['args'] : '',
			'caller_function' => ( !empty( $trace[2]['function'] ) ) ? $trace[2]['function'] . '()' : '',
			'caller_line' => ( !empty( $trace[1]['line'] ) ) ? $trace[1]['line'] : '',
			'caller_file' => ( !empty( $trace[1]['file'] ) ) ? $trace[1]['file'] : '',
			'value' => $value_cp,
			'mem_usage' => $mem_usage,
		);

		if ( false === $var_name ) {
			$var_name = 'n/a';
			if ( file_exists( $result['file'] ) && is_readable( $result['file'] ) ) {
				$line = $this->read_line_of_file( $result['file'], $result['line'] );
				if ( $line && preg_match( "/trace_var\(([^\)]+)\)/", $line, $matches ) ) {
					$var_name = trim( $matches[1] );
				}
			}
		}
		$result['var_name'] = $var_name;

		$this->variable_lookup[$var_name][] = $result;
		if ( isset( $this->variable_lookup[$var_name]['total_mem'] ) )
			$this->variable_lookup[$var_name]['total_mem']+=$mem_usage;
		else
			$this->variable_lookup[$var_name]['total_mem']=$mem_usage;
		$this->log_result( $result );
	}

	/*
	 * Only internal functions below
	 */

	private function log_result( $result ) {
		if ( ! $this->use_error_log )
			return;

		error_log( $result['function'] . ' - ' . $result['file'] . '::L' . $result['line'] );
		error_log( $result['caller_function'] . ' - ' . $result['caller_file'] . '::L' . $result['caller_line'] );

		unset( $result['function'] );
		unset( $result['file'] );
		unset( $result['line'] );
		unset( $result['caller_function'] );
		unset( $result['caller_file'] );
		unset( $result['caller_line'] );

		error_log( print_r( $result, true ) );
	}

	public function trace_var_cron_array() {
		$crons = _get_cron_array();
		$this->trace_var( $crons, 'cron array via _get_cron_array()' );
	}

	public function trace_var_redirect( $location, $status = 301 ) {
		$this->trace_var( $location, 'wp_redirect ( ' . $location . ',' . $status . ' )' );
		return $location;
	}

	public function trace_var_request( &$request ) {
		$this->trace_var( $request, '$request via parse_request' );
		return $request;
	}

	public function trace_var_template() {
		$this->trace_var( get_template(), 'template via get_template' );
	}

	public function trace_var_posts_request( $posts_request ) {
		$this->trace_var( $posts_request, '$posts_request via posts_request' );
		return $posts_request;
	}

	public function trace_var_found_post_ids( $posts_results ) {
		foreach ( $posts_results as $post )
			$this->trace_var( $post->ID, 'found $post->IDs via posts_results' );
		return $posts_results;
	}

	public function trace_var_wp_query( $wp_query ) {
		$this->trace_var( $wp_query->query_vars, '$wp_query->query_vars via pre_get_posts' );
		return $wp_query;
	}

	private function guess_variable_size( $var ) {
		$mem = strlen( serialize( $var ) );
		return $mem;
	}

	private function read_line_of_file( $file_name, $line_number, $delimiter = "\n" ) {
		$l = 1;
		$fp = fopen( $file_name, 'r' );
		while ( !feof( $fp ) ) {
			$line = stream_get_line( $fp, 1024, $delimiter );
			if ( $l == $line_number ) {
				fclose( $fp );
				return $line;
			}
			$l++;
			$line = '';
		}
		fclose( $fp );
		return false;
	}

	public function add_profiler_menu( $panels ) {
		require_once( 'class-debug-bar-extender.php' );
		eval ( 'class Debug_Bar_Extender_Profiler extends Debug_Bar_Extender_Panel {}' );

		$panel = new Debug_Bar_Extender_Profiler;
		$panel->set_tab( 'Profiler', array( &$this, 'print_result_html' ) );
		$panels[] = $panel;
		return $panels;
	}

	public function add_var_menu( $panels ) {
		require_once( 'class-debug-bar-extender.php' );
		eval ( 'class Debug_Bar_Extender_Variables extends Debug_Bar_Extender_Panel {}' );

		$panel = new Debug_Bar_Extender_Variables;
		$panel->set_tab( 'Variable Lookup', array( &$this, 'print_variable_html' ) );
		$panels[] = $panel;
		return $panels;
	}

	public function print_result_html() {
		if ( isset( $this->profile_data['summary'] ) ) {
			$summary_data = $this->profile_data['summary'];

			$summary_data = $this->sort_summary( $summary_data, 'total_time', 'DESC' );

			$flow_data = $this->profile_data['log'];
			$total_time = $flow_data[ count( $flow_data )-1 ]['time'] + $flow_data[ count( $flow_data )-1 ]['elapsed_time'];

			// display summary
			$out = '
Summary
';
			$out .= '
';
			$counter = 1;

			foreach ( $summary_data as $line_data ) {
				$query = '' . ( ( !empty( $line_data['note'] ) ) ? $line_data['note'] . ' - ' : '' ) . $line_data['function'] . ' in ' . $line_data['file'] . '::L' . $line_data['line'] . ( ( !empty( $args ) ) ? ' args : ' . serialize( $args ) : '' ) . "\n";
				$debug = 'called from ' . $line_data['caller_function'] . ' in ' . $line_data['caller_file'] . '::L' . $line_data['caller_line'] . "\n";
				$out .= "
$query

$debug #{$counter} ( total " . number_format( sprintf( '%0.2f', $line_data['total_time'] * 1000 ), 2, '.', ',' ) . "ms in " . $line_data['call_count']  . " calls spent)

\n";
				$counter++;
			}
			$out .= '
';

			// display flow
			if ( count( $flow_data ) < 100 ) {
				$out .= '
Flow
';
				$out .= '
';
				$counter = 1;

				foreach ( $flow_data as $line_data ) {
					$query = '' . ( ( !empty( $line_data['note'] ) ) ? $line_data['note'] . ' - ' : '' ) . $line_data['function'] . ' in ' . $line_data['file'] . '::L' . $line_data['line'] . ( ( !empty( $args ) ) ? ' args : ' . serialize( $args ) : '' ) . "\n";
					$debug = 'called from ' . $line_data['caller_function'] . ' in ' . $line_data['caller_file'] . '::L' . $line_data['caller_line'] . "\n";
					$out .= "
$query

$debug #{$counter} ( " . number_format( sprintf( '%0.2f', $line_data['elapsed_time'] * 1000 ), 2, '.', ',' ) . "ms @ " . number_format( sprintf( '%0.2f', $line_data['time'] * 1000 ), 2, '.', ',' ) . "ms )

\n";
					$counter++;
				}
				$out .= '
';
			} else {
				$out .= '
Flow data is hidden as it contains too much data
';
			}
			$query_time = '
Total execution time:' . number_format( sprintf( '%0.2f', $total_time * 1000 ), 2 ) . "ms
\n";
		} else {
			$out = '
No profiling data found
';
			$query_time = '';
		}

		$note = 'Note: you can measure runtimes between checkpoints via Debug_Bar_Extender::instance()->start( $note="" ), Debug_Bar_Extender::instance()->checkpoint( $note="" ),  Debug_Bar_Extender::instance()->end( $note="" ) or using the simple shortcut function dbgx_checkpoint( $note="" )';
		$out = $query_time . $out . $note;
		return $out;

	}

	public function print_variable_html( $scope='variable' ) {
		$out = "
\n";
		$current = ' class="current"';
		$units = array( 'b', 'kb', 'mb', 'gb', 'tb', 'pb' );

		$overall_mem = $total_ops = 0;

		foreach ( $this->{$scope .'_lookup'} as $var => $values ) {
			$total_mem_usage = $values['total_mem'];
			$overall_mem += $total_mem_usage;
			$total_mem_usage = @number_format( $total_mem_usage / pow( 1024, ( $i = floor( log( $total_mem_usage, 1024 ) ) ) ), 2 ) . ' '.$units[$i];
			unset( $this->{$scope .'_lookup'}[$var]['total_mem'] );
			$var_ops = count( $this->{$scope .'_lookup'}[$var] );
			$total_ops += $var_ops;
			$var_size = $total_mem_usage;
			$var_title = "{$var}[$var_ops] ($var_size)";
			$var_key = md5( $var );
			$out .= "\t
$var_title
\n";
			$current = '';
		}
		$out .= "
\n";

		$out .= "
\n";
		$current = ' style="display: block"';
		foreach ( $this->{$scope .'_lookup'} as $var => $data_lines ) {
			$first_time = true;
			$var_key = md5( $var );
			$out .= "
\n";
			foreach ( $data_lines as $key => $values ) {
				if ( $first_time ) {
					$out .= 'called by ' . $values['function'] . ' in ' . $values['file'] . '::L' . $values['line'] . ( ( !empty( $args ) ) ? ' args : ' . serialize( $args ) : '' ) . "\n";
					if ( !empty( $values['caller_line'] ) )
						$out .= 'initiated from ' . $values['caller_function'] . ' in ' . $values['caller_file'] . '::L' . $values['caller_line'] . "\n";
					$out .= '
';
				}

				if ( 'memcache' == $scope ) {
					$prev_value = NULL;
					$diff = array();
					foreach ( $this->dcs as $dc ) {
						$diff[ md5( serialize( $values['value'][$dc] ) ) ][] = $dc;
					}
					foreach ( $diff as $dcs ) {
						if ( count( $diff ) > 1 )
							$display_key = join( ',', $dcs ) . " - $key";
						else
							$display_key = $key;

						$mem_usage = $values['mem_usage'][$dc];
						if ( $mem_usage > 100000 )
							$style = 'display:none;';
						else
							$style = 'display:block;';
						$mem_usage = number_format( $mem_usage / pow( 1024, ( $i = floor( log( $mem_usage, 1024 ) ) ) ), 2 ) . ' '.$units[$i];
						$out .= "$display_key ( $mem_usage )";
						$out .= "
";
						$out .= "$var = " . htmlentities( var_export( $values['value'][array_shift( $dcs )], true ) );
						$out .= "
\n";
					}
				} else {
					$mem_usage = $values['mem_usage'];
					if ( $mem_usage > 100000 )
						$style = 'display:none;';
					else
						$style = 'display:block;';
					$mem_usage = number_format( $mem_usage / pow( 1024, ( $i = floor( log( $mem_usage, 1024 ) ) ) ), 2 ) . ' '.$units[$i];
					$out .= "$key ( $mem_usage )";
					$out .= "
";
					$out .= "$var = " . htmlentities( var_export( $values['value'], true ) );
					$out .= "
\n";
				}
				$first_time = false;

			}
			$current = '';
			$out .= "
";
		}

		if ( $overall_mem > 0 )
			$overall_mem = @number_format( $overall_mem / pow( 1024, ( $i = floor( log( $overall_mem, 1024 ) ) ) ), 2 ) . ' '.$units[$i];
		else
			$overall_mem = 0;

		$header = "
\n";
		$header .= "
Total mem:". $overall_mem ."
";

		$out .= "
";

		if ( 'variable' == $scope )
			$note = 'Note: you can screen additional variables via Debug_Bar_Extender::instance()->trace_var( $value, $var_name = false ) or simply by using dbgx_trace_var( $value, $var_name = false ). Omitting the $var_name will let the script look it up. Please be aware that sizes are approximate based on strlen(serialize())';
		elseif ( 'memcache' == $scope )
			$note = 'Note: you can screen additional keys via Debug_Bar_Extender::instance()->trace_memcache( $key, $group = "default" ). This lookups are gathering the values from all datacenters and will show one value if all results are the same and multiple if the results in the datacenters differ. As sandboxes don\'t update remote memcache servers make sure to prime the caches by a live page load prior to sandboxing a site.';
		return $header.$out.$note.'
';
	}

	private function log() {
		$trace = debug_backtrace();
		if ( !empty( $trace[2]['function'] ) && 'dbgx_checkpoint' == $trace[2]['function'] )	// usage of dbgx_checkpoint() shortcut function
			array_shift( $trace );

		$caller = $trace[1]; // it always goes through start, checkpoint or end
		$result = array(
			'file' => $trace[1]['file'],
			'line' => $trace[1]['line'],
			'function' => ( !empty( $trace[2]['function'] ) ) ? $trace[2]['function'] . '()' : '',
			'args' => ( !empty( $trace[2]['args'] ) ) ? $trace[2]['args'] : '',
			'caller_function' => ( !empty( $trace[3]['function'] ) ) ? $trace[3]['function'] . '()' : '',
			'caller_line' => ( !empty( $trace[2]['line'] ) ) ? $trace[2]['line'] : '',
			'caller_file' => ( !empty( $trace[2]['file'] ) ) ? $trace[2]['file'] : '',

		);
		$array_key = md5( serialize( array( $result['file'], $result['line'], $result['function'], $result['args'] ) ) );

		$substractor = $this->start_time;
		$time_line = array( 'time' => ( $this->current_time ) - $substractor,
			'elapsed_time' => ( $this->elapsed_time ),
		);
		$profile_data = array_merge( $time_line, $result );

		$profile_data['note'] = $trace[1]['args'][0];

		$this->profile_data['log'][] = $profile_data;
		if ( isset( $this->profile_data['summary'][$array_key]['call_count'] ) ) {
			$this->profile_data['summary'][$array_key]['call_count']++;
			$this->profile_data['summary'][$array_key]['total_time'] += $profile_data['elapsed_time'];
		} else {
			$profile_data['call_count'] = 1;
			$profile_data['total_time'] = $profile_data['elapsed_time'];
			unset( $profile_data['elapsed_time'] );
			unset( $profile_data['time'] );
			$this->profile_data['summary'][$array_key] = $profile_data;
		}

		$this->log_result( $profile_data );
		return $profile_data;
	}

	private function sort_summary( $data, $sortby_index, $order = 'ASC' ) {
		$_tmp = $sorted = array();
		foreach ( $data as $key => $values ) {
			if ( !is_array( $values[$sortby_index] ) )
				$_tmp[$key] = $values[$sortby_index];
		}

		natsort( $_tmp );

		if ( 'DESC' == strtoupper( $order ) )
			$_tmp = array_reverse( $_tmp, true );

		foreach ( $_tmp as $key => $vals ) {
			$sorted[$key] = $data[$key];
		}
		return $sorted;
	}

	public function register_settings_page() {
		add_options_page( 'Debug Bar Extender Settings', 'Debug Bar Extender', 'manage_options', 'debug-bar-extender', array( &$this, 'settings_page' ) );
	}

	public function register_setting() {
		register_setting( 'debugbarextender_settings', 'debugbarextender_settings', array( &$this, 'validate_settings') );
	}

	public function validate_settings( $settings ) {
		if ( !empty( $_POST['debugbarextender-defaults'] ) ) {
			$settings = $this->default_settings;
			$_REQUEST['_wp_http_referer'] = add_query_arg( 'defaults', 'true', $_REQUEST['_wp_http_referer'] );
		} else {
			//foreach( $settings as $setting => $value )
				//$settings[$setting] = (int) ( !empty( $settings[$setting] ) ) ? $settings[$setting] :$this->default_settings[$setting];
		}

		return $settings;
	}

	public function settings_page() {
		if ( !current_user_can( 'manage_options' ) ) {
			global $current_user;
			$msg = "I'm sorry, " . $current_user->display_name . " I'm afraid I can't do that.";
			echo '
' . $msg . '
';
			return false;
		}
	?>

	<?php if ( function_exists('screen_icon') ) screen_icon(); ?>

Debug Bar Extender Settings

		<form method="post" action="options.php">

		<?php settings_fields( 'debugbarextender_settings' ); ?>

			<?php foreach( $this->settings as $setting => $value): ?>

				<label for="debugbarextender-<?php echo $setting; ?>"><?php if ( isset( $this->settings_texts[$setting]['label'] ) ) { echo $this->settings_texts[$setting]['label']; } else { echo $setting; } ?>

					<select name="debugbarextender_settings[<?php echo $setting; ?>]" id="debugbarextender-<?php echo $setting; ?>" class="postform">
						<?php
							$yesno = array( 0 => 'No', 1 => 'Yes' );
							foreach ( $yesno as $val => $txt ) {
								echo '<option value="' . esc_attr( $val ) . '"' . selected( $value, $val, false ) . '>' . esc_html( $txt ) . " </option>\n";
							}
						?>
					</select>

					<?php if ( !empty( $this->settings_texts[$setting]['desc'] ) ) { echo $this->settings_texts[$setting]['desc']; } ?>

			<?php endforeach; ?>

	<?php
			if ( function_exists( 'submit_button' ) ) {
				submit_button( null, 'primary', 'debugbarextender-submit', false );
				echo ' ';
				submit_button( 'Reset to Defaults', 'primary', 'debugbarextender-defaults', false );
			} else {
				echo '<input type="submit" name="debugbarextender-submit" class="button-primary" value="Save Changes" />' . "\n";
				echo '<input type="submit" name="debugbarextender-defaults" id="debugbarextender-defaults" class="button-primary" value="Reset to Defaults" />' . "\n";
			}
	?>

		</form>

	<?php
	}

	public function debug_action_admin_bar_menu() {
		global $wp_admin_bar;
		if ( 0 == Debug_Bar_Extender::instance()->settings['allow_url_settings'] || 0 == Debug_Bar_Extender::instance()->settings['enable_admin_bar_menu'] )
			return;

		$wp_admin_bar->add_menu( array(
			'id' => 'dbg',
			'title' => 'DbgBExt',
			'href' => false,
		) );
		$wp_admin_bar->add_menu( array(
			'parent' => 'dbg',
			'title' => 'default vars',
			'href' => add_query_arg( array( 'dbgx_use_error_log' => 0, 'dbgx_add_default_checkpoints' => 0, 'dbgx_track_default_vars' => 1 ) ),
		) );
		$wp_admin_bar->add_menu( array(
			'parent' => 'dbg',
			'title' => 'default checkpoints',
			'href' => add_query_arg( array( 'dbgx_use_error_log' => 0, 'dbgx_add_default_checkpoints' => 1, 'dbgx_track_default_vars' => 0 ) ),
		) );
		$wp_admin_bar->add_menu( array(
			'parent' => 'dbg',
			'title' => 'default checkpoints+vars',
			'href' => add_query_arg( array( 'dbgx_use_error_log' => 0, 'dbgx_add_default_checkpoints' => 1, 'dbgx_track_default_vars' => 1 ) ),
		) );
		$wp_admin_bar->add_menu( array(
			'parent' => 'dbg',
			'title' => 'send to error_log',
			'href' => add_query_arg( array( 'dbgx_use_error_log' => 1, 'dbgx_add_default_checkpoints' => 0, 'dbgx_track_default_vars' => 0 ) ),
		) );
		$wp_admin_bar->add_menu( array(
			'parent' => 'dbg',
			'title' => 'default vars -> log',
			'href' => add_query_arg( array( 'dbgx_use_error_log' => 1, 'dbgx_add_default_checkpoints' => 0, 'dbgx_track_default_vars' => 1 ) ),
		) );
		$wp_admin_bar->add_menu( array(
			'parent' => 'dbg',
			'title' => 'default checkpoints -> log',
			'href' => add_query_arg( array( 'dbgx_use_error_log' => 1, 'dbgx_add_default_checkpoints' => 1, 'dbgx_track_default_vars' => 0 ) ),
		) );
		$wp_admin_bar->add_menu( array(
			'parent' => 'dbg',
			'title' => 'default checkpoints+vars -> log',
			'href' => add_query_arg( array( 'dbgx_use_error_log' => 1, 'dbgx_add_default_checkpoints' => 1, 'dbgx_track_default_vars' => 1 ) ),
		) );
	}

}

Debug_Bar_Extender::init();

if ( !function_exists( 'dbgx_checkpoint' ) ) {
	function dbgx_checkpoint( $note = '' ) {
		if ( 0 == Debug_Bar_Extender::instance()->get_start_time() ) {
			Debug_Bar_Extender::instance()->start( $note );
		} else {
			Debug_Bar_Extender::instance()->checkpoint( $note );
		}
	}
}

if ( !function_exists( 'dbgx_trace_var' ) ) {
	function dbgx_trace_var( $value, $var_name = false ) {
		Debug_Bar_Extender::instance()->trace_var( $value, $var_name );
	}
}


text:
namespace Meziantou.Framework.CodeDom;

public class DefaultValueExpression : Expression
{
    public DefaultValueExpression()
    {
    }

    public DefaultValueExpression(TypeReference? type)
    {
        Type = type;
    }

    public TypeReference? Type { get; set; }
}


text:
__author__ = 'Jwely'

import os
from TeXFigureGenerator import TeXFigureGenerator

class TeXWriter:

    def __init__(self, main_path, texfile_path):

        self.main_path = os.path.abspath(main_path)
        self.texfile_path = os.path.abspath(texfile_path)

        self.content = []           # a list of content strings

        if not os.path.exists(self.main_path):
            raise Warning("main_path '{0}' does not exist".format(self.main_path))

    def add_figure(self, figure_path, caption, width,
                   create_from_function=None, create_kwargs=None):
        """
        Adds a figure to the TexFile, if create params are given, the figure is
        generated from scratch.
        :param figure_path:     filepath to the image
        :param caption:         caption to use on the figure
        :param width:           width of the figure as a string, such as '5in'

        :param create_from_function: input method to use to generate the figure
        :param create_kwargs: kwargs for the create_from_function
        """

        fig = TeXFigureGenerator(self.main_path, figure_path, caption, width)
        self.content += fig.get_tex()

        # if creation parameters were given, create the figure from scratch
        if create_from_function is not None:
            fig.create_from(create_from_function, create_kwargs)

    def add_text(self, text):
        """
        Adds a string of text to the TeX document, must be TeX formatted. Not really intended
        to be used extensively, but could be needed.
        """
        self.content += [text]

    def chapter(self, name):
        self.content += ["\\chapter{{{0}}}".format(name)]

    def write(self, verbose=False, reset_content=False, include_labels=True):
        """ Writes a `.tex` file with the current text and figures """

        with open(self.texfile_path, 'w+') as f:
            for line in self.content:
                if not include_labels:
                    if r"\label" not in line:
                        if verbose:
                            print(line)
                        f.write(line + "\n")
                else:
                    if verbose:
                        print(line)
                    f.write(line + "\n")
        print("Wrote tex file at {0}".format(self.texfile_path))

        # resets the content to ensure figure is only writen once, not subsequently
        if reset_content:
            self.content = []


text:
package main

import (
	log "code.google.com/p/log4go"
	"github.com/Terry-Mao/goim/define"
	"time"
)

type Operator interface {
	// Operate process the common operation such as send message etc.
	Operate(*Proto) error
	// Connect used for auth user and return a subkey, roomid, hearbeat.
	Connect(*Proto) (string, int32, time.Duration, error)
	// Disconnect used for revoke the subkey.
	Disconnect(string, int32) error
}

type DefaultOperator struct {
}

func (operator *DefaultOperator) Operate(p *Proto) error {
	var (
		body []byte
	)
	if p.Operation == define.OP_SEND_SMS {
		// call suntao's api
		// p.Body = nil
		p.Operation = define.OP_SEND_SMS_REPLY
		log.Info("send sms proto: %v", p)
	} else if p.Operation == define.OP_TEST {
		log.Debug("test operation: %s", body)
		p.Operation = define.OP_TEST_REPLY
		p.Body = []byte("{\"test\":\"come on\"}")
	} else {
		return ErrOperation
	}
	return nil
}

func (operator *DefaultOperator) Connect(p *Proto) (key string, rid int32, heartbeat time.Duration, err error) {
	key, rid, heartbeat, err = connect(p)
	return
}

func (operator *DefaultOperator) Disconnect(key string, rid int32) (err error) {
	var has bool
	if has, err = disconnect(key, rid); err != nil {
		return
	}
	if !has {
		log.Warn("disconnect key: \"%s\" not exists", key)
	}
	return
}


text:
#![warn(missing_docs)]

//! # Safe JNI Bindings in Rust
//!
//! This crate provides a (mostly) safe way to implement methods in Java using
//! the JNI. Because who wants to *actually* write Java?
//!
//! ## Getting Started
//!
//! Naturally, any ffi-related project is going to require some code in both
//! languages that we're trying to make communicate. Java requires all native
//! methods to adhere to the Java Native Interface (JNI), so we first have to
//! define our function signature from java, and then we can write Rust that
//! will adhere to it.
//!
//! ### The Java side
//!
//! First, you need a Java class definition. `HelloWorld.java`:
//!
//! ```java
//! class HelloWorld {
//!     // This declares that the static `hello` method will be provided
//!     // a native library.
//!     private static native String hello(String input);
//!
//!     static {
//!         // This actually loads the shared object that we'll be creating.
//!         // The actual location of the .so or .dll may differ based on your
//!         // platform.
//!         System.loadLibrary("mylib");
//!     }
//!
//!     // The rest is just regular ol' java!
//!     public static void main(String[] args) {
//!         String output = HelloWorld.hello("josh");
//!         System.out.println(output);
//!     }
//! }
//! ```
//!
//! Compile this to a class file with `javac HelloWorld.java`.
//!
//! Trying to run it now will give us the error `Exception in thread "main"
//! java.lang.UnsatisfiedLinkError: no mylib in java.library.path` since we
//! haven't written our native code yet.
//!
//! To do that, first we need the name and type signature that our rust function
//! needs to adhere to. Luckily, java comes with a utility to generate that for
//! you! Run `javah HelloWorld` and you'll get a `HelloWorld.h` output to your
//! directory. It should look something like this:
//!
//! ```c
//! /* DO NOT EDIT THIS FILE - it is machine generated */
//! #include <jni.h>
//! /* Header for class HelloWorld */
//!
//! #ifndef _Included_HelloWorld
//! #define _Included_HelloWorld
//! #ifdef __cplusplus
//! extern "C" {
//! #endif
//! /*
//!  * Class:     HelloWorld
//!  * Method:    hello
//!  * Signature: (Ljava/lang/String;)Ljava/lang/String;
//!  */
//! JNIEXPORT jstring JNICALL Java_HelloWorld_hello
//!   (JNIEnv *, jclass, jstring);
//!
//! #ifdef __cplusplus
//! }
//! #endif
//! #endif
//! ```
//!
//! It's a C header, but luckily for us, the types will mostly match up. Let's
//! make our crate that's going to compile to our native library.
//!
//! ### The Rust side
//!
//! Create your crate with `cargo new mylib`. This will create a directory
//! `mylib` that has everything needed to build an basic crate with `cargo`. We
//! need to make a couple of changes to `Cargo.toml` before we do anything else.
//!
//! * Under `[dependencies]`, add `jni = { git =
//!   "https://github.com/prevoty/jni-rs" }`
//! * Add a new `[lib]` section and under it, `crate_type = ["dylib"]`.
//!
//! Now, if you run `cargo build` from inside the crate directory, you should
//! see a `libmylib.so` (if you're on linux/OSX) in the `target/debug`
//! directory.
//!
//! The last thing we need to do is to define our exported method. Add this to
//! your crate's `src/lib.rs`:
//!
//! ```rust,ignore
//! extern crate jni;
//!
//! // This is the interface to the JVM that we'll call the majority of our
//! // methods on.
//! use jni::JNIEnv;
//!
//! // These objects are what you should use as arguments to your native
//! // function. They carry extra lifetime information to prevent them escaping
//! // this context and getting used after being GC'd.
//! use jni::objects::{JClass, JString};
//!
//! // This is just a pointer. We'll be returning it from our function. We
//! // can't return one of the objects with lifetime information because the
//! // lifetime checker won't let us.
//! use jni::sys::jstring;
//!
//! // This keeps rust from "mangling" the name and making it unique for this
//! // crate.
//! #[no_mangle]
//! // This turns off linter warnings because the name doesn't conform to
//! // conventions.
//! #[allow(non_snake_case)]
//! pub extern "C" fn Java_HelloWorld_hello(env: JNIEnv,
//!                                         // this is the class that owns our
//!                                         // static method. Not going to be
//!                                         // used, but still needs to have an
//!                                         // argument slot
//!                                         class: JClass,
//!                                         input: JString)
//!                                         -> jstring {
//!     // First, we have to get the string out of java. Check out the `strings`
//!     // module for more info on how this works.
//!     let input: String =
//!         env.get_string(input).expect("Couldn't get java string!").into();
//!
//!     // Then we have to create a new java string to return. Again, more info
//!     // in the `strings` module.
//!     let output = env.new_string(format!("Hello, {}!", input))
//!         .expect("Couldn't create java string!");
//!
//!     // Finally, extract the raw pointer to return.
//!     output.into_inner()
//! }
//! ```
//!
//! Note that the type signature for our function is almost identical to the one
//! from the generated header, aside from our lifetime-carrying arguments.
//!
//! ### Final steps
//!
//! That's it! Build your crate and try to run your java class again.
//!
//! ... Same error as before you say? Well that's because java is looking for
//! `mylib` in all the wrong places. This will differ by platform thanks to
//! different linker/loader semantics, but on Linux, you can simply `export
//! LD_LIBRARY_PATH=/path/to/mylib/target/debug`. Now, you should get the
//! expected output `Hello, josh!` from your java class.

/// Bindgen-generated definitions. Mirrors `jni.h` and `jni_md.h`.
extern crate jni_sys;
/// `jni-sys` re-exports
pub mod sys;

#[macro_use]
extern crate log;

#[macro_use]
extern crate error_chain;

extern crate combine;

extern crate cesu8;

mod wrapper {
    #[macro_use]
    mod macros;

    /// Errors. Do you really need more explanation?
    pub mod errors;

    /// Descriptors for classes and method IDs.
    pub mod descriptors;

    /// Parser for java type signatures.
    pub mod signature;

    /// Wrappers for object pointers returned from the JVM.
    pub mod objects;

    /// String types for going to/from java strings.
    pub mod strings;

    /// Actual communication with the JVM
    mod jnienv;
    pub use self::jnienv::*;

    mod javavm;
    pub use self::javavm::*;
}

pub use wrapper::*;


text:
using FoxTool.Fox.Types.Values;

namespace FoxTool.Tpp.Classes
{
    public class TppObjectBrushPluginFlutteringGrass : Data
    {
        // Static properties
        public FoxString ParentDataName { get; set; }
        public FoxBool Visibility { get; set; }
        public FoxFilePtr ModelFile { get; set; }
        public FoxFloat MinSize { get; set; }
        public FoxFloat MaxSize { get; set; }
        public FoxFloat FarLodSize { get; set; }
        public FoxFloat MiddleLodSize { get; set; }
        public FoxFloat NearLodSize { get; set; }
        public FoxBool EnableLod { get; set; }
        public FoxFloat BaseCycleSpeedRate { get; set; }
        public FoxFloat WindAmplitude { get; set; }
        public FoxFloat WindOffsetFactor { get; set; }
        public FoxBool WindDirYAxisFixZero { get; set; }
    }
}


text:
from temboo.core.choreography import Choreography
from temboo.core.choreography import InputSet
from temboo.core.choreography import ResultSet
from temboo.core.choreography import ChoreographyExecution

import json

class RefreshToken(Choreography):

    def __init__(self, temboo_session):
        """
        Create a new instance of the RefreshToken Choreo. A TembooSession object, containing a valid
        set of Temboo credentials, must be supplied.
        """
        super(RefreshToken, self).__init__(temboo_session, '/Library/Utilities/Authentication/OAuth2/RefreshToken')

    def new_input_set(self):
        return RefreshTokenInputSet()

    def _make_result_set(self, result, path):
        return RefreshTokenResultSet(result, path)

    def _make_execution(self, session, exec_id, path):
        return RefreshTokenChoreographyExecution(session, exec_id, path)

class RefreshTokenInputSet(InputSet):
    """
    An InputSet with methods appropriate for specifying the inputs to the RefreshToken
    Choreo. The InputSet object is used to specify input parameters when executing this Choreo.
    """
    def set_AccessTokenEndpoint(self, value):
        """
        Set the value of the AccessTokenEndpoint input for this Choreo. ((required, string) The URL for the authorization server that issues access tokens (e.g. https://accounts.google.com/o/oauth2/token).)
        """
        super(RefreshTokenInputSet, self)._set_input('AccessTokenEndpoint', value)
    def set_ClientID(self, value):
        """
        Set the value of the ClientID input for this Choreo. ((required, string) The Client ID provided by the service.)
        """
        super(RefreshTokenInputSet, self)._set_input('ClientID', value)
    def set_ClientSecret(self, value):
        """
        Set the value of the ClientSecret input for this Choreo. ((required, string) The Client Secret provided by the service.)
        """
        super(RefreshTokenInputSet, self)._set_input('ClientSecret', value)
    def set_RefreshToken(self, value):
        """
        Set the value of the RefreshToken input for this Choreo. ((required, string) The refresh token retrieved in the OAuth process to be used when your access token expires.)
        """
        super(RefreshTokenInputSet, self)._set_input('RefreshToken', value)

class RefreshTokenResultSet(ResultSet):
    """
    A ResultSet with methods tailored to the values returned by the RefreshToken Choreo.
    The ResultSet object is used to retrieve the results of a Choreo execution.
    """

    def getJSONFromString(self, str):
        return json.loads(str)

    def get_Response(self):
        """
        Retrieve the value for the "Response" output from this Choreo execution. (The response from the server.)
        """
        return self._output.get('Response', None)

class RefreshTokenChoreographyExecution(ChoreographyExecution):

    def _make_result_set(self, response, path):
        return RefreshTokenResultSet(response, path)


text:
package object

import (
	"fmt"
)

// Float : Object representing a float
type Float struct {
	Value float64
}

func (f *Float) number() {}

// Type : Returns Object's type
func (f *Float) Type() ObjectType {
	return FLOAT_OBJ
}

// Inspect : Returns string representation of Object's value
func (f *Float) Inspect() string {
	return fmt.Sprintf("%g", f.Value)
}


text:
from policyiteration import trueValues, trueQValues, policyIteration
from leastsquares import LSTD_values, LSTD_Qvalues, LSPI_policy, LSTD_PI_policy


text:
Description
===========

This cookbook takes care of the installation and configuration of BIND9. At the moment you're able to define some global variables and to manage your zonefiles via data bags (json example below).
It currently also supports automatic serial number generation and automatic resource records for chef nodes (see optional json in example below)
Besides that there's not much to see, e.g. no DNSSEC, no configurable logging, no rndc shell operations or other safety checks (named-checkconf, etc.).

It's my intention to round its edges over time. If you want to help feel free to contribute!

**DISCLAIMER**:
Please keep in mind that this cookbook is far from finished and not adequately tested. It could break your setup. Use at **YOUR OWN RISK**!

Requirements
============

Platform:

* Debian
* Ubuntu
* Centos

Attributes
==========

* **node[:bind9][:enable_ipv6]**       - Enables BIND to listen on an IPv6 address. Default is: On
* **node[:bind9][:allow_query]**       - Allow clients to query the nameserver. Default is: anyone
* **node[:bind9][:allow_recursion]**   - Allow recursive name resolution. Default is: none (to prevent DNS cache poisoning)
* **node[:bind9][:allow_update]**      - Allow dynamic DNS updates. Default is: none
* **node[:bind9][:allow_transfer]**    - Allow zone transfers globally. Default is: none
* **node[:bind9][:enable_forwarding]** - Enables forwarding of requests. Default is: No forwarding
* **node[:bind9][:forwarders]**        - Array for forwarding DNS. Default is: 4.4.4.4 and 8.8.8.8 (Google DNS)

Usage
=====

Add "recipe[bind9]" directly to a node or a role. If you want to use BIND9 for serving domains you may add the appropriate data via data bags (example below).
Please note that the data bag's structure is mandatory except:

* TTL for DNS records (if you decide to leave it empty, the global TTL will take over)
* autodomain for the zone (if you include this, automatic records will be added for chef nodes whose "domain" matches this)

Examples
=====

    $ knife data bag create zones
    $ knife data bag create zones exampleDOTcom
    $ ... do something ...
    $ knife data bag from file zones exampleDOTcom.json

    {
      "id": "exampleDOTcom",
      "domain": "example.com",
      "type": "master",
      "allow_transfer": [ "4.4.4.4",
                          "8.8.8.8" ],
      "zone_info": {
        "global_ttl": 300,
        "soa": "ns.example.com.",
        "contact": "user.example.com.",
				"autodomain": "example.com.",
        "nameserver": [ "ns.example.com",
                        "ns.example.net",
                        "ns2.example.org.",
                        "ns3.example.de." ],
        "mail_exchange": [{
          "host": "ASPMX.L.GOOGLE.COM.",
          "priority": 10
        },{
          "host": "ALT1.ASPMX.L.GOOGLE.COM.",
          "priority": 20
        },{
          "host": "ALT2.ASPMX.L.GOOGLE.COM.",
          "priority": 20
        },{
          "host": "ASPMX2.GOOGLEMAIL.COM.",
          "priority": 30
        },{
          "host": "ASPMX3.GOOGLEMAIL.COM.",
          "priority": 30
        },{
          "host": "ASPMX4.GOOGLEMAIL.COM.",
          "priority": 30
        },{
          "host": "ASPMX5.GOOGLEMAIL.COM.",
          "priority": 30
        }],
        "records": [{
          "name": "www",
          "type": "A",
          "ip": "127.0.0.1"
        },{
          "name": "img",
          "ttl": 30,
          "type": "A",
          "ip": "127.0.0.1"
        },{
          "name": "mail",
          "type": "CNAME",
          "ip": "ghs.google.com."
        }]
      }
    }


text:
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/methods', __FILE__)

describe "Time.at" do
  describe "passed Numeric" do
    it "returns a Time object representing the given number of Integer seconds since 1970-01-01 00:00:00 UTC" do
      Time.at(1184027924).getgm.asctime.should == "Tue Jul 10 00:38:44 2007"
    end

    it "returns a Time object representing the given number of Float seconds since 1970-01-01 00:00:00 UTC" do
      t = Time.at(10.5)
      t.usec.should == 500000.0
      t.should_not == Time.at(10)
    end

    it "returns a non-UTC Time" do
      Time.at(1184027924).utc?.should == false
    end

    it "returns a subclass instance on a Time subclass" do
      c = Class.new(Time)
      t = c.at(0)
      t.should be_an_instance_of(c)
    end
  end

  describe "passed Time" do
    it "creates a new time object with the value given by time" do
      t = Time.now
      Time.at(t).inspect.should == t.inspect
    end

    it "creates a dup time object with the value given by time" do
      t1 = Time.new
      t2 = Time.at(t1)
      t1.object_id.should_not == t2.object_id
    end

    it "returns a UTC time if the argument is UTC" do
      t = Time.now.getgm
      Time.at(t).utc?.should == true
    end

    it "returns a non-UTC time if the argument is non-UTC" do
      t = Time.now
      Time.at(t).utc?.should == false
    end

    it "returns a subclass instance" do
      c = Class.new(Time)
      t = c.at(Time.now)
      t.should be_an_instance_of(c)
    end
  end

  describe "passed non-Time, non-Numeric" do
    it "raises a TypeError with a String argument" do
      lambda { Time.at("0") }.should raise_error(TypeError)
    end

    it "raises a TypeError with a nil argument" do
      lambda { Time.at(nil) }.should raise_error(TypeError)
    end

    describe "with an argument that responds to #to_int" do
      ruby_version_is ""..."1.9" do
        it "raises a TypeError" do
          o = mock('integer')
          o.should_not_receive(:to_int)
          lambda { Time.at(o) }.should raise_error(TypeError)
        end
      end

      ruby_version_is "1.9" do
        it "coerces using #to_int" do
          o = mock('integer')
          o.should_receive(:to_int).and_return(0)
          Time.at(o).should == Time.at(0)
        end
      end
    end

    describe "with an argument that responds to #to_r" do
      ruby_version_is ""..."1.9" do
        it "raises a TypeError" do
          o = mock_numeric('rational')
          o.should_not_receive(:to_r)
          lambda { Time.at(o) }.should raise_error(TypeError)
        end
      end

      ruby_version_is "1.9" do
        it "coerces using #to_r" do
          o = mock_numeric('rational')
          o.should_receive(:to_r).and_return(Rational(5, 2))
          Time.at(o).should == Time.at(Rational(5, 2))
        end
      end
    end
  end

  describe "passed [Integer, Numeric]" do
    it "returns a Time object representing the given number of seconds and Integer microseconds since 1970-01-01 00:00:00 UTC" do
      t = Time.at(10, 500000)
      t.tv_sec.should == 10
      t.tv_usec.should == 500000
    end

    ruby_version_is "1.9" do
      it "returns a Time object representing the given number of seconds and Float microseconds since 1970-01-01 00:00:00 UTC" do
        t = Time.at(10, 500.500)
        t.tv_sec.should == 10
        t.tv_nsec.should == 500500
      end
    end
  end

  describe "with a second argument that responds to #to_int" do
    it "coerces using #to_int" do
      o = mock('integer')
      o.should_receive(:to_int).and_return(10)
      Time.at(0, o).should == Time.at(0, 10)
    end
  end

  describe "with a second argument that responds to #to_r" do
    ruby_version_is ""..."1.9" do
      it "raises a TypeError" do
        o = mock('rational')
        o.should_not_receive(:to_r)
        lambda { Time.at(0, o) }.should raise_error(TypeError)
      end
    end

    ruby_version_is "1.9" do
      it "coerces using #to_r" do
        o = mock_numeric('rational')
        o.should_receive(:to_r).and_return(Rational(5, 2))
        Time.at(0, o).should == Time.at(0, Rational(5, 2))
      end
    end
  end

  describe "passed [Integer, nil]" do
    it "raises a TypeError" do
      lambda { Time.at(0, nil) }.should raise_error(TypeError)
    end
  end

  describe "passed [Integer, String]" do
    it "raises a TypeError" do
      lambda { Time.at(0, "0") }.should raise_error(TypeError)
    end
  end

  describe "passed [Time, Integer]" do
    ruby_version_is ""..."1.9" do
      it "raises a TypeError" do
        lambda { Time.at(Time.now, 500000) }.should raise_error(TypeError)
      end
    end

    ruby_bug "#8173", "2.0" do
      it "raises a TypeError" do
        lambda { Time.at(Time.now, 500000) }.should raise_error(TypeError)
      end
    end
  end
end


text:
class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedProject
  include SharedNote
  include SharedPaths
  include Select2Helper

  step 'I am a member of project "Shop"' do
    @project = Project.find_by(name: "Shop")
    @project ||= create(:project, name: "Shop")
    @project.team << [@user, :reporter]
    @project.ensure_satellite_exists
  end

  step 'I have a project forked off of "Shop" called "Forked Shop"' do
    @forked_project = Projects::ForkService.new(@project, @user).execute
  end

  step 'I click link "New Merge Request"' do
    click_link "New Merge Request"
  end

  step 'I should see merge request "Merge Request On Forked Project"' do
    expect(@project.merge_requests.size).to be >= 1
    @merge_request = @project.merge_requests.last
    expect(current_path).to eq namespace_project_merge_request_path(@project.namespace, @project, @merge_request)
    expect(@merge_request.title).to eq "Merge Request On Forked Project"
    expect(@merge_request.source_project).to eq @forked_project
    expect(@merge_request.source_branch).to eq "fix"
    expect(@merge_request.target_branch).to eq "master"
    expect(page).to have_content @forked_project.path_with_namespace
    expect(page).to have_content @project.path_with_namespace
    expect(page).to have_content @merge_request.source_branch
    expect(page).to have_content @merge_request.target_branch
  end

  step 'I fill out a "Merge Request On Forked Project" merge request' do
    select @forked_project.path_with_namespace, from: "merge_request_source_project_id"
    select @project.path_with_namespace, from: "merge_request_target_project_id"
    select "fix", from: "merge_request_source_branch"
    select "master", from: "merge_request_target_branch"

    click_button "Compare branches"

    fill_in "merge_request_title", with: "Merge Request On Forked Project"
  end

  step 'I submit the merge request' do
    click_button "Submit new merge request"
  end

  step 'I follow the target commit link' do
    commit = @project.repository.commit
    click_link commit.short_id(8)
  end

  step 'I should see the commit under the forked from project' do
    commit = @project.repository.commit
    expect(page).to have_content(commit.message)
  end

  step 'I click "Create Merge Request on fork" link' do
    click_link "Create Merge Request on fork"
  end

  step 'I see prefilled new Merge Request page for the forked project' do
    expect(current_path).to eq new_namespace_project_merge_request_path(@forked_project.namespace, @forked_project)
    expect(find("#merge_request_source_project_id").value).to eq @forked_project.id.to_s
    expect(find("#merge_request_target_project_id").value).to eq @project.id.to_s
    expect(find("#merge_request_source_branch").value).to have_content "new_design"
    expect(find("#merge_request_target_branch").value).to have_content "master"
    expect(find("#merge_request_title").value).to eq "New Design"
    verify_commit_link(".mr_target_commit", @project)
    verify_commit_link(".mr_source_commit", @forked_project)
  end

  step 'I update the merge request title' do
    fill_in "merge_request_title", with: "An Edited Forked Merge Request"
  end

  step 'I save the merge request' do
    click_button "Save changes"
  end

  step 'I should see the edited merge request' do
    expect(page).to have_content "An Edited Forked Merge Request"
    expect(@project.merge_requests.size).to be >= 1
    @merge_request = @project.merge_requests.last
    expect(current_path).to eq namespace_project_merge_request_path(@project.namespace, @project, @merge_request)
    expect(@merge_request.source_project).to eq @forked_project
    expect(@merge_request.source_branch).to eq "fix"
    expect(@merge_request.target_branch).to eq "master"
    expect(page).to have_content @forked_project.path_with_namespace
    expect(page).to have_content @project.path_with_namespace
    expect(page).to have_content @merge_request.source_branch
    expect(page).to have_content @merge_request.target_branch
  end

  step 'I should see last push widget' do
    expect(page).to have_content "You pushed to new_design"
    expect(page).to have_link "Create Merge Request"
  end

  step 'I click link edit "Merge Request On Forked Project"' do
    find("#edit_merge_request").click
  end

  step 'I see the edit page prefilled for "Merge Request On Forked Project"' do
    expect(current_path).to eq edit_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)
    expect(page).to have_content "Edit merge request ##{@merge_request.id}"
    expect(find("#merge_request_title").value).to eq "Merge Request On Forked Project"
  end

  step 'I fill out an invalid "Merge Request On Forked Project" merge request' do
    select "Select branch", from: "merge_request_target_branch"
    expect(find(:select, "merge_request_source_project_id", {}).value).to eq @forked_project.id.to_s
    expect(find(:select, "merge_request_target_project_id", {}).value).to eq @project.id.to_s
    expect(find(:select, "merge_request_source_branch", {}).value).to eq ""
    expect(find(:select, "merge_request_target_branch", {}).value).to eq ""
    click_button "Compare branches"
  end

  step 'I should see validation errors' do
    expect(page).to have_content "You must select source and target branch"
  end

  step 'the target repository should be the original repository' do
    expect(page).to have_select("merge_request_target_project_id", selected: @project.path_with_namespace)
  end

  step 'I click "Assign to" dropdown"' do
    first('.ajax-users-select').click
  end

  step 'I should see the target project ID in the input selector' do
    expect(page).to have_selector("input[data-project-id=\"#{@project.id}\"]")
  end

  step 'I should see the users from the target project ID' do
    expect(page).to have_selector('.user-result', visible: true, count: 2)
    users = page.all('.user-name')
    expect(users[0].text).to eq 'Unassigned'
    expect(users[1].text).to eq @project.users.first.name
  end

  # Verify a link is generated against the correct project
  def verify_commit_link(container_div, container_project)
    # This should force a wait for the javascript to execute
    expect(find(:div,container_div).find(".commit_short_id")['href']).to have_content "#{container_project.path_with_namespace}/commit"
  end
end