あんまりにも痛いんで、ムシャクシャして、適当なぬいぐるみを報復したくなった
包丁で、無抵抗なぬいぐるみを滅多刺し。誰にでもできる惨殺行為、簡単すぎてものすごく無意味【つまらな】い。
それはさぞかし気持ちが悪く、気色が悪く、後味なんか最悪で、つまり今のオレはそのぬいぐるみ役なのだった。

Because it hurt so much, because I got angry, I wanted to take revenge on a stuffed animal.

Is it correct?
I tought you should use に in this sentence.
Is it there a difference?

I have a site at hostgator, using their "Business account". It's cheap, and comes with a private SSL cert. HOWEVER, their MySQL settings are such that any db connection goes stale fairly quickly, and then the hostgator staff try to convince you to use a VPS or dedicated server at multiple times the expense.

I'm creating and deploying WebAPIs, which can have a 'conversation' which exceeds 60 seconds. When this occurs, the db connection handle is stale, causing any db operations after my timeout to fail.

I'm in the process of implementing the following solution, but am curious if anyone else has solved this issue (where they can not modify their my.ini or my.cnf to give MySQL more resources) in a similar or completely different manner.

last part of a hook_update:

$ret = db_query( "UPDATE {my_table} set field1 = '%s', field2 = %d ... WHERE vid - %d", $node->field1, $node->field2, ... $node->vid );
if (!$ret) {
       // get private storage directory for this node:
       $cexStorage    = _cex_front_getCexStore();
       $nodeFilesPath = DRUPALROOT.'/'.$cexStorage.'/'.$node->storeDir;
       $fname         = $nodeFilesPath.'/recover.node'; 
       $readyToWrite  = serialize( $node );
       file_put_contents( $fname, $readyToWrite );
       if (file_exists( $fname )) {
         _dbgReport( 'seems to have worked!' );
       }
    }

Then this is called in my hook_form, right after I determine that node->nid is valid:

function _cex_front_recover_node( &$node ) {
  if (!isset($node->storeDir)) {
     _dbgReport( '**************************** _cex_front_recover_node: no storeDir!!!' );
     return;
  }

  // get private storage directory for this node:
  $cexStorage    = _cex_front_getCexStore();
  $nodeFilesPath = DRUPALROOT.'/'.$cexStorage.'/'.$node->storeDir;
  $fname         = $nodeFilesPath.'/recover.node';
  if (file_exists( $fname )) {
    $recovered = file_get_contents( $fname );
    if ($recovered) {
      // no longer needed:
      unlink( $fname );
      $recoveredNode = unserialize( $recovered );
      // restore the key values I need to proceed with this node:
      $node->stage = $recoveredNode->stage;
      $node->rnid  = $recoveredNode->rnid;
      $node->iris  = $recoveredNode->iris;
      cex_front_update( $node );
    }
    else {
      _dbgReport( '********* failed to read "'.$fname.'"' );
    }
  }
}

I'll be pairing the logic down to only store the key fields I need, but this works! Sure beats upgrading my server at 3x the expense. Anyone else doing something like this?

So for a not so dumb reason 5 years ago I decided not to pay a utility bill (charged me $300 for 2.5 days of service when my normal bill was < $100). Fought with them back and forth and told them to take it to collections because I wasn't going to pay it.

And it has sat there a sour spot on my credit report, but I have been waiting for the day when it goes away. Today I got a new credit report and noticed the debt had been sold to another agency, and when it sold, the day of it disappearing went from 2015 to 2020. Is that right, should I dispute it? I was always told that after 7 years a debt is taken off your record, but here it is looking like it will take more than 12 years.

Can one agency sell a debt and mark it as a new collection?

Ich bin kein deutscher Muttersprachler und wohne seit einigen Jahren in Deutschland.

Als ich Deutsch als Fremdsprache gelernt habe, habe ich folgende Regel bzgl. der Beugung von Adjektiven gelernt: Ein oder mehrere Adjektive haben starke Endungen, wenn vor dem ersten Adjektiv kein Artikel, Demonstrativ- oder Possessivpronomen vorkommt. Also: gute Menschen, mit gutem rotem Wein, mit frischer weicher Butter, neues kaltes Bier, lieber alter Freund usw.

Ich höre aber oft Ausdrücke wie mit gutem roten Wein und frage mich, welche Regel hier angewendet wird.

Meine erste Vermutung war, dass es in der Umgangssprache eine weitere Regel gibt. Nach dieser Regel ist es korrekt, wenn das erste Adjektiv in einer Kette eine starke Endung hat und alle anderen die entsprechende schwache Endung. Aber nach dieser Regel müsste man auch sagen können: mit frischer weichen Butter, neues kalte Bier, usw. Solche Ausdrücke habe ich nie gehört.

Also, ist mit gutem roten Wein überhaupt korrekt? Wenn ja, welche Regel wird hier angewendet?

I used Geogebra to draw the graph enter image description here

and I tried Mathematica

Plot[{(x^2 - 1) (x^2 - 4)}, {x, -2.3, 2.3}, 
    AxesStyle -> Arrowheads[{0.0, 0.02}], ImagePadding -> None]

How can I label and add arrow into x-axis and y-axis like above picture?

enter image description here

I'm trying to make a custom multiplication operation, which would be distributive, as well as associative with normal multiplication by scalar. Using Distribute I can get the distributive transformation:

Distribute[dot[235 vec[i] + vec[j], vec[k] + vec[l]]]

dot[235 vec[i], vec[k]] + dot[235 vec[i], vec[l]] + dot[vec[j], vec[k]] + dot[vec[j], vec[l]]

Here dot is only defined via dot[vec[i_],vec[j_]]:=....

Now I need to transform these dot[235 vec[i], vec[k]]-like items into 235 dot[vec[i], vec[k]]. How can I do this?

I have created an inventory that works via QR codes. Briefly: the QR code codes for an email with the book/student checking it out. The email is downloaded into R using the gmailR package (code not shown). The info from the email is taken and added to a table which is compared to a master table (the inventory) and the changes are then made accordingly to update the master table.

The updating works by looking to see if the book is already IN or OUT and then simply flipping it to the opposite. And if it is being checked in the student and the date are erased (switched back to NA).

My original approach to updating the table was to use a function from the apply family but the problem I ran in to was that I do not want to change ALL rows in the master table but only the ones that need to be updated. I could not figure out a way to do this without using a for loop. Is there a way to write this code more efficiently, perhaps using apply, or via any other vectorized functions? Also, any other suggestions about my general design strategy/approach for this inventory would be appreciated.

(By the way, I know I should probably use the date class for the date column but don't worry about that for now).

## Sample data. 
# new = List of books to update, the date, and student name. 
# master = The inventory
new <- structure(list(book = structure(1:3, .Label = c("Almost moon", "Ava my story", "Catching fire"), class = "factor"), date = structure(c(1L, 1L, 1L), .Label = "8/23/15", class = "factor"), student = structure(1:3, .Label = c("John", "Mary", "Sue"), class = "factor")), .Names = c("book", "date", "student"), row.names = c(NA, -3L), class = "data.frame")
master <- structure(list(book = c("A trick I learned from dead men", "Almost moon", "Austin monthly july 2013", "Ava my story", "Becoming jane austen", "Bossypants", "Catching fire", "Cold mountain", "Comfort food", "Confessions of a jane austen addict"), author = c("Aldridge", "Sebold", "Various", "Gardner", "Spence", "Fey", "Collins", "Frazier", "Jacobs", "Rigler"), status = c("IN", "IN", "IN", "IN", "IN", "IN", "IN", "IN", "IN", "IN"), student = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), date = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), .Names = c("book", "author", "status", "student", "date"), row.names = c(NA, 10L), class = "data.frame")

## Update inventory
if(sum(new[,1] %in% master$book) == length(new[,1])) {
    matches <- which(master$book %in% new[,1])
    for(i in matches) {
        if(master[i, 3] == "IN") {
            master[i, 3] <- "OUT"
            master[i, 4] <- as.character(new[new$book == master[i, 1], "student"])
            master[i, 5] <- as.character(new[new$book == master[i, 1], "date"])
        } else if(master[i, 3] == "OUT") {
            master[i, 3] <- "IN"
            master[i, 4] <- NA
            master[i, 5] <- NA
        }
    }
} else {
    stop("At least one book not found in database")
}

My wife has Cerebral Palsy (CP) so can’t balance on a normal bike, what are the options so she can go cycling with me?

We don't own a van, the size of any "bike" is important as it will have to fit in a car.

Here is my second attempt at writing clean code for "Sherlock and Pairs" challenge. For my previous thread please look here: Calculate pairs in a Set ("Sherlock and Pairs" HackerRank challenge)

Problem statement:

Sherlock is given an array of N integers (A0,A1…AN−1) by Watson. Now Watson asks Sherlock how many different pairs of indices i and j exist such that i is not equal to j but Ai is equal to Aj.

That is, Sherlock has to count the total number of pairs of indices (i,j) where Ai=Aj AND i≠j.

Input Format

The first line contains T, the number of test cases. T test cases follow. Each test case consists of two lines; the first line contains an integer N, the size of array, while the next line contains N space separated integers.

Output Format

For each test case, print the required answer on a different line.

Constraints

1≤T≤10

1≤N≤105

1≤A[i]≤106

Things that I have changed in my code:

  1. Removed dead code
  2. Followed naming conventions. Camel case for all local variables.
  3. Replaced class variables with parameters.

Things that I have kept the same:

  1. Currently there are no messages being shown in the Console for the user. I have purposely kept it that way as on HackerRank while submitting the solution I cannot post any messages to the console.

Things that still need improvement:

  1. I wanted to follow the single responsibility principle. However my CalculatePairsForAllTestCases function takes input from the user, splits it and then proceeds to the calculation. Can someone help me with how can I split that function further into Single responsibility functions?

using System;
using System.Collections.Generic;
using System.Linq;

namespace NoOfPairsInASet
{
    class Solution
    {
        static void Main()
        {
            int testCases = Convert.ToInt32(Console.ReadLine());
            CalculatePairsForAllTestCases(testCases);
        }

        private static void CalculatePairsForAllTestCases(int testCases)
        {
            for (int t = 0; t < testCases; t++)
            {
                int noOfElements = Convert.ToInt32(Console.ReadLine());
                string elements = Console.ReadLine();

                string[] arrayOfElements = elements.Split(' ');

                long[] data = arrayOfElements.Select(s => long.Parse(s)).ToArray();

                long totalPairs = CalculatePairs(data);
                Console.WriteLine(totalPairs);
            }
        }

        private static long CalculatePairs(long[] data)
        {

            Dictionary<long,long> countOfElements = GenerateDictionary(data);
            long sum = CalculateSum(countOfElements);
            return sum;
        }

        private static Dictionary<long, long> GenerateDictionary(long[] data)
        {
            Dictionary<long,long> countOfElements = new Dictionary<long, long>();
            const int DEFAULTCOUNT = 1;
            for (long i = 0; i < data.Length; i++)
            {
                if (countOfElements.ContainsKey(data[i]))
                {
                    IncrementCounter(data,countOfElements,i);
                }
                else
                {
                    countOfElements.Add(data[i], DEFAULTCOUNT);
                }
            }
            return countOfElements;
        }

        private static void IncrementCounter(long[] data,Dictionary<long, long> countOfElements, long i)
        {
            if (countOfElements != null) countOfElements[(data[i])]++;
        }

        private static long CalculateSum(Dictionary<long, long> countOfElements)
        {
            long sum = 0;
            if (countOfElements == null) return sum;
            sum = countOfElements.Where(item => item.Value > 1).Sum(item => CalculatePermutationOfValue(item.Value));
            return sum;
        }

        private static long CalculatePermutationOfValue(long n)
        {
            return n * (n - 1);
        }


    }
}

Please review the code and let me know how I could have written it better in terms of logic, coding practices or any other advice you might have.

I just bought this overpriced Wiha 386 screwdriver. It takes a 1/4 bit. It also has a "retaining ring." I put a bit in it, and everything went great. But.. how do I get the bit out of it?

I know it sounds stupid, but I can't figure out how to get the bit ouf of this screwdriver. What's the trick. This has to be a German joke of some sort. The screwdriver is titled, "Wiha 38600 Bit Holder 1/4" with Retaining Ring, Flexible Shaft."