Show cash on delivery (COD) based on applied coupons in WooCommerce

Question: I am trying to have cash on delivery (COD) enabled only for customers that use certain type off coupons.
I have an existing code that, when coupons of a certain type are entered, converts the product sales price to the regular product price.
Now I would like to add that cash on delivery (COD) only is available for valid coupons within the same function.
The part that I have tried to add is this:
if ($coupons = WC()->cart->get_applied_coupons()  == False )
    unset( $available_gateways['cod'] );

Resulting in:
add_action( 'woocommerce_before_calculate_totals', 'add_custom_price', 10, 1);
function add_custom_price( $cart_object) {

    global $woocommerce;

    if ( is_admin() && ! defined( 'DOING_AJAX' ) )
        return;

    $coupon = False;

    if ($coupons = WC()->cart->get_applied_coupons()  == False )
        unset( $available_gateways['cod'] );

    if ($coupons = WC()->cart->get_applied_coupons()  == False )
      $coupon = False;
    else {
        foreach ( WC()->cart->get_applied_coupons() as $code ) {
          $coupons1 = new WC_Coupon( $code );
          if ($coupons1->type == 'percent_product' || $coupons1->type == 'percent')
            $coupon = True;
        }
    }

    if ($coupon == True)
        foreach ( $cart_object->get_cart() as $cart_item )
        {
            $price = $cart_item['data']->regular_price;
            $cart_item['data']->set_price( $price );
        }
}

This does not give real error messages, but certainly not the desired result either. Any advice?
Answer: First of all I have rewritten your existing code, the part that converts sale prices to regular prices when a certain type of coupon is applied. This because your current code contains outdated methods:
function action_woocommerce_before_calculate_totals( $cart ) {
    if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;

    if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 ) return;

    // Initialize
    $flag = false;

    // Applied coupons only
    if (  sizeof( $cart->get_applied_coupons() ) >= 1 ) {
        // Loop trough
        foreach ( $cart->get_applied_coupons() as $coupon_code ) {
            // Get an instance of the WC_Coupon Object
            $coupon = new WC_Coupon( $coupon_code );

            // Only for certain types, several can be added, separated by a comma
            if ( in_array( $coupon->get_discount_type(), array( 'percent', 'fixed_product', 'percent_product' ) ) ) {
                $flag = true;
                break;
            }
        }
    }

    // True
    if ( $flag ) {
        // Loop through cart items
        foreach ( $cart->get_cart() as $cart_item ) {
            // Get regular price
            $regular_price = $cart_item['data']->get_regular_price();

            // Set new price
            $cart_item['data']->set_price( $regular_price );
        }
    }
}
add_action( 'woocommerce_before_calculate_totals', 'action_woocommerce_before_calculate_totals', 10, 1 );

Then to only make COD active, if coupons of a certain type are applied you can use the woocommerce_available_payment_gateways hook
By default COD will not be available:
// Payment gateways
function filter_woocommerce_available_payment_gateways( $payment_gateways ) {
    // Not on admin
    if ( is_admin() ) return $payment_gateways;

    // Initialize
    $flag = false;

    // WC Cart
    if ( WC()->cart ) {
        // Get cart
        $cart = WC()->cart;

        // Applied coupons only
        if (  sizeof( $cart->get_applied_coupons() ) >= 1 ) {
            // Loop trough
            foreach ( $cart->get_applied_coupons() as $coupon_code ) {
                // Get an instance of the WC_Coupon Object
                $coupon = new WC_Coupon( $coupon_code );

                // Only for certain types, several can be added, separated by a comma
                if ( in_array( $coupon->get_discount_type(), array( 'percent', 'fixed_product', 'percent_product' ) ) ) {
                    $flag = true;
                    break;
                }
            }
        }
    }

    // NOT true, so false
    if ( ! $flag ) {
        // Cod
        if ( isset( $payment_gateways['cod'] ) ) {
            unset( $payment_gateways['cod'] );
        }
    }

    return $payment_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'filter_woocommerce_available_payment_gateways', 10, 1 );

Both codes go goes in functions.php file of the active child theme (or active theme).
Tested in WordPress 5.8.1 and WooCommerce 5.8.0
Comment: This code worked exactly as I wanted it to :-) Thank you very much for help.


Combine dataframe from two list to a single list

Question: I have two lists containing multiple dataframes listA and listB. The first list has 5 dataframe, and the second list has 3 dataframe. I want to form a third list listC where it contains the dataframes from both list such that I will have 8 dataframes in total in listC. I tried using merge(), but it didn't seem to work.
Comment: give a code example please
Comment: It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions.
Answer: The function to use is append():
df <- data.frame(v1 = c(1,2))

l1 <- list(df, df, df, df)
l2 <- list(df, df)
l3 <- append(l1, l2)


Leaving a league

Question: After the release of Heart of The Swarm, a feature was added in the league ladder section, where you now can leave your current league. I noticed this in the BETA aswell.
In the buttom right of the screen, when you are at the "View Ladder", theres a button that says "Leave League".

What is the purpose of leaving your ladder league in StarCraft 2?
Will your MMR remain the same?

These questions rise when I see the buttom. And wonder why some would use this. And if the MMR is the same, why leave just to join the same league again.
Answer: Your MMR will stay the same. It is not known what happens to MMR confidence, but it may well just not come into play, as the game will need to place you somewhere (a low confidence value does prevent you from being promoted, even when your MMR is already in another league).
So, in general the purpose is to force re-placement into a league, if you believe you're not where you belong. That is when you're tired of waiting for a promotion, or, arguably more importantly, when you are too high. Since some recent version it is impossible to be demoted mid-season, only to re-qualify to a lower league.

On one dull Friday night, after several vs.AI matches and some three liters of beer, I had a brilliant idea - go qualify in 1v1, so I will get placed low and play slow and peacefully. I was pretty drunk, and played Random. After four proxy 2-gates and one 8-pool vs a Master leaguer, I was left with Hot Shot, in Platinum, and an expression like O_O.
After getting brutalized in Platinum for a couple of days, I've left a league and found my place in Silver, and all was well once again :-)
Answer: From a post I found on the Official Forums:

So.. say you're in Bronze, but you've won about 100 games, quickly, in a row! The Blizzard matchmaking system is confused, as it doesn't know if you're getting lucky, or you're really good... So, when you press the Leave League Button, instead of having to lose games to get your MMR stabilized, when you press it, it acts like a new season has just started, so therefore, you can just do a placement match, and get placed into the league of what your current MMR is!

So to summarise, it appears to force a recalculation of your current league placement, by making you re-play the placement match, like when a new season starts.
Comment: You only play one match, just like when a new season starts.
Comment: @FedorHajdu - of course, that's what I meant. I've fixed it up

Leaving a league


Using schema to make a vue-form-generator section collapse-able

Question: I'm using the vue-form-generator library to create a form.
The problem is my form has 116 questions on it and I would like to collapse some questions, making the form more manageable for users.
My form has five sections. So each question in my form has the section attribute in the schema. However, the section part is not a form field such as label that you can modify. The sections are automatically generated into headings for you.
Apart from creating custom form fields, is there any way to make these sections collapse-able?
One route that I was thinking of trying would be to split my form into five forms, which will allow me to place a vue-bootstrap collapse element around each form. Something like:

<vue-form-generator  :schema="survey.schema" :options="survey.formOptions" :model="survey.model"></vue-form-generator>

But this would then again make submission of the form more difficult, since I would have to splice the results of all five forms.
Is there any easier solution to this problem?
Comment: I tried using b-collapse-accordion from Bootstrap Vue and generate a new vue-form-generator for each section, but it didn't work. Did you find another solution?
Answer: I had the same problem recently and this is the only way I found to solve it.
In the schema object add a .collapse class to the group like so:
const schema = {
  groups: [
    {
      styleClasses: 'collapse',
      legend: 'Group title',
      fields: [ ...

On the parent component add a collapse method and attach an onclick event to the fieldset's legend, you can access the form in the vue mounted lifecycle hook, like below:
    ...
    methods: {
        collapse(e) {
            const group = e.target.parentElement;
            group.classList.toggle("hide");
        }
    },
    mounted() {
        const collapsableLegends = this.$el.querySelectorAll('.vue-form-generator .collapse legend');
        collapsableLegends.forEach(legend => legend.onclick = this.collapse);
    }
    ...

Finally add a .hide class to your css:
.vue-form-generator .collapse.hide .form-group { display: none }

It's a bit hacky, but it get the job done.


CPU soft lockup on Ubuntu and pthreads

Question: I have a daemon with multiple pthreads (about 4). One of threads provides high precision timer with microsecond resolution using POSIX gettimeofday. Using gettimeofday results in very high CPU usage and this is expected behaviour, so thread moved to separate core of processor via  pthread_attr_setaffinity_np. All is ok, but Ubuntu 14.04 sometimes fails with error in syslog:
whoopsie[1467]: Not online; processing later (/var/crash/linux-image-3.13.0-34-
generic.144394.crash).

Soft lockup CPU#1 stuck for 22s

What does it mean?
Comment: any update on the problem?
Comment: i just make of pthread_yield() on thread and problem now is gone.
Answer: whoopsie is the "Ubuntu Error Reporting" daemon.
And the Soft lockup CPU#1 stuck for message does not appear to be directly connected to what you are doing with the thread and gettimeofday. It might be a system stability problem under heavy load as discussed here or here.

CPU soft lockup on Ubuntu and pthreads


ORA-00907: missing right parenthesis in synapse

Question: qu = 'SELECT DS.TABLESPACE_NAME AS SCHEMA_NAME,
             SEGMENT_NAME AS TABLE_NAME,
             ROUND(SUM(DS.BYTES) / (1024 * 1024)) AS MB
        FROM DBA_SEGMENTS DS
       WHERE SEGMENT_NAME IN (SELECT TABLE_NAME
                                FROM DBA_TABLES)
       GROUP BY DS.TABLESPACE_NAME, SEGMENT_NAME;'

When I'm executing this query in the synapse notebook, it says "missing right parenthesis".
Can anyone help pls?
Answer: Seems to be OK, unless you need to remove the terminating semi-colon:
... GROUP BY DS.TABLESPACE_NAME, SEGMENT_NAME;'
                                             ^
                                             |
                                           here

Query itself runs OK:
SQL> SELECT ds.tablespace_name AS schema_name,
  2         segment_name       AS table_name,
  3         round(SUM(ds.bytes)/(1024 * 1024)) AS mb
  4  FROM dba_segments ds
  5  WHERE segment_name IN (SELECT table_name
  6                         FROM dba_tables
  7                        )
  8  GROUP BY ds.tablespace_name,
  9           segment_name;

SCHEMA_NAME                    TABLE_NAME         MB
------------------------------ ---------- ----------
SYSTEM                         OBJ$                2
SYSTEM                         UNDO$               0
SYSTEM                         FILE$               0
<snip>

Comment: Thanks for your reply, but when I remove the terminating semi-colon, it says " SQL command not properly ended"
Comment: Hm ... query is correctly written, it runs OK on my 11gXE Oracle database - see an example I posted. Maybe it has to do something with the tool you use.


How to install Unity 3D in Ubuntu 17.04

Question: I have used Blender and Unity 3D in Windows 8. Recently I have started using Ubuntu 17.04. Can anyone tell me the procedure to install Unity 3D Game Engine.
Thank You
Answer: You can download <code>.deb</code> file from this link. After that type the following:

sudo dpkg -i filename.deb
  sudo apt-get install -f
  sudo dpkg -i filename.deb
Comment: Official installers do not come with a. `.deb` file now. For some reason this does not work as expected.

How to install Unity 3D in Ubuntu 17.04


Apply a function to each element of a matrix

Question: I'm trying to apply a function to a Matrix but I don't know how to proceed.
Here's how I define my Matrix :
data Matrice a = Mat [[a]]

montre [] = "/"
montre (t:q) = "" ++ (Pp.printf "%5s" (show t)) ++ " " ++ (montre q)

instance (Show a) => Show (Matrice a) where
        show (Mat ([])) = ""
        show (Mat (t:q)) = "/" ++ (montre t) ++ "\n" ++ (show (Mat q))

Then, once my Matrix is defined I'd like to apply my function z95 to each of the elements of the matrix.
Here's the signature of my z95 function (which allows to convert a integer into this integer modulo 95)
z95 n = Z95(n %% 95)
z95 18 = 18%95

I tried to do a double map too access the elements of my Matrix but then I didn't figure out how to apply my z95 function.
Thanks fo the help!
Answer: You could define a Functor instance for your type, which is the usual way to map a function over the elements of a container.
instance Functor Matrice where
  fmap f (Mat xss) = Mat (map (map f) xss)

Now you can write
>> let m = Mat [[1,2,3],[4,5,6]]
>> fmap (+3) m -- => Mat [[4,5,6],[7,8,9]]

or in your case
>> fmap z95 m

Comment: Thanks a lot dude ! it's exactly what i was trying to do :)
Comment: Or -XDeriveFunctor ? http://www.haskell.org/ghc/docs/6.12.1/html/users_guide/deriving.html


Kendo grid with numerictextbox tab out issues

Question: I have a Kendo grid that I am using in a time entry application.  The time entry covers a 2 week pay period, so I have 14 columns where the user can enter the number of hours worked each day for the given task.  I also have columns for the task, an overtime indicator, totals for each week and a total for the pay period.  For the time entry cells I am using a numeric text box.  Each task is a row in the grid.  I have the grid set to navigatable: true, so the user can tab from one cell to the next.  This works great until the user enters time in the cell.  When they tab out after entering or changing the value in the time cell they are thrown to the first row and first cell of the grid.  I have tried all kinds of things to get the current cell and force it to move to the next cell on tab, but nothing works.  I am always taken to the first cell in the grid.  Is this a known issue with the Kendo grid when using the numeric text box within the cells?  Or am I doing something wrong here?  Any input would be appreciated.
Here is my code:
        GetTimeSheet: function () {

             function editNumberWithoutSpinners(container, options) {
                $('<input data-text-field="' + options.field + '" ' +
                        'data-value-field="' + options.field + '" ' +
                        'data-bind="value:' + options.field + '" ' +
                        'data-format="' + options.format + '"/>')
                        .appendTo(container)
                        .kendoNumericTextBox({
                            min: 0,
                            max: 25,
                            spinners: false
                        });
                //Select text on focus
                $('.k-input').on('focus', function () { var input = $(this); setTimeout(function () { input.select(); }); });

            }

            //Employee grid
            var timeSheetGrid = $("#Time-Sheet-grid").empty().kendoGrid({
                autoBind: true,
                dataSource: {
                    serverPaging: true,
                    serverSorting: true,
                    serverFiltering: true,
                    transport: {
                        read: {
                            url: "/TimeSheet/GetTimeSheetSummary",
                            contentType: "application/json; charset=utf-8",
                            type: 'POST'
                        },
                        parameterMap: function (data, operation) {
                            return kendo.stringify({
                                employeeNum: JARS.TimeSheet.employeeNumHold,
                                payPeriod: JARS.TimeSheet.payPeriodHold
                            });
                        }
                    },
                    schema: {
                        data: "TimesheetSummaryList",
                        model: {
                            id: "EmployeeNum",
                            fields: {
                                EmployeeNum: { type: "integer", hidden: true },
                                ErrorMessage: { type: "string", editable: false },
                                FullName: { type: "string", editable: false },
                                RCN: { type: "string", editable: false },
                                OtAllowedInd: { type: "string", editable: false },
                                PayPeriodDate: { type: "date", editable: false },
                                HoursDay1: { type: "double", editable: false },
                                HoursDay2: { type: "double", editable: false },
                                HoursDay3: { type: "double", editable: false },
                                HoursDay4: { type: "double", editable: false },
                                HoursDay5: { type: "double", editable: false },
                                HoursDay6: { type: "double", editable: false },
                                HoursDay7: { type: "double", editable: false },
                                Week1Total: { type: "double", editable: false },
                                HoursDay8: { type: "double", editable: false },
                                HoursDay9: { type: "double", editable: false },
                                HoursDay10: { type: "double", editable: false },
                                HoursDay11: { type: "double", editable: false },
                                HoursDay12: { type: "double", editable: false },
                                HoursDay13: { type: "double", editable: false },
                                HoursDay14: { type: "double", editable: false },
                                Week2Total: { type: "double", editable: false },
                                PayPeriodTotal: { type: "double", editable: false },
                                OTHoursDay1: { type: "double", editable: false },
                                OTHoursDay2: { type: "double", editable: false },
                                OTHoursDay3: { type: "double", editable: false },
                                OTHoursDay4: { type: "double", editable: false },
                                OTHoursDay5: { type: "double", editable: false },
                                OTHoursDay6: { type: "double", editable: false },
                                OTHoursDay7: { type: "double", editable: false },
                                OTWeek1Total: { type: "double", editable: false },
                                OTHoursDay8: { type: "double", editable: false },
                                OTHoursDay9: { type: "double", editable: false },
                                OTHoursDay10: { type: "double", editable: false },
                                OTHoursDay11: { type: "double", editable: false },
                                OTHoursDay12: { type: "double", editable: false },
                                OTHoursDay13: { type: "double", editable: false },
                                OTHoursDay14: { type: "double", editable: false },
                                OTWeek2Total: { type: "double", editable: false },
                                OTPayPeriodTotal: { type: "double", editable: false }
                            }
                        },
                        total: function (response) {
                            return $(response.TimesheetList).length
                        }
                    }
                },
                pageable: false,
                sortable: false,
                filterable: false,
                navigatable: true,
                batch: true,
                detailInit: detailInit,
                dataBound: function () {
                    if (JARS.TimeSheet.modeHold == "I") {
                        this.expandRow(this.tbody.find("tr.k-master-row").first());
                    }
                },

                columns: [
                    { field: "EmployeeNum", title: "", hidden: true},
                    {
                        field: "FullName", title: "Timesheet for", width: "200px", template: function (data) {
                            var fieldData = data.FullName;
                            if (data.ErrorMessage != "") {
                                fieldData += "
";
                                fieldData += data.ErrorMessage.replace(/\n/g, "
");
                                fieldData += "";
                            }
                            return fieldData;
                        }
                    },
                    { title: "", template: "RT
OT", width: "55px" },
                    { field: "HoursDay1", headerTemplate: 'Sat
' + getDay(1) + '', template: "#:data.HoursDay1#
 #:data.OTHoursDay1#", width: "55px" },
                    { field: "HoursDay2", headerTemplate: 'Sun
' + getDay(2) + '' , template: "#:data.HoursDay2#
 #:data.OTHoursDay2#", width: "55px" },
                    { field: "HoursDay3", headerTemplate: 'Mon
' + getDay(3) + '', template: "#:data.HoursDay3#
 #:data.OTHoursDay3#", width: "55px" },
                    { field: "HoursDay4", headerTemplate: 'Tue
' + getDay(4) + '', template: "#:data.HoursDay4#
 #:data.OTHoursDay4#", width: "55px" },
                    { field: "HoursDay5", headerTemplate: 'Wed
' + getDay(5) + '', template: "#:data.HoursDay5#
 #:data.OTHoursDay5#", width: "55px" },
                    { field: "HoursDay6", headerTemplate: 'Thur
' + getDay(6) + '', template: "#:data.HoursDay6#
 #:data.OTHoursDay6#", width: "55px" },
                    { field: "HoursDay7", headerTemplate: 'Fri
' + getDay(7) + '', template: "#:data.HoursDay7#
 #:data.OTHoursDay7#", width: "55px" },
                    { headerTemplate: 'Week
  1
Total', template: "#:data.Week1Total#
 #:data.OTWeek1Total#", width: "55px" },
                    { field: "HoursDay8", headerTemplate: 'Sat
' + getDay(8) + '', template: "#:data.HoursDay8#
 #:data.OTHoursDay8#", width: "55px" },
                    { field: "HoursDay9", headerTemplate: 'Sun
' + getDay(9) + '', template: "#:data.HoursDay9#
 #:data.OTHoursDay9#", width: "55px" },
                    { field: "HoursDay10", headerTemplate: 'Mon
' + getDay(10) + '', template: "#:data.HoursDay10#
 #:data.OTHoursDay10#", width: "55px" },
                    { field: "HoursDay11", headerTemplate: 'Tue
' + getDay(11) + '', template: "#:data.HoursDay11#
 #:data.OTHoursDay11#", width: "55px" },
                    { field: "HoursDay12", headerTemplate: 'Wed
' + getDay(12) + '', template: "#:data.HoursDay12#
 #:data.OTHoursDay12#", width: "55px" },
                    { field: "HoursDay13", headerTemplate: 'Thur
' + getDay(13) + '', template: "#:data.HoursDay13#
 #:data.OTHoursDay13#", width: "55px" },
                    { field: "HoursDay14", headerTemplate: 'Fri
' + getDay(14) + '', template: "#:data.HoursDay14#
 #:data.OTHoursDay14#", width: "55px" },
                    { field: "Week2Total", headerTemplate: 'Week
  2
Total', template: "#:data.Week2Total#
 #:data.OTWeek2Total#", width: "55px" },
                    { field: "PayPeriodTotal", title: "Total", template: "#:data.PayPeriodTotal#
 #:data.OTPayPeriodTotal#", width: "55px" }

                ],
                resizable: true,
            });

            //Time Records
            function detailInit(e) {
                childTimesheetGrid = $("
").appendTo(e.detailCell).kendoGrid({
                    dataSource: {
                        serverPaging: false,
                        serverSorting: false,
                        serverFiltering: false,
                        transport: {
                            read: {
                                url: "/TimeSheet/GetTimeSheets",
                                contentType: "application/json; charset=utf-8",
                                type: 'POST'
                            },
                            update: {
                                url: "/TimeSheet/UpdateTimesheet",
                                contentType: "application/json; charset=utf-8",
                                type: 'POST',
                                complete: function (e) {
                                    $("#Time-Sheet-grid").data("kendoGrid").dataSource.read();
                                }
                            },
                            destroy: {
                                url: "/TimeSheet/DeleteTimesheet",
                                contentType: "application/json; charset=utf-8",
                                type: 'POST',
                                complete: function (e) {
                                    $("#Time-Sheet-grid").data("kendoGrid").dataSource.read();
                                }
                            },
                            create: {
                                url: "/TimeSheet/CreateTimesheet",
                                contentType: "application/json; charset=utf-8",
                                type: 'POST',
                                complete: function (e) {
                                    $("#Time-Sheet-grid").data("kendoGrid").dataSource.read();
                                }
                            },
                            parameterMap: function(data, operation) {
                                if (operation == "read") {
                                    return kendo.stringify({ employeeNum: e.data.EmployeeNum, payPeriod: e.data.PayPeriodDate });
                                }
                                else {
                                    if (operation !== "destroy") {
                                        return kendo.stringify({ model: data });
                                    }
                                    return kendo.stringify({ id: data.TimesheetId });
                                }

                            }
                        },
                        schema: {
                            data: "TimesheetList",
                            model: {
                                id: "TimesheetId",
                                fields: {
                                    Activity: { type: "string", editable: false },
                                    ActvyComments: { type: "string", editable: true },
                                    ActvyLongDesc: { type: "string", editable: false },
                                    OvertimeInd: { type: "string", editable: false },
                                    HoursDay1: { type: "number", editable: true },
                                    HoursDay2: { type: "number", editable: true },
                                    HoursDay3: { type: "number", editable: true },
                                    HoursDay4: { type: "number", editable: true },
                                    HoursDay5: { type: "number", editable: true },
                                    HoursDay6: { type: "number", editable: true },
                                    HoursDay7: { type: "number", editable: true },
                                    HoursDay8: { type: "number", editable: true },
                                    HoursDay9: { type: "number", editable: true },
                                    HoursDay10: { type: "number", editable: true },
                                    HoursDay11: { type: "number", editable: true },
                                    HoursDay12: { type: "number", editable: true },
                                    HoursDay13: { type: "number", editable: true },
                                    HoursDay14: { type: "number", editable: true },
                                    SpreadInd: { type: "string", editable: false },
                                    TimesheetId: { type: "integer", editable: false, nullable: true },
                                    WorkId: { type: "integer", editable: false },
                                    RCN: { type: "string", editable: false },
                                    OtAllowedInd: { type: "string", editable: false },
                                    EmployeeNum: { type: "integer", editable: false },
                                    FullName: { type: "string", editable: false },
                                    PayPeriodDate: { type: "date", editable: false },
                                    Week1Total: {type: "double", editable: false },
                                    Week2Total: { type: "double", editable: false },
                                    PayPeriodTotal: { type: "double", editable: false }
                                }
                            },
                            total: function (response) {
                                return $(response.TimesheetList).length
                            }
                        },
                        group: {
                            field: "FullName", template: "Timesheet for", aggregates: [
                               { field: "HoursDay1", aggregate: "sum" },
                               { field: "HoursDay2", aggregate: "sum" },
                               { field: "HoursDay3", aggregate: "sum" },
                               { field: "HoursDay4", aggregate: "sum" },
                               { field: "HoursDay5", aggregate: "sum" },
                               { field: "HoursDay6", aggregate: "sum" },
                               { field: "HoursDay7", aggregate: "sum" },
                               { field: "HoursDay8", aggregate: "sum" },
                               { field: "HoursDay9", aggregate: "sum" },
                               { field: "HoursDay10", aggregate: "sum" },
                               { field: "HoursDay11", aggregate: "sum" },
                               { field: "HoursDay12", aggregate: "sum" },
                               { field: "HoursDay13", aggregate: "sum" },
                               { field: "HoursDay14", aggregate: "sum" },
                               { field: "Week1Total", aggregate: "sum" },
                               { field: "Week2Total", aggregate: "sum" },
                               { field: "PayPeriodTotal", aggregate: "sum" }
                            ]
                        },
                        aggregate: [{ field: "HoursDay1", aggregate: "sum" },
                               { field: "HoursDay2", aggregate: "sum" },
                               { field: "HoursDay3", aggregate: "sum" },
                               { field: "HoursDay4", aggregate: "sum" },
                               { field: "HoursDay5", aggregate: "sum" },
                               { field: "HoursDay6", aggregate: "sum" },
                               { field: "HoursDay7", aggregate: "sum" },
                               { field: "HoursDay8", aggregate: "sum" },
                               { field: "HoursDay9", aggregate: "sum" },
                               { field: "HoursDay10", aggregate: "sum" },
                               { field: "HoursDay11", aggregate: "sum" },
                               { field: "HoursDay12", aggregate: "sum" },
                               { field: "HoursDay13", aggregate: "sum" },
                               { field: "HoursDay14", aggregate: "sum" },
                               { field: "Week1Total", aggregate: "sum" },
                               { field: "Week2Total", aggregate: "sum" },
                               { field: "PayPeriodTotal", aggregate: "sum" }
                        ]
                    },
                    batch: true,
                    pageable: false,
                    sortable: true,
                    filterable: false,
                    navigatable: true,
                    columns: [
                        { field: "Activity", title: "Activity", width: 190, attributes: { tip: "#:data.ActvyLongDesc#" } },
                        { field: "ActvyComments", title: "Comments", width: 70 },
                        { title: "OT", width: 35, template: "#:data.OvertimeInd=='Y'?'OT':''#" },
                        { field: "HoursDay1", editor: editNumberWithoutSpinners, headerTemplate: 'Sat
' + getDay(1) + '', width: 35, template: "#:data.HoursDay1==0?'':data.HoursDay1#", groupFooterTemplate: "#=sum#", attributes: { class: "editable-cell" } },
                        { field: "HoursDay2", editor: editNumberWithoutSpinners, headerTemplate: 'Sun
' + getDay(2) + '', width: 35, template: "#:data.HoursDay2==0?'':data.HoursDay2#", groupFooterTemplate: "#=sum#", attributes: { class: "editable-cell" } },
                        { field: "HoursDay3", editor: editNumberWithoutSpinners, headerTemplate: 'Mon
' + getDay(3) + '', width: 35, template: "#:data.HoursDay3==0?'':data.HoursDay3#", groupFooterTemplate: "#=sum#", attributes: { class: "editable-cell" } },
                        { field: "HoursDay4", editor: editNumberWithoutSpinners, headerTemplate: 'Tue
' + getDay(4) + '', width: 35, template: "#:data.HoursDay4==0?'':data.HoursDay4#", groupFooterTemplate: "#=sum#", attributes: { class: "editable-cell" } },
                        { field: "HoursDay5", editor: editNumberWithoutSpinners, headerTemplate: 'Wed
' + getDay(5) + '', width: 35, template: "#:data.HoursDay5==0?'':data.HoursDay5#", groupFooterTemplate: "#=sum#", attributes: { class: "editable-cell" } },
                        { field: "HoursDay6", editor: editNumberWithoutSpinners, headerTemplate: 'Thur
' + getDay(6) + '', width: 35, template: "#:data.HoursDay6==0?'':data.HoursDay6#", groupFooterTemplate: "#=sum#", attributes: { class: "editable-cell" } },
                        { field: "HoursDay7", editor: editNumberWithoutSpinners, headerTemplate: 'Fri
' + getDay(7) + '', width: 35, template: "#:data.HoursDay7==0?'':data.HoursDay7#", groupFooterTemplate: "#=sum#", attributes: { class: "editable-cell" } },
                        { field: "Week1Total", headerTemplate: 'Week
  1
Total', width: 50, template: "#= HoursDay1 + HoursDay2 +  HoursDay3 + HoursDay4 + HoursDay5 + HoursDay6 + HoursDay7#",
                        groupFooterTemplate: function (data) {
                            return (data["HoursDay1"].sum + data["HoursDay2"].sum + data["HoursDay3"].sum + data["HoursDay4"].sum + data["HoursDay5"].sum + data["HoursDay6"].sum + data["HoursDay7"].sum);
                        }
                        },
                        { field: "HoursDay8", editor: editNumberWithoutSpinners, headerTemplate: 'Sat
' + getDay(8) + '', width: 35, template: "#:data.HoursDay8==0?'':data.HoursDay8#", groupFooterTemplate: "#=sum#", attributes: { class: "editable-cell" } },
                        { field: "HoursDay9", editor: editNumberWithoutSpinners, headerTemplate: 'Sun
' + getDay(9) + '', width: 35, template: "#:data.HoursDay9==0?'':data.HoursDay9#", groupFooterTemplate: "#=sum#", attributes: { class: "editable-cell" } },
                        { field: "HoursDay10", editor: editNumberWithoutSpinners, headerTemplate: 'Mon
' + getDay(10) + '', width: 35, template: "#:data.HoursDay10==0?'':data.HoursDay10#", groupFooterTemplate: "#=sum#", attributes: { class: "editable-cell" } },
                        { field: "HoursDay11", editor: editNumberWithoutSpinners, headerTemplate: 'Tue
' + getDay(11) + '', width: 35, template: "#:data.HoursDay11==0?'':data.HoursDay11#", groupFooterTemplate: "#=sum#", attributes: { class: "editable-cell" } },
                        { field: "HoursDay12", editor: editNumberWithoutSpinners, headerTemplate: 'Wed
' + getDay(12) + '', width: 35, template: "#:data.HoursDay12==0?'':data.HoursDay12#", groupFooterTemplate: "#=sum#", attributes: { class: "editable-cell" } },
                        { field: "HoursDay13", editor: editNumberWithoutSpinners, headerTemplate: 'Thur
' + getDay(13) + '', width: 35, template: "#:data.HoursDay13==0?'':data.HoursDay13#", groupFooterTemplate: "#=sum#", attributes: { class: "editable-cell" } },
                        { field: "HoursDay14", editor: editNumberWithoutSpinners, headerTemplate: 'Fri
' + getDay(14) + '', width: 35, template: "#:data.HoursDay14==0?'':data.HoursDay14#", groupFooterTemplate: "#=sum#", attributes: { class: "editable-cell" } },
                        {field: "Week2Total", headerTemplate: 'Week
  2
Total', width: 50, template: "#= HoursDay8 + HoursDay9 +  HoursDay10 + HoursDay11 + HoursDay12 + HoursDay13 + HoursDay14#",
                        groupFooterTemplate: function (data) {
                            return (data["HoursDay8"].sum + data["HoursDay9"].sum + data["HoursDay10"].sum + data["HoursDay11"].sum + data["HoursDay12"].sum + data["HoursDay13"].sum + data["HoursDay14"].sum);
                        }
                        },
                        {field: "PayPeriodTotal", title: "Total", width: 50, template: "#=  HoursDay1 + HoursDay2 +  HoursDay3 + HoursDay4 + HoursDay5 + HoursDay6 + HoursDay7 + HoursDay8 + HoursDay9 +  HoursDay10 + HoursDay11 + HoursDay12 + HoursDay13 + HoursDay14#",
                        groupFooterTemplate: function (data) {
                            return (data["HoursDay1"].sum + data["HoursDay2"].sum + data["HoursDay3"].sum + data["HoursDay4"].sum + data["HoursDay5"].sum + data["HoursDay6"].sum + data["HoursDay7"].sum +
                            data["HoursDay8"].sum + data["HoursDay9"].sum + data["HoursDay10"].sum + data["HoursDay11"].sum + data["HoursDay12"].sum + data["HoursDay13"].sum + data["HoursDay14"].sum);
                        }
                        }],
                    resizable: true,
                    editable: true,
                    toolbar: toolbarTemplate(e.data.EmployeeNum, e.data.FullName, e.data.RCN, e.data.OtAllowedInd),
                    dataBound: function () {
                        //Set row color when the row is Overtime
                        var grid = childTimesheetGrid;
                        var data = grid.dataSource.data();
                        $.each(data, function (i, row) {
                            if (row.OvertimeInd == 'Y')
                                $('tr[data-uid="' + row.uid + '"] ').css("color", "#FF0000");
                        });

                        //Set background color for weekend columns
                        $('tr').each(function () {
                            $(this).find('td:nth-child(5)').addClass('Weekend_Days');
                            $(this).find('td:nth-child(6)').addClass('Weekend_Days');
                            $(this).find('td:nth-child(13)').addClass('Weekend_Days');
                            $(this).find('td:nth-child(14)').addClass('Weekend_Days');
                        });
                    },
                    save: function (e) {
                        var dataSource = this.dataSource;
                        e.model.one("change", function () {
                            dataSource.one("change", function () {
                                dataSource.aggregates().HoursDay1.sum;
                                dataSource.aggregates().HoursDay2.sum;
                                dataSource.aggregates().HoursDay3.sum;
                                dataSource.aggregates().HoursDay4.sum;
                                dataSource.aggregates().HoursDay5.sum;
                                dataSource.aggregates().HoursDay6.sum;
                                dataSource.aggregates().HoursDay7.sum;
                                dataSource.aggregates().HoursDay8.sum;
                                dataSource.aggregates().HoursDay9.sum;
                                dataSource.aggregates().HoursDay10.sum;
                                dataSource.aggregates().HoursDay11.sum;
                                dataSource.aggregates().HoursDay12.sum;
                                dataSource.aggregates().HoursDay13.sum;
                                dataSource.aggregates().HoursDay14.sum;
                                dataSource.aggregates().Week1Total.sum;
                                dataSource.aggregates().Week2Total.sum;
                                dataSource.aggregates().PayPeriodTotal.sum;
                            });
                            dataSource.fetch();
                        });
                    }

                }).data("kendoGrid");

                childTimesheetGrid.table.kendoTooltip({
                    filter: "td[tip]",
                    content: function (e) {
                        var target = e.target; // element for which the tooltip is shown
                        return $(target).attr('tip');
                    }
                });
            }
        },

Answer: Finally found a fix.
Found the tabbing was not working due to the save of the weekly and daily subtotals (my aggregates).  So I allow the save and then refocus to the next cell if the user clicks tab.
Here is my solution:
Added two variable to hold my location and if I clicked tab:
JARS.TimeSheet.focusCellHold = -1;
JARS.TimeSheet.isKeyTabHold = false;

Then added this code to the grid's databound event:
if (JARS.TimeSheet.focusCellHold > 0 && JARS.TimeSheet.isKeyTabHold) {
    setTimeout(function () {

        var grid = childTimesheetGrid;
        //Set the focus on the next cell.
        grid.current(grid.tbody.find("td").eq(JARS.TimeSheet.focusCellHold + 1));
        grid.editCell(grid.tbody.find("td").eq(JARS.TimeSheet.focusCellHold + 1));
        JARS.TimeSheet.isKeyTabHold = false;
    }, 750);
}

$(childTimesheetGrid.tbody).on("keydown", "td", function (e) {
    if (e.keyCode === kendo.keys.TAB) {
        JARS.TimeSheet.isKeyTabHold = true;
    }
});

$(childTimesheetGrid.tbody).on("focus", "td", function (e) {
    var cell = $(this).closest("td");
    var cellIndx = $("td", childTimesheetGrid.tbody).index(cell);
    JARS.TimeSheet.focusCellHold = cellIndx;
});

Answer: What version of jQuery are you using? I read there were some issues with the numeric boxes with 1.8.2...try updating.
Comment: Referring to this: [link](http://www.telerik.com/forums/tabbing-out-of-numeric-inputs-causes-changed-value-to-revert)
Comment: I am using jQuery 1.91.
Comment: Also noticed that it has issues with my comment cell in the grid.  It also goes back to the beginning of the grid when I edit the comment and tab out.


Are principal congruence subgroups ever surface groups?

Question: Define the principal congruence subgroup of level $ n $, $ \Gamma(n) $, to be the subgroup of $ PSL_2(\mathbb{Z}) $ which is congruent to the identity mod $ n $. $ \Gamma(n) $ is discrete infinite, and torsion free.
A (Fuchsian) surface group is also a discrete infinite and torsion free group of 2 by 2 matrices.
Are there any $ n $ for which $ \Gamma(n) $ is a surface group (isomorphic to the fundamental group of a surface)?
Answer: No, $PSL(2,\mathbb Z)$ has a free subgroup $F$ of finite index. If $\Gamma(n)$ was a surface group $G$, then $G$ would have a free subgroup $G\cap F$ of finite index. However every finite index subgroup of a surface group is a surface group itself possibly of different genus. Of course I assume that by "surface group" you mean the fundamental group of a closed surface.
Comment: In general does this show that there are no surface groups in $ PSL_2(\mathbb{Z}) $?
Comment: Yes, it does. Every subgroup of $PSL_2(\mathbb Z)$ has a free subgroup of finite index.
Comment: About your last question.  According to at least one definition of a Fuchsian group, a subgroup of a Fuchsian group is Fuchsian, so the answer to your question is "no".
Comment: I'm sorry I didn't make myself clear.  What I'm trying to ask is the following. Let $ \Gamma $ be a subgroup of $ PSL_2(\mathbb{R}) $ which is isomorphic to the fundamental group of a compact genus $ g $ surface with $ g \geq 2 $. Is the intersection $ \Gamma \cap  PSL_2(\mathbb{Z}) $ necessarily just the identity?
Comment: The intersection is $\Gamma$.
Comment: sorry that was a typo the $ PSL_2(\mathbb{R}) $ in the last line was supposed to be  $ PSL_2(\mathbb{Z}) $
Comment: Then the intersection may be a non-trivial free group.
Comment: oh that's very interesting! Would you happen to have an example a surface group intersecting nontrivially with $  PSL_2(\mathbb{Z}) $  that you could put in your answer or a comment?
Comment: I do not want to give a non-optimal proof. I have asked a specialist who should know. It is probably published somewhere. I suspect that every non-torsion element of $PSL_2(\mathbb R)$ is in a surface subgroup.
Comment: The experts responded. In fact every hyperbolic element of $PSL_2(\mathbb R)$ is contained in a surface subgroup. That is because  any two hyperbolic elements with the same translation length are conjugate. For example there is a surface subgroup containing the matrix $\begin{pmatrix} 2 &1 \\1&1\end{pmatrix}$. If $G$ is a surface subgroup containing this matrix, then $G\cap PSL(2,\mathbb Z)$ is infinite.
Comment: Here is a more detailed proof. Choose a hyperbolic element $f$. It has translation length $t$. You can then take any hyperbolic surface with a simple closed curve of length $t$. (This is possible by hyperbolic geometry). The surface subgroup $G$ will have a hyperbolic element $g$ with translation length $t$. Take any hyperbolic isometry sending the axis of $f$ to the axis of $g$. Conjugating $G$ by this isometry gives you your surface group containing $f$.
Comment: Thanks so much! You've gone above and beyond and I'm grateful for your help.  The next question I was going to post to MSE is given $ g \geq 2 $ is there a good way to find real algebraic numbers $ b_1, \dots b_k $ such that $ \pi_1(\Sigma_g) $ can be embedded in $ PSL_2(\mathbb{Z}[b_1, \dots, b_k]) $ For example, is there some way to, given $ g $, find a prime $ p $ such that $ \pi_1(\Sigma_g) $ embeds in $ PSL_2(\mathbb{Z}[cos(2\pi/p), sin(2\pi/p)]) $. If this expert of yours is taking more questions I would love to get an opinion!


Create a fixed length string function (originally from Java)

Question: I'm trying to create a fixed length string function in swift.  I know how it's done in Java for Android but unsure how to translate it to Swift.  This is what the Java function looks like:
private String getFixedLengthString(String name, int fixedLength) {
    if(name == null) {
        name = "";
    }
    if(name.length() > fixedLength) {
        name = name.substring(0, fixedLength);
    }
    return String.format("%1$-" + fixedLength + "s", name);
}

Any help is appreciated!
Comment: Sorry but you are in the wrong place. SO it is not a code conversion website. You should show what you have tried and the issues you are facing. You should take a moment and read hot to ask https://stackoverflow.com/help/how-to-ask
Comment: Moreover, explaining what exactly you are trying to achieve would help a lot in receiving an answer, since in that case, someone without any Java knowledge could also help.
Comment: Read [Swift Strings documentation](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/StringsAndCharacters.html) to find what you want
Comment: @dasblinkenlight he is trying to trim not pad
Comment: @DávidPásztor   I'm trying to add a string and a and a fixed length to a function to check if the string is the same as the fixed length, but if the string is nil, return empty space, " ".
Comment: @SwiftyJD Show what you have tried first. Nobody should do your homework for you
Comment: @LeoDabus He tries to do both - his `substring` line trims, while his `return` line pads.
Comment: @SwiftyJD I haven't written Java code for a long time, but if I get your code write, that's not what the Java function does. You want to return a String looking like `"\(input/substring)-\(fixedLength)"`, where input/substring consists of the first `fixedLength` characters of `name`?
Comment: @DávidPásztor yes, something like that
Answer:     func getFixedLengthString(_ name: String?, _ fixedLength: Int) -> String{
    var myName = name
    if myName == nil{
        myName = ""
    }

    if myName!.characters.count > fixedLength{
        myName = myName?.substring(to: fixedLength)
    }
    return "\(myName!)-\(fixedLength)s"
    }

try this
Comment: I did'nt say it didn't work. Anyway you should unwrap your optional instead of checking against nil and forcing unwrap it later
Comment: substring it is deprecated Swift4
Comment: @eneadume this is giving a error on the .substring - "Cannot convert value of type 'Int' to expected argument type 'String.Index'"
Comment: you can substituate substring with myName = myName[..fixedLength]
Comment: i force unwrapp becouse if it is nil i give an empty string ""
Comment: Just use nil coalescing operator `??` and provide a default value to your string
Comment: yes you are wright, but he is newbie, and he wants it as in android, so i was making something equivalent for him
Comment: @eneadume fixedLength should be a String.Index not an Int. Btw if you would like to subscript String with an Int you can take a look at this answer https://stackoverflow.com/questions/24092884/get-nth-character-of-a-string-in-swift-programming-language/38215613?s=1|43.0600#38215613. It also supports partial range operator
Answer: You can use the prefix function to get the first fixedLength characters of a String. The output String format can easily be achieved using String interpolation.
func getFixedLengthString(name:String?,fixedLength:Int)->String{
    if let name = name {
        if name.count > fixedLength {
            return "\(name.prefix(fixedLength))-\(fixedLength)s"
        } else {
            return "\(name)-\(fixedLength)s"
        }
    } else {
        return "-\(fixedLength)s"
    }
}


Need a creative way to post employee bios

Question: i need to find a creative way to post employee bios.
right now i just have it in a table, alternating bio and pictures, like this:
person 1
[picture] [bio]
person 2
[bio] [picture]
person 3
[picture] [bio]
person 4
[bio] [picture]
its really hard to maintain when i need to add or remove a person.
could anyone suggest an extension i could use for this?
it does not have to use a table, just look good(creative) and be easy to maintain
thank you!
Answer: I would suggest the best way would be to create a category for your employees then use a category blog layout with multiple columns. This would give you a nice first page where you could have name+picture, and then upon clicking their name you view an individual page about that person.

Should you choose this solution (I am assuming 1.5). Create a category for employees and create an article for each employee within this category. Seperate the photo from the main content using the "read more" button.
Then goto menus->main menu->"new"
The type you want to select is articles -> category -> category blog layout.
On the next page, pick the category you created earlier on the RH side, and just below that you can specify how many columns and how many employees to view per page.

Hope this helps, the same method loosely applies to Joomla 1.6, however, categories are setup differently.
Answer: I found a solution - DJCatalog Extension did the trick :)


If $\gcd(m,n)=1$ then $\gcd(2m-n-1,m-1)=2$?

Question: How to prove following statement:

If $\gcd(m,n)=1$, then $\gcd(2m-n-1,m-1)=2$, where $m,n$ are odd numbers and $m>n$.

Since $m=2k_1+1$ and $n=2k_2+1$ we may write:
$2m-n-1=2(2k_1+1)-2k_2-1-1=4k_1-2k_2=2(2k_1-k_2)$
$m-1=2k_1+1-1=2k_1$
So we may conclude that common divisor is $2$ but how to prove that it is greatest common divisor of those two numbers ?
Comment: $\gcd(13,5)=1$ but $\gcd(20,12)=4\ne2$...
Answer: If $m=9$ and $n=5$ then $\gcd(9,5) =1$ but $\gcd(2\times 9-5-1,9-1) = \gcd(12,8) =4$ so it is not true.
From your previous work, if $k_1$ and $k_2$ have a common factor but $2k_1+1$ and $2k_2+1$ do not then you will find a counterexample.
Answer: If $m=7$ and $n=5$, then $\gcd(m,n)=1$ and $\gcd(2m-n-1,n-1)=\gcd(8,4)=4$, so it would seem the proposition is not true.
Comment added later: Someone else gave a counterexample, with $m-1$ where I had $n-1$ above.  The comments below still stand. End of comment added later
Every divisor that $a$ and $b$ have in common is a divisor that $a$ and $b-a$ have in common.
Conversely, every divisor that $a$ and $b-a$ have in common is a divisor that $a$ and $b$ have in common.
Therefore the set of all common divisors of $a$ and $b$ is the same as the set of all common divisors of $a$ and $b-a$.
Therefore the greatest common divisor of $a$ and $b$ is the same as the greatest common divisor of $a$ and $b-a$, and that's why Euclid's algorithm works.
Think about applying all that to similar propositions.
Later edit: Subtracting those $1$s at the end changes things.  I almost wonder if somehow a slightly different identity was intended---one that is correct.  But I don't know what it would be.
Comment: @JavaMan I'm not following you.  If $n=5$ then $n-1=4\ne6$.
Comment: Oh.  I see.  But someone else posted another counterexample.
Answer: It is known/easy to prove that $\gcd(a,b) = \gcd (a \pm b,b)$.
This means that
$$\gcd(2m-n-1,m-1)=\gcd(m-n,m-1)=\gcd(m-n,m-1-(m-n))$$
$$=
\gcd(m-n,n-1)=\gcd(m-1, n-1) \,.$$
Comment: Might add here that given only that $m$ and $n$ are relatively prime and odd, we can arrange for $\gcd(m-1,n-1)$ to be *any* even number.


jQuery show/hide div in direction

Question: I have three div in the code. One is fix, one is for info and one is for detail.
Functioning: Initially I want to show only fix and info part, once click on info I want to show detail and fix and on click on detail I want to show fix and info.
For this part please find the working link : Working Example
$( document ).ready(function() {
        $("#detail").hide();

    $("#info").click(function () {
            $("#info").hide();
            $('#detail').show();
    });

    $("#detail").click(function () {
            $("#info").show();
            $("#detail").hide();
    });
});

My question is:
In this example I want to show detail part moves towards the left side in a way that fix part should always be fixed.
Here you can see the fix part is shifting towards right.
Comment: do you want info and detail to be the same size or do you want their animations different?
Answer: $( document ).ready(function() {
    $("#detail").hide();

    $("#info").click(function () {
         $("#info").css({"width":'100%'}).animate({"width":'0%'},200).hide();
         $('#detail').show().css({"width":'0'}).animate({"width":'100%'},200);
    });

    $("#detail").click(function () {
         $("#info").show().css({"width":'0'}).animate({"width":'100%'},200);
         $("#detail").css({"width":'100%'}).animate({"width":'0%'},200).hide();
    });
});

you can use it. it will work.
for smoothness may be you have to use overflow hidden container
Answer: I put your detail and info inside fix, and then use position absolute to position them. Try the code snippet.. =)

$(document).ready(function() {
  $("#detail").hide();

  $("#info").click(function() {
    $("#info").hide();
    $('#detail').show();
  });

  $("#detail").click(function() {
    $("#info").show();
    $("#detail").hide();
  });
});
#info {
  position: absolute;
  width: 30px;
  -moz-border-radius: 4px;
  -webkit-border-radius: 4px;
  -khtml-border-radius: 4px;
  border-radius: 4px;
  font: normal normal 13px Arial, Helvetica, Geneva, sans-serif;
  color: #929392;
  background: lightblue;
  margin-left: -30px;
  text-align: left;
  float: none;
  display: inline-block;
  height: 400px;
}
#detail {
  position: absolute;
  width: 80px;
  -moz-border-radius: 4px;
  -webkit-border-radius: 4px;
  -khtml-border-radius: 4px;
  border-radius: 4px;
  font: normal normal 13px Arial, Helvetica, Geneva, sans-serif;
  color: #929392;
  background: silver;
  margin-left: -80px;
  text-align: left;
  float: none;
  display: inline-block;
  height: 400px;
}
#fix {
  width: 297px;
  -moz-border-radius: 4px;
  -webkit-border-radius: 4px;
  -khtml-border-radius: 4px;
  border-radius: 4px;
  font: normal normal 13px Arial, Helvetica, Geneva, sans-serif;
  color: #929392;
  background: grey;
  margin: 0 auto;
  margin-top: 50px;
  text-align: left;
  float: right;
  display: inline-block;
  height: 400px;
}
#main {
  margin-left: auto;
  margin-right: auto;
  width: 410px;
}

      Info

      Detail

    fix

Answer: You can also do that by updating your css/style.
Jsfiddle is below.

 $( document ).ready(function() {
       $("#detail").hide();

      $("#info").click(function () {
     $("#info").hide();
        $('#detail').show();
   });

   $("#detail").click(function () {
     $("#info").show();
        $("#detail").hide();
   });
  });

#fix {
 width: 297px;
 -moz-border-radius: 4px;
 -webkit-border-radius: 4px;
 -khtml-border-radius: 4px;
 border-radius: 4px;
 font: normal normal 13px Arial, Helvetica, Geneva, sans-serif;
 color: #929392;
 background: grey;
 margin: 0 auto;
 margin-top: 50px;
 text-align:left;
 position: absolute;
    right: 0;
    top: 0;
 display:inline-block;
    height: 400px;
}

#info {
 width: 30px;
 -moz-border-radius: 4px;
 -webkit-border-radius: 4px;
 -khtml-border-radius: 4px;
 border-radius: 4px;
 font: normal normal 13px Arial, Helvetica, Geneva, sans-serif;
 color: #929392;
 background: lightblue;
 margin: 0 auto;
 margin-top: 50px;
 text-align:left;
 display: inline-block;
 height:400px;
}

#detail {
 width: 80px;
 -moz-border-radius: 4px;
 -webkit-border-radius: 4px;
 -khtml-border-radius: 4px;
 border-radius: 4px;
 font: normal normal 13px Arial, Helvetica, Geneva, sans-serif;
 color: #929392;
 background: silver;
 margin: 0 auto;
 margin-top: 50px;
 text-align:left;
 display: inline-block;
 height:400px;
}

#info,
#detail{
    position: absolute;
    right: 297px;
}

#main{
 margin-left: auto;
    margin-right: auto;
    width: 410px;
    position: relative;
}

        Info

        Detail

        fix

Answer: Try using this, it should help -
$("#info").click(function () {
      $("#info").hide();
      $('#detail').show();
      $('#detail').css('margin-left', '-50px');
});

Answer: You'll have to change the order of your divs to

       fix

       Detail

      Info

and replace all your float: left by float: right, although there is always the question whether you should use floats here in the first place.
Answer: Here is the simple syntax to use this effect

selector.hide|show|toggle( "slide", {arguments}, speed );
  Following is a simple example a simple showing the usage of this effect −

        The jQuery Example

Click on any of the buttons

  <button id="hide"> Hide </button>
  <button id="show"> Show</button>

jQuery show/hide div in direction


What's a "shade nut"?

Question: Can someone point to "the shade nut" with a real life picture? I'm assuming it's not a shade ring.

I would fit a disk of aluminum foil on top, either over or under the shade nut. You could also use sheet metal, such as from the bottom of a coffee can. This disk should not extend all the way out to the shade wall--leave at least 1/2" for ventilation to prevent dangerous heat buildup. Do not use tape or other combustible materials. If you put the disk under the shade nut you could also use a standard or fender washer to prevent damage to the foil.

Is it this? See my red lines.
Comment: "Shade" = "Lamp Shade", so it's just the nut that fastens the shade.
Comment: I would say the threaded fastener that secures a lamp shade to the lamp is likely to be what the author of that text means when they write "shade nut". But really, you're going about this the wrong way. You should post a comment under the answer you're quoting, and find out _exactly_ what the person who wrote the text meant. And yes, that means you'll have to spend a smidgen of extra time here building the reputation so that you're allowed to post a comment.
Comment: Your red lines point exactly to the shade nut (as does the blue line & text describing what the blue line is pointing to), so I'm honestly a bit confused by what you're asking and why. You seem to have perfectly identified it on "real life pictures" (even if they were sourced from the internet, not pics from your house), so you should be able to transfer this to the lamp shades in your house. If your spacial relations are so challenged that you can't make that transfer (nothing personal, my wife's aren't that great), maybe you should consider _not_ doing home repairs yourself.
Answer: For the purpose of the question you linked to, Yes the nut you have illustrated with a red mark is a nut holding on a shade so we will call it a  shade nut.
A "shade nut" is a nut that secures a lamp shade on a lamp.
I do not know if that is the official name for that part, but it is a nut on a shade. They are referred to on lamp parts websites as a "Finial" but a finial can be a design element on furniture or architecture and have nothing to do with being a nut or having threads.
Now we can call your part a lamp shade finial.
I do not have a lamp with shade so i can not provide a real life photo of a lamp finial.
Not all shade nuts or finials look that the one in your photo but they all do the same job, secure the shade to the lamp.
This nut, Alaska Man, is going to go sit in the shade.

What's a "shade nut"?


Strange output of memory usage

Question: I came across a code in How to get memory usage at run time in c++?. The code is due to @DonWakefield I ran two instances of the code and got different results.
Code:
#include <unistd.h>
#include <ios>
#include <iostream>
#include <fstream>
#include <string>

//////////////////////////////////////////////////////////////////////////////
//
// process_mem_usage(double &, double &) - takes two doubles by reference,
// attempts to read the system-dependent data for a process' virtual memory
// size and resident set size, and return the results in KB.
//
// On failure, returns 0.0, 0.0

void process_mem_usage(double& vm_usage, double& resident_set)
{
using std::ios_base;
using std::ifstream;
using std::string;

vm_usage     = 0.0;
resident_set = 0.0;

// 'file' stat seems to give the most reliable results
//
ifstream stat_stream("/proc/self/stat",ios_base::in);

// dummy vars for leading entries in stat that we don't care about
//
string pid, comm, state, ppid, pgrp, session, tty_nr;
string tpgid, flags, minflt, cminflt, majflt, cmajflt;
string utime, stime, cutime, cstime, priority, nice;
string O, itrealvalue, starttime;

// the two fields we want
//
unsigned long vsize;
long rss;

stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr
           >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt
           >> utime >> stime >> cutime >> cstime >> priority >> nice
           >> O >> itrealvalue >> starttime >> vsize >> rss; // don't care about the
rest

stat_stream.close();

long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // in case x86-64 is configured to
use 2MB pages
vm_usage     = vsize / 1024.0;
resident_set = rss * page_size_kb;
}

Test1#
int main()
{
 using std::cout;
 using std::endl;

 std::vector<int> vec1;
 double vm, rss;
 double vm1, rss1;

 process_mem_usage(vm, rss);

 vec1.resize(800000);

 process_mem_usage(vm1, rss1);
 cout << "VM: " << vm1-vm << "; RSS: " << rss1-rss << endl;

 vec1.erase(vec1.begin(), vec1.end());
 process_mem_usage(vm1, rss1);
 cout << "VM: " << vm1-vm << "; RSS: " << rss1-rss << endl;
 }

 Output:
 VM: 3128; RSS: 3208
 VM: 3132; RSS: 3316

 Test2#
 int main()
 {
 using std::cout;
 using std::endl;
 int *vec1;
 double vm, rss;
 double vm1, rss1;

 process_mem_usage(vm, rss);

 vec1 = new int [800000];

 process_mem_usage(vm1, rss1);
 cout << "VM: " << vm1-vm << "; RSS: " << rss1-rss << endl;

 delete[] vec1;
 process_mem_usage(vm1, rss1);
 cout << "VM: " << vm1-vm << "; RSS: " << rss1-rss << endl;
 }

 Output:
 VM: 3128; RSS: 76
 VM: 4; RSS: 180

Why do these tests behave differently. Shouldn't the results be closer to each other? Even the memory consumed by vector/pointer is not reflected in the output.
Another question I have is that the output shows vector occupying large memory while test2# shows the int array occupying low memory. 80k ints would require 3125kB of memory. Why is there a difference?
Comment: erasing elements from a vector doesn't recover any memory.
Comment: @roger_rowland I had some thought about this. how do I recover memory in the program then? So, whenever an erase operation is done, is memory reclaimed only when the program exits? If a vector is erased then can new allocations get access to this memory?
Answer: The underlying structure of a vector is an array that may be bigger or equal to the number of populated elements (this is called the capacity of the vector). This is to prevent constant reallocation of the entire array as you insert and remove elements.
When you erase the elements, the capacity doesn't change and the underlying structure is still there.
This question covers how to change the capacity. The recommended way appears to be:
vector<int>().swap(vec1);

Comment: Ok. So, in test1# the vector's memory would still be 80,000?
Comment: @SumanVajjala Yes, until the vector goes out of scope or you use `swap` to swap its structure with a smaller vector as above (an empty one in this case).
Comment: Shouldn't the program consume just 312.5 kB of memory? This is not reflected in the output
Comment: @SumanVajjala It's 800,000 elements, not 80,000, so 800,000*4 bytes = 3125 KB.
Comment: Ohh. My bad. I did swap the vector but the program shows around 1000 KB of memory. Another question is why does the program show that VM is consumed? Also, why are the memory statistics different for the 2 tests?
Comment: @SumanVajjala I don't understand the first question. [This](https://ideone.com/9GjHkw) shows similar results to the array test, except that the resident size is different, this may be because the compiler saw the `int[800000]` and reserved memory for that or something along those lines.

Strange output of memory usage


Do we need the tutorials tag?

Question: There are a few pending edits in the queue right that that remove tutorials.
It appears that if all of these edits are approved, that tutorials will not be on any questions anymore, so it will be deleted the night after.
I think the general consensus is that questions inquiring about tutorials aren't a good fit here, but those questions are still open, so that tags makes sense.
What are others thoughts about this?
Answer: Questions about tutorials have the same problem questions about resource links have:

They are not constructive, as they don't require a specific expertise to be answered.
They are rather subjective, as everybody could provide a different list of resource links.
Their answers don't provide an explanation of why a specific tutorial is suggested, such as why that specific tutorial is preferable to another one.
Looking at different questions about tutorials, you will notice that some of the links point to the same web site.
Their answers don't provide a solution to a problem, but they give a link to a page where a specific problem is resolved.

The more important problem with those questions is evident in this answer:

You could try NodeOne videos here.

Rather than asking for a tutorial about doing X, it would be better if the question would be specific on how doing X.
The tag should be removed from the questions, which should be closed as not constructive.

Do we need the tutorials tag?


How to update Django variable passed through context using Ajax

Question: I've spent quite some time trying to solve this, I've seen a bunch of solutions but I just can't seem to wrap my ahead around this.
So basically, I have this view in which I pass an array I want to display in the template and an index (arr in the view), which is the index of the array that I currently want to display. Meaning that when I first load the page the index will be 0 and I will display the first element of said array. Then, I wanted to update this index variable (by clicking the X button) so I can display the next elements (2, 3 and 4) of the array without reloading the page. I figured I can do this using an Ajax Query however, I can't get seem to get the value to update in the template.
Thank you in advance!
results.js

(function () {
 //automatically called as soon as the javascript is loaded
 window.addEventListener('load', main);
}());

function update_display_counter(e, display_counter){
 const $csrf_token = $('input[name="csrfmiddlewaretoken"]').attr('value');
 display_counter++;
 $("#arr_counter").val(display_counter);
 $.ajax({
  headers: { 'X-CSRFToken': $csrf_token },
  url: "/establishments/results/",
  dataType: "json",
        type: "POST",
        data: {
          'arr_counter': display_counter,
  },
  success: function (json) {
   console.log(json)
  display_counter = json['sucess']
  display_counter = parseInt(display_counter)
  $("#arr_counter").val(display_counter);

    },
      });
 return display_counter;
}

function main(){
 const acceptBtn = document.getElementById('accept_btn');
 const rejectBtn = document.getElementById('reject_btn');
 let display_counter = 0;
 acceptBtn.addEventListener('click', (e) => {
  window.location.href = 'establishments/';
 });
 rejectBtn.addEventListener('click', (e) => {
  display_counter = update_display_counter(e, display_counter);
 });
}

view.py
def handle_results(request):
if request.method == "POST":
    arr_counter = request.POST.get('arr_counter')
    print("THIS IS: ", arr_counter)
    return JsonResponse({"sucess": arr_counter})
else:
    try:
        coordinates = request.session['coordinates']
        del request.session['coordinates']
        display = handle_places_search(request, coordinates)
        handle_transactions(request, display)
    except request.ConnectionError as e:
        print("Connection error: ", str(e))
    except request.Timeout as e:
        print("Timeout Error: ", str(e))
    except request.RequestException as e:
        print("RequestException Error: ", str(e))
    except Exception as e:
        print("Error: ", str(e))
    return render(request, "results.html", context={"display": display, "arr": 0})

results.html

<!DOCTYPE html>

    {% load staticfiles %}
    {% csrf_token %}
    {% block styles %}
        <link href="{% static 'main_tanto_faz/styles/index.css' %}" rel="stylesheet">
    {% endblock %}

{{arr}}

    <button type = "button" id="accept_btn">O</button>
    Testing: {{arr}}
    <button type = "button" id="reject_btn">X</button>

Comment: your view doesn't actually do anything on a POST except sending by "success". And your javascript doesn't do anything in the success function except log the response to console. Just update your view to return whatever content is required and your javascript success function to manipulate the html to change whatever is needed in the document based on the response.
Comment: @dirkgroten Hey. I've edited my answer. I made the changes you suggested but I still can't get the template {{arr}} value to update. Is there something I'm still doing wrong?
Comment: where's the `` with id "are_counter" in your template? Your code looks good on first glance, must be small detail. Check in your browser dev tools the request/response (network tab) and set a breakpoint inside your success function to go through it step by step.
Comment: @dirkgroten Do I need the div? I wanted {{arr}} to remain hidden to the user but still update the value. How can I do that with the div? And do I set to set the element with value = {{arr}} ? I think that's what I'm finding confusing atm. Thank you for your patience
Comment: `$("#arr_counter").val(display_counter);` is already setting the value for a DOM element with id "arr_counter." you can use any div () and for any div you can always set the css to hidden (`display:none;`). But yes, it needs to be a DOM element, could be .
Comment: @dirkgroten Ok. I think I'm starting to get it. One last question would be, using $("#arr_counter").val(display_counter); to set the value to the  DOM (I have it in the template as , how can I then access and use it's value?
Comment: $("#arr_counter").val() is the current value. Now I see your , not sure that's a good idea, especially if it's in . Anyway, any div can have a val(). If you want to actually put the value in the contents of the div, then you shouldn't use val() but html() or text() but that's only relevant if you're going to display it.
Comment: @dirkgroten I don't need to display the index number as is, but I do need to do something like this in the template {{ display.display_counter}} so I can show the contents of the array to the user. So I should just use html to change the display_counter and then display it inside that div like above?
Comment: why doesn't your view return the actual value to show to the user then? Otherwise you need to already have all the elements of the array in your HTML (as hidden divs or inside a javascript array variable) and with your js, pick the right element to display.
Comment: @dirkgroten I do have all the elements of the array passed through context (see the views.py function), the only thing I really wanted to change was the second value passed in the context, arr: 0.
Comment: What I'm saying is that your js doesn't have access to `display` so you either need to output all the possible values in your template as html divs (hidden) and your js then Unhides the one with the correct index. Or which would be more logical, return the value in your POST and not in the original view.
Comment: @dirkgroten I finally figured it out, thank you for your patience :)
Answer: Your code looks fine. If you check $("#arr_counter").val() you'll see the value of the div was most likely set correctly.
Note that browser developer tools don't always reflect value changes directly in the source code, so you won't see
0
 in your browser dev tools.
Also, having your
 in  rather than  is an odd choice. It will never be displayed. If you just want to keep track of a variable in javascript, just use a var (of let in more modern ECMAScript) and adjust its value:
// In your template, initialise the var with a value from the context
var counter = {{ arr }};
// or if it's a string
var counter = "{{ arr }}";

// then when the you receive a new value through ajax:
counter = response.data.counter;


How to add one more column?

Question: Using VB6
code
Dim fso As FileSystemObject
Dim TS As TextStream
Dim TempS As String
Dim Final As String
Set fso = New FileSystemObject
Set TS = fso.OpenTextFile(1.txt, ForReading)
Final = TS.ReadAll
Do Until TS.AtEndOfStream
    TempS = TS.ReadLine
    Final = Final & TempS & vbCrLf
Loop
TS.Close
Set TS = fso.OpenTextFile(App.Path & "\Staff.txt", ForAppending, True)
    TS.Write Final
TS.Close
Set TS = Nothing
Set fso = Nothing

Above code is working, but I want add one more line while writing in Staff.txt.
Textfile
1.txt
M3,4331,57,0,3,,20090405,153601,8193,3,0,,,,
M3,4440,59,0,3,,20090405,172110,8193,3,0,,,,
M3,4439,66,0,1,,20090405,172106,8193,3,0,,,,
M3,4374,68,0,1,,20090405,165003,8193,3,0,,,,

Expected Output
When writing a file as Staff.txt
Col1, col2, col3, col4, col5, col6..
M3,4331,57,0,3,,20090405,153601,8193,3,0,,,,
M3,4440,59,0,3,,20090405,172110,8193,3,0,,,,
M3,4439,66,0,1,,20090405,172106,8193,3,0,,,,
M3,4374,68,0,1,,20090405,165003,8193,3,0,,,,

I want to add above one line like col1, col2, col3…. So on…,.  How to modify a code?
Need VB6 Code Help
Answer: First you should have a string variable to write columns names to:
Dim header as String
Dim i as Integer
For i=0 To NumberOfColumns-1
  header=header &"Col" & i & ","
Next i

Then you should write the header to your TextStream before writing any other text:(before TS.Write Final)
TS.Write Header & vbCrLf
TS.Write Final

Answer: try
Set TS = fso.OpenTextFile(App.Path & "\Staff.txt", ForAppending, True)
    TS.WriteLine("col1, col2, col3, col4, col5, col6")
    TS.Write Final
TS.Close

Also, I douth this code is working. For one, you have fso.OpenTextFile(1.txt, ForReading), should be "1.txt".

How to add one more column?


AuthenticationHandler calls everytime even Controller is not required Authorization

Question: I have added Custom security it is working fine for authrization. I don't know why Task<AuthenticateResult> HandleAuthenticateAsync() is calling for controller that don't needs authorization.
In Startup.cs below is code how I Initilize  it .
public void ConfigureServices(IServiceCollection services)
    {
        services.AddCors();
        services.AddMvc();

        services.AddAutoMapper();

c.AddSecurityDefinition(MM.AuthenticationScheme, new ApiKeyScheme()
            {
                Description = "API Key Authorization header using the mm Api Key scheme. Example: \"MM-API-KEY: {MM-API-KEY}\"",
                Name = "MM-API-KEY",
                In = "header",
                Type = "apiKey"
            });
auth.AddPolicy(MM.AuthenticationScheme, b =>
            {
                b.RequireAuthenticatedUser();
                b.AuthenticationSchemes = new List<string> { MenulogApiKey.AuthenticationScheme };
            });

services.AddAuthentication(options =>
        {
            // the scheme name has to match the value we're going to use in                 options.DefaultAuthenticateScheme = MM.AuthenticationScheme;
            options.DefaultChallengeScheme = MM.AuthenticationScheme;
        })
            .AddMenulogApiKeyAuth(o => { });

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
         app.UseAuthentication();
         }

In KeyHandler Class I am using like this :
internal class MMApiKeyHandler : AuthenticationHandler<MMApiKeyAuthOptions>

Comment: This is just the way authentication works. You will see `UseAuthentication` in your middleware pipeline configuration which means you'll always be authenticating your users - authorisation simply uses the authenticated user to determine whether or not access is allowed.
Comment: @KirkLarkin Thanks   for your help , Yes it was because of  `UseAuthentication `
Answer: (Blind guess)
The authentication filter may be set up as a global filter.
Search for something like filters.Add(
or examine the code where GlobalFilters.Filters are used.


Will Torchlight II allow importing characters from Torchlight I?

Question: Torchlight II is out, but so far I could not find any information if it will allow me to import my character from the first game.
Does anyone have better knowledge?
Answer: Since Torchlight II will have completely new character classes, and none of the ones from Torchlight I will have a comingback, you will not be able to use old characters.
It is also stated in Torchlight II FAQ in Runic Games official Forum:

Will I be able to import my old characters?
No, the original characters will be in the game as NPCs, as will other NPCs of the Destroyer, Vanquisher, and Alchemist class types. Additionally, due to various changes in gamplay systems the old character files will not be able to be imported as-is, as detailed below:
Along with the story the game will use a new wardrobing system opposed to the one in Torchlight. As a result they did not reuse the Torchlight character assets.
Comment: Good point about character class, but they can always "convert" to the closest class if they really want. :/


Beaglebone inittab issue

Question: I am developing an application in beaglebone.
I want to add start up scripts to my Beaglebone but I can not find /etc/inittab.
I am using the image : Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.05-beaglebone-2012.06.18.img.xz
I think in the previous versions of image there is /etc/initab but for the new distributions I could not find the inittab :/
I want to apply this : Automatic login on Angstrom Linux
but I can not because there is no /etc/inittab.
Where is the inittab in new distributions.
When I write uname -r it gives:
3.2.23
Regards
Comment: Auto-Login Answer: http://stackoverflow.com/questions/10282981/automatic-login-on-angstrom-linux Automatically Start Application Answer: http://stackoverflow.com/questions/14149477/auto-start-program-at-login-in-angstrom-on-beagleboard
Answer: inittab has been replaced by systemd
This is how I did it for the serial console. You can probably adapt it easily for tty1 by replacing "serial-getty@..." by "getty@...", but I haven't tested it.
cp /lib/systemd/system/serial-getty@.service /etc/systemd/system/autologin@.service
rm /email@example.com
ln -s /etc/systemd/system/autologin@.service /firstname.lastname@example.com

Create the following script file in any location (/home/root/autologin.sh in my case)
#!/bin/sh
exec /bin/login -f root

Make it executable
chmod a+x autologin.sh

Edit /etc/systemd/system/autologin@.service and update the ExecStart command by adding the -n (Do not prompt the user for a login name) and -l (Invoke the specified login_program instead of /bin/login) options.
ExecStart=-/sbin/agetty -n -l /home/root/autologin.sh -s %I 115200

Beaglebone inittab issue


Account was hacked and leveled.. What do I do now?

Question: I've never touched MoP but I was going to give it a whirl a couple days ago when I noticed I was banned. Went thru the process of getting it fixed and now I'm level 88 with (only?) 8k gold and old gear still.
I don't know if I can tank (warrior): I still have ZA/ZG 'epics' and my non-tank gear is still ruthless stuff.
I was, for some reason, in a WoTLK map when I logged in so I don't know where to go. Where should I level at 88 and is the tank gear I have, gold I have decent to run thru the new dungeons?
I'd like to not make anyone mad, ha.
Thanks!
Comment: I have heard of people's account being hacked and their gold and stuff being stolen (haven't happened in a long while though), but never heard of an account being hacked for playing (leveling and stuff). No offence, but this made me giggle. Good to know the world still has weird people out there somewhere :)
Answer: Your gear is okay to head to the correct zone in Pandaria for a level 88. I'd recommend that to be Kun-lai Summit or Towlong Steppes. You'll replace the gear pretty fast with quest greens, but it won't stop you levelling in the mean time. Regarding 8k gold, it isn't a great deal, but it will buy you the necessities and then more. You'll be fine tanking the current instances.
In order to get back to Pandaria, you need to head to either Stormwind or Orgrimmar (depending on your faction). There you will be able to take a portal to Jade Forest in Pandaria.
I suspect the hacker didn't level using quests, but just by farming mobs. Probably a bot doing this. You might not have any flight paths to the desired zones, so you might have to spend some time trekking across Pandaria. It shouldn't take too long. And quests should be available when you get there. Hope that helps.
Comment: As for the gold, it really depends on the server too. I was on a low population server, and was cheap about buying my own gems/enchants/glyphs (guild would provide). So 8K gold could be a lot, it was for me at one time (until I stacked for the Sandstone Drake).


Are there any other TypeScript tools than tsc?

Question: The TypeScript docs say:

There are two main ways to get the TypeScript tools:
  ...

But I cannot identify any other TypeScript tools than tsc.
Are there any other TypeScript tools?
Comment: That means editor tooling like tsserver.
Comment: Immediately underneath that statement in the docs it lists the two ways to get the tools. By tools it means the typescript package. There are tons of other typescript tools, but since this is the Typescript docs, it explicitly talking about the main Typescript tool: the compiler and language server.
Comment: It is talking about ways to install `tsc`. `tsc` is the main way to transpile ts to js, although it can be done with babel as well
Answer: Looking in node_modules/typescript/bin and you'll see two executable files:

tsc
tsserver

A description of tsserver has been answered here.


Does PES/FIFA support online multiplayer for older versions?

Question: Say I want to play PES 2017 / FIFA 2017 online today, does the company maintain support it?
Or has the online feature for 2017 been shut down since the 2018 version got released?
Answer: According to  EA's own site, the Fifa 17 servers for PS3, PS4, X360 are still up and running while the Xbox one and Origin servers for it are down.
For PES, it is so, that for every game the lifespan of the servers are only a few years, 2-3 normally. That means, according to reddit that the server for PES 17 was shut down in 2018.


Including an existing file yields WordPress's 404 page

Question: I have a website that is running on WordPress. In the document root of this site, I have a directory in which I test PHP scripts unrelated to my WordPress installation. I notice that whenever I require or include a file that indeed exists, I get a 404. If I comment out the require statement, all is well. At first, this was because of syntax errors. But I cleaned it up and am no longer getting anything in the error_log file. What gives?
EDIT: found this in my main error_log: malformed header from script. Bad header=X-UA-Compatible: ide.php. I've never had a problem with this on other Apache servers.
Below is the offending script:
ide.php
<?php

require_once 'config.php';

if (isset($_SESSION['username'])) {
    if (isset($_POST['command'])) {
        if ($_POST['session'] == '@') {
            session_destroy();
            header('Location: /area51/ide.php');
        } else {
            echo 'None';
        }
    } else {
        $smarty->assign('version', shell_exec("/home1/tylercro/local/python3/bin/python3 -c \"import sys;print('Python', sys.version)\""));
        $smarty->display('ide.tpl');
    }
} else {
    if (isset($_POST['username']) && isset($_POST['password'])) {
        if ($_POST['username'] == 'user' && $_POST['password'] == 'password') {
            $_SESSION['username'] = $_POST['username'];
        }
        header('Location: /area51/ide.php');
    } else {
        $smarty->display('ide-login.tpl');
    }
}

?>

config.php
<?php

error_reporting(E_ALL);

session_start();

if (!headers_sent()) {
    header('X-UA-Compatible: chrome=1');
    header('Content-Type: text/html; charset=UTF-8');
}

require_once 'Smarty-3.1.8/Smarty.class.php';

$smarty = new Smarty();
$smarty->setTemplateDir('Smarty-3.1.8/templates/');
$smarty->setCompileDir('Smarty-3.1.8/templates_c/');
$smarty->setCacheDir('Smarty-3.1.8/cache/');
$smarty->setConfigDir('Smarty-3.1.8/configs/');

?>

Answer: It was a header issue. I had some syntax errors in the headers that I was sending out.


Eclipse IDE internal project representaion

Question: Currently I'm trying to write a tool for migration from Eclipse IDE to Intellij Idea specifically for my project.
For now, the main question is how and where Eclipse store project information (i.e. libraries, dependencies between app modules and so on) internally.
P.S.
The Intellij's migration tool does not work for my project.
Update:
<code><?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
    <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
    <classpathentry excluding="generated/" kind="src" path="src"/>
    <classpathentry kind="src" path="src/"/>
    <classpathentry kind="src" path="resources"/>
    <classpathentry kind="output" path="bin"/>
</classpath>
</code>
Comment: Judging by "org.eclipse.pde.core.requiredPlugins" entry, you have an Eclipse plugin or an OSGi bundle project. How do you expect to migrate to IntelliJ? I don't believe it has any tooling for this. In Eclipse, PDE will resolve the bundles and packages referenced in your project's manifest against the target platform defined in the workspace to compute the project's classpath.
Comment: Please post the content of your .classpath file. That will help folks to help you figure our where the rest of the dependency information is located. An entry in .classpath can be dynamic, resolving based on metadata stored elsewhere.
Comment: @KonstantinKomissarchik, I've updated the post with content of .classpath file.
Comment: @KonstantinKomissarchik, it seems you're right. This module is an OSGI bundle. Also, according to http://www.jetbrains.com/idea/features/osgi.html, IntelliJ IDEA supports OSGI projects, but for some reason it doesn't work for me. Thanks for the help!
Answer: Everything that eclipse keeps on your project is stored in the .settings folder (containing a.o. .project and .classpath).
But unless you have some very specific setup you should be able to import your project into IntelliJ without any hassle. Even if it's not, I would expect that setting up the project manually in IntelliJ will be a lot faster than writing a tool for it.
Comment: As I wrote in my post, the project can't be imported using Intellij. Also, the tool can be reused to help my colleagues to migrate as well. Actually, I have already checked these files (org.eclipse.*.core.prefs from .settings, .classpath and .project), but I haven't found info about used libraries and module dependencies.
Comment: @pbespechnyi Project dependencies are in the .classpath file.
Comment: @pbespechnyi All the information is in those files. Otherwise it would not even be possible to open the project in a new eclipse installation for instance.
Comment: @StijnGeukens, I've added content of .classpath file.


From Terminal-1, Create new terminal, execute command (e.g: start JBoss), come back to Terminal-1

Question: As Stated in the title, I want to start a new terminal from (say) Terminal-1. The new Terminal will execute a command (Say, start JBoss). And after starting JBoss, there will be JBoss log in Terminal-2, so i dont want to stay there as I have some other tasks to do. I want the control back to Terminal-1, so I can execute other commands. I am running script.
Example scenario:
Running a script where i need to:
(1) Install JBoss
(2) Start JBoss
(3) Deploy a code in jboss as.
NOTE: Creating a new Terminal is not a problem. I can follow this. The problem is to come back to the primary terminal for executing further command.
Answer: You can simply do :
gnome-terminal -e jboss_command; exit;

That should close the new terminal as soon as the jboss_command finishes.
However, you almost certainly don't want that. There is no reason to open a new terminal. Just run your command in the background:
jboss_command &

If that creates output, run it like this:
jboss_command &>/dev/null &

The & at the end makes a command run in the background, allowing you to keep using the terminal. &>/dev/null redirects standard error and standard output to /dev/null, it basically discards any messages printed by the command. So, running your jboss command like this will enable you to keep working on the same terminal while the command is running.
Comment: "jboss_command &>/dev/null &"

worked perfectly for me.
Thanks a million.
Answer: I like using 'screen' for this sort of work. You can install it with sudo apt-get install screen and use it like this:

Open new screen (terminal) with screen
Execute your command(s) in it
Detach it (temporarily exit) with 'ctrl+a' release keys and then press only 'd'
Optionally open another one and do some stuff there too, detach that one also
When you want to come back type screen -ls
And then reattach one you want with screen -r screen_name

man screen for more!
Comment: any alternatives to 'ctrl+a' ? I am thinking to run a script where i dont know how to use 'ctrl+a' unfortunately.


Overhead / problems of creating Realm instances for each operation?

Question: I have split my code in many small functions which sometimes are meant to be executed together inside a transaction. So I create somewhere a Realm and open a write block, and inside this block I call all my functions.
So far I have been passing the Realm instance as parameter to the functions in order to be re-used (for calls like realm.add), but I wonder if this is really necessary? Does it have any downsides to simply create a new instance of the Realm wherever it's needed? I also wonder, in case this is not a problem, if the fact that this new Realm is being used inside a transaction which was "started by" another Realm instance, if maybe this is a problem.
Finally, I also wonder if there may be any problems with the notification token used to suppress executing the notification block for updates - for this, the particular Realm instance I use, doesn't matter, right?
P.S. I'm talking only about using Realm in the same thread, I'm aware of the multi-thread limitations.
Comment: @AustinZ Edited! I selected realm-cocoa tag but for some reason StackOverflow ignores it.
Comment: Which platform are you using Realm on? I assume Swift, given you mentioned blocks?
Answer: There's no harm in passing around Realm instances between your functions if you want to structure your code that way. There's also not really any appreciable overhead to opening multiple Realm instances on the same thread, since Realm Cocoa has an internal cache that it uses when vending out Realms on the same thread.
I suppose one possible argument against opening Realms repeatedly is that you  must either use try!, or wrap each attempt to open a Realm in a do-catch block. In most cases, though, if you've opened a Realm successfully opening it again by creating more Realm instances cannot result in file-related errors (as long as you haven't abused Realm by moving the underlying database file).
You also shouldn't need to worry about notification tokens that weren't vended out by a specific Realm instance, or using one Realm instance within another Realm instance's write transaction; if you are indeed working on the same thread Realm should work just fine in the situations you described. (And if it doesn't, please file a bug against us!)
More generally speaking, it's better to worry about optimization only if you run into performance issues and Instruments has identified a particular operation as being a potential peformance bottleneck. In your case, I think you can choose whichever solution fits your personal preferences better.


Vue - state is updating for all array items

Question: i have a very simple app that increment counter value for each array item individually. the problem is when i am incrementing the counter value, it updates for all array items
i know that it's possible to update counter value with each index of the array but can't find a better way to do it

<template>

      Name: {{ item.name }}
      Age:{{ counter }}
      <button @click="increment">
        increment
      </button>

</template>

Comment: I added an answer. I hope it helps as per the problem statement you have.
Answer: Now you have only one counter. I understand that you want individual counter for each person.
Our people are:
 1. { name: 'john' }
 2. { name: 'paul' }

If we want to have individual counter, we need to add counter for individual person (with default state, so counter is equal to 0):
 1. { name: 'john', counter: 0 }
 2. { name: 'paul', counter: 0 }

Now we can remove our single counter and increment function:
const counter = ref(0)
const increment = () => {
  counter.value = counter.value + 1
}

Next, change displayed counter (to handle our new individual counter) from:
Age:{{ counter }}

to:
Age:{{ item.counter }}

And our click function should increment person's individual counter so:
<button @click="item.counter++">
  increment
</button>

The last thing is wrapping our data variable in ref. The same you did with single counter. We have to share state between rerenders:
const data = ref([
  { name: 'john', counter: 0 },
  { name: 'paul', counter: 0 },
]);

At the end our code should look like this:

<template>

      Name: {{ item.name }}
      Age:{{ item.counter }}
      <button @click="item.counter++">increment</button>

</template>

And there is a stackblitz:
https://stackblitz.com/edit/vitejs-vite-xthp6v?file=src%2Fcomponents%2FHelloWorld.vue
Answer: To achieve the requirement, you have to bind the counter property in each object. So that you can play with it individualy.
Working Demo :

new Vue({
  el: '#app',
  data: {
    data: [{ name: 'john', counter: 0 }, { name: 'paul', counter: 0 }],
  },
  methods: {
    increment(index) {
        this.data[index].counter = this.data[index].counter + 1
    }
  }
})

      Name: {{ item.name }}
      Age: {{ item.counter }}
      <button v-on:click="increment(index)">
        increment
      </button>