code
stringlengths
3
1.05M
repo_name
stringlengths
4
116
path
stringlengths
3
942
language
stringclasses
30 values
license
stringclasses
15 values
size
int32
3
1.05M
using System; using System.Collections.Generic; using System.Linq; using System.Text; using ASPPatterns.Chap7.Library.Services.Views; namespace ASPPatterns.Chap7.Library.Services.Messages { public class FindMembersResponse : ResponseBase { public IEnumerable<MemberView> MembersFound { get; set; } } }
liqipeng/helloGithub
Book-Code/ASP.NET Design Pattern/ASPPatternsc07/ASPPatterns.Chap7.Library/ASPPatterns.Chap7.Library.Services/Messages/FindMembersResponse.cs
C#
mit
327
let _ = require('underscore'), React = require('react'); class Icon extends React.Component { render() { let className = "icon " + this.props.icon; let other = _.omit(this.props.icon, "icon"); return ( <span className={className} role="img" {...other}></span> ); } } Icon.propTypes = { icon: React.PropTypes.string.isRequired }; module.exports = Icon;
legendary-code/chaos-studio-web
app/src/js/components/Icon.js
JavaScript
mit
433
using System.IO; namespace Mandro.Utils.Setup { public class DirectoryHelper { public DirectoryHelper() { } public static void CopyDirectory(string sourceDirName, string destDirName, bool copySubDirs) { // Get the subdirectories for the specified directory. DirectoryInfo dir = new DirectoryInfo(sourceDirName); DirectoryInfo[] dirs = dir.GetDirectories(); if (!dir.Exists) { throw new DirectoryNotFoundException( "Source directory does not exist or could not be found: " + sourceDirName); } // If the destination directory doesn't exist, create it. if (!Directory.Exists(destDirName)) { Directory.CreateDirectory(destDirName); } // Get the files in the directory and copy them to the new location. FileInfo[] files = dir.GetFiles(); foreach (FileInfo file in files) { string temppath = Path.Combine(destDirName, file.Name); file.CopyTo(temppath, true); } // If copying subdirectories, copy them and their contents to new location. if (copySubDirs) { foreach (DirectoryInfo subdir in dirs) { string temppath = Path.Combine(destDirName, subdir.Name); CopyDirectory(subdir.FullName, temppath, copySubDirs); } } } } }
mandrek44/Mandro.Utils
Mandro.Utils/Setup/DirectoryHelper.cs
C#
mit
1,605
import { NotificationType } from 'vscode-languageclient' export enum Status { ok = 1, warn = 2, error = 3 } export interface StatusParams { state: Status } export const type = new NotificationType<StatusParams>('standard/status')
chenxsan/vscode-standardjs
client/src/utils/StatusNotification.ts
TypeScript
mit
241
import React from 'react'; import IconBase from './../components/IconBase/IconBase'; export default class ChevronDown extends React.Component { render() { if(this.props.bare) { return <g> <path d="M256,298.3L256,298.3L256,298.3l174.2-167.2c4.3-4.2,11.4-4.1,15.8,0.2l30.6,29.9c4.4,4.3,4.5,11.3,0.2,15.5L264.1,380.9 c-2.2,2.2-5.2,3.2-8.1,3c-3,0.1-5.9-0.9-8.1-3L35.2,176.7c-4.3-4.2-4.2-11.2,0.2-15.5L66,131.3c4.4-4.3,11.5-4.4,15.8-0.2L256,298.3 z"></path> </g>; } return <IconBase> <path d="M256,298.3L256,298.3L256,298.3l174.2-167.2c4.3-4.2,11.4-4.1,15.8,0.2l30.6,29.9c4.4,4.3,4.5,11.3,0.2,15.5L264.1,380.9 c-2.2,2.2-5.2,3.2-8.1,3c-3,0.1-5.9-0.9-8.1-3L35.2,176.7c-4.3-4.2-4.2-11.2,0.2-15.5L66,131.3c4.4-4.3,11.5-4.4,15.8-0.2L256,298.3 z"></path> </IconBase>; } };ChevronDown.defaultProps = {bare: false}
fbfeix/react-icons
src/icons/ChevronDown.js
JavaScript
mit
819
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin'); const webpack = require('webpack'); const paths = require('./tools/paths'); const env = { 'process.env.NODE_ENV': JSON.stringify('development') }; module.exports = { devtool: 'cheap-module-eval-source-map', entry: [ require.resolve('./tools/polyfills'), 'webpack-dev-server/client?http://localhost:3000', 'webpack/hot/only-dev-server', 'react-hot-loader/patch', './src/index' ], output: { filename: 'static/js/bundle.js', path: paths.appDist, pathinfo: true, publicPath: '/' }, module: { rules: [ // Default loader: load all assets that are not handled // by other loaders with the url loader. // Note: This list needs to be updated with every change of extensions // the other loaders match. // E.g., when adding a loader for a new supported file extension, // we need to add the supported extension to this loader too. // Add one new line in `exclude` for each loader. // // "file" loader makes sure those assets get served by WebpackDevServer. // When you `import` an asset, you get its (virtual) filename. // In production, they would get copied to the `dist` folder. // "url" loader works like "file" loader except that it embeds assets // smaller than specified limit in bytes as data URLs to avoid requests. // A missing `test` is equivalent to a match. { exclude: [ /\.html$/, /\.js$/, /\.scss$/, /\.json$/, /\.svg$/, /node_modules/ ], use: [{ loader: 'url-loader', options: { limit: 10000, name: 'static/media/[name].[hash:8].[ext]' } }] }, { test: /\.js$/, enforce: 'pre', include: paths.appSrc, use: [{ loader: 'xo-loader', options: { // This loader must ALWAYS return warnings during development. If // errors are emitted, no changes will be pushed to the browser for // testing until the errors have been resolved. emitWarning: true } }] }, { test: /\.js$/, include: paths.appSrc, use: [{ loader: 'babel-loader', options: { // This is a feature of `babel-loader` for webpack (not Babel itself). // It enables caching results in ./node_modules/.cache/babel-loader/ // directory for faster rebuilds. cacheDirectory: true } }] }, { test: /\.scss$/, use: [ 'style-loader', { loader: 'css-loader', options: { importLoaders: 2 } }, 'postcss-loader', 'sass-loader' ] }, { test: /\.svg$/, use: [{ loader: 'file-loader', options: { name: 'static/media/[name].[hash:8].[ext]' } }] } ] }, plugins: [ new HtmlWebpackPlugin({ inject: true, template: paths.appHtml }), new webpack.DefinePlugin(env), new webpack.HotModuleReplacementPlugin(), new webpack.NoEmitOnErrorsPlugin(), // Watcher doesn't work well if you mistype casing in a path so we use // a plugin that prints an error when you attempt to do this. // See https://github.com/facebookincubator/create-react-app/issues/240 new CaseSensitivePathsPlugin(), // If you require a missing module and then `npm install` it, you still have // to restart the development server for Webpack to discover it. This plugin // makes the discovery automatic so you don't have to restart. // See https://github.com/facebookincubator/create-react-app/issues/186 new WatchMissingNodeModulesPlugin(paths.appNodeModules) ], // Some libraries import Node modules but don't use them in the browser. // Tell Webpack to provide empty mocks for them so importing them works. node: { fs: 'empty', net: 'empty', tls: 'empty' } };
hn3etta/VS2015-React-Redux-Webpack-Front-end-example
webpack.config.js
JavaScript
mit
3,928
// // SA_DiceEvaluator.h // // Copyright (c) 2016 Said Achmiz. // // This software is licensed under the MIT license. // See the file "LICENSE" for more information. #import <Foundation/Foundation.h> @class SA_DiceBag; @class SA_DiceExpression; /************************************************/ #pragma mark SA_DiceEvaluator class declaration /************************************************/ @interface SA_DiceEvaluator : NSObject /************************/ #pragma mark - Properties /************************/ @property NSUInteger maxDieCount; @property NSUInteger maxDieSize; /****************************/ #pragma mark - Public methods /****************************/ -(SA_DiceExpression *) resultOfExpression:(SA_DiceExpression *)expression; @end
achmizs/SA_Dice
SA_DiceEvaluator.h
C
mit
763
// This file is automatically generated. package adila.db; /* * Alcatel POP 2 (5) * * DEVICE: alto5 * MODEL: 7043K */ final class alto5_7043k { public static final String DATA = "Alcatel|POP 2 (5)|"; }
karim/adila
database/src/main/java/adila/db/alto5_7043k.java
Java
mit
213
<?php namespace BackOfficeBundle\Entity; use Doctrine\ORM\EntityRepository; /** * PosteCollaborateurRepository * * This class was generated by the Doctrine ORM. Add your own custom * repository methods below. */ class PosteCollaborateurRepository extends EntityRepository { }
elmabdgrub/azplatform
src/BackOfficeBundle/Entity/PosteCollaborateurRepository.php
PHP
mit
284
/* database.h Author: Pixel Flash Server database.h contains the class definition for the database class used by the cuCare server to store data persistently */ #ifndef DATABASE_H #define DATABASE_H #include <QtSql> #include <QDebug> class Database { public: Database(); ~Database(); QSqlQuery query(QString query_string); void close(); bool opened(); private: QSqlDatabase db; }; #endif // DATABASE_H
jmehic/cuCare
server/database.h
C
mit
438
// ========================================================================== // snd_app // ========================================================================== // Copyright (c) 2006-2012, Knut Reinert, FU Berlin // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of Knut Reinert or the FU Berlin nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // // ========================================================================== // Author: Your Name <[email protected]> // ========================================================================== #include <seqan/basic.h> #include <seqan/sequence.h> #include <seqan/arg_parse.h> // ========================================================================== // Classes // ========================================================================== // -------------------------------------------------------------------------- // Class AppOptions // -------------------------------------------------------------------------- // This struct stores the options from the command line. // // You might want to rename this to reflect the name of your app. struct AppOptions { // Verbosity level. 0 -- quiet, 1 -- normal, 2 -- verbose, 3 -- very verbose. int verbosity; // The first (and only) argument of the program is stored here. seqan::CharString text; AppOptions() : verbosity(1) {} }; // ========================================================================== // Functions // ========================================================================== // -------------------------------------------------------------------------- // Function parseCommandLine() // -------------------------------------------------------------------------- seqan::ArgumentParser::ParseResult parseCommandLine(AppOptions & options, int argc, char const ** argv) { // Setup ArgumentParser. seqan::ArgumentParser parser("snd_app"); // Set short description, version, and date. setShortDescription(parser, "Put a Short Description Here"); setVersion(parser, "0.1"); setDate(parser, "July 2012"); // Define usage line and long description. addUsageLine(parser, "[\\fIOPTIONS\\fP] \"\\fITEXT\\fP\""); addDescription(parser, "This is the application skelleton and you should modify this string."); // We require one argument. addArgument(parser, seqan::ArgParseArgument(seqan::ArgParseArgument::STRING, "TEXT")); addOption(parser, seqan::ArgParseOption("q", "quiet", "Set verbosity to a minimum.")); addOption(parser, seqan::ArgParseOption("v", "verbose", "Enable verbose output.")); addOption(parser, seqan::ArgParseOption("vv", "very-verbose", "Enable very verbose output.")); // Add Examples Section. addTextSection(parser, "Examples"); addListItem(parser, "\\fBsnd_app\\fP \\fB-v\\fP \\fItext\\fP", "Call with \\fITEXT\\fP set to \"text\" with verbose output."); // Parse command line. seqan::ArgumentParser::ParseResult res = seqan::parse(parser, argc, argv); // Only extract options if the program will continue after parseCommandLine() if (res != seqan::ArgumentParser::PARSE_OK) return res; // Extract option values. if (isSet(parser, "quiet")) options.verbosity = 0; if (isSet(parser, "verbose")) options.verbosity = 2; if (isSet(parser, "very-verbose")) options.verbosity = 3; seqan::getArgumentValue(options.text, parser, 0); return seqan::ArgumentParser::PARSE_OK; } // -------------------------------------------------------------------------- // Function main() // -------------------------------------------------------------------------- // Program entry point. int main(int argc, char const ** argv) { // Parse the command line. seqan::ArgumentParser parser; AppOptions options; seqan::ArgumentParser::ParseResult res = parseCommandLine(options, argc, argv); // If there was an error parsing or built-in argument parser functionality // was triggered then we exit the program. The return code is 1 if there // were errors and 0 if there were none. if (res != seqan::ArgumentParser::PARSE_OK) return res == seqan::ArgumentParser::PARSE_ERROR; std::cout << "EXAMPLE PROGRAM\n" << "===============\n\n"; // Print the command line arguments back to the user. if (options.verbosity > 0) { std::cout << "__OPTIONS____________________________________________________________________\n" << '\n' << "VERBOSITY\t" << options.verbosity << '\n' << "TEXT \t" << options.text << "\n\n"; } return 0; }
bkahlert/seqan-research
raw/pmsb13/pmsb13-data-20130530/sources/130wu1dgzoqmxyu2/2013-04-09T10-23-18.897+0200/sandbox/my_sandbox/apps/snd_app/snd_app.cpp
C++
mit
6,165
% % Primera página del documento \begin{titlepage} \begin{scriptsize}\noindent Facultad de Informática.\\ Ingeniería en Informática.\\ Ingeniería del Software.\\ Proyecto: Everywhere House Control. \end{scriptsize}\\ \vfill \begin{center} \begin{Large} \textbf{Documento de análisis} \end{Large} \end{center} \vfill \begin{flushright} \begin{scriptsize} \begin{tabular}{lll} Creado por & Gutierrez, Hector & Guzman, Fernando\\ & Ladrón, Alejandro & Maldonado, Miguel Alexander\\ & Morales, Álvaro & Ochoa, Victor\\ & Rey, José Antonio & Saavendra, Luis Antonio\\ & Tirado, Colin & Vicente, Victor\\ \end{tabular} \end{scriptsize} \end{flushright} \end{titlepage} \thispagestyle{empty} \cleardoublepage \newpage % % Tabla de contenidos, etc. \pagenumbering{Roman} \tableofcontents \newpage \thispagestyle{empty} \cleardoublepage \newpage \pagenumbering{arabic} \raggedbottom \interfootnotelinepenalty 10000 \input{3.Analisis/ERS.tex} % % % % % % Fin del cuerpo
EverywhereHouseControl/Documentation
3.Analisis/Analisis.tex
TeX
mit
1,176
<?php /** * @file * Contains \Drupal\shortcut\ShortcutSetStorageControllerInterface. */ namespace Drupal\shortcut; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\shortcut\ShortcutSetInterface; /** * Defines a common interface for shortcut entity controller classes. */ interface ShortcutSetStorageControllerInterface extends EntityStorageControllerInterface { /** * Assigns a user to a particular shortcut set. * * @param \Drupal\shortcut\ShortcutSetInterface $shortcut_set * An object representing the shortcut set. * @param $account * A user account that will be assigned to use the set. */ public function assignUser(ShortcutSetInterface $shortcut_set, $account); /** * Unassigns a user from any shortcut set they may have been assigned to. * * The user will go back to using whatever default set applies. * * @param $account * A user account that will be removed from the shortcut set assignment. * * @return bool * TRUE if the user was previously assigned to a shortcut set and has been * successfully removed from it. FALSE if the user was already not assigned * to any set. */ public function unassignUser($account); /** * Delete shortcut sets assigned to users. * * @param \Drupal\shortcut\ShortcutSetInterface $entity * Delete the user assigned sets belonging to this shortcut. */ public function deleteAssignedShortcutSets(ShortcutSetInterface $entity); /** * Get the name of the set assigned to this user. * * @param \Drupal\user\Plugin\Core\Entity\User * The user account. * * @return string * The name of the shortcut set assigned to this user. */ public function getAssignedToUser($account); /** * Get the number of users who have this set assigned to them. * * @param \Drupal\shortcut\ShortcutSetInterface $shortcut_set * The shortcut to count the users assigned to. * * @return int * The number of users who have this set assigned to them. */ public function countAssignedUsers(ShortcutSetInterface $shortcut_set); }
augustash/d8.dev
core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetStorageControllerInterface.php
PHP
mit
2,130
using System; using System.Collections.Generic; using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using MS.Core; namespace System.Runtime.Remoting.Contexts { public static class __ContextAttribute { public static IObservable<System.Boolean> IsNewContextOK( this IObservable<System.Runtime.Remoting.Contexts.ContextAttribute> ContextAttributeValue, IObservable<System.Runtime.Remoting.Contexts.Context> newCtx) { return Observable.Zip(ContextAttributeValue, newCtx, (ContextAttributeValueLambda, newCtxLambda) => ContextAttributeValueLambda.IsNewContextOK(newCtxLambda)); } public static IObservable<System.Reactive.Unit> Freeze( this IObservable<System.Runtime.Remoting.Contexts.ContextAttribute> ContextAttributeValue, IObservable<System.Runtime.Remoting.Contexts.Context> newContext) { return ObservableExt.ZipExecute(ContextAttributeValue, newContext, (ContextAttributeValueLambda, newContextLambda) => ContextAttributeValueLambda.Freeze(newContextLambda)); } public static IObservable<System.Boolean> Equals( this IObservable<System.Runtime.Remoting.Contexts.ContextAttribute> ContextAttributeValue, IObservable<System.Object> o) { return Observable.Zip(ContextAttributeValue, o, (ContextAttributeValueLambda, oLambda) => ContextAttributeValueLambda.Equals(oLambda)); } public static IObservable<System.Int32> GetHashCode( this IObservable<System.Runtime.Remoting.Contexts.ContextAttribute> ContextAttributeValue) { return Observable.Select(ContextAttributeValue, (ContextAttributeValueLambda) => ContextAttributeValueLambda.GetHashCode()); } public static IObservable<System.Boolean> IsContextOK( this IObservable<System.Runtime.Remoting.Contexts.ContextAttribute> ContextAttributeValue, IObservable<System.Runtime.Remoting.Contexts.Context> ctx, IObservable<System.Runtime.Remoting.Activation.IConstructionCallMessage> ctorMsg) { return Observable.Zip(ContextAttributeValue, ctx, ctorMsg, (ContextAttributeValueLambda, ctxLambda, ctorMsgLambda) => ContextAttributeValueLambda.IsContextOK(ctxLambda, ctorMsgLambda)); } public static IObservable<System.Reactive.Unit> GetPropertiesForNewContext( this IObservable<System.Runtime.Remoting.Contexts.ContextAttribute> ContextAttributeValue, IObservable<System.Runtime.Remoting.Activation.IConstructionCallMessage> ctorMsg) { return ObservableExt.ZipExecute(ContextAttributeValue, ctorMsg, (ContextAttributeValueLambda, ctorMsgLambda) => ContextAttributeValueLambda.GetPropertiesForNewContext(ctorMsgLambda)); } public static IObservable<System.String> get_Name( this IObservable<System.Runtime.Remoting.Contexts.ContextAttribute> ContextAttributeValue) { return Observable.Select(ContextAttributeValue, (ContextAttributeValueLambda) => ContextAttributeValueLambda.Name); } } }
RixianOpenTech/RxWrappers
Source/Wrappers/mscorlib/System.Runtime.Remoting.Contexts.ContextAttribute.cs
C#
mit
3,328
# -*- coding: utf-8 -*- # # Copyright (C) 2008 John Paulett (john -at- paulett.org) # Copyright (C) 2009, 2011, 2013 David Aguilar (davvid -at- gmail.com) # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. """Python library for serializing any arbitrary object graph into JSON. jsonpickle can take almost any Python object and turn the object into JSON. Additionally, it can reconstitute the object back into Python. The object must be accessible globally via a module and must inherit from object (AKA new-style classes). Create an object:: class Thing(object): def __init__(self, name): self.name = name obj = Thing('Awesome') Use jsonpickle to transform the object into a JSON string:: import jsonpickle frozen = jsonpickle.encode(obj) Use jsonpickle to recreate a Python object from a JSON string:: thawed = jsonpickle.decode(frozen) .. warning:: Loading a JSON string from an untrusted source represents a potential security vulnerability. jsonpickle makes no attempt to sanitize the input. The new object has the same type and data, but essentially is now a copy of the original. .. code-block:: python assert obj.name == thawed.name If you will never need to load (regenerate the Python class from JSON), you can pass in the keyword unpicklable=False to prevent extra information from being added to JSON:: oneway = jsonpickle.encode(obj, unpicklable=False) result = jsonpickle.decode(oneway) assert obj.name == result['name'] == 'Awesome' """ import sys, os from music21 import common sys.path.append(common.getSourceFilePath() + os.path.sep + 'ext') from jsonpickle import pickler from jsonpickle import unpickler from jsonpickle.backend import JSONBackend from jsonpickle.version import VERSION # ensure built-in handlers are loaded __import__('jsonpickle.handlers') __all__ = ('encode', 'decode') __version__ = VERSION json = JSONBackend() # Export specific JSONPluginMgr methods into the jsonpickle namespace set_preferred_backend = json.set_preferred_backend set_encoder_options = json.set_encoder_options load_backend = json.load_backend remove_backend = json.remove_backend enable_fallthrough = json.enable_fallthrough def encode(value, unpicklable=True, make_refs=True, keys=False, max_depth=None, backend=None, warn=False, max_iter=None): """Return a JSON formatted representation of value, a Python object. :param unpicklable: If set to False then the output will not contain the information necessary to turn the JSON data back into Python objects, but a simpler JSON stream is produced. :param max_depth: If set to a non-negative integer then jsonpickle will not recurse deeper than 'max_depth' steps into the object. Anything deeper than 'max_depth' is represented using a Python repr() of the object. :param make_refs: If set to False jsonpickle's referencing support is disabled. Objects that are id()-identical won't be preserved across encode()/decode(), but the resulting JSON stream will be conceptually simpler. jsonpickle detects cyclical objects and will break the cycle by calling repr() instead of recursing when make_refs is set False. :param keys: If set to True then jsonpickle will encode non-string dictionary keys instead of coercing them into strings via `repr()`. :param warn: If set to True then jsonpickle will warn when it returns None for an object which it cannot pickle (e.g. file descriptors). :param max_iter: If set to a non-negative integer then jsonpickle will consume at most `max_iter` items when pickling iterators. >>> encode('my string') '"my string"' >>> encode(36) '36' >>> encode({'foo': True}) '{"foo": true}' >>> encode({'foo': True}, max_depth=0) '"{\\'foo\\': True}"' >>> encode({'foo': True}, max_depth=1) '{"foo": "True"}' """ if backend is None: backend = json return pickler.encode(value, backend=backend, unpicklable=unpicklable, make_refs=make_refs, keys=keys, max_depth=max_depth, warn=warn) def decode(string, backend=None, keys=False): """Convert a JSON string into a Python object. The keyword argument 'keys' defaults to False. If set to True then jsonpickle will decode non-string dictionary keys into python objects via the jsonpickle protocol. >>> str(decode('"my string"')) 'my string' >>> decode('36') 36 """ if backend is None: backend = json return unpickler.decode(string, backend=backend, keys=keys) # json.load(),loads(), dump(), dumps() compatibility dumps = encode loads = decode
arnavd96/Cinemiezer
myvenv/lib/python3.4/site-packages/music21/ext/jsonpickle/__init__.py
Python
mit
5,049
require 'spec_helper' describe "beings/show" do before(:each) do @being = FactoryGirl.create(:being) @being.randomize! end end
slabgorb/populinator-0
spec/views/beings/show.html.haml_spec.rb
Ruby
mit
142
import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; class ProteinTranslator { private static final Integer CODON_LENGTH = 3; private static final Map<String, String> CODON_TO_PROTEIN = Map.ofEntries( Map.entry("AUG", "Methionine"), Map.entry("UUU", "Phenylalanine"), Map.entry("UUC", "Phenylalanine"), Map.entry("UUA", "Leucine"), Map.entry("UUG", "Leucine"), Map.entry("UCU", "Serine"), Map.entry("UCC", "Serine"), Map.entry("UCA", "Serine"), Map.entry("UCG", "Serine"), Map.entry("UAU", "Tyrosine"), Map.entry("UAC", "Tyrosine"), Map.entry("UGU", "Cysteine"), Map.entry("UGC", "Cysteine"), Map.entry("UGG", "Tryptophan")); private static final Set<String> STOP_CODONS = Set.of("UAA", "UAG", "UGA"); public List<String> translate(final String rnaSequence) { final List<String> codons = splitIntoCodons(rnaSequence); List<String> proteins = new ArrayList<>(); for (String codon : codons) { if (STOP_CODONS.contains(codon)) { return proteins; } proteins.add(translateCodon(codon)); } ; return proteins; } private static List<String> splitIntoCodons(final String rnaSequence) { final List<String> codons = new ArrayList<>(); for (int i = 0; i < rnaSequence.length(); i += CODON_LENGTH) { codons.add(rnaSequence.substring(i, Math.min(rnaSequence.length(), i + CODON_LENGTH))); } return codons; } private static String translateCodon(final String codon) { return CODON_TO_PROTEIN.get(codon); } }
rootulp/exercism
java/protein-translation/src/main/java/ProteinTranslator.java
Java
mit
1,679
# -*- coding: utf-8 -*- """ Created on Wed Sep 09 13:04:53 2015 * If TimerTool.exe is running, kill the process. * If input parameter is given, start TimerTool and set clock resolution Starts TimerTool.exe and sets the clock resolution to argv[0] ms Ex: python set_clock_resolution 0.5 @author: marcus """ import time, datetime from socket import gethostname, gethostbyname import os import numpy as np def main(): my_path = os.path.join('C:',os.sep,'Share','sync_clocks') os.chdir(my_path) # Initial timestamps t1 = time.clock() t2 = time.time() t3 = datetime.datetime.now() td1 = [] td2 = [] td3 = [] for i in xrange(100): td1.append(time.clock()-t1) td2.append(time.time() -t2) td3.append((datetime.datetime.now()-t3).total_seconds()) time.sleep(0.001) # Create text file and write header t = datetime.datetime.now() ip = gethostbyname(gethostname()).split('.')[-1] f_name = '_'.join([ip,'test_clock_res',str(t.year),str(t.month),str(t.day), str(t.hour),str(t.minute),str(t.second)]) f = open(f_name+'.txt','w') f.write('%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' % ('mean_clock','median_clock','sd_clock', 'mean_time','median_time','sd_time', 'mean_datetime','median_datetime','sd_datetime',)) # Write results to text file f.write('%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\n' % (np.mean(np.diff(td1))*1000, np.median(np.diff(td1))*1000,np.std(np.diff(td1))*1000, np.mean(np.diff(td2))*1000, np.median(np.diff(td2))*1000,np.std(np.diff(td2))*1000, np.mean(np.diff(td3))*1000, np.median(np.diff(td3))*1000,np.std(np.diff(td3))*1000)) f.close() if __name__ == "__main__": main()
marcus-nystrom/share-gaze
sync_clocks/test_clock_resolution.py
Python
mit
1,930
<?php use Illuminate\Database\Seeder; use jeremykenedy\LaravelRoles\Models\Permission; class PermissionsTableSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { /* * Add Permissions * */ if (Permission::where('name', '=', 'Can View Users')->first() === null) { Permission::create([ 'name' => 'Can View Users', 'slug' => 'view.users', 'description' => 'Can view users', 'model' => 'Permission', ]); } if (Permission::where('name', '=', 'Can Create Users')->first() === null) { Permission::create([ 'name' => 'Can Create Users', 'slug' => 'create.users', 'description' => 'Can create new users', 'model' => 'Permission', ]); } if (Permission::where('name', '=', 'Can Edit Users')->first() === null) { Permission::create([ 'name' => 'Can Edit Users', 'slug' => 'edit.users', 'description' => 'Can edit users', 'model' => 'Permission', ]); } if (Permission::where('name', '=', 'Can Delete Users')->first() === null) { Permission::create([ 'name' => 'Can Delete Users', 'slug' => 'delete.users', 'description' => 'Can delete users', 'model' => 'Permission', ]); } if (Permission::where('name', '=', 'Super Admin Permissions')->first() === null) { Permission::create([ 'name' => 'Super Admin Permissions', 'slug' => 'perms.super-admin', 'description' => 'Has Super Admin Permissions', 'model' => 'Permission', ]); } if (Permission::where('name', '=', 'Admin Permissions')->first() === null) { Permission::create([ 'name' => 'Admin Permissions', 'slug' => 'perms.admin', 'description' => 'Has Admin Permissions', 'model' => 'Permission', ]); } if (Permission::where('name', '=', 'Moderator Permissions')->first() === null) { Permission::create([ 'name' => 'Moderator Permissions', 'slug' => 'perms.moderator', 'description' => 'Has Moderator Permissions', 'model' => 'Permission', ]); } if (Permission::where('name', '=', 'Writer Permissions')->first() === null) { Permission::create([ 'name' => 'Writer Permissions', 'slug' => 'perms.writer', 'description' => 'Has Writer Permissions', 'model' => 'Permission', ]); } if (Permission::where('name', '=', 'User Permissions')->first() === null) { Permission::create([ 'name' => 'User Permissions', 'slug' => 'perms.user', 'description' => 'Has User Permissions', 'model' => 'Permission', ]); } } }
jeremykenedy/larablog
database/seeds/PermissionsTableSeeder.php
PHP
mit
3,481
#------------------------------------------------------------------------------- # osx.cmake # Fips cmake settings file for OSX target platform. #------------------------------------------------------------------------------- set(FIPS_PLATFORM OSX) set(FIPS_PLATFORM_NAME "osx") set(FIPS_MACOS 1) set(FIPS_OSX 1) set(FIPS_POSIX 1) set(CMAKE_XCODE_GENERATE_SCHEME 1) # define configuration types set(CMAKE_CONFIGURATION_TYPES Debug Release) if (FIPS_OSX_UNIVERSAL) set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64") endif() # FIXME: define standard frame works that are always linked set(FIPS_OSX_STANDARD_FRAMEWORKS Foundation IOKit) # compiler flags set(CMAKE_CXX_FLAGS "-fstrict-aliasing -Wno-expansion-to-defined -Wno-multichar -Wall -Wextra -Wno-unknown-pragmas -Wno-ignored-qualifiers -Wno-long-long -Wno-overloaded-virtual -Wno-unused-volatile-lvalue -Wno-deprecated-writable-strings") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "-O0 -D_DEBUG_ -D_DEBUG -DFIPS_DEBUG=1 -ggdb") set(CMAKE_C_FLAGS "-fstrict-aliasing -Wno-multichar -Wall -Wextra -Wno-expansion-to-defined -Wno-unknown-pragmas -Wno-ignored-qualifiers -Wno-long-long -Wno-overloaded-virtual -Wno-unused-volatile-lvalue -Wno-deprecated-writable-strings") set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") set(CMAKE_C_FLAGS_DEBUG "-O0 -D_DEBUG_ -D_DEBUG -DFIPS_DEBUG=1 -g") set(CMAKE_EXE_LINKER_FLAGS "-ObjC -dead_strip -lpthread") set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") set(CMAKE_EXE_LINKER_FLAGS_RELEASE "") # need to set some flags directly as Xcode attributes set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14") set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") # stack-checking? enabling this leads may generate binaries # that are not backward compatible to older macOS versions option(FIPS_OSX_USE_STACK_CHECKING "Enable/disable stack checking" OFF) if (FIPS_OSX_USE_STACK_CHECKING) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-check") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-check") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-check") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-stack-check") endif() # ARC on/off? option(FIPS_OSX_USE_ARC "Enable/disable Automatic Reference Counting" OFF) if (FIPS_OSX_USE_ARC) set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-arc") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fobjc-arc") else() set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "NO") endif() # exceptions on/off? if (FIPS_EXCEPTIONS) set(CMAKE_XCODE_ATTRIBUTE_GCC_ENABLE_CPP_EXCEPTIONS "YES") else() set(CMAKE_XCODE_ATTRIBUTE_GCC_ENABLE_CPP_EXCEPTIONS "NO") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") endif() # rtti on/off? if (FIPS_RTTI) set(CMAKE_XCODE_ATTRIBUTE_GCC_ENABLE_CPP_RTTI "YES") else() set(CMAKE_XCODE_ATTRIBUTE_GCC_ENABLE_CPP_RTTI "NO") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") endif() # clang address sanitizer? if (FIPS_CLANG_ADDRESS_SANITIZER) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") endif() # clang 'save-optimization-record'? if (FIPS_CLANG_SAVE_OPTIMIZATION_RECORD) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsave-optimization-record") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsave-optimization-record") endif() # update cache variables for cmake gui set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Config Type" FORCE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "Generic C++ Compiler Flags" FORCE) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "C++ Debug Compiler Flags" FORCE) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "C++ Release Compiler Flags" FORCE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "Generic C Compiler Flags" FORCE) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING "C Debug Compiler Flags" FORCE) set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "C Release Compiler Flags" FORCE) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "Generic Linker Flags" FORCE) set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING "Debug Linker Flags" FORCE) set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}" CACHE STRING "Release Linker Flags" FORCE) # set the build type to use if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Compile Type" FORCE) endif() set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release)
floooh/fips
cmake-toolchains/osx.cmake
CMake
mit
4,722
# maton 👀 Watch a machine's load and display it beautifully ✨ Even if this project is originally a technical test for an interview, I used it to try some tools that either I never had the chance to experiment with, or I wanted to know better. ## ⚒ Tools ### NodeJS and express I never used them in a big project, only in small proof of concepts. This was the occasion to improve my skills. ### Socket.io I wanted to use it since a long time ! And afterwards, I really like its simplicity. ### D3.js A lot like Socket.io, I waited for some pretext to use it. It's really popular and wanted to know why ! It indeed makes graph pretty easy to build, but in some cases it don't fit really well with React and functional programming (like for graph's axis). ### Next.js I really like the stack React / ES6 / Webpack & co, and when I heard of this new all-inclusive framework which embed theses technologies without having to configure them, I wanted to know if there's any drawbacks. Spoiler alert : there are some, but it's really good. ## 🏛 App architecture The app has three main parts : - *The probes* [`/probe`](https://github.com/thibthib/maton/tree/master/probe/) is the tiny bit of code responsible of measuring stuff and sending it to... - *The server* [`/server`](https://github.com/thibthib/maton/tree/master/server/) is where the measures (only the load for now) are stored. It has an API entry point for getting data as well as a socket that sends events for each new measure or alert to... - *The dashboards* [`/pages`](https://github.com/thibthib/maton/tree/master/pages/) (I would have named it dashboard if I could) is where we display meaningful and beautiful graphs and alerts. ## How-to run `npm start` ## 📈 Improvements plan [➡️ For the probes, follow me](https://github.com/thibthib/maton/tree/master/probe/) [➡️ For the server, it's here](https://github.com/thibthib/maton/tree/master/server) For the dashboard, stay here - **Share more with the server** : There's a lot of stuff (events, configuration) that's common to both server and dashboards. I shared a little, but there's still work to do (alerts threshold, graph time span, etc...). - **Add responsiveness** : The graph and the interface in general don't really scale to devices. not good. - **Rewrite graph axis** : The easiest (and quickest) solution to add them was to let D3.js handle their rendering. All the application is rendered with React, the axis along with it. - **Regain control of front-end stack** : Next.js is pretty awesome in that you can start coding your app without any configuration. And it comes with a LOT of cool stuff, like server side rendering. But this seems made more for static websites rather than complex webapps, as there are some choices made for you that won't necessarily fit your needs : - I couldn't put the dashboard part of the app into its own module as Next.js can't load files outside its directory - The use of Glamor (CSS in JS) for styling isn't easy to apprehend. - As the code is totally shared between server and browser, you have to load polyfills for both. This isn't optimal, like at all. - **Display other probes** : everything in the server is ready to display data from different probes ! The dashboard just don't implement it. So sad 😟
thibthib/maton
README.md
Markdown
mit
3,314
# MpiSyncManager Aplikasi Mpi Sync Manager
trogalko/MpiSyncManager
README.md
Markdown
mit
43
using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; namespace TrueSync.Physics2D { // Original Code by Steven Lu - see http://www.box2d.org/forum/viewtopic.php?f=3&t=1688 // Ported to Farseer 3.0 by Nicolás Hormazábal internal struct ShapeData { public Body Body; public FP Max; public FP Min; // absolute angles } /// <summary> /// This is a comprarer used for /// detecting angle difference between rays /// </summary> internal class RayDataComparer : IComparer<FP> { #region IComparer<FP> Members int IComparer<FP>.Compare(FP a, FP b) { FP diff = (a - b); if (diff > 0) return 1; if (diff < 0) return -1; return 0; } #endregion } /* Methodology: * Force applied at a ray is inversely proportional to the square of distance from source * AABB is used to query for shapes that may be affected * For each RIGID BODY (not shape -- this is an optimization) that is matched, loop through its vertices to determine * the extreme points -- if there is structure that contains outlining polygon, use that as an additional optimization * Evenly cast a number of rays against the shape - number roughly proportional to the arc coverage * - Something like every 3 degrees should do the trick although this can be altered depending on the distance (if really close don't need such a high density of rays) * - There should be a minimum number of rays (3-5?) applied to each body so that small bodies far away are still accurately modeled * - Be sure to have the forces of each ray be proportional to the average arc length covered by each. * For each ray that actually intersects with the shape (non intersections indicate something blocking the path of explosion): * - Apply the appropriate force dotted with the negative of the collision normal at the collision point * - Optionally apply linear interpolation between aforementioned Normal force and the original explosion force in the direction of ray to simulate "surface friction" of sorts */ /// <summary> /// Creates a realistic explosion based on raycasting. Objects in the open will be affected, but objects behind /// static bodies will not. A body that is half in cover, half in the open will get half the force applied to the end in /// the open. /// </summary> public sealed class RealExplosion : PhysicsLogic { /// <summary> /// Two degrees: maximum angle from edges to first ray tested /// </summary> private static readonly FP MaxEdgeOffset = FP.Pi / 90; /// <summary> /// Ratio of arc length to angle from edges to first ray tested. /// Defaults to 1/40. /// </summary> public FP EdgeRatio = 1.0f / 40.0f; /// <summary> /// Ignore Explosion if it happens inside a shape. /// Default value is false. /// </summary> public bool IgnoreWhenInsideShape = false; /// <summary> /// Max angle between rays (used when segment is large). /// Defaults to 15 degrees /// </summary> public FP MaxAngle = FP.Pi / 15; /// <summary> /// Maximum number of shapes involved in the explosion. /// Defaults to 100 /// </summary> public int MaxShapes = 100; /// <summary> /// How many rays per shape/body/segment. /// Defaults to 5 /// </summary> public int MinRays = 5; private List<ShapeData> _data = new List<ShapeData>(); private RayDataComparer _rdc; public RealExplosion(World world) : base(world, PhysicsLogicType.Explosion) { _rdc = new RayDataComparer(); _data = new List<ShapeData>(); } /// <summary> /// Activate the explosion at the specified position. /// </summary> /// <param name="pos">The position where the explosion happens </param> /// <param name="radius">The explosion radius </param> /// <param name="maxForce">The explosion force at the explosion point (then is inversely proportional to the square of the distance)</param> /// <returns>A list of bodies and the amount of force that was applied to them.</returns> public Dictionary<Fixture, TSVector2> Activate(TSVector2 pos, FP radius, FP maxForce) { AABB aabb; aabb.LowerBound = pos + new TSVector2(-radius, -radius); aabb.UpperBound = pos + new TSVector2(radius, radius); Fixture[] shapes = new Fixture[MaxShapes]; // More than 5 shapes in an explosion could be possible, but still strange. Fixture[] containedShapes = new Fixture[5]; bool exit = false; int shapeCount = 0; int containedShapeCount = 0; // Query the world for overlapping shapes. World.QueryAABB( fixture => { if (fixture.TestPoint(ref pos)) { if (IgnoreWhenInsideShape) { exit = true; return false; } containedShapes[containedShapeCount++] = fixture; } else { shapes[shapeCount++] = fixture; } // Continue the query. return true; }, ref aabb); if (exit) return new Dictionary<Fixture, TSVector2>(); Dictionary<Fixture, TSVector2> exploded = new Dictionary<Fixture, TSVector2>(shapeCount + containedShapeCount); // Per shape max/min angles for now. FP[] vals = new FP[shapeCount * 2]; int valIndex = 0; for (int i = 0; i < shapeCount; ++i) { PolygonShape ps; CircleShape cs = shapes[i].Shape as CircleShape; if (cs != null) { // We create a "diamond" approximation of the circle Vertices v = new Vertices(); TSVector2 vec = TSVector2.zero + new TSVector2(cs.Radius, 0); v.Add(vec); vec = TSVector2.zero + new TSVector2(0, cs.Radius); v.Add(vec); vec = TSVector2.zero + new TSVector2(-cs.Radius, cs.Radius); v.Add(vec); vec = TSVector2.zero + new TSVector2(0, -cs.Radius); v.Add(vec); ps = new PolygonShape(v, 0); } else ps = shapes[i].Shape as PolygonShape; if ((shapes[i].Body.BodyType == BodyType.Dynamic) && ps != null) { TSVector2 toCentroid = shapes[i].Body.GetWorldPoint(ps.MassData.Centroid) - pos; FP angleToCentroid = FP.Atan2(toCentroid.y, toCentroid.x); FP min = FP.MaxValue; FP max = FP.MinValue; FP minAbsolute = 0.0f; FP maxAbsolute = 0.0f; for (int j = 0; j < ps.Vertices.Count; ++j) { TSVector2 toVertex = (shapes[i].Body.GetWorldPoint(ps.Vertices[j]) - pos); FP newAngle = FP.Atan2(toVertex.y, toVertex.x); FP diff = (newAngle - angleToCentroid); diff = (diff - FP.Pi) % (2 * FP.Pi); // the minus pi is important. It means cutoff for going other direction is at 180 deg where it needs to be if (diff < 0.0f) diff += 2 * FP.Pi; // correction for not handling negs diff -= FP.Pi; if (FP.Abs(diff) > FP.Pi) continue; // Something's wrong, point not in shape but exists angle diff > 180 if (diff > max) { max = diff; maxAbsolute = newAngle; } if (diff < min) { min = diff; minAbsolute = newAngle; } } vals[valIndex] = minAbsolute; ++valIndex; vals[valIndex] = maxAbsolute; ++valIndex; } } Array.Sort(vals, 0, valIndex, _rdc); _data.Clear(); bool rayMissed = true; for (int i = 0; i < valIndex; ++i) { Fixture fixture = null; FP midpt; int iplus = (i == valIndex - 1 ? 0 : i + 1); if (vals[i] == vals[iplus]) continue; if (i == valIndex - 1) { // the single edgecase midpt = (vals[0] + FP.PiTimes2 + vals[i]); } else { midpt = (vals[i + 1] + vals[i]); } midpt = midpt / 2; TSVector2 p1 = pos; TSVector2 p2 = radius * new TSVector2(FP.Cos(midpt), FP.Sin(midpt)) + pos; // RaycastOne bool hitClosest = false; World.RayCast((f, p, n, fr) => { Body body = f.Body; if (!IsActiveOn(body)) return 0; hitClosest = true; fixture = f; return fr; }, p1, p2); //draws radius points if ((hitClosest) && (fixture.Body.BodyType == BodyType.Dynamic)) { if ((_data.Any()) && (_data.Last().Body == fixture.Body) && (!rayMissed)) { int laPos = _data.Count - 1; ShapeData la = _data[laPos]; la.Max = vals[iplus]; _data[laPos] = la; } else { // make new ShapeData d; d.Body = fixture.Body; d.Min = vals[i]; d.Max = vals[iplus]; _data.Add(d); } if ((_data.Count > 1) && (i == valIndex - 1) && (_data.Last().Body == _data.First().Body) && (_data.Last().Max == _data.First().Min)) { ShapeData fi = _data[0]; fi.Min = _data.Last().Min; _data.RemoveAt(_data.Count - 1); _data[0] = fi; while (_data.First().Min >= _data.First().Max) { fi.Min -= FP.PiTimes2; _data[0] = fi; } } int lastPos = _data.Count - 1; ShapeData last = _data[lastPos]; while ((_data.Count > 0) && (_data.Last().Min >= _data.Last().Max)) // just making sure min<max { last.Min = _data.Last().Min - FP.PiTimes2; _data[lastPos] = last; } rayMissed = false; } else { rayMissed = true; // raycast did not find a shape } } for (int i = 0; i < _data.Count; ++i) { if (!IsActiveOn(_data[i].Body)) continue; FP arclen = _data[i].Max - _data[i].Min; FP first = TSMath.Min(MaxEdgeOffset, EdgeRatio * arclen); int insertedRays = FP.Ceiling((((arclen - 2.0f * first) - (MinRays - 1) * MaxAngle) / MaxAngle)).AsInt(); if (insertedRays < 0) insertedRays = 0; FP offset = (arclen - first * 2.0f) / ((FP)MinRays + insertedRays - 1); //Note: This loop can go into infinite as it operates on FPs. //Added FPEquals with a large epsilon. for (FP j = _data[i].Min + first; j < _data[i].Max || MathUtils.FPEquals(j, _data[i].Max, 0.0001f); j += offset) { TSVector2 p1 = pos; TSVector2 p2 = pos + radius * new TSVector2(FP.Cos(j), FP.Sin(j)); TSVector2 hitpoint = TSVector2.zero; FP minlambda = FP.MaxValue; List<Fixture> fl = _data[i].Body.FixtureList; for (int x = 0; x < fl.Count; x++) { Fixture f = fl[x]; RayCastInput ri; ri.Point1 = p1; ri.Point2 = p2; ri.MaxFraction = 50f; RayCastOutput ro; if (f.RayCast(out ro, ref ri, 0)) { if (minlambda > ro.Fraction) { minlambda = ro.Fraction; hitpoint = ro.Fraction * p2 + (1 - ro.Fraction) * p1; } } // the force that is to be applied for this particular ray. // offset is angular coverage. lambda*length of segment is distance. FP impulse = (arclen / (MinRays + insertedRays)) * maxForce * 180.0f / FP.Pi * (1.0f - TrueSync.TSMath.Min(FP.One, minlambda)); // We Apply the impulse!!! TSVector2 vectImp = TSVector2.Dot(impulse * new TSVector2(FP.Cos(j), FP.Sin(j)), -ro.Normal) * new TSVector2(FP.Cos(j), FP.Sin(j)); _data[i].Body.ApplyLinearImpulse(ref vectImp, ref hitpoint); // We gather the fixtures for returning them if (exploded.ContainsKey(f)) exploded[f] += vectImp; else exploded.Add(f, vectImp); if (minlambda > 1.0f) hitpoint = p2; } } } // We check contained shapes for (int i = 0; i < containedShapeCount; ++i) { Fixture fix = containedShapes[i]; if (!IsActiveOn(fix.Body)) continue; FP impulse = MinRays * maxForce * 180.0f / FP.Pi; TSVector2 hitPoint; CircleShape circShape = fix.Shape as CircleShape; if (circShape != null) { hitPoint = fix.Body.GetWorldPoint(circShape.Position); } else { PolygonShape shape = fix.Shape as PolygonShape; hitPoint = fix.Body.GetWorldPoint(shape.MassData.Centroid); } TSVector2 vectImp = impulse * (hitPoint - pos); fix.Body.ApplyLinearImpulse(ref vectImp, ref hitPoint); if (!exploded.ContainsKey(fix)) exploded.Add(fix, vectImp); } return exploded; } } }
Xaer033/YellowSign
YellowSignUnity/Assets/ThirdParty/Networking/TrueSync/Physics/Farseer/Common/PhysicsLogic/RealExplosion.cs
C#
mit
16,308
<?php /* * This file is part of the Sonata project. * * (c) Thomas Rabaix <[email protected]> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sonata\MediaBundle\Tests\Validator; use Sonata\MediaBundle\Provider\Pool; use Sonata\MediaBundle\Validator\Constraints\ValidMediaFormat; use Sonata\MediaBundle\Validator\FormatValidator; class FormatValidatorTest extends \PHPUnit_Framework_TestCase { public function testValidate() { $pool = new Pool('defaultContext'); $pool->addContext('test', array(), array('format1' => array())); $gallery = $this->getMock('Sonata\MediaBundle\Model\GalleryInterface'); $gallery->expects($this->once())->method('getDefaultFormat')->will($this->returnValue('format1')); $gallery->expects($this->once())->method('getContext')->will($this->returnValue('test')); // Prefer the Symfony 2.5+ API if available if (class_exists('Symfony\Component\Validator\Context\ExecutionContext')) { $contextClass = 'Symfony\Component\Validator\Context\ExecutionContext'; } else { $contextClass = 'Symfony\Component\Validator\ExecutionContext'; } $context = $this->getMock($contextClass, array(), array(), '', false); $context->expects($this->never())->method('addViolation'); $validator = new FormatValidator($pool); $validator->initialize($context); $validator->validate($gallery, new ValidMediaFormat()); } public function testValidateWithValidContext() { $pool = new Pool('defaultContext'); $pool->addContext('test'); $gallery = $this->getMock('Sonata\MediaBundle\Model\GalleryInterface'); $gallery->expects($this->once())->method('getDefaultFormat')->will($this->returnValue('format1')); $gallery->expects($this->once())->method('getContext')->will($this->returnValue('test')); // Prefer the Symfony 2.5+ API if available if (class_exists('Symfony\Component\Validator\Context\ExecutionContext')) { $contextClass = 'Symfony\Component\Validator\Context\ExecutionContext'; } else { $contextClass = 'Symfony\Component\Validator\ExecutionContext'; } $context = $this->getMock($contextClass, array(), array(), '', false); $context->expects($this->once())->method('addViolation'); $validator = new FormatValidator($pool); $validator->initialize($context); $validator->validate($gallery, new ValidMediaFormat()); } }
DevKhater/YallaWebSite
vendor/sonata-project/media-bundle/Tests/Validator/FormatValidatorTest.php
PHP
mit
2,647
--- layout: page title: "2016Google校招笔试-Not So Random" subheadline: teaser: "今天参加宣讲会模拟面试的题目,来源Google APAC 2016 University Graduates Test Round E Problem C。Google开始校招了,而我还是这么弱鸡..." categories: - share - algorithm tags: - Algorithm header: no image: thumb: gallery-example-4-thumb.jpg title: gallery-example-4.jpg caption: Google 2016 ACPC University Graduates Test Round E最后排名,我想说的是老印真是厉害。 caption_url: https://code.google.com/codejam/contest/8264486/scoreboard# --- # 题目描述 有一个随机数字生成函数,对于一个输入X,有A/100的概率生成 ```X AND K```,有B/100的概率生成 ```X OR K``` ,有C/100的概率生成 ```X XOR K``` 。 0 ≤ X, K ≤ 10^9,0 ≤ A, B, C ≤ 100,A+B+C = 100。 现在假设有N个这样的随机数字生成函数,问最后输出数字的期望值。 # 思路 对于数字二进制下的每一位只有两种状态**0**或者**1**,同时每一位相互独立,所以可以分开考虑每一位,就算出经过N步之后每一位为1的概率,则最后的期望可以表示为:$ expect = \sum_{j=0}^{31} {p_j * (1 << j)} $ ,$p_j$表示经过N步随机数字生成函数后第j位为1的概率。 所以,有DP: 令dp[i][j][s]表示经过i步随机数字生成函数后第j位状态为s的概率,s = 0 / 1,有状态转移方程: ```If (k & (1 << j)) > 0 :``` ```dp[i][j][0] += dp[i-1][j][0] * a / 100``` ```dp[i][j][0] += dp[i-1][j][1] * c / 100``` ```dp[i][j][1] += dp[i-1][j][1] * a / 100``` ```dp[i][j][1] += dp[i-1][j][0] * b / 100``` ```dp[i][j][1] += dp[i-1][j][1] * b / 100``` ```dp[i][j][1] += dp[i-1][j][0] * c / 100``` ```Else :``` ```dp[i][j][0] += dp[i-1][j][0] * a / 100``` ```dp[i][j][0] += dp[i-1][j][1] * a / 100``` ```dp[i][j][0] += dp[i-1][j][0] * b / 100``` ```dp[i][j][0] += dp[i-1][j][0] * c / 100``` ```dp[i][j][1] += dp[i-1][j][1] * b / 100``` ```dp[i][j][1] += dp[i-1][j][1] * c / 100``` 初始化,则根据X的每一位0或者1,对dp[0][j][0]和dp[0][j][1]赋值1或者0。 # 代码 <pre class="brush: cpp; highlight: [23, 35] auto-links: true; collapse: true" id = "simpleblock"> #include <bits/stdc++.h> using namespace std; #define clr(x,c) memset(x, c, sizeof(x)) #define pb push_back #define mp make_pair #define pii pair<int, int> #define psi pair<string, int> #define inf 0x3f3f3f3f typedef long long lld; const int N = 111111; const int M = 31; // x & k >= 0, bit(31) = 0 double dp[N][M][2]; double solve() { double ret = 0.0; int n, x, k, a, b, c; cin >> n >> x >> k >> a >> b >> c; // init clr(dp, 0); for (int j = 0; j < M; ++j) { if ( x & (1 << j) ) { dp[0][j][0] = 0.0; dp[0][j][1] = 1.0; } else { dp[0][j][0] = 1.0; dp[0][j][1] = 0.0; } } // dp for (int j = 0; j < M; ++j) { for (int i = 1; i <= n; ++i) { if ( k & (1 << j) ) { dp[i][j][0] += dp[i-1][j][0] * a / 100; dp[i][j][0] += dp[i-1][j][1] * c / 100; dp[i][j][1] += dp[i-1][j][1] * a / 100; dp[i][j][1] += (dp[i-1][j][0] + dp[i-1][j][1]) * b / 100; dp[i][j][1] += dp[i-1][j][0] * c / 100; } else { dp[i][j][0] += (dp[i-1][j][0] + dp[i-1][j][1]) * a / 100; dp[i][j][0] += dp[i-1][j][0] * b / 100; dp[i][j][0] += dp[i-1][j][0] * c / 100; dp[i][j][1] += dp[i-1][j][1] * b / 100; dp[i][j][1] += dp[i-1][j][1] * c / 100; } } ret += dp[n][j][1] * (1 << j); } return ret; } int main () { freopen("F:/#test-data/in.txt", "r", stdin); freopen("F:/#test-data/out.txt", "w", stdout); ios::sync_with_stdio(false); cin.tie(0); cout << fixed << showpoint; int t; cin >> t; for (int cas = 1; cas <= t; ++cas) { cout << "Case #" << cas << ": "; cout << setprecision(9) << solve() << endl; } return 0; } </pre>
goudan-er/goudan-er.github.io
_posts/Algorithm/2016-05-09-Google-APAC-2016-RoundE-Problem-C.md
Markdown
mit
4,098
require "rails_helper" describe Linter::Shellcheck do it_behaves_like "a linter" do let(:lintable_files) { %w(foo.sh foo.zsh foo.bash) } let(:not_lintable_files) { %w(foo.js) } end describe "#file_review" do it "returns a saved and incomplete file review" do commit_file = build_commit_file(filename: "lib/a.sh") linter = build_linter result = linter.file_review(commit_file) expect(result).to be_persisted expect(result).not_to be_completed end it "schedules a review job" do build = build(:build, commit_sha: "foo", pull_request_number: 123) commit_file = build_commit_file(filename: "lib/a.sh") allow(LintersJob).to receive(:perform_async) linter = build_linter(build) linter.file_review(commit_file) expect(LintersJob).to have_received(:perform_async).with( filename: commit_file.filename, commit_sha: build.commit_sha, linter_name: "shellcheck", pull_request_number: build.pull_request_number, patch: commit_file.patch, content: commit_file.content, config: "--- {}\n", linter_version: nil, ) end end end
thoughtbot/hound
spec/models/linter/shellcheck_spec.rb
Ruby
mit
1,185
-- This query extracts dose+durations of neuromuscular blocking agents -- Note: we assume that injections will be filtered for carevue as they will have starttime = stopttime. -- Get drug administration data from CareVue and MetaVision -- metavision is simple and only requires one temporary table with drugmv as ( select icustay_id, orderid , rate as vaso_rate , amount as vaso_amount , starttime , endtime from inputevents_mv where itemid in ( 222062 -- Vecuronium (664 rows, 154 infusion rows) , 221555 -- Cisatracurium (9334 rows, 8970 infusion rows) ) and statusdescription != 'Rewritten' -- only valid orders and rate is not null -- only continuous infusions ) , drugcv1 as ( select icustay_id, charttime -- where clause below ensures all rows are instance of the drug , 1 as drug -- the 'stopped' column indicates if a drug has been disconnected , max(case when stopped in ('Stopped','D/C''d') then 1 else 0 end) as drug_stopped -- we only include continuous infusions, therefore expect a rate , max(case -- for "free form" entries (itemid >= 40000) rate is not available when itemid >= 40000 and amount is not null then 1 when itemid < 40000 and rate is not null then 1 else 0 end) as drug_null , max(case -- for "free form" entries (itemid >= 40000) rate is not available when itemid >= 40000 then coalesce(rate, amount) else rate end) as drug_rate , max(amount) as drug_amount from inputevents_cv where itemid in ( 30114 -- Cisatracurium (63994 rows) , 30138 -- Vecuronium (5160 rows) , 30113 -- Atracurium (1163 rows) -- Below rows are less frequent ad-hoc documentation, but worth including! , 42174 -- nimbex cc/hr (207 rows) , 42385 -- Cisatracurium gtt (156 rows) , 41916 -- NIMBEX inputevents_cv (136 rows) , 42100 -- cistatracurium (132 rows) , 42045 -- nimbex mcg/kg/min (78 rows) , 42246 -- CISATRICARIUM CC/HR (70 rows) , 42291 -- NIMBEX CC/HR (48 rows) , 42590 -- nimbex inputevents_cv (38 rows) , 42284 -- CISATRACURIUM DRIP (9 rows) , 45096 -- Vecuronium drip (2 rows) ) group by icustay_id, charttime UNION -- add data from chartevents select icustay_id, charttime -- where clause below ensures all rows are instance of the drug , 1 as drug -- the 'stopped' column indicates if a drug has been disconnected , max(case when stopped in ('Stopped','D/C''d') then 1 else 0 end) as drug_stopped , max(case when valuenum <= 10 then 0 else 1 end) as drug_null -- educated guess! , max(case when valuenum <= 10 then valuenum else null end) as drug_rate , max(case when valuenum > 10 then valuenum else null end) as drug_amount from chartevents where itemid in ( 1856 -- Vecuronium mcg/min (8 rows) , 2164 -- NIMBEX MG/KG/HR (243 rows) , 2548 -- nimbex mg/kg/hr (103 rows) , 2285 -- nimbex mcg/kg/min (85 rows) , 2290 -- nimbex mcg/kg/m (32 rows) , 2670 -- nimbex (38 rows) , 2546 -- CISATRACURIUMMG/KG/H (7 rows) , 1098 -- cisatracurium mg/kg (36 rows) , 2390 -- cisatracurium mg/hr (15 rows) , 2511 -- CISATRACURIUM GTT (4 rows) , 1028 -- Cisatracurium (208 rows) , 1858 -- cisatracurium (351 rows) ) group by icustay_id, charttime ) , drugcv2 as ( select v.* , sum(drug_null) over (partition by icustay_id order by charttime) as drug_partition from drugcv1 v ) , drugcv3 as ( select v.* , first_value(drug_rate) over (partition by icustay_id, drug_partition order by charttime) as drug_prevrate_ifnull from drugcv2 v ) , drugcv4 as ( select icustay_id , charttime -- , (CHARTTIME - (LAG(CHARTTIME, 1) OVER (partition by icustay_id, drug order by charttime))) AS delta , drug , drug_rate , drug_amount , drug_stopped , drug_prevrate_ifnull -- We define start time here , case when drug = 0 then null -- if this is the first instance of the drug when drug_rate > 0 and LAG(drug_prevrate_ifnull,1) OVER ( partition by icustay_id, drug, drug_null order by charttime ) is null then 1 -- you often get a string of 0s -- we decide not to set these as 1, just because it makes drugnum sequential when drug_rate = 0 and LAG(drug_prevrate_ifnull,1) OVER ( partition by icustay_id, drug order by charttime ) = 0 then 0 -- sometimes you get a string of NULL, associated with 0 volumes -- same reason as before, we decide not to set these as 1 -- drug_prevrate_ifnull is equal to the previous value *iff* the current value is null when drug_prevrate_ifnull = 0 and LAG(drug_prevrate_ifnull,1) OVER ( partition by icustay_id, drug order by charttime ) = 0 then 0 -- If the last recorded rate was 0, newdrug = 1 when LAG(drug_prevrate_ifnull,1) OVER ( partition by icustay_id, drug order by charttime ) = 0 then 1 -- If the last recorded drug was D/C'd, newdrug = 1 when LAG(drug_stopped,1) OVER ( partition by icustay_id, drug order by charttime ) = 1 then 1 when (CHARTTIME - (LAG(CHARTTIME, 1) OVER (partition by icustay_id, drug order by charttime))) > (interval '8 hours') then 1 else null end as drug_start FROM drugcv3 ) -- propagate start/stop flags forward in time , drugcv5 as ( select v.* , SUM(drug_start) OVER (partition by icustay_id, drug order by charttime) as drug_first FROM drugcv4 v ) , drugcv6 as ( select v.* -- We define end time here , case when drug = 0 then null -- If the recorded drug was D/C'd, this is an end time when drug_stopped = 1 then drug_first -- If the rate is zero, this is the end time when drug_rate = 0 then drug_first -- the last row in the table is always a potential end time -- this captures patients who die/are discharged while on drug -- in principle, this could add an extra end time for the drug -- however, since we later group on drug_start, any extra end times are ignored when LEAD(CHARTTIME,1) OVER ( partition by icustay_id, drug order by charttime ) is null then drug_first else null end as drug_stop from drugcv5 v ) -- -- if you want to look at the results of the table before grouping: -- select -- icustay_id, charttime, drug, drug_rate, drug_amount -- , drug_stopped -- , drug_start -- , drug_first -- , drug_stop -- from drugcv6 order by icustay_id, charttime; , drugcv7 as ( select icustay_id , charttime as starttime , lead(charttime) OVER (partition by icustay_id, drug_first order by charttime) as endtime , drug, drug_rate, drug_amount, drug_stop, drug_start, drug_first from drugcv6 where drug_first is not null -- bogus data and drug_first != 0 -- sometimes *only* a rate of 0 appears, i.e. the drug is never actually delivered and icustay_id is not null -- there are data for "floating" admissions, we don't worry about these ) -- table of start/stop times for event , drugcv8 as ( select icustay_id , starttime, endtime , drug, drug_rate, drug_amount, drug_stop, drug_start, drug_first from drugcv7 where endtime is not null and drug_rate > 0 and starttime != endtime ) -- collapse these start/stop times down if the rate doesn't change , drugcv9 as ( select icustay_id , starttime, endtime , case when LAG(endtime) OVER (partition by icustay_id order by starttime, endtime) = starttime AND LAG(drug_rate) OVER (partition by icustay_id order by starttime, endtime) = drug_rate THEN 0 else 1 end as drug_groups , drug, drug_rate, drug_amount, drug_stop, drug_start, drug_first from drugcv8 where endtime is not null and drug_rate > 0 and starttime != endtime ) , drugcv10 as ( select icustay_id , starttime, endtime , drug_groups , SUM(drug_groups) OVER (partition by icustay_id order by starttime, endtime) as drug_groups_sum , drug, drug_rate, drug_amount, drug_stop, drug_start, drug_first from drugcv9 ) , drugcv as ( select icustay_id , min(starttime) as starttime , max(endtime) as endtime , drug_groups_sum , drug_rate , sum(drug_amount) as drug_amount from drugcv10 group by icustay_id, drug_groups_sum, drug_rate ) -- now assign this data to every hour of the patient's stay -- drug_amount for carevue is not accurate SELECT icustay_id , starttime, endtime , drug_rate, drug_amount from drugcv UNION SELECT icustay_id , starttime, endtime , drug_rate, drug_amount from drugmv order by icustay_id, starttime;
MIT-LCP/mimic-code
mimic-iii/concepts/durations/neuroblock_dose.sql
SQL
mit
9,203
cryptocurrency-market-data ========================== Experiments in cryptocurrency market data parsing/processing
rnicoll/cryptocurrency-market-data
README.md
Markdown
mit
116
#ifndef ABB_VALUE_H #define ABB_VALUE_H #include <type_traits> #include <tuple> namespace abb { class und_t {}; class pass_t {}; const und_t und; const pass_t pass; template<typename Value> struct is_und : std::is_same<Value, und_t> {}; template<typename Value> struct is_pass : std::is_same<Value, pass_t> {}; template<typename Value> struct is_special : std::integral_constant<bool, is_und<Value>::value || is_pass<Value>::value> {}; template<typename T> class inplace_args; template<typename Ret, typename... Args> class inplace_args<Ret(Args...)> : private std::tuple<Args...> { public: using std::tuple<Args...>::tuple; template<std::size_t Index> typename std::tuple_element<Index, std::tuple<Args...>>::type const& get() const { return std::get<Index>(*this); } }; template<typename Ret = pass_t, typename... Args> inplace_args<Ret(Args &&...)> inplace(Args &&... args) { return inplace_args<Ret(Args &&...)>(std::forward<Args>(args)...); } namespace internal { template<typename Arg> struct normalize_arg { typedef Arg type; }; template<typename Ret, typename... Args> struct normalize_arg<inplace_args<Ret(Args...)>> { static_assert(!is_special<Ret>::value, "Expected inplace_args to contain valid object type"); typedef Ret type; }; template<typename Arg> struct normalize_arg<std::reference_wrapper<Arg>> { typedef Arg & type; }; template<typename Arg> using normalize_arg_t = typename normalize_arg<Arg>::type; template<typename Value> struct normalize_value { typedef void type(normalize_arg_t<Value>); }; template<> struct normalize_value<und_t> { typedef und_t type; }; template<typename Return, typename... Args> struct normalize_value<Return(Args...)> {}; template<typename... Args> struct normalize_value<void(Args...)> { typedef void type(normalize_arg_t<Args>...); }; template<> struct normalize_value<void> { typedef void type(); }; } // namespace internal template<typename Arg> using get_result_t = typename Arg::result; template<typename Arg> using get_reason_t = typename Arg::reason; template<typename Value> using normalize_value_t = typename internal::normalize_value<Value>::type; template<typename Value, typename OtherValue> struct is_value_substitutable : std::integral_constant< bool, std::is_same<Value, OtherValue>::value || std::is_same<OtherValue, und_t>::value > {}; namespace internal { template<typename... Types> struct common_value {}; template<> struct common_value<> { typedef und_t type; }; template<typename Type> struct common_value<Type> { typedef Type type; }; template<typename First, typename Second> struct common_value<First, Second> { typedef typename std::conditional<is_und<First>::value, Second, First>::type type; static_assert(is_value_substitutable<type, Second>::value, "Incompatible types"); }; template<typename First, typename Second, typename... Types> struct common_value<First, Second, Types...> : common_value<typename common_value<First, Second>::type, Types...> {}; } // namespace internal template<typename... Types> using common_value_t = typename internal::common_value<Types...>::type; } // namespace abb #endif // ABB_VALUE_H
rusek/abb-cpp
include/abb/value.h
C
mit
3,236
//================================================================================================= /*! // \file blazemark/blaze/TDVecSMatMult.h // \brief Header file for the Blaze transpose dense vector/sparse matrix multiplication kernel // // Copyright (C) 2012-2020 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. Redistribution and use in source and binary // forms, with or without modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other materials // provided with the distribution. // 3. Neither the names of the Blaze development group nor the names of its contributors // may be used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT // SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. */ //================================================================================================= #ifndef _BLAZEMARK_BLAZE_TDVECSMATMULT_H_ #define _BLAZEMARK_BLAZE_TDVECSMATMULT_H_ //************************************************************************************************* // Includes //************************************************************************************************* #include <blazemark/system/Types.h> namespace blazemark { namespace blaze { //================================================================================================= // // KERNEL FUNCTIONS // //================================================================================================= //************************************************************************************************* /*!\name Blaze kernel functions */ //@{ double tdvecsmatmult( size_t N, size_t F, size_t steps ); //@} //************************************************************************************************* } // namespace blaze } // namespace blazemark #endif
camillescott/boink
include/goetia/sketches/sketch/vec/blaze/blazemark/blazemark/blaze/TDVecSMatMult.h
C
mit
3,056
/* * Copyright 2015 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var THREE = require('./three-math.js'); var PredictionMode = { NONE: 'none', INTERPOLATE: 'interpolate', PREDICT: 'predict' } // How much to interpolate between the current orientation estimate and the // previous estimate position. This is helpful for devices with low // deviceorientation firing frequency (eg. on iOS8 and below, it is 20 Hz). The // larger this value (in [0, 1]), the smoother but more delayed the head // tracking is. var INTERPOLATION_SMOOTHING_FACTOR = 0.01; // Angular threshold, if the angular speed (in deg/s) is less than this, do no // prediction. Without it, the screen flickers quite a bit. var PREDICTION_THRESHOLD_DEG_PER_S = 0.01; //var PREDICTION_THRESHOLD_DEG_PER_S = 0; // How far into the future to predict. window.WEBVR_PREDICTION_TIME_MS = 80; // Whether to predict or what. window.WEBVR_PREDICTION_MODE = PredictionMode.PREDICT; function PosePredictor() { this.lastQ = new THREE.Quaternion(); this.lastTimestamp = null; this.outQ = new THREE.Quaternion(); this.deltaQ = new THREE.Quaternion(); } PosePredictor.prototype.getPrediction = function(currentQ, rotationRate, timestamp) { // If there's no previous quaternion, output the current one and save for // later. if (!this.lastTimestamp) { this.lastQ.copy(currentQ); this.lastTimestamp = timestamp; return currentQ; } // DEBUG ONLY: Try with a fixed 60 Hz update speed. //var elapsedMs = 1000/60; var elapsedMs = timestamp - this.lastTimestamp; switch (WEBVR_PREDICTION_MODE) { case PredictionMode.INTERPOLATE: this.outQ.copy(currentQ); this.outQ.slerp(this.lastQ, INTERPOLATION_SMOOTHING_FACTOR); // Save the current quaternion for later. this.lastQ.copy(currentQ); break; case PredictionMode.PREDICT: var axisAngle; if (rotationRate) { axisAngle = this.getAxisAngularSpeedFromRotationRate_(rotationRate); } else { axisAngle = this.getAxisAngularSpeedFromGyroDelta_(currentQ, elapsedMs); } // If there is no predicted axis/angle, don't do prediction. if (!axisAngle) { this.outQ.copy(currentQ); this.lastQ.copy(currentQ); break; } var angularSpeedDegS = axisAngle.speed; var axis = axisAngle.axis; var predictAngleDeg = (WEBVR_PREDICTION_TIME_MS / 1000) * angularSpeedDegS; // If we're rotating slowly, don't do prediction. if (angularSpeedDegS < PREDICTION_THRESHOLD_DEG_PER_S) { this.outQ.copy(currentQ); this.lastQ.copy(currentQ); break; } // Calculate the prediction delta to apply to the original angle. this.deltaQ.setFromAxisAngle(axis, THREE.Math.degToRad(predictAngleDeg)); // DEBUG ONLY: As a sanity check, use the same axis and angle as before, // which should cause no prediction to happen. //this.deltaQ.setFromAxisAngle(axis, angle); this.outQ.copy(this.lastQ); this.outQ.multiply(this.deltaQ); // Use the predicted quaternion as the new last one. //this.lastQ.copy(this.outQ); this.lastQ.copy(currentQ); break; case PredictionMode.NONE: default: this.outQ.copy(currentQ); } this.lastTimestamp = timestamp; return this.outQ; }; PosePredictor.prototype.setScreenOrientation = function(screenOrientation) { this.screenOrientation = screenOrientation; }; PosePredictor.prototype.getAxis_ = function(quat) { // x = qx / sqrt(1-qw*qw) // y = qy / sqrt(1-qw*qw) // z = qz / sqrt(1-qw*qw) var d = Math.sqrt(1 - quat.w * quat.w); return new THREE.Vector3(quat.x / d, quat.y / d, quat.z / d); }; PosePredictor.prototype.getAngle_ = function(quat) { // angle = 2 * acos(qw) // If w is greater than 1 (THREE.js, how can this be?), arccos is not defined. if (quat.w > 1) { return 0; } var angle = 2 * Math.acos(quat.w); // Normalize the angle to be in [-π, π]. if (angle > Math.PI) { angle -= 2 * Math.PI; } return angle; }; PosePredictor.prototype.getAxisAngularSpeedFromRotationRate_ = function(rotationRate) { if (!rotationRate) { return null; } var screenRotationRate; if (/iPad|iPhone|iPod/.test(navigator.platform)) { // iOS: angular speed in deg/s. var screenRotationRate = this.getScreenAdjustedRotationRateIOS_(rotationRate); } else { // Android: angular speed in rad/s, so need to convert. rotationRate.alpha = THREE.Math.radToDeg(rotationRate.alpha); rotationRate.beta = THREE.Math.radToDeg(rotationRate.beta); rotationRate.gamma = THREE.Math.radToDeg(rotationRate.gamma); var screenRotationRate = this.getScreenAdjustedRotationRate_(rotationRate); } var vec = new THREE.Vector3( screenRotationRate.beta, screenRotationRate.alpha, screenRotationRate.gamma); /* var vec; if (/iPad|iPhone|iPod/.test(navigator.platform)) { vec = new THREE.Vector3(rotationRate.gamma, rotationRate.alpha, rotationRate.beta); } else { vec = new THREE.Vector3(rotationRate.beta, rotationRate.alpha, rotationRate.gamma); } // Take into account the screen orientation too! vec.applyQuaternion(this.screenTransform); */ // Angular speed in deg/s. var angularSpeedDegS = vec.length(); var axis = vec.normalize(); return { speed: angularSpeedDegS, axis: axis } }; PosePredictor.prototype.getScreenAdjustedRotationRate_ = function(rotationRate) { var screenRotationRate = { alpha: -rotationRate.alpha, beta: rotationRate.beta, gamma: rotationRate.gamma }; switch (this.screenOrientation) { case 90: screenRotationRate.beta = - rotationRate.gamma; screenRotationRate.gamma = rotationRate.beta; break; case 180: screenRotationRate.beta = - rotationRate.beta; screenRotationRate.gamma = - rotationRate.gamma; break; case 270: case -90: screenRotationRate.beta = rotationRate.gamma; screenRotationRate.gamma = - rotationRate.beta; break; default: // SCREEN_ROTATION_0 screenRotationRate.beta = rotationRate.beta; screenRotationRate.gamma = rotationRate.gamma; break; } return screenRotationRate; }; PosePredictor.prototype.getScreenAdjustedRotationRateIOS_ = function(rotationRate) { var screenRotationRate = { alpha: rotationRate.alpha, beta: rotationRate.beta, gamma: rotationRate.gamma }; // Values empirically derived. switch (this.screenOrientation) { case 90: screenRotationRate.beta = -rotationRate.beta; screenRotationRate.gamma = rotationRate.gamma; break; case 180: // You can't even do this on iOS. break; case 270: case -90: screenRotationRate.alpha = -rotationRate.alpha; screenRotationRate.beta = rotationRate.beta; screenRotationRate.gamma = rotationRate.gamma; break; default: // SCREEN_ROTATION_0 screenRotationRate.alpha = rotationRate.beta; screenRotationRate.beta = rotationRate.alpha; screenRotationRate.gamma = rotationRate.gamma; break; } return screenRotationRate; }; PosePredictor.prototype.getAxisAngularSpeedFromGyroDelta_ = function(currentQ, elapsedMs) { // Sometimes we use the same sensor timestamp, in which case prediction // won't work. if (elapsedMs == 0) { return null; } // Q_delta = Q_last^-1 * Q_curr this.deltaQ.copy(this.lastQ); this.deltaQ.inverse(); this.deltaQ.multiply(currentQ); // Convert from delta quaternion to axis-angle. var axis = this.getAxis_(this.deltaQ); var angleRad = this.getAngle_(this.deltaQ); // It took `elapsed` ms to travel the angle amount over the axis. Now, // we make a new quaternion based how far in the future we want to // calculate. var angularSpeedRadMs = angleRad / elapsedMs; var angularSpeedDegS = THREE.Math.radToDeg(angularSpeedRadMs) * 1000; // If no rotation rate is provided, do no prediction. return { speed: angularSpeedDegS, axis: axis }; }; module.exports = PosePredictor;
lacker/universe
vr_webpack/webvr-polyfill/src/pose-predictor.js
JavaScript
mit
8,628
<?php namespace Kuxin\Helper; /** * Class Collect * * @package Kuxin\Helper * @author Pakey <[email protected]> */ class Collect { /** * 获取内容 * * @param $data * @return bool|mixed|string */ public static function getContent($data, $header = [], $option = []) { if (is_string($data)) $data = ['rule' => $data, 'charset' => 'auto']; if (strpos($data['rule'], '[timestamp]') || strpos($data['rule'], '[时间]')) { $data['rule'] = str_replace(['[timestamp]', '[时间]'], [time() - 64566122, date('Y-m-d H:i:s')], $data['rule']); } elseif (isset($data['usetimestamp']) && $data['usetimestamp'] == 1) { $data['rule'] .= (strpos($data['rule'], '?') ? '&_ptcms=' : '?_ptcms=') . (time() - 13456867); } if (isset($data['method']) && strtolower($data['method']) == 'post') { $content = Http::post($data['rule'], [], $header, $option); } else { $content = Http::get($data['rule'], [], $header, $option); } if ($content) { // 处理编码 if (empty($data['charset']) || !in_array($data['charset'], ['auto', 'utf-8', 'gbk'])) { $data['charset'] = 'auto'; } // 检测编码 if ($data['charset'] == 'auto') { if (preg_match('/[;\s\'"]charset[=\'\s]+?big/i', $content)) { $data['charset'] = 'big5'; } elseif (preg_match('/[;\s\'"]charset[=\'"\s]+?gb/i', $content) || preg_match('/[;\s\'"]encoding[=\'"\s]+?gb/i', $content)) { $data['charset'] = 'gbk'; } elseif (mb_detect_encoding($content) != 'UTF-8') { $data['charset'] = 'gbk'; } } // 转换 switch ($data['charset']) { case 'gbk': $content = mb_convert_encoding($content, 'UTF-8', 'GBK'); break; case 'big5': $content = mb_convert_encoding($content, 'UTF-8', 'big-5'); $content = big5::toutf8($content); break; case 'utf-16': $content = mb_convert_encoding($content, 'UTF-8', 'UTF-16'); default: } //错误标识 if (!empty($data['error']) && strpos($content, $data['error']) !== false) { return ''; } if (!empty($data['replace'])) { $content = self::replace($content, $data['replace']); } return $content; } return ''; } /** * 根据正则批量获取 * * @param mixed $pregArr 正则 * @param string $code 源内容 * @param int $needposition 确定是否需要间距数字 * @return array|bool */ public static function getMatchAll($pregArr, $code, $needposition = 0) { if (is_numeric($pregArr)) { return $pregArr; } elseif (is_string($pregArr)) { $pregArr = ['rule' => self::parseMatchRule($pregArr)]; } elseif (empty($pregArr['rule'])) { return []; } if (!self::isreg($pregArr['rule'])) return []; $pregstr = '{' . $pregArr['rule'] . '}'; $pregstr .= empty($pregArr['option']) ? '' : $pregArr['option']; $matchvar = $match = []; if (!empty($pregstr)) { if ($needposition) { preg_match_all($pregstr, $code, $match, PREG_SET_ORDER + PREG_OFFSET_CAPTURE); } else { preg_match_all($pregstr, $code, $match); } } if (is_array($match)) { if ($needposition) { foreach ($match as $var) { if (is_array($var)) { $matchvar[] = $var[count($var) - 1]; } else { $matchvar[] = $var; } } } else { if (isset($match['2'])) { $count = count($match); foreach ($match['1'] as $k => $v) { if ($v == '') { for ($i = 2; $i < $count; $i++) { if (!empty($match[$i][$k])) { $match['1'][$k] = $match[$i][$k]; break; } } } } } if (isset($match['1'])) { $matchvar = $match['1']; } else { return false; } } if (!empty($pregArr['replace'])) { foreach ($matchvar as $k => $v) { $matchvar[$k] = self::replace($v, $pregArr['replace']); } } return $matchvar; } return []; } /** * 根据正则获取指定数据 单个 * * @param mixed $pregArr 正则 * @param string $code 源内容 * @return bool|string */ public static function getMatch($pregArr, $code) { if (is_numeric($pregArr)) { return $pregArr; } elseif (empty($pregArr) || (isset($pregArr['rule']) && empty($pregArr['rule']))) { return ''; } elseif (is_string($pregArr)) { $pregArr = ['rule' => self::parseMatchRule($pregArr), 'replace' => []]; } if (!self::isreg($pregArr['rule'])) return $pregArr['rule']; $pregstr = '{' . $pregArr['rule'] . '}'; $pregstr .= empty($pregArr['option']) ? '' : $pregArr['option']; preg_match($pregstr, $code, $match); if (isset($match['1'])) { if (empty($pregArr['replace'])) { return $match['1']; } else { return self::replace($match[1], $pregArr['replace']); } } return ''; } /** * 内容替换 支持正则批量替换 * * @param string $con 代替换的内容 * @param array $arr 替换规则数组 单个元素如下 * array( * 'rule'=>'规则1',//♂后面表示要替换的 内容 * 'option'=>'参数', * 'method'=>1,//1 正则 0普通 * v ), * @return mixed */ public static function replace($con, array $arr) { foreach ($arr as $v) { if (!empty($v['rule'])) { $tmp = explode('♂', $v['rule']); $rule = $tmp['0']; $replace = isset($tmp['1']) ? $tmp['1'] : ''; $v['option'] = isset($v['option']) ? $v['option'] : ''; if ($v['method'] == 1) { //正则 $con = preg_replace("{" . $rule . "}{$v['option']}", $replace, $con); } else { if (strpos($v['option'], 'i') === false) { $con = str_replace($rule, $replace, $con); } else { $con = str_ireplace($rule, $replace, $con); } } } } return $con; } /** * 处理链接,根据当前页面地址得到完整的链接地址 * * @param string $url 当前链接 * @param string $path 当前页面地址 * @return string */ public static function parseUrl($url, $path) { if ($url) { if (strpos($url, '://') === false) { if (substr($url, 0, 1) == '/') { $tmp = parse_url($path); $url = $tmp['scheme'] . '://' . $tmp['host'] . $url; } elseif (substr($url, 0, 3) == '../') { $url = dirname($path) . substr($url, 2); } elseif (substr($path, -1) == '/') { $url = $path . $url; } else { $url = dirname($path) . '/' . $url; } } return $url; } else { return ''; } } /** * 内容切割方式 * * @param string $strings 要切割的内容 * @param string $argl 左侧标识 如果带有.+?则为正则模式 * @param string $argr 右侧标识 如果带有.+?则为正则模式 * @param bool $lt 是否包含左切割字符串 * @param bool $gt 是否包含右切割字符串 * @return string */ public static function cut($strings, $argl, $argr, $lt = false, $gt = false) { if (!$strings) return (""); if (strpos($argl, ".+?")) { $argl = strtr($argl, ["/" => "\/"]); if (preg_match("/" . $argl . "/", $strings, $match)) $argl = $match[0]; } if (strpos($argr, ".+?")) { $argr = strtr($argr, ["/" => "\/"]); if (preg_match("/" . $argr . "/", $strings, $match)) $argr = $match[0]; } $args = explode($argl, $strings); $args = explode($argr, $args[1]); $args = $args[0]; if ($args) { if ($lt) $args = $argl . $args; if ($gt) $args .= $argr; } else { $args = ""; } return ($args); } /** * 简写规则转化 * * @param $rules * @return array|string */ public static function parseMatchRule($rules) { $replace_pairs = [ '{' => '\{', '}' => '\}', '[内容]' => '(.*?)', '[数字]' => '\d*', '[空白]' => '\s*', '[任意]' => '.*?', '[参数]' => '[^\>\<]*?', '[属性]' => '[^\>\<\'"]*?', ]; if (is_array($rules)) { $rules['rule'] = strtr($rules['rule'], $replace_pairs); return $rules; } return strtr($rules, $replace_pairs); } /** * 是否正则 * * @param $str * @return bool */ public static function isreg($str) { return (strpos($str, ')') !== false || strpos($str, '(') !== false); } /** * @param $data * @return array */ public static function parseListData($data) { $list = []; $num = 0; foreach ($data as $v) { if ($v) { if ($num) { if ($num != count($v)) return []; } else { $num = count($v); } } } foreach ($data as $k => $v) { if ($v) { foreach ($v as $kk => $vv) { $list[$kk][$k] = $vv; } } else { for ($i = 0; $i < $num; $i++) { $list[$i][$k] = ''; } } } return $list; } }
pakey/PTFrameWork
kuxin/helper/collect.php
PHP
mit
11,227
/** * JS for the player character. * * * * */ import * as Consts from './consts'; var leftLeg; var rightLeg; var leftArm; var rightArm; const BODY_HEIGHT = 5; const LEG_HEIGHT = 5; const HEAD_HEIGHT = Consts.BLOCK_WIDTH * (3/5); const SKIN_COLORS = [0xFADCAB, 0x9E7245, 0x4F3F2F]; const BASE_MAT = new THREE.MeshLambertMaterial({color: 0xFF0000}); export var Player = function() { THREE.Object3D.call(this); this.position.y += BODY_HEIGHT / 2 + LEG_HEIGHT / 2 + HEAD_HEIGHT / 2 + HEAD_HEIGHT; this.moveLeft = false; this.moveRight = false; this.moveUp = false; this.moveDown = false; this.orientation = "backward"; var scope = this; var legGeo = new THREE.BoxGeometry(Consts.BLOCK_WIDTH / 2, LEG_HEIGHT, Consts.BLOCK_WIDTH / 2); var armGeo = new THREE.BoxGeometry(Consts.BLOCK_WIDTH / 2, BODY_HEIGHT, Consts.BLOCK_WIDTH / 2); // Base mat(s) var redMaterial = new THREE.MeshLambertMaterial({color: 0xFF2E00}); var blueMaterial = new THREE.MeshLambertMaterial({color: 0x23A8FC}); var yellowMaterial = new THREE.MeshLambertMaterial({color: 0xFFD000}); // Skin color mat, only used for head var skinColor = SKIN_COLORS[Math.floor(Math.random() * SKIN_COLORS.length)] var skinMat = new THREE.MeshLambertMaterial({color: skinColor}); // Body material var bodyFrontMat = new THREE.MeshPhongMaterial({color: 0xFFFFFF}); var bodyFrontTexture = new THREE.TextureLoader().load("img/tetratowerbodyfront.png", function(texture) { bodyFrontMat.map = texture; bodyFrontMat.needsUpdate = true; }) var bodyMat = new THREE.MultiMaterial([ redMaterial, redMaterial, redMaterial, redMaterial, bodyFrontMat, bodyFrontMat ]); var armSideMat = new THREE.MeshLambertMaterial({color: 0xFFFFFF}) var armTopMat = new THREE.MeshLambertMaterial({color: 0xFFFFFF}); var armMat = new THREE.MultiMaterial([ armSideMat, armSideMat, armTopMat, armTopMat, armSideMat, armSideMat ]); // Leg material var legSideMat = new THREE.MeshLambertMaterial({color: 0xFFFFFF}) var legMat = new THREE.MultiMaterial([ legSideMat, legSideMat, blueMaterial, blueMaterial, legSideMat, legSideMat ]); var legTexture = new THREE.TextureLoader().load("/img/tetratowerleg.png", function (texture) { legSideMat.map = texture; legSideMat.needsUpdate = true; }); var textureURL; switch (skinColor) { case SKIN_COLORS[0]: textureURL = "/img/tetratowerarm_white.png"; break; case SKIN_COLORS[1]: textureURL = "/img/tetratowerarm_brown.png"; break; case SKIN_COLORS[2]: textureURL = "/img/tetratowerarm_black.png"; break; default: textureURL = "/img/tetratowerarm.png"; break; } var armTexture = new THREE.TextureLoader().load(textureURL, function(texture) { armSideMat.map = texture; armSideMat.needsUpdate = true; }); var armTopTexture = new THREE.TextureLoader().load("img/tetratowerarmtop.png", function(texture) { armTopMat.map = texture; armTopMat.needsUpdate = true; }) // Create a body var bodyGeo = new THREE.BoxGeometry(Consts.BLOCK_WIDTH, BODY_HEIGHT, Consts.BLOCK_WIDTH / 2); var body = new THREE.Mesh(bodyGeo, bodyMat); this.add(body); // Create some leggy legs leftLeg = new THREE.Mesh(legGeo, legMat); this.add(leftLeg) leftLeg.translateX(-Consts.BLOCK_WIDTH / 4); leftLeg.translateY(-(LEG_HEIGHT + BODY_HEIGHT) / 2); rightLeg = new THREE.Mesh(legGeo, legMat); this.add(rightLeg); rightLeg.translateX(Consts.BLOCK_WIDTH / 4); rightLeg.translateY(-(LEG_HEIGHT + BODY_HEIGHT) / 2); // Create the arms leftArm = new THREE.Mesh(armGeo, armMat); this.add(leftArm); leftArm.translateX(-(Consts.BLOCK_WIDTH / 4 + Consts.BLOCK_WIDTH / 2)); rightArm = new THREE.Mesh(armGeo, armMat); this.add(rightArm); rightArm.translateX((Consts.BLOCK_WIDTH / 4 + Consts.BLOCK_WIDTH / 2)); // Now add a head var headGeo = new THREE.BoxGeometry(Consts.BLOCK_WIDTH * (3/5), Consts.BLOCK_WIDTH * (3/5), Consts.BLOCK_WIDTH * (3/5)); var head = new THREE.Mesh(headGeo, skinMat); this.add(head); head.translateY((BODY_HEIGHT + HEAD_HEIGHT) / 2); // And a fashionable hat var hatBodyGeo = new THREE.BoxGeometry(HEAD_HEIGHT * 1.05, HEAD_HEIGHT * (4/5), HEAD_HEIGHT * 1.05); var hatBody = new THREE.Mesh(hatBodyGeo, yellowMaterial); head.add(hatBody); hatBody.translateY(HEAD_HEIGHT * (4/5)); var hatBrimGeo = new THREE.BoxGeometry(HEAD_HEIGHT * 1.05, HEAD_HEIGHT / 5, HEAD_HEIGHT * 0.525); var hatBrim = new THREE.Mesh(hatBrimGeo, yellowMaterial); head.add(hatBrim); hatBrim.translateZ((HEAD_HEIGHT * 1.05) / 2 + (HEAD_HEIGHT * 0.525 / 2)); hatBrim.translateY(HEAD_HEIGHT / 2); // Add some listeners var onKeyDown = function(event) { switch(event.keyCode) { case 38: // up case 87: // w scope.moveForward = true; break; case 40: // down case 83: // s scope.moveBackward = true; break; case 37: // left case 65: // a scope.moveLeft = true; break; case 39: // right case 68: // d scope.moveRight = true; break; } } var onKeyUp = function(event) { switch(event.keyCode) { case 38: // up case 87: // w scope.moveForward = false; break; case 40: // down case 83: // s scope.moveBackward = false; break; case 37: // left case 65: // a scope.moveLeft = false; break; case 39: // right case 68: // d scope.moveRight = false; break; } } document.addEventListener('keydown', onKeyDown, false); document.addEventListener('keyup', onKeyUp, false); } Player.prototype = new THREE.Object3D(); Player.prototype.constructor = Player; THREE.Object3D.prototype.worldToLocal = function ( vector ) { if ( !this.__inverseMatrixWorld ) this.__inverseMatrixWorld = new THREE.Matrix4(); return vector.applyMatrix4( this.__inverseMatrixWorld.getInverse( this.matrixWorld )); }; THREE.Object3D.prototype.lookAtWorld = function( vector ) { vector = vector.clone(); this.parent.worldToLocal( vector ); this.lookAt( vector ); };
Bjorkbat/tetratower
js/src/player.js
JavaScript
mit
6,258
<!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 (1.8.0_112-google-v7) on Fri Jul 21 13:02:32 PDT 2017 --> <title>Resetter</title> <meta name="date" content="2017-07-21"> <link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style"> <script type="text/javascript" src="../../../script.js"></script> </head> <body> <script type="text/javascript"><!-- try { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Resetter"; } } catch(err) { } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar.top"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.top.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">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="../../../org/robolectric/annotation/RealObject.html" title="annotation in org.robolectric.annotation"><span class="typeNameLink">Prev&nbsp;Class</span></a></li> <li>Next&nbsp;Class</li> </ul> <ul class="navList"> <li><a href="../../../index.html?org/robolectric/annotation/Resetter.html" target="_top">Frames</a></li> <li><a href="Resetter.html" target="_top">No&nbsp;Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../../allclasses-noframe.html">All&nbsp;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> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li>Required&nbsp;|&nbsp;</li> <li>Optional</li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li>Element</li> </ul> </div> <a name="skip.navbar.top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <!-- ======== START OF CLASS DATA ======== --> <div class="header"> <div class="subTitle">org.robolectric.annotation</div> <h2 title="Annotation Type Resetter" class="title">Annotation Type Resetter</h2> </div> <div class="contentContainer"> <div class="description"> <ul class="blockList"> <li class="blockList"> <hr> <br> <pre>@Documented @Retention(value=RUNTIME) @Target(value=METHOD) public @interface <span class="memberNameLabel">Resetter</span></pre> <div class="block"><p>Indicates that the annotated method is used to reset static state in a shadow.</p></div> </li> </ul> </div> </div> <!-- ========= END OF CLASS DATA ========= --> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar.bottom"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.bottom.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">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 class="aboutLanguage"><script type="text/javascript" src="../../../highlight.pack.js"></script> <script type="text/javascript"><!-- hljs.initHighlightingOnLoad(); //--></script></div> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../org/robolectric/annotation/RealObject.html" title="annotation in org.robolectric.annotation"><span class="typeNameLink">Prev&nbsp;Class</span></a></li> <li>Next&nbsp;Class</li> </ul> <ul class="navList"> <li><a href="../../../index.html?org/robolectric/annotation/Resetter.html" target="_top">Frames</a></li> <li><a href="Resetter.html" target="_top">No&nbsp;Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../../allclasses-noframe.html">All&nbsp;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> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li>Required&nbsp;|&nbsp;</li> <li>Optional</li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li>Element</li> </ul> </div> <a name="skip.navbar.bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> </body> </html>
robolectric/robolectric.github.io
javadoc/3.4/org/robolectric/annotation/Resetter.html
HTML
mit
5,317
blocklevel = ["blockquote", "div", "form", "p", "table", "video", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "details", "article", "header", "main"] def normalizeEnter(src): #Deletes all user defined for readability reason existing line breaks that are issues for the HTML output for elem in blocklevel: while src.find("\r<" + elem) > -1: src = src.replace("\r<" + elem, "<" + elem) while src.find("</" + elem + ">\r") > -1: src = src.replace("</" + elem + ">\r", "</" + elem + ">") while src.find(">\r") > -1: src = src.replace(">\r", ">") #It is really needed, it created some other bugs?! while src.find("\r</") > -1: src = src.replace("\r</", "</") ##It is really needed, it created some other bugs?! return src def main(islinput, inputfile, pluginData, globalData): currentIndex = 0 for item in islinput: item = normalizeEnter(item) #Deletes not wanted line breaks in order to prevent the problem we have with Markdown. islinput[currentIndex] = item currentIndex += 1 return islinput, pluginData, globalData
ValorNaram/isl
inputchangers/002.py
Python
mit
1,044
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class DataQuestionnaire extends Model { protected $fillable = ['game_question', 'game_opponent_evaluation', 'study_evaluation']; /** * Relationship with parent DataParticipant. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function data_participant() { return $this->belongsTo('App\Models\DataParticipant'); } }
mihaiconstantin/game-theory-tilburg
app/Models/DataQuestionnaire.php
PHP
mit
460
# riemann-stream Stream events from Riemann on CLI
alexforrow/riemann-stream
README.md
Markdown
mit
51
_rm: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 e4 f0 and $0xfffffff0,%esp 6: 83 ec 20 sub $0x20,%esp int i; if(argc < 2){ 9: 83 7d 08 01 cmpl $0x1,0x8(%ebp) d: 7f 19 jg 28 <main+0x28> printf(2, "Usage: rm files...\n"); f: c7 44 24 04 43 08 00 movl $0x843,0x4(%esp) 16: 00 17: c7 04 24 02 00 00 00 movl $0x2,(%esp) 1e: e8 54 04 00 00 call 477 <printf> exit(); 23: e8 cf 02 00 00 call 2f7 <exit> } for(i = 1; i < argc; i++){ 28: c7 44 24 1c 01 00 00 movl $0x1,0x1c(%esp) 2f: 00 30: eb 4f jmp 81 <main+0x81> if(unlink(argv[i]) < 0){ 32: 8b 44 24 1c mov 0x1c(%esp),%eax 36: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 3d: 8b 45 0c mov 0xc(%ebp),%eax 40: 01 d0 add %edx,%eax 42: 8b 00 mov (%eax),%eax 44: 89 04 24 mov %eax,(%esp) 47: e8 fb 02 00 00 call 347 <unlink> 4c: 85 c0 test %eax,%eax 4e: 79 2c jns 7c <main+0x7c> printf(2, "rm: %s failed to delete\n", argv[i]); 50: 8b 44 24 1c mov 0x1c(%esp),%eax 54: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 5b: 8b 45 0c mov 0xc(%ebp),%eax 5e: 01 d0 add %edx,%eax 60: 8b 00 mov (%eax),%eax 62: 89 44 24 08 mov %eax,0x8(%esp) 66: c7 44 24 04 57 08 00 movl $0x857,0x4(%esp) 6d: 00 6e: c7 04 24 02 00 00 00 movl $0x2,(%esp) 75: e8 fd 03 00 00 call 477 <printf> break; 7a: eb 0e jmp 8a <main+0x8a> if(argc < 2){ printf(2, "Usage: rm files...\n"); exit(); } for(i = 1; i < argc; i++){ 7c: 83 44 24 1c 01 addl $0x1,0x1c(%esp) 81: 8b 44 24 1c mov 0x1c(%esp),%eax 85: 3b 45 08 cmp 0x8(%ebp),%eax 88: 7c a8 jl 32 <main+0x32> printf(2, "rm: %s failed to delete\n", argv[i]); break; } } exit(); 8a: e8 68 02 00 00 call 2f7 <exit> 0000008f <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 8f: 55 push %ebp 90: 89 e5 mov %esp,%ebp 92: 57 push %edi 93: 53 push %ebx asm volatile("cld; rep stosb" : 94: 8b 4d 08 mov 0x8(%ebp),%ecx 97: 8b 55 10 mov 0x10(%ebp),%edx 9a: 8b 45 0c mov 0xc(%ebp),%eax 9d: 89 cb mov %ecx,%ebx 9f: 89 df mov %ebx,%edi a1: 89 d1 mov %edx,%ecx a3: fc cld a4: f3 aa rep stos %al,%es:(%edi) a6: 89 ca mov %ecx,%edx a8: 89 fb mov %edi,%ebx aa: 89 5d 08 mov %ebx,0x8(%ebp) ad: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } b0: 5b pop %ebx b1: 5f pop %edi b2: 5d pop %ebp b3: c3 ret 000000b4 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { b4: 55 push %ebp b5: 89 e5 mov %esp,%ebp b7: 83 ec 10 sub $0x10,%esp char *os; os = s; ba: 8b 45 08 mov 0x8(%ebp),%eax bd: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) c0: 90 nop c1: 8b 45 08 mov 0x8(%ebp),%eax c4: 8d 50 01 lea 0x1(%eax),%edx c7: 89 55 08 mov %edx,0x8(%ebp) ca: 8b 55 0c mov 0xc(%ebp),%edx cd: 8d 4a 01 lea 0x1(%edx),%ecx d0: 89 4d 0c mov %ecx,0xc(%ebp) d3: 0f b6 12 movzbl (%edx),%edx d6: 88 10 mov %dl,(%eax) d8: 0f b6 00 movzbl (%eax),%eax db: 84 c0 test %al,%al dd: 75 e2 jne c1 <strcpy+0xd> ; return os; df: 8b 45 fc mov -0x4(%ebp),%eax } e2: c9 leave e3: c3 ret 000000e4 <strcmp>: int strcmp(const char *p, const char *q) { e4: 55 push %ebp e5: 89 e5 mov %esp,%ebp while(*p && *p == *q) e7: eb 08 jmp f1 <strcmp+0xd> p++, q++; e9: 83 45 08 01 addl $0x1,0x8(%ebp) ed: 83 45 0c 01 addl $0x1,0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) f1: 8b 45 08 mov 0x8(%ebp),%eax f4: 0f b6 00 movzbl (%eax),%eax f7: 84 c0 test %al,%al f9: 74 10 je 10b <strcmp+0x27> fb: 8b 45 08 mov 0x8(%ebp),%eax fe: 0f b6 10 movzbl (%eax),%edx 101: 8b 45 0c mov 0xc(%ebp),%eax 104: 0f b6 00 movzbl (%eax),%eax 107: 38 c2 cmp %al,%dl 109: 74 de je e9 <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; 10b: 8b 45 08 mov 0x8(%ebp),%eax 10e: 0f b6 00 movzbl (%eax),%eax 111: 0f b6 d0 movzbl %al,%edx 114: 8b 45 0c mov 0xc(%ebp),%eax 117: 0f b6 00 movzbl (%eax),%eax 11a: 0f b6 c0 movzbl %al,%eax 11d: 29 c2 sub %eax,%edx 11f: 89 d0 mov %edx,%eax } 121: 5d pop %ebp 122: c3 ret 00000123 <strlen>: uint strlen(char *s) { 123: 55 push %ebp 124: 89 e5 mov %esp,%ebp 126: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 129: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 130: eb 04 jmp 136 <strlen+0x13> 132: 83 45 fc 01 addl $0x1,-0x4(%ebp) 136: 8b 55 fc mov -0x4(%ebp),%edx 139: 8b 45 08 mov 0x8(%ebp),%eax 13c: 01 d0 add %edx,%eax 13e: 0f b6 00 movzbl (%eax),%eax 141: 84 c0 test %al,%al 143: 75 ed jne 132 <strlen+0xf> ; return n; 145: 8b 45 fc mov -0x4(%ebp),%eax } 148: c9 leave 149: c3 ret 0000014a <memset>: void* memset(void *dst, int c, uint n) { 14a: 55 push %ebp 14b: 89 e5 mov %esp,%ebp 14d: 83 ec 0c sub $0xc,%esp stosb(dst, c, n); 150: 8b 45 10 mov 0x10(%ebp),%eax 153: 89 44 24 08 mov %eax,0x8(%esp) 157: 8b 45 0c mov 0xc(%ebp),%eax 15a: 89 44 24 04 mov %eax,0x4(%esp) 15e: 8b 45 08 mov 0x8(%ebp),%eax 161: 89 04 24 mov %eax,(%esp) 164: e8 26 ff ff ff call 8f <stosb> return dst; 169: 8b 45 08 mov 0x8(%ebp),%eax } 16c: c9 leave 16d: c3 ret 0000016e <strchr>: char* strchr(const char *s, char c) { 16e: 55 push %ebp 16f: 89 e5 mov %esp,%ebp 171: 83 ec 04 sub $0x4,%esp 174: 8b 45 0c mov 0xc(%ebp),%eax 177: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 17a: eb 14 jmp 190 <strchr+0x22> if(*s == c) 17c: 8b 45 08 mov 0x8(%ebp),%eax 17f: 0f b6 00 movzbl (%eax),%eax 182: 3a 45 fc cmp -0x4(%ebp),%al 185: 75 05 jne 18c <strchr+0x1e> return (char*)s; 187: 8b 45 08 mov 0x8(%ebp),%eax 18a: eb 13 jmp 19f <strchr+0x31> } char* strchr(const char *s, char c) { for(; *s; s++) 18c: 83 45 08 01 addl $0x1,0x8(%ebp) 190: 8b 45 08 mov 0x8(%ebp),%eax 193: 0f b6 00 movzbl (%eax),%eax 196: 84 c0 test %al,%al 198: 75 e2 jne 17c <strchr+0xe> if(*s == c) return (char*)s; return 0; 19a: b8 00 00 00 00 mov $0x0,%eax } 19f: c9 leave 1a0: c3 ret 000001a1 <gets>: char* gets(char *buf, int max) { 1a1: 55 push %ebp 1a2: 89 e5 mov %esp,%ebp 1a4: 83 ec 28 sub $0x28,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 1a7: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 1ae: eb 4c jmp 1fc <gets+0x5b> cc = read(0, &c, 1); 1b0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 1b7: 00 1b8: 8d 45 ef lea -0x11(%ebp),%eax 1bb: 89 44 24 04 mov %eax,0x4(%esp) 1bf: c7 04 24 00 00 00 00 movl $0x0,(%esp) 1c6: e8 44 01 00 00 call 30f <read> 1cb: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 1ce: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 1d2: 7f 02 jg 1d6 <gets+0x35> break; 1d4: eb 31 jmp 207 <gets+0x66> buf[i++] = c; 1d6: 8b 45 f4 mov -0xc(%ebp),%eax 1d9: 8d 50 01 lea 0x1(%eax),%edx 1dc: 89 55 f4 mov %edx,-0xc(%ebp) 1df: 89 c2 mov %eax,%edx 1e1: 8b 45 08 mov 0x8(%ebp),%eax 1e4: 01 c2 add %eax,%edx 1e6: 0f b6 45 ef movzbl -0x11(%ebp),%eax 1ea: 88 02 mov %al,(%edx) if(c == '\n' || c == '\r') 1ec: 0f b6 45 ef movzbl -0x11(%ebp),%eax 1f0: 3c 0a cmp $0xa,%al 1f2: 74 13 je 207 <gets+0x66> 1f4: 0f b6 45 ef movzbl -0x11(%ebp),%eax 1f8: 3c 0d cmp $0xd,%al 1fa: 74 0b je 207 <gets+0x66> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 1fc: 8b 45 f4 mov -0xc(%ebp),%eax 1ff: 83 c0 01 add $0x1,%eax 202: 3b 45 0c cmp 0xc(%ebp),%eax 205: 7c a9 jl 1b0 <gets+0xf> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 207: 8b 55 f4 mov -0xc(%ebp),%edx 20a: 8b 45 08 mov 0x8(%ebp),%eax 20d: 01 d0 add %edx,%eax 20f: c6 00 00 movb $0x0,(%eax) return buf; 212: 8b 45 08 mov 0x8(%ebp),%eax } 215: c9 leave 216: c3 ret 00000217 <stat>: int stat(char *n, struct stat *st) { 217: 55 push %ebp 218: 89 e5 mov %esp,%ebp 21a: 83 ec 28 sub $0x28,%esp int fd; int r; fd = open(n, O_RDONLY); 21d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 224: 00 225: 8b 45 08 mov 0x8(%ebp),%eax 228: 89 04 24 mov %eax,(%esp) 22b: e8 07 01 00 00 call 337 <open> 230: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 233: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 237: 79 07 jns 240 <stat+0x29> return -1; 239: b8 ff ff ff ff mov $0xffffffff,%eax 23e: eb 23 jmp 263 <stat+0x4c> r = fstat(fd, st); 240: 8b 45 0c mov 0xc(%ebp),%eax 243: 89 44 24 04 mov %eax,0x4(%esp) 247: 8b 45 f4 mov -0xc(%ebp),%eax 24a: 89 04 24 mov %eax,(%esp) 24d: e8 fd 00 00 00 call 34f <fstat> 252: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 255: 8b 45 f4 mov -0xc(%ebp),%eax 258: 89 04 24 mov %eax,(%esp) 25b: e8 bf 00 00 00 call 31f <close> return r; 260: 8b 45 f0 mov -0x10(%ebp),%eax } 263: c9 leave 264: c3 ret 00000265 <atoi>: int atoi(const char *s) { 265: 55 push %ebp 266: 89 e5 mov %esp,%ebp 268: 83 ec 10 sub $0x10,%esp int n; n = 0; 26b: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 272: eb 25 jmp 299 <atoi+0x34> n = n*10 + *s++ - '0'; 274: 8b 55 fc mov -0x4(%ebp),%edx 277: 89 d0 mov %edx,%eax 279: c1 e0 02 shl $0x2,%eax 27c: 01 d0 add %edx,%eax 27e: 01 c0 add %eax,%eax 280: 89 c1 mov %eax,%ecx 282: 8b 45 08 mov 0x8(%ebp),%eax 285: 8d 50 01 lea 0x1(%eax),%edx 288: 89 55 08 mov %edx,0x8(%ebp) 28b: 0f b6 00 movzbl (%eax),%eax 28e: 0f be c0 movsbl %al,%eax 291: 01 c8 add %ecx,%eax 293: 83 e8 30 sub $0x30,%eax 296: 89 45 fc mov %eax,-0x4(%ebp) atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 299: 8b 45 08 mov 0x8(%ebp),%eax 29c: 0f b6 00 movzbl (%eax),%eax 29f: 3c 2f cmp $0x2f,%al 2a1: 7e 0a jle 2ad <atoi+0x48> 2a3: 8b 45 08 mov 0x8(%ebp),%eax 2a6: 0f b6 00 movzbl (%eax),%eax 2a9: 3c 39 cmp $0x39,%al 2ab: 7e c7 jle 274 <atoi+0xf> n = n*10 + *s++ - '0'; return n; 2ad: 8b 45 fc mov -0x4(%ebp),%eax } 2b0: c9 leave 2b1: c3 ret 000002b2 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 2b2: 55 push %ebp 2b3: 89 e5 mov %esp,%ebp 2b5: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 2b8: 8b 45 08 mov 0x8(%ebp),%eax 2bb: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 2be: 8b 45 0c mov 0xc(%ebp),%eax 2c1: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 2c4: eb 17 jmp 2dd <memmove+0x2b> *dst++ = *src++; 2c6: 8b 45 fc mov -0x4(%ebp),%eax 2c9: 8d 50 01 lea 0x1(%eax),%edx 2cc: 89 55 fc mov %edx,-0x4(%ebp) 2cf: 8b 55 f8 mov -0x8(%ebp),%edx 2d2: 8d 4a 01 lea 0x1(%edx),%ecx 2d5: 89 4d f8 mov %ecx,-0x8(%ebp) 2d8: 0f b6 12 movzbl (%edx),%edx 2db: 88 10 mov %dl,(%eax) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 2dd: 8b 45 10 mov 0x10(%ebp),%eax 2e0: 8d 50 ff lea -0x1(%eax),%edx 2e3: 89 55 10 mov %edx,0x10(%ebp) 2e6: 85 c0 test %eax,%eax 2e8: 7f dc jg 2c6 <memmove+0x14> *dst++ = *src++; return vdst; 2ea: 8b 45 08 mov 0x8(%ebp),%eax } 2ed: c9 leave 2ee: c3 ret 000002ef <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 2ef: b8 01 00 00 00 mov $0x1,%eax 2f4: cd 40 int $0x40 2f6: c3 ret 000002f7 <exit>: SYSCALL(exit) 2f7: b8 02 00 00 00 mov $0x2,%eax 2fc: cd 40 int $0x40 2fe: c3 ret 000002ff <wait>: SYSCALL(wait) 2ff: b8 03 00 00 00 mov $0x3,%eax 304: cd 40 int $0x40 306: c3 ret 00000307 <pipe>: SYSCALL(pipe) 307: b8 04 00 00 00 mov $0x4,%eax 30c: cd 40 int $0x40 30e: c3 ret 0000030f <read>: SYSCALL(read) 30f: b8 05 00 00 00 mov $0x5,%eax 314: cd 40 int $0x40 316: c3 ret 00000317 <write>: SYSCALL(write) 317: b8 10 00 00 00 mov $0x10,%eax 31c: cd 40 int $0x40 31e: c3 ret 0000031f <close>: SYSCALL(close) 31f: b8 15 00 00 00 mov $0x15,%eax 324: cd 40 int $0x40 326: c3 ret 00000327 <kill>: SYSCALL(kill) 327: b8 06 00 00 00 mov $0x6,%eax 32c: cd 40 int $0x40 32e: c3 ret 0000032f <exec>: SYSCALL(exec) 32f: b8 07 00 00 00 mov $0x7,%eax 334: cd 40 int $0x40 336: c3 ret 00000337 <open>: SYSCALL(open) 337: b8 0f 00 00 00 mov $0xf,%eax 33c: cd 40 int $0x40 33e: c3 ret 0000033f <mknod>: SYSCALL(mknod) 33f: b8 11 00 00 00 mov $0x11,%eax 344: cd 40 int $0x40 346: c3 ret 00000347 <unlink>: SYSCALL(unlink) 347: b8 12 00 00 00 mov $0x12,%eax 34c: cd 40 int $0x40 34e: c3 ret 0000034f <fstat>: SYSCALL(fstat) 34f: b8 08 00 00 00 mov $0x8,%eax 354: cd 40 int $0x40 356: c3 ret 00000357 <link>: SYSCALL(link) 357: b8 13 00 00 00 mov $0x13,%eax 35c: cd 40 int $0x40 35e: c3 ret 0000035f <mkdir>: SYSCALL(mkdir) 35f: b8 14 00 00 00 mov $0x14,%eax 364: cd 40 int $0x40 366: c3 ret 00000367 <chdir>: SYSCALL(chdir) 367: b8 09 00 00 00 mov $0x9,%eax 36c: cd 40 int $0x40 36e: c3 ret 0000036f <dup>: SYSCALL(dup) 36f: b8 0a 00 00 00 mov $0xa,%eax 374: cd 40 int $0x40 376: c3 ret 00000377 <getpid>: SYSCALL(getpid) 377: b8 0b 00 00 00 mov $0xb,%eax 37c: cd 40 int $0x40 37e: c3 ret 0000037f <sbrk>: SYSCALL(sbrk) 37f: b8 0c 00 00 00 mov $0xc,%eax 384: cd 40 int $0x40 386: c3 ret 00000387 <sleep>: SYSCALL(sleep) 387: b8 0d 00 00 00 mov $0xd,%eax 38c: cd 40 int $0x40 38e: c3 ret 0000038f <uptime>: SYSCALL(uptime) 38f: b8 0e 00 00 00 mov $0xe,%eax 394: cd 40 int $0x40 396: c3 ret 00000397 <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 397: 55 push %ebp 398: 89 e5 mov %esp,%ebp 39a: 83 ec 18 sub $0x18,%esp 39d: 8b 45 0c mov 0xc(%ebp),%eax 3a0: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 3a3: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 3aa: 00 3ab: 8d 45 f4 lea -0xc(%ebp),%eax 3ae: 89 44 24 04 mov %eax,0x4(%esp) 3b2: 8b 45 08 mov 0x8(%ebp),%eax 3b5: 89 04 24 mov %eax,(%esp) 3b8: e8 5a ff ff ff call 317 <write> } 3bd: c9 leave 3be: c3 ret 000003bf <printint>: static void printint(int fd, int xx, int base, int sgn) { 3bf: 55 push %ebp 3c0: 89 e5 mov %esp,%ebp 3c2: 56 push %esi 3c3: 53 push %ebx 3c4: 83 ec 30 sub $0x30,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 3c7: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 3ce: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 3d2: 74 17 je 3eb <printint+0x2c> 3d4: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 3d8: 79 11 jns 3eb <printint+0x2c> neg = 1; 3da: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 3e1: 8b 45 0c mov 0xc(%ebp),%eax 3e4: f7 d8 neg %eax 3e6: 89 45 ec mov %eax,-0x14(%ebp) 3e9: eb 06 jmp 3f1 <printint+0x32> } else { x = xx; 3eb: 8b 45 0c mov 0xc(%ebp),%eax 3ee: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 3f1: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 3f8: 8b 4d f4 mov -0xc(%ebp),%ecx 3fb: 8d 41 01 lea 0x1(%ecx),%eax 3fe: 89 45 f4 mov %eax,-0xc(%ebp) 401: 8b 5d 10 mov 0x10(%ebp),%ebx 404: 8b 45 ec mov -0x14(%ebp),%eax 407: ba 00 00 00 00 mov $0x0,%edx 40c: f7 f3 div %ebx 40e: 89 d0 mov %edx,%eax 410: 0f b6 80 bc 0a 00 00 movzbl 0xabc(%eax),%eax 417: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1) }while((x /= base) != 0); 41b: 8b 75 10 mov 0x10(%ebp),%esi 41e: 8b 45 ec mov -0x14(%ebp),%eax 421: ba 00 00 00 00 mov $0x0,%edx 426: f7 f6 div %esi 428: 89 45 ec mov %eax,-0x14(%ebp) 42b: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 42f: 75 c7 jne 3f8 <printint+0x39> if(neg) 431: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 435: 74 10 je 447 <printint+0x88> buf[i++] = '-'; 437: 8b 45 f4 mov -0xc(%ebp),%eax 43a: 8d 50 01 lea 0x1(%eax),%edx 43d: 89 55 f4 mov %edx,-0xc(%ebp) 440: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) while(--i >= 0) 445: eb 1f jmp 466 <printint+0xa7> 447: eb 1d jmp 466 <printint+0xa7> putc(fd, buf[i]); 449: 8d 55 dc lea -0x24(%ebp),%edx 44c: 8b 45 f4 mov -0xc(%ebp),%eax 44f: 01 d0 add %edx,%eax 451: 0f b6 00 movzbl (%eax),%eax 454: 0f be c0 movsbl %al,%eax 457: 89 44 24 04 mov %eax,0x4(%esp) 45b: 8b 45 08 mov 0x8(%ebp),%eax 45e: 89 04 24 mov %eax,(%esp) 461: e8 31 ff ff ff call 397 <putc> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 466: 83 6d f4 01 subl $0x1,-0xc(%ebp) 46a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 46e: 79 d9 jns 449 <printint+0x8a> putc(fd, buf[i]); } 470: 83 c4 30 add $0x30,%esp 473: 5b pop %ebx 474: 5e pop %esi 475: 5d pop %ebp 476: c3 ret 00000477 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 477: 55 push %ebp 478: 89 e5 mov %esp,%ebp 47a: 83 ec 38 sub $0x38,%esp char *s; int c, i, state; uint *ap; state = 0; 47d: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 484: 8d 45 0c lea 0xc(%ebp),%eax 487: 83 c0 04 add $0x4,%eax 48a: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 48d: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 494: e9 7c 01 00 00 jmp 615 <printf+0x19e> c = fmt[i] & 0xff; 499: 8b 55 0c mov 0xc(%ebp),%edx 49c: 8b 45 f0 mov -0x10(%ebp),%eax 49f: 01 d0 add %edx,%eax 4a1: 0f b6 00 movzbl (%eax),%eax 4a4: 0f be c0 movsbl %al,%eax 4a7: 25 ff 00 00 00 and $0xff,%eax 4ac: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 4af: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 4b3: 75 2c jne 4e1 <printf+0x6a> if(c == '%'){ 4b5: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 4b9: 75 0c jne 4c7 <printf+0x50> state = '%'; 4bb: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 4c2: e9 4a 01 00 00 jmp 611 <printf+0x19a> } else { putc(fd, c); 4c7: 8b 45 e4 mov -0x1c(%ebp),%eax 4ca: 0f be c0 movsbl %al,%eax 4cd: 89 44 24 04 mov %eax,0x4(%esp) 4d1: 8b 45 08 mov 0x8(%ebp),%eax 4d4: 89 04 24 mov %eax,(%esp) 4d7: e8 bb fe ff ff call 397 <putc> 4dc: e9 30 01 00 00 jmp 611 <printf+0x19a> } } else if(state == '%'){ 4e1: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 4e5: 0f 85 26 01 00 00 jne 611 <printf+0x19a> if(c == 'd'){ 4eb: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 4ef: 75 2d jne 51e <printf+0xa7> printint(fd, *ap, 10, 1); 4f1: 8b 45 e8 mov -0x18(%ebp),%eax 4f4: 8b 00 mov (%eax),%eax 4f6: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) 4fd: 00 4fe: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 505: 00 506: 89 44 24 04 mov %eax,0x4(%esp) 50a: 8b 45 08 mov 0x8(%ebp),%eax 50d: 89 04 24 mov %eax,(%esp) 510: e8 aa fe ff ff call 3bf <printint> ap++; 515: 83 45 e8 04 addl $0x4,-0x18(%ebp) 519: e9 ec 00 00 00 jmp 60a <printf+0x193> } else if(c == 'x' || c == 'p'){ 51e: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 522: 74 06 je 52a <printf+0xb3> 524: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 528: 75 2d jne 557 <printf+0xe0> printint(fd, *ap, 16, 0); 52a: 8b 45 e8 mov -0x18(%ebp),%eax 52d: 8b 00 mov (%eax),%eax 52f: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 536: 00 537: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 53e: 00 53f: 89 44 24 04 mov %eax,0x4(%esp) 543: 8b 45 08 mov 0x8(%ebp),%eax 546: 89 04 24 mov %eax,(%esp) 549: e8 71 fe ff ff call 3bf <printint> ap++; 54e: 83 45 e8 04 addl $0x4,-0x18(%ebp) 552: e9 b3 00 00 00 jmp 60a <printf+0x193> } else if(c == 's'){ 557: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 55b: 75 45 jne 5a2 <printf+0x12b> s = (char*)*ap; 55d: 8b 45 e8 mov -0x18(%ebp),%eax 560: 8b 00 mov (%eax),%eax 562: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 565: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 569: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 56d: 75 09 jne 578 <printf+0x101> s = "(null)"; 56f: c7 45 f4 70 08 00 00 movl $0x870,-0xc(%ebp) while(*s != 0){ 576: eb 1e jmp 596 <printf+0x11f> 578: eb 1c jmp 596 <printf+0x11f> putc(fd, *s); 57a: 8b 45 f4 mov -0xc(%ebp),%eax 57d: 0f b6 00 movzbl (%eax),%eax 580: 0f be c0 movsbl %al,%eax 583: 89 44 24 04 mov %eax,0x4(%esp) 587: 8b 45 08 mov 0x8(%ebp),%eax 58a: 89 04 24 mov %eax,(%esp) 58d: e8 05 fe ff ff call 397 <putc> s++; 592: 83 45 f4 01 addl $0x1,-0xc(%ebp) } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 596: 8b 45 f4 mov -0xc(%ebp),%eax 599: 0f b6 00 movzbl (%eax),%eax 59c: 84 c0 test %al,%al 59e: 75 da jne 57a <printf+0x103> 5a0: eb 68 jmp 60a <printf+0x193> putc(fd, *s); s++; } } else if(c == 'c'){ 5a2: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 5a6: 75 1d jne 5c5 <printf+0x14e> putc(fd, *ap); 5a8: 8b 45 e8 mov -0x18(%ebp),%eax 5ab: 8b 00 mov (%eax),%eax 5ad: 0f be c0 movsbl %al,%eax 5b0: 89 44 24 04 mov %eax,0x4(%esp) 5b4: 8b 45 08 mov 0x8(%ebp),%eax 5b7: 89 04 24 mov %eax,(%esp) 5ba: e8 d8 fd ff ff call 397 <putc> ap++; 5bf: 83 45 e8 04 addl $0x4,-0x18(%ebp) 5c3: eb 45 jmp 60a <printf+0x193> } else if(c == '%'){ 5c5: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 5c9: 75 17 jne 5e2 <printf+0x16b> putc(fd, c); 5cb: 8b 45 e4 mov -0x1c(%ebp),%eax 5ce: 0f be c0 movsbl %al,%eax 5d1: 89 44 24 04 mov %eax,0x4(%esp) 5d5: 8b 45 08 mov 0x8(%ebp),%eax 5d8: 89 04 24 mov %eax,(%esp) 5db: e8 b7 fd ff ff call 397 <putc> 5e0: eb 28 jmp 60a <printf+0x193> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 5e2: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp) 5e9: 00 5ea: 8b 45 08 mov 0x8(%ebp),%eax 5ed: 89 04 24 mov %eax,(%esp) 5f0: e8 a2 fd ff ff call 397 <putc> putc(fd, c); 5f5: 8b 45 e4 mov -0x1c(%ebp),%eax 5f8: 0f be c0 movsbl %al,%eax 5fb: 89 44 24 04 mov %eax,0x4(%esp) 5ff: 8b 45 08 mov 0x8(%ebp),%eax 602: 89 04 24 mov %eax,(%esp) 605: e8 8d fd ff ff call 397 <putc> } state = 0; 60a: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 611: 83 45 f0 01 addl $0x1,-0x10(%ebp) 615: 8b 55 0c mov 0xc(%ebp),%edx 618: 8b 45 f0 mov -0x10(%ebp),%eax 61b: 01 d0 add %edx,%eax 61d: 0f b6 00 movzbl (%eax),%eax 620: 84 c0 test %al,%al 622: 0f 85 71 fe ff ff jne 499 <printf+0x22> putc(fd, c); } state = 0; } } } 628: c9 leave 629: c3 ret 0000062a <free>: static Header base; static Header *freep; void free(void *ap) { 62a: 55 push %ebp 62b: 89 e5 mov %esp,%ebp 62d: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 630: 8b 45 08 mov 0x8(%ebp),%eax 633: 83 e8 08 sub $0x8,%eax 636: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 639: a1 d8 0a 00 00 mov 0xad8,%eax 63e: 89 45 fc mov %eax,-0x4(%ebp) 641: eb 24 jmp 667 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 643: 8b 45 fc mov -0x4(%ebp),%eax 646: 8b 00 mov (%eax),%eax 648: 3b 45 fc cmp -0x4(%ebp),%eax 64b: 77 12 ja 65f <free+0x35> 64d: 8b 45 f8 mov -0x8(%ebp),%eax 650: 3b 45 fc cmp -0x4(%ebp),%eax 653: 77 24 ja 679 <free+0x4f> 655: 8b 45 fc mov -0x4(%ebp),%eax 658: 8b 00 mov (%eax),%eax 65a: 3b 45 f8 cmp -0x8(%ebp),%eax 65d: 77 1a ja 679 <free+0x4f> free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 65f: 8b 45 fc mov -0x4(%ebp),%eax 662: 8b 00 mov (%eax),%eax 664: 89 45 fc mov %eax,-0x4(%ebp) 667: 8b 45 f8 mov -0x8(%ebp),%eax 66a: 3b 45 fc cmp -0x4(%ebp),%eax 66d: 76 d4 jbe 643 <free+0x19> 66f: 8b 45 fc mov -0x4(%ebp),%eax 672: 8b 00 mov (%eax),%eax 674: 3b 45 f8 cmp -0x8(%ebp),%eax 677: 76 ca jbe 643 <free+0x19> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 679: 8b 45 f8 mov -0x8(%ebp),%eax 67c: 8b 40 04 mov 0x4(%eax),%eax 67f: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 686: 8b 45 f8 mov -0x8(%ebp),%eax 689: 01 c2 add %eax,%edx 68b: 8b 45 fc mov -0x4(%ebp),%eax 68e: 8b 00 mov (%eax),%eax 690: 39 c2 cmp %eax,%edx 692: 75 24 jne 6b8 <free+0x8e> bp->s.size += p->s.ptr->s.size; 694: 8b 45 f8 mov -0x8(%ebp),%eax 697: 8b 50 04 mov 0x4(%eax),%edx 69a: 8b 45 fc mov -0x4(%ebp),%eax 69d: 8b 00 mov (%eax),%eax 69f: 8b 40 04 mov 0x4(%eax),%eax 6a2: 01 c2 add %eax,%edx 6a4: 8b 45 f8 mov -0x8(%ebp),%eax 6a7: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 6aa: 8b 45 fc mov -0x4(%ebp),%eax 6ad: 8b 00 mov (%eax),%eax 6af: 8b 10 mov (%eax),%edx 6b1: 8b 45 f8 mov -0x8(%ebp),%eax 6b4: 89 10 mov %edx,(%eax) 6b6: eb 0a jmp 6c2 <free+0x98> } else bp->s.ptr = p->s.ptr; 6b8: 8b 45 fc mov -0x4(%ebp),%eax 6bb: 8b 10 mov (%eax),%edx 6bd: 8b 45 f8 mov -0x8(%ebp),%eax 6c0: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 6c2: 8b 45 fc mov -0x4(%ebp),%eax 6c5: 8b 40 04 mov 0x4(%eax),%eax 6c8: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 6cf: 8b 45 fc mov -0x4(%ebp),%eax 6d2: 01 d0 add %edx,%eax 6d4: 3b 45 f8 cmp -0x8(%ebp),%eax 6d7: 75 20 jne 6f9 <free+0xcf> p->s.size += bp->s.size; 6d9: 8b 45 fc mov -0x4(%ebp),%eax 6dc: 8b 50 04 mov 0x4(%eax),%edx 6df: 8b 45 f8 mov -0x8(%ebp),%eax 6e2: 8b 40 04 mov 0x4(%eax),%eax 6e5: 01 c2 add %eax,%edx 6e7: 8b 45 fc mov -0x4(%ebp),%eax 6ea: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 6ed: 8b 45 f8 mov -0x8(%ebp),%eax 6f0: 8b 10 mov (%eax),%edx 6f2: 8b 45 fc mov -0x4(%ebp),%eax 6f5: 89 10 mov %edx,(%eax) 6f7: eb 08 jmp 701 <free+0xd7> } else p->s.ptr = bp; 6f9: 8b 45 fc mov -0x4(%ebp),%eax 6fc: 8b 55 f8 mov -0x8(%ebp),%edx 6ff: 89 10 mov %edx,(%eax) freep = p; 701: 8b 45 fc mov -0x4(%ebp),%eax 704: a3 d8 0a 00 00 mov %eax,0xad8 } 709: c9 leave 70a: c3 ret 0000070b <morecore>: static Header* morecore(uint nu) { 70b: 55 push %ebp 70c: 89 e5 mov %esp,%ebp 70e: 83 ec 28 sub $0x28,%esp char *p; Header *hp; if(nu < 4096) 711: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 718: 77 07 ja 721 <morecore+0x16> nu = 4096; 71a: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 721: 8b 45 08 mov 0x8(%ebp),%eax 724: c1 e0 03 shl $0x3,%eax 727: 89 04 24 mov %eax,(%esp) 72a: e8 50 fc ff ff call 37f <sbrk> 72f: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 732: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 736: 75 07 jne 73f <morecore+0x34> return 0; 738: b8 00 00 00 00 mov $0x0,%eax 73d: eb 22 jmp 761 <morecore+0x56> hp = (Header*)p; 73f: 8b 45 f4 mov -0xc(%ebp),%eax 742: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 745: 8b 45 f0 mov -0x10(%ebp),%eax 748: 8b 55 08 mov 0x8(%ebp),%edx 74b: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 74e: 8b 45 f0 mov -0x10(%ebp),%eax 751: 83 c0 08 add $0x8,%eax 754: 89 04 24 mov %eax,(%esp) 757: e8 ce fe ff ff call 62a <free> return freep; 75c: a1 d8 0a 00 00 mov 0xad8,%eax } 761: c9 leave 762: c3 ret 00000763 <malloc>: void* malloc(uint nbytes) { 763: 55 push %ebp 764: 89 e5 mov %esp,%ebp 766: 83 ec 28 sub $0x28,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 769: 8b 45 08 mov 0x8(%ebp),%eax 76c: 83 c0 07 add $0x7,%eax 76f: c1 e8 03 shr $0x3,%eax 772: 83 c0 01 add $0x1,%eax 775: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 778: a1 d8 0a 00 00 mov 0xad8,%eax 77d: 89 45 f0 mov %eax,-0x10(%ebp) 780: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 784: 75 23 jne 7a9 <malloc+0x46> base.s.ptr = freep = prevp = &base; 786: c7 45 f0 d0 0a 00 00 movl $0xad0,-0x10(%ebp) 78d: 8b 45 f0 mov -0x10(%ebp),%eax 790: a3 d8 0a 00 00 mov %eax,0xad8 795: a1 d8 0a 00 00 mov 0xad8,%eax 79a: a3 d0 0a 00 00 mov %eax,0xad0 base.s.size = 0; 79f: c7 05 d4 0a 00 00 00 movl $0x0,0xad4 7a6: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 7a9: 8b 45 f0 mov -0x10(%ebp),%eax 7ac: 8b 00 mov (%eax),%eax 7ae: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 7b1: 8b 45 f4 mov -0xc(%ebp),%eax 7b4: 8b 40 04 mov 0x4(%eax),%eax 7b7: 3b 45 ec cmp -0x14(%ebp),%eax 7ba: 72 4d jb 809 <malloc+0xa6> if(p->s.size == nunits) 7bc: 8b 45 f4 mov -0xc(%ebp),%eax 7bf: 8b 40 04 mov 0x4(%eax),%eax 7c2: 3b 45 ec cmp -0x14(%ebp),%eax 7c5: 75 0c jne 7d3 <malloc+0x70> prevp->s.ptr = p->s.ptr; 7c7: 8b 45 f4 mov -0xc(%ebp),%eax 7ca: 8b 10 mov (%eax),%edx 7cc: 8b 45 f0 mov -0x10(%ebp),%eax 7cf: 89 10 mov %edx,(%eax) 7d1: eb 26 jmp 7f9 <malloc+0x96> else { p->s.size -= nunits; 7d3: 8b 45 f4 mov -0xc(%ebp),%eax 7d6: 8b 40 04 mov 0x4(%eax),%eax 7d9: 2b 45 ec sub -0x14(%ebp),%eax 7dc: 89 c2 mov %eax,%edx 7de: 8b 45 f4 mov -0xc(%ebp),%eax 7e1: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 7e4: 8b 45 f4 mov -0xc(%ebp),%eax 7e7: 8b 40 04 mov 0x4(%eax),%eax 7ea: c1 e0 03 shl $0x3,%eax 7ed: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 7f0: 8b 45 f4 mov -0xc(%ebp),%eax 7f3: 8b 55 ec mov -0x14(%ebp),%edx 7f6: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 7f9: 8b 45 f0 mov -0x10(%ebp),%eax 7fc: a3 d8 0a 00 00 mov %eax,0xad8 return (void*)(p + 1); 801: 8b 45 f4 mov -0xc(%ebp),%eax 804: 83 c0 08 add $0x8,%eax 807: eb 38 jmp 841 <malloc+0xde> } if(p == freep) 809: a1 d8 0a 00 00 mov 0xad8,%eax 80e: 39 45 f4 cmp %eax,-0xc(%ebp) 811: 75 1b jne 82e <malloc+0xcb> if((p = morecore(nunits)) == 0) 813: 8b 45 ec mov -0x14(%ebp),%eax 816: 89 04 24 mov %eax,(%esp) 819: e8 ed fe ff ff call 70b <morecore> 81e: 89 45 f4 mov %eax,-0xc(%ebp) 821: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 825: 75 07 jne 82e <malloc+0xcb> return 0; 827: b8 00 00 00 00 mov $0x0,%eax 82c: eb 13 jmp 841 <malloc+0xde> nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 82e: 8b 45 f4 mov -0xc(%ebp),%eax 831: 89 45 f0 mov %eax,-0x10(%ebp) 834: 8b 45 f4 mov -0xc(%ebp),%eax 837: 8b 00 mov (%eax),%eax 839: 89 45 f4 mov %eax,-0xc(%ebp) return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } 83c: e9 70 ff ff ff jmp 7b1 <malloc+0x4e> } 841: c9 leave 842: c3 ret
tzulang/xv6_4
rm.asm
Assembly
mit
40,983
--- layout: page title: About Us permalink: /about/ --- Just started in 2015, we bring passion and energy to the industry backed by years of real-world experience. We strive to make our software both useful and usable, which can often be a fun challenge in today's fast-paced world. We are woman-owned small business based out of Lacey, Washington. ### What clients say > I really enjoyed working with Eve and would work with her again in a heartbeat. <!-- --> > After working with [Eve] for over a year, I can happily say it has been my pleasure and I look forward to working with her in the future. ### Contact [[email protected]](mailto:[email protected]) (360) 216-1738
eve-corp/eve-corp.github.io
about.md
Markdown
mit
688
# Editing a document with Vim Today was the first time I used Vim to edit a text file. I'd previously install Vim and attempted to play around with it, but I had no clue what I was doing and abandoned it until now. My issue was that I couldn't figure out how to actually add or edit the contents of a text file. Silly, I know, but it wasn't cut and dry and I didn't have the patience to figure it out at the time. So, here's what you do: ``` vim [existing file name, or create a new file] ``` This command will launch Vim in the terminal in 'Command mode' with either your existing file or a blank one. If there is already text in the file, you'll be able to see it, but NOT edit it. To do this, you'll need to type `i` to enter insert mode, where you'll have full control of your file. From here, you can type to your heart's content. When you're through, hit `esc` to re-enter command mode. From command mode, you can quit AND save your work using `:wq` or just quit by typing `:q`. This is pretty much the bare minimum needed to use Vim. I'm going to try and add it to my workflow for these TIL posts. It'd be neat to do everything straight form Terminal. I'll of course be back to update my progress learning Vim. I know it's extremely powerful and that's why I'm excited to learn more!
kingbryan/til
vim/editing-doc-with-vim-021116.md
Markdown
mit
1,299
<?php namespace Tests\Map\Gazzetta; use PHPUnit\Framework\TestCase; use FFQP\Map\Gazzetta\GazzettaMapSince2013; class GazzettaMapSince2013Test extends TestCase { public function testExtractRows() { $map = new GazzettaMapSince2013(); $this->assertInternalType('int', 3); $rows = $map->extractRows('tests/fixtures/2014_quotazioni_gazzetta_01.xls'); $this->assertSame(665, count($rows)); // First Footballer $this->assertSame('101', $rows[0]->code); $this->assertSame('ABBIATI', $rows[0]->player); $this->assertSame('MILAN', $rows[0]->team); $this->assertSame('P', $rows[0]->role); $this->assertSame('P', $rows[0]->secondaryRole); $this->assertSame('1', $rows[0]->status); $this->assertSame('12', $rows[0]->quotation); $this->assertSame('-', $rows[0]->magicPoints); $this->assertSame('-', $rows[0]->vote); $this->assertSame('', $rows[0]->goals); $this->assertSame('', $rows[0]->yellowCards); $this->assertSame('', $rows[0]->redCards); $this->assertSame('', $rows[0]->penalties); $this->assertSame('', $rows[0]->autoGoals); $this->assertSame('', $rows[0]->assists); // Footballer with a vote $this->assertSame('106', $rows[5]->code); $this->assertSame('BARDI', $rows[5]->player); $this->assertSame('CHIEVO', $rows[5]->team); $this->assertSame('P', $rows[5]->role); $this->assertSame('P', $rows[5]->secondaryRole); $this->assertSame('1', $rows[5]->status); $this->assertSame('8', $rows[5]->quotation); $this->assertSame('4', $rows[5]->magicPoints); $this->assertSame('5', $rows[5]->vote); $this->assertSame('-1', $rows[5]->goals); $this->assertSame('0', $rows[5]->yellowCards); $this->assertSame('0', $rows[5]->redCards); $this->assertSame('0', $rows[5]->penalties); $this->assertSame('0', $rows[5]->autoGoals); $this->assertSame('0', $rows[5]->assists); // Footballer without a vote $this->assertSame('105', $rows[4]->code); $this->assertSame('AVRAMOV', $rows[4]->player); $this->assertSame('ATALANTA', $rows[4]->team); $this->assertSame('P', $rows[4]->role); $this->assertSame('P', $rows[4]->secondaryRole); $this->assertSame('1', $rows[4]->status); $this->assertSame('1', $rows[4]->quotation); $this->assertSame('-', $rows[4]->magicPoints); $this->assertSame('-', $rows[4]->vote); $this->assertSame('', $rows[4]->goals); $this->assertSame('', $rows[4]->yellowCards); $this->assertSame('', $rows[4]->redCards); $this->assertSame('', $rows[4]->penalties); $this->assertSame('', $rows[4]->autoGoals); $this->assertSame('', $rows[4]->assists); } }
astronati/fantasy-football-quotations-parser
tests/Map/Gazzetta/GazzettaMapSince2013Test.php
PHP
mit
2,877
/* * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) * * Copyright (c) 2013, 2014 Damien P. George * Copyright (c) 2015 Daniel Campora * * 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. */ #ifndef MICROPY_INCLUDED_LIB_TIMEUTILS_TIMEUTILS_H #define MICROPY_INCLUDED_LIB_TIMEUTILS_TIMEUTILS_H typedef int64_t mp_time_t; typedef struct _timeutils_struct_time_t { uint16_t tm_year; // i.e. 2014 uint8_t tm_mon; // 1..12 uint8_t tm_mday; // 1..31 uint8_t tm_hour; // 0..23 uint8_t tm_min; // 0..59 uint8_t tm_sec; // 0..59 uint8_t tm_wday; // 0..6 0 = Monday uint16_t tm_yday; // 1..366 } timeutils_struct_time_t; bool timeutils_is_leap_year(mp_uint_t year); mp_uint_t timeutils_days_in_month(mp_uint_t year, mp_uint_t month); mp_uint_t timeutils_year_day(mp_uint_t year, mp_uint_t month, mp_uint_t date); void timeutils_seconds_since_2000_to_struct_time(mp_uint_t t, timeutils_struct_time_t *tm); mp_uint_t timeutils_seconds_since_2000(mp_uint_t year, mp_uint_t month, mp_uint_t date, mp_uint_t hour, mp_uint_t minute, mp_uint_t second); mp_uint_t timeutils_mktime(mp_uint_t year, mp_int_t month, mp_int_t mday, mp_int_t hours, mp_int_t minutes, mp_int_t seconds); void timeutils_seconds_since_epoch_to_struct_time(mp_time_t t, timeutils_struct_time_t *tm); mp_time_t timeutils_seconds_since_epoch(mp_uint_t year, mp_uint_t month, mp_uint_t date, mp_uint_t hour, mp_uint_t minute, mp_uint_t second); mp_time_t timeutils_mktime_epoch(mp_uint_t year, mp_int_t month, mp_int_t mday, mp_int_t hours, mp_int_t minutes, mp_int_t seconds); #endif // MICROPY_INCLUDED_LIB_TIMEUTILS_TIMEUTILS_H
SHA2017-badge/micropython-esp32
lib/timeutils/timeutils.h
C
mit
2,785
<?php namespace ObjectStorage\Test\Adapter; use ObjectStorage\Adapter\PlaintextStorageKeyEncryptedStorageAdapter; use ObjectStorage\Adapter\StorageAdapterInterface; use ParagonIE\Halite\KeyFactory; use ParagonIE\Halite\Symmetric\Crypto; use ParagonIE\HiddenString\HiddenString; use PHPUnit\Framework\Constraint\LogicalNot; use PHPUnit\Framework\TestCase; class PlaintextStorageKeyEncryptedStorageAdapterTest extends TestCase { private $encryptedStorageAdapter; private $encryptionKey; private $storageAdapter; protected function setUp(): void { $this->encryptionKey = KeyFactory::generateEncryptionKey(); $this->storageAdapter = $this->getMockBuilder(StorageAdapterInterface::class) ->getMockForAbstractClass() ; $this->encryptedStorageAdapter = new PlaintextStorageKeyEncryptedStorageAdapter( $this->storageAdapter, $this->encryptionKey ); } public function testSetDataDoesNotPassUnencryptedDataToStorageAdapter() { $this->storageAdapter ->expects($this->once()) ->method('setData') ->with( $this->identicalTo('some-key'), new LogicalNot('some-data') ) ; $this->encryptedStorageAdapter->setData('some-key', 'some-data'); } public function testGetDataDoesNotPassUnencryptedDataToStorageAdapter() { $this->storageAdapter ->expects($this->once()) ->method('getData') ->with($this->identicalTo('some-key')) ->willReturn(Crypto::encrypt(new HiddenString('some-data'), $this->encryptionKey)) ; $this->encryptedStorageAdapter->getData('some-key'); } public function testDeleteDataDoesNotPassUnencryptedDataToStorageAdapter() { $this->storageAdapter ->expects($this->once()) ->method('deleteData') ->with($this->identicalTo('some-key')) ; $this->encryptedStorageAdapter->deleteData('some-key'); } }
linkorb/objectstorage
tests/Adapter/PlaintextStorageKeyEncryptedStorageAdapterTest.php
PHP
mit
2,076
package com.github.kolandroid.kol.model.elements.basic; import com.github.kolandroid.kol.model.elements.interfaces.ModelGroup; import java.util.ArrayList; import java.util.Iterator; public class BasicGroup<E> implements ModelGroup<E> { /** * Autogenerated by eclipse. */ private static final long serialVersionUID = 356357357356695L; private final ArrayList<E> items; private final String name; public BasicGroup(String name) { this(name, new ArrayList<E>()); } public BasicGroup(String name, ArrayList<E> items) { this.name = name; this.items = items; } @Override public int size() { return items.size(); } @Override public E get(int index) { return items.get(index); } @Override public void set(int index, E value) { items.set(index, value); } @Override public void remove(int index) { items.remove(index); } public void add(E item) { items.add(item); } @Override public String getName() { return name; } @Override public Iterator<E> iterator() { return items.iterator(); } }
Kasekopf/kolandroid
kol_base/src/main/java/com/github/kolandroid/kol/model/elements/basic/BasicGroup.java
Java
mit
1,193
import Ember from 'ember'; import { module, test } from 'qunit'; import startApp from 'superhero/tests/helpers/start-app'; import characterData from '../fixtures/character'; var application, server; module('Acceptance: Character', { beforeEach: function() { application = startApp(); var character = characterData(); server = new Pretender(function() { this.get('/v1/public/characters/1009609', function(request) { var responseData = JSON.stringify(character); return [ 200, {"Content-Type": "application/json"}, responseData ]; }); }); }, afterEach: function() { Ember.run(application, 'destroy'); server.shutdown(); } }); test('visiting /characters/1009609 shows character detail', function(assert) { assert.expect(3); visit('/characters/1009609'); andThen(function() { assert.equal(currentURL(), '/characters/1009609'); assert.equal(find('.heading').text(), 'Spider-Girl (May Parker)', 'Should show character heading'); assert.equal( find('.description').text(), "May \"Mayday\" Parker is the daughter of Spider-Man and Mary Jane Watson-Parker. Born with all her father's powers-and the same silly sense of humor-she's grown up to become one of Earth's most trusted heroes and a fitting tribute to her proud papa.", 'Should show character descripton' ); }); }); test('visiting /characters/1009609 shows key events for the character', function(assert) { assert.expect(2); visit('/characters/1009609'); andThen(function() { assert.equal(find('.events .event').length, 1, 'Should show one event'); assert.equal( find('.events .event:first').text(), 'Fear Itself', 'Should show event name' ); }); });
dtt101/superhero
tests/acceptance/character-test.js
JavaScript
mit
1,790
#ifndef CAVALIERI_RULE_TESTER_UTIL_H #define CAVALIERI_RULE_TESTER_UTIL_H #include <vector> #include <common/event.h> #include <external/mock_external.h> typedef std::pair<time_t, Event> mock_index_events_t; std::vector<Event> json_to_events(const std::string json, bool & ok); std::string results(std::vector<mock_index_events_t> index_events, std::vector<external_event_t> external_events); #endif
juruen/cavalieri
include/rule_tester_util.h
C
mit
425
//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.34014 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace Genius.VisualStudio.BaseEditors.Properties { using System; /// <summary> /// A strongly-typed resource class, for looking up localized strings, etc. /// </summary> // This class was auto-generated by the StronglyTypedResourceBuilder // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { private static global::System.Resources.ResourceManager resourceMan; private static global::System.Globalization.CultureInfo resourceCulture; [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } /// <summary> /// Returns the cached ResourceManager instance used by this class. /// </summary> [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Genius.VisualStudio.BaseEditors.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } /// <summary> /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// </summary> [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } /// <summary> /// Looks up a localized string similar to XmlDesigner Designer. /// </summary> internal static string ErrorMessageBoxTitle { get { return ResourceManager.GetString("ErrorMessageBoxTitle", resourceCulture); } } /// <summary> /// Looks up a localized string similar to The xml file you are attempting to load is invalid for your model.. /// </summary> internal static string InvalidXmlData { get { return ResourceManager.GetString("InvalidXmlData", resourceCulture); } } /// <summary> /// Looks up a localized string similar to Reformat. /// </summary> internal static string ReformatBuffer { get { return ResourceManager.GetString("ReformatBuffer", resourceCulture); } } /// <summary> /// Looks up a localized string similar to Synchronize XML file with view. /// </summary> internal static string SynchronizeBuffer { get { return ResourceManager.GetString("SynchronizeBuffer", resourceCulture); } } } }
pgourlain/VsXmlDesigner
BaseEditors/Properties/Resources.Designer.cs
C#
mit
4,105
#!/usr/bin/perl -w use strict; use Getopt::Long; use FindBin qw($Bin $Script); use File::Basename qw(basename dirname); use Data::Dumper; use lib "/home/zhoujj/my_lib/pm"; use bioinfo; &usage if @ARGV<1; #open IN,"" ||die "Can't open the file:$\n"; #open OUT,"" ||die "Can't open the file:$\n"; sub usage { my $usage = << "USAGE"; Description of this script. Author: zhoujj2013\@gmail.com Usage: $0 <para1> <para2> Example:perl $0 para1 para2 USAGE print "$usage"; exit(1); }; my ($all_int_f, $directed_int_f, $inferred_int_f, $ra_scored_inferred_int_f) = @ARGV; my %directed; open IN,"$directed_int_f" || die $!; while(<IN>){ chomp; my @t = split /\t/; unless(exists $directed{$t[0]}{$t[1]} || exists $directed{$t[1]}{$t[0]}){ my $score = 1; if($t[3] =~ /\d+$/){ $score = $t[3]; }else{ $score = 1; } $directed{$t[0]}{$t[1]} = $score; } } close IN; my %inferred; open IN,"$inferred_int_f" || die $!; while(<IN>){ chomp; my @t = split /\t/; unless(exists $inferred{$t[0]}{$t[1]} || exists $inferred{$t[1]}{$t[0]}){ my $score = 0; if($t[3] =~ /\d+$/){ $score = $t[3]; }else{ $score = 1; } $inferred{$t[0]}{$t[1]} = $score; } } close IN; my %ra; open IN,"$ra_scored_inferred_int_f" || die $!; while(<IN>){ chomp; my @t = split /\t/; unless(exists $ra{$t[0]}{$t[1]} || exists $ra{$t[1]}{$t[0]}){ $ra{$t[0]}{$t[1]} = $t[3]; } } close IN; my %int; open IN,"$all_int_f" || die $!; while(<IN>){ chomp; my @t = split /\t/; if(exists $directed{$t[0]}{$t[1]} || exists $directed{$t[1]}{$t[0]}){ my $score = abs($directed{$t[0]}{$t[1]}); $t[3] = $score; }elsif(exists $inferred{$t[0]}{$t[1]} || exists $inferred{$t[1]}{$t[0]}){ my $score1 = 0; if(exists $inferred{$t[0]}{$t[1]}){ $score1 = $inferred{$t[0]}{$t[1]}; }elsif(exists $inferred{$t[1]}{$t[0]}){ $score1 = $inferred{$t[1]}{$t[0]}; } my $score2 = 0; if(exists $ra{$t[0]}{$t[1]}){ $score2 = abs($ra{$t[0]}{$t[1]}); }elsif(exists $ra{$t[1]}{$t[0]}){ $score2 = abs($ra{$t[1]}{$t[0]}); } my $score = ($score1 + $score2)/2; $t[3] = $score; } print join "\t",@t; print "\n"; } close IN;
zhoujj2013/lncfuntk
bin/NetworkConstruction/bk/CalcConfidentScore.pl
Perl
mit
2,170
<table> <thead> <tr> <th>Nombre</th> <th>RUT</th> <th>Sexo</th> <th>Dirección</th> <th>Ciudad/Comuna</th> </tr> </thead> <tbody> </tbody> </table>
lgaticaq/info-rut
test/replies/person-fail.html
HTML
mit
196
\begin{tikzpicture} \begin{axis}[ width=9cm,height=6cm, ymin=0, ytick align=outside, axis x line*=bottom,axis y line*=left, tick label style={ /pgf/number format/assume math mode=true, /pgf/number format/1000 sep={} }, ylabel={\# citations}, % enlargelimits=0.15, ybar, bar width=12pt, ] \addplot[ fill=lightgray, nodes near coords, every node near coord/.append style={ /pgf/number format/assume math mode=true, font=\small } ] coordinates{ (2010,2) (2011,7) (2012,22) (2013,51) (2014,73) (2015,92) (2016,123) (2017,141) }; \end{axis} \end{tikzpicture}
jdferreira/vitae
images/histogram-citations.tex
TeX
mit
715
.podcast-channel-header{width:100%;clear:both;display:inline-block;border-bottom:3px solid #000}.podcast-channel-image{width:25%;float:left;display:inline-block;border:1px solid #000}.channel-meta{width:74%;float:left;display:inline-block}.channel-meta h1{text-align:center;margin:0}.channel-meta h2{text-align:center}.channel-meta p.owner{text-align:center;margin:-1em 0 0 0}.channel-meta p.description{margin-left:auto;margin-right:auto;text-align:center;line-height:1.2}.channel-links{float:left;margin-left:2em}.channel-content{display:inline-block}#episodes{display:inline-block;clear:both;width:75%;float:left}#episodes ul{list-style-type:none}.clearfix{clear:both}#podcast-series{-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;display:inline-block;background:#ccc;width:24%;float:right;min-height:16em}#podcast-series h2{font-size:20px;text-align:center}#podcast-series a{color:#000}#podcast-series a:hover{font-weight:bold} /*# sourceMappingURL=podcast.css.map */
floede/freeplay-blog
user/plugins/podcast/assets/css/podcast.css
CSS
mit
992
#!/usr/bin/env node (function () { var DirectoryLayout = require('../lib/index.js'), program = require('commander'), options; program .version('1.0.2') .usage('[options] <path, ...>') .option('-g, --generate <path> <output-directory-layout-file-path>', 'Generate directory layout') .option('-v, --verify <input-directory-layout-file-path> <path>', 'Verify directory layout') .parse(process.argv); if(program.generate) { options = { output: program.args[0] || 'layout.md', ignore: [] }; console.log('Generating layout for ' + program.generate + '... \n') DirectoryLayout .generate(program.generate, options) .then(function() { console.log('Layout generated at: ' + options.output); }); } else if(program.verify) { options = { root: program.args[0] }; console.log('Verifying layout for ' + options.root + ' ...\n'); DirectoryLayout .verify(program.verify, options) .then(function() { console.log('Successfully verified layout available in ' + program.verify + '.'); }); } }());
ApoorvSaxena/directory-layout
bin/index.js
JavaScript
mit
1,267
--- layout: post title: "Seek for Sole External Sponsor" date: 2017-08-08 18:00:00 isStaticPost: false --- We are seeking for one more sponsor except ShanghaiTech University to cover the expenses of awarding excellent presenters. Note that you cannot title the event, you can only show here at the website and in the final awarding ceremony.
xiongzhp/FoGG2017
_posts/2017-08-08-seek-for-sole-sponsor.markdown
Markdown
mit
345
var class_snowflake_1_1_game_1_1_game_database = [ [ "GameDatabase", "class_snowflake_1_1_game_1_1_game_database.html#a2f09c1f7fe18beaf8be1447e541f4d68", null ], [ "AddGame", "class_snowflake_1_1_game_1_1_game_database.html#a859513bbac24328df5d3fe2e47dbc183", null ], [ "GetAllGames", "class_snowflake_1_1_game_1_1_game_database.html#a7c43f2ccabe44f0491ae25e9b88bb07a", null ], [ "GetGameByUUID", "class_snowflake_1_1_game_1_1_game_database.html#ada7d853b053f0bbfbc6dea8eb89e85c4", null ], [ "GetGamesByName", "class_snowflake_1_1_game_1_1_game_database.html#ac1bbd90e79957e360dd5542f6052616e", null ], [ "GetGamesByPlatform", "class_snowflake_1_1_game_1_1_game_database.html#a2e93a35ea18a9caac9a6165cb33b5494", null ] ];
SnowflakePowered/snowflakepowered.github.io
doc/html/class_snowflake_1_1_game_1_1_game_database.js
JavaScript
mit
745
--- layout: api_index title: api breadcrumbs: true --- {% include api_listing.html %}
tempusjs/tempus-js.com
api/index.html
HTML
mit
85
package org.winterblade.minecraft.harmony.api.questing; import org.winterblade.minecraft.scripting.api.IScriptObjectDeserializer; import org.winterblade.minecraft.scripting.api.ScriptObjectDeserializer; /** * Created by Matt on 5/29/2016. */ public enum QuestStatus { INVALID, ACTIVE, LOCKED, COMPLETE, CLOSED; @ScriptObjectDeserializer(deserializes = QuestStatus.class) public static class Deserializer implements IScriptObjectDeserializer { @Override public Object Deserialize(Object input) { if(!String.class.isAssignableFrom(input.getClass())) return null; return QuestStatus.valueOf(input.toString().toUpperCase()); } } }
legendblade/CraftingHarmonics
api/src/main/java/org/winterblade/minecraft/harmony/api/questing/QuestStatus.java
Java
mit
697
package leetcode11_20; /**Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5. Note: Given n will always be valid. Try to do this in one pass. */ public class RemoveNthFromEnd { // Definition for singly-linked list. public static class ListNode { int val; ListNode next; ListNode(int x) { val = x; } } //one pass public ListNode removeNthFromEnd(ListNode head, int n) { ListNode dummy = new ListNode(0); dummy.next = head; ListNode slow = dummy, fast = dummy; //Move fast in front so that the gap between slow and fast becomes n for(int i=1; i<=n+1; i++) { //TODO 注意边界 fast = fast.next; } while(fast != null) {//Move fast to the end, maintaining the gap slow = slow.next; fast = fast.next; } slow.next = slow.next.next;//Skip the desired node return dummy.next; } //two pass public ListNode removeNthFromEnd1(ListNode head, int n) { int length = 0; ListNode temp = head; while (temp != null){ length++; temp = temp.next; } if (n == length) return head.next; temp = head; for (int i = 2; i <= length - n; i++){ //TODO 循环条件极易出错 temp = temp.next; } temp.next = temp.next.next; return head; } }
Ernestyj/JStudy
src/main/java/leetcode11_20/RemoveNthFromEnd.java
Java
mit
1,586
package org.kohsuke.github; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.net.URLEncoder; import java.util.Collections; import java.util.Date; import java.util.List; import static java.lang.String.*; /** * Release in a github repository. * * @see GHRepository#getReleases() GHRepository#getReleases() * @see GHRepository#listReleases() () GHRepository#listReleases() * @see GHRepository#createRelease(String) GHRepository#createRelease(String) */ public class GHRelease extends GHObject { GHRepository owner; private String html_url; private String assets_url; private List<GHAsset> assets; private String upload_url; private String tag_name; private String target_commitish; private String name; private String body; private boolean draft; private boolean prerelease; private Date published_at; private String tarball_url; private String zipball_url; private String discussion_url; /** * Gets discussion url. Only present if a discussion relating to the release exists * * @return the discussion url */ public String getDiscussionUrl() { return discussion_url; } /** * Gets assets url. * * @return the assets url */ public String getAssetsUrl() { return assets_url; } /** * Gets body. * * @return the body */ public String getBody() { return body; } /** * Is draft boolean. * * @return the boolean */ public boolean isDraft() { return draft; } /** * Sets draft. * * @param draft * the draft * @return the draft * @throws IOException * the io exception * @deprecated Use {@link #update()} */ @Deprecated public GHRelease setDraft(boolean draft) throws IOException { return update().draft(draft).update(); } public URL getHtmlUrl() { return GitHubClient.parseURL(html_url); } /** * Gets name. * * @return the name */ public String getName() { return name; } /** * Sets name. * * @param name * the name */ public void setName(String name) { this.name = name; } /** * Gets owner. * * @return the owner */ @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior") public GHRepository getOwner() { return owner; } /** * Sets owner. * * @param owner * the owner * @deprecated Do not use this method. It was added due to incomplete understanding of Jackson binding. */ @Deprecated public void setOwner(GHRepository owner) { throw new RuntimeException("Do not use this method."); } /** * Is prerelease boolean. * * @return the boolean */ public boolean isPrerelease() { return prerelease; } /** * Gets published at. * * @return the published at */ public Date getPublished_at() { return new Date(published_at.getTime()); } /** * Gets tag name. * * @return the tag name */ public String getTagName() { return tag_name; } /** * Gets target commitish. * * @return the target commitish */ public String getTargetCommitish() { return target_commitish; } /** * Gets upload url. * * @return the upload url */ public String getUploadUrl() { return upload_url; } /** * Gets zipball url. * * @return the zipball url */ public String getZipballUrl() { return zipball_url; } /** * Gets tarball url. * * @return the tarball url */ public String getTarballUrl() { return tarball_url; } GHRelease wrap(GHRepository owner) { this.owner = owner; return this; } static GHRelease[] wrap(GHRelease[] releases, GHRepository owner) { for (GHRelease release : releases) { release.wrap(owner); } return releases; } /** * Because github relies on SNI (http://en.wikipedia.org/wiki/Server_Name_Indication) this method will only work on * Java 7 or greater. Options for fixing this for earlier JVMs can be found here * http://stackoverflow.com/questions/12361090/server-name-indication-sni-on-java but involve more complicated * handling of the HTTP requests to github's API. * * @param file * the file * @param contentType * the content type * @return the gh asset * @throws IOException * the io exception */ public GHAsset uploadAsset(File file, String contentType) throws IOException { FileInputStream s = new FileInputStream(file); try { return uploadAsset(file.getName(), s, contentType); } finally { s.close(); } } /** * Upload asset gh asset. * * @param filename * the filename * @param stream * the stream * @param contentType * the content type * @return the gh asset * @throws IOException * the io exception */ public GHAsset uploadAsset(String filename, InputStream stream, String contentType) throws IOException { Requester builder = owner.root().createRequest().method("POST"); String url = getUploadUrl(); // strip the helpful garbage from the url url = url.substring(0, url.indexOf('{')); url += "?name=" + URLEncoder.encode(filename, "UTF-8"); return builder.contentType(contentType).with(stream).withUrlPath(url).fetch(GHAsset.class).wrap(this); } /** * Get the cached assets. * * @return the assets * * @deprecated This should be the default behavior of {@link #getAssets()} in a future release. This method is * introduced in addition to enable a transition to using cached asset information while keeping the * existing logic in place for backwards compatibility. */ @Deprecated public List<GHAsset> assets() { return Collections.unmodifiableList(assets); } /** * Re-fetch the assets of this release. * * @return the assets * @throws IOException * the io exception * @deprecated The behavior of this method will change in a future release. It will then provide cached assets as * provided by {@link #assets()}. Use {@link #listAssets()} instead to fetch up-to-date information of * assets. */ @Deprecated public List<GHAsset> getAssets() throws IOException { return listAssets().toList(); } /** * Re-fetch the assets of this release. * * @return the assets * @throws IOException * the io exception */ public PagedIterable<GHAsset> listAssets() throws IOException { Requester builder = owner.root().createRequest(); return builder.withUrlPath(getApiTailUrl("assets")).toIterable(GHAsset[].class, item -> item.wrap(this)); } /** * Deletes this release. * * @throws IOException * the io exception */ public void delete() throws IOException { root().createRequest().method("DELETE").withUrlPath(owner.getApiTailUrl("releases/" + getId())).send(); } /** * Updates this release via a builder. * * @return the gh release updater */ public GHReleaseUpdater update() { return new GHReleaseUpdater(this); } private String getApiTailUrl(String end) { return owner.getApiTailUrl(format("releases/%s/%s", getId(), end)); } }
kohsuke/github-api
src/main/java/org/kohsuke/github/GHRelease.java
Java
mit
8,107
import cairo from gi.repository import Gtk from gi.repository import Gdk from pylsner import plugin class Window(Gtk.Window): def __init__(self): super(Window, self).__init__(skip_pager_hint=True, skip_taskbar_hint=True, ) self.set_title('Pylsner') screen = self.get_screen() self.width = screen.get_width() self.height = screen.get_height() self.set_size_request(self.width, self.height) self.set_position(Gtk.WindowPosition.CENTER) rgba = screen.get_rgba_visual() self.set_visual(rgba) self.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 0), ) self.set_wmclass('pylsner', 'pylsner') self.set_type_hint(Gdk.WindowTypeHint.DOCK) self.stick() self.set_keep_below(True) drawing_area = Gtk.DrawingArea() drawing_area.connect('draw', self.redraw) self.refresh_cnt = 0 self.add(drawing_area) self.connect('destroy', lambda q: Gtk.main_quit()) self.widgets = [] self.show_all() def refresh(self, force=False): self.refresh_cnt += 1 if self.refresh_cnt >= 60000: self.refresh_cnt = 0 redraw_required = False for wid in self.widgets: if (self.refresh_cnt % wid.metric.refresh_rate == 0) or force: wid.refresh() redraw_required = True if redraw_required: self.queue_draw() return True def redraw(self, _, ctx): ctx.set_antialias(cairo.ANTIALIAS_SUBPIXEL) for wid in self.widgets: wid.redraw(ctx) class Widget: def __init__(self, name='default', metric={'plugin': 'time'}, indicator={'plugin': 'arc'}, fill={'plugin': 'rgba_255'}, ): self.name = name MetricPlugin = plugin.load_plugin('metrics', metric['plugin']) self.metric = MetricPlugin(**metric) IndicatorPlugin = plugin.load_plugin('indicators', indicator['plugin']) self.indicator = IndicatorPlugin(**indicator) FillPlugin = plugin.load_plugin('fills', fill['plugin']) self.fill = FillPlugin(**fill) def refresh(self): self.metric.refresh() self.fill.refresh(self.metric.value) def redraw(self, ctx): ctx.set_source(self.fill.pattern) self.indicator.redraw(ctx, self.metric.value)
mrmrwat/pylsner
pylsner/gui.py
Python
mit
2,624
<!DOCTYPE html> <html> <head> <title>likeness:Configuration#children~details documentation</title> <link rel="stylesheet" type="text/css" href="../../../../../../../../index.css" /> <link rel="stylesheet" type="text/css" href="../../../../../../../../highlight.css" /> <script type="text/javascript" src="../../../../../../../../index.js"></script> </head> <body class="spare" id="component_1995"> <div id="outer"> <div id="header"> <a class="ctype" href="../../../../../../../../index.html">spare</a> <span></span> <span class="breadcrumbs"> <span class="delimiter">:</span><a href="../../../../../../index.html" class="breadcrumb module">likeness</a><span class="delimiter">:</span><a href="../../../../index.html" class="breadcrumb module">Configuration</a><span class="delimiter">#</span><a href="../../index.html" class="breadcrumb member">children</a><span class="delimiter">~</span><a href="index.html" class="breadcrumb spare">details</a> </span> </div> <div id="content"> <!-- basic document info --> <div id="details"> <div class="markdown"><p>If a fixed child name begins with a period, this property is used to insulate it from the operator namespace.</p> </div> <div class="clear"></div> </div> <div class="children"> </div> </div> </div> <div id="footer"> This document was generated with <a href="https://github.com/shenanigans/node-doczar">doczar</a> at <span class="time">4:47pm</span> on <span class="date">8/11/2015</span> </div> </body> </html>
shenanigans/node-sublayer
static/docs/generated/module/likeness/module/configuration/member/children/spare/details/index.html
HTML
mit
1,754
<?php $t = $a->getThing(); ?> <div class="linkitem item-flavour-<?php echo $a->getFlavour() ?>" id="link-item-<?php echo $a->getId(); ?>"> <?php if (isset($nopos)): ?> <span class="itempos">&nbsp;</span> <?php else: ?> <span class="itempos"><?php echo $pos; ?></span> <?php endif; ?> <div class="votebtn"> <?php if ($sf_user->isAuthenticated()):?> <?php $vote = $a->getThing()->getUserVote($sf_user->getId()); ?> <?php if ($vote): ?> <?php if ($vote['type'] == 'up'): ?> <a href="#" onclick="voteUp(this, <?php echo $t->getId(); ?>); return false;"> <?php echo image_tag('mod_up.png', array('id' => 'link-up-' . $t->getId())) ?> </a> <?php else: ?> <a href="#" onclick="voteUp(this, <?php echo $t->getId(); ?>); return false;"> <?php echo image_tag('up.png', array('id' => 'link-up-' . $t->getId())) ?> </a> <?php endif; ?> <?php if ($vote['type'] == 'down'): ?> <a href="#" onclick="voteDown(this, <?php echo $t->getId(); ?>); return false;"> <?php echo image_tag('mod_down.png', array('id' => 'link-down-' . $t->getId())) ?> </a> <?php else: ?> <a href="#" onclick="voteDown(this, <?php echo $t->getId(); ?>); return false;"> <?php echo image_tag('down.png', array('id' => 'link-down-' . $t->getId())) ?> </a> <?php endif; ?> <?php else: ?> <a href="#" onclick="voteUp(this, <?php echo $t->getId(); ?>); return false;"><?php echo image_tag('up.png', array('id' => 'link-up-' . $t->getId())) ?></a> <a href="#" onclick="voteDown(this, <?php echo $t->getId(); ?>); return false;"><?php echo image_tag('down.png', array('id' => 'link-down-' . $t->getId())) ?></a> <?php endif; ?> <?php else: ?> <a href="#" onclick="return false;"><?php echo image_tag('up.png', array('id' => 'link-up-' . $t->getId())) ?></a> <a href="#" onclick="return false;"><?php echo image_tag('down.png', array('id' => 'link-down-' . $t->getId())) ?></a> <?php endif; ?> </div> <div class="item"> <?php if ($a->getFlavour() == 'link'): ?> <p><?php echo link_to($a->getTitle(), $a->getUrl(), array('class' => 'name', 'target' => '_blank', 'rel' => 'nofollow')); ?></p> <p class="url"><?php echo $a->getUrl(); ?></p> <?php else: ?> <p><?php echo link_to($a->getTitle(), $a->getViewUrl(), array('class' => 'name')); ?></p> <?php endif;?> <p class="link_footer"> <span class="flavour-<?php echo $a->getFlavour(); ?>"><?php echo $a->getFlavour(); ?></span> <?php $score = $t->getScore(); ?> <?php if ($score > 0): ?> <?php if ($score === 1): ?> <span id="link-score-<?php echo $t->getId(); ?>"><?php echo $t->getScore(); ?></span> point <?php else: ?> <span id="link-score-<?php echo $t->getId(); ?>"><?php echo $t->getScore(); ?></span> points <?php endif; ?> <?php endif; ?> posted <?php echo time_ago_in_words(strtotime($a->getCreatedAt())) ?> ago by <span class="link_author"><?php echo link_to($a->getUsername(), "@show_profile?username=" . $a->getUsername()); ?></span> <?php $comment_count = $a->getTotalComments(); ?> <?php if ($comment_count == 1): ?> <a class="ctrl" href="<?php echo url_for($a->getViewUrl()); ?>">1 comment</a> <?php else: ?> <a class="ctrl" href="<?php echo url_for($a->getViewUrl()); ?>"><?php echo $comment_count; ?> comments</a> <?php endif; ?> <?php if ($sf_user->isAuthenticated() && $sf_user->isAdmin()): ?> <?php echo link_to('delete', 'article/delete?articleid=' . $a->getId(), array('class' => 'ctrl admin', 'confirm' => 'Are you sure you want to delet this?')); ?> <?php endif; ?> </p> <?php if ($a->getFlavour() == 'snapshot'): ?> <?php $snapshot = $a->getSnapshot(true); ?> <a title="<?php echo $a->getTitle(); ?>" rel="lightbox" target="_blank" href="<?php echo $snapshot->getUrl(); ?>"><img class="snapshot" src="<?php echo $snapshot->getThumbnailUrl(200); ?>" /></a> <p class="link_summary"><?php echo truncate_text($a->getSummary(), 200); ?></p> <div class="clear"></div> <?php endif; ?> <?php if ($a->getFlavour() == 'link'): ?> <p class="link_summary"><?php echo truncate_text($a->getSummary(), 200); ?></p> <?php if ($a->getHasThumbnails()): ?> <?php $ftas = $a->getFiles(true); ?> <?php if (count($ftas) > 0): ?> <div class="preview"> <?php foreach ($ftas as $fta): ?> <img class="preview-image" src="<?php echo $fta->getFile()->getThumbnailUrl(); ?>" /> <?php endforeach; ?> </div> <?php endif; ?> <?php endif; ?> <?php endif; ?> <?php if ($a->getFlavour() == 'code'): ?> <pre style="display: none;" class="brush: <?php echo $a->getBrushAlias(); ?>"><?php echo htmlspecialchars($a->getCode()); ?></pre> <?php endif; ?> <?php if ($a->getFlavour() == 'question'): ?> <div class="question-body"><?php echo $a->getQuestionHtml(); ?></div> <?php endif; ?> </div> <div style="clear:both;"></div> </div>
sanjeevan/codelovely
apps/frontend/modules/article/templates/_article.php
PHP
mit
5,279
import { Physics as EightBittrPhysics } from "eightbittr"; import { FullScreenPokemon } from "../FullScreenPokemon"; import { Direction } from "./Constants"; import { Character, Grass, Actor } from "./Actors"; /** * Physics functions to move Actors around. */ export class Physics<Game extends FullScreenPokemon> extends EightBittrPhysics<Game> { /** * Determines the bordering direction from one Actor to another. * * @param actor The source Actor. * @param other The destination Actor. * @returns The direction from actor to other. */ public getDirectionBordering(actor: Actor, other: Actor): Direction | undefined { if (Math.abs(actor.top - (other.bottom - other.tolBottom)) < 4) { return Direction.Top; } if (Math.abs(actor.right - other.left) < 4) { return Direction.Right; } if (Math.abs(actor.bottom - other.top) < 4) { return Direction.Bottom; } if (Math.abs(actor.left - other.right) < 4) { return Direction.Left; } return undefined; } /** * Determines the direction from one Actor to another. * * @param actor The source Actor. * @param other The destination Actor. * @returns The direction from actor to other. * @remarks Like getDirectionBordering, but for cases where the two Actors * aren't necessarily touching. */ public getDirectionBetween(actor: Actor, other: Actor): Direction { const dx: number = this.getMidX(other) - this.getMidX(actor); const dy: number = this.getMidY(other) - this.getMidY(actor); if (Math.abs(dx) > Math.abs(dy)) { return dx > 0 ? Direction.Right : Direction.Left; } return dy > 0 ? Direction.Bottom : Direction.Top; } /** * Checks whether one Actor is overlapping another. * * @param actor An in-game Actor. * @param other An in-game Actor. * @returns Whether actor and other are overlapping. */ public isActorWithinOther(actor: Actor, other: Actor): boolean { return ( actor.top >= other.top && actor.right <= other.right && actor.bottom <= other.bottom && actor.left >= other.left ); } /** * Determines whether a Character is visually within grass. * * @param actor An in-game Character. * @param other Grass that actor might be in. * @returns Whether actor is visually within other. */ public isActorWActorrass(actor: Character, other: Grass): boolean { if (actor.right <= other.left) { return false; } if (actor.left >= other.right) { return false; } if (other.top > actor.top + actor.height / 2) { return false; } if (other.bottom < actor.top + actor.height / 2) { return false; } return true; } /** * Shifts a Character according to its xvel and yvel. * * @param actor A Character to shift. */ public shiftCharacter(actor: Character): void { if (actor.bordering[Direction.Top] && actor.yvel < 0) { actor.yvel = 0; } if (actor.bordering[Direction.Right] && actor.xvel > 0) { actor.xvel = 0; } if (actor.bordering[Direction.Bottom] && actor.yvel > 0) { actor.yvel = 0; } if (actor.bordering[Direction.Left] && actor.xvel < 0) { actor.xvel = 0; } this.shiftBoth(actor, actor.xvel, actor.yvel); } /** * Snaps a moving Actor to a predictable grid position. * * @param actor An Actor to snap the position of. */ public snapToGrid(actor: Actor): void { const grid = 32; const x: number = (this.game.mapScreener.left + actor.left) / grid; const y: number = (this.game.mapScreener.top + actor.top) / grid; this.setLeft(actor, Math.round(x) * grid - this.game.mapScreener.left); this.setTop(actor, Math.round(y) * grid - this.game.mapScreener.top); } }
FullScreenShenanigans/FullScreenPokemon
src/sections/Physics.ts
TypeScript
mit
4,204
import {Model} from '../../models/base/Model'; import {Subject} from 'rxjs/Subject'; import {BaseService} from '../BaseService'; import {ActivatedRoute, Router} from '@angular/router'; import {UserRights, UserService} from '../../services/UserService'; import {ListTableColumn} from './ListTableColumn'; import {BehaviorSubject} from 'rxjs/BehaviorSubject'; import {SortDirection} from '../SortDirection'; import {ListTableColumnActionType, ListTableColumnType} from './ListEnums'; export class ListProvider<T extends Model> { public currentPage = 1; public itemsPerPage = 10; public totalItems = 0; public dataLoaded = false; public items: Subject<T[]>; public cardTitle = ''; public cardIcon = ''; public columns: ListTableColumn<T>[]; public sortDirection = SortDirection; public columnTypes = ListTableColumnType; public actionTypes = ListTableColumnActionType; protected title = 'Список'; private sort = '-id'; public getRowClass: (model: T) => { [key: string]: boolean }; private static getSortKey(column: string, desc: boolean = false): string { let sortKey = column; if (desc) { sortKey = '-' + sortKey; } return sortKey; } constructor(private service: BaseService<T>, private router: Router, private route: ActivatedRoute, private _userService: UserService) { } public init() { this.items = new BehaviorSubject<T[]>([]); this.route.queryParamMap.subscribe(params => { const pageNumber = parseInt(params.get('page'), 10); if (pageNumber >= 1) { this.currentPage = pageNumber; } const sort = params.get('sort'); if (sort != null) { this.sort = sort; const key = this.sort.replace('-', ''); const sortDirection = this.sort.indexOf('-') > -1 ? SortDirection.Desc : SortDirection.Asc; this.columns.forEach(col => { col.setSorted(col.Key === key ? sortDirection : null); }); } this.load(this.currentPage); }); } public applySort(column: string) { let sortKey; if (this.sort === column) { sortKey = ListProvider.getSortKey(column, true); } else { sortKey = ListProvider.getSortKey(column); } this.sort = sortKey; this.reload(); } public changePage(page: number) { this.currentPage = page; this.reload(); } public load(page?: number) { page = page ? page : this.currentPage; this.service.getList(page, this.itemsPerPage, this.sort).subscribe((res) => { this.items.next(res.data); this.totalItems = res.totalItems; this.currentPage = page; this.dataLoaded = true; }); } private reload() { this.router.navigate([], {queryParams: {page: this.currentPage, sort: this.sort}, relativeTo: this.route}); } public can(right: UserRights): boolean { return this._userService.hasRight(right); } }
BioWareRu/Admin
src/core/lists/ListProvider.ts
TypeScript
mit
2,898
# Given the list values = [] , write code that fills the list with each set of numbers below. # a.1 2 3 4 5 6 7 8 9 10 list = [] for i in range(11): list.append(i) print(list)
futurepr0n/Books-solutions
Python-For-Everyone-Horstmann/Chapter6-Lists/R6.1A.py
Python
mit
203
using System; using System.IO; using System.ServiceProcess; using InEngine.Core; //using Mono.Unix; //using Mono.Unix.Native; namespace InEngine { class Program { public const string ServiceName = "InEngine.NET"; public static ServerHost ServerHost { get; set; } static void Main(string[] args) { /* * Set current working directory as services use the system directory by default. * Also, maybe run from the CLI from a different directory than the application root. */ Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); new ArgumentInterpreter().Interpret(args); } /// <summary> /// Start the server as a service or as a CLI program in the foreground. /// </summary> public static void RunServer() { var settings = InEngineSettings.Make(); ServerHost = new ServerHost() { MailSettings = settings.Mail, QueueSettings = settings.Queue, }; if (!Environment.UserInteractive && Type.GetType("Mono.Runtime") == null) { using (var service = new Service()) ServiceBase.Run(service); } else { ServerHost.Start(); Console.WriteLine("Press any key to exit..."); Console.ReadLine(); ServerHost.Dispose(); } } static void Start(string[] args) { ServerHost.Start(); } static void Stop() { ServerHost.Dispose(); } public class Service : ServiceBase { public Service() { ServiceName = Program.ServiceName; } protected override void OnStart(string[] args) { Start(args); } protected override void OnStop() { Stop(); } } } }
InEngine-NET/InEngine.NET
src/InEngine/Program.cs
C#
mit
2,105
// JavaScript Document $(document).ready(function() { $('form input[type="file"]').change(function() { var filename = $(this).val(); $(this).prev('i').text(filename); }); $('.input-file').click(function() { $(this).find('input').click(); }); /* * Previene doble click en boton submit de envio de datos de formulario y evitar doble envio */ $('form').on('submit', function() { var submit = $(this).find('input[type="submit"]'); submit.attr('disabled','yes').css('cursor', 'not-allowed'); }); $('form').on('reset', function() { $('form .input-file i').text('Selecciona un archivo'); }); /* * Toggle en menu principal lateral */ $('ul#navi li').click(function() { $(this).next('ul').slideToggle('fast'); //$(this).toggleClass('active'); }); /* * Coloca un simbolo para identificar los item con subitems en el menu navegacion izquierda */ $('ul.subnavi').each(function() { var ori_text = $(this).prev('li').find('a').text(); $(this).prev('li').find('a').html(ori_text+'<span class="fa ellipsis">&#xf107;</span>'); }); /* * Despliega cuadro de informacion de usuario */ $('li.user_photo, li.user_letter').click(function(e) { $(this).next('div.user_area').fadeToggle(50); e.stopPropagation(); }); $('body').click(function() { $('li.user_photo, li.user_letter').next('div.user_area').hide(); }); $('div.user_area').click(function(e) { e.stopPropagation(); }); /* * Mostrar/Ocultar mapa */ $('#toggle_map').click(function() { $('ul.map_icon_options').fadeToggle('fast'); $('img#mapa').fadeToggle('fast'); $(this).toggleClass('active'); }); /* * Confirmación de cerrar sesión */ /*$('#cerrar_sesion').click(function() { return confirm(String.fromCharCode(191)+'Esta seguro que desea salir de la sesi'+String.fromCharCode(243)+'n?'); });*/ /* * Confirmación de eliminar datos */ $('a.eliminar').click(function() { return confirm(String.fromCharCode(191)+'Esta seguro que desea eliminar este registro?'); }); /* * Confirmación de quitar asignacion a responsable de un area */ $('a.quitar_asignacion').click(function() { return confirm('Se quitara la asignacion al usuario. '+String.fromCharCode(191)+'Desea continuar?'); }); /* * Ajusta tamaño a imagenes de mapas que son mas altas que anchas */ $('.map_wrapper img#mapa').each(function() { var h = $(this).height(); var w = $(this).width(); if(h > w) { $(this).css('width', '50%').addClass('halign'); } }) /* * Envia a impresion */ $('#print').click(function() { window.print(); }); /* * Inhabilita el click derecho */ $(function(){ $(document).bind("contextmenu",function(e){ return false; }); }); /* * Toma atruto ALT de campo de formulario y lo usa como descripcion debajo del campo */ $('form.undertitled').find('input:text, input:password, input:file, select, textarea').each(function() { $(this).after('<span>'+$(this).attr('title')+'</span>'); }); /* * Hack para centrar horizontalmente mensajes de notificación */ $('p.notify').each(function() { var w = $(this).width(); $(this).css('left', -(w/2)+'px'); }).delay(5000).fadeOut('medium'); //-- /* * Focus en elementos de tabla */ $("table tbody tr").click(function() { $(this).addClass('current').siblings("tr").removeClass('current'); }); /* * Hace scroll al tope de la página * * $('.boton_accion').toTop(); */ $.fn.toTop = function() { $(this).click(function() { $('html, body').animate({scrollTop:0}, 'medium'); }) } //-- /* * Ventana modal * @param text box * Qparam text overlay * * $('.boton_que_acciona_ventana').lightbox('.objeto_a_mostrar', 'w|d : opcional') * w : Muestra una ventana al centro de la pantalla en fondo blanco * d : Muestra una ventana al top de la pantalla sobre fondo negro, si no define * el segundo parametro se mostrara por default este modo. */ $.fn.lightbox = function(box, overlay='d') { $(this).click(function() { var ol = (overlay=='w') ? 'div.overlay_white' : 'div.overlay'; $(ol).fadeIn(250).click(function() { $(box).slideUp(220); $(this).delay(221).fadeOut(250); }).attr('title','Click para cerrar'); $(box).delay(251).slideDown(220); }); if(overlay=='d') { $(box).each(function() { $(this).html($(this).html()+'<p style="border-top:1px #CCC solid; color:#888; margin-bottom:0; padding-top:10px">Para cerrar esta ventana haga click sobre el &aacute;rea sombreada.</p>'); }); } }; //-- })
rguezque/enlaces
web/res/js/jquery-functions.js
JavaScript
mit
4,483
# 插件 Vuex 的 store 接受 `plugins` 选项,这个选项暴露出每次 mutation 的钩子。Vuex 插件就是一个函数,它接收 store 作为唯一参数: ``` js const myPlugin = store => { // 当 store 初始化后调用 store.subscribe((mutation, state) => { // 每次 mutation 之后调用 // mutation 的格式为 { type, payload } }) } ``` 然后像这样使用: ``` js const store = new Vuex.Store({ // ... plugins: [myPlugin] }) ``` ### 在插件内提交 Mutation 在插件中不允许直接修改状态——类似于组件,只能通过提交 mutation 来触发变化。 通过提交 mutation,插件可以用来同步数据源到 store。例如,同步 websocket 数据源到 store(下面是个大概例子,实际上 `createPlugin` 方法可以有更多选项来完成复杂任务): ``` js export default function createWebSocketPlugin (socket) { return store => { socket.on('data', data => { store.commit('receiveData', data) }) store.subscribe(mutation => { if (mutation.type === 'UPDATE_DATA') { socket.emit('update', mutation.payload) } }) } } ``` ``` js const plugin = createWebSocketPlugin(socket) const store = new Vuex.Store({ state, mutations, plugins: [plugin] }) ``` ### 生成 State 快照 有时候插件需要获得状态的“快照”,比较改变的前后状态。想要实现这项功能,你需要对状态对象进行深拷贝: ``` js const myPluginWithSnapshot = store => { let prevState = _.cloneDeep(store.state) store.subscribe((mutation, state) => { let nextState = _.cloneDeep(state) // 比较 prevState 和 nextState... // 保存状态,用于下一次 mutation prevState = nextState }) } ``` **生成状态快照的插件应该只在开发阶段使用**,使用 webpack 或 Browserify,让构建工具帮我们处理: ``` js const store = new Vuex.Store({ // ... plugins: process.env.NODE_ENV !== 'production' ? [myPluginWithSnapshot] : [] }) ``` 上面插件会默认启用。在发布阶段,你需要使用 webpack 的 [DefinePlugin](https://webpack.github.io/docs/list-of-plugins.html#defineplugin) 或者是 Browserify 的 [envify](https://github.com/hughsk/envify) 使 `process.env.NODE_ENV !== 'production'` 为 `false`。 ### 内置 Logger 插件 > 如果正在使用 [vue-devtools](https://github.com/vuejs/vue-devtools),你可能不需要此插件。 Vuex 自带一个日志插件用于一般的调试: ``` js import createLogger from 'vuex/dist/logger' const store = new Vuex.Store({ plugins: [createLogger()] }) ``` `createLogger` 函数有几个配置项: ``` js const logger = createLogger({ collapsed: false, // 自动展开记录的 mutation filter (mutation, stateBefore, stateAfter) {    // 若 mutation 需要被记录,就让它返回 true 即可    // 顺便,`mutation` 是个 { type, payload } 对象    return mutation.type !== "aBlacklistedMutation" }, transformer (state) { // 在开始记录之前转换状态 // 例如,只返回指定的子树 return state.subTree }, mutationTransformer (mutation) { // mutation 按照 { type, payload } 格式记录 // 我们可以按任意方式格式化 return mutation.type }, logger: console, // 自定义 console 实现,默认为 `console` }) ``` 日志插件还可以直接通过 `<script>` 标签引入,它会提供全局方法 `createVuexLogger`。 要注意,logger 插件会生成状态快照,所以仅在开发环境使用。
LIZIMEME/vuex-shopping-cart-plus
docs/zh-cn/plugins.md
Markdown
mit
3,574
<?php namespace App\Jobs; use App\Jobs\Job; use App\Models\API\Outpost; use DB; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Log; use Pheal\Pheal; class UpdateOutpostsJob extends Job implements ShouldQueue { use InteractsWithQueue, SerializesModels; /** * @var \App\Models\API\Outpost; */ private $outpost; /** * @var \Pheal\Pheal */ private $pheal; /** * Create a new job instance. * @param \App\Models\API\Outpost $outpost * @param \Pheal\Pheal $pheal * @return void */ public function __construct(Outpost $outpost, Pheal $pheal) { $this->outpost = $outpost; $this->pheal = $pheal; } /** * Execute the job. * @return void */ public function handle() { try { Log::info('Updating outposts.'); DB::transaction(function () { $stations = $this->pheal->eveScope->ConquerableStationList(); foreach ($stations->outposts as $station) { $this->outpost->updateOrCreate([ 'stationID' => $station->stationID, ], [ 'stationName' => $station->stationName, 'stationTypeID' => $station->stationTypeID, 'solarSystemID' => $station->solarSystemID, 'corporationID' => $station->corporationID, 'corporationName' => $station->corporationName, 'x' => $station->x, 'y' => $station->y, 'z' => $station->z, ]); } }); // transaction } catch (Exception $e) { Log::error('Failed updating outposts. Throwing exception:'); throw $e; } } }
msims04/eve-buyback
app/Jobs/UpdateOutpostsJob.php
PHP
mit
1,614
using System; using System.Net; using Jasper.Configuration; using Jasper.Runtime; using Jasper.Transports; using Jasper.Transports.Sending; using Jasper.Util; namespace Jasper.Tcp { public class TcpEndpoint : Endpoint { public TcpEndpoint() : this("localhost", 2000) { } public TcpEndpoint(int port) : this ("localhost", port) { } public TcpEndpoint(string hostName, int port) { HostName = hostName; Port = port; Name = Uri.ToString(); } protected override bool supportsMode(EndpointMode mode) { return mode != EndpointMode.Inline; } public override Uri Uri => ToUri(Port, HostName); public static Uri ToUri(int port, string hostName = "localhost") { return $"tcp://{hostName}:{port}".ToUri(); } public override Uri ReplyUri() { var uri = ToUri(Port, HostName); if (Mode != EndpointMode.Durable) { return uri; } return $"{uri}durable".ToUri(); } public string HostName { get; set; } = "localhost"; public int Port { get; private set; } public override void Parse(Uri uri) { if (uri.Scheme != "tcp") { throw new ArgumentOutOfRangeException(nameof(uri)); } HostName = uri.Host; Port = uri.Port; if (uri.IsDurable()) { Mode = EndpointMode.Durable; } } public override void StartListening(IMessagingRoot root, ITransportRuntime runtime) { if (!IsListener) return; var listener = createListener(root); runtime.AddListener(listener, this); } protected override ISender CreateSender(IMessagingRoot root) { return new BatchedSender(Uri, new SocketSenderProtocol(), root.Settings.Cancellation, root.TransportLogger); } private IListener createListener(IMessagingRoot root) { // check the uri for an ip address to bind to var cancellation = root.Settings.Cancellation; var hostNameType = Uri.CheckHostName(HostName); if (hostNameType != UriHostNameType.IPv4 && hostNameType != UriHostNameType.IPv6) return HostName == "localhost" ? new SocketListener(root.TransportLogger,IPAddress.Loopback, Port, cancellation) : new SocketListener(root.TransportLogger,IPAddress.Any, Port, cancellation); var ipaddr = IPAddress.Parse(HostName); return new SocketListener(root.TransportLogger, ipaddr, Port, cancellation); } } }
JasperFx/jasper
src/Jasper.Tcp/TcpEndpoint.cs
C#
mit
2,840
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>TITLE</title> <style type="text/css" media="screen"> body { font-family: sans-serif; } </style> </head> <body> <p>HELLO</p> <script type="text/javascript"> </script> </body> </html>
felixhummel/skeletons
html-inline/index.html
HTML
mit
298
// // KontaktSDK // Version: 3.0.4 // // Copyright (c) 2015 Kontakt.io. All rights reserved. // @import Foundation; #import "KTKNearbyDevice.h" NS_ASSUME_NONNULL_BEGIN @protocol KTKDevicesManagerDelegate; #pragma mark - External Constants extern NSTimeInterval const KTKDeviceInvalidationAgeNever; #pragma mark - Type Definition /** * Nearby devices discovery mode. */ typedef NS_ENUM(NSUInteger, KTKDevicesManagerDiscoveryMode) { /** * Discovery mode Auto deliveres devices notifications as the devices becoming valid or invalid. * There is no limit to these notifications so please make sure when working with hundreds of * nearby devices this may impact performance. It is better to use discovery with interval then. */ KTKDevicesManagerDiscoveryModeAuto = 0, /** * Discovery mode Interval deliveres devices notifications with the specified time inverval. * When working with hundreds of nearby devices this is preferred mode. * When just few nearby devices have been discovered in a close time span it is better to use mode auto, as it is responding faster to changes. */ KTKDevicesManagerDiscoveryModeInterval }; #pragma mark - KTKDevicesManager (Interface) @interface KTKDevicesManager : NSObject #pragma mark - Other Properties ///-------------------------------------------------------------------- /// @name Other Properties ///-------------------------------------------------------------------- /** * The current state of the bluetooth central. */ @property (nonatomic, assign, readonly) CBManagerState centralState; /** * A Boolean indicating whether the devices manager is currently discovering. */ @property (nonatomic, assign, readonly, getter=isDiscovering) BOOL discovering; /** * A Boolean indicating whether the devices manager should detect devices locked status. */ @property (nonatomic, assign, readwrite, getter=isDetectingLocks) BOOL detectingLocks; /** * The delegate object that will receive events. */ @property (nonatomic, weak, readonly) id<KTKDevicesManagerDelegate> _Nullable delegate; #pragma mark - Initialization Methods ///-------------------------------------------------------------------- /// @name Initialization Methods ///-------------------------------------------------------------------- /** * Initializes and returns an devices manager object with the specified delegate. * * @param delegate The delegate object that will receive events. * * @return An initialized devices manager object. * * @see KTKDevicesManagerDelegate */ - (instancetype)initWithDelegate:(id<KTKDevicesManagerDelegate> _Nullable)delegate; #pragma mark - Configuration Properties ///-------------------------------------------------------------------- /// @name Configuration Properties ///-------------------------------------------------------------------- /** * A time interval after which nearby device will be invalidated if not re-discovered. * * Each time nearby device advertising is discovered its <code>updateAt</code> property is updated. * If <code>updateAt</code> property is updated for longer than <code>invalidationAge</code> value * a nearby device will be invalidated/removed from current devices list. * * Default value is 10.0 seconds. */ @property (nonatomic, assign, readwrite) NSTimeInterval invalidationAge; /** * A mode in which nearby devices discovery is done. * * If <code>discoveryInterval</code> property is set or discovery is started with <code>startDevicesDiscoveryWithInterval:</code> method, * <code>discoveryMode</code> is automatically set to <code>KTKDevicesManagerDiscoveryModeInterval</code>. * * When discovery is started with <code>startDevicesDiscovery</code> mode will be set to <code>KTKDevicesManagerDiscoveryModeAuto</code>. * * @see KTKDevicesManagerDiscoveryMode */ @property (nonatomic, assign, readwrite) KTKDevicesManagerDiscoveryMode discoveryMode; /** * A time interval after which discovered notifications will be delivered. */ @property (nonatomic, assign, readwrite) NSTimeInterval discoveryInterval; #pragma mark - Discovery Methods ///-------------------------------------------------------------------- /// @name Discovery Methods ///-------------------------------------------------------------------- /** * Starts discovery of Kontakt.io's nearby devices. */ - (void)startDevicesDiscovery; /** * Starts discovery of Kontakt.io's nearby devices with specified time interval. * * @param interval A time interval after which discovered notifications will be delivered. */ - (void)startDevicesDiscoveryWithInterval:(NSTimeInterval)interval; /** * Stops discovery of Kontakt.io's nearby devices. */ - (void)stopDevicesDiscovery; /** * Restarts discovery of Kontakt.io's nearby devices. * * @param completion A block object to be executed when manager restarts the discovery. */ - (void)restartDeviceDiscoveryWithCompletion:(void(^)( NSError * _Nullable))completion; @end #pragma mark - KTKDevicesManagerDelegate @protocol KTKDevicesManagerDelegate <NSObject> #pragma mark - Required Methods ///-------------------------------------------------------------------- /// @name Required Methods ///-------------------------------------------------------------------- /** * Tells the delegate that one or more devices were discovered. * * @param manager The devices manager object reporting the event. * @param devices An list of discovered nearby devices. */ @required - (void)devicesManager:(KTKDevicesManager*)manager didDiscoverDevices:(NSArray <KTKNearbyDevice*>*)devices; #pragma mark - Optional Methods ///-------------------------------------------------------------------- /// @name Optional Methods ///-------------------------------------------------------------------- /** * Tells the delegate that a devices discovery error occurred. * * @param manager The devices manager object reporting the event. * @param error An error object containing the error code that indicates why discovery failed. */ @optional - (void)devicesManagerDidFailToStartDiscovery:(KTKDevicesManager*)manager withError:(NSError*)error; @end NS_ASSUME_NONNULL_END
Artirigo/react-native-kontaktio
ios/KontaktSDK.framework/Headers/KTKDevicesManager.h
C
mit
6,213
<div class="ui right aligned grid"> <div class="right aligned column"> <span *ngIf="currentState == 'save as' && endPointForm.valid"> <a mat-mini-fab routerLink="." color='primary' (click)="createEndPoint()"><mat-icon>content_copy</mat-icon></a> &nbsp;save as&nbsp; </span> <span *ngIf="currentState == 'update' && endPointForm.valid"> <a mat-mini-fab routerLink="." color='primary' (click)="updateEndPoint()"><mat-icon>save</mat-icon></a> &nbsp;update&nbsp; </span> <span *ngIf="currentState == 'create' && endPointForm.valid"> <a mat-mini-fab routerLink="." color='primary' (click)="createEndPoint()"><mat-icon>save</mat-icon></a> &nbsp;save&nbsp; </span> <span *ngIf="endPointForm.dirty && currentState != 'create'"> <a mat-mini-fab routerLink="." color='primary' (click)="resetEndPoint()"><mat-icon>undo</mat-icon></a> &nbsp;undo&nbsp; </span> <span> <a mat-mini-fab routerLink="." color='primary' (click)="newEndPoint()"><mat-icon>add</mat-icon></a> &nbsp;create&nbsp; </span> <span *ngIf="currentEndPoint.name !='' && currentState != 'create' && preDefined == false"> <a mat-mini-fab routerLink="." (click)="deleteEndPoint()"> <mat-icon>clear</mat-icon></a> &nbsp;remove&nbsp; </span> </div> </div> <br> <form [formGroup]="endPointForm" novalidate class="ui form"> <div class="field"> <div class="ui left icon input"> <input formControlName="name" type="text" placeholder="Name"> <i class="tag icon"></i> </div> </div> <div class="field"> <div class="ui left icon input"> <input formControlName="address" type="text" placeholder="URL"> <i class="marker icon"></i> </div> </div> <div class="field"> <div class="ui"> <textarea rows="2" class="form-control" formControlName="description" placeholder="Description"></textarea> </div> </div> <mat-form-field class="example-chip-list"> <mat-chip-list #chipList> <mat-chip *ngFor="let tag of formTags.tags" [selectable]="selectable" [removable]="removable" (removed)="removeTag(tag)"> {{tag.name}} <mat-icon matChipRemove *ngIf="removable">cancel</mat-icon> </mat-chip> <input [disabled]="preDefined" type="" placeholder={{tagPlaceHolderText}} [matChipInputFor]="chipList" [matChipInputSeparatorKeyCodes]="separatorKeysCodes" [matChipInputAddOnBlur]="addOnBlur" (matChipInputTokenEnd)="addTag($event)"> </mat-chip-list> </mat-form-field> <div *ngIf="useCredentials"> <div class="field"> <label> <select class="ui transparent" formControlName="credentialType"> <option *ngFor="let credentialType of credentialScheme" [value]="credentialType"> {{credentialType}} </option> </select> </label> </div> <div class="field"> <div class="ui left icon input"> <input formControlName="user" type="text" placeholder="User"> <i class="user icon"></i> </div> </div> <div class="field"> <div class="ui left icon input"> <input formControlName="credential" type="password" placeholder="Credential"> <i class="key icon"></i> </div> </div> <div class="field"> <div class="ui left icon input"> <input formControlName="tokenAPI" type="string" placeholder="Token API"> <i class="key icon"></i> </div> </div> <div class="field"> <div class="ui left icon input"> <input formControlName="tokenAPIProperty" type="string" placeholder="Token API Property"> <i class="key icon"></i> </div> </div> </div> </form>
catalogicsoftware/Angular-4-Plus-Dashboard-Framework
src/app/configuration/tab-endpoint/endpointDetail.html
HTML
mit
4,391
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Palestrantes_model extends CI_Model { private $id; private $nome; private $foto; public function __construct() { parent::__construct(); } public function setId($id) { $this->id = $id; } public function getId() { return $this->id; } public function setNome($nome) { $this->nome = $nome; } public function getNome() { return $this->nome; } public function setFoto($foto) { $this->foto = $foto; } public function getFoto() { return $this->foto; } private function salvar() { $id = $this->input->post('id'); $nome = $this->input->post('nome'); $foto = $this->input->post('foto'); $this->setId($id); $this->setNome($nome); $this->setFoto($foto); $this->db->set('nome',$this->getNome()); $this->db->set('foto',$this->getFoto()); if ( empty( $this->id ) ) { $query = $this->db->insert('palestrantes'); if ( $query == TRUE ) { $this->setId($this->db->insert_id()); return TRUE; } else { return FALSE; } } else { $this->db->where('id',$this->getId()); $query = $this->db->update('palestrantes'); return $query; } } private function salvar_detalhes() { $palestrantes_id = $this->getId(); $idioma = $this->input->post('idioma'); $pequena_descricao = $this->input->post('pequena_descricao'); $descricao = $this->input->post('descricao'); if (empty($idioma)) $idioma = 'pt'; $this->db->where('palestrantes_id',$palestrantes_id); $this->db->where('idioma',$idioma); $query = $this->db->get('palestrantes_detalhes'); $this->db->set('pequena_descricao',$pequena_descricao); $this->db->set('descricao',$descricao); $this->db->set('idioma',$idioma); $this->db->set('palestrantes_id',$palestrantes_id); if ( $query->num_rows() > 0 ) { $query = $query->row_array(); $this->db->where('id',$query['id']); $rowset = $this->db->update('palestrantes_detalhes'); } else { $this->db->insert('palestrantes_detalhes'); } } public function salvar_palestrante() { $this->db->trans_begin(); $this->salvar(); $this->salvar_detalhes(); if ( $this->db->trans_status() === FALSE ) { $this->db->trans_rollback(); return array('status'=>'fail','msg'=>'Não foi possível salvar, tente novamente mais tarde', 'id' => ''); } else { $this->db->trans_commit(); return array('status'=>'ok','msg'=>'Salvo com sucesso', 'id' => $this->getId()); } } public function grid_palestrantes() { $this->db->select(' palestrantes.id, palestrantes.nome, palestrantes.foto '); $query = $this->db->get('palestrantes')->result_array(); $dados = array(); foreach ($query as $key => $value) { $dados[$key]['id'] = $value['id']; $dados[$key]['nome'] = $value['nome']; $dados[$key]['foto'] = base_url('files/get/'.$value['foto']); } $retorno['status'] = 'ok'; $retorno['msg'] = sizeof($dados) . " registros encontrados"; $retorno['dados'] = $dados; return $retorno; } public function get_palestrante($id) { $this->db->where('palestrantes.id',$id); $this->db->select(' palestrantes.id, palestrantes.nome, palestrantes.foto, palestrantes_detalhes.idioma, palestrantes_detalhes.descricao, palestrantes_detalhes.pequena_descricao '); $this->db->join('palestrantes_detalhes','palestrantes_detalhes.palestrantes_id = palestrantes.id AND palestrantes_detalhes.idioma = "pt"','LEFT'); $query = $this->db->get('palestrantes')->row_array(); return $query; } public function trocar_idioma_palestrante() { $palestrantes_id = $this->input->post('id'); $idioma = $this->input->post('idioma'); if (empty($idioma)) $idioma = 'pt'; $descricao = ''; $pequena_descricao = ''; if (!empty($palestrantes_id)) { $this->db->where('palestrantes_id',$palestrantes_id); $this->db->where('idioma',$idioma); $row = $this->db->get('palestrantes_detalhes'); if ($row->num_rows() > 0) { $row = $row->row_array(); $descricao = $row['descricao']; $pequena_descricao = $row['pequena_descricao']; } } $retorno['status'] = 'ok'; $retorno['msg'] = ''; $retorno['dados']['id'] = $palestrantes_id; $retorno['dados']['idioma'] = $idioma; $retorno['dados']['descricao'] = $descricao; $retorno['dados']['pequena_descricao'] = $pequena_descricao; return $retorno; } public function get_all_palestrantes($idioma) { // $idioma = $this->input->post('idioma'); if (empty($idioma)) $idioma = 'pt'; $this->db->select(' palestrantes.id, palestrantes.nome, palestrantes.foto, palestrantes_detalhes.pequena_descricao, palestrantes_detalhes.descricao, palestrantes_detalhes.idioma '); $this->db->join('palestrantes_detalhes','palestrantes_detalhes.palestrantes_id = palestrantes.id AND palestrantes_detalhes.idioma = "'.$idioma.'"','LEFT'); $dados = $this->db->get('palestrantes')->result_array(); foreach ($dados as $key => $value) { $dados[$key]['foto'] = base_url('files/get/'.$value['foto']); } $retorno['status'] = 'ok'; $retorno['msg'] = sizeof($dados) . " registros encontrados"; $retorno['dados'] = $dados; return $retorno; } } /* End of file Palestrantes_model.php */ /* Location: ./application/models/Palestrantes_model.php */
tucanowned/congressouniapac
application/models/Palestrantes_model.php
PHP
mit
5,283
Thanks for reading. You can put me down now.
robhumphries/Shopify-Theme
README.md
Markdown
mit
45
<?php namespace Acast; /** * 中间件 * @package Acast */ abstract class Middleware { /** * 存储中间件回调函数 * @var array */ protected static $_middleware = []; /** * 注册中间件 * * @param string $name * @param callable $callback */ static function register(string $name, callable $callback) { if (isset(self::$_middleware[$name])) Console::warning("Overwriting middleware callback \"$name\"."); self::$_middleware[$name] = $callback; } /** * 获取中间件 * * @param string $name * @return callable|null */ static function fetch(string $name) : ?callable { if (!isset(self::$_middleware[$name])) { Console::warning("Failed to fetch middleware \"$name\". Not exist."); return null; } return self::$_middleware[$name]; } }
CismonX/Acast
src/Middleware.php
PHP
mit
917
clean "/tmp" do copy "*.*", to: "/test" end
akatakritos/rcleaner
spec/fixtures/rfiles/copyfile.rb
Ruby
mit
46
using System; using System.CodeDom; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; namespace EmptyKeys.UserInterface.Generator.Types { /// <summary> /// Implements List Box control generator /// </summary> public class ListBoxGeneratorType : SelectorGeneratorType { /// <summary> /// Gets the type of the xaml. /// </summary> /// <value> /// The type of the xaml. /// </value> public override Type XamlType { get { return typeof(ListBox); } } /// <summary> /// Generates code /// </summary> /// <param name="source">The dependence object</param> /// <param name="classType">Type of the class.</param> /// <param name="initMethod">The initialize method.</param> /// <param name="generateField"></param> /// <returns></returns> public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) { CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); ListBox listBox = source as ListBox; CodeComHelper.GenerateEnumField<SelectionMode>(initMethod, fieldReference, source, ListBox.SelectionModeProperty); return fieldReference; } } }
EmptyKeys/UI_Generator
UIGenerator/Types/ListBoxGeneratorType.cs
C#
mit
1,638
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ /* * Copyright (c) 2008 litl, LLC * * 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. */ #include <config.h> #include <string.h> /* include first for logging related #define used in repo.h */ #include <util/log.h> #include "union.h" #include "arg.h" #include "object.h" #include <cjs/gjs-module.h> #include <cjs/compat.h> #include "repo.h" #include "proxyutils.h" #include "function.h" #include "gtype.h" #include <girepository.h> typedef struct { GIUnionInfo *info; void *gboxed; /* NULL if we are the prototype and not an instance */ GType gtype; } Union; extern struct JSClass gjs_union_class; GJS_DEFINE_PRIV_FROM_JS(Union, gjs_union_class) /* * Like JSResolveOp, but flags provide contextual information as follows: * * JSRESOLVE_QUALIFIED a qualified property id: obj.id or obj[id], not id * JSRESOLVE_ASSIGNING obj[id] is on the left-hand side of an assignment * JSRESOLVE_DETECTING 'if (o.p)...' or similar detection opcode sequence * JSRESOLVE_DECLARING var, const, or boxed prolog declaration opcode * JSRESOLVE_CLASSNAME class name used when constructing * * The *objp out parameter, on success, should be null to indicate that id * was not resolved; and non-null, referring to obj or one of its prototypes, * if id was resolved. */ static JSBool union_new_resolve(JSContext *context, JSObject **obj, jsid *id, unsigned flags, JSObject **objp) { Union *priv; char *name; JSBool ret = JS_TRUE; *objp = NULL; if (!gjs_get_string_id(context, *id, &name)) return JS_TRUE; /* not resolved, but no error */ priv = priv_from_js(context, *obj); gjs_debug_jsprop(GJS_DEBUG_GBOXED, "Resolve prop '%s' hook obj %p priv %p", name, (void *)obj, priv); if (priv == NULL) { ret = JS_FALSE; /* wrong class */ goto out; } if (priv->gboxed == NULL) { /* We are the prototype, so look for methods and other class properties */ GIFunctionInfo *method_info; method_info = g_union_info_find_method((GIUnionInfo*) priv->info, name); if (method_info != NULL) { JSObject *union_proto; const char *method_name; #if GJS_VERBOSE_ENABLE_GI_USAGE _gjs_log_info_usage((GIBaseInfo*) method_info); #endif method_name = g_base_info_get_name( (GIBaseInfo*) method_info); gjs_debug(GJS_DEBUG_GBOXED, "Defining method %s in prototype for %s.%s", method_name, g_base_info_get_namespace( (GIBaseInfo*) priv->info), g_base_info_get_name( (GIBaseInfo*) priv->info)); union_proto = *obj; if (gjs_define_function(context, union_proto, g_registered_type_info_get_g_type(priv->info), method_info) == NULL) { g_base_info_unref( (GIBaseInfo*) method_info); ret = JS_FALSE; goto out; } *objp = union_proto; /* we defined the prop in object_proto */ g_base_info_unref( (GIBaseInfo*) method_info); } } else { /* We are an instance, not a prototype, so look for * per-instance props that we want to define on the * JSObject. Generally we do not want to cache these in JS, we * want to always pull them from the C object, or JS would not * see any changes made from C. So we use the get/set prop * hooks, not this resolve hook. */ } out: g_free(name); return ret; } static void* union_new(JSContext *context, JSObject *obj, /* "this" for constructor */ GIUnionInfo *info) { int n_methods; int i; /* Find a zero-args constructor and call it */ n_methods = g_union_info_get_n_methods(info); for (i = 0; i < n_methods; ++i) { GIFunctionInfo *func_info; GIFunctionInfoFlags flags; func_info = g_union_info_get_method(info, i); flags = g_function_info_get_flags(func_info); if ((flags & GI_FUNCTION_IS_CONSTRUCTOR) != 0 && g_callable_info_get_n_args((GICallableInfo*) func_info) == 0) { jsval rval; rval = JSVAL_NULL; gjs_invoke_c_function_uncached(context, func_info, obj, 0, NULL, &rval); g_base_info_unref((GIBaseInfo*) func_info); /* We are somewhat wasteful here; invoke_c_function() above * creates a JSObject wrapper for the union that we immediately * discard. */ if (JSVAL_IS_NULL(rval)) return NULL; else return gjs_c_union_from_union(context, JSVAL_TO_OBJECT(rval)); } g_base_info_unref((GIBaseInfo*) func_info); } gjs_throw(context, "Unable to construct union type %s since it has no zero-args <constructor>, can only wrap an existing one", g_base_info_get_name((GIBaseInfo*) info)); return NULL; } GJS_NATIVE_CONSTRUCTOR_DECLARE(union) { GJS_NATIVE_CONSTRUCTOR_VARIABLES(union) Union *priv; Union *proto_priv; JSObject *proto; void *gboxed; GJS_NATIVE_CONSTRUCTOR_PRELUDE(union); priv = g_slice_new0(Union); GJS_INC_COUNTER(boxed); g_assert(priv_from_js(context, object) == NULL); JS_SetPrivate(object, priv); gjs_debug_lifecycle(GJS_DEBUG_GBOXED, "union constructor, obj %p priv %p", object, priv); JS_GetPrototype(context, object, &proto); gjs_debug_lifecycle(GJS_DEBUG_GBOXED, "union instance __proto__ is %p", proto); /* If we're the prototype, then post-construct we'll fill in priv->info. * If we are not the prototype, though, then we'll get ->info from the * prototype and then create a GObject if we don't have one already. */ proto_priv = priv_from_js(context, proto); if (proto_priv == NULL) { gjs_debug(GJS_DEBUG_GBOXED, "Bad prototype set on union? Must match JSClass of object. JS error should have been reported."); return JS_FALSE; } priv->info = proto_priv->info; g_base_info_ref( (GIBaseInfo*) priv->info); priv->gtype = proto_priv->gtype; /* union_new happens to be implemented by calling * gjs_invoke_c_function(), which returns a jsval. * The returned "gboxed" here is owned by that jsval, * not by us. */ gboxed = union_new(context, object, priv->info); if (gboxed == NULL) { return JS_FALSE; } /* Because "gboxed" is owned by a jsval and will * be garbage collected, we make a copy here to be * owned by us. */ priv->gboxed = g_boxed_copy(priv->gtype, gboxed); gjs_debug_lifecycle(GJS_DEBUG_GBOXED, "JSObject created with union instance %p type %s", priv->gboxed, g_type_name(priv->gtype)); GJS_NATIVE_CONSTRUCTOR_FINISH(union); return JS_TRUE; } static void union_finalize(JSFreeOp *fop, JSObject *obj) { Union *priv; priv = (Union*) JS_GetPrivate(obj); gjs_debug_lifecycle(GJS_DEBUG_GBOXED, "finalize, obj %p priv %p", obj, priv); if (priv == NULL) return; /* wrong class? */ if (priv->gboxed) { g_boxed_free(g_registered_type_info_get_g_type( (GIRegisteredTypeInfo*) priv->info), priv->gboxed); priv->gboxed = NULL; } if (priv->info) { g_base_info_unref( (GIBaseInfo*) priv->info); priv->info = NULL; } GJS_DEC_COUNTER(boxed); g_slice_free(Union, priv); } static JSBool to_string_func(JSContext *context, unsigned argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(context, vp); Union *priv; JSBool ret = JS_FALSE; jsval retval; if (!priv_from_js_with_typecheck(context, obj, &priv)) goto out; if (!_gjs_proxy_to_string_func(context, obj, "union", (GIBaseInfo*)priv->info, priv->gtype, priv->gboxed, &retval)) goto out; ret = JS_TRUE; JS_SET_RVAL(context, vp, retval); out: return ret; } /* The bizarre thing about this vtable is that it applies to both * instances of the object, and to the prototype that instances of the * class have. */ struct JSClass gjs_union_class = { "GObject_Union", JSCLASS_HAS_PRIVATE | JSCLASS_NEW_RESOLVE, JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, (JSResolveOp) union_new_resolve, /* needs cast since it's the new resolve signature */ JS_ConvertStub, union_finalize, NULL, NULL, NULL, NULL, NULL }; JSPropertySpec gjs_union_proto_props[] = { { NULL } }; JSFunctionSpec gjs_union_proto_funcs[] = { { "toString", JSOP_WRAPPER((JSNative)to_string_func), 0, 0 }, { NULL } }; JSBool gjs_define_union_class(JSContext *context, JSObject *in_object, GIUnionInfo *info) { const char *constructor_name; JSObject *prototype; jsval value; Union *priv; GType gtype; JSObject *constructor; /* For certain unions, we may be able to relax this in the future by * directly allocating union memory, as we do for structures in boxed.c */ gtype = g_registered_type_info_get_g_type( (GIRegisteredTypeInfo*) info); if (gtype == G_TYPE_NONE) { gjs_throw(context, "Unions must currently be registered as boxed types"); return JS_FALSE; } /* See the comment in gjs_define_object_class() for an * explanation of how this all works; Union is pretty much the * same as Object. */ constructor_name = g_base_info_get_name( (GIBaseInfo*) info); if (!gjs_init_class_dynamic(context, in_object, NULL, g_base_info_get_namespace( (GIBaseInfo*) info), constructor_name, &gjs_union_class, gjs_union_constructor, 0, /* props of prototype */ &gjs_union_proto_props[0], /* funcs of prototype */ &gjs_union_proto_funcs[0], /* props of constructor, MyConstructor.myprop */ NULL, /* funcs of constructor, MyConstructor.myfunc() */ NULL, &prototype, &constructor)) { g_error("Can't init class %s", constructor_name); } GJS_INC_COUNTER(boxed); priv = g_slice_new0(Union); priv->info = info; g_base_info_ref( (GIBaseInfo*) priv->info); priv->gtype = gtype; JS_SetPrivate(prototype, priv); gjs_debug(GJS_DEBUG_GBOXED, "Defined class %s prototype is %p class %p in object %p", constructor_name, prototype, JS_GetClass(prototype), in_object); value = OBJECT_TO_JSVAL(gjs_gtype_create_gtype_wrapper(context, gtype)); JS_DefineProperty(context, constructor, "$gtype", value, NULL, NULL, JSPROP_PERMANENT); return JS_TRUE; } JSObject* gjs_union_from_c_union(JSContext *context, GIUnionInfo *info, void *gboxed) { JSObject *obj; JSObject *proto; Union *priv; GType gtype; if (gboxed == NULL) return NULL; /* For certain unions, we may be able to relax this in the future by * directly allocating union memory, as we do for structures in boxed.c */ gtype = g_registered_type_info_get_g_type( (GIRegisteredTypeInfo*) info); if (gtype == G_TYPE_NONE) { gjs_throw(context, "Unions must currently be registered as boxed types"); return NULL; } gjs_debug_marshal(GJS_DEBUG_GBOXED, "Wrapping union %s %p with JSObject", g_base_info_get_name((GIBaseInfo *)info), gboxed); proto = gjs_lookup_generic_prototype(context, (GIUnionInfo*) info); obj = JS_NewObjectWithGivenProto(context, JS_GetClass(proto), proto, gjs_get_import_global (context)); GJS_INC_COUNTER(boxed); priv = g_slice_new0(Union); JS_SetPrivate(obj, priv); priv->info = info; g_base_info_ref( (GIBaseInfo *) priv->info); priv->gtype = gtype; priv->gboxed = g_boxed_copy(gtype, gboxed); return obj; } void* gjs_c_union_from_union(JSContext *context, JSObject *obj) { Union *priv; if (obj == NULL) return NULL; priv = priv_from_js(context, obj); return priv->gboxed; } JSBool gjs_typecheck_union(JSContext *context, JSObject *object, GIStructInfo *expected_info, GType expected_type, JSBool throw_error) { Union *priv; JSBool result; if (!do_base_typecheck(context, object, throw_error)) return JS_FALSE; priv = priv_from_js(context, object); if (priv->gboxed == NULL) { if (throw_error) { gjs_throw_custom(context, "TypeError", "Object is %s.%s.prototype, not an object instance - cannot convert to a union instance", g_base_info_get_namespace( (GIBaseInfo*) priv->info), g_base_info_get_name( (GIBaseInfo*) priv->info)); } return JS_FALSE; } if (expected_type != G_TYPE_NONE) result = g_type_is_a (priv->gtype, expected_type); else if (expected_info != NULL) result = g_base_info_equal((GIBaseInfo*) priv->info, (GIBaseInfo*) expected_info); else result = JS_TRUE; if (!result && throw_error) { if (expected_info != NULL) { gjs_throw_custom(context, "TypeError", "Object is of type %s.%s - cannot convert to %s.%s", g_base_info_get_namespace((GIBaseInfo*) priv->info), g_base_info_get_name((GIBaseInfo*) priv->info), g_base_info_get_namespace((GIBaseInfo*) expected_info), g_base_info_get_name((GIBaseInfo*) expected_info)); } else { gjs_throw_custom(context, "TypeError", "Object is of type %s.%s - cannot convert to %s", g_base_info_get_namespace((GIBaseInfo*) priv->info), g_base_info_get_name((GIBaseInfo*) priv->info), g_type_name(expected_type)); } } return result; }
mtwebster/cjs
gi/union.cpp
C++
mit
16,293
/* Project Orleans Cloud Service SDK ver. 1.0 Copyright (c) Microsoft Corporation All rights reserved. MIT License 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.Collections.Generic; using System.Diagnostics; using System; namespace Orleans.Runtime { internal class Constants { // This needs to be first, as GrainId static initializers reference it. Otherwise, GrainId actually see a uninitialized (ie Zero) value for that "constant"! public static readonly TimeSpan INFINITE_TIMESPAN = TimeSpan.FromMilliseconds(-1); // We assume that clock skew between silos and between clients and silos is always less than 1 second public static readonly TimeSpan MAXIMUM_CLOCK_SKEW = TimeSpan.FromSeconds(1); public const string DEFAULT_STORAGE_PROVIDER_NAME = "Default"; public const string MEMORY_STORAGE_PROVIDER_NAME = "MemoryStore"; public const string DATA_CONNECTION_STRING_NAME = "DataConnectionString"; public static readonly GrainId DirectoryServiceId = GrainId.GetSystemTargetGrainId(10); public static readonly GrainId DirectoryCacheValidatorId = GrainId.GetSystemTargetGrainId(11); public static readonly GrainId SiloControlId = GrainId.GetSystemTargetGrainId(12); public static readonly GrainId ClientObserverRegistrarId = GrainId.GetSystemTargetGrainId(13); public static readonly GrainId CatalogId = GrainId.GetSystemTargetGrainId(14); public static readonly GrainId MembershipOracleId = GrainId.GetSystemTargetGrainId(15); public static readonly GrainId ReminderServiceId = GrainId.GetSystemTargetGrainId(16); public static readonly GrainId TypeManagerId = GrainId.GetSystemTargetGrainId(17); public static readonly GrainId ProviderManagerSystemTargetId = GrainId.GetSystemTargetGrainId(19); public static readonly GrainId DeploymentLoadPublisherSystemTargetId = GrainId.GetSystemTargetGrainId(22); public const int PULLING_AGENTS_MANAGER_SYSTEM_TARGET_TYPE_CODE = 254; public const int PULLING_AGENT_SYSTEM_TARGET_TYPE_CODE = 255; public static readonly GrainId SystemMembershipTableId = GrainId.GetSystemGrainId(new Guid("01145FEC-C21E-11E0-9105-D0FB4724019B")); public static readonly GrainId SiloDirectConnectionId = GrainId.GetSystemGrainId(new Guid("01111111-1111-1111-1111-111111111111")); internal const long ReminderTableGrainId = 12345; /// <summary> /// The default timeout before a request is assumed to have failed. /// </summary> public static readonly TimeSpan DEFAULT_RESPONSE_TIMEOUT = Debugger.IsAttached ? TimeSpan.FromMinutes(30) : TimeSpan.FromSeconds(30); /// <summary> /// Minimum period for registering a reminder ... we want to enforce a lower bound /// </summary> public static readonly TimeSpan MinReminderPeriod = TimeSpan.FromMinutes(1); // increase this period, reminders are supposed to be less frequent ... we use 2 seconds just to reduce the running time of the unit tests /// <summary> /// Refresh local reminder list to reflect the global reminder table every 'REFRESH_REMINDER_LIST' period /// </summary> public static readonly TimeSpan RefreshReminderList = TimeSpan.FromMinutes(5); public const int LARGE_OBJECT_HEAP_THRESHOLD = 85000; public const bool DEFAULT_PROPAGATE_E2E_ACTIVITY_ID = false; public const int DEFAULT_LOGGER_BULK_MESSAGE_LIMIT = 5; public static readonly bool USE_BLOCKING_COLLECTION = true; private static readonly Dictionary<GrainId, string> singletonSystemTargetNames = new Dictionary<GrainId, string> { {DirectoryServiceId, "DirectoryService"}, {DirectoryCacheValidatorId, "DirectoryCacheValidator"}, {SiloControlId,"SiloControl"}, {ClientObserverRegistrarId,"ClientObserverRegistrar"}, {CatalogId,"Catalog"}, {MembershipOracleId,"MembershipOracle"}, {ReminderServiceId,"ReminderService"}, {TypeManagerId,"TypeManagerId"}, {ProviderManagerSystemTargetId, "ProviderManagerSystemTarget"}, {DeploymentLoadPublisherSystemTargetId, "DeploymentLoadPublisherSystemTarge"}, }; private static readonly Dictionary<int, string> nonSingletonSystemTargetNames = new Dictionary<int, string> { {PULLING_AGENT_SYSTEM_TARGET_TYPE_CODE, "PullingAgentSystemTarget"}, {PULLING_AGENTS_MANAGER_SYSTEM_TARGET_TYPE_CODE, "PullingAgentsManagerSystemTarget"}, }; public static string SystemTargetName(GrainId id) { string name; if (singletonSystemTargetNames.TryGetValue(id, out name)) return name; if (nonSingletonSystemTargetNames.TryGetValue(id.GetTypeCode(), out name)) return name; return String.Empty; } public static bool IsSingletonSystemTarget(GrainId id) { return singletonSystemTargetNames.ContainsKey(id); } private static readonly Dictionary<GrainId, string> systemGrainNames = new Dictionary<GrainId, string> { {SystemMembershipTableId, "MembershipTableGrain"}, {SiloDirectConnectionId, "SiloDirectConnectionId"} }; public static bool TryGetSystemGrainName(GrainId id, out string name) { return systemGrainNames.TryGetValue(id, out name); } public static bool IsSystemGrain(GrainId grain) { return systemGrainNames.ContainsKey(grain); } } }
yaronthurm/orleans
src/Orleans/Runtime/Constants.cs
C#
mit
6,677
// // FastTemplate // // The MIT License (MIT) // // Copyright (c) 2014 Jeff Panici // 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.Globalization; namespace PaniciSoftware.FastTemplate.Common { public class UIntType : PrimitiveType { public UIntType() { } public UIntType(Int64 i) { Value = (UInt64) i; } public override Type UnderlyingType { get { return typeof (UInt64); } } public override object RawValue { get { return Value; } } public UInt64 Value { get; set; } public static explicit operator UIntType(UInt64 i) { return new UIntType((Int64) i); } public override object ApplyBinary(Operator op, ITemplateType rhs) { switch (op) { case Operator.Div: { var uIntType = rhs as UIntType; if (uIntType != null) { return Value/(uIntType).Value; } var doubleType = rhs as DoubleType; if (doubleType != null) { return Value/(doubleType).Value; } var decimalType = rhs as DecimalType; if (decimalType != null) { return Value/(decimalType).Value; } break; } case Operator.EQ: { var uIntType = rhs as UIntType; if (uIntType != null) { return Value == (uIntType).Value; } var doubleType = rhs as DoubleType; if (doubleType != null) { return Value == (doubleType).Value; } var decimalType = rhs as DecimalType; if (decimalType != null) { return Value == (decimalType).Value; } if (rhs is NullType) { return Value == default(ulong); } break; } case Operator.GE: { var uIntType = rhs as UIntType; if (uIntType != null) { return Value >= (uIntType).Value; } var doubleType = rhs as DoubleType; if (doubleType != null) { return Value >= (doubleType).Value; } var decimalType = rhs as DecimalType; if (decimalType != null) { return Value >= (decimalType).Value; } break; } case Operator.GT: { var uIntType = rhs as UIntType; if (uIntType != null) { return Value > (uIntType).Value; } var doubleType = rhs as DoubleType; if (doubleType != null) { return Value > (doubleType).Value; } var decimalType = rhs as DecimalType; if (decimalType != null) { return Value > (decimalType).Value; } break; } case Operator.LE: { var uIntType = rhs as UIntType; if (uIntType != null) { return Value <= (uIntType).Value; } var doubleType = rhs as DoubleType; if (doubleType != null) { return Value <= (doubleType).Value; } var decimalType = rhs as DecimalType; if (decimalType != null) { return Value <= (decimalType).Value; } break; } case Operator.LT: { var uIntType = rhs as UIntType; if (uIntType != null) { return Value < (uIntType).Value; } var doubleType = rhs as DoubleType; if (doubleType != null) { return Value < (doubleType).Value; } var decimalType = rhs as DecimalType; if (decimalType != null) { return Value < (decimalType).Value; } break; } case Operator.Minus: { var uIntType = rhs as UIntType; if (uIntType != null) { return Value - (uIntType).Value; } var doubleType = rhs as DoubleType; if (doubleType != null) { return Value - (doubleType).Value; } var decimalType = rhs as DecimalType; if (decimalType != null) { return Value - (decimalType).Value; } break; } case Operator.Mod: { var uIntType = rhs as UIntType; if (uIntType != null) { return Value%(uIntType).Value; } var doubleType = rhs as DoubleType; if (doubleType != null) { return Value%(doubleType).Value; } var decimalType = rhs as DecimalType; if (decimalType != null) { return Value%(decimalType).Value; } break; } case Operator.Mul: { var uIntType = rhs as UIntType; if (uIntType != null) { return Value*(uIntType).Value; } var doubleType = rhs as DoubleType; if (doubleType != null) { return Value*(doubleType).Value; } var decimalType = rhs as DecimalType; if (decimalType != null) { return Value*(decimalType).Value; } break; } case Operator.NEQ: { var uIntType = rhs as UIntType; if (uIntType != null) { return Value != (uIntType).Value; } var doubleType = rhs as DoubleType; if (doubleType != null) { return Value != (doubleType).Value; } var decimalType = rhs as DecimalType; if (decimalType != null) { return Value != (decimalType).Value; } if (rhs is NullType) { return Value != default(ulong); } break; } case Operator.Plus: { var uIntType = rhs as UIntType; if (uIntType != null) { return Value + (uIntType).Value; } var doubleType = rhs as DoubleType; if (doubleType != null) { return Value + (doubleType).Value; } var stringType = rhs as StringType; if (stringType != null) { return string.Format( "{0}{1}", Value, (stringType).Value); } var decimalType = rhs as DecimalType; if (decimalType != null) { return Value + (decimalType).Value; } break; } } throw new InvalidTypeException( op.ToString(), UnderlyingType, rhs.UnderlyingType); } public override bool TryConvert<T>(out T o) { try { var type = typeof (T); if (type == typeof (string)) { o = (T) (object) Value.ToString(CultureInfo.InvariantCulture); return true; } if (type == typeof (double)) { o = (T) (object) Convert.ToDouble(Value); return true; } if (type == typeof (UInt64)) { o = (T) (object) Value; return true; } if (type == typeof (Int64)) { o = (T) (object) Convert.ToInt64(Value); return true; } if (type == typeof (decimal)) { o = (T) (object) Convert.ToDecimal(Value); return true; } } catch (Exception) { o = default(T); return false; } o = default(T); return false; } public override object ApplyUnary(Operator op) { switch (op) { case Operator.Plus: { return +Value; } } throw new InvalidTypeException( op.ToString(), UnderlyingType); } } }
jeffpanici75/FastTemplate
PaniciSoftware.FastTemplate/Common/UIntType.cs
C#
mit
11,872
<?xml version="1.0" ?><!DOCTYPE TS><TS language="bs" version="2.1"> <context> <name>AboutDialog</name> <message> <location filename="../forms/aboutdialog.ui" line="+14"/> <source>About phreak</source> <translation type="unfinished"/> </message> <message> <location line="+39"/> <source>&lt;b&gt;phreak&lt;/b&gt; 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 phreak 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 ([email protected]) and UPnP software written by Thomas Bernard.</source> <translation type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+27"/> <source>Create a new address</source> <translation type="unfinished"/> </message> <message> <location line="+14"/> <source>Copy the currently selected address to the system clipboard</source> <translation type="unfinished"/> </message> <message> <location line="-11"/> <source>&amp;New Address</source> <translation type="unfinished"/> </message> <message> <location line="-46"/> <source>These are your phreak 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>&amp;Copy Address</source> <translation type="unfinished"/> </message> <message> <location line="+11"/> <source>Show &amp;QR Code</source> <translation type="unfinished"/> </message> <message> <location line="+11"/> <source>Sign a message to prove you own a phreak address</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Sign &amp;Message</source> <translation type="unfinished"/> </message> <message> <location line="+25"/> <source>Delete the currently selected address from the list</source> <translation type="unfinished"/> </message> <message> <location line="-14"/> <source>Verify a message to ensure it was signed with a specified phreak address</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>&amp;Verify Message</source> <translation type="unfinished"/> </message> <message> <location line="+14"/> <source>&amp;Delete</source> <translation type="unfinished"/> </message> <message> <location filename="../addressbookpage.cpp" line="+65"/> <source>Copy &amp;Label</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>&amp;Edit</source> <translation type="unfinished"/> </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 type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+0"/> <source>Address</source> <translation type="unfinished"/> </message> <message> <location line="+36"/> <source>(no label)</source> <translation type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+14"/> <source>New passphrase</source> <translation type="unfinished"/> </message> <message> <location line="+14"/> <source>Repeat new passphrase</source> <translation type="unfinished"/> </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.&lt;br/&gt;Please use a passphrase of &lt;b&gt;10 or more random characters&lt;/b&gt;, or &lt;b&gt;eight or more words&lt;/b&gt;.</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Encrypt wallet</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <source>This operation needs your wallet passphrase to unlock the wallet.</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Unlock wallet</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>This operation needs your wallet passphrase to decrypt the wallet.</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Decrypt wallet</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Change passphrase</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Enter the old and new passphrase to the wallet.</source> <translation type="unfinished"/> </message> <message> <location line="+46"/> <source>Confirm wallet encryption</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Warning: If you encrypt your wallet and lose your passphrase, you will &lt;b&gt;LOSE ALL OF YOUR COINS&lt;/b&gt;!</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 type="unfinished"/> </message> <message> <location line="-58"/> <source>phreak 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 type="unfinished"/> </message> <message> <location line="-56"/> <source>Wallet encryption failed due to an internal error. Your wallet was not encrypted.</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <location line="+50"/> <source>The supplied passphrases do not match.</source> <translation type="unfinished"/> </message> <message> <location line="-38"/> <source>Wallet unlock failed</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <location line="+12"/> <location line="+19"/> <source>The passphrase entered for the wallet decryption was incorrect.</source> <translation type="unfinished"/> </message> <message> <location line="-20"/> <source>Wallet decryption failed</source> <translation type="unfinished"/> </message> <message> <location line="+14"/> <source>Wallet passphrase was successfully changed.</source> <translation type="unfinished"/> </message> </context> <context> <name>BitcoinGUI</name> <message> <location filename="../bitcoingui.cpp" line="+282"/> <source>Sign &amp;message...</source> <translation type="unfinished"/> </message> <message> <location line="+251"/> <source>Synchronizing with network...</source> <translation type="unfinished"/> </message> <message> <location line="-319"/> <source>&amp;Overview</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Show general overview of wallet</source> <translation type="unfinished"/> </message> <message> <location line="+17"/> <source>&amp;Transactions</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Browse transaction history</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>&amp;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>&amp;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>&amp;Send coins</source> <translation type="unfinished"/> </message> <message> <location line="+35"/> <source>E&amp;xit</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Quit application</source> <translation type="unfinished"/> </message> <message> <location line="+6"/> <source>Show information about phreak</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>About &amp;Qt</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Show information about Qt</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>&amp;Options...</source> <translation type="unfinished"/> </message> <message> <location line="+4"/> <source>&amp;Encrypt Wallet...</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>&amp;Backup Wallet...</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>&amp;Change Passphrase...</source> <translation type="unfinished"/> </message> <message numerus="yes"> <location line="+259"/> <source>~%n block(s) remaining</source> <translation type="unfinished"><numerusform></numerusform><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="-256"/> <source>&amp;Export...</source> <translation type="unfinished"/> </message> <message> <location line="-64"/> <source>Send coins to a phreak address</source> <translation type="unfinished"/> </message> <message> <location line="+47"/> <source>Modify configuration options for phreak</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 type="unfinished"/> </message> <message> <location line="+10"/> <source>&amp;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>&amp;Verify message...</source> <translation type="unfinished"/> </message> <message> <location line="-202"/> <source>phreak</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source>Wallet</source> <translation type="unfinished"/> </message> <message> <location line="+180"/> <source>&amp;About phreak</source> <translation type="unfinished"/> </message> <message> <location line="+9"/> <source>&amp;Show / Hide</source> <translation type="unfinished"/> </message> <message> <location line="+9"/> <source>Unlock wallet</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>&amp;Lock Wallet</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Lock wallet</source> <translation type="unfinished"/> </message> <message> <location line="+35"/> <source>&amp;File</source> <translation type="unfinished"/> </message> <message> <location line="+8"/> <source>&amp;Settings</source> <translation type="unfinished"/> </message> <message> <location line="+8"/> <source>&amp;Help</source> <translation type="unfinished"/> </message> <message> <location line="+12"/> <source>Tabs toolbar</source> <translation type="unfinished"/> </message> <message> <location line="+8"/> <source>Actions toolbar</source> <translation type="unfinished"/> </message> <message> <location line="+13"/> <location line="+9"/> <source>[testnet]</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <location line="+60"/> <source>phreak client</source> <translation type="unfinished"/> </message> <message numerus="yes"> <location line="+75"/> <source>%n active connection(s) to phreak network</source> <translation type="unfinished"><numerusform></numerusform><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.&lt;br&gt;Your weight is %1&lt;br&gt;Network weight is %2&lt;br&gt;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&apos;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><numerusform></numerusform></translation> </message> <message> <location line="-312"/> <source>About phreak card</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Show information about phreak card</source> <translation type="unfinished"/> </message> <message> <location line="+18"/> <source>&amp;Unlock Wallet...</source> <translation type="unfinished"/> </message> <message numerus="yes"> <location line="+297"/> <source>%n minute(s) ago</source> <translation type="unfinished"><numerusform></numerusform><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><numerusform></numerusform></translation> </message> <message numerus="yes"> <location line="+4"/> <source>%n day(s) ago</source> <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform><numerusform></numerusform></translation> </message> <message> <location line="+6"/> <source>Up to date</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <source>Catching up...</source> <translation type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+1"/> <source>Incoming transaction</source> <translation type="unfinished"/> </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 phreak address or malformed URI parameters.</source> <translation type="unfinished"/> </message> <message> <location line="+18"/> <source>Wallet is &lt;b&gt;encrypted&lt;/b&gt; and currently &lt;b&gt;unlocked&lt;/b&gt;</source> <translation type="unfinished"/> </message> <message> <location line="+10"/> <source>Wallet is &lt;b&gt;encrypted&lt;/b&gt; and currently &lt;b&gt;locked&lt;/b&gt;</source> <translation type="unfinished"/> </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><numerusform></numerusform></translation> </message> <message numerus="yes"> <location line="+4"/> <source>%n minute(s)</source> <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform><numerusform></numerusform></translation> </message> <message numerus="yes"> <location line="+4"/> <source>%n hour(s)</source> <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform><numerusform></numerusform></translation> </message> <message numerus="yes"> <location line="+4"/> <source>%n day(s)</source> <translation type="unfinished"><numerusform></numerusform><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. phreak 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 type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+5"/> <source>Label</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Address</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Date</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Confirmations</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Confirmed</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Priority</source> <translation type="unfinished"/> </message> <message> <location filename="../coincontroldialog.cpp" line="-515"/> <source>Copy address</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Copy label</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <location line="+26"/> <source>Copy amount</source> <translation type="unfinished"/> </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 &quot;medium&quot;. 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 type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+11"/> <source>&amp;Label</source> <translation type="unfinished"/> </message> <message> <location line="+10"/> <source>The label associated with this address book entry</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <source>&amp;Address</source> <translation type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+4"/> <source>New sending address</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Edit receiving address</source> <translation type="unfinished"/> </message> <message> <location line="+4"/> <source>Edit sending address</source> <translation type="unfinished"/> </message> <message> <location line="+76"/> <source>The entered address &quot;%1&quot; is already in the address book.</source> <translation type="unfinished"/> </message> <message> <location line="-5"/> <source>The entered address &quot;%1&quot; is not a valid phreak address.</source> <translation type="unfinished"/> </message> <message> <location line="+10"/> <source>Could not unlock wallet.</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>New key generation failed.</source> <translation type="unfinished"/> </message> </context> <context> <name>GUIUtil::HelpMessageBox</name> <message> <location filename="../guiutil.cpp" line="+420"/> <location line="+12"/> <source>phreak-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 &quot;de_DE&quot; (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 type="unfinished"/> </message> <message> <location line="+16"/> <source>&amp;Main</source> <translation type="unfinished"/> </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 &amp;fee</source> <translation type="unfinished"/> </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 phreak after logging in to the system.</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>&amp;Start phreak 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>&amp;Detach databases at shutdown</source> <translation type="unfinished"/> </message> <message> <location line="+21"/> <source>&amp;Network</source> <translation type="unfinished"/> </message> <message> <location line="+6"/> <source>Automatically open the phreak 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 &amp;UPnP</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <source>Connect to the phreak network through a SOCKS proxy (e.g. when connecting through Tor).</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>&amp;Connect through SOCKS proxy:</source> <translation type="unfinished"/> </message> <message> <location line="+9"/> <source>Proxy &amp;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>&amp;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 &amp;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>&amp;Window</source> <translation type="unfinished"/> </message> <message> <location line="+6"/> <source>Show only a tray icon after minimizing the window.</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>&amp;Minimize to the tray instead of the taskbar</source> <translation type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+3"/> <source>M&amp;inimize on close</source> <translation type="unfinished"/> </message> <message> <location line="+21"/> <source>&amp;Display</source> <translation type="unfinished"/> </message> <message> <location line="+8"/> <source>User Interface &amp;language:</source> <translation type="unfinished"/> </message> <message> <location line="+13"/> <source>The user interface language can be set here. This setting will take effect after restarting phreak.</source> <translation type="unfinished"/> </message> <message> <location line="+11"/> <source>&amp;Unit to show amounts in:</source> <translation type="unfinished"/> </message> <message> <location line="+13"/> <source>Choose the default subdivision unit to show in the interface and when sending coins.</source> <translation type="unfinished"/> </message> <message> <location line="+9"/> <source>Whether to show phreak addresses in the transaction list or not.</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>&amp;Display addresses in transaction list</source> <translation type="unfinished"/> </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 &amp;control features (experts only!)</source> <translation type="unfinished"/> </message> <message> <location line="+71"/> <source>&amp;OK</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <source>&amp;Cancel</source> <translation type="unfinished"/> </message> <message> <location line="+10"/> <source>&amp;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 phreak.</source> <translation type="unfinished"/> </message> <message> <location line="+29"/> <source>The supplied proxy address is invalid.</source> <translation type="unfinished"/> </message> </context> <context> <name>OverviewPage</name> <message> <location filename="../forms/overviewpage.ui" line="+14"/> <source>Form</source> <translation type="unfinished"/> </message> <message> <location line="+33"/> <location line="+231"/> <source>The displayed information may be out of date. Your wallet automatically synchronizes with the phreak 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 type="unfinished"/> </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>&lt;b&gt;Recent transactions&lt;/b&gt;</source> <translation type="unfinished"/> </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 type="unfinished"/> </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>&amp;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 type="unfinished"/> </message> <message> <location line="-217"/> <source>Client version</source> <translation type="unfinished"/> </message> <message> <location line="-45"/> <source>&amp;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 type="unfinished"/> </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>&amp;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 phreak-Qt help message to get a list with possible phreak command-line options.</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>&amp;Show</source> <translation type="unfinished"/> </message> <message> <location line="+24"/> <source>&amp;Console</source> <translation type="unfinished"/> </message> <message> <location line="-260"/> <source>Build date</source> <translation type="unfinished"/> </message> <message> <location line="-104"/> <source>phreak - Debug window</source> <translation type="unfinished"/> </message> <message> <location line="+25"/> <source>phreak 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 phreak 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 type="unfinished"/> </message> <message> <location filename="../rpcconsole.cpp" line="-33"/> <source>Welcome to the phreak RPC console.</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Use up and down arrows to navigate history, and &lt;b&gt;Ctrl-L&lt;/b&gt; to clear screen.</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Type &lt;b&gt;help&lt;/b&gt; 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 type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+22"/> <location line="+86"/> <location line="+86"/> <location line="+32"/> <source>0.00 PHR</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 type="unfinished"/> </message> <message> <location line="+3"/> <source>Add &amp;Recipient</source> <translation type="unfinished"/> </message> <message> <location line="+20"/> <source>Remove all transaction fields</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Clear &amp;All</source> <translation type="unfinished"/> </message> <message> <location line="+28"/> <source>Balance:</source> <translation type="unfinished"/> </message> <message> <location line="+16"/> <source>123.456 PHR</source> <translation type="unfinished"/> </message> <message> <location line="+31"/> <source>Confirm the send action</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>S&amp;end</source> <translation type="unfinished"/> </message> <message> <location filename="../sendcoinsdialog.cpp" line="-173"/> <source>Enter a phreak address (e.g. PHR1xGeKnTkaAotEVgs2rnUfVsFv8LVSM)</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 type="unfinished"/> </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>&lt;b&gt;%1&lt;/b&gt; to %2 (%3)</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Confirm send coins</source> <translation type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+5"/> <source>The amount to pay must be larger than 0.</source> <translation type="unfinished"/> </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 phreak address</source> <translation type="unfinished"/> </message> <message> <location line="+13"/> <source>(no label)</source> <translation type="unfinished"/> </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&amp;mount:</source> <translation type="unfinished"/> </message> <message> <location line="+13"/> <source>Pay &amp;To:</source> <translation type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+9"/> <source>&amp;Label:</source> <translation type="unfinished"/> </message> <message> <location line="+18"/> <source>The address to send the payment to (e.g. PHR1xGeKnTkaAotEVgs2rnUfVsFv8LVSM)</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 type="unfinished"/> </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 phreak address (e.g. PHR1xGeKnTkaAotEVgs2rnUfVsFv8LVSM)</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 type="unfinished"/> </message> <message> <location line="+13"/> <location line="+124"/> <source>&amp;Sign Message</source> <translation type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+18"/> <source>The address to sign the message with (e.g. PHR1xGeKnTkaAotEVgs2rnUfVsFv8LVSM)</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 type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+24"/> <source>Copy the current signature to the system clipboard</source> <translation type="unfinished"/> </message> <message> <location line="+21"/> <source>Sign the message to prove you own this phreak 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 &amp;All</source> <translation type="unfinished"/> </message> <message> <location line="-87"/> <location line="+70"/> <source>&amp;Verify Message</source> <translation type="unfinished"/> </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. PHR1xGeKnTkaAotEVgs2rnUfVsFv8LVSM)</source> <translation type="unfinished"/> </message> <message> <location line="+40"/> <source>Verify the message to ensure it was signed with the specified phreak 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 phreak address (e.g. PHR1xGeKnTkaAotEVgs2rnUfVsFv8LVSM)</source> <translation type="unfinished"/> </message> <message> <location line="-2"/> <source>Click &quot;Sign Message&quot; to generate signature</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Enter phreak signature</source> <translation type="unfinished"/> </message> <message> <location line="+82"/> <location line="+81"/> <source>The entered address is invalid.</source> <translation type="unfinished"/> </message> <message> <location line="-81"/> <location line="+8"/> <location line="+73"/> <location line="+8"/> <source>Please check the address and try again.</source> <translation type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+12"/> <source>Message signing failed.</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Message signed.</source> <translation type="unfinished"/> </message> <message> <location line="+59"/> <source>The signature could not be decoded.</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <location line="+13"/> <source>Please check the signature and try again.</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source>The signature did not match the message digest.</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <source>Message verification failed.</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Message verified.</source> <translation type="unfinished"/> </message> </context> <context> <name>TransactionDesc</name> <message> <location filename="../transactiondesc.cpp" line="+19"/> <source>Open until %1</source> <translation type="unfinished"/> </message> <message numerus="yes"> <location line="-2"/> <source>Open for %n block(s)</source> <translation type="unfinished"><numerusform></numerusform><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 type="unfinished"/> </message> <message> <location line="+2"/> <source>%1/unconfirmed</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>%1 confirmations</source> <translation type="unfinished"/> </message> <message> <location line="+18"/> <source>Status</source> <translation type="unfinished"/> </message> <message numerus="yes"> <location line="+7"/> <source>, broadcast through %n node(s)</source> <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform><numerusform></numerusform></translation> </message> <message> <location line="+4"/> <source>Date</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <source>Source</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source>Generated</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <location line="+17"/> <source>From</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <location line="+22"/> <location line="+58"/> <source>To</source> <translation type="unfinished"/> </message> <message> <location line="-77"/> <location line="+2"/> <source>own address</source> <translation type="unfinished"/> </message> <message> <location line="-2"/> <source>label</source> <translation type="unfinished"/> </message> <message> <location line="+37"/> <location line="+12"/> <location line="+45"/> <location line="+17"/> <location line="+30"/> <source>Credit</source> <translation type="unfinished"/> </message> <message numerus="yes"> <location line="-102"/> <source>matures in %n more block(s)</source> <translation type="unfinished"><numerusform></numerusform><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 type="unfinished"/> </message> <message> <location line="-39"/> <source>Transaction fee</source> <translation type="unfinished"/> </message> <message> <location line="+16"/> <source>Net amount</source> <translation type="unfinished"/> </message> <message> <location line="+6"/> <source>Message</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Comment</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Transaction ID</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Generated coins must mature 110 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 &quot;not accepted&quot; and it won&apos;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 type="unfinished"/> </message> <message> <location line="+5"/> <source>Inputs</source> <translation type="unfinished"/> </message> <message> <location line="+23"/> <source>Amount</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>true</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source>false</source> <translation type="unfinished"/> </message> <message> <location line="-211"/> <source>, has not been successfully broadcast yet</source> <translation type="unfinished"/> </message> <message> <location line="+35"/> <source>unknown</source> <translation type="unfinished"/> </message> </context> <context> <name>TransactionDescDialog</name> <message> <location filename="../forms/transactiondescdialog.ui" line="+14"/> <source>Transaction details</source> <translation type="unfinished"/> </message> <message> <location line="+6"/> <source>This pane shows a detailed description of the transaction</source> <translation type="unfinished"/> </message> </context> <context> <name>TransactionTableModel</name> <message> <location filename="../transactiontablemodel.cpp" line="+226"/> <source>Date</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source>Type</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source>Address</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source>Amount</source> <translation type="unfinished"/> </message> <message> <location line="+60"/> <source>Open until %1</source> <translation type="unfinished"/> </message> <message> <location line="+12"/> <source>Confirmed (%1 confirmations)</source> <translation type="unfinished"/> </message> <message numerus="yes"> <location line="-15"/> <source>Open for %n more block(s)</source> <translation type="unfinished"><numerusform></numerusform><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 type="unfinished"/> </message> <message> <location line="+3"/> <source>Generated but not accepted</source> <translation type="unfinished"/> </message> <message> <location line="+42"/> <source>Received with</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Received from</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Sent to</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Payment to yourself</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Mined</source> <translation type="unfinished"/> </message> <message> <location line="+38"/> <source>(n/a)</source> <translation type="unfinished"/> </message> <message> <location line="+190"/> <source>Transaction status. Hover over this field to show number of confirmations.</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Date and time that the transaction was received.</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Type of transaction.</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Destination address of transaction.</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Amount removed from or added to balance.</source> <translation type="unfinished"/> </message> </context> <context> <name>TransactionView</name> <message> <location filename="../transactionview.cpp" line="+55"/> <location line="+16"/> <source>All</source> <translation>Sve</translation> </message> <message> <location line="-15"/> <source>Today</source> <translation>Danas</translation> </message> <message> <location line="+1"/> <source>This week</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>This month</source> <translation>Ovaj mjesec</translation> </message> <message> <location line="+1"/> <source>Last month</source> <translation>Prošli mjesec</translation> </message> <message> <location line="+1"/> <source>This year</source> <translation>Ove godine</translation> </message> <message> <location line="+1"/> <source>Range...</source> <translation type="unfinished"/> </message> <message> <location line="+11"/> <source>Received with</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Sent to</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>To yourself</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Mined</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Other</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <source>Enter address or label to search</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <source>Min amount</source> <translation type="unfinished"/> </message> <message> <location line="+34"/> <source>Copy address</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Copy label</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Copy amount</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Copy transaction ID</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Edit label</source> <translation type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+8"/> <source>Confirmed</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Date</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Type</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Label</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Address</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Amount</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>ID</source> <translation type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+8"/> <source>to</source> <translation type="unfinished"/> </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>phreak version</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Usage:</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Send command to -server or phreakd</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>List commands</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Get help for a command</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Options:</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Specify configuration file (default: phreak.conf)</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Specify pid file (default: phreakd.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 type="unfinished"/> </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 &lt;port&gt; (default: 15714 or testnet: 25714)</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Maintain at most &lt;n&gt; 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 type="unfinished"/> </message> <message> <location line="+1"/> <source>Number of seconds to keep misbehaving peers from reconnecting (default: 86400)</source> <translation type="unfinished"/> </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 &lt;port&gt; (default: 15715 or testnet: 25715)</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 type="unfinished"/> </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&apos;s date and time are correct! If your clock is wrong phreak 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: &apos;%s&apos;</source> <translation type="unfinished"/> </message> <message> <location line="+4"/> <source>Invalid amount for -reservebalance=&lt;amount&gt;</source> <translation type="unfinished"/> </message> <message> <location line="-82"/> <source>Maximum per-connection receive buffer, &lt;n&gt;*1000 bytes (default: 5000)</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Maximum per-connection send buffer, &lt;n&gt;*1000 bytes (default: 1000)</source> <translation type="unfinished"/> </message> <message> <location line="-16"/> <source>Only connect to nodes in network &lt;net&gt; (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 type="unfinished"/> </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 type="unfinished"/> </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 type="unfinished"/> </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=phreakrpc 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 &quot;phreak Alert&quot; [email protected] </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 type="unfinished"/> </message> <message> <location line="+1"/> <source>Send commands to node running on &lt;ip&gt; (default: 127.0.0.1)</source> <translation type="unfinished"/> </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 &lt;n&gt; (default: 100)</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Rescan the block chain for missing wallet transactions</source> <translation type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+1"/> <source>Server certificate file (default: server.cert)</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Server private key (default: server.pem)</source> <translation type="unfinished"/> </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 type="unfinished"/> </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. phreak is probably already running.</source> <translation type="unfinished"/> </message> <message> <location line="-98"/> <source>phreak</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 type="unfinished"/> </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 phreak</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Wallet needed to be rewritten: restart phreak 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: &apos;%s&apos;</source> <translation type="unfinished"/> </message> <message> <location line="-1"/> <source>Unknown network specified in -onlynet: &apos;%s&apos;</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: &apos;%s&apos;</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Cannot resolve -externalip address: &apos;%s&apos;</source> <translation type="unfinished"/> </message> <message> <location line="-24"/> <source>Invalid amount for -paytxfee=&lt;amount&gt;: &apos;%s&apos;</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 type="unfinished"/> </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. phreak 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=&lt;amount&gt;: &apos;%s&apos;</source> <translation type="unfinished"/> </message> <message> <location line="+25"/> <source>Loading wallet...</source> <translation type="unfinished"/> </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 type="unfinished"/> </message> <message> <location line="+5"/> <source>Done loading</source> <translation type="unfinished"/> </message> <message> <location line="-167"/> <source>To use the %s option</source> <translation type="unfinished"/> </message> <message> <location line="+14"/> <source>Error</source> <translation type="unfinished"/> </message> <message> <location line="+6"/> <source>You must set rpcpassword=&lt;password&gt; 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>
qtvideofilter/streamingcoin
src/qt/locale/bitcoin_bs.ts
TypeScript
mit
107,835
<?php /** * Created by PhpStorm. * User: phpNT * Date: 24.07.2016 * Time: 21:57 */ namespace phpnt\cropper\assets; use yii\web\AssetBundle; class DistAsset extends AssetBundle { public $sourcePath = '@vendor/phpnt/yii2-cropper'; public $css = [ 'css/crop.css' ]; public $images = [ 'images/' ]; }
phpnt/yii2-cropper
assets/DistAsset.php
PHP
mit
343
本文的目的是为了探索通过genkins来打包不同target(DEBUG,PRE_RELEASE等) ## 在github上创建repo ## 在本地创建工程 ``` git remote add origin url_to_your_git_repo git branch --set-upstream master origin/master #track local master branch to origin/master git add * git commit -m 'first commit' git pull origin master git push origin master ``` ## 蒲公英中创建应用 ## 在genkins中配置build item ## 估值Target
pingguoilove/MultiTarget
README.md
Markdown
mit
449
--- layout: post date: 2015-08-29 title: "Alessandro Angelozzi 101 Sleeveless Chapel Train Sheath/Column" category: Alessandro Angelozzi tags: [Alessandro Angelozzi,Alessandro Angelozzi ,Sheath/Column,One shoulder,Chapel Train,Sleeveless] --- ### Alessandro Angelozzi 101 Just **$309.99** ### Sleeveless Chapel Train Sheath/Column <table><tr><td>BRANDS</td><td>Alessandro Angelozzi </td></tr><tr><td>Silhouette</td><td>Sheath/Column</td></tr><tr><td>Neckline</td><td>One shoulder</td></tr><tr><td>Hemline/Train</td><td>Chapel Train</td></tr><tr><td>Sleeve</td><td>Sleeveless</td></tr></table> <a href="https://www.readybrides.com/en/alessandro-angelozzi/14072-alessandro-angelozzi-101.html"><img src="//img.readybrides.com/31923/alessandro-angelozzi-101.jpg" alt="Alessandro Angelozzi 101" style="width:100%;" /></a> <!-- break --> Buy it: [https://www.readybrides.com/en/alessandro-angelozzi/14072-alessandro-angelozzi-101.html](https://www.readybrides.com/en/alessandro-angelozzi/14072-alessandro-angelozzi-101.html)
HOLEIN/HOLEIN.github.io
_posts/2015-08-29-Alessandro-Angelozzi-101-Sleeveless-Chapel-Train-SheathColumn.md
Markdown
mit
1,023
require 'vcr' require 'vcr/rspec' VCR.config do |c| c.cassette_library_dir = 'spec/vcr' c.http_stubbing_library = :webmock c.default_cassette_options = { :record => :new_episodes } end RSpec.configure do |c| c.extend VCR::RSpec::Macros end
compactcode/recurly-client-ruby
spec/support/vcr.rb
Ruby
mit
249
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace NonVisitorPatternExample { public class Loan { public int Owed { get; set; } public int MonthlyPayment { get; set; } } }
jasonlowder/DesignPatterns
NonVisitorPatternExample/Loan.cs
C#
mit
279
--- layout: post published: true title: Why we switched from AWS Lightsail to EC2 for Gitlab imagefeature: blog/aws-lightsail-create-gitlab.png mathjax: false featured: true comments: false description: AWS Lightsail vs AWS EC2 categories: - aws tags: ec2 aws lightsail vpc canonical: https://www.transfon.com/blog/Lightsail-vs-EC2-Gitlab --- Gitlab can do Continuous Integration, Continuous Delivery, and Continuous Deployment within the same web interface. You can host Gitlab CE yourself on your own servers or in a container or on the cloud providers for free. AWS Lightsail is a new product from AWS, it as simple as digitalocean or linode, one click to setup Gitlab CE. If you have a large website and looking for managed cloud service please check: <a href="https://www.transfon.com/services/managed-service">Transfon managed cloud service</a>. <p style="text-align: center;"><img src="https://www.devopszen.com/images/blog/aws-lightsail-create-gitlab.png" alt="AWS Lightsail - Gitlab"/></p> AWS Lightsail provides the fixed public IP which can be binded on a Lightsail instance. So when you modify the Lightsail instance the public IP will not change and you don't have to modify the DNS records which is good. <p style="text-align: center;"><img src="https://www.devopszen.com/images/blog/lightsail-fixed-public-ip.png" alt="AWS Lightsail Networking and fixed IP"/></p> There is a private IP of the instance similar to AWS EC2, which is using the CIDR 172.26.0.0/16. The firewall is very simple, you can only control the ports connectivity. It is not allowed to block IP or whitelist IP. You can only do this inside the instance with iptables. <p style="text-align: center;"><img src="https://www.devopszen.com/images/blog/lightsail-private-ip-firewall.png" alt="AWS Lightsail Networking and private IP"/></p> The private subnet gave me hope to connect with and communicate with the existed AWS VPC. Then we can see there is an advanced feature called VPC peering at the Lightsail settings menu. It is just a on/off button for VPC peering. <p style="text-align: center;"><img src="https://www.devopszen.com/images/blog/lightsail-vs-ec2-vpc-peering.png" alt="AWS Lightsail VPC peering"/></p> VPC peering only enables the Two-way communication between 2 VPC, and it is not possible to communication via a 'middle man' VPC. So the problem is you can only do VPC peering from AWS Lightsail VPC to the 'default' AWS VPC. We can't communite with the other custom VPC by default without setting up a proxy. Plus using the 'default' VPC is not a best practice. <p style="text-align: center;"><img src="https://www.devopszen.com/images/blog/aws-ec2-gitlab-instance-marketplace.png" alt="AWS EC2 marketplace - Gitlab"/></p> So, it is better to launch the Gitlab instance inside your existed VPC with a marketplace instance which is providing the same features.
doubaokun/devopszen
_posts/2017-12-15-why-not-aws-lightsail.md
Markdown
mit
2,879
// BASE64压缩接口 #ifndef _INCLUDE_BASE64_H #define _INCLUDE_BASE64_H #include <stdio.h> #include <stdlib.h> #include "sqlite3.h" // 标准Base64编码表 static char encoding_table[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'}; static char* decoding_table = NULL; static int mod_table[] = {0, 2, 1}; unsigned char* base64_encode(unsigned char* data, int input_length, int* output_length); unsigned char* base64_decode(unsigned char* data, int input_length, int* output_length); void build_decoding_table(); void base64_cleanup(); #endif // _INCLUDE_BASE64_H
wangwang4git/SQLite3-ICU
FTSJNI4/jni/include/base64.h
C
mit
1,077
Application.class_eval do get '/' do if current_user @sites = ABPlugin::API.sites( :include => { :envs => true, :categories => { :include => { :tests => { :include => { :variants => { :methods => :for_dashboard } } } } } }, :token => current_user.single_access_token ) @sites.sort! { |a, b| a["name"] <=> b["name"] } @sites.each do |site| site["categories"].sort! { |a, b| a["name"] <=> b["name"] } site["envs"].sort! { |a, b| a["name"] <=> b["name"] } site["categories"].each do |category| category["tests"].reverse! end end haml :dashboard else haml :front end end end
winton/a_b_front_end
lib/a_b_front_end/controller/front.rb
Ruby
mit
867
<?php namespace Wahlemedia\Showroom\Updates; use Schema; use October\Rain\Database\Schema\Blueprint; use October\Rain\Database\Updates\Migration; class add_short_description_to_items_table extends Migration { public function up() { Schema::table('wahlemedia_showroom_items', function (Blueprint $table) { $table->text('short_description')->nullable(); }); } public function down() { Schema::dropColumn('short_description'); } }
wahlemedia/oc-showroom-plugin
updates/add_short_description_to_items_table.php
PHP
mit
492
#### Integrations ##### Google Cloud SCC - Updated the Docker image to: *demisto/google-api-py3:1.0.0.27143*. - Fixed an issue where the ***test-module*** command would fail when using a custom certificate.
demisto/content
Packs/GoogleCloudSCC/ReleaseNotes/2_0_6.md
Markdown
mit
208
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <header class="entry-header" role="heading"> <h1 class="entry-title"> <?php if( !is_single() ) : ?> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a> <?php else: ?> <?php the_title(); ?> <?php endif; ?> </h1> </header><!-- .entry-header --> <div class="entry-meta clearfix"> <?php $postFormat = get_post_format($post->id); echo '<span class="genericon genericon-' . $postFormat . '"></span>'; ?> <?php cs_bootstrap_entry_meta(); ?> <?php comments_popup_link(__( '0 Kommentare', 'cs-bootstrap' ), __( '1 Kommentar', 'cs-bootstrap' ), __( '% Kommentare', 'cs-bootstrap' )); ?> <?php edit_post_link( __( 'editieren', 'cs-bootstrap' ), '<span class="edit-link">', '</span>' ); ?> </div><!-- .entry-meta --> <div class="row"> <?php if( has_post_thumbnail() ) : ?> <div class="entry-thumbnail col-sm-4"> <a href="<?php the_permalink(); ?>"> <figure> <?php the_post_thumbnail( 'full' ); ?> </figure> </a> </div> <div class="entry-content col-sm-8"> <blockquote> <?php the_content( __( 'Artikel "' . get_the_title() . '" lesen <span class="meta-nav">&raquo;</span>', 'cs-bootstrap' ) ); ?> </blockquote> </div> <?php else : ?> <div class="entry-content col-sm-12"> <blockquote> <?php the_content( __( 'Artikel "' . get_the_title() . '" lesen <span class="meta-nav">&raquo;</span>', 'cs-bootstrap' ) ); ?> </blockquote> </div> <?php endif; ?> <?php if( is_single() ) { wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Seiten:', 'cs-bootstrap' ) . '</span>', 'after' => '</div>' ) ); } ?> </div><!-- .entry-content --> </article><!-- #post-<?php the_ID(); ?> -->
purzlbaum/cs-bootstrap
content-quote.php
PHP
mit
1,925
module Days class App < Sinatra::Base get "/admin/users", :admin_only => true do @users = User.all haml :'admin/users/index', layout: :admin end get "/admin/users/new", :admin_only => true do @user = User.new haml :'admin/users/form', layout: :admin end post "/admin/users", :admin_only => true do user = params[:user] || halt(400) @user = User.new(user) if @user.save redirect "/admin/users/#{@user.id}" # FIXME: Permalink else status 406 haml :'admin/users/form', layout: :admin end end get "/admin/users/:id", :admin_only => true do @user = User.where(id: params[:id]).first || halt(404) haml :'admin/users/form', layout: :admin end put "/admin/users/:id", :admin_only => true do user = params[:user] || halt(400) @user = User.where(id: params[:id]).first || halt(404) if user[:password] == "" user.delete :password end @user.assign_attributes(user) if @user.save redirect "/admin/users/#{@user.id}" else status 406 haml :'admin/users/form', layout: :admin end end delete "/admin/users/:id", :admin_only => true do @user = User.where(id: params[:id]).first || halt(404) if @user == current_user halt 400 else @user.destroy redirect "/admin/users" end end end end
sorah/days
lib/days/app/admin/users.rb
Ruby
mit
1,446
""" Tests for L{monotone}. """ from hypothesis import given, strategies as st import errno from monotone import get_clock_info, monotonic from monotone import _api, _bindings import os import platform import pytest needs_posix = pytest.mark.skipif( os.name == "posix" and platform.system() == "Darwin", reason="POSIX-only tests (clock_gettime(3))", ) needs_macos = pytest.mark.skipif( platform.system() != "Darwin", reason="macOS-only tests (mach_absolute_time(3))", ) @pytest.fixture def errno_value(): """ A particular errno. """ return errno.EINVAL @pytest.fixture def strerror(errno_value): """ The string representation of a particular errno """ return "[Errno {}] Invalid argument".format(errno_value) @pytest.fixture def apply_failing_clock_call(monkeypatch): """ Return a callable that patches in a failing system call fake that fails and return a list of calls to that fake. """ def _apply_failing_clock_call(name, errno_value): calls = [] def _failing_clock_call(clock_id, timespec): calls.append((clock_id, timespec)) monkeypatch.setattr(_api.ffi, "errno", errno.EINVAL) return -1 monkeypatch.setattr(_api, name, _failing_clock_call) return calls return _apply_failing_clock_call @pytest.fixture def apply_timespec(monkeypatch): """ Return a callable that patches in a fake over the specified clock call that sets the specified resolution and returns a list of calls to that fake. """ def _apply_timespec(name, goal_timespec): calls = [] def _fake_clock_call(clock_id, timespec): calls.append((clock_id, timespec)) timespec[0] = goal_timespec[0] return 0 monkeypatch.setattr(_api, name, _fake_clock_call) return calls return _apply_timespec class TestSimpleNamespace(object): """ Tests for L{_SimpleNamespace}. """ def test_init(self): """ The initializer updates the instance's C{__dict__} with its keyword arguments. """ namespace = _api._SimpleNamespace(x=1) assert namespace.x == 1 def test_repr(self): """ The instance's repr reflects its C{__dict__} """ namespace = _api._SimpleNamespace() namespace.y = 2 assert repr(namespace) == "namespace(y=2)" def test_eq(self): """ Two instances with equal C{__dict__}s are equal. """ assert _api._SimpleNamespace(a=1) == _api._SimpleNamespace(a=1) @needs_posix class TestGetClockInfoPosix(object): """ Tests for L{get_clock_info}. """ def test_non_monotonic(self): """ L{get_clock_info} only knows about the monotonic clock. """ with pytest.raises(ValueError): get_clock_info("not monotonic") def test_failure(self, apply_failing_clock_call, errno_value, strerror): """ A failure in C{clock_getres} results in an L{OSError} that presents the failure's errno. """ calls = apply_failing_clock_call('_clock_getres', errno_value) with pytest.raises(OSError) as exc: get_clock_info("monotonic") assert len(calls) == 1 assert calls[0][0] == _bindings.lib.CLOCK_MONOTONIC assert str(exc.value) == strerror @given( clock_getres_spec=st.fixed_dictionaries({ "tv_sec": st.sampled_from([0, 1]), "tv_nsec": st.sampled_from([0, 1]), }), ) def test_info(self, clock_getres_spec, apply_timespec): """ The reported info always includes a nanosecond resolution when C{clock_getres} indicates nanosecond resolution. """ calls = apply_timespec( "_clock_getres", _bindings.ffi.new("struct timespec *", clock_getres_spec), ) expected_info = _api._SimpleNamespace( adjustable=False, implementation="clock_gettime(MONOTONIC)", monotonic=True, resolution=None, # checked separately ) if clock_getres_spec['tv_nsec']: expected_resolution = 1e-09 else: expected_resolution = 1.0 info = get_clock_info("monotonic") resolution, info.resolution = info.resolution, None assert info == expected_info assert resolution - expected_resolution == pytest.approx(0.0) assert len(calls) == 1 assert calls[0][0] == _bindings.lib.CLOCK_MONOTONIC @needs_macos class TestGetClockInfoMacOS(object): """ Tests for L{get_clock_info}. """ def test_non_monotonic(self): """ L{get_clock_info} only knows about the monotonic clock. """ with pytest.raises(ValueError): get_clock_info("not monotonic") def test_info(self): """ The reported info always includes a nanosecond resolution. """ expected_info = _api._SimpleNamespace( adjustable=False, implementation="mach_absolute_time()", monotonic=True, resolution=None, # checked separately ) expected_resolution = 1e-09 info = get_clock_info("monotonic") resolution, info.resolution = info.resolution, None assert info == expected_info assert resolution - expected_resolution == pytest.approx(0.0) @needs_posix def test_monotonic_fails_posix(apply_failing_clock_call, errno_value, strerror): """ A failure in C{clock_gettime} results in an L{OSError} that presents the failure's errno. """ calls = apply_failing_clock_call('_clock_gettime', errno_value) with pytest.raises(OSError) as exc: monotonic() assert len(calls) == 1 assert calls[0][0] == _bindings.lib.CLOCK_MONOTONIC assert str(exc.value) == strerror @needs_posix @given( clock_gettime_spec=st.fixed_dictionaries({ "tv_sec": st.integers(min_value=0, max_value=2 ** 32 - 1), "tv_nsec": st.integers(min_value=0, max_value=2 ** 32 - 1), }), ) def test_clock(clock_gettime_spec, apply_timespec): """ For any given time resolution, the monotonic time equals the sum of the seconds and nanoseconds. """ clock_gettime_calls = apply_timespec( '_clock_gettime', _bindings.ffi.new("struct timespec *", clock_gettime_spec), ) # we a float, representing the current seconds plus the # nanoseconds (offset by a billion) iff the resolution is accurate # to the nanosecond. expected = float(clock_gettime_spec['tv_sec']) + ( clock_gettime_spec['tv_nsec'] * 1e-09) result = monotonic() assert result - expected == pytest.approx(0.0) assert clock_gettime_calls[0][0] == _bindings.lib.CLOCK_MONOTONIC def test_clock_increases(): """ A monotonic moment is never greater than a succeeding monotonic moment. """ assert monotonic() <= monotonic()
mrwsr/monotone
test/test_monotone.py
Python
mit
7,143
import require from 'require'; function getDescriptor(obj: Record<string, unknown>, path: string) { let parts = path.split('.'); let value: unknown = obj; for (let i = 0; i < parts.length - 1; i++) { let part = parts[i]!; // NOTE: This isn't entirely safe since we could have a null! value = (value as Record<string, unknown>)[part]; if (!value) { return undefined; } } let last = parts[parts.length - 1]!; return Object.getOwnPropertyDescriptor(value, last); } export default function confirmExport( Ember: Record<string, unknown>, assert: QUnit['assert'], path: string, moduleId: string, exportName: string | { value: unknown; get: string; set: string } ) { try { let desc: PropertyDescriptor | null | undefined; if (path !== null) { desc = getDescriptor(Ember, path); assert.ok(desc, `the ${path} property exists on the Ember global`); } else { desc = null; } if (desc == null) { let mod = require(moduleId); assert.notEqual( mod[exportName as string], undefined, `${moduleId}#${exportName} is not \`undefined\`` ); } else if (typeof exportName === 'string') { let mod = require(moduleId); let value = 'value' in desc ? desc.value : desc.get!.call(Ember); assert.equal(value, mod[exportName], `Ember.${path} is exported correctly`); assert.notEqual(mod[exportName], undefined, `Ember.${path} is not \`undefined\``); } else if ('value' in desc) { assert.equal(desc.value, exportName.value, `Ember.${path} is exported correctly`); } else { let mod = require(moduleId); assert.equal(desc.get, mod[exportName.get], `Ember.${path} getter is exported correctly`); assert.notEqual(desc.get, undefined, `Ember.${path} getter is not undefined`); if (exportName.set) { assert.equal(desc.set, mod[exportName.set], `Ember.${path} setter is exported correctly`); assert.notEqual(desc.set, undefined, `Ember.${path} setter is not undefined`); } } } catch (error) { assert.pushResult({ result: false, message: `An error occurred while testing ${path} is exported from ${moduleId}`, actual: error, expected: undefined, }); } }
emberjs/ember.js
packages/internal-test-helpers/lib/confirm-export.ts
TypeScript
mit
2,277
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="theme-color" content="#000000"> <link rel="manifest" href="%PUBLIC_URL%/manifest.json"> <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"> <title>React App</title> </head> <body> <noscript> You need to enable JavaScript to run this app. </noscript> <div id="root"></div> </body> </html>
gmmendezp/generator-nyssa-fe
generators/app/templates/public/index.html
HTML
mit
692
<?php namespace TenUp\Doze\v1_0_0; use PHPUnit_Framework_TestResult; use Text_Template; use WP_Mock; use WP_Mock\Tools\TestCase as BaseTestCase; class TestCase extends BaseTestCase { public function run( PHPUnit_Framework_TestResult $result = null ) { $this->setPreserveGlobalState( false ); return parent::run( $result ); } protected $testFiles = array(); public function setUp() { if ( ! empty( $this->testFiles ) ) { foreach ( $this->testFiles as $file ) { if ( file_exists( PROJECT . $file ) ) { require_once( PROJECT . $file ); } } } parent::setUp(); } public function assertActionsCalled() { $actions_not_added = $expected_actions = 0; try { WP_Mock::assertActionsCalled(); } catch ( \Exception $e ) { $actions_not_added = 1; $expected_actions = $e->getMessage(); } $this->assertEmpty( $actions_not_added, $expected_actions ); } public function ns( $function ) { if ( ! is_string( $function ) || false !== strpos( $function, '\\' ) ) { return $function; } $thisClassName = trim( get_class( $this ), '\\' ); if ( ! strpos( $thisClassName, '\\' ) ) { return $function; } // $thisNamespace is constructed by exploding the current class name on // namespace separators, running array_slice on that array starting at 0 // and ending one element from the end (chops the class name off) and // imploding that using namespace separators as the glue. $thisNamespace = implode( '\\', array_slice( explode( '\\', $thisClassName ), 0, - 1 ) ); return "$thisNamespace\\$function"; } /** * Define constants after requires/includes * * See http://kpayne.me/2012/07/02/phpunit-process-isolation-and-constant-already-defined/ * for more details * * @param \Text_Template $template */ public function prepareTemplate( \Text_Template $template ) { $template->setVar( [ 'globals' => '$GLOBALS[\'__PHPUNIT_BOOTSTRAP\'] = \'' . $GLOBALS['__PHPUNIT_BOOTSTRAP'] . '\';', ] ); parent::prepareTemplate( $template ); } }
ericmann/doze
tests/test-tools/TestCase.php
PHP
mit
2,024
<?php namespace Oro\Bundle\CalendarBundle\Form\EventListener; use Doctrine\Common\Collections\Collection; use Oro\Bundle\CalendarBundle\Entity\Attendee; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; /** * Makes sure indexes of attendees from request are equal to indexes of the same * attendees so that in the end we end up with correct data. */ class AttendeesSubscriber implements EventSubscriberInterface { /** * {@inheritdoc} */ public static function getSubscribedEvents() { return [ FormEvents::PRE_SUBMIT => ['fixSubmittedData', 100], ]; } /** * @SuppressWarnings(PHPMD.NPathComplexity) * * Makes sure indexes of attendees from request are equal to indexes of the same * attendees so that in the end we end up with correct data. * * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function fixSubmittedData(FormEvent $event) { /** @var Attendee[]|Collection $data */ $data = $event->getData(); $attendees = $event->getForm()->getData(); if (!$attendees || !$data) { return; } $attendeeKeysByEmail = []; foreach ($attendees as $key => $attendee) { $id = $attendee->getEmail() ?: $attendee->getDisplayName(); if (!$id) { return; } $attendeeKeysByEmail[$id] = $key; } $nextNewKey = count($attendeeKeysByEmail); $fixedData = []; foreach ($data as $attendee) { if (empty($attendee['email']) && empty($attendee['displayName'])) { return; } $id = empty($attendee['email']) ? $attendee['displayName'] : $attendee['email']; $key = isset($attendeeKeysByEmail[$id]) ? $attendeeKeysByEmail[$id] : $nextNewKey++; $fixedData[$key] = $attendee; } $event->setData($fixedData); } }
orocrm/OroCalendarBundle
Form/EventListener/AttendeesSubscriber.php
PHP
mit
2,088
package com.lynx.service; import java.util.Collection; import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import com.lynx.domain.User; import com.lynx.repository.UserRepository; import lombok.extern.slf4j.Slf4j; @Slf4j @Service public class UserService { @Autowired private UserRepository userRepository; public Optional<User> getUserById(String id) { log.debug("Getting user={}", id); return Optional.ofNullable(userRepository.findOne(id)); } public Optional<User> getUserByEmail(String email) { log.debug("Getting user by email={}", email.replaceFirst("@.*", "@***")); return userRepository.findOneByEmail(email); } public Collection<User> getAllUsers() { log.debug("Getting all users"); return userRepository.findAll(new Sort("email")); } public User create(User user) { return userRepository.save(user); } }
6o1/lynx-server
src/main/java/com/lynx/service/UserService.java
Java
mit
978
var _ = require('underscore'); var colors = require('colors'); var sprintf = require('sprintf-js').sprintf; /** * used to decode AIS messages. * Currently decodes types 1,2,3,4,5,9,18,19,21,24,27 * Currently does not decode 6,7,8,10,11,12,13,14,15,16,17,20,22,23,25,26 * Currently does not support the USCG Extended AIVDM messages * * Normal usage: * var decoder = new aivdmDecode.aivdmDecode(options) * then * decoder.decode(aivdm); * var msgData = decoder.getData(); * * aisData will return with an object that contains the message fields. * The object returned will also include the sentence(s) that were decoded. This is to make it easy to * use the decoder to filter based on in-message criteria but then forward the undecoded packets. * * The decoded data object uses field naming conventions in the same way that GPSD does. * * @param {object} options: * returnJson: If true then json is returned instead of a javascript object (default false) * aivdmPassthrough If true then the aivdm messages that were decoded are included with the returned object * default false */ /** * String.lpad: Used to pad mmsi's to 9 digits and imo's to 7 digits * Converts number to string, then lpads it with padString to length * @param {string} padString The character to use when padding * @param desiredLength The desired length after padding */ Number.prototype.lpad = function (padString, desiredLength) { var str = '' + this; while (str.length < desiredLength) str = padString + str; return str; }; var aivdmDecode = function (options) { if (options) { // returnJson: If true, returns json instead of an object this.returnJson = options.returnJson || false; // aivdmPassthrough: If true then the original aivdm sentences are embedded in the returned object this.aivdmPassthrough = options.aivdmPassthrough || true; // includeMID: If true then the mid (nationality) of the vessels is included in the returned object this.includeMID = options.includeMID || true; // accept_related. Passed as true to decoder when you wish static packets with accepted MMSI passed to output //this.accept_related = options.accept_related || true; // isDebug. If true, prints debug messages this.isDebug = options.isDebug || false; } else { this.returnJson = false; this.aivdmPassthrough = true; this.includeMID = true; this.isDebug = false; } this.AIVDM = ''; this.splitParts = []; // Contains aivdm's of multi part messages this.splitPart1Sequence = null; this.splitPart1Type = null; this.splitLines = []; // contains untrimmed lines of multi part messages this.numFragments = null; this.fragmentNum = null; this.seqMsgId = ''; this.binString = ''; this.partNo = null; this.channel = null; this.msgType = null; this.supportedTypes = [1,2,3,4,5,9,18,19,21,24,27]; this.char_table = [ /* 4th line would normally be: '[', '\\', ']', '^', '_', ' ', '!', '"', '#', '$', '%', '&', '\\', '(', ')', '*', '+', ',', '-','.', '/', but has been customized to eliminate most punctuation characters Last line would normally be: ':', ';', '<', '=', '>', '?' but has been customized to eliminate most punctuation characters */ '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '-', '-', '-', '_', ' ', '-', '-', '-', '-', '-', '-', '-', '(', ')', '-', '-', '-', '-', '.', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '-', '<', '-', '>', '-' ]; this.posGroups = { 1: {'lat': {'start': 89, 'length': 27, 'divisor': 600000.0}, 'lon': {'start': 61, 'length': 28, 'divisor': 600000.0}}, 2: {'lat': {'start': 89, 'length': 27, 'divisor': 600000.0}, 'lon': {'start': 61, 'length': 28, 'divisor': 600000.0}}, 3: {'lat': {'start': 89, 'length': 27, 'divisor': 600000.0}, 'lon': {'start': 61, 'length': 28, 'divisor': 600000.0}}, 4: {'lat': {'start': 107, 'length': 27, 'divisor': 600000.0}, 'lon': {'start': 79, 'length': 28, 'divisor': 600000.0}}, 9: {'lat': {'start': 89, 'length': 27, 'divisor': 600000.0}, 'lon': {'start': 61, 'length': 28, 'divisor': 600000.0}}, 18: {'lat': {'start': 85, 'length': 27, 'divisor': 600000.0}, 'lon': {'start': 57, 'length': 28, 'divisor': 600000.0}}, 19: {'lat': {'start': 85, 'length': 27, 'divisor': 600000.0}, 'lon': {'start': 57, 'length': 28, 'divisor': 600000.0}}, 21: {'lat': {'start': 192, 'length': 27, 'divisor': 600000.0}, 'lon': {'start': 164, 'length': 28, 'divisor': 600000.0}}, 27: {'lat': {'start': 62, 'length': 17, 'divisor': 600.0}, 'lon': {'start': 44, 'length': 18, 'divisor': 600.0}} }; this.speedGroups = { 1: {'start': 50, 'length': 10, 'divisor': 10}, 2: {'start': 50, 'length': 10, 'divisor': 10}, 3: {'start': 50, 'length': 10, 'divisor': 10}, 9: {'start': 50, 'length': 10, 'divisor': 1}, 18: {'start': 46, 'length': 10, 'divisor': 10}, 19: {'start': 46, 'length': 10, 'divisor': 10}, 27: {'start': 79, 'length': 6, 'divisor': 1} }; this.navStatusText = [ 'Under way using engine', 'At anchor', 'Not under command', 'Restricted manoeuverability', 'Constrained by her draught', 'Moored', 'Aground', 'Engaged in Fishing', 'Under way sailing', 'Reserved for future amendment of Navigational Status for HSC', 'Reserved for future amendment of Navigational Status for WIG', 'Reserved for future use', 'Reserved for future use', 'Reserved for future use', 'AIS-SART is active', 'Not defined' ]; this.maneuverText = [ 'Not available', 'No special maneuver', 'Special maneuver (such as regional passing arrangement' ]; this.epfdText = [ 'Undefined', 'GPS', 'GLONASS', 'Combined GPS/GLONASS', 'Loran-C', 'Chayka', 'Integrated navigation system', 'Surveyed', 'Galileo' ]; this.shiptypeText = [ "Not available", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Reserved for future use", "Wing in ground (WIG) - all ships of this type", "Wing in ground (WIG) - Hazardous category A", "Wing in ground (WIG) - Hazardous category B", "Wing in ground (WIG) - Hazardous category C", "Wing in ground (WIG) - Hazardous category D", "Wing in ground (WIG) - Reserved for future use", "Wing in ground (WIG) - Reserved for future use", "Wing in ground (WIG) - Reserved for future use", "Wing in ground (WIG) - Reserved for future use", "Wing in ground (WIG) - Reserved for future use", "Fishing", "Towing", "Towing: length exceeds 200m or breadth exceeds 25m", "Dredging or underwater ops", "Diving ops", "Military ops", "Sailing", "Pleasure Craft", "Reserved", "Reserved", "High speed craft (HSC) - all ships of this type", "High speed craft (HSC) - Hazardous category A", "High speed craft (HSC) - Hazardous category B", "High speed craft (HSC) - Hazardous category C", "High speed craft (HSC) - Hazardous category D", "High speed craft (HSC) - Reserved for future use", "High speed craft (HSC) - Reserved for future use", "High speed craft (HSC) - Reserved for future use", "High speed craft (HSC) - Reserved for future use", "High speed craft (HSC) - No additional information", "Pilot Vessel1", "Search and Rescue vessel", "Tug", "Port Tender", "Anti-pollution equipment", "Law Enforcement", "Spare - Local Vessel", "Spare - Local Vessel", "Medical Transport", "Ship according to RR Resolution No. 18", "Passenger - all ships of this type", "Passenger - Hazardous category A", "Passenger - Hazardous category B", "Passenger - Hazardous category C", "Passenger - Hazardous category D", "Passenger - Reserved for future use", "Passenger - Reserved for future use", "Passenger - Reserved for future use", "Passenger - Reserved for future use", "Passenger - No additional information", "Cargo - all ships of this type", "Cargo - Hazardous category A", "Cargo - Hazardous category B", "Cargo - Hazardous category C", "Cargo - Hazardous category D", "Cargo - Reserved for future use", "Cargo - Reserved for future use", "Cargo - Reserved for future use", "Cargo - Reserved for future use", "Cargo - No additional information", "Tanker - all ships of this type", "Tanker - Hazardous category A", "Tanker - Hazardous category B1", "Tanker - Hazardous category C1", "Tanker - Hazardous category D1", "Tanker - Reserved for future use", "Tanker - Reserved for future use", "Tanker - Reserved for future use", "Tanker - Reserved for future use", "Tanker - No additional information", "Other Type - all ships of this type", "Other Type - Hazardous category A", "Other Type - Hazardous category B", "Other Type - Hazardous category C", "Other Type - Hazardous category D", "Other Type - Reserved for future use", "Other Type - Reserved for future use", "Other Type - Reserved for future use", "Other Type - Reserved for future use", "Other Type - no additional information" ]; this.midTable = { 202: "Andorra (Principality of)", 203: "Austria", 204: "Azores - Portugal", 205: "Belgium", 206: "Belarus (Republic of)", 207: "Bulgaria (Republic of)", 208: "Vatican City State", 209: "Cyprus (Republic of)", 210: "Cyprus (Republic of)", 211: "Germany (Federal Republic of)", 212: "Cyprus (Republic of)", 213: "Georgia", 214: "Moldova (Republic of)", 215: "Malta", 216: "Armenia (Republic of)", 218: "Germany (Federal Republic of)", 219: "Denmark", 220: "Denmark", 224: "Spain", 225: "Spain", 226: "France", 227: "France", 228: "France", 229: "Malta", 230: "Finland", 231: "Faroe Islands - Denmark", 232: "United Kingdom of Great Britain and Northern Ireland", 233: "United Kingdom of Great Britain and Northern Ireland", 234: "United Kingdom of Great Britain and Northern Ireland", 235: "United Kingdom of Great Britain and Northern Ireland", 236: "Gibraltar - United Kingdom of Great Britain and Northern Ireland", 237: "Greece", 238: "Croatia (Republic of)", 239: "Greece", 240: "Greece", 241: "Greece", 242: "Morocco (Kingdom of)", 243: "Hungary", 244: "Netherlands (Kingdom of the)", 245: "Netherlands (Kingdom of the)", 246: "Netherlands (Kingdom of the)", 247: "Italy", 248: "Malta", 249: "Malta", 250: "Ireland", 251: "Iceland", 252: "Liechtenstein (Principality of)", 253: "Luxembourg", 254: "Monaco (Principality of)", 255: "Madeira - Portugal", 256: "Malta", 257: "Norway", 258: "Norway", 259: "Norway", 261: "Poland (Republic of)", 262: "Montenegro", 263: "Portugal", 264: "Romania", 265: "Sweden", 266: "Sweden", 267: "Slovak Republic", 268: "San Marino (Republic of)", 269: "Switzerland (Confederation of)", 270: "Czech Republic", 271: "Turkey", 272: "Ukraine", 273: "Russian Federation", 274: "The Former Yugoslav Republic of Macedonia", 275: "Latvia (Republic of)", 276: "Estonia (Republic of)", 277: "Lithuania (Republic of)", 278: "Slovenia (Republic of)", 279: "Serbia (Republic of)", 301: "Anguilla - United Kingdom of Great Britain and Northern Ireland", 303: "Alaska (State of) - United States of America", 304: "Antigua and Barbuda", 305: "Antigua and Barbuda", 306: "Dutch West Indies", //306: "Curaçao - Netherlands (Kingdom of the)", //306: "Sint Maarten (Dutch part) - Netherlands (Kingdom of the)", //306: "Bonaire, Sint Eustatius and Saba - Netherlands (Kingdom of the)", 307: "Aruba - Netherlands (Kingdom of the)", 308: "Bahamas (Commonwealth of the)", 309: "Bahamas (Commonwealth of the)", 310: "Bermuda - United Kingdom of Great Britain and Northern Ireland", 311: "Bahamas (Commonwealth of the)", 312: "Belize", 314: "Barbados", 316: "Canada", 319: "Cayman Islands - United Kingdom of Great Britain and Northern Ireland", 321: "Costa Rica", 323: "Cuba", 325: "Dominica (Commonwealth of)", 327: "Dominican Republic", 329: "Guadeloupe (French Department of) - France", 330: "Grenada", 331: "Greenland - Denmark", 332: "Guatemala (Republic of)", 334: "Honduras (Republic of)", 336: "Haiti (Republic of)", 338: "United States of America", 339: "Jamaica", 341: "Saint Kitts and Nevis (Federation of)", 343: "Saint Lucia", 345: "Mexico", 347: "Martinique (French Department of) - France", 348: "Montserrat - United Kingdom of Great Britain and Northern Ireland", 350: "Nicaragua", 351: "Panama (Republic of)", 352: "Panama (Republic of)", 353: "Panama (Republic of)", 354: "Panama (Republic of)", 355: "unassigned", 356: "unassigned", 357: "unassigned", 358: "Puerto Rico - United States of America", 359: "El Salvador (Republic of)", 361: "Saint Pierre and Miquelon (Territorial Collectivity of) - France", 362: "Trinidad and Tobago", 364: "Turks and Caicos Islands - United Kingdom of Great Britain and Northern Ireland", 366: "United States of America", 367: "United States of America", 368: "United States of America", 369: "United States of America", 370: "Panama (Republic of)", 371: "Panama (Republic of)", 372: "Panama (Republic of)", 373: "Panama (Republic of)", 375: "Saint Vincent and the Grenadines", 376: "Saint Vincent and the Grenadines", 377: "Saint Vincent and the Grenadines", 378: "British Virgin Islands - United Kingdom of Great Britain and Northern Ireland", 379: "United States Virgin Islands - United States of America", 401: "Afghanistan", 403: "Saudi Arabia (Kingdom of)", 405: "Bangladesh (People's Republic of)", 408: "Bahrain (Kingdom of)", 410: "Bhutan (Kingdom of)", 412: "China (People's Republic of)", 413: "China (People's Republic of)", 414: "China (People's Republic of)", 416: "Taiwan (Province of China) - China (People's Republic of)", 417: "Sri Lanka (Democratic Socialist Republic of)", 419: "India (Republic of)", 422: "Iran (Islamic Republic of)", 423: "Azerbaijan (Republic of)", 425: "Iraq (Republic of)", 428: "Israel (State of)", 431: "Japan", 432: "Japan", 434: "Turkmenistan", 436: "Kazakhstan (Republic of)", 437: "Uzbekistan (Republic of)", 438: "Jordan (Hashemite Kingdom of)", 440: "Korea (Republic of)", 441: "Korea (Republic of)", 443: "State of Palestine (In accordance with Resolution 99 Rev. Guadalajara, 2010)", 445: "Democratic People's Republic of Korea", 447: "Kuwait (State of)", 450: "Lebanon", 451: "Kyrgyz Republic", 453: "Macao (Special Administrative Region of China) - China (People's Republic of)", 455: "Maldives (Republic of)", 457: "Mongolia", 459: "Nepal (Federal Democratic Republic of)", 461: "Oman (Sultanate of)", 463: "Pakistan (Islamic Republic of)", 466: "Qatar (State of)", 468: "Syrian Arab Republic", 470: "United Arab Emirates", 472: "Tajikistan (Republic of)", 473: "Yemen (Republic of)", 475: "Yemen (Republic of)", 477: "Hong Kong (Special Administrative Region of China) - China (People's Republic of)", 478: "Bosnia and Herzegovina", 501: "Adelie Land - France", 503: "Australia", 506: "Myanmar (Union of)", 508: "Brunei Darussalam", 510: "Micronesia (Federated States of)", 511: "Palau (Republic of)", 512: "New Zealand", 514: "Cambodia (Kingdom of)", 515: "Cambodia (Kingdom of)", 516: "Christmas Island (Indian Ocean) - Australia", 518: "Cook Islands - New Zealand", 520: "Fiji (Republic of)", 523: "Cocos (Keeling) Islands - Australia", 525: "Indonesia (Republic of)", 529: "Kiribati (Republic of)", 531: "Lao People's Democratic Republic", 533: "Malaysia", 536: "Northern Mariana Islands (Commonwealth of the) - United States of America", 538: "Marshall Islands (Republic of the)", 540: "New Caledonia - France", 542: "Niue - New Zealand", 544: "Nauru (Republic of)", 546: "French Polynesia - France", 548: "Philippines (Republic of the)", 553: "Papua New Guinea", 555: "Pitcairn Island - United Kingdom of Great Britain and Northern Ireland", 557: "Solomon Islands", 559: "American Samoa - United States of America", 561: "Samoa (Independent State of)", 563: "Singapore (Republic of)", 564: "Singapore (Republic of)", 565: "Singapore (Republic of)", 566: "Singapore (Republic of)", 567: "Thailand", 570: "Tonga (Kingdom of)", 572: "Tuvalu", 574: "Viet Nam (Socialist Republic of)", 576: "Vanuatu (Republic of)", 577: "Vanuatu (Republic of)", 578: "Wallis and Futuna Islands - France", 601: "South Africa (Republic of)", 603: "Angola (Republic of)", 605: "Algeria (People's Democratic Republic of)", 607: "Saint Paul and Amsterdam Islands - France", 608: "Ascension Island - United Kingdom of Great Britain and Northern Ireland", 609: "Burundi (Republic of)", 610: "Benin (Republic of)", 611: "Botswana (Republic of)", 612: "Central African Republic", 613: "Cameroon (Republic of)", 615: "Congo (Republic of the)", 616: "Comoros (Union of the)", 617: "Cabo Verde (Republic of)", 618: "Crozet Archipelago - France", 619: "Côte d'Ivoire (Republic of)", 620: "Comoros (Union of the)", 621: "Djibouti (Republic of)", 622: "Egypt (Arab Republic of)", 624: "Ethiopia (Federal Democratic Republic of)", 625: "Eritrea", 626: "Gabonese Republic", 627: "Ghana", 629: "Gambia (Republic of the)", 630: "Guinea-Bissau (Republic of)", 631: "Equatorial Guinea (Republic of)", 632: "Guinea (Republic of)", 633: "Burkina Faso", 634: "Kenya (Republic of)", 635: "Kerguelen Islands - France", 636: "Liberia (Republic of)", 637: "Liberia (Republic of)", 638: "South Sudan (Republic of)", 642: "Libya", 644: "Lesotho (Kingdom of)", 645: "Mauritius (Republic of)", 647: "Madagascar (Republic of)", 649: "Mali (Republic of)", 650: "Mozambique (Republic of)", 654: "Mauritania (Islamic Republic of)", 655: "Malawi", 656: "Niger (Republic of the)", 657: "Nigeria (Federal Republic of)", 659: "Namibia (Republic of)", 660: "Reunion (French Department of) - France", 661: "Rwanda (Republic of)", 662: "Sudan (Republic of the)", 663: "Senegal (Republic of)", 664: "Seychelles (Republic of)", 665: "Saint Helena - United Kingdom of Great Britain and Northern Ireland", 666: "Somalia (Federal Republic of)", 667: "Sierra Leone", 668: "Sao Tome and Principe (Democratic Republic of)", 669: "Swaziland (Kingdom of)", 670: "Chad (Republic of)", 671: "Togolese Republic", 672: "Tunisia", 674: "Tanzania (United Republic of)", 675: "Uganda (Republic of)", 676: "Democratic Republic of the Congo", 677: "Tanzania (United Republic of)", 678: "Zambia (Republic of)", 679: "Zimbabwe (Republic of)", 701: "Argentine Republic", 710: "Brazil (Federative Republic of)", 720: "Bolivia (Plurinational State of)", 725: "Chile", 730: "Colombia (Republic of)", 735: "Ecuador", 740: "Falkland Islands (Malvinas) - United Kingdom of Great Britain and Northern Ireland", 745: "Guiana (French Department of) - France", 750: "Guyana", 755: "Paraguay (Republic of)", 760: "Peru", 765: "Suriname (Republic of)", 770: "Uruguay (Eastern Republic of)", 775: "Venezuela (Bolivarian Republic of)" }; this.functionMap = { "accuracy": "getAccuracy", "aid_type": "getAidType", "alt": "getAlt", "assigned": "getAssigned", "callsign": "getCallsign", "course": "getCourse", "day": "getDay", "destination": "getDestination", "dimensions": "getDimensions", "draught": "getDraught", "dte": "getDte", "epfd": "getEpfd", "fragmentNum": "getFragmentNum", "heading": "getHeading", "hour": "getHour", "imo": "getIMO", "latLon": "getLatLon", "maneuver": "getManeuver", "mid": "getMid", "mmsi": "getMMSI", "minute": "getMinute", "month": "getMonth", "name": "getName", "nameExtension": "getNameExtension", "numFragments": "getNumFragments", "off_position": "getOffPosition", "part": "getPartno", "radio": "getRadio", "raim": "getRaim", "second": "getSecond", "seqMsgId": "getSeqMsgId", "shiptype": "getShiptype", "speed": "getSpeed", "status": "getStatus", "turn": "getTurn", "type": "getType", "vendorInfo": "getVendorInfo", "virtual_aid": "getVirtualAid", "year": "getYear" }; /** * Type 6 and 8 (Binary addressed message and Binary broadcast message) contain lat/lon in some of their subtypes. * These messages are evidently only used in the St Lawrence seaway, the USG PAWSS system and the Port Authority of * london and aren't implemented in this code * * Type 17 is the Differential correction message type and is not implemented in this code * Type 22 is a channel management message and is not implemented in this code * Type 23 is a Group assignment message and is not implemented in this code */ }; /** Loads required attributes from AIVDM message for retrieval by other methods [0]=!AIVDM, [1]=Number of fragments, [2]=Fragment num, [3]=Seq msg ID, [4]=channel, [5]=payload, Fetch the AIVDM part of the line, from !AIVDM to the end of the line Split the line into fragments, delimited by commas fetch numFragments, fragmentNum and SeqMsgId (SeqMsgId may be empty) convert to a binary 6 bit string : param (string) line. The received message within which we hope an AIVDM statement exists :returns True if message is a single packet msg (1,2,3,9,18,27 etc) or part 1 of a multi_part message False if !AIVDM not in the line or exception during decode process */ aivdmDecode.prototype = { /** * getData(aivdm) * Decodes message, then returns an object containing extracted data * If the message is received in two parts (i.e. type 5 and 19) then * the return for the first of the messages is null. When the second part has been received then it * is combined with the first and decoded. * Whether a single or two part message, the return will contain the original message(s) in an array called 'aivdm' */ getData: function (line) { var lineData = { numFragments: this.numFragments, fragmentNum: this.fragmentNum, type: this.getType(), mmsi: this.getMMSI(), mid: this.getMid(), seqMsgId: this.getSeqMsgId(), aivdm: this.splitLines }; return this.msgTypeSwitcher(line, lineData); }, /** * msgTypeSwitcher * Used only by getData * Fills fields relevant to the message type * @param line The !AIVD string * @param lineData The partially filled lineData object * @returns {*} lineData object or false (if lineData is not filled */ msgTypeSwitcher: function (line, lineData) { switch (this.getType()) { // Implemented message types case 1: case 2: case 3: lineData = this.fill_1_2_3(line, lineData); break; case 4: lineData = this.fill_4(line, lineData); break; case 5: lineData = this.fill_5(line, lineData); break; case 9: lineData = this.fill_9(line, lineData); break; case 18: lineData = this.fill_18(line, lineData); break; case 19: lineData = this.fill_19(line, lineData); break; case 21: lineData = this.fill_21(line, lineData); break; case 24: lineData.partno = this.getPartno(); if (lineData.partno === 'A') { lineData = this.fill_24_0(line, lineData); } else if (lineData.partno === 'B') { lineData = this.fill_24_1(line, lineData); } break; case 27: lineData = this.fill_27(line, lineData); break; // unimplemented message types case 6: case 7: case 8: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 20: case 22: case 23: case 25: case 26: if (module.parent && module.parent.exports.isDebug) { //if (swu.hasProp(module, 'parent.exports.isDebug')) { console.log('Message type (switch) %d', parseInt(this.binString.substr(0, 6), 2)); console.log(line); console.log('-------------------------------------------------------'); } lineData = false; break; default: if (module.parent && module.parent.exports.isDebug) { //if (swu.hasProp(module, 'prent.exports.isDebug')) { console.log('Message type ????? %d ?????', parseInt(this.binString.substr(0, 6), 2)); } lineData = false; } if (lineData) { if (this.returnJson) { return JSON.stringify(lineData); } else { return lineData; } } else { return false; } }, fill_1_2_3: function (line, lineData) { var latLon = this.getLatLon(); var status = this.getStatus(); var maneuver = this.getManeuver(); if (this.aivdmPassthrough) { lineData.aivdm = [line]; } lineData.status = status.status_num; lineData.status_text = status.status_text; lineData.turn = this.getTurn(); lineData.speed = this.getSpeed(); lineData.accuracy = this.getAccuracy(); lineData.lon = latLon.lon; lineData.lat = latLon.lat; lineData.course = this.getCourse(); lineData.heading = this.getHeading(); lineData.second = this.getSecond(); lineData.maneuver = maneuver.maneuver; lineData.maneuver_text = maneuver.maneuver_text; lineData.raim = this.getRaim(); lineData.radio = this.getRadio(); return lineData; }, fill_4: function (line, lineData) { var latLon = this.getLatLon(); var epfd = this.getEpfd(); if (this.aivdmPassthrough) { lineData.aivdm = [line]; } lineData.year = this.getYear(); lineData.month = this.getMonth(); lineData.day = this.getDay(); lineData.hour = this.getHour(); lineData.minute = this.getMinute(); lineData.second = this.getSecond(); lineData.accuracy = this.getAccuracy(); lineData.lon = latLon.lon; lineData.lat = latLon.lat; lineData.epfd = epfd.epfd; lineData.epfd_text = epfd.epfd_text; lineData.raim = this.getRaim(); lineData.radio = this.getRadio(); return lineData; }, fill_5: function (line, lineData) { var dimensions = this.getDimensions(); var epfd = this.getEpfd(); var shiptype = this.getShiptype(); var eta = sprintf( '%s-%sT%s:%sZ', this.getMonth().lpad('0', 2), this.getDay().lpad('0', 2), this.getHour().lpad('0', 2), this.getMinute().lpad('0', 2) ); //if (this.aivdmPassthrough) { lineData.aivdm = this.splitLines; } //if (this.aivdmPassthrough) { lineData.aivdm = this.splitParts; } lineData.imo = this.getIMO(); lineData.callsign = this.getCallsign(); lineData.shipname = this.getName(); lineData.shiptype = shiptype.shiptype; lineData.shiptype_text = shiptype.shiptype_text; lineData.to_bow = dimensions.to_bow; lineData.to_stern = dimensions.to_stern; lineData.to_port = dimensions.to_port; lineData.to_starboard = dimensions.to_starboard; lineData.epfd = epfd.epfd; lineData.eta = eta; lineData.epfd_text = epfd.epfd.text; lineData.month = this.getMonth(); lineData.day = this.getDay(); lineData.hour = this.getHour(); lineData.minute = this.getMinute(); lineData.draught = this.getDraught(); lineData.destination = this.getDestination(); lineData.dte = this.getDte(); return lineData; }, fill_9: function (line, lineData) { var latLon = this.getLatLon(); if (this.aivdmPassthrough) { lineData.aivdm = [line]; } lineData.alt = this.getAlt(); lineData.speed = this.getSpeed(); lineData.accuracy = this.getAccuracy(); lineData.lon = latLon.lon; lineData.lat = latLon.lat; lineData.course = this.getCourse(); lineData.second = this.getSecond(); lineData.assigned = this.getAssigned(); lineData.raim = this.getRaim(); lineData.radio = this.getRadio(); return lineData; }, fill_18: function (line, lineData) { var latLon = this.getLatLon(); if (this.aivdmPassthrough) { lineData.aivdm = [line]; } lineData.speed = this.getSpeed(); lineData.accuracy = this.getAccuracy(); lineData.lon = latLon.lon; lineData.lat = latLon.lat; lineData.course = this.getCourse(); lineData.heading = this.getHeading(); lineData.second = this.getSecond(); lineData.raim = this.getRaim(); lineData.radio = this.getRadio(); return lineData; }, fill_19: function (line, lineData) { var latLon = this.getLatLon(); var dimensions = this.getDimensions(); var epfd = this.getEpfd(); var shiptype = this.getShiptype(); if (this.aivdmPassthrough) { lineData.aivdm = [line]; } lineData.speed = this.getSpeed(); lineData.accuracy = this.getAccuracy(); lineData.lon = latLon.lon; lineData.lat = latLon.lat; lineData.course = this.getCourse(); lineData.heading = this.getHeading(); lineData.second = this.getSecond(); lineData.shipname = this.getName(); lineData.shiptype = shiptype.shiptype; lineData.shiptype_text = shiptype.shiptype_text; lineData.to_bow = dimensions.to_bow; lineData.to_stern = dimensions.to_stern; lineData.to_port = dimensions.to_port; lineData.to_starboard = dimensions.to_starboard; lineData.epfd = epfd.epfd; lineData.epfd_text = epfd.epfd_text; lineData.raim = this.getRaim(); return lineData; }, fill_21: function (line, lineData) { var latLon = this.getLatLon(); var dimensions = this.getDimensions(); var epfd = this.getEpfd(); if (this.aivdmPassthrough) { lineData.aivdm = [line]; } lineData.aid_type = this.getAidType(); lineData.name = this.getName(); lineData.accuracy = this.getAccuracy(); lineData.lon = latLon.lon; lineData.lat = latLon.lat; lineData.to_bow = dimensions.to_bow; lineData.to_stern = dimensions.to_stern; lineData.to_port = dimensions.to_port; lineData.to_starboard = dimensions.to_starboard; lineData.epfd = epfd.epfd; lineData.epfd_text = epfd.epfd_text; lineData.second = this.getSecond(); lineData.off_position = this.getOffPosition(); lineData.raim = this.getRaim(); lineData.virtual_aid = this.getVirtualAid(); lineData.assigned = this.getAssigned(); lineData.name += this.getNameExtension(); return lineData; }, fill_24_0: function (line, lineData) { if (this.aivdmPassthrough) { lineData.aivdm = [line]; } lineData.part = this.getPartno(); lineData.shipname = this.getName(); return lineData; }, fill_24_1: function (line, lineData) { var dimensions; var vendorInfo = this.getVendorInfo(); var shiptype = this.getShiptype(); if (this.aivdmPassthrough) { lineData.aivdm = [line]; } lineData.part = this.getPartno(); lineData.shiptype = shiptype.shiptype; lineData.shiptype_text = shiptype.shiptype_text; lineData.callsign = this.getCallsign(); if (lineData.mmsi.toString().substr(0, 2) === '98') { // Then this is an auxiliary craft (see AIVDM Docs) lineData.mothership_mmsi = this.getBits(132, 30); dimensions = {to_bow: null, to_stern: null, to_port: null, to_starboard: null}; } else { lineData.mothership_mmsi = null; dimensions = this.getDimensions(); } lineData.vendorid = vendorInfo.vendorString; lineData.model = vendorInfo.model; lineData.serial = vendorInfo.serial; lineData.to_bow = dimensions.to_bow; lineData.to_stern = dimensions.to_stern; lineData.to_port = dimensions.to_port; lineData.to_starboard = dimensions.to_starboard; return lineData; }, fill_27: function (line, lineData) { var latLon = this.getLatLon(); var status = this.getStatus(); if (this.aivdmPassthrough) { lineData.aivdm = [line]; } lineData.accuracy = this.getAccuracy(); lineData.raim = this.getRaim(); lineData.status = status.status_num; lineData.status_text = status.status_text; lineData.lon = latLon.lon; lineData.lat = latLon.lat; lineData.speed = this.getSpeed(); lineData.course = this.getCourse(); return lineData; }, // ------------------------------- /** * getAccuracy() * @returns {boolean} false if 0, else true - to synchronise with how gpsd handles it */ getAccuracy: function () { switch (this.msgType) { case 1: case 2: case 3: case 9: return this.getBits(60, 1) !== 0; case 18: case 19: return this.getBits(56, 1) !== 0; case 21: return this.getBits(163, 1) !== 0; case 27: return this.getBits(38, 1) !== 0; default: return false; } }, getAidType: function () { return this.getBits(38,5); }, getAlt: function () { return this.getBits(38, 12); }, getAssigned: function () { switch (this.msgType) { case 9: return this.getBits(146, 1); case 21: return this.getBits(270, 1); default: return false; } }, getCallsign: function () { var callsignField; switch (this.msgType) { case 5: callsignField = this.binString.substr(70, 42); break; case 24: if (this.partNo == 1) { callsignField = this.binString.substr(90, 42); } else { callsignField = null; } break; default: callsignField = null } if (callsignField) { var callsignArray = callsignField.match(/.{1,6}/g); var callsign = ''; var self = this; _.each(callsignArray, function (binChar, index) { callsign += self.char_table[parseInt(binChar, 2)]; }); return callsign.replace(/@/g, '').trim(); } else { return false; } }, getCourse: function () { switch (this.msgType) { case 1: case 2: case 3: case 9: return this.getBits(116, 12) / 10; break; case 18: case 19: return this.getBits(112, 12) / 10; break; case 27: return this.getBits(85, 9); break; default: return false; } }, getDay: function () { switch (this.msgType) { case 4: return this.getBits(56, 5); case 5: return this.getBits(278, 5); default: return false; } }, getDestination: function () { var destField = null; switch (this.msgType) { case 5: destField = this.binString.substr(302, 120); break; default: destField = null } if (destField) { var destArray = destField.match(/.{1,6}/g); var destination = ''; var self = this; _.each(destArray, function (binChar, index) { destination += self.char_table[parseInt(binChar, 2)]; }); return destination.replace(/@/g, '').trim(); } else { return false; } }, getDimensions: function () { var dimensions = {to_bow: null, to_stern: null, to_port: null, to_starboard: null}; switch (this.msgType) { case 5: dimensions.to_bow = this.getBits(240, 9); dimensions.to_stern = this.getBits(249, 9); dimensions.to_port = this.getBits(258, 6); dimensions.to_starboard = this.getBits(264, 6); break; case 19: dimensions.to_bow = this.getBits(271, 9); dimensions.to_stern = this.getBits(280, 9); dimensions.to_port = this.getBits(289, 6); dimensions.to_starboard = this.getBits(295, 6); break; case 21: dimensions.to_bow = this.getBits(219, 9); dimensions.to_stern = this.getBits(228, 9); dimensions.to_port = this.getBits(237, 6); dimensions.to_starboard = this.getBits(243, 6); break; case 24: dimensions.to_bow = this.getBits(132, 9); dimensions.to_stern = this.getBits(141, 9); dimensions.to_port = this.getBits(150, 6); dimensions.to_starboard = this.getBits(156, 6); break; } return dimensions; }, getDraught: function () { switch (this.msgType) { case 5: return this.getBits(294, 8) / 10; default: return 0; } }, getDte: function () { switch (this.msgType) { case 5: return this.getBits(423, 1); default: return 0; } }, getETA: function () { }, getEpfd: function () { var epfd; switch (this.msgType) { case 4: epfd = this.getBits(134, 4); break; case 5: epfd = this.getBits(270, 4); break; case 19: epfd = this.getBits(310, 4); break; case 21: epfd = this.getBits(249, 4); break; default: epfd = 0; } if (epfd < 0 || epfd > 8) { epfd = 0; } return {epfd: epfd, epfd_text: this.epfdText[epfd]} }, getFragmentNum: function getFragmentNum () { return this.fragmentNum; }, getHeading: function () { switch (this.msgType) { case 1: case 2: case 3: return this.getBits(128, 9); case 18: case 19: return this.getBits(124, 9); default: return false; } }, getHour: function () { switch (this.msgType) { case 4: return this.getBits(61, 5); case 5: return this.getBits(283, 5); default: return false; } }, getIMO: function () { switch (this.msgType) { case 5: return this.getBits(40, 30); default: return false; } }, getLatLon: function () { // Does this message contain position info? var msgType = this.getType(); if (msgType in this.posGroups) { var latGroup = this.posGroups[msgType]['lat']; var lonGroup = this.posGroups[msgType]['lon']; // fetch the relevant bits var latString = this.binString.substr(latGroup['start'], latGroup['length']); var lonString = this.binString.substr(lonGroup['start'], lonGroup['length']); // convert them var lat = this.toTwosComplement(parseInt(latString, 2), latString.length) / latGroup['divisor']; var lon = this.toTwosComplement(parseInt(lonString, 2), lonString.length) / lonGroup['divisor']; return {"lat": parseFloat(lat.toFixed(4)), "lon": parseFloat(lon.toFixed(4))}; } else { // Not a message type that contains a position return {'lat': null, 'lon': null}; } }, getManeuver: function () { var man, maneuver_text; switch (this.msgType) { case 1: case 2: case 3: man = this.getBits(143, 2); break; default: man = 0; } if (man < 1 || man > 2) { man = 0; } maneuver_text = this.maneuverText[man]; return {maneuver: man, maneuver_text: maneuver_text}; }, /** * getMid() Fetched 3 digit MID number that is embedded in MMSI * The mid usually occupies chars 0,1 and 2 of the MMSI string * For some special cases it may be at another location (see below). * Uses this.midTable to look up nationality. * Returns "" unless the option 'includeMID' is set true in the aivdmDecode constructor options * @returns {string} mid - a string containing 3 numeric digits. */ getMid: function () { // See info in http://catb.org/gpsd/AIVDM.html if (this.includeMID) { var mid; var mmsi = this.getMMSI(); var nationality; if (mmsi !== null && mmsi.length === 9) { // Coastal station if (mmsi.substr(0, 2) == "00") { mid = mmsi.substr(2, 3); } // Group of ships (i.e. coast guard is 0369 else if (mmsi.substr(0, 1) === "0") { mid = mmsi.substr(1, 3); } // SAR Aircraft else if (mmsi.substr(0, 3) === "111") { mid = mmsi.substr(3, 3); } // Aus craft associated with a parent ship else if (mmsi.substr(0, 2) === "98" || mmsi.substr(0, 2) === "99") { mid = mmsi.substr(2, 3); } // AIS SART else if (mmsi.substr(0, 3) === "970") { mid = mmsi.substr(3, 3); } // MOB device (972) or EPIRB (974). Neither of these have a MID else if (mmsi.substr(0, 3) === "972" || mmsi.substr(0, 3) === "974") { mid = ""; } // Normal ship transponder else { mid = mmsi.substr(0, 3); } if (mid !== "") { nationality = this.midTable[mid]; if (nationality !== undefined) { if (typeof(nationality) !== 'string') { nationality = ""; } } else { nationality = ""; } } else { nationality = ""; } } else { nationality = ""; } } else { nationality = ""; } return nationality; }, getMMSI: function (/* onlyValidMid */) { //TODO: onlyValidMid to be implemented later return this.getBits(8, 30); }, getMinute: function () { switch (this.msgType) { case 4: return this.getBits(66, 6); case 5: return this.getBits(288, 6); default: return false; } }, getMonth: function () { switch (this.msgType) { case 4: return this.getBits(53, 4); case 5: return this.getBits(274, 4); default: return false; } }, getName: function () { var msgType = this.getType(); var nameField = null; switch (msgType) { case 5: nameField = this.binString.substr(112, 120); break; case 19: nameField = this.binString.substr(143, 120); break; case 21: nameField = this.binString.substr(43, 120); break; case 24: nameField = this.binString.substr(40, 120); break; default: nameField = null } if (nameField) { var nameArray = nameField.match(/.{1,6}/g); var name = ''; var self = this; _.each(nameArray, function (binChar, index) { name += self.char_table[parseInt(binChar, 2)]; }); return name.replace(/@/g, '').trim(); } else { return false; } }, getNameExtension: function () { switch (this.msgType) { case 21: if (this.binString.length >= 272) { var nameBits = this.binString.substring(272, this.binString.length -1); var nameArray = nameBits.match(/.{1,6}/g); var name = ''; var self = this; _.each(nameArray, function (binChar, index) { name += self.char_table[parseInt(binChar, 2)]; }); return name.replace(/@/g, '').trim(); } else { return ''; } break; default: return false; } }, getNumFragments: function getNumFragments () { return this.numFragments; }, getOffPosition: function () { return this.getBits(259, 1); }, getPartno: function () { switch (this.msgType) { case 24: var partRaw = parseInt(this.getBits(38, 2), 2); var partNo = partRaw === 0 ? 'A' : 'B'; return partNo; default: return ''; } }, getRadio: function () { switch (this.msgType) { case 1: case 2: case 3: return this.getBits(149, 19); case 9: case 18: return this.getBits(148, 19); default: return false; } }, getRaim: function () { switch (this.msgType) { case 1: case 2: case 3: return this.getBits(148, 1) !== 0; case 9: case 18: return this.getBits(147, 1) !== 0; case 19: return this.getBits(305, 1) !== 0; case 21: return this.getBits(268, 1) !== 0; case 27: return this.getBits(39, 1) !== 0; default: return false; } }, getSecond: function () { switch (this.msgType) { case 1: case 2: case 3: return this.getBits(137, 6); case 9: return this.getBits(128, 6); case 18: case 19: return this.getBits(133, 6); case 21: return this.getBits(253, 6); default: return false; } }, getSeqMsgId: function () { return this.seqMsgId; }, getShiptype: function () { var sType; switch (this.msgType) { case 5: sType = this.getBits(232, 8); break; case 19: sType = this.getBits(263, 8); break; case 24: sType = this.getBits(40, 8); break; default: sType = 0; } if (sType < 0 || sType > 99) { sType = 0; } return {shiptype: sType, shiptype_text: this.shiptypeText[sType]}; }, getSpeed: function () { if (this.numFragments == 1) { var msgType = this.getType(); if (msgType in this.speedGroups) { var group = this.speedGroups[msgType]; var speedString = this.binString.substr(group['start'], group['length']); return parseInt(speedString, 2) / group['divisor']; } else { return false; } } else { return false; } }, getStatus: function () { var statusText = "", statusNum = -1; switch (this.msgType) { case 1: case 2: case 3: statusNum = this.getBits(38, 4); break; case 27: statusNum = this.getBits(40, 4); break; } if (statusNum >= 0 && statusNum <= 15) { statusText = this.navStatusText[statusNum]; } // status_num coerced to string to match gpsdecode / gpsd return {status_num: '' + statusNum, status_text: statusText} }, /** * getTurn() Called only for types 1,2 and 3 * @returns {null} */ getTurn: function () { var turn = this.getBits(42, 8); switch (true) { case turn === 0: break; case turn > 0 && turn <= 126: return '' + (4.733 * Math.sqrt(turn)); case turn === 127: return 'fastright'; case turn < 0 && turn >= -126: return '' + (4.733 * Math.sqrt(turn)); case turn === -127: return 'fastleft'; case turn == 128 || turn == -128: return "nan"; default: return "nan"; } }, getType: function () { return this.getBits(0,6); }, getVendorInfo: function () { var vendorBits, vendorArray, vendorString, model, serial; switch (this.msgType) { case 24: vendorBits = this.binString.substr(48, 38); vendorArray = vendorBits.match(/.{1,6}/g); vendorString = ''; var self = this; _.each(vendorArray, function (binChar, index) { vendorString += self.char_table[parseInt(binChar, 2)]; }); vendorString = vendorString.replace(/@/g, '').trim(); model = parseInt(this.binString.substr(66, 4), 2); serial = parseInt(this.binString.substr(70, 20), 2); return {vendorString: vendorString, model: model, serial: serial}; } }, /** * getVendorID not currently implemented * @returns {*} */ getVendorID: function () { var msgType = this.getType(); var vendorID = null; switch (msgType) { case 24: vendorID = this.binString.substr(48, 18); break; default: vendorID = null } if (vendorID) { var vendorIDArray = vendorID.match(/.{1,6}/g); var vid = ''; var self = this; _.each(vendorIDArray, function (binChar, index) { vid += self.char_table[parseInt(binChar, 2)]; }); return vid.replace(/@/g, '').trim(); } else { return false; } }, getVirtualAid: function () { return this.getBits(269, 1); }, getYear: function () { switch (this.msgType) { case 4: return this.getBits(38, 14); default: return false; } }, // --------------------------------------- /** * manageFragments * makes aivdm sentences ready for data fetching by using buildBinString to convert them to a binary string * Returns true when a message is ready for data to be fetched. * For single part messages this is after processing of the aivdm payload * For multi part messages the payloads are accumulated until all have been received, then the binString * conversion is done. * For multi part messages returns false for the first and any intermediate messages * @param line A string containing an AIVDM or AIVDO sentence. May have a tag block on the front of the msg * @param payload The payload portion of the AIVD? string * @returns {boolean} true when this.binString has been set, false when this.binString is not set */ manageFragments: function (line, payload) { // this.splitParts is an array of payloads that are joined to become the binString of multi msgs // this.splitLines is an array of the received lines including AIVDM's if (this.numFragments === 1) { this.splitLines = [line]; this.binString = this.buildBinString(payload); this.msgType = this.getType(); return true; } else if (this.numFragments > 1 && this.fragmentNum === 1) { this.splitParts = [payload]; this.splitLines = [line]; this.splitPart1Sequence = this.seqMsgId; this.binString = this.buildBinString(payload); this.splitPart1Type = this.getType(); this.msgType = this.getType(); return false; } else if (this.numFragments > 1 && this.fragmentNum > 1) { if (this.seqMsgId === this.splitPart1Sequence) { this.splitParts.push(payload); this.splitLines.push(line); } } if (this.fragmentNum === this.numFragments) { var parts = this.splitParts.join(''); this.binString = this.buildBinString(parts); this.msgType = this.splitPart1Type; return true; } else { return false; } }, /** * decode * @param line A line containing an !AIVD sentence * @returns {boolean} true if this.binString has been set (ready for data to be fetched * false if: * binString not set, * line is not an !AIVD * !AIVD is not a supported type (see this.supportedTypes) */ decode: function (bLine) { var line = bLine.toString('utf8'); var aivdmPos = line.indexOf('!AIVD'); if (aivdmPos !== -1) { this.AIVDM = line.substr(aivdmPos); var aivdmFragments = this.AIVDM.split(','); this.numFragments = parseInt(aivdmFragments[1]); this.fragmentNum = parseInt(aivdmFragments[2]); try { this.seqMsgId = parseInt(aivdmFragments[3]); if (typeof(this.seqMsgId) !== 'number') { this.seqMsgId = ''; } } catch (err) { this.seqMsgId = ''; } this.channel = aivdmFragments[4]; var payload = aivdmFragments[5]; if (this.manageFragments(line, payload)) { if (_.contains(this.supportedTypes, this.msgType)) { this.msgType = this.getType(); if (this.msgType == 24) { this.partNo = this.getBits(38, 2) } return this.getData(bLine); //return true; // this.binString is ready } else { return false; } } else { // this.binString is not ready return false; } } else { // no !AIVD on front of line return false; } }, buildBinString: function (payload) { var binStr = ''; var payloadArr = payload.split(""); _.each(payloadArr, function (value) { var dec = value.charCodeAt(0); var bit8 = dec - 48; if (bit8 > 40) { bit8 -= 8; } var strBin = bit8.toString(2); strBin = sprintf('%06s', strBin); binStr += strBin; }); if (module.parent && module.parent.exports.isDebug) { //if (swu.hasProp(module, 'parent.exports.isDebug')) { console.log('binString for type ', parseInt(binStr.substr(0, 6), 2), payload, binStr); } return binStr; }, getBits: function (start, len) { return parseInt(this.binString.substr(start, len), 2); }, asciidec_2_8bit: function (dec) { var newDec = dec - 48; if (newDec > 40) { newDec -= 8; } return newDec; }, dec_2_6bit: function (bit8) { var strBin = bit8.toString(2); strBin = sprintf('%06s', strBin); return strBin; }, toTwosComplement: function (val, bits) { if ((val & (1 << (bits - 1))) != 0) { val -= 1 << bits; } return val; } }; module.exports = { aivdmDecode: aivdmDecode }; if (require.main === module) { var SW_utilsModule = require('SW_utils'); SW_utils = new SW_utilsModule.SW_Utils('aivdmDecode', false); /** * testSet * An array of objects. Each object contains: * aivdm: The raw aivdm sentence to be decoded * gpsd: aivdm as decoded by gpsdecode * test: The fields within the decoded aivdm to test * @type {*[]} */ var testSet = [ // type 5 first msg {aivdm: '!AIVDM,2,1,4,A,539cRCP00000@7WSON08:3?V222222222222221@4@=3340Ht50000000000,0*13', gpsd: '' }, // type 5 second msg {aivdm: '!AIVDM,2,2,4,A,00000000000,2*20', gpsd: {"class":"AIS","device":"stdin","type":5,"repeat":0,"mmsi":211477070,"scaled":true,"imo":0,"ais_version":0,"callsign":"DA9877 ","shipname":"BB 39","shiptype":80,"shiptype_text":"Tanker - all ships of this type","to_bow":34,"to_stern":13,"to_port":3,"to_starboard":3,"epfd":1,"epfd_text":"GPS","eta":"00-00T24:60Z","draught":2.0,"destination":"","dte":0}, test: ['type', 'mmsi', 'imo', 'callsign', 'shipname', 'shiptype', 'shiptype_text', 'to_bow', 'to_stern', 'to_port', 'to_starboard', 'epfd', 'eta', 'draught', 'destination', 'dte'] }, // type 1 {aivdm: '!AIVDM,1,1,,A,144iRPgP001N;PjOb:@F1?vj0PSB,0*47', gpsd: {"class":"AIS","device":"stdin","type":1,"repeat":0,"mmsi":273441410,"scaled":true,"status":"15","status_text":"Not defined","turn":"nan","speed":0.0,"accuracy":false,"lon":20.5739,"lat":55.3277,"course":154.0,"heading":511,"second":25,"maneuver":0,"raim":false,"radio":133330}, test: ['type', 'mmsi', 'status', 'status_text','turn', 'speed', 'accuracy', 'lon', 'lat', 'course', 'heading', 'second', 'maneuver', 'raim', 'radio'] }, // type 3 {aivdm: '!AIVDM,1,1,,A,33aTCJ0Oh;8>Q>7kW>eKwaf6010P,0*63', gpsd: {"class":"AIS","device":"stdin","type":3,"repeat":0,"mmsi":244913000,"scaled":true,"status":"0","status_text":"Under way using engine","turn":"fastright","speed":1.1,"accuracy":false,"lon":115.0198,"lat":-21.6479,"course":307.0,"heading":311,"second":3,"maneuver":0,"raim":false,"radio":4128}, test: ['type', 'mmsi', 'status', 'status_text', 'turn', 'speed', 'accuracy', 'lon', 'lat', 'course', 'heading', 'second', 'maneuver', 'raim', 'radio'] }, // type 9 {aivdm: "!AIVDM,1,1,,A,97oordNF>hPppq5af003QHi0S7sE,0*52", gpsd: { "class": "AIS", "device": "stdin", "type": 9, "repeat": 0, "mmsi": 528349873, "scaled": true, "alt": 3672, "speed": 944, "accuracy": true, "lon": 12.4276, "lat": -38.9393, "course": 90.1, "second": 35, "regional": 16, "dte": 0, "raim": false, "radio": 818901 }, test: ['type', 'mmsi', 'speed', 'lon', 'lat'] }, // type 24 {aivdm: '!AIVDM,1,1,,B,H7OeD@QLE=A<D63:22222222220,2*25', gpsd: {"class":"AIS","device":"stdin","type":24,"repeat":0,"mmsi":503010370,"scaled":true,"part":"A","shipname":"WESTSEA 2"}, test: ['type', 'mmsi', 'part', 'shipname'] }, //type 24 part A {aivdm: '!AIVDM,1,1,,A,H697GjPhT4t@4qUF3;G;?F22220,2*7E', gpsd: {"class":"AIS","device":"stdin","type":24,"repeat":0,"mmsi":412211146,"scaled":true,"part":"A","shipname":"LIAODANYU 25235"}, test: ['type', 'mmsi', 'part', 'shipname'] }, // type 24 part B {aivdm: '!AIVDM,1,1,,B,H3mw=<TT@B?>1F0<7kplk01H1120,0*5D', gpsd: {"class":"AIS","device":"stdin","type":24,"repeat":0,"mmsi":257936690,"scaled":true,"part":"B","shiptype":36,"shiptype_text":"Sailing","vendorid":"PRONAV","model":3,"serial":529792,"callsign":"LG3843","to_bow":11,"to_stern":1,"to_port":1,"to_starboard":2}, test: ['type', 'mmsi', 'part', 'shiptype', 'shiptype_text', 'vendorid', 'model', 'serial', 'callsign', 'to_bow', 'to_stern', 'to_port', 'to_starboard'] } ]; var aisDecoder = new aivdmDecode({returnJson: false, aivdmPassthrough: true}); _.each(testSet, function (val, index) { var decoded = aisDecoder.decode(val.aivdm); if (decoded) { var testSubject = aisDecoder.getData(val.aivdm); console.log(colors.cyan('Test subject ' + index)); if (testSubject && testSubject.type) { //if (swu.hasProp(testSubject, 'type')) { console.log(colors.cyan('Type: ' + testSubject.type)); } if (val.gpsd.part) { console.log(sprintf(colors.cyan('Part %s'), val.gpsd.part)); } if (val.test) { _.each(val.test, function (item) { console.log('Testing: ' + item); // test for undefined item in testSubject if (testSubject[item] === undefined) { console.log(colors.red('Item missing ' + item)); return; } // test that both items are the same type else if (typeof(val.gpsd[item]) !== typeof(testSubject[item])) { console.log(colors.red('Type mismatch: gpsd: ' + typeof(val.gpsd[item]) + ' me: ' + typeof(testSubject[item]))); return; } // if gpsd is int then testSubject should also be int else if (SW_utils.isInt(val.gpsd[item])) { if (!SW_utils.isInt(testSubject[item])) { console.log(colors.red('Type mismatch (gpsd int testsubject float')); return; } // if gpsd is float then testSubject should also be float } else if (SW_utils.isFloat(val.gpsd[item])) { if (!SW_utils.isFloat(testSubject[item])) { console.log(colors.red('Type mismatch (gpsd float testsubject int')); return } } // finally, test items for equality if (typeof(val.gpsd[item]) === 'string') { gItem = val.gpsd[item].trim(); tItem = testSubject[item].trim(); } else { gItem = val.gpsd[item]; tItem = testSubject[item]; } if (gItem === tItem) { console.log( sprintf(colors.yellow('Test ok gpsd: %s'), gItem) + sprintf(colors.cyan(' me: %s'), tItem) ); } else { console.log(colors.red('Test failed')); console.log(colors.red('gpsd: ' + val.gpsd[item] + ' me: ' + testSubject[item])) } }) } } if (this.isDebug) { console.log(colors.magenta('----------------------------------------------------------')); } }); }
Royhb/aivdmDecode
bin/aivdmDecode.js
JavaScript
mit
69,382