/*
 * STM32 - TIM2 (General purpose timer) emulation.
 *
 * Copyright (c) 2016 Liviu Ionescu.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, see <http://www.gnu.org/licenses/>.
 */

#include <hw/cortexm/stm32/tim2.h>
#include <hw/cortexm/stm32/mcu.h>
#include <hw/cortexm/helper.h>
#include <hw/cortexm/svd.h>

// ----- Generated code -------------------------------------------------------
//
// ----- 8< ----- 8< -----  8< ----- 8< ----- 8< ----- 8< ----- 8< -----

// DO NOT EDIT! Automatically generated!
static void stm32f103xx_tim2_create_objects(Object *obj, JSON_Object *svd, const char *name)
{
    STM32TIM2State *state = STM32_TIM2_STATE(obj);

    JSON_Object *periph = svd_get_peripheral_by_name(svd, name);
    svd_add_peripheral_properties_and_children(obj, periph, svd);

    // Registers.
    state->u.f1.reg.cr1 = cm_object_get_child_by_name(obj, "CR1");
    state->u.f1.reg.cr2 = cm_object_get_child_by_name(obj, "CR2");
    state->u.f1.reg.smcr = cm_object_get_child_by_name(obj, "SMCR");
    state->u.f1.reg.dier = cm_object_get_child_by_name(obj, "DIER");
    state->u.f1.reg.sr = cm_object_get_child_by_name(obj, "SR");
    state->u.f1.reg.egr = cm_object_get_child_by_name(obj, "EGR");
    state->u.f1.reg.ccmr1_output = cm_object_get_child_by_name(obj, "CCMR1_Output");
    state->u.f1.reg.ccmr1_input = cm_object_get_child_by_name(obj, "CCMR1_Input");
    state->u.f1.reg.ccmr2_output = cm_object_get_child_by_name(obj, "CCMR2_Output");
    state->u.f1.reg.ccmr2_input = cm_object_get_child_by_name(obj, "CCMR2_Input");
    state->u.f1.reg.ccer = cm_object_get_child_by_name(obj, "CCER");
    state->u.f1.reg.cnt = cm_object_get_child_by_name(obj, "CNT");
    state->u.f1.reg.psc = cm_object_get_child_by_name(obj, "PSC");
    state->u.f1.reg.arr = cm_object_get_child_by_name(obj, "ARR");
    state->u.f1.reg.ccr1 = cm_object_get_child_by_name(obj, "CCR1");
    state->u.f1.reg.ccr2 = cm_object_get_child_by_name(obj, "CCR2");
    state->u.f1.reg.ccr3 = cm_object_get_child_by_name(obj, "CCR3");
    state->u.f1.reg.ccr4 = cm_object_get_child_by_name(obj, "CCR4");
    state->u.f1.reg.dcr = cm_object_get_child_by_name(obj, "DCR");
    state->u.f1.reg.dmar = cm_object_get_child_by_name(obj, "DMAR");

    // CR1 bitfields.
    state->u.f1.fld.cr1.cen = cm_object_get_child_by_name(state->u.f1.reg.cr1, "CEN");
    state->u.f1.fld.cr1.udis = cm_object_get_child_by_name(state->u.f1.reg.cr1, "UDIS");
    state->u.f1.fld.cr1.urs = cm_object_get_child_by_name(state->u.f1.reg.cr1, "URS");
    state->u.f1.fld.cr1.opm = cm_object_get_child_by_name(state->u.f1.reg.cr1, "OPM");
    state->u.f1.fld.cr1.dir = cm_object_get_child_by_name(state->u.f1.reg.cr1, "DIR");
    state->u.f1.fld.cr1.cms = cm_object_get_child_by_name(state->u.f1.reg.cr1, "CMS");
    state->u.f1.fld.cr1.arpe = cm_object_get_child_by_name(state->u.f1.reg.cr1, "ARPE");
    state->u.f1.fld.cr1.ckd = cm_object_get_child_by_name(state->u.f1.reg.cr1, "CKD");

    // CR2 bitfields.
    state->u.f1.fld.cr2.ccds = cm_object_get_child_by_name(state->u.f1.reg.cr2, "CCDS");
    state->u.f1.fld.cr2.mms = cm_object_get_child_by_name(state->u.f1.reg.cr2, "MMS");
    state->u.f1.fld.cr2.ti1s = cm_object_get_child_by_name(state->u.f1.reg.cr2, "TI1S");

    // SMCR bitfields.
    state->u.f1.fld.smcr.sms = cm_object_get_child_by_name(state->u.f1.reg.smcr, "SMS");
    state->u.f1.fld.smcr.ts = cm_object_get_child_by_name(state->u.f1.reg.smcr, "TS");
    state->u.f1.fld.smcr.msm = cm_object_get_child_by_name(state->u.f1.reg.smcr, "MSM");
    state->u.f1.fld.smcr.etf = cm_object_get_child_by_name(state->u.f1.reg.smcr, "ETF");
    state->u.f1.fld.smcr.etps = cm_object_get_child_by_name(state->u.f1.reg.smcr, "ETPS");
    state->u.f1.fld.smcr.ece = cm_object_get_child_by_name(state->u.f1.reg.smcr, "ECE");
    state->u.f1.fld.smcr.etp = cm_object_get_child_by_name(state->u.f1.reg.smcr, "ETP");

    // DIER bitfields.
    state->u.f1.fld.dier.uie = cm_object_get_child_by_name(state->u.f1.reg.dier, "UIE");
    state->u.f1.fld.dier.cc1ie = cm_object_get_child_by_name(state->u.f1.reg.dier, "CC1IE");
    state->u.f1.fld.dier.cc2ie = cm_object_get_child_by_name(state->u.f1.reg.dier, "CC2IE");
    state->u.f1.fld.dier.cc3ie = cm_object_get_child_by_name(state->u.f1.reg.dier, "CC3IE");
    state->u.f1.fld.dier.cc4ie = cm_object_get_child_by_name(state->u.f1.reg.dier, "CC4IE");
    state->u.f1.fld.dier.tie = cm_object_get_child_by_name(state->u.f1.reg.dier, "TIE");
    state->u.f1.fld.dier.ude = cm_object_get_child_by_name(state->u.f1.reg.dier, "UDE");
    state->u.f1.fld.dier.cc1de = cm_object_get_child_by_name(state->u.f1.reg.dier, "CC1DE");
    state->u.f1.fld.dier.cc2de = cm_object_get_child_by_name(state->u.f1.reg.dier, "CC2DE");
    state->u.f1.fld.dier.cc3de = cm_object_get_child_by_name(state->u.f1.reg.dier, "CC3DE");
    state->u.f1.fld.dier.cc4de = cm_object_get_child_by_name(state->u.f1.reg.dier, "CC4DE");
    state->u.f1.fld.dier.tde = cm_object_get_child_by_name(state->u.f1.reg.dier, "TDE");

    // SR bitfields.
    state->u.f1.fld.sr.uif = cm_object_get_child_by_name(state->u.f1.reg.sr, "UIF");
    state->u.f1.fld.sr.cc1if = cm_object_get_child_by_name(state->u.f1.reg.sr, "CC1IF");
    state->u.f1.fld.sr.cc2if = cm_object_get_child_by_name(state->u.f1.reg.sr, "CC2IF");
    state->u.f1.fld.sr.cc3if = cm_object_get_child_by_name(state->u.f1.reg.sr, "CC3IF");
    state->u.f1.fld.sr.cc4if = cm_object_get_child_by_name(state->u.f1.reg.sr, "CC4IF");
    state->u.f1.fld.sr.tif = cm_object_get_child_by_name(state->u.f1.reg.sr, "TIF");
    state->u.f1.fld.sr.cc1of = cm_object_get_child_by_name(state->u.f1.reg.sr, "CC1OF");
    state->u.f1.fld.sr.cc2of = cm_object_get_child_by_name(state->u.f1.reg.sr, "CC2OF");
    state->u.f1.fld.sr.cc3of = cm_object_get_child_by_name(state->u.f1.reg.sr, "CC3OF");
    state->u.f1.fld.sr.cc4of = cm_object_get_child_by_name(state->u.f1.reg.sr, "CC4OF");

    // EGR bitfields.
    state->u.f1.fld.egr.ug = cm_object_get_child_by_name(state->u.f1.reg.egr, "UG");
    state->u.f1.fld.egr.cc1g = cm_object_get_child_by_name(state->u.f1.reg.egr, "CC1G");
    state->u.f1.fld.egr.cc2g = cm_object_get_child_by_name(state->u.f1.reg.egr, "CC2G");
    state->u.f1.fld.egr.cc3g = cm_object_get_child_by_name(state->u.f1.reg.egr, "CC3G");
    state->u.f1.fld.egr.cc4g = cm_object_get_child_by_name(state->u.f1.reg.egr, "CC4G");
    state->u.f1.fld.egr.tg = cm_object_get_child_by_name(state->u.f1.reg.egr, "TG");

    // CCMR1_Output bitfields.
    state->u.f1.fld.ccmr1_output.cc1s = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_output, "CC1S");
    state->u.f1.fld.ccmr1_output.oc1fe = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_output, "OC1FE");
    state->u.f1.fld.ccmr1_output.oc1pe = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_output, "OC1PE");
    state->u.f1.fld.ccmr1_output.oc1m = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_output, "OC1M");
    state->u.f1.fld.ccmr1_output.oc1ce = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_output, "OC1CE");
    state->u.f1.fld.ccmr1_output.cc2s = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_output, "CC2S");
    state->u.f1.fld.ccmr1_output.oc2fe = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_output, "OC2FE");
    state->u.f1.fld.ccmr1_output.oc2pe = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_output, "OC2PE");
    state->u.f1.fld.ccmr1_output.oc2m = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_output, "OC2M");
    state->u.f1.fld.ccmr1_output.oc2ce = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_output, "OC2CE");

    // CCMR1_Input bitfields.
    state->u.f1.fld.ccmr1_input.cc1s = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_input, "CC1S");
    state->u.f1.fld.ccmr1_input.ic1psc = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_input, "IC1PSC");
    state->u.f1.fld.ccmr1_input.ic1f = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_input, "IC1F");
    state->u.f1.fld.ccmr1_input.cc2s = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_input, "CC2S");
    state->u.f1.fld.ccmr1_input.ic2psc = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_input, "IC2PSC");
    state->u.f1.fld.ccmr1_input.ic2f = cm_object_get_child_by_name(state->u.f1.reg.ccmr1_input, "IC2F");

    // CCMR2_Output bitfields.
    state->u.f1.fld.ccmr2_output.cc3s = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_output, "CC3S");
    state->u.f1.fld.ccmr2_output.oc3fe = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_output, "OC3FE");
    state->u.f1.fld.ccmr2_output.oc3pe = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_output, "OC3PE");
    state->u.f1.fld.ccmr2_output.oc3m = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_output, "OC3M");
    state->u.f1.fld.ccmr2_output.oc3ce = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_output, "OC3CE");
    state->u.f1.fld.ccmr2_output.cc4s = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_output, "CC4S");
    state->u.f1.fld.ccmr2_output.oc4fe = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_output, "OC4FE");
    state->u.f1.fld.ccmr2_output.oc4pe = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_output, "OC4PE");
    state->u.f1.fld.ccmr2_output.oc4m = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_output, "OC4M");
    state->u.f1.fld.ccmr2_output.o24ce = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_output, "O24CE");

    // CCMR2_Input bitfields.
    state->u.f1.fld.ccmr2_input.cc3s = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_input, "CC3S");
    state->u.f1.fld.ccmr2_input.ic3psc = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_input, "IC3PSC");
    state->u.f1.fld.ccmr2_input.ic3f = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_input, "IC3F");
    state->u.f1.fld.ccmr2_input.cc4s = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_input, "CC4S");
    state->u.f1.fld.ccmr2_input.ic4psc = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_input, "IC4PSC");
    state->u.f1.fld.ccmr2_input.ic4f = cm_object_get_child_by_name(state->u.f1.reg.ccmr2_input, "IC4F");

    // CCER bitfields.
    state->u.f1.fld.ccer.cc1e = cm_object_get_child_by_name(state->u.f1.reg.ccer, "CC1E");
    state->u.f1.fld.ccer.cc1p = cm_object_get_child_by_name(state->u.f1.reg.ccer, "CC1P");
    state->u.f1.fld.ccer.cc2e = cm_object_get_child_by_name(state->u.f1.reg.ccer, "CC2E");
    state->u.f1.fld.ccer.cc2p = cm_object_get_child_by_name(state->u.f1.reg.ccer, "CC2P");
    state->u.f1.fld.ccer.cc3e = cm_object_get_child_by_name(state->u.f1.reg.ccer, "CC3E");
    state->u.f1.fld.ccer.cc3p = cm_object_get_child_by_name(state->u.f1.reg.ccer, "CC3P");
    state->u.f1.fld.ccer.cc4e = cm_object_get_child_by_name(state->u.f1.reg.ccer, "CC4E");
    state->u.f1.fld.ccer.cc4p = cm_object_get_child_by_name(state->u.f1.reg.ccer, "CC4P");

    // CNT bitfields.
    state->u.f1.fld.cnt.cnt = cm_object_get_child_by_name(state->u.f1.reg.cnt, "CNT");

    // PSC bitfields.
    state->u.f1.fld.psc.psc = cm_object_get_child_by_name(state->u.f1.reg.psc, "PSC");

    // ARR bitfields.
    state->u.f1.fld.arr.arr = cm_object_get_child_by_name(state->u.f1.reg.arr, "ARR");

    // CCR1 bitfields.
    state->u.f1.fld.ccr1.ccr1 = cm_object_get_child_by_name(state->u.f1.reg.ccr1, "CCR1");

    // CCR2 bitfields.
    state->u.f1.fld.ccr2.ccr2 = cm_object_get_child_by_name(state->u.f1.reg.ccr2, "CCR2");

    // CCR3 bitfields.
    state->u.f1.fld.ccr3.ccr3 = cm_object_get_child_by_name(state->u.f1.reg.ccr3, "CCR3");

    // CCR4 bitfields.
    state->u.f1.fld.ccr4.ccr4 = cm_object_get_child_by_name(state->u.f1.reg.ccr4, "CCR4");

    // DCR bitfields.
    state->u.f1.fld.dcr.dba = cm_object_get_child_by_name(state->u.f1.reg.dcr, "DBA");
    state->u.f1.fld.dcr.dbl = cm_object_get_child_by_name(state->u.f1.reg.dcr, "DBL");

    // DMAR bitfields.
    state->u.f1.fld.dmar.dmab = cm_object_get_child_by_name(state->u.f1.reg.dmar, "DMAB");
}

// ----- 8< ----- 8< -----  8< ----- 8< ----- 8< ----- 8< ----- 8< -----

// ----- Private --------------------------------------------------------------

#if 0
static peripheral_register_t stm32_tim2_xxx_pre_write_callback(Object *reg,
        Object *periph, uint32_t addr, uint32_t offset, unsigned size,
        peripheral_register_t value, peripheral_register_t full_value)
{
    STM32TIM2State *state = STM32_TIM2_STATE(periph);

    peripheral_register_t prev_value = peripheral_register_get_raw_prev_value(reg);

    // TODO: Add code to adjust the value (like applying some masks,
    // for example prevent setting interrupts not enabled).
    // Also process cleared/set by write 1/0 bits.
    // The returned value will be stored in the register value.

    return full_value;
}

static void stm32_tim2_xxx_post_write_callback(Object *reg, Object *periph,
        uint32_t addr, uint32_t offset, unsigned size,
        peripheral_register_t value, peripheral_register_t full_value)
{
    STM32TIM2State *state = STM32_TIM2_STATE(periph);

    peripheral_register_t prev_value = peripheral_register_get_raw_prev_value(reg);
    // The new register value is full_value, the old one is prev_value.

    // TODO: Add code to send the value to the consumer.
}

static peripheral_register_t stm32_tim2_xxx_pre_read_callback(Object *reg,
        Object *periph, uint32_t addr, uint32_t offset, unsigned size)
{
    STM32TIM2State *state = STM32_TIM2_STATE(periph);

    peripheral_register_t value = 0;

    // Add code to get the value from the producer, and return it.

    // This value, possibly masked, will be stored in the register
    // and returned when the register is read.
    return value;
}

static void stm32_tim2_xxx_post_read_callback(Object *reg, Object *periph,
        uint32_t addr, uint32_t offset, unsigned size)
{
    STM32TIM2State *state = STM32_TIM2_STATE(periph);

    peripheral_register_t value = peripheral_register_get_raw_value(reg);

    // TODO: add code to perform the post read actions, like clearing some bits.
}
#endif

// ----------------------------------------------------------------------------

// TODO: remove this if the peripheral is always enabled.
static bool stm32_tim2_is_enabled(Object *obj)
{
    STM32TIM2State *state = STM32_TIM2_STATE(obj);

    if (register_bitfield_is_non_zero(state->enabling_bit)) {
        return true; // Positive logic, bit == 1 means enabled.
    }

    // Not enabled
    return false;
}

static void stm32_tim2_instance_init_callback(Object *obj)
{
    qemu_log_function_name();

    STM32TIM2State *state = STM32_TIM2_STATE(obj);

    // Capabilities are not yet available.

    // TODO: remove this if the peripheral is always enabled.
    state->enabling_bit = NULL;

    // TODO: Add code to initialise all members.
}

static void stm32_tim2_realize_callback(DeviceState *dev, Error **errp)
{
    qemu_log_function_name();

    // Call parent realize().
    if (!cm_device_parent_realize(dev, errp, TYPE_STM32_TIM2)) {
        return;
    }

    STM32MCUState *mcu = stm32_mcu_get();
    CortexMState *cm_state = CORTEXM_MCU_STATE(mcu);

    STM32TIM2State *state = STM32_TIM2_STATE(dev);
    // First thing first: get capabilities from MCU, needed everywhere.
    state->capabilities = mcu->capabilities;

    // Also keep a local pointer, to access them easier.
    const STM32Capabilities *capabilities = state->capabilities;
    assert(capabilities != NULL);

    Object *obj = OBJECT(dev);

    const char *periph_name = "TIM2";

    svd_set_peripheral_address_block(cm_state->svd_json, periph_name, obj);
    peripheral_create_memory_region(obj);

    // TODO: remove this if the peripheral is always enabled.
    char enabling_bit_name[STM32_RCC_SIZEOF_ENABLING_BITFIELD];

    switch (capabilities->family) {
    case STM32_FAMILY_F1:

        if (capabilities->f1.is_103xx ) {

            stm32f103xx_tim2_create_objects(obj, cm_state->svd_json, periph_name);

            // TODO: add actions.
            // cm_object_property_set_str(state->u.f1.fld.xxx.fff, "GGG", "follows");
            // cm_object_property_set_str(state->u.f1.fld.xxx.fff, "GGG", "cleared-by");

            // TODO: add callbacks.
            // peripheral_register_set_pre_read(state->f1.reg.xxx, &stm32_tim2_xxx_pre_read_callback);
            // peripheral_register_set_post_read(state->f1.reg.xxx, &stm32_tim2_xxx_post_read_callback);
            // peripheral_register_set_pre_read(state->f1.reg.xxx, &stm32_tim2_xxx_pret_read_callback);
            // peripheral_register_set_post_write(state->f1.reg.xxx, &stm32_tim2_xxx_post_write_callback);

            // TODO: add interrupts.

            // TODO: remove this if the peripheral is always enabled.
            snprintf(enabling_bit_name, sizeof(enabling_bit_name) - 1,
                DEVICE_PATH_STM32_RCC "/AHB1ENR/TIM2EN");

        } else {
            assert(false);
        }

        break;

    default:
        assert(false);
        break;
    }

    // TODO: remove this if the peripheral is always enabled.
    state->enabling_bit = OBJECT(cm_device_by_name(enabling_bit_name));

    peripheral_prepare_registers(obj);
}

static void stm32_tim2_reset_callback(DeviceState *dev)
{
    qemu_log_function_name();

    // Call parent reset(); this will reset all children registers.
    cm_device_parent_reset(dev, TYPE_STM32_TIM2);
}

static void stm32_tim2_class_init_callback(ObjectClass *klass, void *data)
{
    DeviceClass *dc = DEVICE_CLASS(klass);

    dc->reset = stm32_tim2_reset_callback;
    dc->realize = stm32_tim2_realize_callback;

    // TODO: remove this if the peripheral is always enabled.
    PeripheralClass *per_class = PERIPHERAL_CLASS(klass);
    per_class->is_enabled = stm32_tim2_is_enabled;
}

static const TypeInfo stm32_tim2_type_info = {
    .name = TYPE_STM32_TIM2,
    .parent = TYPE_STM32_TIM2_PARENT,
    .instance_init = stm32_tim2_instance_init_callback,
    .instance_size = sizeof(STM32TIM2State),
    .class_init = stm32_tim2_class_init_callback,
    .class_size = sizeof(STM32TIM2Class) };

static void stm32_tim2_register_types(void)
{
    type_register_static(&stm32_tim2_type_info);
}

type_init(stm32_tim2_register_types);

// ----------------------------------------------------------------------------


Twins Reared Apart From Birth: Beyond The Secret Study

[Editor’s Note: This article is part of “Peer Review,” our commissioning project where research scientists write about topics in current film. Dr. Nancy L. Segal is an expert in twin studies, and founder and Director of the Twin Studies Center at California State University, Fullerton. Dr. Segal is also a Professor of Psychology. She writes about Tim Wardle’s THREE IDENTICAL STRANGERS, which follows the lives of Robert Shafran, Eddy Galland, and David Kellman. The film is in theaters, distributed by NEON, and will be released onto VOD and Blu-ray on October 2, 2018.]

It is a study that does not go away.

It was fall 1982 when I arrived at the University of Minnesota as a post-doctoral fellow to work on the Minnesota Study of Twins Reared Apart (MISTRA). By then, the MISTRA had gained considerable stature, drawing attention from national and international scholars, students, and journalists. But for a brief time during my early years in Minnesota, an older twin study was gaining attention once again. CBS’s newsmagazine program Sixty Minutes was preparing an exposé of psychoanalyst Dr. Peter Neubauer’s 1950s-1980s Child Development Center twin project. The program intended to show how and why a group of New York City child psychiatrists and psychologists decided to ‘play God’ by separating infant twins placed through the Louise Wise adoption agency, and track their development without informing the adoptive families that their children were twins. The Agency’s decision to separate twins came from psychiatrist Viola Bernard who advised them that separating twins was in the children’s best interest since it would avoid competition for parental attention. This view was not based on research. The investigative journalists assigned to the Sixty Minutes story wanted to know what the scientists hoped to learn from this unique study, the only one in the world to follow intentionally separated twins prospectively from birth. Ultimately, the planned television special never aired.

Scientists and journalists occasionally revisit this controversial study, most recently in two documentary films, Tim Wardle’s THREE IDENTICAL STRANGERS and Lori Shinseki’s THE TWINNING REACTION, and a 20/20 ABC news program. This notorious twin study has gripped both the public and professionals, perhaps because the project was so unthinkable. It breached not just established research norms, but faith in scientific integrity and belief in the inviolability of family. It is a study that does not go away.

Twin Research: The Science Behind the Fascination

The striking resemblance and exceptional intimacy of genetically identical twins have engaged society for decades. This fascination explains, in part, why stories of their matched achievements in academics and athletics, similar tastes in friends and food, and extraordinary parallels in interests and occupations (even among twins reared apart from birth) have been the focus of books, films, plays, and social media. The 2016 Guinness World Records devoted a special two-page spread to the twin record holders for longest birth interval, longest separated pair, and oldest octuplet set, among other “dual” distinctions. When we encounter identical twins who look and act identically, it challenges general beliefs about personality and development.

Scientists have also been captivated by the striking similarities of identical twins and the relative differences between fraternal—non-identical—twins. In 1875, Sir Francis Galton of Great Britain conducted the first twin study. Though it wasn’t until the early 1920s that biological differences between fraternal and identical twins were known, Galton correctly surmised that there are two types of twins. He thought of them as look-alikes and non look-alikes. Through a letter writing campaign, Galton obtained detailed life history material on 80 sets of twins, of which the members of 35 pairs showed “close similarity” and 20 showed “great dissimilarity.” Contrasting these groups led Galton to his famous conclusion that “nature prevails enormously over nurture.” Today, the classic comparison of trait resemblance between identical (monozygotic or MZ) twins who share 100% of their genes and fraternal (dizygotic or DZ) twins who share on average 50% of their genes is being applied across diverse disciplines. The design is a simple, yet elegant approach to understanding factors affecting height, weight, intelligence, personality traits, religiosity, wage earnings, medical complaints, and mental disorders. While greater resemblance between identical than fraternal twins is consistent with genetic influence on a behavioral or physical characteristic, it does not prove it. Studying the rare pairs of identical twins reared apart from birth provides the best and most direct estimate of how much genes shape our different traits. Twins just have to act naturally to reveal a wealth of information.

Twin Studies in Historical Context

Twin studies were generally frowned upon from the 1950s through the 1970s. There are many historical events that explain their disfavor. They include the Nazi legacy (1933-1945) that supported the biological superiority of some populations over others and the horrific twin experiments conducted in the Auschwitz-Birkenau concentration camps; the 1964 Civil Rights Act that outlawed racial discrimination; and the women’s rights movement of the 1960s that promoted gender equality in educational and occupational settings. Research suggesting that genetic factors affect behavior was strongly rejected in light of these developments, in favor of environmental theories to explain trait development. Twin studies’ reputation was further damaged by controversy about the veracity of the 1943-1966 intelligence test findings of British researcher Sir Cyril Burt. His findings showed genetic effects, but there was doubt over the existence of his reared-apart twin sample and research staff. It should be noted, however, that Burt’s name has been largely cleared (although some may say that the case remains open) and that reports from five well-respected reared-apart twin studies, published in 1937, 1962, 1965, 1990/2007, and 1992 show very similar results.

While all this was happening, events in other regions paved the way for twin research’s amazing comeback in the late 1970s and early 1980s. There was increasing dissatisfaction in the scientific community with environmental explanations of behavior, from both human and non-human laboratories. It was becoming evident that there were biological constraints on what animals could learn. Chromosomal aberrations underlying medical conditions, such as Down syndrome, were being discovered. Biological views of language development and information-processing were gaining attention. Data from available twin and adoption studies of general intelligence were summarized, revealing greater resemblance between close relatives than less distant relatives or non-relatives. Then, in 1979, there was a widely publicized reunion between identical twins, Jim Lewis and Jim Springer, who met for the first time at age thirty-nine. Their similarities included their nail-biting habit, unusual headache syndrome, favorite vacation spot, love of woodworking, and penchant for showering their wives with love letters. University of Minnesota psychology professor Thomas J. Bouchard, Jr., brought them to his laboratory for several days of study.

The twins’ time in Minnesota was widely covered by the press, leading to the identification of other separated sets of twins, and eventually to the launching of the Minnesota Study of Twins Reared Apart. When the study ended in 1999, 81 identical and 56 fraternal separated twin pairs had been studied. There are two key themes that emerged from that work: genetic influence is pervasive, affecting virtually every measured human trait, and shared environments do not make family members alike. The MISTRA transformed behavioral research as it transfixed both the professional and public imagination. A comprehensive account of the project is presented in my 2012 book, Born Together-Reared Apart: The Landmark Minnesota Twin Study.

Renewed attention to Peter Neubauer’s secret study does not threaten the value and validity of twin research. The International Society for Twin Studies, formed in 1974, is thriving and twins are prominent players in molecular-genetic and epigenetic studies of behavior and disease. The Neubauer study does encourage new thinking about investigator responsibilities and participant rights, coming as it does in our current climate of threats to individual identity by government agencies, private companies, and social media platforms. Most offensive is the unspeakable arrogance on the part of Neubauer and his associates who separated the twins for professional gain, the secrecy they maintained in the years that followed, and their lack of remorse when later confronted with that decision. In the 1950s and 1960s, biological and adoptive families were never put in touch—as they often are today—but that is an issue apart from the twins’ separate placement.

Rare family arrangements of scientific significance occasionally happen and researchers can study them with justification. Single parents, or families who cannot afford to raise two children, may choose to relinquish one or both babies. A number of newborn twins have been separated by hospitals that, in, error accidentally switched one twin with one non-twin infant. Twins have even been separated due to political circumstances such as emigration regulations and tax exemption policies. In 2001, I discovered pairs of young twins reared apart because of China’s One-Child Policy, leading to the abandonment of thousands of baby girls. Most of the adoptive parents were unaware that they were raising a singleton twin until their chance viewing of the other twin’s photograph posted on a website. I have been able to track separated twins’ development in real time but, unlike Neubauer, with the full consent of their families. My hope is that project and this article will help reunite other twins who may still be apart.

References:

Galton. F. (1975). The history of twins as a criterion of the relative powers of nature and nurture. Journal of the Anthropological Institute, 5, 391-406.

Segal, N.L. (2012). Born Together - Reared Apart: The Landmark Minnesota Twin Study.

Cambridge, MA: Harvard University Press.


Endoventricular circular patch plasty for end-stage valvular cardiomyopathy.
We present here a case of end-stage non-ischemic valvular dilated cardiomyopathy (DCM) associated with mitral regurgitation (MR). The patient underwent surgery where left ventricular volume reduction using endoventricular circular patch plasty (EVCPP) and mitral valve replacement (MVR) were performed. He has improved much after the operation and is now in New York Heart Association (NYHA) functional class II.


Q:

Hexadecimal string representation to floating number in python

From python documentation says that "the hexadecimal string 0x3.a7p10 represents the floating-point number (3 + 10./16 + 7./16**2) * 2.0**10, or 3740.0" so :
>>> float.fromhex('0x3.a7p10')

3740.0

then
>>> float.hex(3740.0)

'0x1.d380000000000p+11' (will give different presentation)

My question is how to convert '0x1.d380000000000p+11' in to floating number using calculation formula above and why classmethod float.hex and classmethod float.fromhex give different presentation.
Thankyou....

A:

'0x1.d380000000000p+11' means (1 + 13./16 + 3./16**2 + 8/16**3) * 2.0**11, which is equal to 3740.0. To convert this result, you can run float.fromhex('0x1.d380000000000p+11') which returns 3740.0 again.
float.hex gives you a normalized representation, which means that the factor in front of the 2**x is between 1 and 2. What the interpreter did, was shift the comma in the binary representation by one position: increase the exponent (from 10 to 11), and half the factor (0x3.a7 / 2 = 0x1.d38).
In general, in this normalized representation, the factor in front is between 1 and the base. For example, if you do print(2234.2e-34), you get 2.2342e-31. Here the leading factor is between 1 and 10 because e corresponds to 10**x.


England beat co-host Ukraine, 1-0, at Euro 2012 but it barely managed to earn a 1-1 with a late Frank Lampard penalty in their World Cup 2014 qualifier on Tuesday at Wembley
Stadium.

Ukraine had taken the lead on a goal by Evhen Konoplianka in the 39th minute and it looked like it would hold up, but England was awarded a penalty in the
85th minute on an Evhen Khacheridi handball.

Ukraine was all over England and could have been ahead by several goals in the first 10 minutes. Oleh Gusyev
hit the post with a deflection off Alex Oxlade-Chamberlain and Steven Gerrard cleared Ruslan Rotan's effort with goalkeeper Joe Hart
beaten. After that, it was almost all England with the exception of Konoplianka's goal.

England coach Roy Hodgson thought his team had played better on Tuesday than they
had against Ukraine in Donetsk.

"The first 15 minutes we weren't at our best," he said. "The next 75 minutes we dominated the game. The fact is we played against a very good Ukraine team
but I was very pleased with the way the players went about their task. We created chances and struck the post three times. We thoroughly deserved a point."

-- Defending champion Spain needed a goal in the 86th minute from Roberto Soldado to win at Georgia, 1-0, and extend it winning streak in qualifiers to 23 games.

-- Germany, also perfect in Euro 2012 qualifying, earned a 2-1 win over neighbor Austria on goals by Marco Reus and Mesut Ozil in Vienna. "Austria should have
equalized in the end," Germany coach Joachim Loew said.

-- Euro 2012 finalist Italy was unimpressive in a 2-0 win at home over lowly Malta. Missing star Mario
Balotelli, who had undergone eye surgery, the Azzurri needed a late own goal to put the game away.

FAMILIA COLOMBIANA.
The hottest player in the world is Atletico Madrid's Radamel Falcao, and his form has carried over to the Colombian national team. Falcao scored twice in
Colombia's 4-0 win over South American champion Uruguay on Friday, and he scored the winning goal as Colombia rallied from a goal down to beat Chile, 3-1, on the road in Santiago.

Falcao's form has been infectious as teammate Teo Gutierrez scored twice against Uruguay, and the third goal against Chile on a play set up by Falcao.

"We have a good understanding," Gutierrez said of his relationship with Falcao. "This is a very nice family."

None of the home teams won in South America on Tuesday. Perhaps the
biggest surprise was Venezeula's 2-0 win at Paraguay that left Paraguay in a tie for last place.

ASIAN SHOCKERS. Jordan produced the shock result of Asian
qualifying with a 2-1 win over Australia on second-half goals by Hassan Abdel-Fattah Mahmoud and Amer Deeb at the King
Abdullah Stadium in Amman. Almost as big an upset was Lebanon's 1-0 win over Iran.

The Socceroos qualified for the last two World Cups but already trail Japan by eight points in Group B.
The top two teams in each group qualify from the Asian finals while the two third-place teams meet in a playoff to determine who meets the team that finishes fifth in South America.

"The
disappointment is enormous," Australia coach Holger Osieck told Fox Sports. "We had a very, very poor first half. We didn't get into the game, our passing was a disaster, we never
could get into our normal rhythm. We played a lot of long balls and I don't know why that happened."

BRAZIL WATCH. Three days after the national
team was jeered by fans in Sao Paulo following its 1-0 win over South Africa, all is well in again Brazil. An 8-0 win will do that.

Neymar scored a hat trick in the friendly win over
China in Recife, a traditional bastion of support for the national team.

"That's the connection we have to have with the fans," right back Daniel Alves said. "We know
what we must improve but without them we can't improve. With their help, it's all going to be easier. The Brazil teams belongs to us all and if we have that connection the work with flow."
--------------------------------Friend Soccer America:FacebookFollow Soccer America:TwitterSign up:World Cup Watch

Mr. Kennedy, you forgot to mention one world power, the best team in Cpncacaf Mexico, who struggled to take a 1-0 win vs Costa Rica at home. Mexico has qualified with 2 games left to play, as the only Concacad team to do so and as 1st place in its group. Mexico has won every official Concavaf competition starting with all 6 in Gold Cup and 4 qualifiers. That's dominance.


Q:

Different chirality in IIB (N=2, D=10) supergravity

In some papers on type IIB supergravity (N=2, D=10) the dilatino is taken to be of positive chirality.
In some other papers dilatino is choosen instead of negative chirality.
Is it possible to map one convention to the other?
What is the standard method?

A:

I think I can give you some hints to help you spot where the whole thing starts, though I do not know if this is something I am allowed to do (I mean not give a definite answer but rather some logical steps).
In any case.
In order to go from one convention to the other, you need to figure out what is going on.
Also, it would be a good thing to check that there is no typo in the paper. It is a common situation. One makes a typo and then they derive some important results, and in subsequent papers other authors carry the typo as they didn't check. It has happened before, it will happen again.
What do we know about type $IIB$ in $10d$?
It is a maximal supergravity in ten dimensions which cannot be (directly) obtained from d = 11. It contains 32 real supercharges in two
Majorana-Weyl spinors of the SAME chirality.
$\Gamma$-matrices
They are unique (up to a similarity transformation)
in even dimensions; for odd dimensions, there are two inequivalent representations.
For d=10,
$$\Gamma_{chiral} = \Gamma_0 \cdots \Gamma_9$$
and there is no other way to write it down, see i.e Polchinski vol 2, appendix.
So, it seems we can narrow down the confusion.
The $\gamma$-matrices are not causing -or better yet should not be causing- this chirality change. Now, it seems, that the change in chirality should be in the spinors. What I mean is that the left-chiral of one paper is the right-chiral of the other. At least this is what sounds reasonable in my head.
This might have to do with the conventions that each author is using.
And it makes sense, since there is no universal way of writing down SUSY. The conventions are very different from one paper to the other, so it has to do with how they write down the chiral supermultiplets.
Is there a consistent way to do it?
If I am correct in my above considerations, then by knowing both of the SUSY conventions that they used, you'll be able to figure out where they have a relative minus change or something like that.
I know that this does not answer fully your question, but I sincerely hope I helped. At least a bit. If not, apologies.
Cheers


Lactobacillus rhamnosus

Lactobacillus rhamnosus is a bacterium that originally was considered to be a subspecies of L. casei, but genetic research found it to be a species of its own. It is a short Gram-positive heterofermentative facultative anaerobic non-spore-forming rod that often appears in chains. Some strains of L. rhamnosus bacteria are being used as probiotics, and are particularly useful in treating female-related infections, most particularly very difficult to treat cases of bacterial vaginosis (or "BV"). The Lactobacillus rhamnosus and L. reuteri species are most commonly found in the healthy female genito-urinary tract and are most helpful to supplement in order to regain control over dysbiotic bacterial overgrowth during an active infection. L. rhamnosus sometimes is used in yogurt and dairy products such as fermented and unpasteurized milk and semi-hard cheese. While frequently considered a beneficial organism, L. rhamnosus may not be as beneficial to certain subsets of the population; in rare circumstances, especially those primarily involving weakened immune system or infants, it may cause endocarditis.

Genome
Lactobacillus rhamnosus has a wide variety of strains that have been isolated from many different environments including the vagina and gastrointestinal tract. L. rhamnosus strains have the capacity for strain-specific gene functions that are required to adapt to a large range of environments. Its core genome contains 2,164 genes, out of 4,711 genes in total (the pan-genome). The accessory genome is overtaken by genes encoding carbohydrate transport and metabolism, extracellular polysaccharides, biosynthesis, bacteriocin production, pili production, the CRISPR-cas system, the clustered regularly interspaced short palindromic repeat (CRISPR) loci, and more than 100 transporter functions and mobile genetic elements such as phages, plasmid genes, and transposons.

The genome of the specific strain L. rhamnosus LRB, in this case, taken from a human baby tooth, consists of a circular chromosome of 2,934,954 bp with 46.78% GC content. This genome contains 2,749 total genes with 2,672 that are total protein-coding sequences. This sample did not contain any plasmids. The most extensively studied strain, L. rhamnosus GG, a gut isolate, consists of a genome of 3,010,111 bp. Therefore, the LRB genome is shorter than GG’s genome. LRB lacks the spaCBA gene cluster of GG and is not expected to produce functional pili (6). This difference may help explain why each strain lives in a different habitat.

Lactobacillus rhamnosus GG (ATCC 53103)
Lactobacillus rhamnosus GG (ATCC 53103) is a strain of L. rhamnosus that was isolated in 1983 from the intestinal tract of a healthy human being; filed for a patent on 17 April 1985, by Sherwood Gorbach and Barry Goldin, the 'GG' derives from the first letters of their surnames. The patent refers to a strain of "L. acidophilus GG" with American Type Culture Collection (ATCC) accession number 53103; later reclassified as a strain of L. rhamnosus. The patent claims the L. rhamnosus GG (ATCC 53103) strain is acid- and bile-stable, has a great avidity for human intestinal mucosal cells, and produces lactic acid. Since the discovery of the L. rhamnosus GG (ATCC 53103) strain, it has been studied extensively on its various health benefits and currently L. rhamnosus GG (ATCC 53103) strain is the world's most studied probiotic bacterium with more than 800 scientific studies.

The genome sequence of Lactobacillus rhamnosus GG (ATCC 53103) has been decoded in 2009.

History
In 1983, Lactobacillus rhamnosus GG was isolated from the intestinal tract of a healthy human by Sherwood Gorbach and Barry Goldin.

Medical research and use
While Lactobacillus rhamnosus GG (ATCC 53103) is able to survive the acid and bile of the stomach and intestine, is claimed to colonize the digestive tract, and to balance intestinal microflora, evidence suggests that Lactobacillus rhamnosus is likely a transient inhabitant, and not autochthonous. Regardless, it is considered a probiotic useful for the treatment of various maladies, as it works on many levels. Lactobacillus rhamnosus GG binds to the gut mucosa.

Diarrhea
L. rhamnosus GG is beneficial in the prevention of rotavirus diarrhea in children. Prevention and treatment of various types of diarrhea have been shown in children and in adults. L. rhamnosus GG can be beneficial in the prevention of antibiotic-associated diarrhea and nosocomial diarrhea and this has been recently supported by European guidelines. Lactobacillus rhamnosus GG may reduce the risk of traveler's diarrhea.

Acute gastroenteritis
A position paper published by ESPGHAN Working Group for Probiotics and Prebiotics based on a systematic review and randomized controlled trials (RCTs) suggested that L. rhamnosus GG (low quality of evidence, strong recommendation) may be considered in the management of children with acute gastroenteritis in addition to rehydration therapy.

Atopic dermatitis, eczema
Lactobacillus rhamnosus GG has been found to be ineffective for treating eczema.

Risks
The use of L. rhamnosus GG for probiotic therapy has been linked with rare cases of sepsis in certain risk groups, primarily those with a weakened immune system and infants. Ingestion of GG is considered to be safe and data show a significant growth in the consumption of L. rhamnosus GG at the population level did not lead to an increase in Lactobacillus bacteraemia cases.

References

Further reading

External links
Type strain of Lactobacillus rhamnosus at BacDive - the Bacterial Diversity Metadatabase

Category:Digestive system
Category:Probiotics
Category:Lactobacillaceae
Category:Bacteria described in 1989


Ben Stiller's new NYC pad is ridiculously good-looking

It's a zoo out there, so Ben Stiller found himself a peaceful home above it all. For $15.3 million, the "Zoolander" and Focker film series actor snagged 3,400 square feet of pure Manhattan luxury overlooking the Hudson River.

While his walls of windows frame the sunset, Stiller's new home interior features an eat-in kitchen clad in walnut and Alabama white-vein marble. It includes a 78-bottle wine refrigerator and a Miele coffee station.

See exclusive photos of the stellar home:

7PHOTOS

Ben Stiller's NYC apartment

See Gallery

Ben Stiller's NYC apartment

Photo via StreetEasy

Photo via StreetEasy

Photo via StreetEasy

Photo via StreetEasy

Photo via StreetEasy

Photo via StreetEasy

Up Next

See Gallery

Discover More Like This

of

SEE ALL

BACK TO SLIDE

SHOW CAPTION
+

HIDE CAPTION
–

The apartment also has 3 eastern-facing bedrooms with en-suite bathrooms and walk-in closets.

All this in a West Village high-rise built in 2013, with a lavish community lap pool, a plunge pool and a hot tub, plus a gym offering steam, sauna and massage.


High incidence of disability pension with a psychiatric diagnosis in western Sweden. A population-based study from 1980 to 1998.
Regional differences in Sweden in the prevalence of disability pension with a psychiatric diagnosis are unexplained, in spite of the significant impact on the population's health, rehabilitation systems, and the health care system. The purpose of this study was to describe the pattern of disability pensions with a psychiatric diagnosis and to analyze the impact of age and gender. We examined the incidence rates in one urban and one semi-rural region and compared these to national rates. The study sample was drawn from employed persons between 16-64 years of age who, because of their sickness insurance coverage, would be eligible to access disability pensions should it be necessary. Analysis of annual incidences and standardized morbidity ratios were made for 1980, 1985, 1990, 1995, and 1998. Data on disability pension cases were collected from the National Social Insurance registers. In the urban region we found that the proportion of men and women clearly outnumbered the national average: approximately twice the number of persons between 16-64 years of age with a psychiatric diagnosis were receiving a disability pension. In the semi-rural region there were fewer men overall on disability pensions with psychiatric disorders, but in 1980, 1985, and 1995 women clearly outnumbered men. Access to psychiatric care, unemployment, alcohol dependence, and previous sickness absence are suggested as possible factors that might affect the rates of disability pension in different geographical settings.


Talk Soft

FreeSWITCH is a powerful and versatile telephony platform that can scale from a softphone to a PBX and even to a carrier-class softswitch.

Open source projects have lowered the barrier to entry into telephony for hobbyists and businesses alike. The popular Asterisk PBX tool, for instance, is a high-functioning and low-budget telephony alternative that has proven disruptive in the world of business telephone systems [1]. Perhaps the most disruptive software of all, however, comes in the form of the scalable softswitch library called FreeSWITCH.

The FreeSWITCH website [2] says that it can be used as a "simple switching engine, a PBX, a media gateway, or a media server to host IVR applications."

True to that chameleon-like description, FreeSWITCH has appeared in production environments as a telco switch, in numerous business scenarios as a PBX, as a softphone for laptop users, and even as a voice routing engine for the OpenSim project.

Additionally, you can deploy FreeSWITCH as an application or use it as a library (libfreeswitch) that can be embedded in third-party software. This double identity is similar to the relationship between cURL (application) and libcurl (library).

FreeSWITCH has been used in some exotic scenarios; however, those new to telephony applications are best served starting out with FreeSWITCH in its default configuration as a SOHO PBX. Although you might find the numerous FreeSWITCH configuration files and settings overwhelming, in a short time, you will appreciate the power and flexibility of this versatile telephony tool.

Installing FreeSWITCH

As of this writing, the current, stable version of FreeSWITCH is 1.0.4, which can be downloaded from the project website [3], or you can use the Subversion repository to install the latest version. Unlike many projects, the SVN trunk is extremely stable, so it might be convenient for you simply to use the latest trunk.

In any case, the FreeSWITCH developers have made it very easy to update to the latest trunk, even if you have installed from the latest stable version. Some pre-compiled binaries are known to exist; however, I recommend compiling from source.

First, unpack and install the source. In this example, I will download into /usr/src and install from there:

FreeSWITCH comes with and can handle sound files at 8, 16, 32, and 48kHz sampling rates. Few, if any, telephony systems – open source or proprietary – can do the kinds of things FreeSWITCH can do with calls at multiple sampling rates.

The installation will take some time, so feel free to chain the commands together with the && operator.

When the process is complete, you will have a basic FreeSWITCH installation. Because it is handy to have the two main FreeSWITCH executable files available in the bin path, I use symlinks:

To launch the application, enter freeswitch, and use the fs_cli utility to access the command line of any FreeSWITCH server to which you have access, even if it is on another server. At first, you'll see quite a bit of debug/log information, but don't worry about errors or warnings at this point.

Your New Softswitch

The first basic command is version, which displays the version of Free-SWITCH you are running, including the SVN revision. The status command shows information about your instance of FreeSWITCH, including uptime and the number of currently active sessions. Another basic command is the self-descriptive help.

The i and o are next to the currently selected input and output devices. To change the input device, use the pa indev command with the device number,

pa indev #x

where x is the number of the input device. The output device can be changed with the pa outdev command. In my setup, I'll use device 4 as output and device 5 as input.

If you have the MOH (music on hold) files installed, this command will make a call to the MOH extension and send the MOH to the PortAudio output device:

pa call 9999

If you hear music, it was a successful call. If not, make sure the MOH files were installed properly. Hang up with the pa hangup command.

To make sure both input and output devices are working, do an echo test:

pa call 9996

Now when you speak into the input device, your voice should be echoed to the output device. The pa hangup command disconnects.

As you can see, it is possible to use Free-SWITCH and PortAudio to create a simple softphone. In this way, you will be able to use any codec that your FreeSWITCH installation supports – and there are some very high quality codecs available – without installing a softphone client.

Connecting a SIP Phone

The most common way to use Free-SWITCH is with a SIP phone. A physical handset is often called a hard phone, whereas a software-based phone is appropriately called a softphone. Numerous types of hard phones are available from manufacturers. Softphones come in both proprietary and FLOSS varieties. A popular free – but not open source – softphone is X-Lite from CounterPath [4], which is available for Linux, Mac OS X, and Windows. Even if your FreeSWITCH server runs on Linux, your softphones can run on any operating system, as long as they are SIP compliant.

Session Initiation Protocol

SIP is a TCP/IP-based Application Layer protocol used for multimedia sessions over the Internet. The text-based protocol is similar to HTTP, with requests and responses, header fields, encoding rules, and status codes. In addition to VoIP, SIP is used in instant messaging, online gaming, and distribution of streaming multimedia.

To begin, download X-Lite for your desktop or laptop operating system and perform a default install. (Installing a softphone on the same system that is running FreeSWITCH is not recommended; however, in many cases, it will work for the sake of testing.)

Now launch X-Lite and open the SIP Account Settings menu by clicking the Show Menu button. (The button is the small down-arrow at the top of the phone, just left of center.)

Only one SIP account is available in X-Lite, so click on it then click the Properties button. As shown in Figure 1, fill in the fields and use 1234 as the password for extension 1000.

Figure 1: The X-Lite SIP account configuration screen.

Next, clear out the Dialing plan field because it is not needed with FreeSWITCH. Now click OK then Close, and the phone will attempt to register. Figure 2 shows a successful registration.

Figure 2: A successfully registered X-Lite client.

To make a test call, dial 9999 and click the green button to send. In a few moments you should hear music on hold. Figure 3 shows a call in progress to extension 9999.

Buy Linux Magazine

Related content

Linux users didn't need the recent NSA eavesdropping scandal to convince them that securing communication was a good idea. Free software developers have been creating secure tools for years that offer similar functionalities to all of those popular but very leaky services with ridiculous names.


Q:

Как закрыть все divы

Я новичек. Никак не могу разобраться, как закрыть один div если нажимаем на другую кнопку.

ABOUT
CONTACTS

about

contacts

Постоянный див который не нужно закрывать

A:

  ABOUT
  CONTACTS

about

contacts

Постоянный див который не нужно закрывать


package org.jzy3d.plot3d.primitives.vbo.buffers;

import java.nio.IntBuffer;

import org.jzy3d.maths.BoundingBox3d;

public interface VBO<T> {
    public T getVertices();

    public void setVertices(T vertices);

    public IntBuffer getIndices();

    public void setIndices(IntBuffer indices);

    public BoundingBox3d getBounds();

    public void setBounds(BoundingBox3d bounds);

}


Choose from our most popular fabrics

Free Swatch Kit


Q:

How to specify a default value for an argument for clap_app! macro?

I want to use clap_app! macro to define an argument which should have a default value. Unfortunately, there is nothing in the docs, and my naive attempt didn't work:
#[macro_use]
extern crate clap;

fn main() {
    let matches = clap_app!(myapp =>
        (@arg seconds: -u +takes_value +default_value("1.0") "Update time")
    ).get_matches();
    println!("{}", matches.value_of("seconds").unwrap())
}

How can I specify a default value for an argument within clap_app! macro?

A:

This is currently impossible with number, https://github.com/kbknapp/clap-rs/issues/1035.
But it's should be:
(@arg seconds: -u +takes_value default_value[1.0] "Update time")


Rachel Maddow points out that Fox News violated their own debate qualification criteria by ignoring the fifth most recent poll and instead taking the sixth, with the result being a greater distinction between tenth and eleventh place, Kasich and Perry.


Joseph Gordon-Levitt joined Christian Bale on the set Friday, Oct. 28. Levitt plays young special assignment cop John Blake in the film, and was spotted donning his police uniform in several new photographs.

Rumors had circulated that filming could include the Occupy Wall Street protests, though Friday's shoot reportedly took place outside the Trump Tour, which was temporarily transformed into Wayne Enterprises. Bale was spotted outside wearing a suit and tie as his average joe alter-ego, Bruce Wayne, while extras lined the streets dressed as reporters and photogs.

According to NJ.com, the cast will move production to Newark, New Jersey next week, filming one day inside City Hall.


Q:

Horiztonal centered rotated text

Hello I am trying to create this in HTML + CSS.

I have everything working, except the horizontal alignement of the legend is wrong, and the whole legend is offset.
https://jsbin.com/cuzobijuqe/

.barometer-body>div {
  float: left;
  width: 12.5%;
  height: 1.3em;
  display: inline-block;
}

.barometer-body>div:nth-child(1) {
  background-color: #CC0033;
}

.barometer-body>div:nth-child(2) {
  background-color: #FF6633;
}

.barometer-body>div:nth-child(3) {
  background-color: #F49819;
}

.barometer-body>div:nth-child(4) {
  background-color: #FFCC00;
}

.barometer-body>div:nth-child(5) {
  background-color: #FFFF66;
}

.barometer-body>div:nth-child(6) {
  background-color: #99C667;
}

.barometer-body>div:nth-child(7) {
  background-color: #349937;
}

.barometer-body>div:nth-child(8) {
  background-color: #006633;
}

.barometer-legend>div {
  width: 12.5%;
  float: left;
  font-size: 2em;
  line-height: 12.5%;
  display: inline-block;
  transform: rotate(90deg);
  transform-origin: left top 0;
}

One

Two

Three

Four

Five

Six

Seven

Eight

What CSS method should I use for aligning the rotated text to the center position of it's associated segment?
EDIT: thanks to @ovokuro I have an almost perfect solution. I'm happy to use flexbox for this. However when I reduce the viewport, the alignment seems to switch to left rather than right which causes the text to look messy. How would I fix this?

A:

I think you could approach this layout using flexbox
updated as per comment (text not aligning on smaller screen sizes):
Replace text-align: right with justify-content: flex-end:
.barometer-legend > div {
  display: flex;
  justify-content: flex-end;
}

I have also added a media query to reduce the font-size on smaller screens.

.wrapper,
.barometer-body,
.barometer-legend {
  display: flex;
}

.wrapper {
  flex-direction: column;
}

.barometer-body {
  border-radius: 2em;
  overflow: hidden;
}

/* create space between body and legend */

.barometer-legend {
  padding-top: 6%;
}

.barometer-body>div,
.barometer-legend>div {
  flex: 1 0 12.5%;
  width: 12.5%;
  height: 1.3em;
}

.barometer-body>div:nth-child(1) {
  background-color: #CC0033;
}

.barometer-body>div:nth-child(2) {
  background-color: #FF6633;
}

.barometer-body>div:nth-child(3) {
  background-color: #F49819;
}

.barometer-body>div:nth-child(4) {
  background-color: #FFCC00;
}

.barometer-body>div:nth-child(5) {
  background-color: #FFFF66;
}

.barometer-body>div:nth-child(6) {
  background-color: #99C667;
}

.barometer-body>div:nth-child(7) {
  background-color: #349937;
}

.barometer-body>div:nth-child(8) {
  background-color: #006633;
}

.barometer-legend>div {
  font-size: 2em;
  transform: rotate(-90deg);
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 600px) {
  .barometer-legend div {
    font-size: 1.5em
  }
}

One

Two

Three

Four

Five

Six

Seven

Eight


Google posts source for Ice Cream Sandwich

There were a few people in these forums who contended that Google had abandoned its commitment to “open source” with Honeycomb.

Before the first Ice Cream Sandwich device is available, Google has posted the source code, and the mod-ers can get busy with it. Device manufacturers can also get busy with it, and we should see some tablets with ICS installed in December, with phones following in January. It’s really a great time for Android.


South Carolina Highway 2

South Carolina Highway 2 (SC 2) is a state highway in the U.S. state of South Carolina that runs  between two portions of U.S. Highway 21/U.S. Highway 176/U.S. Highway 321 (US 21/US 176/US 321) in Lexington County. The southern  of the highway are known as Frink Street while the northern  of the highway are known as State Street.

Route description
SC 2 is a , two-lane road just southwest of Columbia, serving as a business route for Cayce. It begins at the US 21/US 176/US 321 concurrency heading northeast. It then takes a turn to the north and runs parallel to the Congaree River to its west. Shortly after passing US 1, the highway ends at US 378 in West Columbia. The highway runs by an elementary school, Brookland-Cayce High School, two shopping centers, and a park.

History
SC 2 is one of the original state highways. The original route went from the Georgia state line north of Mountain Rest heading east towards Greenville before turning southeast and ending in Charleston, spanning over . It was considered the state's "Main Street" in the 1920s and 1930s. The road began construction in 1923 and ended 11 years later in 1932. The road was re-designated as US 76, US 176 and US 178 in the 1940s and has been reduced to just under .

Major intersections

References

External links

002
Category:Transportation in Lexington County, South Carolina
Category:U.S. Route 76


“Empire” co-creator and executive producer Lee Daniels says he is "beyond embarrassed" by his initial public support for actor Jussie Smollett, who was charged with faking a hate crime attack. But he is not convinced Smollett is guilty.

Daniels told New York magazine's culture and entertainment website, Vulture, that when Smollett, who is black and gay, reported he was attacked Jan. 29 in downtown Chicago, he was inclined to believe the "Empire" actor. Smollett claimed two masked men hurled racial and homophobic slurs, placed a noose around his neck and poured bleach on him.

Authorities alleged that Smollett knew the men, Abimbola “Abel” and Olabinjo “Ola” Osundairo, and had arranged for them to pretend to attack him. Police believed he staged the attack because he was unhappy with his salary on "Empire" and wanted to gain public sympathy.

"I’m beyond embarrassed," Daniels said. "I think that when it happened, I had a flash of me running from bullies. I had a flash of my whole life, of my childhood, my youth, getting beaten."

Daniels, who had been among the first to voice his support for Smollett after he made the report, also said he is uncertain if Smollett staged the attack.

"I’m telling you that because I love him so much," Daniels said. "That’s the torture that I’m in right now, because it’s literally if it were to happen to your son and your child, how would you feel? You would feel, 'Please, God, please let there be that glimmer of hope that there is some truth in this story.' That’s why it’s been so painful. It was a flood of pain."

Daniels said he did not read any media coverage of the incident because he was "too busy putting out fires."

"We weren’t there. I can’t judge him," Daniels said. "That’s only for the f------ lady or man with that black robe and God."

The Oscar-nominated director said he had to distance himself from the case.

"I had to detach myself and stop calling him, because it was taking away the time I have for my kids, the time I have for my partner," Daniels said. "It was affecting my spirit and other shows, everything."

Smollett was arrested in February, but prosecutors dropped the charges in March. He has maintained his innocence and insists he was attacked.

Daniels has been clear that Smollett will not return to "Empire."

Fox announced in May that the show's recently announced sixth season will be its last. Asked if he believed that Smollett's case played a part, Daniels said, "Certainly, that played a major part."

He added: "But come on, man. I think that it’s been a good run. 'Empire' in its current iteration may be over, but 'Empire' is far from over."


412 Ill. 446 (1952)
107 N.E.2d 692
THE PEOPLE OF THE STATE OF ILLINOIS et al., Appellants,
v.
ROTH, INCORPORATED, et al., Appellees.
No. 32238.
Supreme Court of Illinois.
Opinion filed May 22, 1952.
Rehearing denied September 15, 1952.
*447 IVAN A. ELLIOTT, Attorney General, of Springfield, (WILLIAM C. WINES, RAYMOND S. SARNOW, A. ZOLA GROVES, and JOHN T. COBURN, of counsel,) for appellants.
LEONARD H. LAWRENCE, (ALBERT E. JENNER, JR., and CHARLES J. O'LAUGHLIN, of counsel,) all of Chicago, for appellees.
Reversed and remanded.
Mr. JUSTICE MAXWELL delivered the opinion of the court:
This suit was instituted in the circuit court of Cook County by the People of the State of Illinois, as plaintiff, against seven defendants, proprietors of establishments variously referred to as night clubs and theater restaurants. Upon motion, Benjamin O. Cooper, Auditor of Public Accounts of the State of Illinois, was joined as plaintiff. Plaintiffs filed a motion to strike the answer of defendants and for judgment on the pleadings, and upon denial of the motion by the trial court plaintiffs elected to stand upon their motion and perfected their appeal directly to this court, the public revenue being involved.
The case at bar is a sequel to the decision of this court in two consolidated cases entitled "Byron Massell et al., Appellees, v. Richard J. Daley, Director of Revenue, et al., Appellants," and "Roth, Inc., et al., Appellees, v. Richard *448 J. Daley, Director of Revenue, et al., Appellants," and cited as Massell v. Daley, 404 Ill. 479.
Practically all the proceedings in these cases, hereinafter referred to as the consolidated cases, including the above opinion, are set out in haec verba in the pleadings in this suit. It appears therefrom that the defendants in this cause joined as plaintiffs in suits in equity under section 2a of an act which relates to the disposition of State funds paid under protest, (Ill. Rev. Stat. 1949, chap. 127, par. 172,) against certain State officials to restrain the collection of retailers' occupation taxes. The suits alleged that the plaintiffs were operating establishments which furnished entertainment and also dispensed food, beverages and liquors to their patrons. They there contended that they were engaged primarily in the business of furnishing entertainment and that services, in the form of entertainment, constituted 40 per cent of the total gross receipts realized from the sale of both such services and tangible personal property for consumption by their customers. Those suits were commenced in 1941 and a temporary injunction was entered enjoining certain State officials from paying or depositing into the State Treasury money paid by plaintiffs under protest. The money so paid in 1941 and from thence until December, 1948, amounted to 40 per cent of the "sales tax" upon the gross receipts of the plaintiffs. The funds thus accumulated by December 21, 1948, amounted to $91,912.97. In 1948 the plaintiffs amended their complaint, abandoning the right to apportionment between sales of tangible personal property and entertainment, and contending that their business was primarily that of furnishing entertainment, that the sale of food and drink was only incidental to their business, and that the whole of the business was nontaxable. The Attorney General filed a motion to dismiss the complaint as amended, which was overruled, and a decree was entered holding that the plaintiffs in that suit were not liable for said retailers' occupation *449 tax by their operation of their several places of business. The then Attorney General raised no objections to the decree. On December 21, 1948, the trial court entered an order directing the then State Treasurer to return to the plaintiffs sums aggregating the above amount. This order was consented to by the then Attorney General through one of his assistants. Following the entry of such decree and order, warrants were drawn on the protest fund, payable to the several plaintiffs in the aggregate sum of $91,912.97. The succeeding State officers perfected an appeal from that decree. Upon that appeal, this court, in its opinion in the consolidated cases, found that the decree was invalid and it was reversed. Massell v. Daley, 404 Ill. 479.
The plaintiff State, defendant in the consolidated cases, seeks judgment against the defendants, jointly and severally, in the amount of $91,912.97 in this action at law sounding in trespass on the case and trover. They allege that the defendants illegally procured and converted to their own use unlawfully issued State warrants and their proceeds, by joint consent to unlawful action, with the co-operation of former State officers, and by the pretended authority of the decree in the consolidated cases.
Two contentions of the defendants in the case at bar regarding the meaning of the language appearing in the Massell v. Daley opinion may be readily eliminated. First: when we held that the decree was "invalid," we held in clear and unmistakable language that the decree was void. If this court had meant "erroneous," as contended by the defendants, we would have so stated. There could be no plainer language than to say that the decree was entered by consent and did not constitute a judicial determination of the rights of the parties. If the purported decree did not constitute a judicial determination, then, obviously, it was not merely erroneous but was actually void. We pointed out in that case that the constitution prohibited the General Assembly from releasing an obligation due to *450 the State, (sec. 23, art. IV,) and that if the General Assembly could not release such obligations an administrative officer could not do so. (People ex rel. Ames v. Marx, 370 Ill. 264.) There seems no room for doubt that at the time the consent decree was entered releasing the taxpayers from all liability, at least a part of the amount involved was a valid obligation due the State. It will be presumed that both the taxpayers and the State officials knew that the officials had no authority to agree to a consent decree releasing the obligation due the State, and, under such circumstances, fraud is presumed, and such a decree is void ab initio. (Green v. Hutsonville Township High School Dist. 356 Ill. 216.) Second: the contention that the opinion in Massell v. Daley was authority for the proposition that the defendant taxpayers were liable only for a tax measured by their receipts from the sale of food and beverages and need not pay a tax measured by their receipts for entertainment is without merit. That issue was not before the court and could not have been before the court upon the pleadings. We there specifically stated, page 486: "The question of the right to recover the amounts provided in said decrees is not before the court and we express no opinion thereon."
The defendants contend that plaintiffs have no title to any of the tax-protest fund but that title to such fund was at all times in defendants and, consequently, an action in the nature of trover cannot lie. Apparently, this is based on the theory that the decree in the consolidated cases had not been reversed at the time the defendants received and cashed the warrants. This contention ignores the well-established rule that a void decree has no legal effect, and attempts to controvert the doctrine that where property has been delivered to a neutral depositary upon a condition that, if not fulfilled, it should be paid over to a third party, then the third party becomes entitled to it as of the time of the original deposit. (Clodfelter v. Van Fossan, *451 394 Ill. 29.) The protest fund remained in the hands of the State Treasurer and not in the general funds of the State, but when the decree in the consolidated cases was found to be void, the funds belonged in the general fund of the State and the State became entitled to them as of the time of the original deposits. Such a deposit only fails to become the property of the State when the taxpayer obtains a favorable adjudication in a protest injunction suit. The statute specifically requires that the money in the protest fund shall be held in the protest fund until "the final order or decree of the court," whereupon it shall be returned to the protesting taxpayer if that order is in his favor. In the case at bar, not only was the order permitting the taxpayers to recover not final, it was not a court order at all. It was not a judicial determination. There can be no doubt that the State had and retained a special title in the protested amount from the time of its deposit until it acquired full title by court order, or its special title was divested by a final, valid order in the protesting taxpayers' favor. This special title which the State is bound to retain permits this action of trover. Undoubtedly, it was the intention of the General Assembly that deposits paid under protest should, if taxpayers failed to recover their deposit legally, have the effect of taxes paid at the time of the deposits. It was the purpose of the act to give the taxpayer the benefit of credit for payment of his taxes as of the time of the deposit, if it should ultimately be decided that he owed the tax.
The defendants attempt to make a distinction between an action for the conversion of the warrants themselves and an action for the conversion of the proceeds of the warrants. While this is not strictly an action of trover, it is an action in the nature of trover, and we have held that trover will lie against one who has unlawfully obtained negotiable instruments and received the proceeds thereof. (Rauch v. Fort Dearborn Nat. Bank, 223 Ill. 507.) Technically, *452 this can be considered a conversion of the specific personal property, or it can be looked on as two successive conversions, the first being the conversion of the instrument, the second the conversion of the proceeds to the use of the wrongdoer. We are of the opinion that the complaint is broad enough to support an action either for the conversion of the warrants or of the proceeds. The facts are not in doubt as to the receiving of the several amounts by the respective defendants by the obtaining of the warrants and the taking and retaining of the proceeds.
The defendants allege that this is an action for the recovery and collection of "sales tax," and must fail because the statutory scheme, which is exclusive, was not followed. In view of our discussion above, it should be unnecessary to reiterate that this is a common-law action in the nature of trover to recover the proceeds of State warrants illegally acquired by the defendants. The reversal of the invalid consent decree did not determine the plaintiffs' claims for refund; an injunction operative from 1941 to 1948 precluded State action during that period; and the statutory period within which redetermination of taxes can be made has lapsed. The defendants' actions, under the spurious cloak of legality afforded them by the void decree, have denied the State all remedies save this one at common law. The action is not, and could not be, an action for the recovery or collection of "sales tax." It is an action to recover the value of property wrongfully converted to the defendants' use.
The only remaining question is whether the judgment should be entered jointly or severally. The plaintiffs contend that by joining with other defendants in the consolidated suits, their retention of one attorney and the co-operation of the defendants in a course of conduct that resulted in the illegal disbursement of said funds, made the defendants jointly liable. We fail to see that there is here such a joint liability. No conspiracy is shown to *453 make the defendants joint tort-feasors; there would appear to be no illegal intent which would make all responsible for the acts of one. It is true that the litigants in the consolidated cases proceeded in two separate actions to prosecute their claims. This they had a right to do, and they had a right to employ the same counsel if they saw fit. Each defendant was acting on his own behalf for the amount which each, respectively, claimed. The money was refunded by separate warrants, each such payment being separate and distinct. We conclude that there is no joint liability, but that the defendants are severally liable to plaintiffs for the amounts, respectively, illegally collected by them from the State.
The decree of the circuit court is reversed and the cause remanded, with directions to enter separate judgments against the defendants for the several sums set forth in the alternate prayer of plaintiffs' complaint.
Reversed and remanded, with directions.


Terrusnolides A-D, new butenolides with anti-inflammatory activities from an endophytic Aspergillus from Tripterygium wilfordii.
Terrusnolides A-D (1-4), four butenolides were isolated from an endophytic Aspergillus from Tripterygium wilfordii. The structures of 1-4 were established by comprehensive spectroscopic analyses and electronic circular dichroism (ECD) calculation. It is interesting that 1 was a butenolide derived by a triple decarboxylation, while 2-4 were the metabolites with 4-benzyl-3-phenyl-5H-furan-2-one motif possessing an isopentene group fused to the benzene ring. In vitro anti-inflammatory effects of these isolates were evaluated in lipopolysaccharide (LPS)-stimulated RAW264.7 macrophages. 1-4 exhibited excellent inhibitory effects on the production of interleukin-1β (IL-1β), tumor necrosis factor-α (TNF-α), and nitric oxide (NO) in LPS-induced macrophages, comparable with the positive control (indomethacin). Those results indicated that, terrusnolides A-D might serve as new potential natural remedies for the treatment of inflammation.


Taiwanese bizmen seek organic products

THIS year’s Taiwan Trade and Investment Delegation will gear in creating potential business partners in organic products, a business leader said.

Mindanao Business Council (MBC) executive director Rolando Torres said organic products will be the one of the four industries to be business-matched during the investment meeting on October 19, 2018 at Apo View Hotel.

The organic edible products include variants of multi-grain flakes and OTER multi-cereal milk, yam and nuts, organic juices, and even ketchup and organic vinegar. Cheng Yuan Organic Corporation and Hong Kong View Enterprise Ltd. Taiwan branch will be the companies attending for the organic product business match.

Torres said this organic product industry will help strengthen the local efforts in supporting farm-to-table initiatives.

“Maganda yung potential on farm-to-table restaurants. Of course, offering organic products, so magandang ma-explore ‘yun (There is a potential in farm-to-table restaurants. It would be good to explore on organic products),” Torres said in an interview.

Torres said the Taiwanese investors are gaining interest here because of the government's efforts on investment promotions.

“Well, they (the Taiwanese) were very vocal about it that it was the president and the president’s intensified effort in investments here in Mindanao. And the expectations were met. That prompted them to hold another meeting in October,” Torres said in an interview.

SunStar website welcomes friendly debate, but comments posted on this site do not necessarily reflect the views of the SunStar
management and its affiliates. SunStar reserves the right to delete, reproduce or modify comments posted here without notice.
Posts that are inappropriate will automatically be deleted.

Forum rules:

Do not use obscenity. Some words have been banned. Stick to the topic. Do not veer away from the discussion. Be coherent.
Do not shout or use CAPITAL LETTERS!


Product Description

High-Quality Stuffed Mink Trophy

Part of the Mustelidae family, the American Mink is highly prized for it's fur. There are only two species living today, the European Mink and the American Mink. The European Mink always has a white patch on its upper lip, but the American Mink sometimes does not. They are distant relatives of the weasel, otter, and ferret. Bring out the raw nature of this wily weasel in your living room, fireplace setting, game room, or bedroom and it's sure to get the conversation started. Featuring a full size American Mink in full detail. Available in different poses to choose from. We also do custom orders. Just call for more details. We proudly carry a life-time guarantee with all our work.

Taxidermy is the incredible art of providing top quality workmanship to sports enthusiasts through wild game tanning and mounting. Because we use only the finest materials available for our craft, and because we use only the premier tanners in the country, our work is second to none. The best quality leather tan we can possibly give you in a mount, combined with our skillful expertise assures you that your trophy will last generations. It is sure to be a conversation starter.

The stock picture is not the actual package you will receive. Because Mother Nature blessed each animal differently, no two trophies will be the same. Feel free to browse our collection of other animals.

Dimensions

Dimensions

No

Typically Ships Via

FedEx/UPS/USPS

Shipping Cost

Free Shipping - Curbside/Tailgate Delivery

Free Shipping Requirements

Free Curbside/Tailgate Shipping within the Contiguous 48 States

Availability

Usually ships in 3 - 6 business days when in stock - call/email for availability


//
//  ViewController.swift
//  RSSReader
//
//  Created by susieyy on 2014/06/03.
//  Copyright (c) 2014年 susieyy. All rights reserved.
//

import UIKit

class ViewController: UITableViewController, MWFeedParserDelegate {

    var items = [MWFeedItem]()

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        request()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func request() {
        let URL = NSURL(string: "https://www.wantedly.com/projects.xml")
        let feedParser = MWFeedParser(feedURL: URL);
        feedParser.delegate = self
        feedParser.parse()
    }

    func feedParserDidStart(parser: MWFeedParser) {
        SVProgressHUD.show()
        self.items = [MWFeedItem]()
    }

    func feedParserDidFinish(parser: MWFeedParser) {
        SVProgressHUD.dismiss()
        self.tableView.reloadData()
    }

    func feedParser(parser: MWFeedParser, didParseFeedInfo info: MWFeedInfo) {
        println(info)
        self.title = info.title
    }

    func feedParser(parser: MWFeedParser, didParseFeedItem item: MWFeedItem) {
        println(item)
        self.items.append(item)
    }

    override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        return 100
    }

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.items.count
    }

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "FeedCell")
        self.configureCell(cell, atIndexPath: indexPath)
        return cell
    }

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        let item = self.items[indexPath.row] as MWFeedItem
        let con = KINWebBrowserViewController()
        let URL = NSURL(string: item.link)
        con.loadURL(URL)
        self.navigationController?.pushViewController(con, animated: true)
    }

    func configureCell(cell: UITableViewCell, atIndexPath indexPath: NSIndexPath) {
        let item = self.items[indexPath.row] as MWFeedItem
        cell.textLabel?.text = item.title
        cell.textLabel?.font = UIFont.systemFontOfSize(14.0)
        cell.textLabel?.numberOfLines = 0

        let projectURL = item.link.componentsSeparatedByString("?")[0]
        let imgURL: NSURL? = NSURL(string: projectURL + "/cover_image?style=200x200#")
        cell.imageView?.contentMode = UIViewContentMode.ScaleAspectFit
        cell.imageView?.setImageWithURL(imgURL, placeholderImage: UIImage(named: "logo.png"))
    }

}