text:
<?php
$userRole = $this->session->userdata('role');
?>

USER DETAILS
                » <?php echo $details['user']->first_name . " " . $details['user']->last_name; ?>

                <li class="<?php echo(($this->uri->segment(4)) == 'overview' ? 'active' : '') ?>"><a
                            href="<?php echo base_url() ?>users/details/<?php echo $details['user']->uuid; ?>/overview">Overview

                <li id="nav_generalInformation2"
                    class="<?php echo(($this->uri->segment(2)) == 'profile' ? 'active' : '') ?>"><a
                            href="<?php echo base_url() ?>users/profile/<?php echo $details['user']->uuid; ?>">Profile

                <li id="nav_generalInformation3"
                    class="<?php echo(($this->uri->segment(4)) == 'notes' ? 'active' : '') ?>"><a
                            href="<?php echo base_url() ?>users/notes/<?php echo $details['user']->uuid; ?>">Notes

<?php
$message = $this->session->userdata('success');

if (isset($message)) { ?>

        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        <?php
        echo $message;
        $this->session->unset_userdata('success')
        ?>

<?php } ?>

<?php
$errors = $this->session->userdata('errors');
$oldValues = $this->session->userdata('oldValues');
?>

General Information

        <?php
        if ($userRole->slug == 'super-administrator') { ?>

                <a title="Delete this user?" href="/users/delete/<?php echo $details['user']->uuid; ?>" class="btn btn-sm btn-danger pull-right">Delete

        <?php } ?>

        <form class="form" method="post"
              action="<?php echo base_url() ?>users/updateProfile/<?php echo $details['user']->uuid; ?>"
              id="pupdate_puForm">

                    <input type="hidden" name="profile[user_id]"
                           value="<?php echo(isset($details['user']->user_id) ? $details['user']->user_id : ''); ?>">
                    <input type="hidden" name="profile[user_uuid]"
                           value="<?php echo(isset($details['user']->uuid) ? $details['user']->uuid : ''); ?>">

                        First Name
                        <input name="profile[first_name]" type="text"
                               value="<?php echo(isset($details['user']->first_name) ? $details['user']->first_name : ''); ?>"
                               class="form-control" placeholder="First name" required="required">
                        <?php echo(isset($oldValues['first_name']) ? $oldValues['first_name'] : '');
                        $this->session->unset_userdata('oldValues'); ?>
                        <?php
                        if (isset($errors['first_name'])) { ?>

                                    <?php
                                    echo $errors['first_name'][0];
                                    $this->session->unset_userdata('errors');
                                    ?>

                        <?php } ?>

                        Last Name
                        <input name="profile[last_name]" type="text"
                               value="<?php echo(isset($details['user']->last_name) ? $details['user']->last_name : ''); ?>"
                               class="form-control" placeholder="Last name" required="required">
                        <?php echo(isset($oldValues['last_name']) ? $oldValues['last_name'] : '');
                        $this->session->unset_userdata('oldValues'); ?>
                        <?php
                        if (isset($errors['last_name'])) { ?>

                                    <?php
                                    echo $errors['last_name'][0];
                                    $this->session->unset_userdata('errors');
                                    ?>

                        <?php } ?>

                        Family Name
                        <input name="profile[family_name]" type="text"
                               value="<?php echo(isset($details['user']->family_name) ? $details['user']->family_name : ''); ?>"
                               class="form-control" placeholder="Family name">

                        Nick Name
                        <input name="profile[nick_name]" type="text"
                               value="<?php echo(isset($details['user']->nick_name) ? $details['user']->nick_name : ''); ?>"
                               class="form-control" placeholder="Nick name">

                        Title
                        <select name="profile[title]" class="form-control">
                            <option value="" hidden>Choose one</option>
                            <option value="Mr" <?php echo $details['user']->title == 'Mr' ? 'selected' : ''; ?>>Mr
                            </option>
                            <option value="Mrs" <?php echo $details['user']->title == 'Mrs' ? 'selected' : ''; ?>>Mrs
                            </option>
                            <option value="Miss" <?php echo $details['user']->title == 'Miss' ? 'selected' : ''; ?>>
                                Miss
                            </option>
                            <option value="Ms" <?php echo $details['user']->title == 'Ms' ? 'selected' : ''; ?>>Ms
                            </option>
                            <option value="Dr" <?php echo $details['user']->title == 'Dr' ? 'selected' : ''; ?>>Dr
                            </option>
                        </select>

                        Timezone
                        <select name="profile[timezone]" id="time" class="form-control" required="required">
                            <option value="" hidden>Choose one</option>
                            <?php
                            foreach ($timezones as $timezone) { ?>
                                <option value="<?php echo $timezone; ?>" <?php echo ($timezone == $details['user']->timezone) ? 'selected' : '' ?>>
                                    <?php echo $timezone; ?>
                                </option>
                            <?php } ?>
                        </select>
                        <?php
                        if (isset($errors['timezone'])) { ?>

                                <?php
                                echo $errors['timezone'][0];
                                $this->session->unset_userdata('errors');
                                ?>

                        <?php } ?>

                        Gender
                        <select name="profile[gender]" class="form-control" style="color: grey" required="required">
                            <option value="" hidden>Choose one</option>
                            <option value="male" <?php echo($details['user']->gender == 'male' ? 'selected' : '') ?>>
                                Male
                            </option>
                            <option value="female" <?php echo($details['user']->gender == 'female' ? 'selected' : '') ?>>
                                Female
                            </option>
                        </select>
                        <?php
                        if (isset($errors['gender'])) { ?>

                                <?php
                                echo $errors['gender'][0];
                                $this->session->unset_userdata('errors');
                                ?>

                        <?php } ?>

                        Date of birth
                        <input name="profile[date_of_birth]" type="date"
                               value="<?php echo($details['user']->date_of_birth ?: ''); ?>" class="form-control">
                        <?php
                        if (isset($errors['date_of_birth'])) { ?>

                                <?php
                                echo $errors['date_of_birth'][0];
                                $this->session->unset_userdata('errors');
                                ?>

                        <?php } ?>

                        Language
                        <select name="profile[language]" class="form-control" style="color: grey">
                            <option value="" hidden>Choose one</option>
                            <option value="bn_BD" <?php echo($details['user']->language == 'bn_BD' ? 'selected' : ""); ?>>
                                Bangla
                            </option>
                            <option value="en_US" <?php echo($details['user']->language == 'en_US' ? 'selected' : ""); ?>>
                                English
                            </option>
                        </select>

            <button type="submit" class="btn btn-success" id="pu_btnUpdate">Update</button>
        </form>

<?php
if ($userRole->slug == 'super-administrator') { ?>

Roles and Access Control

                    <form class="form" method="post"
                          action="<?php echo base_url(); ?>users/roleAccessControll/<?php echo $details['user']->uuid; ?>"
                          id="pupdate_puForm">

                                    Is Visible
                                    <select name="users[is_visible]" class="form-control" style="color: grey">
                                        <option value="" hidden>Choose one</option>
                                        <option value="0" <?php echo($details['user']->is_visible == 0 ? 'selected' : ""); ?>>
                                            No
                                        </option>
                                        <option value="1" <?php echo($details['user']->is_visible == 1 ? 'selected' : ""); ?>>
                                            Yes
                                        </option>
                                    </select>

                                    Status
                                    <select name="users[status]" class="form-control" style="color: grey">
                                        <option value="" hidden="hidden">Choose one</option>
                                        <option value="0" <?php echo($details['user']->status == 0 ? 'selected' : ""); ?>>
                                            No
                                        </option>
                                        <option value="1" <?php echo($details['user']->status == 1 ? 'selected' : ""); ?>>
                                            Yes
                                        </option>
                                    </select>

                                    Roles
                                    <select multiple="multiple" name="roles[role_id]" class="form-control"
                                            style="color: grey">
                                        <option value="" hidden="hidden">Choose one</option>
                                        <?php
                                        $roleName = Roles_model::getName($details['user']->role_id);
                                        foreach ($roles as $role) { ?>
                                            <option value="<?php echo $role->id; ?>" <?php echo($role->name == $roleName->name ? 'selected' : ''); ?>><?php echo $role->name; ?></option>
                                        <?php } ?>
                                    </select>

                        <button type="submit" class="btn btn-success" id="pu_btnUpdate">Update</button>
                    </form>

Security Settings

                            <form class="form" method="post" action="" id="pupdate_puForm">

                                            First Question
                                            <select class="form-control"
                                                    name="user[security_questions_one]">
                                                <option value="" hidden="hidden">Please select one</option>
                                                <option value="What is your pet's name?" <?php echo($details['user']->security_questions_one == "What is your pet's name?" ? 'selected' : ""); ?>>
                                                    What is your pet's name?
                                                </option>
                                                <option value="In what year was your father born?" <?php echo($details['user']->security_questions_one == "In what year was your father born?" ? 'selected' : ""); ?>>
                                                    In what year was your father born?
                                                </option>
                                                <option value="What is your favorite color?" <?php echo($details['user']->security_questions_one == "What is your favorite color?" ? 'selected' : ""); ?>>
                                                    What is your favorite color?
                                                </option>
                                                <option value="What is your favorite game?" <?php echo($details['user']->security_questions_one == "What is your favorite game?" ? 'selected' : ""); ?>>
                                                    What is your favorite game?
                                                </option>
                                            </select>

                                            Answer
                                            <input type="text" class="form-control" value=""
                                                   name="user[security_questions_one_answer]" placeholder="Answer One">

                                            Second Question
                                            <select class="form-control"
                                                    name="user[security_questions_two]">
                                                <option value="" hidden="hidden">Please select one</option>
                                                <option value="What is your pet's name?" <?php echo($details['user']->security_questions_two == "What is your pet's name?" ? 'selected' : ""); ?>>
                                                    What is your pet's name?
                                                </option>
                                                <option value="In what year was your father born?" <?php echo($details['user']->security_questions_two == "In what year was your father born?" ? 'selected' : ""); ?>>
                                                    In what year was your father born?
                                                </option>
                                                <option value="What is your favorite color?" <?php echo($details['user']->security_questions_two == "What is your favorite color?" ? 'selected' : ""); ?>>
                                                    What is your favorite color?
                                                </option>
                                                <option value="What is your favorite game?" <?php echo($details['user']->security_questions_two == "What is your favorite game?" ? 'selected' : ""); ?>>
                                                    What is your favorite game?
                                                </option>
                                            </select>

                                            Answer
                                            <input type="text" class="form-control"
                                                   value=""
                                                   name="user[security_questions_two_answer]" placeholder="Answer Two">

                                            Password
                                            <input type="text" value="********"
                                                   class="form-control" placeholder="Password">

                                            Password Hash
                                            <input type="text" value="********"
                                                   class="form-control" placeholder="Password Hash"
                                                   disabled="disabled">

                                            Password Token
                                            <input type="text"
                                                   value="********"
                                                   class="form-control" placeholder="Password Token"
                                                   disabled="disabled">

                                            Password Last Modified
                                            <input name="profile[general][password_last_modified]" type="date"
                                                   value=""
                                                   class="form-control" placeholder="Password Token"
                                                   disabled="disabled">

                                            Password Last Modified IP
                                            <input name="profile[general][password_last_modified_ip]" type="text"
                                                   value=""
                                                   class="form-control"
                                                   placeholder="Password Last ModifiedIP"
                                                   disabled="disabled">

                                <input name="csrf_token" type="hidden" value="{{ csrf_token }}">
                                <button type="submit" class="btn btn-success"
                                        id="pu_btnUpdate">Update
                                </button>
                            </form>

<?php } ?>

<?php
$errors = $this->session->userdata('errors');
?>

Primary Address

        <form class="form" method="post" action="<?php echo base_url() ?>users/address/<?php echo $details['user']->uuid; ?>" id="pu_puAddForm">

                        Street Address *
                        <input name="address[street]" type="text"
                               value="<?php if (isset($details['address']) && $details['address']->street) {
                                   echo $details['address']->street;
                               } ?>" class="form-control"
                               placeholder="Street" required="required">
                        <?php
                        if (isset($errors['street'])) { ?>

                                    <?php
                                    echo $errors['street'][0];
                                    $this->session->unset_userdata('errors');
                                    ?>

                        <?php } ?>

                        Additional Street
                        <input name="address[street_secondary]" type="text"
                               value="<?php if (isset($details['address']) && $details['address']->street_secondary) {
                                   echo $details['address']->street_secondary;
                               } ?>"
                               class="form-control" placeholder="Additional Street">

                        City *
                        <input  name="address[city]" type="text"
                               value="<?php if (isset($details['address']) && $details['address']->city) {
                                   echo $details['address']->city;
                               } ?>"
                               class="form-control" placeholder="City name" required="required">
                        <?php
                        if (isset($errors['city'])) { ?>

                                    <?php
                                    echo $errors['city'][0];
                                    $this->session->unset_userdata('errors');
                                    ?>

                        <?php } ?>

                        State
                        <input name="address[state]" type="text"
                               value="<?php if (isset($details['address']) && $details['address']->state) {
                                   echo $details['address']->state;
                               } ?>" class="form-control" placeholder="State name">

                        Postal Code
                        <input name="address[postal_code]" type="text"
                               value="<?php if (isset($details['address']) && $details['address']->postal_code) {
                                   echo $details['address']->postal_code;
                               } ?>"
                               class="form-control" placeholder="Postal Code">

                        Country *
                        <select  name="address[country]" id="country" class="form-control" required="required">
                            <option value="" hidden>Choose one</option>
                            <?php
                            foreach ($countries as $country) { ?>
                                <option value="<?php echo $country; ?>" <?php if (isset($details['address']) && ($country == $details['address']->country)) {
                                    echo 'selected';
                                } ?>>
                                    <?php echo $country; ?>
                                </option>
                            <?php } ?>
                        </select>
                        <?php
                        if (isset($errors['country'])) { ?>

                                    <?php
                                    echo $errors['country'][0];
                                    $this->session->unset_userdata('errors');
                                    ?>

                        <?php } ?>

                        Phone *
                        <input  name="address[phone]" type="text"
                               value="<?php if (isset($details['address']) && $details['address']->phone) {
                                   echo $details['address']->phone;
                               } ?>" class="form-control" placeholder="Phone" required="required">
                        <?php
                        if (isset($errors['phone'])) { ?>

                                    <?php
                                    echo $errors['phone'][0];
                                    $this->session->unset_userdata('errors');
                                    ?>

                        <?php } ?>

                        Fax
                        <input name="address[fax]" type="text"
                               value="<?php if (isset($details['address']) && $details['address']->fax) {
                                   echo $details['address']->fax;
                               } ?>"
                               class="form-control" placeholder="Fax">

            <button type="submit" class="btn btn-success" id="pupdate_btnAUpdate">Update</button>
        </form>


text:
	<title>EECS 368 - Calculator</title>
	<link rel="stylesheet"
			href="calculator.css">

			  <input type="radio" name="inte_or_gra" id="display_graphing" checked>Graph
			  <input type="radio" name="inte_or_gra" id="display_integration">Integrate

			<button class="button" value = "1" id="One">1</button>
			<button class="button" value = "2" id="Two">2</button>
			<button class="button" value = "3" id="Three">3</button>

			<button class="button" value = "4" id="Four">4</button>
			<button class="button" value = "5" id="Five">5</button>
			<button class="button" value = "6" id="Six">6</button>

			<button class="button" value = "7" id="Seven">7</button>
			<button class="button" value = "8" id="Eight">8</button>
			<button class="button" value = "9" id="Nine">9</button>

			<button class="button" value = "0" id="Zero">0</button>
			<button class="button" value = "()" id="Parenthesis">( )</button>
			<button class="button" value = "^" id="Exponent">^</button>

			<button class="button" value = "*" id="Multiply">*</button>
			<button class="button" value = "/" id="Divide">/</button>
			<button class="button" value = "+" id="Plus">+</button>

			<button class="button" value = "-" id="Minus">-</button>
			<button class="button" value = "." id="Decimal">.</button>
			<button class="button" value = "x" id="Variable">x</button>

			<button class="button" id="ToClear">Clear</button>

			<button class="button" id="ToEvaluate" onclick="evaluate()">Evaluate</button>

		<canvas id="graph" height="512" width="512"></canvas>

		<input onclick="drawGraph()" type="submit" id="graphbutn" value="Graph It" class="graphButton">

		<input onclick="incrementXScale()" type="image" id="xScaleUp" value="Zoom X+" src="http://people.eecs.ku.edu/~slongofo/project/mockup_site/image/xplus.png" style="width:50;height:50;">
		<input onclick="decrementXScale()" type="image" id="xScaleDown" value="Zoom X-" src="http://people.eecs.ku.edu/~slongofo/project/mockup_site/image/xminus.png" style="width:50;height:50;">
		<input onclick="incrementYScale()" type="image" id="yScaleUp" value="Zoom Y+" src="http://people.eecs.ku.edu/~slongofo/project/mockup_site/image/yplus.png" style="width:50;height:50;">
		<input onclick="decrementYScale()" type="image" id="yScaleDown" value="Zoom Y-" src="http://people.eecs.ku.edu/~slongofo/project/mockup_site/image/yminus.png" style="width:50;height:50;">

X Scale: 8.00:1.0

Y Scale: 1.00:1.0

redpajama_set_name: RedPajamaGithub


text: It is, nothing more than it's intent at the moment.


text:
class FeedbackRatingsCalculator
  def initialize(applications)
    @apps_with_feedback = applications.where.not(feedback_rating: "unfilled")
  end

  def percentage(category)
    apps_of_type = apps_with_feedback.where(feedback_rating: category)

    ((apps_of_type.count.to_f / apps_with_feedback.count.to_f) * 100).round unless apps_with_feedback.empty?
  end

  def net_satisfaction_score(positive_value: "positive", negative_value: "negative")
    percentage(positive_value) - percentage(negative_value) unless apps_with_feedback.empty?
  end

  private

  attr_reader :apps_with_feedback
end


text:
QString priceToQString(uint64_t price) {
    QString priceInt = QString::number(price/STATS_PRICE_RATIO);
    uint64_t fraction = price % STATS_PRICE_RATIO;
    QString priceFract = QString::number(fraction);

    if ( fraction < 10 ) {
        priceFract.prepend("0");
    }

    return priceInt + "." + priceFract;
}

QString massToQString(uint64_t mass) {
    QString massInt = QString::number(mass/STATS_MASS_RATIO);
    uint64_t fraction = mass % STATS_MASS_RATIO;
    QString massFract = QString::number(fraction);

    if ( fraction < 10 ) {
        massFract.prepend("00");
    } else if ( fraction < 100 ) {
        massFract.prepend("0");
    }

    return massInt + "." + massFract;
}

QString fatsToQString(uint64_t fats) {
    QString fatsInt = QString::number(fats/STATS_FATS_RATIO);
    uint64_t fraction = fats % STATS_FATS_RATIO;
    QString fatsFract = QString::number(fraction);

    return fatsInt + "." + fatsFract;
}

QString proteinsToQString(uint64_t proteins) {
    QString proteinsInt = QString::number(proteins/STATS_PROTEINS_RATIO);
    uint64_t fraction = proteins % STATS_PROTEINS_RATIO;
    QString proteinsFract = QString::number(fraction);

    return proteinsInt + "." + proteinsFract;
}

QString carbohydratesToQString(uint64_t carbohydrates) {
    QString carbohydratesInt = QString::number(carbohydrates/STATS_CARBOHYDRATES_RATIO);
    uint64_t fraction = carbohydrates % STATS_CARBOHYDRATES_RATIO;
    QString carbohydratesFract = QString::number(fraction);

    return carbohydratesInt + "." + carbohydratesFract;
}

QString caloriesToQString(uint64_t calories) {
    return QString::number(calories);
}

uint64_t QStringToPrice(QString price) {
    return static_cast<uint64_t>(price.toDouble()*STATS_PRICE_RATIO);
}

uint64_t QStringToMass(QString mass) {
    return static_cast<uint64_t>(mass.toDouble()*STATS_MASS_RATIO);
}

uint64_t QStringToFats(QString fats) {
    return static_cast<uint64_t>(fats.toDouble()*STATS_FATS_RATIO);
}

uint64_t QStringToProteins(QString proteins) {
    return static_cast<uint64_t>(proteins.toDouble()*STATS_PROTEINS_RATIO);
}

uint64_t QStringToCarbohydrates(QString carbohydrates) {
    return static_cast<uint64_t>(carbohydrates.toDouble()*STATS_CARBOHYDRATES_RATIO);
}

uint64_t QStringToCalories(QString calories) {
    return static_cast<uint64_t>(calories.toDouble()*STATS_CALORIES_RATIO);
}


text:
var minimist = require('minimist');
var argv = minimist(process.argv.slice(2), {
    alias: {
        p: 'port', s: 'sslport',
        u: 'uid', g: 'gid',
        d: 'datadir', r: 'remote',
        redir: [ 'sslredirect', 'redirect' ],
        allowPost: 'allow-post', h: 'help'
    },
    default: {
        port: process.getuid() ? 8000 : 80,
        sslport: process.getuid() ? 8443 : 443,
        datadir: './htmlbin-data'
    }
});
var alloc = require('tcp-bind');
if (argv._[0] === 'server') {
    var fd = {
        http: alloc(argv.port),
        https: argv.key || argv.pfx ? alloc(argv.sslport) : null
    };
    if (argv.gid) process.setgid(argv.gid);
    if (argv.uid) process.setuid(argv.uid);
}

var http = require('http');
var https = require('https');
var mkdirp = require('mkdirp');
var url = require('url');
var defined = require('defined');
var fs = require('fs');
var path = require('path');

if (argv._[0] === 'help' || argv.help) {
    var r = fs.createReadStream(path.join(__dirname, 'usage.txt'));
    r.pipe(process.stdout);
}
else if (argv._[0] === 'server') {
    mkdirp.sync(argv.datadir);
    var level = require('level');
    var db = level(path.join(argv.datadir, 'db'), { valueEncoding: 'json' });

    var blob = require('content-addressable-blob-store');
    var store = blob({
        path: path.join(argv.datadir, 'blob'),
        algo: 'sha1'
    });
    var handle = require('../')(db, store, argv);

    if (fd.https) {
        if (fd.http && argv.sslredirect) {
            http.createServer(function (req, res) {
                var u = 'https://' + req.headers.host + req.url;
                res.statusCode = 301;
                res.setHeader('location', u);
                res.end();
            }).listen({ fd: fd.http });
        }
        else if (fd.http) {
            http.createServer(handle).listen({ fd: fd.http })
        }

        var opts = {};
        if (argv.key) opts.key = fs.readFileSync(argv.key);
        if (argv.cert) opts.cert = fs.readFileSync(argv.cert);
        if (argv.pfx) opts.pfx = fs.readFileSync(argv.pfx);

        var server = https.createServer(opts, handle);
        server.listen({ fd: fd.https }, function () {
            console.log('https://localhost:' + server.address().port);
        });
    }
    else {
        var server = http.createServer(handle);
        server.listen({ fd: fd.http }, function () {
            console.log('http://localhost:' + server.address().port);
        });
    }
}
else if (argv._[0] === 'upload' || argv._[0] === undefined) {
    var input = argv.infile
        ? fs.createReadStream(argv.infile)
        : process.stdin
    ;
    var config = getConfig();
    var remote = defined(argv.remote, config.remote);
    var u = url.parse(remote);
    var proto = u.protocol === 'https:' ? https : http;
    var r = input.pipe(proto.request({
        method: 'PUT',
        host: u.hostname,
        port: u.port,
        path: u.path
    }));
    r.on('response', function (res) {
        if (!/^2/.test(res.statusCode)) {
            console.error('error code ' + res.statusCode);
            res.pipe(process.stderr);
            res.on('end', function () { process.exit(1) });
        }
        else res.pipe(process.stdout);
    });
}
else if (argv._[0] === 'config' && argv._[1] === 'get') {
    console.log(getConfig()[argv._[2]]);
}
else if (argv._[0] === 'config' && argv._[1] === 'set') {
    var config = getConfig();
    config[argv._[2]] = argv._[3];
    setConfig(config);
}
else if (argv._[0] === 'config' && argv._[1] === 'list') {
    console.log(JSON.stringify(getConfig(), null, 2));
}
else if (argv._[0] === 'config' && argv._[1] === 'rm') {
    var config = getConfig();
    delete config[argv._[2]];
    setConfig(config);
}

function getConfig () {
    var file = configPath();
    mkdirp.sync(path.dirname(file));
    var config;
    try { config = require(file) }
    catch (err) { config = {} }
    if (!config.remote) config.remote = 'https://htmlb.in';
    return config;
}

function configPath () {
    var home = defined(process.env.HOME, process.env.USERPROFILE);
    return path.join(home, '.config/htmlbin.json');
}

function setConfig (config) {
    var file = configPath();
    mkdirp.sync(path.dirname(file));
    fs.writeFileSync(file, JSON.stringify(config, null, 2));
}


text:
layout: post
title: Setting up test Active Directory VMs on a Mac
date:
type: post
published: false
status: draft
categories: []
tags: []
meta:
  _publicize_twitter_user: "@dvdsmpsn"
  _edit_last: '1'
  _syntaxhighlighter_encoded: '1'
  _thumbnail_id: '3176'
author: David Simpson
excerpt_separator:
---

Previously, I've discussed Using a Vagrant built OpenLDAP server to test Enteprise Directory and Org Chart for Confluence. Now is the turn of Active Directory. This is somewhat more labourious because all steps are manually done, but you get a valid working VM at the end of the process.

Prerequisites

wget:

brew update

brew install wget

qemu-img:

brew install qemu

VMware Fusion -- buy it ;)

Procedure

You can download a 180 day evaluation of Windows Server 2008 R2 Enterprise Edition from Microsoft's Download Center.

Download and unarchive the source image

In terminal:

mkdir -p ~/tmp/vhd

cd ~/tmp/vhd

wget http://download.microsoft.com/download/5/4/C/54C15FA1-B3AA-4A8B-B26C-47C3BA7A20E0/WS2008R2Fullx64Ent.part01.exe

wget http://download.microsoft.com/download/5/4/C/54C15FA1-B3AA-4A8B-B26C-47C3BA7A20E0/WS2008R2Fullx64Ent.part02.rar

wget http://download.microsoft.com/download/5/4/C/54C15FA1-B3AA-4A8B-B26C-47C3BA7A20E0/WS2008R2Fullx64Ent.part03.rar

unrar x WS2008R2Fullx64Ent.part01.exe

Convert the original VHD image for VMware

cd ~/tmp/vhd/WS2008R2Fullx64Ent/WS2008R2Fullx64Ent/Virtual\ Hard\ Disks

This stalled after 20 minutes:

qemu-img convert -p -f vpc -O vmdk WS2008R2Fullx64Ent.vhd WS2008R2Fullx64Ent.vmdk

This worked and was much faster...

emu-img convert -O vmdk WS2008R2Fullx64Ent.vhd ~/tmp/WS2008R2Fullx64Ent.vmdk

The conversion takes approx 5 mins. Take a backup of the resulting file

Open VMware Fusion

File | New…

Click on "Continue without disc" & "Continue":

Select "Use an existing virtual disk:" and choose ~/tmp/WS2008R2Fullx64Ent.vmdk then "Continue"

Windows setup starts…

You need to change the Administrator password e.g. to Admin4test on setup completion.

Shutdown the VM and set the network config to Bridged Networking | Autodetect:

Restart the VM and continue with steps 5-7 from "How to create an Active Directory domain to test against" by Stef Walter:

Set the IP address

An Active Directory server acts as an LDAP and DNS server, and needs a static IP address.

Click Start  >  Network, and then click the Change adapter settings link in the window that comes up. Another window should appear.

Right click on the Local Area Connection item and chooseProperties in the menu.

Click on the Internet Protocol Version 4 (TCP/IPv4) item and then click the Properties button. A dialog for setting the addresses comes up.

		Choose Use the following IP address. Then set the relevant fields. The settings here are based on the virtual network you created above, if you used a different netblock then modify as appropriate:

		IP Address: <tt>192.168.0.101</tt>

		Subnet mask: <tt>255.255.255.0</tt>

		Default gateway: <tt>192.168.0.1</tt>

Click OK or Close in the various dialogs to complete things.

Set the machine name

An Active Directory server should have a well known DNS name, you don't need to set it in DNS, but just name the server appropriately and then Active Directory will do the rest.

Click Start > Computer, and a window should come up.

In the left pane of the window, there's an item called Computer.Right click on it and choose Properties from the menu. Another window should show up.

Click Change Settings, and a dialog will come up.

In the Computer Name tab click the Change... button, which displays another dialog.

Set <tt>DC</tt> as the Computer name or another name of your choice. Don't worry about the Member of Domain or Workgroup stuff yet.

Click OK and/or Close to complete the changes. You'll be prompted to restart, so go ahead and do that.

 Setting up Active Directory

Click Start > Run and type <tt>DCPROMO</tt> in the dialog that comes up.

A progress window will come up which explains about installing some components. This takes a while.

A wizard will eventually show up. Click through the introduction and warnings.

Choose Create a new domain in a new forest.

On the next page enter the domain -- we're using appfusions.local

Choose the Forest functional level. You can choose whichever one you like. Choosing 2008 R2 is a decent choice. You can test against various Active Directory servers with different levels to simulate different domains you might encounter in the wild.

Make sure DNS Server is chosen on the next page.

Once you complete that, a dialog will come up warning you about how the DNS delegation cannot be created. We'll do that manually below, so this is nothing to worry about. Choose Yes.

Leave the default paths for database and log files.

Choose a domain Administrator password. Logically this is different from the local server Administrator account you set the password for above. But you can use the same password to keep things simple. we're using Admin4test

Review the selections if you're interested, and then click Next to complete things.

Wait for a while for installation and configuration, Finish.

You'll need to Restart Now.

The reboot after installing Active Directory will take a while as it does a bunch of stuff on the first boot.

Adding some users

Click Start > Type "Server Manager"

In Server Manager, expand the tree Roles | Active Directory Domain Services | Active Directory Users and Computers [appfusions.local] | appfusions.local

Add some users

Uncheck User must change password at next login

Check Password never expires

From an external machine, check that you can connect to the AD:

ldapsearch -h 192.168.0.101 -p 389 -D "CN=Sametime User,CN=Users,DC=appfusions,DC=local" -w password -b CN=Users,DC=appfusions,DC=local "cn=David*"

# extended LDIF

#

# LDAPv3

# base <CN=Users,DC=appfusions,DC=local> with scope subtree

# filter: cn=DAVID*

# requesting: ALL

#

# David Simpson, Users, appfusions.local

dn: CN=David Simpson,CN=Users,DC=appfusions,DC=local

objectClass: top

objectClass: person

objectClass: organizationalPerson

objectClass: user

cn: David Simpson

sn: Simpson

givenName: David

distinguishedName: CN=David Simpson,CN=Users,DC=appfusions,DC=local

instanceType: 4

whenCreated: 20130430202315.0Z

whenChanged: 20130430202349.0Z

displayName: David Simpson

uSNCreated: 12725

uSNChanged: 12731

name: David Simpson

objectGUID:: jrlW2NfWXUqwpo/Ks6G6KQ==

userAccountControl: 66048

badPwdCount: 0

codePage: 0

countryCode: 0

badPasswordTime: 0

lastLogoff: 0

lastLogon: 0

pwdLastSet: 130118269951934678

primaryGroupID: 513

objectSid:: AQUAAAAAAAUVAAAATgHMeSBL+ixYUEeEUAQAAA==

accountExpires: 9223372036854775807

logonCount: 0

sAMAccountName: david

sAMAccountType: 805306368

userPrincipalName: david @ appfusions.local

objectCategory: CN=Person,CN=Schema,CN=Configuration,DC=appfusions,DC=local

dSCorePropagationData: 16010101000000.0Z

mail: david @ appfusions.com

# search result

search: 2

result: 0 Success

# numResponses: 2

# numEntries: 1

Update the hosts file on remote machines

Next if you want to refer to this machine as say dc.appfusions.com or even ad.vm.appfusions.com from another VM, remember to update the hosts file on that VM with:

192.168.0.101 dc.appfusions.com ad.vm.appfusions.com

See:

http://freeipa.org/page/Setting_up_Active_Directory_domain_for_testing_purposes

http://www.microsoft.com/en-us/download/details.aspx?id=2227

http://stef.thewalter.net/2012/08/how-to-create-active-directory-domain.html


text:
from __future__ import print_function
from django.core.management.base import BaseCommand, CommandError
from django.core import management
from random import random
import subprocess

class Command(BaseCommand):
    option_list = BaseCommand.option_list

    def __init__(self):
        BaseCommand.__init__(self)

    def handle(self, *args, **options):
        print('\033[0;43m\t\t\t\t\tgulp tasks\t\t\t\t'
              '\t\033[0;37m \nrandom = %s\033[0;00m' % int(random() * 1e10))
        subprocess.call("gulp", shell=True)
        print('')

        print('\033[0;42m\t\t\tdjango development server\t\t\t'
              '\033[0;32m \nrandom = %s\033[0;00m' % int(random() * 1e10))
        management.call_command('runserver')


text:
"""Tests for Softplus and SoftplusGrad."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import numpy as np

from tensorflow.python.framework import constant_op
from tensorflow.python.ops import gradient_checker
from tensorflow.python.ops import nn_ops
import tensorflow.python.ops.nn_grad  # pylint: disable=unused-import
from tensorflow.python.platform import test

class SoftplusTest(test.TestCase):

  def _npSoftplus(self, np_features):
    np_features = np.asarray(np_features)
    zero = np.asarray(0).astype(np_features.dtype)
    return np.logaddexp(zero, np_features)

  def _testSoftplus(self, np_features, use_gpu=False):
    np_softplus = self._npSoftplus(np_features)
    with self.test_session(use_gpu=use_gpu):
      softplus = nn_ops.softplus(np_features)
      tf_softplus = softplus.eval()
    self.assertAllCloseAccordingToType(np_softplus, tf_softplus)
    self.assertTrue(np.all(tf_softplus > 0))
    self.assertShapeEqual(np_softplus, softplus)

  def testNumbers(self):
    for t in [np.float16, np.float32, np.float64]:
      self._testSoftplus(
          np.array([[-9, 7, -5, 3, -1], [1, -3, 5, -7, 9]]).astype(t),
          use_gpu=False)
      self._testSoftplus(
          np.array([[-9, 7, -5, 3, -1], [1, -3, 5, -7, 9]]).astype(t),
          use_gpu=True)
      log_eps = np.log(np.finfo(t).eps)
      one = t(1)
      ten = t(10)
      self._testSoftplus(
          [
              log_eps, log_eps - one, log_eps + one, log_eps - ten,
              log_eps + ten, -log_eps, -log_eps - one, -log_eps + one,
              -log_eps - ten, -log_eps + ten
          ],
          use_gpu=False)
      self._testSoftplus(
          [
              log_eps, log_eps - one, log_eps + one, log_eps - ten,
              log_eps + ten - log_eps, -log_eps - one, -log_eps + one,
              -log_eps - ten, -log_eps + ten
          ],
          use_gpu=True)

  def testGradient(self):
    with self.test_session():
      x = constant_op.constant(
          [-0.9, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.7, 0.9],
          shape=[2, 5],
          name="x")
      y = nn_ops.softplus(x, name="softplus")
      x_init = np.asarray(
          [[-0.9, -0.7, -0.5, -0.3, -0.1], [0.1, 0.3, 0.5, 0.7, 0.9]],
          dtype=np.float32,
          order="F")
      err = gradient_checker.compute_gradient_error(
          x, [2, 5], y, [2, 5], x_init_value=x_init)
    print("softplus (float) gradient err = ", err)
    self.assertLess(err, 1e-4)

  def testWarnInts(self):
    # NOTE(irving): Actually I don't know how to intercept the warning, but
    # let's make sure it runs.  I promised I've looked, and there was a warning.
    with self.test_session():
      nn_ops.softplus(constant_op.constant(7)).eval()

if __name__ == "__main__":
  test.main()


text:
package com.tistory.devilnangel.autometer.common;

import com.tistory.devilnangel.autometer.ResultViewer;
import lombok.Data;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.util.Calculator;

import java.util.HashMap;

/**
 * @author k, Created on 16. 1. 31.
 */
@Slf4j
@Data
public class HTTPResultCalculator implements Runnable {

    private final AbstractQ q;
    private final HashMap<String, Calculator> calculators = new HashMap<String, Calculator>();
    private final Calculator totalCalculator = new Calculator("TOTAL");
    private ResultViewer resultViewer;

    public HTTPResultCalculator() { this(AbstractQ.EQ_SIZE); }
    public HTTPResultCalculator(int qsize) {
        q = new AbstractQ(qsize) {};
    }

    @Override
    public void run() {

        while (true) {
            try {
                AutometerHTTPSampleResult sampleResult = (AutometerHTTPSampleResult) q.take();
                addResult(sampleResult);
            } catch (InterruptedException e) {
                log.warn("interrupted", e);
                return;
            }
        }
    }

    private void addResult(@NonNull final AutometerHTTPSampleResult sampleResult) {
        Calculator calculator = null;

        String path = sampleResult.getURL().getPath();
        if (path != null && !calculators.containsKey(path)) {
            calculators.put(path, new Calculator(path));
        }
        if (path != null) calculator = calculators.get(path);
        if (calculator != null) calculator.addSample(sampleResult);

        totalCalculator.addSample(sampleResult);
        StatisticSample sample = new StatisticSample();
        sample.setName(totalCalculator.getLabel());
        sample.setRate(totalCalculator.getRate());
        sample.setAvgRate(totalCalculator.getMean());
        sample.setDeviation(totalCalculator.getStandardDeviation());
        sample.setErrorPercentage(totalCalculator.getErrorPercentage());
        sample.setBytesPerSec(totalCalculator.getBytesPerSecond());
        sample.setAvgPageBytes(totalCalculator.getAvgPageBytes());
        sample.setCpuBusyPercentage(sampleResult.getCpuBusy());
        sample.setCount(totalCalculator.getCount());
        sample.setMax(totalCalculator.getMax());
        sample.setMin(totalCalculator.getMin());
        sample.setTotalThread(sampleResult.getAllThreads());
        sample.setTimestamp(sampleResult.getTimeStamp());
        if (resultViewer != null) resultViewer.offer(sample);

    }

    public Thread start() {
        Thread t = new Thread(this);
        t.setDaemon(true);
        t.start();
        return t;
    }

    public void clear() throws AutoMeterException {
        doEndJob();
        resultViewer.clear();
        totalCalculator.clear();
        calculators.clear();
        q.clear();
    }

    private void doEndJob() {
        log.debug("calculate end");
    }

    public boolean offer(SampleResult sampleResult) { return q.offer(sampleResult); }
}