text:
Q: WPF: Cannot scroll in DataGrids I have an application where I manage a tournament. The view which I have a scrolling issue looks like that: Group Phase View Screenshot
Now I have the problem that I cannot scroll when the mouse is over the DataGrid. As soon as I try to scroll for example on the Expander - it works (but as soon as the mouse then gets over a DataGrid again, the scrolling stops). Also the ScrollViewer itself works as expected, for example when I am trying to scroll with the scrollbar itself.
The view is build as following...
I have a GroupPhaseView that looks like that (this view contains the ScrollViewer):
<UserControl x:Class="TournamentApplication.UI.Tournament.GroupPhase.GroupPhaseView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:groupPhase="clr-namespace:TournamentApplication.UI.Tournament.GroupPhase"
         mc:Ignorable="d"
         d:DesignHeight="450" d:DesignWidth="800">
<Grid>
    <ScrollViewer VerticalScrollBarVisibility="Auto">
        <ItemsControl ItemsSource="{Binding GroupPhaseCategoryViewModels}">
            <ItemsControl.ItemTemplate>
                <DataTemplate DataType="groupPhase:GroupPhaseCategoryViewModel">
                    <groupPhase:GroupPhaseCategoryView />
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </ScrollViewer>
</Grid>

This GroupPhaseView contains multiple GroupPhaseCategoryView's. One GroupPhaseCategoryView looks like that:
<UserControl x:Class="TournamentApplication.UI.Tournament.GroupPhase.GroupPhaseCategoryView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:groupPhase="clr-namespace:TournamentApplication.UI.Tournament.GroupPhase"
         mc:Ignorable="d"
         d:DesignHeight="450" d:DesignWidth="800">
<Grid>
    <Expander Header="{Binding Category.Name}" IsExpanded="True">
        <ItemsControl ItemsSource="{Binding GroupPhaseGroupViewModels}">
            <ItemsControl.ItemTemplate>
                <DataTemplate DataType="groupPhase:GroupPhaseGroupViewModel">
                    <groupPhase:GroupPhaseGroupView />
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </Expander>
</Grid>

This GroupPhaseCategoryView contains multiple GroupPhaseGroupView's. They contain two DataGrid which are leading to the scrolling issue:
<UserControl x:Class="TournamentApplication.UI.Tournament.GroupPhase.GroupPhaseGroupView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         mc:Ignorable="d"
         d:DesignHeight="450" d:DesignWidth="800">
<Grid>
    <GroupBox Header="{Binding Group.Name}" ScrollViewer.CanContentScroll="True">
        <Grid ScrollViewer.CanContentScroll="True">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>
            <DataGrid ScrollViewer.CanContentScroll="True" Grid.Row="0" Margin="0,10,0,30" ItemsSource="{Binding GroupGames}" AutoGenerateColumns="False" >
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Zeit" Binding="{Binding StartTime, StringFormat=HH:mm}" IsReadOnly="True"/>
                    <DataGridTextColumn Header="Platz" Binding="{Binding GameFieldName}" IsReadOnly="True"/>
                    <DataGridTextColumn Header="Heim-Team" Binding="{Binding Team1Name}" IsReadOnly="True"/>
                    <DataGridTextColumn Header="Gast-Team" Binding="{Binding Team2Name}" IsReadOnly="True"/>
                    <DataGridTextColumn Header="Heim-Tore" Binding="{Binding GoalsTeam1, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" IsReadOnly="False">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="HorizontalAlignment" Value="Center" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Gast-Tore" Binding="{Binding GoalsTeam2, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" IsReadOnly="False">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="HorizontalAlignment" Value="Center" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>
            <DataGrid Grid.Row="1" ItemsSource="{Binding GroupTeams}" AutoGenerateColumns="False">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Team" Binding="{Binding Team.Name}" IsReadOnly="True"/>
                    <DataGridTextColumn Header="Spiele" Binding="{Binding PlayedGames.Count}" IsReadOnly="True">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="HorizontalAlignment" Value="Center" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Niederlagen" Binding="{Binding LostGamesCount}" IsReadOnly="True">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="HorizontalAlignment" Value="Center" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Unentschieden" Binding="{Binding DrawGamesCount}" IsReadOnly="True">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="HorizontalAlignment" Value="Center" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Siege" Binding="{Binding WonGamesCount}" IsReadOnly="True">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="HorizontalAlignment" Value="Center" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Tore" Binding="{Binding Goals}" IsReadOnly="True">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="HorizontalAlignment" Value="Center" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Differenz" Binding="{Binding GoalDifference}" IsReadOnly="True">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="HorizontalAlignment" Value="Center" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Punkte" Binding="{Binding Points}" IsReadOnly="True">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="HorizontalAlignment" Value="Center" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>
        </Grid>
    </GroupBox>
</Grid>

As you see I tried to set the ScrollViewer.CanContentScroll = "true" property in multiple controls to achieve the expected result - but unfortunately without any success...

A: Your scroll event is handled by the DataGrid, and can thus never reach the ScrollViewer while you are scrolling on the DataGrid. To solve this, tell the data grid to hand over the event to the parent (see here for a similar question):
Subscribe to PreviewMouseWheel on the DataGrid
            <DataGrid PreviewMouseWheel="UIElement_OnPreviewMouseWheel" ScrollViewer.CanContentScroll="True" Grid.Row="0" Margin="40"
                      ItemsSource="{Binding GroupGames}" AutoGenerateColumns="False">

...and in the callback hand the event to the parent:
    private void UIElement_OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
    {
        if (!e.Handled)
        {
            e.Handled = true;
            var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
            eventArg.RoutedEvent = MouseWheelEvent;
            eventArg.Source = sender;
            var parent = ((Control)sender).Parent as UIElement;
            parent?.RaiseEvent(eventArg);
        }
    }


text:
Q: Spring boot javabean that could not be found I have POJO classes which are for 90% accessed using services and repositories, but in those 10% cases I want a service to have a attribute of a POJO and in those cases the autowiring fails.
At runtime I get "Parameter 0 of constructor in com.ripple.trading.impl.Trader required a bean of type 'com.ripple.repositories.pojo.Wallet' that could not be found." This is the Trader class:
  @Service
public class Trader implements ITrade {
    private Wallet wallet;
    private List<Quantity> balance;
    private Advice latestAdvice;

@Autowired
private OrderService orderService;
@Autowired
private HistoryService historyService;
@Autowired
private CurrencyService currencyService;

private Advice lastAdvice;

public Trader(Wallet wallet, Advice advice){
    this.lastAdvice = Advice.HOLD;
    this.wallet = wallet;
    this.balance = WalletFetcher.getWalletByAddress(this.wallet.getAddress());
    this.latestAdvice = advice;
}
}

This is the wallet
@Document
public class Wallet extends BaseModel implements Serializable{

private String address;
private String encryptedSecret;
private String name;

/**
 * Instantiates a new Wallet.
 *
 * @param address         the address
 * @param encryptedSecret the encrypted secret
 */
@PersistenceConstructor
public Wallet(String address, String encryptedSecret, String name) {
    this.address = address;
    this.encryptedSecret = encryptedSecret;
    this.name = name;
}

/**
 * Gets address.
 *
 * @return the address
 */
public String getAddress() {
    return address;
}

/**
 * Sets address.
 *
 * @param address the address
 */
public void setAddress(String address) {
    this.address = address;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

/**
 * Gets encrypted secret.
 *
 * @return the encrypted secret
 */
public String getEncryptedSecret() {
    return encryptedSecret;
}

/**
 * Sets encrypted secret.
 *
 * @param encryptedSecret the encrypted secret
 */
public void setEncryptedSecret(String encryptedSecret) {
    this.encryptedSecret = encryptedSecret;
}
}

And this is my main application
@EnableOAuth2Sso
@ComponentScan
@EnableMongoRepositories(value = "com.ripple.repositories.mongo")
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
public class RippleSpringApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(RippleSpringApplication.class);
}

/**
 * The entry point of application.
 *
 * @param args the input arguments
 */
public static void main(String[] args) {
    SpringApplication.run(RippleSpringApplication.class, args);
}
}

My guess is the autowiring, maybe break the application down in smaller pieces until it works again. It's an issue that previously had occurred and refactoring fixed it, but the reason behind it, why did it fixed it, was it the right solution. That's what I'm after now.
My applicationclass is in the root package so ComponentScan shouldn't be the problem.

A: Your wallet class is not managed by Spring, it's not @Component that enables to be picked up via Component Scanning, it's not defined as a @Bean in your configuration.
Additionally the Wallet class is stateful, and realistically you should not be having spring manage this class but passing it as a parameter to required Beans.

A: Class Wallet is not a Spring configured bean. It's just a class (a spring-data-mongodb document).
If your Spring component has a single constructor, Spring automatically considers this constructor for autowiring and will look for beans matching the constructor argument types to provide when calling that constructor.
That is why you're receiving that error.
If you want Trader to be a "service" consider not making Wallet and Advice it's fields because that essentially introduces state into what should be stateless. If you have methods in Trader that do something with the Wallet and Advice consider passing those as parameters to those methods. Something like:
@Service
public class Trader {
  /// ... your autowired dependecies

  public BigDecimal getBalance(Wallet wallet) {
    return WalletFetcher.getWalletByAddress(wallet.getAddress());
  }
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: I installed Ubuntu alongside Windows but I can't see it in Windows' boot menu I have a second machine where Ubuntu 12.04 LTS and Debian Squeeze are installed on the same HD and when I boot, I have this grub menu where I can choose which partition I will used. It works perfectly! But in my Windows environment that's another story.
Now after making almost everything that I know, to make it work along Windows 7, there is no entry in the boot menu of Windows (I know, Ubuntu use grub but anyway there is surely a way to fix it, access it?). Why there is no Ubuntu entry? Why the installation gave me no error while I have this strange situation of having a "ghost OS" called Ubuntu installed somewhere in my second HD in a partition made especially for it and not being able to access it, starting it, having it working?
Am I wrong? If I am, what's the problem? If I'm not, what's the need of Wubi?

A: Are you getting the boot menu at all? Or is ir going straight to 7?
If it is, your going to have to modify the bootloader time with msconfig:

*

*Open Start

*type "msconfig"

*Go to the tab "Boot"

*Verify that there is a Ubuntu entry in the list.

*if there is, Look for a option near the right-bottom called "Timeout".

*If it is 0, set it to about 10 seconds.

*Restart PC

*Look for the ubuntu option, then move the arrow keys at the boot menu to it, then press enter.

*Ubuntu should load.

Try and follow these steps, and it should work.

A: Your solution is very good, i tried it but unfortunatly i do not have any Ubuntu entries in the boot tab of my msconfig. Somehow, in my bios (or cmos) option, i have a boot option when i start my pc (before having the windows menu) and i can press F## to enter what it is called "boot option menu" and it lead me to my HD, and also to my usb drives. So i select my second HD, and i had the proper menu of Ubuntu including Windows, where now i can select Ubuntu and starting it properly.

A: I believe you can chainload the GRUB bootloader with EasyBCD, try finding a option that says chainload, or make a Linux Entry that points to your second HD.

A: Run a Live Session of Ubuntu (from cd or usb). Once loged in, install the program called "boot repair" (check https://help.ubuntu.com/community/Boot-Repair).
Run the program, it will install Grub, and fix everything for you


text:
Q: phpinfo() file instead of sites index phpinfo() file showing instead of all sites index, after server software upgrade. (example site on this server: sms4.pro)
There are many websites in this server, and ALL websites have this phpinfo instead of thier index..
Websites files is exists, FTP is accessible, databases/phpmyadmin is OK, but for unknown reasons displayed phpinfo instead of sites content.
I have already tried a variety of solutions, but still can not find a way how to fix it.
Maybe you have encountered a similar problem? Please help ..
My server is apache, debian 8, PHP Version 5.6.30-0+deb8u1

A: Check your web root folder, i.e. /var/www in most cases, and check all files that are named index.* where * is any file extension. From the looks of it one of these files is calling phpinfo() and it is being used as your index file. Either modify this file to reflect what you want the index page to be or remove it if it is overriding another index file. You can also specify what you want your index file to be by modifying the Apache config file's DirectoryIndex directive. More info here: http://httpd.apache.org/docs/2.0/mod/mod_dir.html#directoryindex

A: If you've just done an update and this happened it is possible that your Apache configurations have been lost (or moved) and all requests to the server, regardless of which domain it comes from, is just being served what is in the /var/www/ folder (which might be a file with just phpinfo(); in it).
Depending on which version of Apache you've updated from, you might need to change the extension of the files in /etc/apache2/sites-enabled/ (which are what point to the configurations for the different websites running on the server) to end in .conf


text:
Q: How do I explicitly set which port my TCP client is listening on? Say I have a server and client similar to the code below which is taken from here: https://wiki.python.org/moin/TcpCommunication#Client
Server:
   1 #!/usr/bin/env python

   3 import socket
   4
   5
   6 TCP_IP = '127.0.0.1'
   7 TCP_PORT = 5005
   8 BUFFER_SIZE = 20  # Normally 1024, but we want fast response
   9
  10 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  11 s.bind((TCP_IP, TCP_PORT))
  12 s.listen(1)
  13
  14 conn, addr = s.accept()
  15 print 'Connection address:', addr
  16 while 1:
  17     data = conn.recv(BUFFER_SIZE)
  18     if not data: break
  19     print "received data:", data
  20     conn.send(data)  # echo
  21 conn.close()

Client:
   1 #!/usr/bin/env python
   2
   3 import socket
   4
   5
   6 TCP_IP = '127.0.0.1'
   7 TCP_PORT = 5005
   8 BUFFER_SIZE = 1024
   9 MESSAGE = "Hello, World!"
  10
  11 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  12 s.connect((TCP_IP, TCP_PORT))
  13 s.send(MESSAGE)
  14 data = s.recv(BUFFER_SIZE)
  15 s.close()
  16
  17 print "received data:", data

Seems to me when the client connects to the server it is assigned a somewhat random port that it will listen on for responses.
My question is how do I explicitly set which port my client will listen for a responses on and communicate that to the server?
I want to receive msg's from my server to my client which should be listening on port 5023 for example rather than some randomly assigned port.

A: This question could should be marked as duplicate. The original answer is here:
Python socket-module: How to change the local port on the client side?
Basically before the client calls the connect() they have the option to
bind((HOST, PORT)

Where HOST is the ip address of the client and PORT is the port the client would like to listen on.

A: #!/usr/bin/env python

import socket

TCP_IP = '127.0.0.1'
TCP_PORT = 5005
BUFFER_SIZE = 1024
MESSAGE = "Hello, World!"

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('',5023))
s.connect((TCP_IP, TCP_PORT))
s.send(MESSAGE)
data = s.recv(BUFFER_SIZE)
s.close()

print("received data:", data)

Use bind after you create the socket. Just tested this on Py3, it looks to me you're on Py2.7 but it should work the same.

A: I think your client listens to the TCP_PORT as you set in s.connect; and your server listens on the TCP_PORT you set in s.bind


text:
Q: Is there a way to open Microsoft Map on Windows 10 from browser javascript I'm working on an app which will contain an address.  The user can click or tap on the address, on an android device, the following web page code runs which opens Google Navigation with the destination address and ready for turn by turn.
Here is the code:
 window.open("google.navigation:q=lat,lon", '_system');
I'm trying to do this on for other devices such as a window 10 surface with the Here Windows Maps installed?
I run the code above on a Surface and you get a prompt that says you need to find a app in the store to open google.navigation so I'm thinking it could possibly be done.
Does anybody know if this is possible?  Next will trying to figure out how to open up navigation on an Apple tablet or phone if anybody has any pointers for that platform.
Thanks

A: After posting this, I stumbled across a link that showed some launch commands.
The below is working.  A user is prompted to open an application which is understandable but it does open Windows maps to navigation and calculates the route.
Still looking for a way to do this on idevices.
function GetMobileOperatingSystem() {
var userAgent = navigator.userAgent || navigator.vendor || window.opera;

if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i) || userAgent.match(/iPod/i)) {

    return 'iOS';

}
else if (userAgent.match(/Android/i)) {

    return 'Android';
}
else if(userAgent.match(/Windows Phone/i))
{
    return 'Windows Phone';
}
else if (userAgent.match(/Windows NT/i) && userAgent.match(/Tablet PC/i)) {
    return 'Windows Tablet';
}
else if (userAgent.match(/Windows NT/i)) {
    return 'Windows Desktop';
}
else {
    return 'unknown';
}
}

function OpenNavigation(lat, lon) {
    // If Android device, open coordinates for google navigation
    if (GetMobileOperatingSystem() === 'Android') {
        // window.open("google.navigation:q=35.208707,-80.830739", '_system');
        window.open("google.navigation:q=lat,lon", '_system');
    }
    else if(GetMobileOperatingSystem().match(/Windows/i))
    {
        // window.open("http://maps.google.com/maps?daddr=" + lat + "," + lon);
        window.open("ms-drive-to:?destination.latitude=" + lat + "&destination.longitude=" + lon);
    }

}


text:
Q: Difficulty with listing function Write a function named "counting" that takes a list of numbers as a parameter and returns the number of values in the input that are between 29.88 and 48.05 not including these end points. (My code below)
def counting(number):
    sum = 0
    for x in number:
        if (29.88 < x < 48.05):
            sum = sum + x
        return sum

How do I return the number of values in the input instead of the first number of an input?

A: your return statement is indented too deep; you should return it after the for loop. also sum is not a good name as it is a built-in function that you overwrite.
and you should add 1 to the sum (you are counting) and not x itself.
you could also try this using the built-in function sum:
def counting(number):
    return sum(29.88 < x < 48.05 for x in number)

(this is actually short for sum(1 for x in number if 29.88 < x < 48.05) and works because True is basically 1 and False is basically 0).

A: Or to be similar to yours:
def counting(number):
    c = 0
    for x in number:
        if 29.88 < x < 48.05:
            c += 1
    return c

Or can do one-liner, len:
def counting(number):
    return len([29.88 < x < 48.05 for x in number])

A: You could also use filter() on your list to keep only elements that the given function evaluates to true.
def counting(number):
    return len(list(filter(lambda x: 29.88 < x < 48.05, number)))


text:
Q: Custom Taxonomies not appearing in Admin I've made a plugin of a custom content type and taxonomy. The CPT is showing fine, but the Taxonomies are not. There's a lot of code, but the taxonomy information is parsed below:
Full code can be found here on github
    <?php

function check_exhibition_type_tax() {
        $labels = array(
            'name'                  => _x( 'Exhibition Types', 'taxonomy general name' ),
            'singular_name'         => _x( 'Exhibition Type', 'taxonomy singular name' ),
            'add_new'               => _x( 'Add New Exhibition Type', 'Exhibition Type'),
            'add_new_item'          => __( 'Add New Exhibition Type' ),
            'edit_item'             => __( 'Edit Exhibition Type' ),
            'new_item'              => __( 'New Exhibition Type' ),
            'view_item'             => __( 'View Exhibition Type' ),
            'search_items'          => __( 'Search Exhibition Types' ),
            'not_found'             => __( 'No Exhibition Type found' ),
            'not_found_in_trash'    => __( 'No Exhibition Type found in Trash' ),
        );

        $pages = array('ksasexhibits');

        $args = array(
            'labels'            => $labels,
            'singular_label'    => __('Exhibiton Type'),
            'public'            => true,
            'show_ui'           => true,
            'hierarchical'      => true,
            'show_tagcloud'     => false,
            'show_in_nav_menus' => false,
            'rewrite'           => array('slug' => 'exhibiton', 'with_front' => false ),
         );
        register_taxonomy('exhibition_type', $pages, $args);
}

    add_action('init', 'register_exhibition_type_tax');

function check_exhibition_type_terms(){

    //see if we already have populated any terms
    $term = get_terms ('exhibition_type', array( 'hide_empty' => false ) );

    //if no terms then lets add our terms
      if( empty( $term ) ){
        $terms = define_exhibition_type_terms();
        foreach( $terms as $term ){
            if( !term_exists( $term['name'], 'exhibition_type' ) ){
                wp_insert_term( $term['name'], 'exhibition_type', array( 'slug' => $term['slug'] ) );
            }
        }
    }

}

add_action ( 'init', 'check_exhibition_type_terms' );

function define_exhibiton_type_terms(){

$terms = array(
        '0' => array( 'name' => 'Campus Partnerships','slug' => 'campus'),
        '1' => array( 'name' => 'Community Partnerships','slug' => 'community'),
        '2' => array( 'name' => 'Independent Study','slug' => 'independent'),
        '3' => array( 'name' => 'Digital Work.','slug' => 'digital'),
        '4' => array( 'name' => 'Mellon Foundation','slug' => 'mellon'),
    );

    return $terms;
}

add_filter( 'manage_edit-ksasexhibits_columns', 'my_ksasexhibits_columns' ) ;

function my_ksasexhibits_columns( $columns ) {

    $columns = array(
        'cb' => '<input type="checkbox" />',
        'title' => __( 'Name' ),
        'exhibitons' => __( 'Exhibiton Type' ),
        'date' => __( 'Date' ),
    );

    return $columns;
}

add_action( 'manage_studyfields_posts_custom_column', 'my_manage_ksasexhibits_columns', 10, 2 );

function my_manage_program_columns( $column, $post_id ) {
    global $post;

    switch( $column ) {

        /* If displaying the 'program_type' column. */

        case 'exhibitons' :

            /* Get the program_types for the post. */
            $terms = get_the_terms( $post_id, 'exhibition_type' );

            /* If terms were found. */
            if ( !empty( $terms ) ) {

                $out = array();

                /* Loop through each term, linking to the 'edit posts' page for the specific term. */
                foreach ( $terms as $term ) {
                    $out[] = sprintf( '%s',
                        esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'exhibiton_type' => $term->slug ), 'edit.php' ) ),
                        esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'exhibiton_type', 'display' ) )
                    );
                }

                /* Join the terms, separating them with a comma. */
                echo join( ', ', $out );
            }

            /* If no terms were found, output a default message. */
            else {
                _e( 'No Exhibitons Assigned' );
            }

            break;
        /* Just break out of the switch statement for everything else. */
        default :
            break;
    }
}

?>

A: There seemed to be an issue with the way you registered the taxonomy.
I prefer to register the taxonomy first, before registering the post type.

I submitted a pull request but here ya go:
<?php

// hook into the init action and call create_book_taxonomies when it fires
add_action( 'init', 'create_ksasexhibits_taxonomies', 0 );

// create two taxonomies, genres and writers for the post type "book"
function create_ksasexhibits_taxonomies() {
    // Add new taxonomy, make it hierarchical (like categories)
    $labels = array(
            'name'                  => _x( 'Exhibition Types', 'taxonomy general name' ),
            'singular_name'         => _x( 'Exhibition Type', 'taxonomy singular name' ),
            'add_new'               => _x( 'Add New Exhibition Type', 'Exhibition Type'),
            'add_new_item'          => __( 'Add New Exhibition Type' ),
            'edit_item'             => __( 'Edit Exhibition Type' ),
            'new_item'              => __( 'New Exhibition Type' ),
            'view_item'             => __( 'View Exhibition Type' ),
            'search_items'          => __( 'Search Exhibition Types' ),
            'not_found'             => __( 'No Exhibition Type found' ),
            'not_found_in_trash'    => __( 'No Exhibition Type found in Trash' ),
        );

        $args = array(
            'labels'            => $labels,
            'singular_label'    => __('Exhibiton Type'),
            'public'            => true,
            'show_ui'           => true,
            'hierarchical'      => true,
            'show_tagcloud'     => false,
            'show_in_nav_menus' => false,
            'rewrite'           => array('slug' => 'exhibiton', 'with_front' => false ),
         );
    register_taxonomy( 'exhibition_type', 'ksasexhibits', $args );
}

function register_ksasexhibits_posttype() {
    $labels = array(
            'name'              => _x( 'Exhibits & Programs', 'post type general name' ),
            'singular_name'     => _x( 'Exhibit', 'post type singular name' ),
            'add_new'           => __( 'Add New Exhibit & Program' ),
            'add_new_item'      => __( 'Add New Exhibit & Program' ),
            'edit_item'         => __( 'Edit Exhibit & Program' ),
            'new_item'          => __( 'New Exhibit & Program' ),
            'view_item'         => __( 'View Exhibit & Program' ),
            'search_items'      => __( 'Search Exhibit & Program' ),
            'not_found'         => __( 'No Exhibit & Program found' ),
            'not_found_in_trash'=> __( 'No Exhibit & Program found in Trash' ),
            'parent_item_colon' => __( '' ),
            'menu_name'         => __( 'Exhibits & Programs' )
        );

        //$taxonomies = array( 'exhibition_type' );

        $supports = array('title','revisions','thumbnail' );

        $post_type_args = array(
            'labels'            => $labels,
            'singular_label'    => __('Exhibit & Program'),
            'public'            => true,
            'show_ui'           => true,
            'publicly_queryable'=> true,
            'query_var'         => true,
            'capability_type'   => 'post',
            'has_archive'       => false,
            'hierarchical'      => true,
            'rewrite'           => array('slug' => 'exhibitons', 'with_front' => false ),
            'supports'          => $supports,
            'menu_position'     => 5,
            //'taxonomies'      => $taxonomies,
            'show_in_nav_menus' => true
         );
    register_post_type('ksasexhibits',$post_type_args);
}
add_action('init', 'register_ksasexhibits_posttype');

function define_exhibiton_type_terms() {
    $terms = array(
        '0' => array( 'name' => 'Campus Partnerships','slug' => 'campus'),
        '1' => array( 'name' => 'Community Partnerships','slug' => 'community'),
        '2' => array( 'name' => 'Independent Study','slug' => 'independent'),
        '3' => array( 'name' => 'Digital Work.','slug' => 'digital'),
        '4' => array( 'name' => 'Mellon Foundation','slug' => 'mellon'),
        );
    return $terms;
}

function check_exhibition_type_terms(){

    //see if we already have populated any terms
    $terms = get_terms ('exhibition_type', array( 'hide_empty' => false ) );

    //if no terms then lets add our terms
    if( empty( $terms ) ){
    $terms = array(
        '0' => array( 'name' => 'Campus Partnerships','slug' => 'campus'),
        '1' => array( 'name' => 'Community Partnerships','slug' => 'community'),
        '2' => array( 'name' => 'Independent Study','slug' => 'independent'),
        '3' => array( 'name' => 'Digital Work.','slug' => 'digital'),
        '4' => array( 'name' => 'Mellon Foundation','slug' => 'mellon'),
        );
        foreach( $terms as $term ){
            if( !term_exists( $term['name'], 'exhibition_type' ) ){
                wp_insert_term( $term['name'], 'exhibition_type', array( 'slug' => $term['slug'] ) );
            }
        }
    }

}

add_action ( 'init', 'check_exhibition_type_terms' );

?>


text:
Q: Route to controller in subfolder not working in Laravel 4 I was updating my Laravel 3 app to Laravel 4 when I hit this problem...
Routes I have tried:
Route::get('backend/login', 'backend/UserController@login');
Route::get('backend/login', 'backend.UserController@login');

A: I had a similar issue just a few hours ago and had to play a little bit with it to have it working.
Routes:
Route::group(array('prefix' => 'admin'), function() {
    Route::resource('/', 'admin\DashboardController');
});

In "controllers/admin" i put the DashboardController:
namespace admin;

use Illuminate\Support\Facades\View;

class DashboardController extends \BaseController {

    public function index()
    {
        return View::make('admin/dashboard');
    }

}

That did the trick on Laravel 4. Hope you find it useful enough. :)

A: At the moment, in Laravel 4 Beta 1, you can "only ?" use namespace.
For exemple here in your controller file: app/controllers/backend/UserController.php
<?php namespace Controllers\Backend;

use Illuminate\Routing\Controllers\Controller;

class UserController extends Controller {

    // Note extends Controller and not BaseController

    // Your stuff
}
?>

So after, in file: app/routes.php :
<?php
Route::get('backend/login', 'Controllers\Backend\UserController@login');

I don't know if is the better way, but working here. Edit & dump-autoload "composer.json" seems not work actualy.
If someone can improve that, he will make my day ! :)

A: If you are gonna use Laravel 4, perhaps you should take a look of this: You can specify the namespace to be used on a group of routes, as you can see here: http://www.laravel-tricks.com/tricks/route-group-namespacing
So in your sample:
Route::group(array('prefix' => 'backend', 'namespace' => 'backend'), function()
{

    Route::get('login', 'UserController@login');

});

It works like a charm :)
I've been using it, and are quite good, it helps you keep your code cleaner and more understandable. Give it a try!

A: I recommend doing
Route::group(array('prefix' => 'backend'), function() {
    // Responds to Request::root() . '/backend/user'
    Route::resource('login', 'UserController');
});

see more info here
Laravel 4 nested resource controllers Route::resource('admin/photo', 'PhotoController'); not working

A: My Admin Controller in app/controllers  directory
class AdminController extends BaseController {
/**.
 * @return \AdminController
 */
    public function __construct()
    {

    }
}

Now I have a folder named admin in controllers folder i.e   app/controllers/admin and I have another controller there named AdminDashboardController.php
class AdminDashboardController extends AdminController {

/**
 * Display a listing of the resource.
 *
 * @return Response
 */
    public function getIndex()
    {
    return View::make('admin/dashboard');
    }
    }

And Lastly My Route.php file
Route::group(array('prefix' => 'admin'), function()
{
    # Admin Dashboard
    Route::controller('/', 'AdminDashboardController');
 });

Hope this helps ..:-)

A: As explained here, with Laravel 4.1 you can specify the namespace to be used on a group of routes, as you can see here: http://www.laravel-tricks.com/tricks/route-group-namespacing
I've been using it, and are quite good, it helps you keep your code cleaner and more understandable. Give it a try!

A: You could also put your backend/admin panel in a package..fruit for thought :)


text:
Q: Firebase promise - Query.once failed: Was called with 1 argument. Expects at least 2 I'm trying to fill an array with some data from Firebase using promises. Here's the DB structure:
- domain name(or something)
  |--highscore
     |--Foo: 50
     |--Bar: 60

The code:
var arr=[];
highscoreRef.child('highscore').once('value').then(function(snapshot) {
    snapshot.forEach(function(data) {
    arr.push({playerName: data.key(), score: data.val()});
    });
  }, function(error) {
     console.error(error);
});

I get Uncaught Error: Query.once failed: Was called with 1 argument. Expects at least 2.
Does that mean I have to add at least 2 properties to Foo and Bar? Ex. Foo = {playerName: name, score: 50}
The current DB arrangement fits my needs.

A: This error message happens when you try to use the Promisified API on a pre-Promisified SDK.
Callbacks (that other answers have suggested) will work on any 2.x version of the Firebase SDK.
We introduced an alternative syntax using promises in Firebase's JavaScript SDK version 2.4. See an example of once().then() in this jsbin: http://jsbin.com/qiranu/edit?js,console
Are you using Firebase JavaScript SDK version 2.4 or later (that's where promises were introduced)?

A: Don't use then. Once takes a callback function as the second parameter:
https://www.firebase.com/docs/web/api/query/once.html
var arr=[];
highscoreRef.child('highscore').once('value', function(snapshot) {
    snapshot.forEach(function(data) {
    arr.push({playerName: data.key(), score: data.val()});
    });
  }, function(error) {
     console.error(error);
});


text:
Q: YouTube Average Rating in Python How can I call the gd:rating XML file using the Python YouTube GData API?
I have the YouTube video_id as a variable and I know it's possible to return this:
<gd:rating average='4.553648' max='5' min='1' numRaters='233' rel='http://schemas.google.com/g/2005#overall'/>

I just can't figure out how to do it in Python.

A: In your previous question you've already demonstrated the code that retrieves an entry given a video_id.
Run python:
>>> from gdata.youtube.service import YouTubeService
>>> yt = YouTubeService()
>>> entry = yt.GetYouTubeVideoEntry(video_id='pP9VjGmmhfo')
>>> entry.rating
<gdata.youtube.Rating object at 0x2722cd0>
>>> print entry.rating
<?xml version='1.0' encoding='UTF-8'?>
<ns0:rating average="4.4662576" max="5" min="1" numRaters="652" rel="http://schemas.google.com/g/2005#overall" xmlns:ns0="http://schemas.google.com/g/2005" />
>>> entry.rating.average
'4.4662576'
>>> entry.rating.numRaters
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Rating' object has no attribute 'numRaters'
>>> dir(entry.rating)
['FindExtensions', 'ToString', '_AddMembersToElementTree', '_BecomeChildElement', '_ConvertElementAttributeToMember', '_ConvertElementTreeToMember', '_HarvestElementTree', '_ToElementTree', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_attributes', '_children', '_namespace', '_tag', 'average', 'extension_attributes', 'extension_elements', 'max', 'min', 'num_raters', 'text']
>>> entry.rating.num_raters
'652'


text:
Q: How to add a conditional statement to js for grade calculator I'm trying to make a grade calculator using js, but facing some issue to implement conditions in my project. (check out my code) I have chosen 5 subjects to calculate the GPA and successfully implemented these things. ( 1. Total Marks obtained out of 500,  2. Percentage,  3. Grade point  4. Grade) but unable to implement the final one pass/fail decision. According to my current code, when someone's calculated percentage is less than 33, it is considered as failed. or if greater than or equal to 33% it is considered as pass. I want to change this condition with this one > (when any one enters less than 33 marks of any subject, they have to be consider as failed). FOR BETTER UNDERSTANDING PLEASE CHECK THE EXAMPLE:
EXAMPLE >
When anyone enters these values (Marks):
Subject1: 36,
subject2: 31,
subject3: 35,
subject4: 30,
subject5: 38,
OUTPUT: Out of 500 your total is 170 and percentage is 34.00%. Your grade point is 3.6 & Grade is D. You are Pass in 3 subject & failed in 2 subject.
Help me to implement this idea ("You are Pass in 3 subject & failed in 2 subject")

const calcy = () =>{
    let sb1 = document.getElementById('sb1').value;
    let sb2 = document.getElementById('sb2').value;
    let sb3 = document.getElementById('sb3').value;
    let sb4 = document.getElementById('sb4').value;
    let sb5 = document.getElementById('sb5').value;
    let grades = "";

    let totalGrades = parseFloat(sb1) + parseFloat(sb2) + parseFloat(sb3) + parseFloat(sb4) + parseFloat(sb5);

    let perc = (totalGrades/500*100).toFixed(2);

    let gp = (perc/9.5).toFixed(1);

    if(perc <= 100  && perc >= 95){
       grades = ("10 & Grade is A1");
    }else if(perc <= 95  && perc >= 91){
       grades = gp.concat(" & Grade is A1");
    }else if(perc <= 90  && perc >= 81){
       grades = gp.concat(" & Grade is A2");
    }else if(perc <= 80  && perc >= 71){
       grades = gp.concat(" & Grade is B1");
    }else if(perc <= 70  && perc >= 61){
       grades = gp.concat(" & Grade is B2")
    }else if(perc <= 60  && perc >= 51){
       grades = gp.concat(" & Grade is C1");
    }else if(perc <= 50  && perc >= 41){
       grades = gp.concat(" & Grade is C2");
    }else if(perc <= 40  && perc >= 33){
       grades = gp.concat(" & Grade is D");
    }else if(perc <= 32  && perc >= 21){
       grades = gp.concat(" & Grade is E1");
    }else if(perc <= 20  && perc >= 00){
       grades = gp.concat(" & Grade is E2");
    }

    if(perc <= 100  && perc >= 91){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}, You are Pass. `
    }
    else if (perc <= 90  && perc >= 81){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
    }
    else if (perc <= 80  && perc >= 71){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
    }
    else if (perc <= 70  && perc >= 61){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
    }
    else if (perc <= 60  && perc >= 51){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
    }
    else if (perc <= 50  && perc >= 41){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
    }
    else if (perc <= 40  && perc >= 33){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
    }
    else if (perc <= 32  && perc >= 21){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Fail. `
    }
    else if(perc <= 20  && perc >= 00)
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Fail. `
    }

              <input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 1" id="sb1">

              <input maxlength="3" type="text"  class="app-form-control"   placeholder="SUBJECT 2" id="sb2">

              <input maxlength="3" type="text"  class="app-form-control"   placeholder="SUBJECT 3" id="sb3">

              <input maxlength="3" type="text"  class="app-form-control"   placeholder="SUBJECT 4" id="sb4" >

              <input maxlength="3" type="text"  class="app-form-control"   placeholder="SUBJECT 5" id="sb5" >

              <input type="button" name="" value="CALCULATE CGPA" class="app-form-button" onclick="calcy()">

A: You can count the failed subject and use logic accordingly,

const calcy = () =>{
    let sb1 = document.getElementById('sb1').value;
    let sb2 = document.getElementById('sb2').value;
    let sb3 = document.getElementById('sb3').value;
    let sb4 = document.getElementById('sb4').value;
    let sb5 = document.getElementById('sb5').value;
    let grades = "";
    let failCount = 0;
    failCount += sb1 < 33 ? 1: 0;
    failCount += sb2 < 33 ? 1: 0;
    failCount += sb3 < 33 ? 1: 0;
    failCount += sb4 < 33 ? 1: 0;
    failCount += sb5 < 33 ? 1: 0;

    let failedInSubject = failCount > 0;
    failCountText = `You are Pass in ${5-failCount} subject & failed in ${failCount} subject`;

    let totalGrades = parseFloat(sb1) + parseFloat(sb2) + parseFloat(sb3) + parseFloat(sb4) + parseFloat(sb5);

    let perc = (totalGrades/500*100).toFixed(2);

    let gp = (perc/9.5).toFixed(1);

    if(perc <= 100  && perc >= 95){
       grades = ("10 & Grade is A1");
    }else if(perc <= 95  && perc >= 91){
       grades = gp.concat(" & Grade is A1");
    }else if(perc <= 90  && perc >= 81){
       grades = gp.concat(" & Grade is A2");
    }else if(perc <= 80  && perc >= 71){
       grades = gp.concat(" & Grade is B1");
    }else if(perc <= 70  && perc >= 61){
       grades = gp.concat(" & Grade is B2")
    }else if(perc <= 60  && perc >= 51){
       grades = gp.concat(" & Grade is C1");
    }else if(perc <= 50  && perc >= 41){
       grades = gp.concat(" & Grade is C2");
    }else if(perc <= 40  && perc >= 33){
       grades = gp.concat(" & Grade is D");
    }else if(perc <= 32  && perc >= 21){
       grades = gp.concat(" & Grade is E1");
    }else if(perc <= 20  && perc >= 00){
       grades = gp.concat(" & Grade is E2");
    }

    if(failedInSubject) {
        document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. ${failCountText}. `
    } else {

        if(perc <= 100  && perc >= 91){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}, You are Pass. `
    }
    else if (perc <= 90  && perc >= 81){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
    }
    else if (perc <= 80  && perc >= 71){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
    }
    else if (perc <= 70  && perc >= 61){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
    }
    else if (perc <= 60  && perc >= 51){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
    }
    else if (perc <= 50  && perc >= 41){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
    }
    else if (perc <= 40  && perc >= 33){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
    }
    else if (perc <= 32  && perc >= 21){
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Fail. `
    }
    else if(perc <= 20  && perc >= 00)
      document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Fail. `
    }

     }

              <input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 1" id="sb1">

              <input maxlength="3" type="text"  class="app-form-control"   placeholder="SUBJECT 2" id="sb2">

              <input maxlength="3" type="text"  class="app-form-control"   placeholder="SUBJECT 3" id="sb3">

              <input maxlength="3" type="text"  class="app-form-control"   placeholder="SUBJECT 4" id="sb4" >

              <input maxlength="3" type="text"  class="app-form-control"   placeholder="SUBJECT 5" id="sb5" >

              <input type="button" name="" value="CALCULATE CGPA" class="app-form-button" onclick="calcy()">

A: Try like this:

const calcy = () => {
  let sb1 = document.getElementById('sb1').value;
  let sb2 = document.getElementById('sb2').value;
  let sb3 = document.getElementById('sb3').value;
  let sb4 = document.getElementById('sb4').value;
  let sb5 = document.getElementById('sb5').value;

  let grades = "";

  const passscore = 33;

  let array = [parseFloat(sb1), parseFloat(sb2), parseFloat(sb3), parseFloat(sb4), parseFloat(sb5)];

  let totalGrades = array.reduce((total, grade) => total + grade, 0);

  let passes = array.reduce((total, grade) => {
    if (passscore <= grade) {
      total++;
    };

    return total;
  }, 0);

  let fails = array.length - passes;

  let result = `<br/>You are Pass in ${passes} subject & failed in ${fails} subject`;

  let perc = (totalGrades / 500 * 100).toFixed(2);

  let gp = (perc / 9.5).toFixed(1);

  if (perc <= 100 && perc >= 95) {
    grades = ("10 & Grade is A1");
  } else if (perc <= 95 && perc >= 91) {
    grades = gp.concat(" & Grade is A1");
  } else if (perc <= 90 && perc >= 81) {
    grades = gp.concat(" & Grade is A2");
  } else if (perc <= 80 && perc >= 71) {
    grades = gp.concat(" & Grade is B1");
  } else if (perc <= 70 && perc >= 61) {
    grades = gp.concat(" & Grade is B2")
  } else if (perc <= 60 && perc >= 51) {
    grades = gp.concat(" & Grade is C1");
  } else if (perc <= 50 && perc >= 41) {
    grades = gp.concat(" & Grade is C2");
  } else if (perc <= 40 && perc >= 33) {
    grades = gp.concat(" & Grade is D");
  } else if (perc <= 32 && perc >= 21) {
    grades = gp.concat(" & Grade is E1");
  } else if (perc <= 20 && perc >= 00) {
    grades = gp.concat(" & Grade is E2");
  }

  if (perc <= 100 && perc >= 91) {
    document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}, You are Pass. ${result}`
  } else if (perc <= 90 && perc >= 81) {
    document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. ${result}`
  } else if (perc <= 80 && perc >= 71) {
    document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. ${result}`
  } else if (perc <= 70 && perc >= 61) {
    document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. ${result}`
  } else if (perc <= 60 && perc >= 51) {
    document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. ${result}`
  } else if (perc <= 50 && perc >= 41) {
    document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. ${result}`
  } else if (perc <= 40 && perc >= 33) {
    document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. ${result}`
  } else if (perc <= 32 && perc >= 21) {
    document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Fail. ${result}`
  } else if (perc <= 20 && perc >= 00) {
    document.getElementById('showData').innerHTML = ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Fail. ${result}`
  }
}

    <input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 1" id="sb1">

    <input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 2" id="sb2">

    <input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 3" id="sb3">

    <input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 4" id="sb4">

    <input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 5" id="sb5">

    <input type="button" name="" value="CALCULATE CGPA" class="app-form-button" onclick="calcy()">

By putting the grades into an array, you can easily loop through them to count total score and pass/fail according to their value.

A: This can still be optimized.

const form = document.querySelector('.app-form');

const calcy = (event) =>{
   event.preventDefault();

   const sb1 = document.getElementById('sb1').value;
   const sb2 = document.getElementById('sb2').value;
   const sb3 = document.getElementById('sb3').value;
   const sb4 = document.getElementById('sb4').value;
   const sb5 = document.getElementById('sb5').value;

   const gradesArray = [parseFloat(sb1), parseFloat(sb2), parseFloat(sb3) ,parseFloat(sb4), parseFloat(sb5)]
   const totalGrades = gradesArray.reduce((acc, e) => acc + e, 0);
   const passGrades = gradesArray.filter(e => e >= 33).length;
   const failGrades = gradesArray.length - passGrades;

   const perc = (totalGrades/500*100).toFixed(2);
   const status = (perc <= 100  && perc >= 33) ? 'Pass' : 'Fail';
   const gp = (perc/9.5).toFixed(1);

   let grades = "";
   if(perc <= 100  && perc >= 95){
       grades = ("10 & Grade is A1");
   }else if(perc <= 95  && perc >= 91){
       grades = gp.concat(" & Grade is A1");
   }else if(perc <= 90  && perc >= 81){
       grades = gp.concat(" & Grade is A2");
   }else if(perc <= 80  && perc >= 71){
      grades = gp.concat(" & Grade is B1");
   }else if(perc <= 70  && perc >= 61){
      grades = gp.concat(" & Grade is B2")
   }else if(perc <= 60  && perc >= 51){
      grades = gp.concat(" & Grade is C1");
   }else if(perc <= 50  && perc >= 41){
      grades = gp.concat(" & Grade is C2");
   }else if(perc <= 40  && perc >= 33){
      grades = gp.concat(" & Grade is D");
   }else if(perc <= 32  && perc >= 21){
      grades = gp.concat(" & Grade is E1");
   }else if(perc <= 20  && perc >= 0){
      grades = gp.concat(" & Grade is E2");
   }

   document.getElementById('showData').innerHTML =
    ` Out of 500 your total is  ${totalGrades} and percentage is ${perc}%.

 Your grade point is ${grades}. You are ${status}.

  You are Pass in ${passGrades} subject & failed in ${failGrades} subject`
}

form.addEventListener('submit', calcy, false)
    <form class="app-form">

        <input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 1" id="sb1">

        <input maxlength="3" type="text"  class="app-form-control"   placeholder="SUBJECT 2" id="sb2">

        <input maxlength="3" type="text"  class="app-form-control"   placeholder="SUBJECT 3" id="sb3">

        <input maxlength="3" type="text"  class="app-form-control"   placeholder="SUBJECT 4" id="sb4" >

        <input maxlength="3" type="text"  class="app-form-control"   placeholder="SUBJECT 5" id="sb5" >

        <input type="submit" value="CALCULATE CGPA" class="app-form-button">

</form>

A: I have tried to simplify the code as much as possible by utilizing functions wherever it was necessary.
I avoided using arrays for now as there are only 5 subjects.

const calcy = () => {
  document.getElementById("showData").innerHTML = result();
};

const result = () => {
  const sb1 = document.getElementById("sb1").value;
  const sb2 = document.getElementById("sb2").value;
  const sb3 = document.getElementById("sb3").value;
  const sb4 = document.getElementById("sb4").value;
  const sb5 = document.getElementById("sb5").value;
  const totalGrades =
    parseFloat(sb1) +
    parseFloat(sb2) +
    parseFloat(sb3) +
    parseFloat(sb4) +
    parseFloat(sb5);
  const numberOfPassedSubjects =
    checkPass(sb1) +
    checkPass(sb2) +
    checkPass(sb1) +
    checkPass(sb1) +
    checkPass(sb1);

  const numberOfFailedSubjects = 5 - numberOfPassedSubjects;
  const perc = ((totalGrades / 500) * 100).toFixed(2);
  const gp = (perc / 9.5).toFixed(1);
  const grade = grader(perc);

  message =
    "
Out of 500, your total is  " +
    totalGrades +
    ".
" +
    " Your percentage is " +
    perc +
    " %.
" +
    " Your Grade point is " +
    gp +
    "
" +
    " Grade is " +
    grade +
    "
" +
    " You have passed in " +
    numberOfPassedSubjects +
    " subjects and " +
    " You have failed in " +
    numberOfFailedSubjects +
    " subjects.
";
  return message;
};

var checkPass = (sbMarks) => {
  if (sbMarks >= 33) {
    return 1;
  } else return 0;
};

const gpCalc = (perc) => {
  initialGP = (perc / 9.5).toFixed(1);
  if (initialGP > 10) {
    return 10;
  } else return initialGP;
};
const grader = (perc) => {
  if (perc >= 91) {
    return "A1";
  } else if (perc >= 81) {
    return "A2";
  } else if (perc >= 71) {
    return "B1";
  } else if (perc >= 61) {
    return "B2";
  } else if (perc >= 51) {
    return "C1";
  } else if (perc >= 41) {
    return "C2";
  } else if (perc >= 31) {
    return "D";
  } else if (perc >= 21) {
    return "E1";
  } else if (perc >= 0) {
    return "E2";
  }
};

    <input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 1" id="sb1">

    <input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 2" id="sb2">

    <input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 3" id="sb3">

    <input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 4" id="sb4">

    <input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 5" id="sb5">

    <input type="button" name="" value="CALCULATE CGPA" class="app-form-button" onclick="calcy()">

Above is the logic, and your result should be provided in the message object which will duly returned to your first calcy function.
I would suggest you to add condition check to your input to make sure numbers is below 100 while input.


text:
Q: Best Way to Add Object Via Other Class? In my iPhone app, I have a custom UIViewController class setup which adds some UIImageViews and things.
How can I access this class via my main UIViewController and, for example, call a method from that outside class and have it add those UIImageViews to the view?

A: Make property and public methods, after that you can call them in target viewcontroller.
p.s. But I never used this approach because it breaks controller's logic. Instead of I usually use some managers which has all required methods. (DBManager, NetworkManager, etc)


text:
Q: PHPExcel - Erasing formula's not supported by PHPExcel I have an excel template saved in the server. When I write some data using PHPExcel library to the existing template and save it, it writes the data but erases all the formulas from the excel file such as linest, etc. while being saved. So when I open the excel file, it shows the data written to it but the file does not contain any formulas. Is it something that I am doing wrong or PHPExcel does not support those functions? I tried looking at other questions on stackoverflow but could not find anything similiar to mine.
Below is my code for writing to the excel file.
<?php
/** Include PHPExcel */
require_once 'PHPExcel.php';
require_once 'PHPExcel/IOFactory.php';
$sheetname = "Input";

$inputFileName = "templates/test_template2.xlsx";
$inputFileType = "Excel2007";
class MyReadFilter implements PHPExcel_Reader_IReadFilter {
    public function readCell($column, $row, $worksheetName = '') {
    //  Read rows 1 to 200 and columns A to PP only for avoiding memory limit errors
        if ($row >= 1 && $row <= 200) {
           if (in_array($column,range('A','PP'))) {
           return true;
           }
       }
       return false;
   }
}

$filterSubset = new MyReadFilter();

$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setIncludeCharts(true);
$objReader->setLoadSheetsOnly($sheetname);
$objReader->setReadFilter($filterSubset);
$objPHPExcel = $objReader->load($inputFileName);

$objPHPExcel->setActiveSheetIndex(0);
//random data for testing
$objPHPExcel->getActiveSheet()->SetCellValue('B15', '234');
$objPHPExcel->getActiveSheet()->SetCellValue('C15', '2554');
$objPHPExcel->getActiveSheet()->SetCellValue('D15', '436');
$objPHPExcel->getActiveSheet()->SetCellValue('B16', '246546');
$objPHPExcel->getActiveSheet()->SetCellValue('C16', '576');
$objPHPExcel->getActiveSheet()->SetCellValue('D16', '457');
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->setPreCalculateFormulas(true);
$objWriter->setIncludeCharts(true);
$objWriter->save('test_template_edit.xlsx');
echo "Data written and saved to the excel file";
?>

EDIT :
    So after changing the memory and time limit and uploading a file with fewer columns, I was able to keep the formatting and formulas. However, when viewing the workbook later, all of the charts on adjacent worksheets are disappearing even when I am using setIncludeCharts(TRUE) both before the file is uploaded and output. Any suggestions?


text:
Q: ObjC: ARC releasing dynamically created view controller too early I have a view controller, named AllThingsViewController that dynamically creates other view controllers, named ThingViewController, and adds their top level view to a UIScrollView. (I'm writing proprietary code so I've changed the names of my classes, but the structure of my code is exactly the same.)
Here's what its loadView method contains:
NSArray *things = [[ThingDataController shared] getThings];

if ([things count] == 0) {
    // code in this block is not relevant as it's not being executed...
} else {

    for(unsigned int i = 0; i < [things count]; ++i) {
        ThingViewController *thingViewController = [[ThingViewController alloc] init];
        [thingViewController loadView];

        [scrollView addSubview:thingViewController.topView];
        thingViewController.topView.frame = CGRectNewOrigin(thingViewController.topView.frame,
                0, thingViewController.topView.frame.size.height*i);

        [thingViewController displayThing:thing[i]];
    }
}

ThingViewController's loadView method looks like this:
- (void)loadView
{
    NSArray *topLevelObjs = nil;
    topLevelObjs = [[NSBundle mainBundle] loadNibNamed:@"ThingView" owner:self options:nil];
    if (topLevelObjs == nil)
    {
        NSLog(@"Error: Could not load ThingView xib\n");
        return;
    }
}

When my app starts up everything displays correctly, until I try to tap one of the buttons that exists in the xib being loaded by ThingViewController, at which point it crashes due to an exception: "unrecognized selector sent to instance". It seems that ARC is releasing my ThingViewController instances too early.
Looking at my code, I figured it was because they weren't being held on to anything, so I created an NSMutableArray as an instance variable in my AllThingsViewController class, and started adding the ThingViewControllers to it thusly:
NSArray *things = [[ThingDataController shared] getThings];

if ([things count] == 0) {
    // not being executed...
} else {

    for(unsigned int i = 0; i < [things count]; ++i) {
        ThingViewController *thingViewController = [[ThingViewController alloc] init];
        [thingViewController loadView];

        [scrollView addSubview:thingViewController.topView];
        thingViewController.topView.frame = CGRectNewOrigin(thingViewController.topView.frame,
                0, thingViewController.topView.frame.size.height*i);

        [thingViewController displayThing:thing[i]];

        [allThingsViewControllers addObject:thingViewController];
    }
}

However, it didn't change anything, even though those objects are being added to the array. Finally, just to confirm that this is ARC releasing it early, I changed "thingViewController" to be an instance variable in AllThingsViewController and changed:
ThingViewController *thingViewController = [[ThingViewController alloc] init];

to be:
thingViewController = [[ThingViewController alloc] init];

Sure enough, the last item in the scrollable list doesn't crash when I tap its buttons, but the other ones do, because its ThingViewController isn't being deallocated.
I'm still relatively new to ARC, but after a bunch of Googling I have no idea how to fix this. What do I do?

A: Couple of things.
Problem 1:
This looks like the cause of your bug:
[allBillViewControllers addObject:billViewController];

It should be:
[allBillViewControllers addObject:thingViewController];

Right?
Problem 2
You are not properly adding the view controller to your view hierarchy. It should be this:
[self addChildViewController:childViewController];
[childViewController.view setFrame:targetFrame];
[scrollView addSubview:childViewController.view];
[childViewController didMoveToParentViewController:self];

And similarly when removing a child view controller:
[childViewController willMoveToParentViewController:nil];
[childViewController.view removeFromSuperview];
[childViewController removeFromParentViewController];

Problem 3
Never call loadView explicitly on a view controller. It gets called by UIKit whenever you access the view property of a view controller.
Problem 4
You must add the view of the child view controller to your scroll view, not an arbitrary subview topView in its view hierarchy. Refactor your ThingViewController class to make this simpler for yourself. :-)

A: Let's look at your code:
for(unsigned int i = 0; i < [things count]; ++i) {
    ThingViewController *thingViewController = [[ThingViewController alloc] init];
    [thingViewController loadView];

    [scrollView addSubview:thingViewController.topView];
    thingViewController.topView.frame = CGRectNewOrigin(thingViewController.topView.frame,
            0, thingViewController.topView.frame.size.height*i);

    [billViewController displayThing:thing[i]];

    [allBillViewControllers addObject:billViewController];
}

After each loop of the for loop executes, nothing will have a strong reference to the ThingViewController.  Thus, it gets released and destroyed.
If ThingViewController is a subclass of UIViewController, then it should be made a "child view controller" of the scrollview's view controller.  I recommend reading the section on from the View Controller Programming Guide on creating custom container view controllers (i.e., a view controller that encapsulates and displays other view controllers).


text:
Q: faild to link protobuf I'm trying to link protobuf but I'm getting an undefined reference:
this is my CMAKE file:
I also see in the error code it has a problem with the std::string of the ABI of CPP11 but I don't know if this is the main problem or not because I'm building from a source using GCC 7.3.1
cmake_minimum_required(VERSION 3.17)
project(cpp_server_side_objects)

set(CMAKE_CXX_STANDARD 17)

SET(BOOST_LIB boost_system boost_thread)

INCLUDE(FindProtobuf)
FIND_PACKAGE(Protobuf  REQUIRED)
if(Protobuf_VERBOSE)
    message(STATUS "Using Protocol Buffers ${Protobuf_VERSION}")
    else()
    message(STATUS "cant find protobuf ${Protobuf_VERSION}")
endif()
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
PROTOBUF_GENERATE_CPP(PROTO_SRC PROTO_HEADER SREXOrderRequest.proto)
ADD_LIBRARY(proto ${PROTO_HEADER} ${PROTO_SRC})

add_executable(cpp_server_side_objects main.cpp request.cpp request.h)
target_link_libraries(cpp_server_side_objects proto ${PROTOBUF_LIBRARY} ${BOOST_LIB} )

but I'm getting this error messages:
====================[ Build | cpp_server_side_objects | Debug ]=================
/home/yaodav/clion-2019.1.4/bin/cmake/linux/bin/cmake --build /home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug --target cpp_server_side_objects -- -j 4
[ 25%] Linking CXX executable cpp_server_side_objects
CMakeFiles/cpp_server_side_objects.dir/main.cpp.o: In function `server_side_order::SREXOrderRequest::set__symbol(char const*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.h:618: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/main.cpp.o: In function `server_side_order::SREXOrderRequest::set__myid(char const*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.h:691: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/main.cpp.o: In function `server_side_order::SREXOrderRequest::set__exdest(char const*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.h:764: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/main.cpp.o: In function `server_side_order::SREXOrderRequest::set__userinfo(char const*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.h:837: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/main.cpp.o: In function `server_side_order::SREXOrderRequest::set__dest(char const*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.h:910: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::SREXOrderRequest(server_side_order::SREXOrderRequest const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:155: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:160: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:165: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:170: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:175: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_InternalParse(char const*, google::protobuf::internal::ParseContext*)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:325: undefined reference to `google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:336: undefined reference to `google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:347: undefined reference to `google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:358: undefined reference to `google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)'
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/SREXOrderRequest.proc.pb.cc:369: undefined reference to `google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `google::protobuf::internal::ArenaStringPtr::Swap(google::protobuf::internal::ArenaStringPtr*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, google::protobuf::Arena*)':
/usr/local/include/google/protobuf/arenastring.h:326: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
/usr/local/include/google/protobuf/arenastring.h:327: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
/usr/local/include/google/protobuf/arenastring.h:326: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
/usr/local/include/google/protobuf/arenastring.h:327: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
/usr/local/include/google/protobuf/arenastring.h:326: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o:/usr/local/include/google/protobuf/arenastring.h:327: more undefined references to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)' follow
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliased(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)':
/usr/local/include/google/protobuf/io/coded_stream.h:719: undefined reference to `google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliasedOutline(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_set__symbol(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:607: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_mutable__symbol[abi:cxx11]()':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:630: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_set__myid(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:680: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_mutable__myid[abi:cxx11]()':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:703: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_set__exdest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:753: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_mutable__exdest[abi:cxx11]()':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:776: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_set__userinfo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:826: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_mutable__userinfo[abi:cxx11]()':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:849: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_set__dest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:899: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o: In function `server_side_order::SREXOrderRequest::_internal_mutable__dest[abi:cxx11]()':
/home/yaodav/Desktop/dnr_main_repo/cpp_server_side_objects/cmake-build-debug/SREXOrderRequest.proc.pb.h:922: undefined reference to `google::protobuf::internal::ArenaStringPtr::Mutable[abi:cxx11](google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o:(.rodata._ZTVN17server_side_order16SREXOrderRequestE[_ZTVN17server_side_order16SREXOrderRequestE]+0x20): undefined reference to `google::protobuf::Message::GetTypeName[abi:cxx11]() const'
CMakeFiles/cpp_server_side_objects.dir/SREXOrderRequest.proc.pb.cc.o:(.rodata._ZTVN17server_side_order16SREXOrderRequestE[_ZTVN17server_side_order16SREXOrderRequestE]+0x48): undefined reference to `google::protobuf::Message::InitializationErrorString[abi:cxx11]() const'
collect2: error: ld returned 1 exit status
gmake[3]: *** [cpp_server_side_objects] Error 1
gmake[2]: *** [CMakeFiles/cpp_server_side_objects.dir/all] Error 2
gmake[1]: *** [CMakeFiles/cpp_server_side_objects.dir/rule] Error 2
gmake: *** [cpp_server_side_objects] Error 2

how to fix it?
tried using this and this and this and with this also with no luck.

A: I had a similar problem. The protobuf_generate_cpp command in CMake seems to cause a problem in linking the source and header files created from the *.proto file with the necessary libraries.
My workaround was as follows. After obtaining the files created from the proto file, it was to close it so that it would not be created again.
# ---------------------------------------------------------------
## Protocol Buffers
set(CMAKE_PREFIX_PATH "C:\\DevTools\\vcpkg\\packages\\protobuf_x64-windows" "${CMAKE_PREFIX_PATH}")
set(PROTOBUF_INCLUDE_DIR "C:\\DevTools\\vcpkg\\packages\\protobuf_x64-windows\\include")
include(FindProtobuf)
find_package(Protobuf CONFIG REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
#protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS src/protocolbuffers/person.proto) # this line
# copy the generated files to the build directory
file(COPY ${PROTO_HDRS} DESTINATION src/protocolbuffers)
file(COPY ${PROTO_SRCS} DESTINATION src/protocolbuffers)
message(STATUS "debug protobuf lib location:${PROTOBUF_LIBRARY}")
message(STATUS "debug protobuf include location:${PROTOBUF_INCLUDE_DIR}")
message(STATUS "proto source files:${PROTO_SRCS}")
message(STATUS "proto header files:${PROTO_HDRS}")
# ---------------------------------------------------------------

...
add_executable(${PROJECT_NAME}
        ${SOURCE_FILES}
        ${HEADER_FILES}
        ${PROTO_SRCS} ${PROTO_HDRS}
        )

...
target_link_libraries(${PROJECT_NAME} PRIVATE
        ...
        ${Protobuf_LIBRARIES}
        protobuf::libprotobuf
        )


text:
Q: What are .EXE.IGNORE files and why are they on my windows machine I found a bunch of zero-length files with the extension .EXE.IGNORE on a few windows machines recently.
Their purpose and source was a unknown, so I dug into it some...

A: It turns out these files .EXE.IGNORE are side-effects from installation of certain packages using the chocolatey package installer.   While I've concluded they aren't in themselves harmful, in a production environment it might suggests a need for better configuration control
There is a bug opened for the Python package on Github.


text:
Q: RPy2 Convert Dataframe to SpatialGridDataFrame how can a Dataframe be converted to a SpatialGridDataFrame using the R maptools library? I am new to Rpy2, so this might be a very basic question.
The R Code is:
coordinates(dataf)=~X+Y
In Python:
import rpy2
import rpy2.robjects as robjects
r = robjects.r
# Create a Test Dataframe
d = {'TEST': robjects.IntVector((221,412,332)), 'X': robjects.IntVector(('25', '31', '44')), 'Y': robjects.IntVector(('25', '35', '14'))}
dataf = robjects.r['data.frame'](**d)
r.library('maptools')
# Then i could not manage to write the above mentioned R-Code using the Rpy2 documentation

Apart this particular question i would be pleased to get some feedback on a more general idea: My final goal would be to make regression-kriging with spatial data using the gstat library. The R-script is working fine, but i would like to call my Script from Python/Arcgis. What do you think about this task, is this possible via rpy2?
Thanks a lot!
Richard

A: In some cases, Rpy2 is still unable to dynamically (and automagically) generate smart bindings.
An analysis of the R code will help:
coordinates(dataf)=~X+Y

This can be more explicitly written as:
dataf <- "coordinates<-"(dataf, formula("~X+Y"))

That last expression makes the Python/rpy2 straigtforward:
from rpy2.robjects.packages import importr
sp = importr('sp') # "coordinates<-()" is there

from rpy2.robjects import baseenv, Formula
maptools_set = baseenv.get('coordinates<-')
dataf = maptools_set(dataf, Formula(' ~ X + Y'))

To be (wisely) explicit about where "coordinates<-" is coming from, use:
maptools_set = getattr(sp, 'coordinates<-')


text:
Q: Separating values for UI from View I'd like to create a NSObject subclass which would hold all my values for UIView.
Problem - what's the right way to do that?

*

*Using "extern" and class method combination?

*Using "extern" and #define combination?

*Using only #define on class methods?

UI elements(e.g. UIColor) can't be initialized using "extern *const" method.
Writing a class methods for each value seems like too much.
Macros are plain(no coloring, etc.) and are declared only in header file.
Isn't there are better solution, which would hold all my ints,floats, colors in same place. And which is not a macro.

A: Why not macros?
For UIColor you can use:
#define RGBA_COLOR(r, g, b, a) [UIColor colorWithRed:(r/255.0) green:(g/255.0) blue:(b/255.0) alpha:a]

#define MY_GREEN_COLOR RGBA_COLOR(60, 192, 174, 1.0)

And then you can use MY_GREEN_COLOR without problems:
UIColor *color = MY_GREEN_COLOR;

And the same for int, floats and so on:
#define MY_INT 83

I usually have a "Globals.h" file with all this stuff.


text: Q: Is there a way in Java to be notified when a select object's data changes? I have a DefaultListSelectionModel and I'm registering via addListSelectionListener. This tells me when a new row gets selected, is there any way to be notified when a selected row's data changes (or maybe even gets repainted)?


text:
Q: Installing R packages with bash script - responding to prompts At my job, the edge node server that accesses our cluster is re-instantiated every day. This means I have to clone our repo and install a bunch of R packages every morning. I wrote a bash script (using https://github.com/eddelbuettel/littler to open R from the command line) to automate this and it works except for one hiccup.
Bash calls:
    r install.R
which opens an R session and calls the following command:
repos <- "http://... [our CRAN equivalent]"
install.packages("[package_name]",repos)

Now, normally, if I were entering this myself in R, I would get this as a response:
Installing package into '/usr/hdp/2.5.5.3-2/spark2/R/lib' (as 'lib' is unspecified)
Warning in install.packages("[name_of_package]", repos = "http://...") :

'lib = "/usr/hdp/2.5.5.3-2/spark2/R/lib"' is not writable
Would you like to use a personal library instead?  (y/n)

And I would say 'y,' followed by another 'y' when it suggests a library to create. However, when I do this from the bash script, it just says the library is not writable and aborts.
Two options I see here:
1) I tell it which library to write the packages in. I've tried this, and while the packages did go there, they arrived empty. Nothing was actually downloaded from the repo.
2) Somehow get the script to be able to pipe in the two affirmative responses I need in order to let R do its thing and create its own library.
Any suggestions on either of these would be much appreciated!

A: There are multiple solutions to this. I will show two similar solutions.
The interactive script:
#!/bin/bash
# test.sh

printf "Response 1: "
read resp1
echo "You inserted $resp1"
printf "Response 2: "
read resp2
echo "You inserted $resp2"

To pipe two entries into this script, we can use a here string:
$ ./test.sh <<< $'yes\nno\n'
Response 1: You inserted yes
Response 2: You inserted no

Each entry is delimited from the other entries by the \n character. This string is sent to the standard input of the script.
Alternatively, you could also pipe the string into the scripts stdin stream:
$ printf 'yes\nno\n' | ./test.sh
Response 1: You inserted yes
Response 2: You inserted no

A: A different approach that works much better than what I originally posted:
In bash:
Create a specific library for installation (the same as the default R will want to create)
mkdir -p R/x86_64-pc-linux-gnu-library/3.3
Rscript --vanilla install_packages.R

In install_packages.R:
pkg_list <- # however you want to get this

for (pkg in pkg_list) {
  install.packages(pkg, repos = "your_cran_mirror",
                   lib = "R/x86_64-pc-linux-gnu-library/3.3")
  if (!require(pkg, character.only = T)) {
    quit(save = "no", status = 1, runLast = FALSE)
  }
}

Using this method, R will not prompt you and your script will run as intended.

A: Two options:
yes | r install.R

or:
{ echo y; echo y; } | r install.R

A: NOTE: This technically works but is very clumsy and error-prone. Please see my other answer.
I figured out a way to do it.
First, create or modify .Rprofile. Add the installations and responses at the top of that file. For example:
repos = [CRAN or wherever you're sourcing from]
install.packages(package1, repos)
y
y
install.packages(package2, repos)
install.packages(package3, repos)
... # etc.

The 'y's should only be necessary for the first package, when R asks if you want to create a new library. The subsequent packages will also be dropped in there.
If you really want it to be hands-free and the script does other things after installing the R packages, you can add a quit() statement at the end, which will exit R and do whatever else you want the script to do. This might be annoying when you want to launch R later, so you'd want the script to pass around a couple different .Rprofiles.
Second, in your bash script, simply open R with R. The .Rprofile will be run immediately on startup, and the packages will be downloaded automatically.


text:
Q: Appening Bulk of JSON Data From Server In jQueryMobile and PhoneGap project I got more than 1000 of data in JSON format.
The problem am facing that; Need to fetch all the data with in minumum time.
So for this purpose ; currently am using Fetching data in Scroll Up event using jQueryMobile iScrollview.
jquery-mobile-iscrollview
Is there any method instead of that..

A: Using ajax to fetch your data block by block after the page is loaded. This won't block your UI. And when you scroll your page, as the data is already fetched, user needn't to wait.
I am not sure whether this answer fit your needs.


text:
Q: Defining array with multiple types in TypeScript I have an array of the form: [ 1, "message" ].
How would I define this in TypeScript?

A:
Defining array with multiple types in TypeScript

Use a union type (string|number)[] demo:
const foo: (string|number)[] = [ 1, "message" ];

I have an array of the form: [ 1, "message" ].

If you are sure that there are always only two elements [number, string] then you can declare it as a tuple:
const foo: [number, string] = [ 1, "message" ];

And you can even provide meaningful names for the tuple members e.g. id and text:
const foo: [id: number, text: string] = [ 1, "message" ];

A: If you are interested in getting an array of either numbers or strings, you could define a type that will take an array of either
type Tuple = Array<number | string>
const example: Tuple = [1, "message"]
const example2: Tuple = ["message", 1]

If you expect an array of a specific order (i.e. number and a string)
type Tuple = [number, string]
const example: Tuple = [1, "message"]
const example2: Tuple = ["messsage", 1] // Type 'string' is not assignable to type 'number'.

A: My TS lint was complaining about other solutions, so the solution that was working for me was:
item: Array<Type1 | Type2>

if there's only one type, it's fine to use:
item: Type1[]

A: Im using this version:
exampleArr: Array<{ id: number, msg: string}> = [
   { id: 1, msg: 'message'},
   { id: 2, msg: 'message2'}
 ]

It is a little bit similar to the other suggestions but still easy and quite good to remember.

A: const myarray:(TypeA | TypeB)[];

or even better to avoid changes in multiple place in case you need to add another type, create type
type MyMixedType = TypeA | TypeB;
const myarray: MyMixedType[];

A: TypeScript 3.9+ update (May 12, 2020)
Now, TypeScript also supports named tuples. This greatly increases the understandability and maintainability of the code. Check the official TS playground.

So, now instead of unnamed:
const a: [number, string] = [ 1, "message" ];

We can add names:
const b: [id: number, message: string] = [ 1, "message" ];

Note: you need to add all names at once, you can not omit some names, e.g:
type tIncorrect = [id: number, string]; // INCORRECT, 2nd element has no name, compile-time error.
type tCorrect = [id: number, msg: string]; // CORRECT, all have a names.

Tip: if you are not sure in the count of the last elements, you can write it like this:
type t = [msg: string, ...indexes: number];// means first element is a message and there are unknown number of indexes.

TypeScript 4.x+ Variadic Tuple Types
The last example has to be changed to this one for TS 4.x:
type t = [msg: string, ...indexes: number[]];// means first element is a message and there are unknown number of indexes.

The type number is changed to number[].
More info here: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-0.html#variadic-tuple-types

A: I've settled on the following format for typing arrays that can have items of multiple types.
Array<ItemType1 | ItemType2 | ItemType3>
This works well with testing and type guards. https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types
This format doesn't work well with testing or type guards:
(ItemType1 | ItemType2 | ItemType3)[]

A: If you're treating it as a tuple (see section 3.3.3 of the language spec), then:
var t:[number, string] = [1, "message"]

or
interface NumberStringTuple extends Array<string|number>{0:number; 1:string}
var t:NumberStringTuple = [1, "message"];

A: If dealing with an array with multiple value types in an object this worked for me.
 { [key: string]: number | string }[]

A: [ 1, "message" ] as const ;

if you do "as const" , type will be
type const = readonly [1, "message"]

It is good because of the exact type inference that computer can possible.