text:
Q: Get the current location after an interval using RX I'm using reactive extensions in my wp7 app that I'm making and I wish to get the the current location at certain intervals (intervals are based on a user setting). For this example lets say after every 5 seconds I wish to know the current location from the GeoCoordinateWatcher.
I have read some places that I can use .Delay(5 Seconds) but wouldn't that just delay the stream of position changes? As I am only after the current position, would .Delay(5 seconds).Last() work for what I want?
My code so far
if (LocationServices == null)
     LocationServices = new GeoCoordinateWatcher(GeoPositionAccuracy.High)
     {
        MovementThreshold = 2
     };

// Take the first ready status from the GeoCoordinateWatcher
var status = (from o in Observable.FromEvent<GeoPositionStatusChangedEventArgs>                  LocationServices, "StatusChanged")
              where o.EventArgs.Status == GeoPositionStatus.Ready
              select o);

status.Subscribe();

var pos = (from s in status
           from p in Observable.FromEvent<GeoPositionChangedEventArgs<GeoCoordinate>>(LocationServices, "PositionChanged")
           select p.EventArgs.Position); // Do something here to delay?

        pos.Subscribe(LastPos =>
        {
            // Do something with LastPos
        }
        );

        LocationServices.Start();

I'm thinking something like this would work?
var pos = (from s in status
           from p in Observable.FromEvent<GeoPositionChangedEventArgs<GeoCoordinate>>(LocationServices, "PositionChanged")
           select p.EventArgs.Position).Delay( var pos = (from s in status
                   from p in Observable.FromEvent<GeoPositionChangedEventArgs<GeoCoordinate>>(LocationServices, "PositionChanged")
                   select p.EventArgs.Position).TakeLast(1).Delay(new TimeSpan(0,0,5));

        pos.Subscribe(Lastpos =>
        {
           // Do something with Lastpos
        }
        );;

Edit: Nope it doesn't work

A: There are a few different rate limiting operators in RX.  Sample is the closest to what you describe, but it will not generate a notification every 5 seconds if the source is not producing new notifications (in other words: Sample = "no more often than").
You should be able to get a polling effect by combining a few other operators.  To start, we will need Interval to get the ticks and CombineLatest to do the sampling at the ticks.  However, CombineLatest will output a result both on ticks and notifications from the original source.  To deal with that, we can use a combination of Scan, Where and Select.  In the end you should have something like:
IObservable<T> Poll<T>(this IObservable<T> source, TimeSpan interval)
{
    //error checking goes here
    return source.CombineLatest(Observable.Interval(interval),
                                Tuple.Create)
                 .Scan(Tuple.Create(string.Empty, -1L, -1L),
                       (a, t) => Tuple.Create(t.Item1, t.Item2, a.Item2))
                 .Where(t => t.Item2 != t.Item3)
                 .Select(t => t.Item1);
}

A few notes about the code you posted:
var pos = (from s in status
           from p in Observable.FromEvent<GeoPositionChangedEventArgs<GeoCoordinate>>(LocationServices, "PositionChanged")
           select p.EventArgs.Position);

This makes a new subscription to the PositionChanged event every time the status event is triggered as ready.  This will eventually cause position changes to be reported multiple times, which is probably not what you want.  You probably want something more like:
var status = Observable.FromEvent<...>(LocationServices, "StatusChanged");
var readys = status.Where(o => o.EventArgs.Status == GeoPositionStatus.Ready);
var notReadys = status.Where(o => o.EventArgs.Status != GeoPositionStatus.Ready);
var positions = Observable.FromEvent<...>)(LocationServices, "PositionChanged");

var readyPositions = from r in readys
                     from p in positions.TakeUntil(notReadys)
                     select p;
//now you can use the Poll operator
readyPositions = readyPositions.Poll(TimeSpan.FromSeconds(5));

EDIT Upon further review, if all you want to do is poll the position every so often, there is no need to handle either event.  You can simply check the properties on a timer.
var readyPositions = from tick in Observable.Interval(TimeSpan.FromSeconds(5))
                     where LocationServices.Status == GeoPositionStatus.Ready
                     select LocationServices.Position;

If you only want the timer to run while the watcher is "Ready", you can use the status event, but still don't need to use the position event.
//using variable definitions from above (readys, notReadys)
var readyPositions = from r in readys
                     from i in Observable.Interval(TimeSpan.FromSeconds(5))
                                         .TakeUnitl(notReadys)
                     select LocationServices.Position;


text:
Q: Multiple defintion error in SDL program I have a problem with multiple definitions with the variable's beeld, knop, clips, foto, text, font, fontkleur, muziek, event.
The problems are mostly in these files:
globals.h
#ifndef globals_H
#define globals_H

#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_ttf.h"
#include "SDL/SDL_mixer.h"

SDL_Surface *beeld = NULL;
SDL_Surface *knop = NULL;
SDL_Rect clips[ 4 ];
SDL_Surface *foto = NULL;
SDL_Surface *text = NULL;
TTF_Font *font = NULL;
SDL_Color fontkleur = { 100, 0, 10 };
Mix_Music *muziek = NULL;
SDL_Event event;

#endif

main.cpp
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_ttf.h"
#include "SDL/SDL_mixer.h"

#include "variabelen.h"
#include "class.h"
#include "functies.h"
#include "globals.h"

#include <string>

int main( int argc, char* args[] )
{
    bool stop = false;
    if( init(beeld_L,beeld_H,beeld_BPP) == false )
    {
        return 1;
    }

    foto = zichtbaar_scherm( "rescource/achtergrond.png" );
    knop = zichtbaar_scherm( "rescource/knop.png" );
    font = TTF_OpenFont( "rescource/lazy.ttf", 80 );
    muziek = Mix_LoadMUS( "rescource/muziek.wma" );

    laad_prenten(foto);
    laad_prenten(knop);
    laad_text(font);
    laad_muziek(muziek);

    if( laad_prenten(foto) == false || laad_prenten(knop) == false || laad_text(font) == false || laad_muziek(muziek) == false )
    {
        return 1;
    }

    set_clips();

    Knop drukknop( 170, 180, 320, 120 );

    plus_laag( 0, 0, foto, beeld );

    text = TTF_RenderText_Solid( font, "START !", fontkleur );
    plus_laag( ( 320 - text->w ) / 2, 30, text, knop );
    Mix_PlayMusic( muziek, -1 );

    while( stop == false )
    {
        if( SDL_PollEvent( &event ) )
        {

            if( event.type == SDL_QUIT )
            {
                stop = true;
            }
            if( drukknop.events() == true )
            {
                stop = true;
            }
        }
        drukknop.toon();

        if( SDL_Flip( beeld ) == -1 )
        {
            return 1;
        }
    }

    afsluiten();

    return 0;
}

the programme makes a small menu :D

A: Defining variables as you do in the .h file has a serious problem. Such a definition reserves space for that variable so that if you include such a .h file in two different C++ files you get separate instances in EACH c++ module which gives you a conflict when it comes to linking.
Normally in the .h files variables are declared (but not defined) extern like so
extern int X;

This makes the symbol valid but does NOT reserve memory so if you include the extern keyword then the problem with multiple definitions goes away.
However  you do need ONE real full definition in ONE module (perhaps your main.cpp file)
int X=0;

redpajama_set_name: RedPajamaStackExchange


text:
Q: How do I generate an array of Streams with type as enums in java with a default value I have an enum as below
enum color
{
  red, blue, green;
}

I have to generate an array of colors with default color as blue
in old java(<8), I do this.

color[] myArray = new color[mySize];

for(int iter=0; iter<myArray.length; iter++)
  myArray[iter] = color.blue;

How do I use java Array Generator Stream code to do this?

A: Your iterative version sounds good and I'll advise you to keep it. However, since you are curious on equivalent streams version, here it is.
color[] myArray = IntStream.range(0, size)
    .mapToObj(unused -> color.blue)
    .toArray(color[]::new);

You have to use an IntStream, creating a default color.blue in each iteration. Finally, use the toArray to create an array of enums.


text:
Q: Voltameter in TeX? Hello I wanted to draw a Hofmann voltameter in TikZ like in this image:

Unfortunately, there are a lot of curves and shapes that are tedious to draw. Is there an easy way to draw it or do I have to settle for something like this
\begin{tikzpicture}[xscale=0.7]
\filldraw[black!50!white] (0,0)  to[line to] (0,4.5) to[line to] (2,4.5) to[line to] (2,2) to[line to] (4,2) to[line to] (4,5) to[line to] (6,5) to[line to] (6,2) to[line to] (8,2) to[line to] (8,3) to[line to] (10,3) to[line to] (10,0) to[line to] (8,0) to[line to] (8,1) to[line to] (2,1) to[line to] (2,0) to[line to] (0,0);
\node (Anode) at (-0.8,0.3) {Anode};
\node (Cathode) at (11,0.3) {Cathode};
\draw[line width=1pt] (1,0) to[line to] (1,-0.5)  to[line to] (4.7,-0.5);
\draw[line width=1pt] (5.3,-0.5) to[line to] (9,-0.5) to[line to] (9,0);
\draw[line width=1pt] (4.7,-1)  to[line to] (4.7,0);
\draw[line width=1pt] (5.3,-0.7) to[line to] (5.3,-0.3);
\fill[black!20!white] (0,0)  to[line to] (0,4.5) to[line to] (2,4.5) to[line to] (2,2) to[line to] (4,2) to[line to] (4,5) to[line to] (6,5) to[line to] (6,2) to[line to] (8,2) to[line to] (8,3) to[line to] (10,3) to[line to] (10,0) to[line to] (8,0) to[line to] (8,1) to[line to] (2,1) to[line to] (2,0) to[line to] (0,0);
\fill[black!100!white] (0.875,0) rectangle (1.125,0.7);
\fill[black!100!white] (8.875,0) rectangle (9.125,0.7);
\draw[line width=1pt] (0,0) to[line to] (0,6) to[line to] (2,6) to[line to] (2,2) to[line to] (4,2) to[line to] (4,7) to[line to] (6,7) to[line to] (6,2) to[line to] (8,2) to[line to] (8,6) to[line to] (10,6) to[line to] (10,0) to[line to] (8,0) to[line to] (8,1) to[line to] (2,1) to[line to] (2,0) to[line to] (0,0);
\end{tikzpicture}

Which yields this:

A: Final tikz image, big shoutout to Max Snippe (uses tikz package and mhchem package)
\begin{tikzpicture}[
thick,
>=latex,
line join=round,
ode/.style={
    minimum width=2mm,
    minimum height=7mm,
    draw,
    fill=white,
    postaction={
        pattern = crosshatch dots
    }
},
cork/.style={
    minimum width=4mm-2\pgflinewidth,
    minimum height=6mm,
    draw,
    fill=white,
    postaction={
        pattern = north east lines
    }
},
battery/.style={
    minimum width=6mm+2pt,
    minimum height=8mm,
    outer sep=0pt,
    node contents={},
    path picture={
        \draw[line width=1pt] (-3mm-0.5pt,-4mm) -- ++(0,8mm);
        \draw[line width=3pt] (-1mm-0.5pt,-2mm) -- ++(0,4mm);
        \draw[line width=1pt] (1mm-0.5pt,-4mm) -- ++(0,8mm);
        \draw[line width=3pt] (3mm-0.5pt,-2mm) -- ++(0,4mm);
    },
},
amperemeter/.style={
    draw,
    circle,
    minimum size=10mm,
    node contents={\( A \)},
    },
]
    \fill[white!80!black] (0,-0.2)
        -- ++(-1,0)
        -- ++(0,-0.4) -- ++ (-0.4,0) -- ++(0,4.65)
        arc (180:270:0.1) -- ++(0.2,0) arc (270:360:0.1)
        -- ++(0,-3.85) -- ++(0.8,0) -- ++(0,7.7)
        .. controls +(0,0.4) and +(0,-0.9) .. ++(-0.8,1.25)
        arc (180:270:0.1)
        let \p1 = ++(0,0) in --(-\x1,\y1)
        arc (270:360:0.1)
        .. controls +(0,-0.9) and +(0,0.4) .. ++(-0.8,-1.25)
        -- ++(0,-7.7) -- ++(0.8,0)  -- ++(0,1)
        arc (180:270:0.1) -- ++(0.2,0) arc (270:360:0.1)
        -- ++(0,-1.8) -- ++(-0.4,0) -- ++(0,0.4)
        -- cycle;
\draw (0,-0.2)
    -- ++(-1,0) -- ++(0,-0.8) -- ++(0.1,-0.1)
    ++ (-0.6,0) -- ++(0.1,0.1) -- ++(0,7.25)
    .. controls +(0,0.2) and +(0,-0.1) .. ++(0.16,0.3)
    .. controls +(0,0.45) and +(0,-0.22) .. ++(0.02,1.25)
    ++(0.04,0)
    .. controls +(0,-0.22) and +(0,0.45) .. ++(0.02,-1.25)
    .. controls +(0,-0.1) and +(0,0.2) .. ++(0.16,-0.3)
    -- ++(0,-6.05) -- ++(0.8,0) -- ++(0,7.7)
    .. controls +(0,0.4) and +(0,-0.9) .. ++(-0.8,1.25)
    .. controls +(0,0.4) and +(0,-0.3) .. ++(0.8,0.65)
    .. controls +(0,0.1) and +(0,0) .. ++(-0.1,0.1)
    let \p1 = ++(0,0) in (-\x1,\y1)
    .. controls +(0,0) and +(0,0.1) .. ++(-0.1,-0.1)
    .. controls +(0,-0.3) and +(0,0.4) .. ++(0.8,-0.65)
    .. controls +(0,-0.9) and +(0,0.4) .. ++(-0.8,-1.25)
    -- ++(0,-7.7) -- ++(0.8,0) -- ++(0,6.05)
    .. controls +(0,0.2) and +(0,-0.1) .. ++(0.16,0.3)
    .. controls +(0,0.45) and +(0,-0.22) .. ++(0.02,1.25)
    ++(0.04,0)
    .. controls +(0,-0.22) and +(0,0.45) .. ++(0.02,-1.25)
    .. controls +(0,-0.1) and +(0,0.2) .. ++(0.16,-0.3)
    -- ++(0,-7.25) -- ++(0.1,-0.1) ++ (-0.6,0)
    -- ++(0.1,0.1) -- ++(0,0.8) -- ++(-1,0);

\node[ode,pin={[align=center,pin edge={thick}]left:Anode\\\( + \)}] at (-1.2,0) (anode) {};
\node[ode,pin={[align=center,pin edge={thick}]right:Cathode\\\( - \)}] at (1.2,0) (cathode) {};

\coordinate[pin={[pin edge={thick}]left:Oxygen}] (ox) at (-1.2,4.7);
\coordinate[pin={[pin edge={thick}]right:Hydrogen}] (hy) at (1.2,5.1);
\coordinate[pin={[pin distance=2.5cm,align=center,pin edge={thick}]right:Acidulated\\water}] (aw) at (0.2,8.6);

\node[cork] at (-1.2,-0.9) {};
\node[cork] at (1.2,-0.9) {};

\begin{scope}[shift={(1.2,6.8)},fill=white]
    \filldraw (0.45,-0.05) rectangle (0,0.05);
    \filldraw[fill=white,rounded corners=1pt] (-0.3,-0.15) rectangle ++(0.6,0.3);
    \filldraw[fill=white] (0.45,0) circle (0.075 and 0.2);
    \filldraw[fill=white] (0,0) circle (0.075);
\end{scope}
\begin{scope}[xscale=-1,shift={(1.2,6.8)},fill=white]
    \filldraw (0.45,-0.05) rectangle (0,0.05);
    \filldraw[fill=white,rounded corners=1pt] (-0.3,-0.15) rectangle ++(0.6,0.3);
    \filldraw[fill=white] (0.45,0) circle (0.075 and 0.2);
    \filldraw[fill=white] (0,0) circle (0.075);
\end{scope}

\node (bat) at (-0.5,-3) [battery];
\node (amp) at (1,-3) [amperemeter];
\node (res) at (3,-3) [draw,minimum width=15mm,minimum height=2.5mm]{};
\draw (anode) |- (bat);
\draw (bat) -- (amp);
\draw (amp) -- (res);
\draw[->] (cathode) -- (cathode|-0,-1.5) -| (res.40);

\node (oxlabel) at (-5,4) {Reaction at Anode};
\node (oxygenreacc) at (-5,3.5) {$\ce{3H2O -> \frac{1}{2}O2 +2H3O+ +2e-}$};
\node (hydlable) at (5,4) {Reaction at Cathode};
\node (hydrogenreacc) at (5,3.5) {$\ce{2H3O+ +2e- ->H2 +2H2O}$};
\node (overallreacclabel) at (-5,-1) {Overall Reaction};
\node (overallreacc) at (-5,-1.5) {$\ce{H2O ->\frac{1}{2}O2 + H2}$};
\end{tikzpicture}

A: To answer your question: No, there is not an easy way to draw this, other than to try some vectorisation on the .png (e.g. with Autotracer.org). Fortunately, some of us don't have anything better to do :)
Edit
Fixed the left and right tubes, noticed that they are supposed to be open at the top.
Edit 2
I wanted to draw the pattern of the acidulated water too, so now the image is complete :) . Of course you can choose for yourself which one you like better, I just wanted to give you that choice.

New code:
\documentclass[tikz,margin=2mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,shapes,patterns,calc}

\makeatletter
\tikzset{
    horizontal dashes length/.store in=\@hordash@length,
    horizontal dashes distance/.store in=\@hordash@dist,
    horizontal dashes line width/.store in=\@hordash@lw,
    horizontal dashes length=5pt,
    horizontal dashes distance=2pt,
    horizontal dashes line width=0.2pt,
}

\pgfdeclarepatternformonly[\@hordash@length,\@hordash@dist,\@hordash@lw]{horizontal dashes}
{\pgfpointorigin}
{\pgfpoint{\@hordash@length+\@hordash@dist}{2*\@hordash@dist}}
{\pgfpoint{\@hordash@length+\@hordash@dist}{2*\@hordash@dist}}
{
    \pgfpathmoveto{\pgfpoint{0.5*\@hordash@dist}{1.5*\@hordash@dist}}
    \pgfpathlineto{\pgfpoint{0.5*\@hordash@dist+\@hordash@length}{1.5*\@hordash@dist}}
    \pgfpathmoveto{\pgfpoint{0mm}{0.5*\@hordash@dist}}
    \pgfpathlineto{\pgfpoint{0.5*\@hordash@length}{0.5*\@hordash@dist}}
    \pgfpathmoveto{\pgfpoint{\@hordash@dist+0.5*\@hordash@length}{0.5*\@hordash@dist}}
    \pgfpathlineto{\pgfpoint{\@hordash@dist+\@hordash@length}{0.5*\@hordash@dist}}
    \pgfsetlinewidth{\@hordash@lw}
    \pgfusepath{stroke}
}
\makeatother

\begin{document}
    \begin{tikzpicture}[
        thick,
        >=latex,
        line join=round,
        ode/.style={
            minimum width=2mm,
            minimum height=7mm,
            draw,
            fill=white,
            postaction={
                pattern = crosshatch dots
            }
        },
        cork/.style={
            minimum width=4mm-2\pgflinewidth,
            minimum height=6mm,
            draw,
            fill=white,
            postaction={
                pattern = north east lines
            }
        },
        battery/.style={
            minimum width=6mm+2pt,
            minimum height=8mm,
            outer sep=0pt,
            node contents={},
            path picture={
                \draw[line width=1pt] (-3mm-0.5pt,-4mm) -- ++(0,8mm);
                \draw[line width=3pt] (-1mm-0.5pt,-2mm) -- ++(0,4mm);
                \draw[line width=1pt] (1mm-0.5pt,-4mm) -- ++(0,8mm);
                \draw[line width=3pt] (3mm-0.5pt,-2mm) -- ++(0,4mm);
            },
        },
        amperemeter/.style={
            draw,
            circle,
            minimum size=10mm,
            node contents={\( A \)},
        },
    ]

        \filldraw[pattern=horizontal dashes,line width=0.4pt] (0,-0.2)
            -- ++(-1,0)
            -- ++(0,-0.4) -- ++ (-0.4,0) -- ++(0,4.65)
            arc (180:270:0.1) -- ++(0.2,0) arc (270:360:0.1)
            -- ++(0,-3.85) -- ++(0.8,0) -- ++(0,7.7)
            .. controls +(0,0.4) and +(0,-0.9) .. ++(-0.8,1.25)
            arc (180:270:0.1)
            let \p1 = ++(0,0) in --(-\x1,\y1)
            arc (270:360:0.1)
            .. controls +(0,-0.9) and +(0,0.4) .. ++(-0.8,-1.25)
            -- ++(0,-7.7) -- ++(0.8,0)  -- ++(0,1)
            arc (180:270:0.1) -- ++(0.2,0) arc (270:360:0.1)
            -- ++(0,-1.8) -- ++(-0.4,0) -- ++(0,0.4)
            -- cycle;
        \draw (0,-0.2)
            -- ++(-1,0) -- ++(0,-0.8) -- ++(0.1,-0.1)
            ++ (-0.6,0) -- ++(0.1,0.1) -- ++(0,7.25)
            .. controls +(0,0.2) and +(0,-0.1) .. ++(0.16,0.3)
            .. controls +(0,0.45) and +(0,-0.22) .. ++(0.02,1.25)
            ++(0.04,0)
            .. controls +(0,-0.22) and +(0,0.45) .. ++(0.02,-1.25)
            .. controls +(0,-0.1) and +(0,0.2) .. ++(0.16,-0.3)
            -- ++(0,-6.05) -- ++(0.8,0) -- ++(0,7.7)
            .. controls +(0,0.4) and +(0,-0.9) .. ++(-0.8,1.25)
            .. controls +(0,0.4) and +(0,-0.3) .. ++(0.8,0.65)
            .. controls +(0,0.1) and +(0,0) .. ++(-0.1,0.1)
            let \p1 = ++(0,0) in (-\x1,\y1)
            .. controls +(0,0) and +(0,0.1) .. ++(-0.1,-0.1)
            .. controls +(0,-0.3) and +(0,0.4) .. ++(0.8,-0.65)
            .. controls +(0,-0.9) and +(0,0.4) .. ++(-0.8,-1.25)
            -- ++(0,-7.7) -- ++(0.8,0) -- ++(0,6.05)
            .. controls +(0,0.2) and +(0,-0.1) .. ++(0.16,0.3)
            .. controls +(0,0.45) and +(0,-0.22) .. ++(0.02,1.25)
            ++(0.04,0)
            .. controls +(0,-0.22) and +(0,0.45) .. ++(0.02,-1.25)
            .. controls +(0,-0.1) and +(0,0.2) .. ++(0.16,-0.3)
            -- ++(0,-7.25) -- ++(0.1,-0.1) ++ (-0.6,0)
            -- ++(0.1,0.1) -- ++(0,0.8) -- ++(-1,0);

        \node[ode,pin={[align=center]left:Anode\\\( + \)}] at (-1.2,0) (anode) {};
        \node[ode,pin={[align=center]right:Cathode\\\( - \)}] at (1.2,0) (cathode) {};

        \coordinate[pin={left:Oxygen}] (ox) at (-1.2,4.7);
        \coordinate[pin={right:Hydrogen}] (hy) at (1.2,5.1);
        \coordinate[pin={[pin distance=2.5cm,align=center]right:Acidulated\\water}] (aw) at (0.2,8.6);

        \node[cork] at (-1.2,-0.9) {};
        \node[cork] at (1.2,-0.9) {};

        \begin{scope}[shift={(1.2,6.8)},fill=white]
            \filldraw (0.45,-0.05) rectangle (0,0.05);
            \filldraw[fill=white,rounded corners=1pt] (-0.3,-0.15) rectangle ++(0.6,0.3);
            \filldraw[fill=white] (0.45,0) circle (0.075 and 0.2);
            \filldraw[fill=white] (0,0) circle (0.075);
        \end{scope}
        \begin{scope}[xscale=-1,shift={(1.2,6.8)},fill=white]
            \filldraw (0.45,-0.05) rectangle (0,0.05);
            \filldraw[fill=white,rounded corners=1pt] (-0.3,-0.15) rectangle ++(0.6,0.3);
            \filldraw[fill=white] (0.45,0) circle (0.075 and 0.2);
            \filldraw[fill=white] (0,0) circle (0.075);
        \end{scope}

        \node (bat) at (-0.5,-3) [battery];
        \node (amp) at (1,-3) [amperemeter];
        \node (res) at (3,-3) [draw,minimum width=15mm,minimum height=2.5mm]{};

        \draw (anode) |- (bat);
        \draw (bat) -- (amp);
        \draw (amp) -- (res);
        \draw[->] (cathode) -- (cathode|-0,-1.5) -| (res.40);
    \end{tikzpicture}
\end{document}

Old code:
\documentclass[tikz,margin=2mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,shapes,patterns,calc}

\begin{document}
    \begin{tikzpicture}[
        thick,
        >=latex,
        line join=round,
        ode/.style={
            minimum width=2mm,
            minimum height=7mm,
            draw,
            fill=white,
            postaction={
                pattern = crosshatch dots
            }
        },
        cork/.style={
            minimum width=4mm-2\pgflinewidth,
            minimum height=6mm,
            draw,
            fill=white,
            postaction={
                pattern = north east lines
            }
        },
        battery/.style={
            minimum width=6mm+2pt,
            minimum height=8mm,
            outer sep=0pt,
            node contents={},
            path picture={
                \draw[line width=1pt] (-3mm-0.5pt,-4mm) -- ++(0,8mm);
                \draw[line width=3pt] (-1mm-0.5pt,-2mm) -- ++(0,4mm);
                \draw[line width=1pt] (1mm-0.5pt,-4mm) -- ++(0,8mm);
                \draw[line width=3pt] (3mm-0.5pt,-2mm) -- ++(0,4mm);
            },
        },
        amperemeter/.style={
            draw,
            circle,
            minimum size=10mm,
            node contents={\( A \)},
        },
    ]

        \fill[white!80!black] (0,-0.2)
            -- ++(-1,0)
            -- ++(0,-0.4) -- ++ (-0.4,0) -- ++(0,4.65)
            arc (180:270:0.1) -- ++(0.2,0) arc (270:360:0.1)
            -- ++(0,-3.85) -- ++(0.8,0) -- ++(0,7.7)
            .. controls +(0,0.4) and +(0,-0.9) .. ++(-0.8,1.25)
            arc (180:270:0.1)
            let \p1 = ++(0,0) in --(-\x1,\y1)
            arc (270:360:0.1)
            .. controls +(0,-0.9) and +(0,0.4) .. ++(-0.8,-1.25)
            -- ++(0,-7.7) -- ++(0.8,0)  -- ++(0,1)
            arc (180:270:0.1) -- ++(0.2,0) arc (270:360:0.1)
            -- ++(0,-1.8) -- ++(-0.4,0) -- ++(0,0.4)
            -- cycle;
        \draw (0,-0.2)
            -- ++(-1,0) -- ++(0,-0.8) -- ++(0.1,-0.1)
            ++ (-0.6,0) -- ++(0.1,0.1) -- ++(0,7.25)
            .. controls +(0,0.2) and +(0,-0.1) .. ++(0.16,0.3)
            .. controls +(0,0.45) and +(0,-0.22) .. ++(0.02,1.25)
            ++(0.04,0)
            .. controls +(0,-0.22) and +(0,0.45) .. ++(0.02,-1.25)
            .. controls +(0,-0.1) and +(0,0.2) .. ++(0.16,-0.3)
            -- ++(0,-6.05) -- ++(0.8,0) -- ++(0,7.7)
            .. controls +(0,0.4) and +(0,-0.9) .. ++(-0.8,1.25)
            .. controls +(0,0.4) and +(0,-0.3) .. ++(0.8,0.65)
            .. controls +(0,0.1) and +(0,0) .. ++(-0.1,0.1)
            let \p1 = ++(0,0) in (-\x1,\y1)
            .. controls +(0,0) and +(0,0.1) .. ++(-0.1,-0.1)
            .. controls +(0,-0.3) and +(0,0.4) .. ++(0.8,-0.65)
            .. controls +(0,-0.9) and +(0,0.4) .. ++(-0.8,-1.25)
            -- ++(0,-7.7) -- ++(0.8,0) -- ++(0,6.05)
            .. controls +(0,0.2) and +(0,-0.1) .. ++(0.16,0.3)
            .. controls +(0,0.45) and +(0,-0.22) .. ++(0.02,1.25)
            ++(0.04,0)
            .. controls +(0,-0.22) and +(0,0.45) .. ++(0.02,-1.25)
            .. controls +(0,-0.1) and +(0,0.2) .. ++(0.16,-0.3)
            -- ++(0,-7.25) -- ++(0.1,-0.1) ++ (-0.6,0)
            -- ++(0.1,0.1) -- ++(0,0.8) -- ++(-1,0);

        \node[ode,pin={[align=center]left:Anode\\\( + \)}] at (-1.2,0) (anode) {};
        \node[ode,pin={[align=center]right:Cathode\\\( - \)}] at (1.2,0) (cathode) {};

        \coordinate[pin={left:Oxygen}] (ox) at (-1.2,4.7);
        \coordinate[pin={right:Hydrogen}] (hy) at (1.2,5.1);
        \coordinate[pin={[pin distance=2.5cm,align=center]right:Acidulated\\water}] (aw) at (0.2,8.6);

        \node[cork] at (-1.2,-0.9) {};
        \node[cork] at (1.2,-0.9) {};

        \begin{scope}[shift={(1.2,6.8)},fill=white]
            \filldraw (0.45,-0.05) rectangle (0,0.05);
            \filldraw[fill=white,rounded corners=1pt] (-0.3,-0.15) rectangle ++(0.6,0.3);
            \filldraw[fill=white] (0.45,0) circle (0.075 and 0.2);
            \filldraw[fill=white] (0,0) circle (0.075);
        \end{scope}
        \begin{scope}[xscale=-1,shift={(1.2,6.8)},fill=white]
            \filldraw (0.45,-0.05) rectangle (0,0.05);
            \filldraw[fill=white,rounded corners=1pt] (-0.3,-0.15) rectangle ++(0.6,0.3);
            \filldraw[fill=white] (0.45,0) circle (0.075 and 0.2);
            \filldraw[fill=white] (0,0) circle (0.075);
        \end{scope}

        \node (bat) at (-0.5,-3) [battery];
        \node (amp) at (1,-3) [amperemeter];
        \node (res) at (3,-3) [draw,minimum width=15mm,minimum height=2.5mm]{};

        \draw (anode) |- (bat);
        \draw (bat) -- (amp);
        \draw (amp) -- (res);
        \draw[->] (cathode) -- (cathode|-0,-1.5) -| (res.40);
    \end{tikzpicture}
\end{document}


text:
Q: vs2010 debugger exception view My vs2010 shows this message when an exception is thrown:

How can I configure the debugger to show exceptions like this instead:

Thanks!

A: Big difference between the two.  You'll only see the first one when you explicitly configure the debugger to stop when an exception is thrown.  You do so with Debug + Exceptions, Thrown checkbox.  You don't often use this, really only when your code contains too many catch statements that swallow exceptions inappropriately and making the code misbehave.  It also has a knack for showing exceptions in code you didn't write.  Click the Break button to allow the debugger to show you the details.
You'll only get the second screenshot when an exception is thrown and there is no catch block to catch it, making it an unhandled exception.  That's a fatal error, the program cannot continue.  The debugger stops to show you the problem, it is otherwise the end of the debugging session.  Without a debugger your program will crash.  This is the 'good' kind, you get it by omitting try/catch blocks so your program terminates when something unexpected happens.  You will want to write an event handler for the AppDomain.CurrentDomain.UnhandledException event so the user at least has an idea what went wrong.  And you for that matter.


text:
Q: Minimum recommended LED drive current I've stumbled upon a LED's datasheet that includes a strange recommendation. They want me to drive the LED at >5mA for reasons of "long term performance." I've never seen a similar thing anywhere else, what's the rationale behind it?

A: The properties of aging on transparent substrate LEDs have been documented in research by many but are not handy to me the time of this writing. I have known this for about 10 yrs so Google or Microsoft Scholar ought to have some papers on this. I got mine from EOS by NDA.
Generally 10% of rated max current is needed to prevent some corrosion of the crystal electrode interface. But then with 50kh given as expected min MTBF this has been greatly improved by many brand name suppliers  by quality controls to millions of hours if you want to use PWM dimming to 1% some of the time, that would be OK if 100% of the time was also experienced.
Heat generally has a positive aging effect initially only either by soldering or operating at rate temp for several hours or days.  This can burn off leakage R and sometimes crystalline-metallic shorts. (dendrites)


text:
Q: Need to understand Regex advanced substring, replace and split to make work with PowerShell In forums, have seen the signature as:
[string](0..9 | %{[char][int](32+("......................."
    ).substring(($_*2), 2))}) -replace "\s{1}\b"

it gives the result as an email address.
Need to understand the substring and replace syntax here and to be precise the complete syntax how it is being evaluated.
I understand that [string] is a data type, then foreach every digit from 1 to 9 following result can be in integer or character and finding the ASCII value followed by finding the substring which is multiplied by 2 (don't understand why) and taking only 2 digits of result (result will be be of 2 digits then why to), then comes the replace which replaces with white space and the end \b signifies the word end boundary.
Also, as mentioned in http://ss64.com/ps/syntax-regex.html, how
PS> 'ABCD' -replace "([AC])(.)",'$2-$1'
B-AD-C

results in B-AD-C.
What's the period significance here? cant find the meaning which tells me how to use it, I have tried removing it and it results in
PS> 'ABCD' -replace "([AC])",'$2-$1'
$2-AB$2-CD

Why the period is significant with capture groups in regex?
I am in this for almost a week now but not able to find the exact meaning.
Any help would be appreciated on this.
Regards
Merry X'Mas

A: I think you are supposed to replace the dots with digits.
For each digit n from 0 to 9, pick the n'th pair of digits in the string, add 32, and convert to that Unicode character. Then remove every space that comes before a word character.
32 is the code for a space (" "), and is followed by 94 printable characters. See List of Unicode characters, Basic Latin (Wikipedia) for a list.
[string], [char], and [int] converts a value to the specified type. The % { } syntax is short for ForEach-Object { }.
The regex at the end, matches one space character, followed by a word-boundary. —That is, it matches zero characters but only before a word-character (A-Z, a-z, 0-9 and "_")).
The full syntax is: string -replace regex , replacement. Since there are no replacement specified, it defaults to the empty string. Effectively removes any space before a letter or digit.

For the regex ([AC])(.), it will match any A or C followed by another character. It will capture the A or C into group one, and the following character into group 2.
Simple ( ) creates a capture group, and allows you to refer to the matched substring elsewhere. . is a wildcard, and matches any character except newline (U+00A0).
ABCD -> {
  Match 1 = {
    Text = "AB"
    Capture 1 = { Text = "A" }
    Capture 2 = { Text = "B" }
  }
  Match 2 = {
    Text = "CD"
    Capture 1 = { Text = "C" }
    Capture 2 = { Text = "D" }
  }
}

The replacement string $2-$1 says to put the text captured into group 2 first, followed by a dash, followed by the text captured into group 1.
$1 refers to the text captured into group 1, and $2 refers to the text captured into group 2. Match 1 will be replaced by "B-A", and Match 2 by "D-C", resulting in "B-AD-C".
A good source for the syntax and mechanics of regex is http://www.regular-expressions.info/


text:
Q: Rendering a shapefile with a custom projection in GeoTools I have an image, a shapefile, and a method which can translate an x/y pixel location from the image into a latitude/longitude point or vice versa. I'm trying to use Geotools to render the shapefile on the image, but I can't seem to get it to work.
All of the examples and tutorials I can find use factories to retrieve pre-existing transforms and mappings, but how can I use my custom projection?
Edit: The image is the view from a satellite, which means that it cannot see the entire earth. Is Geotools capable of handling this?
Edit2: I don't think that this can be done easily in GeoTools, I ended up just writing what I needed from scratch.

A: I don't understand completely your question, probably due to my limit knowledge about projections, but you can read and transform the features of a shapefile easily:
http://docs.geotools.org/stable/userguide/tutorial/geometry/geometrycrs.html#export-reprojected-shapefile
=== UPDATED ===
Here you can find a simple creating a CRS from a WKT expression:
docs.geotools.org/latest/userguide/library/referencing/crs.html and docs.geotools.org/latest/userguide/library/main/geometry.html.
That can help you.

A: If it's a non-affine transformation, then you're going to have trouble with line segments staying straight when they should be curved in the image's space. This is a general problem with transforming vectors, and with sufficiently small line segments, isn't usually too much of a problem.
If you don't know ahead of time what the projection parameters are for the image, or if they cannot be represented by standard map-projection parameters - if the image hasn't been rectified for instance - then you really have one course open to you: manual rasterization. If you're on 3D-accelerated hardware, it would be a fairly simple fragment shader to map from one space to another, given that you have the function already. However, if you're working on a headless server or similar, you'll need to roll your own polygon rasterizer, transforming points from one space to the other as you go. This isn't too difficult, and much has been written on it in the past, but it is mostly just time-consuming to write.
A simple, if not very efficient, method would be to scan over each pixel in the satellite image, transform the coordinate into your polygons' space, and do a simple inside/outside test of that point on your polygons. If it's inside, then colour your pixel appropriately. Lines are a bit harder with this method, but you essentially have to measre the cross-track error of your point against the line, and colour it if it is within some distance, but this won't be very pretty. You could use an alpha value based on the CTE, which would smooth the lines out somewhat, but it's hardly the cutting edge of anti-aliasing.

A: Although this not exactly for Geotools, this should work.(actually this is for GeoServer). This explains how to define a custom projection, edit the EPSG.sql file, which is used to create the cached EPSG database.:
Manually editing the CRS database
Another option is creating your own PROJ4 expression for your custom projection. You can use http://spatialreference.org/ for this.


text:
Q: how show activityindicator in swift? in my app i have a  login with a usernamaeTextfield, passwordtextfield and login button. When the login button is tapped i check the fields. I need show a activityindicator in this time, but my var activityindicator is always hidden.
This is my code.
@IBOutlet weak var activity: UIActivityIndicatorView!
override func viewDidLoad() {
    self.activity.hidden = true
    super.viewDidLoad()}

@IBAction func login(sender: AnyObject) {
    activity.hidden = false
    activity.startAnimating()
    if (self.username.isEmpty || self.password.isEmpty){
            self.showAlert("Asegurese de ingresar un usuario y contraseña!")
        }else{
            var user = user_function()
            if !user.user_valid(self.username,password: self.password){
                self.showAlert("Usuario Invalido")
            }else{

            }
        }

    activity.hidden = true
    activity.stopAnimating()
 }

my code of user_valid is
func user_valid(username :String, password : String)->Bool{
    var resultados : Array<JSON> = []
    userbase64 = self.encode_to_base64(username)
    passbase64 = self.encode_to_base64(password)

    var api = channels_function()

     resultados =  api.load_videos("https://api.cxntv.com/api/v1/videos/?type=canales&page_size=100&ordering=-id")

    if errormessage.isEmpty{
        api.save_LiveChannels(resultados)
        saver_user(userbase64, passbase64: passbase64, username: username, password: password)
        errormessage = ""
        return true

    }else{
        errormessage = ""
        return false}
}

and loads videos is:
func load_videos(url :String)->Array<JSON>{
    var resultados : Array<JSON> = []
    var request = Get_Data()

    self.task_completed = false
    request.remoteUrl = url
    request.getData({data, error -> Void in
        println("los datos")
        //println(data)
        if (data != nil){
            // Fix possible error if no "results" key
            if let results = data["results"].array {
                resultados = results
                self.task_completed = true

            }

            println("Data reloaded")
        } else {
            println("api.getData failed")
            self.task_completed = true
        }

    })
    while(!self.task_completed){}

    return resultados
}

and get data is:
var remoteUrl = ""
func getData(completionHandler: ((JSON!, NSError!) -> Void)!) -> Void {

    let url: NSURL = NSURL(string: remoteUrl)!
    let request: NSMutableURLRequest = NSMutableURLRequest(URL: url)
    let session = NSURLSession.sharedSession()
    println(request.HTTPBody)
    request.addValue(userbase64 ,forHTTPHeaderField: "X_CXN_USER")
    request.addValue( passbase64,forHTTPHeaderField: "X_CXN_PASS")
    let task = session.dataTaskWithRequest(request, completionHandler: {data, response, error -> Void in
        if (error != nil) {
            return completionHandler(nil, error)
        }
        var error: NSError?
        let json = JSON(data : data)
        if (error != nil){
            return completionHandler(nil, error)
        } else {
            if let results = json["detail"].string {
                errormessage = results
                return completionHandler(nil, error)
            } else {
                return completionHandler(json, nil)
            }
        }
    })

    task.resume()

}

A: It happens because you show and hide it in the same method, not allowing the application to update the screen.
Try dispatching
// CODE***
activity.hidden = true
activity.stopAnimating()

asynchronously.

A: Your code contains connection to the server so you the code between startAnimating and stopAnimating will be executed on a different thread, and that's why hide function will be executed before you notice.
What you have to do is to show the activityIndicator and hide it inside the connection code after you receive the response from the server. Also, you should write the code to hide the activityIndicator inside a dispatch like this:
dispatch_async(dispatch_get_main_queue(), { () -> Void in
    activity.hidden = true
    activity.stopAnimating()
})

the answer can be more helpful if you post the rest of the code.
Edit:
You should remove the hide code from the login function and hide the activityIndicator in load_videos like this:
func load_videos(url :String)->Array<JSON>{
    ...

    request.getData({data, error -> Void in
        println("los datos")

        dispatch_async(dispatch_get_main_queue(), { () -> Void in
            activity.hidden = true
            activity.stopAnimating()
        })
        ...
    })

    return resultados
}

A: Your shown code will never work as intended. Since you are in an IBAction it is safe to assume that when this function is called you generally are operating on the main thread.
I assume that the // CODE*** section takes a long time (otherwise there would be no need for an activity indicator).
Therefore you either currently do

*

*actually perform the time-expensive operation on the main-thread and are therefore locking it -> very bad. Since you are on the main / UI-loop no UI updates happen, therefore no acitivity indicator is shown until the login is completely which is the exact time where you hide the indicator again.

*or perform the operating asynchronously in the background (recommended way). If you do this however you have to move the stopAnimating to that background-task as well.

What you should do is the following:
@IBAction func login(sender: AnyObject) {
    activity.hidden = false
    activity.startAnimating()

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
        // CODE***

        dispatch_async(dispatch_get_main_queue(), {
            activity.hidden = true
            activity.stopAnimating()
        })
    })
}

Important to note is that the stopping has to be done on the main thread again.

A: The problem is loadVideos, in which you've taken a very nice, asynchronous method and made it synchronous (blocking UI updates), and, have done so in a pretty inefficient manner with a spinning while loop. Instead, make loadVideos asynchronous:
func loadVideos(url:String, completionHandler: (Array<JSON>?) -> ()) {
    var request = Get_Data()

    request.remoteUrl = url
    request.getData {data, error in
        println("los datos")
        //println(data)
        if (data != nil){
            // Fix possible error if no "results" key
            if let results = data["results"].array {
                completionHandler(results)
            }

            println("Data reloaded")
        } else {
            println("api.getData failed")
            completionHandler(nil)
        }
    }
}

And then userValid should use the completion block parameter (employing a completionBlock pattern of its own):
func userValid(username :String, password : String, completionHandler: (Bool) -> ()) {
    userbase64 = encode_to_base64(username)
    passbase64 = encode_to_base64(password)

    var api = channelsFunction()

    api.loadVideos("https://api.cxntv.com/api/v1/videos/?type=canales&page_size=100&ordering=-id") { results in

        if results != nil {
            api.save_LiveChannels(results!)
            saver_user(userbase64, passbase64: passbase64, username: username, password: password)
            errormessage = ""
            completionHandler(true)

        }else{
            completionHandler(false)
        }
    }
}

And then login would call this asynchronously, too:
@IBAction func login(sender: AnyObject) {
    activity.hidden = false
    activity.startAnimating()
    if username.isEmpty || password.isEmpty {
        showAlert("Asegurese de ingresar un usuario y contraseña!")
    } else {
        userValid() { success in
            if !user.user_valid(self.username,password: self.password){
                self.showAlert("Usuario Invalido")
            }else{

            }

            dispatch_async(dispatch_get_main_queue(), {
                activity.hidden = true
                activity.stopAnimating()
            }
        }
    }
}

I'm sure I don't have all of your functions and variables right, but hopefully you can see the pattern: Don't use synchronous methods and use completionHandler parameters with your asynchronous methods.
--
If you want to see my original answer, that I posted before you shared the additional code, see the revision history of this answer. But the above outlines the basic approach.

A: you should learn to use dispatch_async
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0)){
    //Code take time here
    //<#Code#>
    dispatch_async(dispatch_get_main_queue(){
        //update UI
        //<#Code#>
    }
 }

and remember that UPDATE UI in the main queue


text:
Q: Priority of statemachine transitions with substates I am currently writing a generic statemachine. But I have a couple of understanding problems.
Say I have a state A. A transitions to B if a condition is met.
A also has a substate A1. A1 transitions to state C if a condition is met.
Do I transition to B or C if both conditions are met and the active state is A1?
Also do I have to run the repetitive running task of A since A is technically also active?

A: In order for a state machine to be Deterministic, all the transitions out of a given state (including it's 'substates' which is really just a shorthand for defining states with similar transitions) must be mutually exclusive.  If they are not mutually exclusive, you have a Non-Deterministic state machine.  Such machines are perfectly reasonable, but harder to evaluate -- at any given time it can be in any set of states (rather than just a single state), and every transition that is possible from any of states in the current set of states is relevant for finding the next set of states. So in your example, you would go from being in states {A1} to states {B,C}

A: After some more research I found this article that answers my question in chapter 2.10.
Crashcourse UML Statemachines
Shortly it depends which event occurs first, the timeout or the second event.


text:
Q: Checking image size via Javascript I need to check the dimensions of an image by javascript (the image is not attached to the DOM anywhere yet), and do so by a load() event on the image.
The variable IMAGE below contains a valid image url.
The variable SELF below contains a reference to THIS of the plugin.
The problem is that from within the load event I don't have access to the variables of my jQuery plugin. And from outside of the load event, I don't have access to the image dimensions checked by that event.
Gives me dimensions but no access to the plugin scope
            //Find dimensions of image
            var imageTest = new Image(), iWidth, iHeight;
            // just in case it is not already loaded
            $(imageTest).load(function () {
                iWidth = imageTest.width;
                iHeight = imageTest.height;
                alert(iWidth+' x '+iHeight);
                alert(self.data('overlayTypePreview'));
            });
            imageTest.src = image;

Gives me access to the plugin scope, but not to the image dimensions:
            //Find dimensions of image
            var imageTest = new Image(), iWidth, iHeight;
            // just in case it is not already loaded
            $(imageTest).load(function () {
                iWidth = imageTest.width;
                iHeight = imageTest.height;
            });
            imageTest.src = image;

            alert( self.data('overlayTypePreview') ); // <-- gives me the correct data, string 'mainOverlay'
            alert(iWidth+' x '+iHeight); // <-- gives me 'undefined x undefined'

I also tried the ugly hackish solution of going via window, but that didn't work for me either, perhaps because the code supposed to do the alerting triggers before the load event?
            //Find dimensions of image
            var imageTest = new Image(), iWidth, iHeight;
            // just in case it is not already loaded
            $(imageTest).load(function () {
                window.iWidth = imageTest.width;
                window.iHeight = imageTest.height;
            });
            imageTest.src = image;

            alert(window.iWidth+' x '+window.iHeight);

I suppose I could set up a system of 3 functions passing the thread to each other, but from the load event there is no way of calling the instance of my jquery-plugin right? (seeing I don't know what the user will instantiate the plugin as, otherwise I could have hard-coded the instance name, if I wanted an even uglier solution).
I suppose I could set up some sort of timeout-ping:ing of the image from inside the plugin instead of using the load() event but I thought there might be a smarter way that I didn't think of yet...

A: This is how I ended up solving it. Like I stated in my initial question, a series of 3 functions was necessary to make this clean:
In my plugin, to draw a preview of an image I make this call:
self.data('drawPreview')(self,entityId);

The drawPreview function however is only going to bounce the execution on to the isImageGreaterThanOverlay test
var drawPreview = function(self,entityId){

    self.data('isImageGreaterThanOverlay')(self,entityId,'drawPreview2')

}
this.data('drawPreview',drawPreview);

If I had only used the isImageGreaterThanOverlay() function for the drawPreview() function I could have put all of the contents of the isImageGreaterThanOverlay() righ inside the drawPreview above, but since I want to be able to use this tester for other similar functions as well, I keep it separate like this.
As seen below, my tester function declares a new Image, then attaches a load event to that image, then actually loads the image, which triggers the anonymous function inside the load event.
var isImageGreaterThanOverlay = function(self,entityId,destination){
    //Find dimensions of image
    var imageTest = new Image(), iWidth, iHeight;

    $(imageTest).load(function () {
        var iWidth = imageTest.width;
        var iHeight = imageTest.height;

        //find dimensions of overlay
        var myOverlay = self.data('overlayTypePreview');
        oWidth = parseInt( $(self).find(".VanillaGallery-"+myOverlay).css("width").replace('px', '') );
        oHeight = parseInt( $(self).find(".VanillaGallery-"+myOverlay).css("width").replace('px', '') );

        if (iWidth > oWidth || iHeight > oHeight) {
            var isGreater = true;
        }
        else {
            var isGreater = false;
        }

        self.data(destination)(self,entityId,isGreater);

    });

    var entity = self.data('findTheObject')(self,entityId);
    var image = entity['path'];
    imageTest.src = image;

}
this.data('isImageGreaterThanOverlay',isImageGreaterThanOverlay);

This is important because doing this in any other way would risk the image not being fully loaded in the browser when the code tries to read the dimensions of the image.
Key to making this work in a jQuery plugin is including the reference to the jQuery plugins's THIS like karl-andré-gagnon suggested in his comment. Through that reference, you can access the variables and functions of your plugin scope. It is how I compare the image against the overlay size (stored in my plugin's variable) and also how I pass execution back to a function inside my plugin from the load-event's anonymous function.
Also make sure you don't pass a THIS-reference (in my case SELF) in the load-events anonymous function but do it as I have done, just write it inside the anonymous function.
So when the load-events anonymous function is done checking the sizes, it passes execution on to a function that I call drawPreview2 (since it is the second part of my initial drawPreview function, remember I had to split it up because of the asynchronous load-event)
var drawPreview2 = function(self,entityId,isGreater){

    //using the passed in 'isGreater' variable,
    //I do the stuff I need to display the image correctly

}
this.data('drawPreview2',drawPreview2);


text:
Q: Performing a multiplication, textbox I have a winform with few comboboxes,texboxes etc...So I want to multiply the value from txtStake in txtTotal by clicking btnAdd, but everytime when I click btnAdd I want to multiply  the result too.
 //For example:
 //click-1, txtStake = 2, txtTotal = 2;
 //click-2, txtStake = 2, txtTotal = 4;
 //click-3, txtStake = 3, txtTotal = 12;
 //click-3, txtStake = 4.5 txtTotal = 54; Ok? How to do that? Thanks.
 --------------------------------------------------------------------

class Multy
{
    public decimal Stake;

    public Multy()
    {}
}

 private List<Multy> matches = new List<Multy>();

 private void btnAdd_Click(object sender, EventArgs e)
    {
        matches = new List<Multy>();
        Multy match = new Multy();

        match.Stake = decimal.Parse(txtStake.Text);

        matches.Add(match);

        decimal l_Stake;

        string strStake;

        string strOutputLine;

        foreach (Multy m in matches)
        {
            l_Stake = m.Stake;

            strStake = l_Stake.ToString();
        }
       txtTotal.text = //code?
     }

A: I really don't understand why you are adding one element to your list and then using foreach... If you want to multiply txtStake value with the current value of txtTotal then just do the following:
decimal result,value;
if(decimal.TryParse(txtStake.Text,out result)
    && decimal.TryParse(txtTotal.Text,out value))
         txtTotal.Text = (result * value).ToString();
else if(decimal.TryParse(txtStake.Text,out result))
         txtTotal.Text = result.ToString();

Also your Multy class is totally pointless, you can use List<decimal>

A: You basically asking for this (without error handling, feel free to improve it):
private void btnAdd_Click(object sender, EventArgs e)
{
    var stake = decimal.Parse(txtStake.Text);
    var total = decimal.Parse(txtTotal.Text);
    total *= stake;
    txtTotal.Text = total.ToString();
}

But there are a lot of things going in your code. Multy? List? foreach?

A: You probably want something like this:
private List<Multy> matches = new List<Multy>();

private void btnAdd_Click(object sender, EventArgs e)
{
    // do NOT create a new 'matches' list, use the existing one
    Multy match = new Multy();
    match.Stake = decimal.Parse(txtStake.Text);
    // you should use "TryParse" here, what if the user entered "A"?
    matches.Add(match);

    decimal runningTotal = 1m; // base value

    foreach (Multy m in matches)
    {
        runningTotal = runningTotal * m.Stake;
    }
   txtTotal.text = runningTotal.ToString();
 }


text:
Q: Add/inject image to DOM via PhantomJS I'm trying to dynamically add an image to the DOM of a loaded page, but it's not showing up when rendering the page.
In page.evaluate in modify the DOM like this (excerpt):
page.open(url, function(status) {
    ...
    window.setTimeout(function () {
        ...
        page.evaluate(function() {
            ...
                var myimg = document.createElement("img");
                myimg.setAttribute('src', 'http://www.foobar.com/fooimage.png');
                myimg.setAttribute('height', '41px');
                myimg.setAttribute('width', '80px');
                outerdiv.appendChild(myimg); // outerdiv is visible in the rendered output
                document.body.appendChild(outerdiv);
            ...
        }
        page.render

Debugging page.content shows that it's successfully added, but page.render does not show it (only the outerdiv it's appended to). Instead of using an external URL src I also tried a base64 encoded string with no luck. I also omitted the path and stored the file inside PhantomJS' include path. None of this 3 seems to work.
I also have a window.timeout of 2000 so I don't think it's an issue of rendering the page before the PNG is loaded.
What would be the proper way to add the src? External URL, local file? Why isn't even adding a base64 encoded image working? Are any security limitations blocking what I'm trying to do? I'm running PhantomJS 1.9.0 btw.

A: I cannot reproduce your problem with this complete script.
var page = require('webpage').create();
var url = "http://phantomjs.org/img/phantomjs-logo.png";

page.open("http://example.com", function (status) {
    if (status !== 'success') {
        console.log('Unable to access network');
        phantom.exit();
    } else {
        page.render("without.png");
        page.evaluate(function(url){
            var myimg = document.createElement("img");
            myimg.setAttribute('src', url);
            document.body.appendChild(myimg);
        }, url);
        setTimeout(function(){
            page.render("with.png");
            phantom.exit();
        }, 5000);
    }
});

I tried it with PhantomJS 1.9.0 and 1.9.8 with exactly the same result.

A: I came across the same problem. When I am using page.evaluate() to add images, they are not getting loaded, but content is getting changed.
If I do the same with page.content, images are getting loaded and working as expected.
var page = require('webpage').create();

page.onLoadFinished = function() {
    console.log('');
    console.log('load finished');
    var render = page.render('evaluateTesting.png');
}

page.open('about:blank', function(status) {
    console.log('');
    console.log('open callback');

    //page reloading after this line
    page.content = '<!DOCTYPE html>';

    /*
     * this is not causing page reload
     * but content is changing
        page.evaluate(function() {
        console.log('');
        console.log('evaluating');
        var body = document.getElementsByTagName('body');
        body = body[0];
        body.innerHTML = '
';
    })*/
    console.log('content : '+page.content);
})


text:
Q: How can I reuse a function properly? I try to make 3 basic slideshow.
I made this code for the first one and wanted to use it on the other 2 as well with the New slideS() method and with some parameter changing.But it's not working,even the first function is'nt working if I put parameter in it.
Can somebody explain me why is this not working and how to fix it?Thanks beforehand!
var img = document.getElementById("asd");
var imgArr = ["1.jpg", "3.png", "3.png"];
var i = 0;

function slideS(a) {

  a.src = imgArr[i];

  if (i < imgArr.length - 1) {

    i++;

  } else {

    i = 0;
  }
  setTimeout("slideS()", 1500);
}
slideS(img)

A: You could do something like this, using an object oriented approach:
function SlideShow(el, imagesArray, msDelay) {
  this.el = el;
  this.images = imagesArray;
  this.delay = (msDelay) ? msDelay : 1000;
  this.timer = null;

  this.Run = function () {
    var self = this;
    var index = 0;
    this.timer = setInterval(function(){
      self.el.src = self.images[index++ % self.images.length];
    }, this.delay);
  }

  this.Stop = function() {
    this.timer = null;
  }
}

var img = document.getElementById("asd");
var imgArr = ["1.jpg", "3.png", "3.png"];
var delay = 1500;
var ss = new SlideShow(img, imgArr, delay);
ss.Run();
...
ss.Stop();

Would that work for you? Then you are using pure functions and an object that can be used to start, stop, and manage any slide show.

A: I think you want like:
Remove setTimeout. And use setInterval:
setInterval(function(){
  slideS(img)
},1500)

A: You could use a closure over the element and the array and use setInterval instead of setTimeout.

function slide(id, array) {
    function swap() {
        image.src = array[i];
        i++;
        i %= array.length;
    }

    var image = document.getElementById(id),
        i = 0;

    setInterval(swap, 1500);
}

slide('image1', ['http://lorempixel.com/400/200/', 'http://lorempixel.com/400/200/', 'http://lorempixel.com/400/200/']);
<image id="image1"></image>

A: try this... you are making mistake at some places
var img = document.getElementById("asd");
var imgArr = ["1.jpg", "3.png", "3.png"];
var i = 0;

function slideS(a) {

  a.src = imgArr[i];

  if (i < imgArr.length - 1) {

    i++;

  } else {

    i = 0;
  }

  setTimeout(() => slideS(a), 1500);
/* you need to pass function to setTimeout and pass refrence of image that's 'a' */

// or use function instead of arrow function

  setTimeout(function() { slides(a) }, 1500);

}
slideS(img)

hope this helps..

A: I assume it works when the function doesn't take a parameter?
Then, the reason it would work with no parameter, but stop working with a parameter, is that the setTimeout tries to recursively call the function but doesn't pass a parameter.  So you'd change that to
setTimeout(() => {slideS(a);}, 1500);

But then when you try to run multiple instances of this concurrently, you'll get into trouble because your'e using global variables.  You'll need to use something more local (perhaps closures?) for your lcv, for example.

A: You have to use setInterval instead of setTimeout

var img = document.getElementById("asd");
var imgArr = ["https://i.stack.imgur.com/lgt0W.png", "https://i.stack.imgur.com/X0fKm.png", "https://i.stack.imgur.com/YfPSD.png"];
var i = 0;

function slideS(a) {

  a.src = imgArr[i];

  if (i < imgArr.length - 1) {

    i++;

  } else {

    i = 0;
  }
}

slideS(img);  //initial call to start it without having to wait for 1500 ms to pass

setInterval(function() {
    slideS(img);
}, 1500);
<img id="asd">


text:
Q: Less Than XPath I'm trying to pull products on sale from an xml file. Here is my XML:
<product>
    <programname>QVC.com</programname>
    <programurl>http://www.qvc.com</programurl>
    <catalogname>QVC Product Catalog</catalogname>
    <lastupdated>04/17/2013</lastupdated>
    <name>Product 1</name>
    <keywords>CTA Digital, Electronics, Video Games, Hardware. Nintendo Wii</keywords>
    <manufacturer>CTA Digital</manufacturer>
    <currency>USD</currency>
    <saleprice>15.96</saleprice>
    <price>17.96</price>
    <retailprice>17.96</retailprice>
</product>

I used the following xpath but it didn't work: /product[saleprice < retailprice]. I'm looking for the output to be true for any product where saleprice is less than retail price. Any thoughts on what I might be doing wrong?

A: try
/product[number(saleprice) < number(retailprice)]


text:
Q: Making carousel slider fill the entire page Hey I made this carousel slide and I wanna make it fill my entire page by changing my CSS code, how would I do that??
This is my Javascript
const carouselSlide = document.querySelector('.carousel-slide');
const carouselImages = document.querySelectorAll('.carousel-slide img');

const prevBtn = document.querySelector('#prevBtn');
const nextBtn = document.querySelector('#nextBtn');

let counter = 1;
const size = carouselImages[0].clientWidth;

carouselSlide.style.transform = 'translateX(' + (-size * counter) + 'px)';

nextBtn.addEventListener('click',()=>{
    if (counter >= carouselImages.length - 1) return;
    carouselSlide.style.transition = "transform 0.4s ease-in-out";
    counter++;
    carouselSlide.style.transform = 'translateX(' + (-size * counter) + 'px)';
});

prevBtn.addEventListener('click',()=>{
    if (counter <= 0) return;
    carouselSlide.style.transition = "transform 0.4s ease-in-out";
    counter--;
    carouselSlide.style.transform = 'translateX(' + (-size * counter) + 'px)';
});

carouselSlide.addEventListener('transitionend', ()=>{
    if (carouselImages[counter].id === 'lastClone'){
        carouselSlide.style.transition = "none";
        counter = carouselImages.length - 2;
        carouselSlide.style.transform = 'translateX(' + (-size * counter) + 'px)';
    }
    if (carouselImages[counter].id === 'firstClone'){
        carouselSlide.style.transition = "none";
        counter = carouselImages.length - counter;
        carouselSlide.style.transform = 'translateX(' + (-size * counter) + 'px)';
    }
});

and my html:
<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css"
    integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p"
    crossorigin="anonymous"/>
    <title>My Goals</title>

and lastly my css (where the "error" is):
*{
    padding: 0px;
    margin: 0px;
    box-sizing: border-box;
}

.image {
    width: 1000px;
    height: 800px;
}

.carousel-container {
    width: 1000px;
    margin: auto;
    overflow: hidden;
    position: relative;
}

.carousel-slide {
    display: flex;
    width: 100%;
    height: 800px;
}

#prevBtn {
    position: absolute;
    top: 50%;
    z-index: 10;
    left: 5%;
    font-size: 60px;
    color: white;
    cursor: pointer;
}

#nextBtn {
    position: absolute;
    top: 50%;
    z-index: 10;
    right: 5%;
    font-size: 60px;
    color: white;
    cursor: pointer;
}

I have tried to play around with the width: 100% or vh different places in my css but i cant seem to make it work. Remember there is no issue with the code. All i want is to make it 100% on the width and 100% height but when try to do that then the images just look weird and doesn't fill the entire screen like its supposed to. My code pen is here if you wanna help. :)
https://codepen.io/lucasthorsen/pen/gOxYEWm


text:
Q: Where does human waste go when going to the toilet in the Star Trek universe? Even if the society in Star Trek has evolved into a cashless state, that still leaves the matter of stools and other bodily excretions (not sweat or blood) to deal with.
Where does that all faecal matter and urine go?
Having not seen any depiction of toilets or water closets in any of the films or TV series, there has to be a way to deal with this basic bodily function. They're not the Brady Bunch after all.
They eat fine and drink plenty of tea from the replicators. And that Neelix fellow on Voyagar sure cooks up exotic meals. All that has to be handled in some hygienic manner. It's not like they stand around the transport room and have their bowels expunged into space. Do they?

A: The best (and I think only) "in-show" reference to this is in an Enterprise episode called Breaking the Ice. The crew records a series of answers for school children in Ireland and one of the questions is "When you flush the toilet [on the Enterprise], where does it go?" Captain Archer tells Engineer Trip Tucker to answer the question, which he reluctantly does, saying (not verbatim) that waste is broken down into its constituent molecules and recycled as anything required, namely boots, uniforms, etc. (Presumably at that point they don't get to make it into anything edible. Food is indeed mentioned later as being stocked and "natural.")
By TNG era, as Zypher points out, the breaking down of matter is most likely atomic (literally pulverizing the icky argument) and food can be replicated as well, or a reasonably close facsimile thereof. Table waste was also likewise disposed of (there's a mention in DS9).

A: In Star Trek V when Kirk, Spock, and McCoy are in the brig, Kirk takes a seat on what appears to be a toilet.  The only reason I believe it is a toilet is because there is signage saying something like "do not use while in Spacedock." (What else could it be?)
While I agree with the above answers, I assume also that the designers of that brig didn't want prisoner poo to be "reclaimed."

A: As a side reference, to support most of these comments, in one episode of Voyager (Year of Hell), when they are running very low on supplies, Chakotay is told to recycle something he replicated for Janeway. The implication of this is that they have the facilities to recycle material for the replicators, and it would be logical to assume that human waste - as well as any other waste - could also be included in this.
Of course, no details are given as to how material is recycled, or how the replicators work and use their resources to make anything.

A: According to the ST:TNG technical manual sections 13.4 and 13.5 wastewater is reclaimed by the replicator system, although they will use up their stock of fresh source material first and only dive into the reclaimed material in emergency situations.

A: In the documentary Journey's End: The Saga of Star Trek - The Next Generation, Johnathan Frakes actually answers this question by pointing out that only 1 bathroom is ever on an actual map in one of the props.
So, if you wanna be technical, there was only 1 bathroom on the Enterprise.

A: Easy answer:Raw material for the replicators.

A: It's natural to assume that it's decomposed in the replicator system, but in DS9, there are a few mentions of Rom cleaning the waste disposal systems, which clashes a bit with that explanation.

A: Waste in the disposal unit would most likely be flushed to a single location via traditional plumbing and atomised in bulk at a set time each day, which would be more energy efficient than using replicator technology with each flush, as well as account for the need to clean them.

A: According to The Making of Star Trek the original Kirk era Enterprise NCC-1701 had a "waste and water reconversion" area in the secondary hull.

A: As MPelletier points out, waste handling (any part of the issue from restroom facilities to disposition of the waste material) never got so much as a mention on-screen outside of the school children's Q&A sequence in ST:Enterprise, although I vaguely recall at least one perhaps ambiguous reference to "waste extraction" in DS9.
Given that the ISS reclaims water from human waste and, in nature, everything is ultimately recycled, it's reasonable to assume that in the Star Trek universe, all of the waste would be reclaimed in some fashion. Even on a large vessel like the TOS Enterprise, space is constrained, so it doesn't make sense to store months worth of provisions if you have the means to implement an alternative approach. In TOS, there is only mention of "food processors", not clearly specifying how food selections are prepared (whether synthesized or drawn from stores), so no indication if there is a "closed system". TNG-era replicator technology, however, would clearly suggest that waste processing would be like a replicator run in reverse, so waste handling could be part of a closed system with food synthesis.

A: Waste extraction is never much specified in the Star Trek universe. However replicators are presumed to be the primary means of recycling the waste on board into useful stuff. Blue prints for the Enterprise D showcase various holding tanks for inorganic and organic stuffs onboard presumably this is the feedstock for the ship.


text:
Q: How can we check whether data exists or not in a table thru sys. tables/functions directly Is there any way to check whether data exists in a table thru sys. tables or functions directly without querying the table.
Any such sys. available?
** Not querying the dynamic sql..:)

A: Read this article:
Find Row Count in Table – Find Largest Table in Database
Here is a query to find a ROWCOUNT of a table:
SELECT SUM(pa.rows) RowCnt
 FROM sys.tables ta
 INNER JOIN sys.partitions pa
 ON pa.OBJECT_ID = ta.OBJECT_ID

 WHERE ta.is_ms_shipped = 0
       AND pa.index_id IN (1,0)
       AND ta.name='table1'

SQLFiddle demo
Or if you need only information about empty table or not then something like this:
SELECT
ISNULL(
(SELECT TOP 1 1 from sys.partitions pa
                       where pa.OBJECT_ID = ta.OBJECT_ID
                             AND
                             pa.rows>0
                             AND
                             pa.index_id IN (1,0)
                 )
,0) as TableIsNotEmpty
 FROM sys.tables ta
 WHERE ta.is_ms_shipped = 0
       AND ta.name='table1'

A: -- This is how I got the result...
SELECT  Distinct tbl.name, C.name  , X.rowcnt
FROM        Sys.Columns          as     c
INNER JOIN  Sys.Tables           as     tbl
ON          tbl.object_id        =             c.object_id
INNER JOIN  Sys.Types            as     t
ON          c.system_type_id     =             t.system_type_id
INNER JOIN  Sys.Indexes     I
ON  I.object_id =       Tbl.object_id
Inner Join  Sys.sysindexes  X
On  I.index_id      =       X.indid
And I.object_id =       X.id
WHERE       X.rowcnt > 0
ORDER BY    tbl.name


text:
Q: How do you deploy a clojurescript reagent app? Reducing the problem to the simplest form:
$ lein new reagent experiment
$ cd experiment
$ lein do clean, uberjar
$ cat >index.html <<EOF
<html>
  <head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1" name="viewport">
    <link href="resources/public/css/site.css" rel="stylesheet" type="text/css">
  </head>
  <body class="body-container">
    Hello World
    <div id="app">
      <script src="target/cljsbuild/public/js/app.js" type="text/javascript"></script>
    </div>
  </body>
</html>
EOF

Pointing the browser to localhost:5000 works when using 'foreman start', but does not when serving out of nginx. (Meaning, putting this directory in a directory served by nginx will load the css and js, will show "Hello World", but the javascript has errors.) The following two errors appear in the browser's console:
app.js:451 Error rendering component (in Vn)
(anonymous) @ app.js:451
app.js:471 Uncaught Error: Assert failed: Invalid Hiccup form: [nil]
 (in Vn)
(valid-tag? tag)
    at Mk (app.js:471)
    at Jk (app.js:473)
    at Dk (app.js:475)
    at Ik (app.js:470)
    at Mk (app.js:472)
    at Jk (app.js:473)
    at bk (app.js:449)
    at app.js:451
    at uj (app.js:428)
    at vj (app.js:429)
    at Tj (app.js:448)
    at t.render (app.js:451)
    at p._renderValidatedComponentWithoutOwnerOrContext (app.js:25)
    at p._renderValidatedComponent (app.js:25)
    at performInitialMount (app.js:25)
    at p.mountComponent (app.js:25)
    at Object.mountComponent (app.js:27)
    at performInitialMount (app.js:25)
    at p.mountComponent (app.js:25)
    at Object.mountComponent (app.js:27)
    at i (app.js:26)
    at r.perform (app.js:27)
    at u (app.js:26)
    at r.perform (app.js:27)
    at Object.batchedUpdates (app.js:26)
    at Object.a [as batchedUpdates] (app.js:27)
    at Object._renderNewRootComponent (app.js:26)
    at Object._renderSubtreeIntoContainer (app.js:26)
    at Sk (app.js:476)
    at app.js:554
    at app.js:554
    at app.js:555

A: Okay, I believe something about your nginx configuration is breaking the clientside secretary routing. As you noted a similar error happens if you load the file from the filesystem (file://.../index.html).
One thing that the default reagent template doesn't provide is a default route for ".../index.html". I suspect that might help in the nginx case. I would add the following to src/cljs/experiment/core.cljs and rebuild:
(secretary/defroute "/index.html" []
  (session/put! :current-page #'home-page))

With that change, I was able to successfully load the page by serving it using the standard nginx docker container (and then browsing to localhost:5001):
docker run --name nginx -v `pwd`:/usr/share/nginx/html:ro -d -p 5001:80 nginx

You might want to compare the default configuration of that nginx docker image to your own configuration to determine what the root cause of your issue is.

A: There were two problems here, both of which kanaka's help was instrumental in ferreting out.

*

*the incoming url from nginx included "/index.html", for which there was not a secretary route. See kanaka's solution above.

*the secretary routes assume urls are off of root. In my case, this app is one of many, so it resided in a subfolder at https://www.murphydye.com/experiment/index.html.

One solution for this is to modify #'current-page as such:
(defn current-page []
  [:div (or (session/get :current-page) #'home-page)])

This gets us to the home-page when nothing matches, and also solves problem #1 (we no longer need the additional defroute "/index.html").
I say "one solution" because as you click links, the url bar will again assume it is off of root, e.g., click the about link and the url bar will show /about, not /experiment/about. Everything works because it doesn't go to the server to load the erroneous url, but bookmarking it will not work. There is surely another way to handle this, but this solves both problems sufficiently for now.
Thanks again kanaka!


text:
Q: Android, Store large amount of text (HTML) and search through them I am making a framework in order to easily "appify" books.
This framework will need to automatically detect chapter and heading to make a table of contents. The idea is to also be able to easily search through the text and find what you are looking for.
Now what I still need to figure out is:

*

*how to store the data in such a way that I can easily detect the chapters and heading

*and still be able to search through the text.

The text that is stored needs to be formatted, so I thought I would store them as HTML or Markdown (which will be translated to HTML). I don't think it would be very searchable if the text is in HTML.
P.S. it does not have to be HTML if there are other more efficient ways to format the text.

A: Do you really want to do such thing on the device itself?
I can suggest you to use separate sqlite database for every book. With separate tables for table of contents, chapters, summarized keywords of chapters(for faster search) and other service info.
Also here you can find full text search example
Also I recommend you to bring your own sqlite build with your app.
Now lets talk about the main problem of yours - the book scraping.
I have no competency here, I believe this problem is the same as the web sites scraping.
Upd:
Please do not store book contents as HTML, you can store it as markdown for example, it takes less amount of storage, easier to sanitize and you can always apply your styles later


text:
Q: Why do I get bounty emails when I'm supposedly not subscribed to emails? I checked the email I used for my Gravatar (the autogen image was cooler than the one that matches my OpenID), and I was surprised to find an automated Stack Overflow notifying me about a bounty I posted.
It told me I could opt out of these notifications, which I found odd because I wasn't aware I ever opted in to them. A study of my user profile shows a checkbox for "I'd like email notifications of activity on my questions and answers", which I have never toggled.
I find the on-site notification envelope to be far more useful, so I thought it less-than-optimal to use email notifications.
Why did I receive the email even with that setting turned off?

A: Bounty questions are automatic opt-in for email flag.

We are also turning on this flag for
users who have a bounty question in
play. We want to make sure users have
at least one day of email warning
before their question bounty expires,
so they remember to check for an
answer and accept one, if they want to
avoid the auto-accept that kicks in
for the highest scored answer (minimum
of 2 score required).

ref: https://blog.stackoverflow.com/2009/02/now-showing-email-notifications/

A: Starting a bounty is an implicit opt-in to the bounty notification emails.
Otherwise, we get far too many complaints about "gee, you didn't tell me I had to select an answer before the bounty closed!"


text:
Q: `web_sys::Url::create_object_url_with_blob(&blob)` not formatting binary data correctly I have the following code:
let bytes: Vec<u8> = load_file_as_bytes("mydoc.docx"); // This gets a byte vec representation of the file mydoc.docx
let uint8arr =  unsafe { js_sys::Uint8Array::view(&bytes) };
let js_value = wasm_bindgen::JsValue::from(uint8arr);
let blob = Blob::new_with_u8_array_sequence_and_options(
    &js_value,
    web_sys::BlobPropertyBag::new().type_("application/vnd.openxmlformats-officedocument.wordprocessingml.document"),
).unwrap();
let download_url = web_sys::Url::create_object_url_with_blob(&blob).unwrap();

When I follow the link, the file that gets downloaded is a bunch of bytes written inside a Word document.
These bytes are meant to represent the word document itself and not written to it as plaintext.
This is being compiled to Wasm and run in the browser.
I get the correct representation if I represent the bytes as Base64-encoded text and make an <a> element with an href to the string.
let base64_string = base64::encode(&file.bytes);
let download_url = format!("data:{};base64,{}",file.mime_type,base64_string);
// ... set href = &download_url inside dom

But this is horribly slow for files more than a couple KB and gets slower as more files get added.
What is the correct Rust -> JS conversion to use the create_object_url_with_blob() so that it works as expected?

A: It looks like the correct way to do this is to push your Uint8Array to a js_sys::Array first,
and because js_sys::Array implements JsCast you can use it directly inside the blob.
I assume this comes from some sort of internal representation of JavaScript types inside js_sys, and the behavior of the code in the question likely defaults to treating an array of bytes as text.
Working code:
let uint8arr = js_sys::Uint8Array::new(&unsafe { js_sys::Uint8Array::view(&bytes) }.into());
let array = js_sys::Array::new();
array.push(&uint8arr.buffer());
let blob = Blob::new_with_u8_array_sequence_and_options(
&array,
web_sys::BlobPropertyBag::new().type_("application/vnd.openxmlformats-officedocument.wordprocessingml.document"),
).unwrap();
let download_url = web_sys::Url::create_object_url_with_blob(&blob).unwrap();

This results in the bytes actually being used as the Word Document as opposed to written to an empty word doc.


text:
Q: maximum size for an array in Matlab I tried zeros(1500*64) but it says "Maximum variable size allowed by the program is exceeded."
But [C,MAXSIZE] = COMPUTER returns MAXSIZE = 2.1475e+009
So why isn't it working? Also, after trying to issue this aommand on the Matlab command line a few times, I tried everything from zeroes(500*64) to zeros(1500*64) to find the maximum allowed, and sometimes it returned "Maximum variable size allowed by the program is exceeded." for 500*64 and sometimes returned "Out of memory." error. What could be the reason for that? This is what the memory command returns:

Maximum possible array:             486 MB (5.094e+008 bytes) * Memory
  available for all arrays:   1436 MB (1.506e+009 bytes) ** Memory used
  by MATLAB:              353 MB (3.697e+008 bytes) Physical Memory
  (RAM):             3070 MB (3.219e+009 bytes)

*

*Limited by contiguous virtual address space available.
  ** Limited by virtual address space available.

Output of [u,s] = memory
[u, s] = memory
u =

MaxPossibleArrayBytes: 509411328
MemAvailableAllArrays: 1.5057e+009
        MemUsedMATLAB: 369819648

s =
VirtualAddressSpace: [1x1 struct]
       SystemMemory: [1x1 struct]
     PhysicalMemory: [1x1 struct]

How do I calculate my allowed maximum size from this information, both in terms of nuber of elements and total bytes occupied?

A: The command
 x = zeros(1500*64);

attempts to create a square matrix of double precision zeros, 96000 elements per side, requiring 73 gigabytes.
I suspect you want to use
x = zeros(1500,64);

which creates a 1500-by-64 array of double precision zeros, requiring 0.8 megabytes of memory.

A: When I google for that error message, first hit is a descriptive help page from MathWorks, the developer of MatLab:

*

*Why do I get the error 'Maximum variable size allowed by the program is exceeded.' ?
According to that, you should use the computer command, not memory, to learn the maximum matrix size supported by your edition of MatLab.
For the "Out of Memory" error, take the "Maximum possible array: 486 MB (5.094e+008 bytes)" reported by memory, and divide by the size of an array element (8 bytes for double-precision real values, which is what MatLab uses by default).  The reason it's so low is due to address space fragmentation, which is what the memory command is telling you when it talks about "Limited by contiguous address space".


text:
Q: Unable to access admin shares on Windows 2008 R2 I cannot access the any network shares of a Windows 2008 R2 server from any other server or workstation on the domain. The error is always the same Error code: 0x80070043 The network name cannot be found.
Is there something that I can do to test the connectivity?

A: OK, solution: uninstall symantec 11 for windows 2008 r2


text:
Q: SQL - displaying the top selling european car model I have this question:
Display the details (i.e. Manufacturer name, model name, type) of the top selling European car
model.
the tables are:
MANUFACTURER
CREATE TABLE Manufacturer(
manufacturerID    VARCHAR2(10)  NOT NULL,
name     VARCHAR2(20),
region   VARCHAR2(20) CHECK(region IN('ASIA', 'AFRICA', 'NORTH AMERICA', 'SOUTH AMERICA', 'EUROPE', 'OCEANIA')),
PRIMARY KEY(manufacturerID));

SALESTRANSACTION
CREATE TABLE SalesTransaction(
VIN    VARCHAR2(17)  NOT NULL,
custID   VARCHAR2(10) NOT NULL,
agentID   VARCHAR2(10) NOT NULL,
dateOfSale DATE,
agreedPrice NUMBER(10,2),
PRIMARY KEY(VIN, custID, agentID),
FOREIGN KEY(VIN) REFERENCES Car(VIN),
FOREIGN KEY(custID) REFERENCES Customer(custID),
FOREIGN KEY(agentID) REFERENCES SalesAgent(agentID));

CAR
CREATE TABLE Car(
VIN      VARCHAR2(17)  NOT NULL,
dateAcquired   DATE,
yearBuilt  NUMBER(4) CHECK(yearBuilt >1980),
purchasedPrice  NUMBER(10,2),
askingPrice NUMBER(10,2),
currentMileage NUMBER(7),
modelNo VARCHAR2(10),
PRIMARY KEY(VIN),
FOREIGN KEY(modelNo) REFERENCES Model(modelNo));

MODEL
CREATE TABLE Model(
    modelNo      VARCHAR2(10)  NOT NULL,
    name   VARCHAR2(20),
    type VARCHAR2(20) CHECK(type IN('CONVERTIBLE', 'HYBRID', 'LUXURY', 'SUV', 'VAN', 'COUPE', 'SEDAN', 'WAGON', 'HATCH', 'SPORTS', 'ROADSTER')),
    previousModel VARCHAR2(10),
    manufacturerID VARCHAR2(10),
    PRIMARY KEY(modelNo),
    FOREIGN KEY(previousModel) REFERENCES Model(modelNo),
    FOREIGN KEY(manufacturerID) REFERENCES Manufacturer(manufacturerID));

So far i did this:
SELECT Manufacturer.name, Model.name, Model.type
FROM Manufacturer, Model, Car, SalesTransaction
WHERE Manufacturer.region = 'EUROPE'
AND Model.modelNo = Car.modelNo
AND SalesTransaction.VIN = Car.VIN
AND Model.manufacturerID = Manufacturer.manufacturerID;

I get all the cars but I want only the top selling european car.
Should I use ORDER BY and rownum =1? If that is a possible way to do it, how do I do it? I am confused how to do it.

A: You should first get the total sales by doing a group by and then order the results by using order by.
SELECT Manufacturer.name, Model.name, Model.type, sum(st.agreedPrice) total_sales
FROM Manufacturer, Model, Car, SalesTransaction st
WHERE Manufacturer.region = 'EUROPE'
AND Model.modelNo = Car.modelNo
AND SalesTransaction.VIN = Car.VIN
AND Model.manufacturerID = Manufacturer.manufacturerID
group by Manufacturer.name, Model.name, Model.type
order by sum(st.agreedPrice) desc; -- order desc is important

You can then select the first row by using rownum on top of this.
select * from (
    SELECT Manufacturer.name manufacturer_name,
           Model.name model_name,
           Model.type,
           sum(st.agreedPrice) total_sales
    FROM Manufacturer, Model, Car, SalesTransaction st
    WHERE Manufacturer.region = 'EUROPE'
    AND Model.modelNo = Car.modelNo
    AND SalesTransaction.VIN = Car.VIN
    AND Model.manufacturerID = Manufacturer.manufacturerID
    group by Manufacturer.name, Model.name, Model.type
    order by sum(st.agreedPrice) desc -- order desc is important
) where rownum <= 1;

This is one way to acheieve it. There are related questions such as "What happens when to cars are tied for the first spot?" that you need to consider as well.
Based on your scenarios, you could consider using the oracle analytic functions such as rank() or row_number() as well.
Oracle RANK
Oracle DENSE_RANK
ORACLE ROW_NUMBER


text:
Q: Airflow | DAG | Copy dags written by Dev team to airflow server continuously How can I continuously copy Dags written by Development team to airflow(/home/ec2-user/airflow/dags) server. I am using Ansible currently to install Airflow.
Current approach which I am using:-
I am asking dev team to push all the dags to Bit Bucket and I have  written a ansible script which picks up the dags and put in Airflow server. This is currently handled by Jenkins job which when triggered will copy to server.