text:
Q: GDAL 2.4.2 from UbuntuGIS unstable broken because of missing libogdi.so.3.2? After an unthoughtful apt-get update today, GDAL no longer works on my Ubuntu Machine (bionic) because libogdi.so.3.2 is missing:
daniel@gin-nuest:~$ gdalinfo
gdalinfo: error while loading shared libraries: libogdi.so.3.2: cannot open shared object file: No such file or directory

The link actually seems be missing, and OGDI is installed in version 4.1
daniel@gin-nuest:~$ ldd /usr/bin/gdalinfo
[..]
    libgdal.so.20 => /usr/local/lib/libgdal.so.20 (0x00007fc157fc5000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc157bd4000)
[..]
    libogdi.so.3.2 => not found
    libgif.so.7 => /usr/lib/x86_64-linux-gnu/libgif.so.7 (0x00007fc1541cf000)
    libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007fc153f67000)
    libgeotiff.so.2 => /usr/lib/x86_64-linux-gnu/libgeotiff.so.2 (0x00007fc153d31000)
[..]

I have removed GDAL and reinstalled (from UbuntuGIS unstable), but it seems I only get OSGI 3.2 when uninstalling GDAL.
daniel@gin-nuest:~$ apt-cache search ogdi
libcgi-application-basic-plugin-bundle-perl - bundle of basic plugins for CGI::Application
libcgi-application-plugin-logdispatch-perl - plugin that adds Log::Dispatch support to CGI::Application
libogdi3.2 - Open Geographic Datastore Interface Library -- library
libogdi3.2-dev - Open Geographic Datastore Interface Library -- development
ogdi-bin - Open Geographic Datastore Interface Library -- utilities
libogdi-dev - Open Geographic Datastore Interface Library -- development
libogdi4.1 - Open Geographic Datastore Interface Library -- library
daniel@gin-nuest:~$ sudo apt-get install libogdi3.2
Reading package lists... Done
Building dependency tree
Reading state information... Done
[..]
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libproj12
Suggested packages:
  ogdi-bin
The following packages will be REMOVED
  gdal-bin libgdal-dev libgdal20 libogdi-dev libogdi4.1 ogdi-bin
The following NEW packages will be installed
  libogdi3.2 libproj12
0 to upgrade, 2 to newly install, 6 to remove and 0 not to upgrade.

I have GDAL 2.4.2, which should link to libogdi-dev:
daniel@gin-nuest:~$ sudo apt-get install libgdal-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libgdal-dev is already the newest version (2.4.2+dfsg-1~bionic0).

daniel@gin-nuest:~$ apt-cache show libgdal-dev
Package: libgdal-dev
Source: gdal
Priority: optional
Section: libdevel
Installed-Size: 43790
Maintainer: Debian GIS Project <pkg-grass-devel@lists.alioth.debian.org>
Architecture: amd64
Version: 2.4.2+dfsg-1~bionic0
Suggests: libgdal-doc
Depends: libgdal20 (= 2.4.2+dfsg-1~bionic0), libc6-dev, libarmadillo-dev, libcharls-dev, libcurl4-gnutls-dev | libcurl-ssl-dev, libdap-dev, libepsilon-dev, libexpat1-dev, libfreexl-dev, libfyba-dev, libgeos-dev, libgeotiff-dev, libgif-dev, libhdf4-alt-dev, libhdf5-dev, libjpeg-dev, libjson-c-dev, libkml-dev, libltdl-dev, liblzma-dev, default-libmysqlclient-dev, libnetcdf-dev, libogdi-dev, libopenjp2-7-dev, libpcre3-dev, libpng-dev, libpoppler-private-dev, libpq-dev, libproj-dev, libqhull-dev, libspatialite-dev, libsqlite3-dev, libtiff-dev, liburiparser-dev, libwebp-dev, libxerces-c-dev, libxml2-dev, libzstd-dev, unixodbc-dev
Filename: pool/main/g/gdal/libgdal-dev_2.4.2+dfsg-1~bionic0_amd64.deb
Size: 7493120
MD5sum: 28a4b604a9274a087dfbd274989a6a2f
SHA1: 38402e01ef5d1833afcc75c673efadacdca53c13
SHA256: 19f27da9c9fecd0d58d9eb1dda8bfa0f4d4af85ca4ea94241446f97e14b41aa1
Description-en_GB: Geospatial Data Abstraction Library - Development files
 GDAL is a translator library for raster geospatial data formats. As a
 library, it presents a single abstract data model to the calling
 application for all supported formats. The related OGR library (which
 lives within the GDAL source tree) provides a similar capability for
 simple features vector data.
 .
 GDAL supports many popular data formats, including commonly used ones
 (GeoTIFF, JPEG, PNG and more) as well as the ones used in GIS and remote
 sensing software packages (ERDAS Imagine, ESRI Arc/Info, ENVI, PCI
 Geomatics). Also supported many remote sensing and scientific data
 distribution formats such as HDF, EOS FAST, NOAA L1B, NetCDF, FITS.
 .
 OGR library supports popular vector formats like ESRI Shapefile, TIGER
 data, S57, MapInfo File, DGN, GML and more.
 .
 This package contains the files needed to develop a software that will use
 the GDAL/OGR (headers, static objects, configuration script).
Description-md5: fe1355584b1a93438b3699e1581cff4b

Package: libgdal-dev
Architecture: amd64
Version: 2.2.3+dfsg-2
Priority: extra
Section: universe/libdevel
Source: gdal
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian GIS Project <pkg-grass-devel@lists.alioth.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 38196
Depends: libgdal20 (= 2.2.3+dfsg-2), libc6-dev, libarmadillo-dev, libcurl4-gnutls-dev | libcurl-ssl-dev, libdap-dev, libepsilon-dev, libexpat1-dev, libfreexl-dev, libfyba-dev, libgeos-dev, libgeotiff-dev, libgif-dev, libhdf4-alt-dev, libhdf5-dev, libjpeg-dev, libjson-c-dev, libkml-dev, libltdl-dev, liblzma-dev, default-libmysqlclient-dev, libnetcdf-dev, libogdi3.2-dev, libopenjp2-7-dev, libpcre3-dev, libpng-dev, libpoppler-private-dev, libpq-dev, libproj-dev, libqhull-dev, libspatialite-dev, libsqlite3-dev, libtiff-dev, liburiparser-dev, libwebp-dev, libxerces-c-dev, libxml2-dev, unixodbc-dev
Suggests: libgdal-doc
Filename: pool/universe/g/gdal/libgdal-dev_2.2.3+dfsg-2_amd64.deb
Size: 6368740
MD5sum: 711832653250698db1fc098f873a8160
SHA1: 0aba22cd81a92495d129a8bdb5dcf6dab63888a7
SHA256: 82bf99ada413ec8f00b544cf7123d458e58fb994e5d84d93ec9407f7b5877c0f
Homepage: http://www.gdal.org/
Description-en_GB: Geospatial Data Abstraction Library - Development files
 GDAL is a translator library for raster geospatial data formats. As a
 library, it presents a single abstract data model to the calling
 application for all supported formats. The related OGR library (which
 lives within the GDAL source tree) provides a similar capability for
 simple features vector data.
 .
 GDAL supports many popular data formats, including commonly used ones
 (GeoTIFF, JPEG, PNG and more) as well as the ones used in GIS and remote
 sensing software packages (ERDAS Imagine, ESRI Arc/Info, ENVI, PCI
 Geomatics). Also supported many remote sensing and scientific data
 distribution formats such as HDF, EOS FAST, NOAA L1B, NetCDF, FITS.
 .
 OGR library supports popular vector formats like ESRI Shapefile, TIGER
 data, S57, MapInfo File, DGN, GML and more.
 .
 This package contains the files needed to develop a software that will use
 the GDAL/OGR (headers, static objects, configuration script).
Description-md5: fe1355584b1a93438b3699e1581cff4b
Supported: 3y

daniel@gin-nuest:~$ which gdalinfo
/usr/bin/gdalinfo
daniel@gin-nuest:~$ /usr/bin/gdalinfo
/usr/bin/gdalinfo: error while loading shared libraries: libogdi.so.3.2: cannot open shared object file: No such file or directory

Further information:
daniel@gin-nuest:~$ apt-cache madison gdal
      gdal | 2.2.3+dfsg-2 | http://archive.ubuntu.com/ubuntu bionic/universe Sources
      gdal | 2.4.2+dfsg-1~bionic0 | http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu bionic/main Sources
      gdal | 2.2.2+dfsg-1~xenial1 | http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu xenial/main Sources
daniel@gin-nuest:~$ apt-cache policy gdal
N: Unable to locate package gdal
daniel@gin-nuest:~$ apt-cache policy libgdal-dev
libgdal-dev:
  Installed: 2.4.2+dfsg-1~bionic0
  Candidate: 2.4.2+dfsg-1~bionic0
  Version table:
 *** 2.4.2+dfsg-1~bionic0 500
        500 http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status
     2.2.3+dfsg-2 500
        500 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
aniel@gin-nuest:~$ apt-cache policy ogdi-bin
ogdi-bin:
  Installed: 4.1.0+ds-1~bionic0
  Candidate: 4.1.0+ds-1~bionic0
  Version table:
 *** 4.1.0+ds-1~bionic0 500
        500 http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status
     3.2.0+ds-2 500
        500 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages

Summary
gdal-bin links to libogdi.so.3.2 it seems, but when I install it, it wants to install libogdi4.1:
daniel@gin-nuest:~$ sudo apt-get install gdal-bin
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libgdal20 libogdi4.1
Suggested packages:
  libgdal-grass python-gdal ogdi-bin
The following packages will be REMOVED
  libogdi3.2
The following NEW packages will be installed
  gdal-bin libgdal20 libogdi4.1
0 to upgrade, 3 to newly install, 1 to remove and 0 not to upgrade.

Not a solution
I can install the older GDAL from Ubuntu's sources:
sudo apt-get install libgdal20=2.2.3+dfsg-2
sudo apt-get install gdal-bin=2.2.3+dfsg-2
sudo apt-get install libgdal-dev=2.2.3+dfsg-2
sudo apt-get install gdal-data=2.2.3+dfsg-2
sudo apt-get install libproj-dev=4.9.3-2
[..]
daniel@gin-nuest:~$ gdalinfo  --version
GDAL 2.3.2, released 2018/09/21

Excursion
A futher problem downstream (installing the sf package in R) was then due to a stray libgdal.so file, probably from a two year old source install, which helped me to solve the the undefined symbol: _ZN10OGRFeature20GetFieldAsDoubleListEiPi problem on my machine:
I identified this by running
daniel@gin-nuest:/usr/share/proj$ ldconfig -p | grep gdal
    libgdal.so.20 (libc6,x86-64) => /usr/local/lib/libgdal.so.20
    libgdal.so.20 (libc6,x86-64) => /usr/lib/libgdal.so.20
    libgdal.so (libc6,x86-64) => /usr/local/lib/libgdal.so
    libgdal.so (libc6,x86-64) => /usr/lib/libgdal.so

So, two libgdal.so. After uninstalling GDAL (libgdal20) and then running the same command again I got:
daniel@gin-nuest:/usr/share/proj$ ldconfig -p | grep gdal
    libgdal.so.20 (libc6,x86-64) => /usr/local/lib/libgdal.so.20
    libgdal.so (libc6,x86-64) => /usr/local/lib/libgdal.so

So I manually removed the files (daniel@gin-nuest:/usr/local/lib$ sudo rm libgdal.*) and then installed GDAL from Ubuntu sources (not UbuntuGIS unstable). Installation of sf works again:
> library("sf")
Linking to GEOS 3.7.1, GDAL 2.2.3, PROJ 4.9.3

Solution
As pointed out below, the library in /usr/local/lib was a leftover from a manual compilation. Once that was cleared as stated above, I could

*

*enable UbuntuGIS unstable

*update GDAL and other libraries

and now have the latest versions installed.

A: After a clean install on my system, I can run gdalinfo without any problem.
It seems you have a version of libgdal20 in /usr/local/lib/ from some self-compilation of an older GDAL version. This overrides any installation by apt, and apt can not remove it.
You have to recompile that version from GDAL 2.4.2 sources to get rid of your error.
Nothing to blame the ubuntugis people for.


text:
Q: NiFi make single Database call after processing multiple flowfiles I have a below scenario, I am trying

*

*get new files list with ListFile processor

*set a constant variable  zipFilesBundleConstant = listBundle on each flowfile

*Put the list to Database

*Get all the list of files old and new from Database to process further with ExecuteSQL processor. (Here I want to make only one Database call to fetch complete list old and new, but ExecuteSQL is being called for all the flowfiles)

I tried keeping MergeContent processor with zipFilesBundleConstant as Correlation Attribute Name before ExecuteSQL to combine all the flowfiles but that is not working as expected and it merges some but always gives me multiple flowfiles.
Can anyone please help me with a solution on how to make a one call after inserting the new files list into the database.

A: You can use ExecuteSQL processor has separate workflow to fetch existing old files list from the database with the scheduling strategy as per the requirement.
https://nifi.apache.org/docs/nifi-docs/html/user-guide.html#scheduling-tab

redpajama_set_name: RedPajamaStackExchange


text:
Q: SQL Inner Queries- Subquery returns more than 1 row SELECT DISTINCT cmt.topic_id,ctt.description AS topic_name,cmrt.room_id,cmrt.family_id, crt.title AS room_name, ft.family_identifier AS family_name, upt.gender, cmt.postedby_userid, cmt.member_id,
ut.picture_filename AS senderImage,
ut.croppedpicture_filename AS senderCroppedImage,
cmt.image AS imageUrl ,
cmt.message AS caption,
cmrt.user_id,
(SELECT COUNT(id) FROM `conversation_messages_tbl` a ,`conversation_msgreadstatus_tbl` b WHERE a.`message_id` = b.`message_id`
AND a.`topic_id` = b.`topic_id` AND  b.`is_read`= 0 AND b.`user_id`!= 27 GROUP BY b.`user_id`) countn
FROM conversation_messages_tbl cmt,
conversation_topics_tbl ctt ,
conversation_msgreadstatus_tbl cmrt,
conversation_rooms_tbl crt, family_tbl ft,
user_profileinformation_tbl upt,
user_tbl ut
WHERE ctt.topic_id=cmt.topic_id AND cmrt.message_id=cmt.message_id
AND upt.user_id=cmt.postedby_userid AND crt.room_id=cmrt.room_id AND ft.family_id=crt.family_id
AND ut.user_id=cmt.postedby_userid AND cmt.message_id=202 GROUP BY cmrt.user_id;

I'm getting the error message saying
Error Code: 1242
Subquery returns more than 1 row
Solutions ??

A: Your inner query
(SELECT COUNT(id) FROM `conversation_messages_tbl` a ,`conversation_msgreadstatus_tbl` b WHERE a.`message_id` = b.`message_id` AND a.`topic_id` = b.`topic_id` AND  b.`is_read`= 0 AND b.`user_id`!= 27 GROUP BY b.`user_id`) countn

may return more than 1 row, as it will return a count for each distinct user_id different from 27 (because of group by).

A: You sub query will return multiple rows, because you have used GROUP BY b.user_id and there is not condition between your query and sub query.
If I am thinking in correct way, cmrt.user_id is equals to b.user_id, you can add a condition to your sub query like the following:
(SELECT COUNT(id) FROM `conversation_messages_tbl` a
`conversation_msgreadstatus_tbl` b WHERE a.`message_id` = b.`message_id`
AND a.`topic_id` = b.`topic_id` AND  b.`is_read`= 0 AND b.`user_id`!= 27
b.`user_id`=cmrt.user_id) countn


text:
Q: How to change img to amp-img with jQuery? Accelerated Mobile Pages (AMP) Project
Original

Result

 <amp-img src="MyImage.jpg" width="1080" height="610" layout="responsive" alt="an image"></amp-img>

How to do it with jQuery ?

A: Use .replaceWith() API to replace the content :
$('.thumbnail').find('img').replaceWith(function () {
   return '<amp-img src="'+this.src+'" width="1080" height="610" layout="responsive" alt="'+this.alt+'"></amp-img>'
});


text:
Q: How to extract information with Xpath in python scrapy i need some help to extract a part of information from html page with xpath! i wanna extract the review's rating
exemple : this is the HTML code

Overall rating

      4.9
      out of
      5
      <meta itemprop="reviewCount" content="23">

From this code i wanna display "4.9 out of 5" or 3 variables which contains "4.9" , "out of" , "5"
I used this but it didn't work :
response.xpath('//div[@class="BVRRRatingNormalImage"]/img/@alt').extract()

Any help?

A: response.xpath('//span[@itemprop="aggregateRating"]/span/text()').extract()

it will give three element in list format
response.xpath('//span[@itemprop="ratingValue"]/text()').extract_first()

it will give only one element as string "4.9"


text:
Q: How to handle pressing any keys in the user control in visual studio vspackage I added usercontrol (textbox) in code editor control. But textbox not handle any keys (arrow, backspace). Keys handle code editor only.
Example:
get IWpfTextView
var textManager = (IVsTextManager)Package.GetGlobalService(typeof(SVsTextManager));
IVsTextView textView;
textManager.GetActiveView(1, null, out textView);
var userData = (IVsUserData)textView;
if (userData == null)
    return null;
Guid guidWpfViewHost = Microsoft.VisualStudio.Editor.DefGuidList.guidIWpfTextViewHost;
object host;
userData.GetData(ref guidWpfViewHost, out host);
return ((IWpfTextViewHost)host).TextView;

Add control with textbox
Canvas.SetLeft(_control, _view.ViewportRight - 255);
Canvas.SetTop(_control, _view.ViewportTop + 10);
(((System.Windows.Controls.ContentControl)_view).Content as Canvas).Children.Add(_control);

But there was a problem when processing keys, their intercepts (the main window as the editor),
keys are not processed. For example arrows, HOME and other.
If so add a textbox, then the letters are printed there. But the other key is handled by the editor, rather than this text box even backspace.
Who knows how to catch and handle correctly?


text:
Q: Is it possible to overload static method by closure signature in Swift 3? Is it possible to overload static method by closure type in Swift 3?
For example, i have a struct with 2 methods:
struct Some {
  static func doSomething(first: String, @escaping completion: ([Int]?) -> Void) {
    ...
  }

  static func doSomething(first: String, @escaping completion: ([Int]?, String?) -> Void) {
    ...
  }
}
But when i try to call the first method Some.doSomething(first: "Hello") { (numbers) in ... } (with closure with one parameter) compiler gives me an error:

Ambiguous use of 'doSomething(first:completion:)'

A:
Yes you can overload static method by closure type in Swift 3, but you
  need to specify the type of the parameter for the first function as
  its parameters partially  matches with that of second function

 Some.doSomething(first: "") { (number:[Int]?) in

}

Some.doSomething(first: "") { (number, value) in

}


text:
Q: Gridview Shows the Repeated Value I have a User Information table which contains
First name
last name
...

When i am fetching the Data from a source into a dataset. It shows the repeated Value in a grid as:
First Name Last Name .... First Name Last Name....

the code as follows:
Utility class
public DataSet GetMember()
        {

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                using (SqlCommand cnn = new SqlCommand("selectmember", con))
                {
                    cnn.CommandType = CommandType.StoredProcedure;

                    using(DataSet ds=new DataSet())
                    {
                       try
                       {
                        con.Open();
                        cnn.ExecuteNonQuery();
                        SqlDataAdapter da = new SqlDataAdapter(cnn);
                        da.Fill(ds);

                        }

                       catch (Exception e)
                       {
                       }
                       return ds;
                    }
                }
            }
        }

Member.aspx
 public void binddata()
        {
            DataSet ds = new DataSet();
            ds = utility.GetMember();
            GdMember.DataSource = ds;
            GdMember.DataBind();
        }

Am i missing any code or i am doing any error. Thanks for any assistance.

A: Most probably your grid has explicit column templates but in the same time you forgot to set AutoGenerateColumns to false. Thus, the first set of columns comes from templates and the second one is auto generated by the grid based on the structure of the data set.

A: Just like @WiktorZychla mentioned, try setting AutoGenerateColumns="false"
<asp:GridView AutoGenerateColumns="false" ...>
</asp:GridView>


text:
Q: Catch exception while initializing static final variable I have following code:
public class LoadProperty
{
public static final String property_file_location = System.getProperty("app.vmargs.propertyfile");
public static final String application-startup_mode = System.getProperty("app.vmargs.startupmode");
}

It reads from 'VM arguments' and assigns to variables.
Since static final variable is only initialized at class load,
how can I catch exception in case some one forgets to pass parameter.
As of now, when I am using 'property_file_location' variable, exception is encountered in following cases:

*

*If value is present, and location is wrong, FileNotFound exception comes.

*If it is not initialized properly(value is null), it throws NullPointerException.

I need to handle second case at time of initialization only.
Similiar is case of second variable.
Whole idea is

*

*To initialize application configuration parameters.

*If successfully initialized, continue.

*If not, alert user and terminate application.

A: You can catch it this way:
public class LoadProperty
{
    public static final String property_file_location;

    static {
        String myTempValue = MY_DEFAULT_VALUE;
        try {
            myTempValue = System.getProperty("app.vmargs.propertyfile");
        } catch(Exception e) {
            myTempValue = MY_DEFAULT_VALUE;
        }
        property_file_location = myTempValue;
    }
}

A: You can use a static initializer block as suggested by the rest of the answers. Even better move this functionality to a static utility class so you can still use them as an one-liner. You could then even provide default values e.g.
// PropertyUtils is a new class that you implement
// DEFAULT_FILE_LOCATION could e.g. out.log in current folder
public static final String property_file_location = PropertyUtils.getProperty("app.vmargs.propertyfile", DEFAULT_FILE_LOCATION);

However if those properties are not expected to exist all the time, I would suggest to not initialize them as static variables but read them during normal execution.
// in the place where you will first need the file location
String fileLocation = PropertyUtils.getProperty("app.vmargs.propertyfile");
if (fileLocation == null) {
    // handle the error here
}

A: You may want to use a static bloc :
public static final property_file_location;
static {
  try {
    property_file_location = System.getProperty("app.vmargs.propertyfile");
  } catch (xxx){//...}
}


text:
Q: Error: NG0201: No provider for NgControl found in NodeInjector. Find more at https://angular.io/errors/NG0201 While testing with Karma and Jasmine I am new to testing with Karma and Jasmine in Angular. I have looked for the error and it comes up due to modules not being imported or declared properly, But in my use case, I am testing the app. I believe I have provided the imports, so what exactly am I missing here?
This is my component.
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { FormControl } from '@angular/forms';
import { MatAutocomplete } from '@angular/material/autocomplete';
import { map, Observable, startWith } from 'rxjs';

interface Options {
  key: string;
  value: string;
}

@Component({
  selector: 'app-primary-auto-complete',
  templateUrl: './primary-auto-complete.component.html',
  styleUrls: ['./primary-auto-complete.component.css'],
})
export class PrimaryAutoCompleteComponent implements OnInit {
  @Input() label: string = '';
  @Input() placeholder: string = 'Start typing here';
  @Input() options: Options[] = [];
  @Input() ngStyle: { [Klass: string]: any } | null = null;

  @Input() autoSelectFormControl = new FormControl('');

  // @ts-ignore
  filteredOptions: Observable<Options[]>;

  // @ts-ignore
  @ViewChild('auto') autocomplete: MatAutocomplete;

  constructor() {}

  ngOnInit() {
    this.filteredOptions = this.autoSelectFormControl.valueChanges.pipe(
      startWith(''),
      map((value) => this._filter(value || ''))
    );
  }

  // Clears the option if it is a wrong one
  onBlur = () => {
    if (!this.autocomplete.isOpen)
      this.options.some((item) => {
        if (item.key === this.autoSelectFormControl.value) return true;
        return false;
      })
        ? null
        : this.autoSelectFormControl.setValue('');
  };

  private _filter(value: string): {
    key: string;
    value: string;
  }[] {
    const filterValue = value.toLowerCase();

    return this.options.filter((item) =>
      item.key.toLowerCase().includes(filterValue)
    );
  }
}

This is the HTML file.
<mat-form-field
  [ngStyle]="ngStyle"
  appearance="outline"
  class="primary-autoSelect"
  floatLabel="always"
>
  <mat-label>{{ label }}</mat-label>
  <input
    type="text"
    [placeholder]="placeholder"
    matInput
    [formControl]="autoSelectFormControl"
    [matAutocomplete]="auto"
    (blur)="onBlur()"
  />
  <mat-autocomplete #auto="matAutocomplete">
    <mat-option
      *ngFor="let option of filteredOptions | async"
      [value]="option.value"
    >
      {{ option.key }}
    </mat-option>
  </mat-autocomplete>
  <mat-error *ngIf="autoSelectFormControl.hasError('required')">
    {{ label }} is required
  </mat-error>
  <mat-error *ngIf="!autoSelectFormControl.hasError('required')">
    Please select a value from the list {{ label }}
  </mat-error>
</mat-form-field>

This is the testing file.
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormControl, FormsModule } from '@angular/forms';
import { MatAutocomplete } from '@angular/material/autocomplete';
import { MatOption } from '@angular/material/core';
import { MatError, MatFormField, MatLabel } from '@angular/material/form-field';

import { PrimaryAutoCompleteComponent } from './primary-auto-complete.component';

describe('PrimaryAutoCompleteComponent', () => {
  let component: PrimaryAutoCompleteComponent;
  let fixture: ComponentFixture<PrimaryAutoCompleteComponent>;

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [
        PrimaryAutoCompleteComponent,
        MatAutocomplete,
        MatFormField,
        MatLabel,
        MatOption,
        MatError,
      ],
      imports: [FormsModule],
    }).compileComponents();
  });

  beforeEach(() => {
    fixture = TestBed.createComponent(PrimaryAutoCompleteComponent);
    component = fixture.componentInstance;
    component.ngOnInit();
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
});

When I run the test file, I get this. Error: NG0201: No provider for NgControl found in NodeInjector. Find more at https://angular.io/errors/NG0201.
What is the right way to test such a component?
Any help is appreciated.


text:
Q: How to construct PDOStatement class? I am writing a PDO extension. I would like prepare method of PDO to not call upon its parent and instead construct the PDOStatement of its own.
class Foo extends \PDO {
    public function prepare ($statement, $driver_options = []) {
        // return parent::prepare($statement, $driver_options);
        // What does parent::prepare do?
    }
}

It appears that PDO prepare method simply constructs PDOStatement instance, but then PDOStatement constructor does not have all the parameters that I would expect there (the statement itself, etc).
How to write PDO prepare method in user-land?
Note that I am aware about the presence of the PDO::ATTR_STATEMENT_CLASS and that it can be used to name the PDOStatement class to construct. I am interested whether that PDOStatement can be constructed in the user-land.

A: You can't instantiate a PDOStatement directly. It's hard-coded to disallow it.
I find this in the PHP 5.5 source, in ext/pdo/pdo_stmt.c:
static PHP_FUNCTION(dbstmt_constructor) /* {{{ */
{
        php_error_docref(NULL TSRMLS_CC, E_ERROR, "You should not create a PDOStatement manually");
}
/* }}} */

You should create a PDOStatement by calling PDO::query() or PDO::prepare().
It's not clear from your question why you would need to instantiate a PDOStatement directly. I think you need to rethink your goals.


text:
Q: Setting up eclipse for maya 2013 I followed this instructions:
http://www.luma-pictures.com/tools/pymel/docs/1.0/eclipse.html
Also have read the Maya's documentation:
http://download.autodesk.com/global/docs/maya2013/en_us/files/Python_Python_from_an_external_interpreter.htm#
And now I can successfully import and initialize Maya Standalone and
Cmds module.
BUT, as I try to code something like 'cmds.polyCube()', first I don't have any
auto completion and secondly Eclipse returns with an error saying that cmds module
Doesn't has any variable that named polyCube() etc....
Here is my exact procedure which I use to import and initialize maya inside Eclipse:
import maya.standalone
maya.standalone.initialize()

import maya
from maya import cmds

cmds.polyCube(n='cuby_01')
cmds.select('cuby_01')

A: Are you sure you followed this step from the pymel eclipse docs:

Click the "New Folder" button again, and add the site-packages directory you removed earlier. We did this in order to ensure that the
  stub maya package is found before the real maya package. When you're
  done, the main site-packages directory should be somewhere below the
  extras/completion/py folder you just added.

That is the important part for adding the stubs to your custom interpreter. In the end you should have a mayapy interpreter set up, with this added site-packages location. And also, make sure when you create a new pydev project, that you go into its specific properties and set the python interpreter to the mayapy that you set up. Otherwise you could still possibly be using the default python interp.

A: I wrote a little explanation here, how to add a mayapay interpreter here:
Eclipse environment for Maya's python modules
I'm pretty sure is this one your problem.
give a look and if you have any question don't hesitate to ask here again :)

A: You can also take a look at this tutorial:
http://www.creativecrash.com/tutorials/using-eclipse-as-a-maya-ide  (the most relevant portion is available on the 'page 2' tab in the linked page).  Basically, you need to point Eclipse's 'predefined' at the  /devkit/other/pymel/extras/completion/pypredef

Your sample should work correctly as long as (a) you're using a 2.6 interpreter and (b) you've got the maya python directory in your eclipse PYTHONPATH:

  Its usually easiest to configure eclipse to use /bin/mayapy.exe as the intepreter for maya.  You might find it easier to use
import maya.standalone
maya.standalone.initialize()
import maya.cmds as cmds
pc = cmds.polyCube()

the cmds module imports as empty UNLESS you've already initialized maya.standalone - your sample shows that but perhaps you got that error in an earlier run without standalone.initialize()?


text:
Q: Convert Leads Trigger Strange OwnerId Behavior I have some code that automatically converts leads when certain conditions are met using the convertLead() method. This process is fairly well-documented in threads such as this:
Convert Lead on Update trigger
and this works just fine for the most part. However, I'm noticing some strange behavior regarding the owner the newly created contact. For a brief moment in time, the owner of the contact that results from the lead being converted is the user that causes the trigger to fire rather than the owner of the lead.
Even more strangely, the contact eventually ends up being owned by the lead owner, but when before/after insert triggers and workflow rules fire on the Contact, the ownerid is the executing user.
I plan to open a case with support about this as well, but wondered if anyone had encountered anything like this or found a solution/workaround.

A: According to the documentation, unless you specify the owner with the SetOwnerid method, the owner of the newly created objects will be the owner of the Lead.  There are a number of idiosyncrasies around Apex based lead conversion, especially regarding the record owner, and the order of execution.  But, I have a lot of success in doing the conversion in an after insert/after update trigger and doing my own merging and ownership setting.


text:
Q: creating trigger inserting UNIX_TIMESTAMP() to a log table Hi im stuck on the syntax of making this trigger to insert values to my log table. Using the sql tab inside phpmyadmin an error appears before executing the sql statement
`#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 8 `

here is my sql statement in creating a trigger
CREATE TRIGGER after_insert_list
AFTER INSERT ON list FOR EACH ROW
BEGIN
    INSERT INTO log (user_id, action, date_log)
    VALUES (
        NEW.user_id,
        NEW.action,
        UNIX_TIMESTAMP()
    );
END

A: Create your trigger like follows:
delimiter |
CREATE TRIGGER testref
BEFORE INSERT ON test1FOR EACH ROW BEGIN
INSERT INTO test2 SET a2 = NEW.a1;
DELETE FROM test3 WHERE a3 = NEW.a1;
UPDATE test4 SET b4 = b4 + 1 WHERE a4 = NEW.a1;
END;
|
delimiter ;

A: Here is a 100% working example:
Table demo
CREATE TABLE `demo` (
    `id` int NOT NULL AUTO_INCREMENT,
    `text` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
    `updated_at` int NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`)
);

Trigger on INSERT
DELIMITER ;;
CREATE TRIGGER `updated_at__on_insert`
BEFORE INSERT
ON `demo`
FOR EACH ROW
BEGIN
   SET new.updated_at = UNIX_TIMESTAMP();
END;;
DELIMITER ;

Trigger on UPDATE
DELIMITER ;;
CREATE TRIGGER `updated_at__on_update`
BEFORE UPDATE
ON `demo`
FOR EACH ROW
BEGIN
   SET new.updated_at = UNIX_TIMESTAMP();
END;;
DELIMITER ;

p.s. I was looking for such a solution for my CMS EFFCORE.


text:
Q: EF6: Many-to-many relationship returning empty collections I've been trying to figure this out for the past 3 hours, and I'm sure I'm missing something very obvious...
Here is the model code:
[Table("company")]
public partial class company
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
    public company()
    {
        job = new HashSet<job>();
        contact = new HashSet<contact>();
    }

    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int companyId { get; set; }

    [Required]
    [StringLength(255)]
    public string name { get; set; }

    [StringLength(255)]
    public string address { get; set; }

    [StringLength(255)]
    public string locality { get; set; }

    [StringLength(255)]
    public string city { get; set; }

    [StringLength(100)]
    public string state { get; set; }

    [StringLength(16)]
    public string postalCode { get; set; }

    [StringLength(2)]
    public string country { get; set; }

    [StringLength(16)]
    public string phone { get; set; }

    [StringLength(63)]
    public string email { get; set; }

    [StringLength(127)]
    public string website { get; set; }

    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
    public virtual ICollection<job> job { get; set; }

    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
    public virtual ICollection<contact> contact { get; set; }
}

[Table("contact")]
public partial class contact
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
    public contact()
    {
        this.company = new HashSet<company>();
    }
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int contactId { get; set; }

    [Required]
    [StringLength(64)]
    public string firstName { get; set; }

    [Required]
    [StringLength(64)]
    public string lastName { get; set; }

    [StringLength(1)]
    public string middleInitial { get; set; }

    public string title { get; set; }

    [StringLength(18)]
    public string phoneNumber { get; set; }

    [StringLength(128)]
    public string emailAddress { get; set; }

    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
    public virtual ICollection<company> company { get; set; }
}

[Table("job")]
public class job
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
    public job()
    {
        company = new HashSet<company>();
    }

    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int jobId { get; set; }

    public string jobTitle { get; set; }

    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
    public virtual ICollection<company> company { get; set; }

}

And in OnModelCreating I have this:
modelBuilder.Entity<company>()
    .HasMany(e => e.job)
    .WithMany(e => e.company)
    .Map(m => m.ToTable("company_job", "dbo").MapLeftKey("companyId").MapRightKey("jobId"));

modelBuilder.Entity<company>()
    .HasMany(e => e.contact)
    .WithMany(e => e.company)
    .Map(m => m.ToTable("company_contact", "dbo").MapLeftKey("companyId").MapRightKey("contactId"));

I've checked all of the following on the database end:

*

*All three main tables exist and match the model column-for-column.

*All foreign key relationships to the bridge tables exist.

*Both bridge tables have a composite primary key consisting of the two columns.

*Both bridge tables are named matching the Map method parameters, as do the columns in the bridge tables.

*The database has appropriate data that should cause job and contact entities to appear under all company entities.

*Manually written queries to the database do succeed in producing the expected data.

However:
ctx.company.Where(x => x.companyId == 300).job.Count()

always returns 0. Trying:
ctx.company.Where(x => x.companyId == 300).job.FirstOrDefault()

returns null.
I tried setting up logging on the context:
Database.Log = msg => System.Diagnostics.Debug.WriteLine(msg);

And I noticed that the only queries ever sent to the database are for the company table. It doesn't do a join query. It never even touches the job or contact tables, or the bridge tables. It simply makes a single query to the company table with the correct WHERE clause but never goes further.
Just for kicks I tried reversing the order of the fields in the .Map call, but that had no effect. (in other words: .Map(m => m.ToTable("company_job", "dbo").MapLeftKey("jobId").MapRightKey("companyId")) didn't change things.)
Ok, what am I missing?

A: ACK...
In the context constructor was this:
base.Configuration.ProxyCreationEnabled = false;

I removed it and it seems to work now!
(I inherited this code, so the lesson here is: never assume that code you inherit does exactly what you think it'll do!)


text:
Q: Merging application icon into .exe file I'm using WineHQ on Debian 10 and it is running totally fine with many Windows programs. However Wine cannot show the right application icon (it always shows only a generic icon for .exe applications).
I wonder if there is a way to restore the right icon or if there is a way to permanently link another icon to this particular program.
For example, I'm playing FO2 and it would be cool to link .exe file to the icon which is stored in the same folder and every time I move the game to another directory it will keep the same icon.
I had the same problem with .mp3 files where I wanted to change the default audio icon. I solved that with program called Puddletag which merges images into the original .mp3 file. Is there something similar for .exe programs?

A: Windows applications typically already have icons embedded in the .exe files; what's missing here is probably a program to extract the icons and make corresponding thumbnails.
Installing the exe-thumbnailer package should fix this.

A: Did not test yet, however, as an alternative to Stephen's answer (exe-thumbnailer is suggested to wine package), could create a .desktop shortcut with icon property, exported with icoutils package and e.g. manual prefix.
$ wrestool -x -t 14 app.exe > "$HOME/.icons/app.ico"

$ cat > ~/app.desktop << EOF
[Desktop Entry]
Name=An App
Exec=env WINEPREFIX="$HOME/.wine" wine-stable 'C:\Program Files (x86)\...\app.exe'
Type=Application
StartupNotify=true
Path="$HOME/.wine/dosdevices/c:/Program Files (x86)/..."
Icon="$HOME/.icons/app.ico"
StartupWMClass=app.exe
EOF

$ chmod +x ~/app.desktop


text:
Q: The error message was : 'error:brokencount>0'. this usually means that your installed packages have unmet dependecies I have tried
sudo apt-get update (it is working fine)
After that when i do sudo apt-get upgrade this error is displaying:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 mariadb-server-10.3 : Depends: mariadb-client-10.3 (>= 1:10.3.34+maria~focal) but 1:10.3.34-0ubuntu0.20.04.1 is installed
 mariadb-server-core-10.3 : Breaks: mariadb-client-10.3 (< 1:10.3.34+maria~focal) but 1:10.3.34-0ubuntu0.20.04.1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

I tried this command
sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  chromium-codecs-ffmpeg-extra gstreamer1.0-vaapi libconfig-inifiles-perl
  libgstreamer-plugins-bad1.0-0 libva-wayland2
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  mariadb-client-10.3 mariadb-client-core-10.3
The following packages will be upgraded:
  mariadb-client-10.3 mariadb-client-core-10.3
2 upgraded, 0 newly installed, 0 to remove and 139 not upgraded.
4 not fully installed or removed.
Need to get 0 B/1,866 kB of archives.
After this operation, 20.1 MB disk space will be freed.
Do you want to continue? [Y/n] y
dpkg: regarding .../mariadb-client-core-10.3_1%3a10.3.34+maria~focal_amd64.deb c
ontaining mariadb-client-core-10.3:
 mariadb-client-10.3 conflicts with mysql-client-core-5.5
  mariadb-client-core-10.3 provides mysql-client-core-5.5 and is to be installed
.

dpkg: error processing archive /var/cache/apt/archives/mariadb-client-core-10.3_
1%3a10.3.34+maria~focal_amd64.deb (--unpack):
 conflicting packages - not installing mariadb-client-core-10.3
dpkg: regarding .../mariadb-client-10.3_1%3a10.3.34+maria~focal_amd64.deb contai
ning mariadb-client-10.3:
 mariadb-client-core-10.3 conflicts with mysql-client-5.5
  mariadb-client-10.3 provides mysql-client-5.5 and is to be installed.

dpkg: error processing archive /var/cache/apt/archives/mariadb-client-10.3_1%3a1
0.3.34+maria~focal_amd64.deb (--unpack):
 conflicting packages - not installing mariadb-client-10.3
Errors were encountered while processing:
 /var/cache/apt/archives/mariadb-client-core-10.3_1%3a10.3.34+maria~focal_amd64.
deb
 /var/cache/apt/archives/mariadb-client-10.3_1%3a10.3.34+maria~focal_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)


text:
Q: Как изменить ответ REST в yii2 Как можно изменить ответ после того как отправил запрос. К примеру POST, на добавление записи. Как изменить что когда добавит запись, вернет собственный ответ.

A: В ActiveController можно прописать вот это
public function actions()
{
    $actions = parent::actions();
    unset($actions['create']);
    return $actions;
}

public function actionCreate(){
    //То что нужно возвращать.
}


text:
Q: Purpose of SQLAlchemy over MySQLdb Why do people use SQLAlchemy instead of MySQLdb? What advantages does it offer?

A: In addition to what Alex said...

*

*"Not wanting to learn SQL" is probably a bad thing. However, if you want to get more people who want to avoid SQL involved as part of the development process, ORMs do a pretty good job at it because it abstracts away "raw SQL," pushing that level of complexity down a notch. One of the elements that has made Django successful is its ability to let "newspaper journalists" maintain a website, rather than software engineers.

*One of the limitations of ORMs is that they are not as scalable as using raw SQL. At a previous job, we wanted to get rid of a lot of manual SQL generation and switched to an ORM for ease-of-use (SQLAlchemy, Elixir, etc.), but months later, I ended up having to write raw SQL again to get around the inefficient or high latency queries that were generated by the ORM system.

A: You don't use SQLAlchemy instead of MySQLdb—you use SQLAlchemy to access something like MySQLdb, oursql (another MySQL driver that I hear is nicer and has better performance), the sqlite3 module, psycopg2, or whatever other database driver you are using.
An ORM (like SQLAlchemy) helps abstract away the details of the database you are using. This allows you to keep from the miry details of the database system you're using, avoiding the possibility of errors some times (and introducing the possibility of others), and making porting trivial (at least in theory).

A: Easier portability among different DB engines (say that tomorrow you decide you want to move to sqlite, or PostgreSQL, or...), and higher level of abstraction (and thus potentially higher productivity).
Those are some of the good reasons.  There are also some bad reasons for using an ORM, such as not wanting to learn SQL, but I suspect SQLAlchemy in particular is not really favored by people for such bad reasons for wanting an ORM rather than bare SQL;-).


text:
Q: Is the energy coming from sun to earth completely sent back? So energy comes to earth from sun in the form of EM waves. Some of it is reflected back but some of it remains on earth and is used by plants to create food and some is used in the atmosphere creating storms. But how is this energy sent back to space?
If it is not sent back, then does it mean that the total energy on earth as a whole is continuously increasing?

A: There are mainly two mechanisms that send radiation back into space: reflection and emission. In the first case, electromagnetic waves coming from the sun are simply reflected, with the same high frequency. This is due mainly to clouds, that in this respect contribute to cooling the earth's temperature. The fraction of the incoming light that is reflected by a planet (or any other object) is called albedo. For the earth, it is about $0.3$, which means that about $30\%$ percent of all the energy from the sun is already reflected into space by reflection (this is a rough estimate, different parts of the earth have different albedos: oceans and forests have a lower one, poles a higher one and so on).
What is left can be absorbed and then re-emitted with a lower frequency as thermal radiation (typically in the infrared). As far as emission is concerned, we have to take into account the effect of the atmosphere (for example, the ozone layer subtracts energy, absorbing the higher frequencies), of the surface and of clouds (apart from reflection, they also absorb the radiation emitted by the surface; part of it is emitted again toward the surface and part out into space - the mechanism is complicated and typically depends on the difference in temperatures between the top and the bottom of a cloud, the type of particles in the clouds and so on). The net effect is that the atmosphere raises temperatures on earth (without the atmosphere, the average temperature would be $-19$ degrees celsius or so). But in the long run (apart from what Ron mentioned), all the energy is re-emitted into space. This may seem paradoxical, but as pointed out for example by R.Penrose, what really matters for life is that the sun is a hot spot in an otherwise dark sky (it is a source of low-entropy energy: yellow energetic photons are absorbed by the earth and emitted in the infrared in larger numbers; this means more degrees of freedom, more volume occupied in phase space or more entropy).

A: It is all sent back eventually, mostly at wavelengths comparable to infrared. The only residual energy stored is where there is an increasing amount of organic material (produced from solar energy) deposited in riverbeds and seabeds, which is greater than the material breaking down at the bottommost layer of the bottom organic layers. If the organic layers at the bottom of the ocean are in a steady state, neither increasing in total mass or decreasing in total mass, the amount breaking down at the bottom and releasing heat is equal to the new material placed on top.
The reason is what you say--- the Earth doesn't have anywhere to store the energy in steady state. The Earth radiates slightly more energy than it recieves, since there are radioactive materials in the core.


text:
Q: Draw rectangle in circle with remains colored in different colours I need to draw a circle in which I must place a square with corners touching circle line.
After that, four part that remains must be colored with different colors.
Colors of square is not important.

A: Try something like this out:
Public Class Form1

    Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
        Dim radius As Integer = 100
        Dim center As New Point(125, 125)
        Dim Y As Integer = radius * Math.Sin(45 * Math.PI / 180)
        Dim X As Integer = radius * Math.Cos(45 * Math.PI / 180)
        Dim centerRC As New Rectangle(center.X - X, center.Y - Y, X * 2, Y * 2)
        Dim ellipseRC As New Rectangle(center.X - radius, center.Y - radius, radius * 2, radius * 2)

        e.Graphics.ExcludeClip(centerRC)
        e.Graphics.FillPie(Brushes.Red, ellipseRC, 225, 90)
        e.Graphics.FillPie(Brushes.Green, ellipseRC, -45, 90)
        e.Graphics.FillPie(Brushes.Blue, ellipseRC, 45, 90)
        e.Graphics.FillPie(Brushes.White, ellipseRC, 135, 90)
    End Sub

End Class

Result:


text:
Q: Null Pointer Exception in CustomAdapter Hi i am getting a null pointer exception while running my application..
Here is my code :
ProductAdapter.java
public class ProductAdapter extends BaseAdapter {

    Context context;
    List<Product> products = new ArrayList<Product>();
    private boolean showCheckbox;

    public ProductAdapter(Context context, List<Product> products,
            boolean showCheckbox) {
        super();
        this.context = context;
        this.products = products;
        this.showCheckbox = showCheckbox;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return products.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return products.get(position);
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if(convertView == null){
            LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            inflater.inflate(R.layout.new_item, null);
        }

        Product myProduct = products.get(position);

        TextView title = (TextView) convertView.findViewById(R.id.txt_title);
        title.setText(myProduct.getTitle());

        TextView cost = (TextView) convertView.findViewById(R.id.txt_cost);
        cost.setText(myProduct.getCost());

        ImageView image = (ImageView) convertView.findViewById(R.id.imageView1);
        CheckBox selectBox = (CheckBox) convertView.findViewById(R.id.CheckBoxSelect1);

        if(!showCheckbox){
            selectBox.setVisibility(View.GONE);
        }
        else{
            if(myProduct.selected == true)
                selectBox.setChecked(true);
            else
                selectBox.setChecked(false);
        }

        return convertView;
    }
}

Here is my layout xml file
new_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/txt_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/txt_cost"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <CheckBox
        android:id="@+id/CheckBoxSelect1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>

Here i am getting a nullpointer exception please help me out.
Here is my logcat.
09-26 16:37:23.894: D/AndroidRuntime(2611): Shutting down VM
09-26 16:37:23.894: W/dalvikvm(2611): threadid=1: thread exiting with uncaught exception (group=0x409951f8)
09-26 16:37:23.904: E/AndroidRuntime(2611): FATAL EXCEPTION: main
09-26 16:37:23.904: E/AndroidRuntime(2611): java.lang.NullPointerException
09-26 16:37:23.904: E/AndroidRuntime(2611):     at com.shoppingcart.ProductAdapter.getView(ProductAdapter.java:59)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.widget.AbsListView.obtainView(AbsListView.java:2033)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.widget.ListView.makeAndAddView(ListView.java:1772)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.widget.ListView.fillDown(ListView.java:672)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.widget.ListView.fillFromTop(ListView.java:732)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.widget.ListView.layoutChildren(ListView.java:1625)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.widget.AbsListView.onLayout(AbsListView.java:1863)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.view.View.layout(View.java:11158)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.view.ViewGroup.layout(ViewGroup.java:4197)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.view.View.layout(View.java:11158)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.view.ViewGroup.layout(ViewGroup.java:4197)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.view.View.layout(View.java:11158)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.view.ViewGroup.layout(ViewGroup.java:4197)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.view.View.layout(View.java:11158)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.view.ViewGroup.layout(ViewGroup.java:4197)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.view.View.layout(View.java:11158)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.view.ViewGroup.layout(ViewGroup.java:4197)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1462)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2382)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.os.Looper.loop(Looper.java:137)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at android.app.ActivityThread.main(ActivityThread.java:4340)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at java.lang.reflect.Method.invokeNative(Native Method)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at java.lang.reflect.Method.invoke(Method.java:511)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-26 16:37:23.904: E/AndroidRuntime(2611):     at dalvik.system.NativeStart.main(Native Method)

Thank You.
here is my Logcat.
09-26 16:58:35.205: D/AndroidRuntime(2749): Shutting down VM
09-26 16:58:35.205: W/dalvikvm(2749): threadid=1: thread exiting with uncaught exception (group=0x409951f8)
09-26 16:58:35.225: E/AndroidRuntime(2749): FATAL EXCEPTION: main
09-26 16:58:35.225: E/AndroidRuntime(2749): java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.ImageView
09-26 16:58:35.225: E/AndroidRuntime(2749):     at com.shoppingcart.ProductAdapter.getView(ProductAdapter.java:66)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.widget.AbsListView.obtainView(AbsListView.java:2033)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.widget.ListView.makeAndAddView(ListView.java:1772)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.widget.ListView.fillDown(ListView.java:672)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.widget.ListView.fillFromTop(ListView.java:732)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.widget.ListView.layoutChildren(ListView.java:1625)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.widget.AbsListView.onLayout(AbsListView.java:1863)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.view.View.layout(View.java:11158)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.view.ViewGroup.layout(ViewGroup.java:4197)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.view.View.layout(View.java:11158)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.view.ViewGroup.layout(ViewGroup.java:4197)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.view.View.layout(View.java:11158)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.view.ViewGroup.layout(ViewGroup.java:4197)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.view.View.layout(View.java:11158)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.view.ViewGroup.layout(ViewGroup.java:4197)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.view.View.layout(View.java:11158)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.view.ViewGroup.layout(ViewGroup.java:4197)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1462)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2382)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.os.Looper.loop(Looper.java:137)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at android.app.ActivityThread.main(ActivityThread.java:4340)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at java.lang.reflect.Method.invokeNative(Native Method)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at java.lang.reflect.Method.invoke(Method.java:511)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-26 16:58:35.225: E/AndroidRuntime(2749):     at dalvik.system.NativeStart.main(Native Method)

A: Assign inflated xml file to convertView when its null for the first time.
if(convertView == null){
        LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.new_item, null);
    }

A:  public View getView(int position, View convertView, ViewGroup parent) {

        if(convertView == null){
            LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            inflater.inflate(R.layout.new_item, null);
        }

change above code to as below

  public View getView(int position, View convertView, ViewGroup parent) {
            LinearLayout rowLayout = null;
            if (rowLayout == null) {
                    rowLayout = (LinearLayout) LayoutInflater.from(context)
                            .inflate(R.layout.new_item, parent, false);
                }
 Product myProduct = products.get(position);

        TextView title = (TextView) rowLayout.findViewById(R.id.txt_title);
        title.setText(myProduct.getTitle());

        TextView cost = (TextView) rowLayout.findViewById(R.id.txt_cost);
        cost.setText(myProduct.getCost());

        ImageView image = (ImageView) rowLayout.findViewById(R.id.imageView1);
        CheckBox selectBox = (CheckBox) rowLayout.findViewById(R.id.CheckBoxSelect1);

        if(!showCheckbox){
            selectBox.setVisibility(View.GONE);
        }
        else{
            if(myProduct.selected == true)
                selectBox.setChecked(true);
            else
                selectBox.setChecked(false);
        }

        return rowLayout;
    }
}


text:
Q: Can't find Ceph when install on CentOS I can't install Ceph on my centos 7 system.
The error message is like:
node.example.com][DEBUG ] This system is not registered with an entitlement server. You can use subscription-manager to register.

[node.example.com][DEBUG ] Determining fastest mirrors
[node.example.com][DEBUG ] No package ceph available.
[node.example.com][DEBUG ] No package ceph-osd available.
[node.example.com][DEBUG ] No package ceph-mds available.
[node.example.com][DEBUG ] No package ceph-mon available.
[node.example.com][DEBUG ] No package ceph-radosgw available.
[node.example.com][WARNIN] Error: Nothing to do
[node.example.com][ERROR ] RuntimeError: command returned non-zero exit status: 1 [ceph_deploy][ERROR ] RuntimeError: Failed to execute command: yum -y install ceph ceph-osd ceph-mds ceph-mon ceph-radosgw

A: Below command install ceph mimic version 13.2
 ceph-deploy install  cephmon02 cephmon03  --repo-url=http://mirrors.aliyun.com/ceph/rpm-mimic/el7/

Changed mimic to another version.

A: You need to install the ceph repo. first.
Refer the below link:
# yum install centos-release-ceph-jewel

# yum install ceph-{mon,osd,...}

https://wiki.centos.org/SpecialInterestGroup/Storage


text:
Q: Applying JavaScript "Counter" object This question is derived from a previous question.
JavaScript "Counter" object, what is it?
@Gyum Fox noticed that Webkit, Firefox and Chrome define a global variable called "Counter" in the window.
After much research and little information I was lead to believe the "Counter Variable" is for garbage collection; counting the number of references to any given data and returning an accurate pointer to any objects it was still tied to. Based on this Link.
http://blog.peschla.net/doxygen/v8_chromium_r157275/v8-counters_8h.html
I am too green to fully understand. My question is, why did they choose to expose this Global "Counter" object and What benefits could this object provide over alternative methods???


text:
Q: Rails Logger with shift_age = 'daily' does not rotate when size of the file is small I am using Rails Logger with shift_age = 'daily', looks like it does not rotate the log file when the size is small or if logs do not populate daily.
It works fine in my production environment, but in staging environment it does not rotate, below is my code.
FileUtils.touch(Rails.root.join('log/custom_log.json'))
@@custom_logger = Logger.new(Rails.root.join('log/custom_log.json'), shift_age = 'daily')

A: Does this work?
FileUtils.touch(Rails.root.join('log', 'custom_log.json'))
@@custom_logger = Logger.new(Rails.root.join('log',
'custom_log.json'), 'daily')

This example from the docs might also work:
file = File.open(Rails.root.join('log', 'custom_log.json'), File::WRONLY | File::APPEND | File::CREAT)
logger = Logger.new(file)

Also note that most log examples seem to create files with the .log file format.


text:
Q: Connection pooling - closed connection issue Problems:
I have a web app that is getting battered. Everything is working but I get about two errors a day I can not explain. It could be the first user hitting the system because the error appears in the error log intermittently it occurred today around 7:30 am in servers time zone (same as the users).
I fixed an old issue by implicitly destroying the connection by way of the using statement as it only marks the connection as recyclable.
Error Log:
Message: 3df8d62a-6b47-479e-b5d2-b23e0db92d92 : System.InvalidOperationException: Invalid operation. The connection is closed.
 at System.Data.SqlClient.SqlConnection.GetOpenConnection()
 at System.Data.SqlClient.SqlConnection.get_ServerVersion()
 at System.Data.Linq.SqlClient.SqlProvider.get_IsServer2005()
 at System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode()
 at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
 at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
 at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source)
 at xxxxx.Resources.Data.LINQ.DistrictService.GetDistrict(Int32 districtID)

Related Code:
//--------------------------------------------------------------------------------------------
        public Domain.Data.District GetDistrict(int districtID)
        {
            using (_dataContext = new DistrictDataDataContext(_systemService.GetCurrentSystem().WriteOnlyDatabase.ConnectionString))
            {
                Mapper.CreateMap<District, Domain.Data.District>();
                return (from s in _dataContext.Districts
                        where s.DistrictID == districtID
                        select Mapper.Map<District, Domain.Data.District>(s)).SingleOrDefault();
            }
        }

Note:
I think that this is a non-issue because the inherent behavior of the connection pooling might be firing a retry (this could just be information saying "hey we tried what you asked for but the connection was closed, we will now open one up it.") however, If this is the case, I do not get a confirmation of successful retry and I am not even sure would be expected. We have had no complaints and this cant be duplicated in house by our QA staff. I hope maybe someone else has come across this.


text:
Q: How to split a very long string column in Pandas? I have a (very) long single dataframe column and want to split it into multiple columns to make a regular DataFrame out of it. I've tried
.tolist()
zip()
str.extract()
.str.split()
expand=True

which always results in some errors.
Dataframe infos:
df.info()

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 3150708 entries, 0 to 3150707
Data columns (total 1 columns):
 #   Column                                                                                Dtype
---  ------                                                                                -----
 0   CAL_DT,MODEL_NAME,BRAND_FULL_NAME,BRAND_NAME,VENDOR_NAME,OS_NAME,DEVICE_TYPE,_2G_FLG,_3G_FLG,_4G_FLG,WIFI_FLG,BLUETOOTH_FLG,TOUCH_SCREEN_FLG,DUAL_SIM_FLG,GENDER_TYPE_CD,AGE_B,NATIONALITY_CD,NATIONALITY_NAME,SAUDI_NON_SAUDI,DEVICE_COUNT  object
dtypes: object(1)
memory usage: 24.0+ MB

A: If only splitting values of first column use:
df1 = df.iloc[:, 0].str.split(',', expand=True)

If possible assign back splitted first column, here not, because different length of len(df1.columns) and len(df.columns[0].split(',')):
df1.columns = df.columns[0].split(',')


text:
Q: I can't make useEffect read input properly on conditional render I'm trying to create an input component with a 'static' mode. In this mode the input gets replaced by a span containing the input value. In this question I use a range input.
import React from 'react';
import ReactDOM from 'react-dom';

const { useState, useEffect, } = React;

const RangeInput = ({
  inputID, min, max, defaultValue, children,
}) => {
  const [valueAfterStaticChange, setValueAfterStaticChange] = useState(
    defaultValue
  );
  const [isStatic, setIsStatic] = useState(false);
  useEffect(
    () => () => {
      // do this before component unmounts and when 'isStatic' changes,
      // but only when 'isStatic' is true
      isStatic
        || setValueAfterStaticChange(document.getElementById(inputID).value);
    },
    [isStatic]
  );
  return (

      {children}

        {valueAfterStaticChange}

      <input
        type="range"
        min={min}
        max={max}
        defaultValue={valueAfterStaticChange}
        id={inputID}
        style={{ display: isStatic && 'none', }}
      />
      <button
        onClick={() => {
          setIsStatic(!isStatic);
        }}
      >
        Toggle Static
      </button>

  );
};

ReactDOM.render(
  <RangeInput inputID="myID" min={0} max={100} defaultValue={50}>
    My Range Input
  </RangeInput>,
  document.getElementById('root')
);

The above code works. But it uses display: none to simulate a 'no render'. I thought that I could accomplish actual unmounting with the following logic:
// all unchanged until...

  return (

      {children}
      {isStatic ? (
        {valueAfterStaticChange}
      ) : (
        <input
          type="range"
          min={min}
          max={max}
          defaultValue={valueAfterStaticChange}
          id={inputID}
        />
      )}
      <button
        onClick={() => {
          setIsStatic(!isStatic);
        }}
      >
        Toggle Static
      </button>

  );
};

Somehow my useEffect return function won't read the input properly now that it actually unmounts. I thought that using the return function in useEffect would result in a function that would run just before the component unmounts. What am I doing wrong?

A: Naturally, you can't access document.getElementById(inputID).value if the <input> element isn't mounted - it doesn't exist! And even it did, you wouldn't want to read its value that way. That is a very un-React way of doing things. React components should have everything they need in state and props - if you find yourself querying or acting upon the DOM directly, you are (almost always) going down a Dark Path.
Instead what you want is a controlled component.
A controlled component does not rely upon the DOM to store anything like a "value". Instead, the component merely displays whatever value that React has in state and provides a handy event hook.
I would highly, highly recommend that you read the docs that I linked and see if you can figure out an implementation on your own. That's the best way to learn after all! But if you still can't figure it out, I'll come back and edit my answer with a basic working example.
Edit: here is a simple working demo with some comments.
https://stackblitz.com/edit/controlled-input-demo?file=index.js
Note that it's actually quite simple! The <App> tracks the slider value in state, while the <RangeInput> simply consumes that value as a prop and provides an event handler for updating it back in <App>. <RangeSlider> can track its own "editing mode" value because other components probably would not need access to it (but you could "lift" that state up a level if you wanted!) You don't even need useEffect() here!

A: Unless there's a reason to get the value when you're unmounting, it seems like you could just keep track of the value as it changes. That way you wouldn't need useEffect at all:
const RangeInput = ({ inputID, min, max, defaultValue, children }) => {
  const [value, setValue] = useState(defaultValue); // <-- keep track of value
  const [isStatic, setIsStatic] = useState(false);

  return (

      {children}
      {isStatic ? (
        {value}
      ) : (
        <input
          type="range"
          min={min}
          max={max}
          defaultValue={value}
          onChange={e => setValue(e.target.value)} // <-- Set value onChange
          id={inputID}
        />
      )}
      <button
        onClick={() => {
          setIsStatic(!isStatic);
        }}
      >
        Toggle Static
      </button>

  );
};


text:
Q: Using custom types with Gorilla sessions I am trying to use gorilla sessions in Golang to store session data. I have found that I can store slices of strings ([]strings) but I cannot store slices of custom structs ([]customtype). I was wondering if anyone had this problem and if there was any fix for it.
I can run sessions fine and get other variables that are not slices of custom structs I have stored fine. I even am able to pass the correct variables to session.Values["variable"] but when I do session.Save(r, w) it seems to not save the variable.
EDIT: Found the solution. Will edit once I get full understanding.

A: Solved this one.
You need to register the gob type so that sessions can use it.
Ex:
import(
"encoding/gob"
"github.com/gorilla/sessions"
)

type Person struct {

FirstName    string
LastName     string
Email        string
Age            int
}

func main() {
   //now we can use it in the session
   gob.Register(Person{})
}

func createSession(w http.ResponseWriter, r *http.Request) {
   //create the session
   session, _ := store.Get(r, "Scholar0")

   //make the new struct
   x := Person{"Bob", "Smith", "Bob@Smith.com", 22}

   //add the value
   session.Values["User"] = x

   //save the session
   session.Save(r, w)
}

A: What is not explicitly stated (but makes sense in hindsight) is that you must have  exported fields (i.e type Person struct { Name ... vs type Person struct { name) otherwise serialisation won't work as gob can't access the fields.

A: I understand that this has been answered already. However, for reference purposes on the setup and retrieval of an object in a session, please see below code.
package main

import (
    "encoding/gob"
    "fmt"
    "net/http"
    "github.com/gorilla/securecookie"
    "github.com/gorilla/sessions"
)

var store = sessions.NewCookieStore(securecookie.GenerateRandomKey(32))

type Person struct {
    FirstName string
    LastName string
}

func createSession(w http.ResponseWriter, r *http.Request) {
    gob.Register(Person{})

    session, _ := store.Get(r, "session-name")

    session.Values["person"] = Person{"Pogi", "Points"}
    session.Save(r, w)

    fmt.Println("Session initiated")
}

func getSession(w http.ResponseWriter, r *http.Request) {
    session, _ := store.Get(r, "session-name")
    fmt.Println(session.Values["person"])
}

func main() {
    http.HandleFunc("/1", createSession)
    http.HandleFunc("/2", getSession)

    http.ListenAndServe(":8080", nil)
}

You can access this via:
http://localhost:8080/1 -> session value setup
http://localhost:8080/2 -> session value retrieval

Hope this helps!


text:
Q: Estimating impact of indexes SQLite database size I'm trying to estimate the database size (on disk) for a SQLite DB that includes a number of indexed columns. These columns are of (SQLite) type Integer and String. It's straightforward enough to estimate the size per row with these columns, but I'm not sure how to account for the extra per-row padding due to the indexes. What's the best approach for this?

A: At least some of the details of index B-trees are documented.
It might be easier to just create a test database, populate it, and measure the file size before and after creating an index.


text:
Q: Android Sdk MediaPlayer method implementation.Unfortunately App Has Stopped 04-16 16:26:25.238: D/dalvikvm(619): GC_FOR_ALLOC freed 56K, 5% free 2847K/2976K, paused 39ms, total 42ms
04-16 16:26:25.248: I/dalvikvm-heap(619): Grow heap (frag case) to 3.319MB for 495952-byte allocation
04-16 16:26:25.318: D/dalvikvm(619): GC_FOR_ALLOC freed 3K, 4% free 3328K/3464K, paused 26ms, total 26ms
04-16 16:26:25.408: E/MediaPlayer(619): error (1, -2147483648)
04-16 16:26:25.418: D/MediaPlayer(619): create failed:
04-16 16:26:25.418: D/MediaPlayer(619): java.io.IOException: Prepare failed.: status=0x1
04-16 16:26:25.418: D/MediaPlayer(619):     at android.media.MediaPlayer.prepare(Native Method)
04-16 16:26:25.418: D/MediaPlayer(619):     at android.media.MediaPlayer.create(MediaPlayer.java:850)
04-16 16:26:25.418: D/MediaPlayer(619):     at com.example.buttona.Splash.onCreate(Splash.java:23)
04-16 16:26:25.418: D/MediaPlayer(619):     at android.app.Activity.performCreate(Activity.java:5231)
04-16 16:26:25.418: D/MediaPlayer(619):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-16 16:26:25.418: D/MediaPlayer(619):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2172)
04-16 16:26:25.418: D/MediaPlayer(619):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2270)
04-16 16:26:25.418: D/MediaPlayer(619):     at android.app.ActivityThread.access$800(ActivityThread.java:138)
04-16 16:26:25.418: D/MediaPlayer(619):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
04-16 16:26:25.418: D/MediaPlayer(619):     at android.os.Handler.dispatchMessage(Handler.java:102)
04-16 16:26:25.418: D/MediaPlayer(619):     at android.os.Looper.loop(Looper.java:136)
04-16 16:26:25.418: D/MediaPlayer(619):     at android.app.ActivityThread.main(ActivityThread.java:5042)
04-16 16:26:25.418: D/MediaPlayer(619):     at java.lang.reflect.Method.invokeNative(Native Method)
04-16 16:26:25.418: D/MediaPlayer(619):     at java.lang.reflect.Method.invoke(Method.java:515)
04-16 16:26:25.418: D/MediaPlayer(619):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:776)
04-16 16:26:25.418: D/MediaPlayer(619):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
04-16 16:26:25.418: D/MediaPlayer(619):     at dalvik.system.NativeStart.main(Native Method)
04-16 16:26:25.428: D/AndroidRuntime(619): Shutting down VM
04-16 16:26:25.428: W/dalvikvm(619): threadid=1: thread exiting with uncaught exception (group=0xb2a8cd58)
04-16 16:26:25.438: E/AndroidRuntime(619): FATAL EXCEPTION: main
04-16 16:26:25.438: E/AndroidRuntime(619): Process: com.example.buttona, PID: 619
04-16 16:26:25.438: E/AndroidRuntime(619): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.buttona/com.example.buttona.Splash}: java.lang.NullPointerException
04-16 16:26:25.438: E/AndroidRuntime(619):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2208)
04-16 16:26:25.438: E/AndroidRuntime(619):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2270)
04-16 16:26:25.438: E/AndroidRuntime(619):  at android.app.ActivityThread.access$800(ActivityThread.java:138)
04-16 16:26:25.438: E/AndroidRuntime(619):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
04-16 16:26:25.438: E/AndroidRuntime(619):  at android.os.Handler.dispatchMessage(Handler.java:102)
04-16 16:26:25.438: E/AndroidRuntime(619):  at android.os.Looper.loop(Looper.java:136)
04-16 16:26:25.438: E/AndroidRuntime(619):  at android.app.ActivityThread.main(ActivityThread.java:5042)
04-16 16:26:25.438: E/AndroidRuntime(619):  at java.lang.reflect.Method.invokeNative(Native Method)
04-16 16:26:25.438: E/AndroidRuntime(619):  at java.lang.reflect.Method.invoke(Method.java:515)
04-16 16:26:25.438: E/AndroidRuntime(619):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:776)
04-16 16:26:25.438: E/AndroidRuntime(619):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
04-16 16:26:25.438: E/AndroidRuntime(619):  at dalvik.system.NativeStart.main(Native Method)
04-16 16:26:25.438: E/AndroidRuntime(619): Caused by: java.lang.NullPointerException
04-16 16:26:25.438: E/AndroidRuntime(619):  at com.example.buttona.Splash.onCreate(Splash.java:24)
04-16 16:26:25.438: E/AndroidRuntime(619):  at android.app.Activity.performCreate(Activity.java:5231)
04-16 16:26:25.438: E/AndroidRuntime(619):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-16 16:26:25.438: E/AndroidRuntime(619):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2172)
04-16 16:26:25.438: E/AndroidRuntime(619):  ... 11 more
04-16 16:26:29.768: I/Process(619): Sending signal. PID: 619 SIG: 9
04-16 16:29:50.508: D/dalvikvm(669): GC_FOR_ALLOC freed 60K, 5% free 2847K/2980K, paused 110ms, total 113ms
04-16 16:29:50.508: I/dalvikvm-heap(669): Grow heap (frag case) to 3.319MB for 495952-byte allocation
04-16 16:29:50.578: D/dalvikvm(669): GC_FOR_ALLOC freed 3K, 5% free 3328K/3468K, paused 26ms, total 26ms
04-16 16:29:50.668: E/MediaPlayer(669): error (1, -2147483648)
04-16 16:29:50.678: D/MediaPlayer(669): create failed:
04-16 16:29:50.678: D/MediaPlayer(669): java.io.IOException: Prepare failed.: status=0x1
04-16 16:29:50.678: D/MediaPlayer(669):     at android.media.MediaPlayer.prepare(Native Method)
04-16 16:29:50.678: D/MediaPlayer(669):     at android.media.MediaPlayer.create(MediaPlayer.java:850)
04-16 16:29:50.678: D/MediaPlayer(669):     at com.example.buttona.Splash.onCreate(Splash.java:23)
04-16 16:29:50.678: D/MediaPlayer(669):     at android.app.Activity.performCreate(Activity.java:5231)
04-16 16:29:50.678: D/MediaPlayer(669):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-16 16:29:50.678: D/MediaPlayer(669):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2172)
04-16 16:29:50.678: D/MediaPlayer(669):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2270)
04-16 16:29:50.678: D/MediaPlayer(669):     at android.app.ActivityThread.access$800(ActivityThread.java:138)
04-16 16:29:50.678: D/MediaPlayer(669):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
04-16 16:29:50.678: D/MediaPlayer(669):     at android.os.Handler.dispatchMessage(Handler.java:102)
04-16 16:29:50.678: D/MediaPlayer(669):     at android.os.Looper.loop(Looper.java:136)
04-16 16:29:50.678: D/MediaPlayer(669):     at android.app.ActivityThread.main(ActivityThread.java:5042)
04-16 16:29:50.678: D/MediaPlayer(669):     at java.lang.reflect.Method.invokeNative(Native Method)
04-16 16:29:50.678: D/MediaPlayer(669):     at java.lang.reflect.Method.invoke(Method.java:515)
04-16 16:29:50.678: D/MediaPlayer(669):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:776)
04-16 16:29:50.678: D/MediaPlayer(669):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
04-16 16:29:50.678: D/MediaPlayer(669):     at dalvik.system.NativeStart.main(Native Method)
04-16 16:29:50.688: D/AndroidRuntime(669): Shutting down VM
04-16 16:29:50.688: W/dalvikvm(669): threadid=1: thread exiting with uncaught exception (group=0xb2a8cd58)
04-16 16:29:50.698: E/AndroidRuntime(669): FATAL EXCEPTION: main
04-16 16:29:50.698: E/AndroidRuntime(669): Process: com.example.buttona, PID: 669
04-16 16:29:50.698: E/AndroidRuntime(669): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.buttona/com.example.buttona.Splash}: java.lang.NullPointerException
04-16 16:29:50.698: E/AndroidRuntime(669):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2208)
04-16 16:29:50.698: E/AndroidRuntime(669):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2270)
04-16 16:29:50.698: E/AndroidRuntime(669):  at android.app.ActivityThread.access$800(ActivityThread.java:138)
04-16 16:29:50.698: E/AndroidRuntime(669):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
04-16 16:29:50.698: E/AndroidRuntime(669):  at android.os.Handler.dispatchMessage(Handler.java:102)
04-16 16:29:50.698: E/AndroidRuntime(669):  at android.os.Looper.loop(Looper.java:136)
04-16 16:29:50.698: E/AndroidRuntime(669):  at android.app.ActivityThread.main(ActivityThread.java:5042)
04-16 16:29:50.698: E/AndroidRuntime(669):  at java.lang.reflect.Method.invokeNative(Native Method)
04-16 16:29:50.698: E/AndroidRuntime(669):  at java.lang.reflect.Method.invoke(Method.java:515)
04-16 16:29:50.698: E/AndroidRuntime(669):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:776)
04-16 16:29:50.698: E/AndroidRuntime(669):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
04-16 16:29:50.698: E/AndroidRuntime(669):  at dalvik.system.NativeStart.main(Native Method)
04-16 16:29:50.698: E/AndroidRuntime(669): Caused by: java.lang.NullPointerException
04-16 16:29:50.698: E/AndroidRuntime(669):  at com.example.buttona.Splash.onCreate(Splash.java:24)
04-16 16:29:50.698: E/AndroidRuntime(669):  at android.app.Activity.performCreate(Activity.java:5231)
04-16 16:29:50.698: E/AndroidRuntime(669):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-16 16:29:50.698: E/AndroidRuntime(669):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2172)
04-16 16:29:50.698: E/AndroidRuntime(669):  ... 11 more
04-16 16:29:53.048: I/Process(669): Sending signal. PID: 669 SIG: 9
04-16 16:36:21.928: D/dalvikvm(715): GC_FOR_ALLOC freed 64K, 5% free 2847K/2984K, paused 43ms, total 46ms
04-16 16:36:21.928: I/dalvikvm-heap(715): Grow heap (frag case) to 3.319MB for 495952-byte allocation
04-16 16:36:22.008: D/dalvikvm(715): GC_FOR_ALLOC freed 2K, 5% free 3328K/3472K, paused 29ms, total 29ms
04-16 16:36:22.118: E/MediaPlayer(715): error (1, -2147483648)
04-16 16:36:22.128: D/MediaPlayer(715): create failed:
04-16 16:36:22.128: D/MediaPlayer(715): java.io.IOException: Prepare failed.: status=0x1
04-16 16:36:22.128: D/MediaPlayer(715):     at android.media.MediaPlayer.prepare(Native Method)
04-16 16:36:22.128: D/MediaPlayer(715):     at android.media.MediaPlayer.create(MediaPlayer.java:850)
04-16 16:36:22.128: D/MediaPlayer(715):     at com.example.buttona.Splash.onCreate(Splash.java:23)
04-16 16:36:22.128: D/MediaPlayer(715):     at android.app.Activity.performCreate(Activity.java:5231)
04-16 16:36:22.128: D/MediaPlayer(715):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-16 16:36:22.128: D/MediaPlayer(715):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2172)
04-16 16:36:22.128: D/MediaPlayer(715):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2270)
04-16 16:36:22.128: D/MediaPlayer(715):     at android.app.ActivityThread.access$800(ActivityThread.java:138)
04-16 16:36:22.128: D/MediaPlayer(715):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
04-16 16:36:22.128: D/MediaPlayer(715):     at android.os.Handler.dispatchMessage(Handler.java:102)
04-16 16:36:22.128: D/MediaPlayer(715):     at android.os.Looper.loop(Looper.java:136)
04-16 16:36:22.128: D/MediaPlayer(715):     at android.app.ActivityThread.main(ActivityThread.java:5042)
04-16 16:36:22.128: D/MediaPlayer(715):     at java.lang.reflect.Method.invokeNative(Native Method)
04-16 16:36:22.128: D/MediaPlayer(715):     at java.lang.reflect.Method.invoke(Method.java:515)
04-16 16:36:22.128: D/MediaPlayer(715):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:776)
04-16 16:36:22.128: D/MediaPlayer(715):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
04-16 16:36:22.128: D/MediaPlayer(715):     at dalvik.system.NativeStart.main(Native Method)
04-16 16:36:22.138: D/AndroidRuntime(715): Shutting down VM
04-16 16:36:22.138: W/dalvikvm(715): threadid=1: thread exiting with uncaught exception (group=0xb2a8cd58)
04-16 16:36:22.138: E/AndroidRuntime(715): FATAL EXCEPTION: main
04-16 16:36:22.138: E/AndroidRuntime(715): Process: com.example.buttona, PID: 715
04-16 16:36:22.138: E/AndroidRuntime(715): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.buttona/com.example.buttona.Splash}: java.lang.NullPointerException
04-16 16:36:22.138: E/AndroidRuntime(715):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2208)
04-16 16:36:22.138: E/AndroidRuntime(715):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2270)
04-16 16:36:22.138: E/AndroidRuntime(715):  at android.app.ActivityThread.access$800(ActivityThread.java:138)
04-16 16:36:22.138: E/AndroidRuntime(715):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
04-16 16:36:22.138: E/AndroidRuntime(715):  at android.os.Handler.dispatchMessage(Handler.java:102)
04-16 16:36:22.138: E/AndroidRuntime(715):  at android.os.Looper.loop(Looper.java:136)
04-16 16:36:22.138: E/AndroidRuntime(715):  at android.app.ActivityThread.main(ActivityThread.java:5042)
04-16 16:36:22.138: E/AndroidRuntime(715):  at java.lang.reflect.Method.invokeNative(Native Method)
04-16 16:36:22.138: E/AndroidRuntime(715):  at java.lang.reflect.Method.invoke(Method.java:515)
04-16 16:36:22.138: E/AndroidRuntime(715):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:776)
04-16 16:36:22.138: E/AndroidRuntime(715):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
04-16 16:36:22.138: E/AndroidRuntime(715):  at dalvik.system.NativeStart.main(Native Method)
04-16 16:36:22.138: E/AndroidRuntime(715): Caused by: java.lang.NullPointerException
04-16 16:36:22.138: E/AndroidRuntime(715):  at com.example.buttona.Splash.onCreate(Splash.java:24)
04-16 16:36:22.138: E/AndroidRuntime(715):  at android.app.Activity.performCreate(Activity.java:5231)
04-16 16:36:22.138: E/AndroidRuntime(715):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-16 16:36:22.138: E/AndroidRuntime(715):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2172)
04-16 16:36:22.138: E/AndroidRuntime(715):  ... 11 more
04-16 16:36:25.658: I/Process(715): Sending signal. PID: 715 SIG: 9
04-16 16:41:32.168: D/dalvikvm(761): GC_FOR_ALLOC freed 68K, 5% free 2847K/2988K, paused 40ms, total 43ms
04-16 16:41:32.178: I/dalvikvm-heap(761): Grow heap (frag case) to 3.319MB for 495952-byte allocation
04-16 16:41:32.418: D/dalvikvm(761): GC_FOR_ALLOC freed 3K, 5% free 3328K/3476K, paused 46ms, total 46ms
04-16 16:41:32.528: E/MediaPlayer(761): error (1, -2147483648)
04-16 16:41:32.538: D/MediaPlayer(761): create failed:
04-16 16:41:32.538: D/MediaPlayer(761): java.io.IOException: Prepare failed.: status=0x1
04-16 16:41:32.538: D/MediaPlayer(761):     at android.media.MediaPlayer.prepare(Native Method)
04-16 16:41:32.538: D/MediaPlayer(761):     at android.media.MediaPlayer.create(MediaPlayer.java:850)
04-16 16:41:32.538: D/MediaPlayer(761):     at com.example.buttona.Splash.onCreate(Splash.java:23)
04-16 16:41:32.538: D/MediaPlayer(761):     at android.app.Activity.performCreate(Activity.java:5231)
04-16 16:41:32.538: D/MediaPlayer(761):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-16 16:41:32.538: D/MediaPlayer(761):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2172)
04-16 16:41:32.538: D/MediaPlayer(761):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2270)
04-16 16:41:32.538: D/MediaPlayer(761):     at android.app.ActivityThread.access$800(ActivityThread.java:138)
04-16 16:41:32.538: D/MediaPlayer(761):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
04-16 16:41:32.538: D/MediaPlayer(761):     at android.os.Handler.dispatchMessage(Handler.java:102)
04-16 16:41:32.538: D/MediaPlayer(761):     at android.os.Looper.loop(Looper.java:136)
04-16 16:41:32.538: D/MediaPlayer(761):     at android.app.ActivityThread.main(ActivityThread.java:5042)
04-16 16:41:32.538: D/MediaPlayer(761):     at java.lang.reflect.Method.invokeNative(Native Method)
04-16 16:41:32.538: D/MediaPlayer(761):     at java.lang.reflect.Method.invoke(Method.java:515)
04-16 16:41:32.538: D/MediaPlayer(761):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:776)
04-16 16:41:32.538: D/MediaPlayer(761):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
04-16 16:41:32.538: D/MediaPlayer(761):     at dalvik.system.NativeStart.main(Native Method)
04-16 16:41:32.548: D/AndroidRuntime(761): Shutting down VM
04-16 16:41:32.548: W/dalvikvm(761): threadid=1: thread exiting with uncaught exception (group=0xb2a8cd58)
04-16 16:41:32.558: E/AndroidRuntime(761): FATAL EXCEPTION: main
04-16 16:41:32.558: E/AndroidRuntime(761): Process: com.example.buttona, PID: 761
04-16 16:41:32.558: E/AndroidRuntime(761): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.buttona/com.example.buttona.Splash}: java.lang.NullPointerException
04-16 16:41:32.558: E/AndroidRuntime(761):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2208)
04-16 16:41:32.558: E/AndroidRuntime(761):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2270)
04-16 16:41:32.558: E/AndroidRuntime(761):  at android.app.ActivityThread.access$800(ActivityThread.java:138)
04-16 16:41:32.558: E/AndroidRuntime(761):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
04-16 16:41:32.558: E/AndroidRuntime(761):  at android.os.Handler.dispatchMessage(Handler.java:102)
04-16 16:41:32.558: E/AndroidRuntime(761):  at android.os.Looper.loop(Looper.java:136)
04-16 16:41:32.558: E/AndroidRuntime(761):  at android.app.ActivityThread.main(ActivityThread.java:5042)
04-16 16:41:32.558: E/AndroidRuntime(761):  at java.lang.reflect.Method.invokeNative(Native Method)
04-16 16:41:32.558: E/AndroidRuntime(761):  at java.lang.reflect.Method.invoke(Method.java:515)
04-16 16:41:32.558: E/AndroidRuntime(761):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:776)
04-16 16:41:32.558: E/AndroidRuntime(761):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
04-16 16:41:32.558: E/AndroidRuntime(761):  at dalvik.system.NativeStart.main(Native Method)
04-16 16:41:32.558: E/AndroidRuntime(761): Caused by: java.lang.NullPointerException
04-16 16:41:32.558: E/AndroidRuntime(761):  at com.example.buttona.Splash.onCreate(Splash.java:24)
04-16 16:41:32.558: E/AndroidRuntime(761):  at android.app.Activity.performCreate(Activity.java:5231)
04-16 16:41:32.558: E/AndroidRuntime(761):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-16 16:41:32.558: E/AndroidRuntime(761):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2172)
04-16 16:41:32.558: E/AndroidRuntime(761):  ... 11 more
04-16 16:41:34.618: I/Process(761): Sending signal. PID: 761 SIG: 9

This Is The Java File.
package com.example.buttona;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;

public class Splash extends Activity {

MediaPlayer song = null;

@Override
protected void onCreate(Bundle splashExamleMethod) {
    // TODO Auto-generated method stub

    super.onCreate(splashExamleMethod);

    setContentView(R.layout.buttbcgrnd);

    song = MediaPlayer.create(Splash.this, R.raw.musica);
    song.start();

    Thread timer = new Thread() {
        public void run() {
            try{
                sleep(5000);

            } catch (InterruptedException e) {

                e.printStackTrace();

            }finally{

Intent openButtonwa = new   Intent("com.example.buttona.BUTTONWA");
                startActivity(openButtonwa);

            }
        }
    };
    timer.start();

}

@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    song.release();

    finish();
}

}

As soon as I remove the code of MediaPlayer Method.My App RUns Fine.
The mp3 that I am Trying to play is 1.37mb and is proper.
Except for the adding of song part everything runs fine but as soon as I add the song and the code for it, It says Unfortunately My App Has Stopped.

A: As you can see from the logcat MediaPlayer.create has failed so the return value is null.
Check whether the file musica is not corrupt


text:
Q: cherrypy as a gevent-socketio server I have just started using gevent-socketio and it's great!
But I have been using the default socketioserver and socketio_manage from the chat tutorial and was wondering how to integrate socketio with cherrypy.
essentially, how do I turn this:
class MyNamespace(BaseNamespace):...

def application(environ, start_response):
    if environ['PATH_INFO'].startswith('/socket.io'):
        return socketio_manage(environ, { '/app': MyNamespace})
    else:
        return serve_file(environ, start_response)

def serve_file(...):...

sio_server = SocketIOServer(
    ('', 8080), application,
    policy_server=False) sio_server.serve_forever()

into a normal cherrypy server?

A: Gevent-socketio is based on Gevent, and Gevent's web server. There are two implementations: pywsgi, which is pure python, and wsgi, which uses libevent's http implementation.
See the paragraph starting with "The difference between pywsgi.WSGIServer and wsgi.WSGIServer" over here:
http://www.gevent.org/servers.html
Only those servers are "green", in the sense that they yield the control to the Gevent loop.. so you can only use those servers afaik.  The reason for this is that the server is present at the very beginning of the request, and will know how to handle the "Upgrade" and websockets protocol negotiations, and it will pass values inside the "environ" that the next layer (SocketIO) will expect and know how to handle.
You will also need to use the gevent-websocket package.. because it is green (and gevent-socketio is based on that one).  You can't just swap the websocket stack.
Hope this helps.

A: CherryPy doesn't implement the socket.io protocol, nor does it support WebSocket as a built-in. However, there is an extension to CherryPy, called ws4py, that implements only the bare WebSocket protocol on top of its stack. You could start there probably.