text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VisualRust.Cargo
{
    public enum OutputTargetType
    {
        Library,
        Binary,
        Benchmark,
        Test,
        Example
    }

    public static class OutputTargetTypeExtensions
    {
        public static OutputTargetType FromString(string type)
        {
            switch(type)
            {
                case "lib":
                    return OutputTargetType.Library;
                case "bin":
                    return OutputTargetType.Binary;
                case "bench":
                    return OutputTargetType.Benchmark;
                case "test":
                    return OutputTargetType.Test;
                case "example":
                    return OutputTargetType.Example;
            }
            throw new ArgumentException(null, "type");
        }

        public static string ToTypeString(this OutputTargetType type)
        {
            switch(type)
            {
                case OutputTargetType.Library:
                    return "lib";
                case OutputTargetType.Binary:
                    return "bin";
                case OutputTargetType.Benchmark:
                    return "bench";
                case OutputTargetType.Test:
                    return "test";
                case OutputTargetType.Example:
                    return "example";
            }
            throw new ArgumentException(null, "type");
        }

        public static string DefaultPath(this OutputTargetType type, string name)
        {
            switch(type)
            {
                case OutputTargetType.Library:
                    return String.Format(@"src\{0}.rs", name);
                case OutputTargetType.Binary:
                    return String.Format(@"src\{0}.rs", name);
                case OutputTargetType.Benchmark:
                    return String.Format(@"benches\{0}.rs", name);
                case OutputTargetType.Test:
                    return String.Format(@"tests\{0}.rs", name);
                case OutputTargetType.Example:
                    return String.Format(@"examples\{0}.rs", name);
            }
            throw new ArgumentException(null, "type");
        }

        public static bool DefaultTest(this OutputTargetType type)
        {
            switch(type)
            {
                default:
                    return true;
                case OutputTargetType.Benchmark:
                    return false;
            }
        }

        public static bool DefaultDoctest(this OutputTargetType type)
        {
            switch(type)
            {
                default:
                    return false;
                case OutputTargetType.Library:
                    return true;
            }
        }

        public static bool DefaultBench(this OutputTargetType type)
        {
            switch(type)
            {
                default:
                    return true;
                case OutputTargetType.Test:
                case OutputTargetType.Example:
                    return false;
            }
        }

        public static bool DefaultDoc(this OutputTargetType type)
        {
            switch(type)
            {
                default:
                    return false;
                case OutputTargetType.Binary:
                case OutputTargetType.Library:
                    return true;
            }
        }

        public static bool DefaultPlugin(this OutputTargetType _)
        {
            return false;
        }

        public static bool DefaultHarness(this OutputTargetType _)
        {
            return true;
        }
    }
}


text:
aroche
======
simple Mac App builder for node-shell

![image](Resources/screen-shot.png)

redpajama_set_name: RedPajamaGithub


text:
<?php
class Mlaporan extends CI_Model {

    var $tabel = 'invoices';

    function __construct() {
        parent::__construct();
    }
    function getAllItem($email) {
        $this->db->from($this->tabel);
        $query = $this->db->where('email',$email)->get();
        return $query->result();
    }

}
?>


text:
from django.db import migrations

class Migration(migrations.Migration):

    dependencies = [("order", "0054_move_data_to_order_events")]

    operations = [
        migrations.RemoveField(model_name="orderhistoryentry", name="order"),
        migrations.RemoveField(model_name="orderhistoryentry", name="user"),
        migrations.RemoveField(model_name="ordernote", name="order"),
        migrations.RemoveField(model_name="ordernote", name="user"),
        migrations.DeleteModel(name="OrderHistoryEntry"),
        migrations.DeleteModel(name="OrderNote"),
    ]


text:
namespace native
{
namespace detail
{

template <typename T>
struct stream_type;

template <>
struct stream_type<istring>
{
    using type = string_builder;
};

template <>
struct stream_type<std::string>
{
    using type = std::ostringstream;
};

} // namespace detail
} // namespace native

#endif


text:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<feed><tipo>Rua</tipo><logradouro>da Saudade</logradouro><bairro>Vila Maria</bairro><cidade>Assis</cidade><uf>SP</uf><cep>19814210</cep></feed>


text:
package org.jboss.weld.tests.producer.method.parameterized;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

@ApplicationScoped
public class TestBean {
    @Inject
    @Parameterized
    Parameterized1<Parameterized2<Double>> parameterized;

}


text:
var jsfcrud = {};
jsfcrud.busyImagePath = '/mvcbookstore/busy.xhtm';
jsfcrud.isDynamicFacesAvailable = typeof DynaFaces != 'undefined';
jsfcrud.canAjaxEnableForm = true;
if (!jsfcrud.isDynamicFacesAvailable) {
    jsfcrud.canAjaxEnableForm = false;
}
if (jsfcrud.isDynamicFacesAvailable) {
    Form.Element.Serializers.selectOne = function(element) {
        var value = '', opt, index = element.selectedIndex;
        if (index >= 0) {
            opt = element.options[index];
            value = opt.value;
        }
        return [element.name, value];
    };
}
jsfcrud.postReplace = function(element, markup) {
    markup.evalScripts();
    setTimeout(function(){jsfcrud.ajaxEnableForm({options: {postReplace:jsfcrud.postReplace}});}, 20);
}
jsfcrud.ajaxEnableForm = function(args) {
    if (!jsfcrud.canAjaxEnableForm) {
        return;
    }

    if (typeof args == undefined || args == null) {
        args = {};
    }

    if (typeof args.options == 'undefined') {
        args.options = {};
    }

    var sourceElement = null;
    if (typeof args.sourceElementId != 'undefined' && args.sourceElementId != null) {
        sourceElement = document.getElementById(args.sourceElementId);
    }

    if (typeof args.formId == 'undefined' || args.formId == null) {
        args.formId = 0;
    }

    //insert busy image we'll display when sending an Ajax request
    jsfcrud.insertBusyImage();

    document.forms[args.formId].submit = function() {
        var busyImage = document.getElementById('busyImage');
        if (busyImage) {
            busyImage.style.display = 'block';
        }
        DynaFaces.fireAjaxTransaction(sourceElement, args.options);
    };
};

jsfcrud.insertBusyImage = function() {
    var busyImage = document.createElement('img');
    busyImage.id = 'busyImage';
    busyImage.src = jsfcrud.busyImagePath;
    busyImage.style.display = 'none';
    document.body.insertBefore(busyImage, document.forms[0]);
}

setTimeout(function(){jsfcrud.ajaxEnableForm({options: {postReplace:jsfcrud.postReplace}});}, 20);


text:
using System.Drawing;
using System.Windows.Forms;

namespace HearThis.UI
{
	public class ExclamationIcon : UserControl
	{
		private const string kDefaultIconText = "!";
		public override Color BackColor { get; set; } = AppPalette.Background;
		public override string Text { get; set; } = kDefaultIconText;

		public void ResetIcon()
		{
			Text = kDefaultIconText;
			Visible = true;
		}

		protected override void OnPaint(PaintEventArgs e)
		{
			var rect = new Rectangle(ClientRectangle.X + Padding.Left, ClientRectangle.Y + Padding.Top,
				ClientRectangle.Width - Padding.Horizontal, ClientRectangle.Height - Padding.Vertical);
			base.OnPaint(e);
			e.Graphics.FillEllipse(AppPalette.HighlightBrush, rect);
			if (rect.Height - 3 <= Font.SizeInPoints && Text == kDefaultIconText)
				rect.DrawExclamation(e.Graphics, AppPalette.BackgroundBrush);
			else
			{
				rect.Inflate(-6, -1);
				//rect.Y = 0;
				rect.X += 1;
				rect.Y -= 1; // Annoying magic fudge factor because otherwise it is too low.

				TextRenderer.DrawText(e.Graphics, Text, Font, rect, AppPalette.Background, AppPalette.HilightColor,
					TextFormatFlags.HorizontalCenter | TextFormatFlags.Top);
			}
		}
	}
}


text:
import math
def sensible_range(min_value, max_value, significant_digits = 2):
    assert min_value < max_value
    def scaling_factor(value):
        # power of 10 to use to get correct precision
        return 10.0**(
            math.floor(math.log(abs(value), 10)) - (significant_digits - 1)
        )
    def sensible(value, round):
        if value == 0.0:
            return 0.0
        else:
            factor = scaling_factor(value)
            return round(value/factor) * factor
    range_mag = scaling_factor(
        sensible(max_value, math.ceil) - sensible(min_value, math.floor)
    )
    return (math.floor(min_value/range_mag) * range_mag,
        math.ceil(max_value/range_mag) * range_mag)

import unittest
class TestSensibleRange(unittest.TestCase):
    def sensible_range(test, args, (expected_lower_limit, expected_upper_limit)):
        (actual_lower_limit, actual_upper_limit) = sensible_range(*args)
        test.assertAlmostEquals(actual_lower_limit, expected_lower_limit)
        test.assertAlmostEquals(actual_upper_limit, expected_upper_limit)

    def test_1(test):
        test.sensible_range((-1234, 0.1, 2), (-1300.0, 100.0))

    def test_2(test):
        test.sensible_range((0.05, 0.1, 2), (0.05, 0.1))

    def test_3(test):
        test.sensible_range((0.0512, 0.1, 2), (0.051, 0.1))

    def test_4(test):
        test.sensible_range((-0.1, 0.0512, 2), (-0.1, 0.06))

    def test_0_sd(test):
        test.sensible_range((-0.1, 0.0512, 0), (-10.0, 10.0))

    def test_both_negative(test):
        test.sensible_range((-15765, -0.001, 2), (-16000.0, 0.0))

    def test_bad_range(test):
        test.assertRaises(AssertionError, sensible_range, 0.0, 0.0, 2)
        test.assertRaises(AssertionError, sensible_range, -0.0, 0.0, 2)
        test.assertRaises(AssertionError, sensible_range, 0.0, -0.0, 2)
        test.assertRaises(AssertionError, sensible_range, 10, -10000, 2)

suite = unittest.TestLoader().loadTestsFromTestCase(TestSensibleRange)
unittest.TextTestRunner(verbosity=2).run(suite)


text:
package org.citygml4j.core.model.ade.generic;

import org.citygml4j.core.model.transportation.ADEOfRoad;
import org.w3c.dom.Element;

public class GenericADEOfRoad extends ADEOfRoad implements ADEGenericProperty {
    private Element value;

    private GenericADEOfRoad(Element value) {
        this.value = value;
    }

    public static GenericADEOfRoad of(Element value) {
        return new GenericADEOfRoad(value);
    }

    @Override
    public Element getValue() {
        return value;
    }

    @Override
    public void setValue(Element value) {
        this.value = value;
    }
}