text:
Q: WindowBuilder Unable to load *.wbp-component.xml description I've installed the last version (1.9.7) of WindowBuilder.
When i create the "Application Window" i receive the following error
Unable to load *.wbp-component.xml description.
does anyone know the problem and how to fix it?
Thank you.

A: I'm having the same problem. Everything was fine until recently when I switched from windows 7 to windows 10 (not sure if it makes a difference but who knows). I'm kinda newbie in all of this, but I thought it might help if I showed the stack trace. Personally I think the problem might be with the java path if that makes any sense. I remember that I did something when I installed for the first time (university, professor showed us what to do, but I can't remember what it was (some kind of pathing)).

org.eclipse.wb.internal.core.utils.exception.DesignerException: 502 (Unable to load *.wbp-component.xml description.). javax.swing.JFrame
    at org.eclipse.wb.internal.core.model.description.helpers.ComponentDescriptionHelper.getDescription0(ComponentDescriptionHelper.java:442)
    at org.eclipse.wb.internal.core.model.description.helpers.ComponentDescriptionHelper.getDescription0(ComponentDescriptionHelper.java:289)
    at org.eclipse.wb.internal.core.model.description.helpers.ComponentDescriptionHelper.getDescription(ComponentDescriptionHelper.java:258)
    at org.eclipse.wb.internal.core.model.JavaInfoUtils.createJavaInfo(JavaInfoUtils.java:387)
    at org.eclipse.wb.internal.swing.parser.ParseFactory.getRootContext(ParseFactory.java:128)
    at org.eclipse.wb.internal.core.parser.JavaInfoParser.prepareParseContext(JavaInfoParser.java:1182)
    at org.eclipse.wb.internal.core.parser.JavaInfoParser.parse(JavaInfoParser.java:242)
    at org.eclipse.wb.internal.core.parser.JavaInfoParser.access$9(JavaInfoParser.java:238)
    at org.eclipse.wb.internal.core.parser.JavaInfoParser$1.runObject(JavaInfoParser.java:153)
    at org.eclipse.wb.internal.core.parser.JavaInfoParser$1.runObject(JavaInfoParser.java:1)
    at org.eclipse.wb.internal.core.utils.execution.ExecutionUtils.runDesignTime(ExecutionUtils.java:159)
    at org.eclipse.wb.internal.core.parser.JavaInfoParser.parse(JavaInfoParser.java:151)
    at org.eclipse.wb.internal.core.editor.DesignPage.internal_refreshGEF(DesignPage.java:534)
    at org.eclipse.wb.internal.core.editor.DesignPage.access$9(DesignPage.java:522)
    at org.eclipse.wb.internal.core.editor.DesignPage$8$1.run(DesignPage.java:449)
    at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:236)
    at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:133)
    at org.eclipse.swt.widgets.Display.syncExec(Display.java:4779)
    at org.eclipse.wb.internal.core.editor.DesignPage$8.run(DesignPage.java:446)
    at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:434)
    at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:352)
    at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:468)
    at org.eclipse.wb.internal.core.editor.DesignPage.internal_refreshGEF_withProgress(DesignPage.java:465)
    at org.eclipse.wb.internal.core.editor.DesignPage.internal_refreshGEF(DesignPage.java:415)
    at org.eclipse.wb.internal.core.editor.UndoManager.refreshDesignerEditor(UndoManager.java:381)
    at org.eclipse.wb.internal.core.editor.DesignPage.refreshGEF(DesignPage.java:392)
    at org.eclipse.wb.internal.core.editor.actions.RefreshAction.run(RefreshAction.java:46)
    at org.eclipse.wb.internal.core.editor.actions.DesignPageAction.run(DesignPageAction.java:34)
    at org.eclipse.wb.internal.core.editor.errors.JavaExceptionComposite.doRefresh(JavaExceptionComposite.java:87)
    at org.eclipse.wb.internal.core.editor.errors.ExceptionComposite$3.widgetSelected(ExceptionComposite.java:129)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4243)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1060)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4060)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3632)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1154)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1045)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1467)

Caused by:

 java.lang.reflect.InaccessibleObjectException: Unable to make protected java.lang.String javax.swing.JFrame.paramString() accessible: module java.desktop does not "opens javax.swing" to unnamed module @38c6f088
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
    at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
    at org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.appendPropertyComponents(ReflectionUtils.java:1560)
    at org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.getPropertyDescriptors(ReflectionUtils.java:1469)
    at org.eclipse.wb.internal.core.model.description.rules.StandardBeanPropertiesRule.begin(StandardBeanPropertiesRule.java:47)
    at org.apache.commons.digester.Digester.startElement(Digester.java:1563)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:518)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:183)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1387)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2726)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:542)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:889)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:825)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224)
    at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:637)
    at org.apache.commons.digester.Digester.parse(Digester.java:1887)
    at org.eclipse.wb.internal.core.model.description.helpers.ComponentDescriptionHelper.getDescription0(ComponentDescriptionHelper.java:389)
    ... 56 more

Full context stack trace:

org.eclipse.wb.internal.core.utils.exception.DesignerException: 502 (Unable to load *.wbp-component.xml description.). javax.swing.JFrame
    at org.eclipse.wb.internal.core.model.description.helpers.ComponentDescriptionHelper.getDescription0(ComponentDescriptionHelper.java:442)
    at org.eclipse.wb.internal.core.model.description.helpers.ComponentDescriptionHelper.getDescription0(ComponentDescriptionHelper.java:289)
    at org.eclipse.wb.internal.core.model.description.helpers.ComponentDescriptionHelper.getDescription(ComponentDescriptionHelper.java:258)
    at org.eclipse.wb.internal.core.model.JavaInfoUtils.createJavaInfo(JavaInfoUtils.java:387)
    at org.eclipse.wb.internal.swing.parser.ParseFactory.getRootContext(ParseFactory.java:128)
    at org.eclipse.wb.internal.core.parser.JavaInfoParser.prepareParseContext(JavaInfoParser.java:1182)
    at org.eclipse.wb.internal.core.parser.JavaInfoParser.parse(JavaInfoParser.java:242)
    at org.eclipse.wb.internal.core.parser.JavaInfoParser.access$9(JavaInfoParser.java:238)
    at org.eclipse.wb.internal.core.parser.JavaInfoParser$1.runObject(JavaInfoParser.java:153)
    at org.eclipse.wb.internal.core.parser.JavaInfoParser$1.runObject(JavaInfoParser.java:1)
    at org.eclipse.wb.internal.core.utils.execution.ExecutionUtils.runDesignTime(ExecutionUtils.java:159)
    at org.eclipse.wb.internal.core.parser.JavaInfoParser.parse(JavaInfoParser.java:151)
    at org.eclipse.wb.internal.core.editor.DesignPage.internal_refreshGEF(DesignPage.java:534)
    at org.eclipse.wb.internal.core.editor.DesignPage.access$9(DesignPage.java:522)
    at org.eclipse.wb.internal.core.editor.DesignPage$8$1.run(DesignPage.java:449)
    at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:236)
    at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:133)
    at org.eclipse.swt.widgets.Display.syncExec(Display.java:4779)
    at org.eclipse.wb.internal.core.editor.DesignPage$8.run(DesignPage.java:446)
    at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:434)
    at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:352)
    at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:468)
    at org.eclipse.wb.internal.core.editor.DesignPage.internal_refreshGEF_withProgress(DesignPage.java:465)
    at org.eclipse.wb.internal.core.editor.DesignPage.internal_refreshGEF(DesignPage.java:415)
    at org.eclipse.wb.internal.core.editor.UndoManager.refreshDesignerEditor(UndoManager.java:381)
    at org.eclipse.wb.internal.core.editor.DesignPage.refreshGEF(DesignPage.java:392)
    at org.eclipse.wb.internal.core.editor.actions.RefreshAction.run(RefreshAction.java:46)
    at org.eclipse.wb.internal.core.editor.actions.DesignPageAction.run(DesignPageAction.java:34)
    at org.eclipse.wb.internal.core.editor.errors.JavaExceptionComposite.doRefresh(JavaExceptionComposite.java:87)
    at org.eclipse.wb.internal.core.editor.errors.ExceptionComposite$3.widgetSelected(ExceptionComposite.java:129)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4243)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1060)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4060)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3632)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1154)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1045)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1467)

Caused by:

java.lang.reflect.InaccessibleObjectException: Unable to make protected java.lang.String javax.swing.JFrame.paramString() accessible: module java.desktop does not "opens javax.swing" to unnamed module @38c6f088
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
    at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
    at org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.appendPropertyComponents(ReflectionUtils.java:1560)
    at org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.getPropertyDescriptors(ReflectionUtils.java:1469)
    at org.eclipse.wb.internal.core.model.description.rules.StandardBeanPropertiesRule.begin(StandardBeanPropertiesRule.java:47)
    at org.apache.commons.digester.Digester.startElement(Digester.java:1563)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:518)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:183)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1387)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2726)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:542)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:889)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:825)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224)
    at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:637)
    at org.apache.commons.digester.Digester.parse(Digester.java:1887)
    at org.eclipse.wb.internal.core.model.description.helpers.ComponentDescriptionHelper.getDescription0(ComponentDescriptionHelper.java:389)
    ... 56 more

The code itself doesn't matter, it's same for everything, every time, same error, used codes that worked on my friends PC.
I hope I attached the image correctly.
Thanks on any help :)
If I find the solution, I will post it here :D
image here


text:
Q: How can I separate numbers and letters in a C++ String? I'm having several input strings containing numbers and letters. Sometimes the space is missing. I would like to add an additional Space each time the string changes from numbers to letters or from letters to numbers.
Example inputs:
"30EinsteinStreet"
"548 Roe Drive5500 TestCity"
"44B SaarlouisDrive1234Testtown"

they should become:
"30 EinsteinStreet"
"548 Roe Drive 5500 TestCity"
"44 B SaarlouisDrive 1234 Testtown"

My existing function is not working and I think far to complex. Can anyone provide an easy solution? Preferably using modern C++11 classes but no Boost. Also I'm using GCC so all the regex stuff doesn't work for me.
Thanks
Here is my existing method:
        inline string separateAlphanumChunks(const std::string& s)
        {
            string ret = "";
            const int sl = s.length();
            //int inserts = 0;

            if (sl<=4)
                return s;

            for (int i=0 ; i< sl ; i++)
            {
//              cerr << "separateAlphanumChunks: '" << ret << "'" <<endl;
                // check if index would go out of range
                if (i+4 > sl)
                {
                    ret += s.substr (i,sl-i);
                    //TODO add the remain to ret
                    break;
                }

                // seperate chars
                const char c0 = s[i+0];
                const char c1 = s[i+1];

                // check if 0 and 1 are the same class
                const bool c0c = isCharAnInt (c0);
                const bool c1c = isCharAnInt (c1);
                bool class0 = false;
                if (c0c == c1c)
                {
                    class0 = c0c;
                }
                else
                {
                    ret += c0;
//                  cerr << "cont1: '" << c0 << "'" <<endl;
                    continue;
                }

                // seperate chars
                const char c2 = s[i+2];
                const char c3 = s[i+3];

                // check if 2 and 3 are the same class
                const bool c2c = isCharAnInt (c2);
                const bool c3c = isCharAnInt (c3);
                bool class2 = false;
                if (c2c == c3c)
                {
                    class2 = c2c;
                }
                else
                {
                    ret += c0;
//                  cerr << "cont2: '" << c0 << "'" <<endl;
                    continue;
                }

                // check if the 2 classes are different
                if (class0 != class2)
                {
                    // split!
                    ret += c0+(c1+string(" ")+c2)+c3;
                    //inserts++;
                    i+=3;
                }
                else
                {
                    ret += c0;
//                  cerr << "cont3: '" << c0 << "'" <<endl;
                    continue;
                }

            }

            // remove double spaces
            //replaceStringInPlace(ret, "  "," ");
            //cerr << "separateAlphanumChunks: '" << ret << "'" <<endl;
            return ret;
        }

    inline bool isCharAnInt (char c)
    {
        //TODO might be able to use isdigit() here
        int i = c - '0';
        return ((i>=0) && (i<=9));
    }

A: I saw various complex answers, and this is the reason to give another answer too.
The answer of your problem is exactly in the problem statement:
"add an additional Space each time the string changes from numbers to letters or from letters to numbers."
So here is exactly what you want ( I used some code from a previous answer ) the compilation should be done using the flag -std=c++11
#include <string>
#include <iostream>
using namespace std;

enum charTypeT{ other, alpha, digit};

charTypeT charType(char c){
    if(isdigit(c))return digit;
    if(isalpha(c))return alpha;
    return other;
}

string separateThem(string inString){
  string oString = "";charTypeT st=other;
    for(auto c:inString){
        if( (st==alpha && charType(c)==digit) || (st==digit && charType(c)==alpha) )
          oString.push_back(' ');
        oString.push_back(c);st=charType(c);
    }
    return oString;
}

int main(){
  string str1 = "30EinsteinStreet";
  string str2 = "548 Roe Drive5500 TestCity";
  string str3 = "44B SaarlouisDrive1234Testtown";

  cout << separateThem(str1) << endl;
  cout << separateThem(str2) << endl;
  cout << separateThem(str3) << endl;
}

A: I think what you are looking for and what Ajay is hinting at is a finite-state machine to parse strings.
Although this is not a C++11 solution, and you might find more elegant solutions by means of regex, I provided the code sample below.
#include <iostream>
#include <sstream>

bool isDigit(const char c)
{
    bool res = true;
    switch (c)
    {
        case '0': case '1': case '2': case '3': case '4':
        case '5': case '6': case '7': case '8': case '9':
            break;

        default:
            res = false;
            break;
    }
    return res;
}

std::string separateNumbers(const std::string& inputString)
{
    const size_t N = inputString.length();
    std::ostringstream os;
    bool readDigit = false;
    for (size_t i = 0; i < N; ++i)
    {
        if (isDigit(inputString[i]))
        {
            if ((i > 0) && (i < N) && (! readDigit))
            {
                if (inputString[i] != ' ')
                    os << ' ';
            }
            readDigit = true;
        }
        else
        {
            if ((i > 0) && (i < N) && (readDigit))
            {
                if (inputString[i] != ' ')
                    os << ' ';
            }
            readDigit = false;
        }
        os << inputString[i];
    }
    return os.str();
}

int main(int argc, char** argv)
{
    std::string strings[3] = {
        "30EinsteinStreet",
        "548 Roe Drive5500 TestCity",
        "44B SaarlouisDrive1234Testtown"
    };

    for (int i = 0; i < 3; ++i)
    {
        std::cout << "input #" << i << ": " << strings[i] << std::endl;
        std::cout << "output #" << i << ": " << separateNumbers(strings[i]) << std::endl;
        std::cout << std::endl;
    }

    return 0;
}

A: Here is my five cents.
#include <iostream>
#include <string>
#include <cctype>

std::string SeparateAlphanumChunks( const std::string &s )
{
    std::string::size_type n = 0;
    bool ctype = std::isdigit( s[0] );

    for ( char c : s )
    {
        if ( !ctype != !std::isdigit( c ) )
        {
            ctype = std::isdigit( c );
            if ( !isblank( c ) ) ++n;
        }
    }

    std::string t;
    t.reserve( s.size() + n );

    ctype = std::isdigit( s[0] );

    for ( char c : s )
    {
        if ( !ctype != !std::isdigit( c ) )
        {
            ctype = std::isdigit( c );
            if ( !isblank( c ) ) t.push_back( ' ');
        }
        t.push_back( c );
    }

    return t;
}

int main()
{
    for ( const std::string &s : { "30EinsteinStreet",
                                   "548 Roe Drive5500 TestCity",
                                   "44B SaarlouisDrive1234Testtown"
                                 } )
    {
        std::cout << SeparateAlphanumChunks( s ) << std::endl;
    }

    return 0;
}

The output is
30 EinsteinStreet
548 Roe Drive 5500 TestCity
44 B SaarlouisDrive 1234 Testtown

You also may change the string "in place". For example
#include <iostream>
#include <string>
#include <cctype>

std::string & SeparateAlphanumChunks( std::string &s )
{
    std::string::size_type n = 0;
    bool ctype = std::isdigit( s[0] );

    for ( char c : s )
    {
        if ( !ctype != !std::isdigit( c ) )
        {
            ctype = std::isdigit( c );
            if ( !isblank( c ) ) ++n;
        }
    }

    s.reserve( s.size() + n );

    ctype = std::isdigit( s[0] );

    for ( std::string::size_type i = 0; i < s.size(); i++ )
    {
        if ( !ctype != !std::isdigit( s[i] ) )
        {
            ctype = std::isdigit( s[i] );
            if ( !isblank( s[i] ) )
            {
                s.insert( i, 1, ' ' );
            }
        }
    }

    return s;
}

int main()
{
    for ( std::string s : { "30EinsteinStreet",
                            "548 Roe Drive5500 TestCity",
                                "44B SaarlouisDrive1234Testtown"
                              } )
    {
        std::cout << SeparateAlphanumChunks( s ) << std::endl;
    }

    return 0;
}

A: What I would suggest is to go trough a iteration trough string elements.
Something like that will help:
#include <string>
#include <iostream>
using namespace std;

string separateThem(string inString){
  string numbers = "1234567890";
  string oString = "";
  int i;
  for(i=0; i<inString.size()-1; i++){
    if ((numbers.find(inString[i]) != string::npos) && (numbers.find(inString[i+1]) == string::npos) && !isspace(inString[i+1])){
      oString += inString.substr(i,1) + " ";
    }
    else if ((numbers.find(inString[i]) == string::npos) && (numbers.find(inString[i+1]) != string::npos) && !isspace(inString[i+1])){
      oString += inString.substr(i,1) + " ";
    }
else oString += inString.substr(i,1);
  }
  oString += inString.substr(i,1);
  return oString;
}

int main(){
  string str1 = "30EinsteinStreet";
  string str2 = "548 Roe Drive5500 TestCity";
  string str3 = "44B SaarlouisDrive1234Testtown";

  cout << separateThem(str1) << endl;
  cout << separateThem(str2) << endl;
  cout << separateThem(str3) << endl;
}

If you execute this the output will be:
30 EinsteinStreet
548 Roe Drive 5500 TestCity
44 B SaarlouisDrive 1234 Testtown

Hope this helps :)

A: Upgrade to GCC 4.9 (whose first release was back in April) and use a simple regex:
#include <regex>
#include <iostream>

std::string fix(const std::string& in)
{
    return std::regex_replace(
        in,
        std::regex("(?:([a-zA-Z])([0-9]))|(?:([0-9])([a-zA-Z]))"),
        "\\1\\3 \\2\\4",
        std::regex_constants::format_sed
    );
}

int main()
{
    const std::string in[] = {
        "30EinsteinStreet",
        "548 Roe Drive5500 TestCity",
        "44B SaarlouisDrive1234Testtown"
    };

    for (auto el : in)
        std::cout << fix(el) << '\n';
}

/*
"30 EinsteinStreet"
"548 Roe Drive 5500 TestCity"
"44 B SaarlouisDrive 1234 Testtown"
*/

(live demo)

A: I would suggest you to iterator the string as raw-string (i.e. string::c_str()), and generate a new string altogether. This would be my algorithm (not very complete):

*

*For each character, check if it is a digit. If no, just append to new string.

*If yes, check if it is first character - if yes, just append to new string.

*If the digit is last character, then append to new string.

*If digit is falling in between, check if last appended character was space. If no space was there, put a space, and then put digit.

*If last inserted character was a digit, and this is also a digit, insert.

*However, if last was digit, but this is not a digit (and not a space), then insert a space.

You may need to tweak it further.
What if string is like this:
"enter 144    code   here    123    "

?

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to open serial port programatically? I have an Arduino connected to Raspberry Pi running Arch.
The arduino has not much to do, but to constantly print some sensor data:
#include<Arduino.h>

void setup() {
    Serial.begin(9600);
}

float temp = .0;
int lumen = 0;

void loop() {
    if(Serial.available()) {
        temp = analogRead(4) * .4882812 - 273.15;
        lumen = analogRead(0);
        Serial.print(temp);
        Serial.print("|");
        Serial.print(lumen);
        Serial.println();
    }
    delay(10);
}

On the Raspberry, following script will run:
# run.py
#!/usr/bin/env python2
from arduino import Arduino
from poster import Poster
import time
import subprocess
import json

if __name__ == '__main__':
    with open("config.json") as config_fh:
        config = json.load(config_fh)
        print(config)

    base_url = config["URL"]
    security_token = config["KEY"]
    port = config["TTY"]

    arduino = Arduino(port=port)
    arduino.start()
    time.sleep(1)

    while True:
        is_door_open = arduino.is_door_open()
        temperature = arduino.get_temperature()

        print arduino.is_door_open()
        print arduino.get_temperature()

#       nmap = subprocess.Popen("./networkClientsInNetwork.sh", stdout = subprocess.PIPE, stderr = subprocess.PIPE)
#       network_clients_count = int(nmap.stdout.readlines()[0])
#       print network_clients_count

#       poster = Poster()
#       poster.post_door_state(base_url, arduino.is_door_open(), security_token)
#       poster.post_temperature(base_url, str(arduino.get_temperature()), security_token)
#       poster.post_clients(base_url, str(network_clients_count), security_token)

        time.sleep(3)

from threading import Thread
import serial
import random
import time

This is the thread which constantly should get the values from the serial port:
class Arduino(Thread):
    def __init__(self, port):
        Thread.__init__(self, target=self.recieve)
        self.daemon = True
        self.last_recieved = None

        self.serial = self.configure_port(port)
        self.serial.open()

    def configure_port(self, port_id):
        ser = serial.Serial(port=port_id, timeout=1)
        ser.rtscts = True
        ser.dsrdtr = True

        return ser

    def recieve(self):
        while True:
            self.serial.flushInput()
            self.serial.flushOutput()
            if self.serial.isOpen():
                self.last_recieved = self.serial.readline().replace("\r\n", "").split("|")

    def getLastRecieved(self):
        return self.last_recieved

    def is_door_open(self):
        try:
            lumen = int(self.getLastRecieved()[1])
            return_val = lumen > 150
        except Exception:
            return_val = None
            pass

        return return_val

    def get_temperature(self):
        try:
            temperature = int(float(self.getLastRecieved()[0]))
            temperature_offset = -5
            return_val = int(temperature) + temperature_offset
        except Exception:
            return_val = None
            pass

        return return_val

Now, when I start run.py for the first time, it never will get the data from the serial port. They always will be None.
When I run
ino serial (which  starts picocom)
and hit Enter, the Arduino sends all its data in the stream. If I exit picocom via Q and then start run.py, the python script can read all the data from the serial port.
So I am wondering: What am I missing in the initalization? How can I automate the serial port initalization with picocom via python?

A: I use the following code to connect to my arduino using python and receive data:
import serial

class Arduino():
def __init__(self):
    try:
        self.arduino = serial.Serial('/dev/ttyUSB0', 9600)
        self.receivethread = threading.Thread(target=self.receive)
        #self.receivethread.start()
    except serial.error as message:
        pass
    except threading.ThreadError as message:
        pass
    except Exception as message:
        pass

def receive(self):
    while 1:
        if self.arduino.open():
            try:
                datapacket = self.arduino.readline(30, chr(0))
            except Exception as message:
                pass
            except serial.error as message:
                pass)
        else:
                pass

    return datapacketdecoded

A: I have worked around the issue by begging the question. I changed my Arduino loop method to:
void loop() {
    temp = analogRead(4) * .4882812 - 273.15;
    lumen = analogRead(0);
    Serial.print(temp);
    Serial.print("|");
    Serial.print(lumen);
    Serial.println();
    delay(10);
}

This will make the run.py without the magic initialization via picocom. Though I still would like to know what Serial.available() expects as input.

A: import serial

ser=serial.Serial('/dev/ttyUSB0', 9600, timeout=3)


text:
Q: Why is my float object not callable? Literally copied this code from an example notebook and it's not working alpha = 0.5;  # Contrast control

name = input('Your name: ')
print('Hello,', name)
#input = float(input("Enter alpha [0.0-1.0]: "))

# # We use the alpha provided by the user if it is between 0 and 1
# if( input >= 0, input <= 1 ):
#       alpha = input;

betax = 1 - alpha; # Brightness control

This is the error i'm getting:
TypeError                                 Traceback (most recent call last)
<ipython-input-28-b7a9133002e1> in <module>()
      3 alpha = 0.5;  # Contrast control
      4
----> 5 name = input('Your name: ')
      6 print('Hello,', name)
      7 #input = float(input("Enter alpha [0.0-1.0]: "))

TypeError: 'float' object is not callable

I have no idea why this doesn't work. I'm working in google colab btw. It's a really weird situation because the code on line 7 works once, but then when I run it again I get the same error. This happened multiple times so I tried copying an example code for inputting and I'm getting the same error, yet this exact same code works in other notebooks. Also the code on line 7 works without problems on my classmate's computer. What am I doing wrong?


text:
Q: rails-boilerplate (0.1.9) gem mirror Using paperclip (3.2.0)
Using polyamorous (0.5.0)
Using pr_geohash (1.0.0)
Using slop (3.3.3)
Using pry (0.9.10)
Using pry-rails (0.2.2)

Gem::RemoteFetcher::FetchError: too many connection resets (http://tokyo-m.rubygems.org/gems/rails-boilerplate-0.1.9.gem)
  An error occurred while installing rails-boilerplate (0.1.9), and Bundler cannot continue.
  Make sure that gem install rails-boilerplate -v '0.1.9' succeeds before bundling.

Today, I applied bundle install in my rails directory, but i found out that the mirror where i get the gem rails-boilerplate is not available now? HOw can i modify the references of the mirror? I have tried:

gem install --source http://rubygems.org/downloads rails-boilerplate

but it also failed.

A: gem install rails-boilerplate -v '0.1.9'
Worked just fine for me.  My sources are:
gem sources -l
*** CURRENT SOURCES ***

http://rubygems.org/

In general, all stable gem releases should be there even if the project is hosted on Github or elsewhere.  If you need to grab a different fork of it or a pre-release version, you may have to specify a different source, but in your case 0.1.0 looks like the current release version.  Somehow your gem source is set to fetch from
http://tokyo-m.rubygems.org/gems/rails-boilerplate-0.1.9.gem

What do you get when you run
gem sources -l

Since you get the error when installing directly with gem and when running bundle, I assume that the problem is in your default gem sources.  You should check the source list with the command above, and alter the list with
gem sources -r SOURCE_URI

to remove, or
gem sources -a SOURCE_URI

to add a new one.  I don't know if you should leave the http://tokyo-m.rubygems.org source there or not - it depends on if you have some nonstandard version of a gem installed from there or not.  If you do, I would suggest adding that source in your Gemfile, NOT as your gem source.  This can be done with something like this:
gem 'prototype_legacy_helper',
    '0.0.0',
    :git => 'git://github.com/rails/prototype_legacy_helper.git'

in your Gemfile.  Good luck!


text:
Q: SharePoint 2013 and Online: Customized blog post display I'm trying to customise the display of a blog post item (individual post) to add a "feature image" to the top of the post, and to change the Author to a custom People picker field.
From my understanding, an individual blog post's display is controlled by the blog.xsl file, which i cannot access on SP Online.
I have seen some solutions for customizing a blog post by:

*

*Making a copy of blog.xsl, and referencing the custom blog.xsl in the webpart

*Using javascript to alter the display

Even with following instructions, neither of these solutions have not worked for me on my SP Online test site or my SP 2013 test site.
Questions:
How do I go about adding custom fields to an individual Post?
I haven't seen any instructions on how to do this for SP2013, only for SP 2010 and 2007. Is that because there isn't a significant difference between Blog sites across versions/editions?
Edit/Update:
I think I have discovered what has been going on. I have managed to add custom fields to my on site SP2013 blog, but it reverts the view back to look the same at SP2010 blog.
I found a blog that says:

...out of the box, the SharePoint 2013 blog (and any other Document or
List App) will use Client Side Rendering (CSR). CSR allows you to
style lists and libraries using JavaScript. ... However, it means
that the content is not semantic HTML on the page, rather it's a
JavaScript object...
https://bradbrook-public.sharepoint.com/Blog/Post/7/Improve-the-SEO-of-a-SharePoint-2013-blog

I suspect that the only difference between a SP2013 blog and a SP2010 blog is the CSR/Javascript to change appearance and the html between versions is the same. Can anyone confirm this?
Also, I noted that applying a new CustomBlog.xsl removed the Like functionality. I assume then that the likes functionality is tied in with the js that changes appearance of the posts, so a new xsl means the javascript doesn't run.
.
NOTE: I'm still very new to xsl (Teaching myself, and getting there) and brand new to javascript.


text:
Q: Android : Static variable null on low memory I have an application which has some static variables.
These variables are stored in an independent Class named DataContext.
These variables are initialized from raw files at the application start (a method named DataContext.initConstant() is called in the onCreate() of MyApplication which extends Application).
(EDIT : the initConstant method use an AsyncTask to load this data from files).
When my application comes to the background for a certain time or when my application used to much memory, these static variables become null.

*

*How can it be prevented?

*If not what should I do with my static variables?
I have other data which are stored in static variables to be used across different activities, but I clear them or pass them to null in the onLowMemory() of MyApplication.

*What is the best way to keep some data accessible between activities if these data are too big to be serialized in an Intent, a database can't be used (for whatever reason), and can't be stored in files through serialization either?

A: *

*You can't. Android needs to free up memory from time to time. Imagine if all applications had a ton of static data that is supposed to be resident forever - how would you fit that in memory? It's a mobile phone. It doesn't have virtual memory.

*(and 3): Anything that is intended to be persistent needs to be stored, either via SharedPreferences, a Sqlite database, or a file.

A: Most likely the issue is that your application is being killed while it is in the background, and then recreated when you come back to it.  Check out the Activity Lifecycle documentation on when this might occur for a single activity.  You need to make sure that you move anything stored in memory to more permanent storage at the correct point in time to avoid losing that information if the app gets killed.
I'm not sure what exactly you are storing, but it sounds like using Shared Preferences might work well.  This page on Data Storage explains a number of different ways of more permanently storing data, including Shared Preferences.

A: If you weren't using raw files, I'd advise initializing when the class is loaded.
For instance,
public static Map<?,?> myStaticMap = new HashMap<?,?>();
static { //fill myStaticMap }

You do have some bigger concerns to worry about if you are loading files that way. For instance, what about I/O errors, or latency issues? You will get warnings in gingerbread (if you enable them) for doing I/O in your main thread. Perhaps you should have an object to retrieve these values instead of a class with static fields. (perhaps with a static cache, although you should synchronize on it before checking/changing it)

A: I assume this is a data cache problem.
Storing data in static class is not guaranteed to work when user swap apps often. Android system will reclaim any background activity when memory is low. Static class is definitely among this category.
The proper way to do it is to use sharedPreference to persist cache data.
You can create your own getter and setter of the data you want and wrap it around sharedPreference object. When you access using getter, you should always check if the value is empty or expired. You can store an update_time when using setter.
For activity specific data, you can just use getPreference(permission), if you want to share data across activities and other applications components, you can use getSharedPreference(name, permission).
Normally, the permission will be MODE_PRIVATE such that the data can only be accessed within your application.
You should group data and store in difference sharedPreference object. This is good practice because when you want to invalidate that group of data, it is just a matter of one liner.
editor.clear(); editor.commit()
If you want to cache complex object, you should serialize it. I prefer JSON format. So you need some conversion mechanism in place. To do this, I will create my data object class extending JSONable class. JSONable class will have toJSON() method and readFromJSON(). This is convenient when restore and serialize data.

A: I store a User object and a Client object in my static scope. I have noticed from time to time the reference becomes null. So now in my getters I check to see if this value is null and if so I restart the app.
Intent i = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
                i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                context.startActivity(i);

I could have also chosen to reload the Client because I store the Access Token in prefs however I do so much initialization that I decided restarting the app would the best idea.

A: In your onResume() method you could query the static data to see if it is present and if not, load it back in again.

A: Instead of using the static variable u can use the shared preference for storing the value.
Note: for shared preference also you should not give heavy load.
I have solved this problem by having the super class with getter and setter function for storing and retrieving shared preference variable.
All class in my application extended the super class instead of activity.


text:
Q: Add more font in blazor editor SfDocumentEditorContainer font dropdown menu I am a beginner in blazor and use syncfusion components. I want to add fonts to SfDocumentEditorContainer  font dropdown menu.
I see syncfusion comment at
https://www.syncfusion.com/forums/157923/add-more-font-in-blazor-editor-document-component
and tried the below code:
<SfDocumentEditorContainer @ref="container" Height="580px" Width="1300px" EnableToolbar="true" EnableRtl=true DocumentEditorSettings="EditorSettings" >
    <DocumentEditorContainerEvents Created="OnCreated" DocumentChanged="OnDocumentChange" ></DocumentEditorContainerEvents>
</SfDocumentEditorContainer>

@code {

    internal string DocumentName { get; set; }

    SfDocumentEditorContainer container;

    DocumentEditorSettingsModel EditorSettings = new DocumentEditorSettingsModel() { FontFamilies= new string[3] { "Algerian", "Arial","Tahoma" } };

}

but font dropdown menu always load by default fonts.
I use SyncFusion 20.3.0.47.
thanks for any body help.

A: We have confirmed the reported issue as a defect and logged a defect report. We will fix this issue in our EJ2 patch release which is scheduled for November 16, 2022.
You can track the status of the bug through the below feedback link:
https://www.syncfusion.com/feedback/38618/font-family-customization-is-not-working-in-properties-pane
Disclaimer: "Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization."


text:
Q: Cannot get python IDLE 2.7, 3.3 to run - OS X I am running a MacBook Pro with 8gb of memory and a 2.5GHz processor. I run OS X Mavericks, but this problem has happened on other operating systems as well. when I try to open the editor, or even open a python file, this happens:

This has been a problem since I got into python. I have tried as many versions as I can, and the same screen pops up. Please help

A: I recently also upgraded a friends iMac to OS X 10.9 Mavericks and her Python to 2.7.6. If you mount the python-2.7.6-macosx10.6.dmg disk image there's a text file named ReadMe.txt. If you ahem, actually read it, right near the beginning it says:

           **** IMPORTANT ****

Update your version of Tcl/Tk to use IDLE or other Tk applications
To use IDLE or other programs that use the Tkinter graphical user
  interface toolkit, you may need to install a newer third-party version
  of the Tcl/Tk frameworks.  Visit
  http://www.python.org/download/mac/tcltk/ for current information
  about supported and recommended versions of Tcl/Tk for this version of
  Python and of Mac OS X.

Here's what http://www.python.org/download/mac/tcltk currently looks like (my highlighting):

To summarize: You need to download and install ActiveTcl 8.5.15.1 (which is mislabeled ActiveTcl 8.5.15.0) from ActiveState's webpage. After doing that you should be able to run IDLE:

I haven't actually tried to do it yet, but from what I read it sounds like the same process applies to Python 3.3.3 and its IDLE app.

A: I was having the exact same problem.
I was finally able to install Python (and IDLE) via MacPorts by also installing a package called "pyXX-tkinter" -- where XX is the version, e.g. py34-tkinter for Python 3.4.


text:
Q: snprintf() warning and segmentation fault I am newbie to C program. When I compiled the program, I got warning related to the snprintf() function and the compilation is completed. But when I run the binary file, I got segmentation fault. May I know is the segmentation fault related to the warning of snprintf? If yes, may I know how can I solve it?
Thank you.
../src/main.c:1924:54: warning: '%s' directive output may be truncated writing up to 99 bytes into a region of size between 0 and 999 [-Wformat-truncation=]
 1924 |                     snprintf(temp, sizeof(temp), "%s|%s", data1pld, data2ld);
      |                                                      ^~              ~~~~~
In file included from /usr/include/stdio.h:867,
                 from ../../../src/porting/twLinux.h:17,
                 from ../../../src/porting/twOSPort.h:20,
                 from ../src/main.c:97:
/usr/include/aarch64-linux-gnu/bits/stdio2.h:67:10: note: '__builtin___snprintf_chk' output between 2 and 1100 bytes into a destination of size 1000
   67 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |        __bos (__s), __fmt, __va_arg_pack ());
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The program is
char temp[1000]="";
char data1pld[1000]="";
char ld[100]="";
char *ldb = malloc(100);  //"4331297.187"
strcpy(ld,ldb);
strcpy(data1pld,ld);
snprintf(temp, sizeof(temp), "%s|%s", data1pld, ld);


text:
Q: Derive parametric equation for $x^2+y^2=9z^2$ Could somebody show me any ideas how this $$x^2+y^2=9z^2$$ can be transformed into parametric form?

A: For a fixed non-zero value of $z=c$, your equation describes a circle in the plane $z=c$ with radius $3c$. You probably know that a parametrization of a circle can be given by sine and cosine. Taking the varying $z$ into account, we get
$$x=3u\cos t$$
$$y=3u\sin t$$
$$z=u$$
$$t\in [0,2\pi),\ u\in (-\infty,\infty)$$
There are other ways to do this, of course. Note that for $u=0$, all values of $t$ give the same answer $x=0,y=0,z=0$. For non-zero $u$ and the given domain for $t$, the values are distinct.


text:
Q: Update virus definitions for a ClamAV Docker container Does anyone know how to maintain a ClamAV container?
Specifically, it's the ClamAV container included with MailCow, but I'd like to use Docker more broadly as well, so how can I keep something like virus definitions, or other updateables in containerized services, up to date?
Can I use a cron process for something like this?
I can't really find a good way to interact with the container's filesystem to do it manually from the host system, and I get the impression that's not the right approach with containers. How should I approach something like this?
Should I pull a fresh container constantly? That worries me about the possibility of introducing new binaries/codebases all the time, and would like to maintain the model of using well known versions of software rather than push containers into production without testing. Ideas?
Thanks in advance -
P.S. - I tried freshclam from the command line, no dice...

A: MJHd,
I am also looking for the same answer and going by description provided in the Overview section, it seems that freshclam runs continuously in the background updating the virus signature database. Hope this helps!!!
Reference:
https://hub.docker.com/r/mkodockx/docker-clamav/


text:
Q: JAVA_HOME is not defined correctly I installed java jdk hotspot 1.7. When I type java -version I am getting:
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)

This is correct.
And I tried to install maven, and added to /etc/environment file:
JAVA_HOME=/usr/lib/jvm/jdk1.7.0
M2_HOME=/usr/local/apache-maven/apache-maven-3.0.4
MAVEN_HOME=/usr/local/apache-maven/apache-maven-3.0.4
M2=/usr/local/apache-maven/apache-maven-3.0.4/bin

Now When I type mvn I am getting:
Error: JAVA_HOME is not defined correctly.   We cannot execute
"/usr/lib/jvm/jdk1.7.0"/bin/java

However I am not putting " mark for JAV_HOME var in environment file.
It is trying to run from
"/usr/lib/jvm/jdk1.7.0"/bin/java

path, Actually it should be
/usr/lib/jvm/jdk1.7.0/bin/java

When I command
$JAVA_HOME

I am getting:
bash: "/usr/lib/jvm/jdk1.7.0": No such file or directory

I am sure the path(/usr/lib/jvm/jdk1.7.0) is correct.

A: JAVA_HOME should be set to the name of the directory that contains the bin directory that contains the Java executables (in particular, java itself).
Assuming you do have a /usr/lib/jvm/jdk1.7.0 directory, it probably contains a jre subdirectory that contains the bin directory that contains java and related executables.
So you should probably be setting JAVA_HOME to /usr/lib/jvm/jdk1.7.0/jre rather than /usr/lib/jvm/jdk1.7.0.


text:
Q: Why is comment history a mod-only privilege? I just noticed recently that edited comments get this cute little pencil next to them. What I also noticed is that as a mod I can see the entire edit history of the comment, but non-mods cannot.
Regular users can see edit history on regular posts, so why not comments? The fact that mods can edit any comment at any time and that there is no way for the community to see the exact change is a bit concerning, and also doesn't seem to fit with the philosophy guiding other content on the SE sites.
What is the reasoning why comment history is a mod-only privilege?


text:
Q: How to merge if row in table exists I have a 3 tables joined in the statement below:
var data = from x in dbContext.Base_Agencies
                   from u in dbContext.Base_AgencyInstances
                   from o in dbContext.Payment2Account_SecurityRuleAgencies
                   where u.AgencyId == x.AgencyId
                   where o.AgencyId == x.AgencyId
                   where u.AgencyInstanceId == param.AgencyInstanceId
                   select new RsSecurityParamsResult
                   {
                       AgencyId = x.AgencyId,
                       AgencyNameView = u.AgencyNameView,
                       Stamp = u.Stamp,
                       Pni = x.Pni,
                       Prefix = u.Prefix,
                       ServiceEnabled = o.ServiceEnabled,
                       DisabledDateTime = o.DisabledDateTime,
                       AmountHourTresholdWarning = o.AmountHourTresholdWarning,
                       AmountHourTresholdStop = o.AmountHourTresholdStop,
                       CountHourTresholdWarning = o.CountHourTresholdWarning,
                       CountHourTresholdStop = o.CountHourTresholdStop
                   };

The problem is that in some examples there won't be a row for agency in table 'o'. In this situation I would like to select values only from other tables, except 'o' table. How should I do that?

A: I think you might want to do a LEFT OUTER JOIN like
var data = from x in dbContext.Base_Agencies
                   join u in dbContext.Base_AgencyInstances
                   on u.AgencyId == x.AgencyId
                   join o in dbContext.Payment2Account_SecurityRuleAgencies
                   on o.AgencyId == x.AgencyId into lrs
                   from lr in lrs.DefaultIfEmpty()
                   select new RsSecurityParamsResult
                   {
                       AgencyId = x.AgencyId,
                       AgencyNameView = u.AgencyNameView,
                       Stamp = u.Stamp,
                       Pni = x.Pni,
                       Prefix = u.Prefix,
                       ServiceEnabled =  lr.ServiceEnabled ?? "Default",
                        ...... // other code similar ........
                   };

A: Correct solution is:
  var data = from x in dbContext.Base_Agencies
                   join u in dbContext.Base_AgencyInstances
                   on  x.AgencyId equals u.AgencyId
                   join o in dbContext.Payment2Account_SecurityRuleAgencies
                   on x.AgencyId equals o.AgencyId into lrs
                   from lr in lrs.DefaultIfEmpty()
                   where u.AgencyInstanceId == param.AgencyInstanceId

                   select new RsSecurityParamsResult
                   {
                       AgencyId = x.AgencyId,
                       AgencyNameView = u.AgencyNameView,
                       Stamp = u.Stamp,
                       Pni = x.Pni,
                       Prefix = u.Prefix,
                       ServiceEnabled = lr.ServiceEnabled,
                       DisabledDateTime = lr.DisabledDateTime,
                       AmountHourTresholdWarning = lr.AmountHourTresholdWarning ,
                       AmountHourTresholdStop = lr.AmountHourTresholdStop,
                       CountHourTresholdWarning = lr.CountHourTresholdWarning ,
                       CountHourTresholdStop = lr.CountHourTresholdStop
                   };


text:
Q: Can we have a PDF with countably infinite points at which it blows up? I would like to know if there is an example of a probability density function (PDF) $f$ with $f \in L^1(\mathbb{R})$ such that $f$ has countable many points $\{x_n\}_{n=1}^{\infty}$ in its domain such that $f(x_n) = +\infty$?, excluding the Dirac Comb I think this would be impossible to have. Am I correct? I say this because let's say we start with a single point of singularity and replicate that PDF to get another one with two singularities, by squeezing (horizontally) and placing two copies of it at some distance to get a total area of 1. As we keep repeating this procedure countably many times, the sequence would result in Diracs placed at the points $x_n$. This is a very crude and non-rigorous argument, but I would appreciate if someone who is more adept in analysis and probability than I am would contribute, as I am an engineer by training.
Edit: I should mention explicitly that the support of the function $f$ is unbounded.

A: Yeah, this isn't so bad to do.  Set $g(x) = \begin{cases} |x|^{-1/2} & \text{ if } |x| \leq 1 \\
e^{-|x|} & \text{ if } |x| \geq 1
\end{cases}$.  Then $$\int_{-\infty}^\infty g(x) \,dx = 4 + 2/e =: C\,.$$
We can then define the p.d.f. $f(x)$ by shifting $g$ to integer points:  $$f(x) = \frac{1}{C}\sum_{j \geq 1} 2^{-j} g(x - j)\,.$$
Then $f$ is continuous everywhere except the natural numbers, at which points it is $+\infty$ and is a p.d.f.

A: Let $r_n$ be an enumeration of the rationals, and let
$$ g(x) = \sum_{n=1}^\infty 2^{-n} |x-r_n|^{-1/2} I_{r_n -1 < x < r_n + 1} .$$
Since ${\|g\|}_1 = 4$, we can use
$$ f = \tfrac14 g .$$


text:
Q: LaTeX Error: Can be used only in preamble even though all packages are defined in preamble Many similar errors I found on this platform, but my problem is bit different.
There is main.tex file which including two files from expternal sources and it contains no \documentclass{article}. But, Latex is giving me error and not giving the proper output.
.\chapters/abstract_v1.tex:1: LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation.
Type H ≤return> for immediate help.
l.3 \begin{document}
?

following are lines which I am including in my main.tex file:
\documentclass[12pt]{report}
\usepackage{hyperref}
\usepackage{natbib}
\usepackage{xpatch}
\usepackage{url}
\usepackage{enumitem}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage{graphicx}
\graphicspath{ {images/} }
\usepackage{caption}
\usepackage{subcaption}
\usepackage[a4paper, width=150mm, top=25mm, bottom=25mm, bindingoffset=6mm]{geometry}
\usepackage{ragged2e}

\makeatletter
\newcommand\NoWarnNat{
\xpatchcmd{\NAT@citexnum}{\PackageWarning}{\let\PackageWarning\@gobbletwo\PackageWarning}{}{}
\xpatchcmd{\NAT@citex}{\PackageWarning}{\let\PackageWarning\@gobbletwo\PackageWarning}{}{}
\xpatchcmd{\nocite}{\PackageWarning}{\let\PackageWarning\@gobbletwo\PackageWarning}{}{}
}
\makeatother

\NoWarnNat

%\author{Python Buddha}
\date{02 March 2020}

\begin{document}

\input{titlepage}

\pagenumbering{roman}

\chapter*{Dedication}

\addcontentsline{toc}{chapter}{Dedication}

\chapter*{Declaration}

\addcontentsline{toc}{chapter}{Declaration}

\cleardoublepage
\tableofcontents

\listoffigures

\cleardoublepage

\chapter*{Abstract}
\input{chapters/abstract_v3}
\addcontentsline{toc}{chapter}{Abstract}

\chapter*{Foreword}
\input{chapters/abstract_v1}
\addcontentsline{toc}{chapter}{Foreword}

\chapter*{Introduction}
\input{chapters/introduction_v2}
\addcontentsline{toc}{chapter}{Introduction}

\cleardoublepage

\pagenumbering{arabic}

\chapter{Add Language identifier to highlight code}
\input{chapters/chapter1_v1}

\chapter{Put Returns between paragraphs}
\input{chapters/chapter2_v1}

\chapter{For Linebreak add 2 spaces at end}
\input{chapters/chapter3_v1}

\chapter{Indent code by 4 spaces}
\input{chapters/chapter4_v1}

\chapter{To make Links}
\input{chapters/chapter5_v1}

\chapter*{Formatting Help}
\addcontentsline{toc}{chapter}{Formatting Help}

other files look like this:
abstract_v2.tex

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\\

`abstract_v1.tex`

```\chapter*{Foreword}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\\


text:
Q: How to parse Json data from URL?which contains number of arrays i am having a issue of parsing JSON data i followed this link..
over there it has parsing data images description..
and i also refereed this in stack over flow a guy who is having same issue but no correct  answer..
How to Parse JSONarray inside JSONarray in android? and
How to display Image from URL?
we can say just extention of the above questions..
its not a duplicate that guy is also same problem no answer..
i have a data like below
{
"request": "ok",
"query": {
    "result": [
        {
            "site": [
                {
                    "latest": [
                        {
                            "id": "2eaQy8Ow",
                            "data": "1/1/2014"
                        }
                    ]
                }
            ],
            "flag": [
                "http://www.simplydecoded.com/wp-content/uploads/2013/02/Telangana2.jpg"
            ]
        }
    ]
   }
  }

i am using below code for parsing
JSONArray json_query_flag = c.getJSONArray("flag");

JSONArray json_query_site=c.getJSONArray("site");
System.out.println("looping json_query_site");
for (int j = 0; j < c.length(); j++) {
System.out.println("looping json_query_site[" + j +"]" + "json_query_site.length() -->" + json_query_site.length());

if (j <json_query_site.length()) {

HashMap<String, String> map1 = new HashMap<String, String>();
JSONObject sd = json_query_site.getJSONObject(j);

// get latestoffers
JSONArray json_latest = sd.getJSONArray("latest");
System.out.println(json_latest.toString());

for (int k = 0; k < json_latest.length(); k++) {

HashMap<String, String> map2 = new HashMap<String, String>();
JSONObject e = json_latest.getJSONObject(k);

My problem is that i am not getting the latest and flag..
may be parsing problem..

A: Hellow man thanks for understanding the problem please follow this post for the till your site and latest..
it solved I am getting text.. but problem with images I think you have flag..
for that you need to change your Listviewadapter.java file. so that images will appear
change this like
String strflag = resultp.get(Mainactivity.IMAGES);
    if(strflag != null)
        imageLoader.DisplayImage(strflag, flag);
    else
        imageLoader.DisplayImage("http://www.butterentals.com/graphics/no_image.jpg", flag);

so that I will be done.

A: TRy this..
JSONObject JObj = new JSONObject(response);
JSONObject query = JObj.getJSONObject("query");
JSONArray result = query.getJSONArray("result");
for (int i = 0; i < result.length(); i++) {
        JSONObject jobj = result.getJSONObject(i);
        JSONArray site = jobj.getJSONArray("site");
            for (int j = 0; j < site.length(); j++) {
                JSONObject sitobj = site.getJSONObject(j);
                JSONArray latest = sitobj.getJSONArray("latest");
                    for (int k = 0; k < latest.length(); k++) {
                         JSONObject lateobj = latest.getJSONObject(k);
                         System.out.println("id : "+lateobj.getString("id"));
                    }
            }
        JSONArray flag = jobj.getJSONArray("flag");
        for (int l = 0; l < flag.length(); l++) {
            System.out.println("urls : "+flag.getString(l));
        }
}


text:
Q: serialize datatable to JSON issue vb.net Ok, I'm trying to serialize a data table in vb.net:
Dim dt As New System.Data.DataTable

and for the serializer:
Dim js As JavaScriptSerializer = New JavaScriptSerializer()
dim jsonString as string
jsonString=js.serialize(dt)

when it serialize the data table on the last line,
it got an error:

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Web.Extensions.dll
Additional information: A circular reference was detected while serializing an object of type 'System.Globalization.CultureInfo'

I even make the simplest datatable with only 1 column and 1 row, but it just won't serialize it,
I know that this kind of question was answered: in here
but I don't know how to implement the answer (make a new class),
or maybe there's an even better solution?

A: As far as I know there is not out of the box serializer for DataTable objects. I ended up going with a full custom serialization. Another approach could be converting first your DataTable to an IEnumerable<> and then, serializing.
However, this link may be helpful: JSV


text:
Q: Axon: Using Cassandra as a Event Store We are attempting to implement our own Cassandra-based Event store that extends EmbeddedEventStore. Any thoughts on why this may not work with Axon such that we see the same behavior as if using JPA? One doubt revolves around the fact that Cassandra supports eventual consistency. Currently, we're seeing unexpected behavior when using a multi-threaded TrackingEventProcessor within a single JVM and/or when deploying Saga-based applications in different JVMs with logs as follows:
o.a.e.TrackingEventProcessor : message=Unable to claim the token for segment: 0. It is owned by another process

It seems as though it always tries to retrieve from segment 0.
This may very well be our own defect (perhaps with our bean configurations KafkaPublisher/EventProcessorConfigurer), which we'll resolve, but the bigger question is, in your opinion, is it possible to make Cassandra work with Axon. I recall seeing some posts in the google groups forum stating Cassandra support wasn't considered due to performance issues. We want to ensure we're not investing into something that will be a nightmare to maintain or simply isn't a good solution.

A: If you want to create your own Event Storage solution whilst using Axon Framework, it is recommended to provide an EventStorageEngine implementation.
That way, the EventStore, which is of type EmbeddedEventStore if you are not using Axon Server, can simply point to the other storage solution for storage and retrieval of events. Samples of EventStorageEngine are the JpaEventStorageEngine, JdbcEventStorageEngine and MongoEventStorageEngine. The former two reside in Axon Frameworks event sourcing module, whereas the MongoDb variant is part of Axon's Mongo Extension.
Now, to your actual question on whether it is doable.
I am very confident you should be able to draft up a CassandraEventStorageEngine which does the job just fine.
Whether it is going to be the most optimal Event Store you can have is however very debatable. There is a reason why AxonIQ drafted up Axon Server as an Event Store, and that's simply because all hard requirements you would have for an Event Store are not optimally implemented if you use a different storage approach?
Why? Well simply because things like RDBMS, MongoDb, Cassandra, Kafka, etc provide a broader spectrum of functionality with different intents at its core than an Event Store would.
Providing all the details here would be a bit much, but this presentation by Allard Buijze (creator of Axon Framework) should give quite some insights into this. Also, why Cassandra wouldn't be the optimal solution to go for.
So concluding, if you strongly feel for building your own Event Store, picking up Cassandra would be an interesting endeavour. If it will bring you all you need from an Event Store, well that's up for debate.


text:
Q: Is it possible to install python packages without a direct outbound network connection? I have a server (RHEL) that I need to install specific python packages on.  However, my server is firewalled off from internet access so I am not able to install any packages using pip.  Is there a way to "manually" download packages to my local workstation and then push them and install them to my isolated RHEL system.  Is this possible?  Is it possible to manually push python packages and install them onto a system without internet access?

A: from a pc that connected to internet :
pip download yourpackage

copy "yourpackage.tar.gz" to server
in server :
pip install "path/yourpackage.tar.gz"

if package have ".whl" file :
pip install "path/yourpackage-version.whl"

A: Solved it...all that really needs to be done is to tar up the "site-packages" directory from a server that has the packages installed and then restore that on the desired target server.

A: Yes. You can download a package from PyPI, untar it and run setup.py:
python setup.py


text:
Q: BinaryReader overwhelming me by padding byte array So I have this really simple code that reads a file and spits its data out in a hex viewer fashion. Here it is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace HexViewer
{
    class Program
    {
        static void Main(string[] args)
        {
            BinaryReader br = new BinaryReader(new FileStream("C:\\dump.bin", FileMode.Open));
            for (int i = 0; i < br.BaseStream.Length; i+= 16)
            {
                Console.Write(i.ToString("x") + ": ");
                byte[] data = new byte[16];
                br.Read(data, i, 16);
                Console.WriteLine(BitConverter.ToString(data).Replace("-", " "));
            }
            Console.ReadLine();
        }
    }
}

The problem is that after the first iteration, when I do
br.Read(data, 16, 16);

The byte array is padded by 16 bytes, and then filled with data from 15th byte to 31st byte of the file. Because it can't fit 32 bytes into a 16 byte large array, it throws an exception. You can try this code with any file larger than 16 bytes. So, the question is, what is wrong with this code?

A: Just change br.Read(data, i, 16); to br.Read(data, 0, 16);
You are reading in a new block of data each time, so no need to use i for the data buffer.
Even better, change:
byte[] data = new byte[16];
br.Read(data, 0, 16);

To:
var data = br.ReadBytes(16);


text:
Q: Cloudera - dynamic Resource Pool for user I am running a Cloudera Cluster on Yarn with the version 5.8.2. The
scheduler of the Resource manager is running as Fair scheduler.
The dynamic resource Pool setting for YARN is active. The pools are
generated under root.users..
What I want is to increase the resources for a specific user. So I changed
the weight in the dynamic resource configuration for this user from "1" to
"3".
Assume I have three users USER1 to USER3 and have the follwing wheigting.
USER1 is 3, USER2 is 1, USER3 is 1.
Am I right that USER3 is able to get three times more Cluster resources than
USER2 and USER3 ?
If all Users running jobs on the cluster at the same time, USER3 gets "60"
percent of root resources?

A: If you haven't defined any restriction, user3 gets 60% of cluster resource.
You can know more about fair scheduler in cloudera blog


text:
Q: C4 camera capture - problems when coming back to the view I'm working on an app with several subviews.
Currently I have 4 subviews.
Here it the C4Workspace code to set them up
//TakePhoto
    takePhoto= [TakePhoto new];
    takePhoto.canvas.frame=CGRectMake(0, 0, self.canvas.width, self.canvas.height);
    takePhoto.canvas.userInteractionEnabled = YES;
    [takePhoto transferVariables:1 topBarFromTop:TopBarFromTopDefault topBarHeight:TopNavBarHeightDefault bottomBarHeight:BottomBarHeightDefault navBarColor:navBarColorDefault navigationColor:navigationColorDefault typeColor:typeColorDefault fatFont:fatFontDefault normalFont:normalFontDefault iconTakePhoto:iconTakePhoto iconClose:iconClose iconBack:iconBack];
    [takePhoto setup];
    [takePhoto cameraSetup];
    [self.canvas addSubview:takePhoto.canvas];

    //CropPhoto
    cropPhoto=[CropPhoto new];
    cropPhoto.canvas.frame=CGRectMake(0, 0, self.canvas.width, self.canvas.height);
    cropPhoto.canvas.userInteractionEnabled=YES;
    [cropPhoto transferVariables:1 topBarFroTop:TopBarFromTopDefault topBarHeight:TopNavBarHeightDefault bottomBarHeight:BottomBarHeightDefault navBarColor:navBarColorDefault navigationColor:navigationColorDefault typeColor:typeColorDefault overlayColor:overlayColorDefault fatFont:fatFontDefault normalFont:normalFontDefault iconClose:iconClose iconBack:iconBack iconOk:iconOk];
    [self.canvas addSubview:cropPhoto.canvas];
    cropPhoto.canvas.hidden= YES;

    //AssignPhoto
    assignLetter=[AssignLetter new];
    assignLetter.canvas.frame=CGRectMake(0, 0, self.canvas.width, self.canvas.height);
    assignLetter.canvas.userInteractionEnabled=YES;
    [assignLetter transferVariables:1 topBarFroTop:TopBarFromTopDefault topBarHeight:TopNavBarHeightDefault bottomBarHeight:BottomBarHeightDefault navBarColor:navBarColorDefault navigationColor:navigationColorDefault typeColor:typeColorDefault highlightColor:highlightColorDefault fatFont:fatFontDefault normalFont:normalFontDefault iconClose:iconClose iconBack:iconBack iconOk:iconOk iconSettings:iconSettings];

    [self.canvas addSubview:assignLetter.canvas ];
    assignLetter.canvas.hidden=YES;

    //AlphabetView
    alphabetView=[AlphabetView new];
    alphabetView.canvas.frame= CGRectMake(0, 0, self.canvas.width, self.canvas.height);
    alphabetView.canvas.userInteractionEnabled=YES;
    [alphabetView transferVaribles:1 topBarFromTop:TopBarFromTopDefault topBarHeight:TopNavBarHeightDefault bottomBarHeight:BottomBarHeightDefault navBarColor:navBarColorDefault navigationColor:navigationColorDefault typeColor:typeColorDefault darkenColor:darkenColorDefault fatFont:fatFontDefault normalFont:normalFontDefault iconClose:iconClose iconBack:iconBack iconMenu:iconMenu iconTakePhoto:iconTakePhoto iconAlphabetInfo:iconAlphabetInfo iconShareAlphabet:iconShareAlphabet iconWritePostcard:iconWritePostcard iconMyPostcards:iconMyPostcards iconMyAlphabets:iconMyAlphabets];
    [self.canvas addSubview:alphabetView.canvas];
    alphabetView.canvas.hidden=YES;

//the methods to listen for from all other canvasses
    [self listenFor:@"goToTakePhoto" andRunMethod:@"goToTakePhoto"];
    [self listenFor:@"goToCropPhoto" andRunMethod:@"goToCropPhoto"];
    [self listenFor:@"goToAssignPhoto" andRunMethod:@"goToAssignPhoto"];
    [self listenFor:@"goToAlphabetsView" andRunMethod:@"goToAlphabetsView"];

This main workspace also has the following functions to switch between the views
-(void)goToTakePhoto{
    [takePhoto resetCounter];
    [takePhoto setup];

    C4Log(@"TakePhoto");
    takePhoto.canvas.hidden=NO;
    cropPhoto.canvas.hidden=YES;
    assignLetter.canvas.hidden=YES;
    alphabetView.canvas.hidden=YES;
}
-(void)goToCropPhoto{
    C4Log(@"going to CropPhoto");
    [cropPhoto displayImage:takePhoto.img];
    [cropPhoto setup];
    takePhoto.canvas.hidden=YES;
    cropPhoto.canvas.hidden=NO;
    assignLetter.canvas.hidden=YES;
    alphabetView.canvas.hidden=YES;
}
-(void)goToAssignPhoto{
    C4Log(@"AssignPhoto");
    [assignLetter setup];
    [assignLetter drawCurrentAlphabet:currentAlphabet];
    [assignLetter drawCroppedPhoto:cropPhoto.croppedPhoto];
    takePhoto.canvas.hidden=YES;
    cropPhoto.canvas.hidden=YES;
    assignLetter.canvas.hidden=NO;
    alphabetView.canvas.hidden=YES;
}
-(void)goToAlphabetsView{
    C4Log(@"AlphabetsView");
    [alphabetView setup];
    [alphabetView drawCurrentAlphabet:assignLetter.currentAlphabet];
    takePhoto.canvas.hidden=YES;
    cropPhoto.canvas.hidden=YES;
    assignLetter.canvas.hidden=YES;
    alphabetView.canvas.hidden=NO;
}

the first view is taking the photo very similar to the tutorial (I added a reset counter for the camera because I noticed that the button to take the photo always sends the notification twice when it was tapped).
-(void) setup{
photoButtonImage=iconTakePhoto;
    photoButtonImage.height=45;
    photoButtonImage.width=90;
    photoButtonImage.center=CGPointMake(self.canvas.width/2, self.canvas.height-bottomBarHeight/2);
    [self.canvas addImage:photoButtonImage];
    //gestures to take the photo
    [self listenFor:@"touchesBegan" fromObject:photoButtonImage andRunMethod:@"captureImage"];
    [self numberOfTouchesRequired:1 forGesture:@"capture"];
    [self listenFor:@"imageWasCaptured" fromObject:cam andRunMethod:@"goToCropPhoto"];
}

-(void)cameraSetup{
    cam = [C4Camera cameraWithFrame:CGRectMake(0,topBarFromTop+topBarHeight, self.canvas.width, self.canvas.height-(topBarHeight+bottomBarHeight+topBarFromTop))];
    cam.cameraPosition = CAMERABACK;
    [self.canvas addCamera:cam];
    [cam initCapture];
    counter=0;
}
-(void) captureImage{
    [cam captureImage];
    C4Log(@"capturing image");
}
-(void)resetCounter{
    counter=0;
}

this works fine as long as I navigate back to that view from a C4Label but not if I'm navigating back from an image. Even though I'm running the exact same functions when touching both.
It looks like this:
//image as navigation element
takePhotoButton=iconTakePhoto;
    takePhotoButton.width=60;
    takePhotoButton.center=CGPointMake(takePhotoButton.width/2+5, bottomNavBar.center.y);
    [self.canvas addImage:takePhotoButton];
    [self listenFor:@"touchesBegan" fromObject:takePhotoButton andRunMethod:@"goToTakePhoto"];

//label as navigation element
takePhoto=[C4Label labelWithText:@"take Photo" font: normalFont];
    takePhoto.center=CGPointMake(self.canvas.width-(takePhoto.width/2+5), topNavBar.center.y);
    [self.canvas addLabel:takePhoto ];
    [self listenFor:@"touchesBegan" fromObject:takePhoto andRunMethod:@"goToTakePhoto"];

and lastly this is the function inside that view that sends te notification
-(void) goToTakePhoto{
    C4Log(@"goToTakePhoto");
    [self removeFromView]; //removes the currently displayed items from being displayed
    [self postNotification:@"goToTakePhoto"];
}

I can make it work for now using the label but it would be so much nicer to use a C4Image as a button....
Any ideas?
Full code available on Github: http://github.com/susemiessner/Urban-Alphabets/tree/master/urbanAlphabetsII

A: I just found the answer to this one:
When coming back to the camera view the old
[self listenFor:@"imageWasCaptured" fromObject:cam andRunMethod:@"goToCropPhoto"];

was still active, so it thinks I already captured an image from the camera, which is not true. So the solution is when I leave the view I just have to disable that using this code
[self stopListeningFor:@"imageWasCaptured" object:cam];

that does the entire magic!


text:
Q: The APFS partition on my external hard drive doesn't mount anymore I have a WD Elements 1.5Tb external hard drive with two partitions. One is for Windows (that I use with Bootcamp on my mac), the other is for OSX (APFS file system). Usually, OSX can see both WIN and MAC partitions as separate drives, and Windows only see the WIN partition.
Today I plugged my HDD into my Mac, and I only can see the WIN partition anymore (in Finder and on my Desktop). It shows up on Disk Utility with a generic name, two times (As a partition, grayed out, and as a separate disk, uninitialized). I cannot mount them or run S.O.S on it. One is grayed out.

but I still have no ways to even read it. I tried different usb ports, even plugged it into another Mac and got the same results.
It also seems to show up with diskutil but I still cannot do anything with it:

I also tried Stellar Data Recovery which shows me +64gb of files on it that it can recover, so it's still there, but I cannot afford the 100$ to recover it.
I really need the data that's on this drive, so is there anyway I can repair it myself, or at least recover the data? Any help would be appreciated.


text:
Q: org.apache.cxf.bus.extension.ExtensionException in WAS9 server Can you please help me with following error I'm facing in WAS9 environment:
In order to resolve the import
org.apache.cxf.binding.soap.SoapHeader
I added the following dependencies in my pom.xml:
cxf-api-2.7.7
cxf-rt-bindings-soap-2.7.7
But when I'm trying to run my application, I'm getting the following error.
Default Executor-thread-7] ([  ])  Controllerclass - org.apache.cxf.bus.extension.ExtensionException
at org.apache.cxf.bus.extension.Extension.load(Extension.java:222)
at org.apache.cxf.bus.extension.ExtensionManagerImpl.loadAndRegister(ExtensionManagerImpl.java:199)
at org.apache.cxf.bus.extension.ExtensionManagerImpl.initialize(ExtensionManagerImpl.java:118)
at org.apache.cxf.bus.extension.ExtensionManagerBus.doInitializeInternal(ExtensionManagerBus.java:147)
at org.apache.cxf.bus.CXFBusImpl.initialize(CXFBusImpl.java:191)
at com.ibm.ws.jaxws.bus.LibertyApplicationBusFactory.createBus(LibertyApplicationBusFactory.java:119)
at com.ibm.ws.jaxws.bus.LibertyApplicationBusFactory.createClientScopedBus(LibertyApplicationBusFactory.java:86)
at com.ibm.ws.jaxws.metadata.JaxWsClientMetaData.<init>(JaxWsClientMetaData.java:28)
at com.ibm.ws.jaxws.metadata.JaxWsModuleMetaData.getClientMetaData(JaxWsModuleMetaData.java:123)
at com.ibm.ws.jaxws.support.JaxWsMetaDataManager.getJaxWsClientMetaData(JaxWsMetaDataManager.java:84)
at com.ibm.ws.jaxws.support.JaxWsMetaDataManager.getJaxWsClientMetaData(JaxWsMetaDataManager.java:123)
at com.ibm.ws.jaxws.client.LibertyProviderImpl.createServiceDelegate(LibertyProviderImpl.java:56)
at javax.xml.ws.Service.<init>(Service.java:57)

Caused by: java.lang.InstantiationException:org.apache.cxf.bus.osgi.OSGIBusListener
at java.lang.Class.newInstance(Class.java:427)
at org.apache.cxf.bus.extension.Extension.load(Extension.java:218)
Caused by: java.lang.NoSuchMethodException:org.apache.cxf.bus.osgi.OSGIBusListener.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.newInstance(Class.java:412)

A: The server where your WAS9 has been deployed has different version of the above jar file. You need to have same version of jar files both in your eclipse where you have developed your codes and the server where you are deploying the war or ear.
mavan dependency file pom.xml is used during your project compilation. It might add the jar in your binary under lib folder as well. But WAS9 might considering the one which is in server's CLASSPATH. Hence check your class path and replace that jar with the one which you have mentioned in your pom.xml file. Hope that will fix your issue.

A: We can eliminate this exception by adding webProfile-7.0 in our server.xml, but how ever this is not working with javaee-7.0 not sure, if one knows about how to handle this in javaee-7.0 please share your approach.


text:
Q: NCurses doesn't change colours, shows 16 colours only I'm trying to get 256-colour support working for Curses and Ruby on Windows. I'm pretty sure it's possible, because Brogue uses curses, and has 256-colour support for Windows.
Right now, my setup is to use Ruby 1.8.7 (yech) with NCurses (0.9.1 pre-compiled binaries).
I see two problems right now, which I suspect are related:

*

*Curses.colors returns 16

*Curses.init_color(...) doesn't error out, but doesn't do anything.

Some legwork:

*

*ENV['TERM'] evaluates to xterm-256color

*Tried both Ruby 1.9.3 and 2.0 (NCurses doesn't load)

*can_change_color returns false
What am I missing?

A: The Windows console window only supports 16 colors. You would have better luck with another console/terminal emulator like mintty, ConEmu, or Console2.


text:
Q: First three values from cell + other cell data VBA Excel I have two tables, where I need to get data from one to another with VBA. I have a code to import data and put them in column ranges what I need, but I am stuck on formating them:

*

*I need to check if date columns cell is empty and if it is, than put date from other cell
If IsEmpty(oldtable.Range("L3", "L10").Value) Then
newtable.Range("J3", "J10").Value = newtable.Rang("E3", "E10").Value
Else newtable.Range("J3", "J10").Value = oldtable.Rang("L3", "E10").Value
End if

*Need to get first 3 string from number + value from cell in same range
newtable.Range("O3", "O10").Value = Mid(newtable.Range("M3", "10").Value,1,3)&newtable.Range("N3", "N10").Value
Code is not working for me.
Thank you for support!
fullcode:
Dim filter As String
Dim caption As String
Dim file As String
Dim oldtable As Workbook
Dim newtable As Workbook

Range("A3:R10").Select
Selection.ClearContents

Set newtable = Application.ActiveWorkbook

filter = "Text files (C:\Excel\file.xlsx),C:\Excel\file.xlsx"
caption = "Please Select an input file "
GREMPG1 = Application.GetOpenFilename(filter, , caption)

oldtable = Application.Workbooks.Open(GREMPG1)

Dim wsheet_new1 As Worksheet
Set wsheet_new1 = newtable.Worksheets(1)
Set wsheet_new2 = newtable.Worksheets(2)

Dim wsheet_old As Worksheet
Set wsheet_old = oldtable.Worksheets(1)

'This is OK
wsheet_new1.Range("C3", "C11").Value = wsheet_new1.Range("C2").Value

'This is OK
wsheet_new1.Range("D3", "D11").Value = Application.WorksheetFunction.VLookup(wsheet_old.Range("E2", "E10"), wsheet_new2.Range("A1:B16").Value, 2, False)

'Empty values stay empty
    If IsEmpty(wsheet_old.Range("L3", "L11").Value) Then
        wsheet_new1.Range("J3", "J11").Value = wsheet_new1.Range("E3", "E11").Value
    Else
        wsheet_new1.Range("J3", "J11").Value = wsheet_old.Range("L2", "L10").Value
    End If

GREMPG1_wb.Close

End Sub

A: The Help for the IsEmpty function states:

IsEmpty returns True if the variable is uninitialized, or is explicitly set to Empty; otherwise, it returns False.False is always returned if expression contains more than one variable. IsEmpty only returns meaningful information for variants.

Because you are passing more than one cell ("L3", "L11") the IsEmpty functions always returns False. The simplest answer is to write a function that takes a Range and tests every cell and returns True/False. Here's the function:
Private Function RangeIsEmpty(ByRef theRange As Range) As Boolean

Dim cell As Range
Dim result As Boolean

    result = True
    For Each cell In theRange.Cells
        If Not IsEmpty(cell) Then
            result = False
            Exit For
        End If
    Next cell

    RangeIsEmpty = result

End Function

Copy the function into the same module as your code. Then change this line:
If IsEmpty(wsheet_old.Range("L3", "L11").Value) Then

To:
If RangeIsEmpty(wsheet_old.Range("L3", "L11").Value) Then


text:
Q: $R = \mathbb{Z}[\sqrt{-41}]$, show that 3 is irreducible but not prime in $R$ I'm asked to show that 3 is irreducible but not prime in $R = \mathbb{Z}[\sqrt{-41}]$. And if $R$ is a Euclidean domain.
To show that it's not prime I have $(1 + \sqrt{-41})(1 - \sqrt{-41}) = 42 = (3)(14)$. I get that 3 divides 14 but how do I show that 3 does not divide either $(1 + \sqrt{-41})$, $(1-\sqrt{-41})$ to show that it's not prime? $x \mid 42$ but $x$ does not divide 3?
To show that it's irreducible how am I showing that either $(1 + \sqrt{-41})$, $(1 - \sqrt{-41})$ is a unit since clearly $(1 + \sqrt{-41})(1 - \sqrt{-41}) = 42$?

A: You can generalize quite a few things here. If $p$ is a prime number in $\mathbb{Z}$, $d \not\equiv 1 \pmod 4$ is negative and squarefree, and $|p| < |d|$, then $p$ is irreducible in $\mathbb{Z}[\sqrt{d}]$. Since $p$ is not a square (one of the most important reasons why 1 is not prime), it is irreducible.
Thus, in $\mathbb{Z}[\sqrt{-41}]$, we see that $|3| < |-41|$. The possible norms in this domain less than 41 are all squares: 1, 4, 9, 16, 25, 36, and clearly 3 is not one of these.
If $p$ is irreducible but not prime, then the congruence $x^2 \equiv d \pmod p$ can be solved. Indeed $1^2 \equiv -41 \pmod 3$, leading you to find that $(1 - \sqrt{-41})(1 + \sqrt{-41}) = 42$.
If either $1 - \sqrt{-41}$ or $1 + \sqrt{-41}$ was a unit, its norm would be equal to 1 (we don't have to worry about a norm of $-1$ here). But you've already seen that both of those numbers have norms of 42 (remember that $N(a + b \sqrt{d}) = (a - b \sqrt{d})(a + b \sqrt{d})$).
Saying "$a$ divides $b$" is a convenient shorthand for "$b$ divided by $a$ is a number that's also in this domain." But $$\frac{1 - \sqrt{-41}}{3} \not\in \mathbb{Z}[\sqrt{-41}].$$ Likewise for $1 + \sqrt{-41}$.
You have thus proven that 42 has two distinct factorizations in this domain: $$2 \times 3 \times 7 = (1 - \sqrt{-41})(1 + \sqrt{-41}) = 42.$$ (2 and 7 are also irreducible but not prime.)
If a domain is Euclidean, then it's also a principal ideal domain and a unique factorization domain. This domain is clearly not a Euclidean domain because it's not a unique factorization domain (e.g., 42).

A: You are close to a proof. You observed that $42=(1+\sqrt{-41})((1-\sqrt{-41})$. So $3$ divides  $(1+\sqrt{-41})(1-\sqrt{-41})$. But $3$ divides neither $1+\sqrt{-41}$ nor $1-\sqrt{-41}$.
Next we show that $3$ is irreducible. For suppose that $3=(a+b\sqrt{-41})(c+d\sqrt{-41})$, where $a,b,c,d$ are integers. Then the norm of $a+b\sqrt{-41}$ divides the norm of $3$. Thus $a^2+41b^2$ divides $9$. It is clear that we must have $b=0$. So $a^2$ divides $9$. It follows that $a=\pm 1$, in which case $a+b\sqrt{-41}$ is a unit, or $a=\pm 3$, in which case $c+d\sqrt{-41}=\pm 1$, a unit.
Finally, in a Euclidean domain, every irreducible is prime.

A: Numbers in this domain are of the form $a + b \sqrt{-41}$, where $a, b \in \mathbb{Z}$. Notice then that $$\frac{1 + \sqrt{-41}}{3} = \frac{1}{3} + \frac{\sqrt{-41}}{3},$$ and $$\frac{3}{1 + \sqrt{-41}} = \frac{1}{14} + \frac{\sqrt{-41}}{14}.$$ Neither of these numbers is of the form $a + b \sqrt{-41}$ with $a, b \in \mathbb{Z}$. This means that $3$ is not a divisor of $1 + \sqrt{-41}$ nor the other way around, but obviously $3$ is a divisor of $42$, proving that $3$ is not prime.
On the last paragraph of your question you've gotten a little confused. What you need to show is that if $xy = 3$, with $x, y \in \mathbb{Z}[\sqrt{-41}]$, either $x$ is a unit or $y$ is. The only solutions are $x = -1$ or $1$, $y = -3$ or $3$. $-1$ and $1$ are units.

A: The answers given already are all very complete and good. I wanted to give a slightly different perspective on the fact that $3$ is not prime; this perspective is alluded to in Robert Soupe's very nice answer.
If $3 \in R:= \mathbb{Z}[\sqrt{-41}]$ is prime, then $3R$ is a prime ideal of $R$. In particular, this means that $R/3R$ is an integral domain. Since $R$ can be expressed as the quotient $\mathbb{Z}[X]/\langle X^{2}+41 \rangle$ and we can interchange the order in which we take quotients, we see that
$$R/3R \cong \mathbb{Z}[X]/\langle X^{2}+41, 3 \rangle \cong (\mathbb{Z}/3\mathbb{Z})[X]/\langle X^{2}+2 \rangle$$
Of course, $X^{2}+2$ is reducible over $\mathbb{Z}/3\mathbb{Z}$, since it factors as $(X+1)(X+2)$. The images of $X+1$ and $X+2$ in the quotient ring $(\mathbb{Z}/3\mathbb{Z})[X]/\langle X^{2}+2 \rangle$ are thus zero divisors, so $R/3R$ is not a domain, and therefore $3$ is not a prime element of $R$.


text:
Q: Сравнить два списка и вывести недостающие элементы (с сохранением количества) Пытаюсь получить все элементы списка list_a, которых нет в списке list_b (с сохранением количества):
list_a = ['users1_', 'users1_', 'users2_', 'users3_']
list_b = ['users1_', 'users3_']
list_c = list()

for template in list_a:
    if template not in list_b:
        list_c.append(template)

print(list_c)  # ['users2_']

Но получаю только один элемент. Что требуется сделать, чтобы получить ['users1_', 'users2_'] ?
Что-то вроде:
print(list(set(list_a) ^ set(list_b)))

не подходит, поскольку мне важны все элементы списка. Здесь set не подходит, так как он оставит только уникальные элементы в списках.

A: Если элемент найден, то удалить из списка b:
for template in list_a:
    if template not in list_b:
        list_c.append(template)
    else:
        list_b.remove(template)

A: А так?
Разницу добавляем в list_b:
list_a = ['users1_', 'users1_', 'users2_', 'users3_']
list_b = ['users1_', 'users3_']
list_c = []

for x in list_a:
    num_a = list_a.count(x)
    num_b = list_b.count(x)
    if num_a > num_b:
        list_b.append(x)
        list_c.append(x)

print(list_c)  # ['users1_', 'users2_']

A: Если порядок элементов в результирующем списке не важен, зато важна производительность.
from collections import Counter

list_c = list((Counter(list_a) - Counter(list_b)).elements()) # ['users1_', 'users2_']


text:
Q: Read JSON file into a Jarray and access data dynamically I am trying to read in a json file which is very complex into a JArray that can be accessed dynamically in a foreach statement. However I am getting an error which is stating 'Current JsonReader item is not an Array' I am able to access the keys and values if I use a JObject but that is not what I need I need to be able to go through the records and search by names or IDs, etc. I am a bit new at newtwonsoft and JSON.net so any help would be appreciated!
JArray o1 = JArray.Parse(File.ReadAllText(@"myfilepath"));

dynamic records = o1;

foreach (dynamic record in records)
{
       Console.WriteLine(record.Id + " (" + record.Name + ")");
}

My json file looks like this, there are multiple records however I have shortened it.  I need to access and search by Id or Name however I am having issues accessing.
String json = @"{
  "RecordSetBundles" : [ {
    "Records" : [ {
      "attributes" : {
        "type" : "nihrm__Location__c",
        "url" : "/services/data/v38.0/sobjects/nihrm__Location__c/a0di0000001nI3oAAE"
      },
      "CurrencyIsoCode" : "USD",
      "Id" : "a0di0000001nI3oAAE",
      "Name" : "The City Hotel",
      "nihrm__Abbreviation__c" : "TCH",
      "nihrm__AddressLine1__c" : "1 Main Street",
      "nihrm__AlternateNameES__c" : "El Ciudad Hotel",
      "nihrm__AvailabilityScreenView__c" : "Combined",
      "nihrm__Geolocation__c" : null,
      "nihrm__HideBookingsFromPortal__c" : false,
      "nihrm__IsActive__c" : true,
      "nihrm__IsPlannerPortalEnabled__c" : false,
      "nihrm__isRemoveCancelledEventsFromBEOs__c" : false,
      "nihrm__ManagementAffliation__c" : "NI International",
      "nihrm__NearestAirportCode__c" : "MHT",
      "nihrm__Phone__c" : "(207) 555-5555",
      "nihrm__PostalCode__c" : "04103",
      "nihrm__PropertyCode__c" : "TCH",
      "nihrm__RegionName__c" : "Northeast",
      "nihrm__RestrictBookingMoveWithPickup__c" : true,
      "nihrm__RohAllowedStatuses__c" : "Prospect;Tentative;Definite",
      "nihrm__StateProvince__c" : "ME",
      "nihrm__SystemOfMeasurement__c" : "Standard",
      "nihrm__TimeZone__c" : "GMT-05:00 Eastern Daylight Time (America/New_York)",
      "nihrm__UpdateBookingEventAverageChecks__c" : false,
      "nihrm__UseAlternateLanguage__c" : false,
      "nihrm__Website__c" : "www.thecityhotelweb.com"
    } ],
    "ObjectType" : "nihrm__Location__c",
    "DeleteFirst" : false
  },

Here is a link to the entire json:
https://codeshare.io/rGL6K5

A: Do you know if the properties of your JSon object will be the same each time the request is made? Not the values, just the names? If so, create a concrete type and use JSonObjectSerializer to deserialize into an object. If should be able to create a dictionary collection on that object that deserialized your JSon data into Key Value pairs. Then you can iterate like any other collection via the Keys collection.
You don't really need to use dynamic objects unless you really don't know what you are dealing with on the input. Ascertain if your incoming data has consistent property names each time the request is made.
An example could be
var myData = JsonSerializer.Deserialize<myDataType>(incomingTextData);

myDataType would have a collection that can handle your array.

A: This error Current JsonReader item is not an Array is self explanatory: the object parsed is not an array.However without see the Json we can only suppose that this Json is an object and if you want use a dynamic object change the code as follow:
dynamic myJson = JsonConvert.DeserializeObject(File.ReadAllText(@"myfilepath"));
var currency = myJson.RecordSetBundles[0].Records[0].CurrencyIsoCode
//Access to other property in your dynamic object

EDIT
Your JSON object seems quite complex and access via dynamic can be complex I suggest you to use JsonConvert.DeserializeObject<T>(string).
From the json that yoou have posted the class looks like this:
public class Attributes
{
    public string type { get; set; }
    public string url { get; set; }
}

public class Record
{
    public Attributes attributes { get; set; }
    public string CurrencyIsoCode { get; set; }
    public string Id { get; set; }
    public string Name { get; set; }
    public string nihrm__Abbreviation__c { get; set; }
    public string nihrm__AddressLine1__c { get; set; }
    public string nihrm__AlternateNameES__c { get; set; }
    public string nihrm__AvailabilityScreenView__c { get; set; }
    public object nihrm__Geolocation__c { get; set; }
    public bool nihrm__HideBookingsFromPortal__c { get; set; }
    public bool nihrm__IsActive__c { get; set; }
    public bool nihrm__IsPlannerPortalEnabled__c { get; set; }
    public bool nihrm__isRemoveCancelledEventsFromBEOs__c { get; set; }
    public string nihrm__ManagementAffliation__c { get; set; }
    public string nihrm__NearestAirportCode__c { get; set; }
    public string nihrm__Phone__c { get; set; }
    public string nihrm__PostalCode__c { get; set; }
    public string nihrm__PropertyCode__c { get; set; }
    public string nihrm__RegionName__c { get; set; }
    public bool nihrm__RestrictBookingMoveWithPickup__c { get; set; }
    public string nihrm__RohAllowedStatuses__c { get; set; }
    public string nihrm__StateProvince__c { get; set; }
    public string nihrm__SystemOfMeasurement__c { get; set; }
    public string nihrm__TimeZone__c { get; set; }
    public bool nihrm__UpdateBookingEventAverageChecks__c { get; set; }
    public bool nihrm__UseAlternateLanguage__c { get; set; }
    public string nihrm__Website__c { get; set; }
}

public class RecordSetBundle
{
    public List<Record> Records { get; set; }
    public string ObjectType { get; set; }
    public bool DeleteFirst { get; set; }
}

public class RootObject
{
    public List<RecordSetBundle> RecordSetBundles { get; set; }
}

To deserialize it using Newtonsoft:
var myObject = JsonConvert.DeserializeObject<RootObject>(myJsonStrin);

A: The other answers show strong typed classes. If you can do this and you're sure the structure won't change I'd recommend doing it that way. It'll make everything else much easier.
If you want to do it with a dynamic object, then you can get what you want this way.
// GET JSON DATA INTO DYNAMIC OBJECT
var data  = JsonConvert.DeserializeObject<dynamic>(File.ReadAllText(@"myfilepath"));

// GET TOP LEVEL "RecordSetBundles" OBJECT
var bundles = data.RecordSetBundles;

// LOOP THROUGH EACH BUNDLE OF RECORDS
foreach (var bundle in bundles)
{
    // GET THE RECORDS IN THIS BUNDLE
    var records = bundle.Records;

    // LOOP THROUGH THE RECORDS
    foreach (var record in records)
    {
        // WRITE TO CONSOLE
        Console.WriteLine(record.Id.ToString() + " (" + record.Name.ToString() + ")");
    }
}

Produces this output:

a0di0000001nI3oAAE (The City Hotel)
  a0xi0000000jOQCAA2 (Rounds of 8)
  a0xi0000001aUbfAAE (Additional Services)
  a0xi0000004ZnehAAC (Citywide)
  a0xi0000001YXcCAAW (Cocktail Rounds)

etc etc