code
stringlengths
5
1.01M
repo_name
stringlengths
5
84
path
stringlengths
4
311
language
stringclasses
30 values
license
stringclasses
15 values
size
int64
5
1.01M
input_ids
listlengths
502
502
token_type_ids
listlengths
502
502
attention_mask
listlengths
502
502
labels
listlengths
502
502
// Copyright (c) 2015 by Contributors // This file contains the customization implementations of R module // to change behavior of libxgboost #include <xgboost/logging.h> #include "src/common/random.h" #include "./xgboost_R.h" // redirect the messages to R's console. namespace dmlc { void CustomLogMessage::Log(const std::string& msg) { Rprintf("%s\n", msg.c_str()); } } // namespace dmlc // implements rabit error handling. extern "C" { void XGBoostAssert_R(int exp, const char *fmt, ...); void XGBoostCheck_R(int exp, const char *fmt, ...); } namespace rabit { namespace utils { extern "C" { void (*Printf)(const char *fmt, ...) = Rprintf; void (*Assert)(int exp, const char *fmt, ...) = XGBoostAssert_R; void (*Check)(int exp, const char *fmt, ...) = XGBoostCheck_R; void (*Error)(const char *fmt, ...) = error; } } } namespace xgboost { ConsoleLogger::~ConsoleLogger() { dmlc::CustomLogMessage::Log(log_stream_.str()); } TrackerLogger::~TrackerLogger() { dmlc::CustomLogMessage::Log(log_stream_.str()); } } // namespace xgboost namespace xgboost { namespace common { // redirect the nath functions. bool CheckNAN(double v) { return ISNAN(v); } double LogGamma(double v) { return lgammafn(v); } // customize random engine. void CustomGlobalRandomEngine::seed(CustomGlobalRandomEngine::result_type val) { // ignore the seed } // use R's PRNG to replacd CustomGlobalRandomEngine::result_type CustomGlobalRandomEngine::operator()() { return static_cast<result_type>( std::floor(unif_rand() * CustomGlobalRandomEngine::max())); } } // namespace common } // namespace xgboost
RPGOne/Skynet
xgboost-master/R-package/src/xgboost_custom.cc
C++
bsd-3-clause
1,620
[ 30522, 1013, 1013, 9385, 1006, 1039, 1007, 2325, 2011, 16884, 1013, 1013, 2023, 5371, 3397, 1996, 7661, 3989, 24977, 1997, 1054, 11336, 1013, 1013, 2000, 2689, 5248, 1997, 5622, 2497, 2595, 18259, 9541, 3367, 1001, 2421, 1026, 1060, 18259, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php require_once('auth.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <?php include '../connect.php'; $result = $db->prepare("SELECT * FROM products where qty < level ORDER BY product_id DESC"); $result->execute(); $rowcount123 = $result->rowcount(); ?> <html> <head> <!-- js --> <link href="src/facebox.css" media="screen" rel="stylesheet" type="text/css" /> <script src="lib/jquery.js" type="text/javascript"></script> <script src="src/facebox.js" type="text/javascript"></script> <script type="text/javascript"> jQuery(document).ready(function($) { $('a[rel*=facebox]').facebox({ loadingImage : 'src/loading.gif', closeImage : 'src/closelabel.png' }) }) </script> <title> stock take </title> <link href="vendors/uniform.default.css" rel="stylesheet" media="screen"> <link href="css/bootstrap.css" rel="stylesheet"> <link rel="stylesheet" type="text/css" href="css/DT_bootstrap.css"> <link rel="stylesheet" href="css/font-awesome.min.css"> <style type="text/css"> body { padding-top: 60px; padding-bottom: 40px; } .sidebar-nav { padding: 9px 0; } </style> <link href="css/bootstrap-responsive.css" rel="stylesheet"> <script src="vendors/jquery-1.7.2.min.js"></script> <script src="vendors/bootstrap.js"></script> <link href="../style.css" media="screen" rel="stylesheet" type="text/css" /> </head> <?php function createRandomPassword() { $chars = "003232303232023232023456789"; srand((double) microtime() * 1000000); $i = 0; $pass = ''; while ($i <= 7) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $pass = $pass . $tmp; $i++; } return $pass; } $finalcode = 'INV-' . createRandomPassword(); ?> <body> <?php include 'navfixed.php';?> <?php $position = $_SESSION['SESS_LAST_NAME']; if ($position == 'cashier') { ?> <a href="sales.php?id=cash&invoice=<?php echo $finalcode ?>">Cash</a> <a href="../index.php">Logout</a> <?php } if ($position == 'admin' || 'cashier') { ?> <?php }?> </div><!--/.well --> </div> <div class="container"> <div class="contentheader"> <i class="icon-money"></i> stock take </div> <ul class="breadcrumb"> <a href="../main/index.php"><li>Dashboard</li></a> / <li class="active">stock take</li> </ul> <div style="margin-top: -19px; margin-bottom: 21px;"> <a href="../main/index.php"><button class="btn btn-success btn-large" style="float: none;" ><i class="icon icon-circle-arrow-left icon-large"></i> Back</button></a> </div> <div style="text-align:center;"> <font style="color:rgb(255, 95, 66);; font:bold 22px 'Aleo';"><?php echo $rowcount123; ?></font><a rel="facebox" href="level.php"> <button class="btn btn-primary">Low running products</button></a> </div> </div> <div class="container"> <form action="incoming.php" method="post" > <input type="hidden" name="pt" value="<?php echo $_GET['id']; ?>" /> <input type="hidden" name="invoice" value="<?php echo $_GET['invoice']; ?>" /> <select autofocus name="product" style="width:430px;font-size:0.8em;" class="chzn-select" id="mySelect"> <option></option> <?php include '../connect.php'; $result = $db->prepare("SELECT* FROM products RIGHT OUTER JOIN batch ON batch.product_id=products.product_id ORDER BY expirydate ASC"); $result->execute(); ?> <?php for ($i = 0; $row = $result->fetch(); $i++): ?> <option value="<?php echo $row['product_id']; ?>" data-qty="<?=$row['quantity'];?>" data-pr="<?=$row['o_price']*$row['markup'];?>" data-exp="<?=$row['expirydate'];?>" data-batch="<?=$row['batch_no'];?>" data-maxdisc="<?=$row['maxdiscre'];?>" data-maxdiscpc="<?=$row['maxdiscpr'];?>"> <?=$row['gen_name'];?> - <?=$row['product_code'];?> </option> <?php endfor;?> </select> <span id="price" contenteditable="true" name="price"></span> <script> $('#mySelect').on('change', function (event) { var selectedOptionIndex = event.currentTarget.options.selectedIndex; var price = event.currentTarget.value; var quantity = event.currentTarget.options[selectedOptionIndex].dataset.qty; var price = event.currentTarget.options[selectedOptionIndex].dataset.pr; var exp = event.currentTarget.options[selectedOptionIndex].dataset.exp; var batch = event.currentTarget.options[selectedOptionIndex].dataset.batch; var discountmax = event.currentTarget.options[selectedOptionIndex].dataset.maxdiscpc; var minprice = event.currentTarget.options[selectedOptionIndex].dataset.maxdisc; var myinput= document.getElementById('myqty'); var deviate= quantity-myinput; $('[name=qty]').val(quantity); $('[name=pr]').val(price); $('[name=exp]').val(exp); $('[name=batch]').val(batch); $('[name=deviate]').val(deviate); document.getElementById('deviate').value; }); </script> <script type="text/javascript"> </script> <input type="text" name="batch" placeholder="batch" autocomplete="off" style="width: 68px; height:30px; padding-top:6px; padding-bottom: 4px; margin-right: 4px; font-size:15px;"> <input name="qty" min="1" placeholder="in stock" autocomplete="off" id="deviatee" style="width: 68px; height:30px; padding-top:6px; padding-bottom: 4px; margin-right: 4px; font-size:15px;" readonly /> <input type="number" name="quantity" min="1" max="" placeholder="qty" id="myqty" style="width: 68px; height:30px; padding-top:6px; padding-bottom: 4px; margin-right: 4px; font-size:15px;" required> <input type="text" name="deviate" placeholder="deviation" id="deviate" style="width: 68px; height:30px; padding-top:6px; padding-bottom: 4px; margin-right: 4px; font-size:15px;" value="" readonly> <input name="exp" placeholder="expiry" autocomplete="off" style="width: 68px; height:30px; padding-top:6px; padding-bottom: 4px; margin-right: 4px; font-size:15px;" readonly /> <input type="hidden" name="pr" min="1" placeholder="price" id="fpr" step=".00001" style="width: 68px; height:30px; padding-top:6px; padding-bottom: 4px; margin-right: 4px; font-size:15px;"> <input type="hidden" name="pc" max="" placeholder="disc" id="disc" style="width: 68px; height:30px; padding-top:6px; padding-bottom: 4px; margin-right: 4px; font-size:15px;" /> <input type="hidden" name="date" value="<?php $date = date('Y-m-d'); $d11 = strtotime ( $date ) ; $d11 = date ('Y-m-d' , $d11); echo $d11; ?>" /> <Button type="submit" class="btn btn-info" style="width: 123px; height:35px; margin-top:-5px;" /><i class="icon-plus-sign icon-large" ></i> Add</button> </form> <table class="table table-bordered" id="resultTable" data-responsive="table"> <thead> <tr> <th> Product Name </th> <th> Generic Name </th> <th> Category / Description </th> <th> Qty </th> <th> deviation </th> <th> Action </th> </tr> </thead> <tbody> <?php $id = $_GET['invoice']; include '../connect.php'; $result = $db->prepare("SELECT * FROM sales_order sales_order RIGHT OUTER JOIN products ON products.product_id=sales_order.product WHERE invoice= :userid AND quantity!= ''"); $result->bindParam(':userid', $id); $result->execute(); for ($i = 1; $row = $result->fetch(); $i++) { ?> <tr class="record"> <td hidden><?php echo $row['product']; ?></td> <td><?php echo $row['product_code']; ?></td> <td><?php echo $row['gen_name']; ?></td> <td><?php echo $row['product_name']; ?></td> <td><?php echo $row['quantity']; ?></td> <td> <?php $dfdf = $row['quantity']-$row['balance']; echo $dfdf; ?> </td> <td width="90"><a rel="facebox" href="editsales.php?id=<?php echo $row['transaction_id']; ?>"><button class="btn btn-mini btn-warning"><i class="icon icon-edit"></i> edit </button></a> <a href="delete.php?id=<?php echo $row['transaction_id']; ?>&invoice=<?php echo $_GET['invoice']; ?>&dle=<?php echo $_GET['id']; ?>&qty=<?php echo $row['qty']; ?>&code=<?php echo $row['product']; ?>"><button class="btn btn-mini btn-warning"><i class="icon icon-remove"></i> Cancel </button></a> </tr> <?php } ?> </tbody> </table><br> <a rel="facebox" href="checkout.php?pt=<?php echo $_GET['id'] ?>&invoice=<?php echo $_GET['invoice'] ?>&total=<?php echo $fgfg ?>&totalprof=<?php echo $asd ?>&cashier=<?php echo $_SESSION['SESS_FIRST_NAME'] ?>"><button class="btn btn-success btn-large btn-block" accesskey="s"><i class="icon icon-save icon-large" accesskey="s"></i> SAVE</button></a> <div class="clearfix"></div> </div> </div> </body> <?php include 'footer.php';?> </html>
mathunjoroge/pharmacy
stocktake/stocktake.php
PHP
apache-2.0
8,600
[ 30522, 1026, 1029, 25718, 5478, 1035, 2320, 1006, 1005, 8740, 2705, 1012, 25718, 1005, 1007, 1025, 1029, 1028, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 1060, 11039, 19968, 1015,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Recurly PHP Client Library CHANGELOG ## Version 2.10.6 (October 30th, 2018) This release will upgrade us to API version 2.16. There are no breaking changes. * Added `details` to error messages [372](https://github.com/recurly/recurly-client-php/pull/372) * Added `charge` parameter to subscription termination functions [374](https://github.com/recurly/recurly-client-php/pull/374) * Fixed errors reported by PHPStorm [375](https://github.com/recurly/recurly-client-php/pull/375) * Added `account_acquisition` attribute to `account` [377](https://github.com/recurly/recurly-client-php/pull/377) * Fixed pager so it does not break when there is no data [378](https://github.com/recurly/recurly-client-php/pull/378) ## Version 2.10.5 (September 25th, 2018) This release will upgrade us to API version 2.15. There are no breaking changes. * Added `scripts` folder [364](https://github.com/recurly/recurly-client-php/pull/364) * Provide a correct recurly code when responding with a 404 [366](https://github.com/recurly/recurly-client-php/pull/366) * Add support for more webhooks [368](https://github.com/recurly/recurly-client-php/pull/368) ## Version 2.10.4 (August 21st, 2018) This release will upgrade us to API version 2.14. There are no breaking changes. * Update php version info [#355](https://github.com/recurly/recurly-client-php/pull/355) * Support updating an invoice [#360](https://github.com/recurly/recurly-client-php/pull/360) * Fix custom field serialization [#361](https://github.com/recurly/recurly-client-php/pull/361) * Support updating custom fields through Subscription#updateNotes [#362](https://github.com/recurly/recurly-client-php/pull/362) * Update README [#359](https://github.com/recurly/recurly-client-php/pull/359) ## Version 2.10.3 (June 26th, 2018) This release will upgrade us to API version 2.13. There are no breaking changes. * Add all_transactions link to Invoice [#350](https://github.com/recurly/recurly-client-php/pull/350) * Allow programmer to set gateway code in purchase [#351](https://github.com/recurly/recurly-client-php/pull/351) * External token support [#352](https://github.com/recurly/recurly-client-php/pull/352) * Support for custom fields [#353](https://github.com/recurly/recurly-client-php/pull/353) * Subscription terms [#356](https://github.com/recurly/recurly-client-php/pull/356) ## Version 2.10.2 (May 16th, 2018) This release will upgrade us to API version 2.12. There are no breaking changes. * API Version 2.12 [#348](https://github.com/recurly/recurly-client-php/pull/348) ## Version 2.10.1 (April 4th, 2018) This release will upgrade us to API version 2.11. There are no breaking changes. * API Version 2.11 [#342](https://github.com/recurly/recurly-client-php/pull/342) ## Version 2.10.0 (March 19th, 2018) This release will upgrade us to API version 2.10. * API Version 2.10 [#339](https://github.com/recurly/recurly-client-php/pull/339) * Add missing writeable fields to AddOn [#338](https://github.com/recurly/recurly-client-php/pull/338) * Removes links to singular subscription (thanks to @phpdave) [#340](https://github.com/recurly/recurly-client-php/pull/340) ### Upgrade Notes There are several breaking changes to support the new credit memos feature. #### 1. InvoiceCollection When creating invoices or using `markFailed()`, we now return an `Recurly_InvoiceCollection` object rather than an `Recurly_Invoice`. If you wish to upgrade your application without changing functionality, we recommend that you use the `charge_invoice` on the `Recurly_InvoiceCollection`. Example: ```php # Change This: $invoice = Recurly_Invoice::invoicePendingCharges('my_account_code'); # To this $invoiceCollection = Recurly_Invoice::invoicePendingCharges('my_account_code'); $invoice = $invoiceCollection->charge_invoice; ``` Calls that now return `InvoiceCollection` instead of `Invoice`: * `Recurly_Purchase::invoice()` * `Recurly_Purchase::preview()` * `Recurly_Purchase::authorize()` * `Recurly_Invoice::invoicePendingCharges()` * `Recurly_Invoice::previewPendingCharges()` Furthermore, `Recurly_Invoice->markFailed()` no longer updates the invoice but rather returns a new `Recurly_InvoiceCollection` object: ```php # Change This: $invoice->markFailed(); # To this $invoiceCollection = $invoice->markFailed(); $failedInvoice = $invoiceCollection->charge_invoice; ``` #### 2. Recurly_Invoice->original_invoice removed `Recurly_Invoice->original_invoice` was removed in favor of `Recurly_Invoice->original_invoices`. If you want to maintain functionality, change your code grab the first invoice from that endpoint: ```php # Change this $originalInvoice = $invoice->original_invoice->get(); # To this $originalInvoice = $invoice->original_invoices->get()->current(); # current is first item ``` #### 3. Invoice `subtotal_*` changes We have renamed two of the invoice subtotal fields to more clearly reflect their values: - Renamed `subtotal_in_cents` to `subtotal_before_discount_in_cents` - Renamed `subtotal_after_discount_in_cents` to `subtotal_in_cents` #### 4. Invoice Refund -- `refund_apply_order` changed to `refund_method` If you were using `Recurly_Invoice->refund` or `Recurly_Invoice->refundAmount` and explicitly setting the second `refund_apply_order` parameter, then you may need to change value to fit the new `refund_method` format. The values for this have changed from (`credit`, `transaction`) to (`credit_first`, `transaction_first`) If you don't explicitly set the `refund_apply_order` like in these two calls, no change is needed: ```php $invoice->refund($line_items); $invoice->refundAmount(1000); ``` If you do set the second param, you'll need to change: * `credit` to `credit_first` * `transaction` to `transaction_first` Examples: ```php # Change `credit`: $invoice->refund($line_items, 'credit'); $invoice->refundAmount(1000, 'credit'); # To `credit_first` $invoice->refund($line_items, 'credit_first'); $invoice->refundAmount(1000, 'credit_first'); # Change `transaction` $invoice->refund($line_items, 'transaction'); $invoice->refundAmount(1000, 'transaction'); # To `transaction_first` $invoice->refund($line_items, 'transaction_first'); $invoice->refundAmount(1000, 'transaction_first'); ``` #### 5. Invoice States If you are checking `Recurly_Invoice->state` anywhere, you will want to check that you have the new correct values. `collected` has changed to `paid` and `open` has changed to `pending`. Example: ```php # Change this if ($invoice->state == 'collected') # To this if ($invoice->state == 'paid') ``` ```php # Change this if ($invoice->state == 'open') # To this if ($invoice->state == 'pending') ``` This also affects the `Recurly_InvoiceList::getCollected()` and `Recurly_InvoiceList::getOpen()` functions. Example: ```php # Change this Recurly_InvoiceList::getCollected() # To this Recurly_InvoiceList::getPaid() ``` ```php # Change this Recurly_InvoiceList::getOpen() # To this Recurly_InvoiceList::getPending() ``` ## Version 2.9.0 (October 6th, 2017) This release will upgrade us to API version 2.8. - Added custom invoice notes to `Purchase` [#332](https://github.com/recurly/recurly-client-php/pull/332) - Added `imported_trial` boolean field to `Subscription` [#331](https://github.com/recurly/recurly-client-php/pull/331) ### Upgrade Notes There is one breaking changes in this API version you must consider. All `country` fields must now contain valid [2 letter ISO 3166 country codes](https://www.iso.org/iso-3166-country-codes.html). If your country code fails validation, you will receive a validation error. This affects any endpoint where an address is collected. ## Version 2.8.2 (July 21th, 2017) * Fixes a bug creating subscriptions for existing accounts (thanks to @g30rg) [#326](https://github.com/recurly/recurly-client-php/pull/326) ## Version 2.8.1 (July 14th, 2017) This bumps us to API v2.7 but does not contain any breaking changes. * Bump API v2.7 (purchase endpoint updates) [#319](https://github.com/recurly/recurly-client-php/pull/319) * Enhancement: Enable IntelliSense (IDE friendly) for class properties (Part 2) Invoice and Subscription (thanks to @phpdave) [#279](https://github.com/recurly/recurly-client-php/pull/279) ## Version 2.8.0 (June 7th, 2017) No changes from 2.8.0.rc1 ## Version 2.8.0.rc1 (June 2nd, 2017) * Remove 5.3 Support and upgrade Travis to support HHVM [#316](https://github.com/recurly/recurly-client-php/pull/316) * Purchases endpoint [#315](https://github.com/recurly/recurly-client-php/pull/315) * Remove X-Records header [#314](https://github.com/recurly/recurly-client-php/pull/314) * Add trial requires billing info field and no billing info reason field [#312](https://github.com/recurly/recurly-client-php/pull/312) ### Upgrade Notes There are a few breaking changes this release. 1. PHP 5.3 is no longer officially supported and we no longer run tests against it. 2. To speed up your listing requests we're no longer automatically computing the record counts for each request's `X-Records` header. For our larger sites this could halve the response time. If you still need a count it will be computed with a separate request. From now on, when you call `Recurly_Pager::count()`, it will send a HEAD request to the server. Ensure you aren't calling that method in places where you expect the value to be cached for you. For more information on how this may affect you, see PR [#314](https://github.com/recurly/recurly-client-php/pull/314) 3. For `POST /v2/subscriptions` Sending `null` for `total_billing_cycles` attribute will now override plan `total_billing_cycles` setting and will make subscription renew forever. Omitting the attribute will cause the setting to default to the value of plan `total_billing_cycles`. ## Version 2.7.2 (March 21st, 2017) * Require export files [#296](https://github.com/recurly/recurly-client-php/pull/296) * Writeable and updatable coupon description [#297](https://github.com/recurly/recurly-client-php/pull/297) * Adds a getType method to all Resources [#299](https://github.com/recurly/recurly-client-php/pull/299) * The Pager should implement the Countable interface (thanks to [naderman]()) [#282](https://github.com/recurly/recurly-client-php/pull/282) * Parse incorrectly shaped validation errors [#298](https://github.com/recurly/recurly-client-php/pull/298) * Adds external payments to invoices [#309](https://github.com/recurly/recurly-client-php/pull/309) * GiftCard: deliver_at goes on the Delivery object [#307](https://github.com/recurly/recurly-client-php/pull/307) * Changes for API v2.5 [#310](https://github.com/recurly/recurly-client-php/pull/310) ## Version 2.7.1 (January 9th, 2017) * Added property documentation to several classes (thanks to [phpdave](https://github.com/phpdave)) [#278](https://github.com/recurly/recurly-client-php/pull/278) * Added company attribute to billing info [#280](https://github.com/recurly/recurly-client-php/pull/280) * Fixed add-on creation bug [#286](https://github.com/recurly/recurly-client-php/pull/286) * Create shipping addresses on existing accounts and allow updates [#289](https://github.com/recurly/recurly-client-php/pull/289) * Adding ability to get Recurly error code from Recurly_Error Exception [#291](https://github.com/recurly/recurly-client-php/pull/291) ## Version 2.7.0 (September 15th, 2016) * Upgraded to API V2.4: https://dev.recurly.com/v2.4/docs * Fix for client not being passed from `Recurly_Pager` to its items (thanks to [cyruscollier](https://github.com/cyruscollier)) [#265](https://github.com/recurly/recurly-client-php/pull/265) * Adding missing require for `account_balance` [#273](https://github.com/recurly/recurly-client-php/pull/273) * Allow credit adjustments (`Recurly_Adjustment`) to specify an `origin` of `external_gift_card` [#263](https://github.com/recurly/recurly-client-php/pull/263) * Added `Recurly_AccountAcquisition` [#259](https://github.com/recurly/recurly-client-php/pull/259) * Added support for automated exports [#260](https://github.com/recurly/recurly-client-php/pull/260) * Added support for shipping addresses [#269](https://github.com/recurly/recurly-client-php/pull/269) * Added filters to `Recurly_Stub` allowing `$account->invoices->get(array('state' => 'past_due'))` (thanks to [developer-devPHP](https://github.com/developer-devPHP)) [#270](https://github.com/recurly/recurly-client-php/pull/270) ## Version 2.6.0 (August 9th, 2016) * Upgraded to API V2.3: https://dev.recurly.com/v2.3/docs * Added support for `original_transaction` to `Recurly_Transaction` [#238](https://github.com/recurly/recurly-client-php/pull/238) * Added `Recurly_AccountBalance` [#239](https://github.com/recurly/recurly-client-php/pull/239) * Print warnings when using a deprecated version of the API. [#250](https://github.com/recurly/recurly-client-php/pull/250): * Added support new pagination options [#249](https://github.com/recurly/recurly-client-php/pull/249): - `sort` accepts `created_at` or `updated_at`, defaults to `created_at`. - `order` accepts `desc` or `asc`, defaults to `desc`. - `begin_time` and `end_time` accepts an ISO 8601 date or date and time. * Changed `Recurly_AddonList::get()` and `Recurly_NoteList::get()` to add `$params` as the second parameter so sort, order and date filtering can be passed in [#249](https://github.com/recurly/recurly-client-php/pull/249) * Added support for `revenue_schedule_type` to `Recurly_Addon`, `Recurly_Adjustment`, `Recurly_Plan`, `Recurly_Subscription` and `Recurly_SubscriptionAddOn` classes [#257](https://github.com/recurly/recurly-client-php/pull/257) ## Version 2.5.3 (July 5th, 2016) * Added support for setting `free_trial_amount` and `free_trial_unit` to `Recurly_Coupon` [#224](https://github.com/recurly/recurly-client-php/pull/224) * Fix PHP 7 notice (thanks to [davedevelopment](https://github.com/davedevelopment)) [#235](https://github.com/recurly/recurly-client-php/pull/235) * Fix for fetching `Recurly_NoteList` [#236](https://github.com/recurly/recurly-client-php/pull/236) * Fix for updating subscriptions with add-ons [#242](https://github.com/recurly/recurly-client-php/pull/242) * Fix for paginating `Recurly_CouponRedemptionList` and `Recurly_UniqueCouponCodeList` [#243](https://github.com/recurly/recurly-client-php/pull/243) * Use standard PHPUnit configuration file name (thanks to [davedevelopment](https://github.com/davedevelopment)) [#234](https://github.com/recurly/recurly-client-php/pull/234) * Removed old transparent post path constants [#237](https://github.com/recurly/recurly-client-php/pull/237) * Provide default implementation for `getRequiredAttributes()` [#241](https://github.com/recurly/recurly-client-php/pull/241) ## Version 2.5.2 (June 7th, 2016) * Added support for parsing `fraud` attribute on the `Transaction` class [#228](https://github.com/recurly/recurly-client-php/pull/228) * Added support for setting `start_date` and `end_date` when creating an `Adjustment` (thanks to [imsagar](https://github.com/imsagar)) [#229](https://github.com/recurly/recurly-client-php/pull/229) * Added support for Usage Based Billing [#227](https://github.com/recurly/recurly-client-php/pull/227) ## Version 2.5.1 (February 19th, 2016) * Added support for `cc_emails` attribute on the `Account` class [#202](https://github.com/recurly/recurly-client-php/pull/202) * Fix bug with incorrect `delete_uri` on the `Redemption` class [#201](https://github.com/recurly/recurly-client-php/pull/201) * Added `currency` attribute to `BillingInfo` [#205](https://github.com/recurly/recurly-client-php/pull/205) ## Version 2.5.0 (January 13th, 2016) * Removed `nestedAttributes` [#191](https://github.com/recurly/recurly-client-php/pull/191) * Added support for coupon `update` and `restore` actions [#186](https://github.com/recurly/recurly-client-php/pull/186) * Added support bulk coupons and generation [#188](https://github.com/recurly/recurly-client-php/pull/188) ## Version 2.4.6 (September 15th, 2015) * Added `setup_fee_accounting_code` to `Plan` [#179](https://github.com/recurly/recurly-client-php/pull/179) * Added `applies_to_non_plan_charges` to `Coupon` [#181](https://github.com/recurly/recurly-client-php/pull/181) * Added `redemption_resource` to `Coupon` [#181](https://github.com/recurly/recurly-client-php/pull/181) * Added `X-Api-Version` request header at 2.1 [#181](https://github.com/recurly/recurly-client-php/pull/181) * Added `uuid` to `Account` [#181](https://github.com/recurly/recurly-client-php/pull/181) * Added `redemptions` to `Account` [#181](https://github.com/recurly/recurly-client-php/pull/181) * Added `max_redemptions_per_account` to `Coupon` [#181](https://github.com/recurly/recurly-client-php/pull/181) * Added `redemptions` to `Subscription` [#181](https://github.com/recurly/recurly-client-php/pull/181) * Added `coupon_codes` to `Subscription` [#181](https://github.com/recurly/recurly-client-php/pull/181) * Added `CACertPath` to `Recurly_Client` [#176](https://github.com/recurly/recurly-client-php/pull/176) ## Version 2.4.5 (August 3, 2015) * Added `duration`, `temporal_unit`, & `temporal_amount` to `Coupon` [#171](https://github.com/recurly/recurly-client-php/pull/171) ## Version 2.4.4 (July 2nd, 2015) * Added `gateway_error_code` to `Recurly_Transaction` [#163](https://github.com/recurly/recurly-client-php/pull/163) * Add support for `refund_apply_order` when performing an open amount or line item refund [#161](https://github.com/recurly/recurly-client-php/pull/161)] * Add `tax_exempt`, `tax_code` to `Recurly_Transaction` [#166](https://github.com/recurly/recurly-client-php/pull/166) * Add `Recurly_CouponRedemptionList` (thanks to [Flambe](https://github.com/Flambe)) [#164](https://github.com/recurly/recurly-client-php/pull/164) ## Version 2.4.3 (June 4th, 2015) * Fixed bug where fetching an invoice PDF did not use the invoice number prefix [#155](https://github.com/recurly/recurly-client-php/pull/155) * Added bank account attributes to `Recurly_BillingInfo`, these include: + `name_on_account` + `account_type` (`checking` or `savings`) + `last_four` + `routing_number` * [#153](https://github.com/recurly/recurly-client-php/pull/153) * Added `ip_address` attribute to `Recurly_Transaction`[#157](https://github.com/recurly/recurly-client-php/pull/157) * Added `bank_account_authorized_at` to `Recurly_Subscription` [#156](https://github.com/recurly/recurly-client-php/pull/156) * Add invoice node to `Recurly_PushNotification` to read data on *_invoice_notification (thanks to [rikless](https://github.com/rikless)) [#159](https://github.com/recurly/recurly-client-php/pull/159) ## Version 2.4.2 (Apr 14th, 2015) * Fixes encoding of values with ampersands [#150](https://github.com/recurly/recurly-client-php/issues/150) ## Version 2.4.1 (Feb 6th, 2015) * Added adjustment refund support: `refund()` and `toRefundAttributes()` on `Recurly_Adjustment` [#133](https://github.com/recurly/recurly-client-php/pull/133) * Added invoice refund support: `refund()` and `refundAmount()` on `Recurly_Invoice` [#133](https://github.com/recurly/recurly-client-php/pull/133) ## Version 2.4.0 (Feb 2nd, 2015) * Force cURL to validate SSL certificates [#122](https://github.com/recurly/recurly-client-php/pull/122) * Reverted #64, removing `balance_in_cents_invoiced` and `balance_in_cents_uninvoiced` from `Recurly_Account`. They were never added to the API. * Added `tax_code` to `Recurly_Plan`, `Recurly_Addon` and `Recurly_Adjustment` [#120](https://github.com/recurly/recurly-client-php/pull/120) * Added invoice previews: `Recurly_Invoice::previewPendingCharges($accountCode)` [#112](https://github.com/recurly/recurly-client-php/pull/112) * Added `terms_and_conditions` and `customer_notes` to `Recurly_Invoice` [#115](https://github.com/recurly/recurly-client-php/pull/115) * Added `vat_location_valid` field to `Recurly_Account` [#127](https://github.com/recurly/recurly-client-php/pull/127) * Added `updateNotes()` and `vat_reverse_charge` to `Recurly_Subscription` [#128](https://github.com/recurly/recurly-client-php/pull/128) * Added `vat_reverse_charge_notes` to `Recurly_Invoice` [#128](https://github.com/recurly/recurly-client-php/pull/128) * Added `invoice_number_prefix` and `invoiceNumberWithPrefix()` to `Recurly_Invoice`. This is to be used with the Country Invoice Sequencing feature. [#130](https://github.com/recurly/recurly-client-php/pull/130) * Added `collection_method`, `net_terms` and `po_number` to `Recurly_Invoice` [#131 by dmatora](https://github.com/recurly/recurly-client-php/pull/131) ## Version 2.3.1 (Sept 26th, 2014) * Added remaining billing cycles to subscriptions: `$subscription->remaining_billing_cycles` [#91](https://github.com/recurly/recurly-client-php/pull/91) * Added subscription change preview for existing subscriptions: `$subscription->preview()` [#94](https://github.com/recurly/recurly-client-php/pull/94) * Remove readme reference to RecurlyJS v2 private key [#97](https://github.com/recurly/recurly-client-php/pull/97) * Adding bulk parameter to subscription creation [#98](https://github.com/recurly/recurly-client-php/pull/98) * Added account entity use code: `$account->entity_use_code` [#100](https://github.com/recurly/recurly-client-php/pull/100) * Added PHP 5.6 and HHVM to `travis.yml` (thanks to [Nyholm](https://github.com/Nyholm)) [#101](https://github.com/recurly/recurly-client-php/pull/101) * Update branch alias to 2.3.x-dev (thanks to [bangpound](https://github.com/bangpound)) [#102](https://github.com/recurly/recurly-client-php/pull/102) * Bump phpunit to 4.2 [#103](https://github.com/recurly/recurly-client-php/pull/103) * Adds PayPal and Amazon support to `Recurly_BillingInfo` [#104](https://github.com/recurly/recurly-client-php/pull/104) * Adding bulk parameter to `$subscription->postpone()` [#105](https://github.com/recurly/recurly-client-php/pull/105) ## Version 2.3.0 (May 19th, 2014) * Added tax details to adjustments: `$adjustment->tax_details` [#90](https://github.com/recurly/recurly-client-php/pull/90) * Added subscription previews: `$subscription->preview()` [#90](https://github.com/recurly/recurly-client-php/pull/90) ## Version 2.2.6 (May 9th, 2014) * Added support for `Recurly_Account` field `balance_in_cents_invoiced` [#64](https://github.com/recurly/recurly-client-php/pull/64) * Added support for `Recurly_Account` field `balance_in_cents_uninvoiced` [#64](https://github.com/recurly/recurly-client-php/pull/64) * Added support for `Recurly_BillingInfo` field `token_id` [#83](https://github.com/recurly/recurly-client-php/pull/83) * Fixed bug in parsing large XML responses [#88](https://github.com/recurly/recurly-client-php/pull/88) ## Version 2.2.5 (Apr 24th, 2014) * Explictly call `Recurly_Resource`'s constructor [#67](https://github.com/recurly/recurly-client-php/pull/67) * More tests for coupons [#77](https://github.com/recurly/recurly-client-php/pull/77) * Document where new releases are announced in the README [#78](https://github.com/recurly/recurly-client-php/pull/78) * Fixed error where where `Recurly_Addon` was not found [#79 by baxevanis](https://github.com/recurly/recurly-client-php/pull/79) * Fixed bug setting account address [#80 by deviantintegral](https://github.com/recurly/recurly-client-php/pull/80) ## Version 2.2.4 (Jan 7th, 2014) * Fixed error when trying to redeem expired or maxed out coupons (thanks to [jeffchannell](https://github.com/jeffchannell)) * Improved documentation of `Recurly_PushNotification` (thanks to [richardkmiller](https://github.com/richardkmiller)) * Updated XML in test fixtures * Better tests for `Recurly_Adjustment` ## Version 2.2.3 (Nov 11th, 2013) * Use PHPUnit for testing * Remove old `taxable` parameter from `Recurly_Adjustment` * Send `null` attributes because `Recurly_PlanTest` needs `total_billing_cycles` to be set to `null` for unlimited renewals. ## Version 2.2.2 (Oct 7th, 2013) * Fixed errors thrown due to empty XML strings #62 [beaudesigns](https://github.com/beaudesigns) ## Version 2.2.1 (July 19th, 2013) * Fixed invalid XML errors when saving subscriptions with add-ons. * Added support for manual payments * Added support for account level address * Moved VAT number to Account ## Version 2.2.0 (May 10, 2013) * Added support for client subdomains, the default of 'api' should be fine for most users. * Added support for fetching account notes. ## Version 2.1.4 (February 19, 2013) * Fixed fatal error in `Recurly_Invoice::getInvoicePdf()`. * Fixed fatal error in `Recurly_Account::close()`. * Added `reopen()` and `reopenAccount` to `Recurly_Account`. ## Version 2.1.3 (February 8, 2013) * Added Composer support (SimpleTest is no longer bundled, use `composer install --dev` to install it) * Added `Recurly_AccountList::getClosed()` * Added `update()` and `accounting_code` to `Recurly_Addon` and `Recurly_Transaction` * Improved test coverage * Lists now implement Countable and IteratorAggregate * Fixed fatal errors in delete methods * Fixed problems marking invoices successful/failed ## Version 2.1.2 (June 7, 2012) * Support marking invoices as successful/failed * Add subscriptions postpone functionality * Support for subscriptions 'first_renewal_date' attribute. * Fix problem where require parameters are sometimes not sent in requests (such as account_code). * Fix un-pageable array results (no href is present), such as invoice/transactions. * Fix transaction refunding, which was sending to a deprecated route. ## Version 2.1.1 (March 13, 2012) * Fix Recurly.js token retrieval ## Version 2.1.0 (March 2, 2012) * Improved Recurly.js support for Recurly.js v2.1.x. Supports optional parameters, simplified signatures, etc. NOTE: Recurly.js signature and result retrieval is not backwards compatible with 2.0.x version of the client. ## Version 2.0.8 (February 22, 2012) * Better parsing of transaction errors on one-time transaction requests. * Parse an array of plan_codes as strings in the coupon response. ## Version 2.0.7 (November 30, 2011) * Update subscription create URL to the endpoint that auto-creates the account if it does not exist. * Accept transaction description. ## Version 2.0.6 (November 29, 2011) * Fix creating subscription when add-ons is an empty array. Added tests. ## Version 2.0.5 (November 20, 2011) * Always send list of addons when performing a subscription update. * Fixed URL for `Recurly_CouponRedemption::get()`. * Added `Recurly_TransactionList::getForAccount()`. * Add coupon redemption via `$coupon->redeemCoupon('account_code')`. * Properly encode `plan_codes` when limiting coupons to specific plans. ## Version 2.0.4 (November 16, 2011) * Support for creating a subscription with add-ons (thanks to @qqqq). * Attributes with a date are now DateTime objects instead of epoch timestamps. ## Version 2.0.3 (November 9, 2011) * Use `rawurlencode()` instead of `urlencode()` to create resource URLs. Required for URLs that contain spaces * Raise `Recurly_ValidationError` for 422 instead of `Recurly_RequestError`. Bug introduced in earlier commit today ## Version 2.0.2 (November 9, 2011) * Fix `Recurly_InvoiceList::getForAccount()`, `SubscriptionList::getForAccount()` * Interpret 4xx as request errors and 5xx as server errors for future error codes ## Version 2.0.1 (November 2, 2011) * Include method to retrieve invoice as PDF Merged fixes from [beaudesigns](https://github.com/beaudesigns): * Replaced static class to DomDocument::loadXML() * "pending_subscription" now loads class `Recurly_Subscription` * Fixed references to $this that should have been local scopes ## Version 2.0.0 (October 18, 2011) * Full rewrite for API v2
developer-devPHP/recurly-client-php
CHANGELOG.md
Markdown
mit
27,704
[ 30522, 1001, 28667, 3126, 2135, 25718, 7396, 3075, 2689, 21197, 1001, 1001, 2544, 1016, 1012, 2184, 1012, 1020, 1006, 2255, 13293, 1010, 2760, 1007, 2023, 2713, 2097, 12200, 2149, 2000, 17928, 2544, 1016, 1012, 2385, 1012, 2045, 2024, 2053,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
//Create an event node var Event = (function($) { return function(properties) { this.properties = properties; this.blip = null; this.listing = null; this.className = properties.event_type_name.replace(/[^\w]/ig,"-").toLowerCase(); this.LatLng = [parseFloat(this.properties.latitude), parseFloat(this.properties.longitude)]; this.startTime = moment(this.properties.start_dt)._d; this.endTime = this.properties.end_dt ? moment(this.properties.end_dt)._d : null; this.visible = true; if (this.properties.capacity) { this.properties.capacity = parseInt(this.properties.capacity); } if (this.properties.attendee_count) { this.properties.attendee_count = parseInt(this.properties.attendee_count); } this.isFull = this.properties.attendee_count && this.properties.capacity > 0 && this.properties.attendee_count >= this.properties.capacity; this.render = function (distance, zipcode) { var that = this; var moreThan5RSVP = that.properties.attendee_count && parseInt(that.properties.attendee_count) > 5 ? true : false; if (!that.properties.attendee_count) { moreThan5RSVP = false; } var datetime = that.properties.id_obfuscated && that.properties.id_obfuscated == '4gw5k' ? 'Mar 20 (Sun) 11:00am' : moment(that.properties.start_dt).format("MMM DD (ddd) h:mma") var lat = that.properties.latitude var lon = that.properties.longitude var endtime = that.endTime ? moment(that.endTime).format("h:mma") : null; var shiftElems = null; if ( that.properties.shift_details ) { var shiftList = that.properties.shift_details.map( function(item) { var current = moment(); var start = moment(item.start); var end = moment(item.end); if (end.isBefore(current)) { return; } return $("<li />") .append($("<input type='checkbox' value='" + item.event_shift_id + "' id='" + item.event_shift_id + "' name='shift_id[]'>")) .append("<label for='" + item.event_shift_id + "'>" + start.format("h:mma") + " - " + end.format("h:mma")) } ); shiftElems = $("<div class='shift-details'/>") .append("<h5>Shifts</h5>") .append($("<ul/>").append(shiftList)) } // end of creating shift items var rendered = $("<div class='lato'/>") .addClass('event-item ' + that.className) .append($("<div />").addClass('event-item lato ' + that.className+'').attr("lat",lat).attr("lon",lon) //appended lat-lon attributes to this class for marker highlighting .append(that.properties.is_campaign_office ? $("<a class='office-image' href='" + (that.properties.opening_event ? that.properties.opening_event : that.properties.url) + "' />").append($("<img src='" + that.properties.image + "'>")) : "") .append($("<h5 class='time-info'/>").html((distance ? ("<span class='time-info-dist'>" + distance + "mi &nbsp;&nbsp;</span>") : "") + datetime + (endtime ? " - " + endtime : "" ))) .append($("<h3/>").html("<a target='_blank' href='" + (that.properties.opening_event ? that.properties.opening_event : that.properties.url) + "'>" + that.properties.name + "</a>")) .append(that.properties.is_official ? $("<h5 class='official-tag'/>").text("Official Event") : "") .append($("<span/>").addClass("label-icon")) .append($("<h5 class='event-type'/>").text(that.properties.event_type_name)) .append($("<p/>").html(that.properties.location)) .append(that.properties.phone && that.properties.phone != "-" ? $("<p/>").text("Phone: " + that.properties.phone) : "") .append(that.properties.notes ? that.properties.notes : "") //Append RSVP Form .append($("<div class='event-rsvp-activity' />") .append($("<form class='event-form lato'>") .append($("<h4/>").html("RSVP to <strong>" + that.properties.name + "</strong>")) .append($("<div class='event-error' />")) .append(shiftElems ? shiftElems : "") // .append($("<input type='text' name='name' placeholder='Name'/>")) .append($("<input type='hidden' name='has_shift'/>").val(shiftElems != null)) .append($("<input type='hidden' name='zipcode'/>").val(zipcode?zipcode:that.properties.venue_zip)) .append($("<input type='hidden' name='id_obfuscated'/>").val(that.properties.id_obfuscated)) .append($("<input type='text' name='phone' placeholder='Phone Number'/>")) .append($("<input type='text' name='email' placeholder='Email Address'/>")) .append($("<input type='submit' class='lato' value='Confirm RSVP' />")) ) ) .append( $("<div class='social-area' />") .addClass(moreThan5RSVP ? "more-than-5" : "") .append( $("<a class='rsvp-link'/>") .attr("href", that.properties.is_campaign_office ? (that.properties.opening_event ? that.properties.opening_event : that.properties.url) : "javascript: void(null) ") .attr("onclick", that.properties.is_campaign_office ? null: "$('.event-rsvp-activity').hide(); $(document).trigger('show-event-form', [this])") // .attr('target', 'blank') // .attr("href", that.properties.is_campaign_office ? (that.properties.opening_event ? that.properties.opening_event : that.properties.url) : that.properties.url) .attr("data-id", that.properties.id_obfuscated) .attr("data-url", (that.properties.opening_event ? that.properties.opening_event : that.properties.url)) .text(that.isFull ? "FULL" : that.properties.is_campaign_office ? (that.properties.opening_event ? "RSVP" : "Get Directions") : "RSVP") ) .append( $("<span class='rsvp-count'/>").text(that.properties.attendee_count + " SIGN UPS") ) ) .append($("<div class='rsvp-attending'/>").html('<a href="https://go.berniesanders.com/page/event/myevents" target="_blank">You are attending this event</a>')) ); return rendered.html(); }; } })(jQuery); //End of events // /**** // * Campaign Offices // */ // var CampaignOffices = (function($) { // return function(properties) { // this.properties = properties; // this.render = function (distance) { // var that = this; // var moreThan5RSVP = that.properties.attendee_count && parseInt(that.properties.attendee_count) > 5 ? true : false; // if (!that.properties.attendee_count) { moreThan5RSVP = false; } // var datetime = moment(that.properties.start_dt).format("MMM DD (ddd) h:mma") // var rendered = $("<div class='lato'/>") // .addClass('event-item ' + that.className) // .append($("<h5 class='time-info'/>").html((distance ? (distance + "mi &nbsp;&nbsp;") : "") + datetime)) // .append($("<h3/>").html("<a target='_blank' href='" + that.properties.url + "'>" + that.properties.name + "</a>")) // .append(that.properties.is_official ? $("<h5 class='official-tag'/>").text("Official Event") : "") // .append($("<span/>").addClass("label-icon")) // .append($("<h5 class='event-type'/>").text(that.properties.event_type_name)) // .append($("<p/>").text(that.properties.location)) // .append( // $("<div class='social-area'/>") // .addClass(moreThan5RSVP ? "more-than-5" : "") // .append( // $("<a class='rsvp-link' target='_blank'/>") // .attr("href", that.properties.url) // .text(that.isFull ? "FULL" : "RSVP") // ) // .append( // $("<span class='rsvp-count'/>").text(that.properties.attendee_count + " SIGN UPS") // ) // ); // return rendered.html(); // }; // }; // })(jQuery); /**** * MapManager proper */ var MapManager = (function($, d3, leaflet) { return ( function(eventData, campaignOffices, zipcodes, options) { var allFilters = window.eventTypeFilters.map(function(i) { return i.id; }); var popup = L.popup(); var options = options; var zipcodes = zipcodes.reduce(function(zips, item) { zips[item.zip] = item; return zips; }, {}); var current_filters = [], current_zipcode = "", current_distance = "", current_sort = ""; var originalEventList = eventData.map(function(d) { return new Event(d); }); var eventsList = originalEventList.slice(0); // var officeList = campaignOffices.map(function(d) { return new CampaignOffices(d); }); leaflet.mapbox.accessToken = "pk.eyJ1IjoiemFja2V4bGV5IiwiYSI6Ijc2OWFhOTE0ZDllODZiMTUyNDYyOGM5MTk1Y2NmZmEyIn0.mfl6MGaSrMmNv5o5D5WBKw"; var mapboxTiles = leaflet.tileLayer('http://{s}.tiles.mapbox.com/v4/mapbox.streets/{z}/{x}/{y}.png?access_token=' + leaflet.mapbox.accessToken, { attribution: '<a href="http://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap contributors</a>'}); var CAMPAIGN_OFFICE_ICON = L.icon({ iconUrl: '//dcxc7a0ls04u1.cloudfront.net/img/icon/star.png', iconSize: [17, 14], // size of the icon // shadowSize: [50, 64], // size of the shadow // iconAnchor: [22, 94], // point of the icon which will correspond to marker's location // shadowAnchor: [4, 62], // the same for the shadow // popupAnchor: [-3, -76] // point from which the popup should open relative to the iconAnchor }); var GOTV_CENTER_ICON = L.icon({ iconUrl: '//dcxc7a0ls04u1.cloudfront.net/img/icon/gotv-star.png', iconSize: [13, 10], // size of the icon }); var defaultCoord = options&&options.defaultCoord ? options.defaultCoord : {center: [37.8, -96.9], zoom: 4}; var centralMap = new leaflet .Map("map-container", window.customMapCoord ? window.customMapCoord : defaultCoord) .addLayer(mapboxTiles); if(centralMap) {} var overlays = L.layerGroup().addTo(centralMap); var offices = L.layerGroup().addTo(centralMap); var gotvCenter = L.layerGroup().addTo(centralMap); var campaignOfficeLayer = L.layerGroup().addTo(centralMap); //initialize map var filteredEvents = []; var module = {}; var _popupEvents = function(event) { var target = event.target._latlng; var filtered = eventsList.filter(function(d) { return target.lat == d.LatLng[0] && target.lng == d.LatLng[1] && (!current_filters || current_filters.length == 0 || $(d.properties.filters).not(current_filters).length != d.properties.filters.length); }).sort(function(a, b) { return a.startTime - b.startTime; }); var div = $("<div />") .append(filtered.length > 1 ? "<h3 class='sched-count'>" + filtered.length + " Scheduled Events</h3>" : "") .append( $("<div class='popup-list-container'/>") .append($("<ul class='popup-list'>") .append( filtered.map(function(d) { return $("<li class='lato'/>") .attr('data-attending', (function(prop) { var email = Cookies.get('map.bernie.email'); var events_attended_raw = Cookies.get('map.bernie.eventsJoined.' + email); var events_attended = events_attended_raw ? JSON.parse(events_attended_raw) : []; return $.inArray(prop.id_obfuscated, events_attended) > -1; })(d.properties)) .addClass(d.isFull?"is-full":"not-full") .addClass(d.visible ? "is-visible" : "not-visible") .append(d.render()); }) ) ) ); setTimeout( function() { L.popup() .setLatLng(event.target._latlng) .setContent(div.html()) .openOn(centralMap); } , 100); }; /*** * Initialization */ var initialize = function() { var uniqueLocs = eventsList.reduce(function(arr, item){ var className = item.properties.filters.join(" "); if ( arr.indexOf(item.properties.latitude + "||" + item.properties.longitude + "||" + className) >= 0 ) { return arr; } else { arr.push(item.properties.latitude + "||" + item.properties.longitude + "||" + className); return arr; } }, []); uniqueLocs = uniqueLocs.map(function(d) { var split = d.split("||"); return { latLng: [ parseFloat(split[0]), parseFloat(split[1])], className: split[2] }; }); uniqueLocs.forEach(function(item) { // setTimeout(function() { if (item.className == "campaign-office") { L.marker(item.latLng, {icon: CAMPAIGN_OFFICE_ICON, className: item.className}) .on('click', function(e) { _popupEvents(e); }) .addTo(offices); } else if (item.className == "gotv-center") { L.marker(item.latLng, {icon: GOTV_CENTER_ICON, className: item.className}) .on('click', function(e) { _popupEvents(e); }) .addTo(gotvCenter); }else if (item.className.match(/bernie\-event/ig)) { L.circleMarker(item.latLng, { radius: 12, className: item.className, color: 'white', fillColor: '#F55B5B', opacity: 0.8, fillOpacity: 0.7, weight: 2 }) .on('click', function(e) { _popupEvents(e); }) .addTo(overlays); } else { L.circleMarker(item.latLng, { radius: 5, className: item.className, color: 'white', fillColor: '#1462A2', opacity: 0.8, fillOpacity: 0.7, weight: 2 }) .on('click', function(e) { _popupEvents(e); }) .addTo(overlays); } // }, 10); }); // $(".leaflet-overlay-pane").find(".bernie-event").parent().prependTo('.leaflet-zoom-animated'); }; // End of initialize var toMile = function(meter) { return meter * 0.00062137; }; var filterEventsByCoords = function (center, distance, filterTypes) { var zipLatLng = leaflet.latLng(center); var filtered = eventsList.filter(function(d) { var dist = toMile(zipLatLng.distanceTo(d.LatLng)); if (dist < distance) { d.distance = Math.round(dist*10)/10; //If no filter was a match on the current filter if (options && options.defaultCoord && !filterTypes) { return true; } if($(d.properties.filters).not(filterTypes).length == d.properties.filters.length) { return false; } return true; } return false; }); return filtered; }; var filterEvents = function (zipcode, distance, filterTypes) { return filterEventsByCoords([parseFloat(zipcode.lat), parseFloat(zipcode.lon)], distance, filterTypes) }; var sortEvents = function(filteredEvents, sortType) { switch (sortType) { case 'distance': filteredEvents = filteredEvents.sort(function(a,b) { return a.distance - b.distance; }); break; default: filteredEvents = filteredEvents.sort(function(a,b) { return a.startTime - b.startTime; }); break; } // filteredEvents = filteredEvents.sort(function(a, b) { // var aFull = a.isFull(); // var bFull = b.isFull(); // if (aFull && bFull) { return 0; } // else if (aFull && !bFull) { return 1; } // else if (!aFull && bFull) { return -1; } // }); //sort by fullness; //.. return filteredEvents; }; setTimeout(function(){ initialize(); }, 10); module._eventsList = eventsList; module._zipcodes = zipcodes; module._options = options; /* * Refresh map with new events map */ var _refreshMap = function() { overlays.clearLayers(); initialize(); }; module.filterByType = function(type) { if ($(filters).not(type).length != 0 || $(type).not(filters).length != 0) { current_filters = type; //Filter only items in the list // eventsList = originalEventList.filter(function(eventItem) { // var unmatch = $(eventItem.properties.filters).not(filters); // return unmatch.length != eventItem.properties.filters.length; // }); // var target = type.map(function(i) { return "." + i }).join(","); // $(".leaflet-overlay-pane").find("path:not("+type.map(function(i) { return "." + i }).join(",") + ")") var toHide = $(allFilters).not(type); if (toHide && toHide.length > 0) { toHide = toHide.splice(0,toHide.length); $(".leaflet-overlay-pane").find("." + toHide.join(",.")).hide(); } if (type && type.length > 0) { $(".leaflet-overlay-pane").find("." + type.join(",.")).show(); // _refreshMap(); } //Specifically for campaign office if (!type) { centralMap.removeLayer(offices); } else if (type && type.indexOf('campaign-office') < 0) { centralMap.removeLayer(offices); } else { centralMap.addLayer(offices); } //For gotv-centers if (!type) { centralMap.removeLayer(gotvCenter); } else if (type && type.indexOf('gotv-center') < 0) { centralMap.removeLayer(gotvCenter); } else { centralMap.addLayer(gotvCenter); } } return; }; module.filterByCoords = function(coords, distance, sort, filterTypes) { //Remove list d3.select("#event-list") .selectAll("li").remove(); var filtered = filterEventsByCoords(coords, parseInt(distance), filterTypes); //Sort event filtered = sortEvents(filtered, sort, filterTypes); //Check cookies var email = Cookies.get('map.bernie.email'); var events_attended_raw = Cookies.get('map.bernie.eventsJoined.' + email); var events_attended = events_attended_raw ? JSON.parse(events_attended_raw) : []; //Render event var eventList = d3.select("#event-list") .selectAll("li") .data(filtered, function(d){ return d.properties.id_obfuscated; }); eventList.enter() .append("li") .attr("data-attending", function(d, id) { return $.inArray(d.properties.id_obfuscated, events_attended) > -1; }) .attr("class", function(d) { return (d.isFull ? 'is-full' : 'not-full') + " " + (this.visible ? "is-visible" : "not-visible")}) .classed("lato", true) .html(function(d){ return d.render(d.distance); }); eventList.exit().remove(); //add a highlighted marker function addhighlightedMarker(lat,lon){ var highlightedMarker = new L.circleMarker([lat,lon],{radius: 5, color: '#ea504e', fillColor: '#1462A2', opacity: 0.8, fillOpacity: 0.7, weight: 2}).addTo(centralMap); // event listener to remove highlighted markers $(".not-full").mouseout(function(){ centralMap.removeLayer(highlightedMarker) }) } // event listener to get the mouseover $(".not-full" ).mouseover(function(){ $(this).toggleClass("highlight") var cMarkerLat = $(this).children('div').attr('lat') var cMarkerLon = $(this).children('div').attr('lon') // function call to add highlighted marker addhighlightedMarker(cMarkerLat,cMarkerLon); }) //Push all full items to end of list $("div#event-list-container ul#event-list li.is-full").appendTo("div#event-list-container ul#event-list"); //Move campaign offices to var officeCount = $("div#event-list-container ul#event-list li .campaign-office").length; $("#hide-show-office").attr("data-count", officeCount); $("#campaign-off-count").text(officeCount); $("section#campaign-offices ul#campaign-office-list *").remove(); $("div#event-list-container ul#event-list li .campaign-office").parent().appendTo("section#campaign-offices ul#campaign-office-list"); } /*** * FILTER() -- When the user submits query, we will look at this. */ module.filter = function(zipcode, distance, sort, filterTypes) { //Check type filter if (!zipcode || zipcode == "") { return; }; //Start if other filters changed var targetZipcode = zipcodes[zipcode]; //Remove list d3.select("#event-list") .selectAll("li").remove(); if (targetZipcode == undefined || !targetZipcode) { $("#event-list").append("<li class='error lato'>Zipcode does not exist. <a href=\"https://go.berniesanders.com/page/event/search_results?orderby=zip_radius&zip_radius%5b0%5d=" + zipcode + "&zip_radius%5b1%5d=100&country=US&radius_unit=mi\">Try our events page</a></li>"); return; } //Calibrate map var zoom = 4; switch(parseInt(distance)) { case 5 : zoom = 12; break; case 10: zoom = 11; break; case 20: zoom = 10; break; case 50: zoom = 9; break; case 100: zoom = 8; break; case 250: zoom = 7; break; case 500: zoom = 5; break; case 750: zoom = 5; break; case 1000: zoom = 4; break; case 2000: zoom = 4; break; case 3000: zoom = 3; break; } if (!(targetZipcode.lat && targetZipcode.lat != "")) { return; } if (current_zipcode != zipcode || current_distance != distance) { current_zipcode = zipcode; current_distance = distance; centralMap.setView([parseFloat(targetZipcode.lat), parseFloat(targetZipcode.lon)], zoom); } var filtered = filterEvents(targetZipcode, parseInt(distance), filterTypes); //Sort event filtered = sortEvents(filtered, sort, filterTypes); //Check cookies var email = Cookies.get('map.bernie.email'); var events_attended_raw = Cookies.get('map.bernie.eventsJoined.' + email); var events_attended = events_attended_raw ? JSON.parse(events_attended_raw) : []; //Render event var eventList = d3.select("#event-list") .selectAll("li") .data(filtered, function(d){ return d.properties.id_obfuscated; }); eventList.enter() .append("li") .attr("data-attending", function(d, id) { return $.inArray(d.properties.id_obfuscated, events_attended) > -1; }) .attr("class", function(d) { return (d.isFull ? 'is-full' : 'not-full') + " " + (this.visible ? "is-visible" : "not-visible")}) .classed("lato", true) .html(function(d){ return d.render(d.distance); }); eventList.exit().remove(); //add a highlighted marker function addhighlightedMarker(lat,lon){ var highlightedMarker = new L.circleMarker([lat,lon],{radius: 5, color: '#ea504e', fillColor: '#1462A2', opacity: 0.8, fillOpacity: 0.7, weight: 2}).addTo(centralMap); // event listener to remove highlighted markers $(".not-full").mouseout(function(){ centralMap.removeLayer(highlightedMarker) }) } // event listener to get the mouseover $(".not-full" ).mouseover(function(){ $(this).toggleClass("highlight") var cMarkerLat = $(this).children('div').attr('lat') var cMarkerLon = $(this).children('div').attr('lon') // function call to add highlighted marker addhighlightedMarker(cMarkerLat,cMarkerLon); }) //Push all full items to end of list $("div#event-list-container ul#event-list li.is-full").appendTo("div#event-list-container ul#event-list"); //Move campaign offices to var officeCount = $("div#event-list-container ul#event-list li .campaign-office").length; $("#hide-show-office").attr("data-count", officeCount); $("#campaign-off-count").text(officeCount); $("section#campaign-offices ul#campaign-office-list *").remove(); $("div#event-list-container ul#event-list li .campaign-office").parent().appendTo("section#campaign-offices ul#campaign-office-list"); }; module.toMapView = function () { $("body").removeClass("list-view").addClass("map-view"); centralMap.invalidateSize(); centralMap._onResize(); } module.toListView = function () { $("body").removeClass("map-view").addClass("list-view"); } module.getMap = function() { return centralMap; } return module; }); })(jQuery, d3, L); var VotingInfoManager = (function($) { return (function(votingInfo) { var votingInfo = votingInfo; var module = {}; function buildRegistrationMessage(state) { var $msg = $("<div class='registration-msg'/>").append($("<h3/>").text("Registration deadline: " + moment(new Date(state.registration_deadline)).format("MMM D"))) .append($("<p />").html(state.name + " has <strong>" + state.is_open + " " + state.type + "</strong>. " + state.you_must)) .append($("<p />").html("Find out where and how to register at <a target='_blank' href='https://vote.berniesanders.com/" + state.state + "'>vote.berniesanders.com</a>")) return $msg; } function buildPrimaryInfo(state) { var $msg = $("<div class='registration-msg'/>").append($("<h3/>").text("Primary day: " + moment(new Date(state.voting_day)).format("MMM D"))) .append($("<p />").html(state.name + " has <strong>" + state.is_open + " " + state.type + "</strong>. " + state.you_must)) .append($("<p />").html("Find out where and how to vote at <a target='_blank' href='https://vote.berniesanders.com/" + state.state + "'>vote.berniesanders.com</a>")) return $msg; } function buildCaucusInfo(state) { var $msg = $("<div class='registration-msg'/>").append($("<h3/>").text("Caucus day: " + moment(new Date(state.voting_day)).format("MMM D"))) .append($("<p />").html(state.name + " has <strong>" + state.is_open + " " + state.type + "</strong>. " + state.you_must)) .append($("<p />").html("Find out where and how to caucus at <a target='_blank' href='https://vote.berniesanders.com/" + state.state + "'>vote.berniesanders.com</a>")) return $msg; } module.getInfo = function(state) { var targetState = votingInfo.filter(function(d) { return d.state == state })[0]; //return first if(!targetState) return null; var today = new Date(); today.setDate(today.getDate() - 1); if(today <= new Date(targetState.registration_deadline)) { return buildRegistrationMessage(targetState); } else if (today <= new Date(targetState.voting_day)) { if (targetState.type == "primaries") { return buildPrimaryInfo(targetState); } else { // return buildCaucusInfo(targetState); } } else { return null; } } return module; }); })(jQuery); // More events (function($) { $(document).on("click", function(event, params) { $(".event-rsvp-activity").hide(); }); $(document).on("click", ".rsvp-link, .event-rsvp-activity", function(event, params) { event.stopPropagation(); }); //Show email $(document).on("show-event-form", function(events, target) { var form = $(target).closest(".event-item").find(".event-rsvp-activity"); if (Cookies.get('map.bernie.email')) { form.find("input[name=email]").val(Cookies.get('map.bernie.email')); } if (Cookies.get('map.bernie.phone')) { form.find("input[name=phone]").val(Cookies.get('map.bernie.phone')); } // var params = $.deparam(window.location.hash.substring(1) || ""); // form.find("input[name=zipcode]").val(params.zipcode ? params.zipcode : Cookies.get('map.bernie.zipcode')); form.fadeIn(100); }); $(document).on("submit", "form.event-form", function() { var query = $.deparam($(this).serialize()); var params = $.deparam(window.location.hash.substring(1) || ""); query['zipcode'] = params['zipcode'] || query['zipcode']; var $error = $(this).find(".event-error"); var $container = $(this).closest(".event-rsvp-activity"); if (query['has_shift'] == 'true' && (!query['shift_id'] || query['shift_id'].length == 0)) { $error.text("You must pick a shift").show(); return false; } var shifts = null; var guests = 0; if (query['shift_id']) { shifts = query['shift_id'].join(); } if (!query['phone'] || query['phone'] == '') { $error.text("Phone number is required").show(); return false; } if (!query['email'] || query['email'] == '') { $error.text("Email is required").show(); return false; } if (!query['email'].toUpperCase().match(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/)) { $error.text("Please input valid email").show(); return false; } // if (!query['name'] || query['name'] == "") { // $error.text("Please include your name").show(); // return false; // } $(this).find(".event-error").hide(); var $this = $(this) $.ajax({ type: 'POST', url: 'https://organize.berniesanders.com/events/add-rsvp', // url: 'https://bernie-ground-control-staging.herokuapp.com/events/add-rsvp', crossDomain: true, dataType: 'json', data: { // name: query['name'], phone: query['phone'], email: query['email'], zip: query['zipcode'], shift_ids: shifts, event_id_obfuscated: query['id_obfuscated'] }, success: function(data) { Cookies.set('map.bernie.zipcode', query['zipcode'], {expires: 7}); Cookies.set('map.bernie.email', query['email'], {expires: 7}); Cookies.set('map.bernie.name', query['name'], {expires: 7}); if (query['phone'] != '') { Cookies.set('map.bernie.phone', query['phone'], {expires: 7}); } //Storing the events joined var events_joined = JSON.parse(Cookies.get('map.bernie.eventsJoined.' + query['email']) || "[]") || []; events_joined.push(query['id_obfuscated']); Cookies.set('map.bernie.eventsJoined.' + query['email'], events_joined, {expires: 7}); $this.closest("li").attr("data-attending", true); $this.html("<h4 style='border-bottom: none'>RSVP Successful! Thank you for joining to this event!</h4>"); $container.delay(1000).fadeOut('fast') } }) return false; }); })(jQuery);
Bernie-2016/EventMap
js/MapManager.js
JavaScript
agpl-3.0
31,622
[ 30522, 1013, 1013, 3443, 2019, 2724, 30524, 2171, 1012, 5672, 1006, 1013, 1031, 1034, 1032, 1059, 1033, 1013, 1045, 2290, 1010, 1000, 1011, 1000, 1007, 1012, 2000, 27663, 18992, 3366, 1006, 1007, 1025, 2023, 1012, 2474, 19646, 3070, 1027, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package eu.monnetproject.util; import java.util.*; /** * Utility function to syntactically sugar properties for OSGi. * This allows you to create a property map as follows * <code>Props.prop("key1","value1")</code><br/> * <code> .prop("key2","value2")</code> */ public final class Props { public static PropsMap prop(String key, Object value) { PropsMap pm = new PropsMap(); pm.put(key,value); return pm; } public static class PropsMap extends Hashtable<String,Object> { public PropsMap prop(String key, Object value) { put(key,value); return this; } } }
monnetproject/coal
nlp.sim/src/main/java/eu/monnetproject/util/Props.java
Java
bsd-3-clause
590
[ 30522, 7427, 7327, 1012, 12256, 7159, 21572, 20614, 1012, 21183, 30524, 21183, 4014, 1012, 1008, 1025, 1013, 1008, 1008, 1008, 9710, 3853, 2000, 19962, 2696, 13306, 3973, 5699, 5144, 2005, 9808, 5856, 1012, 1008, 2023, 4473, 2017, 2000, 344...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
class Stats def self.debug(message) puts(message) if ENV["DEBUG"] end def self.since(last_date) message = "\n" new_members = Membership.active.since(last_date); groups = new_members.group_by(&:level); plans = MembershipPlan.all.sort_by(&:amount); plans.select{|plan| groups[plan.product_id.to_s] }. map{|plan| [plan, groups[plan.product_id.to_s]] }. each do |plan, group| message << "#{group.size} new #{plan.product.shortname} #{"member".pluralize(group.size)}" names = group.map{|m| [m.name, m.url].compact.join(" ") if m.name }.compact message << " including\n - #{names.join("\n - ")}" if names.any? message << "\n" end companies, people = new_members.partition(&:corporate?) message << "\n" message << "#{people.count} new #{"developer".pluralize(people.count)}\n" message << "#{companies.count} new #{"company".pluralize(companies.count)}\n" message << "#{new_members.size} new #{"member".pluralize(new_members.size)} total\n" message << "\n" counts = Membership.active.group(:level).count.map do |id, c| [MembershipPlan.monthly(id), c] end.to_h corp, dev = counts.partition{|s,c| s.corporate? } message << "#{corp.map(&:last).inject(:+)} #{"company".pluralize(companies.count)} (" message << corp.sort_by{|s,c| -s.amount}.map{|s,c| "#{c} #{s.product.shortname}" }.join(", ") message << ")\n" message << "#{dev.map(&:last).inject(:+)} #{"developer".pluralize(people.count)} (" message << dev.sort_by{|s,c| -s.amount}.map{|s,c| "#{c} #{s.product.shortname}" }.join(", ") message << ")\n" end end
rubytogether/rubytogether.org
app/lib/stats.rb
Ruby
mit
1,656
[ 30522, 2465, 26319, 13366, 2969, 1012, 2139, 8569, 2290, 1006, 4471, 1007, 8509, 1006, 4471, 1007, 2065, 4372, 2615, 1031, 1000, 2139, 8569, 2290, 1000, 1033, 2203, 13366, 2969, 1012, 2144, 1006, 2197, 1035, 3058, 1007, 4471, 1027, 1000, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html lang="en" > <head> <title>40123232 cdw11 報告 - CDW11 網頁 (虎尾科大MDE)</title> <!-- Using the latest rendering mode for IE --> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style type="text/css"> /*some stuff for output/input prompts*/ div.cell{border:1px solid transparent;display:-webkit-box;-webkit-box-orient:vertical;-webkit-box-align:stretch;display:-moz-box;-moz-box-orient:vertical;-moz-box-align:stretch;display:box;box-orient:vertical;box-align:stretch;display:flex;flex-direction:column;align-items:stretch}div.cell.selected{border-radius:4px;border:thin #ababab solid} div.cell.edit_mode{border-radius:4px;border:thin #008000 solid} div.cell{width:100%;padding:5px 5px 5px 0;margin:0;outline:none} div.prompt{min-width:11ex;padding:.4em;margin:0;font-family:monospace;text-align:right;line-height:1.21429em} @media (max-width:480px){div.prompt{text-align:left}}div.inner_cell{display:-webkit-box;-webkit-box-orient:vertical;-webkit-box-align:stretch;display:-moz-box;-moz-box-orient:vertical;-moz-box-align:stretch;display:box;box-orient:vertical;box-align:stretch;display:flex;flex-direction:column;align-items:stretch;-webkit-box-flex:1;-moz-box-flex:1;box-flex:1;flex:1} div.input_area{border:1px solid #cfcfcf;border-radius:4px;background:#f7f7f7;line-height:1.21429em} div.prompt:empty{padding-top:0;padding-bottom:0} div.input{page-break-inside:avoid;display:-webkit-box;-webkit-box-orient:horizontal;-webkit-box-align:stretch;display:-moz-box;-moz-box-orient:horizontal;-moz-box-align:stretch;display:box;box-orient:horizontal;box-align:stretch;} div.inner_cell{width:90%;} div.input_area{border:1px solid #cfcfcf;border-radius:4px;background:#f7f7f7;} div.input_prompt{color:navy;border-top:1px solid transparent;} div.output_wrapper{margin-top:5px;position:relative;display:-webkit-box;-webkit-box-orient:vertical;-webkit-box-align:stretch;display:-moz-box;-moz-box-orient:vertical;-moz-box-align:stretch;display:box;box-orient:vertical;box-align:stretch;width:100%;} div.output_scroll{height:24em;width:100%;overflow:auto;border-radius:4px;-webkit-box-shadow:inset 0 2px 8px rgba(0, 0, 0, 0.8);-moz-box-shadow:inset 0 2px 8px rgba(0, 0, 0, 0.8);box-shadow:inset 0 2px 8px rgba(0, 0, 0, 0.8);} div.output_collapsed{margin:0px;padding:0px;display:-webkit-box;-webkit-box-orient:vertical;-webkit-box-align:stretch;display:-moz-box;-moz-box-orient:vertical;-moz-box-align:stretch;display:box;box-orient:vertical;box-align:stretch;width:100%;} div.out_prompt_overlay{height:100%;padding:0px 0.4em;position:absolute;border-radius:4px;} div.out_prompt_overlay:hover{-webkit-box-shadow:inset 0 0 1px #000000;-moz-box-shadow:inset 0 0 1px #000000;box-shadow:inset 0 0 1px #000000;background:rgba(240, 240, 240, 0.5);} div.output_prompt{color:darkred;} a.anchor-link:link{text-decoration:none;padding:0px 20px;visibility:hidden;} h1:hover .anchor-link,h2:hover .anchor-link,h3:hover .anchor-link,h4:hover .anchor-link,h5:hover .anchor-link,h6:hover .anchor-link{visibility:visible;} /* end stuff for output/input prompts*/ .highlight-ipynb .hll { background-color: #ffffcc } .highlight-ipynb { background: #f8f8f8; } .highlight-ipynb .c { color: #408080; font-style: italic } /* Comment */ .highlight-ipynb .err { border: 1px solid #FF0000 } /* Error */ .highlight-ipynb .k { color: #008000; font-weight: bold } /* Keyword */ .highlight-ipynb .o { color: #666666 } /* Operator */ .highlight-ipynb .cm { color: #408080; font-style: italic } /* Comment.Multiline */ .highlight-ipynb .cp { color: #BC7A00 } /* Comment.Preproc */ .highlight-ipynb .c1 { color: #408080; font-style: italic } /* Comment.Single */ .highlight-ipynb .cs { color: #408080; font-style: italic } /* Comment.Special */ .highlight-ipynb .gd { color: #A00000 } /* Generic.Deleted */ .highlight-ipynb .ge { font-style: italic } /* Generic.Emph */ .highlight-ipynb .gr { color: #FF0000 } /* Generic.Error */ .highlight-ipynb .gh { color: #000080; font-weight: bold } /* Generic.Heading */ .highlight-ipynb .gi { color: #00A000 } /* Generic.Inserted */ .highlight-ipynb .go { color: #888888 } /* Generic.Output */ .highlight-ipynb .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ .highlight-ipynb .gs { font-weight: bold } /* Generic.Strong */ .highlight-ipynb .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ .highlight-ipynb .gt { color: #0044DD } /* Generic.Traceback */ .highlight-ipynb .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ .highlight-ipynb .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ .highlight-ipynb .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ .highlight-ipynb .kp { color: #008000 } /* Keyword.Pseudo */ .highlight-ipynb .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ .highlight-ipynb .kt { color: #B00040 } /* Keyword.Type */ .highlight-ipynb .m { color: #666666 } /* Literal.Number */ .highlight-ipynb .s { color: #BA2121 } /* Literal.String */ .highlight-ipynb .na { color: #7D9029 } /* Name.Attribute */ .highlight-ipynb .nb { color: #008000 } /* Name.Builtin */ .highlight-ipynb .nc { color: #0000FF; font-weight: bold } /* Name.Class */ .highlight-ipynb .no { color: #880000 } /* Name.Constant */ .highlight-ipynb .nd { color: #AA22FF } /* Name.Decorator */ .highlight-ipynb .ni { color: #999999; font-weight: bold } /* Name.Entity */ .highlight-ipynb .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ .highlight-ipynb .nf { color: #0000FF } /* Name.Function */ .highlight-ipynb .nl { color: #A0A000 } /* Name.Label */ .highlight-ipynb .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ .highlight-ipynb .nt { color: #008000; font-weight: bold } /* Name.Tag */ .highlight-ipynb .nv { color: #19177C } /* Name.Variable */ .highlight-ipynb .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ .highlight-ipynb .w { color: #bbbbbb } /* Text.Whitespace */ .highlight-ipynb .mf { color: #666666 } /* Literal.Number.Float */ .highlight-ipynb .mh { color: #666666 } /* Literal.Number.Hex */ .highlight-ipynb .mi { color: #666666 } /* Literal.Number.Integer */ .highlight-ipynb .mo { color: #666666 } /* Literal.Number.Oct */ .highlight-ipynb .sb { color: #BA2121 } /* Literal.String.Backtick */ .highlight-ipynb .sc { color: #BA2121 } /* Literal.String.Char */ .highlight-ipynb .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ .highlight-ipynb .s2 { color: #BA2121 } /* Literal.String.Double */ .highlight-ipynb .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ .highlight-ipynb .sh { color: #BA2121 } /* Literal.String.Heredoc */ .highlight-ipynb .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ .highlight-ipynb .sx { color: #008000 } /* Literal.String.Other */ .highlight-ipynb .sr { color: #BB6688 } /* Literal.String.Regex */ .highlight-ipynb .s1 { color: #BA2121 } /* Literal.String.Single */ .highlight-ipynb .ss { color: #19177C } /* Literal.String.Symbol */ .highlight-ipynb .bp { color: #008000 } /* Name.Builtin.Pseudo */ .highlight-ipynb .vc { color: #19177C } /* Name.Variable.Class */ .highlight-ipynb .vg { color: #19177C } /* Name.Variable.Global */ .highlight-ipynb .vi { color: #19177C } /* Name.Variable.Instance */ .highlight-ipynb .il { color: #666666 } /* Literal.Number.Integer.Long */ </style> <style type="text/css"> /* Overrides of notebook CSS for static HTML export */ div.entry-content { overflow: visible; padding: 8px; } .input_area { padding: 0.2em; } a.heading-anchor { white-space: normal; } .rendered_html code { font-size: .8em; } pre.ipynb { color: black; background: #f7f7f7; border: none; box-shadow: none; margin-bottom: 0; padding: 0; margin: 0px; font-size: 13px; } /* remove the prompt div from text cells */ div.text_cell .prompt { display: none; } /* remove horizontal padding from text cells, */ /* so it aligns with outer body text */ div.text_cell_render { padding: 0.5em 0em; } img.anim_icon{padding:0; border:0; vertical-align:middle; -webkit-box-shadow:none; -box-shadow:none} </style> <script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" type="text/javascript"></script> <script type="text/javascript"> init_mathjax = function() { if (window.MathJax) { // MathJax loaded MathJax.Hub.Config({ tex2jax: { inlineMath: [ ['$','$'], ["\\(","\\)"] ], displayMath: [ ['$$','$$'], ["\\[","\\]"] ] }, displayAlign: 'left', // Change this to 'center' to center equations. "HTML-CSS": { styles: {'.MathJax_Display': {"margin": 0}} } }); MathJax.Hub.Queue(["Typeset",MathJax.Hub]); } } init_mathjax(); </script> <link rel="canonical" href="http://cdw11-ag100.rhcloud.com/static/blog/40123232-cdw11-bao-gao.html"> <meta name="author" content="40123232" /> <meta name="keywords" content="40123232,cdw11" /> <meta name="description" content="啟動 cdw11 協同專案" /> <meta property="og:site_name" content="CDW11 網頁 (虎尾科大MDE)" /> <meta property="og:type" content="article"/> <meta property="og:title" content="40123232 cdw11 報告"/> <meta property="og:url" content="http://cdw11-ag100.rhcloud.com/static/blog/40123232-cdw11-bao-gao.html"/> <meta property="og:description" content="啟動 cdw11 協同專案"/> <meta property="article:published_time" content="2016-06-30" /> <meta property="article:section" content="bg2" /> <meta property="article:tag" content="40123232" /> <meta property="article:tag" content="cdw11" /> <meta property="article:author" content="40123232" /> <!-- Bootstrap --> <link rel="stylesheet" href="http://cdw11-ag100.rhcloud.com/static/blog/theme/css/bootstrap.united.min.css" type="text/css"/> <link href="http://cdw11-ag100.rhcloud.com/static/blog/theme/css/font-awesome.min.css" rel="stylesheet"> <link href="http://cdw11-ag100.rhcloud.com/static/blog/theme/css/pygments/monokai.css" rel="stylesheet"> <link href="http://cdw11-ag100.rhcloud.com/static/blog/theme/tipuesearch/tipuesearch.css" rel="stylesheet"> <link rel="stylesheet" href="http://cdw11-ag100.rhcloud.com/static/blog/theme/css/style.css" type="text/css"/> <link href="http://cdw11-ag100.rhcloud.com/static/blog/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="CDW11 網頁 (虎尾科大MDE) ATOM Feed"/> <script type="text/javascript" src="http://cad-lab.github.io/cadlab_data/files/syntaxhighlighter/shCore.js"></script> <script type="text/javascript" src="http://cad-lab.github.io/cadlab_data/files/syntaxhighlighter/shBrushJScript.js"></script> <script type="text/javascript" src="http://cad-lab.github.io/cadlab_data/files/syntaxhighlighter/shBrushJava.js"></script> <script type="text/javascript" src="http://cad-lab.github.io/cadlab_data/files/syntaxhighlighter/shBrushPython.js"></script> <script type="text/javascript" src="http://cad-lab.github.io/cadlab_data/files/syntaxhighlighter/shBrushSql.js"></script> <script type="text/javascript" src="http://cad-lab.github.io/cadlab_data/files/syntaxhighlighter/shBrushXml.js"></script> <script type="text/javascript" src="http://cad-lab.github.io/cadlab_data/files/syntaxhighlighter/shBrushPhp.js"></script> <script type="text/javascript" src="http://cad-lab.github.io/cadlab_data/files/syntaxhighlighter/shBrushCpp.js"></script> <script type="text/javascript" src="http://cad-lab.github.io/cadlab_data/files/syntaxhighlighter/shBrushCss.js"></script> <script type="text/javascript" src="http://cad-lab.github.io/cadlab_data/files/syntaxhighlighter/shBrushCSharp.js"></script> <script type='text/javascript'> (function(){ var corecss = document.createElement('link'); var themecss = document.createElement('link'); var corecssurl = "http://cad-lab.github.io/cadlab_data/files/syntaxhighlighter/css/shCore.css"; if ( corecss.setAttribute ) { corecss.setAttribute( "rel", "stylesheet" ); corecss.setAttribute( "type", "text/css" ); corecss.setAttribute( "href", corecssurl ); } else { corecss.rel = "stylesheet"; corecss.href = corecssurl; } document.getElementsByTagName("head")[0].insertBefore( corecss, document.getElementById("syntaxhighlighteranchor") ); var themecssurl = "http://cad-lab.github.io/cadlab_data/files/syntaxhighlighter/css/shThemeDefault.css?ver=3.0.9b"; if ( themecss.setAttribute ) { themecss.setAttribute( "rel", "stylesheet" ); themecss.setAttribute( "type", "text/css" ); themecss.setAttribute( "href", themecssurl ); } else { themecss.rel = "stylesheet"; themecss.href = themecssurl; } //document.getElementById("syntaxhighlighteranchor").appendChild(themecss); document.getElementsByTagName("head")[0].insertBefore( themecss, document.getElementById("syntaxhighlighteranchor") ); })(); SyntaxHighlighter.config.strings.expandSource = '+ expand source'; SyntaxHighlighter.config.strings.help = '?'; SyntaxHighlighter.config.strings.alert = 'SyntaxHighlighter\n\n'; SyntaxHighlighter.config.strings.noBrush = 'Can\'t find brush for: '; SyntaxHighlighter.config.strings.brushNotHtmlScript = 'Brush wasn\'t configured for html-script option: '; SyntaxHighlighter.defaults['pad-line-numbers'] = false; SyntaxHighlighter.defaults['toolbar'] = false; SyntaxHighlighter.all(); </script> </head> <body> <div class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a href="http://cdw11-ag100.rhcloud.com/static/blog/" class="navbar-brand"> CDW11 網頁 (虎尾科大MDE) </a> </div> <div class="collapse navbar-collapse navbar-ex1-collapse"> <ul class="nav navbar-nav"> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag1.html">Ag1</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag10.html">Ag10</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag100.html">Ag100</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag2.html">Ag2</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag3.html">Ag3</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag4.html">Ag4</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag5.html">Ag5</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag6.html">Ag6</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag7.html">Ag7</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag8.html">Ag8</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag9.html">Ag9</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg1.html">Bg1</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg10.html">Bg10</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg101.html">Bg101</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg11.html">Bg11</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg15.html">Bg15</a> </li> <li class="active"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg2.html">Bg2</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg3.html">Bg3</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg4.html">Bg4</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg5.html">Bg5</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg6.html">Bg6</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg8.html">Bg8</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg9.html">Bg9</a> </li> <li > <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/g3.html">G3</a> </li> </ul> <ul class="nav navbar-nav navbar-right"> <li><span> <form class="navbar-search" action="http://cdw11-ag100.rhcloud.com/static/blog/search.html"> <input type="text" class="search-query" placeholder="Search" name="q" id="tipue_search_input" required> </form></span> </li> <li><a href="http://cdw11-ag100.rhcloud.com/static/blog/archives.html"><i class="fa fa-th-list"></i><span class="icon-label">Archives</span></a></li> </ul> </div> <!-- /.navbar-collapse --> </div> </div> <!-- /.navbar --> <!-- Banner --> <!-- End Banner --> <div class="container"> <div class="row"> <div class="col-sm-9"> <section id="content"> <article> <header class="page-header"> <h1> <a href="http://cdw11-ag100.rhcloud.com/static/blog/40123232-cdw11-bao-gao.html" rel="bookmark" title="Permalink to 40123232 cdw11 報告"> 40123232 cdw11 報告 </a> </h1> </header> <div class="entry-content"> <div class="panel"> <div class="panel-body"> <footer class="post-info"> <span class="label label-default">Date</span> <span class="published"> <i class="fa fa-calendar"></i><time datetime="2016-06-30T00:48:26.637807+08:00"> 四 30 六月 2016</time> </span> <span class="label label-default">By</span> <a href="http://cdw11-ag100.rhcloud.com/static/blog/author/40123232.html"><i class="fa fa-user"></i> 40123232</a> <span class="label label-default">Tags</span> <a href="http://cdw11-ag100.rhcloud.com/static/blog/tag/40123232.html">40123232</a> / <a href="http://cdw11-ag100.rhcloud.com/static/blog/tag/cdw11.html">cdw11</a> </footer><!-- /.post-info --> </div> </div> <p>啟動 cdw11 協同專案</p> <p>cdw11心得</p> <p>先註冊藍圖及導入</p> <p><img src="http://i.imgur.com/GE2lnu7.png" width="100%" /> <img src="http://i.imgur.com/nQowkLo.png" width="100%" /></p> <p>使用老師及同學提供及修改過的ABCD程式來達成此次練習</p> <p>練習1:4A</p> <p>直接以老師的原本程式的A來使用 修改起始坐標後來呈現 如圖</p> <p><img src="http://i.imgur.com/kzmIMPi.png" width="100%" /></p> <p>完成後須先在近端執行可否運作</p> <p><img src="http://i.imgur.com/NnYYEdz.png" width="100%" /></p> <p>接下來BACD及從上到下ABCD都是相似作法</p> <p>成果:</p> <p>4A 網誌位置: <a href="http://cdw2g2-40123232.rhcloud.com/bg2_40123232/task4a">http://cdw2g2-40123232.rhcloud.com/bg2_40123232/task4a</a></p> <p>BACD網誌位置: <a href="http://cdw2g2-40123232.rhcloud.com/bg2_40123232/taskbacd">http://cdw2g2-40123232.rhcloud.com/bg2_40123232/taskbacd</a></p> <p>上下ABCD網誌位置: <a href="http://cdw2g2-40123232.rhcloud.com/bg2_40123232/taskabcd">http://cdw2g2-40123232.rhcloud.com/bg2_40123232/taskabcd</a></p> </div> <!-- /.entry-content --> <hr/> <section class="comments" id="comments"> <h2>Comments</h2> <div id="disqus_thread"></div> <script type="text/javascript"> /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ var disqus_shortname = 'cadlabmanual'; // required: replace example with your forum shortname var disqus_identifier = '40123232-cdw11-bao-gao'; var disqus_url = 'http://cdw11-ag100.rhcloud.com/static/blog/40123232-cdw11-bao-gao.html'; var disqus_config = function () { this.language = "en"; }; /* * * DON'T EDIT BELOW THIS LINE * * */ (function () { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); </script> <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a> </section> </article> </section> </div> <div class="col-sm-3" id="sidebar"> <aside> <section class="well well-sm"> <ul class="list-group list-group-flush"> <li class="list-group-item"><h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Recent Posts</span></h4> <ul class="list-group" id="recentposts"> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/2016-nian-chun-ji-xie-tong-chan-pin-she-ji-shi-xi.html"> 2016 年春季協同產品設計實習 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/40123128-cdw11-bao-gao.html"> 40123128 cdw11 報告 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/40123128-cdw11-bao-gao-1.html"> 40123128 cdw11 報告-1 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/40123128-cdw13-bao-gao.html"> 40123128 cdw13 報告 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/40123128-cdw15-bao-gao.html"> 40123128 cdw15 報告 </a> </li> </ul> </li> <li class="list-group-item"><a href="http://cdw11-ag100.rhcloud.com/static/blog/categories.html"><h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Categories</span></h4></a> <ul class="list-group" id="categories"> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag1.html"> <i class="fa fa-folder-open fa-lg"></i> ag1 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag10.html"> <i class="fa fa-folder-open fa-lg"></i> ag10 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag100.html"> <i class="fa fa-folder-open fa-lg"></i> ag100 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag2.html"> <i class="fa fa-folder-open fa-lg"></i> ag2 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag3.html"> <i class="fa fa-folder-open fa-lg"></i> ag3 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag4.html"> <i class="fa fa-folder-open fa-lg"></i> ag4 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag5.html"> <i class="fa fa-folder-open fa-lg"></i> ag5 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag6.html"> <i class="fa fa-folder-open fa-lg"></i> ag6 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag7.html"> <i class="fa fa-folder-open fa-lg"></i> ag7 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag8.html"> <i class="fa fa-folder-open fa-lg"></i> ag8 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/ag9.html"> <i class="fa fa-folder-open fa-lg"></i> ag9 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg1.html"> <i class="fa fa-folder-open fa-lg"></i> bg1 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg10.html"> <i class="fa fa-folder-open fa-lg"></i> bg10 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg101.html"> <i class="fa fa-folder-open fa-lg"></i> bg101 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg11.html"> <i class="fa fa-folder-open fa-lg"></i> bg11 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg15.html"> <i class="fa fa-folder-open fa-lg"></i> bg15 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg2.html"> <i class="fa fa-folder-open fa-lg"></i> bg2 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg3.html"> <i class="fa fa-folder-open fa-lg"></i> bg3 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg4.html"> <i class="fa fa-folder-open fa-lg"></i> bg4 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg5.html"> <i class="fa fa-folder-open fa-lg"></i> bg5 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg6.html"> <i class="fa fa-folder-open fa-lg"></i> bg6 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg8.html"> <i class="fa fa-folder-open fa-lg"></i> bg8 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/bg9.html"> <i class="fa fa-folder-open fa-lg"></i> bg9 </a> </li> <li class="list-group-item"> <a href="http://cdw11-ag100.rhcloud.com/static/blog/category/g3.html"> <i class="fa fa-folder-open fa-lg"></i> g3 </a> </li> </ul> </li> <li class="list-group-item"><a href="http://cdw11-ag100.rhcloud.com/static/blog/tags.html"><h4><i class="fa fa-tags fa-lg"></i><span class="icon-label">Tags</span></h4></a> <ul class="list-group list-inline tagcloud" id="tags"> </ul> </li> <li class="list-group-item"><h4><i class="fa fa-external-link-square fa-lg"></i><span class="icon-label">Links</span></h4> <ul class="list-group" id="links"> <li class="list-group-item"> <a href="http://getpelican.com/" target="_blank"> Pelican </a> </li> <li class="list-group-item"> <a href="https://github.com/DandyDev/pelican-bootstrap3/" target="_blank"> pelican-bootstrap3 </a> </li> <li class="list-group-item"> <a href="https://github.com/getpelican/pelican-plugins" target="_blank"> pelican-plugins </a> </li> <li class="list-group-item"> <a href="https://github.com/Tipue/Tipue-Search" target="_blank"> Tipue search </a> </li> </ul> </li> </ul> </section> </aside> </div> </div> </div> <footer> <div class="container"> <hr> <div class="row"> <div class="col-xs-10">&copy; 2016 kmol &middot; Powered by <a href="https://github.com/DandyDev/pelican-bootstrap3" target="_blank">pelican-bootstrap3</a>, <a href="http://docs.getpelican.com/" target="_blank">Pelican</a>, <a href="http://getbootstrap.com" target="_blank">Bootstrap</a> </div> <div class="col-xs-2"><p class="pull-right"><i class="fa fa-arrow-up"></i> <a href="#">Back to top</a></p></div> </div> </div> </footer> <script src="http://cdw11-ag100.rhcloud.com/static/blog/theme/js/jquery.min.js"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="http://cdw11-ag100.rhcloud.com/static/blog/theme/js/bootstrap.min.js"></script> <!-- Enable responsive features in IE8 with Respond.js (https://github.com/scottjehl/Respond) --> <script src="http://cdw11-ag100.rhcloud.com/static/blog/theme/js/respond.min.js"></script> <!-- Disqus --> <script type="text/javascript"> /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ var disqus_shortname = 'cadlabmanual'; // required: replace example with your forum shortname /* * * DON'T EDIT BELOW THIS LINE * * */ (function () { var s = document.createElement('script'); s.async = true; s.type = 'text/javascript'; s.src = '//' + disqus_shortname + '.disqus.com/count.js'; (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s); }()); </script> <!-- End Disqus Code --> </body> </html>
2015fallhw/cdw11
static/blog/40123232-cdw11-bao-gao.html
HTML
agpl-3.0
34,635
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 11374, 1027, 1000, 4372, 1000, 1028, 1026, 2132, 1028, 1026, 2516, 1028, 22649, 21926, 21926, 2475, 3729, 2860, 14526, 100, 100, 1011, 3729, 2860, 14526, 100, 100, 1006, 100, 100, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
require 'rails_helper' describe ActiveAdmin::Views::Tabs do describe "creating with the dsl" do context "when creating tabs with a symbol" do let(:tabs) do render_arbre_component do tabs do tab :overview end end end it "should create a tab navigation bar based on the symbol" do expect(tabs.find_by_tag('li').first.content).to include "Overview" end end context "when creating a tab with a block" do let(:tabs) do render_arbre_component do tabs do tab :overview do span 'tab 1' end end end end it "should create a tab navigation bar based on the symbol" do expect(tabs.find_by_tag('li').first.content).to include "Overview" end it "should create a tab with a span inside of it" do expect(tabs.find_by_tag('span').first.content).to eq('tab 1') end end end end
BibNumUMontreal/DMPonline_v4
vendor/ruby/2.1.0/gems/activeadmin-1.0.0.pre1/spec/unit/views/components/tabs_spec.rb
Ruby
agpl-3.0
990
[ 30522, 5478, 1005, 15168, 1035, 2393, 2121, 1005, 6235, 3161, 4215, 10020, 1024, 1024, 5328, 1024, 1024, 21628, 2015, 2079, 6235, 1000, 4526, 2007, 1996, 16233, 2140, 1000, 2079, 6123, 1000, 2043, 4526, 21628, 2015, 2007, 1037, 6454, 1000, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
using System.Collections.Generic; using System.Threading.Tasks; using Octokit; namespace GithubXamarin.Core.Contracts.Repository { public interface IFileRepository { Task<IEnumerable<RepositoryContent>> GetContentForRepository(long repositoryId, string path, GitHubClient gitHubClient); Task<IEnumerable<RepositoryContent>> GetRootContentForRepository(long repositoryId, GitHubClient githubClient); Task<Readme> GetReadmeForRepository(long repositoryId, GitHubClient authorizedGitHubClient); Task<RepositoryContentChangeSet> CreateFile(long repositoryId, string path, string message, string content, GitHubClient gitHubClient); Task<RepositoryContentChangeSet> UpdateFile(long repositoryId, string path, string message, string content, string sha, GitHubClient gitHubClient); Task DeleteFile(long repositoryId, string path, string message, string sha, GitHubClient gitHubClient); } }
prajjwaldimri/GithubXamarin
GithubXamarin.Core/Contracts/Repository/IFileRepository.cs
C#
gpl-3.0
972
[ 30522, 2478, 2291, 1012, 6407, 1012, 12391, 1025, 2478, 2291, 1012, 11689, 2075, 1012, 8518, 1025, 2478, 13323, 23212, 2102, 1025, 3415, 15327, 21025, 2705, 12083, 18684, 7849, 2378, 1012, 4563, 1012, 8311, 1012, 22409, 1063, 2270, 8278, 20...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Adjunctions \epigraph{"Adjoint functors arise everywhere"}{\emph{Saunders Mac Lane}} There are multiple ways to introduce adjunctions, both in terms of the intuition behind them, as well as the actual definition. The setup is that there are two functors $F, G$: \begin{figure}[H] \centering \begin{tikzcd} \mathcal{C} \arrow[r, "F", bend left=30] & \mathcal{D} \arrow[l, "G", bend left=30] \end{tikzcd} \end{figure} that we want to relate. In particular, we want to generalize the _inverse_ of a functor. We say that the functor $F$ is an isomorphism with inverse $G$ if: $$\text{Id}_\mathcal{C} = GF,~FG = \text{Id}_\mathcal{D}$$ where $\text{Id}_\mathcal{C}$ is the identity functor on $\mathcal{C}$, and $GF$ denotes $G \circ F$. A weaker notion is _isomorphism up to natural isomorphism_, where we require that there exists some natural isomorphisms $$\text{Id}_\mathcal{C} \stackrel{\sim}{\Rightarrow} GF,~FG \stackrel{\sim}{\Rightarrow} \text{Id}_\mathcal{D}$$ Even weaker is that we only require that there exists natural transformations: $$\text{Id}_\mathcal{C} \Rightarrow GF,~FG \Rightarrow \text{Id}_\mathcal{D}$$ This is what we are going to explore in this part. ## Universal arrow adjunctions \begin{definition}[Universal arrow adjunction] Let $\mathcal{C}, \mathcal{D}$ be categories. Let $F: \mathcal{C} \to \mathcal{D}$ and $G: \mathcal{D} \to \mathcal{C}$ be functors. If there exists a natural transformation: $$\eta: \text{Id}_\mathcal{C} \Rightarrow GF,$$ such that for all objects $c \in \mathcal{C}$ and $d \in \mathcal{D}$, and all arrows $f: c \to Gd$ there exists a unique arrow $g: Fc \to d$ such that the following diagram commutes: \begin{figure}[H] \centering \begin{tikzcd} c \arrow[r, "\eta_c"] \arrow[rd, "f"'] & GFc \arrow[d, "Gg"] \\ & Gd \end{tikzcd} \end{figure} We call the triple $(F, G, \eta)$ an \emph{adjunction}, and $\eta$ the \emph{unit} of the adjunction. We say that $F \text{ is left adjoint to } G$, and $G \text{ is right adjoint to } F$, or simply $F \dashv G$. \end{definition} In other words, given an adjunction and any arrow $f: c \to Gd$, i.e. from an arbitrary object of $\mathcal{C}$ to something in the image of $G$ (so _relevant to the functor $G$_), we can equivalently consider an arrow $g: Fc \to d$ in $\mathcal{D}$ relating to the functor $F$, because we use the natural transformation $\eta$ and our functors to convert them to the same arrow. This means that the _relevant structure_ of $\mathcal{C}$ with respect to the functor $G$, can also be found in $\mathcal{D}$ with respect to the functor $F$. \begin{example} View $\mathbb{Z}$ and $\mathbb{R}$ as categories, with $a \to b \iff a \leq b$. Let $I: \mathbb{Z} \to \mathbb{R}$ be the inclusion functor that sends $z \to \iota(z)$. $I$ is left adjoint to the functor $\lfloor \cdot \rfloor: \mathbb{R} \to \mathbb{Z}$ that sends $r \to \lfloor r \rfloor$. Indeed, consider the following diagram in $\mathbb{Z}$: \begin{figure}[H] \centering \begin{tikzcd} z \arrow[r, "z \leq z"] \arrow[rd, "z \leq \lfloor r \rfloor"'] & \lfloor \iota(z) \rfloor = z \arrow[d, "G(\iota(z) \leq r)"] \\ & \lfloor r \rfloor \end{tikzcd} \end{figure} the existence of a unique $g = \iota(z) \leq r$ for such an $f$ corresponds to the statement: $$ \iota(z) \leq r \iff z \leq \lfloor r \rfloor.$$ For the converse, consider the ceiling functor $\lceil \cdot \rceil : \mathbb{R} \to \mathbb{Z}$ and the following diagram in $\mathbb{R}$: \begin{figure}[H] \centering \begin{tikzcd} r \arrow[r, "r \leq \iota(\lceil r \rceil)"] \arrow[rd, "r \leq \iota(z)"'] & \iota(\lceil r \rceil) \arrow[d, "\iota(\lceil r \rceil \leq \iota(z))"] \\ & \iota(z) \end{tikzcd} \end{figure} Which corresponds to the statement: $$r \leq \iota(z) \iff \lceil r \rceil \leq z,$$ showing that the inclusion functor is right adjoint to the ceil functor. So we have the adjunction chain: $$\lceil \cdot \rceil \dashv I \dashv \lfloor \cdot \rfloor.$$ \end{example} \begin{example} An important class of adjunctions take the form $\textbf{free} \dashv \textbf{forgetful}$. Let $X$ be a set. The free monoid $F(X)$ is defined as: $$F(X) = (X^*, \concat, ()),$$ see Example \ref{exa:kleene-closure} for the definition of $X^*$, $\concat$ denotes the concatenation of words as a binary operator, and $()$ denotes the empty word. $F$ defines a \emph{free functor}: $$F: \mathbf{Set} \to \mathbf{Mon},$$ sending a set to the free monoid over that set. There is also a \emph{forgetful functor}: $$U: \mathbf{Mon} \to \mathbf{Set},$$ sending a monoid to its underlying set, that sends monoid homomorphisms to the corresponding function on sets. We define: $$\eta: \text{Id}_{\mathbf{Set}} \Rightarrow U \circ F,$$ as having components defining a function that sends an element $x \in X$ to a singleton word containing that element: $$\eta_X(x) = (x).$$ To show that $(F, U, \eta)$ form an adjunction, we consider some $f: X \to U(M)$ where $M$ is a monoid, and we want to show that there is a unique monoid homomorphism $g: F(X) \to M$ that makes the following diagram commute: \begin{figure}[H] \centering \begin{tikzcd} X \arrow[r, "\eta_X"] \arrow[rd, "f"'] & U(F(X)) \arrow[d, "U(g)"] \\ & U(M) \end{tikzcd} \end{figure} We have to define: \begin{align*} g(()) &= \text{id}_M \\ g((x)) &= f(x)\\ g((x_1, x_2, \ldots, x_n)) &= f(x_1) f(x_2) \ldots f(x_n) \end{align*} to make $g$ into a monoid homomorphism that satisfies also: $$f(x) = U(g)(\eta_X x) = U(g)((x)).$$ \end{example} Before moving on, we first show that there are other definitions of adjunctions, which we will show are equivalent to the one we gave above, but are useful for describing other examples of adjunctions. ## Equivalent formulations There is an alternative way of describing adjunctions, as a natural bijection between hom-sets. \begin{definition}[Hom-set adjunctions] Let $\mathcal{C}, \mathcal{D}$ be categories. Let $F: \mathcal{C} \to \mathcal{D}$ and $G: \mathcal{D} \to \mathcal{C}$ be functors. If there is a natural bijection: $$\text{Hom}_{\mathcal{D}}(Fc, d) \stackrel{\phi_{c,d}}{\longrightarrow} \text{Hom}_{\mathcal{C}}(c, Gd),$$ for each $c \in \mathcal{C}$ and $d \in \mathcal{D}$, then $(F, G, \{ \phi_{c, d} \}_{c \in \mathcal{C}, d \in \mathcal{D}})$ is an \emph{adjunction}. Here, the bijection should be natural in both $c$ and $d$, where in $\mathcal{D}$ we have that for all $g: d \to d'$ in $\mathcal{D}$ the following diagram commutes: \begin{figure}[H] \centering \begin{tikzcd} \text{Hom}_\mathcal{D}(Fc, d) \arrow[d, "g \circ \_"'] \arrow[r, "\phi_{c, d}"] & \text{Hom}_\mathcal{C}(c, Gd) \arrow[d, "Gg \circ \_"] \\ \text{Hom}_\mathcal{C}(Fc, d') \arrow[r, "\phi_{c, d'}"] & \text{Hom}_\mathcal{C}(c, Gd') \end{tikzcd} \end{figure} while naturality in $\mathcal{C}$ means that for all $f: c' \to c$ the following diagram commutes: \begin{figure}[H] \centering \begin{tikzcd} \text{Hom}_\mathcal{D}(Fc, d) \arrow[d, "\_ \circ Ff"'] \arrow[r, "\phi_{c, d}"] & \text{Hom}_\mathcal{C}(c, Gd) \arrow[d, "\_ \circ f"] \\ \text{Hom}_\mathcal{C}(Fc', d) \arrow[r, "\phi_{c', d}"] & \text{Hom}_\mathcal{C}(c', Gd) \end{tikzcd} \end{figure} \end{definition} We can show that given a universal arrow adjunction, we can obtain a hom-set adjunction. \begin{proposition} Let $(F, G, \eta)$ be a univeral arrow adjunction. Then the family of functions: \begin{align*} \phi_{c, d}:~&\text{Hom}_\mathcal{D}(Fc, d) \to \text{Hom}_\mathcal{C}(c, Gd), \\ & (\alpha: Fc \to d) \mapsto G \alpha \circ \eta_c \end{align*} defines a hom-set adjunction $(F, G, \{ \phi_{c, d} \}_{c \in \mathcal{C}, d \in \mathcal{D}})$. \end{proposition} \begin{proof} First we show that $\phi_{c, d}$ is a bijection. Because $(F, G, \eta)$ is an adjunction, we know that: $$\forall f: c \to Gd, \exists !~g: Fc \to d, \text{ s.t. } f = Gg \circ \eta_c.$$ Injectivity of $\phi_{c, d}$ is guaranteed by the uniqueness of the arrow $g$, while surjectivity is guaranteed by the existence of such an arrow. Next we have to show that it is natural in both $\mathcal{C}$, and $\mathcal{D}$ which means respectively that for all $f: c' \to c$ and $g: d \to d'$: \begin{align} G\alpha \circ \eta_c \circ f &= G(\alpha \circ Ff) \circ \eta_{c'} \label{eqn:natural-in-c}\\ Gg \circ G\alpha \circ \eta_c &= G(g \circ \alpha) \circ \eta_c \label{eqn:natural-in-d} \end{align} Equation \ref{eqn:natural-in-c} follows from the functoriality of $G$ and the naturality of $\eta$: $$G(\alpha \circ Ff) \circ \eta_{c'} = G(\alpha) \circ G(Ff) \circ \eta_{c'} = G(\alpha) \circ \eta_c \circ f.$$ Equation \ref{eqn:natural-in-d} follows directly from the functoriality of $G$. \end{proof} \begin{definition}[Unit-counit adjunctions] Let $\mathcal{C}, \mathcal{D}$ be categories. Let $F: \mathcal{C} \to \mathcal{D}$ and $G: \mathcal{D} \to \mathcal{C}$ be functors. If there are natural transformations: $$\eta: \text{Id}_\mathcal{C} \Rightarrow GF,~\epsilon: FG \Rightarrow \text{Id}_\mathcal{D},$$ such that the following diagrams (the \emph{triangle identities}) commute: \begin{figure}[H] \centering \begin{tikzcd} F \arrow[r, Rightarrow, "F\eta"] \arrow[dr, Rightarrow, "\text{id}_F"'] & FGF \arrow[d, Rightarrow, "\epsilon F"] \\ & F \end{tikzcd} \end{figure} \begin{figure}[H] \centering \begin{tikzcd} G \arrow[r, Rightarrow, "\eta G"] \arrow[dr, Rightarrow, "\text{id}_G"'] & GFG \arrow[d, Rightarrow, "G \epsilon"] \\ & G \end{tikzcd} \end{figure} where we use the notation (now in components) $(\eta G)_d = \eta_{Gd}$ and $(F \eta)_c = F(\eta_c)$, then $(F, G, \eta, \epsilon)$ is an \emph{adjunction}. We call $\eta$ the \emph{unit} and $\epsilon$ the \emph{counit} of the adjunction. \end{definition} Note that this means that the unit is the \emph{translated inverse} of the counit and vice versa. \begin{proposition} We can construct a unit-counit adjunction $(F, G, \eta, \epsilon)$ from a hom-set adjunction. \end{proposition} \begin{proof} We define $\eta$ and $\epsilon$ as having components: \begin{align} \eta_c: c \to GFc &= \phi_{c, Fc}(\text{id}_{Fc}) \label{eqn:unit-from-hom}\\ \epsilon_d: FGd \to d &= \phi^{-1}_{Gd, d}(\text{id}_{Gd}) \label{eqn:counit-from-hom} \end{align} Let us prove that $\eta$ is a natural transformation, the proof of the naturality of $\epsilon$ is dual to this. We want to show that the following diagram commutes for all $f: c \to c'$: \begin{figure}[H] \centering \begin{tikzcd} c \arrow[d, "f"] \arrow[r, "\eta_c"] & GFc \arrow[d, "GFf"] \\ c'\arrow[r, "\eta_{c'}"] & GFc' \end{tikzcd} \end{figure} i.e. that: $$\alongtop = GF f \circ \eta_c = \eta_{c'} \circ f = \alongbottom$$ Plugging in our definition for $\eta_c$, and using the naturality of $\phi_{c, d}$ we see: \begin{align*} GFf \circ \phi_{c, Fc}(\text{id}_{Fc}) &= \phi_{c, Fc'} (Ff \circ \text{id}_{Fc}) \\ &= \phi_{c, Fc'} (\text{id}_{Fc'} \circ Ff) \\ &= \phi_{c', Fc'} (\text{id}_{Fc'}) \circ f = \eta_{c'} \circ f \end{align*} To show the first triangle identity, i.e. that for all $c \in \mathcal{C}$: $$\epsilon_{Fc} \circ F(\eta_c) = \text{id}_{Fc},$$ we use naturality of $\phi_{GFc, Fc}^{-1}$: \begin{align*} \phi^{-1}_{GFc, Fc}(\text{id}_{GFc}) \circ F(\phi_{c, Fc}(\text{id}_{Fc})) &= \phi^{-1}_{c, Fc} (\text{id}_{GFc} \circ \phi_{c, Fc}(\text{id}_{Fc})) \\ &= \phi^{-1}_{c, Fc} (\phi_{c, Fc}(\text{id}_{Fc})) = \text{id}_{Fc} \end{align*} For the second triangle identity, i.e. for all $d \in \mathcal{D}$: $$G(\epsilon_d) \circ \eta_{Gd} = \text{id}_{Gd},$$ we use the naturality of $\phi_{Gd, FGd}$: \begin{align*} G(\phi^{-1}_{Gd, d}(\text{id}_Gd)) \circ \phi_{Gd, FGd}(\text{id}_{FGd}) &= \phi_{Gd, d}(\phi^{-1}_{Gb, b} (\text{id}_{Gb}) \circ \text{id}_{FGb}) \\ &= \phi_{Gd, d}(\phi^{-1}_{Gb, b} (\text{id}_{Gb})) = \text{id}_{Gb} \end{align*} \qedhere \end{proof} To complete the cycle of equalities, we show that we can retrieve our original universal arrow adjunction from the unit-counit adjunction. \begin{proposition} Let $(F, G, \eta, \epsilon)$ be a unit-counit adjunction. Then $(F, G, \eta)$ forms a universal arrow adjunction. \end{proposition} \begin{proof} Let $f: c \to Gd$. We need to show that there is a unique solution to the equation $G(?) \circ \eta_c = f$. From the second triangle identity, naturality of $\eta$, and functorality of $G$, we have: \begin{align*} G(\epsilon_d) \circ \eta_{Gd} &= \text{id}_{Gd} \\ G(\epsilon_d) \circ \eta_{Gd} \circ f &= f \\ G(\epsilon_d) \circ GF f \circ \eta_{c} &= f \\ G(\epsilon_d \circ F f) \circ \eta_{c} &= f \end{align*} So that the required $g \equiv \epsilon_d \circ F f: F c \rightarrow d$ exists. To show that it is unique, let: \begin{align*} f &= G(g) \circ \eta_c \\ Ff &= FG(g) \circ F\eta_c \\ \epsilon_d \circ Ff &= \epsilon_d \circ FG(g) \circ F\eta_c \\ \epsilon_d \circ Ff &= g \circ \epsilon_{Fd} \circ F\eta_c \\ \epsilon_d \circ Ff &= g \circ \text{id}_{Fc} \\ \epsilon_d \circ Ff &= g \end{align*} So $g$ must be of this form, as required. \qedhere \end{proof} Summarizing what we saw so far, adjunctions can be defined either as: 1. _Universal arrow adjunction_: As a triple $(F, G, \eta)$ together with a universal mapping property. 2. _Hom-set adjunction_: As a natural bijection between hom-sets 3. _Unit-counit adjunction_: As $(F, G, \eta, \epsilon)$ satisfying the triangle identities. And we showed $1 \implies 2 \implies 3 \implies 1$, meaning that all these definitions are equivalent. ## Uniqueness of adjoints You can show that adjoints are unique up to natural isomorphism. Say $F, F': \mathcal{C} \to \mathcal{D}$ and $G: \mathcal{D} \to \mathcal{C}$. Assume $F \dashv G$ and $F' \dashv G$, with natural bijections $\phi_{c, d}$ and $\phi'_{c, d}$ respectively. Then we have for all $c \in \mathcal{C}$: $$\text{Hom}_\mathcal{D}(Fc, -) \simeq \text{Hom}_\mathcal{C}(c, G-) \simeq \text{Hom}_\mathcal{D}(F'c, -),$$ through natural isomorphisms in $\mathbf{Set}$ defined by $\phi_{c, -}$ and $\phi'_{c, -}$ respectively, by composing them we obtain: $$\text{Hom}_\mathcal{D}(Fc, -) \simeq \text{Hom}_\mathcal{D}(F'c, -),$$ but the Yoneda embedding then says that $Fc$ and $F'c$ are isomorphic (see Corollary \ref{cor:natural_transformation_arrow}). To show that these isomorphisms $Fc \to Fc'$ define the components of a natural isomorphism $F \Rightarrow F'$ we have to show that the following diagram commutes: \begin{figure}[H] \centering \begin{tikzcd} Fc \arrow[d, "Ff"'] \arrow[r, "\simeq"] & F'c \arrow[d, "F'f"]\\ Fc' \arrow[r, "\simeq"'] & F'c' \end{tikzcd} \end{figure} Because the Hom-functor $\text{Hom}_\mathcal{C}(-, d)$ is faithful, the above diagram commutes if\footnote{You can prove that faithful functors reflect commutative diagrams, by showing that it preserves non-commutative diagrams}: \begin{figure}[H] \centering \begin{tikzcd} \text{Hom}(d, Fc) \arrow[d, "h^d(Ff)"'] \arrow[r, "\simeq"] & \text{Hom}(d, F'c) \arrow[d, "h^d(F'f)"]\\ \text{Hom}(d, Fc') \arrow[r, "\simeq"'] & \text{Hom}(d, F'c') \end{tikzcd} \end{figure} which commutes by the naturality of $\phi_{c, d}$ (in $\mathcal{D}$). We conclude that adjoints are unique up to natural isomorphism. ## Examples \begin{example} The exponential object of a CCC is described by an adjunction. Consider the functor: \begin{align*} - \times c:~&\mathcal{C} \to \mathcal{C},\\ &a \mapsto a \times c,\\ &f: a \to b \mapsto f \times \text{id}_c. \end{align*} Here, $f \times \text{id}_c$ is the unique arrow from $a \times c \to b \times c$ that makes the following diagram commute: \begin{figure}[H] \centering \begin{tikzcd} a \arrow[dd, "f"'] & a \times c \arrow[l, "p_1"'] \arrow[r, "p_2"] \arrow[d, dashed, "f \times \text{id}_c"] & c \arrow[dd, "\text{id}_c"] \\ & b \times c \arrow[dl, "p_1'"'] \arrow[dr, "p_2'"]& \\ b & & c \end{tikzcd} \end{figure} If $- \times c$ has a right adjoint, which we will suggestively denote: $$(- \times c) \dashv (c \to -),$$ then for this adjunction, the universal property in Exercise \ref{exc:universal-mapping-property-counit} states: For any $g: a \times c \to b$ there exists a unique arrow $f \equiv \lambda g : a \to (c \to b)$ such that the following diagram commutes: \begin{figure}[H] \centering \begin{tikzcd} b & (c \to b) \times c \arrow[l, "\epsilon_b"'] \\ & \arrow[lu, "g"] \arrow[u, "\lambda g \times \text{id}_c"'] a \times c \end{tikzcd} \end{figure} so that the universal property for the counit is identical to the universal property of the evaluation function, compare also with Definition \ref{def:ccc} of a CCC. Since adjoints are essentially unique, the exponential is determined by the adjunction. You can show that adjunctions preserve (among other constructions involving universal properties) initial objects, terminal objects and products, which can be used to prove many useful and familiar equalities in a CCC. For example, we have $R_a(b \times c) \simeq R_a(b) \times R_a(c)$ which in the notation $a \to b \equiv b^a$ says: $$(b \times c)^a \simeq b^a \times c^a.$$ Conversely, the product functor preserves coproducts, in that $(- \times c)(a + b) \simeq (- \times c)a + (- \times c)b$, or: $$(a + b) \times c \simeq (a \times c) + (b \times c),$$ which shows that CCC's are distributative. \end{example} Other examples: - Free/forgetful functor pairs. - Groups $G$ and their abelianizations $G^{ab} \equiv G / [G, G]$ form an adjunction. - As an interesting application that we will see shortly, adjunctions also give rise to monads. ## Exercises \begin{exercise} Argue using duality that the counit satisfies the following universal mapping property: For any $g: Fc \to d$ there is a unique arrow $f: c \to Gd$ such that the following diagram commutes: \begin{figure}[H] \centering \begin{tikzcd} d & FGd \arrow[l, "\epsilon_d"'] \\ & \arrow[lu, "g"] \arrow[u, "Ff"'] Fc \end{tikzcd} \end{figure} \label{exc:universal-mapping-property-counit} \end{exercise} \begin{exercise} Let $\Delta: \mathcal{C} \to \mathcal{C} \times \mathcal{C}$ be the \emph{diagonal functor} defined as: \begin{align*} \Delta a &= (a, a) \\ \Delta (f: a \to b) &= (f, f) : (a, a) \to (b, b) \end{align*} Show that the category $\mathcal{C}$ has binary products if and only if $\Delta$ has a right adjoint $\Pi$. Here, the functor $\Pi: \mathcal{C} \times \mathcal{C} \to \mathcal{C}$ should send $(a, b) \mapsto a \times b$. \emph{Hint:} write the components of the counit and the arrows that arise in the universal arrow property of the counit (see Exercise \ref{exc:universal-mapping-property-counit}), in terms components of $\mathcal{C} \times \mathcal{C}$, i.e. $\epsilon_d = (p_1, p_2)$, $f = (q_1, q_2)$. Use that a diagram in $\mathcal{C} \times \mathcal{C}$ commutes if and only if the diagrams for each component commute, and show that you obtain the definition for the binary product. \end{exercise} \begin{exercise} Although we proved almost everything equationally in this part, some parts can be proved more efficiently using the Yoneda lemma, for example we consider the natural bijection in the definition of a hom-set adjunction as a natural transformation between the hom-functors: $$\text{Hom}(F-, -) \Rightarrow \text{Hom}(-, G-)$$ from $\mathcal{C}^{\text{op}} \times \mathcal{D} \to \mathbf{Set}$. Think about this. \end{exercise} ## References - <https://www.youtube.com/watch?v=K8f19pXB3ts> - Chapter 13 of Barr and Wells - Chapter 4 of Riehl - Chapter 4 of Mac Lane
jmgimeno/category-theory-programmers
doc/07_adjunctions.md
Markdown
mit
19,371
[ 30522, 1001, 20621, 8496, 1032, 4958, 8004, 24342, 1063, 1000, 4748, 5558, 18447, 4569, 24817, 13368, 7249, 1000, 1065, 1063, 1032, 7861, 8458, 1063, 15247, 6097, 4644, 1065, 1065, 2045, 2024, 3674, 3971, 2000, 8970, 20621, 8496, 1010, 2119...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.integer :identity_id t.string :first_name t.string :last_name t.timestamps end add_index :users, :identity_id, unique: true end end
paulnsorensen/donezo
db/migrate/20140605230624_create_users.rb
Ruby
mit
258
[ 30522, 2465, 3443, 20330, 2015, 1026, 3161, 2890, 27108, 2094, 1024, 1024, 9230, 13366, 2689, 3443, 1035, 2795, 1024, 5198, 2079, 1064, 1056, 1064, 1056, 1012, 16109, 1024, 4767, 1035, 8909, 1056, 1012, 5164, 1024, 2034, 1035, 2171, 1056, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP # # Licensed under the Apache License, Version 2.0 (the "License"); # You may not use this file except in compliance with the License. # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software distributed # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR # CONDITIONS OF ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. require_relative '../../api200/server_hardware_type' module OneviewSDK module API300 module Synergy class ServerHardwareType < OneviewSDK::API200::ServerHardwareType end end end end
HewlettPackard/oneview-sdk-ruby
lib/oneview-sdk/resource/api300/synergy/server_hardware_type.rb
Ruby
apache-2.0
807
[ 30522, 1001, 1006, 1039, 1007, 9385, 2355, 2002, 13668, 6582, 24100, 6960, 2458, 6948, 1001, 1001, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 1001, 2017, 2089, 2025, 2224, 2023, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="icon" href="http://getbootstrap.com/favicon.ico"> <title>AngularJS & Firebase Web App</title> <link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet"> <script type="text/javascript" src="../js/spin.min.js"></script> <script type="text/javascript" src="../js/ladda.js"></script> <link rel="stylesheet" type="text/css" href="../assets/css/style.css"> </head> <body ng-controller="TestCtrl"> <div class="container"> <div class="jumbotron" style="padding-bottom:0px;"> <h2>AngularJS & Firebase App!</h2> </div> <button data-ui-ladda="login.loading" type="submit" ng-click="test()" id="btnSignIn" class="btn btn-primary segoe-ui-light ladda-button" data-style="expand-right"> <span class="ladda-label">Sign In</span> </button> </div> </body></html>
Rickcy/AngularShop
app/test/test.html
HTML
mit
1,025
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 11374, 1027, 1000, 4372, 1000, 1028, 1026, 2132, 1028, 1026, 18804, 8299, 1011, 1041, 15549, 2615, 1027, 1000, 4180, 1011, 2828, 1000, 4180, 1027, 1000, 3793, 1013, 16129, 1025, 25869...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
'use strict'; // Adapted from https://github.com/tleunen/babel-plugin-module-resolver/blob/master/src/normalizeOptions.js const path = require('path'); const { createSelector } = require('reselect'); const defaultExtensions = ['.js']; const normalizeRoots = (optsRoot, cwd) => { return Object.keys(optsRoot).reduce((acc, current) => { const dirPath = path.resolve(cwd, optsRoot[current]); acc[current] = dirPath; return acc; }, {}); }; const normalizeOptions = createSelector( // TODO check if needed currentFile => (currentFile.includes('.') ? path.dirname(currentFile) : currentFile), (_, opts) => opts, (_, opts) => { const cwd = process.cwd(); const roots = normalizeRoots(opts.roots, cwd); return { cwd, roots, extensions: defaultExtensions, }; } ); module.exports = normalizeOptions;
wistityhq/strapi
packages/utils/babel-plugin-switch-ee-ce/lib/normalizeOptions.js
JavaScript
mit
859
[ 30522, 1005, 2224, 9384, 1005, 1025, 1013, 1013, 5967, 2013, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 1056, 2571, 9816, 2078, 1013, 11561, 2140, 1011, 13354, 2378, 1011, 11336, 1011, 10663, 2099, 1013, 1038, 4135, 2497...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright 2000-2009 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.intellij.lexer; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; import com.intellij.util.text.CharArrayUtil; import java.io.IOException; public class DocCommentLexer extends MergingLexerAdapter { public DocCommentLexer(final DocCommentTokenTypes tokenTypes, final boolean isJdk15Enabled) { super(new AsteriskStripperLexer(new _JavaDocLexer(isJdk15Enabled, tokenTypes), tokenTypes), TokenSet.create(tokenTypes.commentData(), tokenTypes.space())); } private static class AsteriskStripperLexer extends LexerBase { private final _JavaDocLexer myFlex; private final DocCommentTokenTypes myTokenTypes; private CharSequence myBuffer; private int myBufferIndex; private int myBufferEndOffset; private int myTokenEndOffset; private int myState; private IElementType myTokenType; private boolean myAfterLineBreak; private boolean myInLeadingSpace; public AsteriskStripperLexer(final _JavaDocLexer flex, final DocCommentTokenTypes tokenTypes) { myFlex = flex; myTokenTypes = tokenTypes; } public final void start(CharSequence buffer, int startOffset, int endOffset, int initialState) { myBuffer = buffer; myBufferIndex = startOffset; myBufferEndOffset = endOffset; myTokenType = null; myTokenEndOffset = startOffset; myFlex.reset(myBuffer, startOffset, endOffset, initialState); } public int getState() { return myState; } public CharSequence getBufferSequence() { return myBuffer; } public int getBufferEnd() { return myBufferEndOffset; } public final IElementType getTokenType() { locateToken(); return myTokenType; } public final int getTokenStart() { locateToken(); return myBufferIndex; } public final int getTokenEnd() { locateToken(); return myTokenEndOffset; } public final void advance() { locateToken(); myTokenType = null; } protected final void locateToken() { if (myTokenType != null) return; _locateToken(); if (myTokenType == myTokenTypes.space()) { myAfterLineBreak = CharArrayUtil.containLineBreaks(myBuffer, getTokenStart(), getTokenEnd()); } } private void _locateToken() { if (myTokenEndOffset == myBufferEndOffset) { myTokenType = null; myBufferIndex = myBufferEndOffset; return; } myBufferIndex = myTokenEndOffset; if (myAfterLineBreak) { myAfterLineBreak = false; while (myTokenEndOffset < myBufferEndOffset && myBuffer.charAt(myTokenEndOffset) == '*' && (myTokenEndOffset + 1 >= myBufferEndOffset || myBuffer.charAt(myTokenEndOffset + 1) != '/')) { myTokenEndOffset++; } myInLeadingSpace = true; if (myBufferIndex < myTokenEndOffset) { myTokenType = myTokenTypes.commentLeadingAsterisks(); return; } } if (myInLeadingSpace) { myInLeadingSpace = false; boolean lf = false; while (myTokenEndOffset < myBufferEndOffset && Character.isWhitespace(myBuffer.charAt(myTokenEndOffset))) { if (myBuffer.charAt(myTokenEndOffset) == '\n') lf = true; myTokenEndOffset++; } final int state = myFlex.yystate(); if (state == _JavaDocLexer.COMMENT_DATA || myTokenEndOffset < myBufferEndOffset && (myBuffer.charAt(myTokenEndOffset) == '@' || myBuffer.charAt(myTokenEndOffset) == '{' || myBuffer.charAt(myTokenEndOffset) == '\"' || myBuffer.charAt(myTokenEndOffset) == '<')) { myFlex.yybegin(_JavaDocLexer.COMMENT_DATA_START); } if (myBufferIndex < myTokenEndOffset) { myTokenType = lf || state == _JavaDocLexer.PARAM_TAG_SPACE || state == _JavaDocLexer.TAG_DOC_SPACE || state == _JavaDocLexer.INLINE_TAG_NAME || state == _JavaDocLexer.DOC_TAG_VALUE_IN_PAREN ? myTokenTypes.space() : myTokenTypes.commentData(); return; } } flexLocateToken(); } private void flexLocateToken() { try { myState = myFlex.yystate(); myFlex.goTo(myBufferIndex); myTokenType = myFlex.advance(); myTokenEndOffset = myFlex.getTokenEnd(); } catch (IOException e) { // Can't be } } } }
jexp/idea2
platform/lang-api/src/com/intellij/lexer/DocCommentLexer.java
Java
apache-2.0
5,217
[ 30522, 1013, 1008, 1008, 9385, 2456, 1011, 2268, 6892, 10024, 7076, 1055, 1012, 1054, 1012, 1051, 1012, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 1008, 2017, 2089, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace AppBundle\Form; use AppBundle\AppBundle; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; class ProductType extends AbstractType { /** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('name') ->add('price') ->add('productType') ; } /** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'data_class' => 'AppBundle\Entity\Product' )); } /** * {@inheritdoc} */ public function getBlockPrefix() { return 'appbundle_product'; } }
Bunkermaster/exosymfony
src/AppBundle/Form/ProductType.php
PHP
mit
885
[ 30522, 1026, 1029, 25718, 3415, 15327, 10439, 27265, 2571, 1032, 2433, 1025, 2224, 10439, 27265, 2571, 1032, 10439, 27265, 2571, 1025, 2224, 25353, 2213, 14876, 4890, 1032, 2958, 1032, 8998, 1032, 2433, 1032, 2828, 1032, 9178, 13874, 1025, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package org.pikater.web; import java.util.logging.Level; import java.util.logging.Logger; import org.pikater.shared.logging.GeneralPikaterLogger; import org.pikater.shared.logging.IPikaterLogger; /** * Special logger wrapper to be used by the web application. * * @author SkyCrawl */ public class PikaterWebLogger extends GeneralPikaterLogger { private static final IPikaterLogger innerLogger = createPikaterLogger(Logger.getLogger("log4j")); public static IPikaterLogger getLogger() { return innerLogger; } public static void logThrowable(String message, Throwable t) { getLogger().logThrowable(message, t); } public static void log(Level logLevel, String message) { getLogger().log(logLevel, message); } public static void log(Level logLevel, String source, String message) { getLogger().log(logLevel, source, message); } }
SkyCrawl/pikater-vaadin
src/org/pikater/web/PikaterWebLogger.java
Java
apache-2.0
857
[ 30522, 7427, 8917, 1012, 14255, 24498, 2121, 1012, 4773, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 15899, 1012, 2504, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 15899, 1012, 8833, 4590, 1025, 12324, 8917, 1012, 14255, 24498, 2121, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# sqlite-to-mongo This is a node package that will help you move your data from sqlite to MongoDB ## Basic Usage ``` const SqliteToMongo = require('sqlite-to-mongo'); var importer = new SqliteToMongo('db.sqlite', 'mongodb://localhost/dbname', function () { importer.importCollection('newMongoCollection', { tableName : "SQLiteTable", columns: { SQLite_Column: 'MongoColumn', SQLite_AnotherColumn: 'AnotherMongoColumn', EMAIL: 'profile.email' } } ); ``` ## Import from a given query ``` importer.importCollection('books', { query: 'select a.author_name author, b.id id, b.bookname book ' + 'from authors_table a left ' + 'outer join books_table b ' + 'on b.author_id = a.id ', columns: { id: '_id', book: 'name', author : 'author' } }); ``` ## Import with preset values ``` importer.importCollection('books', { query: 'select a.author_name author, b.id id, b.bookname book ' + 'from authors_table a left ' + 'outer join books_table b ' + 'on b.author_id = a.id', columns: { id: '_id', book: 'name', author : 'author' }, presets: { publisher: 'Barnes and Noble' } }); ``` ## Import and update based on values from the query ``` importer.importCollection('books', { query: 'select a.author_name author, b.id id, b.bookname book, b.price price' + 'from authors_table a left ' + 'outer join books_table b ' + 'on b.author_id = a.id', columns: { id: '_id', book: 'name', author : 'author', price: 'price' }, selector: { '_id': 'id' } }); ``` ## Custom Callback ``` importer.importCollection('users', { tableName : "USERS_TABLE", columns: { ID: '_id', USERNAME: 'username', EMAIL : 'profile.email' } }, /** * Called after operation has finished. * * @param err Can be empty. * @param num Number of total operations. */ function (err, num) { if (err) throw new Error(err); console.log('Number of operations:', num); } ); ```
davidyaha/sqlite-to-mongo
README.md
Markdown
mit
2,101
[ 30522, 1001, 29296, 4221, 1011, 2000, 1011, 12256, 3995, 2023, 2003, 1037, 13045, 7427, 2008, 2097, 2393, 2017, 2693, 2115, 2951, 2013, 29296, 4221, 2000, 12256, 3995, 18939, 1001, 1001, 3937, 8192, 1036, 1036, 1036, 9530, 3367, 29296, 4221...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Clean ups from Moschip version and a few ioctl implementations by: * Paul B Schroeder <pschroeder "at" uplogix "dot" com> * * Originally based on drivers/usb/serial/io_edgeport.c which is: * Copyright (C) 2000 Inside Out Networks, All rights reserved. * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com> * */ #include <linux/kernel.h> #include <linux/errno.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/tty.h> #include <linux/tty_driver.h> #include <linux/tty_flip.h> #include <linux/module.h> #include <linux/serial.h> #include <linux/usb.h> #include <linux/usb/serial.h> #include <linux/uaccess.h> /* * Version Information */ #define DRIVER_VERSION "1.3.1" #define DRIVER_DESC "Moschip 7840/7820 USB Serial Driver" /* * 16C50 UART register defines */ #define LCR_BITS_5 0x00 /* 5 bits/char */ #define LCR_BITS_6 0x01 /* 6 bits/char */ #define LCR_BITS_7 0x02 /* 7 bits/char */ #define LCR_BITS_8 0x03 /* 8 bits/char */ #define LCR_BITS_MASK 0x03 /* Mask for bits/char field */ #define LCR_STOP_1 0x00 /* 1 stop bit */ #define LCR_STOP_1_5 0x04 /* 1.5 stop bits (if 5 bits/char) */ #define LCR_STOP_2 0x04 /* 2 stop bits (if 6-8 bits/char) */ #define LCR_STOP_MASK 0x04 /* Mask for stop bits field */ #define LCR_PAR_NONE 0x00 /* No parity */ #define LCR_PAR_ODD 0x08 /* Odd parity */ #define LCR_PAR_EVEN 0x18 /* Even parity */ #define LCR_PAR_MARK 0x28 /* Force parity bit to 1 */ #define LCR_PAR_SPACE 0x38 /* Force parity bit to 0 */ #define LCR_PAR_MASK 0x38 /* Mask for parity field */ #define LCR_SET_BREAK 0x40 /* Set Break condition */ #define LCR_DL_ENABLE 0x80 /* Enable access to divisor latch */ #define MCR_DTR 0x01 /* Assert DTR */ #define MCR_RTS 0x02 /* Assert RTS */ #define MCR_OUT1 0x04 /* Loopback only: Sets state of RI */ #define MCR_MASTER_IE 0x08 /* Enable interrupt outputs */ #define MCR_LOOPBACK 0x10 /* Set internal (digital) loopback mode */ #define MCR_XON_ANY 0x20 /* Enable any char to exit XOFF mode */ #define MOS7840_MSR_CTS 0x10 /* Current state of CTS */ #define MOS7840_MSR_DSR 0x20 /* Current state of DSR */ #define MOS7840_MSR_RI 0x40 /* Current state of RI */ #define MOS7840_MSR_CD 0x80 /* Current state of CD */ /* * Defines used for sending commands to port */ #define WAIT_FOR_EVER (HZ * 0) /* timeout urb is wait for ever */ #define MOS_WDR_TIMEOUT (HZ * 5) /* default urb timeout */ #define MOS_PORT1 0x0200 #define MOS_PORT2 0x0300 #define MOS_VENREG 0x0000 #define MOS_MAX_PORT 0x02 #define MOS_WRITE 0x0E #define MOS_READ 0x0D /* Requests */ #define MCS_RD_RTYPE 0xC0 #define MCS_WR_RTYPE 0x40 #define MCS_RDREQ 0x0D #define MCS_WRREQ 0x0E #define MCS_CTRL_TIMEOUT 500 #define VENDOR_READ_LENGTH (0x01) #define MAX_NAME_LEN 64 #define ZLP_REG1 0x3A /* Zero_Flag_Reg1 58 */ #define ZLP_REG5 0x3E /* Zero_Flag_Reg5 62 */ /* For higher baud Rates use TIOCEXBAUD */ #define TIOCEXBAUD 0x5462 /* vendor id and device id defines */ /* The native mos7840/7820 component */ #define USB_VENDOR_ID_MOSCHIP 0x9710 #define MOSCHIP_DEVICE_ID_7840 0x7840 #define MOSCHIP_DEVICE_ID_7820 0x7820 /* The native component can have its vendor/device id's overridden * in vendor-specific implementations. Such devices can be handled * by making a change here, in moschip_port_id_table, and in * moschip_id_table_combined */ #define USB_VENDOR_ID_BANDB 0x0856 #define BANDB_DEVICE_ID_USOPTL4_4 0xAC44 #define BANDB_DEVICE_ID_USOPTL4_2 0xAC42 /* Interrupt Routine Defines */ #define SERIAL_IIR_RLS 0x06 #define SERIAL_IIR_MS 0x00 /* * Emulation of the bit mask on the LINE STATUS REGISTER. */ #define SERIAL_LSR_DR 0x0001 #define SERIAL_LSR_OE 0x0002 #define SERIAL_LSR_PE 0x0004 #define SERIAL_LSR_FE 0x0008 #define SERIAL_LSR_BI 0x0010 #define MOS_MSR_DELTA_CTS 0x10 #define MOS_MSR_DELTA_DSR 0x20 #define MOS_MSR_DELTA_RI 0x40 #define MOS_MSR_DELTA_CD 0x80 /* Serial Port register Address */ #define INTERRUPT_ENABLE_REGISTER ((__u16)(0x01)) #define FIFO_CONTROL_REGISTER ((__u16)(0x02)) #define LINE_CONTROL_REGISTER ((__u16)(0x03)) #define MODEM_CONTROL_REGISTER ((__u16)(0x04)) #define LINE_STATUS_REGISTER ((__u16)(0x05)) #define MODEM_STATUS_REGISTER ((__u16)(0x06)) #define SCRATCH_PAD_REGISTER ((__u16)(0x07)) #define DIVISOR_LATCH_LSB ((__u16)(0x00)) #define DIVISOR_LATCH_MSB ((__u16)(0x01)) #define CLK_MULTI_REGISTER ((__u16)(0x02)) #define CLK_START_VALUE_REGISTER ((__u16)(0x03)) #define SERIAL_LCR_DLAB ((__u16)(0x0080)) /* * URB POOL related defines */ #define NUM_URBS 16 /* URB Count */ #define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */ static struct usb_device_id moschip_port_id_table[] = { {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)}, {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)}, {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4)}, {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2)}, {} /* terminating entry */ }; static __devinitdata struct usb_device_id moschip_id_table_combined[] = { {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)}, {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)}, {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4)}, {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2)}, {} /* terminating entry */ }; MODULE_DEVICE_TABLE(usb, moschip_id_table_combined); /* This structure holds all of the local port information */ struct moschip_port { int port_num; /*Actual port number in the device(1,2,etc) */ struct urb *write_urb; /* write URB for this port */ struct urb *read_urb; /* read URB for this port */ struct urb *int_urb; __u8 shadowLCR; /* last LCR value received */ __u8 shadowMCR; /* last MCR value received */ char open; char open_ports; char zombie; wait_queue_head_t wait_chase; /* for handling sleeping while waiting for chase to finish */ wait_queue_head_t delta_msr_wait; /* for handling sleeping while waiting for msr change to happen */ int delta_msr_cond; struct async_icount icount; struct usb_serial_port *port; /* loop back to the owner of this object */ /* Offsets */ __u8 SpRegOffset; __u8 ControlRegOffset; __u8 DcrRegOffset; /* for processing control URBS in interrupt context */ struct urb *control_urb; struct usb_ctrlrequest *dr; char *ctrl_buf; int MsrLsr; spinlock_t pool_lock; struct urb *write_urb_pool[NUM_URBS]; char busy[NUM_URBS]; }; static int debug; /* * mos7840_set_reg_sync * To set the Control register by calling usb_fill_control_urb function * by passing usb_sndctrlpipe function as parameter. */ static int mos7840_set_reg_sync(struct usb_serial_port *port, __u16 reg, __u16 val) { struct usb_device *dev = port->serial->dev; val = val & 0x00ff; dbg("mos7840_set_reg_sync offset is %x, value %x\n", reg, val); return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ, MCS_WR_RTYPE, val, reg, NULL, 0, MOS_WDR_TIMEOUT); } /* * mos7840_get_reg_sync * To set the Uart register by calling usb_fill_control_urb function by * passing usb_rcvctrlpipe function as parameter. */ static int mos7840_get_reg_sync(struct usb_serial_port *port, __u16 reg, __u16 *val) { struct usb_device *dev = port->serial->dev; int ret = 0; ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, MCS_RD_RTYPE, 0, reg, val, VENDOR_READ_LENGTH, MOS_WDR_TIMEOUT); dbg("mos7840_get_reg_sync offset is %x, return val %x\n", reg, *val); *val = (*val) & 0x00ff; return ret; } /* * mos7840_set_uart_reg * To set the Uart register by calling usb_fill_control_urb function by * passing usb_sndctrlpipe function as parameter. */ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg, __u16 val) { struct usb_device *dev = port->serial->dev; val = val & 0x00ff; /* For the UART control registers, the application number need to be Or'ed */ if (port->serial->num_ports == 4) { val |= (((__u16) port->number - (__u16) (port->serial->minor)) + 1) << 8; dbg("mos7840_set_uart_reg application number is %x\n", val); } else { if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { val |= (((__u16) port->number - (__u16) (port->serial->minor)) + 1) << 8; dbg("mos7840_set_uart_reg application number is %x\n", val); } else { val |= (((__u16) port->number - (__u16) (port->serial->minor)) + 2) << 8; dbg("mos7840_set_uart_reg application number is %x\n", val); } } return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ, MCS_WR_RTYPE, val, reg, NULL, 0, MOS_WDR_TIMEOUT); } /* * mos7840_get_uart_reg * To set the Control register by calling usb_fill_control_urb function * by passing usb_rcvctrlpipe function as parameter. */ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg, __u16 *val) { struct usb_device *dev = port->serial->dev; int ret = 0; __u16 Wval; /* dbg("application number is %4x \n", (((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */ /* Wval is same as application number */ if (port->serial->num_ports == 4) { Wval = (((__u16) port->number - (__u16) (port->serial->minor)) + 1) << 8; dbg("mos7840_get_uart_reg application number is %x\n", Wval); } else { if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { Wval = (((__u16) port->number - (__u16) (port->serial->minor)) + 1) << 8; dbg("mos7840_get_uart_reg application number is %x\n", Wval); } else { Wval = (((__u16) port->number - (__u16) (port->serial->minor)) + 2) << 8; dbg("mos7840_get_uart_reg application number is %x\n", Wval); } } ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, MCS_RD_RTYPE, Wval, reg, val, VENDOR_READ_LENGTH, MOS_WDR_TIMEOUT); *val = (*val) & 0x00ff; return ret; } static void mos7840_dump_serial_port(struct moschip_port *mos7840_port) { dbg("***************************************\n"); dbg("SpRegOffset is %2x\n", mos7840_port->SpRegOffset); dbg("ControlRegOffset is %2x \n", mos7840_port->ControlRegOffset); dbg("DCRRegOffset is %2x \n", mos7840_port->DcrRegOffset); dbg("***************************************\n"); } /************************************************************************/ /************************************************************************/ /* I N T E R F A C E F U N C T I O N S */ /* I N T E R F A C E F U N C T I O N S */ /************************************************************************/ /************************************************************************/ static inline void mos7840_set_port_private(struct usb_serial_port *port, struct moschip_port *data) { usb_set_serial_port_data(port, (void *)data); } static inline struct moschip_port *mos7840_get_port_private(struct usb_serial_port *port) { return (struct moschip_port *)usb_get_serial_port_data(port); } static void mos7840_handle_new_msr(struct moschip_port *port, __u8 new_msr) { struct moschip_port *mos7840_port; struct async_icount *icount; mos7840_port = port; icount = &mos7840_port->icount; if (new_msr & (MOS_MSR_DELTA_CTS | MOS_MSR_DELTA_DSR | MOS_MSR_DELTA_RI | MOS_MSR_DELTA_CD)) { icount = &mos7840_port->icount; /* update input line counters */ if (new_msr & MOS_MSR_DELTA_CTS) { icount->cts++; smp_wmb(); } if (new_msr & MOS_MSR_DELTA_DSR) { icount->dsr++; smp_wmb(); } if (new_msr & MOS_MSR_DELTA_CD) { icount->dcd++; smp_wmb(); } if (new_msr & MOS_MSR_DELTA_RI) { icount->rng++; smp_wmb(); } } } static void mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr) { struct async_icount *icount; dbg("%s - %02x", __func__, new_lsr); if (new_lsr & SERIAL_LSR_BI) { /* * Parity and Framing errors only count if they * occur exclusive of a break being * received. */ new_lsr &= (__u8) (SERIAL_LSR_OE | SERIAL_LSR_BI); } /* update input line counters */ icount = &port->icount; if (new_lsr & SERIAL_LSR_BI) { icount->brk++; smp_wmb(); } if (new_lsr & SERIAL_LSR_OE) { icount->overrun++; smp_wmb(); } if (new_lsr & SERIAL_LSR_PE) { icount->parity++; smp_wmb(); } if (new_lsr & SERIAL_LSR_FE) { icount->frame++; smp_wmb(); } } /************************************************************************/ /************************************************************************/ /* U S B C A L L B A C K F U N C T I O N S */ /* U S B C A L L B A C K F U N C T I O N S */ /************************************************************************/ /************************************************************************/ static void mos7840_control_callback(struct urb *urb) { unsigned char *data; struct moschip_port *mos7840_port; __u8 regval = 0x0; int result = 0; int status = urb->status; mos7840_port = urb->context; switch (status) { case 0: /* success */ break; case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", __func__, status); return; default: dbg("%s - nonzero urb status received: %d", __func__, status); goto exit; } dbg("%s urb buffer size is %d\n", __func__, urb->actual_length); dbg("%s mos7840_port->MsrLsr is %d port %d\n", __func__, mos7840_port->MsrLsr, mos7840_port->port_num); data = urb->transfer_buffer; regval = (__u8) data[0]; dbg("%s data is %x\n", __func__, regval); if (mos7840_port->MsrLsr == 0) mos7840_handle_new_msr(mos7840_port, regval); else if (mos7840_port->MsrLsr == 1) mos7840_handle_new_lsr(mos7840_port, regval); exit: spin_lock(&mos7840_port->pool_lock); if (!mos7840_port->zombie) result = usb_submit_urb(mos7840_port->int_urb, GFP_ATOMIC); spin_unlock(&mos7840_port->pool_lock); if (result) { dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n", __func__, result); } } static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg, __u16 *val) { struct usb_device *dev = mcs->port->serial->dev; struct usb_ctrlrequest *dr = mcs->dr; unsigned char *buffer = mcs->ctrl_buf; int ret; dr->bRequestType = MCS_RD_RTYPE; dr->bRequest = MCS_RDREQ; dr->wValue = cpu_to_le16(Wval); /* 0 */ dr->wIndex = cpu_to_le16(reg); dr->wLength = cpu_to_le16(2); usb_fill_control_urb(mcs->control_urb, dev, usb_rcvctrlpipe(dev, 0), (unsigned char *)dr, buffer, 2, mos7840_control_callback, mcs); mcs->control_urb->transfer_buffer_length = 2; ret = usb_submit_urb(mcs->control_urb, GFP_ATOMIC); return ret; } /***************************************************************************** * mos7840_interrupt_callback * this is the callback function for when we have received data on the * interrupt endpoint. *****************************************************************************/ static void mos7840_interrupt_callback(struct urb *urb) { int result; int length; struct moschip_port *mos7840_port; struct usb_serial *serial; __u16 Data; unsigned char *data; __u8 sp[5], st; int i, rv = 0; __u16 wval, wreg = 0; int status = urb->status; dbg("%s", " : Entering\n"); switch (status) { case 0: /* success */ break; case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: /* this urb is terminated, clean up */ dbg("%s - urb shutting down with status: %d", __func__, status); return; default: dbg("%s - nonzero urb status received: %d", __func__, status); goto exit; } length = urb->actual_length; data = urb->transfer_buffer; serial = urb->context; /* Moschip get 5 bytes * Byte 1 IIR Port 1 (port.number is 0) * Byte 2 IIR Port 2 (port.number is 1) * Byte 3 IIR Port 3 (port.number is 2) * Byte 4 IIR Port 4 (port.number is 3) * Byte 5 FIFO status for both */ if (length && length > 5) { dbg("%s \n", "Wrong data !!!"); return; } sp[0] = (__u8) data[0]; sp[1] = (__u8) data[1]; sp[2] = (__u8) data[2]; sp[3] = (__u8) data[3]; st = (__u8) data[4]; for (i = 0; i < serial->num_ports; i++) { mos7840_port = mos7840_get_port_private(serial->port[i]); wval = (((__u16) serial->port[i]->number - (__u16) (serial->minor)) + 1) << 8; if (mos7840_port->open) { if (sp[i] & 0x01) { dbg("SP%d No Interrupt !!!\n", i); } else { switch (sp[i] & 0x0f) { case SERIAL_IIR_RLS: dbg("Serial Port %d: Receiver status error or ", i); dbg("address bit detected in 9-bit mode\n"); mos7840_port->MsrLsr = 1; wreg = LINE_STATUS_REGISTER; break; case SERIAL_IIR_MS: dbg("Serial Port %d: Modem status change\n", i); mos7840_port->MsrLsr = 0; wreg = MODEM_STATUS_REGISTER; break; } spin_lock(&mos7840_port->pool_lock); if (!mos7840_port->zombie) { rv = mos7840_get_reg(mos7840_port, wval, wreg, &Data); } else { spin_unlock(&mos7840_port->pool_lock); return; } spin_unlock(&mos7840_port->pool_lock); } } } if (!(rv < 0)) /* the completion handler for the control urb will resubmit */ return; exit: result = usb_submit_urb(urb, GFP_ATOMIC); if (result) { dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n", __func__, result); } } static int mos7840_port_paranoia_check(struct usb_serial_port *port, const char *function) { if (!port) { dbg("%s - port == NULL", function); return -1; } if (!port->serial) { dbg("%s - port->serial == NULL", function); return -1; } return 0; } /* Inline functions to check the sanity of a pointer that is passed to us */ static int mos7840_serial_paranoia_check(struct usb_serial *serial, const char *function) { if (!serial) { dbg("%s - serial == NULL", function); return -1; } if (!serial->type) { dbg("%s - serial->type == NULL!", function); return -1; } return 0; } static struct usb_serial *mos7840_get_usb_serial(struct usb_serial_port *port, const char *function) { /* if no port was specified, or it fails a paranoia check */ if (!port || mos7840_port_paranoia_check(port, function) || mos7840_serial_paranoia_check(port->serial, function)) { /* then say that we don't have a valid usb_serial thing, * which will end up genrating -ENODEV return values */ return NULL; } return port->serial; } /***************************************************************************** * mos7840_bulk_in_callback * this is the callback function for when we have received data on the * bulk in endpoint. *****************************************************************************/ static void mos7840_bulk_in_callback(struct urb *urb) { int retval; unsigned char *data; struct usb_serial *serial; struct usb_serial_port *port; struct moschip_port *mos7840_port; struct tty_struct *tty; int status = urb->status; if (status) { dbg("nonzero read bulk status received: %d", status); return; } mos7840_port = urb->context; if (!mos7840_port) { dbg("%s", "NULL mos7840_port pointer \n"); return; } port = (struct usb_serial_port *)mos7840_port->port; if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Port Paranoia failed \n"); return; } serial = mos7840_get_usb_serial(port, __func__); if (!serial) { dbg("%s\n", "Bad serial pointer "); return; } dbg("%s\n", "Entering... \n"); data = urb->transfer_buffer; dbg("%s", "Entering ........... \n"); if (urb->actual_length) { tty = mos7840_port->port->port.tty; if (tty) { tty_buffer_request_room(tty, urb->actual_length); tty_insert_flip_string(tty, data, urb->actual_length); dbg(" %s \n", data); tty_flip_buffer_push(tty); } mos7840_port->icount.rx += urb->actual_length; smp_wmb(); dbg("mos7840_port->icount.rx is %d:\n", mos7840_port->icount.rx); } if (!mos7840_port->read_urb) { dbg("%s", "URB KILLED !!!\n"); return; } mos7840_port->read_urb->dev = serial->dev; retval = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); if (retval) { dbg(" usb_submit_urb(read bulk) failed, retval = %d", retval); } } /***************************************************************************** * mos7840_bulk_out_data_callback * this is the callback function for when we have finished sending * serial data on the bulk out endpoint. *****************************************************************************/ static void mos7840_bulk_out_data_callback(struct urb *urb) { struct moschip_port *mos7840_port; struct tty_struct *tty; int status = urb->status; int i; mos7840_port = urb->context; spin_lock(&mos7840_port->pool_lock); for (i = 0; i < NUM_URBS; i++) { if (urb == mos7840_port->write_urb_pool[i]) { mos7840_port->busy[i] = 0; break; } } spin_unlock(&mos7840_port->pool_lock); if (status) { dbg("nonzero write bulk status received:%d\n", status); return; } if (mos7840_port_paranoia_check(mos7840_port->port, __func__)) { dbg("%s", "Port Paranoia failed \n"); return; } dbg("%s \n", "Entering ........."); tty = mos7840_port->port->port.tty; if (tty && mos7840_port->open) tty_wakeup(tty); } /************************************************************************/ /* D R I V E R T T Y I N T E R F A C E F U N C T I O N S */ /************************************************************************/ #ifdef MCSSerialProbe static int mos7840_serial_probe(struct usb_serial *serial, const struct usb_device_id *id) { /*need to implement the mode_reg reading and updating\ structures usb_serial_ device_type\ (i.e num_ports, num_bulkin,bulkout etc) */ /* Also we can update the changes attach */ return 1; } #endif /***************************************************************************** * mos7840_open * this function is called by the tty driver when a port is opened * If successful, we return 0 * Otherwise we return a negative error number. *****************************************************************************/ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) { int response; int j; struct usb_serial *serial; struct urb *urb; __u16 Data; int status; struct moschip_port *mos7840_port; struct moschip_port *port0; if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Port Paranoia failed \n"); return -ENODEV; } serial = port->serial; if (mos7840_serial_paranoia_check(serial, __func__)) { dbg("%s", "Serial Paranoia failed \n"); return -ENODEV; } mos7840_port = mos7840_get_port_private(port); port0 = mos7840_get_port_private(serial->port[0]); if (mos7840_port == NULL || port0 == NULL) return -ENODEV; usb_clear_halt(serial->dev, port->write_urb->pipe); usb_clear_halt(serial->dev, port->read_urb->pipe); port0->open_ports++; /* Initialising the write urb pool */ for (j = 0; j < NUM_URBS; ++j) { urb = usb_alloc_urb(0, GFP_KERNEL); mos7840_port->write_urb_pool[j] = urb; if (urb == NULL) { err("No more urbs???"); continue; } urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); if (!urb->transfer_buffer) { usb_free_urb(urb); mos7840_port->write_urb_pool[j] = NULL; err("%s-out of memory for urb buffers.", __func__); continue; } } /***************************************************************************** * Initialize MCS7840 -- Write Init values to corresponding Registers * * Register Index * 1 : IER * 2 : FCR * 3 : LCR * 4 : MCR * * 0x08 : SP1/2 Control Reg *****************************************************************************/ /* NEED to check the following Block */ Data = 0x0; status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data); if (status < 0) { dbg("Reading Spreg failed\n"); return -1; } Data |= 0x80; status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); if (status < 0) { dbg("writing Spreg failed\n"); return -1; } Data &= ~0x80; status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); if (status < 0) { dbg("writing Spreg failed\n"); return -1; } /* End of block to be checked */ Data = 0x0; status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, &Data); if (status < 0) { dbg("Reading Controlreg failed\n"); return -1; } Data |= 0x08; /* Driver done bit */ Data |= 0x20; /* rx_disable */ status = mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data); if (status < 0) { dbg("writing Controlreg failed\n"); return -1; } /* do register settings here */ /* Set all regs to the device default values. */ /*********************************** * First Disable all interrupts. ***********************************/ Data = 0x00; status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); if (status < 0) { dbg("disableing interrupts failed\n"); return -1; } /* Set FIFO_CONTROL_REGISTER to the default value */ Data = 0x00; status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); if (status < 0) { dbg("Writing FIFO_CONTROL_REGISTER failed\n"); return -1; } Data = 0xcf; status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); if (status < 0) { dbg("Writing FIFO_CONTROL_REGISTER failed\n"); return -1; } Data = 0x03; status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); mos7840_port->shadowLCR = Data; Data = 0x0b; status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); mos7840_port->shadowMCR = Data; Data = 0x00; status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data); mos7840_port->shadowLCR = Data; Data |= SERIAL_LCR_DLAB; /* data latch enable in LCR 0x80 */ status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); Data = 0x0c; status = mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data); Data = 0x0; status = mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data); Data = 0x00; status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data); Data = Data & ~SERIAL_LCR_DLAB; status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); mos7840_port->shadowLCR = Data; /* clearing Bulkin and Bulkout Fifo */ Data = 0x0; status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data); Data = Data | 0x0c; status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); Data = Data & ~0x0c; status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); /* Finally enable all interrupts */ Data = 0x0c; status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); /* clearing rx_disable */ Data = 0x0; status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, &Data); Data = Data & ~0x20; status = mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data); /* rx_negate */ Data = 0x0; status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, &Data); Data = Data | 0x10; status = mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data); /* force low_latency on so that our tty_push actually forces * * the data through,otherwise it is scheduled, and with * * high data rates (like with OHCI) data can get lost. */ if (tty) tty->low_latency = 1; /* Check to see if we've set up our endpoint info yet * * (can't set it up in mos7840_startup as the structures * * were not set up at that time.) */ if (port0->open_ports == 1) { if (serial->port[0]->interrupt_in_buffer == NULL) { /* set up interrupt urb */ usb_fill_int_urb(serial->port[0]->interrupt_in_urb, serial->dev, usb_rcvintpipe(serial->dev, serial->port[0]->interrupt_in_endpointAddress), serial->port[0]->interrupt_in_buffer, serial->port[0]->interrupt_in_urb-> transfer_buffer_length, mos7840_interrupt_callback, serial, serial->port[0]->interrupt_in_urb->interval); /* start interrupt read for mos7840 * * will continue as long as mos7840 is connected */ response = usb_submit_urb(serial->port[0]->interrupt_in_urb, GFP_KERNEL); if (response) { err("%s - Error %d submitting interrupt urb", __func__, response); } } } /* see if we've set up our endpoint info yet * * (can't set it up in mos7840_startup as the * * structures were not set up at that time.) */ dbg("port number is %d \n", port->number); dbg("serial number is %d \n", port->serial->minor); dbg("Bulkin endpoint is %d \n", port->bulk_in_endpointAddress); dbg("BulkOut endpoint is %d \n", port->bulk_out_endpointAddress); dbg("Interrupt endpoint is %d \n", port->interrupt_in_endpointAddress); dbg("port's number in the device is %d\n", mos7840_port->port_num); mos7840_port->read_urb = port->read_urb; /* set up our bulk in urb */ usb_fill_bulk_urb(mos7840_port->read_urb, serial->dev, usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), port->bulk_in_buffer, mos7840_port->read_urb->transfer_buffer_length, mos7840_bulk_in_callback, mos7840_port); dbg("mos7840_open: bulkin endpoint is %d\n", port->bulk_in_endpointAddress); response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); if (response) { err("%s - Error %d submitting control urb", __func__, response); } /* initialize our wait queues */ init_waitqueue_head(&mos7840_port->wait_chase); init_waitqueue_head(&mos7840_port->delta_msr_wait); /* initialize our icount structure */ memset(&(mos7840_port->icount), 0x00, sizeof(mos7840_port->icount)); /* initialize our port settings */ /* Must set to enable ints! */ mos7840_port->shadowMCR = MCR_MASTER_IE; /* send a open port command */ mos7840_port->open = 1; /* mos7840_change_port_settings(mos7840_port,old_termios); */ mos7840_port->icount.tx = 0; mos7840_port->icount.rx = 0; dbg("\n\nusb_serial serial:%p mos7840_port:%p\n usb_serial_port port:%p\n\n", serial, mos7840_port, port); return 0; } /***************************************************************************** * mos7840_chars_in_buffer * this function is called by the tty driver when it wants to know how many * bytes of data we currently have outstanding in the port (data that has * been written, but hasn't made it out the port yet) * If successful, we return the number of bytes left to be written in the * system, * Otherwise we return zero. *****************************************************************************/ static int mos7840_chars_in_buffer(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; int i; int chars = 0; unsigned long flags; struct moschip_port *mos7840_port; dbg("%s \n", " mos7840_chars_in_buffer:entering ..........."); if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return 0; } mos7840_port = mos7840_get_port_private(port); if (mos7840_port == NULL) { dbg("%s \n", "mos7840_break:leaving ..........."); return 0; } spin_lock_irqsave(&mos7840_port->pool_lock, flags); for (i = 0; i < NUM_URBS; ++i) if (mos7840_port->busy[i]) chars += URB_TRANSFER_BUFFER_SIZE; spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); dbg("%s - returns %d", __func__, chars); return chars; } /************************************************************************ * * mos7840_block_until_tx_empty * * This function will block the close until one of the following: * 1. TX count are 0 * 2. The mos7840 has stopped * 3. A timeout of 3 seconds without activity has expired * ************************************************************************/ static void mos7840_block_until_tx_empty(struct tty_struct *tty, struct moschip_port *mos7840_port) { int timeout = HZ / 10; int wait = 30; int count; while (1) { count = mos7840_chars_in_buffer(tty); /* Check for Buffer status */ if (count <= 0) return; /* Block the thread for a while */ interruptible_sleep_on_timeout(&mos7840_port->wait_chase, timeout); /* No activity.. count down section */ wait--; if (wait == 0) { dbg("%s - TIMEOUT", __func__); return; } else { /* Reset timeout value back to seconds */ wait = 30; } } } /***************************************************************************** * mos7840_close * this function is called by the tty driver when a port is closed *****************************************************************************/ static void mos7840_close(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial; struct moschip_port *mos7840_port; struct moschip_port *port0; int j; __u16 Data; dbg("%s\n", "mos7840_close:entering..."); if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Port Paranoia failed \n"); return; } serial = mos7840_get_usb_serial(port, __func__); if (!serial) { dbg("%s", "Serial Paranoia failed \n"); return; } mos7840_port = mos7840_get_port_private(port); port0 = mos7840_get_port_private(serial->port[0]); if (mos7840_port == NULL || port0 == NULL) return; for (j = 0; j < NUM_URBS; ++j) usb_kill_urb(mos7840_port->write_urb_pool[j]); /* Freeing Write URBs */ for (j = 0; j < NUM_URBS; ++j) { if (mos7840_port->write_urb_pool[j]) { if (mos7840_port->write_urb_pool[j]->transfer_buffer) kfree(mos7840_port->write_urb_pool[j]-> transfer_buffer); usb_free_urb(mos7840_port->write_urb_pool[j]); } } if (serial->dev) /* flush and block until tx is empty */ mos7840_block_until_tx_empty(tty, mos7840_port); /* While closing port, shutdown all bulk read, write * * and interrupt read if they exists */ if (serial->dev) { if (mos7840_port->write_urb) { dbg("%s", "Shutdown bulk write\n"); usb_kill_urb(mos7840_port->write_urb); } if (mos7840_port->read_urb) { dbg("%s", "Shutdown bulk read\n"); usb_kill_urb(mos7840_port->read_urb); } if ((&mos7840_port->control_urb)) { dbg("%s", "Shutdown control read\n"); /*/ usb_kill_urb (mos7840_port->control_urb); */ } } /* if(mos7840_port->ctrl_buf != NULL) */ /* kfree(mos7840_port->ctrl_buf); */ port0->open_ports--; dbg("mos7840_num_open_ports in close%d:in port%d\n", port0->open_ports, port->number); if (port0->open_ports == 0) { if (serial->port[0]->interrupt_in_urb) { dbg("%s", "Shutdown interrupt_in_urb\n"); usb_kill_urb(serial->port[0]->interrupt_in_urb); } } if (mos7840_port->write_urb) { /* if this urb had a transfer buffer already (old tx) free it */ if (mos7840_port->write_urb->transfer_buffer != NULL) kfree(mos7840_port->write_urb->transfer_buffer); usb_free_urb(mos7840_port->write_urb); } Data = 0x0; mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); Data = 0x00; mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); mos7840_port->open = 0; dbg("%s \n", "Leaving ............"); } /************************************************************************ * * mos7840_block_until_chase_response * * This function will block the close until one of the following: * 1. Response to our Chase comes from mos7840 * 2. A timeout of 10 seconds without activity has expired * (1K of mos7840 data @ 2400 baud ==> 4 sec to empty) * ************************************************************************/ static void mos7840_block_until_chase_response(struct tty_struct *tty, struct moschip_port *mos7840_port) { int timeout = 1 * HZ; int wait = 10; int count; while (1) { count = mos7840_chars_in_buffer(tty); /* Check for Buffer status */ if (count <= 0) return; /* Block the thread for a while */ interruptible_sleep_on_timeout(&mos7840_port->wait_chase, timeout); /* No activity.. count down section */ wait--; if (wait == 0) { dbg("%s - TIMEOUT", __func__); return; } else { /* Reset timeout value back to seconds */ wait = 10; } } } /***************************************************************************** * mos7840_break * this function sends a break to the port *****************************************************************************/ static void mos7840_break(struct tty_struct *tty, int break_state) { struct usb_serial_port *port = tty->driver_data; unsigned char data; struct usb_serial *serial; struct moschip_port *mos7840_port; dbg("%s \n", "Entering ..........."); dbg("mos7840_break: Start\n"); if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Port Paranoia failed \n"); return; } serial = mos7840_get_usb_serial(port, __func__); if (!serial) { dbg("%s", "Serial Paranoia failed \n"); return; } mos7840_port = mos7840_get_port_private(port); if (mos7840_port == NULL) return; if (serial->dev) /* flush and block until tx is empty */ mos7840_block_until_chase_response(tty, mos7840_port); if (break_state == -1) data = mos7840_port->shadowLCR | LCR_SET_BREAK; else data = mos7840_port->shadowLCR & ~LCR_SET_BREAK; mos7840_port->shadowLCR = data; dbg("mcs7840_break mos7840_port->shadowLCR is %x\n", mos7840_port->shadowLCR); mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, mos7840_port->shadowLCR); return; } /***************************************************************************** * mos7840_write_room * this function is called by the tty driver when it wants to know how many * bytes of data we can accept for a specific port. * If successful, we return the amount of room that we have for this port * Otherwise we return a negative error number. *****************************************************************************/ static int mos7840_write_room(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; int i; int room = 0; unsigned long flags; struct moschip_port *mos7840_port; dbg("%s \n", " mos7840_write_room:entering ..........."); if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); dbg("%s \n", " mos7840_write_room:leaving ..........."); return -1; } mos7840_port = mos7840_get_port_private(port); if (mos7840_port == NULL) { dbg("%s \n", "mos7840_break:leaving ..........."); return -1; } spin_lock_irqsave(&mos7840_port->pool_lock, flags); for (i = 0; i < NUM_URBS; ++i) { if (!mos7840_port->busy[i]) room += URB_TRANSFER_BUFFER_SIZE; } spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); room = (room == 0) ? 0 : room - URB_TRANSFER_BUFFER_SIZE + 1; dbg("%s - returns %d", __func__, room); return room; } /***************************************************************************** * mos7840_write * this function is called by the tty driver when data should be written to * the port. * If successful, we return the number of bytes written, otherwise we * return a negative error number. *****************************************************************************/ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *data, int count) { int status; int i; int bytes_sent = 0; int transfer_size; unsigned long flags; struct moschip_port *mos7840_port; struct usb_serial *serial; struct urb *urb; /* __u16 Data; */ const unsigned char *current_position = data; unsigned char *data1; dbg("%s \n", "entering ..........."); /* dbg("mos7840_write: mos7840_port->shadowLCR is %x\n", mos7840_port->shadowLCR); */ #ifdef NOTMOS7840 Data = 0x00; status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data); mos7840_port->shadowLCR = Data; dbg("mos7840_write: LINE_CONTROL_REGISTER is %x\n", Data); dbg("mos7840_write: mos7840_port->shadowLCR is %x\n", mos7840_port->shadowLCR); /* Data = 0x03; */ /* status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data); */ /* mos7840_port->shadowLCR=Data;//Need to add later */ Data |= SERIAL_LCR_DLAB; /* data latch enable in LCR 0x80 */ status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); /* Data = 0x0c; */ /* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */ Data = 0x00; status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data); dbg("mos7840_write:DLL value is %x\n", Data); Data = 0x0; status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data); dbg("mos7840_write:DLM value is %x\n", Data); Data = Data & ~SERIAL_LCR_DLAB; dbg("mos7840_write: mos7840_port->shadowLCR is %x\n", mos7840_port->shadowLCR); status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); #endif if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Port Paranoia failed \n"); return -1; } serial = port->serial; if (mos7840_serial_paranoia_check(serial, __func__)) { dbg("%s", "Serial Paranoia failed \n"); return -1; } mos7840_port = mos7840_get_port_private(port); if (mos7840_port == NULL) { dbg("%s", "mos7840_port is NULL\n"); return -1; } /* try to find a free urb in the list */ urb = NULL; spin_lock_irqsave(&mos7840_port->pool_lock, flags); for (i = 0; i < NUM_URBS; ++i) { if (!mos7840_port->busy[i]) { mos7840_port->busy[i] = 1; urb = mos7840_port->write_urb_pool[i]; dbg("\nURB:%d", i); break; } } spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); if (urb == NULL) { dbg("%s - no more free urbs", __func__); goto exit; } if (urb->transfer_buffer == NULL) { urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); if (urb->transfer_buffer == NULL) { err("%s no more kernel memory...", __func__); goto exit; } } transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE); memcpy(urb->transfer_buffer, current_position, transfer_size); /* fill urb with data and submit */ usb_fill_bulk_urb(urb, serial->dev, usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress), urb->transfer_buffer, transfer_size, mos7840_bulk_out_data_callback, mos7840_port); data1 = urb->transfer_buffer; dbg("\nbulkout endpoint is %d", port->bulk_out_endpointAddress); /* send it down the pipe */ status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { mos7840_port->busy[i] = 0; err("%s - usb_submit_urb(write bulk) failed with status = %d", __func__, status); bytes_sent = status; goto exit; } bytes_sent = transfer_size; mos7840_port->icount.tx += transfer_size; smp_wmb(); dbg("mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx); exit: return bytes_sent; } /***************************************************************************** * mos7840_throttle * this function is called by the tty driver when it wants to stop the data * being read from the port. *****************************************************************************/ static void mos7840_throttle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct moschip_port *mos7840_port; int status; if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return; } dbg("- port %d\n", port->number); mos7840_port = mos7840_get_port_private(port); if (mos7840_port == NULL) return; if (!mos7840_port->open) { dbg("%s\n", "port not opened"); return; } dbg("%s", "Entering .......... \n"); /* if we are implementing XON/XOFF, send the stop character */ if (I_IXOFF(tty)) { unsigned char stop_char = STOP_CHAR(tty); status = mos7840_write(tty, port, &stop_char, 1); if (status <= 0) return; } /* if we are implementing RTS/CTS, toggle that line */ if (tty->termios->c_cflag & CRTSCTS) { mos7840_port->shadowMCR &= ~MCR_RTS; status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mos7840_port->shadowMCR); if (status < 0) return; } return; } /***************************************************************************** * mos7840_unthrottle * this function is called by the tty driver when it wants to resume * the data being read from the port (called after mos7840_throttle is * called) *****************************************************************************/ static void mos7840_unthrottle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; int status; struct moschip_port *mos7840_port = mos7840_get_port_private(port); if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return; } if (mos7840_port == NULL) return; if (!mos7840_port->open) { dbg("%s - port not opened", __func__); return; } dbg("%s", "Entering .......... \n"); /* if we are implementing XON/XOFF, send the start character */ if (I_IXOFF(tty)) { unsigned char start_char = START_CHAR(tty); status = mos7840_write(tty, port, &start_char, 1); if (status <= 0) return; } /* if we are implementing RTS/CTS, toggle that line */ if (tty->termios->c_cflag & CRTSCTS) { mos7840_port->shadowMCR |= MCR_RTS; status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mos7840_port->shadowMCR); if (status < 0) return; } } static int mos7840_tiocmget(struct tty_struct *tty, struct file *file) { struct usb_serial_port *port = tty->driver_data; struct moschip_port *mos7840_port; unsigned int result; __u16 msr; __u16 mcr; int status; mos7840_port = mos7840_get_port_private(port); dbg("%s - port %d", __func__, port->number); if (mos7840_port == NULL) return -ENODEV; status = mos7840_get_uart_reg(port, MODEM_STATUS_REGISTER, &msr); status = mos7840_get_uart_reg(port, MODEM_CONTROL_REGISTER, &mcr); result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0) | ((mcr & MCR_RTS) ? TIOCM_RTS : 0) | ((mcr & MCR_LOOPBACK) ? TIOCM_LOOP : 0) | ((msr & MOS7840_MSR_CTS) ? TIOCM_CTS : 0) | ((msr & MOS7840_MSR_CD) ? TIOCM_CAR : 0) | ((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0) | ((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0); dbg("%s - 0x%04X", __func__, result); return result; } static int mos7840_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { struct usb_serial_port *port = tty->driver_data; struct moschip_port *mos7840_port; unsigned int mcr; int status; dbg("%s - port %d", __func__, port->number); mos7840_port = mos7840_get_port_private(port); if (mos7840_port == NULL) return -ENODEV; /* FIXME: What locks the port registers ? */ mcr = mos7840_port->shadowMCR; if (clear & TIOCM_RTS) mcr &= ~MCR_RTS; if (clear & TIOCM_DTR) mcr &= ~MCR_DTR; if (clear & TIOCM_LOOP) mcr &= ~MCR_LOOPBACK; if (set & TIOCM_RTS) mcr |= MCR_RTS; if (set & TIOCM_DTR) mcr |= MCR_DTR; if (set & TIOCM_LOOP) mcr |= MCR_LOOPBACK; mos7840_port->shadowMCR = mcr; status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mcr); if (status < 0) { dbg("setting MODEM_CONTROL_REGISTER Failed\n"); return status; } return 0; } /***************************************************************************** * mos7840_calc_baud_rate_divisor * this function calculates the proper baud rate divisor for the specified * baud rate. *****************************************************************************/ static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor, __u16 *clk_sel_val) { dbg("%s - %d", __func__, baudRate); if (baudRate <= 115200) { *divisor = 115200 / baudRate; *clk_sel_val = 0x0; } if ((baudRate > 115200) && (baudRate <= 230400)) { *divisor = 230400 / baudRate; *clk_sel_val = 0x10; } else if ((baudRate > 230400) && (baudRate <= 403200)) { *divisor = 403200 / baudRate; *clk_sel_val = 0x20; } else if ((baudRate > 403200) && (baudRate <= 460800)) { *divisor = 460800 / baudRate; *clk_sel_val = 0x30; } else if ((baudRate > 460800) && (baudRate <= 806400)) { *divisor = 806400 / baudRate; *clk_sel_val = 0x40; } else if ((baudRate > 806400) && (baudRate <= 921600)) { *divisor = 921600 / baudRate; *clk_sel_val = 0x50; } else if ((baudRate > 921600) && (baudRate <= 1572864)) { *divisor = 1572864 / baudRate; *clk_sel_val = 0x60; } else if ((baudRate > 1572864) && (baudRate <= 3145728)) { *divisor = 3145728 / baudRate; *clk_sel_val = 0x70; } return 0; #ifdef NOTMCS7840 for (i = 0; i < ARRAY_SIZE(mos7840_divisor_table); i++) { if (mos7840_divisor_table[i].BaudRate == baudrate) { *divisor = mos7840_divisor_table[i].Divisor; return 0; } } /* After trying for all the standard baud rates * * Try calculating the divisor for this baud rate */ if (baudrate > 75 && baudrate < 230400) { /* get the divisor */ custom = (__u16) (230400L / baudrate); /* Check for round off */ round1 = (__u16) (2304000L / baudrate); round = (__u16) (round1 - (custom * 10)); if (round > 4) custom++; *divisor = custom; dbg(" Baud %d = %d\n", baudrate, custom); return 0; } dbg("%s\n", " Baud calculation Failed..."); return -1; #endif } /***************************************************************************** * mos7840_send_cmd_write_baud_rate * this function sends the proper command to change the baud rate of the * specified port. *****************************************************************************/ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, int baudRate) { int divisor = 0; int status; __u16 Data; unsigned char number; __u16 clk_sel_val; struct usb_serial_port *port; if (mos7840_port == NULL) return -1; port = (struct usb_serial_port *)mos7840_port->port; if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return -1; } if (mos7840_serial_paranoia_check(port->serial, __func__)) { dbg("%s", "Invalid Serial \n"); return -1; } dbg("%s", "Entering .......... \n"); number = mos7840_port->port->number - mos7840_port->port->serial->minor; dbg("%s - port = %d, baud = %d", __func__, mos7840_port->port->number, baudRate); /* reset clk_uart_sel in spregOffset */ if (baudRate > 115200) { #ifdef HW_flow_control /* NOTE: need to see the pther register to modify */ /* setting h/w flow control bit to 1 */ Data = 0x2b; mos7840_port->shadowMCR = Data; status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); if (status < 0) { dbg("Writing spreg failed in set_serial_baud\n"); return -1; } #endif } else { #ifdef HW_flow_control / *setting h/w flow control bit to 0 */ Data = 0xb; mos7840_port->shadowMCR = Data; status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); if (status < 0) { dbg("Writing spreg failed in set_serial_baud\n"); return -1; } #endif } if (1) { /* baudRate <= 115200) */ clk_sel_val = 0x0; Data = 0x0; status = mos7840_calc_baud_rate_divisor(baudRate, &divisor, &clk_sel_val); status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data); if (status < 0) { dbg("reading spreg failed in set_serial_baud\n"); return -1; } Data = (Data & 0x8f) | clk_sel_val; status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); if (status < 0) { dbg("Writing spreg failed in set_serial_baud\n"); return -1; } /* Calculate the Divisor */ if (status) { err("%s - bad baud rate", __func__); dbg("%s\n", "bad baud rate"); return status; } /* Enable access to divisor latch */ Data = mos7840_port->shadowLCR | SERIAL_LCR_DLAB; mos7840_port->shadowLCR = Data; mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); /* Write the divisor */ Data = (unsigned char)(divisor & 0xff); dbg("set_serial_baud Value to write DLL is %x\n", Data); mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data); Data = (unsigned char)((divisor & 0xff00) >> 8); dbg("set_serial_baud Value to write DLM is %x\n", Data); mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data); /* Disable access to divisor latch */ Data = mos7840_port->shadowLCR & ~SERIAL_LCR_DLAB; mos7840_port->shadowLCR = Data; mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); } return status; } /***************************************************************************** * mos7840_change_port_settings * This routine is called to set the UART on the device to match * the specified new settings. *****************************************************************************/ static void mos7840_change_port_settings(struct tty_struct *tty, struct moschip_port *mos7840_port, struct ktermios *old_termios) { int baud; unsigned cflag; unsigned iflag; __u8 lData; __u8 lParity; __u8 lStop; int status; __u16 Data; struct usb_serial_port *port; struct usb_serial *serial; if (mos7840_port == NULL) return; port = (struct usb_serial_port *)mos7840_port->port; if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return; } if (mos7840_serial_paranoia_check(port->serial, __func__)) { dbg("%s", "Invalid Serial \n"); return; } serial = port->serial; dbg("%s - port %d", __func__, mos7840_port->port->number); if (!mos7840_port->open) { dbg("%s - port not opened", __func__); return; } dbg("%s", "Entering .......... \n"); lData = LCR_BITS_8; lStop = LCR_STOP_1; lParity = LCR_PAR_NONE; cflag = tty->termios->c_cflag; iflag = tty->termios->c_iflag; /* Change the number of bits */ if (cflag & CSIZE) { switch (cflag & CSIZE) { case CS5: lData = LCR_BITS_5; break; case CS6: lData = LCR_BITS_6; break; case CS7: lData = LCR_BITS_7; break; default: case CS8: lData = LCR_BITS_8; break; } } /* Change the Parity bit */ if (cflag & PARENB) { if (cflag & PARODD) { lParity = LCR_PAR_ODD; dbg("%s - parity = odd", __func__); } else { lParity = LCR_PAR_EVEN; dbg("%s - parity = even", __func__); } } else { dbg("%s - parity = none", __func__); } if (cflag & CMSPAR) lParity = lParity | 0x20; /* Change the Stop bit */ if (cflag & CSTOPB) { lStop = LCR_STOP_2; dbg("%s - stop bits = 2", __func__); } else { lStop = LCR_STOP_1; dbg("%s - stop bits = 1", __func__); } /* Update the LCR with the correct value */ mos7840_port->shadowLCR &= ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK); mos7840_port->shadowLCR |= (lData | lParity | lStop); dbg("mos7840_change_port_settings mos7840_port->shadowLCR is %x\n", mos7840_port->shadowLCR); /* Disable Interrupts */ Data = 0x00; mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); Data = 0x00; mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); Data = 0xcf; mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); /* Send the updated LCR value to the mos7840 */ Data = mos7840_port->shadowLCR; mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); Data = 0x00b; mos7840_port->shadowMCR = Data; mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); Data = 0x00b; mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); /* set up the MCR register and send it to the mos7840 */ mos7840_port->shadowMCR = MCR_MASTER_IE; if (cflag & CBAUD) mos7840_port->shadowMCR |= (MCR_DTR | MCR_RTS); if (cflag & CRTSCTS) mos7840_port->shadowMCR |= (MCR_XON_ANY); else mos7840_port->shadowMCR &= ~(MCR_XON_ANY); Data = mos7840_port->shadowMCR; mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); /* Determine divisor based on baud rate */ baud = tty_get_baud_rate(tty); if (!baud) { /* pick a default, any default... */ dbg("%s\n", "Picked default baud..."); baud = 9600; } dbg("%s - baud rate = %d", __func__, baud); status = mos7840_send_cmd_write_baud_rate(mos7840_port, baud); /* Enable Interrupts */ Data = 0x0c; mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); if (mos7840_port->read_urb->status != -EINPROGRESS) { mos7840_port->read_urb->dev = serial->dev; status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); if (status) { dbg(" usb_submit_urb(read bulk) failed, status = %d", status); } } wake_up(&mos7840_port->delta_msr_wait); mos7840_port->delta_msr_cond = 1; dbg("mos7840_change_port_settings mos7840_port->shadowLCR is End %x\n", mos7840_port->shadowLCR); return; } /***************************************************************************** * mos7840_set_termios * this function is called by the tty driver when it wants to change * the termios structure *****************************************************************************/ static void mos7840_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios) { int status; unsigned int cflag; struct usb_serial *serial; struct moschip_port *mos7840_port; dbg("mos7840_set_termios: START\n"); if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return; } serial = port->serial; if (mos7840_serial_paranoia_check(serial, __func__)) { dbg("%s", "Invalid Serial \n"); return; } mos7840_port = mos7840_get_port_private(port); if (mos7840_port == NULL) return; if (!mos7840_port->open) { dbg("%s - port not opened", __func__); return; } dbg("%s\n", "setting termios - "); cflag = tty->termios->c_cflag; dbg("%s - clfag %08x iflag %08x", __func__, tty->termios->c_cflag, RELEVANT_IFLAG(tty->termios->c_iflag)); dbg("%s - old clfag %08x old iflag %08x", __func__, old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); dbg("%s - port %d", __func__, port->number); /* change the port settings to the new ones specified */ mos7840_change_port_settings(tty, mos7840_port, old_termios); if (!mos7840_port->read_urb) { dbg("%s", "URB KILLED !!!!!\n"); return; } if (mos7840_port->read_urb->status != -EINPROGRESS) { mos7840_port->read_urb->dev = serial->dev; status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); if (status) { dbg(" usb_submit_urb(read bulk) failed, status = %d", status); } } return; } /***************************************************************************** * mos7840_get_lsr_info - get line status register info * * Purpose: Let user call ioctl() to get info when the UART physically * is emptied. On bus types like RS485, the transmitter must * release the bus after transmitting. This must be done when * the transmit shift register is empty, not be done when the * transmit holding register is empty. This functionality * allows an RS485 driver to be written in user space. *****************************************************************************/ static int mos7840_get_lsr_info(struct tty_struct *tty, unsigned int __user *value) { int count; unsigned int result = 0; count = mos7840_chars_in_buffer(tty); if (count == 0) { dbg("%s -- Empty", __func__); result = TIOCSER_TEMT; } if (copy_to_user(value, &result, sizeof(int))) return -EFAULT; return 0; } /***************************************************************************** * mos7840_set_modem_info * function to set modem info *****************************************************************************/ /* FIXME: Should be using the model control hooks */ static int mos7840_set_modem_info(struct moschip_port *mos7840_port, unsigned int cmd, unsigned int __user *value) { unsigned int mcr; unsigned int arg; __u16 Data; int status; struct usb_serial_port *port; if (mos7840_port == NULL) return -1; port = (struct usb_serial_port *)mos7840_port->port; if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return -1; } mcr = mos7840_port->shadowMCR; if (copy_from_user(&arg, value, sizeof(int))) return -EFAULT; switch (cmd) { case TIOCMBIS: if (arg & TIOCM_RTS) mcr |= MCR_RTS; if (arg & TIOCM_DTR) mcr |= MCR_RTS; if (arg & TIOCM_LOOP) mcr |= MCR_LOOPBACK; break; case TIOCMBIC: if (arg & TIOCM_RTS) mcr &= ~MCR_RTS; if (arg & TIOCM_DTR) mcr &= ~MCR_RTS; if (arg & TIOCM_LOOP) mcr &= ~MCR_LOOPBACK; break; case TIOCMSET: /* turn off the RTS and DTR and LOOPBACK * and then only turn on what was asked to */ mcr &= ~(MCR_RTS | MCR_DTR | MCR_LOOPBACK); mcr |= ((arg & TIOCM_RTS) ? MCR_RTS : 0); mcr |= ((arg & TIOCM_DTR) ? MCR_DTR : 0); mcr |= ((arg & TIOCM_LOOP) ? MCR_LOOPBACK : 0); break; } mos7840_port->shadowMCR = mcr; Data = mos7840_port->shadowMCR; status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); if (status < 0) { dbg("setting MODEM_CONTROL_REGISTER Failed\n"); return -1; } return 0; } /***************************************************************************** * mos7840_get_modem_info * function to get modem info *****************************************************************************/ static int mos7840_get_modem_info(struct moschip_port *mos7840_port, unsigned int __user *value) { unsigned int result = 0; __u16 msr; unsigned int mcr = mos7840_port->shadowMCR; mos7840_get_uart_reg(mos7840_port->port, MODEM_STATUS_REGISTER, &msr); result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0) /* 0x002 */ |((mcr & MCR_RTS) ? TIOCM_RTS : 0) /* 0x004 */ |((msr & MOS7840_MSR_CTS) ? TIOCM_CTS : 0) /* 0x020 */ |((msr & MOS7840_MSR_CD) ? TIOCM_CAR : 0) /* 0x040 */ |((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0) /* 0x080 */ |((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0); /* 0x100 */ dbg("%s -- %x", __func__, result); if (copy_to_user(value, &result, sizeof(int))) return -EFAULT; return 0; } /***************************************************************************** * mos7840_get_serial_info * function to get information about serial port *****************************************************************************/ static int mos7840_get_serial_info(struct moschip_port *mos7840_port, struct serial_struct __user *retinfo) { struct serial_struct tmp; if (mos7840_port == NULL) return -1; if (!retinfo) return -EFAULT; memset(&tmp, 0, sizeof(tmp)); tmp.type = PORT_16550A; tmp.line = mos7840_port->port->serial->minor; tmp.port = mos7840_port->port->number; tmp.irq = 0; tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; tmp.baud_base = 9600; tmp.close_delay = 5 * HZ; tmp.closing_wait = 30 * HZ; if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) return -EFAULT; return 0; } /***************************************************************************** * SerialIoctl * this function handles any ioctl calls to the driver *****************************************************************************/ static int mos7840_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { struct usb_serial_port *port = tty->driver_data; void __user *argp = (void __user *)arg; struct moschip_port *mos7840_port; struct async_icount cnow; struct async_icount cprev; struct serial_icounter_struct icount; int mosret = 0; if (mos7840_port_paranoia_check(port, __func__)) { dbg("%s", "Invalid port \n"); return -1; } mos7840_port = mos7840_get_port_private(port); if (mos7840_port == NULL) return -1; dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); switch (cmd) { /* return number of bytes available */ case TIOCSERGETLSR: dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); return mos7840_get_lsr_info(tty, argp); return 0; /* FIXME: use the modem hooks and remove this */ case TIOCMBIS: case TIOCMBIC: case TIOCMSET: dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __func__, port->number); mosret = mos7840_set_modem_info(mos7840_port, cmd, argp); return mosret; case TIOCMGET: dbg("%s (%d) TIOCMGET", __func__, port->number); return mos7840_get_modem_info(mos7840_port, argp); case TIOCGSERIAL: dbg("%s (%d) TIOCGSERIAL", __func__, port->number); return mos7840_get_serial_info(mos7840_port, argp); case TIOCSSERIAL: dbg("%s (%d) TIOCSSERIAL", __func__, port->number); break; case TIOCMIWAIT: dbg("%s (%d) TIOCMIWAIT", __func__, port->number); cprev = mos7840_port->icount; while (1) { /* interruptible_sleep_on(&mos7840_port->delta_msr_wait); */ mos7840_port->delta_msr_cond = 0; wait_event_interruptible(mos7840_port->delta_msr_wait, (mos7840_port-> delta_msr_cond == 1)); /* see if a signal did it */ if (signal_pending(current)) return -ERESTARTSYS; cnow = mos7840_port->icount; smp_rmb(); if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) return -EIO; /* no change => error */ if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) { return 0; } cprev = cnow; } /* NOTREACHED */ break; case TIOCGICOUNT: cnow = mos7840_port->icount; smp_rmb(); icount.cts = cnow.cts; icount.dsr = cnow.dsr; icount.rng = cnow.rng; icount.dcd = cnow.dcd; icount.rx = cnow.rx; icount.tx = cnow.tx; icount.frame = cnow.frame; icount.overrun = cnow.overrun; icount.parity = cnow.parity; icount.brk = cnow.brk; icount.buf_overrun = cnow.buf_overrun; dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, port->number, icount.rx, icount.tx); if (copy_to_user(argp, &icount, sizeof(icount))) return -EFAULT; return 0; default: break; } return -ENOIOCTLCMD; } static int mos7840_calc_num_ports(struct usb_serial *serial) { int mos7840_num_ports = 0; dbg("numberofendpoints: %d \n", (int)serial->interface->cur_altsetting->desc.bNumEndpoints); dbg("numberofendpoints: %d \n", (int)serial->interface->altsetting->desc.bNumEndpoints); if (serial->interface->cur_altsetting->desc.bNumEndpoints == 5) { mos7840_num_ports = serial->num_ports = 2; } else if (serial->interface->cur_altsetting->desc.bNumEndpoints == 9) { serial->num_bulk_in = 4; serial->num_bulk_out = 4; mos7840_num_ports = serial->num_ports = 4; } return mos7840_num_ports; } /**************************************************************************** * mos7840_startup ****************************************************************************/ static int mos7840_startup(struct usb_serial *serial) { struct moschip_port *mos7840_port; struct usb_device *dev; int i, status; __u16 Data; dbg("%s \n", " mos7840_startup :entering.........."); if (!serial) { dbg("%s\n", "Invalid Handler"); return -1; } dev = serial->dev; dbg("%s\n", "Entering..."); /* we set up the pointers to the endpoints in the mos7840_open * * function, as the structures aren't created yet. */ /* set up port private structures */ for (i = 0; i < serial->num_ports; ++i) { mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); if (mos7840_port == NULL) { err("%s - Out of memory", __func__); status = -ENOMEM; i--; /* don't follow NULL pointer cleaning up */ goto error; } /* Initialize all port interrupt end point to port 0 int * endpoint. Our device has only one interrupt end point * common to all port */ mos7840_port->port = serial->port[i]; mos7840_set_port_private(serial->port[i], mos7840_port); spin_lock_init(&mos7840_port->pool_lock); mos7840_port->port_num = ((serial->port[i]->number - (serial->port[i]->serial->minor)) + 1); if (mos7840_port->port_num == 1) { mos7840_port->SpRegOffset = 0x0; mos7840_port->ControlRegOffset = 0x1; mos7840_port->DcrRegOffset = 0x4; } else if ((mos7840_port->port_num == 2) && (serial->num_ports == 4)) { mos7840_port->SpRegOffset = 0x8; mos7840_port->ControlRegOffset = 0x9; mos7840_port->DcrRegOffset = 0x16; } else if ((mos7840_port->port_num == 2) && (serial->num_ports == 2)) { mos7840_port->SpRegOffset = 0xa; mos7840_port->ControlRegOffset = 0xb; mos7840_port->DcrRegOffset = 0x19; } else if ((mos7840_port->port_num == 3) && (serial->num_ports == 4)) { mos7840_port->SpRegOffset = 0xa; mos7840_port->ControlRegOffset = 0xb; mos7840_port->DcrRegOffset = 0x19; } else if ((mos7840_port->port_num == 4) && (serial->num_ports == 4)) { mos7840_port->SpRegOffset = 0xc; mos7840_port->ControlRegOffset = 0xd; mos7840_port->DcrRegOffset = 0x1c; } mos7840_dump_serial_port(mos7840_port); mos7840_set_port_private(serial->port[i], mos7840_port); /* enable rx_disable bit in control register */ status = mos7840_get_reg_sync(serial->port[i], mos7840_port->ControlRegOffset, &Data); if (status < 0) { dbg("Reading ControlReg failed status-0x%x\n", status); break; } else dbg("ControlReg Reading success val is %x, status%d\n", Data, status); Data |= 0x08; /* setting driver done bit */ Data |= 0x04; /* sp1_bit to have cts change reflect in modem status reg */ /* Data |= 0x20; //rx_disable bit */ status = mos7840_set_reg_sync(serial->port[i], mos7840_port->ControlRegOffset, Data); if (status < 0) { dbg("Writing ControlReg failed(rx_disable) status-0x%x\n", status); break; } else dbg("ControlReg Writing success(rx_disable) status%d\n", status); /* Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2 and 0x24 in DCR3 */ Data = 0x01; status = mos7840_set_reg_sync(serial->port[i], (__u16) (mos7840_port->DcrRegOffset + 0), Data); if (status < 0) { dbg("Writing DCR0 failed status-0x%x\n", status); break; } else dbg("DCR0 Writing success status%d\n", status); Data = 0x05; status = mos7840_set_reg_sync(serial->port[i], (__u16) (mos7840_port->DcrRegOffset + 1), Data); if (status < 0) { dbg("Writing DCR1 failed status-0x%x\n", status); break; } else dbg("DCR1 Writing success status%d\n", status); Data = 0x24; status = mos7840_set_reg_sync(serial->port[i], (__u16) (mos7840_port->DcrRegOffset + 2), Data); if (status < 0) { dbg("Writing DCR2 failed status-0x%x\n", status); break; } else dbg("DCR2 Writing success status%d\n", status); /* write values in clkstart0x0 and clkmulti 0x20 */ Data = 0x0; status = mos7840_set_reg_sync(serial->port[i], CLK_START_VALUE_REGISTER, Data); if (status < 0) { dbg("Writing CLK_START_VALUE_REGISTER failed status-0x%x\n", status); break; } else dbg("CLK_START_VALUE_REGISTER Writing success status%d\n", status); Data = 0x20; status = mos7840_set_reg_sync(serial->port[i], CLK_MULTI_REGISTER, Data); if (status < 0) { dbg("Writing CLK_MULTI_REGISTER failed status-0x%x\n", status); goto error; } else dbg("CLK_MULTI_REGISTER Writing success status%d\n", status); /* write value 0x0 to scratchpad register */ Data = 0x00; status = mos7840_set_uart_reg(serial->port[i], SCRATCH_PAD_REGISTER, Data); if (status < 0) { dbg("Writing SCRATCH_PAD_REGISTER failed status-0x%x\n", status); break; } else dbg("SCRATCH_PAD_REGISTER Writing success status%d\n", status); /* Zero Length flag register */ if ((mos7840_port->port_num != 1) && (serial->num_ports == 2)) { Data = 0xff; status = mos7840_set_reg_sync(serial->port[i], (__u16) (ZLP_REG1 + ((__u16)mos7840_port->port_num)), Data); dbg("ZLIP offset%x\n", (__u16) (ZLP_REG1 + ((__u16) mos7840_port->port_num))); if (status < 0) { dbg("Writing ZLP_REG%d failed status-0x%x\n", i + 2, status); break; } else dbg("ZLP_REG%d Writing success status%d\n", i + 2, status); } else { Data = 0xff; status = mos7840_set_reg_sync(serial->port[i], (__u16) (ZLP_REG1 + ((__u16)mos7840_port->port_num) - 0x1), Data); dbg("ZLIP offset%x\n", (__u16) (ZLP_REG1 + ((__u16) mos7840_port->port_num) - 0x1)); if (status < 0) { dbg("Writing ZLP_REG%d failed status-0x%x\n", i + 1, status); break; } else dbg("ZLP_REG%d Writing success status%d\n", i + 1, status); } mos7840_port->control_urb = usb_alloc_urb(0, GFP_KERNEL); mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL); mos7840_port->dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); if (!mos7840_port->control_urb || !mos7840_port->ctrl_buf || !mos7840_port->dr) { status = -ENOMEM; goto error; } } /* Zero Length flag enable */ Data = 0x0f; status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data); if (status < 0) { dbg("Writing ZLP_REG5 failed status-0x%x\n", status); goto error; } else dbg("ZLP_REG5 Writing success status%d\n", status); /* setting configuration feature to one */ usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), (__u8) 0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5 * HZ); return 0; error: for (/* nothing */; i >= 0; i--) { mos7840_port = mos7840_get_port_private(serial->port[i]); kfree(mos7840_port->dr); kfree(mos7840_port->ctrl_buf); usb_free_urb(mos7840_port->control_urb); kfree(mos7840_port); serial->port[i] = NULL; } return status; } /**************************************************************************** * mos7840_shutdown * This function is called whenever the device is removed from the usb bus. ****************************************************************************/ static void mos7840_shutdown(struct usb_serial *serial) { int i; unsigned long flags; struct moschip_port *mos7840_port; dbg("%s \n", " shutdown :entering.........."); if (!serial) { dbg("%s", "Invalid Handler \n"); return; } /* check for the ports to be closed,close the ports and disconnect */ /* free private structure allocated for serial port * * stop reads and writes on all ports */ for (i = 0; i < serial->num_ports; ++i) { mos7840_port = mos7840_get_port_private(serial->port[i]); spin_lock_irqsave(&mos7840_port->pool_lock, flags); mos7840_port->zombie = 1; spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); usb_kill_urb(mos7840_port->control_urb); kfree(mos7840_port->ctrl_buf); kfree(mos7840_port->dr); kfree(mos7840_port); mos7840_set_port_private(serial->port[i], NULL); } dbg("%s\n", "Thank u :: "); } static struct usb_driver io_driver = { .name = "mos7840", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = moschip_id_table_combined, .no_dynamic_id = 1, }; static struct usb_serial_driver moschip7840_4port_device = { .driver = { .owner = THIS_MODULE, .name = "mos7840", }, .description = DRIVER_DESC, .usb_driver = &io_driver, .id_table = moschip_port_id_table, .num_ports = 4, .open = mos7840_open, .close = mos7840_close, .write = mos7840_write, .write_room = mos7840_write_room, .chars_in_buffer = mos7840_chars_in_buffer, .throttle = mos7840_throttle, .unthrottle = mos7840_unthrottle, .calc_num_ports = mos7840_calc_num_ports, #ifdef MCSSerialProbe .probe = mos7840_serial_probe, #endif .ioctl = mos7840_ioctl, .set_termios = mos7840_set_termios, .break_ctl = mos7840_break, .tiocmget = mos7840_tiocmget, .tiocmset = mos7840_tiocmset, .attach = mos7840_startup, .shutdown = mos7840_shutdown, .read_bulk_callback = mos7840_bulk_in_callback, .read_int_callback = mos7840_interrupt_callback, }; /**************************************************************************** * moschip7840_init * This is called by the module subsystem, or on startup to initialize us ****************************************************************************/ static int __init moschip7840_init(void) { int retval; dbg("%s \n", " mos7840_init :entering.........."); /* Register with the usb serial */ retval = usb_serial_register(&moschip7840_4port_device); if (retval) goto failed_port_device_register; dbg("%s\n", "Entring..."); info(DRIVER_DESC " " DRIVER_VERSION); /* Register with the usb */ retval = usb_register(&io_driver); if (retval == 0) { dbg("%s\n", "Leaving..."); return 0; } usb_serial_deregister(&moschip7840_4port_device); failed_port_device_register: return retval; } /**************************************************************************** * moschip7840_exit * Called when the driver is about to be unloaded. ****************************************************************************/ static void __exit moschip7840_exit(void) { dbg("%s \n", " mos7840_exit :entering.........."); usb_deregister(&io_driver); usb_serial_deregister(&moschip7840_4port_device); dbg("%s\n", "Entring..."); } module_init(moschip7840_init); module_exit(moschip7840_exit); /* Module information */ MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); module_param(debug, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "Debug enabled or not");
JonnyH/pandora-kernel
drivers/usb/serial/mos7840.c
C
gpl-2.0
78,274
[ 30522, 1013, 1008, 1008, 2023, 2565, 2003, 2489, 4007, 1025, 2017, 2064, 2417, 2923, 3089, 8569, 2618, 2009, 1998, 1013, 2030, 19933, 1008, 2009, 2104, 1996, 3408, 1997, 1996, 27004, 2236, 2270, 6105, 2004, 2405, 2011, 1008, 1996, 2489, 4...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package drain import ( "encoding/json" boshas "github.com/cloudfoundry/bosh-agent/agent/applier/applyspec" bosherr "github.com/cloudfoundry/bosh-agent/internal/github.com/cloudfoundry/bosh-utils/errors" ) // presentedJobState exposes only limited subset of apply spec to drain scripts. // New fields should only be exposed once concrete use cases develop. type presentedJobState struct { applySpec *boshas.V1ApplySpec } type presentedJobStateEnvelope struct { // PersistentDisk is exposed to determine if data needs to be migrated off // when disk is completely removed or shrinks in size PersistentDisk int `json:"persistent_disk"` } func newPresentedJobState(applySpec *boshas.V1ApplySpec) presentedJobState { return presentedJobState{applySpec: applySpec} } func (js presentedJobState) MarshalToJSONString() (string, error) { if js.applySpec == nil { return "", nil } envelope := presentedJobStateEnvelope{ PersistentDisk: js.applySpec.PersistentDisk, } bytes, err := json.Marshal(envelope) if err != nil { return "", bosherr.WrapError(err, "Marshalling job state") } return string(bytes), nil }
pivotal-nader-ziada/bosh-agent
agent/script/drain/presented_job_state.go
GO
apache-2.0
1,130
[ 30522, 7427, 12475, 12324, 1006, 1000, 17181, 1013, 1046, 3385, 1000, 8945, 7377, 2015, 1000, 21025, 2705, 12083, 1012, 4012, 1013, 6112, 14876, 8630, 2854, 1013, 8945, 4095, 1011, 4005, 1013, 4005, 1013, 10439, 14355, 1013, 6611, 13102, 85...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- layout: page title: Michael Limited Show date: 2016-05-24 author: Alan Woods tags: weekly links, java status: published summary: Aliquam sit amet laoreet velit. Ut tincidunt vitae urna. banner: images/banner/leisure-01.jpg booking: startDate: 12/03/2018 endDate: 12/08/2018 ctyhocn: TOLPGHX groupCode: MLS published: true --- Donec sit amet turpis sed mauris laoreet accumsan. Vestibulum varius iaculis elit, ut vulputate lectus varius sit amet. Praesent sodales ipsum lorem, nec mollis elit imperdiet eget. Sed vel pulvinar lorem, quis venenatis turpis. Sed vitae tempus mauris, et rhoncus sem. Fusce condimentum quam quis suscipit tempus. Nulla et semper lectus. Nam et quam in odio ornare malesuada id sed eros. Cras non ipsum ut ex aliquet volutpat in vitae neque. Nulla placerat laoreet varius. Pellentesque velit mauris, viverra non quam vel, pharetra ornare dolor. Phasellus porttitor sagittis tortor. Ut a urna quis ipsum dignissim facilisis. Maecenas placerat bibendum tempor. Aenean pulvinar, nibh quis ultrices lobortis, magna odio porttitor tellus, quis mattis ipsum metus rhoncus enim. Nunc porttitor dignissim est, elementum venenatis ex scelerisque ac. In finibus nisi at sapien tristique placerat. Proin pellentesque semper congue. Suspendisse porta, velit nec pretium dapibus, libero nisl feugiat augue, vel tincidunt diam leo nec leo. Suspendisse quis justo et est placerat dignissim et et mi. Vestibulum efficitur mi vel turpis viverra sollicitudin. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aenean eu augue et felis tristique sollicitudin. * Maecenas et nisl hendrerit, interdum tortor sed, euismod lectus * Duis consectetur eros a leo consequat, et elementum dolor ultricies * In a turpis eget libero fringilla porta * Duis imperdiet nunc sit amet arcu facilisis placerat * Donec vitae lorem eget elit luctus sollicitudin vitae vel massa. Fusce id bibendum lectus. Etiam id enim eu mauris cursus tempor id sit amet massa. Proin sit amet iaculis metus. Quisque sit amet tincidunt diam, vel hendrerit risus. Nunc ut varius dolor, non porta quam. Duis consectetur quam ligula, eget semper nunc aliquam et. Etiam vulputate augue tortor, ac finibus lectus ornare ac. Nam sit amet porta nibh. Mauris lorem arcu, ullamcorper id ante facilisis, sollicitudin blandit justo. Nullam sit amet iaculis elit, in pharetra neque. Ut quis placerat quam. Morbi magna orci, dictum a sagittis eget, ultrices eu quam. Phasellus vehicula porta venenatis. Proin sodales semper ex, et blandit magna bibendum vel. Phasellus commodo ipsum id tincidunt scelerisque. Curabitur dictum, est non laoreet dapibus, justo odio malesuada risus, vitae tempus massa nibh id metus. Nulla volutpat in magna ut hendrerit. Sed congue rhoncus lectus quis semper. Morbi sed magna eu lacus ultrices ultrices. Integer enim eros, porttitor eu mollis sed, consectetur in ipsum. Curabitur lacinia iaculis ex, vitae vulputate turpis varius eu.
KlishGroup/prose-pogs
pogs/T/TOLPGHX/MLS/index.md
Markdown
mit
2,980
[ 30522, 1011, 1011, 1011, 9621, 1024, 3931, 2516, 1024, 2745, 3132, 2265, 3058, 1024, 2355, 1011, 5709, 1011, 2484, 3166, 1024, 5070, 5249, 22073, 1024, 4882, 6971, 1010, 9262, 3570, 1024, 2405, 12654, 1024, 4862, 16211, 2213, 4133, 2572, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* Material Icons Font (for MD theme) */ @font-face { font-family: 'Material Icons'; font-style: normal; font-weight: 400; src: url(../fonts/MaterialIcons-Regular.eot); src: local('Material Icons'), local('MaterialIcons-Regular'), url(../fonts/MaterialIcons-Regular.woff2) format('woff2'), url(../fonts/MaterialIcons-Regular.woff) format('woff'), url(../fonts/MaterialIcons-Regular.ttf) format('truetype'); } .material-icons { font-family: 'Material Icons'; font-weight: normal; font-style: normal; font-size: 24px; display: inline-block; line-height: 1; text-transform: none; letter-spacing: normal; word-wrap: normal; white-space: nowrap; direction: ltr; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; -moz-osx-font-smoothing: grayscale; font-feature-settings: 'liga'; } /* Framework7 Icons Font (for iOS theme) */ @font-face { font-family: 'Framework7 Icons'; font-style: normal; font-weight: 400; src: url("../fonts/Framework7Icons-Regular.eot"); src: url("../fonts/Framework7Icons-Regular.woff2") format("woff2"), url("../fonts/Framework7Icons-Regular.woff") format("woff"), url("../fonts/Framework7Icons-Regular.ttf") format("truetype"); } .f7-icons { font-family: 'Framework7 Icons'; font-weight: normal; font-style: normal; font-size: 28px; line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; word-wrap: normal; direction: ltr; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; -moz-osx-font-smoothing: grayscale; -webkit-font-feature-settings: "liga"; -moz-font-feature-settings: "liga=1"; -moz-font-feature-settings: "liga"; font-feature-settings: "liga"; text-align: center; }
GuillaumeBiton/HackerNews7
src/css/icons.css
CSS
mit
1,822
[ 30522, 1013, 1008, 3430, 18407, 15489, 1006, 2005, 9108, 4323, 1007, 1008, 1013, 1030, 15489, 1011, 2227, 1063, 15489, 1011, 2155, 1024, 1005, 3430, 18407, 1005, 1025, 15489, 1011, 2806, 1024, 3671, 1025, 15489, 1011, 3635, 1024, 4278, 1025...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# -*- coding: utf-8 -*- # from rest_framework.viewsets import ModelViewSet from rest_framework.generics import RetrieveAPIView, ListAPIView from django.shortcuts import get_object_or_404 from django.db.models import Q from common.utils import get_logger, get_object_or_none from common.mixins.api import SuggestionMixin from users.models import User, UserGroup from users.serializers import UserSerializer, UserGroupSerializer from users.filters import UserFilter from perms.models import AssetPermission from perms.serializers import AssetPermissionSerializer from perms.filters import AssetPermissionFilter from orgs.mixins.api import OrgBulkModelViewSet from orgs.mixins import generics from assets.api import FilterAssetByNodeMixin from ..models import Asset, Node, Platform from .. import serializers from ..tasks import ( update_assets_hardware_info_manual, test_assets_connectivity_manual, test_system_users_connectivity_a_asset, push_system_users_a_asset ) from ..filters import FilterAssetByNodeFilterBackend, LabelFilterBackend, IpInFilterBackend logger = get_logger(__file__) __all__ = [ 'AssetViewSet', 'AssetPlatformRetrieveApi', 'AssetGatewayListApi', 'AssetPlatformViewSet', 'AssetTaskCreateApi', 'AssetsTaskCreateApi', 'AssetPermUserListApi', 'AssetPermUserPermissionsListApi', 'AssetPermUserGroupListApi', 'AssetPermUserGroupPermissionsListApi', ] class AssetViewSet(SuggestionMixin, FilterAssetByNodeMixin, OrgBulkModelViewSet): """ API endpoint that allows Asset to be viewed or edited. """ model = Asset filterset_fields = { 'hostname': ['exact'], 'ip': ['exact'], 'system_users__id': ['exact'], 'platform__base': ['exact'], 'is_active': ['exact'], 'protocols': ['exact', 'icontains'] } search_fields = ("hostname", "ip") ordering_fields = ("hostname", "ip", "port", "cpu_cores") ordering = ('hostname', ) serializer_classes = { 'default': serializers.AssetSerializer, 'suggestion': serializers.MiniAssetSerializer } rbac_perms = { 'match': 'assets.match_asset' } extra_filter_backends = [FilterAssetByNodeFilterBackend, LabelFilterBackend, IpInFilterBackend] def set_assets_node(self, assets): if not isinstance(assets, list): assets = [assets] node_id = self.request.query_params.get('node_id') if not node_id: return node = get_object_or_none(Node, pk=node_id) if not node: return node.assets.add(*assets) def perform_create(self, serializer): assets = serializer.save() self.set_assets_node(assets) class AssetPlatformRetrieveApi(RetrieveAPIView): queryset = Platform.objects.all() serializer_class = serializers.PlatformSerializer rbac_perms = { 'retrieve': 'assets.view_gateway' } def get_object(self): asset_pk = self.kwargs.get('pk') asset = get_object_or_404(Asset, pk=asset_pk) return asset.platform class AssetPlatformViewSet(ModelViewSet): queryset = Platform.objects.all() serializer_class = serializers.PlatformSerializer filterset_fields = ['name', 'base'] search_fields = ['name'] def check_object_permissions(self, request, obj): if request.method.lower() in ['delete', 'put', 'patch'] and obj.internal: self.permission_denied( request, message={"detail": "Internal platform"} ) return super().check_object_permissions(request, obj) class AssetsTaskMixin: def perform_assets_task(self, serializer): data = serializer.validated_data action = data['action'] assets = data.get('assets', []) if action == "refresh": task = update_assets_hardware_info_manual.delay(assets) else: # action == 'test': task = test_assets_connectivity_manual.delay(assets) return task def perform_create(self, serializer): task = self.perform_assets_task(serializer) self.set_task_to_serializer_data(serializer, task) def set_task_to_serializer_data(self, serializer, task): data = getattr(serializer, '_data', {}) data["task"] = task.id setattr(serializer, '_data', data) class AssetTaskCreateApi(AssetsTaskMixin, generics.CreateAPIView): model = Asset serializer_class = serializers.AssetTaskSerializer def create(self, request, *args, **kwargs): pk = self.kwargs.get('pk') request.data['asset'] = pk request.data['assets'] = [pk] return super().create(request, *args, **kwargs) def check_permissions(self, request): action = request.data.get('action') action_perm_require = { 'refresh': 'assets.refresh_assethardwareinfo', 'push_system_user': 'assets.push_assetsystemuser', 'test': 'assets.test_assetconnectivity', 'test_system_user': 'assets.test_assetconnectivity' } perm_required = action_perm_require.get(action) has = self.request.user.has_perm(perm_required) if not has: self.permission_denied(request) def perform_asset_task(self, serializer): data = serializer.validated_data action = data['action'] if action not in ['push_system_user', 'test_system_user']: return asset = data['asset'] system_users = data.get('system_users') if not system_users: system_users = asset.get_all_system_users() if action == 'push_system_user': task = push_system_users_a_asset.delay(system_users, asset=asset) elif action == 'test_system_user': task = test_system_users_connectivity_a_asset.delay(system_users, asset=asset) else: task = None return task def perform_create(self, serializer): task = self.perform_asset_task(serializer) if not task: task = self.perform_assets_task(serializer) self.set_task_to_serializer_data(serializer, task) class AssetsTaskCreateApi(AssetsTaskMixin, generics.CreateAPIView): model = Asset serializer_class = serializers.AssetsTaskSerializer class AssetGatewayListApi(generics.ListAPIView): serializer_class = serializers.GatewayWithAuthSerializer rbac_perms = { 'list': 'assets.view_gateway' } def get_queryset(self): asset_id = self.kwargs.get('pk') asset = get_object_or_404(Asset, pk=asset_id) if not asset.domain: return [] queryset = asset.domain.gateways.filter(protocol='ssh') return queryset class BaseAssetPermUserOrUserGroupListApi(ListAPIView): def get_object(self): asset_id = self.kwargs.get('pk') asset = get_object_or_404(Asset, pk=asset_id) return asset def get_asset_related_perms(self): asset = self.get_object() nodes = asset.get_all_nodes(flat=True) perms = AssetPermission.objects.filter(Q(assets=asset) | Q(nodes__in=nodes)) return perms class AssetPermUserListApi(BaseAssetPermUserOrUserGroupListApi): filterset_class = UserFilter search_fields = ('username', 'email', 'name', 'id', 'source', 'role') serializer_class = UserSerializer def get_queryset(self): perms = self.get_asset_related_perms() users = User.objects.filter( Q(assetpermissions__in=perms) | Q(groups__assetpermissions__in=perms) ).distinct() return users class AssetPermUserGroupListApi(BaseAssetPermUserOrUserGroupListApi): serializer_class = UserGroupSerializer def get_queryset(self): perms = self.get_asset_related_perms() user_groups = UserGroup.objects.filter(assetpermissions__in=perms).distinct() return user_groups class BaseAssetPermUserOrUserGroupPermissionsListApiMixin(generics.ListAPIView): model = AssetPermission serializer_class = AssetPermissionSerializer filterset_class = AssetPermissionFilter search_fields = ('name',) rbac_perms = { 'list': 'perms.view_assetpermission' } def get_object(self): asset_id = self.kwargs.get('pk') asset = get_object_or_404(Asset, pk=asset_id) return asset def filter_asset_related(self, queryset): asset = self.get_object() nodes = asset.get_all_nodes(flat=True) perms = queryset.filter(Q(assets=asset) | Q(nodes__in=nodes)) return perms def filter_queryset(self, queryset): queryset = super().filter_queryset(queryset) queryset = self.filter_asset_related(queryset) return queryset class AssetPermUserPermissionsListApi(BaseAssetPermUserOrUserGroupPermissionsListApiMixin): def filter_queryset(self, queryset): queryset = super().filter_queryset(queryset) queryset = self.filter_user_related(queryset) queryset = queryset.distinct() return queryset def filter_user_related(self, queryset): user = self.get_perm_user() user_groups = user.groups.all() perms = queryset.filter(Q(users=user) | Q(user_groups__in=user_groups)) return perms def get_perm_user(self): user_id = self.kwargs.get('perm_user_id') user = get_object_or_404(User, pk=user_id) return user class AssetPermUserGroupPermissionsListApi(BaseAssetPermUserOrUserGroupPermissionsListApiMixin): def filter_queryset(self, queryset): queryset = super().filter_queryset(queryset) queryset = self.filter_user_group_related(queryset) queryset = queryset.distinct() return queryset def filter_user_group_related(self, queryset): user_group = self.get_perm_user_group() perms = queryset.filter(user_groups=user_group) return perms def get_perm_user_group(self): user_group_id = self.kwargs.get('perm_user_group_id') user_group = get_object_or_404(UserGroup, pk=user_group_id) return user_group
jumpserver/jumpserver
apps/assets/api/asset.py
Python
gpl-3.0
10,108
[ 30522, 1001, 1011, 1008, 1011, 16861, 1024, 21183, 2546, 30524, 1001, 2013, 2717, 1035, 7705, 1012, 5328, 8454, 12324, 2944, 8584, 13462, 2013, 2717, 1035, 7705, 1012, 12391, 2015, 12324, 12850, 9331, 12848, 2666, 2860, 1010, 2862, 9331, 12...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!doctype html><html lang=en><head><title>Redirecting&mldr;</title><link rel=canonical href=/v1.5/zh/news/releases/1.0.x/announcing-1.0.8/><meta name=robots content="noindex"><meta charset=utf-8><meta http-equiv=refresh content="0; url=/v1.5/zh/news/releases/1.0.x/announcing-1.0.8/"></head><body><h1>Redirecting&mldr;</h1><a href=/v1.5/zh/news/releases/1.0.x/announcing-1.0.8/>Click here if you are not redirected.</a></body></html>
istio/istio.io
archive/v1.5/zh/news/announcing-1.0.8/index.html
HTML
apache-2.0
433
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 11374, 1027, 4372, 1028, 1026, 2132, 1028, 1026, 2516, 1028, 2417, 7442, 11873, 1004, 19875, 13626, 1025, 1026, 1013, 2516, 1028, 1026, 4957, 2128, 2140, 1027, 18562, 17850, 12879, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import createSvgIcon from './utils/createSvgIcon'; import { jsx as _jsx } from "react/jsx-runtime"; export default createSvgIcon( /*#__PURE__*/_jsx("path", { d: "M8 10H5V7H3v3H0v2h3v3h2v-3h3v-2zm10 1c1.66 0 2.99-1.34 2.99-3S19.66 5 18 5c-.32 0-.63.05-.91.14.57.81.9 1.79.9 2.86s-.34 2.04-.9 2.86c.28.09.59.14.91.14zm-5 0c1.66 0 2.99-1.34 2.99-3S14.66 5 13 5s-3 1.34-3 3 1.34 3 3 3zm6.62 2.16c.83.73 1.38 1.66 1.38 2.84v2h3v-2c0-1.54-2.37-2.49-4.38-2.84zM13 13c-2 0-6 1-6 3v2h12v-2c0-2-4-3-6-3z" }), 'GroupAddSharp');
mbrookes/material-ui
packages/material-ui-icons/lib/esm/GroupAddSharp.js
JavaScript
mit
518
[ 30522, 12324, 9005, 2615, 12863, 2239, 2013, 1005, 1012, 1013, 21183, 12146, 1013, 9005, 2615, 12863, 2239, 1005, 1025, 12324, 1063, 1046, 2015, 2595, 2004, 1035, 1046, 2015, 2595, 1065, 2013, 1000, 10509, 1013, 1046, 2015, 2595, 1011, 2448...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
\section{Spisak klasa} Spisak klasa, struktura, unija i interfejsa sa kratkim opisima\+:\begin{DoxyCompactList} \item\contentsline{section}{\hyperlink{classHangman_1_1DataBase}{Hangman.\+Data\+Base} }{\pageref{classHangman_1_1DataBase}}{} \item\contentsline{section}{\hyperlink{classHangman_1_1Film}{Hangman.\+Film} }{\pageref{classHangman_1_1Film}}{} \item\contentsline{section}{\hyperlink{classHangmanService_1_1HangmanService}{Hangman\+Service.\+Hangman\+Service} }{\pageref{classHangmanService_1_1HangmanService}}{} \item\contentsline{section}{\hyperlink{interfaceHangmanService_1_1IHangmanService}{Hangman\+Service.\+I\+Hangman\+Service} }{\pageref{interfaceHangmanService_1_1IHangmanService}}{} \item\contentsline{section}{\hyperlink{classHangmanService_1_1MainClass}{Hangman\+Service.\+Main\+Class} }{\pageref{classHangmanService_1_1MainClass}}{} \item\contentsline{section}{\hyperlink{classHangman_1_1Rekord}{Hangman.\+Rekord} }{\pageref{classHangman_1_1Rekord}}{} \item\contentsline{section}{\hyperlink{classHangman_1_1ServiceFault}{Hangman.\+Service\+Fault} }{\pageref{classHangman_1_1ServiceFault}}{} \end{DoxyCompactList}
dms-cmt/hangman-service
doc/latex/annotated.tex
TeX
gpl-2.0
1,134
[ 30522, 1032, 2930, 1063, 11867, 14268, 2243, 1047, 8523, 2050, 1065, 11867, 14268, 2243, 1047, 8523, 2050, 1010, 2358, 6820, 25509, 4648, 1010, 4895, 14713, 1045, 6970, 7959, 22578, 2050, 7842, 1047, 8609, 21138, 6728, 17417, 2863, 1032, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Holosticha hamulata Lei, Xu & Choi, 2005 SPECIES #### Status ACCEPTED #### According to World Register of Marine Species #### Published in Lei, Xu & Choi. 2005. Holosticha hamulata n. sp. and Holosticha heterofoissneri Hu and Song, 2001, Two Urostylid Ciliates (Protozoa, Ciliophora) from Intertidal Sediments of the Yellow Sea. Journal of Eukaryotic Microbiology 52(4) : 310-318 #### Original name null ### Remarks null
mdoering/backbone
life/Protozoa/Ciliophora/Hypotrichea/Urostylida/Holostichidae/Holosticha/Holosticha hamulata/README.md
Markdown
apache-2.0
427
[ 30522, 1001, 7570, 10483, 4588, 3270, 10654, 18060, 26947, 1010, 15990, 1004, 18151, 1010, 2384, 2427, 1001, 1001, 1001, 1001, 3570, 3970, 1001, 1001, 1001, 1001, 2429, 2000, 2088, 4236, 1997, 3884, 2427, 1001, 1001, 1001, 1001, 2405, 1999,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# -*- coding:utf-8 -*- import zstackwoodpecker.test_util as test_util import zstackwoodpecker.test_lib as test_lib volume = test_lib.lib_get_specific_stub('e2e_mini/volume', 'volume') volume_ops = None vm_ops = None volume_name = 'volume-' + volume.get_time_postfix() backup_name = 'backup-' + volume.get_time_postfix() def test(): global volume_ops volume_ops = volume.VOLUME() vm = test_lib.lib_get_specific_stub(suite_name='e2e_mini/vm', specific_name='vm') vm_ops = vm.VM(uri=volume_ops.uri, initialized=True) vm_ops.create_vm() volume_ops.create_volume(volume_name) volume_ops.volume_attach_to_vm(vm_ops.vm_name) volume_ops.create_backup(volume_name, 'volume', backup_name) vm_ops.vm_ops(vm_ops.vm_name, action='stop') volume_ops.restore_backup(volume_name, 'volume', backup_name) volume_ops.delete_backup(volume_name, 'volume', backup_name) volume_ops.check_browser_console_log() test_util.test_pass('Test Volume Create, Restore and Delete Backups Successful') def env_recover(): global volume_ops vm_ops.expunge_vm() volume_ops.expunge_volume(volume_name) volume_ops.close() #Will be called only if exception happens in test(). def error_cleanup(): global volume_ops try: vm_ops.expunge_vm() volume_ops.expunge_volume(volume_name) volume_ops.close() except: pass
zstackio/zstack-woodpecker
integrationtest/vm/e2e_mini/volume/test_volume_backup.py
Python
apache-2.0
1,389
[ 30522, 1001, 1011, 1008, 1011, 16861, 1024, 21183, 2546, 1011, 1022, 1011, 1008, 1011, 12324, 1062, 9153, 3600, 3702, 5051, 9102, 1012, 3231, 1035, 21183, 4014, 2004, 3231, 1035, 21183, 4014, 12324, 1062, 9153, 3600, 3702, 5051, 9102, 1012,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/***************************************************************************** Copyright (c) 2005, 2013, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ /**************************************************//** @file handler/handler0alter.cc Smart ALTER TABLE *******************************************************/ #include <unireg.h> #include <mysqld_error.h> #include <sql_class.h> #include <sql_lex.h> // SQLCOM_CREATE_INDEX #include <innodb_priv.h> extern "C" { #include "log0log.h" #include "row0merge.h" #include "srv0srv.h" #include "trx0trx.h" #include "trx0roll.h" #include "ha_prototypes.h" #include "handler0alter.h" } #include "ha_innodb.h" /*************************************************************//** Copies an InnoDB column to a MySQL field. This function is adapted from row_sel_field_store_in_mysql_format(). */ static void innobase_col_to_mysql( /*==================*/ const dict_col_t* col, /*!< in: InnoDB column */ const uchar* data, /*!< in: InnoDB column data */ ulint len, /*!< in: length of data, in bytes */ Field* field) /*!< in/out: MySQL field */ { uchar* ptr; uchar* dest = field->ptr; ulint flen = field->pack_length(); switch (col->mtype) { case DATA_INT: ut_ad(len == flen); /* Convert integer data from Innobase to little-endian format, sign bit restored to normal */ for (ptr = dest + len; ptr != dest; ) { *--ptr = *data++; } if (!(field->flags & UNSIGNED_FLAG)) { ((byte*) dest)[len - 1] ^= 0x80; } break; case DATA_VARCHAR: case DATA_VARMYSQL: case DATA_BINARY: field->reset(); if (field->type() == MYSQL_TYPE_VARCHAR) { /* This is a >= 5.0.3 type true VARCHAR. Store the length of the data to the first byte or the first two bytes of dest. */ dest = row_mysql_store_true_var_len( dest, len, flen - field->key_length()); } /* Copy the actual data */ memcpy(dest, data, len); break; case DATA_BLOB: /* Store a pointer to the BLOB buffer to dest: the BLOB was already copied to the buffer in row_sel_store_mysql_rec */ row_mysql_store_blob_ref(dest, flen, data, len); break; #ifdef UNIV_DEBUG case DATA_MYSQL: ut_ad(flen >= len); ut_ad(DATA_MBMAXLEN(col->mbminmaxlen) >= DATA_MBMINLEN(col->mbminmaxlen)); memcpy(dest, data, len); break; default: case DATA_SYS_CHILD: case DATA_SYS: /* These column types should never be shipped to MySQL. */ ut_ad(0); case DATA_FLOAT: case DATA_DOUBLE: case DATA_DECIMAL: /* Above are the valid column types for MySQL data. */ ut_ad(flen == len); /* fall through */ case DATA_FIXBINARY: case DATA_CHAR: /* We may have flen > len when there is a shorter prefix on the CHAR and BINARY column. */ ut_ad(flen >= len); #else /* UNIV_DEBUG */ default: #endif /* UNIV_DEBUG */ memcpy(dest, data, len); } } /*************************************************************//** Copies an InnoDB record to table->record[0]. */ extern "C" UNIV_INTERN void innobase_rec_to_mysql( /*==================*/ TABLE* table, /*!< in/out: MySQL table */ const rec_t* rec, /*!< in: record */ const dict_index_t* index, /*!< in: index */ const ulint* offsets) /*!< in: rec_get_offsets( rec, index, ...) */ { uint n_fields = table->s->fields; uint i; ut_ad(n_fields == dict_table_get_n_user_cols(index->table)); for (i = 0; i < n_fields; i++) { Field* field = table->field[i]; ulint ipos; ulint ilen; const uchar* ifield; field->reset(); ipos = dict_index_get_nth_col_or_prefix_pos(index, i, TRUE); if (UNIV_UNLIKELY(ipos == ULINT_UNDEFINED)) { null_field: field->set_null(); continue; } ifield = rec_get_nth_field(rec, offsets, ipos, &ilen); /* Assign the NULL flag */ if (ilen == UNIV_SQL_NULL) { ut_ad(field->real_maybe_null()); goto null_field; } field->set_notnull(); innobase_col_to_mysql( dict_field_get_col( dict_index_get_nth_field(index, ipos)), ifield, ilen, field); } } /*************************************************************//** Resets table->record[0]. */ extern "C" UNIV_INTERN void innobase_rec_reset( /*===============*/ TABLE* table) /*!< in/out: MySQL table */ { uint n_fields = table->s->fields; uint i; for (i = 0; i < n_fields; i++) { table->field[i]->set_default(); } } /******************************************************************//** Removes the filename encoding of a database and table name. */ static void innobase_convert_tablename( /*=======================*/ char* s) /*!< in: identifier; out: decoded identifier */ { uint errors; char* slash = strchr(s, '/'); if (slash) { char* t; /* Temporarily replace the '/' with NUL. */ *slash = 0; /* Convert the database name. */ strconvert(&my_charset_filename, s, system_charset_info, s, slash - s + 1, &errors); t = s + strlen(s); ut_ad(slash >= t); /* Append a '.' after the database name. */ *t++ = '.'; slash++; /* Convert the table name. */ strconvert(&my_charset_filename, slash, system_charset_info, t, slash - t + strlen(slash), &errors); } else { strconvert(&my_charset_filename, s, system_charset_info, s, strlen(s), &errors); } } /*******************************************************************//** This function checks that index keys are sensible. @return 0 or error number */ static int innobase_check_index_keys( /*======================*/ const KEY* key_info, /*!< in: Indexes to be created */ ulint num_of_keys, /*!< in: Number of indexes to be created */ const dict_table_t* table) /*!< in: Existing indexes */ { ulint key_num; ut_ad(key_info); ut_ad(num_of_keys); for (key_num = 0; key_num < num_of_keys; key_num++) { const KEY& key = key_info[key_num]; /* Check that the same index name does not appear twice in indexes to be created. */ for (ulint i = 0; i < key_num; i++) { const KEY& key2 = key_info[i]; if (0 == strcmp(key.name, key2.name)) { my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key.name); return(ER_WRONG_NAME_FOR_INDEX); } } /* Check that the same index name does not already exist. */ for (const dict_index_t* index = dict_table_get_first_index(table); index; index = dict_table_get_next_index(index)) { if (0 == strcmp(key.name, index->name)) { my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key.name); return(ER_WRONG_NAME_FOR_INDEX); } } /* Check that MySQL does not try to create a column prefix index field on an inappropriate data type and that the same column does not appear twice in the index. */ for (ulint i = 0; i < key.key_parts; i++) { const KEY_PART_INFO& key_part1 = key.key_part[i]; const Field* field = key_part1.field; ibool is_unsigned; switch (get_innobase_type_from_mysql_type( &is_unsigned, field)) { default: break; case DATA_INT: case DATA_FLOAT: case DATA_DOUBLE: case DATA_DECIMAL: if (field->type() == MYSQL_TYPE_VARCHAR) { if (key_part1.length >= field->pack_length() - ((Field_varstring*) field) ->length_bytes) { break; } } else { if (key_part1.length >= field->pack_length()) { break; } } my_error(ER_WRONG_KEY_COLUMN, MYF(0), field->field_name); return(ER_WRONG_KEY_COLUMN); } for (ulint j = 0; j < i; j++) { const KEY_PART_INFO& key_part2 = key.key_part[j]; if (strcmp(key_part1.field->field_name, key_part2.field->field_name)) { continue; } my_error(ER_WRONG_KEY_COLUMN, MYF(0), key_part1.field->field_name); return(ER_WRONG_KEY_COLUMN); } } } return(0); } /*******************************************************************//** Create index field definition for key part */ static void innobase_create_index_field_def( /*============================*/ KEY_PART_INFO* key_part, /*!< in: MySQL key definition */ mem_heap_t* heap, /*!< in: memory heap */ merge_index_field_t* index_field) /*!< out: index field definition for key_part */ { Field* field; ibool is_unsigned; ulint col_type; DBUG_ENTER("innobase_create_index_field_def"); ut_ad(key_part); ut_ad(index_field); field = key_part->field; ut_a(field); col_type = get_innobase_type_from_mysql_type(&is_unsigned, field); if (DATA_BLOB == col_type || (key_part->length < field->pack_length() && field->type() != MYSQL_TYPE_VARCHAR) || (field->type() == MYSQL_TYPE_VARCHAR && key_part->length < field->pack_length() - ((Field_varstring*)field)->length_bytes)) { index_field->prefix_len = key_part->length; } else { index_field->prefix_len = 0; } index_field->field_name = mem_heap_strdup(heap, field->field_name); DBUG_VOID_RETURN; } /*******************************************************************//** Create index definition for key */ static void innobase_create_index_def( /*======================*/ KEY* key, /*!< in: key definition */ bool new_primary, /*!< in: TRUE=generating a new primary key on the table */ bool key_primary, /*!< in: TRUE if this key is a primary key */ merge_index_def_t* index, /*!< out: index definition */ mem_heap_t* heap) /*!< in: heap where memory is allocated */ { ulint i; ulint len; ulint n_fields = key->key_parts; char* index_name; DBUG_ENTER("innobase_create_index_def"); index->fields = (merge_index_field_t*) mem_heap_alloc( heap, n_fields * sizeof *index->fields); index->ind_type = 0; index->n_fields = n_fields; len = strlen(key->name) + 1; index->name = index_name = (char*) mem_heap_alloc(heap, len + !new_primary); if (UNIV_LIKELY(!new_primary)) { *index_name++ = TEMP_INDEX_PREFIX; } memcpy(index_name, key->name, len); if (key->flags & HA_NOSAME) { index->ind_type |= DICT_UNIQUE; } if (key_primary) { index->ind_type |= DICT_CLUSTERED; } for (i = 0; i < n_fields; i++) { innobase_create_index_field_def(&key->key_part[i], heap, &index->fields[i]); } DBUG_VOID_RETURN; } /*******************************************************************//** Copy index field definition */ static void innobase_copy_index_field_def( /*==========================*/ const dict_field_t* field, /*!< in: definition to copy */ merge_index_field_t* index_field) /*!< out: copied definition */ { DBUG_ENTER("innobase_copy_index_field_def"); DBUG_ASSERT(field != NULL); DBUG_ASSERT(index_field != NULL); index_field->field_name = field->name; index_field->prefix_len = field->prefix_len; DBUG_VOID_RETURN; } /*******************************************************************//** Copy index definition for the index */ static void innobase_copy_index_def( /*====================*/ const dict_index_t* index, /*!< in: index definition to copy */ merge_index_def_t* new_index,/*!< out: Index definition */ mem_heap_t* heap) /*!< in: heap where allocated */ { ulint n_fields; ulint i; DBUG_ENTER("innobase_copy_index_def"); /* Note that we take only those fields that user defined to be in the index. In the internal representation more colums were added and those colums are not copied .*/ n_fields = index->n_user_defined_cols; new_index->fields = (merge_index_field_t*) mem_heap_alloc( heap, n_fields * sizeof *new_index->fields); /* When adding a PRIMARY KEY, we may convert a previous clustered index to a secondary index (UNIQUE NOT NULL). */ new_index->ind_type = index->type & ~DICT_CLUSTERED; new_index->n_fields = n_fields; new_index->name = index->name; for (i = 0; i < n_fields; i++) { innobase_copy_index_field_def(&index->fields[i], &new_index->fields[i]); } DBUG_VOID_RETURN; } /*******************************************************************//** Create an index table where indexes are ordered as follows: IF a new primary key is defined for the table THEN 1) New primary key 2) Original secondary indexes 3) New secondary indexes ELSE 1) All new indexes in the order they arrive from MySQL ENDIF @return key definitions or NULL */ static merge_index_def_t* innobase_create_key_def( /*====================*/ trx_t* trx, /*!< in: trx */ const dict_table_t*table, /*!< in: table definition */ mem_heap_t* heap, /*!< in: heap where space for key definitions are allocated */ KEY* key_info, /*!< in: Indexes to be created */ ulint& n_keys) /*!< in/out: Number of indexes to be created */ { ulint i = 0; merge_index_def_t* indexdef; merge_index_def_t* indexdefs; bool new_primary; DBUG_ENTER("innobase_create_key_def"); indexdef = indexdefs = (merge_index_def_t*) mem_heap_alloc(heap, sizeof *indexdef * (n_keys + UT_LIST_GET_LEN(table->indexes))); /* If there is a primary key, it is always the first index defined for the table. */ new_primary = !my_strcasecmp(system_charset_info, key_info->name, "PRIMARY"); /* If there is a UNIQUE INDEX consisting entirely of NOT NULL columns and if the index does not contain column prefix(es) (only prefix/part of the column is indexed), MySQL will treat the index as a PRIMARY KEY unless the table already has one. */ if (!new_primary && (key_info->flags & HA_NOSAME) && (!(key_info->flags & HA_KEY_HAS_PART_KEY_SEG)) && row_table_got_default_clust_index(table)) { uint key_part = key_info->key_parts; new_primary = TRUE; while (key_part--) { if (key_info->key_part[key_part].key_type & FIELDFLAG_MAYBE_NULL) { new_primary = FALSE; break; } } } if (new_primary) { const dict_index_t* index; /* Create the PRIMARY key index definition */ innobase_create_index_def(&key_info[i++], TRUE, TRUE, indexdef++, heap); row_mysql_lock_data_dictionary(trx); index = dict_table_get_first_index(table); /* Copy the index definitions of the old table. Skip the old clustered index if it is a generated clustered index or a PRIMARY KEY. If the clustered index is a UNIQUE INDEX, it must be converted to a secondary index. */ if (dict_index_get_nth_col(index, 0)->mtype == DATA_SYS || !my_strcasecmp(system_charset_info, index->name, "PRIMARY")) { index = dict_table_get_next_index(index); } while (index) { innobase_copy_index_def(index, indexdef++, heap); index = dict_table_get_next_index(index); } row_mysql_unlock_data_dictionary(trx); } /* Create definitions for added secondary indexes. */ while (i < n_keys) { innobase_create_index_def(&key_info[i++], new_primary, FALSE, indexdef++, heap); } n_keys = indexdef - indexdefs; DBUG_RETURN(indexdefs); } /*******************************************************************//** Check each index column size, make sure they do not exceed the max limit @return HA_ERR_INDEX_COL_TOO_LONG if index column size exceeds limit */ static int innobase_check_column_length( /*=========================*/ const dict_table_t*table, /*!< in: table definition */ const KEY* key_info) /*!< in: Indexes to be created */ { ulint max_col_len = DICT_MAX_FIELD_LEN_BY_FORMAT(table); for (ulint key_part = 0; key_part < key_info->key_parts; key_part++) { if (key_info->key_part[key_part].length > max_col_len) { my_error(ER_INDEX_COLUMN_TOO_LONG, MYF(0), max_col_len); return(HA_ERR_INDEX_COL_TOO_LONG); } } return(0); } /*******************************************************************//** Create a temporary tablename using query id, thread id, and id @return temporary tablename */ static char* innobase_create_temporary_tablename( /*================================*/ mem_heap_t* heap, /*!< in: memory heap */ char id, /*!< in: identifier [0-9a-zA-Z] */ const char* table_name) /*!< in: table name */ { char* name; ulint len; static const char suffix[] = "@0023 "; /* "# " */ len = strlen(table_name); name = (char*) mem_heap_alloc(heap, len + sizeof suffix); memcpy(name, table_name, len); memcpy(name + len, suffix, sizeof suffix); name[len + (sizeof suffix - 2)] = id; return(name); } class ha_innobase_add_index : public handler_add_index { public: /** table where the indexes are being created */ dict_table_t* indexed_table; ha_innobase_add_index(TABLE* table, KEY* key_info, uint num_of_keys, dict_table_t* indexed_table_arg) : handler_add_index(table, key_info, num_of_keys), indexed_table (indexed_table_arg) {} ~ha_innobase_add_index() {} }; /*******************************************************************//** Create indexes. @return 0 or error number */ UNIV_INTERN int ha_innobase::add_index( /*===================*/ TABLE* table, /*!< in: Table where indexes are created */ KEY* key_info, /*!< in: Indexes to be created */ uint num_of_keys, /*!< in: Number of indexes to be created */ handler_add_index** add) /*!< out: context */ { dict_index_t** index; /*!< Index to be created */ dict_table_t* indexed_table; /*!< Table where indexes are created */ merge_index_def_t* index_defs; /*!< Index definitions */ mem_heap_t* heap; /*!< Heap for index definitions */ trx_t* trx; /*!< Transaction */ ulint num_of_idx; ulint num_created = 0; ibool dict_locked = FALSE; ulint new_primary; int error; DBUG_ENTER("ha_innobase::add_index"); ut_a(table); ut_a(key_info); ut_a(num_of_keys); *add = NULL; if (srv_created_new_raw || srv_force_recovery) { DBUG_RETURN(HA_ERR_WRONG_COMMAND); } update_thd(); /* In case MySQL calls this in the middle of a SELECT query, release possible adaptive hash latch to avoid deadlocks of threads. */ trx_search_latch_release_if_reserved(prebuilt->trx); if (UNIV_UNLIKELY(prebuilt->trx->fake_changes)) { DBUG_RETURN(HA_ERR_WRONG_COMMAND); } /* Check if the index name is reserved. */ if (innobase_index_name_is_reserved(user_thd, key_info, num_of_keys)) { DBUG_RETURN(ER_WRONG_NAME_FOR_INDEX); } indexed_table = dict_table_get(prebuilt->table->name, FALSE, DICT_ERR_IGNORE_NONE); if (UNIV_UNLIKELY(!indexed_table)) { DBUG_RETURN(HA_ERR_NO_SUCH_TABLE); } ut_a(indexed_table == prebuilt->table); if (indexed_table->tablespace_discarded) { DBUG_RETURN(-1); } /* Check that index keys are sensible */ error = innobase_check_index_keys(key_info, num_of_keys, prebuilt->table); if (UNIV_UNLIKELY(error)) { DBUG_RETURN(error); } /* Check each index's column length to make sure they do not exceed limit */ for (ulint i = 0; i < num_of_keys; i++) { error = innobase_check_column_length(prebuilt->table, &key_info[i]); if (error) { DBUG_RETURN(error); } } heap = mem_heap_create(1024); trx_start_if_not_started(prebuilt->trx); /* Create a background transaction for the operations on the data dictionary tables. */ trx = innobase_trx_allocate(user_thd); if (UNIV_UNLIKELY(trx->fake_changes)) { mem_heap_free(heap); trx_general_rollback_for_mysql(trx, NULL); trx_free_for_mysql(trx); DBUG_RETURN(HA_ERR_WRONG_COMMAND); } trx_start_if_not_started(trx); /* Create table containing all indexes to be built in this alter table add index so that they are in the correct order in the table. */ num_of_idx = num_of_keys; index_defs = innobase_create_key_def( trx, prebuilt->table, heap, key_info, num_of_idx); new_primary = DICT_CLUSTERED & index_defs[0].ind_type; /* Allocate memory for dictionary index definitions */ index = (dict_index_t**) mem_heap_alloc( heap, num_of_idx * sizeof *index); /* Flag this transaction as a dictionary operation, so that the data dictionary will be locked in crash recovery. */ trx_set_dict_operation(trx, TRX_DICT_OP_INDEX); /* Acquire a lock on the table before creating any indexes. */ error = row_merge_lock_table(prebuilt->trx, prebuilt->table, new_primary ? LOCK_X : LOCK_S); if (UNIV_UNLIKELY(error != DB_SUCCESS)) { goto error_handling; } /* Latch the InnoDB data dictionary exclusively so that no deadlocks or lock waits can happen in it during an index create operation. */ row_mysql_lock_data_dictionary(trx); dict_locked = TRUE; ut_d(dict_table_check_for_dup_indexes(prebuilt->table, TRUE)); /* If a new primary key is defined for the table we need to drop the original table and rebuild all indexes. */ if (UNIV_UNLIKELY(new_primary)) { /* This transaction should be the only one operating on the table. */ ut_a(prebuilt->table->n_mysql_handles_opened == 1); char* new_table_name = innobase_create_temporary_tablename( heap, '1', prebuilt->table->name); /* Clone the table. */ trx_set_dict_operation(trx, TRX_DICT_OP_TABLE); indexed_table = row_merge_create_temporary_table( new_table_name, index_defs, prebuilt->table, trx); if (!indexed_table) { switch (trx->error_state) { case DB_TABLESPACE_ALREADY_EXISTS: case DB_DUPLICATE_KEY: innobase_convert_tablename(new_table_name); my_error(HA_ERR_TABLE_EXIST, MYF(0), new_table_name); error = HA_ERR_TABLE_EXIST; break; default: error = convert_error_code_to_mysql( trx->error_state, prebuilt->table->flags, user_thd); } ut_d(dict_table_check_for_dup_indexes(prebuilt->table, TRUE)); mem_heap_free(heap); trx_general_rollback_for_mysql(trx, NULL); row_mysql_unlock_data_dictionary(trx); trx_free_for_mysql(trx); trx_commit_for_mysql(prebuilt->trx); DBUG_RETURN(error); } trx->table_id = indexed_table->id; } /* Create the indexes in SYS_INDEXES and load into dictionary. */ for (num_created = 0; num_created < num_of_idx; num_created++) { index[num_created] = row_merge_create_index( trx, indexed_table, &index_defs[num_created]); if (!index[num_created]) { error = trx->error_state; goto error_handling; } } ut_ad(error == DB_SUCCESS); /* Commit the data dictionary transaction in order to release the table locks on the system tables. This means that if MySQL crashes while creating a new primary key inside row_merge_build_indexes(), indexed_table will not be dropped by trx_rollback_active(). It will have to be recovered or dropped by the database administrator. */ trx_commit_for_mysql(trx); row_mysql_unlock_data_dictionary(trx); dict_locked = FALSE; ut_a(trx->n_active_thrs == 0); ut_a(UT_LIST_GET_LEN(trx->signals) == 0); if (UNIV_UNLIKELY(new_primary)) { /* A primary key is to be built. Acquire an exclusive table lock also on the table that is being created. */ ut_ad(indexed_table != prebuilt->table); error = row_merge_lock_table(prebuilt->trx, indexed_table, LOCK_X); if (UNIV_UNLIKELY(error != DB_SUCCESS)) { goto error_handling; } } /* Read the clustered index of the table and build indexes based on this information using temporary files and merge sort. */ error = row_merge_build_indexes(prebuilt->trx, prebuilt->table, indexed_table, index, num_of_idx, table); DBUG_EXECUTE_IF("crash_innodb_add_index_after", DBUG_SUICIDE();); error_handling: /* After an error, remove all those index definitions from the dictionary which were defined. */ switch (error) { case DB_SUCCESS: ut_a(!dict_locked); ut_d(mutex_enter(&dict_sys->mutex)); ut_d(dict_table_check_for_dup_indexes(prebuilt->table, TRUE)); ut_d(mutex_exit(&dict_sys->mutex)); *add = new ha_innobase_add_index(table, key_info, num_of_keys, indexed_table); break; case DB_TOO_BIG_RECORD: my_error(HA_ERR_TO_BIG_ROW, MYF(0)); goto error; case DB_PRIMARY_KEY_IS_NULL: my_error(ER_PRIMARY_CANT_HAVE_NULL, MYF(0)); /* fall through */ case DB_DUPLICATE_KEY: error: prebuilt->trx->error_info = NULL; /* fall through */ default: trx->error_state = DB_SUCCESS; if (new_primary) { if (indexed_table != prebuilt->table) { row_merge_drop_table(trx, indexed_table); } } else { if (!dict_locked) { row_mysql_lock_data_dictionary(trx); dict_locked = TRUE; } row_merge_drop_indexes(trx, indexed_table, index, num_created); } } trx_commit_for_mysql(trx); if (prebuilt->trx) { trx_commit_for_mysql(prebuilt->trx); } if (dict_locked) { row_mysql_unlock_data_dictionary(trx); } trx_free_for_mysql(trx); mem_heap_free(heap); /* There might be work for utility threads.*/ srv_active_wake_master_thread(); DBUG_RETURN(convert_error_code_to_mysql(error, prebuilt->table->flags, user_thd)); } /*******************************************************************//** Finalize or undo add_index(). @return 0 or error number */ UNIV_INTERN int ha_innobase::final_add_index( /*=========================*/ handler_add_index* add_arg,/*!< in: context from add_index() */ bool commit) /*!< in: true=commit, false=rollback */ { ha_innobase_add_index* add; trx_t* trx; int err = 0; DBUG_ENTER("ha_innobase::final_add_index"); ut_ad(add_arg); add = static_cast<class ha_innobase_add_index*>(add_arg); /* Create a background transaction for the operations on the data dictionary tables. */ trx = innobase_trx_allocate(user_thd); trx_start_if_not_started(trx); /* Flag this transaction as a dictionary operation, so that the data dictionary will be locked in crash recovery. */ trx_set_dict_operation(trx, TRX_DICT_OP_INDEX); /* Latch the InnoDB data dictionary exclusively so that no deadlocks or lock waits can happen in it during an index create operation. */ row_mysql_lock_data_dictionary(trx); if (add->indexed_table != prebuilt->table) { ulint error; /* We copied the table (new_primary). */ if (commit) { mem_heap_t* heap; char* tmp_name; heap = mem_heap_create(1024); /* A new primary key was defined for the table and there was no error at this point. We can now rename the old table as a temporary table, rename the new temporary table as the old table and drop the old table. */ tmp_name = innobase_create_temporary_tablename( heap, '2', prebuilt->table->name); error = row_merge_rename_tables( prebuilt->table, add->indexed_table, tmp_name, trx); switch (error) { case DB_TABLESPACE_ALREADY_EXISTS: case DB_DUPLICATE_KEY: innobase_convert_tablename(tmp_name); my_error(HA_ERR_TABLE_EXIST, MYF(0), tmp_name); err = HA_ERR_TABLE_EXIST; break; default: err = convert_error_code_to_mysql( error, prebuilt->table->flags, user_thd); break; } mem_heap_free(heap); } if (!commit || err) { error = row_merge_drop_table(trx, add->indexed_table); trx_commit_for_mysql(prebuilt->trx); } else { dict_table_t* old_table = prebuilt->table; trx_commit_for_mysql(prebuilt->trx); row_prebuilt_free(prebuilt, TRUE); error = row_merge_drop_table(trx, old_table); add->indexed_table->n_mysql_handles_opened++; prebuilt = row_create_prebuilt(add->indexed_table, 0 /* XXX Do we know the mysql_row_len here? Before the addition of this parameter to row_create_prebuilt() the mysql_row_len member was left 0 (from zalloc) in the prebuilt object. */); } err = convert_error_code_to_mysql( error, prebuilt->table->flags, user_thd); } else { /* We created secondary indexes (!new_primary). */ if (commit) { err = convert_error_code_to_mysql( row_merge_rename_indexes(trx, prebuilt->table), prebuilt->table->flags, user_thd); } if (!commit || err) { dict_index_t* index; dict_index_t* next_index; for (index = dict_table_get_first_index( prebuilt->table); index; index = next_index) { next_index = dict_table_get_next_index(index); if (*index->name == TEMP_INDEX_PREFIX) { row_merge_drop_index( index, prebuilt->table, trx); } } } } /* If index is successfully built, we will need to rebuild index translation table. Set valid index entry count in the translation table to zero. */ if (err == 0 && commit) { share->idx_trans_tbl.index_count = 0; } trx_commit_for_mysql(trx); if (prebuilt->trx) { trx_commit_for_mysql(prebuilt->trx); } ut_d(dict_table_check_for_dup_indexes(prebuilt->table, TRUE)); row_mysql_unlock_data_dictionary(trx); trx_free_for_mysql(trx); /* There might be work for utility threads.*/ srv_active_wake_master_thread(); delete add; DBUG_RETURN(err); } /*******************************************************************//** Prepare to drop some indexes of a table. @return 0 or error number */ UNIV_INTERN int ha_innobase::prepare_drop_index( /*============================*/ TABLE* table, /*!< in: Table where indexes are dropped */ uint* key_num, /*!< in: Key nums to be dropped */ uint num_of_keys) /*!< in: Number of keys to be dropped */ { trx_t* trx; int err = 0; uint n_key; DBUG_ENTER("ha_innobase::prepare_drop_index"); ut_ad(table); ut_ad(key_num); ut_ad(num_of_keys); if (srv_created_new_raw || srv_force_recovery) { DBUG_RETURN(HA_ERR_WRONG_COMMAND); } update_thd(); trx_search_latch_release_if_reserved(prebuilt->trx); trx = prebuilt->trx; if (UNIV_UNLIKELY(trx->fake_changes)) { DBUG_RETURN(HA_ERR_WRONG_COMMAND); } /* Test and mark all the indexes to be dropped */ row_mysql_lock_data_dictionary(trx); ut_d(dict_table_check_for_dup_indexes(prebuilt->table, TRUE)); /* Check that none of the indexes have previously been flagged for deletion. */ { const dict_index_t* index = dict_table_get_first_index(prebuilt->table); do { ut_a(!index->to_be_dropped); index = dict_table_get_next_index(index); } while (index); } for (n_key = 0; n_key < num_of_keys; n_key++) { const KEY* key; dict_index_t* index; key = table->key_info + key_num[n_key]; index = dict_table_get_index_on_name_and_min_id( prebuilt->table, key->name); if (!index) { sql_print_error("InnoDB could not find key n:o %u " "with name %s for table %s", key_num[n_key], key ? key->name : "NULL", prebuilt->table->name); err = HA_ERR_KEY_NOT_FOUND; goto func_exit; } /* Refuse to drop the clustered index. It would be better to automatically generate a clustered index, but mysql_alter_table() will call this method only after ha_innobase::add_index(). */ if (dict_index_is_clust(index)) { my_error(ER_REQUIRES_PRIMARY_KEY, MYF(0)); err = -1; goto func_exit; } rw_lock_x_lock(dict_index_get_lock(index)); index->to_be_dropped = TRUE; rw_lock_x_unlock(dict_index_get_lock(index)); } /* If FOREIGN_KEY_CHECKS = 1 you may not drop an index defined for a foreign key constraint because InnoDB requires that both tables contain indexes for the constraint. Such index can be dropped only if FOREIGN_KEY_CHECKS is set to 0. Note that CREATE INDEX id ON table does a CREATE INDEX and DROP INDEX, and we can ignore here foreign keys because a new index for the foreign key has already been created. We check for the foreign key constraints after marking the candidate indexes for deletion, because when we check for an equivalent foreign index we don't want to select an index that is later deleted. */ if (trx->check_foreigns && thd_sql_command(user_thd) != SQLCOM_CREATE_INDEX) { dict_index_t* index; for (index = dict_table_get_first_index(prebuilt->table); index; index = dict_table_get_next_index(index)) { dict_foreign_t* foreign; if (!index->to_be_dropped) { continue; } /* Check if the index is referenced. */ foreign = dict_table_get_referenced_constraint( prebuilt->table, index); if (foreign) { index_needed: trx_set_detailed_error( trx, "Index needed in foreign key " "constraint"); trx->error_info = index; err = HA_ERR_DROP_INDEX_FK; break; } else { /* Check if this index references some other table */ foreign = dict_table_get_foreign_constraint( prebuilt->table, index); if (foreign) { ut_a(foreign->foreign_index == index); /* Search for an equivalent index that the foreign key constraint could use if this index were to be deleted. */ if (!dict_foreign_find_equiv_index( foreign)) { goto index_needed; } } } } } else if (thd_sql_command(user_thd) == SQLCOM_CREATE_INDEX) { /* This is a drop of a foreign key constraint index that was created by MySQL when the constraint was added. MySQL does this when the user creates an index explicitly which can be used in place of the automatically generated index. */ dict_index_t* index; for (index = dict_table_get_first_index(prebuilt->table); index; index = dict_table_get_next_index(index)) { dict_foreign_t* foreign; if (!index->to_be_dropped) { continue; } /* Check if this index references some other table */ foreign = dict_table_get_foreign_constraint( prebuilt->table, index); if (foreign == NULL) { continue; } ut_a(foreign->foreign_index == index); /* Search for an equivalent index that the foreign key constraint could use if this index were to be deleted. */ if (!dict_foreign_find_equiv_index(foreign)) { trx_set_detailed_error( trx, "Index needed in foreign key " "constraint"); trx->error_info = foreign->foreign_index; err = HA_ERR_DROP_INDEX_FK; break; } } } func_exit: if (err) { /* Undo our changes since there was some sort of error. */ dict_index_t* index = dict_table_get_first_index(prebuilt->table); do { rw_lock_x_lock(dict_index_get_lock(index)); index->to_be_dropped = FALSE; rw_lock_x_unlock(dict_index_get_lock(index)); index = dict_table_get_next_index(index); } while (index); } ut_d(dict_table_check_for_dup_indexes(prebuilt->table, TRUE)); row_mysql_unlock_data_dictionary(trx); DBUG_RETURN(err); } /*******************************************************************//** Drop the indexes that were passed to a successful prepare_drop_index(). @return 0 or error number */ UNIV_INTERN int ha_innobase::final_drop_index( /*==========================*/ TABLE* table) /*!< in: Table where indexes are dropped */ { dict_index_t* index; /*!< Index to be dropped */ trx_t* trx; /*!< Transaction */ int err; DBUG_ENTER("ha_innobase::final_drop_index"); ut_ad(table); if (srv_created_new_raw || srv_force_recovery) { DBUG_RETURN(HA_ERR_WRONG_COMMAND); } update_thd(); trx_search_latch_release_if_reserved(prebuilt->trx); trx_start_if_not_started(prebuilt->trx); /* Create a background transaction for the operations on the data dictionary tables. */ trx = innobase_trx_allocate(user_thd); if (UNIV_UNLIKELY(trx->fake_changes)) { trx_general_rollback_for_mysql(trx, NULL); trx_free_for_mysql(trx); DBUG_RETURN(HA_ERR_WRONG_COMMAND); } trx_start_if_not_started(trx); /* Flag this transaction as a dictionary operation, so that the data dictionary will be locked in crash recovery. */ trx_set_dict_operation(trx, TRX_DICT_OP_INDEX); /* Lock the table exclusively, to ensure that no active transaction depends on an index that is being dropped. */ err = convert_error_code_to_mysql( row_merge_lock_table(prebuilt->trx, prebuilt->table, LOCK_X), prebuilt->table->flags, user_thd); row_mysql_lock_data_dictionary(trx); ut_d(dict_table_check_for_dup_indexes(prebuilt->table, TRUE)); if (UNIV_UNLIKELY(err)) { /* Unmark the indexes to be dropped. */ for (index = dict_table_get_first_index(prebuilt->table); index; index = dict_table_get_next_index(index)) { rw_lock_x_lock(dict_index_get_lock(index)); index->to_be_dropped = FALSE; rw_lock_x_unlock(dict_index_get_lock(index)); } goto func_exit; } /* Drop indexes marked to be dropped */ index = dict_table_get_first_index(prebuilt->table); while (index) { dict_index_t* next_index; next_index = dict_table_get_next_index(index); if (index->to_be_dropped) { row_merge_drop_index(index, prebuilt->table, trx); } index = next_index; } /* Check that all flagged indexes were dropped. */ for (index = dict_table_get_first_index(prebuilt->table); index; index = dict_table_get_next_index(index)) { ut_a(!index->to_be_dropped); } /* We will need to rebuild index translation table. Set valid index entry count in the translation table to zero */ share->idx_trans_tbl.index_count = 0; func_exit: ut_d(dict_table_check_for_dup_indexes(prebuilt->table, TRUE)); trx_commit_for_mysql(trx); trx_commit_for_mysql(prebuilt->trx); row_mysql_unlock_data_dictionary(trx); /* Flush the log to reduce probability that the .frm files and the InnoDB data dictionary get out-of-sync if the user runs with innodb_flush_log_at_trx_commit = 0 */ log_buffer_flush_to_disk(); trx_free_for_mysql(trx); /* Tell the InnoDB server that there might be work for utility threads: */ srv_active_wake_master_thread(); DBUG_RETURN(err); }
ottok/mariadb-5.5
storage/xtradb/handler/handler0alter.cc
C++
gpl-2.0
37,584
[ 30522, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
$('#modalUploader').on('show.bs.modal', function (event) { var uploader = new qq.FileUploaderBasic({ element: document.getElementById('file-uploader-demo1'), button: document.getElementById('areaSubir'), action: '/Files/Upload', params: { ruta: $('#RutaActual').val() }, allowedExtensions: ['jpg', 'jpeg', 'png', 'gif', 'doc', 'docx', 'pdf'], multiple: false, onComplete: function (id, fileName, responseJSON) { $.gritter.add({ title: 'Upload file', text: responseJSON.message }); }, onSubmit: function (id, fileName) { var strHtml = "<li>" + fileName + "</li>"; $("#dvxArchivos").append(strHtml); } }); }); $('#modalUploader').on('hidden.bs.modal', function () { RecargarRuta(); }) function AbrirCarpeta(pCarpeta) { $("#RutaSolicitada").val(pCarpeta); $("#frmMain").submit(); } function AbrirRuta(pCarpeta) { $("#RutaSolicitada").val(pCarpeta); $("#frmMain").submit(); } function RecargarRuta() { AbrirCarpeta($("#RutaActual").val()); } function EliminarArchivo(pRuta) { if (confirm("Are you sure that want to delete this file?")) { $.gritter.add({ title: 'Delete file', text: "File deleted" }); $("#ArchivoParaEliminar").val(pRuta); AbrirCarpeta($("#RutaActual").val()); } } function SubirNivel() { if ($("#TieneSuperior").val() == "1") { var strRutaAnterior = $("#RutaSuperior").val(); AbrirRuta(strRutaAnterior); } } function IrInicio() { AbrirRuta($("#RutaRaiz").val()); } function AbrirDialogoArchivo() { $("#modalUploader").modal(); } function getParameterByName(name) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.search); if (results == null) return ""; else return decodeURIComponent(results[1].replace(/\+/g, " ")); }
walalm/MVC-Azure-Explorer
MVC_Azure_Explorer/MVC_Azure_Explorer/Scripts/UtilsFileManager.js
JavaScript
mit
2,111
[ 30522, 1002, 1006, 1005, 1001, 16913, 2389, 6279, 11066, 2121, 1005, 1007, 1012, 2006, 1006, 1005, 2265, 1012, 18667, 1012, 16913, 2389, 1005, 1010, 3853, 1006, 2724, 1007, 1063, 13075, 2039, 11066, 2121, 1027, 2047, 1053, 4160, 1012, 5371,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
@echo off perl "%~dpn0" %*
mwcampbell/texinfo
util/texi2any.bat
Batchfile
gpl-3.0
29
[ 30522, 1030, 9052, 2125, 2566, 2140, 1000, 1003, 1066, 1040, 2361, 2078, 2692, 1000, 1003, 1008, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Verify data doesn't have basic mistakes, like empty text fields or empty label candidates. ## Examples ```shell parlai verify_data --task convai2 --datatype valid ``` """ from parlai.agents.repeat_label.repeat_label import RepeatLabelAgent from parlai.core.message import Message from parlai.core.params import ParlaiParser from parlai.utils.misc import TimeLogger, warn_once from parlai.core.worlds import create_task from parlai.core.script import ParlaiScript, register_script import parlai.utils.logging as logging def setup_args(parser=None): if parser is None: parser = ParlaiParser(True, True, 'Check tasks for common errors') # Get command line arguments parser.add_argument('-ltim', '--log-every-n-secs', type=float, default=2) parser.add_argument('-d', '--display-examples', type='bool', default=False) parser.set_defaults(datatype='train:stream:ordered') return parser def report(world, counts, log_time): report = world.report() log = { 'missing_text': counts['missing_text'], 'missing_labels': counts['missing_labels'], 'missing_label_candidates': counts['missing_label_candidates'], 'empty_string_label_candidates': counts['empty_string_label_candidates'], 'label_candidates_with_missing_label': counts[ 'label_candidates_with_missing_label' ], 'did_not_return_message': counts['did_not_return_message'], } text, log = log_time.log(report['exs'], world.num_examples(), log) return text, log def warn(txt, act, opt): if opt.get('display_examples'): print(txt + ":\n" + str(act)) else: warn_once(txt) def verify(opt): if opt['datatype'] == 'train': logging.warning("changing datatype from train to train:ordered") opt['datatype'] = 'train:ordered' opt.log() # create repeat label agent and assign it to the specified task agent = RepeatLabelAgent(opt) world = create_task(opt, agent) log_every_n_secs = opt.get('log_every_n_secs', -1) if log_every_n_secs <= 0: log_every_n_secs = float('inf') log_time = TimeLogger() counts = {} counts['missing_text'] = 0 counts['missing_labels'] = 0 counts['missing_label_candidates'] = 0 counts['empty_string_label_candidates'] = 0 counts['label_candidates_with_missing_label'] = 0 counts['did_not_return_message'] = 0 # Show some example dialogs. while not world.epoch_done(): world.parley() act = world.acts[0] if not isinstance(act, Message): counts['did_not_return_message'] += 1 if 'text' not in act and 'image' not in act: warn("warning: missing text field:\n", act, opt) counts['missing_text'] += 1 if 'labels' not in act and 'eval_labels' not in act: warn("warning: missing labels/eval_labels field:\n", act, opt) counts['missing_labels'] += 1 else: if 'label_candidates' not in act: counts['missing_label_candidates'] += 1 else: labels = act.get('labels', act.get('eval_labels')) is_label_cand = {} for l in labels: is_label_cand[l] = False for c in act['label_candidates']: if c == '': warn("warning: empty string label_candidate:\n", act, opt) counts['empty_string_label_candidates'] += 1 if c in is_label_cand: if is_label_cand[c] is True: warn( "warning: label mentioned twice in candidate_labels:\n", act, opt, ) is_label_cand[c] = True for _, has in is_label_cand.items(): if has is False: warn("warning: label missing in candidate_labels:\n", act, opt) counts['label_candidates_with_missing_label'] += 1 if log_time.time() > log_every_n_secs: text, log = report(world, counts, log_time) print(text) try: # print dataset size if available logging.info( f'Loaded {world.num_episodes()} episodes with a ' f'total of {world.num_examples()} examples' ) except AttributeError: pass counts['exs'] = int(world.report()['exs']) return counts def verify_data(opt): counts = verify(opt) print(counts) return counts @register_script('verify_data', hidden=True) class VerifyData(ParlaiScript): @classmethod def setup_args(cls): return setup_args() def run(self): return verify_data(self.opt) if __name__ == '__main__': VerifyData.main()
facebookresearch/ParlAI
parlai/scripts/verify_data.py
Python
mit
5,106
[ 30522, 1001, 999, 1013, 2149, 2099, 1013, 8026, 30524, 1010, 4297, 1012, 1998, 2049, 18460, 1012, 1001, 2023, 3120, 3642, 2003, 7000, 2104, 1996, 10210, 6105, 2179, 1999, 1996, 1001, 6105, 5371, 1999, 1996, 7117, 14176, 1997, 2023, 3120, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* RPG Paper Maker Copyright (C) 2017-2021 Wano RPG Paper Maker engine is under proprietary license. This source code is also copyrighted. Use Commercial edition for commercial use of your games. See RPG Paper Maker EULA here: http://rpg-paper-maker.com/index.php/eula. */ #ifndef PROJECTUPDATER_H #define PROJECTUPDATER_H #include "project.h" // ------------------------------------------------------- // // CLASS ProjectUpdater // // Module used for detecting if a project needs to be updated according to // the engine version. // // ------------------------------------------------------- class ProjectUpdater : public QObject { Q_OBJECT public: ProjectUpdater(Project* project, QString previous); virtual ~ProjectUpdater(); static const int incompatibleVersionsCount; static QString incompatibleVersions[]; void clearListMapPaths(); void clearListMapPortions(); void copyPreviousProject(); void getAllPathsMapsPortions(); void updateVersion(QString& version); void copyExecutable(); void copySystemScripts(); void updateCommands(); protected: Project* m_project; QString m_previousFolderName; QList<QString> m_listMapPaths; QList<QJsonObject> m_listMapProperties; QList<QString> m_listMapPropertiesPaths; QList<QList<QJsonObject>*> m_listMapPortions; QList<QList<QString>*> m_listMapPortionsPaths; public slots: void check(); void updateVersion_0_3_1(); void updateVersion_0_4_0(); void updateVersion_0_4_3(); void updateVersion_0_5_2(); void updateVersion_1_0_0(); void updateVersion_1_1_1(); void updateVersion_1_2_0(); void updateVersion_1_2_1(); void updateVersion_1_3_0(); void updateVersion_1_3_0_commands(QStandardItem *commands); void updateVersion_1_4_0(); void updateVersion_1_4_0_commands(QStandardItem *commands); void updateVersion_1_4_1(); void updateVersion_1_4_1_commands(QStandardItem *commands); void updateVersion_1_5_0(); void updateVersion_1_5_3(); void updateVersion_1_5_6(); void updateVersion_1_5_6_commands(QStandardItem *commands); void updateVersion_1_6_0(); void updateVersion_1_6_2(); void updateVersion_1_6_3(); void updateVersion_1_6_3_commands(QStandardItem *commands); void updateVersion_1_6_4(); void updateVersion_1_7_0(); void updateVersion_1_7_0_commands(QStandardItem *commands); void updateVersion_1_7_0_json(QString path, QString listName); void updateVersion_1_7_3(); void updateVersion_1_7_3_commands(QStandardItem *commands); signals: void progress(int, QString); void finished(); void updatingCommands(QStandardItem *commands); }; #endif // PROJECTUPDATER_H
Wano-k/RPG-Paper-Maker
Editor/Models/projectupdater.h
C
gpl-3.0
2,757
[ 30522, 1013, 1008, 22531, 3259, 9338, 9385, 1006, 1039, 1007, 2418, 1011, 25682, 14071, 2080, 22531, 3259, 9338, 3194, 2003, 2104, 16350, 6105, 1012, 2023, 3120, 3642, 2003, 2036, 9385, 2098, 1012, 2224, 3293, 3179, 2005, 3293, 2224, 1997, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Class template year_based_generator</title> <link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> <link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> <link rel="up" href="../../date_time/doxy.html#header.boost.date_time.date_generators_hpp" title="Header &lt;boost/date_time/date_generators.hpp&gt;"> <link rel="prev" href="date_generator_parser.html" title="Class template date_generator_parser"> <link rel="next" href="partial_date.html" title="Class template partial_date"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table cellpadding="2" width="100%"><tr> <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td> <td align="center"><a href="../../../../index.html">Home</a></td> <td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td> <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> <td align="center"><a href="../../../../more/index.htm">More</a></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="date_generator_parser.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.date_generators_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="partial_date.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> </div> <div class="refentry"> <a name="boost.date_time.year_based_generator"></a><div class="titlepage"></div> <div class="refnamediv"> <h2><span class="refentrytitle">Class template year_based_generator</span></h2> <p>boost::date_time::year_based_generator &#8212; Base class for all generators that take a year and produce a date. </p> </div> <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../date_time/doxy.html#header.boost.date_time.date_generators_hpp" title="Header &lt;boost/date_time/date_generators.hpp&gt;">boost/date_time/date_generators.hpp</a>&gt; </span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> date_type<span class="special">&gt;</span> <span class="keyword">class</span> <a class="link" href="year_based_generator.html" title="Class template year_based_generator">year_based_generator</a> <span class="special">{</span> <span class="keyword">public</span><span class="special">:</span> <span class="comment">// types</span> <span class="keyword">typedef</span> <span class="identifier">date_type</span><span class="special">::</span><span class="identifier">calendar_type</span> <a name="boost.date_time.year_based_generator.calendar_type"></a><span class="identifier">calendar_type</span><span class="special">;</span> <span class="keyword">typedef</span> <span class="identifier">calendar_type</span><span class="special">::</span><span class="identifier">year_type</span> <a name="boost.date_time.year_based_generator.year_type"></a><span class="identifier">year_type</span><span class="special">;</span> <span class="comment">// <a class="link" href="year_based_generator.html#boost.date_time.year_based_generatorconstruct-copy-destruct">construct/copy/destruct</a></span> <a class="link" href="year_based_generator.html#id447455-bb"><span class="identifier">year_based_generator</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span> <a class="link" href="year_based_generator.html#id447456-bb"><span class="special">~</span><span class="identifier">year_based_generator</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span> <span class="comment">// <a class="link" href="year_based_generator.html#id687676-bb">public member functions</a></span> <span class="identifier">date_type</span> <a class="link" href="year_based_generator.html#id447431-bb"><span class="identifier">get_date</span></a><span class="special">(</span><span class="identifier">year_type</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a class="link" href="year_based_generator.html#id447444-bb"><span class="identifier">to_string</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="special">}</span><span class="special">;</span></pre></div> <div class="refsect1"> <a name="id1381517"></a><h2>Description</h2> <p>This class is a base class for polymorphic function objects that take a year and produce a concrete date. </p> <div class="refsect2"> <a name="id1381524"></a><h3> <a name="boost.date_time.year_based_generatorconstruct-copy-destruct"></a><code class="computeroutput">year_based_generator</code> public construct/copy/destruct</h3> <div class="orderedlist"><ol class="orderedlist" type="1"> <li class="listitem"><pre class="literallayout"><a name="id447455-bb"></a><span class="identifier">year_based_generator</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li> <li class="listitem"><pre class="literallayout"><a name="id447456-bb"></a><span class="special">~</span><span class="identifier">year_based_generator</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li> </ol></div> </div> <div class="refsect2"> <a name="id1381608"></a><h3> <a name="id687676-bb"></a><code class="computeroutput">year_based_generator</code> public member functions</h3> <div class="orderedlist"><ol class="orderedlist" type="1"> <li class="listitem"><pre class="literallayout"><span class="identifier">date_type</span> <a name="id447431-bb"></a><span class="identifier">get_date</span><span class="special">(</span><span class="identifier">year_type</span> y<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li> <li class="listitem"> <pre class="literallayout"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a name="id447444-bb"></a><span class="identifier">to_string</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Returns a string for use in a POSIX time_zone string. </li> </ol></div> </div> </div> </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> <td align="right"><div class="copyright-footer">Copyright &#169; 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file <code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p> </div></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="date_generator_parser.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#header.boost.date_time.date_generators_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="partial_date.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> </div> </body> </html>
tianyang-li/de-novo-rna-seq-quant-1
boost_1_51_0/doc/html/boost/date_time/year_based_generator.html
HTML
gpl-3.0
8,172
[ 30522, 1026, 16129, 1028, 1026, 2132, 1028, 1026, 18804, 8299, 1011, 1041, 15549, 2615, 1027, 1000, 4180, 1011, 2828, 1000, 4180, 1027, 1000, 3793, 1013, 16129, 1025, 25869, 13462, 1027, 2149, 1011, 2004, 6895, 2072, 1000, 1028, 1026, 2516,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!doctype html> <html class="default no-js"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Dungeon | rot.js</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="../assets/css/main.css"> </head> <body> <header> <div class="tsd-page-toolbar"> <div class="container"> <div class="table-wrap"> <div class="table-cell" id="tsd-search" data-index="../assets/js/search.js" data-base=".."> <div class="field"> <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label> <input id="tsd-search-field" type="text" /> </div> <ul class="results"> <li class="state loading">Preparing search index...</li> <li class="state failure">The search index is not available</li> </ul> <a href="../index.html" class="title">rot.js</a> </div> <div class="table-cell" id="tsd-widgets"> <div id="tsd-filter"> <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a> <div class="tsd-filter-group"> <div class="tsd-select" id="tsd-filter-visibility"> <span class="tsd-select-label">All</span> <ul class="tsd-select-list"> <li data-value="public">Public</li> <li data-value="protected">Public/Protected</li> <li data-value="private" class="selected">All</li> </ul> </div> <input type="checkbox" id="tsd-filter-inherited" checked /> <label class="tsd-widget" for="tsd-filter-inherited">Inherited</label> <input type="checkbox" id="tsd-filter-externals" checked /> <label class="tsd-widget" for="tsd-filter-externals">Externals</label> <input type="checkbox" id="tsd-filter-only-exported" /> <label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label> </div> </div> <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a> </div> </div> </div> </div> <div class="tsd-page-title"> <div class="container"> <ul class="tsd-breadcrumb"> <li> <a href="../index.html">Globals</a> </li> <li> <a href="../modules/_map_dungeon_.html">&quot;map/dungeon&quot;</a> </li> <li> <a href="_map_dungeon_.dungeon.html">Dungeon</a> </li> </ul> <h1>Class Dungeon</h1> </div> </div> </header> <div class="container container-main"> <div class="row"> <div class="col-8 col-content"> <section class="tsd-panel tsd-comment"> <div class="tsd-comment tsd-typography"> <dl class="tsd-comment-tags"> <dt>class</dt> <dd><p>Dungeon map: has rooms and corridors</p> </dd> <dt>augments</dt> <dd><p>ROT.Map</p> </dd> </dl> </div> </section> <section class="tsd-panel tsd-hierarchy"> <h3>Hierarchy</h3> <ul class="tsd-hierarchy"> <li> <a href="_map_map_.map.html" class="tsd-signature-type">Map</a> <ul class="tsd-hierarchy"> <li> <span class="target">Dungeon</span> <ul class="tsd-hierarchy"> <li> <a href="_map_uniform_.uniform.html" class="tsd-signature-type">Uniform</a> </li> <li> <a href="_map_digger_.digger.html" class="tsd-signature-type">Digger</a> </li> </ul> </li> </ul> </li> </ul> </section> <section class="tsd-panel-group tsd-index-group"> <h2>Index</h2> <section class="tsd-panel tsd-index-panel"> <div class="tsd-index-content"> <section class="tsd-index-section "> <h3>Constructors</h3> <ul class="tsd-index-list"> <li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite"><a href="_map_dungeon_.dungeon.html#constructor" class="tsd-kind-icon">constructor</a></li> </ul> </section> <section class="tsd-index-section "> <h3>Properties</h3> <ul class="tsd-index-list"> <li class="tsd-kind-property tsd-parent-kind-class"><a href="_map_dungeon_.dungeon.html#_corridors" class="tsd-kind-icon">_corridors</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><a href="_map_dungeon_.dungeon.html#_height" class="tsd-kind-icon">_height</a></li> <li class="tsd-kind-property tsd-parent-kind-class"><a href="_map_dungeon_.dungeon.html#_rooms" class="tsd-kind-icon">_rooms</a></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><a href="_map_dungeon_.dungeon.html#_width" class="tsd-kind-icon">_width</a></li> </ul> </section> <section class="tsd-index-section "> <h3>Methods</h3> <ul class="tsd-index-list"> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><a href="_map_dungeon_.dungeon.html#_fillmap" class="tsd-kind-icon">_fill<wbr>Map</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><a href="_map_dungeon_.dungeon.html#create" class="tsd-kind-icon">create</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="_map_dungeon_.dungeon.html#getcorridors" class="tsd-kind-icon">get<wbr>Corridors</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="_map_dungeon_.dungeon.html#getrooms" class="tsd-kind-icon">get<wbr>Rooms</a></li> </ul> </section> </div> </section> </section> <section class="tsd-panel-group tsd-member-group "> <h2>Constructors</h2> <section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite"> <a name="constructor" class="tsd-anchor"></a> <h3>constructor</h3> <ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite"> <li class="tsd-signature tsd-kind-icon">new <wbr>Dungeon<span class="tsd-signature-symbol">(</span>width<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span>, height<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_map_dungeon_.dungeon.html" class="tsd-signature-type">Dungeon</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <p>Overrides <a href="_map_map_.map.html">Map</a>.<a href="_map_map_.map.html#constructor">constructor</a></p> <ul> <li>Defined in <a href="https://github.com/ondras/rot.js/blob/736d55d/src/map/dungeon.ts#L10">map/dungeon.ts:10</a></li> </ul> </aside> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>width: <span class="tsd-signature-type">number</span></h5> </li> <li> <h5>height: <span class="tsd-signature-type">number</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="_map_dungeon_.dungeon.html" class="tsd-signature-type">Dungeon</a></h4> </li> </ul> </section> </section> <section class="tsd-panel-group tsd-member-group "> <h2>Properties</h2> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="_corridors" class="tsd-anchor"></a> <h3>_corridors</h3> <div class="tsd-signature tsd-kind-icon">_corridors<span class="tsd-signature-symbol">:</span> <a href="_map_features_.corridor.html" class="tsd-signature-type">Corridor</a><span class="tsd-signature-symbol">[]</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/ondras/rot.js/blob/736d55d/src/map/dungeon.ts#L10">map/dungeon.ts:10</a></li> </ul> </aside> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-inherited"> <a name="_height" class="tsd-anchor"></a> <h3>_height</h3> <div class="tsd-signature tsd-kind-icon">_height<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> <aside class="tsd-sources"> <p>Inherited from <a href="_map_map_.map.html">Map</a>.<a href="_map_map_.map.html#_height">_height</a></p> <ul> <li>Defined in <a href="https://github.com/ondras/rot.js/blob/736d55d/src/map/map.ts#L7">map/map.ts:7</a></li> </ul> </aside> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"> <a name="_rooms" class="tsd-anchor"></a> <h3>_rooms</h3> <div class="tsd-signature tsd-kind-icon">_rooms<span class="tsd-signature-symbol">:</span> <a href="_map_features_.room.html" class="tsd-signature-type">Room</a><span class="tsd-signature-symbol">[]</span></div> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/ondras/rot.js/blob/736d55d/src/map/dungeon.ts#L9">map/dungeon.ts:9</a></li> </ul> </aside> </section> <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-inherited"> <a name="_width" class="tsd-anchor"></a> <h3>_width</h3> <div class="tsd-signature tsd-kind-icon">_width<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div> <aside class="tsd-sources"> <p>Inherited from <a href="_map_map_.map.html">Map</a>.<a href="_map_map_.map.html#_width">_width</a></p> <ul> <li>Defined in <a href="https://github.com/ondras/rot.js/blob/736d55d/src/map/map.ts#L6">map/map.ts:6</a></li> </ul> </aside> </section> </section> <section class="tsd-panel-group tsd-member-group "> <h2>Methods</h2> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited"> <a name="_fillmap" class="tsd-anchor"></a> <h3>_fill<wbr>Map</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited"> <li class="tsd-signature tsd-kind-icon">_fill<wbr>Map<span class="tsd-signature-symbol">(</span>value<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">[]</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <p>Inherited from <a href="_map_map_.map.html">Map</a>.<a href="_map_map_.map.html#_fillmap">_fillMap</a></p> <ul> <li>Defined in <a href="https://github.com/ondras/rot.js/blob/736d55d/src/map/map.ts#L21">map/map.ts:21</a></li> </ul> </aside> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>value: <span class="tsd-signature-type">number</span></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">[]</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-inherited"> <a name="create" class="tsd-anchor"></a> <h3><span class="tsd-flag ts-flagAbstract">Abstract</span> create</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-inherited"> <li class="tsd-signature tsd-kind-icon">create<span class="tsd-signature-symbol">(</span>callback<span class="tsd-signature-symbol">?: </span><a href="../interfaces/_map_map_.createcallback.html" class="tsd-signature-type">CreateCallback</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <p>Inherited from <a href="_map_map_.map.html">Map</a>.<a href="_map_map_.map.html#create">create</a></p> <ul> <li>Defined in <a href="https://github.com/ondras/rot.js/blob/736d55d/src/map/map.ts#L19">map/map.ts:19</a></li> </ul> </aside> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5><span class="tsd-flag ts-flagOptional">Optional</span> callback: <a href="../interfaces/_map_map_.createcallback.html" class="tsd-signature-type">CreateCallback</a></h5> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="getcorridors" class="tsd-anchor"></a> <h3>get<wbr>Corridors</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">get<wbr>Corridors<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_map_features_.corridor.html" class="tsd-signature-type">Corridor</a><span class="tsd-signature-symbol">[]</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/ondras/rot.js/blob/736d55d/src/map/dungeon.ts#L28">map/dungeon.ts:28</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Get all generated corridors</p> </div> </div> <h4 class="tsd-returns-title">Returns <a href="_map_features_.corridor.html" class="tsd-signature-type">Corridor</a><span class="tsd-signature-symbol">[]</span></h4> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="getrooms" class="tsd-anchor"></a> <h3>get<wbr>Rooms</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">get<wbr>Rooms<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_map_features_.room.html" class="tsd-signature-type">Room</a><span class="tsd-signature-symbol">[]</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/ondras/rot.js/blob/736d55d/src/map/dungeon.ts#L22">map/dungeon.ts:22</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Get all generated rooms</p> </div> </div> <h4 class="tsd-returns-title">Returns <a href="_map_features_.room.html" class="tsd-signature-type">Room</a><span class="tsd-signature-symbol">[]</span></h4> </li> </ul> </section> </section> </div> <div class="col-4 col-menu menu-sticky-wrap menu-highlight"> <nav class="tsd-navigation primary"> <ul> <li class="globals "> <a href="../index.html"><em>Globals</em></a> </li> <li class="current tsd-kind-external-module"> <a href="../modules/_map_dungeon_.html">&quot;map/dungeon&quot;</a> </li> </ul> </nav> <nav class="tsd-navigation secondary menu-sticky"> <ul class="before-current"> </ul> <ul class="current"> <li class="current tsd-kind-class tsd-parent-kind-external-module"> <a href="_map_dungeon_.dungeon.html" class="tsd-kind-icon">Dungeon</a> <ul> <li class=" tsd-kind-constructor tsd-parent-kind-class tsd-is-overwrite"> <a href="_map_dungeon_.dungeon.html#constructor" class="tsd-kind-icon">constructor</a> </li> <li class=" tsd-kind-property tsd-parent-kind-class"> <a href="_map_dungeon_.dungeon.html#_corridors" class="tsd-kind-icon">_corridors</a> </li> <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-inherited"> <a href="_map_dungeon_.dungeon.html#_height" class="tsd-kind-icon">_height</a> </li> <li class=" tsd-kind-property tsd-parent-kind-class"> <a href="_map_dungeon_.dungeon.html#_rooms" class="tsd-kind-icon">_rooms</a> </li> <li class=" tsd-kind-property tsd-parent-kind-class tsd-is-inherited"> <a href="_map_dungeon_.dungeon.html#_width" class="tsd-kind-icon">_width</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-inherited"> <a href="_map_dungeon_.dungeon.html#_fillmap" class="tsd-kind-icon">_fill<wbr>Map</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-inherited"> <a href="_map_dungeon_.dungeon.html#create" class="tsd-kind-icon">create</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="_map_dungeon_.dungeon.html#getcorridors" class="tsd-kind-icon">get<wbr>Corridors</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="_map_dungeon_.dungeon.html#getrooms" class="tsd-kind-icon">get<wbr>Rooms</a> </li> </ul> </li> </ul> <ul class="after-current"> </ul> </nav> </div> </div> </div> <footer class="with-border-bottom"> <div class="container"> <h2>Legend</h2> <div class="tsd-legend-group"> <ul class="tsd-legend"> <li class="tsd-kind-module"><span class="tsd-kind-icon">Module</span></li> <li class="tsd-kind-object-literal"><span class="tsd-kind-icon">Object literal</span></li> <li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li> <li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li> <li class="tsd-kind-function tsd-has-type-parameter"><span class="tsd-kind-icon">Function with type parameter</span></li> <li class="tsd-kind-index-signature"><span class="tsd-kind-icon">Index signature</span></li> <li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li> <li class="tsd-kind-type-alias tsd-has-type-parameter"><span class="tsd-kind-icon">Type alias with type parameter</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-enum"><span class="tsd-kind-icon">Enumeration</span></li> <li class="tsd-kind-enum-member"><span class="tsd-kind-icon">Enumeration member</span></li> <li class="tsd-kind-property tsd-parent-kind-enum"><span class="tsd-kind-icon">Property</span></li> <li class="tsd-kind-method tsd-parent-kind-enum"><span class="tsd-kind-icon">Method</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li> <li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li> <li class="tsd-kind-constructor tsd-parent-kind-interface"><span class="tsd-kind-icon">Constructor</span></li> <li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li> <li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li> <li class="tsd-kind-index-signature tsd-parent-kind-interface"><span class="tsd-kind-icon">Index signature</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li> <li class="tsd-kind-class tsd-has-type-parameter"><span class="tsd-kind-icon">Class with type parameter</span></li> <li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li> <li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li> <li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><span class="tsd-kind-icon">Accessor</span></li> <li class="tsd-kind-index-signature tsd-parent-kind-class"><span class="tsd-kind-icon">Index signature</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited constructor</span></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li> <li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited accessor</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected property</span></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected method</span></li> <li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected accessor</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private property</span></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private method</span></li> <li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private accessor</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static property</span></li> <li class="tsd-kind-call-signature tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li> </ul> </div> </div> </footer> <div class="container tsd-generator"> <p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p> </div> <div class="overlay"></div> <script src="../assets/js/main.js"></script> <script>if (location.protocol == 'file:') document.write('<script src="../assets/js/search.js"><' + '/script>');</script> </body> </html>
ondras/rot.js
doc/classes/_map_dungeon_.dungeon.html
HTML
bsd-3-clause
22,426
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 2465, 1027, 1000, 12398, 2053, 1011, 1046, 2015, 1000, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1028, 1026, 18804, 8299, 1011, 104...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import Event, { Emitter } from 'vs/base/common/event'; import { Disposable } from 'vs/base/common/lifecycle'; import URI from 'vs/base/common/uri'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration'; import { IPosition, Position } from 'vs/editor/common/core/position'; import { IModeService } from 'vs/editor/common/services/modeService'; import { IModelService } from 'vs/editor/common/services/modelService'; export class TextResourceConfigurationService extends Disposable implements ITextResourceConfigurationService { public _serviceBrand: any; private readonly _onDidUpdateConfiguration: Emitter<void> = this._register(new Emitter<void>()); public readonly onDidUpdateConfiguration: Event<void> = this._onDidUpdateConfiguration.event; constructor( @IConfigurationService private configurationService: IConfigurationService, @IModelService private modelService: IModelService, @IModeService private modeService: IModeService, ) { super(); this._register(this.configurationService.onDidUpdateConfiguration(() => this._onDidUpdateConfiguration.fire())); } getConfiguration<T>(resource: URI, section?: string): T getConfiguration<T>(resource: URI, at?: IPosition, section?: string): T getConfiguration<T>(resource: URI, arg2?: any, arg3?: any): T { const position: IPosition = Position.isIPosition(arg2) ? arg2 : null; const section: string = position ? (typeof arg3 === 'string' ? arg3 : void 0) : (typeof arg2 === 'string' ? arg2 : void 0); const language = resource ? this.getLanguage(resource, position) : void 0; return this.configurationService.getConfiguration<T>(section, { resource, overrideIdentifier: language }); } private getLanguage(resource: URI, position: IPosition): string { const model = this.modelService.getModel(resource); if (model) { return position ? this.modeService.getLanguageIdentifier(model.getLanguageIdAtPosition(position.lineNumber, position.column)).language : model.getLanguageIdentifier().language; } return this.modeService.getModeIdByFilenameOrFirstLine(resource.fsPath); } }
gagangupt16/vscode
src/vs/editor/common/services/resourceConfigurationImpl.ts
TypeScript
mit
2,553
[ 30522, 1013, 1008, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 101...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package org.alvarogp.nettop.common.di.components; import org.alvarogp.nettop.common.di.modules.ActivityModule; import org.alvarogp.nettop.common.di.scopes.PerActivity; import dagger.Component; @PerActivity @Component(dependencies = ApplicationComponent.class, modules = ActivityModule.class) public interface ActivityComponent { }
alvarogzp/net-top
app/src/main/java/org/alvarogp/nettop/common/di/components/ActivityComponent.java
Java
gpl-3.0
334
[ 30522, 7427, 8917, 1012, 24892, 21600, 1012, 5658, 14399, 1012, 2691, 1012, 4487, 1012, 6177, 1025, 12324, 8917, 1012, 24892, 21600, 1012, 5658, 14399, 1012, 2691, 1012, 4487, 1012, 14184, 1012, 4023, 5302, 8566, 2571, 1025, 12324, 8917, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Text; using System.Threading; using Newtonsoft.Json; namespace lit { class HttpTransferModule : ITransferModule { public const string ConnectionRequest = "subscribe"; public const string StatusRequest = "getstatus"; public const string StatusReport = "status"; private List<string> connections = new List<string>(); private IDictionary<string, string> myRecord; private readonly HttpListener myListener = new HttpListener(); public List<string> Prefixes { get; set; } public HttpTransferModule(IConfiguration configuration) { if (!HttpListener.IsSupported) { throw new NotSupportedException("Needs Windows XP SP2, Server 2003 or later."); } // URI prefixes are required, for example // "http://localhost:8080/index/". if (string.IsNullOrEmpty(configuration.Transfer.Prefix)) { throw new ArgumentException("Prefix"); } Console.WriteLine("using prefix {0}", configuration.Transfer.Prefix); myListener.Prefixes.Add(configuration.Transfer.Prefix); } public void Start() { myListener.Start(); ThreadPool.QueueUserWorkItem((o) => { Console.WriteLine("Webserver is running..."); try { while (myListener.IsListening) { ThreadPool.QueueUserWorkItem((c) => { var ctx = c as HttpListenerContext; try { var simpleResponse = Response(ctx.Request); var buf = Encoding.UTF8.GetBytes(simpleResponse.Content); ctx.Response.ContentLength64 = buf.Length; ctx.Response.OutputStream.Write(buf, 0, buf.Length); ctx.Response.StatusCode = (int)simpleResponse.StatusCode; } catch { } // suppress any exceptions finally { // always close the stream ctx.Response.OutputStream.Close(); } }, myListener.GetContext()); } } catch { } // suppress any exceptions }); } public void ReceiveChanges(IDictionary<string, string> record) { myRecord = record; Console.WriteLine(string.Join(", ", new List<string>() { "TimeStamp", "Build", "Assembly", "TC", "Status" }.Select(f => record.ContainsKey(f) ? record[f] : ""))); } public void Stop() { myListener.Stop(); myListener.Close(); } public void Dispose() { Stop(); } private HttpSimpleResponse Response(HttpListenerRequest httpRequest) { if (null == httpRequest) { return new HttpSimpleResponse(HttpStatusCode.BadRequest, "null"); } var request = httpRequest.Url.LocalPath.Trim('/'); var client = httpRequest.RemoteEndPoint.Address.ToString(); Console.WriteLine("http {0} request received from {1}: {2}", httpRequest.HttpMethod, client, request); switch (request) { case ConnectionRequest: if (connections.All(c => c != client)) { connections.Add(client); Console.WriteLine("connection request accepted from {0}", client); } return new HttpSimpleResponse(HttpStatusCode.OK, RecordAsJson); case StatusRequest: return new HttpSimpleResponse(HttpStatusCode.OK, RecordAsJson); default: return new HttpSimpleResponse(HttpStatusCode.BadRequest, "he?!"); } } private string RecordAsJson { get { return JsonConvert.SerializeObject(myRecord, typeof(Dictionary<string, string>), Formatting.None, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore, }); } } } }
klapantius/lit
lit/Transfer/HttpTransferModule.cs
C#
gpl-2.0
4,828
[ 30522, 2478, 2291, 1025, 2478, 2291, 1012, 6407, 1012, 12391, 1025, 2478, 2291, 1012, 11409, 4160, 1025, 2478, 2291, 1012, 5658, 1025, 2478, 2291, 1012, 3793, 1025, 2478, 2291, 1012, 11689, 2075, 1025, 2478, 8446, 6499, 6199, 1012, 1046, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import {Event, ipcRenderer} from 'electron' import * as React from 'react' import * as ReactDOM from 'react-dom' import * as globalProperties from '../../globalProperties' import * as HelperUI from '../../HelperUI' import { ISettings } from '../../settings' import { TrelloTypes } from '../../TrelloInterfaces' export default class ImageCover extends React.Component<IimageCoverProps, {}> { public render () { let extension: string = this.props.attData.url.match(/.+([.].+)/)[1] if (this.props.settings !== undefined && !this.props.settings.animateGIFs && extension === '.gif') { extension = '.png' } const filename = `${this.props.attData.id}${extension}` const pathToImage = `${globalProperties.getPath()}attachments/${filename}` return ( <div style={{backgroundColor: this.props.attData.edgeColor}}> <img className='imgCover' src={pathToImage}/> </div> ) } } interface IimageCoverProps { attData: TrelloTypes.Attachment // TODO - remove this and use Redux settings: ISettings }
TheNumerus/ToDoElectron
src/components/trello/imageCover.tsx
TypeScript
mit
1,015
[ 30522, 12324, 1063, 2724, 1010, 12997, 16748, 11563, 2121, 1065, 2013, 1005, 10496, 1005, 12324, 1008, 2004, 10509, 2013, 1005, 10509, 1005, 12324, 1008, 2004, 10509, 9527, 2013, 1005, 10509, 1011, 14383, 1005, 12324, 1008, 2004, 3795, 21572,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
using System; using System.Collections.Generic; using System.Linq; using System.Text; using FlatRedBall.Content.Scene; using FlatRedBall; using FlatRedBall.IO; namespace EditorObjects.EditorSettings { public class AIEditorPropertiesSave { public const string Extension = "aiep"; public CameraSave BoundsCamera; public CameraSave Camera = new CameraSave(); public bool BoundsVisible = false; // For loading. public AIEditorPropertiesSave() { Camera.Z = 40; // do nothing } public void SetFromRuntime(Camera camera, Camera boundsCamera, bool boundsVisible) { Camera = CameraSave.FromCamera(camera); if (boundsCamera != null) { BoundsCamera = CameraSave.FromCamera(boundsCamera, true); } BoundsVisible = boundsVisible; // Gui.GuiData.listWindow } public static AIEditorPropertiesSave Load(string fileName) { AIEditorPropertiesSave toReturn = new AIEditorPropertiesSave(); FileManager.XmlDeserialize(fileName, out toReturn); return toReturn; } public void Save(string fileName) { FileManager.XmlSerialize(this, fileName); } } }
GorillaOne/FlatRedBall
FRBDK/FRBDK Supporting Projects/EditorObjects/EditorSettings/AIEditorPropertiesSave.cs
C#
mit
1,372
[ 30522, 2478, 2291, 1025, 2478, 2291, 1012, 6407, 1012, 12391, 1025, 2478, 2291, 1012, 11409, 4160, 1025, 2478, 2291, 1012, 3793, 1025, 2478, 4257, 5596, 7384, 1012, 4180, 1012, 3496, 1025, 2478, 4257, 5596, 7384, 1025, 2478, 4257, 5596, 7...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# -*- coding: utf8 -*- # Copyright (c) 2017-2021 THL A29 Limited, a Tencent company. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # 操作失败。 FAILEDOPERATION = 'FailedOperation' # API网关触发器创建失败。 FAILEDOPERATION_APIGATEWAY = 'FailedOperation.ApiGateway' # 创建触发器失败。 FAILEDOPERATION_APIGW = 'FailedOperation.Apigw' # 获取Apm InstanceId失败。 FAILEDOPERATION_APMCONFIGINSTANCEID = 'FailedOperation.ApmConfigInstanceId' # 当前异步事件状态不支持此操作,请稍后重试。 FAILEDOPERATION_ASYNCEVENTSTATUS = 'FailedOperation.AsyncEventStatus' # 复制函数失败。 FAILEDOPERATION_COPYFAILED = 'FailedOperation.CopyFailed' # 不支持复制到该地域。 FAILEDOPERATION_COPYFUNCTION = 'FailedOperation.CopyFunction' # 操作COS资源失败。 FAILEDOPERATION_COS = 'FailedOperation.Cos' # 创建别名失败。 FAILEDOPERATION_CREATEALIAS = 'FailedOperation.CreateAlias' # 操作失败。 FAILEDOPERATION_CREATEFUNCTION = 'FailedOperation.CreateFunction' # 创建命名空间失败。 FAILEDOPERATION_CREATENAMESPACE = 'FailedOperation.CreateNamespace' # 当前函数状态无法进行此操作。 FAILEDOPERATION_CREATETRIGGER = 'FailedOperation.CreateTrigger' # 当前调试状态无法执行此操作。 FAILEDOPERATION_DEBUGMODESTATUS = 'FailedOperation.DebugModeStatus' # 调试状态下无法更新执行超时时间。 FAILEDOPERATION_DEBUGMODEUPDATETIMEOUTFAIL = 'FailedOperation.DebugModeUpdateTimeOutFail' # 删除别名失败。 FAILEDOPERATION_DELETEALIAS = 'FailedOperation.DeleteAlias' # 当前函数状态无法进行此操作,请在函数状态正常时重试。 FAILEDOPERATION_DELETEFUNCTION = 'FailedOperation.DeleteFunction' # 删除layer版本失败。 FAILEDOPERATION_DELETELAYERVERSION = 'FailedOperation.DeleteLayerVersion' # 无法删除默认Namespace。 FAILEDOPERATION_DELETENAMESPACE = 'FailedOperation.DeleteNamespace' # 删除触发器失败。 FAILEDOPERATION_DELETETRIGGER = 'FailedOperation.DeleteTrigger' # 当前函数状态无法更新代码,请在状态为正常时更新。 FAILEDOPERATION_FUNCTIONNAMESTATUSERROR = 'FailedOperation.FunctionNameStatusError' # 函数在部署中,无法做此操作。 FAILEDOPERATION_FUNCTIONSTATUSERROR = 'FailedOperation.FunctionStatusError' # 当前函数版本状态无法进行此操作,请在版本状态为正常时重试。 FAILEDOPERATION_FUNCTIONVERSIONSTATUSNOTACTIVE = 'FailedOperation.FunctionVersionStatusNotActive' # 获取别名信息失败。 FAILEDOPERATION_GETALIAS = 'FailedOperation.GetAlias' # 获取函数代码地址失败。 FAILEDOPERATION_GETFUNCTIONADDRESS = 'FailedOperation.GetFunctionAddress' # 当前账号或命名空间处于欠费状态,请在可用时重试。 FAILEDOPERATION_INSUFFICIENTBALANCE = 'FailedOperation.InsufficientBalance' # 调用函数失败。 FAILEDOPERATION_INVOKEFUNCTION = 'FailedOperation.InvokeFunction' # 命名空间已存在,请勿重复创建。 FAILEDOPERATION_NAMESPACE = 'FailedOperation.Namespace' # 服务开通失败。 FAILEDOPERATION_OPENSERVICE = 'FailedOperation.OpenService' # 操作冲突。 FAILEDOPERATION_OPERATIONCONFLICT = 'FailedOperation.OperationConflict' # 创建定时预置任务失败。 FAILEDOPERATION_PROVISIONCREATETIMER = 'FailedOperation.ProvisionCreateTimer' # 删除定时预置任务失败。 FAILEDOPERATION_PROVISIONDELETETIMER = 'FailedOperation.ProvisionDeleteTimer' # 当前函数版本已有预置任务处于进行中,请稍后重试。 FAILEDOPERATION_PROVISIONEDINPROGRESS = 'FailedOperation.ProvisionedInProgress' # 发布layer版本失败。 FAILEDOPERATION_PUBLISHLAYERVERSION = 'FailedOperation.PublishLayerVersion' # 当前函数状态无法发布版本,请在状态为正常时发布。 FAILEDOPERATION_PUBLISHVERSION = 'FailedOperation.PublishVersion' # 角色不存在。 FAILEDOPERATION_QCSROLENOTFOUND = 'FailedOperation.QcsRoleNotFound' # 当前函数已有保留并发设置任务处于进行中,请稍后重试。 FAILEDOPERATION_RESERVEDINPROGRESS = 'FailedOperation.ReservedInProgress' # Topic不存在。 FAILEDOPERATION_TOPICNOTEXIST = 'FailedOperation.TopicNotExist' # 用户并发内存配额设置任务处于进行中,请稍后重试。 FAILEDOPERATION_TOTALCONCURRENCYMEMORYINPROGRESS = 'FailedOperation.TotalConcurrencyMemoryInProgress' # 指定的服务未开通,可以提交工单申请开通服务。 FAILEDOPERATION_UNOPENEDSERVICE = 'FailedOperation.UnOpenedService' # 更新别名失败。 FAILEDOPERATION_UPDATEALIAS = 'FailedOperation.UpdateAlias' # 当前函数状态无法更新代码,请在状态为正常时更新。 FAILEDOPERATION_UPDATEFUNCTIONCODE = 'FailedOperation.UpdateFunctionCode' # UpdateFunctionConfiguration操作失败。 FAILEDOPERATION_UPDATEFUNCTIONCONFIGURATION = 'FailedOperation.UpdateFunctionConfiguration' # 内部错误。 INTERNALERROR = 'InternalError' # 创建apigw触发器内部错误。 INTERNALERROR_APIGATEWAY = 'InternalError.ApiGateway' # ckafka接口失败。 INTERNALERROR_CKAFKA = 'InternalError.Ckafka' # 删除cmq触发器失败。 INTERNALERROR_CMQ = 'InternalError.Cmq' # 更新触发器失败。 INTERNALERROR_COS = 'InternalError.Cos' # ES错误。 INTERNALERROR_ES = 'InternalError.ES' # 内部服务异常。 INTERNALERROR_EXCEPTION = 'InternalError.Exception' # 内部服务错误。 INTERNALERROR_GETROLEERROR = 'InternalError.GetRoleError' # 内部系统错误。 INTERNALERROR_SYSTEM = 'InternalError.System' # 内部服务错误。 INTERNALERROR_SYSTEMERROR = 'InternalError.SystemError' # FunctionName取值与规范不符,请修正后再试。可参考:https://tencentcs.com/5jXKFnBW。 INVALIDPARAMETER_FUNCTIONNAME = 'InvalidParameter.FunctionName' # 请求参数不合法。 INVALIDPARAMETER_PAYLOAD = 'InvalidParameter.Payload' # RoutingConfig参数传入错误。 INVALIDPARAMETER_ROUTINGCONFIG = 'InvalidParameter.RoutingConfig' # 参数取值错误。 INVALIDPARAMETERVALUE = 'InvalidParameterValue' # Action取值与规范不符,请修正后再试。可参考:https://tencentcs.com/5jXKFnBW。 INVALIDPARAMETERVALUE_ACTION = 'InvalidParameterValue.Action' # AdditionalVersionWeights参数传入错误。 INVALIDPARAMETERVALUE_ADDITIONALVERSIONWEIGHTS = 'InvalidParameterValue.AdditionalVersionWeights' # 不支持删除默认别名,请修正后重试。 INVALIDPARAMETERVALUE_ALIAS = 'InvalidParameterValue.Alias' # ApiGateway参数错误。 INVALIDPARAMETERVALUE_APIGATEWAY = 'InvalidParameterValue.ApiGateway' # ApmConfig参数传入错误。 INVALIDPARAMETERVALUE_APMCONFIG = 'InvalidParameterValue.ApmConfig' # ApmConfigInstanceId参数传入错误。 INVALIDPARAMETERVALUE_APMCONFIGINSTANCEID = 'InvalidParameterValue.ApmConfigInstanceId' # ApmConfigRegion参数传入错误。 INVALIDPARAMETERVALUE_APMCONFIGREGION = 'InvalidParameterValue.ApmConfigRegion' # Args 参数值有误。 INVALIDPARAMETERVALUE_ARGS = 'InvalidParameterValue.Args' # 函数异步重试配置参数无效。 INVALIDPARAMETERVALUE_ASYNCTRIGGERCONFIG = 'InvalidParameterValue.AsyncTriggerConfig' # Cdn传入错误。 INVALIDPARAMETERVALUE_CDN = 'InvalidParameterValue.Cdn' # cfs配置项重复。 INVALIDPARAMETERVALUE_CFSPARAMETERDUPLICATE = 'InvalidParameterValue.CfsParameterDuplicate' # cfs配置项取值与规范不符。 INVALIDPARAMETERVALUE_CFSPARAMETERERROR = 'InvalidParameterValue.CfsParameterError' # cfs参数格式与规范不符。 INVALIDPARAMETERVALUE_CFSSTRUCTIONERROR = 'InvalidParameterValue.CfsStructionError' # Ckafka传入错误。 INVALIDPARAMETERVALUE_CKAFKA = 'InvalidParameterValue.Ckafka' # 运行函数时的参数传入有误。 INVALIDPARAMETERVALUE_CLIENTCONTEXT = 'InvalidParameterValue.ClientContext' # Cls传入错误。 INVALIDPARAMETERVALUE_CLS = 'InvalidParameterValue.Cls' # 修改Cls配置需要传入Role参数,请修正后重试。 INVALIDPARAMETERVALUE_CLSROLE = 'InvalidParameterValue.ClsRole' # Cmq传入错误。 INVALIDPARAMETERVALUE_CMQ = 'InvalidParameterValue.Cmq' # Code传入错误。 INVALIDPARAMETERVALUE_CODE = 'InvalidParameterValue.Code' # CodeSecret传入错误。 INVALIDPARAMETERVALUE_CODESECRET = 'InvalidParameterValue.CodeSecret' # CodeSource传入错误。 INVALIDPARAMETERVALUE_CODESOURCE = 'InvalidParameterValue.CodeSource' # Command[Entrypoint] 参数值有误。 INVALIDPARAMETERVALUE_COMMAND = 'InvalidParameterValue.Command' # CompatibleRuntimes参数传入错误。 INVALIDPARAMETERVALUE_COMPATIBLERUNTIMES = 'InvalidParameterValue.CompatibleRuntimes' # Content参数传入错误。 INVALIDPARAMETERVALUE_CONTENT = 'InvalidParameterValue.Content' # Cos传入错误。 INVALIDPARAMETERVALUE_COS = 'InvalidParameterValue.Cos' # CosBucketName不符合规范。 INVALIDPARAMETERVALUE_COSBUCKETNAME = 'InvalidParameterValue.CosBucketName' # CosBucketRegion取值与规范不符,请修正后再试。可参考:https://tencentcs.com/5jXKFnBW。 INVALIDPARAMETERVALUE_COSBUCKETREGION = 'InvalidParameterValue.CosBucketRegion' # CosObjectName不符合规范。 INVALIDPARAMETERVALUE_COSOBJECTNAME = 'InvalidParameterValue.CosObjectName' # CustomArgument参数长度超限。 INVALIDPARAMETERVALUE_CUSTOMARGUMENT = 'InvalidParameterValue.CustomArgument' # DateTime传入错误。 INVALIDPARAMETERVALUE_DATETIME = 'InvalidParameterValue.DateTime' # DeadLetterConfig取值与规范不符,请修正后再试。可参考:https://tencentcs.com/5jXKFnBW。 INVALIDPARAMETERVALUE_DEADLETTERCONFIG = 'InvalidParameterValue.DeadLetterConfig' # 默认Namespace无法创建。 INVALIDPARAMETERVALUE_DEFAULTNAMESPACE = 'InvalidParameterValue.DefaultNamespace' # Description传入错误。 INVALIDPARAMETERVALUE_DESCRIPTION = 'InvalidParameterValue.Description' # 环境变量DNS[OS_NAMESERVER]配置有误。 INVALIDPARAMETERVALUE_DNSINFO = 'InvalidParameterValue.DnsInfo' # EipConfig参数错误。 INVALIDPARAMETERVALUE_EIPCONFIG = 'InvalidParameterValue.EipConfig' # Enable取值与规范不符,请修正后再试。可参考:https://tencentcs.com/5jXKFnBW。 INVALIDPARAMETERVALUE_ENABLE = 'InvalidParameterValue.Enable' # Environment传入错误。 INVALIDPARAMETERVALUE_ENVIRONMENT = 'InvalidParameterValue.Environment' # 环境变量大小超限,请保持在 4KB 以内。 INVALIDPARAMETERVALUE_ENVIRONMENTEXCEEDEDLIMIT = 'InvalidParameterValue.EnvironmentExceededLimit' # 不支持修改函数系统环境变量和运行环境变量。 INVALIDPARAMETERVALUE_ENVIRONMENTSYSTEMPROTECT = 'InvalidParameterValue.EnvironmentSystemProtect' # Filters参数错误。 INVALIDPARAMETERVALUE_FILTERS = 'InvalidParameterValue.Filters' # Function取值与规范不符,请修正后再试。可参考:https://tencentcs.com/5jXKFnBW。 INVALIDPARAMETERVALUE_FUNCTION = 'InvalidParameterValue.Function' # 函数不存在。 INVALIDPARAMETERVALUE_FUNCTIONNAME = 'InvalidParameterValue.FunctionName' # GitBranch不符合规范。 INVALIDPARAMETERVALUE_GITBRANCH = 'InvalidParameterValue.GitBranch' # GitCommitId取值与规范不符,请修正后再试。可参考:https://tencentcs.com/5jXKFnBW。 INVALIDPARAMETERVALUE_GITCOMMITID = 'InvalidParameterValue.GitCommitId' # GitDirectory不符合规范。 INVALIDPARAMETERVALUE_GITDIRECTORY = 'InvalidParameterValue.GitDirectory' # GitPassword不符合规范。 INVALIDPARAMETERVALUE_GITPASSWORD = 'InvalidParameterValue.GitPassword' # GitUrl不符合规范。 INVALIDPARAMETERVALUE_GITURL = 'InvalidParameterValue.GitUrl' # GitUserName不符合规范。 INVALIDPARAMETERVALUE_GITUSERNAME = 'InvalidParameterValue.GitUserName' # Handler传入错误。 INVALIDPARAMETERVALUE_HANDLER = 'InvalidParameterValue.Handler' # IdleTimeOut参数传入错误。 INVALIDPARAMETERVALUE_IDLETIMEOUT = 'InvalidParameterValue.IdleTimeOut' # imageUri 传入有误。 INVALIDPARAMETERVALUE_IMAGEURI = 'InvalidParameterValue.ImageUri' # InlineZipFile非法。 INVALIDPARAMETERVALUE_INLINEZIPFILE = 'InvalidParameterValue.InlineZipFile' # InvokeType取值与规范不符,请修正后再试。 INVALIDPARAMETERVALUE_INVOKETYPE = 'InvalidParameterValue.InvokeType' # L5Enable取值与规范不符,请修正后再试。 INVALIDPARAMETERVALUE_L5ENABLE = 'InvalidParameterValue.L5Enable' # LayerName参数传入错误。 INVALIDPARAMETERVALUE_LAYERNAME = 'InvalidParameterValue.LayerName' # Layers参数传入错误。 INVALIDPARAMETERVALUE_LAYERS = 'InvalidParameterValue.Layers' # Limit传入错误。 INVALIDPARAMETERVALUE_LIMIT = 'InvalidParameterValue.Limit' # 参数超出长度限制。 INVALIDPARAMETERVALUE_LIMITEXCEEDED = 'InvalidParameterValue.LimitExceeded' # Memory取值与规范不符,请修正后再试。可参考:https://tencentcs.com/5jXKFnBW。 INVALIDPARAMETERVALUE_MEMORY = 'InvalidParameterValue.Memory' # MemorySize错误。 INVALIDPARAMETERVALUE_MEMORYSIZE = 'InvalidParameterValue.MemorySize' # MinCapacity 参数传入错误。 INVALIDPARAMETERVALUE_MINCAPACITY = 'InvalidParameterValue.MinCapacity' # Name参数传入错误。 INVALIDPARAMETERVALUE_NAME = 'InvalidParameterValue.Name' # Namespace参数传入错误。 INVALIDPARAMETERVALUE_NAMESPACE = 'InvalidParameterValue.Namespace' # 规则不正确,Namespace为英文字母、数字、-_ 符号组成,长度30。 INVALIDPARAMETERVALUE_NAMESPACEINVALID = 'InvalidParameterValue.NamespaceInvalid' # NodeSpec 参数传入错误。 INVALIDPARAMETERVALUE_NODESPEC = 'InvalidParameterValue.NodeSpec' # NodeType 参数传入错误。 INVALIDPARAMETERVALUE_NODETYPE = 'InvalidParameterValue.NodeType' # 偏移量不合法。 INVALIDPARAMETERVALUE_OFFSET = 'InvalidParameterValue.Offset' # Order传入错误。 INVALIDPARAMETERVALUE_ORDER = 'InvalidParameterValue.Order' # OrderBy取值与规范不符,请修正后再试。可参考:https://tencentcs.com/5jXKFnBW。 INVALIDPARAMETERVALUE_ORDERBY = 'InvalidParameterValue.OrderBy' # 入参不是标准的json。 INVALIDPARAMETERVALUE_PARAM = 'InvalidParameterValue.Param' # ProtocolType参数传入错误。 INVALIDPARAMETERVALUE_PROTOCOLTYPE = 'InvalidParameterValue.ProtocolType' # 定时预置的cron配置重复。 INVALIDPARAMETERVALUE_PROVISIONTRIGGERCRONCONFIGDUPLICATE = 'InvalidParameterValue.ProvisionTriggerCronConfigDuplicate' # TriggerName参数传入错误。 INVALIDPARAMETERVALUE_PROVISIONTRIGGERNAME = 'InvalidParameterValue.ProvisionTriggerName' # TriggerName重复。 INVALIDPARAMETERVALUE_PROVISIONTRIGGERNAMEDUPLICATE = 'InvalidParameterValue.ProvisionTriggerNameDuplicate' # ProvisionType 参数传入错误。 INVALIDPARAMETERVALUE_PROVISIONTYPE = 'InvalidParameterValue.ProvisionType' # PublicNetConfig参数错误。 INVALIDPARAMETERVALUE_PUBLICNETCONFIG = 'InvalidParameterValue.PublicNetConfig' # 不支持的函数版本。 INVALIDPARAMETERVALUE_QUALIFIER = 'InvalidParameterValue.Qualifier' # 企业版镜像实例ID[RegistryId]传值错误。 INVALIDPARAMETERVALUE_REGISTRYID = 'InvalidParameterValue.RegistryId' # RetCode不合法。 INVALIDPARAMETERVALUE_RETCODE = 'InvalidParameterValue.RetCode' # RoutingConfig取值与规范不符,请修正后再试。可参考:https://tencentcs.com/5jXKFnBW。 INVALIDPARAMETERVALUE_ROUTINGCONFIG = 'InvalidParameterValue.RoutingConfig' # Runtime传入错误。 INVALIDPARAMETERVALUE_RUNTIME = 'InvalidParameterValue.Runtime' # searchkey 不是 Keyword,Tag 或者 Runtime。 INVALIDPARAMETERVALUE_SEARCHKEY = 'InvalidParameterValue.SearchKey' # SecretInfo错误。 INVALIDPARAMETERVALUE_SECRETINFO = 'InvalidParameterValue.SecretInfo' # ServiceName命名不规范。 INVALIDPARAMETERVALUE_SERVICENAME = 'InvalidParameterValue.ServiceName' # Stamp取值与规范不符,请修正后再试。 INVALIDPARAMETERVALUE_STAMP = 'InvalidParameterValue.Stamp' # 起始时间传入错误。 INVALIDPARAMETERVALUE_STARTTIME = 'InvalidParameterValue.StartTime' # 需要同时指定开始日期与结束日期。 INVALIDPARAMETERVALUE_STARTTIMEORENDTIME = 'InvalidParameterValue.StartTimeOrEndTime' # Status取值与规范不符,请修正后再试。 INVALIDPARAMETERVALUE_STATUS = 'InvalidParameterValue.Status' # 系统环境变量错误。 INVALIDPARAMETERVALUE_SYSTEMENVIRONMENT = 'InvalidParameterValue.SystemEnvironment' # 非法的TempCosObjectName。 INVALIDPARAMETERVALUE_TEMPCOSOBJECTNAME = 'InvalidParameterValue.TempCosObjectName' # TraceEnable取值与规范不符,请修正后再试。 INVALIDPARAMETERVALUE_TRACEENABLE = 'InvalidParameterValue.TraceEnable' # TrackingTarget 参数输入错误。 INVALIDPARAMETERVALUE_TRACKINGTARGET = 'InvalidParameterValue.TrackingTarget' # TriggerCronConfig参数传入错误。 INVALIDPARAMETERVALUE_TRIGGERCRONCONFIG = 'InvalidParameterValue.TriggerCronConfig' # TriggerCronConfig参数定时触发间隔小于指定值。 INVALIDPARAMETERVALUE_TRIGGERCRONCONFIGTIMEINTERVAL = 'InvalidParameterValue.TriggerCronConfigTimeInterval' # TriggerDesc传入参数错误。 INVALIDPARAMETERVALUE_TRIGGERDESC = 'InvalidParameterValue.TriggerDesc' # TriggerName传入错误。 INVALIDPARAMETERVALUE_TRIGGERNAME = 'InvalidParameterValue.TriggerName' # TriggerProvisionedConcurrencyNum参数传入错误。 INVALIDPARAMETERVALUE_TRIGGERPROVISIONEDCONCURRENCYNUM = 'InvalidParameterValue.TriggerProvisionedConcurrencyNum' # Type传入错误。 INVALIDPARAMETERVALUE_TYPE = 'InvalidParameterValue.Type' # 开启cfs配置的同时必须开启vpc。 INVALIDPARAMETERVALUE_VPCNOTSETWHENOPENCFS = 'InvalidParameterValue.VpcNotSetWhenOpenCfs' # WebSocketsParams参数传入错误。 INVALIDPARAMETERVALUE_WEBSOCKETSPARAMS = 'InvalidParameterValue.WebSocketsParams' # 检测到不是标准的zip文件,请重新压缩后再试。 INVALIDPARAMETERVALUE_ZIPFILE = 'InvalidParameterValue.ZipFile' # 压缩文件base64解码失败: `Incorrect padding`,请修正后再试。 INVALIDPARAMETERVALUE_ZIPFILEBASE64BINASCIIERROR = 'InvalidParameterValue.ZipFileBase64BinasciiError' # 别名个数超过最大限制。 LIMITEXCEEDED_ALIAS = 'LimitExceeded.Alias' # Cdn使用超过最大限制。 LIMITEXCEEDED_CDN = 'LimitExceeded.Cdn' # eip资源超限。 LIMITEXCEEDED_EIP = 'LimitExceeded.Eip' # 函数数量超出最大限制 ,可通过[提交工单](https://cloud.tencent.com/act/event/Online_service?from=scf%7Cindex)申请提升限制。 LIMITEXCEEDED_FUNCTION = 'LimitExceeded.Function' # 同一个主题下的函数超过最大限制。 LIMITEXCEEDED_FUNCTIONONTOPIC = 'LimitExceeded.FunctionOnTopic' # FunctionProvisionedConcurrencyMemory数量达到限制,可提交工单申请提升限制:https://tencentcs.com/7Fixwt63。 LIMITEXCEEDED_FUNCTIONPROVISIONEDCONCURRENCYMEMORY = 'LimitExceeded.FunctionProvisionedConcurrencyMemory' # 函数保留并发内存超限。 LIMITEXCEEDED_FUNCTIONRESERVEDCONCURRENCYMEMORY = 'LimitExceeded.FunctionReservedConcurrencyMemory' # FunctionTotalProvisionedConcurrencyMemory达到限制,可提交工单申请提升限制:https://tencentcs.com/7Fixwt63。 LIMITEXCEEDED_FUNCTIONTOTALPROVISIONEDCONCURRENCYMEMORY = 'LimitExceeded.FunctionTotalProvisionedConcurrencyMemory' # 函数预置并发总数达到限制。 LIMITEXCEEDED_FUNCTIONTOTALPROVISIONEDCONCURRENCYNUM = 'LimitExceeded.FunctionTotalProvisionedConcurrencyNum' # InitTimeout达到限制,可提交工单申请提升限制:https://tencentcs.com/7Fixwt63。 LIMITEXCEEDED_INITTIMEOUT = 'LimitExceeded.InitTimeout' # layer版本数量超出最大限制。 LIMITEXCEEDED_LAYERVERSIONS = 'LimitExceeded.LayerVersions' # layer数量超出最大限制。 LIMITEXCEEDED_LAYERS = 'LimitExceeded.Layers' # 内存超出最大限制。 LIMITEXCEEDED_MEMORY = 'LimitExceeded.Memory' # 函数异步重试配置消息保留时间超过限制。 LIMITEXCEEDED_MSGTTL = 'LimitExceeded.MsgTTL' # 命名空间数量超过最大限制,可通过[提交工单](https://cloud.tencent.com/act/event/Online_service?from=scf%7Cindex)申请提升限制。 LIMITEXCEEDED_NAMESPACE = 'LimitExceeded.Namespace' # Offset超出限制。 LIMITEXCEEDED_OFFSET = 'LimitExceeded.Offset' # 定时预置数量超过最大限制。 LIMITEXCEEDED_PROVISIONTRIGGERACTION = 'LimitExceeded.ProvisionTriggerAction' # 定时触发间隔小于最大限制。 LIMITEXCEEDED_PROVISIONTRIGGERINTERVAL = 'LimitExceeded.ProvisionTriggerInterval' # 配额超限。 LIMITEXCEEDED_QUOTA = 'LimitExceeded.Quota' # 函数异步重试配置异步重试次数超过限制。 LIMITEXCEEDED_RETRYNUM = 'LimitExceeded.RetryNum' # Timeout超出最大限制。 LIMITEXCEEDED_TIMEOUT = 'LimitExceeded.Timeout' # 用户并发内存配额超限。 LIMITEXCEEDED_TOTALCONCURRENCYMEMORY = 'LimitExceeded.TotalConcurrencyMemory' # 触发器数量超出最大限制,可通过[提交工单](https://cloud.tencent.com/act/event/Online_service?from=scf%7Cindex)申请提升限制。 LIMITEXCEEDED_TRIGGER = 'LimitExceeded.Trigger' # UserTotalConcurrencyMemory达到限制,可提交工单申请提升限制:https://tencentcs.com/7Fixwt63。 LIMITEXCEEDED_USERTOTALCONCURRENCYMEMORY = 'LimitExceeded.UserTotalConcurrencyMemory' # 缺少参数错误。 MISSINGPARAMETER = 'MissingParameter' # Code没有传入。 MISSINGPARAMETER_CODE = 'MissingParameter.Code' # 缺失 Runtime 字段。 MISSINGPARAMETER_RUNTIME = 'MissingParameter.Runtime' # 资源被占用。 RESOURCEINUSE = 'ResourceInUse' # Alias已被占用。 RESOURCEINUSE_ALIAS = 'ResourceInUse.Alias' # Cdn已被占用。 RESOURCEINUSE_CDN = 'ResourceInUse.Cdn' # Cmq已被占用。 RESOURCEINUSE_CMQ = 'ResourceInUse.Cmq' # Cos已被占用。 RESOURCEINUSE_COS = 'ResourceInUse.Cos' # 函数已存在。 RESOURCEINUSE_FUNCTION = 'ResourceInUse.Function' # FunctionName已存在。 RESOURCEINUSE_FUNCTIONNAME = 'ResourceInUse.FunctionName' # Layer版本正在使用中。 RESOURCEINUSE_LAYERVERSION = 'ResourceInUse.LayerVersion' # Namespace已存在。 RESOURCEINUSE_NAMESPACE = 'ResourceInUse.Namespace' # TriggerName已存在。 RESOURCEINUSE_TRIGGER = 'ResourceInUse.Trigger' # TriggerName已存在。 RESOURCEINUSE_TRIGGERNAME = 'ResourceInUse.TriggerName' # COS资源不足。 RESOURCEINSUFFICIENT_COS = 'ResourceInsufficient.COS' # 资源不存在。 RESOURCENOTFOUND = 'ResourceNotFound' # 别名不存在。 RESOURCENOTFOUND_ALIAS = 'ResourceNotFound.Alias' # 未找到指定的AsyncEvent,请创建后再试。 RESOURCENOTFOUND_ASYNCEVENT = 'ResourceNotFound.AsyncEvent' # Cdn不存在。 RESOURCENOTFOUND_CDN = 'ResourceNotFound.Cdn' # 指定的cfs下未找到您所指定的挂载点。 RESOURCENOTFOUND_CFSMOUNTINSNOTMATCH = 'ResourceNotFound.CfsMountInsNotMatch' # 检测cfs状态为不可用。 RESOURCENOTFOUND_CFSSTATUSERROR = 'ResourceNotFound.CfsStatusError' # cfs与云函数所处vpc不一致。 RESOURCENOTFOUND_CFSVPCNOTMATCH = 'ResourceNotFound.CfsVpcNotMatch' # Ckafka不存在。 RESOURCENOTFOUND_CKAFKA = 'ResourceNotFound.Ckafka' # Cmq不存在。 RESOURCENOTFOUND_CMQ = 'ResourceNotFound.Cmq' # Cos不存在。 RESOURCENOTFOUND_COS = 'ResourceNotFound.Cos' # 不存在的Demo。 RESOURCENOTFOUND_DEMO = 'ResourceNotFound.Demo' # 函数不存在。 RESOURCENOTFOUND_FUNCTION = 'ResourceNotFound.Function' # 函数不存在。 RESOURCENOTFOUND_FUNCTIONNAME = 'ResourceNotFound.FunctionName' # 函数版本不存在。 RESOURCENOTFOUND_FUNCTIONVERSION = 'ResourceNotFound.FunctionVersion' # 获取cfs挂载点信息错误。 RESOURCENOTFOUND_GETCFSMOUNTINSERROR = 'ResourceNotFound.GetCfsMountInsError' # 获取cfs信息错误。 RESOURCENOTFOUND_GETCFSNOTMATCH = 'ResourceNotFound.GetCfsNotMatch' # 未找到指定的ImageConfig,请创建后再试。 RESOURCENOTFOUND_IMAGECONFIG = 'ResourceNotFound.ImageConfig' # layer不存在。 RESOURCENOTFOUND_LAYER = 'ResourceNotFound.Layer' # Layer版本不存在。 RESOURCENOTFOUND_LAYERVERSION = 'ResourceNotFound.LayerVersion' # Namespace不存在。 RESOURCENOTFOUND_NAMESPACE = 'ResourceNotFound.Namespace' # 版本不存在。 RESOURCENOTFOUND_QUALIFIER = 'ResourceNotFound.Qualifier' # 角色不存在。 RESOURCENOTFOUND_ROLE = 'ResourceNotFound.Role' # Role不存在。 RESOURCENOTFOUND_ROLECHECK = 'ResourceNotFound.RoleCheck' # Timer不存在。 RESOURCENOTFOUND_TIMER = 'ResourceNotFound.Timer' # 并发内存配额资源未找到。 RESOURCENOTFOUND_TOTALCONCURRENCYMEMORY = 'ResourceNotFound.TotalConcurrencyMemory' # 触发器不存在。 RESOURCENOTFOUND_TRIGGER = 'ResourceNotFound.Trigger' # 版本不存在。 RESOURCENOTFOUND_VERSION = 'ResourceNotFound.Version' # VPC或子网不存在。 RESOURCENOTFOUND_VPC = 'ResourceNotFound.Vpc' # 余额不足,请先充值。 RESOURCEUNAVAILABLE_INSUFFICIENTBALANCE = 'ResourceUnavailable.InsufficientBalance' # Namespace不可用。 RESOURCEUNAVAILABLE_NAMESPACE = 'ResourceUnavailable.Namespace' # 未授权操作。 UNAUTHORIZEDOPERATION = 'UnauthorizedOperation' # CAM鉴权失败。 UNAUTHORIZEDOPERATION_CAM = 'UnauthorizedOperation.CAM' # 无访问代码权限。 UNAUTHORIZEDOPERATION_CODESECRET = 'UnauthorizedOperation.CodeSecret' # 没有权限。 UNAUTHORIZEDOPERATION_CREATETRIGGER = 'UnauthorizedOperation.CreateTrigger' # 没有权限的操作。 UNAUTHORIZEDOPERATION_DELETEFUNCTION = 'UnauthorizedOperation.DeleteFunction' # 没有权限。 UNAUTHORIZEDOPERATION_DELETETRIGGER = 'UnauthorizedOperation.DeleteTrigger' # 不是从控制台调用的该接口。 UNAUTHORIZEDOPERATION_NOTMC = 'UnauthorizedOperation.NotMC' # Region错误。 UNAUTHORIZEDOPERATION_REGION = 'UnauthorizedOperation.Region' # 没有权限访问您的Cos资源。 UNAUTHORIZEDOPERATION_ROLE = 'UnauthorizedOperation.Role' # TempCos的Appid和请求账户的APPID不一致。 UNAUTHORIZEDOPERATION_TEMPCOSAPPID = 'UnauthorizedOperation.TempCosAppid' # 无法进行此操作。 UNAUTHORIZEDOPERATION_UPDATEFUNCTIONCODE = 'UnauthorizedOperation.UpdateFunctionCode' # 操作不支持。 UNSUPPORTEDOPERATION = 'UnsupportedOperation' # 资源还有别名绑定,不支持当前操作,请解绑别名后重试。 UNSUPPORTEDOPERATION_ALIASBIND = 'UnsupportedOperation.AliasBind' # 指定的配置AsyncRunEnable暂不支持,请修正后再试。 UNSUPPORTEDOPERATION_ASYNCRUNENABLE = 'UnsupportedOperation.AsyncRunEnable' # Cdn不支持。 UNSUPPORTEDOPERATION_CDN = 'UnsupportedOperation.Cdn' # Cos操作不支持。 UNSUPPORTEDOPERATION_COS = 'UnsupportedOperation.Cos' # 指定的配置EipFixed暂不支持。 UNSUPPORTEDOPERATION_EIPFIXED = 'UnsupportedOperation.EipFixed' # 不支持此地域。 UNSUPPORTEDOPERATION_REGION = 'UnsupportedOperation.Region' # Trigger操作不支持。 UNSUPPORTEDOPERATION_TRIGGER = 'UnsupportedOperation.Trigger' # 指定的配置暂不支持,请修正后再试。 UNSUPPORTEDOPERATION_UPDATEFUNCTIONEVENTINVOKECONFIG = 'UnsupportedOperation.UpdateFunctionEventInvokeConfig' # 指定的配置VpcConfig暂不支持。 UNSUPPORTEDOPERATION_VPCCONFIG = 'UnsupportedOperation.VpcConfig'
tzpBingo/github-trending
codespace/python/tencentcloud/scf/v20180416/errorcodes.py
Python
mit
27,390
[ 30522, 1001, 1011, 1008, 1011, 16861, 1024, 21183, 2546, 2620, 1011, 1008, 1011, 1001, 9385, 1006, 1039, 1007, 2418, 1011, 25682, 16215, 2140, 22441, 2683, 3132, 1010, 1037, 2702, 13013, 2194, 1012, 2035, 2916, 9235, 1012, 1001, 1001, 7000,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php use wenyuan\ueditor\Ueditor; use yii\helpers\Url; use frontend\models\Member; //用户模型 use frontend\models\UserThirdPartyLogin; //用户第三方登录模型 $session = Yii::$app->session; $session->isActive?'':$session->open(); $user = $session->get('user'); $tplogin = isset($user['third_party_login']) ? $user['third_party_login'] : false; if ($user['uid'] == UserThirdPartyLogin::NOT_BOUND_USERID) { $user['avatar'] = $tplogin['profile']['avatar']; } elseif (!empty($user)) { $member_model = new Member(); $user = $member_model->getByUid($user['uid']); // var_dump($user); } $this->registerCssFile(Yii::$app->params['idaiyan-static']."static/modules/home/css/uc-prodadd-step2.css"); ?> <!-- <link rel="stylesheet" href="http://static.idaiyan.cn/website/static/modules/home/css/home.css"> <link rel="stylesheet" href="http://static.idaiyan.cn/website/static/modules/home/css/uc.css"> <link rel="stylesheet" href="http://static.idaiyan.cn/website/static/modules/home/css/uc-prodadd-step2.css"> --> <div class="respons_wp uc_body cf"> <form action="<?= Url::toRoute(['product/update']); ?>" id="editform" method="post" enctype="multipart/form-data"> <div class="main_wrap cf"> <!--产品信息完善表单--> <div class="prodeditform_wrap fl"> <div class="prodedit_wrap"> <div class="listtitle cf"> <h2 class="fl"> <!-- 修改的话是 编辑我的代言 --> 完善产品信息 <span class="subtitle">Releases new speaking</span> </h2> </div> <div class="editform_wrap"> <div class="formitem name"> <label for="name" class="formlabel">产品名称:</label> <div class="formobject"> <input type="text" name="extra[name]" id="name" value="<?php echo isset($product['name']) ? $product['name'] : '';?>" datatype="*2-32" nullmsg="产品名称不可以为空哦!" errormsg="产品名称至少2个字符,最多32个字符!"/> <br/> </div> <div class="price"> <label for="name" class="label-price">单价:</label> <input type="hidden" name="formhash" value="<?php echo $formhash ?>" /> <div class="formobject"> <div class="money-box"> <div class="left">¥</div> <input class="right" type="text" name="extra[price]" id="originprice" maxlength="8" value="<?php echo isset($product['price']) ? $product['price'] : '';?>" datatype="/^([1-9]\d{0,7}[\s,]*)+\.?(\d{0,2})?$/" nullmsg="产品价格不能为空哦!" errormsg="请填写正确的价格!" /> </div> <br/> </div> </div> </div> <div class="formitem intro"> <label for="intro" class="formlabel">产品简介:</label> <div class="formobject"> <textarea name="extra[summary]" id="intro" cols="30" rows="10" datatype="*" nullmsg="产品简介不能为空!" ><?php echo isset($product['extra']['summary']) ? $product['extra']['summary'] : '';?></textarea> <br/> </div> </div> <div class="formitem cover"> <label class="formlabel">封面图片:</label> <div class="formobject" data-type="1"> <div class="imgselect"> <div class="filewrap"> <input type="file" name="album" id="cover"> </div> <div class="imgpreview_wrap"> <div class="imgpreview" <?php if(isset($product['album']) && !empty($product['album'])) { ?>style="background-image:url(<?=$product['album'].".jpg";?>);display:block;"<?php } ?>></div> </div> <div class="tip"> <p>支持 JPG , JPEG , PNG格式的图片</p> <p>尺寸为 <b>800x500</b> 。大小不超过 <b>1M</b> 。</p> </div> </div> </div> </div> <?php if(isset($product['image']) && !empty($product['image'])) { foreach ($product['image'] as $key => $value) { $__valname = 'bigbanner'.$value['pos_id']; $$__valname = $value['url']; } } ?> <div class="formitem bigbanner" data-type="2"> <label class="formlabel">通栏图片:</label> <div class="formobject" > <div class="imgselect" data-target="bigbanner"> <div class="imgpreview_wrap cf"> <div class="imgpreview"> <div class="fl"></div> <div class="fr"></div> </div> </div> <div class="tip"> 支持 JPG , JPEG , PNG格式的图片 尺寸为 <b>2560x450</b> 。大小不超过 <b>2M</b> 。 </div> </div> <div class="cf"> <div class="addimg addimg1<?php if(isset($bigbanner1)) { ?> hasimg<?php } ?>" postid="1" data-target="bigbanner"> <div class="add_wrap"> <div class="edit"></div> <div class="del"></div> </div> <div class="imgpreview_wrap"> <div class="imgpreview" <?php if(isset($bigbanner1)) { ?>style="background-image:url(<?=$bigbanner1.".jpg";?>);display:block;"<?php } ?>> <div class="filewrap"> <input type="file" name="bigbanner1" id="bigbanner"> </div> </div> </div> <div class="tip">可以再添加一张</div> </div> <div class="addimg addimg2<?php if(isset($bigbanner2)) { ?> hasimg<?php } ?>" postid="2" data-target="bigbanner2"> <div class="add_wrap"> <div class="edit"></div> <div class="del"></div> </div> <div class="imgpreview_wrap"> <div class="imgpreview" <?php if(isset($bigbanner2)) { ?>style="background-image:url(<?=$bigbanner2.".jpg";?>);display:block;"<?php } ?>> <div class="filewrap"> <input type="file" name="bigbanner2" id="bigbanner2"> </div> </div> </div> <div class="tip">可以再添加一张</div> </div> <div class="addimg addimg3<?php if(isset($bigbanner3)) { ?> hasimg<?php } ?>" postid="3" data-target="bigbanner3"> <div class="add_wrap"> <div class="edit"></div> <div class="del"></div> </div> <div class="imgpreview_wrap"> <div class="imgpreview" <?php if(isset($bigbanner3)) { ?>style="background-image:url(<?=$bigbanner3.".jpg";?>);display:block;"<?php } ?>> <div class="filewrap"> <input type="file" name="bigbanner3" id="bigbanner3"> </div> </div> </div> <div class="tip">可以再添加一张</div> </div> </div> </div> </div> <div class="formitem video"> <label for="video" class="formlabel">宣传视频:</label> <div class="formobject"> <input class="gray" type="text" name="extra[video_url]" value="<?php echo isset($product['extra']['video_url']) ? $product['extra']['video_url'] : '';?>" placeholder="可选, 输入视频地址 ( 支持: 优酷, 土豆 )" datatype="url" nullmsg="地址不可以为空哦!" errormsg="请填写正确的地址类型哦!" ignore="ignore" > <br/> </div> </div> <div class="formitem detail"> <label for="detail" class="formlabel">详细描述:</label> <div class="formobject"> <?php echo Ueditor::widget(['id' => 'extra[detail]','ucontent'=>'']);?> <br/> </div> </div> </div> <div class="formsubmit"> <input type="hidden" name="extra[id]" id= 'product_id' value="<?php echo $id;?>" /> <button type="submit" class="submitbtn" id="submit-btn">发布</button> <button type="submit" class="savebtn">保存</button> </div> </div> </div> <div class="article_right prodedit_preview"> <div class="pinned"> <div class="right_b"> <button class="previewbtn">预览</button> </div> <div class="right_t"> <div class="top1"> <div class="cover_preview"></div> <div class="cover_add"></div> </div> <div class="middle"> <p>您填写的产品名称将出现在这里</p> <span class="small-text">您填写的产品简介将出现在这里</span> <div class="prodnums cf"> <div class="icon icon-money fl"> <b>9383</b> </div> <div class="icon icon-topic fl"> <b>9383</b> </div> <div class="icon icon-attention fl"> <b> 938万</b> </div> <div class="icon icon-love fl"> <b>938万</b> </div> </div> </div> <div class="prodrate"> </div> <div class="bot"> <div class="avatar_wrap"> <img class="avatar" src="<?php echo isset($user['avatar']) && $user['avatar'] ? (strpos($user['avatar'], 'http') === 0 ? $user['avatar'] : '/' . $user['avatar']) : Yii::$app->params['idaiyan-static'].'static/modules/home/images/temp/avatar.jpg';?>" alt="我的头像"> <span class="text"><?php echo isset($user['nickname']) && $user['nickname'] ?$user['nickname']:'无名'; ?></span> </div> <span class="add"></span> <span class="email"></span> <div class="add_icon fr"> <div class="inner_div"></div> <div class="inner_div"></div> <div class="inner_div"></div> </div> </div> </div> <div class="right_d"> <div class="top_t"></div> <div class="top1 top2"> <div class="bigbanner_preview"></div> <div class="bigbanner_add"></div> </div> <div class="scal"> <img src="<?php echo Yii::$app->params['idaiyan-static'];?>static/modules/home/images/uc/scals1.png"> </div> </div> </div> </div> </form> </div> </div> <script> var SAVEURL = "<?= Url::toRoute(['product/wesave']); ?>";//保存 var SUBMITURL = "<?= Url::toRoute(['product/update']); ?>"; var PREVIEWURL = "<?= Url::toRoute(['product/preview']); ?>"; </script> <script type="text/javascript" src="<?php echo Yii::$app->params['idaiyan-static'];?>static/modules/home/js/require.js"></script> <script type="text/javascript" data-single="true" src="<?php echo Yii::$app->params['idaiyan-static'];?>pkg/map_fe6f523.js"></script> <script> /*fis async*/ require(['js/modules/app/uc-prodadd-step2']); </script> <link href="<?php echo $url;?>/static/ueditor/css/ueditor.min.css" rel="stylesheet"> <script src="<?php echo $url;?>/static/ueditor/jquery/jquery.js"></script> <script src="<?php echo $url;?>/static/ueditor/js/ueditor.config.js"></script> <script src="<?php echo $url;?>/static/ueditor/js/ueditor.all.min.js"></script> <script type="text/javascript"> jQuery(document).ready(function () { UE.getEditor('extra[detail]', { toolbars: [ ['fullscreen', 'undo', 'redo', 'bold', 'italic', 'underline', 'fontborder', 'backcolor', 'fontsize', 'fontfamily', 'justifyleft', 'justifyright', 'justifycenter', 'justifyjustify', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', 'simpleupload', 'insertimage'] ] }); }); </script>
songhongyu/idaiyan
frontend/views/product/uc_prodadd_step2.php
PHP
apache-2.0
15,175
[ 30522, 1026, 1029, 25718, 2224, 19181, 17236, 1032, 1057, 2098, 15660, 1032, 1057, 2098, 15660, 1025, 2224, 12316, 2072, 1032, 2393, 2545, 1032, 24471, 2140, 1025, 2224, 2392, 10497, 1032, 4275, 1032, 2266, 1025, 1013, 1013, 100, 100, 100, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import operator from pyspark import since, keyword_only from pyspark.ml import Estimator, Model from pyspark.ml.param.shared import * from pyspark.ml.regression import DecisionTreeModel, DecisionTreeRegressionModel, \ RandomForestParams, TreeEnsembleModel, TreeEnsembleParams from pyspark.ml.util import * from pyspark.ml.wrapper import JavaEstimator, JavaModel, JavaParams from pyspark.ml.wrapper import JavaWrapper from pyspark.ml.common import inherit_doc from pyspark.sql import DataFrame from pyspark.sql.functions import udf, when from pyspark.sql.types import ArrayType, DoubleType from pyspark.storagelevel import StorageLevel __all__ = ['LinearSVC', 'LinearSVCModel', 'LogisticRegression', 'LogisticRegressionModel', 'LogisticRegressionSummary', 'LogisticRegressionTrainingSummary', 'BinaryLogisticRegressionSummary', 'BinaryLogisticRegressionTrainingSummary', 'DecisionTreeClassifier', 'DecisionTreeClassificationModel', 'GBTClassifier', 'GBTClassificationModel', 'RandomForestClassifier', 'RandomForestClassificationModel', 'NaiveBayes', 'NaiveBayesModel', 'MultilayerPerceptronClassifier', 'MultilayerPerceptronClassificationModel', 'OneVsRest', 'OneVsRestModel'] @inherit_doc class JavaClassificationModel(JavaPredictionModel): """ (Private) Java Model produced by a ``Classifier``. Classes are indexed {0, 1, ..., numClasses - 1}. To be mixed in with class:`pyspark.ml.JavaModel` """ @property @since("2.1.0") def numClasses(self): """ Number of classes (values which the label can take). """ return self._call_java("numClasses") @inherit_doc class LinearSVC(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol, HasMaxIter, HasRegParam, HasTol, HasRawPredictionCol, HasFitIntercept, HasStandardization, HasWeightCol, HasAggregationDepth, JavaMLWritable, JavaMLReadable): """ .. note:: Experimental `Linear SVM Classifier <https://en.wikipedia.org/wiki/Support_vector_machine#Linear_SVM>`_ This binary classifier optimizes the Hinge Loss using the OWLQN optimizer. Only supports L2 regularization currently. >>> from pyspark.sql import Row >>> from pyspark.ml.linalg import Vectors >>> df = sc.parallelize([ ... Row(label=1.0, features=Vectors.dense(1.0, 1.0, 1.0)), ... Row(label=0.0, features=Vectors.dense(1.0, 2.0, 3.0))]).toDF() >>> svm = LinearSVC(maxIter=5, regParam=0.01) >>> model = svm.fit(df) >>> model.coefficients DenseVector([0.0, -0.2792, -0.1833]) >>> model.intercept 1.0206118982229047 >>> model.numClasses 2 >>> model.numFeatures 3 >>> test0 = sc.parallelize([Row(features=Vectors.dense(-1.0, -1.0, -1.0))]).toDF() >>> result = model.transform(test0).head() >>> result.prediction 1.0 >>> result.rawPrediction DenseVector([-1.4831, 1.4831]) >>> svm_path = temp_path + "/svm" >>> svm.save(svm_path) >>> svm2 = LinearSVC.load(svm_path) >>> svm2.getMaxIter() 5 >>> model_path = temp_path + "/svm_model" >>> model.save(model_path) >>> model2 = LinearSVCModel.load(model_path) >>> model.coefficients[0] == model2.coefficients[0] True >>> model.intercept == model2.intercept True .. versionadded:: 2.2.0 """ threshold = Param(Params._dummy(), "threshold", "The threshold in binary classification applied to the linear model" " prediction. This threshold can be any real number, where Inf will make" " all predictions 0.0 and -Inf will make all predictions 1.0.", typeConverter=TypeConverters.toFloat) @keyword_only def __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", maxIter=100, regParam=0.0, tol=1e-6, rawPredictionCol="rawPrediction", fitIntercept=True, standardization=True, threshold=0.0, weightCol=None, aggregationDepth=2): """ __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", \ maxIter=100, regParam=0.0, tol=1e-6, rawPredictionCol="rawPrediction", \ fitIntercept=True, standardization=True, threshold=0.0, weightCol=None, \ aggregationDepth=2): """ super(LinearSVC, self).__init__() self._java_obj = self._new_java_obj( "org.apache.spark.ml.classification.LinearSVC", self.uid) self._setDefault(maxIter=100, regParam=0.0, tol=1e-6, fitIntercept=True, standardization=True, threshold=0.0, aggregationDepth=2) kwargs = self._input_kwargs self.setParams(**kwargs) @keyword_only @since("2.2.0") def setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", maxIter=100, regParam=0.0, tol=1e-6, rawPredictionCol="rawPrediction", fitIntercept=True, standardization=True, threshold=0.0, weightCol=None, aggregationDepth=2): """ setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", \ maxIter=100, regParam=0.0, tol=1e-6, rawPredictionCol="rawPrediction", \ fitIntercept=True, standardization=True, threshold=0.0, weightCol=None, \ aggregationDepth=2): Sets params for Linear SVM Classifier. """ kwargs = self._input_kwargs return self._set(**kwargs) def _create_model(self, java_model): return LinearSVCModel(java_model) def setThreshold(self, value): """ Sets the value of :py:attr:`threshold`. """ return self._set(threshold=value) def getThreshold(self): """ Gets the value of threshold or its default value. """ return self.getOrDefault(self.threshold) class LinearSVCModel(JavaModel, JavaClassificationModel, JavaMLWritable, JavaMLReadable): """ .. note:: Experimental Model fitted by LinearSVC. .. versionadded:: 2.2.0 """ @property @since("2.2.0") def coefficients(self): """ Model coefficients of Linear SVM Classifier. """ return self._call_java("coefficients") @property @since("2.2.0") def intercept(self): """ Model intercept of Linear SVM Classifier. """ return self._call_java("intercept") @inherit_doc class LogisticRegression(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol, HasMaxIter, HasRegParam, HasTol, HasProbabilityCol, HasRawPredictionCol, HasElasticNetParam, HasFitIntercept, HasStandardization, HasThresholds, HasWeightCol, HasAggregationDepth, JavaMLWritable, JavaMLReadable): """ Logistic regression. This class supports multinomial logistic (softmax) and binomial logistic regression. >>> from pyspark.sql import Row >>> from pyspark.ml.linalg import Vectors >>> bdf = sc.parallelize([ ... Row(label=1.0, weight=1.0, features=Vectors.dense(0.0, 5.0)), ... Row(label=0.0, weight=2.0, features=Vectors.dense(1.0, 2.0)), ... Row(label=1.0, weight=3.0, features=Vectors.dense(2.0, 1.0)), ... Row(label=0.0, weight=4.0, features=Vectors.dense(3.0, 3.0))]).toDF() >>> blor = LogisticRegression(regParam=0.01, weightCol="weight") >>> blorModel = blor.fit(bdf) >>> blorModel.coefficients DenseVector([-1.080..., -0.646...]) >>> blorModel.intercept 3.112... >>> data_path = "data/mllib/sample_multiclass_classification_data.txt" >>> mdf = spark.read.format("libsvm").load(data_path) >>> mlor = LogisticRegression(regParam=0.1, elasticNetParam=1.0, family="multinomial") >>> mlorModel = mlor.fit(mdf) >>> mlorModel.coefficientMatrix SparseMatrix(3, 4, [0, 1, 2, 3], [3, 2, 1], [1.87..., -2.75..., -0.50...], 1) >>> mlorModel.interceptVector DenseVector([0.04..., -0.42..., 0.37...]) >>> test0 = sc.parallelize([Row(features=Vectors.dense(-1.0, 1.0))]).toDF() >>> result = blorModel.transform(test0).head() >>> result.prediction 1.0 >>> result.probability DenseVector([0.02..., 0.97...]) >>> result.rawPrediction DenseVector([-3.54..., 3.54...]) >>> test1 = sc.parallelize([Row(features=Vectors.sparse(2, [0], [1.0]))]).toDF() >>> blorModel.transform(test1).head().prediction 1.0 >>> blor.setParams("vector") Traceback (most recent call last): ... TypeError: Method setParams forces keyword arguments. >>> lr_path = temp_path + "/lr" >>> blor.save(lr_path) >>> lr2 = LogisticRegression.load(lr_path) >>> lr2.getRegParam() 0.01 >>> model_path = temp_path + "/lr_model" >>> blorModel.save(model_path) >>> model2 = LogisticRegressionModel.load(model_path) >>> blorModel.coefficients[0] == model2.coefficients[0] True >>> blorModel.intercept == model2.intercept True .. versionadded:: 1.3.0 """ threshold = Param(Params._dummy(), "threshold", "Threshold in binary classification prediction, in range [0, 1]." + " If threshold and thresholds are both set, they must match." + "e.g. if threshold is p, then thresholds must be equal to [1-p, p].", typeConverter=TypeConverters.toFloat) family = Param(Params._dummy(), "family", "The name of family which is a description of the label distribution to " + "be used in the model. Supported options: auto, binomial, multinomial", typeConverter=TypeConverters.toString) @keyword_only def __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", maxIter=100, regParam=0.0, elasticNetParam=0.0, tol=1e-6, fitIntercept=True, threshold=0.5, thresholds=None, probabilityCol="probability", rawPredictionCol="rawPrediction", standardization=True, weightCol=None, aggregationDepth=2, family="auto"): """ __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", \ maxIter=100, regParam=0.0, elasticNetParam=0.0, tol=1e-6, fitIntercept=True, \ threshold=0.5, thresholds=None, probabilityCol="probability", \ rawPredictionCol="rawPrediction", standardization=True, weightCol=None, \ aggregationDepth=2, family="auto") If the threshold and thresholds Params are both set, they must be equivalent. """ super(LogisticRegression, self).__init__() self._java_obj = self._new_java_obj( "org.apache.spark.ml.classification.LogisticRegression", self.uid) self._setDefault(maxIter=100, regParam=0.0, tol=1E-6, threshold=0.5, family="auto") kwargs = self._input_kwargs self.setParams(**kwargs) self._checkThresholdConsistency() @keyword_only @since("1.3.0") def setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", maxIter=100, regParam=0.0, elasticNetParam=0.0, tol=1e-6, fitIntercept=True, threshold=0.5, thresholds=None, probabilityCol="probability", rawPredictionCol="rawPrediction", standardization=True, weightCol=None, aggregationDepth=2, family="auto"): """ setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", \ maxIter=100, regParam=0.0, elasticNetParam=0.0, tol=1e-6, fitIntercept=True, \ threshold=0.5, thresholds=None, probabilityCol="probability", \ rawPredictionCol="rawPrediction", standardization=True, weightCol=None, \ aggregationDepth=2, family="auto") Sets params for logistic regression. If the threshold and thresholds Params are both set, they must be equivalent. """ kwargs = self._input_kwargs self._set(**kwargs) self._checkThresholdConsistency() return self def _create_model(self, java_model): return LogisticRegressionModel(java_model) @since("1.4.0") def setThreshold(self, value): """ Sets the value of :py:attr:`threshold`. Clears value of :py:attr:`thresholds` if it has been set. """ self._set(threshold=value) self._clear(self.thresholds) return self @since("1.4.0") def getThreshold(self): """ Get threshold for binary classification. If :py:attr:`thresholds` is set with length 2 (i.e., binary classification), this returns the equivalent threshold: :math:`\\frac{1}{1 + \\frac{thresholds(0)}{thresholds(1)}}`. Otherwise, returns :py:attr:`threshold` if set or its default value if unset. """ self._checkThresholdConsistency() if self.isSet(self.thresholds): ts = self.getOrDefault(self.thresholds) if len(ts) != 2: raise ValueError("Logistic Regression getThreshold only applies to" + " binary classification, but thresholds has length != 2." + " thresholds: " + ",".join(ts)) return 1.0/(1.0 + ts[0]/ts[1]) else: return self.getOrDefault(self.threshold) @since("1.5.0") def setThresholds(self, value): """ Sets the value of :py:attr:`thresholds`. Clears value of :py:attr:`threshold` if it has been set. """ self._set(thresholds=value) self._clear(self.threshold) return self @since("1.5.0") def getThresholds(self): """ If :py:attr:`thresholds` is set, return its value. Otherwise, if :py:attr:`threshold` is set, return the equivalent thresholds for binary classification: (1-threshold, threshold). If neither are set, throw an error. """ self._checkThresholdConsistency() if not self.isSet(self.thresholds) and self.isSet(self.threshold): t = self.getOrDefault(self.threshold) return [1.0-t, t] else: return self.getOrDefault(self.thresholds) def _checkThresholdConsistency(self): if self.isSet(self.threshold) and self.isSet(self.thresholds): ts = self.getOrDefault(self.thresholds) if len(ts) != 2: raise ValueError("Logistic Regression getThreshold only applies to" + " binary classification, but thresholds has length != 2." + " thresholds: {0}".format(str(ts))) t = 1.0/(1.0 + ts[0]/ts[1]) t2 = self.getOrDefault(self.threshold) if abs(t2 - t) >= 1E-5: raise ValueError("Logistic Regression getThreshold found inconsistent values for" + " threshold (%g) and thresholds (equivalent to %g)" % (t2, t)) @since("2.1.0") def setFamily(self, value): """ Sets the value of :py:attr:`family`. """ return self._set(family=value) @since("2.1.0") def getFamily(self): """ Gets the value of :py:attr:`family` or its default value. """ return self.getOrDefault(self.family) class LogisticRegressionModel(JavaModel, JavaClassificationModel, JavaMLWritable, JavaMLReadable): """ Model fitted by LogisticRegression. .. versionadded:: 1.3.0 """ @property @since("2.0.0") def coefficients(self): """ Model coefficients of binomial logistic regression. An exception is thrown in the case of multinomial logistic regression. """ return self._call_java("coefficients") @property @since("1.4.0") def intercept(self): """ Model intercept of binomial logistic regression. An exception is thrown in the case of multinomial logistic regression. """ return self._call_java("intercept") @property @since("2.1.0") def coefficientMatrix(self): """ Model coefficients. """ return self._call_java("coefficientMatrix") @property @since("2.1.0") def interceptVector(self): """ Model intercept. """ return self._call_java("interceptVector") @property @since("2.0.0") def summary(self): """ Gets summary (e.g. accuracy/precision/recall, objective history, total iterations) of model trained on the training set. An exception is thrown if `trainingSummary is None`. """ if self.hasSummary: java_blrt_summary = self._call_java("summary") # Note: Once multiclass is added, update this to return correct summary return BinaryLogisticRegressionTrainingSummary(java_blrt_summary) else: raise RuntimeError("No training summary available for this %s" % self.__class__.__name__) @property @since("2.0.0") def hasSummary(self): """ Indicates whether a training summary exists for this model instance. """ return self._call_java("hasSummary") @since("2.0.0") def evaluate(self, dataset): """ Evaluates the model on a test dataset. :param dataset: Test dataset to evaluate model on, where dataset is an instance of :py:class:`pyspark.sql.DataFrame` """ if not isinstance(dataset, DataFrame): raise ValueError("dataset must be a DataFrame but got %s." % type(dataset)) java_blr_summary = self._call_java("evaluate", dataset) return BinaryLogisticRegressionSummary(java_blr_summary) class LogisticRegressionSummary(JavaWrapper): """ .. note:: Experimental Abstraction for Logistic Regression Results for a given model. .. versionadded:: 2.0.0 """ @property @since("2.0.0") def predictions(self): """ Dataframe outputted by the model's `transform` method. """ return self._call_java("predictions") @property @since("2.0.0") def probabilityCol(self): """ Field in "predictions" which gives the probability of each class as a vector. """ return self._call_java("probabilityCol") @property @since("2.0.0") def labelCol(self): """ Field in "predictions" which gives the true label of each instance. """ return self._call_java("labelCol") @property @since("2.0.0") def featuresCol(self): """ Field in "predictions" which gives the features of each instance as a vector. """ return self._call_java("featuresCol") @inherit_doc class LogisticRegressionTrainingSummary(LogisticRegressionSummary): """ .. note:: Experimental Abstraction for multinomial Logistic Regression Training results. Currently, the training summary ignores the training weights except for the objective trace. .. versionadded:: 2.0.0 """ @property @since("2.0.0") def objectiveHistory(self): """ Objective function (scaled loss + regularization) at each iteration. """ return self._call_java("objectiveHistory") @property @since("2.0.0") def totalIterations(self): """ Number of training iterations until termination. """ return self._call_java("totalIterations") @inherit_doc class BinaryLogisticRegressionSummary(LogisticRegressionSummary): """ .. note:: Experimental Binary Logistic regression results for a given model. .. versionadded:: 2.0.0 """ @property @since("2.0.0") def roc(self): """ Returns the receiver operating characteristic (ROC) curve, which is a Dataframe having two fields (FPR, TPR) with (0.0, 0.0) prepended and (1.0, 1.0) appended to it. .. seealso:: `Wikipedia reference \ <http://en.wikipedia.org/wiki/Receiver_operating_characteristic>`_ .. note:: This ignores instance weights (setting all to 1.0) from `LogisticRegression.weightCol`. This will change in later Spark versions. """ return self._call_java("roc") @property @since("2.0.0") def areaUnderROC(self): """ Computes the area under the receiver operating characteristic (ROC) curve. .. note:: This ignores instance weights (setting all to 1.0) from `LogisticRegression.weightCol`. This will change in later Spark versions. """ return self._call_java("areaUnderROC") @property @since("2.0.0") def pr(self): """ Returns the precision-recall curve, which is a Dataframe containing two fields recall, precision with (0.0, 1.0) prepended to it. .. note:: This ignores instance weights (setting all to 1.0) from `LogisticRegression.weightCol`. This will change in later Spark versions. """ return self._call_java("pr") @property @since("2.0.0") def fMeasureByThreshold(self): """ Returns a dataframe with two fields (threshold, F-Measure) curve with beta = 1.0. .. note:: This ignores instance weights (setting all to 1.0) from `LogisticRegression.weightCol`. This will change in later Spark versions. """ return self._call_java("fMeasureByThreshold") @property @since("2.0.0") def precisionByThreshold(self): """ Returns a dataframe with two fields (threshold, precision) curve. Every possible probability obtained in transforming the dataset are used as thresholds used in calculating the precision. .. note:: This ignores instance weights (setting all to 1.0) from `LogisticRegression.weightCol`. This will change in later Spark versions. """ return self._call_java("precisionByThreshold") @property @since("2.0.0") def recallByThreshold(self): """ Returns a dataframe with two fields (threshold, recall) curve. Every possible probability obtained in transforming the dataset are used as thresholds used in calculating the recall. .. note:: This ignores instance weights (setting all to 1.0) from `LogisticRegression.weightCol`. This will change in later Spark versions. """ return self._call_java("recallByThreshold") @inherit_doc class BinaryLogisticRegressionTrainingSummary(BinaryLogisticRegressionSummary, LogisticRegressionTrainingSummary): """ .. note:: Experimental Binary Logistic regression training results for a given model. .. versionadded:: 2.0.0 """ pass class TreeClassifierParams(object): """ Private class to track supported impurity measures. .. versionadded:: 1.4.0 """ supportedImpurities = ["entropy", "gini"] impurity = Param(Params._dummy(), "impurity", "Criterion used for information gain calculation (case-insensitive). " + "Supported options: " + ", ".join(supportedImpurities), typeConverter=TypeConverters.toString) def __init__(self): super(TreeClassifierParams, self).__init__() @since("1.6.0") def setImpurity(self, value): """ Sets the value of :py:attr:`impurity`. """ return self._set(impurity=value) @since("1.6.0") def getImpurity(self): """ Gets the value of impurity or its default value. """ return self.getOrDefault(self.impurity) class GBTParams(TreeEnsembleParams): """ Private class to track supported GBT params. .. versionadded:: 1.4.0 """ supportedLossTypes = ["logistic"] @inherit_doc class DecisionTreeClassifier(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol, HasProbabilityCol, HasRawPredictionCol, DecisionTreeParams, TreeClassifierParams, HasCheckpointInterval, HasSeed, JavaMLWritable, JavaMLReadable): """ `Decision tree <http://en.wikipedia.org/wiki/Decision_tree_learning>`_ learning algorithm for classification. It supports both binary and multiclass labels, as well as both continuous and categorical features. >>> from pyspark.ml.linalg import Vectors >>> from pyspark.ml.feature import StringIndexer >>> df = spark.createDataFrame([ ... (1.0, Vectors.dense(1.0)), ... (0.0, Vectors.sparse(1, [], []))], ["label", "features"]) >>> stringIndexer = StringIndexer(inputCol="label", outputCol="indexed") >>> si_model = stringIndexer.fit(df) >>> td = si_model.transform(df) >>> dt = DecisionTreeClassifier(maxDepth=2, labelCol="indexed") >>> model = dt.fit(td) >>> model.numNodes 3 >>> model.depth 1 >>> model.featureImportances SparseVector(1, {0: 1.0}) >>> model.numFeatures 1 >>> model.numClasses 2 >>> print(model.toDebugString) DecisionTreeClassificationModel (uid=...) of depth 1 with 3 nodes... >>> test0 = spark.createDataFrame([(Vectors.dense(-1.0),)], ["features"]) >>> result = model.transform(test0).head() >>> result.prediction 0.0 >>> result.probability DenseVector([1.0, 0.0]) >>> result.rawPrediction DenseVector([1.0, 0.0]) >>> test1 = spark.createDataFrame([(Vectors.sparse(1, [0], [1.0]),)], ["features"]) >>> model.transform(test1).head().prediction 1.0 >>> dtc_path = temp_path + "/dtc" >>> dt.save(dtc_path) >>> dt2 = DecisionTreeClassifier.load(dtc_path) >>> dt2.getMaxDepth() 2 >>> model_path = temp_path + "/dtc_model" >>> model.save(model_path) >>> model2 = DecisionTreeClassificationModel.load(model_path) >>> model.featureImportances == model2.featureImportances True .. versionadded:: 1.4.0 """ @keyword_only def __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", probabilityCol="probability", rawPredictionCol="rawPrediction", maxDepth=5, maxBins=32, minInstancesPerNode=1, minInfoGain=0.0, maxMemoryInMB=256, cacheNodeIds=False, checkpointInterval=10, impurity="gini", seed=None): """ __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", \ probabilityCol="probability", rawPredictionCol="rawPrediction", \ maxDepth=5, maxBins=32, minInstancesPerNode=1, minInfoGain=0.0, \ maxMemoryInMB=256, cacheNodeIds=False, checkpointInterval=10, impurity="gini", \ seed=None) """ super(DecisionTreeClassifier, self).__init__() self._java_obj = self._new_java_obj( "org.apache.spark.ml.classification.DecisionTreeClassifier", self.uid) self._setDefault(maxDepth=5, maxBins=32, minInstancesPerNode=1, minInfoGain=0.0, maxMemoryInMB=256, cacheNodeIds=False, checkpointInterval=10, impurity="gini") kwargs = self._input_kwargs self.setParams(**kwargs) @keyword_only @since("1.4.0") def setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", probabilityCol="probability", rawPredictionCol="rawPrediction", maxDepth=5, maxBins=32, minInstancesPerNode=1, minInfoGain=0.0, maxMemoryInMB=256, cacheNodeIds=False, checkpointInterval=10, impurity="gini", seed=None): """ setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", \ probabilityCol="probability", rawPredictionCol="rawPrediction", \ maxDepth=5, maxBins=32, minInstancesPerNode=1, minInfoGain=0.0, \ maxMemoryInMB=256, cacheNodeIds=False, checkpointInterval=10, impurity="gini", \ seed=None) Sets params for the DecisionTreeClassifier. """ kwargs = self._input_kwargs return self._set(**kwargs) def _create_model(self, java_model): return DecisionTreeClassificationModel(java_model) @inherit_doc class DecisionTreeClassificationModel(DecisionTreeModel, JavaClassificationModel, JavaMLWritable, JavaMLReadable): """ Model fitted by DecisionTreeClassifier. .. versionadded:: 1.4.0 """ @property @since("2.0.0") def featureImportances(self): """ Estimate of the importance of each feature. This generalizes the idea of "Gini" importance to other losses, following the explanation of Gini importance from "Random Forests" documentation by Leo Breiman and Adele Cutler, and following the implementation from scikit-learn. This feature importance is calculated as follows: - importance(feature j) = sum (over nodes which split on feature j) of the gain, where gain is scaled by the number of instances passing through node - Normalize importances for tree to sum to 1. .. note:: Feature importance for single decision trees can have high variance due to correlated predictor variables. Consider using a :py:class:`RandomForestClassifier` to determine feature importance instead. """ return self._call_java("featureImportances") @inherit_doc class RandomForestClassifier(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol, HasSeed, HasRawPredictionCol, HasProbabilityCol, RandomForestParams, TreeClassifierParams, HasCheckpointInterval, JavaMLWritable, JavaMLReadable): """ `Random Forest <http://en.wikipedia.org/wiki/Random_forest>`_ learning algorithm for classification. It supports both binary and multiclass labels, as well as both continuous and categorical features. >>> import numpy >>> from numpy import allclose >>> from pyspark.ml.linalg import Vectors >>> from pyspark.ml.feature import StringIndexer >>> df = spark.createDataFrame([ ... (1.0, Vectors.dense(1.0)), ... (0.0, Vectors.sparse(1, [], []))], ["label", "features"]) >>> stringIndexer = StringIndexer(inputCol="label", outputCol="indexed") >>> si_model = stringIndexer.fit(df) >>> td = si_model.transform(df) >>> rf = RandomForestClassifier(numTrees=3, maxDepth=2, labelCol="indexed", seed=42) >>> model = rf.fit(td) >>> model.featureImportances SparseVector(1, {0: 1.0}) >>> allclose(model.treeWeights, [1.0, 1.0, 1.0]) True >>> test0 = spark.createDataFrame([(Vectors.dense(-1.0),)], ["features"]) >>> result = model.transform(test0).head() >>> result.prediction 0.0 >>> numpy.argmax(result.probability) 0 >>> numpy.argmax(result.rawPrediction) 0 >>> test1 = spark.createDataFrame([(Vectors.sparse(1, [0], [1.0]),)], ["features"]) >>> model.transform(test1).head().prediction 1.0 >>> model.trees [DecisionTreeClassificationModel (uid=...) of depth..., DecisionTreeClassificationModel...] >>> rfc_path = temp_path + "/rfc" >>> rf.save(rfc_path) >>> rf2 = RandomForestClassifier.load(rfc_path) >>> rf2.getNumTrees() 3 >>> model_path = temp_path + "/rfc_model" >>> model.save(model_path) >>> model2 = RandomForestClassificationModel.load(model_path) >>> model.featureImportances == model2.featureImportances True .. versionadded:: 1.4.0 """ @keyword_only def __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", probabilityCol="probability", rawPredictionCol="rawPrediction", maxDepth=5, maxBins=32, minInstancesPerNode=1, minInfoGain=0.0, maxMemoryInMB=256, cacheNodeIds=False, checkpointInterval=10, impurity="gini", numTrees=20, featureSubsetStrategy="auto", seed=None, subsamplingRate=1.0): """ __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", \ probabilityCol="probability", rawPredictionCol="rawPrediction", \ maxDepth=5, maxBins=32, minInstancesPerNode=1, minInfoGain=0.0, \ maxMemoryInMB=256, cacheNodeIds=False, checkpointInterval=10, impurity="gini", \ numTrees=20, featureSubsetStrategy="auto", seed=None, subsamplingRate=1.0) """ super(RandomForestClassifier, self).__init__() self._java_obj = self._new_java_obj( "org.apache.spark.ml.classification.RandomForestClassifier", self.uid) self._setDefault(maxDepth=5, maxBins=32, minInstancesPerNode=1, minInfoGain=0.0, maxMemoryInMB=256, cacheNodeIds=False, checkpointInterval=10, impurity="gini", numTrees=20, featureSubsetStrategy="auto", subsamplingRate=1.0) kwargs = self._input_kwargs self.setParams(**kwargs) @keyword_only @since("1.4.0") def setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", probabilityCol="probability", rawPredictionCol="rawPrediction", maxDepth=5, maxBins=32, minInstancesPerNode=1, minInfoGain=0.0, maxMemoryInMB=256, cacheNodeIds=False, checkpointInterval=10, seed=None, impurity="gini", numTrees=20, featureSubsetStrategy="auto", subsamplingRate=1.0): """ setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", \ probabilityCol="probability", rawPredictionCol="rawPrediction", \ maxDepth=5, maxBins=32, minInstancesPerNode=1, minInfoGain=0.0, \ maxMemoryInMB=256, cacheNodeIds=False, checkpointInterval=10, seed=None, \ impurity="gini", numTrees=20, featureSubsetStrategy="auto", subsamplingRate=1.0) Sets params for linear classification. """ kwargs = self._input_kwargs return self._set(**kwargs) def _create_model(self, java_model): return RandomForestClassificationModel(java_model) class RandomForestClassificationModel(TreeEnsembleModel, JavaClassificationModel, JavaMLWritable, JavaMLReadable): """ Model fitted by RandomForestClassifier. .. versionadded:: 1.4.0 """ @property @since("2.0.0") def featureImportances(self): """ Estimate of the importance of each feature. Each feature's importance is the average of its importance across all trees in the ensemble The importance vector is normalized to sum to 1. This method is suggested by Hastie et al. (Hastie, Tibshirani, Friedman. "The Elements of Statistical Learning, 2nd Edition." 2001.) and follows the implementation from scikit-learn. .. seealso:: :py:attr:`DecisionTreeClassificationModel.featureImportances` """ return self._call_java("featureImportances") @property @since("2.0.0") def trees(self): """Trees in this ensemble. Warning: These have null parent Estimators.""" return [DecisionTreeClassificationModel(m) for m in list(self._call_java("trees"))] @inherit_doc class GBTClassifier(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol, HasMaxIter, GBTParams, HasCheckpointInterval, HasStepSize, HasSeed, JavaMLWritable, JavaMLReadable): """ `Gradient-Boosted Trees (GBTs) <http://en.wikipedia.org/wiki/Gradient_boosting>`_ learning algorithm for classification. It supports binary labels, as well as both continuous and categorical features. The implementation is based upon: J.H. Friedman. "Stochastic Gradient Boosting." 1999. Notes on Gradient Boosting vs. TreeBoost: - This implementation is for Stochastic Gradient Boosting, not for TreeBoost. - Both algorithms learn tree ensembles by minimizing loss functions. - TreeBoost (Friedman, 1999) additionally modifies the outputs at tree leaf nodes based on the loss function, whereas the original gradient boosting method does not. - We expect to implement TreeBoost in the future: `SPARK-4240 <https://issues.apache.org/jira/browse/SPARK-4240>`_ .. note:: Multiclass labels are not currently supported. >>> from numpy import allclose >>> from pyspark.ml.linalg import Vectors >>> from pyspark.ml.feature import StringIndexer >>> df = spark.createDataFrame([ ... (1.0, Vectors.dense(1.0)), ... (0.0, Vectors.sparse(1, [], []))], ["label", "features"]) >>> stringIndexer = StringIndexer(inputCol="label", outputCol="indexed") >>> si_model = stringIndexer.fit(df) >>> td = si_model.transform(df) >>> gbt = GBTClassifier(maxIter=5, maxDepth=2, labelCol="indexed", seed=42) >>> model = gbt.fit(td) >>> model.featureImportances SparseVector(1, {0: 1.0}) >>> allclose(model.treeWeights, [1.0, 0.1, 0.1, 0.1, 0.1]) True >>> test0 = spark.createDataFrame([(Vectors.dense(-1.0),)], ["features"]) >>> model.transform(test0).head().prediction 0.0 >>> test1 = spark.createDataFrame([(Vectors.sparse(1, [0], [1.0]),)], ["features"]) >>> model.transform(test1).head().prediction 1.0 >>> model.totalNumNodes 15 >>> print(model.toDebugString) GBTClassificationModel (uid=...)...with 5 trees... >>> gbtc_path = temp_path + "gbtc" >>> gbt.save(gbtc_path) >>> gbt2 = GBTClassifier.load(gbtc_path) >>> gbt2.getMaxDepth() 2 >>> model_path = temp_path + "gbtc_model" >>> model.save(model_path) >>> model2 = GBTClassificationModel.load(model_path) >>> model.featureImportances == model2.featureImportances True >>> model.treeWeights == model2.treeWeights True >>> model.trees [DecisionTreeRegressionModel (uid=...) of depth..., DecisionTreeRegressionModel...] .. versionadded:: 1.4.0 """ lossType = Param(Params._dummy(), "lossType", "Loss function which GBT tries to minimize (case-insensitive). " + "Supported options: " + ", ".join(GBTParams.supportedLossTypes), typeConverter=TypeConverters.toString) @keyword_only def __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", maxDepth=5, maxBins=32, minInstancesPerNode=1, minInfoGain=0.0, maxMemoryInMB=256, cacheNodeIds=False, checkpointInterval=10, lossType="logistic", maxIter=20, stepSize=0.1, seed=None, subsamplingRate=1.0): """ __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", \ maxDepth=5, maxBins=32, minInstancesPerNode=1, minInfoGain=0.0, \ maxMemoryInMB=256, cacheNodeIds=False, checkpointInterval=10, \ lossType="logistic", maxIter=20, stepSize=0.1, seed=None, subsamplingRate=1.0) """ super(GBTClassifier, self).__init__() self._java_obj = self._new_java_obj( "org.apache.spark.ml.classification.GBTClassifier", self.uid) self._setDefault(maxDepth=5, maxBins=32, minInstancesPerNode=1, minInfoGain=0.0, maxMemoryInMB=256, cacheNodeIds=False, checkpointInterval=10, lossType="logistic", maxIter=20, stepSize=0.1, subsamplingRate=1.0) kwargs = self._input_kwargs self.setParams(**kwargs) @keyword_only @since("1.4.0") def setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", maxDepth=5, maxBins=32, minInstancesPerNode=1, minInfoGain=0.0, maxMemoryInMB=256, cacheNodeIds=False, checkpointInterval=10, lossType="logistic", maxIter=20, stepSize=0.1, seed=None, subsamplingRate=1.0): """ setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", \ maxDepth=5, maxBins=32, minInstancesPerNode=1, minInfoGain=0.0, \ maxMemoryInMB=256, cacheNodeIds=False, checkpointInterval=10, \ lossType="logistic", maxIter=20, stepSize=0.1, seed=None, subsamplingRate=1.0) Sets params for Gradient Boosted Tree Classification. """ kwargs = self._input_kwargs return self._set(**kwargs) def _create_model(self, java_model): return GBTClassificationModel(java_model) @since("1.4.0") def setLossType(self, value): """ Sets the value of :py:attr:`lossType`. """ return self._set(lossType=value) @since("1.4.0") def getLossType(self): """ Gets the value of lossType or its default value. """ return self.getOrDefault(self.lossType) class GBTClassificationModel(TreeEnsembleModel, JavaPredictionModel, JavaMLWritable, JavaMLReadable): """ Model fitted by GBTClassifier. .. versionadded:: 1.4.0 """ @property @since("2.0.0") def featureImportances(self): """ Estimate of the importance of each feature. Each feature's importance is the average of its importance across all trees in the ensemble The importance vector is normalized to sum to 1. This method is suggested by Hastie et al. (Hastie, Tibshirani, Friedman. "The Elements of Statistical Learning, 2nd Edition." 2001.) and follows the implementation from scikit-learn. .. seealso:: :py:attr:`DecisionTreeClassificationModel.featureImportances` """ return self._call_java("featureImportances") @property @since("2.0.0") def trees(self): """Trees in this ensemble. Warning: These have null parent Estimators.""" return [DecisionTreeRegressionModel(m) for m in list(self._call_java("trees"))] @inherit_doc class NaiveBayes(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol, HasProbabilityCol, HasRawPredictionCol, HasThresholds, HasWeightCol, JavaMLWritable, JavaMLReadable): """ Naive Bayes Classifiers. It supports both Multinomial and Bernoulli NB. `Multinomial NB <http://nlp.stanford.edu/IR-book/html/htmledition/naive-bayes-text-classification-1.html>`_ can handle finitely supported discrete data. For example, by converting documents into TF-IDF vectors, it can be used for document classification. By making every vector a binary (0/1) data, it can also be used as `Bernoulli NB <http://nlp.stanford.edu/IR-book/html/htmledition/the-bernoulli-model-1.html>`_. The input feature values must be nonnegative. >>> from pyspark.sql import Row >>> from pyspark.ml.linalg import Vectors >>> df = spark.createDataFrame([ ... Row(label=0.0, weight=0.1, features=Vectors.dense([0.0, 0.0])), ... Row(label=0.0, weight=0.5, features=Vectors.dense([0.0, 1.0])), ... Row(label=1.0, weight=1.0, features=Vectors.dense([1.0, 0.0]))]) >>> nb = NaiveBayes(smoothing=1.0, modelType="multinomial", weightCol="weight") >>> model = nb.fit(df) >>> model.pi DenseVector([-0.81..., -0.58...]) >>> model.theta DenseMatrix(2, 2, [-0.91..., -0.51..., -0.40..., -1.09...], 1) >>> test0 = sc.parallelize([Row(features=Vectors.dense([1.0, 0.0]))]).toDF() >>> result = model.transform(test0).head() >>> result.prediction 1.0 >>> result.probability DenseVector([0.32..., 0.67...]) >>> result.rawPrediction DenseVector([-1.72..., -0.99...]) >>> test1 = sc.parallelize([Row(features=Vectors.sparse(2, [0], [1.0]))]).toDF() >>> model.transform(test1).head().prediction 1.0 >>> nb_path = temp_path + "/nb" >>> nb.save(nb_path) >>> nb2 = NaiveBayes.load(nb_path) >>> nb2.getSmoothing() 1.0 >>> model_path = temp_path + "/nb_model" >>> model.save(model_path) >>> model2 = NaiveBayesModel.load(model_path) >>> model.pi == model2.pi True >>> model.theta == model2.theta True >>> nb = nb.setThresholds([0.01, 10.00]) >>> model3 = nb.fit(df) >>> result = model3.transform(test0).head() >>> result.prediction 0.0 .. versionadded:: 1.5.0 """ smoothing = Param(Params._dummy(), "smoothing", "The smoothing parameter, should be >= 0, " + "default is 1.0", typeConverter=TypeConverters.toFloat) modelType = Param(Params._dummy(), "modelType", "The model type which is a string " + "(case-sensitive). Supported options: multinomial (default) and bernoulli.", typeConverter=TypeConverters.toString) @keyword_only def __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", probabilityCol="probability", rawPredictionCol="rawPrediction", smoothing=1.0, modelType="multinomial", thresholds=None, weightCol=None): """ __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", \ probabilityCol="probability", rawPredictionCol="rawPrediction", smoothing=1.0, \ modelType="multinomial", thresholds=None, weightCol=None) """ super(NaiveBayes, self).__init__() self._java_obj = self._new_java_obj( "org.apache.spark.ml.classification.NaiveBayes", self.uid) self._setDefault(smoothing=1.0, modelType="multinomial") kwargs = self._input_kwargs self.setParams(**kwargs) @keyword_only @since("1.5.0") def setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", probabilityCol="probability", rawPredictionCol="rawPrediction", smoothing=1.0, modelType="multinomial", thresholds=None, weightCol=None): """ setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", \ probabilityCol="probability", rawPredictionCol="rawPrediction", smoothing=1.0, \ modelType="multinomial", thresholds=None, weightCol=None) Sets params for Naive Bayes. """ kwargs = self._input_kwargs return self._set(**kwargs) def _create_model(self, java_model): return NaiveBayesModel(java_model) @since("1.5.0") def setSmoothing(self, value): """ Sets the value of :py:attr:`smoothing`. """ return self._set(smoothing=value) @since("1.5.0") def getSmoothing(self): """ Gets the value of smoothing or its default value. """ return self.getOrDefault(self.smoothing) @since("1.5.0") def setModelType(self, value): """ Sets the value of :py:attr:`modelType`. """ return self._set(modelType=value) @since("1.5.0") def getModelType(self): """ Gets the value of modelType or its default value. """ return self.getOrDefault(self.modelType) class NaiveBayesModel(JavaModel, JavaClassificationModel, JavaMLWritable, JavaMLReadable): """ Model fitted by NaiveBayes. .. versionadded:: 1.5.0 """ @property @since("2.0.0") def pi(self): """ log of class priors. """ return self._call_java("pi") @property @since("2.0.0") def theta(self): """ log of class conditional probabilities. """ return self._call_java("theta") @inherit_doc class MultilayerPerceptronClassifier(JavaEstimator, HasFeaturesCol, HasLabelCol, HasPredictionCol, HasMaxIter, HasTol, HasSeed, HasStepSize, JavaMLWritable, JavaMLReadable): """ Classifier trainer based on the Multilayer Perceptron. Each layer has sigmoid activation function, output layer has softmax. Number of inputs has to be equal to the size of feature vectors. Number of outputs has to be equal to the total number of labels. >>> from pyspark.ml.linalg import Vectors >>> df = spark.createDataFrame([ ... (0.0, Vectors.dense([0.0, 0.0])), ... (1.0, Vectors.dense([0.0, 1.0])), ... (1.0, Vectors.dense([1.0, 0.0])), ... (0.0, Vectors.dense([1.0, 1.0]))], ["label", "features"]) >>> mlp = MultilayerPerceptronClassifier(maxIter=100, layers=[2, 2, 2], blockSize=1, seed=123) >>> model = mlp.fit(df) >>> model.layers [2, 2, 2] >>> model.weights.size 12 >>> testDF = spark.createDataFrame([ ... (Vectors.dense([1.0, 0.0]),), ... (Vectors.dense([0.0, 0.0]),)], ["features"]) >>> model.transform(testDF).show() +---------+----------+ | features|prediction| +---------+----------+ |[1.0,0.0]| 1.0| |[0.0,0.0]| 0.0| +---------+----------+ ... >>> mlp_path = temp_path + "/mlp" >>> mlp.save(mlp_path) >>> mlp2 = MultilayerPerceptronClassifier.load(mlp_path) >>> mlp2.getBlockSize() 1 >>> model_path = temp_path + "/mlp_model" >>> model.save(model_path) >>> model2 = MultilayerPerceptronClassificationModel.load(model_path) >>> model.layers == model2.layers True >>> model.weights == model2.weights True >>> mlp2 = mlp2.setInitialWeights(list(range(0, 12))) >>> model3 = mlp2.fit(df) >>> model3.weights != model2.weights True >>> model3.layers == model.layers True .. versionadded:: 1.6.0 """ layers = Param(Params._dummy(), "layers", "Sizes of layers from input layer to output layer " + "E.g., Array(780, 100, 10) means 780 inputs, one hidden layer with 100 " + "neurons and output layer of 10 neurons.", typeConverter=TypeConverters.toListInt) blockSize = Param(Params._dummy(), "blockSize", "Block size for stacking input data in " + "matrices. Data is stacked within partitions. If block size is more than " + "remaining data in a partition then it is adjusted to the size of this " + "data. Recommended size is between 10 and 1000, default is 128.", typeConverter=TypeConverters.toInt) solver = Param(Params._dummy(), "solver", "The solver algorithm for optimization. Supported " + "options: l-bfgs, gd.", typeConverter=TypeConverters.toString) initialWeights = Param(Params._dummy(), "initialWeights", "The initial weights of the model.", typeConverter=TypeConverters.toVector) @keyword_only def __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", maxIter=100, tol=1e-6, seed=None, layers=None, blockSize=128, stepSize=0.03, solver="l-bfgs", initialWeights=None): """ __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", \ maxIter=100, tol=1e-6, seed=None, layers=None, blockSize=128, stepSize=0.03, \ solver="l-bfgs", initialWeights=None) """ super(MultilayerPerceptronClassifier, self).__init__() self._java_obj = self._new_java_obj( "org.apache.spark.ml.classification.MultilayerPerceptronClassifier", self.uid) self._setDefault(maxIter=100, tol=1E-4, blockSize=128, stepSize=0.03, solver="l-bfgs") kwargs = self._input_kwargs self.setParams(**kwargs) @keyword_only @since("1.6.0") def setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", maxIter=100, tol=1e-6, seed=None, layers=None, blockSize=128, stepSize=0.03, solver="l-bfgs", initialWeights=None): """ setParams(self, featuresCol="features", labelCol="label", predictionCol="prediction", \ maxIter=100, tol=1e-6, seed=None, layers=None, blockSize=128, stepSize=0.03, \ solver="l-bfgs", initialWeights=None) Sets params for MultilayerPerceptronClassifier. """ kwargs = self._input_kwargs return self._set(**kwargs) def _create_model(self, java_model): return MultilayerPerceptronClassificationModel(java_model) @since("1.6.0") def setLayers(self, value): """ Sets the value of :py:attr:`layers`. """ return self._set(layers=value) @since("1.6.0") def getLayers(self): """ Gets the value of layers or its default value. """ return self.getOrDefault(self.layers) @since("1.6.0") def setBlockSize(self, value): """ Sets the value of :py:attr:`blockSize`. """ return self._set(blockSize=value) @since("1.6.0") def getBlockSize(self): """ Gets the value of blockSize or its default value. """ return self.getOrDefault(self.blockSize) @since("2.0.0") def setStepSize(self, value): """ Sets the value of :py:attr:`stepSize`. """ return self._set(stepSize=value) @since("2.0.0") def getStepSize(self): """ Gets the value of stepSize or its default value. """ return self.getOrDefault(self.stepSize) @since("2.0.0") def setSolver(self, value): """ Sets the value of :py:attr:`solver`. """ return self._set(solver=value) @since("2.0.0") def getSolver(self): """ Gets the value of solver or its default value. """ return self.getOrDefault(self.solver) @since("2.0.0") def setInitialWeights(self, value): """ Sets the value of :py:attr:`initialWeights`. """ return self._set(initialWeights=value) @since("2.0.0") def getInitialWeights(self): """ Gets the value of initialWeights or its default value. """ return self.getOrDefault(self.initialWeights) class MultilayerPerceptronClassificationModel(JavaModel, JavaPredictionModel, JavaMLWritable, JavaMLReadable): """ Model fitted by MultilayerPerceptronClassifier. .. versionadded:: 1.6.0 """ @property @since("1.6.0") def layers(self): """ array of layer sizes including input and output layers. """ return self._call_java("javaLayers") @property @since("2.0.0") def weights(self): """ the weights of layers. """ return self._call_java("weights") class OneVsRestParams(HasFeaturesCol, HasLabelCol, HasWeightCol, HasPredictionCol): """ Parameters for OneVsRest and OneVsRestModel. """ classifier = Param(Params._dummy(), "classifier", "base binary classifier") @since("2.0.0") def setClassifier(self, value): """ Sets the value of :py:attr:`classifier`. .. note:: Only LogisticRegression and NaiveBayes are supported now. """ return self._set(classifier=value) @since("2.0.0") def getClassifier(self): """ Gets the value of classifier or its default value. """ return self.getOrDefault(self.classifier) @inherit_doc class OneVsRest(Estimator, OneVsRestParams, MLReadable, MLWritable): """ .. note:: Experimental Reduction of Multiclass Classification to Binary Classification. Performs reduction using one against all strategy. For a multiclass classification with k classes, train k models (one per class). Each example is scored against all k models and the model with highest score is picked to label the example. >>> from pyspark.sql import Row >>> from pyspark.ml.linalg import Vectors >>> data_path = "data/mllib/sample_multiclass_classification_data.txt" >>> df = spark.read.format("libsvm").load(data_path) >>> lr = LogisticRegression(regParam=0.01) >>> ovr = OneVsRest(classifier=lr) >>> model = ovr.fit(df) >>> model.models[0].coefficients DenseVector([0.5..., -1.0..., 3.4..., 4.2...]) >>> model.models[1].coefficients DenseVector([-2.1..., 3.1..., -2.6..., -2.3...]) >>> model.models[2].coefficients DenseVector([0.3..., -3.4..., 1.0..., -1.1...]) >>> [x.intercept for x in model.models] [-2.7..., -2.5..., -1.3...] >>> test0 = sc.parallelize([Row(features=Vectors.dense(-1.0, 0.0, 1.0, 1.0))]).toDF() >>> model.transform(test0).head().prediction 0.0 >>> test1 = sc.parallelize([Row(features=Vectors.sparse(4, [0], [1.0]))]).toDF() >>> model.transform(test1).head().prediction 2.0 >>> test2 = sc.parallelize([Row(features=Vectors.dense(0.5, 0.4, 0.3, 0.2))]).toDF() >>> model.transform(test2).head().prediction 0.0 >>> model_path = temp_path + "/ovr_model" >>> model.save(model_path) >>> model2 = OneVsRestModel.load(model_path) >>> model2.transform(test0).head().prediction 0.0 .. versionadded:: 2.0.0 """ @keyword_only def __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", classifier=None, weightCol=None): """ __init__(self, featuresCol="features", labelCol="label", predictionCol="prediction", \ classifier=None, weightCol=None) """ super(OneVsRest, self).__init__() kwargs = self._input_kwargs self._set(**kwargs) @keyword_only @since("2.0.0") def setParams(self, featuresCol=None, labelCol=None, predictionCol=None, classifier=None, weightCol=None): """ setParams(self, featuresCol=None, labelCol=None, predictionCol=None, \ classifier=None, weightCol=None): Sets params for OneVsRest. """ kwargs = self._input_kwargs return self._set(**kwargs) def _fit(self, dataset): labelCol = self.getLabelCol() featuresCol = self.getFeaturesCol() predictionCol = self.getPredictionCol() classifier = self.getClassifier() assert isinstance(classifier, HasRawPredictionCol),\ "Classifier %s doesn't extend from HasRawPredictionCol." % type(classifier) numClasses = int(dataset.agg({labelCol: "max"}).head()["max("+labelCol+")"]) + 1 weightCol = None if (self.isDefined(self.weightCol) and self.getWeightCol()): if isinstance(classifier, HasWeightCol): weightCol = self.getWeightCol() else: warnings.warn("weightCol is ignored, " "as it is not supported by {} now.".format(classifier)) if weightCol: multiclassLabeled = dataset.select(labelCol, featuresCol, weightCol) else: multiclassLabeled = dataset.select(labelCol, featuresCol) # persist if underlying dataset is not persistent. handlePersistence = \ dataset.rdd.getStorageLevel() == StorageLevel(False, False, False, False) if handlePersistence: multiclassLabeled.persist(StorageLevel.MEMORY_AND_DISK) def trainSingleClass(index): binaryLabelCol = "mc2b$" + str(index) trainingDataset = multiclassLabeled.withColumn( binaryLabelCol, when(multiclassLabeled[labelCol] == float(index), 1.0).otherwise(0.0)) paramMap = dict([(classifier.labelCol, binaryLabelCol), (classifier.featuresCol, featuresCol), (classifier.predictionCol, predictionCol)]) if weightCol: paramMap[classifier.weightCol] = weightCol return classifier.fit(trainingDataset, paramMap) # TODO: Parallel training for all classes. models = [trainSingleClass(i) for i in range(numClasses)] if handlePersistence: multiclassLabeled.unpersist() return self._copyValues(OneVsRestModel(models=models)) @since("2.0.0") def copy(self, extra=None): """ Creates a copy of this instance with a randomly generated uid and some extra params. This creates a deep copy of the embedded paramMap, and copies the embedded and extra parameters over. :param extra: Extra parameters to copy to the new instance :return: Copy of this instance """ if extra is None: extra = dict() newOvr = Params.copy(self, extra) if self.isSet(self.classifier): newOvr.setClassifier(self.getClassifier().copy(extra)) return newOvr @since("2.0.0") def write(self): """Returns an MLWriter instance for this ML instance.""" return JavaMLWriter(self) @since("2.0.0") def save(self, path): """Save this ML instance to the given path, a shortcut of `write().save(path)`.""" self.write().save(path) @classmethod @since("2.0.0") def read(cls): """Returns an MLReader instance for this class.""" return JavaMLReader(cls) @classmethod def _from_java(cls, java_stage): """ Given a Java OneVsRest, create and return a Python wrapper of it. Used for ML persistence. """ featuresCol = java_stage.getFeaturesCol() labelCol = java_stage.getLabelCol() predictionCol = java_stage.getPredictionCol() classifier = JavaParams._from_java(java_stage.getClassifier()) py_stage = cls(featuresCol=featuresCol, labelCol=labelCol, predictionCol=predictionCol, classifier=classifier) py_stage._resetUid(java_stage.uid()) return py_stage def _to_java(self): """ Transfer this instance to a Java OneVsRest. Used for ML persistence. :return: Java object equivalent to this instance. """ _java_obj = JavaParams._new_java_obj("org.apache.spark.ml.classification.OneVsRest", self.uid) _java_obj.setClassifier(self.getClassifier()._to_java()) _java_obj.setFeaturesCol(self.getFeaturesCol()) _java_obj.setLabelCol(self.getLabelCol()) _java_obj.setPredictionCol(self.getPredictionCol()) return _java_obj class OneVsRestModel(Model, OneVsRestParams, MLReadable, MLWritable): """ .. note:: Experimental Model fitted by OneVsRest. This stores the models resulting from training k binary classifiers: one for each class. Each example is scored against all k models, and the model with the highest score is picked to label the example. .. versionadded:: 2.0.0 """ def __init__(self, models): super(OneVsRestModel, self).__init__() self.models = models def _transform(self, dataset): # determine the input columns: these need to be passed through origCols = dataset.columns # add an accumulator column to store predictions of all the models accColName = "mbc$acc" + str(uuid.uuid4()) initUDF = udf(lambda _: [], ArrayType(DoubleType())) newDataset = dataset.withColumn(accColName, initUDF(dataset[origCols[0]])) # persist if underlying dataset is not persistent. handlePersistence = \ dataset.rdd.getStorageLevel() == StorageLevel(False, False, False, False) if handlePersistence: newDataset.persist(StorageLevel.MEMORY_AND_DISK) # update the accumulator column with the result of prediction of models aggregatedDataset = newDataset for index, model in enumerate(self.models): rawPredictionCol = model._call_java("getRawPredictionCol") columns = origCols + [rawPredictionCol, accColName] # add temporary column to store intermediate scores and update tmpColName = "mbc$tmp" + str(uuid.uuid4()) updateUDF = udf( lambda predictions, prediction: predictions + [prediction.tolist()[1]], ArrayType(DoubleType())) transformedDataset = model.transform(aggregatedDataset).select(*columns) updatedDataset = transformedDataset.withColumn( tmpColName, updateUDF(transformedDataset[accColName], transformedDataset[rawPredictionCol])) newColumns = origCols + [tmpColName] # switch out the intermediate column with the accumulator column aggregatedDataset = updatedDataset\ .select(*newColumns).withColumnRenamed(tmpColName, accColName) if handlePersistence: newDataset.unpersist() # output the index of the classifier with highest confidence as prediction labelUDF = udf( lambda predictions: float(max(enumerate(predictions), key=operator.itemgetter(1))[0]), DoubleType()) # output label and label metadata as prediction return aggregatedDataset.withColumn( self.getPredictionCol(), labelUDF(aggregatedDataset[accColName])).drop(accColName) @since("2.0.0") def copy(self, extra=None): """ Creates a copy of this instance with a randomly generated uid and some extra params. This creates a deep copy of the embedded paramMap, and copies the embedded and extra parameters over. :param extra: Extra parameters to copy to the new instance :return: Copy of this instance """ if extra is None: extra = dict() newModel = Params.copy(self, extra) newModel.models = [model.copy(extra) for model in self.models] return newModel @since("2.0.0") def write(self): """Returns an MLWriter instance for this ML instance.""" return JavaMLWriter(self) @since("2.0.0") def save(self, path): """Save this ML instance to the given path, a shortcut of `write().save(path)`.""" self.write().save(path) @classmethod @since("2.0.0") def read(cls): """Returns an MLReader instance for this class.""" return JavaMLReader(cls) @classmethod def _from_java(cls, java_stage): """ Given a Java OneVsRestModel, create and return a Python wrapper of it. Used for ML persistence. """ featuresCol = java_stage.getFeaturesCol() labelCol = java_stage.getLabelCol() predictionCol = java_stage.getPredictionCol() classifier = JavaParams._from_java(java_stage.getClassifier()) models = [JavaParams._from_java(model) for model in java_stage.models()] py_stage = cls(models=models).setPredictionCol(predictionCol).setLabelCol(labelCol)\ .setFeaturesCol(featuresCol).setClassifier(classifier) py_stage._resetUid(java_stage.uid()) return py_stage def _to_java(self): """ Transfer this instance to a Java OneVsRestModel. Used for ML persistence. :return: Java object equivalent to this instance. """ sc = SparkContext._active_spark_context java_models = [model._to_java() for model in self.models] java_models_array = JavaWrapper._new_java_array( java_models, sc._gateway.jvm.org.apache.spark.ml.classification.ClassificationModel) metadata = JavaParams._new_java_obj("org.apache.spark.sql.types.Metadata") _java_obj = JavaParams._new_java_obj("org.apache.spark.ml.classification.OneVsRestModel", self.uid, metadata.empty(), java_models_array) _java_obj.set("classifier", self.getClassifier()._to_java()) _java_obj.set("featuresCol", self.getFeaturesCol()) _java_obj.set("labelCol", self.getLabelCol()) _java_obj.set("predictionCol", self.getPredictionCol()) return _java_obj if __name__ == "__main__": import doctest import pyspark.ml.classification from pyspark.sql import SparkSession globs = pyspark.ml.classification.__dict__.copy() # The small batch size here ensures that we see multiple batches, # even in these small test examples: spark = SparkSession.builder\ .master("local[2]")\ .appName("ml.classification tests")\ .getOrCreate() sc = spark.sparkContext globs['sc'] = sc globs['spark'] = spark import tempfile temp_path = tempfile.mkdtemp() globs['temp_path'] = temp_path try: (failure_count, test_count) = doctest.testmod(globs=globs, optionflags=doctest.ELLIPSIS) spark.stop() finally: from shutil import rmtree try: rmtree(temp_path) except OSError: pass if failure_count: exit(-1)
jlopezmalla/spark
python/pyspark/ml/classification.py
Python
apache-2.0
70,656
[ 30522, 30524, 1007, 2104, 2028, 2030, 2062, 1001, 12130, 6105, 10540, 1012, 2156, 1996, 5060, 5371, 5500, 2007, 1001, 2023, 2147, 2005, 3176, 2592, 4953, 9385, 6095, 1012, 1001, 1996, 2004, 2546, 15943, 2023, 5371, 2000, 2017, 2104, 1996, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* This file is part of the KDE project Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include <dcopclient.h> #include <kapplication.h> #include <kprocess.h> #include <kstaticdeleter.h> #include "watcher_stub.h" #include "mrml_utils.h" // after 100 of no use, terminate the mrmld #define TIMEOUT 100 // how often to restart the mrmld in case of failure #define NUM_RESTARTS 5 using namespace KMrml; KStaticDeleter<Util> utils_sd; Util *Util::s_self = 0L; Util::Util() { // we need our own dcopclient, when used in kio_mrml if ( !DCOPClient::mainClient() ) { DCOPClient::setMainClient( new DCOPClient() ); if ( !DCOPClient::mainClient()->attach() ) qWarning( "kio_mrml: Can't attach to DCOP Server."); } } Util::~Util() { if ( this == s_self ) s_self = 0L; } Util *Util::self() { if ( !s_self ) s_self = utils_sd.setObject( new Util() ); return s_self; } bool Util::requiresLocalServerFor( const KURL& url ) { return url.host().isEmpty() || url.host() == "localhost"; } bool Util::startLocalServer( const Config& config ) { if ( config.serverStartedIndividually() ) return true; DCOPClient *client = DCOPClient::mainClient(); // ### check if it's already running (add dcop method to Watcher) Watcher_stub watcher( client, "kded", "daemonwatcher"); return ( watcher.requireDaemon( client->appId(), "mrmld", config.mrmldCommandline(), TIMEOUT, NUM_RESTARTS ) && watcher.ok() ); } void Util::unrequireLocalServer() { DCOPClient *client = DCOPClient::mainClient(); Watcher_stub watcher( client, "kded", "daemonwatcher"); watcher.unrequireDaemon( client->appId(), "mrmld" ); }
iegor/kdegraphics
kmrml/kmrml/lib/mrml_utils.cpp
C++
gpl-2.0
2,481
[ 30522, 1013, 1008, 2023, 5371, 2003, 2112, 1997, 1996, 1047, 3207, 2622, 9385, 1006, 1039, 1007, 2526, 3765, 6528, 1052, 7959, 13355, 2121, 1026, 30524, 2618, 2009, 1998, 1013, 2030, 19933, 2009, 2104, 1996, 3408, 1997, 1996, 27004, 2236, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
local pi = math.pi local player_in_bed = 0 local is_sp = minetest.is_singleplayer() local enable_respawn = minetest.setting_getbool("enable_bed_respawn") if enable_respawn == nil then enable_respawn = true end -- Helper functions local function get_look_yaw(pos) local n = minetest.get_node(pos) if n.param2 == 1 then return pi / 2, n.param2 elseif n.param2 == 3 then return -pi / 2, n.param2 elseif n.param2 == 0 then return pi, n.param2 else return 0, n.param2 end end local function is_night_skip_enabled() local enable_night_skip = minetest.setting_getbool("enable_bed_night_skip") if enable_night_skip == nil then enable_night_skip = true end return enable_night_skip end local function check_in_beds(players) local in_bed = beds.player if not players then players = minetest.get_connected_players() end for n, player in ipairs(players) do local name = player:get_player_name() if not in_bed[name] then return false end end return #players > 0 end local function lay_down(player, pos, bed_pos, state, skip) local name = player:get_player_name() local hud_flags = player:hud_get_flags() if not player or not name then return end -- stand up if state ~= nil and not state then local p = beds.pos[name] or nil if beds.player[name] ~= nil then beds.player[name] = nil player_in_bed = player_in_bed - 1 end -- skip here to prevent sending player specific changes (used for leaving players) if skip then return end if p then player:setpos(p) end -- physics, eye_offset, etc player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0}) player:set_look_yaw(math.random(1, 180) / 100) default.player_attached[name] = false player:set_physics_override(1, 1, 1) hud_flags.wielditem = true default.player_set_animation(player, "stand" , 30) -- lay down else beds.player[name] = 1 beds.pos[name] = pos player_in_bed = player_in_bed + 1 -- physics, eye_offset, etc player:set_eye_offset({x = 0, y = -13, z = 0}, {x = 0, y = 0, z = 0}) local yaw, param2 = get_look_yaw(bed_pos) player:set_look_yaw(yaw) local dir = minetest.facedir_to_dir(param2) local p = {x = bed_pos.x + dir.x / 2, y = bed_pos.y, z = bed_pos.z + dir.z / 2} player:set_physics_override(0, 0, 0) player:setpos(p) default.player_attached[name] = true hud_flags.wielditem = false default.player_set_animation(player, "lay" , 0) end player:hud_set_flags(hud_flags) end local function update_formspecs(finished) local ges = #minetest.get_connected_players() local form_n = "" local is_majority = (ges / 2) < player_in_bed if finished then form_n = beds.formspec .. "label[2.7,11; Good morning.]" else form_n = beds.formspec .. "label[2.2,11;" .. tostring(player_in_bed) .. " of " .. tostring(ges) .. " players are in bed]" if is_majority and is_night_skip_enabled() then form_n = form_n .. "button_exit[2,8;4,0.75;force;Force night skip]" end end for name,_ in pairs(beds.player) do minetest.show_formspec(name, "beds_form", form_n) end end -- Public functions function beds.kick_players() for name, _ in pairs(beds.player) do local player = minetest.get_player_by_name(name) lay_down(player, nil, nil, false) end end function beds.skip_night() minetest.set_timeofday(0.23) beds.set_spawns() end function beds.on_rightclick(pos, player) local name = player:get_player_name() local ppos = player:getpos() local tod = minetest.get_timeofday() if tod > 0.2 and tod < 0.805 then if beds.player[name] then lay_down(player, nil, nil, false) end minetest.chat_send_player(name, "You can only sleep at night.") return end -- move to bed if not beds.player[name] then lay_down(player, ppos, pos) else lay_down(player, nil, nil, false) end if not is_sp then update_formspecs(false) end -- skip the night and let all players stand up if check_in_beds() then minetest.after(2, function() if not is_sp then update_formspecs(is_night_skip_enabled()) end if is_night_skip_enabled() then beds.skip_night() beds.kick_players() end end) end end -- Callbacks minetest.register_on_joinplayer(function(player) beds.read_spawns() end) -- respawn player at bed if enabled and valid position is found minetest.register_on_respawnplayer(function(player) if not enable_respawn then return false end local name = player:get_player_name() local pos = beds.spawn[name] or nil if pos then player:setpos(pos) return true end end) minetest.register_on_leaveplayer(function(player) local name = player:get_player_name() lay_down(player, nil, nil, false, true) beds.player[name] = nil if check_in_beds() then minetest.after(2, function() update_formspecs(is_night_skip_enabled()) if is_night_skip_enabled() then beds.skip_night() beds.kick_players() end end) end end) minetest.register_on_player_receive_fields(function(player, formname, fields) if formname ~= "beds_form" then return end if fields.quit or fields.leave then lay_down(player, nil, nil, false) update_formspecs(false) end if fields.force then update_formspecs(is_night_skip_enabled()) if is_night_skip_enabled() then beds.skip_night() beds.kick_players() end end end)
linushsao/sky_islands_game-linus
mods/beds/functions.lua
Lua
gpl-3.0
5,266
[ 30522, 2334, 14255, 1027, 8785, 1012, 14255, 2334, 2447, 1035, 1999, 1035, 2793, 1027, 1014, 2334, 2003, 1035, 11867, 1027, 3067, 22199, 1012, 2003, 1035, 2309, 13068, 2121, 1006, 1007, 2334, 9585, 1035, 24501, 4502, 7962, 1027, 3067, 22199...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually #pragma once #include <common/common.h> #include <CCashDbWorkerRUDetail.hpp> #include <common/ATFCore.hpp> START_ATF_NAMESPACE namespace Register { class CCashDbWorkerRURegister : public IRegister { public: void Register() override { auto& hook_core = CATFCore::get_instance(); for (auto& r : Detail::CCashDbWorkerRU_functions) hook_core.reg_wrapper(r.pBind, r); } }; }; // end namespace Register END_ATF_NAMESPACE
goodwinxp/Yorozuya
library/ATF/CCashDbWorkerRURegister.hpp
C++
mit
688
[ 30522, 1013, 1013, 2023, 5371, 8285, 7013, 2011, 13354, 2378, 2005, 16096, 4013, 30524, 2691, 1012, 1044, 1028, 1001, 2421, 1026, 10507, 11823, 18939, 6198, 2121, 28121, 12928, 4014, 1012, 6522, 2361, 1028, 1001, 2421, 1026, 2691, 1013, 201...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #include "../Array/ArrayShortcuts.hpp" #include "../Object/ObjectShortcuts.hpp" namespace ARDUINOJSON_NAMESPACE { template <typename TVariant> class VariantShortcuts : public ObjectShortcuts<TVariant>, public ArrayShortcuts<TVariant> { public: using ArrayShortcuts<TVariant>::createNestedArray; using ArrayShortcuts<TVariant>::createNestedObject; using ArrayShortcuts<TVariant>::operator[]; using ObjectShortcuts<TVariant>::createNestedArray; using ObjectShortcuts<TVariant>::createNestedObject; using ObjectShortcuts<TVariant>::operator[]; }; } // namespace ARDUINOJSON_NAMESPACE
felipehfj/Arduino
libraries/ArduinoJson/src/ArduinoJson/Operators/VariantShortcuts.hpp
C++
gpl-3.0
724
[ 30522, 1013, 1013, 12098, 8566, 5740, 22578, 2239, 1011, 12098, 8566, 5740, 22578, 2239, 1012, 8917, 1013, 1013, 9385, 21721, 18698, 8747, 2297, 1011, 10476, 1013, 1013, 10210, 6105, 1001, 10975, 8490, 2863, 2320, 1001, 2421, 1000, 1012, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (c) 1998-2014 by Richard A. Wilkes. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public License, * version 2.0. If a copy of the MPL was not distributed with this file, You * can obtain one at http://mozilla.org/MPL/2.0/. * * This Source Code Form is "Incompatible With Secondary Licenses", as defined * by the Mozilla Public License, version 2.0. */ package com.trollworks.gcs.character; import com.trollworks.toolkit.ui.GraphicsUtilities; import com.trollworks.toolkit.ui.UIUtilities; import com.trollworks.toolkit.ui.print.PrintManager; import com.trollworks.toolkit.utility.units.LengthUnits; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Insets; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; /** A printer page. */ public class Page extends JPanel { private PageOwner mOwner; /** * Creates a new page. * * @param owner The page owner. */ public Page(PageOwner owner) { super(new BorderLayout()); mOwner = owner; setOpaque(true); setBackground(Color.white); PrintManager pageSettings = mOwner.getPageSettings(); Insets insets = mOwner.getPageAdornmentsInsets(this); double[] size = pageSettings != null ? pageSettings.getPageSize(LengthUnits.POINTS) : new double[] { 8.5 * 72.0, 11.0 * 72.0 }; double[] margins = pageSettings != null ? pageSettings.getPageMargins(LengthUnits.POINTS) : new double[] { 36.0, 36.0, 36.0, 36.0 }; setBorder(new EmptyBorder(insets.top + (int) margins[0], insets.left + (int) margins[1], insets.bottom + (int) margins[2], insets.right + (int) margins[3])); Dimension pageSize = new Dimension((int) size[0], (int) size[1]); UIUtilities.setOnlySize(this, pageSize); setSize(pageSize); } @Override protected void paintComponent(Graphics gc) { super.paintComponent(GraphicsUtilities.prepare(gc)); mOwner.drawPageAdornments(this, gc); } }
smithkm/gcs
src/com/trollworks/gcs/character/Page.java
Java
mpl-2.0
1,978
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 2687, 1011, 2297, 2011, 2957, 1037, 1012, 20635, 1012, 2035, 2916, 9235, 1012, 1008, 1008, 2023, 3120, 3642, 2433, 2003, 3395, 2000, 1996, 3408, 1997, 1996, 9587, 5831, 4571, 2270, 6105, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/*L * Copyright Ekagra Software Technologies Ltd. * Copyright SAIC * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/cacore-sdk-pre411/LICENSE.txt for details. */ package gov.nih.nci.system.webservice; import gov.nih.nci.system.applicationservice.ApplicationService; import gov.nih.nci.system.client.proxy.ListProxy; import gov.nih.nci.system.query.hibernate.HQLCriteria; import gov.nih.nci.system.query.nestedcriteria.NestedCriteriaPath; import gov.nih.nci.system.util.ClassCache; import gov.nih.nci.system.webservice.util.WSUtils; import java.util.ArrayList; import java.util.List; import java.util.Properties; import java.util.StringTokenizer; import javax.xml.rpc.ServiceException; import org.apache.log4j.Logger; import org.springframework.remoting.jaxrpc.ServletEndpointSupport; public class WSQueryImpl extends ServletEndpointSupport implements WSQuery{ private static Logger log = Logger.getLogger(WSQueryImpl.class); private static ApplicationService applicationService; private static ClassCache classCache; private static int resultCountPerQuery = 1000; public void destroy() { applicationService = null; classCache = null; resultCountPerQuery = 0; } protected void onInit() throws ServiceException { classCache = (ClassCache)getWebApplicationContext().getBean("ClassCache"); applicationService = (ApplicationService)getWebApplicationContext().getBean("ApplicationServiceImpl"); Properties systemProperties = (Properties) getWebApplicationContext().getBean("SystemProperties"); try { String count = systemProperties.getProperty("resultCountPerQuery"); log.debug("resultCountPerQuery: " + count); if (count != null) { resultCountPerQuery = Integer.parseInt(count); } } catch (Exception ex) { log.error("Exception initializing resultCountPerQuery: ", ex); throw new ServiceException("Exception initializing resultCountPerQuery: ", ex); } } public int getTotalNumberOfRecords(String targetClassName, Object criteria) throws Exception{ return getNestedCriteriaResultSet(targetClassName, criteria, 0).size(); } public List queryObject(String targetClassName, Object criteria) throws Exception { return query(targetClassName,criteria,0); } public List query(String targetClassName, Object criteria, int startIndex) throws Exception { List results = new ArrayList(); results = getNestedCriteriaResultSet(targetClassName, criteria, startIndex); List alteredResults = alterResultSet(results); return alteredResults; } private List getNestedCriteriaResultSet(String targetClassName, Object searchCriteria, int startIndex) throws Exception{ List results = new ArrayList(); String searchClassName = getSearchClassName(targetClassName); try { if(searchClassName != null && searchCriteria != null){ List<Object> paramList = new ArrayList<Object>(); paramList.add(searchCriteria); NestedCriteriaPath pathCriteria = new NestedCriteriaPath(targetClassName,paramList); results = applicationService.query(pathCriteria, startIndex, targetClassName); } else{ throw new Exception("Invalid arguments passed over to the server"); } } catch(Exception e) { log.error("WSQuery caught an exception: ", e); throw e; } return results; } public List getAssociation(Object source, String associationName, int startIndex) throws Exception { List results = new ArrayList(); String targetClassName = source.getClass().getName(); log.debug("targetClassName: " + targetClassName); String hql = "select obj."+associationName+" from "+targetClassName+" obj where obj = ?"; log.debug("hql: " + hql); List<Object> params = new ArrayList<Object>(); params.add(source); HQLCriteria criteria = new HQLCriteria(hql,params); results = getHQLResultSet(targetClassName, criteria, startIndex); List alteredResults = alterResultSet(results); return alteredResults; } private List getHQLResultSet(String targetClassName, Object searchCriteria, int startIndex) throws Exception{ List results = new ArrayList(); String searchClassName = getSearchClassName(targetClassName); try { if(searchClassName != null && searchCriteria != null){ results = applicationService.query(searchCriteria, startIndex, targetClassName); } else{ throw new Exception("Invalid arguments passed over to the server"); } } catch(Exception e) { log.error("WSQuery caught an exception: ", e); throw e; } return results; } private String getSearchClassName(String targetClassName)throws Exception { String searchClassName = ""; if(targetClassName.indexOf(",")>0){ StringTokenizer st = new StringTokenizer(targetClassName, ","); while(st.hasMoreTokens()){ String className = st.nextToken(); String validClassName = classCache.getQualifiedClassName(className); log.debug("validClassName: " + validClassName); searchClassName += validClassName + ","; } searchClassName = searchClassName.substring(0,searchClassName.lastIndexOf(",")); } else{ searchClassName = classCache.getQualifiedClassName(targetClassName); } if(searchClassName == null){ throw new Exception("Invalid class name: " + targetClassName); } return searchClassName; } private List alterResultSet(List results) { List objList; if (results instanceof ListProxy) { ListProxy listProxy = (ListProxy)results; objList = listProxy.getListChunk(); } else { objList = results; } WSUtils util = new WSUtils(); objList = (List)util.convertToProxy(null, objList); return objList; } }
NCIP/cacore-sdk-pre411
SDK4/system/src/gov/nih/nci/system/webservice/WSQueryImpl.java
Java
bsd-3-clause
5,667
[ 30522, 1013, 1008, 1048, 1008, 9385, 23969, 8490, 2527, 4007, 6786, 5183, 1012, 1008, 9385, 18952, 2278, 1008, 1008, 5500, 2104, 1996, 9808, 2072, 1011, 4844, 18667, 2094, 1017, 1011, 11075, 6105, 1012, 1008, 2156, 8299, 1024, 1013, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.giantbomb.main; public class ListOfGamesGenerator { public static void main(final String[] args) { } }
brentnash/gbecho
src/main/java/com/giantbomb/main/ListOfGamesGenerator.java
Java
mit
137
[ 30522, 7427, 4012, 1012, 5016, 5092, 14905, 1012, 2364, 1025, 2270, 2465, 2862, 11253, 26393, 6914, 6906, 4263, 1063, 2270, 10763, 11675, 2364, 1006, 2345, 5164, 1031, 1033, 12098, 5620, 1007, 1063, 1065, 1065, 102, 0, 0, 0, 0, 0, 0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#!/bin/bash set -ueo pipefail # Usage: ./EVAL.sh gold_amr_file # Output will be in $MODEL_DIR/gold_amr_file.parsed if [ -z "$JAMR_HOME" ]; then echo 'Error: please source config script' exit 1 fi if [ ! -f "${MODEL_DIR}/stage1-weights" ]; then echo "Error: cannot find weights file ${MODEL_DIR}/stage1-weights." echo "Please train JAMR or download and extract weights file to ${MODEL_DIR}" exit 1 fi if [ -z "$1" ]; then echo 'Usage: EVAL.sh gold_amr_file (iteration)' exit 1 fi TEST_FILE="$(cd "$(dirname "$1")"; pwd)"/"$(basename $1)" STAGE1_WEIGHTS="${MODEL_DIR}/stage1-weights" if [ -z "$2" ]; then STAGE2_WEIGHTS="${MODEL_DIR}/stage2-weights" OUTPUT="${MODEL_DIR}/$(basename $1)" else STAGE2_WEIGHTS="${MODEL_DIR}/stage2-weights.iter$2" OUTPUT="${MODEL_DIR}/$(basename $1).iter$2" fi INPUT="$OUTPUT.snt" #### Parse #### ${JAMR_HOME}/run AMRParser \ --stage1-concept-table "${MODEL_DIR}/conceptTable.train" \ --stage1-weights "${STAGE1_WEIGHTS}" \ --stage2-weights "${STAGE2_WEIGHTS}" \ --dependencies "${OUTPUT}.deps" \ --training-data "${OUTPUT}.aligned.no_opN" \ --ner "${OUTPUT}.IllinoisNER" \ --tok "${OUTPUT}.snt.tok" \ -v 0 \ --stage1-eval \ ${PARSER_OPTIONS} \ < "${INPUT}" \ > "${OUTPUT}.parsed" \ 2> "${OUTPUT}.parsed.err" ${JAMR_HOME}/run AMRParser \ --stage1-oracle \ --stage1-concept-table "${MODEL_DIR}/conceptTable.train" \ --stage1-weights "${STAGE1_WEIGHTS}" \ --stage2-weights "${STAGE2_WEIGHTS}" \ --dependencies "${OUTPUT}.deps" \ --training-data "${OUTPUT}.aligned.no_opN" \ --ner "${OUTPUT}.IllinoisNER" \ --tok "${OUTPUT}.snt.tok" \ -v 0 \ ${PARSER_OPTIONS} \ < "${INPUT}" \ > "${OUTPUT}.parsed-gold-concepts" \ 2> "${OUTPUT}.parsed-gold-concepts.err" #rm "$OUTPUT.deps" "$OUTPUT.IllinoisNER" "$OUTPUT.tok" "$OUTPUT.snt.tok" "$OUTPUT.snt" "$OUTPUT.aligned.no_opN" echo "" echo " ----- Evaluation: Smatch (all stages) -----" | tee "$OUTPUT.results" "${JAMR_HOME}/scripts/smatch_v1_0/smatch_modified.py" --pr -f "${OUTPUT}.parsed" "$TEST_FILE" 2>&1 | tee -a "$OUTPUT.results" echo "" | tee -a "$OUTPUT.results" echo " ----- Evaluation: Smatch (gold concept ID) -----" | tee -a "$OUTPUT.results" "${JAMR_HOME}/scripts/smatch_v1_0/smatch_modified.py" --pr -f "${OUTPUT}.parsed-gold-concepts" "$TEST_FILE" 2>&1 | tee -a "$OUTPUT.results" echo "" | tee -a "$OUTPUT.results" echo " ----- Evaluation: Spans -----" | tee -a "$OUTPUT.results" tail -n 3 "$OUTPUT.parsed.err" | tee -a "$OUTPUT.results"
jflanigan/jamr
scripts/EVAL_no_preprocess.sh
Shell
bsd-2-clause
2,531
[ 30522, 1001, 999, 1013, 8026, 1013, 24234, 2275, 1011, 1057, 8780, 8667, 7011, 4014, 1001, 8192, 1024, 1012, 1013, 9345, 2140, 1012, 14021, 2751, 1035, 2572, 2099, 1035, 5371, 1001, 6434, 2097, 2022, 1999, 1002, 2944, 1035, 16101, 1013, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
namespace LSLib.LS.Enums { public enum CompressionLevel { FastCompression, DefaultCompression, MaxCompression }; }
Norbyte/lslib
LSLib/LS/Enums/CompressionLevel.cs
C#
mit
161
[ 30522, 3415, 15327, 1048, 14540, 12322, 1012, 1048, 2015, 1012, 4372, 18163, 1063, 2270, 4372, 2819, 13379, 20414, 2884, 1063, 3435, 9006, 20110, 3258, 1010, 12398, 9006, 20110, 3258, 1010, 4098, 9006, 20110, 3258, 1065, 1025, 1065, 102, 0,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
//======================================================================== // // SplashFTFont.cc // //======================================================================== //======================================================================== // // Modified under the Poppler project - http://poppler.freedesktop.org // // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // // Copyright (C) 2005, 2007-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Kristian Høgsberg <krh@bitplanet.net> // Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git // //======================================================================== #include <config.h> #if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H #ifdef USE_GCC_PRAGMAS #pragma implementation #endif #include <ft2build.h> #include FT_OUTLINE_H #include FT_SIZES_H #include FT_GLYPH_H #include "goo/gmem.h" #include "SplashMath.h" #include "SplashGlyphBitmap.h" #include "SplashPath.h" #include "SplashFTFontEngine.h" #include "SplashFTFontFile.h" #include "SplashFTFont.h" //------------------------------------------------------------------------ static int glyphPathMoveTo(const FT_Vector *pt, void *path); static int glyphPathLineTo(const FT_Vector *pt, void *path); static int glyphPathConicTo(const FT_Vector *ctrl, const FT_Vector *pt, void *path); static int glyphPathCubicTo(const FT_Vector *ctrl1, const FT_Vector *ctrl2, const FT_Vector *pt, void *path); //------------------------------------------------------------------------ // SplashFTFont //------------------------------------------------------------------------ SplashFTFont::SplashFTFont(SplashFTFontFile *fontFileA, SplashCoord *matA, SplashCoord *textMatA): SplashFont(fontFileA, matA, textMatA, fontFileA->engine->aa), enableFreeTypeHinting(fontFileA->engine->enableFreeTypeHinting) { FT_Face face; double div; int x, y; face = fontFileA->face; if (FT_New_Size(face, &sizeObj)) { return; } face->size = sizeObj; size = splashSqrt(mat[2]*mat[2] + mat[3]*mat[3]); if (FT_Set_Pixel_Sizes(face, 0, (int)size)) { return; } // if the textMat values are too small, FreeType's fixed point // arithmetic doesn't work so well textScale = splashSqrt(textMat[2]*textMat[2] + textMat[3]*textMat[3]) / size; div = face->bbox.xMax > 20000 ? 65536 : 1; // transform the four corners of the font bounding box -- the min // and max values form the bounding box of the transformed font x = (int)((mat[0] * face->bbox.xMin + mat[2] * face->bbox.yMin) / (div * face->units_per_EM)); xMin = xMax = x; y = (int)((mat[1] * face->bbox.xMin + mat[3] * face->bbox.yMin) / (div * face->units_per_EM)); yMin = yMax = y; x = (int)((mat[0] * face->bbox.xMin + mat[2] * face->bbox.yMax) / (div * face->units_per_EM)); if (x < xMin) { xMin = x; } else if (x > xMax) { xMax = x; } y = (int)((mat[1] * face->bbox.xMin + mat[3] * face->bbox.yMax) / (div * face->units_per_EM)); if (y < yMin) { yMin = y; } else if (y > yMax) { yMax = y; } x = (int)((mat[0] * face->bbox.xMax + mat[2] * face->bbox.yMin) / (div * face->units_per_EM)); if (x < xMin) { xMin = x; } else if (x > xMax) { xMax = x; } y = (int)((mat[1] * face->bbox.xMax + mat[3] * face->bbox.yMin) / (div * face->units_per_EM)); if (y < yMin) { yMin = y; } else if (y > yMax) { yMax = y; } x = (int)((mat[0] * face->bbox.xMax + mat[2] * face->bbox.yMax) / (div * face->units_per_EM)); if (x < xMin) { xMin = x; } else if (x > xMax) { xMax = x; } y = (int)((mat[1] * face->bbox.xMax + mat[3] * face->bbox.yMax) / (div * face->units_per_EM)); if (y < yMin) { yMin = y; } else if (y > yMax) { yMax = y; } // This is a kludge: some buggy PDF generators embed fonts with // zero bounding boxes. if (xMax == xMin) { xMin = 0; xMax = (int)size; } if (yMax == yMin) { yMin = 0; yMax = (int)((SplashCoord)1.2 * size); } // compute the transform matrix #if USE_FIXEDPOINT matrix.xx = (FT_Fixed)((mat[0] / size).getRaw()); matrix.yx = (FT_Fixed)((mat[1] / size).getRaw()); matrix.xy = (FT_Fixed)((mat[2] / size).getRaw()); matrix.yy = (FT_Fixed)((mat[3] / size).getRaw()); textMatrix.xx = (FT_Fixed)((textMat[0] / (textScale * size)).getRaw()); textMatrix.yx = (FT_Fixed)((textMat[1] / (textScale * size)).getRaw()); textMatrix.xy = (FT_Fixed)((textMat[2] / (textScale * size)).getRaw()); textMatrix.yy = (FT_Fixed)((textMat[3] / (textScale * size)).getRaw()); #else matrix.xx = (FT_Fixed)((mat[0] / size) * 65536); matrix.yx = (FT_Fixed)((mat[1] / size) * 65536); matrix.xy = (FT_Fixed)((mat[2] / size) * 65536); matrix.yy = (FT_Fixed)((mat[3] / size) * 65536); textMatrix.xx = (FT_Fixed)((textMat[0] / (size * textScale)) * 65536); textMatrix.yx = (FT_Fixed)((textMat[1] / (size * textScale)) * 65536); textMatrix.xy = (FT_Fixed)((textMat[2] / (size * textScale)) * 65536); textMatrix.yy = (FT_Fixed)((textMat[3] / (size * textScale)) * 65536); #endif } SplashFTFont::~SplashFTFont() { } GBool SplashFTFont::getGlyph(int c, int xFrac, int yFrac, SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) { return SplashFont::getGlyph(c, xFrac, 0, bitmap, x0, y0, clip, clipRes); } static FT_Int32 getFTLoadFlags(GBool aa, GBool enableFreeTypeHinting) { if (aa && enableFreeTypeHinting) return FT_LOAD_NO_BITMAP; else if (aa && !enableFreeTypeHinting) return FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP; else if (!aa && enableFreeTypeHinting) return FT_LOAD_DEFAULT; else return FT_LOAD_NO_HINTING; } GBool SplashFTFont::makeGlyph(int c, int xFrac, int yFrac, SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) { SplashFTFontFile *ff; FT_Vector offset; FT_GlyphSlot slot; FT_UInt gid; int rowSize; Guchar *p, *q; int i; ff = (SplashFTFontFile *)fontFile; ff->face->size = sizeObj; offset.x = (FT_Pos)(int)((SplashCoord)xFrac * splashFontFractionMul * 64); offset.y = 0; FT_Set_Transform(ff->face, &matrix, &offset); slot = ff->face->glyph; if (ff->codeToGID && c < ff->codeToGIDLen) { gid = (FT_UInt)ff->codeToGID[c]; } else { gid = (FT_UInt)c; } if (ff->trueType && gid == 0) { // skip the TrueType notdef glyph return gFalse; } if (FT_Load_Glyph(ff->face, gid, getFTLoadFlags(aa, enableFreeTypeHinting))) { return gFalse; } FT_Glyph_Metrics *glyphMetrics = &(ff->face->glyph->metrics); // prelimirary values from FT_Glyph_Metrics bitmap->x = splashRound(-glyphMetrics->horiBearingX / 64.0); bitmap->y = splashRound(glyphMetrics->horiBearingY / 64.0); bitmap->w = splashRound(glyphMetrics->width / 64.0); bitmap->h = splashRound(glyphMetrics->height / 64.0); *clipRes = clip->testRect(x0 - bitmap->x, y0 - bitmap->y, x0 - bitmap->x + bitmap->w, y0 - bitmap->y + bitmap->h); if (*clipRes == splashClipAllOutside) { bitmap->freeData = gFalse; return gTrue; } if (FT_Render_Glyph(slot, aa ? ft_render_mode_normal : ft_render_mode_mono)) { return gFalse; } bitmap->x = -slot->bitmap_left; bitmap->y = slot->bitmap_top; bitmap->w = slot->bitmap.width; bitmap->h = slot->bitmap.rows; bitmap->aa = aa; if (aa) { rowSize = bitmap->w; } else { rowSize = (bitmap->w + 7) >> 3; } bitmap->data = (Guchar *)gmallocn_checkoverflow(rowSize, bitmap->h); bitmap->freeData = gTrue; for (i = 0, p = bitmap->data, q = slot->bitmap.buffer; i < bitmap->h; ++i, p += rowSize, q += slot->bitmap.pitch) { memcpy(p, q, rowSize); } return gTrue; } double SplashFTFont::getGlyphAdvance(int c) { SplashFTFontFile *ff; FT_Vector offset; FT_UInt gid; FT_Matrix identityMatrix; ff = (SplashFTFontFile *)fontFile; // init the matrix identityMatrix.xx = 65536; // 1 in 16.16 format identityMatrix.xy = 0; identityMatrix.yx = 0; identityMatrix.yy = 65536; // 1 in 16.16 format // init the offset offset.x = 0; offset.y = 0; ff->face->size = sizeObj; FT_Set_Transform(ff->face, &identityMatrix, &offset); if (ff->codeToGID && c < ff->codeToGIDLen) { gid = (FT_UInt)ff->codeToGID[c]; } else { gid = (FT_UInt)c; } if (ff->trueType && gid == 0) { // skip the TrueType notdef glyph return -1; } if (FT_Load_Glyph(ff->face, gid, getFTLoadFlags(aa, enableFreeTypeHinting))) { return -1; } // 64.0 is 1 in 26.6 format return ff->face->glyph->metrics.horiAdvance / 64.0 / size; } struct SplashFTFontPath { SplashPath *path; SplashCoord textScale; GBool needClose; }; SplashPath *SplashFTFont::getGlyphPath(int c) { static FT_Outline_Funcs outlineFuncs = { #if FREETYPE_MINOR <= 1 (int (*)(FT_Vector *, void *))&glyphPathMoveTo, (int (*)(FT_Vector *, void *))&glyphPathLineTo, (int (*)(FT_Vector *, FT_Vector *, void *))&glyphPathConicTo, (int (*)(FT_Vector *, FT_Vector *, FT_Vector *, void *))&glyphPathCubicTo, #else &glyphPathMoveTo, &glyphPathLineTo, &glyphPathConicTo, &glyphPathCubicTo, #endif 0, 0 }; SplashFTFontFile *ff; SplashFTFontPath path; FT_GlyphSlot slot; FT_UInt gid; FT_Glyph glyph; ff = (SplashFTFontFile *)fontFile; ff->face->size = sizeObj; FT_Set_Transform(ff->face, &textMatrix, NULL); slot = ff->face->glyph; if (ff->codeToGID && c < ff->codeToGIDLen) { gid = ff->codeToGID[c]; } else { gid = (FT_UInt)c; } if (ff->trueType && gid == 0) { // skip the TrueType notdef glyph return NULL; } if (FT_Load_Glyph(ff->face, gid, getFTLoadFlags(aa, enableFreeTypeHinting))) { return NULL; } if (FT_Get_Glyph(slot, &glyph)) { return NULL; } path.path = new SplashPath(); path.textScale = textScale; path.needClose = gFalse; FT_Outline_Decompose(&((FT_OutlineGlyph)glyph)->outline, &outlineFuncs, &path); if (path.needClose) { path.path->close(); } FT_Done_Glyph(glyph); return path.path; } static int glyphPathMoveTo(const FT_Vector *pt, void *path) { SplashFTFontPath *p = (SplashFTFontPath *)path; if (p->needClose) { p->path->close(); p->needClose = gFalse; } p->path->moveTo((SplashCoord)pt->x * p->textScale / 64.0, (SplashCoord)pt->y * p->textScale / 64.0); return 0; } static int glyphPathLineTo(const FT_Vector *pt, void *path) { SplashFTFontPath *p = (SplashFTFontPath *)path; p->path->lineTo((SplashCoord)pt->x * p->textScale / 64.0, (SplashCoord)pt->y * p->textScale / 64.0); p->needClose = gTrue; return 0; } static int glyphPathConicTo(const FT_Vector *ctrl, const FT_Vector *pt, void *path) { SplashFTFontPath *p = (SplashFTFontPath *)path; SplashCoord x0, y0, x1, y1, x2, y2, x3, y3, xc, yc; if (!p->path->getCurPt(&x0, &y0)) { return 0; } xc = (SplashCoord)ctrl->x * p->textScale / 64.0; yc = (SplashCoord)ctrl->y * p->textScale / 64.0; x3 = (SplashCoord)pt->x * p->textScale / 64.0; y3 = (SplashCoord)pt->y * p->textScale / 64.0; // A second-order Bezier curve is defined by two endpoints, p0 and // p3, and one control point, pc: // // p(t) = (1-t)^2*p0 + t*(1-t)*pc + t^2*p3 // // A third-order Bezier curve is defined by the same two endpoints, // p0 and p3, and two control points, p1 and p2: // // p(t) = (1-t)^3*p0 + 3t*(1-t)^2*p1 + 3t^2*(1-t)*p2 + t^3*p3 // // Applying some algebra, we can convert a second-order curve to a // third-order curve: // // p1 = (1/3) * (p0 + 2pc) // p2 = (1/3) * (2pc + p3) x1 = (SplashCoord)(1.0 / 3.0) * (x0 + (SplashCoord)2 * xc); y1 = (SplashCoord)(1.0 / 3.0) * (y0 + (SplashCoord)2 * yc); x2 = (SplashCoord)(1.0 / 3.0) * ((SplashCoord)2 * xc + x3); y2 = (SplashCoord)(1.0 / 3.0) * ((SplashCoord)2 * yc + y3); p->path->curveTo(x1, y1, x2, y2, x3, y3); p->needClose = gTrue; return 0; } static int glyphPathCubicTo(const FT_Vector *ctrl1, const FT_Vector *ctrl2, const FT_Vector *pt, void *path) { SplashFTFontPath *p = (SplashFTFontPath *)path; p->path->curveTo((SplashCoord)ctrl1->x * p->textScale / 64.0, (SplashCoord)ctrl1->y * p->textScale / 64.0, (SplashCoord)ctrl2->x * p->textScale / 64.0, (SplashCoord)ctrl2->y * p->textScale / 64.0, (SplashCoord)pt->x * p->textScale / 64.0, (SplashCoord)pt->y * p->textScale / 64.0); p->needClose = gTrue; return 0; } #endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
linsujie/apvlv
win32/poppler-src/splash/SplashFTFont.cc
C++
gpl-2.0
12,823
[ 30522, 1013, 1013, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 102...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta name="generator" content="PHPDoctor 2RC4 (http://phpdoctor.sourceforge.net/)"> <meta name="when" content="Wed, 14 Apr 2010 15:12:06 +0000"> <link rel="stylesheet" type="text/css" href="../../../stylesheet.css"> <link rel="start" href="../../../overview-summary.html"> <title>Globals (Doctrine)</title> </head> <body id="definition" onload="parent.document.title=document.title;"> <div class="header"> <h1>Doctrine</h1> <ul> <li><a href="../../../overview-summary.html">Overview</a></li> <li><a href="../../../doctrine/dbal/driver/package-summary.html">Package</a></li> <li class="active">Global</li> <li><a href="../../../overview-tree.html">Tree</a></li> <li><a href="../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../index-all.html">Index</a></li> </ul> </div> <div class="small_links"> <a href="../../../index.html" target="_top">Frames</a> <a href="../../../doctrine/dbal/driver/package-globals.html" target="_top">No frames</a> </div> <div class="small_links"> Summary: <a href="#summary_global">Global</a> Detail: <a href="#detail_global">Global</a> </div> <hr> <h1>Globals</h1> <hr> <div class="header"> <h1>Doctrine</h1> <ul> <li><a href="../../../overview-summary.html">Overview</a></li> <li><a href="../../../doctrine/dbal/driver/package-summary.html">Package</a></li> <li class="active">Global</li> <li><a href="../../../overview-tree.html">Tree</a></li> <li><a href="../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../index-all.html">Index</a></li> </ul> </div> <div class="small_links"> <a href="../../../index.html" target="_top">Frames</a> <a href="../../../doctrine/dbal/driver/package-globals.html" target="_top">No frames</a> </div> <div class="small_links"> Summary: <a href="#summary_global">Global</a> Detail: <a href="#detail_global">Global</a> </div> <hr> <p id="footer">This document was generated by <a href="http://peej.github.com/phpdoctor/">PHPDoctor: The PHP Documentation Creator</a></p> </body> </html>
j13k/doctrine1
lib/api/doctrine/dbal/driver/package-globals.html
HTML
mit
2,113
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 16129, 1018, 1012, 5890, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, 8917, 1013, 19817, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <!--[if IE]><![endif]--> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Class ExportRequest | Picturepark.SDK.V1 API </title> <meta name="viewport" content="width=device-width"> <meta name="title" content="Class ExportRequest | Picturepark.SDK.V1 API "> <meta name="generator" content="docfx 2.16.7.0"> <link rel="shortcut icon" href="../favicon.ico"> <link rel="stylesheet" href="../styles/docfx.vendor.css"> <link rel="stylesheet" href="../styles/docfx.css"> <link rel="stylesheet" href="../styles/main.css"> <meta property="docfx:navrel" content="../toc.html"> <meta property="docfx:tocrel" content="toc.html"> <meta property="docfx:rel" content="../"> </head> <body data-spy="scroll" data-target="#affix"> <div id="wrapper"> <header> <nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="../index.html"> <img id="logo" class="svg" src="../logo.svg" alt=""> </a> </div> <div class="collapse navbar-collapse" id="navbar"> <form class="navbar-form navbar-right" role="search" id="search"> <div class="form-group"> <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off"> </div> </form> </div> </div> </nav> <div class="subnav navbar navbar-default"> <div class="container hide-when-search" id="breadcrumb"> <ul class="breadcrumb"> <li></li> </ul> </div> </div> </header> <div role="main" class="container body-content"> <div id="search-results"> <div class="search-list"></div> <div class="sr-items"></div> <ul id="pagination"></ul> </div> </div> <div role="main" class="container body-content hide-when-search"> <div class="sidenav hide-when-search"> <a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a> <div class="sidetoggle collapse" id="sidetoggle"> <div id="sidetoc"></div> </div> </div> <div class="article row grid-right"> <div class="col-md-10"> <article class="content wrap" id="_content"> <h1 id="Picturepark_SDK_V1_ServiceProvider_Contract_ExportRequest" data-uid="Picturepark.SDK.V1.ServiceProvider.Contract.ExportRequest">Class ExportRequest </h1> <div class="markdown level0 summary"></div> <div class="markdown level0 conceptual"></div> <div class="inheritance"> <h5>Inheritance</h5> <div class="level0"><span class="xref">System.Object</span></div> <div class="level1"><span class="xref">ExportRequest</span></div> </div> <div class="inheritedMembers"> <h5>Inherited Members</h5> <div> <span class="xref">System.Object.ToString()</span> </div> <div> <span class="xref">System.Object.Equals(System.Object)</span> </div> <div> <span class="xref">System.Object.Equals(System.Object, System.Object)</span> </div> <div> <span class="xref">System.Object.ReferenceEquals(System.Object, System.Object)</span> </div> <div> <span class="xref">System.Object.GetHashCode()</span> </div> <div> <span class="xref">System.Object.GetType()</span> </div> <div> <span class="xref">System.Object.MemberwiseClone()</span> </div> </div> <h6><strong>Namespace</strong>:Picturepark.SDK.V1.ServiceProvider.Contract</h6> <h6><strong>Assembly</strong>:cs.temp.dll.dll</h6> <h5 id="Picturepark_SDK_V1_ServiceProvider_Contract_ExportRequest_syntax">Syntax</h5> <div class="codewrapper"> <pre><code class="lang-csharp hljs">public class ExportRequest</code></pre> </div> <h3 id="properties">Properties </h3> <a id="Picturepark_SDK_V1_ServiceProvider_Contract_ExportRequest_AccessToken_" data-uid="Picturepark.SDK.V1.ServiceProvider.Contract.ExportRequest.AccessToken*"></a> <h4 id="Picturepark_SDK_V1_ServiceProvider_Contract_ExportRequest_AccessToken" data-uid="Picturepark.SDK.V1.ServiceProvider.Contract.ExportRequest.AccessToken">AccessToken</h4> <div class="markdown level1 summary"></div> <div class="markdown level1 conceptual"></div> <h5 class="decalaration">Declaration</h5> <div class="codewrapper"> <pre><code class="lang-csharp hljs">public string AccessToken { get; set; }</code></pre> </div> <h5 class="propertyValue">Property Value</h5> <table class="table table-bordered table-striped table-condensed"> <thead> <tr> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><span class="xref">System.String</span></td> <td></td> </tr> </tbody> </table> <a id="Picturepark_SDK_V1_ServiceProvider_Contract_ExportRequest_FileName_" data-uid="Picturepark.SDK.V1.ServiceProvider.Contract.ExportRequest.FileName*"></a> <h4 id="Picturepark_SDK_V1_ServiceProvider_Contract_ExportRequest_FileName" data-uid="Picturepark.SDK.V1.ServiceProvider.Contract.ExportRequest.FileName">FileName</h4> <div class="markdown level1 summary"></div> <div class="markdown level1 conceptual"></div> <h5 class="decalaration">Declaration</h5> <div class="codewrapper"> <pre><code class="lang-csharp hljs">public string FileName { get; set; }</code></pre> </div> <h5 class="propertyValue">Property Value</h5> <table class="table table-bordered table-striped table-condensed"> <thead> <tr> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><span class="xref">System.String</span></td> <td></td> </tr> </tbody> </table> <a id="Picturepark_SDK_V1_ServiceProvider_Contract_ExportRequest_Path_" data-uid="Picturepark.SDK.V1.ServiceProvider.Contract.ExportRequest.Path*"></a> <h4 id="Picturepark_SDK_V1_ServiceProvider_Contract_ExportRequest_Path" data-uid="Picturepark.SDK.V1.ServiceProvider.Contract.ExportRequest.Path">Path</h4> <div class="markdown level1 summary"></div> <div class="markdown level1 conceptual"></div> <h5 class="decalaration">Declaration</h5> <div class="codewrapper"> <pre><code class="lang-csharp hljs">public string Path { get; set; }</code></pre> </div> <h5 class="propertyValue">Property Value</h5> <table class="table table-bordered table-striped table-condensed"> <thead> <tr> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><span class="xref">System.String</span></td> <td></td> </tr> </tbody> </table> <a id="Picturepark_SDK_V1_ServiceProvider_Contract_ExportRequest_UserId_" data-uid="Picturepark.SDK.V1.ServiceProvider.Contract.ExportRequest.UserId*"></a> <h4 id="Picturepark_SDK_V1_ServiceProvider_Contract_ExportRequest_UserId" data-uid="Picturepark.SDK.V1.ServiceProvider.Contract.ExportRequest.UserId">UserId</h4> <div class="markdown level1 summary"></div> <div class="markdown level1 conceptual"></div> <h5 class="decalaration">Declaration</h5> <div class="codewrapper"> <pre><code class="lang-csharp hljs">public string UserId { get; set; }</code></pre> </div> <h5 class="propertyValue">Property Value</h5> <table class="table table-bordered table-striped table-condensed"> <thead> <tr> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><span class="xref">System.String</span></td> <td></td> </tr> </tbody> </table> <h3 id="methods">Methods </h3> <a id="Picturepark_SDK_V1_ServiceProvider_Contract_ExportRequest_FromJson_" data-uid="Picturepark.SDK.V1.ServiceProvider.Contract.ExportRequest.FromJson*"></a> <h4 id="Picturepark_SDK_V1_ServiceProvider_Contract_ExportRequest_FromJson_System_String_" data-uid="Picturepark.SDK.V1.ServiceProvider.Contract.ExportRequest.FromJson(System.String)">FromJson(String)</h4> <div class="markdown level1 summary"></div> <div class="markdown level1 conceptual"></div> <h5 class="decalaration">Declaration</h5> <div class="codewrapper"> <pre><code class="lang-csharp hljs">public static ExportRequest FromJson(string data)</code></pre> </div> <h5 class="parameters">Parameters</h5> <table class="table table-bordered table-striped table-condensed"> <thead> <tr> <th>Type</th> <th>Name</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><span class="xref">System.String</span></td> <td><span class="parametername">data</span></td> <td></td> </tr> </tbody> </table> <h5 class="returns">Returns</h5> <table class="table table-bordered table-striped table-condensed"> <thead> <tr> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><a class="xref" href="Picturepark.SDK.V1.ServiceProvider.Contract.ExportRequest.html">ExportRequest</a></td> <td></td> </tr> </tbody> </table> <a id="Picturepark_SDK_V1_ServiceProvider_Contract_ExportRequest_ToJson_" data-uid="Picturepark.SDK.V1.ServiceProvider.Contract.ExportRequest.ToJson*"></a> <h4 id="Picturepark_SDK_V1_ServiceProvider_Contract_ExportRequest_ToJson" data-uid="Picturepark.SDK.V1.ServiceProvider.Contract.ExportRequest.ToJson">ToJson()</h4> <div class="markdown level1 summary"></div> <div class="markdown level1 conceptual"></div> <h5 class="decalaration">Declaration</h5> <div class="codewrapper"> <pre><code class="lang-csharp hljs">public string ToJson()</code></pre> </div> <h5 class="returns">Returns</h5> <table class="table table-bordered table-striped table-condensed"> <thead> <tr> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><span class="xref">System.String</span></td> <td></td> </tr> </tbody> </table> </article> </div> <div class="hidden-sm col-md-2" role="complementary"> <div class="sideaffix"> <div class="contribution"> <ul class="nav"> </ul> </div> <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix"> <!-- <p><a class="back-to-top" href="#top">Back to top</a><p> --> </nav> </div> </div> </div> </div> <footer> <div class="grad-bottom"></div> <div class="footer"> <div class="container"> <span class="pull-right"> <a href="#top">Back to top</a> </span> <span>Copyright © 2015-2017 Microsoft<br>Generated by <strong>DocFX</strong></span> </div> </div> </footer> </div> <script type="text/javascript" src="../styles/docfx.vendor.js"></script> <script type="text/javascript" src="../styles/docfx.js"></script> <script type="text/javascript" src="../styles/main.js"></script> </body> </html>
Picturepark/Picturepark.SDK.DotNet
docs/sdk/site/api/Picturepark.SDK.V1.ServiceProvider.Contract.ExportRequest.html
HTML
mit
14,549
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 999, 1011, 1011, 1031, 2065, 29464, 1033, 1028, 1026, 999, 1031, 2203, 10128, 1033, 1011, 1011, 1028, 1026, 16129, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_EVENTS_ANDROID_EVENT_HANDLER_ANDROID_H_ #define UI_EVENTS_ANDROID_EVENT_HANDLER_ANDROID_H_ #include "ui/events/events_export.h" namespace ui { class DragEventAndroid; class GestureEventAndroid; class KeyEventAndroid; class MotionEventAndroid; // Dispatches events to appropriate targets. The default implementations of // all of the specific handlers do nothing. Implementations should set // themselves to the ViewAndroid in the view tree to get the calls routed. // Use bool return type to stop propagating the call i.e. overriden method // should return true to indicate that the event was handled and stop // the processing. class EVENTS_EXPORT EventHandlerAndroid { public: virtual bool OnDragEvent(const DragEventAndroid& event); virtual bool OnTouchEvent(const MotionEventAndroid& event); virtual bool OnMouseEvent(const MotionEventAndroid& event); virtual bool OnMouseWheelEvent(const MotionEventAndroid& event); virtual bool OnGestureEvent(const GestureEventAndroid& event); virtual void OnSizeChanged(); virtual void OnPhysicalBackingSizeChanged(); virtual void OnBrowserControlsHeightChanged(); virtual bool OnGenericMotionEvent(const MotionEventAndroid& event); virtual bool OnKeyUp(const KeyEventAndroid& event); virtual bool DispatchKeyEvent(const KeyEventAndroid& event); virtual bool ScrollBy(float delta_x, float delta_y); virtual bool ScrollTo(float x, float y); }; } // namespace ui #endif // UI_EVENTS_ANDROID_EVENT_HANDLER_ANDROID_H_
endlessm/chromium-browser
ui/events/android/event_handler_android.h
C
bsd-3-clause
1,668
[ 30522, 1013, 1013, 9385, 2760, 1996, 10381, 21716, 5007, 6048, 1012, 2035, 2916, 9235, 1012, 1013, 1013, 2224, 1997, 2023, 3120, 3642, 2003, 9950, 2011, 1037, 18667, 2094, 1011, 2806, 6105, 2008, 2064, 2022, 1013, 1013, 2179, 1999, 1996, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
class UsersController < ApplicationController def index end end
csto/grapher
test/dummy/app/controllers/users_controller.rb
Ruby
mit
68
[ 30522, 2465, 5198, 8663, 13181, 10820, 1026, 4646, 8663, 13181, 10820, 13366, 5950, 2203, 2203, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30524, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// // ReadEntityBodyMode.cs // // Author: Martin Thwaites (github@my2cents.co.uk) // // Copyright (C) 2014 Martin Thwaites // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. namespace System.Web { public enum ReadEntityBodyMode { None, Classic, Bufferless, Buffered, } }
hardvain/mono-compiler
class/System.Web/System.Web/ReadEntityBodyMode.cs
C#
gpl-2.0
1,312
[ 30522, 1013, 1013, 1013, 1013, 3191, 4765, 3012, 23684, 5302, 3207, 1012, 20116, 1013, 1013, 1013, 1013, 3166, 1024, 3235, 16215, 29601, 2015, 1006, 21025, 2705, 12083, 1030, 2026, 2475, 13013, 2015, 1012, 2522, 1012, 2866, 1007, 1013, 1013...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <!-- Distributed under both the W3C Test Suite License [1] and the W3C 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the policies and contribution forms [3]. [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license [3] http://www.w3.org/2004/10/27-testcases --> <html> <head> <title>Shadow DOM Test: A_04_07_01</title> <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> <link rel="help" href="http://www.w3.org/TR/2013/WD-shadow-dom-20130514/#multiple-shadow-subtrees"> <meta name="assert" content="Composition:Composition algorithm"> <script src="../../../../../../resources/testharness.js"></script> <script src="../../../../../../resources/testharnessreport.js"></script> <script src="../../testcommon.js"></script> </head> <body> <div id="log"></div> <script> test(unit(function (ctx) { var d = newRenderedHTMLDocument(ctx); var div = d.createElement('div'); div.innerHTML = '' + '<ul id="host">' + '<li id="li1" class="shadow">' + '<a id="a11" class="cl1" href="#">Link11 Shadow</a>' + '<a id="a12" class="cl2" href="#">Link12 Shadow</a>' + '<a id="a13" class="cl1" href="#">Link13 Shadow</a>' + '</li>' + '<li id="li2">' + '<a id="a21" href="#">Link21</a><a id="a22" href="#">Link22</a>' + '</li>' + '<li id="li3" class="shadow">' + '<a id="a31" href="#">Link31 Shadow</a><a id="a32" href="#">Link32 Shadow</a>' + '</li>' + '<li id="li4" class="shadow2">' + '<a id="a41" href="#">Link41 Shadow 2</a><a id="a42" href="#">Link22 Shadow 2</a>' + '</li>' + '<li id="li5" class="shadow2">' + '<a id="a51" href="#">Link51 Shadow</a><a id="a52" href="#">Link52 Shadow 2</a>' + '</li>' + '</ul>'; d.body.appendChild(div); //make nested shadow tree to check the reprojection var li1 = d.querySelector('#li1'); var s = li1.createShadowRoot(); var shadowLI1 = document.createElement('li'); shadowLI1.innerHTML = '<content select=".cl1"></content>'; s.appendChild(shadowLI1); //Shadow root to play with var ul = d.querySelector('#host'); //make an old shadow tree var s2 = ul.createShadowRoot(); var div2 = d.createElement('div'); div2.innerHTML = '<ul><content select=".shadow2"></content></ul>'; s2.appendChild(div2); // At this point visible: li4 and li5 assert_true(d.querySelector('#li4').offsetTop > 0, 'Point 1: Node that match insertion ' + 'point criteria should be rendered'); assert_true(d.querySelector('#li5').offsetTop > 0, 'Point 2: Node that match insertion ' + 'point criteria should be rendered'); assert_equals(d.querySelector('#li1').offsetTop, 0, 'Point 3: Node that doen\'t match ' + 'insertion point criteria shouldn\'t be rendered'); assert_equals(d.querySelector('#li2').offsetTop, 0, 'Point 4: Node that doen\'t match ' + 'insertion point criteria shouldn\'t be rendered'); assert_equals(d.querySelector('#li3').offsetTop, 0, 'Point 5: Node that doen\'t match ' + 'insertion point criteria shouldn\'t be rendered'); //check the nested tree assert_equals(d.querySelector('#a11').offsetTop, 0, 'Point 6: Aleady distributed nodes should behave like a shadow host child nodes'); assert_equals(d.querySelector('#a13').offsetTop, 0, 'Point 7: Aleady distributed nodes should behave like a shadow host child nodes'); assert_equals(d.querySelector('#a12').offsetTop, 0, 'Point 8: Aleady distributed nodes should behave like a shadow host child nodes'); //make a young shadow tree var s3 = ul.createShadowRoot(); var div3 = d.createElement('div'); div3.innerHTML = '<ul><content select=".shadow"></content></ul>'; s3.appendChild(div3); //At this point: li1 and li3 visible, others not assert_true(d.querySelector('#li1').offsetTop > 0, 'Point 21: Node that match insertion ' + 'point criteria should be rendered'); assert_true(d.querySelector('#li3').offsetTop > 0, 'Point 22: Node that match insertion ' + 'point criteria should be rendered'); assert_equals(d.querySelector('#li2').offsetTop, 0, 'Point 23: Node that doen\'t match ' + 'insertion point criteria shouldn\'t be rendered'); assert_equals(d.querySelector('#li4').offsetTop, 0, 'Point 24: Node that doen\'t match ' + 'insertion point criteria shouldn\'t be rendered'); assert_equals(d.querySelector('#li5').offsetTop, 0, 'Point 25: Node that doen\'t match ' + 'insertion point criteria shouldn\'t be rendered'); //check the reprojected nodes (a11 and a13 visible, a12 not) assert_true(d.querySelector('#a11').offsetTop > 0, 'Point 26: Aleady distributed nodes should behave like a shadow host child nodes'); assert_equals(d.querySelector('#a12').offsetTop, 0, 'Point 27: Aleady distributed nodes should behave like a shadow host child nodes'); assert_true(d.querySelector('#a13').offsetTop > 0, 'Point 28: Aleady distributed nodes should behave like a shadow host child nodes'); var shadow = d.createElement('shadow'); s3.appendChild(shadow); //At this point: li1, li3, li4 and li5 visible li2 not assert_true(d.querySelector('#li1').offsetTop > 0, 'Point 31: Node that match insertion ' + 'point criteria should be rendered'); assert_true(d.querySelector('#li3').offsetTop > 0, 'Point 32: Node that match insertion ' + 'point criteria should be rendered'); assert_equals(d.querySelector('#li2').offsetTop, 0, 'Point 33: Node that doen\'t match ' + 'insertion point criteria shouldn\'t be rendered'); assert_true(d.querySelector('#li4').offsetTop > 0, 'Point 34: Node that doen\'t match ' + 'insertion point criteria shouldn\'t be rendered'); assert_true(d.querySelector('#li5').offsetTop > 0, 'Point 35: Node that doen\'t match ' + 'insertion point criteria shouldn\'t be rendered'); //check the reprojected nodes (a11 and a13 visible, a12 not) assert_true(d.querySelector('#a11').offsetTop > 0, 'Point 36: Aleady distributed nodes should behave like a shadow host child nodes'); assert_equals(d.querySelector('#a12').offsetTop, 0, 'Point 37: Aleady distributed nodes should behave like a shadow host child nodes'); assert_true(d.querySelector('#a13').offsetTop > 0, 'Point 38: Aleady distributed nodes should behave like a shadow host child nodes'); var shadow2 = d.createElement('shadow'); s3.appendChild(shadow2); // Nothing should be changed //At this point: li1, li3, li4 and li5 visible li2 not assert_true(d.querySelector('#li1').offsetTop > 0, 'Point 41: Node that match insertion ' + 'point criteria should be rendered'); assert_true(d.querySelector('#li3').offsetTop > 0, 'Point 42: Node that match insertion ' + 'point criteria should be rendered'); assert_equals(d.querySelector('#li2').offsetTop, 0, 'Point 43: Node that doen\'t match ' + 'insertion point criteria shouldn\'t be rendered'); assert_true(d.querySelector('#li4').offsetTop > 0, 'Point 44: Node that doen\'t match ' + 'insertion point criteria shouldn\'t be rendered'); assert_true(d.querySelector('#li5').offsetTop > 0, 'Point 45: Node that doen\'t match ' + 'insertion point criteria shouldn\'t be rendered'); //check the reprojected nodes (a11 and a13 visible, a12 not) assert_true(d.querySelector('#a11').offsetTop > 0, 'Point 46: Aleady distributed nodes should behave like a shadow host child nodes'); assert_equals(d.querySelector('#a12').offsetTop, 0, 'Point 47: Aleady distributed nodes should behave like a shadow host child nodes'); assert_true(d.querySelector('#a13').offsetTop > 0, 'Point 48: Aleady distributed nodes should behave like a shadow host child nodes'); }), 'A_04_07_01'); </script> </body> </html>
was4444/chromium.src
third_party/WebKit/LayoutTests/imported/web-platform-tests/shadow-dom/untriaged/shadow-trees/composition/test-001.html
HTML
bsd-3-clause
7,776
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 999, 1011, 1011, 5500, 2104, 2119, 1996, 1059, 2509, 2278, 3231, 7621, 6105, 1031, 1015, 1033, 1998, 1996, 1059, 2509, 2278, 1017, 1011, 11075, 18667, 2094, 6105, 1031, 1016, 1033, 1012, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
DEPS = presentacion.tex explicacion.tex include ../../../common/Makefile.include
unlp-so/contenidos
explicaciones/iso/practica1/Makefile
Makefile
unlicense
81
[ 30522, 2139, 4523, 1027, 2556, 21736, 1012, 16060, 4654, 24759, 5555, 10446, 1012, 16060, 2421, 1012, 1012, 1013, 1012, 1012, 1013, 1012, 1012, 1013, 2691, 1013, 2191, 8873, 2571, 1012, 2421, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.team2502.robot2017.command.autonomous; import edu.wpi.first.wpilibj.command.CommandGroup; public class ShinyFollow extends CommandGroup { /** * Does a follow */ public ShinyFollow() { addSequential(new AutoVisionCommand(200, 0.3)); } }
Team-2502/UpdatedRobotCode2017
src/com/team2502/robot2017/command/autonomous/ShinyFollow.java
Java
mit
267
[ 30522, 7427, 4012, 1012, 2136, 17788, 2692, 2475, 1012, 8957, 11387, 16576, 1012, 3094, 1012, 8392, 1025, 12324, 3968, 2226, 1012, 1059, 8197, 1012, 2034, 1012, 1059, 8197, 29521, 3501, 1012, 3094, 1012, 3094, 17058, 1025, 2270, 2465, 12538...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
.admanage-img p img{ width: 300px; height:100px; display: block; float: left; }
simaxuaner/Xinxin
sites/all/modules/custom/admanage/admanage.css
CSS
gpl-2.0
95
[ 30522, 1012, 4748, 24805, 3351, 1011, 10047, 2290, 1052, 10047, 2290, 1063, 9381, 1024, 3998, 2361, 2595, 1025, 4578, 1024, 2531, 2361, 2595, 1025, 4653, 1024, 3796, 1025, 14257, 1024, 2187, 1025, 1065, 102, 0, 0, 0, 0, 0, 0, 0, 0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#include <ctype.h> #include <stdio.h> #include <string.h> #include "geekcode.h" #include "lines.h" #include "parse.h" const char *parse_errors[] = { "Success", "Trailing text in data", "Missing alias", "Missing dependant", "Syntax error", "Unexpected EOF", "File error", }; /* * Parses the contents of data into line. * Returns 0 on success, error code on failure. */ static enum parse_errors_t process_line(struct answer *line, char *data) { char *last, *p; for ((p = strtok_r(data, " ", &last)); p && line->answer; (p = strtok_r(NULL, " ", &last)), line++) { int i; const struct elem *temp; char c=0; /* Skip lines we shouldn't display */ while (!line->display) line++; /* Parse each 'element' in the text, put the value in the * answer struct */ for (temp = line->contents, i=0; temp[i].alias; i++) { char *n, buf[256]; const char *s; /* * If the line is dependant, iterate over the possible * aliases it could be. If it's not, this loop will * only be entered once. */ if (line->dependant) { if (sscanf(p, temp[i].alias, &c)) snprintf(buf, sizeof(buf), temp[i].alias, c); else continue; s = (const char *)&buf; } else { s = temp[i].alias; } /* Kill those pesky newlines */ n = strchr(p, '\n'); if (n) *n = '\0'; if (!strcmp(s, p)) goto out; } return EALIAS; out: line->answer = i+1; /* Set the answer of the dependant */ if (c) { const struct elem *temp; int i; for (temp = (line-1)->contents, i = 0; temp->alias; temp++, i++) if (*(temp->alias) == c) goto found; return EDEPENDANT; found: (line-1)->answer = i+1; } } /* There's something left! */ if ((p && isalnum((unsigned char )*p)) || line->answer) return ETRAILING; return SUCCESS; } /* * Reads geekcode from in and initialises the structures in lines * appropriately. * Returns 0 on success, error code on failure. */ static int parse_header(FILE *in, unsigned *line_count) { char data[1024]; *line_count = 0; while (fgets(data, sizeof(data), in)) { (*line_count)++; if (strcmp(data, "-----BEGIN GEEK CODE BLOCK-----\n")) continue; /* Skip version line */ /* XXX: Check version some way? */ if (!fgets(data, sizeof(data), in)) return -1; (*line_count)++; return 0; } return -1; } static int parse_code(FILE *in, unsigned *line_count) { char data[1024]; struct answer **cur_line = lines; while (fgets(data, sizeof(data), in)) { int ret; (*line_count)++; if (!strcmp(data, "------END GEEK CODE BLOCK------\n")) return 0; if (!*cur_line) return ESYNTAX; if ((ret = process_line(*cur_line, data))) return ret; cur_line++; } return -1; } unsigned read_code(FILE *in, unsigned *line_count) { int ret; ret = parse_header(in, line_count); if (!ret) ret = parse_code(in, line_count); if (!ret) return 0; if (ret < 0) { if (ferror(in)) return EFERROR; else return EEOF; } return ret; }
masterdriverz/geekcode
parse.c
C
gpl-2.0
2,988
[ 30522, 1001, 2421, 1026, 14931, 18863, 1012, 1044, 1028, 1001, 2421, 1026, 2358, 20617, 1012, 1044, 1028, 1001, 2421, 1026, 5164, 1012, 1044, 1028, 1001, 2421, 1000, 29294, 16044, 1012, 1044, 1000, 1001, 2421, 1000, 3210, 1012, 1044, 1000, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.algorithms.sorting; public class MergeBU { public static void sort(Comparable[] a) { Comparable[] aux = new Comparable[a.length]; int N = a.length; for (int size = 1; size < N; size = size*2) { for (int i = 0; i < N; i = i + size) merge(a, aux, i, i+size-1, Math.min(i+size+size-1, N-1)); } } private static boolean less(Comparable v, Comparable w) { return v.compareTo(w) < 0; } private static void merge(Comparable[] a, Comparable[] aux, int lo, int mid, int hi) { assert isSorted(a, lo, mid); assert isSorted(a, mid+1, hi); for (int i = lo; i < hi; i++) aux[i] = a[i]; int i = lo, j = mid + 1; for (int k = lo; k < hi; k ++) { if (i > mid) a[k] = aux[j++]; else if (j > hi) a[k] = aux[i++]; if (less(aux[j], aux[i])) a[k] = aux[j++]; else a[k] = aux[i++]; } assert isSorted(a, lo, hi); } private static boolean isSorted(Comparable[] a, int lo, int hi) { for (int i = lo; i < hi; i ++) { if (less(a[i+1], a[i])) return false; } return true; } }
SkullTech/algorithms-princeton
Algorithms/src/sorting/MergeBU.java
Java
mit
1,193
[ 30522, 7427, 4012, 1012, 13792, 1012, 22210, 1025, 2270, 2465, 13590, 8569, 1063, 2270, 10763, 11675, 4066, 1006, 12435, 1031, 1033, 1037, 1007, 1063, 12435, 1031, 1033, 19554, 1027, 2047, 12435, 1031, 1037, 1012, 3091, 1033, 1025, 20014, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import unittest import subprocess import os import platform import shutil from os.path import join, normpath, abspath, split import sys env_path = "/".join(os.path.dirname(os.path.abspath(__file__)).split('/')[:-1]) sys.path.insert(0, env_path) import littlechef # Set some convenience variables test_path = split(normpath(abspath(__file__)))[0] littlechef_top = normpath(join(test_path, '..')) if platform.system() == 'Windows': fix = join(littlechef_top, 'fix.cmd') WIN32 = True else: fix = join(littlechef_top, 'fix') WIN32 = False class BaseTest(unittest.TestCase): def setUp(self): """Change to the test directory""" self.set_location() def set_location(self, location=test_path): """Change directories to a known location""" os.chdir(location) def execute(self, call): """Executes a command and returns stdout and stderr""" if WIN32: proc = subprocess.Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE) else: proc = subprocess.Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return proc.communicate() class TestConfig(BaseTest): def tearDown(self): self.set_location() def test_not_a_kitchen(self): """Should exit with error when not a kitchen directory""" # Change to parent dir, which has no nodes/cookbooks/roles dir self.set_location(littlechef_top) # Call fix from the current directory above "tests/" resp, error = self.execute([fix, 'node:a']) self.assertTrue("Fatal error" in error, resp) self.assertTrue( 'No {0} file found'.format(littlechef.CONFIGFILE) in error, error) self.assertEquals(resp, "", resp) def test_version(self): """Should output the correct Little Chef version""" resp, error = self.execute([fix, '-v']) self.assertEquals(resp, "", "Response should be empty, version should be in stderr") self.assertTrue( 'LittleChef {0}'.format(littlechef.__version__) in error) def test_list_commands(self): """Should output a list of available commands""" resp, error = self.execute([fix, '-l']) self.assertEquals(error, "") expected = "Starts a Chef Solo configuration run" self.assertTrue(expected in resp) commands = resp.split('\nAvailable commands:\n')[-1] commands = filter(None, commands.split('\n')) self.assertEquals(len(commands), 21) def test_verbose(self): """Should turn on verbose output""" resp, error = self.execute([fix, '--verbose', 'list_nodes']) self.assertEquals(error, "", error) self.assertTrue('Verbose output on' in resp, resp) def test_debug(self): """Should turn on debug loglevel""" resp, error = self.execute([fix, '--debug', 'list_nodes']) self.assertEquals(error, "", error) self.assertTrue('Debug level on' in resp, resp) class TestEnvironment(BaseTest): def test_no_valid_value(self): """Should error out when the env value is empty or is a fabric task""" resp, error = self.execute([fix, 'list_nodes', '--env']) self.assertEquals(resp, "") self.assertTrue( "error: argument -e/--env: expected one argument" in error, error) resp, error = self.execute([fix, '--env', 'list_nodes']) self.assertEquals(resp, "") self.assertTrue("error: No value given for --env" in error, error) cmd = [fix, '--env', 'nodes_with_role:base', 'role:base'] resp, error = self.execute(cmd) self.assertEquals(resp, "") self.assertTrue("error: No value given for --env" in error, error) def test_valid_environment(self): """Should set the chef_environment value when one is given""" resp, error = self.execute([fix, 'list_nodes', '--env', 'staging']) self.assertEquals(error, "", error) self.assertTrue("Environment: staging" in resp, resp) class TestRunner(BaseTest): def test_no_node_given(self): """Should abort when no node is given""" resp, error = self.execute([fix, 'node:']) self.assertTrue("Fatal error: No node was given" in error) def test_plugin(self): """Should execute the given plugin""" resp, error = self.execute([fix, 'node:testnode1', 'plugin:notthere']) expected = ", could not find 'notthere.py' in the plugin directory" self.assertTrue(expected in error, resp + error) resp, error = self.execute([fix, 'node:testnode1', 'plugin:bad']) expected = "Found plugin 'bad', but it seems to have a syntax error:" expected += " invalid syntax (bad.py, line 6)" self.assertTrue(expected in error, resp + error) resp, error = self.execute([fix, 'node:testnode1', 'plugin:dummy']) expected = "Executing plugin '{0}' on {1}".format("dummy", "testnode1") self.assertTrue(expected in resp, resp + error) def test_list_plugins(self): """Should print a list of available plugins""" resp, error = self.execute([fix, 'list_plugins']) self.assertTrue("List of available plugins:" in resp, resp) self.assertTrue("bad: Plugin has a syntax error" in resp, resp) self.assertTrue("dummy: Dummy LittleChef plugin" in resp, resp) class TestCookbooks(BaseTest): def test_list_recipes(self): """Should list available recipes""" resp, error = self.execute([fix, 'list_recipes']) self.assertEquals(error, "") self.assertTrue('subversion::client' in resp) self.assertTrue('subversion::server' in resp) def test_list_recipes_site_cookbooks(self): """Should give priority to site-cookbooks information""" resp, error = self.execute([fix, 'list_recipes']) self.assertTrue('Modified by site-cookbooks' in resp) def test_list_recipes_detailed(self): """Should show a detailed list of available recipes""" resp, error = self.execute([fix, 'list_recipes_detailed']) self.assertTrue('subversion::client' in resp) for field in ['description', 'version', 'dependencies', 'attributes']: self.assertTrue(field in resp) def test_list_recipes_detailed_site_cookbooks(self): """Should show a detailed list of available recipes with site-cookbook priority """ resp, error = self.execute([fix, 'list_recipes_detailed']) self.assertTrue('0.8.4' in resp) def test_no_metadata(self): """Should abort if cookbook has no metadata.json""" bad_cookbook = join(test_path, 'cookbooks', 'bad_cookbook') os.mkdir(bad_cookbook) try: resp, error = self.execute([fix, 'list_recipes']) except OSError: self.fail("Couldn't execute {0}".format(fix)) finally: os.rmdir(bad_cookbook) expected = 'Fatal error: Cookbook "bad_cookbook" has no metadata.json' self.assertTrue(expected in error) class TestListRoles(BaseTest): def test_list_roles(self): """Should list all roles""" resp, error = self.execute([fix, 'list_roles']) self.assertTrue('base' in resp and 'example aplication' in resp) def test_list_roles_detailed(self): """Should show a detailed list of all roles""" resp, error = self.execute([fix, 'list_roles_detailed']) self.assertTrue('base' in resp and 'example aplication' in resp) class TestListNodes(BaseTest): def test_list_nodes(self): """Should list all nodes""" resp, error = self.execute([fix, 'list_nodes']) for node in ['testnode1', 'testnode2', 'testnode3.mydomain.com']: self.assertTrue(node in resp) self.assertTrue('Recipes: subversion' in resp) def test_list_nodes_in_env(self): """Should list all nodes in an environment""" resp, error = self.execute([fix, '--env', 'staging', 'list_nodes']) self.assertTrue('testnode2' in resp) self.assertFalse('testnode1' in resp) self.assertFalse('testnode3.mydomain.com' in resp) def test_list_nodes_detailed(self): """Should show a detailed list of all nodes""" resp, error = self.execute([fix, 'list_nodes_detailed']) self.assertTrue('testnode1' in resp) self.assertTrue('Recipe: subversion' in resp) def test_list_nodes_with_recipe(self): """Should list all nodes with a recipe in the run list""" resp, error = self.execute([fix, 'list_nodes_with_recipe:subversion']) self.assertTrue('testnode1' in resp) self.assertTrue('Recipes: subversion' in resp) resp, error = self.execute([fix, 'list_nodes_with_recipe:apache2']) self.assertFalse('testnode1' in resp) class TestNewKitchen(BaseTest): def setUp(self): self.new_kitchen = join(test_path, 'test_new_kitchen') os.mkdir(self.new_kitchen) self.set_location(self.new_kitchen) def tearDown(self): shutil.rmtree(self.new_kitchen) self.set_location() def test_new_kitchen_creates_required_directories(self): resp, error = self.execute([fix, 'new_kitchen']) kitchen_contents = os.listdir(os.getcwd()) self.assertTrue('roles' in kitchen_contents) self.assertTrue('cookbooks' in kitchen_contents) self.assertTrue('site-cookbooks' in kitchen_contents) self.assertTrue('data_bags' in kitchen_contents) self.assertTrue('nodes' in kitchen_contents) self.assertTrue('environments' in kitchen_contents) self.assertTrue(littlechef.CONFIGFILE in kitchen_contents) def test_new_kitchen_can_list_nodes(self): self.execute([fix, 'new_kitchen']) with open(littlechef.CONFIGFILE, "w") as configfh: print >> configfh, "[userinfo]" print >> configfh, "user = testuser" print >> configfh, "password = testpassword" resp, error = self.execute([fix, 'list_nodes']) self.assertFalse(error) self.assertTrue('Found 0 nodes' in resp) self.assertEqual('', error)
tobami/littlechef
tests/test_command.py
Python
apache-2.0
10,393
[ 30522, 12324, 3131, 22199, 12324, 4942, 21572, 9623, 2015, 12324, 9808, 12324, 4132, 12324, 3844, 4014, 2013, 9808, 1012, 4130, 12324, 3693, 1010, 13373, 15069, 1010, 14689, 15069, 1010, 3975, 12324, 25353, 2015, 4372, 2615, 1035, 4130, 1027,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> <title>What Sunrise Is It?</title> <meta name="description" content="What Sunrise Is It? See what our Sunrise looks like from Earth right now."/> <meta name="mobile-web-app-capable" content="yes"> <link rel="stylesheet" type="text/css" href="assets/style.css"/> <link rel="icon" sizes="128x128" href="assets/favicon.png"> <script src="assets/script.js" defer></script> </head> <body> <h2 class="not-centered" id="time">...</h2> <div id="image"></div> <div id="next-image"></div> <a href="https://github.com/rthbound/WhatSunriseIsIt" title="Fork this project on GitHub"><img id="github-badge" src="assets/fork.png" alt="Fork this project on GitHub" /></a> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-41441385-1"); pageTracker._trackPageview(); } catch(err) {} </script> </body> </html>
rthbound/WhatSunriseIsIt
index.html
HTML
mit
1,290
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1013, 1028, 1026, 18804, 2171, 1027, 1000, 3193, 6442, 1000, 4180, 1027, 1000, 9381, 1027...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package model; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.HashMap; import java.util.Map; import javax.imageio.ImageIO; import com.google.zxing.BarcodeFormat; import com.google.zxing.BinaryBitmap; import com.google.zxing.EncodeHintType; import com.google.zxing.MultiFormatReader; import com.google.zxing.MultiFormatWriter; import com.google.zxing.NotFoundException; import com.google.zxing.Result; import com.google.zxing.WriterException; import com.google.zxing.client.j2se.BufferedImageLuminanceSource; import com.google.zxing.client.j2se.MatrixToImageWriter; import com.google.zxing.common.BitMatrix; import com.google.zxing.common.HybridBinarizer; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; public class BarcodeScanner { private String path; private String result; public BarcodeScanner(String path2) { this.path = path2; String charset = "UTF-8"; // or "ISO-8859-1" Map<EncodeHintType, ErrorCorrectionLevel> hintMap = new HashMap<EncodeHintType, ErrorCorrectionLevel>(); hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); result = readQRCode(this.path,charset,hintMap); System.out.println(result); } public String readQRCode(String filePath, String charset, Map hintMap) { BinaryBitmap binaryBitmap = null; try { binaryBitmap = new BinaryBitmap(new HybridBinarizer( new BufferedImageLuminanceSource( ImageIO.read(new FileInputStream(filePath))))); } catch (IOException e) { e.printStackTrace(); System.out.println("File not found"); } Result qrCodeResult = null; try { qrCodeResult = new MultiFormatReader().decode(binaryBitmap, hintMap); } catch (NotFoundException e) { // TODO Auto-generated catch block System.out.println("Barcode not found"); } return qrCodeResult.getText(); } public static Map<EncodeHintType, ErrorCorrectionLevel> getMap() { Map<EncodeHintType, ErrorCorrectionLevel> hintMap = new HashMap<EncodeHintType, ErrorCorrectionLevel>(); hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); return hintMap; } public void setPath(String path) { this.path = path; } public String getResult() { return this.result; } }
vrabievictor/proiectCondr
Web/src/model/BarcodeScanner.java
Java
mit
2,252
[ 30522, 7427, 2944, 1025, 12324, 9262, 1012, 22834, 1012, 5371, 1025, 12324, 9262, 1012, 22834, 1012, 5371, 2378, 18780, 21422, 1025, 12324, 9262, 1012, 22834, 1012, 5371, 17048, 14876, 8630, 10288, 24422, 1025, 12324, 9262, 1012, 22834, 1012,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright 2008-2010 WorldWide Conferencing, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package net.liftweb { package jpademo { package model { object Genre extends Enumeration with Enumv { val Mystery = Value("Mystery", "Mystery") val SciFi = Value("SciFi", "SciFi") val Classic = Value("Classic", "Classic") val Childrens = Value("Childrens", "Childrens") val Horror = Value("Horror", "Horror") val Poetry = Value("Poetry", "Poetry") val unknown = Value("Unknown", "Unknown genre") } class GenreType extends EnumvType(Genre) {} } } }
jeppenejsum/liftweb
examples/JPADemo/JPADemo-spa/src/main/scala/net/liftweb/jpademo/model/Genre.scala
Scala
apache-2.0
1,082
[ 30522, 1013, 1008, 1008, 9385, 2263, 1011, 2230, 4969, 9530, 7512, 2368, 6129, 1010, 11775, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 1008, 2017, 2089, 2025, 2224, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
----------------------------------- -- Area: Batallia Downs -- NPC: Luck Rune -- Involved in Quest: Mhaura Fortune -- !pos -362.167 -12.199 157.158 105 ----------------------------------- package.loaded["scripts/zones/Batallia_Downs/TextIDs"] = nil; ------------------------------------- require("scripts/zones/Batallia_Downs/TextIDs"); ----------------------------------- function onTrade(player,npc,trade) end; function onTrigger(player,npc) player:messageSpecial(NOTHING_OUT_OF_THE_ORDINARY); end; function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
HeavensSword/darkstar
scripts/zones/Batallia_Downs/npcs/Luck_Rune.lua
Lua
gpl-3.0
742
[ 30522, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 2181, 102...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<h1 style="margin-bottom:10px;">Park Board</h1> <div id="sub-menu"> <h1>Menu</h1> <ul> <?php foreach($page_list as $link): ?> <?php if($link->url == 'park_board'): ?> <li><a href="<?=url::site('boards/park')?>">Home</a></li> <?php else: ?> <li><a href="<?=url::site('boards/park/' . $link->url)?>"><?=$link->title?></a></li> <?php endif; ?> <?php endforeach; ?> <li><a href="<?=url::site('boards/park/reports')?>">Minutes and Agendas</a></li> <li class="clear-item"> </li> </ul> </div> <div id="report-years"> <div id="minutes"> <h1>Minutes</h1> <?php if(count($minute_years) > 0): ?> <?php foreach($minute_years as $year): ?> <h2><a href="<?=url::site('boards/park/reports/' . $year->year . '/minutes')?>"><?=$year->year?></a></h2> <?php endforeach; ?> <?php else: ?> <p>No minutes to display</p> <?php endif; ?> </div> <div id="agendas"> <h1>Agendas</h1> <?php if(count($agenda_years) > 0): ?> <?php foreach($agenda_years as $year): ?> <h2><a href="<?=url::site('boards/park/reports/' . $year->year . '/agendas')?>"><?=$year->year?></a></h2> <?php endforeach; ?> <?php else: ?> <p>No agendas to display</p> <?php endif; ?> </div> </div>
mjschaefer/codesamples
Lowell.net/views/park_reports.php
PHP
gpl-2.0
1,286
[ 30522, 1026, 1044, 2487, 2806, 1027, 1000, 7785, 1011, 3953, 1024, 2184, 2361, 2595, 1025, 1000, 1028, 2380, 2604, 1026, 1013, 1044, 2487, 1028, 1026, 4487, 2615, 8909, 1027, 1000, 4942, 1011, 12183, 1000, 1028, 1026, 1044, 2487, 1028, 12...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * Created by Adrian on 2016-05-08. */ import angular from "angular"; import angularMeteor from "angular-meteor"; import uiRouter from "angular-ui-router"; import "./mobile.html"; import {Tasks} from "../../../api/tasks/index"; import {name as TaskItem} from "../taskItem/taskItem"; class TasksList { constructor($scope, $reactive) { 'ngInject'; $reactive(this).attach($scope); this.subscribe('tasks'); this.helpers({ tasks() { return Tasks.find(); } }); } } const template = 'mobile'; const name = 'tasksList'; export default angular.module(name, [ angularMeteor, uiRouter, TaskItem ]).component(name, { templateUrl: `imports/ui/components/${name}/${template}.html`, controllerAs: name, controller: TasksList });
adik993/mobile-agents
imports/ui/components/tasksList/tasksList.js
JavaScript
mit
866
[ 30522, 1013, 1008, 1008, 1008, 2580, 2011, 7918, 2006, 2355, 1011, 5709, 1011, 5511, 1012, 1008, 1013, 12324, 16108, 2013, 1000, 16108, 1000, 1025, 12324, 16108, 11368, 8780, 2099, 2013, 1000, 16108, 1011, 23879, 1000, 1025, 12324, 21318, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) */ /*jshint jquery:true*/ (function (factory) { if (typeof define === 'function' && define.amd) { define([ "jquery", "mage/validation", "mage/translate" ], factory); } else { factory(jQuery); } }(function ($) { "use strict"; /** * Validation rule for grouped product, with multiple qty fields, * only one qty needs to have a positive integer */ $.validator.addMethod( "validate-grouped-qty", function(value, element, params) { var result = false; var total = 0; $(params).find('input[data-validate*="validate-grouped-qty"]').each(function(i, e) { var val = $(e).val(); if (val && val.length > 0) { result = true; var valInt = parseInt(val, 10) || 0; if (valInt >= 0) { total += valInt; } else { result = false; return result; } } }); return result && total > 0; }, 'Please specify the quantity of product(s).' ); $.validator.addMethod( "validate-one-checkbox-required-by-name", function(value, element, params) { var checkedCount = 0; if (element.type === 'checkbox') { $('[name="' + element.name + '"]').each(function() { if ($(this).is(':checked')) { checkedCount += 1; return false; } }); } var container = '#' + params; if (checkedCount > 0) { $(container).removeClass('validation-failed'); $(container).addClass('validation-passed'); return true; } else { $(container).addClass('validation-failed'); $(container).removeClass('validation-passed'); return false; } }, 'Please select one of the options.' ); $.validator.addMethod( "validate-date-between", function(value, element, params) { var minDate = new Date(params[0]), maxDate = new Date(params[1]), inputDate = new Date(element.value); minDate.setHours(0); maxDate.setHours(0); if (inputDate >= minDate && inputDate <= maxDate) { return true; } this.dateBetweenErrorMessage = $.mage.__('Please enter a date between %min and %max.').replace('%min', minDate).replace('%max', maxDate); return false; }, function(){ return this.dateBetweenErrorMessage; } ); }));
webadvancedservicescom/magento
lib/web/mage/validation/validation.js
JavaScript
apache-2.0
2,961
[ 30522, 1013, 1008, 1008, 1008, 1030, 9385, 9385, 1006, 1039, 1007, 2297, 1060, 1012, 6236, 1010, 4297, 1012, 1006, 8299, 1024, 1013, 1013, 7479, 1012, 17454, 13663, 9006, 5017, 3401, 1012, 4012, 1007, 1008, 1013, 1013, 1008, 1046, 17426, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Name Aswin M Guptha ### Academics BTech CSE from [Amrita University](https://www.amrita.edu) ### Projects [My Projects](https://www.github.com/aswinmguptha) Links to my projects ### Profile Link [GitHub](https://github.com/aswinmguptha) [GitLab](https://gitlab.com/aswinmguptha) [Twitter](https://twitter.com/aswinmguptha)
AliceWonderland/hacktoberfest
profiles/Aswin_M_Guptha.md
Markdown
gpl-3.0
326
[ 30522, 1001, 2171, 2004, 10105, 1049, 19739, 13876, 3270, 1001, 1001, 1001, 15032, 18411, 15937, 20116, 2063, 2013, 1031, 2572, 17728, 2118, 1033, 1006, 16770, 1024, 1013, 1013, 7479, 1012, 2572, 17728, 1012, 3968, 2226, 1007, 1001, 1001, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html xmlns:msxsl="urn:schemas-microsoft-com:xslt"> <head> <meta content="en-us" http-equiv="Content-Language" /> <meta content="text/html; charset=utf-16" http-equiv="Content-Type" /> <title _locid="PortabilityAnalysis0">.NET Portability Report</title> <style> /* Body style, for the entire document */ body { background: #F3F3F4; color: #1E1E1F; font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; padding: 0; margin: 0; } /* Header1 style, used for the main title */ h1 { padding: 10px 0px 10px 10px; font-size: 21pt; background-color: #E2E2E2; border-bottom: 1px #C1C1C2 solid; color: #201F20; margin: 0; font-weight: normal; } /* Header2 style, used for "Overview" and other sections */ h2 { font-size: 18pt; font-weight: normal; padding: 15px 0 5px 0; margin: 0; } /* Header3 style, used for sub-sections, such as project name */ h3 { font-weight: normal; font-size: 15pt; margin: 0; padding: 15px 0 5px 0; background-color: transparent; } h4 { font-weight: normal; font-size: 12pt; margin: 0; padding: 0 0 0 0; background-color: transparent; } /* Color all hyperlinks one color */ a { color: #1382CE; } /* Paragraph text (for longer informational messages) */ p { font-size: 10pt; } /* Table styles */ table { border-spacing: 0 0; border-collapse: collapse; font-size: 10pt; } table th { background: #E7E7E8; text-align: left; text-decoration: none; font-weight: normal; padding: 3px 6px 3px 6px; } table td { vertical-align: top; padding: 3px 6px 5px 5px; margin: 0px; border: 1px solid #E7E7E8; background: #F7F7F8; } .NoBreakingChanges { color: darkgreen; font-weight:bold; } .FewBreakingChanges { color: orange; font-weight:bold; } .ManyBreakingChanges { color: red; font-weight:bold; } .BreakDetails { margin-left: 30px; } .CompatMessage { font-style: italic; font-size: 10pt; } .GoodMessage { color: darkgreen; } /* Local link is a style for hyperlinks that link to file:/// content, there are lots so color them as 'normal' text until the user mouse overs */ .localLink { color: #1E1E1F; background: #EEEEED; text-decoration: none; } .localLink:hover { color: #1382CE; background: #FFFF99; text-decoration: none; } /* Center text, used in the over views cells that contain message level counts */ .textCentered { text-align: center; } /* The message cells in message tables should take up all avaliable space */ .messageCell { width: 100%; } /* Padding around the content after the h1 */ #content { padding: 0px 12px 12px 12px; } /* The overview table expands to width, with a max width of 97% */ #overview table { width: auto; max-width: 75%; } /* The messages tables are always 97% width */ #messages table { width: 97%; } /* All Icons */ .IconSuccessEncoded, .IconInfoEncoded, .IconWarningEncoded, .IconErrorEncoded { min-width: 18px; min-height: 18px; background-repeat: no-repeat; background-position: center; } /* Success icon encoded */ .IconSuccessEncoded { /* Note: Do not delete the comment below. It is used to verify the correctness of the encoded image resource below before the product is released */ /* [---XsltValidateInternal-Base64EncodedImage:IconSuccess#Begin#background-image: url(data:image/png;base64,#Separator#);#End#] */ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABPElEQVR4Xp1Tv0vDUBi8FqeA4NpBcBLcWnQSApncOnTo4FSnjP0DsnXpH5CxiwbHDg4Zuj4oOEXiJgiC4FDcCkLWmIMc1Pfw+eMgQ77v3Xf3Pe51YKGqqisAEwCR1TIAsiAIblSo6xrdHeJR85Xle3mdmCQKb0PsfqyxxzM8K15HZADl/H5+sHpZwYfxyRjTs+kWwKBx8yoHd2mRiuzF8mkJniWH/13u3Fjrs/EdhsdDFHGB/DLXEJBDLh1MWPAhPo1BLB4WX5yQywHR+m3tVe/t97D52CB/ziG0nIgD/qDuYg8WuCcVZ2YGwlJ3YDugkpR/VNcAEx6GEKhERSr71FuO4YCM4XBdwKvecjIlkSnsO0Hyp/GxSeJAdzBKzpOtnPwyyiPdAZhpZptT04tU+zk7s8czeges//s5C5+CwqrR4/gw+AAAAABJRU5ErkJggg==); } /* Information icon encoded */ .IconInfoEncoded { /* Note: Do not delete the comment below. It is used to verify the correctness of the encoded image resource below before the product is released */ /* [---XsltValidateInternal-Base64EncodedImage:IconInformation#Begin#background-image: url(data:image/png;base64,#Separator#);#End#] */ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABHElEQVR4Xs2TsUoDQRRF7wwoziokjZUKadInhdhukR9YP8DMX1hYW+QvdsXa/QHBbcXC7W0CamWTQnclFutceIQJwwaWNLlwm5k5d94M76mmaeCrrmsLYOocY12FcxZFUeozCqKqqgYA8uevv1H6VuPxcwlfk5N92KHBxfFeCSAxxswlYAW/Xr989x/mv9gkhtyMDhcAxgzRsp7flj8B/HF1RsMXq+NZMkopaHe7lbKxQUEIGbKsYNoGn969060hZBkQex/W8oRQwsQaW2o3Ago2SVcJUzAgY3N0lTCZZm+zPS8HB51gMmS1DEYyOz9acKO1D8JWTlafKIMxdhvlfdyT94Vv5h7P8Ky7nQzACmhvKq3zk3PjW9asz9D/1oigecsioooAAAAASUVORK5CYII=); } /* Warning icon encoded */ .IconWarningEncoded { /* Note: Do not delete the comment below. It is used to verify the correctness of the encoded image resource below before the product is released */ /* [---XsltValidateInternal-Base64EncodedImage:IconWarning#Begin#background-image: url(data:image/png;base64,#Separator#);#End#] */ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAx0lEQVR4XpWSMQ7CMAxFf4xAyBMLCxMrO8dhaBcuwdCJS3RJBw7SA/QGTCxdWJgiQYWKXJWKIXHIlyw5lqr34tQgEOdcBsCOx5yZK3hCCKdYXneQkh4pEfqzLfu+wVDSyyzFoJjfz9NB+pAF+eizx2Vruts0k15mPgvS6GYvpVtQhB61IB/dk6AF6fS4Ben0uIX5odtFe8Q/eW1KvFeH4e8khT6+gm5B+t3juyDt7n0jpe+CANTd+oTUjN/U3yVaABnSUjFz/gFq44JaVSCXeQAAAABJRU5ErkJggg==); } /* Error icon encoded */ .IconErrorEncoded { /* Note: Do not delete the comment below. It is used to verify the correctness of the encoded image resource below before the product is released */ /* [---XsltValidateInternal-Base64EncodedImage:IconError#Begin#background-image: url(data:image/png;base64,#Separator#);#End#] */ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABQElEQVR4XqWTvUoEQRCE6wYPZUA80AfwAQz23uCMjA7MDRQEIzPBVEyNTQUFIw00vcQTTMzuAh/AxEQQT8HF/3G/oGGnEUGuoNnd6qoZuqltyKEsyzVJq5I6rnUp6SjGeGhESikzzlc1eL7opfuVbrqbU1Zw9NCgtQMaZpY0eNnaaL2fHusvTK5vKu7sjSS1Y4y3QUA6K3e3Mau5UFDyMP7tYF9o8cAHZv68vipoIJg971PZIZ5HiwdvYGGvFVFHmGmZ2MxwmQYPXubPl9Up0tfoMQGetXd6mRbvhBw+boZ6WF7Mbv1+GsHRk0fQmPAH1GfmZirbCfDJ61tw3Px8/8pZsPAG4jlVhcPgZ7adwNWBB68lkRQWFiTgFlbnLY3DGGM7izIJIyT/jjIvEJw6fdJTc6krDzh6aMwMP9bvDH4ADSsa9uSWVJkAAAAASUVORK5CYII=); } </style> </head> <body> <h1 _locid="PortabilityReport">.NET Portability Report</h1> <div id="content"> <div id="submissionId" style="font-size:8pt;"> <p> <i> Submission Id&nbsp; 9ed8f698-5353-4484-b628-91840090693d </i> </p> </div> <h2 _locid="SummaryTitle"> <a name="Portability Summary"></a>Portability Summary </h2> <div id="summary"> <table> <tbody> <tr> <th>Assembly</th> <th>ASP.NET 5,Version=v1.0</th> <th>Windows,Version=v8.1</th> <th>.NET Framework,Version=v4.6</th> <th>Windows Phone,Version=v8.1</th> </tr> <tr> <td><strong><a href="#Manatee.Trello.RestSharp">Manatee.Trello.RestSharp</a></strong></td> <td class="text-center">100.00 %</td> <td class="text-center">100.00 %</td> <td class="text-center">100.00 %</td> <td class="text-center">100.00 %</td> </tr> </tbody> </table> </div> <div id="details"> </div> </div> </body> </html>
kuhlenh/port-to-core
Reports/ma/manatee.trello.restsharp.1.2.0.2/Manatee.Trello.RestSharp-net35.html
HTML
mit
9,663
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 20950, 3619, 1024, 5796, 2595, 14540, 1027, 1000, 24471, 2078, 1024, 8040, 28433, 2015, 1011, 7513, 1011, 4012, 1024, 1060, 14540, 2102, 1000, 1028, 1026, 2132, 1028, 1026, 18804, 418...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. #.rst: # FindZLIB # -------- # # Find the native ZLIB includes and library. # # IMPORTED Targets # ^^^^^^^^^^^^^^^^ # # This module defines :prop_tgt:`IMPORTED` target ``ZLIB::ZLIB``, if # ZLIB has been found. # # Result Variables # ^^^^^^^^^^^^^^^^ # # This module defines the following variables: # # :: # # ZLIB_INCLUDE_DIRS - where to find zlib.h, etc. # ZLIB_LIBRARIES - List of libraries when using zlib. # ZLIB_FOUND - True if zlib found. # # :: # # ZLIB_VERSION_STRING - The version of zlib found (x.y.z) # ZLIB_VERSION_MAJOR - The major version of zlib # ZLIB_VERSION_MINOR - The minor version of zlib # ZLIB_VERSION_PATCH - The patch version of zlib # ZLIB_VERSION_TWEAK - The tweak version of zlib # # Backward Compatibility # ^^^^^^^^^^^^^^^^^^^^^^ # # The following variable are provided for backward compatibility # # :: # # ZLIB_MAJOR_VERSION - The major version of zlib # ZLIB_MINOR_VERSION - The minor version of zlib # ZLIB_PATCH_VERSION - The patch version of zlib # # Hints # ^^^^^ # # A user may set ``ZLIB_ROOT`` to a zlib installation root to tell this # module where to look. set(_ZLIB_SEARCHES) # Search ZLIB_ROOT first if it is set. if(ZLIB_ROOT) set(_ZLIB_SEARCH_ROOT PATHS ${ZLIB_ROOT} NO_DEFAULT_PATH) list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_ROOT) endif() # Normal search. set(_ZLIB_SEARCH_NORMAL PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]" "$ENV{PROGRAMFILES}/zlib" ) list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL) set(ZLIB_NAMES z zlib zdll zlib1) set(ZLIB_NAMES_DEBUG zlibd zlibd1) # Try each search configuration. foreach(search ${_ZLIB_SEARCHES}) find_path(ZLIB_INCLUDE_DIR NAMES zlib.h ${${search}} PATH_SUFFIXES include) endforeach() # Allow ZLIB_LIBRARY to be set manually, as the location of the zlib library if(NOT ZLIB_LIBRARY) foreach(search ${_ZLIB_SEARCHES}) find_library(ZLIB_LIBRARY_RELEASE NAMES ${ZLIB_NAMES} ${${search}} PATH_SUFFIXES lib) find_library(ZLIB_LIBRARY_DEBUG NAMES ${ZLIB_NAMES_DEBUG} ${${search}} PATH_SUFFIXES lib) endforeach() include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) select_library_configurations(ZLIB) endif() unset(ZLIB_NAMES) unset(ZLIB_NAMES_DEBUG) mark_as_advanced(ZLIB_INCLUDE_DIR) if(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") file(STRINGS "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H REGEX "^#define ZLIB_VERSION \"[^\"]*\"$") string(REGEX REPLACE "^.*ZLIB_VERSION \"([0-9]+).*$" "\\1" ZLIB_VERSION_MAJOR "${ZLIB_H}") string(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_MINOR "${ZLIB_H}") string(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_PATCH "${ZLIB_H}") set(ZLIB_VERSION_STRING "${ZLIB_VERSION_MAJOR}.${ZLIB_VERSION_MINOR}.${ZLIB_VERSION_PATCH}") # only append a TWEAK version if it exists: set(ZLIB_VERSION_TWEAK "") if( "${ZLIB_H}" MATCHES "ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+)") set(ZLIB_VERSION_TWEAK "${CMAKE_MATCH_1}") string(APPEND ZLIB_VERSION_STRING ".${ZLIB_VERSION_TWEAK}") endif() set(ZLIB_MAJOR_VERSION "${ZLIB_VERSION_MAJOR}") set(ZLIB_MINOR_VERSION "${ZLIB_VERSION_MINOR}") set(ZLIB_PATCH_VERSION "${ZLIB_VERSION_PATCH}") endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_LIBRARY ZLIB_INCLUDE_DIR VERSION_VAR ZLIB_VERSION_STRING) if(ZLIB_FOUND) set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR}) if(NOT ZLIB_LIBRARIES) set(ZLIB_LIBRARIES ${ZLIB_LIBRARY}) endif() if(NOT TARGET ZLIB::ZLIB) add_library(ZLIB::ZLIB UNKNOWN IMPORTED) set_target_properties(ZLIB::ZLIB PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIRS}") if(ZLIB_LIBRARY_RELEASE) set_property(TARGET ZLIB::ZLIB APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) set_target_properties(ZLIB::ZLIB PROPERTIES IMPORTED_LOCATION_RELEASE "${ZLIB_LIBRARY_RELEASE}") endif() if(ZLIB_LIBRARY_DEBUG) set_property(TARGET ZLIB::ZLIB APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) set_target_properties(ZLIB::ZLIB PROPERTIES IMPORTED_LOCATION_DEBUG "${ZLIB_LIBRARY_DEBUG}") endif() if(NOT ZLIB_LIBRARY_RELEASE AND NOT ZLIB_LIBRARY_DEBUG) set_property(TARGET ZLIB::ZLIB APPEND PROPERTY IMPORTED_LOCATION "${ZLIB_LIBRARY}") endif() endif() endif()
pipou/rae
builder/cmake/windows/share/cmake-3.8/Modules/FindZLIB.cmake
CMake
mit
4,880
[ 30522, 1001, 5500, 2104, 1996, 9808, 2072, 1011, 4844, 18667, 2094, 1017, 1011, 11075, 6105, 1012, 2156, 10860, 1001, 5371, 9385, 1012, 19067, 2102, 2030, 16770, 1024, 1013, 1013, 4642, 13808, 1012, 8917, 1013, 13202, 2005, 4751, 1012, 1001...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace denbora\R_T_G_Services\services\REST; use denbora\R_T_G_Services\R_T_G_ServiceException; class GameService extends RestService { /** * First part in url after /api/ */ const API_URL = 'games'; /** * @param $query * @param null $array * @param string $endpoint * @return bool|mixed * @throws R_T_G_ServiceException */ private function callGet($query, $array = null, $endpoint = '') { if ($query != '' || $this->validator->call('validate', $query)) { return $this->get($this->createGetFullUrl($query, self::API_URL, $array, $endpoint)); } return false; } /** * @param string $query * @return bool|mixed * @throws R_T_G_ServiceException */ public function getGames($query = '') { return $this->callGet($query); } /** * @param string $query * @return bool|mixed * @throws R_T_G_ServiceException */ public function getDetails($query = '') { return $this->callGet($query, array('gameId'), 'details'); } /** * @param string $query * @return bool|mixed * @throws R_T_G_ServiceException */ public function getFlash($query = '') { return $this->callGet($query, '', 'flash'); } /** * @param string $query * @return bool|mixed * @throws R_T_G_ServiceException */ public function getActive($query = '') { return $this->callGet($query, '', 'active'); } /** * @param string $query * @return bool|mixed * @throws R_T_G_ServiceException */ public function getFavorite($query = '') { return $this->callGet($query, '', 'favorite'); } /** * @param string $query * @return bool|mixed * @throws R_T_G_ServiceException */ public function getActiveFlash($query = '') { return $this->callGet($query, '', 'active-flash'); } /** * @param string $query * @return bool|mixed * @throws R_T_G_ServiceException */ public function getFavoriteFlash($query = '') { return $this->callGet($query, '', 'favorite-flash'); } /** * @param string $query * @return bool|mixed * @throws R_T_G_ServiceException */ public function postBlock($query = '') { if ($query != '' || $this->validator->call('validate', $query)) { return $this->post( $this->createFullUrl($query, self::API_URL, '', 'block'), $query ); } return false; } }
Denbora/R_T_G_Services
src/services/REST/GameService.php
PHP
mit
2,636
[ 30522, 1026, 1029, 25718, 3415, 15327, 7939, 12821, 2050, 1032, 1054, 1035, 1056, 1035, 1043, 1035, 2578, 1032, 2578, 1032, 2717, 1025, 2224, 7939, 12821, 2050, 1032, 1054, 1035, 1056, 1035, 1043, 1035, 2578, 1032, 1054, 1035, 1056, 1035, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package qa.qcri.aidr.manager.dto; import qa.qcri.aidr.dbmanager.dto.CollectionDTO; public class TaggerCrisisRequest { private String code; private String name; private TaggerCrisisType crisisType; private TaggerUserRequest users; public TaggerCrisisRequest() { } public TaggerCrisisRequest(String code, String name, TaggerCrisisType crisisType, TaggerUserRequest users) { this.code = code; this.name = name; this.crisisType = crisisType; this.users = users; } public CollectionDTO toDTO() throws Exception { CollectionDTO dto = new CollectionDTO(); dto.setCode(this.getCode()); dto.setName(this.getName()); dto.setIsTrashed(false); dto.setUsersDTO(this.getUsers() != null ? this.getUsers().toDTO() : null); dto.setCrisisTypeDTO(this.getCrisisType() != null ? this.getCrisisType().toDTO() : null); return dto; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getName() { return name; } public void setName(String name) { this.name = name; } public TaggerCrisisType getCrisisType() { return crisisType; } public void setCrisisType(TaggerCrisisType crisisType) { this.crisisType = crisisType; } public TaggerUserRequest getUsers() { return users; } public void setUsers(TaggerUserRequest users) { this.users = users; } }
qcri-social/Crisis-Computing
aidr-manager/src/main/java/qa/qcri/aidr/manager/dto/TaggerCrisisRequest.java
Java
agpl-3.0
1,518
[ 30522, 7427, 1053, 2050, 1012, 25196, 3089, 1012, 4681, 2099, 1012, 3208, 1012, 26718, 2080, 1025, 12324, 1053, 2050, 1012, 25196, 3089, 1012, 4681, 2099, 1012, 16962, 24805, 4590, 1012, 26718, 2080, 1012, 3074, 11927, 2080, 1025, 2270, 246...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon")); var _jsxRuntime = require("react/jsx-runtime"); var _default = (0, _createSvgIcon.default)([/*#__PURE__*/(0, _jsxRuntime.jsx)("path", { d: "M5 18h14V8H5v10zm3.82-6.42 2.12 2.12 4.24-4.24 1.41 1.41-5.66 5.66L7.4 13l1.42-1.42z", opacity: ".3" }, "0"), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", { d: "m16.6 10.88-1.42-1.42-4.24 4.25-2.12-2.13L7.4 13l3.54 3.54z" }, "1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", { d: "M19 4H5c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2zm0 14H5V8h14v10z" }, "2")], 'DomainVerificationTwoTone'); exports.default = _default;
oliviertassinari/material-ui
packages/mui-icons-material/lib/DomainVerificationTwoTone.js
JavaScript
mit
864
[ 30522, 1000, 2224, 9384, 1000, 1025, 13075, 1035, 6970, 7361, 2890, 15549, 5596, 12879, 23505, 1027, 5478, 1006, 1000, 1030, 11561, 2140, 1013, 2448, 7292, 1013, 2393, 2545, 1013, 6970, 7361, 2890, 15549, 5596, 12879, 23505, 1000, 1007, 102...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Food Inspector - Choose well to eat better * Copyright (C) 2016 Frédéric Letellier * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.fredericletellier.foodinspector.data.source.remote; import android.support.annotation.NonNull; import android.util.Log; import com.fredericletellier.foodinspector.data.CountryCategory; import com.fredericletellier.foodinspector.data.Search; import com.fredericletellier.foodinspector.data.source.CountryCategoryDataSource; import com.fredericletellier.foodinspector.data.source.remote.API.CountryCategoryNotExistException; import com.fredericletellier.foodinspector.data.source.remote.API.OpenFoodFactsAPIClient; import com.fredericletellier.foodinspector.data.source.remote.API.ServerUnreachableException; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; import static com.google.common.base.Preconditions.checkNotNull; public class CountryCategoryRemoteDataSource implements CountryCategoryDataSource { private static final String TAG = CountryCategoryRemoteDataSource.class.getName(); private static CountryCategoryRemoteDataSource INSTANCE; // Prevent direct instantiation. private CountryCategoryRemoteDataSource() { } public static CountryCategoryRemoteDataSource getInstance() { if (INSTANCE == null) { INSTANCE = new CountryCategoryRemoteDataSource(); } return INSTANCE; } /** * Gets the sumOfProducts from remote data source to complete CountryCategory data * <p/> * Note: {@link GetCountryCategoryCallback#onError(Throwable)} is fired if remote data sources fail to * get the data (HTTP error, IOException, IllegalStateException, ...) */ @Override public void getCountryCategory(@NonNull final String categoryKey, @NonNull final String countryKey, @NonNull final GetCountryCategoryCallback getCountryCategoryCallback) { checkNotNull(categoryKey); checkNotNull(countryKey); checkNotNull(getCountryCategoryCallback); OpenFoodFactsAPIClient openFoodFactsAPIClient = new OpenFoodFactsAPIClient(OpenFoodFactsAPIClient.ENDPOINT_SEARCH); Call<Search> call = openFoodFactsAPIClient.getCountryCategory(categoryKey, countryKey); call.enqueue(new Callback<Search>() { @Override public void onResponse(Call<Search> call, Response<Search> response) { if (!response.isSuccessful() || response.body() == null) { ServerUnreachableException e = new ServerUnreachableException(); Log.w(TAG, e); getCountryCategoryCallback.onError(e); return; } Search search = response.body(); if (search.getCount() == 0) { CountryCategoryNotExistException e = new CountryCategoryNotExistException(); Log.w(TAG, e); getCountryCategoryCallback.onError(e); return; } int sumOfProducts = search.getCount(); CountryCategory countryCategory = new CountryCategory(categoryKey, countryKey, sumOfProducts); getCountryCategoryCallback.onCountryCategoryLoaded(countryCategory); } @Override public void onFailure(Call<Search> call, Throwable t) { ServerUnreachableException e = new ServerUnreachableException(); Log.w(TAG, e); getCountryCategoryCallback.onError(e); } }); } }
fredericletellier/udacity-capstone
app/src/main/java/com/fredericletellier/foodinspector/data/source/remote/CountryCategoryRemoteDataSource.java
Java
agpl-3.0
4,316
[ 30522, 1013, 1008, 1008, 2833, 7742, 1011, 5454, 2092, 2000, 4521, 2488, 1008, 9385, 1006, 1039, 1007, 2355, 15296, 2292, 13348, 2121, 1008, 1008, 2023, 2565, 2003, 2489, 4007, 1024, 2017, 2064, 2417, 2923, 3089, 8569, 2618, 2009, 1998, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
""" LLDB AppKit formatters part of The LLVM Compiler Infrastructure This file is distributed under the University of Illinois Open Source License. See LICENSE.TXT for details. """ # example summary provider for NSMachPort # the real summary is now C++ code built into LLDB import lldb import ctypes import lldb.runtime.objc.objc_runtime import lldb.formatters.metrics import lldb.formatters.Logger statistics = lldb.formatters.metrics.Metrics() statistics.add_metric('invalid_isa') statistics.add_metric('invalid_pointer') statistics.add_metric('unknown_class') statistics.add_metric('code_notrun') # despite the similary to synthetic children providers, these classes are not # trying to provide anything but the port number of an NSMachPort, so they need not # obey the interface specification for synthetic children providers class NSMachPortKnown_SummaryProvider: def adjust_for_architecture(self): pass def __init__(self, valobj, params): logger = lldb.formatters.Logger.Logger() self.valobj = valobj; self.sys_params = params if not(self.sys_params.types_cache.NSUInteger): if self.sys_params.is_64_bit: self.sys_params.types_cache.NSUInteger = self.valobj.GetType().GetBasicType(lldb.eBasicTypeUnsignedLong) else: self.sys_params.types_cache.NSUInteger = self.valobj.GetType().GetBasicType(lldb.eBasicTypeUnsignedInt) self.update(); def update(self): logger = lldb.formatters.Logger.Logger() self.adjust_for_architecture(); # one pointer is the ISA # then we have one other internal pointer, plus # 4 bytes worth of flags. hence, these values def offset(self): logger = lldb.formatters.Logger.Logger() if self.sys_params.is_64_bit: return 20 else: return 12 def port(self): logger = lldb.formatters.Logger.Logger() vport = self.valobj.CreateChildAtOffset("port", self.offset(), self.sys_params.types_cache.NSUInteger) return vport.GetValueAsUnsigned(0) class NSMachPortUnknown_SummaryProvider: def adjust_for_architecture(self): pass def __init__(self, valobj, params): logger = lldb.formatters.Logger.Logger() self.valobj = valobj; self.sys_params = params self.update(); def update(self): logger = lldb.formatters.Logger.Logger() self.adjust_for_architecture(); def port(self): logger = lldb.formatters.Logger.Logger() stream = lldb.SBStream() self.valobj.GetExpressionPath(stream) num_children_vo = self.valobj.CreateValueFromExpression("port","(int)[" + stream.GetData() + " machPort]") if num_children_vo.IsValid(): return num_children_vo.GetValueAsUnsigned(0) return '<variable is not NSMachPort>' def GetSummary_Impl(valobj): logger = lldb.formatters.Logger.Logger() global statistics class_data,wrapper =lldb.runtime.objc.objc_runtime.Utilities.prepare_class_detection(valobj,statistics) if wrapper: return wrapper name_string = class_data.class_name() logger >> "class name is: " + str(name_string) if name_string == 'NSMachPort': wrapper = NSMachPortKnown_SummaryProvider(valobj, class_data.sys_params) statistics.metric_hit('code_notrun',valobj) else: wrapper = NSMachPortUnknown_SummaryProvider(valobj, class_data.sys_params) statistics.metric_hit('unknown_class',valobj.GetName() + " seen as " + name_string) return wrapper; def NSMachPort_SummaryProvider (valobj,dict): logger = lldb.formatters.Logger.Logger() provider = GetSummary_Impl(valobj); if provider != None: if isinstance(provider,lldb.runtime.objc.objc_runtime.SpecialSituation_Description): return provider.message() try: summary = provider.port(); except: summary = None logger >> "got summary " + str(summary) if summary == None: summary = '<variable is not NSMachPort>' if isinstance(summary, basestring): return summay return 'mach port: ' + str(summary) return 'Summary Unavailable' def __lldb_init_module(debugger,dict): debugger.HandleCommand("type summary add -F NSMachPort.NSMachPort_SummaryProvider NSMachPort")
s20121035/rk3288_android5.1_repo
external/lldb/examples/summaries/cocoa/NSMachPort.py
Python
gpl-3.0
3,980
[ 30522, 1000, 1000, 1000, 2222, 18939, 10439, 23615, 4289, 7747, 2112, 1997, 1996, 2222, 2615, 2213, 21624, 6502, 2023, 5371, 2003, 5500, 2104, 1996, 2118, 1997, 4307, 2330, 3120, 6105, 1012, 2156, 6105, 1012, 19067, 2102, 2005, 4751, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# # Author:: Lamont Granquist (<lamont@chef.io>) # Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # require "spec_helper" describe Chef::Resource::RegistryKey, "initialize" do let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } it "sets the resource_name to :registry_key" do expect(resource.resource_name).to eql(:registry_key) end it "the key property is the name_property" do expect(resource.key).to eql('HKCU\Software\Raxicoricofallapatorius') end it "sets the default action as :create" do expect(resource.action).to eql([:create]) end it "supports :create, :create_if_missing, :delete, :delete_key actions" do expect { resource.action :create }.not_to raise_error expect { resource.action :create_if_missing }.not_to raise_error expect { resource.action :delete }.not_to raise_error expect { resource.action :delete_key }.not_to raise_error end it "defaults recursive to false" do expect(resource.recursive).to eql(false) end it "defaults architecture to :machine" do expect(resource.architecture).to eql(:machine) end it "sets action to :create" do expect(resource.action).to eql([:create]) end %w{create create_if_missing delete delete_key}.each do |action| it "allows action #{action}" do expect(resource.allowed_actions.detect { |a| a == action.to_sym }).to eql(action.to_sym) end end end describe Chef::Resource::RegistryKey, "key" do let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } it "allows a string" do resource.key 'HKCU\Software\Poosh' expect(resource.key).to eql('HKCU\Software\Poosh') end it "does not allow an integer" do expect { resource.send(:key, 100) }.to raise_error(ArgumentError) end it "does not allow a hash" do expect { resource.send(:key, { sonic: "screwdriver" }) }.to raise_error(ArgumentError) end end describe Chef::Resource::RegistryKey, "values" do let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } it "allows a single proper hash of registry values" do resource.values( { name: "poosh", type: :string, data: "carmen" } ) expect(resource.values).to eql([ { name: "poosh", type: :string, data: "carmen" } ]) end it "allows an array of proper hashes of registry values" do resource.values [ { name: "poosh", type: :string, data: "carmen" } ] expect(resource.values).to eql([ { name: "poosh", type: :string, data: "carmen" } ]) end it "returns checksummed data if the type is unsafe" do resource.values( { name: "poosh", type: :binary, data: 255.chr * 1 }) expect(resource.values).to eql([ { name: "poosh", type: :binary, data: "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" } ]) end it "raises an exception if the name field is missing" do expect { resource.values [ { type: :string, data: "carmen" } ] }.to raise_error(ArgumentError) end it "raises an exception if extra fields are present" do expect { resource.values [ { name: "poosh", type: :string, data: "carmen", screwdriver: "sonic" } ] }.to raise_error(ArgumentError) end it "does not allow a string" do expect { resource.send(:values, "souffle") }.to raise_error(ArgumentError) end it "does not allow an integer" do expect { resource.send(:values, 100) }.to raise_error(ArgumentError) end it "raises an exception if type of name is not string" do expect { resource.values([ { name: 123, type: :string, data: "carmen" } ]) }.to raise_error(ArgumentError) end it "does not raise an exception if type of name is string" do expect { resource.values([ { name: "123", type: :string, data: "carmen" } ]) }.to_not raise_error end context "type key not given" do it "does not raise an exception" do expect { resource.values([ { name: "123", data: "carmen" } ]) }.to_not raise_error end end context "type key given" do it "raises an exception if type of type is not symbol" do expect { resource.values([ { name: "123", type: "string", data: "carmen" } ]) }.to raise_error(ArgumentError) end it "does not raise an exception if type of type is symbol" do expect { resource.values([ { name: "123", type: :string, data: "carmen" } ]) }.to_not raise_error end end it "does not raise an exception if keys are in string format" do expect { resource.values([ { "name" => "123", "type" => :string, "data" => "carmen" } ]) }.to_not raise_error end end describe Chef::Resource::RegistryKey, "recursive" do let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } it "allows a boolean" do resource.recursive(true) expect(resource.recursive).to eql(true) end it "does not allow a hash" do expect { resource.recursive({ sonic: :screwdriver }) }.to raise_error(ArgumentError) end it "does not allow an array" do expect { resource.recursive(%i{nose chin}) }.to raise_error(ArgumentError) end it "does not allow a string" do expect { resource.recursive("souffle") }.to raise_error(ArgumentError) end it "does not allow an integer" do expect { resource.recursive(100) }.to raise_error(ArgumentError) end end describe Chef::Resource::RegistryKey, "architecture" do let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } %i{i386 x86_64 machine}.each do |arch| it "allows #{arch} as a symbol" do resource.architecture(arch) expect(resource.architecture).to eql(arch) end end it "does not allow other symbols" do expect { resource.architecture(:nope) }.to raise_error(ArgumentError) end it "does not allow a hash" do expect { resource.architecture({ sonic: :screwdriver }) }.to raise_error(ArgumentError) end it "does not allow an array" do expect { resource.architecture(%i{nose chin}) }.to raise_error(ArgumentError) end it "does not allow a string" do expect { resource.architecture("souffle") }.to raise_error(ArgumentError) end it "does not allow an integer" do expect { resource.architecture(100) }.to raise_error(ArgumentError) end end describe Chef::Resource::RegistryKey, ":unscrubbed_values" do let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } it "returns unsafe data as-is" do key_values = [ { name: "poosh", type: :binary, data: 255.chr * 1 } ] resource.values(key_values) expect(resource.unscrubbed_values).to eql(key_values) end end describe Chef::Resource::RegistryKey, "state" do let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') } it "returns scrubbed values" do resource.values([ { name: "poosh", type: :binary, data: 255.chr * 1 } ]) expect(resource.state_for_resource_reporter[:values]).to eql( [{ name: "poosh", type: :binary, data: "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" }] ) end end
gene1wood/chef
spec/unit/resource/registry_key_spec.rb
Ruby
apache-2.0
7,634
[ 30522, 1001, 1001, 3166, 1024, 1024, 16983, 12162, 12604, 18331, 1006, 1026, 16983, 12162, 1030, 10026, 1012, 22834, 1028, 1007, 1001, 9385, 1024, 1024, 9385, 1006, 1039, 1007, 10026, 4007, 4297, 1012, 30524, 1001, 2017, 2089, 6855, 1037, 6...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import gc import os import argparse os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' from util import generate_features def get_arguments(): parser = argparse.ArgumentParser(description='Generate features using a previously trained model') parser.add_argument('data', type=str, help='File containing the input smiles matrices') parser.add_argument('model', type=str, help='The model file') parser.add_argument('features', type=str, help='Output file that will contain the generated features') parser.add_argument('--batch_size', type=int, default=100, help='Size of the batches (default: 100)') return parser.parse_args() args = get_arguments() generate_features.generate_features(args.data, args.model, args.features, args.batch_size) gc.collect()
patrick-winter-knime/deep-learning-on-molecules
smiles-vhts/generate_features.py
Python
gpl-3.0
769
[ 30522, 12324, 1043, 2278, 12324, 9808, 12324, 12098, 21600, 11650, 2063, 9808, 1012, 4372, 21663, 2239, 1031, 1005, 1056, 2546, 1035, 18133, 2361, 1035, 8117, 1035, 8833, 1035, 2504, 1005, 1033, 1027, 1005, 1016, 1005, 2013, 21183, 4014, 12...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright 2013 Velodyne Acoustics, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*========================================================================= Program: Visualization Toolkit Module: vtkVelodyneHDLReader.cxx Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ // .NAME vtkPlaneFitter - class for finding a plane fit to polydata // .Section Description // #ifndef _vtkPlaneFitter_h #define _vtkPlaneFitter_h #include <vtkObject.h> class vtkPointSet; class VTK_EXPORT vtkPlaneFitter : public vtkObject { public: static vtkPlaneFitter *New(); vtkTypeMacro(vtkPlaneFitter, vtkObject); virtual void PrintSelf(ostream& os, vtkIndent indent); static void PlaneFit(vtkPointSet* pts, double origin[3], double normal[3], double &minDist, double &maxDist, double &stdDev, double channelMean[32], double channelStdDev[32], vtkIdType channelNpts[32]); protected: vtkPlaneFitter(); virtual ~vtkPlaneFitter(); private: vtkPlaneFitter(const vtkPlaneFitter&); void operator=(const vtkPlaneFitter&); }; #endif
frizaro/Veloview
VelodyneHDL/vtkPlaneFitter.h
C
apache-2.0
2,011
[ 30522, 1013, 1013, 9385, 2286, 2310, 4135, 5149, 2638, 6490, 2015, 1010, 4297, 1012, 1013, 1013, 1013, 1013, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 1013, 1013, 2017, 2089, 20...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
define([ 'gmaps', 'config', 'leaflet', 'leaflet-pip', 'app-state' ], function (gmaps, config, L, leafletPip, appState) { "use strict"; var geocoder = new gmaps.Geocoder(), // simplifies place name for geocoder to get better results locationAddress = function(place_name, district_name) { district_name = district_name || config.defaultDistrictName; return place_name .replace(/&nbsp;/gi, ' ') .split('x ', 1)[0] .split('(', 1)[0] .split(' - ', 1)[0] .split(' – ', 1)[0] // EN DASH character .replace('křižovatka ', '') .replace('ul. ', '') .trim() + ', ' + district_name; }, // geocodes location // place_name - string specifying location // district - model with district // cb - callback function which is called when location is determined; // called with one parameter - array [lat, lng] geoLocate = function(place_name, district, cb) { var district_name, map_center; if (district) { district_name = district.get('properties').district_name; map_center = district.getCenter(); } else { map_center = config.mapCenter; } geocoder.geocode({'address': locationAddress(place_name, district_name)}, function(data, status) { if (status == gmaps.GeocoderStatus.OK && data[0].geometry.location_type != gmaps.GeocoderLocationType.APPROXIMATE && (!('partial_match' in data[0]) || data[0].partial_match !== true)) { cb([data[0].geometry.location.lat(), data[0].geometry.location.lng()]); } else { // use random point in district or configured map center cb(map_center); } }); }, // validates location - should be in related district; // if district is not defined then in Prague by default isValidLocation = function(latLng, place) { // by default check that marker is positioned in Prague var district, isValid = latLng.lat < config.borders.maxLat && latLng.lat > config.borders.minLat && latLng.lng < config.borders.maxLng && latLng.lng > config.borders.minLng ; if (place.get('district_id')) { district = appState.districts.get(place.get('district_id')); if (district) { // district model already in the collection if (district.has('geometry')) { // pointInLayer returns array of matched layers; empty array if nothing was matched isValid = (leafletPip.pointInLayer(latLng, L.geoJson(district.get('geometry')), true).length > 0); } } } return isValid; } ; return { geoLocate: geoLocate, locationAddress: locationAddress, isValidLocation: isValidLocation }; });
saxicek/odpad-praha8.cz
client/src/js/containers/geo-util.js
JavaScript
mit
2,887
[ 30522, 9375, 1006, 1031, 1005, 20917, 4523, 1005, 1010, 1005, 9530, 8873, 2290, 1005, 1010, 1005, 7053, 7485, 1005, 1010, 1005, 7053, 7485, 1011, 28315, 1005, 1010, 1005, 10439, 1011, 2110, 1005, 1033, 1010, 3853, 1006, 20917, 4523, 1010, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- layout: post title: "udp连接报错error no 111原因分析" subtitle: " \"从一个实际的例子出发\"" date: 2018-05-05 12:00:00 author: "Xion" header-img: "img/1878823053.jpg" catalog: true tags: - 问题分析 --- # 问题构造 ``` 有以下两个python程序,你可以在本地运行,它们看起来相似,执行起来却有不同的结果。 最后同样执行来sock.recvfrom这个函数,一个报错了,另一个却没有报错。 ``` ### 程序一 ```python import socket hostname,port = ('localhost', 1060) data = b'123' MAX_BYTES=65535 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #[1] sock.connect((hostname, port)) #[2] sock.send(data) #[3] data = sock.recvfrom(MAX_BYTES) #[4] print('The server says {!r}'.format(data.decode('ascii'))) ``` - [1] AF_INET表示IP,SOCK_DGRAM表示UDP协议,这句话的意思是创建一个UDP套接字 - [2] connect不会进行任何网络操作,只是将hostname和port保存到操作系统的内存 - [3] 发送bytes b'123' - [4] 接收请求 #### 运行效果如下 ``` Traceback (most recent call last): File "test", line 8, in <module> data = sock.recvfrom(MAX_BYTES) socket.error: [Errno 111] Connection refused ``` ### 程序二 ```python import socket hostname,port = ('localhost', 1060) data = b'123' MAX_BYTES=65535 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #[1] sock.connect((hostname, port)) data = sock.recvfrom(MAX_BYTES) print('The server says {!r}'.format(data.decode('ascii'))) ``` 运行后会一直阻塞住,但是却不会报错 ### 分析 已知: - python中的recv就是linux系统调用中的recv。 - recv默认是阻塞的 。 - 使用的协议是UDP,面向数据报,而不是面向连接的。 # 问题原因讲解 ``` 这个问题挺有意思的,我先是查阅的python的源码,发现没有任何问题, ``` 最终通过在《unix网络编程:卷1套接字联网API》一书中找到了答案。 可以通过一个实验来说明原因: ## 使用tcpdump抓包 先开启tcpdump,然后运行上面的第一个程序,tcpdump的结果如下: ``` ➜ sudo tcpdump -i lo "udp or icmp" and dst 127.0.0.1 -v tcpdump: listening on lo, link-type EN10MB (Ethernet), capture size 262144 bytes 01:39:58.454346 IP (tos 0x0, ttl 64, id 1043, offset 0, flags [DF], proto UDP (17), length 31) xion.45117 > xion.1060: UDP, length 3 01:39:58.454359 IP (tos 0xc0, ttl 64, id 15527, offset 0, flags [none], proto ICMP (1), length 59) xion > xion: ICMP xion udp port 1060 unreachable, length 39 ``` 这个与upd中的**异步错误有关**:这个ICMP是一个**异步错误**(asynchronous error)。这个错误是又sendto引起的,但是sendto是返回成功的,直到下次调用receive的时候才被返回给进程。因此上面的两段代码有了不同的表象。 但是sendto的返回是成功仅仅表示的是接口输出队列中具有存放所形成的ip数据报的空间。这个错,直到下一次udp操作的时候才会被返回。 对于upd套接字而言,有一个基本规则:由它引发的错误不返回给它,除非它已经建立连接。也就是说如果上述的两个程序总,都没用调用connect那么这个错误也不会被返回来。
xionchen/xionchen.github.io
_posts/2018-04-17-udp.markdown
Markdown
apache-2.0
3,362
[ 30522, 1011, 1011, 1011, 9621, 1024, 2695, 2516, 1024, 1000, 20904, 2361, 100, 100, 100, 30524, 1024, 4002, 1024, 4002, 3166, 1024, 1000, 8418, 2239, 1000, 20346, 1011, 10047, 2290, 1024, 1000, 10047, 2290, 1013, 7261, 2620, 21926, 2692, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
**Warning**: This project will be released at late Q3 of 2015. #Open Journal Software [![Build Status](https://img.shields.io/travis/okulbilisim/ojs/master.svg?style=flat-square)](https://travis-ci.org/okulbilisim/ojs) [![Quality Status](https://img.shields.io/scrutinizer/g/okulbilisim/ojs.svg?style=flat-square)](https://scrutinizer-ci.com/g/okulbilisim/ojs/) [![Software License](http://img.shields.io/badge/License-MIT-brightgreen.svg?style=flat-square)](LICENSE) **Open Journal Software (OJS)** is a journal management and publishing software bulit with **Symfony 2 Framework**. As a company we, [OkulBilişim](http://www.okulbilisim.com), analyzed journal management systems and needs of the community and decided to make a harder, better, faster and stronger content management and workflow software using [Symfony 2](http://en.wikipedia.org/wiki/Symfony) and [cloud](http://en.wikipedia.org/wiki/Cloud_computing) in parnership with [TÜBİTAK-ULAKBİM](http://www.ulakbim.gov.tr) ## Contributing Feel free to add any issues. You are welcome to suggest new features. You can add issues through the GitHub interface or directly on our [waffle.io board](http://waffle.io/okulbilisim/ojs). It's a good idea to check existing issues beforehand in order to reduce duplicates. It'd be great if you only joined the conversation too. - Please [fork](https://github.com/okulbilisim/ojs/fork) us! - Please [open](https://github.com/okulbilisim/ojs/issues/new) issues for improvements/features/bugs! [![Issue Throughput Graph](http://graphs.waffle.io/okulbilisim/ojs/throughput.svg)](https://waffle.io/okulbilisim/ojs/metrics) ## Installing Read [Install.md](https://github.com/okulbilisim/ojs/tree/master/docs/INSTALL.md) ## More information We also provide OJS as SaaS (software as a service) from [OJS.io](http://ojs.io). [Contact](mailto:info@okulbilisim.com) with [us](http://okulbilisim.com)!
zaferkanbur/ojs
README.md
Markdown
mit
1,911
[ 30522, 1008, 1008, 5432, 1008, 1008, 1024, 2023, 2622, 2097, 2022, 2207, 2012, 2397, 1053, 2509, 1997, 2325, 1012, 1001, 2330, 3485, 4007, 1031, 999, 1031, 3857, 3570, 1033, 1006, 16770, 1024, 1013, 1013, 10047, 2290, 1012, 11824, 1012, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
class RenameIworkonthewebPeopleToPeople < ActiveRecord::Migration def self.up rename_table :iworkontheweb_people, :people end def self.down rename_table :people, :iworkontheweb_people end end
toolmantim/iworkontheweb
www/migrations/009_rename_iworkontheweb_people_to_people.rb
Ruby
mit
209
[ 30522, 2465, 14916, 14074, 2072, 6198, 12162, 5369, 8545, 2497, 5051, 27469, 14399, 8780, 10814, 1026, 3161, 2890, 27108, 2094, 1024, 1024, 9230, 13366, 2969, 1012, 2039, 14916, 14074, 1035, 2795, 1024, 1045, 6198, 12162, 5369, 8545, 2497, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="it"> <head> <!-- Generated by javadoc (version 1.7.0_60) on Fri Feb 13 15:30:20 CET 2015 --> <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"> <title>gameshop.advance.exceptions.db</title> <meta name="date" content="2015-02-13"> <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> </head> <body> <h1 class="bar"><a href="../../../../gameshop/advance/exceptions/db/package-summary.html" target="classFrame">gameshop.advance.exceptions.db</a></h1> <div class="indexContainer"> <h2 title="Exceptions">Exceptions</h2> <ul title="Exceptions"> <li><a href="ObjectAlreadyExistsDbException.html" title="class in gameshop.advance.exceptions.db" target="classFrame">ObjectAlreadyExistsDbException</a></li> <li><a href="ObjectNotExistsDbException.html" title="class in gameshop.advance.exceptions.db" target="classFrame">ObjectNotExistsDbException</a></li> <li><a href="ReservationNotFoundDbException.html" title="class in gameshop.advance.exceptions.db" target="classFrame">ReservationNotFoundDbException</a></li> <li><a href="SaleNotFoundDbException.html" title="class in gameshop.advance.exceptions.db" target="classFrame">SaleNotFoundDbException</a></li> </ul> </div> </body> </html>
GameShopAdvance/GameShop-Advance
docs/javadoc/employee/gameshop/advance/exceptions/db/package-frame.html
HTML
mit
1,364
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 16129, 1018, 1012, 5890, 17459, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, 8917, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /** * For licensing information, please see the LICENSE file accompanied with this file. * * @author Gerard van Helden <drm@melp.nl> * @copyright 2012 Gerard van Helden <http://melp.nl> */ namespace Melp\Vcs\Git; /** * Common interface for subversion failures. */ interface CommandFailedException { }
drm/MelpVcs
src/Melp/Vcs/Git/CommandFailedException.php
PHP
mit
315
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 2005, 13202, 2592, 1010, 3531, 2156, 1996, 6105, 5371, 5642, 2007, 2023, 5371, 1012, 1008, 1008, 1030, 3166, 11063, 3158, 2218, 2368, 1026, 2852, 2213, 1030, 11463, 2361, 1012, 17953, 1028, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace PlaygroundDesign\Service; use PlaygroundDesign\Entity\Theme as ThemeEntity; use Laminas\Form\Form; use Laminas\ServiceManager\ServiceManager; use Laminas\Validator\NotEmpty; use Laminas\EventManager\EventManagerAwareTrait; use PlaygroundDesign\Options\ModuleOptions; use DoctrineModule\Validator\NoObjectExists as NoObjectExistsValidator; use Laminas\Stdlib\ErrorHandler; use Laminas\ServiceManager\ServiceLocatorInterface; class Theme { use EventManagerAwareTrait; /** * @var themeMapperInterface */ protected $themeMapper; /** * @var ServiceManager */ protected $serviceManager; /** * @var UserServiceOptionsInterface */ protected $options; public static $files = array('assets.php', 'layout.php', 'theme.php'); public function __construct(ServiceLocatorInterface $locator) { $this->serviceManager = $locator; } /** * * This service is ready for create a theme * * @param array $data * @param string $formClass * * @return \PlaygroundPartnership\Entity\Theme */ public function create(array $data, $formClass) { $valid = new NotEmpty(); if (!$valid->isValid($data['title'])) { return false; } $theme = new ThemeEntity; $form = $this->getServiceManager()->get($formClass); $form->bind($theme); $theme->setImage('tmp'); $form->setData($data); if (!$form->isValid()) { return false; } if (!$this->checkDirectoryTheme($theme, $data)) { mkdir($theme->getBasePath().'/'.$data['area'].'/'.$data['package'].'/'.$data['theme'], 0777, true); } $this->createFiles($theme, $data); $themeMapper = $this->getThemeMapper(); $theme = $themeMapper->insert($theme); $this->uploadImage($theme, $data); $theme = $themeMapper->update($theme); return $theme; } /** * * This service is ready for edit a theme * * @param array $data * @param string $theme * @param string $formClass * * @return \PlaygroundDesignEntity\Theme */ public function edit(array $data, $theme, $formClass) { $valid = new NotEmpty(); if (!$valid->isValid($data['title'])) { return false; } $entityManager = $this->getServiceManager()->get('playgrounddesign_doctrine_em'); $form = $this->getServiceManager()->get($formClass); $form->bind($theme); $form->setData($data); if (!$form->isValid() || !$this->checkDirectoryTheme($theme, $data)) { return false; } $this->uploadImage($theme, $data); $theme = $this->getThemeMapper()->update($theme); return $theme; } public function uploadImage($theme, $data) { if (!empty($data['uploadImage']['tmp_name'])) { $path = $this->getOptions()->getMediaPath() . $data['area'] . DIRECTORY_SEPARATOR . $data['package'] . DIRECTORY_SEPARATOR . $data['theme'] . '/assets/images/screenshots/'; if (!is_dir($path)) { mkdir($path, 0777, true); } $media_url = $this->getOptions()->getMediaUrl() . '/'; move_uploaded_file($data['uploadImage']['tmp_name'], $path . $theme->getId() . "-" . $data['uploadImage']['name']); $theme->setImage($media_url . $theme->getId() . "-" . $data['uploadImage']['name']); } return $theme; } /** * * Check if the directory theme exist * * @param \PlaygroundPartnership\Entity\Theme $theme * @param array $data * * @return bool $bool */ public function checkDirectoryTheme($theme, $data) { $newUrlTheme = $theme->getBasePath().'/'.$data['area'].'/'.$data['package'].'/'.$data['theme']; if (!is_dir($newUrlTheme)) { return false; } return true; } public function createFiles($theme, $data) { foreach (self::$files as $file) { if (file_exists($theme->getBasePath().$data['area'].'/'.$data['package'].'/'.$data['theme'].'/'.$file)) { continue; } $contentAssets = file_get_contents(__DIR__.'/../Templates/'.$file); $contentAssets = str_replace(array('{{area}}', '{{package}}', '{{theme}}', '{{title}}'), array($data['area'], $data['package'], $data['theme'], $data['title']), $contentAssets); file_put_contents($theme->getBasePath().$data['area'].'/'.$data['package'].'/'.$data['theme'].'/'.$file, $contentAssets); } } /** * findById : recupere l'entite en fonction de son id * @param int $id id du theme * * @return PlaygroundDesign\Entity\Theme $theme */ public function findById($id) { return $this->getThemeMapper()->findById($id); } /** * insert : insert en base une entité theme * @param PlaygroundDesign\Entity\Theme $entity theme * * @return PlaygroundDesign\Entity\Theme $theme */ public function insert($entity) { return $this->getThemeMapper()->insert($entity); } /** * insert : met a jour en base une entité theme * @param PlaygroundDesign\Entity\Theme $entity theme * * @return PlaygroundDesign\Entity\Theme $theme */ public function update($entity) { return $this->getThemeMapper()->update($entity); } /** * remove : supprimer une entite theme * @param PlaygroundDesign\Entity\Theme $entity theme * */ public function remove($entity) { $this->getThemeMapper()->remove($entity); } /** * findActiveTheme : recupere des entites en fonction du filtre active * @param boolean $active valeur du champ active * * @return collection $themes collection de PlaygroundDesign\Entity\Theme */ public function findActiveTheme($active = true) { return $this->getThemeMapper()->findActiveTheme($active); } /** * findActiveThemeByArea : recupere des entites active en fonction du filtre Area * @param string $area area du theme * @param boolean $active valeur du champ active * * @return collection $themes collection de PlaygroundDesign\Entity\Theme */ public function findActiveThemeByArea($area, $active = true) { return $this->getThemeMapper()->findActiveThemeByArea($area, $active); } /** * findThemeByAreaPackageAndBase : recupere des entites en fonction des filtre Area, Package et Theme * @param string $area area du theme * @param string $package package du theme * @param string $base base du theme * * @return collection $themes collection de PlaygroundDesign\Entity\Theme */ public function findThemeByAreaPackageAndBase($area, $package, $base) { return $this->getThemeMapper()->findThemeByAreaPackageAndBase($area, $package, $base); } /** * getThemeMapper * * @return ThemeMapperInterface */ public function getThemeMapper() { if (null === $this->themeMapper) { $this->themeMapper = $this->getServiceManager()->get('playgrounddesign_theme_mapper'); } return $this->themeMapper; } /** * setThemeMapper * @param ThemeMapperInterface $themeMapper * * @return PlaygroundPartnership\Entity\Theme Theme */ public function setThemeMapper($themeMapper) { $this->themeMapper = $themeMapper; return $this; } /** * setOptions * @param ModuleOptions $options * * @return PlaygroundDesign\Service\Theme $this */ public function setOptions(ModuleOptions $options) { $this->options = $options; return $this; } /** * getOptions * * @return ModuleOptions $optins */ public function getOptions() { if (!$this->options instanceof ModuleOptions) { $this->setOptions($this->getServiceManager()->get('playgrounddesign_module_options')); } return $this->options; } /** * Retrieve service manager instance * * @return ServiceManager */ public function getServiceManager() { return $this->serviceManager; } }
gregorybesson/PlaygroundDesign
src/Service/Theme.php
PHP
mit
8,422
[ 30522, 1026, 1029, 25718, 3415, 15327, 14705, 6155, 23773, 1032, 2326, 1025, 2224, 14705, 6155, 23773, 1032, 9178, 1032, 4323, 2004, 4323, 4765, 3012, 1025, 2224, 16983, 15227, 1032, 2433, 1032, 2433, 1025, 2224, 16983, 15227, 1032, 2326, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.example.pengpeng.db; import org.litepal.crud.DataSupport; /** * Created by Administrator on 2017/9/21 0021. */ public class County extends DataSupport { private int id; private String countyName; private String weatherId; private int cityId; public int getId() {return id;} public void setId(int id) {this.id = id;} public String getCountyName() {return countyName;} public void setCountyName(String countyName) {this.countyName = countyName;} public String getWeatherId() {return weatherId;} public void setWeatherId(String weatherId) {this.weatherId = weatherId;} public int getCityId() {return cityId;} public void setCityId(int cityId) {this.cityId = cityId;} }
Zhangbaowen13/greenhouse
app/src/main/java/com/example/pengpeng/db/County.java
Java
apache-2.0
731
[ 30522, 7427, 4012, 1012, 2742, 1012, 26473, 11837, 2290, 1012, 16962, 1025, 12324, 8917, 1012, 5507, 13699, 2389, 1012, 13675, 6784, 1012, 2951, 6342, 9397, 11589, 1025, 1013, 1008, 1008, 1008, 2580, 2011, 8911, 2006, 2418, 1013, 1023, 1013...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <meta charset=utf-8> <title>Redirecting...</title> <link rel=canonical href="../業/index.html"> <meta http-equiv=refresh content="0; url='../業/index.html'"> <h1>Redirecting...</h1> <a href="../業/index.html">Click here if you are not redirected.</a> <script>location='../業/index.html'</script>
hochanh/hochanh.github.io
rtk/v4/1792.html
HTML
apache-2.0
316
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 18804, 25869, 13462, 1027, 21183, 2546, 1011, 1022, 1028, 1026, 2516, 1028, 2417, 7442, 11873, 1012, 1012, 1012, 1026, 1013, 2516, 1028, 1026, 4957, 2128, 2140, 1027, 18562, 17850, 12879, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#include "util/mapper.h" #include "method.h" namespace frost { cstr_map_t<http_method> http_method_assist::_desc; // frost::unordered_map<std::string, http_method> http_method_assist::_desc // = mapper<std::string, http_method>() // ("OPTIONS", http_method::OPTIONS) // ("GET", http_method::GET) // ("HEAD", http_method::HEAD) // ("POST", http_method::POST) // ("PUT", http_method::PUT) // ("DELETE", http_method::DELETE) // ("TRACE", http_method::TRACE) // ("CONNECT", http_method::CONNECT) // ; }
igorcoding/frost
frost/http/method.cc
C++
mit
673
[ 30522, 1001, 2421, 1000, 21183, 4014, 1013, 4949, 4842, 1012, 1044, 1000, 1001, 2421, 1000, 4118, 1012, 1044, 30524, 4118, 1035, 6509, 1024, 1024, 1035, 4078, 2278, 1025, 1013, 1013, 10097, 1024, 1024, 27776, 26764, 2098, 1035, 4949, 1026, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Profiler; use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface; /** * Profile. * * @author Fabien Potencier <fabien@symfony.com> */ class Profile { private $token; /** * @var DataCollectorInterface[] */ private $collectors = array(); private $ip; private $method; private $url; private $time; /** * @var Profile */ private $parent; /** * @var Profile[] */ private $children = array(); /** * Constructor. * * @param string $token The token */ public function __construct($token) { $this->token = $token; } /** * Returns the parent profile. * * @return Profile The parent profile */ public function getParent() { return $this->parent; } /** * Sets the parent token * * @param Profile $parent The parent Profile */ public function setParent( Profile $parent ) { $this->parent = $parent; } /** * Returns the parent token. * * @return null|string The parent token */ public function getParentToken() { return $this->parent ? $this->parent->getToken() : null; } /** * Gets the token. * * @return string The token */ public function getToken() { return $this->token; } /** * Sets the token. * * @param string $token The token */ public function setToken( $token ) { $this->token = $token; } /** * Returns the IP. * * @return string The IP */ public function getIp() { return $this->ip; } /** * Sets the IP. * * @param string $ip */ public function setIp($ip) { $this->ip = $ip; } /** * Returns the request method. * * @return string The request method */ public function getMethod() { return $this->method; } public function setMethod($method) { $this->method = $method; } /** * Returns the URL. * * @return string The URL */ public function getUrl() { return $this->url; } public function setUrl($url) { $this->url = $url; } /** * Returns the time. * * @return string The time */ public function getTime() { if (null === $this->time) { return 0; } return $this->time; } public function setTime($time) { $this->time = $time; } /** * Finds children profilers. * * @return Profile[] An array of Profile */ public function getChildren() { return $this->children; } /** * Sets children profiler. * * @param Profile[] $children An array of Profile */ public function setChildren(array $children) { $this->children = array(); foreach ($children as $child) { $this->addChild($child); } } /** * Adds the child token * * @param Profile $child The child Profile */ public function addChild(Profile $child) { $this->children[] = $child; $child->setParent($this); } /** * Gets a Collector by name. * * @param string $name A collector name * * @return DataCollectorInterface A DataCollectorInterface instance * * @throws \InvalidArgumentException if the collector does not exist */ public function getCollector($name) { if (!isset($this->collectors[$name])) { throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name)); } return $this->collectors[$name]; } /** * Gets the Collectors associated with this profile. * * @return DataCollectorInterface[] */ public function getCollectors() { return $this->collectors; } /** * Sets the Collectors associated with this profile. * * @param DataCollectorInterface[] $collectors */ public function setCollectors(array $collectors) { $this->collectors = array(); foreach ($collectors as $collector) { $this->addCollector($collector); } } /** * Adds a Collector. * * @param DataCollectorInterface $collector A DataCollectorInterface instance */ public function addCollector(DataCollectorInterface $collector) { $this->collectors[$collector->getName()] = $collector; } /** * Returns true if a Collector for the given name exists. * * @param string $name A collector name * * @return bool */ public function hasCollector($name) { return isset($this->collectors[$name]); } public function __sleep() { return array('token', 'parent', 'children', 'collectors', 'ip', 'method', 'url', 'time'); } }
KWZwickau/KREDA-Sphere
Library/MOC-V/Component/Router/Vendor/Symfony/Component/HttpKernel/Profiler/Profile.php
PHP
agpl-3.0
5,311
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 2023, 5371, 2003, 2112, 1997, 1996, 25353, 2213, 14876, 4890, 7427, 1012, 1008, 1008, 1006, 1039, 1007, 6904, 11283, 2078, 8962, 2368, 19562, 1026, 6904, 11283, 2078, 1030, 25353, 2213, 14876, 489...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import os import sys import argparse from pandaharvester.harvesterconfig import harvester_config from pandaharvester.harvestermisc.selfcheck import harvesterPackageInfo def main(): oparser = argparse.ArgumentParser(prog='prescript', add_help=True) oparser.add_argument('-f', '--local_info_file', action='store', dest='local_info_file', help='path of harvester local info file') if len(sys.argv) == 1: print('No argument or flag specified. Did nothing') sys.exit(0) args = oparser.parse_args(sys.argv[1:]) local_info_file = os.path.normpath(args.local_info_file) hpi = harvesterPackageInfo(local_info_file=local_info_file) if hpi.package_changed: print('Harvester package changed') #TODO pass hpi.renew_local_info() else: print('Harvester package unchanged. Skipped') if __name__ == '__main__': main()
dougbenjamin/panda-harvester
pandaharvester/harvesterscripts/prescript.py
Python
apache-2.0
901
[ 30522, 12324, 9808, 12324, 25353, 2015, 12324, 12098, 21600, 11650, 2063, 2013, 25462, 8167, 6961, 3334, 1012, 11203, 2121, 8663, 8873, 2290, 12324, 11203, 2121, 1035, 9530, 8873, 2290, 2013, 25462, 8167, 6961, 3334, 1012, 11203, 2121, 15630,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE HTML> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>My Love with you</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <style type="text/css"> @font-face { font-family: digit; src: url('digital-7_mono.ttf') format("truetype"); } </style> <link href="css/default.css" type="text/css" rel="stylesheet"> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/garden.js"></script> <script type="text/javascript" src="js/functions.js"></script> </head> <body> <div id="mainDiv"> <div id="content"> <div id="code"> <span class="comments">/**</span><br /> <span class="space"/><span class="comments">* We are both Fudan SSers and programmers,</span><br /> <span class="space"/><span class="comments">* so I write some code to celebrate our 1st anniversary.</span><br /> <span class="space"/><span class="comments">*/</span><br /> Boy i = <span class="keyword">new</span> Boy(<span class="string">"Yimu"</span>);<br /> Girl u = <span class="keyword">new</span> Girl(<span class="string">"Qingtian"</span>);<br /> <span class="comments">// Feb 2, 2013, I told you I love you. </span><br /> i.love(u);<br /> <span class="comments">// Luckily, you accepted and became my girlfriend eversince.</span><br /> u.accepted();<br /> <span class="comments">// Since then, I miss u every day.</span><br /> i.miss(u);<br /> <span class="comments">// And take care of u and our love.</span><br /> i.takeCareOf(u);<br /> <span class="comments">// You say that you won't be so easy to marry me.</span><br /> <span class="comments">// So I keep waiting and I have confidence that you will.</span><br /> <span class="keyword">boolean</span> isHesitate = <span class="keyword">true</span>;<br /> <span class="keyword">while</span> (isHesitate) {<br /> <span class="placeholder"/>i.waitFor(u);<br /> <span class="placeholder"/><span class="comments">// I think it is an important decision</span><br /> <span class="placeholder"/><span class="comments">// and you should think it over.</span><br /> <span class="placeholder"/>isHesitate = u.thinkOver();<br /> }<br /> <span class="comments">// After a romantic wedding, we will live happily ever after.</span><br /> i.marry(u);<br /> i.liveHappilyWith(u);<br /> </div> <div id="loveHeart"> <canvas id="garden"></canvas> <div id="words"> <div id="messages"> Qingtian, I have fallen in love with you for <div id="elapseClock"></div> </div> <div id="loveu"> Love u forever and ever.<br/> <div class="signature">- Yimu</div> </div> </div> </div> </div> <div id="copyright"> <!-- Inspired by <a href="http://www.openrise.com/lab/FlowerPower/">FlowerPower</a> project.<br />--> Copyright © 2013 by Yimu.me </div> </div> <script type="text/javascript"> var offsetX = $("#loveHeart").width() / 2; var offsetY = $("#loveHeart").height() / 2 - 55; var together = new Date(); together.setFullYear(2013, 1, 2); together.setHours(20); together.setMinutes(0); together.setSeconds(0); together.setMilliseconds(0); if (!document.createElement('canvas').getContext) { var msg = document.createElement("div"); msg.id = "errorMsg"; msg.innerHTML = "Your browser doesn't support HTML5!<br/>Recommend use Chrome 14+/IE 9+/Firefox 7+/Safari 4+"; document.body.appendChild(msg); $("#code").css("display", "none") $("#copyright").css("position", "absolute"); $("#copyright").css("bottom", "10px"); document.execCommand("stop"); } else { setTimeout(function () { startHeartAnimation(); }, 5000); timeElapse(together); setInterval(function () { timeElapse(together); }, 500); adjustCodePosition(); $("#code").typewriter(); } </script> </body> </html>
yimun/Blog
source/qingtian/indexorg.html
HTML
apache-2.0
3,964
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 20950, 3619, 1027, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, 8917, 1013, 2639, 1013, 1060, 11039, 19968, 1000, 20950, 1024, 11374, 1027, 1000, 4372, 1000, 11374, 102...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * OWASP Benchmark Project v1.1 * * This file is part of the Open Web Application Security Project (OWASP) * Benchmark Project. For details, please see * <a href="https://www.owasp.org/index.php/Benchmark">https://www.owasp.org/index.php/Benchmark</a>. * * The Benchmark is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Foundation, version 2. * * The Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * @author Nick Sanidas <a href="https://www.aspectsecurity.com">Aspect Security</a> * @created 2015 */ package org.owasp.benchmark.testcode; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/BenchmarkTest05767") public class BenchmarkTest05767 extends HttpServlet { private static final long serialVersionUID = 1L; @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String[] values = request.getParameterValues("foo"); String param; if (values.length != 0) param = request.getParameterValues("foo")[0]; else param = null; String bar; // Simple if statement that assigns constant to bar on true condition int i = 86; if ( (7*42) - i > 200 ) bar = "This_should_always_happen"; else bar = param; try { java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG"); boolean randNumber = getNextNumber(numGen); } catch (java.security.NoSuchAlgorithmException e) { System.out.println("Problem executing SecureRandom.nextBoolean() - TestCase"); throw new ServletException(e); } response.getWriter().println("Weak Randomness Test java.security.SecureRandom.nextBoolean() executed"); } boolean getNextNumber(java.util.Random generator) { return generator.nextBoolean(); } }
iammyr/Benchmark
src/main/java/org/owasp/benchmark/testcode/BenchmarkTest05767.java
Java
gpl-2.0
2,444
[ 30522, 1013, 1008, 1008, 1008, 27593, 3022, 2361, 6847, 10665, 2622, 1058, 2487, 1012, 1015, 1008, 1008, 2023, 5371, 2003, 2112, 1997, 1996, 2330, 4773, 4646, 3036, 2622, 1006, 27593, 3022, 2361, 1007, 1008, 6847, 10665, 2622, 1012, 2005, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import $ from '../core'; import { userAgent } from '../../common/navigator'; $.os = (() => { const match = userAgent.match($.regexp.os); const mobile = (/mobile/i).test(userAgent); const os = RegExp.$1.toLowerCase(); if($.device.idevice){ return 'ios'; } if(os === 'blackberry' && mobile){ return 'bbmobile'; } if(os === 'macintosh'){ return 'osx'; } return os; })(); export default $;
dysfunc/eleven
src/query/support/os.js
JavaScript
bsd-2-clause
424
[ 30522, 12324, 1002, 2013, 1005, 1012, 1012, 1013, 4563, 1005, 1025, 12324, 1063, 5310, 4270, 3372, 1065, 2013, 1005, 1012, 1012, 1013, 1012, 1012, 1013, 2691, 1013, 20532, 1005, 1025, 1002, 1012, 9808, 1027, 1006, 1006, 1007, 1027, 1028, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package demo import ( _ "fmt" cp "github.com/eka-tel72/go-chipmunk62/chipmunk" ) /* #include <stdlib.h> int Random(void) { return rand(); } void Seed(unsigned int i) { srand(i); } */ import "C" type tumble struct { *demoClass rogueBoxBody *cp.Body } var tumbleInst = &tumble{ &demoClass{ name: "Tumble", timestep: 1.0/180.0, }, nil, } func (t *tumble) Update(space *cp.Space, dt float64) { fdt := cp.Float(dt) cp.BodyUpdatePosition(t.rogueBoxBody, fdt) cp.SpaceStep(space, fdt) } func tumbleAddBox(space *cp.Space, pos cp.Vect, mass, width, height cp.Float) { body := cp.SpaceAddBody( space, cp.BodyNew(mass, cp.MomentForBox(mass, width, height)) ) cp.BodySetPos(body, pos) shape := cp.SpaceAddShape(space, cp.BoxShapeNew(body, width, height)) cp.ShapeSetElasticity(shape, 0.0) cp.ShapeSetFriction(shape, 0.7) } func tumbleAddSegment(space *cp.Space, pos cp.Vect, mass, width, height cp.Float) { body := cp.SpaceAddBody( space, cp.BodyNew(mass, cp.MomentForBox(mass, width, height)) ) cp.BodySetPos(body, pos) shape := cp.SpaceAddShape(space, cp.SegmentShapeNew(body, cp.V(0.0, (height - width)/2.0), cp.V(0.0, (width - height)/2.0), width/2.0)) cp.ShapeSetElasticity(shape, 0.0) cp.ShapeSetFriction(shape, 0.7) } func tumbleAddCircle(space *cp.Space, pos cp.Vect, mass, radius cp.Float) { body := cp.SpaceAddBody( space, cp.BodyNew(mass, cp.MomentForCircle(mass, 0.0, radius, cpvzero)) ) cp.BodySetPos(body, pos) shape := cp.SpaceAddShape(space, cp.CircleShapeNew(body, radius, cpvzero)) cp.ShapeSetElasticity(shape, 0.0) cp.ShapeSetFriction(shape, 0.7) } func (t *tumble) Init() *cp.Space { C.Seed(45073) space := cp.SpaceNew() cp.SpaceSetGravity(space, cp.V(0, -600)) rogueBoxBody := cp.BodyNew(infinity, infinity) cp.BodySetAngVel(rogueBoxBody, 0.4) a := cp.V(-200, -200) b := cp.V(-200, 200) c := cp.V( 200, 200) d := cp.V( 200, -200) seg := [][]cp.Vect {{a, b}, {b, c}, {c, d}, {d, a}} for i := 0; i < len(seg); i++ { vs := seg[i] shape := cp.SpaceAddShape(space, cp.SegmentShapeNew(rogueBoxBody, vs[0], vs[1], 0.0)) cp.ShapeSetElasticity(shape, 1.0) cp.ShapeSetFriction(shape, 1.0) cp.ShapeSetLayers(shape, notGrabableMask) } mass := cp.Float(1.0) width := cp.Float(30.0) height := width*2 for i := 0; i < 7; i++ { for j := 0; j < 3; j++ { pos := cp.V(cp.Float(i)*width - 150, cp.Float(j)*height - 150) switch (C.Random()%3000)/1000 { default: tumbleAddCircle(space, cp.Vadd(pos, cp.V(0.0, (height - width)/2.0)), mass, width/2.0) tumbleAddCircle(space, cp.Vadd(pos, cp.V(0.0, (width - height)/2.0)), mass, width/2.0) case 0: tumbleAddBox(space, pos, mass, width, height) case 1: tumbleAddSegment(space, pos, mass, width, height) } } } t.rogueBoxBody = rogueBoxBody return space } func (t *tumble) Destroy(space *cp.Space) { freeSpaceChildren(space) cp.BodyFree(t.rogueBoxBody) cp.SpaceFree(space) }
eka-tel72/go-chipmunk62
chipmunk62demo/demo/tumble.go
GO
mit
2,935
[ 30522, 7427, 9703, 12324, 1006, 1035, 1000, 4718, 2102, 1000, 18133, 1000, 21025, 2705, 12083, 1012, 4012, 1013, 23969, 2050, 1011, 10093, 2581, 2475, 1013, 2175, 1011, 9090, 23041, 2243, 2575, 2475, 1013, 9090, 23041, 2243, 1000, 1007, 101...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
require "cases/helper" require 'support/connection_helper' require 'support/schema_dumping_helper' class PostgresqlBitStringTest < ActiveRecord::PostgreSQLTestCase include ConnectionHelper include SchemaDumpingHelper class PostgresqlBitString < ActiveRecord::Base; end def setup @connection = ActiveRecord::Base.connection @connection.create_table('postgresql_bit_strings', :force => true) do |t| t.bit :a_bit, default: "00000011", limit: 8 t.bit_varying :a_bit_varying, default: "0011", limit: 4 t.bit :another_bit t.bit_varying :another_bit_varying end end def teardown return unless @connection @connection.drop_table 'postgresql_bit_strings', if_exists: true end def test_bit_string_column column = PostgresqlBitString.columns_hash["a_bit"] assert_equal :bit, column.type assert_equal "bit(8)", column.sql_type assert_not column.array? type = PostgresqlBitString.type_for_attribute("a_bit") assert_not type.binary? end def test_bit_string_varying_column column = PostgresqlBitString.columns_hash["a_bit_varying"] assert_equal :bit_varying, column.type assert_equal "bit varying(4)", column.sql_type assert_not column.array? type = PostgresqlBitString.type_for_attribute("a_bit_varying") assert_not type.binary? end def test_default assert_equal "00000011", PostgresqlBitString.column_defaults['a_bit'] assert_equal "00000011", PostgresqlBitString.new.a_bit assert_equal "0011", PostgresqlBitString.column_defaults['a_bit_varying'] assert_equal "0011", PostgresqlBitString.new.a_bit_varying end def test_schema_dumping output = dump_table_schema("postgresql_bit_strings") assert_match %r{t\.bit\s+"a_bit",\s+limit: 8,\s+default: "00000011"$}, output assert_match %r{t\.bit_varying\s+"a_bit_varying",\s+limit: 4,\s+default: "0011"$}, output end def test_assigning_invalid_hex_string_raises_exception assert_raises(ActiveRecord::StatementInvalid) { PostgresqlBitString.create! a_bit: "FF" } assert_raises(ActiveRecord::StatementInvalid) { PostgresqlBitString.create! a_bit_varying: "FF" } end def test_roundtrip PostgresqlBitString.create! a_bit: "00001010", a_bit_varying: "0101" record = PostgresqlBitString.first assert_equal "00001010", record.a_bit assert_equal "0101", record.a_bit_varying record.a_bit = "11111111" record.a_bit_varying = "0xF" record.save! assert record.reload assert_equal "11111111", record.a_bit assert_equal "1111", record.a_bit_varying end end
rokn/Count_Words_2015
fetched_code/ruby/bit_string_test.rb
Ruby
mit
2,595
[ 30522, 5478, 1000, 3572, 1013, 2393, 2121, 1000, 5478, 1005, 2490, 1013, 4434, 1035, 2393, 2121, 1005, 5478, 1005, 2490, 1013, 8040, 28433, 1035, 23642, 1035, 2393, 2121, 1005, 2465, 2695, 17603, 2015, 4160, 20850, 12762, 18886, 3070, 22199...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...