text:
package vexriscv

import java.io.File

import org.scalatest.funsuite.AnyFunSuite
import spinal.core.SpinalVerilog
import vexriscv.demo._

import scala.sys.process._

class DhrystoneBench extends AnyFunSuite {
  def doCmd(cmd: String): String = {
    val stdOut = new StringBuilder()
    class Logger extends ProcessLogger {
      override def err(s: => String): Unit = {
        if (!s.startsWith("ar: creating ")) println(s)
      }

      override def out(s: => String): Unit = {
        println(s)
        stdOut ++= s
      }

      override def buffer[T](f: => T) = f
    }
    Process(cmd, new File("src/test/cpp/regression")).!(new Logger)
    stdOut.toString()
  }

  val report = new StringBuilder()

  def getDmips(name: String, gen: => Unit, testCmd: String): Unit = {
    var genPassed = false
    test(name + "_gen") {
      gen
      genPassed = true
    }
    test(name + "_test") {
      assert(genPassed)
      val str = doCmd(testCmd)
      assert(!str.contains("FAIL"))
      val intFind = "(\\d+\\.?)+".r
      val dmips = intFind.findFirstIn("DMIPS per Mhz\\:                              (\\d+.?)+".r.findAllIn(str).toList.last).get.toDouble
      val coremarkTicks = intFind.findFirstIn("Total ticks      \\: (\\d+.?)+".r.findAllIn(str).toList.last).get.toDouble
      val coremarkIterations = intFind.findFirstIn("Iterations       \\: (\\d+.?)+".r.findAllIn(str).toList.last).get.toDouble
      val coremarkHzs = intFind.findFirstIn("DCLOCKS_PER_SEC=(\\d+.?)+".r.findAllIn(str).toList.last).get.toDouble
      val coremarkPerMhz = 1e6 * coremarkIterations / coremarkTicks
      report ++= s"$name -> $dmips DMIPS/Mhz $coremarkPerMhz Coremark/Mhz\n"
    }

  }

  for(withMemoryStage <- List(false, true)){
    val stages = if(withMemoryStage) "Three" else "Two"
    getDmips(
      name = s"Gen${stages}StageArty",
      gen = SpinalVerilog(GenTwoThreeStage.cpu(
        withMulDiv = false,
        bypass = false,
        barrielShifter = false,
        withMemoryStage = withMemoryStage
      )),
      testCmd = "make clean run REDO=10 IBUS=SIMPLE DBUS=SIMPLE CSR=no MMU=no DEBUG_PLUGIN=no MUL=no DIV=no  COREMARK=yes"
    )
    getDmips(
      name = s"Gen${stages}StageBarrielArty",
      gen = SpinalVerilog(GenTwoThreeStage.cpu(
        withMulDiv = false,
        bypass = true,
        barrielShifter = true,
        withMemoryStage = withMemoryStage
      )),
      testCmd = "make clean run REDO=10 IBUS=SIMPLE DBUS=SIMPLE CSR=no MMU=no DEBUG_PLUGIN=no MUL=no DIV=no  COREMARK=yes"
    )
    getDmips(
      name = s"Gen${stages}StageMDArty",
      gen = SpinalVerilog(GenTwoThreeStage.cpu(
        withMulDiv = true,
        bypass = false,
        barrielShifter = false,
        withMemoryStage = withMemoryStage
      )),
      testCmd = "make clean run REDO=10 IBUS=SIMPLE DBUS=SIMPLE CSR=no MMU=no DEBUG_PLUGIN=no MUL=yes DIV=yes  COREMARK=yes"
    )
    getDmips(
      name = s"Gen${stages}StageMDBarrielArty",
      gen = SpinalVerilog(GenTwoThreeStage.cpu(
        withMulDiv = true,
        bypass = true,
        barrielShifter = true,
        withMemoryStage = withMemoryStage
      )),
      testCmd = "make clean run REDO=10 IBUS=SIMPLE DBUS=SIMPLE CSR=no MMU=no DEBUG_PLUGIN=no MUL=yes DIV=yes  COREMARK=yes"
    )
  }

  getDmips(
    name = "GenSmallestNoCsr",
    gen = GenSmallestNoCsr.main(null),
    testCmd = "make clean run REDO=10 IBUS=SIMPLE DBUS=SIMPLE CSR=no MMU=no DEBUG_PLUGIN=no MUL=no DIV=no  COREMARK=yes"
  )

  getDmips(
    name = "GenSmallest",
    gen = GenSmallest.main(null),
    testCmd = "make clean run REDO=10 IBUS=SIMPLE DBUS=SIMPLE CSR=no MMU=no DEBUG_PLUGIN=no MUL=no DIV=no  COREMARK=yes"
  )

  getDmips(
    name = "GenSmallAndProductive",
    gen = GenSmallAndProductive.main(null),
    testCmd = "make clean run REDO=10 IBUS=SIMPLE DBUS=SIMPLE CSR=no MMU=no DEBUG_PLUGIN=no MUL=no DIV=no  COREMARK=yes"
  )

  getDmips(
    name = "GenSmallAndProductiveWithICache",
    gen = GenSmallAndProductiveICache.main(null),
    testCmd = "make clean run REDO=10 IBUS=CACHED DBUS=SIMPLE CSR=no MMU=no DEBUG_PLUGIN=no MUL=no DIV=no  COREMARK=yes"
  )

  getDmips(
    name = "GenFullNoMmuNoCache",
    gen = GenFullNoMmuNoCache.main(null),
    testCmd = "make clean run REDO=10 IBUS=SIMPLE DBUS=SIMPLE CSR=no MMU=no  COREMARK=yes"
  )

  getDmips(
    name = "GenNoCacheNoMmuMaxPerf",
    gen = GenNoCacheNoMmuMaxPerf.main(null),
    testCmd = "make clean run REDO=10 MMU=no CSR=no DBUS=SIMPLE IBUS=SIMPLE  COREMARK=yes"
  )

  getDmips(
    name = "GenFullNoMmuMaxPerf",
    gen = GenFullNoMmuMaxPerf.main(null),
    testCmd = "make clean run REDO=10 MMU=no CSR=no  COREMARK=yes"
  )
  getDmips(
    name = "GenFullNoMmu",
    gen = GenFullNoMmu.main(null),
    testCmd = "make clean run REDO=10 MMU=no CSR=no  COREMARK=yes"
  )

  getDmips(
    name = "GenFull",
    gen = GenFull.main(null),
    testCmd = "make clean run REDO=10 CSR=no MMU=no  COREMARK=yes"
  )

  getDmips(
    name = "GenLinuxBalenced",
    gen = LinuxGen.main(Array.fill[String](0)("")),
    testCmd = "make clean run IBUS=CACHED DBUS=CACHED DEBUG_PLUGIN=STD DHRYSTONE=yes SUPERVISOR=yes MMU=no CSR=yes CSR_SKIP_TEST=yes  COMPRESSED=no MUL=yes DIV=yes LRSC=yes AMO=yes REDO=10 TRACE=no COREMARK=yes LINUX_REGRESSION=no"
  )

  test("final_report") {
    println(report)
  }
}


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>

    <parent>
        <groupId>io.dropwizard</groupId>
        <artifactId>dropwizard-parent</artifactId>
        <version>2.1.5-SNAPSHOT</version>
        <relativePath>../dropwizard-parent</relativePath>
    </parent>

    <artifactId>dropwizard-hibernate</artifactId>
    <name>Dropwizard Hibernate Support</name>

    <dependencies>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-core</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-db</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-jackson</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-jersey</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-lifecycle</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-logging</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-util</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard.metrics</groupId>
            <artifactId>metrics-core</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard.metrics</groupId>
            <artifactId>metrics-healthchecks</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-hibernate5</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>javax.transaction</groupId>
                    <artifactId>javax.transaction-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>javax.persistence-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.glassfish.hk2.external</groupId>
                    <artifactId>jakarta.inject</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-common</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.glassfish.hk2.external</groupId>
                    <artifactId>jakarta.inject</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-server</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.glassfish.hk2.external</groupId>
                    <artifactId>jakarta.inject</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>net.bytebuddy</groupId>
            <artifactId>byte-buddy</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jadira.usertype</groupId>
            <artifactId>usertype.core</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>javax.activation</groupId>
                    <artifactId>javax.activation-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.xml.bind</groupId>
                    <artifactId>jaxb-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>jakarta.activation</groupId>
            <artifactId>jakarta.activation-api</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-configuration</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-testing</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.test-framework</groupId>
            <artifactId>jersey-test-framework-core</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.glassfish.hk2.external</groupId>
                    <artifactId>jakarta.inject</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.test-framework.providers</groupId>
            <artifactId>jersey-test-framework-provider-inmemory</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

redpajama_set_name: RedPajamaGithub


text:
typedef enum {
    NetWorkEngineTypeGET,
    NetWorkEngineTypePOST,
    NetWorkEngineTypePUT,
    NetWorkEngineTypeDELETE
}NetWorkEngineType;
@class NetWorkEngine;
@protocol NetWorkEngineDelegate <NSObject>
//1.网络请求开始
- (void)netWorkStartLoading:(NetWorkEngine *)netWorkEngine;
//2.网络请求结束
- (void)netWorkFinishLoading:(NetWorkEngine *)netWorkEngine withResponeserObject:(id)responeserObject;

@end
@interface NetWorkEngine : NSObject
//3.创建初始化方法 闯入网络请求必要条件
+(instancetype)netWorkEngineWithUrlString:(NSString *)urlString parameters:(NSDictionary *)parameters requestDelegate:(id<NetWorkEngineDelegate>)delegate httpMethodType:(NetWorkEngineType)netWorkEngineType;
//4.开始网络请求
- (void)startRequestNetWork;
@end


text:
require 'test_helper'

class GlyphTest < ActionView::TestCase
  include UiBibz::Helpers::Ui::CoreHelper

  test 'create glyph with a name' do
    actual   = ui_glyph('add')
    expected = ''
    assert_equal expected, actual
  end

  test 'create glyph with hash' do
    actual   = ui_glyph({ name: 'add', size: 3, type: 'li' })
    expected = ''
    assert_equal expected, actual
  end

  test 'create glyph with name and hash' do
    actual   = ui_glyph('add', { size: 3, type: 'li' })
    expected = ''
    assert_equal expected, actual
  end

  test 'create glyph with label' do
    actual   = ui_glyph('add', { label: 'Example' })
    expected = ' Example'
    assert_equal expected, actual
  end
end


text:
require File.dirname(__FILE__) + '/../test_helper'

class ConversationTest < ActiveSupport::TestCase
  context "A Conversation" do
    setup do
      @c = Conversation.new(:subject => 'hi', :participants_text => 'quentin, joe1')
      assert @c.save
    end

    should "look up users correctly" do
      assert @c.users.include?(users(:quentin))
      assert @c.users.include?(users(:joe1))
      assert_equal 2, @c.users.size
    end

    should "be resavable" do
      c2 = Conversation.find(@c.id)
      assert c2.save
    end

    should "be able to add additional users" do
      @c.additional_users = [users(:anotherjoe)]
      assert @c.save
      assert @c.users.include?(users(:anotherjoe))
      assert_equal 3, @c.users.size
    end

    should "not include a message from an uninvolved user" do
      @m = Message.new(:body => 'test')
      @m.conversation = @c
      @m.user = users(:anotherjoe)
      assert !@m.save
      assert @m.errors.on(:users)
    end
  end

  context "A Conversation" do
    setup do
      @c = Conversation.new
    end

    should "require more than 1 particpant" do
      @c.subject = 'hi'
      @c.participants_text = 'quentin'
      assert !@c.save
      assert @c.errors.on(:users)
    end
  end

  context "A Conversation with a message" do
    setup do
      @c = Conversation.new(:subject => 'hi', :participants_text => 'quentin, joe1')
      assert @c.save
      @m = Message.new(:body => 'test')
      @m.conversation = @c
      @m.user = users(:quentin)
      assert @m.save
    end

    should "disappear when all references are gone" do
      @m.message_references.each do |mr|
        mr.destroy
      end

      assert !Conversation.find_by_id(@c.id)
    end

    should "stick around when not all references are gone" do
      @m.message_references.first.destroy

      assert Conversation.find_by_id(@c.id)
    end
  end
end


text:
package ioutils

import "io"

// LimitedWriter is similar to io.LimitedReader; it writes to W but
// limits the amount of data written to just N bytes. Each subsequent call to
// Write() will return a nil error and a count of 0.
type LimitedWriter struct {
	W io.Writer
	N int64
}

func (l *LimitedWriter) Write(data []byte) (n int, err error) {
	if l.N <= 0 {
		return 0, nil
	}
	if int64(len(data)) > l.N {
		data = data[0:l.N]
	}
	n, err = l.W.Write(data)
	l.N -= int64(n)
	return
}


text:
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input;

namespace osu.Game.Graphics.UserInterface
{
    public class IconButton : ClickableContainer
    {
        private readonly TextAwesome icon;
        private readonly Box hover;
        private readonly Container content;

        public FontAwesome Icon
        {
            get { return icon.Icon; }
            set { icon.Icon = value; }
        }

        private const float button_size = 30;
        private Color4 flashColour;

        public Vector2 IconScale
        {
            get { return icon.Scale; }
            set { icon.Scale = value; }
        }

        public IconButton()
        {
            AutoSizeAxes = Axes.Both;

            Origin = Anchor.Centre;
            Anchor = Anchor.Centre;

            Children = new Drawable[]
            {
                content = new Container
                {
                    Origin = Anchor.Centre,
                    Anchor = Anchor.Centre,
                    Size = new Vector2 (button_size),

                    CornerRadius = 5,
                    Masking = true,
                    EdgeEffect = new EdgeEffect
                    {
                        Colour = Color4.Black.Opacity(0.04f),
                        Type = EdgeEffectType.Shadow,
                        Radius = 5,
                    },
                    Children = new Drawable[]
                    {
                        hover = new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Alpha = 0,
                        },
                        icon = new TextAwesome
                        {
                            Origin = Anchor.Centre,
                            Anchor = Anchor.Centre,
                            TextSize = 18,
                        }
                    }
                }
            };
        }

        [BackgroundDependencyLoader]
        private void load(OsuColour colours)
        {
            hover.Colour = colours.Yellow.Opacity(0.6f);
            flashColour = colours.Yellow;
        }

        protected override bool OnHover(InputState state)
        {
            hover.FadeIn(500, EasingTypes.OutQuint);
            return base.OnHover(state);
        }

        protected override void OnHoverLost(InputState state)
        {
            hover.FadeOut(500, EasingTypes.OutQuint);
            base.OnHoverLost(state);
        }

        protected override bool OnClick(InputState state)
        {
            hover.FlashColour(flashColour, 800, EasingTypes.OutQuint);
            return base.OnClick(state);
        }

        protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
        {
            content.ScaleTo(0.75f, 2000, EasingTypes.OutQuint);
            return base.OnMouseDown(state, args);
        }

        protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
        {
            content.ScaleTo(1, 1000, EasingTypes.OutElastic);
            return base.OnMouseUp(state, args);
        }
    }
}


text:
import os
import sys
import json
import getpass

from pyethapp.accounts import Account

def find_datadir():
    home = os.path.expanduser('~')
    if home == '~':  # Could not expand user path
        return None
    datadir = None

    if sys.platform == 'darwin':
        datadir = os.path.join(home, 'Library', 'Ethereum')
    # NOTE: Not really sure about cygwin here
    elif sys.platform == 'win32' or sys.platform == 'cygwin':
        datadir = os.path.join(home, 'AppData', 'Roaming', 'Ethereum')
    elif os.name == 'posix':
        datadir = os.path.join(home, '.ethereum')
    else:
        raise RuntimeError('Unsupported Operating System')

    if not os.path.isdir(datadir):
        return None
    return datadir

def find_keystoredir():
    datadir = find_datadir()
    if datadir is None:
        # can't find a data directory in the system
        return None
    keystore_path = os.path.join(datadir, 'keystore')
    if not os.path.exists(keystore_path):
        # can't find a keystore under the found data directory
        return None
    return keystore_path

class AccountManager(object):

    def __init__(self, keystore_path=None):
        self.keystore_path = keystore_path
        self.accounts = {}
        if self.keystore_path is None:
            self.keystore_path = find_keystoredir()
        if self.keystore_path is not None:

            for f in os.listdir(self.keystore_path):
                fullpath = os.path.join(self.keystore_path, f)
                if os.path.isfile(fullpath):
                    with open(fullpath) as data_file:
                        data = json.load(data_file)
                        self.accounts[str(data['address'])] = str(fullpath)

    def address_in_keystore(self, address):
        if address is not None and address.startswith('0x'):
            address = address[2:]

        return address in self.accounts

    def get_privkey(self, address, password=None):
        """Find the keystore file for an account, unlock it and get the private key

        :param str address: The Ethereum address for which to find the keyfile in the system
        :param str password: Mostly for testing purposes. A password can be provided
                             as the function argument here. If it's not then the
                             user is interactively queried for one.
        :return str: The private key associated with the address
        """

        if address.startswith('0x'):
            address = address[2:]

        if not self.address_in_keystore(address):
            raise ValueError("Keystore file not found for %s" % address)

        with open(self.accounts[address]) as data_file:
            data = json.load(data_file)

        # Since file was found prompt for a password if not already given
        if password is None:
            password = getpass.getpass("Enter the password to unlock %s: " % address)
        acc = Account(data, password, self.accounts[address])
        return acc.privkey


text:
title: .zshrc and .bash_profile
disqus: yep
layout: page
---

Useful aliases and alike from my `.zshrc`

```
export EDITOR="nano"

export HISTSIZE=1000000
export HISTFILESIZE=1000000

## Git

alias master='git checkout master'
alias pull='git pull'
alias push='git push origin HEAD'
alias gitclean='git branch | grep -v "^*"" | xargs git branch -d'

parse_git_branch() {
    git_status="$(git status 2> /dev/null)"
    pattern="On branch ([^[:space:]]*)"
    if [[ ! ${git_status} =~ "(working (tree|directory) clean)" ]]; then
        state="*"
    fi
    if [[ ${git_status} =~ ${pattern} ]]; then
      branch=${match[1]}
      branch_cut=${branch:0:35}
      if (( ${#branch} > ${#branch_cut} )); then
          echo "(${branch_cut}…${state})"
      else
          echo "(${branch}${state})"
      fi
    fi
}

# Ruby

alias brake='bundle exec rake'
alias brails='bundle exec rails'

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

# signing scripts
export PATH="$HOME/bin:$PATH"
```

My old `.bash_profile` from before MacOS moved from bash to zsh by default.

```
export EDITOR="nano"

export HISTSIZE=1000000
export HISTFILESIZE=1000000

## Git

alias master='git checkout master'
alias pull='git pull'
alias push='git push origin HEAD'
alias gitclean='git branch | grep -v "^*"" | xargs git branch -d'

parse_git_branch() {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "

# Rails

alias brake='bundle exec rake'
alias brails='bundle exec rails'
alias hrake='heroku run rake'
alias hrails='heroku run rails'

# Dev

dcd() {
  dev cd "$1"
  code .
}

fortune | cowsay
```


text:
package com.example.book.api.resource;

import com.example.book.api.BookRestController;
import com.example.book.entity.Book;
import org.apache.commons.lang3.StringUtils;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.hateoas.mvc.ControllerLinkBuilder;
import org.springframework.util.Assert;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.stream.Collectors;

import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;

/**
 * Resource for a collection of {@link BookResource book resources}.
 */
@XmlRootElement(name = "Books")
public class BookListResource extends ResourceSupport {

    private Collection<BookResource> bookResources;

    public BookListResource() {
        super();
    }

    public BookListResource(Collection<Book> books, String isbn, String title) {
        Assert.notNull(books, "Books must be set");

        this.bookResources = books.stream().map(BookResource::new).collect(Collectors.toList());

        if (StringUtils.isNotBlank(isbn) || StringUtils.isNotBlank(title)) {
            add(ControllerLinkBuilder.linkTo(methodOn(BookRestController.class)
                    .findByQuery(isbn, title)).withSelfRel());
        } else {
            add(linkTo(methodOn(BookRestController.class)
                    .findAllBooks()).withSelfRel());
        }
    }

    @XmlElement(name="Book")
    public Collection<BookResource> getBooks() {
        return bookResources;
    }
}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.7"/>
<title>PRAgMaTIc: File Members</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>

<link href="doxygen.css" rel="stylesheet" type="text/css" />

PRAgMaTIc
    master

Main Page

Related Pages

Namespaces

Classes

Files

File List

File Members

All

Functions

Variables

Typedefs

Macros

index_t
: PragmaticTypes.h

range_element
: PragmaticMinis.h

SNEList_t
: PragmaticTypes.h

vtkFloatingPointType
: VTKTools.h

<address class="footer">
Generated on Mon Feb 23 2015 22:50:45 for PRAgMaTIc by

 1.8.7
</address>


text:
<!DOCTYPE html>
<html>
  <head>
    <!-- Load platform support before any code that touches the DOM. -->
    <script src="bower_components/platform/platform.js"></script>
    <link rel="import" href="personas.html">
  </head>
  <body unresolved touch-action="auto">
    <persona-summary img="https://s3.amazonaws.com/uifaces/faces/twitter/dancounsell/128.jpg" name="Leon Walsh" sex="Male" age="35">
  </body>
</html>


text:
package org.inferred.freebuilder;

import static org.junit.Assert.assertEquals;

import com.google.common.base.Optional;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** FreeBuilder test using {@link OptionalGwtType}. */
@RunWith(JUnit4.class)
public class OptionalGwtTypeTest {

  private static final String NAME_1 = "name1";
  private static final String NAME_2 = "name2";
  private static final String NAME_3 = "name3";

  @Test
  public void testAllMethodInteractions() {
    OptionalGwtType.Builder builder = new OptionalGwtType.Builder();
    builder.setName(NAME_1);
    assertEquals(Optional.of(NAME_1), builder.getName());
    assertEquals(Optional.of(NAME_1), builder.build().getName());
    builder.clearName();
    assertEquals(Optional.absent(), builder.getName());
    assertEquals(Optional.absent(), builder.build().getName());
    builder.setNullableName(NAME_3);
    assertEquals(Optional.of(NAME_3), builder.getName());
    assertEquals(Optional.of(NAME_3), builder.build().getName());
    builder.setName(Optional.absent());
    assertEquals(Optional.absent(), builder.getName());
    assertEquals(Optional.absent(), builder.build().getName());
    builder.setNullableName(null);
    assertEquals(Optional.absent(), builder.getName());
    assertEquals(Optional.absent(), builder.build().getName());
    builder.setName(Optional.of(NAME_2));
    assertEquals(Optional.of(NAME_2), builder.getName());
    assertEquals(Optional.of(NAME_2), builder.build().getName());
    builder.clear();
    assertEquals(Optional.absent(), builder.getName());
    assertEquals(Optional.absent(), builder.build().getName());
  }
}


text:
class CredentialsItemView;
class ManagePasswordsBubbleModel;

namespace autofill {
struct PasswordForm;
}

namespace views {
class ImageButton;
class Link;
}

// A custom view that represents one credential row. There are two states:
// * Present a credential to the user for management.
// * Offer the user the ability to undo a deletion action.
class ManageCredentialItemView : public views::View,
                                 public views::ButtonListener,
                                 public views::LinkListener {
 public:
  ManageCredentialItemView(ManagePasswordsBubbleModel* model,
                           const autofill::PasswordForm* password_form);
  ~ManageCredentialItemView() override;

 private:
  void Refresh();

  // ButtonListener:
  void ButtonPressed(views::Button* sender, const ui::Event& event) override;

  // LinkListener:
  void LinkClicked(views::Link* source, int event_flags) override;

  scoped_ptr<CredentialsItemView> credential_button_;
  views::ImageButton* delete_button_;
  views::Link* undo_link_;

  ManagePasswordsBubbleModel* const model_;
  bool form_deleted_;

  DISALLOW_COPY_AND_ASSIGN(ManageCredentialItemView);
};

#endif  // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_CREDENTIAL_ITEM_VIEW_H_


text:
namespace WinTail
{
    using System;
    using System.IO;
    using Akka.Actor;

    /// <summary>
    /// Turns <see cref="FileSystemWatcher"/> events about a specific file into
    /// messages for <see cref="TailActor"/>.
    /// </summary>
    class FileObserver : IDisposable
    {
        private readonly IActorRef tailActor;
        private readonly string absoluteFilePath;
        private FileSystemWatcher watcher;
        private readonly string fileDir;
        private readonly string fileNameOnly;

        public FileObserver(IActorRef tailActor, string absoluteFilePath)
        {
            this.tailActor = tailActor;
            this.absoluteFilePath = absoluteFilePath;
            this.fileDir = Path.GetDirectoryName(absoluteFilePath);
            this.fileNameOnly = Path.GetFileName(absoluteFilePath);
        }

        /// <summary>
        /// Begin monitoring file.
        /// </summary>
        public void Start()
        {
            // Need this for Mono 3.12.0 workaround
            // uncomment next line if you're running on Mono!
            // Environment.SetEnvironmentVariable("MONO_MANAGED_WATCHER", "enabled");

            // make watcher to observe our specific file
            this.watcher = new FileSystemWatcher(fileDir, fileNameOnly);

            // watch our file for changes to the file name,
            // or new messages being written to file
            this.watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;

            // assign callbacks for event types
            this.watcher.Changed += OnFileChanged;
            this.watcher.Error += OnFileError;

            // start watching
            this.watcher.EnableRaisingEvents = true;
        }

        /// <summary>
        /// Stop monitoring file.
        /// </summary>
        public void Dispose()
        {
            this.watcher.Dispose();
        }

        /// <summary>
        /// Callback for <see cref="FileSystemWatcher"/> file error events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnFileError(object sender, ErrorEventArgs e)
        {
            this.tailActor.Tell(new TailActor.FileError(fileNameOnly, e.GetException().Message), ActorRefs.NoSender);
        }

        /// <summary>
        /// Callback for <see cref="FileSystemWatcher"/> file change events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnFileChanged(object sender, FileSystemEventArgs e)
        {
            if (e.ChangeType == WatcherChangeTypes.Changed)
            {
                // here we use a special ActorRefs.NoSender
                // since this event can happen many times,
                // this is a little microoptimization
                this.tailActor.Tell(new TailActor.FileWrite(e.Name), ActorRefs.NoSender);
            }
        }
    }
}


text:
#!/usr/local/bin/python3

import argparse
import glob
import logging
import os
import urllib
import iwebparseandpost

parser = argparse.ArgumentParser()
parser.add_argument('iweb_blog_path', help='path root directory of iWeb blog')
parser.add_argument('wp_auth_token', help='your bearer token for the WordPress API')
parser.add_argument('wp_site', help='your WordPress site name')
args = parser.parse_args()

with open(args.iweb_blog_path + '/index.html','r') as f:
    html_string = f.read()
start_pos = html_string.find('url=') + 4
end_pos = html_string.find('"', start_pos)
blog_main = urllib.parse.unquote(html_string[start_pos:end_pos].strip())
blog_entries_root = args.iweb_blog_path + '/' + os.path.dirname(blog_main) + '/Entries'
blog_entries = glob.glob(blog_entries_root + '/*/*/*.html')
logging.debug(blog_entries)

for entry in blog_entries:
    iwebparseandpost.parse_entry(entry, args.wp_auth_token, args.wp_site)


text:
<?php

namespace OpenOrchestra\Backoffice\Reference\Strategies;

/**
 * Interface ReferenceStrategy
 */
Interface ReferenceStrategyInterface
{
    /**
     * @param mixed $entity
     *
     * @return boolean
     */
    public function support($entity);

    /**
     * @param mixed $entity
     */
    public function addReferencesToEntity($entity);

    /**
     * @param mixed $entity
     */
    public function removeReferencesToEntity($entity);
}