text:
Q: Record rtsp stream with ffmpeg in iOS I've followed iFrameExtractor to successfully stream rtsp in my swift project. In this project, it also has recording function. It basically use avformat_write_header
, av_interleaved_write_frame and av_write_trailer to save the rtsp source into mp4 file.
When I used this project in my device, the rtsp streaming works fine, but recording function will always generate a blank mp4 file with no image and sound.
Could anyone tell me what step that I miss?
I'm using iPhone5 with iOS 9.1 and XCode 7.1.1.
The ffmpeg is 2.8.3 version and followed the compile instruction by CompilationGuide – FFmpeg
Following is the sample code in this project
The function that generate every frame:
-(BOOL)stepFrame {
// AVPacket packet;
int frameFinished=0;
static bool bFirstIFrame=false;
static int64_t vPTS=0, vDTS=0, vAudioPTS=0, vAudioDTS=0;

while(!frameFinished && av_read_frame(pFormatCtx, &packet)>=0) {
    // Is this a packet from the video stream?
    if(packet.stream_index==videoStream) {

        // 20130525 albert.liao modified start

        // Initialize a new format context for writing file
        if(veVideoRecordState!=eH264RecIdle)
        {
            switch(veVideoRecordState)
            {
                case eH264RecInit:
                {
                    if ( !pFormatCtx_Record )
                    {
                        int bFlag = 0;
                        //NSString *videoPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test.mp4"];
                        NSString *videoPath = @"/Users/liaokuohsun/iFrameTest.mp4";

                        const char *file = [videoPath UTF8String];
                        pFormatCtx_Record = avformat_alloc_context();
                        bFlag = h264_file_create(file, pFormatCtx_Record, pCodecCtx, pAudioCodecCtx,/*fps*/0.0, packet.data, packet.size );

                        if(bFlag==true)
                        {
                            veVideoRecordState = eH264RecActive;
                            fprintf(stderr, "h264_file_create success\n");
                        }
                        else
                        {
                            veVideoRecordState = eH264RecIdle;
                            fprintf(stderr, "h264_file_create error\n");
                        }
                    }
                }
                //break;

                case eH264RecActive:
                {
                    if((bFirstIFrame==false) &&(packet.flags&AV_PKT_FLAG_KEY)==AV_PKT_FLAG_KEY)
                    {
                        bFirstIFrame=true;
                        vPTS = packet.pts ;
                        vDTS = packet.dts ;
#if 0
                        NSRunLoop *pRunLoop = [NSRunLoop currentRunLoop];
                        [pRunLoop addTimer:RecordingTimer forMode:NSDefaultRunLoopMode];
#else
                        [NSTimer scheduledTimerWithTimeInterval:5.0//2.0
                                                         target:self
                                                       selector:@selector(StopRecording:)
                                                       userInfo:nil
                                                        repeats:NO];
#endif
                    }

                    // Record audio when 1st i-Frame is obtained
                    if(bFirstIFrame==true)
                    {
                        if ( pFormatCtx_Record )
                        {
#if PTS_DTS_IS_CORRECT==1
                            packet.pts = packet.pts - vPTS;
                            packet.dts = packet.dts - vDTS;

#endif
                                h264_file_write_frame( pFormatCtx_Record, packet.stream_index, packet.data, packet.size, packet.dts, packet.pts);

                        }
                        else
                        {
                            NSLog(@"pFormatCtx_Record no exist");
                        }
                    }
                }
                break;

                case eH264RecClose:
                {
                    if ( pFormatCtx_Record )
                    {
                        h264_file_close(pFormatCtx_Record);
#if 0
                        // 20130607 Test
                        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void)
                        {
                            ALAssetsLibrary *library = [[ALAssetsLibrary alloc]init];
                            NSString *filePathString = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test.mp4"];
                            NSURL *filePathURL = [NSURL fileURLWithPath:filePathString isDirectory:NO];
                            if(1)// ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:filePathURL])
                            {
                                [library writeVideoAtPathToSavedPhotosAlbum:filePathURL completionBlock:^(NSURL *assetURL, NSError *error){
                                    if (error) {
                                        // TODO: error handling
                                        NSLog(@"writeVideoAtPathToSavedPhotosAlbum error");
                                    } else {
                                        // TODO: success handling
                                        NSLog(@"writeVideoAtPathToSavedPhotosAlbum success");
                                    }
                                }];
                            }
                            [library release];
                        });
#endif
                        vPTS = 0;
                        vDTS = 0;
                        vAudioPTS = 0;
                        vAudioDTS = 0;
                        pFormatCtx_Record = NULL;
                        NSLog(@"h264_file_close() is finished");
                    }
                    else
                    {
                        NSLog(@"fc no exist");
                    }
                    bFirstIFrame = false;
                    veVideoRecordState = eH264RecIdle;

                }
                break;

                default:
                    if ( pFormatCtx_Record )
                    {
                        h264_file_close(pFormatCtx_Record);
                        pFormatCtx_Record = NULL;
                    }
                    NSLog(@"[ERROR] unexpected veVideoRecordState!!");
                    veVideoRecordState = eH264RecIdle;
                    break;
            }
        }

        // Decode video frame
        avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
    }
    else if(packet.stream_index==audioStream)
    {
        // 20131024 albert.liao modfied start
        static int vPktCount=0;
        BOOL bIsAACADTS = FALSE;
        int ret = 0;

        if(aPlayer.vAACType == eAAC_UNDEFINED)
        {
            tAACADTSHeaderInfo vxAACADTSHeaderInfo = {0};
            bIsAACADTS = [AudioUtilities parseAACADTSHeader:(uint8_t *)packet.data ToHeader:&vxAACADTSHeaderInfo];
        }

        @synchronized(aPlayer)
        {
            if(aPlayer==nil)
            {
                aPlayer = [[AudioPlayer alloc]initAudio:nil withCodecCtx:(AVCodecContext *) pAudioCodecCtx];
                NSLog(@"aPlayer initAudio");

                if(bIsAACADTS)
                {
                    aPlayer.vAACType = eAAC_ADTS;
                    //NSLog(@"is ADTS AAC");
                }
            }
            else
            {
                if(vPktCount<5) // The voice is listened once image is rendered
                {
                    vPktCount++;
                }
                else
                {
                    if([aPlayer getStatus]!=eAudioRunning)
                    {
                        dispatch_async(dispatch_get_main_queue(), ^(void) {
                            @synchronized(aPlayer)
                            {
                                NSLog(@"aPlayer start play");
                                [aPlayer Play];
                            }

                        });
                    }
                }
            }
        };

        @synchronized(aPlayer)
        {
            int ret = 0;

            ret = [aPlayer putAVPacket:&packet];
            if(ret <= 0)
                NSLog(@"Put Audio Packet Error!!");

        }

        // 20131024 albert.liao modfied end

        if(bFirstIFrame==true)
        {
            switch(veVideoRecordState)
            {
                case eH264RecActive:
                {
                    if ( pFormatCtx_Record )
                    {
                        h264_file_write_audio_frame(pFormatCtx_Record, pAudioCodecCtx, packet.stream_index, packet.data, packet.size, packet.dts, packet.pts);

                    }
                    else
                    {
                        NSLog(@"pFormatCtx_Record no exist");
                    }
                }
            }
        }
    }
    else
    {
        //fprintf(stderr, "packet len=%d, Byte=%02X%02X%02X%02X%02X\n",\
                packet.size, packet.data[0],packet.data[1],packet.data[2],packet.data[3], packet.data[4]);
    }
    // 20130525 albert.liao modified end
}
return frameFinished!=0;
}

avformat_write_header:
int h264_file_create(const char *pFilePath, AVFormatContext *fc, AVCodecContext *pCodecCtx,AVCodecContext *pAudioCodecCtx, double fps, void *p, int len )
{
int vRet=0;
AVOutputFormat *of=NULL;
AVStream *pst=NULL;
AVCodecContext *pcc=NULL, *pAudioOutputCodecContext=NULL;

avcodec_register_all();
av_register_all();
av_log_set_level(AV_LOG_VERBOSE);

if(!pFilePath)
{
    fprintf(stderr, "FilePath no exist");
    return -1;
}

if(!fc)
{
    fprintf(stderr, "AVFormatContext no exist");
    return -1;
}
fprintf(stderr, "file=%s\n",pFilePath);

// Create container
of = av_guess_format( 0, pFilePath, 0 );
fc->oformat = of;
strcpy( fc->filename, pFilePath );

// Add video stream
pst = avformat_new_stream( fc, 0 );
vVideoStreamIdx = pst->index;
fprintf(stderr,"Video Stream:%d",vVideoStreamIdx);

pcc = pst->codec;
avcodec_get_context_defaults3( pcc, AVMEDIA_TYPE_VIDEO );

// Save the stream as origin setting without convert
pcc->codec_type = pCodecCtx->codec_type;
pcc->codec_id = pCodecCtx->codec_id;
pcc->bit_rate = pCodecCtx->bit_rate;
pcc->width = pCodecCtx->width;
pcc->height = pCodecCtx->height;

if(fps==0)
{
    double fps=0.0;
    AVRational pTimeBase;
    pTimeBase.num = pCodecCtx->time_base.num;
    pTimeBase.den = pCodecCtx->time_base.den;
    fps = 1.0/ av_q2d(pCodecCtx->time_base)/ FFMAX(pCodecCtx->ticks_per_frame, 1);
    fprintf(stderr,"fps_method(tbc): 1/av_q2d()=%g",fps);
    pcc->time_base.num = 1;
    pcc->time_base.den = fps;
}
else
{
    pcc->time_base.num = 1;
    pcc->time_base.den = fps;
}
// reference ffmpeg\libavformat\utils.c

// For SPS and PPS in avcC container
pcc->extradata = malloc(sizeof(uint8_t)*pCodecCtx->extradata_size);
memcpy(pcc->extradata, pCodecCtx->extradata, pCodecCtx->extradata_size);
pcc->extradata_size = pCodecCtx->extradata_size;

// For Audio stream
if(pAudioCodecCtx)
{
    AVCodec *pAudioCodec=NULL;
    AVStream *pst2=NULL;
    pAudioCodec = avcodec_find_encoder(AV_CODEC_ID_AAC);

    // Add audio stream
    pst2 = avformat_new_stream( fc, pAudioCodec );
    vAudioStreamIdx = pst2->index;
    pAudioOutputCodecContext = pst2->codec;
    avcodec_get_context_defaults3( pAudioOutputCodecContext, pAudioCodec );
    fprintf(stderr,"Audio Stream:%d",vAudioStreamIdx);
    fprintf(stderr,"pAudioCodecCtx->bits_per_coded_sample=%d",pAudioCodecCtx->bits_per_coded_sample);

    pAudioOutputCodecContext->codec_type = AVMEDIA_TYPE_AUDIO;
    pAudioOutputCodecContext->codec_id = AV_CODEC_ID_AAC;

    // Copy the codec attributes
    pAudioOutputCodecContext->channels = pAudioCodecCtx->channels;
    pAudioOutputCodecContext->channel_layout = pAudioCodecCtx->channel_layout;
    pAudioOutputCodecContext->sample_rate = pAudioCodecCtx->sample_rate;
    pAudioOutputCodecContext->bit_rate = 12000;//pAudioCodecCtx->sample_rate * pAudioCodecCtx->bits_per_coded_sample;
    pAudioOutputCodecContext->bits_per_coded_sample = pAudioCodecCtx->bits_per_coded_sample;
    pAudioOutputCodecContext->profile = pAudioCodecCtx->profile;
    //FF_PROFILE_AAC_LOW;
    // pAudioCodecCtx->bit_rate;

    // AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_S16P
    //pAudioOutputCodecContext->sample_fmt = AV_SAMPLE_FMT_FLTP;//pAudioCodecCtx->sample_fmt;
    pAudioOutputCodecContext->sample_fmt = pAudioCodecCtx->sample_fmt;
    //pAudioOutputCodecContext->sample_fmt = AV_SAMPLE_FMT_U8;

    pAudioOutputCodecContext->sample_aspect_ratio = pAudioCodecCtx->sample_aspect_ratio;

    pAudioOutputCodecContext->time_base.num = pAudioCodecCtx->time_base.num;
    pAudioOutputCodecContext->time_base.den = pAudioCodecCtx->time_base.den;
    pAudioOutputCodecContext->ticks_per_frame = pAudioCodecCtx->ticks_per_frame;
    pAudioOutputCodecContext->frame_size = 1024;

    fprintf(stderr,"profile:%d, sample_rate:%d, channles:%d", pAudioOutputCodecContext->profile, pAudioOutputCodecContext->sample_rate, pAudioOutputCodecContext->channels);
    AVDictionary *opts = NULL;
    av_dict_set(&opts, "strict", "experimental", 0);

    if (avcodec_open2(pAudioOutputCodecContext, pAudioCodec, &opts) < 0) {
        fprintf(stderr, "\ncould not open codec\n");
    }

    av_dict_free(&opts);

#if 0
    // For Audio, this part is no need
    if(pAudioCodecCtx->extradata_size!=0)
    {
        NSLog(@"extradata_size !=0");
        pAudioOutputCodecContext->extradata = malloc(sizeof(uint8_t)*pAudioCodecCtx->extradata_size);
        memcpy(pAudioOutputCodecContext->extradata, pAudioCodecCtx->extradata, pAudioCodecCtx->extradata_size);
        pAudioOutputCodecContext->extradata_size = pAudioCodecCtx->extradata_size;
    }
    else
    {
        // For WMA test only
        pAudioOutputCodecContext->extradata_size = 0;
        NSLog(@"extradata_size ==0");
    }
#endif
}

if(fc->oformat->flags & AVFMT_GLOBALHEADER)
{
    pcc->flags |= CODEC_FLAG_GLOBAL_HEADER;
    pAudioOutputCodecContext->flags |= CODEC_FLAG_GLOBAL_HEADER;
}

if ( !( fc->oformat->flags & AVFMT_NOFILE ) )
{
    vRet = avio_open( &fc->pb, fc->filename, AVIO_FLAG_WRITE );
    if(vRet!=0)
    {
        fprintf(stderr,"avio_open(%s) error", fc->filename);
    }
}

// dump format in console
av_dump_format(fc, 0, pFilePath, 1);

vRet = avformat_write_header( fc, NULL );
if(vRet==0)
    return 1;
else
    return 0;
}

av_interleaved_write_frame:
void h264_file_write_frame(AVFormatContext *fc, int vStreamIdx, const void* p, int len, int64_t dts, int64_t pts )
{
    AVStream *pst = NULL;
    AVPacket pkt;

if ( 0 > vVideoStreamIdx )
    return;

// may be audio or video
pst = fc->streams[ vStreamIdx ];

// Init packet
av_init_packet( &pkt );

if(vStreamIdx ==vVideoStreamIdx)
{
    pkt.flags |= ( 0 >= getVopType( p, len ) ) ? AV_PKT_FLAG_KEY : 0;
    //pkt.flags |= AV_PKT_FLAG_KEY;
    pkt.stream_index = pst->index;
    pkt.data = (uint8_t*)p;
    pkt.size = len;

    pkt.dts = AV_NOPTS_VALUE;
    pkt.pts = AV_NOPTS_VALUE;

    // TODO: mark or unmark the log
    //fprintf(stderr, "dts=%lld, pts=%lld\n",dts,pts);
    // av_write_frame( fc, &pkt );
}
av_interleaved_write_frame( fc, &pkt );
}

av_write_trailer:
void h264_file_close(AVFormatContext *fc)
{
if ( !fc )
    return;

av_write_trailer( fc );

if ( fc->oformat && !( fc->oformat->flags & AVFMT_NOFILE ) && fc->pb )
    avio_close( fc->pb );

av_free( fc );
}

Thanks.

A: It looks like you're using the same AVFormatContext for both the input and output?
In the line
pst = fc->streams[ vStreamIdx ];

You're assigning the AVStream* from your AVFormatContext connected with your input (RTSP stream).  But then later on you're trying to write the packet back to the same context av_interleaved_write_frame( fc, &pkt );.   I kind of think of a context as a file which has helped me navagate this type of thing better.  I do something identicial to what you're doing (not iOS though) where I use a separate AVFormatContext for each of the input (RTSP stream) and output (mp4 file).  If I'm correct, I think what you just need to do is initialize an AVFormatContext and properly.
The following code (without error checking everything) is what I do to take an AVFormatContext * output_format_context = NULL and the AVFormatContext * input_format_context that I had associated with the RTSP stream and write from one to the other.  This is after I have fetched a packet, etc., which in your case it looks like you're populating (I just take the packet from av_read_frame and re-package it.
This is code that could be in your write frame function (but it also does include the writing of the header).
AVFormatContext * output_format_context;
AVStream * in_stream_2;
AVStream * out_stream_2;
// Allocate the context with the output file
avformat_alloc_output_context2(&output_format_context, NULL, NULL, out_filename.c_str());
// Point to AVOutputFormat * output_format for manipulation
output_format = output_format_context->oformat;
// Loop through all streams
for (i = 0; i < input_format_context->nb_streams; i++) {
    // Create a pointer to the input stream that was allocated earlier in the code
    AVStream *in_stream = input_format_context->streams[i];
    // Create a pointer to a new stream that will be part of the output
    AVStream *out_stream = avformat_new_stream(output_format_context, in_stream->codec->codec);
    // Set time_base of the new output stream to equal the input stream one since I'm not changing anything (can avoid but get a deprecation warning)
    out_stream->time_base = in_stream->time_base;
    // This is the non-deprecated way of copying all the parameters from the input stream into the output stream since everything stays the same
    avcodec_parameters_from_context(out_stream->codecpar, in_stream->codec);
    // I don't remember what this is for :)
    out_stream->codec->codec_tag = 0;
    // This just sets a flag from the format context to the stream relating to the header
    if (output_format_context->oformat->flags & AVFMT_GLOBALHEADER)
         out_stream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
}
// Check NOFILE flag and open the output file context (previously the output file was associated with the format context, now it is actually opened.
if (!(output_format->flags & AVFMT_NOFILE))
    avio_open(&output_format_context->pb, out_filename.c_str(), AVIO_FLAG_WRITE);
// Write the header (not sure if this is always needed but h264 I believe it is.
avformat_write_header(output_format_context,NULL);
// Re-getting the appropriate stream that was populated above (this should allow for both audio/video)
in_stream_2 = input_format_context->streams[packet.stream_index];
out_stream_2 = output_format_context->streams[packet.stream_index];
// Rescaling pts and dts, duration and pos - you would do as you need in your code.
packet.pts = av_rescale_q_rnd(packet.pts, in_stream_2->time_base, out_stream_2->time_base, (AVRounding) (AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));
packet.dts = av_rescale_q_rnd(packet.dts, in_stream_2->time_base, out_stream_2->time_base, (AVRounding) (AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));
packet.duration = av_rescale_q(packet.duration, in_stream_2->time_base, out_stream_2->time_base);
packet.pos = -1;
// The first packet of my stream always gives me negative dts/pts so this just protects that first one for my purposes.  You probably don't need.
if (packet.dts < 0) packet.dts = 0;
if (packet.pts < 0) packet.pts = 0;
// Finally write the frame
av_interleaved_write_frame(output_format_context, &packet);
// ....
// Write header, close/cleanup... etc
// ....

This code is fairly bare bones and doesn't include the setup (which it sounds like you're doing correctly anyway).  I would also imagine this code could be cleaned up and tweaked for your purposes, but this works for me to re-write the RTSP stream into a file (in my case many files but code not shown).
The code is C code, so you might need to do minor tweaks for making it Swift compatible (for some of the library function calls maybe). I think overall it should be compatible though.
Hopefully this helps point you to the right direction.  This was cobbled together thanks to several sample code sources (I don't remember where), along with warning prompts from the libraries themselves.


text:
Q: how to get a list of layers that are published in geoserver by php? I'm using Apache Tomcat 7.0.72 & Geoserver v2.2 & php v5.3.5. i'm going to make a server side app with PHP that controls Accessing the layers that are published with  Geoserver.In viewing the layers from the Geoserver i'm using Openlayers3.i want to have a list of layers that are published in Geoserver. what should i do??!

A: Why aren't you just using a WMS GetCapabilities request? OpenLayers has ol.format.WMSCapabilities, so you can easily get a JSON from the available layers.
var xhr = new XMLHttpRequest();
xhr.open('GET', '/geoserver/wms?service=wms&request=GetCapabilities');
xhr.onload = function() {
  var parser = new ol.format.WMSCapabilities();
  var capabilities = parser.read(xhr.responseText);
  var layers = capabilities.Capability.Layer.Layer;
  /* List of layers is now in the `layers` array */
};

redpajama_set_name: RedPajamaStackExchange


text:
Q: wso2 developer studio dss mongo data source type removed I just downloaded WSO2 Developer Studio for Mac 64bit. I tried setting up a MongoDB data source. However, the MongoDB option no longer exists. Has WSO2 discontinued MongoDB support in DSS or is there some way to re-enable it?

A: WSO2 didn't discontinue MongoDB support in DSS 3.5.1. You can add Mongo DB data source in the data service. It's available in the management console as well.
Thanks,
Madhawa


text:
Q: Java Generics Compiler Error in Chain of Responsibility design principle public abstract class AbstractExecutor<PARAM, RET> {

private AbstractExecutor<?, ?> nextExecutor;

public abstract RET execute(PARAM param);

public void executeAll(PARAM par) {
    System.out.println("Executing..");
    RET ret= execute(par);
     if(this.nextExecutor!=null){
         System.out.println("Executing.." + this.getClass());
            this.nextExecutor.executeAll(ret);
        }
}

public AbstractExecutor<?, ?> setNextExecutor(AbstractExecutor<?,?> next){
    this.nextExecutor = next;
    return this.nextExecutor;
}}

Can anyone help me with this code, why I am wrong here "this.nextExecutor.executeAll(ret);" ? I am getting
"The method executeAll(capture#4-of ?) in the type AbstractExecutor<capture#4-of ?,capture#5-of ?> is not applicable for the arguments (RET)"
but unable to understand whats wrong here?
How to correct this ?

A: In your code, PARAM and RET are [type] parameters, i.e. they are not actual types.
Method executeAll is essentially a recursive method, i.e. it calls itself and the value returned from method execute serves as the argument for [the recursive invocation of] method executeAll. Hence RET must either be the same as PARAM or a subset of it. Therefore, the following code does compile.
public abstract class AbstractExecutor<PARAM, RET extends PARAM> {
    private AbstractExecutor<PARAM, RET> nextExecutor;

    public abstract RET execute(PARAM param);

    public void executeAll(PARAM par) {
        System.out.println("Executing..");
        RET ret = execute(par);
        if (this.nextExecutor != null) {
            System.out.println("Executing.." + this.getClass());
            this.nextExecutor.executeAll(ret);
        }
    }

    public AbstractExecutor<PARAM, RET> setNextExecutor(AbstractExecutor<PARAM, RET> next) {
        this.nextExecutor = next;
        return this.nextExecutor;
    }
}


text:
Q: Application is preventing Windows from shutting down I have a Windows Forms application which starts a couple of background workers and has a main UI thread running a form.
This application sometimes prevents the user from logging off, restarting or shutting down.
It shows a screen like the following:

The only solution I got is subscribing to the FormClosing event of my mainform and force the closing of the program like shown in the following answer.
Following this solution I was able to terminate my program without waiting indefinitely on the screen shown above but I still get it for few seconds.
How can I prevent the windows from showing

This program is preventing Windows from (restarting/shutting down/logging off)?

I tried other answers on similar question:

*

*Made sure all my other threads are background threads

*Subscribed to the Form_Closing event (Partial solution, windows closes the application eventually but the message appears for a few seconds)

*Made sure no other forms are implementing Form_Closing and holding the application


text:
Q: What does Firebase Auth library do to require all the setup? To login a user using Firebase REST API, all I have to do is POST to https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=APIKEY.
That's it.
To do the exact same thing using FirebaseAuth, I have to install command-line tools, run  scripts that add platform-specific dependencies, download config files from Firebase, generate sources and god knows what. I mean just look at this setup, and all that is before I even get to do anything auth-related  Like... what the heck? What is this thing doing under the hood to require this much theater? Why would I ever prefer this to a simple HTTP call? Sure, I get auto token-refreshing (right?), but that's just another simple HTTP call anyway.
Also, if I just do this:
Firebase.initializeApp(options: FirebaseOptions(
      apiKey: '...',
      appId: '...',
      messagingSenderId: '...',
      projectId: '...'));

I seem to be able to side-step the entire crazy setup just fine. No new dependencies, no nothing. So again... what am I missing here?


text:
Q: SQL inner select to LINQ This thing is driving me crazy.
I think its not that complicated but I don't get it.
I have this working SQL statement and I need the Linq statement for it.
select
    a.id, a.date,
    (select top 1 b.price from b where a.id = b.id and a.date >= b.date) as price
from a;

For explanation:
I have a table a with articles and a table b with a price history.
Now I need a datagrid where I can enter new entries for table a (so a view is not working) and after saving its showing me associated price
I hope I could express myself understandably

A: For translating SQL to LINQ query comprehension:

*

*Translate FROM subselects as separately declared variables.

*Translate each clause in LINQ clause order, leaving monadic operators (DISTINCT, TOP, etc) as functions applied to the whole LINQ query.

*Use table aliases as range variables. Use column aliases as anonymous type field names.

*Use anonymous types (new { }) for multiple columns

*Left Join is simulated by using a into join_variable and doing another from from the join variable followed by .DefaultIfEmpty().

*Replace COALESCE with the conditional operator and a null test.

*SELECT * must be replaced with select range_variable or for joins, an anonymous object containing all the range variables.

*SELECT fields must be replaced with select new { ... } creating an anonymous object with all the desired fields or expressions.

*Proper FULL OUTER JOIN must be handled with an extension method.

For your query:
var ans = from ra in a
          select new {
              ra.id,
              ra.date,
              price = (from rb in b
                       where ra.id == rb.id && ra.date >= rb.date
                       select rb.price).First()
          };

A: I'm not sure which syntax you're aiming for, but one of these should do the trick. I haven't tested it though.
from xa in a
select new
{
    id,
    date,
    price = (
        from xb in b
        where xa.id == xb.id && xa.date >= xb.date
        select xb.price
    ).First() // or .FirstOrDefault() if you want to allow null prices
};

or
a.Select(xa => new
{
    id,
    date,
    price = b.First(xb => xa.id == xb.id && xa.date >= xb.date) // or .FirstOrDefault() if you want to allow null prices
});


text:
Q: Python way of getting max of list containing integers and floats I have a list like this in python
list = ['1', '1.1', '1.2', '1.3','1.4', '2', '2.1', '2.2', '3', '3.1', '3.2']

Can I get this result
['1', '1.4', '2', '2.2', '3', '3.2']

or
['1.4', '2.2', '3.2']

This is a task list in string format, and I need to get the last subtask under each parent.
Thanks

A: First you need to define the comparing function:
def cmp_tasks(a,b):
    a = a.split('.')
    b = b.split('.')
    if len(a) == len(b):
        ret = cmp(int(a[0]),int(b[0]))
        if not ret:
            return cmp(int(a[1]),int(b[1]))
        return ret
    else:
        return cmp(int(a[0]),int(b[0]))

then:
One Liner:
You can do this in one liner:
>>> {int(float(i)):i for i in sorted(l,cmp=cmp_tasks)}.values()
['1.30', '2.2', '3.2']

Detailed approach:
or, more detailed: you first need to group the values according to their floored value:
l = ['1', '1.30', '1.1', '1.2', '1.3','1.4', '2', '2.1', '2.2', '3', '3.1', '3.2']
groups = {}
for i in l:
    groups.setdefault(int(float(i)),[]).append(i)

now
>>> groups
{1: ['1','1.30', '1.1', '1.2', '1.3', '1.4'], 2: ['2', '2.1', '2.2'], 3: ['3', '3.1', '3.2']}

then you can take the maximum from each group:
>>> [sorted(g,cmp=cmp_tasks)[-1] for g in groups.values()]
['1.30', '2.2', '3.2']

p.s.
note that overriding list keyword is not a good idea, because you will not be able to use list afterwards

A: Simple itertools solution:
import itertools
l = ['1', '1.1', '1.2', '1.3','1.4', '2', '2.1', '2.2', '3', '3.1', '3.2', '11', '11.1']
assert [list(group)[-1] for category, group in itertools.groupby(l, lambda x: x.split('.')[0])] == ['1.4', '2.2', '3.2', '11.1']

For different form of input data lambda function should be changed.


text:
Q: Error : "non-fast-forward" GitHub I'm trying to push some files to a remote repository from Eclipse to GitHub.
but I get this error "rejected push - non-fast-forward".
any advice ?
Thanks

A: That means that the remote repository that you're pushing to is ahead of your local one – someone else made other changes.
You need to pull and merge those changes first.


text:
Q: Change Existing Set UIColors on UIButton Press The objective is to change the font color and background color of my UITextView upon UIButton click and then revert them back to the original colors when the UIButton is clicked again; then repeat, ect.

Default Color Settings

*

*Text: blackColor

*Background: lightGrayColor
Upon Button Click (change to..)

*

*Text: greenColor

*Background: blackColor
(then if clicked again, change back to default color settings)
So far I have this:
- (IBAction) enableSleepMode:(id)sender {

    [txtNotes setTextColor:[UIColor greenColor]];
    [txtNotes setBackgroundColor:[UIColor blackColor]];

}

I apologize but I'm not exactly sure where to go from here. Thanks in advance.

A: try this
 (void)setTextColor:(UIColor *)color forState:(UIControlState)state

[button setTextColor:[UIColor greenColor] forState:UIControlStateNormal];
[button setTextColor:[UIColor blackColor] forState:UIControlStateHighlighted];

 (void)setBackgroundColor:(UIColor *)color forState:(UIControlState)state

[button setBackgroundColor:[UIColor blackColor] forState:UIControlStateNormal];
[button setBackgroundColor:[UIColor lightgrayColor] forState:UIControlStateHighlighted];

something like that is i think what you're looking for

A: You said to change the font color and background color of 'UITextView' not 'UIButton' Right? . Then did you add UItextViewDelegate?
I have done this like
EDIT:
    - (void)viewDidLoad
    {
    [super viewDidLoad];
    [txtView setBackgroundColor:[UIColor lightGrayColor]];
    [txtView setTextColor:[UIColor blackColor]];
    str = @"first";
    }

   -(IBAction)bt:(id)sender
{
    if([str isEqualToString:@"first"])
    {
        [txtView setBackgroundColor:[UIColor blackColor]];
        [txtView setTextColor:[UIColor greenColor]];
        str = @"second";
    }
    else
    {
       [txtView setBackgroundColor:[UIColor lightGrayColor]];
       [txtView setTextColor:[UIColor blackColor]];
        str = @"first";
    }
}


text:
Q: CMV Search widget url query string I am migrating my Flex eSearch widget to the CMV Search widget.  I need to be able to pass a query through an url within the widget.  Currently my widget has 8 URLs that are in the widget.
Flex Code:

A: You didn't include the Flex code. I assume you are asking about my Search widget Below is what I do to run a query from the url with my widget.
You need to include some additional modules at the top of your viewer.js file:
define([
    ...
    'dojo/io-query',
    'dojo/topic'

], function (... ioQuery, topic) {

Include this queryString widget in the widgets section of viewer.js:
queryString: {
    include: true,
    id: 'queryString',
    type: 'invisible',
    path: 'dijit/_WidgetBase',
    options: {
        startup: function () {
            var uri = window.location.href;
            var qs = uri.substring(uri.indexOf('?') + 1, uri.length);
            var qsObj = ioQuery.queryToObject(qs);
            var id = qsObj.ID;
            if (id) {
                window.setTimeout(function () {
                    topic.publish('searchResults/search', {
                        layerIndex: 0,
                        searchTerm: id
                    })
                }, 2000);
            }
        }
    }
}

Note at present, searching from the url is limited to a single search term (1 field).

A: I found a simple answer to my question.  I just added an additional  tag for each URL.  I used the same url in the example for simplicity sake.
Windyty Wind Map ForecastsWindyty Wind Map ForecastsWindyty Wind Map ForecastsWindyty Wind Map ForecastsWindyty Wind Map ForecastsWindyty Wind Map Forecasts'

A: I figured the ioQuery question. The function did not like the "-" in the text.


text:
Q: Pronunciation difference between "collar" and "color" What is the pronunciation difference between collar and color? Can a native speaker tell them apart?

A: The vowel sound is slightly more open in collar [ɑ] than in color [ʌ].
English pronunciation is not always easy for non native speakers.
A good thing is to be able to read the IPA. Most bilingual paper dictionaries will give the pronunciation of words in the IPA.
And on monolingual dictionaries on the web you can listen to the word as well:

*

*collar   /ˈkɑlər/

*color   /ˈkʌlə(r)/

An on the Wiktionary, the Freedictionary and lots of others.
On the University of Iowa website there is a very good flash animation that shows all the movements involved when pronouncing each vowel.

A: The difference is quite clear in British pronunciation. Colour is /ˈkʌlə/, rhyming with duller. Collar is /ˈkɒlə(r)/, rhyming with dollar. (I realize those rhymes may not be much help if duller and dollar sound the same in American pronunciation.)

A: Yes, native speakers can easily differentiate these words.
If you have trouble with IPA, you can try pronouncing them this way (for American English):
color ≈  culler (the vowel is a short "uh" sound)
collar ≈  caller (the syllable following c is just like the word all)
You might try practicing with a sentence like "What color is your collar?" and overemphasize the differences until you get used to the sound.

A: What color was the caller's collar? Thinking about the differences makes me question my pronunciation (and kind of makes my brain hurt). The OP had a good question and the answer varies depending on accent. I pronounce color like cahler, but my husband says culler. My pronunciation of collar is similar to that of color, the difference is very subtle and I don't know how to describe it - for color my tongue is more forward giving a slightly more open/hollow vowel. For caller I say cawler - but not with a southern drawl. My husband pronounces collar and caller the same - cahler.

A: Color is pronounced much shorter than collar. Pronouncing collar you spend a bit more time on the first coll- part.

A: For "collar" you say "caw", opening your mouth to about half-open as you say the vowel.
For "color" you say "cuh", keeping your mouth just barely ajar.
In both cases, the second syllable is just lrrr.

A: Approximate to Kollar (gentle r) and Culla in British English.


text:
Q: Cannot connect to socket Hey im writing an echo client, and for some reason the connectsock function is returning an error, and returning an INVALID_SOCKET. I can't figure out why is this. Can someone tell me why
/*********************************
*   echo1.cpp                    *
*                                *
*   Echo client - version 1      *
**********************************/
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
#include <string>
#include <iostream>
using namespace std;

const int  MAXBUF  = 128;
const int  MAXNAME = 80;

SOCKET connectsock (char*, char*, char*);

int main (int argc, char **argv)
{
    char msg[MAXBUF] = "";
    char buf[MAXBUF] = "";
    char host[MAXNAME] = "";
    char service[MAXNAME] = "";
    int  len;
    SOCKET s;

    /* Must always initialize the Windows Sockets TCP/IP library */
    WORD wVersion = 0x0202;
    WSADATA wsaData;
    int iResult = WSAStartup( wVersion, &wsaData);
    if (iResult != 0)
    {
        cout << "Unable to initialize Windows Socket library." << endl;
        return 0;
    }

    string hostaddress = argv[1];

    if(argv[2] == NULL)
    {
        strcpy_s(service, MAXNAME, "7");
    }
    else
    {
        strcpy_s(service, MAXNAME, argv[2]);
    }

    strcpy_s( host, MAXNAME, hostaddress.c_str() );

    s = connectsock(host, service, "tcp");
    if (s != INVALID_SOCKET)
    {

        cout <<"Message?";
        cin.getline(msg, MAXBUF);

        // Now, let's try to send the message to the remote machine

        len = send(s, msg, (int) strlen(msg), 0);
        if (len > 0)
        {
            cout << "Number of bytes sent: " << len << endl;
            cout << endl;
        }
        else
        {
            cout << "Unable to send message to remote machine." << endl;
            return 0;
        }

        // Message was sent.  Is there a reply from the remote machine?
        len = recv(s, buf, sizeof(buf), 0);
        if (len > 0)
        {
            cout << "Received message: ";
            for (int i=0; i<len; i++) cout << buf[i];
            cout << endl;
            cout << "Number of bytes received: " << len << endl << endl;
        }
        cout << endl << endl;

        /* Close the socket (and thus the connection) */
        shutdown(s,1);
        closesocket(s);
    }
    WSACleanup();
}

/*------------------------------------------------------------------
* connectsock - allocate & connect a remote socket using TCP or UDP
*------------------------------------------------------------------
*/
SOCKET connectsock (char *host, char *service, char *protocol)
{
    struct  hostent *phe;
    struct  servent *pse;
    short   port;
    int     ihost;

    port = htons( (u_short) atoi(service)); // 1st try to convert string to integer
    if (port == 0)
    {                       // if that doesn't work, call service function
        pse = getservbyname(service,NULL);
        if (pse)
        {
            port = pse->s_port;
        }
        else
        {
            cout << "Invalid service request." << endl;
            return INVALID_SOCKET;
        }
    }
/*
    cout << "Service: " << service << endl;
    cout << "Port:    " << htons(port) << endl;
*/

    ihost = inet_addr(host);
    if (ihost == INADDR_NONE)
    {
        phe = gethostbyname(host);
        if (phe)
        {
            memmove(&ihost, phe->h_addr, phe->h_length);
        }
        else
        {
            cout << "Invalid Host." << endl;
            return INVALID_SOCKET;
        }
    }
/*
    cout << "Network address for hostname:         " << host << endl;
    cout << "32-bit address in Network Byte Order: " << ihost << endl;
    cout << "32-bit address in Host Byte Order:    " << ntohl(ihost) << endl;

    struct in_addr in;
    in.S_un.S_addr = ihost;
    cout << "Address as dotted decimal:            " << inet_ntoa(in) << endl;

*/

    struct sockaddr_in remote;
    SOCKET s;

    if (_stricmp(protocol, "tcp") == 0)
    {
        s = socket(AF_INET, SOCK_STREAM, 0);

        if (s < 0 || s == INVALID_SOCKET)
        {
            cout << "Cannot create socket" << endl;
            return INVALID_SOCKET;
        }

        memset(&remote, 0, sizeof(remote));
        remote.sin_family = AF_INET;
        remote.sin_port = htons( (u_short) atoi(service));
        remote.sin_addr.s_addr = inet_addr(host);

        int status = connect(s, (LPSOCKADDR) &remote, sizeof(SOCKADDR));

        if (status == SOCKET_ERROR)
        {
            cout << "Remote host/service not found - or connection refused" << endl;
            return INVALID_SOCKET;
        }
    }

    else if (_stricmp(protocol,"udp") == 0)
    {
        s = socket(AF_INET, SOCK_DGRAM,  0);
        if (s < 0 || s == INVALID_SOCKET)
        {
            cout << "Cannot create socket" << endl;
            return INVALID_SOCKET;
        }
    }
    else
    {                                   // Unknown or unsupported protocol request
        cout << "Invalid Protocol" << endl;
        return INVALID_SOCKET;
    }

    return s;
}

A: I think that you should use
      remote.sin_port = port;

instead of what you use:
      remote.sin_port = htons( (u_short) atoi(service));

because at some point before in the function you already try to convert the service into a port number. If the service is specified by name, as it seems in your example, this code will always give a remote.sin_port of 0.

A: When you run this code, are you possibly supplying a socket that is already in use? In windows you can do
netstat -a

And take a look to make sure that socket isn't already in use.
Note: I'm not a window user's so that command might now work.

A: Based on @Diego's sharp eye, I also noticed a second issue.  This code:
remote.sin_addr.s_addr = inet_addr(host);

is odd because earlier you had checked inet_addr and then fallen back on gethostbyname if inet_addr failed.  So if you have supplied a hostname, this will cause problems as well.  You need to change that to:
remote.sin_addr.s_addr = ihost;


text:
Q: std::unordered_map invalid read of size 8 in valgrind related to element erasure I'm writing a wrapper around std::unordered_map to make it threadsafe (putting mutex lock and mutex unlock around all operations on the unordered_map.
Recently I was testing this wrapper class and i got an invalid read of size 8 from my wrapper's del function (which wraps the unorderd_map's erase(key) function). The delete returns a pointer to the value of the erased key-value pair. This is to be able to be able to free memory in case we're storing pointers to allocated memory in the unordered_map. For example if I store string* pointers (with allocated memory) in unordered map, del(key) would return a string** pointer.
However, when deleting the string* valgrind complains about an invalid read of size 8.
I wrote a small test program to reproduce the error:
compiled with g++ -g -std=c++0x ./*.cpp   (version g++ (Debian 4.9.1-16) 4.9.1)
#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

//wrapper class around unordered_map.
template<typename KEY, typename VAL>
class Umwrap{
    public:
    Umwrap(){}
    ~Umwrap(){}

   //simple add. returns true when key is unique and add is succesful, false when key   isn't unique
    bool add(KEY key, VAL val){
        auto respair = this->umw.emplace(key, val);
        return respair.second;
    }

    //delete key-value pair. Returns pointer to val.
    VAL* del(KEY key){
        VAL* retval = NULL;
        try{
            retval = &(this->umw.at(key));
        }catch(out_of_range &oor){
            return retval;
        }
        umw.erase(key);
        return retval;
    }

    private:
    unordered_map<KEY, VAL> umw;
};

int main(int argc, char** argv){

    Umwrap<int, string*> testmap;

    testmap.add(1, new string("a"));

    //delete key-value pair. the unordered_map header says that it will not touch the memory pointed to by val, and that the user should do his/her own memory management.
    string** sta = testmap.del(1);

    delete *sta; //causes an invalid read of size 8 in valgrind.

    return 0;
 }

this gives me in valgrind:
==18625==
==18625== Invalid read of size 8
==18625==    at 0x400D7A: main (main.cpp:46)
==18625==  Address 0x59ff1a0 is 16 bytes inside a block of size 24 free'd
==18625==    at 0x4C2A360: operator delete(void*) (vg_replace_malloc.c:507)
==18625==    by 0x402951: __gnu_cxx::new_allocator<std::__detail::_Hash_node<std::pair<int const, std::string*>, false> >::deallocate(std::__detail::_Hash_node<std::pair<int const, std::string*>, false>*, unsigned long) (new_allocator.h:110)
==18625==    by 0x4023F3: std::allocator_traits<std::allocator<std::__detail::_Hash_node<std::pair<int const, std::string*>, false> > >::deallocate(std::allocator<std::__detail::_Hash_node<std::pair<int const, std::string*>, false> >&, std::__detail::_Hash_node<std::pair<int const, std::string*>, false>*, unsigned long) (alloc_traits.h:383)
==18625==    by 0x401B55: std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<int const, std::string*>, false> > >::_M_deallocate_node(std::__detail::_Hash_node<std::pair<int const, std::string*>, false>*) (hashtable_policy.h:1977)
==18625==    by 0x4021C9: std::_Hashtable<int, std::pair<int const, std::string*>, std::allocator<std::pair<int const, std::string*> >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_erase(unsigned long, std::__detail::_Hash_node_base*, std::__detail::_Hash_node<std::pair<int const, std::string*>, false>*) (hashtable.h:1796)
==18625==    by 0x4019C0: std::_Hashtable<int, std::pair<int const, std::string*>, std::allocator<std::pair<int const, std::string*> >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_erase(std::integral_constant<bool, true>, int const&) (hashtable.h:1823)
==18625==    by 0x4013E5: std::_Hashtable<int, std::pair<int const, std::string*>, std::allocator<std::pair<int const, std::string*> >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::erase(int const&) (hashtable.h:741)
==18625==    by 0x4011CA: std::unordered_map<int, std::string*, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, std::string*> > >::erase(int const&) (unordered_map.h:500)
==18625==    by 0x400FFF: Umwrap<int, std::string*>::del(int) (main.cpp:28)
==18625==    by 0x400D71: main (main.cpp:44)
==18625==
==18625==
==18625== HEAP SUMMARY:
==18625==     in use at exit: 0 bytes in 0 blocks
==18625==   total heap usage: 4 allocs, 4 frees, 146 bytes allocated
==18625==
==18625== All heap blocks were freed -- no leaks are possible
==18625==
==18625== For counts of detected and suppressed errors, rerun with: -v
==18625== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

I'm somewhat stumped. A similar test program using std::vector<string*> in stead of std::unordered_map<int, string*> did not produce a similar invalid read error in valgrind.
So as a sanity check i'm asking here:
What am I doing wrong in/around the del(KEY key){...} function?
If not, is it a bug? Any pointers as to where to file a bug report would be helpful too.
Many thanks in advance.


text:
Q: Error: Attempt to read or write outside of disk 'hd0' Before I start, I'd like to mention a few things.
I'm quite a newbie, and do not know much about Ubuntu. All I wanted was to be able to have a dual boot Windows7/Ubuntu, the latter being a backup when my Windows get a bit slow. It's been working fine, and I have mostly been browsing on firefox with it.
I have very little knowledge of Ubuntu (I don't know how to do commands, "sudo" things etc). I've looked up my question a few times, and words such as "kernel" pop up, which confuse me.
So please, be tolerant and patient with me! :)
A few days ago, my laptop fell from the desk (cables hanging, pulled on by a foot...). I've had this laptop for over 3 years and it fell a few times (I'm very clumsy), nothing major happened to it appart from a few scuffs. Yet, since this happened, my computer seems to refuse to boot properly, and at the "Grub" ,where you select between Ubuntu and Windows, I get the error "Attempt to read or write outside of disk 'hd0'".
If I try to boot Windows, nothing happens.
I suspect it is due to the computer falling and possibly damaging the Hard Drive, but I am not sure.
I did try and install a few programs before (such as VLC etc) while on Ubuntu, attempting at the "sudo" thingies... Could I have done something wrong to mess up the whole hard drive?
In any case, since this happened, I have not been able to boot my computer, and right now am using an old laptop to post this message.
I have a little bit of knowledge on dismantling laptops, so I removed the hard drive from the laptop and connected it to this one. It does the same error, so I confirmed (to myself) that it wasn't hardware problems of the laptop but just the Hard Drive.
Thank you for your time, and many thanks if you can help me!

A: This almost definitely seems like a hardware issue. Try making another live-boot disk or USB drive (ubuntu) and booting into that. If you can mount your hard drive (via the file manager) it isn't a hardware issue, and would be something else. However, hd0 is the name that GRUB gives to your hard drive, so if it (suddenly) doesn't see it, it's likely not due to software.
Alternatively, try booting into your BIOS and see if it can see your hard drive. Either way, I'd be surprised if it's not a hard drive failure.

A: The mere fact that you get errors after a drop, and such severe ones that makes it not boot, is a sure sign of something being very wrong.
Computer software cannot run well on "bumpy roads" and that shows.
The very best option you have is to replace all hardware.
More: There may well be small fractions in (one or more...) PCBs which show up in intermittent manner, which is really bad if you want to keep your data intact.
Video, Music and similar content might not be that important to keep 100% intact, but when the software read from storage (harddisk) doesn't read correctly - then you're on your own, you will likely see obscure and intermittent fails.
Another source of strange faults is power supply malfunction. e.g. harddisks need both 5 and 12V feeds, if 12V fails the platters will stop rotating - read/write faults will appear, even if those failures are very short. You might not notice such a failure until it is too late - when you loose data.
The end result is very similar when the 5V supply fails, that could be called "brain damage" on the behalf of a harddisk.


text:
Q: Marketing Cloud Txn API | Whitelist my Webhook only for Marketing Cloud calls If I implement a webhook, it basically allows anyone to call that endpoint. As this would be a public URL.
From security point of view, I should only consume event notifications coming only from Marketing Cloud.
How do I secure my webhook and whitelist only Marketing Cloud? I did not find any official documentation from Marketing Cloud about this.

A: I will suggest starting by solving it with IP whitelisting in your webhook service. The IPs you need to allow for communication between Marketing Cloud and your endpoint depend on the stack on which your MC resides.
You can find all the IP addresses on this page, under Instance-Specific IP Addresses. For example, if your instance resides on stack 6, you should allow your endpoint to receive traffic from following IP adresses:
68.232.200.1
68.232.200.2
68.232.200.3
207.67.38.42
198.245.87.251
13.111.27.193
13.111.27.194
13.111.27.195
13.111.27.196
You should also have a look at this sequence diagram explaining the process of integrating MC with your endpoint (source):

As described in the documentation all the callbacks are signed, and can be validated by looking at their HMAC-SHA256 signature.
Combining both IP whitelisting and signing, will ensure you only accept valid calls to your endpoint.


text:
Q: How do I put text that is inside a P element next to a image? Here is my code:

This is some example text that i want next to the image on the right hand side

At the moment, the text is underneath the image. How do I put the text next to the image?

A: NO CSS & JavaScript, PURE HTML

 Text beside image

Place  inside a
 can put the image surround by text. Read more here.
NOTE:  tag has display: inline by default and   is basic a non-breaking space, read more here.

This is some text.
     This is some text.

     This text is next to the image

A: you can do it without changing the html structure
As img is a inline element you can set the next sibling p to inline
By default p is a block element so it is taking full width
more about + selector

img + p {
  display: inline;
  margin-left: 10px;
  vertical-align: top; /* so that p aligns to the top of img*/
}

This is some example text that i want next to the image on the right hand side

A: If you want to place text to right side of an image, here's code which will allow it:

 Image text here.

Running example: https://jsfiddle.net/apc5spcu/
Alternately, you could use divs and make a nicer looking image form.
HTML

 Image text here.

 Image text here.

 Image text here.

 Image text here.

This code makes use of 'Float' which positions each division next to eachother on left and right sides.
CSS
.container {
    width:540px;
}
.imgdiv {
    float:left;
    width:140px;
}
.textdiv {
    float:right;
    width:300px;
}

Running example: https://jsfiddle.net/apc5spcu/1/

A: As a side note, since you tagged this as HTML5, you would be better off using
 and
 to mark up this content.
For example:

This is some example text that i want next to the image on the right hand side

Then you could style it like:
figure {
   margin: 0;
   width: 600px;
   height: auto;
   overflow: hidden;
}
figure img {
   width: 30%;
   float: left;
}
figure figcaption {
   width: 70%;
   float: right;
}


text:
Q: Set state in React based on Java Spring request I have a small project with React Front and Spring Java backend. For now I am trying to set a data in React "state" based on response of Spring method. This is how looks like Java method:
    @CrossOrigin(origins = "http://localhost:3000")
@GetMapping("/cities")
public ResponseEntity getCity ()throws JsonProcessingException
{
    List <City> cities = cityRepository.findByName("New York");
    System.out.println(cities);
    return ResponseEntity.ok(objectMapper.writeValueAsString(cities));
}

When i tapped in browser

localhost:8080/cities"

it looks like:

[{"name":"New York","countryCode":null,"population":8008278,"id":3793,"district":"New York"}]

countryCode doesn't matter. It have @transient adnotation.
In React i have a state and methods looks like:
    class App extends Component {

    state = {
    population: '',
    district: ''
    }

    handleInputChange = (e) => {
      this.setState({
        value: e.target.value
      })
    }

    handleCitySubmit = e => {
      e.preventDefault()
      const API = `http://localhost:8080/cities`;

      fetch(API)
      .then(response => {
        if(response.ok){
      return response
    }
    throw Error("It doesn't works")
      })
      .then(response => response.json())
      .then(data => {
        this.setState({
          district: data.district
          population: data.population

        })
      })
console.log('District info: '+this.state.district)
console.log('District info: '+this.state.population)
}

But it doesn't works. District and population are still undifined. Does anyone could tell me, how to fix it?

A: I assume this is not all of your code in your App-Component.
Actually I use more function components but still, I think you need to bind your handlers:
constructor(props) {
   super(props);
   this.state = {
      population: '',
      district: ''
   };
   this.handleInputChang = this.handleInputChange.bind(this);
   this.handleCitySubmit = this.handleCitySubmit.bind(this);
}

Or just use Function-Components :)
And did you console log your responce from your first resolve? and I would prefer to use catch for error-handling.

A:
I think you need to bind your handlers:

Sorry, but it doesn't works. I'll show all React and Spring classes of project below:
First, Spring:
City
    @Entity
@Table(name = "city")
@Getter
@Setter
@ToString

public class City {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    int ID;
    String name;
    @Transient
    String countryCode;
    String District;
    int population;

    public City()
    {

    }

    public City(int ID, String name, /*String countryCode,*/ String District, int Population) {
        this.ID = ID;
        this.name = name;
        /*this.countryCode = countryCode;*/
        this.District = District;
        this.population = Population;
    }
}

CityRepository
public interface CityRepository extends JpaRepository<City, Long> {

List<City> findByName(String name);

}
CityService
    @RestController
public class CityService {

    @Autowired
    CityRepository cityRepository;

    @Autowired
    ObjectMapper objectMapper;

    @CrossOrigin(origins = "http://localhost:3000")
    @GetMapping("/cities")
    public ResponseEntity getCity ()throws JsonProcessingException
    {
        List <City> cities = cityRepository.findByName("New York");
        System.out.println(cities);
        return ResponseEntity.ok(objectMapper.writeValueAsString(cities));
    }
}

React:
App.js

    class App extends Component {

  constructor(props) {
    super(props);
    this.state = {
       population: '',
       district: ''
    };
    this.handleInputChange = this.handleInputChange.bind(this);
    this.handleCitySubmit = this.handleCitySubmit.bind(this);
 }

state = {
  district: '',
  population: '',
}

handleInputChange = (e) => {
  this.setState({
    value: e.target.value
  })
}

handleCitySubmit = e => {
  e.preventDefault()
  const API = `http://localhost:8080/cities`;

  fetch(API)
  .then(response => {
    if(response.ok){
  return response
}
throw Error("It doesn't works")
  })
  .then(response => response.json())
  .then(data => {
    this.setState({
      district: data.district,
      population: data.population

    })
  })
console.log('District info: '+this.state.district)
console.log('Population info: '+this.state.population)
}

  render (){
    return (

      <Form
      value = {this.state.value}
      submit = {this.handleCitySubmit}
      />
      <Result/>

  );
    }
}

export default App

Form.js
    const Form = props => {
return (
    <form onSubmit={props.submit}>
        <input
        type ="text"
        value = {props.value}
        placeholder="Enter city name"
        />
        <button>Find city </button>

    </form>
)
}

export default Form

Result.js
const Result = () => {
return (

City

);
}

export default Result;

A: setState is an asynchronous operation, which means it is entirely possible that those console.log calls are made before the state is properly set. The same applies to your render method. I'm not sure what your specific error is, but undefined problems using http requests are usually caused by trying to render something that depends on the state, while the state has not been set yet. In your case, it is probably that your state has not been set yet. You can try:
  render (){
    return (

      {this.state.value ? <Form
      value = {this.state.value}
      submit = {this.handleCitySubmit}
      /> :
State has not been set yet
}
      <Result/>

  );
    }

Which checks whether this.state.value actually has a value other than null or undefined, and only renders the Form when it actually has a proper value.
PS: Your indentation (or rather lack of indentation) makes your functions hard to read. I would recommend using your IDE's formatting tool to properly indent, so the code becomes easier to read for others.


text:
Q: How to check if there is an active session in a JSF page? there is a way to check if there is an active session directly in jsf page?
I have try this but it doesn't work:
<p:ajaxStatus onerror="#{session == null ? 'idleDialog.show();' : null}"

thank you in advance
@Update
I have see that onerror isn't fired even if viewExpiredException occurr.

A: There is always an active session at the time the EL is evaluated. If there isn't before the page was opened, it is automatically created.
In JSF expiring sessions are a problem because of the so called "state saving method". By default the state of the generated page is stored in the session. If you try to submit the form and the session is expired, the state is lost and hence an error occurs.
But even in that case a new session is generated. So, as BalusC noted, you can keep the session alive - poll with ajax requests (for example richfaces has such facilities) so that the session never expires

A: You can use the following EL expression in JSF 2.0:
#{facesContext.externalContext.getSession(false) == null}
Do note that referencing the implicit EL object session will automatically (re)create it again. This one can thus never be used for testing.
E.g.
Suppose you would have invalidated the session in a backing bean, and a Facelet with the following content was rendered:
#{facesContext.externalContext.getSession(false) == null}
#{session.new}
#{facesContext.externalContext.getSession(false) == null}

This would render:
true true false

The session is first really gone, but by referencing the implicit EL object it's created again (and will be in the new state). The second test then finds the session to be there again.


text:
Q: Custom HTML Form Element with Shadow DOM gives blank html page The code is from this page https://usefulangle.com/post/362/custom-elements
It builds a custom html form element with shadow DOM.
But, when I open it in a browser, it's blank.

I opened the code in "Inspect" and saw this error.

class InputPlusMinus extends HTMLElement {
  constructor() {
    super();

    let template = document.querySelector('#input-plus-minus-template').content;
    this.attachShadow({
      mode: 'open'
    }).appendChild(template.cloneNode(true));

    let add_button = this.shadowRoot.querySelector("#add");
    let subtract_button = this.shadowRoot.querySelector("#subtract");
    let count_textbox = this.shadowRoot.querySelector("#count");

    this.setAttribute('value', '1');

    add_button.addEventListener('click', () => {
      let current = parseInt(count_textbox.value, 10);
      count_textbox.value = current + 1;
      this.setAttribute('value', count_textbox.value);
    });

    subtract_button.addEventListener('click', () => {
      let current = parseInt(count_textbox.value, 10);
      if (current > 1) {
        count_textbox.value = current - 1;
        this.setAttribute('value', count_textbox.value);
      }
    });
  }
}

customElements.define('input-plus-minus', InputPlusMinus);
<template id="input-plus-minus-template">

            <button id="subtract">-</button>
            <input type="text" id="count" value="1" readonly />
            <button id="add">+</button>

    </template>

<input-plus-minus id="sample"></input-plus-minus>

A: Based on the comments, I modified the code and it works now. Thank You so much!!

class InputPlusMinus extends HTMLElement {

  connectedCallback() {
    let template = document.querySelector('#input-plus-minus-template').content;
    this.attachShadow({
      mode: 'open'
    }).appendChild(template.cloneNode(true));

    let add_button = this.shadowRoot.querySelector("#add");
    let subtract_button = this.shadowRoot.querySelector("#subtract");
    let count_textbox = this.shadowRoot.querySelector("#count");

    this.setAttribute('value', '1');

    add_button.addEventListener('click', () => {
      let current = parseInt(count_textbox.value, 10);
      count_textbox.value = current + 1;
      this.setAttribute('value', count_textbox.value);
    });

    subtract_button.addEventListener('click', () => {
      let current = parseInt(count_textbox.value, 10);
      if (current > 1) {
        count_textbox.value = current - 1;
        this.setAttribute('value', count_textbox.value);
      }
    });
  }
}

customElements.define('input-plus-minus', InputPlusMinus);
<template id="input-plus-minus-template">

                <button id="subtract">-</button>
                <input type="text" id="count" value="1" readonly />
                <button id="add">+</button>

        </template>

<input-plus-minus id="sample"></input-plus-minus>


text:
Q: AngularJS smart Table Global search only on displayed field I'm using smartTable and I love it, it is really nice. I have an issue with the global search, to perform global search with smart table, you just have to define an input like this:
<input st-search class="form-control" placeholder="Global search ..." type="text"/>

The problem is that this will search on all the data returned by the server.
I would like to find a way to search only in the displayed data, so if the data returned by the server is not displayed, I don't want that the search finds it.
I created this jsFiddle that shows the problem, in there we display the firstName and lastName but not the "id"
If you search for a number, for instance "12", the result display will be "Laurent Renard" because his ID is "12".
So the the question is :
Is there a way to globally search only on the displayed data withtout using a custom filter ?


text:
Q: html list item selection with arrow keys in Angular 2 I am trying to select li's via arrow keys, but am running into issues.
I tried following the answer here, but my li's never become selected.
For the following code, I'm just trying to get (keydown) to work.
Here is my:
landingpage.component.html

  <input type="text" autoComplete="off" (keydown)="keyDown($event)" placeholder={{backgroundPlaceholder.info.placeholderText}} [(ngModel)]="keystroke"
    (ngModelChange)="getKey($event)">

      {{list.show}}

landingpage.component.ts
arrowkeyLocation = 0;

 keyDown(event) {
   return this.arrowkeyLocation++;
 }

As-is, nothing is selected when I press the downkey. I'm pretty sure the problem lied within my html [class.active], but I'm not sure how to resolve it.
How can I select li elements via the arrow keys?

A: If you want to only select the list using arrow key, I think you need to change your landingpage.component.ts to something like this:
arrowkeyLocation = 0;

keyDown(event: KeyboardEvent) {
    switch (event.keyCode) {
        case 38: // this is the ascii of arrow up
                 this.arrowkeyLocation--;
                 break;
        case 40: // this is the ascii of arrow down
                 this.arrowkeyLocation++;
                 break;
    }
}

And in your html you need to change [class.active]="i == {{arrowkeyLocation}}" to [class.active]="i == arrowkeyLocation".. No need to use {{ and }} there.

A: I agree with what @samAlvin has to say in his answer and I also recommend using an if condition which checks if we haven't exceeded the li list otherwise the selection would just disappear if user presses the down arrow key and same in case of up arrow key:
if (event.keyCode === 40 && this.selectedLiValue < this.shows.length - 1) {
    // Arrow Down
    this.selectedLiValue++;
} else if (event.keyCode === 38 && this.selectedLiValue > 0) {
    // Arrow Up
    this.selectedLiValue--;
}

A: Thanks all. I have implemented this to take care of scrolling it.
arrowkeyLocation = 0;
  keyDown(event: any) {

    if(event.keyCode=== 13){
     let valueEnterKey =this.serviceDropdown[this.arrowkeyLocation];

     console.log("valueEnterKey",valueEnterKey);
     this.dropDefaultVal1=valueEnterKey;
     this.boolval1 = !this.boolval1;
    }

    var listOfDropDownItemsService = document.getElementsByTagName('ul')[6];

    if (event.keyCode === 40 && this.arrowkeyLocation < this.serviceDropdown.length - 1) {
      // Arrow Down
      this.arrowkeyLocation++;
      listOfDropDownItemsService.scrollTop = listOfDropDownItemsService.scrollTop + 15;
    }
     else if (event.keyCode === 38 && this.arrowkeyLocation > 0) {
      // Arrow Up
      this.arrowkeyLocation--;
      listOfDropDownItemsService.scrollTop = listOfDropDownItemsService.scrollTop - 15;
    }

  }


text:
Q: How can I download e-mails + folders to my hard drive using Mozilla Thunderbird? I need to download e-mails from the current web host's server to my hard drive, so they can be uploaded to the new web host's server!
I have a company and we're switching web hosts.  I do not want to lose any old mail, saved mail, folders, etc. ...
So I've put all 14 e-mail accounts in my Mozilla Thunderbird.
I have searched through add-ons, but I'm unable to figure out:

*

*How to download them

*Where to find them once they're downloaded

*If what I'm downloading can be utilized by the new web hosting company to be uploaded to the new cloud server we're going to be hosted on.

I have searched through articles for Mozilla Thunderbird, but I am unable to determine the proper way to get these on my PC's hard drive.
Any guidance would be greatly appreciated!

A: The original accounts are ideally in IMAP and in order to upload the emails on the new server, you will need them to be IMAP too.

*

*Create the old accounts in Thunderbird.  By default, all emails will be downloaded to the local disk, but check the settings anyway, in Options / Account Settings / Synchronisation and Storage:

*Create the new accounts in Thunderbird.  These will be empty on the new server.

*Select all emails from each of the old accounts, right-click and choose Copy to and navigate to the new accounts Inbox.


text:
Q: How can we get Cascading Lookup Columns in sharepoint 2010? How to get the cascaded Lookup columns in sharepoint 2010,Iam having requirement
like i have two lists(Category List and Sub category list)..For each item in category
list i have 5 different items in sub category list..
So if i select one item(ex:Desktop) in Category list,the next column dropdown has to come
corresponding items of sub category list which relates to item(Desktop) in category list..
Iam using three lists here 1)Category
               2)Sub Category
               3)Ticket
calling category and sub category title columns as lookup columns in Ticket List..
i have searched some sites like http://www.sharepointboris.net/js/spcd/ but didnt find the solution
Could anyone help me achieve this?
Thanks,
Naresh.

A: I got the Solution from http://cascadefilterlookup.codeplex.com

A: Its can also be done in InfoPath, I highly recommend SPservices though.
Examples:

*

*MSDN Blog

*PointBeyond

A: I've used a custom field for this request in SP 2007. I don't know for sure if you can use it in SP 2010.

A: Check out SPServices Jquery library which provides cascading dropdown functionality among many others: http://spservices.codeplex.com/documentation

A: InfoPath is probably the easier solution to implement.

A: If you don't mind using the Metadata, I suggest you the best way to do the Category-Subcategory-Item senario at here.

A: I would like to share the link which would guide you in creating the cascading dropdowns in SharePoint
Cascading or Filtered dropdowns in LookUp Columns
Hope this helps you!

A: This is other custom field SharePoint Cascaded Lookup


text:
Q: I am always getting com.google.zxing.ChecksumException None of the QR code are being decoded . Even the ones from zxing.
Is it also that the QR code is not being read at all ?
package com.pavan.secureqr;

import android.app.Activity;
import android.graphics.PointF;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import com.dlazaro66.qrcodereaderview.QRCodeReaderView;

public class ScanActivity extends Activity implements

QRCodeReaderView.OnQRCodeReadListener {

private QRCodeReaderView decoder;
private TextView myText;
static final String tag="ScanActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.scan_activity);
    decoder = (QRCodeReaderView) findViewById(R.id.qrdecoderview);
    decoder.setOnQRCodeReadListener(this);
    myText= (TextView) findViewById(R.id.decodedText);

}

@Override
public void onQRCodeRead(String s, PointF[] pointFs) {
    myText.setText(s);
}

@Override
public void cameraNotFound() {

}

@Override
public void QRCodeNotFoundOnCamImage() {

}

}
Logcat:
04-18 22:30:06.359  13672-13672/com.pavan.secureqr I/CameraConfiguration﹕ Initial camera parameters: antibanding=auto;antibanding-values=off,60hz,50hz,auto;auto-exposure-lock=false;auto-exposure-lock-supported=true;auto-whitebalance-lock=false;auto-whitebalance-lock-supported=true;effect=none;effect-values=none,mono,negative,solarize,sepia,posterize,whiteboard,blackboard,aqua;exposure-compensation=0;exposure-compensation-step=0.166667;focal-length=3.5;focus-distances=Infinity,Infinity,Infinity;focus-mode=fixed;focus-mode-values=fixed;horizontal-view-angle=54.9;jpeg-quality=95;jpeg-thumbnail-height=384;jpeg-thumbnail-quality=85;jpeg-thumbnail-size-values=512x384,512x288,480x288,256x154,432x288,320x240,176x144,0x0;jpeg-thumbnail-width=512;max-exposure-compensation=12;max-num-detected-faces-hw=5;max-num-detected-faces-sw=5;max-num-focus-areas=0;max-num-metering-areas=1;max-zoom=60;metering-areas=(0,0,0,0,0);min-exposure-compensation=-12;picture-format=jpeg;picture-format-values=jpeg;picture-size=2592x1944;picture-size-values=2592x1944,2592x1456,2048x1536,1920x1080,1600x1200,1440x1080,1280x960,1280x768,1280x720,1024x768,800x600,800x480,720x480,640x480;preferred-preview-size-for-video=960x540;preview-format=yuv420sp;preview-format-values=yuv420sp,yuv420p;preview-fps-range=15000,30000;preview-fps-range-values=(15000,15000),(15000,30000);preview-frame-rate=30;preview-frame-rate-values=15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30;preview-size=1280x720;preview-size-values=1280x720,960x540,864x480,800x480,768x432,720x480,640x480,576x432,480x320,384x288,352x288,320x240,240x160,176x144;scene-mode=auto;scene-mode-values=auto,hdr,auto_hdr;smooth-zoom-supported=true;vertical-view-angle=42.5;video-frame-format=yuv420sp;video-size-values=960x540,864x480,800x480,720x480,640x480,480x320,352x288,320x240,176x144;video-snapshot-supported=true;video-stabilization-supported=false;whitebalance=auto;whitebalance-values=auto,incandescent,fluorescent,daylight,cloudy-daylight;zoom=0;zoom-ratios=100,102,104,107,109,112,114,117,120,123,125,128,131,135,138,141,144,148,151,155,158,162,166,170,174,178,182,186,190,195,200,204,209,214,219,224,229,235,240,246,251,257,263,270,276,282,289,296,303,310,317,324,332,340,348,356,364,373,381,390,400;zoom-supported=true
04-18 22:30:06.359  13672-13672/com.pavan.secureqr I/CameraConfiguration﹕ Supported values: [fixed]
04-18 22:30:06.359  13672-13672/com.pavan.secureqr I/CameraConfiguration﹕ Settable value: null
04-18 22:30:06.366  13672-13672/com.pavan.secureqr D/com.dlazaro66.qrcodereaderview.QRCodeReaderView﹕ surfaceChanged
04-18 22:30:06.491  13672-13672/com.pavan.secureqr I/PlatformSupportManager﹕ Using implementation class com.google.zxing.client.android.common.executor.HoneycombAsyncTaskExecInterface of interface com.google.zxing.client.android.common.executor.AsyncTaskExecInterface for SDK 11
04-18 22:30:06.493  13672-13672/com.pavan.secureqr I/AutoFocusManager﹕ Current focus mode 'fixed'; use auto focus? false
04-18 22:30:06.740  13672-13685/com.pavan.secureqr D/dalvikvm﹕ GC_FOR_ALLOC freed 1673K, 35% free 7173K/11032K, paused 10ms, total 29ms
04-18 22:30:06.982  13672-13684/com.pavan.secureqr D/dalvikvm﹕ GC_FOR_ALLOC freed 1761K, 35% free 7172K/11032K, paused 18ms, total 18ms
04-18 22:30:07.161  13672-14288/com.pavan.secureqr D/dalvikvm﹕ GC_FOR_ALLOC freed 1718K, 35% free 7172K/11032K, paused 14ms, total 14ms
04-18 22:30:07.375  13672-13685/com.pavan.secureqr D/dalvikvm﹕ GC_FOR_ALLOC freed 2290K, 41% free 6600K/11032K, paused 11ms, total 11ms
04-18 22:30:07.562  13672-14283/com.pavan.secureqr D/dalvikvm﹕ GC_FOR_ALLOC freed 1145K, 35% free 7172K/11032K, paused 14ms, total 14ms
04-18 22:30:07.817  13672-14288/com.pavan.secureqr D/dalvikvm﹕ GC_FOR_ALLOC freed 1674K, 35% free 7173K/11032K, paused 41ms, total 41ms
04-18 22:30:07.898  13672-13672/com.pavan.secureqr D/com.dlazaro66.qrcodereaderview.QRCodeReaderView﹕ surfaceDestroyed
04-18 22:30:34.039  13672-13678/com.pavan.secureqr D/dalvikvm﹕ Debugger has detached; object registry had 1 entries
04-18 22:31:01.068  13672-13672/com.pavan.secureqr I/PlatformSupportManager﹕ Using implementation class com.google.zxing.client.android.camera.open.GingerbreadOpenCameraInterface of interface com.google.zxing.client.android.camera.open.OpenCameraInterface for SDK 9
04-18 22:31:01.111  13672-13672/com.pavan.secureqr I/GingerbreadOpenCamera﹕ Opening camera #0
04-18 22:31:01.457  13672-13672/com.pavan.secureqr I/CameraConfiguration﹕ Screen resolution: Point(540, 850)
04-18 22:31:01.458  13672-13672/com.pavan.secureqr I/CameraConfiguration﹕ Supported preview sizes: 1280x720 960x540 864x480 800x480 720x480 768x432 640x480 576x432 480x320 384x288 352x288 320x240 240x160 176x144
04-18 22:31:01.458  13672-13672/com.pavan.secureqr I/CameraConfiguration﹕ Found best approximate preview size: Point(720, 480)
04-18 22:31:01.458  13672-13672/com.pavan.secureqr I/CameraConfiguration﹕ Camera resolution: Point(720, 480)
04-18 22:31:01.463  13672-13672/com.pavan.secureqr I/CameraConfiguration﹕ Initial camera parameters: antibanding=auto;antibanding-values=off,60hz,50hz,auto;auto-exposure-lock=false;auto-exposure-lock-supported=true;auto-whitebalance-lock=false;auto-whitebalance-lock-supported=true;effect=none;effect-values=none,mono,negative,solarize,sepia,posterize,whiteboard,blackboard,aqua;exposure-compensation=0;exposure-compensation-step=0.166667;focal-length=3.5;focus-distances=Infinity,Infinity,Infinity;focus-mode=fixed;focus-mode-values=fixed;horizontal-view-angle=54.9;jpeg-quality=95;jpeg-thumbnail-height=384;jpeg-thumbnail-quality=85;jpeg-thumbnail-size-values=512x384,512x288,480x288,256x154,432x288,320x240,176x144,0x0;jpeg-thumbnail-width=512;max-exposure-compensation=12;max-num-detected-faces-hw=5;max-num-detected-faces-sw=5;max-num-focus-areas=0;max-num-metering-areas=1;max-zoom=60;metering-areas=(0,0,0,0,0);min-exposure-compensation=-12;picture-format=jpeg;picture-format-values=jpeg;picture-size=2592x1944;picture-size-values=2592x1944,2592x1456,2048x1536,1920x1080,1600x1200,1440x1080,1280x960,1280x768,1280x720,1024x768,800x600,800x480,720x480,640x480;preferred-preview-size-for-video=960x540;preview-format=yuv420sp;preview-format-values=yuv420sp,yuv420p;preview-fps-range=15000,30000;preview-fps-range-values=(15000,15000),(15000,30000);preview-frame-rate=30;preview-frame-rate-values=15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30;preview-size=1280x720;preview-size-values=1280x720,960x540,864x480,800x480,768x432,720x480,640x480,576x432,480x320,384x288,352x288,320x240,240x160,176x144;scene-mode=auto;scene-mode-values=auto,hdr,auto_hdr;smooth-zoom-supported=true;vertical-view-angle=42.5;video-frame-format=yuv420sp;video-size-values=960x540,864x480,800x480,720x480,640x480,480x320,352x288,320x240,176x144;video-snapshot-supported=true;video-stabilization-supported=false;whitebalance=auto;whitebalance-values=auto,incandescent,fluorescent,daylight,cloudy-daylight;zoom=0;zoom-ratios=100,102,104,107,109,112,114,117,120,123,125,128,131,135,138,141,144,148,151,155,158,162,166,170,174,178,182,186,190,195,200,204,209,214,219,224,229,235,240,246,251,257,263,270,276,282,289,296,303,310,317,324,332,340,348,356,364,373,381,390,400;zoom-supported=true
04-18 22:31:01.463  13672-13672/com.pavan.secureqr I/CameraConfiguration﹕ Supported values: [fixed]
04-18 22:31:01.463  13672-13672/com.pavan.secureqr I/CameraConfiguration﹕ Settable value: null
04-18 22:31:01.576  13672-13672/com.pavan.secureqr I/PlatformSupportManager﹕ Using implementation class com.google.zxing.client.android.common.executor.HoneycombAsyncTaskExecInterface of interface com.google.zxing.client.android.common.executor.AsyncTaskExecInterface for SDK 11
04-18 22:31:01.578  13672-13672/com.pavan.secureqr I/AutoFocusManager﹕ Current focus mode 'fixed'; use auto focus? false
04-18 22:31:01.578  13672-13672/com.pavan.secureqr D/com.dlazaro66.qrcodereaderview.QRCodeReaderView﹕ surfaceChanged
04-18 22:31:01.798  13672-13672/com.pavan.secureqr I/PlatformSupportManager﹕ Using implementation class com.google.zxing.client.android.common.executor.HoneycombAsyncTaskExecInterface of interface com.google.zxing.client.android.common.executor.AsyncTaskExecInterface for SDK 11
04-18 22:31:01.800  13672-13672/com.pavan.secureqr I/AutoFocusManager﹕ Current focus mode 'fixed'; use auto focus? false
04-18 22:31:02.105  13672-13684/com.pavan.secureqr D/dalvikvm﹕ GC_FOR_ALLOC freed 1843K, 35% free 7238K/11032K, paused 34ms, total 47ms
04-18 22:31:02.298  13672-14288/com.pavan.secureqr D/dalvikvm﹕ GC_FOR_ALLOC freed 1737K, 35% free 7175K/11032K, paused 15ms, total 15ms
04-18 22:31:02.590  13672-13685/com.pavan.secureqr D/dalvikvm﹕ GC_FOR_ALLOC freed 1761K, 35% free 7175K/11032K, paused 35ms, total 35ms
04-18 22:31:02.690  13672-13672/com.pavan.secureqr D/com.dlazaro66.qrcodereaderview.QRCodeReaderView﹕ ChecksumException
04-18 22:31:02.690  13672-13672/com.pavan.secureqr W/System.err﹕ com.google.zxing.ChecksumException
04-18 22:31:02.840  13672-14283/com.pavan.secureqr D/dalvikvm﹕ GC_FOR_ALLOC freed 1680K, 35% free 7175K/11032K, paused 42ms, total 42ms
04-18 22:31:03.157  13672-13672/com.pavan.secureqr D/com.dlazaro66.qrcodereaderview.QRCodeReaderView﹕ ChecksumException
04-18 22:31:03.157  13672-13672/com.pavan.secureqr W/System.err﹕ com.google.zxing.ChecksumException
04-18 22:31:03.212  13672-13684/com.pavan.secureqr D/dalvikvm﹕ GC_FOR_ALLOC freed 1769K, 36% free 7131K/11032K, paused 48ms, total 48ms
04-18 22:31:03.341  13672-13672/com.pavan.secureqr D/com.dlazaro66.qrcodereaderview.QRCodeReaderView﹕ ChecksumException
04-18 22:31:03.341  13672-13672/com.pavan.secureqr W/System.err﹕ com.google.zxing.ChecksumException
04-18 22:31:03.477  13672-13672/com.pavan.secureqr D/com.dlazaro66.qrcodereaderview.QRCodeReaderView﹕ ChecksumException
04-18 22:31:03.477  13672-13672/com.pavan.secureqr W/System.err﹕ com.google.zxing.ChecksumException
04-18 22:31:03.658  13672-14288/com.pavan.secureqr D/dalvikvm﹕ GC_FOR_ALLOC freed 1736K, 35% free 7175K/11032K, paused 24ms, total 24ms
04-18 22:31:03.868  13672-13685/com.pavan.secureqr D/dalvikvm﹕ GC_FOR_ALLOC freed 1718K, 35% free 7175K/11032K, paused 18ms, total 18ms
04-18 22:31:03.958  13672-13672/com.pavan.secureqr D/com.dlazaro66.qrcodereaderview.QRCodeReaderView﹕ ChecksumException
04-18 22:31:03.958  13672-13672/com.pavan.secureqr W/System.err﹕ com.google.zxing.ChecksumException
04-18 22:31:04.031  13672-13672/com.pavan.secureqr D/com.dlazaro66.qrcodereaderview.QRCodeReaderView﹕ ChecksumException
04-18 22:31:04.031  13672-13672/com.pavan.secureqr W/System.err﹕ com.google.zxing.ChecksumException
04-18 22:31:04.062  13672-14283/com.pavan.secureqr D/dalvikvm﹕ GC_FOR_ALLOC freed 1728K, 36% free 7131K/11032K, paused 14ms, total 14ms
04-18 22:31:04.135  13672-13672/com.pavan.secureqr D/com.dlazaro66.qrcodereaderview.QRCodeReaderView﹕ ChecksumException
04-18 22:31:04.135  13672-13672/com.pavan.secureqr W/System.err﹕ com.google.zxing.ChecksumException
04-18 22:31:04.208  13672-13672/com.pavan.secureqr D/com.dlazaro66.qrcodereaderview.QRCodeReaderView﹕ ChecksumException
04-18 22:31:04.209  13672-13672/com.pavan.secureqr W/System.err﹕ com.google.zxing.ChecksumException
04-18 22:31:04.309  13672-13672/com.pavan.secureqr D/com.dlazaro66.qrcodereaderview.QRCodeReaderView﹕ ChecksumException
04-18 22:31:04.309  13672-13672/com.pavan.secureqr W/System.err﹕ com.google.zxing.ChecksumException
04-18 22:31:04.342  13672-13684/com.pavan.secureqr D/dalvikvm﹕ GC_FOR_ALLOC freed 1738K, 36% free 7131K/11032K, paused 26ms, total 26ms

A: No the QR-Code gets read, but doing a quick research shows that the Exception is thrown, because the checksum feature failed.


text:
Q: What search algorithm or a data structure would you suggest? I have a big number of SortedSet<Long> structures:
1, 2, 5, 8, 10, 35, 77, ...
5, 9, 35, 50, 132, ...
2, 4, 8, 15, 17, 23, ...
... hundreds of thousands of such rows...

I need to find a number that goes after, say, 50. In this example (if there are just three sets) it is 77. The number of sets is huge - hundreds of thousands. What algorithm would you suggest?

A: If I understand correctly here is my idea:
Collection<SortedSet<Long>> sets = //...

long minAfter50 = Long.MAX_VALUE;
for (SortedSet<Long> set : sets) {
    final Long first = set.tailSet(51L).first();
    minAfter50 = Math.min(minAfter50, first);
}

Here is the idea:

*

*iterate over all input sets

*crop all values less then or equal 50

*take the first argument of the cropped set (guaranteed to be greater than 50)

*calcualte the smallest value out of those collected in previous step

UPDATE (based on @beerbajay comment): if SortedSet is actually a TreeSet, the following code might perform better. Also I am making sure that there is any value greater than 50 in each and every set:
long minAfter50 = Long.MAX_VALUE;
for (TreeSet<Long> set : sets) {
    final Long higher = set.higher(50L);
    if (higher != null && higher < minAfter50) {
        minAfter50 = higher;
    }
}

A: If that's all the precomputation you allow, then the only thing you can do is call tailSet on each SortedSet and find the minimum.
If you allow some extra data structures, the easiest thing to do is keep track of the union of all the sets and then you just have to call tailSet on that.
I suspect neither is the answer you want.  Perhaps you could better describe the constraints you have?

A: set is implemented as a binary search tree, the largest number always in the last.
you can search number bigger than 50 easier, always get the 1st number bigger than 50 in each set.


text:
Q: Simple: Plot pairs of numbers I'm a beginner. I've read a book about Mathematica and thought, I had learned a lot, but apparently…
I have a list with pairs of numbers like so, assigned to a variable "list":
   list = {{1, 1}, {2, 1}, {3, 2}, {4, 2}, {5, 4}, {6, 2}, {7, 6}}

How can I plot this list, when the first number of each pair is x, the second is y? It could look something like this:

Any help is greatly appreciated. Thank you.

A: Emad kareems solution worked just fine for me:
ListPlot[{{1, 1}, {2, 1}, {3, 2}, {4, 2}, {5, 4}, {6, 2}, {7, 6}}, Filling -> Axis]


text:
Q: how to execute external function in dalekjs .execute( )? i want to execute an external function inside .execute() function of dalekjs.
Is it possible to do that?

A: Depends on what you mean with external.
If you want to execute a function that already exists in your client side JavaScript it must be accessible via the global window object. For example:
In one of my client side scripts I have something like this:
function myAwesomeFn (message) {
  $('body').append('<p>' + message + '</p>');
}

If that function is defined in the global scope (not within some IIFE f.e.), you can trigger it in your execute function like so:
test.execute(function () {
  window.myAwesomeFn('Some message');
});

If you mean "a function that is defined within a Dalek Testsuite" with external, I might must disappoint you, because Daleks testfiles and the contents of the execute function are invoked in different contexts (different JavaScript engines even).
So this does not work:
'My test': function (test) {
   var myFn = function () { // does something };

   test.execute(function () {
     myFn(); // Does not work, 'myFn' is defined in the Node env, this functions runs in the browser env

   })
 }

What does work:
'My test': function (test) {

   test.execute(function () {
     var myFn = function () { // does something };
     myFn(); // Does work, myFn is defined in the correct scope

   })
 }

Hope that answers your question, if not, please provide some more details.
EDIT:
Load the file(s) using node own require
var helper = require('./helper');
module.exports = {
  'My test': function (test) {
     test.execute(helper.magicFn)
   }
 };

In your helper.js, you can do whatever you want,
this would make sense (more or less):
module.exports = {
  magicFn: function () {
     alert('I am a magic function, defined in node, executed in the browser!');
   }
 };

For further strategies on how to keep your testing code DRY ;),
check this repo/file: Dalek DRY Example