text:
Q: how to move JButton to specific position this is a very easy code because I  just started learning java.
how do I move the button to specific position/points. Please be brief and make your answer simple and easy to understand because I just started learning java.
this is my code:
            import javax.swing.*;
            import java.awt.*;
            import java.awt.event.*;
            public class finals extends JFrame implements ActionListener{
                JButton login = new JButton("Log-In");
                JButton enroll = new JButton("Enroll");
                JPanel con = new JPanel();
                JFrame frame = new JFrame();
                public finals(){
                    frame.setTitle("Enrollment");
                    setContentPane(con);
                    setLayout(new FlowLayout());
                    login.setLocation(122, 120);
                    con.add(login);
                    System.out.println(login.getLocation());
                    frame.add(con);

                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setSize(300,150);
                    frame.setVisible(true);
                }
                public void actionPerformed(ActionEvent e){

                }
                public static void main(String Args[]){
                    new finals();
                }
            }

A:
make your answer simple and easy to understand

Don't attempt to specify a pixel location of a component! What is so special about (122, 12)? Nothing, its just a random number you picked.
Let the layout manager do its job. For example you can use a FlowLayout and set the alignment to CENTER so the component is centered on the row.
Or if you don't like that you can use a BoxLayout, and add a "horizontal strut" to the panel to help control positioning.
Read the section from the Swing tutorial on Layout Managers for more information and working examples.

I just started learning java.

Don't forget to check out the Table of Contents from the above tutorial link for more basic information about creating GUI's.

A: You have to put your JPanel layout to "null".
Just add this : con.setLayout(null);


text: Q: Finite-dimensional representations of the Lie algebra of vector fields on a circle I have just began to study infinite-dimensional Lie algebras and I am curious whether the Lie algebra $L$ spanned by the vector fields $z^n \partial/\partial z$, $n=0,1,2,3,\dots$ admits any representations (not necessarily irreducible) by finite-dimensional matrices. In particular, the $sl(2)$ subalgebra of $L$ spanned by $z^n \partial/\partial z$, $n=0,1,2$ is well-known to admit infinitely many such representations, and I wonder whether any of those can be somehow extended to the representations of the whole $L$. Many thanks in advance!

redpajama_set_name: RedPajamaStackExchange


text:
Q: Is it possible to blink an LED with just a USB data cable and a transistor? Sorry if this is a dumb question, I am new to electronics and was looking at diagrams of USB cables and wondered,
"Could you use the low voltage data wires on a usb and a MOSFET or something to control the voltage from the higher voltage wires to make an LED blink on and off?"
I have been searching online and could not find much (maybe that's a bad sign) I have a cable that splits the 4 usb wires and connected them to a bread board and can turn on the LED with the +5V and -5V wires, but I'd like to know if I can use the other wires to control it?
Any advice is appreciated! Thank you

A: No, you can't do this. You need a chip of some sort to translate the USB commands into whatever you want to do. It could be an Arduino running your code, but there are also dedicated chips (like this one - note that I haven't tried this chip).
If you're trying to find parts to turn a plain wire on and off, the key word to search for is "GPIO" (stands for General Purpose Input/Output). I found the above chip by searching for "USB to GPIO".
It's not necessarily worthwhile though. In my experience, getting your computer to work with these sorts of devices is fiddly at best. If you have a working Arduino setup then I would stick with that.

A:
I'd like to know if I can use the other wires to control it?
  ... So what would I need to control an LED with usb data?

You will need to connect the GND, VBUS and D+/D- to any USB-compliant device that has an ability to toggle a GPIO. The GPIO should control your transistor and whatever you connect to it.
There are several simple ICs that can do this. I know FT232R (see application section 7) can do this by toggling CBUS[3:0] pins, and I am certain that MCP2221A (USB 2.0 to I2C/UART Protocol Converter with GPIO) can do GPIO as well. The MCP2221A also comes in PDIP-14 case, which is easy to breadboard.
On PC side, all API libraries, drivers and application examples are available from respective manufacturers.


text:
Q: If i want the JDK for my Mac, where should I look for it? I want Java to be installed on my Leopard MacBook, but I couldn't find the JDK kit for Mac on Sun's Java site.  Where should I look for it?

A: The JDK is already installed on Mac OS X 10.5.  If you go to /Applications/Utilities you will see Java Preferences.  There you can select between the versions of Java you would like to use, including version 6 (6 is only 64-bit so if you have a 32-bit Core Duo Macbook you'll have to use SoyLatte).
alt text http://img121.imageshack.us/img121/4249/javapref.jpg

A: You need to install the Xcode developer tools. The JDK is included there. Before you do that, though, you can check if it is already installed by using javac -version. To find out where it is located, you can run the command which javac, although it will most likely be a symlink to somewhere else.

A: It comes with the OS.
Try "java -version" in Terminal.
Apple is maintaining this version, not Sun. It gets updated using Software Update, and there may be downloads (for beta versions) at the Apple Developer Connection site.

A: OpenJDK seems to be the ultimate source for anyone who doesn't want to run in to licensing issues. I understand Oracle's version is derived from OpenJDK.
Installers for macOS can be found at https://adoptopenjdk.net/

A: You may want to try soylatte or openJDK from Mac Ports . Also, Apple has download section of java too ( http://developer.apple.com/java/download/ )
you didn't tell what architecture you are using which has some impact.


text:
Q: Is database partitioning only created to get a better performance? and why should one partition a table, and a database? I was asked if SQL Server can handle huge databases ( for them a huge database is 100GB). I know it can. I worked with 4tB databases already. But I would like to ask, thinking about really huge databases ( I don't know. maybe 30TB ).
In a busy environment, a 30tb database would be a problem if not indexed or partitioned correctly. An example is, if a table is not partitioned, when those 500 concurrents queries run, the table would be really slow to give us results, so we can partition this table, let's say, by months or years.
Is Database partition and Table partition the same? Not literal the same, but, is this for the same result? Only performance?
In the company where I work, we barely have a query. We only "hold" data. theres less then 3 queries running each time. If I have a huge database, will I have performance issues ( With so little interaction on it?)
I don't know if I could explain what I would like to.

A: I am not sure if I would be able to put this in a comment, hence making it an answer:
Partitioning may not serve the mere goal of performance, because querying the partitioned tables and data comes more into picture when we talk performance. Therefore one needs to have a better understanding of writing efficient queries on partitioned tables.
Partitioning is good for very large databases, for maintaining that big amount of data within the database efficiently so that you can handle its growth properly. What I get from partitioning is saving some space on the data drives, which might be filling with unwanted data preserved, depending upon RTO or RPO. Good for saving some space for sure.
I don't think database partitioning and tables are the same. I have never implemented database partitioning, but yes you can use it for large tables. Also check on data and/or page compression when using partitioning.
With big databases, like 30 TB, you may consider other performance checks and good practices apart from partitioning as well, like infra build, etc.
This might help: https://www.brentozar.com/guide-to-evaluating-table-partitioning/


text:
Q: Why my variable is undefined when I'm using an arrow function onClick? In my react component, orders[i] is defined, since the component is rendered using name and amount, however, when it comes to onClick event, orders[i] is undefined in the context of the arrow function. How can I call that function using orders[i].name as an argument?
let orders = this.state.orders;
let ordersRender =[];
for (var i=0; i<orders.length; i++) {
  if (orders[i].amount) {
    let newInvoiceItem = <InvoiceItem name={orders[i].name} amount ={orders[i].amount} key={i} handleDelete={() => this.deleteProduct(orders[i].name)}/>;
    ordersRender.push(newInvoiceItem);
  }
}

A: When handleDelete event is fired, the variable i has changed its value to orders.length, that's why orders[i] is undefined when onClick is fired.
So, instead of for-loop, use Array#map to iterate over the orders and return an array of InvoiceItem items. Since amount is optional, we need to filter the orders based on the amount before applying the .map function.
let { orders } = this.state;
let ordersRender = orders.filter(order => order.amount).map(({name, amount}, index) => {
  return (
    <InvoiceItem name={name} amount ={amount} key={index} handleDelete={() => this.deleteProduct(name)}/>
  );
})
...

Hope this will help!

A: Simply changing var to let solves this issue.


text:
Q: Xamarin MainStoryBoard opening error: Object reference not set to an instance of an object I'm trying xamarin how to create native ios apps with visual studio, but when i open main.storyboard, there is an error

Anyone know how to fix this?


text:
Q: KineticJS gives 2fps drag performance on Android mobile VS 20fps Android desktop Very slow interactive drag performance (about 2 fps) while running a simple KineticJS version 5.0.2 app on Android Chrome (Android 4.3 on a Samsung Galaxy Note 10.1 2014 edition) BUT as soon as I select Chrome's setting to "Request desktop site" suddenly there's a massive performance increase of about 10x with the drag refresh rate. I'm not sure if this is a KineticJS issue or perhaps something else entirely. Running on a desktop browser on my workstation, performance is butter smooth.
Here's a description of the app: There's a bitmap in the background layer (900x600) and a PNG bitmap with alpha channel in the foreground layer (320x156) with draggable = true.
If I remove the background layer, then drag performance is OK.
Is there a way to solve this?

A: I have now achieved a consistent frame rate of roughly 30 to 40 fps on both mobile and desktop modes on the Samsung tablet mentioned above!
The big change came from restructuring my game code which erroneously called init() several times (about 6 times) instead of just once, each time instantiating the stage and the multiple images.  I do also use "Kinetic.pixelRatio = 1" at the top of the code and a "Kinetic.FastLayer()" for my static background artwork.


text:
Q: numpy memmap memory usage - want to iterate once let say I have some big matrix saved on disk. storing it all in memory is not really feasible so I use memmap to access it
A = np.memmap(filename, dtype='float32', mode='r', shape=(3000000,162))

now let say I want to iterate over this matrix (not essentially in an ordered fashion) such that each row will be accessed exactly once.
p = some_permutation_of_0_to_2999999()

I would like to do something like that:
start = 0
end = 3000000
num_rows_to_load_at_once = some_size_that_will_fit_in_memory()
while start < end:
    indices_to_access = p[start:start+num_rows_to_load_at_once]
    do_stuff_with(A[indices_to_access, :])
    start = min(end, start+num_rows_to_load_at_once)

as this process goes on my computer is becoming slower and slower and my RAM and virtual memory usage is exploding.
Is there some way to force np.memmap to use up to a certain amount of memory? (I know I won't need more than the amount of rows I'm planning to read at a time and that caching won't really help me since I'm accessing each row exactly once)
Maybe instead is there some other way to iterate (generator like) over a np array in a custom order? I could write it manually using file.seek but it happens to be much slower than np.memmap implementation
do_stuff_with() does not keep any reference to the array it receives so no "memory leaks" in that aspect
thanks

A: This has been an issue that I've been trying to deal with for a while. I work with large image datasets and numpy.memmap offers a convenient solution for working with these large sets.
However, as you've pointed out, if I need to access each frame (or row in your case) to perform some operation, RAM usage will max out eventually.
Fortunately, I recently found a solution that will allow you to iterate through the entire memmap array while capping the RAM usage.
Solution:
import numpy as np

# create a memmap array
input = np.memmap('input', dtype='uint16', shape=(10000,800,800), mode='w+')

# create a memmap array to store the output
output = np.memmap('output', dtype='uint16', shape=(10000,800,800), mode='w+')

def iterate_efficiently(input, output, chunk_size):
    # create an empty array to hold each chunk
    # the size of this array will determine the amount of RAM usage
    holder = np.zeros([chunk_size,800,800], dtype='uint16')

    # iterate through the input, replace with ones, and write to output
    for i in range(input.shape[0]):
        if i % chunk_size == 0:
            holder[:] = input[i:i+chunk_size] # read in chunk from input
            holder += 5 # perform some operation
            output[i:i+chunk_size] = holder # write chunk to output

def iterate_inefficiently(input, output):
    output[:] = input[:] + 5

Timing Results:
In [11]: %timeit iterate_efficiently(input,output,1000)
1 loop, best of 3: 1min 48s per loop

In [12]: %timeit iterate_inefficiently(input,output)
1 loop, best of 3: 2min 22s per loop

The size of the array on disk is ~12GB. Using the iterate_efficiently function keeps the memory usage to 1.28GB whereas the iterate_inefficiently function eventually reaches 12GB in RAM.
This was tested on Mac OS.

A: I've been experimenting with this problem for a couple days now and it appears there are two ways to control memory consumption using np.mmap. The first is reliable while the second would require some testing and will be OS dependent.
Option 1 - reconstruct the memory map with each read / write:
def MoveMMapNPArray(data, output_filename):
    CHUNK_SIZE = 4096
    for idx in range(0,x.shape[1],CHUNK_SIZE):
        x = np.memmap(data.filename, dtype=data.dtype, mode='r', shape=data.shape, order='F')
        y = np.memmap(output_filename, dtype=data.dtype, mode='r+', shape=data.shape, order='F')
        end = min(idx+CHUNK_SIZE, data.shape[1])
        y[:,idx:end] = x[:,idx:end]

Where data is of type np.memmap. This discarding of the memmap object with each read keeps the array from being collected into memory and will keep memory consumption very low if the chunk size is low. It likely introduces some CPU overhead but was found to be small on my setup (MacOS).
Option 2 - construct the mmap buffer yourself and provide memory advice
If you look at the np.memmap source code here, you can see that it is relatively simple to create your own memmapped numpy array relatively easily. Specifically, with the snippet:
mm = mmap.mmap(fid.fileno(), bytes, access=acc, offset=start)
mmap_np_array = ndarray.__new__(subtype, shape, dtype=descr, buffer=mm, offset=array_offset, order=order)

Note this python mmap instance is stored as the np.memmap's private _mmap attribute.
With access to the python mmap object, and python 3.8, you can use its madvise method, described here.
This allows you to advise the OS to free memory where available. The various madvise constants are described here for linux, with some generic cross platform options specified.
The MADV_DONTDUMP constant looks promising but I haven't tested memory consumption with it like I have for option 1.


text:
Q: How to initialize I2C on STM32F0? Recently I've been trying to get the I2C bus working on the STM32F030F4P6 MCU, but with little luck.
I'm using an STM32F0 module and have found plenty of resources for the STM32F1 module I2C initialization, but nothing specific about the STM32F0 initialization/transfer process.
Here's my initialization code:
void i2c_init(uint8_t ownAddress)
{
GPIO_InitTypeDef  GPIO_InitStructure;
I2C_InitTypeDef  I2C_InitStructure;

// Enable GPIOA clocks

RCC_APB2PeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

// Configure I2C1 clock and GPIO

GPIO_StructInit(&GPIO_InitStructure);

/* I2C1 clock enable */

RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);

/* I2C1 SDA and SCL configuration */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
GPIO_Init(GPIOA, &GPIO_InitStructure);

/* I2C1 Reset */

RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE);

/* Configure I2C1                */

I2C_InitStructure.I2C_AnalogFilter = I2C_AnalogFilter_Enable;
I2C_StructInit(&I2C_InitStructure);
I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
//I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
I2C_InitStructure.I2C_OwnAddress1 = ownAddress;
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
//I2C_InitStructure.I2C_ClockSpeed = ClockSpeed;

I2C_Init(I2C1, &I2C_InitStructure);
I2C_Cmd(I2C1, ENABLE);

}

In order to test to see if my setup was correct I designed some I2C transmission code that would transfer data in a never ending loop. Here's the code for that:
while(1)
{
I2C_SlaveAddressConfig(I2C1, RegName);
I2C_GenerateSTART(I2C1, ENABLE);
I2C_NumberOfBytesConfig(I2C1, 8);
I2C_SendData(I2C1,0b00000000);
I2C_GenerateSTOP(I2C1, ENABLE);
}

Where:
RegName = 0x75
SDA = GPIO_PIN_10 on GPIOA
SCL = GPIO_PIN_9 on GPIOA
I2C = I2C1
ownAdrress = 0x68
When I scope the I2C lines after I start this code I get a floating voltage around 160mV. When I step through the code every one of the I2C function calls happen and complete, so that's why I was thinking that it had something more so to do with my initialization of the pins themselves.
My problem is very similar to this thread, but was never answered:
https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a%2f%2fmy%2est%2ecom%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex_mx_stm32%2fSTM32F0%20I2C%20code%20doesn%27t%20work&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=1342
Edit 1: Here's my latest code; still not working (Edit 2: Updated to what I currently have; moved things into more correct locations):
void i2c_init(uint8_t ownAddress)
{

    /* TypeDefs for GPIOA and I2C1 */

    GPIO_InitTypeDef  GPIO_InitStructure;
    I2C_InitTypeDef  I2C_InitStructure;

    /* Enable GPIOA clocks and I2C1 clock enable */

    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);

    /* Configure I2C1 clock and GPIO */

    GPIO_StructInit(&GPIO_InitStructure);

    /* I2C1 SDA and SCL configuration */

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; //UP
    GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;

    /* GPIO AF Configuration -> GPIO_AF_1: USART2, CEC, Tim3, USART1, USART2,EVENTOUT, I2C1, I2C2, TIM15 */

    GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_1);
    GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_1);

    GPIO_Init(GPIOA, &GPIO_InitStructure);

    /* I2C1 Reset */

    RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE);
    RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE);

    //I2C_DeInit(I2C1);

    /* Configure I2C1 */

    I2C_StructInit(&I2C_InitStructure);

    I2C_InitStructure.I2C_AnalogFilter = I2C_AnalogFilter_Enable;
    I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
    I2C_InitStructure.I2C_OwnAddress1 = ownAddress;
    I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
    I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;

    I2C_Init(I2C1, &I2C_InitStructure);
    I2C_Cmd(I2C1, ENABLE);
    //I2C_AcknowledgeConfig(I2C1, ENABLE);

}

As you can see I added the two lines GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_1); and GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_1); where I found that GPIO_AF_1 had the alternate function of I2C1 from the STM32F0 Standard Peripheral bibliotheek.
Any other ideas? I've been playing around with the clocks to see if that changed anything and have been adding snippets of other people's code just to see if that has any effect on the output of my device.
Edit 3: I have tried pulling both the SDA and SCL lines up to VCC with a 1kohm resistor as instructed by this guide: https://electronics.stackexchange.com/questions/57121/i2c-pullup-resistor-calculations
->(3.3V-0.4)/3mA ~= 1kohm
Edit 4: After going through my code line by line I tried outputting various flag bit registers. Specifically these registers: isr = I2C1->ISR;, cr1 = I2C1->CR1;, and cr2 = I2C1->CR2;
The flag I get after initiating the I2C transfer handling with I2C_TransferHandling(I2C1, 0x02, 1, I2C_AutoEnd_Mode, I2C_Generate_Start_Write); was 0x8001 which can be deciphered down to two errors:
#define  I2C_ISR_BUSY                        ((uint32_t)0x00008000)        /*!< Bus busy */
and
#define  I2C_ISR_TXE                         ((uint32_t)0x00000001)        /*!< Transmit data register empty */
I've found some work arounds at this link here (remove the space after https: to go to the link -> stack overflow won't let me post more than 1 link for some reason): https: //my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FSTM32L151RB%20I2C%20Busy%20flag%20always%20set&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=690 that I'm looking to implement and will report back as soon as I try them out.

A: I have I2C working as master and slave on the F0. The main issue I can see with your code is that in master mode you absolutely must set the I2C_Timing initialisation structure member. See RM0091 for sample values that correspond to the frequency you want to generate on SCL. In slave mode the clock is recovered from the master so the timing member doesn't appear to be used.
As the others have said, external pullups to Vcc on SCL and SDA are not optional and must be present once per bus not per peripheral as you incorrectly stated in a comment. You were right to use the calculator to choose suitable values because the internal pullups in the STM32 at about 30-50K are far too weak for use as I2C pullups.

A: The problem is that you don't configure proper AF (Alternate Function) source for I2C pins. After reset registers that configure AF are all 0, and I2C's function is 1, so your I2C peripheral is in fact disconnected from the GPIOs.
Technically it makes no difference when you configure that, but it's best to do that before GPIO configuration to minimize any unwanted transitions on the pins.
Edit: You MUST have the pullups on the I2C pins - without them you have "low" level there, and I2C peripheral detects that as bus error, which obviously prevents it from working properly. Either connect external resistors, or at least enable internal pullups instead of "no pullups/no pulldowns" configuration.
Moreover - it's just not possible for an "open drain" pin to work properly without pullup.

A: The Core of Cortex M0 is different then Core of Cortex M3, STM32f030f4 has AHB and APB1 (bridged) only. The C code of STM32f1xx never be run under STM32f0xx.
Use STM32F0xx_Snippets_Package for solve your key problems.

A: I notice that you are mapping the pins to AF_1 and that is for the UART function.
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_1);

You need to map them to AF_4 to use the I2C function.
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_4);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_4);

A: I just noticed this too:
RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE);

So you have disabled the clock after you enabled it. I don't see where you have re-enabled it later.


text:
Q: Why is it unsafe to mount a physical NTFS partition from two running OSs (Win10+Linux, Dual Boot+Virtualize From Physical Disk)? I'm running Windows 10 & Ubuntu dual-boot, and would like to also use VirtualBox to boot to the Windows installation as a VM from within Ubuntu (to avoid a full reboot to just do something quick).  This is pretty common & well-documented - i.e. here. However, a caveat that I sometimes see mentioned is:
"[if] you open the same partition twice [...] this will kill your data, so never mount multiple partitions concurrently. Furthermore, don't mount your NTFS partitions while they are used by your Windows." (From: here)
My system is setup where I have a shared NTFS partition for data common to both Linux & Windows.  Obviously when dual-booting, this works fine: I can access the same set of data from whichever OS is up & running.  So for the VM scenario to be useful, both OSs would similarly need access to this "shared data" partition.  VirtualBox usually handles shared storage by mapping network drives into the VM, but there are many cases where this doesn't work.  Some examples: Lightroom doesn't let you open a catalog on a network drive; many applications won't let you open a database on a network drive or use a network drive for temp; Windows complains when running some applications directly off a network drive.  Thus, to be useful, both OSs need direct access to this "shared data" partition.
So my question: am I understanding correctly in that this is somehow unsafe - to directly mount this NTFS partition from both OSs? If so, why? And is there any possible solution to what I'm trying to accomplish - or no, I just have to either dual boot, or copy all the problematic data (i.e. LR catalog) back & forth onto the VM's system disk for it to work (which pretty much defeats the purpose of using the VM - at that point it's more efficient to just fully reboot in Windows)


text:
Q: Looking for an apocalyptic fantasy book I think it was a "magic returns" type of story.
There was the revival of an aztec/mayan sorcerer. He and an underling ate a prostitutes heart for power.
There was a woman fighting them, who had been basically a new age pagan but her powers were growing (iirc).
Thanks for any help!


text:
Q: Not clear why init methods gets called on some class again I am reading a book and there is such implementation of class:
@implementation BNRItemStore

// Init method
- (id)init
{
    self = [super init];

    if(self)
    {
        allItems = [[NSMutableArray alloc] init];
    }

    return self;

}

#pragma mark singleton stuff

// Implementing singleton functionality
+(BNRItemStore*) sharedStore
{
    static BNRItemStore *sharedStore = nil;

    // Check if instance of this class has already been created via sharedStore
    if(!sharedStore)
    {
        // No, create one
        sharedStore = [[super allocWithZone:nil] init];
    }

    return sharedStore;

}

// This method gets called by alloc
+ (id)allocWithZone:(NSZone *)zone
{
    return [self sharedStore];
}

#pragma mark Methods

// return pointer to allItems
-(NSArray*) allItems
{
    return allItems;
}

// Create a random item and add it to the array. Also return it.
-(BNRItem*) createItem
{
    BNRItem *p = [BNRItem randomItem];
    [allItems addObject:p];
    return p;
}

@end

The thing I find strange is that Nowhere outside the class, e.g., some other class, is the init method of BNRItemStore called. However, still by some means it gets called, even when someone has typed such code outside the BNRItemStore class:
    [[BNRItemStore sharedStore] createItem]; // This still calls the init method of BNRItemStore. How?

Can someone please explain why?

A: sharedStore = [[super allocWithZone:nil] init];

This line is responsible for the init call. First time entering sharedStore the sharedStore variable is nil, so the condition check fails and an instance of the class is initialized.

A: -init gets called because +sharedStore calls it:
sharedStore = [[super allocWithZone:nil] init];

[super allocWithZone:nil] skips the current class' implementation of allocWithZone and calls the superclass implementation. However, init is an ordinary method call so it doesn't skip the superclass implementation.
Although the quoted line makes it look like super is an object that you're sending a message to, it really means something like "self, but skip the current class' implementation and use the superclass instead". It doesn't affect messages sent to the returned object.


text:
Q: Replacing information within XML tags I am trying to replace the information in an SVG file using ElementTree, however I am very new to it and haven't been making much progress.
So far, my code is:
import xml.etree.ElementTree as ET

tree = ET.parse('path-to-file')
root = tree.getroot()
for item in root.iter('tspan'):
    print(item)

However this doesn't find anything.
The SVG file information that I'm trying to locate is in the form:
<text
     transform="matrix(0,-1,-1,0,2286,3426)"
     style="font-variant:normal;font-weight:normal;font-size:123.10199738px;font-family:Arial;-inkscape-font-specification:ArialMT;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
     id="text79724">
  <tspan
     x="0 71.891571 154.0006 188.22296 256.66766"
     y="0"
     sodipodi:role="line"
     id="tspan79722"><SI1></tspan>
</text>

Where I am specifically looking to change the
x="0 71.891571 154.0006 188.22296 256.66766"

to x="0".
I am not set on using ElementTree to do this, however, most similar StackOverflow questions suggest that it's the best idea.

A: As you stated in the question, you are not set to using ElementTree - so here is a solution using beautifulsoup:
data = '''<text
           transform="matrix(0,-1,-1,0,2286,3426)"
           style="font-variant:normal;font-weight:normal;font-size:123.10199738px;font-family:Arial;-inkscape-font-specification:ArialMT;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
           id="text79724"><tspan
             x="0 71.891571 154.0006 188.22296 256.66766"
             y="0"
             sodipodi:role="line"
             id="tspan79722"><SI1></tspan></text>'''

from bs4 import BeautifulSoup

soup = BeautifulSoup(data, 'html.parser')

for tspan in soup.select('tspan[x]'):
    if tspan['x'] == '0 71.891571 154.0006 188.22296 256.66766':
        tspan['x'] = 0

print(soup.prettify())
#if writing to a new svg file, use soup instead of soup.prettify()

Prints:
<text id="text79724" style="font-variant:normal;font-weight:normal;font-size:123.10199738px;font-family:Arial;-inkscape-font-specification:ArialMT;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none" transform="matrix(0,-1,-1,0,2286,3426)">
 <tspan id="tspan79722" sodipodi:role="line" x="0" y="0">
  <SI1>
 </tspan>
</text>

CSS selector tspan[x] will select <tspan> tag with attribute x. Then we check if attribute x is '0 71.891571 154.0006 188.22296 256.66766'. If it is, we set it to 0.


text:
Q: Node: ShellJS not working with command line tools If I execute shell.exec('http') I get the help for httpie, a request library I use. However if I add an argument, like seen below, shelljs never calls the callback.
var shell = require('shelljs');

shell.exec('http http://www.example.com/', {async: true, silent: false}, function(data){
  console.log(data);
})

The above example DOES work if I use curl instead of http. Any ideas why its not working with http?

A: Add ignore-stdin option
var shell = require('shelljs');
shell.exec('http --ignore-stdin http://www.example.com/', {async: true, silent: false}, function(data){
  console.log(data);
});

The --ignore-stdin option prevents HTTPie from reading data from stdin, which is usually not desirable during non-interactive invocations.
You can read more in the Scripting section of httpie


text:
Q: Type another answer in JSON enum FormFlow dialog I am using JSON FormFlow dialogs.
public async Task StartAsync(IDialogContext context)
        {
            context.Wait(MessageReceivedAsync);
        }

public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> argument)
        {
            var activity = await argument;
            if (activity.Type == ActivityTypes.Message)
            {
                context.Call(FormDialog.FromForm(() => BuildJsonForm(), FormOptions.PromptInStart), DialogCompleted);
            }
        }
public static IForm<JObject> BuildJsonForm()
    {

        using (var stream = File.OpenRead("my.json"))
        {
            var schema = JObject.Parse(new StreamReader(stream).ReadToEnd());
            return new FormBuilderJson(schema)
                .AddRemainingFields()
                .Build();
        }
    }

Inside of my.json I have enum:
"properties": {
"EnumExample": {
  "Prompt": { "Patterns": [ "To what language translate {||}" ] },

  "Describe": { "Image": "" },
  "type": [
    "string",
    "null"
  ],
  "enum": [
    "en",
    "fr",
    "ru",
    "de",
    "es"
  ],
  "Values": {
    "en": {
      "Describe": "English"
    },
    "fr": {
      "Describe": "French"
    },
    "ru": {
      "Describe": "Russian"
    },
    "de": {
      "Describe": "German"
    },
    "es": {
      "Describe": "Spanish"
    }
  }
}

The question : how I can support selecting by user one of Enum options and also free text typing , so I can run another dialog or run Luis API on that input. For example user will type " I want to talk with operator" instead of answering Enum in my JSON FormFlow dialog?
Thanks


text:
Q: Why does gem dependency list a gem I have commented out in my Gemfile? I'm trying to eliminate a dependency on JSON-1.8.3 that is wreaking havoc with my build.  I deleted my Gemfile.lock and then commented out the only item (bootstrap-sass) in my Gemfile that had that dependency ...
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails'  #, '~> 4.2.7.1'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'

gem 'uuids'
gem 'addressable'
gem 'pg'
gem 'pundit'
gem 'omniauth-oauth2', '~> 1.3.1'
gem 'omniauth-google-oauth2'
gem 'omniauth-facebook'
gem 'omniauth-twitter'
gem 'omniauth-linkedin-oauth2'
gem 'jquery-ui-rails'
gem 'jquery-cookie-rails'
gem 'will_paginate'
#gem 'bootstrap-sass'
gem 'autoprefixer-rails'
gem 'compass-rails'
gem 'pdf-reader'
gem 'jquery-turbolinks'
gem 'activerecord-import'
gem 'w3c_validators'
gem 'whenever', :require => false
gem 'roo-xls'
gem 'socksify'

But when I run gem dependency, it still lists bootstrap-sass-3.3.7...
localhost:myproject davea$ gem dependency
Gem Ascii85-1.0.2
  bundler (>= 1.0.0, development)
  minitest (>= 2.6.0, development)
  rake (>= 0.9.2, development)

Gem actioncable-5.0.0.1
  actionpack (= 5.0.0.1)
  blade (~> 0.5.1, development)
  nio4r (~> 1.2)
  websocket-driver (~> 0.6.1)

Gem actioncable-5.0.1
  actionpack (= 5.0.1)
  blade (~> 0.5.1, development)
  nio4r (~> 1.2)
  websocket-driver (~> 0.6.1)

Gem actionmailer-5.0.0.1
  actionpack (= 5.0.0.1)
  actionview (= 5.0.0.1)
  activejob (= 5.0.0.1)
  mail (>= 2.5.4, ~> 2.5)
  rails-dom-testing (~> 2.0)

Gem actionmailer-5.0.1
  actionpack (= 5.0.1)
  actionview (= 5.0.1)
  activejob (= 5.0.1)
  mail (>= 2.5.4, ~> 2.5)
  rails-dom-testing (~> 2.0)

Gem actionpack-5.0.0.1
  actionview (= 5.0.0.1)
  activemodel (= 5.0.0.1, development)
  activesupport (= 5.0.0.1)
  rack (~> 2.0)
  rack-test (~> 0.6.3)
  rails-dom-testing (~> 2.0)
  rails-html-sanitizer (>= 1.0.2, ~> 1.0)

Gem actionpack-5.0.1
  actionview (= 5.0.1)
  activemodel (= 5.0.1, development)
  activesupport (= 5.0.1)
  rack (~> 2.0)
  rack-test (~> 0.6.3)
  rails-dom-testing (~> 2.0)
  rails-html-sanitizer (>= 1.0.2, ~> 1.0)

Gem actionview-5.0.0.1
  actionpack (= 5.0.0.1, development)
  activemodel (= 5.0.0.1, development)
  activesupport (= 5.0.0.1)
  builder (~> 3.1)
  erubis (~> 2.7.0)
  rails-dom-testing (~> 2.0)
  rails-html-sanitizer (>= 1.0.2, ~> 1.0)

Gem actionview-5.0.1
  actionpack (= 5.0.1, development)
  activemodel (= 5.0.1, development)
  activesupport (= 5.0.1)
  builder (~> 3.1)
  erubis (~> 2.7.0)
  rails-dom-testing (~> 2.0)
  rails-html-sanitizer (>= 1.0.2, ~> 1.0)

Gem activejob-5.0.0.1
  activesupport (= 5.0.0.1)
  globalid (>= 0.3.6)

Gem activejob-5.0.1
  activesupport (= 5.0.1)
  globalid (>= 0.3.6)

Gem activemodel-5.0.0.1
  activesupport (= 5.0.0.1)

Gem activemodel-5.0.1
  activesupport (= 5.0.1)

Gem activerecord-5.0.0.1
  activemodel (= 5.0.0.1)
  activesupport (= 5.0.0.1)
  arel (~> 7.0)

Gem activerecord-5.0.1
  activemodel (= 5.0.1)
  activesupport (= 5.0.1)
  arel (~> 7.0)

Gem activesupport-5.0.0.1
  concurrent-ruby (>= 1.0.2, ~> 1.0)
  i18n (~> 0.7)
  minitest (~> 5.1)
  tzinfo (~> 1.1)

Gem activesupport-5.0.1
  concurrent-ruby (>= 1.0.2, ~> 1.0)
  i18n (~> 0.7)
  minitest (~> 5.1)
  tzinfo (~> 1.1)

Gem afm-0.2.2
  minitest (~> 5.3, development)
  rake (~> 10.3, development)
  rdoc (~> 4.1, development)

Gem arel-6.0.4
  minitest (~> 5.4, development)
  rake (>= 0, development)
  rdoc (~> 4.0, development)

Gem arel-7.1.4
  minitest (~> 5.4, development)
  rake (>= 0, development)
  rdoc (~> 4.0, development)

Gem autoprefixer-rails-6.5.1
  compass (>= 0, development)
  execjs (>= 0)
  rails (>= 0, development)
  rake (>= 0, development)
  rspec-rails (>= 0, development)

Gem bcrypt-3.1.11
  rake-compiler (~> 0.9.2, development)
  rdoc (~> 3.12, development)
  rspec (>= 3, development)

Gem bcrypt-ruby-3.1.5
  bcrypt (>= 3.1.3)
  rake-compiler (~> 0.9.2, development)
  rdoc (~> 3.12, development)
  rspec (>= 0, development)

Gem bigdecimal-1.3.0
  minitest (~> 4.7.5, development)
  rake (~> 10.0, development)
  rake-compiler (~> 0.9, development)

Gem bootstrap-sass-3.3.7
  actionpack (>= 4.1.5, development)
  activesupport (>= 4.1.5, development)
  autoprefixer-rails (>= 5.2.1)
  capybara (>= 2.5.0, development)
  jquery-rails (>= 3.1.0, development)
  json (>= 1.8.1, development)
  minitest (~> 5.8, development)
  minitest-reporters (~> 1.1, development)
  poltergeist (>= 0, development)
  sass (>= 3.3.4)
  slim-rails (>= 0, development)
  sprockets-rails (>= 2.1.3, development)
  term-ansicolor (>= 0, development)
  uglifier (>= 0, development)

Gem builder-3.2.2

Gem bundler-1.13.7
  automatiek (~> 0.1.0, development)
  mustache (= 0.99.6, development)
  rake (~> 10.0, development)
  rdiscount (~> 2.2, development)
  ronn (~> 0.7.3, development)
  rspec (~> 3.5, development)

Gem bundler-unload-1.0.2
  bundler (>= 0, development)

Gem byebug-9.0.6
  bundler (~> 1.7, development)

Gem chronic-0.10.2
  activesupport (>= 0, development)
  minitest (~> 5.0, development)
  rake (>= 0, development)
  simplecov (>= 0, development)

Gem chunky_png-1.3.8
  rake (>= 0, development)
  rspec (~> 3, development)

Gem coffee-rails-4.2.1
  coffee-script (>= 2.2.0)
  railties (< 5.2.x, >= 4.0.0)

Gem coffee-script-2.4.1
  coffee-script-source (>= 0)
  execjs (>= 0)
  json (>= 0, development)
  rake (>= 0, development)

Gem coffee-script-source-1.10.0

Gem coffee-script-source-1.12.2

Gem colorize-0.8.1
  codeclimate-test-reporter (~> 0.4, development)
  minitest (~> 5.0, development)
  rake (~> 10.0, development)

Gem concurrent-ruby-1.0.2

Gem concurrent-ruby-1.0.4

Gem daemons-1.2.4
  pry-byebug (~> 0, development)
  rake (~> 0, development)
  rspec (~> 3.1, development)
  simplecov (~> 0, development)

Gem debug_inspector-0.0.2

Gem did_you_mean-1.1.0
  bundler (>= 0, development)
  minitest (>= 0, development)
  rake (>= 0, development)

Gem erubis-2.7.0

Gem eventmachine-1.2.1
  rake-compiler (~> 0.9.5, development)
  rake-compiler-dock (~> 0.5.1, development)
  test-unit (~> 2.0, development)

Gem execjs-2.7.0
  rake (>= 0, development)

Gem executable-hooks-1.3.2
  tf (>= 0, development)

Gem ffi-1.9.14
  rake (~> 10.1, development)
  rake-compiler (~> 0.9, development)
  rake-compiler-dock (~> 0.5.2, development)
  rspec (~> 2.14.1, development)
  rubygems-tasks (~> 0.2.4, development)

Gem gem-wrappers-1.2.7
  minitest (>= 0, development)
  rake (>= 0, development)

Gem globalid-0.3.7
  activesupport (>= 4.1.0)
  rake (>= 0, development)

Gem hashery-2.1.2
  lemon (>= 0, development)
  qed (>= 0, development)
  rubytest-cli (>= 0, development)

Gem hashie-3.4.6
  rake (>= 0, development)
  rspec (~> 3.0, development)
  rspec-pending_for (~> 0.1, development)

Gem httplog-0.3.3
  colorize (>= 0)
  ethon (>= 0, development)
  excon (>= 0.18.0, development)
  faraday (>= 0, development)
  guard-rspec (>= 0, development)
  http (= 1.0.4, development)
  httparty (>= 0, development)
  httpclient (>= 0, development)
  log4r (>= 0, development)
  patron (>= 0, development)
  rack (>= 0, development)
  rake (>= 0, development)
  rspec (>= 0, development)
  simplecov (>= 0, development)
  thin (>= 0, development)
  typhoeus (>= 0, development)

Gem i18n-0.7.0

Gem ims-lti-1.1.13
  builder (>= 0)
  oauth (< 0.6, >= 0.4.5)
  rspec (>= 0, development)

Gem io-console-0.4.6

Gem jbuilder-2.6.0
  activesupport (< 5.1, >= 3.0.0)
  multi_json (~> 1.2)

Gem jquery-rails-4.2.1
  rails-dom-testing (< 3, >= 1)
  railties (>= 4.2.0)
  thor (< 2.0, >= 0.14)

Gem jquery-ui-rails-5.0.5
  json (~> 1.7, development)
  railties (>= 3.2.16)

Gem json-2.0.2
  rake (>= 0, development)
  test-unit (~> 2.0, development)

Gem jwt-1.5.6
  bundler (>= 0, development)
  codeclimate-test-reporter (>= 0, development)
  json (< 2.0, development)
  rake (>= 0, development)
  rspec (>= 0, development)
  simplecov (>= 0, development)
  simplecov-json (>= 0, development)

Gem listen-3.0.8
  bundler (>= 1.3.5, development)
  rb-fsevent (>= 0.9.4, ~> 0.9)
  rb-inotify (>= 0.9.7, ~> 0.9)

Gem loofah-2.0.3
  hoe (~> 3.13, development)
  hoe-bundler (>= 0, development)
  hoe-debugging (>= 0, development)
  hoe-gemspec (>= 0, development)
  hoe-git (>= 0, development)
  json (>= 0, development)
  minitest (~> 2.2, development)
  nokogiri (>= 1.5.9)
  rake (>= 0.8, development)
  rdoc (~> 4.0, development)
  rr (~> 1.1.0, development)

Gem mail-2.6.4
  bundler (>= 1.0.3, development)
  mime-types (< 4, >= 1.16)
  rake (> 0.8.7, development)
  rdoc (>= 0, development)
  rspec (~> 3.0, development)

Gem method_source-0.8.2
  bacon (~> 1.1.0, development)
  rake (~> 0.9, development)

Gem mime-types-3.1
  fivemat (~> 1.3, development)
  hoe (~> 3.15, development)
  hoe-doofus (~> 1.0, development)
  hoe-gemspec2 (~> 1.1, development)
  hoe-git (~> 1.6, development)
  hoe-rubygems (~> 1.0, development)
  hoe-travis (~> 1.2, development)
  mime-types-data (~> 3.2015)
  minitest (~> 5.9, development)
  minitest-autotest (~> 1.0, development)
  minitest-bonus-assertions (~> 2.0, development)
  minitest-focus (~> 1.0, development)
  minitest-hooks (~> 1.4, development)
  minitest-rg (~> 5.2, development)
  rake (~> 10.0, development)
  rdoc (~> 4.0, development)
  simplecov (~> 0.7, development)

Gem mime-types-data-3.2016.0521
  hoe (~> 3.15, development)
  hoe-doofus (~> 1.0, development)
  hoe-gemspec2 (~> 1.1, development)
  hoe-git (~> 1.6, development)
  hoe-rubygems (~> 1.0, development)
  mime-types (~> 3.0, development)
  nokogiri (~> 1.6, development)
  rake (~> 10.0, development)
  rdoc (~> 4.0, development)

Gem mini_portile2-2.1.0
  bundler (~> 1.7, development)
  minitar (~> 0.5.4, development)
  minitest (~> 5.8.0, development)
  minitest-hooks (~> 1.4.0, development)
  rake (~> 10.0, development)

Gem minitest-5.9.1
  hoe (~> 3.15, development)
  rdoc (~> 4.0, development)

Gem minitest-5.10.1
  hoe (~> 3.15, development)
  rdoc (~> 4.0, development)

Gem multi_json-1.12.1
  bundler (~> 1.0, development)

Gem multi_xml-0.6.0
  bundler (~> 1.0, development)

Gem multipart-post-2.0.0

Gem net-telnet-0.1.1
  bundler (~> 1.9, development)
  rake (~> 10.0, development)

Gem nio4r-1.2.1
  bundler (>= 0, development)
  rake (>= 0, development)

Gem nio4r-2.0.0
  bundler (>= 0, development)
  rake (>= 0, development)

Gem nokogiri-1.6.8.1
  hoe (~> 3.15, development)
  hoe-bundler (~> 1.2.0, development)
  hoe-debugging (~> 1.2.1, development)
  hoe-gemspec (~> 1.0.0, development)
  hoe-git (~> 1.6.0, development)
  mini_portile2 (~> 2.1.0)
  minitest (~> 5.8.4, development)
  racc (~> 1.4.14, development)
  rake (~> 10.5.0, development)
  rake-compiler (~> 0.9.2, development)
  rake-compiler-dock (~> 0.5.1, development)
  rdoc (~> 4.0, development)
  rexical (~> 1.0.5, development)

Gem nokogiri-1.7.0
  hoe (~> 3.15, development)
  hoe-bundler (~> 1.2.0, development)
  hoe-debugging (~> 1.2.1, development)
  hoe-gemspec (~> 1.0.0, development)
  hoe-git (~> 1.6.0, development)
  mini_portile2 (~> 2.1.0)
  minitest (~> 5.8.4, development)
  racc (~> 1.4.14, development)
  rake (~> 10.5.0, development)
  rake-compiler (~> 0.9.2, development)
  rake-compiler-dock (~> 0.5.1, development)
  rdoc (~> 4.0, development)
  rexical (~> 1.0.5, development)

Gem oauth-0.5.1
  actionpack (>= 4.0.2, development)
  byebug (>= 0, development)
  curb (>= 0, development)
  em-http-request (= 0.2.11, development)
  iconv (>= 0, development)
  minitest (>= 0, development)
  mocha (>= 0.9.12, development)
  rack (>= 0, development)
  rack-test (>= 0, development)
  rake (>= 0, development)
  typhoeus (>= 0.1.13, development)

Gem openssl-2.0.2
  rake (>= 0, development)
  rake-compiler (>= 0, development)
  rdoc (>= 0, development)
  test-unit (~> 3.0, development)

Gem pg-0.19.0
  hoe (~> 3.12, development)
  hoe-bundler (~> 1.0, development)
  hoe-deveiate (~> 0.7, development)
  hoe-highline (~> 0.2, development)
  hoe-mercurial (~> 1.4, development)
  rake-compiler (~> 0.9, development)
  rake-compiler-dock (~> 0.5, development)
  rdoc (~> 4.0, development)
  rspec (~> 3.0, development)

Gem power_assert-0.4.1
  rake (>= 0, development)
  simplecov (>= 0, development)
  test-unit (>= 0, development)

Gem psych-2.2.2
  minitest (~> 5.0, development)
  rake-compiler (>= 0.4.1, development)

Gem public_suffix-2.0.5
  mocha (>= 0, development)
  rake (>= 0, development)
  yard (>= 0, development)

Gem puma-3.6.0
  hoe (~> 3.15, development)
  rack (< 2.0, >= 1.1, development)
  rake-compiler (~> 0.8, development)
  rdoc (~> 4.0, development)

Gem rack-1.6.5
  bacon (>= 0, development)
  rake (>= 0, development)

Gem rack-2.0.1
  concurrent-ruby (>= 0, development)
  minitest (~> 5.0, development)
  minitest-sprint (>= 0, development)
  rake (>= 0, development)

Gem rack-test-0.6.3
  rack (>= 1.0)

Gem rails-5.0.0.1
  actioncable (= 5.0.0.1)
  actionmailer (= 5.0.0.1)
  actionpack (= 5.0.0.1)
  actionview (= 5.0.0.1)
  activejob (= 5.0.0.1)
  activemodel (= 5.0.0.1)
  activerecord (= 5.0.0.1)
  activesupport (= 5.0.0.1)
  bundler (< 2.0, >= 1.3.0)
  railties (= 5.0.0.1)
  sprockets-rails (>= 2.0.0)

Gem rails-5.0.1
  actioncable (= 5.0.1)
  actionmailer (= 5.0.1)
  actionpack (= 5.0.1)
  actionview (= 5.0.1)
  activejob (= 5.0.1)
  activemodel (= 5.0.1)
  activerecord (= 5.0.1)
  activesupport (= 5.0.1)
  bundler (< 2.0, >= 1.3.0)
  railties (= 5.0.1)
  sprockets-rails (>= 2.0.0)

Gem rails-dom-testing-2.0.1
  activesupport (< 6.0, >= 4.2.0)
  bundler (~> 1.3, development)
  minitest (>= 0, development)
  nokogiri (~> 1.6.0)
  rake (>= 0, development)

Gem rails-dom-testing-2.0.2
  activesupport (< 6.0, >= 4.2.0)
  bundler (~> 1.3, development)
  minitest (>= 0, development)
  nokogiri (~> 1.6)
  rake (>= 0, development)

Gem rails-html-sanitizer-1.0.3
  bundler (~> 1.3, development)
  loofah (~> 2.0)
  minitest (>= 0, development)
  rails-dom-testing (>= 0, development)
  rake (>= 0, development)

Gem railties-5.0.0.1
  actionpack (= 5.0.0.1)
  actionview (= 5.0.0.1, development)
  activesupport (= 5.0.0.1)
  method_source (>= 0)
  rake (>= 0.8.7)
  thor (< 2.0, >= 0.18.1)

Gem railties-5.0.1
  actionpack (= 5.0.1)
  actionview (= 5.0.1, development)
  activesupport (= 5.0.1)
  method_source (>= 0)
  rake (>= 0.8.7)
  thor (< 2.0, >= 0.18.1)

Gem rake-11.3.0
  bundler (~> 1.11, development)
  minitest (~> 5.8, development)
  rdoc (~> 4.0, development)

Gem rake-12.0.0
  bundler (>= 0, development)
  minitest (>= 0, development)
  rdoc (>= 0, development)

Gem rb-fsevent-0.9.8
  bundler (~> 1.0, development)
  guard-rspec (~> 4.2, development)
  rspec (~> 2.11, development)

Gem rb-inotify-0.9.7
  ffi (>= 0.5.0)
  yard (>= 0.4.0, development)

Gem rdoc-5.0.0
  kpeg (>= 0, development)
  minitest (~> 4, development)
  racc (> 1.4.10, development)
  rake (>= 0, development)

Gem ruby-ole-1.2.12

Gem ruby-rc4-0.1.5
  rspec (>= 0, development)

Gem rubygems-bundler-1.4.4
  bundler-unload (>= 1.0.2)
  executable-hooks (>= 1.3.2)
  tf (>= 0, development)

Gem rubyzip-1.2.0
  coveralls (~> 0.7, development)
  minitest (~> 5.4, development)
  pry (~> 0.10, development)
  rake (~> 10.3, development)

Gem rvm-1.11.3.9

Gem sass-3.4.22
  maruku (>= 0.5.9, development)
  minitest (>= 5, development)
  yard (>= 0.5.3, development)

Gem sass-3.4.23
  maruku (>= 0.5.9, development)
  minitest (>= 5, development)
  yard (>= 0.5.3, development)

Gem sass-rails-5.0.6
  railties (< 6, >= 4.0.0)
  sass (~> 3.1)
  sprockets (< 4.0, >= 2.8)
  sprockets-rails (< 4.0, >= 2.0)
  sqlite3 (>= 0, development)
  tilt (< 3, >= 1.1)

Gem socksify-1.7.0

Gem spring-2.0.0
  activesupport (>= 4.2)
  bump (>= 0, development)
  rake (>= 0, development)

Gem spring-watcher-listen-2.0.1
  activesupport (>= 0, development)
  bundler (~> 1.6, development)
  listen (< 4.0, >= 2.7)
  rake (>= 0, development)
  spring (< 3.0, >= 1.2)

Gem sprockets-3.7.0
  closure-compiler (~> 1.1, development)
  coffee-script (~> 2.2, development)
  coffee-script-source (~> 1.6, development)
  concurrent-ruby (~> 1.0)
  eco (~> 1.0, development)
  ejs (~> 1.0, development)
  execjs (~> 2.0, development)
  minitest (~> 5.0, development)
  nokogiri (~> 1.3, development)
  rack (< 3, > 1)
  rack-test (~> 0.6, development)
  rake (~> 10.0, development)
  sass (~> 3.1, development)
  uglifier (~> 2.3, development)
  yui-compressor (~> 0.12, development)

Gem sprockets-3.7.1
  closure-compiler (~> 1.1, development)
  coffee-script (~> 2.2, development)
  coffee-script-source (~> 1.6, development)
  concurrent-ruby (~> 1.0)
  eco (~> 1.0, development)
  ejs (~> 1.0, development)
  execjs (~> 2.0, development)
  minitest (~> 5.0, development)
  nokogiri (~> 1.3, development)
  rack (< 3, > 1)
  rack-test (~> 0.6, development)
  rake (~> 10.0, development)
  sass (~> 3.1, development)
  uglifier (~> 2.3, development)
  yui-compressor (~> 0.12, development)

Gem sprockets-rails-3.2.0
  actionpack (>= 4.0)
  activesupport (>= 4.0)
  railties (>= 4.0, development)
  rake (>= 0, development)
  sass (>= 0, development)
  sprockets (>= 3.0.0)
  uglifier (>= 0, development)

Gem test-unit-3.2.3
  bundler (>= 0, development)
  kramdown (>= 0, development)
  packnga (>= 0, development)
  power_assert (>= 0)
  rake (>= 0, development)
  yard (>= 0, development)

Gem thin-1.7.0
  daemons (>= 1.0.9, ~> 1.0)
  eventmachine (>= 1.0.4, ~> 1.0)
  rack (< 3, >= 1)

Gem thor-0.19.1
  bundler (~> 1.0, development)

Gem thor-0.19.4
  bundler (~> 1.0, development)

Gem thread_safe-0.3.5
  atomic (= 1.1.16, development)
  minitest (>= 4, development)
  rake (>= 0, development)

Gem tilt-2.0.5

Gem ttfunk-1.4.0
  rake (>= 0, development)
  rdoc (>= 0, development)
  rspec (>= 0, development)
  rubocop (= 0.20.1, development)

Gem turbolinks-5.0.1
  turbolinks-source (~> 5)

Gem turbolinks-source-5.0.0

Gem tzinfo-1.2.2
  thread_safe (~> 0.1)

Gem uglifier-3.0.3
  bundler (~> 1.3, development)
  execjs (< 3, >= 0.3.0)
  rake (~> 11.3, development)
  rspec (~> 3.0, development)
  sourcemap (~> 0.1.1, development)

Gem web-console-3.4.0
  actionview (>= 5.0)
  activemodel (>= 5.0)
  debug_inspector (>= 0)
  railties (>= 5.0)

Gem websocket-driver-0.6.4
  eventmachine (>= 0, development)
  permessage_deflate (>= 0, development)
  rake-compiler (~> 0.8.0, development)
  rspec (>= 0, development)
  websocket-extensions (>= 0.1.0)

Gem websocket-extensions-0.1.2
  rspec (>= 0, development)

Gem will_paginate-3.1.5

Gem xmlrpc-0.2.1
  bundler (>= 0, development)
  rake (>= 0, development)
  test-unit (>= 0, development)

Gem zip-zip-0.3
  bundler (~> 1.6, development)
  minitest (= 4.7.5, development)
  pry (>= 0, development)
  rake (>= 0, development)
  rubyzip (>= 1.0.0)

How do I eliminate the dependency on this gem?  I thought deleting Gemfile.lock and trying again would work, but evidently, no dice.

A: Maybe one of your gems needs JSON-1.8.3 and has it as a dependency for itself.
Have you tried to comment half of your gems, then run bundle again, and so on until you don't find it in your dependencies anymore? (dichotomy)


text:
Q: Syncing Assets to AWS cloudfront with asset_sync gem syncing assets with s3 via asset_sync works seamlessly.
Is there a way to sync to cloudfront in a similar manner?

A: You probably wouldn't need to do anything special here. Cloudfront can be configured to "just work" for whatever happens to be in a given bucket. So you could use asset sync to keep things together and allow cloudfront to just pass all requests through to the synced bucket. You can see a bit about how to setup a distribution for cloudfront to point to a particular bucket here: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/GettingStarted.html


text:
Q: Deleting an answer should check for edits first Deleting an answer should check for edits, and abort if the answer has been edited since the page was loaded. If the answer has been edited, there's a significant chance that the reason for deleting the answer no longer applies.
I think this is most relevant for the moderator immediate answer delete action and convert to comment action. 20k deletion at least requires several people to see the answer, which reduces the risk of a deletion on obsolete grounds.
This isn't a theoretical concern: I'm posting this because it just happened to me.
This answer was originally just a reply to a comment on the question, and (correctly) flagged as "not an answer". A few minutes after I'd loaded the page, the author edited his post and turned it into a real answer. Then, I went and converted the answer into a comment, only to see that the answer had become a lot longer. I restored the answer, so I think there's no lasting harm done, but there should have been something to warn me I was acting on obsolete information.


text:
Q: Strange Azure Service bus behaviour - subscription #2 is receiving message while subscription #1 is not I am having some very strange issues with Azure Service Bus topic subscriptions. For the reference I have extracted the service bus topic configurations via service bus explorer and hoping somebody could point me into the right direction here. Really appreciate any help I can get.
Setup
I have 1 topic named topic2 and two subscription for this topic topicsub2 and topicsub3.
Issues
When publishing message to topic. Subscription topicsub3 recieves all messages that are sent while topicsub2 does not receive any messages. This behaviour is random, sometimes I would see messages in topicsub2 and sometimes the message is never delivered to the topicsub2 both subscriptions are using the same filters.
Followings are the few test scenarios that I have tried to figure out why this is happening.

*

*I tried removing the filter from topicsub2 and sending message. But this had no impact still no messages. My assumption is that if no filters are applied all message for the topic will be forwarded to the subscription.

*After removing the filter, I added default SQL filter (1=1) filter back to the subscription and tried sending message again it didn't work. I tried sending 5 messages to the topic, none of them appeared in the subscription topicsub2 and all were received by topicsub3.

*I restarted the console application receiver (console application that reads from topicsub2) and tried sending messages again. This time it worked.

*After about 10 mins, the subscription topicsub2 stopped receiving messages again.
Summary
This is where I am at. My investigation leads me this behaviour is random and there is some idling going on in topicsub2 that I am unaware of. Topicsub3 is working fine.
Can somebody please lead me into the right direction?
Following is the settings for topic 2 including the two subscriptions.
<?xml version="1.0" encoding="UTF-8"?>
<Entities xmlns="http://schemas.microsoft.com/servicebusexplorer" serviceBusNamespace="defaultstd">
   <Topics>
      <Topic>
         <DefaultMessageTimeToLive>14.00:00:00</DefaultMessageTimeToLive>
         <AutoDeleteOnIdle>10675199.02:48:05.4775807</AutoDeleteOnIdle>
         <MaxSizeInMegabytes>1024</MaxSizeInMegabytes>
         <RequiresDuplicateDetection>False</RequiresDuplicateDetection>
         <DuplicateDetectionHistoryTimeWindow>00:10:00</DuplicateDetectionHistoryTimeWindow>
         <Path>topic2</Path>
         <EnableBatchedOperations>True</EnableBatchedOperations>
         <SupportOrdering>False</SupportOrdering>
         <EnableFilteringMessagesBeforePublishing>True</EnableFilteringMessagesBeforePublishing>
         <IsAnonymousAccessible>False</IsAnonymousAccessible>
         <Status>Active</Status>
         <UserMetadata />
         <EnablePartitioning>True</EnablePartitioning>
         <EnableExpress>False</EnableExpress>
         <IsReadOnly>False</IsReadOnly>
         <Subscriptions>
            <Subscription>
               <LockDuration>00:00:30</LockDuration>
               <RequiresSession>False</RequiresSession>
               <DefaultMessageTimeToLive>14.00:00:00</DefaultMessageTimeToLive>
               <AutoDeleteOnIdle>10675199.02:48:05.4775807</AutoDeleteOnIdle>
               <EnableDeadLetteringOnMessageExpiration>True</EnableDeadLetteringOnMessageExpiration>
               <EnableDeadLetteringOnFilterEvaluationExceptions>True</EnableDeadLetteringOnFilterEvaluationExceptions>
               <TopicPath>topic2</TopicPath>
               <Name>topicsub2</Name>
               <MaxDeliveryCount>2</MaxDeliveryCount>
               <EnableBatchedOperations>False</EnableBatchedOperations>
               <Status>Active</Status>
               <ForwardTo />
               <ForwardDeadLetteredMessagesTo />
               <UserMetadata />
               <IsReadOnly>False</IsReadOnly>
               <Rules>
                  <Rule>
                     <Filter>
                        <SqlFilter>
                           <SqlExpression>sys.Label NOT IN  ('TestEvent')</SqlExpression>
                           <CompatibilityLevel>20</CompatibilityLevel>
                        </SqlFilter>
                     </Filter>
                     <Action>
                        <EmptyRuleAction />
                     </Action>
                     <Name>$Default</Name>
                     <IsReadOnly>True</IsReadOnly>
                  </Rule>
               </Rules>
            </Subscription>
            <Subscription>
               <LockDuration>00:00:30</LockDuration>
               <RequiresSession>False</RequiresSession>
               <DefaultMessageTimeToLive>14.00:00:00</DefaultMessageTimeToLive>
               <AutoDeleteOnIdle>10675199.02:48:05.4775807</AutoDeleteOnIdle>
               <EnableDeadLetteringOnMessageExpiration>True</EnableDeadLetteringOnMessageExpiration>
               <EnableDeadLetteringOnFilterEvaluationExceptions>True</EnableDeadLetteringOnFilterEvaluationExceptions>
               <TopicPath>topic2</TopicPath>
               <Name>topicsub3</Name>
               <MaxDeliveryCount>2</MaxDeliveryCount>
               <EnableBatchedOperations>False</EnableBatchedOperations>
               <Status>Active</Status>
               <ForwardTo />
               <ForwardDeadLetteredMessagesTo />
               <UserMetadata />
               <IsReadOnly>False</IsReadOnly>
               <Rules>
                  <Rule>
                     <Filter>
                        <SqlFilter>
                           <SqlExpression>sys.Label NOT IN  ('TestEvent')</SqlExpression>
                           <CompatibilityLevel>20</CompatibilityLevel>
                        </SqlFilter>
                     </Filter>
                     <Action>
                        <EmptyRuleAction />
                     </Action>
                     <Name>$Default</Name>
                     <IsReadOnly>True</IsReadOnly>
                  </Rule>
               </Rules>
            </Subscription>
         </Subscriptions>
      </Topic>
   </Topics>
</Entities>


text:
Q: How to Find Common Keys in an Array of Dictionaries in Python Given an array of dictionaries: [{'key1': 'valueA', 'key2': 'valueB'}, {'key1': 'valueC', 'key3': 'valueD'}, {}, ... ]
How would you find the most common keys among the dictionaries and rank them?
In this example the key of 'key1' appears twice, so this would be ranked number 1. Then if 'key2' would appear with the next common frequency, this would be ranked number 2, and so on.

A: Use this:
keys = dict()
# d is your dictionary
for i in d:
    for k, v in i.items():
        if k in keys:
            keys[k] += 1
        else:
            keys[k] = 1
max = 0
max_key = ''
for k, v in keys.items():
    if v > max:
        max = v
        max_key = k
print(max, max_key)

A: You can use pandas for that to parse the dict and then describe it to get stats.
import pandas as pd

lod = [{'points': 50, 'time': '5:00', 'year': 2010},
{'points': 25, 'time': '6:00', 'month': "february"},
{'points':90, 'time': '9:00', 'month': 'january'},
{'points_h1':20, 'month': 'june'}]

df = pd.DataFrame(lod)

print(df.describe(include=['float', 'object']))

'''
           points  time    year    month  points_h1
count    3.000000     3     1.0        3        1.0
unique        NaN     3     NaN        3        NaN
top           NaN  9:00     NaN  january        NaN
freq          NaN     1     NaN        1        NaN
mean    55.000000   NaN  2010.0      NaN       20.0
std     32.787193   NaN     NaN      NaN        NaN
min     25.000000   NaN  2010.0      NaN       20.0
25%     37.500000   NaN  2010.0      NaN       20.0
50%     50.000000   NaN  2010.0      NaN       20.0
75%     70.000000   NaN  2010.0      NaN       20.0
max     90.000000   NaN  2010.0      NaN       20.0
'''

Note however that this does not work with nested dictionaries! And you need to install pandas with pip.

A: is that your answer
from collections import Counter
d=[{'key1': 'valueA', 'key2': 'valueB'}, {'key1': 'valueC', 'key3': 'valueD'}, {'key1': 'valueC'}]
keys=[]
for i in d:
    for j in i.keys():
        keys.append(j)

Counter(keys)

output
Counter({'key1': 3, 'key2': 1, 'key3': 1})

A: You can use Counter to count that:
import collections

def count(array):
    counter = collections.Counter()
    for dict in array:
        counter.update(dict.keys())
    return counter

print(count([{'a': 1}, {'a': 2}])) # Counter({'a': 2})
print(count([{'f': 2}, {'f': '2'}, {'b': 10}])) # Counter({'f': 2, 'b': 1})

A: Another nice solution using pandas would be to convert the dictionaries in dataframes, merge them and then use value_counts. Here is a little example
import pandas as pd

d1 = {'key1': '1', 'key2': '2'}
d2 = {'key1': '1', 'key3': '3'}

df1 = pd.DataFrame.from_dict(d1.items())
df2 = pd.DataFrame.from_dict(d2.items())

frames = [df1, df2]
result = pd.concat(frames)
print(result[0].value_counts())

Which prints
key1    2
key2    1
key3    1
Name: 0, dtype: int64

A: # Extract the keys in a flat list
keys = [k for k, v in i.items for i in data]

# Sort and group
from itertools import sorted, groupby
s = sorted(keys)
g = groupby(s)

A: Another approach for using collections.Counter:
from collections import Counter
d=[{'key1': 'valueA', 'key2': 'valueB'}, {'key1': 'valueC', 'key3': 'valueD'}, {} ]
c = Counter(key for t in d for key in t.keys())

Outputs:
Counter({'key1': 2, 'key2': 1, 'key3': 1})

A: There are many ways you could do this, I assume one of the cleanest ways would be to use the Counter class, however I would do it the following way:
my_dicts = [{"hello": 2},{"hello1": 3, "hello": 5},{"hello2": 5, "hello": 7, "hello1": 4}]

merged = {}
for d in my_dicts:
  for k in d.keys():
    if k in merged:
      merged[k] += 1
    else:
      merged[k] = 1
results = {k: v for k, v in sorted(merged.items(), key=lambda item: item[1], reverse = True)}

The variable results ends up containing a dictionary of the sorted items in descending order, like such:
Output:
{'hello': 3, 'hello1': 2, 'hello2': 1}

A: Try this;
Code Syntax
dicts =[{'key1': 'valueA', 'key2': 'valueB'}, {'key1': 'valueC', 'key3': 'valueD'}]

lis = [list(dicts[i].keys()) for i in range(len(dicts))]
x = sorted([j for i in lis for j in i])
print(x)
for i, each in enumerate(x):
    if x[i-1] == x[i]:
        continue
    else:
        indey = x.count(x[x.index(each)])
        print(f"{each} = {indey}")

Output
['key1', 'key1', 'key2', 'key3']
key1 = 2
key2 = 1
key3 = 1

[Program finished]


text:
Q: Iterating through sub-array to check dates I have an employee database with multiple sets of date values. Currently I output this data in this format:
<% @trainings.each do |training| %>

    <%= training.birthday %>
    <%= training.comp_cert %>
    <%= training.cdl %>
    <%= training.forklift %>

<% end %>

I would like to iterate through these dates on each loop and check the dates against
Time.now + 30.days

but am having some issues. I've tried this:
<% @trainings.each do |training| %>
  <% training.each do |t| %>
    <% if t < Time.now + 30.days %>

    <% else %>

    <% end %>
  <% end %>

<% end %>

but it tells me there is no method called each on training. Is there a more efficient way of doing this rather than just manually checking each of the individual keys?

A: You can't iterate on a single object. You can use the iterator pattern only on the collection. I suggest the following approach, for starters :)
<% @trainings.each do |training| %>
  <% %w{birthday comp_cert cdl forklift}.each do |field_name| %>
    <% if training[field_name] < Time.now + 30.days %>

    <% else %>

    <% end %>
  <% end %>

<% end %>

A: You can use helper
def old_training?(training)
  %{birthday comp_cert cdl forklift}.any? { |field| training[field] < Time.now + 30.days }
end

and in view:
<% @trainings.each do |training| %>
    <tr class="<%= old_training?(training) ? "warning" : "success" %>">

<% end %>


text:
Q: Ajax post error with no futher information I need help with this stuff. Chrome doesn't have this problem, only Firefox. When I submit form, ajax creates tasks. My mysql queries ain't got any problems, I added tons of

if not working write mysql error into file

But all are successful. So here is the error
http://i.stack.imgur.com/KYq4L.jpg how to find out what the hell is this? My code of ajax is pure empty here it is:
$.ajax({
    type: "POST",
    url: '/modules/projects/ajax/ajax_import.php',
    data: {
        data: array,
        id: projectNow,
    }
});

Thats it.

A: First check ajax_import.php is available at this location or not.
/modules/projects/ajax/ajax_import.php
If file is exist at this location then just clear all content from there and just write test content as below.
<?php
    echo "testing";
?>


text:
Q: SLURM: How to submit a job to a remote slurm cluster from another server? I have the main server-'A' hosting the SLURM cluster. The set up is working fine as expected.
I wanted to know if there is a way to submit the jobs to that main server from another server- 'B' remotely and get the responses.
This situation arises because I don't want to give access to the terminal of the main server- 'A' to the users on 'B'.
I have gone through the documentation and FAQs, but unfortunately couldn't find the details.

A: If you install the Slurm client on Server B . Copy your slurm.conf to it and then ensure it has the correct authentication (i.e the correct Munge key) , it should work.


text:
Q: Which tables to store relational IDs in for joins (for best practice/efficiency) I'm a developer with limited experience of DB architecture. I just started to rough up what my DB for rethinkdb should look like and I came up with something like this:

*

*User

*

*Project IDs (including access level)

*...

*Project

*

*Or should this have User IDs (and access level)?

*Language IDs (1 to many)

*...

*Language

*

*Or should this have a Project ID instead?

*...

*Language Entry

*

*Language ID

*....

It occurred to me that the IDs which join the data could go in a couple of different places:

*

*Should a User hold the Projects they belong to and other data like access level, or should a Project hold the Users?

*Should the Project hold Language IDs, or should a Language hold the Project ID?

What's best practice/more efficient?
My guess is that it's more efficient to do:

*

*User access site, we know the Project IDs so can grab them

*Project IDs know the Language IDs so can grab them

*Language knows the Language Entry IDs so can grab them

Especially where there could be a LOT of Language Entries across all projects, my assumption is that it would be slow to iterate through them all looking for matching Language IDs.

A: This isn't really a matter of efficiency, it falls under the discipline of logic and physical data modelling. The relational database should be created so that it can accommodate the real world situations (like a car manufacturer having multiple car models), but also be constrained so that it prevents any situations that cannot exist in the real world (like a car model having two manufacturers).
Here's some logic to follow, based on understanding the real-world situation.

*

*If a language can only ever have one project, but a project can have many languages, then put project_id on languages. language belongs_to project and project has_many languages

*If a language can have many projects, but a project can only ever have one language, then put language_id on projects. language has_many projects and project has_many languages

*If a language can have many projects, and a project can have many languages, then create a new project_language model with both id's. language has_many projects through project_languages and project has_many languages through project_languages
I suspect that users and projects are in the third category, so you need the intermediate table, which could also store privileges.
With the correct associations, scopes etc. you'll then be able to do such magic as @user.projects, @project.users, @project.languages, @user.project_languages - @user.languages


text:
Q: Python SMTPLIB Gmail recipient security issues I am trying to send emails with already made Zip attachments and I am running into errors with gmail's security kicking them back. Originally I was using a gmail account to send the email, but I learned that gmail blocks that. So now I am using an outlook email. It sends the emails, which is an improvement, but my recipient emails (gmail) are returning the emails. How do people get around this? Surely there has to be a way to send zip files to gmail addresses. Here is my code:
UPDATE: I opened the returned email I sent - the attached file is a .bin file, not the .zip file. I may be misunderstanding the code and converting the zip file to binary rather than just attaching it.

def send_mail(zips_folder):
    import smtplib
    from email.mime.multipart import MIMEMultipart
    from email.mime.base import MIMEBase
    from email import encoders
    sender_email = "senderEmail@outlook.com"
    receiver_email ="receiverEmail@gmail.com"
    message = MIMEMultipart()
    message["From"] = sender_email
    message['To'] = receiver_email
    message['Subject'] = "subject"

    zf = open(r"C:\Users\Full File Path to Zip File\Zip File Name.zip",'rb')

    obj = MIMEBase('application', 'octet-stream')
    obj.set_payload(zf.read())
    encoders.encode_base64(obj)
    obj.add_header('Content-Disposition', "attachment; filename= " )
    message.attach(obj)
    my_message = message.as_string()
    email_session = smtplib.SMTP("smtp-mail.outlook.com", 587)
    email_session.starttls()
    email_session.login(sender_email, 'email password')
    email_session.sendmail(sender_email, receiver_email, my_message)
    email_session.quit()
    print("YOUR MAIL HAS BEEN SENT SUCCESSFULLY")


text:
Q: XQuery transform string into a datetime (exist-db) I am using XQuery 3.0 for exist-db, and am trying to make the string $value a dateTime object. This is what I've got, but it's not working:
let $value := '"2001-10-18T08:47:00"'

if ($key = 'start_time')
    then
        element { $key } { xs:dateTime(string(replace($value, '"', ''))) }

It's saying: illegal lexical form for date-time-like value ''. Any ideas?

A: I'm unable to reproduce the error you're getting with that code - which is incomplete (lacks return and else clauses, doesn't define $key). But paring those issues away, your code runs fine for me, as follows:
let $value := '"2001-10-18T08:47:00"'
return
    xs:dateTime(replace($value, '"', ''))

The result:
2001-10-18T08:47:00


text:
Q: Is this characteristic function zero-free in any strip? Consider a probability density $p(x) = c \frac{e^{-(x-\alpha)^2/(2 \beta^2)}}{x^2 + \gamma^2}$, with support $x \in (-\infty,\infty)$,
where $(\alpha,\beta,\gamma)$ are real constants (the last two strictly positive) and c the normalization constant.
I'm pretty sure the Fourier Transform $\hat{p}(z) = \int_{-\infty}^{\infty} e^{i z x} p(x) \, dx$ is an entire function of z, somewhat similar to the easy FT of the Gaussian density without the denominator. The latter is zero-free in the complex z-plane.
Is $\hat{p}(z)$ similarly zero-free in the whole $z$-plane or perhaps a strip? If so, how do I prove it?


text:
Q: calculating the Gamma function for negative real values (C++, Boost) The following infinite serious require the calculation of factorial for non-integer, negative, real numbers:

(it is a way to calculate the circumference of an ellipse, a and b are the semi-major and semi minor axis and h is defined as:
h = (a-b)^2/(a+b)^2)
The factorial function can be extended to negative values via the Gamma function which is defined for all the real numbers that are not negative integers.
While coding the serious I tried boost::math::factorial and boost::math::tgamma which gives results only down to -1 (not included) -1.5 for example give an error.
    #include <iostream>
    #include <boost/math/special_functions/factorials.hpp>

    int main()
    {
        double x;
        double f;
        double tg;

        x = -0.5;
        f = boost::math::factorial<double>(x);
        tg = boost::math::tgamma<double>(x);
        cout << "factorial of " << x << " = " << f << endl;
        cout << "tgamma of " << x << " = " << tg << endl << endl;

        x = -1.5;
        f = boost::math::factorial<double>(x);
        tg = boost::math::tgamma<double>(x);
        cout << "factorial of " << x << " = " << f << endl;
        cout << "tgamma of " << x << " = " << tg << endl << endl;

        return 0;
    }

the output:

factorial of -0.5 = 1
tgamma of -0.5 = -3.54491
terminate called after throwing an instance of 'boost::exception_detail::clone_implboost::exception_detail::error_info_injector<std::domain_error >'
what():  Error in function boost::math::tgamma(long double): Evaluation of tgamma at a negative integer 0.
Aborted (core dumped)

boost factorial:
boost factorial
boost tgamma:
boost tgamma
My questions:

*

*Is there an alternative to boost that can calculate the gamma function for its negative domain?

*I could not find in the boost documentation linked above mention of the implemented domain for factorials and tgamma functions. In fact I might simply be using them wrong. What is the way to ascertain what is indeed the domain/correct usage?

Thanks.

A: Gamma functions are part of the standard library since C++11 [1].
The usage is as follows:
#include <cmath>

std::tgamma(-0.5) # -3.5449077
std::lgamma(-0.5) # 1.2655121

You might as well use tgammal and tgammaf for long double and float types correspondingly.

*

*https://en.cppreference.com/w/cpp/numeric/math

A: I understand what's going wrong. The boost::math::factorial function takes an unsigned integer by definition:
template <class T>
inline T factorial(unsigned i)
{
   return factorial<T>(i, policies::policy<>());
}

This means that if you call it with a double, it will get implicitly converted to unsigned. That's not what you want. Also, factorial ends up using tgamma internally, so you get this:
#include <boost/math/special_functions/factorials.hpp>
#include <iostream>

void foo(long double x) {
    using namespace boost::math;
    try {
        auto f = factorial<long double>(x);
        std::cout << "factorial of " << static_cast<unsigned>(x) << " = " << f << "\n";
    } catch(std::exception const& e) {
        std::cout << "error at " << static_cast<unsigned>(x) << ": " << std::quoted(e.what()) << "\n";
    }
}

int main() {
    std::cout << std::unitbuf;
    foo(-2);
}

Will end up doing this:
#0  boost::math::tgamma<long double, boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> > (a=4294967295, z=...)
    at /home/sehe/custom/boost_1_73_0/boost/math/special_functions/gamma.hpp:1994
No locals.
#1  0x0000555555558eb3 in boost::math::factorial<long double, boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> > (i=4294967294, pol=...)
    at /home/sehe/custom/boost_1_73_0/boost/math/special_functions/factorials.hpp:44
        result = -0.667762310955655363645
#2  0x0000555555558674 in boost::math::factorial<long double> (i=4294967294)
    at /home/sehe/custom/boost_1_73_0/boost/math/special_functions/factorials.hpp:53
No locals.
#3  0x0000555555557792 in foo (x=-2) at /home/sehe/Projects/stackoverflow/test.cpp:7
        f = <invalid float value>
#4  0x000055555555791f in main () at /home/sehe/Projects/stackoverflow/test.cpp:16
No locals.

So it's attempting to give you boost::math::factorial<long double> (i=4294967294)
Fix
Don't use factorials for other than non-negative integers.
Live On Compiler Explorer
#include <boost/math/special_functions/factorials.hpp>
#include <iostream>

void foo(long double x) {
    using namespace boost::math;
    try {
        auto tg = tgamma<long double>(x);
        std::cout << "tgamma    of " << x << " = " << tg << "\n" << std::endl;
    } catch(std::exception const& e) {
        std::cout << "error at " << x << ": " << std::quoted(e.what()) << std::endl;
    }
}

int main() {
    for (auto x : { 1., 2., 3., 4., 5., -.2, -2., -.5, -1.5 })
        foo(x);
}

Prints:
tgamma    of 1 = 1

tgamma    of 2 = 1

tgamma    of 3 = 2

tgamma    of 4 = 6

tgamma    of 5 = 24

tgamma    of -0.2 = -5.82115

error at -2: "Error in function boost::math::tgamma<long double>(long double): Evaluation of tgamma at a negative integer -2."
tgamma    of -0.5 = -3.54491

tgamma    of -1.5 = 2.36327

It understandably overflows at -2, but that's correct.

A: I just tried to reproduce your problem using g++-10 on Mac, using boost.math commit hash 87929356790ad0 (current develop), but I get:
factorial of -0.5 = 1
tgamma of -0.5 = -3.54491

factorial of -1.5 = 1
tgamma of -1.5 = 2.36327

So more information is necessary, Boost version, OS, compiler, so on.


text:
Q: hello Deserialize nested JSON into C# objects "Data": [{
    "timeLive": "74",
    "halfTimeScore": "0 - 0",
    "fullTimeScore": null,
    "firstTeamToScore": null,
    "homeTeamInfo": {
        "homeTeam": "Atlético Mineiro",
        "homeGoals": "0",
        "homeGoalsHalfTime": "0",
        "homeCorners": "9",
        "homeYellowCards": "1",
        "homeRedCards": "0",
        "homeShotsGol": "3",
        "homeShotsFora": "9",
        "homeAttacks": "131",
        "homeDangerousAttack": "49",
        "homePossession": "74",
        "homeFouls": 13,
        "avgGoalsHome": 2.1,
        "teamID": "43669",
        "homeTeamForm": {
            "position": "6",
            "points": "33",
            "form": [
                "W",
                "D",
                "L",
                "W",
                "W"
            ]
        }
    },
    "awayTeamInfo": {
        "awayTeam": "Vasco da Gama",
        "awayGoals": "0",
        "awayGoalsHalfTime": "0",
        "awayCorners": "1",
        "awayYellowCards": "3",
        "awayRedCards": "0",
        "awayShotsGol": "3",
        "awayShotsFora": "4",
        "awayAttacks": "58",
        "awayDangerousAttack": "21",
        "awayPossession": "26",
        "awayFouls": 14,
        "avgGoalsAway": 0.9,
        "teamID": "43663",
        "awayTeamForm": {
            "position": "15",
            "points": "20",
            "form": [
                "W",
                "L",
                "L",
                "L",
                "D"
            ]
        }
    },
    "head2head": {
        "draws": 3,
        "homeWins": 6,
        "awayWins": 6,
        "avgGolsH2H": 2.3
    },
    "matchEvents": [{
            "eventName": "Card",
            "eventType": "Yellow card",
            "eventTeam": "Away",
            "eventTime": 72,
            "eventPlayer": {
                "playerName": "Martín Silva",
                "playerShortName": "M. Silva",
                "playerID": "547DD"
            },
            "eventSubIn": null,
            "eventSubOut": null,
            "eventHomeTeam": false
        }
]

i have the class but i don t know how to convert from json to gridview
can some one help with an exemple

A: If you want to do this on server side, here is the solution you need.
As your said, you have class ready or you can create class for your json using http://json2csharp.com (generate c# classes from json)
public class HomeTeamForm
{
    public string position { get; set; }
    public string points { get; set; }
    public List<string> form { get; set; }
}

public class HomeTeamInfo
{
    public string homeTeam { get; set; }
    public string homeGoals { get; set; }
    public string homeGoalsHalfTime { get; set; }
    public string homeCorners { get; set; }
    public string homeYellowCards { get; set; }
    public string homeRedCards { get; set; }
    public string homeShotsGol { get; set; }
    public string homeShotsFora { get; set; }
    public string homeAttacks { get; set; }
    public string homeDangerousAttack { get; set; }
    public string homePossession { get; set; }
    public int homeFouls { get; set; }
    public double avgGoalsHome { get; set; }
    public string teamID { get; set; }
    public HomeTeamForm homeTeamForm { get; set; }
}

public class AwayTeamForm
{
    public string position { get; set; }
    public string points { get; set; }
    public List<string> form { get; set; }
}

public class AwayTeamInfo
{
    public string awayTeam { get; set; }
    public string awayGoals { get; set; }
    public string awayGoalsHalfTime { get; set; }
    public string awayCorners { get; set; }
    public string awayYellowCards { get; set; }
    public string awayRedCards { get; set; }
    public string awayShotsGol { get; set; }
    public string awayShotsFora { get; set; }
    public string awayAttacks { get; set; }
    public string awayDangerousAttack { get; set; }
    public string awayPossession { get; set; }
    public int awayFouls { get; set; }
    public double avgGoalsAway { get; set; }
    public string teamID { get; set; }
    public AwayTeamForm awayTeamForm { get; set; }
}

public class Head2head
{
    public int draws { get; set; }
    public int homeWins { get; set; }
    public int awayWins { get; set; }
    public double avgGolsH2H { get; set; }
}

public class EventPlayer
{
    public string playerName { get; set; }
    public string playerShortName { get; set; }
    public string playerID { get; set; }
}

public class MatchEvent
{
    public string eventName { get; set; }
    public string eventType { get; set; }
    public string eventTeam { get; set; }
    public int eventTime { get; set; }
    public EventPlayer eventPlayer { get; set; }
    public object eventSubIn { get; set; }
    public object eventSubOut { get; set; }
    public bool eventHomeTeam { get; set; }
}

public class RootObject : List<RootObject>
{
    public string timeLive { get; set; }
    public string halfTimeScore { get; set; }
    public object fullTimeScore { get; set; }
    public object firstTeamToScore { get; set; }
    public HomeTeamInfo homeTeamInfo { get; set; }
    public AwayTeamInfo awayTeamInfo { get; set; }
    public Head2head head2head { get; set; }
    public List<MatchEvent> matchEvents { get; set; }
}

Now you need to Deserialize json to the class.
RootObject myCShartData = new JavaScriptSerializer().Deserialize<RootObject>(json);

Now you are ready to bind gridview using myCShartData variable
I hope you will be helpful


text:
Q: Inducing sane multiple assertions with integration tests I have came across many resources which talk about using/not using multiple assertions during unit testing. But while writing UI level automation integration tests I end up in doing many assertion in one test, which does not seem very bad idea to me, especially when I use soft assertions which fail only during tear down and reporting all assertion failures in a test method, instead of limiting it to one report per test.
One such scenarios is filling a form having 10 fields (text box, drop down etc). Coming back to the form and verifying all entered values are available. What I don't like with my tests is, it is filled with many assertions. I want to assert all of these values but yet want my tests to look clean and not like -
 public void testMethod() {
  // Some operation here
  softAssert("verification failed for field 1, expected value:" +value, isValuePresent(value));
  softAssert("verification failed for field 2, expected value:" +value, isValuePresent(value));
  softAssert("verification failed for field 3, expected value:" +value, isValuePresent(value));
  // Some more assertions here
}

I could extract these assertions to a different method but then I feel that assertions should be kept in test methods. to make it clear what is being tested in a test method.
Is just a trivial wishy washy feeling I have and such design of tests is justified? Or
I could make design enhancements in my test methods.

A: you can do what I'd call "assertion by example" which is simply an assertion at the form level.  It would look something like this:
public void testMethod() {
  Form expected = new Form()
                    .field1('value1')
                    .field2('value2')
                    .field3('value3')
                    .field4('value4')

  Form result = someFormOperation();

  softAssert(expected, result);

}

A: I often call toString() on some of the results and assertEquals to the correct result.  If your underlying objects implement a reasonable toString (or a toXML etc.) That simplifies the test code.  But it's less robust to future changes.


text:
Q: Constraint to not allow a number to be more than one time in a column I'm developing a solution with SQL Server 2012 SP2.
I'm wondering if I can do the following adding some kind of restriction to a table's column.
I will have a column that can store tinyint values (from 1 to 5). This table will have a lot of rows.
The restriction is that you can have number 5 repeated more than one time, but the rest of the numbers couldn't be repeated. In other words, only one row could have number 1, only one row could have number 2, or 3 or 4. But many rows could have number 5.
Is there anyway to do that in SQL? (like an UNIQUE constraint).
Now I'm doing it in a stored procedure doing select count() ... and if statements.

A: What you need is a unique filtered index:
CREATE UNIQUE NONCLUSTERED INDEX IDX_UQ_Col
ON mytable(myCol)
WHERE myCol <> 5


text:
Q: Pandas aggregate with function with multiple parameters df = pd.DataFrame({'a': list('aabb'), 'b': [1, 2, 3, 4], 'c': [4, 2, 1, 3]})

def agg_func(x, y):
    return sum(x) > sum(y)

I need smth like that
df.groupby('a').agg({('b', 'c'): agg_func})

And expect

A: Here I would simple aggregate the columns, and then perform the comparison:
g = df.groupby('a').sum()
out = g['b']>g['c']

With your function (probably less efficient):
out = df.groupby('a').apply(lambda g: agg_func(g['b'], g['c']))

output:
a    False
b     True
dtype: bool


text:
Q: how to download and display server images if scrolldown the scrollview in iphone I am new to iPhone programming.
Using below code I can able to download and displaying all images form server. But in server I have more than some 1000s of images are there. so Using below code I can able to download and displaying in scrollview as 3*3 thumbnail.
But what I want means first I have to download and display 15 images in scrollview as 3*3 thumbnail.
If I scroll down means i have to show activity indicator then download next form 16 to 30 images, similarly again if I scroll means I want to download and display 31 to 45 images in thumbnail.
I dont want to download all images form server.
Can any tell me please how can I do this.
- (void)viewDidLoad
{
    URLs = [[NSMutableArray alloc]init];

    for (NSString *path in latestiamge)
    {
        NSURL *URL = [NSURL URLWithString:path];

        if (URL)
        {
            [URLs addObject:URL];
        }
        else
        {
            NSLog(@"'%@' is not a valid URL", path);
        }
    }

    self.imageURLs = URLs;

    myScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0.0, 84.0, 320.0, 840.0)];
    myScrollView.delegate = self;
    myScrollView.contentSize = CGSizeMake(320.0, 840.0);
    myScrollView.backgroundColor = [UIColor whiteColor];

    [self.view addSubview:myScrollView];

    float horizontal = 2.0;
    float vertical = 2.0;

    for(int i=0; i<[imageURLs count]; i++)
    {
        if((i%3) == 0 && i!=0)
        {
            horizontal = 5.0;
            vertical = vertical + 100.0 + 5.0;
        }

        CGRect frame;
        frame.size.width=100.0;
        frame.size.height=100.0;
        frame.origin.x=0;
        frame.origin.y=0;

        AsyncImageView *imageView = [[AsyncImageView alloc] initWithFrame:frame];
        imageView.contentMode = UIViewContentModeScaleAspectFill;
        imageView.clipsToBounds = YES;
        imageView.tag = i;
        UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc]
                                             initWithTarget:self
                                             action:@selector(actionHandleTapOnImageView:)];

        imageView.userInteractionEnabled = YES;
        [imageView addGestureRecognizer:singleTap];

        [myScrollView addSubview:imageView];
        [myScrollView addSubview:imageView];

        horizontal = horizontal + 100.0 + 5.0;
    }

    [myScrollView setContentSize:CGSizeMake(320.0, vertical + 3900.0)];

    [super viewDidLoad];
}

A: Well there is a good and basic class you can use for downloading and displaying images asynchronously .
SDWebImage

A: Doing everything yourself as you currently are is more effort than is required and not good for memory management. Consider using a table or collection view to manage the scrolling so you don't have so many views loaded at the same time and so you don't need code for the full layout of everything.
You're already using AsyncImageView, it will work if you add a number of them to the cells you're going to display and configure them as requested by the delegate/dataSource methods.
You should also think about acting as the scroll view delegate and monitoring the scroll completion. If the user has scrolled to the current bottom, you could add a footer view with an activity indicator, start a load of the next page from the server and then reload the view and remove the footer when the new page is downloaded.

A: From what I can understand from your question, you want to create a image grid with three images in a row. But your approach is wrong...!
Do not use scrollView but use a UITableView. I think you can use UICollectionView if you are targeting iOS 6.0 or above.
Here is what you need to do :

*

*Create custom UITableViewCell with number of images you need in a row. You can make this dynamic too by passing number of grid items you need while creating the cell and creating the and positioning those views in the cell as subviews.

*Reuse the cells in the table to populate the grid.

*You can cache images for better performance, I would suggest you to use SDWebImage

*In cellForRowAtIndexPath you can configure all the gridItems.

Do you need more help...??


text:
Q: Django: put offline a post after an event I'm trying to put offline the posts after an event, a definite date. I've developed a simple model for test my aim and inside the model I've put a function(named is_expired) that, ideally, must define if a post is or not is online. Below there is the model:
from django.db import models
from django.utils import timezone
import datetime

class BlogPost(models.Model):
    CHOICHES = (
        ("Unselected", "Unselected"),
        ("One Month", "One Month"),
        ("One Year", "One Year"),
        )

    title = models.CharField(
        max_length=70,
        unique=True,
        )
    membership = models.CharField(
        max_length=50,
        choices=CHOICHES,
        default="Unselected",
        )
    publishing_date = models.DateTimeField(
                        default=timezone.now,
                        )

    def __str__(self):
        return self.title

    @property
    def is_future(self):
        if self.publishing_date > datetime.datetime.now():
            return True
        return False

    @property
    def is_expired(self):
        if self.membership == "One Month":
            def monthly(self):
                if publishing_date + datetime.timedelta(days=30) <= datetime.datetime.now():
                    return True
        if self.membership == "One Year":
            def yearly(self):
                if publishing_date + datetime.timedelta(days=365) <= datetime.datetime.now():
                    return True
        return False

    class Meta:
        ordering = ['-publishing_date']

For show a list of all expired posts I use this simple template:
{% for p in posts_list %}
  {% if p.is_future or p.is_expired %}

{{ p.title }}

Data di pubblicazione: {{ p.publishing_date|date:"d - M - Y | G:i:s" }}

    {% if p.is_expired %}

Expired? Yes

    {% else %}

Expired? No

    {% endif %}

  {% endif %}
{% empty %}

No posts!

{% endfor %}

The problem is that I don't see the expired posts but only the future posts(with function named is_future), inside the console there are no errors and then I don't now where is the error.
I'm newbie whit use of Python and Django.
Someone can indicate to me the error?
UPDATE:
views.py
def listPosts(request):
    posts_list = BlogPost.objects.all()
    context = {"posts_list": posts_list}
    template = 'blog/reading/list_post.html'
    return render(request, template, context)

A: Your is_expired() method always returns False. Inside the method, you define two inner function (monthly and yearly) but never call them. Those inner functions are actually useless, you want:
@property
def is_expired(self):
    if self.membership == "One Month":
        if self.publishing_date + datetime.timedelta(days=30) <= datetime.datetime.now():
            return True
    elif self.membership == "One Year":
        if self.publishing_date + datetime.timedelta(days=365) <= datetime.datetime.now():
            return True
    return False


text:
Q: What is the quickest way to convert a large XML file into a SQLite file? I am retrieving data from an XML file but the file contains more than 15000 records, so my application is getting slowed. So I want to convert it into SQLLite file (by using programmatically or by using any tool).
Please provide me any solution for it.

A: I would suggest using Core Data. Parse the date, create managed objects and let Core Data persist those objects to a sqlite database.
The the following benefit will be, that you don't have to care for sql statements later on.
To prepopulate the core data db read this article. I'd write a simple xml2sqlite importer like in Ruby or PHP.
If you are not a friend of scripting languages then have a look at SQLite Manager it's a Firefox Plugin to manage SQLite database and it's capable of importing XML.