text:
Q: Excel VBA if Column B contains a value then copy that value to Column A do not overwrite existing Column A data I have some code right now that will look at Column B and will update Column A with a predetermined value ("ANY VALUE" from my code snippet) but what I am looking for is to be able to copy what is in Column B and paste it into Column A. Here is the code I have so far:
    Sub Copy_And_Paste_Column_Values_Into_Column_1()
On Error Resume Next
    Dim ws As Worksheet
    Dim lRow As Long

    Set ws = ThisWorkbook.Sheets("Sheet1")

    With ws
        lRow = .Range("B" & .Rows.Count).End(xlUp).Row

        .Range("A1:A" & lRow).SpecialCells(xlCellTypeBlanks).Formula = "=If(B1<>"""",""ANY VALUE"","""")"
        .Range("A1:A" & lRow).Value = .Range("A1:A" & lRow).Value
    End With
End Sub

I would like to turn this:

into this:

Thanks in advance for the assistance!

A: You can do this a little more succinctly, using SpecialCells():
Sub copy_data_to_blanks()
Dim rng As Range
Set rng = Range("A1:A3") ' Change this as necessary.
rng.Cells.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=rc[1]"
rng.Value = rng.Value ' This effectively removes the formulas, just by overwriting the range with the actual values.
End Sub


text:
Q: GMail composer links don't work on Android I am using GMail links like
https://mail.google.com/?view=cm&to=some@email.com

or
https://mail.google.com/mail/?extsrc=mailto&url=mailto%3A%3Fto%3Dsome%40email.com

to simplify writing mails with prefilled receiver, subject, and body content. This works fine on desktop, but when I open either type of link in Firefox or Chrome on Android, it will just go to my inbox instead of opening a composer.
Any ideas how I can make this work?

A: Use mailto instead
mailto:some@email.com?subject=test&body=test

This will allow android and iOS to automatically use intents to offer the user a choice of email clients or selecting the default email client.
It will also use your default mail client on your pc. If gmail is not your default, you can make it so that links will open in your gmail browser

redpajama_set_name: RedPajamaStackExchange


text:
Q: Abrir Url con UIImage Utilizar una imagen para abrir url, algunos no tiene su url y quiero que muestre un mensaje de que no cuenta con el pero no se como realizarlo

A: Muy simple... compruebas si el campo url de tu data esta vacio y de ser asi usa un UIAlertView, si quieres con un delegate = nil, algo asi:
if miUrl.isEmpty {
    let alert = UIAlertView("Aviso!!!", message: "Mmmm, no tengo url!", delegate: nil,
                            cancelButtonTitle: "OK")
    alert.show()
}else{
    //hacer algo
}

A: En Swift puedes validar con isEmpty y mostrar un UIAlertView() :
if (textField.text.isEmpty) {
                let alert = UIAlertView()
                alert.title = "Error"
                alert.message = "No existe url definida"
                alert.addButtonWithTitle("Ok")
                alert.show()
}

Usando Swift 2.0 , if:
if let urlImagen = textField.text where textField.text.isEmpty {
    // crea UIAlertView()
}

Swift 2.0, guard:
guard let urlImagen = textField.text where textField.text.isEmpty else {
    // crea UIAlertView()
    return
}

Para cargar una url de imagen dentro de un UIImage, este es un ejemplo:
if let url = NSURL(string: "http://www.mydominio.com/myimagen.jpg") {
  if let data = NSData(contentsOfURL: url) {
     imageURL.image = UIImage(data: data)
  }
}


text:
Q: No partitions showing during installation I have a HP EliteBook 8570w with Windows7 pre-installed. when I try to install ubuntu from either a disk or a USB-stick, it skips the third step and I don't get to see any partitions at all:

The output of sudo fdisk -lu:
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xb760cea1

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200    7  HPFS/NTFS/exFAT
/dev/sda2          616448   210339044   104861298+   7  HPFS/NTFS/exFAT
/dev/sda3       210339840   959995903   374828032   83  Linux
/dev/sda4       959995904   976773119     8388608   82  Linux swap / Solaris

Disk /dev/sdb: 24.0 GB, 24015495168 bytes
255 heads, 63 sectors/track, 2919 cylinders, total 46905264 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x57000000

Disk /dev/sdb doesn't contain a valid partition table

The output of sudo parted -l:
Model: ATA WDC WD5000BPKT-6 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos

Number  Start   End    Size    Type     File system     Flags
 1      1049kB  316MB  315MB   primary  ntfs            boot
 2      316MB   108GB  107GB   primary  ntfs
 3      108GB   492GB  384GB   primary  ext4
 4      492GB   500GB  8590MB  primary  linux-swap(v1)

Error: /dev/sdb: unrecognised disk label

Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0
has been opened read-only.
Error: Can't have a partition outside the disk!

What I've tried:
sudo gdisk /dev/sda2:
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xb760cea1

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200    7  HPFS/NTFS/exFAT
/dev/sda2          616448   210339044   104861298+   7  HPFS/NTFS/exFAT
/dev/sda3       210339840   959995903   374828032   83  Linux
/dev/sda4       959995904   976773119     8388608   82  Linux swap / Solaris

Disk /dev/sdb: 24.0 GB, 24015495168 bytes
255 heads, 63 sectors/track, 2919 cylinders, total 46905264 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x57000000

Disk /dev/sdb doesn't contain a valid partition table

chdisk /f
In Windows I've tried this but it also didn't solve my problem.
Setting my SATA mode from RAID to AHCI
This didn't work out either. I had to reset it to RAID to get Windows7 working again
Installing 12.04 instead of 13.04
But the problem keeps persisting
Disabling my SLC mSATA cache module
Windows wouldn't start again and the problem persisted

If anyone could provide me with an answer I would be delighted. Thank you in advance.

A: You also have the 4 primary partition issue.
My laptop already has 4 primary partitions: how can I install Ubuntu?
Be sure to create recovery DVD(s) first as well as a Windows repair CD.
HP Tools Partition discussion
If you shrink Windows using Windows disk tools and backup HP tools. You can then use gparted to create one large extended partition and have many logical partitions. You can restore HP tools in one if you want. You can make a shared NTFS data partition if you want and you can install Ubuntu in / (root), swap and /home again if you want that as a separate partition.
Update:
If system was an Ultrabook it has Intel SRT which somehow uses RAID. You need to turn off the SRT and then remove the meta-data on both drives. If still booting Windows you can turn SRT back on and it should work.
sudo dmraid -E -r /dev/sda
sudo dmraid -E -r /dev/sdb

Some other issues can be dynamic or LDM partitions if you used Windows to create extra partitions, or left over gpt backup partition table where drive was gpt and you use Windows install in MBR mode.

A: http://ubuntuforums.org/showthread.php?t=1970636
If you read this thread, the moderators answer to the OP suggests that if you run gparted from a live cd / usb and partition your drives yourself beforehand, it will solve this glitch, and also speed up the install process, since it can now use the swap partition to speed up the process.
Google how to make a gparted live usb/cd, whichever you prefer, and format your partitions with however much space you want for the root system, a separate /home if you like, and a swap formatted partition equal to the amount of ram you have, measured in GiB (according to the moderator in the linked forum thread).


text:
Q: how to test Windows service i have a windows service which is writen in vb.net
in order to be sure about the performance
i want to test it before instalation
how can i do the job in vs2010
is there any special tool in vs2010 or an extension
any idea ?
Regards,

A: I already told you in my answer to your other question - you might want to check out some "hybrid" approaches, that would allow you to write your code as a command-line app first (which can be easily debugged), and once it works okay, you can then install it as a service:

*

*HybridService: Easily Switch Between Console Application and Service

*Hybrid Windows Service

*TopShelf - a service-construction helper for .NET


text:
Q: Firefox isn't showing typescript (.ts) source maps in the debugger I can only see the .js files, the .ts sources don't appear in Firefox.
It works in Chrome, I can see and place line breaks in .ts files, and the debugger works great. But Firefox will not work, no version, not the stable or the nightly or the developer version.
Could it be that the functionality is not implemented on Mac/OSX? If so, there should be something on the internet about that, but I've found nothing. Apparently, the problem has not been documented anywhere.
Does anyone have any knowledge of this, and perhaps how to fix it?

A: A little late but hopefully helpful.
For Firefox make sure that you have "Show Original Source" checked in the debugger settings.
Next, your compiled javascript must have an absolute path reference to your .map file, the path reference should appear at the end of your compiled js file and will look like this:
//# sourceMappingURL=http://localhost:9000/dist/customElements/listview.js.map
It is likely that you have a sourceMappingURL but specified as a relative path. FF doesn't seem to like relative paths for sourcemaps.
Of course this is in your compiled js so every time you complile ts to js you will need to reset the sourceMappingURL. This becomes tiresome very quickly.
If you are using Gulp (or probably other task runners) you can set a prefix option (sourceMappingURLPrefix) for the mapping URL in your gulp.task that compiles your typescript. (see https://github.com/floridoo/gulp-sourcemaps)
My compiled .js resides in \dist with sub-folders. Unfortunately the prefix option doesn't help with sub-folders. Fortunately Gulp can handle this as well by specifying a function for the sourceMappingURLPrefix.
The function gets passed an object which has a path to the complied js, so with a bit of string manipulation you can create the path to the .map file as well (mine are together in the same folder).
My gulp build task looks like this (see sourceMappingURLPrefix):
gulp.task('build-system', function() {
    if(!typescriptCompiler) {
         typescriptCompiler = typescript.createProject('tsconfig.json', {
         "typescript": require('typescript')
      });
 }
return gulp.src(paths.dtsSrc.concat(paths.source))
    .pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')}))
    .pipe(changed(paths.output, {extension: '.ts'}))
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(typescript(typescriptCompiler))
    .pipe(sourcemaps.write('.', {
        includeContent: false,
        sourceRoot: '/src',
        sourceMappingURLPrefix: function (file) {
            var mapPath = file.path.split(/[\\\/]/); //split path into component parts
            return 'http://localhost:9000/dist/' + mapPath.slice(1, mapPath.length - 1).join('/') //prepend my local webserver and dist folder then re-join discarding the last slice which is the compiled .js file name.
        }
    }))
    .pipe(gulp.dest(paths.output));
});

This now produces an absolute path for the sourceMappingURL in my compiled js that also correctly references subfolders, like this: /# sourceMappingURL=http://localhost:9000/dist/customElements/listview.js.map
Firefox is loading the .ts files and the debugger functions as expected.
It also is working in Chrome.
I'm no Gulp expert so if there is a better way I am keen to find out.
update : I recently have switched to using aurelia-cli which, so far, I am finding far simpler than Gulp+jspm. Both Firefox & Chrome correctly pick up the .ts files without any configuration necessary.


text:
Q: will python code written in windows work in linux? I would like to write some Python code in Windows using QtPy. But before I do that I'd like to know that I can use the code I wrote in Python. I understand that the complied program won't work due to different platforms but will there be any issues with regards to the *.py files I write in windows vs linux?
I've been trying to install QtPy on my Mint installation and I just don't know what the problem is. Which is why I wanna go this route.
I'd also like my code to work on the raspberry pi.
Could you guys advise me to this end?
Thanks!

A: Mostly, yes, as long as you keep to using the tools Python provides you and don't write code that is platform specific.
Use os.path.join() to build paths, for example. Open files in binary mode when you deal with binary data, text mode when it's text data. Etc.
Python code itself is platform agnostic; the interpreter on Linux can read python code written on Windows just fine and vice versa.
The general rule of thumb is to pay attention to the documentation of the modules you are using; any platform specific gotchas should be documented.

A: It depends on what your code does.  Most packages work in both windows and linux however some such as signal only work in windows and are not portable.  But in the python docs it will say what platforms a given package works in.


text:
Q: Eclipse Plugin: Link MulitPageEditorPart with Navigator In an Eclipse-Plugin, I have an implementation of a MultiPageEditorPart and it is associated with a file-extension - let's call it f.
When I click on a file f in the standard Package Explorer the Editor is opend. This works fine so far.
But what is not working, is linking this Editor with the Package Explorer. Let's say someone has several open Editors and one of them is the custom MultiPageEditorPart. If the custom Editor becomes selected via the tabs (not the Package Explorer) the corresponding file in the Package Explorer should be selected / marked.
Following the example in "link with editor" for FormEditor I tried to achive this using an ILinkHelper and the Extension Point org.eclipse.ui.navigator.LinkHelper, but it is never called.
How is the ILinkHelper used together with a MultiPageEditorPart?
PS: I'm using Eclipse Oxygen

A: The MulitpageEditorPart (and other Editors) have an IEditorInput which owns a Method
<T> T getAdapter(Class<T> adapter)

If this Method is called with IResource.class or IFile.class it should return the IResource that is the source for the current Editor. This is then used by Eclipse to link the Editor with the View (Package Explorer).
Like this:
<T> T getAdapter(Class<T> adapter) {
   if (IResource.class.isAssignableFrom(adapter) {
       return (T) myFile;
   }
}


text:
Q: Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL for the right syntax to use near Actually, i am using jquery datatables in HMVC. when i write charector in serarch bar of datatable it gives me error like if i write 'foo' it will give me
Error Number: 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 'LIKE '%foo%' OR uid LIKE '%foo%' OR pwd LIKE '%foo%' OR pooling LIKE '%foo%' OR ' at line 3
My Query:
 public function data_loc_table()

     {
       $this->load->helper('datatables');
       $this->datatables->select('data_location_id,group_name,provider,driver,server,port,protocol,database,uid,pwd,pooling,min_pool_size,max_pool_size,conn_reset,conn_life_time,modified_time,status')

            ->unset_column('data_location_id')
            ->unset_column('status')
            ->add_column('Status','$1', 'get_connected_meters(status)')
            ->add_column('Actions', get_dloc_buttons('$1'), 'data_location_id')
            ->from('data_location');
            return ;
        }

Description:
Please help me find out why do I have this error?

A: I think the issue is with
'$1'

We can't use php variables in single quotes(' '), so try replacing these single quotes with double quotes(" ")
Replace

'$1'

with

"$1"


text:
Q: Changing directories in Rscript How can I have my Rscript parameters change directories?
If my command-line argument is Rscript test.R "foo1", I want to setwd("~/foo1"), but I get the error that it cannot change working directory.
args<-commandArgs(trailingOnly=TRUE)
lambda<args[1]
fileEnd<-args[2]
replicate<-args[3]
directory<-args[4]
setwd(directory)

A sample command-line is Rscript test.R 0 1 10 "~/foo1"

A: Try this:
# use commandline arguments
args <- commandArgs(TRUE)

# the first argument is the working dir
working.dir <- args[1]

# change the working dir
setwd(file.path("~", working.dir))

A: It is not possible to give you a specific answer since you are not providing the key parts of your script. To simplify the troubleshooting, start with adding the full physical path to what you want to change directory. This to secure that the full path works.
General suggestions.
The most structured way is to put an [.Rprofile] file in the directory you will trigger your Rscript. The local [.Rprofile] will be read when Rscript initiates the R terminal session. In [.Rprofile] you need to add [setwd('/yourpath'). This is assumed if you just want to set the wd at start.
If you need to change the [setwd] during the course of your script/s you can of course include them in the R-files. Remember though that Rstudio and R terminal behaves different when comes to [load/save]. Rstudio acts dynamically when you change something through its console and show directly the changes in the global environment window.
For Rscript triggered from terminal you will have to make sure that for each script you add [load/save] for R to compensate that it losses the environment when it is not in a running session with Rscript.
The difference behaviour between Rstudio and R terminal is important to keep in mind, especially if you test scenarios in Rstudio and expect it to work the same way in R-terminal.


text:
Q: Rewrite rule takes in two variables and adds text to the URL I've created an htaccess file for my website that converts a URL like this http://www.example.com/fixture?id=1 to something like http://www.example.com/fixtures/1.
My htaccess file:
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^fixtures/(\d+)*$ fixture.php?id=$1

That works how I want it, but isn't exactly SEO friendly, so I'd like to pass in two more variables home and away like so http://www.example.com/fixture?id=1&home=Arsenal&away=Chelsea.
Then rewrite the URL to look like `http://www.example.com/fixtures/arsenal-vs-chelsea.
There are many questions about rewrite rules on SO, but none discuss adding a small portion of text between variables. How could I make it so that I could add the vs portion of the URL using a rewrite rule?

A: You can use:
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^fixtures/([^/]+)-vs-([^/]+)/?$ fixture.php?home=$1&away=$2

Rewrite to:
http://www.example.com/fixture?home=Arsenal&away=Chelsea


text:
Q: Is JSON type in PostgreSQL part of transactions? Just want to know if JSON type is also comes under the transactions. For e.g. If I have started a transaction which insert data both for column JSON types and others and if something wrong happens, will it rollback the json stuff as well?

A: Everything is transactional and crash-safe in PostgreSQL unless explicitly documented not to be.
PostgreSQL's transactions operate on tuples, not individual fields. The data type is irrelevant. It isn't really possible to implement a data type that is not transactional in PostgreSQL. (The SERIAL "data type" is just a wrapper for the integer type with a DEFAULT, and is a bit of a special case).
Only a few things have special behaviour regarding transactions - sequences, advisory locks, etc - and they're pretty clearly documented where that's the case.
Note that this imposes some limitations you may not immediately expect. Most importantly, because PostgreSQL relies on MVCC for concurrency control it must copy a value when that value is modified (or, sometimes, when other values in the same tuple are modified). It cannot change fields in-place. So if you have a 5MB json document in a field and you change a single integer value, the whole json document must be copied and written out with the changed value. PostgreSQL will then come along later and mark the old copy as free space that can be re-used.


text:
Q: Objective C - Data Binding? I am trying to create a JSON library that converts JSON string into objects.
What's the cleanest way to mark properties that are related to JSON string?
Is it possible to achieve something like the code below
NOTE: The code below doesn't work it's just a sample to show what I'm trying to achieve
JSON String
{
   "FIRST_NAME": "Some first name",
   "LAST_NAME":  "Some last name"
   "CLASSES" :
   [
      {
         "CLASS_NAME": "class 1"
      }
      {
         "CLASS_NAME": "class 2"
      }
   ]
}

Model
@interFace Student

[JSON = "FIRST_NAME"]
@property (nonatomic, retain) NSString *firstName;

[JSON = "LAST_NAME"]
@property (nonatomic, retain) NSString *lastName;

[JSON = "CLASSES"]
@property (nonatomic, retain) NSArray  *classes;

@end

JSON Method
@implementation JSON
+ (id)getObjectFromJSONString:(NSString*)string withType:(Class)class
{
   //Create a student Object
   //for each property if there is a JSON mark look for the value in json string
   //populate all available values
   //return object
}
@end

A: It is certainly possible. However, note that Objective-C doesn't support arbitrary source code annotations that can be inspected at runtime, so the mapping between a JSON key and an object key representing an instance variable or declared property won't be exactly like you've described.
I recommend you take a look at RestKit. Besides helping with connecting your program to RESTful services, it has an object mapping infrastructure that turns remote JSON messages into local domain objects in a declarative manner.

A: I ended up writing a small library for this specific purpose.
https://github.com/aryaxt/OCMapper

A: I assuming that you are using JSON-Framework to parse JSON.
Not as far as I know. We have been writing a few data clients that consume JSON input.
Depending on who maintains the REST service you also have to check for things like NULL values. Also you might have to covert values to Integer/Float.


text:
Q: Sphinx-quickstart doesn't work I am trying to install sphinx on a remote machine.
Since I don't have an access to the root, I did this:
$bash

$mkdir -p ~/local/lib/python2.7/site-packages

$export PYTHONPATH=$PYTHONPATH:~/local/lib/python2.7/site-packages

$export PATH=$PATH::~/local/lib/python2.7/site-packages

$easy_install -U --prefix=$HOME/local Sphinx

But apparently, $easy_install doesn't build sphinx-quickstart; when I type
$sphinx-quickstart

I get the following message:
bash: sphinx-quickstart: command not found

I tried
find $HOME -name sphinx-quickstart

and no result was found. However, I can import sphinx inside python:
$python

And then
>>import sphinx

works. Any idea why sphinx-quickstart doesn't work?

A: An alternative way to invoke sphinx-quickstart is to explicitly load Sphinx's quickstart module. For Sphinx v1.7+:
python -m sphinx.cmd.quickstart

For older versions of Sphinx:
python -m sphinx.quickstart

For example:
$ /c/Python35/python -m sphinx.quickstart
Welcome to the Sphinx 1.6.2 quickstart utility.
...

A: I found the solution in this webpage:

  User (root/sudo free) installation of Python modules.

In section 3. Python 2.6+ he mentioned that the command line commands are in
~/local/bin

Although I had put ~/local/lib/python2.7/siste-packages in the path, the ~/local/bin directory was not in the path. So all I did
$export PYTHONPATH=$PYTHONPATH:~/local/bin

and now it works.
I don't know why find $HOME -name sphinx-quickstart did not find sphinx-quickstart

A: In MacOS (Catalina) and zsh:
I installed sphinx with brew and had the same problem as you.
Solution:
Installed it with conda as conda install sphinx and now it works for me
$ sphinx-quickstart
Welcome to the Sphinx 2.3.0 quickstart utility.

Installation Guide

A: Note, if you're in a virtual environment and using poetry to run
poetry run py -m sphinx.cmd.quickstart
where py is the python launcher for Windows.

A: Have added an answer for installation on macOS using brew here

For new users, installing with brew gives the following caveats:
==> sphinx-doc
sphinx-doc is keg-only, which means it was not symlinked into /usr/local,
because this formula is mainly used internally by other formulae.
Users are advised to use `pip` to install sphinx-doc.

If you need to have sphinx-doc first in your PATH, run:
  echo 'export PATH="/usr/local/opt/sphinx-doc/bin:$PATH"' >> ~/.zshrc

Running the echo command:
echo 'export PATH="/usr/local/opt/sphinx-doc/bin:$PATH"' >> ~/.zshrc

should fix the issue.
Don't miss source-ing the .zshrc after the updating it:
source ~/.zshrc


text:
Q: Standard Controller behavior with not available ids - behavior changed? Question
Do standard controllers no longer throw exceptions if the current user doesn't have access to the passed in id? Has this always been that case or did this just recently change? Hoping to validate this is a regression before contacting support ...
Background
Regressions are always funky (hard to go back in time to test), but previously, if a page using a standard controller with an ID that wasn't visible to a user you'd get a Data not available white screen of death. This is important in case you do something like this.
public with sharing MyExt {
  public MyExt(ApexPages.StandardController controller) {
    if(controller.getId() != null) {
      My_Object__c obj = [SELECT Id FROM My_Object__c WHERE Id = :controller.getId()];
    }
  }
}

Previously this code would never execute since we'd get the exception before the constructor run, but with Summer '14 orgs (and Winter '14) this pages now are failing with List has no rows for assignment to SObject.
Note that this is distinct from an invalid id (either not the correct object type, or just plain invalid) which still throws a Id value <blah> is not valid for the My_Object__c standard controller.
Docs
The docs aren't super clear, but seem to imply that this should get an exception since standard controller's run in system mode

If a controller extension extends a standard controller, the logic
  from the standard controller doesn't execute in system mode. Instead,
  it executes in user mode, in which the permissions, field-level
  security, and sharing rules of the current user apply.

Update
After some further testing it appears that, (1) the constructor gets run regardless of whether an id is visible as long as it's valid, (2) nothing gets run if the id is invalid or wrong object type and an Id value <blah> is not valid for the My_Object__c standard controller error is thrown, (3) the Data Not Available error only occurs if the controller object is referenced directly on the page, i.e. {!My_Object__c.Id}. (4) getters may or may not be processed if id is not visible depending on their position until the first getter call to the core object ({My_Object__c.Id}). Maybe this was always the case?

A: The standard controller will still throw the same Data Not Available error if you use the getRecord() method. i.e.
public with sharing MyExt {
  public My_Object__c obj;

  public MyExt(ApexPages.StandardController controller) {
     obj = (My_Object__c)controller.getRecord();
  }
}

However, the getId() method throws no error and just returns null. So you're best bet would be to stick with the getRecord() method.
As for the regression, who knows, but as of Winter '15 my org functions this way.


text:
Q: .net core replace update dll live I have the following solution structure:
Host references:
Project A
Project B (A requires B)
Project C
We are building a .net core solution using "dotnet publish -p:FileVersion=2.0.0.0"
After deploying, we sometime need to replace a dll file for bug fixing, we don't want to replace the entire solution (Project B & C) only the changed dll file (Project A)
Once we rebuild using "dotnet publish -p:FileVersion=2.1.0.0"
and try to replace only the dll of project A, we get the following error
Unhandled exception caught System.IO.FileNotFoundException: Could not load file or assembly 'ProjectB, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
Using dotPeek I saw that both in .net core and in .net framework project A had a reference to project b with the new version 2.1.0.0
However in .net framework for same reason it didn't enforce the version check so project b was loaded successfully even when it was on 2.0.0.0
Any suggestions on how can I allow this in .net core (3.1) as well?
Thanks.


text:
Q: SAX parsing with Nokogiri element error? I have couple of hundred XML files like below. I want to parse them using SAX and save the content between all the tags and save them in hashes.
This is a snippet of the XML-file:
<titles>
 <title xml:lang="sv">Arkivvetenskap</title>
 <title xml:lang="en">Archival science</title>
</titles>
<descriptions>
 <ct:description xml:lang="sv">
  <ct:text>Arkivvetenskap rör villkoren för befintliga arkiv och modern arkivbildning med
   fokus på arkivarieyrkets arbetsuppgifter: bevara, tillgängliggöra och styra information.
   Under ett år behandlas bl a informations- och dokumenthantering, arkivredovisning,
   gallring, lagstiftning och arkivteori. I kursen ingår praktik, där man under handledning
   får arbeta med olika arkivarieuppgifter.
  </ct:text>
 </ct:description>
</descriptions>
</educationInfo>

The full XML looks like this: https://gist.github.com/2282103
I have the following code:
require 'rubygems'
require 'nokogiri'
require 'ap'
include Nokogiri

class Fish < Nokogiri::XML::SAX::Document

   def initialize
      @f = {}
      @f["titles"] = Array.new([])
      @f["descriptions"] = Array.new([])
      @desc = {}
   end

   def start_element(element, attributes = [])
      @element = element
      @desc = {} if element == "ct:description xml:lang='sv'"
   end

   def end_element(element, attributes = [])
      @f["titles"] << @characters if element == "title xml:lang='sv'"
      @f["titles"] << @characters if element == "title xml:lang='en'"
      if element == "ct:text"
         @desc["edutext"] = @characters
         @f["descriptions"] << @desc
      end
   end

   def characters(string)
      @characters = string
   end

   def end_document
      ap @f
      puts "Finished..."
   end

end
#Create a parser
parser = Nokogiri::XML::SAX::Parser.new(Fish.new)
# Feed the parser some XML
parser.parse(File.open("arkivvetenskap.xml", 'rb'))

The element in the XML files that I want to store doesn't store in the hashes. And I want to store every content in every element.
The output I get is:
{
    "descriptions" => [
        [0] {
            "edutext" => "tik, där man under handledning får arbeta med olika arkivarieuppgifter."
        }
    ],
          "titles" => []
}

How do make it work?


text:
Q: How to add force to non connected objects in d3.js in javascript? How to add force to non connected objects in d3.js?
Following is demo of a force directed graph in d3.js
https://jsbin.com/bijoxozuno/edit?html,css,js,output
This is the force code:
    force.on("tick", function() {
      dataset.nodes.forEach((node, i) => {
        const circle = layer.findOne(".node-" + i);
        circle.x(node.x);
        circle.y(node.y);
      });
      dataset.edges.forEach((edge, i) => {
        const { target, source } = edge;
        const line = layer.findOne(".edge-" + i);
        line.points([target.x, target.y, source.x, source.y]);
      });
      layer.draw();
    });

Imagine if I have some other entities like a separate square or a circle which when collides with the force connected graph; it should interact (like attract or repel).
How can I achieve that?
Cause currently all the connected nodes are interacting well(attracting and repelling).
But my need is to extend this interaction further with other third party objects (like a different circle or square) which is not connected to the graph. but is under the influence of same force.
NOTE What I want to achieve is simply I want the connected nodes to interact with objects that are not part of the connected graph... but is under the influence of the same force.
Example the red rectangle in the above example


text:
Q: TranslateX an object and keep the final position I wrote a test with CSS transform-translateX. The animation works but the object doesn't keep the final position, returns to the original position.
How can keep the final position?
Here the CSS:
@-webkit-keyframes mover {
    0% { -webkit-transform: translateX(0); }
    100% { -webkit-transform: translateX(300px); }
}
@-moz-keyframes mover {
    0% { -moz-transform: translateX(0); }
    100% { -moz-transform: translateX(300px); }
}
@-o-keyframes mover {
    0% { -o-transform: translateX(0); }
    100% { -o-transform: translateX(300px); }
}
@keyframes mover {
    0% { transform: translateX(0); }
    100% { transform: translateX(300px); }
}

#box {
    position: relative;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background-color: #666;
}

.box-mover {
    -webkit-animation: mover 2s ease-in-out;
    -moz-animation: mover 2s ease-in-out;
    -o-animation: mover 2s ease-in-out;
    animation: mover 2s ease-in-out;
}

Here the test:
http://jsfiddle.net/junihh/1v0t9vs2/
Thanks for any help with this.

A: Add the forwards keyword. DEMO
.box-mover {
    -webkit-animation: mover 2s ease-in-out forwards;
    -moz-animation: mover 2s ease-in-out forwards;
    -o-animation: mover 2s ease-in-out forwards;
    animation: mover 2s ease-in-out forwards;
}

This will set the animation-fill-mode: property.

Forwards - The target will retain the computed values set by the last
  keyframe encountered during execution. The last keyframe encountered
  depends on the value of animation-direction and
  animation-iteration-count:

*

*Source


text:
Q: itextsharp-insert dynamic table in existing pdf model now i face a problem that i need to add a dynamic table inside my pdf model. as far as i search the answer. they are all insert fixed length content(just like below link). I wonder know how can i insert a dynamic table(maybe different rows) into my pdf model and other content in model roll over accordingly? great appreciate if giving code sample.
How to continue field output on a second page?


text:
Q: Is this really equal to sin x? Link to image: https://i.redd.it/uj2a83j468yy.png
Is this really true? I can't prove or disprove it.

A: If you start with
$\sin'(x) = \cos(x),
\cos'(x) = -\sin(x),
\sin(0) = 0,
\cos(0) = 1,
\sin^2(x)+\cos^2(x) = 1$,
you can proceed like this
(not original with me):
$$\sin(x)
=\int_0^x \cos(t)dt
\le\int_0^x dt
=x
$$
$$\cos(x)-\cos(0)
=\int_0^x -\sin(t) dt
=-\int_0^x \sin(t) dt
\ge-\int_0^x t dt
=-\frac{x^2}{2}\\
\text{ so }
\cos(x)
\ge 1-\frac{x^2}{2}
$$
$$\sin(x)
=\int_0^x \cos(t)dt
\ge\int_0^x (1-\frac{t^2}{2})dt
=x-\frac{x^3}{6}
$$
$$\cos(x)-\cos(0)
=\int_0^x -\sin(t) dt
=-\int_0^x \sin(t) dt
\ge-\int_0^x (t-\frac{t^3}{6}) dt
=-\frac{x^2}{2}+\frac{x^4}{24}\\
\text{ so }
\cos(x)
\le 1-\frac{x^2}{2}+\frac{x^4}{24}
$$
By induction you can
derive the power series
for sin and cos
and show that they are
enveloping
(the sum is between any two
consecutive sums).


text:
Q: Custom UINavigationBar Drawing Empty This is probably something very easy and stupid of me but I have a custom UINavigationBar that customized it with core graphics in the drawrect method.  I use it multiple times throughout my app and all but two instances work fine.  The two instances when loaded into view are rendering black when they should be a gray gradient.  The drawrect method is being called but for some reason they are being presented black in the view.
These are the IB settings I have for the UINavigationBar

And the settings I have for the parent UIVIew

If theres any other information I can provide to make this easier please just let me know.  Thanks a lot for anyone that can help.


text:
Q: Unable to run MSI from network path using Process.Start - Is this possible to run an msi from network share? I would like to start an MSI which lives on network share, however the msiexec 'help' dialog shows instead (which indicates something is wrong with the process start info):
string testPath1 = @"\\mynetwork.share.com\dev\builds 1.0\product.msi";  //DOESN'T WORK
string testPath2 = @"C:\users\username\desktop\product.msi";         //DOES WORK

ProcessStartInfo startMsiexecProcess = new ProcessStartInfo(@"C:\windows\system32\msiexec.exe");
startMsiexecProcess.Arguments = @"/i " + testPath1;
Process.Start(startMsiexecProcess);

I have tried variations on the testPath1 - ie not using fully qualified name, and other network shares. I have tried adjusting the spacing on the Arguments, as well.
Finally, if I change the 'local' path to a fully qualified format like this:
string testPath2 = @"\\mylocalmachine.domain.com\c$\users\username\desktop\product.msi";

..it does work correctly. So this gives me confidence that it is likely not a badly formed string causing the issue when I try to execute this on the network share.
Is this possible to run an msi from network share?

A: It is the space in my path: "builds 1.0". Process.Start may be interpreting this as an argument delimiter.
To resolve I added quotes around the path to the MSI being run ie:
"\"" + testPath1 + "\""

this post led me to the solution: how-to-handle-values-with-spaces-in-process-start-in-c-sharp


text:
Q: UPDATING a table in MySQL containing a foreign key column I am working on 3 tables linked with foreign keys and also set to ON UPDATE CASCADE and ON DELETE CASCADE. These tables are category, subcategory and products.
products table - PID(PK), productname, subcatid(FK)
subcategory table - subcatid(PK), subcategoryname, catid(FK)
category table - catid(PK), categoryname
What is the right query to UPDATE products table when I want to change the name of the product? Also if I want to change the subcategory of a product by using a form?
I am using a form which successfully prepopulates with the fields - product name, subcategory name but it does not update the records in products table, means it does nothing and does not changes the product name and subcategory name.
Any help is appreciated.
am using the following code
<?php
// Parse the form data and add inventory item to the system
if (isset($_POST['PRODUCT_NAME'])) {
    $pid = mysql_real_escape_string($_POST['thisPID']);
    $catalog_no = mysql_real_escape_string($_POST['CATALOG_NO']);
    $product_name = mysql_real_escape_string($_POST['PRODUCT_NAME']);
    $price = mysql_real_escape_string($_POST['PRICE']);
    $composition = mysql_real_escape_string($_POST['COMPOSITION']);
    $size = mysql_real_escape_string($_POST['SIZE']);
    $subcat = mysql_real_escape_string($_POST['SUBCAT_ID']);
    // See if that product name is an identical match to another product in the system
    $sql = mysql_query("UPDATE products SET CATALOG_N0='$catalog_no', PRODUCT_NAME='$product_name', PRICE='$price', COMPOSITION='$composition', SIZE='$size', SUBCAT_ID='$subcat' WHERE PID='$pid'");
    header("location: inventory_list.php");
    exit();
}
?>

<?php
// Gather this product's full information for inserting automatically into the edit form below on page
if (isset($_GET['pid'])) {
    $targetID = $_GET['pid'];
    $sql = mysql_query("SELECT products.PID, products.CATALOG_NO, products.PRODUCT_NAME, products.PRICE, products.COMPOSITION, products.SIZE, products.SUBCAT_ID, subcategory.SUBCAT_ID, subcategory.SUBCATEGORY_NAME FROM (products, subcategory) WHERE subcategory.SUBCAT_ID=products.SUBCAT_ID AND PID='$targetID' LIMIT 1");
    $productCount = mysql_num_rows($sql); // count the output amount
    if ($productCount > 0) {
        while($row = mysql_fetch_array($sql)){

             $catalog_no = $row["CATALOG_NO"];
             $product_name = $row["PRODUCT_NAME"];
             $price = $row["PRICE"];
             $composition = $row["COMPOSITION"];
             $size = $row["SIZE"];
             $subcat = $row["SUBCAT_ID"];
        }
    } else {
        echo "You dont have that product";
        exit();
    }
}
?>

A: You're not using the product name as a foreign key, so a simple standard
UPDATE products SET productname='New Name of Product' where PID=XXX;

would do the trick. Same goes for the subcatid in products. As long as the new subcat ID exists in the subcategory table, you can change products.subcatid to whatever you want, again via a simple
UPDATE products SET subcatid=New_ID where PID=XXX;


text:
Q: How to used Pandas.assign to create a new column from the pandas dataframe index? I am trying to use the pandas assign method to create a new column which derives its values from the Dataframe index. I really want to use the assign function to achieve the desired output. How do I do this? Thanks in advance.
import pandas as pd
df = pd.DataFrame([1,2,3,4,5],index=['A','B','C','D','E'],columns=
     ['Score'])
df

df.assign(Person=df.index)
df

Actual Output

Desired Output

A: is this what you are looking for?
1 first way not using assign:
import pandas as pd
import numpy as np

df = pd.DataFrame([1,2,3,4,5],index=['A','B','C','D','E'],columns=
     ['Score'])

df=df.reset_index().rename(columns={'index': 'Person'})
df

2 second way using assign:
df = pd.DataFrame([1,2,3,4,5],index=['A','B','C','D','E'],columns=
 ['Score'])

df=df.assign(Person=df.index).reset_index()

df=df.drop(['index'], axis=1)
df


text:
Q: Imap Fetch Command I am using the following C# code retrieve the header of messages, but I want to modify it so it can tell me if the message contains any Attachments, however I do  not want to load the complete message with attachments
var command = string.Format("FETCH {0} (FLAGS UID BODY[HEADER])", i);
Clean();
SendCommand(command);
var sizeLine = ReadLine();

I've tried the following
This retrieves the complete message or simply don't work, I am also working from the rfc website but can't seem to find the command for it
var command = string.Format("FETCH {0} (FLAGS UID BODY.PEEK[])", i);
var command = string.Format("FETCH {0} (FLAGS UID BODY[])", i);
var command = string.Format("FETCH {0} (FLAGS UID BODY[HEADER,MIME])", i);
var command = string.Format("FETCH {0} (FLAGS UID BODY[MIME])", i);

A: The command you're looking for is UID FETCH ... BODYSTRUCTURE. Once you've seen the response, you may wish to consider using a library to do the parsing for you. There are at least two candidates on C#, MailKit and something called, IIRC, mailsystem.net. Try mailkit first.

A: Maybe you forgot to put UID before the FETCH command:
string tag = GetTag();
string response = SendCommandGetResponse(tag + "UID FETCH " + uid + " (BODY" +
                    (seen ? null : ".PEEK") + "[HEADER])", false);

coming from the S22  ImapClient.cs


text:
Q: Upload a file to AWS S3 using C# without using AWS SDK I need to create a C# SQL CLR stored procedure to upload files (data exports) to AWS S3 buckets.  These files will generally be very small.
The AWS SDK cannot be installed on the SQL Servers and I am finding it difficult to find any information about how to accomplish this.
I am looking for some examples or documentation on how to accomplish uploading files without using the SDK.
My experience is mainly SQL, limited amount of C#.

A: You can use Amazon S3 via a REST API: Amazon S3 REST API Introduction
However, it can get a little complex, especially when providing Authentication signatures.


text:
Q: Creating polygons with different heights in Qgis2threejs i'm trying to display a polygon in qgis-2threejs which works fine. Now i want to adjust the height on the sides of the polygon, so that i can vary the body of the polygon.
Basically i want to display different fractures inside of a mountain with the height of each polygon adjusted to the surface.
See here:

A: As far as I know, it is not possible to get a sloped polygon in Qgis2treeJS.
However, you can create a second DEM with your mountain and display your lines on that surface.
You can then use your lines layer in Qgis2threeJS and select "profile" as object type. Then use the parameters Zcoordinate (mode absolute value, I'd recommend 0 ) and Height (the altitude of your layer) to draw a surface all the way through your model.

A: You need to set height according to your column and multiplier that column with your  criteria. I did it with following way you can see screen shot of my process . this might help you


text:
Q: Can't boot into ubuntu after remove window7 My friend have a computer pre-installing window 7,but later he installed other systems including window 8,and linux. All worked fine with the grub2 for a few weeks.
Yesterday,when he removed window 7 and restart computer all worked fine.
But later he remove the partition where window7 formally located he can't boot any more just showing grub rescue.Run ls (hd0,msdosX) command,but all partitions are showing unknown filesystem.So he tried install a liveCD and mistakenly run a memory test which was terminated by him in the half of the process.
Later,I try to boot using LiveCD ubuntu 12.10,but when boot it,it just showing
SYSLINUX 4.03 2010-10-22 EDD Copyright (C) 1994-2010 H. Peter Anvin et al
This liveCD is fine and worked for me few days ago,then I try to boot using USB
SYSLINUX 4.05 2012-10-22 EDD Copyright (C) 1994-2012 H. Peter Anvin et al
 similar information displayed. What should I do?Thanks in advanced.

A: It could be that your Partition table is bonked.
Try using Testdisk with a live cd

*

*http://www.cgsecurity.org/wiki/TestDisk
To reconfigure grub from a live cd, use this excellent HOWTO

*

*http://ubuntuforums.org/showthread.php?t=1581099

A: if you have windows geinstalleerdt as first and then ubuntu. The bootloaders are on the windows partition. so the user can choose in the beginning witch Operating system it wants.
if you removed the windows partition. You permanently delete de bootloader of ubuntu too. so best option is to complete clean install.

A: Check where the boot partition is located. Windows 7 makes a 100M partition for booting. After removing Windows 7 and adding Windows 8 this partition tends to get changed. As far as I know it is still NTFS based.
There is a thread on how to restore the boot partition over at https://help.ubuntu.com/community/RestoreUbuntu/XP/Vista/7Bootloader that you should read. You need a CD or DVD that can boot and follow their instructions. Good luck.

A: I know i'm too late to answer to this thread. But follow this step when you format Windows partition after installing Ubuntu. You can do this with working Internet connection. Boot from Ubuntu live CD or Ubunt USB boot and select try Ubuntu. And open terminal by pressing Ctrl+Alt+T And install this Boot-Repair software by typing "sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update"
2. After it finish installing type "sudo apt-get install -y boot-repair && boot-repair &" and press enter. For detailed information visit this url "https://help.ubuntu.com/community/Boot-Repair"
You can also install it by preparing boot-repair cd or download iso file form this link "http://sourceforge.net/projects/boot-repair-cd/files/"
After installing Select Option "Recommanded Repair"
Note down the URL appeared after repair completes for getting further help
Mention that URL in the forum to get specific help if the above Recommanded Repair doesn't correct repair your grub. I hope this will help you next time.


text:
Q: How to specify two pods in the same job in a kubernetes yaml file? I'm trying to do something simple, just create two pods within a job. I'm looking at the documentation here: https://kubernetes.io/docs/concepts/workloads/controllers/job/#single-job-starts-controller-pod
While the documentation discusses parallelization it doesn't give much in the way of examples. The only example with one pod is given as:
apiVersion: batch/v1
kind: Job
metadata:
  name: pi
spec:
  template:
    spec:
      containers:
      - name: pi
        image: perl
        command: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]
      restartPolicy: Never
  backoffLimit: 4

To create two pods I attempted effectively this:
apiVersion: batch/v1
kind: Job
metadata:
  name: pi
spec:
  template:
    spec:
      containers:
      - name: pi1
        image: perl
        command: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]
      restartPolicy: Never
    spec:
      containers:
      - name: pi2
        image: perl
        command: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]
      restartPolicy: Never
  backoffLimit: 4

But that didn't get me two pods, instead it appears that only the second container ran in one pod.
It's not clear to me how I get my job to launch multiple pods. My pods don't need to run on the same machine, but they each need a unique environment variable to be set so the pods know what part of the work to do. The work is divided in an embarrassingly parallel way and with a fixed number of pods (2 in this example).

A: You can not have two different pod template in the same job. From the docs here
Parallel Jobs with a work queue:

*

*do not specify .spec.completions, default to .spec.parallelism.

*the Pods must coordinate amongst themselves or an external service to
determine what each should work on. For example, a Pod might fetch a
batch of up to N items from the work queue.

*each Pod is independently capable of determining whether or not all
its peers are done, and thus that the entire Job is done. when any
Pod from the Job terminates with success, no new Pods are created.

*once at least one Pod has terminated with success and all Pods are
terminated, then the Job is completed with success.

*once any Pod has exited with success, no other Pod should still be
doing any work for this task or writing any output. They should all
be in the process of exiting.
For a work queue Job, you must leave
.spec.completions

 unset, and set
.spec.parallelism

 to a non-negative integer.


text:
Q: I need to embed the value of [data:post.url] inside [onclick=" location.href = '#' "] first of all... thanks for the help.
I have in my Blogger template certain Anchor elements that I have to convert to another element type because I have problems with a JS code and I can't find another way besides changing the element.
It has helped me to change from  to
 and place inside it onclick="location.href = '#link';" instead of href="#link" (it does almost the same function):
Before: clickme
After:
clickme

But how could I do this on a  element if the link is obtained through a part of code that is only understood by the Blogger API?
It would look something like this:
<data:post.title/>

And convert it to:

<data:post.title/>

But so far, I don't know what it takes to make it work...


text: Q: How to send JavaFX TextArea through socket? I try to make simple text editor on client - server, that let edit few people the same text (sth. like google docs). And now I've got a little problem. I try to send textarea through the socket to server and server should send it to all clients, but textarea isn't serializable so I can't send it through the ObjectOutputStream. Any ideas how to solve this problem? I was looking everywhere for answer but can't find anything.


text:
Q: volume group disappeared after xfs_check run EDIT**
I have a volume group consisting of 5 RAID1 devices grouped together into a lvm and formatted with xfs.  The 5th RAID device lost its RAID config (cat /proc/mdstat does not show anything).  The two drives are still present (sdj and sdk), but they have no partitions.  The LVM appeared to be happily using sdj up until recently.  (doing a pvscan showed the first 4 RAID1 devices + /dev/sdj) I removed the LVM from the fstab, rebooted, then ran xfs_check on the LV.  It ran for about half an hour, then stopped with an error.
I tried rebooting again, and this time when it came up, the logical volume was no longer there.  It is now looking for /dev/md5, which is gone (though it had been using /dev/sdj earlier). /dev/sdj was having read errors, but after replacing the SATA cable, those went away, so the drive appears to be fine for now.
Can I modify the /etc/lvm/backup/dedvol, change the device to /dev/sdj and do a vgcfgrestore?  I could try doing a pvcreate --uuid KZron2-pPTr-ZYeQ-PKXX-4Woq-6aNc-AG4rRJ /dev/sdj to make it recognize it, but I'm afraid that would erase the data on the drive
UPDATE: just changing the pv to point to /dev/sdj did not work

vgcfgrestore --file /etc/lvm/backup/dedvol dedvol
  Couldn't find device with uuid 'KZron2-pPTr-ZYeQ-PKXX-4Woq-6aNc-AG4rRJ'.
  Cannot restore Volume Group dedvol with 1 PVs marked as missing.
  Restore failed.

pvscan
  /dev/sdj: read failed after 0 of 4096 at 0: Input/output error
  Couldn't find device with uuid 'KZron2-pPTr-ZYeQ-PKXX-4Woq-6aNc-AG4rRJ'.
  Couldn't find device with uuid 'KZron2-pPTr-ZYeQ-PKXX-4Woq-6aNc-AG4rRJ'.
  Couldn't find device with uuid 'KZron2-pPTr-ZYeQ-PKXX-4Woq-6aNc-AG4rRJ'.
  Couldn't find device with uuid 'KZron2-pPTr-ZYeQ-PKXX-4Woq-6aNc-AG4rRJ'.
  PV /dev/sdd2        VG VolGroup00   lvm2 [74.41 GB / 0    free]
  PV /dev/md2         VG dedvol       lvm2 [931.51 GB / 0    free]
  PV /dev/md3         VG dedvol       lvm2 [931.51 GB / 0    free]
  PV /dev/md0         VG dedvol       lvm2 [931.51 GB / 0    free]
  PV /dev/md4         VG dedvol       lvm2 [931.51 GB / 0    free]
  PV unknown device   VG dedvol       lvm2 [1.82 TB / 63.05 GB free]
  Total: 6 [5.53 TB] / in use: 6 [5.53 TB] / in no VG: 0 [0   ]

vgscan
  Reading all physical volumes.  This may take a while...
  /dev/sdj: read failed after 0 of 4096 at 0: Input/output error
  /dev/sdj: read failed after 0 of 4096 at 2000398843904: Input/output error
  Found volume group "VolGroup00" using metadata type lvm2
  Found volume group "dedvol" using metadata type lvm2

vgdisplay dedvol
  --- Volume group ---
  VG Name               dedvol
  System ID
  Format                lvm2
  Metadata Areas        5
  Metadata Sequence No  10
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               0
  Max PV                0
  Cur PV                5
  Act PV                5
  VG Size               5.46 TB
  PE Size               4.00 MB
  Total PE              1430796
  Alloc PE / Size       1414656 / 5.40 TB
  Free  PE / Size       16140 / 63.05 GB
  VG UUID               o1U6Ll-5WH8-Pv7Z-Rtc4-1qYp-oiWA-cPD246

dedvol {
        id = "o1U6Ll-5WH8-Pv7Z-Rtc4-1qYp-oiWA-cPD246"
        seqno = 10
        status = ["RESIZEABLE", "READ", "WRITE"]
        flags = []
        extent_size = 8192              # 4 Megabytes
        max_lv = 0
        max_pv = 0

        physical_volumes {

                pv0 {
                        id = "Msiee7-Zovu-VSJ3-Y2hR-uBVd-6PaT-Ho9v95"
                        device = "/dev/md2"     # Hint only

                        status = ["ALLOCATABLE"]
                        flags = []
                        dev_size = 1953519872   # 931.511 Gigabytes
                        pe_start = 384
                        pe_count = 238466       # 931.508 Gigabytes
                }

                pv1 {
                        id = "ZittCN-0x6L-cOsW-v1v4-atVN-fEWF-e3lqUe"
                        device = "/dev/md3"     # Hint only

                        status = ["ALLOCATABLE"]
                        flags = []
                        dev_size = 1953519872   # 931.511 Gigabytes
                        pe_start = 384
                        pe_count = 238466       # 931.508 Gigabytes
                }

                pv2 {
                        id = "NRNo0w-kgGr-dUxA-mWnl-bU5v-Wld0-XeKVLD"
                        device = "/dev/md0"     # Hint only

                        status = ["ALLOCATABLE"]
                        flags = []
                        dev_size = 1953519872   # 931.511 Gigabytes
                        pe_start = 384
                        pe_count = 238466       # 931.508 Gigabytes
                }

                pv3 {
                        id = "2EfLFr-JcRe-MusW-mfAs-WCct-u4iV-W0pmG3"
                        device = "/dev/md4"     # Hint only

                        status = ["ALLOCATABLE"]
                        flags = []
                        dev_size = 1953519872   # 931.511 Gigabytes
                        pe_start = 384
                        pe_count = 238466       # 931.508 Gigabytes
                }

                pv4 {
                        id = "KZron2-pPTr-ZYeQ-PKXX-4Woq-6aNc-AG4rRJ"
                        device = "/dev/md5"     # Hint only

                        status = ["ALLOCATABLE"]
                        flags = []
                        dev_size = 3907028992   # 1.81935 Terabytes
                        pe_start = 384
                        pe_count = 476932       # 1.81935 Terabytes
                }
        }

A: Wow, your system is badly hosed.  With enough care and attention, you could probably reconstruct the LVs in the volume group out of the LVM state archives in /etc/lvm/archives, but it'll be a lot quicker just to break out the backups (you do have backups, right?) and rebuild the system (this time with a more robust RAID setup -- if you've got 10 disks, why not just one big RAID-10?).
To put your mind at ease, I have significant doubts that if you did run xfs_check on an LV, that it could have done anything to corrupt the volume group.  Far more likely is that was already hosed, and you just hadn't noticed yet.


text:
Q: Annoying Search Behavior - Search Companion I'm running Windows XP Professional, and ever since the last service pack I've had a searching problem.
When I want to search a network drive, I get the following message:

This folder is not indexed.  To search
  this directory plase use Search
  Companion or add this directory to
  your index via options.

Basically, I have two questions.  Is there some way that I can use the indexed search where appropriate and then have it switch over to the Search Companion automatically?
Second, how does a programmer look at this code and think this is a good idea?  I realize that this question is rhetorical.  However, I must enter my search string into one search, receive the error, and then click "Search Companion" to bring up the new search window.  This window doesn't even take the defaults from the previous one so I have to specify the search string and drive again.

A: Microsoft has improved file search to the point of being too user-friendly to use.
I don't use it for non-indexed searches, but rather the Agent Ransack Freeware, which keeps the history of all past searches and can even do contents search.
I'm aware that this doesn't directly address your question, but using Agent Ransack will solve your problem.

A: Have you tried Agent Ransack? I started using it when we still used XP because it I couldn't find anything using the search on XP. I use it a lot now even on Windows 7 because I can specify a folder like system folders, which Windows doesn't do by default.
Oh and it's free as well!

A: It reports the fact that the folder isn't indexed before you start the search.
Admittedly it's in the bottom right corner of the dialog below all the input boxes, and as your focus is at the top left where the input box is you might not notice it straight away.
However, this isn't really a solution as you still have to open the old "Search Companion" to perform the search.

A: I found the solution:
Add a key called:

HKEY_CURRENT_USER\Software\Microsoft\Windows Desktop Search\DS\ShowStartSearchBand

Make sure the value is 0 and you are set.


text:
Q: Emplacing in vector using default constructor I want to use vector::emplace to default construct a non-copyable and non-assignable object and then use specific methods on the object using an iterator to the newly created object. Note that there are no parameterized constructors of the class just the default constructor. A simple example is:
#include <iostream>
#include <vector>
using namespace std;

class Test {
public:
    Test() {}
private:
    Test(const Test&) = delete;             // To make clas un-copyable.
    Test& operator=(const Test&) = delete;

    int a_;
};

int main() {
    vector<Test> test_vec;
    test_vec.emplace_back();     // <---- fails

    return 0;
}

vector::emplace() constructs a new object but requires arguments to a non-default constructor. vector::emplace_back() will construct at the end of the vector.
Is there a way to emplace with default construction. Is there a way to use piecewise construction or default forwarding perhaps using std::piecewise_construct as there is for maps? For example, in the case of maps, we can use:
std::map<int,Test> obj_map;
int val = 10;
obj_map.emplace(std::piecewise_construct,
                std::forward_as_tuple(val),
                std::forward_as_tuple());

Is there something similar for vectors?

A: As pointed out by @dyp and @Casey in the comments, std::emplace will not work for vectors of the Test class as the class is neither movable nor copyable because "the user-declared copy constructor suppresses generation of the default move constructor" (@Casey).
To use emplace here, the class will need to be movable or copyable. We can make the class movable by explicitly defining (and defaulting) the move constructors:
public:
    Test(Test&& other) = default;
    Test& operator=(Test&& other) = default;

This will also implicitly make the class not-copyable "since declaring the move operations will suppress implicit generation of the copies." (@Casey)
Now we can use std::emplace_back() and then use vector::back() to call methods of the newly created object.

A:
vector::emplace_back() will construct at the end of the vector but also require arguments.

Parameter packs can be empty. Thus the variadic template emplace_back can be called without arguments; I.e.
vector<VeryLimitedClass> vec;
vec.emplace_back();

Is valid code that initializes an object of type VeryLimitedClass through its default constructor and "emplaces" it at the back of vec.

A: For map, easy:
std::map<int, Object> obj_map;
obj_map[10]; // default-constructs an object with key 10

Otherwise, what you have works too:
obj_map.emplace(std::piecewise_construct,
                std::forward_as_tuple(10),
                std::forward_as_tuple(args, to, construct, with));

[edit] The equivalent for vector is emplace_back:
obj_vector.emplace_back(); // default construct
obj_vector.emplace_back(args, to, std::move(construct), with); // forward these


text:
Q: Scrollable dropdown menu with submenus in Bootstrap I am trying to achieve scrollable dropdown menu with sub-menus. I used the css from this post to have sub-menus in bootstrap 3. The problem is that the sub-menu is hidden within the container or is visible with a horizontal scrollbar within the container.
Here is what I have http://www.bootply.com/1OsPZq7WJC
For reference, HTML:

            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Scrollable Menu </button>

Action

Submenu

Action 1

Action 2

Action 3

Action 4

Action 5

Action 7

Action

Another action

Submenu

Action 1

Action 2

Action 3

Action 4

Action 5

Action 7

And CSS:
.scrollable-menu {
  height: auto;
  max-height: 200px;
  overflow-x: visible;
  overflow-y: scroll;
}

.dropdown-submenu{position:relative;}
.dropdown-submenu>.dropdown-menu{top:0;left:100%;margin-top:-6px;margin-left:-1px;-webkit-border-radius:0 6px 6px 6px;-moz-border-radius:0 6px 6px 6px;border-radius:0 6px 6px 6px;}
.dropdown-submenu:hover>.dropdown-menu{display:block;}
.dropdown-submenu>a:after{display:block;content:" ";float:right;width:0;height:0;border-color:transparent;border-style:solid;border-width:5px 0 5px 5px;border-left-color:#cccccc;margin-top:5px;margin-right:-10px;}
.dropdown-submenu:hover>a:after{border-left-color:#ffffff;}
.dropdown-submenu.pull-left{float:none;}.dropdown-submenu.pull-left>.dropdown-menu{left:-100%;margin-left:10px;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px;}

A: You can't force the page to adopt the height of the drop down menu unless you define a specific height. Here is the css you need to add for a full page height.
body{
  height:100vw;
}

Fiddle.


text:
Q: Magento customer login programmatically I have the code:
function loginUser( $email, $password )
{
    /** @var $session Mage_Customer_Model_Session */
    $session = Mage::getSingleton( 'customer/session' );

    try
    {
        $session->login( $email, $password );
        $session->setCustomerAsLoggedIn( $session->getCustomer() );
        return 1;
    }
    catch( Exception $e )
    {
        return $e;
    }
}

$test = loginUser("login","password");
echo "test";
print_r($test);
die;

but I always get
Mage_Core_Exception Object ( [_messages:protected] => Array ( ) [message:protected] => Invalid login or password.
Login and password is correct, I tried many accounts, with the same result.
How can I log in correctly?

A: Martin,please try below code...
 require_once "app/Mage.php";
    Mage::app('default');
    umask(0);
    Mage::getSingleton('core/session', array('name' => 'frontend'));

    $session = Mage::getSingleton('customer/session');

$session->start();

            if (!empty($email) && !empty($password )) {
                    try {
                        $session->login($email, $password );
                        if ($session->getCustomer()->getIsJustConfirmed()) {
                            $this->_welcomeCustomer($session->getCustomer(), true);
                        }
                    } catch (Mage_Core_Exception $e) {
                        switch ($e->getCode()) {
                            case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
                                $value = Mage::helper('customer')->getEmailConfirmationUrl($email);
                                $message = Mage::helper('customer')->__('This account is not confirmed. Click here to resend confirmation email.', $value);
                                break;
                            case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
                                $message = $e->getMessage();
                                break;
                            default:
                                $message = $e->getMessage();
                        }
                        $session->addError($message);
                        $session->setUsername($email);
                    } catch (Exception $e) {
                        // Mage::logException($e); // PA DSS violation: this exception log can disclose customer password
                    }
                } else {
                    $session->addError('Login and password are required.');

   }

With Out password login
try{
    $customer = Mage::getModel("customer/customer");
    $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
    $customer->loadByEmail($email); //load customer by email i
        /* if customer has ,then login */
        if($customer->getId()>0){
        $userSession = Mage::getSingleton('customer/session');
        $userSession->setCustomer($customer);
        Mage::dispatchEvent('customer_login', array('customer'=>$customer));

        }else{
            echo "Error";

        }
    }catch(Exception $e)
    {
    print_r($e->getMessage());
    }

A: <?php
function loginUser( $email, $password )
    require_once ("app/Mage.php");
    umask(0);
    ob_start();
    session_start();
    Mage::app('default');
    Mage::getSingleton("core/session", array("name" => "frontend"));

    $websiteId = Mage::app()->getWebsite()->getId();
    $store = Mage::app()->getStore();
    $customer = Mage::getModel("customer/customer");
    $customer->website_id = $websiteId;
    $customer->setStore($store);
    try {
        $customer->loadByEmail($email);
        $session = Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer);
        $session->login($email, $password);
    }catch(Exception $e){

    }

  }
?>


text:
Q: Can not get rid of Shift-Key in NSMenuItem Modifier Mask I have a NSMenuItem that has a keyboard shortcut.
I set the shortcut like this:
        // Close
    let closeItem = NSMenuItem()
    closeItem.title = Resources.QUIT
    closeItem.action = #selector(quit)
    closeItem.keyEquivalentModifierMask = [NSCommandKeyMask]
    closeItem.keyEquivalent = "Q"
    self.menu.addItem(closeItem)

Unfortunately, I can not get rid of the "Shift" key:

What is the problem with my code?

A: The solution was pretty easy: Instead of using "Q", I used "q" and the shift modifier was gone.
The new code:
self.menu.addItem(NSMenuItem(title: Resources.QUIT, action: #selector(quit), keyEquivalent: "q"))


text:
Q: How to set up Maven project to optionally generate signature files I maintain a small Java component published in Maven Central. In order to successfully publish the artifact, pgp/gpg signature files are required for all the artifacts. Following the directions here: https://central.sonatype.org/pages/apache-maven.html#gpg-signed-components, I can add this plugin to my pom.xml like this no problem.
 <build>
   <plugins>
     <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-gpg-plugin</artifactId>
       ...

and I attach it to the verify or install phase. Now, when I run: "mvn install" or "mvn deploy" the .asc files are generated automatically as desired. Note: you also have to have your pgp/gpg machinery installed and configured properly for this to work.
This works OK for me as the artifact maintainer, but if someone else wants to clone my source code, modify it, and then run mvn install so they can make a locally modified version of the component available to other projects of theirs, they have to have all this pgp/gpg machinery setup properly too, which can be a pain. And they likely don't care about having signature files.
My question is, is there a recommended pom setup so the component maintainer can generate the .asc signature files when needed for a deployment (e.g., to Maven Central), but normal usage of Maven commands don't require signature generation?
I imagine I could use a profile in my pom to handle this. I did figure out a solution, which is pretty simple.  Rather than adding the maven-gpg-plugin to my pom, I figured out I can actually just do this:
mvn clean install org.apache.maven.plugins:maven-gpg-plugin:sign deploy
This cleans everything, creates and installs all the artifacts locally, signs all the generated artifacts, and then deploys all the generated artifacts, including the signature files to the deployment target.
This does exactly what I want in 1 line without a pom modification, which is pretty cool. But are there other 'better' ways? Either way, I figured posting this way to do this might be helpful to others.

A: maven profile
One way using maven-gpg-plugin conditional it is put configuration of maven-gpg-plugin in profile.
You can simplify your profile by only add one property for skip / don't skip maven-gpg-plugin
Your project can look like:
<project ...>

   <properties>
        <gpg.skip>true</gpg.skip><!-- by default skip gpg -->
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>1.6</version>
                <configuration>
                    <!-- ... -->
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <properties>
                <gpg.skip>false</gpg.skip>
            </properties>
        </profile>
    </profiles>

</project>

another plugin
You can also consider use another plugin for making signatures, eg: https://www.simplify4u.org/sign-maven-plugin/ sign-maven-plugin by default skips execution if private key not exist on running system.
Another feature of sign-maven-plugin is that don't need external software like gpg to make signature.

A: gpp.skip property
In my poms I set the gpp.skip property to true:
<properties>
    <gpg.skip>true</gpg.skip>
</properties>

Its evaluated by the maven gpg plugin in the way, that signing is skipped by default, e.g.:
mvn install

To enable signing, you can set gpp.skip to false within pom.xml. But better you do it on the command line, so you don't have to modify your pom all the time:
mvn install -Dgpg.skip=false

You can also skip setting the property within the pom and skip signing like this:
mvn install -Dgpg.skip=true

But this way you (and other people working with your project) have to add this all the time to avoid signing. I find it more convenient when signing is turned off by default, as in the first solution. And I guess that's what you want.


text:
Q: C# get item from listbox and search from web Have a project that im working on in c#(.net). I have a listbox, that a user fills.
I need to search for every listbox item online with webclient. So i need a for loop that searches every listbox item online (same link always) individually.
Should the add new item from textbox to listbox add it in an array ? or does it create an array by itself?
Any guidance is much appreciated.

A: You can iterate through on listbox with a simple for loop, from 0->Items.Count, and add the Item to a new List. I'd rather not write the code :)
I would use List instead of array becouse you don't know how many items you'll have in the ListBox
Or you can just iterate through with for loop and in the for loop call the function for the Item (listBox.Items[i])
I hope it helped.


text:
Q: Passing a set as a parameter in Python I am trying to create a method in python (and utilizing numpy) to take a matrix A and reduce it to reduced row echelon form using the Gaussian Elimination Method.
I've run into my first problem which is trying to pass a set as a parameter.
For example:def gauss([A]): gets me an error which was surprising to me. Why is this?
Also, the way I plan to construct matrices (maybe it's the only way?) in the program is as follows:
a = numpy.array([[1 ,2 ,3] , [4 ,5 ,6] , [7 ,8 ,9]])

So I would like to be able to pass this a into my method gauss(a), and then have gauss do terrible things unto thy matrix
thank you

A: JoshAdel is right (in the now dearly departed comment) that it's normally impossible to tell what's going on without some code and sample output, but in this case I think I know:
def gauss([A]):

is not valid Python syntax. When you're declaring a function, you can't surround the parameter names with brackets. Just use
def gauss(A):

And if you want to pass a matrix/array/nested list or whatever into the function, just do it!
gauss(a)

In the method you can then treat the parameter A as a matrix.

A: Some further information in case you are new to Python and function definitions in Python.
[A] (i.e A enclosed in square brackets) is the literal expression for making a list containing A. Just as 42 is the literal expression for "making" an integer 42, 'foobar' is the literal expression for "making" the string foobar etc.
So trying to define a function with def gauss([A]): pass wouldn't make sense just as trying to define a function like def gauss(42): pass woudn't make sense.
However def gauss(a=20): pass is whole another story. In this case it creates a function with argument a and default value of 20. As a side note, it is not recommended to define a function like def gauss(a=[]): pass because [] is mutable and will cause issues as a default argument.
As others have already suggested def gauss(a): ... will fix your errors.

A: def func(param): is how you define a function. You don't "pass" anything during a function definition. Does this work?
def gauss(a):
    # do something with `a`

gauss([A])


text:
Q: PDFsharp - How to create a 2nd page I can't find documentation in PDFsharp to show how to add a 2nd page using C#!
As an example, over in VB6 I use a PDF creation method called mjwPDF.  To indicate that the page is finished
objPDF.PDFEndPage

And to start a new page:
objPDF.PDFNewPage

My PDFsharp initial settings:
// Create a new PDF document
PdfDocument document = new PdfDocument();

// Create an empty page
PdfPage page = document.AddPage();
//page.Contents.CreateSingleContent().Stream.UnfilteredValue;

// Get an XGraphics object for drawing
XGraphics gfx = XGraphics.FromPdfPage(page);

Unfortunately in PDFsharp I can't find out how to start/write on a new page.  I see these commands but can't get a second page started.
document.AddPage();
document.InsertPage();

I've tried both of these but my output continues to write on page 1, not page 2.
Any ideas would be greatly appreciated.
Here's the actual code:
private void buttonPrint_Click(object sender, EventArgs e)
{
    // Create a new PDF document
    PdfDocument document = new PdfDocument();

    // Create an empty page
    PdfPage page = document.AddPage();
    //page.Contents.CreateSingleContent().Stream.UnfilteredValue;

    // Get an XGraphics object for drawing
    XGraphics gfx = XGraphics.FromPdfPage(page);

    XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

    // Create a font
    XFont fontArial20 = new XFont("Arial", 20, XFontStyle.Bold, options);
    XFont fontArial14 = new XFont("Arial", 14, XFontStyle.Regular, options);
    XFont fontArial14Bold = new XFont("Arial", 14, XFontStyle.Bold, options);
    XFont fontArial10 = new XFont("Arial", 10, XFontStyle.Regular, options);
    XFont fontArial10Bold = new XFont("Arial", 10, XFontStyle.Bold, options);
    XFont fontArial9 = new XFont("Arial", 9, XFontStyle.Regular, options);
    XFont fontArial9Bold = new XFont("Arial", 9, XFontStyle.Bold, options);
    XFont fontArial8 = new XFont("Arial", 8, XFontStyle.Regular, options);
    XFont fontArial8Bold = new XFont("Arial", 8, XFontStyle.Bold, options);

    XFont fontCour10 = new XFont("Courier New", 10, XFontStyle.Regular, options);
    XFont fontCour10Bold = new XFont("Courier New", 10, XFontStyle.Bold, options);

    XFont printFontCour8 = new XFont("Courier New", 8, XFontStyle.Regular);
    XFont printFontCour8Bold = new XFont("Courier New", 8, XFontStyle.Bold);
    XFont printFontCour8Italic = new XFont("Courier New", 8, XFontStyle.Italic);
    XFont printFontCour10 = new XFont("Courier New", 10, XFontStyle.Regular);
    XFont printFontCour10Bold = new XFont("Courier New", 10, XFontStyle.Bold);
    XFont printFontCour14 = new XFont("Courier New", 14, XFontStyle.Bold);

    XFont printFontCour10BoldItalic = new XFont("Courier New", 10, XFontStyle.Bold | XFontStyle.Italic);

    XFont printFontArial8 = new XFont("Arial", 8, XFontStyle.Regular);
    XFont printFontArial10 = new XFont("Arial", 10, XFontStyle.Regular);
    XFont printFontArial10Bold = new XFont("Arial", 10, XFontStyle.Bold);
    XFont printFontArial14 = new XFont("Arial", 14, XFontStyle.Bold);

    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);

    Pen blackPen3 = new Pen(Color.Black, 3);
    Pen blackPen1 = new Pen(Color.Black, 1);
    Pen greyPen1 = new Pen(Color.Gray, 1);
    Pen greyPen3 = new Pen(Color.Gray, 3);
    Pen lightgreyPen1 = new Pen(Color.LightGray, 1);

    //define margins
    double leftMargin = 40.0;
    double rightMargin = 570.0;
    double topMargin = 20.0;
    double lineTop = 0d;
    double lineFooter = 780d;

    double rowStep = 12d;
    //double rowStep = 15d;

    double newRow = topMargin + rowStep;
    double beginRow = newRow;
    double currentRow = beginRow;
    double currentRowCol2 = 0;

    double firstCustomerRow = 100d;
    //double firstCustomerRow = 110d;
    //float firstCustomerRow = 120;
    double txtShift = 8d;

    string hcString = string.Empty; //---added 6-26-13

    //---top section--------------------------------------------------------
    // draw the TIW Logo
    Image Logo = Image.FromFile(Settings.Default.LogoPath);
    gfx.DrawImage(Logo, leftMargin, topMargin);

    // title & version
    string textToPrint = "TIW Purchasing - Master Buy List";
    gfx.DrawString(textToPrint, fontArial14Bold, Brushes.Black, leftMargin + 160, topMargin + 30);

    string eiNum = listView1.Items[0].Text;
    string eiDesc = listView1.Items[0].SubItems[1].Text;
    string partNum = listView1.Items[0].SubItems[2].Text;
    string partDesc = listView1.Items[0].SubItems[3].Text;
    string price = listView1.Items[0].SubItems[4].Text;
    string partType = listView1.Items[0].SubItems[5].Text;
    string partQty = listView1.Items[0].SubItems[6].Text;

    if (eiDesc.Length > 80)
        eiDesc = eiDesc.Substring(0, 80) + "...";

    textToPrint = eiNum + " - " + eiDesc;
    gfx.DrawString(textToPrint, fontArial10Bold, Brushes.Black, leftMargin, topMargin + 70);

    int lineInc = 70;

    for (int i = 0; i < listView1.Items.Count; i++)
    {
        if (listView1.Items[i].Text == eiNum)
        {
            lineInc = lineInc + 12;

            if (lineInc >= 480)
            {
                //PdfPage page2 = document.AddPage();

                document.AddPage();
                XGraphics.FromPdfPage(page);

                // title & version
                textToPrint = "TIW Purchasing - Master Buy List - (continued)";
                gfx.DrawString(textToPrint, fontArial14Bold, Brushes.Black, leftMargin + 160, topMargin + 30);

                lineInc = 70;
            }

            partNum = listView1.Items[i].SubItems[2].Text;
            partDesc = listView1.Items[i].SubItems[3].Text;
            price = listView1.Items[i].SubItems[4].Text;
            partType = listView1.Items[i].SubItems[5].Text;
            partQty = listView1.Items[i].SubItems[6].Text;

            textToPrint = partNum;
            gfx.DrawString(textToPrint, fontArial10, Brushes.Black, leftMargin + 10, topMargin + lineInc);

            //textToPrint = partDesc.Substring(0, 50);
            textToPrint = partDesc;
            gfx.DrawString(textToPrint, fontArial10, Brushes.Black, leftMargin + 70, topMargin + lineInc);

            textToPrint = price;
            gfx.DrawString(textToPrint, fontArial10, Brushes.Black, leftMargin + 450, topMargin + lineInc);

            textToPrint = partType;
            gfx.DrawString(textToPrint, fontArial10, Brushes.Black, leftMargin + 470, topMargin + lineInc);

            textToPrint = partQty;
            gfx.DrawString(textToPrint, fontArial10, Brushes.Black, leftMargin + 490, topMargin + lineInc);
        }
        else
        {
            lineInc = lineInc + 16;
            eiNum = listView1.Items[i].Text;
            eiDesc = listView1.Items[i].SubItems[1].Text;

            if (eiDesc.Length > 80)
                eiDesc = eiDesc.Substring(0, 80) + "...";

            textToPrint = eiNum + " - " + eiDesc;
            gfx.DrawString(textToPrint, fontArial10Bold, Brushes.Black, leftMargin, topMargin + lineInc);

            lineInc = lineInc + 12;

            partNum = listView1.Items[i].SubItems[2].Text;
            partDesc = listView1.Items[i].SubItems[3].Text;
            price = listView1.Items[i].SubItems[4].Text;
            partType = listView1.Items[i].SubItems[5].Text;
            partQty = listView1.Items[i].SubItems[6].Text;

            textToPrint = partNum;
            gfx.DrawString(textToPrint, fontArial10, Brushes.Black, leftMargin + 10, topMargin + lineInc);

            //textToPrint = partDesc.Substring(0, 20);
            textToPrint = partDesc;
            gfx.DrawString(textToPrint, fontArial10, Brushes.Black, leftMargin + 70, topMargin + lineInc);

            textToPrint = price;
            gfx.DrawString(textToPrint, fontArial10, Brushes.Black, leftMargin + 450, topMargin + lineInc);

            textToPrint = partType;
            gfx.DrawString(textToPrint, fontArial10, Brushes.Black, leftMargin + 470, topMargin + lineInc);

            textToPrint = partQty;
            gfx.DrawString(textToPrint, fontArial10, Brushes.Black, leftMargin + 490, topMargin + lineInc);

        }
    }

    //------ footer
    DateTime dateTime = DateTime.Now;
    String.Format("{0:F}", dateTime);
    textToPrint = "eView " + EViewMethods.eviewVersion + "                       " + Environment.UserName + "                     " + String.Format("{0:F}", dateTime);
    gfx.DrawString(textToPrint, printFontCour8Italic, Brushes.Black, leftMargin, lineFooter);

    SaveFileDialog saveFileDialog1 = new SaveFileDialog();

    saveFileDialog1.Filter = "pdf files (*.pdf)|*.pdf|All files (*.*)|*.*";
    saveFileDialog1.FilterIndex = 1;
    saveFileDialog1.RestoreDirectory = true;

    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
    {
        document.Save(saveFileDialog1.FileName);
        Process.Start(saveFileDialog1.FileName);
    }
}

Here's my corrected code:
    private void createPDF()
    {
        // Create a new PDF document
        PdfDocument document = new PdfDocument();

        // Create an empty page
        PdfPage page = document.AddPage();

        // Get an XGraphics object for drawing
        XGraphics gfx = XGraphics.FromPdfPage(page);

        XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

        // Create fonts
        XFont printFontArial8 = new XFont("Arial", 8, XFontStyle.Regular);
        XFont printFontArial10 = new XFont("Arial", 10, XFontStyle.Regular);
        XFont printFontArial10Bold = new XFont("Arial", 10, XFontStyle.Bold);
        XFont printFontCour10BoldItalic = new XFont("Courier New", 10, XFontStyle.Bold | XFontStyle.Italic);
        XFont printFontArial14 = new XFont("Arial", 14, XFontStyle.Bold);
        XFont printFontCour8 = new XFont("Courier New", 8, XFontStyle.Regular);

        // Create pen.
        Pen blackPen = new Pen(Color.Black, 3);

        float lineInc = 20.0f;
        //--------------------------------------------

        //define margins
        double leftMargin = 40.0;
        //double rightMargin = 570.0;
        double topMargin = 20.0;
        //double lineTop = 0d;
        //double lineFooter = 780d;

        string eiNum = string.Empty;
        string eiDesc = string.Empty;
        string partNum = string.Empty;
        string partDesc = string.Empty;
        string price = string.Empty;
        string partType = string.Empty;
        string partQty = string.Empty;
        string thisEndItem = string.Empty;

        string textToPrint = string.Empty;
        int pageCounter = 0;

        string filename = string.Empty;

        bool morePages = true;

        while (morePages)
        {
            if (pageCounter == 0 && counter == 0)
            {
                // draw image/logo
                Image Logo = Image.FromFile(Settings.Default.LogoPath);
                gfx.DrawImage(Logo, leftMargin, 35f);

                // draw title
                textToPrint = "TIW Purchasing - Master Buy List";
                gfx.DrawString(textToPrint, printFontArial14, Brushes.Black, leftMargin + 160f, 54f);

                // date
                DateTime thisDay = DateTime.Today;
                textToPrint = thisDay.ToString("d");
                gfx.DrawString(textToPrint, printFontArial10, Brushes.Black, leftMargin + 280f, 76f);

                eiNum = listView1.Items[0].Text;
                eiDesc = listView1.Items[0].SubItems[1].Text;

                if (eiDesc.Length > 80)
                    eiDesc = eiDesc.Substring(0, 80) + "...";

                textToPrint = eiNum + " - " + eiDesc;
                gfx.DrawString(textToPrint, printFontArial10Bold, Brushes.Black, leftMargin, topMargin + 90);
            }
            else if (pageCounter > 0)
            {
                double remainder = counter % amtperpage;
                if (remainder == 0) //---means we're at the top of the page
                {
                    //title & version
                    textToPrint = "TIW Purchasing - Master Buy List";
                    gfx.DrawString(textToPrint, printFontArial10Bold, Brushes.Black, leftMargin + 120, 54f);
                    textToPrint = "(continued from page " + page + ")";
                    gfx.DrawString(textToPrint, printFontArial10, Brushes.Black, leftMargin + 400, 54f);
                }
            }

            if (pageCounter == 0)
                lineInc = 90;
            else
                lineInc = 78;

            int stop = counter + amtperpage;

            if (stop > listView1.Items.Count)
                stop = listView1.Items.Count;

            while (counter < stop)
            {
                thisEndItem = listView1.Items[counter].SubItems[0].Text;

                partNum = listView1.Items[counter].SubItems[2].Text;
                partDesc = listView1.Items[counter].SubItems[3].Text;
                price = listView1.Items[counter].SubItems[4].Text;
                partType = listView1.Items[counter].SubItems[5].Text;
                partQty = listView1.Items[counter].SubItems[6].Text;

                if (thisEndItem == eiNum) //---still working on the same end item
                {
                    lineInc += 12;

                    textToPrint = partNum;
                    gfx.DrawString(textToPrint, printFontArial10, Brushes.Black, leftMargin + 10, topMargin + lineInc);

                    if (partDesc.Length > 70)
                        partDesc = partDesc.Substring(0, 70) + "...";
                    textToPrint = partDesc;
                    gfx.DrawString(textToPrint, printFontArial10, Brushes.Black, leftMargin + 70, topMargin + lineInc);

                    textToPrint = price;
                    gfx.DrawString(textToPrint, printFontArial10, Brushes.Black, leftMargin + 600, topMargin + lineInc);

                    textToPrint = partType;
                    gfx.DrawString(textToPrint, printFontArial10, Brushes.Black, leftMargin + 630, topMargin + lineInc);

                    textToPrint = partQty;
                    gfx.DrawString(textToPrint, printFontArial10, Brushes.Black, leftMargin + 670, topMargin + lineInc);
                }
                else //---starting a new end item
                {
                    lineInc += 16;

                    eiNum = listView1.Items[counter].Text;
                    eiDesc = listView1.Items[counter].SubItems[1].Text;

                    if (eiDesc.Length > 80)
                        eiDesc = eiDesc.Substring(0, 80) + "...";

                    textToPrint = eiNum + " - " + eiDesc;
                    gfx.DrawString(textToPrint, printFontArial10Bold, Brushes.Black, leftMargin, topMargin + lineInc);
                }

                counter++;
            }

            //---footer-------------------------------
            DateTime dateTime = DateTime.Now;
            textToPrint = "eView " + EViewMethods.eviewVersion + "                       " + Environment.UserName + "                     " + String.Format("{0:F}", dateTime);
            gfx.DrawString(textToPrint, printFontCour8, Brushes.Black, leftMargin, 1060f);

            printpagenum = pageCounter + 1;
            textToPrint = printpagenum.ToString();
            gfx.DrawString(textToPrint, printFontArial10Bold, Brushes.Black, leftMargin + 740, 1060f);
            //----------------------------------------

            if (counter == listView1.Items.Count)
            {
                morePages = false;
            }
            else
            {
                pageCounter++;
                page = document.AddPage();
                gfx = XGraphics.FromPdfPage(page);
            }
        }

        SaveFileDialog saveFileDialog1 = new SaveFileDialog();

        saveFileDialog1.Filter = "pdf files (*.pdf)|*.pdf|All files (*.*)|*.*";
        saveFileDialog1.FilterIndex = 1;
        saveFileDialog1.RestoreDirectory = true;

        if (saveFileDialog1.ShowDialog() == DialogResult.OK)
        {
            document.Save(saveFileDialog1.FileName);
            Process.Start(saveFileDialog1.FileName);
        }
    }

A: Do not forget to update your "canvas" or "graphics" object variable to the new page:
You may be doing something like this:
// First time:
this.page = document.AddPage();
this.gfx = XGraphics.FromPdfPage(page);

...

// next time (forgot to update graphics or canvas variable):
this.page = document.AddPage();

And, it should be something like:
// First time:
this.page = document.AddPage();
this.gfx = XGraphics.FromPdfPage(page);

...

// next time:
this.page = document.AddPage();
// update graphics object, also
this.gfx = XGraphics.FromPdfPage(page);

I also made that mistake.

A: You create a new page with
document.AddPage();

and then call
XGraphics.FromPdfPage(page);

to get a gfx object for the second page (probably this is the missing step).
So repeat those steps from your code sample for every new page:
// Create an empty page
PdfPage page = document.AddPage();

// Get an XGraphics object for drawing
XGraphics gfx = XGraphics.FromPdfPage(page);

Update: In your loop you do the following:
document.AddPage();
XGraphics.FromPdfPage(page);

AddPage() returns a "handle" to the newly created page - which you throw in the bin.
Then you call "XGraphics.FromPdfPage()" to create yet another gfx for the first page - which you also would throw in the bin, but you get an exception since there already is a gfx for the first page.
A small change should do the trick:
page = document.AddPage();
gfx = XGraphics.FromPdfPage(page);

See also:
http://www.pdfsharp.net/wiki/PageSizes-sample.ashx
"I never dreamed adding a second page could be so difficult! No luck with the suggested code."
PDFsharp includes quite a few working samples to get people going. No luck with the suggested code since you ignored the important part - the values returned by the methods.

A: Before trying to create a new XGraphics object for the new page, dispose the old existing object:
xgrObject.Dispose();

A: you can print in multiple pages by decreasing the size of "Ypoint" as shown below code.
its given value is "yPoint = yPoint + 40"
change it to "yPoint = yPoint + 8" i.e increment ypoint by +8 in every loop iteration,
reply for any doubts.
refer while loop below
        While dr.Read

            username = dr.Item(0)
            Action_Performed = dr.Item(1)
            datetim = dr.Item(2)

            graph.DrawString(username, font, XBrushes.Black, _
               New XRect(40, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft)

            graph.DrawString(Action_Performed, font, XBrushes.Black, _
              New XRect(280, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft)

            graph.DrawString(datetim, font, XBrushes.Black, _
               New XRect(420, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft)
            yPoint = yPoint + 10
            counter += 1
            If counter = 30 Then
                pdfPage = pdf.AddPage()
                graph.Dispose()
                graph = XGraphics.FromPdfPage(pdfPage)
                font = New XFont("Verdana", 7, XFontStyle.Regular)
                yPoint = 0
                yPoint = yPoint + 100
                counter = 0
            End If
        End While
        Dim pdfFilename As String = "dbtopdf.pdf"
        pdf.Save(pdfFilename)
        Process.Start(pdfFilename)

regards,
Shivanand