text:
package instasarama

import (
	"bytes"

	"github.com/Shopify/sarama"
	instana "github.com/instana/go-sensor"
	ot "github.com/opentracing/opentracing-go"
	"github.com/opentracing/opentracing-go/ext"
	otlog "github.com/opentracing/opentracing-go/log"
)

// SyncProducer is a wrapper for sarama.SyncProducer that instruments its calls using
// provided instana.Sensor
type SyncProducer struct {
	sarama.SyncProducer
	sensor         *instana.Sensor
	propageContext bool
}

// NewSyncProducer creates a new SyncProducer using the given broker addresses and configuration, and
// instruments its calls
func NewSyncProducer(addrs []string, config *sarama.Config, sensor *instana.Sensor) (sarama.SyncProducer, error) {
	sp, err := sarama.NewSyncProducer(addrs, config)
	if err != nil {
		return sp, err
	}

	return WrapSyncProducer(sp, config, sensor), nil
}

// NewSyncProducerFromClient creates a new SyncProducer using the given client, and instruments its calls
func NewSyncProducerFromClient(client sarama.Client, sensor *instana.Sensor) (sarama.SyncProducer, error) {
	sp, err := sarama.NewSyncProducerFromClient(client)
	if err != nil {
		return sp, err
	}

	return WrapSyncProducer(sp, client.Config(), sensor), nil
}

// WrapSyncProducer wraps an existing sarama.SyncProducer instance and instruments its calls. It requires the same
// config that was used to create this producer to detect the Kafka version and whether it's supposed to return
// successes/errors. To initialize a new sync producer instance use instasarama.NewSyncProducer() and
// instasarama.NewSyncProducerFromClient() convenience methods instead
func WrapSyncProducer(sp sarama.SyncProducer, config *sarama.Config, sensor *instana.Sensor) *SyncProducer {
	return &SyncProducer{
		SyncProducer:   sp,
		sensor:         sensor,
		propageContext: contextPropagationSupported(config.Version),
	}
}

// SendMessage picks up the trace context previously added to the message with
// instasarama.ProducerMessageWithSpan(), starts a new child span and injects its
// context into the message headers before sending it to the underlying producer.
// The call will not be traced if there the message does not contain trace context
func (p *SyncProducer) SendMessage(msg *sarama.ProducerMessage) (int32, int64, error) {
	sp := startProducerSpan(p.sensor, msg)
	if sp != nil {
		defer sp.Finish()

		carrier := ProducerMessageCarrier{msg}
		if p.propageContext {
			// forward the trace context, updating the span ids
			sp.Tracer().Inject(sp.Context(), ot.TextMap, carrier)
		} else {
			// remove previously added trace headers
			carrier.RemoveAll()
		}
	}

	partition, offset, err := p.SyncProducer.SendMessage(msg)
	if err != nil && sp != nil {
		sp.SetTag("kafka.error", err)
		sp.LogFields(otlog.Error(err))
	}

	return partition, offset, err
}

// SendMessages starts a new span and injects its context into messages headers before
// sending them with the underlying producer.
//
// This method attempts to use the existing trace context found in message headers.
// There will be NO SPAN CREATED for this call if messages originate from different trace contexts.
// A possible use case that result in such behavior would be if messages resulted from different
// HTTP requests are buffered and later being sent in one batch asynchronously.
// In case you want your batch publish operation to be a part of a specific trace, make sure that
// you inject the parent span of this trace explicitly before calling `SendMessages()`, i.e.
//
// type MessageCollector struct {
// 	CollectedMessages []*sarama.ProducerMessage
// 	producer *instasarama.SyncProducer
// 	// ...
// }
//
// func (c MessageCollector) Flush(ctx context.Context) error {
// 	// extract the parent span from context and use it to continue the trace
// 	if parentSpan, ok := instana.SpanFromContext(ctx); ok {
// 		// start a new span for the batch send job
//		sp := parentSpan.Tracer().StartSpan("batch-send", ot.ChilfOf(parentSpan.Context()))
// 		defer sp.Finish()
//
// 		// inject the trace context into every collected message, overriding the existing one
//		for i, msg := range c.CollectedMessages {
// 			c.CollectedMessages = instasarama.ProducerMessageWithSpan(msg, sp)
// 		}
// 	}
//
// 	return c.producer.SendMessages(c.CollectedMessages)
// }
func (p *SyncProducer) SendMessages(msgs []*sarama.ProducerMessage) error {
	if len(msgs) == 0 {
		return nil
	}

	var sp ot.Span
	if producerMessagesFromSameContext(msgs) {
		sp = startProducerSpan(p.sensor, msgs[0])
	}

	if sp != nil {
		defer sp.Finish()

		instana.BatchSize(len(msgs)).Set(sp)

		// collect unique topics from the rest of messages and inject trace context in one go
		topics := make(map[string]struct{})
		for _, msg := range msgs {
			if _, ok := topics[msg.Topic]; !ok {
				topics[msg.Topic] = struct{}{}
			}

			// forward the trace context, updating the span id
			sp.Tracer().Inject(sp.Context(), ot.TextMap, ProducerMessageCarrier{msg})
		}

		// send topics as a comma-separated string
		buf := bytes.NewBuffer(nil)
		for topic := range topics {
			buf.WriteString(topic)
			buf.WriteByte(',')
		}
		buf.Truncate(buf.Len() - 1) // truncate trailing comma
		sp.SetTag("kafka.service", buf.String())
	}

	err := p.SyncProducer.SendMessages(msgs)
	if err != nil && sp != nil {
		sp.SetTag("kafka.error", err)
		sp.LogFields(otlog.Error(err))
	}

	return err
}

// startSpan picks up the existing trace context provided in the message and returns a new child
// span. It returns nil if there is no valid context provided in the message
func startProducerSpan(sensor *instana.Sensor, msg *sarama.ProducerMessage) ot.Span {
	switch sc, err := sensor.Tracer().Extract(ot.TextMap, ProducerMessageCarrier{msg}); err {
	case nil:
		return sensor.Tracer().StartSpan(
			"kafka",
			ext.SpanKindProducer,
			ot.ChildOf(sc),
			ot.Tags{
				"kafka.service": msg.Topic,
				"kafka.access":  "send",
			},
		)
	case ot.ErrSpanContextNotFound:
		sensor.Logger().Debug("no span context provided in message to ", msg.Topic, ", skipping the call", msg.Topic)
	case ot.ErrUnsupportedFormat:
		sensor.Logger().Info("unsupported span context format provided in message to ", msg.Topic, ", skipping the call")
	default:
		sensor.Logger().Warn("failed to extract span context from producer message headers: ", err)
	}

	return nil
}

func producerMessagesFromSameContext(msgs []*sarama.ProducerMessage) bool {
	if len(msgs) == 0 {
		return true
	}

	firstTraceID, firstSpanID, err := extractTraceSpanID(msgs[0])
	if err != nil {
		return false
	}

	for _, msg := range msgs[1:] {
		traceID, spanID, err := extractTraceSpanID(msg)
		if err != nil {
			return false
		}

		if traceID != firstTraceID || spanID != firstSpanID {
			return false
		}
	}

	return true
}


text:
class AddEmailAddressToAppointmentSummaries < ActiveRecord::Migration
  def change
    add_column :appointment_summaries, :email_address, :string
  end
end

redpajama_set_name: RedPajamaGithub


text:
package org.jkiss.dbeaver.ext.firebird.model;

import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.ext.generic.model.GenericStructContainer;
import org.jkiss.dbeaver.ext.generic.model.GenericTable;
import org.jkiss.dbeaver.ext.generic.model.GenericTableColumn;
import org.jkiss.dbeaver.model.DBPNamedObject2;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;

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

public class FireBirdTable extends GenericTable implements DBPNamedObject2 {

    public FireBirdTable(GenericStructContainer container, @Nullable String tableName, @Nullable String tableType, @Nullable JDBCResultSet dbResult) {
        super(container, tableName, tableType, dbResult);
    }

    @Override
    protected boolean isTruncateSupported() {
        return false;
    }

    @Override
    public synchronized List<FireBirdTableColumn> getAttributes(@NotNull DBRProgressMonitor monitor) throws DBException {
        Collection<? extends GenericTableColumn> childColumns = super.getAttributes(monitor);
        if (childColumns == null) {
            return Collections.emptyList();
        }
        List<FireBirdTableColumn> columns = new ArrayList<>();
        for (GenericTableColumn gtc : childColumns) {
            columns.add((FireBirdTableColumn) gtc);
        }
        columns.sort(DBUtils.orderComparator());
        return columns;
    }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <properties>
        <stratio-test-bdd.version>0.2.0-SNAPSHOT</stratio-test-bdd.version>
    </properties>

    <groupId>com.stratio.sparta</groupId>
    <artifactId>sparta-test</artifactId>
    <version>0.12.0-SNAPSHOT</version>
    <name>sparta-test-cucumber</name>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.17</version>
                <executions>
                    <execution>
                        <id>acceptance-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>suite.xml</suiteXmlFile>
                    </suiteXmlFiles>
                    <properties>
                        <property>
                            <name>usedefaultlisteners</name>
                            <value>false</value>
                        </property>
                        <property>
                            <name>listener</name>
                            <value>com.stratio.tests.utils.JaCoCoClient</value>
                        </property>
                    </properties>
                    <argLine>-Xmx1024m -XX:+HeapDumpOnOutOfMemoryError
                        -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/1.8.8/aspectjweaver-1.8.8.jar</argLine>
                    <useSystemClassloader>true</useSystemClassloader>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>com.stratio.qa</groupId>
            <artifactId>bdt-lib</artifactId>
            <version>${stratio-test-bdd.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-1.2-api</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
           <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.9.9</version>
        </dependency>
    </dependencies>

</project>


text:
/* $Id: sys_sparc.c,v 1.70 2001/04/14 01:12:02 davem Exp $
 * linux/arch/sparc/kernel/sys_sparc.c
 *
 * This file contains various random system calls that
 * have a non-standard calling sequence on the Linux/sparc
 * platform.
 */

#include <linux/errno.h>
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/fs.h>
#include <linux/file.h>
#include <linux/sem.h>
#include <linux/msg.h>
#include <linux/shm.h>
#include <linux/stat.h>
#include <linux/syscalls.h>
#include <linux/mman.h>
#include <linux/utsname.h>
#include <linux/smp.h>
#include <linux/smp_lock.h>

#include <asm/uaccess.h>
#include <asm/ipc.h>
#include <asm/unistd.h>

/* #define DEBUG_UNIMP_SYSCALL */

/* XXX Make this per-binary type, this way we can detect the type of
 * XXX a binary.  Every Sparc executable calls this very early on.
 */
asmlinkage unsigned long sys_getpagesize(void)
{
	return PAGE_SIZE; /* Possibly older binaries want 8192 on sun4's? */
}

#define COLOUR_ALIGN(addr)      (((addr)+SHMLBA-1)&~(SHMLBA-1))

unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
{
	struct vm_area_struct * vmm;

	if (flags & MAP_FIXED) {
		/* We do not accept a shared mapping if it would violate
		 * cache aliasing constraints.
		 */
		if ((flags & MAP_SHARED) && (addr & (SHMLBA - 1)))
			return -EINVAL;
		return addr;
	}

	/* See asm-sparc/uaccess.h */
	if (len > TASK_SIZE - PAGE_SIZE)
		return -ENOMEM;
	if (ARCH_SUN4C_SUN4 && len > 0x20000000)
		return -ENOMEM;
	if (!addr)
		addr = TASK_UNMAPPED_BASE;

	if (flags & MAP_SHARED)
		addr = COLOUR_ALIGN(addr);
	else
		addr = PAGE_ALIGN(addr);

	for (vmm = find_vma(current->mm, addr); ; vmm = vmm->vm_next) {
		/* At this point:  (!vmm || addr < vmm->vm_end). */
		if (ARCH_SUN4C_SUN4 && addr < 0xe0000000 && 0x20000000 - len < addr) {
			addr = PAGE_OFFSET;
			vmm = find_vma(current->mm, PAGE_OFFSET);
		}
		if (TASK_SIZE - PAGE_SIZE - len < addr)
			return -ENOMEM;
		if (!vmm || addr + len <= vmm->vm_start)
			return addr;
		addr = vmm->vm_end;
		if (flags & MAP_SHARED)
			addr = COLOUR_ALIGN(addr);
	}
}

asmlinkage unsigned long sparc_brk(unsigned long brk)
{
	if(ARCH_SUN4C_SUN4) {
		if ((brk & 0xe0000000) != (current->mm->brk & 0xe0000000))
			return current->mm->brk;
	}
	return sys_brk(brk);
}

/*
 * sys_pipe() is the normal C calling standard for creating
 * a pipe. It's not the way unix traditionally does this, though.
 */
asmlinkage int sparc_pipe(struct pt_regs *regs)
{
	int fd[2];
	int error;

	error = do_pipe(fd);
	if (error)
		goto out;
	regs->u_regs[UREG_I1] = fd[1];
	error = fd[0];
out:
	return error;
}

/*
 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
 *
 * This is really horribly ugly.
 */

asmlinkage int sys_ipc (uint call, int first, int second, int third, void __user *ptr, long fifth)
{
	int version, err;

	version = call >> 16; /* hack for backward compatibility */
	call &= 0xffff;

	if (call <= SEMCTL)
		switch (call) {
		case SEMOP:
			err = sys_semtimedop (first, (struct sembuf __user *)ptr, second, NULL);
			goto out;
		case SEMTIMEDOP:
			err = sys_semtimedop (first, (struct sembuf __user *)ptr, second, (const struct timespec __user *) fifth);
			goto out;
		case SEMGET:
			err = sys_semget (first, second, third);
			goto out;
		case SEMCTL: {
			union semun fourth;
			err = -EINVAL;
			if (!ptr)
				goto out;
			err = -EFAULT;
			if (get_user(fourth.__pad,
				     (void __user * __user *)ptr))
				goto out;
			err = sys_semctl (first, second, third, fourth);
			goto out;
			}
		default:
			err = -ENOSYS;
			goto out;
		}
	if (call <= MSGCTL)
		switch (call) {
		case MSGSND:
			err = sys_msgsnd (first, (struct msgbuf __user *) ptr,
					  second, third);
			goto out;
		case MSGRCV:
			switch (version) {
			case 0: {
				struct ipc_kludge tmp;
				err = -EINVAL;
				if (!ptr)
					goto out;
				err = -EFAULT;
				if (copy_from_user(&tmp, (struct ipc_kludge __user *) ptr, sizeof (tmp)))
					goto out;
				err = sys_msgrcv (first, tmp.msgp, second, tmp.msgtyp, third);
				goto out;
				}
			case 1: default:
				err = sys_msgrcv (first,
						  (struct msgbuf __user *) ptr,
						  second, fifth, third);
				goto out;
			}
		case MSGGET:
			err = sys_msgget ((key_t) first, second);
			goto out;
		case MSGCTL:
			err = sys_msgctl (first, second, (struct msqid_ds __user *) ptr);
			goto out;
		default:
			err = -ENOSYS;
			goto out;
		}
	if (call <= SHMCTL)
		switch (call) {
		case SHMAT:
			switch (version) {
			case 0: default: {
				ulong raddr;
				err = do_shmat (first, (char __user *) ptr, second, &raddr);
				if (err)
					goto out;
				err = -EFAULT;
				if (put_user (raddr, (ulong __user *) third))
					goto out;
				err = 0;
				goto out;
				}
			case 1:	/* iBCS2 emulator entry point */
				err = -EINVAL;
				goto out;
			}
		case SHMDT:
			err = sys_shmdt ((char __user *)ptr);
			goto out;
		case SHMGET:
			err = sys_shmget (first, second, third);
			goto out;
		case SHMCTL:
			err = sys_shmctl (first, second, (struct shmid_ds __user *) ptr);
			goto out;
		default:
			err = -ENOSYS;
			goto out;
		}
	else
		err = -ENOSYS;
out:
	return err;
}

int sparc_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
{
	if (ARCH_SUN4C_SUN4 &&
	    (len > 0x20000000 ||
	     ((flags & MAP_FIXED) &&
	      addr < 0xe0000000 && addr + len > 0x20000000)))
		return -EINVAL;

	/* See asm-sparc/uaccess.h */
	if (len > TASK_SIZE - PAGE_SIZE || addr + len > TASK_SIZE - PAGE_SIZE)
		return -EINVAL;

	return 0;
}

/* Linux version of mmap */
static unsigned long do_mmap2(unsigned long addr, unsigned long len,
	unsigned long prot, unsigned long flags, unsigned long fd,
	unsigned long pgoff)
{
	struct file * file = NULL;
	unsigned long retval = -EBADF;

	if (!(flags & MAP_ANONYMOUS)) {
		file = fget(fd);
		if (!file)
			goto out;
	}

	len = PAGE_ALIGN(len);
	flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);

	down_write(&current->mm->mmap_sem);
	retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
	up_write(&current->mm->mmap_sem);

	if (file)
		fput(file);
out:
	return retval;
}

asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len,
	unsigned long prot, unsigned long flags, unsigned long fd,
	unsigned long pgoff)
{
	/* Make sure the shift for mmap2 is constant (12), no matter what PAGE_SIZE
	   we have. */
	return do_mmap2(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT - 12));
}

asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
	unsigned long prot, unsigned long flags, unsigned long fd,
	unsigned long off)
{
	return do_mmap2(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
}

long sparc_remap_file_pages(unsigned long start, unsigned long size,
			   unsigned long prot, unsigned long pgoff,
			   unsigned long flags)
{
	/* This works on an existing mmap so we don't need to validate
	 * the range as that was done at the original mmap call.
	 */
	return sys_remap_file_pages(start, size, prot,
				    (pgoff >> (PAGE_SHIFT - 12)), flags);
}

extern unsigned long do_mremap(unsigned long addr,
	unsigned long old_len, unsigned long new_len,
	unsigned long flags, unsigned long new_addr);

asmlinkage unsigned long sparc_mremap(unsigned long addr,
	unsigned long old_len, unsigned long new_len,
	unsigned long flags, unsigned long new_addr)
{
	struct vm_area_struct *vma;
	unsigned long ret = -EINVAL;
	if (ARCH_SUN4C_SUN4) {
		if (old_len > 0x20000000 || new_len > 0x20000000)
			goto out;
		if (addr < 0xe0000000 && addr + old_len > 0x20000000)
			goto out;
	}
	if (old_len > TASK_SIZE - PAGE_SIZE ||
	    new_len > TASK_SIZE - PAGE_SIZE)
		goto out;
	down_write(&current->mm->mmap_sem);
	if (flags & MREMAP_FIXED) {
		if (ARCH_SUN4C_SUN4 &&
		    new_addr < 0xe0000000 &&
		    new_addr + new_len > 0x20000000)
			goto out_sem;
		if (new_addr + new_len > TASK_SIZE - PAGE_SIZE)
			goto out_sem;
	} else if ((ARCH_SUN4C_SUN4 && addr < 0xe0000000 &&
		    addr + new_len > 0x20000000) ||
		   addr + new_len > TASK_SIZE - PAGE_SIZE) {
		unsigned long map_flags = 0;
		struct file *file = NULL;

		ret = -ENOMEM;
		if (!(flags & MREMAP_MAYMOVE))
			goto out_sem;

		vma = find_vma(current->mm, addr);
		if (vma) {
			if (vma->vm_flags & VM_SHARED)
				map_flags |= MAP_SHARED;
			file = vma->vm_file;
		}

		new_addr = get_unmapped_area(file, addr, new_len,
				     vma ? vma->vm_pgoff : 0,
				     map_flags);
		ret = new_addr;
		if (new_addr & ~PAGE_MASK)
			goto out_sem;
		flags |= MREMAP_FIXED;
	}
	ret = do_mremap(addr, old_len, new_len, flags, new_addr);
out_sem:
	up_write(&current->mm->mmap_sem);
out:
	return ret;
}

/* we come to here via sys_nis_syscall so it can setup the regs argument */
asmlinkage unsigned long
c_sys_nis_syscall (struct pt_regs *regs)
{
	static int count = 0;

	if (count++ > 5)
		return -ENOSYS;
	printk ("%s[%d]: Unimplemented SPARC system call %d\n",
		current->comm, current->pid, (int)regs->u_regs[1]);
#ifdef DEBUG_UNIMP_SYSCALL
	show_regs (regs);
#endif
	return -ENOSYS;
}

/* #define DEBUG_SPARC_BREAKPOINT */

asmlinkage void
sparc_breakpoint (struct pt_regs *regs)
{
	siginfo_t info;

	lock_kernel();
#ifdef DEBUG_SPARC_BREAKPOINT
        printk ("TRAP: Entering kernel PC=%x, nPC=%x\n", regs->pc, regs->npc);
#endif
	info.si_signo = SIGTRAP;
	info.si_errno = 0;
	info.si_code = TRAP_BRKPT;
	info.si_addr = (void __user *)regs->pc;
	info.si_trapno = 0;
	force_sig_info(SIGTRAP, &info, current);

#ifdef DEBUG_SPARC_BREAKPOINT
	printk ("TRAP: Returning to space: PC=%x nPC=%x\n", regs->pc, regs->npc);
#endif
	unlock_kernel();
}

asmlinkage int
sparc_sigaction (int sig, const struct old_sigaction __user *act,
		 struct old_sigaction __user *oact)
{
	struct k_sigaction new_ka, old_ka;
	int ret;

	if (sig < 0) {
		current->thread.new_signal = 1;
		sig = -sig;
	}

	if (act) {
		unsigned long mask;

		if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
		    __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
		    __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
			return -EFAULT;
		__get_user(new_ka.sa.sa_flags, &act->sa_flags);
		__get_user(mask, &act->sa_mask);
		siginitset(&new_ka.sa.sa_mask, mask);
		new_ka.ka_restorer = NULL;
	}

	ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);

	if (!ret && oact) {
		/* In the clone() case we could copy half consistent
		 * state to the user, however this could sleep and
		 * deadlock us if we held the signal lock on SMP.  So for
		 * now I take the easy way out and do no locking.
		 */
		if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
		    __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
		    __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
			return -EFAULT;
		__put_user(old_ka.sa.sa_flags, &oact->sa_flags);
		__put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
	}

	return ret;
}

asmlinkage long
sys_rt_sigaction(int sig,
		 const struct sigaction __user *act,
		 struct sigaction __user *oact,
		 void __user *restorer,
		 size_t sigsetsize)
{
	struct k_sigaction new_ka, old_ka;
	int ret;

	/* XXX: Don't preclude handling different sized sigset_t's.  */
	if (sigsetsize != sizeof(sigset_t))
		return -EINVAL;

	/* All tasks which use RT signals (effectively) use
	 * new style signals.
	 */
	current->thread.new_signal = 1;

	if (act) {
		new_ka.ka_restorer = restorer;
		if (copy_from_user(&new_ka.sa, act, sizeof(*act)))
			return -EFAULT;
	}

	ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);

	if (!ret && oact) {
		if (copy_to_user(oact, &old_ka.sa, sizeof(*oact)))
			return -EFAULT;
	}

	return ret;
}

asmlinkage int sys_getdomainname(char __user *name, int len)
{
 	int nlen, err;

	if (len < 0)
		return -EINVAL;

 	down_read(&uts_sem);

	nlen = strlen(utsname()->domainname) + 1;
	err = -EINVAL;
	if (nlen > len)
		goto out;

	err = -EFAULT;
	if (!copy_to_user(name, utsname()->domainname, nlen))
		err = 0;

out:
	up_read(&uts_sem);
	return err;
}

/*
 * Do a system call from kernel instead of calling sys_execve so we
 * end up with proper pt_regs.
 */
int kernel_execve(const char *filename, char *const argv[], char *const envp[])
{
	long __res;
	register long __g1 __asm__ ("g1") = __NR_execve;
	register long __o0 __asm__ ("o0") = (long)(filename);
	register long __o1 __asm__ ("o1") = (long)(argv);
	register long __o2 __asm__ ("o2") = (long)(envp);
	asm volatile ("t 0x10\n\t"
		      "bcc 1f\n\t"
		      "mov %%o0, %0\n\t"
		      "sub %%g0, %%o0, %0\n\t"
		      "1:\n\t"
		      : "=r" (__res), "=&r" (__o0)
		      : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1)
		      : "cc");
	return __res;
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.shopstyle</groupId>
  <artifactId>shopstyle-api-client</artifactId>
  <version>0.1.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.2.RELEASE</version>
    </parent>

  <name>java-popsugar-shopping-api</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	 <java.version>1.8</java.version>
  </properties>

  <repositories>
	<repository>
		<id>datanucleus-repository</id>
		<url>http://www.datanucleus.org/downloads/maven2/</url>
	</repository>
	<repository>
	  <id>clojars.org</id>
	  <url>http://clojars.org/repo</url>
	</repository>
  </repositories>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
	  <plugin>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-maven-plugin</artifactId>
	  </plugin>
    </plugins>
  </build>
  <organization>
    <name>POPSUGAR Inc.</name>
    <url>corp.popsugar.com</url>
  </organization>
  <description>Java Client for ShopStyle REST API</description>
  <dependencies>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>2.1.3</version>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>4.3.2</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.1.3</version>
    </dependency>
	<!-- https://mvnrepository.com/artifact/oracle/ojdbc6 -->
	<dependency>
		<groupId>oracle</groupId>
		<artifactId>ojdbc6</artifactId>
		<version>11.2.0.3</version>
	</dependency>

    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.4</version>
    </dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter</artifactId>
		<version>1.0.0.RELEASE</version>
		</dependency>
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-web</artifactId>
		<version>4.0.3.RELEASE</version>
	</dependency>
  </dependencies>
</project>


text:
package org.quartz.examples.example3;

import static org.quartz.CronScheduleBuilder.cronSchedule;
import static org.quartz.JobBuilder.newJob;
import static org.quartz.TriggerBuilder.newTrigger;

import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.SchedulerMetaData;
import org.quartz.impl.StdSchedulerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

/**
 * This Example will demonstrate all of the basics of scheduling capabilities of
 * Quartz using Cron Triggers.
 *
 * @author Bill Kratzer
 */
public class CronTriggerExample {

	public void run() throws Exception {
		Logger log = LoggerFactory.getLogger(CronTriggerExample.class);

		log.info("------- Initializing -------------------");

		// First we must get a reference to a scheduler
		SchedulerFactory sf = new StdSchedulerFactory();
		Scheduler sched = sf.getScheduler();

		log.info("------- Initialization Complete --------");

		log.info("------- Scheduling Jobs ----------------");

		// jobs can be scheduled before sched.start() has been called

		// job 1 will run every 20 seconds
		JobDetail job = newJob(SimpleJob.class).withIdentity("job1", "group1").build();
		// "0/20 * * * * ?" 第一位表示秒, 0/20 表示 从0秒开始,步进为20秒
		CronTrigger trigger = newTrigger().withIdentity("trigger1", "group1")
				.withSchedule(cronSchedule("0/20 * * * * ?")).build();

		Date ft = sched.scheduleJob(job, trigger);
		log.info(job.getKey() + " has been scheduled to run at: " + ft + " and repeat based on expression: "
				+ trigger.getCronExpression());

		// job 2 will run every other minute (at 15 seconds past the minute)
		job = newJob(SimpleJob.class).withIdentity("job2", "group1").build();
		// "15 0/2 * * * ?" 第一位表示秒 延时15秒, 第二位表示分 0/2 表示 从0分开始步进为2分
		trigger = newTrigger().withIdentity("trigger2", "group1").withSchedule(cronSchedule("15 0/2 * * * ?")).build();

		ft = sched.scheduleJob(job, trigger);
		log.info(job.getKey() + " has been scheduled to run at: " + ft + " and repeat based on expression: "
				+ trigger.getCronExpression());

		// job 3 will run every other minute but only between 8am and 5pm
		job = newJob(SimpleJob.class).withIdentity("job3", "group1").build();
		// "0 0/2 8-17 * * ?" 第一位表示秒 延时为0, 第二位为分 0/2 表示每2分钟延时0分钟 第三位表示小时: 8-17
		// 表示 从8am ~~ 5pm
		trigger = newTrigger().withIdentity("trigger3", "group1").withSchedule(cronSchedule("0 0/2 8-17 * * ?"))
				.build();

		ft = sched.scheduleJob(job, trigger);
		log.info(job.getKey() + " has been scheduled to run at: " + ft + " and repeat based on expression: "
				+ trigger.getCronExpression());

		// job 4 will run every three minutes but only between 5pm and 11pm
		job = newJob(SimpleJob.class).withIdentity("job4", "group1").build();
		// 0 表示0秒执行, 0/3 表示0分开始执行步进为3分, 17-23表示时间区段小时
		trigger = newTrigger().withIdentity("trigger4", "group1").withSchedule(cronSchedule("0 0/3 17-23 * * ?"))
				.build();

		ft = sched.scheduleJob(job, trigger);
		log.info(job.getKey() + " has been scheduled to run at: " + ft + " and repeat based on expression: "
				+ trigger.getCronExpression());

		// job 5 will run at 10am on the 1st and 15th days of the month
		job = newJob(SimpleJob.class).withIdentity("job5", "group1").build();

		trigger = newTrigger().withIdentity("trigger5", "group1").withSchedule(cronSchedule("0 0 10am 1,15 * ?"))
				.build();

		ft = sched.scheduleJob(job, trigger);
		log.info(job.getKey() + " has been scheduled to run at: " + ft + " and repeat based on expression: "
				+ trigger.getCronExpression());

		// job 6 will run every 30 seconds but only on Weekdays (Monday through
		// Friday)
		job = newJob(SimpleJob.class).withIdentity("job6", "group1").build();

		trigger = newTrigger().withIdentity("trigger6", "group1").withSchedule(cronSchedule("0,30 * * ? * MON-FRI"))
				.build();

		ft = sched.scheduleJob(job, trigger);
		log.info(job.getKey() + " has been scheduled to run at: " + ft + " and repeat based on expression: "
				+ trigger.getCronExpression());

		// job 7 will run every 30 seconds but only on Weekends (Saturday and
		// Sunday)
		job = newJob(SimpleJob.class).withIdentity("job7", "group1").build();

		trigger = newTrigger().withIdentity("trigger7", "group1").withSchedule(cronSchedule("0,30 * * ? * SAT,SUN"))
				.build();

		ft = sched.scheduleJob(job, trigger);
		log.info(job.getKey() + " has been scheduled to run at: " + ft + " and repeat based on expression: "
				+ trigger.getCronExpression());

		// job 8 will run every three seconds but only between 11am and 1pm or
		// between 5pm and 11pm
		job = newJob(SimpleJob.class).withIdentity("job8", "group1").build();

		trigger = newTrigger().withIdentity("trigger8", "group1").withSchedule(cronSchedule("0/3 * 12-14,15-17 * * ?"))
				.build();

		ft = sched.scheduleJob(job, trigger);
		log.info(job.getKey() + " has been scheduled to run at: " + ft + " and repeat based on expression: "
				+ trigger.getCronExpression());

		log.info("------- Starting Scheduler ----------------");

		// All of the jobs have been added to the scheduler, but none of the
		// jobs
		// will run until the scheduler has been started
		sched.start();

		log.info("------- Started Scheduler -----------------");

		log.info("------- Waiting five minutes... ------------");
		try {
			// wait five minutes to show jobs
			Thread.sleep(600L * 1000L);
			// executing...
		} catch (Exception e) {
			//
		}

		log.info("------- Shutting Down ---------------------");

		sched.shutdown(true);

		log.info("------- Shutdown Complete -----------------");

		SchedulerMetaData metaData = sched.getMetaData();
		log.info("Executed " + metaData.getNumberOfJobsExecuted() + " jobs.");

	}

	public static void main(String[] args) throws Exception {

		CronTriggerExample example = new CronTriggerExample();
		example.run();
	}

}


text:
package org.jets3t.service.security;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Serializable;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;

import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jets3t.service.Constants;
import org.jets3t.service.S3ServiceException;
import org.jets3t.service.utils.ServiceUtils;

/**
 * Class to contain the Amazon Web Services (AWS) credentials of a user. This class also includes
 * utility methods to store credentials to password-encrypted files, and retrieve credentials from
 * these files.
 *
 * @author James Murty
 */
public class AWSCredentials implements Serializable {
    private static final long serialVersionUID = -9198887548912640773L;

    private static final Log log = LogFactory.getLog(AWSCredentials.class);

    protected static final String KEYS_DELIMITER = "AWSKEYS";
    protected static final String VERSION_PREFIX = "jets3t AWS Credentials, version: ";

    private String awsAccessKey = null;
    private String awsSecretAccessKey = null;
    private String friendlyName = null;

    /**
     * Construct credentials.
     *
     * @param awsAccessKey
     * AWS access key for an Amazon S3 account.
     * @param awsSecretAccessKey
     * AWS secret key for an Amazon S3 acount.
     */
    public AWSCredentials(String awsAccessKey, String awsSecretAccessKey) {
        this.awsAccessKey = awsAccessKey;
        this.awsSecretAccessKey = awsSecretAccessKey;
    }

    /**
     * Construct credentials, and associate them with a human-friendly name.
     *
     * @param awsAccessKey
     * AWS access key for an Amazon S3 account.
     * @param awsSecretAccessKey
     * AWS secret key for an Amazon S3 acount.
     * @param friendlyName
     * a name identifying the owner of the credentials, such as 'James'.
     */
    public AWSCredentials(String awsAccessKey, String awsSecretAccessKey, String friendlyName) {
        this(awsAccessKey, awsSecretAccessKey);
        this.friendlyName = friendlyName;
    }

    /**
     * @return
     * the AWS Access Key.
     */
    public String getAccessKey() {
        return awsAccessKey;
    }

    /**
     * @return
     * the AWS Secret Key.
     */
    public String getSecretKey() {
        return awsSecretAccessKey;
    }

    /**
     * @return
     * the friendly name associated with an AWS account, if available.
     */
    public String getFriendlyName() {
        return friendlyName;
    }

    /**
     * Encrypts AWS Credentials with the given password and saves the encrypted data to a file.
     *
     * @param password
     * the password used to encrypt the credentials.
     * @param file
     * the file to write the encrypted credentials data to.
     *
     * @throws InvalidKeyException
     * @throws NoSuchAlgorithmException
     * @throws NoSuchPaddingException
     * @throws InvalidKeySpecException
     * @throws IllegalStateException
     * @throws IllegalBlockSizeException
     * @throws BadPaddingException
     * @throws InvalidAlgorithmParameterException
     * @throws IOException
     */
    public void save(String password, File file) throws InvalidKeyException,
        NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException,
        IllegalStateException, IllegalBlockSizeException, BadPaddingException,
        InvalidAlgorithmParameterException, IOException
    {
        FileOutputStream fos = new FileOutputStream(file);
        save(password, fos);
        fos.close();
    }

    /**
     * Encrypts AWS Credentials with the given password and writes the encrypted data to an
     * output stream.
     *
     * @param password
     * the password used to encrypt the credentials.
     * @param outputStream
     * the output stream to write the encrypted credentials data to, this stream must be closed by
     * the caller.
     *
     * @throws InvalidKeyException
     * @throws NoSuchAlgorithmException
     * @throws NoSuchPaddingException
     * @throws InvalidKeySpecException
     * @throws IllegalStateException
     * @throws IllegalBlockSizeException
     * @throws BadPaddingException
     * @throws InvalidAlgorithmParameterException
     * @throws IOException
     */
    public void save(String password, OutputStream outputStream) throws InvalidKeyException,
        NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException,
        IllegalStateException, IllegalBlockSizeException, BadPaddingException,
        InvalidAlgorithmParameterException, IOException
    {
        BufferedOutputStream bufferedOS = null;
        EncryptionUtil encryptionUtil = new EncryptionUtil(password);
        bufferedOS = new BufferedOutputStream(outputStream);

        // Encrypt AWS credentials
        String dataToEncrypt = getAccessKey() + KEYS_DELIMITER + getSecretKey();
        byte[] encryptedData = encryptionUtil.encrypt(dataToEncrypt);

        // Write plain-text header information to file.
        bufferedOS.write((VERSION_PREFIX + EncryptionUtil.DEFAULT_VERSION + "\n").getBytes(Constants.DEFAULT_ENCODING));
        bufferedOS.write((encryptionUtil.getAlgorithm() + "\n").getBytes(Constants.DEFAULT_ENCODING));
        bufferedOS.write(((friendlyName == null? "" : friendlyName) + "\n").getBytes(Constants.DEFAULT_ENCODING));

        bufferedOS.write(encryptedData);
        bufferedOS.flush();
    }

    /**
     * Loads encrypted credentials from a file.
     *
     * @param password
     * the password used to decrypt the credentials. If null, the AWS Credentials are not decrypted
     * and only the version and friendly-name information is loaded.
     * @param file
     * a file containing an encrypted data encoding of an AWSCredentials object.
     * @return
     * the decrypted credentials in an object.
     *
     * @throws S3ServiceException
     */
    public static AWSCredentials load(String password, File file) throws S3ServiceException {
    	if (log.isDebugEnabled()) {
    		log.debug("Loading credentials from file: " + file.getAbsolutePath());
    	}
        BufferedInputStream fileIS = null;
        try {
            fileIS = new BufferedInputStream(new FileInputStream(file));
            return load(password, fileIS);
        } catch (Throwable t) {
            throw new S3ServiceException("Failed to load AWS credentials", t);
        } finally {
            if (fileIS != null) {
                try {
                    fileIS.close();
                } catch (IOException e) {
                }
            }
        }
    }

    /**
     * Loads encrypted credentials from a data input stream.
     *
     * @param password
     * the password used to decrypt the credentials. If null, the AWS Credentials are not decrypted
     * and only the version and friendly-name information is loaded.
     * @param inputStream
     * an input stream containing an encrypted  data encoding of an AWSCredentials object.
     * @return
     * the decrypted credentials in an object.
     *
     * @throws S3ServiceException
     */
    public static AWSCredentials load(String password, BufferedInputStream inputStream) throws S3ServiceException {
        boolean partialReadOnly = (password == null);
        if (partialReadOnly) {
        	if (log.isDebugEnabled()) {
        		log.debug("Loading partial information about AWS Credentials from input stream");
        	}
        } else {
        	if (log.isDebugEnabled()) {
        		log.debug("Loading AWS Credentials from input stream");
        	}
        }

        try {
            EncryptionUtil encryptionUtil = null;
            byte[] encryptedKeys = new byte[2048];
            int encryptedDataIndex = 0;

            String version = null;
            String algorithm = null;
            String friendlyName = null;

            // Read version information from AWS credentials file.
            version = ServiceUtils.readInputStreamLineToString(inputStream, Constants.DEFAULT_ENCODING);

            if (!version.startsWith(VERSION_PREFIX)) {
                // Either this is not a valid AWS Credentials file, or it's an obsolete version.
                // Try decrypting using the obsolete approach.
                friendlyName = version;

                if (!partialReadOnly) {
                    encryptionUtil = EncryptionUtil.getObsoleteEncryptionUtil(password);
                }
            } else {
                // Read algorithm and friendly name from file.
                algorithm = ServiceUtils.readInputStreamLineToString(inputStream, Constants.DEFAULT_ENCODING);
                friendlyName = ServiceUtils.readInputStreamLineToString(inputStream, Constants.DEFAULT_ENCODING);

                if (!partialReadOnly) {
                    encryptionUtil = new EncryptionUtil(password, algorithm, EncryptionUtil.DEFAULT_VERSION);
                }
            }

            if (partialReadOnly) {
                return new AWSCredentials(null, null, friendlyName);
            }

            // Read encrypted data bytes from file.
            encryptedDataIndex = inputStream.read(encryptedKeys);

            // Decrypt data.
            String keys = encryptionUtil.decryptString(encryptedKeys, 0, encryptedDataIndex);

            int delimOffset = keys.indexOf(KEYS_DELIMITER);
            if (delimOffset < 0) {
                throw new Exception("Unable to load AWS keys. Is the password correct?");
            }

            AWSCredentials awsCredentials = new AWSCredentials(keys.substring(0, delimOffset), keys
                .substring(delimOffset + KEYS_DELIMITER.length()), friendlyName);

            return awsCredentials;
        } catch (BadPaddingException bpe) {
            throw new S3ServiceException("Unable to decrypt AWS credentials. Is your password correct?", bpe);
        } catch (Throwable t) {
            throw new S3ServiceException("Failed to load AWS credentials", t);
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                }
            }
        }
    }

    /**
     * Console utility to store AWS credentials information in an encrypted file in the toolkit's
     * default preferences directory.
     *

     * This class can be run from the command line as:
     *

     * java org.jets3t.service.security.AWSCredentials <friendlyName> <credentialsFilename>
     *

     * When run it will prompt for the user's AWS access key,secret key and encryption password.
     * It will then encode into the specified credentials file.
     *
     * @param args
     */
    public static void main(String[] args) throws Exception {
        if (args.length != 2) {
            printHelp();
            System.exit(1);
        }
        String userName = args[0];
        File encryptedFile = new File(args[1]);

        // Check arguments provided.
        try {
            FileOutputStream testFOS = new FileOutputStream(encryptedFile);
            testFOS.close();
        } catch (IOException e) {
            System.err.println("Unable to write to file: " + encryptedFile);
        }

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        // Obtain credentials and password from user.
        System.out.println("Please enter your AWS Credentials");
        System.out.print("Access Key: ");
        String awsAccessKey = reader.readLine();
        System.out.print("Secret Key: ");
        String awsSecretKey = reader.readLine();
        System.out
            .println("Please enter a password to protect your credentials file (may be empty)");
        System.out.print("Password: ");
        String password = reader.readLine();

        // Create AWSCredentials object and save the details to an encrypted file.
        AWSCredentials awsCredentials = new AWSCredentials(awsAccessKey, awsSecretKey, userName);
        awsCredentials.save(password, encryptedFile);

        System.out.println("Successfully saved AWS Credentials to " + encryptedFile);
    }

    /**
     * Prints help for the use of this class from the console (via the main method).
     */
    private static void printHelp() {
        System.out.println("AWSCredentials <User Name> <File Path>");
        System.out.println();
        System.out
            .println("User Name: A human-friendly name for the owner of the credentials, e.g. Horace.");
        System.out
            .println("File Path: Path and name for the encrypted file. Will be replaced if it already exists.");
    }

}


text:
package demo.components

import chandu0101.macros.tojs.GhPagesMacros
import chandu0101.scalajs.react.components.ReactInfinite
import japgolly.scalajs.react._
import japgolly.scalajs.react.vdom.prefix_<^._

import scalacss.Defaults._
import scalacss.ScalaCssReact._

object ReactInfiniteDemo {

  object styles extends StyleSheet.Inline {

    import dsl._

    val container = style(display.flex,
      justifyContent.center,
      alignItems.center,
      width(65 %%))

    val item = style(
      width(300 px),
      textAlign.center,
      height(70 px),
      padding(20 px)
    )
    val border = style(borderBottom :=! "2px solid rgba(0, 0, 0, 0.1)",
      marginLeft(4 px))
  }

  val code = GhPagesMacros.exampleSource

  // EXAMPLE:START

  case class State(isLoading: Boolean = true, data: Vector[String] = Vector())

  class Backend(t: BackendScope[_, State]) {

    def renderRow(s: String): ReactElement = {
      <.div(styles.item, s, ^.key := s,
        <.div(styles.border)
      )
    }

    def loadData() = {
      val data = (1 to 500).toVector.map(i => s"List Item $i")
      t.modState(_.copy(isLoading = false, data = data))
    }
    def render(S: State) = {
      <.div(
        CodeExample(code, "Demo")(
          <.div(styles.container,
            if (S.isLoading) <.div("Loading ..")
            else ReactInfinite(elementHeight = 70,
              containerHeight = 400)(S.data.map(renderRow))
          )
        )
      )
    }
  }

  val component = ReactComponentB[Unit]("ReactSelectDemo")
    .initialState(State())
    .renderBackend[Backend]
    .componentDidMount(scope => scope.backend.loadData())
    .buildU

  // EXAMPLE:END

  def apply() = component()

}


text:
using namespace node_sqlite3;

namespace {

void RegisterModule(v8::Handle<Object> target) {
    NanScope();
    Database::Init(target);
    Statement::Init(target);

    DEFINE_CONSTANT_INTEGER(target, SQLITE_OPEN_READONLY, OPEN_READONLY);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_OPEN_READWRITE, OPEN_READWRITE);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_OPEN_CREATE, OPEN_CREATE);
    DEFINE_CONSTANT_STRING(target, SQLITE_VERSION, VERSION);
#ifdef SQLITE_SOURCE_ID
    DEFINE_CONSTANT_STRING(target, SQLITE_SOURCE_ID, SOURCE_ID);
#endif
    DEFINE_CONSTANT_INTEGER(target, SQLITE_VERSION_NUMBER, VERSION_NUMBER);

    DEFINE_CONSTANT_INTEGER(target, SQLITE_OK, OK);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_ERROR, ERROR);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_INTERNAL, INTERNAL);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_PERM, PERM);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_ABORT, ABORT);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_BUSY, BUSY);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_LOCKED, LOCKED);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_NOMEM, NOMEM);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_READONLY, READONLY);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_INTERRUPT, INTERRUPT);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_IOERR, IOERR);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_CORRUPT, CORRUPT);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_NOTFOUND, NOTFOUND);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_FULL, FULL);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_CANTOPEN, CANTOPEN);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_PROTOCOL, PROTOCOL);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_EMPTY, EMPTY);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_SCHEMA, SCHEMA);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_TOOBIG, TOOBIG);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_CONSTRAINT, CONSTRAINT);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_MISMATCH, MISMATCH);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_MISUSE, MISUSE);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_NOLFS, NOLFS);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_AUTH, AUTH);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_FORMAT, FORMAT);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_RANGE, RANGE);
    DEFINE_CONSTANT_INTEGER(target, SQLITE_NOTADB, NOTADB);
}

}

const char* sqlite_code_string(int code) {
    switch (code) {
        case SQLITE_OK:         return "SQLITE_OK";
        case SQLITE_ERROR:      return "SQLITE_ERROR";
        case SQLITE_INTERNAL:   return "SQLITE_INTERNAL";
        case SQLITE_PERM:       return "SQLITE_PERM";
        case SQLITE_ABORT:      return "SQLITE_ABORT";
        case SQLITE_BUSY:       return "SQLITE_BUSY";
        case SQLITE_LOCKED:     return "SQLITE_LOCKED";
        case SQLITE_NOMEM:      return "SQLITE_NOMEM";
        case SQLITE_READONLY:   return "SQLITE_READONLY";
        case SQLITE_INTERRUPT:  return "SQLITE_INTERRUPT";
        case SQLITE_IOERR:      return "SQLITE_IOERR";
        case SQLITE_CORRUPT:    return "SQLITE_CORRUPT";
        case SQLITE_NOTFOUND:   return "SQLITE_NOTFOUND";
        case SQLITE_FULL:       return "SQLITE_FULL";
        case SQLITE_CANTOPEN:   return "SQLITE_CANTOPEN";
        case SQLITE_PROTOCOL:   return "SQLITE_PROTOCOL";
        case SQLITE_EMPTY:      return "SQLITE_EMPTY";
        case SQLITE_SCHEMA:     return "SQLITE_SCHEMA";
        case SQLITE_TOOBIG:     return "SQLITE_TOOBIG";
        case SQLITE_CONSTRAINT: return "SQLITE_CONSTRAINT";
        case SQLITE_MISMATCH:   return "SQLITE_MISMATCH";
        case SQLITE_MISUSE:     return "SQLITE_MISUSE";
        case SQLITE_NOLFS:      return "SQLITE_NOLFS";
        case SQLITE_AUTH:       return "SQLITE_AUTH";
        case SQLITE_FORMAT:     return "SQLITE_FORMAT";
        case SQLITE_RANGE:      return "SQLITE_RANGE";
        case SQLITE_NOTADB:     return "SQLITE_NOTADB";
        case SQLITE_ROW:        return "SQLITE_ROW";
        case SQLITE_DONE:       return "SQLITE_DONE";
        default:                return "UNKNOWN";
    }
}

const char* sqlite_authorizer_string(int type) {
    switch (type) {
        case SQLITE_INSERT:     return "insert";
        case SQLITE_UPDATE:     return "update";
        case SQLITE_DELETE:     return "delete";
        default:                return "";
    }
}

NODE_MODULE(node_sqlite3, RegisterModule)


text:
package charge

import (
	"context"
	"testing"

	model "go-common/app/job/main/growup/model/charge"

	. "github.com/smartystreets/goconvey/convey"
)

func Test_GetAvChargeStatisMap(t *testing.T) {
	Convey("GetAvChargeStatisMap", t, func() {
		_, err := s.GetAvChargeStatisMap(context.Background())
		So(err, ShouldBeNil)
	})
}

func Test_GetAvChargeStatis(t *testing.T) {
	Convey("GetAvChargeStatis", t, func() {
		_, err := s.GetAvChargeStatis(context.Background())
		So(err, ShouldBeNil)
	})
}

func Test_AvChargeStatisDBStore(t *testing.T) {
	Convey("AvChargeStatisDBStore", t, func() {
		chargeStatisMap := make(map[int64]*model.AvChargeStatis)
		value := &model.AvChargeStatis{
			AvID:    11,
			MID:     11,
			TagID:   11,
			DBState: 1,
		}
		chargeStatisMap[11] = value
		err := s.AvChargeStatisDBStore(context.Background(), chargeStatisMap)
		So(err, ShouldBeNil)
	})
}


text:
package archimulator.uncore.coherence.msi.flow;

import archimulator.isa.Memory;
import archimulator.uncore.MemoryHierarchyAccess;
import archimulator.uncore.coherence.msi.controller.Controller;
import archimulator.util.Params;
import archimulator.util.collection.tree.Node;

import java.util.ArrayList;
import java.util.List;

/**
 * Cache coherence flow.
 *
 * @author Min Cai
 */
public abstract class CacheCoherenceFlow extends Params implements Node {
    private long id;
    private Controller generator;
    private CacheCoherenceFlow producerFlow;
    private CacheCoherenceFlow ancestorFlow;
    private List<CacheCoherenceFlow> childFlows;
    private int numPendingDescendantFlows;
    private long beginCycle;
    private long endCycle;
    private boolean completed;
    private MemoryHierarchyAccess access;
    private int tag;

    /**
     * Create a cache coherence flow.
     *
     * @param generator    the generator controller
     * @param producerFlow the producer cache coherence flow
     * @param access       the memory hierarchy access
     * @param tag          the tag
     */
    public CacheCoherenceFlow(Controller generator, CacheCoherenceFlow producerFlow, MemoryHierarchyAccess access, int tag) {
        this.id = generator.getSimulation().currentCacheCoherenceFlowId++;
        this.generator = generator;
        this.producerFlow = producerFlow;
        this.ancestorFlow = producerFlow == null ? this : producerFlow.ancestorFlow;
        this.childFlows = new ArrayList<>();
        this.access = access;
        this.tag = tag;

        this.onCreate();
    }

    /**
     * Act on when the cache coherence flow begins.
     */
    private void onCreate() {
        this.beginCycle = this.generator.getCycleAccurateEventQueue().getCurrentCycle();
        if (this.producerFlow == null) {
            this.generator.getSimulation().pendingFlows.add(this);
        } else {
            this.producerFlow.childFlows.add(this);
        }
        this.ancestorFlow.numPendingDescendantFlows++;
    }

    /**
     * Act on when the cache coherence flow is completed.
     */
    public void onCompleted() {
        this.completed = true;
        this.endCycle = this.generator.getCycleAccurateEventQueue().getCurrentCycle();
        this.ancestorFlow.numPendingDescendantFlows--;

        if (this.ancestorFlow.numPendingDescendantFlows == 0) {
            this.generator.getSimulation().pendingFlows.remove(this.ancestorFlow);
        }
    }

    /**
     * Get the ID of the cache coherence flow.
     *
     * @return the ID of the cache coherence flow
     */
    public long getId() {
        return id;
    }

    /**
     * Get the ancestor cache coherence flow.
     *
     * @return the ancestor cache coherence flow
     */
    public CacheCoherenceFlow getAncestorFlow() {
        return ancestorFlow;
    }

    /**
     * Get the producer cache coherence flow.
     *
     * @return the producer cache coherence flow
     */
    public CacheCoherenceFlow getProducerFlow() {
        return producerFlow;
    }

    /**
     * Get the list of child flows.
     *
     * @return the list of child flows
     */
    public List<CacheCoherenceFlow> getChildFlows() {
        return childFlows;
    }

    /**
     * Get the cycle when the cache coherence flow begins.
     *
     * @return the cycle when the cache coherence flow begins
     */
    public long getBeginCycle() {
        return beginCycle;
    }

    /**
     * Get the cycle when the cache coherence flow is completed (ended).
     *
     * @return the cycle when the cache coherence flow is completed (ended)
     */
    public long getEndCycle() {
        return endCycle;
    }

    /**
     * Get the generator controller.
     *
     * @return the generator controller
     */
    public Controller getGenerator() {
        return generator;
    }

    /**
     * Get a value indicating whether the cache coherence flow is completed or not.
     *
     * @return a value indicating whether the cache coherence flow is completed or not
     */
    public boolean isCompleted() {
        return completed;
    }

    /**
     * Get the memory hierarchy access.
     *
     * @return the memory hierarchy access
     */
    public MemoryHierarchyAccess getAccess() {
        return access;
    }

    /**
     * Get the node value.
     *
     * @return the node value
     */
    @Override
    public Object getValue() {
        return String.format("%s%s", this, this.completed ? " -> completed at " + endCycle : "");
    }

    /**
     * Get the list of child flows.
     *
     * @return the list of child flows
     */
    @Override
    public List<CacheCoherenceFlow> getChildren() {
        return this.childFlows;
    }

    /**
     * Get the tag.
     *
     * @return the tag
     */
    public int getTag() {
        return tag;
    }

    /**
     * Get the data if meaningful.
     *
     * @return the data if meaningful
     */
    public byte[] getData() {
        Memory memory = this.getAccess().getThread().getContext().getProcess().getMemory();
        int lineSize = this.getAccess().getThread().getExperiment().getL1DLineSize();
        return memory.readBlock(this.getTag(), lineSize / 4);
    }
}


text:
using System.Web.Mvc;

namespace ASF.UI.WbSite.Areas.Categories
{
    public class CategoriesAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "Categories";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Categories_default",
                "Categories/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}


text:
<?php
// Routes for DepartmentsController
Route::group(['prefix' => 'departments', 'before' => 'auth'], function()
{
	Route::get('showDepartments', [
		'as' => 'showDepartments_path',
		'uses' => 'DepartmentsController@index'
		]);

	Route::get('{department}/editDepartmentInformation', [
		'as' => 'editDepartmentInformation_path',
		'uses' => 'DepartmentsController@edit'
		]);

	Route::delete('{department}/deleteDepartment', [
		'as' => 'deleteDepartment_path',
		'uses' => 'DepartmentsController@destroy'
		]);

	Route::patch('{department}/updateDepartment', [
		'as' => 'updateDepartment_path',
		'uses' => 'DepartmentsController@update'
		]);

	Route::post('saveDepartment', [
		'as' => 'saveDepartment_path',
		'uses' => 'DepartmentsController@store'
		]);
});


text:
package com.linkedin.pinot.common.utils.retry;

import java.util.concurrent.Callable;

/**
 * Retry policy, encapsulating the logic needed to retry an operation until it succeeds.
 */
public interface RetryPolicy {

  /**
   * Attempts to do the operation until it succeeds, aborting if an exception is thrown by the operation or number of
   * attempts exhausted.
   *
   * @param operation The operation to attempt, which returns true on success and false on failure.
   * @throws AttemptsExceededException
   * @throws RetriableOperationException
   */
  void attempt(Callable<Boolean> operation) throws AttemptsExceededException, RetriableOperationException;
}


text:
all: gen

CV: content/media/pdfs/CV.pdf

content/media/pdfs/CV.pdf: CV/CV.tex
	cd CV; make
	mkdir -p content/media/pdfs/
	cp CV/CV.pdf content/media/pdfs/

gen: #CV
	hyde gen

serve: clean gen
	hyde serve

clean:
	rm -rf deploy deploy_production

gen-production: clean
	hyde gen -c production.yaml

publish: gen-production	#CV
	rsync -e ssh -r deploy_production/ jhummel@astro.as.utexas.edu:www/


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

namespace Sharpen
{
    using System;
    using System.Collections.Generic;

    internal class ListIterator<T>
    {
        private IList<T> list;
        private int pos;

        public ListIterator (IList<T> list, int n)
        {
            this.list = list;
            this.pos = n;
        }

        public bool HasPrevious ()
        {
            return (this.pos > 0);
        }

        public T Previous ()
        {
            pos--;
            return list[pos];
        }
    }
}


text:
import { Reducer } from 'redux';
import { ActionType, getType } from 'typesafe-actions';
import * as actions from './actions';
import { ClarityDescription } from './descriptions/descriptionInterface';

export type ClarityAction = ActionType<typeof actions>;

export interface ClarityState {
  /**
   * Descriptions from community provided by Clarity API
   */
  descriptions?: ClarityDescription;
  // I will add more things i need for clarity later on
}

const initialState: ClarityState = {};
export const clarity: Reducer<ClarityState, ClarityAction> = (
  state: ClarityState = initialState,
  action: ClarityAction
) => {
  switch (action.type) {
    case getType(actions.loadDescriptions):
      return {
        ...state,
        descriptions: action.payload,
      };
    default:
      return state;
  }
};


text:
"""Generate TSV of the languages supported by Google."""

from __future__ import print_function, absolute_import

from HTMLParser import HTMLParser

from common import datapath, httpget, Lang, print_lang

# Google's preferences pages
url = 'https://www.google.com/preferences'
cachepath = datapath('Google Prefs.html')

def html():
    return httpget(url, cachepath).decode('ISO-8859-1')

def parse_page(html):
    """Parse language id-name pairs from HTML.

    Args:
        html (unicode): Google's preferences page.

    Returns:
        list: Sequence of 2-tuples: `(id, name)`.
    """
    langs = []
    parser = HTMLParser()

    while True:
        i = html.find('<option value=')
        if i < 0:
            break
        html = html[i+len('<option value='):]
        i = html.find('>')
        key = html[:i]
        if key.endswith(' selected'):
            key = key[:-len(' selected')]
        html = html[i+1:]
        i = html.find(' <')
        name = parser.unescape(html[:i])
        html = html[i+1:]
        if key.startswith('xx-'):  # Novelty language, like xx-bork
            continue
        if key[0] not in 'abcdefghijklmnopqrstuvwxyz':
            continue

        langs.append(Lang(key, name))

    return langs

def main():
    """Parse and print languages from Google's preferences page."""
    langs = parse_page(html())
    langs.sort()
    for l in langs:
        print_lang(l)

if __name__ == '__main__':
    main()


text:
package org.wte4j.ui.auth.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * Entry point classes define onModuleLoad().
 */
public class Wte4jAuth implements EntryPoint {

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {

		LoginPage loginPage = new LoginPage();

		RootPanel root= RootPanel.get();
		root.add(loginPage);

		loginPage.show();

	}
}


text:
<!DOCTYPE html>

	<meta name="viewport" content="width=device-width" />
    <meta charset="utf-8">
    <base href="https://wordbit.com">
    <title> Toponym of the day </title>
    <link rel="canonical" href="https://wordbit.com/posts/toponym-of-the-day-2/">

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

<link rel="stylesheet" href="/css/lanyon.css">
<link rel="stylesheet" href="/css/custom.css">

<input type="checkbox" class="sidebar-checkbox" id="sidebar-checkbox"
       xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">

    Home
    All Blog Posts
    Status Updates
    About

      © 2021. All rights reserved.

      wordbit

Toponym of the day

 Fri Dec 15, 2006

I'm currently writing a TOEFL textbook for Transglobal Prep school for some extra cash. Ironically I'll be using the money I make to buy more overpriced textbooks for next semester in Print Futures (It's going to be an awesome semester, I'm especially looking forward to the tech writing and document design courses).

Anyway, I've been hashing away at this 500 page book due next week and came up with some insights. First of all, let me give you some of the unobvious pros and cons of freelancing:

Pros:

You can write all day in your pajamas

You never have to shave any part of your body…ever

You can take as many showers as you want

There is no commute

You can sleep in

Cons:

There's no gossiping around the watercooler

You have to be so self disciplined that…

you'll realize that you're the worst boss you've ever had

If you like leaving the house now and again you're out of luck

When you're done for the day you can't leave

One slightly interesting thing I discovered while researching the civil war, the American revolution and the tourist attractions of Illinois and Kentucky (don't ask) was…toponymy. If you don't know what that is, go to Wikipedia. Also on the Wiki, here is a real example (WARNING: offensive language) of an unusual place name.

I thought I'd start a toponym of the day, where I present the origins of a placename that I've come across in my research. Geeky, but what else can I do with all the useless facts that I'm learning?

So, without further ado, today's placename is…

Winnipeg:

Winnipeg, in Canada, owes its name to the Algonquins. Winnipig was the Algonquin word meaning dirty water, a possible non tribute to the Red River, which flows near Winnipeg (Source: Turnip Smith).

I checked this out, and according to the official Winnipeg website, "the name WINNIPEG has its origin in the Indian Cree name given to the lake 64kms north, meaning "Win", muddy, "nipee", water".

Either way, Winnipeg means dirty water. Sorry guys.

      « Previous: Longest place name in the world

    Next:    With thunder in his voice »