text:
package com.composum.platform.models.simple;

import com.composum.sling.core.util.PropertyUtil;
import org.apache.sling.api.resource.ValueMap;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

/**
 * a caching property map for direct use as model with i18N support
 */
public abstract class GenericMap extends HashMap<String, Object> implements ValueMap {

    public static final String UNDEFINED = "<undefined>";

    protected final List<String> i18nPaths;

    protected GenericMap(final List<String> i18nPaths) {
        this.i18nPaths = i18nPaths != null ? i18nPaths : Collections.singletonList(".");
    }

    @Nullable
    public <T> T get(@NotNull String key, @NotNull Class<T> type) {
        //noinspection unchecked
        return (T) get(key);
    }

    @NotNull
    public <T> T get(@NotNull String key, @NotNull T defaultValue) {
        Class<T> type = PropertyUtil.getType(defaultValue);
        T value = get(key, type);
        return value != null ? value : defaultValue;
    }

    /**
     * delegates each 'get' to the localized methods and caches the result
     */
    @Override
    public Object get(Object key) {
        Object value = super.get(key);
        if (value == null) {
            value = getValue((String) key, i18nPaths);
            super.put((String) key, value != null ? value : UNDEFINED);
        }
        return value != UNDEFINED ? value : null;
    }

    protected Object getValue(String key, List<String> pathsToTry) {
        Object value;
        for (String path : pathsToTry) {
            // a local path ('./...') doesn't work properly in the LoadedModel; therefore checked here
            if ((value = getValue(".".equals(path) ? key : path + '/' + key)) != null) {
                return value;
            }
        }
        return null;
    }

    protected abstract Object getValue(String key);
}


text:
import json

from django import forms
from django.core.exceptions import ValidationError
from django.utils import six
from django.utils.translation import ugettext_lazy as _

__all__ = ['HStoreField']

class HStoreField(forms.CharField):
    """A field for HStore data which accepts JSON input."""
    widget = forms.Textarea
    default_error_messages = {
        'invalid_json': _('Could not load JSON data.'),
    }

    def prepare_value(self, value):
        if isinstance(value, dict):
            return json.dumps(value)
        return value

    def to_python(self, value):
        if not value:
            return {}
        try:
            value = json.loads(value)
        except ValueError:
            raise ValidationError(
                self.error_messages['invalid_json'],
                code='invalid_json',
            )
        # Cast everything to strings for ease.
        for key, val in value.items():
            value[key] = six.text_type(val)
        return value

    def has_changed(self, initial, data):
        """
        Return True if data differs from initial.
        """
        # For purposes of seeing whether something has changed, None is
        # the same as an empty dict, if the data or initial value we get
        # is None, replace it w/ {}.
        initial_value = self.to_python(initial)
        return super(HStoreField, self).has_changed(initial_value, data)

redpajama_set_name: RedPajamaGithub


text:
var assert = require('assert')
  , Migration = require('../../lib/migration').Migration
  , StandardGenerator = require('../../lib/generators/sql').StandardGenerator
  , utils = require('utilities')
  , tests
  , fakeAdapter
  , createCallback
  , strIncl
  , strIncl;

fakeAdapter = {
  COLUMN_NAME_DELIMITER: '"'
, exec: function (sql, cb) {
    cb(null, sql);
  }
, generator: new StandardGenerator()
};
createCallback = function (next) {
  return function (err, data) {
    next();
  };
};
strIncl = function (searchIn, searchFor) {
    var sIn = utils.string.trim(searchIn.toLowerCase());
    var sFor = utils.string.trim(searchFor.toLowerCase());
    return sIn.indexOf(sFor) > -1;
};

Migration.setDefaultAdapter(fakeAdapter);

tests = {

  'createTable': function (next) {
    var m = new Migration('foo')
      , def = function (t) {
          t.column('fooBarBaz', 'string');
          t.column('bazBarQux', 'int');
          t.column('quxBazBar', 'boolean');
        };
    m.createTable('zerbs', def, function (err, data) {
      var sql = data;
      assert.ok(strIncl(sql,
          'create table zerbs ('));
      assert.ok(strIncl(sql,
          '"id" varchar(255) primary key'));
      assert.ok(strIncl(sql,
          '"foo_bar_baz" varchar(255)'));
      assert.ok(strIncl(sql,
          '"baz_bar_qux" integer'));
      assert.ok(strIncl(sql,
          '"qux_baz_bar" boolean'));
      next();
    });
  }

, 'addColumn': function (next) {
    var m = new Migration('foo');
    m.addColumn('zerbs', 'fooBarBaz', 'int', function (err, data) {
      var sql = data;
      assert.ok(strIncl(sql, 'alter table zerbs'));
      assert.ok(strIncl(sql, 'add column "foo_bar_baz" integer'));
      next();
    });
  }

, 'removeColumn': function (next) {
    var m = new Migration('foo');
    m.removeColumn('zerbs', 'fooBarBaz', function (err, data) {
      var sql = data;
      assert.ok(strIncl(sql, 'alter table zerbs'));
      assert.ok(strIncl(sql, 'drop column "foo_bar_baz"'));
      next();
    });
  }

, 'changeColumn': function (next) {
    var m = new Migration('foo');
    m.changeColumn('zerbs', 'fooBarBaz', 'string', function (err, data) {
      var sql = data;
      assert.ok(strIncl(sql, 'alter table zerbs'));
      assert.ok(strIncl(sql, 'alter column "foo_bar_baz" type varchar(255)'));
      next();
    });
  }

, 'renameColumn': function (next) {
    var m = new Migration('foo');
    m.renameColumn('zerbs', 'fooBarBaz', 'bazBarQux', function (err, data) {
      var sql = data;
      assert.ok(strIncl(sql, 'alter table zerbs'));
      assert.ok(strIncl(sql, 'rename column "foo_bar_baz" to "baz_bar_qux"'));
      next();
    });
  }

, 'dropTable': function (next) {
    var m = new Migration('foo');
    m.dropTable('zerbs', function (err, data) {
      var sql = data;
      assert.ok(strIncl(sql, 'drop table if exists zerbs'));
      next();
    });
  }

};

module.exports = tests;


text:
class Pyinvoke < Formula
  include Language::Python::Virtualenv

  desc "Pythonic task management & command execution"
  homepage "http://pyinvoke.org/"
  url "https://github.com/pyinvoke/invoke/archive/1.0.0.tar.gz"
  sha256 "29cb714cd61d82b0a6cbfa0dfe4249c98c30a8313104221f6a022c5f8b5bc993"
  head "https://github.com/pyinvoke/invoke.git"

  bottle do
    cellar :any_skip_relocation
    sha256 "9f473f2a1494ec73191fa5f1e188bf59c4426b403d9d3620fd6bd877463c9313" => :high_sierra
    sha256 "37e2c92be98d5b920f53acac34a998c99c5b2a949f520ac02e76f5b9107564e6" => :sierra
    sha256 "7252a19f4d91b6b70feed40027a3db913b36a6e80bacf708b9126c3e818cba16" => :el_capitan
  end

  depends_on "python@2"

  def install
    virtualenv_install_with_resources
  end

  test do
    (testpath/"tasks.py").write <<~EOS
      from invoke import run, task

      @task
      def clean(ctx, extra=''):
          patterns = ['foo']
          if extra:
              patterns.append(extra)
          for pattern in patterns:
              run("rm -rf {}".format(pattern))
    EOS
    (testpath/"foo"/"bar").mkpath
    (testpath/"baz").mkpath
    system bin/"invoke", "clean"
    refute_predicate testpath/"foo", :exist?, "\"pyinvoke clean\" should have deleted \"foo\""
    assert_predicate testpath/"baz", :exist?, "pyinvoke should have left \"baz\""
    system bin/"invoke", "clean", "--extra=baz"
    refute_predicate testpath/"foo", :exist?, "\"pyinvoke clean-extra\" should have still deleted \"foo\""
    refute_predicate testpath/"baz", :exist?, "pyinvoke clean-extra should have deleted \"baz\""
  end
end


text:
package com.tle.core.favourites.dao;

import com.tle.beans.item.Item;
import com.tle.beans.item.ItemIdKey;
import com.tle.core.guice.Bind;
import com.tle.core.item.event.IndexItemBackgroundEvent;
import com.tle.core.item.operations.AbstractWorkflowOperation;
import java.util.List;
import javax.inject.Inject;

@Bind
public class UpdateLatestOperation extends AbstractWorkflowOperation {
  @Inject private BookmarkDao dao;

  @Override
  public boolean execute() {
    if (params.isWentLive()) {
      List<Item> itemsToUpdate = dao.updateAlwaysLatest(getItem());
      for (Item item : itemsToUpdate) {
        addAfterCommitEvent(new IndexItemBackgroundEvent(new ItemIdKey(item), true));
      }
    }
    return false;
  }
}


text:
cointainer
==========

A wrapper to bitcoind to provide caching, access control, key management, and other features. Its intended use is an internal service to a web application that manages bitcoin balances for users.

### Setup

Edit the values in config.json to specify the port to listen to for API requests,
the host and port for bitcoind, and other important values.

```
$ npm start
```

### API

#### Balance
Retrieve the current valid coin balance for the given username.

`balance(account_name)`

```
{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "balance",
    "params": [
        "bob"
    ]
}
```

```
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "now": 1369153449779,
        "username": "bob",
        "balance": {
            "amount": 3,
            "currency": "btc"
        }
    }
}
```

#### AddUser
Create an account for username. This is a prerequisite to receive coins.
The bitcoin receiving address for this user is returned.

`add_user(username)`

```
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "now": 1369153371028,
        "username": "bob",
        "receiving_addresss": "1Q3gZkgrcr9AELaZ2mUTCeh66fH9iH5uSK"
    }
}
```

### History

The project began when json-rpc response times from bitcoind were often 500ms. A project required quick balances and transaction history to build html pages of account information.

### Internals

There are three blocks in the system, this nodejs server, bitcoind, and a database.


text:
package com.core.dao;

import java.sql.SQLException;
import java.util.Collection;

/**
 * A DAO interface for managing Java Beans
 * @author Baruch
 */
public interface CompanyCouponDAO {

	// inserts new coupon ID and company ID
	void createCompanyCoupon(long companyID, long couponID)
			throws SQLException;

	// returns all coupon IDs of the current company ID
	Collection<Long> readCompanyCouponIDs(long companyID)
			throws SQLException;

	// checks if a coupon ID belongs to the company ID
	boolean isCouponBelongesToCompany(long companyID, long couponID)
			throws SQLException;

	// deletes the company ID from the table
	int deleteCompany(long companyID) throws SQLException;

	// deletes the coupon ID from the table
	int deleteCoupon(long couponID) throws SQLException;

}


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2014-2018 Evolveum and contributors
  ~
  ~ This work is dual-licensed under the Apache License 2.0
  ~ and European Union Public License. See LICENSE file for details.
  -->

<securityPolicy oid="00000000-0000-0000-0000-000000000120"
    xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'>
    <name>Default Security Policy</name>
    <credentials>
        <password>
            <minOccurs>0</minOccurs>
            <lockoutMaxFailedAttempts>3</lockoutMaxFailedAttempts>
            <lockoutFailedAttemptsDuration>PT3M</lockoutFailedAttemptsDuration>
            <lockoutDuration>PT15M</lockoutDuration>
            <valuePolicyRef oid="00000000-0000-0000-0000-000000000003"/>
        </password>
    </credentials>
</securityPolicy>


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

require 'ruby_info'

describe RubyInfo do
  it "should get info" do
    RubyInfo.should be_ruby
  end

  it "should classify site :lib" do
    kind,path = RubyInfo.classify_path('/opt/local/lib/ruby/site_ruby/1.8/something.rb')
    kind.should == :lib
    path.should == 'something.rb'
  end

  it "should classify core :lib" do
    kind,path = RubyInfo.classify_path('/opt/local/lib/ruby/1.8/erb.rb')
    kind.should == :lib
    path.should == 'erb.rb'
  end

  it "should classify :gem" do
    kind,path = RubyInfo.classify_path('/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb')
    kind.should == :gem
    path.should == ['activerecord-1.15.3','active_record/base.rb']
  end

  it "should classify /app as :app" do
    kind,path = RubyInfo.classify_path('/app/controllers/foo_controller.rb')
    kind.should == :app
    path.should == 'app/controllers/foo_controller.rb'
  end

  it "should classify /lib as :app" do
    kind,path = RubyInfo.classify_path('/lib/thing.rb')
    kind.should == :app
    path.should == 'lib/thing.rb'
  end

  it "should classify /vendor as :app" do
    kind,path = RubyInfo.classify_path('/vendor/rails.rb')
    kind.should == :app
    path.should == 'vendor/rails.rb'
  end

  it "should classify /tmp as :unknown" do
    kind,path = RubyInfo.classify_path('/tmp')
    kind.should == :unknown
    path.should == '/tmp'
  end
end


text:
<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8">

  <title>Twiddy - Desktop Wireframe</title>
  <meta name="description" content="The HTML5 Herald">
  <meta name="author" content="SitePoint">
  <style>
    body {
      margin: 0;
      padding: 0;
      background: url('img/screens/01-home-wireframe-bg-pat.png') repeat-x;
    }
    div {
      background: url('img/screens/01-home-wireframe.png') center no-repeat;
      height: 5122px;
    }
  </style>

  <!--[if lt IE 9]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->
</head>
<body>
  <div> </div>
</body>
</html>