text:
Q: lauch c# app from c++ without taskbar button I am looking for a way to launch a c# app from a c++ app without showing a taskbar button for the c# app until I choose to show it.
I have a class that can hide and show a taskbar button, however the taskbar button shows up very briefly when launching the c# app.
Is there a way to launch a c# app without the os creating a taskbar button, while still allowing me to show a taskbar button later on?
Here is the code Im currently using to hide and show a taskbar button.
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

class Program
{
    static void Main()
    {
        var tb = new Taskbar();
        tb.DeleteTab();
        bool hidden = true;

        while (true)
        {
            Console.WriteLine("Press any key to toggle taskbar button");
            Console.ReadKey();
            Console.Clear();

            if (hidden)
                tb.AddTab();
            else
                tb.DeleteTab();

            hidden = !hidden;
        }
    }
}

class Taskbar
{
    public void AddTab()
    {
        GetTaskbarList().AddTab(GetMainWindowHandle());
    }

    public void DeleteTab()
    {
        GetTaskbarList().DeleteTab(GetMainWindowHandle());
    }

    ITaskbarList GetTaskbarList()
    {
        var taskbarList = (ITaskbarList)new CoTaskbarList();
        taskbarList.HrInit();
        return taskbarList;
    }

    IntPtr GetMainWindowHandle()
    {
        return Process.GetCurrentProcess().MainWindowHandle;
    }

    [ComImport]
    [Guid("56fdf344-fd6d-11d0-958a-006097c9a090")]
    class CoTaskbarList
    {
    }

    [ComImport,
    Guid("56fdf342-fd6d-11d0-958a-006097c9a090"),
    InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    interface ITaskbarList
    {
        /// <summary>
        /// Initializes the taskbar list object. This method must be called before any other ITaskbarList methods can be called.
        /// </summary>
        void HrInit();

        /// <summary>
        /// Adds an item to the taskbar.
        /// </summary>
        /// <param name="hWnd">A handle to the window to be added to the taskbar.</param>
        void AddTab([In] IntPtr hWnd);

        /// <summary>
        /// Deletes an item from the taskbar.
        /// </summary>
        /// <param name="hWnd">A handle to the window to be deleted from the taskbar.</param>
        void DeleteTab([In] IntPtr hWnd);

        /// <summary>
        /// Activates an item on the taskbar. The window is not actually activated; the window's item on the taskbar is merely displayed as active.
        /// </summary>
        /// <param name="hWnd">A handle to the window on the taskbar to be displayed as active.</param>
        void ActivateTab([In] IntPtr hWnd);

        /// <summary>
        /// Marks a taskbar item as active but does not visually activate it.
        /// </summary>
        /// <param name="hWnd">A handle to the window to be marked as active.</param>
        void SetActiveAlt([In] IntPtr hWnd);
    }
}

A: Set the ShowInTaskbar (WinForms or WPF) property.
Set it to false initially and the application won't appear.
Set it to true when you want the application to appear in the taskbar.

A: Using:
this.ShowInTaskbar = false;

in your Form's constructor (or setting it in designer, if possible) should ensure that no taskbar button is initially created. I assume that you should still be able to create one when necessary.


text:
Q: transferring arraylist from one class to another I'm trying to move the data from the stations ArrayList in the fileReader class into the another ArrayList in the CTAStops class. Whenever I test this i get a null pointer exception. What would be the correct way to transfer the data over?
Any help at all would really be appreciated! :)
public class FileReader {
    public static ArrayList<CTAStops> stations = new ArrayList<CTAStops>();

    public FileReader(){
        String csvFile = "CTAStops (2).csv";
        File file = new File(csvFile);

        try {
            Scanner inputStream = new Scanner(file);

            inputStream.nextLine();
            inputStream.nextLine();

            while (inputStream.hasNextLine()) {
                String data = inputStream.nextLine();
                String var[] = data.split(",");

                stations.add(new CTAStops(var[0],Double.parseDouble(var[1]),
                                                 Double.parseDouble(var[2]),
                                                 var[3],Boolean.parseBoolean(var[4]),
                                                 Integer.parseInt(var[5]),
                                                 Integer.parseInt(var[6]),
                                                 Integer.parseInt(var[7]),
                                                 Integer.parseInt(var[8]),
                                                 Integer.parseInt(var[9]),
                                                 Integer.parseInt(var[10]),
                                                 Integer.parseInt(var[11]),
                                                 Integer.parseInt(var[12])));
            }
            inputStream.close();

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    public static ArrayList<CTAStops> getList() {
        return stations;
    }
}

import java.util.ArrayList;

public class CTAStops extends GeoLocation {

private String StationName; //instance variables that define a ctaStop
private double Latitude;
private double Longitude;
private String Location;
private boolean WheelChair;
private int RedLine;
private int GreenLine;
private int BlueLine;
private int BrownLine;
private int PurpleLine;
private int PinkLine;
private int OrangeLine;
private int YellowLine;

public static ArrayList<CTAStops> stations = new ArrayList<CTAStops>();

static FileReader read = new FileReader();

public CTAStops(){//default constructor

    StationName = "";
    Latitude = 0;
    Longitude = 0;
    Location = "elevated";
    WheelChair = true;
    RedLine = 0;
    GreenLine = 0;
    BlueLine = 0;
    BrownLine = 0;
    PurpleLine = 0;
    PinkLine = 0;
    OrangeLine = 0;
    YellowLine = 0;
    stations = FileReader.getList();
}
public CTAStops(String StationName, double Latitude, double Longitude, String Location, boolean wheelChair, int RedLine,int GreenLine,int BlueLine, int BrownLine, int PurpleLine, int PinkLine, int OrangeLine, int YellowLine){//nondefault constructor

    this.StationName = StationName;
    this.Latitude = Latitude;
    this.Longitude = Longitude;
    this.Location = Location;
    this.WheelChair = WheelChair;
    this.RedLine = RedLine;
    this.GreenLine = GreenLine;
    this.BlueLine = BlueLine;
    this.BrownLine = BrownLine;
    this.PurpleLine = PurpleLine;
    this.PinkLine = PinkLine;
    this.OrangeLine = OrangeLine;
    this.YellowLine = YellowLine;
}
}

A: Why do you have two main methods in two classes?
I guess CTAStops is your Main class?
What I'd do is have a constructor for FileReader class with filename as parameter and in it have a method returning ArrayList.
Create an instance of FileReader in CTAStops with the input file name(args[0]), then call the method of FileReader and set it equal to any ArrayList.
Also try avoiding FileReader/ FileWriter as class name as it can conflict with the java FileReader and FileWriter classes/constructors.
You should get an idea from this:
public class FileProcessor {
private ArrayList<CTAStops> stations = new ArrayList<CTAStops>();
private String filename;

public FileProcessor(String filenameIn) {
    filename = filenameIn;
}

public ArrayList<CTAStops> getStations() throws IOException {
    String csvFile = filename;
    File file = new File(csvFile);

    try {
        BufferedReader br = new BufferedReader(new FileReader(file));
        String line;
        while ((line = br.readLine()) != null) {
            String var[] = line.split(",");

            stations.add(new CTAStops(var[0], Double.parseDouble(var[1]),
                    Double.parseDouble(var[2]),
                    var[3], Boolean.parseBoolean(var[4]),
                    Integer.parseInt(var[5]),
                    Integer.parseInt(var[6]),
                    Integer.parseInt(var[7]),
                    Integer.parseInt(var[8]),
                    Integer.parseInt(var[9]),
                    Integer.parseInt(var[10]),
                    Integer.parseInt(var[11]),
                    Integer.parseInt(var[12])));
        }
        br.close();

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    return stations;
}

public ArrayList<CTAStops> getList() {
    return stations;
   }
}

CTAStops:
import java.io.IOException;
import java.util.ArrayList;

public class CTAStops {
private String StationName; //instance variables that define a     ctaStop
private double Latitude;
private double Longitude;
private String Location;
private boolean WheelChair;
private int RedLine;
private int GreenLine;
private int BlueLine;
private int BrownLine;
private int PurpleLine;
private int PinkLine;
private int OrangeLine;
private int YellowLine;

public static ArrayList<CTAStops> stations = new ArrayList<CTAStops>();

public CTAStops(){//default constructor

    StationName = "";
    Latitude = 0;
    Longitude = 0;
    Location = "elevated";
    WheelChair = true;
    RedLine = 0;
    GreenLine = 0;
    BlueLine = 0;
    BrownLine = 0;
    PurpleLine = 0;
    PinkLine = 0;
    OrangeLine = 0;
    YellowLine = 0;
}
public CTAStops(String StationName, double Latitude, double Longitude, String Location, boolean wheelChair, int RedLine,int GreenLine,int BlueLine, int BrownLine, int PurpleLine, int PinkLine, int OrangeLine, int YellowLine){//nondefault constructor

    this.StationName = StationName;
    this.Latitude = Latitude;
    this.Longitude = Longitude;
    this.Location = Location;
    this.WheelChair = WheelChair;
    this.RedLine = RedLine;
    this.GreenLine = GreenLine;
    this.BlueLine = BlueLine;
    this.BrownLine = BrownLine;
    this.PurpleLine = PurpleLine;
    this.PinkLine = PinkLine;
    this.OrangeLine = OrangeLine;
    this.YellowLine = YellowLine;
}

public static void main(String[] args) throws IOException {
    FileProcessor reader = new FileProcessor("inpp.txt");
    stations = reader.getStations();
    //Testing
    CTAStops a = new CTAStops();
    a=stations.get(0);
    System.out.println(a.StationName +" "+ a.Latitude);

   }
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Flutter REST Calls Time Out I am making api calls via flutter to my server. I have checked my android manifest settings and I have placed
 <uses-permission android:name="android.permission.INTERNET"/>

But, the api calls time out. Here is my call:
Future driverLogin(userdetails) async {
  var url = 'http://$_server/api/token/';

  print(userdetails.values);

  await http.post(url, body: json.encode(userdetails), headers: {
    "Content-Type": "application/json"
  }).then((http.Response response) {
    print(response.body);
    final Map<String, dynamic> responseData = json.decode(response.body);

    Token tkn = Token.fromJSON(responseData);

    _accessTkn = tkn.access;
    _refreshTkn = tkn.refresh;
    print('Refreshingly refreshed ${tkn.refresh}');

    if (response.statusCode == 200) {
      addToken(_accessTkn);
      addRefresh(_refreshTkn);

      print(responseData);
      // tokenType = 'email';

      print('Signed In');
      // preformLogin();
    } else {
      // popupSwitch(2);
      print('Error Could not sign in');
    }
  });
  return _accessTkn;
}

When I run it I get this error:

Bad state: Insecure HTTP is not allowed by platform:

A: make sure to import like this.
import 'package:http/http.dart' as http;

and make your url like this.
var url = 'https://$_server/api/token/';

Also check this links maybe will help you
https://flutter.dev/docs/release/breaking-changes/network-policy-ios-android
https://medium.com/flutter-community/solving-the-new-https-requirements-in-flutter-7abe240fbf23


text:
Q: When opening Word from Excel, Cannot find path specified I'm opening word from excel in my macro using the following code:
Dim wdApp As Word.Application

Set wdApp = CreateObject("Word.Application")

It works on all of the computers in our office, except for one.  I'm getting the error:
Run-time error
The system cannot find the path specified
Does anyone have any ideas?  I have uninstalled all forms of office from the computer and reinstalled it.  I've verified that word is in the correct location, or at least the same location it is on all other computers in the office, and I've successfully run word using shell() on the problematic computer.

A: I figured it out. There was something wrong with the profile I was using. It was showing 2 options for Word, along with all of the office apps.  I was unable to get rid of the 2nd option, so I ended up recreating the profile, and now it works.


text:
Q: how to create webview content as pdf file ios sdk how to create UIWebView Content as pdf file..?
i followed this link but this one not creating the entire webview content(still have some data on webview when i scroll) it is only creating a pdf what the screen is showing..
How to Convert UIView to PDF within iOS?
any help

A: Use UIPrintPageRenderer from UIWebView Follow below steps :
Add Category of UIPrintPageRenderer for getting PDF Data
@interface UIPrintPageRenderer (PDF)
- (NSData*) printToPDF;
@end

@implementation UIPrintPageRenderer (PDF)
- (NSData*) printToPDF
{
  NSMutableData *pdfData = [NSMutableData data];
  UIGraphicsBeginPDFContextToData( pdfData, self.paperRect, nil );
  [self prepareForDrawingPages: NSMakeRange(0, self.numberOfPages)];
  CGRect bounds = UIGraphicsGetPDFContextBounds();
  for ( int i = 0 ; i < self.numberOfPages ; i++ )
  {
    UIGraphicsBeginPDFPage();
    [self drawPageAtIndex: i inRect: bounds];
  }
  UIGraphicsEndPDFContext();
  return pdfData;
}
@end

Add these define for A4 size
#define kPaperSizeA4 CGSizeMake(595.2,841.8)

Now in UIWebView's webViewDidFinishLoad delegate use UIPrintPageRenderer property of UIWebView.
- (void)webViewDidFinishLoad:(UIWebView *)awebView
{
  if (awebView.isLoading)
    return;

  UIPrintPageRenderer *render = [[UIPrintPageRenderer alloc] init];
  [render addPrintFormatter:awebView.viewPrintFormatter startingAtPageAtIndex:0];
  //increase these values according to your requirement
  float topPadding = 10.0f;
  float bottomPadding = 10.0f;
  float leftPadding = 10.0f;
  float rightPadding = 10.0f;
  CGRect printableRect = CGRectMake(leftPadding,
                                  topPadding,
                                  kPaperSizeA4.width-leftPadding-rightPadding,
                                  kPaperSizeA4.height-topPadding-bottomPadding);
  CGRect paperRect = CGRectMake(0, 0, kPaperSizeA4.width, kPaperSizeA4.height);
  [render setValue:[NSValue valueWithCGRect:paperRect] forKey:@"paperRect"];
  [render setValue:[NSValue valueWithCGRect:printableRect] forKey:@"printableRect"];
  NSData *pdfData = [render printToPDF];
  if (pdfData) {
    [pdfData writeToFile:[NSString stringWithFormat:@"%@/tmp.pdf",NSTemporaryDirectory()] atomically: YES];
  }
  else
  {
    NSLog(@"PDF couldnot be created");
  }
}

A: You're right, you need a Webview.
If you have the .pdf file in the bundle, simply do this :
@implementation{
     UIWebView *documentWebView;
}

- (void)viewDidLoad{     //Or any other method that you want to create the webview with.

    //Getting the full screen size
    UIWindow* currentWindow = [UIApplication sharedApplication].keyWindow;
    CGRect fullScreenRect = currentWindow.bounds;

    //Getting the pdf from the bundle ; change filepath with URL if its from the internet
    filePath = [[NSBundle mainBundle] pathForResource:@"YourPDFFileName" ofType:@"pdf"];
    NSURL *fileURL = [NSURL fileURLWithPath:filePath];
    NSURLRequest *request = [NSURLRequest requestWithURL:fileURL];

    //Creating the view programatically, because I'm like that.
    documentWebView = [[UIWebView alloc] initWithFrame:CGRectMake(fullScreenRect.origin.x, fullScreenRect.origin.y, fullScreenRect.size.width, fullScreenRect.size.height)];
    documentWebView.scalesPageToFit = YES;

    //Setting a back button to dismiss the view.
    UIButton *backButton = [[UIButton alloc]initWithFrame:CGRectMake(fullScreenRect.size.width-115, 10, 100, 30)];
    backButton.backgroundColor = [UIColor grayColor];
    backButton.alpha = 0.8;
    [backButton setTitle:@"Back" forState:UIControlStateNormal];

    //Linking the action & the button
    [backButton addTarget:self action:@selector(closeWebView:) forControlEvents:UIControlEventTouchUpInside];

    //Loading the pdf into the actual view
    [documentWebView loadRequest:request];

    //Adding the views to the main view
    [currentWindow addSubview:documentWebView];
    [documentWebView addSubview:backButton];
}

//Dismissing the view
- (IBAction)closeWebView:(id)sender{
    [documentWebView removeFromSuperview];
    [documentWebView release];

}


text:
Q: Trial version sonar PLSQL Plugin I am new to sonar PL/SQL plug in .
I would like to use PL/SQL plug in from sonar for analysis of my pLSQL code base.
I am working on a POC. So i need the trial version of the same.
But using the below website , i am not able to get a trial key before installing the free software.
http://www.sonarsource.com/products/plugins/languages/plsql/
Can anybody help me , if he/she has worked on a trial version of sonar plsql plugin.
Thanks,
Sandip

A: As this is explained on the page, you have to fill a dedicated form to ask for a trial key.
Then SonarSource will contact you and will ask you for some information about your installation, which implies that you already have installed Sonar on a server.


text:
Q: Bind TimePicker & DatePicker - MVVMCross (Mono For Android) How to bind a Time - & /DatePicker with MVVMCross in Mono For Android?
  <TimePicker
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

  <DatePicker
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

And what are the types of the Properties behind? For Date, probably DateTime and for the TimePicker? Or do we have here a Property foreach Number, for Example for Date: Year (INT), Month (INT) and Day (INT) = 3 Properties?
Stuck at this one and didn't find any examples..
Help appreciated

A: The DatePicker API from Android is pretty disgusting...
However, binding it should be pretty easy :)
What I would do is to add a custom control and a custom binding.

For some help on Custom Droid controls, see

*

*How to create view's actions listener for MvxItemTemplate

*take a look at http://github.com/CheeseBaron/ repo - he does loads of great custom controls

For some other questions about Custom Bindings, see

*

*Custom Favorites Button Binding - MVVMCross Bindings in Android

*Custom binding for text color - In MvvmCross how do I do custom bind properties

*Two way bindings for integers - MvvmCross Monotouch C# - Binding Int Property - Mode: TwoWay

*Custom binding for a Touch event - mvvmcross touch command binding in android
and other links from http://slodge.blogspot.co.uk/p/mvvmcross-quicklist.html

The Android DatePicker API was clearly written by Kermit during some downtime, so for the DatePicker, I would probably suggest is that you implement an EmiDatePicker that inherits from DatePicker and tidies up the API.
This can provide a single property and a single event:
   private bool _initialised;

   public DateTime Value
   {
      get
      {
         return new DateTime(Year, Month.ToCLRMonthNumber(), DayOfMonth);
      }
      set
      {
         if (_initialised)
         {
             UpdateDate(value.Year, value.Month.ToJavaMonthNumber(), value.DayOfMonth);
         }
         else
         {
             _initialised = true;
             Init(value.Year, value.Month.ToJavaMonthNumber(), value.DayOfMonth, new EmiListener(this));
         }
      }
   }

   public event EventHandler ValueChanged;

where:

*

*ToJavaMonthNumber, ToCLRMonthNumber are workarounds for +1, -1 fixes - see MonthDisplayHelper.NumberOfDaysInMonth returning incorrect value in MonoDroid

*EmiListener is a simple implementation of IOnDateChangeListener to fire ValueChanged - something like:
public class EmiListener : Java.Lang.Object, DatePicker.IOnDateChangedListener
{
    private EmiDatePicker _datePicker;

    public EmiListener(EmiDatePicker datePicker)
    {
        _datePicker = datePicker;
    }

    public void OnDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth)
    {
        _datePicker.InternalSetValueAndRaiseChanged(new DateTime(year, monthOfYear.ToCLRMonth(), dayOfMonth));
    }
}

With this done... then the next code step would be to add a binding - this would be simple:
public class EmiDatePickerValueTargetBinding : MvxPropertyInfoTargetBinding<EmiDatePicker>
{
    public EmiDatePickerValueTargetBinding(object target, PropertyInfo targetPropertyInfo)
        : base(target, targetPropertyInfo)
    {
        var datePicker = View;
        if (datePicker == null)
        {
            MvxBindingTrace.Trace(MvxTraceLevel.Error, "Error - datePicker is null in EmiDatePickerValueTargetBinding");
        }
        else
        {
            datePicker.ValueChanged += DatePickerOnValueChanged;
        }
    }

    public override MvxBindingMode DefaultMode
    {
        get { return MvxBindingMode.TwoWay; }
    }

    private void DatePickerOnValueChanged(object sender, EventArgs args)
    {
        FireValueChanged(View.Value);
    }

    protected override void Dispose(bool isDisposing)
    {
        base.Dispose(isDisposing);
        if (isDisposing)
        {
            var datePicker = View;
            if (datePicker != null)
            {
                datePicker.ValueChanged -= DatePickerOnValueChanged;
            }
        }
    }
}

And to register this binding, just add it in your app's setup class:
    protected override void FillTargetFactories(Cirrious.MvvmCross.Binding.Interfaces.Bindings.Target.Construction.IMvxTargetBindingFactoryRegistry registry)
    {
        registry.RegisterFactory(new MvxSimplePropertyInfoTargetBindingFactory(
                                     typeof (EmiDatePickerValueTargetBinding), typeof (EmiDatePicker), "Value"));

        base.FillTargetFactories(registry);
    }

At this point, you can finally just use an EmiDatePicker in your XML - although to save on typing I'd recommend using an XML abbreviation - http://slodge.blogspot.co.uk/2013/02/abbreviated-namespaces-for-your-custom.html

To do TimePicker... same again, but I'll leave that to you...

There will be typos in the above code - please do edit it to correct it.
If this code works... and since it is a lot of 'mechanical code', I would love to see it open-sourced (maybe even pushed back to MvvmCross)


text:
Q: How do I print a shuffled order of strings that never repeat? ARDUINO I'm trying to make a scramble generator for the rubik's cube, every letter corresponds to a move on the cube, but I don't want that two moves get printed next to each other, for example " R R U U2 L' " because that would make quite inefficient that scramble. I'll paste part of the code down below:
char a0[] = "R ";
char a1[] = "L' ";
char a2[] = "B' ";
char a3[] = "D2 ";
char a4[] = "F ";
char a5[] = "U2 ";
int moveA;

for (int i=0; i < 6; i++)
{
  moveA = random(0,5);
  if (moveA == 0)
    Serial.print(a0);
  else if (moveA == 1)
    Serial.print(a1);
  else if (moveA == 2)
    Serial.print(a2);
  else if (moveA == 3)
    Serial.print(a3);
  else if (moveA == 4)
    Serial.print(a4);
  else if (moveA == 5)
    Serial.print(a5);
  delay(200);

The output is usually something like
B' F D2 D2 R B'
F2 D' D' F2 R2 R2

A: You can put the moves in an array and then shuffle the array:
const char *moves[] = {"R ", "L' ", "B' ", "D2 ", "F ", "U2 "};
const int num_moves = sizeof(moves) / sizeof(moves[0]);

// Shuffle
for (int i = num_moves - 1; i > 0; i--)
{
    // Random index 0 ≤ j ≤ i
    int j = random(0, i + 1);
    // Swap
    const char *tmp = moves[i];
    moves[i] = moves[j];
    moves[j] = tmp;
}
for (int i = 0; i < num_moves; i++)
{
  Serial.print(moves[i]);
  delay(200);
}

See: Fisher–Yates shuffle


text:
Q: Playing video using MediaPlayer class I am trying to make use of MediaPlayer class for playing a video file. The problem is video is not getting displayed at all though I can hear the sound in the video playing.
Following is the code of activity
public class MainActivity extends Activity implements OnClickListener {

private SurfaceView surfaceView;
private Button btnPlay;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    init();
    addListener();

}

private void init() {
    // TODO Auto-generated method stub
    surfaceView = (SurfaceView) findViewById(R.id.surfaceView1);
    btnPlay = (Button) findViewById(R.id.btnPlay);
}

private void addListener() {
    // TODO Auto-generated method stub

    btnPlay.setOnClickListener(this);
}

MediaPlayer mediaPlayer = null;

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    switch (v.getId()) {
    case R.id.btnPlay:
        try{
        if (mediaPlayer != null) {
            mediaPlayer.reset();
            mediaPlayer.release();
        }else{
        getWindow().setFormat(PixelFormat.UNKNOWN);
        MediaPlayer mediaPlayer = MediaPlayer.create(this, R.raw.wildlife);
        SurfaceHolder surfaceHolder = surfaceView.getHolder();

        surfaceHolder.setFixedSize(176, 144);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        mediaPlayer.setDisplay(surfaceHolder);
        mediaPlayer.start();}
        }catch (Exception e) {
            Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
        }
        break;

    default:
        break;
    }
  }
   }

Following is the code of layout xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<SurfaceView
    android:id="@+id/surfaceView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true" />

<Button
    android:id="@+id/btnPlay"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/surfaceView1"
    android:layout_alignTop="@+id/surfaceView1"
    android:text="@string/play" />

</RelativeLayout>

please tell me what needs to be done?
Thanks in advance.

A: set surface View height and width to fill parent in xml file.
  <SurfaceView
android:id="@+id/surfaceView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />

A: Setting your SurfaceView layout to wrap_content will not size a video to play at the proper aspect ratio.
You can refer to this answer link
https://stackoverflow.com/a/6283676/1441666
And also this blog Play media on surfaceview using android.media.MediaPlayer

A: Well, I don't know if you need an specific situation, but have you already tried FullscreenVideoView?
It tries to abstracts all those SurfaceView problems and you can focus only in UI buttons. As It's open, you can subclass FullscreenVideoView and customize as you need.

A: You can override the onSizeChanged() function of the SurfaceView class to get and set the size of the view.
protected void onSizeChanged (int w, int h, int oldw, int oldh)

When ever the screen size has changed, this class is called.
As a second alternative, you may be able to set the size by setting the layout parameters (unsure if this works with ScrollView):
@Override
public void surfaceCreated(SurfaceHolder holder) {
    android.view.ViewGroup.LayoutParams lp = this.getLayoutParams();
    lp.width = 1000; // required width
    lp.height = 1000; // required height
    this.setLayoutParams(lp);
}


text:
Q: Override aero snap case by case? It there a way to disable the snapping feature of Aero for a single operation?
For example, sometimes I want to move a window to the top of the screen, but Windows maximizes it. Or extend a window to the top of the screen, but want its bottom to stays as is (Windows will also extend its bottom to the bottom of the screen).
Something like holding SHIFT while dragging the window (or its edge when resizing) to temporarily disable snap would be nice.

A: It seems to be prevented if you hold down the Alt key. At least in my limited testing. Have not found it in print anywhere, however.


text:
Q: Interval intersection I wrote a class that checks whether two integer intevals overlap.
However I don't like this solution to much. I think that it's possible to do it in a better and simpler way.
public class IntegerInterval implements Interval {
private Integer start;
private Integer end;

public IntegerInterval(Integer start, Integer end) {
    this.start = start;
    this.end = end;
}

public Integer getStart() {
    return start;
}

public Integer getEnd() {
    return end;
}

public boolean isOverlapping(IntegerInterval other) {
    if (other != null) {
        return isInInterval(start, other) || isInInterval(end, other)
                || isInInterval(other.start, this) || isInInterval(other.end, this);
    }
    return false;
}

public boolean isInInterval(Integer number, IntegerInterval interval) {
    if (number != null && interval != null) {
        if(interval.getStart() == null && interval.getEnd() != null) {
            return number.intValue() <= interval.getEnd().intValue();
        }
        if(interval.getStart() != null && interval.getEnd() == null) {
            return number.intValue() >= interval.getStart().intValue();
        }
        if(interval.getStart() == null && interval.getEnd() == null) {
            return true;
        }
        return interval.getStart() <= number && number <= interval.getEnd();
    }
    else if(number == null && interval != null) {
        return interval.getStart() == null && interval.getEnd() == null;
    }
    return false;
}

}

A: The following code should be simpler:
public boolean isOverlapping(IntegerInterval other) {
    if (other == null) return false; // for readability's sake, this condition is pulled out

    // overlap happens ONLY when this's end is on the right of other's start
    // AND this's start is on the left of other's end.
    return (((this.end == null) || (other.start == null) || (this.end.intValue() >= other.start.intValue())) &&
        ((this.start == null) || (other.end == null) || (this.start.intValue() <= other.end.intValue())));
}

UPDATE If compare by Date as @Adam actually asked, the code would be:
private static boolean dateRangesAreOverlaping(Date start1, Date end1,
                                               Date start2, Date end2) {
return (((end1 == null) || (start2 == null) || end1.after(start2)) &&
         ((start1 == null) || (end2 == null) || start1.before(end2)));

}

A: You should wrap start and end in a specific Comparable class that is able to encapsulate null. This way you only need to invoke compareTo in isInInterval and don't need to bother with null.
That class could also explicitly represent positive and negative infinity.
EDIT:
If you add a type parameter <T extends Comparable<T>> to the class declaration and declare the types of start and end type as Comparable<T> then you can use any type that implements Comparable with your Interval, not only Integer.

A: Assuming start < end. There should be 3 the checks for position of start relative to other: left, middle and right (right is for completeness as there is no intersection possible). So here are 2 remaining checks:
 (start <= other.start && end >= other.start) ||
 (start >= other.start && start <= other.end)
 // start > other.end means no intersection as end > start > other.end

If you do checks for location of start as if than second chech can be just (start <= other.end):
 if (start <= other.start) return end >= other.start;
 else if (start <= other.end) return true;
 else return false;

Adjust "=" portions for your needs and add you null checks appropriately (i.e. use SpaceTrucker answer to make comaprison with null hidden inside class).


text:
Q: Automatic substitution of fractions I have several equations with many variables, and here and there I would like to do a variable substitution. For example, in the equation:
a (b + 42 c / d)

I might want to remap variables a * b --> p and a * c / d --> q in order to get:
p + 42 q

Can Mathematica do this? I tried to play with the With[] and Rule[] function and the like, but that doesn't seem to produce anything. I can imagine that Mathematica is not capable of doing such a thing, but I thought it would be worth asking.
And the pro question:
And then very much related to this: is there a way to use With[] not to set a single variable but to set variable relations, e.g. the sum or product of two variables. So that this:
With[{a * b = 5},  a (b + 42 c / d)] (* This doesn't work*)

would reduce to:
5 + 42 a * c / d

A: rules = {a b -> p, a c / d -> q}
Expand[a (b + 42 c/d)] /. rules
(*p + 42  q*)


text:
Q: similar functionality to SQL Server's EXCEPT operand in MySQL? Is there an operand/function/command in MySQL similar to the EXCEPT operand in SQL Server?
EXCEPT returns any distinct values from the left query that are not also found on the right query.
This statement should give me the distinct values.
SELECT * FROM table1
EXCEPT
SELECT * FROM table2;

How can this be achieved in MySQL?

A: The best you could do is use a NOT EXISTS. Something like:
SELECT DISTINCT *
    FROM table1
    WHERE NOT EXISTS(SELECT NULL
                         FROM table2
                         WHERE table1.x = table2.x)


text:
Q: The Chain rule - prove identity let $z(x,y)=\frac{\ln x}{y^{2}}f\left(\frac{e^{-y}}{x}\right)$  for some differentiable  $f(t)$
prove:
$$(xy\ln x)\cdot\frac{\partial z}{\partial x}-(y \ln x)\cdot\frac{\partial z}{\partial y}=(2\ln x+y)\cdot z$$
my try:
my idea was to use the Chain rule
let $u=\frac{lnx}{y^{2}},v=\frac{e^{-y}}{x}$ the composition is:
$$z=uf\left(v\right)\longleftarrow(u,v)=(\frac{\ln x}{y^{2}},\frac{e^{-y}}{x})\longleftarrow(x,y)$$
and by the Chain rule:
$$
\begin{pmatrix}\frac{\partial z}{\partial x} & \frac{\partial z}{\partial y}\end{pmatrix}=\begin{pmatrix}\frac{\partial z}{\partial u} & \frac{\partial z}{\partial v}\end{pmatrix}\begin{pmatrix}\frac{\partial u}{\partial x} & \frac{\partial u}{\partial y}\\
\frac{\partial v}{\partial x} & \frac{\partial v}{\partial y}
\end{pmatrix}$$
but I don't know how to continue because $\frac{\partial z}{\partial v}$ depends on the function $f$

A: Since $z(x,y)=\frac{\ln x}{y^2}f\left(\frac{e^{-y}}x\right)$, you have$$\frac{\partial z}{\partial x}=\frac1{xy^2}f\left(\frac{e^{-y}}x\right)-\frac{e^{-y}\ln x}{x^2y^2}f'\left(\frac{e^{-y}}x\right)$$and$$\frac{\partial z}{\partial y}=-\frac{2\ln x}{y^3}f\left(\frac{e^{-y}}x\right)-\frac{e^{-y}\ln x}{xy^2}f'\left(\frac{e^{-y}}x\right).$$Therefore,$$xy\ln(x)\frac{\partial z}{\partial x}=\frac{\ln x}yf\left(\frac{e^{-y}}x\right)-\frac{e^{-y}\ln^2x}{xy}f'\left(\frac{e^{-y}}x\right)$$and$$y\ln(x)\frac{\partial z}{\partial y}=-\frac{2\ln^2x}{y^2}f\left(\frac{e^{-y}}x\right)-\frac{e^{-y}\ln^2x}{xy}f'\left(\frac{e^{-y}}x\right).$$So\begin{align}xy\ln(x)\frac{\partial z}{\partial x}-y\ln(x)\frac{\partial z}{\partial y}&=\left(\frac{\ln x}y+\frac{2\ln^2x}{y^2}\right)f\left(\frac{e^{-y}}x\right)\\&=\frac{y\ln(x)+2\ln^2(x)}{y^2}f\left(\frac{e^{-y}}x\right)\\&=(y+2\ln x)z(x,y).\end{align}

A: The final result will depend on $f$ (and $f'$). For instance,
$$
\frac{\partial z}{\partial x} = \frac{1}{y^2}\left[\frac 1x f\left(\frac{e^{-y}}{x}\right) + \ln x \cdot \left(-\frac{e^{-y}}{x^2}\right)\cdot f'\left(\frac{e^{-y}}{x}\right) \right].
$$

In a simpler case, assuming enough regularity and $g: \mathbb{R}^2 \to \mathbb{R}$, $f: \mathbb{R} \to \mathbb{R}$
$$
\frac{\partial}{\partial x} f(g(x,y)) = \frac{\partial g}{\partial x} f'(g(x,y))
$$
$$
\frac{\partial}{\partial y} f(g(x,y)) = \frac{\partial g}{\partial y} f'(g(x,y))
$$


text:
Q: How to pass data to an exact sibling component? I have three sibling components which are populated using the same component as follows.
 <div *ngIf="unitLevel && tribeLevel && squadLevel">
      <at-unit-search [level]="unitLevel"></at-unit-search>
      <at-unit-search [level]="tribeLevel"></at-unit-search>
      <at-unit-search [level]="squadLevel"></at-unit-search>
 </div>

I need to pass some data from first sibling to third sibling, but not to second sibling.I used a service for this. But it sends data to all the three components.
Unit search component's typescript
export class UnitSearchComponent implements OnInit {
  operationalUnits: OperationalUnitLightWeight[];
  previousTimeAllSelected: boolean;
  @ViewChild('allSelected', { static: false }) private allSelected: MatOption;
  @Input() level: any;
  unitForm = new FormGroup({ unitControl: new FormControl('') });

  childUnits : any[];

  constructor(private commonServerService: CommonServerService,private sendUnitService: UnitService ) {
    this.childUnits=[];
  }

  ngOnInit() {

    this.commonServerService.findOperationalUnitsByLevelId(this.level.id).subscribe(operationalUnits => {
      {
        this.operationalUnits = operationalUnits;
        this.operationalUnits.sort((a , b) => a.name.localeCompare(b.name));
      }
    });

    this.sendUnitService.getArray().subscribe(units => {
     this.operationalUnits = units
    });

  }

  optionChange() {
    this.unitForm.controls.unitControl.value.forEach(id => {
      {
        if (id === 0) {
          this.previousTimeAllSelected = true;
        }
      }
    });
    let selectedUnitIds = this.toggleAllSelection();
    this.getChildUnits(selectedUnitIds);
  }

   getChildUnits(selectedUnitIds: any[]) {
    let children=  this.loadChildUnits(selectedUnitIds);
    this.sendUnitService.sendArray(children);
  }

This is happening because all three components are generated from same base component. Since every component has getArray() method which is called inside ngOnInit(), when data is sent from a particular component, all the three components are receiving that data.
Is there any way to uniquely send data to only the needed component?
Thanks in advance.

A: Hey you can define a global variables in a globle service for this,
     //assuming that senUnitService is a global service.

     this.sendUnitService.unitLevel = unitLevel;
     this.sendUnitService.tribeLevel= tribeLevel;
     this.sendUnitService.squadLevel= squadLevel;

     //and if then in the sibling component

     this.unitLevel = this.sendUnitService.unitLevel;
     this.tribeLevel = this.sendUnitService.tribeLevel;
     this.squadLevel = this.sendUnitService.squadLevel;

A: Hi and welcome to StackOverflow.
There're different possible solution but they depends on your needs.
If the the third child is "always" the only one interested to the notification, I'g to pass an Input.
<div *ngIf="unitLevel && tribeLevel && squadLevel">
      <at-unit-search [level]="unitLevel"></at-unit-search>
      <at-unit-search [level]="tribeLevel"></at-unit-search>
      <at-unit-search [level]="squadLevel" handleNotification="true"></at-unit-search>
</div>

and the in ngOnInit
if(this.handleNotification) {
    this.sendUnitService.getArray().subscribe(units => {
     this.operationalUnits = units
    });
}

if instead there's a way to filter the data emitted by sendUnitService, you could use
    this.sendUnitService.getArray().pipe(
       filter(x => .....),
       ....
     ).subscribe(units => {
       this.operationalUnits = units
     });

If both approach do not fit your needs I'd go to add some login in the service in order to allow component's instances to "register" to specific notifications.
PS. would be nice to have a minimal running example (I suggest to use StackBlitz)


text:
Q: Java array values being overridden I am just getting started with OOP, and I am trying to create a program that creates an array to store three different types of information, a name, double and an Int.
For some reason, when I run the program and enter the information, it is not stored properly. If I enter, for example, "James", 22.5, 4 on iteration 1, then "John", 23.66, 8 on iteration 2, then print the array, john, 23.66 and 8 prints out twice. I want each iteration of i in my array to store a different set of values, in essence, but I can't seem to figure out why that is not working.
*EDIT TO REFLECT ANSWER
for(int i=0; i<boats.length; i++) {
    System.out.printf("Name: " + boats[i].getName(name) + "  " +
                       "Age: " + boats[i].getLength(length) + "  " +
                       "Length: " + boats[i].getRating(rating) + "\n\n");
}
in.close();

** Code for class
Public Class file
    public String getName(String name) {
        return name;
    }

    public double getLength(double length) {
        return length;
    }

    public int getRating(int rating) {
        return rating;
    }

A: Your getters are returning the parameter you are passing in, not the value stored by the setter.
The values in the variables you are passing as the parameters are the last values you input, so you will always print the last values you input.
Remove the parameter from the getter.
public String getName() {
    return name;
}

And invoke like
boats[i].getName()


text:
Q: How get ctrl + space to autocomplete in eclipse "System.out.print " does not autocomplete when I press ctrl + space. It shows it in the box and I have to click it for it to populate. I am using a Mac and coding in eclipse. I searched the keyboard preferences but no luck.

A: It works by default, i just type sysout and then hit Ctrl+Space, and it auto-completes System.out.println().
I think you should check once, go to Window->Preferences->General->Keys, and scroll down till you find the Content Assist, like in the image.

If still there's a problem and you are unable to get the auto-complete for sysout, then go to Window->Preferences->Java->Editor->Content Assist . From there , you can configure the shortcuts.
For reference, you can check this


text:
Q: PDE for a damped oscillator I'm studying a PDE that describes a damped oscillator, given by:
$$u_t + uu_x = -\gamma u $$
with initial conditions $u(x,0)=f(x)$. I derived the characteristics as:
$$\frac{dx}{dt} = u$$ and $$\frac{du}{dt} = -\gamma u$$
so that $x = ut+c_1$ and $u = c_2\exp(-\gamma t)$.
I'm nut sure how to proceed since the textbook only quotes the solution as
$$ u = f(\zeta)\exp(-\gamma t)$$
and
$$x = \frac{f(\zeta)}{\gamma}( 1- \exp(-\gamma t))+\zeta$$

A: $$u_t + uu_x = -\gamma u $$
Charpit-Lagrange characteristic ODEs :
$$\frac{dt}{1}=\frac{dx}{u}=\frac{du}{-\gamma u}$$
A first characteristic equation comes from solving $\frac{dx}{u}=\frac{du}{-\gamma u}$ :
$$u+\gamma x=c_1$$
A second characteristic equation comes from solving $\frac{dt}{1}=\frac{dx}{u}=\frac{dx}{c_1-\gamma x}$ :
$$\gamma x+e^{-\gamma t}=c_2$$
The general solution of the PDE on implicit form $c_1=F(c_2)$ is :
$$\boxed{u=\gamma x+F(\gamma x+e^{-\gamma t})}$$
$F$ is an arbitrary function (to be determined according to the initial condition).
Condition :
$$u(x,0)=f(x)=\gamma x+F(\gamma x+1)$$
$$F(\gamma x+1)=f(x)-\gamma x$$
Let $\gamma x+1=X\quad\implies\quad x=\frac{X-1}{\gamma}$
$$F(X)=f\left(\frac{X-1}{\gamma}\right)-X+1$$
Now the function $F(X)$ is known. We put it into the above general solution where $X=\gamma x+e^{-\gamma t}$
$$u=\gamma x+f\left(\frac{(\gamma x+e^{-\gamma t})-1}{\gamma}\right)-(\gamma x+e^{-\gamma t})+1$$
$$\boxed{u(x,t)=f\left(x+\frac{e^{-\gamma t}-1}{\gamma}\right)+1-e^{-\gamma t}}$$


text:
Q: Template Haskell: generating code for a function signature with the type class constraints I need to generate code for the function signature with type class constraints, for example:
fun :: (Ord a) => a -> a

I'm using the following signature constructor:
SigD Name Type

So, I need to generate a type. My best guess is to use the following constructor:
ForallT [TyVarBndr] Cxt Type

It corresponds to the following declaration (as seen at Temaplate Haskell documentation):
forall <vars>. <ctxt> => <type>

But Cxt is just a synonym for the list of Type's, and I can't find an appropriate constructor of Type for generating a type class constraint. What should I do to generate code for a type class constraint?

A: I believe that, as was mentioned in the comments, TH does not draw a distinction between Types and Constraints (which kind of makes sense, especially now that ConstraintKinds is around).  I've generally found inspecting the quasiquoted AST for a specific, concrete, example of whatever I'm trying to implement to be useful when working on generating code with TH that the quasiquoters aren't good enough for. For example, in GHCI:
λ> :set -XTemplateHaskell
λ> import Language.Haskell.TH
λ> runQ $ [d|f :: Ord a => a -> a; f = id|]
[SigD f_1 (ForallT [] [AppT (ConT GHC.Classes.Ord) (VarT a_0)] (AppT (AppT ArrowT (VarT a_0)) (VarT a_0))),ValD (VarP f_1) (NormalB (VarE GHC.Base.id)) []]

This shows that the constraint portion is just the Name for Ord applied to the name that you use for the type variable. Note that, at least at this level, the ForallT parameter list is empty, since the a in the type signature wasn't written as an explicit forall a..


text:
Q: Is there a way to mount volumes to a kubernetes docker compose deployment? I am trying to use kompose convert on my docker-compose.yaml files however, when I run the command:
kompose convert -f docker-compose.yaml

I get the output:
WARN Volume mount on the host "/home/centos/Sprint0Demo/Servers/elasticSearchConnector/etc/kafka-connect" isn't supported - ignoring path on the host
WARN Volume mount on the host "/home/centos/Sprint0Demo/Servers/elasticSearchConnector/etc/kafka-elasticsearch" isn't supported - ignoring path on the host
WARN Volume mount on the host "/home/centos/Sprint0Demo/Servers/elasticSearchConnector/etc/kafak" isn't supported - ignoring path on the host

It also says more warning for the other persistent volumes
My docker-compose file is:
version: '3'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.2.1
    container_name: es01
    environment:
      [env]
    ulimits:
      nproc: 3000
      nofile: 65536
      memlock: -1
    volumes:
      - /home/centos/Sprint0Demo/Servers/elasticsearch:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - kafka_demo
  zookeeper:
    image: confluentinc/cp-zookeeper
    container_name: zookeeper
    ports:
      - "2181:2181"
    environment:
        ZOOKEEPER_CLIENT_PORT: 2181
    volumes:
      - /home/centos/Sprint0Demo/Servers/zookeeper/zk-data:/var/lib/zookeeper/data
      - /home/centos/Sprint0Demo/Servers/zookeeper/zk-txn-logs:/var/lib/zookeeper/log
    networks:
      kafka_demo:
  kafka0:
    image: confluentinc/cp-kafka
    container_name: kafka0
    environment:
      [env]
    volumes:
      - /home/centos/Sprint0Demo/Servers/kafkaData:/var/lib/kafka/data
    ports:
      - "9092:9092"
    depends_on:
      - zookeeper
      - es01
    networks:
      kafka_demo:
  schema_registry:
    image: confluentinc/cp-schema-registry:latest
    container_name: schema_registry
    environment:
      [env]
    ports:
      - 8081:8081
    networks:
      - kafka_demo
    depends_on:
      - kafka0
      - es01
  elasticSearchConnector:
    image: confluentinc/cp-kafka-connect:latest
    container_name: elasticSearchConnector
    environment:
        [env]
    volumes:
      - /home/centos/Sprint0Demo/Servers/elasticSearchConnector/etc/kafka-connect:/etc/kafka-connect
      - /home/centos/Sprint0Demo/Servers/elasticSearchConnector/etc/kafka-elasticsearch:/etc/kafka-elasticsearch
      - /home/centos/Sprint0Demo/Servers/elasticSearchConnector/etc/kafak:/etc/kafka
    ports:
      - "28082:28082"
    networks:
      - kafka_demo
    depends_on:
      - kafka0
      - es01
networks:
  kafka_demo:
    driver: bridge

Does anyone know how I can fix this issue? I was thinking it has to do with the error message saying that its a volume mount vs host mount?

A: I have made some research and there are three things to point out:

*

*kompose does not support volume mount on host. You might consider using emptyDir instead.

*Kubernetes makes it difficult to pass in host/root volumes. You can try with
hostPath.
kompose convert --volumes hostPath works for k8s.

*Also you can check out Compose on Kubernetes if you'd like to run things on a single machine.

Please let me know if that helped.


text:
Q: Angular 8: markAsTouched is not trigger the errors I define for controls of form I have a weird problem in angular 8.
I have a parent component and a child component.
I used reactive forms in child component and access this form in parent component via ViewChild.
this ViewChild is static: false.
I call markAsTouched for each control of this form in parent component in submit button but this will not show the errors I defined for controls.
I have several pages like this.
some of them fully functional.
some of them half functional.
but this one is not functional about showing form errors.
It was working fine before but suddenly we faced this problem.
anyone here can help me?
I stuck in this problem a few days.

A: I moved all assignments for my form to child component.
also I used changeDecector.detectChanges() when I wanted to show the errors.
that's all. this resolved my problem.


text:
Q: Get real response of ngResource save() I have the following situation:
I use ngResource to save some data to the mysql database and after the successfull save() I want to log the json response the server sends to me:
Document.save({}, postData, function(response){
    console.log(response);
});

This does not result in a simple response, but in something like an object with its own methods. I want some smple output like the response.data after an $http.$get:
{
    "docClass":"testets",
    "colCount":1,
    "columns":null,
    "groupid":7,
    "id":19,
    "lang":"de",
    "title":"test",
    "version":1409849088,
    "workflow":"12234"
}

Greets

A: Check out this answer
Promise on AngularJS resource save action
So I think in your case you need to do
var document = new Document(postData);
document.$save()
    .then(function(res){});

But also from the link I provided

This may very well means that your call to $save would return empty reference. Also then is not available on Resource api before Angular 1.2 as resources are not promise based.


text:
Q: df -h showing weird output I am getting a weird output on df -h for one of the partitions. Here is the output:
/var/sdc$ df -kh
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       990M  569M  354M  62% /
/dev/sda2       976M  285M  640M  31% /var
/dev/sdc        5.0Z  5.0Z     0 100% /var/sdc

what does Z mean in 5.0Z and how can I free up the space there.

A: It is in the unit of ZiB (or simply Z).
1 ZiB = 2^70 Bytes
So as you have 5.0Z, multiply it by 5 to get your FS size.
From info df:
`Z'
`ZiB'
     2^70 = 1,180,591,620,717,411,303,424.

Note that, ZB is generally called ZettaBytes (10^21 = 1,000,000,000,000,000,000,000), but ZiB is not given any particular name.
But if we follow the trend, e.g. KB for KiloBytes, whereas KiB is called KibiBytes, similarly this can be named something like ZettiBytes? Again nothing official AFAIK.

Regarding the weird filesystem size:
Check the entry carefully:
/dev/sdc        5.0Z  5.0Z     0 100% /var/sdc

you have created filesystem on the whole disk /dev/sdc, not on any partition of it (e.g. /dev/sdc1, have you created any?), leading to this weirdness. Unmount the filesystem, create necessary partition(s) on the disk, and mount the partition(s) (e.g. could be /dev/sdc1) accordingly to meet your need.


text:
Q: How to run code if certain message was sent (Telegram Bot) I am creating a simple Telegram Bot that sends weather information depending on geolocation.
I want it to work like this:

*

*User types /weather in chat

*Bot says that geolocation is mandatory and the custom keyboard requesting location appears

*User presses the button to share location and gets a result (weather info)

Everything is fine except one thing - if user sends his location manually, bot reacts to it and gives feedback about weather. I would like to make it (weather info code) work only when /weather was sent in chat. I had an idea to check whether previous message text equals to "/weather" but could not find the solution. :/
C# Code:
private static void Bot_OnMessage(object sender, MessageEventArgs e)
    {
        var message = e.Message;

        if (message == null || message.Type != MessageType.Text) return;

        try
        {
            switch (message.Text)
            {
                case "/weather":
                    var requestLocationKeyboard = new ReplyKeyboardMarkup(new[]
                        {
                                new KeyboardButton("Share my location") {RequestLocation = true},
                            });

                    Bot.SendTextMessageAsync(
                       message.Chat.Id,
                       "To get the information about weather, you should share your current location.",
                       replyMarkup: requestLocationKeyboard);
                    break;

private static async void Bot_OnLocationReceived(object sender, MessageEventArgs e)
    {
        Thread.Sleep(1000);
        var message = e.Message;
        if (message == null || message.Type != MessageType.Location) return;

        var latitude = message.Location.Latitude;
        var longitude = message.Location.Longitude;

        latitude = (float)Math.Round(latitude, 3);
        longitude = (float)Math.Round(longitude, 3);

        Lat = latitude.ToString(CultureInfo.InvariantCulture);
        Lon = longitude.ToString(CultureInfo.InvariantCulture);

        await Bot.SendTextMessageAsync(
            message.Chat.Id,
            "_Processing Received Location..._",
            ParseMode.Markdown,
            replyMarkup: new ReplyKeyboardRemove());

        Console.WriteLine("{0};{1}", Lat, Lon);

        WeatherResponse weather = GetWeatherData();
        await Bot.SendTextMessageAsync(message.Chat.Id, "Your location: " + weather.List[0].Name + "\n" +
                                                        "Temperature: " + Convert.ToInt32(weather.List[0].Main.Temp) + " °C" +
                                                        "\n" + "Summary: " + weather.List[0].Weather[0].Description);
    }

A: Add a class field to store the last message
private string _lastMessage;

private static void Bot_OnMessage(object sender, MessageEventArgs e)
{
    var message = e.Message;

    if (message == null || message.Type != MessageType.Text) return;

    _lastMessage = message.Text; // <=============
    try
    {
        switch (message.Text)
    ...
}

In Bot_OnLocationReceived:
if (_lastMessage  == "/weather") {
    //TODO: display weather info
} else {
    //TODO: display only geo location.
}


text:
Q: jQuery, JSON and Apache problem I have an jQuery JSON request, that loads some JSON from another server (ex. foo.com):
$.getJSON("http://foo.com/json.php",function(data) { alert(data); });

But I receive data as null. This is not cross-domain issue, I tried following:
$.getJSON("http://twitter.com/users/usejquery.json?callback=?",
    function(data) { alert(data); });

and received nice JSON object. So, I think there is problem with backend, Apache 2.2.14. Here are HTTP headers, sent from server:
Date: Sun, 07 Mar 2010 16:08:38 GMT
Server: Apache/2.2.14 (CentOS)
X-Powered-By: PHP/5.3.1
Content-Length: 2
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Content-Type: application/json; charset=UTF-8

The headers are the same in each case: regular HTTP-request or AJAX. But I receive empty content with AJAX, and normal JSON with browser request. I'm using Firebug for tests, PHP5 for forming JSON.
Somebody have any ideas?
Thank you!

A: I'm pretty sure that in order to do cross domain calls like this you have to have a callback, it's what's needed to do JSONP.
here is some more info on jsonp http://www.insideria.com/2009/03/what-in-the-heck-is-jsonp-and.html
For jsonp to work you have to have a callback for the server to wrap the json string in. for example:
$.getJSON("http://foo.com/json.php?callback=?", function(data){});

here a callback function is generated by jquery and passed into the request, so it would be something like:
http://foo.com/json.php?callback=generatedFunction

then what's returned by the server should be:
generatedFunction("{key:value, key2:value2}");

where the parameter in that function is the actual json string.
in the php to return this it would be something like:
$callback = $_GET['callback'];
print($callback."(".json_encode($theobject).");");

A: More about cross-domain JSON throw JSONP and jQuery.


text:
Q: ICE Failed in firefox in case of different network wbrtc I am using TURN server with my webrtc application.It works fine in chrome in both same network and different network.But in firefox it works fine in same network but in case of different network it shows error:
ICE failed, see about:webrtc for more details

webrtc log:
(ice/WARNING) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): relay only option results in no host candidate for IP4:10.16.241.33:0/UDP

(ice/WARNING) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): relay only option results in no host candidate for IP4:10.32.4.48:0/UDP

(ice/WARNING) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): relay only option results in ICE TCP being disabled

(ice/ERR) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): peer (PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default) specified too many components

(ice/WARNING) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): peer (PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default) specified bogus candidate

(ice/WARNING) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): peer (PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default) has no stream matching stream 0-1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts) aLevel=1

(ice/NOTICE) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): peer (PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default) no streams with non-empty check lists

(ice/NOTICE) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): peer (PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default) no streams with pre-answer requests

(ice/NOTICE) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): peer (PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default) no checks to start

(stun/INFO) STUN-CLIENT(relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:3478/UDP)::TURN): Received response; processing

(stun/WARNING) STUN-CLIENT(relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:3478/UDP)::TURN): Error processing response: Retry may be possible, stun error code 401.

(ice/NOTICE) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): Message does not correspond to any registered stun ctx

(stun/INFO) STUN-CLIENT(relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:3478/UDP)::TURN): Received response; processing

(turn/INFO) TURN(relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:3478/UDP)): Succesfully allocated addr IP4:52.9.27.168:49256/UDP lifetime=3600

(ice/ERR) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): peer (PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default) pairing local trickle ICE candidate turn-relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:49256/UDP)

(ice/INFO) ICE-PEER(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default)/CAND-PAIR(l0AQ): setting pair to state FROZEN: l0AQ|IP4:52.9.27.168:49256/UDP|IP4:52.9.27.168:49963/UDP(turn-relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:49256/UDP)|candidate:3 1 UDP 92020735 52.9.27.168 49963 typ relay raddr 52.9.27.168 rport 49963)

(ice/INFO) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts))/CAND-PAIR(l0AQ): Pairing candidate IP4:52.9.27.168:49256/UDP (57e1fff):IP4:52.9.27.168:49963/UDP (57c1fff) priority=395226047563186174 (57c1fff0afc3ffe)

(ice/INFO) ICE-PEER(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default)/ICE-STREAM(0-1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts) aLevel=0): Starting check timer for stream.

(ice/INFO) ICE-PEER(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default)/CAND-PAIR(l0AQ): setting pair to state WAITING: l0AQ|IP4:52.9.27.168:49256/UDP|IP4:52.9.27.168:49963/UDP(turn-relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:49256/UDP)|candidate:3 1 UDP 92020735 52.9.27.168 49963 typ relay raddr 52.9.27.168 rport 49963)

(ice/INFO) ICE-PEER(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default)/CAND-PAIR(l0AQ): setting pair to state IN_PROGRESS: l0AQ|IP4:52.9.27.168:49256/UDP|IP4:52.9.27.168:49963/UDP(turn-relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:49256/UDP)|candidate:3 1 UDP 92020735 52.9.27.168 49963 typ relay raddr 52.9.27.168 rport 49963)

(turn/INFO) TURN(relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:3478/UDP)): Creating permission for IP4:52.9.27.168:49963/UDP

(ice/NOTICE) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): peer (PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default) is now checking

(ice/WARNING) ICE-PEER(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default): no pairs for 0-1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts) aLevel=0

(stun/WARNING) Inconsistent message method: 103 expected 008

(stun/WARNING) Inconsistent message method: 103 expected 001

(ice/NOTICE) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): Message does not correspond to any registered stun ctx

(stun/INFO) STUN-CLIENT(relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:3478/UDP)::TURN): Received response; processing

(stun/WARNING) Inconsistent message method: 108 expected 001

(ice/NOTICE) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): Message does not correspond to any registered stun ctx

(ice/INFO) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): peer (PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default) Trickle grace period is over; marking every component with only failed pairs as failed.

(stun/INFO) STUN-CLIENT(relay(IP4:10.16.241.33:63522/UDP|IP4:52.9.27.168:3478/UDP)::TURN): Timed out

(turn/WARNING) TURN(relay(IP4:10.16.241.33:63522/UDP|IP4:52.9.27.168:3478/UDP)): mode 20, nr_turn_client_error_cb

(turn/WARNING) TURN(relay(IP4:10.16.241.33:63522/UDP|IP4:52.9.27.168:3478/UDP)) failed

(turn/INFO) TURN(relay(IP4:10.16.241.33:63522/UDP|IP4:52.9.27.168:3478/UDP)): cancelling

(turn/WARNING) ICE-CANDIDATE(relay(IP4:10.16.241.33:63522/UDP|IP4:52.9.27.168:3478/UDP)): nr_turn_allocated_cb called with state 4

(turn/WARNING) ICE-CANDIDATE(relay(IP4:10.16.241.33:63522/UDP|IP4:52.9.27.168:3478/UDP)): nr_turn_allocated_cb failed

(stun/INFO) STUN-CLIENT(l0AQ|IP4:52.9.27.168:49256/UDP|IP4:52.9.27.168:49963/UDP(turn-relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:49256/UDP)|candidate:3 1 UDP 92020735 52.9.27.168 49963 typ relay raddr 52.9.27.168 rport 49963)): Timed out

(ice/INFO) ICE-PEER(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default)/CAND-PAIR(l0AQ): setting pair to state FAILED: l0AQ|IP4:52.9.27.168:49256/UDP|IP4:52.9.27.168:49963/UDP(turn-relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:49256/UDP)|candidate:3 1 UDP 92020735 52.9.27.168 49963 typ relay raddr 52.9.27.168 rport 49963)

(ice/INFO) ICE-PEER(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default)/STREAM(0-1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts) aLevel=0)/COMP(1): All pairs are failed, and grace period has elapsed. Marking component as failed.

(ice/INFO) ICE-PEER(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default): all checks completed success=0 fail=1

(ice/INFO) ICE-PEER(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default)/CAND-PAIR(l0AQ): triggered check on l0AQ|IP4:52.9.27.168:49256/UDP|IP4:52.9.27.168:49963/UDP(turn-relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:49256/UDP)|candidate:3 1 UDP 92020735 52.9.27.168 49963 typ relay raddr 52.9.27.168 rport 49963)

(ice/INFO) ICE-PEER(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default)/CAND-PAIR(l0AQ): received STUN check on failed pair, resurrecting: l0AQ|IP4:52.9.27.168:49256/UDP|IP4:52.9.27.168:49963/UDP(turn-relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:49256/UDP)|candidate:3 1 UDP 92020735 52.9.27.168 49963 typ relay raddr 52.9.27.168 rport 49963)

(ice/INFO) ICE-PEER(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default)/CAND-PAIR(l0AQ): setting pair to state WAITING: l0AQ|IP4:52.9.27.168:49256/UDP|IP4:52.9.27.168:49963/UDP(turn-relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:49256/UDP)|candidate:3 1 UDP 92020735 52.9.27.168 49963 typ relay raddr 52.9.27.168 rport 49963)

(ice/INFO) ICE-PEER(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts):default)/CAND-PAIR(l0AQ): Inserting pair to trigger check queue: l0AQ|IP4:52.9.27.168:49256/UDP|IP4:52.9.27.168:49963/UDP(turn-relay(IP4:10.32.4.48:63523/UDP|IP4:52.9.27.168:49256/UDP)|candidate:3 1 UDP 92020735 52.9.27.168 49963 typ relay raddr 52.9.27.168 rport 49963)

(stun/INFO) Responding with error 400: ICE Failure

(ice/NOTICE) ICE(PC:1480060743115000 (id=119 url=https://172.26.203.112:8889/amit_new/index-rui-dev.jsp#app/contacts)): Message does not correspond to any registered stun ctx

+++++++ END ++++++++

Now i am totally confused where is the problem.Any help will be appreciated.


text:
Q: I have two Django sites: how can I make users of site B login with the credentials on site A? I have a mother site, call it A. I'm planning a new site, B, and I don't want users to have to create new accounts.
I want all users of A to also be users of B, while the opposite is not necessarily too.
I suppose this require some form of OAuth?
Can you please address me to the best way to do this in Django?

A: If you want to use OAuth you need to implement OAuth "provider" on site A, generate app key and app secret and make site B use it while authenticating users. This way site B will be just an application that uses site A as OAuth provider (in OAuth terminology)

A: You could provide a custom auth backend to your new site B. Have a look here: Custom Auth Backend. This way you can try to authenticate your old user with a second auth backend when they could not authenticate against the first one on site B.


text:
Q: Why am i getting an error while trying to make a confusion matrix in decision tree? I am learning how to use decision trees in r.
I made a model and did  a prediction. I want to check the accuracy of my model. But when ever i tried to make confusion matrix using table function I am getting the error:

Error in table(test_data$Outcome, predictn) :    all arguments must
  have the same length

The code I used is:
data =  read.csv("C:/Users/VIJAY/Desktop/ML/logistic regression/diabetes.csv")

head(data)
dim(data)

library(rpart)
library(rpart.plot)
library(caret)

s = sample(768,600)

train_data = data[s,]
test_data = data[-s,]

model = rpart(Outcome ~.,data = train_data, method = "class")
rpart.plot(model,cex = .9)

predictn = predict(model,data= test_data,type = "class")

tab = table(test_data$Outcome,predictn)

A: Your response from the test set and predictions have different lengths. I would say that predictions weren't made for all observations (maybe because of missing values of some predictors - for this consider using surrogate variables or deleting the rows which have missing values in these predictors in the test set).
btw, when you are using caret, there is a nice function caret::confusionMatrix()


text:
Q: Retrieve RAM info on a Mac? I need to retrieve the total amount of RAM present in a system and the total RAM currently being used, so I can calculate a percentage. This is similar to: Retrieve system information on MacOS X?
However, in that question the best answer suggests how to get RAM by reading from:
/usr/bin/vm_stat

Due to the nature of my program, I found out that I am not cannot read from that file - I require a method that will provide me RAM info without simply opening a file and reading from it. I am looking for something to do with function calls. Something like this preferably : getTotalRam() and getRamInUse().
I obviously do not expect it to be that simple but I was looking for a solution other than reading from a file.
I am running Mac OS X Snow Leopard, but would preferably get a solution that would work across all current Mac OS X Platforms (i.e. Lion).
Solutions can be in C++, C or Obj-C, however C++ would the best possible solution in my case so if possible please try to provide it in C++.

A: You're not supposed to read from /usr/bin/vm_stat, rather you're supposed to run it; it is a program.  Look at the first four lines of output
Pages free:                  1880145.
Pages active:                  49962.
Pages inactive:                43609.
Pages wired down:             123353.

Add the numbers in the right column and multiple by the system page size (as returned by getpagesize()) and you get the total amount of physical memory in the system in bytes.
vm_stat isn't setuid on Mac OS, so I assume there is a non-privileged API somewhere to access this information and that vm_stat is using it.  But I don't know what that interface is.

A: You can figure out the answer to this question by looking at the source of the top command.  You can download the source from http://opensource.apple.com/.  The 10.7.2 source is available as an archive here or in browsable form here.  I recommend downloading the archive and opening top.xcodeproj so you can use Xcode to find definitions (command-clicking in Xcode is very useful).
The top command displays physical memory (RAM) numbers after the label "PhysMem".  Searching the project for that string, we find it in the function update_physmem in globalstats.c.  It computes the used and free memory numbers from the vm_stat member of struct libtop_tsamp_t.
You can command-click on "vm_stat" to find its declaration as a membor of libtop_tsamp_t in libtop.h.  It is declared as type vm_statistics_data_t.  Command-clicking that jumps to its definition in /usr/include/mach/vm_statistics.h.
Searching the project for "vm_stat", we find that it is filled in by function libtop_tsamp_update_vm_stats in libtop.c:
mach_msg_type_number_t count = sizeof(tsamp->vm_stat) / sizeof(natural_t);
kr = host_statistics(libtop_port, HOST_VM_INFO, (host_info_t)&tsamp->vm_stat, &count);
if (kr != KERN_SUCCESS) {
    return kr;
}

You will need to figure out how libtop_port is set if you want to call host_statistics.  I'm sure you can figure that out for yourself.

A: It's been 4 years but I just wanted to add some extra info on calculating total RAM.
To get the total RAM, we should also consider Pages occupied by compressor and Pages speculative in addition to Kyle Jones answer.
You can check out this post for where the problem occurs.

A: Getting the machine's physical memory is simple with sysctl:
int mib [] = { CTL_HW, HW_MEMSIZE };
int64_t value = 0;
size_t length = sizeof(value);

if(-1 == sysctl(mib, 2, &value, &length, NULL, 0))
    // An error occurred

// Physical memory is now in value

VM stats are only slightly trickier:
mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
vm_statistics_data_t vmstat;
if(KERN_SUCCESS != host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmstat, &count))
    // An error occurred

You can then use the data in vmstat to get the information you'd like:
double total = vmstat.wire_count + vmstat.active_count + vmstat.inactive_count + vmstat.free_count;
double wired = vmstat.wire_count / total;
double active = vmstat.active_count / total;
double inactive = vmstat.inactive_count / total;
double free = vmstat.free_count / total;

There is also a 64-bit version of the interface.


text:
Q: How to access model data in Ember controller I'm mainly new in Ember.
I want to access model data in my controller.
I'm using Ember.RSVP.hash to load multiple of models in my route.
my route
 model(params) {
   this.set('id', params.userID);
   return Ember.RSVP.hash({
     dashboards: this.store.findAll('dashboard', params)
      .then((dashboards) => dashboards.toArray()),
     user: this.store.find('user', params.userID)
    })
  },
  setupController(controller, model) {
    controller.setProperties(model);
  },

user model
export default DS.Model.extend({
  userID: DS.attr('string'),
  email: DS.attr('string'),
  name: DS.attr('string'),
  picture: DS.attr('string'),
  active: DS.attr('boolean'),
  permissions: DS.attr(),
  created: DS.attr('utc'),
  password: DS.attr('string')
});

Then I'm trying to access one of the user model parameters. In my controller I created init function and I tried to access user model parameter. What I wrote:
  init() {
    console.log(this.get('user.name'));
  },

After that I got undefined.
What is the proper way of doing that?

A: Use this.get('model') on your controller to access your model data as a whole. You can also use Ember.get(this, 'model.user.name');. You can use something like these: look at the actions.
But init is an eager hook! model property has not been set yet at init hook!

A: You should not access it init method. You can access it in a template using {{model.user}}.

*

*findAll - you don't need to pass params argument you got it from model hook.

*find is deperecated, use query or queryRecord

*then should return the value like (dashboards) => return dashboards.toArray()

*You dont need to override setupController since by default it will set model hook return values in controller.

*Just ensure data is loaded in store by using Ember inspector.

Prepared twiddle for basic demonstration


text:
Q: Tooltip data shows up NaN in bqplot Lines chart I am having trouble getting my tooltip data to show up in my line chart. Here is some very simple code that reproduces the error. When I hover over the line all that shows up is NaN. Can someone please help me? Thank you!
from bqplot import (Axis, LinearScale, Lines, Figure, Tooltip)
x = [1,2,3,4,5]
y = [1,2,3,4,5]
x_sc = LinearScale()
y_sc = LinearScale()
def_tt = Tooltip(fields=['x', 'y'], formats=['.1f', '.1f'])
line_chart = Lines(x=x, y=y, scales= {'x': x_sc, 'y': y_sc}, line_style='solid',default_colors=['dodgerblue'],
                        tooltip=def_tt)
ax_x = Axis(scale=x_sc)
ax_y = Axis(scale=y_sc, orientation='vertical', tick_format='0.2f')
Figure(marks=[line_chart], axes=[ax_x, ax_y])

A: Looks like this is an open issue with bqplot (https://github.com/bloomberg/bqplot/issues/702)
One workaround I found around this was to create a scatter chart (for which the tooltip works in the expected way), and plot this with invisible, fully transparent markers. Then plot your visible line on top.


text:
Q: Why spring boot application doesn't generate tables from entity in Postgresql? I have tryed everything what I have found here and in every relevant google match on my searches. I'm stuck with this problem for 2 days now, first I thought the problem might be with MySQL so tried Postgres but still nothing.
The database is connected with the application, when i create a new table i can see in Postgres and if I delete it there it disappears from Intellij also.
But from Entities it generates nothing and doesn't even throw any error.
application.properties:
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres_demo
spring.datasource.username= postgres
spring.datasource.password=1234
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto = create
spring.jpa.generate-ddl = true
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect

PostgresDemoApplication clsaa:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@EnableJpaAuditing
@SpringBootApplication
@EntityScan(basePackages = "models")
public class PostgresDemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(PostgresDemoApplication.class, args);
    }
}

model class:
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

@Entity
@Table(name = "question")
public class Question extends AuditModel {

    @Id
    @GeneratedValue(generator = "question_generator")
    @SequenceGenerator(
            name = "question_generator",
            sequenceName = "question_generator",
            initialValue = 1000
    )
    private Long id;

    @NotBlank
    @Size(min = 3, max = 100)
    private String title;

    @Column(columnDefinition = "text")
    private String description;

Spring boot
2018-09-09 14:11:35.261  INFO 2140 --- [  restartedMain] c.i.p.PostgresDemoApplication            : Starting PostgresDemoApplication on DESKTOP-5Q2LCCO with PID 2140 (D:\Isshae\Java\postgres-demo\out\production\classes started by asus in D:\Isshae\Java\postgres-demo)
2018-09-09 14:11:35.262  INFO 2140 --- [  restartedMain] c.i.p.PostgresDemoApplication            : No active profile set, falling back to default profiles: default
2018-09-09 14:11:35.338  INFO 2140 --- [  restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@44c035dd: startup date [Sun Sep 09 14:11:35 CEST 2018]; root of context hierarchy
2018-09-09 14:11:36.467  INFO 2140 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$41d31d19] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-09-09 14:11:36.908  INFO 2140 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-09-09 14:11:36.925  INFO 2140 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-09-09 14:11:36.925  INFO 2140 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.32
2018-09-09 14:11:36.929  INFO 2140 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_181\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\asus\AppData\Local\Programs\Python\Python37-32\Scripts\;C:\Users\asus\AppData\Local\Programs\Python\Python37-32\;C:\Users\asus\AppData\Local\Microsoft\WindowsApps;;.]
2018-09-09 14:11:37.052  INFO 2140 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-09-09 14:11:37.052  INFO 2140 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1717 ms
2018-09-09 14:11:37.111  INFO 2140 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-09-09 14:11:37.111  INFO 2140 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-09-09 14:11:37.111  INFO 2140 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-09-09 14:11:37.111  INFO 2140 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-09-09 14:11:37.111  INFO 2140 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-09-09 14:11:37.242  INFO 2140 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2018-09-09 14:11:37.498  INFO 2140 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2018-09-09 14:11:37.534  INFO 2140 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-09-09 14:11:37.534  INFO 2140 --- [  restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2018-09-09 14:11:37.675  INFO 2140 --- [  restartedMain] org.hibernate.Version                    : HHH000412: Hibernate Core {5.2.17.Final}
2018-09-09 14:11:37.677  INFO 2140 --- [  restartedMain] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2018-09-09 14:11:37.707  INFO 2140 --- [  restartedMain] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-09-09 14:11:37.809  INFO 2140 --- [  restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2018-09-09 14:11:37.829  INFO 2140 --- [  restartedMain] o.h.e.j.e.i.LobCreatorBuilderImpl        : HHH000422: Disabling contextual LOB creation as connection was null
2018-09-09 14:11:37.829  INFO 2140 --- [  restartedMain] org.hibernate.type.BasicTypeRegistry     : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@4ab9bbe7
2018-09-09 14:11:38.554  INFO 2140 --- [  restartedMain] o.h.t.schema.internal.SchemaCreatorImpl  : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@7d8c0ef6'
2018-09-09 14:11:38.554  INFO 2140 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-09-09 14:11:38.724  INFO 2140 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-09 14:11:38.974  INFO 2140 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@44c035dd: startup date [Sun Sep 09 14:11:35 CEST 2018]; root of context hierarchy
2018-09-09 14:11:38.999  WARN 2140 --- [  restartedMain] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2018-09-09 14:11:39.052  INFO 2140 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-09-09 14:11:39.053  INFO 2140 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-09-09 14:11:39.076  INFO 2140 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-09 14:11:39.076  INFO 2140 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-09 14:11:39.123  WARN 2140 --- [  restartedMain] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
2018-09-09 14:11:39.371  INFO 2140 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2018-09-09 14:11:39.394  INFO 2140 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-09-09 14:11:39.399  INFO 2140 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-09-09 14:11:39.403  INFO 2140 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2018-09-09 14:11:39.435  INFO 2140 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2018-09-09 14:11:39.436  INFO 2140 --- [  restartedMain] c.i.p.PostgresDemoApplication            : Started PostgresDemoApplication in 4.503 seconds (JVM running for 5.399)


text:
Q: Elliptic Curves and cryptography. Recommended Reading I have been studying RSA cryptography and want to extend this to ECC. I am interested in any books on the topic, that start off with basic principles of elliptic curves as I have almost zero knowledge of them. Can you reccomend any books, or combination of books.
(I do have a good working understanding of group theory pre-postgrad level anyway)


text:
Q: can't restore a database from a 100.50 backup on a 100.0 server
Possible Duplicate:
Is it possible to restore Sql Server 2008 backup in sql server 2005

I have a backup that was made on MS SQL Server 100.50 version, and I attempt to restore it on a  MS SQL Server 100.0 version. I get an error message "The database was backed up on a server running version 10.50.1617. That version is incompatible with this server, which is running version 10.00.5500. Either restore the database on a server that supports the backup, or use a backup that is compatible with this server.". So how do I restore it? I can see following solutions:

*

*Create a backup for my version of database. To do this I've tried to set the compatibility level of the original database on 100.50 server to 90 (MS SQL Server 2005), but it still produces same backup file. Haven't found other ways to do it.

*Update my SQL Server instance to 100.50 version. Haven't found how to do it yet.

Maybe there are other ways to solve this problem about which I am not aware yet. Any advice is welcome!

A: Install another instance of the database version you have the backup from.
Then you can restore you backup into this instance.
After that you can use the migrations tool to move the content of the database back to you old server.
That is how I did it when I had the same problem once.
Maybe someone else post a more tricky way.


text:
Q: How to avoid optimize command for every small changes in laravel I have made some changes on a Blade file using  text editor and then refreshed my page but unable to see new added content and noticed that  (it's loading the old content from Blade file).
code in route(web.php)
Route::get('about', function () {

             return view('about');
});

// code in view file(about.php)

some text in about file

I've tried the following:
php artisan optimize

then It worked fine i.e new added html lines visible but why for every small changes I need to optimize server


text:
Q: Regular expressions in PowerShell I need to retrieve a string from a text file which appears between two values. For example, I need to retrieve the string between < postcode >W12 FGS < /postcode >  and then place a space in that string, so it looks like < postcode >W12 FGS < /postcode >. This file can contain over 100 postcode's. How can I do it?

A: You need to be very precise when dealing with regex, anyway, based on your request I'd go with:
$pattern = [regex]::escape('< postcode >W12FGS < /postcode >')
$replaceWith = '< postcode >W12 FGS < /postcode >'

(Get-Content .\postcode.txt) |
Foreach-Object {$_ -replace $pattern,$replaceWith } |
Set-Content .\postcode.txt

Updated based on comments, changing postcode for multiple xml's in of folder.
Get-ChildItem c:\postcodes -Filter *.xml | Foreach-Object{
    [xml]$xml = Get-Content $_.FullName
    $xml.SelectNodes('//c_postcode') | Foreach-Object{ $_.'#text' = $_.'#text'.Insert(3,' ') }
    $xml.Save($_.FullName)
}


text:
Q: NullPointerException with Android SQLiteAssetHelper In the development of Android applications I use Android SQLiteAssetHelper.
The problem is that occasionally when accessing the database I get an error to the object  NullPointerException in object DBQuery
public class DBQuery extends MyDatabase {
  private static MyDatabase dataBaseHelper;

  public DBQuery(Context context) {
        super(context);
        dataBaseHelper = new MyDatabase(context);
  }

  public static void closed() {
        dataBaseHelper.close();
  }

  public static int getFDay(int year) {
    Cursor cursor = database.rawQuery("SELECT offset FROM china_years WHERE year = ?",
        new String[] { Integer.toString(year) });

    cursor.moveToFirst();
    String yearS;
    try {
      yearS = cursor.getString(0);
    } catch (Exception e) {
      yearS = "0";
      e.printStackTrace();
    }
    cursor.close();

    return Integer.parseInt(yearS);
  }

  /* other queries... */
}

MyDatabase class:
public class MyDatabase extends SQLiteAssetHelper {

   private static final String DATABASE_NAME = "db.sqlite";
   private static final int DATABASE_VERSION = 2;
   public static SQLiteDatabase database;

   public MyDatabase(Context context) {
     super(context, DATABASE_NAME, null, DATABASE_VERSION);

     database = getReadableDatabase();
   }
}

UDP:
Sorry, null object is 'database' in DBQuery class.

A: Add Database name Like this & check that database is create or not
 private static final String DATABASE_NAME = "Test";

data/data/YOUR_APP_PACKAGE_NAME Location

A: You have to open your data base first. Than only you can perform operation on that.


text:
Q: A result concerning local rings The following result appears in the book 'Commutative Algebra with a View Toward Algebraic Geometry' by David Eisenbud:
Theorem 18.16* Let $(R,P)$ be a regular local ring, and let $(A,Q)$ be a local Noetherian $R$-algebra, with $PA \subset Q$.
a. $A$ is flat over $R$ iff $\operatorname{depth}(PA,A) = \dim R$.
b. If $A$ is Cohen-Macaulay, then $A$ is flat over $R$ iff $\dim A = \dim R + \dim A/PA$.
(The above result appears here).

Is there a similar result without 'local'? (probably not?).

Thank you very much!


text:
Q: Convert satellite photos of Earth into texture maps on a sphere (OpenGL ES) We have 5 geo-stationary satellites, spaced around the equator (not equally spaced, but almost) taking photos of Earth every day. The output of each photo is - surprise! - a photo of a sphere, taken from a long distance away.
I need to reassemble those photos into a single texture-mapped sphere, and I'm not sure how best to do this. Key problems:

*

*The photos are - obviously - massively distorted the further you go from the center, since they're looking at a sphere

*There are many hundreds of "sets" of 5 photos, taken at different times of day. Any solution needs to be programmatic - I can't just do this by hand :(

*Output platform is the iPad3: Open GL ES 2, textures up to 4096x4096 - but not as powerful as a desktop GPU. I'm not great with shaders (although I've done a lot of OpenGL pre-shaders)

*The photos themselves are high-res, and I'm not sure I can have all 5 textures loaded simultaneously. I've also got a very high-res texture loaded for the planet surface (underneath the satellite photos).

I've already got: a single rectangular texture mapped onto a sphere (my sphere is a standard mesh wrapped into a sphere, with vertices distributed evenly across the surface), so ... I tried converting 5 photos of spheres into a single rectangular map (but no success so far; although someone pointed me at doing a "polar sin warp" which looks like it might work better).
I've also thought of doing something funky with making a cube-map out of the 5 photos, and being clever about deciding which of the photos to read for a given pixel, but I'm not entirely convinced.
Is there a better way? Something I've overlooked? Or has anyone got a concrete way of achieving the above?

A: I would do a rectangular texture from it.
You will need 2 x 2D textures/arrays one for r,g,b color summation avg and one for count cnt. Also I am not convinced that I would use OpenGL/GLSL for that it seems to me that C/C++ will be better for this.
I would do it like this:

*

*blank the destination textures (avg[][]=0, cnt[][]=0)

*obtain satellite position/direction,time
from position and direction create transformation matrix which projects Earth the same ways as on photo. Then from time determine rotation shift.

*do loop through entire Earths surface
just two nested loops a - rotation and `b - distance from equator.

*get x,y,z from a,b and transform matrix + rotation shift (a-axis)
also can do it backwards a,b,z = f(x,y) but it is more tricky but faster and more accurate. You can also interpolate x,y,z between neighboring (pixels/areas)[a][b]

*add pixel
if x,y,z is on the front side (z>0 or z<0 depends on the camera Z direction) then
avg[a][b]+=image[x][y]; cnt[a][b]++;

*end of nested loop from point #3.

*goto #2 with next photo

*do loop through entire avg texture to restore average color
if (cnt[a][b]) avg[a][b]/=cnt[a][b];

[Notes]

*

*can test if the copied pixel is:
Obtained during day or night (use only what you want and not mix both together!!!) also can determine clouds (i think gray/white-ish colors not snow) and ignore them.

*do not overflow the colors
can use 3 separate textures r[][],g[][],b[][] instead avg to avoid that

*can ignore areas near edges of Earth to avoid distortions

*can apply lighting corrections
from time and a,b coordinates to normalize illumination
Hope it helps ...
[Edit1] orthogonal projection
so its clear here is what I mean by orthogonal projection:

this is used texture (cant find nothing better suited and free on the web) and wanted to use real satellite image not some rendered ...

this is my orthogonal projection App

*

*the red,green,blue lines are Earth coordinate system (x,y,z axis)

*the (red,green,blue)-white-ish lines are satellite projection coordinate system (x,y,z axis)

the point is to to convert earth vertex coordinates (vx,vy,vz) to satellite coordinates (x,y,z) if z >= 0 then its the valid vertex for processed texture so compute texture coordinates directly from x,y without any perspective (orthogonally).
for example tx=0.5*(+x+1); ... if x was scaled to <-1,+1> and usable texture is tx <0,1> The same goes for y axis: ty=0.5*(-y+1); ... if y was scaled to <-1,+1> and usable texture is ty <0,1> (my camera has inverted y coordinate system respective to texture matrix therefore the inverted sign on y axis)
if the z < 0 then you are processing vertex out of texture range so ignore it ...
 as you can see on the image the outer boundaries of texture are distorted so  you should use only the inside (for example 70% of earth image area) also you can do some kind of texture coordinates correction dependent on the distance from texture middle point. When you have this done then just merge all satellite image projection to one image and that is all.
[Edit2] Well I played with it a little and found out this:

*

*reverse projection correction do not work for my texture at all I think that is possible it is post processed image ...

*middle point distance based correction seems be nice but the scale coefficient used is odd have no clue why to multiply by 6 when it should be 4 I think ...
tx=0.5*(+(asin(x)*6.0/M_PI)+1);
ty=0.5*(-(asin(y)*6.0/M_PI)+1);

*

*corrected nonlinear projection (by asin)

*

*corrected nonlinear projection edge zoom

*distortions are much much smaller then without asin texture coordinate corrections