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
|
---|---|---|---|---|---|
<?php
namespace spec\Genesis\API\Constants\Transaction;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class StatesSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('Genesis\API\Constants\Transaction\States');
}
}
| dev018/testrepo | spec/Genesis/API/Constants/Transaction/StatesSpec.php | PHP | mit | 276 |
# Injections
Injections are simply other classes that are included in our component tree.
In our example we have `Store` and `Router` injections.
Take a look at our `Store`.
```ruby
class Store
include Inesita::Injection
attr_accessor :counter
def init
@counter = 0
end
def increase
@counter += 1
end
def decrease
@counter -= 1
end
end
```
This is an `injection` example. We are including `Inesita::Injection` in order to be able to inject this class into the root component.
In this example, we're storing counter value.
The `init` method initializes our store. At the beginning we're setting the counter value to 0.
The `increase` method increments current counter value by 1
The `decrease` method decrements current counter value by 1
There is also `attr_accessor :counter` so we can access that value with `store.counter`.
Simple! Right?
You can inject other stores, but also things like dispatchers depending on the architecture you want to obtain.
| inesita-rb/documentation | source/includes/_injections.md | Markdown | mit | 997 |
<div class="row-fluid">{namespace ehrm=Beech\Ehrm\ViewHelpers}
<div class="span1">
<f:render partial="Forms/Buttons/Icon" arguments="{_all}"/>
</div>
<div class="span3"><strong><f:translate id="electronicAddress.electronicAddressType.{electronicAddress.electronicAddressType}">{electronicAddress.electronicAddressType}</f:translate></strong></div>
<div class="span6">{electronicAddress.address}</div>
<div class="span1 primaryIcon"><f:if condition="{electronicAddress.primary}"><i class="icon-check"></i></f:if></div>
<div class="span1">
<div class="btn-group">
<f:render partial="Forms/Buttons/Toggle" arguments="{identifier: electronicAddress.id, action: action, icon: 'icon-pencil', collapsed: collapsed}"/>
<f:if condition="{electronicAddress.primary}">
<f:then>
<f:render partial="Forms/Buttons/Remove" arguments="{class: 'hide'}"/>
</f:then>
<f:else>
<f:render partial="Forms/Buttons/Remove" arguments="{_all}"/>
</f:else>
</f:if>
</div>
</div>
</div> | beechit/MisterMaks-EHRM | Packages/Beech/Beech.Party/Resources/Private/Partials/Views/List/ElectronicAddress.html | HTML | mit | 1,005 |
๏ปฟ// -----------------------------------------------------------------------
// <copyright file="ViewModel.cs" company="Screenmedia">
// Copyright (c) Screenmedia 2018. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------
namespace VanillaSample.Core.ViewModels
{
using Screenmedia.Plugin.Vanilla;
using Screenmedia.Plugin.Vanilla.Abstractions;
public class ViewModel
{
private readonly IIceCreamMachine _iceCreamMachine;
public ViewModel()
{
_iceCreamMachine = CrossIceCreamMachine.Current;
IceCreamFlavour = _iceCreamMachine.Dispense();
}
public string IceCreamFlavour { get; set; } = "Empty Cone";
}
}
| Screenmedia/Plugin.Vanilla | samples/VanillaSample/VanillaSample.Core/ViewModels/ViewModel.cs | C# | mit | 759 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0-beta2) on Mon Mar 19 19:33:09 CST 2007 -->
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>
่ฝฏไปถๅ
org.w3c.dom.bootstrap ็ไฝฟ็จ (Java Platform SE 6)
</TITLE><script>var _hmt = _hmt || [];(function() {var hm = document.createElement("script");hm.src = "//hm.baidu.com/hm.js?dd1361ca20a10cc161e72d4bc4fef6df";var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(hm, s);})();</script>
<META NAME="date" CONTENT="2007-03-19">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="่ฝฏไปถๅ
org.w3c.dom.bootstrap ็ไฝฟ็จ (Java Platform SE 6)";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="่ทณ่ฟๅฏผ่ช้พๆฅ"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>ๆฆ่ฟฐ</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>่ฝฏไปถๅ
</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">็ฑป</FONT> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>ไฝฟ็จ</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>ๆ </B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>ๅทฒ่ฟๆถ</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>็ดขๅผ</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>ๅธฎๅฉ</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>Java<sup><font size=-2>TM</font></sup> Platform<br>Standard Ed. 6</b></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
ไธไธไธช
ไธไธไธช</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html?org/w3c/dom/bootstrap/package-use.html" target="_top"><B>ๆกๆถ</B></A>
<A HREF="package-use.html" target="_top"><B>ๆ ๆกๆถ</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>ๆๆ็ฑป</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html"><B>ๆๆ็ฑป</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<CENTER>
<H2>
<B>่ฝฏไปถๅ
org.w3c.dom.bootstrap<br>็ไฝฟ็จ</B></H2>
</CENTER>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
ไฝฟ็จ <A HREF="../../../../org/w3c/dom/bootstrap/package-summary.html">org.w3c.dom.bootstrap</A> ็่ฝฏไปถๅ
</FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><A HREF="#org.w3c.dom.bootstrap"><B>org.w3c.dom.bootstrap</B></A></TD>
<TD> </TD>
</TR>
</TABLE>
<P>
<A NAME="org.w3c.dom.bootstrap"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<A HREF="../../../../org/w3c/dom/bootstrap/package-summary.html">org.w3c.dom.bootstrap</A> ไฝฟ็จ็ <A HREF="../../../../org/w3c/dom/bootstrap/package-summary.html">org.w3c.dom.bootstrap</A> ไธญ็็ฑป</FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><B><A HREF="../../../../org/w3c/dom/bootstrap/class-use/DOMImplementationRegistry.html#org.w3c.dom.bootstrap"><B>DOMImplementationRegistry</B></A></B>
<BR>
ๅฏ็จๅบ็จ็จๅบๆฅ่ทๅพ <code>DOMImplementation</code> ๅฎไพ็ๅทฅๅใ</TD>
</TR>
</TABLE>
<P>
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="่ทณ่ฟๅฏผ่ช้พๆฅ"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>ๆฆ่ฟฐ</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>่ฝฏไปถๅ
</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">็ฑป</FONT> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>ไฝฟ็จ</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>ๆ </B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>ๅทฒ่ฟๆถ</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>็ดขๅผ</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>ๅธฎๅฉ</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>Java<sup><font size=-2>TM</font></sup> Platform<br>Standard Ed. 6</b></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
ไธไธไธช
ไธไธไธช</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html?org/w3c/dom/bootstrap/package-use.html" target="_top"><B>ๆกๆถ</B></A>
<A HREF="package-use.html" target="_top"><B>ๆ ๆกๆถ</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>ๆๆ็ฑป</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html"><B>ๆๆ็ฑป</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
<font size="-1"><a href="http://bugs.sun.com/services/bugreport/index.jsp">ๆไบค้่ฏฏๆๆ่ง</a><br>ๆๅ
ณๆดๅค็ API ๅ่่ตๆๅๅผๅไบบๅๆๆกฃ๏ผ่ฏทๅ้
<a href="http://java.sun.com/javase/6/webnotes/devdocs-vs-specs.html">Java SE ๅผๅไบบๅๆๆกฃ</a>ใ่ฏฅๆๆกฃๅ
ๅซๆด่ฏฆ็ป็ใ้ขๅๅผๅไบบๅ็ๆ่ฟฐ๏ผไปฅๅๆปไฝๆฆ่ฟฐใๆฏ่ฏญๅฎไนใไฝฟ็จๆๅทงๅๅทฅไฝไปฃ็ ็คบไพใ <p>็ๆๆๆ 2007 Sun Microsystems, Inc. ไฟ็ๆๆๆๅฉใ ่ฏท้ตๅฎ<a href="http://java.sun.com/javase/6/docs/legal/license.html">่ฎธๅฏ่ฏๆกๆฌพ</a>ใๅฆ่ฏทๅ้
<a href="http://java.sun.com/docs/redist.html">ๆๆกฃ้ๆฐๅๅๆฟ็ญ</a>ใ</font>
</BODY>
</HTML>
| piterlin/piterlin.github.io | doc/jdk6_cn/org/w3c/dom/bootstrap/package-use.html | HTML | mit | 7,973 |
<!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 -->
<title>DoNotInstrument</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../jquery/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
<script type="text/javascript" src="../../../../jquery/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../../jquery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="../../../../jquery/jquery-ui.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="DoNotInstrument";
}
}
catch(err) {
}
//-->
var pathtoroot = "../../../../";loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<div class="fixedNav">
<!-- ========= 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 class="aboutLanguage"><ul class="navList" style="font-size: 1.5em;"><li>Robolectric 4.4 | <a href="/" target="_top"><img src="http://robolectric.org/images/logo-with-bubbles-down.png" style="max-height: 18pt; vertical-align: sub;"/></a></li></ul></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/robolectric/annotation/internal/ConfigUtils.html" title="class in org.robolectric.annotation.internal"><span class="typeNameLink">Prev Class</span></a></li>
<li><a href="../../../../org/robolectric/annotation/internal/Instrument.html" title="annotation in org.robolectric.annotation.internal"><span class="typeNameLink">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/robolectric/annotation/internal/DoNotInstrument.html" target="_top">Frames</a></li>
<li><a href="DoNotInstrument.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<ul class="navListSearch">
<li><span>SEARCH: </span>
<input type="text" id="search" value=" " disabled="disabled">
<input type="reset" id="reset" value=" " disabled="disabled">
</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>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Field | </li>
<li>Required | </li>
<li>Optional</li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Element</li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
</div>
<div class="navPadding"> </div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle"><span class="packageLabelInType">Package</span> <a href="../../../../org/robolectric/annotation/internal/package-summary.html">org.robolectric.annotation.internal</a></div>
<h2 title="Annotation Type DoNotInstrument" class="title">Annotation Type DoNotInstrument</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre><a href="https://developer.android.com/reference/java/lang/annotation/Documented.html?is-external=true" title="class or interface in java.lang.annotation">@Documented</a>
<a href="https://developer.android.com/reference/java/lang/annotation/Retention.html?is-external=true" title="class or interface in java.lang.annotation">@Retention</a>(<a href="https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html?is-external=true#RUNTIME" title="class or interface in java.lang.annotation">RUNTIME</a>)
<a href="https://developer.android.com/reference/java/lang/annotation/Target.html?is-external=true" title="class or interface in java.lang.annotation">@Target</a>(<a href="https://developer.android.com/reference/java/lang/annotation/ElementType.html?is-external=true#TYPE" title="class or interface in java.lang.annotation">TYPE</a>)
public @interface <span class="memberNameLabel">DoNotInstrument</span></pre>
<div class="block">Indicates that a class should not be stripped/instrumented under any circumstances.</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"><ul class="navList" style="font-size: 1.5em;"><li>Robolectric 4.4 | <a href="/" target="_top"><img src="http://robolectric.org/images/logo-with-bubbles-down.png" style="max-height: 18pt; vertical-align: sub;"/></a></li></ul></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/robolectric/annotation/internal/ConfigUtils.html" title="class in org.robolectric.annotation.internal"><span class="typeNameLink">Prev Class</span></a></li>
<li><a href="../../../../org/robolectric/annotation/internal/Instrument.html" title="annotation in org.robolectric.annotation.internal"><span class="typeNameLink">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/robolectric/annotation/internal/DoNotInstrument.html" target="_top">Frames</a></li>
<li><a href="DoNotInstrument.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Field | </li>
<li>Required | </li>
<li>Optional</li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Element</li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
| robolectric/robolectric.github.io | javadoc/4.4/org/robolectric/annotation/internal/DoNotInstrument.html | HTML | mit | 8,222 |
@import Foundation;
#import "FDObjectTransformerAdapter.h"
@interface FDURLComponentsTransformerAdapter : NSObject
<
FDObjectTransformerAdapter
>
@end
| reidmain/FDObjectTransformer | Framework Project/FDObjectTransformer Tests/Classes/FDURLComponentsTransformerAdapter.h | C | mit | 154 |
module Goaltender
end
require "goaltender/version"
require "goaltender/base_module"
require 'goaltender/value_parser'
require 'goaltender/input'
require 'goaltender/base' | francirp/goaltender | lib/goaltender.rb | Ruby | mit | 172 |
package com.sms4blood.emergencyhealthservices.util;
import android.content.Intent;
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Toast;
import com.sms4blood.emergencyhealthservices.Sms;
import com.sms4blood.emergencyhealthservices.app.EhsApplication;
import java.text.DecimalFormat;
/**
* Created by Vishnu on 8/1/2015.
*/
public class AppUtil extends Util {
public static boolean callNumber(String phoneNumber) {
boolean isValidPhoneNumber = checkPhoneNumber(phoneNumber);
if (isValidPhoneNumber) {
String callUri = "tel:" + phoneNumber;
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(callUri));
callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(callIntent);
} else {
Toast.makeText(EhsApplication.getContext(), "Invalid phone number.", Toast.LENGTH_SHORT).show();
}
return isValidPhoneNumber;
}
public static boolean sendSms(String phoneNumber, String message) {
boolean isValidPhoneNumber = checkPhoneNumber(phoneNumber);
if (isValidPhoneNumber) {
// /*It is better to let the android manage the sms sending task using native messaging app*/
// Intent smsIntent = new Intent(Intent.ACTION_VIEW);
// // Invokes only SMS/MMS clients
// smsIntent.setType("vnd.android-dir/mms-sms");
// // Specify the Phone Number
// smsIntent.putExtra("address", phoneNumber);
// // Specify the Message
// smsIntent.putExtra("sms_body", message);
// smsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// try {
// startActivity(smsIntent);
// } catch (Exception e) {
// e.printStackTrace();
// Toast.makeText(EhsApplication.getContext(), "Unable to send sms to this number.", Toast.LENGTH_SHORT)
// .show();
// }
Intent i=new Intent(EhsApplication.getContext(), Sms.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Bundle bundle = new Bundle();
bundle.putString("mobileno",phoneNumber);
i.putExtras(bundle);
startActivity(i);
} else {
Toast.makeText(EhsApplication.getContext(), "Invalid phone number.", Toast.LENGTH_SHORT).show();
}
return isValidPhoneNumber;
}
public static boolean showMap(String latitude, String longitude) {
try {
if (!TextUtils.isEmpty(latitude) && (!TextUtils.isEmpty(longitude))) {
Uri gmmIntentUri = Uri.parse("google.navigation:q=" + latitude + "," + longitude);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
mapIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(mapIntent);
return true;
} else {
Toast.makeText(EhsApplication.getContext(), "Address not available.", Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
public static boolean showMap(String address) {
try {
if (!TextUtils.isEmpty(address)) {
String encodedAddress = address.replaceAll("\n", " ");
Uri gmmIntentUri = Uri.parse("google.navigation:q=" + encodedAddress);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
mapIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(mapIntent);
return true;
} else {
Toast.makeText(EhsApplication.getContext(), "Address not available.", Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* @param fromLatitude
* @param fromLongitude
* @param toLatitude
* @param toLongitude
* @return distance between the two latitudes and longitudes in kms.
*/
public static double calculateDistance(double fromLatitude,double fromLongitude,double toLatitude,double toLongitude) {
float results[] = new float[1];
try {
Location.distanceBetween(fromLatitude, fromLongitude, toLatitude, toLongitude, results);
} catch (Exception e) {
if (e != null)
e.printStackTrace();
}
int dist = (int) results[0];
if(dist<=0) {
return 0D;
}
DecimalFormat decimalFormat = new DecimalFormat("#.##");
results[0]/=1000D;
String distance = decimalFormat.format(results[0]);
double d = Double.parseDouble(distance);
return d;
}
}
| VishnuPrabhu/EHS | app/src/main/java/com/sms4blood/emergencyhealthservices/util/AppUtil.java | Java | mit | 5,042 |
<?php
namespace App\FrontModule;
use App\AppModule\ErrorPresenter as Presenter;
class ErrorPresenter extends Presenter
{
}
| castamir/MPR-projekt | app/modules/Front/presenters/ErrorPresenter.php | PHP | mit | 129 |
# Description: Photography References
### Online References
* [None](#): None
### Write Here
- None
### Notes
- None
### TODOs
- None
| vikash-india/PhotographyNotes2Myself | photography/concepts/001-PhotographyReferences.md | Markdown | mit | 138 |
<html>
<head>
<title>
ABC ํธ๋ ํน 3 : ์๋์ :: ์ดํ๊ฒฐ ๋ธ๋ก๊ทธ
</title>
<style>
/* https://github.com/markdowncss/modest/blob/master/css/modest.css */
@media print {
*,
*:before,
*:after {
background: transparent !important;
color: #000 !important;
box-shadow: none !important;
text-shadow: none !important;
}
a,
a:visited {
text-decoration: underline;
}
a[href]:after {
content: ' (' attr(href) ')';
}
abbr[title]:after {
content: ' (' attr(title) ')';
}
a[href^='#']:after,
a[href^='javascript:']:after {
content: '';
}
pre,
blockquote {
border: 1px solid #999;
page-break-inside: avoid;
}
thead {
display: table-header-group;
}
tr,
img {
page-break-inside: avoid;
}
img {
max-width: 100% !important;
}
p,
h2,
h3 {
orphans: 3;
widows: 3;
}
h2,
h3 {
page-break-after: avoid;
}
}
pre,
code {
font-family: Menlo, Monaco, 'Courier New', monospace;
}
pre {
padding: 0.5rem;
line-height: 1.25;
overflow-x: scroll;
}
a,
a:visited {
color: #3498db;
}
a:hover,
a:focus,
a:active {
color: #2980b9;
}
.modest-no-decoration {
text-decoration: none;
}
html {
font-size: 12px;
}
@media screen and (min-width: 32rem) and (max-width: 48rem) {
html {
font-size: 15px;
}
}
@media screen and (min-width: 48rem) {
html {
font-size: 16px;
}
}
body {
line-height: 1.85;
}
p,
.modest-p {
font-size: 1rem;
margin-bottom: 1.3rem;
}
h1,
.modest-h1,
h2,
.modest-h2,
h3,
.modest-h3,
h4,
.modest-h4 {
margin: 1.414rem 0 0.5rem;
font-weight: inherit;
line-height: 1.42;
}
h1,
.modest-h1 {
margin-top: 0;
font-size: 3.998rem;
}
h2,
.modest-h2 {
font-size: 2.827rem;
}
h3,
.modest-h3 {
font-size: 1.999rem;
}
h4,
.modest-h4 {
font-size: 1.414rem;
}
h5,
.modest-h5 {
font-size: 1.121rem;
}
h6,
.modest-h6 {
font-size: 0.88rem;
}
small,
.modest-small {
font-size: 0.707em;
}
/* https://github.com/mrmrs/fluidity */
img,
canvas,
iframe,
video,
svg,
select,
textarea {
max-width: 100%;
}
@import url(
http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,
300italic,
700
);
@import url(http://fonts.googleapis.com/css?family=Arimo:700, 700italic);
html {
font-size: 18px;
max-width: 100%;
}
body {
color: #444;
font-family: 'Open Sans Condensed', sans-serif;
font-weight: 300;
margin: 0 auto;
max-width: 48rem;
line-height: 1.45;
padding: 0.25rem;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: Arimo, Helvetica, sans-serif;
}
h1,
h2,
h3 {
border-bottom: 2px solid #fafafa;
margin-bottom: 1.15rem;
padding-bottom: 0.5rem;
text-align: center;
}
blockquote {
border-left: 8px solid #fafafa;
padding: 1rem;
}
pre,
code {
background-color: #fafafa;
}
</style>
</head>
<body>
<header>
<h2>
์ดํ๊ฒฐ ๋ธ๋ก๊ทธ
<a href="http://leehankyeol.me">โ๏ธ</a>
<a href="https://github.com/leehankyeol">๐ป</a>
<a href="https://www.instagram.com/leehankyeol.me">๐ท</a>
<a href="https://www.facebook.com/lee.hankyeol">๐ป</a>
</h2>
</header>
<article>
<h1>ABC ํธ๋ ํน 3 : ์๋์</h1>
<ol>
<li>
<p>์ฐํ์ ๊ณ ๋๋ค. ๊ทธ๋๋ ํ ๋งํ ์์ค์ด๋ค. ๊ฐ์ฅ ๋ฌด๊ฑฐ์ด ์ง์ ๋ ๋น์ปค์ค๊ฐ ํญ์ ์์ฅ์ ์๊ณ ๊ทธ๋ณด๋ค๋ ์กฐ๊ธ ๋ ๊ฐ๋ฒผ์ด ์ง์ ๋ ๋ด๊ฐ ์ค๊ฐ์, ์ ์ผ ๊ฐ๋ฒผ์ด ๋ฐฐ๋ญ์ ๋ฉจ์ง๋ง ๊ทธ๋งํผ ์ ์ผ ๊ท์ฌ์ด K๊ฐ ํ๋ฐฉ์ ์ ๋ค. ๊ฐ์ฅ ํ๋ค์ด ํ๋ K๋ฅผ ์ฑ๊ธฐ๋ ๊ฒ์ ์๋ฌด๋๋ ๋์ ๋ชซ์ด๋ค. ์ด์ ๋ ์
๋ชจ์๋ง ๋ด๋ ์ผ๋ง๋ ํ๋ ์ง ์์์ฐจ๋ฆด ์ ์๋ค. ์ ๋ค๋ฌผ์์ง๋ง ์
๊ผฌ๋ฆฌ๊ฐ ์ํ์ ์ ์งํ๋ค๋ฉด ํ์ด ๋ ๋งํ ๋ง์ ๋์ง ํ์ด๋ฐ์ด๋ค. ์์ง๊น์ง ์ ๋ง ์ ๊ฐ๊ณ ์๋ค. ๊ธฐํนํ๋ค.</p>
</li>
<li>
<p>๊ฑฐ๋จธ๋ฆฌ์ ๋ฌผ๋ ธ๋ค. ๋ณต์ฅ์ด๋ ๋์ ์ ๊ณ ๋ คํ์ ๋ ๋
ธ์ถ๋ ์๊ฐ์ ์ฐฐ๋์ธ๋ฐ ๊ทธ ํ์ ๋์น์ง ์์ ์
์ด๋ค. ์นจ๋์ ์๋๋ ค ๊ธ์ ์ฐ๋ ๋๋ฅผ ๋ณด๊ณ ๋จผ์ ์์ค๋ผ์น๊ฒ ๋๋ ๊ฑด K, ํผ๋ฒ๋ฒ
(์ ๊ณผ์ฅ์ด ์๋๊ณ ์ง์ง์๋ค.)์ด ๋ ๋ฐ์ ๋์๋ณด๊ณ ๋ค๋ฆ๊ฒ ๋๋ ๊ฒ์ ๋์๋ค. ์๋ง๋ ๋ด ์ค๋ฅธ๋ฐ๋ฑ์ ๋ฏ์ ๊ฒ์ผ๋ก ์ถ์ ๋๋ ๊ฑฐ๋จธ๋ฆฌ๋ ์์ ์ฒ์ฅ์์ ๋๋กฑ๋๋กฑ๊ฑฐ๋ฆฌ๊ณ ์์๋ค. ์นจ์ฐฉํ๊ฒ ๋ฐ์ ๋ฆ๊ณ ๋ฐ์ฐฝ๊ณ ๋ฅผ ๋ถ์ธ ๋ค ์ฒ์ฅ์ ๋
์์ ์ฌ๋ก์ก์๋ค. ๊ฑฐ๋จธ๋ฆฌ์ ๋ฌผ๋ฆฐ ์๊ฐ์ ์์ฝํ๋ฉด, ์ ๋ง ์ฅ๋์๋ ๋ชจ๋ฅด๊ฒ ๋ฌผ๋ฆฌ๊ณ ์๊ฐ๋ณด๋ค ํผ๊ฐ ๋ง์ด ๋๋ค๋ ๊ฒ.</p>
</li>
<li>
<p>ABC๊น์ง ๊ฐ๋ ํธ๋ ํน ์ฝ์ค๋, ๋น์ปค์ค์ ์ํ๋ฉด, ํ๋ ํ๊ตญ ์ฌ๋๋ค์ด ๋ง์ด ์์ ํ์ง์ธ๋ค ์ฌ์ด์์ ์ฝ๋ฆฌ์ ์ฝ์ค๋ผ๊ณ ๋ถ๋ฆฌ๊ธฐ๋ ํ๋จ๋ค. ํฐ ๊ฑฐ์ ์๋ โ1. ํ๊ตญ๋ผ๋ฉด 2. ๊น์น์ฐ๊ฐ 3. ๋ฐฑ์ 4. ๊น์นโ๋ผ๊ณ ์ฐ์ฌ์ง ๊ฐํ์ ์ฌ๋ฟ ๋ณผ ์ ์์ผ๋ฉฐ ๋กฏ์ง๊ฐ ์๋ ์ผํฐ ๋๋ถ๋ถ์์๋ ํ๊ตญ์ธ ๋ฑ์ฐ๊ฐ๋ค์ด ํนํ ๋งํ ๋ฉ๋ด๋ฅผ ๋ณผ ์ ์๋ค. ํ์ง๋ง ์ฝ์ค์ ์กด์ฌํ๋ ๋ชจ๋ ๋กฏ์ง์ ์ผํฐ๋ ๋น๋จ ๊ด๊ด๊ฐ๋ค๋ง์ ์ํ ๊ฒ์ด ์๋๋ค. ๊ทธ๊ณณ์์ ์ด์๊ฐ๋ ํ์ง์ธ๋ค์ ์ถ์ ์ํด์๋ ํ์์ ์ผ๋ก ์์ด์ผ ํ๋ ๊ณต๊ฐ์ด๋ค. ์๋ด๋ฅผ ํ ๋ฒ ๋๊ฐ๋ค ์ค๋ ๊ฒ๋ง ํด๋ ๋ฉฐ์น ์ด ๊ฑธ๋ฆฌ๋ ์ฌ์ ์ด๋ค. ํด์์์ด ์ํํ์ ์ง์ด์ง๊ณ ์ด๋ํ๋ ๊ฒ์ ๋ถ๊ฐ๋ฅํ ์ผ์ด๋ค. 70kg ๋ฌด๊ฒ์ ๊ฐ์คํต์ ์ง์ด์ง ๋น๋๊ท๋, ๋ง๋, ์๋ ํด์ํ ๊ณณ์ด ํ์ํ๋ค. ๋ชจ๋ ๊ณต์ฌ ์์ฌ๋ฅผ ๋ฑ์ ์ง๊ณ ๋จธ๋ฆฌ๋ก ๊ทธ ๋ฌด๊ฒ๋ฅผ ์งํฑํด๊ฐ๋ฉฐ ๊ฐ๋ ์ด๋ค์ ๋ฌด๋ฆฌ๋ฅผ ๋ณผ ๋๋ฉด ๊ฒฝ์ด๋ก์๋ง์ ๋๊ปด์ง๋ค. ์ด ์ ์ฑํ ์ถ์ ๊ณผ์ ์ ์ค์ณ์ง๋๊ฐ๋ ๋ ๊ฐ์ ๊ด๊ด๊ฐ๋ค์ ํ์์ด ๊ฒธ์ํด์ ธ์ผ ํ ๊ฒ์ด๋ค. ํ์ง์ธ๋ค์ ๋ง์ฃผ์น ๋๋ง๋ค ๊ณ ๊ฐ๋ฅผ ์์ด๊ณ ๋๋ง์ค๋ผ๋ฅผ ๋งํ๋ ๊ฒ์ ์์ง ๋ง์์ผ ํ๋ค.</p>
</li>
<li>
<p>๋น์ฐํ ์ด๋ฐ ํธ๋ ํน์ ์ดํ์ธ ๋งํผ ์๋ณด๋ ์ ์ฑ๊ฒจ์ ์์ฌ์ด ๊ฒ ํ๋์ด ์๋์ง๋ง ์ง์ง ์์คํค ๋ ๋ณ ์ฌ์ฌ ๊ฑธ.</p>
</li>
<li>
<p>๋คํ ํ์ง์์ด ๋ณ ๊ฑฐ ์๋ค๋ ๋ง์ ์์ ํ ์๋ชป๋์๋ค. ์ด์ ์ ๋
์ฐ์ฐํ ์ํค๊ฒ ๋(์ค๋ ์ผ์ ๋ถํฐ๋ ์ ์ฑํ ์ง์ญ์ผ๋ก ๋ค์ด์๊ธฐ ๋๋ฌธ์ ๋จน์ ์ ์๋ ๊ณ ๊ธฐ์ ์ข
๋ฅ๊ฐ ์ ํ๋๋ค๊ณ ํ๊ธฐ ๋๋ฌธ์ด๋ค.) ๋ญ๊ณ ๊ธฐ ๋ฒ ์ด์ค์ ๋ฌ๋ฐง๊ณผ ๋ชจ๋ชจ๋ ๋์ K์ ์๊ตญ์
๋ง์ ์ ๋ฉด๊ฐํญํ๋ ๋คํ๋ฐ ํฌํ๊ณผ๋ ๊ฐ์๋ค. ๋ฌ๋ฐงํ์ ํธ์ฌํฐํฌ์์๋ง ์์ผ๋ฉด ABC๋ ๋๋ก์๋ค. ์ค๋ ์ ์ฌ๋ ๋ฌ๋ฐง์ ๋จน์๋ค.</p>
</li>
</ol>
</article>
<footer>
Styled by
<a href="https://github.com/markdowncss/modest/blob/master/css/modest.css"
>Modest</a
>
</footer>
</body>
</html>
| leehankyeol/leehankyeol.github.io | 2018/09/25/abc-3-sinuwa/index.html | HTML | mit | 7,782 |
module Perus::Pinger
class Upload < Command
description 'Uploads a file from the client to the server. Valid values
for "path" are contained in the pinger config file.'
option :path, restricted: true
def run
@file = File.new(options.path)
end
def cleanup
@file.close unless @file.nil? || @file.closed?
end
end
end
| cotag/perus | lib/perus/pinger/commands/upload.rb | Ruby | mit | 417 |
package miwax.java_conf.gr.jp.frugalitycalc.view;
import android.app.AlertDialog;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import miwax.java_conf.gr.jp.frugalitycalc.R;
import miwax.java_conf.gr.jp.frugalitycalc.databinding.ActivityMainBinding;
import miwax.java_conf.gr.jp.frugalitycalc.util.messenger.ShowAlertDialogMessage;
import miwax.java_conf.gr.jp.frugalitycalc.viewmodel.MainViewModel;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.subscriptions.CompositeSubscription;
public class MainActivity extends AppCompatActivity {
private final String VIEW_MODEL = "VIEW_MODEL";
private ActivityMainBinding binding;
private MainViewModel mainViewModel;
private CompositeSubscription subscriptions = new CompositeSubscription();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
if (savedInstanceState != null) {
mainViewModel = savedInstanceState.getParcelable(VIEW_MODEL);
} else {
mainViewModel = new MainViewModel();
}
binding.setViewModel(mainViewModel);
// ใใคใขใญใฐ่กจ็คบใฎใกใใปใผใธๅไฟก
subscriptions.add(
mainViewModel.getMessenger().register(ShowAlertDialogMessage.class)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<ShowAlertDialogMessage>() {
@Override
public void call(ShowAlertDialogMessage message) {
showAlertDialog(message.getTitleId(), message.getTextId());
}
})
);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable(VIEW_MODEL, mainViewModel);
}
@Override
protected void onDestroy() {
mainViewModel.unsubscribe();
super.onDestroy();
}
private void showAlertDialog(int titleId, int textId) {
new AlertDialog.Builder(this)
.setTitle(this.getString(titleId))
.setMessage(this.getString(textId))
.setPositiveButton("OK", null)
.show();
}
}
| tomoya0x00/FrugalityCalc | app/src/main/java/miwax/java_conf/gr/jp/frugalitycalc/view/MainActivity.java | Java | mit | 2,423 |
<?php
namespace Manialib\Maniacode\Elements;
class ViewReplay extends UrlDownload
{
protected $nodeName = 'view_replay';
} | manialib/maniacode | src/Manialib/Maniacode/Elements/ViewReplay.php | PHP | mit | 127 |
import _plotly_utils.basevalidators
class MinexponentValidator(_plotly_utils.basevalidators.NumberValidator):
def __init__(
self, plotly_name="minexponent", parent_name="choropleth.colorbar", **kwargs
):
super(MinexponentValidator, self).__init__(
plotly_name=plotly_name,
parent_name=parent_name,
edit_type=kwargs.pop("edit_type", "colorbars"),
min=kwargs.pop("min", 0),
**kwargs
)
| plotly/plotly.py | packages/python/plotly/plotly/validators/choropleth/colorbar/_minexponent.py | Python | mit | 477 |
<HTML><HEAD>
<TITLE>Review for Timecode (2000)</TITLE>
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/ramr.css">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1 ALIGN="CENTER" CLASS="title"><A HREF="/Title?0220100">Timecode (2000)</A></H1><H3 ALIGN=CENTER>reviewed by<BR><A HREF="/ReviewsBy?Frankie+Paiva">Frankie Paiva</A></H3><HR WIDTH="40%" SIZE="4">
<PRE>Time Code</PRE>
<PRE>rated R
97 minutes
Screen Gems
starring Jeanne Tripplehorn, Salma Hayek, Stellan Skarsgard, Saffron Burrows,
and Kyle MacLachlan
written and directed by Mike Figgis</PRE>
<PRE>A Review by Frankie Paiva</PRE>
<P>I believe it's unfair to call Time Code an actual movie. The word experience
is a better fit. The Time Code experience involves the screen being split
into four different images, each with a different character focus, as they
all play at the same time. The sound gets turned up on the one Figgis wants
you to watch. One could describe it as watching four different shows on MTV
all at once. The story relies heavily on this split screen factor and this is
a very visual film with little complicated dialog. It has to be. Even with a
slightly complicated plot, this movie would have been even more of a frenzy
of annoying pointless images than it was. Essentially, a frenzy of annoying
images describes the film well. This film is a foray into the different and
the unusual, but carries little meaning. While Figgis has created a
groundbreaking filmmaking approach, he seems concentrated on making sure the
audience can handle it, rather than keep an interesting storyline going. It
has been a long time since a movie has challenged you in such a way as this
one does, but I felt it could have been even more challening if trust was put
in the audience. Time Code dares to go freeform, and encourages the viewer to
look at these characters and their surroundings with lightning fast
comprehension before moving onto the next frame. Like any new method to come
onto the film scene, it will take time to master, but consider Time Code the
beginning of a new era in film.</P>
<P>The movie was shot entirely in one afternoon last November using hand-held
cameras. There are no edits. Everything is real time. There is no set plot
structure either. While Figgis gave his actors basic character outlines, he
decided it would be much more interesting if the film was almost entirely
improvisational. This is both an attraction and a detraction. There are
times when you sense the actors come up with things right off the top of
their heads, and those parts of the film are exciting and fun. Character
reactions are a key part of this movie that centers around Red Mullet
Productions (both the producers and setting for this film) during auditions
for a new movie. In the upper left corner Rose (Wild Wild West recovering
Salma Hayek) is going to the audition with Lauren (Jeanne Tripplehorn). Rose
and Lauren are lovers, and the latter suspects infidelity. In the upper
right, Emma (Saffron Burrows, Figgis's wife) consults her psychiatrist about
her husband Alex (Stellan Skarsgard) whom she suspects is cheating on her.
Alex is indeed cheating on her, and he occupies the lower right frame.
Finally, in the bottom left is an aspiring actress that comes to audition for
the lead role at Red Mullet.</P>
<P>After this basic setup, the camera roams free. Characters pop up in two
different frames at once, or switch frames entirely. It's interesting to see
how this effect gets used. One scene that I found bizarre involved Alex and
an anonymous female having sex behind a movie screen. The screen was being
used to show actresses moaning loudly from sexual pleasure during an audition
for a group of executives. Another common element that unites the characters
is the frequent bothersome earthquakes. Much care must have been taken into
the timing to make the illusion of an earthquake appear in all four parts at
the same time. These tremors that connect the characters continuously
reminded me of the character connecting amphibians from the end of Magnolia.
The ensemble cast that includes Steven Weber, Holly Hunter, Julian Sands,
Leslie Mann, and Laurie Metcalf, as well as the actors mentioned above, have
fun with their roles. It's no surprise though that the movie is inconsistent,
but by the hour mark, I found myself comfortably able to grasp all that was
going on. Time Code is almost interactive. It allows people to get a
different experience of the movie each time they see it. The themes are the
same though. Woe, jealousy, and betrayal all occupy different parts of the
screen often. Everyone is cheating on everyone, and all the women are
lesbians. Late in the film a young female independent filmmaker comes forward
with an idea of new age filmmaking. "The end of editing is upon us!" she
preaches. "Imagine a movie with four different images all running at the same
time." Alex blows this idea off, and cannot control his laughter at the
proposal. He tells her what a load of crap he thinks it is. She takes the
criticism surprisingly well, and replies with a thank you stating he's the
only honest person she has ever met in Los Angeles. By the time it reaches
the conclusion, the facade of quality and honesty in Time Code is gone. It
was then I realized the emptiness that ran through this movie. While Time
Code is definitely worth seeing for the very original concept it presents,
there's no hiding that little actual material lies under its surface.</P>
<PRE>B-</PRE>
<PRE>Frankie Paiva
<A HREF="mailto:[email protected]">[email protected]</A>
<A HREF="http://www.homestead.com/cinemaparadise/moviereviews.html">http://www.homestead.com/cinemaparadise/moviereviews.html</A></PRE>
<HR><P CLASS=flush><SMALL>The review above was posted to the
<A HREF="news:rec.arts.movies.reviews">rec.arts.movies.reviews</A> newsgroup (<A HREF="news:de.rec.film.kritiken">de.rec.film.kritiken</A> for German reviews).<BR>
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.<BR>
Please direct comments/criticisms of the review to relevant newsgroups.<BR>
Broken URLs inthe reviews are the responsibility of the author.<BR>
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
</SMALL></P>
<P ALIGN=CENTER>Related links: <A HREF="/Reviews/">index of all rec.arts.movies.reviews reviews</A></P>
</P></BODY></HTML>
| xianjunzhengbackup/code | data science/machine_learning_for_the_web/chapter_4/movie/24925.html | HTML | mit | 6,641 |
//
// YSCMacros.h
// YSCKit
//
// Created by Builder on 16/6/29.
// Copyright ยฉ 2016ๅนด Builder. All rights reserved.
//
#import <sys/time.h>
//==============================================================================
//
// @Description:
// ่ฏฅๆไปถๅฎไนไบๅบ็กๅบYSCKitไธญๅธธ็จ็ๅฎๅฎไน
//
//==============================================================================
#ifndef YSCMacros_h
#define YSCMacros_h
/** ๅคไบ่ฐ่ฏๆ่
ๅผๅๆจกๅผ */
#define IS_DEBUG_OR_DEVELOP_MODE (YSCConfigManagerInstance.isDebugModel || [YSCGeneral isArchiveByDevelopment])
/** ๆฏๅฆ่พๅบlog */
#define IS_NSLOG_AVAILABLE IS_DEBUG_OR_DEVELOP_MODE
#define __NSLog(s, ...) do { \
if (IS_NSLOG_AVAILABLE) { \
NSMutableString *logString = [NSMutableString stringWithFormat:@"[%@(%d)] ",[[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__]; \
if (s) { \
[logString appendFormat:(s), ##__VA_ARGS__]; \
} \
else { \
[logString appendString:@"(null)"]; \
} \
NSLog(@"%@", logString); \
[YSCLog saveLog:logString]; \
} \
} while (0)
#define NSLog(...) __NSLog(__VA_ARGS__)
/** ๅปๆๅญ็ฌฆไธฒ็ๅคดๅฐพ็ฉบๆ ผ */
#define TRIM_STRING(_string) (\
( ! [_string isKindOfClass:[NSString class]]) ? \
@"" : [_string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] \
)
/**
* ๅฏน่ฑกๅค็ฉบ
* ๆณจๆ๏ผๅชๅฏนๅๅงๆฐๆฎ่ฟ่กๅคๆญ๏ผๅณๅ
จ็ฉบ็ๅญ็ฌฆไธฒไธไธบ็ฉบ
*/
#define OBJECT_IS_EMPTY(_object) (_object == nil \
|| [_object isKindOfClass:[NSNull class]] \
|| ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
|| ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))
#define OBJECT_ISNOT_EMPTY(_object) ( ! OBJECT_IS_EMPTY(_object))
#define RETURN_WHEN_OBJECT_IS_EMPTY(_object) if (OBJECT_IS_EMPTY(_object)) { return ; }
#define RETURN_NIL_WHEN_OBJECT_IS_EMPTY(_object) if (OBJECT_IS_EMPTY(_object)) { return nil; }
#define RETURN_EMPTY_WHEN_OBJECT_IS_EMPTY(_object) if (OBJECT_IS_EMPTY(_object)) { return @""; }
#define RETURN_YES_WHEN_OBJECT_IS_EMPTY(_object) if (OBJECT_IS_EMPTY(_object)) { return YES; }
#define RETURN_NO_WHEN_OBJECT_IS_EMPTY(_object) if (OBJECT_IS_EMPTY(_object)) { return NO; }
#define RETURN_ZERO_WHEN_OBJECT_IS_EMPTY(_object) if (OBJECT_IS_EMPTY(_object)) { return 0; }
/**
* ๅๅปบๅไพ
*/
#ifndef DEFINE_SHARED_INSTANCE_USING_BLOCK
#define DEFINE_SHARED_INSTANCE_USING_BLOCK(block) \
static dispatch_once_t pred = 0; \
__strong static id _sharedObject = nil; \
dispatch_once(&pred, ^{ \
if (block) { \
_sharedObject = block(); \
} \
}); \
return _sharedObject;
#endif
/**
* @brief swizzling instance method
*
* @usage:
* SWIZZLING_INSTANCE_METHOD(self.class, @selector(viewDidLoad), @selector(ysc_viewDidLoad))
*/
#ifndef SWIZZLING_INSTANCE_METHOD
#define SWIZZLING_INSTANCE_METHOD(clazz, originalSelector, swizzledSelector) { \
Method originalMethod = class_getInstanceMethod(clazz, originalSelector); \
Method swizzledMethod = class_getInstanceMethod(clazz, swizzledSelector); \
BOOL isAddedMethod = class_addMethod(clazz, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); \
if (isAddedMethod) { \
class_replaceMethod(clazz, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); \
} \
else { \
method_exchangeImplementations(originalMethod, swizzledMethod); \
} }
#endif
/**
* @brief swizzling class method
*
* @usage:
* SWIZZLING_INSTANCE_METHOD(object_getClass((id)self), @selector(viewDidLoad), @selector(ysc_viewDidLoad))
*/
#ifndef SWIZZLING_CLASS_METHOD
#define SWIZZLING_CLASS_METHOD(clazz, originalSelector, swizzledSelector) { \
Method originalMethod = class_getInstanceMethod(clazz, originalSelector); \
Method swizzledMethod = class_getInstanceMethod(clazz, swizzledSelector); \
BOOL isAddedMethod = class_addMethod(clazz, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); \
if (isAddedMethod) { \
class_replaceMethod(clazz, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); \
} \
else { \
method_exchangeImplementations(originalMethod, swizzledMethod); \
} }
#endif
/**
* ไปฃ็ ๆฎต็ฎๅ
*/
#define RGBA(r, g, b, a) [UIColor colorWithRed:r / 255.0f green:g / 255.0f blue:b / 255.0f alpha:a]
#define RGB(r, g, b) RGBA(r,g,b,1.0f)
#define RGB_GRAY(c) RGBA(c,c,c,1.0f)
#define RANDOM_INT(from,to) ((int)((from) + arc4random() % ((to)-(from) + 1))) //้ๆบๆฐ [from,to] ไน้ด
#define GET_NSERROR_MESSAGE(e) ((NSError *)e).userInfo[NSLocalizedDescriptionKey] //=e.localizedDescription
#define KEY_WINDOW [UIApplication sharedApplication].keyWindow
#define FUNCTION_NAME [NSString stringWithUTF8String:__FUNCTION__]
#define IS_NIB_EXISTS(nib) [[NSFileManager defaultManager] fileExistsAtPath:[[NSBundle mainBundle] pathForResource:nib ofType:@"nib"]]
#define CREATE_NSERROR_WITH_Code(c,m) [NSError errorWithDomain:@"YSCKit" code:c userInfo:@{NSLocalizedDescriptionKey : m}]
#define CREATE_NSERROR(m) CREATE_NSERROR_WITH_Code(0,m)
#define PRINT_DEALLOCING NSLog(@"[%@] is deallocing...",NSStringFromClass(self.class));
#define DEPRECATED_MARK(_instead_msg) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, _instead_msg) // ็จไบๆ ็คบๅ้ๆๆนๆณๅทฒ็ป่ฟๆไบ
/**
* 1. if (NSOrderedAscending != COMPARE_VERSION(v1,v2)) { //v1 >= v2 }
* 2. if (NSOrderedDescending == COMPARE_VERSION(v1,v2)) { //v1 > v2 }
* 3. if (NSOrderedAscending == COMPARE_VERSION(v1,v2)) { //v1 < v2 }
*/
#define COMPARE_VERSION(v1,v2) [v1 compare:v2 options:NSNumericSearch]
#define COMPARE_CURRENT_VERSION(v) COMPARE_VERSION([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"], (v))
#define APP_SKIP_VERSION(v) [NSString stringWithFormat:@"APP_SKIP_VERSION_%@", v]
#define APP_LAUNCH_VERSION(v) [NSString stringWithFormat:@"APP_LAUNCH_VERSION_%@", v]
/**
* @brief ๅ
ณ้ญperformSelector็leak่ญฆๅๆ็คบ
*
* @usage:
* PERFORM_SELECTOR_WITHOUT_LEAKWARNING(
* [_target performSelector:_action withObject:self]
* );
*
* OR
*
* id result;
* PERFORM_SELECTOR_WITHOUT_LEAKWARNING(
* result = [_target performSelector:_action withObject:self]
* );
*/
#ifndef PERFORM_SELECTOR_WITHOUT_LEAKWARNING
#define PERFORM_SELECTOR_WITHOUT_LEAKWARNING(block) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
if (block) { \
block(); \
} \
_Pragma("clang diagnostic pop") \
} while (0)
#endif
/**
* ๆณจๅ้็ฅไธๅ้้็ฅ
*/
//ๆณจๅ้็ฅ
#define ADD_OBSERVER_WITH_OBJECT(_selector, _name, _object) \
([[NSNotificationCenter defaultCenter] addObserver:self selector:_selector name:_name object:_object])
#define ADD_OBSERVER(_selector,_name) \
ADD_OBSERVER_WITH_OBJECT(_selector, _name, nil)
//ๅ้้็ฅ
#define POST_NOTIFICATION_WITH_OBJECT_AND_INFO(_name, _object, _info) \
([[NSNotificationCenter defaultCenter] postNotificationName:_name object:_object userInfo:(_info)])
#define POST_NOTIFICATION(_name) \
POST_NOTIFICATION_WITH_OBJECT_AND_INFO(_name, nil, nil)
#define POST_NOTIFICATION_WITH_OBJECT(_name, _object) \
POST_NOTIFICATION_WITH_OBJECT_AND_INFO(_name, _object, nil)
#define POST_NOTIFICATION_WITH_INFO(_name, _info) \
POST_NOTIFICATION_WITH_OBJECT_AND_INFO(_name, nil, _info)
//็งป้ค้็ฅ
#define REMOVE_OBSERVER(_name) \
([[NSNotificationCenter defaultCenter] removeObserver:self name:_name object:nil])
#define REMOVE_ALL_OBSERVERS(_self) \
([[NSNotificationCenter defaultCenter] removeObserver:_self])
/**
* @usage:
* YSCBenchmark(^{
* // code
* }, ^(double ms) {
* NSLog(@"time cost: %.2f ms",ms);
* });
*/
static inline void YSCBenchmark(void (^block)(void), void (^complete)(double ms)) {
// <QuartzCore/QuartzCore.h> version
/*
extern double CACurrentMediaTime (void);
double begin, end, ms;
begin = CACurrentMediaTime();
block();
end = CACurrentMediaTime();
ms = (end - begin) * 1000.0;
complete(ms);
*/
// <sys/time.h> version
struct timeval t0, t1;
gettimeofday(&t0, NULL);
block();
gettimeofday(&t1, NULL);
double ms = (double)(t1.tv_sec - t0.tv_sec) * 1e3 + (double)(t1.tv_usec - t0.tv_usec) * 1e-3;
complete(ms);
}
/**
* @usage:
* @interface NSObject (MyAdd)
* @property (nonatomic, strong) NSMutableArray *textFields;
* @end
*
* #import <objc/runtime.h>
* @implementation NSObject (MyAdd)
* YSC_DYNAMIC_PROPERTY_LAZYLOAD(textFields, NSMutableArray *, [NSMutableArray new])
* @end
*/
#ifndef YSC_DYNAMIC_PROPERTY_LAZYLOAD
#define YSC_DYNAMIC_PROPERTY_LAZYLOAD(_getter_, _type_, _initObject_) \
- (_type_)_getter_ { \
_type_ target = objc_getAssociatedObject(self, _cmd); \
if ( ! target) { \
target = _initObject_; \
objc_setAssociatedObject(self, _cmd, target, OBJC_ASSOCIATION_RETAIN_NONATOMIC); \
} \
return target; \
}
#endif
/**
* usage:
* @interface NSObject (MyAdd)
* @property (nonatomic, assign) BOOL isError;
* @end
*
* #import <objc/runtime.h>
* @implementation NSObject (MyAdd)
* YSC_DYNAMIC_PROPERTY_BOOL(isError, setIsError)
* @end
*/
#ifndef YSC_DYNAMIC_PROPERTY_BOOL
#define YSC_DYNAMIC_PROPERTY_BOOL(_getter_, _setter_) \
- (void)_setter_:(BOOL)value { \
NSNumber *number = [NSNumber numberWithBool:value]; \
[self willChangeValueForKey:@#_getter_]; \
objc_setAssociatedObject(self, _cmd, number, OBJC_ASSOCIATION_RETAIN); \
[self didChangeValueForKey:@#_getter_]; \
} \
- (BOOL)_getter_ { \
NSNumber *number = objc_getAssociatedObject(self, @selector(_setter_:)); \
return [number boolValue]; \
}
#endif
/**
* Synthsize a dynamic object property in @implementation scope.
* It allows us to add custom properties to existing classes in categories.
*
* @param association ASSIGN / RETAIN / COPY / RETAIN_NONATOMIC / COPY_NONATOMIC
* @warning #import <objc/runtime.h>
* *******************************************************************************
*
* @usage:
* @interface NSObject (MyAdd)
* @property (nonatomic, retain) UIColor *myColor;
* @end
*
* #import <objc/runtime.h>
* @implementation NSObject (MyAdd)
* YSC_DYNAMIC_PROPERTY_OBJECT(myColor, setMyColor, RETAIN_NONATOMIC, UIColor *)
* @end
*/
#ifndef YSC_DYNAMIC_PROPERTY_OBJECT
#define YSC_DYNAMIC_PROPERTY_OBJECT(_getter_, _setter_, _association_, _type_) \
- (void)_setter_:(_type_)object { \
[self willChangeValueForKey:@#_getter_]; \
objc_setAssociatedObject(self, _cmd, object, OBJC_ASSOCIATION_##_association_); \
[self didChangeValueForKey:@#_getter_]; \
} \
- (_type_)_getter_ { \
return objc_getAssociatedObject(self, @selector(_setter_:)); \
}
#endif
/**
* @usage:
* @interface NSObject (MyAdd)
* @property (nonatomic, retain) CGPoint myPoint;
* @end
*
* #import <objc/runtime.h>
* @implementation NSObject (MyAdd)
* YSC_DYNAMIC_PROPERTY_CTYPE(myPoint, setMyPoint, CGPoint)
* @end
*/
#ifndef YSC_DYNAMIC_PROPERTY_CTYPE
#define YSC_DYNAMIC_PROPERTY_CTYPE(_getter_, _setter_, _type_) \
- (void)_setter_:(_type_)object { \
[self willChangeValueForKey:@#_getter_]; \
NSValue *value = [NSValue value:&object withObjCType:@encode(_type_)]; \
objc_setAssociatedObject(self, _cmd, value, OBJC_ASSOCIATION_RETAIN); \
[self didChangeValueForKey:@#_getter_]; \
} \
- (_type_)_getter_ { \
_type_ cValue = { 0 }; \
NSValue *value = objc_getAssociatedObject(self, @selector(_setter_:)); \
[value getValue:&cValue]; \
return cValue; \
}
#endif
/**
* @usage:
* @weakiy(self)
* [self doSomething^{
* @strongiy(self)
* if (!self) return;
* ...
* }];
*/
#ifndef weakiy
#if DEBUG
#if __has_feature(objc_arc)
#define weakiy(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object;
#else
#define weakiy(object) autoreleasepool{} __block __typeof__(object) block##_##object = object;
#endif
#else
#if __has_feature(objc_arc)
#define weakiy(object) try{} @finally{} {} __weak __typeof__(object) weak##_##object = object;
#else
#define weakiy(object) try{} @finally{} {} __block __typeof__(object) block##_##object = object;
#endif
#endif
#endif
#ifndef strongiy
#if DEBUG
#if __has_feature(objc_arc)
#define strongiy(object) autoreleasepool{} __typeof__(object) object = weak##_##object;
#else
#define strongiy(object) autoreleasepool{} __typeof__(object) object = block##_##object;
#endif
#else
#if __has_feature(objc_arc)
#define strongiy(object) try{} @finally{} __typeof__(object) object = weak##_##object;
#else
#define strongiy(object) try{} @finally{} __typeof__(object) object = block##_##object;
#endif
#endif
#endif
#endif /* YSCMacros_h */
| yangshengchaoios/YSCKit | YSCMacros.h | C | mit | 14,284 |
/* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true}] */
import path from 'path';
import webpack from 'webpack';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
export default {
context: __dirname,
entry: './index.jsx',
output: {
path: `${__dirname}/__dev__`,
publicPath: '/',
filename: 'bundle.js',
},
module: {
loaders: [
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
},
{ test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel-loader' },
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.scss$/, loaders: [
'style-loader',
'css-loader',
'sass-loader?includePaths[]=' + path.resolve(__dirname, './node_modules/compass-mixins/lib')
]},
],
},
resolve: {
extensions: ['.js', '.jsx'],
},
plugins: [
new CopyWebpackPlugin([
{ from: '404.html' },
{ from: 'img', to: 'img' },
{ from: 'fonts', to: 'fonts' }
]),
new HtmlWebpackPlugin({
template: 'index.template.ejs',
inject: 'body'
}),
],
};
| uofo/reverse-archaeology | webpack.config.babel.js | JavaScript | mit | 1,297 |
๏ปฟnamespace VoiceWall.Web.ViewModels.Search
{
using System.ComponentModel.DataAnnotations;
public class SearchViewModel
{
[Required]
[MinLength(2, ErrorMessage="Search text must be at least 2 characters")]
[DataType(DataType.Text)]
public string SearchText { get; set; }
}
} | dzhenko/VoiceWall | src/Web/VoiceWall.Web/ViewModels/Search/SearchViewModel.cs | C# | mit | 324 |
๏ปฟusing SharpDX;
using SharpDX.Direct3D11;
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Xml;
using System.IO;
using System.Reflection;
namespace Profiler.DirectX
{
public class TextManager : IDisposable
{
[StructLayout(LayoutKind.Sequential)]
public struct Vertex
{
public Vector2 Position;
public Vector2 UV;
public SharpDX.Color Color;
}
DynamicBuffer<Vertex> VertexBuffer;
DynamicBuffer<int> IndexBuffer;
Mesh TextMesh;
class Font : IDisposable
{
public struct Symbol
{
public RectangleF UV;
public Size2F Size;
public float Advance;
}
public Symbol[] Symbols = new Symbol[256];
public Texture2D Texture;
public ShaderResourceView TextureView;
public double Size { get; set; }
public static Font Create(Device device, String name)
{
Font font = new Font();
Assembly assembly = Assembly.GetExecutingAssembly();
using (Stream stream = assembly.GetManifestResourceStream(String.Format("Profiler.DirectX.Fonts.{0}.fnt", name)))
{
XmlDocument doc = new XmlDocument();
doc.Load(stream);
XmlNode desc = doc.SelectSingleNode("//info");
font.Size = double.Parse(desc.Attributes["size"].Value);
XmlNode info = doc.SelectSingleNode("//common");
float width = float.Parse(info.Attributes["scaleW"].Value);
float height = float.Parse(info.Attributes["scaleH"].Value);
foreach (XmlNode node in doc.SelectNodes("//char"))
{
int id = int.Parse(node.Attributes["id"].Value);
Symbol symbol = new Symbol();
symbol.Size.Width = float.Parse(node.Attributes["width"].Value);
symbol.Size.Height = float.Parse(node.Attributes["height"].Value);
int x = int.Parse(node.Attributes["x"].Value);
int y = int.Parse(node.Attributes["y"].Value);
symbol.UV = new RectangleF(x / width, y / height, symbol.Size.Width / width, symbol.Size.Height / height);
symbol.Advance = float.Parse(node.Attributes["xadvance"].Value);
font.Symbols[id] = symbol;
}
using (Stream textureStream = assembly.GetManifestResourceStream(String.Format("Profiler.DirectX.Fonts.{0}_0.png", name)))
{
font.Texture = TextureLoader.CreateTex2DFromFile(device, textureStream);
}
font.TextureView = new ShaderResourceView(device, font.Texture);
}
return font;
}
public void Dispose()
{
Utilities.Dispose(ref Texture);
Utilities.Dispose(ref TextureView);
}
}
Font SegoeUI;
public TextManager(DirectX.DirectXCanvas canvas)
{
double baseFontSize = 16.0;
int desiredFontSize = (int)(RenderSettings.dpiScaleY * baseFontSize);
int fontSize = 16;
int[] sizes = { 16, 20, 24, 28, 32 };
for (int i = 0; i < sizes.Length; ++i)
{
if (desiredFontSize < sizes[i])
break;
fontSize = sizes[i];
}
SegoeUI = Font.Create(canvas.RenderDevice, String.Format("SegoeUI_{0}_Normal", fontSize));
VertexBuffer = new DynamicBuffer<Vertex>(canvas.RenderDevice, BindFlags.VertexBuffer);
IndexBuffer = new DynamicBuffer<int>(canvas.RenderDevice, BindFlags.IndexBuffer);
TextMesh = canvas.CreateMesh(DirectXCanvas.MeshType.Text);
TextMesh.UseAlpha = true;
}
public void Draw(System.Windows.Point pos, String text, System.Windows.Media.Color color, TextAlignment alignment = TextAlignment.Left, double maxWidth = double.MaxValue)
{
Color textColor = Utils.Convert(color);
char[] str = text.ToCharArray();
switch (alignment)
{
case TextAlignment.Center:
{
double totalWidth = 0.0;
for (int i = 0; i < str.Length; ++i)
totalWidth += SegoeUI.Symbols[str[i]].Advance;
double shift = Math.Max(0.0, (maxWidth - totalWidth) * 0.5);
Vector2 origin = new Vector2((float)(pos.X + shift), (float)pos.Y);
for (int i = 0; i < str.Length; ++i)
{
Font.Symbol symbol = SegoeUI.Symbols[str[i]];
if (symbol.Size.Width > maxWidth)
break;
Draw(origin, symbol, textColor);
origin.X += symbol.Advance;
maxWidth -= symbol.Advance;
}
}
break;
case TextAlignment.Right:
{
Vector2 origin = new Vector2((float)(pos.X + maxWidth), (float)pos.Y);
for (int i = str.Length - 1; i >= 0; --i)
{
Font.Symbol symbol = SegoeUI.Symbols[str[i]];
origin.X -= symbol.Advance;
if (symbol.Size.Width > maxWidth)
break;
Draw(origin, symbol, textColor);
maxWidth -= symbol.Advance;
}
}
break;
default:
{
Vector2 origin = new Vector2((float)pos.X, (float)pos.Y);
for (int i = 0; i < str.Length; ++i)
{
Font.Symbol symbol = SegoeUI.Symbols[str[i]];
if (symbol.Size.Width > maxWidth)
break;
Draw(origin, symbol, textColor);
origin.X += symbol.Advance;
maxWidth -= symbol.Advance;
}
}
break;
}
}
void Draw(Vector2 pos, Font.Symbol symbol, Color color)
{
VertexBuffer.Add(new Vertex()
{
Position = new Vector2(pos.X, pos.Y),
UV = symbol.UV.TopLeft,
Color = color
});
VertexBuffer.Add(new Vertex()
{
Position = new Vector2(pos.X + symbol.Size.Width, pos.Y),
UV = symbol.UV.TopRight,
Color = color
});
VertexBuffer.Add(new Vertex()
{
Position = new Vector2(pos.X + symbol.Size.Width, pos.Y + symbol.Size.Height),
UV = symbol.UV.BottomRight,
Color = color
});
VertexBuffer.Add(new Vertex()
{
Position = new Vector2(pos.X, pos.Y + symbol.Size.Height),
UV = symbol.UV.BottomLeft,
Color = color
});
}
public void Render(DirectX.DirectXCanvas canvas)
{
Freeze(canvas.RenderDevice);
canvas.RenderDevice.ImmediateContext.PixelShader.SetSampler(0, canvas.TextSamplerState);
canvas.RenderDevice.ImmediateContext.PixelShader.SetShaderResource(0, SegoeUI.TextureView);
canvas.Draw(TextMesh);
}
public void Freeze(Device device)
{
TextMesh.PrimitiveCount = VertexBuffer.Count * 2 / 4;
if (IndexBuffer.Count < TextMesh.PrimitiveCount * 6)
{
IndexBuffer.Capacity = TextMesh.PrimitiveCount * 6;
while (IndexBuffer.Count < TextMesh.PrimitiveCount * 6)
{
int baseIndex = (IndexBuffer.Count * 4) / 6;
foreach (int i in DynamicMesh.BoxTriIndices)
IndexBuffer.Add(baseIndex + i);
}
IndexBuffer.Update(device);
}
VertexBuffer.Update(device);
TextMesh.VertexBuffer = VertexBuffer.Buffer;
TextMesh.IndexBuffer = IndexBuffer.Buffer;
TextMesh.VertexBufferBinding = new VertexBufferBinding(TextMesh.VertexBuffer, Utilites.SizeOf<Vertex>(), 0);
}
public void Dispose()
{
SharpDX.Utilities.Dispose(ref SegoeUI);
SharpDX.Utilities.Dispose(ref TextMesh);
}
}
}
| galek/brofiler | Brofiler/DirectX/TextManager.cs | C# | mit | 9,431 |
<!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_101) on Fri Oct 21 14:35:23 CEST 2016 -->
<title>Uses of Class core.Task</title>
<meta name="date" content="2016-10-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="Uses of Class core.Task";
}
}
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><a href="../../core/Task.html" title="class in core">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../index-files/index-1.html">Index</a></li>
<li><a href="../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../index.html?core/class-use/Task.html" target="_top">Frames</a></li>
<li><a href="Task.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class core.Task" class="title">Uses of Class<br>core.Task</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">
<li class="blockList">
<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing packages, and an explanation">
<caption><span>Packages that use <a href="../../core/Task.html" title="class in core">Task</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Package</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="#core">core</a></td>
<td class="colLast"> </td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<ul class="blockList">
<li class="blockList"><a name="core">
<!-- -->
</a>
<h3>Uses of <a href="../../core/Task.html" title="class in core">Task</a> in <a href="../../core/package-summary.html">core</a></h3>
<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing subclasses, and an explanation">
<caption><span>Subclasses of <a href="../../core/Task.html" title="class in core">Task</a> in <a href="../../core/package-summary.html">core</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Class and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code>class </code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../core/BasicTask.html" title="class in core">BasicTask</a></span></code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>class </code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../core/ProgrammedEvent.html" title="class in core">ProgrammedEvent</a></span></code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>class </code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../core/SpecialTask.html" title="class in core">SpecialTask</a></span></code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>class </code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../core/TaskSequence.html" title="class in core">TaskSequence</a></span></code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>class </code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../core/TimedTask.html" title="class in core">TimedTask</a></span></code> </td>
</tr>
</tbody>
</table>
<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing fields, and an explanation">
<caption><span>Fields in <a href="../../core/package-summary.html">core</a> declared as <a href="../../core/Task.html" title="class in core">Task</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code>private <a href="../../core/Task.html" title="class in core">Task</a></code></td>
<td class="colLast"><span class="typeNameLabel">Interval.</span><code><span class="memberNameLink"><a href="../../core/Interval.html#fatherTask">fatherTask</a></span></code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>private <a href="../../core/Task.html" title="class in core">Task</a></code></td>
<td class="colLast"><span class="typeNameLabel">TaskSequence.</span><code><span class="memberNameLink"><a href="../../core/TaskSequence.html#nextTask">nextTask</a></span></code> </td>
</tr>
</tbody>
</table>
<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation">
<caption><span>Methods in <a href="../../core/package-summary.html">core</a> that return <a href="../../core/Task.html" title="class in core">Task</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code><a href="../../core/Task.html" title="class in core">Task</a></code></td>
<td class="colLast"><span class="typeNameLabel">Interval.</span><code><span class="memberNameLink"><a href="../../core/Interval.html#getFatherTask--">getFatherTask</a></span>()</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../core/Task.html" title="class in core">Task</a></code></td>
<td class="colLast"><span class="typeNameLabel">TimedTask.</span><code><span class="memberNameLink"><a href="../../core/TimedTask.html#getNextTask--">getNextTask</a></span>()</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../core/Task.html" title="class in core">Task</a></code></td>
<td class="colLast"><span class="typeNameLabel">TaskSequence.</span><code><span class="memberNameLink"><a href="../../core/TaskSequence.html#getNextTask--">getNextTask</a></span>()</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>abstract <a href="../../core/Task.html" title="class in core">Task</a></code></td>
<td class="colLast"><span class="typeNameLabel">Task.</span><code><span class="memberNameLink"><a href="../../core/Task.html#getNextTask--">getNextTask</a></span>()</code>
<div class="block">Implemented by decorator SpecialTask subclass TaskSequence</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>abstract <a href="../../core/Task.html" title="class in core">Task</a></code></td>
<td class="colLast"><span class="typeNameLabel">SpecialTask.</span><code><span class="memberNameLink"><a href="../../core/SpecialTask.html#getNextTask--">getNextTask</a></span>()</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../core/Task.html" title="class in core">Task</a></code></td>
<td class="colLast"><span class="typeNameLabel">ProgrammedEvent.</span><code><span class="memberNameLink"><a href="../../core/ProgrammedEvent.html#getNextTask--">getNextTask</a></span>()</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../core/Task.html" title="class in core">Task</a></code></td>
<td class="colLast"><span class="typeNameLabel">BasicTask.</span><code><span class="memberNameLink"><a href="../../core/BasicTask.html#getNextTask--">getNextTask</a></span>()</code> </td>
</tr>
</tbody>
</table>
<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation">
<caption><span>Methods in <a href="../../core/package-summary.html">core</a> with parameters of type <a href="../../core/Task.html" title="class in core">Task</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><span class="typeNameLabel">Interval.</span><code><span class="memberNameLink"><a href="../../core/Interval.html#setFatherTask-core.Task-">setFatherTask</a></span>(<a href="../../core/Task.html" title="class in core">Task</a> nfatherTask)</code> </td>
</tr>
</tbody>
</table>
<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing constructors, and an explanation">
<caption><span>Constructors in <a href="../../core/package-summary.html">core</a> with parameters of type <a href="../../core/Task.html" title="class in core">Task</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colLast"><code><span class="memberNameLink"><a href="../../core/Interval.html#Interval-java.lang.String-java.lang.String-core.Task-">Interval</a></span>(java.lang.String name,
java.lang.String description,
<a href="../../core/Task.html" title="class in core">Task</a> fatherTask)</code>
<div class="block">Constructs an interval</div>
</td>
</tr>
<tr class="rowColor">
<td class="colLast"><code><span class="memberNameLink"><a href="../../core/TaskSequence.html#TaskSequence-java.lang.String-java.lang.String-core.Project-java.util.ArrayList-core.Task-">TaskSequence</a></span>(java.lang.String name,
java.lang.String description,
<a href="../../core/Project.html" title="class in core">Project</a> father,
java.util.ArrayList<<a href="../../core/Activity.html" title="class in core">Activity</a>> root,
<a href="../../core/Task.html" title="class in core">Task</a> nnextTask)</code>
<div class="block">Task sequence constructor</div>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
</li>
</ul>
</div>
<!-- ======= 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><a href="../../core/Task.html" title="class in core">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../index-files/index-1.html">Index</a></li>
<li><a href="../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../index.html?core/class-use/Task.html" target="_top">Frames</a></li>
<li><a href="Task.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
| drkztan/javaTimeTracker | doc/core/class-use/Task.html | HTML | mit | 12,762 |
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;
string experiment;
for(cin>>n; n>0; n--){
cin >> experiment;
if (experiment.size() < 3) cout << '+' << endl;
else{
string s = experiment.substr(experiment.size()-2, 2);
string saux;
if(s == "35") cout << '-' << endl;
else{
s = s[1];
saux = experiment[0];
if(saux == "9" && s == "4") cout << '*' << endl;
else{
s = experiment.substr(0,3);
if(s == "190") cout << '?' << endl;
else cout << '?' << endl;
}
}
}
}
return 0;
}
| DVRodri8/Competitive-programs | OnlineJudgeUVa/C++/100-9999/621 - Secret Research/main.cpp | C++ | mit | 626 |
import urllib
import urllib2
from bs4 import BeautifulSoup
textToSearch = 'gorillaz'
query = urllib.quote(textToSearch)
url = "https://www.youtube.com/results?search_query=" + query
response = urllib2.urlopen(url)
html = response.read()
soup = BeautifulSoup(html)
for vid in soup.findAll(attrs={'class':'yt-uix-tile-link'}):
print 'https://www.youtube.com' + vid['href']
| arbakker/yt-daemon | search_yt.py | Python | mit | 380 |
"use strict"
var o = require("../../ospec/ospec")
var callAsync = require("../../test-utils/callAsync")
var browserMock = require("../../test-utils/browserMock")
var m = require("../../render/hyperscript")
var callAsync = require("../../test-utils/callAsync")
var coreRenderer = require("../../render/render")
var apiRedraw = require("../../api/redraw")
var apiRouter = require("../../api/router")
var Promise = require("../../promise/promise")
o.spec("route", function() {
void [{protocol: "http:", hostname: "localhost"}, {protocol: "file:", hostname: "/"}].forEach(function(env) {
void ["#", "?", "", "#!", "?!", "/foo"].forEach(function(prefix) {
o.spec("using prefix `" + prefix + "` starting on " + env.protocol + "//" + env.hostname, function() {
var FRAME_BUDGET = Math.floor(1000 / 60)
var $window, root, redrawService, route
o.beforeEach(function() {
$window = browserMock(env)
root = $window.document.body
redrawService = apiRedraw($window)
route = apiRouter($window, redrawService)
route.prefix(prefix)
})
o("throws on invalid `root` DOM node", function() {
var threw = false
try {
route(null, '/', {'/':{view: function() {}}})
} catch (e) {
threw = true
}
o(threw).equals(true)
})
o("renders into `root`", function() {
$window.location.href = prefix + "/"
route(root, "/", {
"/" : {
view: function() {
return m("div")
}
}
})
o(root.firstChild.nodeName).equals("DIV")
})
o("routed mount points can redraw synchronously (#1275)", function() {
var view = o.spy()
$window.location.href = prefix + "/"
route(root, "/", {"/":{view:view}})
o(view.callCount).equals(1)
redrawService.redraw()
o(view.callCount).equals(2)
})
o("default route doesn't break back button", function(done) {
$window.location.href = "http://old.com"
$window.location.href = "http://new.com"
route(root, "/a", {
"/a" : {
view: function() {
return m("div")
}
}
})
callAsync(function() {
o(root.firstChild.nodeName).equals("DIV")
o(route.get()).equals("/a")
$window.history.back()
o($window.location.pathname).equals("/")
o($window.location.hostname).equals("old.com")
done()
})
})
o("default route does not inherit params", function(done) {
$window.location.href = "/invalid?foo=bar"
route(root, "/a", {
"/a" : {
oninit: init,
view: function() {
return m("div")
}
}
})
function init(vnode) {
o(vnode.attrs.foo).equals(undefined)
done()
}
})
o("redraws when render function is executed", function() {
var onupdate = o.spy()
var oninit = o.spy()
$window.location.href = prefix + "/"
route(root, "/", {
"/" : {
view: function() {
return m("div", {
oninit: oninit,
onupdate: onupdate
})
}
}
})
o(oninit.callCount).equals(1)
redrawService.redraw()
o(onupdate.callCount).equals(1)
})
o("redraws on events", function(done) {
var onupdate = o.spy()
var oninit = o.spy()
var onclick = o.spy()
var e = $window.document.createEvent("MouseEvents")
e.initEvent("click", true, true)
$window.location.href = prefix + "/"
route(root, "/", {
"/" : {
view: function() {
return m("div", {
oninit: oninit,
onupdate: onupdate,
onclick: onclick,
})
}
}
})
root.firstChild.dispatchEvent(e)
o(oninit.callCount).equals(1)
o(onclick.callCount).equals(1)
o(onclick.this).equals(root.firstChild)
o(onclick.args[0].type).equals("click")
o(onclick.args[0].target).equals(root.firstChild)
// Wrapped to give time for the rate-limited redraw to fire
callAsync(function() {
o(onupdate.callCount).equals(1)
done()
})
})
o("event handlers can skip redraw", function(done) {
var onupdate = o.spy()
var oninit = o.spy()
var onclick = o.spy()
var e = $window.document.createEvent("MouseEvents")
e.initEvent("click", true, true)
$window.location.href = prefix + "/"
route(root, "/", {
"/" : {
view: function() {
return m("div", {
oninit: oninit,
onupdate: onupdate,
onclick: function(e) {
e.redraw = false
},
})
}
}
})
root.firstChild.dispatchEvent(e)
o(oninit.callCount).equals(1)
// Wrapped to ensure no redraw fired
callAsync(function() {
o(onupdate.callCount).equals(0)
done()
})
})
o("changes location on route.link", function() {
var e = $window.document.createEvent("MouseEvents")
e.initEvent("click", true, true)
$window.location.href = prefix + "/"
route(root, "/", {
"/" : {
view: function() {
return m("a", {
href: "/test",
oncreate: route.link
})
}
},
"/test" : {
view : function() {
return m("div")
}
}
})
var slash = prefix[0] === "/" ? "" : "/"
o($window.location.href).equals(env.protocol + "//" + (env.hostname === "/" ? "" : env.hostname) + slash + (prefix ? prefix + "/" : ""))
root.firstChild.dispatchEvent(e)
o($window.location.href).equals(env.protocol + "//" + (env.hostname === "/" ? "" : env.hostname) + slash + (prefix ? prefix + "/" : "") + "test")
})
o("accepts RouteResolver with onmatch that returns Component", function(done) {
var matchCount = 0
var renderCount = 0
var Component = {
view: function() {
return m("span")
}
}
var resolver = {
onmatch: function(args, requestedPath) {
matchCount++
o(args.id).equals("abc")
o(requestedPath).equals("/abc")
o(this).equals(resolver)
return Component
},
render: function(vnode) {
renderCount++
o(vnode.attrs.id).equals("abc")
o(this).equals(resolver)
return vnode
},
}
$window.location.href = prefix + "/abc"
route(root, "/abc", {
"/:id" : resolver
})
callAsync(function() {
o(matchCount).equals(1)
o(renderCount).equals(1)
o(root.firstChild.nodeName).equals("SPAN")
done()
})
})
o("accepts RouteResolver with onmatch that returns Promise<Component>", function(done) {
var matchCount = 0
var renderCount = 0
var Component = {
view: function() {
return m("span")
}
}
var resolver = {
onmatch: function(args, requestedPath) {
matchCount++
o(args.id).equals("abc")
o(requestedPath).equals("/abc")
o(this).equals(resolver)
return Promise.resolve(Component)
},
render: function(vnode) {
renderCount++
o(vnode.attrs.id).equals("abc")
o(this).equals(resolver)
return vnode
},
}
$window.location.href = prefix + "/abc"
route(root, "/abc", {
"/:id" : resolver
})
callAsync(function() {
o(matchCount).equals(1)
o(renderCount).equals(1)
o(root.firstChild.nodeName).equals("SPAN")
done()
})
})
o("accepts RouteResolver with onmatch that returns Promise<undefined>", function(done) {
var matchCount = 0
var renderCount = 0
var Component = {
view: function() {
return m("span")
}
}
var resolver = {
onmatch: function(args, requestedPath) {
matchCount++
o(args.id).equals("abc")
o(requestedPath).equals("/abc")
o(this).equals(resolver)
return Promise.resolve()
},
render: function(vnode) {
renderCount++
o(vnode.attrs.id).equals("abc")
o(this).equals(resolver)
return vnode
},
}
$window.location.href = prefix + "/abc"
route(root, "/abc", {
"/:id" : resolver
})
callAsync(function() {
o(matchCount).equals(1)
o(renderCount).equals(1)
o(root.firstChild.nodeName).equals("DIV")
done()
})
})
o("accepts RouteResolver with onmatch that returns Promise<any>", function(done) {
var matchCount = 0
var renderCount = 0
var Component = {
view: function() {
return m("span")
}
}
var resolver = {
onmatch: function(args, requestedPath) {
matchCount++
o(args.id).equals("abc")
o(requestedPath).equals("/abc")
o(this).equals(resolver)
return Promise.resolve([])
},
render: function(vnode) {
renderCount++
o(vnode.attrs.id).equals("abc")
o(this).equals(resolver)
return vnode
},
}
$window.location.href = prefix + "/abc"
route(root, "/abc", {
"/:id" : resolver
})
callAsync(function() {
o(matchCount).equals(1)
o(renderCount).equals(1)
o(root.firstChild.nodeName).equals("DIV")
done()
})
})
o("accepts RouteResolver with onmatch that returns rejected Promise", function(done) {
var matchCount = 0
var renderCount = 0
var spy = o.spy()
var Component = {
view: function() {
return m("span")
}
}
var resolver = {
onmatch: function(args, requestedPath) {
matchCount++
return Promise.reject(new Error("error"))
},
render: function(vnode) {
renderCount++
return vnode
},
}
$window.location.href = prefix + "/test/1"
route(root, "/default", {
"/default" : {view: spy},
"/test/:id" : resolver
})
callAsync(function() {
callAsync(function() {
o(matchCount).equals(1)
o(renderCount).equals(0)
o(spy.callCount).equals(1)
done()
})
})
})
o("accepts RouteResolver without `render` method as payload", function(done) {
var matchCount = 0
var Component = {
view: function() {
return m("div")
}
}
$window.location.href = prefix + "/abc"
route(root, "/abc", {
"/:id" : {
onmatch: function(args, requestedPath) {
matchCount++
o(args.id).equals("abc")
o(requestedPath).equals("/abc")
return Component
},
},
})
callAsync(function() {
o(matchCount).equals(1)
o(root.firstChild.nodeName).equals("DIV")
done()
})
})
o("changing `vnode.key` in `render` resets the component", function(done, timeout){
var oninit = o.spy()
var Component = {
oninit: oninit,
view: function() {
return m("div")
}
}
$window.location.href = prefix + "/abc"
route(root, "/abc", {
"/:id": {render: function(vnode) {
return m(Component, {key: vnode.attrs.id})
}}
})
callAsync(function() {
o(oninit.callCount).equals(1)
route.set("/def")
callAsync(function() {
o(oninit.callCount).equals(2)
done()
})
})
})
o("accepts RouteResolver without `onmatch` method as payload", function() {
var renderCount = 0
var Component = {
view: function() {
return m("div")
}
}
$window.location.href = prefix + "/abc"
route(root, "/abc", {
"/:id" : {
render: function(vnode) {
renderCount++
o(vnode.attrs.id).equals("abc")
return m(Component)
},
},
})
o(root.firstChild.nodeName).equals("DIV")
})
o("RouteResolver `render` does not have component semantics", function(done) {
var renderCount = 0
var A = {
view: function() {
return m("div")
}
}
$window.location.href = prefix + "/a"
route(root, "/a", {
"/a" : {
render: function(vnode) {
return m("div")
},
},
"/b" : {
render: function(vnode) {
return m("div")
},
},
})
var dom = root.firstChild
o(root.firstChild.nodeName).equals("DIV")
route.set("/b")
callAsync(function() {
o(root.firstChild).equals(dom)
done()
})
})
o("calls onmatch and view correct number of times", function(done) {
var matchCount = 0
var renderCount = 0
var Component = {
view: function() {
return m("div")
}
}
$window.location.href = prefix + "/"
route(root, "/", {
"/" : {
onmatch: function() {
matchCount++
return Component
},
render: function(vnode) {
renderCount++
return vnode
},
},
})
callAsync(function() {
o(matchCount).equals(1)
o(renderCount).equals(1)
redrawService.redraw()
o(matchCount).equals(1)
o(renderCount).equals(2)
done()
})
})
o("calls onmatch and view correct number of times when not onmatch returns undefined", function(done) {
var matchCount = 0
var renderCount = 0
var Component = {
view: function() {
return m("div")
}
}
$window.location.href = prefix + "/"
route(root, "/", {
"/" : {
onmatch: function() {
matchCount++
},
render: function(vnode) {
renderCount++
return {tag: Component}
},
},
})
callAsync(function() {
o(matchCount).equals(1)
o(renderCount).equals(1)
redrawService.redraw()
o(matchCount).equals(1)
o(renderCount).equals(2)
done()
})
})
o("onmatch can redirect to another route", function(done) {
var redirected = false
var render = o.spy()
$window.location.href = prefix + "/a"
route(root, "/a", {
"/a" : {
onmatch: function() {
route.set("/b")
},
render: render
},
"/b" : {
view: function() {
redirected = true
}
}
})
callAsync(function() {
o(render.callCount).equals(0)
o(redirected).equals(true)
done()
})
})
o("onmatch can redirect to another route that has RouteResolver w/ only onmatch", function(done) {
var redirected = false
var render = o.spy()
var view = o.spy(function() {return m("div")})
$window.location.href = prefix + "/a"
route(root, "/a", {
"/a" : {
onmatch: function() {
route.set("/b")
},
render: render
},
"/b" : {
onmatch: function() {
redirected = true
return {view: view}
}
}
})
callAsync(function() {
callAsync(function() {
o(render.callCount).equals(0)
o(redirected).equals(true)
o(view.callCount).equals(1)
o(root.childNodes.length).equals(1)
o(root.firstChild.nodeName).equals("DIV")
done()
})
})
})
o("onmatch can redirect to another route that has RouteResolver w/ only render", function(done) {
var redirected = false
var render = o.spy()
$window.location.href = prefix + "/a"
route(root, "/a", {
"/a" : {
onmatch: function() {
route.set("/b")
},
render: render
},
"/b" : {
render: function(vnode){
redirected = true
}
}
})
callAsync(function() {
o(render.callCount).equals(0)
o(redirected).equals(true)
done()
})
})
o("onmatch can redirect to another route that has RouteResolver whose onmatch resolves asynchronously", function(done) {
var redirected = false
var render = o.spy()
var view = o.spy()
$window.location.href = prefix + "/a"
route(root, "/a", {
"/a" : {
onmatch: function() {
route.set("/b")
},
render: render
},
"/b" : {
onmatch: function() {
redirected = true
return new Promise(function(fulfill){
callAsync(function(){
fulfill({view: view})
})
})
}
}
})
callAsync(function() {
callAsync(function() {
callAsync(function() {
o(render.callCount).equals(0)
o(redirected).equals(true)
o(view.callCount).equals(1)
done()
})
})
})
})
o("onmatch can redirect to another route asynchronously", function(done) {
var redirected = false
var render = o.spy()
var view = o.spy()
$window.location.href = prefix + "/a"
route(root, "/a", {
"/a" : {
onmatch: function() {
callAsync(function() {route.set("/b")})
return new Promise(function() {})
},
render: render
},
"/b" : {
onmatch: function() {
redirected = true
return {view: view}
}
}
})
callAsync(function() {
callAsync(function() {
callAsync(function() {
o(render.callCount).equals(0)
o(redirected).equals(true)
o(view.callCount).equals(1)
done()
})
})
})
})
o("onmatch can redirect w/ window.history.back()", function(done) {
var render = o.spy()
var component = {view: o.spy()}
$window.location.href = prefix + "/a"
route(root, "/a", {
"/a" : {
onmatch: function() {
return component
},
render: function(vnode) {
return vnode
}
},
"/b" : {
onmatch: function() {
$window.history.back()
return new Promise(function() {})
},
render: render
}
})
callAsync(function() {
route.set('/b')
callAsync(function() {
callAsync(function() {
callAsync(function() {
o(render.callCount).equals(0)
o(component.view.callCount).equals(2)
done()
})
})
})
})
})
o("onmatch can redirect to a non-existent route that defaults to a RouteResolver w/ onmatch", function(done) {
var redirected = false
var render = o.spy()
$window.location.href = prefix + "/a"
route(root, "/b", {
"/a" : {
onmatch: function() {
route.set("/c")
},
render: render
},
"/b" : {
onmatch: function(vnode){
redirected = true
return {view: function() {}}
}
}
})
callAsync(function() {
callAsync(function() {
o(render.callCount).equals(0)
o(redirected).equals(true)
done()
})
})
})
o("onmatch can redirect to a non-existent route that defaults to a RouteResolver w/ render", function(done) {
var redirected = false
var render = o.spy()
$window.location.href = prefix + "/a"
route(root, "/b", {
"/a" : {
onmatch: function() {
route.set("/c")
},
render: render
},
"/b" : {
render: function(vnode){
redirected = true
}
}
})
callAsync(function() {
callAsync(function() {
o(render.callCount).equals(0)
o(redirected).equals(true)
done()
})
})
})
o("onmatch can redirect to a non-existent route that defaults to a component", function(done) {
var redirected = false
var render = o.spy()
$window.location.href = prefix + "/a"
route(root, "/b", {
"/a" : {
onmatch: function() {
route.set("/c")
},
render: render
},
"/b" : {
view: function(vnode){
redirected = true
}
}
})
callAsync(function() {
callAsync(function() {
o(render.callCount).equals(0)
o(redirected).equals(true)
done()
})
})
})
o("the previous view redraws while onmatch resolution is pending (#1268)", function(done) {
var view = o.spy()
var onmatch = o.spy(function() {
return new Promise(function() {})
})
$window.location.href = prefix + "/a"
route(root, "/", {
"/a": {view: view},
"/b": {onmatch: onmatch}
})
o(view.callCount).equals(1)
o(onmatch.callCount).equals(0)
route.set("/b")
callAsync(function() {
o(view.callCount).equals(1)
o(onmatch.callCount).equals(1)
redrawService.redraw()
o(view.callCount).equals(2)
o(onmatch.callCount).equals(1)
done()
})
})
o("when two async routes are racing, the last one set cancels the finalization of the first", function(done) {
var renderA = o.spy()
var renderB = o.spy()
var onmatchA = o.spy(function(){
return new Promise(function(fulfill) {
setTimeout(function(){
fulfill()
}, 10)
})
})
$window.location.href = prefix + "/a"
route(root, "/a", {
"/a": {
onmatch: onmatchA,
render: renderA
},
"/b": {
onmatch: function(){
var p = new Promise(function(fulfill) {
o(onmatchA.callCount).equals(1)
o(renderA.callCount).equals(0)
o(renderB.callCount).equals(0)
setTimeout(function(){
o(onmatchA.callCount).equals(1)
o(renderA.callCount).equals(0)
o(renderB.callCount).equals(0)
fulfill()
p.then(function(){
o(onmatchA.callCount).equals(1)
o(renderA.callCount).equals(0)
o(renderB.callCount).equals(1)
done()
})
}, 20)
})
return p
},
render: renderB
}
})
callAsync(function() {
o(onmatchA.callCount).equals(1)
o(renderA.callCount).equals(0)
o(renderB.callCount).equals(0)
route.set("/b")
o(onmatchA.callCount).equals(1)
o(renderA.callCount).equals(0)
o(renderB.callCount).equals(0)
})
})
o("m.route.set(m.route.get()) re-runs the resolution logic (#1180)", function(done){
var onmatch = o.spy()
var render = o.spy(function() {return m("div")})
$window.location.href = prefix + "/"
route(root, '/', {
"/": {
onmatch: onmatch,
render: render
}
})
callAsync(function() {
o(onmatch.callCount).equals(1)
o(render.callCount).equals(1)
route.set(route.get())
callAsync(function() {
callAsync(function() {
o(onmatch.callCount).equals(2)
o(render.callCount).equals(2)
done()
})
})
})
})
o("m.route.get() returns the last fully resolved route (#1276)", function(done){
$window.location.href = prefix + "/"
route(root, "/", {
"/": {view: function() {}},
"/2": {
onmatch: function() {
return new Promise(function() {})
}
}
})
o(route.get()).equals("/")
route.set("/2")
callAsync(function() {
o(route.get()).equals("/")
done()
})
})
o("routing with RouteResolver works more than once", function(done) {
$window.location.href = prefix + "/a"
route(root, '/a', {
'/a': {
render: function() {
return m("a", "a")
}
},
'/b': {
render: function() {
return m("b", "b")
}
}
})
route.set('/b')
callAsync(function() {
route.set('/a')
callAsync(function() {
o(root.firstChild.nodeName).equals("A")
done()
})
})
})
o("calling route.set invalidates pending onmatch resolution", function(done) {
var rendered = false
var resolved
$window.location.href = prefix + "/a"
route(root, "/a", {
"/a": {
onmatch: function() {
return new Promise(function(resolve) {
callAsync(function() {
callAsync(function() {
resolve({view: function() {rendered = true}})
})
})
})
},
render: function(vnode) {
rendered = true
resolved = "a"
}
},
"/b": {
view: function() {
resolved = "b"
}
}
})
route.set("/b")
callAsync(function() {
o(rendered).equals(false)
o(resolved).equals("b")
callAsync(function() {
o(rendered).equals(false)
o(resolved).equals("b")
done()
})
})
})
o("route changes activate onbeforeremove", function(done) {
var spy = o.spy()
$window.location.href = prefix + "/a"
route(root, "/a", {
"/a": {
onbeforeremove: spy,
view: function() {}
},
"/b": {
view: function() {}
}
})
route.set("/b")
callAsync(function() {
o(spy.callCount).equals(1)
done()
})
})
o("asynchronous route.set in onmatch works", function(done) {
var rendered = false, resolved
route(root, "/a", {
"/a": {
onmatch: function() {
return Promise.resolve().then(function() {
route.set("/b")
})
},
render: function(vnode) {
rendered = true
resolved = "a"
}
},
"/b": {
view: function() {
resolved = "b"
}
},
})
callAsync(function() { // tick for popstate for /a
callAsync(function() { // tick for promise in onmatch
callAsync(function() { // tick for onpopstate for /b
o(rendered).equals(false)
o(resolved).equals("b")
done()
})
})
})
})
o("throttles", function(done, timeout) {
timeout(200)
var i = 0
$window.location.href = prefix + "/"
route(root, "/", {
"/": {view: function(v) {i++}}
})
var before = i
redrawService.redraw()
redrawService.redraw()
redrawService.redraw()
redrawService.redraw()
var after = i
setTimeout(function() {
o(before).equals(1) // routes synchronously
o(after).equals(2) // redraws synchronously
o(i).equals(3) // throttles rest
done()
}, FRAME_BUDGET * 2)
})
o("m.route.param is available outside of route handlers", function(done) {
$window.location.href = prefix + "/"
route(root, "/1", {
"/:id" : {
view : function() {
o(route.param("id")).equals("1")
return m("div")
}
}
})
o(route.param("id")).equals(undefined);
o(route.param()).deepEquals(undefined);
callAsync(function() {
o(route.param("id")).equals("1")
o(route.param()).deepEquals({id:"1"})
done()
})
})
})
})
})
})
| jsguy/slides | resource/mithril.js-rewrite/api/tests/test-router.js | JavaScript | mit | 26,809 |
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
Math.sqrt, recommended that implementations use the approximation
algorithms for IEEE 754 arithmetic contained in fdlibm
es5id: 15.8.2.17_A6
description: >
Checking if Math.sqrt is approximately equals to its mathematical
values on the set of 64 argument values; all the sample values is
calculated with LibC
includes:
- math_precision.js
- math_isequal.js
---*/
// CHECK#1
vnum = 64;
var x = new Array();
x[0] = 0.00000000000000000000;
x[1] = 0.25396825396825395000;
x[2] = 0.50793650793650791000;
x[3] = 0.76190476190476186000;
x[4] = 1.01587301587301580000;
x[5] = 1.26984126984126980000;
x[6] = 1.52380952380952370000;
x[7] = 1.77777777777777770000;
x[8] = 2.03174603174603160000;
x[9] = 2.28571428571428560000;
x[10] = 2.53968253968253950000;
x[11] = 2.79365079365079350000;
x[12] = 3.04761904761904740000;
x[13] = 3.30158730158730140000;
x[14] = 3.55555555555555540000;
x[15] = 3.80952380952380930000;
x[16] = 4.06349206349206330000;
x[17] = 4.31746031746031720000;
x[18] = 4.57142857142857120000;
x[19] = 4.82539682539682510000;
x[20] = 5.07936507936507910000;
x[21] = 5.33333333333333300000;
x[22] = 5.58730158730158700000;
x[23] = 5.84126984126984090000;
x[24] = 6.09523809523809490000;
x[25] = 6.34920634920634890000;
x[26] = 6.60317460317460280000;
x[27] = 6.85714285714285680000;
x[28] = 7.11111111111111070000;
x[29] = 7.36507936507936470000;
x[30] = 7.61904761904761860000;
x[31] = 7.87301587301587260000;
x[32] = 8.12698412698412650000;
x[33] = 8.38095238095238140000;
x[34] = 8.63492063492063440000;
x[35] = 8.88888888888888930000;
x[36] = 9.14285714285714230000;
x[37] = 9.39682539682539720000;
x[38] = 9.65079365079365030000;
x[39] = 9.90476190476190510000;
x[40] = 10.15873015873015800000;
x[41] = 10.41269841269841300000;
x[42] = 10.66666666666666600000;
x[43] = 10.92063492063492100000;
x[44] = 11.17460317460317400000;
x[45] = 11.42857142857142900000;
x[46] = 11.68253968253968200000;
x[47] = 11.93650793650793700000;
x[48] = 12.19047619047619000000;
x[49] = 12.44444444444444500000;
x[50] = 12.69841269841269800000;
x[51] = 12.95238095238095300000;
x[52] = 13.20634920634920600000;
x[53] = 13.46031746031746000000;
x[54] = 13.71428571428571400000;
x[55] = 13.96825396825396800000;
x[56] = 14.22222222222222100000;
x[57] = 14.47619047619047600000;
x[58] = 14.73015873015872900000;
x[59] = 14.98412698412698400000;
x[60] = 15.23809523809523700000;
x[61] = 15.49206349206349200000;
x[62] = 15.74603174603174500000;
x[63] = 16.00000000000000000000;
var y = new Array();
y[0] = 0.00000000000000000000;
y[1] = 0.50395263067896967000;
y[2] = 0.71269664509979835000;
y[3] = 0.87287156094396945000;
y[4] = 1.00790526135793930000;
y[5] = 1.12687233963802200000;
y[6] = 1.23442679969673530000;
y[7] = 1.33333333333333330000;
y[8] = 1.42539329019959670000;
y[9] = 1.51185789203690880000;
y[10] = 1.59363814577919150000;
y[11] = 1.67142178807468980000;
y[12] = 1.74574312188793890000;
y[13] = 1.81702705031799170000;
y[14] = 1.88561808316412670000;
y[15] = 1.95180014589706640000;
y[16] = 2.01581052271587870000;
y[17] = 2.07784992659727900000;
y[18] = 2.13808993529939520000;
y[19] = 2.19667858946110380000;
y[20] = 2.25374467927604400000;
y[21] = 2.30940107675850290000;
y[22] = 2.36374736114111530000;
y[23] = 2.41687191246657520000;
y[24] = 2.46885359939347060000;
y[25] = 2.51976315339484810000;
y[26] = 2.56966429775848400000;
y[27] = 2.61861468283190830000;
y[28] = 2.66666666666666650000;
y[29] = 2.71386797119523940000;
y[30] = 2.76026223736941700000;
y[31] = 2.80588949764880670000;
y[32] = 2.85078658039919340000;
y[33] = 2.89498745782298350000;
y[34] = 2.93852354676981160000;
y[35] = 2.98142396999971960000;
y[36] = 3.02371578407381760000;
y[37] = 3.06542417893925380000;
y[38] = 3.10657265339049320000;
y[39] = 3.14718316987777280000;
y[40] = 3.18727629155838300000;
y[41] = 3.22687130401855570000;
y[42] = 3.26598632371090410000;
y[43] = 3.30463839483761390000;
y[44] = 3.34284357614937950000;
y[45] = 3.38061701891406630000;
y[46] = 3.41797303712883060000;
y[47] = 3.45492517089848670000;
y[48] = 3.49148624377587780000;
y[49] = 3.52766841475278750000;
y[50] = 3.56348322549899170000;
y[51] = 3.59894164336974940000;
y[52] = 3.63405410063598340000;
y[53] = 3.66883053033489940000;
y[54] = 3.70328039909020570000;
y[55] = 3.73741273720925400000;
y[56] = 3.77123616632825340000;
y[57] = 3.80475892484536750000;
y[58] = 3.83798889135426350000;
y[59] = 3.87093360626696680000;
y[60] = 3.90360029179413280000;
y[61] = 3.93599587043272870000;
y[62] = 3.96812698209517300000;
y[63] = 4.00000000000000000000;
var val;
for (i = 0; i < vnum; i++)
{
val = Math.sqrt(x[i]);
if (!isEqual(val, y[i]))
{
$ERROR("\nx = " + x[i] + "\nlibc.sqrt(x) = " + y[i] + "\nMath.sqrt(x) = " + Math.sqrt(x[i]) + "\nMath.abs(libc.sqrt(x) - Math.sqrt(x)) > " + prec + "\n\n");
}
}
| PiotrDabkowski/Js2Py | tests/test_cases/built-ins/Math/sqrt/S15.8.2.17_A6.js | JavaScript | mit | 4,964 |
๏ปฟ///////////////////////////////////////////////////////////////
// This is generated code.
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 4.2
// Code is generated on:
// Code is generated using templates: SD.TemplateBindings.SharedTemplates
// Templates vendor: Solutions Design.
// Templates version:
//////////////////////////////////////////////////////////////
using System;
using System.Collections;
using System.Collections.Generic;
using AdventureWorks.Dal;
using AdventureWorks.Dal.FactoryClasses;
using AdventureWorks.Dal.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
namespace AdventureWorks.Dal.RelationClasses
{
/// <summary>Implements the relations factory for the entity: WorkOrderRouting. </summary>
public partial class WorkOrderRoutingRelations
{
/// <summary>CTor</summary>
public WorkOrderRoutingRelations()
{
}
/// <summary>Gets all relations of the WorkOrderRoutingEntity as a list of IEntityRelation objects.</summary>
/// <returns>a list of IEntityRelation objects</returns>
public virtual List<IEntityRelation> GetAllRelations()
{
List<IEntityRelation> toReturn = new List<IEntityRelation>();
toReturn.Add(this.LocationEntityUsingLocationId);
toReturn.Add(this.WorkOrderEntityUsingWorkOrderId);
return toReturn;
}
#region Class Property Declarations
/// <summary>Returns a new IEntityRelation object, between WorkOrderRoutingEntity and LocationEntity over the m:1 relation they have, using the relation between the fields:
/// WorkOrderRouting.LocationId - Location.LocationId
/// </summary>
public virtual IEntityRelation LocationEntityUsingLocationId
{
get
{
IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "Location", false);
relation.AddEntityFieldPair(LocationFields.LocationId, WorkOrderRoutingFields.LocationId);
relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("LocationEntity", false);
relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("WorkOrderRoutingEntity", true);
return relation;
}
}
/// <summary>Returns a new IEntityRelation object, between WorkOrderRoutingEntity and WorkOrderEntity over the m:1 relation they have, using the relation between the fields:
/// WorkOrderRouting.WorkOrderId - WorkOrder.WorkOrderId
/// </summary>
public virtual IEntityRelation WorkOrderEntityUsingWorkOrderId
{
get
{
IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "WorkOrder", false);
relation.AddEntityFieldPair(WorkOrderFields.WorkOrderId, WorkOrderRoutingFields.WorkOrderId);
relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("WorkOrderEntity", false);
relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("WorkOrderRoutingEntity", true);
return relation;
}
}
/// <summary>stub, not used in this entity, only for TargetPerEntity entities.</summary>
public virtual IEntityRelation GetSubTypeRelation(string subTypeEntityName) { return null; }
/// <summary>stub, not used in this entity, only for TargetPerEntity entities.</summary>
public virtual IEntityRelation GetSuperTypeRelation() { return null;}
#endregion
#region Included Code
#endregion
}
/// <summary>Static class which is used for providing relationship instances which are re-used internally for syncing</summary>
internal static class StaticWorkOrderRoutingRelations
{
internal static readonly IEntityRelation LocationEntityUsingLocationIdStatic = new WorkOrderRoutingRelations().LocationEntityUsingLocationId;
internal static readonly IEntityRelation WorkOrderEntityUsingWorkOrderIdStatic = new WorkOrderRoutingRelations().WorkOrderEntityUsingWorkOrderId;
/// <summary>CTor</summary>
static StaticWorkOrderRoutingRelations()
{
}
}
}
| net-industry/llblgen-training | AdventureWorks.Dal/DatabaseGeneric/RelationClasses/WorkOrderRoutingRelations.cs | C# | mit | 4,089 |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include <avro/platform.h>
#include <stdlib.h>
#include <string.h>
#include "avro_private.h"
#include "avro/allocation.h"
#include "avro/basics.h"
#include "avro/data.h"
#include "avro/errors.h"
#include "avro/refcount.h"
#include "avro/resolver.h"
#include "avro/schema.h"
#include "avro/value.h"
#include "st.h"
#ifndef AVRO_RESOLVER_DEBUG
#define AVRO_RESOLVER_DEBUG 0
#endif
#if AVRO_RESOLVER_DEBUG
#include <stdio.h>
#define AVRO_DEBUG(...) \
do { \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
} while (0)
#else
#define AVRO_DEBUG(...) /* don't print messages */
#endif
typedef struct avro_resolved_reader avro_resolved_reader_t;
struct avro_resolved_reader {
avro_value_iface_t parent;
/** The reference count for this interface. */
volatile int refcount;
/** The writer schema. */
avro_schema_t wschema;
/** The reader schema. */
avro_schema_t rschema;
/* The size of the value instances for this resolver. */
size_t instance_size;
/* A function to calculate the instance size once the overall
* top-level resolver (and all of its children) have been
* constructed. */
void
(*calculate_size)(avro_resolved_reader_t *iface);
/* A free function for this resolver */
void
(*free_iface)(avro_resolved_reader_t *iface, st_table *freeing);
/* An initialization function for instances of this resolver. */
int
(*init)(const avro_resolved_reader_t *iface, void *self);
/* A finalization function for instances of this resolver. */
void
(*done)(const avro_resolved_reader_t *iface, void *self);
/* Clear out any existing wrappers, if any */
int
(*reset_wrappers)(const avro_resolved_reader_t *iface, void *self);
};
#define avro_resolved_reader_calculate_size(iface) \
do { \
if ((iface)->calculate_size != NULL) { \
(iface)->calculate_size((iface)); \
} \
} while (0)
#define avro_resolved_reader_init(iface, self) \
((iface)->init == NULL? 0: (iface)->init((iface), (self)))
#define avro_resolved_reader_done(iface, self) \
((iface)->done == NULL? (void) 0: (iface)->done((iface), (self)))
#define avro_resolved_reader_reset_wrappers(iface, self) \
((iface)->reset_wrappers == NULL? 0: \
(iface)->reset_wrappers((iface), (self)))
/*
* We assume that each instance type in this value contains an an
* avro_value_t as its first element, which is the current wrapped
* value.
*/
void
avro_resolved_reader_set_source(avro_value_t *resolved,
avro_value_t *dest)
{
avro_value_t *self = (avro_value_t *) resolved->self;
if (self->self != NULL) {
avro_value_decref(self);
}
avro_value_copy_ref(self, dest);
}
void
avro_resolved_reader_clear_source(avro_value_t *resolved)
{
avro_value_t *self = (avro_value_t *) resolved->self;
if (self->self != NULL) {
avro_value_decref(self);
}
self->iface = NULL;
self->self = NULL;
}
int
avro_resolved_reader_new_value(avro_value_iface_t *viface,
avro_value_t *value)
{
int rval;
avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
void *self = avro_malloc(iface->instance_size + sizeof(volatile int));
if (self == NULL) {
value->iface = NULL;
value->self = NULL;
return ENOMEM;
}
memset(self, 0, iface->instance_size + sizeof(volatile int));
volatile int *refcount = (volatile int *) self;
self = (char *) self + sizeof(volatile int);
rval = avro_resolved_reader_init(iface, self);
if (rval != 0) {
avro_free(self, iface->instance_size + sizeof(volatile int));
value->iface = NULL;
value->self = NULL;
return rval;
}
*refcount = 1;
value->iface = avro_value_iface_incref(viface);
value->self = self;
return 0;
}
static void
avro_resolved_reader_free_value(const avro_value_iface_t *viface, void *vself)
{
avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
avro_value_t *self = (avro_value_t *) vself;
avro_resolved_reader_done(iface, vself);
if (self->self != NULL) {
avro_value_decref(self);
}
vself = (char *) vself - sizeof(volatile int);
avro_free(vself, iface->instance_size + sizeof(volatile int));
}
static void
avro_resolved_reader_incref(avro_value_t *value)
{
/*
* This only works if you pass in the top-level value.
*/
volatile int *refcount = (volatile int *) ((char *) value->self - sizeof(volatile int));
avro_refcount_inc(refcount);
}
static void
avro_resolved_reader_decref(avro_value_t *value)
{
/*
* This only works if you pass in the top-level value.
*/
volatile int *refcount = (volatile int *) ((char *) value->self - sizeof(volatile int));
if (avro_refcount_dec(refcount)) {
avro_resolved_reader_free_value(value->iface, value->self);
}
}
static avro_value_iface_t *
avro_resolved_reader_incref_iface(avro_value_iface_t *viface)
{
avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
avro_refcount_inc(&iface->refcount);
return viface;
}
static void
free_resolver(avro_resolved_reader_t *iface, st_table *freeing)
{
/* First check if we've already started freeing this resolver. */
if (st_lookup(freeing, (st_data_t) iface, NULL)) {
AVRO_DEBUG("Already freed %p", iface);
return;
}
/* Otherwise add this resolver to the freeing set, then free it. */
st_insert(freeing, (st_data_t) iface, (st_data_t) NULL);
AVRO_DEBUG("Freeing resolver %p (%s->%s)", iface,
avro_schema_type_name(iface->wschema),
avro_schema_type_name(iface->rschema));
iface->free_iface(iface, freeing);
}
static void
avro_resolved_reader_calculate_size_(avro_resolved_reader_t *iface)
{
/* Only calculate the size for any resolver once */
iface->calculate_size = NULL;
AVRO_DEBUG("Calculating size for %s->%s",
avro_schema_type_name((iface)->wschema),
avro_schema_type_name((iface)->rschema));
iface->instance_size = sizeof(avro_value_t);
}
static void
avro_resolved_reader_free_iface(avro_resolved_reader_t *iface, st_table *freeing)
{
AVRO_UNUSED(freeing);
avro_schema_decref(iface->wschema);
avro_schema_decref(iface->rschema);
avro_freet(avro_resolved_reader_t, iface);
}
static void
avro_resolved_reader_decref_iface(avro_value_iface_t *viface)
{
avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
AVRO_DEBUG("Decref resolver %p (before=%d)", iface, iface->refcount);
if (avro_refcount_dec(&iface->refcount)) {
st_table *freeing = st_init_numtable();
free_resolver(iface, freeing);
st_free_table(freeing);
}
}
static int
avro_resolved_reader_reset(const avro_value_iface_t *viface, void *vself)
{
/*
* To reset a wrapped value, we first clear out any wrappers,
* and then have the wrapped value reset itself.
*/
int rval;
avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
avro_value_t *self = (avro_value_t *) vself;
check(rval, avro_resolved_reader_reset_wrappers(iface, vself));
return avro_value_reset(self);
}
static avro_type_t
avro_resolved_reader_get_type(const avro_value_iface_t *viface, const void *vself)
{
AVRO_UNUSED(vself);
const avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
return avro_typeof(iface->rschema);
}
static avro_schema_t
avro_resolved_reader_get_schema(const avro_value_iface_t *viface, const void *vself)
{
AVRO_UNUSED(vself);
avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
return iface->rschema;
}
static avro_resolved_reader_t *
avro_resolved_reader_create(avro_schema_t wschema, avro_schema_t rschema)
{
avro_resolved_reader_t *self = (avro_resolved_reader_t *) avro_new(avro_resolved_reader_t);
memset(self, 0, sizeof(avro_resolved_reader_t));
self->parent.incref_iface = avro_resolved_reader_incref_iface;
self->parent.decref_iface = avro_resolved_reader_decref_iface;
self->parent.incref = avro_resolved_reader_incref;
self->parent.decref = avro_resolved_reader_decref;
self->parent.reset = avro_resolved_reader_reset;
self->parent.get_type = avro_resolved_reader_get_type;
self->parent.get_schema = avro_resolved_reader_get_schema;
self->refcount = 1;
self->wschema = avro_schema_incref(wschema);
self->rschema = avro_schema_incref(rschema);
self->calculate_size = avro_resolved_reader_calculate_size_;
self->free_iface = avro_resolved_reader_free_iface;
self->reset_wrappers = NULL;
return self;
}
/*-----------------------------------------------------------------------
* Memoized resolvers
*/
typedef struct avro_resolved_link_reader avro_resolved_link_reader_t;
typedef struct memoize_state_t {
avro_memoize_t mem;
avro_resolved_link_reader_t *links;
} memoize_state_t;
static avro_resolved_reader_t *
avro_resolved_reader_new_memoized(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema);
/*-----------------------------------------------------------------------
* Recursive schemas
*/
/*
* Recursive schemas are handled specially; the value implementation for
* an AVRO_LINK schema is simply a wrapper around the value
* implementation for the link's target schema. The value methods all
* delegate to the wrapped implementation.
*
* Complicating the links here is that we might be linking to the writer
* schema or the reader schema. This only matters for a couple of
* methods, so instead of keeping a boolean flag in the value interface,
* we just have separate method implementations that we slot in
* appropriately.
*/
struct avro_resolved_link_reader {
avro_resolved_reader_t parent;
/**
* A pointer to the โnextโ link resolver that we've had to
* create. We use this as we're creating the overall top-level
* resolver to keep track of which ones we have to fix up
* afterwards.
*/
avro_resolved_link_reader_t *next;
/** The target's implementation. */
avro_resolved_reader_t *target_resolver;
};
typedef struct avro_resolved_link_value {
avro_value_t wrapped;
avro_value_t target;
} avro_resolved_link_value_t;
static void
avro_resolved_wlink_reader_calculate_size(avro_resolved_reader_t *iface)
{
/* Only calculate the size for any resolver once */
iface->calculate_size = NULL;
AVRO_DEBUG("Calculating size for [%s]->%s",
avro_schema_type_name((iface)->wschema),
avro_schema_type_name((iface)->rschema));
iface->instance_size = sizeof(avro_resolved_link_value_t);
}
static void
avro_resolved_rlink_reader_calculate_size(avro_resolved_reader_t *iface)
{
/* Only calculate the size for any resolver once */
iface->calculate_size = NULL;
AVRO_DEBUG("Calculating size for %s->[%s]",
avro_schema_type_name((iface)->wschema),
avro_schema_type_name((iface)->rschema));
iface->instance_size = sizeof(avro_resolved_link_value_t);
}
static void
avro_resolved_link_reader_free_iface(avro_resolved_reader_t *iface, st_table *freeing)
{
avro_resolved_link_reader_t *liface =
container_of(iface, avro_resolved_link_reader_t, parent);
if (liface->target_resolver != NULL) {
free_resolver(liface->target_resolver, freeing);
}
avro_schema_decref(iface->wschema);
avro_schema_decref(iface->rschema);
avro_freet(avro_resolved_link_reader_t, iface);
}
static int
avro_resolved_link_reader_init(const avro_resolved_reader_t *iface, void *vself)
{
int rval;
const avro_resolved_link_reader_t *liface =
container_of(iface, avro_resolved_link_reader_t, parent);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
size_t target_instance_size = liface->target_resolver->instance_size;
self->target.iface = &liface->target_resolver->parent;
self->target.self = avro_malloc(target_instance_size);
if (self->target.self == NULL) {
return ENOMEM;
}
AVRO_DEBUG("Allocated <%p:%" PRIsz "> for link", self->target.self, target_instance_size);
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
rval = avro_resolved_reader_init(liface->target_resolver, self->target.self);
if (rval != 0) {
avro_free(self->target.self, target_instance_size);
}
return rval;
}
static void
avro_resolved_link_reader_done(const avro_resolved_reader_t *iface, void *vself)
{
const avro_resolved_link_reader_t *liface =
container_of(iface, avro_resolved_link_reader_t, parent);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
size_t target_instance_size = liface->target_resolver->instance_size;
AVRO_DEBUG("Freeing <%p:%" PRIsz "> for link", self->target.self, target_instance_size);
avro_resolved_reader_done(liface->target_resolver, self->target.self);
avro_free(self->target.self, target_instance_size);
self->target.iface = NULL;
self->target.self = NULL;
}
static int
avro_resolved_link_reader_reset(const avro_resolved_reader_t *iface, void *vself)
{
const avro_resolved_link_reader_t *liface =
container_of(iface, avro_resolved_link_reader_t, parent);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
return avro_resolved_reader_reset_wrappers
(liface->target_resolver, self->target.self);
}
static avro_type_t
avro_resolved_link_reader_get_type(const avro_value_iface_t *iface, const void *vself)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_type(&self->target);
}
static avro_schema_t
avro_resolved_link_reader_get_schema(const avro_value_iface_t *iface, const void *vself)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_schema(&self->target);
}
static int
avro_resolved_link_reader_get_boolean(const avro_value_iface_t *iface,
const void *vself, int *out)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_boolean(&self->target, out);
}
static int
avro_resolved_link_reader_get_bytes(const avro_value_iface_t *iface,
const void *vself, const void **buf, size_t *size)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_bytes(&self->target, buf, size);
}
static int
avro_resolved_link_reader_grab_bytes(const avro_value_iface_t *iface,
const void *vself, avro_wrapped_buffer_t *dest)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_grab_bytes(&self->target, dest);
}
static int
avro_resolved_link_reader_get_double(const avro_value_iface_t *iface,
const void *vself, double *out)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_double(&self->target, out);
}
static int
avro_resolved_link_reader_get_float(const avro_value_iface_t *iface,
const void *vself, float *out)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_float(&self->target, out);
}
static int
avro_resolved_link_reader_get_int(const avro_value_iface_t *iface,
const void *vself, int32_t *out)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_int(&self->target, out);
}
static int
avro_resolved_link_reader_get_long(const avro_value_iface_t *iface,
const void *vself, int64_t *out)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_long(&self->target, out);
}
static int
avro_resolved_link_reader_get_null(const avro_value_iface_t *iface, const void *vself)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_null(&self->target);
}
static int
avro_resolved_link_reader_get_string(const avro_value_iface_t *iface,
const void *vself, const char **str, size_t *size)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_string(&self->target, str, size);
}
static int
avro_resolved_link_reader_grab_string(const avro_value_iface_t *iface,
const void *vself, avro_wrapped_buffer_t *dest)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_grab_string(&self->target, dest);
}
static int
avro_resolved_link_reader_get_enum(const avro_value_iface_t *iface,
const void *vself, int *out)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_enum(&self->target, out);
}
static int
avro_resolved_link_reader_get_fixed(const avro_value_iface_t *iface,
const void *vself, const void **buf, size_t *size)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_fixed(&self->target, buf, size);
}
static int
avro_resolved_link_reader_grab_fixed(const avro_value_iface_t *iface,
const void *vself, avro_wrapped_buffer_t *dest)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_grab_fixed(&self->target, dest);
}
static int
avro_resolved_link_reader_set_boolean(const avro_value_iface_t *iface,
void *vself, int val)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_set_boolean(&self->target, val);
}
static int
avro_resolved_link_reader_set_bytes(const avro_value_iface_t *iface,
void *vself, void *buf, size_t size)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_set_bytes(&self->target, buf, size);
}
static int
avro_resolved_link_reader_give_bytes(const avro_value_iface_t *iface,
void *vself, avro_wrapped_buffer_t *buf)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_give_bytes(&self->target, buf);
}
static int
avro_resolved_link_reader_set_double(const avro_value_iface_t *iface,
void *vself, double val)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_set_double(&self->target, val);
}
static int
avro_resolved_link_reader_set_float(const avro_value_iface_t *iface,
void *vself, float val)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_set_float(&self->target, val);
}
static int
avro_resolved_link_reader_set_int(const avro_value_iface_t *iface,
void *vself, int32_t val)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_set_int(&self->target, val);
}
static int
avro_resolved_link_reader_set_long(const avro_value_iface_t *iface,
void *vself, int64_t val)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_set_long(&self->target, val);
}
static int
avro_resolved_link_reader_set_null(const avro_value_iface_t *iface, void *vself)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_set_null(&self->target);
}
static int
avro_resolved_link_reader_set_string(const avro_value_iface_t *iface,
void *vself, const char *str)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_set_string(&self->target, str);
}
static int
avro_resolved_link_reader_set_string_len(const avro_value_iface_t *iface,
void *vself, const char *str, size_t size)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_set_string_len(&self->target, str, size);
}
static int
avro_resolved_link_reader_give_string_len(const avro_value_iface_t *iface,
void *vself, avro_wrapped_buffer_t *buf)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_give_string_len(&self->target, buf);
}
static int
avro_resolved_link_reader_set_enum(const avro_value_iface_t *iface,
void *vself, int val)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_set_enum(&self->target, val);
}
static int
avro_resolved_link_reader_set_fixed(const avro_value_iface_t *iface,
void *vself, void *buf, size_t size)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_set_fixed(&self->target, buf, size);
}
static int
avro_resolved_link_reader_give_fixed(const avro_value_iface_t *iface,
void *vself, avro_wrapped_buffer_t *buf)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_give_fixed(&self->target, buf);
}
static int
avro_resolved_link_reader_get_size(const avro_value_iface_t *iface,
const void *vself, size_t *size)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_size(&self->target, size);
}
static int
avro_resolved_link_reader_get_by_index(const avro_value_iface_t *iface,
const void *vself, size_t index,
avro_value_t *child, const char **name)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_by_index(&self->target, index, child, name);
}
static int
avro_resolved_link_reader_get_by_name(const avro_value_iface_t *iface,
const void *vself, const char *name,
avro_value_t *child, size_t *index)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_by_name(&self->target, name, child, index);
}
static int
avro_resolved_link_reader_get_discriminant(const avro_value_iface_t *iface,
const void *vself, int *out)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_discriminant(&self->target, out);
}
static int
avro_resolved_link_reader_get_current_branch(const avro_value_iface_t *iface,
const void *vself, avro_value_t *branch)
{
AVRO_UNUSED(iface);
const avro_resolved_link_value_t *self = (const avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_get_current_branch(&self->target, branch);
}
static int
avro_resolved_link_reader_append(const avro_value_iface_t *iface,
void *vself, avro_value_t *child_out,
size_t *new_index)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_append(&self->target, child_out, new_index);
}
static int
avro_resolved_link_reader_add(const avro_value_iface_t *iface,
void *vself, const char *key,
avro_value_t *child, size_t *index, int *is_new)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_add(&self->target, key, child, index, is_new);
}
static int
avro_resolved_link_reader_set_branch(const avro_value_iface_t *iface,
void *vself, int discriminant,
avro_value_t *branch)
{
AVRO_UNUSED(iface);
avro_resolved_link_value_t *self = (avro_resolved_link_value_t *) vself;
avro_value_t *target_vself = (avro_value_t *) self->target.self;
*target_vself = self->wrapped;
return avro_value_set_branch(&self->target, discriminant, branch);
}
static avro_resolved_link_reader_t *
avro_resolved_link_reader_create(avro_schema_t wschema, avro_schema_t rschema)
{
avro_resolved_reader_t *self = (avro_resolved_reader_t *) avro_new(avro_resolved_link_reader_t);
memset(self, 0, sizeof(avro_resolved_link_reader_t));
self->parent.incref_iface = avro_resolved_reader_incref_iface;
self->parent.decref_iface = avro_resolved_reader_decref_iface;
self->parent.incref = avro_resolved_reader_incref;
self->parent.decref = avro_resolved_reader_decref;
self->parent.reset = avro_resolved_reader_reset;
self->parent.get_type = avro_resolved_link_reader_get_type;
self->parent.get_schema = avro_resolved_link_reader_get_schema;
self->parent.get_size = avro_resolved_link_reader_get_size;
self->parent.get_by_index = avro_resolved_link_reader_get_by_index;
self->parent.get_by_name = avro_resolved_link_reader_get_by_name;
self->refcount = 1;
self->wschema = avro_schema_incref(wschema);
self->rschema = avro_schema_incref(rschema);
self->free_iface = avro_resolved_link_reader_free_iface;
self->init = avro_resolved_link_reader_init;
self->done = avro_resolved_link_reader_done;
self->reset_wrappers = avro_resolved_link_reader_reset;
self->parent.get_boolean = avro_resolved_link_reader_get_boolean;
self->parent.get_bytes = avro_resolved_link_reader_get_bytes;
self->parent.grab_bytes = avro_resolved_link_reader_grab_bytes;
self->parent.get_double = avro_resolved_link_reader_get_double;
self->parent.get_float = avro_resolved_link_reader_get_float;
self->parent.get_int = avro_resolved_link_reader_get_int;
self->parent.get_long = avro_resolved_link_reader_get_long;
self->parent.get_null = avro_resolved_link_reader_get_null;
self->parent.get_string = avro_resolved_link_reader_get_string;
self->parent.grab_string = avro_resolved_link_reader_grab_string;
self->parent.get_enum = avro_resolved_link_reader_get_enum;
self->parent.get_fixed = avro_resolved_link_reader_get_fixed;
self->parent.grab_fixed = avro_resolved_link_reader_grab_fixed;
self->parent.set_boolean = avro_resolved_link_reader_set_boolean;
self->parent.set_bytes = avro_resolved_link_reader_set_bytes;
self->parent.give_bytes = avro_resolved_link_reader_give_bytes;
self->parent.set_double = avro_resolved_link_reader_set_double;
self->parent.set_float = avro_resolved_link_reader_set_float;
self->parent.set_int = avro_resolved_link_reader_set_int;
self->parent.set_long = avro_resolved_link_reader_set_long;
self->parent.set_null = avro_resolved_link_reader_set_null;
self->parent.set_string = avro_resolved_link_reader_set_string;
self->parent.set_string_len = avro_resolved_link_reader_set_string_len;
self->parent.give_string_len = avro_resolved_link_reader_give_string_len;
self->parent.set_enum = avro_resolved_link_reader_set_enum;
self->parent.set_fixed = avro_resolved_link_reader_set_fixed;
self->parent.give_fixed = avro_resolved_link_reader_give_fixed;
self->parent.get_size = avro_resolved_link_reader_get_size;
self->parent.get_by_index = avro_resolved_link_reader_get_by_index;
self->parent.get_by_name = avro_resolved_link_reader_get_by_name;
self->parent.get_discriminant = avro_resolved_link_reader_get_discriminant;
self->parent.get_current_branch = avro_resolved_link_reader_get_current_branch;
self->parent.append = avro_resolved_link_reader_append;
self->parent.add = avro_resolved_link_reader_add;
self->parent.set_branch = avro_resolved_link_reader_set_branch;
return container_of(self, avro_resolved_link_reader_t, parent);
}
static avro_resolved_reader_t *
try_wlink(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
AVRO_UNUSED(rschema);
/*
* For link schemas, we create a special value implementation
* that allocates space for its wrapped value at runtime. This
* lets us handle recursive types without having to instantiate
* in infinite-size value.
*/
avro_schema_t wtarget = avro_schema_link_target(wschema);
avro_resolved_link_reader_t *lself =
avro_resolved_link_reader_create(wtarget, rschema);
avro_memoize_set(&state->mem, wschema, rschema, lself);
avro_resolved_reader_t *target_resolver =
avro_resolved_reader_new_memoized(state, wtarget, rschema);
if (target_resolver == NULL) {
avro_memoize_delete(&state->mem, wschema, rschema);
avro_value_iface_decref(&lself->parent.parent);
avro_prefix_error("Link target isn't compatible: ");
AVRO_DEBUG("%s", avro_strerror());
return NULL;
}
lself->parent.calculate_size = avro_resolved_wlink_reader_calculate_size;
lself->target_resolver = target_resolver;
lself->next = state->links;
state->links = lself;
return &lself->parent;
}
static avro_resolved_reader_t *
try_rlink(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
AVRO_UNUSED(rschema);
/*
* For link schemas, we create a special value implementation
* that allocates space for its wrapped value at runtime. This
* lets us handle recursive types without having to instantiate
* in infinite-size value.
*/
avro_schema_t rtarget = avro_schema_link_target(rschema);
avro_resolved_link_reader_t *lself =
avro_resolved_link_reader_create(wschema, rtarget);
avro_memoize_set(&state->mem, wschema, rschema, lself);
avro_resolved_reader_t *target_resolver =
avro_resolved_reader_new_memoized(state, wschema, rtarget);
if (target_resolver == NULL) {
avro_memoize_delete(&state->mem, wschema, rschema);
avro_value_iface_decref(&lself->parent.parent);
avro_prefix_error("Link target isn't compatible: ");
AVRO_DEBUG("%s", avro_strerror());
return NULL;
}
lself->parent.calculate_size = avro_resolved_rlink_reader_calculate_size;
lself->target_resolver = target_resolver;
lself->next = state->links;
state->links = lself;
return &lself->parent;
}
/*-----------------------------------------------------------------------
* boolean
*/
static int
avro_resolved_reader_get_boolean(const avro_value_iface_t *viface,
const void *vself, int *val)
{
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Getting boolean from %p", src->self);
return avro_value_get_boolean(src, val);
}
static avro_resolved_reader_t *
try_boolean(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
if (is_avro_boolean(wschema)) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_boolean = avro_resolved_reader_get_boolean;
return self;
}
avro_set_error("Writer %s not compatible with reader boolean",
avro_schema_type_name(wschema));
return NULL;
}
/*-----------------------------------------------------------------------
* bytes
*/
static int
avro_resolved_reader_get_bytes(const avro_value_iface_t *viface,
const void *vself, const void **buf, size_t *size)
{
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Getting bytes from %p", src->self);
return avro_value_get_bytes(src, buf, size);
}
static int
avro_resolved_reader_grab_bytes(const avro_value_iface_t *viface,
const void *vself, avro_wrapped_buffer_t *dest)
{
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Grabbing bytes from %p", src->self);
return avro_value_grab_bytes(src, dest);
}
static avro_resolved_reader_t *
try_bytes(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
if (is_avro_bytes(wschema)) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_bytes = avro_resolved_reader_get_bytes;
self->parent.grab_bytes = avro_resolved_reader_grab_bytes;
return self;
}
avro_set_error("Writer %s not compatible with reader bytes",
avro_schema_type_name(wschema));
return NULL;
}
/*-----------------------------------------------------------------------
* double
*/
static int
avro_resolved_reader_get_double(const avro_value_iface_t *viface,
const void *vself, double *val)
{
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Getting double from %p", src->self);
return avro_value_get_double(src, val);
}
static int
avro_resolved_reader_get_double_float(const avro_value_iface_t *viface,
const void *vself, double *val)
{
int rval;
float real_val;
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Promoting double from float %p", src->self);
check(rval, avro_value_get_float(src, &real_val));
*val = real_val;
return 0;
}
static int
avro_resolved_reader_get_double_int(const avro_value_iface_t *viface,
const void *vself, double *val)
{
int rval;
int32_t real_val;
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Promoting double from int %p", src->self);
check(rval, avro_value_get_int(src, &real_val));
*val = real_val;
return 0;
}
static int
avro_resolved_reader_get_double_long(const avro_value_iface_t *viface,
const void *vself, double *val)
{
int rval;
int64_t real_val;
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Promoting double from long %p", src->self);
check(rval, avro_value_get_long(src, &real_val));
*val = (double) real_val;
return 0;
}
static avro_resolved_reader_t *
try_double(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
if (is_avro_double(wschema)) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_double = avro_resolved_reader_get_double;
return self;
}
else if (is_avro_float(wschema)) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_double = avro_resolved_reader_get_double_float;
return self;
}
else if (is_avro_int32(wschema)) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_double = avro_resolved_reader_get_double_int;
return self;
}
else if (is_avro_int64(wschema)) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_double = avro_resolved_reader_get_double_long;
return self;
}
avro_set_error("Writer %s not compatible with reader double",
avro_schema_type_name(wschema));
return NULL;
}
/*-----------------------------------------------------------------------
* float
*/
static int
avro_resolved_reader_get_float(const avro_value_iface_t *viface,
const void *vself, float *val)
{
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Getting float from %p", src->self);
return avro_value_get_float(src, val);
}
static int
avro_resolved_reader_get_float_int(const avro_value_iface_t *viface,
const void *vself, float *val)
{
int rval;
int32_t real_val;
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Promoting float from int %p", src->self);
check(rval, avro_value_get_int(src, &real_val));
*val = (float) real_val;
return 0;
}
static int
avro_resolved_reader_get_float_long(const avro_value_iface_t *viface,
const void *vself, float *val)
{
int rval;
int64_t real_val;
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Promoting float from long %p", src->self);
check(rval, avro_value_get_long(src, &real_val));
*val = (float) real_val;
return 0;
}
static avro_resolved_reader_t *
try_float(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
if (is_avro_float(wschema)) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_float = avro_resolved_reader_get_float;
return self;
}
else if (is_avro_int32(wschema)) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_float = avro_resolved_reader_get_float_int;
return self;
}
else if (is_avro_int64(wschema)) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_float = avro_resolved_reader_get_float_long;
return self;
}
avro_set_error("Writer %s not compatible with reader float",
avro_schema_type_name(wschema));
return NULL;
}
/*-----------------------------------------------------------------------
* int
*/
static int
avro_resolved_reader_get_int(const avro_value_iface_t *viface,
const void *vself, int32_t *val)
{
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Getting int from %p", src->self);
return avro_value_get_int(src, val);
}
static avro_resolved_reader_t *
try_int(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
if (is_avro_int32(wschema)) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_int = avro_resolved_reader_get_int;
return self;
}
avro_set_error("Writer %s not compatible with reader int",
avro_schema_type_name(wschema));
return NULL;
}
/*-----------------------------------------------------------------------
* long
*/
static int
avro_resolved_reader_get_long(const avro_value_iface_t *viface,
const void *vself, int64_t *val)
{
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Getting long from %p", src->self);
return avro_value_get_long(src, val);
}
static int
avro_resolved_reader_get_long_int(const avro_value_iface_t *viface,
const void *vself, int64_t *val)
{
int rval;
int32_t real_val;
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Promoting long from int %p", src->self);
check(rval, avro_value_get_int(src, &real_val));
*val = real_val;
return 0;
}
static avro_resolved_reader_t *
try_long(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
if (is_avro_int64(wschema)) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_long = avro_resolved_reader_get_long;
return self;
}
else if (is_avro_int32(wschema)) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_long = avro_resolved_reader_get_long_int;
return self;
}
avro_set_error("Writer %s not compatible with reader long",
avro_schema_type_name(wschema));
return NULL;
}
/*-----------------------------------------------------------------------
* null
*/
static int
avro_resolved_reader_get_null(const avro_value_iface_t *viface,
const void *vself)
{
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Getting null from %p", src->self);
return avro_value_get_null(src);
}
static avro_resolved_reader_t *
try_null(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
if (is_avro_null(wschema)) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_null = avro_resolved_reader_get_null;
return self;
}
avro_set_error("Writer %s not compatible with reader null",
avro_schema_type_name(wschema));
return NULL;
}
/*-----------------------------------------------------------------------
* string
*/
static int
avro_resolved_reader_get_string(const avro_value_iface_t *viface,
const void *vself, const char **str, size_t *size)
{
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Getting string from %p", src->self);
return avro_value_get_string(src, str, size);
}
static int
avro_resolved_reader_grab_string(const avro_value_iface_t *viface,
const void *vself, avro_wrapped_buffer_t *dest)
{
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Grabbing string from %p", src->self);
return avro_value_grab_string(src, dest);
}
static avro_resolved_reader_t *
try_string(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
if (is_avro_string(wschema)) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_string = avro_resolved_reader_get_string;
self->parent.grab_string = avro_resolved_reader_grab_string;
return self;
}
avro_set_error("Writer %s not compatible with reader string",
avro_schema_type_name(wschema));
return NULL;
}
/*-----------------------------------------------------------------------
* array
*/
typedef struct avro_resolved_array_reader {
avro_resolved_reader_t parent;
avro_resolved_reader_t *child_resolver;
} avro_resolved_array_reader_t;
typedef struct avro_resolved_array_value {
avro_value_t wrapped;
avro_raw_array_t children;
} avro_resolved_array_value_t;
static void
avro_resolved_array_reader_calculate_size(avro_resolved_reader_t *iface)
{
avro_resolved_array_reader_t *aiface =
container_of(iface, avro_resolved_array_reader_t, parent);
/* Only calculate the size for any resolver once */
iface->calculate_size = NULL;
AVRO_DEBUG("Calculating size for %s->%s",
avro_schema_type_name((iface)->wschema),
avro_schema_type_name((iface)->rschema));
iface->instance_size = sizeof(avro_resolved_array_value_t);
avro_resolved_reader_calculate_size(aiface->child_resolver);
}
static void
avro_resolved_array_reader_free_iface(avro_resolved_reader_t *iface, st_table *freeing)
{
avro_resolved_array_reader_t *aiface =
container_of(iface, avro_resolved_array_reader_t, parent);
free_resolver(aiface->child_resolver, freeing);
avro_schema_decref(iface->wschema);
avro_schema_decref(iface->rschema);
avro_freet(avro_resolved_array_reader_t, iface);
}
static int
avro_resolved_array_reader_init(const avro_resolved_reader_t *iface, void *vself)
{
const avro_resolved_array_reader_t *aiface =
container_of(iface, avro_resolved_array_reader_t, parent);
avro_resolved_array_value_t *self = (avro_resolved_array_value_t *) vself;
size_t child_instance_size = aiface->child_resolver->instance_size;
AVRO_DEBUG("Initializing child array (child_size=%" PRIsz ")", child_instance_size);
avro_raw_array_init(&self->children, child_instance_size);
return 0;
}
static void
avro_resolved_array_reader_free_elements(const avro_resolved_reader_t *child_iface,
avro_resolved_array_value_t *self)
{
size_t i;
for (i = 0; i < avro_raw_array_size(&self->children); i++) {
void *child_self = avro_raw_array_get_raw(&self->children, i);
avro_resolved_reader_done(child_iface, child_self);
}
}
static void
avro_resolved_array_reader_done(const avro_resolved_reader_t *iface, void *vself)
{
const avro_resolved_array_reader_t *aiface =
container_of(iface, avro_resolved_array_reader_t, parent);
avro_resolved_array_value_t *self = (avro_resolved_array_value_t *) vself;
avro_resolved_array_reader_free_elements(aiface->child_resolver, self);
avro_raw_array_done(&self->children);
}
static int
avro_resolved_array_reader_reset(const avro_resolved_reader_t *iface, void *vself)
{
const avro_resolved_array_reader_t *aiface =
container_of(iface, avro_resolved_array_reader_t, parent);
avro_resolved_array_value_t *self = (avro_resolved_array_value_t *) vself;
/* Clear out our cache of wrapped children */
avro_resolved_array_reader_free_elements(aiface->child_resolver, self);
avro_raw_array_clear(&self->children);
return 0;
}
static int
avro_resolved_array_reader_get_size(const avro_value_iface_t *viface,
const void *vself, size_t *size)
{
AVRO_UNUSED(viface);
const avro_resolved_array_value_t *self = (const avro_resolved_array_value_t *) vself;
return avro_value_get_size(&self->wrapped, size);
}
static int
avro_resolved_array_reader_get_by_index(const avro_value_iface_t *viface,
const void *vself, size_t index,
avro_value_t *child, const char **name)
{
int rval;
size_t old_size;
size_t new_size;
const avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
const avro_resolved_array_reader_t *aiface =
container_of(iface, avro_resolved_array_reader_t, parent);
avro_resolved_array_value_t *self = (avro_resolved_array_value_t *) vself;
/*
* Ensure that our child wrapper array is big enough to hold
* this many elements.
*/
new_size = index + 1;
check(rval, avro_raw_array_ensure_size0(&self->children, new_size));
old_size = avro_raw_array_size(&self->children);
if (old_size <= index) {
size_t i;
for (i = old_size; i < new_size; i++) {
check(rval, avro_resolved_reader_init
(aiface->child_resolver,
avro_raw_array_get_raw(&self->children, i)));
}
avro_raw_array_size(&self->children) = index+1;
}
child->iface = &aiface->child_resolver->parent;
child->self = avro_raw_array_get_raw(&self->children, index);
AVRO_DEBUG("Getting element %" PRIsz " from array %p", index, self->wrapped.self);
return avro_value_get_by_index(&self->wrapped, index, (avro_value_t *) child->self, name);
}
static avro_resolved_array_reader_t *
avro_resolved_array_reader_create(avro_schema_t wschema, avro_schema_t rschema)
{
avro_resolved_reader_t *self = (avro_resolved_reader_t *) avro_new(avro_resolved_array_reader_t);
memset(self, 0, sizeof(avro_resolved_array_reader_t));
self->parent.incref_iface = avro_resolved_reader_incref_iface;
self->parent.decref_iface = avro_resolved_reader_decref_iface;
self->parent.incref = avro_resolved_reader_incref;
self->parent.decref = avro_resolved_reader_decref;
self->parent.reset = avro_resolved_reader_reset;
self->parent.get_type = avro_resolved_reader_get_type;
self->parent.get_schema = avro_resolved_reader_get_schema;
self->parent.get_size = avro_resolved_array_reader_get_size;
self->parent.get_by_index = avro_resolved_array_reader_get_by_index;
self->refcount = 1;
self->wschema = avro_schema_incref(wschema);
self->rschema = avro_schema_incref(rschema);
self->calculate_size = avro_resolved_array_reader_calculate_size;
self->free_iface = avro_resolved_array_reader_free_iface;
self->init = avro_resolved_array_reader_init;
self->done = avro_resolved_array_reader_done;
self->reset_wrappers = avro_resolved_array_reader_reset;
return container_of(self, avro_resolved_array_reader_t, parent);
}
static avro_resolved_reader_t *
try_array(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
/*
* First verify that the writer is an array.
*/
if (!is_avro_array(wschema)) {
return 0;
}
/*
* Array schemas have to have compatible element schemas to be
* compatible themselves. Try to create an resolver to check
* the compatibility.
*/
avro_resolved_array_reader_t *aself =
avro_resolved_array_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, aself);
avro_schema_t witems = avro_schema_array_items(wschema);
avro_schema_t ritems = avro_schema_array_items(rschema);
avro_resolved_reader_t *item_resolver =
avro_resolved_reader_new_memoized(state, witems, ritems);
if (item_resolver == NULL) {
avro_memoize_delete(&state->mem, wschema, rschema);
avro_value_iface_decref(&aself->parent.parent);
avro_prefix_error("Array values aren't compatible: ");
return NULL;
}
/*
* The two schemas are compatible. Store the item schema's
* resolver into the child_resolver field.
*/
aself->child_resolver = item_resolver;
return &aself->parent;
}
/*-----------------------------------------------------------------------
* enum
*/
static int
avro_resolved_reader_get_enum(const avro_value_iface_t *viface,
const void *vself, int *val)
{
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Getting enum from %p", src->self);
return avro_value_get_enum(src, val);
}
static avro_resolved_reader_t *
try_enum(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
/*
* Enum schemas have to have the same name โ but not the same
* list of symbols โ to be compatible.
*/
if (is_avro_enum(wschema)) {
const char *wname = avro_schema_name(wschema);
const char *rname = avro_schema_name(rschema);
if (strcmp(wname, rname) == 0) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_enum = avro_resolved_reader_get_enum;
return self;
}
}
avro_set_error("Writer %s not compatible with reader %s",
avro_schema_type_name(wschema),
avro_schema_type_name(rschema));
return NULL;
}
/*-----------------------------------------------------------------------
* fixed
*/
static int
avro_resolved_reader_get_fixed(const avro_value_iface_t *viface,
const void *vself, const void **buf, size_t *size)
{
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Getting fixed from %p", vself);
return avro_value_get_fixed(src, buf, size);
}
static int
avro_resolved_reader_grab_fixed(const avro_value_iface_t *viface,
const void *vself, avro_wrapped_buffer_t *dest)
{
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
AVRO_DEBUG("Grabbing fixed from %p", vself);
return avro_value_grab_fixed(src, dest);
}
static avro_resolved_reader_t *
try_fixed(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
/*
* Fixed schemas need the same name and size to be compatible.
*/
if (avro_schema_equal(wschema, rschema)) {
avro_resolved_reader_t *self =
avro_resolved_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, self);
self->parent.get_fixed = avro_resolved_reader_get_fixed;
self->parent.grab_fixed = avro_resolved_reader_grab_fixed;
return self;
}
avro_set_error("Writer %s not compatible with reader %s",
avro_schema_type_name(wschema),
avro_schema_type_name(rschema));
return NULL;
}
/*-----------------------------------------------------------------------
* map
*/
typedef struct avro_resolved_map_reader {
avro_resolved_reader_t parent;
avro_resolved_reader_t *child_resolver;
} avro_resolved_map_reader_t;
typedef struct avro_resolved_map_value {
avro_value_t wrapped;
avro_raw_array_t children;
} avro_resolved_map_value_t;
static void
avro_resolved_map_reader_calculate_size(avro_resolved_reader_t *iface)
{
avro_resolved_map_reader_t *miface =
container_of(iface, avro_resolved_map_reader_t, parent);
/* Only calculate the size for any resolver once */
iface->calculate_size = NULL;
AVRO_DEBUG("Calculating size for %s->%s",
avro_schema_type_name((iface)->wschema),
avro_schema_type_name((iface)->rschema));
iface->instance_size = sizeof(avro_resolved_map_value_t);
avro_resolved_reader_calculate_size(miface->child_resolver);
}
static void
avro_resolved_map_reader_free_iface(avro_resolved_reader_t *iface, st_table *freeing)
{
avro_resolved_map_reader_t *miface =
container_of(iface, avro_resolved_map_reader_t, parent);
free_resolver(miface->child_resolver, freeing);
avro_schema_decref(iface->wschema);
avro_schema_decref(iface->rschema);
avro_freet(avro_resolved_map_reader_t, iface);
}
static int
avro_resolved_map_reader_init(const avro_resolved_reader_t *iface, void *vself)
{
const avro_resolved_map_reader_t *miface =
container_of(iface, avro_resolved_map_reader_t, parent);
avro_resolved_map_value_t *self = (avro_resolved_map_value_t *) vself;
size_t child_instance_size = miface->child_resolver->instance_size;
AVRO_DEBUG("Initializing child array for map (child_size=%" PRIsz ")", child_instance_size);
avro_raw_array_init(&self->children, child_instance_size);
return 0;
}
static void
avro_resolved_map_reader_free_elements(const avro_resolved_reader_t *child_iface,
avro_resolved_map_value_t *self)
{
size_t i;
for (i = 0; i < avro_raw_array_size(&self->children); i++) {
void *child_self = avro_raw_array_get_raw(&self->children, i);
avro_resolved_reader_done(child_iface, child_self);
}
}
static void
avro_resolved_map_reader_done(const avro_resolved_reader_t *iface, void *vself)
{
const avro_resolved_map_reader_t *miface =
container_of(iface, avro_resolved_map_reader_t, parent);
avro_resolved_map_value_t *self = (avro_resolved_map_value_t *) vself;
avro_resolved_map_reader_free_elements(miface->child_resolver, self);
avro_raw_array_done(&self->children);
}
static int
avro_resolved_map_reader_reset(const avro_resolved_reader_t *iface, void *vself)
{
const avro_resolved_map_reader_t *miface =
container_of(iface, avro_resolved_map_reader_t, parent);
avro_resolved_map_value_t *self = (avro_resolved_map_value_t *) vself;
/* Clear out our cache of wrapped children */
avro_resolved_map_reader_free_elements(miface->child_resolver, self);
return 0;
}
static int
avro_resolved_map_reader_get_size(const avro_value_iface_t *viface,
const void *vself, size_t *size)
{
AVRO_UNUSED(viface);
const avro_value_t *src = (const avro_value_t *) vself;
return avro_value_get_size(src, size);
}
static int
avro_resolved_map_reader_get_by_index(const avro_value_iface_t *viface,
const void *vself, size_t index,
avro_value_t *child, const char **name)
{
int rval;
const avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
const avro_resolved_map_reader_t *miface =
container_of(iface, avro_resolved_map_reader_t, parent);
avro_resolved_map_value_t *self = (avro_resolved_map_value_t *) vself;
/*
* Ensure that our child wrapper array is big enough to hold
* this many elements.
*/
check(rval, avro_raw_array_ensure_size0(&self->children, index+1));
if (avro_raw_array_size(&self->children) <= index) {
avro_raw_array_size(&self->children) = index+1;
}
child->iface = &miface->child_resolver->parent;
child->self = avro_raw_array_get_raw(&self->children, index);
AVRO_DEBUG("Getting element %" PRIsz " from map %p", index, self->wrapped.self);
return avro_value_get_by_index(&self->wrapped, index, (avro_value_t *) child->self, name);
}
static int
avro_resolved_map_reader_get_by_name(const avro_value_iface_t *viface,
const void *vself, const char *name,
avro_value_t *child, size_t *index)
{
int rval;
const avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
const avro_resolved_map_reader_t *miface =
container_of(iface, avro_resolved_map_reader_t, parent);
avro_resolved_map_value_t *self = (avro_resolved_map_value_t *) vself;
/*
* This is a bit convoluted. We need to stash the wrapped child
* value somewhere in our children array. But we don't know
* where to put it until the wrapped map tells us what its index
* is.
*/
avro_value_t real_child;
size_t real_index;
AVRO_DEBUG("Getting element %s from map %p", name, self->wrapped.self);
check(rval, avro_value_get_by_name
(&self->wrapped, name, &real_child, &real_index));
/*
* Ensure that our child wrapper array is big enough to hold
* this many elements.
*/
check(rval, avro_raw_array_ensure_size0(&self->children, real_index+1));
if (avro_raw_array_size(&self->children) <= real_index) {
avro_raw_array_size(&self->children) = real_index+1;
}
child->iface = &miface->child_resolver->parent;
child->self = avro_raw_array_get_raw(&self->children, real_index);
avro_value_t *child_vself = (avro_value_t *) child->self;
*child_vself = real_child;
if (index != NULL) {
*index = real_index;
}
return 0;
}
static avro_resolved_map_reader_t *
avro_resolved_map_reader_create(avro_schema_t wschema, avro_schema_t rschema)
{
avro_resolved_reader_t *self = (avro_resolved_reader_t *) avro_new(avro_resolved_map_reader_t);
memset(self, 0, sizeof(avro_resolved_map_reader_t));
self->parent.incref_iface = avro_resolved_reader_incref_iface;
self->parent.decref_iface = avro_resolved_reader_decref_iface;
self->parent.incref = avro_resolved_reader_incref;
self->parent.decref = avro_resolved_reader_decref;
self->parent.reset = avro_resolved_reader_reset;
self->parent.get_type = avro_resolved_reader_get_type;
self->parent.get_schema = avro_resolved_reader_get_schema;
self->parent.get_size = avro_resolved_map_reader_get_size;
self->parent.get_by_index = avro_resolved_map_reader_get_by_index;
self->parent.get_by_name = avro_resolved_map_reader_get_by_name;
self->refcount = 1;
self->wschema = avro_schema_incref(wschema);
self->rschema = avro_schema_incref(rschema);
self->calculate_size = avro_resolved_map_reader_calculate_size;
self->free_iface = avro_resolved_map_reader_free_iface;
self->init = avro_resolved_map_reader_init;
self->done = avro_resolved_map_reader_done;
self->reset_wrappers = avro_resolved_map_reader_reset;
return container_of(self, avro_resolved_map_reader_t, parent);
}
static avro_resolved_reader_t *
try_map(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
/*
* First verify that the reader is an map.
*/
if (!is_avro_map(wschema)) {
return 0;
}
/*
* Map schemas have to have compatible element schemas to be
* compatible themselves. Try to create an resolver to check
* the compatibility.
*/
avro_resolved_map_reader_t *mself =
avro_resolved_map_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, mself);
avro_schema_t witems = avro_schema_map_values(wschema);
avro_schema_t ritems = avro_schema_map_values(rschema);
avro_resolved_reader_t *item_resolver =
avro_resolved_reader_new_memoized(state, witems, ritems);
if (item_resolver == NULL) {
avro_memoize_delete(&state->mem, wschema, rschema);
avro_value_iface_decref(&mself->parent.parent);
avro_prefix_error("Map values aren't compatible: ");
return NULL;
}
/*
* The two schemas are compatible. Store the item schema's
* resolver into the child_resolver field.
*/
mself->child_resolver = item_resolver;
return &mself->parent;
}
/*-----------------------------------------------------------------------
* record
*/
typedef struct avro_resolved_record_reader {
avro_resolved_reader_t parent;
size_t field_count;
size_t *field_offsets;
avro_resolved_reader_t **field_resolvers;
size_t *index_mapping;
} avro_resolved_record_reader_t;
typedef struct avro_resolved_record_value {
avro_value_t wrapped;
/* The rest of the struct is taken up by the inline storage
* needed for each field. */
} avro_resolved_record_value_t;
/** Return a pointer to the given field within a record struct. */
#define avro_resolved_record_field(iface, rec, index) \
(((char *) (rec)) + (iface)->field_offsets[(index)])
static void
avro_resolved_record_reader_calculate_size(avro_resolved_reader_t *iface)
{
avro_resolved_record_reader_t *riface =
container_of(iface, avro_resolved_record_reader_t, parent);
/* Only calculate the size for any resolver once */
iface->calculate_size = NULL;
AVRO_DEBUG("Calculating size for %s->%s",
avro_schema_type_name((iface)->wschema),
avro_schema_type_name((iface)->rschema));
/*
* Once we've figured out which reader fields we actually need,
* calculate an offset for each one.
*/
size_t ri;
size_t next_offset = sizeof(avro_resolved_record_value_t);
for (ri = 0; ri < riface->field_count; ri++) {
riface->field_offsets[ri] = next_offset;
if (riface->field_resolvers[ri] != NULL) {
avro_resolved_reader_calculate_size
(riface->field_resolvers[ri]);
size_t field_size =
riface->field_resolvers[ri]->instance_size;
AVRO_DEBUG("Field %" PRIsz " has size %" PRIsz, ri, field_size);
next_offset += field_size;
} else {
AVRO_DEBUG("Field %" PRIsz " is being skipped", ri);
}
}
AVRO_DEBUG("Record has size %" PRIsz, next_offset);
iface->instance_size = next_offset;
}
static void
avro_resolved_record_reader_free_iface(avro_resolved_reader_t *iface, st_table *freeing)
{
avro_resolved_record_reader_t *riface =
container_of(iface, avro_resolved_record_reader_t, parent);
if (riface->field_offsets != NULL) {
avro_free(riface->field_offsets,
riface->field_count * sizeof(size_t));
}
if (riface->field_resolvers != NULL) {
size_t i;
for (i = 0; i < riface->field_count; i++) {
if (riface->field_resolvers[i] != NULL) {
AVRO_DEBUG("Freeing field %" PRIsz " %p", i,
riface->field_resolvers[i]);
free_resolver(riface->field_resolvers[i], freeing);
}
}
avro_free(riface->field_resolvers,
riface->field_count * sizeof(avro_resolved_reader_t *));
}
if (riface->index_mapping != NULL) {
avro_free(riface->index_mapping,
riface->field_count * sizeof(size_t));
}
avro_schema_decref(iface->wschema);
avro_schema_decref(iface->rschema);
avro_freet(avro_resolved_record_reader_t, iface);
}
static int
avro_resolved_record_reader_init(const avro_resolved_reader_t *iface, void *vself)
{
int rval;
const avro_resolved_record_reader_t *riface =
container_of(iface, avro_resolved_record_reader_t, parent);
avro_resolved_record_value_t *self = (avro_resolved_record_value_t *) vself;
/* Initialize each field */
size_t i;
for (i = 0; i < riface->field_count; i++) {
if (riface->field_resolvers[i] != NULL) {
check(rval, avro_resolved_reader_init
(riface->field_resolvers[i],
avro_resolved_record_field(riface, self, i)));
}
}
return 0;
}
static void
avro_resolved_record_reader_done(const avro_resolved_reader_t *iface, void *vself)
{
const avro_resolved_record_reader_t *riface =
container_of(iface, avro_resolved_record_reader_t, parent);
avro_resolved_record_value_t *self = (avro_resolved_record_value_t *) vself;
/* Finalize each field */
size_t i;
for (i = 0; i < riface->field_count; i++) {
if (riface->field_resolvers[i] != NULL) {
avro_resolved_reader_done
(riface->field_resolvers[i],
avro_resolved_record_field(riface, self, i));
}
}
}
static int
avro_resolved_record_reader_reset(const avro_resolved_reader_t *iface, void *vself)
{
int rval;
const avro_resolved_record_reader_t *riface =
container_of(iface, avro_resolved_record_reader_t, parent);
avro_resolved_record_value_t *self = (avro_resolved_record_value_t *) vself;
/* Reset each field */
size_t i;
for (i = 0; i < riface->field_count; i++) {
if (riface->field_resolvers[i] != NULL) {
check(rval, avro_resolved_reader_reset_wrappers
(riface->field_resolvers[i],
avro_resolved_record_field(riface, self, i)));
}
}
return 0;
}
static int
avro_resolved_record_reader_get_size(const avro_value_iface_t *viface,
const void *vself, size_t *size)
{
AVRO_UNUSED(vself);
const avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
const avro_resolved_record_reader_t *riface =
container_of(iface, avro_resolved_record_reader_t, parent);
*size = riface->field_count;
return 0;
}
static int
avro_resolved_record_reader_get_by_index(const avro_value_iface_t *viface,
const void *vself, size_t index,
avro_value_t *child, const char **name)
{
const avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
const avro_resolved_record_reader_t *riface =
container_of(iface, avro_resolved_record_reader_t, parent);
const avro_resolved_record_value_t *self = (avro_resolved_record_value_t *) vself;
AVRO_DEBUG("Getting reader field %" PRIsz " from record %p", index, self->wrapped.self);
if (riface->field_resolvers[index] == NULL) {
/*
* TODO: Return the default value if the writer record
* doesn't contain this field.
*/
AVRO_DEBUG("Writer doesn't have field");
avro_set_error("NIY: Default values");
return EINVAL;
}
size_t writer_index = riface->index_mapping[index];
AVRO_DEBUG(" Writer field is %" PRIsz, writer_index);
child->iface = &riface->field_resolvers[index]->parent;
child->self = avro_resolved_record_field(riface, self, index);
return avro_value_get_by_index(&self->wrapped, writer_index, (avro_value_t *) child->self, name);
}
static int
avro_resolved_record_reader_get_by_name(const avro_value_iface_t *viface,
const void *vself, const char *name,
avro_value_t *child, size_t *index)
{
const avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
int ri = avro_schema_record_field_get_index(iface->rschema, name);
if (ri == -1) {
avro_set_error("Record doesn't have field named %s", name);
return EINVAL;
}
AVRO_DEBUG("Reader field %s is at index %d", name, ri);
if (index != NULL) {
*index = ri;
}
return avro_resolved_record_reader_get_by_index(viface, vself, ri, child, NULL);
}
static avro_resolved_record_reader_t *
avro_resolved_record_reader_create(avro_schema_t wschema, avro_schema_t rschema)
{
avro_resolved_reader_t *self = (avro_resolved_reader_t *) avro_new(avro_resolved_record_reader_t);
memset(self, 0, sizeof(avro_resolved_record_reader_t));
self->parent.incref_iface = avro_resolved_reader_incref_iface;
self->parent.decref_iface = avro_resolved_reader_decref_iface;
self->parent.incref = avro_resolved_reader_incref;
self->parent.decref = avro_resolved_reader_decref;
self->parent.reset = avro_resolved_reader_reset;
self->parent.get_type = avro_resolved_reader_get_type;
self->parent.get_schema = avro_resolved_reader_get_schema;
self->parent.get_size = avro_resolved_record_reader_get_size;
self->parent.get_by_index = avro_resolved_record_reader_get_by_index;
self->parent.get_by_name = avro_resolved_record_reader_get_by_name;
self->refcount = 1;
self->wschema = avro_schema_incref(wschema);
self->rschema = avro_schema_incref(rschema);
self->calculate_size = avro_resolved_record_reader_calculate_size;
self->free_iface = avro_resolved_record_reader_free_iface;
self->init = avro_resolved_record_reader_init;
self->done = avro_resolved_record_reader_done;
self->reset_wrappers = avro_resolved_record_reader_reset;
return container_of(self, avro_resolved_record_reader_t, parent);
}
static avro_resolved_reader_t *
try_record(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
/*
* First verify that the writer is also a record, and has the
* same name as the reader.
*/
if (!is_avro_record(wschema)) {
return 0;
}
const char *wname = avro_schema_name(wschema);
const char *rname = avro_schema_name(rschema);
if (strcmp(wname, rname) != 0) {
return 0;
}
/*
* Categorize the fields in the record schemas. Fields that are
* only in the writer are ignored. Fields that are only in the
* reader raise a schema mismatch error, unless the field has a
* default value. Fields that are in both are resolved
* recursively.
*
* The field_resolvers array will contain an avro_value_iface_t
* for each field in the reader schema. To build this array, we
* loop through the fields of the reader schema. If that field
* is also in the writer schema, we resolve them recursively,
* and store the resolver into the array. If the field isn't in
* the writer schema, we raise an error. (TODO: Eventually,
* we'll handle default values here.) After this loop finishes,
* any NULLs in the field_resolvers array will represent fields
* in the writer but not the reader; these fields should be
* skipped, and won't be accessible in the resolved reader.
*/
avro_resolved_record_reader_t *rself =
avro_resolved_record_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, rself);
size_t rfields = avro_schema_record_size(rschema);
AVRO_DEBUG("Checking reader record schema %s", wname);
avro_resolved_reader_t **field_resolvers =
(avro_resolved_reader_t **) avro_calloc(rfields, sizeof(avro_resolved_reader_t *));
size_t *field_offsets = (size_t *) avro_calloc(rfields, sizeof(size_t));
size_t *index_mapping = (size_t *) avro_calloc(rfields, sizeof(size_t));
size_t ri;
for (ri = 0; ri < rfields; ri++) {
avro_schema_t rfield =
avro_schema_record_field_get_by_index(rschema, ri);
const char *field_name =
avro_schema_record_field_name(rschema, ri);
AVRO_DEBUG("Resolving reader record field %" PRIsz " (%s)", ri, field_name);
/*
* See if this field is also in the writer schema.
*/
int wi = avro_schema_record_field_get_index(wschema, field_name);
if (wi == -1) {
/*
* This field isn't in the writer schema โ
* that's an error! TODO: Handle default
* values!
*/
AVRO_DEBUG("Field %s isn't in writer", field_name);
avro_set_error("Reader field %s doesn't appear in writer",
field_name);
goto error;
}
/*
* Try to recursively resolve the schemas for this
* field. If they're not compatible, that's an error.
*/
avro_schema_t wfield =
avro_schema_record_field_get_by_index(wschema, wi);
avro_resolved_reader_t *field_resolver =
avro_resolved_reader_new_memoized(state, wfield, rfield);
if (field_resolver == NULL) {
avro_prefix_error("Field %s isn't compatible: ", field_name);
goto error;
}
/*
* Save the details for this field.
*/
AVRO_DEBUG("Found match for field %s (%" PRIsz " in reader, %d in writer)",
field_name, ri, wi);
field_resolvers[ri] = field_resolver;
index_mapping[ri] = wi;
}
/*
* We might not have found matches for all of the writer fields,
* but that's okay โ any extras will be ignored.
*/
rself->field_count = rfields;
rself->field_offsets = field_offsets;
rself->field_resolvers = field_resolvers;
rself->index_mapping = index_mapping;
return &rself->parent;
error:
/*
* Clean up any resolver we might have already created.
*/
avro_memoize_delete(&state->mem, wschema, rschema);
avro_value_iface_decref(&rself->parent.parent);
{
unsigned int i;
for (i = 0; i < rfields; i++) {
if (field_resolvers[i]) {
avro_value_iface_decref(&field_resolvers[i]->parent);
}
}
}
avro_free(field_resolvers, rfields * sizeof(avro_resolved_reader_t *));
avro_free(field_offsets, rfields * sizeof(size_t));
avro_free(index_mapping, rfields * sizeof(size_t));
return NULL;
}
/*-----------------------------------------------------------------------
* writer union
*/
/*
* For writer unions, we maintain a list of resolvers for each branch of
* the union. When we encounter a writer value, we see which branch it
* is, and choose a reader resolver based on that.
*/
typedef struct avro_resolved_wunion_reader {
avro_resolved_reader_t parent;
/* The number of branches in the writer union */
size_t branch_count;
/* A child resolver for each branch of the writer union. If any
* of these are NULL, then we don't have anything on the reader
* side that's compatible with that writer branch. */
avro_resolved_reader_t **branch_resolvers;
} avro_resolved_wunion_reader_t;
typedef struct avro_resolved_wunion_value {
avro_value_t wrapped;
/** The currently active branch of the union. -1 if no branch
* is selected. */
int discriminant;
/* The rest of the struct is taken up by the inline storage
* needed for the active branch. */
} avro_resolved_wunion_value_t;
/** Return a pointer to the active branch within a union struct. */
#define avro_resolved_wunion_branch(_wunion) \
(((char *) (_wunion)) + sizeof(avro_resolved_wunion_value_t))
static void
avro_resolved_wunion_reader_calculate_size(avro_resolved_reader_t *iface)
{
avro_resolved_wunion_reader_t *uiface =
container_of(iface, avro_resolved_wunion_reader_t, parent);
/* Only calculate the size for any resolver once */
iface->calculate_size = NULL;
AVRO_DEBUG("Calculating size for %s->%s",
avro_schema_type_name((iface)->wschema),
avro_schema_type_name((iface)->rschema));
size_t i;
size_t max_branch_size = 0;
for (i = 0; i < uiface->branch_count; i++) {
if (uiface->branch_resolvers[i] == NULL) {
AVRO_DEBUG("No match for writer union branch %" PRIsz, i);
} else {
avro_resolved_reader_calculate_size
(uiface->branch_resolvers[i]);
size_t branch_size =
uiface->branch_resolvers[i]->instance_size;
AVRO_DEBUG("Writer branch %" PRIsz " has size %" PRIsz, i, branch_size);
if (branch_size > max_branch_size) {
max_branch_size = branch_size;
}
}
}
AVRO_DEBUG("Maximum branch size is %" PRIsz, max_branch_size);
iface->instance_size =
sizeof(avro_resolved_wunion_value_t) + max_branch_size;
AVRO_DEBUG("Total union size is %" PRIsz, iface->instance_size);
}
static void
avro_resolved_wunion_reader_free_iface(avro_resolved_reader_t *iface, st_table *freeing)
{
avro_resolved_wunion_reader_t *uiface =
container_of(iface, avro_resolved_wunion_reader_t, parent);
if (uiface->branch_resolvers != NULL) {
size_t i;
for (i = 0; i < uiface->branch_count; i++) {
if (uiface->branch_resolvers[i] != NULL) {
free_resolver(uiface->branch_resolvers[i], freeing);
}
}
avro_free(uiface->branch_resolvers,
uiface->branch_count * sizeof(avro_resolved_reader_t *));
}
avro_schema_decref(iface->wschema);
avro_schema_decref(iface->rschema);
avro_freet(avro_resolved_wunion_reader_t, iface);
}
static int
avro_resolved_wunion_reader_init(const avro_resolved_reader_t *iface, void *vself)
{
AVRO_UNUSED(iface);
avro_resolved_wunion_value_t *self = (avro_resolved_wunion_value_t *) vself;
self->discriminant = -1;
return 0;
}
static void
avro_resolved_wunion_reader_done(const avro_resolved_reader_t *iface, void *vself)
{
const avro_resolved_wunion_reader_t *uiface =
container_of(iface, avro_resolved_wunion_reader_t, parent);
avro_resolved_wunion_value_t *self = (avro_resolved_wunion_value_t *) vself;
if (self->discriminant >= 0) {
avro_resolved_reader_done
(uiface->branch_resolvers[self->discriminant],
avro_resolved_wunion_branch(self));
self->discriminant = -1;
}
}
static int
avro_resolved_wunion_reader_reset(const avro_resolved_reader_t *iface, void *vself)
{
const avro_resolved_wunion_reader_t *uiface =
container_of(iface, avro_resolved_wunion_reader_t, parent);
avro_resolved_wunion_value_t *self = (avro_resolved_wunion_value_t *) vself;
/* Keep the same branch selected, for the common case that we're
* about to reuse it. */
if (self->discriminant >= 0) {
return avro_resolved_reader_reset_wrappers
(uiface->branch_resolvers[self->discriminant],
avro_resolved_wunion_branch(self));
}
return 0;
}
static int
avro_resolved_wunion_get_real_src(const avro_value_iface_t *viface,
const void *vself, avro_value_t *real_src)
{
int rval;
const avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
const avro_resolved_wunion_reader_t *uiface =
container_of(iface, avro_resolved_wunion_reader_t, parent);
avro_resolved_wunion_value_t *self = (avro_resolved_wunion_value_t *) vself;
int writer_disc;
check(rval, avro_value_get_discriminant(&self->wrapped, &writer_disc));
AVRO_DEBUG("Writer is branch %d", writer_disc);
if (uiface->branch_resolvers[writer_disc] == NULL) {
avro_set_error("Reader isn't compatible with writer branch %d",
writer_disc);
return EINVAL;
}
if (self->discriminant == writer_disc) {
AVRO_DEBUG("Writer branch %d already selected", writer_disc);
} else {
if (self->discriminant >= 0) {
AVRO_DEBUG("Finalizing old writer branch %d", self->discriminant);
avro_resolved_reader_done
(uiface->branch_resolvers[self->discriminant],
avro_resolved_wunion_branch(self));
}
AVRO_DEBUG("Initializing writer branch %d", writer_disc);
check(rval, avro_resolved_reader_init
(uiface->branch_resolvers[writer_disc],
avro_resolved_wunion_branch(self)));
self->discriminant = writer_disc;
}
real_src->iface = &uiface->branch_resolvers[writer_disc]->parent;
real_src->self = avro_resolved_wunion_branch(self);
return avro_value_get_current_branch(&self->wrapped, (avro_value_t *) real_src->self);
}
static int
avro_resolved_wunion_reader_get_boolean(const avro_value_iface_t *viface,
const void *vself, int *out)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_get_boolean(&src, out);
}
static int
avro_resolved_wunion_reader_get_bytes(const avro_value_iface_t *viface,
const void *vself, const void **buf, size_t *size)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_get_bytes(&src, buf, size);
}
static int
avro_resolved_wunion_reader_grab_bytes(const avro_value_iface_t *viface,
const void *vself, avro_wrapped_buffer_t *dest)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_grab_bytes(&src, dest);
}
static int
avro_resolved_wunion_reader_get_double(const avro_value_iface_t *viface,
const void *vself, double *out)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_get_double(&src, out);
}
static int
avro_resolved_wunion_reader_get_float(const avro_value_iface_t *viface,
const void *vself, float *out)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_get_float(&src, out);
}
static int
avro_resolved_wunion_reader_get_int(const avro_value_iface_t *viface,
const void *vself, int32_t *out)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_get_int(&src, out);
}
static int
avro_resolved_wunion_reader_get_long(const avro_value_iface_t *viface,
const void *vself, int64_t *out)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_get_long(&src, out);
}
static int
avro_resolved_wunion_reader_get_null(const avro_value_iface_t *viface,
const void *vself)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_get_null(&src);
}
static int
avro_resolved_wunion_reader_get_string(const avro_value_iface_t *viface,
const void *vself, const char **str, size_t *size)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_get_string(&src, str, size);
}
static int
avro_resolved_wunion_reader_grab_string(const avro_value_iface_t *viface,
const void *vself, avro_wrapped_buffer_t *dest)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_grab_string(&src, dest);
}
static int
avro_resolved_wunion_reader_get_enum(const avro_value_iface_t *viface,
const void *vself, int *out)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_get_enum(&src, out);
}
static int
avro_resolved_wunion_reader_get_fixed(const avro_value_iface_t *viface,
const void *vself, const void **buf, size_t *size)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_get_fixed(&src, buf, size);
}
static int
avro_resolved_wunion_reader_grab_fixed(const avro_value_iface_t *viface,
const void *vself, avro_wrapped_buffer_t *dest)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_grab_fixed(&src, dest);
}
static int
avro_resolved_wunion_reader_set_boolean(const avro_value_iface_t *viface,
void *vself, int val)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_set_boolean(&src, val);
}
static int
avro_resolved_wunion_reader_set_bytes(const avro_value_iface_t *viface,
void *vself, void *buf, size_t size)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_set_bytes(&src, buf, size);
}
static int
avro_resolved_wunion_reader_give_bytes(const avro_value_iface_t *viface,
void *vself, avro_wrapped_buffer_t *buf)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_give_bytes(&src, buf);
}
static int
avro_resolved_wunion_reader_set_double(const avro_value_iface_t *viface,
void *vself, double val)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_set_double(&src, val);
}
static int
avro_resolved_wunion_reader_set_float(const avro_value_iface_t *viface,
void *vself, float val)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_set_float(&src, val);
}
static int
avro_resolved_wunion_reader_set_int(const avro_value_iface_t *viface,
void *vself, int32_t val)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_set_int(&src, val);
}
static int
avro_resolved_wunion_reader_set_long(const avro_value_iface_t *viface,
void *vself, int64_t val)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_set_long(&src, val);
}
static int
avro_resolved_wunion_reader_set_null(const avro_value_iface_t *viface,
void *vself)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_set_null(&src);
}
static int
avro_resolved_wunion_reader_set_string(const avro_value_iface_t *viface,
void *vself, const char *str)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_set_string(&src, str);
}
static int
avro_resolved_wunion_reader_set_string_len(const avro_value_iface_t *viface,
void *vself, const char *str, size_t size)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_set_string_len(&src, str, size);
}
static int
avro_resolved_wunion_reader_give_string_len(const avro_value_iface_t *viface,
void *vself, avro_wrapped_buffer_t *buf)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_give_string_len(&src, buf);
}
static int
avro_resolved_wunion_reader_set_enum(const avro_value_iface_t *viface,
void *vself, int val)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_set_enum(&src, val);
}
static int
avro_resolved_wunion_reader_set_fixed(const avro_value_iface_t *viface,
void *vself, void *buf, size_t size)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_set_fixed(&src, buf, size);
}
static int
avro_resolved_wunion_reader_give_fixed(const avro_value_iface_t *viface,
void *vself, avro_wrapped_buffer_t *dest)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_give_fixed(&src, dest);
}
static int
avro_resolved_wunion_reader_get_size(const avro_value_iface_t *viface,
const void *vself, size_t *size)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_get_size(&src, size);
}
static int
avro_resolved_wunion_reader_get_by_index(const avro_value_iface_t *viface,
const void *vself, size_t index,
avro_value_t *child, const char **name)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_get_by_index(&src, index, child, name);
}
static int
avro_resolved_wunion_reader_get_by_name(const avro_value_iface_t *viface,
const void *vself, const char *name,
avro_value_t *child, size_t *index)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_get_by_name(&src, name, child, index);
}
static int
avro_resolved_wunion_reader_get_discriminant(const avro_value_iface_t *viface,
const void *vself, int *out)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_get_discriminant(&src, out);
}
static int
avro_resolved_wunion_reader_get_current_branch(const avro_value_iface_t *viface,
const void *vself, avro_value_t *branch)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_get_current_branch(&src, branch);
}
static int
avro_resolved_wunion_reader_append(const avro_value_iface_t *viface,
void *vself, avro_value_t *child_out,
size_t *new_index)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_append(&src, child_out, new_index);
}
static int
avro_resolved_wunion_reader_add(const avro_value_iface_t *viface,
void *vself, const char *key,
avro_value_t *child, size_t *index, int *is_new)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_add(&src, key, child, index, is_new);
}
static int
avro_resolved_wunion_reader_set_branch(const avro_value_iface_t *viface,
void *vself, int discriminant,
avro_value_t *branch)
{
int rval;
avro_value_t src;
check(rval, avro_resolved_wunion_get_real_src(viface, vself, &src));
return avro_value_set_branch(&src, discriminant, branch);
}
static avro_resolved_wunion_reader_t *
avro_resolved_wunion_reader_create(avro_schema_t wschema, avro_schema_t rschema)
{
avro_resolved_reader_t *self = (avro_resolved_reader_t *) avro_new(avro_resolved_wunion_reader_t);
memset(self, 0, sizeof(avro_resolved_wunion_reader_t));
self->parent.incref_iface = avro_resolved_reader_incref_iface;
self->parent.decref_iface = avro_resolved_reader_decref_iface;
self->parent.incref = avro_resolved_reader_incref;
self->parent.decref = avro_resolved_reader_decref;
self->parent.reset = avro_resolved_reader_reset;
self->parent.get_type = avro_resolved_reader_get_type;
self->parent.get_schema = avro_resolved_reader_get_schema;
self->parent.get_boolean = avro_resolved_wunion_reader_get_boolean;
self->parent.grab_bytes = avro_resolved_wunion_reader_grab_bytes;
self->parent.get_bytes = avro_resolved_wunion_reader_get_bytes;
self->parent.get_double = avro_resolved_wunion_reader_get_double;
self->parent.get_float = avro_resolved_wunion_reader_get_float;
self->parent.get_int = avro_resolved_wunion_reader_get_int;
self->parent.get_long = avro_resolved_wunion_reader_get_long;
self->parent.get_null = avro_resolved_wunion_reader_get_null;
self->parent.get_string = avro_resolved_wunion_reader_get_string;
self->parent.grab_string = avro_resolved_wunion_reader_grab_string;
self->parent.get_enum = avro_resolved_wunion_reader_get_enum;
self->parent.get_fixed = avro_resolved_wunion_reader_get_fixed;
self->parent.grab_fixed = avro_resolved_wunion_reader_grab_fixed;
self->parent.set_boolean = avro_resolved_wunion_reader_set_boolean;
self->parent.set_bytes = avro_resolved_wunion_reader_set_bytes;
self->parent.give_bytes = avro_resolved_wunion_reader_give_bytes;
self->parent.set_double = avro_resolved_wunion_reader_set_double;
self->parent.set_float = avro_resolved_wunion_reader_set_float;
self->parent.set_int = avro_resolved_wunion_reader_set_int;
self->parent.set_long = avro_resolved_wunion_reader_set_long;
self->parent.set_null = avro_resolved_wunion_reader_set_null;
self->parent.set_string = avro_resolved_wunion_reader_set_string;
self->parent.set_string_len = avro_resolved_wunion_reader_set_string_len;
self->parent.give_string_len = avro_resolved_wunion_reader_give_string_len;
self->parent.set_enum = avro_resolved_wunion_reader_set_enum;
self->parent.set_fixed = avro_resolved_wunion_reader_set_fixed;
self->parent.give_fixed = avro_resolved_wunion_reader_give_fixed;
self->parent.get_size = avro_resolved_wunion_reader_get_size;
self->parent.get_by_index = avro_resolved_wunion_reader_get_by_index;
self->parent.get_by_name = avro_resolved_wunion_reader_get_by_name;
self->parent.get_discriminant = avro_resolved_wunion_reader_get_discriminant;
self->parent.get_current_branch = avro_resolved_wunion_reader_get_current_branch;
self->parent.append = avro_resolved_wunion_reader_append;
self->parent.add = avro_resolved_wunion_reader_add;
self->parent.set_branch = avro_resolved_wunion_reader_set_branch;
self->refcount = 1;
self->wschema = avro_schema_incref(wschema);
self->rschema = avro_schema_incref(rschema);
self->calculate_size = avro_resolved_wunion_reader_calculate_size;
self->free_iface = avro_resolved_wunion_reader_free_iface;
self->init = avro_resolved_wunion_reader_init;
self->done = avro_resolved_wunion_reader_done;
self->reset_wrappers = avro_resolved_wunion_reader_reset;
return container_of(self, avro_resolved_wunion_reader_t, parent);
}
static avro_resolved_reader_t *
try_writer_union(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
/*
* For a writer union, we check each branch of the union in turn
* against the reader schema. For each one that is compatible,
* we save the child resolver that can be used to process a
* writer value of that branch.
*/
size_t branch_count = avro_schema_union_size(wschema);
AVRO_DEBUG("Checking %" PRIsz "-branch writer union schema", branch_count);
avro_resolved_wunion_reader_t *uself =
avro_resolved_wunion_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, uself);
avro_resolved_reader_t **branch_resolvers =
(avro_resolved_reader_t **) avro_calloc(branch_count, sizeof(avro_resolved_reader_t *));
int some_branch_compatible = 0;
size_t i;
for (i = 0; i < branch_count; i++) {
avro_schema_t branch_schema =
avro_schema_union_branch(wschema, i);
AVRO_DEBUG("Resolving writer union branch %" PRIsz " (%s)", i,
avro_schema_type_name(branch_schema));
/*
* Try to recursively resolve this branch of the writer
* union against the reader schema. Don't raise
* an error if this fails โ we just need one of
* the writer branches to be compatible.
*/
branch_resolvers[i] =
avro_resolved_reader_new_memoized(state, branch_schema, rschema);
if (branch_resolvers[i] == NULL) {
AVRO_DEBUG("No match for writer union branch %" PRIsz, i);
} else {
AVRO_DEBUG("Found match for writer union branch %" PRIsz, i);
some_branch_compatible = 1;
}
}
/*
* If we didn't find a match, that's an error.
*/
if (!some_branch_compatible) {
AVRO_DEBUG("No writer union branches match");
avro_set_error("No branches in the writer are compatible "
"with reader schema %s",
avro_schema_type_name(rschema));
goto error;
}
uself->branch_count = branch_count;
uself->branch_resolvers = branch_resolvers;
return &uself->parent;
error:
/*
* Clean up any resolver we might have already created.
*/
avro_memoize_delete(&state->mem, wschema, rschema);
avro_value_iface_decref(&uself->parent.parent);
{
unsigned int i;
for (i = 0; i < branch_count; i++) {
if (branch_resolvers[i]) {
avro_value_iface_decref(&branch_resolvers[i]->parent);
}
}
}
avro_free(branch_resolvers, branch_count * sizeof(avro_resolved_reader_t *));
return NULL;
}
/*-----------------------------------------------------------------------
* reader union
*/
/*
* For reader unions, we only resolve them against writers which aren't
* unions. (We'll have already broken any writer union apart into its
* separate branches.) We just have to record which branch of the
* reader union the writer schema is compatible with.
*/
typedef struct avro_resolved_runion_reader {
avro_resolved_reader_t parent;
/* The reader union branch that's compatible with the writer
* schema. */
size_t active_branch;
/* A child resolver for the reader branch. */
avro_resolved_reader_t *branch_resolver;
} avro_resolved_runion_reader_t;
static void
avro_resolved_runion_reader_calculate_size(avro_resolved_reader_t *iface)
{
avro_resolved_runion_reader_t *uiface =
container_of(iface, avro_resolved_runion_reader_t, parent);
/* Only calculate the size for any resolver once */
iface->calculate_size = NULL;
AVRO_DEBUG("Calculating size for %s->%s",
avro_schema_type_name((iface)->wschema),
avro_schema_type_name((iface)->rschema));
avro_resolved_reader_calculate_size(uiface->branch_resolver);
iface->instance_size = uiface->branch_resolver->instance_size;
}
static void
avro_resolved_runion_reader_free_iface(avro_resolved_reader_t *iface, st_table *freeing)
{
avro_resolved_runion_reader_t *uiface =
container_of(iface, avro_resolved_runion_reader_t, parent);
if (uiface->branch_resolver != NULL) {
free_resolver(uiface->branch_resolver, freeing);
}
avro_schema_decref(iface->wschema);
avro_schema_decref(iface->rschema);
avro_freet(avro_resolved_runion_reader_t, iface);
}
static int
avro_resolved_runion_reader_init(const avro_resolved_reader_t *iface, void *vself)
{
avro_resolved_runion_reader_t *uiface =
container_of(iface, avro_resolved_runion_reader_t, parent);
return avro_resolved_reader_init(uiface->branch_resolver, vself);
}
static void
avro_resolved_runion_reader_done(const avro_resolved_reader_t *iface, void *vself)
{
avro_resolved_runion_reader_t *uiface =
container_of(iface, avro_resolved_runion_reader_t, parent);
avro_resolved_reader_done(uiface->branch_resolver, vself);
}
static int
avro_resolved_runion_reader_reset(const avro_resolved_reader_t *iface, void *vself)
{
avro_resolved_runion_reader_t *uiface =
container_of(iface, avro_resolved_runion_reader_t, parent);
return avro_resolved_reader_reset_wrappers(uiface->branch_resolver, vself);
}
static int
avro_resolved_runion_reader_get_discriminant(const avro_value_iface_t *viface,
const void *vself, int *out)
{
AVRO_UNUSED(vself);
const avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
const avro_resolved_runion_reader_t *uiface =
container_of(iface, avro_resolved_runion_reader_t, parent);
AVRO_DEBUG("Reader union is branch %" PRIsz, uiface->active_branch);
*out = uiface->active_branch;
return 0;
}
static int
avro_resolved_runion_reader_get_current_branch(const avro_value_iface_t *viface,
const void *vself, avro_value_t *branch)
{
const avro_resolved_reader_t *iface =
container_of(viface, avro_resolved_reader_t, parent);
const avro_resolved_runion_reader_t *uiface =
container_of(iface, avro_resolved_runion_reader_t, parent);
AVRO_DEBUG("Getting reader branch %" PRIsz " for union %p", uiface->active_branch, vself);
branch->iface = &uiface->branch_resolver->parent;
branch->self = (void *) vself;
return 0;
}
static avro_resolved_runion_reader_t *
avro_resolved_runion_reader_create(avro_schema_t wschema, avro_schema_t rschema)
{
avro_resolved_reader_t *self = (avro_resolved_reader_t *) avro_new(avro_resolved_runion_reader_t);
memset(self, 0, sizeof(avro_resolved_runion_reader_t));
self->parent.incref_iface = avro_resolved_reader_incref_iface;
self->parent.decref_iface = avro_resolved_reader_decref_iface;
self->parent.incref = avro_resolved_reader_incref;
self->parent.decref = avro_resolved_reader_decref;
self->parent.reset = avro_resolved_reader_reset;
self->parent.get_type = avro_resolved_reader_get_type;
self->parent.get_schema = avro_resolved_reader_get_schema;
self->parent.get_discriminant = avro_resolved_runion_reader_get_discriminant;
self->parent.get_current_branch = avro_resolved_runion_reader_get_current_branch;
self->refcount = 1;
self->wschema = avro_schema_incref(wschema);
self->rschema = avro_schema_incref(rschema);
self->calculate_size = avro_resolved_runion_reader_calculate_size;
self->free_iface = avro_resolved_runion_reader_free_iface;
self->init = avro_resolved_runion_reader_init;
self->done = avro_resolved_runion_reader_done;
self->reset_wrappers = avro_resolved_runion_reader_reset;
return container_of(self, avro_resolved_runion_reader_t, parent);
}
static avro_resolved_reader_t *
try_reader_union(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
/*
* For a reader union, we have to identify which branch
* corresponds to the writer schema. (The writer won't be a
* union, since we'll have already broken it into its branches.)
*/
size_t branch_count = avro_schema_union_size(rschema);
AVRO_DEBUG("Checking %" PRIsz "-branch reader union schema", branch_count);
avro_resolved_runion_reader_t *uself =
avro_resolved_runion_reader_create(wschema, rschema);
avro_memoize_set(&state->mem, wschema, rschema, uself);
size_t i;
for (i = 0; i < branch_count; i++) {
avro_schema_t branch_schema =
avro_schema_union_branch(rschema, i);
AVRO_DEBUG("Resolving reader union branch %" PRIsz " (%s)", i,
avro_schema_type_name(branch_schema));
/*
* Try to recursively resolve this branch of the reader
* union against the writer schema. Don't raise
* an error if this fails โ we just need one of
* the reader branches to be compatible.
*/
uself->branch_resolver =
avro_resolved_reader_new_memoized(state, wschema, branch_schema);
if (uself->branch_resolver == NULL) {
AVRO_DEBUG("No match for reader union branch %" PRIsz, i);
} else {
AVRO_DEBUG("Found match for reader union branch %" PRIsz, i);
uself->active_branch = i;
return &uself->parent;
}
}
/*
* If we didn't find a match, that's an error.
*/
AVRO_DEBUG("No reader union branches match");
avro_set_error("No branches in the reader are compatible "
"with writer schema %s",
avro_schema_type_name(wschema));
goto error;
error:
/*
* Clean up any resolver we might have already created.
*/
avro_memoize_delete(&state->mem, wschema, rschema);
avro_value_iface_decref(&uself->parent.parent);
return NULL;
}
/*-----------------------------------------------------------------------
* Schema type dispatcher
*/
static avro_resolved_reader_t *
avro_resolved_reader_new_memoized(memoize_state_t *state,
avro_schema_t wschema, avro_schema_t rschema)
{
check_param(NULL, is_avro_schema(wschema), "writer schema");
check_param(NULL, is_avro_schema(rschema), "reader schema");
/*
* First see if we've already matched these two schemas. If so,
* just return that resolver.
*/
avro_resolved_reader_t *saved = NULL;
if (avro_memoize_get(&state->mem, wschema, rschema, (void **) &saved)) {
AVRO_DEBUG("Already resolved %s%s%s->%s%s%s",
is_avro_link(wschema)? "[": "",
avro_schema_type_name(wschema),
is_avro_link(wschema)? "]": "",
is_avro_link(rschema)? "[": "",
avro_schema_type_name(rschema),
is_avro_link(rschema)? "]": "");
return saved;
} else {
AVRO_DEBUG("Resolving %s%s%s->%s%s%s",
is_avro_link(wschema)? "[": "",
avro_schema_type_name(wschema),
is_avro_link(wschema)? "]": "",
is_avro_link(rschema)? "[": "",
avro_schema_type_name(rschema),
is_avro_link(rschema)? "]": "");
}
/*
* Otherwise we have some work to do. First check if the writer
* schema is a union. If so, break it apart.
*/
if (is_avro_union(wschema)) {
return try_writer_union(state, wschema, rschema);
}
else if (is_avro_link(wschema)) {
return try_wlink(state, wschema, rschema);
}
/*
* If the writer isn't a union, than choose a resolver based on
* the reader schema.
*/
switch (avro_typeof(rschema))
{
case AVRO_BOOLEAN:
return try_boolean(state, wschema, rschema);
case AVRO_BYTES:
return try_bytes(state, wschema, rschema);
case AVRO_DOUBLE:
return try_double(state, wschema, rschema);
case AVRO_FLOAT:
return try_float(state, wschema, rschema);
case AVRO_INT32:
return try_int(state, wschema, rschema);
case AVRO_INT64:
return try_long(state, wschema, rschema);
case AVRO_NULL:
return try_null(state, wschema, rschema);
case AVRO_STRING:
return try_string(state, wschema, rschema);
case AVRO_ARRAY:
return try_array(state, wschema, rschema);
case AVRO_ENUM:
return try_enum(state, wschema, rschema);
case AVRO_FIXED:
return try_fixed(state, wschema, rschema);
case AVRO_MAP:
return try_map(state, wschema, rschema);
case AVRO_RECORD:
return try_record(state, wschema, rschema);
case AVRO_UNION:
return try_reader_union(state, wschema, rschema);
case AVRO_LINK:
return try_rlink(state, wschema, rschema);
default:
avro_set_error("Unknown reader schema type");
return NULL;
}
return NULL;
}
avro_value_iface_t *
avro_resolved_reader_new(avro_schema_t wschema, avro_schema_t rschema)
{
/*
* Create a state to keep track of the value implementations
* that we create for each subschema.
*/
memoize_state_t state;
avro_memoize_init(&state.mem);
state.links = NULL;
/*
* Create the value implementations.
*/
avro_resolved_reader_t *result =
avro_resolved_reader_new_memoized(&state, wschema, rschema);
if (result == NULL) {
avro_memoize_done(&state.mem);
return NULL;
}
/*
* Fix up any link schemas so that their value implementations
* point to their target schemas' implementations.
*/
avro_resolved_reader_calculate_size(result);
while (state.links != NULL) {
avro_resolved_link_reader_t *liface = state.links;
avro_resolved_reader_calculate_size(liface->target_resolver);
state.links = liface->next;
liface->next = NULL;
}
/*
* And now we can return.
*/
avro_memoize_done(&state.mem);
return &result->parent;
}
| jlawton/ObjectiveAvro | Avro-C/src/resolved-reader.c | C | mit | 107,543 |
\textbf{ะั
ะพะดะฝัะต ะฟะฐัะฐะผะตััั:}
ะััััััะฒััั.
ะ ะฟะตัะตะพะฟัะตะดะตะปัะตะผะพะน ััะฝะบัะธะธ ัะฐะบะถะต ะตััั ะฟะฐัะฐะผะตัั:
Type --- ะพะฑะพะทะฝะฐัะตะฝะธะต ัะตััะพะฒะพะน ััะฝะบัะธะธ, ะบะพัะพััั ะฒัะทัะฒะฐะตะผ.
ะกะผะพััะตัั ะฒะธะดั ะฒ ะฟะตัะตะผะตะฝะฝัั
ะฟะตัะตัะธัะปัะตะผะพะณะพ ัะธะฟะฐ ะฒ ะฝะฐัะฐะปะต HarrixMathLibrary.h ัะฐะนะปะฐ: TestFunction\_Ackley, TestFunction\_ParaboloidOfRevolution, TestFunction\_Rastrigin ะธ ะดั. ะะฝะธ ัะพะฒะฟะฐะดะฐัั ั ะฝะฐะทะฒะฐะฝะธัะผะธ ะพะดะฝะพะธะผะตะฝะฝัั
ัะตััะพะฒัั
ััะฝะบัะธะน, ะฝะพ ะฑะตะท ะฟัะธััะฐะฒะบะธ \textbf{HML\_}.
\textbf{ะะพะทะฒัะฐัะฐะตะผะพะต ะทะฝะฐัะตะฝะธะต:}
ะขะพัะฝะพััั ะฒััะธัะปะตะฝะธะน.
ะัะฐะบ, ะดะปั ะพะฑััะฝะพะณะพ ะธัะฟะพะปัะทะพะฒะฐะฝะธั (ะฑะตะท ะฟะฐัะฐะผะตััะฐ Type) ะฝัะถะฝะพ ะฒัะทะฒะฐัั ััะฝะบัะธั HML\_DefineTestFunction. ะะฝะฐัะต ะธัะฟะพะปัะทะพะฒะฐัั ะฟะตัะตะพะฟัะตะดะตะปะตะฝะฝัั ััะฝะบัะธั ะธ ัะฐะผะพะผั ัะบะฐะทะฐัั ัะธะฟ ัะตััะพะฒะพะน ััะฝะบัะธะธ. | Harrix/HarrixMathLibraryForTestFunctions | source_library/ะะปั ัะตััะพะฒัั
ััะฝะบัะธะน/HML_PrecisionOfCalculationsOfTestFunction_Real.tex | TeX | mit | 1,051 |
'use strict';
export interface IPrint extends ng.resource.IResource<IPrint> {
printOptions: any;
}
export interface IPrintResource extends ng.resource.IResourceClass<IPrint> {}
export class PrintResource {
/* @ngInject */
public static Print($resource: ng.resource.IResourceService): IPrintResource {
var url = '/api/print';
var resource = $resource(url, {});
return <IPrintResource> resource;
}
}
| marksmall/mapuse | src/app/components/print/print.resource.ts | TypeScript | mit | 424 |
---
layout: page
title: Tough Dark Company Dinner
date: 2016-05-24
author: Charles Terrell
tags: weekly links, java
status: published
summary: Aliquam non vehicula metus. Curabitur at est.
banner: images/banner/leisure-01.jpg
booking:
startDate: 04/03/2017
endDate: 04/08/2017
ctyhocn: PHXSRHX
groupCode: TDCD
published: true
---
Praesent tincidunt eget eros et pharetra. Donec quis enim aliquam, rutrum odio elementum, gravida arcu. Cras lobortis gravida lectus, eu ullamcorper dolor rutrum vel. In sit amet ex sagittis, convallis velit id, egestas nibh. Praesent nisl dolor, laoreet ac sapien vel, lobortis vulputate lectus. Fusce placerat varius turpis sit amet dignissim. Nullam non felis in nisi varius sollicitudin vitae id justo. Donec commodo enim eget cursus ornare. Donec turpis nunc, sodales eget rhoncus ac, laoreet vitae ligula.
Nulla venenatis scelerisque lacus vel consequat. Donec lobortis feugiat purus at pretium. Quisque consequat enim semper interdum placerat. Nunc consectetur, mauris a cursus placerat, sem quam ullamcorper sem, nec tincidunt augue nibh et orci. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Phasellus condimentum finibus ligula, sit amet interdum est elementum eu. Fusce id purus fermentum, scelerisque sem id, pulvinar dui. Pellentesque eget laoreet arcu, in posuere risus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec lobortis elementum diam, pretium auctor ante venenatis eu. Nulla facilisi. Duis eu eleifend sapien.
* Morbi non dui non sem ornare porttitor eu in libero
* Phasellus rhoncus orci a arcu mattis, id iaculis augue sagittis.
Etiam sodales sem leo, vel porttitor mauris vulputate eu. Interdum et malesuada fames ac ante ipsum primis in faucibus. Integer volutpat, risus sit amet fringilla placerat, ante orci ornare nulla, nec ultricies sem arcu porttitor velit. Vivamus sagittis justo non nibh hendrerit, eu venenatis elit consequat. Praesent sagittis urna non erat luctus accumsan. Duis cursus massa vitae velit condimentum condimentum. Aliquam erat volutpat. Quisque sodales et turpis ut auctor. Mauris sit amet tempus sapien. Donec egestas arcu vitae risus congue, rhoncus finibus turpis sollicitudin. Aliquam accumsan tristique sagittis. Sed magna felis, mollis vitae vehicula vel, venenatis dapibus urna. Etiam faucibus tellus pharetra, tincidunt arcu non, pulvinar purus. Phasellus id magna dui. Integer fermentum mattis efficitur. Cras efficitur ex leo, id sodales libero posuere non.
| KlishGroup/prose-pogs | pogs/P/PHXSRHX/TDCD/index.md | Markdown | mit | 2,529 |
---
layout: page
title: Diamond Forest Entertainment Show
date: 2016-05-24
author: Nicholas Palmer
tags: weekly links, java
status: published
summary: Pellentesque a dolor dictum, congue arcu.
banner: images/banner/meeting-01.jpg
booking:
startDate: 09/27/2018
endDate: 09/30/2018
ctyhocn: MQBILHX
groupCode: DFES
published: true
---
Ut non aliquet turpis. Phasellus a massa porta, facilisis augue id, rutrum sapien. Sed volutpat felis ex, vel ornare enim lacinia nec. Sed non sagittis purus. Nam placerat dui vel neque tristique sollicitudin. Cras aliquam sapien ex, non facilisis eros laoreet sit amet. Nulla eu dolor tincidunt, laoreet tellus ut, porta lacus.
* Integer ut odio et lorem fermentum iaculis.
Mauris id risus in lacus venenatis pellentesque non in diam. Fusce tempus sit amet sem sed suscipit. Aenean non sodales mi, eu blandit diam. Interdum et malesuada fames ac ante ipsum primis in faucibus. Suspendisse potenti. Donec quis turpis venenatis, rutrum elit id, imperdiet urna. Praesent arcu tortor, imperdiet egestas placerat id, ultrices ut quam. Aliquam varius accumsan placerat. Sed egestas et enim nec suscipit.
| KlishGroup/prose-pogs | pogs/M/MQBILHX/DFES/index.md | Markdown | mit | 1,143 |
<?php
// :default:index.html.twig
return array (
'fe7793f' =>
array (
0 =>
array (
0 => '@bootstrap_css',
1 => '@fontawesome_css_be',
2 => '@YallaWebsiteBackendBundle/Resources/public/css/jquery-ui.css',
3 => '@YallaWebsiteBackendBundle/Resources/public/css/select2.min.css',
4 => '@YallaWebsiteBackendBundle/Resources/public/css/jquery.tagsinput.min.css',
5 => '@YallaWebsiteBackendBundle/Resources/public/css/image-picker.css',
6 => '@YallaWebsiteBackendBundle/Resources/public/css/style.css',
),
1 =>
array (
),
2 =>
array (
'output' => '_controller/css/fe7793f.css',
'name' => 'fe7793f',
'debug' => NULL,
'combine' => NULL,
'vars' =>
array (
),
),
),
'a56fa94' =>
array (
0 =>
array (
0 => '@jquery',
1 => '@bootstrap_js',
),
1 =>
array (
),
2 =>
array (
'output' => '_controller/js/a56fa94.js',
'name' => 'a56fa94',
'debug' => NULL,
'combine' => NULL,
'vars' =>
array (
),
),
),
);
| DevKhater/YallaWebSite | app/cache/dev/assetic/config/a/ae1b290dcfca1cdecd87a85bbe4b1164.php | PHP | mit | 1,120 |
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "search.h"
#include "marcov.h"
#define ORDER 2
int main(int argc, char **argv) {
int limit = 128;
if(argc > 1) {
limit = atoi(argv[1]);
}
void *strings = NULL;
struct timespec t;
clock_gettime(CLOCK_MONOTONIC, &t);
srand(t.tv_nsec);
marcov_t *m = NULL;
marcov_load(&strings, &m, 0);
char *nl = stringidx(&strings, "\n");
wordlist_t nlstart = (wordlist_t) {.num = 1, .w = &nl};
wordlist_t *wl = NULL;
wl = marcov_randomstart(m, &nlstart);
if(!wl) {
wl = marcov_randomstart(m, NULL);
}
for(int i = 0; i < limit; i++) {
char *line = marcov_getline(m);
if(!line) {
break;
}
printf("%s", line);
free(line);
}
return 0;
}
| Cat-Ion/marcov | run-lines.c | C | mit | 745 |
/**
* JRakLibPlus is not affiliated with Jenkins Software LLC or RakNet.
* This software is an enhanced port of RakLib https://github.com/PocketMine/RakLib.
* This file is part of JRakLibPlus.
*
* JRakLibPlus is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* JRakLibPlus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with JRakLibPlus. If not, see <http://www.gnu.org/licenses/>.
*/
package io.github.jython234.jraklibplus.protocol.raknet;
import static io.github.jython234.jraklibplus.JRakLibPlus.*;
/**
* Created by jython234 on 9/12/2015.
*
* @author RedstoneLamp Team
*/
public class NACKPacket extends AcknowledgePacket {
@Override
public byte getPID() {
return NACK;
}
}
| MrGenga/BouncyBall | src/main/java/io/github/jython234/jraklibplus/protocol/raknet/NACKPacket.java | Java | mit | 1,189 |
# Simple.LocalDb
Simple.LocalDb is a simple managed wrapper around the LocalDB API.
This framework has no features. It does not have error checking. It does not do anything smart. It doesn't try to help you in any way. There are no unit tests. There are no integration tests. There are no interfaces, inheritance, coupling, or clever abstractions.
If you're like me and you basically want to call 'CreateInstance' from your test code, this package is your friend.
If you need to automagically deploy a dacpac to a dynamically created test instance, this is not your package.
If you want a smart and robust LocalDb provider that can create different versions of instances, be localized, will clean up cruft localdb files from the filesystem, and will recover from failures, this is not your package.
Try one of these instead:
- [Nicholas Ham's LocalDb NuGet package](https://www.nuget.org/packages/SqlLocalDb.Dac/).
- [Martin Costello's LocalDb NuGet package](https://www.nuget.org/packages/System.Data.SqlLocalDb/).
To use this package:
- You can create an instance of the managed interface, which hides some of the marshaling complexity from you (there's not much).
- You can create an instance of the unmanaged interface and write your own better wrapper around it.
- If you want to use it as a nuget package. Have at it.
- If you want to include the project source in your project. Have at it.
- If you want to copy paste parts of the code into yours. Have at it.
- If you need to target the .Net 3.5 (neee 2.0) runtime and reference a signed assembly. Grab the source and have at it.
- If you want to copy this code and publish a new nuget package from it with a different name and 0..n modifications. Have at it.
Example Managed API usage:
```
//New up the API.
var api = new ManagedLocalDbApi();
//Get all the instances as a list of strings.
var instanceNames = api.GetInstanceNames().ToList();
//Create a new instance with a random name.
var testInstanceName = Path.GetRandomFileName();
api.CreateInstance(testInstanceName);
//Start the instance and get its connection string (named pipes).
var connection = api.StartInstance(testInstanceName);
//Get a bunch of fun details about the instance.
var testInstance = api.GetInstance(testInstanceName);
//Stop the instance. Timeout if it takes longer than 60 seconds.
api.StopInstance(testInstanceName, TimeSpan.FromSeconds(60));
//Delete the instance.
api.DeleteInstance(testInstanceName);
```
| skyguy94/Simple.LocalDb | README.md | Markdown | mit | 2,475 |
๏ปฟ#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using System.IO;
public class CreateAssetbundle : MonoBehaviour {
[MenuItem("Fineness/Build AssetBundle From Select Resource")]
static void SelectResourceAndBuildAB()
{
UnityEngine.Object[] selecteds = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets);
var count = 0;
var max = selecteds.Length;
var fileNames = new string[max];
var assetBundle = new AssetBundleBuild();
Debug.Log("ๅณๅฐๆๅ
็ๆไปถ่ทฏๅพ้ๅ๏ผ");
for (var i = 0; i < max; i++)
{
var target = selecteds[i];
string assetPath = AssetDatabase.GetAssetPath(target);
var fileName = assetPath;
assetPath = assetPath.Replace("Assets/", "");
var fileInfo = new FileInfo(assetPath);
if ((fileName.IndexOf('.') != -1) &&
(fileInfo.Extension != "cs") &&
(fileInfo.Extension != "meta"))
{
fileNames[i] = fileName;
count++;
Debug.Log(i + " >> " + fileNames[i]);
}
}
if (count > 0)
{
var activer = Selection.activeObject;
if (activer == null)
{
Debug.Log(" โฎ(โฏโฝโฐ)โญ ็ผบๅฐ่ขซ้ไธญ็ๆฟๆดป็ฉไปถ๏ผ่ฏท้ๆฉๅ้่ฏ...");
return;
}
assetBundle.assetBundleName = activer.name;
assetBundle.assetNames = fileNames;
var outputFileName = Application.streamingAssetsPath + "/AB" + assetBundle.assetBundleName;
if (!Directory.Exists(outputFileName))
Directory.CreateDirectory(outputFileName);
var options = BuildAssetBundleOptions.None;
var path = "Assets" + outputFileName.Replace(Application.dataPath, "");
BuildPipeline.BuildAssetBundles(path, new[] { assetBundle }, options, EditorUserBuildSettings.activeBuildTarget);
AssetDatabase.Refresh();
Debug.Log(" โช(^โ^*) ๅฐๆฌ็ไธปไบบ๏ผๆๅ
ๅทฒๅฎๆ๏ผ่ตๆบๅญๆพ่ทฏๅพ๏ผ" + path);
}
else
Debug.Log("ๆ้ๆไปถไธญๆฒกๆๅฏๆๅ
็่ตๆบ");
}
}
//่ทๅๆๅ
็ๅนณๅฐ
public class PlatformPath
{
/// <summary>
/// ่ทๅๆๅ
็ๅนณๅฐ๏ผๆ นๆฎๅนณๅฐ่ฎพ็ฝฎๆๅ
็ๆไปถๅคนๅ็งฐ
/// </summary>
/// <param name="target"></param>
/// <returns></returns>
public static string GetPlatformFolder(BuildTarget target)
{
switch (target)
{
case BuildTarget.Android:
return "Android";
case BuildTarget.iOS:
return "IOS";
//case BuildTarget.WebPlayer:
// return "WebPlayer";
case BuildTarget.StandaloneWindows:
case BuildTarget.StandaloneWindows64:
return "Windows";
case BuildTarget.StandaloneOSXIntel:
case BuildTarget.StandaloneOSXIntel64:
case BuildTarget.StandaloneOSXUniversal:
return "OSX";
default: return null;
}
}
}
#endif
| firefishes/ShipDockU3D | Framework/Editer/AssetBundle/CreateAssetbundle.cs | C# | mit | 3,193 |
import http from "http";
import express from "express";
import cors from "cors";
import morgan from "morgan";
import bodyParser from "body-parser";
import initializeDb from "./db";
import middleware from "./middleware";
import api from "./api";
import config from "config"; //we load the db location from the JSON files
let app = express();
app.server = http.createServer(app);
//don't show the log when it is test
if (process.env.NODE_ENV !== "test") {
// logger
app.use(morgan("dev"));
}
// 3rd party middleware
app.use(
cors({
exposedHeaders: config.corsHeaders
})
);
app.use(
bodyParser.json({
limit: config.bodyLimit
})
);
const dbOptions = {
useMongoClient: true
};
// connect to db
initializeDb(config.dbURI, dbOptions, () => {
// internal middleware
app.use(middleware({ config }));
// api router
app.use("/api", api({ config }));
app.server.listen(process.env.PORT || config.port, () => {
console.log(`Started on port ${app.server.address().port}`);
});
});
export default app;
| Hackstr/my-express-boilerplate | src/index.js | JavaScript | mit | 1,034 |
##Generators
<div class="code-extra es6">
```js
// Define generators with '*'
function *foo() { }
// halt and output at 'yield'
function *fibonacci() {
let pre = 0, cur = 1;
while(true) {
[ pre, cur ] = [ cur, pre + cur ];
yield cur;
}
}
let fibGen = fibonacci();
fibGen.next(); // { value: 1, done: false }
fibGen.next(); // { value: 2, done: false }
// Can use For..Of on generators
for(let x of fibGen) {
if (x > 1000) {
break;
}
console.log(x);
}
// 1, 2, 3, 5, 8...
```
Note:
- defined with 'star'
- generators can be halted
- yield outputs value
- yield accepts value
| afram/reveal.js | md/slide-29-generators.md | Markdown | mit | 597 |
# Advanced ่ฟ้ถ
<p class="description">ๆฌ่ๅ
ๅซไบ @material-ui/core/styles ็ไธไบๆดๅค็่ฟ้ถ็จๆณใ</p>
## Theming ไธป้ข
่ฅๆจๆณๅฐไธป้ขไผ ้ๅฐ React ็ปไปถๆ ๏ผ่ฏทๅฐๆทปๅ `ThemeProvider` ๅ
่ฃ
ๅฐๅบ็จ็จๅบ็้กถๅฑใ ็ถๅ๏ผๆจๅฏไปฅๅจๆ ทๅผๅฝๆฐไธญ่ฎฟ้ฎไธป้ขๅฏน่ฑกใ
> ๆญค็คบไพไธบ่ชๅฎไน็ปไปถๅๅปบไบไธไธชไธป้ขๅฏน่ฑก๏ผtheme object๏ผใ If you intend to use some of the Material-UI's components you need to provide a richer theme structure using the `createTheme()` method. ่ฏทๅๅพ [theming ้จๅ](/customization/theming/) ๅญฆไน ๅฆไฝๆๅปบ่ชๅทฑ็ Material-UI ไธป้ขใ
```jsx
import { ThemeProvider } from '@material-ui/core/styles';
import DeepChild from './my_components/DeepChild';
const theme = {
background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)',
};
function Theming() {
return (
<ThemeProvider theme={theme}>
<DeepChild />
</ThemeProvider>
);
}
```
{{"demo": "pages/styles/advanced/Theming.js"}}
### ่ฎฟ้ฎไธไธช็ปไปถไธญ็ไธป้ข
ๆจๅฏ่ฝ้่ฆ่ฎฟ้ฎ React ็ปไปถไธญ็ไธป้ขๅ้ใ
#### `useTheme` hook
ๅจๅฝๆฐ็ปไปถ๏ผfunction components๏ผไธญ็ไฝฟ็จ๏ผ
```jsx
import { useTheme } from '@material-ui/core/styles';
function DeepChild() {
const theme = useTheme();
return <span>{`spacing ${theme.spacing}`}</span>;
}
```
{{"demo": "pages/styles/advanced/UseTheme.js"}}
#### `withTheme` HOC
ๅจ็ฑป๏ผclass๏ผๆๅฝๆฐ๏ผfunction๏ผ็ปไปถไธญ็ไฝฟ็จ๏ผ
```jsx
import { withTheme } from '@material-ui/core/styles';
function DeepChildRaw(props) {
return <span>{`spacing ${props.theme.spacing}`}</span>;
}
const DeepChild = withTheme(DeepChildRaw);
```
{{"demo": "pages/styles/advanced/WithTheme.js"}}
### ่ฆ็ไธป้ข
ๆจๅฏไปฅๅตๅฅๅคไธชไธป้ขๆไพ่
ใ ๅฝๆจๅจๅค็ๅบ็จ็จๅบ็ไธๅๅบๅๆถ๏ผ่ฅ้่ฆๅบ็จ็ไธๅๅค่ง๏ผ่ฟไธชๅ่ฝไผ่ฎฉๆจๅพๅฟๅบๆใ
```jsx
<ThemeProvider theme={outerTheme}>
<Child1 />
<ThemeProvider theme={innerTheme}>
<Child2 />
</ThemeProvider>
</ThemeProvider>
```
{{"demo": "pages/styles/advanced/ThemeNesting.js"}}
ๅ
้จไธป้ขๅฐ **่ฆ็** ๅค้จไธป้ขใ ไฝ ๅฏไปฅๆไพไธไธชๅฝๆฐๆฅๆฉๅฑๅคๅฑไธป้ข๏ผ
```jsx
<ThemeProvider theme={โฆ} >
<Child1 />
<ThemeProvider theme={outerTheme => ({ darkMode: true, ...outerTheme })}>
<Child2 />
</ThemeProvider>
</ThemeProvider>
```
## ่ฆ็ๆ ทๅผ โ `classes` ๅฑๆง
้่ฟ `makeStyles` (hook generator) ๅ `withStyles` (HOC) ่ฟไธคไธช API๏ผ ็จๆทๅฏไปฅไธบๆฏไธชๆ ทๅผ่กจๅๅปบๅค็งๆ ทๅผ่งๅใ ๆฏไธชๆ ทๅผ่งๅ้ฝๆ่ชๅทฑ็็ฑปๅใ ็ปไปถ็ `classes` ๅ้ไผๆไพ็ฑปๅ๏ผclass names๏ผใ ่ฟๅจ่ฎพ็ฝฎ็ปไปถไธญๅตๅฅๅ
็ด ็ๆ ทๅผๆถ็นๅซๆ็จใ
```jsx
// ๆ ทๅผ่กจ
const useStyles = makeStyles({
root: {}, // ๆ ทๅผ่งๅ
label: {}, // ๅตๅฅ็ๆ ทๅผ่งๅ
});
function Nested(props) {
const classes = useStyles();
return (
<button className={classes.root}>
{/* 'jss1' */}
<span className={classes.label}>{/* 'jss2' ๅตๅฅ่งๅ */}</span>
</button>
);
}
function Parent() {
return <Nested />;
}
```
ไฝๆฏ๏ผ็ฑปๅ้ๅธธๆฏไธ็กฎๅฎ็ใ ็ถ็บง็ปไปถๅฆไฝ่ฆ็ๅตๅฅๅ
็ด ็ๆ ทๅผๅข๏ผ
### `withStyles`
่ฟๆฏๆ็ฎๅ็ไธ็งๆ
ๅตใ ๅฐ่ฃ
็็ปไปถๆฅๅ `classes` ๅฑๆง๏ผ ๅฎ็ฎๅๅฐๅๅนถไบๆ ทๅผ่กจๆไพ็็ฑปๅใ
```jsx
const Nested = withStyles({
root: {}, // a style rule
label: {}, // a nested style rule
})(({ classes }) => (
<button className={classes.root}>
<span className={classes.label}>{/* 'jss2 my-label' Nested*/}</span>
</button>
));
function Parent() {
return <Nested classes={{ label: 'my-label' }} />;
}
```
### `makeStyles`
ๆณไฝฟ็จ hook API ็่ฏ้่ฆไธไบ้ขๅค็ๅทฅไฝใ ไฝ ๅฟ
้กปๆ็ถ็บงๅฑๆงไฝไธบ็ฌฌไธไธชๅๆฐไผ ้็ป hookใ
```jsx
const useStyles = makeStyles({
root: {}, // ๆ ทๅผ่งๅ
label: {}, // ๅตๅฅ็ๆ ทๅผ่งๅ
});
function Nested(props) {
const classes = useStyles(props);
return (
<button className={classes.root}>
<span className={classes.label}>{/* 'jss2 my-label' ๅตๅฅ่งๅ */}</span>
</button>
);
}
function Parent() {
return <Nested classes={{ label: 'my-label' }} />;
}
```
## JSS ๆไปถ
JSS ไฝฟ็จๆไปถๆฅๆฉๅฑๅ
ถๆ ธๅฟ๏ผๆจๅฏไปฅๆ้ๆ้็ๅ่ฝ๏ผๅนถไธๅช้ๆฟๆ
ๆจๆญฃๅจไฝฟ็จ็ๅ
ๅฎนๆง่ฝ็ๅผ้ใ
้ป่ฎคๆ
ๅตไธ๏ผไธๆฏๆๆ Material-UI ็ๆไปถ้ฝๅฏไปฅไฝฟ็จใ ไปฅไธ๏ผไธไธช [jss-preset-default ็ๅญ้](https://cssinjs.org/jss-preset-default/)๏ผ ่ขซๅ
ๅซๅจๅ
๏ผ
- [jss-plugin-rule-value-function](https://cssinjs.org/jss-plugin-rule-value-function/)
- [jss-plugin-global](https://cssinjs.org/jss-plugin-global/)
- [jss-plugin-nested](https://cssinjs.org/jss-plugin-nested/)
- [jss-plugin-camel-case](https://cssinjs.org/jss-plugin-camel-case/)
- [jss-plugin-default-unit](https://cssinjs.org/jss-plugin-default-unit/)
- [jss-plugin-vendor-prefixer](https://cssinjs.org/jss-plugin-vendor-prefixer/)
- [jss-plugin-props-sort](https://cssinjs.org/jss-plugin-props-sort/)
ๅฝ็ถ๏ผไฝ ไนๅฏไปฅ้ๆไฝฟ็จ้ขๅค็ๆไปถใ ๆไปฌๆไธไธชไฝฟ็จ [jss-rtl](https://github.com/alitaheri/jss-rtl) ๆไปถ็ไพๅญใ
```jsx
import { create } from 'jss';
import { StylesProvider, jssPreset } from '@material-ui/styles';
import rtl from 'jss-rtl';
const jss = create({
plugins: [...jssPreset().plugins, rtl()],
});
export default function App() {
return <StylesProvider jss={jss}>...</StylesProvider>;
}
```
## ๅญ็ฌฆไธฒๆจกๆฟ
ๅฆๆ็ธๆฏ JSS ๆจๆดๅๆฌข CSS ็่ฏญๆณ๏ผๅๅฏไปฅไฝฟ็จ [jss-plugin-template](https://cssinjs.org/jss-plugin-template/) ๆไปถใ
```jsx
const useStyles = makeStyles({
root: `
background: linear-gradient(45deg, #fe6b8b 30%, #ff8e53 90%);
border-radius: 3px;
font-size: 16px;
border: 0;
color: white;
height: 48px;
padding: 0 30px;
box-shadow: 0 3px 5px 2px rgba(255, 105, 135, 0.3);
`,
});
```
่ฏทๆณจๆ๏ผๆญคๆไปถไธๆฏๆ้ๆฉๅจๆๅตๅฅ่งๅใ
{{"demo": "pages/styles/advanced/StringTemplates.js"}}
## CSS ๆณจๅ
ฅ้กบๅบ
> ไบ่งฃๆต่งๅจๅฆไฝ่ฎก็ฎ CSS ไผๅ
็บงๆฏ**้ๅธธ้่ฆ็**๏ผๅ ไธบๅฎๆฏๆจๅจ่ฆ็ๆ ทๅผๆถ้่ฆไบ่งฃ็้็นไนไธใ ๆไปฌๆจ่ๆจ้
่ฏป MDN ไธ็่ฟๆฎตๅ
ๅฎน๏ผ[ๅฆไฝ่ฎก็ฎไผๅ
็บง๏ผ](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity#How_is_specificity_calculated)
้ป่ฎคๆ
ๅตไธ๏ผๆณจๅ
ฅ็styleๆ ็ญพไผ่ขซๆๅ
ฅๅฐ้กต้ข`<head>`ๅ
็ด ็ๆๅใ ๅฎไปฌ็ไผๅ
็บง้ซไบๆจ้กต้ขไธ็ไปปไฝๅ
ถไปๆ ทๅผๆ ็ญพ๏ผๅฆ CSS ๆจกๅใstyled componentsใ
### injectFirst
`StylesProvider`็ปไปถ็ๅฑๆง `injectFirst` ไผๆstyleๆ ็ญพๆณจๅ
ฅๅฐhead็**ๅ้จ**(ๆๅณ็ๆดไฝ็ๆ้)ใ
```jsx
import { StylesProvider } from '@material-ui/styles';
<StylesProvider injectFirst>
{/* ไฝ ็็ปไปถๆ ใ
ๆ ทๅผๅ็ปไปถๅฏไปฅ่ฆ็ Material-UI ็ๆ ทๅผใ */}
</StylesProvider>;
```
### `makeStyles` / `withStyles` / `styled`
ไฝฟ็จ `makeStyles` / `withStyles` / `styled` ็ๆณจๅ
ฅ้กบๅบไบ่ฐ็จ้กบๅบ**็ธๅ**ใ ไพๅฆ๏ผๅจ่ฟ็งๆ
ๅตไธ๏ผๅญไฝๆ็ปๆฏ็บข่ฒ๏ผ
```jsx
import clsx from 'clsx';
import { makeStyles } from '@material-ui/styles';
const useStylesBase = makeStyles({
root: {
color: 'blue', // ๐ต
},
});
const useStyles = makeStyles({
root: {
color: 'red', // ๐ด
},
});
export default function MyComponent() {
// Order doesn't matter
const classes = useStyles();
const classesBase = useStylesBase();
// Order doesn't matter
const className = clsx(classes.root, classesBase.root);
// color: red ๐ด wins.
return <div className={className} />;
}
```
Hook ่ฐ็จ้กบๅบๅ็ฑปๅ้กบๅบ**ไธๅฝฑๅ**ๆณจๅ
ฅๅฑๆงๆ้ ใ
### insertionPoint
JSS [ๆไพไบไธ็งๆบๅถ](https://github.com/cssinjs/jss/blob/master/docs/setup.md#specify-the-dom-insertion-point) ๆฅๆงๅถ่ฟ็งๆ
ๅตใ ้่ฟๅจ HTML ไธญๆทปๅ `insertionPoint`๏ผๆจๅฐฑๅฏไปฅ[ๆงๅถ](https://cssinjs.org/jss-api#attach-style-sheets-in-a-specific-order) CSS ่งๅๅบ็จๅฐ็ปไปถไธญ็้กบๅบใ
#### HTML ๆณจ้
ๆ็ฎๅ็ๆนๆณๆฏๅจ `<head>` ไธญๆทปๅ ไธไธช HTML ๆณจ้๏ผๆฅๅณๅฎ JSS ๆณจๅ
ฅๆ ทๅผ็ไฝ็ฝฎ๏ผ
```html
<head>
<!-- jss-insertion-point -->
<link href="..." />
</head>
```
```jsx
import { create } from 'jss';
import { StylesProvider, jssPreset } from '@material-ui/styles';
const jss = create({
...jssPreset(),
// Define a custom insertion point that JSS will look for when injecting the styles into the DOM.
insertionPoint: 'jss-insertion-point',
});
export default function App() {
return <StylesProvider jss={jss}>...</StylesProvider>;
}
```
#### ๅ
ถไป HTML ๅ
็ด
ๅจๆๅปบ็ไบง็ฏๅขๆถ๏ผ[Create React App](https://github.com/facebook/create-react-app) ไผ็งป้ค HTML ๆณจ้ใ ไธบไบ่งฃๅณ่ฟไธช้ฎ้ข๏ผๆจๅฏไปฅๆไพไธไธช DOM ๅ
็ด ๏ผ่ไธๆฏไธๆกๆณจ้๏ผไฝไธบ JSS ๆๅ
ฅ็น ๏ผ่ญฌๅฆไธไธช `<noscript>` ๅ
็ด ใ
```jsx
<head>
<noscript id="jss-insertion-point" />
<link href="..." />
</head>
```
```jsx
import { create } from 'jss';
import { StylesProvider, jssPreset } from '@material-ui/styles';
const jss = create({
...jssPreset(),
// Define a custom insertion point that JSS will look for when injecting the styles into the DOM.
insertionPoint: document.getElementById('jss-insertion-point'),
});
export default function App() {
return <StylesProvider jss={jss}>...</StylesProvider>;
}
```
#### JS createComment
codesandbox.io ้ปๆญข่ฎฟ้ฎ `<head>` ๅ
็ด ใ ่ฆ่งฃๅณ่ฟไธช้ฎ้ข๏ผๆจๅฏไปฅไฝฟ็จ JavaScript ไธญ็ `document.createComment()` APIใ
```jsx
import { create } from 'jss';
import { StylesProvider, jssPreset } from '@material-ui/styles';
const styleNode = document.createComment('jss-insertion-point');
document.head.insertBefore(styleNode, document.head.firstChild);
const jss = create({
...jssPreset(),
// Define a custom insertion point that JSS will look for when injecting the styles into the DOM.
insertionPoint: 'jss-insertion-point',
});
export default function App() {
return <StylesProvider jss={jss}>...</StylesProvider>;
}
```
## ๆๅก็ซฏๆธฒๆ
This example returns a string of HTML and inlines the critical CSS required, right before it's used:
```jsx
import ReactDOMServer from 'react-dom/server';
import { ServerStyleSheets } from '@material-ui/styles';
function render() {
const sheets = new ServerStyleSheets();
const html = ReactDOMServer.renderToString(sheets.collect(<App />));
const css = sheets.toString();
return `
<!DOCTYPE html>
<html>
<head>
<style id="jss-server-side">${css}</style>
</head>
<body>
<div id="root">${html}</div>
</body>
</html>
`;
}
```
ๆจๅฏไปฅ[ๆ นๆฎ่ฟ็ฏๆๅก็ซฏๆธฒๆๆๅ](/guides/server-rendering/)ๆฅ่ทๅๆดๅค่ฏฆ็ป็ไพๅญ๏ผๆ่
ๆจไนๅฏไปฅ้
่ฏป [`ServerStyleSheets` ็ API ๆๆกฃ](/styles/api/#serverstylesheets)ใ
### Gatsby
่ฟไธช [ๅฎๆน็ Gatsby ๆไปถ](https://github.com/hupe1980/gatsby-plugin-material-ui)๏ผๅฏไปฅๅฉ็จๅฎๆฅๅฎ็ฐ `@material-ui/style` ็ๆๅกๅจ็ซฏๆธฒๆใ ่ฏทๅ่ๆไปถ้กต้ข็่ฎพ็ฝฎๅไฝฟ็จ่ฏดๆใ
<!-- #default-branch-switch -->
่ฏทๅ่ [Gatsby ้กน็ฎๆกไพ](https://github.com/mui-org/material-ui/blob/next/examples/gatsby) ไปฅไบ่งฃๆๆฐ็ไฝฟ็จๆนๆณใ
### Next.js
ๆจ้่ฆๆไธไธช่ชๅฎไน็ `pages/_document.js`๏ผ็ถๅๅคๅถ [ๆญค้ป่พ](https://github.com/mui-org/material-ui/blob/814fb60bbd8e500517b2307b6a297a638838ca89/examples/nextjs/pages/_document.js#L52-L59) ไปฅๆณจๅ
ฅๆๅกๅจไพงๆธฒๆ็ๆ ทๅผๅฐ `<head>` ๅ
็ด ไธญใ
่ฏทๅ่ [็คบไพ้กน็ฎ](https://github.com/mui-org/material-ui/blob/next/examples/nextjs) ไปฅ่ทๅๆๆฐ็ไฝฟ็จๆนๆณใ
## ็ฑปๅ๏ผClass names๏ผ
็ฑปๅ๏ผclass names๏ผ็ฑ [็ฑปๅ็ๆๅจ](/styles/api/#creategenerateclassname-options-class-name-generator) ็ๆใ
### ้ป่ฎคๅผ
้ป่ฎคๆ
ๅตไธ๏ผ`@material-ui/core/styles` ็ๆ็็ฑปๅ **ไธๆฏๅบๅฎๅผ**๏ผ ๆไปฅไฝ ไธ่ฝๆๆๅฎไปฌไฟๆไธๅใ ่ฎฉๆไปฌไปฅไธ้ข็ๆ ทๅผ๏ผstyle๏ผไฝไธบ็คบไพ๏ผ
```js
const useStyles = makeStyles({
root: {
opacity: 1,
},
});
```
ไธ่ฟฐไพๅญๅฐ็ๆไธไธช็ฑปไผผไบ `makeStyles-root-123` ่ฟๆ ท็็ฑปๅใ
ๆจๅฟ
้กปไฝฟ็จ็ปไปถ็ `classes` ๅฑๆงๆฅ่ฆ็ๆ ทๅผใ ็ฑปๅ็ไธ็กฎๅฎๆงไฝฟๆ ทๅผ้็ฆปๆไธบๅฏ่ฝใ
- ๅจ**ๅผๅ็ฏๅขไธญ**๏ผ็ฑปๅไธบ๏ผ`.makeStyles-root-123`๏ผๅฎ้ตๅพชไปฅไธ้ป่พ๏ผ
```js
const sheetName = 'makeStyles';
const ruleName = 'root';
const identifier = 123;
const className = `${sheetName}-${ruleName}-${identifier}`;
```
- ๅจ**็ไบง็ฏๅขไธญ**๏ผ็ฑปๅไธบ๏ผ`.jss123`๏ผๅฎ้ตๅพชไปฅไธ้ป่พ๏ผ
```js
const productionPrefix = 'jss';
const identifier = 123;
const className = `${productionPrefix}-${identifier}`;
```
### ไธ `@material-ui/core` ไธ่ตทไฝฟ็จ
`@material-ui/core` ็ปไปถ็ๆ็็ฑปๅ่กจ็ฐๅคง็ธๅพๅบญใ ๅฝๆปก่ถณไปฅไธๆกไปถๆถ๏ผ็ฑปๅๆฏ **็กฎๅฎ็**๏ผ
- ไป
ไฝฟ็จไธไธชไธป้ขๆไพ็จๅบ๏ผ**ๆ ไธป้ขๅตๅฅ**๏ผใ
- ๆ ทๅผ่กจ็ๅ็งฐไปฅ `Mui` ๅผๅคด๏ผๅ
ๅซๆๆ Material-UI ็ปไปถ๏ผใ
- [็ฑปๅ็ๆๅจ](/styles/api/#creategenerateclassname-options-class-name-generator)็ `disableGlobal` ้้กนไธบ `false`๏ผ้ป่ฎคๅผ๏ผใ
`@material-ui/core` ๆๅธธ่ง็็จไพๅฏไปฅๆปก่ถณ่ฟไบๆกไปถใ ไพๅฆ๏ผๅจ่ฟไธชๆ ทๅผ่กจไธญ๏ผ
```jsx
const useStyles = makeStyles(
{
root: {
/* โฆ */
},
label: {
/* โฆ */
},
outlined: {
/* โฆ */
'&$disabled': {
/* โฆ */
},
},
outlinedPrimary: {
/* โฆ */
'&:hover': {
/* โฆ */
},
},
disabled: {},
},
{ name: 'MuiButton' },
);
```
่ฟๅฐ็ๆไปฅไธๆจๅฏไปฅ่ฟ่ก่ฆ็ๆไฝ็็ฑปๅ๏ผ
```css
.MuiButton-root {
/* โฆ */
}
.MuiButton-label {
/* โฆ */
}
.MuiButton-outlined {
/* โฆ */
}
.MuiButton-outlined.Mui-disabled {
/* โฆ */
}
.muibutton-outlinedprimary: {
/* โฆ */
}
.MuiButton-outlinedPrimary:hover {
/* โฆ */
}
```
_่ฟๆฏๅฏน `@material-ui/core/Button` ็ปไปถๆ ทๅผ่กจ็็ฎๅใ_
ไฝฟ็จ [`classes` API](#overriding-styles-classes-prop) ๆฅ่ชๅฎไน TextField ๅฏ่ฝไผๅพ้บป็ฆ๏ผๆไปฅไฝ ๅฟ
้กปๅฎไน็ฑปๅฑๆง๏ผclasses prop๏ผใ ๅฆไธๆๆ่ฟฐ๏ผไฝฟ็จ้ป่ฎคๅผไผๆฏ่พๅฎนๆใ ไพๅฆ:
```jsx
import styled from 'styled-components';
import { TextField } from '@material-ui/core';
const StyledTextField = styled(TextField)`
label.focused {
color: green; ๐
}
.MuiOutlinedInput-root {
fieldset {
border-color: red; ๐
}
&:hover fieldset {
border-color: yellow; ๐
}
&.Mui-focused fieldset {
border-color: green; ๐
}
}
`;
```
{{"demo": "pages/styles/advanced/GlobalClassName.js"}}
## ๅ
จๅฑ CSS
### `jss-plugin-global`
[`jss-plugin-global`](#jss-plugins) ๆไปถๅฎ่ฃ
ๅจ้ป่ฎค็้ข่ฎพไธญใ ๆจๅฏไปฅไฝฟ็จๅฎๆฅๅฎไนๅ
จๅฑ็ฑปๅ็งฐใ
{{"demo": "pages/styles/advanced/GlobalCss.js"}}
### ๆททๅ
ๆจไนๅฏไปฅๅฐ JSS ็ๆ็็ฑปๅ็งฐไธๅ
จๅฑๅ็งฐ็ปๅ่ตทๆฅใ
{{"demo": "pages/styles/advanced/HybridGlobalCss.js"}}
## CSS ๅ็ผ๏ผprefixes๏ผ
JSS ไฝฟ็จ็นๅพๆขๆตๆฅๅบ็จๆญฃ็กฎ็ๅ็ผใ ๅฆๆๆจ็ไธๅฐๆๆฐ็ๆฌ Chrome ไธญๆพ็คบไธไธช็นๅฎๅ็ผ๏ผ[่ฏทไธ่ฆๆๅฐๆ่ฎถ](https://github.com/mui-org/material-ui/issues/9293)ใ ๆจ็ๆต่งๅจๅฏ่ฝไธ้่ฆๅฎใ
| mbrookes/material-ui | docs/src/pages/styles/advanced/advanced-zh.md | Markdown | mit | 15,295 |
'use strict';
var gulp = require('gulp');
var autoprefixer = require('jstransformer')(require('jstransformer-stylus'));
var autoprefixer = require('autoprefixer-stylus');
var browserSync = require('browser-sync').create();
var changed = require('gulp-changed');
var concat = require('gulp-concat');
var cssbeautify = require('gulp-cssbeautify');
var csscomb = require('gulp-csscomb');
var csso = require('gulp-csso');
var data = require('gulp-data');
var del = require('del');
var filter = require('gulp-filter');
var flatten = require('gulp-flatten');
var gulpZip = require('gulp-zip');
var gulpif = require('gulp-if');
var gutil = require('gulp-util');
var htmlPrettify = require('gulp-prettify');
var imagemin = require('gulp-imagemin');
var imageminPngquant = require('imagemin-pngquant');
var imageminSvgo = require('imagemin-svgo');
var include = require('gulp-include');
var jade = require('gulp-jade');
var jadeInheritance = require('gulp-jade-inheritance');
var path = require('path');
var plumber = require('gulp-plumber');
var rename = require('gulp-rename');
var runSequence = require('run-sequence');
var rupture = require('rupture');
var stylus = require('gulp-stylus');
var svgSymbols = require('gulp-svg-symbols');
var uglify = require('gulp-uglify');
var watch = require('gulp-watch');
var gcmq = require('gulp-combine-mq');
// Error handler for gulp-plumber
var errorHandler = function (err) {
gutil.log([(err.name + ' in ' + err.plugin).bold.red, '', err.message, ''].join('\n'));
if (gutil.env.beep) {
gutil.beep();
}
this.emit('end');
};
// Print object in console
var debugObj = function (obj) {
var util = require('util');
console.log(util.inspect(obj, {showHidden: false, depth: null}));
};
// Read file and return object
var getData = function getData (file) {
var dataEntry;
var data;
var dataTmp;
var fs = require('fs');
try {
dataEntry = fs.readFileSync(file, 'utf8');
} catch (er) {
dataEntry = false;
}
dataTmp = '{' + dataEntry + '}';
if (dataEntry) {
// eval('data = {' + dataEntry + '}');
data = JSON.parse(dataTmp);
} else {
data = '{}';
}
return data;
};
var correctNumber = function correctNumber(number) {
return number < 10 ? '0' + number : number;
};
// Return timestamp
var getDateTime = function getDateTime() {
var now = new Date();
var year = now.getFullYear();
var month = correctNumber(now.getMonth() + 1);
var day = correctNumber(now.getDate());
var hours = correctNumber(now.getHours());
var minutes = correctNumber(now.getMinutes());
return year + '-' + month + '-' + day + '-' + hours + minutes;
};
// Plugins options
var options = {
del: [
'dest',
'tmp'
],
plumber: {
errorHandler: errorHandler
},
browserSync: {
server: {
baseDir: './dest'
}
},
stylus: {
use: [
rupture(),
autoprefixer({
browsers: ['last 2 version', '> 1%', 'safari 5', 'ie 8', 'ie 7', 'opera 12.1', 'ios 6', 'android 4'],
cascade: false
})
]
},
cssbeautify: {
indent: '\t',
autosemicolon: true
},
jade: {
pretty: '\t'
},
htmlPrettify: {
"unformatted": ["pre", "code"],
"indent_with_tabs": true,
"preserve_newlines": true,
"brace_style": "expand",
"end_with_newline": true
},
svgSymbols: {
title: false,
id: '%f',
className: '%f',
templates: [
path.join(__dirname, 'source/static/styles/components/icons-template.styl'),
'default-svg'
]
},
imagemin: {
optimizationLevel: 3,
progressive: true,
interlaced: true,
svgoPlugins: [{removeViewBox: false}],
use: [
imageminPngquant(),
imageminSvgo()
]
}
};
gulp.task('cleanup', function (cb) {
return del(options.del, cb);
});
gulp.task('browser-sync', function() {
return browserSync.init(options.browserSync);
});
gulp.task('bs-reload', function (cb) {
browserSync.reload();
});
gulp.task('combine-modules-styles', function (cb) {
return gulp.src(['**/*.styl', '!**/_*.styl'], {cwd: 'source/modules'})
.pipe(plumber(options.plumber))
.pipe(concat('modules.styl'))
.pipe(gulp.dest('tmp'));
});
gulp.task('compile-styles', function (cb) {
return gulp.src(['*.styl', '!_*.styl'], {cwd: 'source/static/styles'})
.pipe(plumber(options.plumber))
.pipe(stylus(options.stylus))
.pipe(gcmq({beautify: false}))
.pipe(cssbeautify(options.cssbeautify))
.pipe(csscomb())
.pipe(gulp.dest('dest/css'))
.pipe(csso())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dest/css'))
.pipe(browserSync.stream());
});
gulp.task('combine-modules-data', function (cb) {
return gulp.src(['**/*.js', '!**/_*.js'], {cwd: 'source/modules/*/data'})
.pipe(plumber(options.plumber))
.pipe(concat('data.js', { newLine: ',\n\n' }))
.pipe(gulp.dest('tmp'));
});
gulp.task('compile-pages', function (cb) {
return gulp.src(['**/*.jade', '!**/_*.jade'], {cwd: 'source/pages'})
.pipe(plumber(options.plumber))
.pipe(data(getData('tmp/data.js')))
.pipe(jade(options.jade))
.pipe(htmlPrettify(options.htmlPrettify))
.pipe(gulp.dest('dest'));
});
gulp.task('copy-modules-img', function (cb) {
return gulp.src('**/*.{jpg,gif,svg,png}', {cwd: 'source/modules/*/assets'})
.pipe(plumber(options.plumber))
.pipe(changed('dest/img'))
.pipe(imagemin(options.imagemin))
.pipe(flatten())
.pipe(gulp.dest('dest/img'));
});
gulp.task('combine-modules-scripts', function (cb) {
return gulp.src(['*.js', '!_*.js'], {cwd: 'source/modules/*'})
.pipe(plumber(options.plumber))
.pipe(concat('modules.js', { newLine: '\n\n' }))
.pipe(gulp.dest('tmp'));
});
gulp.task('copy-assets', function (cb) {
var imageFilter = filter('**/*.{jpg,gif,svg,png}', {restore: true});
var scriptsFilter = filter(['**/*.js', '!**/*.min.js'], {restore: true});
var stylesFilter = filter(['**/*.css', '!**/*.min.css'], {restore: true});
return gulp.src(['**/*.*', '!**/_*.*'], {cwd: 'source/static/assets'})
.pipe(plumber(options.plumber))
.pipe(changed('dest'))
// Minify images
.pipe(imageFilter)
.pipe(changed('dest'))
.pipe(imagemin(options.imagemin))
.pipe(imageFilter.restore)
// Minify JavaScript files
.pipe(scriptsFilter)
.pipe(gulp.dest('dest'))
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(scriptsFilter.restore)
// Minify css
.pipe(stylesFilter)
.pipe(csso())
.pipe(rename({suffix: '.min'}))
.pipe(stylesFilter.restore)
// Copy other files
.pipe(gulp.dest('dest'));
});
gulp.task('combine-scripts', function (cb) {
return gulp.src(['*.js', '!_*.js'], {cwd: 'source/static/scripts'})
.pipe(plumber(options.plumber))
.pipe(include())
.pipe(gulp.dest('dest/js'))
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dest/js'));
});
gulp.task('combine-svg-icons', function (cb) {
return gulp.src(['**/*.svg', '!**/_*.svg'], {cwd: 'source/static/icons'})
.pipe(plumber(options.plumber))
.pipe(imagemin(options.imagemin))
.pipe(svgSymbols(options.svgSymbols))
.pipe(gulpif(/\.styl$/, gulp.dest('tmp')))
.pipe(gulpif(/\.svg$/, rename('icons.svg')))
.pipe(gulpif(/\.svg$/, gulp.dest('dest/img')));
});
gulp.task('build-zip', function() {
var datetime = '-' + getDateTime();
var zipName = 'dist' + datetime + '.zip';
return gulp.src('dest/**/*')
.pipe(gulpZip(zipName))
.pipe(gulp.dest('zip'));
});
gulp.task('build-html', function (cb) {
return runSequence(
'combine-modules-data',
'compile-pages',
cb
);
});
gulp.task('build-css', function (cb) {
return runSequence(
'combine-modules-styles',
'compile-styles',
cb
);
});
gulp.task('build-js', function (cb) {
return runSequence(
'combine-modules-scripts',
'combine-scripts',
cb
);
});
gulp.task('build', function (cb) {
return runSequence(
'cleanup',
'combine-svg-icons',
[
'build-html',
'copy-modules-img',
'copy-assets',
'build-css',
'build-js'
],
cb
);
});
gulp.task('zip', function (cb) {
return runSequence(
'build',
'build-zip',
cb
);
});
gulp.task('develop', function (cb) {
return runSequence(
'build',
'browser-sync',
cb
);
});
gulp.task('dev', ['develop'], function (cb) {
// Modules, pages
watch('source/**/*.jade', function() {
return runSequence('compile-pages', browserSync.reload);
});
// Modules data
watch('source/modules/*/data/*.js', function() {
return runSequence('build-html', browserSync.reload);
});
// Static styles
watch('source/static/styles/**/*.styl', function() {
// return runSequence('compile-styles');
gulp.start('compile-styles');
});
// Modules styles
watch('source/modules/**/*.styl', function() {
// return runSequence('build-css');
gulp.start('build-css');
});
// Static scripts
watch('source/static/scripts/**/*.js', function() {
return runSequence('combine-scripts', browserSync.reload);
});
// Modules scripts
watch('source/modules/*/*.js', function() {
return runSequence('build-js', browserSync.reload);
});
// Modules images
watch('source/modules/*/assets/**/*.{jpg,gif,svg,png}', function() {
return runSequence('copy-modules-img', browserSync.reload);
});
// Static files
watch('source/static/assets/**/*', function() {
return runSequence('copy-assets', browserSync.reload);
});
// Svg icons
watch('source/static/icons/**/*.svg', function() {
return runSequence('combine-svg-icons', browserSync.reload);
});
});
| cloud00/fast-front | gulpfile.js | JavaScript | mit | 9,271 |
<?php
namespace Lib\Router\Exception;
class NotFoundException extends \Exception{}
| nirnanaaa/ofwn | libs/Lib/Router/Exception/NotFoundException.php | PHP | mit | 85 |
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin developers
// Copyright (c) 2015-2020 The Bitcoin Unlimited developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_POLICY_POLICY_H
#define BITCOIN_POLICY_POLICY_H
#include "consensus/consensus.h"
#include "script/interpreter.h"
#include "script/standard.h"
#include <string>
class CCoinsViewCache;
/** Default for -blockmaxsize and -blockminsize, which control the range of sizes the mining code will create **/
// this is now set in chain params
static const unsigned int DEFAULT_BLOCK_MAX_SIZE_REGTEST = 1000;
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 8 * ONE_MEGABYTE;
static const unsigned int DEFAULT_BLOCK_MAX_SIZE_TESTNET4 = 2 * ONE_MEGABYTE;
static const unsigned int DEFAULT_BLOCK_MAX_SIZE_SCALENET = 256 * ONE_MEGABYTE;
// Maximum number of mining candidates that this node will remember simultaneously
static const unsigned int DEFAULT_MAX_MINING_CANDIDATES = 10;
// Send an existing mining candidate if a request comes in within this many seconds of its construction
static const unsigned int DEFAULT_MIN_CANDIDATE_INTERVAL = 30;
/** Default for -blockprioritysize for priority or zero/low-fee transactions **/
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 0;
/** The maximum size for transactions we're willing to relay/mine */
static const unsigned int MAX_STANDARD_TX_SIZE = 100000;
/**
* Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed
* keys (remember the 520 byte limit on redeemScript size). That works
* out to a (15*(33+1))+3=513 byte redeemScript, 513+1+15*(73+1)+3=1627
* bytes of scriptSig, which we round off to 1650 bytes for some minor
* future-proofing. That's also enough to spend a 20-of-20 CHECKMULTISIG
* scriptPubKey, though such a scriptPubKey is not considered standard.
*/
static constexpr unsigned int MAX_TX_IN_SCRIPT_SIG_SIZE = 1650;
/** Maximum number of signature check operations in an IsStandard() P2SH script */
static const unsigned int MAX_P2SH_SIGOPS = 15;
/** The maximum number of sigops we're willing to relay/mine in a single tx */
static const unsigned int MAX_STANDARD_TX_SIGOPS = MAX_TX_SIGOPS_COUNT / 5;
/** Default for -maxmempool, maximum megabytes of mempool memory usage */
static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300;
/** Dust threshold in satoshis. Historically this value was calculated as
* minRelayTxFee/1000 * 546. However now we just allow the operator to set
* a simple dust threshold independant of any other value or relay fee.
*/
static const unsigned int DEFAULT_DUST_THRESHOLD = 546;
/**
* Standard script verification flags that standard transactions will comply
* with. However scripts violating these flags may still be present in valid
* blocks and we must accept those blocks.
*/
/* clang-format off */
static const unsigned int STANDARD_SCRIPT_VERIFY_FLAGS = MANDATORY_SCRIPT_VERIFY_FLAGS |
SCRIPT_VERIFY_DERSIG |
SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS |
SCRIPT_VERIFY_CLEANSTACK |
SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY |
SCRIPT_VERIFY_CHECKSEQUENCEVERIFY |
SCRIPT_VERIFY_SIGPUSHONLY |
SCRIPT_ENABLE_CHECKDATASIG |
SCRIPT_DISALLOW_SEGWIT_RECOVERY;
/* clang-format on */
/** For convenience, standard but not mandatory verify flags. */
static const unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS =
STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS;
/** Used as the flags parameter to sequence and nLocktime checks in non-consensus code. */
static const unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS = LOCKTIME_VERIFY_SEQUENCE | LOCKTIME_MEDIAN_TIME_PAST;
bool IsStandard(const CScript &scriptPubKey, txnouttype &whichType);
/**
* Check for standard transaction types
* @return True if all outputs (scriptPubKeys) use only standard transaction forms
*/
bool IsStandardTx(const CTransactionRef tx, std::string &reason);
/**
* Check for standard transaction types
* @param[in] mapInputs Map of previous transactions that have outputs we're spending
* @return True if all inputs (scriptSigs) use only standard transaction forms
*/
bool AreInputsStandard(const CTransactionRef tx, const CCoinsViewCache &mapInputs, bool isMay2020Enabled);
#endif // BITCOIN_POLICY_POLICY_H
| BitcoinUnlimited/BitcoinUnlimited | src/policy/policy.h | C | mit | 4,801 |
๏ปฟusing System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace Lab2A.Models.AccountViewModels
{
public class LoginViewModel
{
[Required]
[EmailAddress]
public string Email { get; set; }
[Required]
[DataType(DataType.Password)]
public string Password { get; set; }
[Display(Name = "Remember me?")]
public bool RememberMe { get; set; }
}
}
| jongalloway/aspnetcore-workshop | Labs/Code/Lab2A/src/Lab2A/Models/AccountViewModels/LoginViewModel.cs | C# | mit | 509 |
########################################
# Automatically generated, do not edit.
########################################
from pyvisdk.thirdparty import Enum
DatastoreSummaryMaintenanceModeState = Enum(
'enteringMaintenance',
'inMaintenance',
'normal',
)
| xuru/pyvisdk | pyvisdk/enums/datastore_summary_maintenance_mode_state.py | Python | mit | 272 |
import Ember from 'ember';
import PaginatedScrollViewMixin from 'kowa/mixins/paginated-scroll-view';
var PaginatedScrollBox = Ember.View.extend(PaginatedScrollViewMixin);
export default PaginatedScrollBox;
| aymerick/kowa-client | app/views/paginated-scroll-box.js | JavaScript | mit | 208 |
import clearSuggestedActions from './actions/clearSuggestedActions';
import connect from './actions/connect';
import createStore, { withDevTools as createStoreWithDevTools } from './createStore';
import disconnect from './actions/disconnect';
import dismissNotification from './actions/dismissNotification';
import emitTypingIndicator from './actions/emitTypingIndicator';
import markActivity from './actions/markActivity';
import postActivity from './actions/postActivity';
import sendEvent from './actions/sendEvent';
import sendFiles from './actions/sendFiles';
import sendMessage from './actions/sendMessage';
import sendMessageBack from './actions/sendMessageBack';
import sendPostBack from './actions/sendPostBack';
import setDictateInterims from './actions/setDictateInterims';
import setDictateState from './actions/setDictateState';
import setLanguage from './actions/setLanguage';
import setNotification from './actions/setNotification';
import setSendBox from './actions/setSendBox';
import setSendTimeout from './actions/setSendTimeout';
import setSendTypingIndicator from './actions/setSendTypingIndicator';
import startDictate from './actions/startDictate';
import startSpeakingActivity from './actions/startSpeakingActivity';
import stopDictate from './actions/stopDictate';
import stopSpeakingActivity from './actions/stopSpeakingActivity';
import submitSendBox from './actions/submitSendBox';
import * as ActivityClientState from './constants/ActivityClientState';
import * as DictateState from './constants/DictateState';
const Constants = { ActivityClientState, DictateState };
const version = process.env.npm_package_version;
export {
clearSuggestedActions,
connect,
Constants,
createStore,
createStoreWithDevTools,
disconnect,
dismissNotification,
emitTypingIndicator,
markActivity,
postActivity,
sendEvent,
sendFiles,
sendMessage,
sendMessageBack,
sendPostBack,
setDictateInterims,
setDictateState,
setLanguage,
setNotification,
setSendBox,
setSendTimeout,
setSendTypingIndicator,
startDictate,
startSpeakingActivity,
stopDictate,
stopSpeakingActivity,
submitSendBox,
version
};
| billba/botchat | packages/core/src/index.js | JavaScript | mit | 2,160 |
var assert = require('assert');
var listXf = require('./helpers/listXf');
var R = require('..');
describe('any', function() {
var odd = function(n) {return n % 2 === 1;};
var T = function() {return true;};
var intoArray = R.into([]);
it('returns true if any element satisfies the predicate', function() {
assert.strictEqual(R.any(odd, [2, 4, 6, 8, 10, 11, 12]), true);
});
it('returns false if all elements fails to satisfy the predicate', function() {
assert.strictEqual(R.any(odd, [2, 4, 6, 8, 10, 12]), false);
});
it('returns true into array if any element satisfies the predicate', function() {
assert.deepEqual(intoArray(R.any(odd), [2, 4, 6, 8, 10, 11, 12]), [true]);
});
it('returns false if all elements fails to satisfy the predicate', function() {
assert.deepEqual(intoArray(R.any(odd), [2, 4, 6, 8, 10, 12]), [false]);
});
it('works with more complex objects', function() {
var people = [{first: 'Paul', last: 'Grenier'}, {first:'Mike', last: 'Hurley'}, {first: 'Will', last: 'Klein'}];
var alliterative = function(person) {return person.first.charAt(0) === person.last.charAt(0);};
assert.strictEqual(R.any(alliterative, people), false);
people.push({first: 'Scott', last: 'Sauyet'});
assert.strictEqual(R.any(alliterative, people), true);
});
it('can use a configurable function', function() {
var teens = [{name: 'Alice', age: 14}, {name: 'Betty', age: 18}, {name: 'Cindy', age: 17}];
var atLeast = function(age) {return function(person) {return person.age >= age;};};
assert.strictEqual(R.any(atLeast(16), teens), true, 'Some can legally drive');
assert.strictEqual(R.any(atLeast(21), teens), false, 'None can legally drink');
});
it('returns false for an empty list', function() {
assert.strictEqual(R.any(T, []), false);
});
it('returns false into array for an empty list', function() {
assert.deepEqual(intoArray(R.any(T), []), [false]);
});
it('dispatches when given a transformer in list position', function() {
assert.deepEqual(R.any(odd, listXf), {
any: false,
f: odd,
xf: listXf
});
});
it('is automatically curried', function() {
var count = 0;
var test = function(n) {count++; return odd(n);};
assert(R.any(test)([2, 4, 6, 7, 8, 10]) === true);
});
});
| megawac/ramda | test/any.js | JavaScript | mit | 2,480 |
<html><body>
<h4>Windows 10 x64 (18362.329)</h4><br>
<h2>_SEGMENT_HEAP</h2>
<font face="arial"> +0x000 EnvHandle : <a href="./RTL_HP_ENV_HANDLE.html">RTL_HP_ENV_HANDLE</a><br>
+0x010 Signature : Uint4B<br>
+0x014 GlobalFlags : Uint4B<br>
+0x018 Interceptor : Uint4B<br>
+0x01c ProcessHeapListIndex : Uint2B<br>
+0x01e AllocatedFromMetadata : Pos 0, 1 Bit<br>
+0x020 CommitLimitData : <a href="./_RTL_HEAP_MEMORY_LIMIT_DATA.html">_RTL_HEAP_MEMORY_LIMIT_DATA</a><br>
+0x020 ReservedMustBeZero1 : Uint8B<br>
+0x028 UserContext : Ptr64 Void<br>
+0x030 ReservedMustBeZero2 : Uint8B<br>
+0x038 Spare : Ptr64 Void<br>
+0x040 LargeMetadataLock : Uint8B<br>
+0x048 LargeAllocMetadata : <a href="./_RTL_RB_TREE.html">_RTL_RB_TREE</a><br>
+0x058 LargeReservedPages : Uint8B<br>
+0x060 LargeCommittedPages : Uint8B<br>
+0x068 StackTraceInitVar : <a href="./_RTL_RUN_ONCE.html">_RTL_RUN_ONCE</a><br>
+0x080 MemStats : <a href="./_HEAP_RUNTIME_MEMORY_STATS.html">_HEAP_RUNTIME_MEMORY_STATS</a><br>
+0x0d8 GlobalLockCount : Uint2B<br>
+0x0dc GlobalLockOwner : Uint4B<br>
+0x0e0 ContextExtendLock : Uint8B<br>
+0x0e8 AllocatedBase : Ptr64 UChar<br>
+0x0f0 UncommittedBase : Ptr64 UChar<br>
+0x0f8 ReservedLimit : Ptr64 UChar<br>
+0x100 SegContexts : [2] <a href="./_HEAP_SEG_CONTEXT.html">_HEAP_SEG_CONTEXT</a><br>
+0x280 VsContext : <a href="./_HEAP_VS_CONTEXT.html">_HEAP_VS_CONTEXT</a><br>
+0x340 LfhContext : <a href="./_HEAP_LFH_CONTEXT.html">_HEAP_LFH_CONTEXT</a><br>
</font></body></html> | epikcraw/ggool | public/Windows 10 x64 (18362.329)/_SEGMENT_HEAP.html | HTML | mit | 1,661 |
@extends('frontend.layouts.default')
@section('content')
<div class="breadcrumb-wrapper">
<div class="pattern-overlay">
<div class="container">
<div class="row">
<div class="col-lg-6 col-md-6 col-xs-12 col-sm-6">
<h2 class="title">Recent Events</h2>
</div>
<div class="col-lg-6 col-md-6 col-xs-12 col-sm-6">
<div class="breadcrumbs pull-right">
<ul>
<li><a href="{!! URL::to('/') !!}">Home</a></li>
<li><a href="#">Events</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Main Content start-->
<div class="content margin-top60 margin-bottom60">
<div class="container">
<div class="row">
<!-- Blog Posts -->
<div class="posts-block col-lg-8 col-md-8 col-sm-8 col-xs-12">
@foreach($events as $event)
<!-- Blog Post 1 -->
<article class="post hentry">
<div class="post-image">
<a href="{!! asset($event->banner) !!}" data-rel="prettyPhoto">
<span class="img-hover"></span>
<span class="fullscreen"><i class="fa fa-plus"></i></span>
<img src="{!! asset($event->banner) !!}" alt="" width="800px" class="img-responsive">
</a>
</div>
<header class="post-header">
<h2><a href="{!! route('event.details',$event->event_meta_data) !!}" title="dd"> {!! $event->headline !!}</a></h2>
<div class="blog-entry-meta">
<div class="blog-entry-meta-author">
<i class="fa fa-user"></i>
<span class="blog-entry-meta-author">Department: {!! $event->dept->name !!}</span>
</div>
<div class="blog-entry-meta-tags">
<i class="fa fa-tags"></i>
<a href="#">Venue: {!! $event->venue !!}</a>,
</div>
<div class="blog-entry-meta-date">
<i class="fa fa-clock-o"></i>
<span class="blog-entry-meta-date-day">Start Date: {!! $event->start_time !!}</span>
</div>
</div>
</header>
<div class="post-content">
<p>
{!! strip_tags(str_limit($event->description, 350)) !!}
</p>
</div>
<footer class="post-footer">
<a class="btn btn-color" href="{!! route('event.details',$event->event_meta_data) !!}" class="readmore">Read More</a>
</footer>
</article>
<!-- /Blog Post 1 -->
<!-- Star-->
<div class="star">
<div class="row">
<div class="col-md-12">
<div class="star-divider">
<div class="star-divider-icon">
<i class=" fa fa-star"></i>
</div>
</div>
</div>
</div>
</div>
<!-- /Star -->
@endforeach
<!-- /Star -->
<ul class="pager">
{!! $events->render() !!}
</ul>
</div>
<!-- /Blog Posts -->
@include('frontend.includes.rightsidebarEvent')
</div>
</div>
</div>
<!-- /Main Content end-->
@stop
@section('style')
<style>
</style>
@stop
@section('script')
@stop
| talha08/sust-society | resources/views/event.blade.php | PHP | mit | 4,484 |
Hamahatschi
===========
Hamahatschi is a simple program to turn Hamachi and its service as well as network adapter on and off.
Usage
------
Simply compile the project or start the executable. It will try to find the adapter and the service and disable/enable Hamachi, depending on what its current state is. If it can't decide on what you want (because one thing is enabled and the other is disabled), it will prompt whether you want to start or close Hamachi.
Because I'm messing around with network adapters and services, this program requires elevated rights (i.e. UAC will bother you every time you start it).
If everything went according to plan, Hamachi should shut down/start up and the program will close itself. In case there was an error, the command line stays open and prints some information. If you are encountering an error and cannot solve it on your own, submit it as an issue. When opening an issue, please include everything Hamahatschi writes.
Motivation
----------
Because Steam's P2P functionality was severely broken for me and a few friends, we had to create direct connections between each other. We chose Hamachi for that as it was somewhat well established and known to all of us.
However, I disliked having Hamachi open 24/7, especially with its (more or less useless) service and network adapter that was only used from time to time. Hamahatschi was created as an attempt to solve this by disabling the network adapter Hamachi creates (called "Hamachi") and stopping its service ("LogMeIn Tunneling Engine"), therefore rendering it quite useless. | Quit/Hamahatschi | README.md | Markdown | mit | 1,583 |
<div layout="row" layout-align="space-between center">
<md-button href="#">Code Challenge for T-Systems</md-button>
<md-button class="acme-navbar-text">Application was created {{ vm.relativeDate }}.</md-button>
</div>
| SuperheroicCoding/notifications | src/app/components/navbar/navbar.html | HTML | mit | 223 |
{% extends 'layouts/base.html' %}
{% block title %}
{% endblock %}
{% block content %}
<div class="row">
<div class="col-lg-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Question Details</h3>
</div>
<div class="panel-body">
<h5>Lecture: {{ question.lecture }}</h5>
<h5>Text: <blockquote><p>{{ question.text }}</p></blockquote></h5>
<h5>Correct Answer: {{ question.answer.correct_answer.text }}</h5>
<table class="table">
<thead>
<th>#</th>
<th>Answer Option</th>
</thead>
{% for option in question.answer.answer_options.all %}
<tbody>
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ option }}</td>
</tr>
</tbody>
{% endfor %}
</table>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Response Summary</h3>
</div>
<div class="panel-body">
<h5>Response Ratio: X/Y </h5>
{% for stat in response_stats %}
{{ stat.0 }} {{ stat.1 }} <br>
{% endfor %}
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Responses</h3>
</div>
<div class="panel-body">
<table class="table table-responsive">
<thead>
<th>#</th>
<th>Student</th>
<th>Response</th>
</thead>
<tbody>
{% for response in responses %}
{% if response.is_correct %}
<tr class="success">
{% else %}
<tr class="danger">
{% endif %}
<td>{{ forloop.counter }}</td>
<td>{{ response.student.user.first_name }}, {{ response.student.user.last_name }}</td>
<td>{{ response.answer_option.id }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock %} | thebenwaters/openclickio | qa/templates/question_answer_response.html | HTML | mit | 3,065 |
<?php
namespace Kids\Controller;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Kids\Entity\Workshop;
use Kids\Entity\Establishment;
use Kids\Entity\PublicAge;
use Kids\Entity\WorkshopCategory;
use Kids\Entity\Address;
use Kids\Entity\Kid;
use Kids\Entity\KidHasParent;
use Kids\Entity\ParentOfKid;
use Kids\Entity\WorkshopHasKid;
use Kids\Entity\Timetable;
class WorkshopController
{
public function indexAction(Application $app, Request $request)
{
$workshop = new Workshop();
$list = $workshop->fetchAll();
$age = new PublicAge();
$ages = $age->fetchAll();
$establishment = new Establishment();
$establishments = $establishment->fetchAll();
$categorie = new WorkshopCategory();
$categories = $categorie->fetchAll();
return new Response($app['twig']->render('workshop/index.html.twig', array('workshops' => $list,
'ages' => $ages,
'lieux' => $establishments,
'categories' => $categories)));
}
public function indexAdminAction(Application $app, Request $request)
{
$workshop = new Workshop();
$list = $workshop->fetchAll(null, false);
return new Response($app['twig']->render('workshop/index_admin.html.twig', array(
'workshops' => $list)));
}
/**
* nouveau atelier
*
*/
public function newAction(Application $app, Request $request)
{
$user = $app['session']->get('user');
if (empty($user)) {
return $app->redirect('/login');
}
$age = new PublicAge();
$ages = $age->fetchAll();
$establishment = new Establishment();
$establishments = $establishment->fetchAll();
$workshop = new WorkshopCategory();
$workshops = $workshop->fetchAll();
if ($request->isMethod('post')){
// upload images
$target_dir = __DIR__.'/../../web/images/';
$filename = time() . basename($_FILES["fileToUpload"]["name"]);
$target_file = $target_dir . $filename;
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
// Check if file already exists
if (file_exists($target_file)) {
echo "Sorry, file already exists.";
$uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 9999999) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
$workshop = new Workshop();
if (isset($_POST['visibility']) && $_POST['visibility'] != null) {
$visibility = 1;
} else {
$visibility = 0;
}
$workshop
->setTitle($_POST['title'])
->setDescription($_POST['description'])
->setPrice($_POST['price'])
->setMaxKids($_POST['max_kids'])
->setImage($filename)
->setVisible($visibility)
->setPublicAgeId($_POST['age'])
->setEstablishmentId($_POST['establishment'])
->setWorkshopCategoryId($_POST['category']);
$workshop->save();
$timetable = new Timetable();
$date = explode('/', $_POST['debut']);
$dateFormat = $date[2] . '-' . $date[1] . '-' . $date[0];
$startAt = $dateFormat . ' ' . $_POST['hours_debut'];
$endAt = $dateFormat . ' ' . $_POST['hours_fin'];
$timetable->setStartAt($startAt)
->setEndAt($endAt)
->setWorkshopId($workshop->getId())
->save();
return $app->redirect('/admin/ateliers');
}
return new Response($app['twig']->render('workshop/new.html.twig', array(
'ages' => $ages,
'establishments' => $establishments,
'workshops_category' => $workshops,
)));
}
public function deleteAction(Application $app, Request $request)
{
$user = $app['session']->get('user');
if (empty($user)) {
return $app->redirect('/login');
}
$id = $request->get('id');
$workshopModel = new Workshop();
$workshop = $workshopModel->delete($id);
return $app->redirect('/admin/ateliers');
}
public function registerAction(Application $app, Request $request)
{
$default = ($request->get('id') != null ? $request->get('id') : null);
$workshop = new Workshop();
$list = $workshop->fetchAll();
if ($request->isMethod('post')){
$address = new Address();
$address->setAddress($_POST['adresse'])
->setComplement($_POST['complement'])
->setCity($_POST['ville'])
->setZipcode($_POST['code_postal'])
->save();
$parent = new ParentOfKid();
$parent->setFirstname($_POST['parent_prenom'])
->setLastname($_POST['parent_nom'])
->setEmail($_POST['mail'])
->setAddressId($address->getId())
->setPhone($_POST['telephone'])
->save();
$enfant = new Kid();
$birthday = explode('/', $_POST['enfant1_naissance']);
$birthdayFormat = $birthday[2] . '-' . $birthday[1] . '-' . $birthday[0];
$enfant->setFirstname($_POST['enfant1_prenom'])
->setLastname($_POST['enfant1_nom'])
->setBirthday($birthdayFormat)
->setClassroom( ($_POST['enfant1_classe'] == '' ? 'NULL' : $_POST['enfant1_classe']))
->save();
$WorkshopHasKid = new WorkshopHasKid();
$WorkshopHasKid->setWorkshopId($_POST['ateliers'])
->setKidId($enfant->getId())
->save();
$kidHasParent = new KidHasParent();
$kidHasParent->setKidId($enfant->getId())
->setParentId($parent->getId())
->save();
if ($_POST['enfant2_nom'] != ''
&& $_POST['enfant2_prenom'] != ''
&& $_POST['enfant2_naissance'] != '') {
$enfant = new Kid();
$birthday = explode('/', $_POST['enfant2_naissance']);
$birthdayFormat = $birthday[2] . '-' . $birthday[1] . '-' . $birthday[0];
$enfant->setFirstname($_POST['enfant2_prenom'])
->setLastname($_POST['enfant2_nom'])
->setBirthday($birthdayFormat)
->setClassroom( ($_POST['enfant2_classe'] == '' ? 'NULL' : $_POST['enfant2_classe']))
->save();
$WorkshopHasKid = new WorkshopHasKid();
$WorkshopHasKid->setWorkshopId($_POST['ateliers'])
->setKidId($enfant->getId())
->save();
$kidHasParent = new KidHasParent();
$kidHasParent->setKidId($enfant->getId())
->setParentId($parent->getId())
->save();
}
$app['session']->getFlashBag()->add('message', 'Votre inscription a bien รฉtรฉ enregistrer.');
return $app->redirect('/ateliers');
}
return new Response($app['twig']->render('workshop/register.html.twig', array('workshops' => $list, 'default' => $default)));
}
public function attenteAdminAction(Application $app, Request $request)
{
$user = $app['session']->get('user');
if (empty($user)) {
return $app->redirect('/login');
}
$workshop = new WorkshopHasKid();
$list = $workshop->fetchAll();
if ($request->get('workshop') != NULL && $request->get('response') != NULL && $request->get('kid') != NULL) {
$workshop->edit($request->get('response'), $request->get('workshop'), $request->get('kid'));
return $app->redirect('/ateliers/attente');
}
return new Response($app['twig']->render('workshop/attente.html.twig', array('workshops' => $list)));
}
}
| AshvinPainiaye/simplon-kids | src/Controller/WorkshopController.php | PHP | mit | 8,315 |
๏ปฟusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AuthorizeNet.Api.Contracts.V1;
using AuthorizeNet.Api.Controllers;
using AuthorizeNet.Api.Controllers.Bases;
namespace net.authorize.sample
{
public class GetAccountUpdaterJobSummary
{
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
{
Console.WriteLine("Get Account Updater job summary sample");
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
// define the merchant information (authentication / transaction id)
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = ApiLoginID,
ItemElementName = ItemChoiceType.transactionKey,
Item = ApiTransactionKey,
};
// Set a valid month for the request
string month = "2017-07";
// Build tbe request object
var request = new getAUJobSummaryRequest();
request.month = month;
// Instantiate the controller that will call the service
var controller = new getAUJobSummaryController(request);
controller.Execute();
// Get the response from the service (errors contained if any)
var response = controller.GetApiResponse();
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
{
Console.WriteLine("SUCCESS: Get Account Updater Summary for Month : " + month);
if (response.auSummary == null)
{
Console.WriteLine("No Account Updater summary for this month.");
return response;
}
// Displaying the summary of each response in the list
foreach (var result in response.auSummary)
{
Console.WriteLine(" Reason Code : " + result.auReasonCode);
Console.WriteLine(" Reason Description : " + result.reasonDescription);
Console.WriteLine(" # of Profiles updated for this reason : " + result.profileCount);
}
}
else if (response != null)
{
Console.WriteLine("ERROR : Invalid response");
Console.WriteLine("Response : " + response.messages.message[0].code + " " + response.messages.message[0].text);
}
return response;
}
}
}
| AuthorizeNet/sample-code-csharp | TransactionReporting/GetAccountUpdaterJobSummary.cs | C# | mit | 2,682 |
-- Copyright (C) 2014 MariaDB Ab.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; version 2 of the License.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# This part creates stored procedures required by the OpenGIS standards.
# script is prepared to be run with the --bootstrap server option
SET sql_mode='';
DROP PROCEDURE IF EXISTS AddGeometryColumn;
DROP PROCEDURE IF EXISTS DropGeometryColumn;
CREATE PROCEDURE AddGeometryColumn(catalog varchar(64), t_schema varchar(64),
t_name varchar(64), geometry_column varchar(64), t_srid int)
begin
set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' ADD ', geometry_column,' GEOMETRY REF_SYSTEM_ID=', t_srid); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end ;
CREATE PROCEDURE DropGeometryColumn(catalog varchar(64), t_schema varchar(64),
t_name varchar(64), geometry_column varchar(64))
begin
set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' DROP ', geometry_column); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end ;
| boggroZZdev/SoftUniHomeWork | TechModule/SoftwareTechnologies/Java-Blog/mysql/share/maria_add_gis_sp_bootstrap.sql | SQL | mit | 1,610 |
// Copyright(c) 2013 GROWTH XPARTNERS, Incorporated.
//
//
package junit.tutorial.calculator;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class CalculatorTest {
@Test
public void multiplyใง๏ผใจ๏ผใฎไน็ฎ็ตๆใๅๅพใงใใ() {
Calculator calc = new Calculator();
int expected = 12;
int actual = calc.multiply(3, 4);
assertThat(actual, is(expected));
}
@Test
public void multiplyใง๏ผใจ๏ผใฎไน็ฎ็ตๆใๅๅพใงใใ() {
Calculator calc = new Calculator();
int expected = 35;
int actual = calc.multiply(5, 7);
assertThat(actual, is(expected));
}
@Test
public void divideใง๏ผใจ๏ผใฎ้ค็ฎ็ตๆใๅๅพใงใใ() {
Calculator calc = new Calculator();
float expected = 1.5f;
float actual = calc.divide(3, 2);
assertThat(actual, is(expected));
}
@Test(expected = IllegalArgumentException.class)
public void divideใง๏ผใจ๏ผใฎใจใIllegalArgumentExceptionใ้ๅบใใ() {
Calculator calc = new Calculator();
calc.divide(5, 0);
}
public static void main(String[] args) {
org.junit.runner.JUnitCore.main(CalculatorTest.class.getName());
}
}
| hosaka893/junit-tutorial | src/test/java/junit/tutorial/calculator/CalculatorTest.java | Java | mit | 1,401 |
import {Vec3f} from "./Vec3f";
import {Quaternion} from "./Quaternion";
import {MathUtils} from "./MathUtils";
import {Vec4f} from "./Vec4f";
/**
* Created by r3f on 7/1/2016.
*/
export class Mat4f{
// Matrix row & column values as in i,j
m:Float32Array;
/*
* Constructor Mat4f()
* @info: Rows and columns are 0 by default
*/
constructor(m?:Float32Array)
{
this.m = m?m:new Float32Array(16);
}
identity(overwrite:boolean=false):Mat4f {
if (!overwrite) {
var mat = new Mat4f()
mat.m[0] = 1;
mat.m[1] = 0;
mat.m[2] = 0;
mat.m[3] = 0;
mat.m[4] = 0;
mat.m[5] = 1;
mat.m[6] = 0;
mat.m[7] = 0;
mat.m[8] = 0;
mat.m[9] = 0;
mat.m[10] = 1;
mat.m[11] = 0;
mat.m[12] = 0;
mat.m[13] = 0;
mat.m[14] = 0;
mat.m[15] = 1;
return mat;
}
this.m[0] = 1;
this.m[1] = 0;
this.m[2] = 0;
this.m[3] = 0;
this.m[4] = 0;
this.m[5] = 1;
this.m[6] = 0;
this.m[7] = 0;
this.m[8] = 0;
this.m[9] = 0;
this.m[10] = 1;
this.m[11] = 0;
this.m[12] = 0;
this.m[13] = 0;
this.m[14] = 0;
this.m[15] = 1;
return this;
}
transpose(overwrite:boolean=false):Mat4f {
if (!overwrite) {
var mat = new Mat4f();
var a01 = this.m[1], a02 = this.m[2], a03 = this.m[3],
a12 = this.m[6], a13 = this.m[7],
a23 = this.m[11];
mat.m[1] = mat[4];
mat.m[2] = mat[8];
mat.m[3] = mat[12];
mat.m[4] = a01;
mat.m[6] = mat[9];
mat.m[7] = mat[13];
mat.m[8] = a02;
mat.m[9] = a12;
mat.m[11] = mat[14];
mat.m[12] = a03;
mat.m[13] = a13;
mat.m[14] = a23;
return mat;
}
this.m[0] = this.m[0];
this.m[1] = this.m[4];
this.m[2] = this.m[8];
this.m[3] = this.m[12];
this.m[4] = this.m[1];
this.m[5] = this.m[5];
this.m[6] = this.m[9];
this.m[7] = this.m[13];
this.m[8] = this.m[2];
this.m[9] = this.m[6];
this.m[10] = this.m[10];
this.m[11] = this.m[14];
this.m[12] = this.m[3];
this.m[13] = this.m[7];
this.m[14] = this.m[11];
this.m[15] = this.m[15];
return this;
}
determinant():number {
// Cache the matrix values (makes for huge speed increases!)
var a00 = this.m[0], a01 = this.m[1], a02 = this.m[2], a03 = this.m[3],
a10 = this.m[4], a11 = this.m[5], a12 = this.m[6], a13 = this.m[7],
a20 = this.m[8], a21 = this.m[9], a22 = this.m[10], a23 = this.m[11],
a30 = this.m[12], a31 = this.m[13], a32 = this.m[14], a33 = this.m[15];
return (a30 * a21 * a12 * a03 - a20 * a31 * a12 * a03 - a30 * a11 * a22 * a03 + a10 * a31 * a22 * a03 +
a20 * a11 * a32 * a03 - a10 * a21 * a32 * a03 - a30 * a21 * a02 * a13 + a20 * a31 * a02 * a13 +
a30 * a01 * a22 * a13 - a00 * a31 * a22 * a13 - a20 * a01 * a32 * a13 + a00 * a21 * a32 * a13 +
a30 * a11 * a02 * a23 - a10 * a31 * a02 * a23 - a30 * a01 * a12 * a23 + a00 * a31 * a12 * a23 +
a10 * a01 * a32 * a23 - a00 * a11 * a32 * a23 - a20 * a11 * a02 * a33 + a10 * a21 * a02 * a33 +
a20 * a01 * a12 * a33 - a00 * a21 * a12 * a33 - a10 * a01 * a22 * a33 + a00 * a11 * a22 * a33);
}
inverse(overwrite:boolean=false) {
var mat = this.m;
if(overwrite){
var dest:Mat4f = this;
}else{
var dest = new Mat4f();
}
// Cache the matrix values (makes for huge speed increases!)
var a00 = mat[0], a01 = mat[1], a02 = mat[2], a03 = mat[3],
a10 = mat[4], a11 = mat[5], a12 = mat[6], a13 = mat[7],
a20 = mat[8], a21 = mat[9], a22 = mat[10], a23 = mat[11],
a30 = mat[12], a31 = mat[13], a32 = mat[14], a33 = mat[15],
b00 = a00 * a11 - a01 * a10,
b01 = a00 * a12 - a02 * a10,
b02 = a00 * a13 - a03 * a10,
b03 = a01 * a12 - a02 * a11,
b04 = a01 * a13 - a03 * a11,
b05 = a02 * a13 - a03 * a12,
b06 = a20 * a31 - a21 * a30,
b07 = a20 * a32 - a22 * a30,
b08 = a20 * a33 - a23 * a30,
b09 = a21 * a32 - a22 * a31,
b10 = a21 * a33 - a23 * a31,
b11 = a22 * a33 - a23 * a32,
d = (b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06),
invDet;
// Calculate the determinant
if (!d) { return null; }
invDet = 1 / d;
dest.m[0] = (a11 * b11 - a12 * b10 + a13 * b09) * invDet;
dest.m[1] = (-a01 * b11 + a02 * b10 - a03 * b09) * invDet;
dest.m[2] = (a31 * b05 - a32 * b04 + a33 * b03) * invDet;
dest.m[3] = (-a21 * b05 + a22 * b04 - a23 * b03) * invDet;
dest.m[4] = (-a10 * b11 + a12 * b08 - a13 * b07) * invDet;
dest.m[5] = (a00 * b11 - a02 * b08 + a03 * b07) * invDet;
dest.m[6] = (-a30 * b05 + a32 * b02 - a33 * b01) * invDet;
dest.m[7] = (a20 * b05 - a22 * b02 + a23 * b01) * invDet;
dest.m[8] = (a10 * b10 - a11 * b08 + a13 * b06) * invDet;
dest.m[9] = (-a00 * b10 + a01 * b08 - a03 * b06) * invDet;
dest.m[10] = (a30 * b04 - a31 * b02 + a33 * b00) * invDet;
dest.m[11] = (-a20 * b04 + a21 * b02 - a23 * b00) * invDet;
dest.m[12] = (-a10 * b09 + a11 * b07 - a12 * b06) * invDet;
dest.m[13] = (a00 * b09 - a01 * b07 + a02 * b06) * invDet;
dest.m[14] = (-a30 * b03 + a31 * b01 - a32 * b00) * invDet;
dest.m[15] = (a20 * b03 - a21 * b01 + a22 * b00) * invDet;
return dest;
}
toRotationMat() {
var dest:Mat4f = new Mat4f();
dest.m[0] = this.m[0];
dest.m[1] = this.m[1];
dest.m[2] = this.m[2];
dest.m[3] = this.m[3];
dest.m[4] = this.m[4];
dest.m[5] = this.m[5];
dest.m[6] = this.m[6];
dest.m[7] = this.m[7];
dest.m[8] = this.m[8];
dest.m[9] = this.m[9];
dest.m[10] = this.m[10];
dest.m[11] = this.m[11];
dest.m[12] = 0;
dest.m[13] = 0;
dest.m[14] = 0;
dest.m[15] = 1;
return dest;
}
frustum(left, right, bottom, top, near, far, overwrite:boolean=false) {
if(overwrite){
var dest:Mat4f = this;
}else{
dest = new Mat4f();
}
var rl = (right - left),
tb = (top - bottom),
fn = (far - near);
dest.m[0] = (near * 2) / rl;
dest.m[1] = 0;
dest.m[2] = 0;
dest.m[3] = 0;
dest.m[4] = 0;
dest.m[5] = (near * 2) / tb;
dest.m[6] = 0;
dest.m[7] = 0;
dest.m[8] = (right + left) / rl;
dest.m[9] = (top + bottom) / tb;
dest.m[10] = -(far + near) / fn;
dest.m[11] = -1;
dest.m[12] = 0;
dest.m[13] = 0;
dest.m[14] = -(far * near * 2) / fn;
dest.m[15] = 0;
return dest;
}
perspective(fovy, aspect, near, far, overwrite:boolean=false) {
var top = near * Math.tan(fovy * Math.PI / 360.0),
right = top * aspect;
return this.frustum(-right, right, -top, top, near, far, overwrite);
}
lookAt(eye, center, up) {
var x0, x1, x2, y0, y1, y2, z0, z1, z2, len,
eyex = eye[0],
eyey = eye[1],
eyez = eye[2],
upx = up[0],
upy = up[1],
upz = up[2],
centerx = center[0],
centery = center[1],
centerz = center[2];
if (eyex === centerx && eyey === centery && eyez === centerz) {
return this.identity(true);
}
//vec3.direction(eye, center, z);
z0 = eyex - centerx;
z1 = eyey - centery;
z2 = eyez - centerz;
// normalize (no check needed for 0 because of early return)
len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);
z0 *= len;
z1 *= len;
z2 *= len;
//vec3.normalize(vec3.cross(up, z, x));
x0 = upy * z2 - upz * z1;
x1 = upz * z0 - upx * z2;
x2 = upx * z1 - upy * z0;
len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);
if (!len) {
x0 = 0;
x1 = 0;
x2 = 0;
} else {
len = 1 / len;
x0 *= len;
x1 *= len;
x2 *= len;
}
//vec3.normalize(vec3.cross(z, x, y));
y0 = z1 * x2 - z2 * x1;
y1 = z2 * x0 - z0 * x2;
y2 = z0 * x1 - z1 * x0;
len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);
if (!len) {
y0 = 0;
y1 = 0;
y2 = 0;
} else {
len = 1 / len;
y0 *= len;
y1 *= len;
y2 *= len;
}
this.m[0] = x0;
this.m[1] = y0;
this.m[2] = z0;
this.m[3] = 0;
this.m[4] = x1;
this.m[5] = y1;
this.m[6] = z1;
this.m[7] = 0;
this.m[8] = x2;
this.m[9] = y2;
this.m[10] = z2;
this.m[11] = 0;
this.m[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);
this.m[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);
this.m[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);
this.m[15] = 1;
return this;
}
multiply(mat2) {
var dest = new Mat4f();
var mat = this.m;
// Cache the matrix values (makes for huge speed increases!)
var a00 = mat[ 0], a01 = mat[ 1], a02 = mat[ 2], a03 = mat[3];
var a10 = mat[ 4], a11 = mat[ 5], a12 = mat[ 6], a13 = mat[7];
var a20 = mat[ 8], a21 = mat[ 9], a22 = mat[10], a23 = mat[11];
var a30 = mat[12], a31 = mat[13], a32 = mat[14], a33 = mat[15];
// Cache only the current line of the second matrix
var b0 = mat2.m[0], b1 = mat2.m[1], b2 = mat2.m[2], b3 = mat2.m[3];
dest.m[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
dest.m[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
dest.m[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
dest.m[3] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
b0 = mat2.m[4];
b1 = mat2.m[5];
b2 = mat2.m[6];
b3 = mat2.m[7];
dest.m[4] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
dest.m[5] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
dest.m[6] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
dest.m[7] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
b0 = mat2.m[8];
b1 = mat2.m[9];
b2 = mat2.m[10];
b3 = mat2.m[11];
dest.m[8] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
dest.m[9] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
dest.m[10] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
dest.m[11] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
b0 = mat2.m[12];
b1 = mat2.m[13];
b2 = mat2.m[14];
b3 = mat2.m[15];
dest.m[12] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
dest.m[13] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
dest.m[14] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
dest.m[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
return dest;
}
multiplyVec4(vec) {
var dest = new Vec4f();
var x = vec[0], y = vec[1], z = vec[2], w = vec[3];
dest.x = this.m[0] * x + this.m[4] * y + this.m[8] * z + this.m[12] * w;
dest.y = this.m[1] * x + this.m[5] * y + this.m[9] * z + this.m[13] * w;
dest.z = this.m[2] * x + this.m[6] * y + this.m[10] * z + this.m[14] * w;
dest.w = this.m[3] * x + this.m[7] * y + this.m[11] * z + this.m[15] * w;
return dest;
}
} | 01alchemist/ParallelPathTracerJS | src/parallelpath/util/math/Mat4f.ts | TypeScript | mit | 11,955 |
๏ปฟmodule.exports = function (options, suite, test, expect, teardown) {
require('./integration.expressions')(options, suite, test, expect, teardown);
suite('tribe.storage.integration.' + options.type, function () {
var storage = require('tribe.storage'),
db;
test("basic store and retrieve", function () {
return open(['p1', 'p2'],
[
{ p1: 1, p2: 'test' },
{ p1: 2, p2: 'test2' }
])
.then(function (container) {
return container.retrieve({ p: 'p1', v: 1 });
})
.then(function (rows) {
expect(rows.length).to.equal(1);
expect(rows[0]).to.deep.equal({ p1: 1, p2: 'test' });
});
});
test("multiple key index store and retrieve", function () {
return open([['p1', 'p2']],
[
{ p1: 'test', p2: 1 },
{ p1: 'test', p2: 2 },
{ p1: 'test', p2: 3 },
{ p1: 'test2', p2: 2 },
])
.then(function (container) {
return container.retrieve([{ p: 'p1', v: 'test' }, { p: 'p2', o: '>=', v: 2 }]);
})
.then(function (rows) {
expect(rows.length).to.equal(2);
});
});
// this was originally done by sorting the index. this won't work with indexeddb as order is significant
// we can store some metadata about index order and apply expression components in the correct order. todo.
//test("multiple key order does not need to match expression order", function () {
// return open([['p1', 'p2']], [{ p1: 'test', p2: 1 }])
// .then(function (container) {
// return container.retrieve([{ p: 'p2', v: 1 }, { p: 'p1', v: 'test' }]);
// })
// .then(function (rows) {
// expect(rows.length).to.equal(1);
// });
//});
test("complex object store and retrieve", function () {
return open([['p1.p2', 'p3']],
[
{ p1: { p2: 'test' }, p3: 1 },
{ p1: { p2: 'test' }, p3: 1 },
{ p1: { p2: 'test2' }, p3: 1 }
])
.then(function (container) {
return container.retrieve([{ p: 'p1.p2', v: 'test' }, { p: 'p3', v: 1 }]);
})
.then(function (rows) {
expect(rows.length).to.equal(2);
});
});
test("keyPath can be queried when autoIncrement is set", function () {
return open([],
[
{ p2: 'test' },
{ p2: 'test2' }
], 'p1', true)
.then(function (container) {
return container.retrieve({ p: 'p1', v: 1 });
})
.then(function (rows) {
expect(rows.length).to.equal(1);
expect(rows[0]).to.deep.equal({ p1: 1, p2: 'test' });
});
});
test("keyPath can be queried when autoIncrement is not set", function () {
return open([],
[
{ p1: 3, p2: 'test' },
{ p1: 4, p2: 'test2' }
], 'p1', false)
.then(function (container) {
return container.retrieve({ p: 'p1', v: 3 });
})
.then(function (rows) {
expect(rows.length).to.equal(1);
expect(rows[0]).to.deep.equal({ p1: 3, p2: 'test' });
});
});
test("keyPath can be queried with indexes", function () {
return open(['p2'],
[
{ p1: 1, p2: 'test' },
{ p1: 2, p2: 'test2' }
], 'p1')
.then(function (container) {
return container.retrieve([{ p: 'p1', v: 1 }, { p: 'p2', v: 'test' }]);
})
.then(function (rows) {
expect(rows.length).to.equal(1);
expect(rows[0]).to.deep.equal({ p1: 1, p2: 'test' });
});
});
test("store operation returns entity with autoIncrement keyPath property set", function () {
return open([], [], 'id', true)
.then(function (container) {
return container.store({});
})
.then(function (updatedEntity) {
expect(updatedEntity).to.deep.equal({ id: 1 });
});
});
test("multiple store operation returns entities with autoIncrement keyPath property set", function () {
return open([], [], 'id', true)
.then(function (container) {
return container.store([{}, {}]);
})
.then(function (updatedEntity) {
expect(updatedEntity).to.deep.equal([{ id: 1 }, { id: 2 }]);
});
});
test("stored entity has autoIncrement keyPath property set", function () {
var container;
return open([], [], 'id', true)
.then(function (db) {
container = db;
return container.store({});
})
.then(function () {
return container.retrieve({ p: 'id', v: 1 });
})
.then(function (entities) {
expect(entities.length).to.equal(1);
expect(entities[0]).to.deep.equal({ id: 1 });
});
});
test("store operation replaces entities with matching keys", function () {
var entity;
return open([], [{ p1: 1, p2: 'test' }], 'p1')
.then(function (provider) {
entity = provider;
return entity.store({ p1: 1, p2: 'test2' });
})
.then(function () {
return entity.retrieve({ p: 'p1', v: 1 });
})
.then(function (entities) {
expect(entities.length).to.equal(1);
expect(entities[0].p2).to.equal('test2');
});
});
test("single property indexes can be specified and requested as arrays or individually", function () {
var container;
return open(['p1', ['p2']], [
{ p1: 1, p2: 1 },
{ p1: 2, p2: 2 }
])
.then(function (result) {
container = result;
return container.retrieve({ p: 'p1', v: 2 });
})
.then(function (results) {
expect(results.length).to.equal(1);
})
.then(function (result) {
return container.retrieve([{ p: 'p1', v: 2 }]);
})
.then(function (results) {
expect(results.length).to.equal(1);
})
.then(function (result) {
return container.retrieve({ p: 'p2', v: 2 });
})
.then(function (results) {
expect(results.length).to.equal(1);
})
.then(function (result) {
return container.retrieve([{ p: 'p2', v: 2 }]);
})
.then(function (results) {
expect(results.length).to.equal(1);
});
});
test("retrieve sorts by index properties", function () {
var container;
return open([['p1', 'p2.value'], ['p2.value', 'p1']], [
{ p1: 4, p2: { value: 1 } },
{ p1: 3, p2: { value: 2 } },
{ p1: 1, p2: { value: 1 } },
{ p1: 2, p2: { value: 2 } }
])
.then(function (result) {
container = result;
return container.retrieve([{ p: 'p1', o: '>', v: 0 }, { p: 'p2.value', o: '>', v: 0 }]);
})
.then(function (results) {
expect(results).to.deep.equal([
{ p1: 1, p2: { value: 1 } },
{ p1: 2, p2: { value: 2 } },
{ p1: 3, p2: { value: 2 } },
{ p1: 4, p2: { value: 1 } }
]);
return container.retrieve([{ p: 'p2.value', o: '>', v: 0 }, { p: 'p1', o: '>', v: 0 }]);
})
.then(function (results) {
expect(results).to.deep.equal([
{ p1: 1, p2: { value: 1 } },
{ p1: 4, p2: { value: 1 } },
{ p1: 2, p2: { value: 2 } },
{ p1: 3, p2: { value: 2 } }
]);
});
});
test("clear deletes all entities", function () {
var container;
return open(['p1'], [{ p1: 1, p2: 1 }])
.then(function (result) {
container = result;
container.clear();
})
.then(function () {
return container.retrieve({ p: 'p1', v: 1 });
})
.then(function (messages) {
expect(messages.length).to.equal(0);
});
});
function open(indexes, entities, keyPath, autoIncrement) {
var entity;
return storage.open([{ name: 'test', indexes: indexes, keyPath: keyPath, autoIncrement: autoIncrement }], options)
.then(function (provider) {
db = provider;
entity = provider.entity('test');
return entity.store(entities);
})
.then(function () {
return entity;
});
}
teardown(function () {
db.close();
});
});
};
| danderson00/tribe.storage | tests/integration.js | JavaScript | mit | 10,388 |
from math import floor
def score_syntax_errors(program_lines):
points = {')': 3, ']': 57, '}': 1197, '>': 25137}
s = 0
scores_auto = []
for line in program_lines:
corrupted, stack = corrupted_character(line)
if corrupted:
s += points[corrupted]
else:
scores_auto.append(score_autocomplete(stack))
return s, sorted(scores_auto)[floor(len(scores_auto)/2)]
def corrupted_character(inp):
stack = []
lookup = {'(': ')', '[': ']', '{': '}', '<': '>'}
lookup_close = {v: k for k, v in lookup.items()}
def stack_converter(st):
return [lookup[element] for element in st[::-1]]
for char in inp:
if char in lookup:
stack.append(char)
elif char in lookup_close:
expected = stack.pop()
if expected != lookup_close[char]:
return char, stack_converter(stack)
else:
print(f"INVALID {char}")
return None, stack_converter(stack)
def score_autocomplete(stack):
points_autocomplete = {')': 1, ']': 2, '}': 3, '>': 4}
s_auto = 0
for char in stack:
s_auto *= 5
s_auto += points_autocomplete[char]
return s_auto
def test_corrupted_character():
assert corrupted_character('{([(<{}[<>[]}>{[]{[(<()>')[0] == '}'
assert corrupted_character('[[<[([]))<([[{}[[()]]]')[0] == ')'
assert corrupted_character('[{[{({}]{}}([{[{{{}}([]')[0] == ']'
assert corrupted_character('[<(<(<(<{}))><([]([]()')[0] == ')'
assert corrupted_character('<{([([[(<>()){}]>(<<{{')[0] == '>'
def test_score_syntax_errors():
assert score_syntax_errors(open('input/10.test').read().splitlines()) == (26397, 288957)
def test_corrupted_character_stack():
assert corrupted_character('[({(<(())[]>[[{[]{<()<>>')[1] == ['}', '}', ']', ']', ')', '}', ')', ']']
def test_scoring_autocomplete():
assert score_autocomplete('}}]])})]') == 288957
assert score_autocomplete(')}>]})') == 5566
assert score_autocomplete('}}>}>))))') == 1480781
if __name__ == '__main__':
print(score_syntax_errors(open('input/10').read().splitlines()))
| matslindh/codingchallenges | adventofcode2021/day10.py | Python | mit | 2,156 |
๏ปฟusing System;
using App.Common.Extensions;
namespace App.Core.Elements
{
/// <summary>
/// ะะปะฐัั ะดะปั ะพะฟะธัะฐะฝะธั ัะฟะธัะบะฐ ะทะฐัะฒะปะตะฝะธะน ะฟะพ ะพะฟะปะฐัะต ะฟะพ ัะธะฟะฐะผ ัะปัะถะฑ.
/// </summary>
public class Declaration
{
/// <summary>
/// ะ ะฐััะตัะฝัะน ะฟะตัะธะพะด.
/// </summary>
public string SettlementPeriod { get; set; }
/// <summary>
/// ะะผั.
/// </summary>
public string Name { get; set; }
/// <summary>
/// ะขะธะฟ.
/// </summary>
public string Type { get; set; }
/// <summary>
/// ะ ะตัััั.
/// </summary>
public string Resource { get; set; }
/// <summary>
/// ะ ะตะณะธะพะฝ.
/// </summary>
public string Region { get; set; }
/// <summary>
/// SKU.
/// </summary>
/// <remarks>ะฃะบะฐะทัะฒะฐะตั ัะฝะธะบะฐะปัะฝัะน ะธะดะตะฝัะธัะธะบะฐัะพั ัะธััะตะผั ะดะปั ะบะฐะถะดะพะณะพ ัะตััััะฐ Windows Azure.</remarks>
public string SKU { get; set; }
/// <summary>
/// ะะดะธะฝะธัะฐ.
/// </summary>
public string Unit { get; set; }
/// <summary>
/// ะะทัะฐัั
ะพะดะพะฒะฐะฝะพ.
/// </summary>
public string Spent { get; set; }
/// <summary>
/// ะะบะปััะตะฝะพ.
/// </summary>
/// <remarks>ะกะพะดะตัะถะธั ะพะฑัะตะผ ัะตััััะพะฒ, ะฑะตัะฟะปะฐัะฝะพ ะฒะบะปััะฐะตะผัั
ะฒ ัะตะบััะธะน ัะฐััะตัะฝัะน ะฟะตัะธะพะด.</remarks>
public string Include { get; set; }
/// <summary>
/// ะะพะดะปะตะถะธั ะพะฟะปะฐัะต.
/// </summary>
/// <remarks>ะกะพะดะตัะถะธั ะพะฑัะตะผ ัะตััััะพะฒ, ะฟะพะดะปะตะถะฐัะธั
ะพะฟะปะฐัะต ะฒ ัะตะบััะตะผ ัะฐััะตัะฝะพะผ ะฟะตัะธะพะดะต.</remarks>
public string Payable { get; set; }
/// <summary>
/// ะ ัะฐะผะบะฐั
ะพะฑัะทะฐัะตะปัััะฒะฐ.
/// </summary>
/// <remarks>ะกะพะดะตัะถะธั ะฒัะฟะปะฐัั ะทะฐ ัะตััััั, ะบะพัะพััะต ะฒััะธัะฐัััั ะธะท ััะผะผั ะพะฑัะทะฐัะตะปัััะฒะฐ, ัะฒัะทะฐะฝะฝะพะน ั 6- ะธะปะธ 12-ะผะตัััะฝัะผ ะฟัะตะดะปะพะถะตะฝะธะตะผ. ะะฑัะฐัะธัะต ะฒะฝะธะผะฐะฝะธะต ะฝะฐ ัะพ, ััะพ ะฒัะฟะปะฐัั ะทะฐ ัะตััััั ะฒััะธัะฐัััั ะธะท ััะผะผั ะพะฑัะทะฐัะตะปัััะฒะฐ ะฒ ั
ัะพะฝะพะปะพะณะธัะตัะบะพะผ ะฟะพััะดะบะต.</remarks>
public string AsPartOfACommitment { get; set; }
/// <summary>
/// ะะฐะปััะฐ.
/// </summary>
/// <remarks>ะฃะบะฐะทัะฒะฐะตั ะฒะฐะปััั, ะธัะฟะพะปัะทัะตะผัั ะฒ ัะตะบััะตะผ ัะฐััะตัะฝะพะผ ะฟะตัะธะพะดะต.</remarks>
public string Currency { get; set; }
/// <summary>
/// ะัะตะฒััะตะฝะธะต.
/// </summary>
/// <remarks>ะกะพะดะตัะถะธั ะฒัะฟะปะฐัั ะทะฐ ัะตััััั, ะบะพัะพััะต ะฟัะตะฒััะฐัั ััะผะผั ะพะฑัะทะฐัะตะปัััะฒะฐ, ัะฒัะทะฐะฝะฝัั ั 6- ะธะปะธ 12-ะผะตัััะฝัะผ ะฟัะตะดะปะพะถะตะฝะธะตะผ.</remarks>
public string Excess { get; set; }
/// <summary>
/// ะขะฐัะธั ะฟะพ ะพะฑัะทะฐัะตะปัััะฒะฐะผ.
/// </summary>
/// <remarks>ะกะพะดะตัะถะธั ัะฐัะธั ะฟะพ ะพะฑัะทะฐัะตะปัััะฒะฐะผ, ะบะพัะพััะน ะทะฐะฒะธัะธั ะพั ะพะฑัะตะน ััะผะผั ะพะฑัะทะฐัะตะปัััะฒะฐ, ัะฒัะทะฐะฝะฝะพะน ั 6- ะธะปะธ 12-ะผะตัััะฝัะผ ะฟัะตะดะปะพะถะตะฝะธะตะผ.</remarks>
public string TariffCommitments { get; set; }
/// <summary>
/// ะขะฐัะธั.
/// </summary>
/// <remarks>ะกะพะดะตัะถะธั ัะฐัะธั ะพะฟะปะฐัั ะฟะพ ะผะตัะต ะธัะฟะพะปัะทะพะฒะฐะฝะธั ะดะปั ัะตััััะฐ.</remarks>
public string Tariff { get; set; }
/// <summary>
/// ะะฝะฐัะตะฝะธะต.
/// </summary>
/// <remarks>ะกะพะดะตัะถะธั ะธัะพะณะพะฒัั ะดะตะฝะตะถะฝัั ััะผะผั ะดะปั ะธะทัะฐัั
ะพะดะพะฒะฐะฝะฝะพะณะพ ัะตััััะฐ.</remarks>
public string Value { get; set; }
/// <summary>
/// ะะฝะธัะธะฐะปะธะทะฐัะธั "ะฟัััะพะณะพ" ะพะฑัะตะบัะฐ.
/// </summary>
public Declaration()
{ }
/// <summary>
/// ะะฝะธัะธะฐะปะธะทะฐัะธั ะพะฑัะตะบัะฐ ั ะดะฐะฝะฝัะผะธ ะฟะพะปััะตะฝะฝัะผะธ ะธะท ัะฐะทะฑะพัะฐ ัััะพะบะธ CSV ัะฐะนะปะฐ.
/// </summary>
/// <param name="data">ะะฐััะธะฒ ัััะพะบ ะธะท ัะฐะนะปะฐ.</param>
public Declaration(string[] data)
{
SettlementPeriod = data[0];
Name = data[1];
Type = data[2];
Resource = data[3];
Region = data[4];
SKU = data[5];
Unit = data[6];
Spent = data[7];
Include = data[8];
Payable = data[9];
AsPartOfACommitment = data[10];
Currency = data[11];
Excess = data[12];
TariffCommitments = data[13];
Tariff = data[14];
Value = data[15];
}
public override string ToString()
{
return String.Format("ะะตะบะปะฐัะฐัะธั ะทะฐ {0} ะพััะตัะฝัะน ะฟะตัะธะพะด ะฟะพ ัะปัะถะฑะต {1}.", SettlementPeriod, Name);
}
/// <summary>
/// ะ ะฐััะตั ะฟะพััะฐัะตะฝะฝะพะน ััะผะผั ะฟะพ ะดะตะบะปะฐัะฐัะธะธ.
/// </summary>
/// <returns>ะะพะทะฒัะฐัะฐะตั ะทะฝะฐัะตะฝะธะต ััะผะผั, ัะตะฐะปัะฝะพ ะฟะพััะฐัะตะฝะฝะพะน ะฝะฐ ััะปัะณั.</returns>
public double CalculateSpentValue()
{
return Convert.ToDouble(Spent.CorrectDouble())*Convert.ToDouble(Tariff.CorrectDouble());
}
}
}
| Digiman/AzureBillingViewer | App.Core/Elements/Declaration.cs | C# | mit | 5,760 |
/*
* Copyright (C) 2013-2015 Uncharted Software Inc.
*
* Property of Uncharted(TM), formerly Oculus Info Inc.
* http://uncharted.software/
*
* Released under the 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.
*/
package influent.server.sql;
/**
* Represents a SQL FROM clause. This can be used to create complicated
* sub-selects that can still be chained together.
*
* @author cregnier
*
*/
public interface SQLFrom {
/**
* Sets the name of table to select results from.<br>
* This cannot be set if {@link #fromQuery(SQLSelect)} has also been set.
* @param name
* The name of an existing table in the database
* @return
*/
SQLFrom table(String name);
/**
* Adds an alias for the table.
* @param alias
* The name of the alias that will be used in the SQL statement.
* @return
*/
SQLFrom as(String alias);
/**
* Sets a subquery that should be used to select results from.<br>
* This cannot be set if {@link #table(String)} has also been set.
* @param fromQuery
* A subquery to select results from.
* @return
*/
SQLFrom fromQuery(SQLSelect fromQuery);
}
| MjAbuz/influent | influent-server/src/main/java/influent/server/sql/SQLFrom.java | Java | mit | 2,160 |
# jekyll-theme-jtannerjones_com
Welcome to your new Jekyll theme! In this directory, you'll find the files you need to be able to package up your theme into a gem. Put your layouts in `_layouts`, your includes in `_includes` and your sass in `_sass`. To experiment with this code, add some sample content and run `bundle exec jekyll serve` โ this directory is setup just like a Jekyll site!
TODO: Delete this and the text above, and describe your gem
## Installation
Add this line to your Jekyll site's `Gemfile`:
```ruby
gem "jekyll-theme-jtannerjones_com"
```
And add this line to your Jekyll site's `_config.yml`:
```yaml
theme: jekyll-theme-jtannerjones_com
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install jekyll-theme-jtannerjones_com
## Usage
TODO: Write usage instructions here. Describe your available layouts, includes, and/or sass.
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/hello. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## Development
To set up your environment to develop this theme, run `bundle install`.
Your theme is setup just like a normal Jekyll site! To test your theme, run `bundle exec jekyll serve` and open your browser at `http://localhost:4000`. This starts a Jekyll server using your theme. Add pages, documents, data, etc. like normal to test your theme's contents. As you make modifications to your theme and to your content, your site will regenerate and you should see the changes in the browser after a refresh, just like normal.
When your theme is released, only the files in `_layouts`, `_includes`, and `_sass` tracked with Git will be released.
## License
The theme is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
| tannerj/jekyll-theme-jtannerjones_com | README.md | Markdown | mit | 1,973 |
module TinyMVC
class BaseModel
attr_reader :id
def initialize(options = {})
parameters = self.class.stored_parameters + [:id]
parameters.each do |attr|
instance_variable_set(:"@#{attr}", options[attr.to_s] || options[attr.to_sym])
end
end
def self.stored_parameters(*args)
return @stored_parameters if args.empty?
@stored_parameters = *args
@stored_parameters.freeze
attr_accessor *args
end
def self.all
raise NotImplementedError
end
def self.find(id)
raise NotImplementedError
end
def self.count
raise NotImplementedError
end
def self.create(options)
new(options).save
end
def self.delete_all
raise NotImplementedError
end
# should generate @id for new record and return self
def save
raise NotImplementedError
end
# should return self
def delete
raise NotImplementedError
end
def ==(obj)
self.class == obj.class && obj.id && self.id == obj.id
end
def new_record?
self.id.nil?
end
def attributes
parameters = self.class.stored_parameters + [:id]
parameters.reduce({}) do |hash, attr|
hash.merge(attr => instance_variable_get("@#{attr}"))
end
end
end
end
| DordovskyDmitry/tiny_mvc | lib/tiny_mvc/mvc/model/base_model.rb | Ruby | mit | 1,309 |
<?xml version="1.0" ?><!DOCTYPE TS><TS language="pt_PT" version="2.1">
<context>
<name>AboutDialog</name>
<message>
<location filename="../forms/aboutdialog.ui" line="+14"/>
<source>About ReturnCoin</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+39"/>
<source><b>ReturnCoin</b> version</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+41"/>
<source>Copyright ยฉ 2009-2014 The Bitcoin developers
Copyright ยฉ 2012-2014 The NovaCoin developers
Copyright ยฉ 2015 The ReturnCoin 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>
Este รฉ um programa experimental.
Distribuรญdo sob uma licenรงa de software MIT/X11, por favor verifique o ficheiro anexo license.txt ou http://www.opensource.org/licenses/mit-license.php.
Este produto inclui software desenvolvido pelo Projecto OpenSSL para uso no OpenSSL Toolkit (http://www.openssl.org/), software criptogrรกfico escrito por Eric Young ([email protected]) e software UPnP escrito por Thomas Bernard.</translation>
</message>
</context>
<context>
<name>AddressBookPage</name>
<message>
<location filename="../forms/addressbookpage.ui" line="+14"/>
<source>Address Book</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+22"/>
<source>Double-click to edit address or label</source>
<translation>Clique duas vezes para editar o endereรงo ou o rรณtulo</translation>
</message>
<message>
<location line="+27"/>
<source>Create a new address</source>
<translation>Criar um novo endereรงo</translation>
</message>
<message>
<location line="+14"/>
<source>Copy the currently selected address to the system clipboard</source>
<translation>Copie o endereรงo selecionado para a รกrea de transferรชncia</translation>
</message>
<message>
<location line="-11"/>
<source>&New Address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-46"/>
<source>These are your ReturnCoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+60"/>
<source>&Copy Address</source>
<translation>&Copiar Endereรงo</translation>
</message>
<message>
<location line="+11"/>
<source>Show &QR Code</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+11"/>
<source>Sign a message to prove you own a ReturnCoin address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Sign &Message</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+25"/>
<source>Delete the currently selected address from the list</source>
<translation>Apagar o endereรงo selecionado da lista</translation>
</message>
<message>
<location line="-14"/>
<source>Verify a message to ensure it was signed with a specified ReturnCoin address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>&Verify Message</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+14"/>
<source>&Delete</source>
<translation>E&liminar</translation>
</message>
<message>
<location filename="../addressbookpage.cpp" line="+65"/>
<source>Copy &Label</source>
<translation>Copiar &Rรณtulo</translation>
</message>
<message>
<location line="+2"/>
<source>&Edit</source>
<translation>&Editar</translation>
</message>
<message>
<location line="+250"/>
<source>Export Address Book Data</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Comma separated file (*.csv)</source>
<translation>Ficheiro separado por vรญrgulas (*.csv)</translation>
</message>
<message>
<location line="+13"/>
<source>Error exporting</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>Could not write to file %1.</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>AddressTableModel</name>
<message>
<location filename="../addresstablemodel.cpp" line="+144"/>
<source>Label</source>
<translation>Rรณtulo</translation>
</message>
<message>
<location line="+0"/>
<source>Address</source>
<translation>Endereรงo</translation>
</message>
<message>
<location line="+36"/>
<source>(no label)</source>
<translation>(sem rรณtulo)</translation>
</message>
</context>
<context>
<name>AskPassphraseDialog</name>
<message>
<location filename="../forms/askpassphrasedialog.ui" line="+26"/>
<source>Passphrase Dialog</source>
<translation>Diรกlogo de Frase-Passe</translation>
</message>
<message>
<location line="+21"/>
<source>Enter passphrase</source>
<translation>Escreva a frase de seguranรงa</translation>
</message>
<message>
<location line="+14"/>
<source>New passphrase</source>
<translation>Nova frase de seguranรงa</translation>
</message>
<message>
<location line="+14"/>
<source>Repeat new passphrase</source>
<translation>Repita a nova frase de seguranรงa</translation>
</message>
<message>
<location line="+33"/>
<source>Serves to disable the trivial sendmoney when OS account compromised. Provides no real security.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>For staking only</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../askpassphrasedialog.cpp" line="+35"/>
<source>Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>10 or more random characters</b>, or <b>eight or more words</b>.</source>
<translation>Escreva a nova frase de seguraรงa da sua carteira. <br/> Por favor, use uma frase de <b>10 ou mais caracteres aleatรณrios,</b> ou <b>oito ou mais palavras</b>.</translation>
</message>
<message>
<location line="+1"/>
<source>Encrypt wallet</source>
<translation>Encriptar carteira</translation>
</message>
<message>
<location line="+7"/>
<source>This operation needs your wallet passphrase to unlock the wallet.</source>
<translation>A sua frase de seguranรงa รฉ necessรกria para desbloquear a carteira.</translation>
</message>
<message>
<location line="+5"/>
<source>Unlock wallet</source>
<translation>Desbloquear carteira</translation>
</message>
<message>
<location line="+3"/>
<source>This operation needs your wallet passphrase to decrypt the wallet.</source>
<translation>A sua frase de seguranรงa รฉ necessรกria para desencriptar a carteira.</translation>
</message>
<message>
<location line="+5"/>
<source>Decrypt wallet</source>
<translation>Desencriptar carteira</translation>
</message>
<message>
<location line="+3"/>
<source>Change passphrase</source>
<translation>Alterar frase de seguranรงa</translation>
</message>
<message>
<location line="+1"/>
<source>Enter the old and new passphrase to the wallet.</source>
<translation>Escreva a frase de seguranรงa antiga seguida da nova para a carteira.</translation>
</message>
<message>
<location line="+46"/>
<source>Confirm wallet encryption</source>
<translation>Confirmar encriptaรงรฃo da carteira</translation>
</message>
<message>
<location line="+1"/>
<source>Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR COINS</b>!</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>Are you sure you wish to encrypt your wallet?</source>
<translation>Tem a certeza que deseja encriptar a carteira?</translation>
</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>IMPORTANTE: Qualquer cรณpia de seguranรงa anterior da carteira deverรก ser substituรญda com o novo, actualmente encriptado, ficheiro de carteira. Por razรตes de seguranรงa, cรณpias de seguranรงa nรฃo encriptadas efectuadas anteriormente do ficheiro da carteira tornar-se-รฃo inรบteis assim que comeรงar a usar a nova carteira encriptada.</translation>
</message>
<message>
<location line="+103"/>
<location line="+24"/>
<source>Warning: The Caps Lock key is on!</source>
<translation>Atenรงรฃo: A tecla Caps Lock estรก activa!</translation>
</message>
<message>
<location line="-133"/>
<location line="+60"/>
<source>Wallet encrypted</source>
<translation>Carteira encriptada</translation>
</message>
<message>
<location line="-58"/>
<source>ReturnCoin 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>A encriptaรงรฃo da carteira falhou</translation>
</message>
<message>
<location line="-56"/>
<source>Wallet encryption failed due to an internal error. Your wallet was not encrypted.</source>
<translation>A encriptaรงรฃo da carteira falhou devido a um erro interno. A carteira nรฃo foi encriptada.</translation>
</message>
<message>
<location line="+7"/>
<location line="+50"/>
<source>The supplied passphrases do not match.</source>
<translation>As frases de seguranรงa fornecidas nรฃo coincidem.</translation>
</message>
<message>
<location line="-38"/>
<source>Wallet unlock failed</source>
<translation>O desbloqueio da carteira falhou</translation>
</message>
<message>
<location line="+1"/>
<location line="+12"/>
<location line="+19"/>
<source>The passphrase entered for the wallet decryption was incorrect.</source>
<translation>A frase de seguranรงa introduzida para a desencriptaรงรฃo da carteira estava incorreta.</translation>
</message>
<message>
<location line="-20"/>
<source>Wallet decryption failed</source>
<translation>A desencriptaรงรฃo da carteira falhou</translation>
</message>
<message>
<location line="+14"/>
<source>Wallet passphrase was successfully changed.</source>
<translation>A frase de seguranรงa da carteira foi alterada com รชxito.</translation>
</message>
</context>
<context>
<name>BitcoinGUI</name>
<message>
<location filename="../bitcoingui.cpp" line="+282"/>
<source>Sign &message...</source>
<translation>Assinar &mensagem...</translation>
</message>
<message>
<location line="+251"/>
<source>Synchronizing with network...</source>
<translation>Sincronizando com a rede...</translation>
</message>
<message>
<location line="-319"/>
<source>&Overview</source>
<translation>Visรฃ&o geral</translation>
</message>
<message>
<location line="+1"/>
<source>Show general overview of wallet</source>
<translation>Mostrar visรฃo geral da carteira</translation>
</message>
<message>
<location line="+17"/>
<source>&Transactions</source>
<translation>&Transaรงรตes</translation>
</message>
<message>
<location line="+1"/>
<source>Browse transaction history</source>
<translation>Navegar pelo histรณrico de transaรงรตes</translation>
</message>
<message>
<location line="+5"/>
<source>&Address Book</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Edit the list of stored addresses and labels</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-13"/>
<source>&Receive coins</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Show the list of addresses for receiving payments</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-7"/>
<source>&Send coins</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+35"/>
<source>E&xit</source>
<translation>Fec&har</translation>
</message>
<message>
<location line="+1"/>
<source>Quit application</source>
<translation>Sair da aplicaรงรฃo</translation>
</message>
<message>
<location line="+6"/>
<source>Show information about ReturnCoin</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>About &Qt</source>
<translation>Sobre &Qt</translation>
</message>
<message>
<location line="+1"/>
<source>Show information about Qt</source>
<translation>Mostrar informaรงรฃo sobre Qt</translation>
</message>
<message>
<location line="+2"/>
<source>&Options...</source>
<translation>&Opรงรตes...</translation>
</message>
<message>
<location line="+4"/>
<source>&Encrypt Wallet...</source>
<translation>E&ncriptar Carteira...</translation>
</message>
<message>
<location line="+3"/>
<source>&Backup Wallet...</source>
<translation>&Guardar Carteira...</translation>
</message>
<message>
<location line="+2"/>
<source>&Change Passphrase...</source>
<translation>Mudar &Palavra-passe...</translation>
</message>
<message numerus="yes">
<location line="+259"/>
<source>~%n block(s) remaining</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message>
<location line="+6"/>
<source>Downloaded %1 of %2 blocks of transaction history (%3% done).</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-256"/>
<source>&Export...</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-64"/>
<source>Send coins to a ReturnCoin address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+47"/>
<source>Modify configuration options for ReturnCoin</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>Faรงa uma cรณpia de seguranรงa da carteira para outra localizaรงรฃo</translation>
</message>
<message>
<location line="+2"/>
<source>Change the passphrase used for wallet encryption</source>
<translation>Mudar a frase de seguranรงa utilizada na encriptaรงรฃo da carteira</translation>
</message>
<message>
<location line="+10"/>
<source>&Debug window</source>
<translation>Janela de &depuraรงรฃo</translation>
</message>
<message>
<location line="+1"/>
<source>Open debugging and diagnostic console</source>
<translation>Abrir consola de diagnรณstico e depuraรงรฃo</translation>
</message>
<message>
<location line="-5"/>
<source>&Verify message...</source>
<translation>&Verificar mensagem...</translation>
</message>
<message>
<location line="-202"/>
<source>ReturnCoin</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>Wallet</source>
<translation>Carteira</translation>
</message>
<message>
<location line="+180"/>
<source>&About ReturnCoin</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+9"/>
<source>&Show / Hide</source>
<translation>Mo&strar / Ocultar</translation>
</message>
<message>
<location line="+9"/>
<source>Unlock wallet</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>&Lock Wallet</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Lock wallet</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+35"/>
<source>&File</source>
<translation>&Ficheiro</translation>
</message>
<message>
<location line="+8"/>
<source>&Settings</source>
<translation>Con&figuraรงรตes</translation>
</message>
<message>
<location line="+8"/>
<source>&Help</source>
<translation>A&juda</translation>
</message>
<message>
<location line="+12"/>
<source>Tabs toolbar</source>
<translation>Barra de separadores</translation>
</message>
<message>
<location line="+8"/>
<source>Actions toolbar</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+13"/>
<location line="+9"/>
<source>[testnet]</source>
<translation>[rede de testes]</translation>
</message>
<message>
<location line="+0"/>
<location line="+60"/>
<source>ReturnCoin client</source>
<translation type="unfinished"/>
</message>
<message numerus="yes">
<location line="+75"/>
<source>%n active connection(s) to ReturnCoin network</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message>
<location line="+40"/>
<source>Downloaded %1 blocks of transaction history.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+413"/>
<source>Staking.<br>Your weight is %1<br>Network weight is %2<br>Expected time to earn reward is %3</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+6"/>
<source>Not staking because wallet is locked</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Not staking because wallet is offline</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Not staking because wallet is syncing</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Not staking because you don't have mature coins</source>
<translation type="unfinished"/>
</message>
<message numerus="yes">
<location line="-403"/>
<source>%n second(s) ago</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message>
<location line="-312"/>
<source>About ReturnCoin card</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Show information about ReturnCoin card</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+18"/>
<source>&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></translation>
</message>
<message numerus="yes">
<location line="+4"/>
<source>%n hour(s) ago</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message numerus="yes">
<location line="+4"/>
<source>%n day(s) ago</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message>
<location line="+6"/>
<source>Up to date</source>
<translation>Atualizado</translation>
</message>
<message>
<location line="+7"/>
<source>Catching up...</source>
<translation>Recuperando...</translation>
</message>
<message>
<location line="+10"/>
<source>Last received block was generated %1.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+59"/>
<source>This transaction is over the size limit. You can still send it for a fee of %1, which goes to the nodes that process your transaction and helps to support the network. Do you want to pay the fee?</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+5"/>
<source>Confirm transaction fee</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+27"/>
<source>Sent transaction</source>
<translation>Transaรงรฃo enviada</translation>
</message>
<message>
<location line="+1"/>
<source>Incoming transaction</source>
<translation>Transaรงรฃo recebida</translation>
</message>
<message>
<location line="+1"/>
<source>Date: %1
Amount: %2
Type: %3
Address: %4
</source>
<translation>Data: %1
Quantia: %2
Tipo: %3
Endereรงo: %4
</translation>
</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 ReturnCoin address or malformed URI parameters.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+18"/>
<source>Wallet is <b>encrypted</b> and currently <b>unlocked</b></source>
<translation>A carteira estรก <b>encriptada</b> e atualmente <b>desbloqueada</b></translation>
</message>
<message>
<location line="+10"/>
<source>Wallet is <b>encrypted</b> and currently <b>locked</b></source>
<translation>A carteira estรก <b>encriptada</b> e atualmente <b>bloqueada</b></translation>
</message>
<message>
<location line="+25"/>
<source>Backup Wallet</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>Wallet Data (*.dat)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Backup Failed</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>There was an error trying to save the wallet data to the new location.</source>
<translation type="unfinished"/>
</message>
<message numerus="yes">
<location line="+76"/>
<source>%n second(s)</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message numerus="yes">
<location line="+4"/>
<source>%n minute(s)</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message numerus="yes">
<location line="+4"/>
<source>%n hour(s)</source>
<translation><numerusform>%n hora</numerusform><numerusform>%n horas</numerusform></translation>
</message>
<message numerus="yes">
<location line="+4"/>
<source>%n day(s)</source>
<translation><numerusform>%n dia</numerusform><numerusform>%n dias</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. ReturnCoin 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>Alerta da Rede</translation>
</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>Quantidade:</translation>
</message>
<message>
<location line="+32"/>
<source>Bytes:</source>
<translation>Bytes:</translation>
</message>
<message>
<location line="+48"/>
<source>Amount:</source>
<translation>Quantia:</translation>
</message>
<message>
<location line="+32"/>
<source>Priority:</source>
<translation>Prioridade:</translation>
</message>
<message>
<location line="+48"/>
<source>Fee:</source>
<translation>Taxa:</translation>
</message>
<message>
<location line="+35"/>
<source>Low Output:</source>
<translation>Saรญda Baixa:</translation>
</message>
<message>
<location filename="../coincontroldialog.cpp" line="+551"/>
<source>no</source>
<translation>nรฃo</translation>
</message>
<message>
<location filename="../forms/coincontroldialog.ui" line="+51"/>
<source>After Fee:</source>
<translation>Depois de taxas:</translation>
</message>
<message>
<location line="+35"/>
<source>Change:</source>
<translation>Troco:</translation>
</message>
<message>
<location line="+69"/>
<source>(un)select all</source>
<translation>(des)seleccionar todos</translation>
</message>
<message>
<location line="+13"/>
<source>Tree mode</source>
<translation>Modo de รกrvore</translation>
</message>
<message>
<location line="+16"/>
<source>List mode</source>
<translation>Modo lista</translation>
</message>
<message>
<location line="+45"/>
<source>Amount</source>
<translation>Quantia</translation>
</message>
<message>
<location line="+5"/>
<source>Label</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+5"/>
<source>Address</source>
<translation>Endereรงo</translation>
</message>
<message>
<location line="+5"/>
<source>Date</source>
<translation>Data</translation>
</message>
<message>
<location line="+5"/>
<source>Confirmations</source>
<translation>Confirmados</translation>
</message>
<message>
<location line="+3"/>
<source>Confirmed</source>
<translation>Confirmada</translation>
</message>
<message>
<location line="+5"/>
<source>Priority</source>
<translation>Prioridade</translation>
</message>
<message>
<location filename="../coincontroldialog.cpp" line="-515"/>
<source>Copy address</source>
<translation>Copiar endereรงo</translation>
</message>
<message>
<location line="+1"/>
<source>Copy label</source>
<translation>Copiar rรณtulo</translation>
</message>
<message>
<location line="+1"/>
<location line="+26"/>
<source>Copy amount</source>
<translation>Copiar quantia</translation>
</message>
<message>
<location line="-25"/>
<source>Copy transaction ID</source>
<translation>Copiar ID da Transaรงรฃo</translation>
</message>
<message>
<location line="+24"/>
<source>Copy quantity</source>
<translation>Copiar quantidade</translation>
</message>
<message>
<location line="+2"/>
<source>Copy fee</source>
<translation>Taxa de cรณpia</translation>
</message>
<message>
<location line="+1"/>
<source>Copy after fee</source>
<translation>Taxa depois de cรณpia</translation>
</message>
<message>
<location line="+1"/>
<source>Copy bytes</source>
<translation>Copiar bytes</translation>
</message>
<message>
<location line="+1"/>
<source>Copy priority</source>
<translation>Prioridade de Cรณpia</translation>
</message>
<message>
<location line="+1"/>
<source>Copy low output</source>
<translation>Copiar output baixo</translation>
</message>
<message>
<location line="+1"/>
<source>Copy change</source>
<translation>Copiar alteraรงรฃo</translation>
</message>
<message>
<location line="+317"/>
<source>highest</source>
<translation>o maior</translation>
</message>
<message>
<location line="+1"/>
<source>high</source>
<translation>alto</translation>
</message>
<message>
<location line="+1"/>
<source>medium-high</source>
<translation>mรฉdio-alto</translation>
</message>
<message>
<location line="+1"/>
<source>medium</source>
<translation>mรฉdio</translation>
</message>
<message>
<location line="+4"/>
<source>low-medium</source>
<translation>baixo-mรฉdio</translation>
</message>
<message>
<location line="+1"/>
<source>low</source>
<translation>baixo</translation>
</message>
<message>
<location line="+1"/>
<source>lowest</source>
<translation>O mais baixo</translation>
</message>
<message>
<location line="+155"/>
<source>DUST</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>yes</source>
<translation>sim</translation>
</message>
<message>
<location line="+10"/>
<source>This label turns red, if the transaction size is bigger than 10000 bytes.
This means a fee of at least %1 per kb is required.
Can vary +/- 1 Byte per input.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Transactions with higher priority get more likely into a block.
This label turns red, if the priority is smaller than "medium".
This means a fee of at least %1 per kb is required.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>This label turns red, if any recipient receives an amount smaller than %1.
This means a fee of at least %2 is required.
Amounts below 0.546 times the minimum relay fee are shown as DUST.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>This label turns red, if the change is smaller than %1.
This means a fee of at least %2 is required.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+37"/>
<location line="+66"/>
<source>(no label)</source>
<translation>(Sem rรณtulo)</translation>
</message>
<message>
<location line="-9"/>
<source>change from %1 (%2)</source>
<translation>Alteraรงรฃo de %1 (%2)</translation>
</message>
<message>
<location line="+1"/>
<source>(change)</source>
<translation>(Alteraรงรฃo)</translation>
</message>
</context>
<context>
<name>EditAddressDialog</name>
<message>
<location filename="../forms/editaddressdialog.ui" line="+14"/>
<source>Edit Address</source>
<translation>Editar Endereรงo</translation>
</message>
<message>
<location line="+11"/>
<source>&Label</source>
<translation>&Rรณtulo</translation>
</message>
<message>
<location line="+10"/>
<source>The label associated with this address book entry</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+7"/>
<source>&Address</source>
<translation>E&ndereรงo</translation>
</message>
<message>
<location line="+10"/>
<source>The address associated with this address book entry. This can only be modified for sending addresses.</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../editaddressdialog.cpp" line="+20"/>
<source>New receiving address</source>
<translation>Novo endereรงo de entrada</translation>
</message>
<message>
<location line="+4"/>
<source>New sending address</source>
<translation>Novo endereรงo de saรญda</translation>
</message>
<message>
<location line="+3"/>
<source>Edit receiving address</source>
<translation>Editar endereรงo de entrada</translation>
</message>
<message>
<location line="+4"/>
<source>Edit sending address</source>
<translation>Editar endereรงo de saรญda</translation>
</message>
<message>
<location line="+76"/>
<source>The entered address "%1" is already in the address book.</source>
<translation>O endereรงo introduzido "%1" jรก se encontra no livro de endereรงos.</translation>
</message>
<message>
<location line="-5"/>
<source>The entered address "%1" is not a valid ReturnCoin address.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+10"/>
<source>Could not unlock wallet.</source>
<translation>Impossรญvel desbloquear carteira.</translation>
</message>
<message>
<location line="+5"/>
<source>New key generation failed.</source>
<translation>Falha ao gerar nova chave.</translation>
</message>
</context>
<context>
<name>GUIUtil::HelpMessageBox</name>
<message>
<location filename="../guiutil.cpp" line="+420"/>
<location line="+12"/>
<source>returncoin-qt</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-12"/>
<source>version</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Usage:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>command-line options</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+4"/>
<source>UI options</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Set language, for example "de_DE" (default: system locale)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Start minimized</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Show splash screen on startup (default: 1)</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>OptionsDialog</name>
<message>
<location filename="../forms/optionsdialog.ui" line="+14"/>
<source>Options</source>
<translation>Opรงรตes</translation>
</message>
<message>
<location line="+16"/>
<source>&Main</source>
<translation>&Principal</translation>
</message>
<message>
<location line="+6"/>
<source>Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB. Fee 0.01 recommended.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+15"/>
<source>Pay transaction &fee</source>
<translation>Pagar &taxa de transaรงรฃo</translation>
</message>
<message>
<location line="+31"/>
<source>Reserved amount does not participate in staking and is therefore spendable at any time.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+15"/>
<source>Reserve</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+31"/>
<source>Automatically start ReturnCoin after logging in to the system.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>&Start ReturnCoin on system login</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+7"/>
<source>Detach block and address databases at shutdown. This means they can be moved to another data directory, but it slows down shutdown. The wallet is always detached.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>&Detach databases at shutdown</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+21"/>
<source>&Network</source>
<translation>&Rede</translation>
</message>
<message>
<location line="+6"/>
<source>Automatically open the ReturnCoin client port on the router. This only works when your router supports UPnP and it is enabled.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Map port using &UPnP</source>
<translation>Mapear porta usando &UPnP</translation>
</message>
<message>
<location line="+7"/>
<source>Connect to the ReturnCoin network through a SOCKS proxy (e.g. when connecting through Tor).</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>&Connect through SOCKS proxy:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+9"/>
<source>Proxy &IP:</source>
<translation>&IP do proxy:</translation>
</message>
<message>
<location line="+19"/>
<source>IP address of the proxy (e.g. 127.0.0.1)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+7"/>
<source>&Port:</source>
<translation>&Porta:</translation>
</message>
<message>
<location line="+19"/>
<source>Port of the proxy (e.g. 9050)</source>
<translation>Porta do proxy (p.ex. 9050)</translation>
</message>
<message>
<location line="+7"/>
<source>SOCKS &Version:</source>
<translation>&Versรฃo SOCKS:</translation>
</message>
<message>
<location line="+13"/>
<source>SOCKS version of the proxy (e.g. 5)</source>
<translation>Versรฃo do proxy SOCKS (p.ex. 5)</translation>
</message>
<message>
<location line="+36"/>
<source>&Window</source>
<translation>&Janela</translation>
</message>
<message>
<location line="+6"/>
<source>Show only a tray icon after minimizing the window.</source>
<translation>Apenas mostrar o รญcone da bandeja apรณs minimizar a janela.</translation>
</message>
<message>
<location line="+3"/>
<source>&Minimize to the tray instead of the taskbar</source>
<translation>&Minimizar para a bandeja e nรฃo para a barra de ferramentas</translation>
</message>
<message>
<location line="+7"/>
<source>Minimize instead of exit the application when the window is closed. When this option is enabled, the application will be closed only after selecting Quit in the menu.</source>
<translation>Minimize ao invรฉs de sair da aplicaรงรฃo quando a janela รฉ fechada. Com esta opรงรฃo selecionada, a aplicaรงรฃo apenas serรก encerrada quando escolher Sair da aplicaรงรฃo no menรบ.</translation>
</message>
<message>
<location line="+3"/>
<source>M&inimize on close</source>
<translation>M&inimizar ao fechar</translation>
</message>
<message>
<location line="+21"/>
<source>&Display</source>
<translation>Vis&ualizaรงรฃo</translation>
</message>
<message>
<location line="+8"/>
<source>User Interface &language:</source>
<translation>&Linguagem da interface de utilizador:</translation>
</message>
<message>
<location line="+13"/>
<source>The user interface language can be set here. This setting will take effect after restarting ReturnCoin.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+11"/>
<source>&Unit to show amounts in:</source>
<translation>&Unidade a usar em quantias:</translation>
</message>
<message>
<location line="+13"/>
<source>Choose the default subdivision unit to show in the interface and when sending coins.</source>
<translation>Escolha a subdivisรฃo unitรกria a ser mostrada por defeito na aplicaรงรฃo e ao enviar moedas.</translation>
</message>
<message>
<location line="+9"/>
<source>Whether to show ReturnCoin addresses in the transaction list or not.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>&Display addresses in transaction list</source>
<translation>Mostrar en&dereรงos na lista de transaรงรตes</translation>
</message>
<message>
<location line="+7"/>
<source>Whether to show coin control features or not.</source>
<translation>Escolha para mostrar funcionalidades de controlo "coin" ou nรฃo.</translation>
</message>
<message>
<location line="+3"/>
<source>Display coin &control features (experts only!)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+71"/>
<source>&OK</source>
<translation>&OK</translation>
</message>
<message>
<location line="+7"/>
<source>&Cancel</source>
<translation>&Cancelar</translation>
</message>
<message>
<location line="+10"/>
<source>&Apply</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../optionsdialog.cpp" line="+55"/>
<source>default</source>
<translation>padrรฃo</translation>
</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 ReturnCoin.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+29"/>
<source>The supplied proxy address is invalid.</source>
<translation>O endereรงo de proxy introduzido รฉ invรกlido. </translation>
</message>
</context>
<context>
<name>OverviewPage</name>
<message>
<location filename="../forms/overviewpage.ui" line="+14"/>
<source>Form</source>
<translation>Formulรกrio</translation>
</message>
<message>
<location line="+33"/>
<location line="+231"/>
<source>The displayed information may be out of date. Your wallet automatically synchronizes with the ReturnCoin 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>Carteira</translation>
</message>
<message>
<location line="+49"/>
<source>Spendable:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+16"/>
<source>Your current spendable balance</source>
<translation>O seu saldo disponรญvel para gastar</translation>
</message>
<message>
<location line="+71"/>
<source>Immature:</source>
<translation>Imaturo:</translation>
</message>
<message>
<location line="+13"/>
<source>Mined balance that has not yet matured</source>
<translation>O saldo minado ainda nรฃo maturou</translation>
</message>
<message>
<location line="+20"/>
<source>Total:</source>
<translation>Total:</translation>
</message>
<message>
<location line="+16"/>
<source>Your current total balance</source>
<translation>O seu saldo total actual</translation>
</message>
<message>
<location line="+46"/>
<source><b>Recent transactions</b></source>
<translation><b>Transaรงรตes recentes</b></translation>
</message>
<message>
<location line="-108"/>
<source>Total of transactions that have yet to be confirmed, and do not yet count toward the current balance</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-29"/>
<source>Total of coins that was staked, and do not yet count toward the current balance</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../overviewpage.cpp" line="+113"/>
<location line="+1"/>
<source>out of sync</source>
<translation>fora de sincronia</translation>
</message>
</context>
<context>
<name>QRCodeDialog</name>
<message>
<location filename="../forms/qrcodedialog.ui" line="+14"/>
<source>QR Code Dialog</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+59"/>
<source>Request Payment</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+56"/>
<source>Amount:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-44"/>
<source>Label:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+19"/>
<source>Message:</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+71"/>
<source>&Save As...</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../qrcodedialog.cpp" line="+62"/>
<source>Error encoding URI into QR Code.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+40"/>
<source>The entered amount is invalid, please check.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+23"/>
<source>Resulting URI too long, try to reduce the text for label / message.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+25"/>
<source>Save QR Code</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>PNG Images (*.png)</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>RPCConsole</name>
<message>
<location filename="../forms/rpcconsole.ui" line="+46"/>
<source>Client name</source>
<translation>Nome do Cliente</translation>
</message>
<message>
<location line="+10"/>
<location line="+23"/>
<location line="+26"/>
<location line="+23"/>
<location line="+23"/>
<location line="+36"/>
<location line="+53"/>
<location line="+23"/>
<location line="+23"/>
<location filename="../rpcconsole.cpp" line="+348"/>
<source>N/A</source>
<translation>N/D</translation>
</message>
<message>
<location line="-217"/>
<source>Client version</source>
<translation>Versรฃo do Cliente</translation>
</message>
<message>
<location line="-45"/>
<source>&Information</source>
<translation>&Informaรงรฃo</translation>
</message>
<message>
<location line="+68"/>
<source>Using OpenSSL version</source>
<translation>Usando versรฃo OpenSSL</translation>
</message>
<message>
<location line="+49"/>
<source>Startup time</source>
<translation>Tempo de inรญcio</translation>
</message>
<message>
<location line="+29"/>
<source>Network</source>
<translation>Rede</translation>
</message>
<message>
<location line="+7"/>
<source>Number of connections</source>
<translation>Nรบmero de ligaรงรตes</translation>
</message>
<message>
<location line="+23"/>
<source>On testnet</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+23"/>
<source>Block chain</source>
<translation>Cadeia de blocos</translation>
</message>
<message>
<location line="+7"/>
<source>Current number of blocks</source>
<translation>Nรบmero actual de blocos</translation>
</message>
<message>
<location line="+23"/>
<source>Estimated total blocks</source>
<translation>Total estimado de blocos</translation>
</message>
<message>
<location line="+23"/>
<source>Last block time</source>
<translation>Tempo do รบltimo bloco</translation>
</message>
<message>
<location line="+52"/>
<source>&Open</source>
<translation>&Abrir</translation>
</message>
<message>
<location line="+16"/>
<source>Command-line options</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+7"/>
<source>Show the returncoin-qt help message to get a list with possible ReturnCoin command-line options.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>&Show</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+24"/>
<source>&Console</source>
<translation>&Consola</translation>
</message>
<message>
<location line="-260"/>
<source>Build date</source>
<translation>Data de construรงรฃo</translation>
</message>
<message>
<location line="-104"/>
<source>ReturnCoin - Debug window</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+25"/>
<source>ReturnCoin Core</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+279"/>
<source>Debug log file</source>
<translation>Ficheiro de registo de depuraรงรฃo</translation>
</message>
<message>
<location line="+7"/>
<source>Open the ReturnCoin 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>Limpar consola</translation>
</message>
<message>
<location filename="../rpcconsole.cpp" line="-33"/>
<source>Welcome to the ReturnCoin RPC console.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Use up and down arrows to navigate history, and <b>Ctrl-L</b> to clear screen.</source>
<translation>Use as setas para cima e para baixo para navegar no histรณrico e <b>Ctrl-L</b> para limpar o ecrรฃ.</translation>
</message>
<message>
<location line="+1"/>
<source>Type <b>help</b> for an overview of available commands.</source>
<translation>Digite <b>help</b> para visualizar os comandos disponรญveis.</translation>
</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>Enviar Moedas</translation>
</message>
<message>
<location line="+76"/>
<source>Coin Control Features</source>
<translation>Funcionalidades de Coin Controlo:</translation>
</message>
<message>
<location line="+20"/>
<source>Inputs...</source>
<translation>Entradas</translation>
</message>
<message>
<location line="+7"/>
<source>automatically selected</source>
<translation>Selecรงรฃo automรกtica</translation>
</message>
<message>
<location line="+19"/>
<source>Insufficient funds!</source>
<translation>Fundos insuficientes!</translation>
</message>
<message>
<location line="+77"/>
<source>Quantity:</source>
<translation>Quantidade:</translation>
</message>
<message>
<location line="+22"/>
<location line="+35"/>
<source>0</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-19"/>
<source>Bytes:</source>
<translation>Bytes:</translation>
</message>
<message>
<location line="+51"/>
<source>Amount:</source>
<translation>Quantia:</translation>
</message>
<message>
<location line="+22"/>
<location line="+86"/>
<location line="+86"/>
<location line="+32"/>
<source>0.00 hack</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-191"/>
<source>Priority:</source>
<translation>Prioridade:</translation>
</message>
<message>
<location line="+19"/>
<source>medium</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+32"/>
<source>Fee:</source>
<translation>Taxa:</translation>
</message>
<message>
<location line="+35"/>
<source>Low Output:</source>
<translation>Output Baixo:</translation>
</message>
<message>
<location line="+19"/>
<source>no</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+32"/>
<source>After Fee:</source>
<translation>Depois de taxas:</translation>
</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>Enviar para mรบltiplos destinatรกrios de uma vez</translation>
</message>
<message>
<location line="+3"/>
<source>Add &Recipient</source>
<translation>Adicionar &Destinatรกrio</translation>
</message>
<message>
<location line="+20"/>
<source>Remove all transaction fields</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+3"/>
<source>Clear &All</source>
<translation>&Limpar Tudo</translation>
</message>
<message>
<location line="+28"/>
<source>Balance:</source>
<translation>Saldo:</translation>
</message>
<message>
<location line="+16"/>
<source>123.456 hack</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+31"/>
<source>Confirm the send action</source>
<translation>Confirme aรงรฃo de envio</translation>
</message>
<message>
<location line="+3"/>
<source>S&end</source>
<translation>&Enviar</translation>
</message>
<message>
<location filename="../sendcoinsdialog.cpp" line="-173"/>
<source>Enter a ReturnCoin address (e.g. PXkRZYXwNDxsgvMmtE3M7rXJKDohbf54Pm)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+15"/>
<source>Copy quantity</source>
<translation>Copiar quantidade</translation>
</message>
<message>
<location line="+1"/>
<source>Copy amount</source>
<translation>Copiar quantia</translation>
</message>
<message>
<location line="+1"/>
<source>Copy fee</source>
<translation>Taxa de cรณpia</translation>
</message>
<message>
<location line="+1"/>
<source>Copy after fee</source>
<translation>Taxa depois de cรณpia</translation>
</message>
<message>
<location line="+1"/>
<source>Copy bytes</source>
<translation>Copiar bytes</translation>
</message>
<message>
<location line="+1"/>
<source>Copy priority</source>
<translation>Prioridade de Cรณpia</translation>
</message>
<message>
<location line="+1"/>
<source>Copy low output</source>
<translation>Copiar output baixo</translation>
</message>
<message>
<location line="+1"/>
<source>Copy change</source>
<translation>Copiar alteraรงรฃo</translation>
</message>
<message>
<location line="+86"/>
<source><b>%1</b> to %2 (%3)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+5"/>
<source>Confirm send coins</source>
<translation>Confirme envio de moedas</translation>
</message>
<message>
<location line="+1"/>
<source>Are you sure you want to send %1?</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source> and </source>
<translation type="unfinished"/>
</message>
<message>
<location line="+29"/>
<source>The recipient address is not valid, please recheck.</source>
<translation>O endereรงo de destino nรฃo รฉ vรกlido, por favor verifique.</translation>
</message>
<message>
<location line="+5"/>
<source>The amount to pay must be larger than 0.</source>
<translation>A quantia a pagar deverรก ser maior que 0.</translation>
</message>
<message>
<location line="+5"/>
<source>The amount exceeds your balance.</source>
<translation>A quantia excede o seu saldo.</translation>
</message>
<message>
<location line="+5"/>
<source>The total exceeds your balance when the %1 transaction fee is included.</source>
<translation>O total excede o seu saldo quando a taxa de transaรงรฃo de %1 for incluรญda.</translation>
</message>
<message>
<location line="+6"/>
<source>Duplicate address found, can only send to each address once per send operation.</source>
<translation>Endereรงo duplicado encontrado, apenas poderรก enviar uma vez para cada endereรงo por cada operaรงรฃo de envio.</translation>
</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 ReturnCoin address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+13"/>
<source>(no label)</source>
<translation>(Sem rรณtulo)</translation>
</message>
<message>
<location line="+4"/>
<source>WARNING: unknown change address</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>SendCoinsEntry</name>
<message>
<location filename="../forms/sendcoinsentry.ui" line="+14"/>
<source>Form</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+15"/>
<source>A&mount:</source>
<translation>Qu&antia:</translation>
</message>
<message>
<location line="+13"/>
<source>Pay &To:</source>
<translation>&Pagar A:</translation>
</message>
<message>
<location line="+24"/>
<location filename="../sendcoinsentry.cpp" line="+25"/>
<source>Enter a label for this address to add it to your address book</source>
<translation>Escreva um rรณtulo para este endereรงo para o adicionar ao seu livro de endereรงos</translation>
</message>
<message>
<location line="+9"/>
<source>&Label:</source>
<translation>Rรณtu&lo:</translation>
</message>
<message>
<location line="+18"/>
<source>The address to send the payment to (e.g. PXkRZYXwNDxsgvMmtE3M7rXJKDohbf54Pm)</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>Cole endereรงo da รกrea de transferรชncia</translation>
</message>
<message>
<location line="+10"/>
<source>Alt+P</source>
<translation>Alt+P</translation>
</message>
<message>
<location line="+7"/>
<source>Remove this recipient</source>
<translation type="unfinished"/>
</message>
<message>
<location filename="../sendcoinsentry.cpp" line="+1"/>
<source>Enter a ReturnCoin address (e.g. PXkRZYXwNDxsgvMmtE3M7rXJKDohbf54Pm)</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>Assinaturas - Assinar / Verificar uma Mensagem</translation>
</message>
<message>
<location line="+13"/>
<location line="+124"/>
<source>&Sign Message</source>
<translation>A&ssinar Mensagem</translation>
</message>
<message>
<location line="-118"/>
<source>You can sign messages with your addresses to prove you own them. Be careful not to sign anything vague, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to.</source>
<translation>Pode assinar mensagens com os seus endereรงos para provar que sรฃo seus. Tenha atenรงรฃo ao assinar mensagens ambรญguas, pois ataques de phishing podem tentar enganรก-lo, de modo a assinar a sua identidade para os atacantes. Apenas assine declaraรงรตes completamente detalhadas com as quais concorde.</translation>
</message>
<message>
<location line="+18"/>
<source>The address to sign the message with (e.g. PXkRZYXwNDxsgvMmtE3M7rXJKDohbf54Pm)</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>Cole endereรงo da รกrea de transferรชncia</translation>
</message>
<message>
<location line="+10"/>
<source>Alt+P</source>
<translation>Alt+P</translation>
</message>
<message>
<location line="+12"/>
<source>Enter the message you want to sign here</source>
<translation>Escreva aqui a mensagem que deseja assinar</translation>
</message>
<message>
<location line="+24"/>
<source>Copy the current signature to the system clipboard</source>
<translation>Copiar a assinatura actual para a รกrea de transferรชncia</translation>
</message>
<message>
<location line="+21"/>
<source>Sign the message to prove you own this ReturnCoin address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+17"/>
<source>Reset all sign message fields</source>
<translation>Repรดr todos os campos de assinatura de mensagem</translation>
</message>
<message>
<location line="+3"/>
<location line="+146"/>
<source>Clear &All</source>
<translation>Limpar &Tudo</translation>
</message>
<message>
<location line="-87"/>
<location line="+70"/>
<source>&Verify Message</source>
<translation>&Verificar Mensagem</translation>
</message>
<message>
<location line="-64"/>
<source>Enter the signing address, message (ensure you copy line breaks, spaces, tabs, etc. exactly) and signature below to verify the message. Be careful not to read more into the signature than what is in the signed message itself, to avoid being tricked by a man-in-the-middle attack.</source>
<translation>Introduza o endereรงo de assinatura, mensagem (assegure-se de copiar quebras de linha, espaรงos, tabuladores, etc. exactamente) e assinatura abaixo para verificar a mensagem. Tenha atenรงรฃo para nรฃo ler mais na assinatura do que o que estiver na mensagem assinada, para evitar ser enganado por um atacante que se encontre entre si e quem assinou a mensagem.</translation>
</message>
<message>
<location line="+21"/>
<source>The address the message was signed with (e.g. PXkRZYXwNDxsgvMmtE3M7rXJKDohbf54Pm)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+40"/>
<source>Verify the message to ensure it was signed with the specified ReturnCoin address</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+17"/>
<source>Reset all verify message fields</source>
<translation>Repรดr todos os campos de verificaรงรฃo de mensagem</translation>
</message>
<message>
<location filename="../signverifymessagedialog.cpp" line="+27"/>
<location line="+3"/>
<source>Enter a ReturnCoin address (e.g. PXkRZYXwNDxsgvMmtE3M7rXJKDohbf54Pm)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-2"/>
<source>Click "Sign Message" to generate signature</source>
<translation>Clique "Assinar mensagem" para gerar a assinatura</translation>
</message>
<message>
<location line="+3"/>
<source>Enter ReturnCoin signature</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+82"/>
<location line="+81"/>
<source>The entered address is invalid.</source>
<translation>O endereรงo introduzido รฉ invรกlido. </translation>
</message>
<message>
<location line="-81"/>
<location line="+8"/>
<location line="+73"/>
<location line="+8"/>
<source>Please check the address and try again.</source>
<translation>Por favor verifique o endereรงo e tente de novo.</translation>
</message>
<message>
<location line="-81"/>
<location line="+81"/>
<source>The entered address does not refer to a key.</source>
<translation>O endereรงo introduzido nรฃo refere a chave alguma.</translation>
</message>
<message>
<location line="-73"/>
<source>Wallet unlock was cancelled.</source>
<translation>O desbloqueio da carteira foi cancelado.</translation>
</message>
<message>
<location line="+8"/>
<source>Private key for the entered address is not available.</source>
<translation>A chave privada para o endereรงo introduzido nรฃo estรก disponรญvel.</translation>
</message>
<message>
<location line="+12"/>
<source>Message signing failed.</source>
<translation>Assinatura de mensagem falhou.</translation>
</message>
<message>
<location line="+5"/>
<source>Message signed.</source>
<translation>Mensagem assinada.</translation>
</message>
<message>
<location line="+59"/>
<source>The signature could not be decoded.</source>
<translation>A assinatura nรฃo pรดde ser descodificada.</translation>
</message>
<message>
<location line="+0"/>
<location line="+13"/>
<source>Please check the signature and try again.</source>
<translation>Por favor verifique a assinatura e tente de novo.</translation>
</message>
<message>
<location line="+0"/>
<source>The signature did not match the message digest.</source>
<translation>A assinatura nรฃo condiz com o conteรบdo da mensagem.</translation>
</message>
<message>
<location line="+7"/>
<source>Message verification failed.</source>
<translation>Verificaรงรฃo da mensagem falhou.</translation>
</message>
<message>
<location line="+5"/>
<source>Message verified.</source>
<translation>Mensagem verificada.</translation>
</message>
</context>
<context>
<name>TransactionDesc</name>
<message>
<location filename="../transactiondesc.cpp" line="+19"/>
<source>Open until %1</source>
<translation>Aberto atรฉ %1</translation>
</message>
<message numerus="yes">
<location line="-2"/>
<source>Open for %n block(s)</source>
<translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation>
</message>
<message>
<location line="+8"/>
<source>conflicted</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>%1/offline</source>
<translation>%1/desligado</translation>
</message>
<message>
<location line="+2"/>
<source>%1/unconfirmed</source>
<translation>%1/nรฃo confirmada</translation>
</message>
<message>
<location line="+2"/>
<source>%1 confirmations</source>
<translation>%1 confirmaรงรตes</translation>
</message>
<message>
<location line="+18"/>
<source>Status</source>
<translation>Estado</translation>
</message>
<message numerus="yes">
<location line="+7"/>
<source>, broadcast through %n node(s)</source>
<translation><numerusform>, transmitida atravรฉs de %n nรณ</numerusform><numerusform>, transmitida atravรฉs de %n nรณs</numerusform></translation>
</message>
<message>
<location line="+4"/>
<source>Date</source>
<translation>Data</translation>
</message>
<message>
<location line="+7"/>
<source>Source</source>
<translation>Origem</translation>
</message>
<message>
<location line="+0"/>
<source>Generated</source>
<translation>Gerado</translation>
</message>
<message>
<location line="+5"/>
<location line="+17"/>
<source>From</source>
<translation>De</translation>
</message>
<message>
<location line="+1"/>
<location line="+22"/>
<location line="+58"/>
<source>To</source>
<translation>Para</translation>
</message>
<message>
<location line="-77"/>
<location line="+2"/>
<source>own address</source>
<translation>endereรงo prรณprio</translation>
</message>
<message>
<location line="-2"/>
<source>label</source>
<translation>rรณtulo</translation>
</message>
<message>
<location line="+37"/>
<location line="+12"/>
<location line="+45"/>
<location line="+17"/>
<location line="+30"/>
<source>Credit</source>
<translation>Crรฉdito</translation>
</message>
<message numerus="yes">
<location line="-102"/>
<source>matures in %n more block(s)</source>
<translation><numerusform>matura daqui por %n bloco</numerusform><numerusform>matura daqui por %n blocos</numerusform></translation>
</message>
<message>
<location line="+2"/>
<source>not accepted</source>
<translation>nรฃo aceite</translation>
</message>
<message>
<location line="+44"/>
<location line="+8"/>
<location line="+15"/>
<location line="+30"/>
<source>Debit</source>
<translation>Dรฉbito</translation>
</message>
<message>
<location line="-39"/>
<source>Transaction fee</source>
<translation>Taxa de transaรงรฃo</translation>
</message>
<message>
<location line="+16"/>
<source>Net amount</source>
<translation>Valor lรญquido</translation>
</message>
<message>
<location line="+6"/>
<source>Message</source>
<translation>Mensagem</translation>
</message>
<message>
<location line="+2"/>
<source>Comment</source>
<translation>Comentรกrio</translation>
</message>
<message>
<location line="+2"/>
<source>Transaction ID</source>
<translation>ID da Transaรงรฃo</translation>
</message>
<message>
<location line="+3"/>
<source>Generated coins must mature 510 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to "not accepted" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+7"/>
<source>Debug information</source>
<translation>Informaรงรฃo de depuraรงรฃo</translation>
</message>
<message>
<location line="+8"/>
<source>Transaction</source>
<translation>Transaรงรฃo</translation>
</message>
<message>
<location line="+5"/>
<source>Inputs</source>
<translation>Entradas</translation>
</message>
<message>
<location line="+23"/>
<source>Amount</source>
<translation>Quantia</translation>
</message>
<message>
<location line="+1"/>
<source>true</source>
<translation>verdadeiro</translation>
</message>
<message>
<location line="+0"/>
<source>false</source>
<translation>falso</translation>
</message>
<message>
<location line="-211"/>
<source>, has not been successfully broadcast yet</source>
<translation>, ainda nรฃo foi transmitida com sucesso</translation>
</message>
<message>
<location line="+35"/>
<source>unknown</source>
<translation>desconhecido</translation>
</message>
</context>
<context>
<name>TransactionDescDialog</name>
<message>
<location filename="../forms/transactiondescdialog.ui" line="+14"/>
<source>Transaction details</source>
<translation>Detalhes da transaรงรฃo</translation>
</message>
<message>
<location line="+6"/>
<source>This pane shows a detailed description of the transaction</source>
<translation>Esta janela mostra uma descriรงรฃo detalhada da transaรงรฃo</translation>
</message>
</context>
<context>
<name>TransactionTableModel</name>
<message>
<location filename="../transactiontablemodel.cpp" line="+226"/>
<source>Date</source>
<translation>Data</translation>
</message>
<message>
<location line="+0"/>
<source>Type</source>
<translation>Tipo</translation>
</message>
<message>
<location line="+0"/>
<source>Address</source>
<translation>Endereรงo</translation>
</message>
<message>
<location line="+0"/>
<source>Amount</source>
<translation>Quantia</translation>
</message>
<message>
<location line="+60"/>
<source>Open until %1</source>
<translation>Aberto atรฉ %1</translation>
</message>
<message>
<location line="+12"/>
<source>Confirmed (%1 confirmations)</source>
<translation>Confirmada (%1 confirmaรงรตes)</translation>
</message>
<message numerus="yes">
<location line="-15"/>
<source>Open for %n more block(s)</source>
<translation><numerusform>Aberta por mais %n bloco</numerusform><numerusform>Aberta por mais %n blocos</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>Este bloco nรฃo foi recebido por outros nรณs e provavelmente nรฃo serรก aceite pela rede!</translation>
</message>
<message>
<location line="+3"/>
<source>Generated but not accepted</source>
<translation>Gerado mas nรฃo aceite</translation>
</message>
<message>
<location line="+42"/>
<source>Received with</source>
<translation>Recebido com</translation>
</message>
<message>
<location line="+2"/>
<source>Received from</source>
<translation>Recebido de</translation>
</message>
<message>
<location line="+3"/>
<source>Sent to</source>
<translation>Enviado para</translation>
</message>
<message>
<location line="+2"/>
<source>Payment to yourself</source>
<translation>Pagamento ao prรณprio</translation>
</message>
<message>
<location line="+2"/>
<source>Mined</source>
<translation>Minadas</translation>
</message>
<message>
<location line="+38"/>
<source>(n/a)</source>
<translation>(n/d)</translation>
</message>
<message>
<location line="+190"/>
<source>Transaction status. Hover over this field to show number of confirmations.</source>
<translation>Estado da transaรงรฃo. Pairar por cima deste campo para mostrar o nรบmero de confirmaรงรตes.</translation>
</message>
<message>
<location line="+2"/>
<source>Date and time that the transaction was received.</source>
<translation>Data e hora a que esta transaรงรฃo foi recebida.</translation>
</message>
<message>
<location line="+2"/>
<source>Type of transaction.</source>
<translation>Tipo de transaรงรฃo.</translation>
</message>
<message>
<location line="+2"/>
<source>Destination address of transaction.</source>
<translation>Endereรงo de destino da transaรงรฃo.</translation>
</message>
<message>
<location line="+2"/>
<source>Amount removed from or added to balance.</source>
<translation>Quantia retirada ou adicionada ao saldo.</translation>
</message>
</context>
<context>
<name>TransactionView</name>
<message>
<location filename="../transactionview.cpp" line="+55"/>
<location line="+16"/>
<source>All</source>
<translation>Todas</translation>
</message>
<message>
<location line="-15"/>
<source>Today</source>
<translation>Hoje</translation>
</message>
<message>
<location line="+1"/>
<source>This week</source>
<translation>Esta semana</translation>
</message>
<message>
<location line="+1"/>
<source>This month</source>
<translation>Este mรชs</translation>
</message>
<message>
<location line="+1"/>
<source>Last month</source>
<translation>Mรชs passado</translation>
</message>
<message>
<location line="+1"/>
<source>This year</source>
<translation>Este ano</translation>
</message>
<message>
<location line="+1"/>
<source>Range...</source>
<translation>Perรญodo...</translation>
</message>
<message>
<location line="+11"/>
<source>Received with</source>
<translation>Recebida com</translation>
</message>
<message>
<location line="+2"/>
<source>Sent to</source>
<translation>Enviada para</translation>
</message>
<message>
<location line="+2"/>
<source>To yourself</source>
<translation>Para si</translation>
</message>
<message>
<location line="+1"/>
<source>Mined</source>
<translation>Minadas</translation>
</message>
<message>
<location line="+1"/>
<source>Other</source>
<translation>Outras</translation>
</message>
<message>
<location line="+7"/>
<source>Enter address or label to search</source>
<translation>Escreva endereรงo ou rรณtulo a procurar</translation>
</message>
<message>
<location line="+7"/>
<source>Min amount</source>
<translation>Quantia mรญnima</translation>
</message>
<message>
<location line="+34"/>
<source>Copy address</source>
<translation>Copiar endereรงo</translation>
</message>
<message>
<location line="+1"/>
<source>Copy label</source>
<translation>Copiar rรณtulo</translation>
</message>
<message>
<location line="+1"/>
<source>Copy amount</source>
<translation>Copiar quantia</translation>
</message>
<message>
<location line="+1"/>
<source>Copy transaction ID</source>
<translation>Copiar ID da Transaรงรฃo</translation>
</message>
<message>
<location line="+1"/>
<source>Edit label</source>
<translation>Editar rรณtulo</translation>
</message>
<message>
<location line="+1"/>
<source>Show transaction details</source>
<translation>Mostrar detalhes da transaรงรฃo</translation>
</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>Ficheiro separado por vรญrgula (*.csv)</translation>
</message>
<message>
<location line="+8"/>
<source>Confirmed</source>
<translation>Confirmada</translation>
</message>
<message>
<location line="+1"/>
<source>Date</source>
<translation>Data</translation>
</message>
<message>
<location line="+1"/>
<source>Type</source>
<translation>Tipo</translation>
</message>
<message>
<location line="+1"/>
<source>Label</source>
<translation>Rรณtulo</translation>
</message>
<message>
<location line="+1"/>
<source>Address</source>
<translation>Endereรงo</translation>
</message>
<message>
<location line="+1"/>
<source>Amount</source>
<translation>Quantia</translation>
</message>
<message>
<location line="+1"/>
<source>ID</source>
<translation>ID</translation>
</message>
<message>
<location line="+4"/>
<source>Error exporting</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+0"/>
<source>Could not write to file %1.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+100"/>
<source>Range:</source>
<translation>Perรญodo:</translation>
</message>
<message>
<location line="+8"/>
<source>to</source>
<translation>atรฉ</translation>
</message>
</context>
<context>
<name>WalletModel</name>
<message>
<location filename="../walletmodel.cpp" line="+206"/>
<source>Sending...</source>
<translation type="unfinished"/>
</message>
</context>
<context>
<name>bitcoin-core</name>
<message>
<location filename="../bitcoinstrings.cpp" line="+33"/>
<source>ReturnCoin version</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Usage:</source>
<translation>Utilizaรงรฃo:</translation>
</message>
<message>
<location line="+1"/>
<source>Send command to -server or returncoind</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>List commands</source>
<translation>Listar comandos</translation>
</message>
<message>
<location line="+1"/>
<source>Get help for a command</source>
<translation>Obter ajuda para um comando</translation>
</message>
<message>
<location line="+2"/>
<source>Options:</source>
<translation>Opรงรตes:</translation>
</message>
<message>
<location line="+2"/>
<source>Specify configuration file (default: ReturnCoin.conf)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Specify pid file (default: returncoind.pid)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Specify wallet file (within data directory)</source>
<translation>Especifique ficheiro de carteira (dentro da pasta de dados)</translation>
</message>
<message>
<location line="-1"/>
<source>Specify data directory</source>
<translation>Especificar pasta de dados</translation>
</message>
<message>
<location line="+2"/>
<source>Set database cache size in megabytes (default: 25)</source>
<translation>Definir o tamanho da cache de base de dados em megabytes (por defeito: 25)</translation>
</message>
<message>
<location line="+1"/>
<source>Set database disk log size in megabytes (default: 100)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+6"/>
<source>Listen for connections on <port> (default: 15714 or testnet: 25714)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Maintain at most <n> connections to peers (default: 125)</source>
<translation>Manter no mรกximo <n> ligaรงรตes a outros nรณs da rede (por defeito: 125)</translation>
</message>
<message>
<location line="+3"/>
<source>Connect to a node to retrieve peer addresses, and disconnect</source>
<translation>Ligar a um nรณ para recuperar endereรงos de pares, e desligar</translation>
</message>
<message>
<location line="+1"/>
<source>Specify your own public address</source>
<translation>Especifique o seu endereรงo pรบblico</translation>
</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>Tolerรขncia para desligar nรณs mal-formados (por defeito: 100)</translation>
</message>
<message>
<location line="+1"/>
<source>Number of seconds to keep misbehaving peers from reconnecting (default: 86400)</source>
<translation>Nรบmero de segundos a impedir que nรณs mal-formados se liguem de novo (por defeito: 86400)</translation>
</message>
<message>
<location line="-44"/>
<source>An error occurred while setting up the RPC port %u for listening on IPv4: %s</source>
<translation>Ocorreu um erro ao definir a porta %u do serviรงo RPC a escutar em IPv4: %s</translation>
</message>
<message>
<location line="+51"/>
<source>Detach block and address databases. Increases shutdown time (default: 0)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+109"/>
<source>Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-5"/>
<source>Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds </source>
<translation type="unfinished"/>
</message>
<message>
<location line="-87"/>
<source>Listen for JSON-RPC connections on <port> (default: 15715 or testnet: 25715)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-11"/>
<source>Accept command line and JSON-RPC commands</source>
<translation>Aceitar comandos da consola e JSON-RPC</translation>
</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>Correr o processo como um daemon e aceitar comandos</translation>
</message>
<message>
<location line="+1"/>
<source>Use the test network</source>
<translation>Utilizar a rede de testes - testnet</translation>
</message>
<message>
<location line="-24"/>
<source>Accept connections from outside (default: 1 if no -proxy or -connect)</source>
<translation>Aceitar ligaรงรตes externas (padrรฃo: 1 sem -proxy ou -connect)</translation>
</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>Ocorreu um erro ao definir a porta %u do serviรงo RPC a escutar em IPv6, a usar IPv4: %s</translation>
</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>Atenรงรฃo: -paytxfee estรก definida com um valor muito alto! Esta รฉ a taxa que irรก pagar se enviar uma transaรงรฃo.</translation>
</message>
<message>
<location line="+61"/>
<source>Warning: Please check that your computer's date and time are correct! If your clock is wrong ReturnCoin 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>Atenรงรฃo: erro ao ler wallet.dat! Todas as chaves foram lidas correctamente, mas dados de transaรงรฃo ou do livro de endereรงos podem estar em falta ou incorrectos.</translation>
</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>Atenรงรฃo: wallet.dat corrupto, dados recuperados! wallet.dat original salvo como wallet.{timestamp}.bak em %s; se o seu saldo ou transaรงรตes estiverem incorrectos deverรก recuperar de uma cรณpia de seguranรงa.</translation>
</message>
<message>
<location line="-30"/>
<source>Attempt to recover private keys from a corrupt wallet.dat</source>
<translation>Tentar recuperar chaves privadas de um wallet.dat corrupto</translation>
</message>
<message>
<location line="+4"/>
<source>Block creation options:</source>
<translation>Opรงรตes de criaรงรฃo de bloco:</translation>
</message>
<message>
<location line="-62"/>
<source>Connect only to the specified node(s)</source>
<translation>Apenas ligar ao(s) nรณ(s) especificado(s)</translation>
</message>
<message>
<location line="+4"/>
<source>Discover own IP address (default: 1 when listening and no -externalip)</source>
<translation>Descobrir endereรงo IP prรณprio (padrรฃo: 1 ao escutar e sem -externalip)</translation>
</message>
<message>
<location line="+94"/>
<source>Failed to listen on any port. Use -listen=0 if you want this.</source>
<translation>Falhou a escutar em qualquer porta. Use -listen=0 se quer isto.</translation>
</message>
<message>
<location line="-90"/>
<source>Find peers using DNS lookup (default: 1)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+5"/>
<source>Sync checkpoints policy (default: strict)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+83"/>
<source>Invalid -tor address: '%s'</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+4"/>
<source>Invalid amount for -reservebalance=<amount></source>
<translation type="unfinished"/>
</message>
<message>
<location line="-82"/>
<source>Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)</source>
<translation>Armazenamento intermรฉdio de recepรงรฃo por ligaรงรฃo, <n>*1000 bytes (por defeito: 5000)</translation>
</message>
<message>
<location line="+1"/>
<source>Maximum per-connection send buffer, <n>*1000 bytes (default: 1000)</source>
<translation>Armazenamento intermรฉdio de envio por ligaรงรฃo, <n>*1000 bytes (por defeito: 1000)</translation>
</message>
<message>
<location line="-16"/>
<source>Only connect to nodes in network <net> (IPv4, IPv6 or Tor)</source>
<translation>Apenas ligar a nรณs na rede <net> (IPv4, IPv6 ou Tor)</translation>
</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>Opรงรตes SSL: (ver a Wiki Bitcoin para instruรงรตes de configuraรงรฃo SSL)</translation>
</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>Enviar informaรงรฃo de rastreio/depuraรงรฃo para a consola e nรฃo para o ficheiro debug.log</translation>
</message>
<message>
<location line="+1"/>
<source>Send trace/debug info to debugger</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+28"/>
<source>Set maximum block size in bytes (default: 250000)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-1"/>
<source>Set minimum block size in bytes (default: 0)</source>
<translation>Definir tamanho minรญmo de um bloco em bytes (por defeito: 0)</translation>
</message>
<message>
<location line="-29"/>
<source>Shrink debug.log file on client startup (default: 1 when no -debug)</source>
<translation>Encolher ficheiro debug.log ao iniciar o cliente (por defeito: 1 sem -debug definido)</translation>
</message>
<message>
<location line="-42"/>
<source>Specify connection timeout in milliseconds (default: 5000)</source>
<translation>Especificar tempo de espera da ligaรงรฃo em millisegundos (por defeito: 5000)</translation>
</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>Usar UPnP para mapear a porta de escuta (padrรฃo: 0)</translation>
</message>
<message>
<location line="-1"/>
<source>Use UPnP to map the listening port (default: 1 when listening)</source>
<translation>Usar UPnP para mapear a porta de escuta (padrรฃo: 1 ao escutar)</translation>
</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>Nome de utilizador para ligaรงรตes JSON-RPC</translation>
</message>
<message>
<location line="+47"/>
<source>Verifying database integrity...</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+57"/>
<source>WARNING: syncronized checkpoint violation detected, but skipped!</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Warning: Disk space is low!</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-2"/>
<source>Warning: This version is obsolete, upgrade required!</source>
<translation>Atenรงรฃo: Esta versรฃo estรก obsoleta, รฉ necessรกrio actualizar!</translation>
</message>
<message>
<location line="-48"/>
<source>wallet.dat corrupt, salvage failed</source>
<translation>wallet.dat corrupta, recuperaรงรฃo falhou</translation>
</message>
<message>
<location line="-54"/>
<source>Password for JSON-RPC connections</source>
<translation>Palavra-passe para ligaรงรตes JSON-RPC</translation>
</message>
<message>
<location line="-84"/>
<source>%s, you must set a rpcpassword in the configuration file:
%s
It is recommended you use the following random password:
rpcuser=ReturnCoinrpc
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 "ReturnCoin Alert" [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>Permitir ligaรงรตes JSON-RPC do endereรงo IP especificado</translation>
</message>
<message>
<location line="+1"/>
<source>Send commands to node running on <ip> (default: 127.0.0.1)</source>
<translation>Enviar comandos para o nรณ a correr em <ip> (por defeito: 127.0.0.1)</translation>
</message>
<message>
<location line="+1"/>
<source>Execute command when the best block changes (%s in cmd is replaced by block hash)</source>
<translation>Executar comando quando mudar o melhor bloco (no comando, %s รฉ substituรญdo pela hash do bloco)</translation>
</message>
<message>
<location line="+3"/>
<source>Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)</source>
<translation>Executar comando quando uma das transaรงรตes na carteira mudar (no comando, %s รฉ substituรญdo pelo ID da Transaรงรฃo)</translation>
</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>Atualize a carteira para o formato mais recente</translation>
</message>
<message>
<location line="+1"/>
<source>Set key pool size to <n> (default: 100)</source>
<translation>Definir o tamanho da memรณria de chaves para <n> (por defeito: 100)</translation>
</message>
<message>
<location line="+1"/>
<source>Rescan the block chain for missing wallet transactions</source>
<translation>Reexaminar a cadeia de blocos para transaรงรตes em falta na carteira</translation>
</message>
<message>
<location line="+2"/>
<source>How many blocks to check at startup (default: 2500, 0 = all)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>How thorough the block verification is (0-6, default: 1)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Imports blocks from external blk000?.dat file</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+8"/>
<source>Use OpenSSL (https) for JSON-RPC connections</source>
<translation>Usar OpenSSL (https) para ligaรงรตes JSON-RPC</translation>
</message>
<message>
<location line="+1"/>
<source>Server certificate file (default: server.cert)</source>
<translation>Ficheiro de certificado do servidor (por defeito: server.cert)</translation>
</message>
<message>
<location line="+1"/>
<source>Server private key (default: server.pem)</source>
<translation>Chave privada do servidor (por defeito: server.pem)</translation>
</message>
<message>
<location line="+1"/>
<source>Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+53"/>
<source>Error: Wallet unlocked for staking only, unable to create transaction.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+18"/>
<source>WARNING: Invalid checkpoint found! Displayed transactions may not be correct! You may need to upgrade, or notify developers.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-158"/>
<source>This help message</source>
<translation>Esta mensagem de ajuda</translation>
</message>
<message>
<location line="+95"/>
<source>Wallet %s resides outside data directory %s.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Cannot obtain a lock on data directory %s. ReturnCoin is probably already running.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-98"/>
<source>ReturnCoin</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>Incapaz de vincular a %s neste computador (vรญnculo retornou erro %d, %s)</translation>
</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>Permitir procuras DNS para -addnode, -seednode e -connect</translation>
</message>
<message>
<location line="+122"/>
<source>Loading addresses...</source>
<translation>Carregar endereรงos...</translation>
</message>
<message>
<location line="-15"/>
<source>Error loading blkindex.dat</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+2"/>
<source>Error loading wallet.dat: Wallet corrupted</source>
<translation>Erro ao carregar wallet.dat: Carteira danificada</translation>
</message>
<message>
<location line="+4"/>
<source>Error loading wallet.dat: Wallet requires newer version of ReturnCoin</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Wallet needed to be rewritten: restart ReturnCoin to complete</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+1"/>
<source>Error loading wallet.dat</source>
<translation>Erro ao carregar wallet.dat</translation>
</message>
<message>
<location line="-16"/>
<source>Invalid -proxy address: '%s'</source>
<translation>Endereรงo -proxy invรกlido: '%s'</translation>
</message>
<message>
<location line="-1"/>
<source>Unknown network specified in -onlynet: '%s'</source>
<translation>Rede desconhecida especificada em -onlynet: '%s'</translation>
</message>
<message>
<location line="-1"/>
<source>Unknown -socks proxy version requested: %i</source>
<translation>Versรฃo desconhecida de proxy -socks requisitada: %i</translation>
</message>
<message>
<location line="+4"/>
<source>Cannot resolve -bind address: '%s'</source>
<translation>Nรฃo conseguiu resolver endereรงo -bind: '%s'</translation>
</message>
<message>
<location line="+2"/>
<source>Cannot resolve -externalip address: '%s'</source>
<translation>Nรฃo conseguiu resolver endereรงo -externalip: '%s'</translation>
</message>
<message>
<location line="-24"/>
<source>Invalid amount for -paytxfee=<amount>: '%s'</source>
<translation>Quantia invรกlida para -paytxfee=<amount>: '%s'</translation>
</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>Quantia invรกlida</translation>
</message>
<message>
<location line="+1"/>
<source>Insufficient funds</source>
<translation>Fundos insuficientes</translation>
</message>
<message>
<location line="-34"/>
<source>Loading block index...</source>
<translation>Carregar รญndice de blocos...</translation>
</message>
<message>
<location line="-103"/>
<source>Add a node to connect to and attempt to keep the connection open</source>
<translation>Adicione um nรณ ao qual se ligar e tentar manter a ligaรงรฃo aberta</translation>
</message>
<message>
<location line="+122"/>
<source>Unable to bind to %s on this computer. ReturnCoin is probably already running.</source>
<translation type="unfinished"/>
</message>
<message>
<location line="-97"/>
<source>Fee per KB to add to transactions you send</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+55"/>
<source>Invalid amount for -mininput=<amount>: '%s'</source>
<translation type="unfinished"/>
</message>
<message>
<location line="+25"/>
<source>Loading wallet...</source>
<translation>Carregar carteira...</translation>
</message>
<message>
<location line="+8"/>
<source>Cannot downgrade wallet</source>
<translation>Impossรญvel mudar a carteira para uma versรฃo anterior</translation>
</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>Impossรญvel escrever endereรงo por defeito</translation>
</message>
<message>
<location line="+1"/>
<source>Rescanning...</source>
<translation>Reexaminando...</translation>
</message>
<message>
<location line="+5"/>
<source>Done loading</source>
<translation>Carregamento completo</translation>
</message>
<message>
<location line="-167"/>
<source>To use the %s option</source>
<translation>Para usar a opรงรฃo %s</translation>
</message>
<message>
<location line="+14"/>
<source>Error</source>
<translation>Erro</translation>
</message>
<message>
<location line="+6"/>
<source>You must set rpcpassword=<password> in the configuration file:
%s
If the file does not exist, create it with owner-readable-only file permissions.</source>
<translation>Deverรก definir rpcpassword=<password> no ficheiro de configuraรงรฃo:
%s
Se o ficheiro nรฃo existir, crie-o com permissรตes de leitura apenas para o dono.</translation>
</message>
</context>
</TS> | ReturnCoin/ReturnCoin | src/qt/locale/bitcoin_pt_PT.ts | TypeScript | mit | 119,402 |
//
// JavaInterfaceManager.h
// ChilliSource
// Created by Ian Copland on 08/08/2012.
//
// The MIT License (MIT)
//
// Copyright (c) 2012 Tag Games Limited
//
// 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.
//
#ifdef CS_TARGETPLATFORM_ANDROID
#ifndef _CHILLISOURCE_PLATFORM_ANDROID_JAVAINTERFACE_JAVAINTERFACEMANAGER_H_
#define _CHILLISOURCE_PLATFORM_ANDROID_JAVAINTERFACE_JAVAINTERFACEMANAGER_H_
#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>
#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.h>
#include <jni.h>
namespace CSBackend
{
namespace Android
{
//========================================================
/// Java Interface Manager
///
/// Handles all of the java interfaces and provides an
/// interface to access them.
///
/// This is deprecated in favour of JavaClass and
/// JavaVirtualMachine
//========================================================
class JavaInterfaceManager
{
public:
//--------------------------------------------------------
/// Get Singleton Ptr
///
/// @return a pointer to the singleton instance.
//--------------------------------------------------------
static JavaInterfaceManager* GetSingletonPtr();
//--------------------------------------------------------
/// Get Singleton
///
/// @return a reference to the singleton instance.
//--------------------------------------------------------
static JavaInterfaceManager& GetSingleton();
//--------------------------------------------------------
/// Initialise
///
/// Initialises the Java Interface Manager
///
/// @param The JVM.
//--------------------------------------------------------
void Initialise(JavaVM* inpJavaVM);
//--------------------------------------------------------
/// Get Java VM
///
/// @return The Java VM.
//--------------------------------------------------------
JavaVM* GetJavaVM();
//--------------------------------------------------------
/// Get JNI Environment Ptr
///
/// returns the jni enviroment pointer for the current
/// thread. The value returned from this should NOT be stored
/// as global or member data, as this will break thread safety
///
/// @return returns a pointer to the jni environment.
//--------------------------------------------------------
JNIEnv* GetJNIEnvironmentPtr();
//--------------------------------------------------------
/// Add Java Interface
///
/// Adds a new Java Interface. This should be called on
/// creation of the system that uses the java interface.
///
/// @param The java interface.
//--------------------------------------------------------
void AddJavaInterface(IJavaInterfaceSPtr inpJavaInterface);
//--------------------------------------------------------
/// Get Java Interface
///
/// Looks for a java interface that implements the given interface.
///
/// @param The type ID of the java interface you wish to implement
/// @return Java Interface that implements the given interface or nullptr if none
//--------------------------------------------------------
IJavaInterfaceSPtr GetJavaInterface(ChilliSource::InterfaceIDType inInterfaceID);
//--------------------------------------------------------
/// Get Java Interface
///
/// Looks for a java interface that implements the given interface.
///
/// @return Java Interface that implements the given interface or nullptr if none
//--------------------------------------------------------
template <typename T> std::shared_ptr<T> GetJavaInterface();
//--------------------------------------------------------
/// Get Java Interface
///
/// Looks for a java interface that implements the given interface.
///
/// @return Java Interface that implements the given interface or nullptr if none
//--------------------------------------------------------
template <typename T, typename U> std::shared_ptr<T> GetJavaInterface();
//--------------------------------------------------------
/// Get Java Interfaces
///
/// Looks for Java Interfaces that implement the given interface
/// and fills an array with them.
///
/// @param The type ID of the Java Interface you wish to implement
/// @param OUT: The array of java interfaces.
//--------------------------------------------------------
void GetJavaInterfaces(ChilliSource::InterfaceIDType inInterfaceID, std::vector<IJavaInterfaceSPtr>& outJavaInterfaces);
//--------------------------------------------------------
/// Get Java Interfaces
///
/// Looks for Java Interfaces that implement the given interface
/// and fills an array with them.
///
/// @param OUT: The array of java interfaces.
//--------------------------------------------------------
template <typename T> void GetJavaInterfaces(std::vector<std::shared_ptr<T> >& outJavaInterfaces);
//--------------------------------------------------------
/// Destructor
//--------------------------------------------------------
~JavaInterfaceManager();
private:
//--------------------------------------------------------
/// Constructor
//--------------------------------------------------------
JavaInterfaceManager();
static JavaInterfaceManager* mpJavaInterfaceManagerSingleton;
std::vector<IJavaInterfaceSPtr> mJavaInterfaces;
JavaVM* mpJavaVM;
};
//========================================================
/// Templated Definitions
//========================================================
//--------------------------------------------------------
/// Get Java Interface
//--------------------------------------------------------
template <typename T> std::shared_ptr<T> JavaInterfaceManager::GetJavaInterface()
{
IJavaInterfaceSPtr pJavaInterface = GetJavaInterface(T::InterfaceID);
if (pJavaInterface != nullptr)
{
return std::static_pointer_cast<T>(pJavaInterface);
}
return std::shared_ptr<T>();
}
//--------------------------------------------------------
/// Get Java Interface
//--------------------------------------------------------
template <typename T, typename U> std::shared_ptr<T> JavaInterfaceManager::GetJavaInterface()
{
IJavaInterfaceSPtr pJavaInterface = GetJavaInterface(U::InterfaceID);
if (pJavaInterface != nullptr)
{
return std::static_pointer_cast<T>(pJavaInterface);
}
return std::shared_ptr<T>();
}
//--------------------------------------------------------
/// Get Java Interfaces
//--------------------------------------------------------
template <typename T> void JavaInterfaceManager::GetJavaInterfaces(std::vector<std::shared_ptr<T> >& outJavaInterfaces)
{
for (size_t nJavaInterface = 0; nJavaInterface < mJavaInterfaces.size(); nJavaInterface++)
{
if (mJavaInterfaces[nJavaInterface]->IsA(T::InterfaceID))
{
outJavaInterfaces.push_back(std::static_pointer_cast<T>(mJavaInterfaces[nJavaInterface]));
}
}
}
}
}
#endif
#endif
| ChilliWorks/ChilliSource | Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h | C | mit | 8,142 |
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* Oeuvre.
*
* @ORM\Table(name="oeuvre")
* @ORM\Entity(repositoryClass="App\Repository\OeuvreRepository")
*/
class Oeuvre
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="titre", type="string", length=100)
*/
private $titre;
/**
* @var string
*
* @ORM\Column(name="soustitre", type="string", length=100, nullable=true)
*/
private $sousTitre;
/**
* @var int
*
* @ORM\Column(name="annee", type="integer", nullable=true)
*/
private $annee;
/**
* @var int
*
* @ORM\Column(name="ageminimum", type="integer", nullable=true)
*/
private $ageMinimum;
/**
* @var Audience
*
* @ORM\ManyToOne(
* targetEntity="App\Entity\Audience",
* inversedBy="oeuvres"
* )
*/
private $audience;
/**
* @var Collection
*
* @ORM\ManyToMany(
* targetEntity="App\Entity\Nationalite",
* inversedBy="oeuvres"
* )
*/
private $nationalites;
/**
* @var Collection
*
* @ORM\ManyToMany(
* targetEntity="App\Entity\Langue",
* inversedBy="oeuvres"
* )
*/
private $langues;
/**
* @var CategorieOeuvre
*
* @ORM\ManyToOne(
* targetEntity="App\Entity\CategorieOeuvre",
* inversedBy="oeuvres"
* )
* @ORM\JoinColumn(name="categorieoeuvre_id", referencedColumnName="id")
*/
private $categorieOeuvre;
/**
* @var Collection
*
* @ORM\OneToMany(
* targetEntity="App\Entity\OeuvreCategorieArtiste",
* mappedBy="oeuvre"
* )
*/
private $oeuvreCategorieArtistes;
/**
* @var Partie
*
* @ORM\OneToOne(
* targetEntity="App\Entity\Partie",
* mappedBy="oeuvre"
* )
*/
private $partie;
/**
* @var Collection
*
* @ORM\ManyToMany(
* targetEntity="App\Entity\Support",
* inversedBy="oeuvres"
* )
*/
private $supports;
/**
* @var Collection
*
* @ORM\ManyToMany(
* targetEntity="App\Entity\GroupePrincipal",
* inversedBy="oeuvres"
* )
* @ORM\JoinTable(
* name="oeuvre_groupeprincipal",
* joinColumns={
* @ORM\JoinColumn(
* name="oeuvre_id",
* referencedColumnName="id"
* )
* },
* inverseJoinColumns={
* @ORM\JoinColumn(
* name="groupeprincipal_id",
* referencedColumnName="id"
* )
* }
* )
*/
private $groupesPrincipaux;
/**
* Constructeur.
*
* @param string|null $titre
* @param string|null $sousTitre
* @param int|null $annee
* @param int|null $ageMinimum
*/
public function __construct(
string $titre = null,
string $sousTitre = null,
int $annee = null,
int $ageMinimum = null
) {
$this->titre = $this->checkTitre($titre);
$this->sousTitre = $this->checkTitre($sousTitre);
$this->annee = $annee;
$this->ageMinimum = $ageMinimum;
$this->nationalites = new ArrayCollection();
$this->langues = new ArrayCollection();
$this->oeuvreCategorieArtistes = new ArrayCollection();
$this->supports = new ArrayCollection();
$this->groupesPrincipaux = new ArrayCollection();
}
/**
* Get id.
*
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* Set titre.
*
* @param string $titre
*/
public function setTitre(?string $titre): void
{
$this->titre = $titre;
}
/**
* Get titre.
*
* @return string|null
*/
public function getTitre(): ?string
{
return $this->titre;
}
/**
* Set sousTitre.
*
* @param string|null $sousTitre
*/
public function setSousTitre(?string $sousTitre): void
{
$this->sousTitre = $sousTitre;
}
/**
* Get sousTitre.
*
* @return string
*/
public function getSousTitre(): ?string
{
return $this->sousTitre;
}
/**
* Set annee.
*
* @param int|null $annee
*/
public function setAnnee(?int $annee): void
{
$this->annee = $annee;
}
/**
* Get annee.
*
* @return int|null
*/
public function getAnnee(): ?int
{
return $this->annee;
}
/**
* Set ageMinimum.
*
* @param int|null $ageMinimum
*/
public function setAgeMinimum(?int $ageMinimum): void
{
$this->ageMinimum = $ageMinimum;
}
/**
* Get ageMinimum.
*
* @return int
*/
public function getAgeMinimum(): ?int
{
return $this->ageMinimum;
}
/**
* @param mixed $titre
* @param int $maxSize
*
* @return null|string
*/
public function checkTitre(?string $titre, $maxSize = 100): ?string
{
if (null !== $titre) {
$titre = trim($titre);
$titre = iconv_substr($titre, 0, $maxSize);
return trim($titre);
}
return null;
}
/**
* Set audience.
*
* @param Audience $audience
*/
public function setAudience(Audience $audience = null): void
{
$this->audience = $audience;
}
/**
* Get audience.
*
* @return Audience|null
*/
public function getAudience(): ?Audience
{
return $this->audience;
}
/**
* Add nationalite.
*
* @param Nationalite $nationalite
*/
public function addNationalite(Nationalite $nationalite): void
{
if (!$this->nationalites->contains($nationalite)) {
$this->nationalites[] = $nationalite;
$nationalite->addOeuvre($this);
}
}
/**
* Remove nationalite.
*
* @param Nationalite $nationalite
*/
public function removeNationalite(Nationalite $nationalite): void
{
if ($this->nationalites->contains($nationalite)) {
$this->nationalites->removeElement($nationalite);
$nationalite->removeOeuvre($this);
}
}
/**
* Get nationalites.
*
* @return Collection
*/
public function getNationalites(): Collection
{
return $this->nationalites;
}
/**
* Add langue.
*
* @param Langue $langue
*/
public function addLangue(Langue $langue): void
{
if (!$this->langues->contains($langue)) {
$this->langues[] = $langue;
$langue->addOeuvre($this);
}
}
/**
* Remove langue.
*
* @param Langue $langue
*/
public function removeLangue(Langue $langue): void
{
if ($this->langues->contains($langue)) {
$this->langues->removeElement($langue);
$langue->removeOeuvre($this);
}
}
/**
* Get langues.
*
* @return Collection
*/
public function getLangues(): Collection
{
return $this->langues;
}
/**
* Set categorieOeuvre.
*
* @param CategorieOeuvre $categorieOeuvre
*/
public function setCategorieOeuvre(
CategorieOeuvre $categorieOeuvre = null
): void {
$this->categorieOeuvre = $categorieOeuvre;
}
/**
* Get categorieOeuvre.
*
* @return CategorieOeuvre
*/
public function getCategorieOeuvre(): ?CategorieOeuvre
{
return $this->categorieOeuvre;
}
/**
* Remove oeuvreCategorieArtiste.
*
* @param OeuvreCategorieArtiste $oeuvreCategorieArtiste
*/
public function removeOeuvreCategorieArtiste(
OeuvreCategorieArtiste $oeuvreCategorieArtiste
): void {
if ($this->oeuvreCategorieArtistes->contains($oeuvreCategorieArtiste)) {
$this->oeuvreCategorieArtistes->removeElement($oeuvreCategorieArtiste);
}
$oeuvreCategorieArtiste->setOeuvre(null);
}
/**
* Add oeuvreCategorieArtiste.
*
* @param OeuvreCategorieArtiste $oeuvreCategorieArtiste
*/
public function addOeuvreCategorieArtiste(
OeuvreCategorieArtiste $oeuvreCategorieArtiste
): void {
if (!$this->oeuvreCategorieArtistes->contains($oeuvreCategorieArtiste)) {
$this->oeuvreCategorieArtistes[] = $oeuvreCategorieArtiste;
}
$oeuvreCategorieArtiste->setOeuvre($this);
}
/**
* Get oeuvreCategorieArtistes.
*
* @return Collection
*/
public function getOeuvreCategorieArtistes(): Collection
{
return $this->oeuvreCategorieArtistes;
}
/**
* Set partie.
*
* @param Partie|null $partie
*/
public function setPartie(Partie $partie = null): void
{
$this->partie = $partie;
}
/**
* Get partie.
*
* @return Partie|null
*/
public function getPartie(): ?Partie
{
return $this->partie;
}
/**
* Add support.
*
* @param Support $support
*/
public function addSupport(Support $support): void
{
if (!$this->supports->contains($support)) {
$this->supports[] = $support;
$support->addOeuvre($this);
}
}
/**
* Remove support.
*
* @param Support $support
*/
public function removeSupport(Support $support): void
{
if ($this->supports->contains($support)) {
$this->supports->removeElement($support);
$support->removeOeuvre($this);
}
}
/**
* Get supports.
*
* @return Collection
*/
public function getSupports(): Collection
{
return $this->supports;
}
/**
* Add groupePrincipal.
*
* @param GroupePrincipal $groupePrincipal
*/
public function addGroupePrincipal(GroupePrincipal $groupePrincipal): void
{
if (!$this->groupesPrincipaux->contains($groupePrincipal)) {
$this->groupesPrincipaux[] = $groupePrincipal;
$groupePrincipal->addOeuvre($this);
}
}
/**
* Remove groupePrincipal.
*
* @param GroupePrincipal $groupePrincipal
*/
public function removeGroupePrincipal(GroupePrincipal $groupePrincipal): void
{
if ($this->groupesPrincipaux->contains($groupePrincipal)) {
$this->groupesPrincipaux->removeElement($groupePrincipal);
$groupePrincipal->removeOeuvre($this);
}
}
/**
* Get groupesPrincipaux.
*
* @return Collection
*/
public function getGroupesPrincipaux(): Collection
{
return $this->groupesPrincipaux;
}
}
| dmsr45/github_sf_media | src/Entity/Oeuvre.php | PHP | mit | 11,190 |
<section>
<body>
<!-- Quick setting box starts -->
<div class="quick-slide hidden-xs"></div>
<div class="out-container">
<div class="outer">
<!-- Sidebar starts -->
<!-- Sidebar ends -->
<!-- Mainbar starts -->
<div class="mainbar">
<!-- Page heading starts -->
<div class="page-head">
<div class="container">
<div class="row">
<!-- Page heading -->
<div class="col-md-3 col-sm-6 col-xs-6">
<h2><i class="fa fa-desktop"></i>LAY</h2>
</div>
</div>
</div>
<!-- Page heading ends -->
<!-- Black block starts -->
<div class="blue-block">
<div class="page-title">
<h3 class="pull-left"><i class="fa fa-group"></i>Denuncias</h3>
<div class="clearfix"></div>
</div>
</div>
<!-- Black block ends -->
<!-- Content starts -->
<div class="container">
<div class="page-content">
<!-- Content starts -->
<div class="container">
<div class="page-content page-users">
<div class="page-tabs">
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane fade active in" id="search">
<h3>Denuncias</h3>
<?php echo form_open('regidenu/registro_exitoso', array('class'=>'form-horizontal')); ?>
<h1>Inserciรณn exitosa</h1>
</div>
</form>
<a href="<?php echo site_url('regidenu/buscar');?>" class="btn btn-danger">Aceptar</a>
<div class="well" align="center">
<!-- Advanced search Denuncia-->
</div>
<!-- Add new Denuncia -->
<div class="tab-pane fade" id="addnew">
</div>
<!--hasta aqui -->
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Content ends -->
</div>
<!-- Mainbar ends -->
<div class="clearfix"></div>
</div>
</div>
</body>
</section>
| Citlaa/LAY | application/views/denuncias/exito.php | PHP | mit | 2,261 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>nlocks</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
</head>
<body bgcolor="white">
<div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<h1>nlocks</h1>
<p>Copyright ยฉ 2016 Guilherme Andrade</p>
<p><b>Version:</b> 1.1.2</p>
<p><b>Authors:</b> Guilherme Andrade (<a href="mailto:nlocks(at)gandrade(dot)net"><tt>nlocks(at)gandrade(dot)net</tt></a>).</p>
<p><code>nlocks</code>: Native spinlocks for Erlang</p>
<hr>
<p>An experiment on Erlang native spinlocks:
* Able to guarantee exclusive access to shared resources
* Not dependent on a single process (no flooded mailbox as a bottleneck)
* Able to deal with brutally killed processes that still held unreleased locks (more below)</p>
<pre lang="erlang">
Lock = nlocks:new(),
Transaction = fun() ->
io:format("hello from ~p at ~p~n", [self(), os:timestamp()]),
timer:sleep(100)
end,
[spawn(fun () -> nlocks:transaction(Lock, Transaction) end) || _ <- lists:seq(1, 4)].
% hello from <0.66.0> at {1465,509871,454813}
% hello from <0.69.0> at {1465,509871,555028}
% hello from <0.67.0> at {1465,509871,656021}
% hello from <0.68.0> at {1465,509871,757031}
</pre>
<h3><a name="Brutal_kills_and_unreleased_locks">Brutal kills and unreleased locks</a></h3><p>
Hackish solution. Other than setting up some sort of monitor in the Erlang land, I found no practical way to deal with these other than making use of _ownership_ objects, references to which should never leave the process under which they were created; the release therefore becomes dependent on the garbage collector calling their destructor, but this also makes it more convenient for regularly terminated processes that forget to clean up.</p>
<h3><a name="Ownership_objects">Ownership objects</a></h3>
<pre lang="c++">
struct Ownership {
ERL_NIF_TERM pid;
Lock** lockResource;
};
</pre>
<p>* They're created for lock acquisition in order to deal with the above problem
* They should never leave their owning process
* On successful acquisition, they link themselves to the lock and force it to live as long as they live
* They guarantee only the lock owner can release the lock
* No explicit destruction needed</p>
<h3><a name="Lock_objects">Lock objects</a></h3>
<pre lang="c++">
struct Lock {
std::atomic<Ownership*> ownership;
};
</pre>
<p>* They keep an atomic pointer either set to null (free) or to the ownership object's address (locked)
* Can be shared between local processes through messages, ETS tables, etc.
* No explicit destruction needed</p>
<h3><a name="The_spinning">The spinning</a></h3><p>
* It uses C++ 11 <a href="http://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange">compare_exchange_weak</a>
* For each attempt, a new NIF call is scheduled; this brings some overhead to the table but it's crucial to play nice with the VM
* If the timeout is other than 'infinity', for each attempt it compares the deadline against the current <a href="http://en.cppreference.com/w/cpp/chrono/steady_clock">steady_clock</a> value; this feels excessive and might hurt performance.</p>
<h3><a name="Internal_metrics">Internal metrics</a></h3>
<pre lang="erlang">
% nlocks:info()
[{allocated_locks,2},
{allocated_ownerships,6},
{acquired_locks,1},
{contention,5}, % amount of processes attempting lock acquisition
{has_lockfree_counters,true},
{has_lockfree_ownership,true}]
</pre>
<hr>
<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, May 1 2017, 02:21:31.</i></p>
</body>
</html>
| g-andrade/nlocks | doc/overview-summary.html | HTML | mit | 4,286 |
---
layout: post
microblog: true
date: 2009-11-17 03:00 +0300
guid: http://desparoz.micro.blog/2009/11/17/t5805027465.html
---
For PADI Instructors in the US this is a BIG deal. RT @DiverWire: Boy Scouts announce new Scuba Diving Merit Badge [bit.ly/15pcnA](http://bit.ly/15pcnA)
| desparoz/desparoz.github.io | _posts/2009-11-17-t5805027465.md | Markdown | mit | 280 |
/*
* main.c
*
* Created on: 31 May 2016
* Author: ajuaristi <[email protected]>
*/
#include <stdio.h>
#include <signal.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <linux/videodev2.h>
#include <sys/stat.h>
#include "utils.h"
#include "appbase.h"
#include "uvc.h"
#define DEFAULT_WAIT_TIME 5
int stop;
#define SHOULD_STOP(v) (stop = v)
#define IS_STOPPED() (stop)
static char *create_debug_filename()
{
#define COUNT_LIMIT 9
static unsigned int count = 0;
char filename_template[] = "picture";
size_t size = sizeof(filename_template) + 2;
char *filename = ec_malloc(size);
snprintf(filename, size, "%s.%d", filename_template, count++);
if (count > COUNT_LIMIT)
count = 0;
return filename;
#undef COUNT_LIMIT
}
static void write_to_disk(const unsigned char *data, size_t size)
{
FILE *f;
char *filename = create_debug_filename();
f = fopen(filename, "w");
if (f) {
fwrite(data, size, 1, f);
fclose(f);
fprintf(stderr, "DEBUG: Frame written to file '%s'\n", filename);
}
free(filename);
}
static void print_usage_and_exit(const char *name)
{
if (name) {
printf("Usage: %s [OPTIONS] <app name> <username> <password>\n"
"Options:\n"
" -w secs Sleep this amount of seconds between shots\n"
" -d Display debug messages\n"
" -s Take one single shot and exit\n"
" -j Convert frames to JPEG\n"
" -S Stream as fast as possible\n",
name);
}
exit(1);
}
static void sighandler(int s)
{
char *signame;
switch (s) {
case SIGINT:
signame = "SIGINT";
break;
case SIGQUIT:
signame = "SIGQUIT";
break;
case SIGTERM:
signame = "SIGTERM";
break;
case SIGABRT:
signame = "SIGABRT";
break;
case SIGTRAP:
signame = "SIGTRAP";
break;
default:
signame = NULL;
break;
}
if (signame)
fprintf(stderr, "Received %s. Exiting.", signame);
else
fprintf(stderr, "Received %d. Exiting.", s);
/* Stop! */
SHOULD_STOP(1);
}
static void do_stream(struct appbase *ab, bool jpeg)
{
struct camera *c;
c = uvc_open();
if (!c)
fatal("Could not find any camera for capturing pictures");
c->frame = uvc_alloc_frame(320, 240, V4L2_PIX_FMT_YUYV);
if (!c->frame)
fatal("Could not allocate enough memory for frames");
if (!uvc_init(c))
fatal("Could not start camera for streaming");
while (!IS_STOPPED() && uvc_capture_frame(c)) {
if (jpeg)
frame_convert_yuyv_to_jpeg(c->frame);
if (!appbase_push_frame(ab,
c->frame->frame_data, c->frame->frame_bytes_used,
&c->frame->capture_time)) {
fprintf(stderr, "ERROR: Could not capture frame\n");
break;
}
c->frame->frame_bytes_used = 0;
}
uvc_close(c);
}
void do_capture(struct appbase *ab, unsigned int wait_time, bool oneshot, bool jpeg, bool debug)
{
struct camera *c;
struct frame *f;
while (!IS_STOPPED()) {
c = uvc_open();
if (!c)
fatal("Could not find any camera for capturing pictures");
c->frame = uvc_alloc_frame(320, 240, V4L2_PIX_FMT_YUYV);
if (!c->frame)
fatal("Could not allocate enough memory for frames");
if (!uvc_init(c))
fatal("Could not start camera for streaming");
if (uvc_capture_frame(c)) {
f = c->frame;
if (jpeg)
frame_convert_yuyv_to_jpeg(f);
if (!appbase_push_frame(ab,
f->frame_data, f->frame_bytes_used,
&f->capture_time))
fprintf(stderr, "ERROR: Could not send frame\n");
if (debug)
write_to_disk(f->frame_data, f->frame_bytes_used);
memset(f->frame_data, 0, f->frame_size);
f->frame_bytes_used = 0;
} else {
fprintf(stderr, "ERROR: Could not capture frame\n");
}
uvc_close(c);
if (oneshot)
break;
/*
* sleep(3) should not interfere with our signal handlers,
* unless we're also handling SIGALRM
*/
sleep(wait_time);
}
}
int main(int argc, char **argv)
{
int opt;
char *endptr;
long int wait_time = DEFAULT_WAIT_TIME;
bool debug = false, oneshot = false, stream = false, jpeg = false;
struct sigaction sig;
struct appbase *ab;
/* Parse command-line options */
while ((opt = getopt(argc, argv, "w:dsSj")) != -1) {
switch (opt) {
case 'w':
wait_time = strtol(optarg, &endptr, 10);
if (*endptr || wait_time < 0)
print_usage_and_exit(argv[0]);
break;
case 'd':
debug = true;
break;
case 's':
oneshot = true;
break;
case 'S':
stream = true;
break;
case 'j':
jpeg = true;
break;
default:
print_usage_and_exit(argv[0]);
break;
}
}
/* Set signal handlers and set stop condition to zero */
SHOULD_STOP(0);
memset(&sig, 0, sizeof(sig));
sig.sa_handler = sighandler;
sig.sa_flags = SA_RESETHAND;
sigemptyset(&sig.sa_mask);
sigaction(SIGINT, &sig, NULL);
sigaction(SIGQUIT, &sig, NULL);
sigaction(SIGTERM, &sig, NULL);
sigaction(SIGABRT, &sig, NULL);
sigaction(SIGTRAP, &sig, NULL);
/* Set up Appbase handle
* We need the app name, username and password to build the REST URL, and these
* should came now as parameters. We expect optind to point us to the first one.
*/
if (argc - optind < 3)
print_usage_and_exit(argv[0]);
ab = appbase_open(
argv[optind], // app name
argv[optind + 1], // username
argv[optind + 2], // password
false); // streaming off
if (!ab)
fatal("Could not log into Appbase");
if (debug) {
appbase_enable_progress(ab, true);
appbase_enable_verbose(ab, true);
}
if (stream)
do_stream(ab, jpeg);
else
do_capture(ab, wait_time, oneshot, jpeg, debug);
appbase_close(ab);
return 0;
}
| juaristi/appbase-cctv | daemon-main.c | C | mit | 5,533 |
<h1><%= title %></h1>
<div class="source_info">
<p><%= title %> description.</p>
</div>
<section class="source_section">
<h2><%= title %> section</h2>
<div class="source_example">
example code
</div>
</section> | JohannesFischer/generator-sourcejs-specs | generators/app/templates/_index.src.html | HTML | mit | 225 |
# Alarm
Cordova + Polymer
| mpbunch/Alarm | README.md | Markdown | mit | 26 |
package builtins
import (
"fmt"
"net/mail"
"net/url"
"regexp"
"strings"
u "github.com/araddon/gou"
"github.com/mssola/user_agent"
"github.com/araddon/qlbridge/expr"
"github.com/araddon/qlbridge/value"
"github.com/araddon/qlbridge/vm"
)
var _ = u.EMPTY
// email a string, parses email and makes sure it is valid
//
// email("Bob <[email protected]>") => [email protected], true
// email("Bob <bob>") => "", false
//
type Email struct{}
// Type string
func (m *Email) Type() value.ValueType { return value.StringType }
func (m *Email) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) != 1 {
return nil, fmt.Errorf("Expected 1 args for Email(field) but got %s", n)
}
return emailEval, nil
}
func emailEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
val := args[0]
if val == nil || val.Nil() || val.Err() {
return nil, false
}
emailStr := ""
switch v := val.(type) {
case value.StringValue:
emailStr = v.ToString()
case value.Slice:
if v.Len() > 0 {
v1 := v.SliceValue()[0]
emailStr = v1.ToString()
}
}
if emailStr == "" {
return value.EmptyStringValue, false
}
if em, err := mail.ParseAddress(emailStr); err == nil {
return value.NewStringValue(strings.ToLower(em.Address)), true
}
return value.EmptyStringValue, false
}
// emailname a string, parses email
//
// emailname("Bob <[email protected]>") => Bob
//
type EmailName struct{}
// Type string
func (m *EmailName) Type() value.ValueType { return value.StringType }
func (m *EmailName) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) != 1 {
return nil, fmt.Errorf("Expected 1 arg for EmailName(fieldname) but got %s", n)
}
return emailNameEval, nil
}
func emailNameEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
val, ok := value.ValueToString(args[0])
if !ok || val == "" {
return value.EmptyStringValue, false
}
if em, err := mail.ParseAddress(val); err == nil {
return value.NewStringValue(em.Name), true
}
return value.EmptyStringValue, false
}
// emaildomain parses email and returns domain
//
// emaildomain("Bob <[email protected]>") => bob.com
//
type EmailDomain struct{}
// Type string
func (m *EmailDomain) Type() value.ValueType { return value.StringType }
func (m *EmailDomain) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) != 1 {
return nil, fmt.Errorf("Expected 1 arg for EmailDomain(fieldname) but got %s", n)
}
return emailDomainEval, nil
}
func emailDomainEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
val, ok := value.ValueToString(args[0])
if !ok || val == "" {
return value.EmptyStringValue, false
}
if em, err := mail.ParseAddress(strings.ToLower(val)); err == nil {
parts := strings.SplitN(strings.ToLower(em.Address), "@", 2)
if len(parts) == 2 {
return value.NewStringValue(parts[1]), true
}
}
return value.EmptyStringValue, false
}
// Domains Extract Domains from a Value, or Values (must be urlish), doesn't do much/any validation
//
// domains("http://www.lytics.io/index.html") => []string{"lytics.io"}
//
type Domains struct{}
// Type strings
func (m *Domains) Type() value.ValueType { return value.StringsType }
func (m *Domains) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) == 0 {
return nil, fmt.Errorf("Expected 1 or more args for Domains(arg, ...) but got %s", n)
}
return domainsEval, nil
}
func domainsEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
svals := value.NewStringsValue(make([]string, 0))
for _, val := range args {
switch v := val.(type) {
case value.StringValue:
svals.Append(v.Val())
case value.StringsValue:
for _, sv := range v.Val() {
svals.Append(sv)
}
}
}
// Since its empty, we will just re-use it
if svals.Len() == 0 {
return nil, false
}
// Now convert to domains
domains := value.NewStringsValue(make([]string, 0))
for _, val := range svals.Val() {
urlstr := strings.ToLower(val)
if len(urlstr) < 4 {
continue
}
// May not have an http prefix, if not assume it
if !strings.HasPrefix(urlstr, "http") {
urlstr = "http://" + urlstr
}
if urlParsed, err := url.Parse(urlstr); err == nil {
parts := strings.Split(urlParsed.Host, ".")
if len(parts) > 2 {
parts = parts[len(parts)-2:]
}
if len(parts) > 0 {
domains.Append(strings.Join(parts, "."))
}
}
}
if domains.Len() == 0 {
return nil, false
}
return domains, true
}
// Extract Domain from a Value, or Values (must be urlish), doesn't do much/any validation.
// if input is a list of strings, only first is evaluated, for plural see domains()
//
// domain("http://www.lytics.io/index.html") => "lytics.io"
//
type Domain struct{}
// Type string
func (m *Domain) Type() value.ValueType { return value.StringType }
func (m *Domain) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) != 1 {
return nil, fmt.Errorf("Expected 1 arg for Domain(field) but got %s", n)
}
return domainEval, nil
}
func domainEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
urlstr := ""
switch itemT := args[0].(type) {
case value.StringValue:
urlstr = itemT.Val()
case value.StringsValue:
for _, sv := range itemT.Val() {
urlstr = sv
break
}
}
urlstr = strings.ToLower(urlstr)
if !strings.HasPrefix(urlstr, "http") {
urlstr = "http://" + urlstr
}
if urlParsed, err := url.Parse(urlstr); err == nil && len(urlParsed.Host) > 2 {
parts := strings.Split(urlParsed.Host, ".")
if len(parts) > 2 {
parts = parts[len(parts)-2:]
}
if len(parts) > 0 {
return value.NewStringValue(strings.Join(parts, ".")), true
}
}
return value.EmptyStringValue, false
}
// Extract host from a String (must be urlish), doesn't do much/any validation
// In the event the value contains more than one input url, will ONLY evaluate first
//
// host("http://www.lytics.io/index.html") => www.lytics.io
//
type Host struct{}
// Type string
func (m *Host) Type() value.ValueType { return value.StringType }
func (m *Host) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) != 1 {
return nil, fmt.Errorf("Expected 1 arg for Host(field) but got %s", n)
}
return HostEval, nil
}
func HostEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
val := ""
switch itemT := args[0].(type) {
case value.StringValue:
val = itemT.Val()
case value.Slice:
if itemT.Len() == 0 {
return value.EmptyStringValue, false
}
val = itemT.SliceValue()[0].ToString()
}
if val == "" {
return value.EmptyStringValue, false
}
urlstr := strings.ToLower(val)
if len(urlstr) < 8 {
return value.EmptyStringValue, false
}
if !strings.HasPrefix(urlstr, "http") {
urlstr = "http://" + urlstr
}
if urlParsed, err := url.Parse(urlstr); err == nil {
//u.Infof("url.parse: %#v", urlParsed)
return value.NewStringValue(urlParsed.Host), true
}
return value.EmptyStringValue, false
}
// Extract hosts from a Strings (must be urlish), doesn't do much/any validation
//
// hosts("http://www.lytics.io", "http://www.activate.lytics.io") => www.lytics.io, www.activate.lytics.io
//
type Hosts struct{}
// Type strings
func (m *Hosts) Type() value.ValueType { return value.StringsType }
func (m *Hosts) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) == 0 {
return nil, fmt.Errorf("Expected 1 or more args for Hosts() but got %s", n)
}
return HostsEval, nil
}
func HostsEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
vals := value.NewStringsValue(make([]string, 0))
for _, item := range args {
switch itemT := item.(type) {
case value.StringValue:
val := itemT.Val()
if len(val) > 0 {
vals.Append(itemT.Val())
}
case value.Slice:
for _, sv := range itemT.SliceValue() {
val := sv.ToString()
if len(val) > 0 {
vals.Append(val)
}
}
}
}
if vals.Len() == 0 {
return vals, false
}
hosts := value.NewStringsValue(make([]string, 0))
for _, val := range vals.Val() {
urlstr := strings.ToLower(val)
if len(urlstr) < 8 {
continue
}
if !strings.HasPrefix(urlstr, "http") {
urlstr = "http://" + urlstr
}
if urlParsed, err := url.Parse(urlstr); err == nil {
//u.Infof("url.parse: %#v", urlParsed)
hosts.Append(urlParsed.Host)
}
}
if hosts.Len() == 0 {
return nil, false
}
return hosts, true
}
// url decode a string
//
// urldecode("http://www.lytics.io/index.html") => http://www.lytics.io
//
// In the event the value contains more than one input url, will ONLY evaluate first
//
type UrlDecode struct{}
// Type string
func (m *UrlDecode) Type() value.ValueType { return value.StringType }
func (m *UrlDecode) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) != 1 {
return nil, fmt.Errorf("Expected 1 arg for UrlDecode(field) but got %s", n)
}
return urlDecodeEval, nil
}
func urlDecodeEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
val := ""
switch itemT := args[0].(type) {
case value.StringValue:
val = itemT.Val()
case value.Slice:
if itemT.Len() == 0 {
return value.EmptyStringValue, false
}
val = itemT.SliceValue()[0].ToString()
}
if val == "" {
return value.EmptyStringValue, false
}
val, err := url.QueryUnescape(val)
return value.NewStringValue(val), err == nil
}
// UrlPath Extract url path from a String (must be urlish), doesn't do much/any validation
//
// path("http://www.lytics.io/blog/index.html") => blog/index.html
//
// In the event the value contains more than one input url, will ONLY evaluate first
//
type UrlPath struct{}
// Type string
func (m *UrlPath) Type() value.ValueType { return value.StringType }
func (m *UrlPath) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) != 1 {
return nil, fmt.Errorf("Expected 1 arg for UrlPath() but got %s", n)
}
return urlPathEval, nil
}
func urlPathEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
val := ""
switch itemT := args[0].(type) {
case value.StringValue:
val = itemT.Val()
case value.Slice:
if itemT.Len() == 0 {
return value.EmptyStringValue, false
}
val = itemT.SliceValue()[0].ToString()
}
if val == "" {
return value.EmptyStringValue, false
}
urlstr := strings.ToLower(val)
if len(urlstr) > 6 && !strings.Contains(urlstr[:5], "/") {
if !strings.HasPrefix(urlstr, "http") {
urlstr = "http://" + urlstr
}
}
if urlParsed, err := url.Parse(urlstr); err == nil {
return value.NewStringValue(urlParsed.Path), true
}
return value.EmptyStringValue, false
}
// Qs Extract qs param from a string (must be url valid)
//
// qs("http://www.lytics.io/?utm_source=google","utm_source") => "google", true
//
type Qs struct{}
// Type string
func (m *Qs) Type() value.ValueType { return value.StringType }
func (m *Qs) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) != 2 {
return nil, fmt.Errorf("Expected 2 args for Qs(url, param) but got %s", n)
}
return qsEval, nil
}
func qsEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
urlstr := ""
switch itemT := args[0].(type) {
case value.StringValue:
urlstr = itemT.Val()
case value.Slice:
if itemT.Len() == 0 {
return value.EmptyStringValue, false
}
urlstr = itemT.SliceValue()[0].ToString()
}
if urlstr == "" {
return value.EmptyStringValue, false
}
qsParam, ok := value.ValueToString(args[1])
if !ok || qsParam == "" {
return value.EmptyStringValue, false
}
if len(urlstr) > 6 && !strings.Contains(urlstr[:5], "/") {
if !strings.HasPrefix(urlstr, "http") {
urlstr = "http://" + urlstr
}
}
if urlParsed, err := url.Parse(urlstr); err == nil {
qsval := urlParsed.Query().Get(qsParam)
if len(qsval) > 0 {
return value.NewStringValue(qsval), true
}
}
return value.EmptyStringValue, false
}
// Qs Extract qs param from a string (must be url valid)
//
// qs("http://www.lytics.io/?utm_source=google","utm_source") => "google", true
//
type QsDeprecate struct{}
// Type string
func (m *QsDeprecate) Type() value.ValueType { return value.StringType }
func (m *QsDeprecate) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) != 2 {
return nil, fmt.Errorf("Expected 2 args for Qs(url, param) but got %s", n)
}
return qsDeprecateEval, nil
}
func qsDeprecateEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
val := ""
switch itemT := args[0].(type) {
case value.StringValue:
val = itemT.Val()
case value.Slice:
if itemT.Len() == 0 {
return value.EmptyStringValue, false
}
val = itemT.SliceValue()[0].ToString()
}
if val == "" {
return value.EmptyStringValue, false
}
urlstr := strings.ToLower(val)
keyVal, ok := value.ValueToString(args[1])
if !ok || keyVal == "" {
return value.EmptyStringValue, false
}
if len(urlstr) > 6 && !strings.Contains(urlstr[:5], "/") {
if !strings.HasPrefix(urlstr, "http") {
urlstr = "http://" + urlstr
}
}
if urlParsed, err := url.Parse(urlstr); err == nil {
qsval := urlParsed.Query().Get(keyVal)
if len(qsval) > 0 {
return value.NewStringValue(qsval), true
}
}
return value.EmptyStringValue, false
}
// UrlMain remove the querystring and scheme from url
//
// urlmain("http://www.lytics.io/?utm_source=google") => "www.lytics.io/", true
//
type UrlMain struct{}
// Type string
func (m *UrlMain) Type() value.ValueType { return value.StringType }
func (m *UrlMain) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) != 1 {
return nil, fmt.Errorf("Expected 1 arg for UrlMain() but got %s", n)
}
return urlMainEval, nil
}
func urlMainEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
val := ""
switch itemT := args[0].(type) {
case value.StringValue:
val = itemT.Val()
case value.Slice:
if itemT.Len() == 0 {
return value.EmptyStringValue, false
}
val = itemT.SliceValue()[0].ToString()
}
if val == "" {
return value.EmptyStringValue, false
}
if up, err := url.Parse(val); err == nil {
return value.NewStringValue(fmt.Sprintf("%s%s", up.Host, up.Path)), true
}
return value.EmptyStringValue, false
}
// UrlMinusQs removes a specific query parameter and its value from a url
//
// urlminusqs("http://www.lytics.io/?q1=google&q2=123", "q1") => "http://www.lytics.io/?q2=123", true
//
type UrlMinusQs struct{}
// Type string
func (m *UrlMinusQs) Type() value.ValueType { return value.StringType }
func (m *UrlMinusQs) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) != 2 {
return nil, fmt.Errorf("Expected 2 args for UrlMinusQs(url, qsparam) but got %s", n)
}
return urlMinusQsEval, nil
}
func urlMinusQsEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
urlstr := ""
switch itemT := args[0].(type) {
case value.StringValue:
urlstr = itemT.Val()
case value.Slice:
if itemT.Len() == 0 {
return value.EmptyStringValue, false
}
urlstr = itemT.SliceValue()[0].ToString()
}
if urlstr == "" {
return value.EmptyStringValue, false
}
if len(urlstr) > 6 && !strings.Contains(urlstr[:5], "/") {
if !strings.HasPrefix(urlstr, "http") {
urlstr = "http://" + urlstr
}
}
keyVal, ok := value.ValueToString(args[1])
if !ok || keyVal == "" {
return value.EmptyStringValue, false
}
if up, err := url.Parse(urlstr); err == nil {
qsval := up.Query()
_, ok := qsval[keyVal]
if !ok {
return value.NewStringValue(fmt.Sprintf("%s://%s%s?%s", up.Scheme, up.Host, up.Path, up.RawQuery)), true
}
qsval.Del(keyVal)
up.RawQuery = qsval.Encode()
if up.RawQuery == "" {
return value.NewStringValue(fmt.Sprintf("%s://%s%s", up.Scheme, up.Host, up.Path)), true
}
return value.NewStringValue(fmt.Sprintf("%s://%s%s?%s", up.Scheme, up.Host, up.Path, up.RawQuery)), true
}
return value.EmptyStringValue, false
}
// UrlWithQueryFunc strips a url and retains only url parameters that match
// the supplied regular expressions.
//
// url.matchqs(url, re1, re2, ...) => url_withoutqs
//
type UrlWithQuery struct{}
// Type string
func (m *UrlWithQuery) Type() value.ValueType { return value.StringType }
func (*UrlWithQuery) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) == 0 {
return nil, fmt.Errorf("Expected at least 1 args for urlwithqs(url, param, param2) but got %s", n)
}
if len(n.Args) == 1 {
return UrlWithQueryEval(nil), nil
}
// Memoize these compiled reg-expressions
include := make([]*regexp.Regexp, 0)
for _, n := range n.Args[1:] {
keyItem, ok := vm.Eval(nil, n)
if !ok {
return nil, fmt.Errorf("Could not evaluate %v", n)
}
keyVal, ok := value.ValueToString(keyItem)
if !ok || keyVal == "" {
return nil, fmt.Errorf("Could not convert %q to regex", n.String())
}
keyRegexp, err := regexp.Compile(keyVal)
if err != nil {
return nil, err
}
include = append(include, keyRegexp)
}
return UrlWithQueryEval(include), nil
}
// UrlWithQueryEval pass reg-expressions to match qs args.
// Must match one regexp or else the qs param is dropped.
func UrlWithQueryEval(include []*regexp.Regexp) expr.EvaluatorFunc {
return func(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
val := ""
switch itemT := args[0].(type) {
case value.StringValue:
val = itemT.Val()
case value.Slice:
if itemT.Len() == 0 {
return value.EmptyStringValue, false
}
val = itemT.SliceValue()[0].ToString()
}
if val == "" {
return value.EmptyStringValue, false
}
up, err := url.Parse(val)
if err != nil {
return value.EmptyStringValue, false
}
if len(args) == 1 {
return value.NewStringValue(fmt.Sprintf("%s%s", up.Host, up.Path)), true
}
oldvals := up.Query()
newvals := make(url.Values)
for k, v := range oldvals {
// include fields specified as arguments
for _, pattern := range include {
if pattern.MatchString(k) {
newvals[k] = v
break
}
}
}
up.RawQuery = newvals.Encode()
if up.RawQuery == "" {
return value.NewStringValue(fmt.Sprintf("%s%s", up.Host, up.Path)), true
}
return value.NewStringValue(fmt.Sprintf("%s%s?%s", up.Host, up.Path, up.RawQuery)), true
}
}
// UserAgent Extract user agent features
//
// useragent(user_agent_field,"mobile") => "true", true
//
type UserAgent struct{}
// Type string
func (m *UserAgent) Type() value.ValueType { return value.StringType }
func (m *UserAgent) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) != 2 {
return nil, fmt.Errorf("Expected 2 args for UserAgent(user_agent_field, feature) but got %s", n)
}
return userAgentEval, nil
}
func userAgentEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
val := ""
switch itemT := args[0].(type) {
case value.StringValue:
val = itemT.Val()
case value.Slice:
if itemT.Len() == 0 {
return value.EmptyStringValue, false
}
val = itemT.SliceValue()[0].ToString()
}
if val == "" {
return value.EmptyStringValue, false
}
/*
fmt.Printf("%v\n", ua.Mobile()) // => false
fmt.Printf("%v\n", ua.Bot()) // => false
fmt.Printf("%v\n", ua.Mozilla()) // => "5.0"
fmt.Printf("%v\n", ua.Platform()) // => "X11"
fmt.Printf("%v\n", ua.OS()) // => "Linux x86_64"
name, version := ua.Engine()
fmt.Printf("%v\n", name) // => "AppleWebKit"
fmt.Printf("%v\n", version) // => "537.11"
name, version = ua.Browser()
fmt.Printf("%v\n", name) // => "Chrome"
fmt.Printf("%v\n", version) // => "23.0.1271.97"
// Let's see an example with a bot.
ua.Parse("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)")
fmt.Printf("%v\n", ua.Bot()) // => true
name, version = ua.Browser()
fmt.Printf("%v\n", name) // => Googlebot
fmt.Printf("%v\n", version) // => 2.1
*/
method, ok := value.ValueToString(args[1])
if !ok || method == "" {
return value.EmptyStringValue, false
}
ua := user_agent.New(val)
switch strings.ToLower(method) {
case "bot":
return value.NewStringValue(fmt.Sprintf("%v", ua.Bot())), true
case "mobile":
return value.NewStringValue(fmt.Sprintf("%v", ua.Mobile())), true
case "mozilla":
return value.NewStringValue(ua.Mozilla()), true
case "platform":
return value.NewStringValue(ua.Platform()), true
case "os":
return value.NewStringValue(ua.OS()), true
case "engine":
name, _ := ua.Engine()
return value.NewStringValue(name), true
case "engine_version":
_, version := ua.Engine()
return value.NewStringValue(version), true
case "browser":
name, _ := ua.Browser()
return value.NewStringValue(name), true
case "browser_version":
_, version := ua.Browser()
return value.NewStringValue(version), true
}
return value.EmptyStringValue, false
}
// UserAgentMap Extract user agent features
//
// useragent.map(user_agent_field) => {"mobile": "false","platform":"X11"}, true
//
type UserAgentMap struct{}
// Type MapString
func (m *UserAgentMap) Type() value.ValueType { return value.MapStringType }
func (m *UserAgentMap) Validate(n *expr.FuncNode) (expr.EvaluatorFunc, error) {
if len(n.Args) != 1 {
return nil, fmt.Errorf("Expected 1 args for useragentmap(user_agent) but got %s", n)
}
return userAgentMapEval, nil
}
func userAgentMapEval(ctx expr.EvalContext, args []value.Value) (value.Value, bool) {
val := ""
switch itemT := args[0].(type) {
case value.StringValue:
val = itemT.Val()
case value.Slice:
if itemT.Len() == 0 {
return nil, false
}
val = itemT.SliceValue()[0].ToString()
}
if val == "" {
return nil, false
}
/*
fmt.Printf("%v\n", ua.Mobile()) // => false
fmt.Printf("%v\n", ua.Bot()) // => false
fmt.Printf("%v\n", ua.Mozilla()) // => "5.0"
fmt.Printf("%v\n", ua.Platform()) // => "X11"
fmt.Printf("%v\n", ua.OS()) // => "Linux x86_64"
name, version := ua.Engine()
fmt.Printf("%v\n", name) // => "AppleWebKit"
fmt.Printf("%v\n", version) // => "537.11"
name, version = ua.Browser()
fmt.Printf("%v\n", name) // => "Chrome"
fmt.Printf("%v\n", version) // => "23.0.1271.97"
// Let's see an example with a bot.
ua.Parse("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)")
fmt.Printf("%v\n", ua.Bot()) // => true
name, version = ua.Browser()
fmt.Printf("%v\n", name) // => Googlebot
fmt.Printf("%v\n", version) // => 2.1
*/
ua := user_agent.New(val)
out := make(map[string]string)
out["bot"] = fmt.Sprintf("%v", ua.Bot())
out["mobile"] = fmt.Sprintf("%v", ua.Mobile())
out["mozilla"] = ua.Mozilla()
out["platform"] = ua.Platform()
out["os"] = ua.OS()
name, version := ua.Engine()
out["engine"] = name
out["engine_version"] = version
name, version = ua.Browser()
out["browser"] = name
out["browser_version"] = version
return value.NewMapStringValue(out), true
}
| araddon/qlbridge | expr/builtins/url_email.go | GO | mit | 23,042 |
#include <QWebView>
#include "helpdialog.h"
/**
* Constructor of Help Dialog
*/
HelpDialog::HelpDialog(QWidget *parent) : QWebPage(parent) {
view = new QWebView();
}
/**
* Shows the help dialog
*/
void HelpDialog::showHelpDialog() {
createWindow(QWebPage::WebModalDialog);
view->setPage(this);
view->setWindowIcon(QIcon(":/images/help-icon.png"));
view->setWindowTitle("Othello FPG - Help");
view->load(QUrl("qrc:/html/index.html"));
view->show();
}
| yannakisg/othello | helpdialog.cpp | C++ | mit | 489 |
"use strict";
var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } };
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
exports.alts = alts;
exports.timeout = timeout;
exports.pipelineAsync = pipelineAsync;
// Enforces order resolution on resulting channel
// This might need to be the default behavior, though that requires more thought
exports.order = order;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _channelsJs = require("./channels.js");
var Channel = _channelsJs.Channel;
var Transactor = _channelsJs.Transactor;
var AltsTransactor = (function (_Transactor) {
function AltsTransactor(offer, commitCb) {
_classCallCheck(this, AltsTransactor);
_get(Object.getPrototypeOf(AltsTransactor.prototype), "constructor", this).call(this, offer);
this.commitCb = commitCb;
}
_inherits(AltsTransactor, _Transactor);
_createClass(AltsTransactor, {
commit: {
value: function commit() {
this.commitCb();
return _get(Object.getPrototypeOf(AltsTransactor.prototype), "commit", this).call(this);
}
}
});
return AltsTransactor;
})(Transactor);
function alts(race) {
var outCh = new Channel();
var transactors = race.map(function (cmd) {
var tx = undefined;
if (Array.isArray(cmd)) {
var _cmd;
(function () {
_cmd = _slicedToArray(cmd, 2);
var ch = _cmd[0];
var val = _cmd[1];
tx = new AltsTransactor(val, function () {
transactors.forEach(function (h) {
return h.active = false;
});
});
ch.fill(val, tx).deref(function () {
outCh.fill([val, ch]).deref(function () {
return outCh.close();
});
});
})();
} else {
tx = new AltsTransactor(true, function () {
transactors.forEach(function (h) {
return h.active = false;
});
});
cmd.drain(tx).deref(function (val) {
outCh.fill([val, cmd]).deref(function () {
return outCh.close();
});
});
}
return tx;
});
return outCh;
}
function timeout(ms) {
var ch = new Channel();
setTimeout(function () {
ch.close();
}, ms);
return ch;
}
function pipelineAsync(inch, converter, outch) {
var shouldCloseDownstream = arguments[3] === undefined ? false : arguments[3];
function take(val) {
if (val !== null) {
Promise.resolve(converter(val)).then(function (converted) {
outch.put(converted).then(function (didPut) {
if (didPut) {
inch.take().then(take);
}
});
});
} else if (shouldCloseDownstream) {
outch.close();
}
}
inch.take().then(take);
}
function order(inch, sizeOrBuf) {
var outch = new Channel(sizeOrBuf);
function drain() {
inch.take().then(function (val) {
if (val === null) {
outch.close();
} else {
outch.put(val).then(drain);
}
});
}
drain();
return outch;
}
//# sourceMappingURL=utils.js.map | nhusher/js-channels | dist/node/utils.js | JavaScript | mit | 4,823 |
//estrutura com os dados lidos
struct {
float tensao;
float corrente;
float temperaturaBaterias;
float temperaturaCockpit;
float velocidade; //velocidade calculada do carro
double hodometro; //armazena a quantidade de metros percorridos
} dados;
//estrutura com as configuracoes do controlador
struct {
long intervaloLeitura; //intervalo de leitura dos sensores
float raioRoda; // raio da roda em mm
byte qtdPulsos; // pulsos por volta recebidos pelo sensor de velocidade
} cfg;
void enviar(String cod, String msg) {
Serial.println(" {\"" + cod + "\":\"" + msg + "\"}");
}
/*
* Funcao de regressao linear com com valores em ponto flutuante
*/
float converte(float x, float in_min, float in_max, float out_min,
float out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
const int chipSelect = 10;
/*
Abre cartao de memoria
*/
boolean abreCartao(boolean forcar) {
static boolean cartaoOK = false;
if (!cartaoOK || forcar) {
cartaoOK = SD.begin(chipSelect);
if (!cartaoOK) {
enviar("20", "Erro ao abrir o cartao SD!");
}
}
return cartaoOK;
}
| tiagopossato/telemetria | Arduino/telemetriaSerialSIMPLIFICADA/telemetria.h | C | mit | 1,144 |
<?php
namespace Wallabag\Bundle\CoreBundle\Entity;
use Doctrine\Bundle\MongoDBBundle\Validator\Constraints\Unique;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use JMS\Serializer\Annotation\Expose;
use JMS\Serializer\Annotation\Groups;
/**
* Entry
*
* @ORM\Entity
*/
class Entry
{
/**
* @var integer
*
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(type="text")
* @Expose
* @Groups({"entries"})
*/
private $url;
/**
* @var string
*
* @ORM\Column(type="text")
* @Expose
* @Groups({"entries"})
*/
private $title;
/**
* @var string
*
* @ORM\Column(type="text")
* @Expose
* @Groups({"entries"})
*/
private $content;
/**
* @var User
*
* @ORM\OneToOne(targetEntity="Wallabag\Bundle\CoreBundle\Entity\User")
*/
private $user;
/**
* @var \DateTime
* @ORM\Column(type="datetime")
* @Expose
* @Groups({"entries"})
*/
private $createdAt;
/**
* @var ArrayCollection
* @ORM\ManyToMany(targetEntity="Wallabag\Bundle\CoreBundle\Entity\Tag")
* @Expose
* @Groups({"entries"})
*/
private $tags;
/**
* @var boolean
* @ORM\Column(type="boolean")
* @Expose
* @Groups({"entries"})
*/
private $archived = false;
/**
* @var boolean
* @ORM\Column(type="boolean")
* @Expose
* @Groups({"entries"})
*/
private $deleted = false;
/**
* @var boolean
* @ORM\Column(type="boolean")
* @Expose
* @Groups({"entries"})
*/
private $starred = false;
public function __construct()
{
$this->tags = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set url
*
* @param string $url
* @return Entry
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* Get url
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set title
*
* @param string $title
* @return Entry
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set content
*
* @param string $content
* @return Entry
*/
public function setContent($content)
{
$this->content = $content;
return $this;
}
/**
* Get content
*
* @return string
*/
public function getContent()
{
return $this->content;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
* @return self
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime $createdAt
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Add tag
*
* @param \Wallabag\Bundle\CoreBundle\Entiy\Tag $tag
*/
public function addTag(\Wallabag\Bundle\CoreBundle\Entiy\Tag $tag)
{
$this->tags[] = $tag;
}
/**
* Remove tag
*
* @param \Wallabag\Bundle\CoreBundle\Entiy\Tag $tag
*/
public function removeTag(\Wallabag\Bundle\CoreBundle\Entiy\Tag $tag)
{
$this->tags->removeElement($tag);
}
public function flushTags() {
$this->tags->clear();
}
/**
* Get tags
*
* @return Tag[] $tags
*/
public function getTags()
{
return $this->tags;
}
/**
* Set archived
*
* @param boolean $archived
* @return self
*/
public function setArchived($archived)
{
$this->archived = $archived;
return $this;
}
/**
* Get archived
*
* @return boolean $archived
*/
public function getArchived()
{
return $this->archived;
}
/**
* Set deleted
*
* @param boolean $deleted
* @return self
*/
public function setDeleted($deleted)
{
$this->deleted = $deleted;
return $this;
}
/**
* Get deleted
*
* @return boolean $deleted
*/
public function getDeleted()
{
return $this->deleted;
}
/**
* Set starred
*
* @param boolean $starred
* @return self
*/
public function setStarred($starred)
{
$this->starred = $starred;
return $this;
}
/**
* Get starred
*
* @return boolean $starred
*/
public function getStarred()
{
return $this->starred;
}
/**
* Set user
*
* @param User $user
* @return self
*/
public function setUser(User $user)
{
$this->user = $user;
return $this;
}
/**
* Get user
*
* @return User $user
*/
public function getUser()
{
return $this->user;
}
}
| sylvainlg/wallabag-v2-symfony | src/Wallabag/Bundle/CoreBundle/Entity/Entry.php | PHP | mit | 5,803 |
๏ปฟusing System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
namespace CommonHelperLibrary.WEB
{
/// <summary>
/// Author : Hans.Huang
/// Date : 2012-12-03
/// Class : HttpWebDealer
/// Discription : Helper class for dealer with the http website
/// </summary>
public class HttpWebDealer
{
protected static LoggerHelper Logger = LoggerHelper.Instance;
#region GetHtml
/// <summary>
/// Get Html text by URL
/// I can't tell the encoding of page,So give me the encodeing best
/// </summary>
/// <param name="url">URL</param>
/// <param name="headers">http request headers</param>
/// <param name="txtEncoding">The Encoding suggest of webpage</param>
/// <returns></returns>
public static string GetHtml(string url, WebHeaderCollection headers = null, Encoding txtEncoding = null)
{
var html = "";
if (string.IsNullOrWhiteSpace(url)) return html;
var response = GetResponseByUrl(url,headers);
html = HttpWebDealerBase.GetHtmlFromResponse(response, txtEncoding);
return html;
}
#endregion
#region GetJsonObject
/// <summary>
/// Get Dynamic Object (json)
/// </summary>
/// <param name="url">URL</param>
/// <param name="headers">http request headers</param>
/// <param name="txtEncoding">The Encoding suggest of response</param>
/// <returns></returns>
public static dynamic GetJsonObject(string url,WebHeaderCollection headers = null, Encoding txtEncoding = null)
{
var json = GetHtml(url, headers, txtEncoding);
var jsonSerializer = new JavaScriptSerializer();
return jsonSerializer.Deserialize<dynamic>(json);
}
#endregion
#region DownloadFile
/// <summary>
/// Get file by HttpWebRequest and save it(Just for Small files those's content length less then 65K)
/// </summary>
/// <param name="fileName">File Name to save as</param>
/// <param name="url">URL</param>
/// <param name="path">The path to save the file</param>
/// <param name="timeout">Request timeout</param>
/// <param name="headers">http request header</param>
/// <returns>Success:Ture</returns>
public static bool DownloadFile(string fileName, string url, string path, int timeout, WebHeaderCollection headers = null)
{
var response = GetResponseByUrl(url, headers, timeout);
var stream = response.GetResponseStream();
if (stream == null) return false;
using (var bReader = new BinaryReader(stream))
{
var length = Int32.Parse(response.ContentLength.ToString(CultureInfo.InvariantCulture));
var byteArr = new byte[length];
//stream.Read(byteArr, 0, length);
bReader.Read(byteArr, 0, length);
//if (File.Exists(path + fileName)) File.Delete(path + fileName);
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
var fs = File.Create(path +"\\"+ fileName);
fs.Write(byteArr, 0, length);
fs.Close();
}
return true;
}
/// <summary>
/// Get file by WebClient method
/// </summary>
/// <param name="fileName">File name to save</param>
/// <param name="url">file url to download</param>
/// <param name="path">file path to save</param>
/// <param name="monitor">Monitor action for download progress</param>
/// <returns></returns>
public static bool DownloadFile(string fileName, string url, string path,
DownloadProgressChangedEventHandler monitor = null)
{
if (string.IsNullOrWhiteSpace(url)) return false;
if (!path.EndsWith("\\")) path += "\\";
using (var wc = new WebClient())
{
//if (File.Exists(path +"\\"+ fileName)) File.Delete(path +"\\"+ fileName);
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
if (monitor != null)
wc.DownloadProgressChanged += monitor;
wc.DownloadFileAsync(new Uri(url), path + fileName);
}
return true;
}
/// <summary>
/// Download largest file from url list
/// </summary>
/// <param name="fileName">File name to save</param>
/// <param name="urls">file url list to download</param>
/// <param name="path">file path to save</param>
/// <param name="monitor">Monitor action for download progress</param>
/// <returns>File Length</returns>
public static long DownloadLargestFile(string fileName, List<string> urls, string path,
DownloadProgressChangedEventHandler monitor = null)
{
if (urls == null || urls.Count == 0) return 0;
var results = new Dictionary<string, long>();
var signals = new List<EventWaitHandle>();
var locker = new object();
foreach (var url in urls)
{
var signal = new EventWaitHandle(true, EventResetMode.ManualReset);
signals.Add(signal);
var str = url;
signal.Reset();
Task.Run(() =>
{
var rsponse = GetResponseByUrl(str, null, 3000);
if (rsponse == null) return;
lock (locker)
{
results.Add(str, rsponse.ContentLength);
}
signal.Set();
});
}
signals.ForEach(s => s.WaitOne(3000));
var largest = new KeyValuePair<string, long>(string.Empty, 0);
foreach (var res in results)
{
if (res.Value > largest.Value) largest = res;
}
return DownloadFile(fileName, largest.Key, path, monitor) ? largest.Value : 0;
}
#endregion
#region GetResponseByUrl
/// <summary>
/// Get response by url
/// </summary>
/// <param name="url">URL</param>
/// <param name="headers">Request headers</param>
/// <param name="requestTimeout">Request timeout(Set to 0 for no limit)</param>
/// <returns></returns>
public static HttpWebResponse GetResponseByUrl(string url, WebHeaderCollection headers = null, int requestTimeout = 0)
{
HttpWebResponse response = null;
var request = (HttpWebRequest)WebRequest.Create(url);
if (requestTimeout > 0) request.Timeout = requestTimeout;
string postData;
HttpWebDealerBase.CorrectHeader(request, headers, out postData);
for (var i = 0; i < 3; i++)
{
try
{
HttpWebDealerBase.TryPostData(request, postData);
response = (HttpWebResponse)request.GetResponse();
return response;
}
catch (Exception e)
{
Logger.Msg("Error", url);
Logger.Exception(e);
}
Thread.Sleep(200);
}
return response;
}
#endregion
/// <summary>
/// Detects the byte order mark of a file and returns an appropriate encoding for the file.
/// </summary>
/// <param name="stream"></param>
/// <returns></returns>
public static Encoding GetEncoding(Stream stream)
{
// Use Default of Encoding.Default (Ansi CodePage)
var enc = Encoding.Default;
// Detect byte order mark if any - otherwise assume default
//var simple = new MemoryStream();
//stream.CopyTo(simple, 5);
var buffer = new byte[5];
stream.Read(buffer, 0, 5);
if (buffer[0] == 0xef && buffer[1] == 0xbb && buffer[2] == 0xbf)
enc = Encoding.UTF8;
else if (buffer[0] == 0xfe && buffer[1] == 0xff)
enc = Encoding.Unicode;
else if (buffer[0] == 0 && buffer[1] == 0 && buffer[2] == 0xfe && buffer[3] == 0xff)
enc = Encoding.UTF32;
else if (buffer[0] == 0x2b && buffer[1] == 0x2f && buffer[2] == 0x76)
enc = Encoding.UTF7;
//simple.Close();
return enc;
}
}
}
| HansHuang/MusicFM | CommonHelperLibrary/WEB/HttpWebDealer.cs | C# | mit | 9,283 |
// Endless Online Bot v0.0.1
#ifndef UTIL_HPP_INCLUDED
#define UTIL_HPP_INCLUDED
#include <math.h>
#include <vector>
#include <string>
int path_length(int x1, int y1, int x2, int y2);
std::vector<std::string> Args(std::string str);
std::string Lowercase(std::string str);
#endif // UTIL_HPP_INCLUDED
| Jimmyee/Endless-Online-Bot | util.hpp | C++ | mit | 318 |
const mutations = {
SET_ACTIVE_TAB(state, tab){
state.activeTab = tab;
},
SET_DATA_ACTIVE_TAB(state, tab){
state.hubActiveTab = tab;
},
SET_PROXY_STATE(state, proxy){
state.proxy_switch = proxy;
},
SET_INIT_INFO(state, info){
_.extend(state, info);
}
};
export default mutations;
| NSFA/ysfplatform | src/store/mutations.js | JavaScript | mit | 313 |
๏ปฟusing System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TestApp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestApp")]
[assembly: AssemblyCopyright("Copyright ยฉ 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("207e9870-0b01-4db3-b656-c4f296d939af")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| taskqueue/taskqueue-net | Src/TestApp/Properties/AssemblyInfo.cs | C# | mit | 1,390 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=Shift_JIS" />
<meta name="keywords" content="ยLย[ยยย[ยh" />
<meta name="description" content="ยรยรฎยยถ" />
<title>ยzย[ยยยyย[ยWยEย^ยCยgยย</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<!-- ยยยCยย -->
<div id="main">
<!-- ยwยbย_ย[ -->
<div id="header">
<h1>ยeยยยvยlย[ยgยยปยรฌยย ยยยยฎยรฏยรยรยzย[ยยยyย[ยWยร
ยยทยB</h1>
<table border="0" cellpadding="0" cellspacing="0" width="800">
<tr>
<td><div id="table-left"><h2><a href="#"><img src="img/logo.gif" alt="ยTยCยgยEย^ยCยgยย" border="0" /></a></h2></div></td>
<td><div id="table-right"><b>00-0000-0000</b><br /><img src="img/icon.gif" alt="icon" border="0" /> <a href="link.html">ยยยยยN</a>ย@<img src="img/icon.gif" alt="icon" border="0" /> <a href="contact.html">ยยจยรขยยขยยยรญยยน</a></div></td>
</tr>
</table>
</div>
<div id="header-menu">
<ul>
<li><a href="index.html">HOME</a></li>
<li><a href="service.html">ยTย[ยrยXยยยjยย
ย[</a></li>
<li><a href="menu.html">ยยฟยร ยรยรยยขยร</a></li>
<li><a href="#">ยยจยqยlยรยยบ</a></li>
<li><a href="#">ยรฆยยญยย ยรฉยยฟยรข</a></li>
<li><a href="#">ยAยNยZยXยรฎยรฑ</a></li>
<li><a href="sitemap.html">ยTยCยgย}ยbยv</a></li>
<li><a href="contact.html">ยยจยรขยยขยยยรญยยน</a></li>
</ul>
</div>
<center>
<img src="img/head_img_slim.jpg" alt="" class="photo01" border="0" />
</center>
<!-- ยwยbย_ย[ยIยรญยรจ -->
<!-- ยRยยยeยยยc -->
<!-- ยยยCยยยRยยยeยยยc -->
<div id="container">
<div id="contents">
<h2>ยTย[ยrยXยEยยยjยย
ย[ 1</h2>
<p>ยยฑยยฟยรงยรยรยAยยจยXยรขยรฏยรยรยTยCยgยรยรชยยยรยAยรกยยฆยรยAยTย[ยrยXยรยยยjยย
ย[ยรยรยรฐยLยรยยตยรยยญยยพยยณยยขยBยรฎยรฑยTยCยgยรยรยAยยยjยย
ย[ยรยยขยยคยRยยยeยยยcยรยKยvยรยยขยรยยขยยคยรชยยยรยAยรยรยyย[ยWยรฐยรฌยยฌยยตยรยAยucontents1.htmlยvยรยรยรยtย@ยCยยยยผยร
ยyย[ยWยรฐยรฌยรยรยรยรยยญยยพยยณยยขยB</p>
<h2>ยTย[ยrยXยEยยยjยย
ย[ 2</h2>
<p>ยยฉยoยยตยรhtmlย^ยOยรยรยยขยรยร
ยยทยยชยAยuh2ยvยรยยขยยคย^ยOยยชยยฉยoยยตย^ยCยgยยยรย^ยOยร
ยยทยBยยฑยรยuh2ยvยรฐยRยsย[ยยตยรยgยpยยทยรชยรยAยยขยยญยรงยร
ยร ยยฉยoยยตยรย^ยCยgยยยoย[ยรฐยยยรขยยทยยฑยรยยชยร
ยยซยรยยทยB</p>
<h2>ยTย[ยrยXยEยยยjยย
ย[ 3</h2>
<p>ยzย[ยยยyย[ยWยรฌยยฌย\ยtยgยรฐยยฒยยยpยรยรยรยAยยฑยรยยฉยoยยตยยชยรยOยรฃยรฐยRยsย[ยยตยรยAยยบยรย\ยรจยtยยฏยร
ยยยรขยยตยรยยขยรยรยยญยยพยยณยยขยB</p>
</div>
<!-- ยยยCยยยRยยยeยยยcยIยรญยรจ -->
<!-- ยยยjยย
ย[ -->
<div id="menu">
<div class="menulist">
<h2>ยRยยยeยยยcยEยยยjยย
ย[</h2>
<a href="index.html">HOME</a>
<a href="service.html">ยTย[ยrยXยยยjยย
ย[</a>
<a href="menu.html">ยยฟยร ยรยรยยขยร</a>
<a href="#">ยรฆยยญยย ยรฉยยฒยยฟยรข</a>
<a href="#">ยAยNยZยXยรฎยรฑ</a>
<a href="link.html">ยยยยยN</a>
<a href="sitemap.html">ยTยCยgย}ยbยv</a>
<a href="contact.html">ยยจยรขยยขยยยรญยยน</a>
</div>
<div class="menu_free">
<h2>ยtยยย[ยXยyย[ยX</h2>
<p>ยรกยยฆยรยAยoยiย[ยรฆยยยรขยAยAยNยZยXยรฎยรฑยรยรยรยยยpยร
ยยซยรฉยXยyย[ยXยร
ยยทยB</p>
</div>
<div class="menulist">
<h2>ยยจยรฐยยงยยฟยยยยยN</h2>
<a href="#">ยยย[ยยย}ยKยWยย</a>
<a href="#">ย}ยCยuยยยO</a>
</div>
</div>
<!-- ยยยjยย
ย[ยIยรญยรจ -->
</div>
<!-- ยRยยยeยยยcยIยรญยรจ -->
<!-- ยtยbย^ย[ -->
<div id="footer">
Copyright (C) 20XX SITE NAME All Rights Reserved.ย@design by <a href="http://tempnate.com/">tempnate</a>
</div>
<!-- ยtยbย^ย[ยIยรญยรจ -->
</div>
<!-- ยยยCยยยIยรญยรจ -->
</body>
</html>
| akihiro-minamino/YNU_Neutrino_HP | menu.html | HTML | mit | 3,447 |
#!/usr/bin/python
#
# Config file test app (together with test.cfg file)
#
import os, sys
sys.path.append("..")
import configfile
cfg = configfile.ConfigFile("test.cfg")
cfg.setCfgValue("name1", "value1")
cfg.setCfgValue("name2", "value2")
cfg.selectSection("user")
cfg.setCfgValue("username", "janis")
cfg.setCfgValue("acceptable_names", ["john", "janis"])
cfg.load()
print cfg.cfg.options("main")
print cfg.cfg.options("user")
print cfg.getCfgValue("username")
print type(cfg.getCfgValue("username"))
print cfg.getCfgValueAsList("acceptable_names")
print cfg.getCfgValueAsList("list_in_list")
cfg.selectSection("main")
print cfg.getCfgValueAsInt("a_number")
print type(cfg.getCfgValueAsInt("a_number"))
print cfg.getCfgValueAsBool("a_bool")
print type(cfg.getCfgValueAsBool("a_bool"))
cfg.filename = "test-mod.cfg"
cfg.selectSection("main")
cfg.setCfgValue("name1", "value1mod2")
cfg.setCfgValue("a_number", 14)
cfg.selectSection("user")
cfg.setCfgValue("acceptable_names", ["john", "janis", "ivan"])
cfg.setCfgValue("list_in_list2", ["[baz]", "[foo, bar]"])
cfg.setCfgValue("list_in_list3", ["first", "[second-one, second-third]"])
cfg.save()
| IECS/MansOS | tools/lib/tests/configtest.py | Python | mit | 1,154 |
# frozen_string_literal: true
require "dis/jobs/delete"
require "dis/jobs/store"
require "dis/jobs/change_type"
| elektronaut/dis | lib/dis/jobs.rb | Ruby | mit | 113 |
<?php
namespace AppBundle\Security\Core\User;
use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface;
use HWI\Bundle\OAuthBundle\Security\Core\User\FOSUBUserProvider as BaseClass;
use Symfony\Component\Security\Core\User\UserInterface;
class FOSUBUserProvider extends BaseClass
{
/**
* {@inheritDoc}
*/
public function connect(UserInterface $user, UserResponseInterface $response)
{
$property = $this->getProperty($response);
$username = $response->getUsername();
$previousUser = $this->userManager->findUserBy(array($property => $username));
var_dump(
$property,
$response->getProfilePicture(),
$response->getRealName(),
$response->getNickname(),
$response->getUsername(),
$previousUser
);
//on connect - get the access token and the user ID
$service = $response->getResourceOwner()->getName();
//we "disconnect" previously connected users
if (null !== $previousUser = $this->userManager->findUserBy(array($property => $username,'auth_type'=>$service))) {
$previousUser->setAccessToken($response->getAccessToken());
$this->userManager->updateUser($previousUser);
}
}
/**
* {@inheritdoc}
*/
public function loadUserByOAuthUserResponse(UserResponseInterface $response)
{
$username = $response->getUsername();
$service = $response->getResourceOwner()->getName();
$user = $this->userManager->findUserBy(array($this->getProperty($response) => $username,'auth_type'=>$service));
//when the user is registrating
if (null === $user) {
$user = $this->userManager->createUser();
$user->setUid($username);
$user->setAccessToken($response->getAccessToken());
$user->setAuthType($service);
//I have set all requested data with the user's username
//modify here with relevant data
$user->setUsername($response->getRealName());
$user->setUsernameCanonical($username);
$user->setEmail($response->getEmail());
if($service=="facebook"){
$user->setPicture("https://graph.facebook.com/$username/picture");
}else{
$user->setPicture($response->getProfilePicture());
}
$user->setPassword($username);
$user->setEnabled(true);
$this->userManager->updateUser($user);
return $user;
}
//if user exists - go with the HWIOAuth way
$user = parent::loadUserByOAuthUserResponse($response);
//update access token
$user->setAccessToken($response->getAccessToken());
return $user;
}
} | lahiiru/Quota | src/AppBundle/Security/Core/User/FOSUBUserProvider.php | PHP | mit | 2,811 |
<?php
namespace Db\User;
use Core\Query;
class GetUnconfirmedUsers extends Query
{
protected $id;
protected function build()
{
$query = '
SELECT
u.id,
u.type,
u.email,
u.email_confirmed,
u.email_confirmation_hash,
u.account_confirmed,
u.password,
u.language,
u.first_name,
u.last_name,
u.department,
IFNULL(u.portrait_file_id, cnfg.value) AS portrait_file_id,
u.created
FROM
users u
JOIN configs cnfg ON cnfg.key = \'default_portrait_id\'
WHERE
u.email_confirmed = 1
AND u.account_confirmed = 0';
return $query;
}
} | dnl-jst/ownsocial | library/Db/User/GetUnconfirmedUsers.php | PHP | mit | 606 |
<?php
echo __DIR__;
require dirname(__DIR__) . "/HikerCommand.php";
function _manually_load_plugin() {
require dirname( __FILE__ ) . '/../hikerquotes.php';
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php';
| jasonrhodes/wphackerguide | public/content/plugins/hikerquotes/tests/bootstrap.php | PHP | mit | 292 |
// home page
exports.index = function(req, res){
res.render('index', { title: 'B O X L A N D' });
}; | Thomas-Elder/bo-xy | server/controllers/indexController.js | JavaScript | mit | 102 |
'use strict';
/**
* Module dependencies.
*/
var express = require('express'),
mean = require('meanio'),
consolidate = require('consolidate'),
mongoStore = require('connect-mongo')(express),
flash = require('connect-flash'),
helpers = require('view-helpers'),
config = require('./config'),
expressValidator = require('express-validator'),
appPath = process.cwd(),
fs = require('fs'),
assetmanager = require('assetmanager');
module.exports = function(app, passport, db) {
app.set('showStackError', true);
// Prettify HTML
app.locals.pretty = true;
// cache=memory or swig dies in NODE_ENV=production
app.locals.cache = 'memory';
// Should be placed before express.static
// To ensure that all assets and data are compressed (utilize bandwidth)
app.use(express.compress({
filter: function(req, res) {
return (/json|text|javascript|css/).test(res.getHeader('Content-Type'));
},
// Levels are specified in a range of 0 to 9, where-as 0 is
// no compression and 9 is best compression, but slowest
level: 9
}));
// Only use logger for development environment
if (process.env.NODE_ENV === 'development') {
app.use(express.logger('dev'));
}
// assign the template engine to .html files
app.engine('html', consolidate[config.templateEngine]);
// set .html as the default extension
app.set('view engine', 'html');
// Set views path, template engine and default layout
app.set('views', config.root + '/server/views');
// Enable jsonp
app.enable('jsonp callback');
app.configure(function() {
// The cookieParser should be above session
app.use(express.cookieParser());
// Request body parsing middleware should be above methodOverride
app.use(express.urlencoded());
app.use(express.json());
app.use(expressValidator());
app.use(express.methodOverride());
// Import your asset file
var assets = require('./assets.json');
assetmanager.init({
js: assets.js,
css: assets.css,
debug: (process.env.NODE_ENV !== 'production'),
webroot: 'public/public'
});
// Add assets to local variables
app.use(function(req, res, next) {
res.locals({
assets: assetmanager.assets
});
next();
});
// Express/Mongo session storage
app.use(express.session({
secret: config.sessionSecret,
store: new mongoStore({
db: db.connection.db,
collection: config.sessionCollection
})
}));
// Dynamic helpers
app.use(helpers(config.app.name));
// Use passport session
app.use(passport.initialize());
app.use(passport.session());
//mean middleware from modules before routes
app.use(mean.chainware.before);
// Connect flash for flash messages
app.use(flash());
// Routes should be at the last
app.use(app.router);
// Setting the fav icon and static folder
app.use(express.favicon());
app.use('/public', express.static(config.root + '/public'));
app.get('/modules/aggregated.js', function(req, res) {
res.setHeader('content-type', 'text/javascript');
res.send(mean.aggregated.js);
});
app.get('/modules/aggregated.css', function(req, res) {
res.setHeader('content-type', 'text/css');
res.send(mean.aggregated.css);
});
mean.events.on('modulesFound', function() {
mean.modules.forEach(function(module) {
app.use('/' + module.name, express.static(config.root + '/node_modules/' + module.name + '/public'));
});
bootstrapRoutes();
//mean middlware from modules after routes
app.use(mean.chainware.after);
// Assume "not found" in the error msgs is a 404. this is somewhat
// silly, but valid, you can do whatever you like, set properties,
// use instanceof etc.
app.use(function(err, req, res, next) {
// Treat as 404
if (~err.message.indexOf('not found')) return next();
// Log it
console.error(err.stack);
// Error page
res.status(500).render('500', {
error: err.stack
});
});
// Assume 404 since no middleware responded
app.use(function(req, res) {
res.status(404).render('404', {
url: req.originalUrl,
error: 'Not found'
});
});
});
});
function bootstrapRoutes() {
var routes_path = appPath + '/server/routes';
var walk = function(path) {
fs.readdirSync(path).forEach(function(file) {
var newPath = path + '/' + file;
var stat = fs.statSync(newPath);
if (stat.isFile()) {
if (/(.*)\.(js$|coffee$)/.test(file)) {
require(newPath)(app, passport);
}
// We skip the app/routes/middlewares directory as it is meant to be
// used and shared by routes as further middlewares and is not a
// route by itself
} else if (stat.isDirectory() && file !== 'middlewares') {
walk(newPath);
}
});
};
walk(routes_path);
}
}; | tmcelreath/meanCity | server/config/express.js | JavaScript | mit | 5,758 |
module Marty
module Promises
module Ruby
end
end
end
| arman000/marty | app/services/marty/promises/ruby.rb | Ruby | mit | 65 |
package prometheusremotewrite
import (
"bytes"
"fmt"
"github.com/gogo/protobuf/proto"
"github.com/golang/snappy"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/prompb"
"strings"
"testing"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/require"
)
func TestRemoteWriteSerialize(t *testing.T) {
tests := []struct {
name string
config FormatConfig
metric telegraf.Metric
expected []byte
}{
{
name: "simple",
metric: testutil.MustMetric(
"cpu",
map[string]string{
"host": "example.org",
},
map[string]interface{}{
"time_idle": 42.0,
},
time.Unix(0, 0),
),
expected: []byte(`
cpu_time_idle{host="example.org"} 42
`),
},
{
name: "prometheus input untyped",
metric: testutil.MustMetric(
"prometheus",
map[string]string{
"code": "400",
"method": "post",
},
map[string]interface{}{
"http_requests_total": 3.0,
},
time.Unix(0, 0),
telegraf.Untyped,
),
expected: []byte(`
http_requests_total{code="400", method="post"} 3
`),
},
{
name: "prometheus input counter",
metric: testutil.MustMetric(
"prometheus",
map[string]string{
"code": "400",
"method": "post",
},
map[string]interface{}{
"http_requests_total": 3.0,
},
time.Unix(0, 0),
telegraf.Counter,
),
expected: []byte(`
http_requests_total{code="400", method="post"} 3
`),
},
{
name: "prometheus input gauge",
metric: testutil.MustMetric(
"prometheus",
map[string]string{
"code": "400",
"method": "post",
},
map[string]interface{}{
"http_requests_total": 3.0,
},
time.Unix(0, 0),
telegraf.Gauge,
),
expected: []byte(`
http_requests_total{code="400", method="post"} 3
`),
},
{
name: "prometheus input histogram no buckets",
metric: testutil.MustMetric(
"prometheus",
map[string]string{},
map[string]interface{}{
"http_request_duration_seconds_sum": 53423,
"http_request_duration_seconds_count": 144320,
},
time.Unix(0, 0),
telegraf.Histogram,
),
expected: []byte(`
http_request_duration_seconds_count 144320
http_request_duration_seconds_sum 53423
http_request_duration_seconds_bucket{le="+Inf"} 144320
`),
},
{
name: "prometheus input histogram only bucket",
metric: testutil.MustMetric(
"prometheus",
map[string]string{
"le": "0.5",
},
map[string]interface{}{
"http_request_duration_seconds_bucket": 129389.0,
},
time.Unix(0, 0),
telegraf.Histogram,
),
expected: []byte(`
http_request_duration_seconds_count 0
http_request_duration_seconds_sum 0
http_request_duration_seconds_bucket{le="+Inf"} 0
http_request_duration_seconds_bucket{le="0.5"} 129389
`),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s, err := NewSerializer(FormatConfig{
MetricSortOrder: SortMetrics,
StringHandling: tt.config.StringHandling,
})
require.NoError(t, err)
data, err := s.Serialize(tt.metric)
actual, err := prompbToText(data)
require.NoError(t, err)
require.Equal(t, strings.TrimSpace(string(tt.expected)),
strings.TrimSpace(string(actual)))
})
}
}
func TestRemoteWriteSerializeBatch(t *testing.T) {
tests := []struct {
name string
config FormatConfig
metrics []telegraf.Metric
expected []byte
}{
{
name: "simple",
metrics: []telegraf.Metric{
testutil.MustMetric(
"cpu",
map[string]string{
"host": "one.example.org",
},
map[string]interface{}{
"time_idle": 42.0,
},
time.Unix(0, 0),
),
testutil.MustMetric(
"cpu",
map[string]string{
"host": "two.example.org",
},
map[string]interface{}{
"time_idle": 42.0,
},
time.Unix(0, 0),
),
},
expected: []byte(`
cpu_time_idle{host="one.example.org"} 42
cpu_time_idle{host="two.example.org"} 42
`),
},
{
name: "multiple metric families",
metrics: []telegraf.Metric{
testutil.MustMetric(
"cpu",
map[string]string{
"host": "one.example.org",
},
map[string]interface{}{
"time_idle": 42.0,
"time_guest": 42.0,
},
time.Unix(0, 0),
),
},
expected: []byte(`
cpu_time_guest{host="one.example.org"} 42
cpu_time_idle{host="one.example.org"} 42
`),
},
{
name: "histogram",
metrics: []telegraf.Metric{
testutil.MustMetric(
"prometheus",
map[string]string{},
map[string]interface{}{
"http_request_duration_seconds_sum": 53423,
"http_request_duration_seconds_count": 144320,
},
time.Unix(0, 0),
telegraf.Histogram,
),
testutil.MustMetric(
"prometheus",
map[string]string{"le": "0.05"},
map[string]interface{}{
"http_request_duration_seconds_bucket": 24054.0,
},
time.Unix(0, 0),
telegraf.Histogram,
),
testutil.MustMetric(
"prometheus",
map[string]string{"le": "0.1"},
map[string]interface{}{
"http_request_duration_seconds_bucket": 33444.0,
},
time.Unix(0, 0),
telegraf.Histogram,
),
testutil.MustMetric(
"prometheus",
map[string]string{"le": "0.2"},
map[string]interface{}{
"http_request_duration_seconds_bucket": 100392.0,
},
time.Unix(0, 0),
telegraf.Histogram,
),
testutil.MustMetric(
"prometheus",
map[string]string{"le": "0.5"},
map[string]interface{}{
"http_request_duration_seconds_bucket": 129389.0,
},
time.Unix(0, 0),
telegraf.Histogram,
),
testutil.MustMetric(
"prometheus",
map[string]string{"le": "1.0"},
map[string]interface{}{
"http_request_duration_seconds_bucket": 133988.0,
},
time.Unix(0, 0),
telegraf.Histogram,
),
testutil.MustMetric(
"prometheus",
map[string]string{"le": "+Inf"},
map[string]interface{}{
"http_request_duration_seconds_bucket": 144320.0,
},
time.Unix(0, 0),
telegraf.Histogram,
),
},
expected: []byte(`
http_request_duration_seconds_count 144320
http_request_duration_seconds_sum 53423
http_request_duration_seconds_bucket{le="+Inf"} 144320
http_request_duration_seconds_bucket{le="0.05"} 24054
http_request_duration_seconds_bucket{le="0.1"} 33444
http_request_duration_seconds_bucket{le="0.2"} 100392
http_request_duration_seconds_bucket{le="0.5"} 129389
http_request_duration_seconds_bucket{le="1"} 133988
`),
},
{
name: "summary with quantile",
metrics: []telegraf.Metric{
testutil.MustMetric(
"prometheus",
map[string]string{},
map[string]interface{}{
"rpc_duration_seconds_sum": 1.7560473e+07,
"rpc_duration_seconds_count": 2693,
},
time.Unix(0, 0),
telegraf.Summary,
),
testutil.MustMetric(
"prometheus",
map[string]string{"quantile": "0.01"},
map[string]interface{}{
"rpc_duration_seconds": 3102.0,
},
time.Unix(0, 0),
telegraf.Summary,
),
testutil.MustMetric(
"prometheus",
map[string]string{"quantile": "0.05"},
map[string]interface{}{
"rpc_duration_seconds": 3272.0,
},
time.Unix(0, 0),
telegraf.Summary,
),
testutil.MustMetric(
"prometheus",
map[string]string{"quantile": "0.5"},
map[string]interface{}{
"rpc_duration_seconds": 4773.0,
},
time.Unix(0, 0),
telegraf.Summary,
),
testutil.MustMetric(
"prometheus",
map[string]string{"quantile": "0.9"},
map[string]interface{}{
"rpc_duration_seconds": 9001.0,
},
time.Unix(0, 0),
telegraf.Summary,
),
testutil.MustMetric(
"prometheus",
map[string]string{"quantile": "0.99"},
map[string]interface{}{
"rpc_duration_seconds": 76656.0,
},
time.Unix(0, 0),
telegraf.Summary,
),
},
expected: []byte(`
rpc_duration_seconds_count 2693
rpc_duration_seconds_sum 17560473
rpc_duration_seconds{quantile="0.01"} 3102
rpc_duration_seconds{quantile="0.05"} 3272
rpc_duration_seconds{quantile="0.5"} 4773
rpc_duration_seconds{quantile="0.9"} 9001
rpc_duration_seconds{quantile="0.99"} 76656
`),
},
{
name: "newer sample",
metrics: []telegraf.Metric{
testutil.MustMetric(
"cpu",
map[string]string{},
map[string]interface{}{
"time_idle": 43.0,
},
time.Unix(1, 0),
),
testutil.MustMetric(
"cpu",
map[string]string{},
map[string]interface{}{
"time_idle": 42.0,
},
time.Unix(0, 0),
),
},
expected: []byte(`
cpu_time_idle 43
`),
},
{
name: "colons are not replaced in metric name from measurement",
metrics: []telegraf.Metric{
testutil.MustMetric(
"cpu::xyzzy",
map[string]string{},
map[string]interface{}{
"time_idle": 42.0,
},
time.Unix(0, 0),
),
},
expected: []byte(`
cpu::xyzzy_time_idle 42
`),
},
{
name: "colons are not replaced in metric name from field",
metrics: []telegraf.Metric{
testutil.MustMetric(
"cpu",
map[string]string{},
map[string]interface{}{
"time:idle": 42.0,
},
time.Unix(0, 0),
),
},
expected: []byte(`
cpu_time:idle 42
`),
},
{
name: "invalid label",
metrics: []telegraf.Metric{
testutil.MustMetric(
"cpu",
map[string]string{
"host-name": "example.org",
},
map[string]interface{}{
"time_idle": 42.0,
},
time.Unix(0, 0),
),
},
expected: []byte(`
cpu_time_idle{host_name="example.org"} 42
`),
},
{
name: "colons are replaced in label name",
metrics: []telegraf.Metric{
testutil.MustMetric(
"cpu",
map[string]string{
"host:name": "example.org",
},
map[string]interface{}{
"time_idle": 42.0,
},
time.Unix(0, 0),
),
},
expected: []byte(`
cpu_time_idle{host_name="example.org"} 42
`),
},
{
name: "discard strings",
metrics: []telegraf.Metric{
testutil.MustMetric(
"cpu",
map[string]string{},
map[string]interface{}{
"time_idle": 42.0,
"cpu": "cpu0",
},
time.Unix(0, 0),
),
},
expected: []byte(`
cpu_time_idle 42
`),
},
{
name: "string as label",
config: FormatConfig{
MetricSortOrder: SortMetrics,
StringHandling: StringAsLabel,
},
metrics: []telegraf.Metric{
testutil.MustMetric(
"cpu",
map[string]string{},
map[string]interface{}{
"time_idle": 42.0,
"cpu": "cpu0",
},
time.Unix(0, 0),
),
},
expected: []byte(`
cpu_time_idle{cpu="cpu0"} 42
`),
},
{
name: "string as label duplicate tag",
config: FormatConfig{
MetricSortOrder: SortMetrics,
StringHandling: StringAsLabel,
},
metrics: []telegraf.Metric{
testutil.MustMetric(
"cpu",
map[string]string{
"cpu": "cpu0",
},
map[string]interface{}{
"time_idle": 42.0,
"cpu": "cpu1",
},
time.Unix(0, 0),
),
},
expected: []byte(`
cpu_time_idle{cpu="cpu0"} 42
`),
},
{
name: "replace characters when using string as label",
config: FormatConfig{
MetricSortOrder: SortMetrics,
StringHandling: StringAsLabel,
},
metrics: []telegraf.Metric{
testutil.MustMetric(
"cpu",
map[string]string{},
map[string]interface{}{
"host:name": "example.org",
"time_idle": 42.0,
},
time.Unix(1574279268, 0),
),
},
expected: []byte(`
cpu_time_idle{host_name="example.org"} 42
`),
},
{
name: "multiple fields grouping",
metrics: []telegraf.Metric{
testutil.MustMetric(
"cpu",
map[string]string{
"cpu": "cpu0",
},
map[string]interface{}{
"time_guest": 8106.04,
"time_system": 26271.4,
"time_user": 92904.33,
},
time.Unix(0, 0),
),
testutil.MustMetric(
"cpu",
map[string]string{
"cpu": "cpu1",
},
map[string]interface{}{
"time_guest": 8181.63,
"time_system": 25351.49,
"time_user": 96912.57,
},
time.Unix(0, 0),
),
testutil.MustMetric(
"cpu",
map[string]string{
"cpu": "cpu2",
},
map[string]interface{}{
"time_guest": 7470.04,
"time_system": 24998.43,
"time_user": 96034.08,
},
time.Unix(0, 0),
),
testutil.MustMetric(
"cpu",
map[string]string{
"cpu": "cpu3",
},
map[string]interface{}{
"time_guest": 7517.95,
"time_system": 24970.82,
"time_user": 94148,
},
time.Unix(0, 0),
),
},
expected: []byte(`
cpu_time_guest{cpu="cpu0"} 8106.04
cpu_time_system{cpu="cpu0"} 26271.4
cpu_time_user{cpu="cpu0"} 92904.33
cpu_time_guest{cpu="cpu1"} 8181.63
cpu_time_system{cpu="cpu1"} 25351.49
cpu_time_user{cpu="cpu1"} 96912.57
cpu_time_guest{cpu="cpu2"} 7470.04
cpu_time_system{cpu="cpu2"} 24998.43
cpu_time_user{cpu="cpu2"} 96034.08
cpu_time_guest{cpu="cpu3"} 7517.95
cpu_time_system{cpu="cpu3"} 24970.82
cpu_time_user{cpu="cpu3"} 94148
`),
},
{
name: "summary with no quantile",
metrics: []telegraf.Metric{
testutil.MustMetric(
"prometheus",
map[string]string{},
map[string]interface{}{
"rpc_duration_seconds_sum": 1.7560473e+07,
"rpc_duration_seconds_count": 2693,
},
time.Unix(0, 0),
telegraf.Summary,
),
},
expected: []byte(`
rpc_duration_seconds_count 2693
rpc_duration_seconds_sum 17560473
`),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s, err := NewSerializer(FormatConfig{
MetricSortOrder: SortMetrics,
StringHandling: tt.config.StringHandling,
})
require.NoError(t, err)
data, err := s.SerializeBatch(tt.metrics)
require.NoError(t, err)
actual, err := prompbToText(data)
require.NoError(t, err)
require.Equal(t,
strings.TrimSpace(string(tt.expected)),
strings.TrimSpace(string(actual)))
})
}
}
func prompbToText(data []byte) ([]byte, error) {
var buf = bytes.Buffer{}
protobuff, err := snappy.Decode(nil, data)
if err != nil {
return nil, err
}
var req prompb.WriteRequest
err = proto.Unmarshal(protobuff, &req)
if err != nil {
return nil, err
}
samples := protoToSamples(&req)
for _, sample := range samples {
buf.Write([]byte(fmt.Sprintf("%s %s\n", sample.Metric.String(), sample.Value.String())))
}
if err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func protoToSamples(req *prompb.WriteRequest) model.Samples {
var samples model.Samples
for _, ts := range req.Timeseries {
metric := make(model.Metric, len(ts.Labels))
for _, l := range ts.Labels {
metric[model.LabelName(l.Name)] = model.LabelValue(l.Value)
}
for _, s := range ts.Samples {
samples = append(samples, &model.Sample{
Metric: metric,
Value: model.SampleValue(s.Value),
Timestamp: model.Time(s.Timestamp),
})
}
}
return samples
}
| marianob85/telegraf | plugins/serializers/prometheusremotewrite/prometheusremotewrite_test.go | GO | mit | 15,051 |
package org.nem.core.model;
import org.nem.core.utils.ArrayUtils;
import java.util.Comparator;
/**
* A custom comparator for comparing MultisigSignatureTransaction objects.
* <br>
* This comparator only looks at the transaction signer and other hash.
*/
public class MultisigSignatureTransactionComparator implements Comparator<MultisigSignatureTransaction> {
@Override
public int compare(final MultisigSignatureTransaction lhs, final MultisigSignatureTransaction rhs) {
final Address lhsAddress = lhs.getSigner().getAddress();
final Address rhsAddress = rhs.getSigner().getAddress();
final int addressCompareResult = lhsAddress.compareTo(rhsAddress);
if (addressCompareResult != 0) {
return addressCompareResult;
}
return ArrayUtils.compare(lhs.getOtherTransactionHash().getRaw(), rhs.getOtherTransactionHash().getRaw());
}
}
| NewEconomyMovement/nem.core | src/main/java/org/nem/core/model/MultisigSignatureTransactionComparator.java | Java | mit | 854 |
body {
padding-top: 65px;
}
#footer {
padding: 10px;
color: #333;
}
#titulo {
color: #fff;
}
#textoSobreNosotros {
color: #333;
}
#login-buttons a, .accounts-dialog a {
color: rgb(0, 0, 0);
text-decoration: none;
text-align: center;
vertical-align: middle;
line-height: 50px;
padding: 20px;
}
#submit {
background-color: #f4511e;
color: #fff;
}
#formGraffiti {
border: 2px solid #f4511e;
border-radius: 12px;
padding-top: 20px;
padding-right: 20px;
}
#agregarGraffiti {
padding-top: 0;
}
#misGraffitis {
padding-top: 0;
padding-bottom: 5px;
}
#buscarGraffitis {
padding-top: 0;
}
#textJumbotron {
color: #fff;
}
#textJumbotronUsuario {
color: #fff;
}
.map-container {
width: 800px;
max-width: 100%;
height: 500px;
margin: 0 auto;
}
.navbar {
margin-bottom: 0;
background-color: #f4511e;
z-index: 9999;
border: 0;
font-size: 12px !important;
line-height: 1.42857143 !important;
letter-spacing: 4px;
border-radius: 0;
}
.navbar-nav li a:hover, .navbar-nav li.active a {
color: #f4511e !important;
background-color: #fff !important;
}
.navbar-default .navbar-toggle {
border-color: transparent;
color: #fff !important;
}
.container .jumbotron, .container-fluid .jumbotron {
background-color: #f4511e;
}
.jumbotron {
background-color: #f4511e;
color: #fff;
padding: 100px 25px;
}
.container-fluid {
padding: 60px 50px;
}
.jumbotron h1 {
color: #fff;
}
.bg-grey {
background-color: #f6f6f6;
}
div.jumbotron.text-center {
margin-bottom: 0;
}
ol, ul {
display: inline-block;
margin-left: auto;
margin-right: auto;
}
.react-tags {
position: relative;
padding: 6px 0 0 6px;
border: 1px solid #D1D1D1;
border-radius: 1px;
/* shared font styles */
font-size: 1em;
line-height: 1.2;
/* clicking anywhere will focus the input */
cursor: text;
}
.react-tags.is-focused {
border-color: #B1B1B1;
}
.react-tags__selected {
display: inline;
}
.react-tags__selected-tag {
display: inline-block;
box-sizing: border-box;
margin: 0 6px 6px 0;
padding: 6px 8px;
border: 1px solid #D1D1D1;
border-radius: 2px;
background: #F1F1F1;
/* match the font styles */
font-size: inherit;
line-height: inherit;
}
.react-tags__selected-tag:after {
content: '\2715';
color: #AAA;
margin-left: 8px;
}
.react-tags__selected-tag:hover,
.react-tags__selected-tag:focus {
border-color: #B1B1B1;
}
.react-tags__search {
display: inline-block;
/* match tag layout */
padding: 7px 2px;
margin-bottom: 6px;
/* prevent autoresize overflowing the container */
max-width: 100%;
}
@media screen and (min-width: 30em) {
.react-tags__search {
/* this will become the offsetParent for suggestions */
position: relative;
}
}
.react-tags__search input {
/* prevent autoresize overflowing the container */
max-width: 100%;
/* remove styles and layout from this element */
margin: 0;
padding: 0;
border: 0;
outline: none;
/* match the font styles */
font-size: inherit;
line-height: inherit;
}
.react-tags__search input::-ms-clear {
display: none;
}
.react-tags__suggestions {
position: absolute;
top: 100%;
left: 80%;
width: 100%;
}
@media screen and (min-width: 30em) {
.react-tags__suggestions {
width: 240px;
}
}
.react-tags__suggestions ul {
margin: 4px -1px;
padding: 0;
list-style: none;
background: white;
border: 1px solid #D1D1D1;
border-radius: 2px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.react-tags__suggestions li {
border-bottom: 1px solid #ddd;
padding: 6px 8px;
}
.react-tags__suggestions li mark {
text-decoration: underline;
background: none;
font-weight: 600;
}
.react-tags__suggestions li:hover {
cursor: pointer;
background: #eee;
}
.react-tags__suggestions li.is-active {
background: #b7cfe0;
}
.react-tags__suggestions li.is-disabled {
opacity: 0.5;
cursor: auto;
}
.votingGraffiti1 {
padding: 50px;
float: left;
}
.votingGraffiti2 {
padding: 50px;
float: right;
}
.nuevos {
margin: 10px;
border-radius: 25px;
border: 2px solid #d34615;
padding: 20px;
}
.revelacion {
margin: 10px;
border-radius: 25px;
border: 2px solid #d34615;
padding: 20px;
}
.creativo {
margin: 10px;
border-radius: 25px;
border: 2px solid #d34615;
padding: 20px;
}
.inspirador {
margin: 10px;
border-radius: 25px;
border: 2px solid #d34615;
padding: 20px;
}
/* CSS declarations go here */
/*! normalize.css v4.1.1 | MIT License | github.com/necolas/normalize.css */
/**
* 1. Change the default font family in all browsers (opinionated).
* 2. Prevent adjustments of font size after orientation changes in IE and iOS.
*/
html {
font-family: sans-serif; /* 1 */
-ms-text-size-adjust: 100%; /* 2 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/**
* Remove the margin in all browsers (opinionated).
*/
body {
margin: 0;
}
/* HTML5 display definitions
========================================================================== */
/**
* Add the correct display in IE 9-.
* 1. Add the correct display in Edge, IE, and Firefox.
* 2. Add the correct display in IE.
*/
article,
aside,
details, /* 1 */
figcaption,
figure,
footer,
header,
main, /* 2 */
menu,
nav,
section,
summary { /* 1 */
display: block;
}
/**
* Add the correct display in IE 9-.
*/
audio,
canvas,
progress,
video {
display: inline-block;
}
/**
* Add the correct display in iOS 4-7.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/**
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/
progress {
vertical-align: baseline;
}
/**
* Add the correct display in IE 10-.
* 1. Add the correct display in IE.
*/
template, /* 1 */
[hidden] {
display: none;
}
/* Links
========================================================================== */
/**
* 1. Remove the gray background on active links in IE 10.
* 2. Remove gaps in links underline in iOS 8+ and Safari 8+.
*/
a {
background-color: transparent; /* 1 */
-webkit-text-decoration-skip: objects; /* 2 */
}
/**
* Remove the outline on focused links when they are also active or hovered
* in all browsers (opinionated).
*/
a:active,
a:hover {
outline-width: 0;
}
/* Text-level semantics
========================================================================== */
/**
* 1. Remove the bottom border in Firefox 39-.
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none; /* 1 */
text-decoration: underline; /* 2 */
text-decoration: underline dotted; /* 2 */
}
/**
* Prevent the duplicate application of `bolder` by the next rule in Safari 6.
*/
b,
strong {
font-weight: inherit;
}
/**
* Add the correct font weight in Chrome, Edge, and Safari.
*/
b,
strong {
font-weight: bolder;
}
/**
* Add the correct font style in Android 4.3-.
*/
dfn {
font-style: italic;
}
/**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/**
* Add the correct background and color in IE 9-.
*/
mark {
background-color: #ff0;
color: #000;
}
/**
* Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/* Embedded content
========================================================================== */
/**
* Remove the border on images inside links in IE 10-.
*/
img {
border-style: none;
}
/**
* Hide the overflow in IE.
*/
svg:not(:root) {
overflow: hidden;
}
/* Grouping content
========================================================================== */
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
pre,
samp {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/**
* Add the correct margin in IE 8.
*/
figure {
margin: 1em 40px;
}
/**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/
hr {
box-sizing: content-box; /* 1 */
height: 0; /* 1 */
overflow: visible; /* 2 */
}
/* Forms
========================================================================== */
/**
* 1. Change font properties to `inherit` in all browsers (opinionated).
* 2. Remove the margin in Firefox and Safari.
*/
button,
input,
select,
textarea {
font: inherit; /* 1 */
margin: 0; /* 2 */
}
/**
* Restore the font weight unset by the previous rule.
*/
optgroup {
font-weight: bold;
}
/**
* Show the overflow in IE.
* 1. Show the overflow in Edge.
*/
button,
input { /* 1 */
overflow: visible;
}
/**
* Remove the inheritance of text transform in Edge, Firefox, and IE.
* 1. Remove the inheritance of text transform in Firefox.
*/
button,
select { /* 1 */
text-transform: none;
}
/**
* 1. Prevent a WebKit bug where (2) destroys native `audio` and `video`
* controls in Android 4.
* 2. Correct the inability to style clickable types in iOS and Safari.
*/
button,
html [type="button"], /* 1 */
[type="reset"],
[type="submit"] {
-webkit-appearance: button; /* 2 */
}
/**
* Remove the inner border and padding in Firefox.
*/
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
/**
* Restore the focus styles unset by the previous rule.
*/
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
}
/**
* Change the border, margin, and padding in all browsers (opinionated).
*/
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
/**
* 1. Correct the text wrapping in Edge and IE.
* 2. Correct the color inheritance from `fieldset` elements in IE.
* 3. Remove the padding so developers are not caught out when they zero out
* `fieldset` elements in all browsers.
*/
legend {
box-sizing: border-box; /* 1 */
color: inherit; /* 2 */
display: table; /* 1 */
max-width: 100%; /* 1 */
padding: 0; /* 3 */
white-space: normal; /* 1 */
}
/**
* Remove the default vertical scrollbar in IE.
*/
textarea {
overflow: auto;
}
/**
* 1. Add the correct box sizing in IE 10-.
* 2. Remove the padding in IE 10-.
*/
[type="checkbox"],
[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Correct the odd appearance in Chrome and Safari.
* 2. Correct the outline style in Safari.
*/
[type="search"] {
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
}
/**
* Remove the inner padding and cancel buttons in Chrome and Safari on OS X.
*/
[type="search"]::-webkit-search-cancel-button,
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* Correct the text style of placeholders in Chrome, Edge, and Safari.
*/
::-webkit-input-placeholder {
color: inherit;
opacity: 0.54;
}
/**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
}
header {
background: #EEE;
padding: 20px;
text-align: center;
}
h1 {
margin: 0;
}
main {
max-width: 1000px;
margin: 0 auto;
padding: 20px;
}
input[type='text'] {
width: 45%;
}
button[type='submit'] {
width: 100%;
border: solid 1px #111;
background: #FFF;
margin-top: 10px;
}
.item {
margin-top: 20px;
background: #FFF;
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
padding: 20px;
display: flex;
justify-content: space-between;
}
.item p {
font-size: 18px;
margin: 0;
}
.item div {
width: 40%;
cursor: pointer;
padding: 5px;
text-align: center;
transition: 0.3s ease all;
border-bottom: solid 10px;
}
.item .vote-one {
border-bottom-color: blue;
}
.item .vote-two {
border-bottom-color: red;
}
.item > span {
font-style: italic;
color: #CCC;
}
.item div:hover {
background: #EEE;
}
| vek/Graffitis | client/main.css | CSS | mit | 12,637 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>cfgv: Not compatible</title>
<link rel="shortcut icon" type="image/png" href="../../../../../favicon.png" />
<link href="../../../../../bootstrap.min.css" rel="stylesheet">
<link href="../../../../../bootstrap-custom.css" rel="stylesheet">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<script src="../../../../../moment.min.js"></script>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="../../../../.."><i class="fa fa-lg fa-flag-checkered"></i> Coq bench</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="../..">clean / released</a></li>
<li class="active"><a href="">8.8.2 / cfgv - 8.7.0</a></li>
</ul>
</div>
</div>
</div>
<div class="article">
<div class="row">
<div class="col-md-12">
<a href="../..">ยซ Up</a>
<h1>
cfgv
<small>
8.7.0
<span class="label label-info">Not compatible</span>
</small>
</h1>
<p><em><script>document.write(moment("2020-03-05 01:02:10 +0000", "YYYY-MM-DD HH:mm:ss Z").fromNow());</script> (2020-03-05 01:02:10 UTC)</em><p>
<h2>Context</h2>
<pre># Packages matching: installed
# Name # Installed # Synopsis
base-bigarray base
base-threads base
base-unix base
camlp5 7.11 Preprocessor-pretty-printer of OCaml
conf-findutils 1 Virtual package relying on findutils
conf-m4 1 Virtual package relying on m4
coq 8.8.2 Formal proof management system.
num 1.3 The legacy Num library for arbitrary-precision integer and rational arithmetic
ocaml 4.09.0 The OCaml compiler (virtual package)
ocaml-base-compiler 4.09.0 Official release 4.09.0
ocaml-config 1 OCaml Switch Configuration
ocamlfind 1.8.1 A library manager for OCaml
# opam file:
opam-version: "2.0"
maintainer: "[email protected]"
homepage: "https://github.com/coq-contribs/cfgv"
license: "LGPL"
build: [make "-j%{jobs}%"]
install: [make "install"]
remove: ["rm" "-R" "%{lib}%/coq/user-contrib/CFGV"]
depends: [
"ocaml"
"coq" {>= "8.7" & < "8.8~"}
]
tags: [ "keyword: generic programming" "keyword: variable bindings" "keyword: context free grammars" "keyword: substitution" "keyword: alpha equality" "keyword: equivariance" "category: Computer Science/Lambda Calculi" ]
authors: [ "Abhishek <[email protected]> [http://www.cs.cornell.edu/~aa755/]" "Vincent Rahli <[email protected]> [http://www.cs.cornell.edu/~rahli/]" ]
bug-reports: "https://github.com/coq-contribs/cfgv/issues"
dev-repo: "git+https://github.com/coq-contribs/cfgv.git"
synopsis: "Generic Proofs about Alpha Equality and Substitution"
description: """
http://www.nuprl.org/html/CFGVLFMTP2014/
Please read the following paper"""
flags: light-uninstall
url {
src: "https://github.com/coq-contribs/cfgv/archive/v8.7.0.tar.gz"
checksum: "md5=59a29ea2c3114e007451171d9de147d8"
}
</pre>
<h2>Lint</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
</dl>
<h2>Dry install</h2>
<p>Dry install with the current Coq version:</p>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>opam install -y --show-action coq-cfgv.8.7.0 coq.8.8.2</code></dd>
<dt>Return code</dt>
<dd>5120</dd>
<dt>Output</dt>
<dd><pre>[NOTE] Package coq is already installed (current version is 8.8.2).
The following dependencies couldn't be met:
- coq-cfgv -> coq < 8.8~ -> ocaml < 4.06.0
base of this switch (use `--unlock-base' to force)
Your request can't be satisfied:
- No available version of coq satisfies the constraints
No solution found, exiting
</pre></dd>
</dl>
<p>Dry install without Coq/switch base, to test if the problem was incompatibility with the current Coq/OCaml version:</p>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>opam remove -y coq; opam install -y --show-action --unlock-base coq-cfgv.8.7.0</code></dd>
<dt>Return code</dt>
<dd>0</dd>
</dl>
<h2>Install dependencies</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Duration</dt>
<dd>0 s</dd>
</dl>
<h2>Install</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Duration</dt>
<dd>0 s</dd>
</dl>
<h2>Installation size</h2>
<p>No files were installed.</p>
<h2>Uninstall</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Missing removes</dt>
<dd>
none
</dd>
<dt>Wrong removes</dt>
<dd>
none
</dd>
</dl>
</div>
</div>
</div>
<hr/>
<div class="footer">
<p class="text-center">
<small>Sources are on <a href="https://github.com/coq-bench">GitHub</a>. ยฉ Guillaume Claret.</small>
</p>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="../../../../../bootstrap.min.js"></script>
</body>
</html>
| coq-bench/coq-bench.github.io | clean/Linux-x86_64-4.09.0-2.0.5/released/8.8.2/cfgv/8.7.0.html | HTML | mit | 7,151 |
/*******************************************************
* File name: pando_subdevice.h
* Author: razr
* Versions: 1.0
* Description: pando iot embeded framework.
* History:
* 1.Date: Sep 11, 2015
* Author: razr
* Modification: initial code
*********************************************************/
#ifndef PANDO_FRAMEWORK_H_
#define PANDO_FRAMEWORK_H_
void pando_framework_init(void);
#endif /* PANDO_FRAMEWORK_H_ */
| PandoCloud/pando-embedded-framework | framework/pando_framework.h | C | mit | 440 |
---
layout: default
---
<div class="page clearfix" index>
<div class="left">
<h1>Welcome to jisonami's Notes!</h1>
<small>่ฟ้่ฎฐๅฝๆๅจ็จๅบๅผๅ่ฟ็จไธญ็ๅญฆไน ็ฌ่ฎฐ</small>
<hr>
<ul>
{% for post in paginator.posts %}
<li>
<h2>
<a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
</h2>
<div class="label">
<div class="label-card">
<i class="fa fa-calendar"></i>{{ post.date | date: "%F" }}
</div>
<div class="label-card">
{% if post.author %}<i class="fa fa-user"></i>{{ post.author }}
{% endif %}
</div>
<div class="label-card">
{% if page.meta %}<i class="fa fa-key"></i>{{ page.meta }} {% endif %}
</div>
<div class="label-card">
{% include category.html %}
</div>
<div class="label-card">
{% include tag.html %}
</div>
</div>
<div class="excerpt">
{{post.excerpt}}
</div>
<div class="read-all">
<a href="{{ post.url | prepend: site.baseurl }}"><i class="fa fa-newspaper-o"></i>Read All</a>
</div>
<hr>
</li>
{% endfor %}
</ul>
<!-- Pagination links -->
<div class="pagination">
{% if paginator.previous_page %}
<a href="/index.html" class="previous"><i class="fa fa-angle-double-left"></i></a>
<a href="{{ paginator.previous_page_path }}" class="previous"><i class="fa fa-angle-left"></i></a>
{% else %}
<span class="previous disable"><i class="fa fa-angle-double-left"></i></span>
<span class="previous disable"><i class="fa fa-angle-left"></i></span>
{% endif %}
<span class="page_number ">{{ paginator.page }}/{{ paginator.total_pages }}</span>
{% if paginator.next_page %}
<a href="{{ paginator.next_page_path }}" class="next"><i class="fa fa-angle-right"></i></a>
<a href="/page{{ paginator.total_pages }}" class="next"><i class="fa fa-angle-double-right"></i></a>
{% else %}
<span class="next disable"><i class="fa fa-angle-right"></i></span>
<span class="next disable"><i class="fa fa-angle-double-right"></i></span>
{% endif %}
</div>
</div>
<!-- <button class="anchor"><i class="fa fa-anchor"></i></button> -->
<div class="right">
<div class="wrap">
<div class="side">
<div>
<i class="fa fa-pencil-square-o" aria-hidden="true"></i>
Recent Posts
</div>
<ul class="content-ul" recent>
{% for post in site.posts offset: 0 limit: 10 %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</div>
<!-- Content -->
<div class="side ">
<div>
<i class="fa fa-th-list"></i>
Categories
</div>
<ul class="content-ul" cate>
{% for category in site.categories %}
<li>
<a href="{{ root_url }}/{{ site.category_dir }}#{{ category | first }}" class="categories-list-item" cate="{{ category | first }}">
<span class="name">
{{ category | first }}
</span>
<span class="badge">{{ category | last | size }}</span>
</a>
</li>
{% endfor %}
</ul>
</div>
<!-- ๅ
ถไปdivๆกๆพๅฐ่ฟ้ -->
<div class="side">
<div>
<i class="fa fa-tags"></i>
Tags
</div>
<div class="tags-cloud">
{% assign first = site.tags.first %}
{% assign max = first[1].size %}
{% assign min = max %}
{% for tag in site.tags offset:1 %}
{% if tag[1].size > max %}
{% assign max = tag[1].size %}
{% elsif tag[1].size < min %}
{% assign min = tag[1].size %}
{% endif %}
{% endfor %}
{% if max == min %}
{% assign diff = 1 %}
{% else %}
{% assign diff = max | minus: min %}
{% endif %}
{% for tag in site.tags %}
{% assign temp = tag[1].size | minus: min | times: 36 | divided_by: diff %}
{% assign base = temp | divided_by: 4 %}
{% assign remain = temp | modulo: 4 %}
{% if remain == 0 %}
{% assign size = base | plus: 9 %}
{% elsif remain == 1 or remain == 2 %}
{% assign size = base | plus: 9 | append: '.5' %}
{% else %}
{% assign size = base | plus: 10 %}
{% endif %}
{% if remain == 0 or remain == 1 %}
{% assign color = 9 | minus: base %}
{% else %}
{% assign color = 8 | minus: base %}
{% endif %}
<a href="{{ root_url }}/{{ site.tag_dir }}#{{ tag[0] }}" style="font-size: {{ size }}pt; color: #{{ color }}{{ color }}{{ color }};">{{ tag[0] }}</a>
{% endfor %}
</div>
</div>
<!-- <div class="side">
<div>
<i class="fa fa-external-link"></i>
Links
</div>
<ul class="content-ul">
</ul>
</div> -->
</div>
</div>
</div>
<!-- <script src="{{ "/js/scroll.min.js " | prepend: site.baseurl }}" charset="utf-8"></script> -->
<!-- <script src="{{ "/js/pageContent.js " | prepend: site.baseurl }}" charset="utf-8"></script> -->
| jisonami/Notes | index.html | HTML | mit | 6,688 |
<?php
namespace app\controllers;
use Yii;
use app\models\{Freight, FreightSearch};
use yii\web\{Controller, NotFoundHttpException};
/**
* FreightController implements the CRUD actions for Freight model.
*/
class FreightController extends Controller
{
/**
* Lists all Freight models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new FreightSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Freight model.
* @param string $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Freight model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Freight();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['index']);
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing Freight model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param string $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['index']);
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Finds the Freight model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param string $id
* @return Freight the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Freight::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
| lmihaylov2512/logistic-app | controllers/FreightController.php | PHP | mit | 2,382 |
// ReplProbe.js (c) 2010-2013 Loren West and other contributors
// May be freely distributed under the MIT license.
// For further details and documentation:
// http://lorenwest.github.com/monitor-min
(function(root){
// Module loading - this runs server-side only
var Monitor = root.Monitor || require('../Monitor'),
_ = Monitor._,
Probe = Monitor.Probe,
REPL = require('repl'),
Stream = require('stream'),
util = require('util'),
events = require('events'),
ChildProcess = require('child_process');
// Statics
var CONSOLE_PROMPT = '> ';
var NEW_REPL = (typeof REPL.disableColors === 'undefined');
/**
* A probe based Read-Execute-Print-Loop console for node.js processes
*
* @class ReplProbe
* @extends Probe
* @constructor
* @param initParams {Object} Probe initialization parameters
* @param initParams.uniqueInstance - Usually specified to obtain a unique REPL probe instance
* @param model {Object} Monitor data model elements
* @param model.output {String} Last (current) REPL output line
* @param model.sequence {Integer} Increasing sequence number - to enforce unique line output
*/
var ReplProbe = Monitor.ReplProbe = Probe.extend({
probeClass: 'Repl',
description: 'A socket.io based Read-Execute-Print-Loop console for node.js processes.',
defaults: {
// This assures output events are sent, even if the
// data is the same as the prior output.
sequence: 0,
output: ''
},
initialize: function(attributes, options){
var t = this;
Probe.prototype.initialize.apply(t, arguments);
// Don't send change events before connected
process.nextTick(function(){
t.stream = new ReplStream(t);
if (NEW_REPL) {
t.repl = require('repl').start({
prompt: CONSOLE_PROMPT,
input: t.stream,
output: t.stream
});
} else {
t.repl = REPL.start(CONSOLE_PROMPT, t.stream);
}
t.htmlConsole = new HtmlConsole(t);
t.shellCmd = null;
t.repl.context.console = t.htmlConsole;
});
},
/**
* Send output to the terminal
*
* This forces the change event even if the last output is the same
* as this output.
*
* @protected
* @method output
* @param str {String} String to output to the repl console
*/
_output: function(str) {
var t = this;
t.set({
output: str,
sequence: t.get('sequence') + 1
});
},
/**
* Release any resources consumed by this probe.
*
* Stop the REPL console. Consoles live 1-1 with a UI counterpart, so stop
* requests exit the underlying repl console. If the probe is re-started it
* will get a new repl stream and console.
*
* @method release
*/
release: function(){
var t = this;
t.stream = null;
t.repl = null;
},
/**
* Process an autocomplete request from the client
*
* @method autocomplete
* @param {Object} params Named parameters
* @param {Function(error, returnParams)} callback Callback function
*/
autocomplete_control: function(params, callback) {
var t = this;
if (typeof(params) !== 'string' || params.length < 1) {
callback("Autocomplete paramter must be a nonzero string");
}
// Forward to the completion mechanism if it can be completed
if (params.substr(-1).match(/([0-9])|([a-z])|([A-Z])|([_])/)) {
t.repl.complete(params, callback);
} else {
// Return a no-op autocomplete
callback(null, [[],'']);
}
},
/**
* Handle user input from the console line
*
* @method input
* @param {Object} params Named parameters
* @param {Function(error, returnParams)} callback Callback function
*/
input_control: function(params, callback) {
var t = this;
if (params === '.break' && t.shellCmd) {
t.shellCmd.kill();
}
if (NEW_REPL) {
t.stream.emit('data', params + "\n");
} else {
t.stream.emit('data', params);
}
return callback(null);
},
/**
* Execute a shell command
*
* @method sh
* @param {Object} params Named parameters
* @param {Function(error, returnParams)} callback Callback function
*/
sh_control: function(params, callback) {
var t = this;
return callback(null, t._runShellCmd(params));
},
/**
* Run a shell command and emit the output to the browser.
*
* @private
* @method _runShellCmd
* @param {String} command - The shell command to invoke
*/
_runShellCmd: function(command) {
var t = this;
t.shellCmd = ChildProcess.exec(command, function(err, stdout, stderr) {
if (err) {
var outstr = 'exit';
if (err.code) {
outstr += ' (' + err.code + ')';
}
if (err.signal) {
outstr += ' ' + err.signal;
}
t._output(outstr);
return null;
}
if (stdout.length) {
t._output(stdout);
}
if (stderr.length) {
t._output(stderr);
}
t.shellCmd = null;
t._output(CONSOLE_PROMPT);
});
return null;
}
});
// Define an internal stream class for the probe
var ReplStream = function(probe){
var t = this;
t.probe = probe;
events.EventEmitter.call(t);
if (t.setEncoding) {
t.setEncoding('utf8');
}
};
util.inherits(ReplStream, events.EventEmitter);
// util.inherits(ReplStream, require('stream'));
ReplStream.prototype.readable = true;
ReplStream.prototype.writable = true;
['pause','resume','destroySoon','pipe', 'end']
.forEach(function(fnName){
ReplStream.prototype[fnName] = function(){
console.log("REPL Stream function unexpected: " + fnName);
};
});
['resume']
.forEach(function(fnName){
ReplStream.prototype[fnName] = function(){
// Handled
};
});
ReplStream.prototype.write = function(data) {
var t = this;
t.probe._output(data);
};
ReplStream.prototype.destroy = function(data) {
var t = this;
console.log("REPL stream destroy " + t.probe.get('id'));
t.probe.stop();
};
// Define format if it's not in util.
var formatRegExp = /%[sdj]/g;
var format = util.format || function (f) {
if (typeof f !== 'string') {
var objects = [];
for (var i = 0; i < arguments.length; i++) {
objects.push(util.inspect(arguments[i]));
}
return objects.join(' ');
}
var j = 1;
var args = arguments;
var str = String(f).replace(formatRegExp, function(x) {
switch (x) {
case '%s': return String(args[j++]);
case '%d': return Number(args[j++]);
case '%j': return JSON.stringify(args[j++]);
default:
return x;
}
});
for (var len = args.length, x = args[j]; j < len; x = args[++j]) {
if (x === null || typeof x !== 'object') {
str += ' ' + x;
} else {
str += ' ' + util.inspect(x);
}
}
return str;
};
// Re-define the console so it goes to the HTML window
var HtmlConsole = function(probe){
this.probe = probe;
};
HtmlConsole.prototype.log = function(msg) {
this.probe._output(format.apply(this, arguments));
};
HtmlConsole.prototype.info = HtmlConsole.prototype.log;
HtmlConsole.prototype.warn = HtmlConsole.prototype.log;
HtmlConsole.prototype.error = HtmlConsole.prototype.log;
HtmlConsole.prototype.dir = function(object) {
this.probe._output(util.inspect(object));
};
var times = {};
HtmlConsole.prototype.time = function(label) {
times[label] = Date.now();
};
HtmlConsole.prototype.timeEnd = function(label) {
var duration = Date.now() - times[label];
this.log('%s: %dms', label, duration);
};
}(this));
| lorenwest/monitor-min | lib/probes/ReplProbe.js | JavaScript | mit | 7,982 |
package model.dataModels;
/**
* Class ManufacturingData.
* @author Daniel
*
*/
public class ManufacturingData {
private String customerNumber;
private String materialNumber;
private String orderNumber;
private String timeStamp;
private MachineData[] machineData;
private SpectralAnalysisData analysisData;
/**
* Constructor.
*/
public ManufacturingData() {}
/**
* Creates a string representation
* of this object.
* @return
*/
@Override
public String toString() {
return customerNumber + " " + materialNumber + " "
+ orderNumber + " " + timeStamp + " "
+ machineData + " " + analysisData;
}
/*
* Getters and Setters.
*/
/**
* Adds erp data.
* @param data
*/
public void setErpData(ErpData data) {
this.customerNumber = data.getCustomerNumber();
this.materialNumber = data.getMaterialNumber();
this.orderNumber = data.getOrderNumber();
this.timeStamp = data.getTimeStamp();
}
/**
* Appends machine data to the array.
* @param data
*/
public void appendMachineData(MachineData data) {
if(this.machineData == null) {
this.machineData = new MachineData[1];
machineData[0] = data;
} else {
int length = this.machineData.length;
MachineData[] temp = new MachineData[length + 1];
for(int i = 0; i < length; i++) {
temp[i] = this.machineData[i];
}
temp[length] = data;
this.machineData = temp;
}
}
/**
* Adds spectral analysis data.
* @param analysisData
*/
public void setAnalysisData(SpectralAnalysisData analysisData) {
this.analysisData = analysisData;
}
public String getCustomerNumber() {
return customerNumber;
}
public String getMaterialNumber() {
return materialNumber;
}
public String getOrderNumber() {
return orderNumber;
}
public String getTimeStamp() {
return timeStamp;
}
public MachineData[] getMachineData() {
return machineData;
}
public SpectralAnalysisData getAnalysisData() {
return analysisData;
}
} | 4lexBaum/projekt-5s-dhbw | Backend/src/main/java/model/dataModels/ManufacturingData.java | Java | mit | 1,974 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.