text:
Q: Error: Cannot find module 'firebase/app' When deploying google cloud function Basically I am trying to have a firebase function simply output values in a document, I have only achieved this locally... but the function won't deploy to the cloud. Below is the function
const functions = require('firebase-functions');
const firebase = require('firebase/app');
require('firebase/firestore');

const firebaseConfig = {
    projectId: "covid-info-bw"
};

const db = firebase
.initializeApp(firebaseConfig)
.firestore()

// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
exports.helloWorld = functions.https.onRequest((request, response) => {
  response.send("Hello from Firebase! Dawg I am beast");
});

exports.getData = functions.https.onRequest((req, res) => {
const docRef = db.collection('FunctionTest').doc('Cm38kBYShNnyuLVpizcy');
const getDoc = docRef.get()
    .then(doc => {
    if (!doc.exists) {
        console.log('No such document!');
        return res.send('Not Found')
    }
        console.log(doc.data());
        return res.send(doc.data());
    })
    .catch(err => {
    console.log('Error getting document', err);
});

This is a snippet from the package.json
"dependencies": {
  "@firebase/app": "^0.6.1",
  "@firebase/firestore": "^1.14.0",
  "@google-cloud/firestore": "^3.7.4",
  "firebase-admin": "^8.10.0",
 "firebase-functions": "^3.6.0"
},

This is the error I am getting from running " firebase deploy --only functions:getData,functions:helloWorld"
λ firebase deploy --only functions:getData,functions:helloWorld

=== Deploying to 'covid-info-bw'...

i  deploying functions
Running command: npm --prefix "%RESOURCE_DIR%" run lint

> functions@ lint M:\VueAdventures\covid-info-bw\functions
> eslint .

+  functions: Finished running predeploy script.
i  functions: ensuring necessary APIs are enabled...
+  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (41.45 KB) for uploading
+  functions: functions folder uploaded successfully
i  functions: current functions in project: getData(us-central1), helloWorld(us-central1)
i  functions: uploading functions in project: helloWorld(us-central1), getData(us-central1)
i  functions: updating Node.js 8 function helloWorld(us-central1)...
i  functions: updating Node.js 8 function getData(us-central1)...
!  functions[getData(us-central1)]: Deployment error.
 Function failed on loading user code. Error message: Code in file index.js can't be loaded.
 Did you list all required modules in the package.json dependencies?
 Detailed stack trace: Error: Cannot find module 'firebase/app'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/srv/index.js:2:18)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    !      functions[helloWorld(us-central1)]: Deployment error.
  Function failed on loading user code. Error message: Code in file index.js can't be loaded.
 Did you list all required modules in the package.json dependencies?
 Detailed stack trace: Error: Cannot find module 'firebase/app'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/srv/index.js:2:18)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)

 Functions deploy had errors with the following functions:
        getData
        helloWorld

 To try redeploying those functions, run:
     firebase deploy --only functions:getData,functions:helloWorld

 To continue deploying other features (such as database), run:
     firebase deploy --except functions

Error: Functions did not deploy properly.

A: You're not supposed to use the Firebase client SDKs for backend code.  What you're trying to do can be achieved using only the Google Cloud Firestore SDK (@google-cloud/firestore) or the Firebase Admin SDK (firebase-admin, which just writes the Cloud SDK).  Just remove the Firebase client SDKs (beginning with @firebase) and use only the backend SDKs you prefer.


text:
Q: Do transportees experience the passage of time? In Star Trek when one is transported, does it feel instantaneous regardless of if there is a need to store the person's pattern in the pattern buffer for any length of time?  Is the sensation of transport instantaneous regardless of length of time between dematerialization and rematerialization?
NOTE: This answer is probably going to have to come from the expanded Star Trek media (prose novels, comics, etc.) as we don't really get a first person perspective from the shows/movies during transportation.

A: Yes, while transporting you have no perception of time. This is why Scotty still thought Kirk came to rescue him when he actually spent 75 years in the transporter buffer.

RIKER: I'm Commander William Riker, starship Enterprise. Lieutenant Commander Geordi La Forge.
SCOTT: The Enterprise? I should have known. I bet Jim Kirk himself hauled the old girl out of mothballs to come looking for me. Captain Montgomery Scott. Tell me, how long have I been missing?

However, we get some insights in how it is to be transported. In "Realm of fear" the camera "witnesses" the moment of de-materialization:

In that episode, Barcley finds some of the survivors of the USS Yosemite "parked" in the transporter in a similar way Scotty saved himself 75 years before.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Separate complex text from number patterns from a single string I have a text file that looks something like this (but with hundreds of lines):
1147-1 SYRUP: DR.PEPPER 5GALLON/BOX
1653-1 SYRUP: DIET DR.PEPPER 5GAL/BOX
2011-2 WATER DISTILLED 6 / 1 GA
1217-2 ALL PURPOSE RASPBERRY FIL 40#
1273-1 STRAWBERRY PIE FILLING 38#
2893-1 BREAD: SOURDOUGH 12/1# OVAL
2287-1 BREAD SQUAW: 8/2.25#LF
1929-1 VINEGAR HERB CONT GRDN 12/12.7
1949-2 KETCHUP: 16/14OZ-PLASTIC BTLS
2408-1 CONE 3 NAB SAMPLER 28/45
2939-1 DULCE LECH FLVR PKT 3/12 EA CS
3017-1 GINGRBRD FLVR PKT 3/12 EA CS
3055-2 EGGNOG FLVR PKT 3/12 EA CS
3192-1 ORIGINAL MRS. DASH SEASONING

I've created the code to pull everything in from the text file line by line and strip out the numbers at the beginning and save the next portion (ie SYRUP: DR.PEPPER 5GALLON/BOX, ALL PURPOSE RASPBERRY FIL 40#) to Mid(nextLine, 10, 30). I want to take that portion and split it up by pulling the name (SYRUP: DR.PEPPER, ALL PURPOSE RASPBERRY FIL), the size (5GALLON, 40#) the number of that size (if it is 12/1# = 12x 1LB) and the unit (BOX, LB) out. As you can see almost every line is different but with many similarities. Not really sure what to do next. I have been trying to use:
re.Pattern = "GALLON|BOX|#|LF|GAL|EA|CS|BTLS"

to pull out the unit portion but I don't know what else to do.
Here is the code I have so far for this portion:
 Function NumericOnly(s As String) As String
 Dim StrUnit As String
 Static re As RegExp
 If re Is Nothing Then Set re = New RegExp
 re.IgnoreCase = True
 re.Global = True
 re.Pattern = "GALLON|BOX|#|LF|GAL|EA|CS|BTLS"
 StrUnit = re.Replace(s, "")
 End Function


text:
Q: how to get a shareable link ending with '.png' of saved image? In my app, i am saving an image into the the ContentVersion and getting a shareable link using the ContentDistribution. I am savinng that shareable link separately in a custom object, so that the user can preview it. This is the code  I used:
    ContentVersion contentVersion = new ContentVersion();
    contentVersion.ContentLocation = 'S';
    contentVersion.PathOnClient = fileName;
    contentVersion.Title = fileName;
    contentVersion.VersionData = EncodingUtil.base64Decode(base64Data);
    insert contentVersion;

    ContentDistribution cd = new ContentDistribution();
    cd.name = fileName;
    cd.ContentVersionId = contentVersion.Id;
    cd.PreferencesAllowOriginalDownload = true;
    cd.PreferencesAllowPDFDownload = false;
    cd.PreferencesAllowViewInBrowser = true;
    insert cd;
    cd = [SELECT DistributionPublicUrl FROM ContentDistribution WHERE ID =:cd.Id];
    String link = cd.DistributionPublicUrl;

The link i got from the above code works fine I if want to preview the image in the browser. But, the problem is that, I have a visualforce page and I want to give the link as an src path to the <img> tag inside the visualforce page. The src path only works when the link ends with '.png'. The link I get from ContentDistribution doesnt end with '.png'. So, is there any way to get the shareable link of an image  that ends with '.png' in apex? Also, the visualforce page opens outside of the org.


text:
Q: Picture editor in HTML/CSS/JS I am trying to make a website code with HTML, CSS, and JavaScript which will allow someone to upload an image and:

*

*crop the picture to fit a face within a circle (just like a profile picture)

*add text to the picture around the edge and

*print out the picture

So far I've been able to come up with this from one of Martin Zikmund's answers on how to add a profile picture which can take a picture and crop it into a circle (it's not centered though), and right now the printing step can be crudely accomplished by printing out the page, however I'm unsure of how I can add in the text around the edge and if I can allow the user to only print out said picture.
All that I've been able to put together so far again is attributed to this answer

$("#profileImage").click(function(e) {
    $("#imageUpload").click();
});

function fasterPreview( uploader ) {
    if ( uploader.files && uploader.files[0] ){
          $('#profileImage').attr('src',
             window.URL.createObjectURL(uploader.files[0]) );
    }
}

$("#imageUpload").change(function(){
    fasterPreview( this );
});
#imageUpload
{
    display: none;
}

#profileImage
{
    cursor: pointer;
}

#profile-container {
    width: 1.125in;
    height: 1.125in;
    overflow: hidden;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    -ms-border-radius: 50%;
    -o-border-radius: 50%;
    border-radius: 50%;
}

#profile-container img {
    width: 150px;
    height: 150px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="profile-container">
   <image id="profileImage" src="https://lorempixel.com/100/100" />
</div>
<input id="imageUpload" type="file"
       name="profile_photo" placeholder="Photo" required="" capture>


text:
Q: Failed to load libGL.so when running Flask app on Heroku I'm trying to run my Flask application on Heroku.  After git push heroku master I run heroku open and get the following error.  What does this it mean and how can I fix it?
(venv)peg@peg:~/Jungle-Flask$ heroku open
Opening jungle-monks... done
[1:1:0309/214907:ERROR:image_metadata_extractor.cc(111)] Couldn't load libexif.
Gtk-Message: Failed to load module "overlay-scrollbar"
Gtk-Message: Failed to load module "unity-gtk-module"
Gtk-Message: Failed to load module "canberra-gtk-module"
GLib-GIO-Message: Using the 'memory' GSettings backend.  Your settings will not be saved or shared with other applications.
[14994:14994:0309/214907:ERROR:gl_implementation_osmesa.cc(22)] Failed to load libGL.so.1: libGL.so.1: cannot open shared object file: No such file or directory

requirements.txt
Flask==0.10.1
Flask-Bcrypt==0.6.0
Flask-Bootstrap==3.1.1.1
Flask-Login==0.2.10
Flask-Mail==0.9.0
Flask-Migrate==1.2.0
Flask-Moment==0.3.0
Flask-PageDown==0.1.4
Flask-SQLAlchemy==1.0
Flask-Script==0.6.7
Flask-Testing==0.4.2
Flask-WTF==0.9.4
Flask-WhooshAlchemy==0.55a
Jinja2==2.7.3
Mako==1.0.0
Markdown==2.4
MarkupSafe==0.23
PAM==0.4.2
Pillow==2.3.0
PsychoPy==1.80.07
Pygments==1.6
SQLAlchemy==0.9.3
Sphinx==1.2.2
Tempita==0.5.2
Twisted-Core==13.2.0
Twisted-Web==13.2.0
WTForms==1.0.5
Werkzeug==0.9.6
Whoosh==2.6.0
adium-theme-ubuntu==0.3.4
alembic==0.6.7
apt-xapian-index==0.45
argparse==1.2.1
bleach==1.4
blinker==1.3
chardet==2.0.1
colorama==0.2.5
command-not-found==0.3
coverage==3.7.1
debtagshw==0.1
decorator==3.4.0
defer==1.0.6
dirspec==13.10
dnspython==1.11.1
docutils==0.11
duplicity==0.6.23
flask-paginate==0.2.3
gunicorn==19.3.0
html5lib==0.999
httplib2==0.8
itsdangerous==0.24
lockfile==0.8
lxml==3.3.3
nose==1.3.1
oauthlib==0.6.1
oneconf==0.3.7
pbr==0.10.0
pexpect==3.1
piston-mini-client==0.7.5
psycopg2==2.4.5
py==1.4.20
pyOpenSSL==0.13
pycrypto==2.6.1
pycups==1.9.66
pycurl==7.19.3
pygobject==3.12.0
pyserial==2.6
pysmbc==1.0.14.1
pytest==2.5.1
python-apt==0.9.3.5ubuntu1
python-debian==0.1.21-nmu2ubuntu2
pyxdg==0.25
reportlab==3.0
requests==2.2.1
roman==2.0.0
sessioninstaller==0.0.0
six==1.5.2
software-center-aptd-plugins==0.0.0
sqlalchemy-migrate==0.9.2
sqlparse==0.1.14
system-service==0.1.6
unity-lens-photos==1.0
urllib3==1.7.1
virtualenv==1.11.4
wsgiref==0.1.2
wxPython==2.8.12.1
wxPython-common==2.8.12.1
xdiagnose==3.6.3build2
zope.interface==4.0.5


text:
Q: guardar radiobutton php y mysql tengo un formulario para poder añadir filas a una tabla

lo que no se como hacer es como recibir el campo del radioButton al momento de guardar, ya que cada uno tiene nombres diferentes en cada fila como por ejemplo

*

*1era fila ---SinPendulo0

*2da fila ----SinPendulo1
....

Vista (parte del td de mi tabla)

                      <input type="radio" name="SinPedinculo${j}[]" id="SinPedinculo${j}" value="SI">
                      Si

                      <input type="radio" name="SinPedinculo${j}[]" id="SinPedinculo${j}" value="NO" checked>
                      No

                      <input type="checkbox" name="GolpexJava[]" id="GolpexJava${j}" value="SI">
                      Si

                      <input type="checkbox" name="GolpexJava[]" id="GolpexJava${j}" value="NO" checked>
                      No

Controller (parte del controller , donde recibo los campos para guardarlos)
                $Recepciones->Idiccab=$Idd;
                $Recepciones->n_item=$num_item+1;
                $Recepciones->Color=$_REQUEST["Color"][$i];
                $Recepciones->Brix=$_REQUEST["Brix"][$i];
               $Recepciones->SinPedinculo=$_REQUEST["SinPedinculo"][$i];

Podrian ayudarme .. gracias..


text:
Q: Powershell code raising error while adding contribute permission on term group to everyone Add-PSSnapin "microsoft.sharepoint.powershell"
#Connect to the Metadata Service
$taxSite = get-SPSite "CentralAdminURL"    # Central Admin URL
$taxonomySession = Get-SPTaxonomySession -site $taxSite
$termStore = $taxonomySession.TermStores["MetadataServiceName"] # Meta data service name
#Create a group
$termGroup = $termstore.CreateGroup("NewTermGroup") # New group
$termStore.CommitAll()

#Connect to existing term group
$termGroup = $termstore.groups["NewTermGroup"];

#TERM SETS
#Create a term set
$termSet = $termGroup.CreateTermSet("Skills")
$termStore.CommitAll()

#Connect to existing term set
$termset = $TermGroup.Termsets["Skills"]

#Adding a default term to term set
$term = $termSet.CreateTerm("Sea wall",1033)
$term.SetDescription("Sea wall", 1033)
$term.CreateLabel("Seawall", 1033, $false)

$TermSet.IsOpenForTermCreation = $true;

# Contribute permission on term group (This statement raising error)
$user = "c:0(.s|true"
$termGroup.AddContributor($user)

# Contribute permission on term group   (This statement raising error)
#$termGroup.AddContributor("Domain\\Everyone")

$termStore.CommitAll()

Error:

Exception calling "AddContributor" with "1" argument(s): "The user name 'ec\everyone' can not be found.
  Parameter name: principalName"
  At line:11 char:1
  + $termGroup.AddContributor("Domain\everyone")
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : ArgumentException

A: The error is coming from the argument passed with AddContributor.  The string to be passed should be the login name of a user, not a path.  Cycle through the actual users of your site, and add each user individually to the term group.
Here are some references to take a look at to understand it better.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.group.addcontributor%28v=office.14%29.aspx
http://msdn.microsoft.com/EN-US/library/3w1b3114

A: The second one that raises error can be solved by removing the escape character: "\", because it causes an error in PowerShell. So here is the working code:
$termGroup.AddContributor("Domain\Everyone")


text:
Q: How would I express that a variable is a very small number? I was wondering if there were a mathematical way to note that a variable in an expression is "very small". I feel like ambiguity might be the cause of there not being one, but I'm not sure.
Example:
$\Delta A = \frac12 (r + \Delta r)^2 \Delta \theta - \frac12 r^2 \theta  = r (\Delta r \Delta \theta) + \frac12(\Delta r)^2 \Delta \theta \approx r \Delta r \Delta \theta$
Error in $\Delta A $ is the term $\frac12 (\Delta r)^2 \Delta \theta$ when $\Delta r$ and $\Delta  \theta$ are very small.
Is there a better way to write the bolded statement?
And on that note, is there a better way to write "Error in $\Delta A$"?

A: Consider using Little o notation. This makes explicit what we mean by "a negligible error". We are ultimately interested in what happens as $\Delta r\to0$. If $f(\Delta r)=o(\Delta r)$ (i.e. if $\frac{f(\Delta r)}{\Delta r}\to0$ as $\Delta r\to0$), then $f(\Delta r)$ must be much smaller than $\Delta r$. Your final expression is a multiple of $\Delta r$, and so it is reasonable to group all lower order terms in one $o(\Delta r)$.
Another example: we know $\lim_{\Delta x\to0}\frac{\sin(x+\Delta x)-\sin(x)}{\Delta x}=\cos(x)$. We could rewrite this as
$$\sin(x+\Delta x)=\sin(x)+\Delta x\cos(x)+o(\Delta x).$$
The difference between $\sin(x+\Delta x)$ and $\sin(x)+\Delta x\cos(x)$ is not zero, but on the scale of $\Delta x$ it is so small that does not affect our limit.

A: You can write $\Delta r, \Delta\theta < \epsilon$, if that is what you are asking.
For the error part you could say, for example:
$$ e = \lVert\Delta A - \Delta A^*\rVert  $$
where $e$ is the error and $\Delta A^*$ the real value of $\Delta A$.


text:
Q: How to create a bootable USB from a bootable ISO with the command line on Linux? I have a CD that's created from an ISO file which I use to install a custom version of Ubuntu via plop linux.
The cd works fine but I'd like to use a bootable USB drive instead.
I used the command dd to try and create the bootable USB:
dd if=filename.iso of=/dev/sdb1 bs=4k

Now this does copy the files and make the USB bootable but I get the error "Missing operating system"
Any ideas?

A: Ok after some research I've figured out a solution, and I'll go through it step by step.
Problem was two-fold.

*

*Plug in the USB flash drive and determine the device it's mounted on with the command:
sudo fdisk -l

This time around it was /dev/sdc1 for me, so I'll use that as my example.

*Umount the device
umount /dev/sdc1

*Not sure if necessary but I formatted the drive in FAT32, just in case
sudo mkdosfs -n 'USB-Drive-Name' -I /dev/sdc -F 32

*Now my ISO was using isolinux not syslinux. I knew it worked with CDs so I figured out that I needed to call the isohybrid command, which allows for an ISO to be recognized by the BIOS from a hard drive.
 isohybrid filename.iso

You can find out more about this command here, but this was the cause of the message "Missing Operating System" The first problem was fixed, but now it said "isolinux.bin was missing or corrupt"

*The next step is to copy the iso. My second problem lay here, where I was copying to the partition, sdc1, not the device, sdc.
sudo dd if=filename.iso of=/dev/sdc bs=4k

This seems to work just fine, but the forum where I got the last fix, it was recommended to do the following before unplugging the device:
sync
sudo eject /dev/sdc

A: This is a common issue with SanDisk USB sticks, or sticks not formatted in FAT32.
If not either of those it is most certainly an issue with your stick partition order or the syslinux.cfg file.

A: isohybrid may not always work. For example, I had an .iso with FreeDOS and isohybrid was not able to find some important files there (I don't know whether they should had been put there by syslinux, which I used too, or anything else). I propose several alternatives here.
1) Install another bootloader there such as GRUB. It is explained here:
"Assume your USB stick's first partition is FAT32 and its partition is /dev/sdy1" (I had grub2 on my Fedora Core, so I changed the commands a bit):
# mkdir -p /mnt/usb ; mount /dev/sdy1 /mnt/usb
# grub2-install --target=i386-pc --recheck --debug --boot-directory=/mnt/usb/boot /dev/sdy
# grub2-mkconfig -o /mnt/usb/boot/grub2/grub.cfg

# optional, backup config files of grub.cfg
# mkdir -p /mnt/usb/etc/default
# cp /etc/default/grub /mnt/usb/etc/default
# cp -a /etc/grub.d /mnt/usb/etc

# sync; umount /mnt/usb

2) FreeDOS wiki offers a compound method with GRUB and syslinux here (though I don't understand how they launched grub> - I couldn't boot from the usb up to that stage).
3) Here is a post which may be useful - it says 'As long as the command.com, kernel.sys, syslinux.cfg, ldlinux.sys and fat32lba.bss files are in the root of the drive and the MBR and boot sector are not rewritten the drive should remain bootable.'
4) Here it is explained how to generate a bootable .iso file with a syslinux bootloader. They don't even use isohybrid. Unfortunately that didn't help me (maybe because of syslinux).
5*) Use a windows program via wine. I tried rufus, however that didn't work, it couldn't find the device.
I warn you that unfortunately I couldn't solve this problem, my device was unbootable, but I hope that this may be useful for other people (also those who want to install not a linux on the usb).
The usb image generated by chtaube though worked for me, so I think these methods are correct.
UPD: The 3rd method really works (with a correction for a custom installation file).
UPD2: (fixed links). The problem with isohybrid was probably because the versions of isolinux.bin on iso and my system were different. Recompiled the iso using genisoimage as suggested here:
genisoimage -l -r -J -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -c isolinux/boot.cat -o fd11new.iso fd11new

There were some problems too, they were solved by the method here before genisoimage:
cp /boot/extlinux/*.c32 fd11new/isolinux/
extlinux --install /boot/isolinux

== end UPD2 ==

A: You could use bootiso utility, which does exactly that, securely:
bootiso -d /dev/sdb filename.iso

bootiso will check that selected device /dev/sdb is connected through USB and fails if it doesn't, which is a big security plus.
It will also autodetect USB device if there is exactly one USB drive connected to your system, see it in action:

If you want to install syslinux bootloader to circumvent issues mentioned by @xsdf, use -b option:
 bootiso -b -d /dev/sdb filename.iso

To install it:
curl -L https://rawgit.com/jsamr/bootiso/latest/bootiso -O
chmod +x bootiso


text:
Q: 'Platform is not supported' supported when trying to run OSGi debug target I'm trying to run a tiny OSGi project from IntelliJ Idea. I've added the Equinox container in the OSGi configuration section in Idea. Then I added the OSGi facet to the project. Everything looks ok to this point.
However as soon as I try to run the project I get into trouble. I use the 'OSGi Bundles' runner from IntelliJ Idea. There I select my project bundles and the OSGi container and run it. Here the issue starts. I always the the same error message:
             ___
            /  /
           /  / Oops, there has been a problem!
          /  /
         /__/   Platform [platform.felix 3.0.6] is not supported
        ___
       /__/

     -> Exception caught during execution:
    org.ops4j.pax.runner.ConfigurationException: Platform [platform.felix 3.0.6] is not supported
        at org.ops4j.pax.runner.Run.installPlatform(Run.java:611)
        at org.ops4j.pax.runner.Run.start(Run.java:221)
        at org.ops4j.pax.runner.Run.main(Run.java:148)
        at org.ops4j.pax.runner.Run.main(Run.java:121)

I tried to use other OSGi containers, like Felix or Knopflerfish and have the same issue. Does anyone know what I'm doing wrong. Or which versions of OSGi containers are supported by IntelliJ?

A: Osmorc (IntelliJ OSGi plugin) sets up pax runner context with the platform name and version you provide in OSGi settings of the IDE (IDE Settings -> OSGi -> Framework Definitions).
The name is "platform."+the name you provided, and the version is verbatim.
The supported versions for different platforms are listed here. The list is not up-to-date, though.
You can check the actual versions by looking inside the runner jar. Go to your idea_home/plugins/osmorc/lib, open pax-runner-...jar. META-INF directory contains sub-directory for each platform with definition-$VERSION.xml.
For your example, you can see there is no support for Felix 3.0.6 in pax-runner 1.5.0. The latest supported version is 3.0.2.


text:
Q: enforce the decimal format for csv I am using CSVLink to download data from my react app. One of the columns contain a 16 digits number so when I am downloading the file the output format will change to something like this 8.1543E+15.
const text = [
{ a1: "1111111111111111", a2: "0658" },
{ a1: "2222222222222222", a2: "0658" },
{ a1: "3333333333333333", a2: "0658" },
{ a1: "4444444444444444", a2: "10658" }]

 <CSVLink
       filename={props.name + ".csv"}
       target="_blank"
       data={text}
       headers={[{ label: "a1", key: "a1" }, { label: "a2", key: "a2" }]}>
       {props.name}
  </CSVLink>

If I will open the file with Notepad then I can see the full number but via Excel I will see 8.1543E+15 & 658
How can I enforce the decimal format so when the user download the file he will see the full number witout the need to manually change the decimal places.
Thank you
.

A: The csv format has no provision to include format information for columns - so you can not enforce decimal format.
The only thing you can possibly do is force spreadsheet programs to treat the numbers as 'string'.

*

*If you have number "8154300000000000" to be treated as string in spreadsheet application, you need to write it as  ="8154300000000000"

*The " character is a separator in csv - that means you need to escape " character. The escape character in csv is ". That means you need to output double quotes ("") to escape single quote (").  Now your output string will be =""8154300000000000""

*Finally, your React program also needs to escape " character. The escape character for javascript is \ - but for simplicity you can enclose the string in single quote (')
You can see the working sample here..
https://codesandbox.io/s/react-cvs-large-integer-ff32p?file=/src/App.js
  const text = [
    { a1: '=""8154300000000000""', a2: "0658" },
    { a1: "2222222222222222", a2: "0658" },
    { a1: "3333333333333333", a2: "0658" },
    { a1: "4444444444444444", a2: "10658" }
  ];

  return (
    <CSVLink
      filename="largeNumber.csv"
      target="_blank"
      data={text}
      headers={[
        { label: "a1", key: "a1" },
        { label: "a2", key: "a2" }
      ]}
    >
      Download Me
    </CSVLink>
  );


text:
Q: TypeScript + React: Avoid setState on unmounted components I know that a common pattern of avoiding calling .setState() on an unmounted component is by adding a private property such as _isMounted to keep track of it, as mentioned in a blog.
I've been using this method like this:
class Hello extends React.PureComponent{
_isMounted = false;

constructor(props) {
    super(props);
    this.state = {
        // ...
    };
}

componentDidMount() {
    this._isMounted = true;
}

componentWillUnmount() {
    this._isMounted = false;
}
// ...
}

Everything was fine until I started to use TypeScript. I tried to do this in the same way:
class Hello extends React.PureComponent<Props, State> {
private _isMounted: boolean;

constructor(props: Props) {
    super(props);
    this.state = {
        // ...
    };
}

componentDidMount() {
    this._isMounted = true;
}

componentWillUnmount() {
    this._isMounted = false;
}
}

But then it always throws a type error:
TypeError: Cannot set property _isMounted of #<Component> which has only a getter

For now, the only solution I know is to explicitly write a setter for it. But I don't really understand if this is the expected way to do it. Doesn't TypeScript generate getter and setter automatically?
Updated:
A codesandbox example: https://codesandbox.io/s/l59wnqy5zz

A: Somehow it's the name, to me _isMounted actually works but not isMounted.

@Stramski points out, I think _isMounted is a private property of React.Component. Rename it and it should work.

To confirm, I rename the variable to mounted, it worked.

A: It might be useful for other developers
Using getters and setters
class Hello extends React.Component {
    private isFullyMounted: boolean = false;

    public componentDidMount() {
        this.isMounted = true;
    }

    public componentWillUnmount() {
        this.isMounted = false;
    }

    public set isMounted(status: boolean) {
        this.isFullyMounted = status;
    }

    public get isMounted() {
        return this.isFullyMounted;
    }
}


text:
Q: Unit testing jQuery references and ajax calls in ES6 classes I'm refactoring a codebase to use ES6 classes. I have limited knowledge in jQuery/ajax and I am struggling to set up a test environment that can be tested outside of being included as a script in an HTML page and also works with ES6 class syntax.
export class VimRegistrationAPI {
getProducts(header, sendparty) {

    $.ajax({
        type: 'GET',
        url: 'api/product',
        beforeSend: function (xhr) { xhr.setRequestHeader('Environment', header); }
    }).done(function (data, textStatus, xhrObject) {
        sendparty(null, data);
    }).fail(function (xhrObject, textStatus, errorThrown) {
        sendparty(new Error("Bad"), errorThrown);
    });
}

I've attempted to unit test this using Mocha.js, but get an error saying $ is undefined. My attempt to solve this was to create a var $ and requiring jQuery, but returns an error declaring that $.ajax is not a function. I am thinking that this is because jQuery has no document to reference. How can I create an environment that allows for unit testing with these ajax calls inside of the class?


text:
Q: Pandas - split columns and include counts I have the following dataframe:
            doc_id  is_fulltext
1243      dok:1            1
3310      dok:1            1
4370      dok:1            1
14403  dok:1020            1
17252  dok:1020            1
15977  dok:1020            0
16480  dok:1020            1
16252  dok:1020            1
468     dok:103            1
128    dok:1030            0
1673   dok:1038            1

I would like to split the is_fulltext column into two columns and count the occurrences of the docs at the same time.
Desired Output:
 doc_id                 fulltext  non-fulltext
0           dok:1        3          0
1           dok:1020     4          1
2           dok:103      1          0
3           dok:1030     0          1
4           dok:1038     1          0

I followed the procedure of Pandas - Create columns from column value, and fill with count
That post shows several alternatives, suggesting Categorical or reindex. I tried the following:
cats = ['fulltext', 'non_fulltext']
df_sorted['is_fulltext'] = pd.Categorical(df_sorted['is_fulltext'], categories=cats)
new_df = df_sorted.groupby(['doc_id', 'is_fulltext']).size().unstack(fill_value=0)

Here I get a ValueError:
ValueError: Length of passed values is 17446, index implies 0

Then I tried this method

cats = ['fulltext', 'non_fulltext']
new_df = df_sorted.groupby(['doc_id','is_fulltext']).size().unstack(fill_value=0).reindex(columns=cats).reset_index()

While this seems to have worked fine in the original post, my counts are filled with NANs (see below). I read by now that this happens when using reindex and categorical, but I wonder why it seems to have worked in the original post. And how can I solve this? Can anyone help? Thank you!
 doc_id                         fulltext  non-fulltext
0           dok:1                NaN          NaN
1           dok:1020             NaN          NaN
2           dok:103              NaN          NaN
3           dok:1030             NaN          NaN
4           dok:1038             NaN          NaN

A: You could GroupBy the doc_id, apply pd.value_counts to each group and unstack:
(df.groupby('doc_id').is_fulltext.apply(pd.value_counts)
                                 .unstack()
                                 .fillna(0)
                                 .rename(columns={0:'non-fulltext', 1:'fulltext'})
                                 .reset_index())

    doc_id      non-fulltext  fulltext
0     dok:1           0.0       3.0
1  dok:1020           1.0       4.0
2   dok:103           0.0       1.0
3  dok:1030           1.0       0.0
4  dok:1038           0.0       1.0

Or similarly to your own method, if performance is an issue do instead:
df.groupby(['doc_id','is_fulltext']).size()
                                    .unstack(fill_value=0)
                                    .rename(columns={0:'fulltext',1:'non_fulltext'})
                                    .reset_index()

is_fulltext    doc_id  fulltext  non_fulltext
0               dok:1         0             3
1            dok:1020         1             4
2             dok:103         0             1
3            dok:1030         1             0
4            dok:1038         0             1

A: I don't know if it's the best approach, but this should work for you:
import pandas as pd
df = pd.DataFrame({"doc_id":["id1", "id2", "id1", "id2"],
                   "is_fulltext":[1, 0, 1, 1]})
df_grouped = df.groupby("doc_id").sum().reset_index()
df_grouped["non_fulltext"] = df.groupby("doc_id").count().reset_index()["is_fulltext"] - df_grouped["is_fulltext"]
df_grouped

And the output is:
  doc_id  is_fulltext  non_fulltext
0    id1            2             0
1    id2            1             1


text:
Q: TextInput going to middle of page I have a TextInput in my app.js , but it stays in the middle of the page, But I want it to be on the top of the page, I mean just under the notification bar, Please how can I do this
 <View style={BackStyles.container}>
            <TextInput
                underlineColorAndroid={'transparent'}  style={BackStyles.textBox}
            /></View>

const BackStyles = StyleSheet.create({
container: {
    flexDirection: 'row',
    alignItems: 'center',
    alignSelf: 'stretch',
    flex: 1,
    backgroundColor: '#E2E2E2',
    marginTop: 20,
},
textBox: {
    height: 36,
    padding: 4,
    marginRight: 5,
    flexGrow: 1,
    fontSize: 18,
    color: '#48BBEC',
    backgroundColor: '#fff'
}
});

A: Try replacing alignItems: 'center' with alignItems: 'flex-start'.


text:
Q: Warning: mysql_select_db() expects parameter 2 to be resource, object given in So i been here for a while i just cant solve the problem.
Thanks for the Help.
Donc je été ici pendant un moment, et j'arrive pas résoudre le problème.
Merci.
<?php

if (!$link = new mysqli("localhost", "root", "")) {
    echo "Connexion impossible à mysql";
    exit; }

if (!$db_selected=mysql_select_db("supersaiyandatabase", $link)) {
    echo "Sélection de base de données impossible";
    exit; }

?>

A: Thanks, solved my problem!! Works now.
<?php

if (!$link = mysqli_connect("localhost","root","","supersaiyandatabase")) {
    echo "Connexion impossible à mysql";
    exit;
}

?>

A: You're doing it a bit wrong, since you're setting $link to a new mysqli object, you have to select the db my doing this:
if (!$db_selected=$link->select_db("supersaiyandatabase")) {
    echo "Sélection de base de données impossible";
    exit; }


text:
Q: Dynamically adding a view to a custom ListView item layout not working I wish to add a custom tailored layout for each ListView item. I have an empty linear layout in the xml layout file for ListView item layout. It has horizontal orientation.
I wish to add three FrameLayouts dynamically to above mentioned LinearLayout and set custom weight for each FrameLayout.
I found a part of the solution for it, as in the code below. Problem arises when the ListView has to be updated. ListView is initially hidden. When a certain button is pressed, ListView gets updated (hash map cleared and then filled with a new data set) and its visibility set from GONE to VISIBLE. Next thing is to loop through all the items and add designed view programmatically.
If I invoke the method add_designed_views(null); right after updating ListView items, the app loops through items, creates all the new views and adds them to right items. However, they are not added. I know this because of check if the item is already added, and if I invoke this method several times in a row, it will do the same each time, as if it didn't add anything at all.
Next thing that I tried is I postponed adding views dynamically by invoking the method add_designed_views from onClick of a dummy button. When I see the list has loaded (without the custom views) I press the dummy button and the custom views appear. But every 6th is missing. If I press it again, the missing ones appear. Which makes me even more confused.
It's obvious that the views can't be added immediately after changing the visibility of ListView. Probably because it takes the system some time to inflate the ListView, or it does some background task, but I couldn't find any listener or some function that tells me that it has finished loading so that I can add my views then.
Custom ListView item layout (xml):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="110dp"
    android:background="@drawable/textview_border_dark_line"
    android:orientation="horizontal">

    <RelativeLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="21"
        android:minHeight="40dp">
        <TextView
            android:id="@+id/text1"
            android:textSize="16sp"
            android:textStyle="bold"
            android:textColor="#000000"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="10dp"
            android:paddingTop="15dp"
            />
    </RelativeLayout>
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="70"
        android:minHeight="90dp"
        android:orientation="vertical">
        <LinearLayout
            android:id="@+id/path_model"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="50"
            android:orientation="horizontal"
            android:onClick="onClick_listItem"
            >
        <!-- Path Model. -->
        <!-- This is where I add view dynamically. -->

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="40"
            android:orientation="vertical">
            <TextView
                android:id="@+id/text2"
                android:textSize="12dp"
                android:textColor="#454545"
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:layout_weight="50"
                android:layout_centerInParent="true"
                android:layout_centerHorizontal="true" />
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="50"
                android:orientation="horizontal">
                <RelativeLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="10">
                    <ImageView
                        android:id="@+id/ic_time"
                        android:layout_width="16dp"
                        android:layout_height="16dp"
                        android:src="@drawable/clock"
                        android:layout_centerVertical="true" />
                    <TextView
                        android:id="@+id/text4_1"
                        android:textSize="14dp"
                        android:textColor="#454545"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="50"
                        android:layout_centerVertical="true"
                        android:layout_toRightOf="@id/ic_time" />
                </RelativeLayout>

                <RelativeLayout
                    android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="10">
                <ImageView
                    android:id="@+id/ic_changes"
                    android:layout_width="16dp"
                    android:layout_height="16dp"
                    android:src="@drawable/change"
                    android:layout_centerVertical="true"/>
                <TextView
                    android:id="@+id/text4_2"
                    android:textSize="14dp"
                    android:textColor="#454545"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="50"
                    android:layout_centerVertical="true"
                    android:layout_toRightOf="@id/ic_changes"
                    />
            </RelativeLayout>
            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="10">
                <ImageView
                    android:id="@+id/ic_cost"
                    android:layout_width="16dp"
                    android:layout_height="16dp"
                    android:src="@drawable/coins"
                    android:layout_centerVertical="true"/>
                <TextView
                    android:id="@+id/text4_3"
                    android:textSize="14dp"
                    android:textColor="#454545"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="50"
                    android:layout_centerVertical="true"
                    android:layout_toRightOf="@id/ic_cost"
                    />
            </RelativeLayout>
            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="10">
            </RelativeLayout>

        </LinearLayout>
    </LinearLayout>

    </LinearLayout>
    <RelativeLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="21"
        android:minHeight="38dp">
        <TextView
            android:id="@+id/text3"
            android:textSize="16sp"
            android:textStyle="bold"
            android:textColor="#000000"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="10dp"
            android:paddingTop="15dp"
            />
    </RelativeLayout>

</LinearLayout>

add_designed_views method (Java):
public void add_designed_views(View view)
{
    for(int i=0; i<hashmap_search_results_list.size(); i++)
    {
        /* Check if it is already added. We have to check,
           because we run it twice in consecutive order. */
        LinearLayout listView_item = (LinearLayout)getViewByPosition(i, listView_search_results);
        View middle_ground = ((ViewGroup) listView_item).getChildAt(1);

        LinearLayout path_model = (LinearLayout) ((ViewGroup) middle_ground).getChildAt(0);
        LinearLayout already_added_ll_path = (LinearLayout)((ViewGroup)path_model).getChildAt(0);
        if(already_added_ll_path != null)
        {
            Log.d(TAG, "Already has linear layout: " + hashmap_search_results_list.get(i).get("latest_departure_time"));
            continue;
        }

        Log.d(TAG, "Doing: " + hashmap_search_results_list.get(i).get("latest_departure_time"));

        Search_Result_Item result_item = (Search_Result_Item)search_results_list.get(i);

        /* How to access each view at each item position in list view. */
        //LinearLayout listView_item = (LinearLayout) getViewByPosition(i, listView_search_results);
        //View middle_ground = ((ViewGroup) listView_item).getChildAt(1);
        //LinearLayout path_model = (LinearLayout) ((ViewGroup) middle_ground).getChildAt(0);

        /* Setting the proportions of lines regarding walking time and riding time. */
        HrMin hrmin_walking_to_entrance_time = result_item.walking_to_entrance_time();
        HrMin hrmin_riding_time = result_item.travel_time();
        HrMin hrmin_walking_from_exit_time = result_item.walking_from_exit_time();

        int int_walking_to_entrance_time = hrmin_get_minutes(hrmin_walking_to_entrance_time);
        int int_riding_time = hrmin_get_minutes(hrmin_riding_time);
        int int_walking_from_exit_time = hrmin_get_minutes(hrmin_walking_from_exit_time);
        int total = int_walking_to_entrance_time +
                int_riding_time +
                int_walking_from_exit_time;

        float weight_walking_to_entrance = (float)int_walking_to_entrance_time/total;
        float weight_bus_ride = (float)int_riding_time/total;
        float weight_walking_from_exit = (float)int_walking_from_exit_time/total;

        /* How to add a new layout, view to existing layout. */
        LinearLayout ll_path = new LinearLayout(this);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams
                (LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);

        /* Pedestrian image. */
        ImageView pedestrian = new ImageView(this);
        pedestrian.setBackground(getResources().getDrawable(R.drawable.runner_rnd));

        int dimensionInPixel = 16;
        int dimensionInDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dimensionInPixel, getResources().getDisplayMetrics());
        FrameLayout.LayoutParams pedestrian_params = new FrameLayout.LayoutParams(
                dimensionInDp,
                dimensionInDp,
                Gravity.CENTER_VERTICAL);
        pedestrian.setLayoutParams(pedestrian_params);

        /* Gray Line. */
        FrameLayout frameLayout_pedestrian_container = new FrameLayout(this);
        LinearLayout.LayoutParams frame_layout_params = new LinearLayout.LayoutParams(
                0,
                LinearLayout.LayoutParams.MATCH_PARENT,
                weight_walking_to_entrance);

        View gray_line = new View(this);
        gray_line.setBackground(getResources().getDrawable(R.drawable.horizontal_gray_line));

        dimensionInPixel = 4;
        dimensionInDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dimensionInPixel, getResources().getDisplayMetrics());
        FrameLayout.LayoutParams gray_line_params = new FrameLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                dimensionInDp,
                Gravity.CENTER_VERTICAL);
        gray_line.setLayoutParams(gray_line_params);

        frameLayout_pedestrian_container.addView(gray_line);
        frameLayout_pedestrian_container.addView(pedestrian);
        frameLayout_pedestrian_container.setLayoutParams(frame_layout_params);
        ll_path.addView(frameLayout_pedestrian_container);

        /* Bus image. */
        FrameLayout frameLayout_bus_container = new FrameLayout(this);
        LinearLayout.LayoutParams frame_layout_bus_params = new LinearLayout.LayoutParams(
                0,
                LinearLayout.LayoutParams.MATCH_PARENT,
                weight_bus_ride);

        ImageView bus = new ImageView(this);
        bus.setBackground(getResources().getDrawable(R.drawable.bus_rnd));

        dimensionInPixel = 17;
        dimensionInDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dimensionInPixel, getResources().getDisplayMetrics());
        FrameLayout.LayoutParams bus_params = new FrameLayout.LayoutParams(
                dimensionInDp,
                dimensionInDp,
                Gravity.CENTER_VERTICAL);
        bus.setLayoutParams(bus_params);

        /* Green line. */
        View green_line = new View(this);
        green_line.setBackground(getResources().getDrawable(R.drawable.horizontal_green_line));

        dimensionInPixel = 4;
        dimensionInDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dimensionInPixel, getResources().getDisplayMetrics());
        FrameLayout.LayoutParams green_line_params = new FrameLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                dimensionInDp,
                Gravity.CENTER_VERTICAL);
        green_line.setLayoutParams(green_line_params);

        frameLayout_bus_container.addView(green_line);
        frameLayout_bus_container.addView(bus);
        frameLayout_bus_container.setLayoutParams(frame_layout_bus_params);
        ll_path.addView(frameLayout_bus_container);

        /* Walking from exit path. */
        ImageView pedestrian2 = new ImageView(this);
        pedestrian2.setBackground(getResources().getDrawable(R.drawable.runner_rnd));

        dimensionInPixel = 16;
        dimensionInDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dimensionInPixel, getResources().getDisplayMetrics());
        FrameLayout.LayoutParams pedestrian_params2 = new FrameLayout.LayoutParams(
                dimensionInDp,
                dimensionInDp,
                Gravity.CENTER_VERTICAL);
        pedestrian2.setLayoutParams(pedestrian_params2);

        /* Gray Line. */
        FrameLayout frameLayout_pedestrian_container2 = new FrameLayout(this);
        LinearLayout.LayoutParams frame_layout_params2 = new LinearLayout.LayoutParams(
                0,
                LinearLayout.LayoutParams.MATCH_PARENT,
                weight_walking_from_exit);

        View gray_line2 = new View(this);
        gray_line2.setBackground(getResources().getDrawable(R.drawable.horizontal_gray_line));

        dimensionInPixel = 4;
        dimensionInDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dimensionInPixel, getResources().getDisplayMetrics());
        FrameLayout.LayoutParams gray_line_params2 = new FrameLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                dimensionInDp,
                Gravity.CENTER_VERTICAL);
        gray_line2.setLayoutParams(gray_line_params2);

        frameLayout_pedestrian_container2.addView(gray_line2);
        frameLayout_pedestrian_container2.addView(pedestrian2);
        frameLayout_pedestrian_container2.setLayoutParams(frame_layout_params2);
        ll_path.addView(frameLayout_pedestrian_container2);

        ll_path.setLayoutParams(params);
        ll_path.setOrientation(LinearLayout.HORIZONTAL);
        path_model.addView(ll_path);
    }
}

Part where I update the ListView and show it:
search_results.setVisibility(View.VISIBLE);

ListView is a child of two layouts:
<LinearLayout
    android:id="@+id/search_results"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    android:visibility="gone"
    android:paddingTop="140dp"
    android:orientation="vertical"
    android:onClick="onClick_nothing">
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/search_options_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="@+id/mapView"
        app:layout_constraintTop_toTopOf="@+id/mapView"
        android:background="@android:color/white"
        android:orientation="vertical"
        >
        <ListView
            android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbarAlwaysDrawVerticalTrack="true"
            android:scrollbarThumbVertical="@android:color/darker_gray"
            />
    </RelativeLayout>

</LinearLayout>

A: One thing that helped is Handler.postDelayed():
final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            add_designed_views (null);
        }
    }, 300);

This function delays method call for 300 mS. Programmatically added layouts are visible. But, still every 6th is missing. They also appear after I touch any of the items.


text:
Q: indiviual files upload asp.net c# when i click on link button for adding more file upload then this add only 1 .. means 1 file upload which is already visible and 1 which is display on clicking on linkbutton ..
but when i click again on linkbutton for adding more then this not display ..
i try this
ok i do this
<form id="form1" runat="server">

    <asp:FileUpload ID="FileUpload1" runat="server" />
    <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">upload</asp:LinkButton>

    <asp:Panel ID="Panel1" runat="server"></asp:Panel>
    <asp:Button ID="Button1" runat="server" Text="submit"  OnClick="Button1_Click" />
 </form>

suppose there is file upload control.. when we select file by clicking on browse and then click on upload then file name with extension i.e. abc.doc should be display  ... then when we use again same file upload and click on browse and select another file then file will be display i.e. xyz.pdf.. so there is two files  abc.doc and xyz.doc .. so this is want to do .. i want to upload files and display these uploaded files
UPDATE
for this i try this
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        fileuploadd(FileUpload1.FileName);

    }

    public void fileuploadd(string filename)
    {
        try
        {
            HttpFileCollection hfc = Request.Files;
            for (int i = 0; i < hfc.Count; i++)
            {
                HttpPostedFile hpf = hfc[i];
                if (hpf.ContentLength > 0)
                {

                    SMSEntities s = new SMSEntities();
                    uploaded_file u = new uploaded_file();
                    {
                        u.fileupload = filename;

                    }
                    s.uploaded_file.Add(u);
                    s.SaveChanges();
                }
                //hpf.SaveAs(Server.MapPath("upload") + "\\" + System.IO.Path.GetFileName(hpf.FileName));
                Response.Write("File: " + hpf.FileName + " Size: " + hpf.ContentLength + " Type: " + hpf.ContentType + " Uploaded Successfully
");

            }

        }
        catch (DbEntityValidationException e)
        {
            foreach (var eve in e.EntityValidationErrors)
            {
                Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                    eve.Entry.Entity.GetType().Name, eve.Entry.State);
                foreach (var ve in eve.ValidationErrors)
                {
                    Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                       ve.PropertyName, ve.ErrorMessage);
               }
            }
            throw;
        }

    }

so when i select file and click on upload then file name is display .. but when i select again file and click on upload then 1st file name is disappear and 2nd file name is display where as i want both ..
so how i display both filenames ... and when click on submit then record files should be inserted in tables individually i am done with this but not with both filename display at a time ..

A: Create a FileUpload Control on your .aspx like:
<asp:FileUpload runat="server" ID="UploadImages" AllowMultiple="true" />

then in your code behind:
protected void uploadFile_Click(object sender, EventArgs e)
{
   if (UploadImages.HasFiles)
   {
       foreach (HttpPostedFile uploadedFile in UploadImages.PostedFiles)
       {
           uploadedFile.SaveAs(System.IO.Path.Combine(Server.MapPath("~/Images/"),
           uploadedFile.FileName)); listofuploadedfiles.Text += String.Format("{0}
", uploadedFile.FileName);
       }
   }
}

A: Multiple File Upload
HI Super User Previously I also had same Problem.
What i Actually did was I have Created 5 File Control's For Example

1) FileUpload1
2) FileUpload2
3) FileUpload3
4) FileUpload4
5) FileUpload5
 And I have 4 of them as Hidden on load.
On click of 1 st I am showing 2nd One and on click of 2nd I am showing the 3rd one and So on...
In the Controller/Method I am checking if the File Control is not null then proceeding with the normal File Upload Process By taking Array of File Uploads.

    <asp:FileUpload ID="flOtherUPL" runat="server" />

     <input style="width: 20px; border: 0px none; background-color:transparent;" id="btnOtherAddMoreFiles" type="button"     onclick="AddOtherMoreImages();" class="icon-plus-sign" />|
   <asp:LinkButton ID="lnkOtherUpload" OnCommand="btnLnk_UploadOtherFiles" CommandArgument='<%# Eval("ID")   %>   'runat="server">Upload Files</asp:LinkButton>

protected void btnLnk_UploadOtherFiles(object sender, CommandEventArgs e)
    {

    int ID;

    try
    {
        if (!String.IsNullOrEmpty(Convert.ToString(e.CommandArgument)))
        {
            ID = Convert.ToInt32(e.CommandArgument);

            HttpFileCollection hfc = Request.Files;
            for (int i = 0; i < hfc.Count; i++)
            {
                HttpPostedFile hpf = hfc[i];
                if (hpf.ContentLength > 0)
                {
                    string fileExtension = System.IO.Path.GetExtension(hpf.FileName);
                    if (ValidExtesion(fileExtension))
                    {
                        int MaxSizeAllowed = Convert.ToInt32(ConfigurationManager.AppSettings["MaxFileSize"]);
                        if (hpf.ContentLength < MaxSizeAllowed)
                        {
                            int lastIndex = Convert.ToInt32(hpf.FileName.LastIndexOf("\\"));
                            string FileName = DateTime.Now.Millisecond + hpf.FileName.Substring(lastIndex + 1);
                            string FileName1 = hpf.FileName.Substring(lastIndex + 1);
                            FileName = FileName.Replace(" ", "");

                            StringBuilder AncTag = new StringBuilder();
                            AncTag = AncTag.Append("'" + FileName1 + "' ");
                            string strAncTag = AncTag.ToString();
                            strAncTag = strAncTag.Replace("'", "");
                            hpf.SaveAs(AppDomain.CurrentDomain.BaseDirectory + "Attachments/AMT/" + FileName);
                            obj.UploadOtherFiles_ProblemDescription(ID, strAncTag);
                        }
                        else
                        {

                        }
                    }
                    else
                    {

                    }
                }
            }

        }
    }
    catch (Exception ex)
    {
        ErrorLog objER = new ErrorLog(ex);
    }
    finally
    {

        obj = null;
        grdPDC.EditIndex = -1;

    }

}


text:
Q: Is it possible to use PostgreSQL anonymous block (PL/pgSQL) within the @Query annotation of Spring Data JPA Repository? I need to call an anonymous block with parameters.
@Repository
public interface FinAccountRepository extends JpaRepository<FinAccount, Long> {

    @Modifying
    @Query(nativeQuery = true, value =
            "DO $$ <<credit_account>>\n" +
            "DECLARE\n" +
            "    nNewBalance numeric(19,2);\n" +
            "    nNewId bigint;\n" +
            "BEGIN\n" +
            "    update fin_account set balance = balance + :amount where id = :account\n" +
            "    returning balance into nNewBalance;\n" +
            "    select nextval('seq_fin_account_def_id') into nNewId;\n" +
            "    insert into fin_account_definition(id, account, transaction, balance)\n" +
            "    values (nNewId, :account, :tx, nNewBalance); \n" +
            "END credit_account $$;")
    void credit(@Param("tx") UUID tx, @Param("account") Long account, @Param("amount") BigDecimal amount);

}

The following code throws errors
org.springframework.dao.DataIntegrityViolationException: could not execute native bulk manipulation query; SQL [DO $$
DECLARE
    nNewBalance numeric(19,2);
BEGIN
    update fin_account set balance = balance - :amount where id = :account
    returning fa.balance into nNewBalance;
    insert into fin_account_definition(id, account, transaction, balance)
    values (nextval('seq_fin_account_def_id'), :account, :tx, nNewBalance);
END $$;]; nested exception is org.hibernate.exception.DataException: could not execute native bulk manipulation query

. . .

Caused by: org.hibernate.exception.DataException: could not execute native bulk manipulation query

. . .

Caused by: org.postgresql.util.PSQLException: The column index is out of range: 1, number of columns: 0.
    at org.postgresql.core.v3.SimpleParameterList.bind(SimpleParameterList.java:69) ~[postgresql-42.2.24.jar:42.2.24]
    at org.postgresql.core.v3.SimpleParameterList.setLiteralParameter(SimpleParameterList.java:128) ~[postgresql-42.2.24.jar:42.2.24]
    at org.postgresql.jdbc.PgPreparedStatement.bindLiteral(PgPreparedStatement.java:1042) ~[postgresql-42.2.24.jar:42.2.24]
    at org.postgresql.jdbc.PgPreparedStatement.setNumber(PgPreparedStatement.java:520) ~[postgresql-42.2.24.jar:42.2.24]
    at org.postgresql.jdbc.PgPreparedStatement.setBigDecimal(PgPreparedStatement.java:337) ~[postgresql-42.2.24.jar:42.2.24]
    at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.setBigDecimal(HikariProxyPreparedStatement.java) ~[HikariCP-4.0.3.jar:na]
    at org.hibernate.type.descriptor.sql.DecimalTypeDescriptor$1.doBind(DecimalTypeDescriptor.java:47) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
    at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:73) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
    at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:276) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
    at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:271) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
    at org.hibernate.loader.custom.sql.NamedParamBinder.bind(NamedParamBinder.java:34) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
    at org.hibernate.engine.query.spi.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:102) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
    ... 160 common frames omitted

Also i tried to use ordinal parameters - the result is the same.
However, an anonymous block without bind parameters is called correctly.
I am interested in the ability to pass parameters to an postgresql anonymous block from method of Spring Data JPA Repository.

A: You don't need PL/pgSQL for this. This can be done in a single SQL statement:
with changed_account as (
   update fin_account
      set balance = balance + :amount
   where id = :account
   returning balance, id
)
insert into fin_account_definition(id, account, transaction, balance)
select nextval('seq_fin_account_def_id'), c.id, :tx, c.balance
from changed_account c;


text:
Q: When did the Millenarian's incantations start [spoilers]? Massive Spoiler Warning: The question discusses events very near the end of Neal Stephenson's Anathem.
When Cell 317 was up in space floating with the Cold Black Mirror, several members discussed having dreams that didn't feel like dreams, ie. were vey hard to distinguish from reality. During a conversation someone (I think it was Arsibalt or Jesry) mentions he's not sure if this is not a dream. Sammann even expresses surprise in that he "wakes up" to find the transmitter still working, although he clearly "remembered" destroying it.
This, along with the Millenarian's general indiference, leads me to believe that he had in fact started his Incantations from the very beginning of the launch - possibly even from the beginning of the Convox, and that the dream-states were the alternative Narratives the Millenarian was taking them through. We can only guess at what the Incanters were up to when secluded in their math, but during the Convox we have the following clues:

*

*Fraa Jad is up all night at the Bazian monastery, chanting. This may be a way to just pass the time, it could also be that Erasmas was witnessing an Incantation.

*When Jad spoke of the "Hooded Ones", referring to the hijacked Matarrhite peregrin, he gave us the hint that they weren't actually Matarrhites. This he could have inferred by observing flaws in their behaviour, like the ones Arsibalt pointed out when he confronted Vernes, or he simply visited some Narrative where their identity had been made known. The Steelyard makes me root for the former, but I can't completly dismiss the latter either.

*The Teglon and the keypad. Again the Steelyard tells us that a Millenarian might have solved the puzzle (although many Millenarians had failed), or he could have made himself into a distributed syndev, brute-forcing the problem through many Narratives. But would he start an Incantation just for fun? Well he's an eccentric old Grandfraa, he might as well act like one.
During the Keypad narrative Fraa Jad tells Erasmas that

I am in several [Narratives], a state of affairs that is not easy to sustain

which leads me to believe he wasn't solving the Teglon just for the fun of it; he was practising.
In any case there must be clues that I've missed and I don't have the energy to go back to the massive book now that I've finished it. So my question is, as the title states, when did Fraa Jad start his Incantations, and how did he affect his Peregrin?

A: Technically, the millenarians use incantation all the time, to weed out pre-cancerous cells. They investigate a multitude of possible narratives, then collapse the quantum wave to a preferred choice. Of course, those small changes (or even the Teglon) only affected a single person, the incanter. You're referring to Jad's much larger polycosmic manipulation, which encompassed the actions of the entire Cell 317 for an extended period of time.
I believe that incantation (or at least its inclusion of other people) started upon reaching orbit. Arsibalt's rescue maneuvers were clearly incanted, marking the latest possible starting point. But incantation seems to require limiting the amount of external observation; I believe superposition could not begin until the launch telemetry ended. Jad smashing the radio to reduce information leakage is key evidence for this view.

A: I think that @foo-bar makes an excellent point about how the launch coincides with a narrowing of the observation window, which means that's when incantation started getting serious.  But let's remember that Fraa Jad is just the tip of the spear.  As Erasmas wonders while floating alone with the nuke:

Where were all of the Thousanders now?  Gathered in a stadium, chanting?

I think it's fair to say that the worldtrack changes were the result of more than just Fraa Jad:

"The practical consequence for me is continuing and ever more effective cooperation between the tendencies known to the vulgar as Rhetors and Incanters," Lodoghir said.  "Procians and Halikaarnians have worked together in the recent past, as you know, with results that have been profoundly startling to those few who are aware of them."  He was staring directly into my eyes as he said this.  I knew he was talking about the rerouting of worldtracks that, among other things, had placed Fra Jaad at the Daban Urnud at the same time as his death was recorded above Arbre."

There's really not enough description on the text to suggest exactly what's involved in Incanting, or who, or when.  Fraa Jad was chanting as he and Erasmas traverse the ship, but Fraa Jad's not actively chanting when he punches the keys into the keypad(s).  It's kind of like Iron Eagle; the chanting helps, but the skill lies underneath.

A: I have been of the opinion that the Millenarians are actually working hard throughout the entire story to affect Erasmas and his journey. I feel like a lot of the chapter endings, cliffhangers, and lucky escapes are the result of Erasmas being guided away from calamity, especially considering how often Jad is mentioned as doing something idly in the background.

A: When the cell formed and they took the plane to the launch site, there was a line about how Jad's chanting was barely audible over the plane noises.  I took that to mean he was ensuring they stayed on a world track where the plane didn't go down.


text:
Q: What am I missing in this use of fgets? If I run the below code with scanf, it returns a string if it's in the tracks array. According to the book Head First C, this should work with fgets but returns nothing for me:
#include <stdio.h>
#include <string.h>

#define MAX 80

char tracks[][MAX] = {
    "The Girl from Ipanema",
    "Here Comes the Sun",
    "Wonderwall",
    "You Belong To Me",
    "Everlong",
};

void find_track(char search_for[])
{
    int i = 0;
    for(i = 0; i < 5; i++) {
        if(strstr(tracks[i], search_for)) {
            printf("Track %d: %s\n", i, tracks[i]);
        }
    }
}

int main()
{
    char search_for[MAX];
    printf("Search for: ");
    //scanf("%79s", search_for);
    fgets(search_for, MAX, stdin);
    find_track(search_for);
    return 0;
}

Input looks like the following:
./tracks
Search for:
Here

Nothing happens

A: It's probably because fgets will also read the newline, i.e. '\n'. In more details:
If you type Girl<enter> then search_forwill contain the characters:  'G' 'i' 'r' 'l'
 '\n' However, your tracks only contain 'G' 'i' 'r' 'l' without the '\n'.
Consequently you will not find a matching substring.
Try changing:
fgets(search_for, MAX, stdin);

into
fgets(search_for, MAX, stdin);
if (strlen(search_for) > 0) search_for[strlen(search_for)-1] = '\0';

to remove the trailing newline
Edit based on comments
It's true that (depending on your OS/environment) the input stream can be terminated without a newline (ctrl-z, ctrl-d on some systems). If that is done the above code is insufficient. It needs an extra check like:
if (strlen(search_for) > 0 && search_for[strlen(search_for)-1] == '\n')
    search_for[strlen(search_for)-1] = '\0';

to make sure that only a "newline" is converted to a string termination.

A: You may also use function memcpy to get rid of newline.
The C library function void *memcpy(void *str1, const void *str2, size_t n) copies n characters from memory area str2 to memory area str1.
fgets(s, MAX, stdin);
memcpy(search_for, s, strlen(s)-1);
find_track(search_for);

You may add some error handling too.


text:
Q: Infinite abelian group whose all nontrivial subroups have finite index D.J.S. Robinson, A Course in the Theory of Groups, 2d edition, exercise 4.1.3, p. 98, asks for a proof of the following statement :
Statement 1. If $G$ is an infinite abelian group all of whose proper quotient groups (I understand : quotients by nonzero subgroups) are finite, then $G$ is (infinite) cyclic.
I can prove it, but only by use of the following theorem, which is proved later in the book (4.2.10, p. 103) :
Statement 2. If an abelian group is finitely generated, it is a direct sum of finitely many cyclic (finite or infinite) subgroups.
(I give a proof of Statement 1 by Statement 2 below.) My question is:

Is it possible to prove Statement 1 without using Statement 2 in a more or less explicit manner?

Thanks in advance for the answers.
Here is my proof of Statement 1 by use of Statement 2.
Let $G$ be as in Statement 1. Note it additively. For every nonzero element $x$ of $G$, $\mathbb{Z}x$ is a nontrivial subgroup of $G$, thus, by hypothesis,
(1) the quotient $G/ \mathbb{Z}x$ is finite.
Thus, since $G$ is infinite by hypothesis, $\mathbb{Z}x$ is infinite. Since this is true for every nonzero element $x$ of $G$,
(2) $G$ is torsion-free.
Choose a nonzero element $x$ of $G$ (it is possible, since $G$ is infinite by hypothesis). By (1), there exists a finite set $\{a_{1}, \ldots , a_{n} \}$ of elements of $G$ such that $a_{1} + \mathbb{Z}x, \ldots , a_{n} + \mathbb{Z}x$ are all the elements of $G/ \mathbb{Z}x$. Thus $G$ is generated by $x, a_{1}, \ldots, a_{n}$, thus $G$ is finitely generated, thus, by Statement 2,
(3) $G$ is a direct sum $H_{1} \oplus \cdots \oplus H_{k}$ of finitely many nontrivial cyclic subgroups.
Since $G$ is nontrivial, we have $k \geq 1$.
By (2), $G$ is torsion-free, thus every $H_{i}$ is torsion-free. Thus, since $H_{i}$ is nontrivial,
(4) every $H_{i}$ is infinite.
Since $H_{1}$ is not trivial, $G / H_{1}$ is finite (by hypothesis of the exercice). But, by (3), $G / H_{1}$ is isomorphic to $H_{2} \oplus \cdots \oplus H_{k}$, thus $H_{2} \oplus \cdots \oplus H_{k}$ is finite. Thus, in view of (4), $k = 1$, thus, by (3), $G = H_{1}$ . Thus, by (3), $G$ is (infinite) cyclic and we are done.
Edit (January 15, 2022). If I am not wrong, the proof of satement 1 can easily be extracted from Robinson's proof of statement 2. Let $G$ be as in statement 1. As noted, $G$ is torsion-free. Since $G$ is infinite, we can choose a nonzero element $a$ of $G$. Then $<a>$ is a nontrivial subgroup of $G$, thus, by hypothesis, $<a>$ is of finite index $m > 0$ in $G$. Then $x \mapsto mx$ defines a homomorphism from $G$ to $<a>$. Since $G$ is torsion-free, this homomorphism is injective, thus $G$ is isomorphic to a subgroup of $<a>$, thus $G$ is cyclic.

A: Let $x \in G$ be such that $G/\mathbb{Z}x$ has minimal order among all quotients of the form $G/\mathbb{Z}g$, $0 \neq g \in G$. We claim that $G = \mathbb{Z}x$.
If this were not the case, then there would exist $y \in G - \mathbb{Z}x$ and $y + \mathbb{Z}x$ has finite order $n > 1$. We then have $ny = m x$ for some $m \in \mathbb{Z}$ and $n$ and $m$ are coprime (since $n$ is minimal with $ny \in \mathbb{Z}x$). We can thus write $1 = m a + n b $ for some $a,b \in \mathbb{Z}$. Let us set $z = ay + bx$, then we have $z \in G - \mathbb{Z}x$ (since $a$ and $n$ are coprime) and
$$n z =  n (ay + bx)= a n y + b n x =  (m a  + n b) x = x $$
so that $\mathbb{Z}x \subseteq \mathbb{Z}z$. Actually this is proper containment, as $z \in G - \mathbb{Z}x$. It follows that $G/\mathbb{Z}z$ has smaller order than $G/\mathbb{Z}x$ which is a contradiction to our choice of $x$. It follows that $G = \mathbb{Z}x$ and we are done.

A: Suppose $G$ is non-cyclic. Lets find a contradiction.
As you have pointed out, $G$ contains an infinite cyclic subgroup of finite index. Let's call one such subgroup $Z$, and write $n$ for its index.
As $G$ is non-cyclic but contains a cyclic subgroup of finite index, there exist elements $x, y\in G$ such that the subgroup $\langle x, y\rangle$ (i.e. the minimal subgroup of $G$ containing $x$ and $y$) is non-cyclic. As $x^n, y^n\in Z$, we have that $x$ and $y$ have a common power, so write $x^p=y^q$. By replacing $x$ with $x^{-1}$ or $y$ with $y^{-1}$, we may assume $p, q>0$. Write $z:=xy$. If $p\geq q$ then consider the subgroup $\langle x, z\rangle$. Otherwise, consider the subgroup $\langle z, y\rangle$. Both subgroups are infact equal to $H$, but we now have $x^{p-q}=z^q$ if $p\geq q$, or $z^p=y^{q-p}$ if $q>p$. Now repeat this process, with $(x, z)$ or $(z, y)$ in place of $(x,y)$, until one of the exponents is $0$ (as we have reduced the size of the exponents, this will necessarily happen) - the other one will not be $0$, so we have $H=\langle x_k, y_k\rangle$ with either $x_k^{p_k}=1$, $p_k>1$, or $y_k^{q_k}=1$, $q_k>1$. It follows that $H=\langle x, y\rangle$ contains a non-trivial element of finite order, which is our required contradiction.

A: Here's an answer for arbitrary modules over commutative rings $A$: an $A$-module $M$ is a just-(infinite length) $A$-module ($M$ is has infinite length, every proper quotient of $M$ is has infinite length) if and only if, $I$ denoting the annihilator of $M$, $A/I$ is a Krull noetherian domain of dimension 1 and $M$ is isomorphic to a nonzero ideal of $A/I$.
Proof: first the assumption implies that $M$ is noetherian. It follows that $A/I$ is noetherian.
To conclude, we can suppose that $A$ is noetherian and $M$ is a faithful $A$-module. The assumption implies that $M$ does not contain the direct sum of two nonzero modules. Hence $M$ has a single associated ideal, say $P$. This applies to any nonzero cyclic submodule of $M$. Hence any nonzero $m\in M$ has a an annihilator contained in $P$. If by contradiction some $m\in M$ as annihilator strictly contained in $M$, then $Pm$ is a nonzero submodule of infinite index, contradiction. So every nonzero $m\in M$ has annihilator $P$. Hence $P=0$ and $M$ is isomorphic to a submodule of the field of fractions of $A=A/P$, thus, since it is finitely generated, is isomorphic to an ideal of $A$.
Conversely, any nonzero ideal in a noetherian domain of Krull dimension 1 satisfies the condition.
If now $M$ is just-infinite ($M$ is infinite and every proper quotient of $M$ is finite), then $M$ is also just-(infinite length), so has the required form: ideal $J/I$ in $A/P$ with $A/P$ noetherian domain of Krull dimension 1. Then for such a module, just-infinite is equivalent to every residual field $A/M$ of $A/P$ being finite. Indeed, we can suppose $P=0$. The condition is sufficient. Conversely, if $M$ is a maximal ideal, then $MJ\neq J$ by Nakayama's lemma, and we see that $J/MJ$ is an infinite proper quotient of $J$.


text:
Q: C# equivalent of DllMain in C (WinAPI) I have an older app (ca. 2005) which accepts dll plugins. The app was originally designed for Win32 C plugins, but I have a working C# dll template. My problem: I need to do some one-time initialization, which in a Win32 C dll would be done in DllMain:
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
  [one-time stuff here...]
}

Is there a C# equivalent of this? There is no "DllMain" in the C# template I have. I tried a literal C# interpretation, but no go: the dll works but it won't trigger the DllMain function.
public static bool DllMain(int hModule, int reason, IntPtr lpReserved) {
  [one time stuff here...]
}

A: Also not easy to do from C# you can have a per module initializers

Modules may contain special methods called module initializers to initialize the module itself.
  All modules may have a module initializer.  This method shall be static, a member of the module, take no parameters, return no value, be marked with rtspecialname and specialname, and be named .cctor.
  There are no limitations on what code is permitted in a module initializer.  Module initializers are permitted to run and call both managed and unmanaged code.

A: Even though C# doesn't directly support module initialization we can implement it using reflection and static constructors.  To do this we can define a custom attribute and use it find classes that need to be initialized on module loading:
public class InitOnLoadAttribute : Attribute {}

private void InitAssembly(Assembly assembly)
{
    foreach (var type in GetLoadOnInitTypes(assembly)){
        var prop = type.GetProperty("loaded", BindingFlags.Static | BindingFlags.NonPublic); //note that this only exists by convention
        if(prop != null){
            prop.GetValue(null, null); //causes the static ctor to be called if it hasn't already
        }
    }
 }

static IEnumerable<Type> GetLoadOnInitTypes(Assembly assembly)
{
    foreach (Type type in assembly.GetTypes())
    {
        if (type.GetCustomAttributes(typeof(InitOnLoadAttribute), true).Length > 0){
            yield return type;
        }
    }
}

public MyMainClass()
{
    //init newly loaded assemblies
    AppDomain.CurrentDomain.AssemblyLoad += (s, o) => InitAssembly(o.LoadedAssembly);
    //and all the ones we currently have loaded
    foreach(var assembly in AppDomain.CurrentDomain.GetAssemblies()){
        InitAssembly(assembly);
    }
}

on classes that we need to initialize immediately we add that code to their static constructor (which will be run once even if the property getter is accessed multiple times) and add the custom attribute we added to expose this functionality.
[InitOnLoad]
class foo
{
    private static bool loaded { get { return true; } }
    static foo()
    {
        int i = 42;
    }
}

A: Give your class a static constructor and do your initialization there. It will run the first time anybody calls a static method or property of your class or constructs an instance of your class.

A: I've had to interact with a legacy application probably in the same situation as you have. I've found a hacky way to get DllMain functionality in a CLR assembly. Luckily it isn't too hard. It requires an additional DLL but it doesn't require you to deploy an additional DLL so you can still have the "put a DLL in that directory and the app will load it" paradigm.
First, you make a simple regular C++ DLL that looks like the following:
dllmain.cpp:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "resource.h"
extern void LaunchDll(
  unsigned char *dll, size_t dllLength,
  char const *className, char const *methodName);
static DWORD WINAPI launcher(void* h)
{
    HRSRC res = ::FindResourceA(static_cast<HMODULE>(h),
                   MAKEINTRESOURCEA(IDR_DLLENCLOSED), "DLL");
    if (res)
    {
        HGLOBAL dat = ::LoadResource(static_cast<HMODULE>(h), res);
        if (dat)
        {
            unsigned char *dll =
                static_cast<unsigned char*>(::LockResource(dat));
            if (dll)
            {
                size_t len = SizeofResource(static_cast<HMODULE>(h), res);
                LaunchDll(dll, len, "MyNamespace.MyClass", "DllMain");
            }
        }
    }
    return 0;
}
extern "C" BOOL APIENTRY DllMain(HMODULE h, DWORD reasonForCall, void* resv)
{
    if (reasonForCall == DLL_PROCESS_ATTACH)
    {
        CreateThread(0, 0, launcher, h, 0, 0);
    }
    return TRUE;
}

Note the thread creation. This is to keep Windows happy because calling managed code within a DLL entrypoint is a no-no.
Next, you have to create that LaunchDll function the code above references. This goes in a separate file because it will be compiled as a managed C++ unit of code. To do this, first create the .cpp file (I called it LaunchDll.cpp). Then right click on that file in your project and in Configuration Properties-->C/C++-->General change the Common Language RunTime Support entry to Common Language RunTime Support (/clr). You can't have exceptions, minimal rebuild, runtime checks and probably some other things I forgot about but the compiler will tell you about. When the compiler complains, track down what settings you much change from the default and change them on the LaunchDll.cpp file only.
LaunchDll.cpp:
#using <mscorlib.dll>
// Load a managed DLL from a byte array and call a static method in the DLL.
// dll - the byte array containing the DLL
// dllLength - the length of 'dll'
// className - the name of the class with a static method to call.
// methodName - the static method to call. Must expect no parameters.
void LaunchDll(
    unsigned char *dll, size_t dllLength,
    char const *className, char const *methodName)
{
    // convert passed in parameter to managed values
    cli::array<unsigned char>^ mdll = gcnew cli::array<unsigned char>(dllLength);
    System::Runtime::InteropServices::Marshal::Copy(
        (System::IntPtr)dll, mdll, 0, mdll->Length);
    System::String^ cn =
        System::Runtime::InteropServices::Marshal::PtrToStringAnsi(
            (System::IntPtr)(char*)className);
    System::String^ mn =
        System::Runtime::InteropServices::Marshal::PtrToStringAnsi(
            (System::IntPtr)(char*)methodName);

    // used the converted parameters to load the DLL, find, and call the method.
    System::Reflection::Assembly^ a = System::Reflection::Assembly::Load(mdll);
    a->GetType(cn)->GetMethod(mn)->Invoke(nullptr, nullptr);
}

Now for the really tricky part. You probably noticed the resource loading in dllmain.cpp:launcher(). What this does is retrieve a second DLL that has been inserted as a resource into the DLL getting created here. To do this, create a resource file by doing the
right click-->Add-->New Item-->Visual C++-->Resource-->Resource File (.rc) thing. Then, you need to make sure there is a line like:
resource.rc:
IDR_DLLENCLOSED DLL "C:\\Path\\to\\Inner.dll"

in the file. (Tricky, huh?)
The only thing left to do is to create that Inner.dll assembly. But, you already have it! This is what you were trying to launch with your legacy app in the first place. Just make sure to include a MyNamespace.MyClass class with a public void DllMain() method (of course you can call these functions whatever you want to, these are just the values hardcoded into dllmain.cpp:launcher() above.
So, in conclusion, the code above takes an existing managed DLL, inserts it into a resource of an unmanaged DLL which, upon getting attached to a process, will load the managed DLL from the resource and call a method in it.
Left as an exercise to the reader is better error checking, loading different DLLs for Debug and Release, etc. mode, calling the DllMain substitute with the same arguments passed to the real DllMain (the example only does it for DLL_PROCESS_ATTACH), and hardcoding other methods of the inner DLL in the outer DLL as pass through methods.


text:
Q: delete a column in the table I have the following table where I would want to delete the column $2 \neq \Box$ but had no luck as it keeps giving error when I compile it.
\documentclass{article}
\setlength{\textwidth}{16cm}
\setlength{\oddsidemargin}{0pt}
\setlength{\evensidemargin}{0pt}
\setlength{\parskip}{3mm}
\setlength{\parindent}{0mm}
\usepackage{amsmath}
\usepackage{amsthm}
\DeclareMathOperator{\lcm}{lcm}
\DeclareMathOperator{\ord}{ord}
\usepackage{tabularx,ragged2e,booktabs,caption}
\usepackage[figuresleft]{rotating}
\usepackage{rotating}
\newcolumntype{C}{>{\Centering\arraybackslash}X}
\newcommand\swb{{\scriptstyle\Box}} % "small white box"
\usepackage{amssymb,bm}
\usepackage{upgreek} %use uptau greek letter

\begin{document}
\begin{sidewaystable}
\setlength\tabcolsep{6pt} % default value: 6pt
\begin{tabularx}{\textwidth}{@{}*{14}{C}@{}}
\toprule
 $\delta_\mu$ & $2 \neq \swb$ & \multicolumn{4}{c}{$5 \cdot 29 \neq \swb$} & \multicolumn{4}{c}{$13 \cdot 1789 \neq \swb$} & \multicolumn{4}{c}{$5333 \cdot 97324757 \neq \swb$}\\
\cmidrule(lr){3-6} \cmidrule(l){7-10} \cmidrule(l){11-14}
    &   & $5=\swb$ & $29\neq\swb$ & $5\neq\swb$ & $29=\swb$ & $13=\swb$ & $1789\neq\swb$ & $13\neq\swb$ & $1789=\swb$ & $5333=\swb$ & $97324757\neq\swb$ & $5333\neq\swb$ & $97324757=\swb$ \\
\midrule
Primes that satisfy the \footnote{Refer Appendix A for the PARI code to find the complete list of $G_1, G_2, G_3, G_4, G_5, G_6$} condition $\delta_\mu \neq \swb$  &
$q\equiv\pm3\pmod{8}$ &
$q\equiv\pm1\pmod{5}$ &
$q\equiv 2,3,8,10,\allowbreak11,12,14,\allowbreak15,17,18,\allowbreak 19,21,26, \allowbreak 27\pmod{29}$ &
$q\equiv\pm2\pmod{5}$ &
$q\equiv 1,4,5,6,\allowbreak7,9,13,\allowbreak 16,20,\allowbreak 22,23,\allowbreak 24,25,28\pmod{29}$ &
$q\equiv 1,3,4,9,\allowbreak10,12\pmod{13}$ &
$q \equiv$ $G_1$ \text{(mod} \allowbreak $1789$) &
$q\equiv2,5,6,\allowbreak 7,8,11\pmod{13}$ &
$q \equiv$ $G_2$ \text{(mod} \allowbreak $1789$) &
$q \equiv$ $G_3$ \text{(mod} \allowbreak $5333$) &
$q \equiv$ $G_4$ \text{(mod} \allowbreak $97324757$) &
$q \equiv$ $G_5$ \text{(mod} \allowbreak $5333$) &
$q \equiv$ $G_6$ \text{(mod} \allowbreak $97324757$) \\
\midrule
 Period of $w_k$  & $24$ & $30$ & $102$ & $30$ & $102$ & $30$ & $2670$ & $30$ & $2670$ & $750$ & $97306362$ & $750$ & $97306362$ \\
\midrule
 $\ord(\widetilde{P})$  &  & $5$ & $17$ & $5$ & $17$ & $10$ & $890$ & $10$ & $890$ & $125$ & $48653181$ & $125$ & $48653181$ \\
\midrule
$k$ which satisfies $w_k$ \footnote{Refer Appendix B for the lists of sets $A_{2}$, $A_5$, $A_{29^*}$, $A_{5}^*$, $A_{29}$, $A_{13}$, $A_{1789}^*$, $A_{13}^*$, $A_{1789}$, $A_{5333}$, $A_{97324757}^*$, $A_{5333}^*$, $A_{97324757}$} &  $A_{2}$ : 10 elements & $A_5$ : 21 elements & $A_{29^*}$ : 37 elements & $A_{5}^*$ : 9 elements & $A_{29}$ : 65 elements & $A_{13}$ : 22 elements & $A_{1789}^*$ : 1304 elements & $A_{13}^*$ : 8 elements & $A_{1789}$ : 1362 elements & $A_{5333}$ : 421 elements & $A_{97324757}^*$ : 48584207 elements & $A_{5333}^*$ : 329 elements & $A_{97324757}$ : 48722155 elements\\
\bottomrule
\end{tabularx}\captionof{table}{Summary of the congruence conditions for $\mu \in Y = \{-4, -3, -2, -1, 0, 3\}$} \label{summary}
\end{sidewaystable}
\end{document}

A: \documentclass{article}
\setlength{\textwidth}{16cm}
\setlength{\oddsidemargin}{0pt}
\setlength{\evensidemargin}{0pt}
\setlength{\parskip}{3mm}
\setlength{\parindent}{0mm}
\usepackage{amsmath}
\usepackage{amsthm}
\DeclareMathOperator{\lcm}{lcm}
\DeclareMathOperator{\ord}{ord}
\usepackage{tabularx,ragged2e,booktabs,caption}
\usepackage[figuresleft]{rotating}
\usepackage{rotating}
\newcolumntype{C}{>{\Centering\arraybackslash}X}
\newcommand\swb{{\scriptstyle\Box}} % "small white box"
\usepackage{amssymb,bm}
\usepackage{upgreek} %use uptau greek letter

\begin{document}

\begin{sidewaystable}
    \setlength\tabcolsep{6pt} % default value: 6pt
    \begin{tabularx}{\textwidth}{@{}*{13}{C}@{}}
        \toprule
        $\delta_\mu$ & \multicolumn{4}{c}{$5 \cdot 29 \neq \swb$} & \multicolumn{4}{c}{$13 \cdot 1789 \neq \swb$} & \multicolumn{4}{c}{$5333 \cdot 97324757 \neq \swb$}\\
        \cmidrule(lr){3-6} \cmidrule(l){7-10} \cmidrule(l){11-13}
        &    $5=\swb$ & $29\neq\swb$ & $5\neq\swb$ & $29=\swb$ & $13=\swb$ & $1789\neq\swb$ & $13\neq\swb$ & $1789=\swb$ & $5333=\swb$ & $97324757\neq\swb$ & $5333\neq\swb$ & $97324757=\swb$ \\
        \midrule
        Primes that satisfy the \footnote{Refer Appendix A for the PARI code to find the complete list of $G_1, G_2, G_3, G_4, G_5, G_6$} condition $\delta_\mu \neq \swb$  &
        $q\equiv\pm1\pmod{5}$ &
        $q\equiv 2,3,8,10,\allowbreak11,12,14,\allowbreak15,17,18,\allowbreak 19,21,26, \allowbreak 27\pmod{29}$ &
        $q\equiv\pm2\pmod{5}$ &
        $q\equiv 1,4,5,6,\allowbreak7,9,13,\allowbreak 16,20,\allowbreak 22,23,\allowbreak 24,25,28\pmod{29}$ &
        $q\equiv 1,3,4,9,\allowbreak10,12\pmod{13}$ &
        $q \equiv$ $G_1$ \text{(mod} \allowbreak $1789$) &
        $q\equiv2,5,6,\allowbreak 7,8,11\pmod{13}$ &
        $q \equiv$ $G_2$ \text{(mod} \allowbreak $1789$) &
        $q \equiv$ $G_3$ \text{(mod} \allowbreak $5333$) &
        $q \equiv$ $G_4$ \text{(mod} \allowbreak $97324757$) &
        $q \equiv$ $G_5$ \text{(mod} \allowbreak $5333$) &
        $q \equiv$ $G_6$ \text{(mod} \allowbreak $97324757$) \\
        \midrule
        Period of $w_k$  &  $30$ & $102$ & $30$ & $102$ & $30$ & $2670$ & $30$ & $2670$ & $750$ & $97306362$ & $750$ & $97306362$ \\
        \midrule
        $\ord(\widetilde{P})$    & $5$ & $17$ & $5$ & $17$ & $10$ & $890$ & $10$ & $890$ & $125$ & $48653181$ & $125$ & $48653181$ \\
        \midrule
        $k$ which satisfies $w_k$ \footnote{Refer Appendix B for the lists of sets $A_{2}$, $A_5$, $A_{29^*}$, $A_{5}^*$, $A_{29}$, $A_{13}$, $A_{1789}^*$, $A_{13}^*$, $A_{1789}$, $A_{5333}$, $A_{97324757}^*$, $A_{5333}^*$, $A_{97324757}$} & $A_5$ : 21 elements & $A_{29^*}$ : 37 elements & $A_{5}^*$ : 9 elements & $A_{29}$ : 65 elements & $A_{13}$ : 22 elements & $A_{1789}^*$ : 1304 elements & $A_{13}^*$ : 8 elements & $A_{1789}$ : 1362 elements & $A_{5333}$ : 421 elements & $A_{97324757}^*$ : 48584207 elements & $A_{5333}^*$ : 329 elements & $A_{97324757}$ : 48722155 elements\\
        \bottomrule
    \end{tabularx}\captionof{table}{Summary of the congruence conditions for $\mu \in Y = \{-4, -3, -2, -1, 0, 3\}$} \label{summary}
\end{sidewaystable}

\end{document}


text:
Q: How to set an initial value to daterangepicker? I have a DateRangePicker as follows:
HTTP:
<input id="date" name="date" ng-model="FilesDate" class="form-control"/>

JQuery:
$('input[name="date"]').daterangepicker({
        opens: 'left'
 });

The DateRangePicker works totally fine but when the program initializes, its empty by default. If I remove ng-model, the date initializes properly.

A: Just set the value of your input:
<input value="01/01/2018 - 01/15/2018" id="date" name="date" ng-model="FilesDate" class="form-control" />

http://www.daterangepicker.com/#examples

A: $('input[name="date"]').attr('value', '01/01/2018 - 01/15/2018');


text:
Q: How to move gcc debug symbols outside from .so and .a files? as far as I know, objcopy is able to move debug symbols (compiled with -g flag) outside from an executable binary. I found this question, but there are only generic methods for symbol outsourcing.
But what can I do when my executable is using some really large .so and .a files?
I would like to profile my application in a small environment where is not enough place for the debug symbols. The entire project was built with -g option. The debug symbols are needed later only when the profile log is processed.

A: You can strip debug symbols:
strip --strip-debug object.so


text:
Q: When is it useful for an associated constant to use a lifetime other than 'static? RFC 1623, stabilized in Rust 1.17.0, made it so that we do not have to explicitly specify the 'static lifetime in a static or const:
const MY_DEFAULT_NAME: &str = "Anna";
//                      ^ Look, ma! No 'static!

RFC 195 defined associated constants, which were stabilized in Rust 1.20.0:
struct A;

impl A {
    const B: i32 = 42;
}

When trying to combine these two, an error is raised:
struct A;

impl A {
    const MY_DEFAULT_NAME: &str = "Anna";
}

error[E0106]: missing lifetime specifier
 --> src/main.rs:4:28
  |
4 |     const MY_DEFAULT_NAME: &str = "Anna";
  |                            ^ expected lifetime parameter

The related GitHub issue #38831 has a comment:

We decided against it because, in that case, there might be other
  lifetimes you would want. For example:
trait Foo<'a> {
    const T: &'a str;
}

that said, revisiting this explanation, it feel a bit weak, since the
  value of an associated constant would still have to be all consisting
  of static data. So it seems like 'static is a pretty good default if
  you don't say otherwise.

What is an example of an associated constant with a non-'static lifetime? What benefit does providing a non-'static lifetime bring?

A: One might consider a constant that is a function:
trait Foo<'a> {
    const BAR: fn(&Self) -> &'a str;
}

struct MyFoo<'a> {
    x: &'a str,
}

impl<'a> Foo<'a> for MyFoo<'a> {
    const BAR: fn(&Self) -> &'a str = my_bar;
}

fn my_bar<'a>(a: &MyFoo<'a>) -> &'a str {
    &a.x
}

Right now, I can't think of how this would be more beneficial than a method.