text:
Q: If statement within Predicate not working My IF statement within my nsfetchresultscontroller  is not working and I cannot figure out why. It is a simple IF statement based on the static title of the viewcontroller using  if ([self.title isEqual: @"Abdominals"]) My storyboard can be seen below:

ViewController
  - (NSFetchedResultsController *)fetchedResultsController {

    if (_fetchedResultsController != nil) {
        return _fetchedResultsController;
    }

    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription
                                   entityForName:@"ExcerciseInfo" inManagedObjectContext:managedObjectContext];
    [fetchRequest setEntity:entity];

    NSSortDescriptor *sort = [[NSSortDescriptor alloc]
                              initWithKey:@"details.muscle" ascending:NO];
    [fetchRequest setSortDescriptors:[NSArray arrayWithObject:sort]];

    [fetchRequest setFetchBatchSize:20];

// Sort Results
  if ([self.title isEqual: @"Abdominals"]) {

        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"details.muscle == %@", @"Biceps"];
        [fetchRequest setPredicate:predicate];

    }

    else if ([self.title isEqual: @"Arms"]) {

        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"details.muscle == %@", @"Biceps"];
        [fetchRequest setPredicate:predicate ];

    }

    else {

        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"details.muscle == %@", @"Chest"];
        [fetchRequest setPredicate:predicate ];

 }

Any suggestions?

A: I think you're looking for isEqualToString:
isEqual: compares objects, where it appears you are wanting to compare values.


text:
Q: CodeRAD2 - buttons overflowMenuStyle issue When using overflowMenuStyle="PopupMenu" the actions is clickable and everything works fine. However when I use overflowMenuStyle="ActionSheet" the actions is not responding to clicks/touch. So, am I missing something or is this a bug?
<buttons actionTemplate.uiid="MyMenuActions" actionCategory="MAIN_TOP_OVERFLOW_MENU" limit="1" overflowActionTemplate.uiid="MainSheetAction" overflowMenuStyle="ActionSheet" />

A: This issue is fixed in CodeRAD version 2.0.3.  Update your CodeRAD version in both your pom.xml and common/pom.xml files, and you should find that it starts working.

redpajama_set_name: RedPajamaStackExchange


text:
Q: API rails app import CSV into database through REST Using Postman to upload to a POST path in a rails app (api only) however not sure how to parse it into the rails app.
We have a model to import the table with a import method that takes a CSV and loops through to add it to the db.
however not sure how to take the file through the post in the controller using the params[] since we are posting it as binary (we have tried the form way in Postman too with not much luck).
I have in the controller

file = CSV.read(params[:file].path)

however this makes an array which I don't quite know how to feed into the model (there are headers in the original CSV file too)

A: How about you can upload your csv to S3, or Dropbox, then just post the url to server, server reads that CSV and import to DB.
Here is example to read CSV from a URL:
app/services/process_csv.rb
require 'csv'
require 'net/http'

class ProcessCsv
  def initialize(csv_url)
    @csv_url = csv_url
  end

  def proesss
    uri = URI(@csv_url)
    csv_text = Net::HTTP.get(uri)
    csv = CSV.parse(csv_text, headers: true)
    csv.each do |row|
      # Process row here and import to DB here
    end
  end
end

Then you can use ProcessCsv in your controller, the params of your controller is just an URL to CSV file, not CSV data!

A: You can parse CSV using foreach. For example, something like given below.
CSV.foreach(params[:file].path, headers: false) do |row|
  Model.create(name: row[0], email: row[1])
end


text:
Q: laravel data loading problem - query in controller I have a problem loading performance data, it seems because of a query in my controller. I don't know which query is best for my program.
Ask for help for the following query optimization master ...
My query
    select data_barang.kode_barang, data_barang.nama_barang, SUM(COALESCE(barang_masuk.qty,0)) as masuk, COALESCE(i.Keluar,0) as keluar,
    SUM(COALESCE(barang_masuk.qty,0)) - COALESCE(i.Keluar,0) as stok
    FROM data_barang
    LEFT JOIN barang_masuk ON data_barang.kode_barang = barang_masuk.kode_barang
    LEFT JOIN
    (SELECT barang_keluar.kode, SUM(barang_keluar.qty) as keluar from barang_keluar group by barang_keluar.kode)
    AS i ON data_barang.kode_barang = i.kode
    GROUP BY data_barang.kode_barang
    ORDER BY data_barang.kode_barang ASC

Or there are other suggestions for this program to perform faster. Can share here.


text:
Q: I do not receive information from the server I made a table called city. Where I put city names. I'm going to display them in a recyclerView, but I won't get anything on the run.I do not receive information from the server.Where do you think my problem is?
I checked these pages but did not respond:
Not Getting data from server
Get Data from server
my code:
public class CitiesActivity extends AppCompatActivity {
    private static final String url= "http://localhost/alibaba/getcity.php";
    ImageView imgBack;
    EditText edtSearch;
    RecyclerView recyclerView;
    List<String> cities;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cities);

        setupViews();
        getAllCity();
    }

    private void getAllCity() {
        JsonArrayRequest jsonArrayRequest=new JsonArrayRequest(Request.Method.GET, url, null, new Response.Listener<JSONArray>() {
            @Override
            public void onResponse(JSONArray response) {
                for (int i=0;i<response.length();i++){
                    try {
                      JSONObject jsonObject= response.getJSONObject(i);
                      String city=jsonObject.getString("title");
                      cities.add(city);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
                recyclerView.setAdapter(new CitiesAdapter(cities));

            }

        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

            }
        });
        RequestQueue requestQueue= Volley.newRequestQueue(this);
        requestQueue.add(jsonArrayRequest);
    }
    private void setupViews() {
        cities=new ArrayList<>();
        edtSearch=(EditText)findViewById(R.id.edt_cities_search);
        imgBack=(ImageView)findViewById(R.id.img_cities_back);
        recyclerView=(RecyclerView)findViewById(R.id.rv_cities_city);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
    }
}

my adapter:
public class CitiesAdapter extends RecyclerView.Adapter<CitiesAdapter.citiesvewHolder> {

    private List<String>cities;
    public CitiesAdapter(List<String> cities){
        this.cities=cities;
    }

    @NonNull
    @Override
    public citiesvewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view= LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.city_item,viewGroup,false);
        return new citiesvewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull citiesvewHolder citiesvewHolder, int i) {
                 String city=cities.get(i);
                   citiesvewHolder.txtTitle.setText(city);
                  citiesvewHolder.parent.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View view) {
            }
              });
                }

    @Override
    public int getItemCount() {
        return cities.size();
    }

    public class citiesvewHolder extends RecyclerView.ViewHolder{
    TextView txtTitle;
    RelativeLayout parent;

    public citiesvewHolder(@NonNull View itemView) {
        super(itemView);
        txtTitle=(TextView)itemView.findViewById(R.id.txt_cityItem_title);
        parent=(RelativeLayout)itemView.findViewById(R.id.rel_cityItem_parent);
    }
}
}

my php code:
   <?php
    include "connect.php";
    $query="SELECT * FROM city";
    $res=$connect->prepare($query);
    $res->execute();
    $products=array();
    while($row=$res->fetch(PDO::FETCH_ASSOC)){
        $record=array();
        $record["id"]=$row["id"];
        $record["title"]=$row["city"];

        $products[]=$record;
    }
    echo JSON_encode($products);

    ?>

my logcast:
10-10 09:57:26.228 16147-16147/com.example.alibaba E/RecyclerView: No adapter attached; skipping layout

10-10 09:57:26.245 16147-16147/com.example.alibaba E/RecyclerView: No adapter attached; skipping layout

10-10 09:57:26.296 16147-16147/com.example.alibaba E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length

10-10 09:57:26.296 16147-16147/com.example.alibaba E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length

10-10 09:57:26.299 16147-16147/com.example.alibaba E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length

10-10 09:57:26.299 16147-16147/com.example.alibaba E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length

10-10 09:57:26.389 16147-16147/com.example.alibaba E/RecyclerView: No adapter attached; skipping layout

10-10 09:57:26.423 16147-16147/com.example.alibaba E/RecyclerView: No adapter attached; skipping layout

10-10 09:57:26.605 16147-16147/com.example.alibaba E/RecyclerView: No adapter attached; skipping layout


text:
Q: How can you get a XAML TextBlock to collapse when it contains no data? I want to tell WPF: "If TextBlock contains no data, then don't show it."
TRY #1 with a simple trigger produces the error "'Text' member is not valid because it does not have a qualifying type name.":
<StackPanel Margin="10">
    <TextBlock Padding="10" Background="Yellow" Text="{Binding MainMessage}">
        <TextBlock.Triggers>
            <Trigger Property="Text" Value="{x:Null}">
                <Setter Property="Visibility" Value="Collapsed"/>
            </Trigger>
        </TextBlock.Triggers>
    </TextBlock>
</StackPanel>

TRY #2 with a style trigger produces the error The type 'style' does not contain a public type-converter class:
<UserControl x:Class="TestItemsSource234.Views.SmartForm"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <UserControl.Resources>
        <Style x:Key="MainMessageStyle" TargetType="TextBlock">
            <Style.Triggers>
                <Trigger>
                    <Trigger Property="Text" Value="{x:Null}">
                        <Setter Property="Visibility" Value="Collapsed"/>
                    </Trigger>
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <StackPanel Margin="10">
        <TextBlock Style="MainMessageStyle" Padding="10" Background="Yellow" Text="{Binding MainMessage}"/>
    </StackPanel>
</UserControl>

TRY #3 with a style DataTrigger produces the same error The type 'style' does not contain a public type-converter class:
<UserControl x:Class="TestItemsSource234.Views.SmartForm"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <UserControl.Resources>
        <Style x:Key="MainMessageStyle" TargetType="TextBlock">
            <Style.Triggers>
                <Trigger>
                    <DataTrigger Binding="{Binding MainMessage}" Value="{x:Null}">
                        <Setter Property="Visibility" Value="Collapsed"/>
                    </DataTrigger>
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <StackPanel Margin="10">
        <TextBlock Style="MainMessageStyle" Padding="10" Background="Yellow" Text="{Binding MainMessage}"/>
    </StackPanel>
</UserControl>

TRY #4: OK, that was a dumb oversight of mine, forgot the StaticResource, but even then both Try #2 and Try #3 get a new error The type System.Windows.Trigger in Style is unknown:
<UserControl x:Class="TestItemsSource234.Views.SmartForm"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <UserControl.Resources>
        <Style x:Key="MainMessageStyle" TargetType="TextBlock">
            <Style.Triggers>
                <Trigger>
                    <Trigger Property="Text" Value="">
                        <Setter Property="Visibility" Value="Collapsed"/>
                    </Trigger>
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <StackPanel Margin="10">
        <TextBlock Style="{StaticResource MainMessageStyle}" Padding="10" Background="Yellow" Text="{Binding MainMessage}"/>
    </StackPanel>
</UserControl>

So how do I do this?
ANSWER:
OK, so that was a maddening syntax hunt with a happy end, here's the version that works, hope it helps somebody, lessons learned:

*

*if trigger, then style

*if style, then StaticResource

*if binding, then DataTrigger
code that works:
<UserControl x:Class="TestItemsSource234.Views.SmartForm"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <UserControl.Resources>
        <Style x:Key="MainMessageStyle" TargetType="TextBlock">
            <Style.Triggers>
                <DataTrigger Binding="{Binding MainMessage}" Value="{x:Null}">
                    <Setter Property="Visibility" Value="Collapsed"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <StackPanel Margin="10">
        <ItemsControl
            ItemsSource="{Binding DataTypeViews}"/>
        <TextBlock Style="{StaticResource MainMessageStyle}" Padding="10" Background="Yellow" Text="{Binding MainMessage}"/>
    </StackPanel>
</UserControl>

A: The easiest, simplest and quickest way are converters. So, why not KISS? (keep it simple, stupid)?
To implement converter classes only a few lines of code are necessary.
Converter:
public class StringToVisibilityConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return string.IsNullOrWhiteSpace((string)value) ? Visibility.Collapsed : Visibility.Visible;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        var visiblity = (Visibility)value;
        return visiblity == Visibility.Visible;
    }
}

Usage:
Include namespace:
xmlns:c="clr-namespace:Hfr.Windows.Controls"
Define resource:
<c:StringToVisibilityConverter x:Key="StringToVisiblity"/>
Use it:
<TextBlock
    Text="{Binding SomeStringPropertyValue}"
    TextWrapping="Wrap"
    Visibility="{Binding SomeStringPropertyValue, Converter={StaticResource StringToVisiblity}}" />

Since you'll use your converters in multiple projects, implement the converter classes in a "common library".

A: Either Try #2 or Try #3 should be fine - the problem is in the line where you are referencing the style - you need to use either 'Style="{StaticResource [KeyName]}"' or 'Style="{DynamicResource [KeyName]}"'.
Try this (in Try #2):
<StackPanel Margin="10">
    <TextBlock Style="{StaticResource MainMessageStyle}" Padding="10" Background="Yellow" Text="{Binding MainMessage}"/>
</StackPanel>

In Try 1 you reveal a limitation of current WPF versions: Triggers are not supported directly on elements.

A: I think the simplest way to do this would be to define a Converter which converts string to visibility.
   ...

   return string.IsNullOrEmpty(s) ? Visibility.Collapsed : Visibility.Visible;
}

Then just
<TextBlock Visibility="{StaticResource StringToVisibilityConverter}"


text:
Q: Reading description about Dataset in pandas The below code shows error as:
TypeError: data type "" not understood
The code i wrote is as below:
>train = pandas.read_csv('train.csv)
>train.describe(include = ['0'])

Can anybody tell me where am i wrong and what is this error?


text:
Q: Change spring cloud loadbalancer default RoundRobin Algorithm I'm trying to migrate from Ribbon to Spring Cloud LoadBalancer because Ribbon is now in maintenance mode, and I can't add ribbon dependency in spring initialize using the default spring-boot 2.4.2 version. I'm currently using OpenFeign and I'm doing some test trying to change the default RoundRobin Load Balancer configuration to Random Rule. This is what I have
When using Ribbon I just had to change the default configuration
@Configuration
public class RibbonConfiguration {

    @Bean
    public IRule loadBalancingRule() {
//        return new RoundRobinRule();
        return new RandomRule();
    }

}

And add the annotation @RibbonClient in the client (also works adding it in the MainApplication class)
@FeignClient("first-service")
@RibbonClient(name = "first-service", configuration = RibbonConfiguration.class)
public interface HelloClient {
    @GetMapping("/hello")
    String hello();
}

But I can't make it works using spring-cloud-loadbalancer. I know is included by default in the spring-cloud-starter-openfeign dependency so my pom is like this
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.demo</groupId>
    <artifactId>edge-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>edge-service</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>11</java.version>
        <spring-cloud.version>2020.0.1</spring-cloud.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Having my FeignClients like this (without any Ribbon annotation)
@FeignClient("first-service")
public interface HelloClient {
    @GetMapping("/hello")
    String hello();
}

@FeignClient("second-service")
public interface WorldClient {
    @GetMapping("/world")
    String world();
}

And my RestController like this
@RestController
public class HelloWorldController {
    @Autowired
    private HelloClient helloClient;
    @Autowired
    private WorldClient worldClient;

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @GetMapping("/hello-world")
    public String helloWorld() {
        logger.info("Calling the clients");
        return helloClient.hello() + " - " + worldClient.world();
    }
}

Without doing anything else it seems to works the load balancing (with two instance of hello-service running still working and is calling alternate), but I want to change the default loadbalancer algorithm (RoundRobin) to anotherone (like random or anyone custom) to test the difference. I suppose I have to change something in the FeignConfiguration class, but I have searched without success.
Hope you can help me so I can get rid of Ribbon and start using Spring Cloud LoadBalancer without problems ! :C

A: Ribbon configuration will not work for Spring Cloud LoadBalancer. If you add spring-cloud-starter-loadbalancer, the default RoundRobin bean will be created for you, so you do not need to set it up. However, if you want switch to the Random algorithm, you will need to add the bean to override the default one to your configuration, like so:
public class CustomLoadBalancerConfiguration {

@Bean
ReactorLoadBalancer<ServiceInstance> randomLoadBalancer(Environment environment,
        LoadBalancerClientFactory loadBalancerClientFactory) {
    String name = environment.getProperty(LoadBalancerClientFactory.PROPERTY_NAME);
    return new RandomLoadBalancer(loadBalancerClientFactory
            .getLazyProvider(name, ServiceInstanceListSupplier.class),
            name);
  }
}

You can read more about it here.
Once you have your LoadBalancer configuration class with the new bean added, you can set your clients to use it with the @LoadBalancerClient or @LoadBalancerClients annotation. You can read in detail how to do it in the docs.

A: I think you just need to create bean of type ReactorServiceInstanceLoadBalancer and it will get used in place of the default RoundRobin bean.
@Configuration
public class LoadBalancingConfiguration {

    @Bean
    public ReactorLoadBalancer<ServiceInstance> reactorServiceInstanceLoadBalancer(Environment environment,
        LoadBalancerClientFactory loadBalancerClientFactory) {
      String name = environment.getProperty(LoadBalancerClientFactory.PROPERTY_NAME);
      return new RandomLoadBalancer(
          loadBalancerClientFactory.getLazyProvider(name, ServiceInstanceListSupplier.class), name);
    }

}

The example above is copied from default bean creation in the LoadBalancerClientConfiguration class from the spring-cloud-loadbalancer project
@Bean
@ConditionalOnMissingBean
public ReactorLoadBalancer<ServiceInstance> reactorServiceInstanceLoadBalancer(Environment environment,
        LoadBalancerClientFactory loadBalancerClientFactory) {
    String name = environment.getProperty(LoadBalancerClientFactory.PROPERTY_NAME);
    return new RoundRobinLoadBalancer(
            loadBalancerClientFactory.getLazyProvider(name, ServiceInstanceListSupplier.class), name);
}

I'm trying to work out how all this works at the moment so that I can get the load balancing code to use a wiremock server for my tests without needing a discovery server as well. But, I've not found much useful documentation that explains how you migrate from ribbon to the spring load balancer.
The following works for me to get everything to use wiremock in my tests. Assuming I have wiremock server running locally and listening on port 9999.
@Bean
public RoundRobinLoadBalancer loadBalancer() {
  DefaultServiceInstance wiremock = new DefaultServiceInstance("", "", "localhost", 9999, false);
  return new RoundRobinLoadBalancer(ServiceInstanceListSuppliers.toProvider("", wiremock), "");
}


text:
Q: How can I sort an array by two criteria? I have an array I want to echo alphabetized while ignoring the number that starts each string, as such:
0 Apple
1 Apple
3 Apple
0 Banana
1 Banana
0 Carrot
//...

When I sort, the number is sorted first.  So, I've tried asort, sort_string with no success.
$file = file("grades.txt");
asort($file, SORT_STRING);

Can I look only at the alphabet characters and ignore numbers? Or can I ignore the first character and sort starting with the second character?  What should I do to get the above result?
It would be great if the numbers could be in order AFTER the arrays are echoed alphabetically, but it is not demanded if too difficult to do.

A: Maybe try php's uasort function.
http://php.net/manual/en/function.uasort.php
function cmp($a, $b) {
    if ($a[2] == $b[2]) {
        return 0;
    }
    return ($a[2] < $b[2]) ? -1 : 1;
}
uasort($array, 'cmp');

A: You can swap the position of the alphabetic part and numeric part, and use strcmp() to compare the string in usort().
http://php.net/manual/en/function.usort.php
usort($arr, function($a, $b) {
    $a = $a[2].' '.$a[0];
    $b = $b[2].' '.$b[0];
    return strcmp($a, $b);
});

A: For this you need a custom order function, which you can do with uasort(), e.g.
Simply explode() your string by a space and save the number and the string in a variable. Then if string is the same order the elements by the number. Else sort by the string.
uasort($arr, function($a, $b){
    list($numberA, $stringA) = explode(" ", $a);
    list($numberB, $stringB) = explode(" ", $b);

    if(strnatcmp($stringA, $stringB) == 0)
        return $numberA < $numberB ? -1 : 1;
    return strnatcmp($stringA, $stringB);

});

A: You can use preg_replace() to remove numbers from beginning of strings, preg_replace() accepts third param ( subject ) as an array ( the search and replace is performed on every item ).
$file = preg_replace( '/^[\d\s]+/', '', file("grades.txt") );

arsort( $file );

EDIT:
Use preg_replace( '/^([\d\s]+)(.+)/', '$2 $1', file("grades.txt") ) to shift the numbers to the end of string.


text:
Q: VisualGDB c++ to RaPi Poco no such file or directory I am taking over a project and am pretty new with this entire setup (linux/gdb/c++). This project did work at 1 point, on RaPi 1.
Using VisualGdb to compile a c++ program to run on a RaspberryPi 2. I've seen similar questions, but either the answers didn't work or I don't fully understand how to implement.
When I try to compile, I get a fatal error: library name: No such file or directory.
2 that I know of so far are:
include "Poco/Data/Common.h"
include "Poco/Data/SQLite/Connector.h"
I have a similar program that uses different poco libraries and it compiles fine. If I look in the External Dependencies of the project, I see Common.h and Connector.h. The GDB Makefile settings have pthread PocoFoundation PocoData PocoDatad PocoDataSQLite PocoDataSQLited libraries listed.
Tried a few things, but not really sure how to debug this. I don't seem to be able to find the files on the RaPi using find -iname "Common.h", but I can't find the ones that are working in the other project either using that method.
I've done the Complete Edition install of poco and run sudo apt-get update; sudo apt-get upgrade; sudo rpi-update.
Tried to give as much info as I understand of this, but sure I missed something. Any help/suggestions would be great. Let me know if you need more info on something I didn't include.
Thanx ahead of time.

A: In case anyone else has this issue.
libmysqlclient-dev needs to be installed first for these libraries to get installed with the poco install.


text:
Q: using painteventargs in a c# form; how do I draw a larger image to the Graphics object (with scrollbars as well)? I'm writing some data acquisition code.  As the app acquires data it draws a graph to a content pane.  Everything works perfectly right now for our data comprised of fixed length scans: the graph is just scaled to fit into the graphics object obtained from painteventargs.   We are now implementing a "free scan" that just grows in length as you collect data.  We would like to draw the graph, which is ever increasing in size, to the graphics object from painteventargs but once it grows larger than the graphics object an "out of memory" exception is generated.  Is there a way to grow the graphics object or simply replace it?  We want to be able to use the scroll bars to see all of the data.
Thanks for any help!
Here's a chunk of the code (Note: I understand why I'm getting the out of memory error -- the bitmap is too big.  This was just one attempt to do what I'm trying to do.  I'm asking the question because I'm stumped at the moment.):
    System.Drawing.Graphics G = e.Graphics;
    e.Graphics.Clear(System.Drawing.Color.White);
    Bitmap bm = new Bitmap(10000, 1000);
    Graphics h = Graphics.FromImage(bm);
    h.DrawLine(myPens[0], 0, 0, 1000, 10000);
    G.DrawImage(bm,0,0);

A: What I'd recommend you is calculating average points and graph them instead of every single data point. This is also done by leading chart controls. To not to hide details from the user, you should implement a zooming function which takes only a specific interval of your data. As more as you zoom in the less the interval of time. And the more you Zoom in the more details you can show. Hope this strategy will help you further.