Q:

Using glDrawElements to draw object from WRL (VRML) file

I'm trying to model an object described in a WRL (VRML) file using OpenGL.
I'm not really concerned with parsing the file, I figure that part will be fairly straight forward. At this stage I am just trying to hard-code in a vertex array and index array so that I can get a good understanding of how this works so that I can generalise for any WRL input file.
I'm trying a basic box (rectangular prism) model first. I currently have this vertex array:
GLfloat vertices[] = {
     -0.200000, -0.025000, -0.050000,
     -0.200000, -0.025000, 0.050000,
     -0.200000, 0.025000, -0.050000,
     -0.200000, 0.025000, 0.050000,
      0.200000, -0.025000, -0.050000,
      0.200000, -0.025000, 0.050000,
      0.200000, 0.025000, -0.050000,
      0.200000, 0.025000, 0.050000
};

and this index array:
GLubyte indices[] = {
     7, 3, 5, -1, 5, 3, 1, -1,
     6, 2, 7, -1, 7, 2, 3, -1,
     4, 0, 6, -1, 6, 0, 2, -1,
     5, 1, 4, -1, 4, 1, 0, -1,
     2, 0, 3, -1, 3, 0, 1, -1,
     4, 6, 5, -1, 5, 6, 7, -1
};

which came directly from the WRL file Coordinate3 {point []} and IndexedFaceSet {coordIndex []}.
I then enable vertex array functionality by calling:
glEnableClientState(GL_VERTEX_ARRAY);
and set up the glVertexPointer:
glVertexPointer(3, GL_FLOAT, 0, vertices);
finally I use the glDrawElements function to draw the box:
glDrawElements(GL_POLYGON, 24, GL_UNSIGNED_BYTE, indices);
and then deactivate vertex array functionality:
glDisableClientState(GL_VERTEX_ARRAY);
So after this, I would expect a box to be drawn, and when I use glDrawElements(GL_POINTS, 24, GL_UNSIGNED_BYTE, indices); it shows the 8 vertices as epected in what, if the correct vertices were joined with lines, would represent the box expected (except there is a point in the middle, but when I use 26 as the count argument, then the point in the middle dissappears)
However when I use GL_POLYGON or GL_LINE_LOOP at the first argument to glDrawElements, I get rubbish. The 8 vertices are obviously there, but they're joined up in really strange ways.
I'm pretty confused by now, and I'm not even sure I'm doing this correctly. Perhaps someone could put me in the right direction at least?

A:

A rectangular prism is not a GL_POLYGON. Note the singular form of that word: polygon. As in one polygon. A rectangular prism is composed of many polygons, not just one.
What you want is to draw some GL_TRIANGLES. Create an index list that shows each of the triangles that compose the box. That means each box face is made of two triangles, so you need 12 triangles total. That means 36 indices.


                   IN THE SUPREME COURT OF THE STATE OF IDAHO
                                  Docket No. 38917

                                         )
    PETER KASEBURG, SHELAGH              )                   Boise, February 2013 Term
    KASEBURG, KASEBURG FAMILY            )
    TRUST,                               )                   2013 Opinion No. 56
                                         )
    Plaintiffs-Respondents.              )                   Filed: May 2, 2013
                                         )
 STATE OF IDAHO, BOARD OF LAND           )                   Stephen W. Kenyon, Clerk
 COMMISSIONERS, DEPARTMENT OF            )
 LANDS,                                  )
                                         )
     Defendants-Appellant.               )
________________________________________)

         Appeal from the district court of the First Judicial District of the State of Idaho,
         Bonner County. Hon. Steve Verby, District Judge.

         The decision of the district court is reversed as to application 219B and
         affirmed as to application 219C and this case is remanded for action consistent
         with this Opinion. No costs or fees are awarded.

         Hon. Lawrence G. Wasden, Idaho Attorney General, Boise, for Appellants.
         Steven Schuster argued.

       Finney, Finney & Finney, P.A., Sandpoint, attorneys for Respondents. John A.
       Finney argued.
__________________________________

W. JONES, Justice
                                         I. NATURE OF THE CASE
        Peter Kaseburg 1 is a littoral owner on Lake Pend Oreille who holds an encroachment
permit for a series of decaying wooden pilings that were driven into the lakebed in the 1930s.
With the exception of a single piling that a neighboring marina uses to anchor one of its docks,
the pilings have never had any known navigational purpose. Kaseburg applied to the Idaho
Department of Lands (“IDL”) for a permit to replace ten of the wooden pilings with steel pilings,

1
 Peter’s wife, Shelagh Kaseburg, and the Kaseburg Family Trust are also parties to the lawsuit. However, because
Peter took all of the actions relevant to this lawsuit, Shelagh and the Trust are not mentioned further.

                                                       1
but failed to specify any navigational purpose for this proposal.           The IDL considered the
application a request for a nonnavigational encroachment permit and denied it after receiving
several objections.
       While a final decision was still pending on the first permit application, Kaseburg filed a
second application for a permit to install a mobile dock system and mooring buoy. The IDL
considered the second application a request for a permit for a navigational encroachment
extending beyond the line of navigability. Again, the IDL received many objections and denied
the application.
       Kaseburg petitioned for judicial review by the First District Court for Bonner County,
which reversed the IDL. The court held that all pilings are navigational encroachments as a
matter of law, regardless of whether they have ever been used to aid navigation. This supposed
error tainted the IDL’s processing of both applications. Therefore, the district court set aside
both denials. The IDL appealed to this Court. We reverse the district court with respect to the
first application, but affirm the district court with respect to the second application.
                          II. FACTUAL AND PROCEDURAL BACKGROUND
       Peter Kaseburg is a relative newcomer to Glengary Bay on Lake Pend Oreille in Bonner
County, Idaho. He recently purchased a vacation home on a small sub-bay (the “Bay”) which is
part of the larger Glengary Bay. Kaseburg shares the Bay’s shoreline with several other property
owners: Gerald Bringhurst; Mark and Laurence Nelson; Tom and Marjorie Trulock; and George
Congleton. Kaseburg’s property extends to the north, around the corner of a point that defines
the mouth of the Bay.
       The area was originally homesteaded by the Nelson family. In 1937, the McLean family
purchased land that included most of the Bay’s shoreline. In the mid-1940s, Marjorie Trulock’s
father, Hennrick Heitman, purchased land that fronted on the remaining shoreline and began
operating a marina there. The McLean and Heitman families owned all of the shoreline until the
mid-1990s. To this day, the Heitman Docks marina continues to operate under the Trulocks’
ownership.
       In the water near Kaseburg’s property stand a set of decaying wooden pilings. They are
arranged in an L-shaped configuration. Seven individual pilings extend roughly perpendicular
from the shoreline and to the south-southeast, terminating in a cluster of three pilings that stands
at the corner of the “L.” Another cluster of three pilings is adjacent to it to the west-southwest,

                                                   2
and, together with six more individual pilings, forms the other leg of the “L.” In 1974 there were
an additional two pilings above the low water mark. These two pilings have apparently rotted
away entirely, and no longer exist.
        The pilings were driven in the early 1930s, although their exact purpose is unknown.
Due to their height, it is unlikely they were intended to support a dock. Around 1937, while a
home was being constructed on what is now Kaseburg’s land, the living room portion of a float
house was towed from another location and was tied to one of the pilings. The pilings may
originally have been intended to hold the portion of the float house in place. Later, they were
used as a destination for swimmers. One of the pilings was also used to support a now-defunct
water intake pipe. There is no evidence that the pilings were ever used to support a dock or to
moor any craft capable of traveling under its own power, with the exception of a single piling
that the Trulocks use to anchor one of their marina’s docks.
        In the early 1950s, the United States Army Corps of Engineers constructed the Albeni
Falls dam on Lake Pend Oreille, thereby creating an artificial high water mark (“AHWM”) 2
approximately eleven and a half feet above the natural high water mark.
        In 1974, Douglas McLean, the owner of what is now both Kaseburg and Congleton’s
respective properties, submitted a notice of existing encroachments (the “Notice”). 3 On a hand-
drawn schematic of the area, McLean noted the existence of a small dock, which he kept beached
at the high water mark; a juniper tree, which was “used to moor small boats”; and the
aforementioned L-shaped series of pilings. In the margin, not next to any particular structure on
the drawing, McLean wrote, “Purpose: Private swimming & boat moorage area; & private water
source.” He did not specify which purpose related to which structure. A neighbor who knew
McLean stated that McLean submitted the Notice in order to be able to continue to use the
pilings to support his water intake pipe. There is no evidence that McLean intended the phrase
“boat moorage area” to apply to the pilings, rather than the dock and tree.

2
 See I.C. § 58-1302(d).
3
 The filing of such a notice was allowed by the former I.C. § 58-153, which was renumbered I.C. § 58-1312 by
1990 Idaho Sess. Laws 986. At the time McLean filed his Notice, the statute provided:
         On or before December 31, 1974, every person owning or possessing an existing navigational or
         nonnavigational encroachment on, in or above the beds or waters of a navigable lake in this state
         shall file with the board notification thereof. Such notice shall be upon forms to be furnished by
         the board and contain such information concerning the encroachment as would be necessary on
         plans submitted with an original application under the provisions of this act.

                                                     3
        It is undisputed that the pilings currently serve little or no useful purpose. Indeed, it is
undisputed that the pilings are a navigational hazard because they increase crowding on the Bay;
are nearly completely submerged when the water level is high; and are difficult to see, especially
at night. The Trulocks anchor one of their marina’s docks with one of the pilings, but they could
adequately anchor the dock without using the piling. Additionally, neighbors have installed
lights on one or more of the pilings, but did so only to warn boaters of the pilings’ presence.
        In August of 2008, Kaseburg submitted a “Request for Assignment of Encroachment
Permit” on behalf of “Douglas C. McLean (Deceased).” McLean was Kaseburg’s predecessor in
interest; however, he was also Congleton’s predecessor in interest, and the pilings are adjacent to
Congleton’s land, not Kaseburg’s. Nonetheless, the IDL granted the request and transferred
McLean’s permit to Kaseburg. It does not appear that the IDL made any determination of
Congleton and Kaseburg’s littoral boundaries, or that Congleton was ever notified of the permit
transfer. 4
        Later in 2008, Kaseburg communicated with the IDL via email. The IDL informed him
that the wooden pilings were “not something we would normally permit anymore” and that,
unless used to “hold a floating dock in location,” any new pilings “would be considered a non-
navigational encroachment and would have to provide a benefit to the public to be permitted.”
In February of 2009, Kaseburg stated his desire to install a dock with an area of between 1,590
and 2,120 square feet. The IDL responded that it did not permit single-family docks exceeding
700 square feet, except for properties accessible only by boat. 5
        In March of 2009, Kaseburg filed an application with the IDL (“Application 219-B”)
requesting permission to remove all of the pilings and to replace ten of them with steel pilings.
Kaseburg’s application did not explain why he wanted to install the pilings or mention any
additional structures that he wanted to attach to them. He instead characterized his proposed
activity as a “maintenance operation.” The IDL processed Kaseburg’s application as a request to
replace a nonnavigational encroachment.

4
  At least some of the pilings may be within Congleton’s littoral lines. Generally, a littoral line begins at the
boundary between two lakefront owners’ properties and extends into the lake perpendicular to the shore. Littoral
lines may be convergent or divergent if the shoreline is concave or convex, respectively. Brett v. Eleventh St.
Dockowner’s Ass’n, 141 Idaho 517, 522, 112 P.3d 805, 810 (2005) (quoting Driesbach v. Lynch, 71 Idaho 501, 508–
09, 234 P.2d 446, 450–51 (1951)).
5
  See I.D.A.P.A. 20.03.04.015.01(b).

                                                       4
           At this point, it is useful to note the statutory definitions of “navigational” and
“nonnavigational” encroachments. Pursuant to the Lake Protection Act: 6
           “Encroachments in aid of navigation” means and includes docks, piers, floats,
           pilings, breakwaters, boat ramps, channels or basins, and other such aids to the
           navigability of the lake, on, in or above the beds or waters of a navigable lake.
           The term “encroachments in aid of navigation” may be used interchangeably
           herein with the term “navigational encroachments.”

           “Encroachments not in aid of navigation” means and includes all other
           encroachments on, in or above the beds or waters of a navigable lake, including
           landfills or other structures not constructed primarily for use in aid of the
           navigability of the lake. The term “encroachments not in aid of navigation” may
           be used interchangeably herein with the term “nonnavigational encroachments.”

I.C. § 58-1302(h)–(i). The distinction between navigational and nonnavigational encroachments,
as well as the distinction between encroachments inside and outside of the line of navigability,
significantly impact how permit applications are processed. I.C. § 58-1305(a) states:
           Applications for construction or enlargement of navigational encroachments not
           extending beyond the line of navigability nor intended primarily for commercial
           or community use shall be processed by the board with a minimum of procedural
           requirements and shall not be denied nor appearance required except in the most
           unusual of circumstances or if the proposed encroachment infringes upon or it
           appears it may infringe upon the riparian or littoral rights of an adjacent property
           owner.

Similarly I.D.A.P.A. 20.03.04.025.01 states:
           Applications for single-family and two-family navigational encroachments not
           extending beyond the line of navigability will be processed with a minimum of
           procedural requirements and shall not be denied except in the most unusual of
           circumstances. No newspaper publication, formal appearance by the applicant, or
           hearing is contemplated.

In contrast, I.D.A.P.A. 20.03.04.030.02 provides:
           Encroachments not in aid of navigation in navigable lakes will normally not be
           approved by the Department and will be considered only in cases involving major
           environmental, economic, or social benefits to the general public. Approval under
           these circumstances is authorized only when consistent with the public trust
           doctrine and when there is no other feasible alternative with less impact on public
           trust values.

6
    I.C. §§ 58-1301 to -1312.

                                                    5
       Later in March of 2009, the IDL mailed a notice of Application 219-B to several
potentially interested governmental agencies and to Kaseburg’s adjacent neighbors. The Bonner
County Sheriff (the “Sheriff”), the Idaho Department of Fish and Game (“Fish and Game”), and
several individuals filed objections. The Sheriff supported removing the existing pilings, which
he characterized as “a hazard to navigation.” However, he was of the opinion that the proposed
steel pilings would also be a hazard and therefore opposed the application. Finally, the Sheriff
noted that Kaseburg had not disclosed his purpose for wishing to replace ten of the wood pilings
with steel pilings. Fish and Game noted that the pilings were “in an advanced stage of decay and
should be removed.” Fish and Game also noted that Kaseburg had not stated what he intended to
do with the steel pilings.
       The individual objectors were similarly concerned that Kaseburg had not explained why
he wanted to install the steel pilings; they believed that he might follow up Application 219-B
with a request to add a sizeable dock and a breakwater. They observed that steel pilings would
continue to pose a navigation hazard. If any dock were later built on the proposed steel pilings, it
would extend a significant distance into the Bay and therefore would increase silt deposition and
milfoil growth in the Bay. The neighbors also objected to the potential interference with their
views of the Bay.
       In May of 2009, after the objector’s comments had already been submitted, Kaseburg
attempted to modify his application. He wished to add a 1,640-square-foot dock that was not
included in his initial application. The IDL refused to consider the proposed modification. On
June 9, 2009, the IDL denied Kaseburg’s permit application on the grounds that the replacement
of the wooden pilings would serve no beneficial public purpose, and, in fact, would perpetuate a
hazard to navigation. Later in the month, Kaseburg requested a reconsideration hearing, which
the IDL granted. At the hearing, Kaseburg stated that he intended to use the steel pilings to moor
his fifteen-foot wooden sailboat, and possibly his father’s forty-two-foot wooden sailboat.
       In August of 2009, while a final decision on Application 219-B was pending, Kaseburg
submitted a new application (“Application 219-C”). He wished to install a 700-square-foot
movable dock system anchored to one of the pilings and, separately, a mooring buoy. The piling
serving as an anchor would be cut off three feet above the mud line. Kaseburg explained that his
family uses wooden boats, which must remain in the water year-round to prevent their hulls from
drying out. He also stated that he did not wish to rely on the Trulocks’ marina across the Bay,

                                                 6
because there might not be any boat slips available for a thirty-foot sailboat without auxiliary
power. He further stated that, if the marina’s ownership changed in the future, he might not have
an adequate place to moor his boat or boats. He objected to using the northeast side of his
property to access the lake because a dock located there would be “smack dab in the middle of
the navigational channel” and would be too exposed to bad weather.
       The IDL processed Application 219-C as a request for a permit for a navigational
encroachment extending beyond the line of navigability. Idaho Code section 58-1302(g) defines
“line of navigability” as:
       [A] line located at such distance waterward of the low water mark established by
       the length of existing legally permitted encroachments, water depths waterward of
       the low water mark, and by other relevant criteria determined by the board when a
       line has not already been established for the body of water in question.

See also I.D.A.P.A. 20.03.04.010.20 (adopting statutory language verbatim). As noted earlier,
the determination of whether an encroachment extends beyond the line of navigability is crucial:
only those encroachments that do not extend beyond the line of navigability are entitled to
expedited processing and a presumption in favor of approval under I.C. § 58-1305(a) and
I.D.A.P.A. 20.03.04.025.01.
       The IDL explained that it considered the line of navigability to be fifty-five feet
waterward of the AHWM. The IDL therefore returned Kaseburg’s second application for lack of
the proper processing fee of $1,075. Instead, Kaseburg had paid only the $250 processing fee for
navigational encroachments within the line of navigability. Kaseburg subsequently paid the
higher fee under protest.
       In October of 2009, the IDL mailed a notice Application 219-C to various governmental
agencies and Kaseburg’s adjacent neighbors. Again, there were many objections. Fish and
Game observed that there appeared to be an inconsistency between Kaseburg’s two applications.
The first requested the removal of the existing wooden pilings because they were decaying. The
second, however, relied on one of those same pilings as a structural component of the movable
dock system. Fish and Game also stated that, in its opinion, the proposed encroachment would
fall beyond the line of navigability. Finally, the three-foot piling stub and underwater cables
“would pose an unseen hazard to boaters, anglers, and other recreationalists.”
       Kaseburg’s neighbors objected on the grounds that the dock would lead to increased
congestion in the Bay and would disrupt views across the Bay. One of the objecting neighbors

                                                7
noted that, with the buoy anchored 190 feet into the Bay and attached to a 30-foot tether holding
a 30-foot sailboat, Kaseburg’s proposed encroachment could extend up to 250 feet into the Bay.
Furthermore, the neighbors noted that, if Kaseburg’s application were granted, it would
encourage other littoral owners to demand permission to construct similar encroachments, thus
leading to even greater congestion on the Bay. Because Kaseburg uses his lake house as a
vacation home, one objector worried that no one might be around to move the dock as the water
level in the lake changed. Yet another neighbor opined that the water on the northern end of
Kaseburg’s property, outside of the Bay, would be a more appropriate location for a mooring
buoy. He pointed out that the water became deeper much more rapidly in that area, that there
was no navigation lane there, and that any congestion would be much greater in the Bay than in
the water to the north.
       In January of 2010, the IDL hearing coordinator issued a memorandum recommending
the affirmation of the earlier denial of Application 219-B. The hearing coordinator noted that
there was no evidence that the pilings had ever been used for navigational purposes. The hearing
coordinator further noted that the application did not specify any navigational use for the
proposed replacement pilings. Although Kaseburg had later attempted to amend Application
219-B, this was done after notice had already been circulated and public comments responding to
the initial version of the application had already been received; therefore, Kaseburg should have
filed a new application rather than attempting to modify his existing application. The Director of
the IDL then issued a Final Order adopting the recommendations in the hearing coordinator’s
memorandum.
       Also during January of 2010, the IDL denied Application 219-C, noting that “the line of
navigability for single family docks in this area has been established at fifty five feet (55’)
waterward of the AHWM.” Because the proposed dock would extend between 95 and 300 feet
waterward of the AHWM, depending on the time of year and corresponding lake level, the IDL
believed that it properly processed Kaseburg’s application as a request for a permit for a
navigational encroachment extending beyond the line of navigability. The IDL held that the
proposed encroachment provided no public benefit and therefore denied it.               The IDL
subsequently denied Kaseburg’s request for reconsideration, stating that no reconsideration was
necessary under I.C. § 58-1306(d) because there were objections to the application. The IDL
stated that reconsideration of Application 219-B had been granted erroneously.

                                                8
       In February of 2010, Kaseburg filed a petition for judicial review with the First District
Court for Bonner County in which he alleged that the IDL improperly denied his applications.
The district court ruled in favor of Kaseburg and set aside both denials. The court reasoned that
I.C. § 58-1302(h) defines “pilings” as navigational encroachments as a matter of law. It found
the statutory definition unambiguous and therefore held that the IDL lacked the power to find
any particular piling nonnavigational under any factual circumstances.             The court further
reasoned that, once a navigational encroachment is installed, it can never become
nonnavigational by mere nonuse. It remanded the matter to the IDL “to determine the line of
navigability and to consider [Kaseburg’s] littoral rights in conjunction with the legislature’s
definition that the pilings at issue are ‘encroachments in aid of navigation.’ ”
       The district court initially awarded Kaseburg attorney’s fees pursuant to I.C. § 12-117.
After Kaseburg submitted his Memorandum of Costs and Attorney Fees, the IDL filed its
Objection to Memorandum of Costs. Citing Smith v. Washington Cnty., 150 Idaho 388, 391, 247
P.3d 615, 618 (2010) and Laughy v. Dep’t of Transp., 149 Idaho 867, 877, 243 P.3d 1055, 1065
(2010), the IDL argued that I.C. § 12-117 did not allow a court to award attorney’s fees in a
judicial review proceeding. The district court agreed and vacated its earlier award of attorney’s
fees. The IDL timely appealed the district court’s order setting aside the IDL’s denial of
Applications 219-B and -C.
                                      III. ISSUES ON APPEAL
A.     Did the district court properly set aside the IDL’s denial of Application 219-B?
B.     Did the district court properly set aside the IDL’s denial of Application 219-C?
C.     Is Kaseburg entitled to attorney’s fees?
                                    IV. STANDARD OF REVIEW
       The applicable standard of review is well established:
       In an appeal from the decision of a district court acting in its appellate capacity
       under the IDAPA, this Court reviews the agency record independently of the
       district court’s decision. This Court “shall not substitute its judgment for that of
       the agency as to the weight of the evidence on questions of fact.” I.C. § 67–
       5279(1). This Court instead defers to the agency’s findings of fact unless they are
       clearly erroneous. In other words, the agency’s factual determinations are binding
       on the reviewing court, even where there is conflicting evidence before the
       agency, so long as the determinations are supported by substantial competent
       evidence in the record.

                                                  9
A & B Irrigation Dist. v. Idaho Dep’t Of Water Res., 153 Idaho 500, 505–06, 284 P.3d 225, 230–
31 (2012) (case citations and quotation marks omitted).        An agency’s final order must be
affirmed unless the appellant shows that its substantial rights have been prejudiced, I.C. § 67-
5279(4); Hawkins v. Bonneville Cnty. Bd. of Comm’rs, 151 Idaho 228, 232, 254 P.3d 1224, 1228
(2011), and also that the final order is:
        (a) in violation of constitutional or statutory provisions;
        (b) in excess of the statutory authority of the agency;
        (c) made upon unlawful procedure;
        (d) not supported by substantial evidence on the record as a whole; or
        (e) arbitrary, capricious, or an abuse of discretion

I.C. § 67-5279(3); Wheeler v. Idaho Dep’t of Health & Welfare, 147 Idaho 257, 260, 207 P.3d
988, 991 (2009). “On an appeal from the district court, we review the decision of the district
court to determine whether it correctly decided the issues presented to it.” Elias-Cruz v. Idaho
Dept. of Transp., 153 Idaho 200, 202, 280 P.3d 703, 705 (2012).
        An agency’s interpretation of a statute that it is entrusted with administering is
        entitled to deference so long as it is reasonable and not contrary to the express
        language of the statute. We interpret the words of a statute according to their
        plain, usual, and ordinary meaning, and do not use any other tools of construction
        if the meaning of the statute is unambiguous from its words alone.

Two Jinn, Inc. v. Idaho Dep’t of Ins., ___ Idaho ___, ___, 293 P.3d 150, 152 (2013) (citations
and quotation marks omitted).
        Nonetheless, the courts have the ultimate authority to construe statutory language. Kuna
Boxing Club, Inc. v. Idaho Lottery Comm’n, 149 Idaho 94, 97, 233 P.3d 25, 28 (2009). “When
interpreting a statute, the primary function of the Court is to determine and give effect to the
legislative intent.” Idaho Cardiology Assocs., P.A. v. Idaho Physicians Network, Inc., 141 Idaho
223, 227, 108 P.3d 370, 374 (2005) (quoting Dyet v. McKinley, 139 Idaho 526, 528, 81 P.3d
1236, 1238 (2003), abrogated on other grounds by Verska v. Saint Alphonsus Reg’l Med. Ctr.,
151 Idaho 889, 265 P.3d 502 (2011)). “If a statute is ambiguous, this Court attempts to ascertain
the Legislature’s intent by examining the ‘language used, the reasonableness of proposed
interpretations, and the policy behind the statute.’ ” Ward v. Portneuf Med. Ctr., Inc., 150 Idaho
501, 504, 248 P.3d 1236, 1239 (2011) (quoting Magic Valley Newspapers, Inc. v. Magic Valley
Reg’l Med. Ctr., 138 Idaho 143, 144, 59 P.3d 314, 315 (2002)). The various sections of a statute
must be construed as a harmonious whole. See City of Pocatello v. State, 152 Idaho 830, 838,

                                                10
275 P.3d 845, 853 (2012); State v. Doe, 147 Idaho 326, 328, 208 P.3d 730, 732 (2009); Olson v.
Ada Cnty., 105 Idaho 18, 20, 665 P.2d 717, 719 (1983).
                                              V. ANALYSIS
           This case revolves around the question of whether Kaseburg was accorded fair treatment
as guaranteed by the Idaho Administrative Procedure Act. 7 We hold that the district court erred
by setting aside the IDL’s denial of Application 219-B. The district court should have deferred
to the IDL’s determination that pilings are not per se navigational. Moreover, there was ample
evidence supporting the IDL’s conclusion that the encroachment proposed in Application 219-B
was nonnavigational and would provide no public benefit. However, we also hold that the
district court properly set aside the IDL’s denial of Application 219-C, although not for the
reasons that the district court relied on. The IDL assumed, without any basis in fact or law, that
the line of navigability in the area of the proposed encroachment was fifty-five feet waterward of
the AHWM.           It cannot be determined whether the IDL applied the correct standard when
processing Application 219-C until a proper line of navigability is established.                Finally,
Kaseburg is not entitled to attorney’s fees, because he is not a prevailing party.
A.         The district court erred in setting aside the IDL’s rejection of Application 219-B.
           The district court held that all pilings placed into a lakebed are navigational as a matter of
law, reversing the IDL’s holding that whether a piling is navigational is a factual question. As
noted above, we defer to an agency’s statutory interpretation only if two elements are satisfied.
The first element is met here because the IDL is entrusted with administering the Lake Protection
Act. The IDL is an “instrumentality” of the State Board of Land Commissioners. Idaho Const.
art. IX, § 7; I.C. § 58-101; I.C. § 58-119. The State Board of Land Commissioners has the power
to “regulate and control the use or disposition of lands in the beds of navigable lakes, rivers and
streams, to the natural or ordinary high water mark thereof, so as to provide for their commercial,
navigational, recreational or other public use . . . .” I.C. § 58-104(9). Therefore, the duty of
administering the Lake Protection Act falls upon the IDL. See Brett v. Eleventh St. Dockowner’s
Ass’n, 141 Idaho 517, 523, 112 P.3d 805, 811 (2005); Lovitt v. Robideaux, 139 Idaho 322, 326–
27, 78 P.3d 389, 393–94 (2003).
           The second element is also met because the IDL’s interpretation—that the inclusion of
the word “pilings” is illustrative rather than definitional—is reasonable and not contrary to the

7
    I.C. §§ 67-5201 to -5292.

                                                    11
express language of the statute. The phrase “and other such aids to the navigability of the lake”
interjects ambiguity into the statute. I.C. § 58-1302(h). It is unclear whether this phrase was
meant only to expand the class of encroachments that are navigational beyond those types of
structures explicitly listed, or whether the phrase excludes particular structures that are not in fact
aids to navigation.         Moreover, we must construe the definitions of navigational and
nonnavigational encroachments harmoniously.                 Together, the two definitions establish a
dichotomy: an encroachment is either navigational or nonnavigational. The district court’s
interpretation would have the impossible consequence of making certain encroachments (such as
the pilings at issue here) both navigational as a matter of law and also nonnavigational as a result
of being constructed not primarily for use in aid of navigation.
        Because the statute is ambiguous, we must consider the Legislature’s likely intent. It is
highly unlikely that the Legislature intended to define pilings used to support bridges, helipads,
and goose nesting boxes as per se navigational. Similarly, the Legislature almost certainly did
not intend steel pilings driven into a lakebed to be considered “navigational” when such pilings
have no specified use relating to navigation and are replacements for wooden pilings that also
never had any navigational use.
        The IDL correctly notes that there is no evidence in the record that the series of wooden
pilings has ever served as an aid to navigation; 8 in fact, all of the evidence shows that this
encroachment is a hazard to navigation. Kaseburg argues that the pilings are navigational
because they were used to “dock a house boat.” This assertion is contrary to the evidence in the
record. As described above, the pilings were once used to moor the living room portion of a
float home after it was partially disassembled.                 Kaseburg does not contest the IDL’s
classification of float homes as nonnavigational encroachments. I.D.A.P.A. 20.03.17.010.10.
Kaseburg further argues that, because McLean’s Notice includes the words “boat moorage area,”
the pilings were navigational. However, the Notice also included a small dock and a juniper tree
that was “used to moor small boats.” It is more likely that these structures constituted the “boat
moorage area.”
        There was ample evidence in the record to support the IDL’s factual finding that the
existing wooden pilings were nonnavigational. Furthermore, Kaseburg’s first application did not

8
 Although one of the pilings serves as an anchor for one of the Trulocks’ docks, Kaseburg’s proposed modification
was unrelated to this navigational purpose. Also, this incidental use could not transform all of the pilings into
navigational encroachments.

                                                       12
specify any navigational purpose for the steel pilings. There was also ample evidence that the
replacement pilings would serve no public purpose and, in fact, would perpetuate a hazard to
navigation. Therefore, the IDL properly denied Application 219-B.
B.     The district court properly set aside the IDL’s rejection of Application 219-C,
       although the district court’s reasoning was incorrect.
       As noted above, I.C. § 58-1302(g) defines “line of navigability” as:
       [A] line located at such distance waterward of the low water mark established by
       the length of existing legally permitted encroachments, water depths waterward of
       the low water mark, and by other relevant criteria determined by the board when a
       line has not already been established for the body of water in question.

(emphasis added). See also I.D.A.P.A. 20.03.04.010.20 (adopting statutory language verbatim).
The IDL’s conclusion that the line of navigability lies fifty-five feet waterward of the AHWM is
contrary to the plain language of the statute and the IDL’s own regulations.         The line of
navigability must be measured from the low water mark. It is not measured from the AHWM.
The error is particularly egregious in this case because the low water mark is approximately 105
feet waterward of the AHWM. In other words, the IDL believes that the line of navigability is
approximately fifty feet landward, rather than waterward, of the low water mark.
       Moreover, the IDL’s interpretation that the line of navigability lies fifty-five feet
waterward of the AHWM is not based on substantial evidence. The record shows only that
littoral owners on the Bay believed that “IDL guidelines” require docks to extend “no more than
55 feet out from summer pool,” and that Bringhurst had previously constructed a dock in
accordance with that belief. And, although the IDL’s letter to Kaseburg denying Application
219-C states that “all other single family docks for miles up and down the shoreline are typically
no more than fifty five feet (55’) into the lake,” there is no evidence in the agency record
supporting this conclusion. At oral argument, counsel for the IDL was unable to specify when,
or by whom, the line of navigability was established.
       The IDL’s improper determination of the line of navigability was in violation of a
statutory provision and was not supported by substantial evidence. It also prejudiced Kaseburg’s
substantial rights by depriving him of a more lenient standard for the consideration of
Application 219-C to which he may be entitled if it is later determined that his proposed
encroachment actually falls within the line of navigability. Therefore, the IDL’s denial of
Application 219-C was properly set aside.

                                               13
       Nonetheless, it is important to emphasize the narrow scope of our holding. On remand,
the IDL should create a record of specific facts that establish the line of navigability, which must
lie waterward of the low water mark.         Once it determines whether the encroachment in
Application 219-C will extend beyond the correct line of navigability, the IDL should process
the application under whichever standard is appropriate in light of that determination.
C.     Kaseburg is not entitled to attorney’s fees.
       The IDL has not requested attorney’s fees in this lawsuit. However, Kaseburg requests
attorney’s fees pursuant to I.C. § 12-117 for all stages of this litigation. Because Kaseburg is not
a prevailing party with respect to Application 219-B, he is not entitled to attorney’s fees related
to that application. See Bldg. Contractors Ass’n of Sw. Idaho v. Idaho Pub. Utilities Comm’n,
151 Idaho 10, 18, 253 P.3d 684, 692 (2011). Nor is Kaseburg a “prevailing party” with respect
to Application 219-C. A party has not “prevailed” until he receives “at least some relief on the
merits of his claim.” Hewitt v. Helms, 482 U.S. 755, 760 (1987). An order remanding a case to
an administrative agency for further consideration normally does not qualify as relief on the
merits. See Envtl. Def. Fund, Inc. v. Reilly, 1 F.3d 1254, 1257 (D.C. Cir. 1993). Here, it would
be premature to declare Kaseburg a “prevailing party” because it is not yet known where the line
of navigability is located; whether his proposed movable dock and mooring buoy lie beyond that
line; and, regardless of that determination, whether his application ultimately should be granted.
See Terra-West, Inc. v. Idaho Mut. Trust, LLC, 150 Idaho 393, 401, 247 P.3d 620, 628 (2010).
We express no opinion on whether Kaseburg might obtain attorney’s fees in the event that he
eventually becomes a prevailing party.
                                         VI. CONCLUSION
       The IDL properly classified the encroachment proposed in Application 219-B as
nonnavigational. The district court erred by not according the IDL’s interpretation of I.C. § 58-
1302(h)–(i) sufficient deference.    The inclusion of the word “pilings” in the definition of
navigational encroachments was merely illustrative. Adopting the opposite construction—that
all pilings are per se navigational—would conflict with the statutory definition of
nonnavigational encroachments and also would subvert the Legislature’s obvious intent.
       Moreover, the IDL properly denied Application 219-B. In this application, Kaseburg
merely sought to replace a series of decaying wooden pilings, which had never been used for any
navigational purpose, with a smaller number of steel pilings, which also had no stated

                                                14
navigational purpose.    Kaseburg initially characterized this as a simple “maintenance” or
“replacement” operation. After the IDL published notice of Kaseburg’s application and received
public comments, Kaseburg improperly attempted to amend the application to add a dock in
order to convert his proposed encroachment from nonnavigational to navigational. There was
ample evidence in the record before the IDL that, rather than providing any public benefit, the
proposed steel pilings would perpetuate a hazard to navigation.
       However, the IDL improperly processed Application 219-C as a navigational
encroachment extending beyond the line of navigability without having first made a
determination of the line of navigability that comported with the statutory definition and that was
based on substantial evidence. On remand, the IDL must make a finding, based on substantial
evidence, establishing the line of navigability. Then, the IDL must process Application 219-C in
accordance with that finding. Because Kaseburg may yet prevail in his efforts to obtain a permit,
we decline to award the IDL costs with respect to Application 219-C.
       Chief Justice BURDICK, Justices EISMANN and HORTON, CONCUR.
JONES, J., specially concurring.
       I concur in the Court’s opinion but wish to further address the line of navigability issue in
Part V.B. As the Court notes, the record contained scant evidence to support IDL’s assertion that
the line of navigability had been “established at fifty five feet (55’) waterward of the AHWM.”
The record did not contain evidence as to when the line of navigability had been established or
the legal authority pursuant to which it was established. On remand, IDL should take the
opportunity to provide that information.
       However, I would not limit IDL’s options by allowing it to only establish a line of
navigability line waterward of the low water mark. Idaho Code § 58-1302(g) establishes the line
of navigability waterward of the low water mark “when a line has not already been established
for the body of water in question.” IDL should have the option of trying to show that the line of
navigability was established for Glengary Bay prior to enactment of the Lake Protection Act, and
that, when established, the line was landward of the low water mark.
       Furthermore, the record contains evidence that a line of navigability as contended for by
Kaseburg may be impractical and potentially hazardous in the narrow confines of Glengary Bay.
According to one comment from a private party, “95 feet of dock jutting out into the bay is a
hazard to navigation.” The commenter continues, “[t]here is no benefit to the general public if

                                                15
the application is approved. . . .[the Kaseburgs] gain at the expense of everyone else.” IDL also
contends that the dock proposed by Kaseburg would constitute a navigation hazard and would
be impractical within the confines of Glengary Bay if other landowners were to assert similar
rights. These are the types of concerns that can be considered by the State Board of Land
Commissioners in carrying out its constitutional responsibility to properly administer the beds of
navigable lakes below their natural high water marks under the public trust doctrine. See
Kootenai Environmental Alliance, Inc. v. Panhandle Yacht Club, Inc., 105 Idaho 622, 671 P.2d
1085 (1983). The record does not indicate whether IDL contends that it established the line of
navigability operating under the constitutional authority of the State Board of Land
Commissioners, derived from Art. IX, §§7−8 of the Idaho Constitution, rather than relying on
the statute. Presumably, that issue can be fleshed out on remand.

                                               16


1. Field
The present disclosure relates generally to radio frequency (RF) power amplifiers, and in particular, to a system and method of performing adaptive digital predistortion (DPD) of complex modulated waveform based on metrics of a system, such as a difference in phase and amplitude between an input and output signal.
2. Background
In the wireless communications field, there is a general need for devices capable of transmitting more data within a given bandwidth, and at the same time achieving a reasonable or optimal power efficiency to conserve battery power. For instance, wireless devices have been designed with different modulation schemes, such as quadrature amplitude modulation (QAM) having 16, 32, or 64 constellations, to increase the data throughput within a given bandwidth. Additionally, wireless devices have also been designed using power amplifiers that operate close to their saturation region, such as class A/B, B, C, and other class amplifiers, to improve the power consumption efficiency.
Because of the relatively high spectral efficiency of the data transmission, such wireless devices often have tight requirements on the allowable spectral leakage. In some cases, these requirements present a problem for operating power amplifiers close to their saturation regions because the nonlinearity characteristic of the amplifier causes significant spectral re-growth and in-band distortion. One solution is to backoff the operation of the amplifier into its linear region so as to reduce or prevent this distortion. However, this results in reduced power efficiency for the device, which has adverse impact on the battery life and continued use of the device.
Another solution is to operate the power amplifier near its saturation or nonlinear region, and use a predistortion device at the input of the amplifier to distort the input signal so as to correct or reduce the distortion of the output signal caused by the nonlinearity of the amplifier. There are generally two approaches: an open loop approach and a closed loop approach. The open loop approach typically works well as long as the nonlinear characteristic of the amplifier is accurately modeled and does not significantly change over time with environmental conditions. The closed loop approach involves providing adaptation to the predistortion device so that it can model the nonlinear characteristic of the power amplifier in “real time,” and adjust the predistortion of the input signal in accordance with the present model of the amplifier. However, often these adaptation techniques are complicated and expensive, as discussed as follows.
FIG. 1 illustrates a block diagram of a typical closed loop transmitter system 100 that uses a demodulation technique to provide information about an output signal in order to apply predistortion of an input signal to compensate for distortion in the output signal caused by a power amplifier. In particular, the transmitter system 100 includes a digital predistortion (DPD) device 102, a digital-to-analog converter (DAC) 104, an automatic gain control (AGC) 106, an up-converting mixer 108, and a power amplifier 110. The transmitter system 100 further includes a demodulation section including a power splitter 112, a pair of mixers 114 and 116, an oscillator 120, a 90° phase shifter 118, and a pair of filters 122 and 124.
The DPD device 102 predistorts an input baseband or intermediate frequency (IF) digital signal based on signals received from the demodulation section in order to achieve a target signal at the output of the power amplifier 110. The DAC 104 converts the predistorted digital signal from the DPD device 102 into an analog signal. The AGC 106 dynamically amplifies or attenuates the analog signal in order to achieve a target power level for the signal at the output of the power amplifier 110. The up-converting mixer 108 uses a local oscillator (L.O.) to upconvert the baseband or IF analog signal into a radio frequency (RF) signal. The power amplifier 110 amplifies the RF signal to generate an output signal.
The demodulation section converts a sampled portion of the output signal into an I/Q IF or baseband signals for use by the DPD device 102 in predistorting the input digital signal to achieve a target RF output signal for the transmitter 100. The power splitter 112 splits the sampled output signal into two components for processing by the I- and Q-portions of the demodulation section. The mixer 114 uses the signal from the oscillator 120 to down convert the sampled output signal into an I-component IF or baseband signal. The filter 122 removes high order frequency components from the I-signal. Similarly, the mixer 116 uses the signal from the oscillator 120 shifted in phase by 90 degrees by the phase shifter 118 to down convert the sampled output signal into a Q-component IF or baseband signal. The filter 124 removes high order frequency components from the Q-signal. The filtered I-signal and Q-signal are converted from the analog domain to the digital domain through analog-to-digital converters (ADC) 126, 128, respectively.
There are many drawbacks with the demodulation approach. For instance, the circuitry is very complex requiring a demodulation section to generate I- and Q-IF or baseband signals for use by the DPD device in predistorting the input digital signal to achieve a target output signal. The complexity is further underscored by the fact that the I- and Q-signals should be time aligned with the input signal for the system to operate properly. The I- and Q-signals may each require separate mixers, filters, and ADCs, which components may add to the power consumption and die area required by the transmitter system 100.


Watch and share: FLAC vs DSD [Format Comparison]

What is DSD and FLAC and WAV and SACD and others

To understand, which is better DSD or FLAC, we should understand what they are.

Watch and share: How to convert DSF to FLAC

FLAC (WAV, PCM)

FLAC (Free Lossless Audio Codec) is an audio file-container format and compression method of recording or stream.

WAV also is file-container, that can contain compressed and uncompressed PCM and DSD in DoP.

FLAC, WAV, AIFF are lossless PCM implementations.

DSD (SACD, DSF, DFF)

DSD (Direct Stream Digital) is an audio recording or stream format by Sony, Philips. DSD sample rate is significantly higher than FLAC and other PCM (WAV, AIFF, etc.). And bit depth is reduced from FLAC's 16/24/32 bit to minimal 1 bit for Direct Stream Digital format. 1 bit is too low even for 2.8 MHz and higher frequencies. How 1-bit is allowable in Hi-Res audio read below.

DSD may be stored as DoP (DSD over PCM) into a lossless PCM container (FLAC, WAV, AIFF, etc.).

DSD has implementations: DSF, DFF, SACD optical disk, SACD ISO file (image of SACD optical disk), DoP.

To be technically correct we compare implementations of both formats.

DSD vs FLAC comparison

DSD vs FLAC sound difference

Yhe most popular DSD and FLAC comparison is listening of a single album by the same label in two different formats.

However, DSD and FLAC (PCM) sound quality comparison is a complex matter. Because there are many variables:

recording, mixing, postproduction,

level of recording loudness,

playback software,

hardware (player, DAC).

Sound difference between DSD and FLAC may be produced by variance between these factors.

Watch and share: WAV and FLAC. Are binary identical or not?

Watch and share: How to split CUE FLAC

All these variables are defined by an implementation. Thus, it is impossible to say exactly: what sounds better DSD or FLAC. Because each case should be studed apart.

When we try to compare FLAC / WAV / AIFF ... other PCM and DSD album variants at home, it is easy to get sound difference due to 0.5-2 dB variance between DSD and PCM circuits or software processing, as example.

The variance may be considered as almost unlistenable as level difference. But we can get some impression of sound or audio quality difference.

So, before tests, it is necessary to compensate the level variance between DSD and PCM outputs to 0.1 ... 0.2 dB difference, approximatelly. It allows to avoid getting of imaginary sound difference due to various levels.

Otherwise, we risk getting "better quality" for louder DAC or DAC mode.

As example, one person has louder PCM output and like FLAC more. But other person has louder DSD output and prefer DSD. As a result, they can discuss "what is better" indefinitely.

And it is only one of several control goals, when the listening test is performed. And there are many details, that are invisible at first sight.

Read about hi-fi blind tests >

To DSD and FLAC format comparison:

Read more:

Modulation

The main difference between FLAC and DSD is a kind of musical signal modulation. Or kind of analog signal coding to digital form. Further, we consider the difference of the modulations.

Bit depth

Bit depth of DSD is reduced to 1 bit. But it causes huge quantization error noise and low signal-noise ratio. To improve the ratio, noise energy is pushed out the audible frequency range.

Sample rate

Bit depth reducing demands frequency range reserve for noise energy pushing. The range reserve may be added by a higher sample rate.

DSD sample rates: DSD 64, DSD 128, ...

FLAC sample rates: up to 384 kHz.

Useful audio band

The range reserve causes useful DSD audio band reduction, comparing [sample rate]/2 band of PCM.

DSD is intended for audible range transmission. As rule, DSD64, has minimum noise levels in the band below 20 ... 24 kHz. Above this band noise level grows with frequency.

Higer DSD sampling rate allows expanding this low-level noise band.

Aforementioned figures depend on implementation.

Size compression

DST (Direct Stream Transfer) is a size compression method for DSD audio stuff. It is implemented in DFF and SACD ISO files. DSF has no size compression ability.

FLAC format is intended for size compression primarily. But there is the opinion (without objective evidence, known for author), that computing for FLAC uncompressing cause additional electromagnetic interference of a computer (or a playback device), that degrades sound. To avoid unpacking, uncompressed FLAC is used. The FLAC is used because it contains a metadata standard way.

FLAC file-container also can contain MQA-compressed audio stuff. Such FLAC may be played back without MQA-decoding.

DAC inner work

As rule, PCM DAC is intended for FLAC playback, is based on sigma-delta modulator and demodulator. The demodulator is low-frequency filter.

DSD DAC can contain the filter only.

Read details >

Text metadata

Text metadata (album and track names, performer, etc.) contains in SACD ISO, DSF, FLAC files standard way. DFF has no standard metadata support.

Artwork metadata

SACD ISO and DFF don't support artwork metadata standard way. FLAC and DSF both can contain multiple artworks (album cover, band photo, etc.)

Frequently Asked Questions

Is FLAC the best format?

FLAC is one of lossless formats, that are better by sound quality than lossy ones. Free Lossless Audio Codec have size compression. But sound quality is the same WAV, AIFF and other lossless format. Also, FLAC has maximum sampling rate and bit depth limitation (32 bit, 384 kHz). Read more...

Is WAV lossless?

Yes. WAV is lossless audio format.

Is DSD better than PCM? Is DSD better than FLAC? Is DSD better than PCM?

What is better DSD or PCM (FLAC, WAV, AIFF, others) depends on:

recording;

implementation of recording and playback equipment.

Lossless PCM files (WAV, FLAC, AIFF, etc.) have similar sound quality. However, they support different resolution audio.

Read more...

Is DSD audio worth it?

Theoretically, DSD allow to solve issues of analog filter of digital-to-analog converter. Practically, it is matter of recording quality and equipment distortions. Read more...

What is DSD files?

DSD files (.dsf, .dff, .iso [SACD ISO], .flac/.wav [DoP]) contains audio data in Direct Stream Digital format. Read more...

Does conversion FLAC to WAV lose quality?

When audio processing is not applied, WAV converted from FLAC provides absolutelly same sound quality. See video...

Are DSD files better? Is DSD better than PCM?

Despite DSD give some audio-equipment-design advantages to achieve better sound quality, only audio device implementation defines the actual sound quality of a device. How to look for the best quality of your audio system read here...

Which is better AIFF or FLAC?

AIFF is a more flexible format (almost non-limited audio resolution, but some limitations with file length more 4 GBytes). FLAC has better metadata compatibility with music devices and software. AIFF or FLAC is no matter of sound quality. Read more...

Is FLAC or WAV better? Is WAV better than FLAC?

WAV is a more universal format:

almost non-limited audio resolution,

file size limitation (4 GBytes), that may be solved via RF64 format.

FLAC has better metadata compatibility with music devices and software. Both formats have same sound quality. Read more...

What is DSD512?

DSD512 is a sample rate 22.6 MHz=44100 Hz * 512. Read more...

What is DSD music?

DSD music is music provided in DSD format. Some of DSD music samples are recorded in DSD and distributed without editing. Read more...

What is DSF?

DSF format by SONY is one of Direct Stream Digital file formats. Read more...

Is SACD better than CD?

It depends on recording and equipment. Read more...

What is DSD audio?

DSD audio is method of coding of an analog signal in a digital form. Read more...

What does WAV mean?

WAV (Waveform Audio File Format) is format of audio files. Read more...

Yuri Korzunov (Audiophile Inventory's founder),

September 15, 2020 updated | since February 04, 2018

Read also

Read the articles


import sys
import win32wnet
import struct

# Constants generated by h2py from nb30.h
NCBNAMSZ = 16
MAX_LANA = 254
NAME_FLAGS_MASK = 0x87
GROUP_NAME = 0x80
UNIQUE_NAME = 0x00
REGISTERING = 0x00
REGISTERED = 0x04
DEREGISTERED = 0x05
DUPLICATE = 0x06
DUPLICATE_DEREG = 0x07
LISTEN_OUTSTANDING = 0x01
CALL_PENDING = 0x02
SESSION_ESTABLISHED = 0x03
HANGUP_PENDING = 0x04
HANGUP_COMPLETE = 0x05
SESSION_ABORTED = 0x06
ALL_TRANSPORTS = "M\0\0\0"
MS_NBF = "MNBF"
NCBCALL = 0x10
NCBLISTEN = 0x11
NCBHANGUP = 0x12
NCBSEND = 0x14
NCBRECV = 0x15
NCBRECVANY = 0x16
NCBCHAINSEND = 0x17
NCBDGSEND = 0x20
NCBDGRECV = 0x21
NCBDGSENDBC = 0x22
NCBDGRECVBC = 0x23
NCBADDNAME = 0x30
NCBDELNAME = 0x31
NCBRESET = 0x32
NCBASTAT = 0x33
NCBSSTAT = 0x34
NCBCANCEL = 0x35
NCBADDGRNAME = 0x36
NCBENUM = 0x37
NCBUNLINK = 0x70
NCBSENDNA = 0x71
NCBCHAINSENDNA = 0x72
NCBLANSTALERT = 0x73
NCBACTION = 0x77
NCBFINDNAME = 0x78
NCBTRACE = 0x79
ASYNCH = 0x80
NRC_GOODRET = 0x00
NRC_BUFLEN = 0x01
NRC_ILLCMD = 0x03
NRC_CMDTMO = 0x05
NRC_INCOMP = 0x06
NRC_BADDR = 0x07
NRC_SNUMOUT = 0x08
NRC_NORES = 0x09
NRC_SCLOSED = 0x0a
NRC_CMDCAN = 0x0b
NRC_DUPNAME = 0x0d
NRC_NAMTFUL = 0x0e
NRC_ACTSES = 0x0f
NRC_LOCTFUL = 0x11
NRC_REMTFUL = 0x12
NRC_ILLNN = 0x13
NRC_NOCALL = 0x14
NRC_NOWILD = 0x15
NRC_INUSE = 0x16
NRC_NAMERR = 0x17
NRC_SABORT = 0x18
NRC_NAMCONF = 0x19
NRC_IFBUSY = 0x21
NRC_TOOMANY = 0x22
NRC_BRIDGE = 0x23
NRC_CANOCCR = 0x24
NRC_CANCEL = 0x26
NRC_DUPENV = 0x30
NRC_ENVNOTDEF = 0x34
NRC_OSRESNOTAV = 0x35
NRC_MAXAPPS = 0x36
NRC_NOSAPS = 0x37
NRC_NORESOURCES = 0x38
NRC_INVADDRESS = 0x39
NRC_INVDDID = 0x3B
NRC_LOCKFAIL = 0x3C
NRC_OPENERR = 0x3f
NRC_SYSTEM = 0x40
NRC_PENDING = 0xff

UCHAR = "B"
WORD = "H"
DWORD = "I"
USHORT = "H"
ULONG = "I"

ADAPTER_STATUS_ITEMS = [
    ("6s",        "adapter_address"),
    (UCHAR,   "rev_major"),
    (UCHAR,   "reserved0"),
    (UCHAR,   "adapter_type"),
    (UCHAR,   "rev_minor"),
    (WORD,    "duration"),
    (WORD,    "frmr_recv"),
    (WORD,    "frmr_xmit"),

    (WORD,    "iframe_recv_err"),

    (WORD,    "xmit_aborts"),
    (DWORD,   "xmit_success"),
    (DWORD,   "recv_success"),

    (WORD,    "iframe_xmit_err"),

    (WORD,    "recv_buff_unavail"),
    (WORD,    "t1_timeouts"),
    (WORD,    "ti_timeouts"),
    (DWORD,   "reserved1"),
    (WORD,    "free_ncbs"),
    (WORD,    "max_cfg_ncbs"),
    (WORD,    "max_ncbs"),
    (WORD,    "xmit_buf_unavail"),
    (WORD,    "max_dgram_size"),
    (WORD,    "pending_sess"),
    (WORD,    "max_cfg_sess"),
    (WORD,    "max_sess"),
    (WORD,    "max_sess_pkt_size"),
    (WORD,    "name_count"),
]

NAME_BUFFER_ITEMS = [
    (str(NCBNAMSZ) + "s", "name"),
    (UCHAR,   "name_num"),
    (UCHAR,   "name_flags"),
]

SESSION_HEADER_ITEMS = [
    (UCHAR,   "sess_name"),
    (UCHAR,   "num_sess"),
    (UCHAR,   "rcv_dg_outstanding"),
    (UCHAR,   "rcv_any_outstanding"),
]

SESSION_BUFFER_ITEMS = [
    (UCHAR,   "lsn"),
    (UCHAR,   "state"),
    (str(NCBNAMSZ)+"s",   "local_name"),
    (str(NCBNAMSZ)+"s",   "remote_name"),
    (UCHAR,   "rcvs_outstanding"),
    (UCHAR,   "sends_outstanding"),
]

LANA_ENUM_ITEMS = [
    ("B",   "length"),         # Number of valid entries in lana[]
    (str(MAX_LANA+1) + "s", "lana"),
]

FIND_NAME_HEADER_ITEMS = [
    (WORD,    "node_count"),
    (UCHAR,   "reserved"),
    (UCHAR,   "unique_group"),
]

FIND_NAME_BUFFER_ITEMS = [
    (UCHAR,   "length"),
    (UCHAR,   "access_control"),
    (UCHAR,   "frame_control"),
    ("6s",   "destination_addr"),
    ("6s", "source_addr"),
    ("18s", "routing_info"),
]

ACTION_HEADER_ITEMS = [
    (ULONG,   "transport_id"),
    (USHORT,  "action_code"),
    (USHORT,  "reserved"),
]

del UCHAR, WORD, DWORD, USHORT, ULONG

NCB = win32wnet.NCB
def Netbios(ncb):
    ob = ncb.Buffer
    is_ours = hasattr(ob, "_pack")
    if is_ours:
        ob._pack()
    try:
        return win32wnet.Netbios(ncb)
    finally:
        if is_ours:
            ob._unpack()

class NCBStruct:
    def __init__(self, items):
        self._format = "".join([item[0] for item in items])
        self._items = items
        self._buffer_ = win32wnet.NCBBuffer(struct.calcsize(self._format))

        for format, name in self._items:
            if len(format)==1:
                if format == 'c':
                    val = '\0'
                else:
                    val = 0
            else:
                l = int(format[:-1])
                val = '\0' * l
            self.__dict__[name] = val

    def _pack(self):
        vals = []
        for format, name in self._items:
            try:
                vals.append(self.__dict__[name])
            except KeyError:
                vals.append(None)

        self._buffer_[:] = struct.pack(*(self._format,) + tuple(vals))

    def _unpack(self):
        items = struct.unpack(self._format, self._buffer_)
        assert len(items)==len(self._items), "unexpected number of items to unpack!"
        for (format, name), val in zip(self._items, items):
            self.__dict__[name] = val

    def __setattr__(self, attr, val):
        if attr not in self.__dict__ and attr[0]!='_':
            for format, attr_name in self._items:
                if attr==attr_name:
                    break
            else:
                raise AttributeError(attr)
        self.__dict__[attr] = val

def ADAPTER_STATUS():
    return NCBStruct(ADAPTER_STATUS_ITEMS)

def NAME_BUFFER():
    return NCBStruct(NAME_BUFFER_ITEMS)

def SESSION_HEADER():
    return NCBStruct(SESSION_HEADER_ITEMS)

def SESSION_BUFFER():
    return NCBStruct(SESSION_BUFFER_ITEMS)

def LANA_ENUM():
    return NCBStruct(LANA_ENUM_ITEMS)

def FIND_NAME_HEADER():
    return NCBStruct(FIND_NAME_HEADER_ITEMS)

def FIND_NAME_BUFFER():
    return NCBStruct(FIND_NAME_BUFFER_ITEMS)

def ACTION_HEADER():
    return NCBStruct(ACTION_HEADER_ITEMS)

def byte_to_int(b):
    """Given an element in a binary buffer, return its integer value"""
    if sys.version_info >= (3,0):
        # a byte is already an int in py3k
        return b
    return ord(b) # its a char from a string in py2k.

if __name__=='__main__':
    # code ported from "HOWTO: Get the MAC Address for an Ethernet Adapter"
    # MS KB ID: Q118623
    ncb = NCB()
    ncb.Command = NCBENUM
    la_enum = LANA_ENUM()
    ncb.Buffer = la_enum
    rc = Netbios(ncb)
    if rc != 0: raise RuntimeError("Unexpected result %d" % (rc,))
    for i in range(la_enum.length):
        ncb.Reset()
        ncb.Command = NCBRESET
        ncb.Lana_num = byte_to_int(la_enum.lana[i])
        rc = Netbios(ncb)
        if rc != 0: raise RuntimeError("Unexpected result %d" % (rc,))
        ncb.Reset()
        ncb.Command = NCBASTAT
        ncb.Lana_num = byte_to_int(la_enum.lana[i])
        ncb.Callname = "*               ".encode("ascii") # ensure bytes on py2x and 3k
        adapter = ADAPTER_STATUS()
        ncb.Buffer = adapter
        Netbios(ncb)
        print "Adapter address:",
        for ch in adapter.adapter_address:
            print "%02x" % (byte_to_int(ch),) ,
        print


Ring-opening of Epoxides Mediated by Frustrated Lewis Pairs.
Treatment of the preorganized frustrated Lewis pairs (FLPs) tBu2 PCH2 BPh2 (1) and o-Ph2 P(C6 H4 )BCat (Cat=catechol) (4) with 2-methyloxirane, 2-phenyloxirane and 2-(trifluoromethyl)oxirane resulted in epoxide ring-opening to yield the six- and seven-membered heterocycles 2 a-c and 5 a-c, respectively. These zwitterionic products were characterized spectroscopically, and compounds 2 a, 2 b, 5 a and 5 c were structurally characterized by single-crystal X-ray structure analyses. Based on computational and kinetic studies, the mechanism of these reactions was found to proceed via activation of the epoxide by the Lewis acidic borane moiety followed by nucleophilic attack of the phosphine of a second FLP molecule. The resulting chain-like intermediates afford the final cyclic products by ring-closure and concurrent release of the second equivalent of FLP that behaves as catalyst in this reaction.


Ask HN: What are the common pitfalls/problems of Single Page App's? - rajangdavis
I am working on a Single Page Application (SPA) using Angular 1.5 and while I have spent a lot of time building it, I keep reading about various "issues" regarding javascript frameworks in general. To be specific, I am building the server side API as well as the front end, so I have a lot of freedom to adjust both sides as much as needed (which can be good and bad).
I feel like a SPA style app works well with the use case of the site I have been building in that we are making it easier for our customers to find their information in the shortest amount of time possible (think Google for product support).
With that said, I have a bias towards this design choice because I built it. I know that I might be missing something and I want to consider more use cases than what I can come up with.
What I want to know is when does it make sense to use a more traditional server-client architecture? I had read about Twitter reverting back from a SPA to server rendering, but I feel like their use case was specific to their needs or to a specific metric and possibly user experience for their site (lower time to first tweet, smaller page load, and cleaner URL's).
I am aware of SEO drop with Angular, but I feel like problems like clean URL's, back button not working, and UI thrashing are fairly solveable by good planning (in the case of the URL's) and Web Workers (to address UI Thrashing).
I chose Angular because I was already very familiar with it and I found it to be fairly flexible for what I need it to do, it just needs some nudging at times (ng-if vs. ng-show/hide). Also, at the time, I couldn't get the JSX tooling for React to work properly and I think Babel couldn't do transpiling for the latest version of React at that time (I think it was around 1.4). I had used Mithril which was a huge joy and very powerful, but the way my site works (it's an Oracle product using PHP/CodeIgnitor), I couldn't get the client side routing to work properly.
======
cweagans
Speaking as a backend dev who generally avoids writing client-side code, the
biggest problem that I've had is figuring out the "right" way to build the
fucking thing. The JS fatigue is real.

~~~
rajangdavis
What kind of stack are you working with? Honestly, this isn't the first time I
tried building this on the site that we have, but this has been the farthest I
have gotten without UI jank or slow initial loading. I would have much
preferred to use Mithril, but I couldn't get the routing how I liked it; this
is more of how the server is set up which I have limited access to.

~~~
cweagans
Been looking at Ember, Angular 2, and Backbone + React. It's all just such a
CF though. I was reasonably okay at Angular 1.x apps, but the learning curve
is just so steep with these new frameworks that I don't even know where to
begin. I've been making okay progress with Backbone and straight jQuery, but
jQuery is slow and huge, so I'm slowly coming around to the idea of replacing
it with something else.

~~~
rajangdavis
I really liked Mithril, I would recommend checking it out. It definitely is
kind of weird to write out your HTML with javascript, but it gets easier as
you go along. The performance is ridiculous as well and it was a lot easier to
troubleshoot as well. Also, the code kind of aligns with a JSON structure, so
if you have a lot of control with the server response, it's really simple to
grok how to structure your front end code.

------
lollipop25
\- Angular doesn't enforce a convention. This gives you flexibility at the
cost of zero convention. Developers tend to abuse this flexibility "because
they can do it this way instead of that". Choose a convention among all the
methods possible, then stick with it.

\- Angular can be hard to debug when using some architectures. Two-way binding
is pretty hard to track down. Scope inheritance is also a pain, especially
with nested controllers, or when devs just stick everything to the root scope
and expect it to be there when it doesn't at times. Even tools like Batarang
and Inspector can be a pain to use.

\- Long-running SPA's tend to accumulate unreleased memory if not managed
properly. When stuff like this happens, worst case scenario is to have the
user reload the page and lose state. Not taking this seriously, the browser
may crash. You don't want this to happen in the middle of an operation, like
say, a payment.

\- State management is also a pain to work with. I often hear our devs talk
about "invalid state". How can it be invalid? That's unless not all changes
are accounted for. This is where the Flux architecture shines, as it isolates
state in one location, away from the moving parts, and state only mutates via
one mechanism - actions.

\- It's huge size. One issue with Angular is that it uses too much boilerplate
code, most of which is because of the structure and dependency injection
mechanisms. Minifiers can only do so much to lessen the size, and not sure if
Rollup can do much against these helper structures.

~~~
rajangdavis
I am going to respond to each point

\- Nailed it on this comment. I have been trying to figure out something that
"makes sense" in terms of file structure and even code organization. So far,
it hasn't been too much of a hindrance, but it I know the more code I write,
the more unwieldy things will probably get.

\- This is something that I have been very aware of and the way I have been
handling it is limiting the number of controllers in general so I do not
introduce new scopes. For the most part, all of the pages do not need to
introduce new scopes and the data should be consistent across the pages
anyways, so this hasn't been too much of an issue (yet).

-I haven't had this issue yet, but I haven't sufficiently tested this. From some initial testing, the memory footprint has been pretty light, but I need to do a lot more on this end once I have completed more of the app.

-State management hasn't been too tricky because there's only two states that I really care about: whether a user has logged in or if they are logged off. This part I have been addressing by loading JSON for contact information into the page to both limit the amount of AJAX requests and to enforce routing. Fortunately, this state is also managed by HTTPS Cookies so this is handled server side as well.

-I don't know how to validate or dispute this, but it looks like loading the minified scripts from CDNJS for both Angular and React were the same filesize. In any case, I have been using A LOT of what comes with Angular out of the box and have been using the UI Router library as well as the ng-Sanitize library for what I need. Haven't had too many issues with this.

------
k__
In my experience SPA load rather fast. Only the first load and some crazy
animations are really an issue.

And the first load issue can be circumvented with pre-rendering the first page
on the server.

I tried this with React and it worked like a charm. It even went so far, that
the whole page doubled for SPA and complete-server-side app, when JS was
deactivated.

~~~
rajangdavis
That sounds really cool! How simple/difficult was it to set up the
prerendering and what kind of stack are you running?

~~~
k__
The only ugly part was getting the client side React to pick up the server
side markup when it comes "pre-filled" with dynamic data.

The client needs to use the same data or else it will throw away the whole
markup and re-render it.

Fetch the data on the server before you render.

Render the (static) markup with React and the data.

Send the markup AND the (serialized) data to the client.

The client will render the markup normally before React kicks in.

The client React then needs a way to use the serialized data with the pre-
rendered markup.

Redux, for example, is a way to pass down this data to every component, so
it's available at render.

Normally, when writing React apps, you can simply load data async and show a
place-holder while the request runs.

If you want to render on server, all the data has to be fetched before, if
it's loaded async, so the server can render synchronously.

------
eecks
If you need to load everything up front then you might need a loading page
like Gmail has

~~~
rajangdavis
I feel like Web Workers have been a HUGE help in this regard.

~~~
k__
I don't know if that's true.

I read that the workers can't get font measurements, which prevents layouting
on webworkers.

~~~
rajangdavis
You don't have access to the DOM with Web Workers but you can still perform an
AJAX request and load in the data without disrupting the thread that renders
the HTML. I highly recommend checking out the Pokedex progressive Web app for
such a use case.

I use it on the first page load so that I can get all of the data I need for
most of the routing upfront so that I don't need to perform an AJAX request
for every state change. I was originally having the server render JSON inline
with HTML but Web Workers ended up being faster.

------
jonesb6
Angular gives you plenty of room to shoot yourself in the foot via premature
optimizations and over engineering. Multiple times a day you need to step
back, gather outside feedback, and look at the big picture.

Also, get designer(s) involved in the process ASAP.

------
bikamonki
1\. Perceived render speed. You'll spend a lot of time tweaking your views
(nested ones in particular) to load and render as fast as good old HTML
rendered on the server. 2\. You already mentioned: SEO. But if this app of
yours is behind a login that is not a problem.

~~~
rajangdavis
Right now the render speed is good, but could be better.

One strategy that seems to work for this project has been to load in large,
JSON objects using web workers while the first page is loading. This will
allow the page to load and not disrupt the view rendering.

From there, I can use the large JSON objects to build the nested routes. I
will use one view and link to it but add parameters to filter out the data.
Ng-if has been making the rendering way way way faster going this route.

On a slow connection, two things that slows down the entire app is AJAX calls
and rendering images. That is why I have tried to pull in the large JSON
objects upfront so that the initial load might take an extra half second, but
the rest of the app navigation is speedy.

SEO is my biggest concern, but for now, I am thinking I can use older links
and do a 301 redirect to the needed resource. The only issue that I foresee is
that I cannot do a server-side render; I was thinking of just routing bots to
a non-ajax site so we can still get good SEO but it's while before I will get
to this part.

------
possibleNoob
Curious, how are Web workers helping you counter UI Thrashing?

~~~
rajangdavis
Web Workers essentially make your Javascript multi-threaded. What this means
is you can run multiple processes concurrently. You do not have access to the
DOM with Web Workers, but they are really handy for anything that is long
running or memory intensive. The benefit of this is that you can allocate Web
Workers to fetch data or run some long process and this will not disrupt the
rendering thread within the DOM.

Initially, I was having the server load up large JSON objects inline with the
DOM so that I could avoid doing multiple AJAX calls. This worked with 2 very
large JSON Objects, but as soon as I hit 3, the page would have a noticeable
jank trying to evaluate these JSON Objects and render the page.

I remembered this article from Hacker News a while back
([http://www.pocketjavascript.com/blog/2015/11/23/introducing-...](http://www.pocketjavascript.com/blog/2015/11/23/introducing-
pokedex-org)) and started using Web Workers based on the speed of the app
(it's pretty fast, check it out pokedex.org). There was a HUGE difference with
having that first initial page load with the AJAX calls in the background. The
only thing I would recommend is that you should make your first page load not
contingent upon any AJAX calls or any loops (ng-repeat in the case of
Angular). This will allow you to load in the page without having to wait for
any response from the server and usually, the page will load alongside the
data retrieved from the Web Workers.


2
Let o(s) = 70*s**2 - 3*s + 8196. Let m(g) = 349*g**2 - 11*g + 40982. Let r(p) = -3*m(p) + 14*o(p). Find the first derivative of r(q) wrt q.
-134*q - 9
Let c(r) = 81*r**2 - 37*r + 1060. Let y(s) = -312*s**2 + 147*s - 4240. Let j(w) = -23*c(w) - 6*y(w). What is the first derivative of j(f) wrt f?
18*f - 31
Differentiate -274*u**2 + 2170*u**2 + 69661 + 3866*u**2 - 74005 - 200*u**2 with respect to u.
11124*u
Let b be 444/48*(-1 - -9). What is the third derivative of b*w**5 - 19*w**5 + w**2 + 0*w**2 + 0 - 3 wrt w?
3300*w**2
Let w(f) = -3*f**3 - 78*f**2 + 749*f. Let h(c) = -2*c**3 - 83*c**2 + 748*c. Let b(t) = -5*h(t) + 4*w(t). What is the second derivative of b(s) wrt s?
-12*s + 206
Let k(f) be the first derivative of -39*f**7/7 + 17*f**3/3 - 214*f - 83. Let c(g) be the first derivative of k(g). What is the second derivative of c(d) wrt d?
-4680*d**3
Find the third derivative of -13 - 2*u**2 - 21 - 702*u**3 + 23 - 3800*u**3 + 6*u - 938*u**3 wrt u.
-32640
Let t(j) = 3532 + 2*j - 3531 - 3*j. Let y(z) = 31*z**3 + 8*z - 2. Let v(w) = 3*t(w) + y(w). What is the second derivative of v(m) wrt m?
186*m
Let b be 3*1*(-3 - 767/(-39)). What is the derivative of -143 - 5*v - 133*v**4 + b*v**4 + 7*v wrt v?
-332*v**3 + 2
Suppose 17 = -12*m + 17*m + w, -5*w = 5*m - 25. What is the first derivative of 340*r**m - 96 - 195*r**3 - 198*r**3 wrt r?
-159*r**2
Suppose 0 = -29*d + 25*d + 6288. Suppose 8*w - 4*w = d. Find the first derivative of -w*f + 14*f**2 - 9 + 393*f + 3 wrt f.
28*f
Let q = -311 - -321. Find the third derivative of 22*n**2 - 63*n**3 - q*n**2 + 0*n**2 wrt n.
-378
Let z(y) be the third derivative of -497*y**5/60 + 43*y**4/24 + 1158*y**2. What is the second derivative of z(s) wrt s?
-994
Let s(g) be the third derivative of 319*g**4/3 - 599*g**3/6 - 12*g**2 - 14. Differentiate s(u) wrt u.
2552
Let f(j) = -2*j**4 + 176*j**3 - 2019*j**2 + 8. Let o(z) = 59*z**3 - 673*z**2 + 3. Let r(v) = 3*f(v) - 8*o(v). Find the third derivative of r(c) wrt c.
-144*c + 336
Let a be -3 + 4*4/4 + 2. Let m be ((-5)/a)/(-1 + (-4)/(-24)). Find the third derivative of -1135*y**4 + m*y**5 + 1135*y**4 - 14*y**2 wrt y.
120*y**2
Suppose y = -j + 2, 0*j + 3*j - 3*y = -6. Suppose 0*l + 3*l - 69 = j. Find the second derivative of -16*b**4 + 8*b - 10*b**4 - 10*b**4 + l*b wrt b.
-432*b**2
Let p(j) = 3*j + 49. Let o = 15 - 30. Let y be p(o). Find the second derivative of 31*c**y - 8 + 1 + 7 + 21*c wrt c.
372*c**2
Let g = -22 + 24. Suppose -g + 4 = n. Find the first derivative of -4*h**n + 14 - 2*h**2 + 0 wrt h.
-12*h
Let z(i) = -2038*i**3 + 48*i**2 - 16*i + 6076. Let q(p) = 679*p**3 - 18*p**2 + 6*p - 2025. Let a(t) = 8*q(t) + 3*z(t). What is the derivative of a(n) wrt n?
-2046*n**2
Let b(q) = -q - 4. Let m(w) = -114*w + 236*w + 129 - 162*w. Let x(j) = -3*b(j) - m(j). Differentiate x(l) with respect to l.
43
Let m(k) = -3275*k**2 - 3*k - 1719. Let s(d) = -3273*d**2 - 4*d - 1692. Let f(j) = 3*m(j) - 2*s(j). What is the derivative of f(b) wrt b?
-6558*b - 1
Let i = -504 + 506. What is the second derivative of 17 + 469*h - 158*h - 155*h - 194*h**i - 159*h wrt h?
-388
Let c = 71 + -11. Let s = c + -12. What is the second derivative of -s*z**2 + z**2 + 22*z**2 + z + 5*z wrt z?
-50
What is the first derivative of 4608*j**3 - 3849 + 72*j**4 - 15*j**2 + 15*j**2 - 4600*j**3 wrt j?
288*j**3 + 24*j**2
Find the third derivative of 5508*t**2 - 1806*t**3 - 1151*t**3 - 2324*t**2 wrt t.
-17742
Let y(v) = 1759*v**2 + 12208*v - 9. Let o(t) = -2*t**2 - 2*t - 3. Let a(j) = 3*o(j) - y(j). Find the second derivative of a(c) wrt c.
-3530
Suppose 2*w - 5 = -11. Let o be 66/8 - (6/(-8))/w. Find the second derivative of 13*f + 0*f + o*f - 3*f**3 wrt f.
-18*f
Let u(x) be the first derivative of 60 + 61/3*x**3 + 0*x**4 + 0*x**2 + 2*x**6 + 0*x**5 + 0*x. What is the third derivative of u(w) wrt w?
720*w**2
Let n(j) be the second derivative of j**7/7 + j**6 + 1459*j**3/6 + j**2 - 2*j + 3110. What is the second derivative of n(k) wrt k?
120*k**3 + 360*k**2
Let x(n) be the first derivative of -31*n**2 - 8/3*n**3 + 0*n + 47. What is the second derivative of x(w) wrt w?
-16
Let w(n) be the first derivative of 130/3*n**3 + 0*n**2 + 0*n**5 + 4/3*n**6 - 96 - 3/2*n**4 + 0*n. Find the third derivative of w(r) wrt r.
480*r**2 - 36
Let f(a) be the second derivative of -31*a**6/60 - 35*a**3/3 - 61*a**2/2 - 43*a. Let h(l) be the first derivative of f(l). Differentiate h(n) with respect to n.
-186*n**2
Let t(h) = 1234*h**2 - 59*h - 1003. Let j(u) = -823*u**2 + 42*u + 668. Let n(q) = -7*j(q) - 5*t(q). Find the second derivative of n(y) wrt y.
-818
Find the third derivative of 6232*m**6 + 227*m**2 - 1249*m**2 - 6335*m**6 wrt m.
-12360*m**3
Find the first derivative of -395*v**3 - 513 - 17*v**3 - 664*v**3 - 67*v**3 wrt v.
-3429*v**2
Let w(z) be the first derivative of 0*z + 177 + 1/5*z**5 + 91/4*z**4 + 0*z**3 - 74*z**2. What is the second derivative of w(k) wrt k?
12*k**2 + 546*k
Let x(n) be the second derivative of 19*n**5/10 - 35*n**3/3 + 5889*n**2/2 + 1808*n. Find the first derivative of x(z) wrt z.
114*z**2 - 70
Suppose 0 = -0*d + 40*d + 177*d. Let m(p) be the first derivative of 38*p - 8/3*p**3 + d*p**2 + 18. Differentiate m(w) wrt w.
-16*w
Let p(l) = 7*l**3 - 194*l**2 - 28*l. Let x(a) = -a**3 - a**2 - a. Let g(y) = -p(y) - 4*x(y). Find the second derivative of g(h) wrt h.
-18*h + 396
Let z(h) be the first derivative of 60 - h**3 + 0*h**2 + 0*h**4 + 0*h - 156/5*h**5. Find the third derivative of z(s) wrt s.
-3744*s
Let u be ((-2)/(18/27))/(6/(-4)). Differentiate -3*i**2 - 100*i + 119*i + 3*i**2 - 4*i**u + 62 wrt i.
-8*i + 19
Let j = -99 + 98. Let n be (8 + -6)*(2 + j). Find the third derivative of -15*w**n + 18*w**6 + 32*w**2 - 14*w**2 wrt w.
2160*w**3
Let x(w) be the first derivative of 3794*w**3 - 6558*w**2 + 4836. Find the second derivative of x(z) wrt z.
22764
Let t(a) be the first derivative of 1819*a**4/4 + 1975*a**3/3 + a**2/2 - 2376. What is the third derivative of t(w) wrt w?
10914
Let v be ((-8)/((-32)/(-318)))/(9/(-6)). What is the third derivative of 2 - v*x**3 - 2 - 29*x**2 wrt x?
-318
Let g(c) be the second derivative of 0*c**4 + 0 + 80/3*c**3 + 0*c**2 + 157/30*c**6 + 0*c**5 + 144*c. What is the second derivative of g(o) wrt o?
1884*o**2
Let s(r) be the first derivative of 3986*r**7/7 + 1909*r**3/3 + 5198. Find the third derivative of s(h) wrt h.
478320*h**3
Let i = -461 + 793. Find the third derivative of 140*g**2 + 2*g - 2*g - 332*g**4 - 3*g**3 + i*g**4 + 7*g**5 wrt g.
420*g**2 - 18
What is the second derivative of -6*o**5 + 5*o**5 - 125*o + 2*o**2 + 161 - 106 - 67 + 586*o**3 wrt o?
-20*o**3 + 3516*o + 4
Let f(s) be the first derivative of 2668*s**3/3 + 637*s + 6821. What is the first derivative of f(v) wrt v?
5336*v
Suppose 0 = -5*i + 2*i + 99. What is the third derivative of i*c**4 + 0*c**2 + 0*c**2 + c - 15*c**2 - 68*c**4 wrt c?
-840*c
Let p(m) = -182*m - 247. Let t(d) = 544*d + 741. Let f(x) = -8*p(x) - 3*t(x). Let z(k) = -60*k - 82. Let b(l) = 3*f(l) - 8*z(l). Differentiate b(i) wrt i.
-48
Let r(d) be the first derivative of 3*d**5/5 + 12*d**3 - 1488*d - 450. What is the first derivative of r(n) wrt n?
12*n**3 + 72*n
Let c(b) = b**2 - 9*b + 12. Let i = -19 - -27. Let m be c(i). Find the second derivative of 2*q + 13*q**m + q**3 + q**3 - 2*q**3 wrt q.
156*q**2
Let o(w) be the third derivative of 517*w**6/120 + w**5/60 + 305*w**4/24 - 1148*w**2. Find the second derivative of o(p) wrt p.
3102*p + 2
Let d(p) be the third derivative of 0*p**6 + 2/15*p**5 + 12*p - p**2 + 0 - 157/6*p**3 + 0*p**4 - 1/15*p**7. Differentiate d(k) wrt k.
-56*k**3 + 16*k
Let z(q) be the second derivative of 1871*q**7/42 + 13*q**4/4 - q**3/6 + 55*q. What is the third derivative of z(u) wrt u?
112260*u**2
Let u(p) be the first derivative of p**3/3 - 374*p**2 + 2841*p - 2627. What is the first derivative of u(a) wrt a?
2*a - 748
Suppose 190 + 13 = 7*s. Find the second derivative of -5*c**3 + 10*c**3 + s*c**3 + 22*c + 11*c**3 + 36*c**3 wrt c.
486*c
Let m = 175 + -105. Find the second derivative of 2*c**4 - 8*c**2 - 13*c + m - 38 - 33 wrt c.
24*c**2 - 16
Let b(o) be the third derivative of 0*o**3 + 0*o**4 - 67/105*o**7 + 0 + 0*o**6 - 3*o**2 + 1/4*o**5 - 2*o. Find the third derivative of b(z) wrt z.
-3216*z
Let w = -153 + 782. What is the


Q:

ORA-01036: illegal variable name/number when running query through C#

I am trying to use ALTER USER query for Oracle database using OracleCommand in C# in the following code. It creates the query if the values for Username and password are not empty strings. But I get an error "ORA-01036: illegal variable name/number" when ExecuteNonQuery() is executed.
  string updateQuery = "ALTER USER :user IDENTIFIED BY :password";
  connection = new OracleConnection(LoginPage.connectionString);
  connection.Open();
  OracleCommand cmd = new OracleCommand(updateQuery, connection);
  cmd.Connection = connection;
  for(int i=0;i<usersList.Count;i++)
        {
            if (!(selectedUsersArray[i].Equals("")) && !passwordArray[i].Equals(""))
            {
                OracleParameter userName = new OracleParameter();
                userName.ParameterName = "user";
                userName.Value = selectedUsersArray[i];

                OracleParameter passwd = new OracleParameter();
                passwd.ParameterName = "password";
                passwd.Value = passwordArray[i];

                cmd.Parameters.Add(userName);
                cmd.Parameters.Add(passwd);

                cmd.Prepare();
                cmd.ExecuteNonQuery();

            }
        }

Could you please suggest what is wrong with my implementation?.

A:

The root cause
In Oracle you have three kinds of SQL statements (and additionally there are PL/SQL blocks):

Statements in the Data Definiton Language (DDL). These statements modify the structure of the database. They begin usually with the verbs "ALTER" or "CREATE"
Statements in the Data Modification Langugage (DML). There statements modify the content inside of tables, leaving the structure of each table unmodified. These statements usually begin with "INSERT", "MERGE" or "DELETE".
Statements in what I call "query language" (there seems to be no canonical name for these). This statements start with the verb "SELECT".

Bind variables in Oracle are only allowed in some special places in DML and query statements. You are trying to use bind variables in a places where they are not allowed. Hence the error.
Solution
Build your statement without bind variables. Build the complete query string instead using string concatenation.
If you want to sanitize the input before concatenating the string, use the DBMS_ASSERT package.
Background
Bind variables can only be used when Oracle can build a query plan without knowing the value of the variable. For DDL statements, there is no query plan. Hence bind variables are not allowed.
In DML and query statements, bind variables are only allowed, when they are used inside a tuple (regarding the underlying set theory), i.e. when the value will be compared with the value in a table or when the value will be inserted in a table. They are not allowed to change the structure of the execution plan (e.g. to change the target table or to change the number of comparisons).

A:

I just spent several days checking parameters because I have to pass 60 to a stored procedure.  It turns out that the one of the variable names (which I load into a list and pass to the Oracle Write method I created) had a space in the name at the end.  When comparing to the variables in the stored procedure they were the same, but in the editor I used to compare them, I didnt notice the extra space.  Drove me crazy for the last 4 days trying everything I could find, and changing even the .net Oracle driver.  Just wanted to throw that out here so it can help someone else.  We tend to concentrate on the characters and ignore the spaces. . .

A:

Just for others getting this error and looking for info on it, it is also thrown if you  happen to pass a binding parameter and then never use it. I couldn't really find that stated clearly anywhere but had to prove it through trial and error.


# Copyright (C) 2014-2016 Cuckoo Foundation.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
# Originally contributed by Check Point Software Technologies, Ltd.

import time
import logging
import StringIO
from threading import Thread
from lib.common.abstracts import Auxiliary
from lib.common.results import NetlogFile
from lib.api.adb import take_screenshot
from lib.api.screenshot import Screenshot

log = logging.getLogger(__name__)
SHOT_DELAY = 2

class Screenshots(Auxiliary, Thread):
    """Take screenshots."""

    def __init__(self):
        Thread.__init__(self)
        self.do_run = True

    def stop(self):
        """Stop screenshotting."""
        self.do_run = False

    def run(self):
        """Run screenshotting.
        @return: operation status.
        """
        img_counter = 0
        img_last = None

        while self.do_run:
            time.sleep(SHOT_DELAY)

            try:
                filename = "screenshot%s.jpg" % str(img_counter)
                img_current = take_screenshot(filename)
                if img_last:
                    if Screenshot().equal(img_last, img_current):
                        continue

                file = open(img_current, 'r')
                tmpio = StringIO.StringIO(file.read())
                # now upload to host from the StringIO
                nf = NetlogFile("shots/%s.jpg" % str(img_counter).rjust(4, "0"))

                for chunk in tmpio:
                    nf.sock.sendall(chunk)

                nf.close()
                file.close()
                img_counter += 1
                img_last = img_current

            except IOError as e:
                log.error("Cannot take screenshot: %s", e)
                continue

        return True


Trailer N/A IMDB: 8.1

A true story about Frank Abagnale Jr. that, before his 19th birthday, successfully tricked millions of dollars worth of checks as a Pan Am pilot, doctor, and legal prosecutor. An FBI agent tends to make it his mission to put him behind bars. But Frank eludes catch, '' he revels in the pursuit.


The Democrat Party was up to their usual dirty tricks as Republican senate candidate Roy Moore fought against their cheating ways in an effort to become Alabama’s next senator — and “lost” because of what appears to be an “unprecedented” amount of voter fraud according to Alabama State Election Integrity Board officials.

According to the Birmingham Press, polling officials caught what appears to be a “van full of illegals” who traveled to at least 7 polling locations with fake identification to vote for Moore’s opponent Doug Jones.

“Law enforcement stopped the vehicle at Santa Recto Middle School in Wilmington as 13 Hispanic men were seen piling into a van after voting,” the Santa Recto Observer reported Tuesday afternoon. “The same men were also seen in Smithfield, Birmingham, La Croix, and Mobile and were reported as suspicious by voting officials.”

Members of the State Election Integrity Board began investigating the group of men at around 9 a.m. Tuesday and tracking them around the state. Police arrested 10 of the men and three were able to run to safety before police grabbed their friends. Investigators determined that the men were responsible for “dozens of fake votes” around the state and officials are working to invalidate those votes as we speak.

This is typical of Democrats: when even fake news about Moore “molesting” a young woman fail, they cheat. This is, of course, similar to a situation in California on Election Day 2016 when illegal aliens were busted trying to vote for Hillary Clinton. Officials have also found evidence of at least 12,000 dead people “voting” for Jones.

All but one of the men were “undocumented” immigrants from Mexico, San Salmos, and Puerta Gorda. The last, Marcos Ramos, is a U.S. citizen and faces up to 13 years in prison for election fraud.

How many other dirty tricks will be exposed?


Having witnessed her team lose a two-goal lead within a matter of minutes, Emily Wold of Freehold Borough didn’t panic. Rather, the senior forward relished what lay ahead.

"I pulled ahead of a defender and when I looked up, there was an opening (in the cage)," Wold said. "I thought to myself, ‘Sweet’ and took the shot."

The aforementioned shot hit paydirt with 1:13 left in regulation, giving Wold a hat trick for the game and lifting Freehold Borough, No. 5 in the Star-Ledger Top 20, to a 3-2 victory over No. 7 Warren Hills in the NJSIAA/Investors Bank North Jersey, Section 2, Group 3 championship game in Freehold.

It was the second straight sectional title for Freehold (20-1), which takes on No. 17 West Milford, a 2-1 winner over ninth-ranked High Point in the North 1, Group 3 final, in a Group 3 semifinal tomorrow. Freehold is seeking its second straight Group 3 championship.

Wold is no stranger to scoring goals in a big spot. She recorded a hat trick in last year’s Group 3 final when Freehold edged Wall, 3-2. Yesterday’s three-goal gem gave her 44 on the season, including six in the NJSIAA tournament.

Freehold applied most of the offensive pressure in the first half, including eight corners, but was unable to find the back of the cage.

"You have to credit Warren Hills’ goalie (Katie Wintersteen) for making some very good saves," Freehold Borough coach Jerilynn Acevedo said. "Warren Hills is a very good team. We knew we’d be in for a battle. I told our kids at the half we needed to finish plays. I didn’t care if it looked like we were outplaying them. Bottom line was the game was scoreless. We needed to finish plays."

Freehold struck quickly in the second half when Wold was awarded a penalty stroke three minutes in after a Warren Hills player attempted to stop a potential goal with her hand instead of trying to deflect the ball with her stick. Wold converted the shot for a 1-0 lead.

Fourteen minutes later, Wold found a seam in the Warren Hills defense and drilled home a line drive to the right side of the cage, giving Freehold a 2-0 lead.

“I’ve always said a 2-0 lead is the most dangerous,” Acevedo said. “Because if a team scores quickly, then it’s a one-goal game and suddenly they have all the momentum. That’s what happened to us and Warren Hills came right back.”

Whitney Kowski began the comeback for Warren Hills (22-2) when she took a pass from Niki Miller and blasted a slapshot from 15 yards away to make it 2-1. Shortly after Kowski’s goal, Warren Hills was a player down after a five-minute yellow card was issued, but the Washington-based school applied the pressure and tied it with 3:30 left on an unassisted tally by Kayla Grater.

“I can’t tell you how proud I am of these kids,” Warren Hills coach Laurie Kerr said. “They never quit. We kept playing hard and took advantage of some opportunities. These kids have done this all season long.”

Grater’s goal set the stage for Wold, who had a simple message for her team.

“I kind of said ‘This isn’t where want to be’,” Wold said. “We needed to get our aggressiveness back on offense. This was a good win for us, but we can’t let down. We want to win that Group 3 championship again.”

“Emily and I have been best friends since pre-school,” Martino said. “She’s that kind of player. I thought we bounced back really well after losing the Shore Conference final (1-0 to Shore Regional on Oct. 30) and Emily has been our leader. Last year, we lost to Shore in the conference final and came back to win the Group 3 championship. We’re hoping to do that again.”