text:
Q: How to add an item to a list after every xth item in Java Wondering what's the most elegant way to achieve the following:
"Add an item after every xth item in a list".
I have this which is working but looks very ugly to me:
ListIterator<Something> it = items.listIterator();
    int i = 0;
    int breakPoint = 3;
    while(it.hasNext()) {
        it.next();
        i++;
        if(i == breakPoint ) {
            it.add(new Something()....);
            i = 0;
        }
    }

I'd prefer doing this without using external libraries and such. Any more elegant ways which also are readable and not relying on tricks?

A: You don't need an iterator, use void add(int index, E element):
for (int i = 3; i < items.size(); i+=3) {
    items.add (i++, new Something());
}

This will start by adding an element at index 3. Note that the original element at index 3 will move to index 4, which is why I have i++ inside the loop (since the next element should be added at index 7, not 6).


text:
Q: unix diff special options How can I diff 2 files so that:

*

*I do not care about any kind of white space (-b option)

*I do not care about position of content. ( ?? )

What I mean by 2 above is: file with a on line1 and b on line2 is equal to another file with b on line1 and a on line2.
Please let me know if the question is still not clear.
thanks.

A: Sort the two files first, then diff them. There's no way to convince diff that the a and b lines are in any way interchangeable. Order is extremely important to diff.
Edit for comment -
Tools like diff do not understand any higher level semantics beyond simply ordered lines. You might try writing a tool that converts your files in to those higher level concepts, one per line, that perhaps diff can then process (vs writing a custom diff, which is kind of a pain). Since you can't sort the entire file, perhaps you sort those small sections where "order doesn't matter", that way they won't matter to diff as well.
The final file doesn't have to necessarily be a proper file format (i.e. compatible with the original syntax), rather simply enough to convey to use the differences you're looking for while still capturing the semantics your after while also leveraging an off the shelf tool like diff.
Example:
File 1:
block thing {
    a
    b
}

block thing 2 {
    c
    d
}

File 2:
block thing {
    b
    c
    a
}

block thing 3 {
    f
    e
}

"sorted" File 1:
block thing {
    a
    b
}

block thing 2 {
    c
    d
}

"sorted" File 2:
block thing {
    a
    b
    c
}

block thing 3 {
    e
    f
}

In the end, ideally, you'll find that Block 3 is "new" as well as the "c" in Block 1.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Prompt user for permissions multiple times in React Native I am writing an image picker in React-Native. For iOS, I would like the image picker to show the user the option of updating their permissions every time it is toggled open.
import CameraRoll from "@react-native-community/cameraroll"

CameraRoll.getPhotos(params)

But the above code will only show the user the permissions prompt once, and every other time it is called per session it will not prompt the user again. I have also tried react-native-permissions but ran into the same problem:
import Permissions from "react-native-permissions"

const res = await Permissions.request(UtilsSystem.RN_PERMISSIONS.CAMERA)

Is there a way to re-prompt a user for camera permissiosn after they have already been shown the prompt once?

A: This is the expected behavior on purpose. Once a user declined a permission, there is no way to trigger the request again. The best option is to guide the user how to enable internally and link to the device permissions.
If the user accepted the permission there is no need to re-prompt as it is permanent.


text:
Q: Lazy_high_chart: why options.xaxis undefined? I work with ror and use lazy_high_chart gem.
my view code is :
%= high_stock("my_id", @h) do |c| %>
   <%="options.rangeSelector= {inputEditDateFormat: '%b %e, %Y',buttons: [{type: 'month',count: 1,text: '1m'}, {type: 'month',count: 3,text: '3m'}, {type: 'month',count: 6,text: '6m'}, {type: 'year',count: 1,text: '1y'}, {type: 'all',text: 'All'}]}"%>
    <%="options.xAxis.events.setExtremes = function() { alert 'ho';}" %>

<%end %>

The rangeSelector setting is o.k but when I add the xaxis events(or xaxis.other parameter)
I got an error
"options.xAxis  is undefined"
In the  gem readme file I saw very similar exemple:
https://github.com/michelson/lazy_high_charts
Can you help me?
Thanks in advance

A: you need to add :
   <%="options.xAxis.events = {}" %>

before:
   <%="options.xAxis.events.setExtremes = function() { alert 'ho';}" %>

A: You'd better follow it's steps and use it in controller, not in view.
https://github.com/michelson/lazy_high_charts
e.g.
In controller,
@h = LazyHighCharts::HighChart.new('graph') do |f|
f.options[:chart][:defaultSeriesType] = "area"
f.series(:name=>'John', :data=>[3, 20, 3, 5, 4, 10, 12 ,3, 5,6,7,7,80,9,9])
f.series(:name=>'Jane', :data=> [1, 3, 4, 3, 3, 5, 4,-46,7,8,8,9,9,0,0,9] )
end

In view,
<%= high_chart("my_id", @h) %>


text:
Q: Docker-compose caches my password for mongodb I'm trying to setup my mongodb and with docker. I created a docker-compose file
services:
  mongo:
    image: mongo:latest
    container_name: mongo
    ports: ["27017:27017"]
    env_file: [".env"]
    environment:
      MONGO_INITDB_DATABASE: ${MONGO_INITDB_DATABASE}
      MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME}
      MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
    networks: ["some_network"]
    volumes: [./mongo-volume:/data/db]

volumes:
  mongo-volume:

networks:
  some_network:
    driver: bridge

In my .env I did define my variables:
MONGO_INITDB_ROOT_USERNAME=admin
MONGO_INITDB_ROOT_PASSWORD=hMSZ7!dM!@HA&EF6

Because I'd like to use MongoCompass and had some problems with the '@' I had to change the password, simply removed the '@'.
But I still can not got a connection. Instead I try to use mongo-client and used the old password, well it worked. But I'll like to change my password. I already used docker-compose down and remove the volume and the image. But it is still cached somewhere. Also I logged in to the container and echo the password, this will be the new one.
Additional information:
I use docker on windows with wsl (Ubuntu)
With this I watched through the directory /var/lib/docker/volumes/ what I found was nothing. I guess. on wsl the volumes are mount somewhere else...
So I changed the mount point, and my new password would be accepted.
But where are my volume mounted?


text:
Q: .net StackFrame and current line/column I wrote a method Assert():
[System.Diagnostics.Conditional("DEBUG")]
internal static void Assert(bool condition)
{
    if (!condition)
    {
        var message =
                "Line:" + (new System.Diagnostics.StackFrame(1)).GetFileLineNumber() + "\r\n" +
                "Column:" + (new System.Diagnostics.StackFrame(1)).GetFileColumnNumber() + "\r\n" +
                "Where:" + (new System.Diagnostics.StackFrame(1)).GetMethod().Name;
            Log("ASSERTION", message);
        }
    }

Why do I have both line and column being equal to 0, when triggered? It supposed to be the place where Debug.Assert(false) is called.
Regards,

A: You need to use the StackFrame(int, bool) overload and specify true as the second argument. It looks like just the StackFrame(int) overload doesn't capture source information.
Sample code:
using System.Diagnostics;

...

[Conditional("DEBUG")]
internal static void Assert(bool condition)
{
    if (!condition)
    {
        StackFrame frame = new StackFrame(1, true);
        var message = string.Format("Line: {0}\r\nColumn: {1}\r\nWhere:{2}",
                                    frame.GetFileLineNumber(),
                                    frame.GetFileColumnNumber(),
                                    frame.GetMethod().Name);
        Log("ASSERTION", message);
    }
}

(Looking at your comments by the way, you will need the PDB files. That's where the debug information is stored. It's not at all clear to me whether this will work in a SQLCLR trigger, to be honest. The above works for me in a console app, but that's all I can say...)


text:
Q: make custom API call with authentication I am trying to develop an application that should eventually replace an existing (non-Ember) one and provide additional functionality.
For a start, for anything not yet implemented in the new app, I want to redirect users to the existing one, using the latter's single-sign-on capability. The workflow I imagined is this:

*

*User logged in to new (Ember) app clicks link or button there

*New app makes an API call to an endpoint that returns an SSO token

*New app generated link including SSO token, opens it (in new or same window)

I use ember-simple-auth to authenticate the user for API calls that return user-specific information, using a JSON web token that contains the user id.
For step 2 above I would need to include that token in the API call, but I am at loss how, and even where to implement the call. Do I need an Ember.Route for this (where I could throw in the AuthenticatedRouteMixin)? I would not consider the SSO token to be part of my model, so that does not seem right. Can I get the session's token somehow and include it in a direct ajax call? Should I?

A: ember-simple-auth provides the SessionService where you can access that information.
My recommendation is to use ember-ajax to make the actual request, and override the ajax service to call the session services authorize method.
Then you need to implement your authorizer to authorize that request.
The detail implementation depends on your authorizer and how you want to include the token in your request. As header, query param, or in the body.


text:
Q: Checking and Unchecking checkboxes according to the data from SQL database is not working properly I have 40 checkboxes , and when a user register his account, for each user 40 rows of data is generated in a sql table like
+----+----------+--------------+---------------------+---------+
| Id | UserName |   Category   |    CheckBoxValue    | Checked |
+----+----------+--------------+---------------------+---------+
| 1  | Sabab    | Emotion      | Maintaining Emotion | no      |
| 2  | Sabab    | Emotion      | Expressing Emotion  | no      |
| 3  | Sabab    | Self Defence | Swimming            | no      |
| .  | xx       | xx           | xx                  | no      |
| 40 | Sabab    | Personality  | Punctuality         | no      |
+----+----------+--------------+---------------------+---------+

and when another user register another 40 rows are generated having the same values of  Category, Checkbox value, Checked value.
Only the ID and UserName Differs.
When a user log into his account he can check some checkboxes and update the database . Suppose ,Sabab after logging int his account , checks  Maintaining Emotion
and Expressing emotion. and then hit the update button, then the checked  value of ID no 1 and 2 will be yes.
and if sabab logs out from his account and later again log into his account then , he should see that Maintaining Emotion and Expressing emotion checkboxes are checked.
To update the database I have used the following code:
  protected void SendButton_Click(object sender, EventArgs e)
        {
            UserManager managerObject=new UserManager();

            if (Session["userType"]==null)
            {
                Response.Write("<script>alert('You have to log in first.');</script>");
            }

            else if (Session["userType"]!=null)
            {
                if (Session["userType"].ToString() == "trainee")
                {
                    if (perceivingEmotionsCheckbox.Checked)
                    {
                       managerObject.UpdateCheckboxValueOfIndexPage(Session["userName"].ToString(), "Maintaining Emotion","yes");

                    }

                    else
                    {
                        managerObject.UpdateCheckboxValueOfIndexPage(Session["userName"].ToString(), "Maintaining Emotion", "no");

                    }

                    if (usingEmotionsCheckbox.Checked)
                    {
                        managerObject.UpdateCheckboxValueOfIndexPage(Session["userName"].ToString(), "Expressing Emotion", "yes");

                    }

                    else
                    {
                        managerObject.UpdateCheckboxValueOfIndexPage(Session["userName"].ToString(), "Using Emotion", "no");

                    }

                    Response.Write("<script>alert('Your choices have been updated');</script>");

 }

 }

to load the checkboxes have used the following method ,LoadCheckboxes() and have put it into the page load method:
 public void LoadCheckBoxes()
        {
             UserManager managerObject=new UserManager();

             if (managerObject.CheckBoxChecked(Session["userName"].ToString(), "Maintaining Emotion")=="yes")
             {
                 maintainingEmotionsCheckbox.Checked = true;
             }

             else
             {
                 maintainingEmotionsCheckbox.Checked = false;
             }

             if (managerObject.CheckBoxChecked(Session["userName"].ToString(), "Expressing Emotions")=="yes")
             {
                 expressingEmotionsCheckbox.Checked = true;

             }

             else
             {
                 expressingEmotionsCheckbox.Checked = false;
             }

        }

        protected void Page_Load(object sender, EventArgs e)
        {

            if (Session["userType"] == "trainee")
            {
                if (!IsPostBack)
                {
                    LoadCheckBoxes();
                }

            }

        }

When the user Sabab enters his account , then everything is fine, and , the checkboxes loads according to the checked and unchecked value from database.
    But if Sabab unchecks a checked checkbox, and then  try to reload the page, then the page is not reloaded . it seems that the page is strucked.


text:
Q: How do i compare a value in one hashmap to the same value in another hashmap? Good morning,
Sorry if this has already been asked but i'm stuck on a java project that I'm building.
It is a program that allows the user to insert a bet (for example the predicted result of a sports match) and at a later time allows an user to insert the definitive result of said match.
This is done by 2 LinkedHashMaps. One with a key value pair of User and predicted score and one of User and definitive score.
The order of the keys in both LinkedHashMaps will be the same as they get their input for the key from another Array with the names of the users. So only the predicted and the definitive score gets set every time. (The key gets set by calling .get on the array with the names of the users).
What I want to do is compare the value in the LinkedHashMap with the predicted scores to the value in LinkedHashMap with the definitive score. This however, needs to be compared per key-value pair. So I can't just check for the equality of both LinkedHashMaps. For example, with four users only one can have predicted the right score. If I check the equality of both LinkedHashMaps to another it checks the key-value pairs as a whole. I need to get one boolean result per key-value pair.
I thought of checking the equality of the index posisition of the value but this not how LinkedHashMaps work. The LinkedHashMap Key and the LinkedHashMap value  are both custom objects (the key being an instance of a class with a set string in it, the value being an enum).
How would I go about doing this?
I'm currently thinking of first calling .toArray on both LinedHashMap per " index " posisition and checking the equality of that one to a set amount.. like this; (voorspellingen is LinkedHashMap 1, uitslagen is the other LinkedHashMap)
voorspellingen.keySet().toArray()[0])
uitslagen.keySet().toArray()[0])
if (etc.)

But i'm not sure if this would be the most "effective" way of doing it...

A: I suggest to use just one HashMap, and for the value, use an object that holds both the two results.
class Results
{
    int res1;
    int res2;
}

Use the above class as your value class, and so you just need to iterate over the HashMap for one time to compare whether the two results in the object are equal or not.

A: There are many ways to do this, but probably the most legible is to iterate over the key set of one map:
    var voorspellingen = new LinkedHashMap<String, Integer>(); //ex: <user name, predicted score difference>
    var uitslagen = new LinkedHashMap<String, Integer>();

    //... add data to maps here

    //Let's get a list of the users that gave good predictions
    Predicate<String> correctPrediction = name -> (uitslagen.get(name) != null
                                                && uitslagen.get(name).equals(voorspellingen.get(name)));
    List<String> correctUsers = uitslagen.keySet().stream()
                                        .filter(correctPrediction)
                                        .collect(Collectors.toList());

Note, this solution is not necessarily the fastest. I don't know why you choose LinkedHashMap, but if you have millions of users it might indeed be better to group the prediction and the result in the same object.

A: I would have gone putting in a map instead of two with the values in the form of an object. But the trade off over here would be that we would lose the sequence of the defitive value that comes in.
import java.util.LinkedHashMap;

public class CompareTwoBets {

    public static void main(String[] args) {
        LinkedHashMap<String, Bet> map = new LinkedHashMap<>();
        // First the users add prediction
        map.put("jack", new Bet(1));
        map.put("Bronwen", new Bet(2));
        map.put("Cyrus", new Bet(2));
        map.put("Brent", new Bet(5));

        // now the users key in the definitive value
        Bet bet = map.get("jack");
        bet.setDefinitive(5);
        map.put("jack", bet);

        bet = map.get("Bronwen");
        bet.setDefinitive(5);
        map.put("Bronwen", bet);

        bet = map.get("Cyrus");
        bet.setDefinitive(5);
        map.put("Cyrus", bet);

        bet = map.get("Brent");
        bet.setDefinitive(5);
        map.put("Brent", bet);
        System.out.println(map);

        // process to know who put the bet accurately

        map.forEach((user, x) -> {
            if(x.definitive == x.predicted) {
                System.out.println("User  " + user +" predicted accurately." );
            }
            else {
                System.out.println("User  " + user +" predicted wrongly." );
            }
        });

    }

}

public class User{
    String firstName;
    String lastName;
    public User(String firstName, String lastName){
        this.firstName = firstName;
        this.lastName = lastName;
    }
}

public class Bet {

    int predicted;
    int definitive;

    public Bet(int predicted) {
        this.predicted = predicted;
    }

    public void setDefinitive(int definitive) {
        this.definitive = definitive;
    }
}


text:
Q: NullPointerException when trying to call BroadcastReceiver not called For some reason I am getting NullPointerException. I have gone through all the posts regarding this question. I wonder what am I missing here.
I intend to call a service, which will inturn a alarmmanager to activate a delayed intent that should be called at a particular time (not duration).
Activity Code, calling the service
    autoBookingIntent = new Intent(this,
            ScheduleAdvanceBookingService.class);
    autoBookingIntent.putExtra("startTime", startTime);
    autoBookingIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startService(autoBookingIntent) ;

Manifest
     <service
        android:name="com.taxeeta.ScheduleAdvanceBookingService"
        android:enabled="true"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Light.NoTitleBar" />

ScheduleAdvanceBookingService code
Exception here ==>
package com.taxeeta;

public ScheduleAdvanceBookingService() {
    super("ScheduleAdvanceBookingService");
}

@Override
protected void onHandleIntent(Intent intent) {
    Intent newIntent = new Intent(this, AutoAdvanceBooking.class);
    **==>**newIntent.putExtra("sourceLng",
            intent.getDoubleExtra("sourceLng", (Double) null));
    Date startTime = (Date) intent.getSerializableExtra("startTime");
    newIntent.putExtra("startTime", startTime);
    autoBookingAlarm = (AlarmManager) this
            .getSystemService(Context.ALARM_SERVICE);
    autoBookingPendingIntent = PendingIntent.getBroadcast(this, 0,
            newIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    autoBookingAlarm.set(AlarmManager.RTC_WAKEUP, startTime.getTime(),
            autoBookingPendingIntent);

    God.setAdvanceBookingNotification(this, God.CREATE_NOTIFICATION,
            startTime);
}

Why is intent null ?

A: I feel like crying, it was a silly mistake on my part.
newIntent.putExtra("sourceLng",
            intent.getDoubleExtra("sourceLng", (Double) null));

This results in a NULLPOINTEREXCEPTION.


text:
Q: Java replace text with emoji I made this class that will replace text to emoji. The code works fine at the moment but the look of the emoji isn't quite right.
They are like this:

But I rather have them like this:

I tried multiple different code formats, but nothing seems to work. Maybe I am searching on the wrong thing?
My class:
package user;

import java.util.HashMap;
import java.util.Map;

public class EmojiReplacer {

    private final Map<String, Integer> emojis = new HashMap<String, Integer>() {{
        put(":)", 0x1F60A);
        put(":d", 0x1F604);
        put(";)", 0x1F609);
        put(":o", 0x1F62E);
        put(":p", 0x1F60B);
        put(":$", 0x1F633);
        put(":(", 0x1F615);
        put(":'(", 0x1F625);
        put(":|", 0x1F610);
        put(">:)", 0x1F608);
        put(">:(", 0x1F621);
        put(":]", 0x1F60F);
        put("<3", 0x2764);
    }};

    public String replaceString(String message) {
        String[] messagePieces = message.split("\\s+");
        for (int i = 0; i < messagePieces.length; i++) {
            if (emojis.containsKey(messagePieces[i])) {
                messagePieces[i] = new String(Character.toChars(emojis.get(messagePieces[i])));
            }
        }
        return String.join(" ", messagePieces);
    }
}

A: My guess is that the problem is whatever is rendering the emoji for you, not the string of text that you are rendering.  In other words, your code is working fine.
I just ran your code like this:
public static void main(String[] args) {
    EmojiReplacer test = new EmojiReplacer();
    System.out.println(test.replaceString(":) :d >:) :$"));
}

and I get this:

which looked good both in my IntelliJ output window, and here.  I'm on a Mac.
What is taking the String that your code produces, and producing the actual visual emojis for you?  Since the browser can obviously render them, have you tried copying the emojis that you think look wrong, and pasting them into your browser, like into your message.  The example of a bad emoji you show seems to be a screen shot, not the actual emoji rendered by the browser.


text:
Q: Is there any way to make my ps4 control vibrate/rumble? With java Maybe a library can do this? ;)
I have been searching the internet but can't find anything :(
I use glfw.

A: Dualshock 4 is tricky because it doesn't do rumble in a standard way. But, it's a HID device and you can send HID output reports that will cause it to rumble.
The easiest cross-platform way to send HID reports is to use the signal11/hidapi library. From Java, you'll want a wrapper for this library like hid4java, or you can take a look at what was suggested when this was asked previously.
Once you can access the device from Java and send reports, send a 0x11 output report to tell the device to rumble.
As an alternative, since you're on Windows, you can use a third-party driver to make the DS4 look like an XInput device, and then send rumble commands through the XInput API. I would recommend getting Ryochan's fork of the DS4Windows driver since the original version hasn't been updated in a while. See here for how to use the XInput API from Java.


text:
Q: Unable to send data to POST Service in Spring 4 I'm trying to write a simple HTTP REST service using Spring 4.
I'm having troubles sending data to a POST endpoint
@RequestMapping(value = "/onlyPost", produces = "application/json", method
= RequestMethod.POST)
public @ResponseBody ResponseEntity<?> createUser(@RequestParam("value1")
String param1, @RequestParam("value2") String param2) {
....
}

While trying to send data with Postman, I receive a 400 message (obviously the values are setted in the request's body)
"message": "Required String parameter 'value1' is not present",

What I have noticed is that the issue is somewhat related to the headers, because when I remove the postman's header (Content-Type: application/json) everything works fine.
I tried for more than one hour fixing this by myself with no results. Any hints?

A: HTTP 400 is returned when your request is badly formatted, i.e. missing required request parameters
@RequestParam is for URL Params, if you want to pass them like that, you call
<api_url>/onlyPost?value1=<value1>&value2=<value2>
but... if you want to create user you should rather use @RequestBody and put your user data there. Something like that:
@RequestMapping(value = "/users", produces = "application/json", method
= RequestMethod.POST)
public @ResponseBody ResponseEntity<?> createUser(@RequestBody User user) {
    [...]
}

if you are creating REST api you should use concrete endpoints, here is a pretty cool reading with some tips: http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api

A: @RequestParam is used to read a URL query parameter.
http://localhost:8080/springmvc/onlyPost?value1=foo&value2=bar

For instance, in the URL above, value1 and value2 are query parameters that you can read using that annotation.
But if you want to read a JSON request instead, you need to change the method to:
@RequestMapping(value = "/onlyPost", method = RequestMethod.POST,
    consumes = "application/json")
public @ResponseBody ResponseEntity<?> createUser(@RequestBody User user) {
    ....
}

where User is a POJO holding the two fields:
public class User {
    private String value1;
    private String value2;

    // getters and setters...
}


text:
Q: Command to list services that start on startup? Is there a command to list services that run on startup? I imagine it would involve parsing /etc/init.d/, and the various /etc/rc.* directories.

A: On 12.04 we could use:
sudo apt-get install chkconfig
chkconfig --list

but it was removed in 12.10.
Sample output:
acpi-support              0:off  1:off  2:on   3:on   4:on   5:on   6:off
acpid                     0:off  1:off  2:off  3:off  4:off  5:off  6:off
apparmor                  0:off  1:off  2:off  3:off  4:off  5:off  6:off  S:on

A: Besides system services and scripts under:

/etc/init.d/
/lib/systemd/system/
/etc/systemd/system/

There are probably AutoStart Applications too, for example:
find / -name "*autostart*"

ls -1 "/etc/xdg/autostart" "/home/$USER/.config/autostart" "/usr/share/gdm/autostart"  "/usr/share/gnome/autostart"

A: The quick answer is:  It depends on your init system.
The long answer is:  For current versions of Ubuntu, you probably have a mix of Upstart, and SystemV.  Newer versions of Ubuntu after 15.04 "Vivid Vervet" (and other Linux distros like RHEL/CentOS 7) are moving to use SystemD.
Upstart

*

*Upstart Documentation
To list all services:
sudo initctl list

To list all Upstart services and run initctl show-config on them, this one-liner may be helpful:
sudo initctl list | awk '{ print $1 }' | xargs -n1 initctl show-config

System V

*

*SysV Runlevels Documentation
To list all services:
sudo service --status-all

OR:
# for init scripts:
ls /etc/init.d/

# for runlevel symlinks:
ls /etc/rc*.d/

SystemD

*

*SystemD for Upstart Users

*FedoraProject SystemD Documentation

*RHEL 7: Managing Services with SystemD

*RedHat: SystemD Overview
To list all services:
sudo systemctl --all list-unit-files --type=service

OR:
ls /lib/systemd/system/*.service /etc/systemd/system/*.service

A: For Ubuntu 18.04 use :
systemctl list-units --type=service

instead of initctl.
Since Ubuntu 16.04, initctl has been replaced by systemd (source, in French).
If it can help @sanjay-manohar.

A: The /etc/init.d and /etc/rc.* directories have been superseded by the 'upstart' init tool. Although scripts in these directories will be executed as expected, the new method for running things on init is defined by files in /etc/init/
You can list all of the upstart jobs with by querying upstart over dbus:
dbus-send --print-reply --system --dest=com.ubuntu.Upstart \
        /com/ubuntu/Upstart com.ubuntu.Upstart0_6.GetAllJobs

You may have to change 0_6 to reflect the version of upstart you have. This command works on my lucid install.

A: If you want a nice graphical representation of services and time it takes to boot try:
sudo apt install bootchart

For systemd (since 16.04) try systemd-bootchart instead:
sudo apt install systemd-bootchart

A: You can simply use the initctl list shell command to list the contents of /etc/init rather than the suggested dbus-send command.

A: Id use initctl show-config <servicename> to really get the details of when/if your service will start during boot.
Like so:
$ initctl show-config myservice
myservice
  start on runlevel [2345]
  stop on runlevel [!2345]

Or for NFS4 idmap-daemon:
$ initctl show-config idmapd
idmapd
  start on (local-filesystems or mounting TYPE=nfs4)
  stop on runlevel [06]

chkconfig is only preferable on RedHat based systems imho.

A: Using gawk:
ls -l /etc/rc*.d/* | gawk 'match($0, /rc([0-6S]).d.*\/(.*)$/, a) {l[a[2]]=l[a[2]]a[1]","}; END{for(v in l){print v,substr(l[v],1,length(l[v])-1)}}'

Sample output:
$ ls -l /etc/rc*.d/* | gawk 'match($0, /rc([0-6S]).d.*\/(.*)$/, a) {l[a[2]]=l[a[2]]a[1]","}; END{for(v in l){print v,substr(l[v],1,length(l[v])-1)}}' | egrep README
README 0,1,2,3,4,5,6,S


text:
Q: HttpClient.PostAsXmlAsync With Specific DateTime Formatting I am looking to send XML to a web service using the extension method HttpClient.PostAsXmlAsync<T> in the System.Net.Http.Formatting NuGet package (version 5.2.3). However, it formats dates in the format:
yyyy-MM-ddThh:mm:ss+hh:mm
Whereas the web service states that the XML needs to be formatted in a specific format that does not have the colon (:) in the time zone, so: yyyy-MM-ddThh:mm:ss+hhmm.
Is there a way to override how the HttpClient formats dates when converting the object? I could make the dates strings on the object of type T, but I would prefer not to as the objects' code is actually generated from an XSD supplied.


text:
Q: Opening a fragment with a button I need some help. I've done some extensive searching for the past 4 hours and I'm not sure if it's because I have errors in my code, or if I'm not doing something correctly.
Basically, this is what's going on. I have my main activity 'homepage' which opens to a second activity with a navigation drawer. I assume that the navigation drawer is also an 'activity'. I am trying to open a fragment within that activity with the button, but I keep getting a fatal exception:
10-14 21:36:54.469      799-799/com.example.workstation.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.workstation.app/com.example.workstation.app.navigation_drawer}: java.lang.NullPointerException
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
            at android.app.ActivityThread.access$600(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5103)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at com.example.workstation.app.navigationdrawer.onCreate(navigationdrawer.java:57)

Here is the code I am working with, this one is for the navigation_drawer activity (I believe):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="com.example.workstation.app.navigation_drawer_activity$PlaceholderFragment">

    <TextView
        android:id="@+id/cctr_ct_home"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/cctr_ct"
        android:textSize="40sp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/cctr_search"
        android:drawableTop="@drawable/search"
        android:layout_below="@+id/cctr_ct_home"
        android:layout_alignLeft="@+id/cctr_ct_home"
        android:layout_alignStart="@+id/cctr_ct_home"
        android:layout_marginTop="95dp"
        android:text="Search"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/cctr_favorites"
        android:drawableTop="@drawable/favorites"
        android:layout_alignTop="@+id/cctr_search"
        android:layout_alignRight="@+id/cctr_ct_home"
        android:layout_alignEnd="@+id/cctr_ct_home"
        android:text="Favorite"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/cctr_recent"
        android:drawableTop="@drawable/recent"
        android:layout_below="@+id/cctr_search"
        android:layout_alignLeft="@+id/cctr_search"
        android:layout_alignStart="@+id/cctr_search"
        android:layout_marginTop="37dp"
        android:text="Recent"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/cctr_contactus"
        android:drawableTop="@drawable/email"
        android:layout_alignTop="@+id/cctr_recent"
        android:layout_alignLeft="@+id/cctr_favorites"
        android:layout_alignStart="@+id/cctr_favorites"
        android:text="Contact Us" />

    <fragment android:name="com.example.workstation.cctrmobileapp.cctrct_search"
        android:id="@+id/cctr_ct_search"
        android:layout_weight="2"
        android:layout_width="0dp"
        android:layout_height="match_parent" />

</RelativeLayout>

Now, the navigation drawer works fine, it's opening the fragment from the button I'm having trouble with. I get the error above. Here is the java code from the activity that comes with the navigation drawer:
package com.example.workstation.cctrmobileapp;

import android.app.Activity;
import android.support.v4.app.FragmentTransaction;
import android.content.Intent;
import android.net.Uri;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.support.v4.widget.DrawerLayout;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;

public class cctr_clinical_trials extends ActionBarActivity implements NavigationDrawerFragment.NavigationDrawerCallbacks, cctrct_search.OnFragmentInteractionListener {

    /**
     * Fragment managing the behaviors, interactions and presentation of the navigation drawer.
     */
    private NavigationDrawerFragment mNavigationDrawerFragment;

    /**
     * Used to store the last screen title. For use in {@link #restoreActionBar()}.
     */
    private CharSequence mTitle;

    Button cctrct_searchButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cctr_clinical_trials);

        mNavigationDrawerFragment = (NavigationDrawerFragment)
                getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
        mTitle = getTitle();

        // Set up the drawer.
        mNavigationDrawerFragment.setUp(
                R.id.navigation_drawer,
                (DrawerLayout) findViewById(R.id.drawer_layout));

        cctrct_searchButton = (Button)findViewById(R.id.cctr_search);

        cctrct_searchButton.setOnClickListener( new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                cctrct_search newFragment = new cctrct_search();
                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

                transaction.replace(R.id.container, newFragment);
                transaction.addToBackStack(null);

                transaction.commit();

            }
        });

/*        cctrct_searchButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                FragmentManager searchFragment = getSupportFragmentManager();

                searchFragment.beginTransaction()

                        .replace(R.id.container, cctrct_search.newInstance("test1", "test2"))

                        .commit();
            }

        });*/

    }

and for the heck of it, here is the xml for the fragment that I want to appear after I press the button:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.workstation.cctrmobileapp.cctrct_search">

    <!-- TODO: Update blank fragment layout -->

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Submit"
        android:id="@+id/cctrct_search_submit"
        android:layout_below="@+id/cctrct_p1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="65dp"
        android:layout_gravity="center_horizontal|bottom" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Only the submit button works"
        android:id="@+id/cctr_search_logo"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="43dp"
        android:layout_gravity="center_horizontal|top" />

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Phase III"
        android:id="@+id/cctrct_p3"
        android:layout_toEndOf="@+id/cctrct_search_dsite"
        android:layout_below="@+id/cctrct_search_pnum"
        android:layout_toRightOf="@+id/cctrct_search_dsite"
        android:layout_marginTop="28dp"
        android:layout_gravity="center" />

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Phase II"
        android:id="@+id/cctrct_p2"
        android:layout_toEndOf="@+id/cctrct_p1"
        android:layout_alignTop="@+id/cctrct_p3"
        android:layout_alignLeft="@+id/cctrct_search_keyword"
        android:layout_alignStart="@+id/cctrct_search_keyword"
        android:layout_alignRight="@+id/cctrct_search_dsite"
        android:layout_alignEnd="@+id/cctrct_search_dsite"
        android:layout_gravity="center" />

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Phase I"
        android:id="@+id/cctrct_p1"
        android:layout_toStartOf="@+id/cctrct_search_pnum"
        android:layout_alignTop="@+id/cctrct_p2"
        android:layout_toLeftOf="@+id/cctrct_search_pnum"
        android:layout_gravity="center" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Keyword"
        android:id="@+id/cctrct_search_keyword"
        android:layout_below="@+id/cctrct_search_dsite"
        android:layout_alignRight="@+id/cctrct_search_submit"
        android:layout_alignEnd="@+id/cctrct_search_submit"
        android:layout_marginTop="26dp"
        android:layout_gravity="left|center_vertical" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Disease Site"
        android:id="@+id/cctrct_search_dsite"
        android:layout_below="@+id/cctr_search_logo"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="22dp"
        android:layout_gravity="right|center_vertical" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Protocol Number"
        android:id="@+id/cctrct_search_pnum"
        android:layout_below="@+id/cctrct_search_keyword"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="31dp"
        android:layout_gravity="left|center_vertical" />

</RelativeLayout>

</FrameLayout>

I just figured I would add the rest of the code from my class:
 @Override
    public void onNavigationDrawerItemSelected(int position) {
        // update the main content by replacing fragments
        FragmentManager fragmentManager = getSupportFragmentManager();

        switch (position) {
            case 0: fragmentManager.beginTransaction()
                    .replace(R.id.container, PlaceholderFragment.newInstance(position + 1))
                    .commit(); break;
            case 1: fragmentManager.beginTransaction()
                    .replace(R.id.container, cctrct_search.newInstance("test1", "test2"))
                    .commit(); break;
            case 2: fragmentManager.beginTransaction()
                    .replace(R.id.container, PlaceholderFragment.newInstance(position + 1))
                    .commit(); break;
            case 3: fragmentManager.beginTransaction()
                    .replace(R.id.container, PlaceholderFragment.newInstance(position + 1))
                    .commit(); break;
        }

    }

    public void onSectionAttached(int number) {
        switch (number) {
            case 1:
                mTitle = getString(R.string.cctr_ct_home);
                break;
            case 2:
                mTitle = getString(R.string.cctr_ct_search);
                break;
            case 3:
                mTitle = getString(R.string.cctr_ct_saved);
                break;
            case 4:
                mTitle = getString(R.string.cctr_ct_recent);
                break;
        }
    }

    public void restoreActionBar() {
        ActionBar actionBar = getSupportActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle(mTitle);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        if (!mNavigationDrawerFragment.isDrawerOpen()) {
            // Only show items in the action bar relevant to this screen
            // if the drawer is not showing. Otherwise, let the drawer
            // decide what to show in the action bar.
            getMenuInflater().inflate(R.menu.cctr_clinical_trials, menu);
            restoreActionBar();
            return true;
        }
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onFragmentInteraction(Uri uri) {

    }

    /**
     * A placeholder fragment containing a simple view.
     */
    public static class PlaceholderFragment extends Fragment {
        /**
         * The fragment argument representing the section number for this
         * fragment.
         */
        private static final String ARG_SECTION_NUMBER = "section_number";

        /**
         * Returns a new instance of this fragment for the given section
         * number.
         */
        public static PlaceholderFragment newInstance(int sectionNumber) {
            PlaceholderFragment fragment = new PlaceholderFragment();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            fragment.setArguments(args);
            return fragment;
        }

        public PlaceholderFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_cctr_clinical_trials, container, false);
            return rootView;
        }

        @Override
        public void onAttach(Activity activity) {
            super.onAttach(activity);
            ((cctr_clinical_trials) activity).onSectionAttached(
                    getArguments().getInt(ARG_SECTION_NUMBER));
        }

    }

}

A: It looks like cctrct_searchButton is null which means it is not being found in the view. Is a Button with the id cctr_search present in the activity_cctr_clinical_trials layout xml file?

A: For future users, Mr. Spidy was 100% correct, the onClickListener should have been in the onCreateView and not in the onCreate section:
public PlaceholderFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_cctr_clinical_trials, container, false);

            Button cctrct_searchButton;

            cctrct_searchButton = (Button)rootView.findViewById(R.id.cctr_search);

            cctrct_searchButton.setOnClickListener( new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    Fragment newFragment = new cctrct_search();
                    FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();

                    transaction.replace(R.id.container, newFragment);
                    transaction.addToBackStack(null);

                    transaction.commit();
                }
            });

            return rootView;

        }

THANKS AGAIN MR. SPIDY


text:
Q: SVG pattern set as background-image, blurry in Safari but not Firefox? I have a SVG that I want to use as the background for a website, I made it so that the SVG itself repeats and fills up the screen. I also rotated the pattern -25 degrees in order to achieve the effect that I wanted. I took the whole SVG, encoded it using an online URL-encoder and made it the background-image of an element.
Problem:
The pattern looks great on Firefox, but on Safari, the SVG pattern looks blurry/pixelated on both macOS and iOS.

*

*Screenshot of SVG Pattern on Firefox

*Screenshot of SVG Pattern on Safari

*Example up on CodePen

<svg version="1.1" id="BlackOnBlackPattern" width="100%" height="100%" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
   <defs id="defs7"/>
     <pattern id="pattern" x="0" y="0" width="512" height="512" patternTransform="rotate(-25)" patternUnits="userSpaceOnUse">
        <path id="blackSquare" style="fill:#000000" d="M 0,384 V 256 H 128 256 V 128 0 H 384 512 V 128 256 H 384 256 V 384 512 H 128 0 Z" />
        <path id="logoBird" style="fill:#000000;stroke-width:0.680128" d="m 129.64298,40.000872 c -9.21804,0.03838 -18.59563,1.456395 -27.85009,4.403021 C 88.498002,48.636982 77.894858,54.853476 67.654423,64.420807 50.405565,80.535864 41.234652,100.07299 40.094015,123.13291 c -1.213221,24.52736 9.377815,49.56649 28.161493,66.57969 3.057867,2.76963 7.493507,6.27893 9.856924,7.79847 5.872595,3.77573 6.702193,3.52936 8.86867,-2.63686 l 1.75857,-5.00519 0.0094,-26.02708 c 0.01049,-25.11511 0.06724,-26.21112 1.596113,-31.29034 1.942724,-6.45424 3.259875,-8.96541 7.347003,-14.00287 1.748214,-2.15469 3.178692,-4.26503 3.178692,-4.68976 0,-1.77256 -2.232527,-3.61866 -5.268931,-4.35481 -5.352708,-1.2977 -8.390585,-3.15065 -10.296911,-6.28258 -0.969515,-1.59281 -1.762633,-3.71266 -1.762633,-4.710626 0,-1.741713 0.06183,-1.772779 1.540606,-0.77554 2.011443,1.356475 13.522274,1.471495 15.393929,0.153803 2.11787,-1.491029 0.75915,-3.647459 -3.418319,-5.426211 -4.481984,-1.908443 -5.962952,-3.925071 -6.701249,-9.122771 -0.309343,-2.177873 -1.041901,-4.852565 -1.627256,-5.942377 -1.298632,-2.417897 -0.58623,-2.540303 3.549635,-0.612624 1.61468,0.752577 3.77541,2.430399 4.803231,3.727843 2.371759,2.993897 5.619358,4.908066 8.328508,4.911355 4.6624,0.0069 5.03416,-3.701391 1.00451,-10.007812 -2.9553,-4.625079 -3.87886,-8.484827 -1.55956,-6.518495 0.66714,0.565614 2.84522,1.815329 4.83977,2.777632 4.37796,2.112169 5.50175,3.634048 6.49278,8.795604 1.2003,6.251496 2.82391,8.292483 6.59698,8.292483 2.84562,0 5.81535,-2.461849 5.79964,-4.807082 -0.007,-0.842555 -0.44966,-3.332537 -0.98691,-5.531802 -0.53735,-2.199255 -0.8713,-4.099913 -0.74188,-4.224447 0.12941,-0.124524 0.90057,0.116604 1.71392,0.535716 1.73794,0.895544 2.10334,1.743493 5.30683,12.334451 1.91179,6.320658 2.86585,8.424307 4.47695,9.868342 2.648,2.373347 6.04559,2.461492 8.74547,0.225493 2.97024,-2.459893 2.67974,-5.99289 -1.06407,-12.965321 -1.64383,-3.061467 -2.82293,-5.725786 -2.62093,-5.920227 1.25067,-1.204157 17.29143,15.096115 19.8357,20.156394 1.68357,3.348439 1.84464,9.344059 0.34388,12.802389 -0.5751,1.3251 -2.13462,3.86784 -3.46572,5.65172 -1.33106,1.78385 -2.42058,3.50646 -2.42058,3.82818 0,0.32172 1.07814,2.30811 2.39486,4.41346 1.31674,2.10535 2.75411,5.5202 3.19493,7.58861 0.68757,3.2263 1.32054,4.23465 4.45535,7.09723 2.00968,1.83527 4.78314,4.78598 6.16242,6.55759 4.446,5.71057 3.01595,7.53159 -4.77075,6.07665 -6.79305,-1.26938 -10.29442,-1.20507 -11.62362,0.21237 -1.41968,1.51408 -2.85846,7.05014 -2.33796,8.99633 0.22293,0.83343 2.63244,4.21456 5.35422,7.51433 5.26001,6.37714 9.23075,13.38707 13.42281,23.69783 1.41767,3.48697 2.84312,6.60571 3.16787,6.93039 1.83629,1.83572 21.15877,-15.28758 27.28826,-24.18271 9.79595,-14.21573 14.73692,-28.73015 15.48329,-45.4796 0.40615,-9.11498 -0.41442,-16.89883 -2.64663,-25.10423 C 206.51682,65.570109 169.58784,39.834701 129.6429,40.000799 Z m 0.33981,4.057607 c 36.17205,0 68.93348,22.414671 80.94839,55.383139 3.53162,9.690692 4.59635,15.932242 4.60423,27.028102 0.0157,18.46361 -5.07202,33.85913 -16.0302,48.5127 -3.85717,5.15791 -13.59136,14.74323 -18.05954,17.78415 -2.11881,1.44201 -2.28261,1.46091 -2.70215,0.31932 -3.50764,-9.54505 -9.09707,-19.53483 -14.83073,-26.50674 -4.34649,-5.28507 -4.83345,-6.16553 -4.43096,-8.00832 0.24864,-1.13873 0.7098,-2.33408 1.02481,-2.65772 0.32987,-0.33872 2.80982,-0.26806 5.84701,0.16672 8.20879,1.17551 10.56234,1.00878 12.52796,-0.88373 1.0007,-0.96348 1.70018,-2.40634 1.69494,-3.50364 -0.0109,-2.84955 -3.57141,-8.21029 -8.18636,-12.32403 -3.63685,-3.24184 -4.28996,-4.21322 -5.24188,-7.79064 -0.5981,-2.24781 -1.85041,-5.53441 -2.78202,-7.3045 l -1.6936,-3.21818 2.13495,-3.29899 c 5.06087,-7.81999 5.80285,-14.26131 2.38807,-20.726001 -2.14527,-4.061307 -9.83387,-12.634487 -16.14527,-18.003103 -5.97051,-5.07863 -7.46455,-5.881945 -9.23688,-4.968703 -2.88894,1.488611 -2.64115,5.765255 0.70261,12.142828 2.28346,4.355264 2.63543,7.717995 0.87588,8.368074 -1.87962,0.694468 -3.52211,-2.050447 -6.21386,-10.384504 -3.09619,-9.586068 -3.91124,-11.1484 -6.47924,-12.426968 -2.68712,-1.337803 -7.55948,-1.342868 -8.09159,-0.0075 -0.22031,0.552842 0.13125,2.897052 0.78115,5.208535 1.35351,4.814278 1.20574,7.361666 -0.44405,7.664219 -1.22299,0.224294 -2.16489,-1.933526 -2.99998,-6.870423 -0.70793,-4.185096 -3.24541,-7.302962 -7.61777,-9.362597 -2.12525,-1.001114 -4.50175,-2.683158 -5.28112,-3.736961 -1.00434,-1.357979 -2.00419,-1.916059 -3.43321,-1.916059 -4.824851,0 -5.601177,7.643229 -1.4147,13.924639 2.73023,4.096455 2.53457,5.790327 -0.31679,2.745051 -5.734741,-6.124736 -9.02434,-7.955952 -14.336614,-7.979657 -2.687222,-0.01211 -3.469626,0.26897 -4.348368,1.560213 -1.158629,1.702511 -0.881886,3.055999 1.1805,5.782056 0.700599,0.926068 1.467598,3.32856 1.704422,5.338877 0.47155,4.00334 2.492113,8.512228 4.077607,9.098016 0.554603,0.204899 1.008572,0.640669 1.008572,0.968442 0,1.02671 -2.337887,0.643076 -4.505404,-0.739036 -4.299778,-2.741716 -7.289226,-0.825576 -7.261714,4.653276 0.03057,6.066906 5.149227,12.492876 11.203944,14.062826 5.903135,1.53062 5.773001,1.21032 2.306849,5.64258 -3.726939,4.76572 -5.565838,9.13762 -7.439059,17.68505 -1.288518,5.87941 -1.358435,7.93967 -0.958482,28.36286 0.346564,17.69787 0.241462,22.78845 -0.538804,25.92018 -0.534035,2.1434 -1.269046,4.18327 -1.632669,4.53336 -0.970853,0.93473 -8.098208,-4.46368 -14.499065,-10.98151 C 40.16197,155.12747 36.462617,113.16696 58.812837,80.896297 74.584479,58.124198 101.75849,44.058494 129.98279,44.058494 Z m 13.07894,82.854411 c -0.24205,-0.0125 -0.49103,-0.007 -0.74728,0.0177 -4.62221,0.44466 -6.0251,6.12215 -2.02663,8.20124 2.16058,1.12347 4.1384,0.74217 5.81046,-1.11966 2.53349,-2.82102 0.59395,-6.92306 -3.03655,-7.09984 z m -0.54017,2.77632 c 0.94864,0.0789 1.95196,1.17436 1.55551,2.16893 -0.20879,0.52378 -0.82431,0.95151 -1.36731,0.95151 -1.30519,0 -2.02119,-1.89781 -1.06408,-2.81934 0.25019,-0.24087 0.55968,-0.32736 0.87588,-0.3011 z" />
        <path id="logoBird-5" style="fill:#000000;stroke-width:0.680128" d="m 389.64318,300.00088 c -9.21807,0.0383 -18.59568,1.4564 -27.85016,4.40302 -13.29492,4.23309 -23.89808,10.44958 -34.13854,20.01692 -17.2489,16.11505 -26.41983,35.65218 -27.56047,58.71209 -1.21322,24.52736 9.37784,49.56649 28.16156,66.57969 3.05787,2.76963 7.49352,6.27894 9.85694,7.79847 5.87261,3.77573 6.70221,3.52937 8.86869,-2.63686 l 1.75858,-5.00519 0.009,-26.02708 c 0.0105,-25.1151 0.0672,-26.21112 1.59611,-31.29034 1.94273,-6.45424 3.25988,-8.9654 7.34702,-14.00287 1.74822,-2.15469 3.1787,-4.26503 3.1787,-4.68976 0,-1.77256 -2.23253,-3.61866 -5.26894,-4.35481 -5.35272,-1.2977 -8.3906,-3.15065 -10.29694,-6.28257 -0.96951,-1.59282 -1.76263,-3.71267 -1.76263,-4.71063 0,-1.74171 0.0618,-1.77278 1.54061,-0.77554 2.01144,1.35647 13.5223,1.47149 15.39395,0.1538 2.11788,-1.49103 0.75915,-3.64745 -3.41831,-5.4262 -4.482,-1.90845 -5.96297,-3.92507 -6.70127,-9.12277 -0.30935,-2.17788 -1.04191,-4.85258 -1.62726,-5.94239 -1.29863,-2.41789 -0.58624,-2.54029 3.54964,-0.61262 1.61469,0.75258 3.77542,2.43041 4.80325,3.72785 2.37176,2.9939 5.61936,4.90806 8.32852,4.91135 4.66241,0.007 5.03417,-3.70139 1.00451,-10.00781 -2.95531,-4.62508 -3.87887,-8.48483 -1.55957,-6.51849 0.66715,0.56561 2.84524,1.81532 4.83979,2.77762 4.37797,2.11217 5.50176,3.63405 6.49279,8.7956 1.2003,6.25151 2.82392,8.29249 6.597,8.29249 2.84562,0 5.81536,-2.46184 5.79965,-4.80708 -0.007,-0.84255 -0.44967,-3.33253 -0.98691,-5.5318 -0.53736,-2.19926 -0.8713,-4.09992 -0.74189,-4.22445 0.12942,-0.12453 0.90058,0.11661 1.71393,0.53572 1.73795,0.89554 2.10335,1.74349 5.30684,12.33445 1.91179,6.32066 2.86586,8.4243 4.47696,9.86834 2.64801,2.37334 6.0456,2.46149 8.7455,0.22549 2.97024,-2.45989 2.67974,-5.99288 -1.06408,-12.96532 -1.64384,-3.06146 -2.82294,-5.72578 -2.62094,-5.92023 1.25068,-1.20416 17.29147,15.09612 19.83575,20.1564 1.68357,3.34843 1.84465,9.34405 0.34388,12.80238 -0.57511,1.3251 -2.13462,3.86784 -3.46572,5.65172 -1.33107,1.78386 -2.42059,3.50646 -2.42059,3.82818 0,0.32172 1.07813,2.30811 2.39486,4.41346 1.31674,2.10535 2.75412,5.5202 3.19494,7.58862 0.68757,3.22629 1.32054,4.23464 4.45536,7.09722 2.00968,1.83527 4.78315,4.78599 6.16244,6.5576 4.446,5.71057 3.01595,7.53158 -4.77077,6.07665 -6.79306,-1.26938 -10.29444,-1.20508 -11.62365,0.21236 -1.41968,1.51408 -2.85846,7.05014 -2.33796,8.99633 0.22293,0.83344 2.63245,4.21456 5.35424,7.51433 5.26001,6.37714 9.23076,13.38708 13.42284,23.69783 1.41766,3.48697 2.84312,6.60572 3.16787,6.93039 1.83629,1.83572 21.15881,-15.28758 27.28833,-24.18271 9.79596,-14.21573 14.73695,-28.73014 15.48332,-45.4796 0.40615,-9.11498 -0.41443,-16.89883 -2.64664,-25.10423 -10.73614,-39.46578 -47.66521,-65.20119 -87.61023,-65.0351 z m 0.33981,4.05761 c 36.17213,0 68.93363,22.41467 80.94857,55.38313 3.53163,9.69069 4.59636,15.93225 4.60424,27.0281 0.0157,18.46361 -5.07203,33.85913 -16.03024,48.5127 -3.85718,5.15791 -13.59139,14.74323 -18.05958,17.78415 -2.11881,1.44201 -2.28262,1.46091 -2.70216,0.31932 -3.50765,-9.54505 -9.09709,-19.53483 -14.83076,-26.50674 -4.3465,-5.28507 -4.83346,-6.16553 -4.43096,-8.00832 0.24863,-1.13873 0.7098,-2.33408 1.0248,-2.65771 0.32987,-0.33873 2.80983,-0.26807 5.84703,0.16672 8.20881,1.17551 10.56236,1.00878 12.52798,-0.88374 1.0007,-0.96348 1.70019,-2.40634 1.69495,-3.50364 -0.0109,-2.84955 -3.57142,-8.21029 -8.18638,-12.32403 -3.63686,-3.24184 -4.28997,-4.21322 -5.24189,-7.79064 -0.5981,-2.24781 -1.85042,-5.53441 -2.78202,-7.3045 l -1.69361,-3.21818 2.13495,-3.29899 c 5.06089,-7.81999 5.80286,-14.26131 2.38808,-20.726 -2.14528,-4.0613 -9.8339,-12.63448 -16.1453,-18.0031 -5.97053,-5.07863 -7.46457,-5.88194 -9.23691,-4.9687 -2.88894,1.48861 -2.64115,5.76525 0.70262,12.14283 2.28345,4.35527 2.63543,7.718 0.87588,8.36808 -1.87963,0.69446 -3.52212,-2.05045 -6.21388,-10.38451 -3.0962,-9.58607 -3.91125,-11.1484 -6.47925,-12.42696 -2.68713,-1.33782 -7.55951,-1.34288 -8.09161,-0.008 -0.22031,0.55284 0.13125,2.89704 0.78115,5.20853 1.35351,4.81428 1.20574,7.36167 -0.44406,7.66422 -1.22298,0.2243 -2.16489,-1.93352 -2.99998,-6.87043 -0.70793,-4.18509 -3.24542,-7.30295 -7.61778,-9.36259 -2.12526,-1.00112 -4.50177,-2.68315 -5.28114,-3.73696 -1.00434,-1.35798 -2.0042,-1.91606 -3.43322,-1.91606 -4.82485,0 -5.60118,7.64322 -1.4147,13.92463 2.73024,4.09646 2.53458,5.79034 -0.31679,2.74506 -5.73475,-6.12474 -9.02436,-7.95595 -14.33664,-7.97966 -2.68723,-0.0121 -3.46964,0.26897 -4.34838,1.56022 -1.15863,1.7025 -0.88189,3.056 1.1805,5.78205 0.7006,0.92607 1.4676,3.32856 1.70443,5.33888 0.47155,4.00334 2.49212,8.51223 4.07762,9.09802 0.5546,0.2049 1.00857,0.64067 1.00857,0.96844 0,1.02671 -2.3379,0.64308 -4.50542,-0.73904 -4.29978,-2.74171 -7.28923,-0.82557 -7.26173,4.65327 0.0306,6.06691 5.14925,12.49288 11.20398,14.06283 5.90314,1.53061 5.77301,1.21032 2.30685,5.64257 -3.72695,4.76573 -5.56585,9.13762 -7.43907,17.68506 -1.28853,5.87941 -1.35845,7.93966 -0.9585,28.36286 0.34658,17.69787 0.24147,22.78845 -0.53879,25.92018 -0.53404,2.1434 -1.26906,4.18327 -1.63268,4.53336 -0.97085,0.93472 -8.09823,-4.46369 -14.4991,-10.98151 -27.6807,-28.18668 -31.38006,-70.14719 -9.02979,-102.41785 15.77168,-22.7721 42.94575,-36.83781 71.17012,-36.83781 z m 13.07897,82.8544 c -0.24206,-0.0125 -0.49104,-0.007 -0.74729,0.0177 -4.62222,0.44467 -6.02511,6.12215 -2.02663,8.20125 2.16059,1.12346 4.13841,0.74216 5.81047,-1.11966 2.5335,-2.82103 0.59395,-6.92307 -3.03655,-7.09985 z m -0.54017,2.77633 c 0.94864,0.0789 1.95195,1.17435 1.55551,2.16892 -0.20879,0.52378 -0.82432,0.95151 -1.36732,0.95151 -1.30519,0 -2.02119,-1.89781 -1.06408,-2.81934 0.25019,-0.24086 0.55969,-0.32735 0.87589,-0.30109 z" />
     </pattern>
        <rect x="0" y="0" width="1000%" height="1000%" fill="url(#pattern)" transform="scale(1)"/>
</svg>

I tried different methods to achieve the same effect but each method brought up its own complexities.
One of these workarounds involved using a png version of the SVG for the background but I could not achieve a true tiling effect since I wanted the whole pattern to be rotated by about 25 degrees.
I tried finding a solution for this for 2 days straight but I came up empty handed with still no solution.


text:
Q: Make python3 as my default python on Mac for Fish shell Every time I type python into the console it uses Python 2.7. I would like it to use the latest version (I have it installed), Python 3.9. How do I do this using the fish shell (other StackOverFlow talks about for bash)?

A: First, look where it is installed :
ls -l /usr/local/bin/python*

note the line which ends with python3.9 without anything (as m for example) and type
ln -s -f /usr/local/bin/python3.9 /usr/local/bin/python

where '/usr/local/bin/python3.9' is what you have copied from above.
type in a new session
python --version

should be ok..


text:
Q: Why does Ubuntu Download recommend 32-bit install? Update for 13.10: 64-bit version is now the default and 32-bit is labelled "for machines with less than 2GB RAM"
The Ubuntu desktop download screen has a pair of radio buttons you use to select whether you wish to download the 32-bit or 64-bit version.  The 64-bit version is labeled "Not recommended for daily desktop usage."  If you have a 64-bit processor, why would you not want to use the 64-bit version of Ubuntu?
Update for 10.10: They've removed the "Not recommended" label from the 64-bit version and added a "Recommended" label to the 32-bit version.
Update for 11.04: Same as 10.10.
Update for 12.04: Still says "Recommended" next to 32-bit version of desktop
Update for 12.10: 32-bit version of desktop is still default, says "recommended"
Update for 13.10: 64-bit version is now the default and 32-bit is labelled "for machines with less than 2GB RAM"

A: As far as I know, 64-bit works fine, with the exception that some people have had problems with Adobe Flash.
Also, a 64-bit operating system will not work on a 32-bit PC but a 32-bit operating system will work on a 64-bit PC. This is probably the reason behind this warning (although it could be worded better).
The Ubuntu community wiki post on the subject recommends using 64-bit Ubuntu if you have a 64-bit pc and no specific reason not to use 64-bit.
There are limitations to 32-bit cannot access much more than 3GB of RAM (although this problem is addressed with the PAE kernels) but 64-bit has no problem here. If you have >3GB of RAM, consider using 64-bit.

A: I assume that the main reason is this: the 32-bit version works on pretty much every single PC and Mac in circulation currently, so if you don't have any idea what 32-bit and 64-bit mean, you should just download the 32-bit version and install it, and it will just work. And if someone doesn't have any idea about the difference between the 32- and 64-bit versions, it;s unlikely that they're going to be doing anything where the difference has any observable effect.
In other words, for the 64-bit version, you have to figure out whether your system supports it. For the 32-bit version, you don't. It works on "everything."

A: I used to use 64bit Ubuntu on my desktop, and 32bit on my laptops.  For the most part I saw no differences, but there were some small niggles:

*

*As mentioned above, Flash historically hasn't been very well supported on 64bit.  I didn't think I'd care about this, but actually this was a fairly major annoyance for me.  I ended up using the 32bit version of flash, manually installed.  Recently Adobe has put out a 64-bit Flash, so possibly this is a thing of the past (I haven't tested it yet).

*Java (and other software) on 64bit uses more memory, and this can have some performance impacts.  I don't use much java so haven't really experienced this issue but guess it's pretty well known.

*It used to be that a lot more people ran 32bit than 64, so once and a while you'd run into a 64-bit specific problem that would tend to take a long time to get fixed.  This has gotten a LOT better in recent years though, but for someone that really wants everything to Just Work, you might prefer 32-bit.

*64bit means that memory pointers can address higher amounts of memory.  If your system has 4gig or more of RAM memory, and you use apps that need lots of RAM, that can be a reason for using 64bit.  However, in recent years the PAE kernels for i386 have become standard, and these do permit addressing >4gig.

*If you're a developer and you run 64-bit, you can build both 32-bit and 64-bit executables fairly easily (e.g. with pbuilder).  Building 64-bit binaries on 32-bit seems not possible (well, at least not without jumping through some hoops).
[Update 12.04]
Just recently I've reinstalled the amd64 version of 12.04, and find it a lot better than it was when I originally wrote the above.  I've not tested Java but Flash is definitely working as well as it had on 32bit.  Also, completely anecdotally but it seems like people are running 64-bit more often than 32-bit these days.

A: I ran some tests to compare 32 vs 64 bit configurations on various applications on a couple of sample machines (small memory Atom based netbook) and a typical laptop.  I compared memory usage, power consumption for the following:

*

*32 bit kernel, 32 bit userspace

*64 bit kernel, 32 bit userspace

*64 bit kernel, 64 bit userspace

Data: http://kernel.ubuntu.com/~cking/x32/Quantal-x32-power-memory-comparisons.ods
The bottom line is that for small systems, 32 bit is a good fit, where as if you have enough memory and you have a modern 64 bit capable CPU, then 64 bit is suitable.  But there is more detail in the spreadsheet than than simple summary.
I also ran some tests comparing 32 bit, 32 bit pae and 64 bit a while ago, here are the results:
http://kernel.ubuntu.com/~cking/power-benchmarking/blueprint-foundations-p-64bit-by-default/hpmini-and-x220-tests/results-3/results.txt  - see the conclusions at the end for a overall summary.

A: At same time Ubuntu Wiki says the opposite:
Unless you have specific reasons to choose 32-bit, we recommend 64-bit to utilise the full capacity of your hardware.
https://help.ubuntu.com/community/32bit_and_64bit

A: 64 bit is only really useful if you have more than 4 gigs of RAM. If you use the 64 bit system, eventually you will run into a situation where a driver or even a program is not available in 32 bits. Adobe pulled its 64 bit Flash for a while. Canon printer drivers are only available in 32 bit (but can be force installed). I used both 64 and 32 bit systems, and found that 64 bit did not provide me any advantages (both ran at the same speed as far as I could tell).

A: I wrote the last Launchpad Bug #585940 description myself a long time ago and the only thing I can say I have been unable to discover why is there so much misinformation around this topic.
I think the most probable answer is the 64-bit edition is much more buggy than the 32-bit one, since this is what my own experience of only using Ubuntu in my daily life suggests. On the other hand this is only speculation since I have not performed a formal comparison between editions.
As far I'm able to work well enough using it I simply choose to use the 64-bit edition because is the one I want to be improved, since in time it will clearly be the best option and it will be here before we have noticed. By then I want us people being using a complete stable distribution.

A: Use to, most computers where 32bit. Now most newer CPU's is 64bit. And 32bit is compatiable with both versions.

A: One disadvantage to running the 32bit version non-PAE kernel is that your processes aren't protected with the CPUs non-executable (NX) bit, which can make it easier for attackers attempting to exploit flaws in software. See the Security Team's Features discussion on it for more details. In recent Ubuntu releases, there's an emulation mode, but it's of limited effectiveness.
Also, the randomization space available for things like Address Space Layout Randomization (ASLR) is much, much smaller when using 32 bits, potentially to the point of being brute forcible.

A: This is actually just a mis-wording of sorts. According to LaunchPad Bug #585940 It's meant to convey that typical desktops are 32-bit whereas more recent desktops are 64-bit. Since the 32bit install will always work on both 32bit and 64bit machines it remains "recommended."

A: The reason is that there are still lots of 32-bit processors in production now, and most computer users do not know what 32-bit and 64-bit are.
If someone with 32-bit computer(s) downloads the 64-bit version, it is very certain that it will not run on his/her computer(s) because 32-bit processors cannot understand and handle 64-bit commands. However, if someone with 64-bit computer(s) downloads and uses the 32-bit version, it works because 64-bit arch is backwards-compatible to 32-bit.
One more issue is that 32-bit software demands less hardware power.
Update: As of 13.10, Ubuntu Download page now recommends the 64-bit download and offers the 32-bit option "for machines with less than 2GB RAM". This is because most computing devices that could potentially have Ubuntu installed on today are 64-bit, and only devices with less than 2GB RAM may contain a 32-bit CPU.

A: Any modern CPU is capable of running 64 bit.
Both Intel and AMD, even a older AMD sempron supports single core 64bit.
If You don't need memory hungry applications then there is no need to go 64bit.
I have 16GB ram and sure 64 bit , 32bit would be a stupid move.
Counts also for windows 7 en 8.


text:
Q: Why is this a permutation instead of a combination? Textbook question: (apologies for the "baby math" question)

A new company with just two employees, Sanchez and Patel, rents a floor of a building with 12 offices. How many ways are there to assign different offices to these two employees?

Textbook answer is $12 \cdot 11 = 132$ by the product rule. Ok cool. Now this was before it introduced permutations and combinations, but I can see it's a permutation $P(12, 2) = \frac{12!}{10!} = 132$.
My question is, why is this a permutation and not a combination? Permutations only apply when the order of the resulting subsets is involved, so how does the order of the office assignments matter in this problem? I get mechanically that it uses the product rule (i.e. pick from 12 then pick from 11) but what I don't understand is, since this is the same value as the permutation then apparently the order matters, or they wouldn't come out to the same answer. So how does order play into this?

A: It is a permutation because assigning Sanchez to office 1 and Patel to office 2 is different from assigning Patel to office 1 and Sanchez to office 2.

A: You can see this problem as an one-to-one function where both objects(employees) and images(offices) are labeled/distinct. The function must be one-to-one because each office can only be assign to one employee.
There is a way to solve all the combinatoric kind of problems. It's the Twelvefold Way. You can google it.

A: A simple way to understand:
a permutation is nothing but [choose]$\times$[place] i.e. $ ^nP_k =\; ^nC_k\times k!$
So we choose $2$ offices out of $12$, and place $S$ and $P$ in them in $2!$ ways.

A: Let the $12$ offices be numbered $1$ to $12$. One way in which different offices can be assigned to Sanchez and Patel is to assign office $7$ to Sanchez and office $3$ to Patel, denoted by $(7,3)$.  Another assignment is $(2,12)$.  The number of ways to fill in the two blanks in $(\_,\_)$ is the number of ways to fill the first blank (which is $12$) times the number of ways to fill the second blank (which is $11$ because the second blank can be any office except the one already assigned in the first blank).  So, the number of ways in question is $12 \times 11$.  Note that this is a permutation problem because the order matters - in this problem, the assignment $(7,3)$ is different from the assignment $(3,7)$.
One could think of a problem where you want to form a team of two players from a total of $12$ available players.  The number of possible teams you can form is ${12 \choose 2} = 12 \times 11 / 2$.  We are dividing $12 \times 11$ by $2$ here. This is a combinations problem because the order doesn't matter - the two subsets $\{7,3\}$ and $\{3,7\}$ refer to the same team.


text:
Q: Why is $\lim_{m\to \infty} \frac{\sin\left(\frac{\pi}{2^m}\right)}{\frac{\pi}{2^m}} = 1$? I am currently working on a proof with a good friend of mine that involves adding more and more triangles to the sides of a regular polygon but keeping the longest diagonal constant until eventually, it becomes a circle. And we ended up with this formula.
$4$-sided regular→$8$-sided regular→$16$-sided regular→$32$-sided regular$\to \ldots \to n$-sided regular
(When $n$ tends to infinity, the area will be equal to that of a circle with the longest diagonal as diameter)
The Question is:
Can someone explain in detail:
Why does $$\frac {\sin \frac {\pi}{2^m}}{\frac{\pi}{2^m}} = 1$$ when $m$ tends to infinity?
Thanks in advance :D
Note I am still a beginner in finding limits. It would help greatly if you can explain step by step.

A: Because we have
$$\lim_{x \to 0}\frac{\sin x}{x} = 1$$
which is a standard limit typically proven through simple geometrical observations followed by the Squeeze Theorem. You can check this link for a various explanation of why this works, particularly the one by robjohn, which I find the simplest and most elegant.
Another way of stating the above limit is
$$\sin x \sim x; \quad x \to 0$$
(Obviously, if $\frac{\sin x}{x} \to 1$ as $x \to 0$, then $\sin x$ becomes very close to $x$.)
In case of your limit, you have
$$\lim_{m \to \infty} \frac{\sin\left(\frac{\pi}{2^m}\right)}{\frac{\pi}{2^m}}$$
It's clear that as $m \to \infty$, $\frac{\pi}{2^m} \to 0$ due to the growing denominator, so we make a substitution $t = \frac{\pi}{2^m}$. Clearly, $t \to 0$ as $m \to \infty$, so the limit becomes
$$\lim_{t \to 0}\frac{\sin t}{t}$$
which becomes $1$.

A: If you replace $\frac\pi{2^m}$ with x, it is obvious that $x$ goes to zero when $m$ goes to infinity. So your limit is equivalent to:
$$\lim_{x \to 0}\frac{\sin x}{x}$$
...which is 1. If you learn to evaluate just one limit, this is the one :) You can easily find several elementary proofs on the web and I really recommend this one from MSE.


text:
Q: How to deploy Ionic app for remote internal users to test I have an ionic app build on my system.
For now, I have been testing my app using Ionic DevAPP (which can be found on the App Store and Google Play).
Prerequisite to run an app on my mobile device using Ionic DevApp is, My app needs to be up and running using the command:
ionic serve

This option looks great when doing development.
But now, I have my app build and I want to share it with the testing team and PO who is located on shore.
I want to know is there any way or free platform where the users can run an app on their mobile devices directly without starting a dev server.
NOTES:

*

*I know about Ionic dashboard, but it is not free when comes to sharing builds.

*I don't want to upload my app on Play Store or Google Play.

Any help is recommended as I am really looking for options to share my app.

A: I use Diawi To share both apk and ipa, bypassing play/app stores.


text:
Q: Number of ways to deal $5$ cards to $5$ players from a $52$ card deck. The question is:

In a game of poker, five players are each dealt $5$ cards from a $52$-card deck. How many ways are there to deal the cards?

The answer is $\frac{52P5}{(5!)^5}$ or $\frac{52!}{47!5!}$ I understand the reason after seeing the answer: $25$ ordered cards are picked from the deck of $52$, then divided by the number of ways each hand can be ordered, because the order of a hand does not matter.
However, before seeing the answer I came up with this attempt:
You choose $5$ cards from $52$, the order doesn't matter so we have $52\choose{5}$. Then you're left with $47$ cards and for the next hand we have $47\choose{5}$. The final sum is ${{52}\choose{5}} + {{47}\choose{5}} + {{42}\choose{5}} + {{37}\choose{5}} + {{32}\choose{5}}$.
This sum is considerably larger, but while I understand the reason $\frac{52!}{47!5!}$ is the correct, I can't find the mistake in my first attempt.

A: There are $52!$ ways to shuffle the deck.   Dealing 5 cards to each player, every hand is one of $5!$ arrangements, and there are $27$ cards remaining, whose order we also don't mind.
Thus there are $\frac{52!}{27!~5!^5}$ ways to deal distinct hands to the five players.
Your attempt was adequate except that you need to multiply rather than add.
$$\binom{52}{5}\binom{47}{5}\binom{42}{5}\binom{37}{5}\binom{32}{5}\binom{27}{0} = \dfrac{52!}{5!^5~27!}$$

PS: $\frac{52!}{47!~5!}$ counts the ways to deal distinct hands to one player; $\frac{47!}{42!~5!}$ counts ways to deal to the next player, et cetera...


text:
Q: TypeError dialog is not a function I need help with this javascript code. I keep getting this error:
Uncaught TypeError: $(...).dialog is not a function

Code:

I included the jquery import in the header. What am I doing wrong?

A: The script is running before the div has been loaded on the page, thus it is unavailable, add the ready function to ensure it is loaded first.
$( document ).ready(function() {
  $('#tdog').dialog({
       autoOpen: false,
       width: 200,
       modal: true,
  });
});

A: I'm guessing you forgot to include jquery UI.
See this answer for reference:
Error: TypeError: $(...).dialog is not a function

A: You have to include the ui and also the styles before starting the script

<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">

A: In Laravel, I had a minified version of all the js files in /public/js/app.js being included in app.blade.php (main template page). I commented out the inclusion of app.js and the error went away, presumably because of the 'included twice' points made above.


text:
Q: Proving Cardinality of Cosets in Abstract Algebra *****************updated question**************
The question starts off like this:
Let $H$ be a subgroup of a finite group $G$. Prove that $|Ha| = |Hb|$ by
proving that there exists a bijection $f : Ha \rightarrow Hb$. Find this bijection.
I know that I have to show injective and surjective but want to know if anyone thinks this is correct in this fashion
$$Let\ a\in G, \ y, x \in Ha,then \ x=ra, y=sa\ for\ some\ r,s \in H. $$
$$we\ define\ f:Ha \rightarrow Hb\ by \ f(x)=hb$$
$$suppose \ f(x)=f(y)$$
$$rb=sb\ for\ some\ r,s \in H$$
  $$r=s$$
  $$xa^{-1}=ya^{-1}\ (from\ x=ra\ and\ y=sa)$$
$$x=y$$
This shows injective. for the onto part this is really wanted to check
$$let\ x\in Ha, y\in Hb\ and\ a,b \in G\  such\ that$$
$$x=sa,\ y=sb\ for \ some\ s \in H$$
$$then\ f(x)=sb$$
$$=yb^{-1}b\ (from \ y=sb)$$
$$=y$$
Thus, we have shown that $\forall y \in Hb, \exists\ x \in Ha \ such
\ that f(x)=y  $
here we have shown the function is also surjective and hence a bijection exist between $Ha$ and $Hb$ and therefore we know then  $|Ha|=|Hb|$

A: Let $x$ and $y$ be in $Ha$. Then $x=ra$ and $y=sa$ for some $r$ and $s$ in $H$. Then $f(x)=rb$ and $f(y)=sb$. If $f(x)=f(y)$, then $rb=sb$, so $r=s$, so $x=y$. Thus, $f$ is injective.

A: Among the cosets there is $H=H1$. If, for every $a\in G$, you find a bijection $f_a\colon H\to Ha$, then the required bijection $Ha\to Hb$ can be obtained as the composition $f_b\circ f_a^{-1}$.
An obvious candidate for $f_a$ is the map $f_a\colon H\to Ha$, $f_a(h)=ha$; can you prove it's indeed bijective? If so, what's its inverse?


text:
Q: simulink model in matlab I am working on detecting road lanes using hough transform in simulink(matlab). I have designed the model but its not detecting the lanes. As i am very new to simulink so i have no idea where i am doing the mistake. I tried to upload the model but its not working. I have used the same model as given in matlab-simulink demo except i added a new block of rgb2intensity just after the image from file block and the image which i have given as an input is also uploaded1.Any help???

A: Without seeing a screenshot of your actual model, it's difficult to give specific detail, but here is some general advice that you may find helpful.
I would debug a Simulink model pretty much the same way that I would debug any other piece of code -- by trying to understand exactly what is happening in my model by examining the output at each step.
For starters, I would make use of the To Workspace block, to see what the data actually looks like at the intermediate stages of your model.  This will help you to identify where things are going wrong.  For example, what is the output of rgb2intensity?  Is this function transforming your data in the way that you expect it to?  Ask that question of each block in your model if you have to.  If the block is not behaving the way that you expect it to, then you can ask why?
Another tool that might be useful for you is the Simulink Debugger.


text: Q: Ps2 don't recognize usb flash drive I have formatted my usb flash drive in FAT32, but my ps2 doesn't recognise the usb drive with mcboot installed in memory card. Neither ulaunchelf don't recognise usb drive. I have tried two different usb drives and the problem remains. Do you have any ideas why my ps2 doesn't recognise the usb drives? There is a case of having a problem with hardware?


text:
Q: Changing bits in a frame in video using OpenCV Current scenario:
I am doing a project in Video processing which requires me to make modifications in the contents of individual frames of a video file.
My Approach:

*

*Split the video into multiple frames i.e. RGB images.

*Modify the images assuming RGB images

*Replace the modified frames in place of the original frames.

My Questions:

*

*What kind of video formats will allow me to do such processing?

*Another way to put it is will lossy video formats like MP4 allow me to edit the image (in RGB format) and replace it safely?

A: If you're still open to ideas to explore...
These media container formats seems to allow including bitmap bytes as video frames.

*

*MOV container (Apple Quicktime) seems to support a PNG codec

*AVI container (supports RGBA lossless codecs - see Lagarith & HuffYUV)

*FLV container (supports both bitmap data and JPEG) : The bitmap codec is referred to a "ScreenVideo" but its just uncompressed RGBA information wedged between some 11 front-bytes (defines frame/tag header inc timestamps etc) + your bitmap data + closing 4 bytes (an integer confirming the tag size).

*MP4 only holds MPEG codecs (so must the picture must be H.264 or H.265 format) : Are you using C++? I think someone made a keyframe encoder for H.264 so maybe you can use that code to supply thr final encoding (or at least end up with .h264 file that can be put into MP4 by FFMPEG or such tool)
Basically use OpenCV to handle whatever format you have, stepping through frame by frame and extracting each frame to RGBA then edit the image grab and either put that bitmapdata to FLV or use that Cardinal Peak's H264 encoder code. You dont need an FLV encoder just some way to write bytes defining an FLV file. Its so easy you can even use a hex-editor (obviously pasting in the long bitmap data where required)


text:
Q: Automating "good" pagebreak (manual local pagebreak optimization) I was recently typesetting a book with LaTeX where the publisher had the following requirements:

*

*Absolutely no clubs; widows tolerated, but avoid if possible. (The text contained many 2-line and 3-line paragraphs.)

*No hyphen at pagebreak.

*Good looking pages.

*I could choose the page layout to some extent (tuning margins and such).

The steps I did were the following:

*

*With fixed \textwidth, use microtype for considerable paragraph flexibility. Find all Overfull hbox and adjust hyphenation of the word being broken, or adjust wording of the phrase; this was always in the first paragraph line.

*Set \clubpenalty=10000 and \widowpenalty=10000. Many Underfull vbox were the result. Find the best \textheight around given page size; I tried initial guess ±4mm with 1mm step. One of them generated the least number of Underfull vboxes, which was the pagesize I chose.

*For each Underfull vbox page, find a paragraph which was close to being shorter (last line short) or longer (last line long) by 1 line. Set \looseness to 1 or -1 and retry. Usually a better pagebreak was found right away by adjusting just one paragraph in this way, and only on the page where the problem was. Continue until no more Underfull vbox appear (with \vbadness=3000).

*Visually find all hyphenations at page break, and put the word broken into \hbox{...} to prevent the break. In all cases, the paragraph was fine that way. (Using \brokenpenalty would move pagebreak but not try to not hyphenate.)

Some of the steps (#3,  #4) were highly repetitive. Although the approach is naive trial-and-error, only providing simple feedback from pagebreak to linebreak improved the result quite a bit in terms of something like local optimization.
The question is: is there some automation of these tasks already done or in the process of being programmed?  (I am not asking about Frank's Alice goes floating which has much broader goal of global optimization.)

A: In classic tex, without using lua callbacks there is not a lot more that can be done but...
step 2 sounds wrong.
\textheight should always be \topskip + some multiple of \baselineskip otherwise on a page with just text there is no possibility of avoiding an underfull box.
If you can allow yourself an extra line without adjusting the page size you can use
\enlargethispage{\baselineskip}

usually best to do on both pages of a spread of course.
but basically it requires hand tuning as you say.
you didn't say what you have \parskip set to. If you have lots of small 2-3 line paragraphs you presumably have lots of inter-paragraph space so if you set club and widow penalties so the paragraphs don't break one option (in some designs) is to make \parskip quite flexible so that in practice you can always take a three line paragraph over to the next page without making the current page under-full. If you need to keep vertical glue controlled or even not stretchy at all to keep things on a grid layout then more hand tuning is needed.


text:
Q: How do you make a copy of an object in JavaScript that is completely separate and independent of the object copied? I have the following code:
let myObj = {
    val1: "Cookies",
    val2: 15
};

let myObj2 = myObj;

myObj2.val1 = "Cake";

console.log(myObj.val1);// This logs "Cake"

I want "Cookies" to be output instead of "Cake", what's the easiest way to make that happen?

A: There are a couple ways to do this, but my personal favorite is by using the Object.assign() method.
The best way to do this for your case would be:
let myObj = {
    val1: "Cookies",
    val2: 15
};

let myObj2 = Object.assign({},myObj);

myObj2.val1 = "Cake";

console.log(myObj.val1);// This logs "Cookies"
console.log(myObj.val2);// This logs "Cake"

The Object.assign() method is a static method of the class Object. It takes two parameters. It takes in an object to write to, and an object to read from. It then assigns all the data inside the read-object to the write-object, and it also returns the result. This is important, as it allows us to use it in this way. If it didn't return the result, our code would have to look like this:
let myObj = {
    val1: "Cookies",
    val2: 15
};

let myObj2 = {};

Object.assign(myObj2,myObj);

myObj2.val1 = "Cake";

console.log(myObj.val1);// This logs "Cookies"
console.log(myObj.val2);// This logs "Cake"

but since Object.assign() returns the value that it assigns to the write-object, we can simply pass in an empty object and assign the returned value to a variable (Or output it to the console, pass it to a function, or really anything we want) like so:
var copy = Object.assign({},original);// Will return the value assigned to the empty object and
// store it inside "copy"

One thing to keep in mind is that this only makes a non-deep copy of the object! If you have an object inside your object, then that object will be passed my reference, which is exactly what you don't want. But as long as your object doesn't contain any other objects, then this should work perfectly! (If your object does contain other objects, then you'll need to use one of the methods found here: JavaScript: How to pass object by value?)


text:
Q: Nexus 5x file issues Since updating to Android O (8.1.0) on our development Nexus 5x phones, we have been seeing a lot of weird file access issues.  We have 1 file that keeps coming up, no reason why this file, but I'm positive the file is in /sdcard/ , I use Java or C++ (NDK) to see if the file exists, but it returns that the file doesn't exist. I can try this 100 times, and maybe 1 time it fails, maybe 10 times it fails.  I have this across 5-6 devices, so it's not just 1 device.
Has anyone seen anything like this before? We've deleted the files and have them re-downloaded. This file is for a 3rd party library, we have wondered if there is a file lock, but this file is accessed at startup, so we swipe the app away, restart and right away we can't view the file.
C++ Example:
   return (access(aFileName.c_str(), F_OK) != -1);

Java Example:
File lTempTaskFile = new File(lTaskFileName);
if(lTempTaskFile.exists())
{
    // blah
}


text:
Q: Customize redundant Checkbox input Jquery Code i have this working code bellow and i think he is a little bit too long and redundant can i customize it ?
$( "#unique" ).click(function() {

    if ( $( this ).is(':checked') ) {
        $( ".lotud" ).show();
        $( "#add_lot" ).hide();
        $( "#lots_rows_contnr" ).hide();

        $(".lotud input").prop({disabled: false})
        $("#lots_rows_contnr input").prop({disabled: true})
    }
    else {
        $( ".lotud" ).hide();
        $( "#add_lot" ).show();
        $( "#lots_rows_contnr" ).show();

        $(".lotud input").prop({disabled: true})
        $("#lots_rows_contnr input").prop({disabled: false})
    }

});

A: You can shorten it slightly through the use of ternaries, using the checked property on the DOMElement itself, joining selectors and using the checked property as the basis for the disabled property. Try this:
$("#unique").click(function() {
    $(".lotud").toggle(this.checked);
    $("#add_lot, #lots_rows_contnr").toggle(!this.checked);
    $(".lotud input").prop({ disabled: !this.checked });
    $("#lots_rows_contnr input").prop({ disabled: this.checked });
});

Which of the two versions, your original or the above, is more readable is a matter of opinion.


text:
Q: create image slider that shows part of previous and next image I'm trying to create a slideshow using jQuery (similar to jquery scrollhorz) but I want the previous and next image partly shown.
Right now, what I have, is a div (with overflow hidden) containing all the images I have. When previous or next button is pressed, I animate the whole div either to left or right. The problem is, if I have many images loaded into the div, it becomes laggy and slow.
What is the best design to implement this image slider?

A: Without going into the code required, my suggestion would be to use jquery (or moo if that's your thing) to maintain a div that is three to five images long, and keep a list of urls to all the images you want displayed. When you slide the images left or right, you'll pop off the image on the opposite end and add the appropriate image to the other side.
You could use the same technique to loop through the list seamlessly.

A: Try this.
Hero carousel
It fits your description....Hope it helps out :)
this might be a solution too.
http://jsfiddle.net/JCQ6Q/15/
Vote up if it helps you :) all the best


text:
Q: How do I implement equality for an abstract base class? I'm following the MSDN guidance for value equality, and I found a case that the documentation didn't cover, equality for a base class.
A little background:
I'm working on a Mahjong game (4-player, not matching), and I'm working on defining the tiles. Tiles can be broken into two groups: suits, which have a number associated with them (and can be put together in sequences, like 2-3-4) and honor tiles, which have no number.
Here's what I have so far:
public enum MahjongSuitType
{
    Bamboo = 1,
    Character,
    Dot
}

public enum MahjongSuitNumber
{
    One = 1,
    Two,
    Three,
    Four,
    Five,
    Six,
    Seven,
    Eight,
    Nine
}

public enum MahjongHonorType
{
    GreenDragon = 1,
    RedDragon,
    WhiteDragon,
    EastWind,
    SouthWind,
    WestWind,
    NorthWind
}

public abstract class MahjongTile
{

}

public class MahjongSuitTile : MahjongTile, IEquatable<MahjongTile>
{
    public MahjongSuitType SuitType { get; private set; }
    public MahjongSuitNumber SuitNumber { get; private set; }
    public bool IsRedBonus { get; private set; }  //this has no bearing on equality

    public MahjongSuitTile(MahjongSuitType suitType,
                           MahjongSuitNumber suitNumber,
                           bool isRedBonus = false)
    {
        this.SuitType = suitType;
        this.SuitNumber = suitNumber;
        this.IsRedBonus = isRedBonus;
    }

    public override bool Equals(object obj)
    {
        return this.Equals(obj as MahjongTile);
    }

    public bool Equals(MahjongTile other)
    {
        if (Object.ReferenceEquals(other, null))
            return false;
        if (Object.ReferenceEquals(other, this))
            return true;

        MahjongSuitTile otherSuitTile = other as MahjongSuitTile;
        if (Object.ReferenceEquals(otherSuitTile, null))
            return false;

        return (this.SuitType == otherSuitTile.SuitType) &&
               (this.SuitNumber == otherSuitTile.SuitNumber);
    }

    public override int GetHashCode()
    {
        return this.SuitType.GetHashCode() ^ this.SuitNumber.GetHashCode();
    }

}

public class MahjongHonorTile : MahjongTile, IEquatable<MahjongTile>
{
    public MahjongHonorType HonorType { get; private set; }

    public MahjongHonorTile(MahjongHonorType honorType)
    {
        this.HonorType = HonorType;
    }

    public override bool Equals(object obj)
    {
        return this.Equals(obj as MahjongTile);
    }

    public bool Equals(MahjongTile other)
    {
        if (Object.ReferenceEquals(other, null))
            return false;
        if (Object.ReferenceEquals(other, this))
            return true;

        MahjongHonorTile otherHonorTile = other as MahjongHonorTile;
        if (Object.ReferenceEquals(otherHonorTile, null))
            return false;

        return this.HonorType == otherHonorTile.HonorType;
    }

    public override int GetHashCode()
    {
        return this.HonorType.GetHashCode();
    }
}

For the majority of the code, I'd like to refer to the tiles via the base class, something like:
List<MahjongTile> hand = new List<MahjongTile>() { ... };

HashSet<MahjongTile> dragonTiles = new HashSet()
{
    new MahjongHonorTile(MahjongHonorType.GreenDragon),
    new MahjongHonorTile(MahjongHonorType.RedDragon),
    new MahjongHonorTile(MahjongHonorType.WhiteDragon)
}

IEnumerable<MahjongTile> dragonTilesInHand = hand.Where(t => dragonTiles.Contains(t));

My Question: how should I define equality in the MahjongTile base class?

A: Since Object.Equals is virtual, the subclasses implementation override the method. No further code is needed.


text:
Q: Laravel Eloquent Relationships Many To Many I have a program that defines a model called a Production line and this production line produces a product. The production line also has many inputs to produce this product so this production line has many production lines. I was able to connect this relationship with no problem in the model itself. A one-to-many referring to itself in this way
class ProductionLine extends Model {

  ...

  /**
   * The inputs for this production line
   */
  public function productionLines() {
    return $this->hasMany(ProductionLine::class);
  }

  /**
   * The consumer
   */
  public function productionLine() {
    return $this->belongsTo(ProductionLine::class);
  }
}

But I was thinking about what if the production line has many consumers. How would I setup this kind of relationship?
Would I just simply have in the ProductionLine model the following?
public function productionLines() {
 return $this->belongsToMany(ProductionLine::class);
}

A: Add another relation like this in your Production line Model.
public function consumer()
{
    return $this->hasMany('App\Consumer');
}

Just remember Consumer table must have a prod_id denoting which production line it belongs to

A: Eloquent allows you to define the pivot table and the ids in this table which proved to be quite useful.
My model was called ProductionLine and a production line has many consumers and producers but both the consumer and producer were also production lines.
SO how do you do that?
In the model I defined my own custom ids and the pivot table 'consumer_producer'.
public function producerProductionLines() {
  return $this->belongsToMany(ProductionLine::class, 'consumer_producer',
    'consumer_production_line_id', 'producer_production_line_id');
}

public function consumerProductionLines() {
  return $this->belongsToMany(ProductionLine::class, 'consumer_producer',
    'producer_production_line_id', 'consumer_production_line_id');
}

For the migration I created my own
php artisan:make migration ConsumerProducer

When the migration was created I added my custom pivot table name with the two custom ids.
public function up() {
  Schema::create('consumer_producer', function(Blueprint $table) {
    $table->integer('consumer_production_line_id')->unsigned()->nullable();
    $table->integer('producer_production_line_id')->unsigned()->nullable();
    $table->timestamps();
  });
}

And that's it! This only works if you defined the ids differently otherwise both columns would be the same name and that can't work.