code
stringlengths 3
1.01M
| repo_name
stringlengths 5
116
| path
stringlengths 3
311
| language
stringclasses 30
values | license
stringclasses 15
values | size
int64 3
1.01M
|
|---|---|---|---|---|---|
export default {
cancel: 'Cancelar',
reply: 'Responder',
onMyWay: 'Estou a caminho',
customMessage: 'Mensagem personalizada',
callMeBackIn: 'Ligue de novo em',
willCallYouBackIn: 'Você pode ligar de novo em',
min: 'min.',
hours: 'horas',
days: 'dias',
};
// @key: @#@"cancel"@#@ @source: @#@"Cancel"@#@
// @key: @#@"reply"@#@ @source: @#@"Reply"@#@
// @key: @#@"onMyWay"@#@ @source: @#@"On my way"@#@
// @key: @#@"customMessage"@#@ @source: @#@"Custom Message"@#@
// @key: @#@"callMeBackIn"@#@ @source: @#@"Call me back in"@#@
// @key: @#@"willCallYouBackIn"@#@ @source: @#@"Will call you back in"@#@
// @key: @#@"min"@#@ @source: @#@"min."@#@
// @key: @#@"hours"@#@ @source: @#@"hours"@#@
// @key: @#@"days"@#@ @source: @#@"days"@#@
|
u9520107/ringcentral-js-widget
|
packages/ringcentral-widgets/components/ReplyWithMessage/i18n/pt-BR.js
|
JavaScript
|
mit
| 754
|
<?xml version="1.0" ?><!DOCTYPE TS><TS language="bg" version="2.1">
<context>
<name>AboutDialog</name>
<message>
<location filename="../forms/aboutdialog.ui" line="+14"/>
<source>About Entrustcoin</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+39"/>
<source><b>Entrustcoin</b> version</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+41"/>
<source>Copyright © 2009-2014 The Bitcoin developers
Copyright © 2012-2014 The NovaCoin developers
Copyright © 2014 The BlackCoin developers
Copyright © 2014 The Entrustcoin developers</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+15"/>
<source>
This is experimental software.
Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php.
This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard.</source>
<translation>
Това е експериментален софтуер.
Разпространява се под MIT/X11 софтуерен лиценз, виж COPYING или http://www.opensource.org/licenses/mit-license.php.
Използван е софтуер, разработен от OpenSSL Project за употреба в OpenSSL Toolkit (http://www.openssl.org/), криптографски софтуер разработен от Eric Young (eay@cryptsoft.com) и UPnP софтуер разработен от Thomas Bernard.</translation>
</message>
</context>
<context>
<name>AddressBookPage</name>
<message>
<location filename="../forms/addressbookpage.ui" line="+14"/>
<source>Address Book</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+22"/>
<source>Double-click to edit address or label</source>
<translation>Двоен клик за редакция на адрес или име</translation>
</message>
<message>
<location line="+27"/>
<source>Create a new address</source>
<translation>Създаване на нов адрес</translation>
</message>
<message>
<location line="+14"/>
<source>Copy the currently selected address to the system clipboard</source>
<translation>Копирай избрания адрес</translation>
</message>
<message>
<location line="-11"/>
<source>&New Address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-46"/>
<source>These are your Entrustcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+60"/>
<source>&Copy Address</source>
<translation>&Копирай</translation>
</message>
<message>
<location line="+11"/>
<source>Show &QR Code</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+11"/>
<source>Sign a message to prove you own a Entrustcoin address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Sign &Message</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+25"/>
<source>Delete the currently selected address from the list</source>
<translation>Изтрий избрания адрес от списъка</translation>
</message>
<message>
<location line="-14"/>
<source>Verify a message to ensure it was signed with a specified Entrustcoin address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>&Verify Message</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+14"/>
<source>&Delete</source>
<translation>&Изтрий</translation>
</message>
<message>
<location filename="../addressbookpage.cpp" line="+65"/>
<source>Copy &Label</source>
<translation>Копирай &име</translation>
</message>
<message>
<location line="+2"/>
<source>&Edit</source>
<translation>&Редактирай</translation>
</message>
<message>
<location line="+250"/>
<source>Export Address Book Data</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Comma separated file (*.csv)</source>
<translation>CSV файл (*.csv)</translation>
</message>
<message>
<location line="+13"/>
<source>Error exporting</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>Could not write to file %1.</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>AddressTableModel</name>
<message>
<location filename="../addresstablemodel.cpp" line="+144"/>
<source>Label</source>
<translation>Име</translation>
</message>
<message>
<location line="+0"/>
<source>Address</source>
<translation>Адрес</translation>
</message>
<message>
<location line="+36"/>
<source>(no label)</source>
<translation>(без име)</translation>
</message>
</context>
<context>
<name>AskPassphraseDialog</name>
<message>
<location filename="../forms/askpassphrasedialog.ui" line="+26"/>
<source>Passphrase Dialog</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+21"/>
<source>Enter passphrase</source>
<translation>Въведи парола</translation>
</message>
<message>
<location line="+14"/>
<source>New passphrase</source>
<translation>Нова парола</translation>
</message>
<message>
<location line="+14"/>
<source>Repeat new passphrase</source>
<translation>Още веднъж</translation>
</message>
<message>
<location line="+33"/>
<source>Serves to disable the trivial sendmoney when OS account compromised. Provides no real security.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>For staking only</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../askpassphrasedialog.cpp" line="+35"/>
<source>Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>10 or more random characters</b>, or <b>eight or more words</b>.</source>
<translation>Въведете нова парола за портфейла.<br/>Моля използвайте <b>поне 10 случайни символа</b> или <b>8 или повече думи</b>.</translation>
</message>
<message>
<location line="+1"/>
<source>Encrypt wallet</source>
<translation>Криптиране на портфейла</translation>
</message>
<message>
<location line="+7"/>
<source>This operation needs your wallet passphrase to unlock the wallet.</source>
<translation>Тази операция изисква Вашата парола за отключване на портфейла.</translation>
</message>
<message>
<location line="+5"/>
<source>Unlock wallet</source>
<translation>Отключване на портфейла</translation>
</message>
<message>
<location line="+3"/>
<source>This operation needs your wallet passphrase to decrypt the wallet.</source>
<translation>Тази операция изисква Вашата парола за декриптиране на портфейла.</translation>
</message>
<message>
<location line="+5"/>
<source>Decrypt wallet</source>
<translation>Декриптиране на портфейла</translation>
</message>
<message>
<location line="+3"/>
<source>Change passphrase</source>
<translation>Смяна на паролата</translation>
</message>
<message>
<location line="+1"/>
<source>Enter the old and new passphrase to the wallet.</source>
<translation>Въведете текущата и новата парола за портфейла.</translation>
</message>
<message>
<location line="+46"/>
<source>Confirm wallet encryption</source>
<translation>Потвърждаване на криптирането</translation>
</message>
<message>
<location line="+1"/>
<source>Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR COINS</b>!</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>Are you sure you wish to encrypt your wallet?</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+15"/>
<source>IMPORTANT: Any previous backups you have made of your wallet file should be replaced with the newly generated, encrypted wallet file. For security reasons, previous backups of the unencrypted wallet file will become useless as soon as you start using the new, encrypted wallet.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+103"/>
<location line="+24"/>
<source>Warning: The Caps Lock key is on!</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-133"/>
<location line="+60"/>
<source>Wallet encrypted</source>
<translation>Портфейлът е криптиран</translation>
</message>
<message>
<location line="-58"/>
<source>Entrustcoin will close now to finish the encryption process. Remember that encrypting your wallet cannot fully protect your coins from being stolen by malware infecting your computer.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+13"/>
<location line="+7"/>
<location line="+44"/>
<location line="+6"/>
<source>Wallet encryption failed</source>
<translation>Криптирането беше неуспешно</translation>
</message>
<message>
<location line="-56"/>
<source>Wallet encryption failed due to an internal error. Your wallet was not encrypted.</source>
<translation>Криптирането на портфейла беше неуспешно поради неизвестен проблем. Портфейлът не е криптиран.</translation>
</message>
<message>
<location line="+7"/>
<location line="+50"/>
<source>The supplied passphrases do not match.</source>
<translation>Паролите не съвпадат</translation>
</message>
<message>
<location line="-38"/>
<source>Wallet unlock failed</source>
<translation>Отключването беше неуспешно</translation>
</message>
<message>
<location line="+1"/>
<location line="+12"/>
<location line="+19"/>
<source>The passphrase entered for the wallet decryption was incorrect.</source>
<translation>Паролата въведена за декриптиране на портфейла е грешна.</translation>
</message>
<message>
<location line="-20"/>
<source>Wallet decryption failed</source>
<translation>Декриптирането беше неуспешно</translation>
</message>
<message>
<location line="+14"/>
<source>Wallet passphrase was successfully changed.</source>
<translation>Паролата на портфейла беше променена успешно.</translation>
</message>
</context>
<context>
<name>BitcoinGUI</name>
<message>
<location filename="../bitcoingui.cpp" line="+280"/>
<source>Sign &message...</source>
<translation>Подписване на &съобщение...</translation>
</message>
<message>
<location line="+242"/>
<source>Synchronizing with network...</source>
<translation>Синхронизиране с мрежата...</translation>
</message>
<message>
<location line="-308"/>
<source>&Overview</source>
<translation>&Баланс</translation>
</message>
<message>
<location line="+1"/>
<source>Show general overview of wallet</source>
<translation>Обобщена информация за портфейла</translation>
</message>
<message>
<location line="+17"/>
<source>&Transactions</source>
<translation>&Транзакции</translation>
</message>
<message>
<location line="+1"/>
<source>Browse transaction history</source>
<translation>История на транзакциите</translation>
</message>
<message>
<location line="+5"/>
<source>&Address Book</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Edit the list of stored addresses and labels</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-13"/>
<source>&Receive coins</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Show the list of addresses for receiving payments</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-7"/>
<source>&Send coins</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+35"/>
<source>E&xit</source>
<translation>Из&ход</translation>
</message>
<message>
<location line="+1"/>
<source>Quit application</source>
<translation>Изход от приложението</translation>
</message>
<message>
<location line="+4"/>
<source>Show information about Entrustcoin</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>About &Qt</source>
<translation>За &Qt</translation>
</message>
<message>
<location line="+1"/>
<source>Show information about Qt</source>
<translation>Покажи информация за Qt</translation>
</message>
<message>
<location line="+2"/>
<source>&Options...</source>
<translation>&Опции...</translation>
</message>
<message>
<location line="+4"/>
<source>&Encrypt Wallet...</source>
<translation>&Криптиране на портфейла...</translation>
</message>
<message>
<location line="+3"/>
<source>&Backup Wallet...</source>
<translation>&Запазване на портфейла...</translation>
</message>
<message>
<location line="+2"/>
<source>&Change Passphrase...</source>
<translation>&Смяна на паролата...</translation>
</message>
<message numerus="yes">
<location line="+250"/>
<source>~%n block(s) remaining</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message>
<location line="+6"/>
<source>Downloaded %1 of %2 blocks of transaction history (%3% done).</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-247"/>
<source>&Export...</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-62"/>
<source>Send coins to a Entrustcoin address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+45"/>
<source>Modify configuration options for Entrustcoin</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+18"/>
<source>Export the data in the current tab to a file</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-14"/>
<source>Encrypt or decrypt wallet</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Backup wallet to another location</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Change the passphrase used for wallet encryption</source>
<translation>Променя паролата за портфейла</translation>
</message>
<message>
<location line="+10"/>
<source>&Debug window</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Open debugging and diagnostic console</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-5"/>
<source>&Verify message...</source>
<translation>&Проверка на съобщение...</translation>
</message>
<message>
<location line="-200"/>
<source>Entrustcoin</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>Wallet</source>
<translation>Портфейл</translation>
</message>
<message>
<location line="+178"/>
<source>&About Entrustcoin</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+9"/>
<source>&Show / Hide</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+9"/>
<source>Unlock wallet</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>&Lock Wallet</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Lock wallet</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+34"/>
<source>&File</source>
<translation>&Файл</translation>
</message>
<message>
<location line="+8"/>
<source>&Settings</source>
<translation>&Настройки</translation>
</message>
<message>
<location line="+8"/>
<source>&Help</source>
<translation>&Помощ</translation>
</message>
<message>
<location line="+9"/>
<source>Tabs toolbar</source>
<translation>Раздели</translation>
</message>
<message>
<location line="+8"/>
<source>Actions toolbar</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+13"/>
<location line="+9"/>
<source>[testnet]</source>
<translation>[testnet]</translation>
</message>
<message>
<location line="+0"/>
<location line="+60"/>
<source>Entrustcoin client</source>
<translation type="unfinished"/>
</message>
<message numerus="yes">
<location line="+70"/>
<source>%n active connection(s) to Entrustcoin network</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message>
<location line="+40"/>
<source>Downloaded %1 blocks of transaction history.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+413"/>
<source>Staking.<br>Your weight is %1<br>Network weight is %2<br>Expected time to earn reward is %3</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+6"/>
<source>Not staking because wallet is locked</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Not staking because wallet is offline</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Not staking because wallet is syncing</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Not staking because you don't have mature coins</source>
<translation type="unfinished"/>
</message>
<message numerus="yes">
<location line="-403"/>
<source>%n second(s) ago</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message>
<location line="-284"/>
<source>&Unlock Wallet...</source>
<translation type="unfinished"/>
</message>
<message numerus="yes">
<location line="+288"/>
<source>%n minute(s) ago</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message numerus="yes">
<location line="+4"/>
<source>%n hour(s) ago</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message numerus="yes">
<location line="+4"/>
<source>%n day(s) ago</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message>
<location line="+6"/>
<source>Up to date</source>
<translation>Синхронизиран</translation>
</message>
<message>
<location line="+7"/>
<source>Catching up...</source>
<translation>Зарежда блокове...</translation>
</message>
<message>
<location line="+10"/>
<source>Last received block was generated %1.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+59"/>
<source>This transaction is over the size limit. You can still send it for a fee of %1, which goes to the nodes that process your transaction and helps to support the network. Do you want to pay the fee?</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+5"/>
<source>Confirm transaction fee</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+27"/>
<source>Sent transaction</source>
<translation>Изходяща транзакция</translation>
</message>
<message>
<location line="+1"/>
<source>Incoming transaction</source>
<translation>Входяща транзакция</translation>
</message>
<message>
<location line="+1"/>
<source>Date: %1
Amount: %2
Type: %3
Address: %4
</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+100"/>
<location line="+15"/>
<source>URI handling</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-15"/>
<location line="+15"/>
<source>URI can not be parsed! This can be caused by an invalid Entrustcoin address or malformed URI parameters.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+18"/>
<source>Wallet is <b>encrypted</b> and currently <b>unlocked</b></source>
<translation>Портфейлът е <b>криптиран</b> и <b>отключен</b></translation>
</message>
<message>
<location line="+10"/>
<source>Wallet is <b>encrypted</b> and currently <b>locked</b></source>
<translation>Портфейлът е <b>криптиран</b> и <b>заключен</b></translation>
</message>
<message>
<location line="+25"/>
<source>Backup Wallet</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>Wallet Data (*.dat)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Backup Failed</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>There was an error trying to save the wallet data to the new location.</source>
<translation type="unfinished"/>
</message>
<message numerus="yes">
<location line="+76"/>
<source>%n second(s)</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message numerus="yes">
<location line="+4"/>
<source>%n minute(s)</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message numerus="yes">
<location line="+4"/>
<source>%n hour(s)</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message numerus="yes">
<location line="+4"/>
<source>%n day(s)</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message>
<location line="+18"/>
<source>Not staking</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../bitcoin.cpp" line="+109"/>
<source>A fatal error occurred. Entrustcoin can no longer continue safely and will quit.</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>ClientModel</name>
<message>
<location filename="../clientmodel.cpp" line="+90"/>
<source>Network Alert</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>CoinControlDialog</name>
<message>
<location filename="../forms/coincontroldialog.ui" line="+14"/>
<source>Coin Control</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+31"/>
<source>Quantity:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+32"/>
<source>Bytes:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+48"/>
<source>Amount:</source>
<translation>Сума:</translation>
</message>
<message>
<location line="+32"/>
<source>Priority:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+48"/>
<source>Fee:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+35"/>
<source>Low Output:</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../coincontroldialog.cpp" line="+551"/>
<source>no</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../forms/coincontroldialog.ui" line="+51"/>
<source>After Fee:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+35"/>
<source>Change:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+69"/>
<source>(un)select all</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+13"/>
<source>Tree mode</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+16"/>
<source>List mode</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+45"/>
<source>Amount</source>
<translation>Сума</translation>
</message>
<message>
<location line="+5"/>
<source>Label</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+5"/>
<source>Address</source>
<translation>Адрес</translation>
</message>
<message>
<location line="+5"/>
<source>Date</source>
<translation>Дата</translation>
</message>
<message>
<location line="+5"/>
<source>Confirmations</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Confirmed</source>
<translation>Потвърдени</translation>
</message>
<message>
<location line="+5"/>
<source>Priority</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../coincontroldialog.cpp" line="-515"/>
<source>Copy address</source>
<translation>Копирай адрес</translation>
</message>
<message>
<location line="+1"/>
<source>Copy label</source>
<translation>Копирай име</translation>
</message>
<message>
<location line="+1"/>
<location line="+26"/>
<source>Copy amount</source>
<translation>Копирай сума</translation>
</message>
<message>
<location line="-25"/>
<source>Copy transaction ID</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+24"/>
<source>Copy quantity</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Copy fee</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Copy after fee</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Copy bytes</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Copy priority</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Copy low output</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Copy change</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+317"/>
<source>highest</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>high</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>medium-high</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>medium</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+4"/>
<source>low-medium</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>low</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>lowest</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+155"/>
<source>DUST</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>yes</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+10"/>
<source>This label turns red, if the transaction size is bigger than 10000 bytes.
This means a fee of at least %1 per kb is required.
Can vary +/- 1 Byte per input.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Transactions with higher priority get more likely into a block.
This label turns red, if the priority is smaller than "medium".
This means a fee of at least %1 per kb is required.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>This label turns red, if any recipient receives an amount smaller than %1.
This means a fee of at least %2 is required.
Amounts below 0.546 times the minimum relay fee are shown as DUST.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>This label turns red, if the change is smaller than %1.
This means a fee of at least %2 is required.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+37"/>
<location line="+66"/>
<source>(no label)</source>
<translation>(без име)</translation>
</message>
<message>
<location line="-9"/>
<source>change from %1 (%2)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>(change)</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>EditAddressDialog</name>
<message>
<location filename="../forms/editaddressdialog.ui" line="+14"/>
<source>Edit Address</source>
<translation>Редактиране на адрес</translation>
</message>
<message>
<location line="+11"/>
<source>&Label</source>
<translation>&Име</translation>
</message>
<message>
<location line="+10"/>
<source>The label associated with this address book entry</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+7"/>
<source>&Address</source>
<translation>&Адрес</translation>
</message>
<message>
<location line="+10"/>
<source>The address associated with this address book entry. This can only be modified for sending addresses.</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../editaddressdialog.cpp" line="+20"/>
<source>New receiving address</source>
<translation>Нов адрес за получаване</translation>
</message>
<message>
<location line="+4"/>
<source>New sending address</source>
<translation>Нов адрес за изпращане</translation>
</message>
<message>
<location line="+3"/>
<source>Edit receiving address</source>
<translation>Редактиране на входящ адрес</translation>
</message>
<message>
<location line="+4"/>
<source>Edit sending address</source>
<translation>Редактиране на изходящ адрес</translation>
</message>
<message>
<location line="+76"/>
<source>The entered address "%1" is already in the address book.</source>
<translation>Вече има адрес "%1" в списъка с адреси.</translation>
</message>
<message>
<location line="-5"/>
<source>The entered address "%1" is not a valid Entrustcoin address.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+10"/>
<source>Could not unlock wallet.</source>
<translation>Отключването на портфейла беше неуспешно.</translation>
</message>
<message>
<location line="+5"/>
<source>New key generation failed.</source>
<translation>Създаването на ключ беше неуспешно.</translation>
</message>
</context>
<context>
<name>GUIUtil::HelpMessageBox</name>
<message>
<location filename="../guiutil.cpp" line="+420"/>
<location line="+12"/>
<source>Entrustcoin-Qt</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-12"/>
<source>version</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Usage:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>command-line options</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+4"/>
<source>UI options</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Set language, for example "de_DE" (default: system locale)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Start minimized</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Show splash screen on startup (default: 1)</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>OptionsDialog</name>
<message>
<location filename="../forms/optionsdialog.ui" line="+14"/>
<source>Options</source>
<translation>Опции</translation>
</message>
<message>
<location line="+16"/>
<source>&Main</source>
<translation>&Основни</translation>
</message>
<message>
<location line="+6"/>
<source>Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB. Fee 0.01 recommended.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+15"/>
<source>Pay transaction &fee</source>
<translation>&Такса за изходяща транзакция</translation>
</message>
<message>
<location line="+31"/>
<source>Reserved amount does not participate in staking and is therefore spendable at any time.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+15"/>
<source>Reserve</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+31"/>
<source>Automatically start Entrustcoin after logging in to the system.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>&Start Entrustcoin on system login</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+7"/>
<source>Detach block and address databases at shutdown. This means they can be moved to another data directory, but it slows down shutdown. The wallet is always detached.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>&Detach databases at shutdown</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+21"/>
<source>&Network</source>
<translation>&Мрежа</translation>
</message>
<message>
<location line="+6"/>
<source>Automatically open the Entrustcoin client port on the router. This only works when your router supports UPnP and it is enabled.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Map port using &UPnP</source>
<translation>Отваряне на входящия порт чрез &UPnP</translation>
</message>
<message>
<location line="+7"/>
<source>Connect to the Entrustcoin network through a SOCKS proxy (e.g. when connecting through Tor).</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>&Connect through SOCKS proxy:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+9"/>
<source>Proxy &IP:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+19"/>
<source>IP address of the proxy (e.g. 127.0.0.1)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+7"/>
<source>&Port:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+19"/>
<source>Port of the proxy (e.g. 9050)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+7"/>
<source>SOCKS &Version:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+13"/>
<source>SOCKS version of the proxy (e.g. 5)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+36"/>
<source>&Window</source>
<translation>&Прозорец</translation>
</message>
<message>
<location line="+6"/>
<source>Show only a tray icon after minimizing the window.</source>
<translation>След минимизиране ще е видима само иконата в системния трей.</translation>
</message>
<message>
<location line="+3"/>
<source>&Minimize to the tray instead of the taskbar</source>
<translation>&Минимизиране в системния трей</translation>
</message>
<message>
<location line="+7"/>
<source>Minimize instead of exit the application when the window is closed. When this option is enabled, the application will be closed only after selecting Quit in the menu.</source>
<translation>При затваряне на прозореца приложението остава минимизирано. Ако изберете тази опция, приложението може да се затвори само чрез Изход в менюто.</translation>
</message>
<message>
<location line="+3"/>
<source>M&inimize on close</source>
<translation>М&инимизиране при затваряне</translation>
</message>
<message>
<location line="+21"/>
<source>&Display</source>
<translation>&Интерфейс</translation>
</message>
<message>
<location line="+8"/>
<source>User Interface &language:</source>
<translation>Език:</translation>
</message>
<message>
<location line="+13"/>
<source>The user interface language can be set here. This setting will take effect after restarting Entrustcoin.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+11"/>
<source>&Unit to show amounts in:</source>
<translation>Мерни единици:</translation>
</message>
<message>
<location line="+13"/>
<source>Choose the default subdivision unit to show in the interface and when sending coins.</source>
<translation>Изберете единиците, показвани по подразбиране в интерфейса.</translation>
</message>
<message>
<location line="+9"/>
<source>Whether to show Entrustcoin addresses in the transaction list or not.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>&Display addresses in transaction list</source>
<translation>Показвай и адресите в списъка с транзакции</translation>
</message>
<message>
<location line="+7"/>
<source>Whether to show coin control features or not.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Display coin &control features (experts only!)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+71"/>
<source>&OK</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+7"/>
<source>&Cancel</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+10"/>
<source>&Apply</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../optionsdialog.cpp" line="+55"/>
<source>default</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+149"/>
<location line="+9"/>
<source>Warning</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-9"/>
<location line="+9"/>
<source>This setting will take effect after restarting Entrustcoin.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+29"/>
<source>The supplied proxy address is invalid.</source>
<translation>Прокси адресът е невалиден.</translation>
</message>
</context>
<context>
<name>OverviewPage</name>
<message>
<location filename="../forms/overviewpage.ui" line="+14"/>
<source>Form</source>
<translation>Форма</translation>
</message>
<message>
<location line="+33"/>
<location line="+231"/>
<source>The displayed information may be out of date. Your wallet automatically synchronizes with the Entrustcoin network after a connection is established, but this process has not completed yet.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-160"/>
<source>Stake:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+29"/>
<source>Unconfirmed:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-107"/>
<source>Wallet</source>
<translation>Портфейл</translation>
</message>
<message>
<location line="+49"/>
<source>Spendable:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+16"/>
<source>Your current spendable balance</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+71"/>
<source>Immature:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+13"/>
<source>Mined balance that has not yet matured</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+20"/>
<source>Total:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+16"/>
<source>Your current total balance</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+46"/>
<source><b>Recent transactions</b></source>
<translation><b>Последни транзакции</b></translation>
</message>
<message>
<location line="-108"/>
<source>Total of transactions that have yet to be confirmed, and do not yet count toward the current balance</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-29"/>
<source>Total of coins that was staked, and do not yet count toward the current balance</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../overviewpage.cpp" line="+113"/>
<location line="+1"/>
<source>out of sync</source>
<translation>несинхронизиран</translation>
</message>
</context>
<context>
<name>QRCodeDialog</name>
<message>
<location filename="../forms/qrcodedialog.ui" line="+14"/>
<source>QR Code Dialog</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+59"/>
<source>Request Payment</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+56"/>
<source>Amount:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-44"/>
<source>Label:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+19"/>
<source>Message:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+71"/>
<source>&Save As...</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../qrcodedialog.cpp" line="+62"/>
<source>Error encoding URI into QR Code.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+40"/>
<source>The entered amount is invalid, please check.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+23"/>
<source>Resulting URI too long, try to reduce the text for label / message.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+25"/>
<source>Save QR Code</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>PNG Images (*.png)</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>RPCConsole</name>
<message>
<location filename="../forms/rpcconsole.ui" line="+46"/>
<source>Client name</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+10"/>
<location line="+23"/>
<location line="+26"/>
<location line="+23"/>
<location line="+23"/>
<location line="+36"/>
<location line="+53"/>
<location line="+23"/>
<location line="+23"/>
<location filename="../rpcconsole.cpp" line="+348"/>
<source>N/A</source>
<translation>N/A</translation>
</message>
<message>
<location line="-217"/>
<source>Client version</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-45"/>
<source>&Information</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+68"/>
<source>Using OpenSSL version</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+49"/>
<source>Startup time</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+29"/>
<source>Network</source>
<translation>Мрежа</translation>
</message>
<message>
<location line="+7"/>
<source>Number of connections</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+23"/>
<source>On testnet</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+23"/>
<source>Block chain</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+7"/>
<source>Current number of blocks</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+23"/>
<source>Estimated total blocks</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+23"/>
<source>Last block time</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+52"/>
<source>&Open</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+16"/>
<source>Command-line options</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+7"/>
<source>Show the Entrustcoin-Qt help message to get a list with possible Entrustcoin command-line options.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>&Show</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+24"/>
<source>&Console</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-260"/>
<source>Build date</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-104"/>
<source>Entrustcoin - Debug window</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+25"/>
<source>Entrustcoin Core</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+279"/>
<source>Debug log file</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+7"/>
<source>Open the Entrustcoin debug log file from the current data directory. This can take a few seconds for large log files.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+102"/>
<source>Clear console</source>
<translation>Изчисти конзолата</translation>
</message>
<message>
<location filename="../rpcconsole.cpp" line="-33"/>
<source>Welcome to the Entrustcoin RPC console.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Use up and down arrows to navigate history, and <b>Ctrl-L</b> to clear screen.</source>
<translation>Използвайте стрелки надолу и нагореза разглеждане на историятаот команди и <b>Ctrl-L</b> за изчистване на конзолата.</translation>
</message>
<message>
<location line="+1"/>
<source>Type <b>help</b> for an overview of available commands.</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>SendCoinsDialog</name>
<message>
<location filename="../forms/sendcoinsdialog.ui" line="+14"/>
<location filename="../sendcoinsdialog.cpp" line="+182"/>
<location line="+5"/>
<location line="+5"/>
<location line="+5"/>
<location line="+6"/>
<location line="+5"/>
<location line="+5"/>
<source>Send Coins</source>
<translation>Изпращане</translation>
</message>
<message>
<location line="+76"/>
<source>Coin Control Features</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+20"/>
<source>Inputs...</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+7"/>
<source>automatically selected</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+19"/>
<source>Insufficient funds!</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+77"/>
<source>Quantity:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+22"/>
<location line="+35"/>
<source>0</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-19"/>
<source>Bytes:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+51"/>
<source>Amount:</source>
<translation>Сума:</translation>
</message>
<message>
<location line="+22"/>
<location line="+86"/>
<location line="+86"/>
<location line="+32"/>
<source>0.00 eTRUST</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-191"/>
<source>Priority:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+19"/>
<source>medium</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+32"/>
<source>Fee:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+35"/>
<source>Low Output:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+19"/>
<source>no</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+32"/>
<source>After Fee:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+35"/>
<source>Change</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+50"/>
<source>custom change address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+106"/>
<source>Send to multiple recipients at once</source>
<translation>Изпращане към повече от един получател</translation>
</message>
<message>
<location line="+3"/>
<source>Add &Recipient</source>
<translation>Добави &получател</translation>
</message>
<message>
<location line="+20"/>
<source>Remove all transaction fields</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Clear &All</source>
<translation>&Изчисти</translation>
</message>
<message>
<location line="+28"/>
<source>Balance:</source>
<translation>Баланс:</translation>
</message>
<message>
<location line="+16"/>
<source>123.456 eTRUST</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+31"/>
<source>Confirm the send action</source>
<translation>Потвърдете изпращането</translation>
</message>
<message>
<location line="+3"/>
<source>S&end</source>
<translation>И&зпрати</translation>
</message>
<message>
<location filename="../sendcoinsdialog.cpp" line="-173"/>
<source>Enter a Entrustcoin address (e.g. SXywGBZBowrppUwwNUo1GCRDTibzJi7g2M)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+15"/>
<source>Copy quantity</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Copy amount</source>
<translation>Копирай сума</translation>
</message>
<message>
<location line="+1"/>
<source>Copy fee</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Copy after fee</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Copy bytes</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Copy priority</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Copy low output</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Copy change</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+86"/>
<source><b>%1</b> to %2 (%3)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+5"/>
<source>Confirm send coins</source>
<translation>Потвърждаване</translation>
</message>
<message>
<location line="+1"/>
<source>Are you sure you want to send %1?</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source> and </source>
<translation type="unfinished"/>
</message>
<message>
<location line="+29"/>
<source>The recipient address is not valid, please recheck.</source>
<translation>Невалиден адрес на получателя.</translation>
</message>
<message>
<location line="+5"/>
<source>The amount to pay must be larger than 0.</source>
<translation>Сумата трябва да е по-голяма от 0.</translation>
</message>
<message>
<location line="+5"/>
<source>The amount exceeds your balance.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+5"/>
<source>The total exceeds your balance when the %1 transaction fee is included.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+6"/>
<source>Duplicate address found, can only send to each address once per send operation.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+5"/>
<source>Error: Transaction creation failed.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+5"/>
<source>Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+251"/>
<source>WARNING: Invalid Entrustcoin address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+13"/>
<source>(no label)</source>
<translation>(без име)</translation>
</message>
<message>
<location line="+4"/>
<source>WARNING: unknown change address</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>SendCoinsEntry</name>
<message>
<location filename="../forms/sendcoinsentry.ui" line="+14"/>
<source>Form</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+15"/>
<source>A&mount:</source>
<translation>С&ума:</translation>
</message>
<message>
<location line="+13"/>
<source>Pay &To:</source>
<translation>Плати &На:</translation>
</message>
<message>
<location line="+24"/>
<location filename="../sendcoinsentry.cpp" line="+25"/>
<source>Enter a label for this address to add it to your address book</source>
<translation>Въведете име за този адрес, за да го добавите в списъка с адреси</translation>
</message>
<message>
<location line="+9"/>
<source>&Label:</source>
<translation>&Име:</translation>
</message>
<message>
<location line="+18"/>
<source>The address to send the payment to (e.g. SXywGBZBowrppUwwNUo1GCRDTibzJi7g2M)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+10"/>
<source>Choose address from address book</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+10"/>
<source>Alt+A</source>
<translation>Alt+A</translation>
</message>
<message>
<location line="+7"/>
<source>Paste address from clipboard</source>
<translation>Вмъкни от клипборда</translation>
</message>
<message>
<location line="+10"/>
<source>Alt+P</source>
<translation>Alt+P</translation>
</message>
<message>
<location line="+7"/>
<source>Remove this recipient</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../sendcoinsentry.cpp" line="+1"/>
<source>Enter a Entrustcoin address (e.g. SXywGBZBowrppUwwNUo1GCRDTibzJi7g2M)</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>SignVerifyMessageDialog</name>
<message>
<location filename="../forms/signverifymessagedialog.ui" line="+14"/>
<source>Signatures - Sign / Verify a Message</source>
<translation>Подпиши / Провери съобщение</translation>
</message>
<message>
<location line="+13"/>
<location line="+124"/>
<source>&Sign Message</source>
<translation>&Подпиши</translation>
</message>
<message>
<location line="-118"/>
<source>You can sign messages with your addresses to prove you own them. Be careful not to sign anything vague, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to.</source>
<translation>Можете да подпишете съобщение като доказателство, че притежавате определен адрес. Бъдете внимателни и не подписвайте съобщения, които биха разкрили лична информация без вашето съгласие.</translation>
</message>
<message>
<location line="+18"/>
<source>The address to sign the message with (e.g. SXywGBZBowrppUwwNUo1GCRDTibzJi7g2M)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+10"/>
<location line="+203"/>
<source>Choose an address from the address book</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-193"/>
<location line="+203"/>
<source>Alt+A</source>
<translation>Alt+A</translation>
</message>
<message>
<location line="-193"/>
<source>Paste address from clipboard</source>
<translation>Вмъкни от клипборда</translation>
</message>
<message>
<location line="+10"/>
<source>Alt+P</source>
<translation>Alt+P</translation>
</message>
<message>
<location line="+12"/>
<source>Enter the message you want to sign here</source>
<translation>Въведете съобщението тук</translation>
</message>
<message>
<location line="+24"/>
<source>Copy the current signature to the system clipboard</source>
<translation>Копиране на текущия подпис</translation>
</message>
<message>
<location line="+21"/>
<source>Sign the message to prove you own this Entrustcoin address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+17"/>
<source>Reset all sign message fields</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<location line="+146"/>
<source>Clear &All</source>
<translation>&Изчисти</translation>
</message>
<message>
<location line="-87"/>
<location line="+70"/>
<source>&Verify Message</source>
<translation>&Провери</translation>
</message>
<message>
<location line="-64"/>
<source>Enter the signing address, message (ensure you copy line breaks, spaces, tabs, etc. exactly) and signature below to verify the message. Be careful not to read more into the signature than what is in the signed message itself, to avoid being tricked by a man-in-the-middle attack.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+21"/>
<source>The address the message was signed with (e.g. SXywGBZBowrppUwwNUo1GCRDTibzJi7g2M)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+40"/>
<source>Verify the message to ensure it was signed with the specified Entrustcoin address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+17"/>
<source>Reset all verify message fields</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../signverifymessagedialog.cpp" line="+27"/>
<location line="+3"/>
<source>Enter a Entrustcoin address (e.g. SXywGBZBowrppUwwNUo1GCRDTibzJi7g2M)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-2"/>
<source>Click "Sign Message" to generate signature</source>
<translation>Натиснете "Подписване на съобщение" за да създадете подпис</translation>
</message>
<message>
<location line="+3"/>
<source>Enter Entrustcoin signature</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+82"/>
<location line="+81"/>
<source>The entered address is invalid.</source>
<translation>Въведеният адрес е невалиден.</translation>
</message>
<message>
<location line="-81"/>
<location line="+8"/>
<location line="+73"/>
<location line="+8"/>
<source>Please check the address and try again.</source>
<translation>Моля проверете адреса и опитайте отново.</translation>
</message>
<message>
<location line="-81"/>
<location line="+81"/>
<source>The entered address does not refer to a key.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-73"/>
<source>Wallet unlock was cancelled.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+8"/>
<source>Private key for the entered address is not available.</source>
<translation>Не е наличен частният ключ за въведеният адрес.</translation>
</message>
<message>
<location line="+12"/>
<source>Message signing failed.</source>
<translation>Подписването на съобщение бе неуспешно.</translation>
</message>
<message>
<location line="+5"/>
<source>Message signed.</source>
<translation>Съобщението е подписано.</translation>
</message>
<message>
<location line="+59"/>
<source>The signature could not be decoded.</source>
<translation>Подписът не може да бъде декодиран.</translation>
</message>
<message>
<location line="+0"/>
<location line="+13"/>
<source>Please check the signature and try again.</source>
<translation>Проверете подписа и опитайте отново.</translation>
</message>
<message>
<location line="+0"/>
<source>The signature did not match the message digest.</source>
<translation>Подписът не отговаря на комбинацията от съобщение и адрес.</translation>
</message>
<message>
<location line="+7"/>
<source>Message verification failed.</source>
<translation>Проверката на съобщението беше неуспешна.</translation>
</message>
<message>
<location line="+5"/>
<source>Message verified.</source>
<translation>Съобщението е потвърдено.</translation>
</message>
</context>
<context>
<name>TransactionDesc</name>
<message>
<location filename="../transactiondesc.cpp" line="+19"/>
<source>Open until %1</source>
<translation>Подлежи на промяна до %1</translation>
</message>
<message numerus="yes">
<location line="-2"/>
<source>Open for %n block(s)</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message>
<location line="+8"/>
<source>conflicted</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>%1/offline</source>
<translation>%1/офлайн</translation>
</message>
<message>
<location line="+2"/>
<source>%1/unconfirmed</source>
<translation>%1/непотвърдени</translation>
</message>
<message>
<location line="+2"/>
<source>%1 confirmations</source>
<translation>включена в %1 блока</translation>
</message>
<message>
<location line="+18"/>
<source>Status</source>
<translation>Статус</translation>
</message>
<message numerus="yes">
<location line="+7"/>
<source>, broadcast through %n node(s)</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message>
<location line="+4"/>
<source>Date</source>
<translation>Дата</translation>
</message>
<message>
<location line="+7"/>
<source>Source</source>
<translation>Източник</translation>
</message>
<message>
<location line="+0"/>
<source>Generated</source>
<translation>Издадени</translation>
</message>
<message>
<location line="+5"/>
<location line="+17"/>
<source>From</source>
<translation>От</translation>
</message>
<message>
<location line="+1"/>
<location line="+22"/>
<location line="+58"/>
<source>To</source>
<translation>За</translation>
</message>
<message>
<location line="-77"/>
<location line="+2"/>
<source>own address</source>
<translation>собствен адрес</translation>
</message>
<message>
<location line="-2"/>
<source>label</source>
<translation>име</translation>
</message>
<message>
<location line="+37"/>
<location line="+12"/>
<location line="+45"/>
<location line="+17"/>
<location line="+30"/>
<source>Credit</source>
<translation>Кредит</translation>
</message>
<message numerus="yes">
<location line="-102"/>
<source>matures in %n more block(s)</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message>
<location line="+2"/>
<source>not accepted</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+44"/>
<location line="+8"/>
<location line="+15"/>
<location line="+30"/>
<source>Debit</source>
<translation>Дебит</translation>
</message>
<message>
<location line="-39"/>
<source>Transaction fee</source>
<translation>Такса</translation>
</message>
<message>
<location line="+16"/>
<source>Net amount</source>
<translation>Сума нето</translation>
</message>
<message>
<location line="+6"/>
<source>Message</source>
<translation>Съобщение</translation>
</message>
<message>
<location line="+2"/>
<source>Comment</source>
<translation>Коментар</translation>
</message>
<message>
<location line="+2"/>
<source>Transaction ID</source>
<translation>ID</translation>
</message>
<message>
<location line="+3"/>
<source>Generated coins must mature 510 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to "not accepted" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+7"/>
<source>Debug information</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+8"/>
<source>Transaction</source>
<translation>Транзакция</translation>
</message>
<message>
<location line="+5"/>
<source>Inputs</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+23"/>
<source>Amount</source>
<translation>Сума</translation>
</message>
<message>
<location line="+1"/>
<source>true</source>
<translation>true</translation>
</message>
<message>
<location line="+0"/>
<source>false</source>
<translation>false</translation>
</message>
<message>
<location line="-211"/>
<source>, has not been successfully broadcast yet</source>
<translation>, все още не е изпратено</translation>
</message>
<message>
<location line="+35"/>
<source>unknown</source>
<translation>неизвестен</translation>
</message>
</context>
<context>
<name>TransactionDescDialog</name>
<message>
<location filename="../forms/transactiondescdialog.ui" line="+14"/>
<source>Transaction details</source>
<translation>Транзакция</translation>
</message>
<message>
<location line="+6"/>
<source>This pane shows a detailed description of the transaction</source>
<translation>Описание на транзакцията</translation>
</message>
</context>
<context>
<name>TransactionTableModel</name>
<message>
<location filename="../transactiontablemodel.cpp" line="+226"/>
<source>Date</source>
<translation>Дата</translation>
</message>
<message>
<location line="+0"/>
<source>Type</source>
<translation>Тип</translation>
</message>
<message>
<location line="+0"/>
<source>Address</source>
<translation>Адрес</translation>
</message>
<message>
<location line="+0"/>
<source>Amount</source>
<translation>Сума</translation>
</message>
<message>
<location line="+60"/>
<source>Open until %1</source>
<translation>Подлежи на промяна до %1</translation>
</message>
<message>
<location line="+12"/>
<source>Confirmed (%1 confirmations)</source>
<translation>Потвърдени (%1 потвърждения)</translation>
</message>
<message numerus="yes">
<location line="-15"/>
<source>Open for %n more block(s)</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message>
<location line="+6"/>
<source>Offline</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Unconfirmed</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Confirming (%1 of %2 recommended confirmations)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+6"/>
<source>Conflicted</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Immature (%1 confirmations, will be available after %2)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>This block was not received by any other nodes and will probably not be accepted!</source>
<translation>Блокът не е получен от останалите участници и най-вероятно няма да бъде одобрен.</translation>
</message>
<message>
<location line="+3"/>
<source>Generated but not accepted</source>
<translation>Генерирана, но отхвърлена от мрежата</translation>
</message>
<message>
<location line="+42"/>
<source>Received with</source>
<translation>Получени с</translation>
</message>
<message>
<location line="+2"/>
<source>Received from</source>
<translation>Получен от</translation>
</message>
<message>
<location line="+3"/>
<source>Sent to</source>
<translation>Изпратени на</translation>
</message>
<message>
<location line="+2"/>
<source>Payment to yourself</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Mined</source>
<translation>Емитирани</translation>
</message>
<message>
<location line="+38"/>
<source>(n/a)</source>
<translation>(n/a)</translation>
</message>
<message>
<location line="+190"/>
<source>Transaction status. Hover over this field to show number of confirmations.</source>
<translation>Състояние на транзакцията. Задръжте върху това поле за брой потвърждения.</translation>
</message>
<message>
<location line="+2"/>
<source>Date and time that the transaction was received.</source>
<translation>Дата и час на получаване.</translation>
</message>
<message>
<location line="+2"/>
<source>Type of transaction.</source>
<translation>Тип на транзакцията.</translation>
</message>
<message>
<location line="+2"/>
<source>Destination address of transaction.</source>
<translation>Получател на транзакцията.</translation>
</message>
<message>
<location line="+2"/>
<source>Amount removed from or added to balance.</source>
<translation>Сума извадена или добавена към баланса.</translation>
</message>
</context>
<context>
<name>TransactionView</name>
<message>
<location filename="../transactionview.cpp" line="+55"/>
<location line="+16"/>
<source>All</source>
<translation>Всички</translation>
</message>
<message>
<location line="-15"/>
<source>Today</source>
<translation>Днес</translation>
</message>
<message>
<location line="+1"/>
<source>This week</source>
<translation>Тази седмица</translation>
</message>
<message>
<location line="+1"/>
<source>This month</source>
<translation>Този месец</translation>
</message>
<message>
<location line="+1"/>
<source>Last month</source>
<translation>Предния месец</translation>
</message>
<message>
<location line="+1"/>
<source>This year</source>
<translation>Тази година</translation>
</message>
<message>
<location line="+1"/>
<source>Range...</source>
<translation>От - до...</translation>
</message>
<message>
<location line="+11"/>
<source>Received with</source>
<translation>Получени</translation>
</message>
<message>
<location line="+2"/>
<source>Sent to</source>
<translation>Изпратени на</translation>
</message>
<message>
<location line="+2"/>
<source>To yourself</source>
<translation>Собствени</translation>
</message>
<message>
<location line="+1"/>
<source>Mined</source>
<translation>Емитирани</translation>
</message>
<message>
<location line="+1"/>
<source>Other</source>
<translation>Други</translation>
</message>
<message>
<location line="+7"/>
<source>Enter address or label to search</source>
<translation>Търсене по адрес или име</translation>
</message>
<message>
<location line="+7"/>
<source>Min amount</source>
<translation>Минимална сума</translation>
</message>
<message>
<location line="+34"/>
<source>Copy address</source>
<translation>Копирай адрес</translation>
</message>
<message>
<location line="+1"/>
<source>Copy label</source>
<translation>Копирай име</translation>
</message>
<message>
<location line="+1"/>
<source>Copy amount</source>
<translation>Копирай сума</translation>
</message>
<message>
<location line="+1"/>
<source>Copy transaction ID</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Edit label</source>
<translation>Редактирай име</translation>
</message>
<message>
<location line="+1"/>
<source>Show transaction details</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+144"/>
<source>Export Transaction Data</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Comma separated file (*.csv)</source>
<translation>CSV файл (*.csv)</translation>
</message>
<message>
<location line="+8"/>
<source>Confirmed</source>
<translation>Потвърдени</translation>
</message>
<message>
<location line="+1"/>
<source>Date</source>
<translation>Дата</translation>
</message>
<message>
<location line="+1"/>
<source>Type</source>
<translation>Тип</translation>
</message>
<message>
<location line="+1"/>
<source>Label</source>
<translation>Име</translation>
</message>
<message>
<location line="+1"/>
<source>Address</source>
<translation>Адрес</translation>
</message>
<message>
<location line="+1"/>
<source>Amount</source>
<translation>Сума</translation>
</message>
<message>
<location line="+1"/>
<source>ID</source>
<translation>ИД</translation>
</message>
<message>
<location line="+4"/>
<source>Error exporting</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>Could not write to file %1.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+100"/>
<source>Range:</source>
<translation>От:</translation>
</message>
<message>
<location line="+8"/>
<source>to</source>
<translation>до</translation>
</message>
</context>
<context>
<name>WalletModel</name>
<message>
<location filename="../walletmodel.cpp" line="+206"/>
<source>Sending...</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>bitcoin-core</name>
<message>
<location filename="../bitcoinstrings.cpp" line="+33"/>
<source>Entrustcoin version</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Usage:</source>
<translation>Използване:</translation>
</message>
<message>
<location line="+1"/>
<source>Send command to -server or entrustcoind</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>List commands</source>
<translation>Вписване на команди</translation>
</message>
<message>
<location line="+1"/>
<source>Get help for a command</source>
<translation>Получете помощ за команда</translation>
</message>
<message>
<location line="+2"/>
<source>Options:</source>
<translation>Опции:</translation>
</message>
<message>
<location line="+2"/>
<source>Specify configuration file (default: entrustcoin.conf)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Specify pid file (default: entrustcoind.pid)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Specify wallet file (within data directory)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-1"/>
<source>Specify data directory</source>
<translation>Определете директория за данните</translation>
</message>
<message>
<location line="+2"/>
<source>Set database cache size in megabytes (default: 25)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Set database disk log size in megabytes (default: 100)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+6"/>
<source>Listen for connections on <port> (default: 51737 or testnet: 51997)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Maintain at most <n> connections to peers (default: 125)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Connect to a node to retrieve peer addresses, and disconnect</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Specify your own public address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+5"/>
<source>Bind to given address. Use [host]:port notation for IPv6</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Stake your coins to support network and gain reward (default: 1)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+5"/>
<source>Threshold for disconnecting misbehaving peers (default: 100)</source>
<translation>Праг на прекъсване на връзката при непорядъчно държащи се пиъри (по подразбиране:100)</translation>
</message>
<message>
<location line="+1"/>
<source>Number of seconds to keep misbehaving peers from reconnecting (default: 86400)</source>
<translation>Брой секунди до възтановяване на връзката за зле държащите се пиъри (по подразбиране:86400)</translation>
</message>
<message>
<location line="-44"/>
<source>An error occurred while setting up the RPC port %u for listening on IPv4: %s</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+51"/>
<source>Detach block and address databases. Increases shutdown time (default: 0)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+109"/>
<source>Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-5"/>
<source>Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds </source>
<translation type="unfinished"/>
</message>
<message>
<location line="-87"/>
<source>Listen for JSON-RPC connections on <port> (default: 51736 or testnet: 51996)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-11"/>
<source>Accept command line and JSON-RPC commands</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+101"/>
<source>Error: Transaction creation failed </source>
<translation type="unfinished"/>
</message>
<message>
<location line="-5"/>
<source>Error: Wallet locked, unable to create transaction </source>
<translation type="unfinished"/>
</message>
<message>
<location line="-8"/>
<source>Importing blockchain data file.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Importing bootstrap blockchain data file.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-88"/>
<source>Run in the background as a daemon and accept commands</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Use the test network</source>
<translation>Използвайте тестовата мрежа</translation>
</message>
<message>
<location line="-24"/>
<source>Accept connections from outside (default: 1 if no -proxy or -connect)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-38"/>
<source>An error occurred while setting up the RPC port %u for listening on IPv6, falling back to IPv4: %s</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+117"/>
<source>Error initializing database environment %s! To recover, BACKUP THAT DIRECTORY, then remove everything from it except for wallet.dat.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-20"/>
<source>Set maximum size of high-priority/low-fee transactions in bytes (default: 27000)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+11"/>
<source>Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+61"/>
<source>Warning: Please check that your computer's date and time are correct! If your clock is wrong Entrustcoin will not work properly.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-31"/>
<source>Warning: error reading wallet.dat! All keys read correctly, but transaction data or address book entries might be missing or incorrect.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-18"/>
<source>Warning: wallet.dat corrupt, data salvaged! Original wallet.dat saved as wallet.{timestamp}.bak in %s; if your balance or transactions are incorrect you should restore from a backup.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-30"/>
<source>Attempt to recover private keys from a corrupt wallet.dat</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+4"/>
<source>Block creation options:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-62"/>
<source>Connect only to the specified node(s)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+4"/>
<source>Discover own IP address (default: 1 when listening and no -externalip)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+94"/>
<source>Failed to listen on any port. Use -listen=0 if you want this.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-90"/>
<source>Find peers using DNS lookup (default: 1)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+5"/>
<source>Sync checkpoints policy (default: strict)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+83"/>
<source>Invalid -tor address: '%s'</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+4"/>
<source>Invalid amount for -reservebalance=<amount></source>
<translation type="unfinished"/>
</message>
<message>
<location line="-82"/>
<source>Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Maximum per-connection send buffer, <n>*1000 bytes (default: 1000)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-16"/>
<source>Only connect to nodes in network <net> (IPv4, IPv6 or Tor)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+28"/>
<source>Output extra debugging information. Implies all other -debug* options</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Output extra network debugging information</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Prepend debug output with timestamp</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+35"/>
<source>SSL options: (see the Bitcoin Wiki for SSL setup instructions)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-74"/>
<source>Select the version of socks proxy to use (4-5, default: 5)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+41"/>
<source>Send trace/debug info to console instead of debug.log file</source>
<translation>Изпрати локализиращата или дебъг информацията към конзолата, вместо файлът debug.log</translation>
</message>
<message>
<location line="+1"/>
<source>Send trace/debug info to debugger</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+28"/>
<source>Set maximum block size in bytes (default: 250000)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-1"/>
<source>Set minimum block size in bytes (default: 0)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-29"/>
<source>Shrink debug.log file on client startup (default: 1 when no -debug)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-42"/>
<source>Specify connection timeout in milliseconds (default: 5000)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+109"/>
<source>Unable to sign checkpoint, wrong checkpointkey?
</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-80"/>
<source>Use UPnP to map the listening port (default: 0)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-1"/>
<source>Use UPnP to map the listening port (default: 1 when listening)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-25"/>
<source>Use proxy to reach tor hidden services (default: same as -proxy)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+42"/>
<source>Username for JSON-RPC connections</source>
<translation>Потребителско име за JSON-RPC връзките</translation>
</message>
<message>
<location line="+47"/>
<source>Verifying database integrity...</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+57"/>
<source>WARNING: syncronized checkpoint violation detected, but skipped!</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Warning: Disk space is low!</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-2"/>
<source>Warning: This version is obsolete, upgrade required!</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-48"/>
<source>wallet.dat corrupt, salvage failed</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-54"/>
<source>Password for JSON-RPC connections</source>
<translation>Парола за JSON-RPC връзките</translation>
</message>
<message>
<location line="-84"/>
<source>%s, you must set a rpcpassword in the configuration file:
%s
It is recommended you use the following random password:
rpcuser=entrustcoinrpc
rpcpassword=%s
(you do not need to remember this password)
The username and password MUST NOT be the same.
If the file does not exist, create it with owner-readable-only file permissions.
It is also recommended to set alertnotify so you are notified of problems;
for example: alertnotify=echo %%s | mail -s "Entrustcoin Alert" admin@foo.com
</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+51"/>
<source>Find peers using internet relay chat (default: 0)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+5"/>
<source>Sync time with other nodes. Disable if time on your system is precise e.g. syncing with NTP (default: 1)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+15"/>
<source>When creating transactions, ignore inputs with value less than this (default: 0.01)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+16"/>
<source>Allow JSON-RPC connections from specified IP address</source>
<translation>Разреши JSON-RPC връзките от отучнен IP адрес</translation>
</message>
<message>
<location line="+1"/>
<source>Send commands to node running on <ip> (default: 127.0.0.1)</source>
<translation>Изпрати команди до възел функциониращ на <ip> (По подразбиране: 127.0.0.1)</translation>
</message>
<message>
<location line="+1"/>
<source>Execute command when the best block changes (%s in cmd is replaced by block hash)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Require a confirmations for change (default: 0)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Enforce transaction scripts to use canonical PUSH operators (default: 1)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Execute command when a relevant alert is received (%s in cmd is replaced by message)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Upgrade wallet to latest format</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Set key pool size to <n> (default: 100)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Rescan the block chain for missing wallet transactions</source>
<translation>Повторно сканиране на блок-връзка за липсващи портефейлни транзакции</translation>
</message>
<message>
<location line="+2"/>
<source>How many blocks to check at startup (default: 2500, 0 = all)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>How thorough the block verification is (0-6, default: 1)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Imports blocks from external blk000?.dat file</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+8"/>
<source>Use OpenSSL (https) for JSON-RPC connections</source>
<translation>Използвайте OpenSSL (https) за JSON-RPC връзките</translation>
</message>
<message>
<location line="+1"/>
<source>Server certificate file (default: server.cert)</source>
<translation>Сертификатен файл на сървъра (По подразбиране:server.cert)</translation>
</message>
<message>
<location line="+1"/>
<source>Server private key (default: server.pem)</source>
<translation>Поверителен ключ за сървъра (default: server.pem)</translation>
</message>
<message>
<location line="+1"/>
<source>Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+53"/>
<source>Error: Wallet unlocked for staking only, unable to create transaction.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+18"/>
<source>WARNING: Invalid checkpoint found! Displayed transactions may not be correct! You may need to upgrade, or notify developers.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-158"/>
<source>This help message</source>
<translation>Това помощно съобщение</translation>
</message>
<message>
<location line="+95"/>
<source>Wallet %s resides outside data directory %s.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Cannot obtain a lock on data directory %s. Entrustcoin is probably already running.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-98"/>
<source>Entrustcoin</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+140"/>
<source>Unable to bind to %s on this computer (bind returned error %d, %s)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-130"/>
<source>Connect through socks proxy</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Allow DNS lookups for -addnode, -seednode and -connect</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+122"/>
<source>Loading addresses...</source>
<translation>Зареждане на адресите...</translation>
</message>
<message>
<location line="-15"/>
<source>Error loading blkindex.dat</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Error loading wallet.dat: Wallet corrupted</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+4"/>
<source>Error loading wallet.dat: Wallet requires newer version of Entrustcoin</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Wallet needed to be rewritten: restart Entrustcoin to complete</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Error loading wallet.dat</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-16"/>
<source>Invalid -proxy address: '%s'</source>
<translation>Невалиден -proxy address: '%s'</translation>
</message>
<message>
<location line="-1"/>
<source>Unknown network specified in -onlynet: '%s'</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-1"/>
<source>Unknown -socks proxy version requested: %i</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+4"/>
<source>Cannot resolve -bind address: '%s'</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Cannot resolve -externalip address: '%s'</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-24"/>
<source>Invalid amount for -paytxfee=<amount>: '%s'</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+44"/>
<source>Error: could not start node</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+11"/>
<source>Sending...</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+5"/>
<source>Invalid amount</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Insufficient funds</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-34"/>
<source>Loading block index...</source>
<translation>Зареждане на блок индекса...</translation>
</message>
<message>
<location line="-103"/>
<source>Add a node to connect to and attempt to keep the connection open</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+122"/>
<source>Unable to bind to %s on this computer. Entrustcoin is probably already running.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-97"/>
<source>Fee per KB to add to transactions you send</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+55"/>
<source>Invalid amount for -mininput=<amount>: '%s'</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+25"/>
<source>Loading wallet...</source>
<translation>Зареждане на портфейла...</translation>
</message>
<message>
<location line="+8"/>
<source>Cannot downgrade wallet</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Cannot initialize keypool</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Cannot write default address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Rescanning...</source>
<translation>Преразглеждане на последовтелността от блокове...</translation>
</message>
<message>
<location line="+5"/>
<source>Done loading</source>
<translation>Зареждането е завършено</translation>
</message>
<message>
<location line="-167"/>
<source>To use the %s option</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+14"/>
<source>Error</source>
<translation>Грешка</translation>
</message>
<message>
<location line="+6"/>
<source>You must set rpcpassword=<password> in the configuration file:
%s
If the file does not exist, create it with owner-readable-only file permissions.</source>
<translation type="unfinished"/>
</message>
</context>
</TS>
|
entrustcoin/eTRUST
|
src/qt/locale/bitcoin_bg.ts
|
TypeScript
|
mit
| 116,997
|
import chance = require('../../extlibs/wrap_chance');
export class Question {
num: number;
constructor() {
this.num = chance.natural({ min: 20, max: 20000 });
}
get avg() {
return this.num + 0.5;
}
get cans() {
return this.num + 2;
}
get qtxt() {
return `Average of 4 consecutive numbers is ${this.avg}, largest number is `
}
}
|
pskhodad/mathmate-templates
|
src/templates/numericals/q_00006.ts
|
TypeScript
|
mit
| 406
|
# encoding: utf-8
require 'rake'
require 'minitest/autorun'
require 'rake/helpers/unittest'
require 'rake/helpers/string'
class TestString < MiniTest::Unit::TestCase
def test_prepend
assert_equal('prefix_a', 'a'.prepend('prefix_'))
end
def test_starts_with
assert 'android32'.starts_with?('android')
assert 'android'.starts_with?('android')
assert ! 'win'.starts_with?('android')
end
def test_double_delimilters
s = 'a\\b\\c'
assert_equal 'a\\\\b\\\\c', 'a\\b\\c'.double_delimiters
# test s was not changed
assert_equal 'a\\b\\c', s
assert_equal 'a/b/c', 'a/b/c'.double_delimiters
assert_equal 'a/b\\\\c', 'a/b\\c'.double_delimiters
end
def test_double_delimilters!
s = 'a\\b\\c'
s.double_delimiters!
assert_equal 'a\\\\b\\\\c', s
s = 'a/b/c'
s.double_delimiters!
assert_equal 'a/b/c', s
s = 'a/b\\c'
s.double_delimiters!
assert_equal 'a/b\\\\c', s
end
end
|
ashumkin/rake-delphi
|
test/test-string.rb
|
Ruby
|
mit
| 1,089
|
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { IDisposable } from 'vs/base/common/lifecycle';
import { IStatusbarItem } from 'vs/workbench/browser/parts/statusbar/statusbar';
import { FeedbackDropdown, IFeedback, IFeedbackService } from './feedback';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import product from 'vs/platform/node/product';
import { Themable, STATUS_BAR_FOREGROUND, STATUS_BAR_NO_FOLDER_FOREGROUND } from 'vs/workbench/common/theme';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
class TwitterFeedbackService implements IFeedbackService {
private static TWITTER_URL: string = 'https://twitter.com/intent/tweet';
private static VIA_NAME: string = 'code';
private static HASHTAGS: string[] = ['HappyCoding'];
private combineHashTagsAsString(): string {
return TwitterFeedbackService.HASHTAGS.join(',');
}
public submitFeedback(feedback: IFeedback): void {
const queryString = `?${feedback.sentiment === 1 ? `hashtags=${this.combineHashTagsAsString()}&` : null}ref_src=twsrc%5Etfw&related=twitterapi%2Ctwitter&text=${feedback.feedback}&tw_p=tweetbutton&via=${TwitterFeedbackService.VIA_NAME}`;
const url = TwitterFeedbackService.TWITTER_URL + queryString;
window.open(url);
}
public getCharacterLimit(sentiment: number): number {
let length: number = 0;
if (sentiment === 1) {
TwitterFeedbackService.HASHTAGS.forEach(element => {
length += element.length + 2;
});
}
if (TwitterFeedbackService.VIA_NAME) {
length += ` via @${TwitterFeedbackService.VIA_NAME}`.length;
}
return 140 - length;
}
}
export class FeedbackStatusbarItem extends Themable implements IStatusbarItem {
private dropdown: FeedbackDropdown;
constructor(
@IInstantiationService private instantiationService: IInstantiationService,
@IContextViewService private contextViewService: IContextViewService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IThemeService themeService: IThemeService
) {
super(themeService);
this.registerListeners();
}
private registerListeners(): void {
this.toUnbind.push(this.contextService.onDidChangeWorkbenchState(() => this.updateStyles()));
}
protected updateStyles(): void {
super.updateStyles();
if (this.dropdown) {
this.dropdown.label.style('background-color', this.getColor(this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? STATUS_BAR_FOREGROUND : STATUS_BAR_NO_FOLDER_FOREGROUND));
}
}
public render(element: HTMLElement): IDisposable {
if (product.sendASmile) {
this.dropdown = this.instantiationService.createInstance(FeedbackDropdown, element, {
contextViewProvider: this.contextViewService,
feedbackService: this.instantiationService.createInstance(TwitterFeedbackService)
});
this.updateStyles();
return this.dropdown;
}
return null;
}
}
|
KattMingMing/vscode
|
src/vs/workbench/parts/feedback/electron-browser/feedbackStatusbarItem.ts
|
TypeScript
|
mit
| 3,410
|
# 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.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
from typing import TYPE_CHECKING
import warnings
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpRequest, HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union
T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
class ExpressRouteConnectionsOperations(object):
"""ExpressRouteConnectionsOperations operations.
You should not instantiate this class directly. Instead, you should create a Client instance that
instantiates it for you and attaches it as an attribute.
:ivar models: Alias to model classes used in this operation group.
:type models: ~azure.mgmt.network.v2021_02_01.models
:param client: Client for service requests.
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
"""
models = _models
def __init__(self, client, config, serializer, deserializer):
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config
def _create_or_update_initial(
self,
resource_group_name, # type: str
express_route_gateway_name, # type: str
connection_name, # type: str
put_express_route_connection_parameters, # type: "_models.ExpressRouteConnection"
**kwargs # type: Any
):
# type: (...) -> "_models.ExpressRouteConnection"
cls = kwargs.pop('cls', None) # type: ClsType["_models.ExpressRouteConnection"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2021-02-01"
content_type = kwargs.pop("content_type", "application/json")
accept = "application/json"
# Construct URL
url = self._create_or_update_initial.metadata['url'] # type: ignore
path_format_arguments = {
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'expressRouteGatewayName': self._serialize.url("express_route_gateway_name", express_route_gateway_name, 'str'),
'connectionName': self._serialize.url("connection_name", connection_name, 'str'),
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
body_content_kwargs = {} # type: Dict[str, Any]
body_content = self._serialize.body(put_express_route_connection_parameters, 'ExpressRouteConnection')
body_content_kwargs['content'] = body_content
request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize('ExpressRouteConnection', pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize('ExpressRouteConnection', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
_create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways/{expressRouteGatewayName}/expressRouteConnections/{connectionName}'} # type: ignore
def begin_create_or_update(
self,
resource_group_name, # type: str
express_route_gateway_name, # type: str
connection_name, # type: str
put_express_route_connection_parameters, # type: "_models.ExpressRouteConnection"
**kwargs # type: Any
):
# type: (...) -> LROPoller["_models.ExpressRouteConnection"]
"""Creates a connection between an ExpressRoute gateway and an ExpressRoute circuit.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param express_route_gateway_name: The name of the ExpressRoute gateway.
:type express_route_gateway_name: str
:param connection_name: The name of the connection subresource.
:type connection_name: str
:param put_express_route_connection_parameters: Parameters required in an
ExpressRouteConnection PUT operation.
:type put_express_route_connection_parameters: ~azure.mgmt.network.v2021_02_01.models.ExpressRouteConnection
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling.
Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
:return: An instance of LROPoller that returns either ExpressRouteConnection or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.network.v2021_02_01.models.ExpressRouteConnection]
:raises ~azure.core.exceptions.HttpResponseError:
"""
polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod]
cls = kwargs.pop('cls', None) # type: ClsType["_models.ExpressRouteConnection"]
lro_delay = kwargs.pop(
'polling_interval',
self._config.polling_interval
)
cont_token = kwargs.pop('continuation_token', None) # type: Optional[str]
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
express_route_gateway_name=express_route_gateway_name,
connection_name=connection_name,
put_express_route_connection_parameters=put_express_route_connection_parameters,
cls=lambda x,y,z: x,
**kwargs
)
kwargs.pop('error_map', None)
kwargs.pop('content_type', None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize('ExpressRouteConnection', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
path_format_arguments = {
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'expressRouteGatewayName': self._serialize.url("express_route_gateway_name", express_route_gateway_name, 'str'),
'connectionName': self._serialize.url("connection_name", connection_name, 'str'),
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs)
elif polling is False: polling_method = NoPolling()
else: polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output
)
else:
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways/{expressRouteGatewayName}/expressRouteConnections/{connectionName}'} # type: ignore
def get(
self,
resource_group_name, # type: str
express_route_gateway_name, # type: str
connection_name, # type: str
**kwargs # type: Any
):
# type: (...) -> "_models.ExpressRouteConnection"
"""Gets the specified ExpressRouteConnection.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param express_route_gateway_name: The name of the ExpressRoute gateway.
:type express_route_gateway_name: str
:param connection_name: The name of the ExpressRoute connection.
:type connection_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ExpressRouteConnection, or the result of cls(response)
:rtype: ~azure.mgmt.network.v2021_02_01.models.ExpressRouteConnection
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.ExpressRouteConnection"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2021-02-01"
accept = "application/json"
# Construct URL
url = self.get.metadata['url'] # type: ignore
path_format_arguments = {
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'expressRouteGatewayName': self._serialize.url("express_route_gateway_name", express_route_gateway_name, 'str'),
'connectionName': self._serialize.url("connection_name", connection_name, 'str'),
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
deserialized = self._deserialize('ExpressRouteConnection', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways/{expressRouteGatewayName}/expressRouteConnections/{connectionName}'} # type: ignore
def _delete_initial(
self,
resource_group_name, # type: str
express_route_gateway_name, # type: str
connection_name, # type: str
**kwargs # type: Any
):
# type: (...) -> None
cls = kwargs.pop('cls', None) # type: ClsType[None]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2021-02-01"
accept = "application/json"
# Construct URL
url = self._delete_initial.metadata['url'] # type: ignore
path_format_arguments = {
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'expressRouteGatewayName': self._serialize.url("express_route_gateway_name", express_route_gateway_name, 'str'),
'connectionName': self._serialize.url("connection_name", connection_name, 'str'),
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
request = self._client.delete(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways/{expressRouteGatewayName}/expressRouteConnections/{connectionName}'} # type: ignore
def begin_delete(
self,
resource_group_name, # type: str
express_route_gateway_name, # type: str
connection_name, # type: str
**kwargs # type: Any
):
# type: (...) -> LROPoller[None]
"""Deletes a connection to a ExpressRoute circuit.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param express_route_gateway_name: The name of the ExpressRoute gateway.
:type express_route_gateway_name: str
:param connection_name: The name of the connection subresource.
:type connection_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling.
Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod]
cls = kwargs.pop('cls', None) # type: ClsType[None]
lro_delay = kwargs.pop(
'polling_interval',
self._config.polling_interval
)
cont_token = kwargs.pop('continuation_token', None) # type: Optional[str]
if cont_token is None:
raw_result = self._delete_initial(
resource_group_name=resource_group_name,
express_route_gateway_name=express_route_gateway_name,
connection_name=connection_name,
cls=lambda x,y,z: x,
**kwargs
)
kwargs.pop('error_map', None)
kwargs.pop('content_type', None)
def get_long_running_output(pipeline_response):
if cls:
return cls(pipeline_response, None, {})
path_format_arguments = {
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'expressRouteGatewayName': self._serialize.url("express_route_gateway_name", express_route_gateway_name, 'str'),
'connectionName': self._serialize.url("connection_name", connection_name, 'str'),
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs)
elif polling is False: polling_method = NoPolling()
else: polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output
)
else:
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways/{expressRouteGatewayName}/expressRouteConnections/{connectionName}'} # type: ignore
def list(
self,
resource_group_name, # type: str
express_route_gateway_name, # type: str
**kwargs # type: Any
):
# type: (...) -> "_models.ExpressRouteConnectionList"
"""Lists ExpressRouteConnections.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param express_route_gateway_name: The name of the ExpressRoute gateway.
:type express_route_gateway_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ExpressRouteConnectionList, or the result of cls(response)
:rtype: ~azure.mgmt.network.v2021_02_01.models.ExpressRouteConnectionList
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.ExpressRouteConnectionList"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2021-02-01"
accept = "application/json"
# Construct URL
url = self.list.metadata['url'] # type: ignore
path_format_arguments = {
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'expressRouteGatewayName': self._serialize.url("express_route_gateway_name", express_route_gateway_name, 'str'),
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
deserialized = self._deserialize('ExpressRouteConnectionList', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteGateways/{expressRouteGatewayName}/expressRouteConnections'} # type: ignore
|
Azure/azure-sdk-for-python
|
sdk/network/azure-mgmt-network/azure/mgmt/network/v2021_02_01/operations/_express_route_connections_operations.py
|
Python
|
mit
| 22,003
|
# -*- coding: utf-8 -*-
import unittest
from pyparsing import ParseException
from tests.utils.grammar import get_record_grammar
"""
CWR Non-Roman Alphabet Agreement Party Name grammar tests.
The following cases are tested:
"""
__author__ = 'Bernardo Martínez Garrido'
__license__ = 'MIT'
__status__ = 'Development'
class TestNPAGrammar(unittest.TestCase):
"""
Tests that the NPA grammar decodes correctly formatted strings
"""
def setUp(self):
self.grammar = get_record_grammar('nra_agreement_party')
def test_valid_full(self):
"""
Tests that IPA grammar decodes correctly formatted record prefixes.
This test contains all the optional fields.
"""
record = 'NPA0000123400000023012345678PARTY NAME PARTY WRITER NAME ES'
result = self.grammar.parseString(record)[0]
self.assertEqual('NPA', result.record_type)
self.assertEqual(1234, result.transaction_sequence_n)
self.assertEqual(23, result.record_sequence_n)
self.assertEqual('012345678', result.ip_n)
self.assertEqual('PARTY NAME', result.ip_name)
self.assertEqual('PARTY WRITER NAME', result.ip_writer_name)
self.assertEqual('ES', result.language_code)
def test_valid_min(self):
"""
Tests that IPA grammar decodes correctly formatted record prefixes.
This test contains none of the optional fields.
"""
record = 'NPA0000123400000023000000000PARTY NAME PARTY WRITER NAME '
result = self.grammar.parseString(record)[0]
self.assertEqual('NPA', result.record_type)
self.assertEqual(1234, result.transaction_sequence_n)
self.assertEqual(23, result.record_sequence_n)
self.assertEqual('000000000', result.ip_n)
self.assertEqual('PARTY NAME', result.ip_name)
self.assertEqual('PARTY WRITER NAME', result.ip_writer_name)
self.assertEqual(None, result.language_code)
def test_extended_character(self):
"""
Tests that IPA grammar decodes correctly formatted record prefixes.
This test contains none of the optional fields.
"""
record = 'NPA0000123400000023000000000PARTY NAME \xc6\x8f PARTY WRITER NAME \xc6\x8f '
result = self.grammar.parseString(record)[0]
self.assertEqual('NPA', result.record_type)
self.assertEqual(1234, result.transaction_sequence_n)
self.assertEqual(23, result.record_sequence_n)
self.assertEqual('000000000', result.ip_n)
self.assertEqual('PARTY NAME \xc6\x8f', result.ip_name)
self.assertEqual('PARTY WRITER NAME \xc6\x8f', result.ip_writer_name)
self.assertEqual(None, result.language_code)
class TestNPAGrammarException(unittest.TestCase):
def setUp(self):
self.grammar = get_record_grammar('nra_agreement_party')
def test_empty(self):
"""
Tests that a exception is thrown when the the works number is zero.
"""
record = ''
self.assertRaises(ParseException, self.grammar.parseString, record)
def test_invalid(self):
record = 'This is an invalid string'
self.assertRaises(ParseException, self.grammar.parseString, record)
|
weso/CWR-DataApi
|
tests/grammar/factory/record/test_npa.py
|
Python
|
mit
| 4,113
|
package com.goutplay.loc_androidsdk.utils;
import android.content.Context;
import android.telephony.NeighboringCellInfo;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
import android.util.Log;
import java.util.List;
/**
* Created by goerver on 16-8-21.
*/
public class GSMCellLocationLbs {
private static final String TAG = "GMSCellLocation";
public static void getCurrentLocation(Context context) {
TelephonyManager mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// 返回值MCC + MNC
String operator = mTelephonyManager.getNetworkOperator();
int mcc = Integer.parseInt(operator.substring(0, 3));
int mnc = Integer.parseInt(operator.substring(3));
Log.i(TAG, " MCC = " + mcc + "\t MNC = " + mnc + "\t");
// 中国移动和中国联通获取LAC、CID的方式
GsmCellLocation location = (GsmCellLocation) mTelephonyManager.getCellLocation();
int lac = location.getLac();
int cellId = location.getCid();
// 中国电信获取LAC、CID的方式
CdmaCellLocation location1 = (CdmaCellLocation) mTelephonyManager.getCellLocation();
lac = location1.getNetworkId();
cellId = location1.getBaseStationId();
cellId /= 16;
Log.i(TAG, " MCC = " + mcc + "\t MNC = " + mnc + "\t LAC = " + lac + "\t CID = " + cellId);
// 获取邻区基站信息
List<NeighboringCellInfo> infos = mTelephonyManager.getNeighboringCellInfo();
StringBuffer sb = new StringBuffer("总数 : " + infos.size() + "\n");
for (NeighboringCellInfo info1 : infos) { // 根据邻区总数进行循环
sb.append(" LAC : " + info1.getLac()); // 取出当前邻区的LAC
sb.append(" CID : " + info1.getCid()); // 取出当前邻区的CID
sb.append(" BSSS : " + (-113 + 2 * info1.getRssi()) + "\n"); // 获取邻区基站信号强度
}
Log.i(TAG, " 获取邻区基站信息:" + sb.toString());
}
}
|
GOutPlay/LBS
|
Client/LBS-AndroidClient/loc_androidsdk/src/main/java/com/goutplay/loc_androidsdk/utils/GSMCellLocationLbs.java
|
Java
|
mit
| 2,123
|
WP Fast Search
==============
"A blazingly fast drop-down search widget for Wordpress."
Responds to key press, instantly presents a drop-down menu of post titles for
the user to select from (with ten-post max per result set).
The user can scroll through the list of posts using the mouse or keyboard
(pressing enter or clicking on a title will take the user to the selected
post.)
Data for posts are loaded asychronously once the page is loaded, and so
it will not affect the page loading speed. Only one request per page load
is ever sent to the server, which queries for cached post information, and
therefore the plugin is performant.
### Bugs/Todos
- Presents a white background for results, which might conflict with a
theme's color scheme.
- JavaScript and CSS are not cached (though they are quite small.)
|
graemeboy/wp-fast-search
|
README.md
|
Markdown
|
mit
| 824
|
'use strict';
var cocktail = require('cocktail');
var senchaCmd = require('./cmd/sencha');
var listCmd = require('./cmd/list');
var useCmd = require('./cmd/use');
var versionCmd = require('./cmd/version');
var noOpCmd = require('./cmd/noop.js');
//TODO: Review this, maybe using nopts
var CMD_OPTIONS = {
'noop' : [noOpCmd],
'use' : [useCmd],
'list' : [listCmd],
'version' : [versionCmd]
};
cocktail.mix({
'@exports': module,
'@as': 'class',
'@static': {
create: function (args) {
var Module = this,
pargs = args.slice(2),
talents = Module._cmdByArgs(pargs),
cli;
cli = new Module(pargs);
cocktail.mix(cli, {'@talents': talents});
return cli;
},
_cmdByArgs: function (pargs) {
var first = pargs && pargs[0],
options = CMD_OPTIONS;
return options[first] || [senchaCmd];
}
},
'@properties': {
args: undefined
},
constructor: function (args) {
this.setArgs(args);
}
});
|
elmasse/sencha-cmd-plus
|
src/cli.js
|
JavaScript
|
mit
| 1,142
|
/*
goroutine
*/
package tips_dir
import (
"fmt"
"github.com/tlorens/go-ibgetkey"
"io/ioutil"
"math"
"os"
"runtime/pprof"
"strconv"
"sync"
"time"
)
//---------------------------------------------------
// goroutineを生成する
//---------------------------------------------------
/*
goroutineはスレッドのようなものです。
joinはないので、終了を待つ場合はchannelを使います。
```
<-quit
```
とすると、quitというchannelに値が書き込まれるまで待ちます。
私の環境では、
```
Create goroutine
Waiting for the goroutine to complete
Start goroutine
End goroutine
Test compleated
```
という順番で表示されました。WaitingとStartの順番が直感と合いませんが、
goroutineの起動にオーバヘッドがあるのでしょうかね。
*/
// import "time"
func goroutine_Create() {
fmt.Println("Create goroutine")
quit := make(chan bool)
go func() {
fmt.Println("Start goroutine")
time.Sleep(3 * time.Second)
fmt.Println("End goroutine")
quit <- true
}()
fmt.Println("Waiting for the goroutine to complete")
<-quit
fmt.Println("Test compleated")
}
//---------------------------------------------------
// goroutineに引数を渡す
//---------------------------------------------------
/*
goroutineは外部宣言したfuncでも起動できます。
channelが必要な場合は引数にchannelを渡します。
もちろん、channel以外の引数も渡すことができます。
```
Start goroutine - Apple 10
```
と表示されます。
*/
//import "time"
func goroutine_Argument() {
fmt.Println("Test start")
fmt.Println("Create goroutine")
quit := make(chan bool)
go appleGoroutine("Apple", 10, quit)
fmt.Println("Waiting for the goroutine to complete")
<-quit
fmt.Println("Test compleated")
}
func appleGoroutine(fruit string, a int, quit chan bool) {
fmt.Printf("Start goroutine - %s %d\n", fruit, a)
time.Sleep(3 * time.Second)
fmt.Println("End goroutine")
quit <- true
}
//---------------------------------------------------
// goroutineの終了を待つ
//---------------------------------------------------
/*
終了待ちはchannelの受信で行います。[goroutineを生成する](#goroutine_Create)
を参照してください。
*/
//---------------------------------------------------
// goroutineの実行を終了させる
//---------------------------------------------------
/*
スレッドと違ってgoroutineは外部から終了させることは出来ません。
チャネルをつかって無限ループを抜けるようにするのが一案です。
無限ループを抜ける際に、breakにラベルを与えてどの階層まで抜けるかを指示できるようです。
下記のプログラムはGorutine内で"."を100msec置きに50回表示して終了しますが、
"."を押すとGorutineを途中で終了します。終了の意思を伝えるためにkillというチャネルで
通信を行っています。
なお、一文字入力を受け付けるのに
[go-ibgetkey](https://github.com/tlorens/go-ibgetkey)という
ライブラリを使いました。
*/
// import "github.com/tlorens/go-ibgetkey"
// import "time"
func goroutine_Kill() {
kill := make(chan bool)
finished := make(chan bool)
go killableGoroutine(kill, finished)
targetkey := "."
t := int(targetkey[0])
loop:
for {
input := keyboard.ReadKey()
select {
case <-finished:
break loop
default:
if input == t {
kill <- true
break loop
}
}
}
}
func killableGoroutine(kill, finished chan bool) {
fmt.Println("Started goroutine. Push \".\" to kill me.")
for i := 0; i < 50; i++ {
select {
case <-kill:
fmt.Println()
fmt.Println("Killed")
finished <- true
return
default:
fmt.Print(".")
time.Sleep(100 * time.Millisecond)
}
}
fmt.Println()
fmt.Println("Finished..push any key to abort.")
finished <- true
return
}
//---------------------------------------------------
// goroutineを停止する
//---------------------------------------------------
/*
[goroutineの実行を終了させる](#goroutine_)と同様にchannelで通信を行います。
下記のプログラムはGorutine内で"."を100msec置きに50回表示して終了しますが、
"."を入力するとGorutineを途中で停止・再開します。
*/
// import "github.com/tlorens/go-ibgetkey"
// import "time"
func goroutine_Stop() {
com := make(chan string)
finished := make(chan bool)
go stoppableGoroutine(com, finished)
targetkey := "."
t := int(targetkey[0])
running := true
loop:
for {
input := keyboard.ReadKey()
select {
case <-finished:
break loop
default:
if input == t {
if running == true {
com <- "stop"
running = false
} else {
com <- "start"
running = true
}
}
}
}
}
func stoppableGoroutine(command chan string, finished chan bool) {
fmt.Println("Started goroutine. Push \".\" to stop/start me.")
running := true
i := 0
for i < 50 {
select {
case com := <-command:
if com == "stop" {
running = false
} else {
running = true
}
default:
}
if running == true {
fmt.Print(".")
time.Sleep(100 * time.Millisecond)
i++
}
}
fmt.Println()
fmt.Println("Finished..push any key to abort.")
finished <- true
return
}
//---------------------------------------------------
// 実行中のgoroutine一覧を取得する
//---------------------------------------------------
/*
Ruby版ではリストを出してそれぞれをkillするというプログラムでしたが、
そもそもkillを簡単に実装する方法がないので、リスト表示だけにとどめます。
goroutineをリスト化する関数自体やmain関数自身もgoroutineなので
多数のgoroutineが表示されます。
*/
//import "os"
//import "runtime/pprof"
//import "time"
func goroutine_ListGoroutines() {
go goroutine1()
go goroutine2()
time.Sleep(1 * time.Second) // goroutineの起動のオーバヘッド待ち
pprof.Lookup("goroutine").WriteTo(os.Stdout, 2) // 2はデバッグレベル。goroutineだけリストする、の意味。
}
func goroutine1() {
time.Sleep(5 * time.Second)
fmt.Println("Goroutine1 finished")
}
func goroutine2() {
time.Sleep(5 * time.Second)
fmt.Println("Goroutine2 finished")
}
//---------------------------------------------------
// goroutine間で通信する
//---------------------------------------------------
/*
Ruby版ではQueueを使っているところを、channelに変更します。
makeでchannelの深さを指定しますが、深さ以上に値を突っ込もうとすると
その時点でロックします。[こちら](http://rosylilly.hatenablog.com/entry/2013/09/26/124801)をご参考。
下記プログラムはキー入力を受付け、平方根を返します。-1を入力すると終了します。
*/
// import "math"
func goroutine_Com() {
queue := make(chan int, 3) // 3はキューの深さ
go sqrtGoroutine(queue)
line := 0
loop:
for {
fmt.Scanln(&line)
if line == -1 {
break loop
} else {
queue <- line
}
}
}
func sqrtGoroutine(queue chan int) {
for {
n := <-queue
if int(n) >= 0 {
val := math.Sqrt(float64(n))
fmt.Printf("Square(%d) = %f\n", int(n), val)
} else {
fmt.Println("?")
}
}
}
//---------------------------------------------------
// goroutine間の競合を回避する(Mutex)
//---------------------------------------------------
/*
syncパッケージにMutexがあります。複数のgoroutine終了を待つにはWaitGroupを使います。
[こちら](http://mattn.kaoriya.net/software/lang/go/20140625223125.htm)がよくまとまっています。
ファイルcount.txtを作って0を書き込み、gotoutine内ではファイルの数値を読んでインクリメントして書き戻します。
終了後は、goroutineが10個走るのでcount.txtの値は10になっています。
*/
//import "sync"
//import "io/ioutil"
func goroutine_Mutex() {
wg := new(sync.WaitGroup)
m := new(sync.Mutex)
write(0)
for i := 0; i < 10; i++ {
wg.Add(1)
go countupGoroutine(wg, m)
}
wg.Wait()
}
func countupGoroutine(wg *sync.WaitGroup, m *sync.Mutex) {
m.Lock()
defer m.Unlock()
counter := read() + 1
write(counter)
wg.Done()
}
func write(i int) {
s := strconv.Itoa(i)
ioutil.WriteFile("count.txt", []byte(s), os.ModePerm)
}
func read() int {
t, _ := ioutil.ReadFile("count.txt")
i, _ := strconv.Atoi(string(t))
return i
}
//---------------------------------------------------
// goroutine
//---------------------------------------------------
func Tips_goroutine() {
goroutine_Create() // goroutineを生成する
goroutine_Argument() // goroutineに引数を渡す
// goroutineの終了を待つ
goroutine_Kill() // goroutineの実行を終了させる
goroutine_Stop() // goroutineを停止する
goroutine_ListGoroutines() // 実行中のgoroutine一覧を取得する
goroutine_Com() // goroutine間で通信する
goroutine_Mutex() // goroutine間の競合を回避する(Mutex)
}
|
ashitani/golangtips
|
pkg/tips_goroutine/tips_goroutine.go
|
GO
|
mit
| 9,125
|
@import Foundation;
@interface DSMessageContext: NSObject<NSCoding>
@end
|
diejmon/DSLibAlerts
|
Pod/Classes/DSMessageContext.h
|
C
|
mit
| 76
|
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Using RingOpenGL and RingAllegro for 3D Graphics — Ring 1.17 documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="The Gold Magic 800 Game" href="goldmagic800.html" />
<link rel="prev" title="Using RingOpenGL and RingFreeGLUT for 3D Graphics" href="usingopengl.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html">
<img src="_static/ringdoclogo.jpg" class="logo" alt="Logo"/>
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="ringapps.html">Applications developed in a few hours</a></li>
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringnotepad.html">Using Ring Notepad</a></li>
<li class="toctree-l1"><a class="reference internal" href="getting_started.html">Getting Started - First Style</a></li>
<li class="toctree-l1"><a class="reference internal" href="getting_started2.html">Getting Started - Second Style</a></li>
<li class="toctree-l1"><a class="reference internal" href="getting_started3.html">Getting Started - Third Style</a></li>
<li class="toctree-l1"><a class="reference internal" href="variables.html">Variables</a></li>
<li class="toctree-l1"><a class="reference internal" href="operators.html">Operators</a></li>
<li class="toctree-l1"><a class="reference internal" href="controlstructures.html">Control Structures - First Style</a></li>
<li class="toctree-l1"><a class="reference internal" href="controlstructures2.html">Control Structures - Second Style</a></li>
<li class="toctree-l1"><a class="reference internal" href="controlstructures3.html">Control Structures - Third Style</a></li>
<li class="toctree-l1"><a class="reference internal" href="getinput.html">Getting Input</a></li>
<li class="toctree-l1"><a class="reference internal" href="functions.html">Functions - First Style</a></li>
<li class="toctree-l1"><a class="reference internal" href="functions2.html">Functions - Second Style</a></li>
<li class="toctree-l1"><a class="reference internal" href="functions3.html">Functions - Third Style</a></li>
<li class="toctree-l1"><a class="reference internal" href="programstructure.html">Program Structure</a></li>
<li class="toctree-l1"><a class="reference internal" href="lists.html">Lists</a></li>
<li class="toctree-l1"><a class="reference internal" href="strings.html">Strings</a></li>
<li class="toctree-l1"><a class="reference internal" href="dateandtime.html">Date and Time</a></li>
<li class="toctree-l1"><a class="reference internal" href="checkandconvert.html">Check Data Type and Conversion</a></li>
<li class="toctree-l1"><a class="reference internal" href="mathfunc.html">Mathematical Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="files.html">Files</a></li>
<li class="toctree-l1"><a class="reference internal" href="systemfunc.html">System Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="evaldebug.html">Eval() and Debugging</a></li>
<li class="toctree-l1"><a class="reference internal" href="demo.html">Demo Programs</a></li>
<li class="toctree-l1"><a class="reference internal" href="odbc.html">ODBC Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="mysql.html">MySQL Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="sqlite.html">SQLite Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="postgresql.html">PostgreSQL Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="secfunc.html">Security and Internet Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="oop.html">Object Oriented Programming (OOP)</a></li>
<li class="toctree-l1"><a class="reference internal" href="fp.html">Functional Programming (FP)</a></li>
<li class="toctree-l1"><a class="reference internal" href="metaprog.html">Reflection and Meta-programming</a></li>
<li class="toctree-l1"><a class="reference internal" href="declarative.html">Declarative Programming using Nested Structures</a></li>
<li class="toctree-l1"><a class="reference internal" href="natural.html">Natural language programming</a></li>
<li class="toctree-l1"><a class="reference internal" href="naturallibrary.html">Using the Natural Library</a></li>
<li class="toctree-l1"><a class="reference internal" href="scope.html">Scope Rules for Variables and Attributes</a></li>
<li class="toctree-l1"><a class="reference internal" href="scope2.html">Scope Rules for Functions and Methods</a></li>
<li class="toctree-l1"><a class="reference internal" href="syntaxflexibility.html">Syntax Flexibility</a></li>
<li class="toctree-l1"><a class="reference internal" href="typehints.html">The Type Hints Library</a></li>
<li class="toctree-l1"><a class="reference internal" href="debug.html">The Trace Library and the Interactive Debugger</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringemb.html">Embedding Ring Language in Ring Programs</a></li>
<li class="toctree-l1"><a class="reference internal" href="stdlib.html">Stdlib Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="stdlibclasses.html">Stdlib Classes</a></li>
<li class="toctree-l1"><a class="reference internal" href="qt.html">Desktop, WebAssembly and Mobile development using RingQt</a></li>
<li class="toctree-l1"><a class="reference internal" href="formdesigner.html">Using the Form Designer</a></li>
<li class="toctree-l1"><a class="reference internal" href="qt3d.html">Graphics Programming using RingQt3D</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringqtobjects.html">Objects Library for RingQt Application</a></li>
<li class="toctree-l1"><a class="reference internal" href="multilanguage.html">Multi-language Applications</a></li>
<li class="toctree-l1"><a class="reference internal" href="qtmobile.html">Building RingQt Applications for Mobile</a></li>
<li class="toctree-l1"><a class="reference internal" href="qtwebassembly.html">Building RingQt Applications for WebAssembly</a></li>
<li class="toctree-l1"><a class="reference internal" href="web.html">Web Development (CGI Library)</a></li>
<li class="toctree-l1"><a class="reference internal" href="deployincloud.html">Deploying Web Applications in the Cloud</a></li>
<li class="toctree-l1"><a class="reference internal" href="allegro.html">Graphics and 2D Games programming using RingAllegro</a></li>
<li class="toctree-l1"><a class="reference internal" href="gameengine.html">Demo Project - Game Engine for 2D Games</a></li>
<li class="toctree-l1"><a class="reference internal" href="gameengineandorid.html">Building Games For Android</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringraylib.html">Developing Games using RingRayLib</a></li>
<li class="toctree-l1"><a class="reference internal" href="usingopengl.html">Using RingOpenGL and RingFreeGLUT for 3D Graphics</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Using RingOpenGL and RingAllegro for 3D Graphics</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#d-cube-and-texture">3D Cube and Texture</a></li>
<li class="toctree-l2"><a class="reference internal" href="#many-cubes">Many Cubes</a></li>
<li class="toctree-l2"><a class="reference internal" href="#tictactoe-3d-game">TicTacToe 3D Game</a></li>
<li class="toctree-l2"><a class="reference internal" href="#more-3d-samples">More 3D Samples</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="goldmagic800.html">Demo Project - The Gold Magic 800 Game</a></li>
<li class="toctree-l1"><a class="reference internal" href="tilengine.html">Using RingTilengine</a></li>
<li class="toctree-l1"><a class="reference internal" href="performancetips.html">Performance Tips</a></li>
<li class="toctree-l1"><a class="reference internal" href="compiler.html">Command Line Options</a></li>
<li class="toctree-l1"><a class="reference internal" href="distribute.html">Distributing Ring Applications (Manual)</a></li>
<li class="toctree-l1"><a class="reference internal" href="distribute_ring2exe.html">Distributing Ring Applications using Ring2EXE</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringpm.html">The Ring Package Manager (RingPM)</a></li>
<li class="toctree-l1"><a class="reference internal" href="zerolib.html">ZeroLib Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="foxringfuncsdoc.html">FoxRing Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="bignumber.html">BigNumber Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="csvlib.html">CSVLib Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="jsonlib.html">JSONLib Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="tokenslib.html">TokensLib Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="libcurl.html">Using RingLibCurl</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringlibcurlfuncsdoc.html">RingLibCurl Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="socket.html">Using RingSockets</a></li>
<li class="toctree-l1"><a class="reference internal" href="threads.html">Using RingThreads</a></li>
<li class="toctree-l1"><a class="reference internal" href="libui.html">Using RingLibui</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringzip.html">Using RingZip</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringlibzipfuncsdoc.html">RingLibZip Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringmurmurhashfuncsdoc.html">RingMurmurHash Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringconsolecolorsfuncsdoc.html">RingConsoleColors Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringallegrofuncsdoc.html">RingAllegro Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="libsdl.html">Using RingLibSDL</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringlibsdlfuncsdoc.html">RingLibSDL Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="libuv.html">Using Ringlibuv</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringlibuvfuncsdoc.html">RingLibuv Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringfreeglutfuncsdoc.html">RingFreeGLUT Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringstbimage.html">RingStbImage Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringopengl32funcsdoc.html">RingOpenGL (OpenGL 3.2) Functions Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="qtclassesdoc.html">RingQt Classes and Methods Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="lowlevel.html">Low Level Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="extension_tutorial.html">Tutorial: Ring Extensions in C/C++</a></li>
<li class="toctree-l1"><a class="reference internal" href="extension.html">Extension using the C/C++ languages</a></li>
<li class="toctree-l1"><a class="reference internal" href="embedding.html">Embedding Ring Language in C/C++ Programs</a></li>
<li class="toctree-l1"><a class="reference internal" href="codegenerator.html">Code Generator for wrapping C/C++ Libraries</a></li>
<li class="toctree-l1"><a class="reference internal" href="ringbeep.html">Create your first extension using the Code Generator</a></li>
<li class="toctree-l1"><a class="reference internal" href="languagedesign.html">Release Notes: Version 1.0</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew.html">Release Notes: Version 1.1</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew2.html">Release Notes: Version 1.2</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew3.html">Release Notes: Version 1.3</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew4.html">Release Notes: Version 1.4</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew5.html">Release Notes: Version 1.5</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew6.html">Release Notes: Version 1.6</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew7.html">Release Notes: Version 1.7</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew8.html">Release Notes: Version 1.8</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew9.html">Release Notes: Version 1.9</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew10.html">Release Notes: Version 1.10</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew11.html">Release Notes: Version 1.11</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew12.html">Release Notes: Version 1.12</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew13.html">Release Notes: Version 1.13</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew14.html">Release Notes: Version 1.14</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew15.html">Release Notes: Version 1.15</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew16.html">Release Notes: Version 1.16</a></li>
<li class="toctree-l1"><a class="reference internal" href="whatisnew17.html">Release Notes: Version 1.17</a></li>
<li class="toctree-l1"><a class="reference internal" href="codeeditors.html">Using Other Code Editors</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions (FAQ)</a></li>
<li class="toctree-l1"><a class="reference internal" href="sourcecode.html">How to Compile Ring From Source Code?</a></li>
<li class="toctree-l1"><a class="reference internal" href="contribute.html">How to contribute?</a></li>
<li class="toctree-l1"><a class="reference internal" href="reference.html">Language Specification</a></li>
<li class="toctree-l1"><a class="reference internal" href="resources.html">Resources</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Ring</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home"></a> »</li>
<li>Using RingOpenGL and RingAllegro for 3D Graphics</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="using-ringopengl-and-ringallegro-for-3d-graphics">
<span id="index-0"></span><h1>Using RingOpenGL and RingAllegro for 3D Graphics<a class="headerlink" href="#using-ringopengl-and-ringallegro-for-3d-graphics" title="Permalink to this headline">¶</a></h1>
<p>In this chapter we will learn about using RingOpenGL and RingAllegro</p>
<div class="section" id="d-cube-and-texture">
<span id="index-1"></span><h2>3D Cube and Texture<a class="headerlink" href="#d-cube-and-texture" title="Permalink to this headline">¶</a></h2>
<p>Source Code:</p>
<div class="highlight-ring notranslate"><div class="highlight"><pre><span></span><span class="c"># Load Libraries</span>
<span class="k">load</span> <span class="s">"gamelib.ring"</span> <span class="c"># RingAllegro Library</span>
<span class="k">load</span> <span class="s">"opengl21lib.ring"</span> <span class="c"># RingOpenGL Library</span>
<span class="c">#==============================================================</span>
<span class="c"># To Support MacOS X</span>
<span class="n">al_run_main</span><span class="p">()</span>
<span class="k">func</span> <span class="n">al_game_start</span> <span class="c"># Called by al_run_main()</span>
<span class="n">main</span><span class="p">()</span> <span class="c"># Now we call our main function</span>
<span class="c">#==============================================================</span>
<span class="k">func</span> <span class="n">main</span>
<span class="k">new</span> <span class="n">GraphicsApp</span> <span class="p">{</span>
<span class="n">start</span><span class="p">()</span>
<span class="p">}</span>
<span class="k">class</span> <span class="n">GraphicsApp</span> <span class="k">from</span> <span class="n">GraphicsAppBase</span>
<span class="n">TITLE</span> <span class="o">=</span> <span class="s">"Ring Cube"</span>
<span class="n">bitmap</span> <span class="n">texture</span>
<span class="n">xrot</span> <span class="o">=</span> <span class="mf">0.0</span>
<span class="n">yrot</span> <span class="o">=</span> <span class="mf">0.0</span>
<span class="n">zrot</span> <span class="o">=</span> <span class="mf">0.0</span>
<span class="k">func</span> <span class="n">loadresources</span>
<span class="n">bitmap</span> <span class="o">=</span> <span class="n">al_load_bitmap</span><span class="p">(</span><span class="s">"ring.bmp"</span><span class="p">)</span>
<span class="n">texture</span> <span class="o">=</span> <span class="n">al_get_opengl_texture</span><span class="p">(</span><span class="n">bitmap</span><span class="p">)</span>
<span class="k">func</span> <span class="n">destroyResources</span>
<span class="n">al_destroy_bitmap</span><span class="p">(</span><span class="n">bitmap</span><span class="p">)</span>
<span class="k">func</span> <span class="n">drawScene</span>
<span class="n">w</span> <span class="o">=</span> <span class="mi">800</span> <span class="n">h</span> <span class="o">=</span> <span class="mi">600</span>
<span class="n">ratio</span> <span class="o">=</span> <span class="n">w</span> <span class="o">/</span> <span class="n">h</span>
<span class="n">glViewport</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">w</span><span class="p">,</span> <span class="n">h</span><span class="p">)</span>
<span class="n">glMatrixMode</span><span class="p">(</span><span class="n">GL_PROJECTION</span><span class="p">)</span>
<span class="n">glLoadIdentity</span><span class="p">()</span>
<span class="n">gluPerspective</span><span class="p">(</span><span class="mi">45</span><span class="p">,</span><span class="n">ratio</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">100</span><span class="p">)</span>
<span class="n">glMatrixMode</span><span class="p">(</span><span class="n">GL_MODELVIEW</span><span class="p">)</span>
<span class="n">glLoadIdentity</span><span class="p">()</span>
<span class="n">glEnable</span><span class="p">(</span><span class="n">GL_TEXTURE_2D</span><span class="p">)</span>
<span class="n">glShadeModel</span><span class="p">(</span><span class="n">GL_SMOOTH</span><span class="p">)</span>
<span class="n">glClearColor</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span>
<span class="n">glClearDepth</span><span class="p">(</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glEnable</span><span class="p">(</span><span class="n">GL_DEPTH_TEST</span><span class="p">)</span>
<span class="n">glEnable</span><span class="p">(</span><span class="n">GL_CULL_FACE</span><span class="p">)</span>
<span class="n">glDepthFunc</span><span class="p">(</span><span class="n">GL_LEQUAL</span><span class="p">)</span>
<span class="n">glHint</span><span class="p">(</span><span class="n">GL_PERSPECTIVE_CORRECTION_HINT</span><span class="p">,</span> <span class="n">GL_NICEST</span><span class="p">)</span>
<span class="n">glClear</span><span class="p">(</span><span class="n">GL_COLOR_BUFFER_BIT</span> <span class="o">|</span> <span class="n">GL_DEPTH_BUFFER_BIT</span><span class="p">)</span>
<span class="n">glLoadIdentity</span><span class="p">()</span>
<span class="n">glTranslatef</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">,</span><span class="o">-</span><span class="mf">5.0</span><span class="p">)</span>
<span class="n">glRotatef</span><span class="p">(</span><span class="n">xrot</span><span class="p">,</span><span class="mf">1.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">)</span>
<span class="n">glRotatef</span><span class="p">(</span><span class="n">yrot</span><span class="p">,</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">1.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">)</span>
<span class="n">glRotatef</span><span class="p">(</span><span class="n">zrot</span><span class="p">,</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glBindTexture</span><span class="p">(</span><span class="n">GL_TEXTURE_2D</span><span class="p">,</span> <span class="n">texture</span><span class="p">)</span>
<span class="n">glBegin</span><span class="p">(</span><span class="n">GL_QUADS</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Front</span> <span class="n">Face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Back</span> <span class="n">Face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Top</span> <span class="n">Face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Bottom</span> <span class="n">Face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Right</span> <span class="n">face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Left</span> <span class="n">Face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glEnd</span><span class="p">()</span>
<span class="n">xrot</span> <span class="o">+=</span> <span class="mf">0.3</span>
<span class="n">yrot</span> <span class="o">+=</span> <span class="mf">0.2</span>
<span class="n">zrot</span> <span class="o">+=</span> <span class="mf">0.4</span>
<span class="k">class</span> <span class="n">GraphicsAppBase</span>
<span class="n">display</span> <span class="n">event_queue</span> <span class="n">ev</span> <span class="n">timeout</span>
<span class="n">timer</span> <span class="n">redraw</span> <span class="o">=</span> <span class="kp">true</span>
<span class="n">FPS</span> <span class="o">=</span> <span class="mi">60</span>
<span class="n">SCREEN_W</span> <span class="o">=</span> <span class="mi">800</span>
<span class="n">SCREEN_H</span> <span class="o">=</span> <span class="mi">600</span>
<span class="n">KEY_UP</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">KEY_DOWN</span> <span class="o">=</span> <span class="mi">2</span>
<span class="n">KEY_LEFT</span> <span class="o">=</span> <span class="mi">3</span>
<span class="n">KEY_RIGHT</span> <span class="o">=</span> <span class="mi">4</span>
<span class="n">Key</span> <span class="o">=</span> <span class="o">[</span><span class="kp">false</span><span class="p">,</span><span class="kp">false</span><span class="p">,</span><span class="kp">false</span><span class="p">,</span><span class="kp">false</span><span class="o">]</span>
<span class="n">TITLE</span> <span class="o">=</span> <span class="s">"Graphics Application"</span>
<span class="k">func</span> <span class="n">start</span>
<span class="n">SetUp</span><span class="p">()</span>
<span class="n">loadResources</span><span class="p">()</span>
<span class="n">eventsLoop</span><span class="p">()</span>
<span class="n">destroy</span><span class="p">()</span>
<span class="k">func</span> <span class="n">setup</span>
<span class="n">al_init</span><span class="p">()</span>
<span class="n">al_init_image_addon</span><span class="p">()</span>
<span class="n">al_set_new_display_flags</span><span class="p">(</span><span class="n">ALLEGRO_OPENGL</span><span class="p">)</span>
<span class="n">display</span> <span class="o">=</span> <span class="n">al_create_display</span><span class="p">(</span><span class="n">SCREEN_W</span><span class="p">,</span><span class="n">SCREEN_H</span><span class="p">)</span>
<span class="n">al_set_Window_title</span><span class="p">(</span><span class="n">display</span><span class="p">,</span><span class="n">TITLE</span><span class="p">)</span>
<span class="n">al_clear_to_color</span><span class="p">(</span><span class="n">al_map_rgb</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">))</span>
<span class="n">event_queue</span> <span class="o">=</span> <span class="n">al_create_event_queue</span><span class="p">()</span>
<span class="n">al_register_event_source</span><span class="p">(</span><span class="n">event_queue</span><span class="p">,</span>
<span class="n">al_get_display_event_source</span><span class="p">(</span><span class="n">display</span><span class="p">))</span>
<span class="n">ev</span> <span class="o">=</span> <span class="n">al_new_allegro_event</span><span class="p">()</span>
<span class="n">timeout</span> <span class="o">=</span> <span class="n">al_new_allegro_timeout</span><span class="p">()</span>
<span class="n">al_init_timeout</span><span class="p">(</span><span class="n">timeout</span><span class="p">,</span> <span class="mf">0.06</span><span class="p">)</span>
<span class="n">timer</span> <span class="o">=</span> <span class="n">al_create_timer</span><span class="p">(</span><span class="mf">1.0</span> <span class="o">/</span> <span class="n">FPS</span><span class="p">)</span>
<span class="n">al_register_event_source</span><span class="p">(</span><span class="n">event_queue</span><span class="p">,</span>
<span class="n">al_get_timer_event_source</span><span class="p">(</span><span class="n">timer</span><span class="p">))</span>
<span class="n">al_start_timer</span><span class="p">(</span><span class="n">timer</span><span class="p">)</span>
<span class="n">al_install_mouse</span><span class="p">()</span>
<span class="n">al_register_event_source</span><span class="p">(</span><span class="n">event_queue</span><span class="p">,</span>
<span class="n">al_get_mouse_event_source</span><span class="p">())</span>
<span class="n">al_install_keyboard</span><span class="p">()</span>
<span class="n">al_register_event_source</span><span class="p">(</span><span class="n">event_queue</span><span class="p">,</span>
<span class="n">al_get_keyboard_event_source</span><span class="p">())</span>
<span class="k">func</span> <span class="n">eventsLoop</span>
<span class="k">while</span> <span class="kp">true</span>
<span class="n">al_init_timeout</span><span class="p">(</span><span class="n">timeout</span><span class="p">,</span> <span class="mf">0.06</span><span class="p">)</span>
<span class="n">al_wait_for_event_until</span><span class="p">(</span><span class="n">event_queue</span><span class="p">,</span> <span class="n">ev</span><span class="p">,</span> <span class="n">timeout</span><span class="p">)</span>
<span class="k">switch</span> <span class="n">al_get_allegro_event_type</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_DISPLAY_CLOSE</span>
<span class="k">exit</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_TIMER</span>
<span class="n">redraw</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_MOUSE_AXES</span>
<span class="n">mouse_x</span> <span class="o">=</span> <span class="n">al_get_allegro_event_mouse_x</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="n">mouse_y</span> <span class="o">=</span> <span class="n">al_get_allegro_event_mouse_y</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY</span>
<span class="n">mouse_x</span> <span class="o">=</span> <span class="n">al_get_allegro_event_mouse_x</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="n">mouse_y</span> <span class="o">=</span> <span class="n">al_get_allegro_event_mouse_y</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_MOUSE_BUTTON_UP</span>
<span class="k">exit</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_KEY_DOWN</span>
<span class="k">switch</span> <span class="n">al_get_allegro_event_keyboard_keycode</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_UP</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_UP</span><span class="o">]</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_DOWN</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_DOWN</span><span class="o">]</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_LEFT</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_LEFT</span><span class="o">]</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_RIGHT</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_RIGHT</span><span class="o">]</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">off</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_KEY_UP</span>
<span class="k">switch</span> <span class="n">al_get_allegro_event_keyboard_keycode</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_UP</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_UP</span><span class="o">]</span> <span class="o">=</span> <span class="kp">false</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_DOWN</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_DOWN</span><span class="o">]</span> <span class="o">=</span> <span class="kp">false</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_LEFT</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_LEFT</span><span class="o">]</span> <span class="o">=</span> <span class="kp">false</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_RIGHT</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_RIGHT</span><span class="o">]</span> <span class="o">=</span> <span class="kp">false</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_ESCAPE</span>
<span class="k">exit</span>
<span class="k">off</span>
<span class="k">off</span>
<span class="k">if</span> <span class="n">redraw</span> <span class="ow">and</span> <span class="n">al_is_event_queue_empty</span><span class="p">(</span><span class="n">event_queue</span><span class="p">)</span>
<span class="n">redraw</span> <span class="o">=</span> <span class="kp">false</span>
<span class="n">drawScene</span><span class="p">()</span>
<span class="n">al_flip_display</span><span class="p">()</span>
<span class="k">ok</span>
<span class="n">callgc</span><span class="p">()</span>
<span class="k">end</span>
<span class="k">func</span> <span class="n">destroy</span>
<span class="n">destroyResources</span><span class="p">()</span>
<span class="n">al_destroy_timer</span><span class="p">(</span><span class="n">timer</span><span class="p">)</span>
<span class="n">al_destroy_allegro_event</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="n">al_destroy_allegro_timeout</span><span class="p">(</span><span class="n">timeout</span><span class="p">)</span>
<span class="n">al_destroy_event_queue</span><span class="p">(</span><span class="n">event_queue</span><span class="p">)</span>
<span class="n">al_destroy_display</span><span class="p">(</span><span class="n">display</span><span class="p">)</span>
<span class="n">al_exit</span><span class="p">()</span>
<span class="k">func</span> <span class="n">loadresources</span>
<span class="k">func</span> <span class="n">drawScene</span>
<span class="k">func</span> <span class="n">destroyResources</span>
</pre></div>
</div>
<p>Screen Shot:</p>
<img alt="Ring Cube" src="_images/ringcube3d.png" />
</div>
<div class="section" id="many-cubes">
<span id="index-2"></span><h2>Many Cubes<a class="headerlink" href="#many-cubes" title="Permalink to this headline">¶</a></h2>
<p>Source Code:</p>
<div class="highlight-ring notranslate"><div class="highlight"><pre><span></span><span class="c"># Load Libraries</span>
<span class="k">load</span> <span class="s">"gamelib.ring"</span> <span class="c"># RingAllegro Library</span>
<span class="k">load</span> <span class="s">"opengl21lib.ring"</span> <span class="c"># RingOpenGL Library</span>
<span class="c">#==============================================================</span>
<span class="c"># To Support MacOS X</span>
<span class="n">al_run_main</span><span class="p">()</span>
<span class="k">func</span> <span class="n">al_game_start</span> <span class="c"># Called by al_run_main()</span>
<span class="n">main</span><span class="p">()</span> <span class="c"># Now we call our main function</span>
<span class="c">#==============================================================</span>
<span class="k">func</span> <span class="n">main</span>
<span class="k">new</span> <span class="n">GraphicsApp</span> <span class="p">{</span>
<span class="n">start</span><span class="p">()</span>
<span class="p">}</span>
<span class="k">class</span> <span class="n">GraphicsApp</span> <span class="k">from</span> <span class="n">GraphicsAppBase</span>
<span class="n">TITLE</span> <span class="o">=</span> <span class="s">"Many Cubes"</span>
<span class="n">bitmap</span> <span class="n">bitmap2</span> <span class="n">bitmap3</span>
<span class="n">texture</span> <span class="n">texture2</span> <span class="n">texture3</span>
<span class="n">fps</span> <span class="o">=</span> <span class="mi">120</span>
<span class="n">xrot</span> <span class="o">=</span> <span class="mf">0.0</span>
<span class="n">yrot</span> <span class="o">=</span> <span class="mf">0.0</span>
<span class="n">zrot</span> <span class="o">=</span> <span class="mf">0.0</span>
<span class="n">nPerspective</span> <span class="o">=</span> <span class="mi">100</span>
<span class="k">func</span> <span class="n">loadresources</span>
<span class="n">bitmap</span> <span class="o">=</span> <span class="n">al_load_bitmap</span><span class="p">(</span><span class="s">"sky1.jpg"</span><span class="p">)</span>
<span class="n">texture</span> <span class="o">=</span> <span class="n">al_get_opengl_texture</span><span class="p">(</span><span class="n">bitmap</span><span class="p">)</span>
<span class="n">bitmap2</span> <span class="o">=</span> <span class="n">al_load_bitmap</span><span class="p">(</span><span class="s">"sky2.jpg"</span><span class="p">)</span>
<span class="n">texture2</span> <span class="o">=</span> <span class="n">al_get_opengl_texture</span><span class="p">(</span><span class="n">bitmap2</span><span class="p">)</span>
<span class="n">bitmap3</span> <span class="o">=</span> <span class="n">al_load_bitmap</span><span class="p">(</span><span class="s">"sky3.jpg"</span><span class="p">)</span>
<span class="n">texture3</span> <span class="o">=</span> <span class="n">al_get_opengl_texture</span><span class="p">(</span><span class="n">bitmap3</span><span class="p">)</span>
<span class="k">func</span> <span class="n">destroyResources</span>
<span class="n">al_destroy_bitmap</span><span class="p">(</span><span class="n">bitmap</span><span class="p">)</span>
<span class="n">al_destroy_bitmap</span><span class="p">(</span><span class="n">bitmap2</span><span class="p">)</span>
<span class="n">al_destroy_bitmap</span><span class="p">(</span><span class="n">bitmap3</span><span class="p">)</span>
<span class="k">func</span> <span class="n">drawScene</span>
<span class="n">prepare</span><span class="p">()</span>
<span class="n">cubes</span><span class="p">()</span>
<span class="n">rotate</span><span class="p">()</span>
<span class="k">func</span> <span class="n">Prepare</span>
<span class="n">w</span> <span class="o">=</span> <span class="mi">800</span> <span class="n">h</span> <span class="o">=</span> <span class="mi">600</span>
<span class="n">ratio</span> <span class="o">=</span> <span class="n">w</span> <span class="o">/</span> <span class="n">h</span>
<span class="n">glViewport</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">w</span><span class="p">,</span> <span class="n">h</span><span class="p">)</span>
<span class="n">glMatrixMode</span><span class="p">(</span><span class="n">GL_PROJECTION</span><span class="p">)</span>
<span class="n">glLoadIdentity</span><span class="p">()</span>
<span class="n">gluPerspective</span><span class="p">(</span><span class="o">-</span><span class="n">nPerspective</span><span class="p">,</span><span class="n">ratio</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="n">nPerspective</span><span class="p">)</span>
<span class="n">glMatrixMode</span><span class="p">(</span><span class="n">GL_MODELVIEW</span><span class="p">)</span>
<span class="n">glLoadIdentity</span><span class="p">()</span>
<span class="n">glEnable</span><span class="p">(</span><span class="n">GL_TEXTURE_2D</span><span class="p">)</span>
<span class="n">glShadeModel</span><span class="p">(</span><span class="n">GL_SMOOTH</span><span class="p">)</span>
<span class="n">glClearColor</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span>
<span class="n">glClearDepth</span><span class="p">(</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glEnable</span><span class="p">(</span><span class="n">GL_DEPTH_TEST</span><span class="p">)</span>
<span class="n">glEnable</span><span class="p">(</span><span class="n">GL_CULL_FACE</span><span class="p">)</span>
<span class="n">glDepthFunc</span><span class="p">(</span><span class="n">GL_LEQUAL</span><span class="p">)</span>
<span class="n">glHint</span><span class="p">(</span><span class="n">GL_PERSPECTIVE_CORRECTION_HINT</span><span class="p">,</span> <span class="n">GL_NICEST</span><span class="p">)</span>
<span class="n">glClear</span><span class="p">(</span><span class="n">GL_COLOR_BUFFER_BIT</span> <span class="o">|</span> <span class="n">GL_DEPTH_BUFFER_BIT</span><span class="p">)</span>
<span class="k">func</span> <span class="n">Cubes</span>
<span class="n">cube</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="o">-</span><span class="mf">3.4</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">,:</span><span class="n">sky1</span><span class="p">)</span>
<span class="n">cube</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="o">-</span><span class="mi">3</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">,:</span><span class="n">sky1</span><span class="p">)</span>
<span class="n">cube</span><span class="p">(</span><span class="o">-</span><span class="mi">5</span><span class="p">,</span><span class="o">-</span><span class="mi">3</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">,:</span><span class="n">sky1</span><span class="p">)</span>
<span class="n">cube</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mf">0.5</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">,:</span><span class="n">sky2</span><span class="p">)</span>
<span class="n">cube</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mf">0.5</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">,:</span><span class="n">sky2</span><span class="p">)</span>
<span class="n">cube</span><span class="p">(</span><span class="o">-</span><span class="mi">5</span><span class="p">,</span><span class="mf">0.5</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">,:</span><span class="n">sky2</span><span class="p">)</span>
<span class="n">cube</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">,:</span><span class="n">sky3</span><span class="p">)</span>
<span class="n">cube</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">,:</span><span class="n">sky3</span><span class="p">)</span>
<span class="n">cube</span><span class="p">(</span><span class="o">-</span><span class="mi">5</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="o">-</span><span class="mi">5</span><span class="p">,:</span><span class="n">sky3</span><span class="p">)</span>
<span class="k">func</span> <span class="n">Rotate</span>
<span class="n">xrot</span> <span class="o">+=</span> <span class="mf">0.3</span> <span class="o">*</span> <span class="mi">5</span>
<span class="n">yrot</span> <span class="o">+=</span> <span class="mf">0.2</span> <span class="o">*</span> <span class="mi">5</span>
<span class="n">zrot</span> <span class="o">+=</span> <span class="mf">0.4</span> <span class="o">*</span> <span class="mi">5</span>
<span class="n">nPerspective</span> <span class="o">+=</span> <span class="mf">0.5</span>
<span class="k">func</span> <span class="n">cube</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="n">z</span><span class="p">,</span><span class="n">nTexture</span><span class="p">)</span>
<span class="n">glLoadIdentity</span><span class="p">()</span>
<span class="n">glTranslatef</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="n">z</span><span class="p">)</span>
<span class="n">glRotatef</span><span class="p">(</span><span class="n">xrot</span><span class="p">,</span><span class="mf">1.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">)</span>
<span class="n">glRotatef</span><span class="p">(</span><span class="n">yrot</span><span class="p">,</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">1.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">)</span>
<span class="n">glRotatef</span><span class="p">(</span><span class="n">zrot</span><span class="p">,</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">drawcube</span><span class="p">(</span><span class="n">nTexture</span><span class="p">)</span>
<span class="k">func</span> <span class="n">drawcube</span><span class="p">(</span><span class="n">cTexture</span><span class="p">)</span>
<span class="k">switch</span> <span class="n">cTexture</span>
<span class="k">on</span> <span class="p">:</span><span class="n">sky1</span>
<span class="n">glBindTexture</span><span class="p">(</span><span class="n">GL_TEXTURE_2D</span><span class="p">,</span> <span class="n">texture</span><span class="p">)</span>
<span class="k">on</span> <span class="p">:</span><span class="n">sky2</span>
<span class="n">glBindTexture</span><span class="p">(</span><span class="n">GL_TEXTURE_2D</span><span class="p">,</span> <span class="n">texture2</span><span class="p">)</span>
<span class="k">on</span> <span class="p">:</span><span class="n">sky3</span>
<span class="n">glBindTexture</span><span class="p">(</span><span class="n">GL_TEXTURE_2D</span><span class="p">,</span> <span class="n">texture3</span><span class="p">)</span>
<span class="k">off</span>
<span class="n">glBegin</span><span class="p">(</span><span class="n">GL_QUADS</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Front</span> <span class="n">Face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Back</span> <span class="n">Face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Top</span> <span class="n">Face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Bottom</span> <span class="n">Face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Right</span> <span class="n">face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Left</span> <span class="n">Face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glEnd</span><span class="p">()</span>
<span class="k">class</span> <span class="n">GraphicsAppBase</span>
<span class="n">display</span> <span class="n">event_queue</span> <span class="n">ev</span> <span class="n">timeout</span>
<span class="n">timer</span> <span class="n">redraw</span> <span class="o">=</span> <span class="kp">true</span>
<span class="n">FPS</span> <span class="o">=</span> <span class="mi">60</span>
<span class="n">SCREEN_W</span> <span class="o">=</span> <span class="mi">800</span>
<span class="n">SCREEN_H</span> <span class="o">=</span> <span class="mi">600</span>
<span class="n">KEY_UP</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">KEY_DOWN</span> <span class="o">=</span> <span class="mi">2</span>
<span class="n">KEY_LEFT</span> <span class="o">=</span> <span class="mi">3</span>
<span class="n">KEY_RIGHT</span> <span class="o">=</span> <span class="mi">4</span>
<span class="n">Key</span> <span class="o">=</span> <span class="o">[</span><span class="kp">false</span><span class="p">,</span><span class="kp">false</span><span class="p">,</span><span class="kp">false</span><span class="p">,</span><span class="kp">false</span><span class="o">]</span>
<span class="n">TITLE</span> <span class="o">=</span> <span class="s">"Graphics Application"</span>
<span class="k">func</span> <span class="n">start</span>
<span class="n">SetUp</span><span class="p">()</span>
<span class="n">loadResources</span><span class="p">()</span>
<span class="n">eventsLoop</span><span class="p">()</span>
<span class="n">destroy</span><span class="p">()</span>
<span class="k">func</span> <span class="n">setup</span>
<span class="n">al_init</span><span class="p">()</span>
<span class="n">al_init_image_addon</span><span class="p">()</span>
<span class="n">al_set_new_display_flags</span><span class="p">(</span><span class="n">ALLEGRO_OPENGL</span><span class="p">)</span>
<span class="n">display</span> <span class="o">=</span> <span class="n">al_create_display</span><span class="p">(</span><span class="n">SCREEN_W</span><span class="p">,</span><span class="n">SCREEN_H</span><span class="p">)</span>
<span class="n">al_set_Window_title</span><span class="p">(</span><span class="n">display</span><span class="p">,</span><span class="n">TITLE</span><span class="p">)</span>
<span class="n">al_clear_to_color</span><span class="p">(</span><span class="n">al_map_rgb</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">))</span>
<span class="n">event_queue</span> <span class="o">=</span> <span class="n">al_create_event_queue</span><span class="p">()</span>
<span class="n">al_register_event_source</span><span class="p">(</span><span class="n">event_queue</span><span class="p">,</span>
<span class="n">al_get_display_event_source</span><span class="p">(</span><span class="n">display</span><span class="p">))</span>
<span class="n">ev</span> <span class="o">=</span> <span class="n">al_new_allegro_event</span><span class="p">()</span>
<span class="n">timeout</span> <span class="o">=</span> <span class="n">al_new_allegro_timeout</span><span class="p">()</span>
<span class="n">al_init_timeout</span><span class="p">(</span><span class="n">timeout</span><span class="p">,</span> <span class="mf">0.06</span><span class="p">)</span>
<span class="n">timer</span> <span class="o">=</span> <span class="n">al_create_timer</span><span class="p">(</span><span class="mf">1.0</span> <span class="o">/</span> <span class="n">FPS</span><span class="p">)</span>
<span class="n">al_register_event_source</span><span class="p">(</span><span class="n">event_queue</span><span class="p">,</span>
<span class="n">al_get_timer_event_source</span><span class="p">(</span><span class="n">timer</span><span class="p">))</span>
<span class="n">al_start_timer</span><span class="p">(</span><span class="n">timer</span><span class="p">)</span>
<span class="n">al_install_mouse</span><span class="p">()</span>
<span class="n">al_register_event_source</span><span class="p">(</span><span class="n">event_queue</span><span class="p">,</span>
<span class="n">al_get_mouse_event_source</span><span class="p">())</span>
<span class="n">al_install_keyboard</span><span class="p">()</span>
<span class="n">al_register_event_source</span><span class="p">(</span><span class="n">event_queue</span><span class="p">,</span>
<span class="n">al_get_keyboard_event_source</span><span class="p">())</span>
<span class="k">func</span> <span class="n">eventsLoop</span>
<span class="k">while</span> <span class="kp">true</span>
<span class="n">al_init_timeout</span><span class="p">(</span><span class="n">timeout</span><span class="p">,</span> <span class="mf">0.06</span><span class="p">)</span>
<span class="n">al_wait_for_event_until</span><span class="p">(</span><span class="n">event_queue</span><span class="p">,</span> <span class="n">ev</span><span class="p">,</span> <span class="n">timeout</span><span class="p">)</span>
<span class="k">switch</span> <span class="n">al_get_allegro_event_type</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_DISPLAY_CLOSE</span>
<span class="k">exit</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_TIMER</span>
<span class="n">redraw</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_MOUSE_AXES</span>
<span class="n">mouse_x</span> <span class="o">=</span> <span class="n">al_get_allegro_event_mouse_x</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="n">mouse_y</span> <span class="o">=</span> <span class="n">al_get_allegro_event_mouse_y</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY</span>
<span class="n">mouse_x</span> <span class="o">=</span> <span class="n">al_get_allegro_event_mouse_x</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="n">mouse_y</span> <span class="o">=</span> <span class="n">al_get_allegro_event_mouse_y</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_MOUSE_BUTTON_UP</span>
<span class="k">exit</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_KEY_DOWN</span>
<span class="k">switch</span> <span class="n">al_get_allegro_event_keyboard_keycode</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_UP</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_UP</span><span class="o">]</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_DOWN</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_DOWN</span><span class="o">]</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_LEFT</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_LEFT</span><span class="o">]</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_RIGHT</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_RIGHT</span><span class="o">]</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">off</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_KEY_UP</span>
<span class="k">switch</span> <span class="n">al_get_allegro_event_keyboard_keycode</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_UP</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_UP</span><span class="o">]</span> <span class="o">=</span> <span class="kp">false</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_DOWN</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_DOWN</span><span class="o">]</span> <span class="o">=</span> <span class="kp">false</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_LEFT</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_LEFT</span><span class="o">]</span> <span class="o">=</span> <span class="kp">false</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_RIGHT</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_RIGHT</span><span class="o">]</span> <span class="o">=</span> <span class="kp">false</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_ESCAPE</span>
<span class="k">exit</span>
<span class="k">off</span>
<span class="k">off</span>
<span class="k">if</span> <span class="n">redraw</span> <span class="ow">and</span> <span class="n">al_is_event_queue_empty</span><span class="p">(</span><span class="n">event_queue</span><span class="p">)</span>
<span class="n">redraw</span> <span class="o">=</span> <span class="kp">false</span>
<span class="n">drawScene</span><span class="p">()</span>
<span class="n">al_flip_display</span><span class="p">()</span>
<span class="k">ok</span>
<span class="n">callgc</span><span class="p">()</span>
<span class="k">end</span>
<span class="k">func</span> <span class="n">destroy</span>
<span class="n">destroyResources</span><span class="p">()</span>
<span class="n">al_destroy_timer</span><span class="p">(</span><span class="n">timer</span><span class="p">)</span>
<span class="n">al_destroy_allegro_event</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="n">al_destroy_allegro_timeout</span><span class="p">(</span><span class="n">timeout</span><span class="p">)</span>
<span class="n">al_destroy_event_queue</span><span class="p">(</span><span class="n">event_queue</span><span class="p">)</span>
<span class="n">al_destroy_display</span><span class="p">(</span><span class="n">display</span><span class="p">)</span>
<span class="n">al_exit</span><span class="p">()</span>
<span class="k">func</span> <span class="n">loadresources</span>
<span class="k">func</span> <span class="n">drawScene</span>
<span class="k">func</span> <span class="n">destroyResources</span>
</pre></div>
</div>
<p>Screen Shot:</p>
<img alt="Many Cubes" src="_images/manycubes.png" />
</div>
<div class="section" id="tictactoe-3d-game">
<span id="index-3"></span><h2>TicTacToe 3D Game<a class="headerlink" href="#tictactoe-3d-game" title="Permalink to this headline">¶</a></h2>
<p>Source Code:</p>
<div class="highlight-ring notranslate"><div class="highlight"><pre><span></span><span class="c"># Load Libraries</span>
<span class="k">load</span> <span class="s">"gamelib.ring"</span> <span class="c"># RingAllegro Library</span>
<span class="k">load</span> <span class="s">"opengl21lib.ring"</span> <span class="c"># RingOpenGL Library</span>
<span class="c">#==============================================================</span>
<span class="c"># To Support MacOS X</span>
<span class="n">al_run_main</span><span class="p">()</span>
<span class="k">func</span> <span class="n">al_game_start</span> <span class="c"># Called by al_run_main()</span>
<span class="n">main</span><span class="p">()</span> <span class="c"># Now we call our main function</span>
<span class="c">#==============================================================</span>
<span class="k">func</span> <span class="n">main</span>
<span class="k">new</span> <span class="n">TicTacToe3D</span> <span class="p">{</span>
<span class="n">start</span><span class="p">()</span>
<span class="p">}</span>
<span class="k">class</span> <span class="n">TicTacToe3D</span> <span class="k">from</span> <span class="n">GameLogic</span>
<span class="n">FPS</span> <span class="o">=</span> <span class="mi">60</span>
<span class="n">TITLE</span> <span class="o">=</span> <span class="s">"TicTacToe 3D"</span>
<span class="n">oBackground</span> <span class="o">=</span> <span class="k">new</span> <span class="n">GameBackground</span>
<span class="n">oGameSound</span> <span class="o">=</span> <span class="k">new</span> <span class="n">GameSound</span>
<span class="n">oGameCube</span> <span class="o">=</span> <span class="k">new</span> <span class="n">GameCube</span>
<span class="n">oGameOver</span> <span class="o">=</span> <span class="k">new</span> <span class="n">GameOver</span>
<span class="n">oGameInterface</span> <span class="o">=</span> <span class="k">new</span> <span class="n">GameInterface</span>
<span class="k">func</span> <span class="n">loadresources</span>
<span class="n">oGameOver</span><span class="p">.</span><span class="n">loadresources</span><span class="p">()</span>
<span class="n">oGameSound</span><span class="p">.</span><span class="n">loadresources</span><span class="p">()</span>
<span class="n">oBackGround</span><span class="p">.</span><span class="n">loadresources</span><span class="p">()</span>
<span class="n">oGameCube</span><span class="p">.</span><span class="n">loadresources</span><span class="p">()</span>
<span class="k">func</span> <span class="n">destroyResources</span>
<span class="n">oGameOver</span><span class="p">.</span><span class="n">destroyResources</span><span class="p">()</span>
<span class="n">oGameSound</span><span class="p">.</span><span class="n">destroyResources</span><span class="p">()</span>
<span class="n">oBackGround</span><span class="p">.</span><span class="n">destroyResources</span><span class="p">()</span>
<span class="n">oGameCube</span><span class="p">.</span><span class="n">destroyResources</span><span class="p">()</span>
<span class="k">func</span> <span class="n">drawScene</span>
<span class="n">oBackground</span><span class="p">.</span><span class="n">update</span><span class="p">()</span>
<span class="n">oGameInterface</span><span class="p">.</span><span class="n">update</span><span class="p">(</span><span class="n">self</span><span class="p">)</span>
<span class="k">func</span> <span class="n">MouseClickEvent</span>
<span class="n">oGameInterface</span><span class="p">.</span><span class="n">MouseClickEvent</span><span class="p">(</span><span class="n">self</span><span class="p">)</span>
<span class="k">class</span> <span class="n">GameInterface</span>
<span class="k">func</span> <span class="n">Update</span> <span class="n">oGame</span>
<span class="n">prepare</span><span class="p">()</span>
<span class="n">cubes</span><span class="p">(</span><span class="n">oGame</span><span class="p">)</span>
<span class="k">func</span> <span class="n">Prepare</span>
<span class="n">w</span> <span class="o">=</span> <span class="mi">1024</span> <span class="n">h</span> <span class="o">=</span> <span class="mi">768</span>
<span class="n">ratio</span> <span class="o">=</span> <span class="n">w</span> <span class="o">/</span> <span class="n">h</span>
<span class="n">glViewport</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">w</span><span class="p">,</span> <span class="n">h</span><span class="p">)</span>
<span class="n">glMatrixMode</span><span class="p">(</span><span class="n">GL_PROJECTION</span><span class="p">)</span>
<span class="n">glLoadIdentity</span><span class="p">()</span>
<span class="n">gluPerspective</span><span class="p">(</span><span class="o">-</span><span class="mi">120</span><span class="p">,</span><span class="n">ratio</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">120</span><span class="p">)</span>
<span class="n">glMatrixMode</span><span class="p">(</span><span class="n">GL_MODELVIEW</span><span class="p">)</span>
<span class="n">glLoadIdentity</span><span class="p">()</span>
<span class="n">glEnable</span><span class="p">(</span><span class="n">GL_TEXTURE_2D</span><span class="p">)</span>
<span class="n">glShadeModel</span><span class="p">(</span><span class="n">GL_SMOOTH</span><span class="p">)</span>
<span class="n">glClearColor</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span>
<span class="n">glClearDepth</span><span class="p">(</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glEnable</span><span class="p">(</span><span class="n">GL_DEPTH_TEST</span><span class="p">)</span>
<span class="n">glEnable</span><span class="p">(</span><span class="n">GL_CULL_FACE</span><span class="p">)</span>
<span class="n">glDepthFunc</span><span class="p">(</span><span class="n">GL_LEQUAL</span><span class="p">)</span>
<span class="n">glHint</span><span class="p">(</span><span class="n">GL_PERSPECTIVE_CORRECTION_HINT</span><span class="p">,</span> <span class="n">GL_NICEST</span><span class="p">)</span>
<span class="k">func</span> <span class="n">Cubes</span> <span class="n">oGame</span>
<span class="n">oGame</span><span class="p">.</span><span class="n">oGameCube</span> <span class="p">{</span>
<span class="n">aGameMap</span> <span class="o">=</span> <span class="n">oGame</span><span class="p">.</span><span class="n">aGameMap</span>
<span class="n">cube</span><span class="p">(</span> <span class="mi">5</span> <span class="p">,</span> <span class="o">-</span><span class="mi">3</span> <span class="p">,</span> <span class="o">-</span><span class="mi">5</span> <span class="p">,</span> <span class="n">aGameMap</span><span class="o">[</span><span class="mi">1</span><span class="o">][</span><span class="mi">1</span><span class="o">]</span> <span class="p">)</span>
<span class="n">cube</span><span class="p">(</span> <span class="mi">0</span> <span class="p">,</span> <span class="o">-</span><span class="mi">3</span> <span class="p">,</span> <span class="o">-</span><span class="mi">5</span> <span class="p">,</span> <span class="n">aGameMap</span><span class="o">[</span><span class="mi">1</span><span class="o">][</span><span class="mi">2</span><span class="o">]</span> <span class="p">)</span>
<span class="n">cube</span><span class="p">(</span> <span class="o">-</span><span class="mi">5</span> <span class="p">,</span> <span class="o">-</span><span class="mi">3</span> <span class="p">,</span> <span class="o">-</span><span class="mi">5</span> <span class="p">,</span> <span class="n">aGameMap</span><span class="o">[</span><span class="mi">1</span><span class="o">][</span><span class="mi">3</span><span class="o">]</span> <span class="p">)</span>
<span class="n">cube</span><span class="p">(</span> <span class="mi">5</span> <span class="p">,</span> <span class="mi">1</span> <span class="p">,</span> <span class="o">-</span><span class="mi">5</span> <span class="p">,</span> <span class="n">aGameMap</span><span class="o">[</span><span class="mi">2</span><span class="o">][</span><span class="mi">1</span><span class="o">]</span> <span class="p">)</span>
<span class="n">cube</span><span class="p">(</span> <span class="mi">0</span> <span class="p">,</span> <span class="mi">1</span> <span class="p">,</span> <span class="o">-</span><span class="mi">5</span> <span class="p">,</span> <span class="n">aGameMap</span><span class="o">[</span><span class="mi">2</span><span class="o">][</span><span class="mi">2</span><span class="o">]</span> <span class="p">)</span>
<span class="n">cube</span><span class="p">(</span> <span class="o">-</span><span class="mi">5</span> <span class="p">,</span> <span class="mi">1</span> <span class="p">,</span> <span class="o">-</span><span class="mi">5</span> <span class="p">,</span> <span class="n">aGameMap</span><span class="o">[</span><span class="mi">2</span><span class="o">][</span><span class="mi">3</span><span class="o">]</span> <span class="p">)</span>
<span class="n">cube</span><span class="p">(</span> <span class="mi">5</span> <span class="p">,</span> <span class="mi">5</span> <span class="p">,</span> <span class="o">-</span><span class="mi">5</span> <span class="p">,</span> <span class="n">aGameMap</span><span class="o">[</span><span class="mi">3</span><span class="o">][</span><span class="mi">1</span><span class="o">]</span> <span class="p">)</span>
<span class="n">cube</span><span class="p">(</span> <span class="mi">0</span> <span class="p">,</span> <span class="mi">5</span> <span class="p">,</span> <span class="o">-</span><span class="mi">5</span> <span class="p">,</span> <span class="n">aGameMap</span><span class="o">[</span><span class="mi">3</span><span class="o">][</span><span class="mi">2</span><span class="o">]</span> <span class="p">)</span>
<span class="n">cube</span><span class="p">(</span> <span class="o">-</span><span class="mi">5</span> <span class="p">,</span> <span class="mi">5</span> <span class="p">,</span> <span class="o">-</span><span class="mi">5</span> <span class="p">,</span> <span class="n">aGameMap</span><span class="o">[</span><span class="mi">3</span><span class="o">][</span><span class="mi">3</span><span class="o">]</span> <span class="p">)</span>
<span class="n">rotate</span><span class="p">()</span>
<span class="p">}</span>
<span class="k">func</span> <span class="n">MouseClickEvent</span> <span class="n">oGame</span>
<span class="n">oGame</span> <span class="p">{</span>
<span class="n">aBtn</span> <span class="o">=</span> <span class="n">Point2Button</span><span class="p">(</span><span class="n">Mouse_X</span><span class="p">,</span><span class="n">Mouse_Y</span><span class="p">)</span>
<span class="n">nRow</span> <span class="o">=</span> <span class="n">aBtn</span><span class="o">[</span><span class="mi">1</span><span class="o">]</span>
<span class="n">nCol</span> <span class="o">=</span> <span class="n">aBtn</span><span class="o">[</span><span class="mi">2</span><span class="o">]</span>
<span class="k">if</span> <span class="n">nRow</span> <span class="o">!=</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">nCol</span> <span class="o">!=</span> <span class="mi">0</span>
<span class="k">if</span> <span class="n">aGameMap</span><span class="o">[</span><span class="n">nRow</span><span class="o">][</span><span class="n">nCol</span><span class="o">]</span> <span class="o">=</span> <span class="p">:</span><span class="n">n</span>
<span class="n">aGameMap</span><span class="o">[</span><span class="n">nRow</span><span class="o">][</span><span class="n">nCol</span><span class="o">]</span> <span class="o">=</span> <span class="n">cActivePlayer</span>
<span class="n">ChangeActivePlayer</span><span class="p">()</span>
<span class="n">CheckGameOver</span><span class="p">()</span>
<span class="k">ok</span>
<span class="k">ok</span>
<span class="p">}</span>
<span class="k">Class</span> <span class="n">GameLogic</span> <span class="k">from</span> <span class="n">GraphicsAppBase</span>
<span class="n">aGameMap</span> <span class="o">=</span> <span class="o">[</span>
<span class="o">[</span> <span class="p">:</span><span class="n">n</span> <span class="p">,</span> <span class="p">:</span><span class="n">n</span> <span class="p">,</span> <span class="p">:</span><span class="n">n</span> <span class="o">]</span> <span class="p">,</span>
<span class="o">[</span> <span class="p">:</span><span class="n">n</span> <span class="p">,</span> <span class="p">:</span><span class="n">n</span> <span class="p">,</span> <span class="p">:</span><span class="n">n</span> <span class="o">]</span> <span class="p">,</span>
<span class="o">[</span> <span class="p">:</span><span class="n">n</span> <span class="p">,</span> <span class="p">:</span><span class="n">n</span> <span class="p">,</span> <span class="p">:</span><span class="n">n</span> <span class="o">]</span>
<span class="o">]</span>
<span class="n">aGameButtons</span> <span class="o">=</span> <span class="o">[</span> <span class="c"># x1,y1,x2,y2</span>
<span class="o">[</span><span class="mi">176</span><span class="p">,</span><span class="mi">88</span><span class="p">,</span><span class="mi">375</span><span class="p">,</span><span class="mi">261</span><span class="o">]</span><span class="p">,</span> <span class="c"># [1,1]</span>
<span class="o">[</span><span class="mi">423</span><span class="p">,</span><span class="mi">88</span><span class="p">,</span><span class="mi">591</span><span class="p">,</span><span class="mi">261</span><span class="o">]</span><span class="p">,</span> <span class="c"># [1,2]</span>
<span class="o">[</span><span class="mi">645</span><span class="p">,</span><span class="mi">88</span><span class="p">,</span><span class="mi">876</span><span class="p">,</span><span class="mi">261</span><span class="o">]</span><span class="p">,</span> <span class="c"># [1,3]</span>
<span class="o">[</span><span class="mi">176</span><span class="p">,</span><span class="mi">282</span><span class="p">,</span><span class="mi">375</span><span class="p">,</span><span class="mi">428</span><span class="o">]</span><span class="p">,</span> <span class="c"># [2,1]</span>
<span class="o">[</span><span class="mi">423</span><span class="p">,</span><span class="mi">282</span><span class="p">,</span><span class="mi">591</span><span class="p">,</span><span class="mi">428</span><span class="o">]</span><span class="p">,</span> <span class="c"># [2,2]</span>
<span class="o">[</span><span class="mi">645</span><span class="p">,</span><span class="mi">282</span><span class="p">,</span><span class="mi">876</span><span class="p">,</span><span class="mi">428</span><span class="o">]</span><span class="p">,</span> <span class="c"># [2,3]</span>
<span class="o">[</span><span class="mi">176</span><span class="p">,</span><span class="mi">454</span><span class="p">,</span><span class="mi">375</span><span class="p">,</span><span class="mi">678</span><span class="o">]</span><span class="p">,</span> <span class="c"># [3,1]</span>
<span class="o">[</span><span class="mi">423</span><span class="p">,</span><span class="mi">454</span><span class="p">,</span><span class="mi">591</span><span class="p">,</span><span class="mi">678</span><span class="o">]</span><span class="p">,</span> <span class="c"># [3,2]</span>
<span class="o">[</span><span class="mi">645</span><span class="p">,</span><span class="mi">454</span><span class="p">,</span><span class="mi">876</span><span class="p">,</span><span class="mi">678</span><span class="o">]</span> <span class="c"># [3,3]</span>
<span class="o">]</span>
<span class="n">cActivePlayer</span> <span class="o">=</span> <span class="p">:</span><span class="n">x</span>
<span class="k">func</span> <span class="n">point2button</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span>
<span class="n">nRow</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">nCol</span> <span class="o">=</span> <span class="mi">0</span>
<span class="k">for</span> <span class="n">t</span> <span class="o">=</span> <span class="mi">1</span> <span class="k">to</span> <span class="n">len</span><span class="p">(</span><span class="n">aGameButtons</span><span class="p">)</span>
<span class="n">rect</span> <span class="o">=</span> <span class="n">aGameButtons</span><span class="o">[</span><span class="n">t</span><span class="o">]</span>
<span class="k">if</span> <span class="n">x</span> <span class="o">>=</span> <span class="n">rect</span><span class="o">[</span><span class="mi">1</span><span class="o">]</span> <span class="ow">and</span> <span class="n">x</span> <span class="o"><=</span> <span class="n">rect</span><span class="o">[</span><span class="mi">3</span><span class="o">]</span> <span class="ow">and</span>
<span class="n">y</span> <span class="o">>=</span> <span class="n">rect</span><span class="o">[</span><span class="mi">2</span><span class="o">]</span> <span class="ow">and</span> <span class="n">y</span> <span class="o"><=</span> <span class="n">rect</span><span class="o">[</span><span class="mi">4</span><span class="o">]</span>
<span class="k">switch</span> <span class="n">t</span>
<span class="k">on</span> <span class="mi">1</span> <span class="n">nRow</span> <span class="o">=</span> <span class="mi">1</span> <span class="n">nCol</span> <span class="o">=</span> <span class="mi">1</span>
<span class="k">on</span> <span class="mi">2</span> <span class="n">nRow</span> <span class="o">=</span> <span class="mi">1</span> <span class="n">nCol</span> <span class="o">=</span> <span class="mi">2</span>
<span class="k">on</span> <span class="mi">3</span> <span class="n">nRow</span> <span class="o">=</span> <span class="mi">1</span> <span class="n">nCol</span> <span class="o">=</span> <span class="mi">3</span>
<span class="k">on</span> <span class="mi">4</span> <span class="n">nRow</span> <span class="o">=</span> <span class="mi">2</span> <span class="n">nCol</span> <span class="o">=</span> <span class="mi">1</span>
<span class="k">on</span> <span class="mi">5</span> <span class="n">nRow</span> <span class="o">=</span> <span class="mi">2</span> <span class="n">nCol</span> <span class="o">=</span> <span class="mi">2</span>
<span class="k">on</span> <span class="mi">6</span> <span class="n">nRow</span> <span class="o">=</span> <span class="mi">2</span> <span class="n">nCol</span> <span class="o">=</span> <span class="mi">3</span>
<span class="k">on</span> <span class="mi">7</span> <span class="n">nRow</span> <span class="o">=</span> <span class="mi">3</span> <span class="n">nCol</span> <span class="o">=</span> <span class="mi">1</span>
<span class="k">on</span> <span class="mi">8</span> <span class="n">nRow</span> <span class="o">=</span> <span class="mi">3</span> <span class="n">nCol</span> <span class="o">=</span> <span class="mi">2</span>
<span class="k">on</span> <span class="mi">9</span> <span class="n">nRow</span> <span class="o">=</span> <span class="mi">3</span> <span class="n">nCol</span> <span class="o">=</span> <span class="mi">3</span>
<span class="k">off</span>
<span class="k">exit</span>
<span class="k">ok</span>
<span class="k">next</span>
<span class="k">return</span> <span class="o">[</span><span class="n">nRow</span><span class="p">,</span><span class="n">nCol</span><span class="o">]</span>
<span class="k">func</span> <span class="n">ChangeActivePlayer</span><span class="p">()</span>
<span class="k">if</span> <span class="n">cActivePlayer</span> <span class="o">=</span> <span class="p">:</span><span class="n">x</span>
<span class="n">cActivePlayer</span> <span class="o">=</span> <span class="p">:</span><span class="n">o</span>
<span class="k">else</span>
<span class="n">cActivePlayer</span> <span class="o">=</span> <span class="p">:</span><span class="n">x</span>
<span class="k">ok</span>
<span class="k">func</span> <span class="n">CheckGameOver</span>
<span class="n">aList</span> <span class="o">=</span> <span class="o">[</span>
<span class="n">aGameMap</span><span class="o">[</span><span class="mi">1</span><span class="o">][</span><span class="mi">1</span><span class="o">]</span><span class="p">,</span>
<span class="n">aGameMap</span><span class="o">[</span><span class="mi">1</span><span class="o">][</span><span class="mi">2</span><span class="o">]</span><span class="p">,</span>
<span class="n">aGameMap</span><span class="o">[</span><span class="mi">1</span><span class="o">][</span><span class="mi">3</span><span class="o">]</span><span class="p">,</span>
<span class="n">aGameMap</span><span class="o">[</span><span class="mi">2</span><span class="o">][</span><span class="mi">1</span><span class="o">]</span><span class="p">,</span>
<span class="n">aGameMap</span><span class="o">[</span><span class="mi">2</span><span class="o">][</span><span class="mi">2</span><span class="o">]</span><span class="p">,</span>
<span class="n">aGameMap</span><span class="o">[</span><span class="mi">2</span><span class="o">][</span><span class="mi">3</span><span class="o">]</span><span class="p">,</span>
<span class="n">aGameMap</span><span class="o">[</span><span class="mi">3</span><span class="o">][</span><span class="mi">1</span><span class="o">]</span><span class="p">,</span>
<span class="n">aGameMap</span><span class="o">[</span><span class="mi">3</span><span class="o">][</span><span class="mi">2</span><span class="o">]</span><span class="p">,</span>
<span class="n">aGameMap</span><span class="o">[</span><span class="mi">3</span><span class="o">][</span><span class="mi">3</span><span class="o">]</span>
<span class="o">]</span>
<span class="k">for</span> <span class="n">item</span> <span class="k">in</span> <span class="n">aList</span>
<span class="k">switch</span> <span class="n">item</span>
<span class="k">on</span> <span class="p">:</span><span class="n">x</span> <span class="n">item</span> <span class="o">=</span> <span class="mi">1</span>
<span class="k">on</span> <span class="p">:</span><span class="n">o</span> <span class="n">item</span> <span class="o">=</span> <span class="mi">2</span>
<span class="k">on</span> <span class="p">:</span><span class="n">n</span> <span class="n">item</span> <span class="o">=</span> <span class="mi">0</span>
<span class="k">off</span>
<span class="k">next</span>
<span class="n">nStatus</span> <span class="o">=</span> <span class="n">CheckWinner</span><span class="p">(</span><span class="n">aList</span><span class="p">)</span>
<span class="k">if</span> <span class="n">nStatus</span>
<span class="n">oGameOver</span> <span class="p">{</span>
<span class="k">Switch</span> <span class="n">nStatus</span>
<span class="k">on</span> <span class="mi">1</span> <span class="n">Player1Win</span><span class="p">(</span><span class="n">this</span><span class="p">)</span>
<span class="k">on</span> <span class="mi">2</span> <span class="n">Player2Win</span><span class="p">(</span><span class="n">this</span><span class="p">)</span>
<span class="k">on</span> <span class="mi">3</span> <span class="n">NoOneWin</span><span class="p">(</span><span class="n">this</span><span class="p">)</span>
<span class="k">off</span>
<span class="p">}</span>
<span class="n">refreshGame</span><span class="p">()</span>
<span class="k">ok</span>
<span class="k">func</span> <span class="n">refreshGame</span>
<span class="n">aGameMap</span> <span class="o">=</span> <span class="o">[</span>
<span class="o">[</span> <span class="p">:</span><span class="n">n</span> <span class="p">,</span> <span class="p">:</span><span class="n">n</span> <span class="p">,</span> <span class="p">:</span><span class="n">n</span> <span class="o">]</span> <span class="p">,</span>
<span class="o">[</span> <span class="p">:</span><span class="n">n</span> <span class="p">,</span> <span class="p">:</span><span class="n">n</span> <span class="p">,</span> <span class="p">:</span><span class="n">n</span> <span class="o">]</span> <span class="p">,</span>
<span class="o">[</span> <span class="p">:</span><span class="n">n</span> <span class="p">,</span> <span class="p">:</span><span class="n">n</span> <span class="p">,</span> <span class="p">:</span><span class="n">n</span> <span class="o">]</span>
<span class="o">]</span>
<span class="n">cActivePlayer</span> <span class="o">=</span> <span class="p">:</span><span class="n">x</span>
<span class="k">func</span> <span class="n">CheckWinner</span> <span class="n">lst</span>
<span class="o">//</span><span class="n">vertical</span> <span class="n">check</span>
<span class="k">for</span> <span class="n">v</span><span class="o">=</span><span class="mi">1</span> <span class="k">to</span> <span class="mi">9</span> <span class="k">step</span> <span class="mi">3</span>
<span class="k">if</span> <span class="n">lst</span><span class="o">[</span><span class="n">v</span><span class="o">]!=</span><span class="mi">0</span> <span class="ow">and</span> <span class="n">lst</span><span class="o">[</span><span class="n">v</span><span class="o">+</span><span class="mi">1</span><span class="o">]!=</span><span class="mi">0</span> <span class="ow">and</span> <span class="n">lst</span><span class="o">[</span><span class="n">v</span><span class="o">+</span><span class="mi">2</span><span class="o">]!=</span><span class="mi">0</span>
<span class="k">if</span> <span class="n">lst</span><span class="o">[</span><span class="n">v</span><span class="o">]=</span><span class="n">lst</span><span class="o">[</span><span class="n">v</span><span class="o">+</span><span class="mi">1</span><span class="o">]</span> <span class="ow">and</span> <span class="n">lst</span><span class="o">[</span><span class="n">v</span><span class="o">+</span><span class="mi">1</span><span class="o">]=</span><span class="n">lst</span><span class="o">[</span><span class="n">v</span><span class="o">+</span><span class="mi">2</span><span class="o">]</span>
<span class="k">return</span> <span class="n">lst</span><span class="o">[</span><span class="n">v</span><span class="o">]</span>
<span class="k">ok</span>
<span class="k">ok</span>
<span class="k">next</span>
<span class="o">//</span><span class="n">horizontal</span>
<span class="k">for</span> <span class="n">h</span><span class="o">=</span><span class="mi">1</span> <span class="k">to</span> <span class="mi">3</span>
<span class="k">if</span> <span class="n">lst</span><span class="o">[</span><span class="n">h</span><span class="o">]!=</span><span class="mi">0</span> <span class="ow">and</span> <span class="n">lst</span><span class="o">[</span><span class="n">h</span><span class="o">+</span><span class="mi">3</span><span class="o">]!=</span><span class="mi">0</span> <span class="ow">and</span> <span class="n">lst</span><span class="o">[</span><span class="n">h</span><span class="o">+</span><span class="mi">6</span><span class="o">]!=</span><span class="mi">0</span>
<span class="k">if</span> <span class="n">lst</span><span class="o">[</span><span class="n">h</span><span class="o">]=</span><span class="n">lst</span><span class="o">[</span><span class="n">h</span><span class="o">+</span><span class="mi">3</span><span class="o">]</span> <span class="ow">and</span> <span class="n">lst</span><span class="o">[</span><span class="n">h</span><span class="o">+</span><span class="mi">3</span><span class="o">]=</span><span class="n">lst</span><span class="o">[</span><span class="n">h</span><span class="o">+</span><span class="mi">6</span><span class="o">]</span>
<span class="k">return</span> <span class="n">lst</span><span class="o">[</span><span class="n">h</span><span class="o">]</span>
<span class="k">ok</span>
<span class="k">ok</span>
<span class="k">next</span>
<span class="o">//</span><span class="n">Cross</span>
<span class="k">if</span> <span class="n">lst</span><span class="o">[</span><span class="mi">1</span><span class="o">]!=</span><span class="mi">0</span> <span class="ow">and</span> <span class="n">lst</span><span class="o">[</span><span class="mi">5</span><span class="o">]!=</span><span class="mi">0</span> <span class="ow">and</span> <span class="n">lst</span><span class="o">[</span><span class="mi">9</span><span class="o">]!=</span><span class="mi">0</span>
<span class="k">if</span> <span class="n">lst</span><span class="o">[</span><span class="mi">1</span><span class="o">]=</span><span class="n">lst</span><span class="o">[</span><span class="mi">5</span><span class="o">]</span> <span class="ow">and</span> <span class="n">lst</span><span class="o">[</span><span class="mi">5</span><span class="o">]=</span><span class="n">lst</span><span class="o">[</span><span class="mi">9</span><span class="o">]</span> <span class="k">return</span> <span class="n">lst</span><span class="o">[</span><span class="mi">1</span><span class="o">]</span> <span class="k">ok</span>
<span class="k">ok</span>
<span class="k">if</span> <span class="n">lst</span><span class="o">[</span><span class="mi">3</span><span class="o">]!=</span><span class="mi">0</span> <span class="ow">and</span> <span class="n">lst</span><span class="o">[</span><span class="mi">5</span><span class="o">]!=</span><span class="mi">0</span> <span class="ow">and</span> <span class="n">lst</span><span class="o">[</span><span class="mi">7</span><span class="o">]!=</span><span class="mi">0</span>
<span class="k">if</span> <span class="n">lst</span><span class="o">[</span><span class="mi">3</span><span class="o">]=</span><span class="n">lst</span><span class="o">[</span><span class="mi">5</span><span class="o">]</span> <span class="ow">and</span> <span class="n">lst</span><span class="o">[</span><span class="mi">5</span><span class="o">]=</span><span class="n">lst</span><span class="o">[</span><span class="mi">7</span><span class="o">]</span> <span class="k">return</span> <span class="n">lst</span><span class="o">[</span><span class="mi">3</span><span class="o">]</span> <span class="k">ok</span>
<span class="k">ok</span>
<span class="o">//</span><span class="n">tie</span>
<span class="n">tie</span><span class="o">=</span><span class="kp">true</span>
<span class="k">for</span> <span class="n">i</span><span class="o">=</span><span class="mi">1</span> <span class="k">to</span> <span class="mi">9</span>
<span class="k">if</span> <span class="n">lst</span><span class="o">[</span><span class="n">i</span><span class="o">]=</span><span class="mi">0</span> <span class="n">tie</span><span class="o">=</span><span class="kp">false</span> <span class="k">exit</span> <span class="k">ok</span>
<span class="k">next</span>
<span class="k">if</span> <span class="n">tie</span><span class="o">=</span><span class="kp">true</span> <span class="k">return</span> <span class="mi">3</span> <span class="k">ok</span> <span class="k">return</span> <span class="mi">0</span>
<span class="k">class</span> <span class="n">GameOver</span>
<span class="n">font</span> <span class="n">bitmap</span>
<span class="k">func</span> <span class="n">loadresources</span>
<span class="n">font</span> <span class="o">=</span> <span class="n">al_load_ttf_font</span><span class="p">(</span><span class="s">"font/pirulen.ttf"</span><span class="p">,</span><span class="mi">54</span><span class="p">,</span><span class="mi">0</span> <span class="p">)</span>
<span class="n">bitmap</span> <span class="o">=</span> <span class="n">al_load_bitmap</span><span class="p">(</span><span class="s">"image/ballon.png"</span><span class="p">)</span>
<span class="k">func</span> <span class="n">destroyResources</span>
<span class="n">al_destroy_bitmap</span><span class="p">(</span><span class="n">bitmap</span><span class="p">)</span>
<span class="n">al_destroy_font</span><span class="p">(</span><span class="n">font</span><span class="p">)</span>
<span class="k">func</span> <span class="n">Player1Win</span> <span class="n">oGame</span>
<span class="n">showMsg</span><span class="p">(</span><span class="n">oGame</span><span class="p">,</span><span class="mi">80</span><span class="p">,</span><span class="mi">430</span><span class="p">,</span><span class="s">"Good job X you won!"</span><span class="p">)</span>
<span class="k">func</span> <span class="n">Player2Win</span> <span class="n">oGame</span>
<span class="n">showMsg</span><span class="p">(</span><span class="n">oGame</span><span class="p">,</span><span class="mi">80</span><span class="p">,</span><span class="mi">430</span><span class="p">,</span><span class="s">"Good job O you won!"</span><span class="p">)</span>
<span class="k">func</span> <span class="n">NoOneWin</span> <span class="n">oGame</span>
<span class="n">showMsg</span><span class="p">(</span><span class="n">oGame</span><span class="p">,</span><span class="mi">150</span><span class="p">,</span><span class="mi">430</span><span class="p">,</span><span class="s">"Oh no it's a tie!"</span><span class="p">)</span>
<span class="k">func</span> <span class="n">ShowMsg</span> <span class="n">oGame</span><span class="p">,</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="n">cMsg</span>
<span class="n">oGame</span> <span class="p">{</span>
<span class="n">drawScene</span><span class="p">()</span>
<span class="n">al_flip_display</span><span class="p">()</span>
<span class="n">al_rest</span><span class="p">(</span><span class="mf">0.3</span><span class="p">)</span>
<span class="n">newdisplay</span> <span class="o">=</span> <span class="n">al_create_display</span><span class="p">(</span><span class="n">SCREEN_W</span><span class="p">,</span><span class="n">SCREEN_H</span><span class="p">)</span>
<span class="n">al_set_window_title</span><span class="p">(</span><span class="n">newdisplay</span><span class="p">,</span><span class="n">TITLE</span><span class="p">)</span>
<span class="n">al_clear_to_color</span><span class="p">(</span><span class="n">al_map_rgb</span><span class="p">(</span><span class="mi">255</span><span class="p">,</span><span class="mi">255</span><span class="p">,</span><span class="mi">255</span><span class="p">))</span>
<span class="n">al_draw_bitmap</span><span class="p">(</span><span class="n">this</span><span class="p">.</span><span class="n">bitmap</span><span class="p">,</span><span class="mi">200</span><span class="p">,</span><span class="mi">50</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
<span class="n">al_draw_text</span><span class="p">(</span><span class="n">this</span><span class="p">.</span><span class="n">font</span><span class="p">,</span>
<span class="n">al_map_rgb</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">255</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span>
<span class="n">ALLEGRO_ALIGN_LEFT</span><span class="p">,</span><span class="n">cMsg</span><span class="p">)</span>
<span class="n">al_flip_display</span><span class="p">()</span>
<span class="n">al_rest</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="n">al_destroy_display</span><span class="p">(</span><span class="n">newdisplay</span><span class="p">)</span>
<span class="n">al_set_target_backbuffer</span><span class="p">(</span><span class="n">display</span><span class="p">)</span>
<span class="p">}</span>
<span class="k">class</span> <span class="n">GameCube</span>
<span class="n">bitmap</span> <span class="n">bitmap2</span> <span class="n">bitmap3</span>
<span class="n">textureX</span> <span class="n">textureO</span> <span class="n">textureN</span>
<span class="n">xrot</span> <span class="o">=</span> <span class="mf">0.0</span>
<span class="n">yrot</span> <span class="o">=</span> <span class="mf">0.0</span>
<span class="n">zrot</span> <span class="o">=</span> <span class="mf">0.0</span>
<span class="k">func</span> <span class="n">loadresources</span>
<span class="n">bitmap</span> <span class="o">=</span> <span class="n">al_load_bitmap</span><span class="p">(</span><span class="s">"image/o.png"</span><span class="p">)</span>
<span class="n">textureO</span> <span class="o">=</span> <span class="n">al_get_opengl_texture</span><span class="p">(</span><span class="n">bitmap</span><span class="p">)</span>
<span class="n">bitmap2</span> <span class="o">=</span> <span class="n">al_load_bitmap</span><span class="p">(</span><span class="s">"image/x.png"</span><span class="p">)</span>
<span class="n">textureX</span> <span class="o">=</span> <span class="n">al_get_opengl_texture</span><span class="p">(</span><span class="n">bitmap2</span><span class="p">)</span>
<span class="n">bitmap3</span> <span class="o">=</span> <span class="n">al_load_bitmap</span><span class="p">(</span><span class="s">"image/empty.png"</span><span class="p">)</span>
<span class="n">textureN</span> <span class="o">=</span> <span class="n">al_get_opengl_texture</span><span class="p">(</span><span class="n">bitmap3</span><span class="p">)</span>
<span class="k">func</span> <span class="n">destroyResources</span>
<span class="n">al_destroy_bitmap</span><span class="p">(</span><span class="n">bitmap</span><span class="p">)</span>
<span class="n">al_destroy_bitmap</span><span class="p">(</span><span class="n">bitmap2</span><span class="p">)</span>
<span class="n">al_destroy_bitmap</span><span class="p">(</span><span class="n">bitmap3</span><span class="p">)</span>
<span class="k">func</span> <span class="n">cube</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="n">z</span><span class="p">,</span><span class="n">nTexture</span><span class="p">)</span>
<span class="n">glLoadIdentity</span><span class="p">()</span>
<span class="n">glTranslatef</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="n">z</span><span class="p">)</span>
<span class="n">glRotatef</span><span class="p">(</span><span class="n">xrot</span><span class="p">,</span><span class="mf">1.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">)</span>
<span class="n">glRotatef</span><span class="p">(</span><span class="n">yrot</span><span class="p">,</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">1.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">)</span>
<span class="n">glRotatef</span><span class="p">(</span><span class="n">zrot</span><span class="p">,</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">setCubeTexture</span><span class="p">(</span><span class="n">nTexture</span><span class="p">)</span>
<span class="n">drawCube</span><span class="p">()</span>
<span class="k">func</span> <span class="n">setCubeTexture</span> <span class="n">cTexture</span>
<span class="k">switch</span> <span class="n">cTexture</span>
<span class="k">on</span> <span class="p">:</span><span class="n">x</span>
<span class="n">glBindTexture</span><span class="p">(</span><span class="n">GL_TEXTURE_2D</span><span class="p">,</span> <span class="n">textureX</span><span class="p">)</span>
<span class="k">on</span> <span class="p">:</span><span class="n">o</span>
<span class="n">glBindTexture</span><span class="p">(</span><span class="n">GL_TEXTURE_2D</span><span class="p">,</span> <span class="n">textureO</span><span class="p">)</span>
<span class="k">on</span> <span class="p">:</span><span class="n">n</span>
<span class="n">glBindTexture</span><span class="p">(</span><span class="n">GL_TEXTURE_2D</span><span class="p">,</span> <span class="n">textureN</span><span class="p">)</span>
<span class="k">off</span>
<span class="k">func</span> <span class="n">Rotate</span>
<span class="n">xrot</span> <span class="o">+=</span> <span class="mf">0.3</span> <span class="o">*</span> <span class="mi">5</span>
<span class="n">yrot</span> <span class="o">+=</span> <span class="mf">0.2</span> <span class="o">*</span> <span class="mi">5</span>
<span class="n">zrot</span> <span class="o">+=</span> <span class="mf">0.4</span> <span class="o">*</span> <span class="mi">5</span>
<span class="k">func</span> <span class="n">drawcube</span>
<span class="n">glBegin</span><span class="p">(</span><span class="n">GL_QUADS</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Front</span> <span class="n">Face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Back</span> <span class="n">Face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Top</span> <span class="n">Face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Bottom</span> <span class="n">Face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Right</span> <span class="n">face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="o">//</span> <span class="n">Left</span> <span class="n">Face</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="n">glTexCoord2f</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span> <span class="n">glVertex3f</span><span class="p">(</span><span class="o">-</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">1.0</span><span class="p">)</span>
<span class="n">glEnd</span><span class="p">()</span>
<span class="k">class</span> <span class="n">GameBackground</span>
<span class="n">nBackX</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">nBackY</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">nBackDiffx</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
<span class="n">nBackDiffy</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
<span class="n">nBackMotion</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">aBackMotionList</span> <span class="o">=</span> <span class="o">[</span>
<span class="o">[</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span> <span class="o">]</span> <span class="p">,</span> <span class="c"># Down - Right</span>
<span class="o">[</span> <span class="mi">0</span> <span class="p">,</span> <span class="mi">1</span> <span class="o">]</span> <span class="p">,</span> <span class="c"># Up</span>
<span class="o">[</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span> <span class="o">]</span> <span class="p">,</span> <span class="c"># Down - Right</span>
<span class="o">[</span> <span class="mi">0</span> <span class="p">,</span> <span class="mi">1</span> <span class="o">]</span> <span class="p">,</span> <span class="c"># Up</span>
<span class="o">[</span> <span class="mi">1</span> <span class="p">,</span> <span class="o">-</span><span class="mi">1</span> <span class="o">]</span> <span class="p">,</span> <span class="c"># Down - Left</span>
<span class="o">[</span> <span class="mi">0</span> <span class="p">,</span> <span class="mi">1</span> <span class="o">]</span> <span class="p">,</span> <span class="c"># Up</span>
<span class="o">[</span> <span class="mi">1</span> <span class="p">,</span> <span class="o">-</span><span class="mi">1</span> <span class="o">]</span> <span class="p">,</span> <span class="c"># Down - Left</span>
<span class="o">[</span> <span class="mi">0</span> <span class="p">,</span> <span class="mi">1</span> <span class="o">]</span> <span class="c"># Up</span>
<span class="o">]</span>
<span class="n">bitmap</span>
<span class="k">func</span> <span class="n">Update</span>
<span class="n">draw</span><span class="p">()</span>
<span class="n">motion</span><span class="p">()</span>
<span class="k">func</span> <span class="n">draw</span>
<span class="n">al_draw_bitmap</span><span class="p">(</span><span class="n">bitmap</span><span class="p">,</span><span class="n">nBackX</span><span class="p">,</span><span class="n">nBackY</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
<span class="k">func</span> <span class="n">motion</span>
<span class="n">nBackX</span> <span class="o">+=</span> <span class="n">nBackDiffx</span>
<span class="n">nBackY</span> <span class="o">+=</span> <span class="n">nBackDiffy</span>
<span class="k">if</span> <span class="p">(</span><span class="n">nBackY</span> <span class="o">=</span> <span class="o">-</span><span class="mi">350</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">nBackY</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">nBackMotion</span><span class="o">++</span>
<span class="k">if</span> <span class="n">nBackMotion</span> <span class="o">></span> <span class="n">len</span><span class="p">(</span><span class="n">aBackMotionList</span><span class="p">)</span>
<span class="n">nBackMotion</span> <span class="o">=</span> <span class="mi">1</span>
<span class="k">ok</span>
<span class="n">nBackDiffx</span> <span class="o">=</span> <span class="n">aBackMotionList</span><span class="o">[</span><span class="n">nBackMotion</span><span class="o">][</span><span class="mi">1</span><span class="o">]</span>
<span class="n">nBackDiffy</span> <span class="o">=</span> <span class="n">aBackMotionList</span><span class="o">[</span><span class="n">nBackMotion</span><span class="o">][</span><span class="mi">2</span><span class="o">]</span>
<span class="k">ok</span>
<span class="k">func</span> <span class="n">loadResources</span>
<span class="n">bitmap</span> <span class="o">=</span> <span class="n">al_load_bitmap</span><span class="p">(</span><span class="s">"image/back.jpg"</span><span class="p">)</span>
<span class="k">func</span> <span class="n">destroyResources</span>
<span class="n">al_destroy_bitmap</span><span class="p">(</span><span class="n">bitmap</span><span class="p">)</span>
<span class="k">class</span> <span class="n">GameSound</span>
<span class="n">sample</span> <span class="n">sampleid</span>
<span class="k">func</span> <span class="n">loadresources</span>
<span class="n">sample</span> <span class="o">=</span> <span class="n">al_load_sample</span><span class="p">(</span> <span class="s">"sound/music1.wav"</span> <span class="p">)</span>
<span class="n">sampleid</span> <span class="o">=</span> <span class="n">al_new_allegro_sample_id</span><span class="p">()</span>
<span class="n">al_play_sample</span><span class="p">(</span><span class="n">sample</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span><span class="mf">1.0</span><span class="p">,</span><span class="n">ALLEGRO_PLAYMODE_LOOP</span><span class="p">,</span><span class="n">sampleid</span><span class="p">)</span>
<span class="k">func</span> <span class="n">destroyResources</span>
<span class="n">al_destroy_allegro_sample_id</span><span class="p">(</span><span class="n">sampleid</span><span class="p">)</span>
<span class="n">al_destroy_sample</span><span class="p">(</span><span class="n">sample</span><span class="p">)</span>
<span class="k">class</span> <span class="n">GraphicsAppBase</span>
<span class="n">display</span> <span class="n">event_queue</span> <span class="n">ev</span> <span class="n">timeout</span>
<span class="n">timer</span>
<span class="n">redraw</span> <span class="o">=</span> <span class="kp">true</span>
<span class="n">FPS</span> <span class="o">=</span> <span class="mi">60</span>
<span class="n">SCREEN_W</span> <span class="o">=</span> <span class="mi">1024</span>
<span class="n">SCREEN_H</span> <span class="o">=</span> <span class="mi">700</span>
<span class="n">KEY_UP</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">KEY_DOWN</span> <span class="o">=</span> <span class="mi">2</span>
<span class="n">KEY_LEFT</span> <span class="o">=</span> <span class="mi">3</span>
<span class="n">KEY_RIGHT</span> <span class="o">=</span> <span class="mi">4</span>
<span class="n">Key</span> <span class="o">=</span> <span class="o">[</span><span class="kp">false</span><span class="p">,</span><span class="kp">false</span><span class="p">,</span><span class="kp">false</span><span class="p">,</span><span class="kp">false</span><span class="o">]</span>
<span class="n">Mouse_X</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">Mouse_Y</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">TITLE</span> <span class="o">=</span> <span class="s">"Graphics Application"</span>
<span class="n">PRINT_MOUSE_XY</span> <span class="o">=</span> <span class="kp">False</span>
<span class="k">func</span> <span class="n">start</span>
<span class="n">SetUp</span><span class="p">()</span>
<span class="n">loadResources</span><span class="p">()</span>
<span class="n">eventsLoop</span><span class="p">()</span>
<span class="n">destroy</span><span class="p">()</span>
<span class="k">func</span> <span class="n">setup</span>
<span class="n">al_init</span><span class="p">()</span>
<span class="n">al_init_font_addon</span><span class="p">()</span>
<span class="n">al_init_ttf_addon</span><span class="p">()</span>
<span class="n">al_init_image_addon</span><span class="p">()</span>
<span class="n">al_install_audio</span><span class="p">()</span>
<span class="n">al_init_acodec_addon</span><span class="p">()</span>
<span class="n">al_reserve_samples</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="n">al_set_new_display_flags</span><span class="p">(</span><span class="n">ALLEGRO_OPENGL</span><span class="p">)</span>
<span class="n">display</span> <span class="o">=</span> <span class="n">al_create_display</span><span class="p">(</span><span class="n">SCREEN_W</span><span class="p">,</span><span class="n">SCREEN_H</span><span class="p">)</span>
<span class="n">al_set_window_title</span><span class="p">(</span><span class="n">display</span><span class="p">,</span><span class="n">TITLE</span><span class="p">)</span>
<span class="n">al_clear_to_color</span><span class="p">(</span><span class="n">al_map_rgb</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">))</span>
<span class="n">event_queue</span> <span class="o">=</span> <span class="n">al_create_event_queue</span><span class="p">()</span>
<span class="n">al_register_event_source</span><span class="p">(</span><span class="n">event_queue</span><span class="p">,</span>
<span class="n">al_get_display_event_source</span><span class="p">(</span><span class="n">display</span><span class="p">))</span>
<span class="n">ev</span> <span class="o">=</span> <span class="n">al_new_allegro_event</span><span class="p">()</span>
<span class="n">timeout</span> <span class="o">=</span> <span class="n">al_new_allegro_timeout</span><span class="p">()</span>
<span class="n">al_init_timeout</span><span class="p">(</span><span class="n">timeout</span><span class="p">,</span> <span class="mf">0.06</span><span class="p">)</span>
<span class="n">timer</span> <span class="o">=</span> <span class="n">al_create_timer</span><span class="p">(</span><span class="mf">1.0</span> <span class="o">/</span> <span class="n">FPS</span><span class="p">)</span>
<span class="n">al_register_event_source</span><span class="p">(</span><span class="n">event_queue</span><span class="p">,</span>
<span class="n">al_get_timer_event_source</span><span class="p">(</span><span class="n">timer</span><span class="p">))</span>
<span class="n">al_start_timer</span><span class="p">(</span><span class="n">timer</span><span class="p">)</span>
<span class="n">al_install_mouse</span><span class="p">()</span>
<span class="n">al_register_event_source</span><span class="p">(</span><span class="n">event_queue</span><span class="p">,</span>
<span class="n">al_get_mouse_event_source</span><span class="p">())</span>
<span class="n">al_install_keyboard</span><span class="p">()</span>
<span class="n">al_register_event_source</span><span class="p">(</span><span class="n">event_queue</span><span class="p">,</span>
<span class="n">al_get_keyboard_event_source</span><span class="p">())</span>
<span class="k">func</span> <span class="n">eventsLoop</span>
<span class="k">while</span> <span class="kp">true</span>
<span class="n">al_init_timeout</span><span class="p">(</span><span class="n">timeout</span><span class="p">,</span> <span class="mf">0.06</span><span class="p">)</span>
<span class="n">al_wait_for_event_until</span><span class="p">(</span><span class="n">event_queue</span><span class="p">,</span> <span class="n">ev</span><span class="p">,</span> <span class="n">timeout</span><span class="p">)</span>
<span class="k">switch</span> <span class="n">al_get_allegro_event_type</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_DISPLAY_CLOSE</span>
<span class="n">CloseEvent</span><span class="p">()</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_TIMER</span>
<span class="n">redraw</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_MOUSE_AXES</span>
<span class="n">mouse_x</span> <span class="o">=</span> <span class="n">al_get_allegro_event_mouse_x</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="n">mouse_y</span> <span class="o">=</span> <span class="n">al_get_allegro_event_mouse_y</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="k">if</span> <span class="n">PRINT_MOUSE_XY</span>
<span class="k">see</span> <span class="s">"x = "</span> <span class="o">+</span> <span class="n">mouse_x</span> <span class="o">+</span> <span class="n">nl</span>
<span class="k">see</span> <span class="s">"y = "</span> <span class="o">+</span> <span class="n">mouse_y</span> <span class="o">+</span> <span class="n">nl</span>
<span class="k">ok</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY</span>
<span class="n">mouse_x</span> <span class="o">=</span> <span class="n">al_get_allegro_event_mouse_x</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="n">mouse_y</span> <span class="o">=</span> <span class="n">al_get_allegro_event_mouse_y</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_MOUSE_BUTTON_UP</span>
<span class="n">MouseClickEvent</span><span class="p">()</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_KEY_DOWN</span>
<span class="k">switch</span> <span class="n">al_get_allegro_event_keyboard_keycode</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_UP</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_UP</span><span class="o">]</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_DOWN</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_DOWN</span><span class="o">]</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_LEFT</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_LEFT</span><span class="o">]</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_RIGHT</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_RIGHT</span><span class="o">]</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">off</span>
<span class="k">on</span> <span class="n">ALLEGRO_EVENT_KEY_UP</span>
<span class="k">switch</span> <span class="n">al_get_allegro_event_keyboard_keycode</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_UP</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_UP</span><span class="o">]</span> <span class="o">=</span> <span class="kp">false</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_DOWN</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_DOWN</span><span class="o">]</span> <span class="o">=</span> <span class="kp">false</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_LEFT</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_LEFT</span><span class="o">]</span> <span class="o">=</span> <span class="kp">false</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_RIGHT</span>
<span class="n">key</span><span class="o">[</span><span class="n">KEY_RIGHT</span><span class="o">]</span> <span class="o">=</span> <span class="kp">false</span>
<span class="k">on</span> <span class="n">ALLEGRO_KEY_ESCAPE</span>
<span class="k">exit</span>
<span class="k">off</span>
<span class="k">off</span>
<span class="k">if</span> <span class="n">redraw</span> <span class="ow">and</span> <span class="n">al_is_event_queue_empty</span><span class="p">(</span><span class="n">event_queue</span><span class="p">)</span>
<span class="n">redraw</span> <span class="o">=</span> <span class="kp">false</span>
<span class="n">drawScene</span><span class="p">()</span>
<span class="n">al_flip_display</span><span class="p">()</span>
<span class="k">ok</span>
<span class="n">callgc</span><span class="p">()</span>
<span class="k">end</span>
<span class="k">func</span> <span class="n">destroy</span>
<span class="n">destroyResources</span><span class="p">()</span>
<span class="n">al_destroy_timer</span><span class="p">(</span><span class="n">timer</span><span class="p">)</span>
<span class="n">al_destroy_allegro_event</span><span class="p">(</span><span class="n">ev</span><span class="p">)</span>
<span class="n">al_destroy_allegro_timeout</span><span class="p">(</span><span class="n">timeout</span><span class="p">)</span>
<span class="n">al_destroy_event_queue</span><span class="p">(</span><span class="n">event_queue</span><span class="p">)</span>
<span class="n">al_destroy_display</span><span class="p">(</span><span class="n">display</span><span class="p">)</span>
<span class="n">al_exit</span><span class="p">()</span>
<span class="k">func</span> <span class="n">loadresources</span>
<span class="k">func</span> <span class="n">drawScene</span>
<span class="k">func</span> <span class="n">destroyResources</span>
<span class="k">func</span> <span class="n">MouseClickEvent</span>
<span class="k">exit</span> <span class="c"># Exit from the Events Loop</span>
<span class="k">func</span> <span class="n">CloseEvent</span>
<span class="k">exit</span> <span class="c"># Exit from the Events Loop</span>
</pre></div>
</div>
<p>Screen Shot:</p>
<a class="reference internal image-reference" href="_images/tictactoe3d.png"><img alt="TicTacToe 3D Game" src="_images/tictactoe3d.png" style="width: 450pt; height: 350pt;" /></a>
</div>
<div class="section" id="more-3d-samples">
<span id="index-4"></span><h2>More 3D Samples<a class="headerlink" href="#more-3d-samples" title="Permalink to this headline">¶</a></h2>
<p>You will find the samples in ring/samples/3D folder</p>
<p>The next screen shot for the Top-Down view - Many levels of cubes sample</p>
<img alt="3D samples" src="_images/more3dsamples.jpg" />
<p>The next screen shot for the Camera Sample</p>
<img alt="3D samples" src="_images/more3dsamples2.jpg" />
<p>The next screen shot for the Camera and background sample</p>
<p>Developer : Azzeddine Remmal</p>
<img alt="Camera and background" src="_images/cameraandbackground.png" />
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="goldmagic800.html" class="btn btn-neutral float-right" title="The Gold Magic 800 Game" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="usingopengl.html" class="btn btn-neutral float-left" title="Using RingOpenGL and RingFreeGLUT for 3D Graphics" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2016-2022, Ring Team
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(false);
});
</script>
</body>
</html>
|
ring-lang/ring
|
documents/build/html/usingopengl2.html
|
HTML
|
mit
| 167,763
|
#include <Point.h>
Point::Point(double x, double y) {
this->x = x;
this->y = y;
}
void Point::setX(double x) {
this->x = x;
}
void Point::setY(double y) {
this->y = y;
}
double Point::getX() {
return x;
}
double Point::getY() {
return y;
}
|
mikehelmick/teaching
|
uc/computerScience1/materials/labs/lab10/Point.cpp
|
C++
|
mit
| 257
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<title>The Component Hierarchy</title>
</head>
<body BGCOLOR="#ffffff">
<table width="100%">
<tr>
<td align=left>
<a href="egClasses.html"><img src="../../images/PreviousArrow.gif" width=26 height=26 align=bottom border=0 alt="Previous | "></a><a
href="drawing.html"><img src="../../images/NextArrow.gif" width=26 height=26 align=bottom border=0 alt="Next | "></a><a
href="../../trailmap.html"><img src="../../images/WayUpArrow.gif" width=26 height=26 align=bottom border=0 alt="Trail Map | "></a><a
href="../index.html"><img src="../../images/uiHeader.gif" width=26 height=26 align=bottom border=0 alt="Creating a User Interface | "></a>
</td>
<td align=right>
<a href="index.html"><strong><em>Overview of the Java UI</em></strong></a>
</td>
</tr>
</table>
<p>
<hr size=4>
<h2>
The Component Hierarchy
</h2>
<p>
<blockquote>
<blockquote><IMG SRC="../../figures/ui/13ui4.gif" WIDTH="436" HEIGHT="247" ALIGN="BOTTOM" NATURALSIZEFLAG="3"></blockquote>
<p>
The example program (see above)
has several levels in its Component hierarchy.
The parent of each level is a Container
(which inherits from Component).
Below is a figure of the hierarchy.
<blockquote><IMG SRC="../../figures/ui/13ui5.gif" WIDTH="462" HEIGHT="181" ALIGN="BOTTOM" NATURALSIZEFLAG="3"></blockquote>
<h4>Explanation</h4>
<blockquote>
At the top of the hierarchy is the window (Frame instance)
that displays the program.
When the example program runs as an application,
the Frame is created in the program's <code>main()</code> method.
When the example runs as an applet within a browser,
the Frame is the browser window.
<p>
Under the Frame is a Converter object,
which inherits from Applet and
thus is a Container (specifically, a Panel).
Depending on what viewer the applet is displayed in,
one or more Containers might be between the Converter object
and the Frame at the top of the Component hierarchy.
<p>
Directly under the Converter object
are two ConversionPanels.
The following code puts them under the Converter,
using the <code>add()</code> method.
Converter inherits the <code>add()</code> method
from the Container class
(Converter extends Applet,
which extends Panel,
which extends Container).
<blockquote>
<pre>
public class Converter extends Applet {
. . .
public void init() {
<em>...//Create metricPanel and usaPanel, two ConversionPanels.</em>
add(metricPanel);
add(usaPanel);
. . .
}
</pre>
</blockquote>
Each ConversionPanel has four children:
a Label, a TextField, a Scrollbar, and a Choice.
Here's the code that adds the children:
<blockquote>
<pre>
class ConversionPanel extends Panel {
. . .
ConversionPanel(Converter myController, String myTitle, Unit myUnits[]) {
. . .
//Add the label. It displays this panel's title, centered.
Label label = new Label(myTitle, Label.CENTER);
<em>...//Set up GridBagConstraints for this Component.</em>
gridbag.setConstraints(label, c);
add(label);
//Add the text field. It initially displays "0" and needs
//to be at least 10 columns wide.
textField = new TextField("0", 10);
<em>...//Set up GridBagConstraints for this Component.</em>
gridbag.setConstraints(textField, c);
add(textField);
//Add the pop-up list (Choice).
unitChooser = new Choice();
<em>...//Populate it with items.</em>
<em>...//Set up GridBagConstraints for this Component.</em>
gridbag.setConstraints(unitChooser, c);
add(unitChooser);
//Add the slider. It's horizontal, its initial value is 0,
//a click increments the value by 100 pixels, and it has the
//minimum and maximum values specified by the instance variables
//min and max.
slider = new Scrollbar(Scrollbar.HORIZONTAL, 0, 100, min, max);
<em>...//Set up GridBagConstraints for this Component.</em>
gridbag.setConstraints(slider, c);
add(slider);
}
</pre>
</blockquote>
GridBagConstraints is an object
that tells the GridBagLayout
(the layout manager for each ConversionPanel)
how to place a particular component.
GridBagLayout, along with the other AWT layout managers,
is discussed in
<a target="_top" href="../layout/index.html">Laying Out Components within a Container</a><a target="_top" href="../layout/index.html"><img src="../../images/uiIcon.gif" width=20 height=20 border=0 alt="(in the Creating a User Interface trail)"></a>.
</blockquote>
<h4>Summary</h4>
<blockquote>
The example program's Component hierarchy
contains eight non-Container Components --
Components that present the graphical UI of the program.
These are the Labels, TextFields, Choices, and Scrollbars
the program displays.
There might be additional Components
such as window controls under the Frame.
<p>
This program's Component hierarchy has at least four Containers --
a Frame (window),
a Converter (a custom kind of Panel),
and two ConversionPanels (another custom Panel).
<p>
Note that if we add a window --
for example, a Frame that contains a Converter instance
that handles distance conversion --
the new window will have its own Component hierarchy,
unattached to the hierarchy this lesson presents.
</blockquote>
</blockquote>
<p>
<hr size=4>
<p>
<table width="100%">
<tr>
<td align=left>
<a href="egClasses.html"><img src="../../images/PreviousArrow.gif" width=26 height=26 align=top border=0 alt="Previous | "></a><a
href="drawing.html"><img src="../../images/NextArrow.gif" width=26 height=26 align=top border=0 alt="Next | "></a><a
href="../../trailmap.html"><img src="../../images/WayUpArrow.gif" width=26 height=26 align=top border=0 alt="Trail Map | "></a><a
href="../index.html"><img src="../../images/uiHeader.gif" width=26 height=26 align=top border=0 alt="Creating a User Interface | "></a>
</td>
<td align=right>
<a href="index.html"><strong><em>Overview of the Java UI</em></strong></a>
</td>
</tr>
</table>
</body>
</html>
|
pitpitman/GraduateWork
|
Java_tutorial/ui/overview/compHierarchy.html
|
HTML
|
mit
| 6,051
|
namespace Microsoft.ApplicationInsights.AspNetCore.Tests.Helpers
{
using System;
using Microsoft.ApplicationInsights.AspNetCore.DiagnosticListeners;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
public static class HttpContextAccessorHelper
{
public static HttpContextAccessor CreateHttpContextAccessor(RequestTelemetry requestTelemetry = null, ActionContext actionContext = null, string httpContextCorrelationId = null)
{
var services = new ServiceCollection();
var request = new DefaultHttpContext().Request;
request.Method = "GET";
request.Path = new PathString("/Test");
if (httpContextCorrelationId != null)
{
HttpHeadersUtilities.SetRequestContextKeyValue(request.Headers, RequestResponseHeaders.RequestContextSourceKey, httpContextCorrelationId);
}
var contextAccessor = new HttpContextAccessor { HttpContext = request.HttpContext };
services.AddSingleton<IHttpContextAccessor>(contextAccessor);
if (actionContext != null)
{
var si = new ActionContextAccessor();
si.ActionContext = actionContext;
services.AddSingleton<IActionContextAccessor>(si);
}
if (requestTelemetry != null)
{
request.HttpContext.Features.Set(requestTelemetry);
}
IServiceProvider serviceProvider = services.BuildServiceProvider();
contextAccessor.HttpContext.RequestServices = serviceProvider;
return contextAccessor;
}
public static HttpContextAccessor CreateHttpContextAccessorWithoutRequest(HttpContext httpContext, RequestTelemetry requestTelemetry = null)
{
var services = new ServiceCollection();
var contextAccessor = new HttpContextAccessor { HttpContext = httpContext };
services.AddSingleton<IHttpContextAccessor>(contextAccessor);
if (requestTelemetry != null)
{
services.AddSingleton<RequestTelemetry>(requestTelemetry);
}
IServiceProvider serviceProvider = services.BuildServiceProvider();
contextAccessor.HttpContext.RequestServices = serviceProvider;
return contextAccessor;
}
}
}
|
pharring/ApplicationInsights-dotnet
|
NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Helpers/HttpContextAccessorHelper.cs
|
C#
|
mit
| 2,566
|
---
authors: Moritz Neujeffski
date: 2016-10-04 11:00:00
picture:
src: /files/blog/2016/10/Industrie.jpg
title:
license: "Public Domain, via pixabay"
license_url: "https://wiki.creativecommons.org/wiki/Public_domain"
tags:
- workshop
- umwelt
title: "Einladung zum Workshop: Analyse und Visualisierung von Schadstoffemissionen"
---
Welche Betriebe belasten die Umwelt in eurer Umgebung am stärksten? Welche Industriebranchen sind für die meisten CO2-Emissionen in Deutschland verantwortlich? Welche Konzerne produzieren den höchsten Abfallberg?
Bei unserem Workshop im Rahmen der diesjährigen <a href='http://www.codeweek.de/'>Code Week</a> zeigen wir euch mit einfachen Tools und Tipps, wie sich spannenden Fragen zur Umweltverschmutzung in Deutschland beantworten lassen und wie ihr Ergebnisse ansprechend aufbereiten könnt.
Dabei schauen wir uns Daten zu freigesetzten Schadstoffen in Deutschland genauer an, analysieren und visualisieren sie.
Unser Workshop richtet sich an Datenneulinge, Vorkenntnisse benötigt ihr nicht.
Meldet euch an und macht mit, Laptop nicht vergessen!
**Was:** Workshop zu Schadstoffemissionen
**Wann:** 20. Oktober 2016, 13:00 - 17:00 Uhr
**Wo:** Zentral- und Landesbibliothek Berlin, Breitestraße 30-36, 10178 Berlin
**Wer:** Datenneulinge mit Interesse an Umweltdaten
**Mit:** Input aus dem Projekt <a href='https://2030-watch.de/'>2030 Watch</a>, das sich das Monitoring der Ziele für nachhaltige Entwicklung zur Aufgabe gemacht hat
**Anmeldung:** Um an dem Event teilzunehmen kannst du dich <a href="https://goo.gl/forms/37d3xa18UFFmcFjB3">hier eintragen</a>.
Wir freuen uns auf euch!
PS: Du kannst leider nicht dabei sein, bist aber an Daten und gesellschaftlichen Fragestellungen interessiert? Der <a href='http://okfn.us5.list-manage.com/subscribe?u=929f1e07936386d34833e20d1&id=57affeefd3'>Newsletter der Datenschule</a> hält dich auf dem Laufenden.
|
okfde/datenschule.de
|
blog/_posts/2016/2016-10-04-DS-Codeweek-Workshop.md
|
Markdown
|
mit
| 1,923
|
import { block, insertAfter, clearSelection, prepend, detach, freeSelect } from "../../domUtils";
import { updateGrid } from "../index";
import { addChange } from "../changes";
import { Toast } from "../../toast";
import { getKeywordView } from "./keyword";
import MANIFEST from "./MANIFEST";
import { MEMBER_SECTIONS, getMemberSection } from "./memberSection";
import { getCodeCaptionView } from "./code";
import { updateGridElement } from "./../index";
/**
* Creates and returns interactive class block property editor.
* @param classData
* @param [memberType]
* @param [classMemberName]
* @returns {Element}
*/
function getMemberDetailedBlock (classData, memberType, classMemberName) {
let isClass = !memberType,
data = isClass ? classData : classData[memberType][classMemberName],
container = block(`div`, `detailed`),
comment = block(`div`, `comment`),
savePath = isClass
? [classData["Name"]]
: [classData["Name"], memberType, classMemberName],
codePropName;
container.appendChild(comment);
comment.setAttribute("contenteditable", "true");
comment.addEventListener("input", () => {
addChange(
isClass
? [classData["Name"], "Description"]
: [classData["Name"], memberType, classMemberName, "Description"],
comment.innerHTML.replace(/<br\s*\/?>/, "<br/>\n")
);
});
if (data["Description"])
comment.innerHTML = data["Description"];
comment.setAttribute("placeholder", "< Add comment >");
for (let propName in data) {
let propManifest = (MANIFEST[isClass ? "Class" : memberType] || {})[propName] || {};
if (propManifest.isCode) codePropName = propName;
if (propManifest.ignore || propManifest.default === data[propName]) continue;
if (typeof data[propName] === "object") continue;
container.appendChild(getKeywordView({
propManifest,
propName,
propData: data[propName],
savePath: savePath.concat(propName)
}));
}
if (codePropName)
container.appendChild(getCodeCaptionView({
memberManifest: MANIFEST[isClass ? "Class" : memberType] || {},
codePropertyName: codePropName,
data: data,
savePath
}));
return container;
}
/**
* Enables block item interactivity.
* This method combines behaviors for class and class members.
* @param {HTMLElement} headerElement
* @param {*} classData
* @param [classBlockName]
* @param [classBlockPropName]
* @param [classBlockElement]
* @param {*} [serviceData] - Object with additional properties passed through all the members.
*/
function enableMember ({
headerElement, classData, classBlockName, classBlockPropName, classBlockElement, serviceData
}) {
let isClass = !classBlockName,
opened = false,
container, controls,
savePath = isClass
? [classData["Name"]]
: [classData["Name"], classBlockName, classBlockPropName];
if (typeof serviceData[`visualCodeBlocksOpened`] === "undefined")
serviceData[`visualCodeBlocksOpened`] = 0;
headerElement.addEventListener(`click`, () => {
if (!container) {
container = isClass
? getMemberDetailedBlock(classData)
: getMemberDetailedBlock(classData, classBlockName, classBlockPropName);
controls = block(`div`, `controls`);
let add = block(`select`, `interactive normal icon add hidden-select`),
del = block(`div`, `interactive normal icon delete`);
freeSelect(add);
controls.appendChild(add);
controls.appendChild(del);
add.addEventListener(`mousedown`, () => { // form the list of not present properties
while (add.firstChild)
add.removeChild(add.firstChild);
if (isClass) {
MEMBER_SECTIONS.forEach(mName => {
let end = false;
[].slice.call(classBlockElement.childNodes).forEach(n => {
if (n.SECTION_NAME === mName)
end = true;
});
if (end)
return;
let opt = block(`option`);
opt.textContent = mName;
opt.value = mName;
add.appendChild(opt);
});
}
let propsManifest = MANIFEST[isClass ? "Class" : classBlockName] || {},
presentProps = {};
[].forEach.call(container.childNodes, (node) => {
if (node.PROPERTY_NAME) presentProps[node.PROPERTY_NAME] = 1;
});
for (let propName in propsManifest) {
if (propsManifest[propName].ignore) continue;
if (presentProps.hasOwnProperty(propName)) continue;
let opt = block(`option`);
opt.textContent = propName;
opt.value = propName;
add.appendChild(opt);
}
});
add.addEventListener(`click`, e => e.stopPropagation());
add.addEventListener(`change`, (e) => {
let propName = (e.target || e.srcElement).value,
propManifest =
(MANIFEST[isClass ? "Class" : classBlockName] || {})[propName] || {};
if (isClass && MEMBER_SECTIONS.indexOf(propName) !== -1) {
classBlockElement.appendChild(
getMemberSection(propName, classData, serviceData)
);
updateGrid();
return;
}
container.appendChild(getKeywordView({
propManifest: propManifest,
propName: propName,
propData: propManifest.default || "",
savePath: savePath.concat(propName)
}));
updateGrid();
});
let lastTimeDelClicked = 0;
del.addEventListener(`click`, e => e.stopPropagation());
del.addEventListener(`click`, () => {
let delta = (-lastTimeDelClicked + (lastTimeDelClicked = (new Date()).getTime()));
if (delta > 5000) { // > 5 sec - show message "click again to delete"
new Toast(`Click again to delete`, Toast.TYPE_INFO);
} else { // delete
addChange(savePath.concat(`$delete`), true);
detach(headerElement);
detach(container);
if (classBlockElement)
detach(classBlockElement);
updateGrid();
}
});
}
if (opened = !opened) {
insertAfter(container, headerElement);
prepend(controls, headerElement);
} else if (container.parentNode) {
container.parentNode.removeChild(container);
controls.parentNode.removeChild(controls);
clearSelection();
}
headerElement.classList.toggle("opened");
if (classBlockName === "Methods" || classBlockName === "XDatas") {
serviceData[`visualCodeBlocksOpened`] += opened ? 1 : -1;
updateGridElement(serviceData[`cardElement`], {
width: serviceData[`cardWidth`] = serviceData[`visualCodeBlocksOpened`] > 0 ? 2 : 1
});
}
updateGrid();
});
}
function getMemberIconsBlock (isClass, memberData) {
let iconsBlock = block(`div`, `icons`);
if (!isClass)
iconsBlock.appendChild(
block(`div`, `icon ${ memberData["Private"] ? "private" : "public" }`)
);
return iconsBlock;
}
/**
* @param classData
* @param [classBlockName]
* @param [classBlockPropName]
* @param {HTMLElement} classBlockElement
* @param {*} [serviceData] - Object with additional properties passed through all the members.
* @returns {HTMLElement}
*/
export function getMemberBlock ({
classData, classBlockName, classBlockPropName, classBlockElement, serviceData
}) {
let isClass = !classBlockName,
div = block(`div`, `item`),
prop = isClass ? classData : classData[classBlockName][classBlockPropName],
item = block(`div`, `header`),
text = block(`span`, `label`),
pName = block(`span`, `name`),
type = prop["Type"] || prop["ReturnType"] || prop["MimeType"] || "",
pTypeText = type ? block(`span`) : null,
pType = type ? block(`span`, `type`) : null;
pName.textContent = prop["_name"] || prop["Name"];
item.appendChild(getMemberIconsBlock(isClass, prop));
text.appendChild(pName);
if (type) {
pTypeText.textContent = ": ";
text.appendChild(pTypeText);
pType.textContent = type;
text.appendChild(pType);
}
item.appendChild(text);
enableMember({
headerElement: item, classData, classBlockName, classBlockPropName, classBlockElement,
serviceData
});
div.appendChild(item);
return div;
}
|
ZitRos/cache-visual-editor
|
source/client/js/classEditor/class/member.js
|
JavaScript
|
mit
| 9,395
|
# Find Duplicate Subtrees
Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of them.
Two trees are duplicate if they have the same structure with same node values.
Example 1:
```
1
/ \
2 3
/ / \
4 2 4
/
4
```
The following are two duplicate subtrees:
```
2
/
4
```
and
```
4
```
Therefore, you need to return above trees' root in the form of a list.
还是直接看stefan大大的[分析](https://leetcode.com/problems/find-duplicate-subtrees/discuss/106016/O(n)-time-and-space-lots-of-analysis)
```python
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def findDuplicateSubtrees(self, root):
"""
:type root: TreeNode
:rtype: List[TreeNode]
"""
def getid(root):
if root:
id = treeid[root.val, getid(root.left), getid(root.right)]
trees[id].append(root)
return id
trees = collections.defaultdict(list)
treeid = collections.defaultdict()
treeid.default_factory = treeid.__len__
getid(root)
return [roots[0] for roots in trees.values() if roots[1:]]
```
|
hanleilei/leetcode
|
python/652_Find_Duplicate_Subtrees.md
|
Markdown
|
mit
| 1,408
|
## Particle Motion Simulation
1. motion.cpp : Particle motion inside triangle in 2D
2. motion1.cpp : Particle motion inside triangle in 2D with collision between
particles and the output is displayed as OpenGL window
3. motion2.cpp : Particle motion inside triangle in 2D with collision between
particles and the output is displayed as OpenGL window as well as streamed to
stdout for recording using ffmpeg
### Particle motion inside triangle in 2D
Gerakan partikel di dalam ruang yang dibatasi oleh segitiga 2 dimensi.
Definisi segitiga:
* segitiga dibentuk oleh garis-garis y = 4x/3; y = -4x/3+8; dan y = 0
* garis-garis tersebut menjadi syarat batas posisi partikel (y > 4x/3; y > -4x/3+8; y < 0)
* garis y = 4x/3 mempunyai gradien m = 4/3 sehingga sudut garis tersebut terhadap sumbu +x adalah alpha1 = 0.927 rad
* garis y = -4x/3+8 mempunyai gradien m = -4/3 sehingga sudut garis tersebut terhadap sumbu +x adalah alpha2 = 2.214 rad
* garis y = 0 mempunyai gradien m = 0 sehingga sudut garis tersebut terhadap sumbu +x adalah 0
Definisi partikel
* posisi awal partikel x = 3 dan y = 2
* kecepatan awal vx = 0.1 dan vy = -1 (variabel vxt & vyt sebagai variabel sementara)
* sudut arah gerak partikel awal adalah theta0 = arctan (vy/vx)
Definisi gerakan
* time step dt = 0.1 detik
* partikel yang terpantul di garis y = 4x/3 mempunyai matriks transformasi posisi 2x2 yaitu T1
* partikel yang terpantul di garis y = -4x/3+8 mempunyai matriks transformasi posisi 2x2 yaitu T2
* iterasi untuk gerakan menggunakan GLB biasa x = x + vx\*dt dan y = y + vy\*dt
* pada setiap iterasi simpan posisi dan kecepatan serta sudut arah pada variabel sementara xt, yt, vxt, vyt, thetat
* uji posisi pada syarat batas
* jika syarat batas y > 4x/3 terpenuhi ubah sudut arah kecepatan dengan persamaan theta0 = 2\*PI + 2\*alpha1 - thetat
* hitung kecepatan baru berdasarkan resultan kecepatan dan sudut arah yang baru
* cerminkan posisi partikel ke sisi yang benar dengan matriks transformasi T1
* jika syarat batas y > -4x/3+8 terpenuhi ubah sudut arah kecepatan dengan persamaan theta0 = 2\*PI + 2\*alpha2 - thetat
* hitung kecepatan baru berdasarkan resultan kecepatan dan sudut arah yang baru
* cerminkan posisi partikel ke sisi yang benar dengan matriks transformasi T2
* jika syarat batas y < 0 terpenuhi ubah sudut arah kecepatan dengan persamaan theta0 = 2\*PI - thetat
* hitung kecepatan baru berdasarkan resultan kecepatan dan sudut arah yang baru
* cerminkan posisi partikel ke sisi yang benar dengan mengubah tanda posisi y
* ulangi iterasi
### Kompilasi program
Untuk melakukan kompilasi program motion1.cpp dan motion2.cpp, gunakan langkah
berikut ini
g++ motion1.cpp -lGL -lglut -o motion1
g++ motion2.cpp -lGL -lglut -o motion2
Khusus untuk program motion2.cpp gunakan langkah berikut untuk melakukan
penyimpanan ke video MP4
./motion2 | ffmpeg -r 240 -f rawvideo -pix_fmt rgb24 -s 660x440 -i pipe:0 -vcodec libx264 -threads 4 -pix_fmt yuv420p -vf vflip output.mp4
Jika video output terlalu lambat, percepat dengan ffmpeg
ffmpeg -i output.mp4 -filter:v "setpts=0.25*PTS" output-fast.mp4
### Video output program
Berikut ini adalah output dari program motion2.cpp
<a href="http://www.youtube.com/watch?feature=player_embedded&v=8aVqEdP0xcU" target="_blank"><img src="http://img.youtube.com/vi/8aVqEdP0xcU/0.jpg" alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a>
### Referensi
* Refleksi terhadap dinding segitiga: [http://www.cimt.plymouth.ac.uk/projects/mepres/alevel/fpure_ch9.pdf](http://www.cimt.plymouth.ac.uk/projects/mepres/alevel/fpure_ch9.pdf)
|
prasetiyohadi/learn-computations
|
particle-motion/README.md
|
Markdown
|
mit
| 3,615
|
<?php
use Tester\Assert;
use UniMapper\Query;
use UniMapper\Entity\Reflection;
require __DIR__ . '/../bootstrap.php';
/**
* @testCase
*/
class QueryDeleteTest extends TestCase
{
/** @var array $adapters */
private $adapters = [];
/** @var \Mockery\Mock */
private $connectionMock;
/** @var \Mockery\Mock */
private $adapterQueryMock;
public function setUp()
{
$this->adapters["FooAdapter"] = Mockery::mock("UniMapper\Adapter");
$this->connectionMock = Mockery::mock("UniMapper\Connection");
$this->connectionMock->shouldReceive("getAdapter")
->once()
->with("FooAdapter")
->andReturn($this->adapters["FooAdapter"]);
$this->adapterQueryMock = Mockery::mock("UniMapper\Adapter\IQuery");
}
public function testOnExecute()
{
$this->connectionMock->shouldReceive("getMapper")
->once()
->andReturn(new UniMapper\Mapper);
$this->adapters["FooAdapter"]->shouldReceive("createDelete")
->with("fooResource")
->once()
->andReturn($this->adapterQueryMock);
$this->adapterQueryMock->shouldReceive("setFilter")
->with(["fooId" => [\UniMapper\Entity\Filter::EQUAL => 1]])
->once();
$this->adapters["FooAdapter"]->shouldReceive("onExecute")
->with($this->adapterQueryMock)
->once()
->andReturn("2");
$query = new Query\Delete(Foo::getReflection());
$query->setFilter(["id" => [\UniMapper\Entity\Filter::EQUAL => 1]]);
Assert::same(2, $query->run($this->connectionMock));
}
public function testOnExecuteNoFilter()
{
$this->adapters["FooAdapter"]->shouldReceive("createDelete")
->with("fooResource")
->once()
->andReturn($this->adapterQueryMock);
$this->adapters["FooAdapter"]->shouldReceive("onExecute")
->with($this->adapterQueryMock)
->once()
->andReturn("2");
$query = new Query\Delete(Foo::getReflection());
$query->run($this->connectionMock);
}
}
/**
* @adapter FooAdapter(fooResource)
*
* @property int $id m:primary m:map-by(fooId)
*/
class Foo extends \UniMapper\Entity {}
$testCase = new QueryDeleteTest;
$testCase->run();
|
unimapper/unimapper
|
tests/cases/Query.Delete.phpt
|
PHP
|
mit
| 2,348
|
// Copyright (c) 2011-2013 The BeCoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "overviewpage.h"
#include "ui_overviewpage.h"
#include "becoinunits.h"
#include "clientmodel.h"
#include "guiconstants.h"
#include "guiutil.h"
#include "optionsmodel.h"
#include "platformstyle.h"
#include "transactionfilterproxy.h"
#include "transactiontablemodel.h"
#include "walletmodel.h"
#include <QAbstractItemDelegate>
#include <QPainter>
#define DECORATION_SIZE 54
#define NUM_ITEMS 5
class TxViewDelegate : public QAbstractItemDelegate
{
Q_OBJECT
public:
TxViewDelegate(const PlatformStyle *platformStyle):
QAbstractItemDelegate(), unit(BeCoinUnits::BEF),
platformStyle(platformStyle)
{
}
inline void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index ) const
{
painter->save();
QIcon icon = qvariant_cast<QIcon>(index.data(TransactionTableModel::RawDecorationRole));
QRect mainRect = option.rect;
QRect decorationRect(mainRect.topLeft(), QSize(DECORATION_SIZE, DECORATION_SIZE));
int xspace = DECORATION_SIZE + 8;
int ypad = 6;
int halfheight = (mainRect.height() - 2*ypad)/2;
QRect amountRect(mainRect.left() + xspace, mainRect.top()+ypad, mainRect.width() - xspace, halfheight);
QRect addressRect(mainRect.left() + xspace, mainRect.top()+ypad+halfheight, mainRect.width() - xspace, halfheight);
icon = platformStyle->SingleColorIcon(icon);
icon.paint(painter, decorationRect);
QDateTime date = index.data(TransactionTableModel::DateRole).toDateTime();
QString address = index.data(Qt::DisplayRole).toString();
qint64 amount = index.data(TransactionTableModel::AmountRole).toLongLong();
bool confirmed = index.data(TransactionTableModel::ConfirmedRole).toBool();
QVariant value = index.data(Qt::ForegroundRole);
QColor foreground = option.palette.color(QPalette::Text);
if(value.canConvert<QBrush>())
{
QBrush brush = qvariant_cast<QBrush>(value);
foreground = brush.color();
}
painter->setPen(foreground);
QRect boundingRect;
painter->drawText(addressRect, Qt::AlignLeft|Qt::AlignVCenter, address, &boundingRect);
if (index.data(TransactionTableModel::WatchonlyRole).toBool())
{
QIcon iconWatchonly = qvariant_cast<QIcon>(index.data(TransactionTableModel::WatchonlyDecorationRole));
QRect watchonlyRect(boundingRect.right() + 5, mainRect.top()+ypad+halfheight, 16, halfheight);
iconWatchonly.paint(painter, watchonlyRect);
}
if(amount < 0)
{
foreground = COLOR_NEGATIVE;
}
else if(!confirmed)
{
foreground = COLOR_UNCONFIRMED;
}
else
{
foreground = option.palette.color(QPalette::Text);
}
painter->setPen(foreground);
QString amountText = BeCoinUnits::formatWithUnit(unit, amount, true, BeCoinUnits::separatorAlways);
if(!confirmed)
{
amountText = QString("[") + amountText + QString("]");
}
painter->drawText(amountRect, Qt::AlignRight|Qt::AlignVCenter, amountText);
painter->setPen(option.palette.color(QPalette::Text));
painter->drawText(amountRect, Qt::AlignLeft|Qt::AlignVCenter, GUIUtil::dateTimeStr(date));
painter->restore();
}
inline QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
return QSize(DECORATION_SIZE, DECORATION_SIZE);
}
int unit;
const PlatformStyle *platformStyle;
};
#include "overviewpage.moc"
OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) :
QWidget(parent),
ui(new Ui::OverviewPage),
clientModel(0),
walletModel(0),
currentBalance(-1),
currentUnconfirmedBalance(-1),
currentImmatureBalance(-1),
currentWatchOnlyBalance(-1),
currentWatchUnconfBalance(-1),
currentWatchImmatureBalance(-1),
txdelegate(new TxViewDelegate(platformStyle)),
filter(0)
{
ui->setupUi(this);
// use a SingleColorIcon for the "out of sync warning" icon
QIcon icon = platformStyle->SingleColorIcon(":/icons/warning");
icon.addPixmap(icon.pixmap(QSize(64,64), QIcon::Normal), QIcon::Disabled); // also set the disabled icon because we are using a disabled QPushButton to work around missing HiDPI support of QLabel (https://bugreports.qt.io/browse/QTBUG-42503)
ui->labelTransactionsStatus->setIcon(icon);
ui->labelWalletStatus->setIcon(icon);
// Recent transactions
ui->listTransactions->setItemDelegate(txdelegate);
ui->listTransactions->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE));
ui->listTransactions->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2));
ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect, false);
connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, SLOT(handleTransactionClicked(QModelIndex)));
// start with displaying the "out of sync" warnings
showOutOfSyncWarning(true);
}
void OverviewPage::handleTransactionClicked(const QModelIndex &index)
{
if(filter)
Q_EMIT transactionClicked(filter->mapToSource(index));
}
OverviewPage::~OverviewPage()
{
delete ui;
}
void OverviewPage::setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance, const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance)
{
int unit = walletModel->getOptionsModel()->getDisplayUnit();
currentBalance = balance;
currentUnconfirmedBalance = unconfirmedBalance;
currentImmatureBalance = immatureBalance;
currentWatchOnlyBalance = watchOnlyBalance;
currentWatchUnconfBalance = watchUnconfBalance;
currentWatchImmatureBalance = watchImmatureBalance;
ui->labelBalance->setText(BeCoinUnits::formatWithUnit(unit, balance, false, BeCoinUnits::separatorAlways));
ui->labelUnconfirmed->setText(BeCoinUnits::formatWithUnit(unit, unconfirmedBalance, false, BeCoinUnits::separatorAlways));
ui->labelImmature->setText(BeCoinUnits::formatWithUnit(unit, immatureBalance, false, BeCoinUnits::separatorAlways));
ui->labelTotal->setText(BeCoinUnits::formatWithUnit(unit, balance + unconfirmedBalance + immatureBalance, false, BeCoinUnits::separatorAlways));
ui->labelWatchAvailable->setText(BeCoinUnits::formatWithUnit(unit, watchOnlyBalance, false, BeCoinUnits::separatorAlways));
ui->labelWatchPending->setText(BeCoinUnits::formatWithUnit(unit, watchUnconfBalance, false, BeCoinUnits::separatorAlways));
ui->labelWatchImmature->setText(BeCoinUnits::formatWithUnit(unit, watchImmatureBalance, false, BeCoinUnits::separatorAlways));
ui->labelWatchTotal->setText(BeCoinUnits::formatWithUnit(unit, watchOnlyBalance + watchUnconfBalance + watchImmatureBalance, false, BeCoinUnits::separatorAlways));
// only show immature (newly mined) balance if it's non-zero, so as not to complicate things
// for the non-mining users
bool showImmature = immatureBalance != 0;
bool showWatchOnlyImmature = watchImmatureBalance != 0;
// for symmetry reasons also show immature label when the watch-only one is shown
ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
ui->labelWatchImmature->setVisible(showWatchOnlyImmature); // show watch-only immature balance
}
// show/hide watch-only labels
void OverviewPage::updateWatchOnlyLabels(bool showWatchOnly)
{
ui->labelSpendable->setVisible(showWatchOnly); // show spendable label (only when watch-only is active)
ui->labelWatchonly->setVisible(showWatchOnly); // show watch-only label
ui->lineWatchBalance->setVisible(showWatchOnly); // show watch-only balance separator line
ui->labelWatchAvailable->setVisible(showWatchOnly); // show watch-only available balance
ui->labelWatchPending->setVisible(showWatchOnly); // show watch-only pending balance
ui->labelWatchTotal->setVisible(showWatchOnly); // show watch-only total balance
if (!showWatchOnly)
ui->labelWatchImmature->hide();
}
void OverviewPage::setClientModel(ClientModel *model)
{
this->clientModel = model;
if(model)
{
// Show warning if this is a prerelease version
connect(model, SIGNAL(alertsChanged(QString)), this, SLOT(updateAlerts(QString)));
updateAlerts(model->getStatusBarWarnings());
}
}
void OverviewPage::setWalletModel(WalletModel *model)
{
this->walletModel = model;
if(model && model->getOptionsModel())
{
// Set up transaction list
filter = new TransactionFilterProxy();
filter->setSourceModel(model->getTransactionTableModel());
filter->setLimit(NUM_ITEMS);
filter->setDynamicSortFilter(true);
filter->setSortRole(Qt::EditRole);
filter->setShowInactive(false);
filter->sort(TransactionTableModel::Status, Qt::DescendingOrder);
ui->listTransactions->setModel(filter);
ui->listTransactions->setModelColumn(TransactionTableModel::ToAddress);
// Keep up to date with wallet
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance(),
model->getWatchBalance(), model->getWatchUnconfirmedBalance(), model->getWatchImmatureBalance());
connect(model, SIGNAL(balanceChanged(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)), this, SLOT(setBalance(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)));
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
updateWatchOnlyLabels(model->haveWatchOnly());
connect(model, SIGNAL(notifyWatchonlyChanged(bool)), this, SLOT(updateWatchOnlyLabels(bool)));
}
// update the display unit, to not use the default ("BEF")
updateDisplayUnit();
}
void OverviewPage::updateDisplayUnit()
{
if(walletModel && walletModel->getOptionsModel())
{
if(currentBalance != -1)
setBalance(currentBalance, currentUnconfirmedBalance, currentImmatureBalance,
currentWatchOnlyBalance, currentWatchUnconfBalance, currentWatchImmatureBalance);
// Update txdelegate->unit with the current unit
txdelegate->unit = walletModel->getOptionsModel()->getDisplayUnit();
ui->listTransactions->update();
}
}
void OverviewPage::updateAlerts(const QString &warnings)
{
this->ui->labelAlerts->setVisible(!warnings.isEmpty());
this->ui->labelAlerts->setText(warnings);
}
void OverviewPage::showOutOfSyncWarning(bool fShow)
{
ui->labelWalletStatus->setVisible(fShow);
ui->labelTransactionsStatus->setVisible(fShow);
}
|
MasterX1582/bitcoin-becoin
|
src/qt/overviewpage.cpp
|
C++
|
mit
| 11,072
|
/**
* primary:3a9aff 2989ee
* success:8fbe33 7ead22
* info:8fbeef 7eadde
* warning:ff6700 ee5600
* danger:e53935 d42824
* */
*{
font-family: 'Microsoft Yahei';
}
body,html{
font-size: 10px;
/* width: 100%;
height: 100%;
padding: 0;
margin: 0; */
}
@media screen and (max-width:960px) {
body,html{font-size: 12px;}
}
p,div,span,a,button,input,textarea{
font-size: 1.4rem !important;
font-size: 14px;
}
/**h1-h6*/
h1{
font-size: 3.2rem !important;
font-size: 32px;
font-weight: bold;
margin-top: 20px;
margin-bottom: 10px;
}
h2{
font-size: 2.8rem !important;
font-size: 28px;
font-weight: bold;
margin-top: 20px;
margin-bottom: 10px;
}
h3{
font-size: 2.2rem !important;
font-size: 22px;
font-weight: bold;
margin-top: 20px;
margin-bottom: 10px;
}
h4{
font-size: 1.8rem !important;
font-size: 18px;
font-weight: bold;
margin: 10px 0px;
}
h5{
font-size: 1.6rem !important;
font-size: 16px;
font-weight: bold;
margin: 10px 0px;
}
h6{
font-size: 1.2rem !important;
font-size: 12px;
font-weight: bold;
margin: 10px 0px;
}
/**文本对齐*/
.text-left{
text-align: left;
}
.text-center{
text-align: center;
}
.text-right{
text-align: right;
}
/**文本大小*/
.text-xxxlarge{
font-size: 3.0rem !important;
font-size: 30px;
}
.text-xxlarge{
font-size: 2.4rem !important;
font-size: 24px;
}
.text-xlarge{
font-size: 2.0rem !important;
font-size: 20px;
}
.text-large{
font-size: 1.6rem !important;
font-size: 16px;
}
.text-small{
font-size: 1.2rem !important;
font-size: 12px;
}
/*文本颜色*/
.text-primary,.text-blue{
color: #3a9aff !important;
}
.text-success,.text-green{
color: #8fbe33 !important;
}
.text-info,.text-sky-blue{
color: #8fbeef !important;
}
.text-warning,.text-orange{
color: #ff6700 !important;
}
.text-danger,.text-red{
color: #e53935 !important;
}
/*引用*/
div.h-quote,p.h-quote,span.h-quote{
border-left: 5px solid #aaa;
padding: 10px 15px;
background-color: #eee;
margin-bottom: 10px;
}
/*背景颜色*/
.bg-primary,.bg-blue{
background-color: #3a9aff !important;
color: #ffffff;
}
.bg-success,.bg-green{
background-color: #8fbe33 !important;
color: #ffffff;
}
.bg-info,.bg-sky-blue{
background-color: #8fbeef !important;
color: #ffffff;
}
.bg-warning,.bg-orange{
background-color: #ff6700 !important;
color: #ffffff;
}
.bg-danger,.bg-red{
background-color: #e53935 !important;
color: #ffffff;
}
/*显示 display*/
.dis-inline-block{
display: inline-block;
}
.dis-block{
display: block;
}
/*hr 分割线*/
hr{
margin: 10px 0px;
border-top: 1px solid transparent;
border-bottom: 1px solid #ddd;
border-left: 0;
}
/**hide 显示/隐藏*/
.show{
display: block !important;
}
.invisible{
visibility: hidden !important;
}
.hide{
display: none !important;
visibility: hidden !important;
}
/**浮动*/
.f-left{
float: left !important;
}
.f-right{
float: right !important;
}
/*clear float 清除浮动*/
.clear-float:before,.clear-float:after{
display: table;
content: "";
}
.clear-float:after{
clear: both;
height: 0;
line-height: 0;
font-size: 0;
}
/*外边距*/
.m-top-10{
margin-top: 10px;
}
.m-top-15{
margin-top: 15px;
}
.m-top-20{
margin-top: 20px;
}
.m-top-30{
margin-top: 30px;
}
.m-bottom-10{
margin-bottom: 10px;
}
.m-bottom-15{
margin-bottom: 15px;
}
.m-bottom-20{
margin-bottom: 20px;
}
.m-bottom-30{
margin-bottom: 30px;
}
.m-left-10{
margin-left: 10px;
}
.m-left-15{
margin-left: 15px;
}
.m-left-20{
margin-left: 20px;
}
.m-left-30{
margin-left: 30px;
}
.m-right-10{
margin-right: 10px;
}
.m-right-15{
margin-right: 15px;
}
.m-right-20{
margin-right: 20px;
}
.m-right-30{
margin-right: 30px;
}
/*内边距*/
.p-top-10{
padding-top: 10px;
}
.p-top-15{
padding-top: 15px;
}
.p-top-20{
padding-top: 20px;
}
.p-top-30{
padding-top: 30px;
}
.p-bottom-10{
padding-bottom: 10px;
}
.p-bottom-15{
padding-bottom: 15px;
}
.p-bottom-20{
padding-bottom: 20px;
}
.p-bottom-30{
padding-bottom: 30px;
}
.p-left-10{
padding-left: 10px;
}
.p-left-15{
padding-left: 15px;
}
.p-left-20{
padding-left: 20px;
}
.p-left-30{
padding-left: 30px;
}
.p-right-10{
padding-right: 10px;
}
.p-right-15{
padding-right: 15px;
}
.p-right-20{
padding-right: 20px;
}
.p-right-30{
padding-right: 30px;
}
|
Hishengs/heyui
|
css/base/base.css
|
CSS
|
mit
| 4,222
|
#include "List.hpp"
#include "Numbers.hpp"
#include "unity.h"
void test_empty_list(void) {
std::shared_ptr<const ISeq> e = List::Empty;
TEST_ASSERT_EQUAL_STRING("()", e->toString().c_str());
}
void test_empty_list_seq(void) {
std::shared_ptr<const ISeq> e = List::Empty;
TEST_ASSERT_EQUAL_STRING("()", e->seq()->toString().c_str());
TEST_ASSERT_EQUAL_PTR(List::Empty.get(), e->seq().get());
}
void test_empty_list_cons(void) {
std::shared_ptr<const ISeq> e = List::Empty;
std::shared_ptr<const ISeq> a = e->cons(std::make_shared<const Integer>(Integer(1)));
TEST_ASSERT_EQUAL_STRING("(1)", a->toString().c_str());
}
void test_empty_list_count(void) {
std::shared_ptr<const ISeq> e = List::Empty;
TEST_ASSERT_EQUAL_UINT(0, e->count());
}
void test_empty_list_empty(void) {
std::shared_ptr<const ISeq> e = List::Empty;
TEST_ASSERT_EQUAL_STRING("()", e->empty()->toString().c_str());
TEST_ASSERT_EQUAL_PTR(List::Empty.get(), e->empty().get());
}
void test_empty_list_first(void) {
std::shared_ptr<const ISeq> e = List::Empty;
TEST_ASSERT_EQUAL_PTR(NULL, e->first().get());
}
void test_empty_list_next(void) {
std::shared_ptr<const ISeq> e = List::Empty;
TEST_ASSERT_EQUAL_PTR(NULL, e->next().get());
}
void test_empty_list_more(void) {
std::shared_ptr<const ISeq> e = List::Empty;
TEST_ASSERT_EQUAL_STRING("()", e->more()->toString().c_str());
TEST_ASSERT_EQUAL_PTR(List::Empty.get(), e->more().get());
}
void test_list(void) {
const std::shared_ptr<List> a = std::make_shared<List>(std::make_shared<const Integer>(Integer(1)));
TEST_ASSERT_EQUAL_STRING("(1)", a->toString().c_str());
TEST_ASSERT_EQUAL_STRING("(1)", a->seq()->toString().c_str());
TEST_ASSERT_EQUAL_STRING("(2 1)", a->cons(std::make_shared<const Integer>(Integer(2)))->toString().c_str());
TEST_ASSERT_EQUAL_UINT(1, a->count());
TEST_ASSERT_EQUAL_PTR(List::Empty.get(), a->empty().get());
TEST_ASSERT_EQUAL_STRING("1", a->first()->toString().c_str());
TEST_ASSERT_EQUAL_STRING("()", a->more()->toString().c_str());
TEST_ASSERT_EQUAL_PTR(NULL, a->next().get());
}
void test_list2(void) {
std::vector<std::shared_ptr<const lisp_object> > entries({
std::make_shared<const Integer>(Integer(1)),
std::make_shared<const Integer>(Integer(2)),
std::make_shared<const Integer>(Integer(3)),
std::make_shared<const Integer>(Integer(4)),
std::make_shared<const Integer>(Integer(5)),
std::make_shared<const Integer>(Integer(6)),
std::make_shared<const Integer>(Integer(7)),
std::make_shared<const Integer>(Integer(8)),
});
const std::shared_ptr<List> a = std::make_shared<List>(entries);
TEST_ASSERT_EQUAL_STRING("(1 2 3 4 5 6 7 8)", a->toString().c_str());
TEST_ASSERT_EQUAL_STRING("(1 2 3 4 5 6 7 8)", a->seq()->toString().c_str());
TEST_ASSERT_EQUAL_STRING("(9 1 2 3 4 5 6 7 8)", a->cons(std::make_shared<const Integer>(Integer(9)))->toString().c_str());
TEST_ASSERT_EQUAL_UINT(8, a->count());
TEST_ASSERT_EQUAL_PTR(List::Empty.get(), a->empty().get());
TEST_ASSERT_EQUAL_STRING("1", a->first()->toString().c_str());
TEST_ASSERT_EQUAL_STRING("(2 3 4 5 6 7 8)", a->more()->toString().c_str());
TEST_ASSERT_EQUAL_STRING("(2 3 4 5 6 7 8)", a->next()->toString().c_str());
}
int main(void) {
UNITY_BEGIN();
RUN_TEST(test_empty_list);
RUN_TEST(test_empty_list_seq);
RUN_TEST(test_empty_list_cons);
RUN_TEST(test_empty_list_count);
RUN_TEST(test_empty_list_empty);
RUN_TEST(test_empty_list_first);
RUN_TEST(test_empty_list_next);
RUN_TEST(test_empty_list_more);
RUN_TEST(test_list);
RUN_TEST(test_list2);
return UNITY_END();
}
|
degustaf/lisp-compiler
|
unittest/TestList.cpp
|
C++
|
mit
| 3,594
|
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AngularJS Tutorials</title>
<link href="../Content/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<div ng-app="app">
<dumb-password></dumb-password>
</div>
<script src="../scripts/angular.min.js"></script>
<script src="main.js"></script>
</body>
</html>
|
danielmackay/Angular-Egghead
|
AngularEggHead/app17-elements/Index.html
|
HTML
|
mit
| 373
|
# PlanChat
A group chatting app for planning things
|
kylebshr/PlanChat
|
README.md
|
Markdown
|
mit
| 52
|
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="ApiGen 2.8.0" />
<title>Class ApiAxleTest\AllTests | fillup/apiaxle</title>
<script type="text/javascript" src="resources/combined.js?3551695169"></script>
<script type="text/javascript" src="elementlist.js?887202800"></script>
<link rel="stylesheet" type="text/css" media="all" href="resources/style.css?3505392360" />
</head>
<body>
<div id="left">
<div id="menu">
<a href="index.html" title="Overview"><span>Overview</span></a>
<div id="groups">
<h3>Namespaces</h3>
<ul>
<li><a href="namespace-ApiAxle.html">ApiAxle<span></span></a>
<ul>
<li><a href="namespace-ApiAxle.Api.html">Api</a>
</li>
<li><a href="namespace-ApiAxle.Shared.html">Shared</a>
</li>
</ul></li>
<li class="active"><a href="namespace-ApiAxleTest.html">ApiAxleTest<span></span></a>
<ul>
<li><a href="namespace-ApiAxleTest.Api.html">Api</a>
</li>
<li><a href="namespace-ApiAxleTest.Shared.html">Shared</a>
</li>
</ul></li>
<li><a href="namespace-PHP.html">PHP</a>
</li>
</ul>
</div>
<hr />
<div id="elements">
<h3>Classes</h3>
<ul>
<li class="active"><a href="class-ApiAxleTest.AllTests.html">AllTests</a></li>
</ul>
</div>
</div>
</div>
<div id="splitter"></div>
<div id="right">
<div id="rightInner">
<form id="search">
<input type="hidden" name="cx" value="" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="text" name="q" class="text" />
<input type="submit" value="Search" />
</form>
<div id="navigation">
<ul>
<li>
<a href="index.html" title="Overview"><span>Overview</span></a>
</li>
<li>
<a href="namespace-ApiAxleTest.html" title="Summary of ApiAxleTest"><span>Namespace</span></a>
</li>
<li class="active">
<span>Class</span> </li>
</ul>
<ul>
<li>
<a href="tree.html" title="Tree view of classes, interfaces, traits and exceptions"><span>Tree</span></a>
</li>
<li>
<a href="todo.html" title="Todo list"><span>Todo</span></a>
</li>
</ul>
<ul>
</ul>
</div>
<div id="content" class="class">
<h1>Class AllTests</h1>
<div class="info">
<b>Namespace:</b> <a href="namespace-ApiAxleTest.html">ApiAxleTest</a><br />
<b>Located at</b> <a href="source-class-ApiAxleTest.AllTests.html#9-20" title="Go to source code">tests/AllTests.php</a><br />
</div>
<table class="summary" id="methods">
<caption>Methods summary</caption>
<tr data-order="suite" id="_suite">
<td class="attributes"><code>
public static
</code>
</td>
<td class="name"><div>
<a class="anchor" href="#_suite">#</a>
<code><a href="source-class-ApiAxleTest.AllTests.html#11-19" title="Go to source code">suite</a>( )</code>
<div class="description short">
</div>
<div class="description detailed hidden">
</div>
</div></td>
</tr>
</table>
</div>
<div id="footer">
fillup/apiaxle API documentation generated by <a href="http://apigen.org">ApiGen 2.8.0</a>
</div>
</div>
</div>
</body>
</html>
|
fillup/apiaxle-module
|
docs/class-ApiAxleTest.AllTests.html
|
HTML
|
mit
| 3,198
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
this School-Project use
Package-Tools:
- npm:
- composer
Build-tool:
- gulp
Template: AdminKTE: https://almsaeedstudio.com/themes/AdminLTE/documentation/index.html#license
PHP Framework: Symfony: http://symfony.com/license
|
JackWolfskind/Tannte-Emma
|
LICENSE.md
|
Markdown
|
mit
| 734
|
#!/bin/bash
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
|
dartmedved/ubuntu-postinstall-v2
|
lang/nodejs/install-node.sh
|
Shell
|
mit
| 108
|
package com.client.core;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.http.HttpStatus;
import org.springframework.web.filter.OncePerRequestFilter;
import com.client.core.security.tools.RC4;
/**
* Filter used to authentication all calls to the web application.
*
* Current implementation is only to allow calls that either
* <ol>
* <li>Have an 'apiKey' parameter on them equal to the apiKey in the application settings file (i.e. the one injected into {@link ApplicationSettings}</li>
* <li>Have an encrypted 'apiKey' in the session. This essentially means that some previous request had an 'apiKey' url parameter and passed the filter.</li>
* </ol>
*/
public class SessionFilter extends OncePerRequestFilter {
private final Logger log = Logger.getLogger(getClass());
private final String sessionStoredApiKeyName;
private final String encryptionKey;
private final String apiKey;
public SessionFilter(ApplicationSettings appSettings) {
super();
this.sessionStoredApiKeyName = RandomStringUtils.randomAlphanumeric(32);
this.encryptionKey = RandomStringUtils.randomAlphanumeric(16);
this.apiKey = appSettings.getApiKey();
}
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
final HttpSession session = getSession(request);
final String apiKey = getApiKeyFromRequest(request);
final String previouslyAuthorizedApiKeyEncrypted = getApiKeyFromSession(session);
final String url = request.getRequestURL().toString();
boolean allowIn = false;
if (validApiKeyInSession(previouslyAuthorizedApiKeyEncrypted)) {
allowIn = true;
}
if (validApiKey(apiKey)) {
allowIn = true;
encryptApiKeyAndAddToSession(session, apiKey);
}
if (allowIn == false) {
log.info("Attempt to get to page: " + url + " was blocked in the SessionFilter. Returning 401 unauthorized response.");
response.sendError(HttpStatus.UNAUTHORIZED.value());
} else {
filterChain.doFilter(request, response);
}
}
private void encryptApiKeyAndAddToSession(HttpSession session, String apiKey) {
String encryptedApiKey = encryptApiKey(apiKey);
session.setAttribute(sessionStoredApiKeyName, encryptedApiKey);
}
public String encryptApiKey(String apiKey) {
return RC4.encryptAndEncode(apiKey, encryptionKey);
}
private boolean validApiKeyInSession(String previouslyAuthorizedApiKeyEncrypted) {
if (StringUtils.isBlank(previouslyAuthorizedApiKeyEncrypted)) {
return false;
}
String decryptedApiKey = decryptApiKey(previouslyAuthorizedApiKeyEncrypted);
return validApiKey(decryptedApiKey);
}
private String decryptApiKey(String previouslyAuthorizedApiKeyEncrypted) {
return RC4.decodeAndDecrypt(previouslyAuthorizedApiKeyEncrypted, encryptionKey);
}
private HttpSession getSession(HttpServletRequest request) {
return request.getSession();
}
private String getApiKeyFromSession(HttpSession session) {
return (String) session.getAttribute(sessionStoredApiKeyName);
}
private String getApiKeyFromRequest(HttpServletRequest request) {
String apiKey = request.getParameter("apiKey");
if (apiKey == null) {
apiKey = "";
}
String[] tmp = apiKey.split("\\?");
if (tmp.length > 1) {
apiKey = tmp[0];
}
return apiKey;
}
private boolean validApiKey(String apiKey) {
if (apiKey == null) {
apiKey = "";
}
if (apiKey.equals(this.apiKey)) {
return true;
}
return false;
}
public String getSessionStoredApiKeyName() {
return sessionStoredApiKeyName;
}
}
|
bullhorn/starter-kit-spring-maven
|
src/main/java/com/client/core/SessionFilter.java
|
Java
|
mit
| 3,987
|
#ifndef __THREADS_H__
#define __THREADS_H__
#include <lpc_types.h>
void thread_init(uint32_t quantaUs);
void thread_go(); // THIS WILL NEVER RETURN
int thread_create(void (*run)(void*), void* userdata);
void thread_kill(int thread_id);
void thread_self_term();
#endif
|
slugonamission/cortexm3-threads
|
threads.h
|
C
|
mit
| 271
|
/*
* main.cpp
*
* Created on: Nov 29, 2015
* Author: Gianluca Tiepolo <tiepolo.gian@gmail.com>
*/
#include "MQ.h"
#include <chrono>
int main(int argc, char *argv[]) {
if(argc < 2) {
std::cout << "Usage: ./example client|server" << std::endl;
return 1;
}
MQ *messageQ;
if(std::string(argv[1]) == "server") {
messageQ = new MQ("example", MQ::EndpointType::Server);
messageQ->listen([messageQ](std::string message){
std::cout << "Received: " << message << std::endl;
messageQ->sendMessage("Hello from the server!");
});
while(true) std::this_thread::sleep_for (std::chrono::seconds(1));
} else if(std::string(argv[1]) == "client") {
messageQ = new MQ("example", MQ::EndpointType::Client);
std::string data;
std::cout << "Write message to send and press ENTER:" << std::endl;
getline(std::cin, data);
messageQ->sendMessage(data);
std::cout << "Received: " << messageQ->readMessage() << std::endl;
}
delete messageQ;
return 0;
}
|
tiepologian/MQ
|
example/main.cpp
|
C++
|
mit
| 1,015
|
package com.hn.nishant.nvhn.network;
import com.google.firebase.FirebaseApp;
import com.hn.nishant.nvhn.App;
import com.hn.nishant.nvhn.BuildConfig;
import com.hn.nishant.nvhn.HNTestRunner;
import com.hn.nishant.nvhn.model.Story;
import com.hn.nishant.nvhn.view.activity.StoryActivity;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.util.ActivityController;
/**
* Created by nishant on 21.03.17.
*/
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class ,sdk =22)
@PrepareForTest({FirebaseApp.class})
public class RetrofitImplTest {
}
|
nishant304/hacker-news-client
|
app/src/test/java/com/hn/nishant/nvhn/network/RetrofitImplTest.java
|
Java
|
mit
| 1,011
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_51) on Mon Jun 30 01:29:13 PDT 2014 -->
<title>algorithms.compGeometry.clustering.twopointcorrelation</title>
<meta name="date" content="2014-06-30">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="algorithms.compGeometry.clustering.twopointcorrelation";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li class="navBarCell1Rev">Package</li>
<li>Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../algorithms/compGeometry/package-summary.html">Prev Package</a></li>
<li><a href="../../../../algorithms/compGeometry/convexHull/package-summary.html">Next Package</a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?algorithms/compGeometry/clustering/twopointcorrelation/package-summary.html" target="_top">Frames</a></li>
<li><a href="package-summary.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 title="Package" class="title">Package algorithms.compGeometry.clustering.twopointcorrelation</h1>
</div>
<div class="contentContainer">
<ul class="blockList">
<li class="blockList">
<table class="packageSummary" border="0" cellpadding="3" cellspacing="0" summary="Interface Summary table, listing interfaces, and an explanation">
<caption><span>Interface Summary</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Interface</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/IGroupFinder.html" title="interface in algorithms.compGeometry.clustering.twopointcorrelation">IGroupFinder</a></td>
<td class="colLast">
<div class="block">interface for classes that find groups of points based upon the background threshhold density.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/IPointBackgroundStats.html" title="interface in algorithms.compGeometry.clustering.twopointcorrelation">IPointBackgroundStats</a></td>
<td class="colLast">
<div class="block">interface for classes which supply an estimate of the background void density</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/ITwoPointIdentity.html" title="interface in algorithms.compGeometry.clustering.twopointcorrelation">ITwoPointIdentity</a></td>
<td class="colLast">
<div class="block">interface for classes used to hold a point identity pair uniquely.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/IVoidFinder.html" title="interface in algorithms.compGeometry.clustering.twopointcorrelation">IVoidFinder</a></td>
<td class="colLast">
<div class="block">interface for classes that find the voids (that is, space between points)
in the dataset</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="packageSummary" border="0" cellpadding="3" cellspacing="0" summary="Class Summary table, listing classes, and an explanation">
<caption><span>Class Summary</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Class</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/AbstractGroupFinder.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">AbstractGroupFinder</a></td>
<td class="colLast"> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/AbstractPointBackgroundStats.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">AbstractPointBackgroundStats</a></td>
<td class="colLast">
<div class="block">abstract class for implementations of IPointBackgroundStats to do some of the
boiler plate code such as file persistence</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/AbstractVoidFinder.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">AbstractVoidFinder</a></td>
<td class="colLast"> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/AxisIndexer.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">AxisIndexer</a></td>
<td class="colLast">
<div class="block">
Class to hold x and y array of points whose values have been
indexed by increasing x and y.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/CompleteSamplingVoidFinder.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">CompleteSamplingVoidFinder</a></td>
<td class="colLast">
<div class="block">
an implementation of VoidFinder that uses complete sampling to determine
the background (void) point density.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/DFSGroupFinder.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">DFSGroupFinder</a></td>
<td class="colLast">
<div class="block">
An implementation of IGroupFinder that uses a depth first search algorithm
to visit all nodes in a dataset and put into groups those within
distance < threshhold * threshholdFactor from each other.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/DivideAndConquerVoidFinder.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">DivideAndConquerVoidFinder</a></td>
<td class="colLast">
<div class="block">an implementation of IVoidFinder that uses a divide and conquer approach to sampling the
data.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/Main.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">Main</a></td>
<td class="colLast">
<div class="block">
Usage from the command line:
Requires a tab delimited text file with 4 columns: x, y, xErrors, yErrors.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/PerformanceMetricsRunner.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">PerformanceMetricsRunner</a></td>
<td class="colLast">
<div class="block">estimates performance metrics for TwoPointCorrelation as
the dependencies upon N of the amount of memory needed and the runtime.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/RandomClusterAndBackgroundGenerator.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">RandomClusterAndBackgroundGenerator</a></td>
<td class="colLast">
<div class="block">utility class for unit tests which need to create random background points and
points in clusters.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/SerializerUtil.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">SerializerUtil</a></td>
<td class="colLast">
<div class="block">a utility class for serializing and de-serializing the indexer contents to the file system</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/SimpleLinkedListNode.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">SimpleLinkedListNode</a></td>
<td class="colLast">
<div class="block">a node holding only a integer key and the next reference.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/SubsetSamplingVoidFinder.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">SubsetSamplingVoidFinder</a></td>
<td class="colLast">
<div class="block">an instance of IVoidFinder that uses a subsection of the AxisIndexer data.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/TwoPointBinarySearchTree.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">TwoPointBinarySearchTree</a></td>
<td class="colLast">
<div class="block">
A holder for two-point identities, where the identities are the indexes
of the indexer internal arrays.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/TwoPointCorrelation.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">TwoPointCorrelation</a></td>
<td class="colLast">
<div class="block">
Find clusters in data.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/TwoPointCorrelationPlotter.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">TwoPointCorrelationPlotter</a></td>
<td class="colLast">
<div class="block">
Convenience class to create a plot to visualize results of the
Two-Point correlation code.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/TwoPointHashMap.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">TwoPointHashMap</a></td>
<td class="colLast">
<div class="block">
A holder for two-point identities, where the identities are the indexes
of the indexer internal arrays.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/TwoPointIdentityFactory.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">TwoPointIdentityFactory</a></td>
<td class="colLast">
<div class="block">creates an instance of ITwoPointIdentity</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/TwoPointVoidStats.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">TwoPointVoidStats</a></td>
<td class="colLast">
<div class="block">
Class to estimate a background density for a set of points in which
the background density will be used by the calling program to find
clusters, that is groups of points associated by proximity, in the data.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/TwoPointVoidStatsPlotter.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">TwoPointVoidStatsPlotter</a></td>
<td class="colLast">
<div class="block">code to produce plots for visualizing the results of and debugging TwoPointVoidStats</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/VoidReader.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">VoidReader</a></td>
<td class="colLast">
<div class="block">a class to read a persisted set of background void points</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="packageSummary" border="0" cellpadding="3" cellspacing="0" summary="Enum Summary table, listing enums, and an explanation">
<caption><span>Enum Summary</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Enum</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/RandomClusterAndBackgroundGenerator.CLUSTER_SEPARATION.html" title="enum in algorithms.compGeometry.clustering.twopointcorrelation">RandomClusterAndBackgroundGenerator.CLUSTER_SEPARATION</a></td>
<td class="colLast"> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/TwoPointCorrelation.BACKGROUND_METHOD.html" title="enum in algorithms.compGeometry.clustering.twopointcorrelation">TwoPointCorrelation.BACKGROUND_METHOD</a></td>
<td class="colLast"> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/TwoPointCorrelation.STATE.html" title="enum in algorithms.compGeometry.clustering.twopointcorrelation">TwoPointCorrelation.STATE</a></td>
<td class="colLast"> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/TwoPointVoidStats.State.html" title="enum in algorithms.compGeometry.clustering.twopointcorrelation">TwoPointVoidStats.State</a></td>
<td class="colLast"> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/VoidSampling.html" title="enum in algorithms.compGeometry.clustering.twopointcorrelation">VoidSampling</a></td>
<td class="colLast">
<div class="block">enumeration of types of sampling for the background void points</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="packageSummary" border="0" cellpadding="3" cellspacing="0" summary="Exception Summary table, listing exceptions, and an explanation">
<caption><span>Exception Summary</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Exception</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../algorithms/compGeometry/clustering/twopointcorrelation/TwoPointVoidStatsException.html" title="class in algorithms.compGeometry.clustering.twopointcorrelation">TwoPointVoidStatsException</a></td>
<td class="colLast"> </td>
</tr>
</tbody>
</table>
</li>
</ul>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li class="navBarCell1Rev">Package</li>
<li>Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../algorithms/compGeometry/package-summary.html">Prev Package</a></li>
<li><a href="../../../../algorithms/compGeometry/convexHull/package-summary.html">Next Package</a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?algorithms/compGeometry/clustering/twopointcorrelation/package-summary.html" target="_top">Frames</a></li>
<li><a href="package-summary.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
|
tectronics/two-point-correlation
|
docs/api/algorithms/compGeometry/clustering/twopointcorrelation/package-summary.html
|
HTML
|
mit
| 17,410
|
namespace Lithogen.Core.Interfaces
{
/// <summary>
/// Determine whether a filename under the Views folder should be processed or totally ignored.
/// Typically used to filter out junk like .gitignore or partials, which are dealt with separately
/// by convention.
/// </summary>
public interface IViewFileNameFilter
{
/// <summary>
/// Determine whether a filename under the Views folder should be processed or totally ignored.
/// Typically used to filter out junk like .gitignore or partials, which are dealt with separately
/// by convention.
/// </summary>
/// <param name="fileName">The file to check.</param>
/// <returns>True if the file should be ignored, false otherwise.</returns>
bool ShouldIgnore(string fileName);
}
}
|
PhilipDaniels/Lithogen
|
Lithogen/Lithogen.Core/Interfaces/IViewFileNameFilter.cs
|
C#
|
mit
| 850
|
@extends('layout')
@section('content')
<form method="post" action="{{ route('user.role.store') }}">
{!! csrf_field() !!}
<div class="flexy mb-24 full-width sticky" id="publish-controls">
<h1 class="fill">{{ translate('cp.creating_role') }}</h1>
<div class="controls">
<button type="submit" class="btn btn-primary">{{ translate('cp.save') }}</button>
</div>
</div>
@include('roles.partials.form', ['role_title' => '', 'role_slug' => ''])
</form>
@endsection
|
ICJIA/icjia-tvpp
|
statamic/resources/views/roles/create.blade.php
|
PHP
|
mit
| 552
|
package org.lst.trading.lib.series;
import java.util.List;
import java.util.function.Function;
public class DoubleSeries extends TimeSeries<Double> {
String mName;
DoubleSeries(List<Entry<Double>> data, String name) {
super(data);
mName = name;
}
public DoubleSeries(String name) {
super();
mName = name;
}
public String getName() {
return mName;
}
public void setName(String name) {
mName = name;
}
public DoubleSeries merge(DoubleSeries other, MergeFunction<Double, Double> f) {
return new DoubleSeries(DoubleSeries.merge(this, other, f).mData, mName);
}
public DoubleSeries mapToDouble(Function<Double, Double> f) {
return new DoubleSeries(map(f).mData, mName);
}
public DoubleSeries plus(DoubleSeries other) {
return merge(other, (x, y) -> x + y);
}
public DoubleSeries plus(double other) {
return mapToDouble(x -> x + other);
}
public DoubleSeries mul(DoubleSeries other) {
return merge(other, (x, y) -> x * y);
}
public DoubleSeries mul(double factor) {
return mapToDouble(x -> x * factor);
}
public DoubleSeries div(DoubleSeries other) {
return merge(other, (x, y) -> x / y);
}
public DoubleSeries returns() {
return this.div(lag(1)).plus(-1);
}
public double getLast() {
return getData().get(size() - 1).getItem();
}
public DoubleSeries tail(int n) {
return new DoubleSeries(getData().subList(size() - n, size()), getName());
}
public DoubleSeries returns(int days) {
return this.div(lag(days)).plus(-1);
}
public double[] toArray() {
return stream().mapToDouble(Entry::getItem).toArray();
}
@Override public DoubleSeries toAscending() {
return new DoubleSeries(super.toAscending().mData, getName());
}
@Override public DoubleSeries toDescending() {
return new DoubleSeries(super.toDescending().mData, getName());
}
@Override public DoubleSeries lag(int k) {
return new DoubleSeries(super.lag(k).mData, getName());
}
@Override public String toString() {
return mData.isEmpty() ? "DoubleSeries{empty}" :
"DoubleSeries{" +
"mName=" + mName +
", from=" + mData.get(0).getInstant() +
", to=" + mData.get(mData.size() - 1).getInstant() +
", size=" + mData.size() +
'}';
}
}
|
Coderaio/quant
|
src/main/java/org/lst/trading/lib/series/DoubleSeries.java
|
Java
|
mit
| 2,531
|
# spec/features/authentication_process_spec.rb
#
feature "Authentication process for all users.", js: true do
context "Users " do
given(:user) { user_estester }
scenario "Sign in with username and password credentials." do
visit signin_url
fill_in 'Username', :with => user.username
fill_in 'Password', :with => "demos"
click_button 'Sign in'
expect(current_path).to eq home_pages_path
expect(page).to have_title("SknServices")
end
scenario "Required to sign in when page is secured." do
visit users_url
expect(current_path).to eq unauthenticated_sessions_path
expect(page).to have_alert_message("You must sign in before accessing")
end
scenario "Not required to sign in when page is unsecured." do
visit about_pages_url
expect(current_path).to eq about_pages_path
expect(page).to have_title("About")
end
scenario "Returned to originally requested page after signing in." do
user = page_user_eptester
visit users_url
expect(current_path).to eq unauthenticated_sessions_path
expect(page).to have_alert_message("You must sign in before accessing")
visit signin_url
fill_in 'Username', :with => user.username
fill_in 'Password', :with => "demos"
click_button 'Sign in'
expect(current_path).to eq users_path
click_link 'Sign out'
end
scenario "Unauthorized access is redirected to Not Authorized page with unauthorized message." do
user = page_user_bstester
visit new_user_url
expect(current_path).to eq unauthenticated_sessions_path
expect(page).to have_alert_message("You must sign in before accessing")
visit signin_url
fill_in 'Username', :with => user.username
fill_in 'Password', :with => "demos"
click_button 'Sign in'
expect(current_path).to eq not_authorized_sessions_path
expect(page).to have_alert_message "You are not authorized"
click_link 'Sign out'
end
scenario "Returned to Home page after sign out." do # uses :get vs the coded :delete method, add route for :get to resolve
user = page_user_eptester
visit users_url
expect(current_path).to eq unauthenticated_sessions_path
expect(page).to have_alert_message("You must sign in before accessing")
visit signin_url
fill_in 'Username', :with => user.username
fill_in 'Password', :with => "demos"
click_button 'Sign in'
expect(current_path).to eq users_path
click_link 'Sign out'
expect(current_url).to eq home_pages_url
expect(page).to have_notice_message("You have been signed out")
end
end
context "Using bad credentials." do
let(:user) { page_user_estester }
scenario "Cannot sign in with incorrect username." do
visit signin_url
fill_in 'Username', :with => "LastNameInitial"
fill_in 'Password', :with => "demos"
click_button 'Sign in'
expect(current_path).to eq sessions_path
expect(page).to have_notice_message("Your Credentials are invalid or expired")
end
scenario "Cannot sign in with incorrect password." do
visit signin_url
fill_in 'Username', :with => user.username
fill_in 'Password', :with => "somebody"
click_button 'Sign in'
expect(current_path).to eq sessions_path
expect(page).to have_notice_message("Your Credentials are invalid or expired")
end
scenario "Cannot sign in when no credentials are offered." do
visit signin_url
click_button 'Sign in'
expect(current_path).to eq sessions_path
expect(page).to have_notice_message("Your Credentials are invalid or expired")
end
end
end
|
skoona/SknServices
|
spec/features/processes/authentication_process_spec.rb
|
Ruby
|
mit
| 3,733
|
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="viewport" content = "user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<title>FloraJS | Simulate natural systems with JavaScript</title>
<link rel="stylesheet" href="css/Burner.min.css" type="text/css" charset="utf-8">
<link rel="stylesheet" href="css/Flora.min.css" type="text/css" charset="utf-8">
<script src="scripts/Burner.min.js" type="text/javascript" charset="utf-8"></script>
<script src="scripts/Flora.min.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<script src="scripts/roll.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>
|
vinceallenvince/FloraJS-Flocking
|
public/roll.html
|
HTML
|
mit
| 881
|
# -*- coding:utf-8 -*-
from collections import defaultdict
import numpy
class ThompsonAgent:
def __init__(self, seed=None):
self._succeeds = defaultdict(int)
self._fails = defaultdict(int)
self._np_random = numpy.random.RandomState(seed)
def choose(self, arms, features=None):
return max(arms, key=lambda arm: self._score(arm))
def _score(self, arm):
return self._np_random.beta(
self._succeeds[arm] + 0.5,
self._fails[arm] + 0.5)
def update(self, arm, reward, arms=None, features=None):
if reward > 0:
self._succeeds[arm] += 1
else:
self._fails[arms] += 1
|
ohtaman/pynm
|
pynm/reinforce/bandit/thompson.py
|
Python
|
mit
| 683
|
<?php
namespace UserBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use FOS\UserBundle\Model\User as BaseUser;
/**
* Admin
*
* @ORM\Table(name="admin")
* @ORM\Entity(repositoryClass="UserBundle\Repository\AdminRepository")
*/
class Admin extends BaseUser
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
}
|
manolo317/fil-rouge
|
src/UserBundle/Entity/Admin.php
|
PHP
|
mit
| 463
|
#include <iostream>
using std::cout;
const int MAX = 20;
void sum_matrices(int first_matrix[][MAX], int second_matrix[][MAX],
int m, int n, int result_matrix[][MAX]) {
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
result_matrix[i][j] = first_matrix[i][j] + second_matrix[i][j];
}
}
}
void print_matrix(int matrix[][MAX], int m, int n) {
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
cout << matrix[i][j] << ' ';
}
cout << '\n';
}
}
int main() {
int first_matrix[MAX][MAX] = {
{1, 2},
{3, 4},
{5, 6},
{7, 8}
};
int second_matrix[MAX][MAX] = {
{2, 3},
{4, 5},
{6, 7},
{8, 9}
};
int result_matrix[MAX][MAX];
sum_matrices(first_matrix, second_matrix, 4, 2, result_matrix);
print_matrix(result_matrix, 4, 2);
return 0;
}
|
dimitaruzunov/up-2016
|
exercises/09/sum-matrices.cpp
|
C++
|
mit
| 860
|
<?php defined('PHPFOX') or exit('NO DICE!'); ?>
<?php /* Cached: February 25, 2013, 5:25 am */ ?>
<?php
/**
* [PHPFOX_HEADER]
*
* @copyright [PHPFOX_COPYRIGHT]
* @author Raymond Benc
* @package Phpfox
* @version $Id: menu.html.php 3346 2011-10-24 15:20:05Z Raymond_Benc $
*/
?>
<?php if (( $this->_aVars['aListing']['user_id'] == Phpfox ::getUserId() && Phpfox ::getUserParam('advancedmarketplace.can_edit_own_listing')) || Phpfox ::getUserParam('advancedmarketplace.can_edit_other_listing')): ?>
<li><a href="<?php echo Phpfox::getLib('phpfox.url')->makeUrl('advancedmarketplace.add', array('id' => $this->_aVars['aListing']['listing_id'])); ?>" title="<?php echo Phpfox::getPhrase('advancedmarketplace.edit_listing'); ?>"><?php echo Phpfox::getPhrase('advancedmarketplace.edit_listing'); ?></a></li>
<li><a href="<?php echo Phpfox::getLib('phpfox.url')->makeUrl('advancedmarketplace.add.customize', array('id' => $this->_aVars['aListing']['listing_id'])); ?>" title="<?php echo Phpfox::getPhrase('advancedmarketplace.manage_photos'); ?>"><?php echo Phpfox::getPhrase('advancedmarketplace.manage_photos'); ?></a></li>
<li><a href="<?php echo Phpfox::getLib('phpfox.url')->makeUrl('advancedmarketplace.add.invite', array('id' => $this->_aVars['aListing']['listing_id'])); ?>" title="<?php echo Phpfox::getPhrase('advancedmarketplace.send_invitations'); ?>"><?php echo Phpfox::getPhrase('advancedmarketplace.send_invitations'); ?></a></li>
<li><a href="<?php echo Phpfox::getLib('phpfox.url')->makeUrl('advancedmarketplace.add.manage', array('id' => $this->_aVars['aListing']['listing_id'])); ?>" title="<?php echo Phpfox::getPhrase('advancedmarketplace.manage_invites'); ?>"><?php echo Phpfox::getPhrase('advancedmarketplace.manage_invites'); ?></a></li>
<?php endif; ?>
<?php if (Phpfox ::getUserParam('advancedmarketplace.can_feature_listings') && $this->_aVars['aListing']['post_status'] != 2): ?>
<li class="js_advancedmarketplace_is_feature" <?php if ($this->_aVars['aListing']['is_featured']): ?> style="display:none;"<?php endif; ?>><a href="#" onclick="$('#js_featured_phrase_<?php echo $this->_aVars['aListing']['listing_id']; ?>').show(); $.ajaxCall('advancedmarketplace.feature', 'listing_id=<?php echo $this->_aVars['aListing']['listing_id']; ?>&type=1', 'GET'); $(this).parent().hide(); $(this).parents('ul:first').find('.js_advancedmarketplace_is_un_feature').show(); return false;"><?php echo Phpfox::getPhrase('advancedmarketplace.feature'); ?></a></li>
<li class="js_advancedmarketplace_is_un_feature" <?php if (! $this->_aVars['aListing']['is_featured']): ?> style="display:none;"<?php endif; ?>><a href="#" onclick="$('#js_featured_phrase_<?php echo $this->_aVars['aListing']['listing_id']; ?>').hide(); $.ajaxCall('advancedmarketplace.feature', 'listing_id=<?php echo $this->_aVars['aListing']['listing_id']; ?>&type=0', 'GET'); $(this).parent().hide(); $(this).parents('ul:first').find('.js_advancedmarketplace_is_feature').show(); return false;"><?php echo Phpfox::getPhrase('advancedmarketplace.un_feature'); ?></a></li>
<?php endif; ?>
<?php if (Phpfox ::getUserParam('advancedmarketplace.can_sponsor_advancedmarketplace') && $this->_aVars['aListing']['post_status'] != 2): ?>
<li>
<span id="js_sponsor_<?php echo $this->_aVars['aListing']['listing_id']; ?>">
<?php if ($this->_aVars['aListing']['is_sponsor']): ?>
<a href="#" onclick="$('#js_sponsor_phrase_<?php echo $this->_aVars['aListing']['listing_id']; ?>').hide(); $.ajaxCall('advancedmarketplace.sponsor','listing_id=<?php echo $this->_aVars['aListing']['listing_id']; ?>&type=0', 'GET'); return false;">
<?php echo Phpfox::getPhrase('advancedmarketplace.unsponsor_this_listing'); ?>
</a>
<?php else: ?>
<a href="#" onclick="$('#js_sponsor_phrase_<?php echo $this->_aVars['aListing']['listing_id']; ?>').show(); $.ajaxCall('advancedmarketplace.sponsor','listing_id=<?php echo $this->_aVars['aListing']['listing_id']; ?>&type=1', 'GET'); return false;">
<?php echo Phpfox::getPhrase('advancedmarketplace.sponsor_this_listing'); ?>
</a>
<?php endif; ?>
</span>
</li>
<?php elseif (Phpfox ::getUserParam('advancedmarketplace.can_purchase_sponsor') && $this->_aVars['aListing']['user_id'] == Phpfox ::getUserId() && $this->_aVars['aListing']['is_sponsor'] != 1): ?>
<li>
<a href="<?php echo Phpfox::permalink('ad.sponsor', $this->_aVars['aListing']['listing_id'], null, false, null, (array) array (
)); ?>section_advancedmarketplace/">
<?php echo Phpfox::getPhrase('advancedmarketplace.sponsor_this_listing'); ?>
</a>
</li>
<?php endif; ?>
<?php if (( $this->_aVars['aListing']['user_id'] == Phpfox ::getUserId() && Phpfox ::getUserParam('advancedmarketplace.can_delete_own_listing')) || Phpfox ::getUserParam('advancedmarketplace.can_delete_other_listings')): ?>
<li class="item_delete"><a href="<?php echo Phpfox::getLib('phpfox.url')->makeUrl('advancedmarketplace', array('delete' => $this->_aVars['aListing']['listing_id'])); ?>" class="sJsConfirm"><?php echo Phpfox::getPhrase('advancedmarketplace.delete_listing'); ?></a></li>
<?php endif; ?>
|
edbiler/BazaarCorner
|
file/cache_for_deletion/template/advancedmarketplace_template_default_block_menu.html.php.php
|
PHP
|
mit
| 5,108
|
import React from 'react';
import Link from 'gatsby-link';
import '../css/tags.css';
export default function Tags({ list = [] }) {
return (
<div className="tag-list">
{list.map(tag =>
<Link className="tag" to={`/tags/${tag}`}>
{tag}
</Link>
)}
</div>
);
}
|
HugoReeves/tfr-blog
|
src/components/Tags.js
|
JavaScript
|
mit
| 314
|
/*!
* Start Bootstrap - Grayscale Bootstrap Theme (http://startbootstrap.com)
* Code licensed under the Apache License v2.0.
* For details, see http://www.apache.org/licenses/LICENSE-2.0.
*/
body {
width: 100%;
height: 100%;
font-family: Lora,"Helvetica Neue",Helvetica,Arial,sans-serif;
color: #fff;
background-color: #49112A;
}
html {
width: 100%;
height: 100%;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 0 0 35px;
text-transform: uppercase;
font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;
font-weight: 700;
letter-spacing: 1px;
}
p {
margin: 0 0 25px;
font-size: 18px;
line-height: 1.5;
}
.agreement{
font-size: 14px !important;
}
@media(min-width:767px) {
p {
margin: 0 0 35px;
font-size: 20px;
line-height: 1.6;
}
}
a {
color: #219ab3;
-webkit-transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
}
a:hover,
a:focus {
text-decoration: none;
color: #11505d;
}
.light {
font-weight: 400;
}
.navbar-custom {
margin-bottom: 0;
border-bottom: 1px solid rgba(255,255,255,.3);
text-transform: uppercase;
font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;
background-color: #6C0D38;
}
.navbar-custom .navbar-brand {
font-weight: 700;
}
.navbar-custom .navbar-brand:focus {
outline: 0;
}
.navbar-custom .navbar-brand .navbar-toggle {
padding: 4px 6px;
font-size: 16px;
color: #fff;
}
.navbar-custom .navbar-brand .navbar-toggle:focus,
.navbar-custom .navbar-brand .navbar-toggle:active {
outline: 0;
}
.navbar-custom a {
color: #fff;
}
.navbar-custom .nav li.active {
outline: nonte;
background-color: rgba(255,255,255,.3);
}
.navbar-custom .nav li a {
-webkit-transition: background .3s ease-in-out;
-moz-transition: background .3s ease-in-out;
transition: background .3s ease-in-out;
}
.navbar-custom .nav li a:hover,
.navbar-custom .nav li a:focus,
.navbar-custom .nav li a.active {
outline: 0;
background-color: rgba(255,255,255,.3);
}
@media(min-width:767px) {
.navbar {
padding: 20px 0;
border-bottom: 0;
letter-spacing: 1px;
background: 0 0;
-webkit-transition: background .5s ease-in-out,padding .5s ease-in-out;
-moz-transition: background .5s ease-in-out,padding .5s ease-in-out;
transition: background .5s ease-in-out,padding .5s ease-in-out;
}
.top-nav-collapse {
padding: 0;
background-color: #6C0D38;
}
.navbar-custom.top-nav-collapse {
border-bottom: 1px solid rgba(255,255,255,.3);
}
}
.intro {
display: table;
width: 100%;
height: auto;
padding: 100px 0;
text-align: center;
color: #fff;
background: url(../img/intro-bg.jpg) no-repeat bottom center scroll;
background-color: #6C0D38;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
.intro .intro-body {
display: table-cell;
vertical-align: middle;
}
.intro .intro-body .brand-heading {
color: #660D35;
border-radius:4px;
border: 0px solid black;
opacity:0.6;
filter:alpha(opacity=60);
font-size: 40px;
}
.intro .intro-body .intro-text {
font-size: 18px;
background-color: #660D35;
border-radius:4px;
border: 0px solid black;
opacity:0.6;
filter:alpha(opacity=60); /* For IE8 and earlier */
}
.login-area {
font-size: 18px;
background-color: #660D35;
border-radius:4px;
border: 0px solid black;
opacity:0.6;
filter:alpha(opacity=60); /* For IE8 and earlier */
}
.register-area {
color: #680D36;
font-size: 18px;
background-color: #fff;
border-radius:4px;
border: 0px solid black;
opacity:0.6;
filter:alpha(opacity=60); /* For IE8 and earlier */
}
.form-area{
padding:10px;
}
.f-well{
color: #660D35;
}
.tooltip.top .tooltip-inner {
background-color: #660D35;
font-size: 18px;
border: 0px solid black;
opacity:0.6;
filter:alpha(opacity=60); /* For IE8 and earlier */
}
.tooltip.top .tooltip-arrow {
border-top-color: #660D35;
}
@media(min-width:767px) {
.intro {
height: 100%;
padding: 0;
}
.intro .intro-body .brand-heading {
font-size: 100px;
}
.intro .intro-body .intro-text {
font-size: 25px;
}
}
.btn-circle {
width: 70px;
height: 70px;
margin-top: 15px;
padding: 7px 16px;
border: 2px solid #fff;
border-radius: 35px;
font-size: 40px;
color: #fff;
background: 0 0;
-webkit-transition: background .3s ease-in-out;
-moz-transition: background .3s ease-in-out;
transition: background .3s ease-in-out;
}
.btn-circle:hover,
.btn-circle:focus {
outline: 0;
color: #fff;
background: rgba(255,255,255,.1);
}
.btn-circle i.animated {
-webkit-transition-property: -webkit-transform;
-webkit-transition-duration: 1s;
-moz-transition-property: -moz-transform;
-moz-transition-duration: 1s;
}
.btn-circle:hover i.animated {
-webkit-animation-name: pulse;
-moz-animation-name: pulse;
-webkit-animation-duration: 1.5s;
-moz-animation-duration: 1.5s;
-webkit-animation-iteration-count: infinite;
-moz-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
-moz-animation-timing-function: linear;
}
@-webkit-keyframes pulse {
0 {
-webkit-transform: scale(1);
transform: scale(1);
}
50% {
-webkit-transform: scale(1.2);
transform: scale(1.2);
}
100% {
-webkit-transform: scale(1);
transform: scale(1);
}
}
@-moz-keyframes pulse {
0 {
-moz-transform: scale(1);
transform: scale(1);
}
50% {
-moz-transform: scale(1.2);
transform: scale(1.2);
}
100% {
-moz-transform: scale(1);
transform: scale(1);
}
}
.content-section {
padding-top: 100px;
border-radius:4px;
border: 0px solid black;
}
.download-section {
width: 100%;
padding: 50px 0;
border-radius:4px;
border: 0px solid black;
opacity:0.6;
filter:alpha(opacity=60);
color: #fff;
background: url(../img/downloads-bg.jpg) no-repeat center center scroll;
background-color: #6C0D38;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
#map {
width: 100%;
height: 200px;
margin-top: 100px;
}
@media(min-width:767px) {
.content-section {
padding-top: 250px;
}
.download-section {
padding: 100px 0;
}
#map {
height: 400px;
margin-top: 250px;
}
}
.btn {
text-transform: uppercase;
font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;
font-weight: 400;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
}
.btn-default {
border: 1px solid #219ab3;
color: #219ab3;
background-color: transparent;
}
.btn-default:hover,
.btn-default:focus {
border: 1px solid #219ab3;
outline: 0;
color: #6C0D38;
background-color: #219ab3;
}
ul.banner-social-buttons {
margin-top: 0;
}
@media(max-width:1199px) {
ul.banner-social-buttons {
margin-top: 15px;
}
}
@media(max-width:767px) {
ul.banner-social-buttons li {
display: block;
margin-bottom: 20px;
padding: 0;
}
ul.banner-social-buttons li:last-child {
margin-bottom: 0;
}
}
footer {
padding: 50px 0;
}
footer p {
margin: 0;
}
::-moz-selection {
text-shadow: none;
background: #fcfcfc;
background: rgba(255,255,255,.2);
}
::selection {
text-shadow: none;
background: #fcfcfc;
background: rgba(255,255,255,.2);
}
.error_msg{
background-color: #E00B0B;
font-size: 20px;
}
img::selection {
background: 0 0;
}
img::-moz-selection {
background: 0 0;
}
body {
webkit-tap-highlight-color: rgba(255,255,255,.2);
}
|
theredfoxfire/lc
|
src/Lc/LcBundle/Resources/public/css/grayscale.css
|
CSS
|
mit
| 8,156
|
package database;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.NavigableSet;
import org.mapdb.BTreeMap;
import org.mapdb.Bind;
import org.mapdb.DB;
import org.mapdb.DBMaker;
import org.mapdb.Fun;
import qora.crypto.Base58;
import qora.crypto.Crypto;
import utils.ObserverMessage;
import at.AT;
import com.google.common.collect.Lists;
import database.serializer.ATSerializer;
@SuppressWarnings("rawtypes")
public class ATMap extends DBMap<String, AT>
{
private Map<Integer, Integer> observableData = new HashMap<Integer, Integer>();
private NavigableSet typeATs;
private NavigableSet creatorATs;
private NavigableSet orderedATs;
private NavigableSet creationHeightATs;
private NavigableSet hashATs;
private Map<String, byte[]> stateAT;
private Map<String, String> hashCodes;
private BTreeMap<String, Integer> atToNextHeight;
private ATMap parentATMap;
public ATMap(DBSet databaseSet, DB database)
{
super(databaseSet, database);
this.observableData.put(DBMap.NOTIFY_ADD, ObserverMessage.ADD_AT_TYPE);
this.observableData.put(DBMap.NOTIFY_REMOVE, ObserverMessage.REMOVE_AT_TYPE);
this.observableData.put(DBMap.NOTIFY_LIST, ObserverMessage.LIST_ATS);
}
public ATMap(ATMap parent)
{
super(parent);
this.parentATMap = parent;
}
protected void createIndexes(DB database){
//
}
@Override
protected Map<String, AT> getMap(DB database)
{
//OPEN MAP
return this.openMap(database);
}
@Override
protected Map<String, AT> getMemoryMap()
{
DB database = DBMaker.newMemoryDB().make();
//OPEN MAP
return this.openMap(database);
}
@SuppressWarnings("unchecked")
private Map<String, AT> openMap(DB database)
{
//OPEN MAP
BTreeMap<String, AT> map = database.createTreeMap("ats")
.valueSerializer(new ATSerializer())
.makeOrGet();
this.typeATs = database.createTreeSet("type_ats")
.comparator(Fun.COMPARATOR)
.makeOrGet();
Bind.secondaryKey(map, this.typeATs, new Fun.Function2<String, String, AT >(){
@Override
public String run(String key, AT value)
{
return value.getType();
}
});
this.creatorATs = database.createTreeSet("creator_ats")
.comparator(Fun.COMPARATOR)
.makeOrGet();
Bind.secondaryKey(map, this.creatorATs, new Fun.Function2<String, String, AT>(){
@Override
public String run(String key, AT value)
{
return Base58.encode( value.getCreator() );
}
});
this.atToNextHeight = database.createTreeMap("at_to_next_height").comparator(Fun.COMPARATOR).makeOrGet();
Bind.secondaryValue( map, this.atToNextHeight, new Fun.Function2<Integer, String, AT>(){
@Override
public Integer run(String key, AT value)
{
return value.getHeight() + value.getWaitForNumberOfBlocks();
}
});
this.orderedATs = database.createTreeSet("ordered_ats")
.comparator(Fun.COMPARATOR)
.makeOrGet();
Bind.secondaryKey(this.atToNextHeight, this.orderedATs, new Fun.Function2<Integer, String, Integer>(){
@Override
public Integer run(String key, Integer value)
{
return value;
}
});
this.creationHeightATs = database.createTreeSet("creation_height_ats")
.comparator(Fun.COMPARATOR)
.makeOrGet();
Bind.secondaryKey(map, this.creationHeightATs, new Fun.Function2<Integer, String, AT>(){
@Override
public Integer run(String key, AT value)
{
return value.getCreationBlockHeight();
}
});
this.stateAT = database.createTreeMap("state_ats_index").comparator(Fun.COMPARATOR).makeOrGet();
Bind.secondaryValue(map, this.stateAT, new Fun.Function2<byte[], String, AT>(){
@Override
public byte[] run(String key, AT value)
{
return value.getState();
}
});
this.hashCodes = database.createTreeMap("hash_code_ats").comparator(Fun.COMPARATOR).makeOrGet();
Bind.secondaryValue(map, this.hashCodes, new Fun.Function2<String, String, AT>(){
@Override
public String run(String key, AT value)
{
return Base58.encode(Crypto.getInstance().digest(value.getAp_Code()));
}
});
this.hashATs = database.createTreeSet("hash_ats").comparator(Fun.COMPARATOR).makeOrGet();
Bind.secondaryKey(map, this.hashATs, new Fun.Function2<String, String, AT >(){
@Override
public String run(String key, AT value)
{
return Base58.encode(Crypto.getInstance().digest(value.getAp_Code()));
}
});
//RETURN
return map;
}
@SuppressWarnings("unchecked")
public boolean validTypeHash(byte[] hash, String type, Integer forkHeight)
{
String hashString = Base58.encode( hash );
if ( (!this.hashCodes.containsValue( hashString ) && !Fun.filter(this.typeATs, type).iterator().hasNext() ))
{
return (this.parentATMap!=null)?this.parentATMap.validTypeHash(hash, type, forkHeight):true;
}
if ( this.hashCodes.containsValue(hashString) && Fun.filter(this.typeATs, type).iterator().hasNext() )
{
Iterable<String> ats = getTypeATs(type);
if ( this.hashCodes.get(ats.iterator().next()).equals( hashString ) )
{
return true;
}
}
if ( forkHeight > 1 )
{
Iterable<String> ats = getTypeATs(type);
Iterator<String> iter = ats.iterator();
while ( iter.hasNext() )
{
AT at = getAT(iter.next() );
if ( at.getCreationBlockHeight() < forkHeight && forkHeight > 1 )
{
return false;
}
}
iter = Fun.filter(this.hashATs, hashString).iterator();
while ( iter.hasNext() )
{
AT at = getAT(iter.next());
if ( at.getCreationBlockHeight() < forkHeight && forkHeight > 1)
{
return false;
}
}
return true;
}
return false;
}
@SuppressWarnings("unchecked")
public Iterable<String> getTypeATs(String type)
{
return Fun.filter(this.typeATs, type);
}
public Collection<String> getTypeATsList(String type)
{
@SuppressWarnings("unchecked")
Collection<String> keys = Lists.newArrayList(Fun.filter(this.typeATs, type) );
return keys;
}
@Override
protected AT getDefaultValue()
{
return null;
}
@Override
protected Map<Integer, Integer> getObservableData()
{
return this.observableData;
}
public boolean add(AT at)
{
//TODO CHECK PROPER at.getCreator() ENCODING
return add(at, at.getCreationBlockHeight());
}
public boolean add(AT at, Integer height)
{
return this.set(Base58.encode(at.getId()), at);
}
public void update(AT at, Integer height)
{
delete(at);
add(at, height);
}
public void delete(AT at)
{
this.map.remove( Base58.encode(at.getId()));
}
//GET AT BY ID
public AT getAT( String id )
{
AT at = this.map.get(id);
if (at!=null)
{
byte[] state = stateAT.get(id);
at.setState(state);
}
return at;
}
public AT getAT( byte[] id )
{
String atId = Base58.encode( id );
AT at = getAT(atId);
if (at == null && this.parent!=null)
{
at = this.parent.get(atId);
}
return at;
}
//delete all ATs created after blockHeight
@SuppressWarnings({ "unchecked" })
public void deleteAllAfterHeight(int blockHeight)
{
Iterable<String> ids = Fun.filter(this.creationHeightATs, blockHeight + 1 , true , Integer.MAX_VALUE , true);
Iterator<String> iter = ids.iterator();
while ( iter.hasNext() )
{
delete(iter.next());
}
}
@SuppressWarnings({ "unchecked" })
public Iterable<String> getATsLimited(int limit)
{
Iterable<String> ids = Fun.filter(this.creationHeightATs, limit + 1, true, Integer.MAX_VALUE, true);
return ids;
}
@SuppressWarnings({ "unchecked" })
public Iterable<String> getATsByCreator(String creator)
{
return Fun.filter(this.creatorATs, creator);
}
//get ATs sorted by lastRunBlockHeight
@SuppressWarnings({ "unchecked" })
public Iterator< String > getOrderedATs(Integer height)
{
return Fun.filter(this.orderedATs, null , true, height , true).iterator();
}
public DBMap<String, AT> getParent() {
return this.parent;
}
@SuppressWarnings({ "unchecked"})
public SortableList<String, AT> getAcctATs(String type, boolean initiators)
{
Collection<String> keys = Lists.newArrayList(Fun.filter(this.typeATs, type));
//RETURN
return new SortableList<String, AT>(this, keys);
}
}
|
Qoracoin/Qora
|
Qora/src/database/ATMap.java
|
Java
|
mit
| 8,118
|
<template>
<h1>Order Search</h1>
</template>
|
cmichaelgraham/aurelia-axel-northwind
|
aurelia-axel-northwind/views/search/order/search-order.html
|
HTML
|
mit
| 51
|
var webpack = require('webpack'),
webpackConfig = require('./webpack.config.base'),
DefinePlugin = require('webpack/lib/DefinePlugin'),
SourceMapDevToolPlugin = require('webpack/lib/SourceMapDevToolPlugin'),
env = require('../environment/dev.env');
webpackConfig.module.rules = [{
test: /\.ts$/,
exclude: /node_modules/,
loader: 'awesome-typescript-loader',
query: {
compilerOptions: {
inlineSourceMap: true,
sourceMap: false
}
}
},
{
test: /\.html$/,
loader: 'raw-loader',
exclude: ['./src/index.html']
},
{
test: /\.scss$/,
use: [{
loader: 'style-loader'
},
{
loader: 'css-loader'
},
{
loader: 'sass-loader'
}
]
},
{
test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2)$/,
loader: 'url-loader?limit=8192'
}
];
webpackConfig.plugins = [...webpackConfig.plugins,
new SourceMapDevToolPlugin({
filename: null, // if no value is provided the sourcemap is inlined
test: /\.(ts|js)($|\?)/i
}),
new DefinePlugin({
'process.env': env
})
];
webpackConfig.devtool = 'inline-source-map';
module.exports = webpackConfig;
|
bamboo-c/vue-vuex-boilerplate
|
template/config/webpack.config.test.js
|
JavaScript
|
mit
| 1,183
|
package pav.sprykerFileCreator.model.definition.spryker;
import pav.sprykerFileCreator.model.definition.ClassDefinitionInterface;
import pav.sprykerFileCreator.model.generator.SprykerConstants;
public class ZedBusinessFactoryDefinition implements ClassDefinitionInterface {
@Override
public String getClassType() {
return SprykerConstants.ZED_BUSINESS_FACTORY;
}
@Override
public String getNamePattern() {
return "{{ bundleName }}BusinessFactory";
}
@Override
public String getNamespacePattern() {
return "{{ projectName }}\\Zed\\{{ bundleName }}\\Business";
}
@Override
public String getMethodForReturnType() {
return "getFactory()";
}
@Override
public String[] getDocBlockClasses() {
String [] docBlockClasses = {
SprykerConstants.ZED_CONFIG,
SprykerConstants.ZED_QUERY_CONTAINER
};
return docBlockClasses;
}
@Override
public String getDefaultParentClass() {
return "Spryker\\Zed\\Kernel\\Business\\AbstractBusinessFactory";
}
}
|
project-a/idea-php-spryker-plugin
|
src/pav/sprykerFileCreator/model/definition/spryker/ZedBusinessFactoryDefinition.java
|
Java
|
mit
| 1,109
|
package images
import (
"image"
"github.com/go-chi/chi"
"github.com/spf13/viper"
)
type ProductImageSet struct {
Thumbnail image.Image
Main image.Image
Original image.Image
}
type ProductImageLocations struct {
Thumbnail string
Main string
Original string
}
type ImageStorer interface {
Init(config *viper.Viper, router chi.Router) error
CreateThumbnails(img image.Image) ProductImageSet
StoreImages(imgset ProductImageSet, sku string, id uint) (*ProductImageLocations, error)
}
|
dairycart/dairycart
|
storage/v1/images/main.go
|
GO
|
mit
| 508
|
package isbn
import (
"errors"
"math"
"strconv"
"unicode"
)
func IsValidISBN(isbn string) bool {
isbn = dropHyphen(isbn)
ary, err := strToSlice(isbn)
if len(ary) != 10 || err != nil {
return false
}
return calcCheckDigit(ary)
}
func dropHyphen(isbn string) string {
var result string
for _, char := range isbn {
if char == '-' {
continue
}
result += string(char)
}
return result
}
func strToSlice(isbn string) (result []int, err error) {
for pos, char := range isbn {
if unicode.IsLetter(char) && (char != 'X' || pos != 9) {
err = errors.New("invalid character")
return
} else if char == 'X' {
result = append(result, 10)
} else {
i, _ := strconv.Atoi(string(char))
result = append(result, i)
}
}
return
}
func calcCheckDigit(isbn []int) bool {
var pool int
for idx, value := range isbn {
pool += int(math.Abs(float64(idx)-10)) * value
}
result := pool % 11
return result == 0
}
|
leenipper/xgo
|
exercises/isbn-verifier/example.go
|
GO
|
mit
| 946
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// MIT License. See license.txt
frappe.provide("frappe.ui.form");
frappe.ui.form.Toolbar = Class.extend({
init: function(opts) {
$.extend(this, opts);
this.make();
this.add_update_button_on_dirty();
this.appframe.add_module_icon(this.frm.meta.module, this.frm.doctype);
this.appframe.set_views_for(this.frm.meta.name, "form");
},
make: function() {
this.set_title();
this.show_title_as_dirty();
if(this.frm.meta.hide_toolbar) {
this.appframe.set_title_right();
this.frm.save_disabled = true;
this.appframe.iconbar.hide();
} else {
this.appframe.iconbar.clear(1)
this.make_file_menu();
this.make_cancel_amend_button();
this.set_title_right();
this.show_infobar();
if(this.frm.doc.__islocal) {
this.appframe.iconbar.hide(2);
this.appframe.iconbar.hide(3);
} else {
this.appframe.iconbar.show(2);
this.appframe.iconbar.show(3);
}
}
},
refresh: function() {
this.make();
},
set_title: function() {
if(this.frm.meta.title_field) {
var title = (this.frm.doc[this.frm.meta.title_field] || "").trim() || __(this.frm.docname);
if(this.frm.doc.__islocal) {
this.appframe.set_title_sub("");
} else {
this.appframe.set_title_sub("#" + this.frm.docname);
}
} else {
var title = __(this.frm.docname);
}
var me = this;
this.appframe.set_title(title + this.get_lock_status());
if(this.frm.meta.issingle) {
this.appframe.set_title_left(function() { frappe.set_route(frappe.get_module(me.frm.meta.module).link); });
} else {
this.appframe.set_title_left(function() {
me.frm.list_route
? frappe.set_route(me.frm.list_route)
: frappe.set_route("List", me.frm.doctype);
});
}
},
show_infobar: function() {
/* docs:
Render info bar that shows timestamp, # of comments, # of attachments etc.
only if saved doc. (doc.__islocal is falsy)
*/
if(this.infobar)
this.infobar.refresh();
else
this.infobar = new frappe.ui.form.InfoBar({appframe:this.appframe, frm:this.frm});
},
get_dropdown_menu: function(label) {
return this.appframe.add_dropdown(label);
},
get_lock_status: function() {
if(this.frm.meta.is_submittable && !this.frm.doc.__islocal) {
switch(this.frm.doc.docstatus) {
case 0:
return ' <i class="icon-unlock text-muted" title="' +__("Not Submitted") + '">';
case 1:
return ' <i class="icon-lock" title="' +__("Submitted") + '">';
case 2:
return ' <i class="icon-remove text-danger" title="' +__("Cancelled") + '">';
}
} else {
return "";
}
},
make_file_menu: function() {
var me = this;
var p = this.frm.perm[0];
var docstatus = cint(this.frm.doc.docstatus);
$(".custom-menu").remove();
// New
if(p[CREATE]) {
this.appframe.add_dropdown_button("File", __("New") + " "
+ __(me.frm.doctype), function() {
new_doc(me.frm.doctype);}, 'icon-plus');
}
// Save
if(docstatus==0 && p[WRITE] && !this.read_only) {
this.appframe.add_dropdown_button("File", __("Save"), function() {
me.frm.save('Save', null, this);}, 'icon-save');
}
// Submit
if(docstatus==0 && !this.frm.doc.__unsaved && p[SUBMIT] && !this.read_only) {
this.appframe.add_dropdown_button("File", __("Submit"), function() {
me.frm.savesubmit(this);}, 'icon-lock');
}
// Cancel
if(this.can_cancel()) {
this.appframe.add_dropdown_button("File", __("Cancel"), function() {
me.frm.savecancel(this);}, 'icon-remove');
}
// Amend
if(this.can_amend()) {
this.appframe.add_dropdown_button("File", __("Amend"), function() {
me.frm.amend_doc();}, 'icon-pencil');
}
// Print
if(!me.frm.doc.__islocal || frappe.model.can_print(null, me.frm)) {
this.appframe.add_dropdown_button("File", __("Print..."), function() {
me.frm.print_doc();}, 'icon-print');
}
// email
if(!me.frm.doc.__islocal || frappe.model.can_email(null, me.frm)) {
this.appframe.add_dropdown_button("File", __("Email..."), function() {
me.frm.email_doc();}, 'icon-envelope');
}
// Linked With
if(!me.frm.doc.__islocal && !me.frm.meta.issingle) {
this.appframe.add_dropdown_button("File", __('Linked With'), function() {
me.show_linked_with();
}, "icon-link")
}
// copy
if(in_list(frappe.boot.user.can_create, me.frm.doctype) && !me.frm.meta.allow_copy) {
this.appframe.add_dropdown_button("File", __("Copy"), function() {
me.frm.copy_doc();}, 'icon-file');
}
// rename
if(me.frm.meta.allow_rename && me.frm.perm[0].write) {
this.appframe.add_dropdown_button("File", __("Rename..."), function() {
me.frm.rename_doc();}, 'icon-retweet');
}
// delete
if((cint(me.frm.doc.docstatus) != 1) && !me.frm.doc.__islocal
&& frappe.model.can_delete(me.frm.doctype)) {
this.appframe.add_dropdown_button("File", __("Delete"), function() {
me.frm.savetrash();}, 'icon-remove-sign');
}
},
can_save: function() {
return this.get_docstatus()===0;
},
can_submit: function() {
return this.get_docstatus()===0
&& !this.frm.doc.__islocal
&& !this.frm.doc.__unsaved
&& this.frm.perm[0].submit
&& !this.has_workflow();
},
can_update: function() {
return this.get_docstatus()===1
&& !this.frm.doc.__islocal
&& this.frm.perm[0].submit
&& this.frm.doc.__unsaved
},
can_cancel: function() {
return this.get_docstatus()===1
&& this.frm.perm[0].cancel
&& !this.read_only
&& !this.has_workflow();
},
can_amend: function() {
return this.get_docstatus()===2
&& this.frm.perm[0].amend
&& !this.read_only;
},
has_workflow: function() {
if(this._has_workflow === undefined)
this._has_workflow = frappe.get_list("Workflow", {document_type: this.frm.doctype}).length;
return this._has_workflow;
},
get_docstatus: function() {
return cint(this.frm.doc.docstatus);
},
show_linked_with: function() {
if(!this.frm.linked_with) {
this.frm.linked_with = new frappe.ui.form.LinkedWith({
frm: this.frm
});
}
this.frm.linked_with.show();
},
set_title_right: function(dirty) {
var me = this,
current = this.appframe.get_title_right_text(),
status = null;
if (!dirty) {
// don't clear actions menu if dirty
this.appframe.clear_primary_action();
}
if (this.can_submit()) {
status = "Submit";
} else if (this.can_save()) {
if (!this.frm.save_disabled) {
status = "Save";
}
} else if (this.can_update()) {
status = "Update";
} else if (this.can_cancel()) {
status = "Cancel";
} else if (this.can_amend()) {
status = "Amend";
}
if (status) {
if (status !== current) {
var perm_to_check = this.frm.action_perm_type_map[status];
if(!this.frm.perm[0][perm_to_check]) {
return;
}
this.appframe.set_title_right(__(status), {
"Save": function() {
me.frm.save('Save', null, this);
},
"Submit": function() {
me.frm.savesubmit(this);
},
"Update": function() {
me.frm.save('Update', null, this);
},
"Cancel": function() {
me.frm.savecancel(this);
},
"Amend": function() {
me.frm.amend_doc();
}
}[status], null, status === "Cancel" ? "btn-default" : "btn-primary");
}
} else {
this.appframe.set_title_right();
}
},
make_cancel_amend_button: function() {
var me = this;
var docstatus = cint(this.frm.doc.docstatus);
var p = this.frm.perm[0];
var has_workflow = this.has_workflow();
if(has_workflow) {
return;
} else if(docstatus==1 && p[CANCEL]) {
this.appframe.add_button('Cancel', function() {
me.frm.savecancel(this) }, 'icon-remove');
} else if(docstatus==2 && p[AMEND]) {
this.appframe.add_button('Amend', function() {
me.frm.amend_doc() }, 'icon-pencil', true);
}
},
add_update_button_on_dirty: function() {
var me = this;
$(this.frm.wrapper).on("dirty", function() {
me.show_title_as_dirty();
})
},
show_title_as_dirty: function() {
if(this.frm.save_disabled)
return;
this.appframe.get_title_area()
.toggleClass("text-warning", this.frm.doc.__unsaved ? true : false)
this.set_title();
this.set_title_right(true);
// set state in wrapper
$(this.frm.wrapper).attr("data-state", this.frm.doc.__unsaved ? "dirty" : "clean");
}
})
|
gangadharkadam/office_frappe
|
frappe/public/js/frappe/form/toolbar.js
|
JavaScript
|
mit
| 8,259
|
using SQLite;
namespace SQLite_net_PCL_Demo.Core
{
public class Entity
{
[PrimaryKey]
[AutoIncrement]
public int Id { get; set; }
public string Name { get; set; }
}
}
|
rafaelromao/SQLite-net_PCL_Demo
|
SQLite-net_PCL_Demo.Core/Entity.cs
|
C#
|
mit
| 215
|
<!DOCTYPE html>
<html>
<title>Chen's Resume</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="w3.css">
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Roboto'>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- old font {font-family: "Roboto", sans-serif} -->
<style>
html,body,h1,h2,h3,h4,h5,h6 {font-family: "Lato", sans-serif}
</style>
<body class="w3-light-grey">
<!-- Page Container -->
<div class="w3-content w3-margin-top" style="max-width:1400px;">
<!-- The Grid -->
<div class="w3-row-padding">
<!-- Left Column -->
<div class="w3-third">
<div class="w3-white w3-text-grey w3-card-4">
<div class="w3-display-container">
<img src="avatar_hat.jpg" style="width:100%" alt="Avatar">
<div class="w3-display-bottomleft w3-container w3-text-teal">
</div>
</div>
<div class="w3-container">
<p><i class="fa fa-briefcase fa-fw w3-margin-right w3-large w3-text-teal"></i>Operations Analyst</p>
<p><i class="fa fa-home fa-fw w3-margin-right w3-large w3-text-teal"></i>Salt Lake City</p>
<p><i class="fa fa-envelope fa-fw w3-margin-right w3-large w3-text-teal"></i>wangc0528@mail.com</p>
<p><i class="fa fa-phone fa-fw w3-margin-right w3-large w3-text-teal"></i>8329048912</p>
<hr>
<p class="w3-large"><b><i class="fa fa-asterisk fa-fw w3-margin-right w3-text-teal"></i>Skills</b></p>
<p>Distribution Planning</p>
<p>Data Analysis</p>
<p>Inventory Control</p>
<p>Python</p>
<p>Java</p>
<p>R</p>
<p>SQL</p>
<br>
<p class="w3-large w3-text-theme"><b><i class="fa fa-globe fa-fw w3-margin-right w3-text-teal"></i>Languages</b></p>
<p>English</p>
<p>Chinese</p>
<p>Cantonese</p>
<br>
</div>
</div><br>
<!-- End Left Column -->
</div>
<!-- Right Column -->
<div class="w3-twothird">
<!-- Work Experience -->
<div class="w3-container w3-card-2 w3-white w3-margin-bottom">
<h2 class="w3-text-grey w3-padding-16"><i class="fa fa-suitcase fa-fw w3-margin-right w3-xxlarge w3-text-teal"></i>Work Experience</h2>
<div class="w3-container">
<h5 class="w3-opacity"><b>Operations Analyst / OOCL USA</b></h5>
<h6 class="w3-text-teal"><i class="fa fa-calendar fa-fw w3-margin-right"></i>Dec 2015 - <span class="w3-tag w3-teal w3-round">Current</span></h6>
<p>• Forecast and balanced weekly equipment level based on the data of export/domestic demands, import returns, and reposition plans with both qualitative and quantitative methods.</p>
<p>• Combined and reorganized historical sales data to analyze demand patterns and customer behaviour</p>
<p>• Performed equipment inventory analysis and implemented strategies to avoid low stock and overstock</p>
<hr>
</div>
<div class="w3-container">
<h5 class="w3-opacity"><b>Account Manager / OOCL USA</b></h5>
<h6 class="w3-text-teal"><i class="fa fa-calendar fa-fw w3-margin-right"></i>Mar 2015 - Dec 2015</h6>
<p>• Drove vendors and cross-functional teams to provide quality logistics support to key cotton export accounts</p>
<p>• Worked with intermodal and terminal operations team on demurrage minimization, which reduced the operational cost of intermodal shipments out of West Coast by 5%</p>
<hr>
</div>
<div class="w3-container">
<h5 class="w3-opacity"><b>Supply Chain Intern / Green America</b></h5>
<h6 class="w3-text-teal"><i class="fa fa-calendar fa-fw w3-margin-right"></i>Oct 2014 - Dec 2014</h6>
<p>• Research the supply chain and manufacturing processes in electronics industry, with a focus on mapping out major issues related to toxic chemicals used in consumer electronics production </p><br>
</div>
</div>
<!-- Projects -->
<div class="w3-container w3-card-2 w3-white w3-margin-bottom">
<h2 class="w3-text-grey w3-padding-16"><i class="fa fa-file-code-o fa-fw w3-margin-right w3-xxlarge w3-text-teal"></i>Projects</h2>
<div class="w3-container">
<h5 class="w3-opacity"><b>OpenStreetMap Data Wrangling / Udacity</b></h5>
<h6 class="w3-text-teal"><i class="fa fa-calendar fa-fw w3-margin-right"></i>Oct 2016 - Dec 2016</h6>
<p>Pre-processed over 200Mb of Las Vegas area map data extracted from OpenStreenMap. XML data was parsed and stored in multi-dimensional NumPy arrays using ElementTree XML API in Python. Each entry was fed through a custom built filter for abnormalities, validated with a predefined SQL schema and stored in a relational database, SQLite.</p>
<hr>
</div>
<div class="w3-container">
<h5 class="w3-opacity"><b>Exploratory Data Analysis with R / Udacity</b></h5>
<h6 class="w3-text-teal"><i class="fa fa-calendar fa-fw w3-margin-right"></i>Oct 2016 - Dec 2016</h6>
<p>Used R language and deployed various exploratory data visualization techniques, including box charts, heat maps, and regression curves, to explore the correlation between chemical compositions of 1600 different red wines and their quality ratings. A linear regression model was established to predict the quality of a wine given its chemical compositions.</p>
<hr>
</div>
<div class="w3-container">
<h5 class="w3-opacity"><b>Vessel Price Forecast Project / University of Maryland</b></h5>
<h6 class="w3-text-teal"><i class="fa fa-calendar fa-fw w3-margin-right"></i>Oct 2016 - Dec 2016</h6>
<p>Statistically analyzed factors affecting the price of secondhand ships, including ship age, size, freight rate and world trade. Used time series forecasting models to forecast the price of secondhand Aframax tanker with 200 quarterly price observations starting from 1963, and optimized the forecasting model with qualitative factors.</p><br>
</div>
</div>
<!-- Education -->
<div class="w3-container w3-card-2 w3-white">
<h2 class="w3-text-grey w3-padding-16"><i class="fa fa-graduation-cap fa-fw w3-margin-right w3-xxlarge w3-text-teal"></i>Education</h2>
<div class="w3-container">
<h5 class="w3-opacity"><b>University Of Maryland - College Park</b></h5>
<h6 class="w3-text-teal"><i class="fa fa-calendar fa-fw w3-margin-right"></i>2013-2014</h6>
<p>Master of Science in Supply Chain Management</p>
<hr>
</div>
<div class="w3-container">
<h5 class="w3-opacity"><b>Hong Kong Polytechnic University</b></h5>
<h6 class="w3-text-teal"><i class="fa fa-calendar fa-fw w3-margin-right"></i>2009 - 2013</h6>
<p>BBA International Shipping and Transport Logistics</p>
<hr>
</div>
</div>
<!-- End Right Column -->
</div>
<!-- End Grid -->
</div>
<!-- End Page Container -->
</div>
<footer class="w3-container w3-padding-16 w3-center w3-teal w3-xlarge w3-margin-top">
<i class="fa fa-github w3-hover-text-purple" >
<a href="http://github.com/wangc528"> Chen's GitHub</a>
</i>
</footer>
</body>
</html>
|
wangc528/portfolio
|
myresume.html
|
HTML
|
mit
| 7,605
|
<?php get_template_part('templates/content', 'single-program'); ?>
|
tworzenieweb/jinternsjip
|
app/themes/ji/single-mcm_programs.php
|
PHP
|
mit
| 67
|
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
*/
package com.microsoft.azure.management.network.v2020_06_01;
import java.util.Collection;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.microsoft.rest.ExpandableStringEnum;
/**
* Defines values for EffectiveRouteSource.
*/
public final class EffectiveRouteSource extends ExpandableStringEnum<EffectiveRouteSource> {
/** Static value Unknown for EffectiveRouteSource. */
public static final EffectiveRouteSource UNKNOWN = fromString("Unknown");
/** Static value User for EffectiveRouteSource. */
public static final EffectiveRouteSource USER = fromString("User");
/** Static value VirtualNetworkGateway for EffectiveRouteSource. */
public static final EffectiveRouteSource VIRTUAL_NETWORK_GATEWAY = fromString("VirtualNetworkGateway");
/** Static value Default for EffectiveRouteSource. */
public static final EffectiveRouteSource DEFAULT = fromString("Default");
/**
* Creates or finds a EffectiveRouteSource from its string representation.
* @param name a name to look for
* @return the corresponding EffectiveRouteSource
*/
@JsonCreator
public static EffectiveRouteSource fromString(String name) {
return fromString(name, EffectiveRouteSource.class);
}
/**
* @return known EffectiveRouteSource values
*/
public static Collection<EffectiveRouteSource> values() {
return values(EffectiveRouteSource.class);
}
}
|
selvasingh/azure-sdk-for-java
|
sdk/network/mgmt-v2020_06_01/src/main/java/com/microsoft/azure/management/network/v2020_06_01/EffectiveRouteSource.java
|
Java
|
mit
| 1,675
|
FROM ubuntu:bionic
ENV LANG=en_US.UTF-8
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN \
apt update && \
apt upgrade -y && \
apt install -y --allow-unauthenticated \
locales \
ca-certificates tzdata python2.7 netcat htop less curl libmysqlclient20 \
libjpeg8 libpng16-16 libxslt1.1 \
libmysqlclient-dev python2.7-dev python-pip libjpeg8-dev libpng-dev libxslt1-dev && \
locale-gen ${LANG} && \
pip install -U pillow django-redis-cache pytz lxml gu-django-filebrowser-no-grappelli gu-django-tinymce mysqlclient uwsgi && \
apt autoremove -y && \
apt autoclean -y && \
rm -rf /tmp/* /var/lib/apt/lists/* /root/.cache && \
true
|
andriyg76/docker
|
python2.7-bionic-nonginx/Dockerfile
|
Dockerfile
|
mit
| 743
|
/**
* VM UI Framework
* A modern, grid-based CSS, layout, and UI framwork for HTML5
* Copyright Virtuosi Media, Inc. 2012
* Released under an MIT-License
*/
/**
* Auto-complete
*/
.autocompleteList, .autocompletePrompt {
background: #FFF;
border: 0.1em solid #CCC;
-moz-box-sizing: border-box;
box-sizing: border-box;
list-style: none;
margin: -0.05em 0 0;
position: absolute;
z-index: 10000;
}
.autocompleteList li {
padding: 0 1em;
}
.autocompleteList li:hover, .autocompleteList li.active {
background: #09F;
color: #FFF;
}
.autocompletePrompt {
color: #999;
margin-left: 0.05em;
padding: 0 1em;
}
|
VirtuosiMedia/VM-UI-Framework
|
templates/skeleton/css/plugins/autocomplete.css
|
CSS
|
mit
| 654
|
# timedPress
A JavaScript function for measuring the length of time an element is pressed. Supports both mouse and touch events.
#### Dependencies
None
#### Browser Compatibility
IE10+. Currently, a single `classList` call keeps `timedPress` from IE9+.
Current versions of Chrome, FireFox, Safari and Opera.
#### Params
@param {string} selector - Basic selector, #id or .class, event bubbles from.
#### Returns
@returns {object} - Returns three methods:
* getDuration - returns last duration value
* registerEvents - iterates over events array and adds listener to the body for each.
* removeEvents - iterates over events array and removes each listener from the body.
## Usage
To invoke timedPress:
```javascript
var foo = timedPress('.class');
```
The selector can be either a `.class` or `#ID`, but must follow CSS notation.
Using touch or mouse events, press and hold the element selected.
## Retrieval
There are two ways to get the resulting data.
#### Method One : Calling a Function
```javascript
var bar = foo.getDuration();
```
The method `getDuration` is one of the returned methods when calling `timedPress`. It will return the last recorded time value.
#### Method Two : Event Handler
```javascript
window.addEventListener('press', function(evt){console.log(evt.data.duration)});
```
`timedPress` dispatches a `press` event every 10ms. Attached to the event is an object literal named `data`, with a `duration` property. This contains the _current_ length of time pressed.
## ToDo
* Refactor `classList` check to allow for IE9.
* configurable settings - user-definable event name, iteration time, etc.
* AMD integration - for the module-based functionality all the cool kids are doing.
|
niftinessafoot/timedPress.js
|
README.md
|
Markdown
|
mit
| 1,715
|
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DependencyInjection;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException;
/**
* Definition represents a service definition.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Definition
{
private $class;
private $file;
private $factory;
private $factoryClass;
private $factoryMethod;
private $factoryService;
private $shared = true;
private $deprecated = false;
private $deprecationTemplate;
private $scope = ContainerInterface::SCOPE_CONTAINER;
private $properties = array();
private $calls = array();
private $configurator;
private $tags = array();
private $public = true;
private $synthetic = false;
private $abstract = false;
private $synchronized = false;
private $lazy = false;
private $decoratedService;
private $autowired = false;
private $autowiringTypes = array();
private static $defaultDeprecationTemplate = 'The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.';
protected $arguments;
/**
* @param string|null $class The service class
* @param array $arguments An array of arguments to pass to the service constructor
*/
public function __construct($class = null, array $arguments = array())
{
$this->class = $class;
$this->arguments = $arguments;
}
/**
* Sets a factory.
*
* @param string|array $factory A PHP function or an array containing a class/Reference and a method to call
*
* @return $this
*/
public function setFactory($factory)
{
if (is_string($factory) && false !== strpos($factory, '::')) {
$factory = explode('::', $factory, 2);
}
$this->factory = $factory;
return $this;
}
/**
* Gets the factory.
*
* @return string|array The PHP function or an array containing a class/Reference and a method to call
*/
public function getFactory()
{
return $this->factory;
}
/**
* Sets the name of the class that acts as a factory using the factory method,
* which will be invoked statically.
*
* @param string $factoryClass The factory class name
*
* @return $this
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function setFactoryClass($factoryClass)
{
@trigger_error(sprintf('%s(%s) is deprecated since Symfony 2.6 and will be removed in 3.0. Use Definition::setFactory() instead.', __METHOD__, $factoryClass), E_USER_DEPRECATED);
$this->factoryClass = $factoryClass;
return $this;
}
/**
* Gets the factory class.
*
* @return string|null The factory class name
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function getFactoryClass($triggerDeprecationError = true)
{
if ($triggerDeprecationError) {
@trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0.', E_USER_DEPRECATED);
}
return $this->factoryClass;
}
/**
* Sets the factory method able to create an instance of this class.
*
* @param string $factoryMethod The factory method name
*
* @return $this
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function setFactoryMethod($factoryMethod)
{
@trigger_error(sprintf('%s(%s) is deprecated since Symfony 2.6 and will be removed in 3.0. Use Definition::setFactory() instead.', __METHOD__, $factoryMethod), E_USER_DEPRECATED);
$this->factoryMethod = $factoryMethod;
return $this;
}
/**
* Sets the service that this service is decorating.
*
* @param null|string $id The decorated service id, use null to remove decoration
* @param null|string $renamedId The new decorated service id
* @param int $priority The priority of decoration
*
* @return $this
*
* @throws InvalidArgumentException in case the decorated service id and the new decorated service id are equals
*/
public function setDecoratedService($id, $renamedId = null, $priority = 0)
{
if ($renamedId && $id === $renamedId) {
throw new \InvalidArgumentException(sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id));
}
if (null === $id) {
$this->decoratedService = null;
} else {
$this->decoratedService = array($id, $renamedId, (int) $priority);
}
return $this;
}
/**
* Gets the service that this service is decorating.
*
* @return null|array An array composed of the decorated service id, the new id for it and the priority of decoration, null if no service is decorated
*/
public function getDecoratedService()
{
return $this->decoratedService;
}
/**
* Gets the factory method.
*
* @return string|null The factory method name
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function getFactoryMethod($triggerDeprecationError = true)
{
if ($triggerDeprecationError) {
@trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0.', E_USER_DEPRECATED);
}
return $this->factoryMethod;
}
/**
* Sets the name of the service that acts as a factory using the factory method.
*
* @param string $factoryService The factory service id
*
* @return $this
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function setFactoryService($factoryService, $triggerDeprecationError = true)
{
if ($triggerDeprecationError) {
@trigger_error(sprintf('%s(%s) is deprecated since Symfony 2.6 and will be removed in 3.0. Use Definition::setFactory() instead.', __METHOD__, $factoryService), E_USER_DEPRECATED);
}
$this->factoryService = $factoryService;
return $this;
}
/**
* Gets the factory service id.
*
* @return string|null The factory service id
*
* @deprecated since version 2.6, to be removed in 3.0.
*/
public function getFactoryService($triggerDeprecationError = true)
{
if ($triggerDeprecationError) {
@trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0.', E_USER_DEPRECATED);
}
return $this->factoryService;
}
/**
* Sets the service class.
*
* @param string $class The service class
*
* @return $this
*/
public function setClass($class)
{
$this->class = $class;
return $this;
}
/**
* Gets the service class.
*
* @return string|null The service class
*/
public function getClass()
{
return $this->class;
}
/**
* Sets the arguments to pass to the service constructor/factory method.
*
* @return $this
*/
public function setArguments(array $arguments)
{
$this->arguments = $arguments;
return $this;
}
/**
* Sets the properties to define when creating the service.
*
* @return $this
*/
public function setProperties(array $properties)
{
$this->properties = $properties;
return $this;
}
/**
* Gets the properties to define when creating the service.
*
* @return array
*/
public function getProperties()
{
return $this->properties;
}
/**
* Sets a specific property.
*
* @param string $name
* @param mixed $value
*
* @return $this
*/
public function setProperty($name, $value)
{
$this->properties[$name] = $value;
return $this;
}
/**
* Adds an argument to pass to the service constructor/factory method.
*
* @param mixed $argument An argument
*
* @return $this
*/
public function addArgument($argument)
{
$this->arguments[] = $argument;
return $this;
}
/**
* Replaces a specific argument.
*
* @param int $index
* @param mixed $argument
*
* @return $this
*
* @throws OutOfBoundsException When the replaced argument does not exist
*/
public function replaceArgument($index, $argument)
{
if (0 === count($this->arguments)) {
throw new OutOfBoundsException('Cannot replace arguments if none have been configured yet.');
}
if ($index < 0 || $index > count($this->arguments) - 1) {
throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, count($this->arguments) - 1));
}
$this->arguments[$index] = $argument;
return $this;
}
/**
* Gets the arguments to pass to the service constructor/factory method.
*
* @return array The array of arguments
*/
public function getArguments()
{
return $this->arguments;
}
/**
* Gets an argument to pass to the service constructor/factory method.
*
* @param int $index
*
* @return mixed The argument value
*
* @throws OutOfBoundsException When the argument does not exist
*/
public function getArgument($index)
{
if ($index < 0 || $index > count($this->arguments) - 1) {
throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, count($this->arguments) - 1));
}
return $this->arguments[$index];
}
/**
* Sets the methods to call after service initialization.
*
* @return $this
*/
public function setMethodCalls(array $calls = array())
{
$this->calls = array();
foreach ($calls as $call) {
$this->addMethodCall($call[0], $call[1]);
}
return $this;
}
/**
* Adds a method to call after service initialization.
*
* @param string $method The method name to call
* @param array $arguments An array of arguments to pass to the method call
*
* @return $this
*
* @throws InvalidArgumentException on empty $method param
*/
public function addMethodCall($method, array $arguments = array())
{
if (empty($method)) {
throw new InvalidArgumentException('Method name cannot be empty.');
}
$this->calls[] = array($method, $arguments);
return $this;
}
/**
* Removes a method to call after service initialization.
*
* @param string $method The method name to remove
*
* @return $this
*/
public function removeMethodCall($method)
{
foreach ($this->calls as $i => $call) {
if ($call[0] === $method) {
unset($this->calls[$i]);
break;
}
}
return $this;
}
/**
* Check if the current definition has a given method to call after service initialization.
*
* @param string $method The method name to search for
*
* @return bool
*/
public function hasMethodCall($method)
{
foreach ($this->calls as $call) {
if ($call[0] === $method) {
return true;
}
}
return false;
}
/**
* Gets the methods to call after service initialization.
*
* @return array An array of method calls
*/
public function getMethodCalls()
{
return $this->calls;
}
/**
* Sets tags for this definition.
*
* @return $this
*/
public function setTags(array $tags)
{
$this->tags = $tags;
return $this;
}
/**
* Returns all tags.
*
* @return array An array of tags
*/
public function getTags()
{
return $this->tags;
}
/**
* Gets a tag by name.
*
* @param string $name The tag name
*
* @return array An array of attributes
*/
public function getTag($name)
{
return isset($this->tags[$name]) ? $this->tags[$name] : array();
}
/**
* Adds a tag for this definition.
*
* @param string $name The tag name
* @param array $attributes An array of attributes
*
* @return $this
*/
public function addTag($name, array $attributes = array())
{
$this->tags[$name][] = $attributes;
return $this;
}
/**
* Whether this definition has a tag with the given name.
*
* @param string $name
*
* @return bool
*/
public function hasTag($name)
{
return isset($this->tags[$name]);
}
/**
* Clears all tags for a given name.
*
* @param string $name The tag name
*
* @return $this
*/
public function clearTag($name)
{
unset($this->tags[$name]);
return $this;
}
/**
* Clears the tags for this definition.
*
* @return $this
*/
public function clearTags()
{
$this->tags = array();
return $this;
}
/**
* Sets a file to require before creating the service.
*
* @param string $file A full pathname to include
*
* @return $this
*/
public function setFile($file)
{
$this->file = $file;
return $this;
}
/**
* Gets the file to require before creating the service.
*
* @return string|null The full pathname to include
*/
public function getFile()
{
return $this->file;
}
/**
* Sets if the service must be shared or not.
*
* @param bool $shared Whether the service must be shared or not
*
* @return $this
*/
public function setShared($shared)
{
$this->shared = (bool) $shared;
return $this;
}
/**
* Whether this service is shared.
*
* @return bool
*/
public function isShared()
{
return $this->shared;
}
/**
* Sets the scope of the service.
*
* @param string $scope Whether the service must be shared or not
*
* @return $this
*
* @deprecated since version 2.8, to be removed in 3.0.
*/
public function setScope($scope, $triggerDeprecationError = true)
{
if ($triggerDeprecationError) {
@trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
}
if (ContainerInterface::SCOPE_PROTOTYPE === $scope) {
$this->setShared(false);
}
$this->scope = $scope;
return $this;
}
/**
* Returns the scope of the service.
*
* @return string
*
* @deprecated since version 2.8, to be removed in 3.0.
*/
public function getScope($triggerDeprecationError = true)
{
if ($triggerDeprecationError) {
@trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
}
return $this->scope;
}
/**
* Sets the visibility of this service.
*
* @param bool $boolean
*
* @return $this
*/
public function setPublic($boolean)
{
$this->public = (bool) $boolean;
return $this;
}
/**
* Whether this service is public facing.
*
* @return bool
*/
public function isPublic()
{
return $this->public;
}
/**
* Sets the synchronized flag of this service.
*
* @param bool $boolean
*
* @return $this
*
* @deprecated since version 2.7, will be removed in 3.0.
*/
public function setSynchronized($boolean, $triggerDeprecationError = true)
{
if ($triggerDeprecationError) {
@trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
}
$this->synchronized = (bool) $boolean;
return $this;
}
/**
* Whether this service is synchronized.
*
* @return bool
*
* @deprecated since version 2.7, will be removed in 3.0.
*/
public function isSynchronized($triggerDeprecationError = true)
{
if ($triggerDeprecationError) {
@trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
}
return $this->synchronized;
}
/**
* Sets the lazy flag of this service.
*
* @param bool $lazy
*
* @return $this
*/
public function setLazy($lazy)
{
$this->lazy = (bool) $lazy;
return $this;
}
/**
* Whether this service is lazy.
*
* @return bool
*/
public function isLazy()
{
return $this->lazy;
}
/**
* Sets whether this definition is synthetic, that is not constructed by the
* container, but dynamically injected.
*
* @param bool $boolean
*
* @return $this
*/
public function setSynthetic($boolean)
{
$this->synthetic = (bool) $boolean;
return $this;
}
/**
* Whether this definition is synthetic, that is not constructed by the
* container, but dynamically injected.
*
* @return bool
*/
public function isSynthetic()
{
return $this->synthetic;
}
/**
* Whether this definition is abstract, that means it merely serves as a
* template for other definitions.
*
* @param bool $boolean
*
* @return $this
*/
public function setAbstract($boolean)
{
$this->abstract = (bool) $boolean;
return $this;
}
/**
* Whether this definition is abstract, that means it merely serves as a
* template for other definitions.
*
* @return bool
*/
public function isAbstract()
{
return $this->abstract;
}
/**
* Whether this definition is deprecated, that means it should not be called
* anymore.
*
* @param bool $status
* @param string $template Template message to use if the definition is deprecated
*
* @return $this
*
* @throws InvalidArgumentException when the message template is invalid
*/
public function setDeprecated($status = true, $template = null)
{
if (null !== $template) {
if (preg_match('#[\r\n]|\*/#', $template)) {
throw new InvalidArgumentException('Invalid characters found in deprecation template.');
}
if (false === strpos($template, '%service_id%')) {
throw new InvalidArgumentException('The deprecation template must contain the "%service_id%" placeholder.');
}
$this->deprecationTemplate = $template;
}
$this->deprecated = (bool) $status;
return $this;
}
/**
* Whether this definition is deprecated, that means it should not be called
* anymore.
*
* @return bool
*/
public function isDeprecated()
{
return $this->deprecated;
}
/**
* Message to use if this definition is deprecated.
*
* @param string $id Service id relying on this definition
*
* @return string
*/
public function getDeprecationMessage($id)
{
return str_replace('%service_id%', $id, $this->deprecationTemplate ?: self::$defaultDeprecationTemplate);
}
/**
* Sets a configurator to call after the service is fully initialized.
*
* @param callable $callable A PHP callable
*
* @return $this
*/
public function setConfigurator($callable)
{
$this->configurator = $callable;
return $this;
}
/**
* Gets the configurator to call after the service is fully initialized.
*
* @return callable|null The PHP callable to call
*/
public function getConfigurator()
{
return $this->configurator;
}
/**
* Sets types that will default to this definition.
*
* @param string[] $types
*
* @return $this
*/
public function setAutowiringTypes(array $types)
{
$this->autowiringTypes = array();
foreach ($types as $type) {
$this->autowiringTypes[$type] = true;
}
return $this;
}
/**
* Is the definition autowired?
*
* @return bool
*/
public function isAutowired()
{
return $this->autowired;
}
/**
* Enables/disables autowiring.
*
* @param bool $autowired
*
* @return $this
*/
public function setAutowired($autowired)
{
$this->autowired = $autowired;
return $this;
}
/**
* Gets autowiring types that will default to this definition.
*
* @return string[]
*/
public function getAutowiringTypes()
{
return array_keys($this->autowiringTypes);
}
/**
* Adds a type that will default to this definition.
*
* @param string $type
*
* @return $this
*/
public function addAutowiringType($type)
{
$this->autowiringTypes[$type] = true;
return $this;
}
/**
* Removes a type.
*
* @param string $type
*
* @return $this
*/
public function removeAutowiringType($type)
{
unset($this->autowiringTypes[$type]);
return $this;
}
/**
* Will this definition default for the given type?
*
* @param string $type
*
* @return bool
*/
public function hasAutowiringType($type)
{
return isset($this->autowiringTypes[$type]);
}
}
|
mihai-stancu/symfony
|
src/Symfony/Component/DependencyInjection/Definition.php
|
PHP
|
mit
| 22,478
|
---
layout: post
title: 新装vps的一些一键脚本整理
categories: [IT&数码]
description: 新购 vps 有很多需要部署的内容,而这些内容中又有很多可以说是必备内容,何不利用脚本去完成呢?在此我整理一些常用的脚本,待补充。
keywords: VPS, 一键, 脚本, oneinstack, LAMP, LNMP
---
新购vps有很多需要部署的内容,而这些内容中又有很多可以说是必备内容,何不利用脚本去完成呢?在此我整理一些常用的脚本,待补充。
## 系统检测
**io测试脚本**
```wget -qO- bench.sh | bash```
**网络测试脚本 speedtest**
```pip install speedtest-cli```
## 环境搭建
**lnmp**
**1. 军哥**
```wget -c http://soft.vpser.net/lnmp/lnmp1.4.tar.gz && tar zxf lnmp1.4.tar.gz && cd lnmp1.4 && ./install.sh lnmp```
**2. oneinstack**
```wget http://mirrors.linuxeye.com/oneinstack.tar.gz && tar xzf oneinstack-full.tar.gz && cd oneinstack && ./install.sh```
## 实用软件
**bbr脚本**
```wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh;./bbr.sh```
**ssr脚本**
```wget -N --no-check-certificate https://softs.pw/Bash/ssr.sh && chmod +x ssr.sh && bash ssr.sh```
转载自 方舟泊,[原文链接](https://www.nozarc.com/archives/195.html)
|
berrythinking/berrythinking.github.io
|
_posts/blog/2017-08-20-新装vps的一些一键脚本整理.md
|
Markdown
|
mit
| 1,337
|
"""
Simple evaluators implement a single objective function, and use the genotype
of a species when performing the evaluation (as opposed to using some later
stage of development).
"""
type SimpleEvaluator <: Evaluator
evaluator::Function
stage::AbstractString
threads::Int
end
"""
Provides a definition for a simple evaluator.
"""
type SimpleEvaluatorDefinition <: EvaluatorDefinition
evaluator::Function
stage::AbstractString
threads::Int
end
"""
Composes a simple evaluator from its definition.
"""
function compose!(e::SimpleEvaluatorDefinition, p::Population)
if e.stage == ""
e.stage = p.demes[1].species.genotype.label
end
SimpleEvaluator(e.evaluator, e.stage, e.threads)
end
"""
Simple evaluators implement a single objective function, and use the genotype
of a species when performing the evaluation (as opposed to using some later
stage of development).
"""
simple(f::Function; stage = "", threads = 1) =
SimpleEvaluatorDefinition(f, stage, max(1, threads))
"""
Evaluates a provided phenome according to a simple evaluation method.
"""
function evaluate{T}(ev::SimpleEvaluator, sch::FitnessScheme, phenome::T)
println("Called simple evaluator")
ev.evaluator(sch, phenome)
end
|
ChrisTimperley/Wallace.jl
|
src/evaluator/_simple.jl
|
Julia
|
mit
| 1,219
|
<style>
.section .reveal .state-background {
background: #ffffff;
}
.section .reveal h1,
.section .reveal h2,
.section .reveal p {
color: black;
margin-top: 50px;
text-align: center;
}
</style>
Multivariate distributions part I
========================================================
autosize: true
incremental: true
width: 1920
height: 1080
<h2 style="text-align:left"> Instructions:</h2>
<p style='text-align:left'>Use the left and right arrow keys to navigate the presentation forward and backward respectively. You can also use the arrows at the bottom right of the screen to navigate with a mouse.<br></p>
<blockquote>
FAIR USE ACT DISCLAIMER:</br>
This site is for educational purposes only. This website may contain copyrighted material, the use of which has not been specifically authorized by the copyright holders. The material is made available on this website as a way to advance teaching, and copyright-protected materials are used to the extent necessary to make this class function in a distance learning environment. The Fair Use Copyright Disclaimer is under section 107 of the Copyright Act of 1976, allowance is made for “fair use” for purposes such as criticism, comment, news reporting, teaching, scholarship, education and research.
</blockquote>
========================================================
<h2>Outline</h2>
<ul>
<li>The following topics will be covered in this lecture:</li>
<ul>
<li>The distribution function of a random vector</li>
<li>The density function of a random vector</li>
<li>Marginal versus conditional probability</li>
<li>Expected value</li>
</ul>
</ul>
========================================================
## Introducing multiple random variables
* We have now learned about <b style="color:#d95f02">how to describe behavior of a single random variable</b> and the <b style="color:#1b9e77">mathematical structure of how to think about multiple variables in matrices and functions</b>.</li>
* We will now introduce the basic tools of <b>statistics and probability theory for multivariate analysis</b>;
* we will be studying the relations between <strong>$p$ random variables that will often covary together in their conditional probabilities</strong>.
* To begin with we will make the extension of random variables to random vectors, using our understanding of basic matrix theory.
* Some notions like the expected / center of mass will translate directly over linear combinations of random variables.
* Recall, for random variables $X,Y$ and a constant scalars $a,b$ we have
$$\mathbb{E}\left[ a X + b Y\right] = a \mathbb{E}\left[X\right] + b \mathbb{E}\left[Y\right].$$
* The same idea extends algebraicly for random vectors $\boldsymbol{\xi}_1, \boldsymbol{\xi}_2$ and constant matrices $\mathbf{A},\mathbf{B}$, we can write
$$\mathbb{E}\left[\mathbf{A}\boldsymbol{\xi}_1 + \mathbf{B}\boldsymbol{\xi}_2 \right] = \mathbf{A}\mathbb{E}\left[ \boldsymbol{\xi}_1\right] + \mathbf{B}\mathbb{E}\left[\boldsymbol{\xi}_2\right].$$
* While the concept of the center of mass remains basically the same, we will need to make some additional considerations when we measure the spread of random variables and how they relate to others.
========================================================
## The cumulitive distribution function
* We will begin our consideration in $p=2$ dimensions, as all properties described in the following will extend (with minor modifications) to arbitrarily large but finite $p$.
* Let the vector $\boldsymbol{\xi}$ be defined as
$$\begin{align}
\boldsymbol{\xi} =
\begin{pmatrix}
\xi_1 \\ \xi_2
\end{pmatrix}
\end{align}$$
where each of the above components $\xi_i$ is a rv.
* We can define the <b>cumulative distribution function</b> in a similar way to the definition in one variable.
* Let $x_1,x_2$ be <strong>two fixed real values forming a constant vector</strong> as
$$\mathbf{x} = \begin{pmatrix} x_1 \\ x_2\end{pmatrix}.$$
* Define the comparison operator between two vectors $\mathbf{y}, \mathbf{x}$ as
$$\mathbf{y} \leq \mathbf{x} \Leftrightarrow y_i \leq x_i \text{ for each and every }i$$
* The <b>cumulative distribution function</b> $F_\boldsymbol{\xi}$, describing the probability of realizations of $\boldsymbol{\xi}$, is thus given as,
$$F_\boldsymbol{\xi}(\mathbf{x}) = P(\boldsymbol{\xi}\leq \mathbf{x} ) = P(\xi_i \leq x_i \text{ for each and every }i)$$
========================================================
### The joint probability density function
* Recall that the cdf
$$\begin{align}
F_\boldsymbol{\xi}:\mathbb{R}^2 & \rightarrow [0,1] \\
\mathbf{x} & \rightarrow P(\boldsymbol{\xi}\leq \mathbf{x})
\end{align}$$
is a function of the variables $(x_1,x_2)$.
* Suppose then that $F_\boldsymbol{\xi}$ has continuous second partial derivatives in $\partial_{x_1} \partial_{x_2}F_\boldsymbol{\xi} = \partial_{x_2}\partial_{x_1}F_\boldsymbol{\xi}$.
* We then can take the probability density function $f$ to be defined as
$$\begin{align}
f_\boldsymbol{\xi}:\mathbb{R}^2 & \rightarrow \mathbb{R}\\
\mathbf{x} &\rightarrow \partial_{x_1}\partial_{x_2}F_\boldsymbol{\xi}(\mathbf{x})
\end{align}$$
* In the above definition, we have constructed the density function in the same way as in one variable;
* specifically, in the case where $f_\boldsymbol{\xi}$ itself is differentiable, we have defined the cdf as the anti-derivative of the density:
$$\begin{align}
F_\boldsymbol{\xi}(\mathbf{x}) = \int_{-\infty}^{x_1} \int_{-\infty}^{x_2} f_\boldsymbol{\xi}(s_1, s_2) \mathrm{d}s_1 \mathrm{d}s_2
\end{align}$$
========================================================
### The joint probability density function
* Recall that we defined the relationship between the cdf and the density as
$$\begin{align}
F_\boldsymbol{\xi}(\mathbf{x}) = \int_{-\infty}^{x_1} \int_{-\infty}^{x_2} f_\boldsymbol{\xi}(s_1, s_2) \mathrm{d}s_1 \mathrm{d}s_2
\end{align}$$
* By the above definition, we have to have that
$$\begin{align}
P(- \infty < \boldsymbol{\xi} < \infty) = \int_{-\infty}^{\infty} \int_{-\infty}^{\infty} f_\boldsymbol{\xi}(s_1, s_2) \mathrm{d}s_1 \mathrm{d}s_2 = 1
\end{align}$$
* We note that, as usual, <strong>the density function $f$ must always be positive as the cdf $F_\boldsymbol{\xi}$ is everywhere increasing for a positive increase in $x_1,x_2$</strong>.
* Note, if we defined this over $p\geq 2$ variables, all of the above extends identically when $F_\boldsymbol{\xi}$ has derivatives defined in arbitrary arrangements of the $p$-th partial derivatives in each $\partial_{x_i}$.
* We then construct $F_\boldsymbol{\xi}$ once again as the anti-derivative of $f_\boldsymbol{\xi}$ in all univariate partial derivatives.
========================================================
### The joint probability density function
<div style="float:left; width:55%">
<ul>
<li>Partiuclarly, we will again view the density function like the curve of the univariate case, but for two variables we see this as a <strong>surface above the $x_1,x_2$ plane</strong>.</li>
</ul>
</div>
<div style="float:right; width:40%" class="fragment">
<img style="width:100%", src="Multivariate_Gaussian.png" alt="Volume under joint density."/><p style="text-align:center"> Courtesy of: Dekking, et al. <i>A Modern Introduction to Probability and Statistics</i>. Springer Science & Business Media, 2005.</p>
</div>
<div style="float:left; width:55%">
<ul>
<li>To the right, we see the multivariate Gaussian bell surface that defines the multivariate normal distribution in two variables.</li>
<li>In one variable, the probability $P(\xi_1 \leq x_1)$ was associated to the area under the curve, computed by the integral of the density.</li>
</ul>
</div>
<div style="float:left; width:40%" class="fragment">
<img style="width:100%", src="joint_density.png" alt="Volume under joint density."/><p style="text-align:center"> Courtesy of: F.M. Dekking, et al. <i>A Modern Introduction to Probability and Statistics</i>. Springer Science & Business Media, 2005.</p>
</div>
<div style="float:right; width:55%">
<ul>
<li>We saw that with integrals in two variables, a volume is computed under the surface with a multiple integral.</li>
<li>Likewise, we will associate the probability $P(\mathbf{a} \leq \boldsymbol{\xi} \leq \mathbf{b})$ with some volume under the surface.</li>
<li>By the construction, we can generally write,
$$\begin{align}
P(\mathbf{a} \leq \boldsymbol{\xi}\leq \mathbf{b}) = \int_{a_1}^{b_1} \int_{a_2}^{b_2} f_\boldsymbol{\xi}(s_1,s_2)\mathrm{d}s_1\mathrm{d}s_2
\end{align}$$
and numerically calculate such a value with the numerical integration methods discussed earlier.</li>
</ul>
</div>
========================================================
### The marginal distribution function
* A new construction arises when we consider the joint probability of multiple variables, and how these relate back to univariate probability.
* Consider if we write the cdf of $\xi_1,\xi_2$ in terms of its component arguments,
$$\begin{align}
F_\boldsymbol{\xi}(x_1, x_2) = \int_{-\infty}^{x_1}\int_{-\infty}^{x_2} f_\boldsymbol{\xi}(s_1, s_2) \mathrm{d}s_1 \mathrm{d}s_2
\end{align}$$
we can also <strong>define the limit as $x_i$ goes to infinity</strong>.
* This can be considered as an operation of averaging out the variable $x_i$ as represented by the integral
$$\begin{align}
\lim_{x_2\rightarrow \infty}\int_{-\infty}^{x_1}\int_{-\infty}^{x_2} f_\boldsymbol{\xi}(s_1, s_2) \mathrm{d}s_1 \mathrm{d}s_2 = \int_{-\infty}^{x_1}\int_{-\infty}^{\infty} f_\boldsymbol{\xi}(s_1, s_2) \mathrm{d}s_1 \mathrm{d}s_2
\end{align}$$
* However, if we consider $x_1$ to still remain a free variable in the above equation, this can be written as,
$$\begin{align}
F_{\xi_1}(x_1) = F_\boldsymbol{\xi}(x_1, \infty) = \lim_{x_2 \rightarrow \infty} F_\boldsymbol{\xi}(x_1,x_2)
\end{align}$$
where <b>$F_{\xi_1}(x_1)$ is the marginal distribution function for $\xi_1$</b>, integrating our $x_2$ in the same sense as above.
* Likewise we can define the marginal distribution function symmetrically in $x_2$ as,
$$\begin{align}
F_{\xi_2}(x_2) = F_\boldsymbol{\xi}(\infty , x_2) = \lim_{x_1 \rightarrow \infty} F_\boldsymbol{\xi}(x_1,x_2)
\end{align}$$
where <b>$F_{\xi_2}(x_2)$ is the marginal distribution function for $\xi_2$</b> integrating our $x_1$ in the same sense as above.
========================================================
### The marginal distribution function
* Let us consider now the meaning of this object in terms of the probability definition.
* Let $A =\{\xi_1 \leq x_1\}$ and $B = \{\xi_2\leq x_2\}$ so that,
$$\begin{align}
F_{\xi_1}(x_1) &= \lim_{x_2\rightarrow \infty} F_\boldsymbol{\xi}(x_1, x_2) \\
&= \lim_{x_2\rightarrow \infty} P(A \cap B) \\
&= P(A)
\end{align}$$
as $\xi_2 \leq \infty$ places no restriction on the event $A$.
* Similarly, we can show this for the marginal distribution in $\xi_2$.
* Therefore, we associate the marginal distribution of $\xi_1$ with its the intrinsic probability distribution, after factoring out the outcomes of possibly related variables.
* Geometrically, we can gain some understanding of the marginal probability distribution terms of the marginal density function.
========================================================
### The marginal density function
<div style="float:left; width:55%">
<ul>
<li>Let's suppose that $\xi_1,\xi_2$ have a joint density defined as $f_\boldsymbol{\xi}(\mathbf{x})$ such that
$$F_\boldsymbol{\xi}(\mathbf{x}) = \int_{-\infty}^{x_1}\int_{-\infty}^{x_2} f_\boldsymbol{\xi}(s_1, s_2) \mathrm{d}s_1 \mathrm{d}s_2.$$</li>
<li>Suppose we integrate $x_2$ out of the density as above, then we define the marginal density function as
$$f_{\xi_1}(x_1) = \int_{-\infty}^{\infty} f_\boldsymbol{\xi}(x_1,s_2) \mathrm{d}s_2.$$</li>
<li>By construction, we have the following relationship between the marginals
$$F_{\xi_1}(x_1) = \int_{-\infty}^{x_1}f_{\xi_1}(s_1)\mathrm{d}s_1.$$</li>
</ul>
</div>
<div style="float:right; width:40%" class="fragment">
<img style="width:100%", src="MultivariateNormalMarginal.png" alt="Volume under joint density."/><p style="text-align:center"> Courtesy of <a href="https://commons.wikimedia.org/wiki/File:MultivariateNormal.png">Bscan</a>, CC0, via Wikimedia Commons</p>
</div>
<div style="float:left; width:100%">
<ul>
<li>The above description shows that $f_{\xi_1}(x_1)$ can be associated to the total area under the curve $f_\boldsymbol{\xi}(x_1, s_2)$ where $x_1$ is fixed and $s_2$ is free to vary over all values $-\infty \leq s_2\leq \infty$.</li>
<li>Geometrically, the marginal density curves are represented for the joint normal distribution in $x$ and $y$ in the figure above.</li>
<li>For any fixed $x$, the marginal histogram is produced by finding the frequency of all values $y$ that are observed associated to this value $x$.</li>
<li>We thus sum all $y$-values in to the margin and look at the density of $x$ over the margin of the joint plot.</li>
</ul>
</div>
========================================================
### Independence and the marginal probability
* Let us recall now that $P(A \cap B) = P(A)P(B)$ if and only if $A$ and $B$ are independent events.
* Let $A =\{\xi_1 \leq x_1\}$ and $B = \{\xi_2\leq x_2\}$ once again.
* Consider thus, if $\xi_1$ and $\xi_2$ are independent random variables, we must have that
$$\begin{align}
F_\boldsymbol{\xi}(x_1, x_2 ) &= P(A \cap B) \\
&= P(A) P(B) \\
&=F_{\xi_1}(x_1) F_{\xi_2}(x_2)
\end{align}$$
from our earlier derivations.
* If we take the derivatives $\partial_{x_1}\partial_{x_2}$ of the above, assuming again the independence,
$$\begin{align}
\partial_{x_1}\partial_{x_2} F_\boldsymbol{\xi}(x_1,x_2) &= f(x_1,x_2) \\
& = \partial_{x_1} F_{\xi_1}(x_1) \partial_{x_2} F_{\xi_2}(x_2)\\
&= f_{\xi_1}(x_1) f_{\xi_2}(x_2)
\end{align}$$
which can be shown by integrating out either $x_i$ from the joint density.
* Therefore, for <strong>independent random variables $\xi_1,\xi_2$</strong> we recover the following <b>identities on the marginal functions</b>,
$$\begin{align} F_\boldsymbol{\xi}(x_1, x_2) = F_{\xi_1}(x_1)F_{\xi_2}(x_2) & & f_\boldsymbol{\xi}(x_1,x_2) = f_{\xi_1}(x_1) f_{\xi_2}(x_2)\end{align}$$
========================================================
## Marginal verus conditional probability
* The marginals are closely related to the notion of the conditional probability.
* We recall, it is a basic assumption in probability that when $P(B)\neq0$,
$$P(A\vert B) = \frac{P(A\cap B)}{P(B)}.$$
* We will thus define the conditional density as,
$$f_{\xi_1 \vert \xi_2}(x_1 \vert x_2) = \frac{f_\boldsymbol{\xi}(x_1, x_2)}{f_{\xi_2}(x_2)}$$
* We can thus write equivalently,
$$ f_\boldsymbol{\xi}(\mathbf{x}) = f_{\xi_1 \vert \xi_2}(x_1 \vert x_2) f_{\xi_2}(x_2)$$
* When $\xi_1,\xi_2$ are independent, we furthermore obtain $f_{\xi_1 \vert \xi_2}(x_1 \vert x_2) = f_{\xi_1}(x_1)$.
========================================================
### Marginal verus conditional probability
* The following relationship between the marginal, conditional and joint densities
$$ f_\boldsymbol{\xi}(\mathbf{x}) = f_{\xi_1 \vert \xi_2}(x_1 \vert x_2) f_{\xi_2}(x_2)$$
can be used to illustrate another connection.
* Consider,
$$\begin{align}
f_{\xi_1}(x_1) &= \int_{-\infty}^\infty f_\boldsymbol{\xi}(\mathbf{x}) \mathrm{d}x_2 \\
&= \int_{-\infty}^\infty f_{\xi_1 \vert \xi_2}(x_1 \vert x_2) f_{\xi_2}(x_2) \mathrm{d}x_2
\end{align}$$
* Then have the interpretation of the marginal $f_{\xi_1}(x_1)$ as the <strong>average value of the conditional density $f_{\xi_1 \vert \xi_2}(x_1 \vert x_2)$, as we take the weighted average over all possible $x_2$</strong>.
* This is equivalent to the earlier interpretation, summing the total frequency of all $x_2$ observed for a fixed value of $x_1$.
========================================================
## Samples and random vectors
* In multivariate statistics, we are given of realizations of a sequence of i.i.d. random vectors $\boldsymbol{\xi}_1 , . . . , \boldsymbol{\xi}_n$, where each $\boldsymbol{\xi}_i$ has the same distribution as a parent or population random vector $\boldsymbol{\xi}$.
* We will observe the values a that the random vector $\boldsymbol{\xi}_i$ attains and obtain a sample of observations as $\{\mathbf{x}_i\}_{i=1}^n$.
* We can thus write the observed sample in a matrix form as
$$\begin{align}
\mathbf{X} & =
\begin{pmatrix}
x_{11} & \cdots & x_{1p} \\
\vdots & \ddots & \vdots \\
x_{n1} & \cdots & x_{np}
\end{pmatrix}
\end{align}$$
where the $i$-th row of of the above matrix corresponds the observed vector $\mathbf{x}_{i}$.
* Similarly, we will denote the random matrix as,
$$\begin{align}
\boldsymbol{\Xi} & =
\begin{pmatrix}
\xi_{11} & \cdots & \xi_{1p} \\
\vdots & \ddots & \vdots \\
\xi_{n1} & \cdots & \xi_{np}
\end{pmatrix}
\end{align}$$
where the $i$-th row of the above matrix corresponds to the random vector $\boldsymbol{\xi}_i$.
* The idea of statistical inference for a given random sample is to analyze the properties of the population variable $\boldsymbol{\xi}$.
* This is typically done by analyzing some characteristics of its distribution, often in terms of the statistics of center and spread once again.
========================================================
## The expected value
* We mentioned already that the expectation has the same property of passing over linear combinations of random variables in the same ways with vectors as with scalars.
* Particularly, we consider the following definition:
* Let $\boldsymbol{\xi}$ be a random vector of size $p$ with the associated cdf $F_\boldsymbol{\xi}(\mathbf{x})$ and the density $f_\boldsymbol{\xi}(\mathbf{x})$.
* Then, we will denote the expected value of the vector $\boldsymbol{\xi}$ as,
$$\begin{align}
\mathbb{E}\left[\boldsymbol{\xi}\right] = \int_{\mathbb{R}^p} \mathbf{s} f_\boldsymbol{\xi}(\mathbf{s})\mathrm{d}\mathbf{s}=
\begin{pmatrix}
\mathbb{E}\left[\xi_1\right] \\ \vdots \\ \mathbb{E}\left[\xi_p\right]
\end{pmatrix} =
\begin{pmatrix}
\int_{-\infty}^\infty s_1 f_{\xi_1}(s_1) \mathrm{d}s_1 \\ \vdots \\ \int_{-\infty}^\infty s_p f_{\xi_p}(s_p) \mathrm{d}s_p
\end{pmatrix} = \begin{pmatrix} \mu_1 \\ \vdots \\ \mu_p\end{pmatrix} = \boldsymbol{\mu}
\end{align}$$
where in the above $f_{\xi_i}$ is again the marginal for $\xi_i$ having integrated out the other variables.
* In the form $\mathbb{E}\left[\boldsymbol{\xi}\right] = \int_{\mathbb{R}^p} \mathbf{s} f_\boldsymbol{\xi}(\mathbf{s})\mathrm{d}\mathbf{s}$ this can be seen as the weighted average of the vector $\mathbf{s}$, given the weights of the joint density.
* Suppose again $p=2$, then we can then consider the entry of $\mathbb{E}\left[\boldsymbol{\xi}\right]$ to be,
$$\begin{align}
\mathbb{E}\left[ \xi_1\right] = \int_{-\infty}^\infty s_1 f_{\xi_1}(s_1)\mathrm{d}s_1 &= \int_{-\infty}^\infty \int_{-\infty}^\infty s_1 f_{\xi_1 \vert \xi_2}(s_1 \vert s_2) f_{\xi_2}(s_2) \mathrm{d}s_2 \mathrm{d}s_1
\end{align}$$
so that this can be understood as the center of mass for $\xi_1$ conditional on $\xi_2$ after averaging over the range of $\xi_2$, weighted by its density.
========================================================
## The expected value
* Recall that the expected value of a random vector can be described as,
$$\begin{align}
\mathbb{E}\left[\boldsymbol{\xi}\right] =
\begin{pmatrix}
\mathbb{E}\left[\xi_1\right] \\ \vdots \\ \mathbb{E}\left[\xi_p\right]
\end{pmatrix}
\end{align}$$
* Using this definition, it is easy to show how we can apply our usual rules of distributing this expected value over linear combinations of random variables.
* Particularly, simply following row-versus column multiplication, we can deduce directly that
$$\mathbb{E}\left[\mathbf{A}\boldsymbol{\xi}_1 + \mathbf{B}\boldsymbol{\xi}_2 \right] = \mathbf{A}\mathbb{E}\left[ \boldsymbol{\xi}_1\right] + \mathbf{B}\mathbb{E}\left[\boldsymbol{\xi}_2\right].$$
for constant matrices $\mathbf{A},\mathbf{B}$.
* The above likewise holds for scalars $a,b$ trivially.
========================================================
### The expected value
* Now, suppose for a sample size $n$, with random vectors $\{\boldsymbol{\xi}_i\}_{i=1}^n$ of length $p$, we again define the sample-based mean of the random variable $\xi_j$ corresponding to the $j$-th entry of each above random vector as
$$\begin{align}
\overline{\xi}_j = \frac{1}{n} \sum_{i=1}^n \xi_{ij},
\end{align}$$
which is itself a random variable.
* This is equivalent to taking a column-average of the random matrix, taken over all rows $i=1,\cdots, n$
$$\begin{align}
\boldsymbol{\Xi} & =
\begin{pmatrix}
\xi_{11} & \cdots & \xi_{1p} \\
\vdots & \ddots & \vdots \\
\xi_{n1} & \cdots & \xi_{np}
\end{pmatrix}
\end{align}$$
* Particularly, for the vector with all entries equal to one $\boldsymbol{1}_n$, we have,
$$\begin{align}
\overline{\boldsymbol{\xi}} = \boldsymbol{\Xi}^\mathrm{T}\frac{1}{n} \mathbf{1}_n =
\begin{pmatrix}
\overline{\xi}_1 \\ \vdots \\ \overline{\xi}_n
\end{pmatrix}
\end{align}$$
as defined above.
========================================================
### The expected value
* Note that from the last slide, we had
$$\begin{align}
\overline{\boldsymbol{\xi}} = \boldsymbol{\Xi}^\mathrm{T}\frac{1}{n} \mathbf{1}_n =
\begin{pmatrix}
\overline{\xi}_1 \\ \vdots \\ \overline{\xi}_n
\end{pmatrix}
\end{align}$$
* Particularly, $\overline{\boldsymbol{\xi}}$ is an unbiased estimator for $\boldsymbol{\mu}$, i.e, $\mathbb{E}\left[ \overline{\boldsymbol{\xi}}\right] = \boldsymbol{\mu}$.
* For observations of the random vectors $\{\mathbf{x}_i\}_{i=1}^n$, we similarly will denote the sample-based mean,
$$\begin{align}
\overline{x}_j = \frac{1}{n} \sum_{i=1}^n x_{ij}
\end{align}$$
where this can also be seen as taking the column-average of
$$\begin{align}
\mathbf{X} & =
\begin{pmatrix}
x_{11} & \cdots & x_{1p} \\
\vdots & \ddots & \vdots \\
x_{n1} & \cdots & x_{np}
\end{pmatrix}
\end{align}$$
========================================================
### The expected value
* Using the previous relationships, we can show that,
$$\begin{align}
\mathbf{X}^\mathrm{T}\frac{1}{n} \mathbf{1}_n =
\begin{pmatrix}
\overline{x}_1 \\ \vdots \\ \overline{x}_n
\end{pmatrix} = \overline{\mathbf{x}}.
\end{align}$$
* This tells us that the vector of the sample-based means of observations provides a point estimate for the expected value of the random vector $\mathbb{E}\left[\boldsymbol{\xi}\right] = \boldsymbol{\mu}$
* In R, we can compute the mean in various ways as the `mean` function extends to vectors and matrices.
* If we want to compute a mean value of the columns, or alternatively of the rows, we can use the functions `colMeans` and `rowMeans` respectively.
* In the next part of this unit, we will consider how to measure spread of a random variable and how this relates to the notion of correlation between variables.
* Finally, we will discuss briefly the importance of the multivariate normal distribution, defined over random vectors.
|
cgrudz/cgrudz.github.io
|
teaching/stat_445_645_2021_fall/lesson_notes/2021_11_08/lesson_21_11_08.md
|
Markdown
|
mit
| 23,563
|
<?php
namespace ErenMustafaOzdal\LaravelUserModule\Http\Requests\Role;
use ErenMustafaOzdal\LaravelModulesBase\Requests\BaseRequest;
use Sentinel;
class StoreRequest extends BaseRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return hasPermission('admin.role.store');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|max:255',
'slug' => 'alpha_dash|max:255|unique:roles',
'permissions' => 'array',
];
}
}
|
erenmustafaozdal/laravel-user-module
|
src/Http/Requests/Role/StoreRequest.php
|
PHP
|
mit
| 724
|
"""Sensitive variant calling using VarDict.
Defaults to using the faster, equally sensitive Java port:
https://github.com/AstraZeneca-NGS/VarDictJava
if 'vardict' or 'vardict-java' is specified in the configuration. To use the
VarDict perl version:
https://github.com/AstraZeneca-NGS/VarDict
specify 'vardict-perl'.
"""
import os
import itertools
import sys
import toolz as tz
import pybedtools
from bcbio import broad, utils
from bcbio.bam import highdepth
from bcbio.distributed.transaction import file_transaction
from bcbio.pipeline import config_utils, shared
from bcbio.pipeline import datadict as dd
from bcbio.provenance import do
from bcbio.variation import annotation, bamprep, vcfutils
def _is_bed_file(target):
return target and isinstance(target, basestring) and os.path.isfile(target)
def _vardict_options_from_config(items, config, out_file, target=None):
opts = ["-c 1", "-S 2", "-E 3", "-g 4"]
# ["-z", "-F", "-c", "1", "-S", "2", "-E", "3", "-g", "4", "-x", "0",
# "-k", "3", "-r", "4", "-m", "8"]
resources = config_utils.get_resources("vardict", config)
if resources.get("options"):
opts += resources["options"]
assert _is_bed_file(target)
if any(tz.get_in(["config", "algorithm", "coverage_interval"], x, "").lower() == "genome"
for x in items):
target = shared.remove_highdepth_regions(target, items)
target = shared.remove_lcr_regions(target, items)
target = _enforce_max_region_size(target, items[0])
opts += [target] # this must be the last option
return opts
def _enforce_max_region_size(in_file, data):
"""Ensure we don't have any chunks in the region greater than 1Mb.
Larger sections have high memory usage on VarDictJava and failures
on VarDict. This creates minimum windows from the input BED file
to avoid these issues. Downstream VarDict merging sorts out any
variants across windows.
"""
max_size = 1e6
overlap_size = 250
def _has_larger_regions(f):
return any(r.stop - r.start > max_size for r in pybedtools.BedTool(f))
out_file = "%s-regionlimit%s" % utils.splitext_plus(in_file)
if not utils.file_exists(out_file):
if _has_larger_regions(in_file):
with file_transaction(data, out_file) as tx_out_file:
pybedtools.BedTool().window_maker(w=max_size,
s=max_size - overlap_size,
b=pybedtools.BedTool(in_file)).saveas(tx_out_file)
else:
utils.symlink_plus(in_file, out_file)
return out_file
def run_vardict(align_bams, items, ref_file, assoc_files, region=None,
out_file=None):
"""Run VarDict variant calling.
"""
if vcfutils.is_paired_analysis(align_bams, items):
call_file = _run_vardict_paired(align_bams, items, ref_file,
assoc_files, region, out_file)
else:
vcfutils.check_paired_problems(items)
call_file = _run_vardict_caller(align_bams, items, ref_file,
assoc_files, region, out_file)
return call_file
def _get_jvm_opts(data, out_file):
"""Retrieve JVM options when running the Java version of VarDict.
"""
if get_vardict_command(data) == "vardict-java":
resources = config_utils.get_resources("vardict", data["config"])
jvm_opts = resources.get("jvm_opts", ["-Xms750m", "-Xmx4g"])
jvm_opts += broad.get_default_jvm_opts(os.path.dirname(out_file))
return "export VAR_DICT_OPTS='%s' && " % " ".join(jvm_opts)
else:
return ""
def _run_vardict_caller(align_bams, items, ref_file, assoc_files,
region=None, out_file=None):
"""Detect SNPs and indels with VarDict.
"""
config = items[0]["config"]
if out_file is None:
out_file = "%s-variants.vcf.gz" % os.path.splitext(align_bams[0])[0]
if not utils.file_exists(out_file):
with file_transaction(items[0], out_file) as tx_out_file:
target = shared.subset_variant_regions(dd.get_variant_regions(items[0]), region,
out_file, do_merge=False)
num_bams = len(align_bams)
sample_vcf_names = [] # for individual sample names, given batch calling may be required
for bamfile, item in itertools.izip(align_bams, items):
# prepare commands
sample = dd.get_sample_name(item)
vardict = get_vardict_command(items[0])
strandbias = "teststrandbias.R"
var2vcf = "var2vcf_valid.pl"
opts = (" ".join(_vardict_options_from_config(items, config, out_file, target))
if _is_bed_file(target) else "")
vcfstreamsort = config_utils.get_program("vcfstreamsort", config)
compress_cmd = "| bgzip -c" if out_file.endswith("gz") else ""
freq = float(utils.get_in(config, ("algorithm", "min_allele_fraction"), 10)) / 100.0
coverage_interval = utils.get_in(config, ("algorithm", "coverage_interval"), "exome")
# for deep targeted panels, require 50 worth of coverage
var2vcf_opts = " -v 50 " if highdepth.get_median_coverage(items[0]) > 5000 else ""
fix_ambig = vcfutils.fix_ambiguous_cl()
remove_dup = vcfutils.remove_dup_cl()
jvm_opts = _get_jvm_opts(items[0], tx_out_file)
r_setup = "unset R_HOME && export PATH=%s:$PATH && " % os.path.dirname(utils.Rscript_cmd())
cmd = ("{r_setup}{jvm_opts}{vardict} -G {ref_file} -f {freq} "
"-N {sample} -b {bamfile} {opts} "
"| {strandbias}"
"| {var2vcf} -N {sample} -E -f {freq} {var2vcf_opts} "
"| {fix_ambig} | {remove_dup} | {vcfstreamsort} {compress_cmd}")
if num_bams > 1:
temp_file_prefix = out_file.replace(".gz", "").replace(".vcf", "") + item["name"][1]
tmp_out = temp_file_prefix + ".temp.vcf"
tmp_out += ".gz" if out_file.endswith("gz") else ""
sample_vcf_names.append(tmp_out)
with file_transaction(item, tmp_out) as tx_tmp_file:
if not _is_bed_file(target):
vcfutils.write_empty_vcf(tx_tmp_file, config, samples=[sample])
else:
cmd += " > {tx_tmp_file}"
do.run(cmd.format(**locals()), "Genotyping with VarDict: Inference", {})
else:
if not _is_bed_file(target):
vcfutils.write_empty_vcf(tx_out_file, config, samples=[sample])
else:
cmd += " > {tx_out_file}"
do.run(cmd.format(**locals()), "Genotyping with VarDict: Inference", {})
if num_bams > 1:
# N.B. merge_variant_files wants region in 1-based end-inclusive
# coordinates. Thus use bamprep.region_to_gatk
vcfutils.merge_variant_files(orig_files=sample_vcf_names,
out_file=tx_out_file, ref_file=ref_file,
config=config, region=bamprep.region_to_gatk(region))
out_file = (annotation.add_dbsnp(out_file, assoc_files["dbsnp"], config)
if assoc_files.get("dbsnp") else out_file)
return out_file
def _safe_to_float(x):
if x is None:
return None
else:
try:
return float(x)
except ValueError:
return None
def depth_freq_filter(line, tumor_index, aligner):
"""Command line to filter VarDict calls based on depth, frequency and quality.
Looks at regions with low depth for allele frequency (AF * DP < 6, the equivalent
of < 13bp for heterogygote calls, but generalized. Within these calls filters if a
calls has:
- Low mapping quality and multiple mismatches in a read (NM)
For bwa only: MQ < 55.0 and NM > 1.0 or MQ < 60.0 and NM > 2.0
- Low depth (DP < 10)
- Low QUAL (QUAL < 45)
Also filters in low allele frequency regions with poor quality, if all of these are
true:
- Allele frequency < 0.2
- Quality < 55
- P-value (SSF) > 0.06
"""
if line.startswith("#CHROM"):
headers = [('##FILTER=<ID=LowAlleleDepth,Description="Low depth per allele frequency '
'along with poor depth, quality, mapping quality and read mismatches.">'),
('##FILTER=<ID=LowFreqQuality,Description="Low frequency read with '
'poor quality and p-value (SSF).">')]
return "\n".join(headers) + "\n" + line
elif line.startswith("#"):
return line
else:
parts = line.split("\t")
sample_ft = {a: v for (a, v) in zip(parts[8].split(":"), parts[9 + tumor_index].split(":"))}
qual = _safe_to_float(parts[5])
dp = _safe_to_float(sample_ft.get("DP"))
af = _safe_to_float(sample_ft.get("AF"))
nm = _safe_to_float(sample_ft.get("NM"))
mq = _safe_to_float(sample_ft.get("MQ"))
ssfs = [x for x in parts[7].split(";") if x.startswith("SSF=")]
pval = _safe_to_float(ssfs[0].split("=")[-1] if ssfs else None)
fname = None
if dp is not None and af is not None:
if dp * af < 6:
if aligner == "bwa" and nm is not None and mq is not None:
if (mq < 55.0 and nm > 1.0) or (mq < 60.0 and nm > 2.0):
fname = "LowAlleleDepth"
if dp < 10:
fname = "LowAlleleDepth"
if qual is not None and qual < 45:
fname = "LowAlleleDepth"
if af is not None and qual is not None and pval is not None:
if af < 0.2 and qual < 55 and pval > 0.06:
fname = "LowFreqQuality"
if fname:
if parts[6] in set([".", "PASS"]):
parts[6] = fname
else:
parts[6] += ";%s" % fname
line = "\t".join(parts)
return line
def _run_vardict_paired(align_bams, items, ref_file, assoc_files,
region=None, out_file=None):
"""Detect variants with Vardict.
This is used for paired tumor / normal samples.
"""
config = items[0]["config"]
if out_file is None:
out_file = "%s-paired-variants.vcf.gz" % os.path.splitext(align_bams[0])[0]
if not utils.file_exists(out_file):
with file_transaction(items[0], out_file) as tx_out_file:
target = shared.subset_variant_regions(dd.get_variant_regions(items[0]), region,
out_file, do_merge=True)
paired = vcfutils.get_paired_bams(align_bams, items)
if not _is_bed_file(target):
vcfutils.write_empty_vcf(tx_out_file, config,
samples=[x for x in [paired.tumor_name, paired.normal_name] if x])
else:
if not paired.normal_bam:
ann_file = _run_vardict_caller(align_bams, items, ref_file,
assoc_files, region, out_file)
return ann_file
vcffilter = config_utils.get_program("vcffilter", config)
vardict = get_vardict_command(items[0])
vcfstreamsort = config_utils.get_program("vcfstreamsort", config)
strandbias = "testsomatic.R"
var2vcf = "var2vcf_paired.pl"
compress_cmd = "| bgzip -c" if out_file.endswith("gz") else ""
freq = float(utils.get_in(config, ("algorithm", "min_allele_fraction"), 10)) / 100.0
# merge bed file regions as amplicon VarDict is only supported in single sample mode
opts = " ".join(_vardict_options_from_config(items, config, out_file, target))
coverage_interval = utils.get_in(config, ("algorithm", "coverage_interval"), "exome")
# for deep targeted panels, require 50 worth of coverage
var2vcf_opts = " -v 50 " if highdepth.get_median_coverage(items[0]) > 5000 else ""
fix_ambig = vcfutils.fix_ambiguous_cl()
remove_dup = vcfutils.remove_dup_cl()
if any("vardict_somatic_filter" in tz.get_in(("config", "algorithm", "tools_off"), data, [])
for data in items):
somatic_filter = ""
freq_filter = ""
else:
var2vcf_opts += " -M " # this makes VarDict soft filter non-differential variants
somatic_filter = ("| sed 's/\\\\.*Somatic\\\\/Somatic/' "
"| sed 's/REJECT,Description=\".*\">/REJECT,Description=\"Not Somatic via VarDict\">/' "
"| %s -x 'bcbio.variation.freebayes.call_somatic(x)'" %
os.path.join(os.path.dirname(sys.executable), "py"))
freq_filter = ("| bcftools filter -m '+' -s 'REJECT' -e 'STATUS !~ \".*Somatic\"' 2> /dev/null "
"| %s -x 'bcbio.variation.vardict.depth_freq_filter(x, %s, \"%s\")'" %
(os.path.join(os.path.dirname(sys.executable), "py"),
0, dd.get_aligner(paired.tumor_data)))
jvm_opts = _get_jvm_opts(items[0], tx_out_file)
r_setup = "unset R_HOME && export PATH=%s:$PATH && " % os.path.dirname(utils.Rscript_cmd())
cmd = ("{r_setup}{jvm_opts}{vardict} -G {ref_file} -f {freq} "
"-N {paired.tumor_name} -b \"{paired.tumor_bam}|{paired.normal_bam}\" {opts} "
"| {strandbias} "
"| {var2vcf} -P 0.9 -m 4.25 -f {freq} {var2vcf_opts} "
"-N \"{paired.tumor_name}|{paired.normal_name}\" "
"{freq_filter} "
"{somatic_filter} | {fix_ambig} | {remove_dup} | {vcfstreamsort} "
"{compress_cmd} > {tx_out_file}")
do.run(cmd.format(**locals()), "Genotyping with VarDict: Inference", {})
out_file = (annotation.add_dbsnp(out_file, assoc_files["dbsnp"], config)
if assoc_files.get("dbsnp") else out_file)
return out_file
def get_vardict_command(data):
"""
convert variantcaller specification to proper vardict command, handling
string or list specification
"""
vcaller = dd.get_variantcaller(data)
if isinstance(vcaller, list):
vardict = [x for x in vcaller if "vardict" in x]
if not vardict:
return None
vardict = vardict[0]
elif not vcaller:
return None
else:
vardict = vcaller
vardict = "vardict-java" if not vardict.endswith("-perl") else "vardict"
return vardict
|
lpantano/bcbio-nextgen
|
bcbio/variation/vardict.py
|
Python
|
mit
| 15,244
|
"""add account id
Revision ID: 3734300868bc
Revises: 3772e5bcb34d
Create Date: 2013-09-30 18:07:21.729288
"""
# revision identifiers, used by Alembic.
revision = '3734300868bc'
down_revision = '3772e5bcb34d'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('account_profile', sa.Column('account_id', sa.Integer(11)))
pass
def downgrade():
pass
|
vsilent/smarty-bot
|
alembic/versions/3734300868bc_add_account_id.py
|
Python
|
mit
| 391
|
---
layout: "docs_api"
title: Supersonic API reference
header_sub_title: <%= apiPath %> overview
section_id: <%= section %>
subsection_id: <%= subsection %>
---
{% assign entry = <%= liquidDataPath %> %}
## Namespace: {{entry.namespace}}.{{entry.name}}
{{entry.description}}
|
AppGyver/supersonic
|
tasks/templates/api_overview_entry.md
|
Markdown
|
mit
| 276
|
<?php
class ShopGroup extends ShopGroupCore
{
}
|
timetre/tnk
|
web/store/override/classes/shop/ShopGroup.php
|
PHP
|
mit
| 51
|
'use strict';
import React from 'react';
const Page = ({children}) => (
<div className="page-component container">
<div className="page-box">
{children}
</div>
</div>
);
export default Page;
|
raapperez/qm
|
frontend/src/js/components/page.js
|
JavaScript
|
mit
| 229
|
require 'spec_helper'
describe "shops/index" do
before(:each) do
assign(:shops, [
stub_model(Shop,
:number => 1,
:name => "Name",
:town => 2,
:street => 3,
:bldg => "Bldg",
:housing => "Housing",
:floor => "Floor",
:id_hard => 4,
:id_stock => 5,
:business_hours => "Business Hours",
:id_provider => 6,
:phone => "Phone"
),
stub_model(Shop,
:number => 1,
:name => "Name",
:town => 2,
:street => 3,
:bldg => "Bldg",
:housing => "Housing",
:floor => "Floor",
:id_hard => 4,
:id_stock => 5,
:business_hours => "Business Hours",
:id_provider => 6,
:phone => "Phone"
)
])
end
it "renders a list of shops" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "tr>td", :text => 1.to_s, :count => 2
assert_select "tr>td", :text => "Name".to_s, :count => 2
assert_select "tr>td", :text => 2.to_s, :count => 2
assert_select "tr>td", :text => 3.to_s, :count => 2
assert_select "tr>td", :text => "Bldg".to_s, :count => 2
assert_select "tr>td", :text => "Housing".to_s, :count => 2
assert_select "tr>td", :text => "Floor".to_s, :count => 2
assert_select "tr>td", :text => 4.to_s, :count => 2
assert_select "tr>td", :text => 5.to_s, :count => 2
assert_select "tr>td", :text => "Business Hours".to_s, :count => 2
assert_select "tr>td", :text => 6.to_s, :count => 2
assert_select "tr>td", :text => "Phone".to_s, :count => 2
end
end
|
AlexKich/Doit
|
spec/views/shops/index.html.erb_spec.rb
|
Ruby
|
mit
| 1,660
|
//select all
$(".input-select-all").change(function () {
var target = $(this).attr("data-target");
// alert(target)
var checked = $(this).is(":checked");
$(target + " input[type=checkbox]").attr("checked", checked);
});
$(function () {
//////////////check group checkboxes/////////
$("body .input-select-all").each(function () {
var target = $(".input-select-all").attr("data-target");
// alert(target)
var checked = $(".input-select-all").is(":checked");
$(target + " input[type=checkbox]").attr("checked", checked);
});
//////////////////////
$(document).on("click", ".step-control .item", function (e) {
e.preventDefault;
var t = $(this).attr("href");
var current = $(".step-control .item.active");
var curr = $(this).attr("href");
curr = curr.substring(1);
tnum = t.substring(1);
if (!inputsEmpty(".item.active") || curr > tnum) {
//code
$(this).parent().find(".item").removeClass("active");
$(this).addClass("active");
//switch tab
$(".steps .item").removeClass("active");
$(".steps .item" + t).addClass("active");
if ($(".steps .item.active").next().length != 0) {
$(".step-ride .next").removeClass("hide");
$(".step-ride .save").addClass("hide");
} else {
$(".step-ride .next").addClass("hide");
$(".step-ride .save").removeClass("hide");
}
}
});
$(".square").each(function () {
var t = $(this).width();
$(this).css({
"height": t + "px",
"opacity": 1
});
});
///position drop menus
// $(".overflow-menu").each(function () {
// var menubox = $(this);
// var h = menubox.height;
// var hb = menubox.offset().bottom - $("tbody").height();
// var ph = 32;
// });
//scale table
$(".tableSection").each(function (i, table) {
var theight = $(document).height() - $(table).find("tbody").offset().top;
theight = theight - 20;
$(table).find("tbody").css("height", theight + "px");
});
//scale fill heigh
//scale table
$(".fill-height").each(function (i, fh) {
var fillheight = $(document).height() - $(fh).offset().top;
fillheight = fillheight - 20;
$(fh).css("height", fillheight + "px");
//alert(fillheight)
//alert(theight);
});
});
$(document).on("click", ".select-box", function (e) {
//alert(00)
//$(this).parent().find("input[type=file]").val("");
//$(this).find("select").click();
});
$(document).on("click", ".browse-file", function (e) {
//$(this).parent().find("input[type=file]").val("");
$(this).parent().find("input[type=file]").click();
});
var menu = 0;
$(document).on("click", ".overflow .overflow-toggle", function (e) {
//alert(3)
e.stopImmediatePropagation();
var menubox = $(this).parent().find(".overflow-menu");
if (menu == 0) {
menubox.fadeIn(100);
menu = 1;
} else {
$(".overflow-menu").fadeOut(100);
menubox.fadeIn(100);
menu = 1;
}
// var h = menubox.height;
// var hb = menubox.offset().bottom - $("tbody").height();
// var ph = 32;
//
// if (elementInViewport(menubox).find("li:last-child").is("visible")) {
// alert(2)
// menubox.css("botton", "-" + ph + "px");
// } else {
//
// menubox.css("top", ph + "px");
// }
});
$(".overflow-menu").click(function (e) {
})
$(document, ".overflow-menu a").on("click", function () {
$(".overflow-menu").fadeOut(10);
menu = 0;
})
$("tbody").on("scroll", function () {
$(".overflow-menu").fadeOut(10);
menu = 0;
})
function elementInViewport(el) {
var top = el.offsetTop;
var left = el.offsetLeft;
var width = el.offsetWidth;
var height = el.offsetHeight;
while (el.offsetParent) {
el = el.offsetParent;
top += el.offsetTop;
left += el.offsetLeft;
}
return (
top >= window.pageYOffset &&
left >= window.pageXOffset &&
(top + height) <= (window.pageYOffset + window.innerHeight) &&
(left + width) <= (window.pageXOffset + window.innerWidth)
);
}
function notify(type, msg, duration) {
var id = new Date().getMilliseconds();
var icon = "fa fa-close";
var htm = "<div class='e-notify " + type +
"' id='" + htm + "'><p><i class='fa " + icon +
"'></i> " + msg +
"</p><a class='close' onclick='close(this)'><i class='fa fa-close-circle'></i></a></div>";
$(document).append(thm);
setTimeout(function () {
$($("#" + id)).remove()
}, duration);
}
function nextStep(element, e) {
//code
e.preventDefault;
//var t = $(el).attr("href");
var current = $(".step-control .item.active"),
nextStep = current.next();
nextStep.click();
}
function prevStep(element, e) {
//code
e.preventDefault;
//var t = $(el).attr("href");
var current = $(".step-control .item.active"),
prevStep = current.prev();
prevStep.click();
}
function gotoStep(position) {
//code
e.preventDefault;
//var t = $(el).attr("href");
var step = $(".step-control .item:eq(" + position + ")");
step.click();
}
function progressDialog(message) {
swal({
title: "",
text: "<br/><i class='fa fa-spin fa-spinner'></i> <strong>" + message + "</strong>",
html: true,
showConfirmButton: false
});
}
function loader(selector, message) {
if ($(selector).hasClass("btn")) {
$(selector).html("<i class='fa fa-spin fa-spinner'></i> <strong> " + message + "</strong>");
} else {
$(selector).html("<br/><i class='fa fa-spin fa-spinner'></i> <strong> " + message + "</strong>");
}
}
function successDialog(title, message) {
//code
swal({
title: title,
text: message,
html: true,
showConfirmButton: true,
type: "success"
});
}
function infoDialog(message) {
//code
swal({
title: "",
text: "<i class='text-blue fa fa-exclamation-circle'></i> " + message,
html: true,
showConfirmButton: true,
type: ""
});
}
//Date
if ($('.date-picker')[0]) {
$('.date-picker').datetimepicker({
format: 'DD/MM/YYYY'
});
}
|
kgidion1/Hive-Projects
|
public/js/custom.js
|
JavaScript
|
mit
| 6,602
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Chris Turner" />
<meta name="description" content="Personal blog and resume">
<link rel="favicon" href="/sustain/static/img/favicon.ico">
<title>The Art of Delegation</title>
<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"
integrity="sha256-MfvZlkHCEqatNoGiOXveE8FIwMzZg4W85qfrfIFBfYc= sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ=="
crossorigin="anonymous">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Custom styles for this template -->
<link rel="stylesheet" type="text/css" href="/sustain/static/css/main.css" />
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,400,200bold,400old" />
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="/sustain/static/css/syntax.css" />
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-69391421-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<!-- Main Body-->
<body>
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Navbar header -->
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/sustain/"><i class="fa fa-home"></i></a>
</div>
<div id="navbar">
<ul class="nav navbar-nav navbar-right">
<li><a href="/sustain/blog.html">Words</a></li>
<li><a href="/sustain/projects.html">Work</a></li>
<li><div class="col-sm-12 col-md-12 col-lg-12 social">
<h4>
<a href="http://twitter.com/username"><i class="fa fa-twitter"></i></a>
<a href="http://github.com/biomadeira/sustain"><i class="fa fa-github"></i></a>
<a href="mailto:yourname@email.com"><i class="fa fa-envelope"></i></a>
</h4>
</div>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="blog-post">
<h3>
<strong><a href="/art-of-delegation.html">The Art of Delegation</a></strong>
</h3>
</div>
<div class="blog-title">
<h5>
October 8, 2015
</h5>
</div>
<div class="panel panel-default">
<div class="panel-body">
<div class="blogpost">
<p>Over the past year at <a href="http://torque.digital">Torque</a>, we’ve been sharing skills and knowledge with each other in small, periodical workshops. These days, that looks like a weekly 2:30pm ‘tea time’ in the conference room. For this week’s workshop, Partner and Creative Director <a href="http://torque.digital/team/jennifer-masi">Jennifer Masi</a> gave us tips and tricks about <em>The Art of Delegating</em>, also known by her actionable phrase, “Delegate to Elevate.”</p>
<p>I’m morphing her presentation into a post so I can share it with you because I believe it’s really important, and it’s something I need to learn myself. Many people I know work alone – sometimes literally alone, other times they’re not working collaboratively with their teammates. I am definitely guilty of this. If we work alone, we may let strong skills for teamwork, collaboration, and trust for others atrophy. We need these traits to provide a necessary foundation for delegation, and we need the practice of delegation to strengthen those traits in us. It can be scary to invite someone else in to your creative process, but your work – <em>and sanity</em> – may suffer if you always do it alone.</p>
<h3>Goals of Delegation</h3>
<p>Delegating helps elevate you to your best use and elevates helpers as they learn and grow. Delegating helps you learn to trust others, gets the job done well, and diversifies perspectives going into the project.</p>
<h3>Ask yourself, is this a delegation moment?</h3>
<p>Just because a task is assigned to you, doesn’t mean you need to be the one to complete it – it can often be delegated. Delegation is also not a status indicator. Jennifer makes an important note:</p>
<blockquote><p>No job is beneath anyone. All jobs are important. Leaders know how and are willing to do all the jobs. Remember, if someone doesn’t buy the toilet paper, <em>what would happen to the office?</em></p></blockquote>
<h3>Keys to Delegate like a Pro</h3>
<ol>
<li><p><strong>Give time frame & details.</strong> Be specific about the details of the project to set a strong foundation and make sure everyone is on the same page. Establishing a clear, shared idea about the outcome of the project will ensure its success.</p></li>
<li><p><strong>Delegate the objective, not the procedure.</strong> This is where trust comes in heavily. Successful delegation respects the opinion and process of everyone involved. Delegating projects or tasks comes with understanding that different people have different ways of doing the same thing. Dictating every facet of a project strangles it; let the project thrive on the contributions of others.</p></li>
<li><p><strong>Ensure your delegatee has whatever they need to be successful.</strong> Equip everyone helping you with the right tools so they can do their best work for your project. Check in with them periodically to make sure their tools are working well for them.</p></li>
<li><p><strong>Give your delegatee the opportunity to ask questions.</strong> Setting aside time for questions and conversations about the project will give your helpers a feeling of ownership and involvement in the project. Strong communication with people to whom you delegate is investing in the quality of the end product.</p></li>
<li><p><strong>Check in through project completion.</strong> Gotta stay on task! Follow up and check in with everyone on the project. Touching base more often makes sure the project doesn’t go off track so you can acheive the outcome you need. Make sure they confirm with you when their tasks are finished and follow up after the project.</p></li>
<li><p><strong>Show your appreciation for the people who invested in your project with you.</strong> A big ‘thank you’ goes a long way. I know I don’t always go the extra step to vocalize my thankfulness. Showing gratitude increases personal growth on both sides and better partnerships going forward.</p></li>
</ol>
<h3>Go do it</h3>
<p>Go delegate! <a href="http://twitter.com/lenamasek">Let me know</a> how delegation is working best for you.</p>
<!-- <hr>
<div class="related-posts">
<h5>Related Posts</h5>
<div class="row">
<div class="col-sm-4 col-md-4 col-lg-4">
<h6 style="text-align: right">
September 22, 2015
</h6>
</div>
<div class="col-sm-8 col-md-8 col-lg-8">
<h6 style="text-align: left">
<strong><a href="/sustain//manifold-garden.html">Manifold Garden</a></strong>
</h6>
</div>
</div>
<div class="row">
<div class="col-sm-4 col-md-4 col-lg-4">
<h6 style="text-align: right">
August 22, 2015
</h6>
</div>
<div class="col-sm-8 col-md-8 col-lg-8">
<h6 style="text-align: left">
<strong><a href="/sustain//bitbash.html">Bit Bash</a></strong>
</h6>
</div>
</div>
<div class="row">
<div class="col-sm-4 col-md-4 col-lg-4">
<h6 style="text-align: right">
July 20, 2015
</h6>
</div>
<div class="col-sm-8 col-md-8 col-lg-8">
<h6 style="text-align: left">
<strong><a href="/sustain//priester-aviation-brand-update.html">Priester Aviation Brand Update</a></strong>
</h6>
</div>
</div>
</div> -->
</div>
</div>
</div>
</div>
</div>
<!-- Footer -->
<footer>
<div id="footer">
<div class="container">
<p class="text-muted">© all rights reserved. powered by <a href="http://jekyllrb.com/">jekyll</a> and
<a href="http://www.github.com/biomadeira/sustain">sustain</a>.</p>
</div>
</div>
</footer>
<div class="footer"></div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"
integrity="sha256-Sk3nkD6mLTMOF0EOpNtsIry+s1CsaqQC1rVLTAy+0yc= sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ=="
crossorigin="anonymous"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="/sustain/static/js/docs.min.js"></script>
<script src="/sustain/static/js/main.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="/sustain/static/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>
|
lenamasek/lenamasek.github.io
|
_site/art-of-delegation.html
|
HTML
|
mit
| 9,992
|
---
author: robmyers
comments: true
date: 2012-10-03 05:04:47+00:00
layout: page
slug: nineteen-sixty-nine
title: '1969'
permalink: /nineteen-sixty-nine/
wordpress_id: 2168
---
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
* 
**1969, 2004, digital vector images.**
Remixed nuclear attack simulation diagrams.
Created using Inkscape on Debian on an iBook G4.
You can download the source files [here](https://gitorious.org/robmyers/1969).
The images in this series are under the [Creative Commons Attribution-ShareAlike 3.0 licence](http://creativecommons.org/licenses/by-sa/3.0/).
|
robmyers/robmyers.org
|
_pages/nineteen-sixty-nine.md
|
Markdown
|
mit
| 1,803
|
/*
* Copyright (c) 2014-2021 Bjoern Kimminich.
* SPDX-License-Identifier: MIT
*/
import { TranslateModule, TranslateService } from '@ngx-translate/core'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { MatCardModule } from '@angular/material/card'
import { MatFormFieldModule } from '@angular/material/form-field'
import { ComponentFixture, fakeAsync, TestBed, waitForAsync } from '@angular/core/testing'
import { AddressCreateComponent } from './address-create.component'
import { MatInputModule } from '@angular/material/input'
import { ReactiveFormsModule } from '@angular/forms'
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
import { of, throwError } from 'rxjs'
import { RouterTestingModule } from '@angular/router/testing'
import { AddressService } from '../Services/address.service'
import { MatGridListModule } from '@angular/material/grid-list'
import { EventEmitter } from '@angular/core'
import { MatIconModule } from '@angular/material/icon'
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar'
describe('AddressCreateComponent', () => {
let component: AddressCreateComponent
let fixture: ComponentFixture<AddressCreateComponent>
let addressService
let translateService
let snackBar: any
beforeEach(waitForAsync(() => {
addressService = jasmine.createSpyObj('AddressService', ['getById', 'put', 'save'])
addressService.save.and.returnValue(of({}))
addressService.getById.and.returnValue(of({}))
addressService.put.and.returnValue(of({}))
translateService = jasmine.createSpyObj('TranslateService', ['get'])
translateService.get.and.returnValue(of({}))
translateService.onLangChange = new EventEmitter()
translateService.onTranslationChange = new EventEmitter()
translateService.onDefaultLangChange = new EventEmitter()
snackBar = jasmine.createSpyObj('MatSnackBar', ['open'])
snackBar.open.and.returnValue(null)
TestBed.configureTestingModule({
imports: [
RouterTestingModule,
TranslateModule.forRoot(),
HttpClientTestingModule,
ReactiveFormsModule,
BrowserAnimationsModule,
MatCardModule,
MatFormFieldModule,
MatInputModule,
MatGridListModule,
MatIconModule,
MatSnackBarModule
],
declarations: [AddressCreateComponent],
providers: [
{ provide: AddressService, useValue: addressService },
{ provide: TranslateService, useValue: translateService },
{ provide: MatSnackBar, useValue: snackBar }
]
})
.compileComponents()
}))
beforeEach(() => {
fixture = TestBed.createComponent(AddressCreateComponent)
component = fixture.componentInstance
fixture.detectChanges()
})
it('should create', () => {
expect(component).toBeTruthy()
})
it('should reinitizalise forms by calling resetForm', () => {
component.countryControl.setValue('US')
component.nameControl.setValue('jim')
component.numberControl.setValue(9800000000)
component.pinControl.setValue('NX 101')
component.addressControl.setValue('Bakers Street')
component.cityControl.setValue('NYC')
component.stateControl.setValue('NY')
component.resetForm()
expect(component.countryControl.value).toBe('')
expect(component.countryControl.pristine).toBe(true)
expect(component.countryControl.untouched).toBe(true)
expect(component.nameControl.value).toBe('')
expect(component.nameControl.pristine).toBe(true)
expect(component.nameControl.untouched).toBe(true)
expect(component.numberControl.value).toBe('')
expect(component.numberControl.pristine).toBe(true)
expect(component.numberControl.untouched).toBe(true)
expect(component.pinControl.value).toBe('')
expect(component.pinControl.pristine).toBe(true)
expect(component.pinControl.untouched).toBe(true)
expect(component.addressControl.value).toBe('')
expect(component.addressControl.pristine).toBe(true)
expect(component.addressControl.untouched).toBe(true)
expect(component.cityControl.value).toBe('')
expect(component.cityControl.pristine).toBe(true)
expect(component.cityControl.untouched).toBe(true)
expect(component.stateControl.value).toBe('')
expect(component.stateControl.pristine).toBe(true)
expect(component.stateControl.untouched).toBe(true)
})
it('should be compulsory to provide country', () => {
component.countryControl.setValue('')
expect(component.countryControl.valid).toBeFalsy()
})
it('should be compulsory to provide name', () => {
component.nameControl.setValue('')
expect(component.nameControl.valid).toBeFalsy()
})
it('should be compulsory to provide number', () => {
component.numberControl.setValue('')
expect(component.numberControl.valid).toBeFalsy()
})
it('should be compulsory to provide pin', () => {
component.pinControl.setValue('')
expect(component.pinControl.valid).toBeFalsy()
})
it('should be compulsory to provide address', () => {
component.addressControl.setValue('')
expect(component.addressControl.valid).toBeFalsy()
})
it('should be compulsory to provide city', () => {
component.cityControl.setValue('')
expect(component.cityControl.valid).toBeFalsy()
})
it('should not be compulsory to provide state', () => {
component.stateControl.setValue('')
expect(component.stateControl.valid).toBe(true)
})
it('pin code should not be more than 8 characters', () => {
let str: string = ''
for (let i = 0; i < 9; ++i) {
str += 'a'
}
component.pinControl.setValue(str)
expect(component.pinControl.valid).toBeFalsy()
str = str.slice(1)
component.pinControl.setValue(str)
expect(component.pinControl.valid).toBe(true)
})
it('address should not be more than 160 characters', () => {
let str: string = ''
for (let i = 0; i < 161; ++i) {
str += 'a'
}
component.addressControl.setValue(str)
expect(component.addressControl.valid).toBeFalsy()
str = str.slice(1)
component.addressControl.setValue(str)
expect(component.addressControl.valid).toBe(true)
})
it('number should be in the range [1111111, 9999999999]', () => {
component.numberControl.setValue(1111110)
expect(component.numberControl.valid).toBeFalsy()
component.numberControl.setValue(10000000000)
expect(component.numberControl.valid).toBeFalsy()
component.numberControl.setValue(9999999999)
expect(component.numberControl.valid).toBe(true)
component.numberControl.setValue(1111111)
expect(component.numberControl.valid).toBe(true)
})
it('should reset the form on updating address and show confirmation', () => {
addressService.put.and.returnValue(of({ city: 'NY' }))
translateService.get.and.returnValue(of('ADDRESS_UPDATED'))
component.mode = 'edit'
spyOn(component, 'resetForm')
spyOn(component, 'ngOnInit')
component.save()
expect(translateService.get).toHaveBeenCalledWith('ADDRESS_UPDATED', { city: 'NY' })
expect(component.ngOnInit).toHaveBeenCalled()
expect(component.resetForm).toHaveBeenCalled()
})
it('should reset the form on adding address and show confirmation', () => {
addressService.save.and.returnValue(of({ city: 'NY' }))
translateService.get.and.returnValue(of('ADDRESS_ADDED'))
spyOn(component, 'resetForm')
spyOn(component, 'ngOnInit')
component.save()
expect(translateService.get).toHaveBeenCalledWith('ADDRESS_ADDED', { city: 'NY' })
expect(component.ngOnInit).toHaveBeenCalled()
expect(component.resetForm).toHaveBeenCalled()
})
it('should clear the form and display error if saving address fails', fakeAsync(() => {
addressService.save.and.returnValue(throwError({ error: 'Error' }))
spyOn(component, 'resetForm')
component.save()
expect(component.resetForm).toHaveBeenCalled()
expect(snackBar.open).toHaveBeenCalled()
}))
it('should clear the form and display error if updating address fails', fakeAsync(() => {
addressService.put.and.returnValue(throwError({ error: 'Error' }))
component.mode = 'edit'
spyOn(component, 'resetForm')
component.save()
expect(component.resetForm).toHaveBeenCalled()
expect(snackBar.open).toHaveBeenCalled()
}))
it('should populate the form on calling initializeForm', () => {
component.initializeForm({ country: 'US', fullName: 'jim', mobileNum: 9800000000, zipCode: 'NX 101', streetAddress: 'Bakers Street', city: 'NYC', state: 'NY' })
expect(component.countryControl.value).toBe('US')
expect(component.nameControl.value).toBe('jim')
expect(component.numberControl.value).toBe(9800000000)
expect(component.pinControl.value).toBe('NX 101')
expect(component.addressControl.value).toBe('Bakers Street')
expect(component.cityControl.value).toBe('NYC')
expect(component.stateControl.value).toBe('NY')
})
})
|
bkimminich/juice-shop
|
frontend/src/app/address-create/address-create.component.spec.ts
|
TypeScript
|
mit
| 8,994
|
/*
*
* @author Benoit Vinay
*
* ben@benoitvinay.com
* http://www.benoitvinay.com
*
*/
//////////////////////////////////////////////////////////////////////////////////////////
// Sound Object
//
// use in loader.sound.js
//////////////////////////////////////////////////////////////////////////////////////////
function SoundObject(url, tag) {
var _this = this;
var _tag = tag;
var _valid = (_tag.canPlayType ? true : false); // check if the tag is valid (i.e.: Safari on Windows)
var _playTimeout = undefined;
var _loopInterval = undefined;
var _duration = (_valid ? (_tag.duration * 1000) : -1);
var _playing = false;
this.url = url;
// play
var _play = function(time) {
_this.stop();
try {
_tag.currentTime = time || 0;
_tag.play();
}
catch(e) {
_error(e);
}
_playing = true;
}
this.play = function(time, complete) {
_play.apply(_this, [time]);
try {
_tag.loop = false;
}
catch(e) {
_error(e);
}
if(complete) {
_playTimeout = setTimeout(function() {
clearTimeout(_playTimeout);
complete.apply(_this);
}, _duration);
}
}
// loop
this.loop = function(time, complete) {
_play.apply(_this, [time]);
try {
_tag.loop = true;
}
catch(e) {
_error(e);
}
_loopInterval = setInterval(function() {
if(complete) {
complete.apply(_this);
}
}, _duration);
}
// stop
this.stop = function() {
_playing = false;
if(_playTimeout) {
clearTimeout(_playTimeout);
}
if(_loopInterval) {
clearInterval(_loopInterval);
}
try {
_tag.pause();
}
catch(e) {
_error(e);
}
}
// volume
this.mute = function(value) {
try {
_tag.muted = value;
}
catch(e) {
_error(e);
}
}
// error
var _error = function(e) {
Console.log("SoundObject.error:", e.message);
}
// valid
if(!_valid) {
_play = function(time) {};
this.play = function(time, complete) {};
this.loop = function(time, complete) {};
this.stop = function() {};
this.mute = function(value) {};
_error({ message: this.url + " is not valid." });
}
// if valid
// we add the tag to the holder
else {
if($("#audios-holder").length == 0) {
$("body").prepend("<div id='audios-holder'></div>");
}
$("#audios-holder").append(_tag);
_tag = document.getElementById(url);
}
}
|
losrebellos/Los-Rebellos-Library-js
|
src/losrebellos/sound/sound.tag.js
|
JavaScript
|
mit
| 2,438
|
<?php
namespace Drupal\migrate_infob\Plugin\migrate\source;
use Drupal\migrate\Row;
use Drupal\node\Plugin\migrate\source\d6\Node;
/**
* Drupal 6 node source from database.
*
* @MigrateSource(
* id = "youtube_video_node"
* )
*/
class YoutubeVideoNode extends Node {
/**
* {@inheritdoc}
*/
public function query() {
$query = parent::query();
$query->condition('n.language', 'en');
$query->condition('n.status', 1);
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
$fields = parent::fields();
//add custom fields
$fields['field_homepage_blurb'] = $this->t('Home page blurb');
$fields['field_external_youtube'] = $this->t('External youtube url');
$fields['field_article_datef'] = $this->t('Date');
$fields['field_pdf'] = $this->t('Pdf file');
return $fields;
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
if (parent::prepareRow($row) === FALSE) {
return FALSE;
}
$metatags = [
'title' => '[node:title] | [site:name]',
'description' => $row->getSourceProperty('DESCRIPTION'),
'keywords' => $row->getSourceProperty('KEYWORDS'),
];
$row->setSourceProperty('meta_tags', serialize($metatags));
if ($hb = $row->getSourceProperty('field_homepage_blurb')) {
$hb[0]['format'] = 'full_html';
$row->setSourceProperty('field_homepage_blurb', $hb);
}
elseif ($body = $row->getSourceProperty('body')) {
$value[0]['value'] = $body;
$value[0]['format'] = 'full_html';
$row->setSourceProperty('field_homepage_blurb', $value);
}
if ($ext = $row->getSourceProperty('field_external_youtube')) {
$ext = 'https://www.youtube.com/watch?v=' . $ext[0]['value'];
$row->setSourceProperty('field_external_youtube', $ext);
}
//- Get taxonomy terms from node being imported
$termIds = $this->select('term_node', 'n')
->fields('n', array('tid'))
->condition('n.nid', $row->getSourceProperty('nid'))
->distinct()
->execute()
->fetchCol();
if (!empty($termIds)) {
$termData = $this->select('term_data', 't')
->fields('t', array( 'vid', 'tid', 'name' ))
->condition('t.tid', $termIds, 'IN')
->distinct()
->execute()
->fetchAll();
//- Map industry taxonomy
$industryTerms = $this->getTerms('industries', $termData);
if ( ! empty( $industryTerms )) {
$row->setSourceProperty('field_industry', $industryTerms);
}
//- Map topic taxonomy
$topicTerms = $this->getTerms('topics', $termData);
if ( ! empty( $topicTerms )) {
$row->setSourceProperty('field_topic', $topicTerms);
}
//- Map product taxonomy
$productTerms = $this->getTerms('products', $termData);
if ( ! empty( $productTerms )) {
$row->setSourceProperty('field_tax_product', $productTerms);
}
//- Map function taxonomy
$functionTerms = $this->getTerms('functions', $termData);
if ( ! empty( $functionTerms )) {
$row->setSourceProperty('field_tax_function', $functionTerms);
}
//- Map video taxonomy
$videoTerms = $this->getTerms('video', $termData);
if ( ! empty( $videoTerms )) {
$row->setSourceProperty('field_tax_video', $videoTerms);
}
}
//- Map customer taxonomy
$customerNode = $row->getSourceProperty('field_customer_node');
if (!empty($customerNode)) {
$nid = $customerNode[0]['nid'];
/**
* Get new node id from migrate_map_xxxx table as nid at destination is different than nid at source.
*/
$d8nid = \Drupal::database()->select('migrate_map_infob_customer', 'mmic')
->fields('mmic', array('destid1'))
->condition('mmic.sourceid1', $nid)
->distinct()
->execute()
->fetchCol();
$d8node = \Drupal\node\Entity\Node::load($d8nid[0]);
if ($d8node) {
$customerTerms = $d8node->get('field_customer')->referencedEntities();
$custTerms = [];
foreach ($customerTerms as $term) {
$custTerms[] = $term->tid->value;
}
$row->setSourceProperty('field_customer_node', $custTerms);
}
}
return TRUE;
}
public function getTerms($vocabulary, $termData) {
$terms = \Drupal::service('entity_type.manager')->getStorage("taxonomy_term")->loadTree($vocabulary, $parent = 0, $max_depth = NULL, $load_entities = FALSE);
$termIds = array();
foreach ($terms as $k => $term) {
foreach($termData as $availableTerm) {
if ($term->name == $availableTerm['name']) {
$termIds[] = $term->tid;
}
}
}
return $termIds;
}
}
|
amutylo/IB-d8-migration
|
migrate_infob/src/Plugin/migrate/source/YoutubeVideoNode.php
|
PHP
|
mit
| 4,966
|
#![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::hash::Hash;
use core::hash::Hasher;
use core::hash::SipHasher;
// pub struct SipHasher {
// k0: u64,
// k1: u64,
// length: usize, // how many bytes we've processed
// v0: u64, // hash state
// v1: u64,
// v2: u64,
// v3: u64,
// tail: u64, // unprocessed bytes le
// ntail: usize, // how many bytes in tail are valid
// }
// macro_rules! u8to64_le {
// ($buf:expr, $i:expr) =>
// ($buf[0+$i] as u64 |
// ($buf[1+$i] as u64) << 8 |
// ($buf[2+$i] as u64) << 16 |
// ($buf[3+$i] as u64) << 24 |
// ($buf[4+$i] as u64) << 32 |
// ($buf[5+$i] as u64) << 40 |
// ($buf[6+$i] as u64) << 48 |
// ($buf[7+$i] as u64) << 56);
// ($buf:expr, $i:expr, $len:expr) =>
// ({
// let mut t = 0;
// let mut out = 0;
// while t < $len {
// out |= ($buf[t+$i] as u64) << t*8;
// t += 1;
// }
// out
// });
// }
// macro_rules! rotl {
// ($x:expr, $b:expr) =>
// (($x << $b) | ($x >> (64_i32.wrapping_sub($b))))
// }
// macro_rules! compress {
// ($v0:expr, $v1:expr, $v2:expr, $v3:expr) =>
// ({
// $v0 = $v0.wrapping_add($v1); $v1 = rotl!($v1, 13); $v1 ^= $v0;
// $v0 = rotl!($v0, 32);
// $v2 = $v2.wrapping_add($v3); $v3 = rotl!($v3, 16); $v3 ^= $v2;
// $v0 = $v0.wrapping_add($v3); $v3 = rotl!($v3, 21); $v3 ^= $v0;
// $v2 = $v2.wrapping_add($v1); $v1 = rotl!($v1, 17); $v1 ^= $v2;
// $v2 = rotl!($v2, 32);
// })
// }
// impl SipHasher {
// /// Creates a new `SipHasher` with the two initial keys set to 0.
// #[inline]
// #[stable(feature = "rust1", since = "1.0.0")]
// pub fn new() -> SipHasher {
// SipHasher::new_with_keys(0, 0)
// }
//
// /// Creates a `SipHasher` that is keyed off the provided keys.
// #[inline]
// #[stable(feature = "rust1", since = "1.0.0")]
// pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher {
// let mut state = SipHasher {
// k0: key0,
// k1: key1,
// length: 0,
// v0: 0,
// v1: 0,
// v2: 0,
// v3: 0,
// tail: 0,
// ntail: 0,
// };
// state.reset();
// state
// }
//
// #[inline]
// fn reset(&mut self) {
// self.length = 0;
// self.v0 = self.k0 ^ 0x736f6d6570736575;
// self.v1 = self.k1 ^ 0x646f72616e646f6d;
// self.v2 = self.k0 ^ 0x6c7967656e657261;
// self.v3 = self.k1 ^ 0x7465646279746573;
// self.ntail = 0;
// }
//
// #[inline]
// fn write(&mut self, msg: &[u8]) {
// let length = msg.len();
// self.length += length;
//
// let mut needed = 0;
//
// if self.ntail != 0 {
// needed = 8 - self.ntail;
// if length < needed {
// self.tail |= u8to64_le!(msg, 0, length) << 8*self.ntail;
// self.ntail += length;
// return
// }
//
// let m = self.tail | u8to64_le!(msg, 0, needed) << 8*self.ntail;
//
// self.v3 ^= m;
// compress!(self.v0, self.v1, self.v2, self.v3);
// compress!(self.v0, self.v1, self.v2, self.v3);
// self.v0 ^= m;
//
// self.ntail = 0;
// }
//
// // Buffered tail is now flushed, process new input.
// let len = length - needed;
// let end = len & (!0x7);
// let left = len & 0x7;
//
// let mut i = needed;
// while i < end {
// let mi = u8to64_le!(msg, i);
//
// self.v3 ^= mi;
// compress!(self.v0, self.v1, self.v2, self.v3);
// compress!(self.v0, self.v1, self.v2, self.v3);
// self.v0 ^= mi;
//
// i += 8;
// }
//
// self.tail = u8to64_le!(msg, i, left);
// self.ntail = left;
// }
// }
// impl Hasher for SipHasher {
// #[inline]
// fn write(&mut self, msg: &[u8]) {
// self.write(msg)
// }
//
// #[inline]
// fn finish(&self) -> u64 {
// let mut v0 = self.v0;
// let mut v1 = self.v1;
// let mut v2 = self.v2;
// let mut v3 = self.v3;
//
// let b: u64 = ((self.length as u64 & 0xff) << 56) | self.tail;
//
// v3 ^= b;
// compress!(v0, v1, v2, v3);
// compress!(v0, v1, v2, v3);
// v0 ^= b;
//
// v2 ^= 0xff;
// compress!(v0, v1, v2, v3);
// compress!(v0, v1, v2, v3);
// compress!(v0, v1, v2, v3);
// compress!(v0, v1, v2, v3);
//
// v0 ^ v1 ^ v2 ^ v3
// }
// }
// pub trait Hash {
// /// Feeds this value into the state given, updating the hasher as necessary.
// #[stable(feature = "rust1", since = "1.0.0")]
// fn hash<H: Hasher>(&self, state: &mut H);
//
// /// Feeds a slice of this type into the state provided.
// #[unstable(feature = "hash", reason = "module was recently redesigned")]
// fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) where Self: Sized {
// for piece in data {
// piece.hash(state);
// }
// }
// }
// pub trait Hasher {
// /// Completes a round of hashing, producing the output hash generated.
// #[stable(feature = "rust1", since = "1.0.0")]
// fn finish(&self) -> u64;
//
// /// Writes some data into this `Hasher`
// #[stable(feature = "rust1", since = "1.0.0")]
// fn write(&mut self, bytes: &[u8]);
//
// /// Write a single `u8` into this hasher
// #[inline]
// #[unstable(feature = "hash", reason = "module was recently redesigned")]
// fn write_u8(&mut self, i: u8) { self.write(&[i]) }
// /// Write a single `u16` into this hasher.
// #[inline]
// #[unstable(feature = "hash", reason = "module was recently redesigned")]
// fn write_u16(&mut self, i: u16) {
// self.write(&unsafe { mem::transmute::<_, [u8; 2]>(i) })
// }
// /// Write a single `u32` into this hasher.
// #[inline]
// #[unstable(feature = "hash", reason = "module was recently redesigned")]
// fn write_u32(&mut self, i: u32) {
// self.write(&unsafe { mem::transmute::<_, [u8; 4]>(i) })
// }
// /// Write a single `u64` into this hasher.
// #[inline]
// #[unstable(feature = "hash", reason = "module was recently redesigned")]
// fn write_u64(&mut self, i: u64) {
// self.write(&unsafe { mem::transmute::<_, [u8; 8]>(i) })
// }
// /// Write a single `usize` into this hasher.
// #[inline]
// #[unstable(feature = "hash", reason = "module was recently redesigned")]
// fn write_usize(&mut self, i: usize) {
// if cfg!(target_pointer_width = "32") {
// self.write_u32(i as u32)
// } else {
// self.write_u64(i as u64)
// }
// }
//
// /// Write a single `i8` into this hasher.
// #[inline]
// #[unstable(feature = "hash", reason = "module was recently redesigned")]
// fn write_i8(&mut self, i: i8) { self.write_u8(i as u8) }
// /// Write a single `i16` into this hasher.
// #[inline]
// #[unstable(feature = "hash", reason = "module was recently redesigned")]
// fn write_i16(&mut self, i: i16) { self.write_u16(i as u16) }
// /// Write a single `i32` into this hasher.
// #[inline]
// #[unstable(feature = "hash", reason = "module was recently redesigned")]
// fn write_i32(&mut self, i: i32) { self.write_u32(i as u32) }
// /// Write a single `i64` into this hasher.
// #[inline]
// #[unstable(feature = "hash", reason = "module was recently redesigned")]
// fn write_i64(&mut self, i: i64) { self.write_u64(i as u64) }
// /// Write a single `isize` into this hasher.
// #[inline]
// #[unstable(feature = "hash", reason = "module was recently redesigned")]
// fn write_isize(&mut self, i: isize) { self.write_usize(i as usize) }
// }
// macro_rules! impl_write {
// ($(($ty:ident, $meth:ident),)*) => {$(
// #[stable(feature = "rust1", since = "1.0.0")]
// impl Hash for $ty {
// fn hash<H: Hasher>(&self, state: &mut H) {
// state.$meth(*self)
// }
//
// fn hash_slice<H: Hasher>(data: &[$ty], state: &mut H) {
// // FIXME(#23542) Replace with type ascription.
// #![allow(trivial_casts)]
// let newlen = data.len() * ::$ty::BYTES;
// let ptr = data.as_ptr() as *const u8;
// state.write(unsafe { slice::from_raw_parts(ptr, newlen) })
// }
// }
// )*}
// }
// impl_write! {
// (u8, write_u8),
// (u16, write_u16),
// (u32, write_u32),
// (u64, write_u64),
// (usize, write_usize),
// (i8, write_i8),
// (i16, write_i16),
// (i32, write_i32),
// (i64, write_i64),
// (isize, write_isize),
// }
type H = SipHasher; // H: Hasher
#[test]
fn hash_test1() {
let mut state: H = <H>::new();
let finish: u64 = state.finish();
assert_eq!(finish, 0x1e924b9d737700d7);
let data: i64 = 0x0102030405060708;
data.hash::<H>(&mut state);
let finish: u64 = state.finish();
assert_eq!(finish, 0x6e30be5baa0e07fe);
}
}
|
athenainn/rust-trace
|
libcore/hash/mod/impl/i64/hash.rs
|
Rust
|
mit
| 10,589
|
// app/models/tools.js
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var ToolsSchema = new Schema({
name: String,
tooltype: String,
weight: Number,
damagedflag: Boolean,
serialnumber: String
});
module.exports = mongoose.model('Tools', ToolsSchema);
|
MatthewGreen/ToolsManagerAppExternalAPI
|
app/models/tools.js
|
JavaScript
|
mit
| 277
|
module.exports = parse
/**
* expected argument lengths
* @type {Object}
*/
var length = {a: 7, c: 6, h: 1, l: 2, m: 2, q: 4, s: 4, t: 2, v: 1, z: 0}
/**
* segment pattern
* @type {RegExp}
*/
var segment = /([astvzqmhlc])([^astvzqmhlc]*)/ig
/**
* parse an svg path data string. Generates an Array
* of commands where each command is an Array of the
* form `[command, arg1, arg2, ...]`
*
* @param {String} path
* @return {Array}
*/
function parse(path) {
var data = []
path.replace(segment, function(_, command, args){
var type = command.toLowerCase()
args = parseValues(args)
// overloaded moveTo
if (type == 'm' && args.length > 2) {
data.push([command].concat(args.splice(0, 2)))
type = 'l'
command = command == 'm' ? 'l' : 'L'
}
while (true) {
if (args.length == length[type]) {
args.unshift(command)
return data.push(args)
}
if (args.length < length[type]) throw new Error('malformed path data')
data.push([command].concat(args.splice(0, length[type])))
}
})
return data
}
var number = /-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig
function parseValues(args) {
var numbers = args.match(number)
return numbers ? numbers.map(Number) : []
}
|
jkroso/parse-svg-path
|
index.js
|
JavaScript
|
mit
| 1,204
|
<!doctype>
<html>
<head>
<title>CSS GRID</title>
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet">
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
#particles-js {
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: hsl(220, 50%, 30%);
}
body {
display: flex;
font-family: 'Montserrat', sans-serif;
height: 100%;
}
.banner {
margin: auto;
position: relative;
background: hsl(220, 40%, 15%);
color: hsl(220, 50%, 80%);
text-align: center;
width: 85vw;
padding-top: 3vw;
padding-bottom: 7vw;
transform: scale(0.7);
}
h1 {
font-weight: bold;
font-size: 15vw;
}
h2 {
font-weight: 400;
font-size: 2.2vw;
margin-top: -1vw;
}
</style>
</head>
<body>
<div id="particles-js"></div>
<div class="banner">
<h1>CSS GRID</h1>
<h2>A tale of Hypnotoad and ALL GLORY TO THE NEW CSS LAYOUT</h2>
</div>
<script src="particles.js"></script>
<script src="code.js"></script>
<!-- http://vincentgarreau.com/particles.js/ -->
</body>
</html>
|
filR/course-advanced-web-dev-2017
|
02 - Particles Library/solution/index.html
|
HTML
|
mit
| 1,522
|
/*
* getdents64.c
* by WN @ Aug. 03, 2010
*/
#include "syscall_handler.h"
#include <common/debug.h>
#ifndef PRE_LIBRARY
DEF_HANDLER(getdents64)
{
TRACE(LOG_SYSCALL, "getdents64\n");
int r = regs->eax;
if (r > 0)
BUFFER((void*)(regs->ecx), r);
return 0;
}
#endif
// vim:ts=4:sw=4
|
pi3orama/Snitchaser
|
src/arch/x86/interp/syscalls/getdents64.c
|
C
|
mit
| 293
|
using System;
using System.Reflection;
using System.Runtime.InteropServices;
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
[assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(true)]
[assembly: AssemblyTitleAttribute("Apache NMS Class Library")]
[assembly: AssemblyDescriptionAttribute("Apache NMS (.Net Messaging Library): An abstract interface to Message Oriented Mi" +
"ddleware (MOM) providers")]
[assembly: AssemblyConfigurationAttribute("SNAPSHOT")]
[assembly: AssemblyCompanyAttribute("http://activemq.apache.org/nms")]
[assembly: AssemblyProductAttribute("Apache NMS Class Library")]
[assembly: AssemblyCopyrightAttribute("Copyright (C) 2005-2016 Apache Software Foundation")]
[assembly: AssemblyTrademarkAttribute("")]
[assembly: AssemblyCultureAttribute("")]
[assembly: AssemblyVersionAttribute("1.8.0.4316")]
[assembly: AssemblyInformationalVersionAttribute("1.8.0")]
|
kainazzzo/FRBInput
|
Apache.NMS/src/main/csharp/CommonAssemblyInfo.cs
|
C#
|
mit
| 1,255
|
/*
* 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.
*/
using System;
using Apache.NMS.Util;
using NUnit.Framework;
namespace Apache.NMS.Test
{
// For ease of cross-platform exchange of information, you might generate objects from
// an XSD file using XSDObjectGen. However, C# has built-in support for serializing.
// All of the XML attributes that are commented out are optional, but give you fine-grained
// control over the serialized format if you need it.
// [Serializable]
public enum CheckType
{
// [XmlEnum(Name = "message")]
message,
// [XmlEnum(Name = "command")]
command,
// [XmlEnum(Name = "response")]
response
}
// [XmlRoot(ElementName = "NMSTestXmlType1", IsNullable = false), Serializable]
public class NMSTestXmlType1
{
// [XmlElement(ElementName = "crcCheck", IsNullable = false, DataType = "int")]
public int crcCheck;
// [XmlElement(Type = typeof(CheckType), ElementName = "checkType", IsNullable = false)]
public CheckType checkType;
public NMSTestXmlType1()
{
crcCheck = 0;
checkType = CheckType.message;
}
}
// [XmlRoot(ElementName = "NMSTestXmlType2", IsNullable = false), Serializable]
public class NMSTestXmlType2
{
// [XmlElement(ElementName = "stringCheck", IsNullable = false, DataType = "string")]
public string stringCheck;
public NMSTestXmlType2()
{
stringCheck = String.Empty;
}
}
[TestFixture]
public class XmlMessageTest : NMSTestSupport
{
#if NET_3_5 || MONO
[Test]
public void SendReceiveXmlMessage_Net35()
{
using(IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
{
IDestination destination = CreateDestination(session, DestinationType.Queue);
using(IMessageConsumer consumer = session.CreateConsumer(destination))
using(IMessageProducer producer = session.CreateProducer(destination))
{
NMSTestXmlType1 srcIntObject = new NMSTestXmlType1();
srcIntObject.crcCheck = 0xbadf00d;
srcIntObject.checkType = CheckType.command;
producer.Send(srcIntObject);
NMSTestXmlType2 srcStringObject = new NMSTestXmlType2();
srcStringObject.stringCheck = "BadFood";
producer.Send(srcStringObject);
// Demonstrate the ability to generically handle multiple object types
// sent to the same consumer. If only one object type is ever sent to
// the destination, then a simple inline cast is all that is necessary
// when calling the NMSConvert.FromXmlMessage() function.
for(int index = 0; index < 2; index++)
{
object receivedObject = consumer.Receive(receiveTimeout).ToObject();
Assert.IsNotNull(receivedObject, "Failed to retrieve XML message object.");
if(receivedObject is NMSTestXmlType1)
{
NMSTestXmlType1 destObject = (NMSTestXmlType1) receivedObject;
Assert.AreEqual(srcIntObject.crcCheck, destObject.crcCheck, "CRC integer mis-match.");
Assert.AreEqual(srcIntObject.checkType, destObject.checkType, "Check type mis-match.");
}
else if(receivedObject is NMSTestXmlType2)
{
NMSTestXmlType2 destObject = (NMSTestXmlType2) receivedObject;
Assert.AreEqual(srcStringObject.stringCheck, destObject.stringCheck, "CRC string mis-match.");
}
else
{
Assert.Fail("Invalid object type.");
}
}
}
}
}
}
#else
// Test the obsolete API versions until they are completely removed.
[Test]
public void SendReceiveXmlMessage()
{
using(IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
{
IDestination destination = CreateDestination(session, DestinationType.Queue);
using(IMessageConsumer consumer = session.CreateConsumer(destination))
using(IMessageProducer producer = session.CreateProducer(destination))
{
NMSTestXmlType1 srcIntObject = new NMSTestXmlType1();
srcIntObject.crcCheck = 0xbadf00d;
srcIntObject.checkType = CheckType.command;
producer.Send(NMSConvert.ToXmlMessage(session, srcIntObject));
NMSTestXmlType2 srcStringObject = new NMSTestXmlType2();
srcStringObject.stringCheck = "BadFood";
producer.Send(NMSConvert.ToXmlMessage(session, srcStringObject));
// Demonstrate the ability to generically handle multiple object types
// sent to the same consumer. If only one object type is ever sent to
// the destination, then a simple inline cast is all that is necessary
// when calling the NMSConvert.FromXmlMessage() function.
for(int index = 0; index < 2; index++)
{
object receivedObject = NMSConvert.FromXmlMessage(consumer.Receive(receiveTimeout));
Assert.IsNotNull(receivedObject, "Failed to retrieve XML message object.");
if(receivedObject is NMSTestXmlType1)
{
NMSTestXmlType1 destObject = (NMSTestXmlType1) receivedObject;
Assert.AreEqual(srcIntObject.crcCheck, destObject.crcCheck, "CRC integer mis-match.");
Assert.AreEqual(srcIntObject.checkType, destObject.checkType, "Check type mis-match.");
}
else if(receivedObject is NMSTestXmlType2)
{
NMSTestXmlType2 destObject = (NMSTestXmlType2) receivedObject;
Assert.AreEqual(srcStringObject.stringCheck, destObject.stringCheck, "CRC string mis-match.");
}
else
{
Assert.Fail("Invalid object type.");
}
}
}
}
}
}
#endif
}
}
|
kainazzzo/FRBInput
|
Apache.NMS/src/test/csharp/XmlMessageTest.cs
|
C#
|
mit
| 6,413
|
---
layout: post
microblog: true
audio:
photo:
date: 2012-02-29 12:01:06 -0600
guid: http://craigmcclellan.micro.blog/2012/02/29/t174917121690701824.html
---
New Avengers Trailer! [t.co/Zwv44xG1](http://t.co/Zwv44xG1)
|
craigwmcclellan/craigwmcclellan.github.io
|
_posts/2012-02-29-t174917121690701824.md
|
Markdown
|
mit
| 220
|
import PluginManager from 'tinymce/core/api/PluginManager';
import * as Commands from './api/Commands';
import * as Options from './api/Options';
import * as FilterContent from './core/FilterContent';
import * as ResolveName from './core/ResolveName';
import * as Buttons from './ui/Buttons';
export default (): void => {
PluginManager.add('pagebreak', (editor) => {
Options.register(editor);
Commands.register(editor);
Buttons.register(editor);
FilterContent.setup(editor);
ResolveName.setup(editor);
});
};
|
tinymce/tinymce
|
modules/tinymce/src/plugins/pagebreak/main/ts/Plugin.ts
|
TypeScript
|
mit
| 535
|
import { inject, TestBed } from '@angular/core/testing';
import { E2EImportsModule } from '../../../e2e-imports.module';
import { WebsocketService } from './websocket.service';
describe('WebsocketService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [E2EImportsModule],
providers: [WebsocketService]
});
});
it('should be created', inject([WebsocketService], (service: WebsocketService) => {
expect(service).toBeTruthy();
}));
});
|
jwinzer/OpenSlides
|
client/src/app/core/core-services/websocket.service.spec.ts
|
TypeScript
|
mit
| 523
|
#define COMPONENT amf_interact
#define PREFIX e12
#include "script_macros.hpp"
|
Echo12/amf_a2
|
e12_amf_interact/script_component.hpp
|
C++
|
mit
| 84
|
Array.prototype.removePlayer = function (player) {
var index = this.findIndex(function (e) {
return e.client.steamId === player.client.steamId;
});
if (index >= 0) this.splice(index, 1);
return this;
}
'use strict';
const fs = require('fs');
const path = require('path');
module.exports = class Utility {
static rreaddir(dir, done, filesOnly) {
filesOnly = filesOnly || false;
let pending = 0;
let files = [];
fs.readdir(dir, (err, list) => {
if (err) {
return done(err, files);
}
pending = list.length;
list.forEach(f => {
fs.stat(path.join(dir, f), (err, stat) => {
if (err) {
console.warn('skipping file because we couldnt stat it in rreaddir: ' + err);
if (!pending--) {
return done(undefined, files);
}
return;
}
if (stat.isDirectory()) {
if (!filesOnly) {
files.push(f);
}
Utility.rreaddir(f, (err, rlist) => {
rlist.forEach(rf => files.push(rf));
pending--;
if (!pending) {
return done(undefined, files);
}
}, filesOnly);
} else {
files.push(f);
pending--;
if (!pending) {
return done(undefined, files);
}
}
});
});
});
}
static hexToRGB(hex) {
var bigint = parseInt(hex, 16);
var r = (bigint >> 16) & 255;
var g = (bigint >> 8) & 255;
var b = bigint & 255;
return new RGB(r, g, b);
}
static randomColor() {
return require('./utils/randomColor.js')();
}
static RGBToHex(rgb) {
return '#' + ((1 << 24) + (rgb.r << 16) + (rgb.g << 8) + rgb.b).toString(16).slice(1);
}
static random(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
static SecondsToMs(n) {
return 1000 * n;
}
static MinToMs(n) {
return this.SecondsToMs(60) * n;
}
/**
* Returns the player from his id or (part of his) Name
*
* @param {string/number} idOrName Networkid or name of the player (or some digits of the name)
* @param {boolean=} [allowDuplicates=false] False: If multiple players have the same Name only the first one found is returned.
* True: Returns an array with all duplicate players with the name
* @param {boolean=} [caseSensitive=false] True if case sensitive, false if not
* @return {Player} An array with the players found with the id or the name,
* only contains the first one found if allowDuplicates was false, empty array if no player was found
*/
static getPlayer(idOrName, opt_allowDuplicates, opt_caseSensitive) {
let allowDuplicates = opt_allowDuplicates || false;
let caseSensitive = opt_caseSensitive || false;
let id = parseInt(idOrName);
let fnCheck;
if (typeof idOrName === 'undefined') {
return [];
}
if (isNaN(id)) {
if (caseSensitive === false) {
idOrName = idOrName.toLowerCase();
}
// define fnCheck to check the players name
fnCheck = target => {
let targetName;
if (caseSensitive === false) {
//ignore capital letters
targetName = target.escapedNametagName.toLowerCase();
} else {
// do not ignore capital letters
targetName = target.escapedNametagName;
}
if (targetName.includes(idOrName)) {
return true;
}
return false;
};
} else {
fnCheck = target => target.client.networkId === id;
}
let playerArray = [];
for (let i = 0; i < jcmp.players.length; i++) {
const tempPlayer = jcmp.players[i];
if (fnCheck(tempPlayer)) {
playerArray.push(tempPlayer);
if (allowDuplicates === false) {
// exit the loop, because we just return the first player found
break;
}
}
}
return playerArray;
}
/**
* Loads all files from a directory recursively.
*
* @param {string} path - path to the directory
*/
static loadFilesFromDirectory(path) {
Utility.rreaddir(path, (err, list) => {
if (err) {
console.log(err);
return;
}
list.forEach(f => {
require(`${path}/${f}`);
});
console.info(`${list.length} files loaded from '${path}'.`);
}, true);
}
/**
* Checks if the given player is an admin on the server.
*
* @param {Player} player - the player to check
*/
static randomSpawn(baseVec, radius) {
const half = radius / 2;
var posx = baseVec.x + battleroyale.utils.random(-half, half);
var posy = baseVec.y;
var posz = baseVec.z + battleroyale.utils.random(-half, half);
return new Vector3f(posx, posy, posz);
}
/*static randomSpawn(baseVec, radius) {
const half = radius / 2;
return new Vector3f(baseVec.x + battleroyale.utils.random(-half, half), baseVec.y, baseVec.z + battleroyale.utils.random(-half, half));
}*/
static broadcastToLobby(msg) {
for (let player of battleroyale.game.players.onlobby) {
battleroyale.chat.send(player, msg);
}
}
static inRangeOfPoint(ppos, bpos, radius) {
return (Math.pow((ppos.x - bpos.x), 2) +
Math.pow((ppos.y - bpos.y), 2) +
Math.pow((ppos.z - bpos.z), 2) < Math.pow(radius, 2));
}
static findBySteamId(id) {
var index = jcmp.players.map(function (player) {
return player.client.steamId;
}).indexOf(id);
return jcmp.players[index];
}
/*static deleteFromArray(array, value) {
index = array.indexOf(value);
array.splice(index, 1);
}*/
static IsPointInCircle(v1, v2, radius) {
//console.log(battleroyale.utils.GetDistanceBetweenPointsXY(v1, v2));
/*if (battleroyale.utils.GetDistanceBetweenPointsXZ(v1, v2) <= radius) return true;
return false;*/
var comparation = (battleroyale.utils.GetDistanceBetweenPointsXZ(v1,v2) <= radius);
return comparation;
}
static IsPointInCircleRender(v1, v2, radius) {
var comparation = (battleroyale.utils.GetDistanceBetweenPointsXZ(v1,v2) <= radius * 0.95/2);
return comparation;
}
static GetDistanceBetweenPoints(v1, v2) {
let dx = v1.x - v2.x;
let dy = v1.y - v2.y;
let dz = v1.z - v2.z;
return Math.sqrt(dx * dx + dy * dy + dz * dz);
}
static GetDistanceBetweenPointsXZ(v1,v2) {
let v13f = new Vector3f(v1.x, 0.0, v1.z);
let v14f = new Vector3f(v2.x, 0.0, v2.z);
return battleroyale.utils.GetDistanceBetweenPoints(v13f, v14f);
}
static isAdmin(player) {
/*
if(battleroyale.config.admins.indexOf(player.client.steamId) >= 0) {
return true;
}
return false;*/
return jcmp.events.Call('adminsys_isAdmin', player)[0];
}
static showLobbyUI(player) {
if(!player.ingame) {
if(battleroyale.game.toStart) {
jcmp.events.CallRemote('battleroyale_txt_updateTime', player, battleroyale.game.timeToStart)
jcmp.events.CallRemote('battleroyale_txt_timerStart', player, true);
} else {
jcmp.events.CallRemote('battleroyale_txt_leftplayers_toggle', player, true);
}
}
}
static removeAllWeapons(player) {
for(var i = 0; i < player.weapons.length; i++) {
player.RemoveWeapon(i);
}
}
};
|
maltoc76/BattleRoyale
|
Battleroyale_base/gm/utility.js
|
JavaScript
|
mit
| 7,365
|
/*
Copyright (c) 2010 by Genstein
This file is (or was originally) part of Trizbort, the Interactive Fiction Mapper.
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.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Threading;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using Trizbort.Export;
namespace Trizbort
{
internal partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
m_caption = Text;
Application.Idle += OnIdle;
m_lastUpdateUITime = DateTime.MinValue;
m_automapBar.StopClick += delegate(object sender, EventArgs e) { m_canvas.StopAutomapping(); };
}
private void MainForm_Load(object sender, EventArgs e)
{
m_canvas.MinimapVisible = Settings.ShowMiniMap;
var args = Environment.GetCommandLineArgs();
if (args.Length > 1 && File.Exists(args[1]))
{
try
{
BeginInvoke((MethodInvoker)delegate
{
OpenProject(args[1]);
});
}
catch (Exception)
{
}
}
NewVersionDialog.CheckForUpdatesAsync(this, false);
}
public Canvas Canvas
{
get { return m_canvas; }
}
private void FileNewMenuItem_Click(object sender, EventArgs e)
{
if (!CheckLoseProject())
return;
Project.Current = new Project();
Settings.Reset();
}
protected override void OnClosing(CancelEventArgs e)
{
if (!CheckLoseProject())
{
e.Cancel = true;
return;
}
Settings.SaveApplicationSettings();
m_canvas.StopAutomapping();
base.OnClosing(e);
}
private bool CheckLoseProject()
{
if (Project.Current.IsDirty)
{
// see if the user would like to save
var result = MessageBox.Show(this, string.Format("Do you want to save changes to {0}?", Project.Current.Name), Text, MessageBoxButtons.YesNoCancel);
switch (result)
{
case DialogResult.Yes:
// user would like to save
if (!SaveProject())
{
// didn't actually save; treat as cancel
return false;
}
// user saved; carry on
return true;
case DialogResult.No:
// user wouldn't like to save; carry on
return true;
default:
// user cancelled; cancel
return false;
}
}
// project doesn't need saving; carry on
return true;
}
private bool OpenProject()
{
if (!CheckLoseProject())
return false;
using (var dialog = new OpenFileDialog())
{
dialog.InitialDirectory = PathHelper.SafeGetDirectoryName(Settings.LastProjectFileName);
dialog.Filter = string.Format("{0}|All Files|*.*||", Project.FilterString);
if (dialog.ShowDialog() == DialogResult.OK)
{
Settings.LastProjectFileName = dialog.FileName;
return OpenProject(dialog.FileName);
}
}
return false;
}
private bool OpenProject(string fileName)
{
var project = new Project();
project.FileName = fileName;
if (project.Load())
{
Project.Current = project;
//AboutMap();
Settings.RecentProjects.Add(fileName);
return true;
}
return false;
}
private void AboutMap()
{
var project = Project.Current;
if (!string.IsNullOrEmpty(project.Title) || !string.IsNullOrEmpty(project.Author) || !string.IsNullOrEmpty(project.Description))
{
var builder = new StringBuilder();
if (!string.IsNullOrEmpty(project.Title))
{
builder.AppendLine(project.Title);
}
if (!string.IsNullOrEmpty(project.Author))
{
if (builder.Length > 0)
{
builder.AppendLine();
}
builder.AppendLine(string.Format("by {0}", project.Author));
}
if (!string.IsNullOrEmpty(project.Description))
{
if (builder.Length > 0)
{
builder.AppendLine();
}
builder.AppendLine(project.Description);
}
MessageBox.Show(builder.ToString(), Application.ProductName, MessageBoxButtons.OK);
}
}
private bool SaveProject()
{
if (!Project.Current.HasFileName)
{
return SaveAsProject();
}
if (Project.Current.Save())
{
Settings.RecentProjects.Add(Project.Current.FileName);
return true;
}
return false;
}
private bool SaveAsProject()
{
using (var dialog = new SaveFileDialog())
{
if (!string.IsNullOrEmpty(Project.Current.FileName))
{
dialog.FileName = Project.Current.FileName;
}
else
{
dialog.InitialDirectory = PathHelper.SafeGetDirectoryName(Settings.LastProjectFileName);
}
dialog.Filter = string.Format("{0}|All Files|*.*||", Project.FilterString);
if (dialog.ShowDialog() == DialogResult.OK)
{
Settings.LastProjectFileName = dialog.FileName;
Project.Current.FileName = dialog.FileName;
if (Project.Current.Save())
{
Settings.RecentProjects.Add(Project.Current.FileName);
return true;
}
}
}
return false;
}
private void FileOpenMenuItem_Click(object sender, EventArgs e)
{
OpenProject();
}
private void FileSaveMenuItem_Click(object sender, EventArgs e)
{
SaveProject();
}
private void FileSaveAsMenuItem_Click(object sender, EventArgs e)
{
SaveAsProject();
}
private void FileExportPDFMenuItem_Click(object sender, EventArgs e)
{
using (var dialog = new SaveFileDialog())
{
dialog.Filter = "PDF Files|*.pdf|All Files|*.*||";
dialog.Title = "Export PDF";
dialog.InitialDirectory = PathHelper.SafeGetDirectoryName(Settings.LastExportImageFileName);
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
Settings.LastExportImageFileName = dialog.FileName;
var doc = new PdfDocument();
doc.Info.Title = Project.Current.Title;
doc.Info.Author = Project.Current.Author;
doc.Info.Creator = Application.ProductName;
doc.Info.CreationDate = DateTime.Now;
doc.Info.Subject = Project.Current.Description;
var page = doc.AddPage();
var size = m_canvas.ComputeCanvasBounds(true).Size;
page.Width = new XUnit(size.X);
page.Height = new XUnit(size.Y);
using (var graphics = XGraphics.FromPdfPage(page))
{
m_canvas.Draw(graphics, true, size.X, size.Y);
}
doc.Save(dialog.FileName);
}
catch (Exception ex)
{
MessageBox.Show(Program.MainForm, string.Format("There was a problem exporting the map:\n\n{0}", ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void FileExportImageMenuItem_Click(object sender, EventArgs e)
{
using (var dialog = new SaveFileDialog())
{
dialog.Filter = "PNG Images|*.png|JPEG Images|*.jpg|BMP Images|*.bmp|Enhanced Metafiles (EMF)|*.emf|All Files|*.*||";
dialog.Title = "Export Image";
dialog.InitialDirectory = PathHelper.SafeGetDirectoryName(Settings.LastExportImageFileName);
if (dialog.ShowDialog() == DialogResult.OK)
{
Settings.LastExportImageFileName = dialog.InitialDirectory;
var format = ImageFormat.Png;
var ext = Path.GetExtension(dialog.FileName);
if (StringComparer.InvariantCultureIgnoreCase.Compare(ext, ".jpg") == 0
|| StringComparer.InvariantCultureIgnoreCase.Compare(ext, ".jpeg") == 0)
{
format = ImageFormat.Jpeg;
}
else if (StringComparer.InvariantCultureIgnoreCase.Compare(ext, ".bmp") == 0)
{
format = ImageFormat.Bmp;
}
else if (StringComparer.InvariantCultureIgnoreCase.Compare(ext, ".emf") == 0)
{
format = ImageFormat.Emf;
}
var size = m_canvas.ComputeCanvasBounds(true).Size * m_canvas.ZoomFactor;
size.X = Numeric.Clamp(size.X, 16, 8192);
size.Y = Numeric.Clamp(size.Y, 16, 8192);
try
{
if (format == ImageFormat.Emf)
{
// export as a metafile
using (var nativeGraphics = Graphics.FromHwnd(m_canvas.Handle))
{
using (var stream = new MemoryStream())
{
try
{
var dc = nativeGraphics.GetHdc();
using (var metafile = new Metafile(stream, dc))
{
using (var imageGraphics = Graphics.FromImage(metafile))
{
using (var graphics = XGraphics.FromGraphics(imageGraphics, new XSize(size.X, size.Y)))
{
m_canvas.Draw(graphics, true, size.X, size.Y);
}
}
var handle = metafile.GetHenhmetafile();
var copy = CopyEnhMetaFile(handle, dialog.FileName);
DeleteEnhMetaFile(copy);
}
}
finally
{
nativeGraphics.ReleaseHdc();
}
}
}
}
else
{
// export as an image
using (var bitmap = new Bitmap((int)Math.Ceiling(size.X), (int)Math.Ceiling(size.Y)))
{
using (var imageGraphics = Graphics.FromImage(bitmap))
{
using (var graphics = XGraphics.FromGraphics(imageGraphics, new XSize(size.X, size.Y)))
{
m_canvas.Draw(graphics, true, size.X, size.Y);
}
}
bitmap.Save(dialog.FileName, format);
}
}
}
catch (Exception ex)
{
MessageBox.Show(Program.MainForm, string.Format("There was a problem exporting the map:\n\n{0}", ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void FileExportInform7MenuItem_Click(object sender, EventArgs e)
{
var fileName = Settings.LastExportInform7FileName;
if (ExportCode<Inform7Exporter>(ref fileName))
{
Settings.LastExportInform7FileName = fileName;
}
}
private void FileExportInform6MenuItem_Click(object sender, EventArgs e)
{
var fileName = Settings.LastExportInform6FileName;
if (ExportCode<Inform6Exporter>(ref fileName))
{
Settings.LastExportInform6FileName = fileName;
}
}
private void FileExportTadsMenuItem_Click(object sender, EventArgs e)
{
var fileName = Settings.LastExportTadsFileName;
if (ExportCode<TadsExporter>(ref fileName))
{
Settings.LastExportTadsFileName = fileName;
}
}
private bool ExportCode<T>(ref string lastExportFileName) where T : CodeExporter, new()
{
using (var exporter = new T())
{
using (var dialog = new SaveFileDialog())
{
// compose filter string for file dialog
var filterString = string.Empty;
var filters = exporter.FileDialogFilters;
foreach (var filter in filters)
{
if (!string.IsNullOrEmpty(filterString))
{
filterString += "|";
}
filterString += string.Format("{0}|*{1}", filter.Key, filter.Value);
}
if (!string.IsNullOrEmpty(filterString))
{
filterString += "|";
}
filterString += "All Files|*.*||";
dialog.Filter = filterString;
// set default filter by extension
var extension = PathHelper.SafeGetExtension(lastExportFileName);
for (var filterIndex = 0; filterIndex < filters.Count; ++filterIndex)
{
if (StringComparer.InvariantCultureIgnoreCase.Compare(extension, filters[filterIndex].Value) == 0)
{
dialog.FilterIndex = filterIndex + 1; // 1 based index
break;
}
}
// show dialog
dialog.Title = exporter.FileDialogTitle;
dialog.InitialDirectory = PathHelper.SafeGetDirectoryName(lastExportFileName);
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
// export source code
exporter.Export(dialog.FileName);
lastExportFileName = dialog.FileName;
return true;
}
catch (Exception ex)
{
MessageBox.Show(Program.MainForm, string.Format("There was a problem exporting the map:\n\n{0}", ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
return false;
}
private void FileExitMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void EditAddRoomMenuItem_Click(object sender, EventArgs e)
{
m_canvas.AddRoom(false);
}
private void EditDeleteMenuItem_Click(object sender, EventArgs e)
{
m_canvas.DeleteSelection();
}
private void EditPropertiesMenuItem_Click(object sender, EventArgs e)
{
if (m_canvas.HasSingleSelectedElement && m_canvas.SelectedElement.HasDialog)
{
m_canvas.SelectedElement.ShowDialog();
}
}
private void PlainLinesMenuItem_Click(object sender, EventArgs e)
{
m_canvas.ApplyNewPlainConnectionSettings();
}
private void ToggleDottedLines_Click(object sender, EventArgs e)
{
switch (m_canvas.NewConnectionStyle)
{
case ConnectionStyle.Solid:
m_canvas.NewConnectionStyle = ConnectionStyle.Dashed;
break;
case ConnectionStyle.Dashed:
m_canvas.NewConnectionStyle = ConnectionStyle.Solid;
break;
}
m_canvas.ApplyConnectionStyle(m_canvas.NewConnectionStyle);
}
private void ToggleDirectionalLines_Click(object sender, EventArgs e)
{
switch (m_canvas.NewConnectionFlow)
{
case ConnectionFlow.TwoWay:
m_canvas.NewConnectionFlow = ConnectionFlow.OneWay;
break;
case ConnectionFlow.OneWay:
m_canvas.NewConnectionFlow = ConnectionFlow.TwoWay;
break;
}
m_canvas.ApplyConnectionFlow(m_canvas.NewConnectionFlow);
}
private void UpLinesMenuItem_Click(object sender, EventArgs e)
{
m_canvas.NewConnectionLabel = ConnectionLabel.Up;
m_canvas.ApplyConnectionLabel(m_canvas.NewConnectionLabel);
}
private void DownLinesMenuItem_Click(object sender, EventArgs e)
{
m_canvas.NewConnectionLabel = ConnectionLabel.Down;
m_canvas.ApplyConnectionLabel(m_canvas.NewConnectionLabel);
}
private void InLinesMenuItem_Click(object sender, EventArgs e)
{
m_canvas.NewConnectionLabel = ConnectionLabel.In;
m_canvas.ApplyConnectionLabel(m_canvas.NewConnectionLabel);
}
private void OutLinesMenuItem_Click(object sender, EventArgs e)
{
m_canvas.NewConnectionLabel = ConnectionLabel.Out;
m_canvas.ApplyConnectionLabel(m_canvas.NewConnectionLabel);
}
private void ReverseLineMenuItem_Click(object sender, EventArgs e)
{
m_canvas.ReverseLineDirection();
}
private void OnIdle(object sender, EventArgs e)
{
var now = DateTime.Now;
if (now - m_lastUpdateUITime > IdleProcessingEveryNSeconds)
{
m_lastUpdateUITime = now;
UpdateCommandUI();
}
}
private void UpdateCommandUI()
{
// caption
Text = string.Format("{0}{1} - {2}", Project.Current.Name, Project.Current.IsDirty ? "*" : string.Empty, m_caption);
// line drawing options
m_toggleDottedLinesButton.Checked = m_canvas.NewConnectionStyle == ConnectionStyle.Dashed;
m_toggleDottedLinesMenuItem.Checked = m_toggleDottedLinesButton.Checked;
m_toggleDirectionalLinesButton.Checked = m_canvas.NewConnectionFlow == ConnectionFlow.OneWay;
m_toggleDirectionalLinesMenuItem.Checked = m_toggleDirectionalLinesButton.Checked;
m_plainLinesMenuItem.Checked = !m_toggleDirectionalLinesMenuItem.Checked && !m_toggleDottedLinesMenuItem.Checked && m_canvas.NewConnectionLabel == ConnectionLabel.None;
m_upLinesMenuItem.Checked = m_canvas.NewConnectionLabel == ConnectionLabel.Up;
m_downLinesMenuItem.Checked = m_canvas.NewConnectionLabel == ConnectionLabel.Down;
m_inLinesMenuItem.Checked = m_canvas.NewConnectionLabel == ConnectionLabel.In;
m_outLinesMenuItem.Checked = m_canvas.NewConnectionLabel == ConnectionLabel.Out;
// selection-specific commands
bool hasSelectedElement = m_canvas.SelectedElement != null;
m_editDeleteMenuItem.Enabled = hasSelectedElement;
m_editPropertiesMenuItem.Enabled = m_canvas.HasSingleSelectedElement;
m_editIsDarkMenuItem.Enabled = hasSelectedElement;
m_editSelectNoneMenuItem.Enabled = hasSelectedElement;
m_editSelectAllMenuItem.Enabled = m_canvas.SelectedElementCount < Project.Current.Elements.Count;
m_editCopyMenuItem.Enabled = m_canvas.SelectedElement != null;
m_editCopyColorToolMenuItem.Enabled = m_canvas.HasSingleSelectedElement && (m_canvas.SelectedElement is Room);
m_editPasteMenuItem.Enabled = (!String.IsNullOrEmpty(Clipboard.GetText())) && ((Clipboard.GetText().Replace("\r\n", "|").Split('|')[0] == "Elements") || (Clipboard.GetText().Replace("\r\n", "|").Split('|')[0] == "Colors"));
m_editRenameMenuItem.Enabled = m_canvas.HasSingleSelectedElement && (m_canvas.SelectedElement is Room);
m_editIsDarkMenuItem.Checked = m_canvas.HasSingleSelectedElement && (m_canvas.SelectedElement is Room) && ((Room)m_canvas.SelectedElement).IsDark;
m_reverseLineMenuItem.Enabled = m_canvas.HasSelectedElement<Connection>();
// automapping
m_automapStartMenuItem.Enabled = !m_canvas.IsAutomapping;
m_automapStopMenuItem.Enabled = m_canvas.IsAutomapping;
m_automapBar.Visible = m_canvas.IsAutomapping;
m_automapBar.Status = m_canvas.AutomappingStatus;
// minimap
m_viewMinimapMenuItem.Checked = m_canvas.MinimapVisible;
UpdateToolStripImages();
m_canvas.UpdateScrollBars();
Debug.WriteLine(m_canvas.Focused ? "Focused!" : "NOT FOCUSED");
}
private void FileRecentProject_Click(object sender, EventArgs e)
{
if (!CheckLoseProject())
{
return;
}
var fileName = (string)((ToolStripMenuItem)sender).Tag;
OpenProject(fileName);
}
private void UpdateToolStripImages()
{
foreach (ToolStripItem item in m_toolStrip.Items)
{
if (!(item is ToolStripButton))
continue;
var button = (ToolStripButton)item;
button.BackgroundImage = button.Checked ? Properties.Resources.ToolStripBackground2 : Properties.Resources.ToolStripBackground;
}
}
private void ViewResetMenuItem_Click(object sender, EventArgs e)
{
m_canvas.ResetZoomOrigin();
}
private void ViewZoomInMenuItem_Click(object sender, EventArgs e)
{
m_canvas.ZoomIn();
}
private void ViewZoomOutMenuItem_Click(object sender, EventArgs e)
{
m_canvas.ZoomOut();
}
private void ViewZoomFiftyPercentMenuItem_Click(object sender, EventArgs e)
{
m_canvas.ZoomFactor = 0.5f;
}
private void ViewZoomOneHundredPercentMenuItem_Click(object sender, EventArgs e)
{
m_canvas.ZoomFactor = 1.0f;
}
private void ViewZoomTwoHundredPercentMenuItem_Click(object sender, EventArgs e)
{
m_canvas.ZoomFactor = 2.0f;
}
private void EditRenameMenuItem_Click(object sender, EventArgs e)
{
if (m_canvas.HasSingleSelectedElement && m_canvas.SelectedElement.HasDialog)
{
m_canvas.SelectedElement.ShowDialog();
}
}
private void EditIsDarkMenuItem_Click(object sender, EventArgs e)
{
foreach (var element in m_canvas.SelectedElements)
{
if (element is Room)
{
var room = (Room)element;
room.IsDark = !room.IsDark;
}
}
}
private void ProjectSettingsMenuItem_Click(object sender, EventArgs e)
{
Settings.ShowDialog();
}
private void ProjectResetToDefaultSettingsMenuItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Restore default settings?\n\nThis will revert any changes to settings in this project.", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
Settings.Reset();
}
}
private void HelpAndSupportMenuItem_Click(object sender, EventArgs e)
{
try
{
Process.Start("http://trizbort.genstein.net/?help");
}
catch (Exception)
{
NewVersionDialog.CannotLaunchWebSite();
}
}
private void CheckForUpdatesMenuItem_Click(object sender, EventArgs e)
{
NewVersionDialog.CheckForUpdatesAsync(this, true);
}
private void HelpAboutMenuItem_Click(object sender, EventArgs e)
{
using (var dialog = new AboutDialog())
{
dialog.ShowDialog();
}
}
private void AutomapStartMenuItem_Click(object sender, EventArgs e)
{
using (var dialog = new AutomapDialog())
{
if (dialog.ShowDialog() == DialogResult.OK)
{
m_canvas.StartAutomapping(dialog.Data);
}
}
}
private void AutomapStopMenuItem_Click(object sender, EventArgs e)
{
m_canvas.StopAutomapping();
}
private void ViewMinimapMenuItem_Click(object sender, EventArgs e)
{
m_canvas.MinimapVisible = !m_canvas.MinimapVisible;
Settings.ShowMiniMap = m_canvas.MinimapVisible;
}
private void FileMenu_DropDownOpening(object sender, EventArgs e)
{
// MRU list
var existingItems = new List<ToolStripItem>();
foreach (ToolStripItem existingItem in m_fileRecentMapsMenuItem.DropDownItems)
{
existingItems.Add(existingItem);
}
foreach (var existingItem in existingItems)
{
existingItem.Click -= FileRecentProject_Click;
existingItem.Dispose();
}
if (Settings.RecentProjects.Count == 0)
{
m_fileRecentMapsMenuItem.Enabled = false;
}
else
{
m_fileRecentMapsMenuItem.Enabled = true;
var index = 1;
foreach (var recentProject in Settings.RecentProjects)
{
var menuItem = new ToolStripMenuItem(string.Format("&{0} {1}", index++, recentProject));
menuItem.Tag = recentProject;
menuItem.Click += FileRecentProject_Click;
m_fileRecentMapsMenuItem.DropDownItems.Add(menuItem);
}
}
}
private void EditSelectAllMenuItem_Click(object sender, EventArgs e)
{
m_canvas.SelectAll();
}
private void EditSelectNoneMenuItem_Click(object sender, EventArgs e)
{
m_canvas.SelectedElement = null;
}
private void ViewEntireMapMenuItem_Click(object sender, EventArgs e)
{
m_canvas.ZoomToFit();
}
[DllImport("gdi32.dll")]
private static extern IntPtr CopyEnhMetaFile(IntPtr hemfSrc, string lpszFile);
[DllImport("gdi32.dll")]
private static extern int DeleteEnhMetaFile(IntPtr hemf);
private string m_caption;
private DateTime m_lastUpdateUITime;
private static readonly TimeSpan IdleProcessingEveryNSeconds = TimeSpan.FromSeconds(0.2);
private void m_editCopyMenuItem_Click(object sender, EventArgs e)
{
m_canvas.CopySelectedElements();
}
private void m_editCopyColorToolMenuItem_Click(object sender, EventArgs e)
{
m_canvas.CopySelectedColor();
}
private void m_editPasteMenuItem_Click(object sender, EventArgs e)
{
m_canvas.Paste(false);
}
}
}
|
Tymian/trizbort
|
MainForm.cs
|
C#
|
mit
| 31,910
|
.demo-blog .coffee-pic .mdl-card__media {
background-image: url('../images/coffee.jpg');
}
.demo-blog .about-pic .mdl-card__media {
background-image: url('../images/keyboard.jpg');
}
.demo-blog .avatar-pic .mdl-card__media {
background-image: url('../images/avatar.jpg');
}
.demo-blog .brown-color .mdl-card__media {
background-color: #795548;
}
.demo-blog .red-color .mdl-card__media {
background-color: #F44336;
}
.demo-blog .pink-color .mdl-card__media {
background-color: #E91E63;
}
.demo-blog .purple-color .mdl-card__media {
background-color: #9C27B0;
}
.demo-blog .indigo-color .mdl-card__media {
background-color: #3F51B5;
}
.demo-blog .blue-color .mdl-card__media {
background-color: #2196F3;
}
.demo-blog .teal-color .mdl-card__media {
background-color: #009688;
}
.demo-blog .blue-grey-color .mdl-card__media {
background-color: #607D8B;
}
|
hackerchai/android-blog
|
assets/themes/material-card/css/pic.css
|
CSS
|
mit
| 898
|
<html>
<head>
<title>SIGEDUC</title>
<link rel="stylesheet" href="<?= base_url('assets/css/bootstrap.min.css') ?>"/>
<link rel="stylesheet" href="<?= base_url('assets/css/matrix-login.css') ?>"/>
<link rel="stylesheet" href="<?= base_url('assets/css/login.css') ?>"/>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="col-md-4 col-md-offset-4 thumbnail" id='box-login'>
<div class="col-md-12 padding-zero">
<?php if ($this->session->flashdata('danger')) : ?>
<strong>
<p class="alert alert-danger text-center"><?= $this->session->flashdata('danger') ?></p>
</strong>
<?php endif ?>
</div>
<div class="col-md-12 padding-zero">
<form action="<?= base_url('login/autenticar') ?>" method="POST" >
<div class="form-group">
<div class="input-group">
<span id="ico-usuario" class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
<input type="text" class="form-control" placeholder="Usuário" id="usuario" name="usuario" required>
</div>
</div>
<div class="form-group">
<div class="input-group">
<span id="ico-senha" class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
<input type="password" class="form-control" placeholder="Senha" id="senha" name="senha" required>
</div>
</div>
<button type="submit" class="btn btn-block btn-success col-md-12" id="btn-entrar">Entrar</button>
</form>
</div>
</div>
</body>
<script src="<?= base_url("assets/js/jquery.min.js") ?>"></script>
<script src="<?= base_url("assets/js/bootstrap.min.js") ?>"></script>
<script>
$("#btn-entrar").click(function () {
if ($('#usuario').val() !== "" && $('#senha').val() !== "") {
$(this).addClass('disabled').text("Autenticando...");
}
});
</script>
</html>
|
guilherme00/sigeduc
|
application/views/login.php
|
PHP
|
mit
| 2,431
|
<?php
namespace IfRPGMaker\HistoireBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Scenario
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="IfRPGMaker\HistoireBundle\Entity\ScenarioRepository")
*/
class Scenario
{
/**
* @ORM\Id
* @ORM\ManyToOne(targetEntity="IfRPGMaker\HistoireBundle\Entity\Histoire")
* @ORM\JoinColumn(nullable=false, referencedColumnName="auteur_id")
* @ORM\Column(name="auteur")
*
*/
private $auteur;
/**
* @ORM\Id
* @ORM\ManyToOne(targetEntity="IfRPGMaker\HistoireBundle\Entity\Histoire")
* @ORM\JoinColumn(nullable=false, referencedColumnName="titre")
* @ORM\Column(name="titre")
*/
private $titre_histoire;
/**
* @ORM\Id
* @ORM\ManyToOne(targetEntity="IfRPGMaker\HistoireBundle\Entity\Choix")
* @ORM\JoinColumn(nullable=false)
* @ORM\Column(name="debut")
*
*/
private $debut;
public function __construct($histoire) {
$this->auteur = $histoire->getAuteur();
$this->titre_histoire = $histoire;
}
/**
* Set debut
*
* @param \IfRPGMaker\HistoireBundle\Entity\Choix $debut
* @return Scenario
*/
public function setDebut(\IfRPGMaker\HistoireBundle\Entity\Choix $debut)
{
$this->debut = $debut;
return $this;
}
/**
* Get debut
*
* @return \IfRPGMaker\HistoireBundle\Entity\Choix
*/
public function getDebut()
{
return $this->debut;
}
/**
* Set auteur
*
* @param \IfRPGMaker\UserBundle\Entity\Joueur $auteur
* @return Scenario
*/
public function setAuteur(\IfRPGMaker\UserBundle\Entity\Joueur $auteur)
{
$this->auteur = $auteur;
return $this;
}
/**
* Get auteur
*
* @return \IfRPGMaker\UserBundle\Entity\Joueur
*/
public function getAuteur()
{
return $this->auteur;
}
/**
* Set titre_histoire
*
* @param \IfRPGMaker\HistoireBundle\Entity\Histoire $titreHistoire
* @return Scenario
*/
public function setTitreHistoire(\IfRPGMaker\HistoireBundle\Entity\Histoire $titreHistoire)
{
$this->titre_histoire = $titreHistoire;
return $this;
}
/**
* Get titre_histoire
*
* @return \IfRPGMaker\HistoireBundle\Entity\Histoire
*/
public function getTitreHistoire()
{
return $this->titre_histoire;
}
public function __toString() {
return $this->debut->__toString();
}
public function getArrayIds()
{
return array('auteur' => $this->auteur, 'titre_histoire' => $this->titre_histoire, 'debut' => $this->debut);
}
}
|
itzala/ifrpgmaker_web
|
src/IfRPGMaker/HistoireBundle/Entity/Scenario.php
|
PHP
|
mit
| 2,765
|
pkg_dnf = {
'collectd': {},
'collectd-chrony': {},
'collectd-curl': {},
'collectd-curl_json': {},
'collectd-curl_xml': {},
'collectd-netlink': {},
'rrdtool': {},
}
if node.os == 'fedora' and node.os_version >= (26):
pkg_dnf['collectd-disk'] = {}
svc_systemd = {
'collectd': {
'needs': ['pkg_dnf:collectd'],
},
}
files = {
'/etc/collectd.conf': {
'source': 'collectd.conf',
'mode': '0600',
'content_type': 'mako',
'context': {
'collectd': node.metadata.get('collectd', {}),
},
'needs': ['pkg_dnf:collectd', 'pkg_dnf:rrdtool'],
'triggers': ['svc_systemd:collectd:restart'],
},
'/etc/collectd.d/nut.conf': {
'delete': True,
'needs': ['pkg_dnf:collectd'],
},
}
actions = {}
directories = {
'/etc/collectd.d/plugins': {
'mode': '0755',
'needs': ['pkg_dnf:collectd'],
},
'/etc/collectd.d/types': {
'mode': '0755',
'needs': ['pkg_dnf:collectd'],
},
}
git_deploy = {}
if node.metadata.get('collectd', {}).get('write_rrd', True):
pkg_dnf['collectd-rrdtool'] = {
'triggers': ['svc_systemd:collectd:restart'],
}
if node.metadata.get('collectd', {}).get('client'):
files['/etc/collectd.d/client.conf'] = {
'source': 'client.conf',
'mode': '0600',
'content_type': 'mako',
'context': {
'client': node.metadata.get('collectd', {}).get('client', {}),
},
'needs': ['pkg_dnf:collectd'],
'triggers': ['svc_systemd:collectd:restart'],
}
if node.metadata.get('collectd', {}).get('server'):
files['/etc/collectd.d/server.conf'] = {
'source': 'server.conf',
'mode': '0600',
'content_type': 'mako',
'context': {
'server': node.metadata.get('collectd', {}).get('server', {}),
},
'needs': ['pkg_dnf:collectd'],
'triggers': ['svc_systemd:collectd:restart'],
}
files['/etc/collectd.d/collectd.auth'] = {
'source': 'server_auth/{}.auth'.format(node.name),
'mode': '0600',
'needs': ['pkg_dnf:collectd'],
'triggers': ['svc_systemd:collectd:restart'],
}
if node.has_bundle('firewalld'):
port = node.metadata.get('collectd', {}).get('server', {}).get('port', '25826')
if node.metadata.get('collectd', {}).get('server', {}).get('firewalld_permitted_zone'):
zone = node.metadata.get('collectd', {}).get('server', {}).get('firewalld_permitted_zone')
actions['firewalld_add_collectd_zone_{}'.format(zone)] = {
'command': 'firewall-cmd --permanent --zone={} --add-port={}/udp'.format(zone, port),
'unless': 'firewall-cmd --zone={} --list-ports | grep {}/udp'.format(zone, port),
'cascade_skip': False,
'needs': ['pkg_dnf:firewalld'],
'triggers': ['action:firewalld_reload'],
}
elif node.metadata.get('firewalld', {}).get('default_zone'):
default_zone = node.metadata.get('firewalld', {}).get('default_zone')
actions['firewalld_add_collectd_zone_{}'.format(default_zone)] = {
'command': 'firewall-cmd --permanent --zone={} --add-port={}/udp'.format(default_zone, port),
'unless': 'firewall-cmd --zone={} --list-ports | grep {}/udp'.format(default_zone, port),
'cascade_skip': False,
'needs': ['pkg_dnf:firewalld'],
'triggers': ['action:firewalld_reload'],
}
elif node.metadata.get('firewalld', {}).get('custom_zones', False):
for interface in node.metadata['interfaces']:
custom_zone = node.metadata.get('interfaces', {}).get(interface).get('firewalld_zone')
actions['firewalld_add_collectd_zone_{}'.format(custom_zone)] = {
'command': 'firewall-cmd --permanent --zone={} --add-port={}/udp'.format(custom_zone, port),
'unless': 'firewall-cmd --zone={} --list-ports | grep {}/udp'.format(custom_zone, port),
'cascade_skip': False,
'needs': ['pkg_dnf:firewalld'],
'triggers': ['action:firewalld_reload'],
}
else:
actions['firewalld_add_https'] = {
'command': 'firewall-cmd --permanent --add-port={}/udp'.format(port),
'unless': 'firewall-cmd --list-ports | grep {}/udp'.format(port),
'cascade_skip': False,
'needs': ['pkg_dnf:firewalld'],
'triggers': ['action:firewalld_reload'],
}
if node.metadata.get('collectd', {}).get('cgp', {}):
cgp_install_path = node.metadata.get('collectd', {}).get('cgp', {}).get('install_path')
directories['{}'.format(cgp_install_path)] = {
'mode': '0755',
}
git_deploy['{}'.format(cgp_install_path)] = {
'needs': [
'directory:{}'.format(cgp_install_path)
],
'repo': 'https://github.com/pommi/CGP.git',
'rev': 'master',
}
files['{}/conf/config.local.php'.format(cgp_install_path)] = {
'source': 'cgp_config',
'mode': '0644',
'needs': ['git_deploy:{}'.format(cgp_install_path)],
}
if node.has_bundle('monit'):
files['/etc/monit.d/collectd'] = {
'source': 'monit',
'mode': '0600',
'content_type': 'mako',
'context': {
'server': node.metadata.get('collectd', {}).get('server', {}),
},
'triggers': ['svc_systemd:monit:restart'],
}
|
rullmann/bundlewrap-collectd
|
items.py
|
Python
|
mit
| 5,646
|
#pragma once
#include "mesh/Mesh.h"
#include <string>
#include <fstream>
#include <map>
NS_BEGIN_NAMESPACE
enum VTKOutputOptions
{
VOO_ElementDeterminant = 0x1,
VOO_ElementMatrix = 0x2,
VOO_ElementGradient = 0x4,
VOO_VertexBoundaryLabel = 0x8,
VOO_VertexImplicitLabel = 0x10,
VOO_IsQuadratic = 0x80
};
template<typename T, Dimension K>
class VTKExporter
{
public:
template<typename V>
static void write(const std::string& path,
const Mesh<T,K>& mesh,
const std::map<std::string, V*>& pointData,
const std::map<std::string, V*>& cellData,
int outputOptions = 0);
};
NS_END_NAMESPACE
#define _NS_VTKEXPORTER_INL
# include "VTKExporter.inl"
#undef _NS_VTKEXPORTER_INL
|
PearCoding/NumericSim
|
src/lib/export/VTKExporter.h
|
C
|
mit
| 689
|
#Change Log
## v0.1.0-alpha.1
- Added/Updated command `php artisan mecenas:create {package}`
- Enhancement/Patch of tests
## v0.1.0-alpha
- Added command `php artisan mecenas:create {package}`
- Initial testing release
|
cristiancmello/laravel-mecenas
|
CHANGELOG.md
|
Markdown
|
mit
| 222
|
/* global module, require */
module.exports = function (grunt) {
'use strict';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
banner: '/*!\n * <%= pkg.name %> - <%= pkg.description %>\n' +
' * Copyright (c) 2010 <%= pkg.author.name %> <<%= pkg.author.email %>>\n' +
' * Licensed <%= pkg.license %>-style.\n */\n',
concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
src: [
'src/js/Moovie.js',
'src/js/Moovie.registerPlugin.js',
'src/js/Moovie.Support.js',
'src/js/Moovie.Util.js',
'src/js/Moovie.toHTMLTrackElement.js',
'src/js/Moovie.Ui.js',
'src/js/Moovie.Ui.Panel.js',
'src/js/Moovie.MediaEvents.js',
'src/js/Moovie.Playlist.js'
],
dest: 'dist/<%= pkg.name %>.js'
}
},
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
src: '<%= concat.dist.dest %>',
dest: 'dist/<%= pkg.name %>.min.js'
}
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
gruntfile: {
src: 'Gruntfile.js'
},
karmafile: {
src: 'karma.conf.js'
},
all: {
src: [
//'src/js/*.js',
'test/specs/*.js'
]
}
},
karma: {
unit: {
configFile: '<%= jshint.karmafile.src %>',
browsers: ['Firefox']
},
watch: {
configFile: '<%= jshint.karmafile.src %>',
browsers: ['Firefox'],
background: true,
singleRun: false,
reporters: ['mocha', 'coverage']
}
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
karmafile: {
files: '<%= jshint.karmafile.src %>',
tasks: ['jshint:karmafile']
},
all: {
files: '<%= jshint.all.src %>',
tasks: ['jshint:all', 'karma:watch:run']
}
},
bump: {
options: {
files: ['package.json', 'bower.json'],
updateConfigs: ['pkg'],
commit: true,
commitMessage: 'Release v%VERSION%',
commitFiles: ['-a'],
createTag: true,
tagName: 'v%VERSION%',
tagMessage: 'Version %VERSION%',
push: true,
pushTo: 'origin',
gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
globalReplace: false,
prereleaseName: false,
regExp: false
}
}
});
require('load-grunt-tasks')(grunt);
grunt.registerTask('default', ['test', 'build']);
grunt.registerTask('test', ['jshint', 'karma:unit']);
grunt.registerTask('start', ['karma:watch:start', 'watch']);
grunt.registerTask('build', ['concat', 'uglify']);
grunt.registerTask('release', function (target) {
target = 'bump-only:' + (target || 'patch');
grunt.task.run(['default', target, 'bump-commit']);
});
};
|
nbish11/microjs
|
gruntfile.js
|
JavaScript
|
mit
| 3,703
|
module Instances where
import Language.Haskell.Syntax
import qualified Language.Haskell.Pretty as P
import Niz
import Data.List
-------------------------------------------------------------------------------
---------------- INSTANCE DECLARATIONS ----------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
---------------------- LENGTH OF HSEXP --------------------------------------
-------------------------------------------------------------------------------
--class Size a where
-- size :: a -> Int
instance Size HsName where
size _ = 1
instance Size HsQName where
-- size (Special HsCons) = 0
size _ = 1
instance Size HsLiteral where
size (HsInt i) = length $ show i
size _ = 1
instance Size HsQualType where
size _ = 1
instance Size HsQOp where
size (HsQVarOp x) = size x
size (HsQConOp x) = size x
instance Size HsExp where
size e = case e of
HsVar n -> size n
HsCon n -> size n
HsLit x -> size x
HsInfixApp e1 op e2 -> size e1 + size e2 + size op
HsApp (HsVar _) e2 -> size e2 + 1
HsApp (HsCon _) e2 -> size e2 + 1
HsApp e1 e2 -> size e1 + size e2
HsNegApp e -> 1 + size e
HsLambda _ pats e -> size e + size pats
HsLet decs e -> size e + size decs
HsIf e1 e2 e3 -> 1 + size e1 + size e2 + size e3
HsCase e alts -> size e + size alts
HsDo stmts -> size stmts
HsTuple es -> sum $ map size es
HsList [] -> 1
HsList es -> sum $ map size es -- size es
HsParen e -> size e
HsLeftSection e op -> size e + size op
HsRightSection op e -> size e + size op
HsRecConstr n fields -> size n + size fields
HsRecUpdate e fields -> size e + size fields
HsEnumFrom e -> 1 + size e
HsEnumFromTo e1 e2 -> 1 + size e1 + size e2
HsEnumFromThen e1 e2 -> 1 + size e1 + size e2
HsEnumFromThenTo e1 e2 e3 -> 1 + size e1 + size e2 + size e3
HsListComp e stmts -> size e + size stmts
HsExpTypeSig _ e t -> size e + size t
HsAsPat n e -> size n + size e
HsWildCard -> 0
HsIrrPat e -> size e
instance Size HsStmt where
size s = case s of
HsGenerator _ p e -> size p + size e
HsQualifier e -> size e
HsLetStmt decs -> size decs
instance Size HsPat where
size p = case p of
HsPVar n -> size n
HsPLit l -> size l
HsPNeg p -> 1 + size p
HsPInfixApp p1 n p2 -> size p1 + size n + size p2
HsPApp n pats -> 1 + (sum $ map size pats)
HsPTuple pats -> sum $ map size pats
HsPList [] -> 1
HsPList pats -> sum $ map size pats
HsPParen p -> size p
HsPRec n fields -> size n + size fields
HsPAsPat n p -> size n + size p
HsPWildCard -> 0
HsPIrrPat p -> size p
instance Size HsPatField where
size (HsPFieldPat n p) = size n + size p
instance Size HsDecl where
size d = case d of
HsTypeDecl _ name names htype -> size name + size names + size htype
HsDataDecl _ ss name names cons qnames
-> size name + size names + size cons + size qnames + size ss
HsInfixDecl _ assoc _ ops -> 2 + size ops
HsNewTypeDecl _ c name names con qname -> size c + size name + size names + size con + size qname
HsClassDecl _ c name names decs -> size c + size name + size names + size decs
HsInstDecl _ c qname types decs -> size c + size qname + size types + size decs
HsDefaultDecl _ types -> size types
HsTypeSig _ names qtype -> size qtype + size names
HsFunBind ms -> sum $ map size ms
HsPatBind _ pat rhs decs -> size pat + size rhs + size decs
HsForeignImport _ s1 safety s2 hname htype -> 3 + size hname + size htype
HsForeignExport _ s1 s2 name htype -> 2 + size name + size htype
instance Size HsType where
size t = case t of
HsTyFun t1 t2 -> size t1 + size t2
HsTyTuple types -> size types
HsTyApp t1 t2 -> size t1 + size t2
HsTyVar n -> size n
HsTyCon n -> size n
instance (Size a, Size b) => Size (a,b) where
size (a,b) = size a + size b
-- instance Size a => Size [a] where
-- size xs = sum (map size xs)
instance Size HsMatch where
size (HsMatch _ name pats rhs decs) = 1 + sum (map size pats) + size rhs
instance Size HsRhs where
size (HsUnGuardedRhs e) = size e
size (HsGuardedRhss x) = size x
instance Size HsGuardedRhs where
size (HsGuardedRhs _ e1 e2) = size e1 + size e2
instance Size HsConDecl where
size (HsConDecl _ name list) = size name + size list
size (HsRecDecl _ name list) = size name + size list
instance Size HsBangType where
size (HsBangedTy x) = size x
size (HsUnBangedTy x) = size x
instance Size HsOp where
size (HsVarOp x) = size x
size (HsConOp x) = size x
instance Size HsAlt where
size (HsAlt _ pat alts decs) = size pat + size alts + size decs
instance Size HsGuardedAlts where
size (HsUnGuardedAlt exp) = size exp
size (HsGuardedAlts xs) = size xs
instance Size HsGuardedAlt where
size (HsGuardedAlt _ e1 e2) = size e1 + size e2
instance Size HsFieldUpdate where
size (HsFieldUpdate qname exp) = size qname + size exp
instance Ord HsLiteral where
compare (HsChar x) (HsChar y) = compare x y
compare (HsChar _) _ = LT
compare _ (HsChar _) = GT
compare (HsString x) (HsString y) = compare x y
compare (HsString _) _ = LT
compare _ (HsString _) = GT
compare (HsInt x) (HsInt y) = compare x y
compare (HsInt _) _ = LT
compare _ (HsInt _) = GT
compare (HsFrac x) (HsFrac y) = compare x y
compare (HsFrac _) _ = LT
compare _ (HsFrac _) = GT
compare (HsCharPrim x) (HsCharPrim y) = compare x y
compare (HsCharPrim _) _ = LT
compare _ (HsCharPrim _) = GT
compare (HsStringPrim x) (HsStringPrim y) = compare x y
compare (HsStringPrim _) _ = LT
compare _ (HsStringPrim _) = GT
compare (HsIntPrim x) (HsIntPrim y) = compare x y
compare (HsIntPrim _) _ = LT
compare _ (HsIntPrim _) = GT
compare (HsFloatPrim x) (HsFloatPrim y) = compare x y
compare (HsFloatPrim _) _ = LT
compare _ (HsFloatPrim _) = GT
compare (HsDoublePrim x) (HsDoublePrim y) = compare x y
instance Ord HsPat where
compare (HsPVar x) (HsPVar y) = compare x y
compare (HsPVar _) _ = LT
compare _ (HsPVar _) = GT
compare (HsPLit x) (HsPLit y) = compare x y
compare (HsPLit _) _ = LT
compare _ (HsPLit _) = GT
compare (HsPNeg x) (HsPNeg y) = compare x y
compare (HsPNeg _) _ = LT
compare _ (HsPNeg _) = GT
compare (HsPInfixApp p1 n1 q1) (HsPInfixApp p2 n2 q2) | n1 == n2 = compare [p1,q1] [p2,q2]
compare (HsPInfixApp _ n1 _) (HsPInfixApp _ n2 _) = compare n1 n2
compare (HsPInfixApp _ _ _) _ = LT
compare _ (HsPInfixApp _ _ _) = GT
compare (HsPApp n1 p1) (HsPApp n2 p2) | n1 == n2 = compare p1 p2
compare (HsPApp n1 _) (HsPApp n2 _) = compare n1 n2
compare (HsPApp _ _) _ = LT
compare _ (HsPApp _ _) = GT
compare (HsPTuple p1) (HsPTuple p2) = compare p1 p2
compare (HsPTuple _) _ = LT
compare _ (HsPTuple _) = GT
compare (HsPList p1) (HsPList p2) = compare p1 p2
compare (HsPList _) _ = LT
compare _ (HsPList _) = GT
compare (HsPParen p1) (HsPParen p2) = compare p1 p2
compare (HsPParen _) _ = LT
compare _ (HsPParen _) = GT
compare (HsPRec n1 p1) (HsPRec n2 p2) | n1 == n2 = compare p1 p2
compare (HsPRec n1 _) (HsPRec n2 _) = compare n1 n2
compare (HsPRec _ _) _ = LT
compare _ (HsPRec _ _) = GT
compare (HsPAsPat n1 p1) (HsPAsPat n2 p2) | n1 == n2 = compare p1 p2
compare (HsPAsPat n1 _) (HsPAsPat n2 _) = compare n1 n2
compare (HsPAsPat _ _) _ = LT
compare _ (HsPAsPat _ _) = GT
compare HsPWildCard _ = LT
compare _ HsPWildCard = GT
compare (HsPIrrPat x) (HsPIrrPat y) = compare x y
instance Ord HsPatField where
compare (HsPFieldPat n1 p1) (HsPFieldPat n2 p2) | n1 == n2 = compare p1 p2
compare (HsPFieldPat n1 _) (HsPFieldPat n2 _) = compare n1 n2
instance Ord HsExp where
compare (HsLit x) (HsLit y) = compare x y
compare (HsLit _) _ = LT
compare _ (HsLit _) = GT
compare (HsCon x) (HsCon y) = compare x y
compare (HsCon _) _ = LT
compare _ (HsCon _) = GT
compare (HsVar x) (HsVar y) = compare x y
compare (HsVar _) _ = LT
compare _ (HsVar _) = GT
compare (HsParen x) (HsParen y) = compare x y
compare (HsParen _) _ = LT
compare _ (HsParen _) = GT
compare (HsNegApp x) (HsNegApp y) = compare x y
compare (HsNegApp _) _ = LT
compare _ (HsNegApp _) = GT
compare (HsApp x1 x2) (HsApp y1 y2) = compare [x1,x2] [y1,y2]
compare (HsApp _ _) _ = LT
compare _ (HsApp _ _) = GT
compare (HsTuple x) (HsTuple y) = compare x y
compare (HsTuple _) _ = LT
compare _ (HsTuple _) = GT
compare (HsList x) (HsList y) = compare x y
compare (HsList _) _ = LT
compare _ (HsList _) = GT
compare HsWildCard _ = LT
compare _ HsWildCard = GT
compare (HsAsPat n1 x) (HsAsPat n2 y) | n1 == n2 = compare x y
compare (HsAsPat n1 _) (HsAsPat n2 _) = compare n1 n2
compare (HsAsPat _ _) _ = LT
compare _ (HsAsPat _ _) = GT
compare (HsLambda a b c) (HsLambda x y z) | a == x && b == y = compare c z
compare (HsLambda a b c) (HsLambda x y z) | a == x = compare b y
compare (HsLambda a b c) (HsLambda x y z) = compare a x
compare (HsLambda _ _ _) _ = LT
compare _ (HsLambda _ _ _) = GT
compare (HsInfixApp x y z) (HsInfixApp a b c) | y == b = compare [x,z] [a,c]
compare (HsInfixApp x y z) (HsInfixApp a b c) = compare y b
compare (HsInfixApp _ _ _) _ = LT
compare _ (HsInfixApp _ _ _) = GT
compare (HsLet a b) (HsLet x y) = compare (a,b) (x,y)
compare (HsLet _ _) _ = LT
compare _ (HsLet _ _) = GT
compare (HsIf a b c) (HsIf x y z) = compare (a,b,c) (x,y,z)
compare (HsIf _ _ _) _ = LT
compare _ (HsIf _ _ _) = GT
compare (HsCase a b) (HsCase x y) = compare (a,b) (x,y)
compare (HsCase _ _) _ = LT
compare _ (HsCase _ _) = GT
compare (HsDo x) (HsDo y) = compare x y
compare (HsDo _) _ = LT
compare _ (HsDo _) = GT
compare (HsLeftSection a b) (HsLeftSection x y) = compare (a,b) (x,y)
compare (HsLeftSection _ _) _ = LT
compare _ (HsLeftSection _ _) = GT
compare (HsRightSection a b) (HsRightSection x y) = compare (a,b) (x,y)
compare (HsRightSection _ _) _ = LT
compare _ (HsRightSection _ _) = GT
compare (HsRecConstr a b) (HsRecConstr x y) = compare (a,b) (x,y)
compare (HsRecConstr _ _) _ = LT
compare _ (HsRecConstr _ _) = GT
compare (HsRecUpdate a b) (HsRecUpdate x y) = compare (a,b) (x,y)
compare (HsRecUpdate _ _) _ = LT
compare _ (HsRecUpdate _ _) = GT
compare (HsEnumFrom x) (HsEnumFrom y) = compare x y
compare (HsEnumFrom _) _ = LT
compare _ (HsEnumFrom _) = GT
compare (HsEnumFromTo a b) (HsEnumFromTo x y) = compare (a,b) (x,y)
compare (HsEnumFromTo _ _) _ = LT
compare _ (HsEnumFromTo _ _) = GT
compare (HsEnumFromThen a b) (HsEnumFromThen x y) = compare (a,b) (x,y)
compare (HsEnumFromThen _ _) _ = LT
compare _ (HsEnumFromThen _ _) = GT
compare (HsEnumFromThenTo a b c) (HsEnumFromThenTo x y z) = compare (a,b,c) (x,y,z)
compare (HsEnumFromThenTo _ _ _) _ = LT
compare _ (HsEnumFromThenTo _ _ _) = GT
compare (HsListComp a b) (HsListComp x y) = compare (a,b) (x,y)
compare (HsListComp _ _) _ = LT
compare _ (HsListComp _ _) = GT
compare (HsExpTypeSig a b c) (HsExpTypeSig x y z) = compare (a,b,c) (x,y,z)
compare (HsExpTypeSig _ _ _) _ = LT
compare _ (HsExpTypeSig _ _ _) = GT
compare (HsIrrPat x) (HsIrrPat y) = compare x y
instance Ord HsDecl where
compare (HsTypeDecl a b c d) (HsTypeDecl w x y z) = compare (a,b,c,d) (w,x,y,z)
compare (HsTypeDecl _ _ _ _) _ = LT
compare _ (HsTypeDecl _ _ _ _) = GT
compare (HsDataDecl a b c d e f) (HsDataDecl m n o p q r) = compare (a,b,c,d,e,f) (m,n,o,p,q,r)
compare (HsDataDecl _ _ _ _ _ _) _ = LT
compare _ (HsDataDecl _ _ _ _ _ _) = GT
compare (HsInfixDecl a b c d) (HsInfixDecl w x y z) = compare (a,b,c,d) (w,x,y,z)
compare (HsInfixDecl _ _ _ _) _ = LT
compare _ (HsInfixDecl _ _ _ _) = GT
compare (HsNewTypeDecl a b c d e f) (HsNewTypeDecl m n o p q r) = compare (a,b,c,d,e,f) (m,n,o,p,q,r)
compare (HsNewTypeDecl _ _ _ _ _ _) _ = LT
compare _ (HsNewTypeDecl _ _ _ _ _ _) = GT
compare (HsClassDecl a b c d e) (HsClassDecl m n o p q) = compare (a,b,c,d,e) (m,n,o,p,q)
compare (HsClassDecl _ _ _ _ _) _ = LT
compare _ (HsClassDecl _ _ _ _ _) = GT
compare (HsInstDecl a b c d e) (HsInstDecl m n o p q) = compare (a,b,c,d,e) (m,n,o,p,q)
compare (HsInstDecl _ _ _ _ _) _ = LT
compare _ (HsInstDecl _ _ _ _ _) = GT
compare (HsDefaultDecl a b) (HsDefaultDecl x y) = compare (a,b) (x,y)
compare (HsDefaultDecl _ _) _ = LT
compare _ (HsDefaultDecl _ _) = GT
compare (HsTypeSig a b c) (HsTypeSig x y z) = compare (a,b,c) (x,y,z)
compare (HsTypeSig _ _ _) _ = LT
compare _ (HsTypeSig _ _ _) = GT
compare (HsFunBind a) (HsFunBind x) = compare a x
compare (HsFunBind _) _ = LT
compare _ (HsFunBind _) = GT
compare (HsPatBind a b c d) (HsPatBind w x y z) = compare (a,b,c,d) (w,x,y,z)
compare (HsPatBind _ _ _ _) _ = LT
compare _ (HsPatBind _ _ _ _) = GT
compare (HsForeignImport a b c d e f) (HsForeignImport m n o p q r) = compare (a,b,c,d,e,f) (m,n,o,p,q,r)
compare (HsForeignImport _ _ _ _ _ _) _ = LT
compare _ (HsForeignImport _ _ _ _ _ _) = GT
compare (HsForeignExport a b c d e) (HsForeignExport m n o p q) = compare (a,b,c,d,e) (m,n,o,p,q)
instance Ord HsRhs where
compare (HsUnGuardedRhs x) (HsUnGuardedRhs y) = compare x y
compare (HsGuardedRhss x) (HsGuardedRhss y) = compare x y
instance Ord HsGuardedRhs where
compare (HsGuardedRhs a b c) (HsGuardedRhs x y z) = compare (a,b,c) (x,y,z)
instance Ord HsMatch where
compare (HsMatch a b c d e) (HsMatch m n o p q) = compare (a,b,c,d,e) (m,n,o,p,q)
instance Ord HsQualType where
compare (HsQualType a b) (HsQualType x y) = compare (a,b) (x,y)
instance Ord HsType where
compare (HsTyFun a b) (HsTyFun x y) = compare (a,b) (x,y)
compare (HsTyFun _ _) _ = LT
compare _ (HsTyFun _ _) = GT
compare (HsTyTuple x) (HsTyTuple y) = compare x y
compare (HsTyTuple _) _ = LT
compare _ (HsTyTuple _) = GT
compare (HsTyApp a b) (HsTyApp x y) = compare (a,b) (x,y)
compare (HsTyApp _ _) _ = LT
compare _ (HsTyApp _ _) = GT
compare (HsTyVar x) (HsTyVar y) = compare x y
compare (HsTyVar _) _ = LT
compare _ (HsTyVar _) = GT
compare (HsTyCon x) (HsTyCon y) = compare x y
instance Ord HsAssoc where
compare HsAssocNone HsAssocNone = EQ
compare HsAssocNone _ = LT
compare _ HsAssocNone = GT
compare HsAssocLeft HsAssocLeft = EQ
compare HsAssocLeft _ = LT
compare _ HsAssocLeft = GT
compare HsAssocRight HsAssocRight = EQ
instance Ord HsConDecl where
compare (HsConDecl a b c) (HsConDecl x y z) = compare (a,b,c) (x,y,z)
compare (HsConDecl _ _ _) _ = LT
compare _ (HsConDecl _ _ _) = GT
compare (HsRecDecl a b c) (HsRecDecl x y z) = compare (a,b,c) (x,y,z)
instance Ord HsBangType where
compare (HsBangedTy x) (HsBangedTy y) = compare x y
compare (HsBangedTy _) _ = LT
compare _ (HsBangedTy _) = GT
compare (HsUnBangedTy x) (HsUnBangedTy y) = compare x y
instance Ord HsFieldUpdate where
compare (HsFieldUpdate a b) (HsFieldUpdate x y) = compare (a,b) (x,y)
instance Ord HsStmt where
compare (HsGenerator a b c) (HsGenerator x y z) = compare (a,b,c) (x,y,z)
compare (HsGenerator _ _ _) _ = LT
compare _ (HsGenerator _ _ _) = GT
compare (HsQualifier x) (HsQualifier y) = compare x y
compare (HsQualifier _) _ = LT
compare _ (HsQualifier _) = GT
compare (HsLetStmt x) (HsLetStmt y) = compare x y
instance Ord HsAlt where
compare (HsAlt a b c d) (HsAlt w x y z) = compare (a,b,c,d) (w,x,y,z)
instance Ord HsGuardedAlts where
compare (HsUnGuardedAlt x) (HsUnGuardedAlt y) = compare x y
compare (HsUnGuardedAlt _) _ = LT
compare _ (HsUnGuardedAlt _) = GT
compare (HsGuardedAlts x) (HsGuardedAlts y) = compare x y
instance Ord HsGuardedAlt where
compare (HsGuardedAlt a b c) (HsGuardedAlt x y z) = compare (a,b,c) (x,y,z)
class Pretty a where
pretty :: a -> String
instance Pretty HsModule where
pretty x = P.prettyPrint x
instance Pretty HsExportSpec where
pretty x = P.prettyPrint x
instance Pretty HsImportDecl where
pretty x = P.prettyPrint x
instance Pretty HsImportSpec where
pretty x = P.prettyPrint x
instance Pretty HsAssoc where
pretty x = P.prettyPrint x
instance Pretty HsDecl where
pretty x = P.prettyPrint x
instance Pretty HsConDecl where
pretty x = P.prettyPrint x
instance Pretty HsBangType where
pretty x = P.prettyPrint x
instance Pretty HsMatch where
--pretty (HsMatch pos f ps rhs whereDecls)
-- = pretty f ++ " " ++ concat (intersperse " " (map pretty ps)) ++ " = " ++ pretty rhs
pretty x = P.prettyPrint x
instance Pretty HsRhs where
pretty x = P.prettyPrint x
instance Pretty HsGuardedRhs where
pretty x = P.prettyPrint x
instance Pretty HsSafety where
pretty x = P.prettyPrint x
instance Pretty HsQualType where
pretty x = P.prettyPrint x
instance Pretty HsType where
pretty x = P.prettyPrint x
instance Pretty HsExp where
pretty x = case x of
HsVar name -> pretty name
HsCon name -> pretty name
HsList list -> (all isChar list)
? (let s = [c | (HsLit (HsChar c)) <- list]
in P.prettyPrint (HsLit (HsString s)))
$ P.prettyPrint (HsList list)
HsApp x arg -> pretty x ++ " (" ++ pretty arg ++ ")"
HsNegApp e@(HsNegApp _) -> "-(" ++ pretty e ++ ")"
HsNegApp e -> "-" ++ pretty e
HsParen e -> "(" ++ pretty e ++ ")"
HsInfixApp e1 (HsQConOp (Special HsCons)) (HsLit (HsInt i))
-> let p = pretty e1
in if take 1 p == "(" then p ++ ":" ++ show i else p ++ show i
HsInfixApp e1 op e2 -> "(" ++ pretty e1 ++ P.prettyPrint op ++ pretty e2 ++ ")"
e -> P.prettyPrint e
isChar (HsLit (HsChar _)) = True
isChar _ = False
instance Pretty HsStmt where
pretty x = P.prettyPrint x
instance Pretty HsFieldUpdate where
pretty x = P.prettyPrint x
instance Pretty HsAlt where
pretty x = P.prettyPrint x
instance Pretty HsGuardedAlts where
pretty x = P.prettyPrint x
instance Pretty HsGuardedAlt where
pretty x = P.prettyPrint x
instance Pretty HsPat where
pretty x = case x of
(HsPInfixApp p1 op p2) -> "(" ++ pretty p1 ++ P.prettyPrint op ++ pretty p2 ++ ")"
e -> P.prettyPrint e
instance Pretty HsPatField where
pretty x = P.prettyPrint x
instance Pretty HsLiteral where
pretty x = P.prettyPrint x
instance Pretty Module where
pretty x = P.prettyPrint x
instance Pretty HsQName where
pretty x = P.prettyPrint x
instance Pretty HsName where
pretty x = P.prettyPrint x
instance Pretty HsQOp where
pretty o = P.prettyPrint o
instance Pretty HsOp where
pretty o = P.prettyPrint o
instance Pretty HsSpecialCon where
pretty HsUnitCon = "()"
pretty HsListCon = "[]"
pretty HsFunCon = "->"
pretty (HsTupleCon i) = "(" ++ take i (repeat ',') ++ ")"
pretty HsCons = ":"
instance Pretty HsCName where
pretty n = P.prettyPrint n
|
arnizamani/occam
|
Instances.hs
|
Haskell
|
mit
| 19,725
|
jui.define("chart.brush.map.selector", [ "util.base" ], function(_) {
/**
* @class chart.brush.over
* @extends chart.brush.core
*/
var MapSelectorBrush = function(chart, axis, brush) {
var g = null,
activePath = null;
this.drawBefore = function() {
g = chart.svg.group();
}
this.draw = function() {
var originFill = null;
this.on("map.mouseover", function(obj, e) {
if(activePath == obj.path) return;
originFill = obj.path.styles.fill || obj.path.attributes.fill;
obj.path.css({
fill: chart.theme("mapSelectorHoverColor")
});
});
this.on("map.mouseout", function(obj, e) {
if(activePath == obj.path) return;
obj.path.css({
fill: originFill
});
});
if(brush.activeEvent != null) {
this.on(brush.activeEvent, function(obj, e) {
activePath = obj.path;
axis.map.each(function(i, obj) {
obj.path.css({
fill: originFill
});
});
obj.path.css({
fill: chart.theme("mapSelectorActiveColor")
});
});
}
if(brush.active.length > 0) {
activePath = [];
axis.map.each(function(i, obj) {
if(_.inArray(axis.getValue(obj.data, "id"), brush.active) != -1) {
activePath.push(obj.path);
obj.path.css({
fill: chart.theme("mapSelectorActiveColor")
});
}
});
}
return g;
}
}
MapSelectorBrush.setup = function() {
return {
active: [],
activeEvent: null
}
}
return MapSelectorBrush;
}, "chart.brush.map.core");
|
juijs/store.jui.io
|
public/jui-all/jui-chart/js/brush/map/selector.js
|
JavaScript
|
mit
| 1,524
|
import tkinter as tk
from time import sleep
from playsound import playsound
import config
import fasttick
from helpmessage import fasttick_help_message
import misc
from tickerwindow import TickerWindow
class GUIfasttick(TickerWindow):
def __init__(self, app):
super().__init__(app)
misc.delete_ancient_pickles('fasttick_history')
self.draw_labels()
self.draw_buttons()
self.draw_lists()
self.draw_timer()
self.timer_update()
def draw_labels(self):
self.labelName.grid(row=3, column=0, sticky='NSWE')
self.labelChange.config(text='Rate')
self.labelChange.grid(row=3, column=1, sticky='NSWE')
self.labelVol.grid(row=3, column=2, sticky='NSWE')
self.labelBuf.grid(row=3, rowspan=2, column=3, columnspan=2, sticky='NSWE')
def draw_buttons(self):
self.sortByName.grid(row=4, column=0, sticky='NSWE')
self.sortByChange.grid(row=4, column=1, sticky='NSWE')
self.sortByVol.grid(row=4, column=2, sticky='NSWE')
self.notifyBell.grid(row=4, column=3, sticky='NSWE')
self.help.grid(row=3, column=4, sticky='E')
def on_click_help(self):
helpWindow = tk.Toplevel()
helpWindow.title('Help')
frameBuf = tk.Frame(helpWindow, width=192, bg=config.MAIN_BG)
frameBuf.grid(row=0, rowspan=4, column=0, columnspan=3)
message = tk.Message(frameBuf, bg=config.MAIN_BG, fg=config.TEXT_COLOR,
width=192, text=fasttick_help_message)
message.grid(row=0, columnspan=3)
dismissButton = tk.Button(frameBuf, text='Dismiss', command=helpWindow.destroy)
dismissButton.grid(row=1, column=1)
def draw_lists(self):
self.yScroll.grid(row=5, column=3, sticky='NSWE')
self.listName.grid(row=5, column=0, sticky='NSWE')
self.listChange.grid(row=5, column=1, sticky='NSWE')
self.listVol.grid(row=5, column=2, sticky='NSWE')
def draw_timer(self):
self.timerLabel.grid(row=5, column=4, ipadx=8)
self.timerFrame.grid(row=5, column=4, columnspan=3)
self.timerDisp.grid(row=5, column=4)
self.timerValue = config.FASTTICK_RATE
def timer_update(self):
if self.timerValue == 3:
self.async = self.pool.apply_async(fasttick.heartbeat)
if self.timerValue == 0:
while True:
if self.async.ready():
break
for i in range(1, 4):
if self.async.ready():
break
self.timerDisp.config(text=f'{"." * i}', font=('', 20))
self.app.update()
sleep(1)
self.ticker_data = self.async.get()
self.sort_ticker()
if self.notifyIsActive and self.ticker_data:
playsound('media/notification_sound.mp3')
self.timerValue = config.FASTTICK_RATE
values = divmod(self.timerValue, 60)
minutes = values[0]
seconds = values[1]
self.timerDisp.config(text=f'{minutes}:{seconds:0>2}', font=('', 20))
self.timerValue -= 1
self.app.after(1000, self.timer_update)
|
JevinJ/Bittrex-Notify
|
src/GUIfasttick.py
|
Python
|
mit
| 3,213
|
import React, {Component} from 'react';
// require('./style.scss');
export default class WorkDetails extends Component {
constructor(props) {
super(props);
}
componentDidMount() {
document.title = "Profile | Work Details";
}
render() {
return (
<div>WorkDetailsWorkDetailsWorkDetailsWorkDetailsWorkDetailsWorkDetails</div>
);
}
};
|
AcrylicInc/totalblu
|
web/src/scenes/Profile/components/ProfilePanel/components/WorkDetails/index.js
|
JavaScript
|
mit
| 359
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.