STM32F103C8T6 doesn't work after reset button

I have "Minimum System Development Board for ARM Microcontroller – STM32F103C8T6" with ST-LINK V2.
This is the main code followed by  linker-script then startup:

1) main:

@@@ Directives
        .thumb                  @ (same as saying '.code 16')
        .syntax unified
        .cpu cortex-m3
        .fpu softvfp
        .include    "stm32f103.i"
        .section .text
        .org 0x00
        .global main

        .equ GPIOC_CRL ,GPIOC_BASE
        .equ GPIOC_CRH ,GPIOC_BASE + 0x04
        .equ GPIOC_ODR ,GPIOC_BASE + 0x0C
        .equ RCC_APB2ENR ,RCC_BASE + 0x14
        .equ LEDDELAY ,800000

main:
        @@ Enable the Port C peripheral clock
        ldr r6, = RCC_APB2ENR
        mov r0, RCC_APB2ENR_IOPCEN
        str r0, [r6]

        @@ Set the config and mode bits for Port C bin 15 so it will
        @@ be a push-pull output (up to 50 MHz)
        @@ to '0011'.

        ldr r6, = GPIOC_CRH
        ldr r0, = 0x34444444
        str r0, [r6]

        @@ Load R2 and R3 with the "on" and "off" constants
        mov r2, 0x8000          @ value to turn on LED
        mov r3, 0x0             @ value to turn off LED

        ldr r6, = GPIOC_ODR     @  point to Port C output data register

loop:
        str r2, [r6]           @ clear Port C, pin 15, turning on LED
        ldr r1, = LEDDELAY
delay1:
        subs r1, 1
        bne delay1

        str r3, [r6]           @ set Port C, pin 15, turning off LED
        ldr r1, = LEDDELAY
delay2:
        subs r1, 1
        bne delay2

        b loop                 @ continue forever

    @@st-flash write forth.bin 0x08000000

2) linker:

/*
*****************************************************************************
**

**  File        : LinkerScript.ld
**
**  Abstract    : Linker script for STM32F103C8Tx Device with
**                64KByte FLASH, 20KByte RAM
**
**                Set heap size, stack size and stack location according
**                to application requirements.
**
**                Set memory bank area and size if external memory is used.
**
**  Target      : STMicroelectronics STM32
**
**
**  Distribution: The file is distributed as is, without any warranty
**                of any kind.
 */
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
/* Entry Point */
ENTRY(Reset_Handler)

/* Specify the memory areas */
MEMORY
{
    FLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 64K
    RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 20K
}
/* The size of the stack used by the application. NOTE: you need to adjust  */
STACK_SIZE = 256;

/* The size of the heap used by the application. NOTE: you need to adjust   */
HEAP_SIZE = 0;

SECTIONS
{
    .isr_vector : {        /* the vector table goes FIRST into FLASH */
        KEEP(*(.isr_vector)) /* vector table */
        . = ALIGN(4);
    } >FLASH

    .text : {              /* code and constants */
        . = ALIGN(4);
        *(.text)           /* .text sections (code) */
        *(.text*)          /* .text* sections (code) */
        *(.rodata)         /* .rodata sections (constants, strings, etc.) */
        *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */

        KEEP (*(.init))
        KEEP (*(.fini))

        . = ALIGN(4);
    } >FLASH

    .preinit_array : {
        PROVIDE_HIDDEN (__preinit_array_start = .);
        KEEP (*(.preinit_array*))
        PROVIDE_HIDDEN (__preinit_array_end = .);
    } >FLASH

    .init_array : {
        PROVIDE_HIDDEN (__init_array_start = .);
        KEEP (*(SORT(.init_array.*)))
        KEEP (*(.init_array*))
        PROVIDE_HIDDEN (__init_array_end = .);
    } >FLASH

    .fini_array : {
        PROVIDE_HIDDEN (__fini_array_start = .);
        KEEP (*(.fini_array*))
        KEEP (*(SORT(.fini_array.*)))
        PROVIDE_HIDDEN (__fini_array_end = .);
    } >FLASH

    _etext = .;            /* global symbols at end of code */

    .stack : {
        __stack_start__ = .;
        . = . + STACK_SIZE;
        . = ALIGN(4);
        __stack_end__ = .;
    } >RAM

    .data :  AT (_etext) {
        __data_load = LOADADDR (.data);
        __data_start = .;
        *(.data)           /* .data sections */
        *(.data*)          /* .data* sections */
        . = ALIGN(4);
        __data_end__ = .;
        _edata = __data_end__;
    } >RAM

    .bss : {
        __bss_start__ = .;
        *(.bss)
        *(.bss*)
        *(COMMON)
        . = ALIGN(4);
        _ebss = .;         /* define a global symbol at bss end */
        __bss_end__ = .;
    } >RAM

    PROVIDE ( end = _ebss );
    PROVIDE ( _end = _ebss );
    PROVIDE ( __end__ = _ebss );

    .heap : {
        __heap_start__ = .;
        . = . + HEAP_SIZE;
        . = ALIGN(4);
        __heap_end__ = .;
    } >RAM

    /* Remove information from the standard libraries
    /DISCARD/ : {
        libc.a ( * )
        libm.a ( * )
        libgcc.a ( * )
    }
  /*.ARM.attributes 0 : { *(.ARM.attributes) }*/
}

3) startup:

    /**
      *************** (C) COPYRIGHT 2016 STMicroelectronics ************************
      * @file      startup_stm32f103xb.s
      * @author    MCD Application Team
      * @version   V4.1.0
      * @date      29-April-2016
      * @brief     STM32F103xB Devices vector table for Atollic toolchain.
      *            This module performs:
      *                - Set the initial SP
      *                - Set the initial PC == Reset_Handler,
      *                - Set the vector table entries with the exceptions ISR address
      *                - Configure the clock system
      *                - Branches to main in the C library (which eventually
      *                  calls main()).
      *            After Reset the Cortex-M3 processor is in Thread mode,
      *            priority is Privileged, and the Stack is set to Main.
      ******************************************************************************
      */

        .syntax unified
        .cpu cortex-m3
        .fpu softvfp
        .thumb
        .global __stack_start__
        .global __stack_end__
        .global g_pfnVectors
        .global Default_Handler

    /* start address for the initialization values of the .data section.
    defined in linker script */
    .word __data_load
    /* start address for the .data section. defined in linker script */
    .word __data_start
    /* end address for the .data section. defined in linker script */
    .word __data_end__
    /* start address for the .bss section. defined in linker script */
    .word __bss_start__
    /* end address for the .bss section. defined in linker script */
    .word __bss_end__

    .equ  BootRAM, 0xF108F85F
    /**
     * @brief  This is the code that gets called when the processor first
     *          starts execution following a reset event. Only the absolutely
     *          necessary set is performed, after which the application
     *          supplied main() routine is called.
     * @param  None
     * @retval : None
    */

      .section .text.Reset_Handler
      .weak Reset_Handler
      .type Reset_Handler, %function
    Reset_Handler:

    /* Copy the data segment initializers from flash to SRAM */
      movs r1, #0
      b LoopCopyDataInit

    CopyDataInit:
      ldr r3, =__data_load
      ldr r3, [r3, r1]
      str r3, [r0, r1]
      adds r1, r1, #4

    LoopCopyDataInit:
      ldr r0, =__data_start
      ldr r3, =__data_end__
      adds r2, r0, r1
      cmp r2, r3
      bcc CopyDataInit
      ldr r2, =__bss_start__
      b LoopFillZerobss
    /* Zero fill the bss segment. */
    FillZerobss:
        movs r3, #0
        str r3, [r2], #4

    LoopFillZerobss:
      ldr r3, =__bss_end__
      cmp r2, r3
      bcc FillZerobss

    /* Call the clock system intitialization function.*/
        /*bl  SystemInit*/
    /* Call static constructors */
        /*bl __libc_init_array*/
    /* Call the application's entry point.*/
      bl main
      bx lr
    .size Reset_Handler, .-Reset_Handler

    /**
     * @brief  This is the code that gets called when the processor receives an
     *         unexpected interrupt.  This simply enters an infinite loop, preserving
     *         the system state for examination by a debugger.
     *
     * @param  None
     * @retval : None
    */
        .section .text.Default_Handler,"ax",%progbits
    Default_Handler:
    Infinite_Loop:
      b Infinite_Loop
      .size Default_Handler, .-Default_Handler
    /******************************************************************************
    *
    * The minimal vector table for a Cortex M3.  Note that the proper constructs
    * must be placed on this to ensure that it ends up at physical address
    * 0x0000.0000.
    *
    ******************************************************************************/
      .section .isr_vector,"a",%progbits
      .type g_pfnVectors, %object
      .size g_pfnVectors, .-g_pfnVectors

    g_pfnVectors:

      .word __stack_end__
      .word Reset_Handler
      .word NMI_Handler
      .word HardFault_Handler
      .word MemManage_Handler
      .word BusFault_Handler
      .word UsageFault_Handler
      .word 0
      .word 0
      .word 0
      .word 0
      .word SVC_Handler
      .word DebugMon_Handler
      .word 0
      .word PendSV_Handler
      .word SysTick_Handler
      .word WWDG_IRQHandler
      .word PVD_IRQHandler
      .word TAMPER_IRQHandler
      .word RTC_IRQHandler
      .word FLASH_IRQHandler
      .word RCC_IRQHandler
      .word EXTI0_IRQHandler
      .word EXTI1_IRQHandler
      .word EXTI2_IRQHandler
      .word EXTI3_IRQHandler
      .word EXTI4_IRQHandler
      .word DMA1_Channel1_IRQHandler
      .word DMA1_Channel2_IRQHandler
      .word DMA1_Channel3_IRQHandler
      .word DMA1_Channel4_IRQHandler
      .word DMA1_Channel5_IRQHandler
      .word DMA1_Channel6_IRQHandler
      .word DMA1_Channel7_IRQHandler
      .word ADC1_2_IRQHandler
      .word USB_HP_CAN1_TX_IRQHandler
      .word USB_LP_CAN1_RX0_IRQHandler
      .word CAN1_RX1_IRQHandler
      .word CAN1_SCE_IRQHandler
      .word EXTI9_5_IRQHandler
      .word TIM1_BRK_IRQHandler
      .word TIM1_UP_IRQHandler
      .word TIM1_TRG_COM_IRQHandler
      .word TIM1_CC_IRQHandler
      .word TIM2_IRQHandler
      .word TIM3_IRQHandler
      .word TIM4_IRQHandler
      .word I2C1_EV_IRQHandler
      .word I2C1_ER_IRQHandler
      .word I2C2_EV_IRQHandler
      .word I2C2_ER_IRQHandler
      .word SPI1_IRQHandler
      .word SPI2_IRQHandler
      .word USART1_IRQHandler
      .word USART2_IRQHandler
      .word USART3_IRQHandler
      .word EXTI15_10_IRQHandler
      .word RTC_Alarm_IRQHandler
      .word USBWakeUp_IRQHandler
      .word 0
      .word 0
      .word 0
      .word 0
      .word 0
      .word 0
      .word 0
      .word BootRAM          /* @0x108. This is for boot in RAM mode for
                                STM32F10x Medium Density devices. */

    /*******************************************************************************
    *
    * Provide weak aliases for each Exception handler to the Default_Handler.
    * As they are weak aliases, any function with the same name will override
    * this definition.
    *
    *******************************************************************************/

      .weak NMI_Handler
      .thumb_set NMI_Handler,Default_Handler

      .weak HardFault_Handler
      .thumb_set HardFault_Handler,Default_Handler

      .weak MemManage_Handler
      .thumb_set MemManage_Handler,Default_Handler

      .weak BusFault_Handler
      .thumb_set BusFault_Handler,Default_Handler

      .weak UsageFault_Handler
      .thumb_set UsageFault_Handler,Default_Handler

      .weak SVC_Handler
      .thumb_set SVC_Handler,Default_Handler

      .weak DebugMon_Handler
      .thumb_set DebugMon_Handler,Default_Handler

      .weak PendSV_Handler
      .thumb_set PendSV_Handler,Default_Handler

      .weak SysTick_Handler
      .thumb_set SysTick_Handler,Default_Handler

      .weak WWDG_IRQHandler
      .thumb_set WWDG_IRQHandler,Default_Handler

      .weak PVD_IRQHandler
      .thumb_set PVD_IRQHandler,Default_Handler

      .weak TAMPER_IRQHandler
      .thumb_set TAMPER_IRQHandler,Default_Handler

      .weak RTC_IRQHandler
      .thumb_set RTC_IRQHandler,Default_Handler

      .weak FLASH_IRQHandler
      .thumb_set FLASH_IRQHandler,Default_Handler

      .weak RCC_IRQHandler
      .thumb_set RCC_IRQHandler,Default_Handler

      .weak EXTI0_IRQHandler
      .thumb_set EXTI0_IRQHandler,Default_Handler

      .weak EXTI1_IRQHandler
      .thumb_set EXTI1_IRQHandler,Default_Handler

      .weak EXTI2_IRQHandler
      .thumb_set EXTI2_IRQHandler,Default_Handler

      .weak EXTI3_IRQHandler
      .thumb_set EXTI3_IRQHandler,Default_Handler

      .weak EXTI4_IRQHandler
      .thumb_set EXTI4_IRQHandler,Default_Handler

      .weak DMA1_Channel1_IRQHandler
      .thumb_set DMA1_Channel1_IRQHandler,Default_Handler

      .weak DMA1_Channel2_IRQHandler
      .thumb_set DMA1_Channel2_IRQHandler,Default_Handler

      .weak DMA1_Channel3_IRQHandler
      .thumb_set DMA1_Channel3_IRQHandler,Default_Handler

      .weak DMA1_Channel4_IRQHandler
      .thumb_set DMA1_Channel4_IRQHandler,Default_Handler

      .weak DMA1_Channel5_IRQHandler
      .thumb_set DMA1_Channel5_IRQHandler,Default_Handler

      .weak DMA1_Channel6_IRQHandler
      .thumb_set DMA1_Channel6_IRQHandler,Default_Handler

      .weak DMA1_Channel7_IRQHandler
      .thumb_set DMA1_Channel7_IRQHandler,Default_Handler

      .weak ADC1_2_IRQHandler
      .thumb_set ADC1_2_IRQHandler,Default_Handler

      .weak USB_HP_CAN1_TX_IRQHandler
      .thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler

      .weak USB_LP_CAN1_RX0_IRQHandler
      .thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler

      .weak CAN1_RX1_IRQHandler
      .thumb_set CAN1_RX1_IRQHandler,Default_Handler

      .weak CAN1_SCE_IRQHandler
      .thumb_set CAN1_SCE_IRQHandler,Default_Handler

      .weak EXTI9_5_IRQHandler
      .thumb_set EXTI9_5_IRQHandler,Default_Handler

      .weak TIM1_BRK_IRQHandler
      .thumb_set TIM1_BRK_IRQHandler,Default_Handler

      .weak TIM1_UP_IRQHandler
      .thumb_set TIM1_UP_IRQHandler,Default_Handler

      .weak TIM1_TRG_COM_IRQHandler
      .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler

      .weak TIM1_CC_IRQHandler
      .thumb_set TIM1_CC_IRQHandler,Default_Handler

      .weak TIM2_IRQHandler
      .thumb_set TIM2_IRQHandler,Default_Handler

      .weak TIM3_IRQHandler
      .thumb_set TIM3_IRQHandler,Default_Handler

      .weak TIM4_IRQHandler
      .thumb_set TIM4_IRQHandler,Default_Handler

      .weak I2C1_EV_IRQHandler
      .thumb_set I2C1_EV_IRQHandler,Default_Handler

      .weak I2C1_ER_IRQHandler
      .thumb_set I2C1_ER_IRQHandler,Default_Handler

      .weak I2C2_EV_IRQHandler
      .thumb_set I2C2_EV_IRQHandler,Default_Handler

      .weak I2C2_ER_IRQHandler
      .thumb_set I2C2_ER_IRQHandler,Default_Handler

      .weak SPI1_IRQHandler
      .thumb_set SPI1_IRQHandler,Default_Handler

      .weak SPI2_IRQHandler
      .thumb_set SPI2_IRQHandler,Default_Handler

      .weak USART1_IRQHandler
      .thumb_set USART1_IRQHandler,Default_Handler

      .weak USART2_IRQHandler
      .thumb_set USART2_IRQHandler,Default_Handler

      .weak USART3_IRQHandler
      .thumb_set USART3_IRQHandler,Default_Handler

      .weak EXTI15_10_IRQHandler
      .thumb_set EXTI15_10_IRQHandler,Default_Handler

      .weak RTC_Alarm_IRQHandler
      .thumb_set RTC_Alarm_IRQHandler,Default_Handler

      .weak USBWakeUp_IRQHandler
      .thumb_set USBWakeUp_IRQHandler,Default_Handler

       .align
    /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

When I try to flash this code with

st-flash write main.bin 0x08000000

I get the following :

st-flash 1.3.1
2017-07-03T21:42:39 INFO src/common.c: Loading device parameters....
2017-07-03T21:42:39 INFO src/common.c: Device connected is: F1 Medium-density device, id 0x20036410
2017-07-03T21:42:39 INFO src/common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in pages of 1024 bytes
2017-07-03T21:42:39 INFO src/common.c: Attempting to write 420 (0x1a4) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08000000 erased
2017-07-03T21:42:40 INFO src/common.c: Finished erasing 1 pages of 1024 (0x400) bytes
2017-07-03T21:42:40 INFO src/common.c: Starting Flash write for VL/F0/F3   core id
2017-07-03T21:42:40 INFO src/flash_loader.c: Successfully loaded flash loader in sram
0/0 pages written
2017-07-03T21:42:40 INFO src/common.c: Starting verification of write complete
2017-07-03T21:42:40 INFO src/common.c: Flash written and verified! jolly good!

and the LED doesn't flash, but when I first upload any code using ARDUINO IDE(for this board) then I run the prevouis command, the led starts blinking, but if I pushed the reset button or unplug then plug st-link agian the LED stop blinking.

So I think the problem is with my linker or the startup code, but I don't know where it is.

What is wrong with startup code or linker script?

-----  EDIT  -----

result of disassembly:

arm-none-eabi-objdump -D main.elf > dump.S

main.elf:     file format elf32-littlearm

Disassembly of section .isr_vector:

08000000 <g_pfnVectors>:
 8000000:   20005000    andcs   r5, r0, r0
 8000004:   08000165    stmdaeq r0, {r0, r2, r5, r6, r8}
 8000008:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 800000c:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000010:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000014:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000018:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
    ...
 800002c:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000030:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000034:   00000000    andeq   r0, r0, r0
 8000038:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 800003c:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000040:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000044:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000048:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 800004c:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000050:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000054:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000058:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 800005c:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000060:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000064:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000068:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 800006c:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000070:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000074:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000078:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 800007c:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000080:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000084:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000088:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 800008c:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000090:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000094:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 8000098:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 800009c:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000a0:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000a4:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000a8:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000ac:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000b0:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000b4:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000b8:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000bc:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000c0:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000c4:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000c8:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000cc:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000d0:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000d4:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000d8:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000dc:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000e0:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000e4:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
 80000e8:   080001a5    stmdaeq r0, {r0, r2, r5, r7, r8}
    ...
 8000108:   f108f85f            ; <UNDEFINED> instruction: 0xf108f85f

Disassembly of section .text:

08000110 <main>:
 8000110:   4e0a        ldr r6, [pc, #40]   ; (800013c <delay2+0x8>)
 8000112:   f04f 0010   mov.w   r0, #16
 8000116:   6030        str r0, [r6, #0]
 8000118:   4e09        ldr r6, [pc, #36]   ; (8000140 <delay2+0xc>)
 800011a:   480a        ldr r0, [pc, #40]   ; (8000144 <delay2+0x10>)
 800011c:   6030        str r0, [r6, #0]
 800011e:   f44f 4200   mov.w   r2, #32768  ; 0x8000
 8000122:   f04f 0300   mov.w   r3, #0
 8000126:   4e08        ldr r6, [pc, #32]   ; (8000148 <delay2+0x14>)

08000128 <loop>:
 8000128:   6032        str r2, [r6, #0]
 800012a:   4908        ldr r1, [pc, #32]   ; (800014c <delay2+0x18>)

0800012c <delay1>:
 800012c:   3901        subs    r1, #1
 800012e:   d1fd        bne.n   800012c <delay1>
 8000130:   6033        str r3, [r6, #0]
 8000132:   4906        ldr r1, [pc, #24]   ; (800014c <delay2+0x18>)

08000134 <delay2>:
 8000134:   3901        subs    r1, #1
 8000136:   d1fd        bne.n   8000134 <delay2>
 8000138:   e7f6        b.n 8000128 <loop>
 800013a:   bf00        nop
 800013c:   40021014    andmi   r1, r2, r4, lsl r0
 8000140:   40011004    andmi   r1, r1, r4
 8000144:   34444444    strbcc  r4, [r4], #-1092    ; 0xfffffbbc
 8000148:   4001100c    andmi   r1, r1, ip
 800014c:   000c3500    andeq   r3, ip, r0, lsl #10
 8000150:   080001a8    stmdaeq r0, {r3, r5, r7, r8}
 8000154:   20005000    andcs   r5, r0, r0
 8000158:   20005000    andcs   r5, r0, r0
 800015c:   20005000    andcs   r5, r0, r0
 8000160:   20005000    andcs   r5, r0, r0

08000164 <Reset_Handler>:
 8000164:   2100        movs    r1, #0
 8000166:   e003        b.n 8000170 <LoopCopyDataInit>

08000168 <CopyDataInit>:
 8000168:   4b09        ldr r3, [pc, #36]   ; (8000190 <LoopFillZerobss+0xc>)
 800016a:   585b        ldr r3, [r3, r1]
 800016c:   5043        str r3, [r0, r1]
 800016e:   3104        adds    r1, #4

08000170 <LoopCopyDataInit>:
 8000170:   4808        ldr r0, [pc, #32]   ; (8000194 <LoopFillZerobss+0x10>)
 8000172:   4b09        ldr r3, [pc, #36]   ; (8000198 <LoopFillZerobss+0x14>)
 8000174:   1842        adds    r2, r0, r1
 8000176:   429a        cmp r2, r3
 8000178:   d3f6        bcc.n   8000168 <CopyDataInit>
 800017a:   4a08        ldr r2, [pc, #32]   ; (800019c <LoopFillZerobss+0x18>)
 800017c:   e002        b.n 8000184 <LoopFillZerobss>

0800017e <FillZerobss>:
 800017e:   2300        movs    r3, #0
 8000180:   f842 3b04   str.w   r3, [r2], #4

08000184 <LoopFillZerobss>:
 8000184:   4b06        ldr r3, [pc, #24]   ; (80001a0 <LoopFillZerobss+0x1c>)
 8000186:   429a        cmp r2, r3
 8000188:   d3f9        bcc.n   800017e <FillZerobss>
 800018a:   f7ff ffc1   bl  8000110 <main>
 800018e:   4770        bx  lr
 8000190:   080001a8    stmdaeq r0, {r3, r5, r7, r8}
 8000194:   20005000    andcs   r5, r0, r0
 8000198:   20005000    andcs   r5, r0, r0
 800019c:   20005000    andcs   r5, r0, r0
 80001a0:   20005000    andcs   r5, r0, r0

080001a4 <ADC1_2_IRQHandler>:
 80001a4:   e7fe        b.n 80001a4 <ADC1_2_IRQHandler>
    ...

Disassembly of section .stack:

20000000 <__stack_start__>:
    ...

Disassembly of section .ARM.attributes:

00000000 <.ARM.attributes>:
   0:   00002041    andeq   r2, r0, r1, asr #32
   4:   61656100    cmnvs   r5, r0, lsl #2
   8:   01006962    tsteq   r0, r2, ror #18
   c:   00000016    andeq   r0, r0, r6, lsl r0
  10:   726f4305    rsbvc   r4, pc, #335544320  ; 0x14000000
  14:   2d786574    cfldr64cs   mvdx6, [r8, #-464]! ; 0xfffffe30
  18:   0600334d    streq   r3, [r0], -sp, asr #6
  1c:   094d070a    stmdbeq sp, {r1, r3, r8, r9, sl}^
  20:   Address 0x0000000000000020 is out of bounds.


Update field in Object array in Meteor (mongoDB)

I have the following document:

{
   "gameName":"Shooter",
   "details":[
      {
         "submitted":1415215991387,
         "author":"XYZ",
         "subPlayer":{
            "members":{
               "squad1":[
                  {
                     "username":"John",
                     "deaths":0
                  }
               ]
            },
            "gameSlug":"0-shooter"
         }
      }
   ],
   "userId":"foL9NpoZFq9AYmXyj",
   "author":"Peter",
   "submitted":1415215991608,
   "lastModified":1415215991608,
   "participants":[
      "CXRR4sGf5AdvSjdgc",
      "foL9NpoZFq9AYmXyj"
   ],
   "slug":"1-shooterConv",
   "_id":"p2QQ4TBwidjeZX6YS"
}

... and the following Meteor method:

Meteor.methods({
    updateDeaths: function(gameSlug, user, squad) {
            Stats.update({details.subPlayer.gameSlug: gameSlug}, ...}); // ???
    }
});

My goal is to update the field deaths. The method has the argument user which is the user object (username = user.username). Furthermore, the argument squad is the squad name as string, e.g. squad1.

How can I do this?

Any help would be greatly appreciated.


How do I write this SQL query using Linq/LAMBDA (with inner and left outer join)?

 SELECT * FROM paquet_esc PE
    INNER JOIN depot D
        ON PE.id_paquet_esc = D.paquet_esc_id
    INNER JOIN fichier_esc FE
        ON D.fichier_id = FE.id_fichier
    INNER JOIN engin EN
        ON FE.engin_id = EN.id_engin
    LEFT OUTER JOIN reception R
        ON FE.id_fichier = R.fichier_id
    LEFT OUTER JOIN traitement T
        ON FE.id_fichier = T.fichier_id
    LEFT OUTER JOIN code_erreur_traitement CET
        ON T.code_erreur_id = CET.id_code_erreur
    LEFT OUTER JOIN integration I
        ON FE.id_fichier = I.fichier_id
    LEFT OUTER JOIN envoi EI
        ON FE.id_fichier = EI.fichier_id


Pivot table and Dates

I am a newbie, and I am sort of a enthusiastic learner, a beginner who is making many mistakes. On my pivot table which is picking up two years worth of dates, I am keen to only choose the first two most recent dates, rather than using a slicer.  I have tried to make it a little bit dynamic, but I am constantly getting error messages,

I was trying to have cells in my spreadsheet which is from date and a two date, or a code that picks the first two most recent dates. I really want the code to work and pulling my hair out, as I have few other pivot tables. Every time I put the cell reference in between, where the dates are I keep getting coding errors.

I want the pivot items more dynamic as like before, I will try to add a validation on the date from and date to make it lot more dynamic.

I want the pivot items to be x first date and y as the second date referring to two cells on the sheet, which I can amend on the sheet, and another code that just picks the first two most recent dates.

Sub DateSlection ()

 With ActiveSheet
.PivotTables("PivotTable4").PivotFields("Date")
        .PivotItems("11/2/2016").Visible = True
        .PivotItems("10/26/2016").Visible = True
    End With
    End Sub

kind regards

Ali


Why do so many apps/frameworks keep their configuration files in an un-executed format?

Many frameworks keep their configuration files in a language different from the rest of the program. Eg, Appengine keeps the configuration in yaml format. to compare, DJango settings.py is a python module. There are many disadvantages I can see with this.

If its in same language as rest of the program, I can

Do interesting things in the configuration file.

 MEDIA_DIR = os.path.join(os.path.dir(__file__), 'media')
 #Or whaever the correct cals are, you get the idea.

Don't have to learn a new(admittedly lightweight) format

My tools work as expected with it.

I can just do import conf etc.

I can see the advantages if it were a heavyweight language like C/C++ etc, but for python why does it make sense. It just seems like taking away power without adding any benefits.


0.0 value when data pass over from First Activity to Next(Android)

i wanted to pass my distance and duration over to the next page, but the result display is 0.0 for both

first Activity

        btnStop.setOnClickListener(new OnClickListener()
    {
        @Override
        public void onClick(View v) {
            startButtonClicked=false;
            startDistance=false;
            Double value=Double.valueOf(distance.getText().toString());
            Double durationValue=time;
            Intent intent = new Intent(MainActivity.this, FinishActivity.class);

            intent.putExtra("dist", value);
            intent.putExtra("time",durationValue);
            startActivity(intent);
            finish();
        }
    });

at the Activity where it display

    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_finish);
    Bundle extras = getIntent().getExtras();
    if (extras != null)
    {
        Double value = extras.getDouble("dist");
        Double durationValue = extras.getDouble("time");
        displayDistance=(TextView)findViewById(R.id.finishDistance);
                displayDistance.setText("Distance: " + value);

        displayDuration=(TextView)findViewById(R.id.finishDuration);
                displayDuration.setText("Duration: " + durationValue);
        }

the app crash after i presses stopped

here is my full Java code for the first Activity(second just display them). in case you all want to see how i get them

public class MainActivity extends FragmentActivity implements LocationListener{

protected LocationManager locationManager;
private GoogleMap googleMap;
Button btnStartMove,btnPause,btnResume,btnStop;
static double n=0;
Long s1,r1;
double dis=0.0;
Thread t1;
EditText userNumberInput;
boolean bool=false;
int count=0;

double speed = 1.6;
double lat1,lon1,lat2,lon2,lat3,lon3,lat4,lon4;
double dist = 0;
TextView distance;
Button btnDuration;
float[] result;
private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES =1; // in Meters
private static final long MINIMUM_TIME_BETWEEN_UPDATES = 4000; //in milliseconds
boolean startDistance = false;
boolean startButtonClicked = false;

MyCount counter;
int timer = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,MINIMUM_TIME_BETWEEN_UPDATES,MINIMUM_DISTANCE_CHANGE_FOR_UPDATES, this);
    if(isGooglePlay())
    {
        setUpMapIfNeeded();
    }
    distance=(TextView)findViewById(R.id.Distance);
    btnDuration=(Button)findViewById(R.id.Duration);
    btnStartMove=(Button)findViewById(R.id.Start);//start moving
    btnStop=(Button)findViewById(R.id.Stop);

    //prepare distance...........
    Log.d("GPS Enabled", "GPS Enabled");
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    String provider = locationManager.getBestProvider(criteria, true);
    Location location=locationManager.getLastKnownLocation(provider);

    btnStartMove.setOnClickListener(new OnClickListener()
    {
        @Override
        public void onClick(View v) {

            Log.d("GPS Enabled", "GPS Enabled");
            Criteria criteria = new Criteria();
            criteria.setAccuracy(Criteria.ACCURACY_FINE);
            String provider = locationManager.getBestProvider(criteria, true);
            Location location=locationManager.getLastKnownLocation(provider);
            lat3 = location.getLatitude();
            lon3 = location.getLongitude();
            startButtonClicked=true;
            counter= new MyCount(30000,1000);
            counter.start();
            Toast.makeText(MainActivity.this,
                      "start is true",
                      Toast.LENGTH_LONG).show();
        }
    });
    btnStop.setOnClickListener(new OnClickListener()
    {
        @Override
        public void onClick(View v) {
            startButtonClicked=false;
            startDistance=false;
            //String dis = (String) distance.getText();
            //Double dd = Double.parseDouble(dis);
            Intent intent = new Intent(MainActivity.this, FinishActivity.class);
            //DecimalFormat df = new DecimalFormat("#.##");
            //dist=(df.format(dd);
            intent.putExtra("dist","value");
            //intent.putExtra("speed","speedValue");
            intent.putExtra("time","durationValue");
            startActivity(intent);
            finish();
        }
    });

    btnDuration.setOnClickListener(new OnClickListener()
    {
        @Override
        public void onClick(View v) {
            if(startButtonClicked=true)
            {
                double time=n*30+r1;
                Toast.makeText(MainActivity.this,"Speed(m/s) :"+String.valueOf(dist/time)+"Duration :"+String.valueOf(time),Toast.LENGTH_LONG).show();
            }
        }
    });

    if(location!= null)
    {
        //Display current location in Toast
        String message = String.format(
                "Current Location \n Longitude: %1$s \n Latitude: %2$s",
                location.getLongitude(), location.getLatitude()
        );
        Toast.makeText(MainActivity.this, message,
                Toast.LENGTH_LONG).show();

        //Display current location in textview
        //latitude.setText("Current Latitude: " + String.valueOf(location.getLatitude()));
        //longitude.setText("Current Longitude: " + String.valueOf(location.getLongitude()));
    }
    else if(location == null)
    {
        Toast.makeText(MainActivity.this,
                "Location is null",
                Toast.LENGTH_LONG).show();
    }

}
private void setUpMapIfNeeded() {

    if(googleMap == null)
    {
        Toast.makeText(MainActivity.this, "Getting map",
                Toast.LENGTH_LONG).show();
        googleMap =((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.displayMap)).getMap();

        if(googleMap != null)
        {
            setUpMap();
        }
    }a

}

private void setUpMap()
{
    //Enable MyLocation Layer of Google Map
    googleMap.setMyLocationEnabled(true);

    //Get locationManager object from System Service LOCATION_SERVICE
    //LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

    //Create a criteria object to retrieve provider
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    //Get the name of the best provider
    String provider = locationManager.getBestProvider(criteria, true);
    if(provider == null)
    {
        onProviderDisabled(provider);
    }
    //set map type
    googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    //Get current location
    Location myLocation = locationManager.getLastKnownLocation(provider);
    if(myLocation != null)
    {
        onLocationChanged(myLocation);
    }
    locationManager.requestLocationUpdates(provider, 0, 0, this);
}

private boolean isGooglePlay()
{
    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

    if (status == ConnectionResult.SUCCESS)
    {

        Toast.makeText(MainActivity.this, "Google Play Services is available",
                Toast.LENGTH_LONG).show();
        return(true);
    }
    else
    {
            GooglePlayServicesUtil.getErrorDialog(status, this, 10).show();

    }
    return (false);

 }

@Override
public void onLocationChanged(Location myLocation) {
    System.out.println("speed " + myLocation.getSpeed());

        //show location on map.................
        //Get latitude of the current location
        double latitude = myLocation.getLatitude();
        //Get longitude of the current location
        double longitude = myLocation.getLongitude();
        //Create a LatLng object for the current location
        LatLng latLng = new LatLng(latitude, longitude);
        //Show the current location in Google Map
        googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
        //Zoom in the Google Map
        googleMap.animateCamera(CameraUpdateFactory.zoomTo(20));
        googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title("You are here!"));

        //show distance............................
        if(startDistance == true)
        {

            Toast.makeText(MainActivity.this,
                      "Location has changed",
                      Toast.LENGTH_LONG).show();
                if(myLocation != null)
                {
                    //latitude.setText("Current Latitude: " + String.valueOf(loc2.getLatitude()));
                    //longitude.setText("Current Longitude: " + String.valueOf(loc2.getLongitude()));
                    float[] results = new float[1];
                    Location.distanceBetween(lat3, lon3, myLocation.getLatitude(), myLocation.getLongitude(), results);
                    System.out.println("Distance is: " + results[0]);

                    dist += results[0];
                    DecimalFormat df = new DecimalFormat("#.##"); // adjust this as appropriate
                if(count==1)
                {
                    distance.setText(df.format(dist) + "meters");
                }
                    lat3=myLocation.getLatitude();
                    lon3=myLocation.getLongitude();
                    count=1;
              }

        }
        if(startButtonClicked == true)
        {
            startDistance=true;
        }

    //}

}

@Override
public void onProviderDisabled(String provider) {
    Toast.makeText(MainActivity.this,
            "Provider disabled by the user. GPS turned off",
            Toast.LENGTH_LONG).show();
}

@Override
public void onProviderEnabled(String provider) {
    Toast.makeText(MainActivity.this,
            "Provider enabled by the user. GPS turned on",
            Toast.LENGTH_LONG).show();
}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
    Toast.makeText(MainActivity.this, "Provider status changed",
            Toast.LENGTH_LONG).show();
}
@Override
protected void onPause() {
super.onPause();
locationManager.removeUpdates(this);
}
@Override
protected void onResume() {
    super.onResume();
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,MINIMUM_TIME_BETWEEN_UPDATES,MINIMUM_DISTANCE_CHANGE_FOR_UPDATES, this);
}
public class MyCount extends CountDownTimer{
    public MyCount(long millisInFuture, long countDownInterval) {
    super(millisInFuture, countDownInterval);
    }
    @Override
    public void onFinish() {
        counter= new MyCount(30000,1000);
     counter.start();
     n=n+1;
    }
    @Override
    public void onTick(long millisUntilFinished) {
        s1=millisUntilFinished;
        r1=(30000-s1)/1000;
        //e1.setText(String.valueOf(r1));

    }
}}


Qplot line color and legend aesthetic

I wanted to change the legend and line colors in this qplot.

Here is my data

   n.clusters mean.cluster mean.bucket   variable    value
1           3     21.64790    21.49858 sd.cluster 5.643380
2           5     21.63516    21.54975 sd.cluster 4.369756
3           7     21.55446    21.49889 sd.cluster 3.643280
4           9     21.59585    21.57022 sd.cluster 3.237870
5          11     21.63110    21.58452 sd.cluster 3.012060
6          13     21.55224    21.56104 sd.cluster 2.643777
7           3     21.64790    21.49858  sd.bucket 5.648886
8           5     21.63516    21.54975  sd.bucket 4.397690
9           7     21.55446    21.49889  sd.bucket 3.654752
10          9     21.59585    21.57022  sd.bucket 3.262954
11         11     21.63110    21.58452  sd.bucket 3.023834
12         13     21.55224    21.56104  sd.bucket 2.716441

And here is the code I used

qplot(n.clusters, value, data = mu.est.summary.long,colour = variable, geom = c("point", "line"))+
  theme_bw() +
  scale_x_continuous(breaks = seq(1,13,2)) +
  geom_point(aes(n.clusters, value), colour = "black", size=3.5) +
  geom_line(size=1)+
  labs(x = "Number of cluster",
       y = "Value",
       variable = "Standard deviation(sd)")

The legend title code line labs(variable = "Standard deviation(sd)") didn't work and R didn't report any error. How do I fix it?

I can color the dot on the line in black but that didn't change the legend. How do I make the legend change?

I tried to change the line color with geom_line(colour = c("red","yellow"), size=1) but that didn't work. How do I fix it?

Sorry for so many questions and thanks for any help.


Get Text from div dropdown

I have this:

php

<div id="moneda">
<?php echo $settings['currency_sign'];
?>
</div>

(you can edit with Dropdown https://code.google.com/p/jquery-in-place-editor/)
js

$("#moneda").change(function(){
alert($(this).val());
});

alert($(this).val()); (Get text in the dropdown NOT WORKING)

thanks

actual alert from get in js


Why can't I call `history` from within Ruby?

I can run Bash shell commands from with a Ruby program or irb using backticks (and %x(), system, etc). But that does not work with history for some reason.

For example:

jones$ irb --simple-prompt
>> `whoami`
=> "jones\n"
>> `history`
(irb):2: command not found: history
=> ""

From within a Ruby program it produces this error:

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31: command not found: history

In bash itself, those commands work fine

It's not that the Ruby call is invoking a new shell - it simply does not find that command...

Anyone know why? I'm stumped...


Sql function that should error but instead creates successfully

I'm debugging a larger script and narrowed it down to the fact that a function is being created when it should error.

I tested the following function which SHOULD fail:

CREATE FUNCTION ShouldFail( @x INT )
RETURNS int
AS
BEGIN
DECLARE @i INT

SELECT @i = id FROM dbo.IDontExist
RETURN @i
END

Instead the creation succeeds.  Any ideas why?


autocomplete menu not visible in jqgrid in a Bootstrap tab

JQuery 2.1.1, Bootstrap 3.0.3 and JQGrid 4.8.2

I have a jqgrid that is included on a page that utilizes Bootstrap tabs.  One of the columns uses autocomplete to provide options for inline editing.  The function fires and retrieves the data but the autocomplete menu is not visible.  If I run my code outside of the Bootstrap tab, the menu appears correctly.  I've tried playing around with the z-index of ui-autocomplete and tab-pane but nothing has worked.  Any suggestions?

<style>
.ui-autocomplete { font-size: 11px; position: absolute; cursor: default;z-index:1000 !important;}
</style>

Here is a snippet grid definition:

var myGrid =  jQuery("#payments").jqGrid({
           datatype: "local",
            data: myData,
            editurl: 'clientArray',
            onSelectRow: editRow,
            colModel: [
               { label: 'Payment ID', name: 'PaymentID', key: true, width: 75 },
               { label: 'Country', name: 'Country',
                    width: 100 ,
                    editable: true,
                    edittype: "text",
                    editoptions: {
                        dataInit: function (element) {
                            window.setTimeout(function () {
                                $(element).autocomplete({
                                    id: 'AutoComplete',
                                    source: ["United States of America", "Germany", "Sweden", "Greece" ],
                                    minLength: 2,
                                    autoFocus: true
                                });
                            }, 100);
                        }
                    }
                },
                ....
            ],
            viewrecords: true,
            width: 1000,
            height: 250,
            subGrid: true,
            subGridRowExpanded: showChildGrid,
            pager: jQuery('#report_pager')
        });

This is a the tab that contains the grid:

...
<div class="tab-pane" id="spendT">
    <div class="col-sm-12">
       <fieldset class="well the-fieldset" >
          <legend class="the-legend">Spend</legend>
          <br>
          <div class="report_Tbl" id="report_Tbl"  style="text-align:left;padding:2px;">
             <div id="report_pager" class="scroll"  style="text-align:left;">    </div>
            <table id="payments" class="scroll" ></table>
         </div>
       </fieldset>
    </div>
 </div>


Can't set cookies in Laravel 4

I'm using the latest version of Laravel 4 and I can't set cookies:

Route::get('cookietest', function()
{
    Cookie::forever('forever', 'Success');
    $forever = Cookie::get('forever');
    Cookie::make('temporary', 'Victory', 5);
    $temporary = Cookie::get('temporary');
    return View::make('cookietest', array('forever' => $forever, 'temporary' => $temporary, 'variableTest' => 'works'));
});

View script:

@extends('layouts.master')

@section('content')
    Forever cookie: {{ $forever }} <br />
    Temporary cookie: {{ $temporary }} <br />
    Variable test: {{ $variableTest }}
@stop

Yields:

Forever cookie:
Temporary cookie:
Variable test: works

It doesn't matter if I refresh the page or create the cookies in one route and try to access them in another. I can confirm that no cookies are being set with the above operation. The cookies 'laravel_payload' and 'laravel_session' as well as 'remember_[HASH]' do exist and I can set cookies with regular PHP using setcookie.

No errors are thrown or logged anywhere that I can find. I'm running Linux Mint locally and Debian on my server, both with nginx and I have the same problem in both places.


Spring ApplicationContext closed before bean invoked

In my Spring app I noticed strange behavior of Spring (or Eclipse). It confused me. ApplicationContext surrounded with try/catch to be sure is closed after done in finally block. But in Eclipse console I saw that it closed before bean invoked.

public class Main {

    public static void main(String[] args) {

            ApplicationContext context = null;
        try {
            context = new ClassPathXmlApplicationContext(new String[] { "beans-annot.xml" });
            Launcher launcher = (Launcher) context.getBean("launcher");

                System.out.println(launcher);
                launcher.invokeBean();
        } catch (BeansException e) {
            e.printStackTrace();
        } finally {
            if(context != null)
            ((AbstractApplicationContext) context).close();
        }
    }
}

@Component
public class Bean {
    public void invoke(){
        System.out.println("invoke bean");
    }
}
@Component
public class Launcher {

    @Autowired
    public Bean bean;

    //setter

    public void invokeBean(){
        bean.invoke();
    }
}

beans-annot.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:component-scan base-package="my.ioc" />
    <context:annotation-config />

</beans>

In Eclipse console output:

[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ IoC ---
окт 30, 2014 8:52:56 PM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@6e4e4adb: startup date [Thu Oct 30 20:52:56 FET 2014]; root of context hierarchy
окт 30, 2014 8:52:56 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [beans-annot.xml]
my.ioc.Launcher@2b7f535d
окт 30, 2014 8:52:56 PM org.springframework.context.support.ClassPathXmlApplicationContext doClose
INFO: Closing org.springframework.context.support.ClassPathXmlApplicationContext@6e4e4adb: startup date [Thu Oct 30 20:52:56 FET 2014]; root of context hierarchy
invoke bean
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

As you can see doClose method init before Bean, why? I think that it's Eclipse or maven plugin error... Project was build with exec-maven-plugin.


java getRuntime().exec() not working?

Basically, when I type these commands in
the terminal by hand, the sift program works and writes a .key file, but when I try to call it from my program, nothing is written.

Am I using the exec() method correctly? I have looked through the API and I can't seem to spot where I went wrong.

public static void main(String[] args) throws IOException, InterruptedException
{
        //Task 1: create .key file for the input file
        String[] arr  = new String[3];
        arr[0] =  "\"C:/Users/Wesley/Documents/cv/final project/ObjectRecognition/sift/siftWin32.exe\"";
        arr[1] = "<\"C:/Users/Wesley/Documents/cv/final project/ObjectRecognition/sift/cover_actual.pgm\"";
        arr[2] = ">\"C:/Users/Wesley/Documents/cv/final project/ObjectRecognition/sift/keys/cover_actual.key\"";

        String command = (arr[0]+" "+arr[1]+" "+arr[2]);

        Process p=Runtime.getRuntime().exec(command);
        p.waitFor();
        BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream()));
        String line=reader.readLine();

        while(line!=null)
        {
            System.out.println(line);
            line=reader.readLine();
        }
}


Pre-Computing Nested Data Set MongoDB

I am implementing an application where I need to pre-compute some stats and using aggregation to show computed results through APIs.

I store all data set on unit day computation. Means for one day, I compute all stats and store those in one MongoDB document. So far linear structure of computing works.

Now I have following complex scenario where multiple inter-related items are encountered. Look at the sample data

data = [
    {id: 1 , date: '29-08-2016', service: 'Good', text: 'R1', categories: ['10-20', 'Male', 'Speed', 'Service']},
    {id: 2 , date: '29-08-2016', service: 'Good', text: 'R2', categories: ['51+', 'Female', 'Strength', 'Service']},
    {id: 3 , date: '29-08-2016', service: 'Good', text: 'R3', categories: ['21-50', 'Male', 'Speed']},
    {id: 4 , date: '29-08-2016', service: 'Bad', text: 'R4', categories: ['10-20', 'Female', 'Flexibility']},
    {id: 5 , date: '29-08-2016', service: 'Bad', text: 'R5', categories: ['21-50', 'Female']}
]

So I compute linear information from above data set into a MongoDB document:

{
   date: '29-08-2016',
   total: 5,
   sub_total: {
      'Good': 3,
      'Bad': 2
   }
}

Now I need to pre-compute count of categories as well. As I do:

{
   date: '29-08-2016',
   total: 5,
   sub_total: {
      'Good': 3,
      'Bad': 2
   },
   categories: {
      '10-20': 2,
      '21-50': 1,
      '51+': 1,
      'Male': 2,
      'Female': 3,
      'Service': 2,
      'Speed': 2,
      'Flexibility': 1,
      'Strength': 1,
   }
}

This structure also work if I need to know individual category information. But it gets more complex when I have questions like this:

Count of Speed and Service for Female having age 10-20

I can't figure out a json structure which can help to answer above questions and using mongodb aggregations.

Any suggestions.


evaluate string with array php

I have a string like

       "subscription link   :%list:subscription%
       unsubscription link :%list:unsubscription%
       ------- etc"

AND

I have an array like

    $variables['list']['subscription']='example.com/sub';
    $variables['list']['unsubscription']='example.com/unsub';
    ----------etc.

I need to replace %list:subscription% with $variables['list']['subscription'],And so on
here list is first index and  subscription is the second index from $variable
.Is possible to use eval() for this? I don't have any idea to do this,please help me


How do I shutdown my PC with Win32 API in C?

I need a way using the Win32 API to force shutdown my machine.

I am currently using Windows 7 but O'd really like if the code would work for Vista and XP.


Checking an Excel document into SharePoint programattically hangs

Salutations-

I've been working on a PowerShell script, with the intent of refreshing a excel document's SQL data daily via task scheduler. The excel document is hosted on SharePoint. I've (after much, much trial and error) gotten it to work up until the checkin part.

Basically, Task Scheduler fires the PowerShell script daily.

The script creates an excel COM object.

It verifies it can checkout the document, then does so if able.

It then performs the refresh.

Finally, it attempts to checkin the document. At this point, it just
hands and nothing happens. I should note this ONLY happens when the
script is run via task scheduler, and 'whether user is logged in or
not' is selected. If run from the PowerShell cmd line or the
option  'user must be    logged in' is checked, everything performs
fine.

Couple important notes-
The account is a service account user, although we granted it local login during testing. It has GOT to be unattended in practice though.
I followed the instructions for folders on this page-
https://social.technet.microsoft.com/Forums/en-US/aede572b-4c1f-4729-bc9d-899fed5fad02/run-powershell-script-as-scheduled-task-that-uses-excel-com-object?forum=winserverpowershell
It is worth noting I also had to set permissions on the folders mentioned a few posts past the initial comment. I STRONGLY suspect my current issue is similar/related- but it must not be these folders because I have pretty open permissions here.

I had to remove 'enhanced IE security' as this is a server box and PowerShell  couldn't initially 'see' the SharePoint site.

I've checked the event log- the office log is apparently operational, but there is no popup at the time of checkin apparently.

I've set and verified COM permission settings, although it is possible I missed something here. Excel wasn't listed in the APP list but adding the user to the call privileges moved me forward on the task.

I'm pretty sure this doesn't happen if I run it as a dev administrator.

CYA-
I'm aware MS doesn't endorse the above, but I'm also aware people get it to work.
Powerpivot for SharePoint is not really an option at this time.
This is like my third question ever (I normally bang my head against the wall until I get it, but I'm getting a bit bloody here for 'just' a PowerShell  script. Please bear with me if I'm over/under wordy :)

Truncated script below- (removed try/catch and debug messages. If you want the cleaned full let me know, I'd love to save someone the trouble I had.)

$i = "http://supersecretintranetsite/excelwithsqldatacon.xlsx"

# Creating the excel COM Object
$Excel = New-Object -ComObject Excel.Application;

Start-Sleep -s 5
# Setting up Excel to run without UI and without alerts
$Excel.DisplayAlerts = $false
$Excel.ScreenUpdating = $false
$Excel.Visible = $false
$Excel.UserControl = $false
$Excel.Interactive = $false

If ($Excel.workbooks.CanCheckOut($i))
{

    # Opening the workbook, can be local path or SharePoint URL
    $Workbook = $Excel.workbooks.Open($i);

    # Perform the check out
    $Workbook = $Excel.workbooks.CheckOut($i)
    $Workbook = $Excel.workbooks.Open($i);

    Start-Sleep -s 15

    # Calling the refresh
    $Workbook.RefreshAll();

    # Forces a hold until all Refreshing is done
    $Excel.CalculateUntilAsyncQueriesDone()

    # Saving and closing the workbook
    # $Workbook.Save() #- this hangs too
    Start-Sleep -s 15
    # THIS HANGS
    $Workbook.CheckInWithVersion();

    Start-Sleep -sec 5

    #Release Workbook
    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($Workbook)
}

$Excel.quit();


How can I obtain URI components using angular.js

How can I get URI components in AngularJS? For example I have http://domain.com/photo/1

So how can I get that second segment (=1) to a variable in angular? Thank you.


How to write Like query in Linq to Entities

i tried the following code...

public ActionResult Search(string query)
    {
        using (DbAccess db=new DbAccess())
        {
            List<Student> studentsList = db.Students.Where(m=>m.name.Contains("d")==query).ToList();
            return View(studentsList);
        }
    }

but if i use "Contains" then it gives me error..
please help


How to filter through a table using ng-repeat checkboxes with Angularjs

Once upon a time this was working but somehow it's broken. I want to be able to produce checkboxes using ng-repeat to get as many checkboxes as required based on stored data and use these to filter through a table produced.

Additionally I don't want identical values for the checkboxes to be repeated.

I have made a plnkr with the code.

<div class="row">
    <label data-ng-repeat="x in projects">
        <input
        type="checkbox"
        data-ng-true-value="{{x.b}}"
        data-ng-false-value=''
        ng-model="quer[queryBy]" />
        {{x.b}}
    </label>
</div>

http://plnkr.co/edit/RBjSNweUskAtLUH3Ss6r?p=preview

So in summary.

Checkboxes to filter Ref.

Checkboxes to be unique.

Checkboxes to be made based off ng-repeat using Ref.


How to get the _locale variable inside in a Symfony layout?

I'm working with Symfony 2 on a site which having 2 languages,
and I want to change patterns of my routes depending on user locale language !

Example:

user_login_en:
    pattern:  /en/user/login.html
    defaults: { _controller: SfErrorsAppBundle:User:login, _locale: en }

user_login_fr:
    pattern:  /fr/utilisateur/connexion.html
    defaults: { _controller: SfErrorsAppBundle:User:login, _locale: fr}

Inside a template, this is not difficult, i just have to pass the $this->get('session')->getLocale() from the controller to the template...

To work, I have to call my routes:

$router->generate('user_login_'.$locale, array());

But  inside my layouts, I have of course a menu, and sidebars, which have links... So I want to get the locale variable to use it ! So my question is simple: how to get this variable inside a "layout" template ? Otherwise, have you got any idea to change the pattern depending on the language ?

The reasons are that I want beautiful routes for all users, whether they're english or french... And also for a SEO reason !


When is persistence.xml necessary for Play 2.1.1 Java? Entities don't persist in a many-to-one relationship

In my program, I have a Task model with a allDates field, which is a collection of all the Dates that task occurs on. My goal is to make a calendar manager that allows users to input tasks that repeat on certain days.

In Tasks, I defined a OneToMany relation between a task and its dates in line 34. To treat the elements of allDates as an entity, I wrapped each date in a DateHelper model that is another Ebean entity.

Right before I save the Task, my console output indicates someTask.allDates.size() is accurate and a number greater than one. After I save the task, however:

1) I query DateHelpers in line 194 for all DateHelper instances for a given task, and the server only returns the first DateHelper that was added to someTask.allDates, rather than returning the same number of DateHelpers that was added to the task before I saved.

2) someTask.allDates.size() also returns 1, and the only element in allDates is the first DateHelper I added before saving the task.

I read here and here that Play developers should modify a persistence.xml file to integrate with JPA. Do I need to do this if I am importing ebean? Also, my program successfully maps one User to many Tasks, so I am confused about why the OneToMany mapping does not work for one Task to many TaskHelpers.


can't see asp.net gridview on page load

I have a gridview that won't show on page load.  The gridview is inside of some asp:Panels which are inside of an update panel.  I stepped through the code, so I know the gridview has rows of data.  If I move the gridview outside of the panels and update panels, then it will show up with data.  Does anybody know why it doesn't work as it sits below, inside of the panels and update panels?

    <%@ Page Language="VB" AutoEventWireup="false" EnableEventValidation="false" MasterPageFile="~/CTPublic.master" CodeFile="Tank.aspx.vb" Inherits="CargoTank_Internal_Tank" %>

<div style="padding-top:9px; width:100%; min-width:800px; " >
    <asp:UpdatePanel ID="udpTank" runat="server" >
    <ContentTemplate>
                <ajaxToolkit:RoundedCornersExtender runat="server" BorderColor="#3260a0"   Corners="All" Radius="5" Color="#98B9C9"  TargetControlID="pnlTank" ID="ajRCEpnlTank" ></ajaxToolkit:RoundedCornersExtender>

         <asp:Panel runat="server" BackColor="#ecece7"  Width="95%"  ID="pnlTank" >

             <div >
            <div style="float:left; width:70%; background-color:#98B9C9; height:19px;">Tanks</div>
            <div style="float:right; width:30%; height:19px;background-color:#98B9C9; text-align:right">
                <asp:Button ID="btnAddNewTank" style="background:transparent; border:0px;" runat="server" Font-Underline="true"   size="1" Font-Bold=true text="Add New" />

             </div>
            <div style="padding-top:19px;"></div>
            </div>
            <div style="width:100%;">
                <table width="100%">
                    <tr>
                        <td colspan="6" class="tdheaderbar">Search Tanks
                        </td>
                    </tr>
                    <tr>
                        <td>CT #</td>
                        <td><asp:TextBox runat="server" ID="txtCTNumber" ></asp:TextBox></td>
                        <td>Serial #</td>
                        <td><asp:TextBox runat="server" ID="txtSerialNumber" MaxLength="17"></asp:TextBox></td>
                        <td>City</td>
                        <td><asp:TextBox runat="server" ID="txtCity"></asp:TextBox></td>

                    </tr>
                    <tr>
                         <td>Capacity</td>
                        <td><asp:TextBox runat="server" ID="txtCapacity"></asp:TextBox></td>
                       <td>Unit #</td>
                        <td><asp:TextBox runat="server" ID="txtUnitNumber"></asp:TextBox></td>
                        <td>License State</td>
                        <td><asp:DropDownList EnableViewState="true" runat="server" ID="ddlState" DataSourceID="linqStates"
                               Width="156px" DataTextField="StateText" DataValueField="StateID"></asp:DropDownList>
                            <asp:LinqDataSource ID="linqStates" runat="server"
                                ContextTypeName="DataClassesDataContext" TableName="States">
                            </asp:LinqDataSource>
                        </td>

                  </tr>
                     <tr>
                         <td>Tank Type</td>
                        <td>
                            <asp:DropDownList runat="server" ID="ddlTankType"  Width="156px"
                                 ></asp:DropDownList>

                        </td>
                        <td>Compartment</td>
                        <td><asp:TextBox runat="server" ID="txtCompartment"></asp:TextBox></td>
                         <td>License #</td>
                        <td><asp:TextBox runat="server" ID="txtLicenseNumber"></asp:TextBox></td>
                  </tr>
                      <tr>
                         <td>Manufacturer</td>
                        <td colspan="2">
                            <asp:DropDownList runat="server" ID="ddlManufacturer"
                                 ></asp:DropDownList>

                        </td>

                       <td><asp:CheckBox runat="server" ID="chkNoLogIn" Text="No Log In Associated" /></td>
                       <td></td> <td></td>
                   </tr>
                   <tr><td>Company</td>
                        <td colspan="5"> <asp:DropDownList runat="server" ID="ddlCompany" ></asp:DropDownList></td>
                 </tr>
                 <tr>
                    <td colspan="3">
                    </td>
                    <td><asp:Button runat="server" ID="btnSearch" Text="Search" /></td>
                  </tr>
                </table>
            </div>

        </asp:Panel>
   </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
    </Triggers>
  </asp:UpdatePanel>
  <br />

      <div style="padding-top:9px; width:100%; " id="divTankDetail" runat="server">
    <asp:UpdatePanel ID="updTankDetail" runat="server"  >
    <ContentTemplate>
        <ajaxToolkit:DropShadowExtender runat="server" ID="dsetank" TargetControlID="pnlTankDetail" TrackPosition="true" BehaviorID="pnlTankDetailHeader"></ajaxToolkit:DropShadowExtender>
        <ajaxToolkit:DragPanelExtender runat="server" ID="dpeTankDetail" TargetControlID="pnlTankDetail" DragHandleID="pnlTankDetailHeader"></ajaxToolkit:DragPanelExtender>
        <asp:Panel CssClass="TankpopupPosition" BackColor="LightBlue" Visible="false" runat="server" BorderColor="#3260a0" BorderWidth="2px"  Width="801px"  ID="pnlTankDetail" >
               <asp:Panel runat="server" BorderColor="#3260a0" BorderWidth="1px"  Width="800px"  ID="pnlTankDetailHeader">
             <div  >
            <div style="float:left; width:90%; background-color:#98B9C9; height:19px;">Tank Detail</div>
            <div style="float:right; width:10%; border-right-width:2px; border-width:1px; border-color:#3260a0; height:19px;background-color:#98B9C9; text-align:right">
                <asp:Button ID="btnClose" style="background:transparent; border:0px;" runat="server"   size="1" Font-Bold=true text="X" />&nbsp;
            </div>

            <div style="padding-top:19px;"></div>
            </div>
            </asp:Panel>
               <asp:Panel  runat="server"  Width="800px"  ID="pnlTankDetailBody">
                <div id="divTankDetailbody" runat="server" style="width:100%"  >
                 <br />
                 <table width="100%">
                    <tr>
                        <td>CT #</td>
                        <td><asp:TextBox TabIndex="10" runat="server" BorderStyle="Inset" BorderColor="White" BorderWidth="2px" BackColor="Transparent" ID="txtCTNum" ReadOnly="true" ></asp:TextBox>
                        <asp:Label ID="lblCTNumber" runat="server" Text="*"></asp:Label>&nbsp</td>
                        <td>Serial #</td>
                        <td><asp:TextBox TabIndex="14" runat="server" BorderStyle="Inset" BorderColor="White" BorderWidth="2px" ID="txtSeriaNum" MaxLength="17"></asp:TextBox>
                        <asp:Label ID="lblSerialNumber" runat="server" Text="*"></asp:Label>&nbsp</td>
                        <td>City</td>
                        <td><asp:TextBox runat="server" TabIndex="18" BorderStyle="Inset" BorderColor="White" BorderWidth="2px" ID="txtOrignatedCity"></asp:TextBox></td>
                    </tr>
                    <tr>
                        <td>Capacity</td>
                        <td><asp:TextBox TabIndex="11" runat="server" BorderStyle="Inset" BorderColor="White" BorderWidth="2px" ID="txtTanktCapacity"></asp:TextBox>
                        <asp:Label ID="lblCapacity" runat="server" Text="*"></asp:Label>&nbsp</td>
                         <td>Compartment</td>
                        <td><asp:TextBox runat="server" TabIndex="15" ID="txtCompartment2" BorderStyle="Inset" BorderColor="White" BorderWidth="2px"></asp:TextBox>
                      <asp:Label ID="lblCompartment" runat="server" Text="*"></asp:Label>&nbsp</td>

                                                    <td>License #</td>
                        <td><asp:TextBox runat="server" BorderStyle="Inset" TabIndex="19" BorderColor="White" BorderWidth="2px" ID="txtLicenseNum"></asp:TextBox></td>
                  </tr>
                     <tr>
                                                  <td>Tank Type</td>
                        <td>
                            <asp:DropDownList runat="server" TabIndex="12" ID="ddlTankType2" Width="156px"
                                 DataTextField="TankTypeName"
                                DataValueField="TankTypeName"></asp:DropDownList><asp:Label ID="lblTankType" runat="server" Text="*"></asp:Label>&nbsp
                         </td>
                        <td>Unit #</td>
                        <td><asp:TextBox runat="server" TabIndex="16" BorderStyle="Inset" BorderColor="White" BorderWidth="2px" ID="txtUnitNum"></asp:TextBox></td>

                        <td>License State</td>
                        <td>
                            <asp:DropDownList EnableViewState="true" Width="156px" TabIndex="20"  runat="server" ID="ddlLicenseState" DataSourceID="linqStates"
                                DataTextField="StateText" DataValueField="StateID"></asp:DropDownList>

                            <asp:LinqDataSource ID="LinqDataSource1" runat="server"
                                ContextTypeName="DataClassesDataContext" TableName="States">
                            </asp:LinqDataSource>
                        </td>

                  </tr>
                  <tr>
                        <td>Manufacturer</td>
                        <td colspan="1">
                            <asp:DropDownList runat="server" TabIndex="13" ID="ddlManufacturer2"
                               >
                                 </asp:DropDownList><asp:Label ID="lblManufacturer" runat="server" Text="*"></asp:Label>&nbsp
                         </td>
                        <td>Company</td>
                        <td colspan="3"> <asp:DropDownList runat="server" TabIndex="17" ID="ddlCompany2" ></asp:DropDownList><asp:Label ID="lblCompany2" runat="server" Text="*"></asp:Label></td>

                   </tr>
                  <tr>
                    <td colspan="6" align="center"><br />
                        <asp:Label ID="lblChangeOwnership" Font-Size="Medium" runat="server"></asp:Label>
                        <br />
                        <asp:CheckBox ID="chkChangeOwnership" runat="server" Text="Changing ownership" ForeColor="Red" Font-Bold="true" />
                    </td>
                  </tr>
                  <tr>
                    <td colspan="6" align="center">
                        <br />
                     <asp:Button runat="server" ID="btnAdd" TabIndex="21" Text="Add" Width="60px" />
                     <asp:Button runat="server" ID="btnUpdate" TabIndex="22" Text="Update" Width="60px" />
                     <asp:Button runat="server" ID="btnChangeOnwership" TabIndex="23" Text="Change" Width="60px" />
                     <asp:Button runat="server" ID="btnCancel" TabIndex="24" Text="Cancel" Width="60px"  />
                     <br /><br />
                        <asp:GridView ID="grdTanks" runat="server" AllowPaging="True"
                            AutoGenerateColumns="False" BackColor="Transparent" GridLines="None"
                            PagerSettings-Mode="NumericFirstLast" PageSize="10"
                            RowStyle-HorizontalAlign="left" Width="100%">
                            <AlternatingRowStyle CssClass="alternateItemStyle" />
                            <HeaderStyle CssClass="headerStyle" />
                            <PagerSettings Mode="NumericFirstLast" />
                            <RowStyle CssClass="itemStyle" />
                            <Columns>
                                <asp:BoundField DataField="CargoTankID" HeaderText="CT #" InsertVisible="False"
                                    ReadOnly="True" SortExpression="CargoTankID" />
                                <asp:BoundField DataField="CompanyID" HeaderText="CompanyID"
                                    SortExpression="CompanyID" Visible="false" />
                                <asp:BoundField DataField="OriginatedCity" HeaderText="OriginatedCity"
                                    SortExpression="OriginatedCity" Visible="false" />
                                <asp:BoundField DataField="LicenseNumber" HeaderText="LicenseNumber"
                                    SortExpression="LicenseNumber" Visible="false" />
                                <asp:BoundField DataField="LicenseState" HeaderText="LicenseState"
                                    SortExpression="LicenseState" Visible="false" />
                                <asp:BoundField DataField="UnitNumber" HeaderText="Unit Number"
                                    SortExpression="UnitNumber" Visible="false" />
                                <asp:TemplateField HeaderText="Company">
                                    <ItemTemplate>
                                        <%#DisplayCompanyName(Eval("CompanyID"))%>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="SerialNumber" HeaderText="Serial Number"
                                    SortExpression="SerialNumber" />
                                <asp:BoundField DataField="Capacity" HeaderText="Capacity"
                                    SortExpression="Capacity" />
                                <asp:TemplateField HeaderText="Manufacturer">
                                    <ItemTemplate>
                                        <%#DisplayManufacturer(Eval("ManufacturerID"))%>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="TankType" HeaderText="Tank Type"
                                    SortExpression="TankType" Visible="false" />
                                <asp:BoundField DataField="Compartment" HeaderText="Compartment"
                                    SortExpression="Compartment" Visible="false" />
                                <asp:BoundField DataField="DecalID" HeaderText="DecalID"
                                    SortExpression="DecalID" Visible="false" />
                                <asp:TemplateField HeaderText="Decal Status">
                                    <ItemTemplate>
                                        <%#DisplayTestLink(Eval("CargoTankID"))%>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                     </td>

                  </tr>
                </table>

            </div>
            </asp:Panel>
        </asp:Panel>
   </ContentTemplate>
    <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />

    </Triggers>
  </asp:UpdatePanel>

Here is my code behind:

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then
        If (Me.Page.User.Identity.IsAuthenticated) Then
            Dim db As DataClassesDataContext = New DataClassesDataContext()

            Dim tanks = From t In db.CT_Tanks _
                        Select t

            Me.grdTanks.DataSource = tanks
            Me.grdTanks.DataBind()

            Dim tanktype = (From t In db.CT_TankTypes _
                            Select t).ToList

            ddlTankType.DataSource = tanktype
            ddlTankType.DataTextField = "TankTypeName"
            ddlTankType.DataValueField = "TankTypeName"
            ddlTankType.DataBind()
            ddlTankType.Items.Insert(0, "-- Select a Type --")
            ddlTankType2.DataSource = tanktype
            ddlTankType2.DataTextField = "TankTypeName"
            ddlTankType2.DataValueField = "TankTypeName"
            ddlTankType2.DataBind()
            ddlTankType2.Items.Insert(0, "-- Select a Type --")

            Dim manufacturer = (From m In db.CT_Manufacturers _
                               Select m).ToList

            ddlManufacturer.DataSource = manufacturer
            ddlManufacturer.DataTextField = "ManufacturerName"
            ddlManufacturer.DataValueField = "ManufacturerID"
            ddlManufacturer.DataBind()
            ddlManufacturer.Items.Insert(0, "-- Select a Manufacturer --")

            ddlManufacturer2.DataSource = manufacturer
            ddlManufacturer2.DataTextField = "ManufacturerName"
            ddlManufacturer2.DataValueField = "ManufacturerID"
            ddlManufacturer2.DataBind()
            ddlManufacturer2.Items.Insert(0, "-- Select a Manufacturer --")

            Dim companies = (From c In db.CT_Companies _
                             Where c.IsOwner = True _
                             Select c Order By c.CompanyName Ascending).ToList

            ddlCompany.DataSource = companies
            ddlCompany.DataTextField = "CompanyName"
            ddlCompany.DataValueField = "CompanyID"
            ddlCompany.DataBind()
            ddlCompany.Items.Insert(0, "-- Select a Company --")

            ddlCompany2.DataSource = companies
            ddlCompany2.DataTextField = "CompanyName"
            ddlCompany2.DataValueField = "CompanyID"
            ddlCompany2.DataBind()
            ddlCompany2.Items.Insert(0, "-- Select a Company --")

        End If
    End If

End Sub


HTTPS Force Redirect not working in Wordpress

My Wordpress directory is at www.example.com/blog

I recently changed my entire site to force HTTPS. So my .htaccess file in /blog/ looks like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

I also changed the site URL in Wordpress settings to be HTTPS.

This works perfectly in the homepage, but in any post pages, the end user is able to change to non-secure HTTP, by changing the URL and pressing enter.

For example, they can type directly: http://www.example.com/blog/post-1/ and it will load as HTTP.

What is wrong with my .htaccess file? Where is the loose end?


How to print errors while streaming with tweepy in python?

I am a Python newbie and am trying to print error messages when using Tweepy to stream tweets. I used an endless loop in my streaming code because it generates InComplete Read errors otherwise. My aim is to print all the error messages I get while continuing to stream tweets, so that I am aware of errors other than the InComplete Read errors.

My streamListerner is:

# Code from http://badhessian.org/2012/10/collecting-real-time-twitter-data-    with-the-streaming-api/ with minor modifications
import json, time, sys
from tweepy import StreamListener

# create an instance of a tweepy StreamListener to handle the incoming data.
class SListener(StreamListener):

    def __init__(self, fprefix = 'streamer'):
        # self.api = api or API()
        self.counter = 0
        self.fprefix = fprefix
        self.output  = open('../Dissertation/stream_3_data/' + fprefix + '.' + time.strftime('%Y%m%d-%H%M%S') + '.json', 'w')
        self.delout  = open('delete.txt', 'a')

    def on_data(self, data):

        if  'in_reply_to_status' in data:
            self.on_status(data)
        elif 'delete' in data:
            delete = json.loads(data)['delete']['status']
            if self.on_delete(delete['id'], delete['user_id']) is False:
                return False
        elif 'limit' in data:
            if self.on_limit(json.loads(data)['limit']['track']) is False:
                return False
        elif 'warning' in data:
            warning = json.loads(data)['warnings']
            print warning['message']
            return False

    def on_status(self, status):
        self.output.write(status)

        self.counter += 1

        if self.counter >= 5000: # New file is started every 5,000 tweets, tagged with prefix and a timestamp.
            self.output.close()
            self.output = open('../Dissertation/stream_3_data/' + self.fprefix + '.'
                           + time.strftime('%Y%m%d-%H%M%S') + '.json', 'w')
            self.counter = 0

        return

    def on_delete(self, status_id, user_id):
        self.delout.write( str(status_id) + "\n")
        return

    def on_limit(self, track):
        sys.stderr.write(track + "\n")
        return

    def on_error(self, status_code):
        sys.stderr.write('Error: ' + str(status_code) + "\n")
        return True # Don't kill the stream

    def on_timeout(self):
        sys.stderr.write("Timeout, sleeping for 60 seconds...\n")
        time.sleep(60)
        return True # Don't kill the stream

The part that seems to generate problems is when I try to use the streamlistener:

twitter_api = tweepy_oauth()
Q = "twitter.com"

locations = [101.615161,3.08115,101.753663,3.167507,
         115.421372,39.43277,117.501099,41.05999,
         120.858322,30.69094,121.9733,31.86889]

# Create a streaming API and set a timeout value of 60 seconds.
streaming_api = tweepy.streaming.Stream(twitter_api, SListener(), timeout=60)

# Used infinite loop from https://github.com/ryanmcgrath/twython/issues/288 cause
# I kept getting InComplete Read Error. Probably due to high volumes of tweets being sent to me at once

#Endless loop
while True:
    try:
        streaming_api.filter(follow=None, track=None, locations=locations, stall_warnings=True)
    except:
        e = sys.exc_info()[0]  #Get exception info
        print 'ERROR:',e  #Print exception info
        continue

My code does run and works, but I encounter the following error occasionally, which stops my entire stream:

---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-4-fb45fa5d8307> in <module>()
      34         streaming_api.filter(follow=None, track=None, locations=locations, stall_warnings=True)
      35     except:
      36         e = sys.exc_info()[0]  #Get exception info
 ---> 37         print 'ERROR:',e  #Print exception info
      38         continue

 IOError: [Errno 22] Invalid argument

The timing when the error appears is inconsistent - it ranges from 1h into the stream to an entire day into the stream.

I concluded that the issue is with the print statement because I replaced line 37 with

print 'Error'

and the same error message appears. I am not sure how to proceed when even the basic print statement does not work - any help would be great.


Solr searching within a dictionary file

I was wondering if there is something out of the box from Solr which would allow me to search within a dictinary file (containing words and phrases) to returning all the phrases that contains my search terms.

For example, my dictionary file could have:

red car
blue bike
big bike tires

When I search 'bike', I expect to see

blue bike
big bike tires

And when I search 'big tires', i expect to see

big bike tires

Is there anything from Solr that could support this? I was looking into the SpellCheckComponent but it would only support prefix searches.

Basically, I would like to achieve solr searches (token searching) but against a dictionary file (this same file would also be used for autosuggest).

Any advice or direction would be appreciated.


How can I use material-ripple to create a button-like component?

I want to create a button-like component with ripple animation and it looks like this:

<div>Button</div>
<material-ripple></material-ripple>

In the past, this works fine because when I click on this custom element, I actually clicks on material-ripple and the click event bubbles to the host element.

As of angular_components 0.5.1, material-ripple shows a centered ripple on keypress. This is different from clicking because the event target is the host element itself and not the ripple component.

Is there a way that I can pass a keypress event down to the material-ripple, so that the ripple animation would be played? Or is there a way to play the animation programmatically?


How to sum up based on a Tuples first elem?

I have a 3-tuple list like the following [I added line breaks for readability]:

(2, 127, 3)
(12156, 127, 3)
(4409, 127, 2) <-- 4409 occurs 2x
(1312, 127, 12) <-- 1312 occurs 3x

(4409, 128, 1) <--
(12864, 128, 1)
(1312, 128, 1) <--
(2664, 128, 2)

(12865, 129, 1)
(183, 129, 1)
(12866, 129, 2)
(1312, 129, 10) <--

I want to sum up based on the first entry. The first entry should be unique.

The result should look like this:

(2, 127, 3)
(12156, 127, 3)
(4409, 127, 3) <- new sum = 3
(1312, 127, 23) <- new sum = 23

(12864, 128, 1)
(2664, 128, 2)

(12865, 129, 1)
(183, 129, 1)
(12866, 129, 2)

How can I achieve this in Scala?


how we can shift X and Y axis to center in Bubble chart (JQPlot)

I am trying to shift bubble chart X and Y axis to the center. I am unable to find the exact configuration.

Currently i am getting the graph as shown below

I want to get it as shown below

please help me out


Throwing exception in @Before, catching in @AfterThrowing

I created a @Before Advice that throws an exception and tried to catch it in another @AfterThrowing, but it does not work.

If the exception is not thrown in the advice, but directly in the method, it works.

If it is thrown in the advice, the @AfterThrowing is not executed.

Why does it behave like that?


WordPress Website is generating random Advertisements in new tab

I am facing a problem with my website https://konhost.com, whenever I open my website in a new tab or new window and click on it for the first time then it opens a new window with an advertisement.

I have also scaned my website with virustotal.com and this comes out:

accept-ranges: bytes

age: 0

cache-control: no-store, no-cache, must-revalidate

connection: keep-alive

content-type: text/html; charset=UTF-8

date: Fri, 08 Sep 2017 19:25:49 GMT

expires: Thu, 19 Nov 1981 08:52:00 GMT

pragma: no-cache

set-cookie: PHPSESSID=0t51snf947vas0a2ifsq8v4590; path=/

transfer-encoding: chunked

vary: Accept-Encoding

x-cache: MISS

x-varnish: 184009294

But I am still not sure what to do and how to fix this problem. Any help will be really appreciated.

Thanks.


How to convert "Fri Sep 21 15:23:59 CEST 2012" to "2012-09-21T15:23:59" in Java?

I want to convert the date string "Fri Sep 21 15:23:59 CEST 2012" to "2012-09-21T15:23:59" in Java.
I tried this with SimpleDateFormat and the following code:

try {
    String dateString = "Fri Sep 21 15:23:59 CEST 2012";
    SimpleDateFormat input = new SimpleDateFormat("EEE MM dd HH:mm:ss z YYYY");
    SimpleDateFormat output = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");

    Date date = input.parse(dateString);
    System.out.println(output.format(date));
} catch (ParseException e) {
    e.printStackTrace();
}

But the input parsing gives me a java.text.ParseException. I have read the documetation at http://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html, but I am not able to find the error.

Which format string solves the input parsing of this string?


Sum of Each Branch in a Binary Search Tree

My assignment is to find the sum of all nodes on each branch in a binary search tree using recursion, and compare them to a user input value. If the user input value matches a sum of one of the branches, the function should return true.

In other words, the sum of 32+24+21+14=91. The sum of 32+24+28+25=109. The sum of 32+24+28+31=115 etc. I have tried many different methods, but cant seem to figure out how to traverse each branch accurately. So far I have only been able to traverse and find the sum of the left-most branch.

I am using the method of subtracting each node from the user input value. If the value reaches 0 at a Leaf-node, then clearly the user-input matches the node-sum of that branch on the tree.

The particular points of difficulty for me are when the branch diverges, such as at the node [24] and [28]. I clearly am getting something very simple wrong, but I cant figure it out.

Below is the condensed code I've written so far, in the form of two companion methods (also required for the assignment).

public:
bool findBranchSum1(int value) throw (InvalidTreeArgument) {
    if (root == nullptr)
        throw InvalidTreeArgument();
    return(findBranchSum(root, value));
}

private:
bool findBranchSum(NodePtr node, int value) throw (InvalidTreeArgument)
{
    bool result = false;
    if (root == nullptr)
        throw InvalidTreeArgument();

    value -= node->getElement(); //subtract current node from user-input value.

    cout << "Current Value = " << value << endl; //help track value changes

    if (node->getLeftSide() == nullptr && node->getRightSide() == nullptr)
        {
            if (value == 0)
            {
                result = true;
                return(true);
            }
            else
                return(false);
        }
    else
    {
        if (node->getLeftSide() != nullptr)
        {
            node = node->getLeftSide(); //advance to next Left node
            result = findBranchSum(node, value); //recursive call using new node
        }
        if (node->getRightSide() != nullptr)
        {
            node = node->getRightSide(); //advance to next Right node
            result = findBranchSum(node, value); //recursive call using new node
        }
        return(result);
    }
}

What am I doing wrong, and how can I fix my code to find the sum of each branch on the tree? Thank you in advance. I apologize for any errors in my format, or missing information.


Using golang couchbase community sdk with MutateIn

When I'm using MutateIn function I always get "No access." error

func (s *service) UserUpdateAvatar(avatarLink string) error {
    key := "profile::1"
    var user User
    _, _ = s.profileBucket.Get(key, &user)
    logrus.Println(user) // printing the user as expected
    logrus.Println(avatarLink) // printing the avatarLink as expected
    mtinb := s.profileBucket.MutateIn(key, 0, 0).Upsert("avatarUrl", avatarLink, true)
    _, err := mtinb.Execute() // throughs "No access." error
    if err != nil {
        logrus.Println(err)
    }
    return nil
}

I'm using go version 1.6, couchbase community 4.0.0


Does List.subList keep a reference to the original list?

If I have a variable

LinkedList list

and repeatedly do the following to extract the tail of 'list'

// Some operation that adds elements to 'list'
// max_size = some constant
list = (LinkedList) list.subList(list.size()-max_size, list.size());

do I end up with a lot of references to the 'previous' list?

So basically what I'm trying to do here is to remove an initial segment of the list.

Is there a better way to remove an initial segment of a LinkedList?  I think the data structure of LinkedList should allow linear time (linear in the size of the initial segment to be removed) operation.


Continuous scrolling of UILabel like marquee

Following is my code to scroll the UILabel horizontal such that it appears as the marquee effect. But the animation starts with the label in center and scrolls till its width and again stats from the center. I want continuous scrolling like marquee from left to right.Can any body help me please.

-(void)loadLabel{

    if (messageView) {
        [messageView removeFromSuperview];
    }

    NSString *theMessage = text;
    messageSize = [theMessage sizeWithFont:font];
    messageView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, messageSize.width, 916)]; //x,y,width,height
    [messageView setClipsToBounds:NO]; // With This you prevent the animation to be drawn outside the bounds.
    [self.view addSubview:messageView];
    lblTime = [[RRSGlowLabel alloc] initWithFrame:CGRectMake(0, 0, messageSize.width, 916)]; //x,y,width,height
    [lblTime setBackgroundColor:[UIColor yellowColor]];
    lblTime.font = font;
    [lblTime setText:theMessage];
    lblTime.glowOffset = CGSizeMake(0.0, 0.0);
    lblTime.glowAmount = 90.0;
    lblTime.glowColor = color;
    [lblTime setClipsToBounds:NO];
    [lblTime setTextColor:color];
    [lblTime setTextAlignment:UITextAlignmentLeft];
    lblTime.frame = messageView.bounds ; //x,y,width,height
    [messageView addSubview:lblTime];

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:speed];

    [UIView setAnimationRepeatCount:HUGE_VALF];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:messageView cache:YES];
    lblTime.frame = CGRectMake(-messageSize.width, 45, messageSize.width, 916); //x,y,width,height
    [UIView commitAnimations];
}


TFS 2008 Build and deploy to Inetpub web folder

I have TFS2008 and have a build running, however, I want to automate the deployment of the build folder and place the build into the inetpub folder it belongs to.

I.E.:

Run Build

After Build, automatically place the new built solution into Inetpub/wwwroot/websitefolder

I have tried xcopy, robocopy and synctoy 2.1 and I cannot get any of them to work.

(xcopy use)

<Exec Command="xcopy $(DropLocation)\$(BuildNumber)\Debug\_PublishedWebsites\IPAMIntranet C:\Inetpub\wwwroot\IPAMOnlineSystem.Test /E " />

(robocopy use)

<Exec Command="ROBOCOPY $(DropLocation)\$(BuildNumber)\Debug\_PublishedWebsites\IPAMIntranet C:\Inetpub\wwwroot\IPAMOnlineSystem.Test /S /XJ /B /R:5" />

(synctoy 2.1 use)

<Exec Command="SyncToyCmd.exe -RIPAMBuildProjectDeploy" />

Can anyone at all please help me with this dilemna?

Thank you in advance


How do you use the Immediate Window in Visual Studio?

The Immediate Window is an immensely useful tool for debugging applications. It can be used to execute code statements that are valid in the context of a break point and inspect values. I also use it to type code snippets to learn language features.

How do you use the Immediate Window?


Restrict access to all URIs except several, Spring security

I would like to restrict the access to all URIs except several ones.

The following URIs can be access freely: "/", "/login", "/register"

Any others can be accessed by passing authenticated procedure.

Here is the code that has to restrict access to all URIs except the "/", "/login", "/register" (I have found it on StackOverflow):

   @Configuration
@EnableWebSecurity
public class SecurityContextConfiguration extends WebSecurityConfigurerAdapter {
    @Autowired
    private UserDetailsImpl userDetailsService;

    @Autowired
    public void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth
                .userDetailsService(userDetailsService)
                .passwordEncoder(getBCryptPasswordEncoder());
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf()
                .disable()
                .authorizeRequests()
                .antMatchers("/resources/**", "/**").permitAll()
                .and();

        http.formLogin()
                .loginPage("/login")
                .loginProcessingUrl("/j_spring_security_check")
                .usernameParameter("j_username")
                .passwordParameter("j_password")
                .permitAll().defaultSuccessUrl("/dashboard");

        http.logout()
                .permitAll()
                .logoutUrl("/logout")
                .logoutSuccessUrl("/")
                .invalidateHttpSession(true);

        http.authorizeRequests()
                .antMatchers("/", "/login", "/register").permitAll()
                .antMatchers("/**").authenticated();
    }

    @Bean
    public BCryptPasswordEncoder getBCryptPasswordEncoder(){
        return new BCryptPasswordEncoder();
    }
}

The issue is that when I generate get request (i.e. click on the following link <a href="/register">Register</a>) the login page is being displayed. However, it should simply display the registration JSP page.

What did I make wrong? And how can I properly restrict access to all URIs except the several ones?

Part from my auth controller:

@RequestMapping(value = "/register", method = RequestMethod.GET)
    public String displayRegistrationForm(Model model) {
        model.addAttribute("user", new Customer());
        return "register";
    }

    @RequestMapping(value = "/register", method = RequestMethod.POST)
    public String processUserRegistration(@Valid @ModelAttribute("user") Customer customer,
                                          BindingResult result,
                                          Model model) {

        if (result.hasErrors()) {
            return "register";
        }
        if (customerRepository.checkIfEmailExistsInDatabase(customer.getEmail())) {
            result.rejectValue("email", "email_exist", "Email is in DB");
            return "register";
        }
        if (customerRepository.checkIfLoginExistsInDb(customer)) {
            result.rejectValue("login", "login_exists", "Login is in DB");
            return "register";
        }
        customer.setPassword(bCryptPasswordEncoder.encode(customer.getPassword()));
        customerRepository.insert(customer);
        model.addAttribute("user", customer);
        if (customer.getCustomerType().getTypeName().equals("BUSINESS")) {
            model.addAttribute("gasstation", new GasStation());
            return "redirect:add_gasstation";
        } else {
            model.addAttribute("vehicle", new Vehicle());
            return "redirect:add_vehicle";
        }
    }


Elements in footer different with firefox and chrome

So I noticed something weird when testing website in different browsers. In Firefox  element and h3 heading are on same line, but in Chrome  element is under the border and not in line with title element.

<footer class="main-footer">
   <h3>Author1<a href="#home" class="foot-nav">BACK TO TOP</a></h3>
</footer>

CSS:

    .main-footer a {
        text-decoration: none;
        font-size: .75em;
        float: right;
        color: #626262;
        padding-top: 3px;
        margin-top: -38px;
     }