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 |
|---|---|---|---|---|---|---|---|---|---|
<?php
require_once OPS_APPLICATION_PATH
. '/services/Optimization/Analyzer/Abstract/Base.php';
class Ops_Service_Optimization_Analyzer_KeywordInPattern
extends Ops_Service_Optimization_Analyzer_Abstract_Base
{
public function __invoke($pattern, $keyword=NULL, $contentType='html')
{
$content = $this->_parent->getData($contentType);
if (is_null($keyword)) {
$keyword = $this->_parent->getData('keyword');
}
if (!preg_match_all($pattern, $content, $matches)) {
return FALSE;
}
foreach ($matches[1] as $match) {
if ($this->_parent
->analyzeKeywordInText($match, $keyword)
) {
return TRUE;
}
}
return FALSE;
}
} | tranvanhoa533/ecommerce_assignment2 | wp-content/plugins/wp-onpage-seo/application/services/Optimization/Analyzer/KeywordInPattern.php | PHP | gpl-2.0 | 789 | [
30522,
1026,
1029,
25718,
5478,
1035,
2320,
23092,
1035,
4646,
1035,
4130,
1012,
1005,
1013,
2578,
1013,
20600,
1013,
17908,
2099,
1013,
10061,
1013,
2918,
1012,
25718,
1005,
1025,
2465,
23092,
1035,
2326,
1035,
20600,
1035,
17908,
2099,
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... |
require 'codeclimate-test-reporter'
CodeClimate::TestReporter.start
require 'pry'
require 'pon'
require 'rails/all'
require 'rspec/rails'
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
RSpec.configure do |config|
# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
# These two settings work together to allow you to limit a spec run
# to individual examples or groups you care about by tagging them with
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
# get run.
config.filter_run :focus
config.run_all_when_everything_filtered = true
# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = 'doc'
end
# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
config.profile_examples = 10
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = :random
# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
# as the one that triggered the failure.
Kernel.srand config.seed
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# Enable only the newer, non-monkey-patching expect syntax.
# For more details, see:
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
expectations.syntax = :expect
end
# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
# Enable only the newer, non-monkey-patching expect syntax.
# For more details, see:
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
mocks.syntax = :expect
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended.
mocks.verify_partial_doubles = true
end
end
| 10beat/pon | spec/spec_helper.rb | Ruby | mit | 2,819 | [
30522,
5478,
1005,
3642,
20464,
21499,
1011,
3231,
1011,
6398,
1005,
3642,
20464,
21499,
1024,
1024,
3231,
2890,
6442,
2121,
1012,
2707,
5478,
1005,
29198,
1005,
5478,
1005,
13433,
2078,
1005,
5478,
1005,
15168,
1013,
2035,
1005,
5478,
1005... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.github.sunnybat.paxchecker.setup.email;
import com.github.sunnybat.commoncode.email.EmailAddress;
import com.github.sunnybat.commoncode.email.account.EmailAccount;
import com.github.sunnybat.commoncode.preferences.PreferenceHandler;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
/**
*
* @author SunnyBat
*/
public class EmailSetupGUI extends javax.swing.JFrame {
private AuthenticationCallback myCallback = new AuthenticationCallback();
private AuthGmail authGmail = new AuthGmail(myCallback);
private AuthSMTP authSmtp = new AuthSMTP(myCallback);
private PreferenceHandler prefs;
private EmailAccount finalizedEmailAccount;
private boolean disableEmail = false;
private List<EmailAddress> savedEmailAddresses;
private boolean savedIsGmail;
/**
* Creates new form EmailUIWrapper
*
* @param prefs The Preferences to save email configuration settings to and load from
*/
public EmailSetupGUI(PreferenceHandler prefs) {
this.prefs = prefs;
initComponents();
customComponents();
}
private void customComponents() {
String smtpAddress = prefs.getStringPreference("EMAIL");
String emailString = prefs.getStringPreference("CELLNUM");
String emailType = prefs.getStringPreference("EMAILTYPE");
// TODO: we need to initialize everything here, including Send To
// addresses and the EmailAccount we're using
if (emailType != null && emailType.equalsIgnoreCase("SMTP")) {
JRBSMTP.setSelected(true);
setAuthPanel(authSmtp);
savedIsGmail = false;
if (smtpAddress != null) {
authSmtp.setEmailAddress(smtpAddress);
} else {
System.out.println("smtpIsNull");
}
authSmtp.recordCurrentFields();
} else {
JRBGmail.setSelected(true);
setAuthPanel(authGmail);
savedIsGmail = true;
if (emailType != null) { // Assumed to be Gmail
authGmail.authenticate();
}
authGmail.recordCurrentFields();
}
if (emailString != null) {
List<EmailAddress> addresses = EmailAddress.convertToList(emailString);
for (EmailAddress address : addresses) {
DefaultTableModel table = (DefaultTableModel) JTCellNumbers.getModel();
table.addRow(new Object[]{address.getCarrierName().equalsIgnoreCase("[Other]") ? address.getCompleteAddress() : address.getAddressBeginning(), address.getCarrierName()});
}
}
savedEmailAddresses = getCurrentEmails();
savedIsGmail = JRBGmail.isSelected();
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
int result = JOptionPane.showConfirmDialog(null,
"Would you like to save your changes?\r\nYes: Save Changes\r\nNo: Disable Email\r\nCancel: Discard changes\r\n[X] Button: Keep window open",
"Save Changes",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (result == JOptionPane.YES_OPTION) {
saveChanges();
} else if (result == JOptionPane.NO_OPTION) {
disableEmail();
} else if (result == JOptionPane.CANCEL_OPTION) {
cancelChanges();
}
}
});
}
/**
* Gets the currently configured EmailAccount. This includes the email addresses currently
* configured to be sent to. The EmailAccount must be successfully authenticated, otherwise null
* will be returned.
*
* @return The EmailAccount configured, or null if not set up
*/
public EmailAccount getEmailAccount() {
if (disableEmail) {
return null;
}
EmailAccount account;
if (JRBGmail.isSelected() && authGmail.isAuthenticated()) {
account = authGmail.getEmailAccount();
} else if (JRBSMTP.isSelected() && authSmtp.isAuthenticated()) {
account = authSmtp.getEmailAccount();
} else {
return null;
}
// === Add emails to account ===
account.clearAllSendAddresses(); // TODO Check to make sure this is the right thing to do, or if there's a better way
DefaultTableModel tableModel = (DefaultTableModel) JTCellNumbers.getModel();
if (tableModel.getRowCount() == 0) {
return null;
} else {
for (int i = 0; i < tableModel.getRowCount(); i++) {
EmailAddress toAdd;
String emailBeginning = (String) tableModel.getValueAt(i, 0);
String emailCarrier = (String) tableModel.getValueAt(i, 1);
if (emailCarrier.equalsIgnoreCase("[Other]")) {
toAdd = new EmailAddress(emailBeginning);
} else {
toAdd = new EmailAddress(emailBeginning + EmailAddress.getCarrierExtension(emailCarrier));
}
account.addBccEmailAddress(toAdd);
}
}
finalizedEmailAccount = account;
return finalizedEmailAccount;
}
public String getEmailType() {
if (JRBGmail.isSelected() && authGmail.isAuthenticated()) {
return "Gmail API";
} else if (JRBSMTP.isSelected() && authSmtp.isAuthenticated()) {
return "SMTP";
} else {
return "Disabled";
}
}
/**
* Gets the semicolon-delimited String representing all of the email addresses configured.
*
* @return All the configured email addresses
*/
public String getEmailAddressesString() {
List<EmailAddress> addresses = getCurrentEmails();
StringBuilder allAddresses = new StringBuilder();
for (int i = 0; i < addresses.size(); i++) {
if (i > 0) {
allAddresses.append(";");
}
allAddresses.append(addresses.get(i).getCompleteAddress());
}
return allAddresses.toString();
}
private List<EmailAddress> getCurrentEmails() {
List<EmailAddress> ret = new ArrayList<>();
DefaultTableModel tableModel = (DefaultTableModel) JTCellNumbers.getModel();
for (int i = 0; i < tableModel.getRowCount(); i++) {
try {
EmailAddress toAdd;
String emailBeginning = (String) tableModel.getValueAt(i, 0);
String emailCarrier = (String) tableModel.getValueAt(i, 1);
if (emailCarrier.equalsIgnoreCase("[Other]")) {
toAdd = new EmailAddress(emailBeginning);
} else {
toAdd = new EmailAddress(emailBeginning + EmailAddress.getCarrierExtension(emailCarrier));
}
ret.add(toAdd);
} catch (IllegalArgumentException iae) {
System.out.println("Invalid email address: " + tableModel.getValueAt(i, 0) + tableModel.getValueAt(i, 1));
}
}
return ret;
}
private void addEmail() {
String cellNumber = JTFCellNumber.getText();
String carrier = JCBCarrier.getSelectedItem().toString();
if (!cellNumber.isEmpty()) {
if (cellNumber.contains("@")) { // Full email configured
carrier = "[Other]";
}
((DefaultTableModel) JTCellNumbers.getModel()).addRow(new Object[]{cellNumber, carrier});
JTFCellNumber.setText(null);
JCBCarrier.setSelectedIndex(0);
JTFCellNumber.requestFocus();
}
}
private void resetChanges() {
DefaultTableModel model = (DefaultTableModel) JTCellNumbers.getModel();
for (int i = model.getRowCount() - 1; i >= 0; i--) {
model.removeRow(i);
}
if (savedEmailAddresses != null) {
for (EmailAddress address : savedEmailAddresses) {
model.addRow(new Object[]{address.getAddressBeginning(), EmailAddress.getProvider(address.getAddressEnding())});
}
}
if (savedIsGmail) {
JRBGmail.setSelected(true);
setAuthPanel(authGmail);
} else {
JRBSMTP.setSelected(true);
setAuthPanel(authSmtp);
}
}
private void setAuthPanel(JPanel toUse) {
JPAuthInfo.removeAll();
JPAuthInfo.add(toUse);
JPAuthInfo.revalidate();
JPAuthInfo.repaint();
pack();
}
private void resetUserInputFields() {
JTPComponents.setSelectedIndex(0);
JTFCellNumber.setText(null);
JCBCarrier.setSelectedIndex(0);
}
private void updatePreferences() {
EmailAccount toSave = getEmailAccount();
if (!disableEmail && toSave != null) {
prefs.getPreferenceObject("EMAIL").setValue(toSave.getEmailAddress());
prefs.getPreferenceObject("CELLNUM").setValue(getEmailAddressesString());
prefs.getPreferenceObject("EMAILTYPE").setValue(getEmailType());
prefs.getPreferenceObject("EMAILENABLED").setValue(true);
} else {
prefs.getPreferenceObject("EMAIL").setValue(null);
prefs.getPreferenceObject("CELLNUM").setValue(null);
prefs.getPreferenceObject("EMAILTYPE").setValue(null);
prefs.getPreferenceObject("EMAILENABLED").setValue(false);
}
}
private void saveChanges() {
if (getCurrentEmails().isEmpty()) {
int result = JOptionPane.showConfirmDialog(null, "You have no Send To emails configured. This means emails will still be disabled.\r\nAre you sure you want to save your changes?\r\nPress Yes to save your changes, or No to add email addresses.",
"No Emails Input",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (result == JOptionPane.NO_OPTION) {
JTPComponents.setSelectedComponent(JPSendTo);
return;
}
}
authGmail.recordCurrentFields();
authSmtp.recordCurrentFields();
savedEmailAddresses = getCurrentEmails();
savedIsGmail = JRBGmail.isSelected();
disableEmail = false;
setVisible(false);
resetUserInputFields();
updatePreferences();
}
private void cancelChanges() {
authGmail.resetChanges();
authSmtp.resetChanges();
resetChanges();
setVisible(false);
resetUserInputFields();
updatePreferences();
}
private void disableEmail() {
disableEmail = true;
authGmail.resetChanges();
authSmtp.resetChanges();
resetChanges();
setVisible(false);
resetUserInputFields();
updatePreferences();
}
/**
* This method is called from within the constructor to initialize the form. WARNING: Do NOT
* modify this code. The content of this method is always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
BGAuthType = new ButtonGroup();
JTPComponents = new JTabbedPane();
JPAuthentication = new JPanel();
JRBGmail = new JRadioButton();
JRBSMTP = new JRadioButton();
JPAuthInfo = new JPanel();
JPSendTo = new JPanel();
JTFCellNumber = new JTextField();
JBAddNumber = new JButton();
JCBCarrier = new JComboBox<>();
jLabel1 = new JLabel();
jScrollPane1 = new JScrollPane();
JTCellNumbers = new JTable();
JPFinish = new JPanel();
JBSaveChanges = new JButton();
JBCancelChanges = new JButton();
JBDisableEmail = new JButton();
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
setTitle("Email Setup");
setResizable(false);
BGAuthType.add(JRBGmail);
JRBGmail.setText("Gmail API");
JRBGmail.setToolTipText("<html>\n<i>English</i>\n<p width=\"500\">Authenticates with Google through your browser. Recommended.</p>\n<i>Tech</i>\n<p width=\"500\">Used for authenticating with Google via OAuth2.<br></p>\n</html>");
JRBGmail.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JRBGmailActionPerformed(evt);
}
});
BGAuthType.add(JRBSMTP);
JRBSMTP.setText("SMTP");
JRBSMTP.setToolTipText("<html>\n<i>English</i>\n<p width=\"500\">Authenticates with any email service. Not recommended.</p>\n<i>Tech</i>\n<p width=\"500\">Authenticates with any mailserver using SMTP. Issues with this have cropped up in the past, and it's hard to detect where the problem lies. My guess is ISPs or routers blocking SMTP traffic (insane), but I don't know for sure.</p>\n</html>");
JRBSMTP.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JRBSMTPActionPerformed(evt);
}
});
JPAuthInfo.setLayout(new BoxLayout(JPAuthInfo, BoxLayout.LINE_AXIS));
GroupLayout JPAuthenticationLayout = new GroupLayout(JPAuthentication);
JPAuthentication.setLayout(JPAuthenticationLayout);
JPAuthenticationLayout.setHorizontalGroup(JPAuthenticationLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(JPAuthenticationLayout.createSequentialGroup()
.addContainerGap()
.addComponent(JRBGmail)
.addGap(18, 18, 18)
.addComponent(JRBSMTP)
.addContainerGap(249, Short.MAX_VALUE))
.addComponent(JPAuthInfo, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
JPAuthenticationLayout.setVerticalGroup(JPAuthenticationLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(JPAuthenticationLayout.createSequentialGroup()
.addContainerGap()
.addGroup(JPAuthenticationLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(JRBGmail)
.addComponent(JRBSMTP))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(JPAuthInfo, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
JTPComponents.addTab("Authentication", JPAuthentication);
JTFCellNumber.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent evt) {
JTFCellNumberKeyPressed(evt);
}
});
JBAddNumber.setText("Add Number");
JBAddNumber.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JBAddNumberActionPerformed(evt);
}
});
JBAddNumber.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent evt) {
JBAddNumberKeyPressed(evt);
}
});
JCBCarrier.setModel(new DefaultComboBoxModel<>(new String[] { "AT&T (MMS)", "AT&T (SMS)", "Verizon", "Sprint", "T-Mobile", "U.S. Cellular", "Bell", "Rogers", "Fido", "Koodo", "Telus", "Virgin (CAN)", "Wind", "Sasktel", "[Other]" }));
JCBCarrier.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent evt) {
JCBCarrierKeyPressed(evt);
}
});
jLabel1.setText("Cell Number");
JTCellNumbers.setModel(new DefaultTableModel(
new Object [][] {
},
new String [] {
"Cell Number", "Carrier"
}
) {
Class[] types = new Class [] {
String.class, String.class
};
boolean[] canEdit = new boolean [] {
false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
JTCellNumbers.setToolTipText("Delete emails by selecting them and pressing the DEL key");
JTCellNumbers.setColumnSelectionAllowed(true);
JTCellNumbers.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent evt) {
JTCellNumbersKeyPressed(evt);
}
});
jScrollPane1.setViewportView(JTCellNumbers);
GroupLayout JPSendToLayout = new GroupLayout(JPSendTo);
JPSendTo.setLayout(JPSendToLayout);
JPSendToLayout.setHorizontalGroup(JPSendToLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(JPSendToLayout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(JTFCellNumber, GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(JCBCarrier, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(JBAddNumber))
.addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
);
JPSendToLayout.setVerticalGroup(JPSendToLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(GroupLayout.Alignment.TRAILING, JPSendToLayout.createSequentialGroup()
.addContainerGap()
.addGroup(JPSendToLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(JTFCellNumber, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(JBAddNumber)
.addComponent(JCBCarrier, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE))
);
JTPComponents.addTab("Send To", JPSendTo);
JBSaveChanges.setText("Save Changes");
JBSaveChanges.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JBSaveChangesActionPerformed(evt);
}
});
JBCancelChanges.setText("Cancel Changes");
JBCancelChanges.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JBCancelChangesActionPerformed(evt);
}
});
JBDisableEmail.setText("Disable Email");
JBDisableEmail.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JBDisableEmailActionPerformed(evt);
}
});
GroupLayout JPFinishLayout = new GroupLayout(JPFinish);
JPFinish.setLayout(JPFinishLayout);
JPFinishLayout.setHorizontalGroup(JPFinishLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(JPFinishLayout.createSequentialGroup()
.addContainerGap()
.addGroup(JPFinishLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(JBSaveChanges, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(JBCancelChanges, GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE)
.addComponent(JBDisableEmail, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
JPFinishLayout.setVerticalGroup(JPFinishLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(GroupLayout.Alignment.TRAILING, JPFinishLayout.createSequentialGroup()
.addContainerGap()
.addComponent(JBSaveChanges)
.addGap(18, 18, 18)
.addComponent(JBCancelChanges)
.addGap(18, 18, 18)
.addComponent(JBDisableEmail)
.addContainerGap(56, Short.MAX_VALUE))
);
JTPComponents.addTab("Finish", JPFinish);
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(JTPComponents)
);
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(JTPComponents)
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void JRBGmailActionPerformed(ActionEvent evt) {//GEN-FIRST:event_JRBGmailActionPerformed
setAuthPanel(authGmail);
}//GEN-LAST:event_JRBGmailActionPerformed
private void JRBSMTPActionPerformed(ActionEvent evt) {//GEN-FIRST:event_JRBSMTPActionPerformed
setAuthPanel(authSmtp);
}//GEN-LAST:event_JRBSMTPActionPerformed
private void JBAddNumberActionPerformed(ActionEvent evt) {//GEN-FIRST:event_JBAddNumberActionPerformed
addEmail();
}//GEN-LAST:event_JBAddNumberActionPerformed
private void JTCellNumbersKeyPressed(KeyEvent evt) {//GEN-FIRST:event_JTCellNumbersKeyPressed
if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
int[] selectedIndeces = JTCellNumbers.getSelectedRows();
for (int i = selectedIndeces.length - 1; i >= 0; i--) { // Iterate from the bottom up
((DefaultTableModel) JTCellNumbers.getModel()).removeRow(selectedIndeces[i]);
}
} else if (evt.getKeyCode() == KeyEvent.VK_TAB) {
this.transferFocus();
evt.consume();
}
}//GEN-LAST:event_JTCellNumbersKeyPressed
private void JTFCellNumberKeyPressed(KeyEvent evt) {//GEN-FIRST:event_JTFCellNumberKeyPressed
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
addEmail();
}
}//GEN-LAST:event_JTFCellNumberKeyPressed
private void JCBCarrierKeyPressed(KeyEvent evt) {//GEN-FIRST:event_JCBCarrierKeyPressed
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
addEmail();
}
}//GEN-LAST:event_JCBCarrierKeyPressed
private void JBAddNumberKeyPressed(KeyEvent evt) {//GEN-FIRST:event_JBAddNumberKeyPressed
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
addEmail();
}
}//GEN-LAST:event_JBAddNumberKeyPressed
private void JBSaveChangesActionPerformed(ActionEvent evt) {//GEN-FIRST:event_JBSaveChangesActionPerformed
saveChanges();
}//GEN-LAST:event_JBSaveChangesActionPerformed
private void JBCancelChangesActionPerformed(ActionEvent evt) {//GEN-FIRST:event_JBCancelChangesActionPerformed
cancelChanges();
}//GEN-LAST:event_JBCancelChangesActionPerformed
private void JBDisableEmailActionPerformed(ActionEvent evt) {//GEN-FIRST:event_JBDisableEmailActionPerformed
disableEmail();
}//GEN-LAST:event_JBDisableEmailActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private ButtonGroup BGAuthType;
private JButton JBAddNumber;
private JButton JBCancelChanges;
private JButton JBDisableEmail;
private JButton JBSaveChanges;
private JComboBox<String> JCBCarrier;
private JPanel JPAuthInfo;
private JPanel JPAuthentication;
private JPanel JPFinish;
private JPanel JPSendTo;
private JRadioButton JRBGmail;
private JRadioButton JRBSMTP;
private JTable JTCellNumbers;
private JTextField JTFCellNumber;
private JTabbedPane JTPComponents;
private JLabel jLabel1;
private JScrollPane jScrollPane1;
// End of variables declaration//GEN-END:variables
private class AuthenticationCallback implements Runnable {
private boolean nextEnabledState = false;
public void run() {
JBSaveChanges.setEnabled(nextEnabledState);
JBCancelChanges.setEnabled(nextEnabledState);
JBDisableEmail.setEnabled(nextEnabledState);
JRBGmail.setEnabled(nextEnabledState);
JRBSMTP.setEnabled(nextEnabledState);
nextEnabledState = !nextEnabledState; // Invert
}
}
}
| SunnyBat/PAXChecker | src/main/java/com/github/sunnybat/paxchecker/setup/email/EmailSetupGUI.java | Java | mit | 22,577 | [
30522,
1013,
1008,
1008,
2000,
2689,
2023,
6105,
20346,
1010,
5454,
6105,
20346,
2015,
1999,
2622,
5144,
1012,
1008,
2000,
2689,
2023,
23561,
5371,
1010,
5454,
5906,
1064,
23561,
2015,
1008,
1998,
2330,
1996,
23561,
1999,
1996,
3559,
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... |
package tunnel
import (
"bytes"
stdcrypto "crypto"
"encoding/base64"
"errors"
"fmt"
"net"
"net/url"
"os"
"os/user"
"path/filepath"
"reflect"
"regexp"
"runtime"
"strconv"
"strings"
"github.com/Lafeng/deblocus/auth"
"github.com/Lafeng/deblocus/crypto"
"github.com/Lafeng/deblocus/exception"
"github.com/go-ini/ini"
"github.com/kardianos/osext"
)
const (
CF_CLIENT = "deblocus.Client"
CF_SERVER = "deblocus.Server"
CF_URL = "URL"
CF_KEY = "Key"
CF_CRYPTO = "Crypto"
CF_PRIVKEY = "PrivateKey"
CF_CREDENTIAL = "Credential"
CF_PAC = "PAC.Server"
CF_FILE = "File"
CONFIG_NAME = "deblocus.ini"
SIZE_UNIT = "BKMG"
)
var (
UNRECOGNIZED_SYMBOLS = exception.New("Unrecognized symbols")
LOCAL_BIND_ERROR = exception.New("Local bind error")
CONF_MISS = exception.New("Missed field in config:")
CONF_ERROR = exception.New("Error field in config:")
)
type ServerRole uint32
const (
SR_AUTO ServerRole = ^ServerRole(0)
SR_CLIENT ServerRole = 0x0f
SR_SERVER ServerRole = 0xf0
)
type ConfigMan struct {
filepath string
iniInstance *ini.File
sConf *serverConf
cConf *clientConf
}
func DetectConfig(specifiedFile string) (*ConfigMan, error) {
var paths []string
if specifiedFile == NULL {
paths = []string{CONFIG_NAME} // cwd
var ef, home string
var err error
// same path with exe
ef, err = osext.ExecutableFolder()
if err == nil {
paths = append(paths, filepath.Join(ef, CONFIG_NAME))
}
// home
if u, err := user.Current(); err == nil {
home = u.HomeDir
} else {
home = os.Getenv("HOME")
}
if home != NULL {
paths = append(paths, filepath.Join(home, CONFIG_NAME))
}
// etc
if runtime.GOOS != "windows" {
paths = append(paths, "/etc/deblocus/"+CONFIG_NAME)
}
} else {
paths = []string{specifiedFile}
}
var file *string
for _, f := range paths {
if f != NULL && !IsNotExist(f) {
file = &f
break
}
}
if file == nil {
msg := fmt.Sprintf("Not found `%s` in [ %s ]\n", CONFIG_NAME, strings.Join(paths, "; "))
msg += "Create config in typical path or specify it with option `--config/-c`."
return nil, errors.New(msg)
}
iniInstance, err := ini.Load(*file)
return &ConfigMan{
filepath: *file,
iniInstance: iniInstance,
}, err
}
func (cman *ConfigMan) InitConfigByRole(expectedRole ServerRole) (r ServerRole, err error) {
if expectedRole&SR_CLIENT != 0 {
if _, err = cman.iniInstance.GetSection(CF_CLIENT); err == nil {
r |= SR_CLIENT
cman.cConf, err = cman.ParseClientConf()
} else if expectedRole == SR_AUTO { // AUTO ignore
err = nil
}
if err != nil {
goto abort
}
}
if expectedRole&SR_SERVER != 0 {
if _, err = cman.iniInstance.GetSection(CF_SERVER); err == nil {
r |= SR_SERVER
cman.sConf, err = cman.ParseServConf()
} else if expectedRole == SR_AUTO { // AUTO ignore
err = nil
}
if err != nil {
goto abort
}
}
cman.iniInstance = nil
abort:
return r, err
}
func (cman *ConfigMan) LogV(expectedRole ServerRole) int {
if expectedRole&SR_SERVER != 0 {
return cman.sConf.Verbose
}
if expectedRole&SR_CLIENT != 0 {
return cman.cConf.Verbose
}
return -1
}
func (cman *ConfigMan) ListenAddr(expectedRole ServerRole) *net.TCPAddr {
if expectedRole&SR_SERVER != 0 {
return cman.sConf.ListenAddr
}
if expectedRole&SR_CLIENT != 0 {
return cman.cConf.ListenAddr
}
return nil
}
func (cman *ConfigMan) KeyInfo(expectedRole ServerRole) string {
var buf = new(bytes.Buffer)
if expectedRole&SR_SERVER != 0 {
key := cman.sConf.publicKey
fmt.Fprintln(buf, "Server Key in", cman.filepath)
fmt.Fprintln(buf, " type:", NameOfKey(key))
fmt.Fprintln(buf, " fingerprint:", FingerprintOfKey(key))
}
if expectedRole&SR_CLIENT != 0 {
key := cman.cConf.connInfo.sPubKey
fmt.Fprintln(buf, "Credential Key in", cman.filepath)
fmt.Fprintln(buf, " type:", NameOfKey(key))
fmt.Fprintln(buf, " fingerprint:", FingerprintOfKey(key))
}
return buf.String()
}
// client config definitions
type clientConf struct {
Listen string `importable:":9009"`
Verbose int `importable:"1"`
ListenAddr *net.TCPAddr `ini:"-"`
connInfo *connectionInfo
}
func (c *clientConf) validate() error {
if c.connInfo == nil {
return CONF_MISS.Apply("Not found credential")
}
if c.Listen == NULL {
return CONF_MISS.Apply("Listen")
}
a, e := net.ResolveTCPAddr("tcp", c.Listen)
if e != nil {
return LOCAL_BIND_ERROR.Apply(e)
}
pkType := NameOfKey(c.connInfo.sPubKey)
if pkType != c.connInfo.pkType {
return CONF_ERROR.Apply(pkType)
}
if c.connInfo.pacFile != NULL && IsNotExist(c.connInfo.pacFile) {
return CONF_ERROR.Apply("File Not Found " + c.connInfo.pacFile)
}
c.ListenAddr = a
return nil
}
type connectionInfo struct {
sAddr string
provider string
cipher string
user string
pass string
pkType string
pacFile string
sPubKey stdcrypto.PublicKey
rawURL string
}
func (d *connectionInfo) RemoteName() string {
if d.provider != NULL {
return d.provider
} else {
return d.sAddr
}
}
func newConnectionInfo(uri string) (*connectionInfo, error) {
url, err := url.Parse(uri)
if err != nil {
return nil, err
}
if url.Scheme != "d5" {
return nil, CONF_ERROR.Apply(url.Scheme)
}
_, err = net.ResolveTCPAddr("tcp", url.Host)
if err != nil {
return nil, HOST_UNREACHABLE.Apply(err)
}
var tmp string
var info = connectionInfo{sAddr: url.Host}
if len(url.Path) > 1 {
info.provider, tmp = SubstringBefore(url.Path[1:], "=")
}
if info.provider == NULL {
return nil, CONF_MISS.Apply("Provider")
}
info.pkType, info.cipher = SubstringBefore(tmp, "/")
_, err = GetAvailableCipher(info.cipher)
if err != nil {
return nil, err
}
user := url.User
if user == nil || user.Username() == NULL {
return nil, CONF_MISS.Apply("user")
}
passwd, ok := user.Password()
if !ok || passwd == NULL {
return nil, CONF_MISS.Apply("passwd")
}
info.user = user.Username()
info.pass = passwd
info.rawURL = uri
return &info, nil
}
// public for external handler
func (cman *ConfigMan) CreateClientConfig(file string, user string, addonAddr string) (err error) {
var f *os.File
if file == NULL {
f = os.Stdout
} else {
f, err = os.OpenFile(file, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0644)
if err != nil {
return err
}
defer f.Close()
}
defer f.Sync()
var sAddr string
var conf = new(clientConf)
var newIni = ini.Empty()
setFieldsDefaultValue(conf)
// client section
dc, _ := newIni.NewSection(CF_CLIENT)
dc.Comment = _CLT_CONF_HEADER[1:]
dc.ReflectFrom(conf)
// prepare server addr
if addonAddr == NULL {
sAddr = findFirstUnicastAddress()
if sAddr == NULL {
sAddr = "localhost:9008"
} else {
sPort := findServerListenPort(cman.sConf.Listen)
sAddr = fmt.Sprint(sAddr, ":", sPort)
}
cman.sConf.Listen = sAddr
} else {
err = IsValidHost(addonAddr)
cman.sConf.Listen = addonAddr
if err != nil {
return
}
}
err = cman.sConf.generateConnInfoOfUser(newIni, user)
if err == nil {
_, err = newIni.WriteTo(f)
if addonAddr == NULL {
var notice = strings.Replace(_NOTICE_MOD_ADDR, "ADDR", sAddr, -1)
fmt.Fprint(f, notice)
}
}
return
}
// public for external
func (cman *ConfigMan) ParseClientConf() (conf *clientConf, err error) {
ii := cman.iniInstance
secDc, err := ii.GetSection(CF_CLIENT)
if err != nil {
return
}
conf = new(clientConf)
err = secDc.MapTo(conf)
if err != nil {
return
}
cr, err := ii.GetSection(CF_CREDENTIAL)
if err != nil {
return
}
url, err := cr.GetKey(CF_URL)
if err != nil {
return
}
connInfo, err := newConnectionInfo(url.String())
if err != nil {
return
}
pubkeyObj, err := cr.GetKey(CF_KEY)
if err != nil {
return
}
pubkeyBytes, err := base64.StdEncoding.DecodeString(pubkeyObj.String())
if err != nil {
return
}
pubkey, err := UnmarshalPublicKey(pubkeyBytes)
if err != nil {
return
}
secPac, _ := ii.GetSection(CF_PAC)
if secPac != nil && secPac.Haskey(CF_FILE) {
pacFile, _ := secPac.GetKey(CF_FILE)
connInfo.pacFile = pacFile.String()
}
connInfo.sPubKey = pubkey
conf.connInfo = connInfo
err = conf.validate()
return
}
// Server config definitions
type serverConf struct {
Listen string `importable:":9008"`
Auth string `importable:"file://_USER_PASS_FILE_PATH_"`
Cipher string `importable:"AES128CTR"`
ServerName string `importable:"_MY_SERVER"`
Parallels int `importable:"2"`
Verbose int `importable:"1"`
DenyDest string `importable:"OFF"`
ErrorFeedback string `importable:"true"`
AuthSys auth.AuthSys `ini:"-"`
ListenAddr *net.TCPAddr `ini:"-"`
errFeedback bool
privateKey stdcrypto.PrivateKey
publicKey stdcrypto.PublicKey
}
func (d *serverConf) validate() error {
if len(d.Listen) < 1 {
return CONF_MISS.Apply("Listen")
}
a, e := net.ResolveTCPAddr("tcp", d.Listen)
if e != nil {
return LOCAL_BIND_ERROR.Apply(e)
}
d.ListenAddr = a
if len(d.Auth) < 1 {
return CONF_MISS.Apply("Auth")
}
d.AuthSys, e = auth.GetAuthSysImpl(d.Auth)
if e != nil {
return e
}
if len(d.Cipher) < 1 {
return CONF_MISS.Apply("Cipher")
}
_, e = GetAvailableCipher(d.Cipher)
if e != nil {
return e
}
if d.ServerName == NULL {
return CONF_MISS.Apply("ServerName")
}
if d.Parallels < 2 || d.Parallels > 16 {
return CONF_ERROR.Apply("Parallels")
}
if d.privateKey == nil {
return CONF_MISS.Apply("PrivateKey")
}
if len(d.DenyDest) > 0 {
if d.DenyDest == "OFF" || d.DenyDest == "off" {
d.DenyDest = NULL
} else if !regexp.MustCompile("[A-Za-z]{2}").MatchString(d.DenyDest) {
return CONF_ERROR.Apply("DenyDest must be ISO3166-1 2-letter Country Code")
}
}
if len(d.ErrorFeedback) > 0 {
d.errFeedback, e = strconv.ParseBool(d.ErrorFeedback)
if e != nil {
return CONF_ERROR.Apply("ErrorFeedback")
}
}
return nil
}
// public for external handler
func (cman *ConfigMan) ParseServConf() (d5s *serverConf, err error) {
ii := cman.iniInstance
sec, err := ii.GetSection(CF_SERVER)
if err != nil {
return
}
d5s = new(serverConf)
if err = sec.MapTo(d5s); err != nil {
return
}
kSec, err := ii.GetSection(CF_PRIVKEY)
if err != nil {
return
}
key, err := kSec.GetKey(CF_KEY)
if err != nil {
return
}
keyBytes, err := base64.StdEncoding.DecodeString(key.String())
if err != nil {
return
}
priv, err := UnmarshalPrivateKey(keyBytes)
if err != nil {
return
}
d5s.privateKey = priv
d5s.publicKey = priv.(stdcrypto.Signer).Public()
err = d5s.validate()
return
}
// public for external handler
func CreateServerConfigTemplate(file string, keyOpt string) (err error) {
var f *os.File
if file == NULL {
f = os.Stdout
} else {
f, err = os.OpenFile(file, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0600)
if err != nil {
return
}
defer f.Close()
}
defer f.Sync()
d5sConf := new(serverConf)
d5sConf.setDefaultValue()
// uppercase algo name
keyOpt = strings.ToUpper(keyOpt)
d5sConf.privateKey, err = GenerateDSAKey(keyOpt)
if err != nil {
return
}
ii := ini.Empty()
ds, _ := ii.NewSection(CF_SERVER)
ds.Comment = _SER_CONF_HEADER[1:]
err = ds.ReflectFrom(d5sConf)
if err != nil {
return
}
ks, _ := ii.NewSection(CF_PRIVKEY)
keyBytes := MarshalPrivateKey(d5sConf.privateKey)
ks.Comment = _SER_CONF_MIDDLE[1:]
ks.NewKey(CF_KEY, base64.StdEncoding.EncodeToString(keyBytes))
_, err = ii.WriteTo(f)
return
}
func (d *serverConf) generateConnInfoOfUser(ii *ini.File, user string) error {
u, err := d.AuthSys.UserInfo(user)
if err != nil {
return err
}
keyBytes, err := MarshalPublicKey(d.publicKey)
if err != nil {
return err
}
url := fmt.Sprintf("d5://%s:%s@%s/%s=%s/%s", u.Name, u.Pass, d.Listen, d.ServerName, NameOfKey(d.publicKey), d.Cipher)
sec, _ := ii.NewSection(CF_CREDENTIAL)
sec.NewKey(CF_URL, url)
sec.NewKey(CF_KEY, base64.StdEncoding.EncodeToString(keyBytes))
sec.Comment = _COMMENTED_PAC_SECTION
return nil
}
// set default values by field comment
// set recommended values by detecting
func (d *serverConf) setDefaultValue() {
setFieldsDefaultValue(d)
host, err := os.Hostname()
if err == nil {
host = regexp.MustCompile(`\W`).ReplaceAllString(host, "")
d.ServerName = strings.ToUpper(host)
}
if crypto.HasAESHardware() == 0 {
d.Cipher = "CHACHA12"
}
}
func setFieldsDefaultValue(str interface{}) {
typ := reflect.TypeOf(str)
val := reflect.ValueOf(str)
if typ.Kind() == reflect.Ptr {
typ = typ.Elem()
val = val.Elem()
}
for i := 0; i < typ.NumField(); i++ {
ft := typ.Field(i)
fv := val.Field(i)
imp := ft.Tag.Get("importable")
if !ft.Anonymous && imp != NULL {
k := fv.Kind()
switch k {
case reflect.String:
fv.SetString(imp)
case reflect.Int:
intVal, err := strconv.ParseInt(imp, 10, 0)
if err == nil {
fv.SetInt(intVal)
}
default:
panic(fmt.Errorf("unsupported %v", k))
}
}
}
}
func findServerListenPort(addr string) int {
n, e := net.ResolveTCPAddr("tcp", addr)
if e != nil {
return 9008
}
return n.Port
}
func findFirstUnicastAddress() string {
nic, e := net.InterfaceAddrs()
if nic != nil && e == nil {
for _, v := range nic {
if i, _ := v.(*net.IPNet); i != nil {
if i.IP.IsGlobalUnicast() {
return i.IP.String()
}
}
}
}
return NULL
}
const _SER_CONF_HEADER = `
# ---------------------------------------------
# deblocus server configuration
# wiki: https://github.com/Lafeng/deblocus/wiki
# ---------------------------------------------
`
const _SER_CONF_MIDDLE = `
### Please take good care of this secret file during the server life cycle.
### DO NOT modify the following lines, unless you known what will happen.
`
const _CLT_CONF_HEADER = `
# ---------------------------------------------
# deblocus client configuration
# wiki: https://github.com/Lafeng/deblocus/wiki
# ---------------------------------------------
`
const _COMMENTED_PAC_SECTION = `# Optional
# [PAC.Server]
# File = mypac.js
`
const _NOTICE_MOD_ADDR = `
# +-----------------------------------------------------------------+
# May need to modify the "ADDR" to your public address.
# +-----------------------------------------------------------------+
`
| Lafeng/deblocus | tunnel/config.go | GO | mit | 14,293 | [
30522,
7427,
5234,
12324,
1006,
1000,
27507,
1000,
2358,
16409,
2854,
13876,
2080,
1000,
19888,
2080,
1000,
1000,
17181,
1013,
2918,
21084,
1000,
1000,
10697,
1000,
1000,
4718,
2102,
1000,
1000,
5658,
1000,
1000,
5658,
1013,
24471,
2140,
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... |
/*******************************************************************************
* 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 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
package org.worldgrower.goal;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.worldgrower.Constants;
import org.worldgrower.TestUtils;
import org.worldgrower.World;
import org.worldgrower.WorldImpl;
import org.worldgrower.WorldObject;
import org.worldgrower.actions.Actions;
import org.worldgrower.condition.Condition;
import org.worldgrower.condition.Conditions;
public class UTestCocoonOutsidersGoal {
private CocoonOutsidersGoal goal = Goals.COCOON_OUTSIDERS_GOAL;
@Test
public void testCalculateGoalNull() {
World world = new WorldImpl(1, 1, null, null);
WorldObject performer = createPerformer(2);
assertEquals(null, goal.calculateGoal(performer, world));
}
@Test
public void testCalculateGoalCocoonOutsider() {
World world = new WorldImpl(10, 10, null, null);
WorldObject performer = createPerformer(2);
WorldObject target = createPerformer(3);
world.addWorldObject(performer);
world.addWorldObject(target);
target.getProperty(Constants.GROUP).removeAll();
Conditions.add(target, Condition.PARALYZED_CONDITION, 8, world);
assertEquals(Actions.COCOON_ACTION, goal.calculateGoal(performer, world).getManagedOperation());
}
@Test
public void testCalculateGoalAlreadyCocooned() {
World world = new WorldImpl(10, 10, null, null);
WorldObject performer = createPerformer(2);
WorldObject target = createPerformer(3);
world.addWorldObject(performer);
world.addWorldObject(target);
target.getProperty(Constants.GROUP).removeAll();
Conditions.add(target, Condition.COCOONED_CONDITION, 8, world);
assertEquals(null, goal.calculateGoal(performer, world));
}
@Test
public void testIsGoalMet() {
World world = new WorldImpl(10, 10, null, null);
WorldObject performer = createPerformer(2);
world.addWorldObject(performer);
assertEquals(true, goal.isGoalMet(performer, world));
WorldObject target = createPerformer(3);
world.addWorldObject(target);
target.getProperty(Constants.GROUP).removeAll();
Conditions.add(target, Condition.PARALYZED_CONDITION, 8, world);
assertEquals(false, goal.isGoalMet(performer, world));
}
private WorldObject createPerformer(int id) {
WorldObject performer = TestUtils.createIntelligentWorldObject(id, "person");
performer.setProperty(Constants.X, 0);
performer.setProperty(Constants.Y, 0);
performer.setProperty(Constants.WIDTH, 1);
performer.setProperty(Constants.HEIGHT, 1);
performer.setProperty(Constants.ARMOR, 1);
performer.setProperty(Constants.HIT_POINTS, 1);
performer.setProperty(Constants.CONDITIONS, new Conditions());
return performer;
}
} | WorldGrower/WorldGrower | test/org/worldgrower/goal/UTestCocoonOutsidersGoal.java | Java | gpl-3.0 | 3,579 | [
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... |
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
(function ($, require) {
var exports = require('piwik/UI');
/**
* Creates a new notifications.
*
* Example:
* var UI = require('piwik/UI');
* var notification = new UI.Notification();
* notification.show('My Notification Message', {title: 'Low space', context: 'warning'});
*/
var Notification = function () {
this.$node = null;
};
/**
* Makes the notification visible.
*
* @param {string} message The actual message that will be displayed. Must be set.
* @param {Object} [options]
* @param {string} [options.id] Only needed for persistent notifications. The id will be sent to the
* frontend once the user closes the notifications. The notification has to
* be registered/notified under this name
* @param {string} [options.title] The title of the notification. For instance the plugin name.
* @param {bool} [options.animate=true] If enabled, the notification will be faded in.
* @param {string} [options.context=warning] Context of the notification: 'info', 'warning', 'success' or
* 'error'
* @param {string} [options.type=transient] The type of the notification: Either 'toast' or 'transitent'
* @param {bool} [options.noclear=false] If set, the close icon is not displayed.
* @param {object} [options.style] Optional style/css dictionary. For instance {'display': 'inline-block'}
* @param {string} [options.placeat] By default, the notification will be displayed in the "stats bar".
* You can specify any other CSS selector to place the notifications
* wherever you want.
*/
Notification.prototype.show = function (message, options) {
checkMessage(message);
options = checkOptions(options);
var template = generateNotificationHtmlMarkup(options, message);
this.$node = placeNotification(template, options);
};
/**
* Removes a previously shown notification having the given notification id.
*
*
* @param {string} notificationId The id of a notification that was previously registered.
*/
Notification.prototype.remove = function (notificationId) {
$('[piwik-notification][notification-id=' + notificationId + ']').remove();
};
Notification.prototype.scrollToNotification = function () {
if (this.$node) {
piwikHelper.lazyScrollTo(this.$node, 250);
}
};
/**
* Shows a notification at a certain point with a quick upwards animation.
*
* TODO: if the materializecss version matomo uses is updated, should use their toasts.
*
* @type {Notification}
* @param {string} message The actual message that will be displayed. Must be set.
* @param {Object} options
* @param {string} options.placeat Where to place the notification. Required.
* @param {string} [options.id] Only needed for persistent notifications. The id will be sent to the
* frontend once the user closes the notifications. The notification has to
* be registered/notified under this name
* @param {string} [options.title] The title of the notification. For instance the plugin name.
* @param {string} [options.context=warning] Context of the notification: 'info', 'warning', 'success' or
* 'error'
* @param {string} [options.type=transient] The type of the notification: Either 'toast' or 'transitent'
* @param {bool} [options.noclear=false] If set, the close icon is not displayed.
* @param {object} [options.style] Optional style/css dictionary. For instance {'display': 'inline-block'}
*/
Notification.prototype.toast = function (message, options) {
checkMessage(message);
options = checkOptions(options);
var $placeat = $(options.placeat);
if (!$placeat.length) {
throw new Error("A valid selector is required for the placeat option when using Notification.toast().");
}
var $template = $(generateNotificationHtmlMarkup(options, message)).hide();
$('body').append($template);
compileNotification($template);
$template.css({
position: 'absolute',
left: $placeat.offset().left,
top: $placeat.offset().top
});
setTimeout(function () {
$template.animate(
{
top: $placeat.offset().top - $template.height()
},
{
duration: 300,
start: function () {
$template.show();
}
}
);
});
};
exports.Notification = Notification;
function generateNotificationHtmlMarkup(options, message) {
var attributeMapping = {
id: 'notification-id',
title: 'notification-title',
context: 'context',
type: 'type',
noclear: 'noclear',
class: 'class',
toastLength: 'toast-length'
},
html = '<div piwik-notification';
for (var key in attributeMapping) {
if (attributeMapping.hasOwnProperty(key)
&& options[key]
) {
html += ' ' + attributeMapping[key] + '="' + options[key].toString().replace(/"/g, """) + '"';
}
}
html += '>' + message + '</div>';
return html;
}
function compileNotification($node) {
angular.element(document).injector().invoke(function ($compile, $rootScope) {
$compile($node)($rootScope.$new(true));
});
}
function placeNotification(template, options) {
var $notificationNode = $(template);
// compile the template in angular
compileNotification($notificationNode);
if (options.style) {
$notificationNode.css(options.style);
}
var notificationPosition = '#notificationContainer';
var method = 'append';
if (options.placeat) {
notificationPosition = options.placeat;
} else {
// If a modal is open, we want to make sure the error message is visible and therefore show it within the opened modal
var modalSelector = '.modal.open .modal-content';
var modalOpen = $(modalSelector);
if (modalOpen.length) {
notificationPosition = modalSelector;
method = 'prepend';
}
}
$notificationNode = $notificationNode.hide();
$(notificationPosition)[method]($notificationNode);
if (false === options.animate) {
$notificationNode.show();
} else {
$notificationNode.fadeIn(1000);
}
return $notificationNode;
}
function checkMessage(message) {
if (!message) {
throw new Error('No message given, cannot display notification');
}
}
function checkOptions(options) {
if (options && !$.isPlainObject(options)) {
throw new Error('Options has the wrong format, cannot display notification');
} else if (!options) {
options = {};
}
return options;
}
})(jQuery, require); | piwik/piwik | plugins/CoreHome/javascripts/notification.js | JavaScript | gpl-3.0 | 7,980 | [
30522,
30524,
4957,
8299,
1024,
1013,
1013,
14255,
9148,
2243,
1012,
8917,
1008,
1030,
6105,
8299,
1024,
1013,
1013,
7479,
1012,
27004,
1012,
8917,
1013,
15943,
1013,
14246,
2140,
1011,
1017,
1012,
1014,
1012,
16129,
14246,
2140,
1058,
2509... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 TwelveCode\MShell;
abstract class ACommand
{
/**
* Call argument count
* @var int
*/
protected $_argc;
/**
* Call argument list
* @var string[]
*/
protected $_argv;
/**
* Holds the command's result
* @var null|mixed
*/
protected $_result = null;
/**
* Executes the command
*
* Internally the protected process() method is called, together with
* beforeProcess() and afterProcess()
*
* The commend's result can be obtained using getResult()
*
* @return ACommand The execution results
*/
public function execute()
{
$this->beforeProcess();
$this->process();
$this->afterProcess();
return $this;
}
/**
* Logic to be executed before the main processing takes place
*
* @return mixed
*/
protected function beforeProcess()
{
return;
}
/**
* The main command working unit
*
* This method contains all the main command's logic
* As a result the internal $_result property should be set, so the
* product can be obtained using getResult() method.
*
* @return mixed
*/
protected function process()
{
return;
}
/**
* The logic that should be executed after the main processing takes
* place
*
* @return mixed
*/
protected function afterProcess()
{
return;
}
/**
* Returns help information for the command
*
* This method should contain all the help information that the end user
* would require. It's extreamly powerful in conjunction with the `help`
* command.
*
* @return string
*/
protected function getHelp()
{
return 'No help contents for this command.';
}
public function setArgc($argc)
{
$this->_argc = $argc;
}
public function getArgc()
{
return $this->_argc;
}
public function setArgv($argv)
{
$this->_argv = $argv;
}
public function getArgv()
{
return $this->_argv;
}
/**
* Returns the command's result (product)
*
* @return mixed|null
*/
public function getResult()
{
return $this->_result;
}
} | twelvecode/mshell | lib/TwelveCode/MShell/ACommand.php | PHP | mpl-2.0 | 2,344 | [
30522,
1026,
1029,
25718,
3415,
15327,
4376,
16044,
1032,
5796,
18223,
1025,
10061,
2465,
9353,
5358,
2386,
2094,
1063,
1013,
1008,
1008,
1008,
2655,
6685,
4175,
1008,
1030,
13075,
20014,
1008,
1013,
5123,
1002,
1035,
12098,
18195,
1025,
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 2014 Cisco Systems, 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.
import os
import random
from neutron.agent.linux import ovs_lib
from neutron.agent.linux import utils
from neutron.common import constants as n_const
from neutron.tests import base
BR_PREFIX = 'test-br'
class BaseLinuxTestCase(base.BaseTestCase):
def setUp(self, root_helper='sudo'):
super(BaseLinuxTestCase, self).setUp()
self.root_helper = root_helper
def check_command(self, cmd, error_text, skip_msg):
try:
utils.execute(cmd)
except RuntimeError as e:
if error_text in str(e):
self.skipTest(skip_msg)
raise
def check_sudo_enabled(self):
if os.environ.get('OS_SUDO_TESTING') not in base.TRUE_STRING:
self.skipTest('testing with sudo is not enabled')
def get_rand_name(self, max_length, prefix='test'):
name = prefix + str(random.randint(1, 0x7fffffff))
return name[:max_length]
def create_resource(self, name_prefix, creation_func, *args, **kwargs):
"""Create a new resource that does not already exist.
:param name_prefix: The prefix for a randomly generated name
:param creation_func: A function taking the name of the resource
to be created as it's first argument. An error is assumed
to indicate a name collision.
:param *args *kwargs: These will be passed to the create function.
"""
while True:
name = self.get_rand_name(n_const.DEV_NAME_MAX_LEN, name_prefix)
try:
return creation_func(name, *args, **kwargs)
except RuntimeError:
continue
class BaseOVSLinuxTestCase(BaseLinuxTestCase):
def setUp(self, root_helper='sudo'):
super(BaseOVSLinuxTestCase, self).setUp(root_helper)
self.ovs = ovs_lib.BaseOVS(self.root_helper)
def create_ovs_bridge(self, br_prefix=BR_PREFIX):
br = self.create_resource(br_prefix, self.ovs.add_bridge)
self.addCleanup(br.destroy)
return br
| onecloud/neutron | neutron/tests/functional/agent/linux/base.py | Python | apache-2.0 | 2,637 | [
30522,
1001,
9385,
2297,
26408,
3001,
1010,
4297,
1012,
1001,
1001,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
2017,
2089,
1001,
2025,
2224,
2023,
5371,
3272,
1999,
12646,
2007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/*
* SonarQube
* Copyright (C) 2009-2016 SonarSource SA
* mailto:contact AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.sonar.api.server.authentication;
import javax.annotation.concurrent.Immutable;
import static com.google.common.base.Preconditions.checkArgument;
import static org.apache.commons.lang.StringUtils.isNotBlank;
/**
* Display information provided by the Identity Provider to be displayed into the login form.
*
* @since 5.4
*/
@Immutable
public final class Display {
private final String iconPath;
private final String backgroundColor;
private Display(Builder builder) {
this.iconPath = builder.iconPath;
this.backgroundColor = builder.backgroundColor;
}
/**
* URL path to the provider icon, as deployed at runtime, for example "/static/authgithub/github.svg" (in this
* case "authgithub" is the plugin key. Source file is "src/main/resources/static/github.svg").
* It can also be an external URL, for example "http://www.mydomain/myincon.png".
*
* Must not be blank.
* <br>
* The recommended format is SVG with a size of 24x24 pixels.
* Other supported format is PNG, with a size of 40x40 pixels.
*/
public String getIconPath() {
return iconPath;
}
/**
* Background color for the provider button displayed in the login form.
* It's a Hexadecimal value, for instance #205081.
* <br>
* If not provided, the default value is #236a97
*/
public String getBackgroundColor() {
return backgroundColor;
}
public static Builder builder() {
return new Builder();
}
public static class Builder {
private String iconPath;
private String backgroundColor = "#236a97";
private Builder() {
}
/**
* @see Display#getIconPath()
*/
public Builder setIconPath(String iconPath) {
this.iconPath = iconPath;
return this;
}
/**
* @see Display#getBackgroundColor()
*/
public Builder setBackgroundColor(String backgroundColor) {
this.backgroundColor = backgroundColor;
return this;
}
public Display build() {
checkArgument(isNotBlank(iconPath), "Icon path must not be blank");
validateBackgroundColor();
return new Display(this);
}
private void validateBackgroundColor() {
checkArgument(isNotBlank(backgroundColor), "Background color must not be blank");
checkArgument(backgroundColor.length() == 7 && backgroundColor.indexOf('#') == 0,
"Background color must begin with a sharp followed by 6 characters");
}
}
}
| Builders-SonarSource/sonarqube-bis | sonar-plugin-api/src/main/java/org/sonar/api/server/authentication/Display.java | Java | lgpl-3.0 | 3,286 | [
30522,
1013,
1008,
1008,
24609,
28940,
4783,
1008,
9385,
1006,
1039,
1007,
2268,
1011,
2355,
24609,
6499,
3126,
3401,
7842,
1008,
5653,
3406,
1024,
3967,
2012,
24609,
6499,
3126,
3401,
11089,
4012,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) 2007, Clarius Consulting, Manas Technology Solutions, InSTEDD, and Contributors.
// All rights reserved. Licensed under the BSD 3-Clause License; see License.txt.
using System;
using System.Diagnostics;
namespace Moq.Matchers
{
internal sealed class AnyMatcher : IMatcher
{
public static AnyMatcher Instance { get; } = new AnyMatcher();
private AnyMatcher()
{
}
public bool Matches(object argument, Type parameterType) => true;
public void SetupEvaluatedSuccessfully(object argument, Type parameterType)
{
Debug.Assert(this.Matches(argument, parameterType));
}
}
}
| Moq/moq4 | src/Moq/Matchers/AnyMatcher.cs | C# | bsd-3-clause | 609 | [
30522,
1013,
1013,
9385,
1006,
1039,
1007,
2289,
1010,
18856,
8486,
2271,
10552,
1010,
24951,
2015,
2974,
7300,
1010,
16021,
3064,
2094,
1010,
1998,
16884,
1012,
1013,
1013,
2035,
2916,
9235,
1012,
7000,
2104,
1996,
18667,
2094,
1017,
1011,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 The PyTorch Lightning team.
#
# 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.
"""Profiler to check if there are any bottlenecks in your code."""
import logging
import os
from abc import ABC, abstractmethod
from contextlib import contextmanager
from pathlib import Path
from typing import Any, Callable, Dict, Generator, Iterable, Optional, TextIO, Union
from pytorch_lightning.utilities.cloud_io import get_filesystem
log = logging.getLogger(__name__)
class AbstractProfiler(ABC):
"""Specification of a profiler."""
@abstractmethod
def start(self, action_name: str) -> None:
"""Defines how to start recording an action."""
@abstractmethod
def stop(self, action_name: str) -> None:
"""Defines how to record the duration once an action is complete."""
@abstractmethod
def summary(self) -> str:
"""Create profiler summary in text format."""
@abstractmethod
def setup(self, **kwargs: Any) -> None:
"""Execute arbitrary pre-profiling set-up steps as defined by subclass."""
@abstractmethod
def teardown(self, **kwargs: Any) -> None:
"""Execute arbitrary post-profiling tear-down steps as defined by subclass."""
class BaseProfiler(AbstractProfiler):
"""
If you wish to write a custom profiler, you should inherit from this class.
"""
def __init__(
self,
dirpath: Optional[Union[str, Path]] = None,
filename: Optional[str] = None,
) -> None:
self.dirpath = dirpath
self.filename = filename
self._output_file: Optional[TextIO] = None
self._write_stream: Optional[Callable] = None
self._local_rank: Optional[int] = None
self._log_dir: Optional[str] = None
self._stage: Optional[str] = None
@contextmanager
def profile(self, action_name: str) -> Generator:
"""
Yields a context manager to encapsulate the scope of a profiled action.
Example::
with self.profile('load training data'):
# load training data code
The profiler will start once you've entered the context and will automatically
stop once you exit the code block.
"""
try:
self.start(action_name)
yield action_name
finally:
self.stop(action_name)
def profile_iterable(self, iterable: Iterable, action_name: str) -> Generator:
iterator = iter(iterable)
while True:
try:
self.start(action_name)
value = next(iterator)
self.stop(action_name)
yield value
except StopIteration:
self.stop(action_name)
break
def _rank_zero_info(self, *args, **kwargs) -> None:
if self._local_rank in (None, 0):
log.info(*args, **kwargs)
def _prepare_filename(
self, action_name: Optional[str] = None, extension: str = ".txt", split_token: str = "-"
) -> str:
args = []
if self._stage is not None:
args.append(self._stage)
if self.filename:
args.append(self.filename)
if self._local_rank is not None:
args.append(str(self._local_rank))
if action_name is not None:
args.append(action_name)
filename = split_token.join(args) + extension
return filename
def _prepare_streams(self) -> None:
if self._write_stream is not None:
return
if self.filename:
filepath = os.path.join(self.dirpath, self._prepare_filename())
fs = get_filesystem(filepath)
file = fs.open(filepath, "a")
self._output_file = file
self._write_stream = file.write
else:
self._write_stream = self._rank_zero_info
def describe(self) -> None:
"""Logs a profile report after the conclusion of run."""
# there are pickling issues with open file handles in Python 3.6
# so to avoid them, we open and close the files within this function
# by calling `_prepare_streams` and `teardown`
self._prepare_streams()
summary = self.summary()
if summary:
self._write_stream(summary)
if self._output_file is not None:
self._output_file.flush()
self.teardown(stage=self._stage)
def _stats_to_str(self, stats: Dict[str, str]) -> str:
stage = f"{self._stage.upper()} " if self._stage is not None else ""
output = [stage + "Profiler Report"]
for action, value in stats.items():
header = f"Profile stats for: {action}"
if self._local_rank is not None:
header += f" rank: {self._local_rank}"
output.append(header)
output.append(value)
return os.linesep.join(output)
def setup(
self, stage: Optional[str] = None, local_rank: Optional[int] = None, log_dir: Optional[str] = None
) -> None:
"""Execute arbitrary pre-profiling set-up steps."""
self._stage = stage
self._local_rank = local_rank
self._log_dir = log_dir
self.dirpath = self.dirpath or log_dir
def teardown(self, stage: Optional[str] = None) -> None:
"""
Execute arbitrary post-profiling tear-down steps.
Closes the currently open file and stream.
"""
self._write_stream = None
if self._output_file is not None:
self._output_file.close()
self._output_file = None # can't pickle TextIOWrapper
def __del__(self) -> None:
self.teardown(stage=self._stage)
def start(self, action_name: str) -> None:
raise NotImplementedError
def stop(self, action_name: str) -> None:
raise NotImplementedError
def summary(self) -> str:
raise NotImplementedError
@property
def local_rank(self) -> int:
return 0 if self._local_rank is None else self._local_rank
class PassThroughProfiler(BaseProfiler):
"""
This class should be used when you don't want the (small) overhead of profiling.
The Trainer uses this class by default.
"""
def start(self, action_name: str) -> None:
pass
def stop(self, action_name: str) -> None:
pass
def summary(self) -> str:
return ""
| williamFalcon/pytorch-lightning | pytorch_lightning/profiler/base.py | Python | apache-2.0 | 6,875 | [
30522,
1001,
9385,
1996,
1052,
22123,
2953,
2818,
7407,
2136,
1012,
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,
5371,
3272,
1999,
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... |
/* -*- javascript -*- */
"use strict";
import {StageComponent} from 'aurelia-testing';
import {bootstrap} from 'aurelia-bootstrapper';
import {LogManager} from 'aurelia-framework';
import {ConsoleAppender} from 'aurelia-logging-console';
import {customMatchers} from '../helpers';
describe('ui-icon', () => {
let component, logger;
beforeAll(() => {
jasmine.addMatchers( customMatchers );
logger = LogManager.getLogger( 'ui-icon-spec' );
});
beforeEach(() => {
component = StageComponent.withResources('src/elements/ui-icon');
});
afterEach(() => {
component.dispose();
});
describe( 'as a custom attribute', () => {
it( 'adds semantic classes when bound', done => {
component.
inView(`
<i ui-icon="name: cloud"></i>
`).
boundTo({}).
create( bootstrap ).then( () => {
expect( component.element ).toHaveCssClasses( 'cloud', 'icon' );
}).
then( done ).
catch( done.fail );
});
it( 'has a reasonable name default', done => {
component.
inView(`
<i ui-icon></i>
`).
boundTo({}).
create( bootstrap ).then( () => {
expect( component.element ).toHaveCssClasses( 'help', 'circle', 'icon' );
}).
then( done ).
catch( done.fail );
});
it( 'adds a size class when one is set', done => {
component.
inView(`
<i ui-icon="name: cloud; size: huge"></i>
`).
boundTo({}).
create( bootstrap ).then( () => {
expect( component.element ).toHaveCssClasses( 'huge', 'cloud', 'icon' );
}).
then( done ).
catch( done.fail );
});
it( 'adds a color class when one is set', done => {
component.
inView(`
<i ui-icon="name: user; color: red">Erase History</i>
`).
boundTo({}).
create( bootstrap ).then( () => {
expect( component.element ).toHaveCssClasses( 'red', 'user', 'icon' );
}).
then( done ).
catch( done.fail );
});
it( 'adds a disabled class when it is set', done => {
component.
inView(`
<i ui-icon="disabled: true">Eject!</i>
`).
boundTo({}).
create( bootstrap ).then( () => {
expect( component.element ).toHaveCssClasses( 'disabled', 'icon' );
}).
then( done ).
catch( done.fail );
});
});
describe( 'as a custom element', () => {
it( 'uses the icon name', done => {
component.
inView(`
<ui-icon name="cloud"></ui-icon>
`).
boundTo({}).
create( bootstrap ).then( () => {
let icon = component.viewModel.semanticElement;
expect( icon ).toBeDefined();
expect( icon.nodeType ).toEqual( 1 );
expect( icon ).toHaveCssClasses( 'cloud' );
}).
then( done ).
catch( done.fail );
});
it( 'support multiple names', done => {
component.
inView(`
<ui-icon name="circular inverted users"></ui-icon>
`).
boundTo({}).
create( bootstrap ).then( () => {
let icon = component.viewModel.semanticElement;
expect( icon ).toBeDefined();
expect( icon.nodeType ).toEqual( 1 );
expect( icon ).toHaveCssClasses( 'circular', 'inverted', 'users' );
}).
then( done ).
catch( done.fail );
});
it( 'has a reasonable default name', done => {
component.
inView(`
<ui-icon></ui-icon>
`).
boundTo({}).
create( bootstrap ).then( () => {
let icon = component.viewModel.semanticElement;
expect( icon ).toBeDefined();
expect( icon.nodeType ).toEqual( 1 );
expect( icon ).toHaveCssClasses( 'help', 'circle' );
}).
then( done ).
catch( done.fail );
});
it( 'adds a size class when one is set', done => {
component.
inView(`
<ui-icon size="huge"></ui-icon>
`).
boundTo({}).
create( bootstrap ).then( () => {
let icon = component.viewModel.semanticElement;
expect( icon ).toBeDefined();
expect( icon.nodeType ).toEqual( 1 );
expect( icon ).toHaveCssClasses( 'huge' );
}).
then( done ).
catch( done.fail );
});
it( 'adds a color class when one is set', done => {
component.
inView(`
<ui-icon color="red"></ui-icon>
`).
boundTo({}).
create( bootstrap ).then( () => {
let icon = component.viewModel.semanticElement;
expect( icon ).toBeDefined();
expect( icon.nodeType ).toEqual( 1 );
expect( icon ).toHaveCssClasses( 'red' );
}).
then( done ).
catch( done.fail );
});
it( 'adds a disabled class when it is set', done => {
component.
inView(`
<ui-icon disabled="true"></ui-icon>
`).
boundTo({}).
create( bootstrap ).then( () => {
let icon = component.viewModel.semanticElement;
expect( icon ).toBeDefined();
expect( icon.nodeType ).toEqual( 1 );
expect( icon ).toHaveCssClasses( 'disabled' );
}).
then( done ).
catch( done.fail );
});
});
});
| ged/aurelia-semantic-ui | test/unit/elements/ui-icon_spec.js | JavaScript | mit | 4,822 | [
30522,
1013,
1008,
1011,
1008,
1011,
9262,
22483,
1011,
1008,
1011,
1008,
1013,
1000,
2224,
9384,
1000,
1025,
12324,
1063,
2754,
9006,
29513,
3372,
1065,
2013,
1005,
8740,
16570,
2401,
1011,
5604,
1005,
1025,
12324,
1063,
6879,
6494,
2361,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.
*/
package org.apache.ignite.visor.commands.alert
import java.io.{File, FileNotFoundException}
import java.util.UUID
import java.util.concurrent.atomic._
import org.apache.ignite._
import org.apache.ignite.cluster.ClusterNode
import org.apache.ignite.events.EventType._
import org.apache.ignite.events.{DiscoveryEvent, Event}
import org.apache.ignite.internal.util.scala.impl
import org.apache.ignite.internal.util.{IgniteUtils => U}
import org.apache.ignite.lang.IgnitePredicate
import org.apache.ignite.visor.VisorTag
import org.apache.ignite.visor.commands.alert.VisorAlertCommand._
import org.apache.ignite.visor.commands.common.{VisorConsoleCommand, VisorTextTable}
import org.apache.ignite.visor.visor._
import scala.collection.immutable.HashMap
import scala.collection.mutable
import scala.language.implicitConversions
import scala.sys.process.{Process, ProcessLogger}
import scala.util.control.Breaks._
/**
* ==Overview==
* Visor 'alert' command implementation.
*
* ==Help==
* {{{
* +---------------------------------------------------------------------+
* | alert | Generates alerts for user-defined events. |
* | | Node events and grid-wide events are defined via mnemonics. |
* +---------------------------------------------------------------------+
* }}}
*
* ====Specification====
* {{{
* alert
* alert "-u {-id=<alert-id>|-a}"
* alert "-r {-t=<sec>} {-<metric>=<condition><value>} ... {-<metric>=<condition><value>}"
* }}}
*
* ====Arguments====
* {{{
* -n
* Alert name
* -u
* Unregisters alert(s). Either '-a' flag or '-id' parameter is required.
* Note that only one of the '-u' or '-r' is allowed.
* If neither '-u' or '-r' provided - all alerts will be printed.
* -a
* When provided with '-u' - all alerts will be unregistered.
* -id=<alert-id>
* When provided with '-u' - alert with matching ID will be unregistered.
* -r
* Register new alert with mnemonic predicate(s).
* Note that only one of the '-u' or '-r' is allowed.
* If neither '-u' or '-r' provided - all alerts will be printed.
* -t
* Defines notification frequency in seconds. Default is 60 seconds.
* This parameter can only appear with '-r'.
* -s
* Define script for execution when alert triggered.
* For configuration of throttle period see -i argument.
* Script will receive following arguments:
* 1) Alert name or alert ID when name is not defined.
* 2) Alert condition as string.
* 3, ...) Values of alert conditions ordered as in alert command.
* -i
* Configure alert notification minimal throttling interval in seconds. Default is 0 seconds.
*
* -<metric>
* This defines a mnemonic for the metric that will be measured:
*
* Grid-wide metrics (not node specific):
* cc - Total number of available CPUs in the grid.
* nc - Total number of nodes in the grid.
* hc - Total number of physical hosts in the grid.
* cl - Current average CPU load (in %) in the grid.
*
* Per-node current metrics:
* aj - Active jobs on the node.
* cj - Cancelled jobs on the node.
* tc - Thread count on the node.
* ut - Up time on the node.
* Note: <num> can have 's', 'm', or 'h' suffix indicating
* seconds, minutes, and hours. By default (no suffix provided)
* value is assumed to be in milliseconds.
* je - Job execute time on the node.
* jw - Job wait time on the node.
* wj - Waiting jobs count on the node.
* rj - Rejected jobs count on the node.
* hu - Heap memory used (in MB) on the node.
* cd - Current CPU load on the node.
* hm - Heap memory maximum (in MB) on the node.
* ),
* <condition>
* Comparison part of the mnemonic predicate:
* eq - Equal '=' to '<value>' number.
* neq - Not equal '!=' to '<value>' number.
* gt - Greater than '>' to '<value>' number.
* gte - Greater than or equal '>=' to '<value>' number.
* lt - Less than '<' to 'NN' number.
* lte - Less than or equal '<=' to '<value>' number.
* }}}
*
* ====Examples====
* {{{
* alert
* Prints all currently registered alerts.
* alert "-u -a"
* Unregisters all currently registered alerts.
* alert "-u -id=12345678"
* Unregisters alert with provided ID.
* alert "-r -t=900 -cc=gte4 -cl=gt50"
* Notify every 15 min if grid has >= 4 CPUs and > 50% CPU load.
* alert "-r -n=Nodes -t=15 -nc=gte3 -s=/home/user/scripts/alert.sh -i=300"
* Notify every 15 second if grid has >= 3 nodes and execute script "/home/user/scripts/alert.sh" with
* repeat interval not less than 5 min.
* }}}
*/
class VisorAlertCommand extends VisorConsoleCommand {
@impl protected val name = "alert"
/** Alerts. */
private var alerts = new HashMap[String, VisorAlert]
/** Map of last sent notification per alert ID. */
private var sent = new HashMap[String, Long]
/** Map of alert statistics. */
private var stats = new HashMap[String, VisorStats]
/** Last 10 sent alerts. */
private var last10 = List.empty[VisorSentAlert]
/** Subscribe guard. */
private val guard = new AtomicBoolean(false)
/** Node metric update listener. */
private var lsnr: IgnitePredicate[Event] = _
/**
* ===Command===
* Lists all registered alerts.
*
* ===Examples===
* <ex>alert</ex>
* Prints all currently registered alerts.
*/
def alert() {
alert("")
}
/**
* ===Command===
* Registers, unregisters and list alerts.
*
* ===Examples===
* <ex>alert "-u -a"</ex>
* Unregisters all currently registered alerts.
*
* <ex>alert "-i"</ex>
* Starts command in interactive mode.
*
* <ex>alert "-u -id=12345678"</ex>
* Unregisters alert with provided ID.
*
* <ex>alert "-r -t=900 -cc=gte4 -cl=gt50"</ex>
* Notify every 15 min if grid has >= 4 CPUs and > 50% CPU load.
*
* @param args Command arguments.
*/
def alert(args: String) {
assert(args != null)
val argLst = parseArgs(args)
if (hasArgFlag("u", argLst))
unregisterAlert(argLst)
else if (hasArgFlag("r", argLst))
registerAlert(argLst)
else if (args.length() > 0)
scold("Invalid arguments: " + args)
else
printAlerts()
}
/**
* Create function to check specific node condition.
*
* @param exprStr Expression string.
* @param value Value generator.
*/
private def makeNodeFilter(exprStr: String, value: (ClusterNode) => Long): Option[(ClusterNode) => (Long, Boolean)] = {
assert(exprStr != null)
assert(value != null)
val expr = makeExpression(exprStr)
// Note that if 'f(n)' is false - 'value' won't be evaluated.
expr match {
case Some(f) => Some((n: ClusterNode) => {
val v = value(n)
(v, f.apply(v))
})
case _ => throw new IgniteException("Invalid expression: " + exprStr)
}
}
/**
* Create function to check specific grid condition.
*
* @param exprStr Expression string.
* @param value Value generator.
*/
private def makeGridFilter(exprStr: String, value: () => Long): Option[() => (Long, Boolean)] = {
assert(exprStr != null)
assert(value != null)
val expr = makeExpression(exprStr)
// Note that if 'f' is false - 'value' won't be evaluated.
expr match {
case Some(f) =>
Some(() => {
val v = value()
(v, f.apply(v))
})
case _ =>
throw new IgniteException("Invalid expression: " + exprStr)
}
}
/**
* @param args Parsed argument list.
*/
private def registerAlert(args: ArgList) {
breakable {
assert(args != null)
if (checkConnected()) {
var name: Option[String] = None
var script: Option[String] = None
val conditions = mutable.ArrayBuffer.empty[VisorAlertCondition]
var freq = DFLT_FREQ
var interval = 0L
try {
args.foreach(arg => {
val (n, v) = arg
n match {
case c if ALERT_DESCRIPTORS.contains(c) && v != null =>
val meta = ALERT_DESCRIPTORS(c)
if (meta.byGrid)
conditions += VisorAlertCondition(arg, gridFunc = makeGridFilter(v, meta.gridFunc))
else
conditions += VisorAlertCondition(arg, nodeFunc = makeNodeFilter(v, meta.nodeFunc))
// Other tags.
case "n" if v != null => name = Some(v)
case "t" if v != null => freq = v.toLong
case "s" if v != null => script = Option(v)
case "i" if v != null => interval = v.toLong
case "r" => () // Skipping.
case _ => throw new IgniteException("Invalid argument: " + makeArg(arg))
}
})
}
catch {
case e: NumberFormatException =>
scold("Number conversion error: " + e.getMessage)
break()
case e: Exception =>
scold(e)
break()
}
if (conditions.isEmpty) {
scold("No predicates have been provided in args: " + makeArgs(args))
break()
}
val alert = VisorAlert(
id = id8,
name = name,
conditions = conditions,
perGrid = conditions.exists(_.gridFunc.isDefined),
perNode = conditions.exists(_.nodeFunc.isDefined),
spec = makeArgs(args.filter((arg) => arg._1 != "r")),
conditionSpec = makeArgs(conditions.map(_.arg)),
freq = freq,
createdOn = System.currentTimeMillis(),
varName = setVar(id8, "a"),
notification = VisorAlertNotification(script, interval * 1000)
)
// Subscribe for node metric updates - if needed.
registerListener()
alerts = alerts + (alert.id -> alert)
stats = stats + (alert.id -> VisorStats())
// Set visor var pointing to created alert.
mset(alert.varName, alert.id)
println("Alert '" + alert.id + "' (" + alert.varName + ") registered.")
}
}
}
/**
* Registers node metrics update listener, if one wasn't registered already.
*/
private def registerListener() {
if (guard.compareAndSet(false, true)) {
assert(lsnr == null)
lsnr = new IgnitePredicate[Event] {
override def apply(evt: Event): Boolean = {
val discoEvt = evt.asInstanceOf[DiscoveryEvent]
val node = ignite.cluster.node(discoEvt.eventNode().id())
if (node != null && !node.isDaemon)
alerts foreach (t => {
val (id, alert) = t
var check = (true, true)
var printNid = false
val values = mutable.ArrayBuffer.empty[String]
var valuesView = mutable.ArrayBuffer.empty[String]
try
check = alert.conditions.foldLeft(check) {
(res, cond) => {
val gridRes = cond.gridFunc.forall(f => {
val (value, check) = f()
values += value.toString
valuesView += cond.arg._1 + "=" + value.toString
check
})
val nodeRes = cond.nodeFunc.forall(f => {
val (value, check) = f(node)
values += value.toString
valuesView += cond.arg._1 + "=" + value.toString
printNid = true
check
})
(res._1 && gridRes) -> (res._2 && nodeRes)
}
}
catch {
// In case of exception (like an empty projection) - simply return.
case _: Throwable => return true
}
if (check._1 && check._2) {
val now = System.currentTimeMillis()
var go: Boolean = false
go = (now - sent.getOrElse(id, 0L)) / 1000 >= alert.freq
if (go) {
sent = sent + (id -> now)
val stat: VisorStats = stats(id)
assert(stat != null)
// Update stats.
if (stat.firstSnd == 0)
stat.firstSnd = now
stat.cnt += 1
stat.lastSnd = now
stats = stats + (id -> stat)
val nodeIdIp = nodeId8Addr(node.id()).split(", ")
// Write to Visor log if it is started (see 'log' command).
logText(
"Alert [" +
"id=" + alert.id + "(@" + alert.varName + "), " +
(if (printNid)
"nid8=" + nodeIdIp(0) + ", ip=" + nodeIdIp.lift(1).getOrElse(NA) + ", "
else "") +
"spec=[" + alert.spec + "], " +
"values=[" + valuesView.mkString("; ") + "], " +
"created on=" + formatDateTime(alert.createdOn) +
"]"
)
executeAlertScript(alert, node, values)
last10 = VisorSentAlert(
id = alert.id,
name = alert.name.getOrElse("(Not set)"),
spec = alert.spec,
createdOn = alert.createdOn,
sentTs = now
) +: last10
if (last10.size > 10)
last10 = last10.take(10)
}
}
else
alert.notification.notified = false
})
true
}
}
ignite.events().localListen(lsnr, EVT_NODE_METRICS_UPDATED)
}
}
/**
* Unregisters previously registered node metric update listener.
*/
private def unregisterListener() {
if (guard.compareAndSet(true, false)) {
assert(lsnr != null)
assert(ignite.events().stopLocalListen(lsnr))
lsnr = null
}
}
/**
* Resets command.
*/
private def reset() {
unregisterAll()
unregisterListener()
}
/**
* Prints advise.
*/
private def advise() {
println("\nType 'help alert' to see how to manage alerts.")
}
/**
* Unregisters all alerts.
*/
private def unregisterAll() {
mclear("-al")
alerts = new HashMap[String, VisorAlert]
}
/**
*
* @param args Parsed argument list.
*/
private def unregisterAlert(args: ArgList) {
breakable {
assert(args != null)
if (alerts.isEmpty) {
scold("No alerts have been registered yet.")
break()
}
// Unregister all alerts.
if (hasArgFlag("a", args)) {
unregisterAll()
println("All alerts have been unregistered.")
}
// Unregister specific alert.
else if (hasArgName("id", args)) {
val idOpt = argValue("id", args)
if (idOpt.isDefined) {
val id = idOpt.get
val a = alerts.get(id)
if (a.isDefined) {
alerts -= id
// Clear variable host.
mclear(a.get.varName)
println("Alert '" + id + "' unregistered.")
}
else {
scold("Failed to find alert with ID: " + id)
break()
}
}
else {
scold("No value for '-id' parameter found.")
break()
}
}
else {
scold("Failed to unregister alert.", "Either \"-a\" or \"-id\" parameter is required.")
break()
}
if (alerts.isEmpty)
unregisterListener()
}
}
/**
* Prints out all alerts.
*/
private def printAlerts() {
if (alerts.isEmpty)
println("No alerts are registered.")
else {
println("Summary:")
val sum = new VisorTextTable()
val firstSnd = (-1L /: stats.values)((b, a) => if (b == -1) a.firstSnd else math.min(b, a.firstSnd))
val lastSnd = (0L /: stats.values)((b, a) => math.max(b, a.lastSnd))
sum += ("Total alerts", alerts.size)
sum += ("Total sends", (0 /: stats.values)((b, a) => b + a.cnt))
sum += ("First send", if (firstSnd == 0) NA else formatDateTime(firstSnd))
sum += ("Last send", if (lastSnd == 0) NA else formatDateTime(lastSnd))
sum.render()
}
if (last10.isEmpty)
println("\nNo alerts have been sent.")
else {
val last10T = VisorTextTable()
last10T #= ("ID(@)/Name", "Spec", "Sent", "Registered", "Count")
last10.foreach((a: VisorSentAlert) => last10T += (
a.idVar + "/" + a.name,
a.spec,
formatDateTime(a.sentTs),
formatDateTime(a.createdOn),
stats(a.id).cnt
))
println("\nLast 10 Triggered Alerts:")
last10T.render()
}
if (alerts.nonEmpty) {
val tbl = new VisorTextTable()
tbl #= ("ID(@)/Name", "Spec", "Count", "Registered", "First Send", "Last Send")
val sorted = alerts.values.toSeq.sortWith(_.varName < _.varName)
sorted foreach (a => {
val stat = stats(a.id)
tbl += (
a.id + "(@" + a.varName + ')' + "/" + a.name.getOrElse("Not set"),
a.spec,
stat.cnt,
formatDateTime(a.createdOn),
if (stat.firstSnd == 0) NA else formatDateTime(stat.firstSnd),
if (stat.lastSnd == 0) NA else formatDateTime(stat.lastSnd)
)
})
println("\nAlerts: " + sorted.size)
tbl.render()
// Print advise.
advise()
}
}
/**
* Gets unique ID8 id for the alert.
*
* @return 8-character locally unique alert ID.
*/
private def id8: String = {
while (true) {
val id = UUID.randomUUID().toString.substring(0, 8)
// Have to check for guaranteed uniqueness.
if (!alerts.contains(id))
return id
}
assert(false, "Should never happen.")
""
}
/**
* Try to execute specified script on alert.
*
* @param alert Alarmed alert.
* @param node Node where alert is alarmed.
* @param values Values ith that alert is generated.
*/
private def executeAlertScript(alert: VisorAlert, node: ClusterNode, values: Seq[String]) {
val n = alert.notification
if (n.notified && System.currentTimeMillis() - n.notifiedTime < n.throttleInterval)
return
try {
n.script.foreach(script => {
val scriptFile = new File(script)
if (!scriptFile.exists())
throw new FileNotFoundException("Script/executable not found: " + script)
val scriptFolder = scriptFile.getParentFile
val p = Process(Seq(script, alert.name.getOrElse(alert.id), alert.conditionSpec) ++ values,
Some(scriptFolder))
p.run(ProcessLogger((fn: String) => {}))
n.notifiedTime = System.currentTimeMillis()
n.notified = true
})
}
catch {
case e: Throwable => logText("Script execution failed [" +
"id=" + alert.id + "(@" + alert.varName + "), " +
"error=" + e.getMessage + ", " +
"]")
}
}
}
/**
* Visor alert.
*
* @param id Alert id.
* @param name Alert name.
* @param conditions List of alert condition metadata.
* @param perGrid Condition per grid exists.
* @param perNode Condition per node exists.
* @param freq Freq of alert check.
* @param spec Alert command specification.
* @param conditionSpec Alert condition command specification.
* @param varName Alert id short name.
* @param createdOn Timestamp of alert creation.
* @param notification Alert notification information.
*/
private case class VisorAlert(
id: String,
name: Option[String],
conditions: Seq[VisorAlertCondition],
perGrid: Boolean,
perNode: Boolean,
freq: Long,
spec: String,
conditionSpec: String,
varName: String,
createdOn: Long,
notification: VisorAlertNotification
) {
assert(id != null)
assert(spec != null)
assert(varName != null)
}
/**
* Visor alert notification information.
*
* @param script Script to execute on alert firing.
* @param throttleInterval Minimal interval between script execution.
* @param notified `True` when on previous check of condition alert was fired or `false` otherwise.
* @param notifiedTime Time of first alert notification in series of firings.
*/
private case class VisorAlertNotification(
script: Option[String],
throttleInterval: Long,
var notified: Boolean = false,
var notifiedTime: Long = -1L
) {
assert(script != null)
}
/**
* Visor alert condition information.
*
* @param arg Configuration argument.
* @param gridFunc Function to check grid condition.
* @param nodeFunc Function to check node condition.
*/
private case class VisorAlertCondition(
arg: (String, String),
gridFunc: Option[() => (Long, Boolean)] = None,
nodeFunc: Option[(ClusterNode) => (Long, Boolean)] = None
)
/**
* Snapshot of the sent alert.
*/
private case class VisorSentAlert(
id: String,
name: String,
sentTs: Long,
createdOn: Long,
spec: String
) {
assert(id != null)
assert(spec != null)
def idVar: String = {
val v = mfindHead(id)
if (v.isDefined) id + "(@" + v.get._1 + ")" else id
}
}
/**
* Statistics holder for visor alert.
*/
private case class VisorStats(
var cnt: Int = 0,
var firstSnd: Long = 0,
var lastSnd: Long = 0
)
/**
* Metadata object for visor alert.
*
* @param byGrid If `true` then `gridFunc` should be used.
* @param gridFunc Function to extract value to check in case of alert for grid metrics.
* @param nodeFunc Function to extract value to check in case of alert for node metrics
*/
private case class VisorAlertMeta(
byGrid: Boolean,
gridFunc: () => Long,
nodeFunc: (ClusterNode) => Long
)
/**
* Companion object that does initialization of the command.
*/
object VisorAlertCommand {
/** Default alert frequency. */
val DFLT_FREQ = 60L
private val dfltNodeValF = (_: ClusterNode) => 0L
private val dfltGridValF = () => 0L
private def cl(): IgniteCluster = ignite.cluster()
private[this] val BY_GRID = true
private[this] val BY_NODE = false
private val ALERT_DESCRIPTORS = Map(
"cc" -> VisorAlertMeta(BY_GRID, () => cl().metrics().getTotalCpus, dfltNodeValF),
"nc" -> VisorAlertMeta(BY_GRID, () => cl().nodes().size, dfltNodeValF),
"hc" -> VisorAlertMeta(BY_GRID, () => U.neighborhood(cl().nodes()).size, dfltNodeValF),
"cl" -> VisorAlertMeta(BY_GRID, () => (cl().metrics().getAverageCpuLoad * 100).toLong, dfltNodeValF),
"aj" -> VisorAlertMeta(BY_NODE, dfltGridValF, (node) => node.metrics().getCurrentActiveJobs),
"cj" -> VisorAlertMeta(BY_NODE, dfltGridValF, (node) => node.metrics().getCurrentCancelledJobs),
"tc" -> VisorAlertMeta(BY_NODE, dfltGridValF, (node) => node.metrics().getCurrentThreadCount),
"ut" -> VisorAlertMeta(BY_NODE, dfltGridValF, (node) => node.metrics().getUpTime),
"je" -> VisorAlertMeta(BY_NODE, dfltGridValF, (node) => node.metrics().getCurrentJobExecuteTime),
"jw" -> VisorAlertMeta(BY_NODE, dfltGridValF, (node) => node.metrics().getCurrentJobWaitTime),
"wj" -> VisorAlertMeta(BY_NODE, dfltGridValF, (node) => node.metrics().getCurrentWaitingJobs),
"rj" -> VisorAlertMeta(BY_NODE, dfltGridValF, (node) => node.metrics().getCurrentRejectedJobs),
"hu" -> VisorAlertMeta(BY_NODE, dfltGridValF, (node) => node.metrics().getHeapMemoryUsed),
"cd" -> VisorAlertMeta(BY_NODE, dfltGridValF, (node) => node.metrics().getHeapMemoryMaximum),
"hm" -> VisorAlertMeta(BY_NODE, dfltGridValF, (node) => (node.metrics().getCurrentCpuLoad * 100).toLong))
/** Singleton command. */
private val cmd = new VisorAlertCommand
addHelp(
name = "alert",
shortInfo = "Alerts for user-defined events.",
longInfo = Seq(
"Generates alerts for user-defined events.",
"Node events and grid-wide events are defined via mnemonics."
),
spec = Seq(
"alert",
"alert -u {-id=<alert-id>|-a}",
"alert -r {-t=<sec>} {-<metric>=<condition><value>} ... {-<metric>=<condition><value>}"
),
args = Seq(
"-n" ->
"Alert name",
"-u" -> Seq(
"Unregisters alert(s). Either '-a' flag or '-id' parameter is required.",
"Note that only one of the '-u' or '-r' is allowed.",
"If neither '-u' or '-r' provided - all alerts will be printed."
),
"-a" ->
"When provided with '-u' - all alerts will be unregistered.",
("-id=<alert-id>",
"When provided with '-u' - alert with matching ID will be unregistered" +
"Note you can also use '@a0' ... '@an' variables as shortcut to <alert-id>."),
"-r" -> Seq(
"Register new alert with mnemonic predicate(s).",
"Note that only one of the '-u' or '-r' is allowed.",
"If neither '-u' or '-r' provided - all alerts will be printed."
),
"-t" -> Seq(
"Defines notification frequency in seconds. Default is 60 seconds.",
"This parameter can only appear with '-r'."
),
"-s" -> Seq(
"Define script for execution when alert triggered.",
"For configuration of throttle period see -i argument.",
"Script will receive following arguments:",
" 1) Alert name or alert ID when name is not defined.",
" 2) Alert condition as string.",
" 3, ...) Values of alert conditions ordered as in alert command."
),
"-i" -> "Configure alert notification minimal throttling interval in seconds. Default is 0 seconds.",
"-<metric>" -> Seq(
"This defines a mnemonic for the metric that will be measured:",
"",
"Grid-wide metrics (not node specific):",
" cc - Total number of available CPUs in the grid.",
" nc - Total number of nodes in the grid.",
" hc - Total number of physical hosts in the grid.",
" cl - Current average CPU load (in %) in the grid.",
"",
"Per-node current metrics:",
" aj - Active jobs on the node.",
" cj - Cancelled jobs on the node.",
" tc - Thread count on the node.",
" ut - Up time on the node.",
" Note: <num> can have 's', 'm', or 'h' suffix indicating",
" seconds, minutes, and hours. By default (no suffix provided)",
" value is assumed to be in milliseconds.",
" je - Job execute time on the node.",
" jw - Job wait time on the node.",
" wj - Waiting jobs count on the node.",
" rj - Rejected jobs count on the node.",
" hu - Heap memory used (in MB) on the node.",
" cd - Current CPU load on the node.",
" hm - Heap memory maximum (in MB) on the node."
),
"<condition>" -> Seq(
"Comparison part of the mnemonic predicate:",
" eq - Equal '=' to '<value>' number.",
" neq - Not equal '!=' to '<value>' number.",
" gt - Greater than '>' to '<value>' number.",
" gte - Greater than or equal '>=' to '<value>' number.",
" lt - Less than '<' to 'NN' number.",
" lte - Less than or equal '<=' to '<value>' number."
)
),
examples = Seq(
"alert" ->
"Prints all currently registered alerts.",
"alert -u -a" ->
"Unregisters all currently registered alerts.",
"alert -u -id=12345678" ->
"Unregisters alert with provided ID.",
"alert -u -id=@a0" ->
"Unregisters alert with provided ID taken from '@a0' memory variable.",
"alert -r -t=900 -cc=gte4 -cl=gt50" ->
"Notify every 15 min if grid has >= 4 CPUs and > 50% CPU load.",
"alert \"-r -n=Nodes -t=15 -nc=gte3 -s=/home/user/scripts/alert.sh -i=300" ->
("Notify every 15 second if grid has >= 3 nodes and execute script \"/home/user/scripts/alert.sh\" with " +
"repeat interval not less than 5 min.")
),
emptyArgs = cmd.alert,
withArgs = cmd.alert
)
addCloseCallback(() => {
cmd.reset()
})
/**
* Singleton.
*/
def apply() = cmd
/**
* Implicit converter from visor to commands "pimp".
*
* @param vs Visor tagging trait.
*/
implicit def fromAlert2Visor(vs: VisorTag): VisorAlertCommand = cmd
}
| alexzaitzev/ignite | modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/alert/VisorAlertCommand.scala | Scala | apache-2.0 | 33,630 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
2030,
2062,
1008,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
5500,
2007,
1008,
2023,
2147,
2005,
3176,
2592,
4953,
9385,
6095,
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... |
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.1433
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace DCalcServer.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
| pavkam/school | DCalc/DCalcServer/Properties/Settings.Designer.cs | C# | mit | 1,096 | [
30522,
1013,
1013,
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... |
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ODM\MongoDB\Mapping\Annotations;
use Doctrine\Common\Annotations\Annotation;
abstract class AbstractDocument extends Annotation
{
}
| CaoPhiHung/CRM | vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/AbstractDocument.php | PHP | mit | 1,168 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
2023,
4007,
2003,
3024,
2011,
1996,
9385,
13304,
1998,
16884,
1008,
1000,
2004,
2003,
1000,
1998,
2151,
4671,
2030,
13339,
10943,
3111,
1010,
2164,
1010,
2021,
2025,
1008,
3132,
2000,
1010,
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... |
/*
* Copyright (c) 2009-2012 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.jme3.terrain.heightmap;
import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* <code>AbstractHeightMap</code> provides a base implementation of height
* data for terrain rendering. The loading of the data is dependent on the
* subclass. The abstract implementation provides a means to retrieve the height
* data and to save it.
*
* It is the general contract that any subclass provide a means of editing
* required attributes and calling <code>load</code> again to recreate a
* heightfield with these new parameters.
*
* @author Mark Powell
* @version $Id: AbstractHeightMap.java 4133 2009-03-19 20:40:11Z blaine.dev $
*/
public abstract class AbstractHeightMap implements HeightMap {
private static final Logger logger = Logger.getLogger(AbstractHeightMap.class.getName());
/** Height data information. */
protected float[] heightData = null;
/** The size of the height map's width. */
protected int size = 0;
/** Allows scaling the Y height of the map. */
protected float heightScale = 1.0f;
/** The filter is used to erode the terrain. */
protected float filter = 0.5f;
/** The range used to normalize terrain */
public static float NORMALIZE_RANGE = 255f;
/**
* <code>unloadHeightMap</code> clears the data of the height map. This
* insures it is ready for reloading.
*/
public void unloadHeightMap() {
heightData = null;
}
/**
* <code>setHeightScale</code> sets the scale of the height values.
* Typically, the height is a little too extreme and should be scaled to a
* smaller value (i.e. 0.25), to produce cleaner slopes.
*
* @param scale
* the scale to multiply height values by.
*/
public void setHeightScale(float scale) {
heightScale = scale;
}
/**
* <code>setHeightAtPoint</code> sets the height value for a given
* coordinate. It is recommended that the height value be within the 0 - 255
* range.
*
* @param height
* the new height for the coordinate.
* @param x
* the x (east/west) coordinate.
* @param z
* the z (north/south) coordinate.
*/
public void setHeightAtPoint(float height, int x, int z) {
heightData[x + (z * size)] = height;
}
/**
* <code>setSize</code> sets the size of the terrain where the area is
* size x size.
*
* @param size
* the new size of the terrain.
* @throws Exception
*
* @throws JmeException
* if the size is less than or equal to zero.
*/
public void setSize(int size) throws Exception {
if (size <= 0) {
throw new Exception("size must be greater than zero.");
}
this.size = size;
}
/**
* <code>setFilter</code> sets the erosion value for the filter. This
* value must be between 0 and 1, where 0.2 - 0.4 produces arguably the best
* results.
*
* @param filter
* the erosion value.
* @throws Exception
* @throws JmeException
* if filter is less than 0 or greater than 1.
*/
public void setMagnificationFilter(float filter) throws Exception {
if (filter < 0 || filter >= 1) {
throw new Exception("filter must be between 0 and 1");
}
this.filter = filter;
}
/**
* <code>getTrueHeightAtPoint</code> returns the non-scaled value at the
* point provided.
*
* @param x
* the x (east/west) coordinate.
* @param z
* the z (north/south) coordinate.
* @return the value at (x,z).
*/
public float getTrueHeightAtPoint(int x, int z) {
//logger.fine( heightData[x + (z*size)]);
return heightData[x + (z * size)];
}
/**
* <code>getScaledHeightAtPoint</code> returns the scaled value at the
* point provided.
*
* @param x
* the x (east/west) coordinate.
* @param z
* the z (north/south) coordinate.
* @return the scaled value at (x, z).
*/
public float getScaledHeightAtPoint(int x, int z) {
return ((heightData[x + (z * size)]) * heightScale);
}
/**
* <code>getInterpolatedHeight</code> returns the height of a point that
* does not fall directly on the height posts.
*
* @param x
* the x coordinate of the point.
* @param z
* the y coordinate of the point.
* @return the interpolated height at this point.
*/
public float getInterpolatedHeight(float x, float z) {
float low, highX, highZ;
float intX, intZ;
float interpolation;
low = getScaledHeightAtPoint((int) x, (int) z);
if (x + 1 >= size) {
return low;
}
highX = getScaledHeightAtPoint((int) x + 1, (int) z);
interpolation = x - (int) x;
intX = ((highX - low) * interpolation) + low;
if (z + 1 >= size) {
return low;
}
highZ = getScaledHeightAtPoint((int) x, (int) z + 1);
interpolation = z - (int) z;
intZ = ((highZ - low) * interpolation) + low;
return ((intX + intZ) / 2);
}
/**
* <code>getHeightMap</code> returns the entire grid of height data.
*
* @return the grid of height data.
*/
public float[] getHeightMap() {
return heightData;
}
/**
* Build a new array of height data with the scaled values.
* @return
*/
public float[] getScaledHeightMap() {
float[] hm = new float[heightData.length];
for (int i=0; i<heightData.length; i++) {
hm[i] = heightScale * heightData[i];
}
return hm;
}
/**
* <code>getSize</code> returns the size of one side the height map. Where
* the area of the height map is size x size.
*
* @return the size of a single side.
*/
public int getSize() {
return size;
}
/**
* <code>save</code> will save the heightmap data into a new RAW file
* denoted by the supplied filename.
*
* @param filename
* the file name to save the current data as.
* @return true if the save was successful, false otherwise.
* @throws Exception
*
* @throws JmeException
* if filename is null.
*/
public boolean save(String filename) throws Exception {
if (null == filename) {
throw new Exception("Filename must not be null");
}
//open the streams and send the height data to the file.
FileOutputStream fos = null;
DataOutputStream dos = null;
try {
fos = new FileOutputStream(filename);
dos = new DataOutputStream(fos);
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
dos.write((int) heightData[j + (i * size)]);
}
}
fos.close();
dos.close();
} catch (FileNotFoundException e) {
logger.log(Level.WARNING, "Error opening file {0}", filename);
return false;
} catch (IOException e) {
logger.log(Level.WARNING, "Error writing to file {0}", filename);
return false;
} finally {
if (fos != null) {
fos.close();
}
if (dos != null) {
dos.close();
}
}
logger.log(Level.FINE, "Saved terrain to {0}", filename);
return true;
}
/**
* <code>normalizeTerrain</code> takes the current terrain data and
* converts it to values between 0 and <code>value</code>.
*
* @param value
* the value to normalize to.
*/
public void normalizeTerrain(float value) {
float currentMin, currentMax;
float height;
currentMin = heightData[0];
currentMax = heightData[0];
//find the min/max values of the height fTemptemptempBuffer
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
if (heightData[i + j * size] > currentMax) {
currentMax = heightData[i + j * size];
} else if (heightData[i + j * size] < currentMin) {
currentMin = heightData[i + j * size];
}
}
}
//find the range of the altitude
if (currentMax <= currentMin) {
return;
}
height = currentMax - currentMin;
//scale the values to a range of 0-255
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
heightData[i + j * size] = ((heightData[i + j * size] - currentMin) / height) * value;
}
}
}
/**
* Find the minimum and maximum height values.
* @return a float array with two value: min height, max height
*/
public float[] findMinMaxHeights() {
float[] minmax = new float[2];
float currentMin, currentMax;
currentMin = heightData[0];
currentMax = heightData[0];
for (int i = 0; i < heightData.length; i++) {
if (heightData[i] > currentMax) {
currentMax = heightData[i];
} else if (heightData[i] < currentMin) {
currentMin = heightData[i];
}
}
minmax[0] = currentMin;
minmax[1] = currentMax;
return minmax;
}
/**
* <code>erodeTerrain</code> is a convenience method that applies the FIR
* filter to a given height map. This simulates water errosion.
*
* @see setFilter
*/
public void erodeTerrain() {
//erode left to right
float v;
for (int i = 0; i < size; i++) {
v = heightData[i];
for (int j = 1; j < size; j++) {
heightData[i + j * size] = filter * v + (1 - filter) * heightData[i + j * size];
v = heightData[i + j * size];
}
}
//erode right to left
for (int i = size - 1; i >= 0; i--) {
v = heightData[i];
for (int j = 0; j < size; j++) {
heightData[i + j * size] = filter * v + (1 - filter) * heightData[i + j * size];
v = heightData[i + j * size];
//erodeBand(tempBuffer[size * i + size - 1], -1);
}
}
//erode top to bottom
for (int i = 0; i < size; i++) {
v = heightData[i];
for (int j = 0; j < size; j++) {
heightData[i + j * size] = filter * v + (1 - filter) * heightData[i + j * size];
v = heightData[i + j * size];
}
}
//erode from bottom to top
for (int i = size - 1; i >= 0; i--) {
v = heightData[i];
for (int j = 0; j < size; j++) {
heightData[i + j * size] = filter * v + (1 - filter) * heightData[i + j * size];
v = heightData[i + j * size];
}
}
}
/**
* Flattens out the valleys. The flatten algorithm makes the valleys more
* prominent while keeping the hills mostly intact. This effect is based on
* what happens when values below one are squared. The terrain will be
* normalized between 0 and 1 for this function to work.
*
* @param flattening
* the power of flattening applied, 1 means none
*/
public void flatten(byte flattening) {
// If flattening is one we can skip the calculations
// since it wouldn't change anything. (e.g. 2 power 1 = 2)
if (flattening <= 1) {
return;
}
float[] minmax = findMinMaxHeights();
normalizeTerrain(1f);
for (int x = 0; x < size; x++) {
for (int y = 0; y < size; y++) {
float flat = 1.0f;
float original = heightData[x + y * size];
// Flatten as many times as desired;
for (int i = 0; i < flattening; i++) {
flat *= original;
}
heightData[x + y * size] = flat;
}
}
// re-normalize back to its oraginal height range
float height = minmax[1] - minmax[0];
normalizeTerrain(height);
}
/**
* Smooth the terrain. For each node, its 8 neighbors heights
* are averaged and will participate in the node new height
* by a factor <code>np</code> between 0 and 1
*
* You must first load() the heightmap data before this will have any effect.
*
* @param np
* The factor to what extend the neighbors average has an influence.
* Value of 0 will ignore neighbors (no smoothing)
* Value of 1 will ignore the node old height.
*/
public void smooth(float np) {
smooth(np, 1);
}
/**
* Smooth the terrain. For each node, its X(determined by radius) neighbors heights
* are averaged and will participate in the node new height
* by a factor <code>np</code> between 0 and 1
*
* You must first load() the heightmap data before this will have any effect.
*
* @param np
* The factor to what extend the neighbors average has an influence.
* Value of 0 will ignore neighbors (no smoothing)
* Value of 1 will ignore the node old height.
*/
public void smooth(float np, int radius) {
if (np < 0 || np > 1) {
return;
}
if (radius == 0)
radius = 1;
for (int x = 0; x < size; x++) {
for (int y = 0; y < size; y++) {
int neighNumber = 0;
float neighAverage = 0;
for (int rx = -radius; rx <= radius; rx++) {
for (int ry = -radius; ry <= radius; ry++) {
if (x+rx < 0 || x+rx >= size) {
continue;
}
if (y+ry < 0 || y+ry >= size) {
continue;
}
neighNumber++;
neighAverage += heightData[(x+rx) + (y+ry) * size];
}
}
neighAverage /= neighNumber;
float cp = 1 - np;
heightData[x + y * size] = neighAverage * np + heightData[x + y * size] * cp;
}
}
}
}
| PlanetWaves/clockworkengine | trunk/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/AbstractHeightMap.java | Java | apache-2.0 | 16,437 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2268,
1011,
2262,
1046,
8202,
14839,
13159,
3170,
1008,
2035,
2916,
9235,
1012,
1008,
1008,
25707,
1998,
2224,
1999,
3120,
1998,
12441,
3596,
1010,
2007,
2030,
2302,
1008,
14080,
1010,
2024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>
<div class="sf_admin_form">
<?php echo form_tag_for($form, '@jt_users') ?>
<?php echo $form->renderHiddenFields(false) ?>
<?php if ($form->hasGlobalErrors()): ?>
<?php echo $form->renderGlobalErrors() ?>
<?php endif; ?>
<?php foreach ($configuration->getFormFields($form, $form->isNew() ? 'new' : 'edit') as $fieldset => $fields): ?>
<?php include_partial('jt_users/form_fieldset', array('jtusers' => $jtusers, 'form' => $form, 'fields' => $fields, 'fieldset' => $fieldset)) ?>
<?php endforeach; ?>
<?php include_partial('jt_users/form_actions', array('jtusers' => $jtusers, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?>
</form>
</div>
| jtarleton/jt-web | cache/front/dev/modules/autoJt_users/templates/_form.php | PHP | mit | 793 | [
30522,
1026,
1029,
25718,
2224,
1035,
6782,
21030,
3215,
1035,
2005,
1035,
2433,
1006,
1002,
2433,
1007,
1029,
1028,
1026,
1029,
25718,
2224,
1035,
9262,
22483,
2015,
1035,
2005,
1035,
2433,
1006,
1002,
2433,
1007,
1029,
1028,
1026,
4487,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/**********************************************************************
* $Id: WKBReader.cpp 2022 2007-09-14 15:25:29Z csavage $
*
* GEOS - Geometry Engine Open Source
* http://geos.refractions.net
*
* Copyright (C) 2005-2006 Refractions Research Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************/
#include <geos/io/WKBReader.h>
#include <geos/io/WKBConstants.h>
#include <geos/io/ByteOrderValues.h>
#include <geos/io/ParseException.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/Coordinate.h>
#include <geos/geom/Point.h>
#include <geos/geom/LinearRing.h>
#include <geos/geom/LineString.h>
#include <geos/geom/Polygon.h>
#include <geos/geom/MultiPoint.h>
#include <geos/geom/MultiLineString.h>
#include <geos/geom/MultiPolygon.h>
#include <geos/geom/CoordinateSequenceFactory.h>
#include <geos/geom/CoordinateSequence.h>
#include <geos/geom/PrecisionModel.h>
#include <iomanip>
#include <ostream>
#include <sstream>
#include <string>
//#define DEBUG_WKB_READER 1
using namespace std;
using namespace geos::geom;
namespace geos {
namespace io { // geos.io
string WKBReader::BAD_GEOM_TYPE_MSG = "bad geometry type encountered in ";
WKBReader::WKBReader()
:
factory(*(GeometryFactory::getDefaultInstance()))
{}
ostream &
WKBReader::printHEX(istream &is, ostream &os)
{
static const char hex[] = "0123456789ABCDEF";
long pos = is.tellg(); // take note of input stream get pointer
is.seekg(0, ios::beg); // rewind input stream
char each=0;
while(is.read(&each, 1))
{
const unsigned char c=each;
int low = (c & 0x0F);
int high = (c >> 4);
os << hex[high] << hex[low];
}
is.clear(); // clear input stream eof flag
is.seekg(pos); // reset input stream position
return os;
}
Geometry *
WKBReader::readHEX(istream &is)
{
// setup input/output stream
stringstream os(ios_base::binary|ios_base::in|ios_base::out);
unsigned char high, low, result_high, result_low, value;
while(!is.eof())//readsome(&str[0], 2))
{
// get the high part of the byte
is >> high;
// geth the low part of the byte
is >> low;
switch (high)
{
case '0' :
result_high = 0;
break;
case '1' :
result_high = 1;
break;
case '2' :
result_high = 2;
break;
case '3' :
result_high = 3;
break;
case '4' :
result_high = 4;
break;
case '5' :
result_high = 5;
break;
case '6' :
result_high = 6;
break;
case '7' :
result_high = 7;
break;
case '8' :
result_high = 8;
break;
case '9' :
result_high = 9;
break;
case 'A' :
result_high = 10;
break;
case 'B' :
result_high = 11;
break;
case 'C' :
result_high = 12;
break;
case 'D' :
result_high = 13;
break;
case 'E' :
result_high = 14;
break;
case 'F' :
result_high = 15;
break;
default:
throw ParseException("Invalid HEX char");
}
switch (low)
{
case '0' :
result_low = 0;
break;
case '1' :
result_low = 1;
break;
case '2' :
result_low = 2;
break;
case '3' :
result_low = 3;
break;
case '4' :
result_low = 4;
break;
case '5' :
result_low = 5;
break;
case '6' :
result_low = 6;
break;
case '7' :
result_low = 7;
break;
case '8' :
result_low = 8;
break;
case '9' :
result_low = 9;
break;
case 'A' :
result_low = 10;
break;
case 'B' :
result_low = 11;
break;
case 'C' :
result_low = 12;
break;
case 'D' :
result_low = 13;
break;
case 'E' :
result_low = 14;
break;
case 'F' :
result_low = 15;
break;
default:
throw ParseException("Invalid HEX char");
}
value = (result_high<<4) + result_low;
#if DEBUG_HEX_READER
cout<<"HEX "<<high<<low<<" -> DEC "<<(int)value<<endl;
#endif
// write the value to the output stream
os << value;
}
// now call read to convert the geometry
return this->read(os);
}
Geometry *
WKBReader::read(istream &is)
{
dis.setInStream(&is); // will default to machine endian
return readGeometry();
}
Geometry *
WKBReader::readGeometry()
{
// determine byte order
unsigned char byteOrder = dis.readByte();
#if DEBUG_WKB_READER
cout<<"WKB byteOrder: "<<(int)byteOrder<<endl;
#endif
// default is machine endian
if (byteOrder == WKBConstants::wkbNDR)
dis.setOrder(ByteOrderValues::ENDIAN_LITTLE);
else if (byteOrder == WKBConstants::wkbXDR)
dis.setOrder(ByteOrderValues::ENDIAN_BIG);
int typeInt = dis.readInt();
int geometryType = typeInt & 0xff;
#if DEBUG_WKB_READER
cout<<"WKB geometryType: "<<geometryType<<endl;
#endif
bool hasZ = ((typeInt & 0x80000000) != 0);
if (hasZ) inputDimension = 3;
else inputDimension = 2; // doesn't handle M currently
#if DEBUG_WKB_READER
cout<<"WKB hasZ: "<<hasZ<<endl;
#endif
#if DEBUG_WKB_READER
cout<<"WKB dimensions: "<<inputDimension<<endl;
#endif
bool hasSRID = ((typeInt & 0x20000000) != 0);
#if DEBUG_WKB_READER
cout<<"WKB hasSRID: "<<hasZ<<endl;
#endif
int SRID = 0;
if (hasSRID) SRID = dis.readInt(); // read SRID
// allocate space for ordValues
if ( ordValues.size() < inputDimension )
ordValues.resize(inputDimension);
Geometry *result;
switch (geometryType) {
case WKBConstants::wkbPoint :
result = readPoint();
break;
case WKBConstants::wkbLineString :
result = readLineString();
break;
case WKBConstants::wkbPolygon :
result = readPolygon();
break;
case WKBConstants::wkbMultiPoint :
result = readMultiPoint();
break;
case WKBConstants::wkbMultiLineString :
result = readMultiLineString();
break;
case WKBConstants::wkbMultiPolygon :
result = readMultiPolygon();
break;
case WKBConstants::wkbGeometryCollection :
result = readGeometryCollection();
break;
default:
stringstream err;
err << "Unknown WKB type " << geometryType;
throw ParseException(err.str());
}
result->setSRID(SRID);
return result;
}
Point *
WKBReader::readPoint()
{
readCoordinate();
return factory.createPoint(Coordinate(ordValues[0], ordValues[1]));
}
LineString *
WKBReader::readLineString()
{
int size = dis.readInt();
#if DEBUG_WKB_READER
cout<<"WKB npoints: "<<size<<endl;
#endif
CoordinateSequence *pts = readCoordinateSequence(size);
return factory.createLineString(pts);
}
LinearRing *
WKBReader::readLinearRing()
{
int size = dis.readInt();
#if DEBUG_WKB_READER
cout<<"WKB npoints: "<<size<<endl;
#endif
CoordinateSequence *pts = readCoordinateSequence(size);
return factory.createLinearRing(pts);
}
Polygon *
WKBReader::readPolygon()
{
int numRings = dis.readInt();
#if DEBUG_WKB_READER
cout<<"WKB numRings: "<<numRings<<endl;
#endif
LinearRing *shell = NULL;
if( numRings > 0 )
shell = readLinearRing();
vector<Geometry *>*holes=NULL;
if ( numRings > 1 )
{
try {
holes = new vector<Geometry *>(numRings-1);
for (int i=0; i<numRings-1; i++)
(*holes)[i] = (Geometry *)readLinearRing();
} catch (...) {
for (unsigned int i=0; i<holes->size(); i++)
delete (*holes)[i];
delete holes;
delete shell;
throw;
}
}
return factory.createPolygon(shell, holes);
}
MultiPoint *
WKBReader::readMultiPoint()
{
int numGeoms = dis.readInt();
vector<Geometry *> *geoms = new vector<Geometry *>(numGeoms);
try {
for (int i=0; i<numGeoms; i++)
{
Geometry *g = readGeometry();
if (!dynamic_cast<Point *>(g))
{
stringstream err;
err << BAD_GEOM_TYPE_MSG << " MultiPoint";
throw ParseException(err.str());
}
(*geoms)[i] = g;
}
} catch (...) {
for (unsigned int i=0; i<geoms->size(); i++)
delete (*geoms)[i];
delete geoms;
throw;
}
return factory.createMultiPoint(geoms);
}
MultiLineString *
WKBReader::readMultiLineString()
{
int numGeoms = dis.readInt();
vector<Geometry *> *geoms = new vector<Geometry *>(numGeoms);
try {
for (int i=0; i<numGeoms; i++)
{
Geometry *g = readGeometry();
if (!dynamic_cast<LineString *>(g))
{
stringstream err;
err << BAD_GEOM_TYPE_MSG << " LineString";
throw ParseException(err.str());
}
(*geoms)[i] = g;
}
} catch (...) {
for (unsigned int i=0; i<geoms->size(); i++)
delete (*geoms)[i];
delete geoms;
throw;
}
return factory.createMultiLineString(geoms);
}
MultiPolygon *
WKBReader::readMultiPolygon()
{
int numGeoms = dis.readInt();
vector<Geometry *> *geoms = new vector<Geometry *>(numGeoms);
try {
for (int i=0; i<numGeoms; i++)
{
Geometry *g = readGeometry();
if (!dynamic_cast<Polygon *>(g))
{
stringstream err;
err << BAD_GEOM_TYPE_MSG << " Polygon";
throw ParseException(err.str());
}
(*geoms)[i] = g;
}
} catch (...) {
for (unsigned int i=0; i<geoms->size(); i++)
delete (*geoms)[i];
delete geoms;
throw;
}
return factory.createMultiPolygon(geoms);
}
GeometryCollection *
WKBReader::readGeometryCollection()
{
int numGeoms = dis.readInt();
vector<Geometry *> *geoms = new vector<Geometry *>(numGeoms);
try {
for (int i=0; i<numGeoms; i++)
(*geoms)[i] = (readGeometry());
} catch (...) {
for (unsigned int i=0; i<geoms->size(); i++)
delete (*geoms)[i];
delete geoms;
throw;
}
return factory.createGeometryCollection(geoms);
}
CoordinateSequence *
WKBReader::readCoordinateSequence(int size)
{
CoordinateSequence *seq = factory.getCoordinateSequenceFactory()->create(size, inputDimension);
unsigned int targetDim = seq->getDimension();
if ( targetDim > inputDimension )
targetDim = inputDimension;
for (int i=0; i<size; i++) {
readCoordinate();
for (unsigned int j=0; j<targetDim; j++) {
seq->setOrdinate(i, j, ordValues[j]);
}
}
return seq;
}
void
WKBReader::readCoordinate()
{
const PrecisionModel &pm = *factory.getPrecisionModel();
for (unsigned int i=0; i<inputDimension; ++i)
{
if ( i <= 1 ) ordValues[i] = pm.makePrecise(dis.readDouble());
else ordValues[i] = dis.readDouble();
}
#if DEBUG_WKB_READER
cout<<"WKB coordinate: "<<ordValues[0]<<","<<ordValues[1]<<endl;
#endif
}
} // namespace geos.io
} // namespace geos
| asapnet/geos | source/io/WKBReader.cpp | C++ | lgpl-2.1 | 10,322 | [
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... |
<!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">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>V8 API Reference Guide for node.js v8.10.0: v8::internal::SmiTagging< ptr_size > Struct Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">V8 API Reference Guide for node.js v8.10.0
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="classes.html"><span>Class Index</span></a></li>
<li><a href="inherits.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="namespacev8.html">v8</a></li><li class="navelem"><b>internal</b></li><li class="navelem"><a class="el" href="structv8_1_1internal_1_1SmiTagging.html">SmiTagging</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">v8::internal::SmiTagging< ptr_size > Struct Template Reference</div> </div>
</div><!--header-->
<div class="contents">
<hr/>The documentation for this struct was generated from the following file:<ul>
<li>deps/v8/include/<a class="el" href="v8_8h_source.html">v8.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>
| v8-dox/v8-dox.github.io | 2a2c881/html/structv8_1_1internal_1_1SmiTagging.html | HTML | mit | 4,590 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
11039,
19968,
1015,
1012,
1014,
17459,
1013,
1013,
4372,
1000,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
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... |
package eu.liderproject.functionalsparql
import org.scalatest._
class TestDistCollection extends FlatSpec with Matchers {
"cogrouping" should "work" in {
val c1 = SimpleKeyDistCollection(Seq(
(1,2),(3,4),(2,5),(1,7),(60,1)
))
val c2 = SimpleKeyDistCollection(Seq(
(3,4),(3,4),(2,2),(-1,1)
))
val SimpleDistCollection(seq) = c1.cogroup(c2).filter{
case (x,y) => !x.isEmpty && !y.isEmpty
}
val iter = seq.iterator
{
val (_i1, _i2) = iter.next
val i1 = _i1.iterator
val i2 = _i2.iterator
i1.next should be (5)
i1.hasNext should be (false)
i2.next should be (2)
i2.hasNext should be (false)
}
{
val (_i1, _i2) = iter.next
val i1 = _i1.iterator
val i2 = _i2.iterator
i1.next should be (4)
i1.hasNext should be (false)
i2.next should be (4)
i2.next should be (4)
i2.hasNext should be (false)
}
iter.hasNext should be (false)
}
} | jmccrae/functionalsparql | src/test/scala/functionalsparql/TestDistCollection.scala | Scala | apache-2.0 | 911 | [
30522,
7427,
7327,
1012,
11876,
2121,
21572,
20614,
1012,
8360,
27694,
4160,
2140,
12324,
8917,
1012,
26743,
22199,
1012,
1035,
2465,
3231,
10521,
13535,
14511,
18491,
8908,
14201,
5051,
2278,
2007,
2674,
2545,
1063,
1000,
2522,
17058,
2075,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.classification;
import static org.alfresco.module.org_alfresco_module_rm.classification.ClearanceLevelManager.NO_CLEARANCE;
import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.ASPECT_SECURITY_CLEARANCE;
import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_CLEARANCE_LEVEL;
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.LevelIdNotFound;
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
import org.alfresco.query.PagingRequest;
import org.alfresco.query.PagingResults;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.security.PersonService.PersonInfo;
import org.alfresco.util.Pair;
import org.alfresco.util.ParameterCheck;
/**
* @author Neil Mc Erlean
* @author David Webster
* @since 3.0.a
*/
public class SecurityClearanceServiceImpl extends ServiceBaseImpl implements SecurityClearanceService
{
/** The clearance levels currently configured in this server. */
private ClearanceLevelManager clearanceManager;
/** The object containing the {@link ClassificationLevel}s in the system. */
private ClassificationLevelManager classificationLevelManager;
private PersonService personService;
private ClassificationServiceBootstrap classificationServiceBootstrap;
private ClassificationLevelComparator classificationLevelComparator;
public void setClearanceManager(ClearanceLevelManager clearanceManager) { this.clearanceManager = clearanceManager; }
public void setClassificationLevelManager(ClassificationLevelManager classificationLevelManager) { this.classificationLevelManager = classificationLevelManager; }
public void setPersonService(PersonService service) { this.personService = service; }
public void setClassificationServiceBootstrap(ClassificationServiceBootstrap classificationServiceBootstrap) { this.classificationServiceBootstrap = classificationServiceBootstrap; }
public void setClassificationLevelComparator(ClassificationLevelComparator classificationLevelComparator) { this.classificationLevelComparator = classificationLevelComparator; }
/** Store the references to the classification and clearance level managers in this class. */
public void init()
{
this.classificationLevelManager = classificationServiceBootstrap.getClassificationLevelManager();
this.clearanceManager = classificationServiceBootstrap.getClearanceLevelManager();
classificationLevelComparator = new ClassificationLevelComparator(classificationLevelManager);
}
@Override
public SecurityClearance getUserSecurityClearance()
{
if (authenticationUtil.isRunAsUserTheSystemUser())
{
return new SecurityClearance(null, clearanceManager.getMostSecureLevel());
}
final String currentUser = authenticationUtil.getRunAsUser();
ParameterCheck.mandatoryString("currentUser", currentUser);
return getUserSecurityClearance(currentUser);
}
/**
* Gets the user's security clearance.
*
* @param userName user name
* @return {@link SecurityClearance} provides information about the user and their clearance level
*/
private SecurityClearance getUserSecurityClearance(final String userName)
{
final NodeRef personNode = personService.getPerson(userName, false);
final PersonInfo personInfo = personService.getPerson(personNode);
ClearanceLevel clearanceLevel = ClearanceLevelManager.NO_CLEARANCE;
if (nodeService.hasAspect(personNode, ASPECT_SECURITY_CLEARANCE))
{
final String clearanceLevelId = (String)nodeService.getProperty(personNode, PROP_CLEARANCE_LEVEL);
clearanceLevel = (clearanceLevelId == null ? ClearanceLevelManager.NO_CLEARANCE
: clearanceManager.findLevelByClassificationLevelId(clearanceLevelId));
}
return new SecurityClearance(personInfo, clearanceLevel);
}
@Override
public PagingResults<SecurityClearance> getUsersSecurityClearance(UserQueryParams queryParams)
{
final PagingRequest pagingRequest = new PagingRequest(queryParams.getSkipCount(),
queryParams.getMaxItems());
// We want an accurate count of how many users there are in the system (in this query).
// Else paging in the UI won't work properly.
pagingRequest.setRequestTotalCountMax(Integer.MAX_VALUE);
final PagingResults<PersonInfo> p = personService.getPeople(queryParams.getSearchTerm(),
queryParams.getFilterProps(),
queryParams.getSortProps(),
pagingRequest);
return new PagingResults<SecurityClearance>()
{
@Override public List<SecurityClearance> getPage()
{
List<SecurityClearance> pcPage= new ArrayList<>(p.getPage().size());
for (PersonInfo pi : p.getPage())
{
pcPage.add(getUserSecurityClearance(pi.getUserName()));
}
return pcPage;
}
@Override public boolean hasMoreItems() { return p.hasMoreItems(); }
@Override public Pair<Integer, Integer> getTotalResultCount() { return p.getTotalResultCount(); }
@Override public String getQueryExecutionId() { return p.getQueryExecutionId(); }
};
}
@Override
public boolean isCurrentUserClearedForClassification(String classificationId)
{
// Get the current user's security clearance.
SecurityClearance securityClearance = getUserSecurityClearance();
ClassificationLevel suppliedLevel;
try
{
suppliedLevel = classificationLevelManager.findLevelById(classificationId);
}
catch(LevelIdNotFound e)
{
// Return false to make "Level not found" indistinguishable from "Not cleared".
return false;
}
ClassificationLevel usersHighestLevel = securityClearance.getClearanceLevel().getHighestClassificationLevel();
int comparison = classificationLevelComparator.compare(usersHighestLevel, suppliedLevel);
return (comparison >= 0);
}
@Override
public SecurityClearance setUserSecurityClearance(String userName, String clearanceId)
{
ParameterCheck.mandatoryString("userName", userName);
ParameterCheck.mandatoryString("clearanceId", clearanceId);
final NodeRef personNode = personService.getPerson(userName, false);
// Check the current user has clearance to see the specified level.
if (!isCurrentUserClearedForClassification(clearanceId))
{
throw new LevelIdNotFound(clearanceId);
}
nodeService.setProperty(personNode, PROP_CLEARANCE_LEVEL, clearanceId);
return getUserSecurityClearance(userName);
}
@Override
public List<ClearanceLevel> getClearanceLevels()
{
if (clearanceManager == null)
{
return Collections.emptyList();
}
// FIXME Currently assume user has highest security clearance, this should be fixed as part of RM-2112.
ClearanceLevel usersLevel = clearanceManager.getMostSecureLevel();
return restrictList(clearanceManager.getClearanceLevels(), usersLevel);
}
/**
* Create a list containing all clearance levels up to and including the supplied level.
*
* @param allLevels The list of all the clearance levels starting with the highest security.
* @param targetLevel The highest security clearance level that should be returned. If this is not found then
* an empty list will be returned.
* @return an immutable list of the levels that a user at the target level can see.
*/
private List<ClearanceLevel> restrictList(List<ClearanceLevel> allLevels, ClearanceLevel targetLevel)
{
int targetIndex = allLevels.indexOf(targetLevel);
if (targetIndex == -1) { return Collections.emptyList(); }
List<ClearanceLevel> subList = allLevels.subList(targetIndex, allLevels.size());
return Collections.unmodifiableList(subList);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService#hasCurrentUserClearance()
*/
@Override
public boolean hasCurrentUserClearance()
{
return hasUserClearance(authenticationUtil.getRunAsUser());
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService#hasUserClearance(java.lang.String)
*/
@Override
public boolean hasUserClearance(String userId)
{
checkNotBlank("userId", userId);
boolean hasUserClearance = false;
ClearanceLevel userCleranceLevel = getUserSecurityClearance(userId).getClearanceLevel();
if (userCleranceLevel != null && userCleranceLevel != NO_CLEARANCE)
{
hasUserClearance = true;
}
return hasUserClearance;
}
}
| dnacreative/records-management | rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceServiceImpl.java | Java | lgpl-3.0 | 10,710 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2384,
1011,
2325,
24493,
6072,
3597,
4007,
3132,
1012,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
24493,
6072,
3597,
1008,
1008,
24493,
6072,
3597,
2003,
2489,
30524,
2004,
2405,
2011,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 data-ng-controller="InvestmentsController" data-ng-init="findOne()">
<div class="page-header">
<a class="pull-right btn btn-primary" data-ng-click="remove();">
<i class="glyphicon glyphicon-trash"></i>
</a>
<h1>Edit Investment</h1>
</div>
<div class="col-md-12">
<form name='investments' class="form-horizontal" data-ng-submit="update()">
<fieldset>
<div class="form-group">
<label class="control-label" for="company">For Company</label>
<select class="form-control" data-ng-model="investment.for_company" data-ng-options="company as (company.name + ' - ' + company.from_fund) for company in companies">
<option value="">-- {{investment.for_company.name}} - {{investment.for_company.from_fund}} --</option>
</select>
</div>
<div class="form-group">
<label class="control-label" for="name">Date (MM/DD/YYYY)</label>
<div class="controls">
<input type="text" data-ng-model="investment.date" id="date" class="form-control" placeholder="Date" required>
</div>
</div>
<div class="form-group">
<label class="control-label" for="name">Amount</label>
<div class="controls">
<input type="text" data-ng-model="investment.amount" id="name" class="form-control" placeholder="Enter Amount" ng-pattern="/^\d+$/" required>
</div>
</div>
<div class="form-group">
<label class="control-label" for="type">Type</label>
<div class="controls">
<input type="text" data-ng-model="investment.type" id="type" class="form-control" placeholder="Enter type of Investment" required>
</div>
</div>
<div class="form-group">
<input type="submit" ng-disabled='investments.$invalid' value="Update" class="btn btn-default">
</div>
</fieldset>
</form>
</div>
</section> | jollyburnz/pw-meanjs | public/modules/investments/views/edit.html | HTML | mit | 2,250 | [
30522,
1026,
2930,
2951,
1011,
12835,
1011,
11486,
1027,
1000,
10518,
8663,
13181,
10820,
1000,
2951,
1011,
12835,
1011,
1999,
4183,
1027,
1000,
2424,
5643,
1006,
1007,
1000,
1028,
1026,
4487,
2615,
2465,
1027,
1000,
3931,
1011,
20346,
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... |
create schema if not exists toughradius collate utf8mb4_unicode_ci;
CREATE USER IF NOT EXISTS raduser@'172.%.%.%' identified by 'radpwd';
GRANT ALL PRIVILEGES ON toughradius.* TO raduser@'172.%.%.%';
ALTER USER 'raduser'@'172.%.%.%' IDENTIFIED WITH mysql_native_password BY 'radpwd';
use toughradius;
create table if not exists tr_bras
(
id bigint auto_increment primary key,
identifier varchar(128) null,
name varchar(64) not null,
ipaddr varchar(32) null,
vendor_id varchar(32) not null,
portal_vendor varchar(32) not null,
secret varchar(64) not null,
coa_port int not null,
ac_port int not null,
auth_limit int null,
acct_limit int null,
status enum('enabled', 'disabled') null,
remark varchar(512) null,
create_time datetime not null
);
create index ix_tr_bras_identifier on tr_bras (identifier);
create index ix_tr_bras_ipaddr on tr_bras (ipaddr);
create table if not exists tr_config
(
id bigint auto_increment primary key,
type varchar(32) not null,
name varchar(128) not null,
value varchar(255) null,
remark varchar(255) null
);
create table if not exists tr_subscribe
(
id bigint auto_increment primary key,
node_id bigint default 0 not null,
subscriber varchar(32) null,
realname varchar(32) null,
password varchar(128) not null,
domain varchar(128) null,
addr_pool varchar(128) null,
policy varchar(512) null,
is_online int null,
active_num int null,
bind_mac tinyint(1) null,
bind_vlan tinyint(1) null,
ip_addr varchar(32) null,
mac_addr varchar(32) null,
in_vlan int null,
out_vlan int null,
up_rate bigint null,
down_rate bigint null,
up_peak_rate bigint null,
down_peak_rate bigint null,
up_rate_code varchar(32) null,
down_rate_code varchar(32) null,
status enum('enabled', 'disabled') null,
remark varchar(512) null,
begin_time datetime not null,
expire_time datetime not null,
create_time datetime not null,
update_time datetime null
);
create index ix_tr_subscribe_create_time
on tr_subscribe (create_time);
create index ix_tr_subscribe_expire_time
on tr_subscribe (expire_time);
create index ix_tr_subscribe_status
on tr_subscribe (status);
create index ix_tr_subscribe_subscriber
on tr_subscribe (subscriber);
create index ix_tr_subscribe_update_time
on tr_subscribe (update_time);
use toughradius;
INSERT INTO toughradius.tr_bras
(identifier, name, ipaddr, vendor_id, portal_vendor,secret, coa_port,ac_port, auth_limit, acct_limit, STATUS, remark, create_time)
VALUES ('radius-tester', 'radius-tester', '127.0.0.1', '14988',"cmccv1", 'secret', 3799,2000, 1000, 1000, NULL, '0', '2019-03-01 14:07:46');
INSERT INTO toughradius.tr_subscribe
(node_id, subscriber, realname, password, domain, addr_pool, policy, is_online, active_num,
bind_mac, bind_vlan, ip_addr, mac_addr, in_vlan, out_vlan, up_rate, down_rate, up_peak_rate, down_peak_rate, up_rate_code,
down_rate_code, status, remark, begin_time, expire_time, create_time, update_time)
VALUES (0, 'test01', '', '888888', null, null, null, null, 10, 0, 0, '', '', 0, 0, 10.000, 10.000, 100.000, 100.000,
'10', '10', 'enabled', '', '2019-03-01 14:13:02', '2019-03-01 14:13:00', '2019-03-01 14:12:59', '2019-03-01 14:12:56'); | talkincode/ToughRADIUS | docker/toughradius.db.sql | SQL | lgpl-3.0 | 3,175 | [
30522,
3443,
8040,
28433,
2065,
2025,
6526,
7823,
12173,
4173,
8902,
13806,
21183,
2546,
2620,
14905,
2549,
1035,
27260,
1035,
25022,
1025,
3443,
5310,
2065,
2025,
6526,
10958,
17619,
2121,
1030,
1005,
18253,
1012,
1003,
1012,
1003,
1012,
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... |
var mongoose = require('mongoose'),
_ = require('underscore'),
roomTokenizer = function(msg) {
var tokens = [];
tokens = tokens.concat(msg.content.split(' '));
tokens.push(msg.author);
return tokens;
};
exports.init = function(db) {
var EntitySchemaDefinition,
EntitySchema,
EntityModel;
//create schema
EntitySchemaDefinition = {
content : { type: String, required: true },
author: {
email: String,
username: String,
avatar: String
},
room: { type: mongoose.Schema.ObjectId, required: true },
status: { type: Number, required: true },
date : { type: Date },
keywords: [String]
};
EntitySchema = new mongoose.Schema(EntitySchemaDefinition, {autoIndex: false} );
EntitySchema.index({keywords: 1});
//during save update all keywords
EntitySchema.pre('save', function(next) {
//set dates
if ( !this.date ) {
this.date = new Date();
}
//clearing keywords
this.keywords.length = 0;
//adding keywords
this.keywords = this.keywords.concat(roomTokenizer(this));
next();
});
EntityModel = db.model('Message', EntitySchema);
return EntityModel;
}; | vitoss/Corpo-Chat | service/lib/model/Message.js | JavaScript | mit | 1,286 | [
30522,
13075,
12256,
3995,
9232,
1027,
5478,
1006,
1005,
12256,
3995,
9232,
1005,
1007,
1010,
1035,
1027,
5478,
1006,
1005,
2104,
9363,
2890,
1005,
1007,
1010,
2282,
18715,
18595,
6290,
1027,
3853,
1006,
5796,
2290,
1007,
1063,
13075,
19204... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/*
comment
*/
var g = 1, i = 2, j = 2/*
*//1+g+"\/*"/i, x = 3,
a = 2/1/g, b = (i)/i/i/*
*/, s = 'aaa\
bbb\
ccc'; var z = 1; | polygonplanet/Chiffon | tests/fixtures/tokenize/loc/test-0002.js | JavaScript | mit | 127 | [
30522,
1013,
1008,
7615,
1008,
1013,
13075,
1043,
1027,
1015,
1010,
1045,
1027,
1016,
1010,
1046,
1027,
1016,
1013,
1008,
1008,
1013,
1013,
1015,
1009,
1043,
1009,
1000,
1032,
1013,
1008,
1000,
1013,
1045,
1010,
1060,
1027,
1017,
1010,
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... |
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content="(C) Copyright 2010" />
<meta name="DC.rights.owner" content="(C) Copyright 2010" />
<meta name="DC.Type" content="concept" />
<meta name="DC.Title" content="Defensive Programming" />
<meta name="DC.Relation" scheme="URI" content="GUID-35D7EEFC-B2E4-5444-8875-2A24790E08C2.html" />
<meta name="DC.Relation" scheme="URI" content="index.html" />
<meta name="DC.Relation" scheme="URI" content="GUID-35D7EEFC-B2E4-5444-8875-2A24790E08C2.html" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285" />
<meta name="DC.Language" content="en" />
<link rel="stylesheet" type="text/css" href="commonltr.css" />
<title>
Defensive Programming
</title>
<link type="text/css" rel="stylesheet" href="css/common.css" media="screen"/>
<link type="text/css" rel="stylesheet" href="css/sdl.css" media="screen"/>
<!--[if IE]>
<link href="css/iefix.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<link rel="stylesheet" type="text/css" href="nokiacxxref.css" />
</head>
<body id="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285">
<a name="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285">
<!-- -->
</a>
<?php include_once (CURRENT_SKIN_PATH.'/sdl_header.html'); ?>
<div id="sdl_container">
<div id="leftMenu">
<div id="expandcontractdiv">
<a id="collapseTree" href="javascript:tree.collapseAll()">
Collapse all
</a>
<a id="index" href="index.html">
Symbian^3 Application Developer Library
</a>
</div>
<iframe style="border:none" height="800" width="300" src="index-toc.html"></iframe>
<div id="treeDiv1">
 
</div>
<script type="text/javascript">
var currentIconMode = 0; window.name="id1197760 ";
YAHOO.util.Event.onDOMReady(buildTree, this,true);
</script>
</div>
<div id="sdl_content">
<div class="breadcrumb">
<a href="index.html" title="Symbian^3 Application Developer Library">
Symbian^3 Application Developer Library
</a>
>
<a href="GUID-35D7EEFC-B2E4-5444-8875-2A24790E08C2.html">
Essential Idioms
</a>
>
</div>
<h1 class="topictitle1">
Defensive Programming
</h1>
<div>
<p>
To help Symbian developers identify potential problems early in development, macros are provided to test for error conditions in functions (asserts) and objects (class invariants). Casting is one well known source of hard-to-find errors.
<a href="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285.html#GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-A0253DF3-098C-5427-9B45-3CEC4F4875AB">
Casting
</a>
discusses its use.
</p>
<div class="section" id="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-55EB9D07-65F1-572B-8F36-9A442F69B9C2">
<a name="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-55EB9D07-65F1-572B-8F36-9A442F69B9C2">
<!-- -->
</a>
<h2 class="sectiontitle">
Testing conditions with asserts and invariants
</h2>
<p>
One method of catching errors early is to identify conditions that should be true at the beginning and end of functions, and raise errors if they are not.
</p>
<p>
Two mechanisms support this programming style.
</p>
<ul>
<li id="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-620C4F53-5465-5A53-9880-7DC27EF752FF">
<a name="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-620C4F53-5465-5A53-9880-7DC27EF752FF">
<!-- -->
</a>
<p>
asserts
</p>
</li>
<li id="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-9A1881EA-4C72-5359-9D16-553806070556">
<a name="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-9A1881EA-4C72-5359-9D16-553806070556">
<!-- -->
</a>
<p>
class invariants
</p>
</li>
</ul>
<p>
<strong>
Asserts
</strong>
</p>
<p>
Two macros are supplied for asserting specific conditions in functions:
</p>
<ul>
<li id="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-9481684E-5E9D-54B1-87E0-3539F4A29157">
<a name="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-9481684E-5E9D-54B1-87E0-3539F4A29157">
<!-- -->
</a>
<p>
<samp class="codeph">
__ASSERT_ALWAYS
</samp>
to catch run-time invalid input, for both release and debug builds
</p>
</li>
<li id="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-4BAF939D-03D4-5D1E-A1BD-79537D930E93">
<a name="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-4BAF939D-03D4-5D1E-A1BD-79537D930E93">
<!-- -->
</a>
<p>
<samp class="codeph">
__ASSERT_DEBUG
</samp>
to catch programming errors, for debug builds only
</p>
</li>
</ul>
<p>
<strong>
Class Invariants
</strong>
</p>
<p>
Class invariants are used to test that an object is in a valid state. They are used only in debug builds.
</p>
<ul>
<li id="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-F79328BA-61FD-5CB6-9D09-4C4DF6A2459B">
<a name="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-F79328BA-61FD-5CB6-9D09-4C4DF6A2459B">
<!-- -->
</a>
<p>
Define class invariants for non-trivial classes using
<samp class="codeph">
__DECLARE_TEST
</samp>
. The class must supply functions that specify its allowed stable states.
</p>
</li>
<li id="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-541758DE-21E9-5599-A12B-0208867240CA">
<a name="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-541758DE-21E9-5599-A12B-0208867240CA">
<!-- -->
</a>
<p>
To ensures that the object is in a stable state prior to executing the function, call the invariant at the start of all public functions using
<samp class="codeph">
__TEST_INVARIANT
</samp>
.
</p>
</li>
<li id="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-20FFC383-0371-5494-8887-D0B3888162EE">
<a name="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-20FFC383-0371-5494-8887-D0B3888162EE">
<!-- -->
</a>
<p>
For non-const functions, you can ensure that the object has been left in a stable state by also calling the invariant at the end of the function.
</p>
</li>
</ul>
</div>
<div class="section" id="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-A0253DF3-098C-5427-9B45-3CEC4F4875AB">
<a name="GUID-D5FD665E-333B-50FF-A46F-6B22C0877285__GUID-A0253DF3-098C-5427-9B45-3CEC4F4875AB">
<!-- -->
</a>
<h2 class="sectiontitle">
Casting
</h2>
<p>
Casts, as in other operating systems, should be used with caution. If a cast seems to be needed, check that this does not reflect a design weakness.
</p>
<p>
The C++
<samp class="codeph">
dynamic_cast
</samp>
operator should not be used because the Symbian platform does not use C++ exceptions in user code.
</p>
<p>
Note that in early versions of the OS (pre v6.0), the GCC compiler did not support the C++ casting operators. The idiom was then to use instead one of the macros
<samp class="codeph">
REINTERPRET_CAST
</samp>
,
<samp class="codeph">
STATIC_CAST
</samp>
,
<samp class="codeph">
CONST_CAST
</samp>
, and
<samp class="codeph">
MUTABLE_CAST
</samp>
, which were defined as simple C style casts for that compiler.
</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink">
<strong>
Parent topic:
</strong>
<a href="GUID-35D7EEFC-B2E4-5444-8875-2A24790E08C2.html">
Essential Idioms
</a>
</div>
</div>
</div>
<p class="copyright">Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).<br /> All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the <a href=" http://www.eclipse.org/legal/epl-v10.html"> Eclipse Public License
v1.0</a>.</p>
</div>
</div>
<?php include_once (CURRENT_SKIN_PATH.'/sdl_footer.html'); ?>
</body>
</html> | warlordh/fork_Symbian | sdk/GUID-D5FD665E-333B-50FF-A46F-6B22C0877285.html | HTML | epl-1.0 | 8,847 | [
30522,
1026,
1029,
20950,
2544,
1027,
1005,
1015,
1012,
1014,
1005,
17181,
1027,
1005,
21183,
2546,
1011,
1022,
1005,
1029,
1028,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 ./ace/ace
//= require ./ace/mode-ruby
//= require ./ace/theme-tomorrow
//= require ./ace/ext-whitespace
$(function() {
var editor = ace.edit("editor");
editor.setTheme("ace/theme/tomorrow");
editor.getSession().setMode("ace/mode/ruby");
editor.getSession().setTabSize(2);
editor.getSession().setUseSoftTabs(true);
$("form").submit(function() {
$("#content").val(editor.getValue());
});
});
| cctiger36/batch_manager | app/assets/javascripts/batch_manager/editor.js | JavaScript | mit | 422 | [
30522,
1013,
1013,
1027,
5478,
1012,
1013,
9078,
1013,
9078,
1013,
1013,
1027,
5478,
1012,
1013,
9078,
1013,
5549,
1011,
10090,
1013,
1013,
1027,
5478,
1012,
1013,
9078,
1013,
4323,
1011,
4826,
1013,
1013,
1027,
5478,
1012,
1013,
9078,
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 Entitas;
public class SomeStartSystem : IStartSystem {
public void Start() {
}
}
| michax/Entitas-CSharp | Entitas.Unity.VisualDebugging/Assets/Tests/Systems/SomeStartSystem.cs | C# | mit | 100 | [
30522,
2478,
4372,
3775,
10230,
1025,
2270,
2465,
2070,
14117,
3215,
27268,
6633,
1024,
21541,
20591,
27268,
6633,
1063,
2270,
11675,
2707,
1006,
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,
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... |
/*!
* Font Awesome 4.5.0 by @davegandy - http://fontawesome.io - @fontawesome
* License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)
*/
/* FONT PATH
* -------------------------- */
@font-face {
font-family: 'FontAwesome';
src: url('../fonts/fontawesome-webfont.eot?v=4.5.0');
src: url('../fonts/fontawesome-webfont.eot?#iefix&v=4.5.0') format('embedded-opentype'), url('../fonts/fontawesome-webfont.woff2?v=4.5.0') format('woff2'), url('../fonts/fontawesome-webfont.woff?v=4.5.0') format('woff'), url('../fonts/fontawesome-webfont.ttf?v=4.5.0') format('truetype'), url('../fonts/fontawesome-webfont.svg?v=4.5.0#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}
.fa {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* makes the font 33% larger relative to the icon container */
.fa-lg {
font-size: 1.33333333em;
line-height: 0.75em;
vertical-align: -15%;
}
.fa-2x {
font-size: 2em;
}
.fa-3x {
font-size: 3em;
}
.fa-4x {
font-size: 4em;
}
.fa-5x {
font-size: 5em;
}
.fa-fw {
width: 1.28571429em;
text-align: center;
}
.fa-ul {
padding-left: 0;
margin-left: 2.14285714em;
list-style-type: none;
}
.fa-ul > li {
position: relative;
}
.fa-li {
position: absolute;
left: -2.14285714em;
width: 2.14285714em;
top: 0.14285714em;
text-align: center;
}
.fa-li.fa-lg {
left: -1.85714286em;
}
.fa-border {
padding: .2em .25em .15em;
border: solid 0.08em #eeeeee;
border-radius: .1em;
}
.fa-pull-left {
float: left;
}
.fa-pull-right {
float: right;
}
.fa.fa-pull-left {
margin-right: .3em;
}
.fa.fa-pull-right {
margin-left: .3em;
}
/* Deprecated as of 4.4.0 */
.pull-right {
float: right;
}
.pull-left {
float: left;
}
.fa.pull-left {
margin-right: .3em;
}
.fa.pull-right {
margin-left: .3em;
}
.fa-spin {
-webkit-animation: fa-spin 2s infinite linear;
animation: fa-spin 2s infinite linear;
}
.fa-pulse {
-webkit-animation: fa-spin 1s infinite steps(8);
animation: fa-spin 1s infinite steps(8);
}
@-webkit-keyframes fa-spin {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
@keyframes fa-spin {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
.fa-rotate-90 {
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);
-webkit-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
}
.fa-rotate-180 {
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2);
-webkit-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
}
.fa-rotate-270 {
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
-webkit-transform: rotate(270deg);
-ms-transform: rotate(270deg);
transform: rotate(270deg);
}
.fa-flip-horizontal {
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);
-webkit-transform: scale(-1, 1);
-ms-transform: scale(-1, 1);
transform: scale(-1, 1);
}
.fa-flip-vertical {
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1);
-webkit-transform: scale(1, -1);
-ms-transform: scale(1, -1);
transform: scale(1, -1);
}
:root .fa-rotate-90,
:root .fa-rotate-180,
:root .fa-rotate-270,
:root .fa-flip-horizontal,
:root .fa-flip-vertical {
filter: none;
}
.fa-stack {
position: relative;
display: inline-block;
width: 2em;
height: 2em;
line-height: 2em;
vertical-align: middle;
}
.fa-stack-1x,
.fa-stack-2x {
position: absolute;
left: 0;
width: 100%;
text-align: center;
}
.fa-stack-1x {
line-height: inherit;
}
.fa-stack-2x {
font-size: 2em;
}
.fa-inverse {
color: #ffffff;
}
/* Font Awesome uses the Unicode Private Use Area (PUA) to ensure screen
readers do not read off random characters that represent icons */
.fa-glass:before {
content: "\f000";
}
.fa-music:before {
content: "\f001";
}
.fa-search:before {
content: "\f002";
}
.fa-envelope-o:before {
content: "\f003";
}
.fa-heart:before {
content: "\f004";
}
.fa-star:before {
content: "\f005";
}
.fa-star-o:before {
content: "\f006";
}
.fa-user:before {
content: "\f007";
}
.fa-film:before {
content: "\f008";
}
.fa-th-large:before {
content: "\f009";
}
.fa-th:before {
content: "\f00a";
}
.fa-th-list:before {
content: "\f00b";
}
.fa-check:before {
content: "\f00c";
}
.fa-remove:before,
.fa-close:before,
.fa-times:before {
content: "\f00d";
}
.fa-search-plus:before {
content: "\f00e";
}
.fa-search-minus:before {
content: "\f010";
}
.fa-power-off:before {
content: "\f011";
}
.fa-signal:before {
content: "\f012";
}
.fa-gear:before,
.fa-cog:before {
content: "\f013";
}
.fa-trash-o:before {
content: "\f014";
}
.fa-home:before {
content: "\f015";
}
.fa-file-o:before {
content: "\f016";
}
.fa-clock-o:before {
content: "\f017";
}
.fa-road:before {
content: "\f018";
}
.fa-download:before {
content: "\f019";
}
.fa-arrow-circle-o-down:before {
content: "\f01a";
}
.fa-arrow-circle-o-up:before {
content: "\f01b";
}
.fa-inbox:before {
content: "\f01c";
}
.fa-play-circle-o:before {
content: "\f01d";
}
.fa-rotate-right:before,
.fa-repeat:before {
content: "\f01e";
}
.fa-refresh:before {
content: "\f021";
}
.fa-list-alt:before {
content: "\f022";
}
.fa-lock:before {
content: "\f023";
}
.fa-flag:before {
content: "\f024";
}
.fa-headphones:before {
content: "\f025";
}
.fa-volume-off:before {
content: "\f026";
}
.fa-volume-down:before {
content: "\f027";
}
.fa-volume-up:before {
content: "\f028";
}
.fa-qrcode:before {
content: "\f029";
}
.fa-barcode:before {
content: "\f02a";
}
.fa-tag:before {
content: "\f02b";
}
.fa-tags:before {
content: "\f02c";
}
.fa-book:before {
content: "\f02d";
}
.fa-bookmark:before {
content: "\f02e";
}
.fa-print:before {
content: "\f02f";
}
.fa-camera:before {
content: "\f030";
}
.fa-font:before {
content: "\f031";
}
.fa-bold:before {
content: "\f032";
}
.fa-italic:before {
content: "\f033";
}
.fa-text-height:before {
content: "\f034";
}
.fa-text-width:before {
content: "\f035";
}
.fa-align-left:before {
content: "\f036";
}
.fa-align-center:before {
content: "\f037";
}
.fa-align-right:before {
content: "\f038";
}
.fa-align-justify:before {
content: "\f039";
}
.fa-list:before {
content: "\f03a";
}
.fa-dedent:before,
.fa-outdent:before {
content: "\f03b";
}
.fa-indent:before {
content: "\f03c";
}
.fa-video-camera:before {
content: "\f03d";
}
.fa-photo:before,
.fa-image:before,
.fa-picture-o:before {
content: "\f03e";
}
.fa-pencil:before {
content: "\f040";
}
.fa-map-marker:before {
content: "\f041";
}
.fa-adjust:before {
content: "\f042";
}
.fa-tint:before {
content: "\f043";
}
.fa-edit:before,
.fa-pencil-square-o:before {
content: "\f044";
}
.fa-share-square-o:before {
content: "\f045";
}
.fa-check-square-o:before {
content: "\f046";
}
.fa-arrows:before {
content: "\f047";
}
.fa-step-backward:before {
content: "\f048";
}
.fa-fast-backward:before {
content: "\f049";
}
.fa-backward:before {
content: "\f04a";
}
.fa-play:before {
content: "\f04b";
}
.fa-pause:before {
content: "\f04c";
}
.fa-stop:before {
content: "\f04d";
}
.fa-forward:before {
content: "\f04e";
}
.fa-fast-forward:before {
content: "\f050";
}
.fa-step-forward:before {
content: "\f051";
}
.fa-eject:before {
content: "\f052";
}
.fa-chevron-left:before {
content: "\f053";
}
.fa-chevron-right:before {
content: "\f054";
}
.fa-plus-circle:before {
content: "\f055";
}
.fa-minus-circle:before {
content: "\f056";
}
.fa-times-circle:before {
content: "\f057";
}
.fa-check-circle:before {
content: "\f058";
}
.fa-question-circle:before {
content: "\f059";
}
.fa-info-circle:before {
content: "\f05a";
}
.fa-crosshairs:before {
content: "\f05b";
}
.fa-times-circle-o:before {
content: "\f05c";
}
.fa-check-circle-o:before {
content: "\f05d";
}
.fa-ban:before {
content: "\f05e";
}
.fa-arrow-left:before {
content: "\f060";
}
.fa-arrow-right:before {
content: "\f061";
}
.fa-arrow-up:before {
content: "\f062";
}
.fa-arrow-down:before {
content: "\f063";
}
.fa-mail-forward:before,
.fa-share:before {
content: "\f064";
}
.fa-expand:before {
content: "\f065";
}
.fa-compress:before {
content: "\f066";
}
.fa-plus:before {
content: "\f067";
}
.fa-minus:before {
content: "\f068";
}
.fa-asterisk:before {
content: "\f069";
}
.fa-exclamation-circle:before {
content: "\f06a";
}
.fa-gift:before {
content: "\f06b";
}
.fa-leaf:before {
content: "\f06c";
}
.fa-fire:before {
content: "\f06d";
}
.fa-eye:before {
content: "\f06e";
}
.fa-eye-slash:before {
content: "\f070";
}
.fa-warning:before,
.fa-exclamation-triangle:before {
content: "\f071";
}
.fa-plane:before {
content: "\f072";
}
.fa-calendar:before {
content: "\f073";
}
.fa-random:before {
content: "\f074";
}
.fa-comment:before {
content: "\f075";
}
.fa-magnet:before {
content: "\f076";
}
.fa-chevron-up:before {
content: "\f077";
}
.fa-chevron-down:before {
content: "\f078";
}
.fa-retweet:before {
content: "\f079";
}
.fa-shopping-cart:before {
content: "\f07a";
}
.fa-folder:before {
content: "\f07b";
}
.fa-folder-open:before {
content: "\f07c";
}
.fa-arrows-v:before {
content: "\f07d";
}
.fa-arrows-h:before {
content: "\f07e";
}
.fa-bar-chart-o:before,
.fa-bar-chart:before {
content: "\f080";
}
.fa-twitter-square:before {
content: "\f081";
}
.fa-facebook-square:before {
content: "\f082";
}
.fa-camera-retro:before {
content: "\f083";
}
.fa-key:before {
content: "\f084";
}
.fa-gears:before,
.fa-cogs:before {
content: "\f085";
}
.fa-comments:before {
content: "\f086";
}
.fa-thumbs-o-up:before {
content: "\f087";
}
.fa-thumbs-o-down:before {
content: "\f088";
}
.fa-star-half:before {
content: "\f089";
}
.fa-heart-o:before {
content: "\f08a";
}
.fa-sign-out:before {
content: "\f08b";
}
.fa-linkedin-square:before {
content: "\f08c";
}
.fa-thumb-tack:before {
content: "\f08d";
}
.fa-external-link:before {
content: "\f08e";
}
.fa-sign-in:before {
content: "\f090";
}
.fa-trophy:before {
content: "\f091";
}
.fa-github-square:before {
content: "\f092";
}
.fa-upload:before {
content: "\f093";
}
.fa-lemon-o:before {
content: "\f094";
}
.fa-phone:before {
content: "\f095";
}
.fa-square-o:before {
content: "\f096";
}
.fa-bookmark-o:before {
content: "\f097";
}
.fa-phone-square:before {
content: "\f098";
}
.fa-twitter:before {
content: "\f099";
}
.fa-facebook-f:before,
.fa-facebook:before {
content: "\f09a";
}
.fa-github:before {
content: "\f09b";
}
.fa-unlock:before {
content: "\f09c";
}
.fa-credit-card:before {
content: "\f09d";
}
.fa-feed:before,
.fa-rss:before {
content: "\f09e";
}
.fa-hdd-o:before {
content: "\f0a0";
}
.fa-bullhorn:before {
content: "\f0a1";
}
.fa-bell:before {
content: "\f0f3";
}
.fa-certificate:before {
content: "\f0a3";
}
.fa-hand-o-right:before {
content: "\f0a4";
}
.fa-hand-o-left:before {
content: "\f0a5";
}
.fa-hand-o-up:before {
content: "\f0a6";
}
.fa-hand-o-down:before {
content: "\f0a7";
}
.fa-arrow-circle-left:before {
content: "\f0a8";
}
.fa-arrow-circle-right:before {
content: "\f0a9";
}
.fa-arrow-circle-up:before {
content: "\f0aa";
}
.fa-arrow-circle-down:before {
content: "\f0ab";
}
.fa-globe:before {
content: "\f0ac";
}
.fa-wrench:before {
content: "\f0ad";
}
.fa-tasks:before {
content: "\f0ae";
}
.fa-filter:before {
content: "\f0b0";
}
.fa-briefcase:before {
content: "\f0b1";
}
.fa-arrows-alt:before {
content: "\f0b2";
}
.fa-group:before,
.fa-users:before {
content: "\f0c0";
}
.fa-chain:before,
.fa-link:before {
content: "\f0c1";
}
.fa-cloud:before {
content: "\f0c2";
}
.fa-flask:before {
content: "\f0c3";
}
.fa-cut:before,
.fa-scissors:before {
content: "\f0c4";
}
.fa-copy:before,
.fa-files-o:before {
content: "\f0c5";
}
.fa-paperclip:before {
content: "\f0c6";
}
.fa-save:before,
.fa-floppy-o:before {
content: "\f0c7";
}
.fa-square:before {
content: "\f0c8";
}
.fa-navicon:before,
.fa-reorder:before,
.fa-bars:before {
content: "\f0c9";
}
.fa-list-ul:before {
content: "\f0ca";
}
.fa-list-ol:before {
content: "\f0cb";
}
.fa-strikethrough:before {
content: "\f0cc";
}
.fa-underline:before {
content: "\f0cd";
}
.fa-table:before {
content: "\f0ce";
}
.fa-magic:before {
content: "\f0d0";
}
.fa-truck:before {
content: "\f0d1";
}
.fa-pinterest:before {
content: "\f0d2";
}
.fa-pinterest-square:before {
content: "\f0d3";
}
.fa-google-plus-square:before {
content: "\f0d4";
}
.fa-google-plus:before {
content: "\f0d5";
}
.fa-money:before {
content: "\f0d6";
}
.fa-caret-down:before {
content: "\f0d7";
}
.fa-caret-up:before {
content: "\f0d8";
}
.fa-caret-left:before {
content: "\f0d9";
}
.fa-caret-right:before {
content: "\f0da";
}
.fa-columns:before {
content: "\f0db";
}
.fa-unsorted:before,
.fa-sort:before {
content: "\f0dc";
}
.fa-sort-down:before,
.fa-sort-desc:before {
content: "\f0dd";
}
.fa-sort-up:before,
.fa-sort-asc:before {
content: "\f0de";
}
.fa-envelope:before {
content: "\f0e0";
}
.fa-linkedin:before {
content: "\f0e1";
}
.fa-rotate-left:before,
.fa-undo:before {
content: "\f0e2";
}
.fa-legal:before,
.fa-gavel:before {
content: "\f0e3";
}
.fa-dashboard:before,
.fa-tachometer:before {
content: "\f0e4";
}
.fa-comment-o:before {
content: "\f0e5";
}
.fa-comments-o:before {
content: "\f0e6";
}
.fa-flash:before,
.fa-bolt:before {
content: "\f0e7";
}
.fa-sitemap:before {
content: "\f0e8";
}
.fa-umbrella:before {
content: "\f0e9";
}
.fa-paste:before,
.fa-clipboard:before {
content: "\f0ea";
}
.fa-lightbulb-o:before {
content: "\f0eb";
}
.fa-exchange:before {
content: "\f0ec";
}
.fa-cloud-download:before {
content: "\f0ed";
}
.fa-cloud-upload:before {
content: "\f0ee";
}
.fa-user-md:before {
content: "\f0f0";
}
.fa-stethoscope:before {
content: "\f0f1";
}
.fa-suitcase:before {
content: "\f0f2";
}
.fa-bell-o:before {
content: "\f0a2";
}
.fa-coffee:before {
content: "\f0f4";
}
.fa-cutlery:before {
content: "\f0f5";
}
.fa-file-text-o:before {
content: "\f0f6";
}
.fa-building-o:before {
content: "\f0f7";
}
.fa-hospital-o:before {
content: "\f0f8";
}
.fa-ambulance:before {
content: "\f0f9";
}
.fa-medkit:before {
content: "\f0fa";
}
.fa-fighter-jet:before {
content: "\f0fb";
}
.fa-beer:before {
content: "\f0fc";
}
.fa-h-square:before {
content: "\f0fd";
}
.fa-plus-square:before {
content: "\f0fe";
}
.fa-angle-double-left:before {
content: "\f100";
}
.fa-angle-double-right:before {
content: "\f101";
}
.fa-angle-double-up:before {
content: "\f102";
}
.fa-angle-double-down:before {
content: "\f103";
}
.fa-angle-left:before {
content: "\f104";
}
.fa-angle-right:before {
content: "\f105";
}
.fa-angle-up:before {
content: "\f106";
}
.fa-angle-down:before {
content: "\f107";
}
.fa-desktop:before {
content: "\f108";
}
.fa-laptop:before {
content: "\f109";
}
.fa-tablet:before {
content: "\f10a";
}
.fa-mobile-phone:before,
.fa-mobile:before {
content: "\f10b";
}
.fa-circle-o:before {
content: "\f10c";
}
.fa-quote-left:before {
content: "\f10d";
}
.fa-quote-right:before {
content: "\f10e";
}
.fa-spinner:before {
content: "\f110";
}
.fa-circle:before {
content: "\f111";
}
.fa-mail-reply:before,
.fa-reply:before {
content: "\f112";
}
.fa-github-alt:before {
content: "\f113";
}
.fa-folder-o:before {
content: "\f114";
}
.fa-folder-open-o:before {
content: "\f115";
}
.fa-smile-o:before {
content: "\f118";
}
.fa-frown-o:before {
content: "\f119";
}
.fa-meh-o:before {
content: "\f11a";
}
.fa-gamepad:before {
content: "\f11b";
}
.fa-keyboard-o:before {
content: "\f11c";
}
.fa-flag-o:before {
content: "\f11d";
}
.fa-flag-checkered:before {
content: "\f11e";
}
.fa-terminal:before {
content: "\f120";
}
.fa-code:before {
content: "\f121";
}
.fa-mail-reply-all:before,
.fa-reply-all:before {
content: "\f122";
}
.fa-star-half-empty:before,
.fa-star-half-full:before,
.fa-star-half-o:before {
content: "\f123";
}
.fa-location-arrow:before {
content: "\f124";
}
.fa-crop:before {
content: "\f125";
}
.fa-code-fork:before {
content: "\f126";
}
.fa-unlink:before,
.fa-chain-broken:before {
content: "\f127";
}
.fa-question:before {
content: "\f128";
}
.fa-info:before {
content: "\f129";
}
.fa-exclamation:before {
content: "\f12a";
}
.fa-superscript:before {
content: "\f12b";
}
.fa-subscript:before {
content: "\f12c";
}
.fa-eraser:before {
content: "\f12d";
}
.fa-puzzle-piece:before {
content: "\f12e";
}
.fa-microphone:before {
content: "\f130";
}
.fa-microphone-slash:before {
content: "\f131";
}
.fa-shield:before {
content: "\f132";
}
.fa-calendar-o:before {
content: "\f133";
}
.fa-fire-extinguisher:before {
content: "\f134";
}
.fa-rocket:before {
content: "\f135";
}
.fa-maxcdn:before {
content: "\f136";
}
.fa-chevron-circle-left:before {
content: "\f137";
}
.fa-chevron-circle-right:before {
content: "\f138";
}
.fa-chevron-circle-up:before {
content: "\f139";
}
.fa-chevron-circle-down:before {
content: "\f13a";
}
.fa-html5:before {
content: "\f13b";
}
.fa-css3:before {
content: "\f13c";
}
.fa-anchor:before {
content: "\f13d";
}
.fa-unlock-alt:before {
content: "\f13e";
}
.fa-bullseye:before {
content: "\f140";
}
.fa-ellipsis-h:before {
content: "\f141";
}
.fa-ellipsis-v:before {
content: "\f142";
}
.fa-rss-square:before {
content: "\f143";
}
.fa-play-circle:before {
content: "\f144";
}
.fa-ticket:before {
content: "\f145";
}
.fa-minus-square:before {
content: "\f146";
}
.fa-minus-square-o:before {
content: "\f147";
}
.fa-level-up:before {
content: "\f148";
}
.fa-level-down:before {
content: "\f149";
}
.fa-check-square:before {
content: "\f14a";
}
.fa-pencil-square:before {
content: "\f14b";
}
.fa-external-link-square:before {
content: "\f14c";
}
.fa-share-square:before {
content: "\f14d";
}
.fa-compass:before {
content: "\f14e";
}
.fa-toggle-down:before,
.fa-caret-square-o-down:before {
content: "\f150";
}
.fa-toggle-up:before,
.fa-caret-square-o-up:before {
content: "\f151";
}
.fa-toggle-right:before,
.fa-caret-square-o-right:before {
content: "\f152";
}
.fa-euro:before,
.fa-eur:before {
content: "\f153";
}
.fa-gbp:before {
content: "\f154";
}
.fa-dollar:before,
.fa-usd:before {
content: "\f155";
}
.fa-rupee:before,
.fa-inr:before {
content: "\f156";
}
.fa-cny:before,
.fa-rmb:before,
.fa-yen:before,
.fa-jpy:before {
content: "\f157";
}
.fa-ruble:before,
.fa-rouble:before,
.fa-rub:before {
content: "\f158";
}
.fa-won:before,
.fa-krw:before {
content: "\f159";
}
.fa-bitcoin:before,
.fa-btc:before {
content: "\f15a";
}
.fa-file:before {
content: "\f15b";
}
.fa-file-text:before {
content: "\f15c";
}
.fa-sort-alpha-asc:before {
content: "\f15d";
}
.fa-sort-alpha-desc:before {
content: "\f15e";
}
.fa-sort-amount-asc:before {
content: "\f160";
}
.fa-sort-amount-desc:before {
content: "\f161";
}
.fa-sort-numeric-asc:before {
content: "\f162";
}
.fa-sort-numeric-desc:before {
content: "\f163";
}
.fa-thumbs-up:before {
content: "\f164";
}
.fa-thumbs-down:before {
content: "\f165";
}
.fa-youtube-square:before {
content: "\f166";
}
.fa-youtube:before {
content: "\f167";
}
.fa-xing:before {
content: "\f168";
}
.fa-xing-square:before {
content: "\f169";
}
.fa-youtube-play:before {
content: "\f16a";
}
.fa-dropbox:before {
content: "\f16b";
}
.fa-stack-overflow:before {
content: "\f16c";
}
.fa-instagram:before {
content: "\f16d";
}
.fa-flickr:before {
content: "\f16e";
}
.fa-adn:before {
content: "\f170";
}
.fa-bitbucket:before {
content: "\f171";
}
.fa-bitbucket-square:before {
content: "\f172";
}
.fa-tumblr:before {
content: "\f173";
}
.fa-tumblr-square:before {
content: "\f174";
}
.fa-long-arrow-down:before {
content: "\f175";
}
.fa-long-arrow-up:before {
content: "\f176";
}
.fa-long-arrow-left:before {
content: "\f177";
}
.fa-long-arrow-right:before {
content: "\f178";
}
.fa-apple:before {
content: "\f179";
}
.fa-windows:before {
content: "\f17a";
}
.fa-android:before {
content: "\f17b";
}
.fa-linux:before {
content: "\f17c";
}
.fa-dribbble:before {
content: "\f17d";
}
.fa-skype:before {
content: "\f17e";
}
.fa-foursquare:before {
content: "\f180";
}
.fa-trello:before {
content: "\f181";
}
.fa-female:before {
content: "\f182";
}
.fa-male:before {
content: "\f183";
}
.fa-gittip:before,
.fa-gratipay:before {
content: "\f184";
}
.fa-sun-o:before {
content: "\f185";
}
.fa-moon-o:before {
content: "\f186";
}
.fa-archive:before {
content: "\f187";
}
.fa-bug:before {
content: "\f188";
}
.fa-vk:before {
content: "\f189";
}
.fa-weibo:before {
content: "\f18a";
}
.fa-renren:before {
content: "\f18b";
}
.fa-pagelines:before {
content: "\f18c";
}
.fa-stack-exchange:before {
content: "\f18d";
}
.fa-arrow-circle-o-right:before {
content: "\f18e";
}
.fa-arrow-circle-o-left:before {
content: "\f190";
}
.fa-toggle-left:before,
.fa-caret-square-o-left:before {
content: "\f191";
}
.fa-dot-circle-o:before {
content: "\f192";
}
.fa-wheelchair:before {
content: "\f193";
}
.fa-vimeo-square:before {
content: "\f194";
}
.fa-turkish-lira:before,
.fa-try:before {
content: "\f195";
}
.fa-plus-square-o:before {
content: "\f196";
}
.fa-space-shuttle:before {
content: "\f197";
}
.fa-slack:before {
content: "\f198";
}
.fa-envelope-square:before {
content: "\f199";
}
.fa-wordpress:before {
content: "\f19a";
}
.fa-openid:before {
content: "\f19b";
}
.fa-institution:before,
.fa-bank:before,
.fa-university:before {
content: "\f19c";
}
.fa-mortar-board:before,
.fa-graduation-cap:before {
content: "\f19d";
}
.fa-yahoo:before {
content: "\f19e";
}
.fa-google:before {
content: "\f1a0";
}
.fa-reddit:before {
content: "\f1a1";
}
.fa-reddit-square:before {
content: "\f1a2";
}
.fa-stumbleupon-circle:before {
content: "\f1a3";
}
.fa-stumbleupon:before {
content: "\f1a4";
}
.fa-delicious:before {
content: "\f1a5";
}
.fa-digg:before {
content: "\f1a6";
}
.fa-pied-piper:before {
content: "\f1a7";
}
.fa-pied-piper-alt:before {
content: "\f1a8";
}
.fa-drupal:before {
content: "\f1a9";
}
.fa-joomla:before {
content: "\f1aa";
}
.fa-language:before {
content: "\f1ab";
}
.fa-fax:before {
content: "\f1ac";
}
.fa-building:before {
content: "\f1ad";
}
.fa-child:before {
content: "\f1ae";
}
.fa-paw:before {
content: "\f1b0";
}
.fa-spoon:before {
content: "\f1b1";
}
.fa-cube:before {
content: "\f1b2";
}
.fa-cubes:before {
content: "\f1b3";
}
.fa-behance:before {
content: "\f1b4";
}
.fa-behance-square:before {
content: "\f1b5";
}
.fa-steam:before {
content: "\f1b6";
}
.fa-steam-square:before {
content: "\f1b7";
}
.fa-recycle:before {
content: "\f1b8";
}
.fa-automobile:before,
.fa-car:before {
content: "\f1b9";
}
.fa-cab:before,
.fa-taxi:before {
content: "\f1ba";
}
.fa-tree:before {
content: "\f1bb";
}
.fa-spotify:before {
content: "\f1bc";
}
.fa-deviantart:before {
content: "\f1bd";
}
.fa-soundcloud:before {
content: "\f1be";
}
.fa-database:before {
content: "\f1c0";
}
.fa-file-pdf-o:before {
content: "\f1c1";
}
.fa-file-word-o:before {
content: "\f1c2";
}
.fa-file-excel-o:before {
content: "\f1c3";
}
.fa-file-powerpoint-o:before {
content: "\f1c4";
}
.fa-file-photo-o:before,
.fa-file-picture-o:before,
.fa-file-image-o:before {
content: "\f1c5";
}
.fa-file-zip-o:before,
.fa-file-archive-o:before {
content: "\f1c6";
}
.fa-file-sound-o:before,
.fa-file-audio-o:before {
content: "\f1c7";
}
.fa-file-movie-o:before,
.fa-file-video-o:before {
content: "\f1c8";
}
.fa-file-code-o:before {
content: "\f1c9";
}
.fa-vine:before {
content: "\f1ca";
}
.fa-codepen:before {
content: "\f1cb";
}
.fa-jsfiddle:before {
content: "\f1cc";
}
.fa-life-bouy:before,
.fa-life-buoy:before,
.fa-life-saver:before,
.fa-support:before,
.fa-life-ring:before {
content: "\f1cd";
}
.fa-circle-o-notch:before {
content: "\f1ce";
}
.fa-ra:before,
.fa-rebel:before {
content: "\f1d0";
}
.fa-ge:before,
.fa-empire:before {
content: "\f1d1";
}
.fa-git-square:before {
content: "\f1d2";
}
.fa-git:before {
content: "\f1d3";
}
.fa-y-combinator-square:before,
.fa-yc-square:before,
.fa-hacker-news:before {
content: "\f1d4";
}
.fa-tencent-weibo:before {
content: "\f1d5";
}
.fa-qq:before {
content: "\f1d6";
}
.fa-wechat:before,
.fa-weixin:before {
content: "\f1d7";
}
.fa-send:before,
.fa-paper-plane:before {
content: "\f1d8";
}
.fa-send-o:before,
.fa-paper-plane-o:before {
content: "\f1d9";
}
.fa-history:before {
content: "\f1da";
}
.fa-circle-thin:before {
content: "\f1db";
}
.fa-header:before {
content: "\f1dc";
}
.fa-paragraph:before {
content: "\f1dd";
}
.fa-sliders:before {
content: "\f1de";
}
.fa-share-alt:before {
content: "\f1e0";
}
.fa-share-alt-square:before {
content: "\f1e1";
}
.fa-bomb:before {
content: "\f1e2";
}
.fa-soccer-ball-o:before,
.fa-futbol-o:before {
content: "\f1e3";
}
.fa-tty:before {
content: "\f1e4";
}
.fa-binoculars:before {
content: "\f1e5";
}
.fa-plug:before {
content: "\f1e6";
}
.fa-slideshare:before {
content: "\f1e7";
}
.fa-twitch:before {
content: "\f1e8";
}
.fa-yelp:before {
content: "\f1e9";
}
.fa-newspaper-o:before {
content: "\f1ea";
}
.fa-wifi:before {
content: "\f1eb";
}
.fa-calculator:before {
content: "\f1ec";
}
.fa-paypal:before {
content: "\f1ed";
}
.fa-google-wallet:before {
content: "\f1ee";
}
.fa-cc-visa:before {
content: "\f1f0";
}
.fa-cc-mastercard:before {
content: "\f1f1";
}
.fa-cc-discover:before {
content: "\f1f2";
}
.fa-cc-amex:before {
content: "\f1f3";
}
.fa-cc-paypal:before {
content: "\f1f4";
}
.fa-cc-stripe:before {
content: "\f1f5";
}
.fa-bell-slash:before {
content: "\f1f6";
}
.fa-bell-slash-o:before {
content: "\f1f7";
}
.fa-trash:before {
content: "\f1f8";
}
.fa-copyright:before {
content: "\f1f9";
}
.fa-at:before {
content: "\f1fa";
}
.fa-eyedropper:before {
content: "\f1fb";
}
.fa-paint-brush:before {
content: "\f1fc";
}
.fa-birthday-cake:before {
content: "\f1fd";
}
.fa-area-chart:before {
content: "\f1fe";
}
.fa-pie-chart:before {
content: "\f200";
}
.fa-line-chart:before {
content: "\f201";
}
.fa-lastfm:before {
content: "\f202";
}
.fa-lastfm-square:before {
content: "\f203";
}
.fa-toggle-off:before {
content: "\f204";
}
.fa-toggle-on:before {
content: "\f205";
}
.fa-bicycle:before {
content: "\f206";
}
.fa-bus:before {
content: "\f207";
}
.fa-ioxhost:before {
content: "\f208";
}
.fa-angellist:before {
content: "\f209";
}
.fa-cc:before {
content: "\f20a";
}
.fa-shekel:before,
.fa-sheqel:before,
.fa-ils:before {
content: "\f20b";
}
.fa-meanpath:before {
content: "\f20c";
}
.fa-buysellads:before {
content: "\f20d";
}
.fa-connectdevelop:before {
content: "\f20e";
}
.fa-dashcube:before {
content: "\f210";
}
.fa-forumbee:before {
content: "\f211";
}
.fa-leanpub:before {
content: "\f212";
}
.fa-sellsy:before {
content: "\f213";
}
.fa-shirtsinbulk:before {
content: "\f214";
}
.fa-simplybuilt:before {
content: "\f215";
}
.fa-skyatlas:before {
content: "\f216";
}
.fa-cart-plus:before {
content: "\f217";
}
.fa-cart-arrow-down:before {
content: "\f218";
}
.fa-diamond:before {
content: "\f219";
}
.fa-ship:before {
content: "\f21a";
}
.fa-user-secret:before {
content: "\f21b";
}
.fa-motorcycle:before {
content: "\f21c";
}
.fa-street-view:before {
content: "\f21d";
}
.fa-heartbeat:before {
content: "\f21e";
}
.fa-venus:before {
content: "\f221";
}
.fa-mars:before {
content: "\f222";
}
.fa-mercury:before {
content: "\f223";
}
.fa-intersex:before,
.fa-transgender:before {
content: "\f224";
}
.fa-transgender-alt:before {
content: "\f225";
}
.fa-venus-double:before {
content: "\f226";
}
.fa-mars-double:before {
content: "\f227";
}
.fa-venus-mars:before {
content: "\f228";
}
.fa-mars-stroke:before {
content: "\f229";
}
.fa-mars-stroke-v:before {
content: "\f22a";
}
.fa-mars-stroke-h:before {
content: "\f22b";
}
.fa-neuter:before {
content: "\f22c";
}
.fa-genderless:before {
content: "\f22d";
}
.fa-facebook-official:before {
content: "\f230";
}
.fa-pinterest-p:before {
content: "\f231";
}
.fa-whatsapp:before {
content: "\f232";
}
.fa-server:before {
content: "\f233";
}
.fa-user-plus:before {
content: "\f234";
}
.fa-user-times:before {
content: "\f235";
}
.fa-hotel:before,
.fa-bed:before {
content: "\f236";
}
.fa-viacoin:before {
content: "\f237";
}
.fa-train:before {
content: "\f238";
}
.fa-subway:before {
content: "\f239";
}
.fa-medium:before {
content: "\f23a";
}
.fa-yc:before,
.fa-y-combinator:before {
content: "\f23b";
}
.fa-optin-monster:before {
content: "\f23c";
}
.fa-opencart:before {
content: "\f23d";
}
.fa-expeditedssl:before {
content: "\f23e";
}
.fa-battery-4:before,
.fa-battery-full:before {
content: "\f240";
}
.fa-battery-3:before,
.fa-battery-three-quarters:before {
content: "\f241";
}
.fa-battery-2:before,
.fa-battery-half:before {
content: "\f242";
}
.fa-battery-1:before,
.fa-battery-quarter:before {
content: "\f243";
}
.fa-battery-0:before,
.fa-battery-empty:before {
content: "\f244";
}
.fa-mouse-pointer:before {
content: "\f245";
}
.fa-i-cursor:before {
content: "\f246";
}
.fa-object-group:before {
content: "\f247";
}
.fa-object-ungroup:before {
content: "\f248";
}
.fa-sticky-note:before {
content: "\f249";
}
.fa-sticky-note-o:before {
content: "\f24a";
}
.fa-cc-jcb:before {
content: "\f24b";
}
.fa-cc-diners-club:before {
content: "\f24c";
}
.fa-clone:before {
content: "\f24d";
}
.fa-balance-scale:before {
content: "\f24e";
}
.fa-hourglass-o:before {
content: "\f250";
}
.fa-hourglass-1:before,
.fa-hourglass-start:before {
content: "\f251";
}
.fa-hourglass-2:before,
.fa-hourglass-half:before {
content: "\f252";
}
.fa-hourglass-3:before,
.fa-hourglass-end:before {
content: "\f253";
}
.fa-hourglass:before {
content: "\f254";
}
.fa-hand-grab-o:before,
.fa-hand-rock-o:before {
content: "\f255";
}
.fa-hand-stop-o:before,
.fa-hand-paper-o:before {
content: "\f256";
}
.fa-hand-scissors-o:before {
content: "\f257";
}
.fa-hand-lizard-o:before {
content: "\f258";
}
.fa-hand-spock-o:before {
content: "\f259";
}
.fa-hand-pointer-o:before {
content: "\f25a";
}
.fa-hand-peace-o:before {
content: "\f25b";
}
.fa-trademark:before {
content: "\f25c";
}
.fa-registered:before {
content: "\f25d";
}
.fa-creative-commons:before {
content: "\f25e";
}
.fa-gg:before {
content: "\f260";
}
.fa-gg-circle:before {
content: "\f261";
}
.fa-tripadvisor:before {
content: "\f262";
}
.fa-odnoklassniki:before {
content: "\f263";
}
.fa-odnoklassniki-square:before {
content: "\f264";
}
.fa-get-pocket:before {
content: "\f265";
}
.fa-wikipedia-w:before {
content: "\f266";
}
.fa-safari:before {
content: "\f267";
}
.fa-chrome:before {
content: "\f268";
}
.fa-firefox:before {
content: "\f269";
}
.fa-opera:before {
content: "\f26a";
}
.fa-internet-explorer:before {
content: "\f26b";
}
.fa-tv:before,
.fa-television:before {
content: "\f26c";
}
.fa-contao:before {
content: "\f26d";
}
.fa-500px:before {
content: "\f26e";
}
.fa-amazon:before {
content: "\f270";
}
.fa-calendar-plus-o:before {
content: "\f271";
}
.fa-calendar-minus-o:before {
content: "\f272";
}
.fa-calendar-times-o:before {
content: "\f273";
}
.fa-calendar-check-o:before {
content: "\f274";
}
.fa-industry:before {
content: "\f275";
}
.fa-map-pin:before {
content: "\f276";
}
.fa-map-signs:before {
content: "\f277";
}
.fa-map-o:before {
content: "\f278";
}
.fa-map:before {
content: "\f279";
}
.fa-commenting:before {
content: "\f27a";
}
.fa-commenting-o:before {
content: "\f27b";
}
.fa-houzz:before {
content: "\f27c";
}
.fa-vimeo:before {
content: "\f27d";
}
.fa-black-tie:before {
content: "\f27e";
}
.fa-fonticons:before {
content: "\f280";
}
.fa-reddit-alien:before {
content: "\f281";
}
.fa-edge:before {
content: "\f282";
}
.fa-credit-card-alt:before {
content: "\f283";
}
.fa-codiepie:before {
content: "\f284";
}
.fa-modx:before {
content: "\f285";
}
.fa-fort-awesome:before {
content: "\f286";
}
.fa-usb:before {
content: "\f287";
}
.fa-product-hunt:before {
content: "\f288";
}
.fa-mixcloud:before {
content: "\f289";
}
.fa-scribd:before {
content: "\f28a";
}
.fa-pause-circle:before {
content: "\f28b";
}
.fa-pause-circle-o:before {
content: "\f28c";
}
.fa-stop-circle:before {
content: "\f28d";
}
.fa-stop-circle-o:before {
content: "\f28e";
}
.fa-shopping-bag:before {
content: "\f290";
}
.fa-shopping-basket:before {
content: "\f291";
}
.fa-hashtag:before {
content: "\f292";
}
.fa-bluetooth:before {
content: "\f293";
}
.fa-bluetooth-b:before {
content: "\f294";
}
.fa-percent:before {
content: "\f295";
}
.hidden {
display: none;
}
.Charts {
margin: 0 auto;
background-color: #f9f9f9;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-align: end;
-webkit-align-items: flex-end;
-ms-flex-align: end;
align-items: flex-end;
padding: 10px;
padding-right: 50px;
}
.Charts.horizontal {
display: block;
}
.Charts.horizontal .Charts--serie {
display: block;
margin: 0 0 30px 0;
border: 0;
}
.Charts.horizontal .Charts--serie label {
position: relative;
top: auto;
right: auto;
left: 0;
bottom: auto;
padding: 0 0 10px 0;
}
.Charts--serie {
height: 100%;
margin: 0 30px 0 0;
display: inline-block;
-webkit-box-flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-align: end;
-webkit-align-items: flex-end;
-ms-flex-align: end;
align-items: flex-end;
-webkit-transform-origin: 0 100%;
transform-origin: 0 100%;
-webkit-animation: slideUp .6s;
animation: slideUp .6s;
position: relative;
border-bottom: 1px solid #c2c2c2;
}
.Charts--serie.stacked {
display: block;
}
.Charts--serie label {
position: absolute;
left: 0;
right: 0;
bottom: -20px;
font-family: Helvetica, sans-serif;
font-size: 10px;
text-align: center;
color: #808080;
}
.Charts.horizontal .Charts--item {
display: block;
border-radius: 0 2px 2px 0;
margin: 0 0 5px 0;
height: 1em;
}
.Charts.horizontal .Charts--item b {
position: absolute;
right: -20px;
top: .3em;
}
.Charts--item {
background-color: #43A19E;
display: inline-block;
margin: 0 5px 0 0;
-webkit-box-flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
-webkit-transition: height 1s ease-out, width 1s ease-out;
transition: height 1s ease-out, width 1s ease-out;
position: relative;
text-align: center;
border-radius: 2px 2px 0 0;
}
.Charts--item.layered {
position: absolute;
left: 5%;
right: 5%;
bottom: 0;
margin: 0;
}
.Charts--item.layered b {
position: absolute;
right: 0;
}
.Charts--item.stacked {
position: relative;
display: block;
border-radius: 0;
}
.Charts--item b {
position: relative;
font-family: Helvetica, sans-serif;
font-size: 10px;
top: -20px;
color: #43A19E;
}
.Legend--color {
display: inline-block;
vertical-align: middle;
border-radius: 2px;
width: 16px;
height: 16px;
}
.Legend--label {
display: inline-block;
vertical-align: middle;
font-family: Helvetica, sans-serif;
font-size: 12px;
margin: 0 0 0 5px;
}
@-webkit-keyframes slideUp {
from {
-webkit-transform: scaleY(0);
transform: scaleY(0);
}
to {
-webkit-transform: scaleY(1);
transform: scaleY(1);
}
}
@keyframes slideUp {
from {
-webkit-transform: scaleY(0);
transform: scaleY(0);
}
to {
-webkit-transform: scaleY(1);
transform: scaleY(1);
}
} | jcapuano328/scratch-minder-web | src/server/content/css/bundle.css | CSS | mit | 36,810 | [
30522,
1013,
1008,
999,
1008,
15489,
12476,
1018,
1012,
1019,
1012,
1014,
2011,
1030,
4913,
5289,
5149,
1011,
8299,
1024,
1013,
1013,
15489,
10376,
2229,
8462,
1012,
22834,
1011,
1030,
15489,
10376,
2229,
8462,
1008,
6105,
1011,
8299,
1024,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
#ifndef GAME_H
#define GAME_H
#include <array>
class Game
{
public:
//Standard Con/Destructors
Game(); //Initialize the board.
~Game(); //Not sure if I need this, but it's here in case
//Are we playing the game?
bool isRunning = true;
//The easiest way I could implement stalemate
//detection with my limited knowledge.
//Is the board completely full, thereby causing a stalemate?
bool isStalemate = false;
//Board specific variables.
static const int MAX_ROWS = 3; //Bounds for our board array
static const int MAX_COLS = 3;
//Return the bounds of our board.
//Useful for, say, only allowing the player
//to make a move within board boundaries
//when player data is in a different class.
int get_max_rows() { return MAX_ROWS; }
int get_max_cols() { return MAX_COLS; }
//Return our private piece variables for public use.
char get_piece_x() { return pieceX; }
char get_piece_o() { return pieceO; }
//Print the board in its current state
void print_board();
//Print our help board. This board does not change.
void print_help_board();
//Check for an overlap, IE placing an X on top of an O.
//Returns false if there is an overlap. The space is invalid.
//Does NOT check for input sanity or bounds!!! This is done
//in some other class, likely going to be the player class.
bool is_valid_space(int xPosition, int yPosition);
//Check for every possible win using piece as the winning piece.
//For example, check if O is the winning piece.
//Returns true on a win, false otherwise.
bool is_victory(char piece);
//Allow a different function/class/file/whatever to acces the board.
//This is done to allow placement of pieces to the board without
//the risk of accidently trashing it. is_valid_space() should always
//be called first, and it likely will be called in this function.
//Returns false if it cannot place the piece.
bool add_new_piece(int xPosition, int yPosition, char piece);
//Removes all pieces from the board, re-sets the score (if I chose to
//implement scoring) to zero. This is used in preperation for a new game.
void reset();
//Simple random number generator, with bounds.
int get_random_num(int bound = 0);
//Place a piece on the board based on user input.
int make_move(int input, char piece);
private:
//Three win calcualtion functions to make my job easier.
//Check for vertical, horizontal, or diagonal wins independently.
//Used by is_victory() to simplify win checking even more.
bool is_win_vertical(char piece);
bool is_win_horizontal(char piece);
bool is_win_diagonal(char piece);
//char board[MAX_ROWS][MAX_COLS]; //The board itself
std::array<std::array<char, MAX_ROWS>, MAX_COLS> board; //The board itself
//These make setting up the board/player(s)/etc MUCH easier.
char pieceX = 'X'; //The player class assigns these variables to a local var.
char pieceO = 'O'; //for example, something like: player.set_piece(game.pieceX);
char pieceNeutral = '-'; //The blank or empty piece.
//Settings for making a help board. Shows the player which number corresponds
//to the tile he/she wants. Below are variables for that.
int helpBoard[MAX_ROWS][MAX_COLS];
};
#endif
| JohnBobSmith/console_games | tictactoe/game.h | C | mit | 3,265 | [
30522,
1001,
2065,
13629,
2546,
2208,
1035,
1044,
1001,
9375,
2208,
1035,
1044,
1001,
2421,
1026,
9140,
1028,
2465,
2208,
1063,
2270,
1024,
1013,
1013,
3115,
9530,
1013,
4078,
18300,
5668,
2208,
1006,
1007,
1025,
1013,
1013,
3988,
4697,
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... |
/**************************************************************************************************
Filename: SensorTagMovementProfile.java
Copyright (c) 2013 - 2015 Texas Instruments Incorporated
All rights reserved not granted herein.
Limited License.
Texas Instruments Incorporated grants a world-wide, royalty-free,
non-exclusive license under copyrights and patents it now or hereafter
owns or controls to make, have made, use, import, offer to sell and sell ("Utilize")
this software subject to the terms herein. With respect to the foregoing patent
license, such license is granted solely to the extent that any such patent is necessary
to Utilize the software alone. The patent license shall not apply to any combinations which
include this software, other than combinations with devices manufactured by or for TI ('TI Devices').
No hardware patent is licensed hereunder.
Redistributions must preserve existing copyright notices and reproduce this license (including the
above copyright notice and the disclaimer and (if applicable) source code license limitations below)
in the documentation and/or other materials provided with the distribution
Redistribution and use in binary form, without modification, are permitted provided that the following
conditions are met:
* No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any
software provided in binary form.
* any redistribution and use are licensed by TI for use only with TI Devices.
* Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
If software source code is provided to you, modification and redistribution of the source code are permitted
provided that the following conditions are met:
* any redistribution and use of the source code, including any resulting derivative works, are licensed by
TI for use only with TI Devices.
* any redistribution and use of any object code compiled from the source code and any resulting derivative
works, are licensed by TI for use only with TI Devices.
Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or
promote products derived from this software without specific prior written permission.
DISCLAIMER.
THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
**************************************************************************************************/
package com.example.ti.ble.sensortag;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattService;
import android.content.Context;
import android.text.Html;
import android.util.Log;
import android.widget.CompoundButton;
import com.example.ti.ble.common.BluetoothLeService;
import com.example.ti.ble.common.GattInfo;
import com.example.ti.ble.common.GenericBluetoothProfile;
import com.example.ti.util.Point3D;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class SensorTagMovementProfile extends GenericBluetoothProfile {
public SensorTagMovementProfile(Context con,BluetoothDevice device,BluetoothGattService service,BluetoothLeService controller) {
super(con,device,service,controller);
this.tRow = new SensorTagMovementTableRow(con);
List<BluetoothGattCharacteristic> characteristics = this.mBTService.getCharacteristics();
for (BluetoothGattCharacteristic c : characteristics) {
if (c.getUuid().toString().equals(SensorTagGatt.UUID_MOV_DATA.toString())) {
this.dataC = c;
}
if (c.getUuid().toString().equals(SensorTagGatt.UUID_MOV_CONF.toString())) {
this.configC = c;
}
if (c.getUuid().toString().equals(SensorTagGatt.UUID_MOV_PERI.toString())) {
this.periodC = c;
}
}
this.tRow.setIcon(this.getIconPrefix(), this.dataC.getUuid().toString());
this.tRow.title.setText(GattInfo.uuidToName(UUID.fromString(this.dataC.getUuid().toString())));
this.tRow.uuidLabel.setText(this.dataC.getUuid().toString());
this.tRow.value.setText("X:0.00G, Y:0.00G, Z:0.00G");
SensorTagMovementTableRow row = (SensorTagMovementTableRow)this.tRow;
row.gyroValue.setText("X:0.00'/s, Y:0.00'/s, Z:0.00'/s");
row.magValue.setText("X:0.00mT, Y:0.00mT, Z:0.00mT");
row.WOS.setChecked(true);
row.WOS.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
byte b[] = new byte[] {0x7F,0x00};
if (isChecked) {
b[0] = (byte)0xFF;
}
int error = mBTLeService.writeCharacteristic(configC, b);
if (error != 0) {
if (configC != null)
Log.d("SensorTagMovementProfile","Sensor config failed: " + configC.getUuid().toString() + " Error: " + error);
}
}
});
this.tRow.periodBar.setProgress(100);
}
public static boolean isCorrectService(BluetoothGattService service) {
if ((service.getUuid().toString().compareTo(SensorTagGatt.UUID_MOV_SERV.toString())) == 0) {
return true;
}
else return false;
}
@Override
public void enableService() {
byte b[] = new byte[] {0x7F,0x00};
SensorTagMovementTableRow row = (SensorTagMovementTableRow)this.tRow;
if (row.WOS.isChecked()) b[0] = (byte)0xFF;
int error = mBTLeService.writeCharacteristic(this.configC, b);
if (error != 0) {
if (this.configC != null)
Log.d("SensorTagMovementProfile","Sensor config failed: " + this.configC.getUuid().toString() + " Error: " + error);
}
error = this.mBTLeService.setCharacteristicNotification(this.dataC, true);
if (error != 0) {
if (this.dataC != null)
Log.d("SensorTagMovementProfile","Sensor notification enable failed: " + this.configC.getUuid().toString() + " Error: " + error);
}
this.periodWasUpdated(700);
this.isEnabled = true;
}
@Override
public void disableService() {
int error = mBTLeService.writeCharacteristic(this.configC, new byte[] {0x00,0x00});
if (error != 0) {
if (this.configC != null)
Log.d("SensorTagMovementProfile","Sensor config failed: " + this.configC.getUuid().toString() + " Error: " + error);
}
error = this.mBTLeService.setCharacteristicNotification(this.dataC, false);
if (error != 0) {
if (this.dataC != null)
Log.d("SensorTagMovementProfile","Sensor notification disable failed: " + this.configC.getUuid().toString() + " Error: " + error);
}
this.isEnabled = false;
}
public void didWriteValueForCharacteristic(BluetoothGattCharacteristic c) {
}
public void didReadValueForCharacteristic(BluetoothGattCharacteristic c) {
}
@Override
public void didUpdateValueForCharacteristic(BluetoothGattCharacteristic c) {
byte[] value = c.getValue();
if (c.equals(this.dataC)){
Point3D v;
v = Sensor.MOVEMENT_ACC.convert(value);
if (this.tRow.config == false) this.tRow.value.setText(Html.fromHtml(String.format("<font color=#FF0000>X:%.2fG</font>, <font color=#00967D>Y:%.2fG</font>, <font color=#00000>Z:%.2fG</font>", v.x, v.y, v.z)));
this.tRow.sl1.addValue((float)v.x);
this.tRow.sl2.addValue((float)v.y);
this.tRow.sl3.addValue((float)v.z);
v = Sensor.MOVEMENT_GYRO.convert(value);
SensorTagMovementTableRow row = (SensorTagMovementTableRow)this.tRow;
row.gyroValue.setText(Html.fromHtml(String.format("<font color=#FF0000>X:%.2f°/s</font>, <font color=#00967D>Y:%.2f°/s</font>, <font color=#00000>Z:%.2f°/s</font>", v.x, v.y, v.z)));
row.sl4.addValue((float)v.x);
row.sl5.addValue((float)v.y);
row.sl6.addValue((float)v.z);
v = Sensor.MOVEMENT_MAG.convert(value);
row.magValue.setText(Html.fromHtml(String.format("<font color=#FF0000>X:%.2fuT</font>, <font color=#00967D>Y:%.2fuT</font>, <font color=#00000>Z:%.2fuT</font>", v.x, v.y, v.z)));
row.sl7.addValue((float)v.x);
row.sl8.addValue((float)v.y);
row.sl9.addValue((float)v.z);
}
}
@Override
public Map<String,String> getMQTTMap() {
Point3D v = Sensor.MOVEMENT_ACC.convert(this.dataC.getValue());
Map<String,String> map = new HashMap<String, String>();
map.put("acc_x",String.format("%.2f",v.x));
map.put("acc_y",String.format("%.2f",v.y));
map.put("acc_z",String.format("%.2f",v.z));
v = Sensor.MOVEMENT_GYRO.convert(this.dataC.getValue());
map.put("gyro_x",String.format("%.2f",v.x));
map.put("gyro_y",String.format("%.2f",v.y));
map.put("gyro_z",String.format("%.2f",v.z));
v = Sensor.MOVEMENT_MAG.convert(this.dataC.getValue());
map.put("compass_x",String.format("%.2f",v.x));
map.put("compass_y",String.format("%.2f",v.y));
map.put("compass_z",String.format("%.2f",v.z));
return map;
}
}
| vanjo9800/SensortagSAPCloud | src/main/java/com/example/ti/ble/sensortag/SensorTagMovementProfile.java | Java | gpl-2.0 | 9,813 | [
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... |
/*
* 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.
*/
package org.apache.flink.types;
import org.apache.flink.api.java.tuple.Tuple2;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class RowTest {
@Test
public void testRowToString() {
Row row = new Row(5);
row.setField(0, 1);
row.setField(1, "hello");
row.setField(2, null);
row.setField(3, new Tuple2<>(2, "hi"));
row.setField(4, "hello world");
assertEquals("1,hello,null,(2,hi),hello world", row.toString());
}
@Test
public void testRowOf() {
Row row1 = Row.of(1, "hello", null, Tuple2.of(2L, "hi"), true);
Row row2 = new Row(5);
row2.setField(0, 1);
row2.setField(1, "hello");
row2.setField(2, null);
row2.setField(3, new Tuple2<>(2L, "hi"));
row2.setField(4, true);
assertEquals(row1, row2);
}
@Test
public void testRowCopy() {
Row row = new Row(5);
row.setField(0, 1);
row.setField(1, "hello");
row.setField(2, null);
row.setField(3, new Tuple2<>(2, "hi"));
row.setField(4, "hello world");
Row copy = Row.copy(row);
assertEquals(row, copy);
assertTrue(row != copy);
}
@Test
public void testRowProject() {
Row row = new Row(5);
row.setField(0, 1);
row.setField(1, "hello");
row.setField(2, null);
row.setField(3, new Tuple2<>(2, "hi"));
row.setField(4, "hello world");
Row projected = Row.project(row, new int[]{0, 2, 4});
Row expected = new Row(3);
expected.setField(0, 1);
expected.setField(1, null);
expected.setField(2, "hello world");
assertEquals(expected, projected);
}
@Test
public void testRowJoin() {
Row row1 = new Row(2);
row1.setField(0, 1);
row1.setField(1, "hello");
Row row2 = new Row(2);
row2.setField(0, null);
row2.setField(1, new Tuple2<>(2, "hi"));
Row row3 = new Row(1);
row3.setField(0, "hello world");
Row joinedRow = Row.join(row1, row2, row3);
Row expected = new Row(5);
expected.setField(0, 1);
expected.setField(1, "hello");
expected.setField(2, null);
expected.setField(3, new Tuple2<>(2, "hi"));
expected.setField(4, "hello world");
assertEquals(expected, joinedRow);
}
}
| jinglining/flink | flink-core/src/test/java/org/apache/flink/types/RowTest.java | Java | apache-2.0 | 2,914 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
1008,
2030,
2062,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
1008,
5500,
2007,
2023,
2147,
2005,
3176,
2592,
1008,
4953,
9385,
6095,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
var Command = require("../Command");
var RealDirection = require("../../RealDirection");
var MessageCategory = require("../../MessageCategory");
var _dir = RealDirection.NORTHEAST;
class Northeast extends Command{
constructor(){
super();
this.rule = /^n(?:orth)?e(?:ast)?$/g;
}
exec(){
if(this.step(_dir)){
this.showRoom();
} else {
this.sendMessage("Alas, you can't go that way.", MessageCategory.COMMAND);
}
}
}
module.exports = Northeast;
| jackindisguise/node-mud | src/handle/command/Northeast.js | JavaScript | mit | 465 | [
30522,
13075,
3094,
1027,
5478,
1006,
1000,
1012,
1012,
1013,
3094,
1000,
1007,
1025,
13075,
2613,
4305,
2890,
7542,
1027,
5478,
1006,
1000,
1012,
1012,
1013,
1012,
1012,
1013,
2613,
4305,
2890,
7542,
1000,
1007,
1025,
13075,
4471,
16280,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
'use strict';
// THIS CHECK SHOULD BE THE FIRST THING IN THIS FILE
// This is to ensure that we catch env issues before we error while requiring other dependencies.
const engines = require('./package.json').engines;
require('./tools/check-environment')({
requiredNodeVersion: engines.node,
requiredNpmVersion: engines.npm,
requiredYarnVersion: engines.yarn
});
const gulp = require('gulp');
// See `tools/gulp-tasks/README.md` for information about task loading.
function loadTask(fileName, taskName) {
const taskModule = require('./tools/gulp-tasks/' + fileName);
const task = taskName ? taskModule[taskName] : taskModule;
return task(gulp);
}
gulp.task('format:enforce', loadTask('format', 'enforce'));
gulp.task('format', loadTask('format', 'format'));
gulp.task('build.sh', loadTask('build', 'all'));
gulp.task('build.sh:no-bundle', loadTask('build', 'no-bundle'));
gulp.task('public-api:enforce', loadTask('public-api', 'enforce'));
gulp.task('public-api:update', ['build.sh'], loadTask('public-api', 'update'));
gulp.task('lint', ['format:enforce', 'validate-commit-messages', 'tslint']);
gulp.task('tslint', ['tools:build'], loadTask('lint'));
gulp.task('validate-commit-messages', loadTask('validate-commit-message'));
gulp.task('tools:build', loadTask('tools-build'));
gulp.task('check-cycle', loadTask('check-cycle'));
gulp.task('serve', loadTask('serve', 'default'));
gulp.task('serve-examples', loadTask('serve', 'examples'));
gulp.task('changelog', loadTask('changelog'));
gulp.task('check-env', () => {/* this is a noop because the env test ran already above */});
| chalin/angular | gulpfile.js | JavaScript | mit | 1,800 | [
30522,
1013,
1008,
1008,
1008,
1030,
6105,
1008,
9385,
8224,
4297,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
2224,
1997,
2023,
3120,
3642,
2003,
9950,
2011,
2019,
10210,
1011,
2806,
6105,
2008,
2064,
2022,
1008,
2179,
1999,
1996,
6105,
53... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
好读书,不求甚解。时不时会读到一些名声斐然的书,作者通常会提出自己的一套理论来解读这个世界。过去常常会为作者思想的深刻和理论的精辟叹服。合上书,拿起作者提的理论武器尝试着去把这个世界切割成理论中提到的几类,给身边的人和事物贴上生搬硬套的各种标签。
读的书越多,越发觉现实的复杂和理论的不可靠。大家都以为自己找到了真理,其实只是盲人摸象,各得一角。目前还没有哪一个解读世界的框架是“正确的”,所有的人都是带着各自的偏见在看世界,越是坚信自己理论的人越是偏执。除了在自然科学领域,其他所有领域的理论都不可靠,经济学也概莫能外。
读书,是为了从更多的角度看这个世界。读得书越多,就越不相信书。纸上得来终觉浅,绝知此事要躬行。 | jianfa/jianfa.github.io | _posts/2017-9-4-书是书,生活是生活.md | Markdown | mit | 927 | [
30522,
100,
100,
100,
1989,
1744,
100,
100,
100,
1636,
100,
1744,
100,
1763,
100,
100,
1740,
100,
1795,
100,
100,
100,
1916,
100,
1989,
100,
100,
100,
100,
1763,
100,
1774,
100,
100,
1916,
1740,
100,
100,
100,
100,
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... |
namespace AnimalHierarchy
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public abstract class Animal : ISound
{
//fields
private string name;
private int age;
private string sex;
//constructors
protected Animal(string name, int age, string sex)
{
this.Name = name;
this.Age = age;
this.Sex = sex;
}
//properties
protected string Name
{
get
{
return this.name;
}
private set
{
if (String.IsNullOrEmpty(value))
{
throw new ArgumentException("Name cannot be null or empty.");
}
this.name = value;
}
}
protected int Age
{
get
{
return this.age;
}
private set
{
if (value < 0)
{
throw new ArgumentException("Age cannot be a negative number.");
}
this.age = value;
}
}
protected string Sex
{
get
{
return this.sex;
}
private set
{
if (value != "male" && value != "female")
{
throw new ArgumentException("Gender can be either male or female.");
}
this.sex = value;
}
}
//methods
public static double AverageAge(IEnumerable<Animal> animals)
{
double average = animals.Average(x => x.Age);
return average;
}
public static void PrintAnimals(IEnumerable<Animal> animals)
{
foreach (var animal in animals)
{
Console.WriteLine(animal);
Console.WriteLine();
}
}
public override string ToString()
{
var animal = new StringBuilder();
animal.AppendFormat("Animal: {0}", this.GetType().Name);
animal.AppendLine();
animal.AppendFormat("Name: {0}", this.Name);
animal.AppendLine();
animal.AppendFormat("Gender: {0}", this.Sex);
animal.AppendLine();
animal.AppendFormat("Age: {0}", this.age);
return animal.ToString();
}
public virtual void MakeSound()
{
Console.WriteLine(this.Name + "made a sound.");
}
}
}
| Vyara/Telerik-OOP-Homeworks | 04. OOP Principles - Part 1/AnimalHierarchy/Animal.cs | C# | mit | 2,690 | [
30522,
3415,
15327,
4111,
4048,
6906,
29389,
1063,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,
3793,
1025,
2270,
10061,
2465,
4111,
1024,
11163,
8630,
1063,
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... |
# coding: utf-8
# Copyright (c) Pymatgen Development Team.
# Distributed under the terms of the MIT License.
__author__ = 'Anubhav Jain'
__copyright__ = 'Copyright 2014, The Materials Project'
__version__ = '0.1'
__maintainer__ = 'Anubhav Jain'
__email__ = 'ajain@lbl.gov'
__date__ = 'Oct 03, 2014'
| fraricci/pymatgen | pymatgen/analysis/cost/__init__.py | Python | mit | 300 | [
30522,
1001,
16861,
1024,
21183,
2546,
1011,
1022,
1001,
9385,
1006,
1039,
1007,
1052,
24335,
4017,
6914,
2458,
2136,
1012,
1001,
5500,
2104,
1996,
3408,
1997,
1996,
10210,
6105,
1012,
1035,
1035,
3166,
1035,
1035,
1027,
1005,
2019,
12083,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 <string>
template std::allocator<char>::allocator();
template std::allocator<char>::~allocator();
template std::basic_string<char, std::char_traits<char>, std::allocator<char>>::basic_string(const char*, const std::allocator<char>&);
template std::basic_string<char, std::char_traits<char>, std::allocator<char>>::~basic_string();
template const char* std::basic_string<char, std::char_traits<char>, std::allocator<char>>::c_str() const noexcept;
| mohtamohit/CppSharp | src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/Std-symbols.cpp | C++ | mit | 458 | [
30522,
1001,
2421,
1026,
5164,
1028,
23561,
2358,
2094,
1024,
1024,
2035,
24755,
4263,
1026,
25869,
1028,
1024,
1024,
2035,
24755,
4263,
1006,
1007,
1025,
23561,
2358,
2094,
1024,
1024,
2035,
24755,
4263,
1026,
25869,
1028,
1024,
1024,
1066... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 Immutable from 'immutable';
import * as ActionType from '../../actions/auth/auth';
const defaultState = Immutable.fromJS({
loggedIn: false,
});
function authReducer(state = defaultState, action) {
const {
loggedIn,
} = action;
switch (action.type) {
case ActionType.VERIFIED_LOGIN:
return state.merge(Immutable.fromJS({ loggedIn }));
default:
return state;
}
}
export default authReducer;
| phillydorn/CAProject2 | app/reducers/auth/auth.js | JavaScript | mit | 439 | [
30522,
12324,
10047,
28120,
3085,
2013,
1005,
10047,
28120,
3085,
1005,
1025,
12324,
1008,
2004,
2895,
13874,
2013,
1005,
1012,
1012,
1013,
1012,
1012,
1013,
4506,
1013,
8740,
2705,
1013,
8740,
2705,
1005,
1025,
9530,
3367,
12398,
9153,
261... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/*************************************************************************//**
*****************************************************************************
* @file exit.c
* @brief
* @author Forrest Y. Yu
* @date Tue May 6 14:25:33 2008
*****************************************************************************
*****************************************************************************/
#include "type.h"
#include "stdio.h"
#include "const.h"
#include "protect.h"
#include "string.h"
#include "fs.h"
#include "proc.h"
#include "tty.h"
#include "console.h"
#include "global.h"
#include "proto.h"
/*****************************************************************************
* exit
*************************************************************************//**
* Terminate the current process.
*
* @param status The value returned to the parent.
*****************************************************************************/
PUBLIC void exit(int status)
{
MESSAGE msg;
msg.type = EXIT;
msg.STATUS = status;
send_recv(BOTH, TASK_MM, &msg);
assert(msg.type == SYSCALL_RET);
}
| RongbinZhuang/simpleOS | ver0/reference/chapter11/c/lib/exit.c | C | mit | 1,142 | [
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... |
import sys, os, fabric
class PiServicePolicies:
@staticmethod
def is_local():
return (not fabric.api.env.hosts or fabric.api.env.hosts[0] in ['localhost', '127.0.0.1', '::1'])
@staticmethod
def is_pi():
return os.path.isdir('/home/pi')
@staticmethod
def check_local_or_exit():
if not PiServicePolicies.is_local():
print "...only callable on localhost!!!"
sys.exit(-1)
@staticmethod
def check_remote_or_exit():
if PiServicePolicies.is_local():
print "...only callable on remote host!!!"
sys.exit(-1)
def check_installed_or_exit(self):
if not PiServicePolicies.installed(self):
print "...first you have to install this service! fab pi %s:install"
sys.exit(-1)
def installed(self):
ret = self.file_exists('__init__.py')
if not ret: print self.name+' not installed'
return ret
| creative-workflow/pi-setup | lib/piservices/policies.py | Python | mit | 867 | [
30522,
12324,
25353,
2015,
1010,
9808,
1010,
8313,
2465,
14255,
8043,
7903,
13699,
23518,
3111,
1024,
1030,
10763,
11368,
6806,
2094,
13366,
2003,
1035,
2334,
1006,
1007,
1024,
2709,
1006,
2025,
8313,
1012,
17928,
1012,
4372,
2615,
1012,
61... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) 2009-2012 by Farsight Security, 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.
*/
/* Import. */
#include "private.h"
/* Internal functions. */
nmsg_res
_input_pcap_read(nmsg_input_t input, nmsg_message_t *msg) {
nmsg_res res;
size_t sz;
struct nmsg_ipdg dg;
struct timespec ts;
uint8_t *pbuf;
/* get next ip datagram from pcap source */
res = nmsg_pcap_input_read(input->pcap, &dg, &ts);
if (res != nmsg_res_success)
return (res);
/* convert ip datagram to payload */
res = nmsg_msgmod_ipdg_to_payload(input->msgmod, input->clos, &dg,
&pbuf, &sz);
if (res != nmsg_res_pbuf_ready)
return (res);
/* encapsulate nmsg payload */
*msg = nmsg_message_from_raw_payload(input->msgmod->plugin->vendor.id,
input->msgmod->plugin->msgtype.id,
pbuf, sz, &ts);
if (*msg == NULL) {
free(pbuf);
return (nmsg_res_memfail);
}
return (nmsg_res_success);
}
nmsg_res
_input_pcap_read_raw(nmsg_input_t input, nmsg_message_t *msg) {
return (nmsg_msgmod_pkt_to_payload(input->msgmod, input->clos, input->pcap, msg));
}
| hstern/nmsg | nmsg/input_pcap.c | C | apache-2.0 | 1,592 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2268,
1011,
2262,
2011,
2521,
25807,
3036,
1010,
4297,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
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... |
/*
* (C) Copyright 2003-2006
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* (C) Copyright 2004
* Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
*
* (C) Copyright 2004-2006
* Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de
*
* See file CREDITS for list of people who contributed to this
* project.
*
* 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
*/
#include <common.h>
#include <mpc5xxx.h>
#include <pci.h>
#include <asm/processor.h>
#ifdef CONFIG_VIDEO_SM501
#include <sm501.h>
#endif
#if defined(CONFIG_MPC5200_DDR)
#include "mt46v16m16-75.h"
#else
#include "mt48lc16m16a2-75.h"
#endif
#ifdef CONFIG_PS2MULT
void ps2mult_early_init(void);
#endif
#ifndef CFG_RAMBOOT
static void sdram_start (int hi_addr)
{
long hi_addr_bit = hi_addr ? 0x01000000 : 0;
/* unlock mode register */
*(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 |
hi_addr_bit;
__asm__ volatile ("sync");
/* precharge all banks */
*(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 |
hi_addr_bit;
__asm__ volatile ("sync");
#if SDRAM_DDR
/* set mode register: extended mode */
*(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_EMODE;
__asm__ volatile ("sync");
/* set mode register: reset DLL */
*(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000;
__asm__ volatile ("sync");
#endif
/* precharge all banks */
*(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 |
hi_addr_bit;
__asm__ volatile ("sync");
/* auto refresh */
*(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 |
hi_addr_bit;
__asm__ volatile ("sync");
/* set mode register */
*(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
__asm__ volatile ("sync");
/* normal operation */
*(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
__asm__ volatile ("sync");
}
#endif
/*
* ATTENTION: Although partially referenced initdram does NOT make real use
* use of CFG_SDRAM_BASE. The code does not work if CFG_SDRAM_BASE
* is something else than 0x00000000.
*/
#if defined(CONFIG_MPC5200)
long int initdram (int board_type)
{
ulong dramsize = 0;
ulong dramsize2 = 0;
uint svr, pvr;
#ifndef CFG_RAMBOOT
ulong test1, test2;
/* setup SDRAM chip selects */
*(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001c; /* 512MB at 0x0 */
*(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x40000000; /* disabled */
__asm__ volatile ("sync");
/* setup config registers */
*(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
*(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
__asm__ volatile ("sync");
#if SDRAM_DDR
/* set tap delay */
*(vu_long *)MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY;
__asm__ volatile ("sync");
#endif
/* find RAM size using SDRAM CS0 only */
sdram_start(0);
test1 = get_ram_size((long *)CFG_SDRAM_BASE, 0x20000000);
sdram_start(1);
test2 = get_ram_size((long *)CFG_SDRAM_BASE, 0x20000000);
if (test1 > test2) {
sdram_start(0);
dramsize = test1;
} else {
dramsize = test2;
}
/* memory smaller than 1MB is impossible */
if (dramsize < (1 << 20)) {
dramsize = 0;
}
/* set SDRAM CS0 size according to the amount of RAM found */
if (dramsize > 0) {
*(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 +
__builtin_ffs(dramsize >> 20) - 1;
} else {
*(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */
}
/* let SDRAM CS1 start right after CS0 */
*(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001c; /* 512MB */
/* find RAM size using SDRAM CS1 only */
sdram_start(0);
test1 = get_ram_size((long *)(CFG_SDRAM_BASE + dramsize), 0x20000000);
sdram_start(1);
test2 = get_ram_size((long *)(CFG_SDRAM_BASE + dramsize), 0x20000000);
if (test1 > test2) {
sdram_start(0);
dramsize2 = test1;
} else {
dramsize2 = test2;
}
/* memory smaller than 1MB is impossible */
if (dramsize2 < (1 << 20)) {
dramsize2 = 0;
}
/* set SDRAM CS1 size according to the amount of RAM found */
if (dramsize2 > 0) {
*(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize
| (0x13 + __builtin_ffs(dramsize2 >> 20) - 1);
} else {
*(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize; /* disabled */
}
#else /* CFG_RAMBOOT */
/* retrieve size of memory connected to SDRAM CS0 */
dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF;
if (dramsize >= 0x13) {
dramsize = (1 << (dramsize - 0x13)) << 20;
} else {
dramsize = 0;
}
/* retrieve size of memory connected to SDRAM CS1 */
dramsize2 = *(vu_long *)MPC5XXX_SDRAM_CS1CFG & 0xFF;
if (dramsize2 >= 0x13) {
dramsize2 = (1 << (dramsize2 - 0x13)) << 20;
} else {
dramsize2 = 0;
}
#endif /* CFG_RAMBOOT */
/*
* On MPC5200B we need to set the special configuration delay in the
* DDR controller. Please refer to Freescale's AN3221 "MPC5200B SDRAM
* Initialization and Configuration", 3.3.1 SDelay--MBAR + 0x0190:
*
* "The SDelay should be written to a value of 0x00000004. It is
* required to account for changes caused by normal wafer processing
* parameters."
*/
svr = get_svr();
pvr = get_pvr();
if ((SVR_MJREV(svr) >= 2) &&
(PVR_MAJ(pvr) == 1) && (PVR_MIN(pvr) == 4)) {
*(vu_long *)MPC5XXX_SDRAM_SDELAY = 0x04;
__asm__ volatile ("sync");
}
#if defined(CONFIG_TQM5200_B)
return dramsize + dramsize2;
#else
return dramsize;
#endif /* CONFIG_TQM5200_B */
}
#elif defined(CONFIG_MGT5100)
long int initdram (int board_type)
{
ulong dramsize = 0;
#ifndef CFG_RAMBOOT
ulong test1, test2;
/* setup and enable SDRAM chip selects */
*(vu_long *)MPC5XXX_SDRAM_START = 0x00000000;
*(vu_long *)MPC5XXX_SDRAM_STOP = 0x0000ffff;/* 2G */
*(vu_long *)MPC5XXX_ADDECR |= (1 << 22); /* Enable SDRAM */
__asm__ volatile ("sync");
/* setup config registers */
*(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
*(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
/* address select register */
*(vu_long *)MPC5XXX_SDRAM_XLBSEL = SDRAM_ADDRSEL;
__asm__ volatile ("sync");
/* find RAM size */
sdram_start(0);
test1 = get_ram_size((ulong *)CFG_SDRAM_BASE, 0x80000000);
sdram_start(1);
test2 = get_ram_size((ulong *)CFG_SDRAM_BASE, 0x80000000);
if (test1 > test2) {
sdram_start(0);
dramsize = test1;
} else {
dramsize = test2;
}
/* set SDRAM end address according to size */
*(vu_long *)MPC5XXX_SDRAM_STOP = ((dramsize - 1) >> 15);
#else /* CFG_RAMBOOT */
/* Retrieve amount of SDRAM available */
dramsize = ((*(vu_long *)MPC5XXX_SDRAM_STOP + 1) << 15);
#endif /* CFG_RAMBOOT */
return dramsize;
}
#else
#error Neither CONFIG_MPC5200 or CONFIG_MGT5100 defined
#endif
int checkboard (void)
{
#if defined(CONFIG_AEVFIFO)
puts ("Board: AEVFIFO\n");
return 0;
#endif
#if defined(CONFIG_TQM5200S)
# define MODULE_NAME "TQM5200S"
#else
# define MODULE_NAME "TQM5200"
#endif
#if defined(CONFIG_STK52XX)
# define CARRIER_NAME "STK52xx"
#elif defined(CONFIG_TB5200)
# define CARRIER_NAME "TB5200"
#elif defined(CONFIG_CAM5200)
# define CARRIER_NAME "Cam5200"
#else
# error "Unknown carrier board"
#endif
puts ( "Board: " MODULE_NAME " (TQ-Components GmbH)\n"
" on a " CARRIER_NAME " carrier board\n");
return 0;
}
#undef MODULE_NAME
#undef CARRIER_NAME
void flash_preinit(void)
{
/*
* Now, when we are in RAM, enable flash write
* access for detection process.
* Note that CS_BOOT cannot be cleared when
* executing in flash.
*/
#if defined(CONFIG_MGT5100)
*(vu_long *)MPC5XXX_ADDECR &= ~(1 << 25); /* disable CS_BOOT */
*(vu_long *)MPC5XXX_ADDECR |= (1 << 16); /* enable CS0 */
#endif
*(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */
}
#ifdef CONFIG_PCI
static struct pci_controller hose;
extern void pci_mpc5xxx_init(struct pci_controller *);
void pci_init_board(void)
{
pci_mpc5xxx_init(&hose);
}
#endif
#if defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET)
#if defined (CONFIG_MINIFAP)
#define SM501_POWER_MODE0_GATE 0x00000040UL
#define SM501_POWER_MODE1_GATE 0x00000048UL
#define POWER_MODE_GATE_GPIO_PWM_I2C 0x00000040UL
#define SM501_GPIO_DATA_DIR_HIGH 0x0001000CUL
#define SM501_GPIO_DATA_HIGH 0x00010004UL
#define SM501_GPIO_51 0x00080000UL
#else
#define GPIO_PSC1_4 0x01000000UL
#endif
void init_ide_reset (void)
{
debug ("init_ide_reset\n");
#if defined (CONFIG_MINIFAP)
/* Configure GPIO_51 of the SM501 grafic controller as ATA reset */
/* enable GPIO control (in both power modes) */
*(vu_long *) (SM501_MMIO_BASE+SM501_POWER_MODE0_GATE) |=
POWER_MODE_GATE_GPIO_PWM_I2C;
*(vu_long *) (SM501_MMIO_BASE+SM501_POWER_MODE1_GATE) |=
POWER_MODE_GATE_GPIO_PWM_I2C;
/* configure GPIO51 as output */
*(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_DIR_HIGH) |=
SM501_GPIO_51;
#else
/* Configure PSC1_4 as GPIO output for ATA reset */
*(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4;
*(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4;
#endif
}
void ide_set_reset (int idereset)
{
debug ("ide_reset(%d)\n", idereset);
#if defined (CONFIG_MINIFAP)
if (idereset) {
*(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) &=
~SM501_GPIO_51;
} else {
*(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) |=
SM501_GPIO_51;
}
#else
if (idereset) {
*(vu_long *) MPC5XXX_WU_GPIO_DATA &= ~GPIO_PSC1_4;
} else {
*(vu_long *) MPC5XXX_WU_GPIO_DATA |= GPIO_PSC1_4;
}
#endif
}
#endif /* defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET) */
#ifdef CONFIG_POST
/*
* Reads GPIO pin PSC6_3. A keypress is reported, if PSC6_3 is low. If PSC6_3
* is left open, no keypress is detected.
*/
int post_hotkeys_pressed(void)
{
struct mpc5xxx_gpio *gpio;
gpio = (struct mpc5xxx_gpio*) MPC5XXX_GPIO;
/*
* Configure PSC6_1 and PSC6_3 as GPIO. PSC6 then couldn't be used in
* CODEC or UART mode. Consumer IrDA should still be possible.
*/
gpio->port_config &= ~(0x07000000);
gpio->port_config |= 0x03000000;
/* Enable GPIO for GPIO_IRDA_1 (IR_USB_CLK pin) = PSC6_3 */
gpio->simple_gpioe |= 0x20000000;
/* Configure GPIO_IRDA_1 as input */
gpio->simple_ddr &= ~(0x20000000);
return ((gpio->simple_ival & 0x20000000) ? 0 : 1);
}
#endif
#if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER)
void post_word_store (ulong a)
{
volatile ulong *save_addr =
(volatile ulong *)(MPC5XXX_SRAM + MPC5XXX_SRAM_POST_SIZE);
*save_addr = a;
}
ulong post_word_load (void)
{
volatile ulong *save_addr =
(volatile ulong *)(MPC5XXX_SRAM + MPC5XXX_SRAM_POST_SIZE);
return *save_addr;
}
#endif /* CONFIG_POST || CONFIG_LOGBUFFER*/
#ifdef CONFIG_PS2MULT
#ifdef CONFIG_BOARD_EARLY_INIT_R
int board_early_init_r (void)
{
ps2mult_early_init();
return (0);
}
#endif
#endif /* CONFIG_PS2MULT */
int last_stage_init (void)
{
/*
* auto scan for really existing devices and re-set chip select
* configuration.
*/
u16 save, tmp;
int restore;
/*
* Check for SRAM and SRAM size
*/
/* save original SRAM content */
save = *(volatile u16 *)CFG_CS2_START;
restore = 1;
/* write test pattern to SRAM */
*(volatile u16 *)CFG_CS2_START = 0xA5A5;
__asm__ volatile ("sync");
/*
* Put a different pattern on the data lines: otherwise they may float
* long enough to read back what we wrote.
*/
tmp = *(volatile u16 *)CFG_FLASH_BASE;
if (tmp == 0xA5A5)
puts ("!! possible error in SRAM detection\n");
if (*(volatile u16 *)CFG_CS2_START != 0xA5A5) {
/* no SRAM at all, disable cs */
*(vu_long *)MPC5XXX_ADDECR &= ~(1 << 18);
*(vu_long *)MPC5XXX_CS2_START = 0x0000FFFF;
*(vu_long *)MPC5XXX_CS2_STOP = 0x0000FFFF;
restore = 0;
__asm__ volatile ("sync");
} else if (*(volatile u16 *)(CFG_CS2_START + (1<<19)) == 0xA5A5) {
/* make sure that we access a mirrored address */
*(volatile u16 *)CFG_CS2_START = 0x1111;
__asm__ volatile ("sync");
if (*(volatile u16 *)(CFG_CS2_START + (1<<19)) == 0x1111) {
/* SRAM size = 512 kByte */
*(vu_long *)MPC5XXX_CS2_STOP = STOP_REG(CFG_CS2_START,
0x80000);
__asm__ volatile ("sync");
puts ("SRAM: 512 kB\n");
}
else
puts ("!! possible error in SRAM detection\n");
} else {
puts ("SRAM: 1 MB\n");
}
/* restore origianl SRAM content */
if (restore) {
*(volatile u16 *)CFG_CS2_START = save;
__asm__ volatile ("sync");
}
/*
* Check for Grafic Controller
*/
/* save origianl FB content */
save = *(volatile u16 *)CFG_CS1_START;
restore = 1;
/* write test pattern to FB memory */
*(volatile u16 *)CFG_CS1_START = 0xA5A5;
__asm__ volatile ("sync");
/*
* Put a different pattern on the data lines: otherwise they may float
* long enough to read back what we wrote.
*/
tmp = *(volatile u16 *)CFG_FLASH_BASE;
if (tmp == 0xA5A5)
puts ("!! possible error in grafic controller detection\n");
if (*(volatile u16 *)CFG_CS1_START != 0xA5A5) {
/* no grafic controller at all, disable cs */
*(vu_long *)MPC5XXX_ADDECR &= ~(1 << 17);
*(vu_long *)MPC5XXX_CS1_START = 0x0000FFFF;
*(vu_long *)MPC5XXX_CS1_STOP = 0x0000FFFF;
restore = 0;
__asm__ volatile ("sync");
} else {
puts ("VGA: SMI501 (Voyager) with 8 MB\n");
}
/* restore origianl FB content */
if (restore) {
*(volatile u16 *)CFG_CS1_START = save;
__asm__ volatile ("sync");
}
return 0;
}
#ifdef CONFIG_VIDEO_SM501
#define DISPLAY_WIDTH 640
#define DISPLAY_HEIGHT 480
#ifdef CONFIG_VIDEO_SM501_8BPP
#error CONFIG_VIDEO_SM501_8BPP not supported.
#endif /* CONFIG_VIDEO_SM501_8BPP */
#ifdef CONFIG_VIDEO_SM501_16BPP
#error CONFIG_VIDEO_SM501_16BPP not supported.
#endif /* CONFIG_VIDEO_SM501_16BPP */
#ifdef CONFIG_VIDEO_SM501_32BPP
static const SMI_REGS init_regs [] =
{
#if 0 /* CRT only */
{0x00004, 0x0},
{0x00048, 0x00021807},
{0x0004C, 0x10090a01},
{0x00054, 0x1},
{0x00040, 0x00021807},
{0x00044, 0x10090a01},
{0x00054, 0x0},
{0x80200, 0x00010000},
{0x80204, 0x0},
{0x80208, 0x0A000A00},
{0x8020C, 0x02fa027f},
{0x80210, 0x004a028b},
{0x80214, 0x020c01df},
{0x80218, 0x000201e9},
{0x80200, 0x00013306},
#else /* panel + CRT */
{0x00004, 0x0},
{0x00048, 0x00021807},
{0x0004C, 0x091a0a01},
{0x00054, 0x1},
{0x00040, 0x00021807},
{0x00044, 0x091a0a01},
{0x00054, 0x0},
{0x80000, 0x0f013106},
{0x80004, 0xc428bb17},
{0x8000C, 0x00000000},
{0x80010, 0x0a000a00},
{0x80014, 0x02800000},
{0x80018, 0x01e00000},
{0x8001C, 0x00000000},
{0x80020, 0x01e00280},
{0x80024, 0x02fa027f},
{0x80028, 0x004a028b},
{0x8002C, 0x020c01df},
{0x80030, 0x000201e9},
{0x80200, 0x00010000},
#endif
{0, 0}
};
#endif /* CONFIG_VIDEO_SM501_32BPP */
#ifdef CONFIG_CONSOLE_EXTRA_INFO
/*
* Return text to be printed besides the logo.
*/
void video_get_info_str (int line_number, char *info)
{
if (line_number == 1) {
strcpy (info, " Board: TQM5200 (TQ-Components GmbH)");
#if defined (CONFIG_STK52XX) || defined (CONFIG_TB5200)
} else if (line_number == 2) {
#if defined (CONFIG_STK52XX)
strcpy (info, " on a STK52xx carrier board");
#endif
#if defined (CONFIG_TB5200)
strcpy (info, " on a TB5200 carrier board");
#endif
#endif
}
else {
info [0] = '\0';
}
}
#endif
/*
* Returns SM501 register base address. First thing called in the
* driver. Checks if SM501 is physically present.
*/
unsigned int board_video_init (void)
{
u16 save, tmp;
int restore, ret;
/*
* Check for Grafic Controller
*/
/* save origianl FB content */
save = *(volatile u16 *)CFG_CS1_START;
restore = 1;
/* write test pattern to FB memory */
*(volatile u16 *)CFG_CS1_START = 0xA5A5;
__asm__ volatile ("sync");
/*
* Put a different pattern on the data lines: otherwise they may float
* long enough to read back what we wrote.
*/
tmp = *(volatile u16 *)CFG_FLASH_BASE;
if (tmp == 0xA5A5)
puts ("!! possible error in grafic controller detection\n");
if (*(volatile u16 *)CFG_CS1_START != 0xA5A5) {
/* no grafic controller found */
restore = 0;
ret = 0;
} else {
ret = SM501_MMIO_BASE;
}
if (restore) {
*(volatile u16 *)CFG_CS1_START = save;
__asm__ volatile ("sync");
}
return ret;
}
/*
* Returns SM501 framebuffer address
*/
unsigned int board_video_get_fb (void)
{
return SM501_FB_BASE;
}
/*
* Called after initializing the SM501 and before clearing the screen.
*/
void board_validate_screen (unsigned int base)
{
}
/*
* Return a pointer to the initialization sequence.
*/
const SMI_REGS *board_get_regs (void)
{
return init_regs;
}
int board_get_width (void)
{
return DISPLAY_WIDTH;
}
int board_get_height (void)
{
return DISPLAY_HEIGHT;
}
#endif /* CONFIG_VIDEO_SM501 */
| eldarerathis/FIREFIREFIRE-Multiboot-PoC | board/tqm5200/tqm5200.c | C | gpl-2.0 | 16,892 | [
30522,
1013,
1008,
1008,
1006,
1039,
1007,
9385,
2494,
1011,
2294,
1008,
13865,
7939,
2243,
1010,
7939,
2595,
4007,
3330,
1010,
1059,
2094,
1030,
7939,
2595,
1012,
2139,
1012,
1008,
1008,
1006,
1039,
1007,
9385,
2432,
1008,
2928,
10680,
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... |
<?php
/**
* @package tikiwiki
*/
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id: tiki-view_tracker_item.php 60689 2016-12-16 14:14:38Z xavidp $
$section = 'trackers';
require_once ('tiki-setup.php');
$access->check_feature('feature_trackers');
$trklib = TikiLib::lib('trk');
if ($prefs['feature_categories'] == 'y') {
$categlib = TikiLib::lib('categ');
}
$filegallib = TikiLib::lib('filegal');
$notificationlib = TikiLib::lib('notification');
if ($prefs['feature_groupalert'] == 'y') {
$groupalertlib = TikiLib::lib('groupalert');
}
$auto_query_args = array(
'offset',
'trackerId',
'reloff',
'itemId',
'maxRecords',
'status',
'sort_mode',
'initial',
'filterfield',
'filtervalue',
'view',
'exactvalue'
);
$special = false;
if (!isset($_REQUEST['trackerId']) && $prefs['userTracker'] == 'y' && !isset($_REQUEST['user'])) {
if (isset($_REQUEST['view']) and $_REQUEST['view'] == ' user') {
if (empty($user)) {
$smarty->assign('msg', tra("You are not logged in"));
$smarty->assign('errortype', '402');
$smarty->display("error.tpl");
die;
}
$utid = $userlib->get_tracker_usergroup($user);
if (isset($utid['usersTrackerId'])) {
$_REQUEST['trackerId'] = $utid['usersTrackerId'];
$_REQUEST["itemId"] = $trklib->get_item_id($_REQUEST['trackerId'], $utid['usersFieldId'], $user);
if ($_REQUEST['itemId'] == NULL) {
$addit = array();
$addit[] = array(
'fieldId' => $utid['usersFieldId'],
'type' => 'u',
'value' => $user,
);
$definition = Tracker_Definition::get($_REQUEST['trackerId']);
if ($definition && $f = $definition->getUserField()) {
if ($f != $utid['usersFieldId']) {
$addit[] = array(
'fieldId' => $f,
'type' => 'u',
'value' => $user,
);
}
}
if ($definition && $f = $definition->getWriterGroupField()) {
$addit[] = array(
'fieldId' => $f,
'type' => 'g',
'value' => $group,
);
}
$_REQUEST['itemId'] = $trklib->replace_item($_REQUEST["trackerId"], 0, array('data' => $addit), 'o');
}
$special = 'user';
}
} elseif (isset($_REQUEST["usertracker"]) and $tiki_p_admin == 'y') {
$utid = $userlib->get_tracker_usergroup($_REQUEST['usertracker']);
if (isset($utid['usersTrackerId'])) {
$_REQUEST['trackerId'] = $utid['usersTrackerId'];
$_REQUEST["itemId"] = $trklib->get_item_id($_REQUEST['trackerId'], $utid['usersFieldId'], $_REQUEST["usertracker"]);
}
}
}
if (!isset($_REQUEST['trackerId']) && $prefs['groupTracker'] == 'y') {
if (isset($_REQUEST['view']) and $_REQUEST['view'] == ' group') {
$gtid = $userlib->get_grouptrackerid($group);
if (isset($gtid['groupTrackerId'])) {
$_REQUEST["trackerId"] = $gtid['groupTrackerId'];
$_REQUEST["itemId"] = $trklib->get_item_id($_REQUEST['trackerId'], $gtid['groupFieldId'], $group);
if ($_REQUEST['itemId'] == NULL) {
$addit = array('data' => array(
'fieldId' => $gtid['groupFieldId'],
'type' => 'g',
'value' => $group,
));
$_REQUEST['itemId'] = $trklib->replace_item($_REQUEST["trackerId"], 0, $addit, 'o');
}
$special = 'group';
}
} elseif (isset($_REQUEST["grouptracker"]) and $tiki_p_admin == 'y') {
$gtid = $userlib->get_grouptrackerid($_REQUEST["grouptracker"]);
if (isset($gtid['groupTrackerId'])) {
$_REQUEST["trackerId"] = $gtid['groupTrackerId'];
$_REQUEST["itemId"] = $trklib->get_item_id($_REQUEST['trackerId'], $gtid['groupFieldId'], $_REQUEST["grouptracker"]);
}
}
}
$smarty->assign_by_ref('special', $special);
//url to a user user tracker tiki-view_tracker_item.php?user=yyyyy&view=+user or tiki-view_tracker_item.php?greoup=yyy&user=yyyyy&view=+user or tiki-view_tracker_item.php?trackerId=xxx&user=yyyyy&view=+user
if ($prefs['userTracker'] == 'y' && isset($_REQUEST['view']) && $_REQUEST['view'] = ' user' && !empty($_REQUEST['user'])) {
if (empty($_REQUEST['trackerId']) && empty($_REQUEST['group'])) {
$_REQUEST['group'] = $userlib->get_user_default_group($_REQUEST['user']);
}
if (empty($_REQUEST['trackerId']) && !empty($_REQUEST['group'])) {
$utid = $userlib->get_usertrackerid($_REQUEST['group']);
if (!empty($utid['usersTrackerId']) && !empty($utid['usersFieldId'])) {
$_REQUEST['trackerId'] = $utid['usersTrackerId'];
$fieldId = $utid['usersFieldId'];
}
}
if (!empty($_REQUEST['trackerId']) && empty($fieldId)) {
$definition = Tracker_Definition::get($_REQUEST['trackerId']);
if ($definition) {
$fieldId = $definition->getUserField();
}
}
if (!empty($_REQUEST['trackerId']) && !empty($fieldId)) {
$_REQUEST['itemId'] = $trklib->get_item_id($_REQUEST['trackerId'], $fieldId, $_REQUEST['user']);
if (!$_REQUEST['itemId']) {
$smarty->assign(
'msg',
tra("You don't have a personal tracker item yet. Click here to make one:") .
'<br /><a href="tiki-view_tracker.php?trackerId=' . $_REQUEST['trackerId'] . '&cookietab=2">' .
tra('Create tracker item') . '</a>'
);
$smarty->display("error.tpl");
die;
}
}
}
if ((!isset($_REQUEST["trackerId"]) || !$_REQUEST["trackerId"]) && isset($_REQUEST["itemId"])) {
$item_info = $trklib->get_tracker_item($_REQUEST["itemId"]);
$_REQUEST['trackerId'] = $item_info['trackerId'];
}
if (!isset($_REQUEST["trackerId"]) || !$_REQUEST["trackerId"]) {
$smarty->assign('msg', tra("No tracker indicated"));
$smarty->display("error.tpl");
die;
}
if (isset($_REQUEST["itemId"])) {
$item_info = $trklib->get_tracker_item($_REQUEST["itemId"]);
$currentItemId = $_REQUEST["itemId"];
TikiLib::events()->trigger('tiki.trackeritem.view',
array(
'type' => 'trackeritem',
'object' => $currentItemId,
'owner' => $item_info['createdBy'],
'user' => $GLOBALS['user'],
)
);
}
$definition = Tracker_Definition::get($_REQUEST['trackerId']);
$xfields = array('data' => $definition->getFields());
$smarty->assign('tracker_is_multilingual', $prefs['feature_multilingual'] == 'y' && $definition->getLanguageField());
if (!isset($utid) and !isset($gtid) and (!isset($_REQUEST["itemId"]) or !$_REQUEST["itemId"]) and !isset($_REQUEST["offset"])) {
$smarty->assign('msg', tra("No item indicated"));
$smarty->display("error.tpl");
die;
}
if ($prefs['feature_groupalert'] == 'y') {
$groupforalert = $groupalertlib->GetGroup('tracker', $_REQUEST['trackerId']);
if ($groupforalert != "") {
$showeachuser = $groupalertlib->GetShowEachUser('tracker', $_REQUEST['trackerId'], $groupforalert);
$listusertoalert = $userlib->get_users(0, -1, 'login_asc', '', '', false, $groupforalert, '');
$smarty->assign_by_ref('listusertoalert', $listusertoalert['data']);
}
$smarty->assign_by_ref('groupforalert', $groupforalert);
$smarty->assign_by_ref('showeachuser', $showeachuser);
}
if (!isset($_REQUEST["sort_mode"])) {
$sort_mode = 'created_desc';
} else {
$sort_mode = $_REQUEST["sort_mode"];
}
$smarty->assign_by_ref('sort_mode', $sort_mode);
if (!isset($_REQUEST["offset"])) {
$offset = 0;
} else {
$offset = $_REQUEST["offset"];
}
$smarty->assign_by_ref('offset', $offset);
if (isset($_REQUEST["find"])) {
$find = $_REQUEST["find"];
} else {
$find = '';
}
$smarty->assign('find', $find);
// ************* previous/next **************
foreach (array(
'status',
'filterfield',
'filtervalue',
'initial',
'exactvalue',
'reloff'
) as $reqfld) {
$trynam = 'try' . $reqfld;
if (isset($_REQUEST[$reqfld])) {
$$trynam = $_REQUEST[$reqfld];
} else {
$$trynam = '';
}
}
if (isset($_REQUEST['filterfield'])) {
if (is_array($_REQUEST['filtervalue']) and isset($_REQUEST['filtervalue'][$tryfilterfield])) {
$tryfiltervalue = $_REQUEST['filtervalue'][$tryfilterfield];
} else {
$tryfilterfield = preg_split('/\s*:\s*/', $_REQUEST['filterfield']);
$tryfiltervalue = preg_split('/\s*:\s*/', $_REQUEST['filtervalue']);
$tryexactvalue = preg_split('/\s*:\s*/', $_REQUEST['exactvalue']);
}
}
//*********** handle prev/next links *****************
if (isset($_REQUEST['reloff'])) {
if (isset($_REQUEST['move'])) {
switch ($_REQUEST['move']) {
case 'prev':
$tryreloff+= - 1;
break;
case 'next':
$tryreloff+= 1;
break;
default:
$tryreloff = (int)$_REQUEST['move'];
}
}
$cant = 0;
$listfields = array();
if (substr($sort_mode, 0, 2) == 'f_') { //look at the field in case the field needs some processing to find the sort
list($a, $i, $o) = explode('_', $sort_mode);
foreach ($xfields['data'] as $f) {
if ($f['fieldId'] == $i) {
$listfields = array(
$i => $f
);
break;
}
}
}
if (isset($_REQUEST['cant'])) {
$cant = $_REQUEST['cant'];
} else {
if (is_array($tryfiltervalue)) {
$tryfiltervalue = array_values($tryfiltervalue);
}
$trymove = $trklib->list_items($_REQUEST['trackerId'], $offset + $tryreloff, 1, $sort_mode, $listfields, $tryfilterfield, $tryfiltervalue, $trystatus, $tryinitial, $tryexactvalue);
if (isset($trymove['data'][0]['itemId'])) {
// Autodetect itemId if not specified
if (!isset($_REQUEST['itemId'])) {
$_REQUEST['itemId'] = $trymove['data'][0]['itemId'];
unset($item_info);
}
$cant = $trymove['cant'];
}
}
$smarty->assign('cant', $cant);
}
//*********** that's all for prev/next *****************
$smarty->assign('itemId', $_REQUEST["itemId"]);
if (!isset($item_info)) {
$item_info = $trklib->get_tracker_item($_REQUEST["itemId"]);
if (empty($item_info)) {
$smarty->assign('msg', tra("No item indicated"));
$smarty->display("error.tpl");
die;
}
}
$item_info['logs'] = $trklib->get_item_history($item_info, 0, '', 0, 1);
$smarty->assign_by_ref('item_info', $item_info);
$smarty->assign('item', array('itemId' => $_REQUEST['itemId'], 'trackerId' => $_REQUEST['trackerId']));
$cat_objid = $_REQUEST['itemId'];
$cat_type = 'trackeritem';
$tracker_info = $definition->getInformation();
$itemObject = Tracker_Item::fromInfo($item_info);
if (!isset($tracker_info["writerCanModify"]) or (isset($utid) and ($_REQUEST['trackerId'] != $utid['usersTrackerId']))) {
$tracker_info["writerCanModify"] = 'n';
}
if (!isset($tracker_info["userCanSeeOwn"]) or (isset($utid) and ($_REQUEST['trackerId'] != $utid['usersTrackerId']))) {
$tracker_info["userCanSeeOwn"] = 'n';
}
if (!isset($tracker_info["writerGroupCanModify"]) or (isset($gtid) and ($_REQUEST['trackerId'] != $gtid['groupTrackerId']))) {
$tracker_info["writerGroupCanModify"] = 'n';
}
$tikilib->get_perm_object($_REQUEST['trackerId'], 'tracker', $tracker_info);
if (! $itemObject->canView()) {
$smarty->assign('errortype', 401);
$smarty->assign('msg', tra("Permission denied"));
$smarty->display("error.tpl");
die;
}
if (isset($tracker_info['adminOnlyViewEditItem']) && $tracker_info['adminOnlyViewEditItem'] === 'y') {
$access->check_permission('tiki_p_admin_trackers', tra('Admin this tracker'), 'tracker', $tracker_info['trackerId']);
}
include_once('tiki-sefurl.php');
if (!empty($_REQUEST['moveto']) && $tiki_p_admin_trackers == 'y') { // mo to another tracker fields with same name
$perms = Perms::get('tracker', $_REQUEST['moveto']);
if ($perms->create_tracker_items) {
$trklib->move_item($_REQUEST['trackerId'], $_REQUEST['itemId'], $_REQUEST['moveto']);
header('Location: '.filter_out_sefurl('tiki-view_tracker_item.php?itemId=' . $_REQUEST['itemId']));
exit;
} else {
$smarty->assign('errortype', 401);
$smarty->assign('msg', tra("Permission denied"));
$smarty->display("error.tpl");
die;
}
}
if (isset($_REQUEST["removeattach"])) {
check_ticket('view-trackers-items');
$owner = $trklib->get_item_attachment_owner($_REQUEST["removeattach"]);
if (($user && ($owner == $user)) || ($tiki_p_admin_trackers == 'y')) {
$access->check_authenticity(tra('Are you sure you want to remove this attachment?'));
$trklib->remove_item_attachment($_REQUEST["removeattach"]);
}
}
$status_types = $trklib->status_types();
$smarty->assign('status_types', $status_types);
$fields = array();
$ins_fields = array();
$usecategs = false;
$cookietab = 1;
$itemUsers = $trklib->get_item_creators($_REQUEST['trackerId'], $_REQUEST['itemId']);
$smarty->assign_by_ref('itemUsers', $itemUsers);
$plugins_loaded = false;
if (empty($tracker_info)) {
$item_info = array();
}
$fieldFactory = $definition->getFieldFactory();
foreach ($xfields["data"] as $i => $current_field) {
$fid = $current_field["fieldId"];
$ins_id = 'ins_' . $fid;
$filter_id = 'filter_' . $fid;
$current_field["ins_id"] = $ins_id;
$current_field["filter_id"] = $filter_id;
$xfields['data'][$i] = $current_field;
$current_field_ins = null;
$fieldIsVisible = $itemObject->canViewField($fid);
$fieldIsEditable = $itemObject->canModifyField($fid);
if ($fieldIsVisible || $fieldIsEditable) {
$current_field_ins = $current_field;
$handler = $fieldFactory->getHandler($current_field, $item_info);
if ($handler) {
$insert_values = $handler->getFieldData($_REQUEST);
if ($insert_values) {
$current_field_ins = array_merge($current_field_ins, $insert_values);
}
}
}
if (! empty($current_field_ins)) {
if ($fieldIsEditable) {
$ins_fields['data'][$i] = $current_field_ins;
}
if ($fieldIsVisible) {
$fields['data'][$i] = $current_field_ins;
}
}
}
$authorfield = $definition->getAuthorField();
if ($authorfield) {
$tracker_info['authorindiv'] = $trklib->get_item_value($_REQUEST["trackerId"], $_REQUEST["itemId"], $authorfield);
}
if (! $itemObject->canView()) {
$smarty->assign('errortype', 401);
$smarty->assign('msg', tra("You do not have permission to use this feature"));
$smarty->display("error.tpl");
die;
}
if ($itemObject->canRemove()) {
if (isset($_REQUEST["remove"])) {
check_ticket('view-trackers-items');
$access->check_authenticity(tr('Are you sure you want to permantently delete this item?'));
$trklib->remove_tracker_item($_REQUEST["remove"]);
$access->redirect(filter_out_sefurl('tiki-view_tracker.php?trackerId=' . $_REQUEST['trackerId']));
}
}
$rateFieldId = $definition->getRateField();
if ($itemObject->canModify()) {
if (isset($_REQUEST["save"]) || isset($_REQUEST["save_return"])) {
$captchalib = TikiLib::lib('captcha');
if (empty($user) && $prefs['feature_antibot'] == 'y' && !$captchalib->validate()) {
$smarty->assign('msg', $captchalib->getErrors());
$smarty->assign('errortype', 'no_redirect_login');
$smarty->display("error.tpl");
die;
}
// Check field values for each type and presence of mandatory ones
$mandatory_missing = array();
$err_fields = array();
$categorized_fields = $definition->getCategorizedFields();
$field_errors = $trklib->check_field_values($ins_fields, $categorized_fields, $_REQUEST['trackerId'], empty($_REQUEST['itemId'])?'':$_REQUEST['itemId']);
$smarty->assign('err_mandatory', $field_errors['err_mandatory']);
$smarty->assign('err_value', $field_errors['err_value']);
// values are OK, then lets save the item
if (count($field_errors['err_mandatory']) == 0 && count($field_errors['err_value']) == 0) {
$smarty->assign('input_err', '0'); // no warning to display
if ($prefs['feature_groupalert'] == 'y') {
$groupalertlib->Notify(isset($_REQUEST['listtoalert']) ? $_REQUEST['listtoalert'] : '', "tiki-view_tracker_item.php?itemId=" . $_REQUEST["itemId"]);
}
check_ticket('view-trackers-items');
if (!isset($_REQUEST["edstatus"]) or ($tracker_info["showStatus"] != 'y' and $tiki_p_admin_trackers != 'y')) {
$_REQUEST["edstatus"] = $tracker_info["modItemStatus"];
}
$trklib->replace_item($_REQUEST["trackerId"], $_REQUEST["itemId"], $ins_fields, $_REQUEST["edstatus"]);
if (isset($rateFieldId) && isset($_REQUEST["ins_$rateFieldId"])) {
$trklib->replace_rating($_REQUEST["trackerId"], $_REQUEST["itemId"], $rateFieldId, $user, $_REQUEST["ins_$rateFieldId"]);
}
$_REQUEST['show'] = 'view';
foreach ($fields["data"] as $i => $array) {
if (isset($fields["data"][$i])) {
$fid = $fields["data"][$i]["fieldId"];
$ins_id = 'ins_' . $fid;
$ins_fields["data"][$i]["value"] = '';
}
}
$item_info = $trklib->get_tracker_item($_REQUEST["itemId"]);
$item_info['logs'] = $trklib->get_item_history($item_info, 0, '', 0, 1);
$smarty->assign('item_info', $item_info);
} else {
$error = $ins_fields;
$cookietab = "2";
if ($tracker_info['useAttachments'] == 'y') {
++$cookietab;
}
if ($tracker_info['useComments'] == 'y') {
++$cookietab;
}
$smarty->assign('input_err', '1'); // warning to display
// can't go back if there are errors
if (isset($_REQUEST['save_return'])) {
$_REQUEST['save'] = 'save';
unset($_REQUEST['save_return']);
}
}
if (isset($_REQUEST['save_return']) && isset($_REQUEST['from'])) {
$fromUrl = filter_out_sefurl('tiki-index.php?page=' . urlencode($_REQUEST['from']));
header("Location: {$fromUrl}");
exit;
}
}
}
// remove image from an image field
if (isset($_REQUEST["removeImage"])) {
$img_field = array(
'data' => array()
);
$img_field['data'][] = array(
'fieldId' => $_REQUEST["fieldId"],
'type' => 'i',
'name' => $_REQUEST["fieldName"],
'value' => 'blank'
);
$trklib->replace_item($_REQUEST["trackerId"], $_REQUEST["itemId"], $img_field);
$_REQUEST['show'] = "mod";
}
// ************* return to list ***************************
if (isset($_REQUEST["returntracker"]) || isset($_REQUEST["save_return"])) {
require_once ('lib/smarty_tiki/block.self_link.php');
header(
'Location: ' . smarty_block_self_link(
array(
'_script' => 'tiki-view_tracker.php',
'_tag' => 'n',
'_urlencode' => 'n',
'itemId' => 'NULL',
'trackerId' => $_REQUEST['trackerId']
),
'',
$smarty
)
);
die;
}
// ********************************************************
if (isset($tracker_info['useRatings']) and $tracker_info['useRatings'] == 'y' and $tiki_p_tracker_vote_ratings == 'y') {
if ($user and $tiki_p_tracker_vote_ratings == 'y' and isset($rateFieldId) and isset($_REQUEST['ins_' . $rateFieldId])) {
$trklib->replace_rating($_REQUEST['trackerId'], $_REQUEST['itemId'], $rateFieldId, $user, $_REQUEST['ins_' . $rateFieldId]);
header('Location: tiki-view_tracker_item.php?trackerId=' . $_REQUEST['trackerId'] . '&itemId=' . $_REQUEST['itemId']);
die;
}
}
if ($_REQUEST["itemId"]) {
$info = $trklib->get_tracker_item($_REQUEST["itemId"]);
$itemObject = Tracker_Item::fromInfo($info);
if (!isset($info['trackerId'])) {
$info['trackerId'] = $_REQUEST['trackerId'];
}
if (! $itemObject->canView()) {
$smarty->assign('errortype', 401);
$smarty->assign('msg', tra('Permission denied'));
$smarty->display('error.tpl');
die;
}
$last = array();
$lst = '';
$tracker_item_main_value = '';
$fieldFactory = $definition->getFieldFactory();
foreach ($xfields["data"] as $i => $current_field) {
$current_field_ins = null;
$fid = $current_field['fieldId'];
$handler = $fieldFactory->getHandler($current_field, $info);
$fieldIsVisible = $itemObject->canViewField($fid);
$fieldIsEditable = $itemObject->canModifyField($fid);
if ($fieldIsVisible || $fieldIsEditable) {
$current_field_ins = $current_field;
if ($handler) {
$insert_values = $handler->getFieldData();
if ($insert_values) {
$current_field_ins = array_merge($current_field_ins, $insert_values);
}
}
}
if (! empty($current_field_ins)) {
if ($fieldIsVisible) {
$fields['data'][$i] = $current_field_ins;
}
if ($fieldIsEditable) {
$ins_fields['data'][$i] = $current_field_ins;
}
}
}
$smarty->assign('tracker_item_main_value', $trklib->get_isMain_value($_REQUEST['trackerId'], $_REQUEST['itemId']));
}
//restore types values if there is an error
if (isset($error)) {
foreach ($ins_fields["data"] as $i => $current_field) {
if (isset($error["data"][$i]["value"])) {
$ins_fields["data"][$i]["value"] = $error["data"][$i]["value"];
}
}
}
// dynamic list process
$id_fields = array();
foreach ($xfields['data'] as $sid => $onefield) {
$id_fields[$xfields['data'][$sid]['fieldId']] = $sid;
}
// Pull realname for user.
$info["createdByReal"] = $tikilib->get_user_preference($info["createdBy"], 'realName', '');
$info["lastModifByReal"] = $tikilib->get_user_preference($info["lastModifBy"], 'realName', '');
$smarty->assign('id_fields', $id_fields);
$smarty->assign('trackerId', $_REQUEST["trackerId"]);
$smarty->assign('tracker_info', $tracker_info);
$smarty->assign_by_ref('info', $info);
$smarty->assign_by_ref('fields', $fields["data"]);
$smarty->assign_by_ref('ins_fields', $ins_fields["data"]);
if ($prefs['feature_user_watches'] == 'y' and $tiki_p_watch_trackers == 'y') {
if ($user and isset($_REQUEST['watch'])) {
check_ticket('view-trackers');
if ($_REQUEST['watch'] == 'add') {
$tikilib->add_user_watch($user, 'tracker_item_modified', $_REQUEST["itemId"], 'tracker ' . $_REQUEST["trackerId"], $tracker_info['name'], "tiki-view_tracker_item.php?trackerId=" . $_REQUEST["trackerId"] . "&itemId=" . $_REQUEST["itemId"]);
} else {
$remove_watch_tracker_type = 'tracker ' . $_REQUEST['trackerId'];
$tikilib->remove_user_watch($user, 'tracker_item_modified', $_REQUEST["itemId"], $remove_watch_tracker_type);
}
}
$smarty->assign('user_watching_tracker', 'n');
$it = $tikilib->user_watches($user, 'tracker_item_modified', $_REQUEST['itemId'], 'tracker ' . $_REQUEST["trackerId"]);
if ($user and $tikilib->user_watches($user, 'tracker_item_modified', $_REQUEST['itemId'], 'tracker ' . $_REQUEST["trackerId"])) {
$smarty->assign('user_watching_tracker', 'y');
}
// Check, if the user is watching this trackers' item by a category.
if ($prefs['feature_categories'] == 'y') {
$watching_categories_temp = $categlib->get_watching_categories($_REQUEST['trackerId'], 'tracker', $user);
$smarty->assign('category_watched', 'n');
if (count($watching_categories_temp) > 0) {
$smarty->assign('category_watched', 'y');
$watching_categories = array();
foreach ($watching_categories_temp as $wct) {
$watching_categories[] = array(
"categId" => $wct,
"name" => $categlib->get_category_name($wct)
);
}
$smarty->assign('watching_categories', $watching_categories);
}
}
}
if ($tracker_info['useComments'] == 'y') {
$comCount = $trklib->get_item_nb_comments($_REQUEST["itemId"]);
$smarty->assign("comCount", $comCount);
}
if ($tracker_info["useAttachments"] == 'y') {
if (isset($_REQUEST["removeattach"])) {
$_REQUEST["show"] = "att";
}
if (isset($_REQUEST["editattach"])) {
$att = $trklib->get_item_attachment($_REQUEST["editattach"]);
$smarty->assign("attach_comment", $att['comment']);
$smarty->assign("attach_version", $att['version']);
$smarty->assign("attach_longdesc", $att['longdesc']);
$smarty->assign("attach_file", $att["filename"]);
$smarty->assign("attId", $att["attId"]);
$_REQUEST["show"] = "att";
}
if (isset($_REQUEST['attach']) && $tiki_p_attach_trackers == 'y' && isset($_FILES['userfile1'])) {
// Process an attachment here
if (is_uploaded_file($_FILES['userfile1']['tmp_name'])) {
$fp = fopen($_FILES['userfile1']['tmp_name'], "rb");
$data = '';
$fhash = '';
if ($prefs['t_use_db'] == 'n') {
$fhash = md5($_FILES['userfile1']['name'] . $tikilib->now);
$fw = fopen($prefs['t_use_dir'] . $fhash, "wb");
if (!$fw) {
$smarty->assign('msg', tra('Cannot write to this file:') . $fhash);
$smarty->display("error.tpl");
die;
}
}
while (!feof($fp)) {
if ($prefs['t_use_db'] == 'n') {
$data = fread($fp, 8192 * 16);
fwrite($fw, $data);
} else {
$data.= fread($fp, 8192 * 16);
}
}
fclose($fp);
if ($prefs['t_use_db'] == 'n') {
fclose($fw);
$data = '';
}
$size = $_FILES['userfile1']['size'];
$name = $_FILES['userfile1']['name'];
$type = $_FILES['userfile1']['type'];
} else {
$smarty->assign('msg', $_FILES['userfile1']['name'] . ': ' . tra('Upload was not successful') . ': ' . $tikilib->uploaded_file_error($_FILES['userfile1']['error']));
$smarty->display("error.tpl");
die;
}
$trklib->replace_item_attachment($_REQUEST["attId"], $name, $type, $size, $data, $_REQUEST["attach_comment"], $user, $fhash, $_REQUEST["attach_version"], $_REQUEST["attach_longdesc"], $_REQUEST['trackerId'], $_REQUEST['itemId'], $tracker_info);
$_REQUEST["attId"] = 0;
$_REQUEST['show'] = "att";
}
// If anything below here is changed, please change lib/wiki-plugins/wikiplugin_attach.php as well.
$attextra = 'n';
if (strstr($tracker_info["orderAttachments"], '|')) {
$attextra = 'y';
}
$attfields = explode(',', strtok($tracker_info["orderAttachments"], '|'));
$atts = $trklib->list_item_attachments($_REQUEST["itemId"], 0, -1, 'comment_asc', '');
$smarty->assign('atts', $atts["data"]);
$smarty->assign('attCount', $atts["cant"]);
$smarty->assign('attfields', $attfields);
$smarty->assign('attextra', $attextra);
}
if (isset($_REQUEST['moveto']) && empty($_REQUEST['moveto'])) {
$trackers = $trklib->list_trackers();
$smarty->assign_by_ref('trackers', $trackers['data']);
$_REQUEST['show'] = 'mod';
}
if (isset($_REQUEST['show'])) {
if ($_REQUEST['show'] == 'view') {
$cookietab = 1;
} elseif ($tracker_info["useComments"] == 'y' and $_REQUEST['show'] == 'com') {
$cookietab = 2;
} elseif ($_REQUEST['show'] == "mod") {
$cookietab = 2;
if ($tracker_info["useAttachments"] == 'y') $cookietab++;
if ($tracker_info["useComments"] == 'y' && $tiki_p_tracker_view_comments == 'y') $cookietab++;
} elseif ($_REQUEST['show'] == "att") {
$cookietab = 2;
if ($tracker_info["useComments"] == 'y' && $tiki_p_tracker_view_comments == 'y') $cookietab = 3;
}
}
if (isset($_REQUEST['from'])) {
$from = $_REQUEST['from'];
} else {
$from = false;
}
$smarty->assign('from', $from);
if (isset($_REQUEST['status'])) $smarty->assign_by_ref('status', $_REQUEST['status']);
include_once ('tiki-section_options.php');
$smarty->assign('uses_tabs', 'y');
ask_ticket('view-trackers-items');
if ($prefs['feature_actionlog'] == 'y') {
$logslib = TikiLib::lib('logs');
$logslib->add_action('Viewed', $_REQUEST['itemId'], 'trackeritem');
}
// Generate validation js
if ($prefs['feature_jquery'] == 'y' && $prefs['feature_jquery_validation'] == 'y') {
$validatorslib = TikiLib::lib('validators');
$validationjs = $validatorslib->generateTrackerValidateJS($fields['data']);
$smarty->assign('validationjs', $validationjs);
}
if ($itemObject->canRemove()) {
$smarty->assign('editTitle', tr('Edit/Delete'));
} else {
$smarty->assign('editTitle', tr('Edit'));
}
$smarty->assign('canView', $itemObject->canView());
$smarty->assign('canModify', $itemObject->canModify());
$smarty->assign('canRemove', $itemObject->canRemove());
// Add view/edit template. Override an optional template defined in the tracker by a template passed via request
// Note: Override is only allowed if a default template was set already in the tracker.
// View
$viewItemPretty = array(
'override' => false,
'value' => $tracker_info['viewItemPretty'],
'type' => 'wiki'
);
if (!empty($tracker_info['viewItemPretty'])) {
if (isset($_REQUEST['vi_tpl'])) {
$viewItemPretty['override'] = true;
$viewItemPretty['value'] = $_REQUEST['vi_tpl'];
}
// Need to check wether this is a wiki: or tpl: template, bc the smarty template needs to take care of this
if (strpos(strtolower($viewItemPretty['value']), 'wiki:') === false) {
$viewItemPretty['type'] = 'tpl';
}
}
$smarty->assign('viewItemPretty', $viewItemPretty);
// Edit
$editItemPretty = array(
'override' => false,
'value' => $tracker_info['editItemPretty'],
'type' => 'wiki'
);
if (!empty($tracker_info['editItemPretty'])) {
if (isset($_REQUEST['ei_tpl'])) {
$editItemPretty['override'] = true;
$editItemPretty['value'] = $_REQUEST['ei_tpl'];
}
if (strpos(strtolower($editItemPretty['value']), 'wiki:') === false) {
$editItemPretty['type'] = 'tpl';
}
}
$smarty->assign('editItemPretty', $editItemPretty);
// add referer url to setup the back button in tpl
// check wether we have been called from a different page than ourselfs to save a link to the referer for a back buttom.
// this can be a wikipage with the trackerlist item and and view item temlate set using vi_tpl=wiki:mytemplate
// if we do anything on the current page (i.e. adding a comment) we need to keep that saved link.
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$temp = strtolower($referer);
if (strpos($temp, 'vi_tpl=') || strpos($temp, 'ei_tpl=')) {
$referer = $_SESSION['item_tpl_referer'];
} else {
$_SESSION['item_tpl_referer'] = $referer;
}
unset($temp);
$smarty->assign('referer', $referer);
// Display the template
$smarty->assign('mid', 'tiki-view_tracker_item.tpl');
try {
if (isset($_REQUEST['print'])) {
$smarty->assign('print_page', 'y');
$smarty->display('tiki-print.tpl');
} else {
$smarty->display('tiki.tpl');
}
} catch (SmartyException $e) {
//$message = tr('This element cannot be displayed correctly. One of the view/edit templates is missing or has errors (%0)/(%1). Contact the administrator.', $viewItemPretty['value'], $editItemPretty['value']);
$message = tr('This element cannot be displayed correctly. One of the view/edit templates is missing or has errors. Contact the administrator. (%0)', $e->getMessage());
$smarty->loadPlugin('smarty_modifier_sefurl');
$access->redirect(smarty_modifier_sefurl($info['trackerId'], 'tracker'), $message);
}
| lorddavy/TikiWiki-Improvement-Project | tiki-view_tracker_item.php | PHP | lgpl-2.1 | 29,456 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
1030,
7427,
14841,
3211,
9148,
3211,
1008,
1013,
1013,
1013,
1006,
1039,
1007,
9385,
2526,
1011,
2355,
2011,
6048,
1997,
1996,
14841,
3211,
15536,
3211,
4642,
2015,
2177,
8059,
2622,
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... |
"""Device tracker for Synology SRM routers."""
from __future__ import annotations
import logging
import synology_srm
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA as DEVICE_TRACKER_PLATFORM_SCHEMA,
DeviceScanner,
)
from homeassistant.const import (
CONF_HOST,
CONF_PASSWORD,
CONF_PORT,
CONF_SSL,
CONF_USERNAME,
CONF_VERIFY_SSL,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__)
DEFAULT_USERNAME = "admin"
DEFAULT_PORT = 8001
DEFAULT_SSL = True
DEFAULT_VERIFY_SSL = False
PLATFORM_SCHEMA = DEVICE_TRACKER_PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_HOST): cv.string,
vol.Required(CONF_USERNAME, default=DEFAULT_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
vol.Optional(CONF_SSL, default=DEFAULT_SSL): cv.boolean,
vol.Optional(CONF_VERIFY_SSL, default=DEFAULT_VERIFY_SSL): cv.boolean,
}
)
ATTRIBUTE_ALIAS = {
"band": None,
"connection": None,
"current_rate": None,
"dev_type": None,
"hostname": None,
"ip6_addr": None,
"ip_addr": None,
"is_baned": "is_banned",
"is_beamforming_on": None,
"is_guest": None,
"is_high_qos": None,
"is_low_qos": None,
"is_manual_dev_type": None,
"is_manual_hostname": None,
"is_online": None,
"is_parental_controled": "is_parental_controlled",
"is_qos": None,
"is_wireless": None,
"mac": None,
"max_rate": None,
"mesh_node_id": None,
"rate_quality": None,
"signalstrength": "signal_strength",
"transferRXRate": "transfer_rx_rate",
"transferTXRate": "transfer_tx_rate",
}
def get_scanner(hass: HomeAssistant, config: ConfigType) -> DeviceScanner | None:
"""Validate the configuration and return Synology SRM scanner."""
scanner = SynologySrmDeviceScanner(config[DOMAIN])
return scanner if scanner.success_init else None
class SynologySrmDeviceScanner(DeviceScanner):
"""This class scans for devices connected to a Synology SRM router."""
def __init__(self, config):
"""Initialize the scanner."""
self.client = synology_srm.Client(
host=config[CONF_HOST],
port=config[CONF_PORT],
username=config[CONF_USERNAME],
password=config[CONF_PASSWORD],
https=config[CONF_SSL],
)
if not config[CONF_VERIFY_SSL]:
self.client.http.disable_https_verify()
self.devices = []
self.success_init = self._update_info()
_LOGGER.info("Synology SRM scanner initialized")
def scan_devices(self):
"""Scan for new devices and return a list with found device IDs."""
self._update_info()
return [device["mac"] for device in self.devices]
def get_extra_attributes(self, device) -> dict:
"""Get the extra attributes of a device."""
device = next(
(result for result in self.devices if result["mac"] == device), None
)
filtered_attributes: dict[str, str] = {}
if not device:
return filtered_attributes
for attribute, alias in ATTRIBUTE_ALIAS.items():
if (value := device.get(attribute)) is None:
continue
attr = alias or attribute
filtered_attributes[attr] = value
return filtered_attributes
def get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""
filter_named = [
result["hostname"] for result in self.devices if result["mac"] == device
]
if filter_named:
return filter_named[0]
return None
def _update_info(self):
"""Check the router for connected devices."""
_LOGGER.debug("Scanning for connected devices")
try:
self.devices = self.client.core.get_network_nsm_device({"is_online": True})
except synology_srm.http.SynologyException as ex:
_LOGGER.error("Error with the Synology SRM: %s", ex)
return False
_LOGGER.debug("Found %d device(s) connected to the router", len(self.devices))
return True
| rohitranjan1991/home-assistant | homeassistant/components/synology_srm/device_tracker.py | Python | mit | 4,397 | [
30522,
1000,
1000,
1000,
5080,
27080,
2005,
19962,
6779,
5034,
2213,
2799,
2869,
1012,
1000,
1000,
1000,
2013,
1035,
1035,
2925,
1035,
1035,
12324,
5754,
17287,
9285,
12324,
15899,
12324,
19962,
6779,
1035,
5034,
2213,
12324,
5285,
29441,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
#ifndef HANDLEBARS_HELPERS_H
#define HANDLEBARS_HELPERS_H
#include <functional>
#include <QHash>
#include <QList>
#include <QVariant>
namespace Handlebars {
using escape_fn = std::function< QString (const QString&) >;
class RenderingContext;
class Node;
using helper_params = QVariantList;
using helper_options = QVariantHash;
using helper_fn = std::function<
QVariant (
const RenderingContext & context,
const helper_params & params,
const helper_options & options
)>;
using block_helper_fn = std::function<
void (
RenderingContext & context,
const helper_params & params,
const helper_options & options,
const QList<Node*> & first,
const QList<Node*> & last
)>;
using helpers = QHash< QString, helper_fn >;
using block_helpers = QHash< QString, block_helper_fn >;
}// namespace Handlebars
#endif // HANDLEBARS_HELPERS_H
| mdhooge/qt-handlebars | src/handlebars/HandlebarsHelpers.h | C | mit | 925 | [
30522,
1001,
2065,
13629,
2546,
5047,
8237,
2015,
1035,
2393,
2545,
1035,
1044,
1001,
9375,
5047,
8237,
2015,
1035,
2393,
2545,
1035,
1044,
1001,
2421,
1026,
8360,
1028,
1001,
2421,
1026,
1053,
14949,
2232,
1028,
1001,
2421,
1026,
1053,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
/**
* Class OptionsModel_bwg
*/
class OptionsModel_bwg {
/**
* Set instagram access token.
*
* @param $key
* @return mixed
*/
function set_instagram_access_token( $key = '' ) {
$row = new WD_BWG_Options();
$row->instagram_access_token = $key;
$upd = update_option('wd_bwg_options', json_encode($row));
return $upd;
}
/**
* Get images count.
*
* @return int $imgcount
*/
public function get_image_count() {
global $wpdb;
$imgcount = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "bwg_image");
return $imgcount;
}
/**
* Update gallery options by key.
*
* @param $data_params
*/
public function update_options_by_key( $data_params = array() ) {
$options = get_option( 'wd_bwg_options' );
if ($options) {
$options = json_decode( $options );
foreach( $data_params as $key => $value ) {
$options->$key = $value;
}
update_option( 'wd_bwg_options', json_encode($options), 'yes' );
}
}
} | jolupeza/cbb | wp-content/plugins/photo-gallery/admin/models/Options.php | PHP | gpl-3.0 | 1,077 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
2465,
7047,
5302,
9247,
1035,
1038,
27767,
1008,
1013,
2465,
7047,
5302,
9247,
1035,
1038,
27767,
1063,
1013,
1008,
1008,
1008,
2275,
16021,
23091,
3229,
19204,
1012,
1008,
1008,
1030,
11498... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 <assert.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
// #include <antlr3.h>
#include "toml.h"
#include "toml-parser.h"
// #include "tomlParser.h"
// #include "tomlLexer.h"
struct _TOMLStringifyData {
TOMLError *error;
int bufferSize;
int bufferIndex;
char *buffer;
int tableNameDepth;
int tableNameStackSize;
TOMLString **tableNameStack;
};
int _TOML_stringify( struct _TOMLStringifyData *self, TOMLRef src );
TOMLRef TOML_alloc( TOMLType type ) {
switch ( type ) {
case TOML_TABLE:
return TOML_allocTable( NULL, NULL );
case TOML_ARRAY:
return TOML_allocArray( TOML_NOTYPE );
case TOML_STRING:
return TOML_allocString( "" );
case TOML_INT:
return TOML_allocInt( 0 );
case TOML_DOUBLE:
return TOML_allocDouble( 0 );
case TOML_BOOLEAN:
return TOML_allocBoolean( 0 );
case TOML_DATE:
return TOML_allocEpochDate( 0 );
default:
return NULL;
}
}
TOMLTable * TOML_allocTable( TOMLString *key, TOMLRef value, ... ) {
TOMLTable *self = malloc( sizeof(TOMLTable) );
self->type = TOML_TABLE;
self->keys = TOML_allocArray( TOML_STRING, NULL );
self->values = TOML_allocArray( TOML_NOTYPE, NULL );
if ( key != NULL ) {
TOMLArray_append( self->keys, key );
TOMLArray_append( self->values, value );
} else {
return self;
}
va_list args;
va_start( args, value );
key = va_arg( args, TOMLString * );
while ( key != NULL ) {
value = va_arg( args, TOMLRef );
TOMLArray_append( self->keys, key );
TOMLArray_append( self->values, value );
key = va_arg( args, TOMLString * );
}
va_end( args );
return self;
}
TOMLArray * TOML_allocArray( TOMLType memberType, ... ) {
TOMLArray *self = malloc( sizeof(TOMLArray) );
self->type = TOML_ARRAY;
self->memberType = memberType;
self->size = 0;
self->members = NULL;
va_list args;
va_start( args, memberType );
TOMLRef member = va_arg( args, TOMLRef );
while ( member != NULL ) {
TOMLArray_append( self, member );
member = va_arg( args, TOMLRef );
}
va_end( args );
return self;
}
TOMLString * TOML_allocString( char *content ) {
int size = strlen( content );
TOMLString *self = malloc( sizeof(TOMLString) + size + 1 );
self->type = TOML_STRING;
self->size = size;
self->content[ self->size ] = 0;
strncpy( self->content, content, size );
return self;
}
TOMLString * TOML_allocStringN( char *content, int n ) {
TOMLString *self = malloc( sizeof(TOMLString) + n + 1 );
self->type = TOML_STRING;
self->size = n;
self->content[ n ] = 0;
strncpy( self->content, content, n );
return self;
}
TOMLNumber * TOML_allocInt( int value ) {
TOMLNumber *self = malloc( sizeof(TOMLNumber) );
self->type = TOML_INT;
// self->numberType = TOML_INT;
self->intValue = value;
return self;
}
TOMLNumber * TOML_allocDouble( double value ) {
TOMLNumber *self = malloc( sizeof(TOMLNumber) );
self->type = TOML_DOUBLE;
// self->numberType = TOML_DOUBLE;
self->doubleValue = value;
return self;
}
TOMLBoolean * TOML_allocBoolean( int truth ) {
TOMLBoolean *self = malloc( sizeof(TOMLBoolean) );
self->type = TOML_BOOLEAN;
self->isTrue = truth;
return self;
}
int _TOML_isLeapYear( int year ) {
if ( year % 400 == 0 ) {
return 1;
} else if ( year % 100 == 0 ) {
return 0;
} else if ( year % 4 == 0 ) {
return 1;
} else {
return 0;
}
}
TOMLDate * TOML_allocDate(
int year, int month, int day, int hour, int minute, int second
) {
TOMLDate *self = malloc( sizeof(TOMLDate) );
self->type = TOML_DATE;
self->year = year;
self->month = month;
self->day = day;
self->hour = hour;
self->minute = minute;
self->second = second;
struct tm _time = {
second,
minute,
hour,
day,
month,
year - 1900
};
// local time
time_t localEpoch = mktime( &_time );
// gm time
_time = *gmtime( &localEpoch );
time_t gmEpoch = mktime( &_time );
double diff = difftime( localEpoch, gmEpoch );
// Adjust the localEpock made by mktime to a gmt epoch.
self->sinceEpoch = localEpoch + diff;
return self;
}
TOMLDate * TOML_allocEpochDate( time_t stamp ) {
TOMLDate *self = malloc( sizeof(TOMLDate) );
self->type = TOML_DATE;
self->sinceEpoch = stamp;
struct tm _time = *gmtime( &stamp );
self->second = _time.tm_sec;
self->minute = _time.tm_min;
self->hour = _time.tm_hour;
self->day = _time.tm_mday;
self->month = _time.tm_mon;
self->year = _time.tm_year + 1900;
return self;
}
TOMLError * TOML_allocError( int code ) {
TOMLError *self = malloc( sizeof(TOMLError) );
self->type = TOML_ERROR;
self->code = code;
self->lineNo = 0;
self->line = NULL;
self->message = NULL;
self->fullDescription = NULL;
return self;
}
char * _TOML_cstringCopy( char *str ) {
if ( !str ) {
return NULL;
}
int size = strlen( str );
char *newstr = malloc( size + 1 );
newstr[ size ] = 0;
strncpy( newstr, str, size );
return newstr;
}
TOMLRef TOML_copy( TOMLRef self ) {
TOMLBasic *basic = (TOMLBasic *) self;
if ( basic->type == TOML_TABLE ) {
TOMLTable *table = (TOMLTable *) self;
TOMLTable *newTable = malloc( sizeof(TOMLTable) );
newTable->type = TOML_TABLE;
newTable->keys = TOML_copy( table->keys );
newTable->values = TOML_copy( table->values );
return newTable;
} else if ( basic->type == TOML_ARRAY ) {
TOMLArray *array = (TOMLArray *) self;
TOMLArray *newArray = malloc( sizeof(TOMLArray) );
newArray->type = TOML_ARRAY;
newArray->memberType = array->memberType;
int i;
for ( i = 0; i < array->size; ++i ) {
TOMLArray_append(
newArray,
TOML_copy( TOMLArray_getIndex( array, i ) )
);
}
return newArray;
} else if ( basic->type == TOML_STRING ) {
TOMLString *string = (TOMLString *) self;
TOMLString *newString = malloc( sizeof(TOMLString) + string->size + 1 );
newString->type = TOML_STRING;
newString->size = string->size;
strncpy( newString->content, string->content, string->size + 1 );
return newString;
} else if ( basic->type == TOML_INT || basic->type == TOML_DOUBLE ) {
TOMLNumber *number = (TOMLNumber *) self;
TOMLNumber *newNumber = malloc( sizeof(TOMLNumber) );
newNumber->type = number->type;
// newNumber->numberType = number->numberType;
memcpy( newNumber->bytes, number->bytes, 8 );
return newNumber;
} else if ( basic->type == TOML_BOOLEAN ) {
TOMLBoolean *boolean = (TOMLBoolean *) self;
TOMLBoolean *newBoolean = malloc( sizeof(TOMLBoolean) );
newBoolean->type = boolean->type;
newBoolean->isTrue = boolean->isTrue;
return newBoolean;
} else if ( basic->type == TOML_DATE ) {
TOMLDate *date = (TOMLDate *) self;
TOMLDate *newDate = malloc( sizeof(TOMLDate) );
*newDate = *date;
return newDate;
} else if ( basic->type == TOML_ERROR ) {
TOMLError *error = (TOMLError *) self;
TOMLError *newError = malloc( sizeof(TOMLError) );
newError->type = TOML_ERROR;
newError->code = error->code;
newError->lineNo = error->lineNo;
newError->line = _TOML_cstringCopy( error->line );
newError->message = _TOML_cstringCopy( error->message );
newError->fullDescription = _TOML_cstringCopy( error->fullDescription );
return newError;
} else {
return NULL;
}
}
void TOML_free( TOMLRef self ) {
TOMLBasic *basic = (TOMLBasic *) self;
if ( basic->type == TOML_TABLE ) {
TOMLTable *table = (TOMLTable *) self;
TOML_free( table->keys );
TOML_free( table->values );
} else if ( basic->type == TOML_ARRAY ) {
TOMLArray *array = (TOMLArray *) self;
int i;
for ( i = 0; i < array->size; ++i ) {
TOML_free( array->members[ i ] );
}
free( array->members );
} else if ( basic->type == TOML_ERROR ) {
TOMLError *error = (TOMLError *) self;
free( error->line );
free( error->message );
free( error->fullDescription );
}
free( self );
}
int TOML_isType( TOMLRef self, TOMLType type ) {
TOMLBasic *basic = (TOMLBasic *) self;
return basic->type == type;
}
int TOML_isNumber( TOMLRef self ) {
TOMLBasic *basic = (TOMLBasic *) self;
return basic->type == TOML_INT || basic->type == TOML_DOUBLE;
}
TOMLRef TOML_find( TOMLRef self, ... ) {
TOMLBasic *basic = self;
va_list args;
va_start( args, self );
char *key;
do {
if ( basic->type == TOML_TABLE ) {
key = va_arg( args, char * );
if ( key == NULL ) {
break;
}
basic = self = TOMLTable_getKey( self, key );
} else if ( basic->type == TOML_ARRAY ) {
key = va_arg( args, char * );
if ( key == NULL ) {
break;
}
basic = self = TOMLArray_getIndex( self, atoi( key ) );
} else {
break;
}
} while ( self );
va_end( args );
return self;
}
TOMLRef TOMLTable_getKey( TOMLTable *self, char *key ) {
int keyLength = strlen( key );
int i;
for ( i = 0; i < self->keys->size; ++i ) {
TOMLString *tableKey = TOMLArray_getIndex( self->keys, i );
int minSize = keyLength < tableKey->size ? keyLength : tableKey->size;
if ( strncmp( tableKey->content, key, minSize + 1 ) == 0 ) {
return TOMLArray_getIndex( self->values, i );
}
}
return NULL;
}
void TOMLTable_setKey( TOMLTable *self, char *key, TOMLRef value ) {
int keyLength = strlen( key );
int i;
for ( i = 0; i < self->keys->size; ++i ) {
TOMLString *tableKey = TOMLArray_getIndex( self->keys, i );
int minSize = keyLength < tableKey->size ? keyLength : tableKey->size;
if ( strncmp( tableKey->content, key, minSize ) == 0 ) {
TOMLArray_setIndex( self->values, i, value );
return;
}
}
TOMLArray_append( self->keys, TOML_allocString( key ) );
TOMLArray_append( self->values, value );
}
TOMLRef TOMLArray_getIndex( TOMLArray *self, int index ) {
return self->members && self->size > index ? self->members[ index ] : NULL;
}
void TOMLArray_setIndex( TOMLArray *self, int index, TOMLRef value ) {
if ( index < self->size ) {
TOML_free( self->members[ index ] );
self->members[ index ] = value;
} else {
TOMLArray_append( self, value );
}
}
void TOMLArray_append( TOMLArray *self, TOMLRef value ) {
TOMLRef *oldMembers = self->members;
self->members = malloc( ( self->size + 1 ) * sizeof(TOMLRef) );
int i = 0;
for ( ; i < self->size; ++i ) {
self->members[ i ] = oldMembers[ i ];
}
// memcpy( self->members, oldMembers, self->size * sizeof(TOMLRef) );
self->members[ self->size ] = value;
self->size++;
free( oldMembers );
}
char * TOML_toString( TOMLString *self ) {
char *string = malloc( self->size + 1 );
TOML_copyString( self, self->size + 1, string );
return string;
}
#define RETURN_VALUE switch ( self->type ) { \
case TOML_INT: \
return self->intValue; \
case TOML_DOUBLE: \
return self->doubleValue; \
default: \
return 0; \
}
int TOML_toInt( TOMLNumber *self ) {
RETURN_VALUE;
}
double TOML_toDouble( TOMLNumber *self ) {
RETURN_VALUE;
}
#undef RETURN_VALUE
struct tm TOML_toTm( TOMLDate *self ) {
return *gmtime( &self->sinceEpoch );
}
int TOML_toBoolean( TOMLBoolean *self ) {
return self->isTrue;
}
TOMLToken * TOML_newToken( TOMLToken *token ) {
TOMLToken *heapToken = malloc( sizeof(TOMLToken) );
memcpy( heapToken, token, sizeof(TOMLToken) );
int size = token->end - token->start;
heapToken->tokenStr = malloc( size + 1 );
heapToken->tokenStr[ size ] = 0;
strncpy( heapToken->tokenStr, token->start, size );
return heapToken;
}
void TOML_strcpy( char *buffer, TOMLString *self, int size ) {
if ( self->type != TOML_STRING ) {
buffer[0] = 0;
} else {
strncpy(
buffer, self->content, size < self->size + 1 ? size : self->size + 1
);
}
}
char * _TOML_increaseBuffer( char *oldBuffer, int *size ) {
int newSize = *size + 1024;
char *newBuffer = malloc( newSize + 1 );
// Always have a null terminator so TOMLScan can exit without segfault.
newBuffer[ newSize ] = 0;
if ( oldBuffer ) {
strncpy( newBuffer, oldBuffer, *size + 1 );
free( oldBuffer );
}
*size = newSize;
return newBuffer;
}
int TOML_load( char *filename, TOMLTable **dest, TOMLError *error ) {
assert( *dest == NULL );
FILE *fd = fopen( filename, "r" );
if ( fd == NULL ) {
if ( error ) {
error->code = TOML_ERROR_FILEIO;
error->lineNo = -1;
error->line = NULL;
int messageSize = strlen( TOMLErrorDescription[ error->code ] );
error->message =
malloc( messageSize + 1 );
strcpy( error->message, TOMLErrorDescription[ error->code ] );
error->message[ messageSize ] = 0;
int fullDescSize = messageSize + strlen( filename ) + 8;
error->fullDescription = malloc( fullDescSize + 1 );
snprintf(
error->fullDescription,
fullDescSize,
"%s File: %s",
error->message,
filename
);
}
return TOML_ERROR_FILEIO;
}
int bufferSize = 0;
char * buffer = _TOML_increaseBuffer( NULL, &bufferSize );
int copyBufferSize = 0;
char * copyBuffer = _TOML_increaseBuffer( NULL, ©BufferSize );
int read = fread( buffer, 1, bufferSize, fd );
int incomplete = read == bufferSize;
int hTokenId;
TOMLToken token = { 0, NULL, NULL, buffer, 0, buffer, NULL };
TOMLToken lastToken = token;
TOMLTable *topTable = *dest = TOML_allocTable( NULL, NULL );
TOMLParserState state = { topTable, topTable, 0, error, &token };
pTOMLParser parser = TOMLParserAlloc( malloc );
while (
state.errorCode == 0 && (
TOMLScan( token.end, &hTokenId, &token ) || incomplete
)
) {
while ( token.end >= buffer + bufferSize && incomplete ) {
int lineSize = buffer + bufferSize - lastToken.lineStart;
if ( lastToken.lineStart == buffer ) {
int oldBufferSize = bufferSize;
strncpy( copyBuffer, lastToken.lineStart, lineSize );
buffer = _TOML_increaseBuffer( buffer, &bufferSize );
copyBuffer = _TOML_increaseBuffer( copyBuffer, ©BufferSize );
strncpy( buffer, copyBuffer, lineSize );
} else {
strncpy( copyBuffer, lastToken.lineStart, lineSize );
strncpy( buffer, copyBuffer, lineSize );
}
int read = fread( buffer + lineSize, 1, bufferSize - lineSize, fd );
incomplete = read == bufferSize - lineSize;
if ( !incomplete ) {
buffer[ lineSize + read ] = 0;
}
token = lastToken;
token.end = buffer + ( token.end - token.lineStart );
token.lineStart = buffer;
lastToken = token;
TOMLScan( token.end, &hTokenId, &token );
}
lastToken = token;
int tmpSize = token.end - token.start;
char *tmp = malloc( tmpSize + 1 );
strncpy( tmp, token.start, tmpSize );
tmp[ tmpSize ] = 0;
free( tmp );
TOMLParser( parser, hTokenId, TOML_newToken( &token ), &state );
}
if ( state.errorCode == 0 ) {
TOMLParser( parser, hTokenId, TOML_newToken( &token ), &state );
}
TOMLParserFree( parser, free );
free( copyBuffer );
free( buffer );
fclose( fd );
if ( state.errorCode != 0 ) {
TOML_free( *dest );
*dest = NULL;
return state.errorCode;
}
return 0;
}
// int TOML_dump( char *filename, TOMLTable * );
int TOML_parse( char *buffer, TOMLTable **dest, TOMLError *error ) {
assert( *dest == NULL );
int hTokenId;
TOMLToken token = { 0, NULL, NULL, buffer, 0, buffer, NULL };
TOMLTable *topTable = *dest = TOML_allocTable( NULL, NULL );
TOMLParserState state = { topTable, topTable, 0, error, &token };
pTOMLParser parser = TOMLParserAlloc( malloc );
while ( state.errorCode == 0 && TOMLScan( token.end, &hTokenId, &token ) ) {
TOMLParser( parser, hTokenId, TOML_newToken( &token ), &state );
}
if ( state.errorCode == 0 ) {
TOMLParser( parser, hTokenId, TOML_newToken( &token ), &state );
}
TOMLParserFree( parser, free );
if ( state.errorCode != 0 ) {
TOML_free( *dest );
*dest = NULL;
return state.errorCode;
}
return 0;
}
TOMLString ** _TOML_increaseNameStack(
TOMLString **nameStack, int *nameStackSize
) {
TOMLString **oldStack = nameStack;
int oldSize = *nameStackSize;
*nameStackSize += 16;
nameStack = malloc( *nameStackSize * sizeof(TOMLString *) );
if ( oldStack ) {
memcpy( nameStack, oldStack, oldSize );
free( oldStack );
}
return nameStack;
}
void _TOML_stringifyPushName(
struct _TOMLStringifyData *self, TOMLRef src
) {
if ( self->tableNameDepth >= self->tableNameStackSize ) {
self->tableNameStack = _TOML_increaseNameStack(
self->tableNameStack,
&( self->tableNameStackSize )
);
}
self->tableNameStack[ self->tableNameDepth ] = src;
self->tableNameDepth++;
}
void _TOML_stringifyPopName(
struct _TOMLStringifyData *self
) {
self->tableNameDepth--;
self->tableNameStack[ self->tableNameDepth ] = NULL;
}
void _TOML_stringifyText( struct _TOMLStringifyData *self, char *text, int n ) {
if ( self->bufferIndex + n + 1 >= self->bufferSize ) {
self->buffer = _TOML_increaseBuffer( self->buffer, &self->bufferSize );
}
strncpy( self->buffer + self->bufferIndex, text, n );
self->bufferIndex += n;
self->buffer[ self->bufferIndex ] = 0;
}
void _TOML_stringifyTableHeader(
struct _TOMLStringifyData *self, TOMLTable *table
) {
TOMLBasic *first = TOMLArray_getIndex( table->values, 0 );
if (
!first ||
first->type == TOML_TABLE || (
first->type == TOML_ARRAY &&
((TOMLArray *) first)->memberType == TOML_TABLE
)
) {
return;
}
if ( self->bufferIndex != 0 ) {
_TOML_stringifyText( self, "\n", 1 );
}
_TOML_stringifyText( self, "[", 1 );
for ( int i = 0; i < self->tableNameDepth; ++i ) {
TOMLString *tableName = self->tableNameStack[ i ];
if ( i > 0 ) {
_TOML_stringifyText( self, ".", 1 );
}
_TOML_stringifyText( self, tableName->content, tableName->size );
}
_TOML_stringifyText( self, "]\n", 2 );
}
void _TOML_stringifyArrayHeader( struct _TOMLStringifyData *self ) {
if ( self->bufferIndex != 0 ) {
_TOML_stringifyText( self, "\n", 1 );
}
_TOML_stringifyText( self, "[[", 2 );
for ( int i = 0; i < self->tableNameDepth; ++i ) {
TOMLString *tableName = self->tableNameStack[ i ];
if ( i > 0 ) {
_TOML_stringifyText( self, ".", 1 );
}
_TOML_stringifyText( self, tableName->content, tableName->size );
}
_TOML_stringifyText( self, "]]\n", 3 );
}
void _TOML_stringifyString(
struct _TOMLStringifyData *self, TOMLString *string
) {
char *cursor = string->content;
while ( cursor != NULL ) {
// Scan for escapable character or unicode.
char *next = cursor;
unsigned int ch = *next;
for ( ;
!(
ch == 0 ||
ch == '\b' ||
ch == '\t' ||
ch == '\f' ||
ch == '\n' ||
ch == '\r' ||
ch == '"' ||
ch == '/' ||
ch == '\\' ||
ch > 0x7f
);
next++, ch = *next
) {}
if ( *next == 0 ) {
next = NULL;
}
// Copy text up to character and then insert escaped character.
if ( next ) {
_TOML_stringifyText( self, cursor, next - cursor );
#define REPLACE( match, value ) \
if ( *next == match ) { \
_TOML_stringifyText( self, value, 2 ); \
}
REPLACE( '\b', "\\b" )
else REPLACE( '\t', "\\t" )
else REPLACE( '\f', "\\f" )
else REPLACE( '\n', "\\n" )
else REPLACE( '\r', "\\r" )
else REPLACE( '"', "\\\"" )
else REPLACE( '/', "\\/" )
else REPLACE( '\\', "\\\\" )
#undef REPLACE
else if ( ((unsigned int) *next ) > 0x7f ) {
int num = 0;
int chsize;
// Decode the numeric representation of the utf8 character
if ( ( *next & 0xe0 ) == 0xe0 ) {
chsize = 3;
num =
( ( next[0] & 0x0f ) << 12 ) |
( ( next[1] & 0x3f ) << 6 ) |
( next[2] & 0x3f );
} else if ( ( *next & 0xc0 ) == 0xc0 ) {
chsize = 2;
num =
( ( next[0] & 0x1f ) << 6 ) |
( next[1] & 0x3f );
} else {
assert( 0 );
}
// Stringify \uxxxx
char utf8Buffer[5];
snprintf( utf8Buffer, 5, "%04x", num );
_TOML_stringifyText( self, "\\u", 2 );
_TOML_stringifyText( self, utf8Buffer, 4 );
next += chsize - 1;
}
next++;
// Copy everything up to the end.
} else {
_TOML_stringifyText( self, cursor, strlen( cursor ) );
}
cursor = next;
}
}
void _TOML_stringifyEntry(
struct _TOMLStringifyData *self, TOMLString *key, TOMLBasic *value
) {
_TOML_stringifyText( self, key->content, key->size );
_TOML_stringifyText( self, " = ", 3 );
if ( value->type == TOML_STRING ) {
_TOML_stringifyText( self, "\"", 1 );
_TOML_stringifyString( self, (TOMLString *) value );
_TOML_stringifyText( self, "\"", 1 );
} else {
_TOML_stringify( self, value );
}
_TOML_stringifyText( self, "\n", 1 );
}
int _TOML_stringify(
struct _TOMLStringifyData *self, TOMLRef src
) {
// Cast to TOMLBasic to discover type.
TOMLBasic *basic = src;
// if null
if ( src == NULL ) {
_TOML_stringifyText( self, "(null)", 6 );
// if table
} else if ( basic->type == TOML_TABLE ) {
TOMLTable *table = src;
// loop keys
for ( int i = 0; i < table->keys->size; ++i ) {
TOMLRef key = TOMLArray_getIndex( table->keys, i );
TOMLRef value = TOMLArray_getIndex( table->values, i );
TOMLBasic *basicValue = value;
// if value is table, print header, recurse
if ( basicValue->type == TOML_TABLE ) {
TOMLTable *tableValue = value;
_TOML_stringifyPushName( self, key );
_TOML_stringifyTableHeader( self, value );
_TOML_stringify( self, value );
_TOML_stringifyPopName( self );
// if value is array
} else if ( basicValue->type == TOML_ARRAY ) {
TOMLArray *array = value;
// if value is object array
if ( array->memberType == TOML_TABLE ) {
// loop indices, print headers, recurse
for ( int j = 0; j < array->size; ++j ) {
_TOML_stringifyPushName( self, key );
_TOML_stringifyArrayHeader( self );
_TOML_stringify( self, TOMLArray_getIndex( array, j ) );
_TOML_stringifyPopName( self );
}
} else {
// print entry line with dense (no newlines) array
_TOML_stringifyEntry( self, key, value );
}
} else {
// if value is string or number, print entry
_TOML_stringifyEntry( self, key, value );
}
}
// if array
} else if ( basic->type == TOML_ARRAY ) {
TOMLArray *array = src;
// print array densely
_TOML_stringifyText( self, "[", 1 );
for ( int i = 0; i < array->size; ++i ) {
_TOML_stringifyText( self, " ", 1 );
TOMLBasic *arrayValue = TOMLArray_getIndex( array, i );
if ( arrayValue->type == TOML_STRING ) {
_TOML_stringifyText( self, "\"", 1 );
_TOML_stringifyString( self, (TOMLString *) arrayValue );
_TOML_stringifyText( self, "\"", 1 );
} else {
_TOML_stringify( self, arrayValue );
}
if ( i != array->size - 1 ) {
_TOML_stringifyText( self, ",", 1 );
} else {
_TOML_stringifyText( self, " ", 1 );
}
}
_TOML_stringifyText( self, "]", 1 );
// if string
} else if ( basic->type == TOML_STRING ) {
TOMLString *string = src;
// print string
_TOML_stringifyText( self, string->content, string->size );
// if number
} else if ( TOML_isNumber( basic ) ) {
TOMLNumber *number = src;
char numberBuffer[ 16 ];
memset( numberBuffer, 0, 16 );
int size;
if ( number->type == TOML_INT ) {
size = snprintf( numberBuffer, 15, "%d", number->intValue );
} else if ( fmod( number->doubleValue, 1 ) == 0 ) {
size = snprintf( numberBuffer, 15, "%.1f", number->doubleValue );
} else {
size = snprintf( numberBuffer, 15, "%g", number->doubleValue );
}
// print number
_TOML_stringifyText( self, numberBuffer, size );
} else if ( basic->type == TOML_BOOLEAN ) {
TOMLBoolean *boolean = (TOMLBoolean *) basic;
if ( boolean->isTrue ) {
_TOML_stringifyText( self, "true", 4 );
} else {
_TOML_stringifyText( self, "false", 5 );
}
} else if ( basic->type == TOML_DATE ) {
TOMLDate *date = (TOMLDate *) basic;
char numberBuffer[ 16 ];
int size;
#define STRINGIFY_DATE_SECTION( format, part, spacer ) \
size = snprintf( numberBuffer, 15, format, date->part ); \
_TOML_stringifyText( self, numberBuffer, size ); \
_TOML_stringifyText( self, spacer, 1 )
STRINGIFY_DATE_SECTION( "%d", year, "-" );
STRINGIFY_DATE_SECTION( "%0.2d", month, "-" );
STRINGIFY_DATE_SECTION( "%0.2d", day, "T" );
STRINGIFY_DATE_SECTION( "%0.2d", hour, ":" );
STRINGIFY_DATE_SECTION( "%0.2d", minute, ":" );
STRINGIFY_DATE_SECTION( "%0.2d", second, "Z" );
#undef STRINGIFY_DATE_SECTION
} else {
assert( 0 );
}
// if error
// print error
return 0;
}
int TOML_stringify( char **buffer, TOMLRef src, TOMLError *error ) {
int bufferSize = 0;
char *output = _TOML_increaseBuffer( NULL, &bufferSize );
int stackSize = 0;
TOMLString **tableNameStack = _TOML_increaseNameStack( NULL, &stackSize );
struct _TOMLStringifyData stringifyData = {
error,
bufferSize,
0,
output,
0,
stackSize,
tableNameStack
};
int errorCode = _TOML_stringify( &stringifyData, src );
free( tableNameStack );
*buffer = stringifyData.buffer;
return errorCode;
}
| mzgoddard/tomlc | toml.c | C | mit | 25,919 | [
30522,
1001,
2421,
1026,
20865,
1012,
1044,
1028,
1001,
2421,
1026,
8785,
1012,
1044,
1028,
1001,
2421,
1026,
2358,
7662,
2290,
1012,
1044,
1028,
1001,
2421,
1026,
2358,
20617,
1012,
1044,
1028,
1001,
2421,
1026,
2358,
19422,
12322,
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... |
// vim: set tabstop=4 shiftwidth=4 noexpandtab:
/*
A KIPI plugin to generate HTML image galleries
Copyright 2006 by Aurelien Gateau <aurelien dot gateau at free.fr>
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., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA.
*/
#ifndef WIZARD_H
#define WIZARD_H
// KDE
#include <kassistantdialog.h>
namespace KIPI {
class Interface;
}
namespace KIPIHTMLExport {
class GalleryInfo;
/**
* The wizard used by the user to select the various settings.
*/
class Wizard : public KAssistantDialog {
Q_OBJECT
public:
Wizard(QWidget* parent, GalleryInfo* info, KIPI::Interface*);
~Wizard();
protected Q_SLOTS:
virtual void accept();
private Q_SLOTS:
void updateCollectionSelectorPageValidity();
void updateFinishPageValidity();
void slotThemeSelectionChanged();
void slotHelp();
private:
struct Private;
Private* d;
};
} // namespace
#endif /* WIZARD_H */
| rosedu/digikam-2012-kipi-plugins | htmlexport/wizard.h | C | gpl-2.0 | 1,497 | [
30522,
1013,
1013,
6819,
2213,
1024,
2275,
21628,
16033,
2361,
1027,
1018,
5670,
9148,
11927,
2232,
1027,
1018,
2053,
10288,
9739,
11927,
7875,
1024,
1013,
1008,
1037,
11382,
8197,
13354,
2378,
2000,
9699,
16129,
3746,
11726,
9385,
2294,
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... |
include ../../Library/GNU.mk
Title= libzip
Name= libzip
Version= 0.12.2
Revision= 0
Site= http://nih.at/libzip/
Source= http://nih.at/libzip//$(Name)-$(Version).tar.bz2
License= BSD
LicenseFile= $(SourceDir)/LICENSE
define test_inner_hook
/usr/local/bin/zipcmp -h
/usr/local/bin/zipmerge -h
endef
| FelixZhang00/rudix | Ports/libzip/Makefile | Makefile | bsd-3-clause | 304 | [
30522,
2421,
1012,
1012,
1013,
1012,
1012,
1013,
3075,
1013,
27004,
1012,
12395,
2516,
1027,
5622,
2497,
5831,
2361,
2171,
1027,
5622,
2497,
5831,
2361,
2544,
1027,
1014,
1012,
2260,
1012,
1016,
13921,
1027,
1014,
2609,
1027,
8299,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) 2016. Fengguo (Hugo) Wei and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Detailed contributors are listed in the CONTRIBUTOR.md
*/
import sbt._
object BintrayResolvers {
def jbBintrayResolver(name: String, repo: String, patterns: Patterns): URLRepository =
Resolver.url(name, url(s"http://dl.bintray.com/jetbrains/$repo"))(patterns)
val scalaPluginDeps: URLRepository = jbBintrayResolver("scala-plugin-deps", "scala-plugin-deps", Resolver.ivyStylePatterns)
val allResolvers = Seq(scalaPluginDeps)
}
object CitVersions {
val scalaVersion = "2.12.3"
val sbtVersion = "0.13.13"
val ideaVersion = "172.3757.52"
val sbtStructureVersion = "5.1.2"
val argusSafVersion = "3.1.1"
val jgraphtVersion = "1.0.1"
val json4sVersion = "3.5.0"
}
object Dependencies {
import CitVersions._
val scalaLibrary: ModuleID = "org.scala-lang" % "scala-library" % scalaVersion
val scalaReflect: ModuleID = "org.scala-lang" % "scala-reflect" % scalaVersion
val safLibrary: ModuleID = "com.github.arguslab" %% "saf-library" % argusSafVersion
val jawa: ModuleID = "com.github.arguslab" %% "jawa" % argusSafVersion
val amandroid: ModuleID = "com.github.arguslab" %% "amandroid" % argusSafVersion
val nailgun: ModuleID = "org.jetbrains" % "nailgun-patched" % "1.0.0"
val compilerInterfaceSources: ModuleID = "org.jetbrains" % "compiler-interface-sources" % "1.0.0"
val bundledJline: ModuleID = "org.jetbrains" % "jline" % "1.0.0"
val incrementalCompiler: ModuleID = "org.jetbrains" % "incremental-compiler" % "1.0.0"
val guava: ModuleID = "com.google.guava" % "guava" % "21.0"
val commons_lang3: ModuleID = "org.apache.commons" % "commons-lang3" % "3.5"
val st4: ModuleID = "org.antlr" % "ST4" % "4.0.8"
val antlr4_runtime: ModuleID = "org.antlr" % "antlr4-runtime" % "4.7"
val antlr_runtime: ModuleID = "org.antlr" % "antlr-runtime" % "3.5.2"
val jgrapht_core: ModuleID = "org.jgrapht" % "jgrapht-core" % jgraphtVersion
val jgrapht_ext: ModuleID = "org.jgrapht" % "jgrapht-ext" % jgraphtVersion
val jgraph: ModuleID = "jgraph" % "jgraph" % "5.13.0.0"
val jgraphx: ModuleID = "org.tinyjee.jgraphx" % "jgraphx" % "2.0.0.1"
val asm_all: ModuleID = "org.ow2.asm" % "asm-all" % "5.2"
val ini4j: ModuleID = "org.ini4j" % "ini4j" % "0.5.4"
val json4s_ext: ModuleID = "org.json4s" %% "json4s-ext" % json4sVersion
val json4s_native: ModuleID = "org.json4s" %% "json4s-native" % json4sVersion
val json4s_core: ModuleID = "org.json4s" %% "json4s-core" % json4sVersion
val json4s_ast: ModuleID = "org.json4s" %% "json4s-ast" % json4sVersion
val json4s_scalap: ModuleID = "org.json4s" %% "json4s-scalap" % json4sVersion
val scalaXml: ModuleID = "org.scala-lang.modules" %% "scala-xml" % "1.0.6"
val joda_time: ModuleID = "joda-time" % "joda-time" % "2.9.5"
val joda_convert: ModuleID = "org.joda" % "joda-convert" % "1.8.1"
val paranamer: ModuleID = "com.thoughtworks.paranamer" % "paranamer" % "2.8"
}
object DependencyGroups {
import Dependencies._
val sbtBundled = Seq(
compilerInterfaceSources,
bundledJline,
incrementalCompiler
)
val saf = Seq(
safLibrary
)
val st = Seq(st4, antlr_runtime)
val jgrapht = Seq(
jgrapht_core,
jgrapht_ext,
jgraph,
jgraphx,
antlr4_runtime
)
val jawa_all: Seq[ModuleID] = saf ++ Seq(
jawa,
guava,
commons_lang3,
scalaReflect
) ++ st ++ jgrapht
val json4s = Seq(
json4s_ext,
json4s_native,
json4s_core,
json4s_ast,
json4s_scalap,
joda_time,
joda_convert,
paranamer,
scalaXml
)
val amandroid_all: Seq[ModuleID] = jawa_all ++ Seq(
amandroid,
ini4j
) ++ json4s
val argus_cit: Seq[ModuleID] = Seq(
scalaLibrary
) ++ amandroid_all
val jc: Seq[ModuleID] = Seq(
nailgun
) ++ jawa_all ++ sbtBundled
} | arguslab/argus-cit-intellij | project/Dependencies.scala | Scala | epl-1.0 | 4,071 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2355,
1012,
19004,
12193,
2080,
1006,
9395,
1007,
11417,
1998,
2500,
1012,
1008,
2035,
2916,
9235,
1012,
2023,
2565,
1998,
1996,
10860,
4475,
1008,
2024,
2081,
2800,
2104,
1996,
3408,
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... |
// Copyright (c) 2012 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.
#include "chrome/app/android/chrome_jni_onload.h"
#include "chrome/app/android/chrome_android_initializer.h"
#include "content/public/app/content_jni_onload.h"
namespace android {
bool OnJNIOnLoadInit() {
if (!content::android::OnJNIOnLoadInit())
return false;
return RunChrome();
}
} // namespace android
| endlessm/chromium-browser | chrome/app/android/chrome_jni_onload.cc | C++ | bsd-3-clause | 490 | [
30522,
1013,
1013,
9385,
30524,
6105,
2008,
2064,
2022,
1013,
1013,
2179,
1999,
1996,
6105,
5371,
1012,
1001,
2421,
1000,
18546,
1013,
10439,
1013,
11924,
1013,
18546,
1035,
1046,
3490,
1035,
2006,
11066,
1012,
1044,
1000,
1001,
2421,
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... |
<!-- HTML header for doxygen 1.8.18-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>OR-Tools: VbpParser</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="styleSheet.tmp.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="orLogo.png"/></td>
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">OR-Tools
 <span id="projectnumber">9.2</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(document).ready(function(){initNavTree('classoperations__research_1_1packing_1_1vbp_1_1_vbp_parser.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> |
<a href="classoperations__research_1_1packing_1_1vbp_1_1_vbp_parser-members.html">List of all members</a> </div>
<div class="headertitle"><div class="title">VbpParser</div></div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock">
<p class="definition">Definition at line <a class="el" href="vector__bin__packing__parser_8h_source.html#l00034">34</a> of file <a class="el" href="vector__bin__packing__parser_8h_source.html">vector_bin_packing_parser.h</a>.</p>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a9b0cf9eb09273743d7657981e9d04efd"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classoperations__research_1_1packing_1_1vbp_1_1_vbp_parser.html#a9b0cf9eb09273743d7657981e9d04efd">ParseFile</a> (const std::string &data_filename)</td></tr>
<tr class="separator:a9b0cf9eb09273743d7657981e9d04efd"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:afc652c9faa7a8f5d08585b2c6acfa64b"><td class="memItemLeft" align="right" valign="top">::<a class="el" href="classoperations__research_1_1packing_1_1vbp_1_1_vector_bin_packing_problem.html">operations_research::packing::vbp::VectorBinPackingProblem</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classoperations__research_1_1packing_1_1vbp_1_1_vbp_parser.html#afc652c9faa7a8f5d08585b2c6acfa64b">problem</a> () const</td></tr>
<tr class="separator:afc652c9faa7a8f5d08585b2c6acfa64b"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a9b0cf9eb09273743d7657981e9d04efd" name="a9b0cf9eb09273743d7657981e9d04efd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9b0cf9eb09273743d7657981e9d04efd">◆ </a></span>ParseFile()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool ParseFile </td>
<td>(</td>
<td class="paramtype">const std::string & </td>
<td class="paramname"><em>data_filename</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="vector__bin__packing__parser_8cc_source.html#l00027">27</a> of file <a class="el" href="vector__bin__packing__parser_8cc_source.html">vector_bin_packing_parser.cc</a>.</p>
</div>
</div>
<a id="afc652c9faa7a8f5d08585b2c6acfa64b" name="afc652c9faa7a8f5d08585b2c6acfa64b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afc652c9faa7a8f5d08585b2c6acfa64b">◆ </a></span>problem()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">::<a class="el" href="classoperations__research_1_1packing_1_1vbp_1_1_vector_bin_packing_problem.html">operations_research::packing::vbp::VectorBinPackingProblem</a> problem </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="vector__bin__packing__parser_8h_source.html#l00041">41</a> of file <a class="el" href="vector__bin__packing__parser_8h_source.html">vector_bin_packing_parser.h</a>.</p>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="vector__bin__packing__parser_8h_source.html">vector_bin_packing_parser.h</a></li>
<li><a class="el" href="vector__bin__packing__parser_8cc_source.html">vector_bin_packing_parser.cc</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.18-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="namespaceoperations__research.html">operations_research</a></li><li class="navelem"><a class="el" href="namespaceoperations__research_1_1packing.html">packing</a></li><li class="navelem"><a class="el" href="namespaceoperations__research_1_1packing_1_1vbp.html">vbp</a></li><li class="navelem"><a class="el" href="classoperations__research_1_1packing_1_1vbp_1_1_vbp_parser.html">VbpParser</a></li>
<li class="footer">Generated by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.9.2 </li>
</ul>
</div>
</body>
</html>
| google/or-tools | docs/cpp/classoperations__research_1_1packing_1_1vbp_1_1_vbp_parser.html | HTML | apache-2.0 | 8,476 | [
30522,
1026,
999,
1011,
1011,
16129,
20346,
2005,
2079,
18037,
6914,
1015,
1012,
1022,
1012,
2324,
1011,
1011,
1028,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
11039,
19968,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define('element/locale/hy-AM', ['module', 'exports'], factory);
} else if (typeof exports !== "undefined") {
factory(module, exports);
} else {
var mod = {
exports: {}
};
factory(mod, mod.exports);
global.ELEMENT.lang = global.ELEMENT.lang || {};
global.ELEMENT.lang.hyAM = mod.exports;
}
})(this, function (module, exports) {
'use strict';
exports.__esModule = true;
exports.default = {
el: {
colorpicker: {
confirm: 'Լաւ',
clear: 'Մաքրել'
},
datepicker: {
now: 'Հիմա',
today: 'Այսօր',
cancel: 'Չեղարկել',
clear: 'Մաքրել',
confirm: 'Լաւ',
selectDate: 'Ընտրեք ամսաթիւը',
selectTime: 'Ընտրեք ժամանակը',
startDate: 'Սկզբ. ամսաթիւը',
startTime: 'Սկզբ. ժամանակը',
endDate: 'Վերջ. ամսաթիվը',
endTime: 'Վերջ. ժամանակը',
prevYear: 'Նախորդ տարի',
nextYear: 'Յաջորդ տարի',
prevMonth: 'Նախորդ ամիս',
nextMonth: 'Յաջորդ ամիս',
year: 'Տարի',
month1: 'Յունուար',
month2: 'Փետրուար',
month3: 'Մարտ',
month4: 'Ապրիլ',
month5: 'Մայիս',
month6: 'Յունիս',
month7: 'Յուլիս',
month8: 'Օգոստոս',
month9: 'Սեպտեմբեր',
month10: 'Յոկտեմբեր',
month11: 'Նոյեմբեր',
month12: 'Դեկտեմբեր',
week: 'Շաբաթ',
weeks: {
sun: 'Կիր',
mon: 'Երկ',
tue: 'Եր',
wed: 'Չոր',
thu: 'Հինգ',
fri: 'Ուրբ',
sat: 'Շաբ'
},
months: {
jan: 'Յունվ',
feb: 'Փետ',
mar: 'Մար',
apr: 'Ապր',
may: 'Մայ',
jun: 'Յուն',
jul: 'Յուլ',
aug: 'Օգ',
sep: 'Սեպտ',
oct: 'Յոկ',
nov: 'Նոյ',
dec: 'Դեկ'
}
},
select: {
loading: 'Բեռնում',
noMatch: 'Համապատասխան տուեալներ չկան',
noData: 'Տվյալներ չկան',
placeholder: 'Ընտրել'
},
cascader: {
noMatch: 'Համապատասխան տուեալներ չկան',
loading: 'Բեռնում',
placeholder: 'Ընտրել'
},
pagination: {
goto: 'Անցնել',
pagesize: ' էջում',
total: 'Ընդամենը {total}',
pageClassifier: ''
},
messagebox: {
title: 'Հաղորդագրութիւն',
confirm: 'Լաւ',
cancel: 'Չեղարկել',
error: 'Անվաւեր տուեալների մուտք'
},
upload: {
deleteTip: 'Սեղմեք [Ջնջել] ջնջելու համար',
delete: 'Ջնջել',
preview: 'Նախադիտում',
continue: 'Շարունակել'
},
table: {
emptyText: 'Տուեալներ չկան',
confirmFilter: 'Յաստատել',
resetFilter: 'Վերագործարկել',
clearFilter: 'Բոլորը',
sumText: 'Գումարը'
},
tree: {
emptyText: 'Տուեալներ չկան'
},
transfer: {
noMatch: 'Համապատասխան տուեալներ չկան',
noData: 'Տուեալներ չկան',
titles: ['Ցուցակ 1', 'Ցուցակ 2'],
filterPlaceholder: 'Մուտքագրեք բանալի բառ',
noCheckedFormat: '{total} միաւոր',
hasCheckedFormat: '{checked}/{total} ընտրուած է'
}
}
};
module.exports = exports['default'];
}); | joeyparrish/cdnjs | ajax/libs/element-ui/2.7.2/locale/hy-AM.js | JavaScript | mit | 3,981 | [
30522,
1006,
3853,
1006,
3795,
1010,
4713,
1007,
1063,
2065,
1006,
2828,
11253,
9375,
1027,
1027,
1027,
1000,
3853,
1000,
1004,
1004,
9375,
1012,
2572,
2094,
1007,
1063,
9375,
1006,
1005,
5783,
1013,
2334,
2063,
1013,
1044,
2100,
1011,
25... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
/**
* The template for displaying the footer.
*
* @package WordPress
*/
?>
</div>
</div>
<!-- Begin footer -->
<div id="footer">
<?php
$pp_footer_display_sidebar = get_option('pp_footer_display_sidebar');
if(!empty($pp_footer_display_sidebar))
{
$pp_footer_style = get_option('pp_footer_style');
$footer_class = '';
switch($pp_footer_style)
{
case 1:
$footer_class = 'one';
break;
case 2:
$footer_class = 'two';
break;
case 3:
$footer_class = 'three';
break;
case 4:
$footer_class = 'four';
break;
default:
$footer_class = 'four';
break;
}
?>
<ul class="sidebar_widget <?php echo $footer_class; ?>">
<?php dynamic_sidebar('Footer Sidebar'); ?>
</ul>
<br class="clear"/>
<?php
}
?>
</div>
<!-- End footer -->
<div>
<div>
<div id="copyright" <?php if(empty($pp_footer_display_sidebar)) { echo 'style="border-top:0"'; } ?>>
<div class="copyright_wrapper">
<div class="one_fourth">
<?php
/**
* Get footer left text
*/
$pp_footer_text = get_option('pp_footer_text');
if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
$pp_footer_text = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($pp_footer_text);
}
if(empty($pp_footer_text))
{
$pp_footer_text = 'Copyright © 2012 Nemesis Theme. Powered by <a href="http://wordpress.org/">Wordpress</a>.<br/>Wordpress theme by <a href="http://themeforest.net/user/peerapong/portfolio" target="_blank">Peerapong</a>';
}
echo nl2br(stripslashes(html_entity_decode($pp_footer_text)));
?>
</div>
<div class="one_fourth">
<?php
/**
* Get footer left text
*/
$pp_footer_second_text = get_option('pp_footer_second_text');
if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
$pp_footer_second_text = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($pp_footer_second_text);
}
if(empty($pp_footer_second_text))
{
$pp_footer_second_text = ' ';
}
echo nl2br(stripslashes(html_entity_decode($pp_footer_second_text)));
?>
</div>
<div class="one_fourth">
<?php
/**
* Get footer left text
*/
$pp_footer_third_text = get_option('pp_footer_third_text');
if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
$pp_footer_third_text = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($pp_footer_third_text);
}
if(empty($pp_footer_third_text))
{
$pp_footer_third_text = ' ';
}
echo nl2br(stripslashes(html_entity_decode($pp_footer_third_text)));
?>
</div>
<div class="one_fourth last">
<?php
/**
* Get footer right text
*/
$pp_footer_right_text = get_option('pp_footer_right_text');
if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
$pp_footer_right_text = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($pp_footer_right_text);
}
if(empty($pp_footer_right_text))
{
$pp_footer_right_text = 'All images are copyrighted to their respective owners.';
}
echo nl2br(stripslashes(html_entity_decode($pp_footer_right_text)));
?>
</div>
<br class="clear"/>
</div>
</div>
</div>
</div>
<?php
/**
* Setup Google Analyric Code
**/
include (TEMPLATEPATH . "/google-analytic.php");
?>
<?php
/* Always have wp_footer() just before the closing </body>
* tag of your theme, or you will break many plugins, which
* generally use this hook to reference JavaScript files.
*/
wp_footer();
?>
<?php
$pp_blog_share = get_option('pp_blog_share');
if(!empty($pp_blog_share))
{
?>
<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>
<?php
}
?>
</body>
</html>
| Seizam/atelierweb | wp-content/themes/nemesis/footer.php | PHP | gpl-2.0 | 4,069 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
1996,
23561,
2005,
14962,
1996,
3329,
2121,
1012,
1008,
1008,
1030,
7427,
2773,
20110,
1008,
1013,
1029,
1028,
1026,
1013,
4487,
2615,
1028,
1026,
1013,
4487,
2615,
1028,
1026,
999,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 nu.aron.kataromannumerals;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class RegistryTest {
Registry registry;
@BeforeEach
void setUp() {
// registry = new Registry(empty());
}
@Test
void test() {
System.err.println("One");
Registry.get().stdout();
Registry.add("first");
System.err.println("Two");
Registry.get().stdout();
Registry.add("second");
Registry.add("third");
System.err.println("Three");
Registry.get().stdout();
Registry.remove("second");
System.err.println("Four");
Registry.get().stdout();
}
}
| andreasaronsson/kataromannumerals | src/test/java/nu/aron/kataromannumerals/RegistryTest.java | Java | apache-2.0 | 686 | [
30522,
7427,
16371,
1012,
12098,
2239,
1012,
29354,
21716,
11639,
17897,
7941,
2015,
1025,
12324,
8917,
1012,
12022,
4183,
1012,
13035,
1012,
17928,
1012,
2077,
5243,
2818,
1025,
12324,
8917,
1012,
12022,
4183,
1012,
13035,
1012,
17928,
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... |
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using System.Collections;
using System.IO;
using System.Text;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.Utilities.Encoders;
namespace Org.BouncyCastle.Asn1.Utilities
{
public sealed class Asn1Dump
{
private static readonly string NewLine = Platform.NewLine;
private Asn1Dump()
{
}
private const string Tab = " ";
private const int SampleSize = 32;
/**
* dump a Der object as a formatted string with indentation
*
* @param obj the Asn1Object to be dumped out.
*/
private static void AsString(
string indent,
bool verbose,
Asn1Object obj,
StringBuilder buf)
{
if (obj is Asn1Sequence)
{
string tab = indent + Tab;
buf.Append(indent);
if (obj is BerSequence)
{
buf.Append("BER Sequence");
}
else if (obj is DerSequence)
{
buf.Append("DER Sequence");
}
else
{
buf.Append("Sequence");
}
buf.Append(NewLine);
foreach (Asn1Encodable o in ((Asn1Sequence)obj))
{
if (o == null || o is Asn1Null)
{
buf.Append(tab);
buf.Append("NULL");
buf.Append(NewLine);
}
else
{
AsString(tab, verbose, o.ToAsn1Object(), buf);
}
}
}
else if (obj is DerTaggedObject)
{
string tab = indent + Tab;
buf.Append(indent);
if (obj is BerTaggedObject)
{
buf.Append("BER Tagged [");
}
else
{
buf.Append("Tagged [");
}
DerTaggedObject o = (DerTaggedObject)obj;
buf.Append(((int)o.TagNo).ToString());
buf.Append(']');
if (!o.IsExplicit())
{
buf.Append(" IMPLICIT ");
}
buf.Append(NewLine);
if (o.IsEmpty())
{
buf.Append(tab);
buf.Append("EMPTY");
buf.Append(NewLine);
}
else
{
AsString(tab, verbose, o.GetObject(), buf);
}
}
else if (obj is BerSet)
{
string tab = indent + Tab;
buf.Append(indent);
buf.Append("BER Set");
buf.Append(NewLine);
foreach (Asn1Encodable o in ((Asn1Set)obj))
{
if (o == null)
{
buf.Append(tab);
buf.Append("NULL");
buf.Append(NewLine);
}
else
{
AsString(tab, verbose, o.ToAsn1Object(), buf);
}
}
}
else if (obj is DerSet)
{
string tab = indent + Tab;
buf.Append(indent);
buf.Append("DER Set");
buf.Append(NewLine);
foreach (Asn1Encodable o in ((Asn1Set)obj))
{
if (o == null)
{
buf.Append(tab);
buf.Append("NULL");
buf.Append(NewLine);
}
else
{
AsString(tab, verbose, o.ToAsn1Object(), buf);
}
}
}
else if (obj is DerObjectIdentifier)
{
buf.Append(indent + "ObjectIdentifier(" + ((DerObjectIdentifier)obj).Id + ")" + NewLine);
}
else if (obj is DerBoolean)
{
buf.Append(indent + "Boolean(" + ((DerBoolean)obj).IsTrue + ")" + NewLine);
}
else if (obj is DerInteger)
{
buf.Append(indent + "Integer(" + ((DerInteger)obj).Value + ")" + NewLine);
}
else if (obj is BerOctetString)
{
byte[] octets = ((Asn1OctetString)obj).GetOctets();
string extra = verbose ? dumpBinaryDataAsString(indent, octets) : "";
buf.Append(indent + "BER Octet String" + "[" + octets.Length + "] " + extra + NewLine);
}
else if (obj is DerOctetString)
{
byte[] octets = ((Asn1OctetString)obj).GetOctets();
string extra = verbose ? dumpBinaryDataAsString(indent, octets) : "";
buf.Append(indent + "DER Octet String" + "[" + octets.Length + "] " + extra + NewLine);
}
else if (obj is DerBitString)
{
DerBitString bt = (DerBitString)obj;
byte[] bytes = bt.GetBytes();
string extra = verbose ? dumpBinaryDataAsString(indent, bytes) : "";
buf.Append(indent + "DER Bit String" + "[" + bytes.Length + ", " + bt.PadBits + "] " + extra + NewLine);
}
else if (obj is DerIA5String)
{
buf.Append(indent + "IA5String(" + ((DerIA5String)obj).GetString() + ") " + NewLine);
}
else if (obj is DerUtf8String)
{
buf.Append(indent + "UTF8String(" + ((DerUtf8String)obj).GetString() + ") " + NewLine);
}
else if (obj is DerPrintableString)
{
buf.Append(indent + "PrintableString(" + ((DerPrintableString)obj).GetString() + ") " + NewLine);
}
else if (obj is DerVisibleString)
{
buf.Append(indent + "VisibleString(" + ((DerVisibleString)obj).GetString() + ") " + NewLine);
}
else if (obj is DerBmpString)
{
buf.Append(indent + "BMPString(" + ((DerBmpString)obj).GetString() + ") " + NewLine);
}
else if (obj is DerT61String)
{
buf.Append(indent + "T61String(" + ((DerT61String)obj).GetString() + ") " + NewLine);
}
else if (obj is DerUtcTime)
{
buf.Append(indent + "UTCTime(" + ((DerUtcTime)obj).TimeString + ") " + NewLine);
}
else if (obj is DerGeneralizedTime)
{
buf.Append(indent + "GeneralizedTime(" + ((DerGeneralizedTime)obj).GetTime() + ") " + NewLine);
}
else if (obj is BerApplicationSpecific)
{
buf.Append(outputApplicationSpecific("BER", indent, verbose, (BerApplicationSpecific)obj));
}
else if (obj is DerApplicationSpecific)
{
buf.Append(outputApplicationSpecific("DER", indent, verbose, (DerApplicationSpecific)obj));
}
else if (obj is DerEnumerated)
{
DerEnumerated en = (DerEnumerated)obj;
buf.Append(indent + "DER Enumerated(" + en.Value + ")" + NewLine);
}
else if (obj is DerExternal)
{
DerExternal ext = (DerExternal)obj;
buf.Append(indent + "External " + NewLine);
string tab = indent + Tab;
if (ext.DirectReference != null)
{
buf.Append(tab + "Direct Reference: " + ext.DirectReference.Id + NewLine);
}
if (ext.IndirectReference != null)
{
buf.Append(tab + "Indirect Reference: " + ext.IndirectReference.ToString() + NewLine);
}
if (ext.DataValueDescriptor != null)
{
AsString(tab, verbose, ext.DataValueDescriptor, buf);
}
buf.Append(tab + "Encoding: " + ext.Encoding + NewLine);
AsString(tab, verbose, ext.ExternalContent, buf);
}
else
{
buf.Append(indent + obj.ToString() + NewLine);
}
}
private static string outputApplicationSpecific(
string type,
string indent,
bool verbose,
DerApplicationSpecific app)
{
StringBuilder buf = new StringBuilder();
if (app.IsConstructed())
{
try
{
Asn1Sequence s = Asn1Sequence.GetInstance(app.GetObject(Asn1Tags.Sequence));
buf.Append(indent + type + " ApplicationSpecific[" + app.ApplicationTag + "]" + NewLine);
foreach (Asn1Encodable ae in s)
{
AsString(indent + Tab, verbose, ae.ToAsn1Object(), buf);
}
}
catch (IOException e)
{
buf.Append(e);
}
return buf.ToString();
}
return indent + type + " ApplicationSpecific[" + app.ApplicationTag + "] ("
+ Hex.ToHexString(app.GetContents()) + ")" + NewLine;
}
[Obsolete("Use version accepting Asn1Encodable")]
public static string DumpAsString(
object obj)
{
if (obj is Asn1Encodable)
{
StringBuilder buf = new StringBuilder();
AsString("", false, ((Asn1Encodable)obj).ToAsn1Object(), buf);
return buf.ToString();
}
return "unknown object type " + obj.ToString();
}
/**
* dump out a DER object as a formatted string, in non-verbose mode
*
* @param obj the Asn1Encodable to be dumped out.
* @return the resulting string.
*/
public static string DumpAsString(
Asn1Encodable obj)
{
return DumpAsString(obj, false);
}
/**
* Dump out the object as a string
*
* @param obj the Asn1Encodable to be dumped out.
* @param verbose if true, dump out the contents of octet and bit strings.
* @return the resulting string.
*/
public static string DumpAsString(
Asn1Encodable obj,
bool verbose)
{
StringBuilder buf = new StringBuilder();
AsString("", verbose, obj.ToAsn1Object(), buf);
return buf.ToString();
}
private static string dumpBinaryDataAsString(string indent, byte[] bytes)
{
indent += Tab;
StringBuilder buf = new StringBuilder(NewLine);
for (int i = 0; i < bytes.Length; i += SampleSize)
{
if (bytes.Length - i > SampleSize)
{
buf.Append(indent);
buf.Append(Hex.ToHexString(bytes, i, SampleSize));
buf.Append(Tab);
buf.Append(calculateAscString(bytes, i, SampleSize));
buf.Append(NewLine);
}
else
{
buf.Append(indent);
buf.Append(Hex.ToHexString(bytes, i, bytes.Length - i));
for (int j = bytes.Length - i; j != SampleSize; j++)
{
buf.Append(" ");
}
buf.Append(Tab);
buf.Append(calculateAscString(bytes, i, bytes.Length - i));
buf.Append(NewLine);
}
}
return buf.ToString();
}
private static string calculateAscString(
byte[] bytes,
int off,
int len)
{
StringBuilder buf = new StringBuilder();
for (int i = off; i != off + len; i++)
{
char c = (char)bytes[i];
if (c >= ' ' && c <= '~')
{
buf.Append(c);
}
}
return buf.ToString();
}
}
}
#endif
| magento-hackathon/DashboardVR | VR/UnityProject/Assets/Plugins/Best HTTP (Pro)/BestHTTP/SecureProtocol/asn1/util/Asn1Dump.cs | C# | mit | 13,152 | [
30522,
1001,
2065,
999,
2190,
11039,
25856,
1035,
4487,
19150,
1035,
6585,
1035,
7020,
2140,
1004,
1004,
1006,
999,
8499,
1035,
4773,
23296,
1064,
1064,
8499,
1035,
3559,
1007,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1025,
2478,
2291,
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... |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Ioc.Net")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Ioc.Net")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("f6d4ae6f-4e01-40b2-bc0a-ea8c7eb517d5")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| plantain-00/csharp-demo | Playthings/Ioc.Net/Ioc.Net/Properties/AssemblyInfo.cs | C# | mit | 1,302 | [
30522,
2478,
2291,
1012,
9185,
1025,
2478,
2291,
1012,
2448,
7292,
1012,
21624,
8043,
7903,
2229,
1025,
2478,
2291,
1012,
2448,
7292,
1012,
6970,
11923,
2121,
7903,
2229,
1025,
1013,
1013,
1873,
100,
100,
100,
100,
1916,
100,
100,
1767,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
### Autoscale a VM Scale Set ###
The following template deploys a VM Scale Set integrated with Azure autoscale
The template deploys a VMSS with a desired count of VMs in the scale set. Once the VM Scale Sets is deployed, user can deploy an application inside each of the VMs (either by directly logging into the VMs or via a custom script extension)
The Autoscale rules are configured as follows
- sample for CPU (\\Processor\\PercentProcessorTime) in each VM every 1 Minute
- if the Percent Processor Time is greater than 50% for 5 Minutes, then the scale out action (add more VM instances, one at a time) is triggered
- once the scale out action is completed, the cool down period is 1 Minute
<a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F201-vmss-ubuntu-autoscale%2Fazuredeploy.json" target="_blank">
<img src="http://azuredeploy.net/deploybutton.png"/>
</a>
<br/><br/>
| alibaloch/azure-quickstart-templates | 201-vmss-ubuntu-autoscale/README.md | Markdown | mit | 989 | [
30522,
1001,
1001,
1001,
8285,
15782,
2571,
1037,
1058,
2213,
4094,
2275,
1001,
1001,
1001,
1996,
2206,
23561,
21296,
2015,
1037,
1058,
2213,
4094,
2275,
6377,
2007,
24296,
8285,
15782,
2571,
1996,
23561,
21296,
2015,
1037,
1058,
5244,
2015... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "FileChooser.h"
namespace WebCore {
FileChooserClient::~FileChooserClient()
{
discardChooser();
}
FileChooser* FileChooserClient::newFileChooser(const FileChooserSettings& settings)
{
discardChooser();
m_chooser = FileChooser::create(this, settings);
return m_chooser.get();
}
void FileChooserClient::discardChooser()
{
if (m_chooser)
m_chooser->disconnectClient();
}
inline FileChooser::FileChooser(FileChooserClient* client, const FileChooserSettings& settings)
: m_client(client)
, m_settings(settings)
{
}
PassRefPtr<FileChooser> FileChooser::create(FileChooserClient* client, const FileChooserSettings& settings)
{
return adoptRef(new FileChooser(client, settings));
}
FileChooser::~FileChooser()
{
}
void FileChooser::chooseFile(const String& filename)
{
Vector<String> filenames;
filenames.append(filename);
chooseFiles(filenames);
}
void FileChooser::chooseFiles(const Vector<String>& filenames)
{
// FIXME: This is inelegant. We should not be looking at settings here.
if (m_settings.selectedFiles == filenames)
return;
if (m_client)
m_client->filesChosen(filenames);
}
}
| Treeeater/WebPermission | platform/FileChooser.cpp | C++ | bsd-2-clause | 2,779 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2289,
1010,
2263,
6207,
4297,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
25707,
1998,
2224,
1999,
3120,
1998,
12441,
3596,
1010,
2007,
2030,
2302,
1008,
14080,
1010,
2024,
7936,
3024,
2008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 ProxyPattern;
public class GumballMachineTestDrive {
public static void main(String[] args) {
int count = 0;
if (args .length < 2) {
System.out.println("GumballMachine <name> <inventory>");
System.exit(1);
}
count = Integer.parseInt(args[1]);
GumballMachine gumballMachine = new GumballMachine(args[0], count);
GumballMonitor monitor = new GumballMonitor(gumballMachine);
monitor.report();
}
}
| ohgood/Head-First-Design-Patterns | ProxyPattern/GumballMachineTestDrive.java | Java | gpl-3.0 | 425 | [
30522,
7427,
24540,
4502,
12079,
2078,
1025,
2270,
2465,
16031,
7384,
22911,
14014,
22199,
23663,
1063,
2270,
10763,
11675,
30524,
5620,
1012,
3091,
1026,
1016,
1007,
1063,
2291,
1012,
2041,
1012,
6140,
19666,
1006,
1000,
16031,
7384,
22911,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/*
* RapidMiner
*
* Copyright (C) 2001-2011 by Rapid-I and the contributors
*
* Complete list of developers available at our web site:
*
* http://rapid-i.com
*
* 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.rapidminer.test;
import com.rapidminer.tools.LogService;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
/**
* Extends the JUnit test case by a method for asserting equality of doubles
* with respect to Double.NaN
*
* @author Simon Fischer
*/
public class RapidMinerTestCase extends TestCase {
public RapidMinerTestCase() {
super();
}
public RapidMinerTestCase(String name) {
super(name);
}
@Override
public void setUp() throws Exception {
super.setUp();
LogService.getGlobal().setVerbosityLevel(LogService.WARNING);
}
public void assertEqualsNaN(String message, double expected, double actual) {
if (Double.isNaN(expected)) {
if (!Double.isNaN(actual)) {
throw new AssertionFailedError(message + " expected: <" + expected + "> but was: <" + actual + ">");
}
} else {
assertEquals(message, expected, actual, 0.000000001);
}
}
}
| aborg0/rapidminer-vega | src/com/rapidminer/test/RapidMinerTestCase.java | Java | agpl-3.0 | 1,838 | [
30522,
1013,
1008,
1008,
5915,
11233,
2099,
1008,
1008,
9385,
1006,
1039,
1007,
2541,
1011,
2249,
2011,
5915,
1011,
1045,
1998,
1996,
16884,
1008,
1008,
3143,
2862,
1997,
9797,
2800,
2012,
2256,
4773,
2609,
1024,
1008,
1008,
8299,
1024,
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... |
// SPDX-License-Identifier: GPL-2.0-or-later
/*
*
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdbool.h>
#include "lib/sdp.h"
#include "lib/sdp_lib.h"
#include "lib/uuid.h"
#include "btio/btio.h"
#include "src/adapter.h"
#include "src/device.h"
#include "src/profile.h"
#include "src/service.h"
#include "src/uuid-helper.h"
#include "src/log.h"
#include "hdp_types.h"
#include "hdp_manager.h"
#include "hdp.h"
static int hdp_adapter_probe(struct btd_profile *p,
struct btd_adapter *adapter)
{
return hdp_adapter_register(adapter);
}
static void hdp_adapter_remove(struct btd_profile *p,
struct btd_adapter *adapter)
{
hdp_adapter_unregister(adapter);
}
static int hdp_driver_probe(struct btd_service *service)
{
struct btd_device *device = btd_service_get_device(service);
return hdp_device_register(device);
}
static void hdp_driver_remove(struct btd_service *service)
{
struct btd_device *device = btd_service_get_device(service);
hdp_device_unregister(device);
}
static struct btd_profile hdp_source_profile = {
.name = "hdp-source",
.remote_uuid = HDP_SOURCE_UUID,
.device_probe = hdp_driver_probe,
.device_remove = hdp_driver_remove,
.adapter_probe = hdp_adapter_probe,
.adapter_remove = hdp_adapter_remove,
};
static struct btd_profile hdp_sink_profile = {
.name = "hdp-sink",
.remote_uuid = HDP_SINK_UUID,
.device_probe = hdp_driver_probe,
.device_remove = hdp_driver_remove,
};
int hdp_manager_init(void)
{
if (hdp_manager_start() < 0)
return -1;
btd_profile_register(&hdp_source_profile);
btd_profile_register(&hdp_sink_profile);
return 0;
}
void hdp_manager_exit(void)
{
btd_profile_unregister(&hdp_sink_profile);
btd_profile_unregister(&hdp_source_profile);
hdp_manager_stop();
}
| cktakahasi/bluez | profiles/health/hdp_manager.c | C | gpl-2.0 | 1,891 | [
30522,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
14246,
2140,
1011,
1016,
1012,
1014,
1011,
2030,
1011,
2101,
1013,
1008,
1008,
1008,
2630,
2480,
1011,
2630,
19392,
8778,
9991,
2005,
11603,
1008,
1008,
9385,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-2004, Drew Davidson and Luke Blanshard
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// Neither the name of the Drew Davidson nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//--------------------------------------------------------------------------
package ariba.util.expr;
import java.util.Map;
/**
* Interface for handling null results from Chains.
* Object has the opportunity to substitute an object for the
* null and continue.
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
public interface NullHandler
{
/**
Method called on target returned null.
*/
public Object nullMethodResult(Map context, Object target, String methodName, Object[] args);
/**
Property in target evaluated to null. Property can be a constant
String property name or a DynamicSubscript.
*/
public Object nullPropertyValue(Map context, Object target, Object property);
}
| pascalrobert/aribaweb | src/expr/src/main/java/ariba/util/expr/NullHandler.java | Java | apache-2.0 | 2,451 | [
30522,
1013,
1013,
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... |
#/bin/sh
#set -x
# Script for processing DETdigits.C (or digitITSDET.C) macros
# and generating files with histograms.
# Generated histograms can be then plot with plotDigits2.C.
# Currently the macro has to be run in the directory
# with the aliroot output, and one has to specify the
# number of events and the number of files in the chain
# to be prcessed.
#
# By E.Sicking, CERN; I. Hrivnacova, IPN Orsay
scriptdir=$ALICE_ROOT/test/vmctest/scripts
export NEVENTS=10
export NFILES=4
for DET in SDD SSD SPD TPC TRD TOF EMCAL HMPID PHOS; do
echo Processing $DET digits
aliroot -b -q $scriptdir/digits${DET}.C\($NEVENTS,$NFILES\)
done
| jgrosseo/AliRoot | test/vmctest/scripts/digits.sh | Shell | bsd-3-clause | 647 | [
30522,
1001,
1013,
8026,
1013,
14021,
1001,
2275,
1011,
1060,
1001,
5896,
2005,
6364,
20010,
4305,
23806,
2015,
1012,
1039,
1006,
2030,
15340,
12762,
3207,
2102,
1012,
1039,
1007,
26632,
2015,
1001,
1998,
11717,
6764,
2007,
2010,
3406,
1311... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import pytest
from os import path, remove, sys, urandom
import platform
import uuid
from azure.storage.blob import (
BlobServiceClient,
ContainerClient,
BlobClient,
ContentSettings
)
if sys.version_info >= (3,):
from io import BytesIO
else:
from cStringIO import StringIO as BytesIO
from settings.testcase import BlobPreparer
from devtools_testutils.storage import StorageTestCase
# ------------------------------------------------------------------------------
TEST_BLOB_PREFIX = 'largeblob'
LARGE_BLOB_SIZE = 12 * 1024 * 1024
LARGE_BLOCK_SIZE = 6 * 1024 * 1024
# ------------------------------------------------------------------------------
if platform.python_implementation() == 'PyPy':
pytest.skip("Skip tests for Pypy", allow_module_level=True)
class StorageLargeBlockBlobTest(StorageTestCase):
def _setup(self, storage_account_name, key):
# test chunking functionality by reducing the threshold
# for chunking and the size of each chunk, otherwise
# the tests would take too long to execute
self.bsc = BlobServiceClient(
self.account_url(storage_account_name, "blob"),
credential=key,
max_single_put_size=32 * 1024,
max_block_size=2 * 1024 * 1024,
min_large_block_upload_threshold=1 * 1024 * 1024)
self.config = self.bsc._config
self.container_name = self.get_resource_name('utcontainer')
if self.is_live:
try:
self.bsc.create_container(self.container_name)
except:
pass
def _teardown(self, file_name):
if path.isfile(file_name):
try:
remove(file_name)
except:
pass
# --Helpers-----------------------------------------------------------------
def _get_blob_reference(self):
return self.get_resource_name(TEST_BLOB_PREFIX)
def _create_blob(self):
blob_name = self._get_blob_reference()
blob = self.bsc.get_blob_client(self.container_name, blob_name)
blob.upload_blob(b'')
return blob
def assertBlobEqual(self, container_name, blob_name, expected_data):
blob = self.bsc.get_blob_client(container_name, blob_name)
actual_data = blob.download_blob()
self.assertEqual(b"".join(list(actual_data.chunks())), expected_data)
# --Test cases for block blobs --------------------------------------------
@pytest.mark.live_test_only
@BlobPreparer()
def test_put_block_bytes_large(self, storage_account_name, storage_account_key):
self._setup(storage_account_name, storage_account_key)
blob = self._create_blob()
# Act
for i in range(5):
resp = blob.stage_block(
'block {0}'.format(i).encode('utf-8'), urandom(LARGE_BLOCK_SIZE))
self.assertIsNotNone(resp)
assert 'content_md5' in resp
assert 'content_crc64' in resp
assert 'request_id' in resp
# Assert
@pytest.mark.live_test_only
@BlobPreparer()
def test_put_block_bytes_large_with_md5(self, storage_account_name, storage_account_key):
self._setup(storage_account_name, storage_account_key)
blob = self._create_blob()
# Act
for i in range(5):
resp = blob.stage_block(
'block {0}'.format(i).encode('utf-8'),
urandom(LARGE_BLOCK_SIZE),
validate_content=True)
self.assertIsNotNone(resp)
assert 'content_md5' in resp
assert 'content_crc64' in resp
assert 'request_id' in resp
@pytest.mark.live_test_only
@BlobPreparer()
def test_put_block_stream_large(self, storage_account_name, storage_account_key):
self._setup(storage_account_name, storage_account_key)
blob = self._create_blob()
# Act
for i in range(5):
stream = BytesIO(bytearray(LARGE_BLOCK_SIZE))
resp = resp = blob.stage_block(
'block {0}'.format(i).encode('utf-8'),
stream,
length=LARGE_BLOCK_SIZE)
self.assertIsNotNone(resp)
assert 'content_md5' in resp
assert 'content_crc64' in resp
assert 'request_id' in resp
# Assert
@pytest.mark.live_test_only
@BlobPreparer()
def test_put_block_stream_large_with_md5(self, storage_account_name, storage_account_key):
self._setup(storage_account_name, storage_account_key)
blob = self._create_blob()
# Act
for i in range(5):
stream = BytesIO(bytearray(LARGE_BLOCK_SIZE))
resp = resp = blob.stage_block(
'block {0}'.format(i).encode('utf-8'),
stream,
length=LARGE_BLOCK_SIZE,
validate_content=True)
self.assertIsNotNone(resp)
assert 'content_md5' in resp
assert 'content_crc64' in resp
assert 'request_id' in resp
# Assert
@pytest.mark.live_test_only
@BlobPreparer()
def test_create_large_blob_from_path(self, storage_account_name, storage_account_key):
# parallel tests introduce random order of requests, can only run live
self._setup(storage_account_name, storage_account_key)
blob_name = self._get_blob_reference()
blob = self.bsc.get_blob_client(self.container_name, blob_name)
data = bytearray(urandom(LARGE_BLOB_SIZE))
FILE_PATH = 'large_blob_from_path.temp.{}.dat'.format(str(uuid.uuid4()))
with open(FILE_PATH, 'wb') as stream:
stream.write(data)
# Act
with open(FILE_PATH, 'rb') as stream:
blob.upload_blob(stream, max_concurrency=2, overwrite=True)
block_list = blob.get_block_list()
# Assert
self.assertIsNot(len(block_list), 0)
self.assertBlobEqual(self.container_name, blob_name, data)
self._teardown(FILE_PATH)
@pytest.mark.live_test_only
@BlobPreparer()
def test_create_large_blob_from_path_with_md5(self, storage_account_name, storage_account_key):
# parallel tests introduce random order of requests, can only run live
self._setup(storage_account_name, storage_account_key)
blob_name = self._get_blob_reference()
blob = self.bsc.get_blob_client(self.container_name, blob_name)
data = bytearray(urandom(LARGE_BLOB_SIZE))
FILE_PATH = "blob_from_path_with_md5.temp.dat"
with open(FILE_PATH, 'wb') as stream:
stream.write(data)
# Act
with open(FILE_PATH, 'rb') as stream:
blob.upload_blob(stream, validate_content=True, max_concurrency=2)
# Assert
self.assertBlobEqual(self.container_name, blob_name, data)
self._teardown(FILE_PATH)
@pytest.mark.live_test_only
@BlobPreparer()
def test_create_large_blob_from_path_non_parallel(self, storage_account_name, storage_account_key):
self._setup(storage_account_name, storage_account_key)
blob_name = self._get_blob_reference()
blob = self.bsc.get_blob_client(self.container_name, blob_name)
data = bytearray(self.get_random_bytes(100))
FILE_PATH = "blob_from_path_non_parallel.temp.dat"
with open(FILE_PATH, 'wb') as stream:
stream.write(data)
# Act
with open(FILE_PATH, 'rb') as stream:
blob.upload_blob(stream, max_concurrency=1)
# Assert
self.assertBlobEqual(self.container_name, blob_name, data)
self._teardown(FILE_PATH)
@pytest.mark.live_test_only
@BlobPreparer()
def test_create_large_blob_from_path_with_progress(self, storage_account_name, storage_account_key):
# parallel tests introduce random order of requests, can only run live
self._setup(storage_account_name, storage_account_key)
blob_name = self._get_blob_reference()
blob = self.bsc.get_blob_client(self.container_name, blob_name)
data = bytearray(urandom(LARGE_BLOB_SIZE))
FILE_PATH = "blob_from_path_with_progress.temp.dat"
with open(FILE_PATH, 'wb') as stream:
stream.write(data)
# Act
progress = []
def callback(response):
current = response.context['upload_stream_current']
total = response.context['data_stream_total']
if current is not None:
progress.append((current, total))
with open(FILE_PATH, 'rb') as stream:
blob.upload_blob(stream, max_concurrency=2, raw_response_hook=callback)
# Assert
self.assertBlobEqual(self.container_name, blob_name, data)
self.assert_upload_progress(len(data), self.config.max_block_size, progress)
self._teardown(FILE_PATH)
@pytest.mark.live_test_only
@BlobPreparer()
def test_create_large_blob_from_path_with_properties(self, storage_account_name, storage_account_key):
# parallel tests introduce random order of requests, can only run live
self._setup(storage_account_name, storage_account_key)
blob_name = self._get_blob_reference()
blob = self.bsc.get_blob_client(self.container_name, blob_name)
data = bytearray(urandom(LARGE_BLOB_SIZE))
FILE_PATH = 'blob_from_path_with_properties.temp.{}.dat'.format(str(uuid.uuid4()))
with open(FILE_PATH, 'wb') as stream:
stream.write(data)
# Act
content_settings = ContentSettings(
content_type='image/png',
content_language='spanish')
with open(FILE_PATH, 'rb') as stream:
blob.upload_blob(stream, content_settings=content_settings, max_concurrency=2)
# Assert
self.assertBlobEqual(self.container_name, blob_name, data)
properties = blob.get_blob_properties()
self.assertEqual(properties.content_settings.content_type, content_settings.content_type)
self.assertEqual(properties.content_settings.content_language, content_settings.content_language)
self._teardown(FILE_PATH)
@pytest.mark.live_test_only
@BlobPreparer()
def test_create_large_blob_from_stream_chunked_upload(self, storage_account_name, storage_account_key):
# parallel tests introduce random order of requests, can only run live
self._setup(storage_account_name, storage_account_key)
blob_name = self._get_blob_reference()
blob = self.bsc.get_blob_client(self.container_name, blob_name)
data = bytearray(urandom(LARGE_BLOB_SIZE))
FILE_PATH = 'blob_from_stream_chunked_upload.temp.{}.dat'.format(str(uuid.uuid4()))
with open(FILE_PATH, 'wb') as stream:
stream.write(data)
# Act
with open(FILE_PATH, 'rb') as stream:
blob.upload_blob(stream, max_concurrency=2)
# Assert
self.assertBlobEqual(self.container_name, blob_name, data)
self._teardown(FILE_PATH)
@pytest.mark.live_test_only
@BlobPreparer()
def test_creat_lrgblob_frm_stream_w_progress_chnkd_upload(self, storage_account_name, storage_account_key):
# parallel tests introduce random order of requests, can only run live
self._setup(storage_account_name, storage_account_key)
blob_name = self._get_blob_reference()
blob = self.bsc.get_blob_client(self.container_name, blob_name)
data = bytearray(urandom(LARGE_BLOB_SIZE))
FILE_PATH = 'stream_w_progress_chnkd_upload.temp.{}.dat'.format(str(uuid.uuid4()))
with open(FILE_PATH, 'wb') as stream:
stream.write(data)
# Act
progress = []
def callback(response):
current = response.context['upload_stream_current']
total = response.context['data_stream_total']
if current is not None:
progress.append((current, total))
with open(FILE_PATH, 'rb') as stream:
blob.upload_blob(stream, max_concurrency=2, raw_response_hook=callback)
# Assert
self.assertBlobEqual(self.container_name, blob_name, data)
self.assert_upload_progress(len(data), self.config.max_block_size, progress)
self._teardown(FILE_PATH)
@pytest.mark.live_test_only
@BlobPreparer()
def test_create_large_blob_from_stream_chunked_upload_with_count(self, storage_account_name, storage_account_key):
# parallel tests introduce random order of requests, can only run live
self._setup(storage_account_name, storage_account_key)
blob_name = self._get_blob_reference()
blob = self.bsc.get_blob_client(self.container_name, blob_name)
data = bytearray(urandom(LARGE_BLOB_SIZE))
FILE_PATH = 'chunked_upload_with_count.temp.{}.dat'.format(str(uuid.uuid4()))
with open(FILE_PATH, 'wb') as stream:
stream.write(data)
# Act
blob_size = len(data) - 301
with open(FILE_PATH, 'rb') as stream:
blob.upload_blob(stream, length=blob_size, max_concurrency=2)
# Assert
self.assertBlobEqual(self.container_name, blob_name, data[:blob_size])
self._teardown(FILE_PATH)
@pytest.mark.live_test_only
@BlobPreparer()
def test_creat_lrgblob_frm_strm_chnkd_uplod_w_count_n_props(self, storage_account_name, storage_account_key):
# parallel tests introduce random order of requests, can only run live
self._setup(storage_account_name, storage_account_key)
blob_name = self._get_blob_reference()
blob = self.bsc.get_blob_client(self.container_name, blob_name)
data = bytearray(urandom(LARGE_BLOB_SIZE))
FILE_PATH = 'plod_w_count_n_props.temp.{}.dat'.format(str(uuid.uuid4()))
with open(FILE_PATH, 'wb') as stream:
stream.write(data)
# Act
content_settings = ContentSettings(
content_type='image/png',
content_language='spanish')
blob_size = len(data) - 301
with open(FILE_PATH, 'rb') as stream:
blob.upload_blob(
stream, length=blob_size, content_settings=content_settings, max_concurrency=2)
# Assert
self.assertBlobEqual(self.container_name, blob_name, data[:blob_size])
properties = blob.get_blob_properties()
self.assertEqual(properties.content_settings.content_type, content_settings.content_type)
self.assertEqual(properties.content_settings.content_language, content_settings.content_language)
self._teardown(FILE_PATH)
@pytest.mark.live_test_only
@BlobPreparer()
def test_creat_lrg_blob_frm_stream_chnked_upload_w_props(self, storage_account_name, storage_account_key):
# parallel tests introduce random order of requests, can only run live
self._setup(storage_account_name, storage_account_key)
blob_name = self._get_blob_reference()
blob = self.bsc.get_blob_client(self.container_name, blob_name)
data = bytearray(urandom(LARGE_BLOB_SIZE))
FILE_PATH = 'creat_lrg_blob.temp.{}.dat'.format(str(uuid.uuid4()))
with open(FILE_PATH, 'wb') as stream:
stream.write(data)
# Act
content_settings = ContentSettings(
content_type='image/png',
content_language='spanish')
with open(FILE_PATH, 'rb') as stream:
blob.upload_blob(stream, content_settings=content_settings, max_concurrency=2)
# Assert
self.assertBlobEqual(self.container_name, blob_name, data)
properties = blob.get_blob_properties()
self.assertEqual(properties.content_settings.content_type, content_settings.content_type)
self.assertEqual(properties.content_settings.content_language, content_settings.content_language)
self._teardown(FILE_PATH)
# ------------------------------------------------------------------------------ | Azure/azure-sdk-for-python | sdk/storage/azure-storage-blob/tests/test_large_block_blob.py | Python | mit | 16,306 | [
30522,
1001,
16861,
1024,
21183,
2546,
1011,
1022,
1001,
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,
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... |
// This file is part of zinc64.
// Copyright (c) 2016-2019 Sebastian Jastrzebski. All rights reserved.
// Licensed under the GPLv3. See LICENSE file in the project root for full license text.
use zinc64_core::{Ram, Rom, Shared, SharedCell};
pub struct VicMemory {
base_address: SharedCell<u16>,
charset: Shared<Rom>,
ram: Shared<Ram>,
}
impl VicMemory {
pub fn new(base_address: SharedCell<u16>, charset: Shared<Rom>, ram: Shared<Ram>) -> VicMemory {
VicMemory {
base_address,
charset,
ram,
}
}
pub fn read(&self, address: u16) -> u8 {
let full_address = self.base_address.get() | address;
let zone = full_address >> 12;
match zone {
0x01 => self.charset.borrow().read(full_address - 0x1000),
0x09 => self.charset.borrow().read(full_address - 0x9000),
_ => self.ram.borrow().read(full_address),
}
}
}
| digitalstreamio/zinc64 | zinc64-emu/src/video/vic_memory.rs | Rust | gpl-3.0 | 953 | [
30522,
1013,
1013,
2023,
5371,
2003,
2112,
1997,
15813,
21084,
1012,
1013,
1013,
9385,
1006,
1039,
1007,
2355,
1011,
10476,
6417,
14855,
3367,
15378,
15878,
5488,
1012,
2035,
2916,
9235,
1012,
1013,
1013,
7000,
2104,
1996,
14246,
2140,
2615... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/local/bin/perl -w
=head1 NAME
load_clones_from_fpc.pl - Populates a core Ensembl DB with FPC clone data
=head1 SYNOPSIS
perl load_clones_from_fpc.pl [options] fpc_file
Options:
-h --help
-m --man
-r --registry_file
-s --species
-f --fasta_file
-c --cb_to_bp
-n --no_insert
=head1 OPTIONS
Reads the B<fpc_file>, and uses its clone data to load feature tables
(dna_align_feature at the moment). Should be run after the fpc assembly
has been loaded using the load_assembly_from_fpc.pl script.
B<-h --help>
Print a brief help message and exits.
B<-m --man>
Print man page and exit
B<-r --registry_file>
Use this Ensembl registry file for database connection info.
Default is <ENSEMBLHOME>/conf/ensembl.registry
B<-s --species>
Use this species entry from the registry file [REQUIRED].
B<-f --fasta_file>
Fasta file (GenBank dump) containing sequences for all accessioned
clones [REQUIRED]. TODO: Get sqeuences from GenBank at runtime using
Entrez?
B<-c --cb_to_bp>
Conversion factor to convert native (cb) fpc coordinated into basepairs.
Calculated by hand by comparison with coordinates shown on AGI browser.
Default: 4096.
B<-n --no_insert>
Do not insert anything into the database. I.e. read-only mode.
Useful for debug.
=head1 DESCRIPTION
B<This program>
Populates a core Ensembl DB with FPC clone mappings.
Could do with additional description!
A good place to look for clone sequences is;
/usr/local/data/fpc/<species>/<species>.fpc
Maintained by Will Spooner <whs@ebi.ac.uk>
=cut
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use Data::Dumper qw(Dumper); # For debug
use DBI;
use FindBin qw( $Bin );
use File::Basename qw( dirname );
use vars qw( $BASEDIR );
BEGIN{
# Set the perl libraries
$BASEDIR = dirname($Bin);
unshift @INC, $BASEDIR.'/ensembl-live/ensembl/modules';
unshift @INC, $BASEDIR.'/bioperl-live';
}
use Bio::EnsEMBL::Registry;
use Bio::EnsEMBL::MiscFeature;
use Bio::EnsEMBL::MiscSet;
use Bio::EnsEMBL::Attribute;
use Bio::EnsEMBL::SimpleFeature;
use Bio::EnsEMBL::Analysis;
use Bio::MapIO;
use Bio::SeqIO;
use Bio::EnsEMBL::Map::Marker;
use Bio::EnsEMBL::Map::MarkerSynonym;
use Bio::EnsEMBL::Map::MarkerFeature;
use vars qw( $I $ENS_DBA $FPC_MAP $SCALING_FACTOR $SEQ_IO );
BEGIN{ #Argument Processing
my $help=0;
my $man=0;
my( $species, $file, $cb_to_bp, $fasta_file, $no_insert );
GetOptions
(
"help|?" => \$help,
"man" => \$man,
"species=s" => \$species,
"registry_file=s" => \$file,
"fasta_file=s" => \$fasta_file,
"cb_to_bp=s" => \$cb_to_bp,
"no_insert" => \$no_insert,
) or pod2usage(2);
pod2usage(-verbose => 2) if $man;
pod2usage(1) if $help;
$I = $no_insert ? 0 : 1; # Put stuff in the database?
# CB to BP scaling foctor. Calculated from AGI site.
# Can we get this programatically?
$SCALING_FACTOR = $cb_to_bp || 4096;
# Validate file paths
$file ||= $BASEDIR.'/conf/ensembl.registry';
my $fpc_file = shift @ARGV;
$fpc_file || ( warn( "Need the path to an FPC file\n" ) && pod2usage(1));
$fasta_file || ( warn( "Need a --fasta_file" ) && pod2usage(1));
map{
-e $_ || ( warn( "File $_ does not exist\n" ) && pod2usage(1) );
-r $_ || ( warn( "Cannot read $_\n" ) && pod2usage(1) );
-f $_ || ( warn( "File $_ is not plain-text\n" ) && pod2usage(1) );
-s $_ || ( warn( "File $_ is empty\n" ) && pod2usage(1) );
} $file, $fpc_file, $fasta_file;
# Set the FASTA_FILE
warn( "Found a FASTA file: $fasta_file. Loading...\n" );
$SEQ_IO = Bio::SeqIO->new(-file=>$fasta_file, -format=>'fasta');
# Load the ensembl file
$species || ( warn( "Need a --species\n" ) && pod2usage(1) );
Bio::EnsEMBL::Registry->load_all( $file );
$ENS_DBA = Bio::EnsEMBL::Registry->get_DBAdaptor( $species, 'core' );
$ENS_DBA || ( warn( "No core DB for $species set in $file\n" ) &&
pod2usage(1) );
# Load the FPC file
warn( "Found an FPC file: $fpc_file. Loading...\n" );
my $mapio = new Bio::MapIO(-format => "fpc",
-file => "$fpc_file",
-readcor => 0,
-verbose => 0);
$FPC_MAP = $mapio->next_map(); # Single map per FPC file
}
#warn Dumper( $fpcmap );
#&list_contigs_by_chromosome($fpcmap);
my $meta = $ENS_DBA->get_MetaContainer();
my $species = $meta->get_Species ||
die( "Cannot find the species in the meta table of the DB" );
my $common_name = $species->common_name ||
die( "Cannot find the species common name in the meta table of the DB" );
$common_name = ucfirst( $common_name );
###########
# Prepare some Ensembl adaptors
#my $analysis = &fetch_analysis( $common_name."_BAC_FPC" );
my $marker_analysis = &fetch_analysis( $common_name."_marker" );
my $sl_adapt = $ENS_DBA->get_adaptor('Slice');
my $f_adapt = $ENS_DBA->get_adaptor('SimpleFeature');
my $mf_adapt = $ENS_DBA->get_adaptor('MiscFeature');
###########
# Process the BAC sequence file from GenBank to map clone names to
# accessions
my %accessions_by_name;
my %accessioned_length;
my %all_accessions; # Keep tally for reporting
warn( "Processing fasta file containing accessioned clones" );
while ( my $seq = $SEQ_IO->next_seq() ) {
my $name = $seq->display_name;
my $description = $seq->description;
my( $accession, $version, $clone_name );
if( $name =~ m/^gi\|\d+\|gb\|(\w+)\.(\d+)\|.*$/ ){
# Parse genbank header
$accession = $1;
$version = $2;
$all_accessions{$accession} = 0;
$accessioned_length{$accession} = $seq->length;
$accessions_by_name{$accession} = $accession;
$accessions_by_name{$version} = $accession;
} else {
warn( "Cannot determine accession from $name" );
next;
}
foreach my $clone ( $description =~ /clone ([A-Z]+(\w+))/ ){
# Clone names can be prefixed with library. Try both with and without
$accessions_by_name{$1} = $accession;
$accessions_by_name{$2} = $accession;
}
}
###########
# Establish the different classes of feature. Similar to analysis
my $misc_set_fpc = Bio::EnsEMBL::MiscSet->new
(-code => 'superctgs', # Must conform to Ensembl for display
-name => 'FPC Contig',
-description => '',
-longest_feature => 8000000 );
my $misc_set_bac = Bio::EnsEMBL::MiscSet->new
(-code => 'bac_map', # Must conform to Ensembl for display
-name => 'BAC map',
-description => 'Full list of FPC BAC clones',
-longest_feature => 250000 );
my $misc_set_accbac = Bio::EnsEMBL::MiscSet->new
(-code => 'acc_bac_map', # Must conform to Ensembl for display
-name => 'Accessioned BAC map',
-description => 'List of mapped and accessioned BAC clones',
-longest_feature => 250000 );
###########
# Loop through each FPC contig
foreach my $ctgid( sort $FPC_MAP->each_contigid ){
$ctgid || next; # Skip ctg 0
# last;
# Create a slice from the FPC contig
my $ctg_name = "ctg$ctgid";
my $ctg_slice = $sl_adapt->fetch_by_region(undef,$ctg_name);
$ctg_slice || die( "FPC Contig $ctg_name was not found in the Ensembl DB" );
warn( "Processing $ctg_name at ",$ctg_slice->name );
# Load the FPC as a misc feature
my $fpc_feature = Bio::EnsEMBL::MiscFeature->new
(
-start => $ctg_slice->start,
-end => $ctg_slice->end,
-strand => 1,
-slice => $ctg_slice,
);
my $fpcname_attrib = Bio::EnsEMBL::Attribute->new
(
-VALUE => $ctg_slice->seq_region_name,
-CODE => 'name',
-NAME => 'name'
);
$fpc_feature->add_MiscSet($misc_set_fpc);
$fpc_feature->add_Attribute($fpcname_attrib);
$fpc_feature = $fpc_feature->transform('chromosome');
$mf_adapt->store( $fpc_feature ) if $I;
# Process each clone on FPC
my $ctg = $FPC_MAP->get_contigobj( $ctgid );
my @clones = $ctg->each_cloneid;
warn( " Num clones on $ctg_name: ",scalar(@clones) );
foreach my $cloneid( sort $ctg->each_cloneid ){
my $clone = $FPC_MAP->get_cloneobj( $cloneid );
#my $clone_tmpl = " Clone %s at Ctg %s:%s-%s\n";
#printf( $clone_tmpl, $clone->name, $clone->contigid,
# $clone->range->start, $clone->range->end );
my $start = $SCALING_FACTOR * $clone->range->start;
my $end = $SCALING_FACTOR * $clone->range->end;
my $clone_name = $clone->name;
my $feature = Bio::EnsEMBL::MiscFeature->new
(
-start => $start,
-end => $end,
-strand => 1,
-slice => $ctg_slice,
);
# Populate the feature with a variety of attributes
$feature->add_MiscSet($misc_set_bac);
$feature->add_Attribute( Bio::EnsEMBL::Attribute->new
( -VALUE => $clone_name,
-CODE => 'name',
-NAME => 'name' ) );
$feature->add_Attribute( Bio::EnsEMBL::Attribute->new
( -VALUE => $ctg_name,
-CODE => 'superctg',
-NAME => 'FPC contig name' ) );
$feature->add_Attribute( Bio::EnsEMBL::Attribute->new
( -VALUE => $start,
-CODE => 'inner_start',
-NAME => 'Max start value' ) );
$feature->add_Attribute( Bio::EnsEMBL::Attribute->new
( -VALUE => $end,
-CODE => 'inner_end',
-NAME => 'Min end value' ) );
$feature->add_Attribute( Bio::EnsEMBL::Attribute->new
( -VALUE => $end-$start+1,
-CODE => 'fp_size',
-NAME => 'FP size' ) );
if( my $acc = $accessions_by_name{$clone_name} ){
# This is an accessioned clone
$all_accessions{$acc} ++;
$feature->add_MiscSet($misc_set_accbac);
$feature->add_Attribute( Bio::EnsEMBL::Attribute->new
( -CODE => 'state',
-NAME => 'Current state of clone',
-VALUE => '12:Accessioned' ) );
$feature->add_Attribute( Bio::EnsEMBL::Attribute->new
( -CODE => 'embl_acc',
-NAME => 'Accession number',
-VALUE => "$acc" ) );
$feature->add_Attribute( Bio::EnsEMBL::Attribute->new
( -CODE => 'seq_len',
-NAME => 'Accession length',
-VALUE => $accessioned_length{$acc} ) );
} else {
# This is a free-state clone
$feature->add_Attribute( Bio::EnsEMBL::Attribute->new
( -CODE => 'state',
-NAME => 'Current state of clone',
-VALUE => '06:Free' ) );
}
# Store
$feature = $feature->transform('chromosome');
$mf_adapt->store( $feature ) if $I;
}
}
###########
# Loop through each marker.
my $marker_feature_adaptor = $ENS_DBA->get_adaptor('MarkerFeature');
my $marker_adaptor = $ENS_DBA->get_adaptor('Marker');
my @markers = $FPC_MAP->each_markerid();
warn( " Num markers: ",scalar(@markers) );
foreach my $marker( @markers ){
# last;
my $markerobj = $FPC_MAP->get_markerobj($marker);
my $type = $markerobj->type; # STS, eMRK, Probe, OVERGO
my $ensmarker = Bio::EnsEMBL::Map::Marker->new();
$ensmarker->display_MarkerSynonym
( Bio::EnsEMBL::Map::MarkerSynonym->new(undef,$type,$marker) );
$ensmarker->priority(100); #Ensure marker displays
# get all the contigs where this marker hit
my @contigs = $markerobj->each_contigid();
foreach my $ctgid( @contigs ) {
$ctgid || next; # Skip empty contig
# Create a slice from the FPC contig
my $ctg_name = "ctg$ctgid";
my $ctg_slice = $sl_adapt->fetch_by_region(undef,$ctg_name);
$ctg_slice || die( "FPC $ctg_name was not found in the Ensembl DB" );
# Create the marker feature
my $maploc = $markerobj->position($ctgid);
my $marker_feature = Bio::EnsEMBL::Map::MarkerFeature->new
(
undef, #DBid
undef, #MarkerFeatureAdaptor
$maploc * $SCALING_FACTOR, # Start
($maploc+1) * $SCALING_FACTOR, # End - assume length=SCALING_FACTOR
$ctg_slice, # Slice
$marker_analysis, # Analysis
undef, # Marker ID?
scalar( @contigs ), # map weight
$ensmarker, # Ensembl Marker
);
$marker_feature = $marker_feature->transform('chromosome') ||
( warn("No chr mapping for $marker!") && next );
$marker_feature_adaptor->store( $marker_feature ) if $I;
}
}
warn( "Found ", scalar( grep{$_} values %all_accessions ),
" accessioned clones in FPC\n" );
warn( "Lost ", scalar( grep{! $_} values %all_accessions ),
" accessioned clones from FPC\n" );
exit;
#======================================================================
sub list_contigs_by_chromosome{
my $FPC_MAP = shift;
my %chr_data;
my %lengths;
my $scaler = $SCALING_FACTOR || 4096;
foreach my $ctgname( $FPC_MAP->each_contigid ){
$ctgname || next; # Skip empty
my $ctgobj = $FPC_MAP->get_contigobj($ctgname);
my $ctgpos = $ctgobj->position+0 || 0;
my $ctgstart = $ctgobj->range->start || 0;
my $ctgend = $ctgobj->range->end || 0;
my $ctgbasepair = $ctgend * $scaler;
my $chr = $ctgobj->group || '';
$chr_data{$chr} ||= [];
push @{$chr_data{$chr}}, [ $ctgname,
sprintf( "%.2f", $ctgpos ),
#$ctgstart,
$ctgend ,
$ctgbasepair,
];
my $l_n = length($ctgname);
my $l_p = length($ctgpos);
my $l_s = length($ctgstart);
my $l_e = length($ctgend);
my $l_b = length($ctgbasepair);
if( $l_n > ($lengths{name} ||0) ){ $lengths{name} = $l_n }
if( $l_p > ($lengths{pos} ||0) ){ $lengths{pos} = $l_p }
if( $l_s > ($lengths{start}||0) ){ $lengths{start}= $l_s }
if( $l_e > ($lengths{end} ||0) ){ $lengths{end} = $l_e }
if( $l_b > ($lengths{bp} ||0) ){ $lengths{bp} = $l_b }
}
my $num_per_line = 3;
$lengths{name} += 3; # Allow for ctg prefix
my $entry_t = join( " ",
"|",
"%-${lengths{name}}s",
"%${lengths{pos}}s",
#"%${lengths{start}}s",
"%${lengths{end}}s",
"%${lengths{bp}}s",
"|" );
my $tmpl = " ". ( $entry_t x $num_per_line ) . "\n";
# Loop through each chromosome and print FPC data
foreach my $chr( sort{$a<=>$b} keys %chr_data ){
my @ctgs = sort{$a->[0]<=>$b->[0]} @{$chr_data{$chr}};
map{ $_->[0] = "Ctg".$_->[0] } @ctgs;
my $total_length = 0;
map{ $total_length += $_->[3] } @ctgs;
my $num_ctgs = scalar( @ctgs );
print( "Chr: $chr ($num_ctgs FPCs, $total_length bp)\n" );
while( my @entries = splice( @ctgs, 0, $num_per_line ) ){
my @data = ( map{defined($_) ? $_ : ''}
map{@{$entries[$_-1]||[]}[0..3]}
(1..$num_per_line) );
#warn Dumper( @data );
printf( $tmpl, @data );
}
}
}
#======================================================================
# Returns an Analysis object; either fetched from the DB if one exists,
# or created fresh, in which case it is stored to the DB.
sub fetch_analysis{
my $logic_name = shift || die("Need a logic_name" );
my $db_file = shift || '';
my $adaptor = $ENS_DBA->get_adaptor('Analysis');
my %args = ( -logic_name=>$logic_name,
$db_file ? (-db_file=>$db_file) : () );
# Hard-coded nastyness to make analyses correspond to Ensembl
# None needed for now
if( $logic_name eq 'MyAnalysis' ){
$args{-logic_name} = 'MyLogic';
$args{-db} = 'MyDB';
$args{-program} = 'MyProgram';
}
my $analysis;
if( $analysis = $adaptor->fetch_by_logic_name($args{-logic_name}) ){
# Analysis found in database already; use this.
return $analysis;
}
# No analysis - create one from scratch
$analysis = Bio::EnsEMBL::Analysis->new(%args);
$adaptor->store($analysis) if $I;
return $analysis;
}
#======================================================================
1;
| warelab/gramene-ensembl | maize/load-scripts/load_clones_from_fpc.pl | Perl | mit | 16,626 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
2334,
1013,
8026,
1013,
2566,
2140,
1011,
1059,
1027,
2132,
2487,
2171,
7170,
1035,
24418,
1035,
2013,
1035,
1042,
15042,
1012,
20228,
1011,
3769,
18969,
1037,
4563,
4372,
3366,
14905,
2140,
16962,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) 2014 Comunitea Servicios Tecnológicos All Rights Reserved
# $Kiko Sánchez <kiko@comunitea.com>$
#
# 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/>.
#
##############################################################################
from odoo import fields, models, api
from datetime import datetime
class OutletLoss(models.Model):
_name = 'outlet.loss'
@api.multi
@api.depends('qty', 'price_outlet', 'price_unit')
def _get_outlet_loss(self):
for loss in self:
loss.total_lost = loss.qty*(loss.price_outlet-loss.price_unit)
product_id = fields.Many2one('product.product', 'Product')
price_unit = fields.Float('Price')
price_outlet = fields.Float('Outlet Price')
total_lost = fields.Float("Outlet Loss", compute=_get_outlet_loss,
store=True, readonly=True)
date_move = fields.Date('Move to outlet on', default=fields.datetime.now())
outlet_ok = fields.Boolean('Outlet')
order_line_id = fields.Many2one('sale.order.line', 'Order Line')
qty = fields.Float('Quantity')
percent = fields.Float('Outlet Percent')
| Comunitea/CMNT_004_15 | project-addons/product_outlet_loss/models/product.py | Python | agpl-3.0 | 1,853 | [
30522,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
30524,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
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... |
(function () {
'use strict';
// Setting up route
angular
.module('app.users')
.run(appRun);
// appRun.$inject = ['$stateProvider'];
/* @ngInject */
function appRun(routerHelper) {
routerHelper.configureStates(getStates());
}
function getStates() {
return [
{
state: 'profile',
config: {
url: '/settings/profile',
controller: 'SettingsController',
controllerAs: 'vm',
templateUrl: 'modules/users/views/settings/edit-profile.client.view.html'
}
},
{
state: 'password',
config: {
url: '/settings/password',
controller: 'SettingsController',
controllerAs: 'vm',
templateUrl: 'modules/users/views/settings/change-password.client.view.html'
}
},
{
state: 'accounts',
config: {
url: '/settings/accounts',
controller: 'SettingsController',
controllerAs: 'vm',
templateUrl: 'modules/users/views/settings/social-accounts.client.view.html'
}
},
{
state: 'signup',
config: {
url: '/signup',
controller: 'AuthenticationController',
controllerAs: 'vm',
templateUrl: 'modules/users/views/authentication/signup.client.view.html'
}
},
{
state: 'signin',
config: {
url: '/signin',
controller: 'AuthenticationController',
controllerAs: 'vm',
templateUrl: 'modules/users/views/authentication/signin.client.view.html'
}
},
{
state: 'forgot',
config: {
url: '/password/forgot',
controller: 'PasswordController',
controllerAs: 'vm',
templateUrl: 'modules/users/views/password/forgot-password.client.view.html'
}
},
{
state: 'reset-invalid',
config: {
url: '/password/reset/invalid',
controller: 'PasswordController',
controllerAs: 'vm',
templateUrl: 'modules/users/views/password/reset-password-invalid.client.view.html'
}
},
{
state: 'reset-success',
config: {
url: '/password/reset/success',
controller: 'PasswordController',
controllerAs: 'vm',
templateUrl: 'modules/users/views/password/reset-password-success.client.view.html'
}
},
{
state: 'reset',
config: {
url: '/password/reset/:token',
controller: 'PasswordController',
controllerAs: 'vm',
templateUrl: 'modules/users/views/password/reset-password.client.view.html'
}
}
];
}
})(); | fr101ed/mean | public/modules/users/config/users.client.routes.js | JavaScript | mit | 2,628 | [
30522,
1006,
3853,
1006,
1007,
1063,
1005,
2224,
9384,
1005,
1025,
1013,
1013,
4292,
2039,
2799,
16108,
1012,
11336,
1006,
1005,
10439,
1012,
5198,
1005,
1007,
1012,
2448,
1006,
10439,
15532,
1007,
1025,
1013,
1013,
10439,
15532,
1012,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.planet_ink.coffee_mud.core.intermud.packets;
import com.planet_ink.coffee_mud.core.intermud.server.*;
import com.planet_ink.coffee_mud.core.interfaces.*;
import com.planet_ink.coffee_mud.core.*;
import com.planet_ink.coffee_mud.Abilities.interfaces.*;
import com.planet_ink.coffee_mud.Areas.interfaces.*;
import com.planet_ink.coffee_mud.Behaviors.interfaces.*;
import com.planet_ink.coffee_mud.CharClasses.interfaces.*;
import com.planet_ink.coffee_mud.Commands.interfaces.*;
import com.planet_ink.coffee_mud.Common.interfaces.*;
import com.planet_ink.coffee_mud.Exits.interfaces.*;
import com.planet_ink.coffee_mud.Items.interfaces.*;
import com.planet_ink.coffee_mud.Locales.interfaces.*;
import com.planet_ink.coffee_mud.MOBS.interfaces.*;
import com.planet_ink.coffee_mud.Races.interfaces.*;
import java.util.Vector;
/**
* Copyright (c) 2008-2010 Bo Zimmerman
* 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.
*
*/
@SuppressWarnings("unchecked")
public class ChannelUserReply extends Packet {
public String userRequested=null;
public String userVisibleName=null;
public char gender = 'N';
public ChannelUserReply()
{
super();
type = Packet.CHAN_USER_REP;
}
public ChannelUserReply(Vector v) throws InvalidPacketException {
super(v);
try {
type = Packet.CHAN_USER_REP;
try{
userRequested = (String)v.elementAt(6);
userVisibleName = (String)v.elementAt(7);
int gend = CMath.s_int(v.elementAt(8).toString());
switch(gend) {
case 0: gender='M'; break;
case 1: gender='F'; break;
case 2: gender='N'; break;
}
}catch(Exception e){}
}
catch( ClassCastException e ) {
throw new InvalidPacketException();
}
}
public void send() throws InvalidPacketException {
if( userRequested == null || userVisibleName == null ) {
throw new InvalidPacketException();
}
super.send();
}
public String toString() {
int genderCode = 0;
switch(gender) {
case 'M': genderCode=0; break;
case 'F': genderCode=1; break;
case 'N': genderCode=2; break;
}
String str="({\"chan-user-req\",5,\"" + Server.getMudName() +
"\",0,\"" + target_mud + "\",0,\"" + userRequested
+ "\",\"" + userVisibleName
+ "\"," + genderCode + ",})";
return str;
}
}
| welterde/ewok | com/planet_ink/coffee_mud/core/intermud/packets/ChannelUserReply.java | Java | apache-2.0 | 2,969 | [
30522,
7427,
4012,
1012,
4774,
1035,
10710,
1012,
4157,
1035,
8494,
1012,
4563,
1012,
6970,
12274,
2094,
1012,
23730,
1025,
12324,
4012,
1012,
4774,
1035,
10710,
1012,
4157,
1035,
8494,
1012,
4563,
1012,
6970,
12274,
2094,
1012,
8241,
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... |
/** @prettier */
import { expect } from 'chai';
import { EMPTY, of, EmptyError, defer, throwError, Observable } from 'rxjs';
import { throwIfEmpty, mergeMap, retry, take } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { observableMatcher } from '../helpers/observableMatcher';
/** @test {throwIfEmpty} */
describe('throwIfEmpty', () => {
let rxTestScheduler: TestScheduler;
beforeEach(() => {
rxTestScheduler = new TestScheduler(observableMatcher);
});
describe('with errorFactory', () => {
it('should error when empty', () => {
rxTestScheduler.run(({ cold, expectObservable }) => {
const source = cold('----|');
const expected = ' ----#';
const result = source.pipe(throwIfEmpty(() => new Error('test')));
expectObservable(result).toBe(expected, undefined, new Error('test'));
});
});
it('should throw if empty', () => {
const error = new Error('So empty inside');
let thrown: any;
EMPTY.pipe(throwIfEmpty(() => error)).subscribe({
error(err) {
thrown = err;
},
});
expect(thrown).to.equal(error);
});
it('should NOT throw if NOT empty', () => {
const error = new Error('So empty inside');
let thrown: any;
of('test')
.pipe(throwIfEmpty(() => error))
.subscribe({
error(err) {
thrown = err;
},
});
expect(thrown).to.be.undefined;
});
it('should pass values through', () => {
rxTestScheduler.run(({ cold, expectObservable, expectSubscriptions }) => {
const source = cold('----a---b---c---|');
const sub1 = ' ^---------------!';
const expected = ' ----a---b---c---|';
const result = source.pipe(throwIfEmpty(() => new Error('test')));
expectObservable(result).toBe(expected);
expectSubscriptions(source.subscriptions).toBe([sub1]);
});
});
it('should never when never', () => {
rxTestScheduler.run(({ cold, expectObservable, expectSubscriptions }) => {
const source = cold('-');
const sub1 = ' ^';
const expected = ' -';
const result = source.pipe(throwIfEmpty(() => new Error('test')));
expectObservable(result).toBe(expected);
expectSubscriptions(source.subscriptions).toBe([sub1]);
});
});
it('should error when empty', () => {
rxTestScheduler.run(({ cold, expectObservable, expectSubscriptions }) => {
const source = cold('----|');
const sub1 = ' ^---!';
const expected = ' ----#';
const result = source.pipe(throwIfEmpty(() => new Error('test')));
expectObservable(result).toBe(expected, undefined, new Error('test'));
expectSubscriptions(source.subscriptions).toBe([sub1]);
});
});
it('should throw if empty after retry', () => {
const error = new Error('So empty inside');
let thrown: any;
let sourceIsEmpty = false;
const source = defer(() => {
if (sourceIsEmpty) {
return EMPTY;
}
sourceIsEmpty = true;
return of(1, 2);
});
source
.pipe(
throwIfEmpty(() => error),
mergeMap((value) => {
if (value > 1) {
return throwError(() => new Error());
}
return of(value);
}),
retry(1)
)
.subscribe({
error(err) {
thrown = err;
},
});
expect(thrown).to.equal(error);
});
});
describe('without errorFactory', () => {
it('should throw EmptyError if empty', () => {
let thrown: any;
EMPTY.pipe(throwIfEmpty()).subscribe({
error(err) {
thrown = err;
},
});
expect(thrown).to.be.instanceof(EmptyError);
});
it('should NOT throw if NOT empty', () => {
let thrown: any;
of('test')
.pipe(throwIfEmpty())
.subscribe({
error(err) {
thrown = err;
},
});
expect(thrown).to.be.undefined;
});
it('should pass values through', () => {
rxTestScheduler.run(({ cold, expectObservable, expectSubscriptions }) => {
const source = cold('----a---b---c---|');
const sub1 = ' ^---------------!';
const expected = ' ----a---b---c---|';
const result = source.pipe(throwIfEmpty());
expectObservable(result).toBe(expected);
expectSubscriptions(source.subscriptions).toBe([sub1]);
});
});
it('should never when never', () => {
rxTestScheduler.run(({ cold, expectObservable, expectSubscriptions }) => {
const source = cold('-');
const sub1 = ' ^';
const expected = ' -';
const result = source.pipe(throwIfEmpty());
expectObservable(result).toBe(expected);
expectSubscriptions(source.subscriptions).toBe([sub1]);
});
});
it('should error when empty', () => {
rxTestScheduler.run(({ cold, expectObservable, expectSubscriptions }) => {
const source = cold('----|');
const sub1 = ' ^---!';
const expected = ' ----#';
const result = source.pipe(throwIfEmpty());
expectObservable(result).toBe(expected, undefined, new EmptyError());
expectSubscriptions(source.subscriptions).toBe([sub1]);
});
});
it('should throw if empty after retry', () => {
let thrown: any;
let sourceIsEmpty = false;
const source = defer(() => {
if (sourceIsEmpty) {
return EMPTY;
}
sourceIsEmpty = true;
return of(1, 2);
});
source
.pipe(
throwIfEmpty(),
mergeMap((value) => {
if (value > 1) {
return throwError(() => new Error());
}
return of(value);
}),
retry(1)
)
.subscribe({
error(err) {
thrown = err;
},
});
expect(thrown).to.be.instanceof(EmptyError);
});
});
it('should stop listening to a synchronous observable when unsubscribed', () => {
const sideEffects: number[] = [];
const synchronousObservable = new Observable<number>((subscriber) => {
// This will check to see if the subscriber was closed on each loop
// when the unsubscribe hits (from the `take`), it should be closed
for (let i = 0; !subscriber.closed && i < 10; i++) {
sideEffects.push(i);
subscriber.next(i);
}
});
synchronousObservable.pipe(throwIfEmpty(), take(3)).subscribe(() => {
/* noop */
});
expect(sideEffects).to.deep.equal([0, 1, 2]);
});
});
| ReactiveX/rxjs | spec/operators/throwIfEmpty-spec.ts | TypeScript | apache-2.0 | 6,821 | [
30522,
1013,
1008,
1008,
1030,
3653,
6916,
2121,
1008,
1013,
12324,
1063,
5987,
1065,
2013,
1005,
15775,
2072,
1005,
1025,
12324,
1063,
4064,
1010,
1997,
1010,
4064,
2121,
29165,
1010,
13366,
2121,
1010,
5466,
2121,
29165,
1010,
27885,
8043... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
#nullable disable
using System;
using System.Globalization;
using System.IO;
using Core2D.Model;
using Core2D.ViewModels;
using Core2D.ViewModels.Data;
using CSV = CsvHelper;
namespace Core2D.Modules.TextFieldWriter.CsvHelper
{
public sealed class CsvHelperWriter : ITextFieldWriter<DatabaseViewModel>
{
private readonly IServiceProvider _serviceProvider;
public CsvHelperWriter(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public string Name { get; } = "Csv (CsvHelper)";
public string Extension { get; } = "csv";
public void Write(Stream stream, DatabaseViewModel database)
{
using var writer = new StringWriter();
var configuration = new CSV.Configuration.CsvConfiguration(CultureInfo.CurrentCulture)
{
Delimiter = CultureInfo.CurrentCulture.TextInfo.ListSeparator,
CultureInfo = CultureInfo.CurrentCulture
};
using (var csvWriter = new CSV.CsvWriter(writer, configuration))
{
// Columns
csvWriter.WriteField(database.IdColumnName);
foreach (var column in database.Columns)
{
csvWriter.WriteField(column.Name);
}
csvWriter.NextRecord();
// Records
foreach (var record in database.Records)
{
csvWriter.WriteField(record.Id.ToString());
foreach (var value in record.Values)
{
csvWriter.WriteField(value.Content);
}
csvWriter.NextRecord();
}
}
var csv = writer.ToString();
var fileSystem = _serviceProvider.GetService<IFileSystem>();
fileSystem?.WriteUtf8Text(stream, csv);
}
}
}
| Core2D/Core2D | src/Core2D/Modules/TextFieldWriter.CsvHelper/CsvHelperWriter.cs | C# | mit | 1,976 | [
30522,
1001,
19701,
3085,
4487,
19150,
2478,
2291,
1025,
2478,
2291,
1012,
24370,
1025,
2478,
2291,
1012,
22834,
1025,
2478,
4563,
2475,
2094,
1012,
2944,
1025,
2478,
4563,
2475,
2094,
1012,
3193,
5302,
9247,
2015,
1025,
2478,
4563,
2475,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.code.constant;
/**
* Created by niu on 2017/8/17.
*/
public class StringEvent {
//网络状态改变
public static String NET_STATE_CHANGE = "net_state_change";
}
| niuzhijun66/NiuStudyDemo | app/src/main/java/com/code/constant/StringEvent.java | Java | apache-2.0 | 187 | [
30522,
7427,
4012,
1012,
3642,
1012,
5377,
1025,
1013,
1008,
1008,
1008,
2580,
2011,
9152,
2226,
2006,
2418,
1013,
1022,
1013,
2459,
1012,
1008,
1013,
2270,
2465,
5164,
18697,
3372,
1063,
1013,
1013,
100,
100,
100,
100,
100,
100,
2270,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 http-equiv="X-UA-Compatible" content="IE=edge">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<title>TSA Website Design</title>
</head>
<body>
<div id="background">
<img src="dscovrblured.jpg" class="stretch">
</div>
<nav id="mainNav" class="navbar navbar-inverse navbar-fixed-top">
<div align="center" class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar1" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Navigation Toggle</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!--<a class="navbar-brand page-scroll" href="index.html">Privatization of Space Exploration</a>-->
</div>
<div style="text-align:center" class="collapse navbar-collapse" id="navbar1">
<ul class="nav navbar-nav navbar-right">
<li>
<a class="page-scroll" href="index.html">Home</a>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#b2">Space Enterprises
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<a href="#b21">SpaceX</a>
</li>
<li>
<a href="#b22">Blue Origin</a>
</li>
<li>
<a href="#b23">Vigin Galactic</a>
</li>
<li>
<a href="#b24">XCOR</a>
</li>
<li>
<a href="#b25">Starchaser Industries</a>
</li>
<li>
<a href="#b26">Bigelow Aerospace</a>
</li>
<li>
<a href="#b27">Lockheed Martin</a>
</li>
<li>
<a href="#b28">Orbital ATK</a>
</li>
<li>
<a href="#b29">Scaled Composites</a>
</li>
</ul>
</li>
<li>
<a class="page-scroll" href="#b2">Timeline of Events</a>
</li>
<li>
<a class="page-scroll" href="#b3">Evolution of Vehicles</a>
</li>
<li>
<a class="page-scroll" href="#d4">Careers & Interviews</a>
</li>
<li>
<a class="page-scroll" href="#d5">Impacts and Advantages</a>
</li>
<li>
<a class="page-scroll" href="#d6">Careers & Interviews</a>
</li>
<li>
<a class="page-scroll" href="#d7">Resources</a>
</li>
</ul>
</div>
</div>
</nav>
<p>
<div class="container-fluid">
<div class="row">
<a href="aboutspacex.html">
<img src="spacexheaderwithlogofaded.png" class="img-responsive">
</a>
</div> <!---NIEN--->
</div>
</p>
<div class="container">
<div class="panel panel-default">
<div class="panel-body">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vitae sapien id est dignissim venenatis. Maecenas quis gravida ipsum, a pharetra nisi. Etiam ornare arcu eu diam luctus convallis. Cras dictum diam augue, sed porttitor nibh euismod ac. Proin ullamcorper, velit ac rutrum fermentum, nunc urna bibendum augue, in scelerisque nisl sapien ac nunc. Ut id faucibus lorem, vel finibus mi. Nunc pharetra elit non libero dictum venenatis. Vestibulum vel massa in odio viverra maximus quis eu velit. Nulla auctor ut ligula at dapibus. Ut id tincidunt orci. Sed et consequat urna. Cras eu consequat dolor. Integer fringilla at nisl eu venenatis.
Ut vulputate accumsan mauris, vel porttitor nunc maximus non. Morbi convallis ornare laoreet. Maecenas sagittis consequat consectetur. Mauris placerat dignissim neque quis lacinia. Phasellus ut dapibus mi, sit amet pretium leo. Praesent eget placerat nisl. Duis dictum nisi vitae maximus hendrerit. Pellentesque porta neque ac malesuada volutpat. Morbi quis erat nisl. Quisque eros sem, molestie et fermentum eu, efficitur ac mi. Sed euismod ipsum enim, ultrices sodales nisl auctor eget. Etiam vel mi convallis, vulputate magna a, dictum enim.
Cras eleifend lorem placerat tortor venenatis, non venenatis dolor lacinia. Morbi augue massa, interdum at neque nec, congue pretium libero. Aenean tempor pellentesque hendrerit. Morbi eget dui lectus. Suspendisse potenti. Suspendisse non enim faucibus, condimentum tellus eget, posuere sem. Aenean volutpat luctus tincidunt. Vestibulum at cursus turpis, in vestibulum nunc. Sed scelerisque erat in finibus auctor. Suspendisse euismod ante diam, in fermentum elit tempus vel.
Nulla auctor enim nec eros semper, nec sollicitudin libero pharetra. Fusce ut finibus neque. Fusce augue risus, semper a consectetur sit amet, congue a nunc. In mattis euismod sem at pretium. Nunc lacinia semper felis, non tincidunt magna placerat vitae. Quisque facilisis vel sapien sit amet vulputate. Nulla facilisi.
In vel tortor libero. Vestibulum pharetra congue metus, et vestibulum tellus ultrices quis. Phasellus vel eros et libero suscipit feugiat. Vivamus pretium malesuada vulputate. Suspendisse egestas metus sit amet dapibus ullamcorper. Quisque elementum tempus nulla id mattis. Quisque iaculis interdum erat, id varius lectus ultricies et. Aenean sit amet arcu rutrum, vulputate arcu ac, consequat nunc. Phasellus vel risus ante. Suspendisse efficitur felis neque, non semper sapien scelerisque ut. Fusce vel libero vitae enim tincidunt sollicitudin. Nunc id ligula cursus, fringilla lectus id, fermentum purus.
</div>
</div>
</div>
</body>
</html> | BedrockSolid/BedrockSolid.github.io | aboutspacex.html | HTML | mit | 6,716 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
18804,
8299,
1011,
1041,
15549,
2615,
1027,
1000,
1060,
1011,
25423,
1011,
11... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
//================================================================
// RS_HUD_OptimizedMobile.js
// ---------------------------------------------------------------
// The MIT License
// Copyright (c) 2015 biud436
// ---------------------------------------------------------------
// Free for commercial and non commercial use.
//================================================================
/*:
* RS_HUD_OptimizedMobile.js
* @plugindesc (v1.0.1) This plugin draws the HUD, which displays the hp and mp and exp and level of each party members.
*
* @author biud436
*
* @param --- Image Name
*
* @param Texture Atlas
* @parent --- Image Name
* @desc import texture atlas.
* @default config
* @require 1
* @dir img/rs_hud/
* @type file
*
* @param EXP Gauge
* @parent --- Image Name
* @desc Specifies to import file in the path named 'exr'
* @default exr
*
* @param Empty Gauge
* @parent --- Image Name
* @desc Specifies to import file in the path named 'gauge'
* @default gauge
*
* @param HP Gauge
* @parent --- Image Name
* @desc Specifies to import file in the path named 'hp'
* @default hp
*
* @param MP Gauge
* @parent --- Image Name
* @desc Specifies to import file in the path named 'mp'
* @default mp
*
* @param HUD Background
* @parent --- Image Name
* @desc Specifies to import file in the path named 'hud_window_empty'
* @default hud_window_empty
*
* @param Masking
* @parent --- Image Name
* @desc Specifies to import file in the path named 'masking'
* @default masking
*
* @param --- Image Custom Position
*
* @param Face Position
* @parent --- Image Custom Position
* @desc Specifies the properties of the face sprite by x, y, visible
* (Draw it at changing position relative to a background sprite)
* @default 0, 0, true
*
* @param HP Position
* @parent --- Image Custom Position
* @desc Specifies the properties of the hp sprite by x, y, visible
* (Draw it at changing position relative to a background sprite)
* @default 160, 41, true
*
* @param MP Position
* @parent --- Image Custom Position
* @desc Specifies the properties of the mp sprite by x, y, visible
* (Draw it at changing position relative to a background sprite)
* @default 160, 67, true
*
* @param EXP Position
* @parent --- Image Custom Position
* @desc Specifies the properties of the exp sprite by x, y, visible
* (Draw it at changing position relative to a background sprite)
* @default 83, 89, true
*
* @param HP Text Position
* @parent --- Image Custom Position
* @desc Specifies the properties of the hp text sprite by x, y, visible
* (Draw it at changing position relative to a background sprite)
* @default 160, 51, true
*
* @param MP Text Position
* @parent --- Image Custom Position
* @desc Specifies the properties of the mp text sprite by x, y, visible
* (Draw it at changing position relative to a background sprite)
* @default 160, 77, true
*
* @param Level Text Position
* @parent --- Image Custom Position
* @desc Specifies the properties of the level text sprite by x, y, visible
* (Draw it at changing position relative to a background sprite)
* @default 60, 78, true
*
* @param EXP Text Position
* @parent --- Image Custom Position
* @desc Specifies the properties of the exp text sprite by x, y, visible
* (Draw it at changing position relative to a background sprite)
* @default 120.5, 91, true
*
* @param Name Text Position
* @parent --- Image Custom Position
* @desc Specifies the properties of the name text sprite by x, y, visible
* (Draw it at changing position relative to a background sprite)
* @default 54, 51, false
*
* @param --- Noraml
*
* @param Width
* @parent --- Noraml
* @desc Do not change this when you are using the default sprite batch.
* (default : 317)
* @default 317
*
* @param Height
* @parent --- Noraml
* @desc Do not change this when you are using the default sprite batch.
* (default : 101)
* @default 101
*
* @param Margin
* @parent --- Noraml
* @type number
* @min 0
* @desc Sets the margin to the HUD borders.
* @default 0
*
* @param Gaussian Blur
* @parent --- Noraml
* @type boolean
* @desc Sets the Gaussian Blur.
* @default true
*
* @param Show
* @parent --- Noraml
* @type boolean
* @desc Sets the visible status. (default : true)
* @default true
*
* @param Opacity
* @parent --- Noraml
* @type number
* @min 0
* @max 255
* @desc Sets the opacity.
* @default 255
*
* @param Arrangement
* @parent --- Noraml
* @type string[]
* @desc Create an array to set the anchor of each HUD.
* @default ["LeftTop", "LeftBottom", "RightTop", "RightBottom"]
*
* @param Anchor
* @parent --- Noraml
* @desc If anchor is not found, HUD would set to this anchor.
* @default LeftTop
*
* @param preloadImportantFaces
* @parent --- Noraml
* @type string[]
* @desc Allow you to pre-load the base face chips.
* (If you do not set this parameter, It can cause errors in the game.)
* @default ["Actor1", "Actor2", "Actor3"]
*
* @param Battle Only
* @parent --- Noraml
* @type boolean
* @desc If you want to use the HUD only in battles.
* (default : false)
* @default false
*
* @param Show Comma
* @parent --- Noraml
* @type boolean
* @desc Sets the value that indicates whether this parameter displays
* the values with commas every three digits.
* @default false
*
* @param Max Exp Text
* @parent --- Noraml
* @desc
* @default ------/------
*
* @param Max Members
* @parent --- Noraml
* @type number
* @min 1
* @desc Specifies the maximum number of party members that displays within the game screen.
* @default 4
*
* @param --- Font
*
* @param Chinese Font
* @parent --- Font
* @desc Specifies the desired fonts
* @default SimHei, Heiti TC, sans-serif
*
* @param Korean Font
* @parent --- Font
* @desc Specifies the desired fonts
* @default NanumGothic, Dotum, AppleGothic, sans-serif
*
* @param Standard Font
* @parent --- Font
* @desc Specifies to import a css for the font file from ./fonts folder.
* @default GameFont
*
* @param Level Text Size
* @parent --- Font
* @desc Specify the text size for levels.
* @default 24
*
* @param HP Text Size
* @parent --- Font
* @desc Specify the text size for HP.
* @default 12
*
* @param MP Text Size
* @parent --- Font
* @desc Specify the text size for MP.
* @default 12
*
* @param EXP Text Size
* @parent --- Font
* @desc Specify the text size for EXP.
* @default 12
*
* @param Name Text Size
* @parent --- Font
* @desc Specify the text size for names.
* @default 12
*
* @param --- Text Color
*
* @param HP Color
* @parent --- Text Color
* @desc Specify the text color for HP.
* @default #ffffff
*
* @param MP Color
* @parent --- Text Color
* @desc Specify the text color for MP.
* @default #ffffff
*
* @param EXP Color
* @parent --- Text Color
* @desc Specify the text color for EXP.
* @default #ffffff
*
* @param Level Color
* @parent --- Text Color
* @desc Specify the text color for levels.
* @default #ffffff
*
* @param Name Color
* @parent --- Text Color
* @desc Specify the text color for names.
* @default #ffffff
*
* @param --- Text Outline Color
*
* @param HP Outline Color
* @parent --- Text Outline Color
* @desc Specify the text outline color for HP.
* @default rgba(0, 0, 0, 0.5)
*
* @param MP Outline Color
* @parent --- Text Outline Color
* @desc Specify the text outline color for MP.
* @default rgba(0, 0, 0, 0.5)
*
* @param EXP Outline Color
* @parent --- Text Outline Color
* @desc Specify the text outline color for EXP.
* @default rgba(0, 0, 0, 0.5)
*
* @param Level Outline Color
* @parent --- Text Outline Color
* @desc Specify the text outline color for levels.
* @default rgba(0, 0, 0, 0.5)
*
* @param Name Outline Color
* @parent --- Text Outline Color
* @desc Specify the text outline color for names.
* @default rgba(0, 0, 0, 0.5)
*
* @param --- Text Outline Width
*
* @param HP Outline Width
* @parent --- Text Outline Width
* @desc Specify the maximum width of a text border line for HP.
* @default 4
*
* @param MP Outline Width
* @parent --- Text Outline Width
* @desc Specify the maximum width of a text border line for MP.
* @default 4
*
* @param EXP Outline Width
* @parent --- Text Outline Width
* @desc Specify the maximum width of a text border line for EXP.
* @default 4
*
* @param Level Outline Width
* @parent --- Text Outline Width
* @desc Specify the maximum width of a text border line for levels.
* @default 4
*
* @param Name Outline Width
* @parent --- Text Outline Width
* @desc Specify the maximum width of a text border line for names.
* @default 4
*
* @param --- Custom Font
*
* @param Using Custom Font
* @parent --- Custom Font
* @type boolean
* @desc Specify whether the custom font shows (default : false)
* YES - true / NO - false
* @default false
*
* @param Custom Font Name
* @parent --- Custom Font
* @desc Specify the name of the custom font
* @default NanumBrush
*
* @param Custom Font Src
* @parent --- Custom Font
* @desc Specify the path of the font file from a game project folder
* @default fonts/NanumBrush.ttf
*
* @param --- Custom HUD Anchor
*
* @param Custom Pos 1
* @parent --- Custom HUD Anchor
* @desc Predefined Variables : W, H, PD, BW, BH
* (Please refer to a custom position of the help section)
* @default 0, (H * 0) + PD
*
* @param Custom Pos 2
* @parent --- Custom HUD Anchor
* @desc Predefined Variables : W, H, PD, BW, BH
* (Please refer to the help section)
* @default 0, (H * 1) + PD
*
* @param Custom Pos 3
* @parent --- Custom HUD Anchor
* @desc Predefined Variables : W, H, PD, BW, BH
* (Please refer to the help section)
* @default 0, (H * 2) + PD
*
* @param Custom Pos 4
* @parent --- Custom HUD Anchor
* @desc Predefined Variables : W, H, PD, BW, BH
* (Please refer to the help section)
* @default 0, (H * 3) + PD
*
* @param Custom Pos 5
* @parent --- Custom HUD Anchor
* @desc Predefined Variables : W, H, PD, BW, BH
* (Please refer to the help section)
* @default 0, (H * 4) + PD
*
* @param Custom Pos 6
* @parent --- Custom HUD Anchor
* @desc Predefined Variables : W, H, PD, BW, BH
* (Please refer to the help section)
* @default W + PD, (H * 0) + PD
*
* @param Custom Pos 7
* @parent --- Custom HUD Anchor
* @desc Predefined Variables : W, H, PD, BW, BH
* (Please refer to the help section)
* @default W + PD, (H * 1) + PD
*
* @param Custom Pos 8
* @parent --- Custom HUD Anchor
* @desc Predefined Variables : W, H, PD, BW, BH
* (Please refer to the help section)
* @default W + PD, (H * 2) + PD
*
* @param Custom Pos 9
* @parent --- Custom HUD Anchor
* @desc Predefined Variables : W, H, PD, BW, BH
* (Please refer to the help section)
* @default W + PD, (H * 3) + PD
*
* @param Custom Pos 10
* @parent --- Custom HUD Anchor
* @desc Predefined Variables : W, H, PD, BW, BH
* (Please refer to the help section)
* @default W + PD, (H * 4) + PD
*
* @help
* =============================================================================
* Installations
* =============================================================================
*
* Download the resources and place them in your img/rs_hud folder.
* All the resources can download in the following link.
* img/rs_hud/config.json : https://github.com/biud436/MV/raw/master/HUD/config.json
* img/rs_hud/config.png : https://github.com/biud436/MV/raw/master/HUD/config.png
*
* Github Link : https://github.com/biud436/MV/blob/master/HUD/RS_HUD_OptimizedMobile.js
*
* =============================================================================
* Custom Positions
* =============================================================================
*
* To display in correct place, you need to know which predefined variables are currently available.
* You can be available predefined variables as belows when specifying the parameter
* named 'Custom Pos'. So you can quickly set up positions for a hud itself.
*
* Predefined Variables :
* W - 'W' is the same as a parameter named 'Width' in Plugin Manager.
* H - 'H' is the same as a parameter named 'Height' in Plugin Manager
* PD - 'PD' is the same as a parameter named 'Margin' in Plugin Manager
* BW - 'BW' is the same as a maximum width of the game canvas.
* BH - 'BH' is the same as a maximum height of the game canvas.
*
* Each sprites draw at changing position relative to the background sprite.
* Therefore, this custom position is pretty important values.
*
* =============================================================================
* Notetags
* =============================================================================
*
* Insert the following the notetag into the map property window as below.
* <DISABLE_HUD> : A notetag can use in the map that does not wish create each huds.
*
* =============================================================================
* Script Calls
* =============================================================================
*
* -----------------------------------------------------------------------------
* Set Opacity
* -----------------------------------------------------------------------------
* Sets the opacity of the HUD to x.
*
* $gameHud.opacity = x;
*
* That is a number between 0 and 255.
*
* For example :
* $gameHud.opacity = 128;
*
* -----------------------------------------------------------------------------
* Set visibility
* -----------------------------------------------------------------------------
* This variable will change the visible option of the HUD.
*
* $gameHud.show = true/false;
*
* For example :
* $gameHud.show = false;
*
* -----------------------------------------------------------------------------
* Refresh Texts
* -----------------------------------------------------------------------------
* In general, text and gauge sprites refresh when requesting a refresh so this one is not
* updated on every frame. Therefore if you need to immediately refresh
* all texts for themselves, you will use as belows.
*
* $gameTemp.notifyHudTextRefresh();
*
* -----------------------------------------------------------------------------
* Clear and create all huds
* -----------------------------------------------------------------------------
* if you need to immediately recreate for all Huds, you will use as belows.
*
* $gameTemp.notifyHudRefresh();
* =============================================================================
* Plugin Commands
* =============================================================================
*
* RS_HUD Opacity x : This command sets up the opacity for all hud elements.
* 'x' is a number value between 0 and 255.
*
* RS_HUD Visible true/false : This command sets up whether it displays all containers for HUD.
* 'RS_HUD Visible true' sets its visibility to true.
* 'RS_HUD Visible false' sets its visibility to false.
*
* RS_HUD import file_name : This command imports the parameter as the json file from your data folder.
* RS_HUD export file_name : This command exports the parameter as the json file to your data folder.
*
* =============================================================================
* Change Log
* =============================================================================
* 2018.03.16 (v1.0.0) - First Release (forked in RS_HUD_4m)
* 2018.05.09 (v1.0.1) - Supported a face image that is made using SumRndmDde's CharacterCreatorEX plugin.
*/
var Imported = Imported || {};
Imported.RS_HUD_OptimizedMobile = '1.0.1';
var $gameHud = null;
var RS = RS || {};
RS.HUD = RS.HUD || {};
RS.HUD.param = RS.HUD.param || {};
(function() {
if(Utils.RPGMAKER_VERSION < '1.5.0') {
console.warn('Note that RS_HUD_4m plugin can use only in RMMV v1.5.0 or above.');
return;
}
var parameters = PluginManager.parameters('RS_HUD_OptimizedMobile');
// Image Settings
RS.HUD.param.imgEXP = String(parameters['EXP Gauge'] || 'exr');
RS.HUD.param.imgEmptyGauge = String(parameters['Empty Gauge'] || 'gauge');
RS.HUD.param.imgHP = String(parameters['HP Gauge'] || 'hp');
RS.HUD.param.imgMP = String(parameters['MP Gauge'] || 'mp');
RS.HUD.param.imgEmptyHUD = String(parameters['HUD Background'] || 'hud_window_empty');
RS.HUD.param.imgMasking = String(parameters['Masking'] || 'masking');
// Image Position
RS.HUD.loadImagePosition = function (szRE) {
var target = szRE.match(/(.*),(.*),(.*)/i);
var x = parseFloat(RegExp.$1);
var y = parseFloat(RegExp.$2);
var visible = Boolean(String(RegExp.$3).contains('true'));
return {'x': x, 'y': y, 'visible': visible};
};
RS.HUD.loadRealNumber = function (paramName, val) {
var value = Number(parameters[paramName]);
switch (typeof(value)) {
case 'object': case 'undefined':
value = val;
break;
}
return value;
};
RS.HUD.param.ptFace = RS.HUD.loadImagePosition(parameters['Face Position'] || '0, 0, true');
RS.HUD.param.ptHP = RS.HUD.loadImagePosition(parameters['HP Position'] || '160, 43, true');
RS.HUD.param.ptMP = RS.HUD.loadImagePosition(parameters['MP Position'] || '160, 69, true');
RS.HUD.param.ptEXP = RS.HUD.loadImagePosition(parameters['EXP Position'] || '83, 91, true');
RS.HUD.param.ptHPText = RS.HUD.loadImagePosition(parameters['HP Text Position'] || '160, 53, true');
RS.HUD.param.ptMPText = RS.HUD.loadImagePosition(parameters['MP Text Position'] || '160, 79, true');
RS.HUD.param.ptLevelText = RS.HUD.loadImagePosition(parameters['Level Text Position'] || '60, 80, true');
RS.HUD.param.ptEXPText = RS.HUD.loadImagePosition(parameters['EXP Text Position'] || '120.5, 93, true');
RS.HUD.param.ptNameText = RS.HUD.loadImagePosition(parameters['Name Text Position'] || '54, 53, true');
// Normal Settings
RS.HUD.param.nWidth = RS.HUD.loadRealNumber('Width', 317);
RS.HUD.param.nHeight = RS.HUD.loadRealNumber('Height', 101);
RS.HUD.param.nPD = RS.HUD.loadRealNumber('Margin', 0);
RS.HUD.param.blurProcessing = Boolean(parameters['Gaussian Blur'] === "true");
RS.HUD.param.bShow = Boolean(parameters['Show'] ==="true");
RS.HUD.param.nOpacity = RS.HUD.loadRealNumber('Opacity', 255);
RS.HUD.param.szAnchor = String(parameters['Anchor'] || "LeftTop");
RS.HUD.param.arrangement = eval(parameters['Arrangement']);
RS.HUD.param.preloadImportantFaces = eval(parameters['preloadImportantFaces'] || 'Actor1');
RS.HUD.param.battleOnly = Boolean(parameters['Battle Only'] === "true");
RS.HUD.param.showComma = Boolean(parameters['Show Comma'] === 'true');
RS.HUD.param.maxExpText = String(parameters['Max Exp Text'] || "------/------");
RS.HUD.param.nMaxMembers = parseInt(parameters["Max Members"] || 4);
RS.HUD.getDefaultHUDAnchor = function () {
var anchor = {
"LeftTop": {x: RS.HUD.param.nPD, y: RS.HUD.param.nPD},
"LeftBottom": {x: RS.HUD.param.nPD, y: Graphics.boxHeight - RS.HUD.param.nHeight - RS.HUD.param.nPD},
"RightTop": {x: Graphics.boxWidth - RS.HUD.param.nWidth - RS.HUD.param.nPD, y: RS.HUD.param.nPD},
"RightBottom": {x: Graphics.boxWidth - RS.HUD.param.nWidth - RS.HUD.param.nPD, y: Graphics.boxHeight - RS.HUD.param.nHeight - RS.HUD.param.nPD}
};
return anchor;
};
// Font Settings
RS.HUD.param.chineseFont = String(parameters['Chinese Font'] || 'SimHei, Heiti TC, sans-serif');
RS.HUD.param.koreanFont = String(parameters['Korean Font'] || 'NanumGothic, Dotum, AppleGothic, sans-serif');
RS.HUD.param.standardFont = String(parameters['Standard Font'] || 'GameFont');
// Text Size
RS.HUD.param.levelTextSize = RS.HUD.loadRealNumber('Level Text Size', 12);
RS.HUD.param.hpTextSize = RS.HUD.loadRealNumber('HP Text Size', 12);
RS.HUD.param.mpTextSize = RS.HUD.loadRealNumber('MP Text Size', 12);
RS.HUD.param.expTextSize = RS.HUD.loadRealNumber('EXP Text Size', 12);
RS.HUD.param.nameTextSize = RS.HUD.loadRealNumber('Name Text Size', 12);
// Text Color
RS.HUD.param.szHpColor = String(parameters['HP Color'] || '#ffffff');
RS.HUD.param.szMpColor = String(parameters['MP Color'] || '#ffffff');
RS.HUD.param.szExpColor = String(parameters['EXP Color'] || '#ffffff');
RS.HUD.param.szLevelColor = String(parameters['Level Color'] || '#ffffff');
RS.HUD.param.szNameColor = String(parameters['Name Color'] || '#ffffff');
// Text Outline Color
RS.HUD.param.szHpOutlineColor = String(parameters['HP Outline Color'] || 'rgba(0, 0, 0, 0.5)');
RS.HUD.param.szMpOutlineColor = String(parameters['MP Outline Color'] || 'rgba(0, 0, 0, 0.5)');
RS.HUD.param.szExpOutlineColor = String(parameters['EXP Outline Color'] || 'rgba(0, 0, 0, 0.5)');
RS.HUD.param.szLevelOutlineColor = String(parameters['Level Outline Color'] || 'rgba(0, 0, 0, 0.5)');
RS.HUD.param.szNameOutlineColor = String(parameters['Name Outline Color'] || 'rgba(0, 0, 0, 0.5)');
// Text Outline Width
RS.HUD.param.szHpOutlineWidth = RS.HUD.loadRealNumber('HP Outline Width', 4);
RS.HUD.param.szMpOutlineWidth = RS.HUD.loadRealNumber('MP Outline Width', 4);
RS.HUD.param.szExpOutlineWidth = RS.HUD.loadRealNumber('EXP Outline Width', 4);
RS.HUD.param.szLevelOutlineWidth = RS.HUD.loadRealNumber('Level Outline Width', 4);
RS.HUD.param.szNameOutlineWidth = RS.HUD.loadRealNumber('Name Outline Width', 4);
// Custom Font
RS.HUD.param.bUseCustomFont = Boolean(parameters['Using Custom Font'] === 'true');
RS.HUD.param.szCustomFontName = String(parameters['Custom Font Name'] || 'GameFont' );
RS.HUD.param.szCustomFontSrc = String(parameters['Custom Font Src'] || 'fonts/mplus-1m-regular.ttf');
// Custom HUD Anchor
RS.HUD.param.ptCustormAnchor = [];
RS.HUD.param.isCurrentBattleShowUp = false;
RS.HUD.param.isPreviousShowUp = false;
RS.HUD.param.init = false;
PIXI.loader
.add("config", "img/rs_hud/config.json")
.load(onAssetsLoaded);
function onAssetsLoaded() {
RS.HUD.param.init = true;
};
RS.HUD.loadCustomPosition = function (szRE) {
var W = RS.HUD.param.nWidth;
var H = RS.HUD.param.nHeight;
var PD = RS.HUD.param.nPD;
var BW = Graphics.boxWidth || 816;
var BH = Graphics.boxHeight || 624;
var x = eval('[' + szRE + ']');
if(x instanceof Array) return new Point(x[0], x[1]);
return new Point(0, 0);
};
// Opacity and Tone Glitter Settings
var nOpacityEps = 5;
var nOpacityMin = 64;
var nFaceDiameter = 96;
var nHPGlitter = 0.4;
var nMPGlitter = 0.4;
var nEXPGlitter = 0.7;
var defaultTemplate = 'hud_default_template.json';
//----------------------------------------------------------------------------
// Data Imports & Exports
//
//
RS.HUD.localFilePath = function (fileName) {
if(!Utils.isNwjs()) return '';
var path, base;
path = require('path');
base = path.dirname(process.mainModule.filename);
return path.join(base, 'data/') + (fileName || defaultTemplate);
};
RS.HUD.exportData = function (fileName) {
var fs, data, filePath;
if(!Utils.isNwjs()) return false;
if(!RS.HUD.param) return false;
fs = require('fs');
data = JSON.stringify(RS.HUD.param);
filePath = RS.HUD.localFilePath(fileName);
fs.writeFile(filePath, data, 'utf8', function (err) {
if (err) throw err;
});
};
RS.HUD.loadData = function (data) {
var params = Object.keys(RS.HUD.param);
data = JSON.parse(data);
params.forEach(function (name) {
RS.HUD.param[name] = data[name];
}, this);
setTimeout(function () {
$gameTemp.notifyHudRefresh();
}, 0);
};
RS.HUD.importData = function (fileName) {
if(!Utils.isNwjs()) return false;
var fs = require('fs');
var filePath = RS.HUD.localFilePath(fileName);
var data = fs.readFileSync(filePath, { encoding: 'utf8' });
RS.HUD.loadData(data);
};
RS.HUD.importDataWithAjax = function (fileName) {
var xhr = new XMLHttpRequest();
var self = RS.HUD;
var url = './data/' + (fileName || defaultTemplate);
xhr.open('GET', url);
xhr.onload = function() {
if(xhr.status < 400) {
RS.HUD.loadData(xhr.responseText.slice(0));
}
}
xhr.send();
};
RS.HUD.loadPicture = function (filename) {
var bitmap = ImageManager.reservePicture(filename);
return bitmap;
};
RS.HUD.loadFace = function (filename) {
var bitmap = ImageManager.reserveFace(filename);
return bitmap;
};
//----------------------------------------------------------------------------
// Bitmap
//
//
Bitmap.prototype.drawClippingImage = function(bitmap, maskImage , _x, _y, _sx, _sy) {
var context = this._context;
context.save();
context.drawImage(maskImage._canvas, _x, _y, nFaceDiameter, nFaceDiameter);
context.globalCompositeOperation = 'source-atop';
context.drawImage(bitmap._canvas, _sx, _sy, 144, 144, 0, 0, nFaceDiameter, nFaceDiameter);
context.restore();
this._setDirty();
};
Bitmap.prototype.drawClippingImageNonBlur = function(bitmap, _x, _y, _sx, _sy) {
var context = this._context;
context.save();
context.beginPath();
context.arc(_x + 45, _y + 45 , 45, 0, Math.PI * 2, false);
context.clip();
context.drawImage(bitmap._canvas, _sx, _sy, 144, 144, 0, 0, nFaceDiameter, nFaceDiameter);
context.restore();
this._setDirty();
};
//----------------------------------------------------------------------------
// Game_Temp
//
//
Game_Temp.prototype.notifyHudTextRefresh = function() {
if($gameHud) $gameHud.updateText();
};
Game_Temp.prototype.notifyHudRefresh = function() {
if($gameHud) $gameHud.refresh();
};
//----------------------------------------------------------------------------
// Game_System ($gameSystem)
//
//
var _alias_Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
_alias_Game_System_initialize.call(this);
this._rs_hud = this._rs_hud || {};
this._rs_hud.show = this._rs_hud.show || RS.HUD.param.bShow;
this._rs_hud.opacity = this._rs_hud.opacity || RS.HUD.param.nOpacity;
};
//----------------------------------------------------------------------------
// Game_Battler
//
//
var alias_Game_Battler_refresh = Game_Battler.prototype.refresh;
Game_Battler.prototype.refresh = function() {
alias_Game_Battler_refresh.call(this);
$gameTemp.notifyHudTextRefresh();
};
//----------------------------------------------------------------------------
// Game_Actor
//
//
Game_Actor.prototype.relativeExp = function () {
if(this.isMaxLevel()) {
return this.expForLevel(this.maxLevel());
} else {
return this.currentExp() - this.currentLevelExp();
}
};
Game_Actor.prototype.relativeMaxExp = function () {
if(!this.isMaxLevel()) {
return this.nextLevelExp() - this.currentLevelExp();
} else {
return this.expForLevel(this.maxLevel());
}
};
//----------------------------------------------------------------------------
// Game_Party
//
//
var alias_Game_Party_swapOrder = Game_Party.prototype.swapOrder;
Game_Party.prototype.swapOrder = function(index1, index2) {
alias_Game_Party_swapOrder.call(this, index1, index2);
$gameTemp.notifyHudRefresh();
};
//----------------------------------------------------------------------------
// TextData
//
//
function TextData() {
this.initialize.apply(this, arguments);
}
TextData.prototype = Object.create(Sprite.prototype);
TextData.prototype.constructor = TextData;
TextData.prototype.initialize = function(bitmap, func, params) {
Sprite.prototype.initialize.call(this, bitmap);
this.setCallbackFunction(func);
this.updateTextLog();
this._params = params;
this.requestUpdate();
};
TextData.prototype.setCallbackFunction = function (cbFunc) {
this._callbackFunction = cbFunc;
};
TextData.prototype.updateTextLog = function () {
this._log = this._callbackFunction.call();
};
TextData.prototype.startCallbackFunction = function () {
this._callbackFunction.call(this);
};
TextData.prototype.getTextProperties = function (n) {
return this._params[n];
};
TextData.prototype.drawDisplayText = function () {
this.defaultFontSettings();
this.bitmap.drawText(this._callbackFunction(this), 0, 0, 120, this._params[0] + 8, 'center');
};
TextData.prototype.isRefresh = function () {
var currentText = this._callbackFunction();
return currentText.localeCompare(this._log) !== 0;
};
TextData.prototype.clearTextData = function () {
this.bitmap.clear();
};
TextData.prototype.requestUpdate = function () {
this.clearTextData();
this.drawDisplayText();
this.updateTextLog();
};
TextData.prototype.standardFontFace = function() {
if(RS.HUD.param.bUseCustomFont) {
return RS.HUD.param.szCustomFontName;
} else {
if (navigator.language.match(/^zh/)) {
return RS.HUD.param.chineseFont;
} else if (navigator.language.match(/^ko/)) {
return RS.HUD.param.koreanFont;
} else {
return RS.HUD.param.standardFont;
}
}
};
TextData.prototype.defaultFontSettings = function() {
var param = this._params;
this.bitmap.fontFace = this.standardFontFace();
this.bitmap.fontSize = param[0];
this.bitmap.textColor = param[1];
this.bitmap.outlineColor = param[2];
this.bitmap.outlineWidth = param[3];
};
//----------------------------------------------------------------------------
// HUD
//
//
function HUD() {
this.initialize.apply(this, arguments);
};
//----------------------------------------------------------------------------
// RS_HudLayer
//
//
function RS_HudLayer() {
this.initialize.apply(this, arguments);
};
RS_HudLayer.prototype = Object.create(Sprite.prototype);
RS_HudLayer.prototype.constructor = RS_HudLayer;
RS_HudLayer.prototype.initialize = function(bitmap) {
Sprite.prototype.initialize.call(this, bitmap);
this.alpha = 0;
this.createItemLayer();
};
RS_HudLayer.prototype.createItemLayer = function () {
this._items = new Sprite();
this._items.setFrame(0, 0, Graphics.boxWidth, Graphics.boxHeight);
this.addChild(this._items);
};
RS_HudLayer.prototype.drawAllHud = function() {
var allHud = this._items;
var items = RS.HUD.param.arrangement;
// This removes any drawing objects that have already been created.
if(allHud.children.length > 0) {
allHud.removeChildren(0, allHud.children.length);
}
items.forEach(function(item, index){
// This code runs only when there is a party member at a specific index.
if(!!$gameParty.members()[index]) {
if(item !== null) allHud.addChild(new HUD({szAnchor: item, nIndex: index}));
}
}, this);
// It sorts objects by party number.
this.sort();
this.show = $gameSystem._rs_hud.show;
this.opacity = $gameSystem._rs_hud.opacity;
};
RS_HudLayer.prototype.update = function () {
var members = $gameParty.members();
this.children.forEach(function(child, idx) {
if (child.update && members[idx]) {
child.update();
}
});
};
RS_HudLayer.prototype.sort = function() {
var allHud = this._items;
var array = allHud.children;
allHud.children = array.sort(function(a, b) {
return a._memberIndex - b._memberIndex;
});
}
RS_HudLayer.prototype.refresh = function() {
var allHud = this._items;
allHud.children.forEach(function(i) {
allHud.removeChild(i);
}, this);
this.drawAllHud();
this.show = $gameSystem._rs_hud.show;
};
RS_HudLayer.prototype.updateText = function() {
var allHud = this._items;
allHud.children.forEach(function(i) {
i.updateText();
}, this);
};
RS_HudLayer.prototype.updateFrame = function () {
var allHud = this._items;
allHud.children.forEach(function(i) {
i.paramUpdate();
}, this);
};
RS_HudLayer.prototype.remove = function(index) {
var self = this;
setTimeout(function() {
while($gameParty.size() !== self._items.children.length) {
self.drawAllHud();
}
}, 0);
};
Object.defineProperty(RS_HudLayer.prototype, 'show', {
get: function() {
return this.visible;
},
set: function(value) {
this.visible = value;
$gameSystem._rs_hud.show = value;
},
});
Object.defineProperty(RS_HudLayer.prototype, 'opacity', {
get: function() {
return Math.floor(this.alpha * 255);
},
set: function(value) {
this.alpha = value * 0.00392156862745098;
$gameSystem._rs_hud.opacity = value.clamp(0, 255);
},
});
//----------------------------------------------------------------------------
// RS_EmptyHudLayer
//
//
function RS_EmptyHudLayer() {
this.initialize.apply(this, arguments);
}
RS_EmptyHudLayer.prototype = Object.create(Sprite.prototype);
RS_EmptyHudLayer.prototype.constructor = RS_EmptyHudLayer;
RS_EmptyHudLayer.prototype.initialize = function(bitmap) {
Sprite.prototype.initialize.call(this, bitmap);
this.alpha = 0;
};
RS_EmptyHudLayer.prototype.constructor = RS_EmptyHudLayer;
Object.defineProperty(RS_EmptyHudLayer.prototype, 'show', {
get: function() {
return $gameSystem._rs_hud.show;
},
set: function(value) {
$gameSystem._rs_hud.show = value;
}
});
Object.defineProperty(RS_EmptyHudLayer.prototype, 'opacity', {
get: function() {
return $gameSystem._rs_hud.opacity;
},
set: function(value) {
$gameSystem._rs_hud.opacity = value.clamp(0, 255);
}
});
//----------------------------------------------------------------------------
// HUD
//
//
HUD.prototype = Object.create(Stage.prototype);
HUD.prototype.constructor = HUD;
HUD.prototype.initialize = function(config) {
Stage.prototype.initialize.call(this);
this.createHud();
this.setAnchor(config.szAnchor || "LeftBottom");
this.setMemberIndex(parseInt(config.nIndex) || 0);
this.createFace();
this.createHp();
this.createMp();
this.createExp();
this.createText();
this.setPosition();
this.paramUpdate();
};
HUD.prototype.getAnchor = function(magnet) {
var anchor = RS.HUD.getDefaultHUDAnchor();
// Add Custom Anchor
for(var i = 0; i < RS.HUD.param.nMaxMembers; i++) {
var idx = parseInt(i + 1);
anchor['Custom Pos ' + idx] = RS.HUD.param.ptCustormAnchor[i];
}
return anchor[magnet];
};
HUD.prototype.setAnchor = function(anchor) {
var pos = this.getAnchor(anchor);
if(typeof(pos) === 'object') {
this._hud.x = pos.x;
this._hud.y = pos.y;
} else {
this.setAnchor(RS.HUD.param.szAnchor);
}
};
HUD.prototype.setMemberIndex = function(index) {
this._memberIndex = index;
};
HUD.prototype.fromImage = function(textureName) {
var texture = PIXI.utils.TextureCache[textureName + ".png"];
var sprite = new PIXI.Sprite(texture);
return sprite;
};
HUD.prototype.createHud = function() {
this._hud = this.fromImage(RS.HUD.param.imgEmptyHUD);
this.addChild(this._hud);
};
HUD.prototype.createFace = function() {
var player = this.getPlayer();
if(Imported["SumRndmDde Character Creator EX"]) {
if(player.hasSetImage()) {
this._faceBitmap = player.getCreatorBitmapFace();
} else {
this._faceBitmap = RS.HUD.loadFace(player.faceName());
}
} else {
this._faceBitmap = RS.HUD.loadFace(player.faceName());
}
this._maskBitmap = RS.HUD.loadPicture(RS.HUD.param.imgMasking);
this._maskBitmap.addLoadListener(function() {
this._faceBitmap.addLoadListener(this.circleClippingMask.bind(this, player.faceIndex()));
}.bind(this));
};
HUD.prototype.circleClippingMask = function(faceIndex) {
this._face = new Sprite();
var fw = Window_Base._faceWidth;
var fh = Window_Base._faceHeight;
var sx = (faceIndex % 4) * fw;
var sy = Math.floor(faceIndex / 4) * fh;
this._face.bitmap = new Bitmap(nFaceDiameter, nFaceDiameter);
if (RS.HUD.param.blurProcessing) {
this._face.bitmap.drawClippingImage(this._faceBitmap, this._maskBitmap, 0, 0, sx, sy);
} else {
this._face.bitmap.drawClippingImageNonBlur(this._faceBitmap, 0, 0, sx, sy);
}
this.addChild(this._face);
this.setCoord(this._face, RS.HUD.param.ptFace);
};
HUD.prototype.createMask = function (parent) {
var mask = new PIXI.Graphics();
mask.beginFill(0x0000ff, 1.0);
mask.drawRect(0,0, parent.width, parent.height);
mask.endFill();
parent.mask = mask;
return mask;
};
HUD.prototype.createHp = function() {
this._hp = this.fromImage(RS.HUD.param.imgHP);
this._hpMask = this.createMask(this._hp);
this.addChild(this._hpMask, this._hp);
};
HUD.prototype.createMp = function() {
this._mp = this.fromImage(RS.HUD.param.imgMP);
this._mpMask = this.createMask(this._mp);
this.addChild(this._mpMask, this._mp);
};
HUD.prototype.createExp = function() {
this._exp = this.fromImage(RS.HUD.param.imgEXP);
this._expMask = this.createMask(this._exp);
this.addChild(this._expMask, this._exp);
};
HUD.prototype.getTextParams = function(src) {
var param = RS.HUD.param;
var textProperties = {
'HP': [param.hpTextSize, param.szHpColor, param.szHpOutlineColor, param.szHpOutlineWidth],
'MP': [param.mpTextSize, param.szMpColor, param.szMpOutlineColor, param.szMpOutlineWidth],
'EXP': [param.expTextSize, param.szExpColor, param.szExpOutlineColor, param.szExpOutlineWidth],
'LEVEL': [param.levelTextSize, param.szLevelColor, param.szLevelOutlineColor, param.szLevelOutlineWidth],
'NAME': [param.nameTextSize, param.szNameColor, param.szNameOutlineColor, param.szNameOutlineWidth]
};
return textProperties[src];
};
HUD.prototype.createText = function() {
this._hpText = this.addText(this.getHp.bind(this), this.getTextParams('HP'));
this._mpText = this.addText(this.getMp.bind(this), this.getTextParams('MP'));
this._expText = this.addText(this.getExp.bind(this), this.getTextParams('EXP'));
this._levelText = this.addText(this.getLevel.bind(this), this.getTextParams('LEVEL'));
this._nameText = this.addText(this.getName.bind(this), this.getTextParams('NAME'));
};
HUD.prototype.setPosition = function() {
var param = RS.HUD.param;
if(this._face) this.setCoord(this._face, param.ptFace);
this.setCoord(this._hpMask, param.ptHP);
this.setCoord(this._hp, param.ptHP);
this.setCoord(this._mpMask, param.ptMP);
this.setCoord(this._mp, param.ptMP);
this.setCoord(this._expMask, param.ptEXP);
this.setCoord(this._exp, param.ptEXP);
this.setCoord(this._hpText, param.ptHPText);
this.setCoord(this._mpText, param.ptMPText);
this.setCoord(this._levelText, param.ptLevelText);
this.setCoord(this._expText, param.ptEXPText);
this.setCoord(this._nameText, param.ptNameText);
};
HUD.prototype.addText = function(strFunc, params) {
var bitmap = new Bitmap(120, params[0] + 8);
var text = new TextData(bitmap, strFunc, params);
var length = this.children.length;
this.addChildAt(text, length);
text.drawDisplayText();
return text;
};
HUD.prototype.getPlayer = function() {
return $gameParty.members()[this._memberIndex];
};
HUD.prototype.getHp = function() {
var player = this.getPlayer();
if(!player) return "0 / 0";
if(RS.HUD.param.showComma) {
return "%1 / %2".appendComma(player.hp, player.mhp);
} else {
return "%1 / %2".format(player.hp, player.mhp);
}
};
HUD.prototype.getMp = function() {
var player = this.getPlayer();
if(!player) return "0 / 0";
if(RS.HUD.param.showComma) {
return "%1 / %2".appendComma(player.mp, player.mmp);
} else {
return "%1 / %2".format(player.mp, player.mmp);
}
};
HUD.prototype.getExp = function() {
var player = this.getPlayer();
if(!player) return "0 / 0";
if(player.isMaxLevel()) return RS.HUD.param.maxExpText;
if(RS.HUD.param.showComma) {
return "%1 / %2".appendComma(player.relativeExp(), player.relativeMaxExp());
} else {
return "%1 / %2".format(player.relativeExp(), player.relativeMaxExp());
}
};
HUD.prototype.getLevel = function() {
var player = this.getPlayer();
if(!player) return "0";
if(RS.HUD.param.showComma) {
return "%1".appendComma(player.level);
} else {
return "%1".format(player.level);
}
};
HUD.prototype.getName = function() {
var player = this.getPlayer();
if(!player) return "";
var name = player && player.name();
if(name) {
return name;
} else {
return ' ';
}
};
HUD.prototype.getHpRate = function() {
var player = this.getPlayer();
if(!player) return 0;
return this._hp.width * (player.hp / player.mhp);
};
HUD.prototype.getMpRate = function() {
var player = this.getPlayer();
if(!player) return 0;
return this._mp.width * (player.mp / player.mmp);
};
HUD.prototype.getExpRate = function() {
var player = this.getPlayer();
if(!player) return 0;
return this._exp.width * (player.relativeExp() / player.relativeMaxExp());
};
HUD.prototype.getRealExpRate = function () {
var player = this.getPlayer();
if(!player) return 0;
if(this.inBattle() && $dataSystem.optDisplayTp) {
return ( player.tp / player.maxTp() );
} else {
return ( player.relativeExp() / player.relativeMaxExp() );
}
};
HUD.prototype.setCoord = function(s,obj) {
var oy = (s._callbackFunction instanceof Function) ? (s.bitmap.height / 2) : 0;
s.x = this._hud.x + obj.x;
s.y = this._hud.y + obj.y - oy;
s.visible = obj.visible;
};
HUD.prototype.update = function() {
this.paramUpdate();
};
HUD.prototype.updateText = function() {
this._hpText.requestUpdate();
this._mpText.requestUpdate();
this._expText.requestUpdate();
this._levelText.requestUpdate();
this._nameText.requestUpdate();
};
HUD.prototype.updateGuage = function (mask, w, h) {
if(!mask) return;
mask.clear();
mask.beginFill(0x0000ff, 1.0);
mask.drawRect(0,0, w, h);
mask.endFill();
};
HUD.prototype.paramUpdate = function() {
this.updateGuage(this._hpMask, this.getHpRate(), this._hp.height);
this.updateGuage(this._mpMask, this.getMpRate(), this._mp.height);
this.updateGuage(this._expMask, this.getExpRate(), this._exp.height);
};
HUD.prototype.inBattle = function() {
return (SceneManager._scene instanceof Scene_Battle ||
$gameParty.inBattle() ||
DataManager.isBattleTest());
};
Object.defineProperty(HUD.prototype, 'show', {
get: function() {
return $gameSystem._rs_hud.show;
},
set: function(value) {
this.children.forEach( function(i) {
i.visible = value;
}, this);
$gameSystem._rs_hud.show = value;
if(value === true) {
this.setPosition();
}
},
});
Object.defineProperty(HUD.prototype, 'opacity', {
get: function() {
return $gameSystem._rs_hud.opacity;
},
set: function(value) {
this.children.forEach( function(i) {
i.opacity = value.clamp(0, 255);
}, this);
$gameSystem._rs_hud.opacity = value.clamp(0, 255);
},
});
//----------------------------------------------------------------------------
// Scene_Map
//
//
var alias_Scene_Map_createDisplayObjects = Scene_Map.prototype.createDisplayObjects;
Scene_Map.prototype.createDisplayObjects = function() {
alias_Scene_Map_createDisplayObjects.call(this);
if(RS.HUD.param.battleOnly || ($dataMap && $dataMap.meta.DISABLE_HUD) ) {
$gameHud = new RS_EmptyHudLayer();
} else {
this._hudLayer = new RS_HudLayer();
this._hudLayer.setFrame(0, 0, Graphics.boxWidth, Graphics.boxHeight);
$gameHud = this._hudLayer;
this._hudLayer.drawAllHud();
this.addChild(this._hudLayer);
this.swapChildren(this._windowLayer, this._hudLayer);
}
};
var alias_Scene_Map_start = Scene_Map.prototype.start;
Scene_Map.prototype.start = function () {
alias_Scene_Map_start.call(this);
$gameTemp.notifyHudTextRefresh();
};
var alias_Scene_Map_terminate = Scene_Map.prototype.terminate;
Scene_Map.prototype.terminate = function() {
this.removeChild(this._hudLayer);
$gameHud = null;
alias_Scene_Map_terminate.call(this);
};
//----------------------------------------------------------------------------
// Game_Party
//
//
var alias_Game_Party_addActor = Game_Party.prototype.addActor;
Game_Party.prototype.addActor = function(actorId) {
alias_Game_Party_addActor.call(this, actorId);
$gameTemp.notifyHudRefresh();
};
var alias_Game_Party_removeActor = Game_Party.prototype.removeActor;
Game_Party.prototype.removeActor = function(actorId) {
alias_Game_Party_removeActor.call(this, actorId);
$gameTemp.notifyHudRefresh();
};
//----------------------------------------------------------------------------
// Scene_Boot
//
//
var alias_Scene_Boot_loadSystemWindowImage = Scene_Boot.prototype.loadSystemWindowImage;
Scene_Boot.prototype.loadSystemWindowImage = function() {
alias_Scene_Boot_loadSystemWindowImage.call(this);
// Load Face
RS.HUD.param.preloadImportantFaces.forEach(function(i) {
if(Utils.RPGMAKER_VERSION >= '1.5.0') {
ImageManager.reserveFace(i)
} else {
ImageManager.loadFace(i);
}
}, this);
if(Utils.RPGMAKER_VERSION >= '1.5.0') {
ImageManager.reservePicture(RS.HUD.param.imgHP);
ImageManager.reservePicture(RS.HUD.param.imgMP);
ImageManager.reservePicture(RS.HUD.param.imgEXP);
}
};
var alias_Scene_Boot_start = Scene_Boot.prototype.start;
Scene_Boot.prototype.start = function() {
alias_Scene_Boot_start.call(this);
// Load Custom Anchor
for(var i = 0; i < RS.HUD.param.nMaxMembers; i++) {
RS.HUD.param.ptCustormAnchor.push( RS.HUD.loadCustomPosition(parameters[String('Custom Pos ' + (i + 1))] || '0, 0') );
}
// Load Custom Font
if(RS.HUD.param.bUseCustomFont) {
Graphics.loadFont(RS.HUD.param.szCustomFontName, RS.HUD.param.szCustomFontSrc);
}
};
//----------------------------------------------------------------------------
// Scene_Map
//
//
var alias_Scene_Map_snapForBattleBackground = Scene_Map.prototype.snapForBattleBackground;
Scene_Map.prototype.snapForBattleBackground = function() {
var temp = $gameHud.show;
if($gameHud && $gameHud.show) $gameHud.show = false;
alias_Scene_Map_snapForBattleBackground.call(this);
if($gameHud && !$gameHud.show) {
RS.HUD.param.isPreviousShowUp = temp;
$gameHud.show = temp;
}
};
var alias_Scene_Map_updateFade = Scene_Map.prototype.updateFade;
Scene_Map.prototype.updateFade = function() {
alias_Scene_Map_updateFade.call(this);
if(this._fadeDuration == 0 && RS.HUD.param.isCurrentBattleShowUp) {
if($gameHud) $gameHud.show = RS.HUD.param.isPreviousShowUp;
RS.HUD.param.isCurrentBattleShowUp = false;
}
};
var alias_Scene_Battle_updateFade = Scene_Battle.prototype.updateFade;
Scene_Battle.prototype.updateFade = function() {
alias_Scene_Battle_updateFade.call(this);
if(this._fadeDuration == 0 && !RS.HUD.param.isCurrentBattleShowUp) {
if($gameHud) $gameHud.show = true;
RS.HUD.param.isCurrentBattleShowUp = true;
}
};
//----------------------------------------------------------------------------
// Game_Interpreter
//
//
var alias_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
alias_Game_Interpreter_pluginCommand.call(this, command, args);
if(command === "RS_HUD") {
switch (args[0].toLowerCase()) {
case 'opacity':
$gameHud.opacity = Number(args[1]);
break;
case 'visible':
$gameHud.show = Boolean(args[1] === "true");
break;
case 'import':
RS.HUD.importDataWithAjax(args[1] + '.json');
break;
case 'export':
RS.HUD.exportData(args[1] + '.json');
break;
}
}
};
//----------------------------------------------------------------------------
// String Utils
//
//
/**
* String.prototype.toArray
*/
String.prototype.toArray = function(){
return this.split("");
}
/**
* String.prototype.reverse
*/
String.prototype.reverse = function(){
return this.toArray().reverse().join("");
}
/**
* String.prototype.toComma
*/
String.prototype.toComma = function(){
return this.reverse().match(/.{1,3}/g).join(",").reverse();
}
/**
* Replaces %1, %2 and so on in the string to the arguments.
*
* @method String.prototype.format
* @param {Any} ...args The objects to format
* @return {String} A formatted string
*/
String.prototype.appendComma = function() {
var args = arguments;
return this.replace(/%([0-9]+)/g, function(s, n) {
return (args[Number(n) - 1] + '').toComma();
});
};
//============================================================================
// Scene_Boot
//============================================================================
var alias_Scene_Boot_isReady = Scene_Boot.prototype.isReady;
Scene_Boot.prototype.isReady = function() {
if(alias_Scene_Boot_isReady.call(this)) {
return RS.HUD.param.init;
} else {
return false;
}
};
//----------------------------------------------------------------------------
// Output Objects
//
//
window.HUD = HUD;
window.RS_HudLayer = RS_HudLayer;
})();
| biud436/MV | HUD/RS_HUD_OptimizedMobile.js | JavaScript | mit | 50,310 | [
30522,
1013,
30524,
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,
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... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>User agent detail - Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; QQDownload 691; SV1) QQBrowser/6.11.12388.201</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/css/materialize.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="../circle.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="section">
<h1 class="header center orange-text">User agent detail</h1>
<div class="row center">
<h5 class="header light">
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; QQDownload 691; SV1) QQBrowser/6.11.12388.201
</h5>
</div>
</div>
<div class="section">
<table class="striped"><tr><th></th><th colspan="3">General</th><th colspan="5">Device</th><th colspan="3">Bot</th><th colspan="2"></th></tr><tr><th>Provider</th><th>Browser</th><th>Engine</th><th>OS</th><th>Brand</th><th>Model</th><th>Type</th><th>Is mobile</th><th>Is touch</th><th>Is bot</th><th>Name</th><th>Type</th><th>Parse time</th><th>Actions</th></tr><tr><th colspan="14" class="green lighten-3">Test suite</th></tr><tr><td>WhichBrowser<br /><small>v2.0.18</small><br /><small>vendor/whichbrowser/parser/tests/data/desktop/browser-qq.yaml</small></td><td>QQ Browser 6.11</td><td> </td><td>Windows XP</td><td style="border-left: 1px solid #555"></td><td></td><td>desktop</td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"></td><td></td><td><i class="material-icons">close</i></td><td>0</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-027cff01-4a76-491b-ace3-9289fcbc172f">Detail</a>
<!-- Modal Structure -->
<div id="modal-027cff01-4a76-491b-ace3-9289fcbc172f" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>WhichBrowser result detail</h4>
<p><pre><code class="php">Array
(
[headers] => User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; QQDownload 691; SV1) QQBrowser/6.11.12388.201
[result] => Array
(
[browser] => Array
(
[name] => QQ Browser
[version] => 6.11
[type] => browser
)
[os] => Array
(
[name] => Windows
[version] => Array
(
[value] => 5.1
[alias] => XP
)
)
[device] => Array
(
[type] => desktop
)
)
[readable] => QQ Browser 6.11 on Windows XP
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><th colspan="14" class="green lighten-3">Providers</th></tr><tr><td>BrowscapFull<br /><small>6014</small><br /></td><td>IE 6.0</td><td>Trident </td><td>WinXP 5.1</td><td style="border-left: 1px solid #555"></td><td></td><td>Desktop</td><td></td><td></td><td style="border-left: 1px solid #555"></td><td></td><td></td><td>0.017</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-47a9cd06-e213-4882-bc34-db6aed664223">Detail</a>
<!-- Modal Structure -->
<div id="modal-47a9cd06-e213-4882-bc34-db6aed664223" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>BrowscapFull result detail</h4>
<p><pre><code class="php">stdClass Object
(
[browser_name_regex] => /^mozilla\/4\.0 \(compatible; msie 6\.0.*; .*windows nt 5\.1.*$/
[browser_name_pattern] => mozilla/4.0 (compatible; msie 6.0*; *windows nt 5.1*
[parent] => IE 6.0 for Desktop
[comment] => IE 6.0
[browser] => IE
[browser_type] => Browser
[browser_bits] => 32
[browser_maker] => Microsoft Corporation
[browser_modus] => unknown
[version] => 6.0
[majorver] => 6
[minorver] => 0
[platform] => WinXP
[platform_version] => 5.1
[platform_description] => Windows XP
[platform_bits] => 32
[platform_maker] => Microsoft Corporation
[alpha] =>
[beta] =>
[win16] =>
[win32] => 1
[win64] =>
[frames] => 1
[iframes] => 1
[tables] => 1
[cookies] => 1
[backgroundsounds] => 1
[javascript] => 1
[vbscript] => 1
[javaapplets] => 1
[activexcontrols] => 1
[ismobiledevice] =>
[istablet] =>
[issyndicationreader] =>
[crawler] =>
[isfake] =>
[isanonymized] =>
[ismodified] =>
[cssversion] => 1
[aolversion] => 0
[device_name] => Windows Desktop
[device_maker] => Various
[device_type] => Desktop
[device_pointing_method] => mouse
[device_code_name] => Windows Desktop
[device_brand_name] => unknown
[renderingengine_name] => Trident
[renderingengine_version] => unknown
[renderingengine_description] => For Internet Explorer since version 4.0 and embedded WebBrowser controls (such as Internet Explorer shells, Maxthon and some media players).
[renderingengine_maker] => Microsoft Corporation
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><td>BrowscapLite<br /><small>6014</small><br /></td><td>IE 6.0</td><td><i class="material-icons">close</i></td><td>Win32 </td><td style="border-left: 1px solid #555"><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td>Desktop</td><td></td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td>0.008</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-42bb56ba-b834-47c5-bea0-c0270e9ab371">Detail</a>
<!-- Modal Structure -->
<div id="modal-42bb56ba-b834-47c5-bea0-c0270e9ab371" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>BrowscapLite result detail</h4>
<p><pre><code class="php">stdClass Object
(
[browser_name_regex] => /^mozilla\/4\.0 \(compatible; msie 6\.0.*; .*windows.*$/
[browser_name_pattern] => mozilla/4.0 (compatible; msie 6.0*; *windows*
[parent] => IE 6.0 for Desktop
[comment] => IE 6.0
[browser] => IE
[browser_type] => unknown
[browser_bits] => 0
[browser_maker] => unknown
[browser_modus] => unknown
[version] => 6.0
[majorver] => 0
[minorver] => 0
[platform] => Win32
[platform_version] => unknown
[platform_description] => unknown
[platform_bits] => 0
[platform_maker] => unknown
[alpha] => false
[beta] => false
[win16] => false
[win32] => false
[win64] => false
[frames] => false
[iframes] => false
[tables] => false
[cookies] => false
[backgroundsounds] => false
[javascript] => false
[vbscript] => false
[javaapplets] => false
[activexcontrols] => false
[ismobiledevice] =>
[istablet] =>
[issyndicationreader] => false
[crawler] => false
[isfake] => false
[isanonymized] => false
[ismodified] => false
[cssversion] => 0
[aolversion] => 0
[device_name] => unknown
[device_maker] => unknown
[device_type] => Desktop
[device_pointing_method] => unknown
[device_code_name] => unknown
[device_brand_name] => unknown
[renderingengine_name] => unknown
[renderingengine_version] => unknown
[renderingengine_description] => unknown
[renderingengine_maker] => unknown
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><td>BrowscapPhp<br /><small>6014</small><br /></td><td>IE 6.0</td><td><i class="material-icons">close</i></td><td>WinXP </td><td style="border-left: 1px solid #555"><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td>Desktop</td><td></td><td></td><td style="border-left: 1px solid #555"></td><td></td><td><i class="material-icons">close</i></td><td>0.012</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-ad0041a2-b0f4-43f6-a70d-cad1443caa68">Detail</a>
<!-- Modal Structure -->
<div id="modal-ad0041a2-b0f4-43f6-a70d-cad1443caa68" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>BrowscapPhp result detail</h4>
<p><pre><code class="php">stdClass Object
(
[browser_name_regex] => /^mozilla\/4\.0 \(compatible; msie 6\.0.*; .*windows nt 5\.1.*$/
[browser_name_pattern] => mozilla/4.0 (compatible; msie 6.0*; *windows nt 5.1*
[parent] => IE 6.0 for Desktop
[comment] => IE 6.0
[browser] => IE
[browser_type] => unknown
[browser_bits] => 0
[browser_maker] => Microsoft Corporation
[browser_modus] => unknown
[version] => 6.0
[majorver] => 6
[minorver] => 0
[platform] => WinXP
[platform_version] => unknown
[platform_description] => unknown
[platform_bits] => 0
[platform_maker] => unknown
[alpha] => false
[beta] => false
[win16] => false
[win32] => false
[win64] => false
[frames] => false
[iframes] => false
[tables] => false
[cookies] => false
[backgroundsounds] => false
[javascript] => false
[vbscript] => false
[javaapplets] => false
[activexcontrols] => false
[ismobiledevice] =>
[istablet] =>
[issyndicationreader] => false
[crawler] =>
[isfake] => false
[isanonymized] => false
[ismodified] => false
[cssversion] => 0
[aolversion] => 0
[device_name] => unknown
[device_maker] => unknown
[device_type] => Desktop
[device_pointing_method] => mouse
[device_code_name] => unknown
[device_brand_name] => unknown
[renderingengine_name] => unknown
[renderingengine_version] => unknown
[renderingengine_description] => unknown
[renderingengine_maker] => unknown
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><td>DonatjUAParser<br /><small>v0.5.1</small><br /></td><td>MSIE 6.0</td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td>0</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-15fbc1f0-2615-4d42-b5d9-a30dd647b050">Detail</a>
<!-- Modal Structure -->
<div id="modal-15fbc1f0-2615-4d42-b5d9-a30dd647b050" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>DonatjUAParser result detail</h4>
<p><pre><code class="php">Array
(
[platform] => Windows
[browser] => MSIE
[version] => 6.0
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><td>JenssegersAgent<br /><small>v2.3.3</small><br /></td><td>IE 6.0</td><td><i class="material-icons">close</i></td><td>Windows 5.1</td><td style="border-left: 1px solid #555"><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td></td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"></td><td></td><td><i class="material-icons">close</i></td><td>0.005</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-b85a2b91-6a55-4436-a82c-1ea0d46e2e51">Detail</a>
<!-- Modal Structure -->
<div id="modal-b85a2b91-6a55-4436-a82c-1ea0d46e2e51" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>JenssegersAgent result detail</h4>
<p><pre><code class="php">Array
(
[browserName] => IE
[browserVersion] => 6.0
[osName] => Windows
[osVersion] => 5.1
[deviceModel] =>
[isMobile] =>
[isRobot] =>
[botName] =>
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><td>NeutrinoApiCom<br /><small></small><br /></td><td>IE 6.0</td><td><i class="material-icons">close</i></td><td>Windows 5.1</td><td style="border-left: 1px solid #555"></td><td></td><td>desktop-browser</td><td></td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"></td><td></td><td><i class="material-icons">close</i></td><td>0.21101</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-8c2a7a4e-3fbf-4df2-8d61-5e730422f67b">Detail</a>
<!-- Modal Structure -->
<div id="modal-8c2a7a4e-3fbf-4df2-8d61-5e730422f67b" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>NeutrinoApiCom result detail</h4>
<p><pre><code class="php">stdClass Object
(
[mobile_screen_height] => 0
[is_mobile] =>
[type] => desktop-browser
[mobile_brand] =>
[mobile_model] =>
[version] => 6.0
[is_android] =>
[browser_name] => IE
[operating_system_family] => Windows
[operating_system_version] => 5.1
[is_ios] =>
[producer] => Microsoft Corporation.
[operating_system] => Windows XP
[mobile_screen_width] => 0
[mobile_browser] =>
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><td>PiwikDeviceDetector<br /><small>3.6.1</small><br /></td><td>QQ Browser 6.11</td><td> </td><td>Windows XP</td><td style="border-left: 1px solid #555"></td><td></td><td>desktop</td><td></td><td></td><td style="border-left: 1px solid #555"></td><td></td><td></td><td>0.004</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-4a941d34-a8d3-4914-9724-346f60ad7046">Detail</a>
<!-- Modal Structure -->
<div id="modal-4a941d34-a8d3-4914-9724-346f60ad7046" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>PiwikDeviceDetector result detail</h4>
<p><pre><code class="php">Array
(
[client] => Array
(
[type] => browser
[name] => QQ Browser
[short_name] => QQ
[version] => 6.11
[engine] =>
)
[operatingSystem] => Array
(
[name] => Windows
[short_name] => WIN
[version] => XP
[platform] =>
)
[device] => Array
(
[brand] =>
[brandName] =>
[model] =>
[device] => 0
[deviceName] => desktop
)
[bot] =>
[extra] => Array
(
[isBot] =>
[isBrowser] => 1
[isFeedReader] =>
[isMobileApp] =>
[isPIM] =>
[isLibrary] =>
[isMediaPlayer] =>
[isCamera] =>
[isCarBrowser] =>
[isConsole] =>
[isFeaturePhone] =>
[isPhablet] =>
[isPortableMediaPlayer] =>
[isSmartDisplay] =>
[isSmartphone] =>
[isTablet] =>
[isTV] =>
[isDesktop] => 1
[isMobile] =>
[isTouchEnabled] =>
)
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><td>SinergiBrowserDetector<br /><small>6.0.1</small><br /></td><td>Internet Explorer 6.0</td><td><i class="material-icons">close</i></td><td>Windows XP</td><td style="border-left: 1px solid #555"><i class="material-icons">close</i></td><td></td><td><i class="material-icons">close</i></td><td></td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td>0</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-ec1cd248-02b0-457e-8a9d-35bb99af008c">Detail</a>
<!-- Modal Structure -->
<div id="modal-ec1cd248-02b0-457e-8a9d-35bb99af008c" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>SinergiBrowserDetector result detail</h4>
<p><pre><code class="php">Array
(
[browser] => Sinergi\BrowserDetector\Browser Object
(
[userAgent:Sinergi\BrowserDetector\Browser:private] => Sinergi\BrowserDetector\UserAgent Object
(
[userAgentString:Sinergi\BrowserDetector\UserAgent:private] => Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; QQDownload 691; SV1) QQBrowser/6.11.12388.201
)
[name:Sinergi\BrowserDetector\Browser:private] => Internet Explorer
[version:Sinergi\BrowserDetector\Browser:private] => 6.0
[isRobot:Sinergi\BrowserDetector\Browser:private] =>
[isChromeFrame:Sinergi\BrowserDetector\Browser:private] =>
[isFacebookWebView:Sinergi\BrowserDetector\Browser:private] =>
[isCompatibilityMode:Sinergi\BrowserDetector\Browser:private] =>
)
[operatingSystem] => Sinergi\BrowserDetector\Os Object
(
[name:Sinergi\BrowserDetector\Os:private] => Windows
[version:Sinergi\BrowserDetector\Os:private] => XP
[isMobile:Sinergi\BrowserDetector\Os:private] =>
[userAgent:Sinergi\BrowserDetector\Os:private] => Sinergi\BrowserDetector\UserAgent Object
(
[userAgentString:Sinergi\BrowserDetector\UserAgent:private] => Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; QQDownload 691; SV1) QQBrowser/6.11.12388.201
)
)
[device] => Sinergi\BrowserDetector\Device Object
(
[name:Sinergi\BrowserDetector\Device:private] => unknown
[userAgent:Sinergi\BrowserDetector\Device:private] => Sinergi\BrowserDetector\UserAgent Object
(
[userAgentString:Sinergi\BrowserDetector\UserAgent:private] => Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; QQDownload 691; SV1) QQBrowser/6.11.12388.201
)
)
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><td>UAParser<br /><small>v3.4.5</small><br /></td><td>QQ Browser 6.11.12388</td><td><i class="material-icons">close</i></td><td>Windows XP </td><td style="border-left: 1px solid #555"></td><td></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"></td><td></td><td><i class="material-icons">close</i></td><td>0.003</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-3160e405-8a8f-46dd-8f47-5115f06462d2">Detail</a>
<!-- Modal Structure -->
<div id="modal-3160e405-8a8f-46dd-8f47-5115f06462d2" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>UAParser result detail</h4>
<p><pre><code class="php">UAParser\Result\Client Object
(
[ua] => UAParser\Result\UserAgent Object
(
[major] => 6
[minor] => 11
[patch] => 12388
[family] => QQ Browser
)
[os] => UAParser\Result\OperatingSystem Object
(
[major] =>
[minor] =>
[patch] =>
[patchMinor] =>
[family] => Windows XP
)
[device] => UAParser\Result\Device Object
(
[brand] =>
[model] =>
[family] => Other
)
[originalUserAgent] => Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; QQDownload 691; SV1) QQBrowser/6.11.12388.201
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><td>UserAgentApiCom<br /><small></small><br /></td><td>Internet Explorer 6.0</td><td> </td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td>Desktop</td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"></td><td></td><td><i class="material-icons">close</i></td><td>0.15201</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-afeb05fb-26b9-4509-b8ac-0c604a9e97d6">Detail</a>
<!-- Modal Structure -->
<div id="modal-afeb05fb-26b9-4509-b8ac-0c604a9e97d6" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>UserAgentApiCom result detail</h4>
<p><pre><code class="php">stdClass Object
(
[platform_name] => Windows XP
[platform_version] => Windows NT 5.1
[platform_type] => Desktop
[browser_name] => Internet Explorer
[browser_version] => 6.0
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><td>UserAgentStringCom<br /><small></small><br /></td><td>Internet Explorer 6.0</td><td><i class="material-icons">close</i></td><td>Windows XP </td><td style="border-left: 1px solid #555"><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"></td><td></td><td></td><td>0.083</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-08a9ddfb-838f-48d7-9ede-1d132306b2ee">Detail</a>
<!-- Modal Structure -->
<div id="modal-08a9ddfb-838f-48d7-9ede-1d132306b2ee" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>UserAgentStringCom result detail</h4>
<p><pre><code class="php">stdClass Object
(
[agent_type] => Browser
[agent_name] => Internet Explorer
[agent_version] => 6.0
[os_type] => Windows
[os_name] => Windows XP
[os_versionName] =>
[os_versionNumber] =>
[os_producer] =>
[os_producerURL] =>
[linux_distibution] => Null
[agent_language] =>
[agent_languageTag] =>
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><td>WhatIsMyBrowserCom<br /><small></small><br /></td><td>QQDownload Download Manager 691</td><td> </td><td>Windows Windows NT 5.1</td><td style="border-left: 1px solid #555"></td><td></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td>0.23501</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-5fc1ff22-a74d-481b-9ad1-fcfde73ded9c">Detail</a>
<!-- Modal Structure -->
<div id="modal-5fc1ff22-a74d-481b-9ad1-fcfde73ded9c" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>WhatIsMyBrowserCom result detail</h4>
<p><pre><code class="php">stdClass Object
(
[operating_system_name] => Windows
[simple_sub_description_string] =>
[simple_browser_string] => QQDownload Download Manager 691 on Windows XP SP2
[browser_version] => 691
[extra_info] => Array
(
)
[operating_platform] =>
[extra_info_table] => Array
(
)
[layout_engine_name] =>
[detected_addons] => Array
(
)
[operating_system_flavour_code] =>
[hardware_architecture] =>
[operating_system_flavour] =>
[operating_system_frameworks] => Array
(
)
[browser_name_code] => qqdownload-download-manager
[operating_system_version] => XP SP2
[simple_operating_platform_string] =>
[is_abusive] =>
[layout_engine_version] =>
[browser_capabilities] => Array
(
)
[operating_platform_vendor_name] =>
[operating_system] => Windows XP SP2
[operating_system_version_full] => Windows NT 5.1
[operating_platform_code] =>
[browser_name] => QQDownload Download Manager
[operating_system_name_code] => windows
[user_agent] => Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; QQDownload 691; SV1) QQBrowser/6.11.12388.201
[browser_version_full] => 691
[browser] => QQDownload Download Manager 691
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><td>WhichBrowser<br /><small>v2.0.18</small><br /></td><td>QQ Browser 6.11</td><td> </td><td>Windows XP</td><td style="border-left: 1px solid #555"></td><td></td><td>desktop</td><td></td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"></td><td></td><td><i class="material-icons">close</i></td><td>0.002</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-083a336f-5d73-4505-84f3-c5fc9bb78652">Detail</a>
<!-- Modal Structure -->
<div id="modal-083a336f-5d73-4505-84f3-c5fc9bb78652" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>WhichBrowser result detail</h4>
<p><pre><code class="php">Array
(
[browser] => Array
(
[name] => QQ Browser
[version] => 6.11
[type] => browser
)
[os] => Array
(
[name] => Windows
[version] => Array
(
[value] => 5.1
[alias] => XP
)
)
[device] => Array
(
[type] => desktop
)
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><td>Woothee<br /><small>v1.2.0</small><br /></td><td>Internet Explorer 6.0</td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td>pc</td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"></td><td></td><td><i class="material-icons">close</i></td><td>0</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-f00e7198-0e22-49fe-bad0-dbb3a9cde9b9">Detail</a>
<!-- Modal Structure -->
<div id="modal-f00e7198-0e22-49fe-bad0-dbb3a9cde9b9" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>Woothee result detail</h4>
<p><pre><code class="php">Array
(
[name] => Internet Explorer
[vendor] => Microsoft
[version] => 6.0
[category] => pc
[os] => Windows XP
[os_version] => NT 5.1
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><td>Wurfl<br /><small>1.7.1.0</small><br /></td><td>IE 6.0</td><td><i class="material-icons">close</i></td><td>Windows XP</td><td style="border-left: 1px solid #555"></td><td></td><td>Desktop</td><td></td><td></td><td style="border-left: 1px solid #555"></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td>0.016</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-a2bedf8c-4a95-42a7-96c5-aaf233b2ac50">Detail</a>
<!-- Modal Structure -->
<div id="modal-a2bedf8c-4a95-42a7-96c5-aaf233b2ac50" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>Wurfl result detail</h4>
<p><pre><code class="php">Array
(
[virtual] => Array
(
[is_android] => false
[is_ios] => false
[is_windows_phone] => false
[is_app] => false
[is_full_desktop] => true
[is_largescreen] => true
[is_mobile] => false
[is_robot] => false
[is_smartphone] => false
[is_touchscreen] => false
[is_wml_preferred] => false
[is_xhtmlmp_preferred] => false
[is_html_preferred] => true
[advertised_device_os] => Windows
[advertised_device_os_version] => XP
[advertised_browser] => IE
[advertised_browser_version] => 6.0
[complete_device_name] => Microsoft Internet Explorer
[device_name] => Microsoft Internet Explorer
[form_factor] => Desktop
[is_phone] => false
[is_app_webview] => false
)
[all] => Array
(
[brand_name] => Microsoft
[model_name] => Internet Explorer
[unique] => true
[ununiqueness_handler] =>
[is_wireless_device] => false
[device_claims_web_support] => true
[has_qwerty_keyboard] => true
[can_skip_aligned_link_row] => true
[uaprof] =>
[uaprof2] =>
[uaprof3] =>
[nokia_series] => 0
[nokia_edition] => 0
[device_os] => Desktop
[mobile_browser] => MSIE
[mobile_browser_version] => 6.0
[device_os_version] =>
[pointing_method] => mouse
[release_date] => 2001_august
[marketing_name] =>
[model_extra_info] =>
[nokia_feature_pack] => 0
[can_assign_phone_number] => false
[is_tablet] => false
[manufacturer_name] =>
[is_bot] => false
[is_google_glass] => false
[proportional_font] => false
[built_in_back_button_support] => false
[card_title_support] => false
[softkey_support] => false
[table_support] => false
[numbered_menus] => false
[menu_with_select_element_recommended] => false
[menu_with_list_of_links_recommended] => false
[icons_on_menu_items_support] => false
[break_list_of_links_with_br_element_recommended] => false
[access_key_support] => false
[wrap_mode_support] => false
[times_square_mode_support] => false
[deck_prefetch_support] => false
[elective_forms_recommended] => false
[wizards_recommended] => false
[image_as_link_support] => false
[insert_br_element_after_widget_recommended] => false
[wml_can_display_images_and_text_on_same_line] => false
[wml_displays_image_in_center] => false
[opwv_wml_extensions_support] => false
[wml_make_phone_call_string] => none
[chtml_display_accesskey] => false
[emoji] => false
[chtml_can_display_images_and_text_on_same_line] => false
[chtml_displays_image_in_center] => false
[imode_region] => none
[chtml_make_phone_call_string] => tel:
[chtml_table_support] => true
[xhtml_honors_bgcolor] => true
[xhtml_supports_forms_in_table] => true
[xhtml_support_wml2_namespace] => false
[xhtml_autoexpand_select] => false
[xhtml_select_as_dropdown] => true
[xhtml_select_as_radiobutton] => true
[xhtml_select_as_popup] => true
[xhtml_display_accesskey] => false
[xhtml_supports_invisible_text] => false
[xhtml_supports_inline_input] => false
[xhtml_supports_monospace_font] => false
[xhtml_supports_table_for_layout] => false
[xhtml_supports_css_cell_table_coloring] => false
[xhtml_format_as_css_property] => false
[xhtml_format_as_attribute] => false
[xhtml_nowrap_mode] => false
[xhtml_marquee_as_css_property] => false
[xhtml_readable_background_color1] => #FFFFFF
[xhtml_readable_background_color2] => #FFFFFF
[xhtml_allows_disabled_form_elements] => false
[xhtml_document_title_support] => true
[xhtml_preferred_charset] => utf8
[opwv_xhtml_extensions_support] => false
[xhtml_make_phone_call_string] => none
[xhtmlmp_preferred_mime_type] => text/html
[xhtml_table_support] => false
[xhtml_send_sms_string] => none
[xhtml_send_mms_string] => none
[xhtml_file_upload] => supported
[cookie_support] => true
[accept_third_party_cookie] => true
[xhtml_supports_iframe] => full
[xhtml_avoid_accesskeys] => true
[xhtml_can_embed_video] => play_and_stop
[ajax_support_javascript] => true
[ajax_manipulate_css] => true
[ajax_support_getelementbyid] => true
[ajax_support_inner_html] => true
[ajax_xhr_type] => standard
[ajax_manipulate_dom] => true
[ajax_support_events] => true
[ajax_support_event_listener] => true
[ajax_preferred_geoloc_api] => none
[xhtml_support_level] => 4
[preferred_markup] => html_web_4_0
[wml_1_1] => false
[wml_1_2] => false
[wml_1_3] => false
[html_wi_w3_xhtmlbasic] => true
[html_wi_oma_xhtmlmp_1_0] => false
[html_wi_imode_html_1] => false
[html_wi_imode_html_2] => false
[html_wi_imode_html_3] => false
[html_wi_imode_html_4] => false
[html_wi_imode_html_5] => false
[html_wi_imode_htmlx_1] => false
[html_wi_imode_htmlx_1_1] => false
[html_wi_imode_compact_generic] => false
[html_web_3_2] => true
[html_web_4_0] => true
[voicexml] => false
[multipart_support] => false
[total_cache_disable_support] => false
[time_to_live_support] => false
[resolution_width] => 800
[resolution_height] => 600
[columns] => 120
[max_image_width] => 800
[max_image_height] => 600
[rows] => 200
[physical_screen_width] => 400
[physical_screen_height] => 400
[dual_orientation] => false
[density_class] => 1.0
[wbmp] => false
[bmp] => true
[epoc_bmp] => false
[gif_animated] => true
[jpg] => true
[png] => true
[tiff] => false
[transparent_png_alpha] => false
[transparent_png_index] => false
[svgt_1_1] => false
[svgt_1_1_plus] => false
[greyscale] => false
[gif] => true
[colors] => 65536
[webp_lossy_support] => false
[webp_lossless_support] => false
[post_method_support] => true
[basic_authentication_support] => true
[empty_option_value_support] => true
[emptyok] => false
[nokia_voice_call] => false
[wta_voice_call] => false
[wta_phonebook] => false
[wta_misc] => false
[wta_pdc] => false
[https_support] => true
[phone_id_provided] => false
[max_data_rate] => 3200
[wifi] => true
[sdio] => false
[vpn] => false
[has_cellular_radio] => false
[max_deck_size] => 100000
[max_url_length_in_requests] => 128
[max_url_length_homepage] => 0
[max_url_length_bookmark] => 0
[max_url_length_cached_page] => 0
[max_no_of_connection_settings] => 0
[max_no_of_bookmarks] => 0
[max_length_of_username] => 0
[max_length_of_password] => 0
[max_object_size] => 0
[downloadfun_support] => false
[directdownload_support] => false
[inline_support] => false
[oma_support] => false
[ringtone] => false
[ringtone_3gpp] => false
[ringtone_midi_monophonic] => false
[ringtone_midi_polyphonic] => false
[ringtone_imelody] => false
[ringtone_digiplug] => false
[ringtone_compactmidi] => false
[ringtone_mmf] => false
[ringtone_rmf] => false
[ringtone_xmf] => false
[ringtone_amr] => false
[ringtone_awb] => false
[ringtone_aac] => false
[ringtone_wav] => false
[ringtone_mp3] => false
[ringtone_spmidi] => false
[ringtone_qcelp] => false
[ringtone_voices] => 1
[ringtone_df_size_limit] => 0
[ringtone_directdownload_size_limit] => 0
[ringtone_inline_size_limit] => 0
[ringtone_oma_size_limit] => 0
[wallpaper] => false
[wallpaper_max_width] => 0
[wallpaper_max_height] => 0
[wallpaper_preferred_width] => 0
[wallpaper_preferred_height] => 0
[wallpaper_resize] => none
[wallpaper_wbmp] => false
[wallpaper_bmp] => false
[wallpaper_gif] => false
[wallpaper_jpg] => false
[wallpaper_png] => false
[wallpaper_tiff] => false
[wallpaper_greyscale] => false
[wallpaper_colors] => 2
[wallpaper_df_size_limit] => 0
[wallpaper_directdownload_size_limit] => 0
[wallpaper_inline_size_limit] => 0
[wallpaper_oma_size_limit] => 0
[screensaver] => false
[screensaver_max_width] => 0
[screensaver_max_height] => 0
[screensaver_preferred_width] => 0
[screensaver_preferred_height] => 0
[screensaver_resize] => none
[screensaver_wbmp] => false
[screensaver_bmp] => false
[screensaver_gif] => false
[screensaver_jpg] => false
[screensaver_png] => false
[screensaver_greyscale] => false
[screensaver_colors] => 2
[screensaver_df_size_limit] => 0
[screensaver_directdownload_size_limit] => 0
[screensaver_inline_size_limit] => 0
[screensaver_oma_size_limit] => 0
[picture] => false
[picture_max_width] => 0
[picture_max_height] => 0
[picture_preferred_width] => 0
[picture_preferred_height] => 0
[picture_resize] => none
[picture_wbmp] => false
[picture_bmp] => false
[picture_gif] => false
[picture_jpg] => false
[picture_png] => false
[picture_greyscale] => false
[picture_colors] => 2
[picture_df_size_limit] => 0
[picture_directdownload_size_limit] => 0
[picture_inline_size_limit] => 0
[picture_oma_size_limit] => 0
[video] => false
[oma_v_1_0_forwardlock] => false
[oma_v_1_0_combined_delivery] => false
[oma_v_1_0_separate_delivery] => false
[streaming_video] => false
[streaming_3gpp] => false
[streaming_mp4] => false
[streaming_mov] => false
[streaming_video_size_limit] => 0
[streaming_real_media] => none
[streaming_flv] => false
[streaming_3g2] => false
[streaming_vcodec_h263_0] => -1
[streaming_vcodec_h263_3] => -1
[streaming_vcodec_mpeg4_sp] => -1
[streaming_vcodec_mpeg4_asp] => -1
[streaming_vcodec_h264_bp] => -1
[streaming_acodec_amr] => none
[streaming_acodec_aac] => none
[streaming_wmv] => none
[streaming_preferred_protocol] => rtsp
[streaming_preferred_http_protocol] => none
[wap_push_support] => false
[connectionless_service_indication] => false
[connectionless_service_load] => false
[connectionless_cache_operation] => false
[connectionoriented_unconfirmed_service_indication] => false
[connectionoriented_unconfirmed_service_load] => false
[connectionoriented_unconfirmed_cache_operation] => false
[connectionoriented_confirmed_service_indication] => false
[connectionoriented_confirmed_service_load] => false
[connectionoriented_confirmed_cache_operation] => false
[utf8_support] => true
[ascii_support] => false
[iso8859_support] => false
[expiration_date] => false
[j2me_cldc_1_0] => false
[j2me_cldc_1_1] => false
[j2me_midp_1_0] => false
[j2me_midp_2_0] => false
[doja_1_0] => false
[doja_1_5] => false
[doja_2_0] => false
[doja_2_1] => false
[doja_2_2] => false
[doja_3_0] => false
[doja_3_5] => false
[doja_4_0] => false
[j2me_jtwi] => false
[j2me_mmapi_1_0] => false
[j2me_mmapi_1_1] => false
[j2me_wmapi_1_0] => false
[j2me_wmapi_1_1] => false
[j2me_wmapi_2_0] => false
[j2me_btapi] => false
[j2me_3dapi] => false
[j2me_locapi] => false
[j2me_nokia_ui] => false
[j2me_motorola_lwt] => false
[j2me_siemens_color_game] => false
[j2me_siemens_extension] => false
[j2me_heap_size] => 0
[j2me_max_jar_size] => 0
[j2me_storage_size] => 0
[j2me_max_record_store_size] => 0
[j2me_screen_width] => 0
[j2me_screen_height] => 0
[j2me_canvas_width] => 0
[j2me_canvas_height] => 0
[j2me_bits_per_pixel] => 0
[j2me_audio_capture_enabled] => false
[j2me_video_capture_enabled] => false
[j2me_photo_capture_enabled] => false
[j2me_capture_image_formats] => none
[j2me_http] => false
[j2me_https] => false
[j2me_socket] => false
[j2me_udp] => false
[j2me_serial] => false
[j2me_gif] => false
[j2me_gif89a] => false
[j2me_jpg] => false
[j2me_png] => false
[j2me_bmp] => false
[j2me_bmp3] => false
[j2me_wbmp] => false
[j2me_midi] => false
[j2me_wav] => false
[j2me_amr] => false
[j2me_mp3] => false
[j2me_mp4] => false
[j2me_imelody] => false
[j2me_rmf] => false
[j2me_au] => false
[j2me_aac] => false
[j2me_realaudio] => false
[j2me_xmf] => false
[j2me_wma] => false
[j2me_3gpp] => false
[j2me_h263] => false
[j2me_svgt] => false
[j2me_mpeg4] => false
[j2me_realvideo] => false
[j2me_real8] => false
[j2me_realmedia] => false
[j2me_left_softkey_code] => 0
[j2me_right_softkey_code] => 0
[j2me_middle_softkey_code] => 0
[j2me_select_key_code] => 0
[j2me_return_key_code] => 0
[j2me_clear_key_code] => 0
[j2me_datefield_no_accepts_null_date] => false
[j2me_datefield_broken] => false
[receiver] => false
[sender] => false
[mms_max_size] => 0
[mms_max_height] => 0
[mms_max_width] => 0
[built_in_recorder] => false
[built_in_camera] => false
[mms_jpeg_baseline] => false
[mms_jpeg_progressive] => false
[mms_gif_static] => false
[mms_gif_animated] => false
[mms_png] => false
[mms_bmp] => false
[mms_wbmp] => false
[mms_amr] => false
[mms_wav] => false
[mms_midi_monophonic] => false
[mms_midi_polyphonic] => false
[mms_midi_polyphonic_voices] => 0
[mms_spmidi] => false
[mms_mmf] => false
[mms_mp3] => false
[mms_evrc] => false
[mms_qcelp] => false
[mms_ota_bitmap] => false
[mms_nokia_wallpaper] => false
[mms_nokia_operatorlogo] => false
[mms_nokia_3dscreensaver] => false
[mms_nokia_ringingtone] => false
[mms_rmf] => false
[mms_xmf] => false
[mms_symbian_install] => false
[mms_jar] => false
[mms_jad] => false
[mms_vcard] => false
[mms_vcalendar] => false
[mms_wml] => false
[mms_wbxml] => false
[mms_wmlc] => false
[mms_video] => false
[mms_mp4] => false
[mms_3gpp] => false
[mms_3gpp2] => false
[mms_max_frame_rate] => 0
[nokiaring] => false
[picturemessage] => false
[operatorlogo] => false
[largeoperatorlogo] => false
[callericon] => false
[nokiavcard] => false
[nokiavcal] => false
[sckl_ringtone] => false
[sckl_operatorlogo] => false
[sckl_groupgraphic] => false
[sckl_vcard] => false
[sckl_vcalendar] => false
[text_imelody] => false
[ems] => false
[ems_variablesizedpictures] => false
[ems_imelody] => false
[ems_odi] => false
[ems_upi] => false
[ems_version] => 0
[siemens_ota] => false
[siemens_logo_width] => 101
[siemens_logo_height] => 29
[siemens_screensaver_width] => 101
[siemens_screensaver_height] => 50
[gprtf] => false
[sagem_v1] => false
[sagem_v2] => false
[panasonic] => false
[sms_enabled] => false
[wav] => false
[mmf] => false
[smf] => false
[mld] => false
[midi_monophonic] => false
[midi_polyphonic] => false
[sp_midi] => false
[rmf] => false
[xmf] => false
[compactmidi] => false
[digiplug] => false
[nokia_ringtone] => false
[imelody] => false
[au] => false
[amr] => false
[awb] => false
[aac] => false
[mp3] => false
[voices] => 1
[qcelp] => false
[evrc] => false
[flash_lite_version] =>
[fl_wallpaper] => false
[fl_screensaver] => false
[fl_standalone] => false
[fl_browser] => false
[fl_sub_lcd] => false
[full_flash_support] => true
[css_supports_width_as_percentage] => true
[css_border_image] => none
[css_rounded_corners] => none
[css_gradient] => none
[css_spriting] => false
[css_gradient_linear] => none
[is_transcoder] => false
[transcoder_ua_header] => user-agent
[rss_support] => false
[pdf_support] => true
[progressive_download] => true
[playback_vcodec_h263_0] => -1
[playback_vcodec_h263_3] => -1
[playback_vcodec_mpeg4_sp] => -1
[playback_vcodec_mpeg4_asp] => -1
[playback_vcodec_h264_bp] => -1
[playback_real_media] => none
[playback_3gpp] => false
[playback_3g2] => false
[playback_mp4] => false
[playback_mov] => false
[playback_acodec_amr] => none
[playback_acodec_aac] => none
[playback_df_size_limit] => 0
[playback_directdownload_size_limit] => 0
[playback_inline_size_limit] => 0
[playback_oma_size_limit] => 0
[playback_acodec_qcelp] => false
[playback_wmv] => none
[hinted_progressive_download] => false
[html_preferred_dtd] => html4
[viewport_supported] => false
[viewport_width] => width_equals_max_image_width
[viewport_userscalable] =>
[viewport_initial_scale] =>
[viewport_maximum_scale] =>
[viewport_minimum_scale] =>
[mobileoptimized] => false
[handheldfriendly] => false
[canvas_support] => none
[image_inlining] => false
[is_smarttv] => false
[is_console] => false
[nfc_support] => false
[ux_full_desktop] => true
[jqm_grade] => A
[is_sencha_touch_ok] => true
)
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr><tr><td>Zsxsoft<br /><small>1.3</small><br /></td><td>QQBrowser 6.11.12388.201</td><td><i class="material-icons">close</i></td><td>Windows XP</td><td style="border-left: 1px solid #555"></td><td></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td style="border-left: 1px solid #555"><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td><i class="material-icons">close</i></td><td>0.001</td><td>
<!-- Modal Trigger -->
<a class="modal-trigger btn waves-effect waves-light" href="#modal-5d43e024-b46c-44f6-8914-529b05569bc2">Detail</a>
<!-- Modal Structure -->
<div id="modal-5d43e024-b46c-44f6-8914-529b05569bc2" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>Zsxsoft result detail</h4>
<p><pre><code class="php">Array
(
[browser] => Array
(
[link] => http://browser.qq.com/
[title] => QQBrowser 6.11.12388.201
[code] => qqbrowser
[version] => 6.11.12388.201
[name] => QQBrowser
[image] => img/16/browser/qqbrowser.png
)
[os] => Array
(
[link] => http://www.microsoft.com/windows/
[name] => Windows
[version] => XP
[code] => win-2
[x64] =>
[title] => Windows XP
[type] => os
[dir] => os
[image] => img/16/os/win-2.png
)
[device] => Array
(
[link] =>
[title] =>
[model] =>
[brand] =>
[code] => null
[dir] => device
[type] => device
[image] => img/16/device/null.png
)
[platform] => Array
(
[link] => http://www.microsoft.com/windows/
[name] => Windows
[version] => XP
[code] => win-2
[x64] =>
[title] => Windows XP
[type] => os
[dir] => os
[image] => img/16/os/win-2.png
)
)
</code></pre></p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">close</a>
</div>
</div>
</td></tr></table>
</div>
<div class="section">
<h1 class="header center orange-text">About this comparison</h1>
<div class="row center">
<h5 class="header light">
The primary goal of this project is simple<br />
I wanted to know which user agent parser is the most accurate in each part - device detection, bot detection and so on...<br />
<br />
The secondary goal is to provide a source for all user agent parsers to improve their detection based on this results.<br />
<br />
You can also improve this further, by suggesting ideas at <a href="https://github.com/ThaDafinser/UserAgentParserComparison">ThaDafinser/UserAgentParserComparison</a><br />
<br />
The comparison is based on the abstraction by <a href="https://github.com/ThaDafinser/UserAgentParser">ThaDafinser/UserAgentParser</a>
</h5>
</div>
</div>
<div class="card">
<div class="card-content">
Comparison created <i>2016-05-10 08:08:18</i> | by
<a href="https://github.com/ThaDafinser">ThaDafinser</a>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/js/materialize.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/list.js/1.2.0/list.min.js"></script>
<script>
$(document).ready(function(){
// the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered
$('.modal-trigger').leanModal();
});
</script>
</body>
</html> | ThaDafinser/UserAgentParserComparison | v5/user-agent-detail/d2/07/d20797e9-3ee0-43ed-b0ab-b70b36aa74b5.html | HTML | mit | 55,810 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1013,
1028,
1026,
2516,
1028,
5310,
30524,
9333,
2121,
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 irc.bot;
import java.io.*;
public class OutHandler implements Runnable {
OutHandler(Connection connection) {
this.connection = connection;
}
private Connection connection;
public void run() {}
}
| propheh/IRCBot | irc/bot/OutHandler.java | Java | gpl-2.0 | 225 | [
30522,
7427,
20868,
2278,
1012,
28516,
1025,
12324,
9262,
1012,
22834,
1012,
1008,
1025,
2270,
2465,
2041,
11774,
3917,
22164,
2448,
22966,
1063,
2041,
11774,
3917,
1006,
4434,
4434,
1007,
1063,
2023,
1012,
4434,
1027,
4434,
1025,
1065,
279... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2014 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
// mapnik
#include <mapnik/feature.hpp>
#include <mapnik/agg_renderer.hpp>
#include <mapnik/agg_rasterizer.hpp>
#include <mapnik/text/symbolizer_helpers.hpp>
#include <mapnik/pixel_position.hpp>
#include <mapnik/text/renderer.hpp>
#include <mapnik/renderer_common/clipping_extent.hpp>
namespace mapnik {
template <typename T0, typename T1>
void agg_renderer<T0,T1>::process(shield_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
box2d<double> clip_box = clipping_extent(common_);
agg::trans_affine tr;
auto transform = get_optional<transform_type>(sym, keys::geometry_transform);
if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_);
text_symbolizer_helper helper(
sym, feature, common_.vars_, prj_trans,
common_.width_, common_.height_,
common_.scale_factor_,
common_.t_, common_.font_manager_, *common_.detector_,
clip_box, tr);
halo_rasterizer_enum halo_rasterizer = get<halo_rasterizer_enum>(sym, keys::halo_rasterizer, feature, common_.vars_, HALO_RASTERIZER_FULL);
composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over);
composite_mode_e halo_comp_op = get<composite_mode_e>(sym, keys::halo_comp_op, feature, common_.vars_, src_over);
agg_text_renderer<T0> ren(*current_buffer_,
halo_rasterizer,
comp_op,
halo_comp_op,
common_.scale_factor_,
common_.font_manager_.get_stroker());
double opacity = get<double>(sym,keys::opacity, feature, common_.vars_, 1.0);
placements_list const& placements = helper.get();
for (glyph_positions_ptr glyphs : placements)
{
marker_info_ptr mark = glyphs->get_marker();
if (mark)
{
render_marker(glyphs->marker_pos(),
*mark->marker_,
mark->transform_,
opacity, comp_op);
}
ren.render(*glyphs);
}
}
template void agg_renderer<image_rgba8>::process(shield_symbolizer const&,
mapnik::feature_impl &,
proj_transform const&);
}
| Airphrame/mapnik | src/agg/process_shield_symbolizer.cpp | C++ | lgpl-2.1 | 3,440 | [
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... |
// <copyright file="AcmlLinearAlgebraProvider.float.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2011 Math.NET
//
// 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.
// </copyright>
namespace MathNet.Numerics.Algorithms.LinearAlgebra.Acml
{
using System;
using System.Security;
using Properties;
/// <summary>
/// AMD Core Math Library (ACML) linear algebra provider.
/// </summary>
public partial class AcmlLinearAlgebraProvider
{
/// <summary>
/// Computes the dot product of x and y.
/// </summary>
/// <param name="x">The vector x.</param>
/// <param name="y">The vector y.</param>
/// <returns>The dot product of x and y.</returns>
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
[SecuritySafeCritical]
public override float DotProduct(float[] x, float[] y)
{
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
return SafeNativeMethods.s_dot_product(x.Length, x, y);
}
/// <summary>
/// Adds a scaled vector to another: <c>result = y + alpha*x</c>.
/// </summary>
/// <param name="y">The vector to update.</param>
/// <param name="alpha">The value to scale <paramref name="x"/> by.</param>
/// <param name="x">The vector to add to <paramref name="y"/>.</param>
/// <param name="result">The result of the addition.</param>
/// <remarks>This is similar to the AXPY BLAS routine.</remarks>
[SecuritySafeCritical]
public override void AddVectorToScaledVector(float[] y, float alpha, float[] x, float[] result)
{
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (y.Length != x.Length)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
if (!ReferenceEquals(y, result))
{
Array.Copy(y, 0, result, 0, y.Length);
}
if (alpha == 0.0f)
{
return;
}
SafeNativeMethods.s_axpy(y.Length, alpha, x, result);
}
/// <summary>
/// Scales an array. Can be used to scale a vector and a matrix.
/// </summary>
/// <param name="alpha">The scalar.</param>
/// <param name="x">The values to scale.</param>
/// <param name="result">This result of the scaling.</param>
/// <remarks>This is similar to the SCAL BLAS routine.</remarks>
[SecuritySafeCritical]
public override void ScaleArray(float alpha, float[] x, float[] result)
{
if (x == null)
{
throw new ArgumentNullException("x");
}
if (!ReferenceEquals(x, result))
{
Array.Copy(x, 0, result, 0, x.Length);
}
if (alpha == 1.0f)
{
return;
}
SafeNativeMethods.s_scale(x.Length, alpha, result);
}
/// <summary>
/// Multiples two matrices. <c>result = x * y</c>
/// </summary>
/// <param name="x">The x matrix.</param>
/// <param name="rowsX">The number of rows in the x matrix.</param>
/// <param name="columnsX">The number of columns in the x matrix.</param>
/// <param name="y">The y matrix.</param>
/// <param name="rowsY">The number of rows in the y matrix.</param>
/// <param name="columnsY">The number of columns in the y matrix.</param>
/// <param name="result">Where to store the result of the multiplication.</param>
/// <remarks>This is a simplified version of the BLAS GEMM routine with alpha
/// set to 1.0f and beta set to 0.0f, and x and y are not transposed.</remarks>
public override void MatrixMultiply(float[] x, int rowsX, int columnsX, float[] y, int rowsY, int columnsY, float[] result)
{
MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 1.0f, x, rowsX, columnsX, y, rowsY, columnsY, 0.0f, result);
}
/// <summary>
/// Multiplies two matrices and updates another with the result. <c>c = alpha*op(a)*op(b) + beta*c</c>
/// </summary>
/// <param name="transposeA">How to transpose the <paramref name="a"/> matrix.</param>
/// <param name="transposeB">How to transpose the <paramref name="b"/> matrix.</param>
/// <param name="alpha">The value to scale <paramref name="a"/> matrix.</param>
/// <param name="a">The a matrix.</param>
/// <param name="rowsA">The number of rows in the <paramref name="a"/> matrix.</param>
/// <param name="columnsA">The number of columns in the <paramref name="a"/> matrix.</param>
/// <param name="b">The b matrix</param>
/// <param name="rowsB">The number of rows in the <paramref name="b"/> matrix.</param>
/// <param name="columnsB">The number of columns in the <paramref name="b"/> matrix.</param>
/// <param name="beta">The value to scale the <paramref name="c"/> matrix.</param>
/// <param name="c">The c matrix.</param>
[SecuritySafeCritical]
public override void MatrixMultiplyWithUpdate(Transpose transposeA, Transpose transposeB, float alpha, float[] a, int rowsA, int columnsA, float[] b, int rowsB, int columnsB, float beta, float[] c)
{
if (a == null)
{
throw new ArgumentNullException("a");
}
if (b == null)
{
throw new ArgumentNullException("b");
}
if (c == null)
{
throw new ArgumentNullException("c");
}
var m = transposeA == Transpose.DontTranspose ? rowsA : columnsA;
var n = transposeB == Transpose.DontTranspose ? columnsB : rowsB;
var k = transposeA == Transpose.DontTranspose ? columnsA : rowsA;
var l = transposeB == Transpose.DontTranspose ? rowsB : columnsB;
if (c.Length != m * n)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
if (k != l)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
SafeNativeMethods.s_matrix_multiply(transposeA, transposeB, m, n, k, alpha, a, b, beta, c);
}
/// <summary>
/// Computes the LUP factorization of A. P*A = L*U.
/// </summary>
/// <param name="data">An <paramref name="order"/> by <paramref name="order"/> matrix. The matrix is overwritten with the
/// the LU factorization on exit. The lower triangular factor L is stored in under the diagonal of <paramref name="data"/> (the diagonal is always 1.0f
/// for the L factor). The upper triangular factor U is stored on and above the diagonal of <paramref name="data"/>.</param>
/// <param name="order">The order of the square matrix <paramref name="data"/>.</param>
/// <param name="ipiv">On exit, it contains the pivot indices. The size of the array must be <paramref name="order"/>.</param>
/// <remarks>This is equivalent to the GETRF LAPACK routine.</remarks>
[SecuritySafeCritical]
public override void LUFactor(float[] data, int order, int[] ipiv)
{
if (data == null)
{
throw new ArgumentNullException("data");
}
if (ipiv == null)
{
throw new ArgumentNullException("ipiv");
}
if (data.Length != order * order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "data");
}
if (ipiv.Length != order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
SafeNativeMethods.s_lu_factor(order, data, ipiv);
}
/// <summary>
/// Computes the inverse of matrix using LU factorization.
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <remarks>This is equivalent to the GETRF and GETRI LAPACK routines.</remarks>
[SecuritySafeCritical]
public override void LUInverse(float[] a, int order)
{
if (a == null)
{
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
var work = new float[order];
SafeNativeMethods.s_lu_inverse(order, a, work, work.Length);
}
/// <summary>
/// Computes the inverse of a previously factored matrix.
/// </summary>
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <param name="ipiv">The pivot indices of <paramref name="a"/>.</param>
/// <remarks>This is equivalent to the GETRI LAPACK routine.</remarks>
[SecuritySafeCritical]
public override void LUInverseFactored(float[] a, int order, int[] ipiv)
{
if (a == null)
{
throw new ArgumentNullException("a");
}
if (ipiv == null)
{
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (ipiv.Length != order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
var work = new float[order];
SafeNativeMethods.s_lu_inverse_factored(order, a, ipiv, work, order);
}
/// <summary>
/// Computes the inverse of matrix using LU factorization.
/// </summary>
/// <param name="a">The N by N matrix to invert. Contains the inverse On exit.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>This is equivalent to the GETRF and GETRI LAPACK routines.</remarks>
[SecuritySafeCritical]
public override void LUInverse(float[] a, int order, float[] work)
{
if (a == null)
{
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (work == null)
{
throw new ArgumentNullException("work");
}
if (work.Length < order)
{
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.s_lu_inverse(order, a, work, work.Length);
}
/// <summary>
/// Computes the inverse of a previously factored matrix.
/// </summary>
/// <param name="a">The LU factored N by N matrix. Contains the inverse On exit.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <param name="ipiv">The pivot indices of <paramref name="a"/>.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>This is equivalent to the GETRI LAPACK routine.</remarks>
[SecuritySafeCritical]
public override void LUInverseFactored(float[] a, int order, int[] ipiv, float[] work)
{
if (a == null)
{
throw new ArgumentNullException("a");
}
if (ipiv == null)
{
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (ipiv.Length != order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
if (work == null)
{
throw new ArgumentNullException("work");
}
if (work.Length < order)
{
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.s_lu_inverse_factored(order, a, ipiv, work, order);
}
/// <summary>
/// Solves A*X=B for X using LU factorization.
/// </summary>
/// <param name="columnsOfB">The number of columns of B.</param>
/// <param name="a">The square matrix A.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <remarks>This is equivalent to the GETRF and GETRS LAPACK routines.</remarks>
[SecuritySafeCritical]
public override void LUSolve(int columnsOfB, float[] a, int order, float[] b)
{
if (a == null)
{
throw new ArgumentNullException("a");
}
if (a.Length != order * order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != columnsOfB * order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (ReferenceEquals(a, b))
{
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.s_lu_solve(order, columnsOfB, a, b);
}
/// <summary>
/// Solves A*X=B for X using a previously factored A matrix.
/// </summary>
/// <param name="columnsOfB">The number of columns of B.</param>
/// <param name="a">The factored A matrix.</param>
/// <param name="order">The order of the square matrix <paramref name="a"/>.</param>
/// <param name="ipiv">The pivot indices of <paramref name="a"/>.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <remarks>This is equivalent to the GETRS LAPACK routine.</remarks>
[SecuritySafeCritical]
public override void LUSolveFactored(int columnsOfB, float[] a, int order, int[] ipiv, float[] b)
{
if (a == null)
{
throw new ArgumentNullException("a");
}
if (ipiv == null)
{
throw new ArgumentNullException("ipiv");
}
if (a.Length != order * order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (ipiv.Length != order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "ipiv");
}
if (b.Length != columnsOfB * order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (ReferenceEquals(a, b))
{
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.s_lu_solve_factored(order, columnsOfB, a, ipiv, b);
}
/// <summary>
/// Computes the Cholesky factorization of A.
/// </summary>
/// <param name="a">On entry, a square, positive definite matrix. On exit, the matrix is overwritten with the
/// the Cholesky factorization.</param>
/// <param name="order">The number of rows or columns in the matrix.</param>
/// <remarks>This is equivalent to the POTRF LAPACK routine.</remarks>
[SecuritySafeCritical]
public override void CholeskyFactor(float[] a, int order)
{
if (a == null)
{
throw new ArgumentNullException("a");
}
if (order < 1)
{
throw new ArgumentException(Resources.ArgumentMustBePositive, "order");
}
if (a.Length != order * order)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
var info = SafeNativeMethods.s_cholesky_factor(order, a);
if (info > 0)
{
throw new ArgumentException(Resources.ArgumentMatrixPositiveDefinite);
}
}
/// <summary>
/// Solves A*X=B for X using Cholesky factorization.
/// </summary>
/// <param name="a">The square, positive definite matrix A.</param>
/// <param name="orderA">The number of rows and columns in A.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <param name="columnsB">The number of columns in the B matrix.</param>
/// <remarks>This is equivalent to the POTRF add POTRS LAPACK routines.
/// </remarks>
[SecuritySafeCritical]
public override void CholeskySolve(float[] a, int orderA, float[] b, int columnsB)
{
if (a == null)
{
throw new ArgumentNullException("a");
}
if (b == null)
{
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (ReferenceEquals(a, b))
{
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.s_cholesky_solve(orderA, columnsB, a, b);
}
/// <summary>
/// Solves A*X=B for X using a previously factored A matrix.
/// </summary>
/// <param name="a">The square, positive definite matrix A.</param>
/// <param name="orderA">The number of rows and columns in A.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <param name="columnsB">The number of columns in the B matrix.</param>
/// <remarks>This is equivalent to the POTRS LAPACK routine.</remarks>
[SecuritySafeCritical]
public override void CholeskySolveFactored(float[] a, int orderA, float[] b, int columnsB)
{
if (a == null)
{
throw new ArgumentNullException("a");
}
if (b == null)
{
throw new ArgumentNullException("b");
}
if (b.Length != orderA * columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (ReferenceEquals(a, b))
{
throw new ArgumentException(Resources.ArgumentReferenceDifferent);
}
SafeNativeMethods.s_cholesky_solve_factored(orderA, columnsB, a, b);
}
/// <summary>
/// Computes the QR factorization of A.
/// </summary>
/// <param name="r">On entry, it is the M by N A matrix to factor. On exit,
/// it is overwritten with the R matrix of the QR factorization. </param>
/// <param name="rowsR">The number of rows in the A matrix.</param>
/// <param name="columnsR">The number of columns in the A matrix.</param>
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="tau">A min(m,n) vector. On exit, contains additional information
/// to be used by the QR solve routine.</param>
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
[SecuritySafeCritical]
public override void QRFactor(float[] r, int rowsR, int columnsR, float[] q, float[] tau)
{
if (r == null)
{
throw new ArgumentNullException("r");
}
if (q == null)
{
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
if (tau.Length < Math.Min(rowsR, columnsR))
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
var work = new float[columnsR * Control.BlockSize];
SafeNativeMethods.s_qr_factor(rowsR, columnsR, r, tau, q, work, work.Length);
}
/// <summary>
/// Computes the QR factorization of A.
/// </summary>
/// <param name="r">On entry, it is the M by N A matrix to factor. On exit,
/// it is overwritten with the R matrix of the QR factorization. </param>
/// <param name="rowsR">The number of rows in the A matrix.</param>
/// <param name="columnsR">The number of columns in the A matrix.</param>
/// <param name="q">On exit, A M by M matrix that holds the Q matrix of the
/// QR factorization.</param>
/// <param name="tau">A min(m,n) vector. On exit, contains additional information
/// to be used by the QR solve routine.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>This is similar to the GEQRF and ORGQR LAPACK routines.</remarks>
[SecuritySafeCritical]
public override void QRFactor(float[] r, int rowsR, int columnsR, float[] q, float[] tau, float[] work)
{
if (r == null)
{
throw new ArgumentNullException("r");
}
if (q == null)
{
throw new ArgumentNullException("q");
}
if (work == null)
{
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * columnsR"), "r");
}
if (tau.Length < Math.Min(rowsR, columnsR))
{
throw new ArgumentException(string.Format(Resources.ArrayTooSmall, "min(m,n)"), "tau");
}
if (q.Length != rowsR * rowsR)
{
throw new ArgumentException(string.Format(Resources.ArgumentArrayWrongLength, "rowsR * rowsR"), "q");
}
if (work.Length < columnsR * Control.BlockSize)
{
work[0] = columnsR * Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.s_qr_factor(rowsR, columnsR, r, tau, q, work, work.Length);
}
/// <summary>
/// Solves A*X=B for X using QR factorization of A.
/// </summary>
/// <param name="a">The A matrix.</param>
/// <param name="rows">The number of rows in the A matrix.</param>
/// <param name="columns">The number of columns in the A matrix.</param>
/// <param name="b">The B matrix.</param>
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(float[] a, int rows, int columns, float[] b, int columnsB, float[] x)
{
if (a == null)
{
throw new ArgumentNullException("a");
}
if (b == null)
{
throw new ArgumentNullException("b");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (a.Length != rows * columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
if (rows < columns)
{
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new float[columns * Control.BlockSize];
QRSolve(a, rows, columns, b, columnsB, x, work);
}
/// <summary>
/// Solves A*X=B for X using QR factorization of A.
/// </summary>
/// <param name="a">The A matrix.</param>
/// <param name="rows">The number of rows in the A matrix.</param>
/// <param name="columns">The number of columns in the A matrix.</param>
/// <param name="b">The B matrix.</param>
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolve(float[] a, int rows, int columns, float[] b, int columnsB, float[] x, float[] work)
{
if (a == null)
{
throw new ArgumentNullException("a");
}
if (b == null)
{
throw new ArgumentNullException("b");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (work == null)
{
throw new ArgumentNullException("work");
}
if (a.Length != rows * columns)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "a");
}
if (b.Length != rows * columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columns * columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
if (rows < columns)
{
throw new ArgumentException(Resources.RowsLessThanColumns);
}
if (work.Length < 1)
{
work[0] = rows * Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.s_qr_solve(rows, columns, columnsB, a, b, x, work, work.Length);
}
/// <summary>
/// Solves A*X=B for X using a previously QR factored matrix.
/// </summary>
/// <param name="q">The Q matrix obtained by calling <see cref="QRFactor(float[],int,int,float[],float[])"/>.</param>
/// <param name="r">The R matrix obtained by calling <see cref="QRFactor(float[],int,int,float[],float[])"/>. </param>
/// <param name="rowsR">The number of rows in the A matrix.</param>
/// <param name="columnsR">The number of columns in the A matrix.</param>
/// <param name="tau">Contains additional information on Q. Only used for the native solver
/// and can be <c>null</c> for the managed provider.</param>
/// <param name="b">The B matrix.</param>
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
[SecuritySafeCritical]
public override void QRSolveFactored(float[] q, float[] r, int rowsR, int columnsR, float[] tau, float[] b, int columnsB, float[] x)
{
if (r == null)
{
throw new ArgumentNullException("r");
}
if (q == null)
{
throw new ArgumentNullException("q");
}
if (b == null)
{
throw new ArgumentNullException("q");
}
if (x == null)
{
throw new ArgumentNullException("q");
}
if (r.Length != rowsR * columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
if (rowsR < columnsR)
{
throw new ArgumentException(Resources.RowsLessThanColumns);
}
var work = new float[columnsR * Control.BlockSize];
QRSolveFactored(q, r, rowsR, columnsR, tau, b, columnsB, x, work);
}
/// <summary>
/// Solves A*X=B for X using a previously QR factored matrix.
/// </summary>
/// <param name="q">The Q matrix obtained by QR factor. This is only used for the managed provider and can be
/// <c>null</c> for the native provider. The native provider uses the Q portion stored in the R matrix.</param>
/// <param name="r">The R matrix obtained by calling <see cref="QRFactor(float[],int,int,float[],float[])"/>. </param>
/// <param name="rowsR">The number of rows in the A matrix.</param>
/// <param name="columnsR">The number of columns in the A matrix.</param>
/// <param name="tau">Contains additional information on Q. Only used for the native solver
/// and can be <c>null</c> for the managed provider.</param>
/// <param name="b">On entry the B matrix; on exit the X matrix.</param>
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
/// <param name="work">The work array - only used in the native provider. The array must have a length of at least N,
/// but should be N*blocksize. The blocksize is machine dependent. On exit, work[0] contains the optimal
/// work size value.</param>
/// <remarks>Rows must be greater or equal to columns.</remarks>
public override void QRSolveFactored(float[] q, float[] r, int rowsR, int columnsR, float[] tau, float[] b, int columnsB, float[] x, float[] work)
{
if (r == null)
{
throw new ArgumentNullException("r");
}
if (q == null)
{
throw new ArgumentNullException("q");
}
if (b == null)
{
throw new ArgumentNullException("q");
}
if (x == null)
{
throw new ArgumentNullException("q");
}
if (work == null)
{
throw new ArgumentNullException("work");
}
if (r.Length != rowsR * columnsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "r");
}
if (q.Length != rowsR * rowsR)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "q");
}
if (b.Length != rowsR * columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsR * columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "x");
}
if (rowsR < columnsR)
{
throw new ArgumentException(Resources.RowsLessThanColumns);
}
if (work.Length < 1)
{
work[0] = rowsR * Control.BlockSize;
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.s_qr_solve_factored(rowsR, columnsR, columnsB, r, b, tau, x, work, work.Length);
}
/// <summary>
/// Computes the singular value decomposition of A.
/// </summary>
/// <param name="computeVectors">Compute the singular U and VT vectors or not.</param>
/// <param name="a">On entry, the M by N matrix to decompose. On exit, A may be overwritten.</param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="s">The singular values of A in ascending value.</param>
/// <param name="u">If <paramref name="computeVectors"/> is <c>true</c>, on exit U contains the left
/// singular vectors.</param>
/// <param name="vt">If <paramref name="computeVectors"/> is <c>true</c>, on exit VT contains the transposed
/// right singular vectors.</param>
/// <remarks>This is equivalent to the GESVD LAPACK routine.</remarks>
[SecuritySafeCritical]
public override void SingularValueDecomposition(bool computeVectors, float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt)
{
if (a == null)
{
throw new ArgumentNullException("a");
}
if (s == null)
{
throw new ArgumentNullException("s");
}
if (u == null)
{
throw new ArgumentNullException("u");
}
if (vt == null)
{
throw new ArgumentNullException("vt");
}
if (u.Length != rowsA * rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
if (s.Length != Math.Min(rowsA, columnsA))
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
var work = new float[Math.Max(((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5 * Math.Min(rowsA, columnsA))];
SingularValueDecomposition(computeVectors, a, rowsA, columnsA, s, u, vt, work);
}
/// <summary>
/// Solves A*X=B for X using the singular value decomposition of A.
/// </summary>
/// <param name="a">On entry, the M by N matrix to decompose.</param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="b">The B matrix.</param>
/// <param name="columnsB">The number of columns of B.</param>
/// <param name="x">On exit, the solution matrix.</param>
public override void SvdSolve(float[] a, int rowsA, int columnsA, float[] b, int columnsB, float[] x)
{
if (a == null)
{
throw new ArgumentNullException("a");
}
if (b == null)
{
throw new ArgumentNullException("b");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (b.Length != rowsA * columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
if (x.Length != columnsA * columnsB)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "b");
}
var work = new float[Math.Max(((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5 * Math.Min(rowsA, columnsA))];
var s = new float[Math.Min(rowsA, columnsA)];
var u = new float[rowsA * rowsA];
var vt = new float[columnsA * columnsA];
var clone = new float[a.Length];
a.Copy(clone);
SingularValueDecomposition(true, clone, rowsA, columnsA, s, u, vt, work);
SvdSolveFactored(rowsA, columnsA, s, u, vt, b, columnsB, x);
}
/// <summary>
/// Computes the singular value decomposition of A.
/// </summary>
/// <param name="computeVectors">Compute the singular U and VT vectors or not.</param>
/// <param name="a">On entry, the M by N matrix to decompose. On exit, A may be overwritten.</param>
/// <param name="rowsA">The number of rows in the A matrix.</param>
/// <param name="columnsA">The number of columns in the A matrix.</param>
/// <param name="s">The singular values of A in ascending value.</param>
/// <param name="u">If <paramref name="computeVectors"/> is <c>true</c>, on exit U contains the left
/// singular vectors.</param>
/// <param name="vt">If <paramref name="computeVectors"/> is <c>true</c>, on exit VT contains the transposed
/// right singular vectors.</param>
/// <param name="work">The work array. For real matrices, the work array should be at least
/// Max(3*Min(M, N) + Max(M, N), 5*Min(M,N)). For complex matrices, 2*Min(M, N) + Max(M, N).
/// On exit, work[0] contains the optimal work size value.</param>
/// <remarks>This is equivalent to the GESVD LAPACK routine.</remarks>
[SecuritySafeCritical]
public override void SingularValueDecomposition(bool computeVectors, float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] work)
{
if (a == null)
{
throw new ArgumentNullException("a");
}
if (s == null)
{
throw new ArgumentNullException("s");
}
if (u == null)
{
throw new ArgumentNullException("u");
}
if (vt == null)
{
throw new ArgumentNullException("vt");
}
if (work == null)
{
throw new ArgumentNullException("work");
}
if (u.Length != rowsA * rowsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "u");
}
if (vt.Length != columnsA * columnsA)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "vt");
}
if (s.Length != Math.Min(rowsA, columnsA))
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "s");
}
if (work.Length == 0)
{
throw new ArgumentException(Resources.ArgumentSingleDimensionArray, "work");
}
if (work.Length < Math.Max(((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA)), 5 * Math.Min(rowsA, columnsA)))
{
work[0] = Math.Max((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5 * Math.Min(rowsA, columnsA));
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
SafeNativeMethods.s_svd_factor(computeVectors, rowsA, columnsA, a, s, u, vt, work, work.Length);
}
}
}
| Amichai/PhysicsPad | mathnetnumerics_b382b1690235/src/Numerics/Algorithms/LinearAlgebra/Acml/AcmlLinearAlgebraProvider.float.cs | C# | lgpl-2.1 | 43,092 | [
30522,
1013,
1013,
1026,
9385,
5371,
1027,
1000,
9353,
19968,
4179,
5400,
28875,
10024,
21572,
17258,
2121,
1012,
14257,
1012,
20116,
1000,
2194,
1027,
1000,
8785,
1012,
5658,
1000,
1028,
1013,
1013,
8785,
1012,
5658,
16371,
25531,
2015,
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... |
<html><head>
<style type="text/css">
<!--
*
{
visibility: visible !important;
overflow: visible !important;
user-select:normal !important;
-moz-user-select:normal !important;
-webkit-user-select:normal !important;
user-focus:normal !important;
-moz-user-focus:normal !important;
-webkit-user-focus:normal !important;
filter:none !important;
}
BODY {
overflow: auto !important;
}
.x-nc-sel0 { text-decoration:none; display:block !important; visibility:visible !important; }
.x-nc-sel1 { text-decoration:none; background-color: #42ffa1 !important; color: black !important; display:block !important; visibility:visible !important; }
.x-nc-sel2 { text-decoration:none; background-color: #ffff42 !important; color: black !important; display:block !important; visibility:visible !important; }
.x-nc-sel3 { text-decoration:none; background-color: #ff42ff !important; color: black !important; display:block !important; visibility:visible !important; }
.x-nc-sel4 { text-decoration:none; background-color: #ffa142 !important; color: black !important; display:block !important; visibility:visible !important; }
.x-nc-sel5 { text-decoration:none; background-color: #00ffff !important; color: black !important; display:block !important; visibility:visible !important; }
BODY.x-nc-linearized *
{
float: none !important;
position: static !important;
overflow: visible !important;
}
BODY.x-nc-linearized DIV {
width:auto !important;
height:auto !important;
}
BODY.x-nc-linearized table, BODY.x-nc-linearized tbody, BODY.x-nc-linearized td, BODY.x-nc-linearized tfoot, BODY.x-nc-linearized th, BODY.x-nc-linearized thead, BODY.x-nc-linearized tr
{
display: block !important;
position: static !important;
}
-->
</style>
<title>
icStaines - More Britons in blood scandal
</title>
</head><body leftmargin="0" topmargin="0" alink="Black" bgcolor="White" link="Black" marginheight="0" marginwidth="0" text="Black" vlink="Black">
<table border="0" cellpadding="0" cellspacing="0" width="765">
<tbody>
<tr>
<td colspan="4">
<img src="http://images.icnetwork.co.uk/design/clear.gif" height="4" width="5">
</td>
</tr>
<tr>
<td valign="top" width="5">
<img src="http://images.icnetwork.co.uk/design/clear.gif" height="60" width="5">
</td>
<td align="left" height="60" valign="top" width="290">
<a href="javascript:void(0)" >
<img src="http://images.icnetwork.co.uk/design/regional/icstaineslogo.gif" border="0" height="60" width="290">
</a>
</td>
<td valign="top" width="2">
<img src="http://images.icnetwork.co.uk/design/clear.gif" height="60" width="2">
</td>
<td align="right" height="60" valign="top" width="468">
</td>
</tr>
</tbody>
</table>
<div class="topTabNav" style="width: 760px;">
<table class="R2tabtable" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="lhon">
</td>
<td class="R2tabon">
<a href="javascript:void(0)" >
icStaines
</a>
</td>
<td class="rhonlhoff">
</td>
<td class="R2tab">
<a href="javascript:void(0)" >
Herald and News
</a>
</td>
<td class="rhofflhoff">
</td>
<td class="R2tab">
<a href="javascript:void(0)" >
Homes
</a>
</td>
<td class="rhofflhoff">
</td>
<td class="R2tab">
<a href="javascript:void(0)" >
Motors
</a>
</td>
<td class="rhofflhoff">
</td>
<td class="R2tab">
<a href="javascript:void(0)" >
Jobs
</a>
</td>
<td class="rhofflhoff">
</td>
<td class="R2tab">
<a href="javascript:void(0)" >
Dating
</a>
</td>
<td class="rhofflhoff">
</td>
<td class="R2tab">
<a href="javascript:void(0)" >
Bingo
</a>
</td>
<td class="rhoff">
</td>
</tr>
</tbody>
</table>
</div>
<div class="R2Searchbar" id="toptable">
<form name="top_search" action="javascript:void(0)">
<table border="0" cellpadding="0" cellspacing="0" width="760">
<tbody>
<tr>
<td class="R2SearchbarDate">
</td>
<td class="R2SearchbarTitle" align="right">
<strong>
Search icStaines for:
</strong>
</td>
<td>
<input name="query" value="Your Search" size="48" maxlength="40" class="R2searchbarfield" type="text">
</td>
<td class="R2Searchbarbutton">
<input name="gobut" src="http://images.icnetwork.co.uk/design/clear.gif" align="middle" border="0" height="26" hspace="0" type="image" vspace="0" width="30">
<input class="x-nc-invisible">
<input class="x-nc-invisible">
<input class="x-nc-invisible">
</td>
</tr>
</tbody>
</table>
</form>
</div>
<table border="0" cellpadding="0" cellspacing="0" width="765">
<tbody>
<tr>
<td width="5">
<img src="http://images.icnetwork.co.uk/design/clear.gif" height="8" width="5">
</td>
<td class="R2topbrandingcolour" width="150">
<img src="http://images.icnetwork.co.uk/design/clear.gif" height="8" width="150">
</td>
<td valign="top" width="610">
<img src="http://images.icnetwork.co.uk/design/topcurve_icstaines.gif" height="8" width="610">
</td>
</tr>
</tbody>
</table>
<table valign="top" border="0" cellpadding="0" cellspacing="0" width="765">
<tbody>
<tr>
<td valign="top" width="5">
<img src="http://images.icnetwork.co.uk/design/clear.gif" height="8" width="5">
</td>
<td class="navtable" align="left" valign="top" width="149">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td bgcolor="#242f71" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="149">
<tbody>
<tr width="149" height="17">
<td bgcolor="#6699cc" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_top_home.gif" border="0" height="4" width="4">
<a class="navchannelover" id="v_href1" href="javascript:void(0)" >
Home page
</a>
</td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="149">
<tbody>
<tr width="149" height="17">
<td id="td11164260" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href11164260" class="navchannelover" href="javascript:void(0)" >
Herald and News
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td11168828" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href11168828" class="navchannelover" href="javascript:void(0)" >
Sport
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td1093" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href1093" class="navchannelover" href="javascript:void(0)" >
Business search
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td11176900" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href11176900" class="navchannelover" href="javascript:void(0)" >
Classified Directory
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td11173996" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href11173996" class="navchannelover" href="javascript:void(0)" >
Shopping Channel
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td11208556" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href11208556" class="navchannelover" href="javascript:void(0)" >
National sport
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td11154128" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href11154128" class="navchannelover" href="javascript:void(0)" >
Jobs
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td11154132" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href11154132" class="navchannelover" href="javascript:void(0)" >
Homes
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td11154140" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href11154140" class="navchannelover" href="javascript:void(0)" >
Motors
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td11063724" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href11063724" class="navchannelover" href="javascript:void(0)" >
Classifieds
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td1089" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href1089" class="navchannelover" href="javascript:void(0)" >
What's on
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td1085" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href1085" class="navchannelover" href="javascript:void(0)" >
TV and radio
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td1081" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href1081" class="navchannelover" href="javascript:void(0)" >
Weather
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td11087820" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href11087820" class="navchannelover" href="javascript:void(0)" >
Personal finance
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td11156796" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href11156796" class="navchannelover" href="javascript:void(0)" >
Dating
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td11131256" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href11131256" class="navchannelover" href="javascript:void(0)" >
Bingo
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td11192840" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href11192840" class="navchannelover" href="javascript:void(0)" >
Travel
</a>
</td>
</tr>
<tr width="149" height="17">
<td id="td11064560" bgcolor="#242f71" width="149">
<img src="http://images.icnetwork.co.uk/design/nav_channel.gif" border="0" height="5" width="3">
<a id="v_href11064560" class="navchannelover" href="javascript:void(0)" >
About us
</a>
</td>
</tr>
<tr width="149" height="17">
<td>
<br>
<br>
</td>
</tr>
</tbody>
</table>
</td>
<td bgcolor="#000000" width="1">
<img src="http://images.icnetwork.co.uk/design/clear.gif" height="1" width="1">
</td>
</tr>
<tr>
<td bgcolor="#000000">
<img src="http://images.icnetwork.co.uk/design/clear.gif" height="1" width="149">
</td>
</tr>
</tbody>
</table>
<center>
<div style="margin-top: 10px; margin-bottom: 10px;">
</div>
</center>
</td>
<td valign="top" width="12">
<img src="http://images.icnetwork.co.uk/design/clear.gif" height="1" width="10">
</td>
<td id="centralContainerCell" valign="top" width="400">
<p>
<br>
<br>
<font class="bigteaserpic">
<strong>
<span class="x-nc-sel1">More Britons in blood scandal</span>
</strong>
</font>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
</table>
<table class="headerTable" border="0" cellpadding="0" cellspacing="0" width="">
<tbody>
<tr>
<td>
<p class="headtypea">
<span class="x-nc-sel3">13:30, Jan 10 2008</span>
<br>
<br>
</p>
</td>
</tr>
<tr>
<td>
<p class="headtypea">
<b>
</b>
</p>
</td>
</tr>
<tr>
<td colspan="2">
<p class="headtypeb">
</p>
</td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="400">
<tbody>
<tr>
<td colspan="3">
</td>
</tr>
<tr>
<td colspan="3">
<p class="headtypea" align="">
<span class="x-nc-sel2">Six British civilians as well as 18 soldiers working in Afghanistan or Iraq may have been exposed to contaminated blood provided by the US military.</span>
</p>
<p class="headtypea" align="">
<span class="x-nc-sel2">The British soldiers, who were seriously wounded, are now undergoing tests after it emerged that the Americans did not follow their own procedures and test the donors after they gave the blood.</span>
</p>
<p class="headtypea" align="">
<span class="x-nc-sel2">The Health Protection Agency said the GPs of all six affected civilians had been informed. But it admitted that because of the holiday period, some of the GPs may not yet have informed their patients. Those affected are being offered testing and counselling.</span>
</p>
<p class="headtypea" align="">
<span class="x-nc-sel2">An HPA spokeswoman said: "The Health Protection Agency is aware that a small number of British individuals may have received a transfusion of unscreened blood as a result of life-threatening injuries received in Afghanistan or Iraq.</span>
</p>
<p class="headtypea" align="">
<span class="x-nc-sel2">"The agency has advised the Ministry of Defence on the level of risk to those who may have been potentially exposed to infections as appropriate and is assisting with contacting some of the affected people."</span>
</p>
<p>
</p>
<div class="x-nc-invisible">
</div>
<a name="story_continue">
</a>
<p class="headtypea" align="">
<span class="x-nc-sel2">Haemophiliacs who were infected with HIV and hepatitis C after receiving contaminated blood in the late 1970s and 1980s described the blunder as an "absolute disgrace".</span>
</p>
<p>
</p>
<p class="headtypea" align="">
<span class="x-nc-sel2">Robert Mackie said it was "outrageous" that servicemen and women who risked their lives for their country had been put in this position. He said: "Attitudes have not changed, it is as simple as that. Lessons have not been learnt. It's an absolute disgrace, to say the least."</span>
</p>
<p>
</p>
<p class="headtypea" align="">
<span class="x-nc-sel2">Defence Minister Derek Twigg said the 18 soldiers would "almost certainly" have died if they had not received an emergency blood transfusion at the front line. While the risk of infection is "low" the matter is being taken "extremely seriously", he said.</span>
</p>
<p>
</p>
<p class="headtypea" align="">
<span class="x-nc-sel2">The US Department of Defence said the American donors who provided the blood had now all tested negative for hepatitis and HIV. But the British soldiers are still facing an agonising wait to learn the results of their own tests for blood infections.</span>
</p>
<p>
</p>
<p class="headtypea" align="">
<span class="x-nc-sel2">Prime Minister Gordon Brown's spokesman said: "Of course this is a very serious matter and the Ministry of Defence are taking it very seriously."</span>
</p>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tbody>
<tr>
<td width="100%">
<p class="headtypeb" align="left">
<a href="javascript:void(0)" >
<img src="http://images.icnetwork.co.uk/design/top.gif" border="0" height="4" width="8">
</a>
<a href="javascript:void(0)" >
<b>
Top
</b>
</a>
<font color="black">
|
</font>
<a href="javascript:void(0)" >
<img src="http://images.icnetwork.co.uk/design/back.gif" border="0" height="8" width="4">
</a>
<a href="javascript:void(0)" >
<b>
Back
</b>
</a>
<font color="black">
|
</font>
<span class="columnistref">
<a href="javascript:void(0)" >
</a>
<a href="javascript:void(0)" >
E-mail to a friend
</a>
</span>
<font color="black">
|
</font>
<span align="left" class="headtypeb">
<a href="javascript:void(0)" >
<b>
Printable version
</b>
</a>
</span>
</p>
</td>
</tr>
<tr>
<td colspan="3">
<p class="headtypeb">
</p>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
</tbody>
</table>
<br>
<br>
<br>
<br>
</p>
<center>
</center>
<br>
<br>
<p>
<table border="0" width="400">
<tbody>
<tr align="center">
<td class="copyrightline">
<b>
Copyright and Trade Mark Notice
</b>
</td>
</tr>
<tr>
<td class="copyrightline">
© 2008 owned by or licensed to Trinity Mirror Southern Ltd.
<br>
<br>
icStaines? is a trade mark of Trinity Mirror Southern Ltd.
<br>
<br>
Please read our
<a href="javascript:void(0)" class="copyrightline" >
Terms and Conditions
</a>
and
<a href="javascript:void(0)" class="copyrightline" >
Privacy Statement
</a>
before using this site.
</td>
</tr>
</tbody>
</table>
<br>
<br>
<table style="border: 1px solid rgb(0, 0, 0);" border="0" cellpadding="0" cellspacing="0" width="400">
<tbody>
<tr>
<td style="border-bottom: 1px solid rgb(0, 0, 0); font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 11px; color: black; padding-left: 7px;" height="18">
<strong>
Advertisements
</strong>
</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="5" cellspacing="0" width="400">
<tbody>
<tr>
<td style="font-family: Arial,Helvetica,sans-serif; font-size: 9px; color: rgb(0, 0, 0);">
<div align="center">
<a href="javascript:void(0)" >
Jobs Southeast
</a>
,
<a href="javascript:void(0)" >
Homes in Staines
</a>
,
<a href="javascript:void(0)" >
Used Cars in Staines
</a>
,
<a href="javascript:void(0)" >
London Free Classified Ads
</a>
<br>
<br>
<a href="javascript:void(0)" >
Jobs in Staines
</a>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</p>
</td>
<td valign="top" width="20">
<img src="http://images.icnetwork.co.uk/design/clear.gif" height="1" width="1">
</td>
<td align="center" bgcolor="#ffffff" valign="top" width="180">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr valign="bottom">
<td>
<input id="but_j" src="http://images.icnetwork.co.uk/design/fish4/new_butjob2.gif" value="Jobs" type="image">
<input id="but_c" src="http://images.icnetwork.co.uk/design/fish4/new_butcar1.gif" value="Cars" type="image">
<input id="but_h" src="http://images.icnetwork.co.uk/design/fish4/new_buthome1.gif" value="Homes" type="image">
<input id="but_d" src="http://images.icnetwork.co.uk/design/fish4/new_butdating1.gif" value="Dating" style="display: inline;" type="image">
</td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<div id="jobs_id" style="display: inline;">
<input class="x-nc-invisible">
<input class="x-nc-invisible">
<input class="x-nc-invisible">
<input class="x-nc-invisible">
<table class="tab_hol" align="center" background="http://images.icnetwork.co.uk/design/fish4/new_bgjob.gif" border="0">
<form class="x-nc-invisible"></form>
<tbody>
<tr>
<td class="tab_info" colspan="2" height="15">
Find your new job:
</td>
</tr>
<tr>
<td class="tab_textbox">
<br>
<br>
<label>
Job title
</label>
<br>
<br>
<input class="tab_textbox" name="JOB_TITLE" style="width: 143px;" type="text">
<br>
<br>
e.g. secretary
<br>
<br>
</td>
</tr>
<tr>
<td class="tab_textbox">
<label>
Location
</label>
<br>
<br>
<input class="tab_textbox" name="LOCATION" style="width: 143px;" type="text">
<br>
<br>
e.g. Staines or TW18
<br>
<br>
<br>
<br>
</td>
</tr>
<tr>
<td align="center" valign="bottom">
<input src="http://images.icnetwork.co.uk/design/fish4/butsearch.gif" type="image">
</td>
</tr>
</tbody>
</table>
</div>
<div class="x-nc-invisible">
</div>
<div class="x-nc-invisible">
</div>
<div class="x-nc-invisible">
</div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<img src="http://images.icnetwork.co.uk/design/clear.gif" border="0" height="5" width="7">
</td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<img src="http://images.icnetwork.co.uk/design/clear.gif" border="0" height="5" width="7">
</td>
</tr>
</tbody>
</table>
<div style="margin-top: 10px; margin-bottom: 10px;">
</div>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<img src="http://images.icnetwork.co.uk/design/clear.gif" border="0" height="5" width="7">
</td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td valign="top">
<noscript class="x-nc-invisible">
</noscript>
<div id="JSRCMO17644854MREGIONALRHBOXDICSOUTHEAST">
</div>
</td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<img src="http://images.icnetwork.co.uk/design/clear.gif" border="0" height="5" width="7">
</td>
</tr>
</tbody>
</table>
<p>
</p>
</td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="765">
<tbody>
<tr>
<td height="1" width="5">
<img src="http://images.icnetwork.co.uk/design/clear.gif" height="1" width="5">
</td>
<td height="1" width="150">
</td>
<td height="1" width="432">
<img src="http://images.icnetwork.co.uk/design/clear.gif" height="1" width="432">
</td>
<td bgcolor="#ffffff" height="1" width="180">
</td>
</tr>
</tbody>
</table>
<div class="x-nc-invisible">
</div>
<div id="rightad" style="position: absolute; top: 120px; left: 780px; bottom: 0px; right: 0px;">
<p>
</p>
<div class="x-nc-invisible">
</div>
<p>
</p>
</div>
<script class="x-nc-invisible">
</script>
</body></html> | muggot/python-goose | tests/suite/l3s/annotated/9b10bc9e-0792-40d4-b904-d48653c377cc.html | HTML | apache-2.0 | 21,332 | [
30522,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
2806,
2828,
1027,
1000,
3793,
1013,
20116,
2015,
1000,
1028,
1026,
999,
1011,
1011,
1008,
1063,
16476,
1024,
5710,
999,
2590,
1025,
2058,
12314,
1024,
5710,
999,
2590,
1025,
5310,
1011,
72... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
#ifndef COUNT_VISITS_TO_SUBDOMAINS_HPP
#define COUNT_VISITS_TO_SUBDOMAINS_HPP
/*
https://leetcode.com/problems/subdomain-visit-count/
A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level,
we have "com", at the next level, we have "leetcode.com", and at the lowest level,
"discuss.leetcode.com". When we visit a domain like "discuss.leetcode.com", we will also visit
the parent domains "leetcode.com" and "com" implicitly.
Now, call a "count-paired domain" to be a count (representing the number of visits this domain
received), followed by a space, followed by the address. An example of a count-paired domain might
be "9001 discuss.leetcode.com".
We are given a list cpdomains of count-paired domains. We would like a list of count-paired domains,
(in the same format as the input, and in any order), that explicitly counts the number of visits
to each subdomain.
Example 1:
Input:
["9001 discuss.leetcode.com"]
Output:
["9001 discuss.leetcode.com", "9001 leetcode.com", "9001 com"]
Explanation:
We only have one website domain: "discuss.leetcode.com". As discussed above, the subdomain
"leetcode.com" and "com" will also be visited. So they will all be visited 9001 times.
Example 2:
Input:
["900 google.mail.com", "50 yahoo.com", "1 intel.mail.com", "5 wiki.org"]
Output:
["901 mail.com","50 yahoo.com","900 google.mail.com","5 wiki.org","5 org","1 intel.mail.com","951 com"]
Explanation:
We will visit "google.mail.com" 900 times, "yahoo.com" 50 times, "intel.mail.com" once and
"wiki.org" 5 times. For the subdomains, we will visit "mail.com" 900 + 1 = 901 times,
"com" 900 + 50 + 1 = 951 times, and "org" 5 times.
Notes:
The length of cpdomains will not exceed 100.
The length of each domain name will not exceed 100.
Each address will have either 1 or 2 "." characters.
The input count in any count-paired domain will not exceed 10000.
The answer output can be returned in any order.
*/
#include <string>
#include <string_view>
#include <vector>
#include <unordered_map>
#include <limits>
namespace Algo::DS::HashMap {
class CountVisitsToSubdomains {
static bool convert_to_num(const std::string_view& str, size_t& num) {
char** end = nullptr;
const auto result = std::strtoull(str.data(), end, 10);
if (result == std::numeric_limits<unsigned long long>::max()) {
return false;
}
num = result;
return true;
}
static std::tuple<bool, size_t, std::vector<std::string_view>> split_count_domains_string(
const std::string_view& str) {
const auto space_pos = str.find(' ');
if (space_pos == std::string::npos) { return {false, 0, {}}; }
size_t count = 0;
if (!convert_to_num(str.substr(0, space_pos), count) || count == 0) {
return {false, 0, {}};
}
std::vector<std::string_view> domains;
for (size_t i = space_pos + 1; i < str.size(); ++i) {
const auto pos = str.find('.', i);
const auto dot_pos = pos == std::string_view::npos ? str.size() : pos;
domains.push_back(str.substr(i));
i = dot_pos;
}
if (domains.empty()) { return {false, 0, {}}; }
return {true, count, domains};
}
public:
static std::vector<std::string> count(const std::vector<std::string>& count_domains) {
std::unordered_map<std::string_view, size_t> count_map;
for (const auto& str : count_domains) {
const auto [is_ok, count, domains] = split_count_domains_string(str);
if (!is_ok) { continue; }
for (const auto& domain : domains) {
count_map[domain] += count;
}
}
std::vector<std::string> result;
for (const auto& [str, count] : count_map) {
result.push_back(std::to_string(count) + ' ' + std::string(str));
}
return result;
}
};
}
#endif //COUNT_VISITS_TO_SUBDOMAINS_HPP
| iamantony/CppNotes | src/algorithms/data_structures/hashmap/count_visits_to_subdomains.hpp | C++ | mit | 4,149 | [
30522,
1001,
2065,
13629,
2546,
4175,
1035,
7879,
1035,
2000,
1035,
4942,
9527,
28247,
1035,
6522,
2361,
1001,
9375,
4175,
1035,
7879,
1035,
2000,
1035,
4942,
9527,
28247,
1035,
6522,
2361,
1013,
1008,
16770,
1024,
1013,
1013,
3389,
13535,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.util.stream;
import java.util.Comparator;
import java.util.Objects;
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.function.DoubleConsumer;
import java.util.function.IntConsumer;
import java.util.function.LongConsumer;
import jdk.internal.HotSpotIntrinsicCandidate;
/**
* Utility methods for operating on and creating streams.
*
* <p>Unless otherwise stated, streams are created as sequential streams. A
* sequential stream can be transformed into a parallel stream by calling the
* {@code parallel()} method on the created stream.
*
* @since 1.8
*/
final class Streams {
private Streams() {
throw new Error("no instances");
}
/**
* An object instance representing no value, that cannot be an actual
* data element of a stream. Used when processing streams that can contain
* {@code null} elements to distinguish between a {@code null} value and no
* value.
*/
static final Object NONE = new Object();
/**
* An {@code int} range spliterator.
*/
static final class RangeIntSpliterator implements Spliterator.OfInt {
// Can never be greater that upTo, this avoids overflow if upper bound
// is Integer.MAX_VALUE
// All elements are traversed if from == upTo & last == 0
private int from;
private final int upTo;
// 1 if the range is closed and the last element has not been traversed
// Otherwise, 0 if the range is open, or is a closed range and all
// elements have been traversed
private int last;
RangeIntSpliterator(int from, int upTo, boolean closed) {
this(from, upTo, closed ? 1 : 0);
}
private RangeIntSpliterator(int from, int upTo, int last) {
this.from = from;
this.upTo = upTo;
this.last = last;
}
@Override
public boolean tryAdvance(IntConsumer consumer) {
Objects.requireNonNull(consumer);
final int i = from;
if (i < upTo) {
from++;
consumer.accept(i);
return true;
}
else if (last > 0) {
last = 0;
consumer.accept(i);
return true;
}
return false;
}
@Override
@HotSpotIntrinsicCandidate
public void forEachRemaining(IntConsumer consumer) {
Objects.requireNonNull(consumer);
int i = from;
final int hUpTo = upTo;
int hLast = last;
from = upTo;
last = 0;
while (i < hUpTo) {
consumer.accept(i++);
}
if (hLast > 0) {
// Last element of closed range
consumer.accept(i);
}
}
@Override
public long estimateSize() {
// Ensure ranges of size > Integer.MAX_VALUE report the correct size
return ((long) upTo) - from + last;
}
@Override
public int characteristics() {
return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED |
Spliterator.IMMUTABLE | Spliterator.NONNULL |
Spliterator.DISTINCT | Spliterator.SORTED;
}
@Override
public Comparator<? super Integer> getComparator() {
return null;
}
@Override
public Spliterator.OfInt trySplit() {
long size = estimateSize();
return size <= 1
? null
// Left split always has a half-open range
: new RangeIntSpliterator(from, from = from + splitPoint(size), 0);
}
/**
* The spliterator size below which the spliterator will be split
* at the mid-point to produce balanced splits. Above this size the
* spliterator will be split at a ratio of
* 1:(RIGHT_BALANCED_SPLIT_RATIO - 1)
* to produce right-balanced splits.
*
* <p>Such splitting ensures that for very large ranges that the left
* side of the range will more likely be processed at a lower-depth
* than a balanced tree at the expense of a higher-depth for the right
* side of the range.
*
* <p>This is optimized for cases such as IntStream.range(0, Integer.MAX_VALUE)
* that is likely to be augmented with a limit operation that limits the
* number of elements to a count lower than this threshold.
*/
private static final int BALANCED_SPLIT_THRESHOLD = 1 << 24;
/**
* The split ratio of the left and right split when the spliterator
* size is above BALANCED_SPLIT_THRESHOLD.
*/
private static final int RIGHT_BALANCED_SPLIT_RATIO = 1 << 3;
private int splitPoint(long size) {
int d = (size < BALANCED_SPLIT_THRESHOLD) ? 2 : RIGHT_BALANCED_SPLIT_RATIO;
// Cast to int is safe since:
// 2 <= size < 2^32
// 2 <= d <= 8
return (int) (size / d);
}
}
/**
* A {@code long} range spliterator.
*
* This implementation cannot be used for ranges whose size is greater
* than Long.MAX_VALUE
*/
static final class RangeLongSpliterator implements Spliterator.OfLong {
// Can never be greater that upTo, this avoids overflow if upper bound
// is Long.MAX_VALUE
// All elements are traversed if from == upTo & last == 0
private long from;
private final long upTo;
// 1 if the range is closed and the last element has not been traversed
// Otherwise, 0 if the range is open, or is a closed range and all
// elements have been traversed
private int last;
RangeLongSpliterator(long from, long upTo, boolean closed) {
this(from, upTo, closed ? 1 : 0);
}
private RangeLongSpliterator(long from, long upTo, int last) {
assert upTo - from + last > 0;
this.from = from;
this.upTo = upTo;
this.last = last;
}
@Override
public boolean tryAdvance(LongConsumer consumer) {
Objects.requireNonNull(consumer);
final long i = from;
if (i < upTo) {
from++;
consumer.accept(i);
return true;
}
else if (last > 0) {
last = 0;
consumer.accept(i);
return true;
}
return false;
}
@Override
public void forEachRemaining(LongConsumer consumer) {
Objects.requireNonNull(consumer);
long i = from;
final long hUpTo = upTo;
int hLast = last;
from = upTo;
last = 0;
while (i < hUpTo) {
consumer.accept(i++);
}
if (hLast > 0) {
// Last element of closed range
consumer.accept(i);
}
}
@Override
public long estimateSize() {
return upTo - from + last;
}
@Override
public int characteristics() {
return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED |
Spliterator.IMMUTABLE | Spliterator.NONNULL |
Spliterator.DISTINCT | Spliterator.SORTED;
}
@Override
public Comparator<? super Long> getComparator() {
return null;
}
@Override
public Spliterator.OfLong trySplit() {
long size = estimateSize();
return size <= 1
? null
// Left split always has a half-open range
: new RangeLongSpliterator(from, from = from + splitPoint(size), 0);
}
/**
* The spliterator size below which the spliterator will be split
* at the mid-point to produce balanced splits. Above this size the
* spliterator will be split at a ratio of
* 1:(RIGHT_BALANCED_SPLIT_RATIO - 1)
* to produce right-balanced splits.
*
* <p>Such splitting ensures that for very large ranges that the left
* side of the range will more likely be processed at a lower-depth
* than a balanced tree at the expense of a higher-depth for the right
* side of the range.
*
* <p>This is optimized for cases such as LongStream.range(0, Long.MAX_VALUE)
* that is likely to be augmented with a limit operation that limits the
* number of elements to a count lower than this threshold.
*/
private static final long BALANCED_SPLIT_THRESHOLD = 1 << 24;
/**
* The split ratio of the left and right split when the spliterator
* size is above BALANCED_SPLIT_THRESHOLD.
*/
private static final long RIGHT_BALANCED_SPLIT_RATIO = 1 << 3;
private long splitPoint(long size) {
long d = (size < BALANCED_SPLIT_THRESHOLD) ? 2 : RIGHT_BALANCED_SPLIT_RATIO;
// 2 <= size <= Long.MAX_VALUE
return size / d;
}
}
private static abstract class AbstractStreamBuilderImpl<T, S extends Spliterator<T>> implements Spliterator<T> {
// >= 0 when building, < 0 when built
// -1 == no elements
// -2 == one element, held by first
// -3 == two or more elements, held by buffer
int count;
// Spliterator implementation for 0 or 1 element
// count == -1 for no elements
// count == -2 for one element held by first
@Override
public S trySplit() {
return null;
}
@Override
public long estimateSize() {
return -count - 1;
}
@Override
public int characteristics() {
return Spliterator.SIZED | Spliterator.SUBSIZED |
Spliterator.ORDERED | Spliterator.IMMUTABLE;
}
}
static final class StreamBuilderImpl<T>
extends AbstractStreamBuilderImpl<T, Spliterator<T>>
implements Stream.Builder<T> {
// The first element in the stream
// valid if count == 1
T first;
// The first and subsequent elements in the stream
// non-null if count == 2
SpinedBuffer<T> buffer;
/**
* Constructor for building a stream of 0 or more elements.
*/
StreamBuilderImpl() { }
/**
* Constructor for a singleton stream.
*
* @param t the single element
*/
StreamBuilderImpl(T t) {
first = t;
count = -2;
}
// StreamBuilder implementation
@Override
public void accept(T t) {
if (count == 0) {
first = t;
count++;
}
else if (count > 0) {
if (buffer == null) {
buffer = new SpinedBuffer<>();
buffer.accept(first);
count++;
}
buffer.accept(t);
}
else {
throw new IllegalStateException();
}
}
public Stream.Builder<T> add(T t) {
accept(t);
return this;
}
@Override
public Stream<T> build() {
int c = count;
if (c >= 0) {
// Switch count to negative value signalling the builder is built
count = -count - 1;
// Use this spliterator if 0 or 1 elements, otherwise use
// the spliterator of the spined buffer
return (c < 2) ? StreamSupport.stream(this, false) : StreamSupport.stream(buffer.spliterator(), false);
}
throw new IllegalStateException();
}
// Spliterator implementation for 0 or 1 element
// count == -1 for no elements
// count == -2 for one element held by first
@Override
public boolean tryAdvance(Consumer<? super T> action) {
Objects.requireNonNull(action);
if (count == -2) {
action.accept(first);
count = -1;
return true;
}
else {
return false;
}
}
@Override
public void forEachRemaining(Consumer<? super T> action) {
Objects.requireNonNull(action);
if (count == -2) {
action.accept(first);
count = -1;
}
}
}
static final class IntStreamBuilderImpl
extends AbstractStreamBuilderImpl<Integer, Spliterator.OfInt>
implements IntStream.Builder, Spliterator.OfInt {
// The first element in the stream
// valid if count == 1
int first;
// The first and subsequent elements in the stream
// non-null if count == 2
SpinedBuffer.OfInt buffer;
/**
* Constructor for building a stream of 0 or more elements.
*/
IntStreamBuilderImpl() { }
/**
* Constructor for a singleton stream.
*
* @param t the single element
*/
IntStreamBuilderImpl(int t) {
first = t;
count = -2;
}
// StreamBuilder implementation
@Override
public void accept(int t) {
if (count == 0) {
first = t;
count++;
}
else if (count > 0) {
if (buffer == null) {
buffer = new SpinedBuffer.OfInt();
buffer.accept(first);
count++;
}
buffer.accept(t);
}
else {
throw new IllegalStateException();
}
}
@Override
public IntStream build() {
int c = count;
if (c >= 0) {
// Switch count to negative value signalling the builder is built
count = -count - 1;
// Use this spliterator if 0 or 1 elements, otherwise use
// the spliterator of the spined buffer
return (c < 2) ? StreamSupport.intStream(this, false) : StreamSupport.intStream(buffer.spliterator(), false);
}
throw new IllegalStateException();
}
// Spliterator implementation for 0 or 1 element
// count == -1 for no elements
// count == -2 for one element held by first
@Override
public boolean tryAdvance(IntConsumer action) {
Objects.requireNonNull(action);
if (count == -2) {
action.accept(first);
count = -1;
return true;
}
else {
return false;
}
}
@Override
public void forEachRemaining(IntConsumer action) {
Objects.requireNonNull(action);
if (count == -2) {
action.accept(first);
count = -1;
}
}
}
static final class LongStreamBuilderImpl
extends AbstractStreamBuilderImpl<Long, Spliterator.OfLong>
implements LongStream.Builder, Spliterator.OfLong {
// The first element in the stream
// valid if count == 1
long first;
// The first and subsequent elements in the stream
// non-null if count == 2
SpinedBuffer.OfLong buffer;
/**
* Constructor for building a stream of 0 or more elements.
*/
LongStreamBuilderImpl() { }
/**
* Constructor for a singleton stream.
*
* @param t the single element
*/
LongStreamBuilderImpl(long t) {
first = t;
count = -2;
}
// StreamBuilder implementation
@Override
public void accept(long t) {
if (count == 0) {
first = t;
count++;
}
else if (count > 0) {
if (buffer == null) {
buffer = new SpinedBuffer.OfLong();
buffer.accept(first);
count++;
}
buffer.accept(t);
}
else {
throw new IllegalStateException();
}
}
@Override
public LongStream build() {
int c = count;
if (c >= 0) {
// Switch count to negative value signalling the builder is built
count = -count - 1;
// Use this spliterator if 0 or 1 elements, otherwise use
// the spliterator of the spined buffer
return (c < 2) ? StreamSupport.longStream(this, false) : StreamSupport.longStream(buffer.spliterator(), false);
}
throw new IllegalStateException();
}
// Spliterator implementation for 0 or 1 element
// count == -1 for no elements
// count == -2 for one element held by first
@Override
public boolean tryAdvance(LongConsumer action) {
Objects.requireNonNull(action);
if (count == -2) {
action.accept(first);
count = -1;
return true;
}
else {
return false;
}
}
@Override
public void forEachRemaining(LongConsumer action) {
Objects.requireNonNull(action);
if (count == -2) {
action.accept(first);
count = -1;
}
}
}
static final class DoubleStreamBuilderImpl
extends AbstractStreamBuilderImpl<Double, Spliterator.OfDouble>
implements DoubleStream.Builder, Spliterator.OfDouble {
// The first element in the stream
// valid if count == 1
double first;
// The first and subsequent elements in the stream
// non-null if count == 2
SpinedBuffer.OfDouble buffer;
/**
* Constructor for building a stream of 0 or more elements.
*/
DoubleStreamBuilderImpl() { }
/**
* Constructor for a singleton stream.
*
* @param t the single element
*/
DoubleStreamBuilderImpl(double t) {
first = t;
count = -2;
}
// StreamBuilder implementation
@Override
public void accept(double t) {
if (count == 0) {
first = t;
count++;
}
else if (count > 0) {
if (buffer == null) {
buffer = new SpinedBuffer.OfDouble();
buffer.accept(first);
count++;
}
buffer.accept(t);
}
else {
throw new IllegalStateException();
}
}
@Override
public DoubleStream build() {
int c = count;
if (c >= 0) {
// Switch count to negative value signalling the builder is built
count = -count - 1;
// Use this spliterator if 0 or 1 elements, otherwise use
// the spliterator of the spined buffer
return (c < 2) ? StreamSupport.doubleStream(this, false) : StreamSupport.doubleStream(buffer.spliterator(), false);
}
throw new IllegalStateException();
}
// Spliterator implementation for 0 or 1 element
// count == -1 for no elements
// count == -2 for one element held by first
@Override
public boolean tryAdvance(DoubleConsumer action) {
Objects.requireNonNull(action);
if (count == -2) {
action.accept(first);
count = -1;
return true;
}
else {
return false;
}
}
@Override
public void forEachRemaining(DoubleConsumer action) {
Objects.requireNonNull(action);
if (count == -2) {
action.accept(first);
count = -1;
}
}
}
abstract static class ConcatSpliterator<T, T_SPLITR extends Spliterator<T>>
implements Spliterator<T> {
protected final T_SPLITR aSpliterator;
protected final T_SPLITR bSpliterator;
// True when no split has occurred, otherwise false
boolean beforeSplit;
// Never read after splitting
final boolean unsized;
public ConcatSpliterator(T_SPLITR aSpliterator, T_SPLITR bSpliterator) {
this.aSpliterator = aSpliterator;
this.bSpliterator = bSpliterator;
beforeSplit = true;
// The spliterator is known to be unsized before splitting if the
// sum of the estimates overflows.
unsized = aSpliterator.estimateSize() + bSpliterator.estimateSize() < 0;
}
@Override
public T_SPLITR trySplit() {
@SuppressWarnings("unchecked")
T_SPLITR ret = beforeSplit ? aSpliterator : (T_SPLITR) bSpliterator.trySplit();
beforeSplit = false;
return ret;
}
@Override
public boolean tryAdvance(Consumer<? super T> consumer) {
boolean hasNext;
if (beforeSplit) {
hasNext = aSpliterator.tryAdvance(consumer);
if (!hasNext) {
beforeSplit = false;
hasNext = bSpliterator.tryAdvance(consumer);
}
}
else
hasNext = bSpliterator.tryAdvance(consumer);
return hasNext;
}
@Override
public void forEachRemaining(Consumer<? super T> consumer) {
if (beforeSplit)
aSpliterator.forEachRemaining(consumer);
bSpliterator.forEachRemaining(consumer);
}
@Override
public long estimateSize() {
if (beforeSplit) {
// If one or both estimates are Long.MAX_VALUE then the sum
// will either be Long.MAX_VALUE or overflow to a negative value
long size = aSpliterator.estimateSize() + bSpliterator.estimateSize();
return (size >= 0) ? size : Long.MAX_VALUE;
}
else {
return bSpliterator.estimateSize();
}
}
@Override
public int characteristics() {
if (beforeSplit) {
// Concatenation loses DISTINCT and SORTED characteristics
return aSpliterator.characteristics() & bSpliterator.characteristics()
& ~(Spliterator.DISTINCT | Spliterator.SORTED
| (unsized ? Spliterator.SIZED | Spliterator.SUBSIZED : 0));
}
else {
return bSpliterator.characteristics();
}
}
@Override
public Comparator<? super T> getComparator() {
if (beforeSplit)
throw new IllegalStateException();
return bSpliterator.getComparator();
}
static class OfRef<T> extends ConcatSpliterator<T, Spliterator<T>> {
OfRef(Spliterator<T> aSpliterator, Spliterator<T> bSpliterator) {
super(aSpliterator, bSpliterator);
}
}
private static abstract class OfPrimitive<T, T_CONS, T_SPLITR extends Spliterator.OfPrimitive<T, T_CONS, T_SPLITR>>
extends ConcatSpliterator<T, T_SPLITR>
implements Spliterator.OfPrimitive<T, T_CONS, T_SPLITR> {
private OfPrimitive(T_SPLITR aSpliterator, T_SPLITR bSpliterator) {
super(aSpliterator, bSpliterator);
}
@Override
public boolean tryAdvance(T_CONS action) {
boolean hasNext;
if (beforeSplit) {
hasNext = aSpliterator.tryAdvance(action);
if (!hasNext) {
beforeSplit = false;
hasNext = bSpliterator.tryAdvance(action);
}
}
else
hasNext = bSpliterator.tryAdvance(action);
return hasNext;
}
@Override
public void forEachRemaining(T_CONS action) {
if (beforeSplit)
aSpliterator.forEachRemaining(action);
bSpliterator.forEachRemaining(action);
}
}
static class OfInt
extends ConcatSpliterator.OfPrimitive<Integer, IntConsumer, Spliterator.OfInt>
implements Spliterator.OfInt {
OfInt(Spliterator.OfInt aSpliterator, Spliterator.OfInt bSpliterator) {
super(aSpliterator, bSpliterator);
}
}
static class OfLong
extends ConcatSpliterator.OfPrimitive<Long, LongConsumer, Spliterator.OfLong>
implements Spliterator.OfLong {
OfLong(Spliterator.OfLong aSpliterator, Spliterator.OfLong bSpliterator) {
super(aSpliterator, bSpliterator);
}
}
static class OfDouble
extends ConcatSpliterator.OfPrimitive<Double, DoubleConsumer, Spliterator.OfDouble>
implements Spliterator.OfDouble {
OfDouble(Spliterator.OfDouble aSpliterator, Spliterator.OfDouble bSpliterator) {
super(aSpliterator, bSpliterator);
}
}
}
/**
* Given two Runnables, return a Runnable that executes both in sequence,
* even if the first throws an exception, and if both throw exceptions, add
* any exceptions thrown by the second as suppressed exceptions of the first.
*/
static Runnable composeWithExceptions(Runnable a, Runnable b) {
return new Runnable() {
@Override
public void run() {
try {
a.run();
}
catch (Throwable e1) {
try {
b.run();
}
catch (Throwable e2) {
try {
e1.addSuppressed(e2);
} catch (Throwable ignore) {}
}
throw e1;
}
b.run();
}
};
}
/**
* Given two streams, return a Runnable that
* executes both of their {@link BaseStream#close} methods in sequence,
* even if the first throws an exception, and if both throw exceptions, add
* any exceptions thrown by the second as suppressed exceptions of the first.
*/
static Runnable composedClose(BaseStream<?, ?> a, BaseStream<?, ?> b) {
return new Runnable() {
@Override
public void run() {
try {
a.close();
}
catch (Throwable e1) {
try {
b.close();
}
catch (Throwable e2) {
try {
e1.addSuppressed(e2);
} catch (Throwable ignore) {}
}
throw e1;
}
b.close();
}
};
}
}
| 34benma/openjdk | jdk/src/java.base/share/classes/java/util/stream/Streams.java | Java | gpl-2.0 | 29,202 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2262,
1010,
2286,
1010,
14721,
1998,
1013,
2030,
2049,
18460,
1012,
2035,
2916,
9235,
1012,
1008,
2079,
2025,
11477,
2030,
6366,
9385,
14444,
2030,
2023,
5371,
20346,
1012,
1008,
1008,
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... |
#ifndef VALUE_H_
#define VALUE_H_
// Cost parameters
#define CARCOST 100
#define TICKETCOST 300
#define CENTSPERLITRE 130
#define METERSPERLITRE 15000
// Headers
#include <limits.h>
#include <immintrin.h>
#include "instance.h"
#include "random.h"
#include "macros.h"
#include "types.h"
#define COST(I, DR, L) ((DR)[(I)] ? (PATHCOST((L)[I]) + CARCOST) : TICKETCOST)
#define PATHCOST(p) ROUND(value, (float)(p) / METERSPERLITRE * CENTSPERLITRE)
#define EURO(i) ((float)(i) / 100)
#define R5 2520
#define R4 90
#define R3 6
meter minpath(agent *c, agent n, agent dr, const meter *sp);
#endif /* VALUE_H_ */
| filippobistaffa/SR-CFSS | value.h | C | gpl-3.0 | 613 | [
30522,
1001,
2065,
13629,
2546,
3643,
1035,
1044,
1035,
1001,
9375,
3643,
1035,
1044,
1035,
1013,
1013,
3465,
11709,
1001,
9375,
2482,
13186,
2102,
2531,
1001,
9375,
7281,
13186,
2102,
3998,
1001,
9375,
16653,
4842,
15909,
2890,
7558,
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... |
jsonp({"cep":"07955020","logradouro":"Rua Cinquenta e Cinco","bairro":"Jardim Vassouras","cidade":"Francisco Morato","uf":"SP","estado":"S\u00e3o Paulo"});
| lfreneda/cepdb | api/v1/07955020.jsonp.js | JavaScript | cc0-1.0 | 156 | [
30522,
1046,
3385,
2361,
1006,
1063,
1000,
8292,
2361,
1000,
1024,
1000,
5718,
2683,
24087,
2692,
11387,
1000,
1010,
1000,
8833,
12173,
8162,
2080,
1000,
1024,
1000,
21766,
2050,
25022,
2078,
15417,
2050,
1041,
25022,
15305,
1000,
1010,
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... |
# -*- coding: utf-8 -*-
import io
import os
from dlstats.fetchers.bea import BEA as Fetcher
import httpretty
from dlstats.tests.base import RESOURCES_DIR as BASE_RESOURCES_DIR
from dlstats.tests.fetchers.base import BaseFetcherTestCase
import unittest
from unittest import mock
RESOURCES_DIR = os.path.abspath(os.path.join(BASE_RESOURCES_DIR, "bea"))
DATA_BEA_10101_An = {
"filepath": os.path.abspath(os.path.join(RESOURCES_DIR, "nipa-section1.xls.zip")),
"DSD": {
"provider": "BEA",
"filepath": None,
"dataset_code": "nipa-section1-10101-a",
"dsd_id": "nipa-section1-10101-a",
"is_completed": True,
"categories_key": "nipa-section1",
"categories_parents": ["national", "nipa"],
"categories_root": ["national", "nipa", "nipa-fa2004", "nipa-underlying"],
"concept_keys": ['concept', 'frequency'],
"codelist_keys": ['concept', 'frequency'],
"codelist_count": {
"concept": 25,
"frequency": 1
},
"dimension_keys": ['concept', 'frequency'],
"dimension_count": {
"concept": 25,
"frequency": 1
},
"attribute_keys": [],
"attribute_count": None,
},
"series_accept": 25,
"series_reject_frequency": 0,
"series_reject_empty": 0,
"series_all_values": 1175,
"series_key_first": "A191RL1-A",
"series_key_last": "A191RP1-A",
"series_sample": {
'provider_name': 'BEA',
'dataset_code': 'nipa-section1-10101-a',
'key': 'A191RL1-A',
'name': 'Gross domestic product - Annually',
'frequency': 'A',
'last_update': None,
'first_value': {
'value': '3.1',
'period': '1969',
'attributes': None,
},
'last_value': {
'value': '2.4',
'period': '2015',
'attributes': None,
},
'dimensions': {
'concept': 'a191rl1',
"frequency": 'a'
},
'attributes': None,
}
}
def _get_datasets_settings(self):
return {
"nipa-section1-10101-a": {
'dataset_code': 'nipa-section1-10101-a',
'name': 'Table 1.1.1. Percent Change From Preceding Period in Real Gross Domestic Product - Annually',
'last_update': None,
'metadata': {
'filename': 'nipa-section1.xls.zip',
'sheet_name': '10101 Ann',
'url': 'http://www.bea.gov/national/nipaweb/GetCSV.asp?GetWhat=SS_Data/Section1All_xls.zip&Section=2'
},
}
}
class FetcherTestCase(BaseFetcherTestCase):
# nosetests -s -v dlstats.tests.fetchers.test_bea:FetcherTestCase
FETCHER_KLASS = Fetcher
DATASETS = {
'nipa-section1-10101-a': DATA_BEA_10101_An
}
DATASET_FIRST = "nipa-fa2004-section1-101-a"
DATASET_LAST = "nipa-underlying-section9-90500U-a"
DEBUG_MODE = False
def _load_files(self, dataset_code):
url = "http://www.bea.gov/national/nipaweb/GetCSV.asp?GetWhat=SS_Data/Section1All_xls.zip&Section=2"
self.register_url(url,
self.DATASETS[dataset_code]["filepath"])
@httpretty.activate
@unittest.skipUnless('FULL_TEST' in os.environ, "Skip - no full test")
def test_load_datasets_first(self):
dataset_code = "nipa-section1-10101-a"
self._load_files(dataset_code)
self.assertLoadDatasetsFirst([dataset_code])
@httpretty.activate
@unittest.skipUnless('FULL_TEST' in os.environ, "Skip - no full test")
def test_load_datasets_update(self):
dataset_code = "nipa-section1-10101-a"
self._load_files(dataset_code)
self.assertLoadDatasetsUpdate([dataset_code])
#@httpretty.activate
@unittest.skipIf(True, "TODO")
def test_build_data_tree(self):
dataset_code = "nipa-section1-10101-a"
self.assertDataTree(dataset_code)
@httpretty.activate
@mock.patch("dlstats.fetchers.bea.BEA._get_datasets_settings", _get_datasets_settings)
def test_upsert_dataset_10101(self):
# nosetests -s -v dlstats.tests.fetchers.test_bea:FetcherTestCase.test_upsert_dataset_10101
dataset_code = "nipa-section1-10101-a"
self._load_files(dataset_code)
self.assertProvider()
dataset = self.assertDataset(dataset_code)
names = {
'a191rl1': 'Gross domestic product',
'dpcerl1': 'Personal consumption expenditures',
'dgdsrl1': 'Personal consumption expenditures - Goods',
'ddurrl1': 'Personal consumption expenditures - Goods - Durable goods',
'dndgrl1': 'Personal consumption expenditures - Goods - Nondurable goods',
'dserrl1': 'Personal consumption expenditures - Services',
'a006rl1': 'Gross private domestic investment',
'a007rl1': 'Gross private domestic investment - Fixed investment',
'a008rl1': 'Gross private domestic investment - Fixed investment - Nonresidential',
'y033rl1': 'Gross private domestic investment - Fixed investment - Nonresidential - Equipment',
'a011rl1': 'Gross private domestic investment - Fixed investment - Residential',
'a020rl1': 'Net exports of goods and services - Exports',
'a191rp1': 'Addendum: - Gross domestic product, current dollars'
}
for k, v in names.items():
self.assertTrue(k in dataset["codelists"]["concept"])
self.assertEquals(dataset["codelists"]["concept"][k], v)
series_list = self.assertSeries(dataset_code)
series_keys = {s["key"].lower(): s for s in series_list}
for k, v in names.items():
search_k = "%s-a" % k
search_name = "%s - Annually" % v
self.assertTrue(search_k in series_keys, "%s not in series_keys" % search_k)
self.assertEquals(series_keys[search_k]["name"], search_name)
for series in series_list:
self.assertEquals(series["last_update_ds"], dataset["last_update"])
| Widukind/dlstats | dlstats/tests/fetchers/test_bea.py | Python | agpl-3.0 | 6,159 | [
30522,
1001,
1011,
1008,
1011,
16861,
1024,
21183,
2546,
1011,
1022,
1011,
1008,
1011,
12324,
22834,
12324,
9808,
2013,
21469,
9153,
3215,
1012,
18584,
2545,
1012,
26892,
12324,
26892,
2004,
18584,
2121,
12324,
8299,
13465,
3723,
2013,
21469,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
var searchData=
[
['ebert_5fgraph_2eh_0',['ebert_graph.h',['../ebert__graph_8h.html',1,'']]],
['element_2ecc_1',['element.cc',['../element_8cc.html',1,'']]],
['encoding_2ecc_2',['encoding.cc',['../encoding_8cc.html',1,'']]],
['encoding_2eh_3',['encoding.h',['../encoding_8h.html',1,'']]],
['encodingutils_2eh_4',['encodingutils.h',['../encodingutils_8h.html',1,'']]],
['entering_5fvariable_2ecc_5',['entering_variable.cc',['../entering__variable_8cc.html',1,'']]],
['entering_5fvariable_2eh_6',['entering_variable.h',['../entering__variable_8h.html',1,'']]],
['environment_2ecc_7',['environment.cc',['../environment_8cc.html',1,'']]],
['environment_2eh_8',['environment.h',['../environment_8h.html',1,'']]],
['eulerian_5fpath_2eh_9',['eulerian_path.h',['../eulerian__path_8h.html',1,'']]],
['expr_5farray_2ecc_10',['expr_array.cc',['../expr__array_8cc.html',1,'']]],
['expr_5fcst_2ecc_11',['expr_cst.cc',['../expr__cst_8cc.html',1,'']]],
['expressions_2ecc_12',['expressions.cc',['../expressions_8cc.html',1,'']]]
];
| google/or-tools | docs/cpp/search/files_4.js | JavaScript | apache-2.0 | 1,043 | [
30522,
13075,
3945,
2850,
2696,
1027,
1031,
1031,
1005,
22660,
1035,
1019,
2546,
14413,
1035,
1016,
11106,
1035,
1014,
1005,
1010,
1031,
1005,
22660,
1035,
10629,
1012,
1044,
1005,
1010,
1031,
1005,
1012,
1012,
1013,
22660,
1035,
1035,
1062... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = DjangoCorrelationId
SOURCEDIR = .
BUILDDIR = ../build/sphinx
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
| snowball-one/cid | docs/Makefile | Makefile | bsd-3-clause | 626 | [
30522,
1001,
10124,
2191,
8873,
2571,
2005,
27311,
12653,
1001,
1001,
2017,
2064,
2275,
2122,
10857,
2013,
1996,
3094,
2240,
1012,
27311,
7361,
3215,
1027,
27311,
8569,
4014,
2094,
1027,
27311,
1011,
3857,
27311,
21572,
3501,
1027,
6520,
23... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
---
st:
published_at: 2016-06-16
type: "User_Guide"
seo:
title: Two-Factor Authentication
description: Two-Factor Authentication gives you an extra layer of security to protect your SendGrid account.
keywords: 2FA, two-factor authentication, authentication, security, authy
title: Two-Factor Authentication
weight: 0
layout: page
navigation:
show: true
---
<iframe src="https://player.vimeo.com/video/248169751" width="700" height="400" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
Two-factor authentication, commonly referred to as multi-factor authentication, allows you to make your SendGrid account more secure by requiring authentication beyond a simple username and password when logging in.
SendGrid’s Two-Factor Authentication can be configured to accept a code sent to your mobile phone either via the [Authy App](https://www.authy.com/app/mobile/), or an SMS message.
* [Setting Up Two-Factor Authentication](#-Setting-Up-Two-Factor-Authentication)
* [Using Two-Factor Authentication](#-Using-Two-Factor-Authentication)
* [Disabling Two-Factor Authentication](#-Disabling-Two-Factor-Authentication)
* [Regaining access to my account when I've been locked out by Two-Factor Authentication](#-Regaining-access-to-my-account-when-I--ve-been-locked-out-by-Two-Factor-Authentication)
{% anchor h2 %}
Setting Up Two-Factor Authentication
{% endanchor h2 %}
You may choose from two different verification methods when using two-factor authentication:
1. Generate a verification code with the [Authy App](https://www.authy.com/app/mobile/).
The Authy App allows you to authenticate over WiFi if you do not have cellular service. However, you may still resort to an SMS message as a backup if you decide to use Authy.
1. Enter a code sent to your mobile phone that is generated by SendGrid.
{% warning %}
When authenticating via SMS message, you must have cellular service, or you will not be able to log into your account.
{% endwarning %}
{% info %}
You can create multiple configurations of Two-Factor Authentication, allowing you to use more than one mobile device to authenticate when logging into your account.
{% endinfo %}
*To set up Two-Factor Authentication:*
1. Navigate to **Settings**, and click **Two-Factor Authentication**.
<br>From this page, you see an overview of your Two-Factor Authentication settings, along with any settings that you have created for credentialed users.
1. Click **Add Two-Factor Authentication**.
1. Select either the Authy App or text messages (SMS) as your means of authentication.
1. Enter your **country code** and **phone number**.
{% info %}
Subusers and Teammates need to create their own Two-Factor Authentication settings in their account using the same steps.
{% endinfo %}
{% anchor h2 %}
Using Two-Factor Authentication
{% endanchor h2 %}
After you create a setting for Two-Factor Authentication, log in as you normally would. If you opt to receive a text message with your authentication token, look for the text message and enter the code that you receive. If you have selected the Authy App, go to your app, and enter the generated code.
Once set up, you will always be required to use Two-Factor Authentication to perform security-restricted actions in your SendGrid account, such as logging in or changing your Two-Factor Authentication settings. When prompted, enter the 7-digit token sent to your device, or generated by the Authy App.
{% anchor h2 %}
Disabling Two-Factor Authentication
{% endanchor h2 %}
*To disable or delete a Two-Factor Authentication setting:*
1. Navigate to **Settings**, and click **Two-Factor Authentication**.
1. Find the setting you would like to delete.
1. Click the **action menu**, and then select **Delete**.
1. Enter the 7 digit code you receive via text or Authy app into the field and then click **Delete**.
{% anchor h2 %}
Regaining access to my account after being locked out by Two-Factor Authentication
{% endanchor h2 %}
If you find that you’ve lost access to your account as a result of Two-Factor Authentication, please reach out to the [Authy Support Team](https://support.authy.com/hc/en-us).
{% anchor h2 %}
Additional Resources
{% endanchor h2 %}
* [Restoring Authy access on lost or inaccessible phones](https://support.authy.com/hc/en-us/articles/115012672088-Restoring-Authy-access-on-lost-or-inaccessible-phones)
| katieporter/docs | source/User_Guide/Settings/two_factor_authentication.md | Markdown | mit | 4,402 | [
30522,
1011,
1011,
1011,
2358,
1024,
2405,
1035,
2012,
1024,
2355,
1011,
5757,
1011,
2385,
2828,
1024,
1000,
5310,
1035,
5009,
1000,
27457,
1024,
2516,
1024,
2048,
1011,
5387,
27280,
6412,
1024,
2048,
1011,
5387,
27280,
3957,
2017,
2019,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.jaudiotagger.audio.mp4;
import org.jaudiotagger.audio.generic.GenericAudioHeader;
import org.jaudiotagger.audio.mp4.atom.Mp4EsdsBox;
/**
* Store some additional attributes not available for all audio types
*/
public class Mp4AudioHeader extends GenericAudioHeader {
/**
* The key for the kind field<br>
*
* @see #content
*/
public final static String FIELD_KIND = "KIND";
/**
* The key for the profile<br>
*
* @see #content
*/
public final static String FIELD_PROFILE = "PROFILE";
/**
* The key for the ftyp brand<br>
*
* @see #content
*/
public final static String FIELD_BRAND = "BRAND";
public void setKind(Mp4EsdsBox.Kind kind) {
content.put(FIELD_KIND, kind);
}
/**
* @return kind
*/
public Mp4EsdsBox.Kind getKind() {
return (Mp4EsdsBox.Kind) content.get(FIELD_KIND);
}
/**
* The key for the profile
*
* @param profile
*/
public void setProfile(Mp4EsdsBox.AudioProfile profile) {
content.put(FIELD_PROFILE, profile);
}
/**
* @return audio profile
*/
public Mp4EsdsBox.AudioProfile getProfile() {
return (Mp4EsdsBox.AudioProfile) content.get(FIELD_PROFILE);
}
/**
* @param brand
*/
public void setBrand(String brand) {
content.put(FIELD_BRAND, brand);
}
/**
* @return brand
*/
public String getBrand() {
return (String) content.get(FIELD_BRAND);
}
}
| dubenju/javay | src/java/org/jaudiotagger/audio/mp4/Mp4AudioHeader.java | Java | apache-2.0 | 1,542 | [
30522,
7427,
8917,
1012,
14855,
21041,
17287,
13327,
1012,
5746,
1012,
6131,
2549,
1025,
12324,
8917,
1012,
14855,
21041,
17287,
13327,
1012,
5746,
1012,
12391,
1012,
12391,
19513,
3695,
4974,
2121,
1025,
12324,
8917,
1012,
14855,
21041,
1728... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
---
title: JVM学习之 线程同步背后的原理
tags:
- JVM
header-img: "img/post-bg-unix-linux.jpg"
preview-img: "/img/post-bg-unix-linux.jpg"
grammar_cjkRuby: true
catalog: true
layout: post
---
本文来自[How the Java virtual machine performs thread synchronization](http://www.javaworld.com/article/2076971/java-concurrency/how-the-java-virtual-machine-performs-thread-synchronization.html)
## 前言
所有的 Java 程序都会被翻译为包含字节码的 class 文件,字节码是 JVM 的机器语言。这篇文章将阐述 JVM 是如何处理线程同步以及相关的字节码。
## 线程和共享数据
Java 的一个优点就是在语言层面支持多线程,这种支持集中在协调多线程对数据的访问上。
JVM 将运行时数据划分为几个区域:一个或多个栈,一个堆,一个方法区。
在 JVM 中,每个线程拥有一个栈,其他线程无法访问,里面的数据包括:局部变量,函数参数,线程调用的
方法的返回值。栈里面的数据只包含原生数据类型和对象引用。在 JVM 中,不可能将实际对象的拷贝放入栈。
所有对象都在堆里面。
JVM 只有一个堆,所有线程都共享它。堆中只包含对象,把单独的原生类型或者对象引用放入堆也是不可能的,
除非它们是对象的一部分。数组也在堆中,包括原生类型的数组,因为在 Java 中,数组也是对象。
除了栈和堆,另一个存放数据的区域就是方法区了,它包含程序中使用到的所有类(静态)变量。方法区类似于栈,也只包含原生类型和对象引用,但是又跟栈不同,方法区中类变量是线程共享的。
## 对象锁和类锁
正如前面所说,JVM 中的两个区域包含线程共享的数据,分别是:
1. **堆**:包含所有对象
2. **方法区**:包含所有类变量
如果多个线程需要同时使用同一个对象或者类变量,它们对数据的访问必须被恰当地控制。否则,程序会产生不可预测的行为。
为了协调多个线程对共享数据的访问,JVM 给每个对象和类关联了一个锁。锁就像是任意时间点只有一个线程能够拥有的特权。如果一个线程想要锁住一个特定的对象或者类,它需要向 JVM 请求锁。线程向 JVM 请求锁之后,可能很快就拿到,或者过一会就拿到,也可能永远拿不到。当线程不需要锁之后,它把锁还给 JVM。如果其他线程需要这个锁,JVM 会交给该线程。
类锁的实现其实跟对象锁是一样的。当 JVM 加载类文件的时候,它会创建一个对应类`java.lang.Class`对象。当你锁住一个类的时候,你实际上是锁住了这个类的`Class`对象。
线程访问对象实例或者类变量的时候不需要获取锁。但是如果一个线程获取了一个锁,其他线程不能访问被锁住的数据,直到拥有锁的线程释放它。
## 管程
JVM 使用锁和管程协作。管程监视一段代码,保证一个时间点内只有一个线程能执行这段代码。
每个管程与一个对象引用关联。当线程到达管程监视代码段的第一条指令时,线程必须获取关联对象的锁。线程不能执行这段代码直到它得到了锁。一旦它得到了锁,线程可以进入被保护的代码段。
当线程离开被保护的代码块,不管是如何离开的,它都会释放关联对象的锁。
## 多次锁定
一个线程被允许锁定一个对象多次。对于每个对象,JVM 维护了一个锁的计数器。没有被锁的对象计数为 0。当一个线程第一次获取锁,计数器自增变为 1。每次这个线程(已经得到锁的线程)请求同一个对象的锁,计数器都会自增。每次线程释放锁,计数器都会自减。当计数器变为 0 时,锁才被释放,可以给别的线程使用。
## 同步块
在 Java 语言的术语中,协调多个线程访问共享数据被称为**同步(synchronization)**。Java 提供了两种内建的方式来同步对数据的访问:
1. 同步语句
2. 同步方法
### 同步语句
为了创建同步语句,你需要使用`synchronized`关键字,括号里面是同步的对象引用,如下所示:
``` java
class KitchenSync {
private int[] intArray = new int[10];
void reverseOrder() {
synchronized (this) {
int halfWay = intArray.length / 2;
for (int i = 0; i < halfWay; ++i) {
int upperIndex = intArray.length - 1 - i;
int save = intArray[upperIndex];
intArray[upperIndex] = intArray[i];
intArray[i] = save;
}
}
}
}
```
在上面的例子中,被同步块包含的语句不会被执行,直到线程得到`this`引用的对象锁。如果不是锁住`this`引用,而是锁住其他对象,在线程执行同步块语句之前,它需要获得该对象的锁。
有两个字节码`monitorenter`和`monitorexit`,被用来**同步方法中的同步块**。
| 字节码 | 操作数 | 描述 |
| - | - | - |
| monitorenter | 无 | 取出对象引用,请求与对象引用关联的锁
| monitorexit | 无 | 取出对象引用,释放与对象引用关联的锁
当`monitorenter`被 JVM 执行时,它请求栈顶对象引用关联的锁。如果该线程已经拥有该对象的锁,计数器自增。每次`monitorexit`被执行,计数器自减。当计数器变为 0 时,该锁被释放。
**注意:**当同步块中抛出异常时,`catch`语句保证对象锁被释放。不管同步块是如何退出的,JVM 保证线程会释放锁。
### 同步方法
为了同步整个方法,你只需要在方法声明前面加上`synchronized`关键字。
``` java
class HeatSync {
private int[] intArray = new int[10];
synchronized void reverseOrder() {
int halfWay = intArray.length / 2;
for (int i = 0; i < halfWay; ++i) {
int upperIndex = intArray.length - 1 - i;
int save = intArray[upperIndex];
intArray[upperIndex] = intArray[i];
intArray[i] = save;
}
}
}
```
JVM 不会使用特殊的字节码来调用同步方法。当 JVM 解析方法的符号引用时,它会判断方法是不是同步的。如果是,JVM 要求线程在调用之前请求锁。对于实例方法,JVM 要求得到该实例对象的锁。对于类方法,JVM 要求得到类锁。在同步方法完成之后,不管它是正常返回还是抛出异常,锁都会被释放。
----------
谢谢大家阅读,如有帮助,来个喜欢或者关注吧!
----------
本文作者:Anderson/Jerey_Jobs
博客地址 : [夏敏的博客/Anderson大码渣/Jerey_Jobs][1] <br>
简书地址 : [Anderson大码渣][2] <br>
github地址 : [Jerey_Jobs][4]
[1]: http://jerey.cn/
[2]: http://www.jianshu.com/users/016a5ba708a0/latest_articles
[3]: http://blog.csdn.net/jerey_jobs
[4]: https://github.com/Jerey-Jobs
| Jerey-Jobs/Jerey-Jobs.github.io | _posts/2017-03-17-JVM学习之synchronization.md | Markdown | apache-2.0 | 7,136 | [
30522,
1011,
1011,
1011,
2516,
1024,
1046,
2615,
2213,
1817,
100,
1749,
100,
100,
1794,
100,
100,
100,
1916,
1787,
100,
22073,
1024,
1011,
1046,
2615,
2213,
20346,
1011,
10047,
2290,
1024,
1000,
10047,
2290,
1013,
2695,
1011,
1038,
2290,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 CreatePapers < ActiveRecord::Migration
def change
create_table :papers do |t|
t.string :title
t.string :venue
t.integer :year
t.timestamps null: false
end
end
end
| DanielStephan97/rails-exercise-17-swteam | db/migrate/20171030153253_create_papers.rb | Ruby | mit | 217 | [
30522,
2465,
3443,
23298,
2015,
1026,
3161,
2890,
27108,
2094,
1024,
1024,
9230,
13366,
2689,
3443,
1035,
2795,
1024,
4981,
2079,
1064,
1056,
1064,
1056,
1012,
5164,
1024,
2516,
1056,
1012,
5164,
1024,
6891,
1056,
1012,
16109,
1024,
2095,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
/**
* Fuel is a fast, lightweight, community driven PHP5 framework.
*
* @package Fuel
* @version 1.0
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2011 Fuel Development Team
* @link http://fuelphp.com
*/
namespace Orm;
abstract class Relation
{
/**
* @var string name of the relationship in the model_from
*/
protected $name;
/**
* @var Model classname of the parent model
*/
protected $model_from;
/**
* @var string classname of the related model
*/
protected $model_to;
/**
* @var string primary key of parent model
*/
protected $key_from = array('id');
/**
* @var string foreign key in related model
*/
protected $key_to = array();
/**
* @var array where & order_by conditions for loading this relation
*/
protected $conditions = array();
/**
* @var bool whether it's a single object or multiple
*/
protected $singular = false;
/**
* @var bool whether saving this one's model_from should cascade to save model_to
*/
protected $cascade_save = true;
/**
* @var bool whether deleting this one's model_from should cascade to delete model_to
*/
protected $cascade_delete = false;
/**
* Configures the relationship
*
* @param string the model that initiates the relationship
* @param string name of the relationship
* @param array config values like model_to classname, key_from & key_to
*/
abstract public function __construct($from, $name, array $config);
/**
* Should get the objects related to the given object by this relation
*
* @param Model
* @return object|array
*/
abstract public function get(Model $from);
/**
* Should get the properties as associative array with alias => property, the table alias is
* given to be included with the property
*
* @param string
* @return array
*/
public function select($table)
{
$props = call_user_func(array($this->model_to, 'properties'));
$i = 0;
$properties = array();
foreach ($props as $pk => $pv)
{
$properties[] = array($table.'.'.$pk, $table.'_c'.$i);
$i++;
}
return $properties;
}
/**
* Returns tables to join and fields to select with optional additional settings like order/where
*
* @param string alias for the from table
* @param string alias for the to table
* @return array
*/
abstract public function join($alias_from, $rel_name, $alias_to);
/**
* Saves the current relationships and may cascade saving to model_to instances
*
* @param Model instance of model_from
* @param array|Model single or multiple model instances to save
* @param bool whether the model_from has been saved already
* @param null|bool either uses default setting (null) or forces when true or prevents when false
* @todo make abstract
*/
abstract public function save($model_from, $model_to, $original_model_id, $parent_saved, $cascade);
/**
* Takes the current relations and attempts to delete them when cascading is allowed or forced
*
* @param Model instance of model_from
* @param array|Model single or multiple model instances to delete
* @param bool whether the model_from has been saved already
* @param null|bool either uses default setting (null) or forces when true or prevents when false
* @todo make abstract
*/
abstract public function delete($model_from, $model_to, $parent_deleted, $cascade);
/**
* Allow outside access to protected properties
*
* @param $property
*/
public function __get($property)
{
if (strncmp($property, '_', 1) == 0 or ! property_exists($this, $property))
{
throw new \FuelException('Invalid relation property: '.$property);
}
return $this->{$property};
}
}
/* End of file relation.php */ | hendrik-weiler/Portal-CMS | fuel/packages/orm/classes/relation.php | PHP | gpl-3.0 | 3,807 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
4762,
2003,
1037,
3435,
1010,
12038,
1010,
2451,
5533,
25718,
2629,
7705,
1012,
1008,
1008,
1030,
7427,
4762,
1008,
1030,
2544,
1015,
1012,
1014,
1008,
1030,
3166,
4762,
2458,
2136,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
/**
* Core file
*
* @author Vince Wooll <sales@jomres.net>
* @version Jomres 7
* @package Jomres
* @copyright 2005-2013 Vince Wooll
* Jomres (tm) PHP, CSS & Javascript files are released under both MIT and GPL2 licenses. This means that you can choose the license that best suits your project, and use it accordingly.
**/
// ################################################################
defined( '_JOMRES_INITCHECK' ) or die( '' );
// ################################################################
class j16000editinplace
{
function j16000editinplace()
{
// Must be in all minicomponents. Minicomponents with templates that can contain editable text should run $this->template_touch() else just return
$MiniComponents = jomres_singleton_abstract::getInstance( 'mcHandler' );
if ( $MiniComponents->template_touch )
{
$this->template_touchable = false;
return;
}
$customText = jomresGetParam( $_POST, 'value', '', 'string' );
$theConstant = filter_var( $_POST[ 'pk' ], FILTER_SANITIZE_SPECIAL_CHARS );
//$lang = jomresGetParam( $_REQUEST, 'lang', '' );
$result = updateCustomText( $theConstant, $customText, true, 0 );
//$result = false;
if ( $result )
{
header( "Status: 200" );
echo jomres_decode( $customText );
}
else
{
header( "Status: 500" );
echo "Something burped";
}
}
// This must be included in every Event/Mini-component
function getRetVals()
{
return null;
}
}
?> | parksandwildlife/parkstay | jomres/core-minicomponents/j16000editinplace.class.php | PHP | gpl-2.0 | 1,484 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
4563,
5371,
1008,
1008,
1030,
3166,
12159,
12121,
2140,
1026,
4341,
1030,
8183,
2213,
6072,
1012,
5658,
1028,
1008,
1030,
2544,
8183,
2213,
6072,
1021,
1008,
1030,
7427,
8183,
2213,
6072,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 2012-2017 Amazon.com, Inc. or its affiliates. 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. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.amazonaws.services.inspector.model;
import javax.annotation.Generated;
/**
* <p>
* You started an assessment run, but one of the instances is already participating in another assessment run.
* </p>
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AgentsAlreadyRunningAssessmentException extends com.amazonaws.services.inspector.model.AmazonInspectorException {
private static final long serialVersionUID = 1L;
/** <p/> */
private java.util.List<AgentAlreadyRunningAssessment> agents;
/** <p/> */
private Boolean agentsTruncated;
/**
* <p>
* You can immediately retry your request.
* </p>
*/
private Boolean canRetry;
/**
* Constructs a new AgentsAlreadyRunningAssessmentException with the specified error message.
*
* @param message
* Describes the error encountered.
*/
public AgentsAlreadyRunningAssessmentException(String message) {
super(message);
}
/**
* <p/>
*
* @return
*/
@com.fasterxml.jackson.annotation.JsonProperty("agents")
public java.util.List<AgentAlreadyRunningAssessment> getAgents() {
return agents;
}
/**
* <p/>
*
* @param agents
*/
@com.fasterxml.jackson.annotation.JsonProperty("agents")
public void setAgents(java.util.Collection<AgentAlreadyRunningAssessment> agents) {
if (agents == null) {
this.agents = null;
return;
}
this.agents = new java.util.ArrayList<AgentAlreadyRunningAssessment>(agents);
}
/**
* <p/>
* <p>
* <b>NOTE:</b> This method appends the values to the existing list (if any). Use
* {@link #setAgents(java.util.Collection)} or {@link #withAgents(java.util.Collection)} if you want to override the
* existing values.
* </p>
*
* @param agents
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AgentsAlreadyRunningAssessmentException withAgents(AgentAlreadyRunningAssessment... agents) {
if (this.agents == null) {
setAgents(new java.util.ArrayList<AgentAlreadyRunningAssessment>(agents.length));
}
for (AgentAlreadyRunningAssessment ele : agents) {
this.agents.add(ele);
}
return this;
}
/**
* <p/>
*
* @param agents
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AgentsAlreadyRunningAssessmentException withAgents(java.util.Collection<AgentAlreadyRunningAssessment> agents) {
setAgents(agents);
return this;
}
/**
* <p/>
*
* @param agentsTruncated
*/
@com.fasterxml.jackson.annotation.JsonProperty("agentsTruncated")
public void setAgentsTruncated(Boolean agentsTruncated) {
this.agentsTruncated = agentsTruncated;
}
/**
* <p/>
*
* @return
*/
@com.fasterxml.jackson.annotation.JsonProperty("agentsTruncated")
public Boolean getAgentsTruncated() {
return this.agentsTruncated;
}
/**
* <p/>
*
* @param agentsTruncated
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AgentsAlreadyRunningAssessmentException withAgentsTruncated(Boolean agentsTruncated) {
setAgentsTruncated(agentsTruncated);
return this;
}
/**
* <p/>
*
* @return
*/
public Boolean isAgentsTruncated() {
return this.agentsTruncated;
}
/**
* <p>
* You can immediately retry your request.
* </p>
*
* @param canRetry
* You can immediately retry your request.
*/
@com.fasterxml.jackson.annotation.JsonProperty("canRetry")
public void setCanRetry(Boolean canRetry) {
this.canRetry = canRetry;
}
/**
* <p>
* You can immediately retry your request.
* </p>
*
* @return You can immediately retry your request.
*/
@com.fasterxml.jackson.annotation.JsonProperty("canRetry")
public Boolean getCanRetry() {
return this.canRetry;
}
/**
* <p>
* You can immediately retry your request.
* </p>
*
* @param canRetry
* You can immediately retry your request.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AgentsAlreadyRunningAssessmentException withCanRetry(Boolean canRetry) {
setCanRetry(canRetry);
return this;
}
/**
* <p>
* You can immediately retry your request.
* </p>
*
* @return You can immediately retry your request.
*/
public Boolean isCanRetry() {
return this.canRetry;
}
}
| dagnir/aws-sdk-java | aws-java-sdk-inspector/src/main/java/com/amazonaws/services/inspector/model/AgentsAlreadyRunningAssessmentException.java | Java | apache-2.0 | 5,478 | [
30522,
1013,
1008,
1008,
9385,
2262,
1011,
2418,
9733,
1012,
4012,
1010,
4297,
1012,
2030,
2049,
18460,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
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... |
$_L(["$wt.widgets.Layout"],"$wt.layout.FillLayout",["$wt.graphics.Point","$wt.layout.FillData"],function(){
c$=$_C(function(){
this.type=256;
this.marginWidth=0;
this.marginHeight=0;
this.spacing=0;
$_Z(this,arguments);
},$wt.layout,"FillLayout",$wt.widgets.Layout);
$_K(c$,
function(){
$_R(this,$wt.layout.FillLayout,[]);
});
$_K(c$,
function(type){
$_R(this,$wt.layout.FillLayout,[]);
this.type=type;
},"~N");
$_V(c$,"computeSize",
function(composite,wHint,hHint,flushCache){
var children=composite.getChildren();
var count=children.length;
var maxWidth=0;
var maxHeight=0;
for(var i=0;i<count;i++){
var child=children[i];
var w=wHint;
var h=hHint;
if(count>0){
if(this.type==256&&wHint!=-1){
w=Math.max(0,Math.floor((wHint-(count-1)*this.spacing)/count));
}if(this.type==512&&hHint!=-1){
h=Math.max(0,Math.floor((hHint-(count-1)*this.spacing)/count));
}}var size=this.computeChildSize(child,w,h,flushCache);
maxWidth=Math.max(maxWidth,size.x);
maxHeight=Math.max(maxHeight,size.y);
}
var width=0;
var height=0;
if(this.type==256){
width=count*maxWidth;
if(count!=0)width+=(count-1)*this.spacing;
height=maxHeight;
}else{
width=maxWidth;
height=count*maxHeight;
if(count!=0)height+=(count-1)*this.spacing;
}width+=this.marginWidth*2;
height+=this.marginHeight*2;
if(wHint!=-1)width=wHint;
if(hHint!=-1)height=hHint;
return new $wt.graphics.Point(width,height);
},"$wt.widgets.Composite,~N,~N,~B");
$_M(c$,"computeChildSize",
function(control,wHint,hHint,flushCache){
var data=control.getLayoutData();
if(data==null){
data=new $wt.layout.FillData();
control.setLayoutData(data);
}var size=null;
if(wHint==-1&&hHint==-1){
size=data.computeSize(control,wHint,hHint,flushCache);
}else{
var trimX;
var trimY;
if($_O(control,$wt.widgets.Scrollable)){
var rect=(control).computeTrim(0,0,0,0);
trimX=rect.width;
trimY=rect.height;
}else{
trimX=trimY=control.getBorderWidth()*2;
}var w=wHint==-1?wHint:Math.max(0,wHint-trimX);
var h=hHint==-1?hHint:Math.max(0,hHint-trimY);
size=data.computeSize(control,w,h,flushCache);
}return size;
},"$wt.widgets.Control,~N,~N,~B");
$_V(c$,"flushCache",
function(control){
var data=control.getLayoutData();
if(data!=null)(data).flushCache();
return true;
},"$wt.widgets.Control");
$_M(c$,"getName",
function(){
var string=this.getClass().getName();
var index=string.lastIndexOf('.');
if(index==-1)return string;
return string.substring(index+1,string.length);
});
$_V(c$,"layout",
function(composite,flushCache){
var rect=composite.getClientArea();
var children=composite.getChildren();
var count=children.length;
if(count==0)return;
var width=rect.width-this.marginWidth*2;
var height=rect.height-this.marginHeight*2;
if(this.type==256){
width-=(count-1)*this.spacing;
var x=rect.x+this.marginWidth;
var extra=width%count;
var y=rect.y+this.marginHeight;
var cellWidth=Math.floor(width/count);
for(var i=0;i<count;i++){
var child=children[i];
var childWidth=cellWidth;
if(i==0){
childWidth+=Math.floor(extra/2);
}else{
if(i==count-1)childWidth+=Math.floor((extra+1)/2);
}child.setBounds(x,y,childWidth,height);
x+=childWidth+this.spacing;
}
}else{
height-=(count-1)*this.spacing;
var x=rect.x+this.marginWidth;
var cellHeight=Math.floor(height/count);
var y=rect.y+this.marginHeight;
var extra=height%count;
for(var i=0;i<count;i++){
var child=children[i];
var childHeight=cellHeight;
if(i==0){
childHeight+=Math.floor(extra/2);
}else{
if(i==count-1)childHeight+=Math.floor((extra+1)/2);
}child.setBounds(x,y,width,childHeight);
y+=childHeight+this.spacing;
}
}},"$wt.widgets.Composite,~B");
$_V(c$,"toString",
function(){
var string=this.getName()+"{";
string+="type="+((this.type==512)?"SWT.VERTICAL":"SWT.HORIZONTAL")+" ";
if(this.marginWidth!=0)string+="marginWidth="+this.marginWidth+" ";
if(this.marginHeight!=0)string+="marginHeight="+this.marginHeight+" ";
if(this.spacing!=0)string+="spacing="+this.spacing+" ";
string=string.trim();
string+="}";
return string;
});
});
| 01org/mayloon-portingtool | sources/net.sf.j2s.lib/j2slib/org/eclipse/swt/layout/FillLayout.js | JavaScript | epl-1.0 | 4,054 | [
30522,
1002,
1035,
1048,
1006,
1031,
1000,
1002,
1059,
2102,
1012,
15536,
28682,
1012,
9621,
1000,
1033,
1010,
1000,
1002,
1059,
2102,
1012,
9621,
1012,
6039,
8485,
5833,
1000,
1010,
1031,
1000,
1002,
1059,
2102,
1012,
8389,
1012,
2391,
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... |
# Aletris pauciflora f. minuscula FORM
#### Status
SYNONYM
#### According to
The Catalogue of Life, 3rd January 2011
#### Published in
null
#### Original name
null
### Remarks
null | mdoering/backbone | life/Plantae/Magnoliophyta/Liliopsida/Dioscoreales/Nartheciaceae/Aletris/Aletris pauciflora/ Syn. Aletris pauciflora minuscula/README.md | Markdown | apache-2.0 | 185 | [
30522,
1001,
15669,
18886,
2015,
29025,
6895,
10258,
6525,
1042,
1012,
15718,
19879,
2433,
1001,
1001,
1001,
1001,
3570,
10675,
1001,
1001,
1001,
1001,
2429,
2000,
1996,
10161,
1997,
2166,
1010,
3822,
2254,
2249,
1001,
1001,
1001,
1001,
240... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) 2010, Carl Burch. License information is located in the
* com.cburch.logisim.Main source code and at www.cburch.com/logisim/. */
package com.cburch.logisim.tools;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import javax.swing.Icon;
import javax.swing.JOptionPane;
import com.cburch.logisim.LogisimVersion;
import com.cburch.logisim.circuit.Circuit;
import com.cburch.logisim.circuit.CircuitException;
import com.cburch.logisim.circuit.CircuitMutation;
import com.cburch.logisim.circuit.SubcircuitFactory;
import com.cburch.logisim.comp.Component;
import com.cburch.logisim.comp.ComponentFactory;
import com.cburch.logisim.comp.ComponentDrawContext;
import com.cburch.logisim.data.Attribute;
import com.cburch.logisim.data.AttributeEvent;
import com.cburch.logisim.data.AttributeListener;
import com.cburch.logisim.data.AttributeSet;
import com.cburch.logisim.data.Bounds;
import com.cburch.logisim.data.Direction;
import com.cburch.logisim.data.Location;
import com.cburch.logisim.gui.main.Canvas;
import com.cburch.logisim.gui.main.SelectionActions;
import com.cburch.logisim.gui.main.ToolAttributeAction;
import com.cburch.logisim.prefs.AppPreferences;
import com.cburch.logisim.proj.Action;
import com.cburch.logisim.proj.Dependencies;
import com.cburch.logisim.proj.Project;
import com.cburch.logisim.tools.key.KeyConfigurationEvent;
import com.cburch.logisim.tools.key.KeyConfigurator;
import com.cburch.logisim.tools.key.KeyConfigurationResult;
import static com.cburch.logisim.util.LocaleString.*;
public class AddTool extends Tool {
private static int INVALID_COORD = Integer.MIN_VALUE;
private static int SHOW_NONE = 0;
private static int SHOW_GHOST = 1;
private static int SHOW_ADD = 2;
private static int SHOW_ADD_NO = 3;
private static Cursor cursor
= Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
private class MyAttributeListener implements AttributeListener {
@Override
public void attributeListChanged(AttributeEvent e) {
bounds = null;
}
@Override
public void attributeValueChanged(AttributeEvent e) {
bounds = null;
}
}
private Class<? extends Library> descriptionBase;
private FactoryDescription description;
private boolean sourceLoadAttempted;
private ComponentFactory factory;
private AttributeSet attrs;
private Bounds bounds;
private boolean shouldSnap;
private int lastX = INVALID_COORD;
private int lastY = INVALID_COORD;
private int state = SHOW_GHOST;
private Action lastAddition;
private boolean keyHandlerTried;
private KeyConfigurator keyHandler;
public AddTool(Class<? extends Library> base, FactoryDescription description) {
this.descriptionBase = base;
this.description = description;
this.sourceLoadAttempted = false;
this.shouldSnap = true;
this.attrs = new FactoryAttributes(base, description);
attrs.addAttributeListener(new MyAttributeListener());
this.keyHandlerTried = false;
}
public AddTool(ComponentFactory source) {
this.description = null;
this.sourceLoadAttempted = true;
this.factory = source;
this.bounds = null;
this.attrs = new FactoryAttributes(source);
attrs.addAttributeListener(new MyAttributeListener());
Boolean value = (Boolean) source.getFeature(ComponentFactory.SHOULD_SNAP, attrs);
this.shouldSnap = value == null ? true : value.booleanValue();
}
private AddTool(AddTool base) {
this.descriptionBase = base.descriptionBase;
this.description = base.description;
this.sourceLoadAttempted = base.sourceLoadAttempted;
this.factory = base.factory;
this.bounds = base.bounds;
this.shouldSnap = base.shouldSnap;
this.attrs = (AttributeSet) base.attrs.clone();
attrs.addAttributeListener(new MyAttributeListener());
}
@Override
public boolean equals(Object other) {
if (!(other instanceof AddTool)) {
return false;
}
AddTool o = (AddTool) other;
if (this.description != null) {
return this.descriptionBase == o.descriptionBase
&& this.description.equals(o.description);
} else {
return this.factory.equals(o.factory);
}
}
@Override
public int hashCode() {
FactoryDescription desc = description;
return desc != null ? desc.hashCode() : factory.hashCode();
}
@Override
public boolean sharesSource(Tool other) {
if (!(other instanceof AddTool)) {
return false;
}
AddTool o = (AddTool) other;
if (this.sourceLoadAttempted && o.sourceLoadAttempted) {
return this.factory.equals(o.factory);
}
if (this.description == null) {
return o.description == null;
}
return this.description.equals(o.description);
}
public ComponentFactory getFactory(boolean forceLoad) {
return forceLoad ? getFactory() : factory;
}
public ComponentFactory getFactory() {
ComponentFactory ret = factory;
if (ret != null || sourceLoadAttempted) {
return ret;
}
ret = description.getFactory(descriptionBase);
if (ret != null) {
AttributeSet base = getBaseAttributes();
Boolean value = (Boolean) ret.getFeature(ComponentFactory.SHOULD_SNAP, base);
shouldSnap = value == null ? true : value.booleanValue();
}
factory = ret;
sourceLoadAttempted = true;
return ret;
}
@Override
public String getName() {
FactoryDescription desc = description;
return desc == null ? factory.getName() : desc.getName();
}
@Override
public String getDisplayName() {
FactoryDescription desc = description;
return desc == null ? factory.getDisplayName() : desc.getDisplayName();
}
@Override
public String getDescription() {
String ret;
FactoryDescription desc = description;
if (desc != null) {
ret = desc.getToolTip();
} else {
ComponentFactory source = getFactory();
if (source != null) {
ret = (String) source.getFeature(ComponentFactory.TOOL_TIP,
getAttributeSet());
} else {
ret = null;
}
}
if (ret == null) {
ret = getFromLocale("addToolText", getDisplayName());
}
return ret;
}
@Override
public Tool cloneTool() {
return new AddTool(this);
}
@Override
public AttributeSet getAttributeSet() {
return attrs;
}
@Override
public boolean isAllDefaultValues(AttributeSet attrs, LogisimVersion ver) {
return this.attrs == attrs && attrs instanceof FactoryAttributes
&& !((FactoryAttributes) attrs).isFactoryInstantiated();
}
@Override
public Object getDefaultAttributeValue(Attribute<?> attr, LogisimVersion ver) {
return getFactory().getDefaultAttributeValue(attr, ver);
}
@Override
public void draw(Canvas canvas, ComponentDrawContext context) {
// next "if" suggested roughly by Kevin Walsh of Cornell to take care of
// repaint problems on OpenJDK under Ubuntu
int x = lastX;
int y = lastY;
if (x == INVALID_COORD || y == INVALID_COORD) {
return;
}
ComponentFactory source = getFactory();
if (source == null) {
return;
}
if (state == SHOW_GHOST) {
source.drawGhost(context, Color.GRAY, x, y, getBaseAttributes());
} else if (state == SHOW_ADD) {
source.drawGhost(context, Color.BLACK, x, y, getBaseAttributes());
}
}
private AttributeSet getBaseAttributes() {
AttributeSet ret = attrs;
if (ret instanceof FactoryAttributes) {
ret = ((FactoryAttributes) ret).getBase();
}
return ret;
}
public void cancelOp() { }
@Override
public void select(Canvas canvas) {
setState(canvas, SHOW_GHOST);
bounds = null;
}
@Override
public void deselect(Canvas canvas) {
setState(canvas, SHOW_GHOST);
moveTo(canvas, canvas.getGraphics(), INVALID_COORD, INVALID_COORD);
bounds = null;
lastAddition = null;
}
private synchronized void moveTo(Canvas canvas, Graphics g,
int x, int y) {
if (state != SHOW_NONE) {
expose(canvas, lastX, lastY);
}
lastX = x;
lastY = y;
if (state != SHOW_NONE) {
expose(canvas, lastX, lastY);
}
}
@Override
public void mouseEntered(Canvas canvas, Graphics g,
MouseEvent e) {
if (state == SHOW_GHOST || state == SHOW_NONE) {
setState(canvas, SHOW_GHOST);
canvas.requestFocusInWindow();
} else if (state == SHOW_ADD_NO) {
setState(canvas, SHOW_ADD);
canvas.requestFocusInWindow();
}
}
@Override
public void mouseExited(Canvas canvas, Graphics g,
MouseEvent e) {
if (state == SHOW_GHOST) {
moveTo(canvas, canvas.getGraphics(), INVALID_COORD, INVALID_COORD);
setState(canvas, SHOW_NONE);
} else if (state == SHOW_ADD) {
moveTo(canvas, canvas.getGraphics(), INVALID_COORD, INVALID_COORD);
setState(canvas, SHOW_ADD_NO);
}
}
@Override
public void mouseMoved(Canvas canvas, Graphics g, MouseEvent e) {
if (state != SHOW_NONE) {
if (shouldSnap) {
Canvas.snapToGrid(e);
}
moveTo(canvas, g, e.getX(), e.getY());
}
}
@Override
public void mousePressed(Canvas canvas, Graphics g, MouseEvent e) {
// verify the addition would be valid
Circuit circ = canvas.getCircuit();
if (!canvas.getProject().getLogisimFile().contains(circ)) {
canvas.setErrorMessage(getFromLocale("cannotModifyError"), 0, 0);
return;
}
if (factory instanceof SubcircuitFactory) {
SubcircuitFactory circFact = (SubcircuitFactory) factory;
Dependencies depends = canvas.getProject().getDependencies();
if (!depends.canAdd(circ, circFact.getSubcircuit())) {
canvas.setErrorMessage(getFromLocale("circularError"), 0, 0);
return;
}
}
if (shouldSnap) {
Canvas.snapToGrid(e);
}
moveTo(canvas, g, e.getX(), e.getY());
setState(canvas, SHOW_ADD);
}
@Override
public void mouseDragged(Canvas canvas, Graphics g, MouseEvent e) {
if (state != SHOW_NONE) {
if (shouldSnap) {
Canvas.snapToGrid(e);
}
moveTo(canvas, g, e.getX(), e.getY());
}
}
@Override
public void mouseReleased(Canvas canvas, Graphics g,
MouseEvent e) {
Component added = null;
if (state == SHOW_ADD) {
Circuit circ = canvas.getCircuit();
if (!canvas.getProject().getLogisimFile().contains(circ)) {
return;
}
if (shouldSnap) {
Canvas.snapToGrid(e);
}
moveTo(canvas, g, e.getX(), e.getY());
Location loc = Location.create(e.getX(), e.getY());
AttributeSet attrsCopy = (AttributeSet) attrs.clone();
ComponentFactory source = getFactory();
if (source == null) {
return;
}
Component c = source.createComponent(loc, attrsCopy);
if (circ.hasConflict(c)) {
canvas.setErrorMessage(getFromLocale("exclusiveError"), 0, 0);
return;
}
Bounds bds = c.getBounds(g);
if (bds.getX() < 0 || bds.getY() < 0) {
canvas.setErrorMessage(getFromLocale("negativeCoordError"), 0, 0);
return;
}
try {
CircuitMutation mutation = new CircuitMutation(circ);
mutation.add(c);
Action action = mutation.toAction(getFromLocale("addComponentAction", factory.getDisplayGetter()));
canvas.getProject().doAction(action);
lastAddition = action;
added = c;
} catch (CircuitException ex) {
JOptionPane.showMessageDialog(canvas.getProject().getFrame(),
ex.getMessage());
}
setState(canvas, SHOW_GHOST);
} else if (state == SHOW_ADD_NO) {
setState(canvas, SHOW_NONE);
}
Project proj = canvas.getProject();
Tool next = determineNext(proj);
if (next != null) {
proj.setTool(next);
Action act = SelectionActions.dropAll(canvas.getSelection());
if (act != null) {
proj.doAction(act);
}
if (added != null) {
canvas.getSelection().add(added);
}
}
}
private Tool determineNext(Project proj) {
String afterAdd = AppPreferences.ADD_AFTER.get();
if (afterAdd.equals(AppPreferences.ADD_AFTER_UNCHANGED)) {
return null;
// switch to Edit Tool
} else {
Library base = proj.getLogisimFile().getLibrary("Base");
if (base == null) {
return null;
} else {
return base.getTool("Edit Tool");
}
}
}
@Override
public void keyPressed(Canvas canvas, KeyEvent event) {
processKeyEvent(canvas, event, KeyConfigurationEvent.KEY_PRESSED);
if (!event.isConsumed() && event.getModifiersEx() == 0) {
switch (event.getKeyCode()) {
case KeyEvent.VK_UP: setFacing(canvas, Direction.NORTH); break;
case KeyEvent.VK_DOWN: setFacing(canvas, Direction.SOUTH); break;
case KeyEvent.VK_LEFT: setFacing(canvas, Direction.WEST); break;
case KeyEvent.VK_RIGHT: setFacing(canvas, Direction.EAST); break;
case KeyEvent.VK_BACK_SPACE:
if (lastAddition != null && canvas.getProject().getLastAction() == lastAddition) {
canvas.getProject().undoAction();
lastAddition = null;
}
}
}
}
@Override
public void keyReleased(Canvas canvas, KeyEvent event) {
processKeyEvent(canvas, event, KeyConfigurationEvent.KEY_RELEASED);
}
@Override
public void keyTyped(Canvas canvas, KeyEvent event) {
processKeyEvent(canvas, event, KeyConfigurationEvent.KEY_TYPED);
}
private void processKeyEvent(Canvas canvas, KeyEvent event, int type) {
KeyConfigurator handler = keyHandler;
if (!keyHandlerTried) {
ComponentFactory source = getFactory();
AttributeSet baseAttrs = getBaseAttributes();
handler = (KeyConfigurator) source.getFeature(KeyConfigurator.class, baseAttrs);
keyHandler = handler;
keyHandlerTried = true;
}
if (handler != null) {
AttributeSet baseAttrs = getBaseAttributes();
KeyConfigurationEvent e = new KeyConfigurationEvent(type, baseAttrs, event, this);
KeyConfigurationResult r = handler.keyEventReceived(e);
if (r != null) {
Action act = ToolAttributeAction.create(r);
canvas.getProject().doAction(act);
}
}
}
private void setFacing(Canvas canvas, Direction facing) {
ComponentFactory source = getFactory();
if (source == null) {
return;
}
AttributeSet base = getBaseAttributes();
Object feature = source.getFeature(ComponentFactory.FACING_ATTRIBUTE_KEY, base);
@SuppressWarnings("unchecked")
Attribute<Direction> attr = (Attribute<Direction>) feature;
if (attr != null) {
Action act = ToolAttributeAction.create(this, attr, facing);
canvas.getProject().doAction(act);
}
}
@Override
public void paintIcon(ComponentDrawContext c, int x, int y) {
FactoryDescription desc = description;
if (desc != null && !desc.isFactoryLoaded()) {
Icon icon = desc.getIcon();
if (icon != null) {
icon.paintIcon(c.getDestination(), c.getGraphics(), x + 2, y + 2);
return;
}
}
ComponentFactory source = getFactory();
if (source != null) {
AttributeSet base = getBaseAttributes();
source.paintIcon(c, x, y, base);
}
}
private void expose(java.awt.Component c, int x, int y) {
Bounds bds = getBounds();
c.repaint(x + bds.getX(), y + bds.getY(),
bds.getWidth(), bds.getHeight());
}
@Override
public Cursor getCursor() { return cursor; }
private void setState(Canvas canvas, int value) {
if (value == SHOW_GHOST) {
if (canvas.getProject().getLogisimFile().contains(canvas.getCircuit())
&& AppPreferences.ADD_SHOW_GHOSTS.getBoolean()) {
state = SHOW_GHOST;
} else {
state = SHOW_NONE;
}
} else {
state = value;
}
}
private Bounds getBounds() {
Bounds ret = bounds;
if (ret == null) {
ComponentFactory source = getFactory();
if (source == null) {
ret = Bounds.EMPTY_BOUNDS;
} else {
AttributeSet base = getBaseAttributes();
ret = source.getOffsetBounds(base).expand(5);
}
bounds = ret;
}
return ret;
}
}
| lawrancej/logisim | src/main/java/com/cburch/logisim/tools/AddTool.java | Java | gpl-3.0 | 18,224 | [
30522,
1013,
1008,
9385,
1006,
1039,
1007,
2230,
1010,
5529,
20934,
11140,
1012,
6105,
2592,
2003,
2284,
1999,
1996,
1008,
4012,
1012,
17324,
3126,
2818,
1012,
8833,
17417,
2213,
1012,
2364,
3120,
3642,
1998,
2012,
7479,
1012,
17324,
3126,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 perl
use warnings;
use strict;
die "Usage: perl $0 <fasta> <split number> <outprefix>\n" if(@ARGV ne 3);
open FA, $ARGV[0] or die $!;
$/ = "\n>";
my @fa;
while(<FA>)
{
chomp;
s/^>//;
push @fa, $_;
}
my $n = int(@fa / $ARGV[1]);
for(my $i = 0; $i < $ARGV[1]; $i ++)
{
open OUT, "> $ARGV[2].$i.fasta" or die $!;
for(my $j = 0; $j < $n; $j ++)
{
my $a = shift @fa;
print OUT ">$a\n";
}
}
foreach(@fa)
{
print OUT ">$_\n";
}
| BaconKwan/Perl_programme | utility/split_fasta.pl | Perl | apache-2.0 | 451 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
2566,
2140,
2224,
16234,
1025,
2224,
9384,
1025,
3280,
1000,
8192,
1024,
2566,
2140,
1002,
1014,
1026,
3435,
2050,
1028,
1026,
3975,
2193,
1028,
1026,
2041,
28139,
8873,
25... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Forum\Controller;
use Flarum\Core\PasswordToken;
use Flarum\Core\Validator\UserValidator;
use Flarum\Forum\UrlGenerator;
use Flarum\Http\Controller\ControllerInterface;
use Flarum\Http\SessionAuthenticator;
use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Diactoros\Response\RedirectResponse;
class SavePasswordController implements ControllerInterface
{
/**
* @var UrlGenerator
*/
protected $url;
/**
* @var UserValidator
*/
protected $validator;
/**
* @var SessionAuthenticator
*/
protected $authenticator;
/**
* @param UrlGenerator $url
* @param SessionAuthenticator $authenticator
*/
public function __construct(UrlGenerator $url, SessionAuthenticator $authenticator, UserValidator $validator)
{
$this->url = $url;
$this->authenticator = $authenticator;
$this->validator = $validator;
}
/**
* @param Request $request
* @return RedirectResponse
*/
public function handle(Request $request)
{
$input = $request->getParsedBody();
$token = PasswordToken::findOrFail(array_get($input, 'passwordToken'));
$password = array_get($input, 'password');
$confirmation = array_get($input, 'password_confirmation');
$this->validator->assertValid(compact('password'));
if (! $password || $password !== $confirmation) {
return new RedirectResponse($this->url->toRoute('resetPassword', ['token' => $token->id]));
}
$token->user->changePassword($password);
$token->user->save();
$token->delete();
$session = $request->getAttribute('session');
$this->authenticator->logIn($session, $token->user->id);
return new RedirectResponse($this->url->toBase());
}
}
| Jerrrrry/yuepao | vendor/flarum/core/src/Forum/Controller/SavePasswordController.php | PHP | mit | 2,065 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
13109,
15728,
2213,
1012,
1008,
1008,
1006,
1039,
1007,
11291,
27838,
18703,
1026,
11291,
1012,
27838,
18703,
1030,
20917,
4014,
1012,
4012,
1028,
1008,
1008,
2005,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.