text:
package com.mytdev.cliqui.swing.components;

import com.mytdev.cliqui.cli.Argument;
import com.mytdev.cliqui.cli.constraints.PathExistsConstraint;
import com.mytdev.cliqui.cli.constraints.PathSelectionMode;
import com.mytdev.cliqui.cli.constraints.PathSelectionModeConstraint;
import com.mytdev.cliqui.util.ValidatingFileChooser;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.EnumMap;
import java.util.Map;
import javax.swing.JFileChooser;

/**
 *
 * @author Yann D'Isanto
 */
public final class PathListArgumentUI extends AbstractListArgumentUI<Path> {

    private static final Map<PathSelectionMode, Integer> SELECTION_MODES = new EnumMap<>(PathSelectionMode.class);

    static {
        SELECTION_MODES.put(PathSelectionMode.FILES_ONLY, JFileChooser.FILES_ONLY);
        SELECTION_MODES.put(PathSelectionMode.FILES_AND_DIRECTORIES, JFileChooser.FILES_AND_DIRECTORIES);
        SELECTION_MODES.put(PathSelectionMode.DIRECTORIES_ONLY, JFileChooser.DIRECTORIES_ONLY);
    }

    protected final JFileChooser fileChooser;

    public PathListArgumentUI(Argument commandLineElement) {
        super(commandLineElement, new StringConverter<Path>() {

            @Override
            public String format(Path path) {
                return path.toString();
            }

            @Override
            public Path parse(String string) {
                return Paths.get(string);
            }
        });

        final PathExistsConstraint pathExistsConstraint = commandLineElement
                .getConstraint(PathExistsConstraint.class);
        final boolean pathMustExist = pathExistsConstraint != null
                ? pathExistsConstraint.isPathExistsMandatory()
                : false;
        fileChooser = new ValidatingFileChooser(new ValidatingFileChooser.DefaultValidator() {

            @Override
            public void validateFileSelection(File file) throws IllegalArgumentException {
                if (pathMustExist && file.exists() == false) {
                    throw new IllegalArgumentException("the selected path does not denote an existing file or directory: " + file.toPath());
                }
            }
        });
        fileChooser.setMultiSelectionEnabled(false);
        final PathSelectionModeConstraint selectionModeConstraint = commandLineElement.getConstraint(PathSelectionModeConstraint.class);
        fileChooser.setFileSelectionMode(selectionModeConstraint != null
            ? SELECTION_MODES.get(selectionModeConstraint.getMode())
            : JFileChooser.FILES_AND_DIRECTORIES);
        fileChooser.setMultiSelectionEnabled(true);
    }

    @Override
    protected void addButtonActionPerformed(ActionEvent e) {
        if (fileChooser.showDialog((Component) e.getSource(), "Select") == JFileChooser.APPROVE_OPTION) {
            for (File file : fileChooser.getSelectedFiles()) {
                listModel.addElement(file.toPath());
            }
        }
    }

}


text:
package com.tickaroo.tikxml.annotationprocessing.elementlist.constructor;

import com.tickaroo.tikxml.TikXml;
import com.tickaroo.tikxml.annotationprocessing.DateConverter;
import com.tickaroo.tikxml.TestUtils;
import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import org.junit.*;

/**
 * @author Hannes Dorfmann
 */
public class CatalogueConstructorTest {

  @Test
  public void simple() throws IOException, ParseException {
    TikXml xml = new TikXml.Builder().exceptionOnUnreadXml(true).build();

    CatalogueConstructor catalogue = xml.read(TestUtils.sourceForFile("books.xml"), CatalogueConstructor.class);

    Assert.assertEquals(10, catalogue.getBooks().size());
    for (int i = 1; i<= 10; i++){
      BookConstructor book = catalogue.getBooks().get(i-1);
      Date date = DateConverter.Companion.getFormat().parse("2000-09-0"+i);

      Assert.assertEquals(i, book.getId());
      Assert.assertEquals("author"+i, book.getAuthor());
      Assert.assertEquals("genre"+i, book.getGenre());
      Assert.assertEquals(i, book.getPrice(), 0);
      Assert.assertEquals(date, book.getPublishDate());
      Assert.assertEquals("description"+i, book.getDescription());
    }
  }

  @Test
  public void simpleWithAttributeInPath() throws IOException, ParseException {
    TikXml xml = new TikXml.Builder().exceptionOnUnreadXml(true).build();

    CatalogueConstructor catalogue = xml.read(TestUtils.sourceForFile("books_with_attribute_with_path.xml"), CatalogueConstructor.class);

    Assert.assertEquals(10, catalogue.getBooks().size());
    for (int i = 1; i<= 10; i++){
      BookConstructor book = catalogue.getBooks().get(i-1);
      Date date = DateConverter.Companion.getFormat().parse("2000-09-0"+i);

      Assert.assertEquals(i, book.getId());
      Assert.assertEquals("author"+i, book.getAuthor());
      Assert.assertEquals("genre"+i, book.getGenre());
      Assert.assertEquals(i, book.getPrice(), 0);
      Assert.assertEquals(date, book.getPublishDate());
      Assert.assertEquals("description"+i, book.getDescription());
    }
  }

  @Test
  public void inlineList() throws IOException, ParseException {
    TikXml xml = new TikXml.Builder().exceptionOnUnreadXml(true).build();

    InlineListCatalogueConstructor catalogue = xml.read(TestUtils.sourceForFile("books_inline.xml"), InlineListCatalogueConstructor.class);

    Assert.assertEquals(10, catalogue.getBooks().size());
    for (int i = 1; i<= 10; i++){
      BookConstructor book = catalogue.getBooks().get(i-1);
      Date date = DateConverter.Companion.getFormat().parse("2000-09-0"+i);

      Assert.assertEquals(i, book.getId());
      Assert.assertEquals("author"+i, book.getAuthor());
      Assert.assertEquals("genre"+i, book.getGenre());
      Assert.assertEquals(i, book.getPrice(), 0);
      Assert.assertEquals(date, book.getPublishDate());
      Assert.assertEquals("description"+i, book.getDescription());
    }
  }

  @Test
  public void simpleDataClass() throws IOException, ParseException {
    TikXml xml = new TikXml.Builder().exceptionOnUnreadXml(true).build();

    CatalogueConstructorDataClass catalogue = xml.read(TestUtils.sourceForFile("books.xml"), CatalogueConstructorDataClass.class);

    Assert.assertEquals(10, catalogue.getBooks().size());
    for (int i = 1; i<= 10; i++){
      BookConstructorDataClass book = catalogue.getBooks().get(i-1);
      Date date = DateConverter.Companion.getFormat().parse("2000-09-0"+i);

      Assert.assertEquals(i, book.getId());
      Assert.assertEquals("author"+i, book.getAuthor());
      Assert.assertEquals("genre"+i, book.getGenre());
      Assert.assertEquals(i, book.getPrice(), 0);
      Assert.assertEquals(date, book.getPublishDate());
      Assert.assertEquals("description"+i, book.getDescription());
    }
  }

  @Test
  public void simpleWithAttributeInPathDataClass() throws IOException, ParseException {
    TikXml xml = new TikXml.Builder().exceptionOnUnreadXml(true).build();

    CatalogueConstructorDataClass catalogue = xml.read(TestUtils.sourceForFile("books_with_attribute_with_path.xml"), CatalogueConstructorDataClass.class);

    Assert.assertEquals(10, catalogue.getBooks().size());
    for (int i = 1; i<= 10; i++){
      BookConstructorDataClass book = catalogue.getBooks().get(i-1);
      Date date = DateConverter.Companion.getFormat().parse("2000-09-0"+i);

      Assert.assertEquals(i, book.getId());
      Assert.assertEquals("author"+i, book.getAuthor());
      Assert.assertEquals("genre"+i, book.getGenre());
      Assert.assertEquals(i, book.getPrice(), 0);
      Assert.assertEquals(date, book.getPublishDate());
      Assert.assertEquals("description"+i, book.getDescription());
    }
  }

  @Test
  public void inlineListDataClass() throws IOException, ParseException {
    TikXml xml = new TikXml.Builder().exceptionOnUnreadXml(true).build();

    InlineListCatalogueConstructorDataClass catalogue = xml.read(TestUtils.sourceForFile("books_inline.xml"), InlineListCatalogueConstructorDataClass.class);

    Assert.assertEquals(10, catalogue.getBooks().size());
    for (int i = 1; i<= 10; i++){
      BookConstructorDataClass book = catalogue.getBooks().get(i-1);
      Date date = DateConverter.Companion.getFormat().parse("2000-09-0"+i);

      Assert.assertEquals(i, book.getId());
      Assert.assertEquals("author"+i, book.getAuthor());
      Assert.assertEquals("genre"+i, book.getGenre());
      Assert.assertEquals(i, book.getPrice(), 0);
      Assert.assertEquals(date, book.getPublishDate());
      Assert.assertEquals("description"+i, book.getDescription());
    }
  }
}

redpajama_set_name: RedPajamaGithub


text:
<?php

class RegistrationProcedure {

private $dsn = 'oci:dbname=clin';
private $user ;
private $password ;

	public function __construct($userClin='breast_registration', $pwdClin='md5_breast@clin'){
		$this->user= $userClin;
		$this->password = $pwdClin;
	}

	public function __destruct(){
		unset($this);
	}

	public function execute ($procedureName){
		$resultat ='';
		try
		{
			$dbh = new PDO($this->dsn, $this->user, $this->password);
			$stmt = $dbh->prepare("CALL $procedureName");
			$stmt->execute();
			$resultat ='OK';
			unset($dbh);
		}

		catch (PDOException $e)
		{
			$resultat = 'Connection failed: ' . $e->getMessage();
		}

		return $resultat ;
	}
}

?>


text:
Adds syntax highlighting and snippets to Handlebars files in Atom.

Modified from [HTML Language Support in Atom](https://github.com/atom/language-html).

Contributions are greatly appreciated. Please fork this repository and open a pull request to add snippets, make grammar tweaks, etc.


text:
<?xml version="1.0" encoding="utf-8"?>
<library xmlns="duell">

    <supported-duell-tool version="4.0.0+" />

	<duelllib name="types" version="3.0.0+" />

    <include path="backends/filesystem_html5/duell_library.xml" if="html5" />
    <include path="backends/filesystem_android/duell_library.xml" if="android" />
    <include path="backends/filesystem_ios/duell_library.xml" if="ios" />
    <include path="backends/filesystem_flash/duell_library.xml" if="flash" />
    <include path="backends/filesystem_electron/duell_library.xml" if="electron" />

    <platform-config>
        <documentation>
            <documentation-folder library="filesystem" path="documentation" />
        </documentation>
    </platform-config>

</library>


text:
import urllib2
from urllib import urlencode
import json

debug=False

def first_flight():
    print "Hello from Python."

sky = "http://cs.kobj.net"
class Endpoint(object):
    domain = 'flier'
    eid = 0
    channel = 1
    def signal_event(self, event_name, args={}):
        response = self.post(
            "/sky/event/{0}/{1}".format(self.channel, self.eid),
            event_name, args)
        if debug: print response
        directives = json.loads(response).get('directives')
        for d in directives:
            self.perform(d.get('name'), d.get('options'))

    def post(self, url, _type, args):
        if not args.get('_domain'):
            args['_domain'] = self.domain
        args['_type'] = _type

        target = sky+url
        if debug:
            print ">>", target
            print ">>", args
        req = urllib2.Request(
            target,
            data=urlencode(args))
        f = urllib2.urlopen(req)
        response=[n for n in f.readlines() if not n.startswith("//")]
        return ''.join(response)

    def perform(self, directive, options):
        getattr(self, "do_"+directive)(options)


text:
# -----------------------------------------------------------------------------------------
# Script: ForeScript.Types.ServerChecklist-Type.psm1.ps1
# Author: Nigel Thomas
# Date: June 24, 2015
# Version: 1.0
# Purpose: This module provides a sample for processing custom data types in ForeScript.
#          The module must be named My_CUSTOM_DATA_Type-Type.psm1. It must expose functions
#          that will format a PSObject into the custom data type and to convert the custom
#          data type into an HTML output for display purposes.
#          The mappings for the custom types is found in the fstypes.json file in the
#          config folder.
#
# Project: foreScript
#
# -----------------------------------------------------------------------------------------
#
# (C) Nigel Thomas, 2015
#
#------------------------------------------------------------------------------------------

#Requires -version 3

function ConvertTo-ServerCheckList {

    [CmdletBinding()]
    Param(
        [Parameter(Position=0,Mandatory=$True)]
        [ValidateNotNullOrEmpty()]
        $InputObject,
        $StartupLocation )

    # Set the working directory to the startup path of the script
    Set-Location $StartupLocation
    [System.IO.Directory]::SetCurrentDirectory($StartupLocation)

    Add-Type -Path ( '.\Types\Modules\ForeScript.Types.dll')

    #$InputObject

    $ServerChecklist = New-Object ForeScript.Types.ServerChecklist
    $ServerChecklist.Description = $Header

    $SystemParams = @{
        ComputerName = $InputObject.System.Computername
        OS = $InputObject.System.OS
        ServicePack = $InputObject.System.ServicePack
        FreePhysicalMemory = $InputObject.System.FreePhysicalMemory
        FreeVirtualMemory = $InputObject.System.FreeVirtualMemory
        TotalVirtualMemorySize = $InputObject.System.TotalVirtualMemorySize
        TotalVisibleMemorySize = $InputObject.System.TotalVisibleMemorySize
        NumberOfProcesses = $InputObject.System.NumberOfProcesses
        LastBoot = $InputObject.System.LastBoot
        Uptime = $InputObject.System.Uptime
    }

    $ServerChecklist.System = New-Object ForeScript.Types.ServerChecklist+SystemInfo
    $ServerChecklist.System = $SystemParams
    #$ServerChecklist.System
    #$ServerChecklist.ConvertToJson($ServerChecklist.System) | Out-String

    $CPUParams = @{
        Manufacturer = $InputObject.Processor.Manufacturer
        Model = $InputObject.Processor.Model
        Architecture = $InputObject.Processor.Architecture
        Processors = $InputObject.Processor.Processors
    }

    $ServerCheckList.Processor = New-Object ForeScript.Types.ServerChecklist+ProcessorInfo
    $ServerCheckList.Processor = $CPUParams

    foreach ($Harddisk in $InputObject.HardDisk) {

        $ServerChecklist.AddHardDisk($Harddisk.DeviceID, $Harddisk.SizeGB, $Harddisk.FreeGB, $Harddisk.PercentFree)
    }

    foreach ($Service in $InputObject.Service) {

        $ServerChecklist.AddService($Service.Name, $Service.DisplayName, $Service.StartMode)
    }

    foreach ($ApplicationLog in $InputObject.ApplicationLog) {

        $ServerChecklist.AddApplicationLog($ApplicationLog.TimeGenerated, $ApplicationLog.EventCode, $ApplicationLog.SourceName, $ApplicationLog.Type, $ApplicationLog.Message)
    }

    foreach ($SystemLog in $InputObject.SystemLog) {

        $ServerChecklist.AddSystemLog($SystemLog.TimeGenerated, $SystemLog.EventCode, $SystemLog.SourceName, $SystemLog.Type, $SystemLog.Message)
    }

    $ServerChecklist

}

function Out-ServerChecklist {

    Param (
        [Parameter(Position=0,Mandatory=$True)]
        [ValidateNotNullOrEmpty()]
        [ForeScript.Types.ServerChecklist]$InputObject,

        [Parameter(Position=1,Mandatory=$True)]
        [ValidateNotNullOrEmpty()]
        $Template

    )

    $TEMPL_JQUERY_VERSION = (Get-Content ".\Templates\scripts\jquery-1.9.1.min.js" -ReadCount 0 | Out-String )
    $TEMPL_JQUERYDATATABLE_VERSION = (Get-Content ".\Templates\scripts\json.htmTable.js" -ReadCount 0 | Out-String )
    $outputtemplate = (Get-Content ".\Templates\html\$Template" -ReadCount 0 | Out-String )

    $tplparameter = @{ "TEMPL_JQUERY_VERSION" = "$TEMPL_JQUERY_VERSION";
                          "TEMPL_JQUERYDATATABLE_VERSION" = "$TEMPL_JQUERYDATATABLE_VERSION";
                          "TEMPL_HEADING" = $InputObject.Description;
                          "TEMPL_COMPUTERSYSTEM" = [ForeScript.Types.Utility]::ConvertToJson($InputObject.System);
                          "TEMPL_COMPUTERPROCESSOR" = [ForeScript.Types.Utility]::ConvertToJson($InputObject.Processor);
                          "TEMPL_COMPUTERDISKS" = [ForeScript.Types.Utility]::ConvertToJson($InputObject.HardDisk);
                          "TEMPL_COMPUTERSERVICE" = [ForeScript.Types.Utility]::ConvertToJson($InputObject.Service);
                          "TEMPL_COMPUTERSYSLOG" = [ForeScript.Types.Utility]::ConvertToJson($InputObject.SystemLog);
                          "TEMPL_COMPUTERAPPLOG" = [ForeScript.Types.Utility]::ConvertToJson($InputObject.ApplicationLog)

    }

    foreach ($key in $tplparameter.Keys) {
             $outputtemplate = $outputtemplate.Replace($key, $tplparameter[$key])
    }

    $outputtemplate
}

# Set functions to read only
Set-Item -Path function:ConvertTo-ServerCheckList -Options ReadOnly
Set-Item -Path function:Out-ServerChecklist -Options ReadOnly

# Export the functions that will be accessed outside the module
Export-ModuleMember -Function ConvertTo-ServerCheckList, Out-ServerChecklist


text: This reposotiory has moved to <https://github.com/Feldspar/raw-feldspar>.


text:
#pragma once

#include "utils/s2n_blob.h"

extern int s2n_rand_init(void);
extern int s2n_rand_cleanup(void);
extern int s2n_rand_cleanup_thread(void);
extern int s2n_get_public_random_data(struct s2n_blob *blob);
extern int s2n_get_public_random_bytes_used(void);
extern int s2n_get_private_random_data(struct s2n_blob *blob);
extern int s2n_get_private_random_bytes_used(void);
extern int s2n_get_urandom_data(struct s2n_blob *blob);
extern int64_t s2n_public_random(int64_t max);
extern int s2n_cpu_supports_rdrand();
extern int s2n_get_rdrand_data(struct s2n_blob *out);


text:
<?php

/**
 * @xmlNamespace http://schema.intuit.com/finance/v3
 * @xmlType StringTypeCustomFieldDefinition
 * @xmlName IPPStringTypeCustomFieldDefinition
 * @var IPPStringTypeCustomFieldDefinition
 */
class IPPStringTypeCustomFieldDefinitionWrapper
	extends IPPStringTypeCustomFieldDefinition
	{

		/**
		* Initializes this object, optionally with pre-defined property values
		*
		* Initializes this object and it's property members, using the dictionary
		* of key/value pairs passed as an optional argument.
		*
		* @param dictionary $keyValInitializers key/value pairs to be populated into object's properties
		* @param boolean $verbose specifies whether object should echo warnings
		*/
		public function __construct($keyValInitializers=array(), $verbose=FALSE)
		{
			foreach($keyValInitializers as $initPropName => $initPropVal)
			{
				if (property_exists('IPPStringTypeCustomFieldDefinitionWrapper',$initPropName))
				{
					$this->{$initPropName} = $initPropVal;
				}
				else
				{
					if ($verbose)
						echo "Property does not exist ($initPropName) in class (".get_class($this).")";
				}
			}
		}

} // end class IPPStringTypeCustomFieldDefinitionWrapper


text:
package org.apache.hadoop.test.system;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class ProcessInfoImpl implements ProcessInfo {

  private int threadCount;
  private long currentTime;
  private long freemem;
  private long maxmem;
  private long totmem;
  private Map<String, String> env;
  private Map<String, String> props;

  public ProcessInfoImpl() {
    env = new HashMap<String, String>();
    props = new HashMap<String, String>();
  }

  /**
   * Construct a concrete process information object. <br/>
   *
   * @param threadCount
   *          count of threads.
   * @param currentTime
   * @param freememory
   * @param maximummemory
   * @param totalmemory
   * @param env
   *          environment list.
   */
  public ProcessInfoImpl(int threadCount, long currentTime, long freemem,
      long maxmem, long totmem, Map<String, String> env,
      Map<String, String> props) {
    this.threadCount = threadCount;
    this.currentTime = currentTime;
    this.freemem = freemem;
    this.maxmem = maxmem;
    this.totmem = totmem;
    this.env = env;
    this.props = props;
  }

  @Override
  public int activeThreadCount() {
    return threadCount;
  }

  @Override
  public long currentTimeMillis() {
    return currentTime;
  }

  @Override
  public long freeMemory() {
    return freemem;
  }

  @Override
  public Map<String, String> getEnv() {
    return env;
  }

  @Override
  public Map<String,String> getSystemProperties() {
    return props;
  }

  @Override
  public long maxMemory() {
    return maxmem;
  }

  @Override
  public long totalMemory() {
    return totmem;
  }

  @Override
  public void readFields(DataInput in) throws IOException {
    this.threadCount = in.readInt();
    this.currentTime = in.readLong();
    this.freemem = in.readLong();
    this.maxmem = in.readLong();
    this.totmem = in.readLong();
    read(in, env);
    read(in, props);
  }

  @Override
  public void write(DataOutput out) throws IOException {
    out.writeInt(threadCount);
    out.writeLong(currentTime);
    out.writeLong(freemem);
    out.writeLong(maxmem);
    out.writeLong(totmem);
    write(out, env);
    write(out, props);
  }

  private void read(DataInput in, Map<String, String> map) throws IOException {
    int size = in.readInt();
    for (int i = 0; i < size; i = i + 2) {
      String key = in.readUTF();
      String value = in.readUTF();
      map.put(key, value);
    }
  }

  private void write(DataOutput out, Map<String, String> map)
  throws IOException {
    int size = (map.size() * 2);
    out.writeInt(size);
    for (Map.Entry<String, String> entry : map.entrySet()) {
      out.writeUTF(entry.getKey());
      out.writeUTF(entry.getValue());
    }
  }

  @Override
  public String toString() {
    StringBuffer strBuf = new StringBuffer();
    strBuf.append(String.format("active threads : %d\n", threadCount));
    strBuf.append(String.format("current time  : %d\n", currentTime));
    strBuf.append(String.format("free memory  : %d\n", freemem));
    strBuf.append(String.format("total memory  : %d\n", totmem));
    strBuf.append(String.format("max memory  : %d\n", maxmem));
    strBuf.append("Environment Variables : \n");
    for (Map.Entry<String, String> entry : env.entrySet()) {
      strBuf.append(String.format("key : %s value : %s \n", entry.getKey(),
          entry.getValue()));
    }
    return strBuf.toString();
  }

}


text:
TOP_DIR=../..

TCLSH=tclsh
FLAGS=

include $(TOP_DIR)/MakeDefs

# Target: test
test:
	$(TCLSH) marsutil.test $(FLAGS)

test_cellmodel:
	$(TCLSH) cellmodel.test $(FLAGS)

test_dynaform:
	$(TCLSH) dynaform.test $(FLAGS)

test_marsmisc:
	$(TCLSH) marsmisc.test $(FLAGS)

test_order:
	$(TCLSH) order.test $(FLAGS)

test_simclock:
	$(TCLSH) simclock.test $(FLAGS)

test_sqldocument:
	$(TCLSH) sqldocument.test $(FLAGS)

test_sqlib:
	$(TCLSH) sqlib.test $(FLAGS)

test_undostack:
	$(TCLSH) undostack.test $(FLAGS)

include $(TOP_DIR)/MakeRules