text:
Q: emulating CSS flex-wrap behavior with SwiftUI i'm writing a SwiftUI app and would like a container view which "pushes" its children into a row and, once the row fills up, starts wrapping subsequent children to the subsequent row—in other words, a container which emulates the behavior of CSS flexbox's flex-wrap: wrap attribute.  the children have variable, dynamic widths, but are the same height (although i suspect most non-insane solutions will be robust to variable heights).  the number of children is also dynamic.
toplevel, my question is just: what's the simplest way to do this?  if i need to dip into UIKit or obj-c land, so be it, but i'd prefer solutions which are standalone (i.e., not pod Yoga).
(NB: i am new to iOS dev, but have working familiarity with React and with all the ~newfangled CSS  layouts.)
so far my best lead is the LazyVGrid View that ships with iOS 14.  in particular, it seems to me like a single adaptive GridItem with no maximum (defaulting to infinity) should do the trick... but it does not, or at least i haven't figured out how yet.  (the best reference slash only detailed reference for *Grid i've found is: https://swiftui-lab.com/impossible-grids/)
i initially tried this:
let columns = [
  GridItem(.adaptive(minimum: 42), alignment: .leading)
]

alongside
LazyVGrid(columns: columns, spacing: 10) {
  Text("Hello, world!")
    .fixedSize(horizontal: true, vertical: false)
    .border(Color.gray)
  Text("lol")
    .fixedSize(horizontal: true, vertical: false)
    .border(Color.gray)
  Text("bananananananananana")
    .fixedSize(horizontal: true, vertical: false)
    .border(Color.gray)
}

but that didn't work.  setting an explicitly large maximum (50000) didn't help either.  my understanding here was that the LazyVGrid should allow its children to expand their grid cells, but that's clearly not what's happening here.
i wanted to make sure this wasn't Text being all shy and meek and declining to express its size preference, so i tried being more explicit with a frame:
LazyVGrid(columns: columns, spacing: 10) {
  Text("sup")
    .border(Color.gray)
  Text("sup")
    .border(Color.gray)
  Text("sup")
    .frame(minWidth: 100, maxWidth: 100)
    .border(Color.gray)
  Text("sup")
    .border(Color.gray)
  Text("sup")
    .border(Color.gray)
  Text("sup")
    .border(Color.gray)
  Text("sup")
    .border(Color.gray)
  Text("sup")
    .border(Color.gray)
  Text("sup")
    .border(Color.gray)
  Text("sup")
    .border(Color.gray)
}

but this also doesn't work.  i've gotten the wrapping behavior, but not the "flex" behavior, which at least by my reading is what .adaptive purports to do on the tin.
so my secondary question is: what am i misunderstanding about the way that an adaptive LazyVGrid performs size proposal to its children and negotiates the size of its "adaptive columns"?  is there a way to do what i want with grids, and if not, why not (and what's a better plan)?

A: my understanding of .adaptive was incorrect—its columns are always evenly spaced; the maximum argument just allows those columns to expand (in lock-step) so that they collectively fill the parent's space.  i'd thought that each column could individually expand to the max width from the min width.
a friend corrected me and linked me an HStack-based solution: SwiftUI HStack with Wrap
(i'm leaving this question up because the best Lazy*Grid writeup i found, linked above, can i think be interpreted both ways on this point, hence my error.)

A: Edit: realised I focused on the wrap not the flex part of your question and don't think this is what you're after.
I think you just need to set the alignment property and then you get the same effect as CSS flexbox's flex-wrap: wrap shown at CSS tricks..
This seems to work for me, only change to your code is setting alignment: .leading in the LazyVGrid initialiser. Result with alignment: .leading
struct ContentView: View {

    let columns = [
      GridItem(.adaptive(minimum: 42), alignment: .leading)
    ]

    var body: some View {
        LazyVGrid(columns: columns, alignment: .leading, spacing: 10) {
          Text("sup")
            .border(Color.gray)
          Text("sup")
            .border(Color.gray)
          Text("sup")
            .border(Color.gray)
          Text("sup")
            .border(Color.gray)
          Text("sup")
            .border(Color.gray)
          Text("sup")
            .border(Color.gray)
          Text("sup")
            .border(Color.gray)
          Text("sup")
            .border(Color.gray)
          Text("sup")
            .border(Color.gray)
          Text("sup")
            .border(Color.gray)
        }
    }
}


text:
Q: Issue with saving custom field (custom post type) in WooCommerce coupon usage restriction tab I'm trying to add a new field in the usage restriction of coupons.
Here is my code:
function add_coupon_cpt_field() {
    $value = get_post_meta( $post->ID, '_select', true );
    if( empty( $value ) ) $value = '';

    $my_c_posts = get_posts( array(
            'posts_per_page'   => -1,
            'orderby'=> 'date',
            'order'=> 'DESC',
            'post_type'=> 'tour',
            'post_status'=> 'publish',
    ) );

    $options[''] = __( 'Select a value', 'woocommerce'); // default value

    foreach ($my_c_posts as $key => $post)
        $options[$key] = $post->post_title;

        echo '
';

        woocommerce_wp_select( array(
        'id'      => '_select',
        'label'   => __( 'Select Tour', 'woocommerce' ),
        'options' =>  $options,
        'value'   => $value,
        ) );

        echo '
';
}
add_action( 'woocommerce_coupon_options_usage_restriction', 'add_coupon_cpt_field', 10, 0 );

// Save Fields
add_action( 'woocommerce_coupon_options_save', 'custom_posts_fields_save' );
function custom_posts_fields_save( $post_id ){
    $woocommerce_select = $_POST['_select'];
    if( !empty( $woocommerce_select ) )
      update_post_meta( $post_id, '_select', esc_attr( $woocommerce_select ) );
    else {
    update_post_meta( $post_id, '_select',  '' );
    }
}

The titles are displayed but when I save the coupon, the selection is not saved. Any advice?

A: Some comments/suggestions regarding your code attempt/question:

*

*Using $value = get_post_meta( $post->ID, '_select', true ); is not necessary

*In this answer I have used post type 'product' (since this is present by default in WooCommerce, adjust where necessary)

So you get:
// Add new field - usage restriction tab
function action_woocommerce_coupon_options_usage_restriction( $coupon_get_id, $coupon ) {
    // Set post type
    $post_type = 'product';

    // Get posts
    $my_c_posts = get_posts( array(
        'posts_per_page'    => -1,
        'orderby'           => 'date',
        'order'             => 'DESC',
        'post_type'         => $post_type,
        'post_status'       => 'publish',
    ) );

    // Default value
    $options[''] = __( 'Select a value', 'woocommerce' );

    // Get post title
    foreach ( $my_c_posts as $key => $post ) {
        $options[$key] = $post->post_title;
    }

    // Output field
    echo '
';

    woocommerce_wp_select( array(
        'id'      => '_select',
        'label'   => __( 'Select tour', 'woocommerce' ),
        'options' =>  $options,
    ) );

    echo '
';
}
add_action( 'woocommerce_coupon_options_usage_restriction', 'action_woocommerce_coupon_options_usage_restriction', 10, 2 );

// Save
function action_woocommerce_coupon_options_save( $post_id, $coupon ) {
    // Isset
    if ( isset ( $_POST['_select'] ) ) {
        $coupon->update_meta_data( '_select', sanitize_text_field( $_POST['_select'] ) );
        $coupon->save();
    }
}
add_action( 'woocommerce_coupon_options_save', 'action_woocommerce_coupon_options_save', 10, 2 );

redpajama_set_name: RedPajamaStackExchange


text:
Q: Object containing arrays - is there a simpler way to write this common pattern Often times I want to create a javascript object and insert items into an array at a certain index. I find myself writing this pattern a lot:
var obj = {}
for (let item of list) {
    if (obj[condition] == undefined) {
        obj[condition] = [item];
    } else {
        obj[condition].push(item);
    }
}

I just find it frustrating to be constantly checking for undefined. Is there a better way to do this?
Edit: Thank to Nick for helping me find a solution I like

const list = [1, 2, 3, 4, 5];
var obj = {}
for (let item in list) {
    obj[item%2] = [...obj[item%2] || [], item]
}

console.log(obj)

And the functional method:

const list = [1, 2, 3, 4, 5];
var obj = list.reduce((acc, item) => {
    acc[item%2] = [...acc[item%2] || [], item]
    return acc;
}, {});

console.log(obj)

A: I tend to like using reduce for these kinds of cases. You still end up having to do a check to see if the array exists yet, but you might be able to condense the logic like in the following code.

const list = [{
  type: "fruit",
  item: "apple"
}, {
  type: "veggie",
  item: "corn"
}, {
  type: "fruit",
  item: "banana"
}];

const obj = list.reduce((acc, el) => {
  acc[el.type] = [...acc[el.type] || [], el.item];
  return acc;
}, {});

console.log(obj);

A: You can use the array spread operator to simplify the operation.
)obj[condition] = obj[condition]? [...obj[condition], item] : [item];


text:
Q: Java on iPhone or iPad They say Java is not supported on iPhone or iPad. Does that mean websites with JSP as its server-side scripting language would not function properly on those devices? Or just do they only mean to say...let's say Java applet? There's not much information about it out there. I'm not even sure if those devices still don't support Java. The latest official announcement I found dated a few years back.

How dumb of me to have had asked this. Of course, since it's server-side, it doesn't care if the Java VM is present or not in iPhone. Doh!

A: Java applets run in the browser and aren't supported on iOS. JSP pages run on the server and generate the HTML which is perfectly compatible with iOS.

A: You don't need Java at all on the iPad to see the content generated by JSP files.
JSP files are executed on the server, and generate (usually) HTML content that can be seen on an iPad. Also, JavaScript  works fine on an iPad, and there is no relation between Java and JavaScript at all.

A: JSP is a server-side language, so it is never actually seen by the client. This will work.
A Java applet is something that is run by the client, and these will not work on iOS devices.


text:
Q: Latest MVC forms authentication I'm trying to implement asp.net membership (forms version) using VS2012 and MVC4.
I've created the database tables using aspnet_regsql.exe and now I want to configure the web.config so I can run the 'asp.net configuration' utility in visual studio.
It seems I might be needing to use 'simplemembership'. Is this correct, and where can I get instructions on how to configure whichever one I need?
Thank you

A: By default ASP.NET MVC 4 uses the SimpleMembership provider which is a lightweight version of the full provider. It doesn't expose all the functionality of the full version.
The membership provider that you want to use is configured inside the <membership> section of your web.config.
So for example if you wanted to configure the full membership provider (as used in MVC 3):
<membership defaultProvider="DefaultMembershipProvider">
    <providers>
        <add name="DefaultMembershipProvider"
             type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
             connectionStringName="DefaultConnection"
             enablePasswordRetrieval="false"
             enablePasswordReset="true"
             requiresQuestionAndAnswer="false"
             requiresUniqueEmail="false"
             maxInvalidPasswordAttempts="5"
             minRequiredPasswordLength="6"
             minRequiredNonalphanumericCharacters="0"
             passwordAttemptWindow="10"
             applicationName="/"
         />
    </providers>
</membership>


text:
Q: Dual monitors with two Nvidia GPU's I have two gtx 275s SLI'd, When I connect both monitors to same card it allows me to enable twinview, and it works. But when I want to connect each monitor to different cards, I lose the option of twinview and my secondary screen is just white and when i mouse over it my mouse turns into an X.
# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings:  version 295.33  (buildd@allspice)  Fri Mar 30 13:37:33 UTC 2012

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "LG Electronics M2762D"
    HorizSync       30.0 - 83.0
    VertRefresh     56.0 - 75.0
    Option         "DPMS"
EndSection

Section "Monitor"
    Identifier     "Monitor1"
    VendorName     "Unknown"
    ModelName      "DELL E193FP"
    HorizSync       31.0 - 83.0
    VertRefresh     56.0 - 76.0
    Option         "DPMS"
    # HorizSync source: edid, VertRefresh source: edid
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "TwinView" "0"
    Option         "TwinViewXineramaInfoOrder" "CRT-1"
    Option         "metamodes" "nvidia-auto-select +0+0"
    SubSection "Display"
        Depth       24
    EndSubSection
EndSection

Section "Screen"
    Identifier     "Screen1"
    Device         "Device1"
    Monitor        "Monitor1"
    DefaultDepth    24
    Option         "TwinView" "0"
    Option         "metamodes" "nvidia-auto-select +0+0"
    SubSection "Display"
        Depth       24
    EndSubSection
EndSection

Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "kbd"
    # generated from default
EndSection

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 1280 0
    Screen      1  "Screen1" LeftOf "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "0"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 275"
    BusID          "PCI:2:0:0"
    Option  "NoLogo"    "True"
EndSection

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 275"
    BusID          "PCI:3:0:0"
    Option  "NoLogo"    "True"
EndSection

A: Please take a look at chapter 29 of the documentation for the proprietary nvidia drivers. For only two displays nvidia seems to recommend using twinview with both displays connected to one card as this configuration seems to give you the best experience.
You can find the documentation when selecting to download the Linux driver from the official site. It is the README link in the additional information tab.
Or use the Unix related page instead and be sure to use the documentation that matches your driver version and architecture:
http://www.nvidia.com/object/unix.html


text:
Q: BasedOn style not overriding styles Resources Edit: The colour override works on some buttons I have got, which work the same way, except I don't define any colours in the main style resources, I just setup the Color tags but with no colour property

The following style has got 3 colours set to be the default colours used throughout the style, however I want to over ride these 3 colours if I wanted a different colour set on the button.
Here are the ComboBox's, first one should be default colour, second one should be Green override.
<ComboBox HorizontalAlignment="Left" SelectedIndex="0" Text="Select USB Device">
            <ComboBoxItem Content="Test 1" />
            <ComboBoxItem Content="Test 2" />
            <ComboBoxItem Content="Test 3" />
        </ComboBox>
        <ComboBox HorizontalAlignment="Left" SelectedIndex="0" Text="Select USB Device" Style="{StaticResource ComboBlue}">
            <ComboBoxItem Content="Test 1" />
            <ComboBoxItem Content="Test 2" />
            <ComboBoxItem Content="Test 3" />
        </ComboBox>

XAML, main style
<!-- Combo Box Style -->
    <Style TargetType="ComboBox">
        <Style.Resources>
            <SolidColorBrush x:Key="colour1" Color="{Binding Source={StaticResource NorGrey}, Path=Color}" />
            <SolidColorBrush x:Key="colour2" Color="{Binding Source={StaticResource DarGrey}, Path=Color}" />
            <SolidColorBrush x:Key="colour3" Color="{Binding Source={StaticResource LigGrey}, Path=Color}" />

            <Style TargetType="ComboBoxItem">
                <Setter Property="SnapsToDevicePixels" Value="True" />
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ComboBoxItem">
                            <Border x:Name="Border"
                                    Padding="4"
                                    SnapsToDevicePixels="True"
                                    Background="Transparent">
                                <ContentPresenter />
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="Border" Property="Background" Value="{StaticResource colour3}" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="ToggleButton">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="20" />
                    </Grid.ColumnDefinitions>
                    <Border x:Name="Border"
                            Grid.ColumnSpan="2"
                            CornerRadius="5"
                            Background="{StaticResource colour1}"/>
                    <Border Grid.Column="0"
                            CornerRadius="5,0,0,5"
                            Margin="1"
                            Background="{StaticResource colour2}" />
                    <Path x:Name="Arrow"
                          Grid.Column="1"
                          HorizontalAlignment="Center"
                          VerticalAlignment="Center"
                          Data="M 0 0 L 4 4 L 8 0 Z"
                          Fill="White" />
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter TargetName="Border" Property="Background" Value="{StaticResource colour3}" />
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>

            <ControlTemplate x:Key="ComboBoxTextBox" TargetType="TextBox">
                <Border x:Name="PART_ContentHost"
                        Focusable="False"
                        Background="{StaticResource colour1}" />
            </ControlTemplate>
        </Style.Resources>
        <Setter Property="Margin" Value="5" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="True" />
        <Setter Property="MinHeight" Value="20" />
        <Setter Property="MinWidth" Value="80" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBox">
                    <Grid>
                        <ToggleButton x:Name="ToggleButton"
                                      Template="{StaticResource ComboBoxToggleButton}"
                                      Grid.Column="2"
                                      Focusable="False"
                                      ClickMode="Press"
                                      IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />
                        <ContentPresenter x:Name="ContentSite"
                                          IsHitTestVisible="False"
                                          Content="{TemplateBinding SelectionBoxItem}"
                                          ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                          ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                          Margin="6,6,10,6"
                                          VerticalAlignment="Stretch"
                                          HorizontalAlignment="Left" />
                        <TextBox x:Name="PART_EditableTextBox"
                                 Style="{x:Null}"
                                 Template="{StaticResource ComboBoxTextBox}"
                                 HorizontalAlignment="Center"
                                 VerticalAlignment="Bottom"
                                 Margin="3,3,23,3"
                                 Focusable="True"
                                 Background="Transparent"
                                 Visibility="Hidden"
                                 IsReadOnly="{TemplateBinding IsReadOnly}" />
                        <Popup x:Name="Popup"
                               Placement="Bottom"
                               IsOpen="{TemplateBinding IsDropDownOpen}"
                               AllowsTransparency="True"
                               Focusable="False"
                               PopupAnimation="Slide">
                            <Grid x:Name="DropDown"
                                  SnapsToDevicePixels="True"
                                  MinWidth="{TemplateBinding ActualWidth}"
                                  MaxHeight="{TemplateBinding MaxDropDownHeight}">
                                <Border x:Name="DropDownBorder"
                                        Background="{StaticResource colour1}" />
                                <ScrollViewer Margin="4,6,4,6"
                                              SnapsToDevicePixels="True">
                                    <StackPanel IsItemsHost="True"
                                                KeyboardNavigation.DirectionalNavigation="Contained" />
                                </ScrollViewer>
                            </Grid>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasItems" Value="False">
                            <Setter TargetName="DropDownBorder" Property="MinHeight" Value="95" />
                        </Trigger>
                        <Trigger Property="IsGrouping" Value="True">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="True" />
                        </Trigger>
                        <Trigger SourceName="Popup" Property="AllowsTransparency" Value="True">
                            <Setter TargetName="DropDownBorder" Property="CornerRadius" Value="4" />
                            <Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

And here are the styles which are used to override the colours, placed BELOW the main style. But for some reason the colours are not changing.
<!-- Combo Box Colors -->
    <Style BasedOn="{StaticResource {x:Type ComboBox}}" TargetType="ComboBox" x:Key="ComboGreen">
        <Style.Resources>
            <SolidColorBrush Color="{Binding Source={StaticResource NorGreen}, Path=Color}" x:Key="colour1" />
            <SolidColorBrush Color="{Binding Source={StaticResource DarGreen}, Path=Color}" x:Key="colour2" />
            <SolidColorBrush Color="{Binding Source={StaticResource LigGreen}, Path=Color}" x:Key="colour3" />
        </Style.Resources>
    </Style>
    <Style BasedOn="{StaticResource {x:Type ComboBox}}" TargetType="ComboBox" x:Key="ComboGrey">
        <Style.Resources>
            <SolidColorBrush Color="{Binding Source={StaticResource NorGrey}, Path=Color}" x:Key="colour1" />
            <SolidColorBrush Color="{Binding Source={StaticResource DarGrey}, Path=Color}" x:Key="colour2" />
            <SolidColorBrush Color="{Binding Source={StaticResource LigGrey}, Path=Color}" x:Key="colour3" />
        </Style.Resources>
    </Style>
    <Style BasedOn="{StaticResource {x:Type ComboBox}}" TargetType="ComboBox" x:Key="ComboBlue">
        <Style.Resources>
            <SolidColorBrush Color="{Binding Source={StaticResource NorBlue}, Path=Color}" x:Key="colour1" />
            <SolidColorBrush Color="{Binding Source={StaticResource DarBlue}, Path=Color}" x:Key="colour2" />
            <SolidColorBrush Color="{Binding Source={StaticResource LigBlue}, Path=Color}" x:Key="colour3" />
        </Style.Resources>
    </Style>
    <Style BasedOn="{StaticResource {x:Type ComboBox}}" TargetType="ComboBox" x:Key="ComboRed">
        <Style.Resources>
            <SolidColorBrush Color="{Binding Source={StaticResource NorRed}, Path=Color}" x:Key="colour1" />
            <SolidColorBrush Color="{Binding Source={StaticResource DarRed}, Path=Color}" x:Key="colour2" />
            <SolidColorBrush Color="{Binding Source={StaticResource LigRed}, Path=Color}" x:Key="colour3" />
        </Style.Resources>
    </Style>

A: I have managed to find the solution, I used the wrong resource type. When referencing the colours I should of used DynamicResource not StaticResource.


text:
Q: Python string format template for selected parameters I want to create a string template that only selected parameters gets value in each session.
For example:
def format_fruits(fruits_num):

 s = "I have {fruits_num} and I like {fruit_name} very much"

 s.format(fruits_num=fruits_num, fruit_name='apple')
 s.format(fruits_num=fruits_num, fruit_name='orange')

I want to avoid the repeated assignment of fruits_num=fruits_num
In a pseduo code:
def format_fruits(fruits_num):

 s = "I have {fruits_num} and I like {fruit_name} very much".format(fruits_num=fruits_num)

 s.format(fruit_name='apple')
 s.format(fruit_name='orange')

I this possible? Thanks.

A: You can double the { around fruits_name so that it will be literal, which will keep it until the next call to .format().
def format_fruits(fruits_num):
    s = "I have {fruits_num} and I like {{fruit_name}} very much".format(fruits_num=fruits_num)
    print(s.format(fruit_name='apple'))
    print(s.format(fruit_name='orange'))


text:
Q: Haskell Stack's executable profiling and ghc options fails to build I'm trying to debug performance problems in a Haskell project, but I can't get profiling to be compiled in so I can use it through +RTS -p command line arguments.
The options for GHC in my .cabal file are:
ghc-options:         -threaded -rtsopts -with-rtsopts=-N -Wall -Werror

Here's me attempting to build it:
stack build --executable-profiling --library-profiling --ghc-options="-fprof-auto -rtsopts"

Which results in:
While constructing the BuildPlan the following exceptions were encountered:

--  Failure when adding dependencies:
      base: needed (>=2 && <5), not present in build plan (latest applicable is 4.9.0.0)
      mtl: needed (>=2.1 && <2.3), couldn't resolve its dependencies
      random: needed (-any), couldn't resolve its dependencies
      transformers: needed (>=0.3 && <0.6), couldn't resolve its dependencies
      transformers-compat: needed (>=0.4 && <0.6), couldn't resolve its dependencies
    needed for package: MonadRandom-0.4.2.3

--  Failure when adding dependencies:
      base: needed (>=4 && <5), not present in build plan (latest applicable is 4.9.0.0)
      stm: needed (>=2.0 && <2.5), couldn't resolve its dependencies
      transformers: needed (>=0.2 && <0.6), couldn't resolve its dependencies
    needed for package: StateVar-1.1.0.4
<snipped large log>

Even trying with just stack build --executable-profiling results in the same error.
For reference, my library dependencies are:
   build-depends:       base >= 4.7 && < 5
                     , aeson
                     , servant
                     , servant-server
                     , wai
                     , warp
                     , either
                     , bytestring
                     , transformers
                     , postgresql-simple
                     , amazonka
                     , amazonka-sqs
                     , lens
                     , text
                     , time
                     , resource-pool

How can I resolve this so I can compile my project with stack and have profiling built in for use with +RTS -p?

A: What does "stack exec -- which ghc" say?  If your ghc is installed globally, it could be that it lacks profiling libraries.  If so, "stack setup --no-system-ghc" + "stack build --no-system-ghc"
What is your stack.yaml configuration?  If you've set a resolver of "ghc-*", it won't work unless you specify the versions of all your dependencies in "extra-deps".  Usually you'll want to use a stackage snapshot - https://www.stackage.org/


text:
Q: Microcontroller ADC Hex equivalent and display I'm only familiar with the 68HC11 as I have been learning its assembly language the past 2 months. In its ADC (Analog to Digital Converter). 5V (or whatever highest cutoff set by Vrh) is hex FF while 0V is 00. How about in other microcontrollers you have encountered. What is the hex value of the highest voltage and lowest?

Also in the HC11. I can make the ADC output FF decrement until it reaches 00 and display it at a screen. In the above image, the lowest point is FF (or 255) and highest 00.
Taken from the following when I programmed the HC11 within the unit to do this:

I'd like to know what display you have used that can also do like the above because I'd like to try others too.

A: *

*68HC11 has a built-in 8-bit ADC. Many other MCUs also have 8-bit or even better ADCs so 256 counts or more. External ADCs can be used if the MCU has no built-in ADC. Typically 10 or 12 bits which give you 1024 or 4096 counts, some might have 16 bits for 65536 counts.

*There may be specialized PC programs or libraries to do PC programs to draw generic plots with generic received data. Generally if you have a specific program you already have, it communicates with some specific protocol. If you want a program that receives certain protocol you need to find it or make it yourself. It is likely someone knows what the protocol is and has made a program to receive data with that protocol. Sometimes device manuals have documentation about how they transfer data so you can be compatible.


text:
Q: How to pass to an intent if Permission request is denied I have an Action that integrates with Dialogflow which as part of the conversation requests access to the user's location.

This is fulfilled via a webhook:
app.intent('actions_intent_PERMISSION', async (conv, params, permissionGranted) => {
    if (!permissionGranted) {
        app.intent('actions_intent_PERMISSION - no', (conv, params) => {
            conv.ask('sad face, you said no to my permission request!');
    });
    // conv.ask(`Ok, no worries. I'll have to figure out how to get your postcode. follow-up intent I suppose`);
    } else {
        conv.data.postcode = conv.device.location.zipCode;
        conv.ask(`Ok great - please give me a minute, I have to get data from a few different places.`);

     //use postcode to make some other API calls
    }
});

Everything is fine when the user gives permission but when they don't give permission I would like to pass off to an intent that asks for their location manually ('what is your postcode/zipcode?').
As per the screenshot I tried creating a followup intent to actions_intent_PERMISSION called actions_intent_PERMISSION - no but this causes the app to crash.
What is the best way to pass the conversation to another intent is the value of permissionGranted is false?

A: Your question doesn't quite make sense the way you've asked it. Intents represent what the user has said and not what you do with it - that is what your webhook does in an Intent Handler. There is nothing (technically) stopping you from replying to the user asking for their zip code by just replying differently.
If you want users to be able to trigger some Intents if they have given permissions, and other Intents if they have not, you can set a different Context for each. Then you would set some Intents to only be triggered if the "permitted" context was set, and others only if the "notpermitted" context was set.
However, you have a non-technical problem to consider. If they aren't giving you permission to get their location, why would they tell you their location? It also is likely that the reviewers would reject it, saying that you should be getting location information through the provided API.


text:
Q: Adapting log4j1 configuration to log4j2 I have a java application that uses log4j version 1 and I want to migrate to log4j2. The configuration properties is as keeps:
log4j.rootLogger=INFO,FILE,console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss} %l - %m%n
log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.FILE.File=${jboss.server.log.dir}/application/application.log
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=[%-5p] %d{dd-MM-yyyy HH:mm:ss} %l - %m%n
log4j.appender.FILE.DatePattern='.'yyyy-MM-dd

This is the xml configuration that I am coding:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
    <Appenders>
        <Console name="ConsoleAppender" target="SYSTEM_OUT">
            <PatternLayout pattern="[%-5p] %d{yyyy-MM-dd HH:mm:ss} %l - %m%n" />
        </Console>
        <RollingFile name="DailyLog"
                 fileName="${env:JBOSS_HOME}/standalone/log/application/application.log"
                 filePattern="${env:JBOSS_HOME}/standalone/log/application/application.log.%d{yyyy-MM-dd}">
            <PatternLayout pattern="[%-5p] %d{dd-MM-yyyy HH:mm:ss} %l - %m%n"/>
            <Policies>
              <TimeBasedTriggeringPolicy/>
            </Policies>
        </RollingFile>
    </Appenders>
    <Loggers>
        <Root level="debug">
            <AppenderRef ref="ConsoleAppender" />
            <AppenderRef ref="DailyLog"/>
        </Root>
    </Loggers>
</Configuration>

The log files created should be:
application.log.2022-06-05
application.log.2022-06-06
application.log  (Today, June 7th)

Log4j2 version: 2.17.1
The objective is that the second configuration is equivalent to first one.
Question: Do you think the xml configuration is equivalent to configuration properties? or Is there something missing?
Post Updates:

*

*ImmediateFlush removed

*Wildfly path changed

*FileAppender removed

*Interval attribute from TimeBasedTriggeringPolicy removed

After post updates, it works.

A: TL;DR: Remove the appender named FileAppender.
The main problem in your configuration is that you have two appenders that append to the same file: ${env:JBOSS_HOME}/standalone/log/application/application.log. Log4j2 allows such a configuration only if both appenders are of the same type (i.e. either both FileAppender or RollingFileAppender): in this case both appenders will share a single file manager. Otherwise the configuration will probably fail.


text:
Q: (Higher order) logic/type theory/category theory like (meta-)grammar/language/machine?
TL;DR: Could you consider the relation between logic, type theory, and category theory like the relation between formal grammars (rules), formal languages (syntax), and abstract machines (semantics), and similarly, the higher order variants (of logic, etc.) as meta-equivalents (of formal grammars, etc.)?

Note: I'm not a mathematician, so most of this is self-taught. I'm a self-taught developer, so I may have missed various minor details and such. Apologies if this happened and my question wound up incomplete somehow.
I was reading up on how category theory and type theory relate, and how there's a clear duality between both of those and logic, and having some familiarity with basic formal grammar/language concepts, I started thinking of an analogy.

*

*Formal language theory sees languages as providing the syntax and abstract machines providing semantics. There similarly also exists a grammar, which defines the rules for building the language and for the semantics to bind to.

*Languages define the syntax, the set of strings/symbols valid within it.

*

*Type theory can be regarded as a formal syntactic framework for category theory, providing a set of concepts for it to work from.

*Languages can be defined based on their rules. Similarly, type theory can be defined through its logical inference rules (and generally is).

*Machines define the semantics, what each "production" does.

*

*Category theory can be regarded as providing a semantic framework for type theory, explaining what each concept does.

*Machines are typically defined by what they do, but the capabilities of certain classes of machines are defined by the languages they accept, with certain restrictions on their grammars. Similarly, classes of categories could be defined by the types it contains, with restrictions on which rules of logic apply. (This maps very closely to the concept of objects + morphisms.)

*Grammars define the rules applied to determine whether some set of symbols are within a language.

*

*Although I can't find any material explicitly stating it, it seems logic, being as rule-based as it is, fills this gap pretty well as providing a rule framework based on a syntax to define the rules.

*Grammars can "generate" languages that satisfy its rules. Similarly, logic is often used to "generate" various conclusions through their proofs, and in the case of constructive logic, is literally used to "generate" type theories and similar through strategic rule definitions.

*Higher order logic/type theory/category theory extends this to basically generate such logic/type theories/category theories, almost as templates.

*

*This is analogous to meta-grammars, meta-languages, and hypermachines/machines that implement machines.*

*Similarly, this can be narrowed to intuitionistic propositional logic/simply typed lambda calculus/Cartesian closed categories due to the Curry-Howard-Lambek correspondence

*

*This is analogous to the hierarchy of non-recursive grammars/finite languages/DAFSA
So, in a sense, if I'm correct with my reasoning,
$$
\begin{matrix}
\text{(higher order) logic} \\
\text{(meta-) rules} \\
\text{(meta-) grammar}
\end{matrix}
\Leftrightarrow
\begin{matrix}
\text{(higher order) type theory} \\
\text{(meta-) syntax} \\
\text{(meta-) language}
\end{matrix}
\Leftrightarrow
\begin{matrix}
\text{(higher order) category theory} \\
\text{(meta-) semantics} \\
\text{(meta-) machine}
\end{matrix}
$$
?
Or am I missing something?
Also, by any chance, where could I find some authors/researchers that could help me better understand this relation?

* It'd be nice if Wikipedia actually made these remotely accessible from anywhere else short of hard-to-discover Google searches.

A: I am not entirely sure I have completely understood your question but I will try to give me 2 cents.
It is true that you can regard logics and type theories as some sort of grammars. The elements of the languages generated by these grammars are called judgments: they will be logical judgments in case you are dealing with logics and they will be typing judgements or equality-judgments in case your dealing with type theories.
The relation between logics and type theories is different from the one between grammars and languages: logics do not generate type theories, they are both grammars.
The Curry-Howard theorem establishes an isomorphism between the grammar intuitionistic propositional calculus and the grammar simply typed lambda calculus and between their languages ... though more exactly this isomorphism regards just the typing rules/judgment of simply typed lambda calculus.
Similarly there are generalizations of Curry Howard isomorphism between other logics and type theories. Again these isomorphisms relate the grammars-logics with the grammar type theories.
About the semantics: usually abstract machines are a way to provide an operational semantics for a language. Category theory provides a semantics for logics and type theories, but it is a denotational semantics which differs for the operational ones.
I hope this addresses your doubts, if you need additional details or some clarifications feel free to ask.


text:
Q: Storing dataframe into HBase using Spark I am storing dataframe to hbase table from the pyspark dataframe in CDP7, following this example, the components that I use are:

*

*Spark version 3.1.1

*Scala version 2.12.10

*shc-core-1.1.1-2.1-s_2.11.jar

The command that i use:
spark3-submit  --packages com.hortonworks:shc-core:1.1.1-2.1-s_2.11 --repositories http://repo.hortonworks.com/content/groups/public/ --files /etc/hbase/conf/hbase-site.xml test-hbase3.py

However, I got this error, it is quite long that I need to put it in hastebin.com as below:
spark-log
error snippet:
Traceback (most recent call last):
  File "/opt/cloudera/parcels/CDH-7.1.6-1.cdh7.1.6.p0.10506313/test-hbase3.py", line 45, in <module>
    main()
  File "/opt/cloudera/parcels/CDH-7.1.6-1.cdh7.1.6.p0.10506313/test-hbase3.py", line 24, in main
    writeDF.write.options(catalog=writeCatalog, newtable=5).format(dataSourceFormat).save()
  File "/opt/cloudera/parcels/SPARK3-3.1.1.3.1.7270.0-253-1.p0.11638568/lib/spark3/python/lib/pyspark.zip/pyspark/sql/readwriter.py", line 1107, in save
  File "/opt/cloudera/parcels/SPARK3-3.1.1.3.1.7270.0-253-1.p0.11638568/lib/spark3/python/lib/py4j-0.10.9-src.zip/py4j/java_gateway.py", line 1305, in __call__
  File "/opt/cloudera/parcels/SPARK3-3.1.1.3.1.7270.0-253-1.p0.11638568/lib/spark3/python/lib/pyspark.zip/pyspark/sql/utils.py", line 111, in deco
  File "/opt/cloudera/parcels/SPARK3-3.1.1.3.1.7270.0-253-1.p0.11638568/lib/spark3/python/lib/py4j-0.10.9-src.zip/py4j/protocol.py", line 328, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o36.save.
: java.lang.NoClassDefFoundError: scala/Product$class
    at org.apache.spark.sql.execution.datasources.hbase.HBaseRelation.<init>(HBaseRelation.scala:73)
    at org.apache.spark.sql.execution.datasources.hbase.DefaultSource.createRelation(HBaseRelation.scala:59)
    at org.apache.spark.sql.execution.datasources.SaveIntoDataSourceCommand.run(SaveIntoDataSourceCommand.scala:46)

What should I do to fix the error? I tried to find other connector. However, only found SHC connector. Im not using any Maven repo here. But, not sure if there is missing dependencies or other error.

A: This is a scala version conflict. Your shc_core.jar is compiled for scala 2.11 but you're using scala 2.12 which is not binary compatible with 2.11.
Easiest fix would be to recompile shc_core from source for scala 2.12 (although you may end up with compatibility issues since the project is
obviously not tested with scala 2.12)
Other ways you can explore to solve your issue:

*

*accessing HBase through a Hive table (https://docs.cloudera.com/HDPDocuments/HDP3/HDP-3.1.5/hbase-data-access/content/hdag_hbase_hive_integration_example.html)

*using something like Phoenix connector (https://docs.cloudera.com/runtime/7.2.8/phoenix-access-data/topics/phoenix-spark-connector-examples.html)

*rolling your own connector with HBase API for your data frame, it's fairly straightforward if you're not trying to implement a fully generic solution


text:
Q: Spell checking using fastText model? So I'm using fastText from its GitHub repo and wondering if it has build-in spell checking command.
If yes, how do I use them? and can I get full documentation of fastText because as in here answer from Kalana Geesara, I could use model.get_nearest_neighbor (and it worked) while I can't find it anywhere (even in the repo readme).
If no, is there any way for me to do spell checking with the model provided?
I am using english model provided here and code it without Gensim

A: I've solved the problem by using Peter Norvig's Spell Correction Algorithm and load it with fastText models.
But I've to install it with Gensim since I only found a tutorial about it.


text:
Q: UIScrollView doesn't scroll without bouncing I have a UIScrollView on my UIViewController. I have the following options set:

*

*Shows Vertical Scrollers

*Scrolling Enabled

It DOES NOT scroll. When I set the following:

*

*Bounces Zoom

*Bounces

*Bounce Vertically

It scrolls but with bouncing... Is there something I am missing? Why is it that with scrolling enabled it doesn't scroll??
[EDIT]
I was having some issues with it, but got it to work by setting the contentSize. My question however is this, I have a screen with all sorts of content, buttons, text, labels, etc. How is it possible to calculate (accurately) of the size of everything? Is there a way for it to automatically tell how much length the scrollview should grow?

A: I dont think there is an automatic way of resizing the contentSize to the subviews you have. If you are using Interface Builder and the content is not dynamic then setting the content size should be relatively easy. If not, your going to have to resize it manually.
You should be able to calculate the size by obtaining the frames of your object ([myView frame]).
You could write a method that checks the frames of all your subviews and resize the contentSize accordingly. Assuming you are placing your subviews in vertical order. taking the last Views frame's y position + it's height (view.frame.origin.y + view.frame.size.height could be your contentViews height and so on...
hope this helps.


text:
Q: How can I import data from Excel to SAGA? I have just started using SAGA and I want to plot some geographic coordinates (latitudes and longitudes) and I want to import them from Excel. Please tell me what to do from Excel to when the points are plotted.

A: In Excel, try exporting your data as tab-seperated textfile (in save as).
You can open this file in saga by using open table.
You will want to run the module modules\shapes\convert table to point to convert your table to points.


text:
Q: CSS Overflow issue in IE I having problem to make the overflow hidden if the width is over the line
anyone know how to do it?
It does not work for IE at all.

        A
        B

        1

I like to eat McDonalds double
cheese burger, i am lovin it!

        aa

A: Add width and height attributes to your overflow-hidden
.

A: I try changing min-width:160px; in div's style to width:160px; & it solved your problem.


text:
Q: E: The package livenavigator needs to be reinstalled, but I can't find an archive for it When I want to upgrade packages on Ubuntu 14.10 I get the message
E: The package livenavigator needs to be reinstalled, but I can't find an archive for it

I didn't find anything about livenavigator on the web.
My update-manager seems out of order... I'm stuck!

A: Finally,
I edited the /var/lib/dpkg/status file using
sudo -H gedit /var/lib/dpkg/status

and removed the part referring to livenavigator. I saved the file, and then I ran
sudo apt-get clean

and I rebooted the PC.
At least, I restored all APT functionality.

A: There's no such package in the Ubuntu repositories; check here.
Run apt-cache policy livenavigator to find out from what repository you installed the software.
Once you know that, investigate further (or add the output to your question so we can take a look at it.)
I don't know what livenavigator is or does and I can't find it on the internet. If you don't know what it is, you may as well try to uninstall it. Be careful and read the output before doing so:
sudo apt-get remove livenavigator.


text:
Q: (Emacs) How to only show last directory in emacs shell? I would like to know if it is possible to show only last directory in eShell (Emacs Shell). For example, It's currently in path /home/user/Programming/C++. With current setup of eshell, ~/Programming/C++ $, but I would like to show only this: C++ $.
Thanks

A: Yes, it's possible - the prompt is generated by function stored in the eshell-prompt-function variable.  You can redefine it to whatever you want.  You can define it something like: (lambda () (concat (car (last (split-string (eshell/pwd) "/"))) " $ "))
See EmacsWiki for examples.


text:
Q: append brackets to all constants beginning with L:: where it not exist on end I have many PHP Files where I need to add on end "()" to every constant beginning with "L::" which don't have on end "(". It should by applied to all *.php including subfolders) :
L::WHAT_EVER
<?=L::WHAT_EVER?>

should become:
L::WHAT_EVER()
<?=L::WHAT_EVER()?>

but not touch any of them:
L::WHAT_EVER()
L::WHAT_EVER('aaa')
L::WHAT_EVER($a, $b)

Is there any sed regex command that I could apply to reach this Goal?

A: It's easier with perl:
perl -pi -e 's/\bL::\w++\K(?!\()/()/g' ./*.php

*

*\bL::: L:: following  a word boundary  (to avoid replacing NIL::Foo ones).

*\w: any word character (ASCII letters, numbers or underscore)

*++: one or more (of the \ws), but don't backtrack

*\K: set the start of the matched portion (so just after that word)

*(?!...): negative look ahead assertion. So here only matches if what follows is not a (.

A: Perl and the better regex engine is easier as it has lookaround feature, for GNU sed testing:
sed -E 's/(\w+::\w+)([^(].+)?/\1()\2/' ./*.php

solving recursive glob process:
find . -iname '*.php' -exec sed -E 's/(\w+::\w+)([^(].+)?/\1()\2/' '{}' +

for its real editing, add -i option,
find . -iname '*.php' -exec sed -i -E 's/(\w+::\w+)([^(].+)?/\1()\2/' '{}' +


text:
Q: Both request.json and request.get_json() fail in Flask 0.12.2 for windows I installed flask and wrote this basic code
from __future__ import print_function
from flask import Flask, jsonify, request
import json
import sys
app = Flask(__name__)

@app.route('/api/dashboard/create', methods=['POST'])
def build_dashboard():

    if "application/json" not in request.headers["Content-Type"]:
         abort(400)

    print('test1', file=sys.stderr)
    json_data = request.get_json()
    print("test2", file=sys.stderr)
    dashboard_data = {}
    return dashboard_data, 201

Then, I used curl to send a json request like this
curl -H "Content-Type: application/json" -X POST -d '{"username":"xyz","password":"xyz"}' http://localhost:5000/api/dashboard/create

The output I see is
test1
127.0.0.1 - - [23/Jul/2017 23:39:29] "POST /api/dashboard/create HTTP/1.1" 400
So the call to request.get_json() causes an error or something.

*

*I tried also calling request.json but I got the same result (I've saw some
questions here regarding a similar issue, but always request.json or
request.get_json() seemed to work for people.

*When I printed request.is_json I got True

*I'm using flask 0.12.2 for windows, which should be the newest version I think.
Any idea what's happening?
Thanks a lot :)
edit:
Pdb step debugging before the call to request.get_json()
> c:\users\john\desktop\lively-backend\main.py(16)build_dashboard()
   -> json_data = request.get_json()
(Pdb) n
BadRequest: <BadRequ...Request'>
> c:\users\john\desktop\lively-backend\main.py(16)build_dashboard()
-> json_data = request.get_json()
(Pdb) n
--Return--
> c:\users\john\desktop\lively-backend\main.py(16)build_dashboard()->None
-> json_data = request.get_json()
(Pdb) n
BadRequest: <BadRequ...Request'>
> c:\python27\lib\site-packages\flask-0.12.2-py2.7.egg\flask\app.py(1598)dispatch_request()
-> return self.view_functions[rule.endpoint](**req.view_args)
(Pdb) n
--Return--
> c:\python27\lib\site-packages\flask-0.12.2-py2.7.egg\flask\app.py(1598)dispatch_request()->None
-> return self.view_functions[rule.endpoint](**req.view_args)
(Pdb) n
BadRequest: <BadRequ...Request'>
> c:\python27\lib\site-packages\flask-0.12.2-py2.7.egg\flask\app.py(1612)full_dispatch_request()
-> rv = self.dispatch_request()
(Pdb) n
> c:\python27\lib\site-packages\flask-0.12.2-py2.7.egg\flask\app.py(1613)full_dispatch_request()
-> except Exception as e:
(Pdb) n
> c:\python27\lib\site-packages\flask-0.12.2-py2.7.egg\flask\app.py(1614)full_dispatch_request()
-> rv = self.handle_user_exception(e)
(Pdb) n
> c:\python27\lib\site-packages\flask-0.12.2-py2.7.egg\flask\app.py(1615)full_dispatch_request()
-> return self.finalize_request(rv)
(Pdb) n
--Return--
> c:\python27\lib\site-packages\flask-0.12.2-py2.7.egg\flask\app.py(1615)full_dispatch_request()-><Respons...REQUEST]>
-> return self.finalize_request(rv)
(Pdb) n
> c:\python27\lib\site-packages\flask-0.12.2-py2.7.egg\flask\app.py(1989)wsgi_app()
-> return response(environ, start_response)
(Pdb) n
> c:\python27\lib\site-packages\flask-0.12.2-py2.7.egg\flask\app.py(1991)wsgi_app()
-> if self.should_ignore_error(error):
(Pdb) n
> c:\python27\lib\site-packages\flask-0.12.2-py2.7.egg\flask\app.py(1993)wsgi_app()
-> ctx.auto_pop(error)
(Pdb) n
--Return--
> c:\python27\lib\site-packages\flask-0.12.2-py2.7.egg\flask\app.py(1993)wsgi_app()-><werkzeu...04467B38>
-> ctx.auto_pop(error)
(Pdb) n
--Return--
> c:\python27\lib\site-packages\flask-0.12.2-py2.7.egg\flask\app.py(1997)__call__()-><werkzeu...04467B38>
-> return self.wsgi_app(environ, start_response)
(Pdb) n
> c:\python27\lib\site-packages\werkzeug\serving.py(198)execute()
-> try:
(Pdb) n
> c:\python27\lib\site-packages\werkzeug\serving.py(199)execute()
-> for data in application_iter:
(Pdb) n
> c:\python27\lib\site-packages\werkzeug\serving.py(200)execute()
-> write(data)


text:
Q: Codeigniter user_agent not working I have used the following to detect mobile, robot and desktop as described in user documentation of codeigniter.
     if ($this->agent->is_mobile()) {
           // This is a mobile device
        $data['is_mobile'] = true;
        $this->load->view('mobile/template/header');
        $this->load->view('mobile/template/imageDiv', $data);
        $this->load->view('mobile/template/footer');
        } else if ($this->agent->is_robot()) {
            // This is a robot, treat it like a mobile device so that our content is indexed
        $data['is_mobile'] = true;
        $this->load->view('mobile/template/header');
        $this->load->view('mobile/template/imageDiv', $data);
        $this->load->view('mobile/template/footer');

        } else {
        $data['is_mobile'] = false;
        $this->load->view('template/header');

        $this->load->view('login/loginOnHover', $data);
        $this->load->view('template/imageDiv', $data);
        $this->load->view('template/booking_track', $data);
        $this->load->view('template/recent_hotels', $data);
        $this->load->view('template/easybooking');
        $this->load->view('template/features');
        $this->load->view('template/stepsApi', $data);
        $this->load->view('template/footer');
    }

It is working fine for almost all mobile devices, but for google nexus series, blackberry PlayBook and Ipads it shows the desktop view.
How could I solve it?

A: Try this way:-
In application/libraries/MY_User_agent.php:
class MY_User_agent extends CI_User_agent {

    public function __construct()
    {
        parent::__construct();
    }

    public function is_ipad()
    {
        return (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad');
          // You can add other checks for other tablets
    }
}

Check by this way:-
    $this->load->library('user_agent');

    ($this->agent->is_ipad() === TRUE) ? $is_ipad = "Yes" : $is_ipad = "No";

    echo "Using ipad: $is_ipad";


text:
Q: Show wait message while application exit I have the following code, Some times ArchiveFiles() take more time to complete its execution.
When user clicks exit option more than one time from context menu, Application becomes non responding if ArchiveFiles() takes more time. How can I show a wait message when he clicks the exit option again?
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
    ArchiveFiles();
    Application.Exit();
}

Thanks
Bhaskar

A: You can use BackgroundWorker.
Using BackgroundWorker, you will be able to execute time consuming tasks such as the one you have on another thread so that the UI doesn't freeze. You will be able to report the progress of that task, then report it accomplishement and executing what ever logic you need after its completion.
Handle the BackgroundWorker.DoWork event to start the operation that performs the potentially time-consuming work.
Handle BackgroundWorker.ProgressChanged event to report the progress of an asynchronous operation to the user.
Finaly, handle BackgroundWorker.RunWorkerCompleted event to implement whatever logic you want to be implemented after the task has been completed.

Refer to the following:
BackgroundWorker Component Overview
C# BackgroundWorker Tutorial

A: Create a new WaitingForm and put an image control on the form and use the below .gif in that image control which which automatically animate. Then use the code below:

  private void exitToolStripMenuItem_Click(object sender, EventArgs e)
  {
     using (var wait = new WaitingForm())
     {
       wait.Show();
       ArchiveFiles();
       Application.Exit();
     }
  }

This may not be the best solution but it is the quickest. If you want the form to be a dialog, use wait.ShowDialog(); instead and carry ArchiveFiles(); Application.Exit();
 functions inside it (if that is a probability).

A: You'd have to run ArchiveFiles asynchronously, by either using a thread or task, or making some delegate and using its BeginInvoke method.
You should use then some synchronization object like ManualResetEvent so the main thread don't continue executing, calling Application.Exit(). Or you could use some event to know when the operation finishes and then call Application.Exit() (or call it inside ArchiveFiles), but I find that to be worse.


text:
Q: How to implement word spell checking with c? I need to create spell checker in c for my assessment. I manage to start the work - I have text file which content all the dictionary, I code how to read the files, how to compare chosen file with the dictionary file and now I need to print out to new text file where the misspelled words been found, what they are, and their correct version. The big problem is, that I have no idea how to do this. My code right now can say that there is a difference between the files. But I don't know how make strcmp check string by string, word by word, if something is wrong.
In dictionary files are all the words, so of course, if my program is reading other file, compare, then writes all the words which aren't in the file to the new output file with errors, these output-error words will be also just random words, which aren't even in the text file, or connected with the text file.
I hope I explained my problem well and there is somebody who would tell me how to fix this problem. I don't even ask for the code, I just need some idea how I would need to code the rest of the program. And sorry, for my English, it's my second language, so I still make grammatical mistakes.

A: Here are some steps you can follow:

*

*read the dictionary into a memory structure, for example an array of strings, which you will sort in lexicographical order (with strcmp).

*read the file line by line, and for each line iterate these steps:

*

*initialize a highlight line with spaces, same length as the line read.

*skip characters that cannot be part of a word with strcspn(), save the index i.

*scan the characters that can be part of a word with strspn() save this number n.

*if n is 0, this is the end of line

*look up the word at index i with n chars in the dictionary (potentially ignoring the case)

*if the word cannot be found, set the corresponding characters in the warning line with ^ characters.

*update the index i += n and iterate.

*if at least one word was not found in the line, output the line and the warning line.
Study these standard functions:

*

*strspn()

*strcspn()

*qsort()

*bsearch()


text:
Q: Define a global variable in laravel and modify it in blades I need to define an array and pass it to blade.
But it is important for me to add items to it in some nested blades, then show the result in another blade.
Example:
Blades Tree:
--plane
----head
----body
------header
------content
------footer

I want to...

*

*Send an array like $var = ['item1', 'item2'] to the blade  "plane".

*Modify it in the blade "header": $var[] = 'item3'

*Modify it again in the blade "content": $var[] = 'item4'

*Then access it in "footer" like ['item1', 'item2', 'item3, 'item4']


text:
Q: How can I delay a css animation until the element is visible? I have this animation that makes a h1 and p "fly in":
@-moz-keyframes titledrop {
                0% {
                    -moz-transform: translateY(-80px);
                }
                100% {
                    -moz-transform: translateY(0);
                }
            }
            @-webkit-keyframes titledrop {
                0% {
                    -webkit-transform: translateY(-80px);
                }
                100% {
                    -webkit-transform: translateY(0);
                }
            }
            @keyframes titledrop {
                0% {
                    transform: translateY(-80px);
                }
                100% {
                    transform: translateY(0);
                }
            }
            @-moz-keyframes drop2 {
                0% {
                    -moz-transform: translateY(-80px);
                }
                100% {
                    -moz-transform: translateY(0);
                }
            }
            @-webkit-keyframes drop2 {
                0% {
                    -webkit-transform: translateY(-80px);
                }
                100% {
                    -webkit-transform: translateY(0);
                }
            }
            @keyframes drop2 {
                0% {
                    transform: translateY(-80px);
                }
                100% {
                    transform: translateY(0);
                }
            }

But sometimes the animation starts before the element is visible, so it looks like nothing happened. How can I delay a css animation until the element is visible?


text:
Q: A combinatoric problem
The question is to find which of the following option is correct regarding $$\left(\frac{\ \ 2^{10}}{11}\right)^{11}$$
$A)$ strictly larger than $\binom{10}{1}^2 \binom{10}{2}^2\binom{10}{3}^2\binom{10}{4}^2\binom{10}{5}$
$B)$ strictly larger than $\binom{10}{1}^2 \binom{10}{2}^2\binom{10}{3}^2\binom{10}{4}^2$ but strictly smaller than $\binom{10}{1}^2 \binom{10}{2}^2\binom{10}{3}^2\binom{10}{4}^2 \binom{10}{5}$
$C)$ less than or equal to $\binom{10}{1}^2 \binom{10}{2}^2\binom{10}{3}^2\binom{10}{4}^2$
$D)$ equal to $\binom{10}{1}^2 \binom{10}{2}^2\binom{10}{3}^2\binom{10}{4}^2\binom{10}{5}$

This question came in I.S.I. B.Stat 2013 Entrance exam in which calculators were not allowed.I tried using some combaratorial argument but failed.Any help shall be highly appreciated.Thanks.

A: Is this AM-GM? We have
$$\binom{10}1^2\binom{10}2^2\binom{10}3^2\binom{10}4^2\binom{10}5
=\prod_{k=0}^{10}\binom{10}k<\left(\frac1{11}\sum_{k=0}^{10}
\binom{10}k\right)^{11}=\left(\frac{2^{10}}{11}\right)^{11}.
$$


text:
Q: How do I know the key sizes of my Bind DNSSEC keys? I set up DNSSEC on my private domain many years ago and unfortunately forgot all about it. Bind now tells me it's about to deprecate auto-dnssec in favour of dnssec-policy and I need to migrate my configuration.
I can see my keys are using RSASHA256 and if I understand the documentation correctly I need to define the KSK and ZSK key sizes in the policy like this:
dnssec-policy "mypolicy" {
        keys {
                ksk lifetime unlimited algorithm RSASHA256 <key-size>;
                zsk lifetime unlimited algorithm RSASHA256 <key-size>;
        };
};

But how do I know what key-sizes I'm currently using? I created them so many years ago and no longer remember.
Regards
Morgan


text:
Q: Find the marginal density of $Y$ and $\mathbb{P}(Y>X)=\frac{5}{8}$. The random vector $(X,Y)$ has joint density function given by
$f(x,y)=\frac{1}{4}(x+3y)e^{-(x+y)}$ if $x,y\geqslant0$ and $f(x,y)=0$ otherwise.
Find the marginal density of $Y$ and $\mathbb{P}(Y>X)=\frac{5}{8}$.
Attempt:
$$\begin{align*}
        f_{Y}(y)&=\int_{-\infty}^{\infty}f(x,y)dx\\
        &=\int_{0}^{\infty}\frac{1}{4}(x+3y)e^{-(x+y)}dx\\
        &=\frac{1}{4}(1+3y)e^{-y}.
    \end{align*}$$
and
$$\begin{align*}
        \mathbb{P}(Y>X)&=\int_{0}^{\infty}\int_{x}^{\infty}\frac{1}{4}(x+3y)e^{-(x+y)}dydx\\
        &=\frac{5}{8}.
    \end{align*}$$


text:
Q: WiFi disconnects for few seconds and resumes In Kubuntu, strangely enough, Wifi completely goes off for about 5 to 30 seconds and then reconnects again. What can be cause of this problem?
My Laptop info:
Kubunu 15.10
KDE plasma 5.4.2
Kernel Version 4.2.0-27-generic
let me know which other info I need to share. (this guy shares alot of info and nobody answered!)
Update 1: output of lspci -knn | grep Net -A2
02:00.0 Network controller [0280]: Broadcom Corporation BCM4312 802.11b/g LP-PHY [14e4:4315] (rev 01)
        Subsystem: Hewlett-Packard Company Device [103c:1508]
        Kernel driver in use: b43-pci-bridge

Update 2: output of grep wlan /var/log/kern.log
Feb  7 13:29:45 HP kernel: [   20.420557] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 13:30:34 HP kernel: [   69.472388] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 13:30:34 HP kernel: [   69.557596] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 13:30:41 HP kernel: [   76.132410] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 13:30:49 HP kernel: [   84.516376] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 13:30:50 HP kernel: [   84.595066] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 13:48:26 HP kernel: [   20.763486] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 13:48:31 HP kernel: [   26.496351] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 13:48:32 HP kernel: [   26.768843] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 13:50:02 HP kernel: [  117.425032] wlan0: authenticate with a4:b1:e9:9c:f0:96
Feb  7 13:50:02 HP kernel: [  117.448664] wlan0: send auth to a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 13:50:02 HP kernel: [  117.453951] wlan0: authenticated
Feb  7 13:50:02 HP kernel: [  117.456283] wlan0: associate with a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 13:50:02 HP kernel: [  117.459509] wlan0: RX AssocResp from a4:b1:e9:9c:f0:96 (capab=0x411 status=0 aid=5)
Feb  7 13:50:02 HP kernel: [  117.459902] wlan0: associated
Feb  7 13:50:02 HP kernel: [  117.459936] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
Feb  7 13:50:05 HP kernel: [  120.472723] wlan0: deauthenticated from a4:b1:e9:9c:f0:96 (Reason: 2=PREV_AUTH_NOT_VALID)
Feb  7 13:50:34 HP kernel: [  149.401202] wlan0: authenticate with a4:b1:e9:9c:f0:96
Feb  7 13:50:34 HP kernel: [  149.424614] wlan0: send auth to a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 13:50:34 HP kernel: [  149.427180] wlan0: authenticated
Feb  7 13:50:34 HP kernel: [  149.428251] wlan0: associate with a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 13:50:34 HP kernel: [  149.431222] wlan0: RX AssocResp from a4:b1:e9:9c:f0:96 (capab=0x411 status=0 aid=5)
Feb  7 13:50:34 HP kernel: [  149.431620] wlan0: associated
Feb  7 14:08:38 HP kernel: [ 1232.119261] wlan0: deauthenticating from a4:b1:e9:9c:f0:96 by local choice (Reason: 3=DEAUTH_LEAVING)
Feb  7 14:11:40 HP kernel: [   19.752909] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 14:12:37 HP kernel: [   77.492458] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 14:12:37 HP kernel: [   77.555537] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 14:13:18 HP kernel: [  117.789036] wlan0: authenticate with a4:b1:e9:9c:f0:96
Feb  7 14:13:18 HP kernel: [  117.812648] wlan0: send auth to a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 14:13:18 HP kernel: [  117.815753] wlan0: authenticated
Feb  7 14:13:18 HP kernel: [  117.820065] wlan0: associate with a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 14:13:18 HP kernel: [  117.823603] wlan0: RX AssocResp from a4:b1:e9:9c:f0:96 (capab=0x411 status=0 aid=1)
Feb  7 14:13:18 HP kernel: [  117.823995] wlan0: associated
Feb  7 14:13:18 HP kernel: [  117.824061] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
Feb  7 15:03:55 HP kernel: [   22.797706] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:04:00 HP kernel: [   28.544436] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:04:01 HP kernel: [   28.970856] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:04:02 HP kernel: [   30.131941] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:05:25 HP kernel: [  113.041220] wlan0: authenticate with a4:b1:e9:9c:f0:96
Feb  7 15:05:25 HP kernel: [  113.064676] wlan0: send auth to a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 15:05:25 HP kernel: [  113.067027] wlan0: authenticated
Feb  7 15:05:25 HP kernel: [  113.068181] wlan0: associate with a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 15:05:25 HP kernel: [  113.071494] wlan0: RX AssocResp from a4:b1:e9:9c:f0:96 (capab=0x411 status=0 aid=1)
Feb  7 15:05:25 HP kernel: [  113.071893] wlan0: associated
Feb  7 15:05:25 HP kernel: [  113.071925] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
Feb  7 15:38:07 HP kernel: [   21.369331] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:38:13 HP kernel: [   27.096353] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:38:13 HP kernel: [   27.177568] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:38:14 HP kernel: [   28.310506] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:40:39 HP kernel: [  172.965166] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:40:39 HP kernel: [  173.511667] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:41:02 HP kernel: [  195.942446] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:41:03 HP kernel: [  197.518776] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:41:04 HP kernel: [  197.806099] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:41:04 HP kernel: [  198.514786] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:41:34 HP kernel: [  228.533349] wlan0: authenticate with a4:b1:e9:9c:f0:96
Feb  7 15:41:34 HP kernel: [  228.556679] wlan0: send auth to a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 15:41:34 HP kernel: [  228.559227] wlan0: authenticated
Feb  7 15:41:34 HP kernel: [  228.560071] wlan0: associate with a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 15:41:34 HP kernel: [  228.563334] wlan0: RX AssocResp from a4:b1:e9:9c:f0:96 (capab=0x411 status=0 aid=1)
Feb  7 15:41:34 HP kernel: [  228.563767] wlan0: associated
Feb  7 15:41:34 HP kernel: [  228.563807] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
Feb  7 15:48:50 HP kernel: [  664.353899] wlan0: deauthenticating from a4:b1:e9:9c:f0:96 by local choice (Reason: 3=DEAUTH_LEAVING)
Feb  7 15:49:02 HP kernel: [  676.206188] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:49:38 HP kernel: [  712.508721] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:49:38 HP kernel: [  712.517050] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:49:39 HP kernel: [  713.469383] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:49:39 HP kernel: [  713.480442] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:49:39 HP kernel: [  713.517817] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:49:39 HP kernel: [  713.536570] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:49:40 HP kernel: [  714.510608] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:49:40 HP kernel: [  714.516118] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:50:26 HP kernel: [  760.585066] wlan0: authenticate with a4:b1:e9:9c:f0:96
Feb  7 15:50:27 HP kernel: [  760.608587] wlan0: send auth to a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 15:50:27 HP kernel: [  760.611016] wlan0: authenticated
Feb  7 15:50:27 HP kernel: [  760.612047] wlan0: associate with a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 15:50:27 HP kernel: [  760.615341] wlan0: RX AssocResp from a4:b1:e9:9c:f0:96 (capab=0x411 status=0 aid=1)
Feb  7 15:50:27 HP kernel: [  760.615782] wlan0: associated
Feb  7 15:50:27 HP kernel: [  760.615823] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
Feb  7 15:57:10 HP kernel: [   20.856551] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:57:16 HP kernel: [   26.592379] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:57:16 HP kernel: [   26.672656] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:57:17 HP kernel: [   27.805317] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:58:03 HP kernel: [   74.526900] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:58:04 HP kernel: [   75.229235] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:58:04 HP kernel: [   75.251292] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:58:04 HP kernel: [   75.265960] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:58:07 HP kernel: [   78.177975] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:58:07 HP kernel: [   78.509149] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:58:20 HP kernel: [   90.837966] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:58:21 HP kernel: [   92.520402] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:58:24 HP kernel: [   94.947817] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:58:25 HP kernel: [   96.510522] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:58:53 HP kernel: [  124.386939] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 15:59:05 HP kernel: [  135.653121] wlan0: authenticate with a4:b1:e9:9c:f0:96
Feb  7 15:59:05 HP kernel: [  135.676663] wlan0: send auth to a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 15:59:05 HP kernel: [  135.680144] wlan0: authenticated
Feb  7 15:59:05 HP kernel: [  135.684069] wlan0: associate with a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 15:59:05 HP kernel: [  135.687297] wlan0: RX AssocResp from a4:b1:e9:9c:f0:96 (capab=0x411 status=0 aid=1)
Feb  7 15:59:05 HP kernel: [  135.687698] wlan0: associated
Feb  7 15:59:05 HP kernel: [  135.687742] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
Feb  7 16:23:36 HP kernel: [   20.390421] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 16:23:42 HP kernel: [   26.116384] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 16:23:42 HP kernel: [   26.193417] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Feb  7 16:23:43 HP kernel: [   27.340317] wlan0: authenticate with a4:b1:e9:9c:f0:96
Feb  7 16:23:43 HP kernel: [   27.352602] wlan0: send auth to a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 16:23:43 HP kernel: [   27.361461] wlan0: authenticated
Feb  7 16:23:43 HP kernel: [   27.364150] wlan0: associate with a4:b1:e9:9c:f0:96 (try 1/3)
Feb  7 16:23:43 HP kernel: [   27.374449] wlan0: RX AssocResp from a4:b1:e9:9c:f0:96 (capab=0x411 status=0 aid=1)
Feb  7 16:23:43 HP kernel: [   27.374827] wlan0: associated
Feb  7 16:23:43 HP kernel: [   27.374864] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready

Edit 1: I tried this asnwer but it didnt work.
Edit 2: I collect a set of questions without answers with the same problem of mine:1 2 3 4 5 6

A: You need an internet connection:
Run the following command:
sudo apt-get remove --purge bcmwl-kernel-source

install build-essential and linux-headers
sudo apt-get update && apt-get install build-essential linux-headers-generic

install or reinstall wpa_supplicant
 sudo apt-get --reinstall install wpasupplicant

install b43 firmware
 sudo apt-get install firmware-b43-installer

and
 sudo apt-get --reinstall install bcmwl-kernel-source

load the driver
sudo modprobe b43

and
sudo ifdown wlan0
sudo ifup wlan0

You can reboot


text:
Q: create word search puzzle using jquery for non english characters I am trying to create a word search puzzle game using this
http://jsfiddle.net/sirmarcio/jtn0mchd/
this is the problem area
$(document).ready( function () {
    var words = "Raúl,María,heißt,TOUCH";
    $("#cuadricula").wordsearchwidget({"wordlist" : words,"gridsize" : 10});
});

i am not pasting whole code as it is available on JSfiddle, its not my code i am just using it for reference
and referring this
Placing words in table grid in word search puzzle?
as you can see i am trying few non english words, while words like
Raúl,María work properly
heißt

ends up as HEISST ,
does javascript and for that matter jquery support such words , and how can i use heißt as it is, any reference so that these words donot end up splitting the way they are.

A: The HTTP headers must indicate UTF-8, if you are using UTF-8.
This appears to be a problem with jsfiddle not recognizing that you have UTF-8 in your copy/paste snippet and then sending you the JS responses without the header.
Naturally, if you have problems with headers, you're not going to want to be testing it using third party vendors, definitely not jsfiddle, at least.


text:
Q: Can't Install NVIDIA drivers after W10 clean install I've upgraded my pc to Windows 10 from Windows 8 thru clean install since windows 8 doesn't have a direct upgrade path. After performing a clean install, obviously, drivers are also removed. I've tried to download NVIDIA drivers from their official site Here. But when I've tried to run the setup and install drivers Nvidia gives me this error:

NVIDIA Installer cannot continue. This NVIDIA graphics driver is not compatible with this version of Windows. Please update your driver using GeForce Experience to download the correct version.

I've also tried to install drivers thru GeForce Experience but it also gave me the same error

Installation can't continue: The NVIDIA graphics driver is not compatible with this version of Windows

Specs:
GeForce 630GT
Windows 10 64-Bit build 2004
Edit: Here is the driver I've downloaded

Manually downloaded:
-451.67-desktop-win10-64bit-international-dch-whql.exe

Downloaded by GeForce Experience:
-GeForce Game Ready Driver: Version 451.67 - Release date: 07/09/2020

EDIT: It seems that GT630 or Fermi Series GPUs has reached its EOL (End of Life) as of April 2018. Security updates is still available until January 2019.

Effective April 2018, Game Ready Driver upgrades, including performance enhancements, new features, and bug fixes, will be available only on Kepler, Maxwell, and Pascal series GPUs.  Critical security updates will be available on Fermi series GPUs through January 2019.

I guess the last version that is compatible will 397.31 WHQL which was released on April 2018.
More info here:
NVIDIACUSTHELP
NVIDIAFORUMS
NVIDIAFORUMS
ANANDTECH.COM

A: You can extract the drivers from the executable using a program like 7-ZIP (download here). Once installed, run 7-ZIP as an admin and navigate to the executable, right click, and select Open Inside.

On the next screen, you should see the contents of the EXE file. Right click on the folder named Display.Driver, select Copy to..., and put it on your desktop.

Next, go to your Device Manager > Display Adapters > double click the entry for the Graphics Card ("Microsoft Basic Display Adapter", most likely).
In the Properties window, Update Driver, select Browse my computer for drivers, and paste the path to the Display.Driver folder on your desktop and click Next.


text:
Q: Show that $S_n/n$ converges in probabilty but not almost surely - Borel Cantelli Let $X_n$ be independent random variables with the following distribution:
$$
P(X_n=\pm n)=\frac{1}{2(n+1)\log (n+1)}, \;\;\;\; P(X_n=0)=1-\frac{1}{(n+1)\log (n+1)}
$$
and let $S_n=\sum_{k=1}^n X_k$. Show that $\frac{S_n}{n}\to 0$ in probability but not almost surely.

I'm a bit doubtful on almost sure convergence part. This was what I thought:
set $A_n=\{X_n=n\}$, then clearly $A_n$ are independent events, and since
$$
\sum_{n=1}^{\infty} P(A_n)=\sum_{n=1}^{\infty} \frac{1}{2(n+1)\log (n+1)}=\infty
$$
By BC lemma $P(A_n \;\;\text{i.o.})=1$. But then we know
$$
\frac{S_n}{n}=\frac{X_n}{n}+\frac{S_{n-1}}{n} \implies \frac{S_n}{n}=1+\frac{S_{n-1}}{n-1}+\delta_n\; \text{infinitely often}
$$
where $\delta_n=S_{n-1}\left(\frac{1}{n}-\frac{1}{n-1}\right)\to 0$. So for all sufficiently large $n$, $S_n/n$ deviates from its previous value by approximately $1$ almost surely, so no convergence.
Couple of questions: Is my argument reasonably rigorous? Also, it seems that this sequence almost surely does not converge (to any limit, not just $0$) according to my reasoning. I'm also a bit curious about what $\limsup \frac{S_n}{n}$ would be - surely it would not be $0$, otherwise by symmetry we would have $\liminf=\limsup=0=\lim$.


text:
Q: Unit test "fail" method unable to find the reference to the test class I am using python unittest to test a web app using selenium. In my teardownClass, I am calling cls.fail but it returns "AttributeError" saying that "failureException" not found in the "string".
Here is what my teardownClass method looks like:

    @classmethod
    def tearDownClass(cls):
        browser_logs = cls.driver.get_log("browser")
        errors = [log_entry['message'] for log_entry in browser_logs if logentry['level'] == 'SEVERE']
        if errors:
            cls.fail(errors)

this returns the following attributeError:
======================================================================
ERROR: tearDownClass (__main__.unitTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/shahrukh/Desktop/apollotest/test_users.py", line 239, in tearDownClass
    cls.fail("error")
  File "/usr/lib/python3.6/unittest/case.py", line 670, in fail
    raise self.failureException(msg)
AttributeError: 'str' object has no attribute 'failureException'

----------------------------------------------------------------------

"fail" method from /usr/lib/python3.6/unittest/case.py file:
    def fail(self, msg=None):
        """Fail immediately, with the given message."""
        raise self.failureException(msg)

This method is part of "Testcase" class
The problem is that fail method above does not find the reference to self. "errors" in my code is a string object. So when I call cls.fail(errors) it considers self=errors and msg remains None.
I don't get this problem if I change my code statement to cls.fail(cls, errors).
I want to understand why am I experiencing this behavior? Am I missing anything because according to my understanding cls.fail should mean that self in fail method is equal to cls.
Would really appreciate some help.


text:
Q: Query search, how to pass params from check_box form as a row sql? Hi I have a controller function, based on a check_box_form ( so there can by one or more value passed), like this:
def show_spells
    #there are 3 params 'elemensts', 'levels', and 'tags'
    if params[:tags].blank?
      @chosen_spells = Spell.where(element: params[:elements], level: params[:levels] ).to_a
    else
      @chosen_spells = Spell.where( "element = ? and level = ? and tags = ARRAY[?]", params[:elements], params[:levels], params[:tags]).to_a
    end
  end

And it references to a object table:
class CreateSpells < ActiveRecord::Migration
  def change
    create_table :spells do |t|
      t.string :element
      t.string :level
      t.string :desc
      t.text :tags, array: true, default: []

      t.timestamps null: false
    end
  end
end

The firs query works perfect, but the second one is making a problem, when I pass just one value to elements and levels it doesn't show any resoults, and when I pass more then one walue to elements or levels it show me an error: PG::InvalidTextRepresentation: ERROR: invalid input syntax for type boolean
I`m new to SQL query searches, but from what I understand, from Active Record Query Guide :
Object.where(attr: params[:foo]) should be equal to Object.where("attr = ?", params[:foo]). And it seems like it isn`t. Any help would be appreciated. :)

A: There are a few different issues here that you're running into. However, I believe all of them are related to bad query syntax. ActiveRecord's query interface is very powerful, but without proper usage, it can throw crazy errors that are hard to debug. A good understanding of SQL will help you navigate it better.
First, regarding "pass[ing] more then one value to elements or levels": the = operator in Postgres can only compare against a single value, and Rails' parameter binding is very simplistic. When you run this code:
Object.where("attr = ?", [1, 2, 3])

Rails is going to run a query like:
SELECT * FROM objects WHERE attr = 1, 2, 3;

Which is invalid SQL -- but Rails doesn't know that, so you get a PGError. The proper SQL syntax is:
SELECT * FROM objects WHERE attr IN (1, 2, 3);

And to get that, the best way is to use where's hash syntax:
Object.where(attr: [1, 2, 3])

Second, for an array type, the operation you're looking for to test inclusion, but Rails only knows to test for equality. You have no choice but to just use interpolated params for this, like you're doing, but your syntax is off. The SQL needs to be something like:
SELECT * FROM objects WHERE some_array_field @> ARRAY['foo', 'bar'];

To get that, .where("some_array_field @> ARRAY[?]", things) is your best bet.
In conclusion, your code could be written like this:
@chosen_spells = Spell.where(element: params[:elements],
                             level:   params[:levels])
                      .where('tags @> ARRAY[?]', params[:tags])

And it should work as desired.


text:
Q: KendoUI Grid button in column I have a KendoUI Grid in my MVC.

And here's the code for it.
@(Html.Kendo().Grid<TekstenViewModel.Tekst>()
      .Name("Grid")
      .Columns(columns =>
      {
          columns.Bound(product => product.Naam).Width(100);
          columns.Bound(product => product.Waarde).Width(100);
          columns.Bound(product => product.Opmerking).Width(250);
          columns.Template(@<text></text>).ClientTemplate("").Title("").Width(50);

      })
          .ToolBar(toolbar =>
          {
              toolbar.Create();
              toolbar.Save();
          })
    .Pageable()
    .Sortable()
    .Filterable()
    .Groupable()
    .Navigatable()
    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Batch(true)
        .Model(model =>
            {
                model.Id(product => product.ID);
                model.Field(product => product.RESOURCE_SET_ID).DefaultValue(Model.SetID);
                model.Field(product => product.Type).DefaultValue(Domain.Agromilieu2.Common.Objects.Entities.Resources.ResourceType.GLOBAL_RESOURCES);
                model.Field(product => product.Taal).DefaultValue(Domain.Agromilieu2.Common.Agromilieu2Constants.Resources.DEFAULT_TAAL_CODE);
            })
            .Create(create => create.Action(MVC.BeheerTeksten.ActionNames.ResourceItems_CreateUpdate, MVC.BeheerTeksten.Name))
            .Read(read => read.Action(MVC.BeheerTeksten.ActionNames.ResourceItems_Read, MVC.BeheerTeksten.Name, new { setID = Model.SetID }))
            .Update(update => update.Action(MVC.BeheerTeksten.ActionNames.ResourceItems_CreateUpdate, MVC.BeheerTeksten.Name))
            .Destroy(destroy => destroy.Action(MVC.BeheerTeksten.ActionNames.ResourceItems_Delete, MVC.BeheerTeksten.Name))
    )
    )

Now I need to change it into this.

And without success so far. Everytime I try to put text and a button in a column, the text disappears. Any ideas??


text:
Q: PHP Date not sticking I'm having a hard time getting dates to stick in variables. When I when I'm tyring to subtract months from a current date it is giving me 0 back (defaulting back to 1-1-1970).
Any thoughts on what I could be doing wrong?
PHP:
$progress = 5;
$initialDate = date('m-d-Y');
echo "ini date: " . date('m-01-Y',$initialDate) . "
";
$date = date('m-01-Y', strtotime("-$progress months", strtotime(date('m-d-Y',$initialDate))));
echo "date: " . $date . "
";

output:
ini date: 12-01-2014
date: 08-01-1969

A: The 2nd argument to date() must be in internal Timestamp format, i.e. "number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)".
strtotime() is really intended to convert a user input into internal date format. If you want to do math with dates, it is better to use a more precise method. I would suggest reading up on date_add() here: http://php.net/manual/en/datetime.add.php
However, the simplest fix to your code is this:
    $progress = 5;
    $initialDate = time();  // current timestamp, including seconds
    echo "initialDate: $initialDate
";
    echo "ini date: " . date('m-01-Y',$initialDate) . "
";
    $date = date('m-d-Y', strtotime("-$progress months", strtotime(date('Y-01-d',$initialDate))));
    echo "date: " . $date . "
";

Note that I used Y-01-d format for the date fed to strtotime, to go back to the 1st of the month before doing the date math, for two reasons:

*

*Y-m-d format has no danger of being interpreted incorrectly by strtotime, unlike m/d/y and d/m/y.

*If you are going back 5 months from Jul 30 to Feb 1, it is safer to have Jul 1 as the intermediate step, not Feb 28. "Safer" meaning you don't even need to test if strtotime handles Feb 28 properly.

A: You can do this using the DateTime object as well. I find it a little more reliable myself. You basically just initiate a DateTime object and then use its ::sub function to subtract a DateInterval in the amount of $progress months.
 $progress = 5;
 $initialDate = new DateTime(date("Y-m-01"));
 echo "ini date: ".$initialDate->format("m-01-Y")."
";
 $date = $initialDate->sub(new DateInterval("P".$progress."M"));
 echo "date: ".$date->format("m-01-Y")."
";

Output:
 ini date: 12-01-2014
 date: 07-01-2014


text:
Q: Best way to tell if in production or development environment in .NET I would like to send email differently on production then the development environment, such as sending emails only to me while testing. I know that I can set an application value in the webconfig file or check the url before sending the emails. I would like to know what is the best practice for doing this or if there is some other option that I don't know about that might be better? Any information on this topic would be greatly appreciated.

A: If you want to only send the email to yourself if it's not Production then do it by changing the email address on the "To" field.
So either change it in the database or config file, wherever you put that value.
The way the application determines if you are in the development server is with the "ASPNETCORE_ENVIRONMENT".
You can check this link, Use multiple environments in ASP.NET Core

A: Well, only you can determine what's production and what's development, so a flag in web.config is ok, but a more elegant solution would involve a pattern like Dependency Injection (DI) ala Spring.Net, StructureMap, and Castle Windsor to name a few.
The key concept behind DI is decoupling/isolating variations in an implementation by dynamically providing information about what class to instantiate at runtime.  In this case, for instance, all your code would be written to deal with a 'mail' interface (oblivious to whether it's prod or dev environment) and you'd configure your DI framework to instantiate either the production or the development version of a mail implementation class.  It's a bit cleaner in that you're not exposing and proliferating config parameter values.
There's certainly a learning curve there though, so it may not be viable at this stage of your project, but definitely something to keep in mind.

A: You can use web config inheritance of IIS to allow your app to 'inherit' global context settings from the respective environment into which it is deployed.
In a parent directory of where your .NET app is installed (e.g. /inetpub/wwwroot.web.config, or even the root web.config ( \Windows\Microsoft.NET\Framework\ver\web.config), add your environment specific settings, e.g.
In PROD
  <appSettings>
    <add key="sendMailTo" value="" />
    <add key="environmentName" value="PROD" />
  </appSettings>

In DEV
  <appSettings>
    <add key="sendMailTo" value="me@mydomain.com" />
    <add key="environmentName" value="DEV" />
  </appSettings>

These environment context settings aren't deployed everytime you redeploy your app. Also, all other apps you deploy to your servers can also inherit these settings.

A: I use what's called Preprocessor Directives (in C#). In VB it's called Directives only.
I have a helper method like this:
public static bool IsDebug()
{
    #if DEBUG
        return true;
    #else
        return false;
    #endif
}

Then anywhere in the code one can call this method and during runtime and it'll tell if the code is being run in Debug ( development ) or if it's the Release version ( production ).
Here's the equivalent #If...Then...#Else Directives in (VB).

A: Instead of changing your code, why don't you set your development mail server to only mail to you regardless of the TO address field?
Seems better than writing code to do that.


text:
Q: Regular curve which normal lines pass through a fixed point not given How can I prove that if a regular parametrized curve which all its normal lines pass through a fixed point then its trace is a circle?
I know that for that I need to prove that the distance from the curve and that point must be constant for all s in I, but I'm stuck with trying to prove it. May I get some help?


text:
Q: Dry Ice in Liquid States If I melt the dry ice in a pool.
I am thinking that Can I have bath without getting wet by melted dry ice?

A:
Are you ready to jump into a pool with pressure of about $50\times 10^5pa$ ??

Yes, $P_c$, critical pressure of carbon-di-oxide is about $5.1\  atm$, that too at about  $-50^0 C$. So, a pool with liquid $CO_2$ will never be opened for a bath!
Also at room temperature this will go above $50atm!!$

This would happen if you try turning it into liquid.
Also If we consider your question as :Will liquid $CO_2$ wet any surface? Then answer would be probably yes.That is probably visible in vedio as well. Liquid $CO_2$ has a low surface tension.


text:
Q: Convert string byte array to Double I have a String representation of Byte array recieved from a server, which looks like this.
"?Ëê%ÁS`?ãù/ŒPü?ÛlÅç`ÔÀ?èï0;D^?ÙÄjh#í´"

these are array of double values.
At the client side, client is android phone i'm not able to get the proper values. The proper double values are :
0.21534, 0.617642, 0.428514, 0.779198 and 0.402613.

How to do it?

A: You can convert byte array from double by below code...
import java.nio.ByteBuffer;

public static byte[] toByteArray(double value) {
   byte[] bytes = new byte[8];
   ByteBuffer.wrap(bytes).putDouble(value);
   return bytes;
}

& double form byte array by below code...
public static double toDouble(byte[] bytes) {
   return ByteBuffer.wrap(bytes).getDouble();
}

Hope it will help you...

A: Lets say you have:
String s="?Ëê%ÁS`?ãù/ŒPü?ÛlÅç`ÔÀ?èï0;D^?ÙÄjh#í´";
Double d;

Convert it by:
d = new Double(s);


text:
Q: Postgres notifications across a vpn I'm trying to get postgresql notifications to work across an openvpn connection and am not having much luck.
I have a simple nodjs listener written
const pg = require('pg');

require('dotenv').config();

// declare variable to hold database connection
let pgClient;

pgClient = new pg.Client(process.env.POSTGRES_CONNECTION_URL);
console.log("Made connection");

pgClient.connect()
console.log('Got client');
const query = pgClient.query('LISTEN message');
pgClient.on('notification', async (data) => {
    const payload = JSON.parse(data.payload);
    console.log('row added', payload);
});

which, when run on the database server itself, works fine.
However, when I run this on a client connected via a vpn, I sometimes get one notification and then nothing else, or no notifications at all seem to make it through.
I could use socket.io or some other mechanism to push this data to the second client, but I can't for the life of me work out why this wouldn't work over openvpn (connecting to the db itself via psql works fine).
Any ideas? Should this work, or do I need to find another way


text:
Q: Npm: Cannot find module '../lib/utils/unsupported.js' on UBUNTU I am getting below error while using npm install
module.js:549
    throw err;
    ^

Error: Cannot find module '../lib/utils/unsupported.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at /usr/sbin/npm:19:21
    at Object.<anonymous> (/usr/sbin/npm:155:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)

Please help.

A: Looks like you are using relative path while using npm
Do :
which npm -a

It should give an output like /usr/bin/npm
Then use absolute path for npm and that is /usr/bin/npm
It should work.