text:
Q: error: no matching function for call to , in static function I have a class named Book that contains an object from class Author. Book's constructor is a private field so I can not use the this class to define objects, so I have another class called BookBuilder which friend to Book and Author helps me to do this.
If I remove the static function problem disappears.
The problem is:
error: no matching function for call to 'Author :: Author ()

In fact I do not have the Author default constructor
class Book {

public:

    friend class BookBuilder;
    // ...  other functions
private:

    Book(const std::string title, const std::string publisher,const Author& author, const std::string genre, int isbn, double price):title_(title),publisher_(publisher),author_(author),isbn_(isbn),price_(price),genre_(genre){}
    std::string title_;
    std::string publisher_;
    Author author_;
    double price_;
    int isbn_;
    std::string genre_;
};

class BookBuilder {

public:

    static BookBuilder start(){return BookBuilder();}
    // ... other functions

private:
    std::string title_;
    std::string publisher_;
    Author author_;
    double price_;
    int isbn_;
    std::string genre_;
};

A: Your BookBuilder::start method is
static BookBuilder start(){ return BookBuilder(); }

This will try to return a default-constructed BookBuilder. This class has a member
Author author_;

So when you try to construct a BookBuilder, it will try to default initialize the members, including default initializing your auther_ in this case. Therefore Author needs a default constructor for this to work.


text:
Q: Red laser that has a higher power output at 400nm than 623nm? I am doing experiments using a red (623nm) LED. However, when I measured the power output I noticed that it is higher at smaller wavelenghts. I did the measurements using two different power-meters and both gave me that result.
First, I am confused since I though LEDs should only emit light in a small wavelenght range.
Second, I don't understand how I can see the LED as red when it emits light in all the visible light spectrum and emits even more in the blue/violet range that in the red range..
The LED is #9008097 in the following datasheet:
https://asset.conrad.com/media10/add/160267/c1/-/gl/000180735DS01/datenblatt-180735-ledxon-9008097-highpower-led-modul-rot-3-w-865-lm-10-2-v.pdf
Thanks in advance!

A: It sounds like you might be using the power meter incorrectly. The power meter has a wavelength setting, but this only affects the calibration. It does not change the operation of the sensor. The wavelength setting is used to compensate for differences in the response of the sensor so you can get an accurate reading. For instance, most sensors have a peak somewhere, and the response falls off on both sides of that peak, so the meter has to report a higher power for the same sensor output the further the wavelength is from the peak.  Here is the responsivity curve for the S120C power sensor from ThorLabs, which uses a silicon photodiode and has a wavelength range of 400-1100 nm (https://www.thorlabs.com/images/tabimages/S120C_Responsivity_780.gif):

In your case, the LED is likely producing most of its output power around 623 nm.  Shining that light on the sensor will result in the sensor emitting some amount of photocurrent.  The meter then converts that photocurrent to optical power by looking at the responsitivity curve.  If you select 400 nm instead of 623 nm, the responsivity of the sensor at that wavelength is lower, so the power meter will compensate for that and report a higher power.  If you set the wavelength to 950 nm, you would get a lower power.  If you set it to 1100 nm, you would get an even higher power.
So in your case, you aren't measuring the LED spectrum, you're measuring the power meter calibration curve. If you want to measure at different wavelengths, then you have to use an optical filter of some sort to select the wavelength that you're interested in.

A:
However, when I measured the power output I noticed that it is higher at smaller wavelengths.

That's what the theory says as well.

and emits even more in the blue/violet range that in the red range..

Laser beam's power, among other factors, highly depends on the energy levels of the material's atoms' electrons: The shorter the wavelength, the higher the beam (photon) energy. That's why you see a blue (~450-480nm) or violet (~400-450nm) LED has a higher power level than a red one (~600-650nm).

First, I am confused since I though LEDs should only emit light in a small wavelenght range. Second, I don't understand how I can see the LED as red when it emits light in all the visible light spectrum

This depends on the LED's materials and construction. An example: A white LED is actually a blue LED, but the construction makes the beam look white.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to prevent a Docker Container to turn on while another Container in the same Service is trying to? I want to prevent several containers to turn on together.
i.e imagine that I have a service and I want to turn on 5 replicas of it.
Then They Should Act Like This:
container 1 starting ==> container 1 running and healthy ==> container 2 starts ==> container 2 running and healthy ==> container 3 starts ==> container 3 running and healthy ==> container 4 starts ==> container 4 running and healthy ==> container 5 starts ==> container 5 running and healthy.
I checked HEALTHCHECK, but I don't know exactly if it helps me in this case
Thank you

A: You can add another app container to act as coordinator.
It is much related to this question.
My idea is to have a shared Redis in which you have a shared-lock. So each new container that is starting query for that lock that is in the shared Redis, and when the lock is acquired, container finishes its startup, then release the lock.
https://redis.io/topics/distlock

Distributed locks are a very useful primitive in many environments
  where different processes must operate with shared resources in a
  mutually exclusive way.


text:
Q: SNMPv3 Trap Unique Content Separator required I send a SNMPv3 Trap and separate its fields using | and ; but these characters are also appearing in my trap, which confuses my parser at trap receiving end. I also tried most of the characters e.g. :,".><!@#$%^&*()
but all these single line character appear in the trap. I also tried special symbols like €,¾,½ but Linux is not accepting these characters.
I need a single character separator.
Could you suggest any Key that can be entered from from Keyboard and works in Linux?

A: Assignment Operator Worked =, Since it is nearly impossible of assignment operator occurring in trap content.


text:
Q: create useState in a loop based on array possible?     const columns = ['task', 'category'];

    for (const text in columns) {
        const [text, setText] = useState();
    }

I wish to create multiple useState things using a loop but to join things together seem to be a problem.
What I want it to do is to create consts: task, setTask | category, setCategory

A: Check this out:
https://reactjs.org/docs/hooks-rules.html
Explicitly mentions:

Only Call Hooks at the Top Level Don't call Hooks inside loops, conditions, or nested functions. Instead, always use Hooks at the top
  level of your React function. By following this rule, you ensure that
  Hooks are called in the same order each time a component renders.
  That's what allows React to correctly preserve the state of Hooks
  between multiple useState and useEffect calls. (If you're curious,
  we'll explain this in depth below.)

A: const [text, setText] = ... is just a deconstructing assignment, you can store the result of useState(..) (an array with two elements) however you want, for example:
const columns = ['task', 'category'];
const state = {};

for (const prop of columns) {
  const resultArr = useState();
  state[prop] = {
    val: resultArr[0],
    fn: resultArr[1]
  };
}

And you can use the results like this:
<button onClick={() => state.task.fn('new value')}>{state.task.val}</button>

But as @EmileBergeron mentioned, there doesn't seem to be any reason to use useState like this. There is definitely a more conventional way of solving the problem that you're facing.

A: Under the hood, useState relies on a linked-list-type nested data structure in the fiber. Each time you call useState that structure is "unwrapped" to get the data associated with the next hook call.
This is a good article that goes into depth about how hooks work.
In theory, so long as your loop always executes the same number of times, you could use a hook inside of the loop. HOWEVER, as other people have said here, this is not a standard way of doing things and is not advisable.

A: const columns = ['task', 'category'];
columns.map( (column, index) => {
  let col = column;
  let setCol = column+index;
  [col, setCol] = useState(false)
})

This way it will give unique state for each iteration of elements in the array columns

A: const [uploadAnimal, setAnimal] = useState(['cat']);

const loopFun = () => {
const arr = uploadAnimal
for (let i = 0; i < 10; i++) {

   arr.push('DOG')
   setUploadCount([...arr])
} };


text:
Q: Is the _xml protected variable from Mage/Core/Model/Config singleton object that holds all config information from modules ? I'm studying for certification and i had this conclusion.
After magento loads all modules available from app/etc/modules/*.xml , it loads all configuration files from each one of them, and stores it on _xml property from Mage/Core/Model/Config Singleton.
Am i correct?

A: Yes, you are correct.

The Mage_Core_Model_Config object has an _xml property. This property
  will store a PHP SimpleXML object which represents the tree for the
  Magento global config. However, this SimpleXML object is instantiated
  with a custom PHP class. This class is Mage_Core_Model_Config_Element,
  which extends a Varien_Simplexml_Element, which extends the built in
  SimpleXMLElement.

Source: The Magento Global Config, Revisited
You can dump config to file like this:
<?php

include_once 'app/Mage.php';
Mage::app();

$config = Mage::app()->getConfig()->getNode();
$io = new Varien_Io_File();
$io->write('magento_config.txt', $config->asNiceXml());


text:
Q: Computing CRC16 with reflected / bit reversed input in C I want to compute the reflected CRC16 of the CCITT polynomial 0x1021 starting from 0xC6C6 (no XOR at end, also known as CRC16-A on this page https://crccalc.com) in two different ways with (embedded) C.
For the two alternatives, I want to use the polynomial 0x1021 starting with 0xC6C6 as well as the reflected polynomial 0x8408 starting from 0x6363 (= reflect(0xC6C6)).
Assume I have a lookup-table for each polynomial:
static const UINT16 au16Table1021[256u]

and
static const UINT16 au16Table8408[256u]

and a reflect function that reverses the bit order of a byte (e.g. based on
In C/C++ what's the simplest way to reverse the order of bits in a byte?)
From the accepted answer of How to configure calculation of CRC table I expected that I would get the same result by reflecting the input, the starting CRC (wOldCRC = 0xC6C6), shifting the CRC calculation in the opposed direction and finally reflecting the resulting CRC. However, the second option I tried does not yield the expected result. What am I doing wrong?
Minimal (more or less) working example with incorrect CRC for option 2:
#include <stdio.h>
#include <stdlib.h>
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;

static const uint16_t crcTable1021[256u] = {
  0x0000u, 0x17CEu, 0x0FDFu, 0x1811u, 0x1FBEu, 0x0870u, 0x1061u, 0x07AFu,
  0x1F3Fu, 0x08F1u, 0x10E0u, 0x072Eu, 0x0081u, 0x174Fu, 0x0F5Eu, 0x1890u,
  0x1E3Du, 0x09F3u, 0x11E2u, 0x062Cu, 0x0183u, 0x164Du, 0x0E5Cu, 0x1992u,
  0x0102u, 0x16CCu, 0x0EDDu, 0x1913u, 0x1EBCu, 0x0972u, 0x1163u, 0x06ADu,
  0x1C39u, 0x0BF7u, 0x13E6u, 0x0428u, 0x0387u, 0x1449u, 0x0C58u, 0x1B96u,
  0x0306u, 0x14C8u, 0x0CD9u, 0x1B17u, 0x1CB8u, 0x0B76u, 0x1367u, 0x04A9u,
  0x0204u, 0x15CAu, 0x0DDBu, 0x1A15u, 0x1DBAu, 0x0A74u, 0x1265u, 0x05ABu,
  0x1D3Bu, 0x0AF5u, 0x12E4u, 0x052Au, 0x0285u, 0x154Bu, 0x0D5Au, 0x1A94u,
  0x1831u, 0x0FFFu, 0x17EEu, 0x0020u, 0x078Fu, 0x1041u, 0x0850u, 0x1F9Eu,
  0x070Eu, 0x10C0u, 0x08D1u, 0x1F1Fu, 0x18B0u, 0x0F7Eu, 0x176Fu, 0x00A1u,
  0x060Cu, 0x11C2u, 0x09D3u, 0x1E1Du, 0x19B2u, 0x0E7Cu, 0x166Du, 0x01A3u,
  0x1933u, 0x0EFDu, 0x16ECu, 0x0122u, 0x068Du, 0x1143u, 0x0952u, 0x1E9Cu,
  0x0408u, 0x13C6u, 0x0BD7u, 0x1C19u, 0x1BB6u, 0x0C78u, 0x1469u, 0x03A7u,
  0x1B37u, 0x0CF9u, 0x14E8u, 0x0326u, 0x0489u, 0x1347u, 0x0B56u, 0x1C98u,
  0x1A35u, 0x0DFBu, 0x15EAu, 0x0224u, 0x058Bu, 0x1245u, 0x0A54u, 0x1D9Au,
  0x050Au, 0x12C4u, 0x0AD5u, 0x1D1Bu, 0x1AB4u, 0x0D7Au, 0x156Bu, 0x02A5u,
  0x1021u, 0x07EFu, 0x1FFEu, 0x0830u, 0x0F9Fu, 0x1851u, 0x0040u, 0x178Eu,
  0x0F1Eu, 0x18D0u, 0x00C1u, 0x170Fu, 0x10A0u, 0x076Eu, 0x1F7Fu, 0x08B1u,
  0x0E1Cu, 0x19D2u, 0x01C3u, 0x160Du, 0x11A2u, 0x066Cu, 0x1E7Du, 0x09B3u,
  0x1123u, 0x06EDu, 0x1EFCu, 0x0932u, 0x0E9Du, 0x1953u, 0x0142u, 0x168Cu,
  0x0C18u, 0x1BD6u, 0x03C7u, 0x1409u, 0x13A6u, 0x0468u, 0x1C79u, 0x0BB7u,
  0x1327u, 0x04E9u, 0x1CF8u, 0x0B36u, 0x0C99u, 0x1B57u, 0x0346u, 0x1488u,
  0x1225u, 0x05EBu, 0x1DFAu, 0x0A34u, 0x0D9Bu, 0x1A55u, 0x0244u, 0x158Au,
  0x0D1Au, 0x1AD4u, 0x02C5u, 0x150Bu, 0x12A4u, 0x056Au, 0x1D7Bu, 0x0AB5u,
  0x0810u, 0x1FDEu, 0x07CFu, 0x1001u, 0x17AEu, 0x0060u, 0x1871u, 0x0FBFu,
  0x172Fu, 0x00E1u, 0x18F0u, 0x0F3Eu, 0x0891u, 0x1F5Fu, 0x074Eu, 0x1080u,
  0x162Du, 0x01E3u, 0x19F2u, 0x0E3Cu, 0x0993u, 0x1E5Du, 0x064Cu, 0x1182u,
  0x0912u, 0x1EDCu, 0x06CDu, 0x1103u, 0x16ACu, 0x0162u, 0x1973u, 0x0EBDu,
  0x1429u, 0x03E7u, 0x1BF6u, 0x0C38u, 0x0B97u, 0x1C59u, 0x0448u, 0x1386u,
  0x0B16u, 0x1CD8u, 0x04C9u, 0x1307u, 0x14A8u, 0x0366u, 0x1B77u, 0x0CB9u,
  0x0A14u, 0x1DDAu, 0x05CBu, 0x1205u, 0x15AAu, 0x0264u, 0x1A75u, 0x0DBBu,
  0x152Bu, 0x02E5u, 0x1AF4u, 0x0D3Au, 0x0A95u, 0x1D5Bu, 0x054Au, 0x1284u,
};

static const uint16_t crcTable8408[256u] = {
  0x0000u, 0x1189u, 0x2312u, 0x329Bu, 0x4624u, 0x57ADu, 0x6536u, 0x74BFu,
  0x8C48u, 0x9DC1u, 0xAF5Au, 0xBED3u, 0xCA6Cu, 0xDBE5u, 0xE97Eu, 0xF8F7u,
  0x1081u, 0x0108u, 0x3393u, 0x221Au, 0x56A5u, 0x472Cu, 0x75B7u, 0x643Eu,
  0x9CC9u, 0x8D40u, 0xBFDBu, 0xAE52u, 0xDAEDu, 0xCB64u, 0xF9FFu, 0xE876u,
  0x2102u, 0x308Bu, 0x0210u, 0x1399u, 0x6726u, 0x76AFu, 0x4434u, 0x55BDu,
  0xAD4Au, 0xBCC3u, 0x8E58u, 0x9FD1u, 0xEB6Eu, 0xFAE7u, 0xC87Cu, 0xD9F5u,
  0x3183u, 0x200Au, 0x1291u, 0x0318u, 0x77A7u, 0x662Eu, 0x54B5u, 0x453Cu,
  0xBDCBu, 0xAC42u, 0x9ED9u, 0x8F50u, 0xFBEFu, 0xEA66u, 0xD8FDu, 0xC974u,
  0x4204u, 0x538Du, 0x6116u, 0x709Fu, 0x0420u, 0x15A9u, 0x2732u, 0x36BBu,
  0xCE4Cu, 0xDFC5u, 0xED5Eu, 0xFCD7u, 0x8868u, 0x99E1u, 0xAB7Au, 0xBAF3u,
  0x5285u, 0x430Cu, 0x7197u, 0x601Eu, 0x14A1u, 0x0528u, 0x37B3u, 0x263Au,
  0xDECDu, 0xCF44u, 0xFDDFu, 0xEC56u, 0x98E9u, 0x8960u, 0xBBFBu, 0xAA72u,
  0x6306u, 0x728Fu, 0x4014u, 0x519Du, 0x2522u, 0x34ABu, 0x0630u, 0x17B9u,
  0xEF4Eu, 0xFEC7u, 0xCC5Cu, 0xDDD5u, 0xA96Au, 0xB8E3u, 0x8A78u, 0x9BF1u,
  0x7387u, 0x620Eu, 0x5095u, 0x411Cu, 0x35A3u, 0x242Au, 0x16B1u, 0x0738u,
  0xFFCFu, 0xEE46u, 0xDCDDu, 0xCD54u, 0xB9EBu, 0xA862u, 0x9AF9u, 0x8B70u,
  0x8408u, 0x9581u, 0xA71Au, 0xB693u, 0xC22Cu, 0xD3A5u, 0xE13Eu, 0xF0B7u,
  0x0840u, 0x19C9u, 0x2B52u, 0x3ADBu, 0x4E64u, 0x5FEDu, 0x6D76u, 0x7CFFu,
  0x9489u, 0x8500u, 0xB79Bu, 0xA612u, 0xD2ADu, 0xC324u, 0xF1BFu, 0xE036u,
  0x18C1u, 0x0948u, 0x3BD3u, 0x2A5Au, 0x5EE5u, 0x4F6Cu, 0x7DF7u, 0x6C7Eu,
  0xA50Au, 0xB483u, 0x8618u, 0x9791u, 0xE32Eu, 0xF2A7u, 0xC03Cu, 0xD1B5u,
  0x2942u, 0x38CBu, 0x0A50u, 0x1BD9u, 0x6F66u, 0x7EEFu, 0x4C74u, 0x5DFDu,
  0xB58Bu, 0xA402u, 0x9699u, 0x8710u, 0xF3AFu, 0xE226u, 0xD0BDu, 0xC134u,
  0x39C3u, 0x284Au, 0x1AD1u, 0x0B58u, 0x7FE7u, 0x6E6Eu, 0x5CF5u, 0x4D7Cu,
  0xC60Cu, 0xD785u, 0xE51Eu, 0xF497u, 0x8028u, 0x91A1u, 0xA33Au, 0xB2B3u,
  0x4A44u, 0x5BCDu, 0x6956u, 0x78DFu, 0x0C60u, 0x1DE9u, 0x2F72u, 0x3EFBu,
  0xD68Du, 0xC704u, 0xF59Fu, 0xE416u, 0x90A9u, 0x8120u, 0xB3BBu, 0xA232u,
  0x5AC5u, 0x4B4Cu, 0x79D7u, 0x685Eu, 0x1CE1u, 0x0D68u, 0x3FF3u, 0x2E7Au,
  0xE70Eu, 0xF687u, 0xC41Cu, 0xD595u, 0xA12Au, 0xB0A3u, 0x8238u, 0x93B1u,
  0x6B46u, 0x7ACFu, 0x4854u, 0x59DDu, 0x2D62u, 0x3CEBu, 0x0E70u, 0x1FF9u,
  0xF78Fu, 0xE606u, 0xD49Du, 0xC514u, 0xB1ABu, 0xA022u, 0x92B9u, 0x8330u,
  0x7BC7u, 0x6A4Eu, 0x58D5u, 0x495Cu, 0x3DE3u, 0x2C6Au, 0x1EF1u, 0x0F78u,
};

static uint8_t reverse(uint8_t n) {
   static uint8_t lookup[16] = {
            0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe,
            0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf, };
   uint8_t result;
   result = lookup[n & 0xF] << 4 | lookup[n>>4];
   return result;
}

static uint16_t reverse16(uint16_t n) {
   return reverse(n & 0xFF) << 8 | reverse(n >> 8);
}

uint16_t Calculate(const uint8_t *message, int nBytes, uint16_t wOldCRC) {
    uint8_t data;
    uint16_t remainder = wOldCRC;
    for (int byte = 0; byte < nBytes; ++byte) {
        data = message[byte] ^ remainder;
        remainder = crcTable8408[data] ^ (remainder >> 8);
    }
    return remainder;
}

uint16_t CalculateInv(const uint8_t *message, int nBytes, uint16_t wOldCRC) {
    uint8_t data;
    uint16_t remainder = wOldCRC; //already reversed in function call
    for (int byte = nBytes; byte > 0; --byte) {
        data = reverse(message[byte-1]) ^ remainder;
        remainder = crcTable1021[data] ^ (remainder << 8);
    }
    return reverse16(remainder);
}

int main(void) {
   uint16_t expected = 0x4167;
   uint8_t pattern[] = "Hello World!";

   uint16_t result = Calculate(pattern, 12, 0x6363);
   printf("CRC option 1: 0x%04x, expected 0x%04x\n", result, expected);

   result = CalculateInv(pattern, 12, 0xC6C6);
   printf("CRC option 2: 0x%04X, expected 0x%04X\n", result, expected);

   return EXIT_SUCCESS;
}

Output:
CRC option 1: 0x4167, expected 0x4167
CRC option 2: 0x62FD, expected 0x4167

Edit: I created the tables by slightly adapting the code from the accepted answer from How to configure calculation of CRC table as follows:
uint16_t  crcTable[256];
void Init(uint16_t polynomial) {
    uint16_t  remainder;
    for (int dividend = 0; dividend < 256; ++dividend) {
        remainder = dividend;
        for (uint8_t bit = 8; bit > 0; --bit) {
            if (remainder & 1)
                remainder = (remainder >> 1) ^ polynomial;
            else
                remainder = (remainder >> 1);
        }
        crcTable[dividend] = remainder;
    }

    printf("static const uint_t crcTable[256u] = {");
    for (int i = 0; i<32; ++i) {
       printf("\n  ");
       for (int j=0; j<8; ++j) {
          printf("0x%04Xu, ",crcTable[i*8+j]);
       }
    }
    printf("\n};\n");
}

A: For a reflected CRC16, only the bits of each byte of a message are reversed, the message itself is not reversed. The other issue is that crcTable1021 needs to be based on a left shifting algorithm, or it can be a copy of crcTable8408 with the index and values reflected. (Comment - the 8408 CRC is a reflected CRC, while the 1021 is normally a non-reflected CRC, but in this case the input and output is being reflected to match the 8408 CRC). Example code that appears to be working:
static uint16_t crcTable8408[256u];   // could use table from question
static uint16_t crcTable1021[256u];   // could use table from automationwiki

// ... no changes ... //

uint16_t CalculateInv(const uint8_t *message, int nBytes, uint16_t wOldCRC) {
    uint8_t data;
    uint16_t remainder = wOldCRC; //already reversed in function call
    for (int byte = 0; byte < nBytes; ++byte) {             // fix
        data = reverse(message[byte]) ^ (remainder >> 8);   // fix
        remainder = crcTable1021[data]  ^ (remainder << 8); // fix
    }
    return reverse16(remainder);
}

void InitTables(void) {          // generate tables
    uint16_t  polynomial = 0x8408;
    uint16_t  remainder;
    for (int dividend = 0; dividend < 256; ++dividend) {
        remainder = dividend;
        for (uint8_t bit = 8; bit > 0; --bit) {
            if (remainder & 1)
                remainder = (remainder >> 1) ^ polynomial;
            else
                remainder = (remainder >> 1);
        }
        crcTable8408[dividend] = remainder;
        crcTable1021[reverse(dividend)] = reverse16(remainder);
    }
}

int main(void) {
   uint16_t expected = 0x4167;
   uint8_t pattern[] = "Hello World!";

   InitTables();     // generate tables (or use constant tables)

   uint16_t result = Calculate(pattern, 12, 0x6363);
   printf("CRC option 1: 0x%04X, expected 0x%04x\n", result, expected);

   result = CalculateInv(pattern, 12, 0xC6C6);
   printf("CRC option 2: 0x%04X, expected 0x%04X\n", result, expected);

   return 0;
}

A: You can use crcany to generate the code (in C) for any CRC you specify. As it happens, the 16-bit CRC reflected with polynomial 0x1021, initial value 0xc6c6, and final xor 0 is already in the list of standard CRCs. This is the code generated, and it produces 0x4167 for the 12 bytes "Hello, World!":
crc16iso_iec_14443_3_a.h:
// The _bit, _byte, and _word routines return the CRC of the len bytes at mem,
// applied to the previous CRC value, crc. If mem is NULL, then the other
// arguments are ignored, and the initial CRC, i.e. the CRC of zero bytes, is
// returned. Those routines will all return the same result, differing only in
// speed and code complexity. The _rem routine returns the CRC of the remaining
// bits in the last byte, for when the number of bits in the message is not a
// multiple of eight. The low bits bits of the low byte of val are applied to
// crc. bits must be in 0..8.

#include <stddef.h>

// Compute the CRC a bit at a time.
unsigned crc16iso_iec_14443_3_a_bit(unsigned crc, void const *mem, size_t len);

// Compute the CRC of the low bits bits in val.
unsigned crc16iso_iec_14443_3_a_rem(unsigned crc, unsigned val, unsigned bits);

// Compute the CRC a byte at a time.
unsigned crc16iso_iec_14443_3_a_byte(unsigned crc, void const *mem, size_t len);

// Compute the CRC a word at a time.
unsigned crc16iso_iec_14443_3_a_word(unsigned crc, void const *mem, size_t len);

crc16iso_iec_14443_3_a.c:
#include <stdint.h>
#include "crc16iso_iec_14443_3_a.h"

// This code assumes that unsigned is 4 bytes.

unsigned crc16iso_iec_14443_3_a_bit(unsigned crc, void const *mem, size_t len) {
    unsigned char const *data = mem;
    if (data == NULL)
        return 0x6363;
    crc &= 0xffff;
    while (len--) {
        crc ^= *data++;
        for (unsigned k = 0; k < 8; k++)
            crc = crc & 1 ? (crc >> 1) ^ 0x8408 : crc >> 1;
    }
    return crc;
}

unsigned crc16iso_iec_14443_3_a_rem(unsigned crc, unsigned val, unsigned bits) {
    crc &= 0xffff;
    val &= (1U << bits) - 1;
    crc ^= val;
    while (bits--)
        crc = crc & 1 ? (crc >> 1) ^ 0x8408 : crc >> 1;
    return crc;
}

#define table_byte table_word[0]

static unsigned short const table_word[][256] = {
   {0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1,
    0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a,
    0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64,
    0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
    0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a,
    0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50,
    0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9,
    0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
    0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44,
    0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d,
    0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3,
    0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
    0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581,
    0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb,
    0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324,
    0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
    0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb,
    0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710,
    0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e,
    0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
    0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704,
    0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e,
    0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3,
    0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
    0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e,
    0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78},
   {0x0000, 0x19d8, 0x33b0, 0x2a68, 0x6760, 0x7eb8, 0x54d0, 0x4d08, 0xcec0, 0xd718,
    0xfd70, 0xe4a8, 0xa9a0, 0xb078, 0x9a10, 0x83c8, 0x9591, 0x8c49, 0xa621, 0xbff9,
    0xf2f1, 0xeb29, 0xc141, 0xd899, 0x5b51, 0x4289, 0x68e1, 0x7139, 0x3c31, 0x25e9,
    0x0f81, 0x1659, 0x2333, 0x3aeb, 0x1083, 0x095b, 0x4453, 0x5d8b, 0x77e3, 0x6e3b,
    0xedf3, 0xf42b, 0xde43, 0xc79b, 0x8a93, 0x934b, 0xb923, 0xa0fb, 0xb6a2, 0xaf7a,
    0x8512, 0x9cca, 0xd1c2, 0xc81a, 0xe272, 0xfbaa, 0x7862, 0x61ba, 0x4bd2, 0x520a,
    0x1f02, 0x06da, 0x2cb2, 0x356a, 0x4666, 0x5fbe, 0x75d6, 0x6c0e, 0x2106, 0x38de,
    0x12b6, 0x0b6e, 0x88a6, 0x917e, 0xbb16, 0xa2ce, 0xefc6, 0xf61e, 0xdc76, 0xc5ae,
    0xd3f7, 0xca2f, 0xe047, 0xf99f, 0xb497, 0xad4f, 0x8727, 0x9eff, 0x1d37, 0x04ef,
    0x2e87, 0x375f, 0x7a57, 0x638f, 0x49e7, 0x503f, 0x6555, 0x7c8d, 0x56e5, 0x4f3d,
    0x0235, 0x1bed, 0x3185, 0x285d, 0xab95, 0xb24d, 0x9825, 0x81fd, 0xccf5, 0xd52d,
    0xff45, 0xe69d, 0xf0c4, 0xe91c, 0xc374, 0xdaac, 0x97a4, 0x8e7c, 0xa414, 0xbdcc,
    0x3e04, 0x27dc, 0x0db4, 0x146c, 0x5964, 0x40bc, 0x6ad4, 0x730c, 0x8ccc, 0x9514,
    0xbf7c, 0xa6a4, 0xebac, 0xf274, 0xd81c, 0xc1c4, 0x420c, 0x5bd4, 0x71bc, 0x6864,
    0x256c, 0x3cb4, 0x16dc, 0x0f04, 0x195d, 0x0085, 0x2aed, 0x3335, 0x7e3d, 0x67e5,
    0x4d8d, 0x5455, 0xd79d, 0xce45, 0xe42d, 0xfdf5, 0xb0fd, 0xa925, 0x834d, 0x9a95,
    0xafff, 0xb627, 0x9c4f, 0x8597, 0xc89f, 0xd147, 0xfb2f, 0xe2f7, 0x613f, 0x78e7,
    0x528f, 0x4b57, 0x065f, 0x1f87, 0x35ef, 0x2c37, 0x3a6e, 0x23b6, 0x09de, 0x1006,
    0x5d0e, 0x44d6, 0x6ebe, 0x7766, 0xf4ae, 0xed76, 0xc71e, 0xdec6, 0x93ce, 0x8a16,
    0xa07e, 0xb9a6, 0xcaaa, 0xd372, 0xf91a, 0xe0c2, 0xadca, 0xb412, 0x9e7a, 0x87a2,
    0x046a, 0x1db2, 0x37da, 0x2e02, 0x630a, 0x7ad2, 0x50ba, 0x4962, 0x5f3b, 0x46e3,
    0x6c8b, 0x7553, 0x385b, 0x2183, 0x0beb, 0x1233, 0x91fb, 0x8823, 0xa24b, 0xbb93,
    0xf69b, 0xef43, 0xc52b, 0xdcf3, 0xe999, 0xf041, 0xda29, 0xc3f1, 0x8ef9, 0x9721,
    0xbd49, 0xa491, 0x2759, 0x3e81, 0x14e9, 0x0d31, 0x4039, 0x59e1, 0x7389, 0x6a51,
    0x7c08, 0x65d0, 0x4fb8, 0x5660, 0x1b68, 0x02b0, 0x28d8, 0x3100, 0xb2c8, 0xab10,
    0x8178, 0x98a0, 0xd5a8, 0xcc70, 0xe618, 0xffc0},
   {0x0000, 0x5adc, 0xb5b8, 0xef64, 0x6361, 0x39bd, 0xd6d9, 0x8c05, 0xc6c2, 0x9c1e,
    0x737a, 0x29a6, 0xa5a3, 0xff7f, 0x101b, 0x4ac7, 0x8595, 0xdf49, 0x302d, 0x6af1,
    0xe6f4, 0xbc28, 0x534c, 0x0990, 0x4357, 0x198b, 0xf6ef, 0xac33, 0x2036, 0x7aea,
    0x958e, 0xcf52, 0x033b, 0x59e7, 0xb683, 0xec5f, 0x605a, 0x3a86, 0xd5e2, 0x8f3e,
    0xc5f9, 0x9f25, 0x7041, 0x2a9d, 0xa698, 0xfc44, 0x1320, 0x49fc, 0x86ae, 0xdc72,
    0x3316, 0x69ca, 0xe5cf, 0xbf13, 0x5077, 0x0aab, 0x406c, 0x1ab0, 0xf5d4, 0xaf08,
    0x230d, 0x79d1, 0x96b5, 0xcc69, 0x0676, 0x5caa, 0xb3ce, 0xe912, 0x6517, 0x3fcb,
    0xd0af, 0x8a73, 0xc0b4, 0x9a68, 0x750c, 0x2fd0, 0xa3d5, 0xf909, 0x166d, 0x4cb1,
    0x83e3, 0xd93f, 0x365b, 0x6c87, 0xe082, 0xba5e, 0x553a, 0x0fe6, 0x4521, 0x1ffd,
    0xf099, 0xaa45, 0x2640, 0x7c9c, 0x93f8, 0xc924, 0x054d, 0x5f91, 0xb0f5, 0xea29,
    0x662c, 0x3cf0, 0xd394, 0x8948, 0xc38f, 0x9953, 0x7637, 0x2ceb, 0xa0ee, 0xfa32,
    0x1556, 0x4f8a, 0x80d8, 0xda04, 0x3560, 0x6fbc, 0xe3b9, 0xb965, 0x5601, 0x0cdd,
    0x461a, 0x1cc6, 0xf3a2, 0xa97e, 0x257b, 0x7fa7, 0x90c3, 0xca1f, 0x0cec, 0x5630,
    0xb954, 0xe388, 0x6f8d, 0x3551, 0xda35, 0x80e9, 0xca2e, 0x90f2, 0x7f96, 0x254a,
    0xa94f, 0xf393, 0x1cf7, 0x462b, 0x8979, 0xd3a5, 0x3cc1, 0x661d, 0xea18, 0xb0c4,
    0x5fa0, 0x057c, 0x4fbb, 0x1567, 0xfa03, 0xa0df, 0x2cda, 0x7606, 0x9962, 0xc3be,
    0x0fd7, 0x550b, 0xba6f, 0xe0b3, 0x6cb6, 0x366a, 0xd90e, 0x83d2, 0xc915, 0x93c9,
    0x7cad, 0x2671, 0xaa74, 0xf0a8, 0x1fcc, 0x4510, 0x8a42, 0xd09e, 0x3ffa, 0x6526,
    0xe923, 0xb3ff, 0x5c9b, 0x0647, 0x4c80, 0x165c, 0xf938, 0xa3e4, 0x2fe1, 0x753d,
    0x9a59, 0xc085, 0x0a9a, 0x5046, 0xbf22, 0xe5fe, 0x69fb, 0x3327, 0xdc43, 0x869f,
    0xcc58, 0x9684, 0x79e0, 0x233c, 0xaf39, 0xf5e5, 0x1a81, 0x405d, 0x8f0f, 0xd5d3,
    0x3ab7, 0x606b, 0xec6e, 0xb6b2, 0x59d6, 0x030a, 0x49cd, 0x1311, 0xfc75, 0xa6a9,
    0x2aac, 0x7070, 0x9f14, 0xc5c8, 0x09a1, 0x537d, 0xbc19, 0xe6c5, 0x6ac0, 0x301c,
    0xdf78, 0x85a4, 0xcf63, 0x95bf, 0x7adb, 0x2007, 0xac02, 0xf6de, 0x19ba, 0x4366,
    0x8c34, 0xd6e8, 0x398c, 0x6350, 0xef55, 0xb589, 0x5aed, 0x0031, 0x4af6, 0x102a,
    0xff4e, 0xa592, 0x2997, 0x734b, 0x9c2f, 0xc6f3},
   {0x0000, 0x1cbb, 0x3976, 0x25cd, 0x72ec, 0x6e57, 0x4b9a, 0x5721, 0xe5d8, 0xf963,
    0xdcae, 0xc015, 0x9734, 0x8b8f, 0xae42, 0xb2f9, 0xc3a1, 0xdf1a, 0xfad7, 0xe66c,
    0xb14d, 0xadf6, 0x883b, 0x9480, 0x2679, 0x3ac2, 0x1f0f, 0x03b4, 0x5495, 0x482e,
    0x6de3, 0x7158, 0x8f53, 0x93e8, 0xb625, 0xaa9e, 0xfdbf, 0xe104, 0xc4c9, 0xd872,
    0x6a8b, 0x7630, 0x53fd, 0x4f46, 0x1867, 0x04dc, 0x2111, 0x3daa, 0x4cf2, 0x5049,
    0x7584, 0x693f, 0x3e1e, 0x22a5, 0x0768, 0x1bd3, 0xa92a, 0xb591, 0x905c, 0x8ce7,
    0xdbc6, 0xc77d, 0xe2b0, 0xfe0b, 0x16b7, 0x0a0c, 0x2fc1, 0x337a, 0x645b, 0x78e0,
    0x5d2d, 0x4196, 0xf36f, 0xefd4, 0xca19, 0xd6a2, 0x8183, 0x9d38, 0xb8f5, 0xa44e,
    0xd516, 0xc9ad, 0xec60, 0xf0db, 0xa7fa, 0xbb41, 0x9e8c, 0x8237, 0x30ce, 0x2c75,
    0x09b8, 0x1503, 0x4222, 0x5e99, 0x7b54, 0x67ef, 0x99e4, 0x855f, 0xa092, 0xbc29,
    0xeb08, 0xf7b3, 0xd27e, 0xcec5, 0x7c3c, 0x6087, 0x454a, 0x59f1, 0x0ed0, 0x126b,
    0x37a6, 0x2b1d, 0x5a45, 0x46fe, 0x6333, 0x7f88, 0x28a9, 0x3412, 0x11df, 0x0d64,
    0xbf9d, 0xa326, 0x86eb, 0x9a50, 0xcd71, 0xd1ca, 0xf407, 0xe8bc, 0x2d6e, 0x31d5,
    0x1418, 0x08a3, 0x5f82, 0x4339, 0x66f4, 0x7a4f, 0xc8b6, 0xd40d, 0xf1c0, 0xed7b,
    0xba5a, 0xa6e1, 0x832c, 0x9f97, 0xeecf, 0xf274, 0xd7b9, 0xcb02, 0x9c23, 0x8098,
    0xa555, 0xb9ee, 0x0b17, 0x17ac, 0x3261, 0x2eda, 0x79fb, 0x6540, 0x408d, 0x5c36,
    0xa23d, 0xbe86, 0x9b4b, 0x87f0, 0xd0d1, 0xcc6a, 0xe9a7, 0xf51c, 0x47e5, 0x5b5e,
    0x7e93, 0x6228, 0x3509, 0x29b2, 0x0c7f, 0x10c4, 0x619c, 0x7d27, 0x58ea, 0x4451,
    0x1370, 0x0fcb, 0x2a06, 0x36bd, 0x8444, 0x98ff, 0xbd32, 0xa189, 0xf6a8, 0xea13,
    0xcfde, 0xd365, 0x3bd9, 0x2762, 0x02af, 0x1e14, 0x4935, 0x558e, 0x7043, 0x6cf8,
    0xde01, 0xc2ba, 0xe777, 0xfbcc, 0xaced, 0xb056, 0x959b, 0x8920, 0xf878, 0xe4c3,
    0xc10e, 0xddb5, 0x8a94, 0x962f, 0xb3e2, 0xaf59, 0x1da0, 0x011b, 0x24d6, 0x386d,
    0x6f4c, 0x73f7, 0x563a, 0x4a81, 0xb48a, 0xa831, 0x8dfc, 0x9147, 0xc666, 0xdadd,
    0xff10, 0xe3ab, 0x5152, 0x4de9, 0x6824, 0x749f, 0x23be, 0x3f05, 0x1ac8, 0x0673,
    0x772b, 0x6b90, 0x4e5d, 0x52e6, 0x05c7, 0x197c, 0x3cb1, 0x200a, 0x92f3, 0x8e48,
    0xab85, 0xb73e, 0xe01f, 0xfca4, 0xd969, 0xc5d2},
   {0x0000, 0x0b44, 0x1688, 0x1dcc, 0x2d10, 0x2654, 0x3b98, 0x30dc, 0x5a20, 0x5164,
    0x4ca8, 0x47ec, 0x7730, 0x7c74, 0x61b8, 0x6afc, 0xb440, 0xbf04, 0xa2c8, 0xa98c,
    0x9950, 0x9214, 0x8fd8, 0x849c, 0xee60, 0xe524, 0xf8e8, 0xf3ac, 0xc370, 0xc834,
    0xd5f8, 0xdebc, 0x6091, 0x6bd5, 0x7619, 0x7d5d, 0x4d81, 0x46c5, 0x5b09, 0x504d,
    0x3ab1, 0x31f5, 0x2c39, 0x277d, 0x17a1, 0x1ce5, 0x0129, 0x0a6d, 0xd4d1, 0xdf95,
    0xc259, 0xc91d, 0xf9c1, 0xf285, 0xef49, 0xe40d, 0x8ef1, 0x85b5, 0x9879, 0x933d,
    0xa3e1, 0xa8a5, 0xb569, 0xbe2d, 0xc122, 0xca66, 0xd7aa, 0xdcee, 0xec32, 0xe776,
    0xfaba, 0xf1fe, 0x9b02, 0x9046, 0x8d8a, 0x86ce, 0xb612, 0xbd56, 0xa09a, 0xabde,
    0x7562, 0x7e26, 0x63ea, 0x68ae, 0x5872, 0x5336, 0x4efa, 0x45be, 0x2f42, 0x2406,
    0x39ca, 0x328e, 0x0252, 0x0916, 0x14da, 0x1f9e, 0xa1b3, 0xaaf7, 0xb73b, 0xbc7f,
    0x8ca3, 0x87e7, 0x9a2b, 0x916f, 0xfb93, 0xf0d7, 0xed1b, 0xe65f, 0xd683, 0xddc7,
    0xc00b, 0xcb4f, 0x15f3, 0x1eb7, 0x037b, 0x083f, 0x38e3, 0x33a7, 0x2e6b, 0x252f,
    0x4fd3, 0x4497, 0x595b, 0x521f, 0x62c3, 0x6987, 0x744b, 0x7f0f, 0x8a55, 0x8111,
    0x9cdd, 0x9799, 0xa745, 0xac01, 0xb1cd, 0xba89, 0xd075, 0xdb31, 0xc6fd, 0xcdb9,
    0xfd65, 0xf621, 0xebed, 0xe0a9, 0x3e15, 0x3551, 0x289d, 0x23d9, 0x1305, 0x1841,
    0x058d, 0x0ec9, 0x6435, 0x6f71, 0x72bd, 0x79f9, 0x4925, 0x4261, 0x5fad, 0x54e9,
    0xeac4, 0xe180, 0xfc4c, 0xf708, 0xc7d4, 0xcc90, 0xd15c, 0xda18, 0xb0e4, 0xbba0,
    0xa66c, 0xad28, 0x9df4, 0x96b0, 0x8b7c, 0x8038, 0x5e84, 0x55c0, 0x480c, 0x4348,
    0x7394, 0x78d0, 0x651c, 0x6e58, 0x04a4, 0x0fe0, 0x122c, 0x1968, 0x29b4, 0x22f0,
    0x3f3c, 0x3478, 0x4b77, 0x4033, 0x5dff, 0x56bb, 0x6667, 0x6d23, 0x70ef, 0x7bab,
    0x1157, 0x1a13, 0x07df, 0x0c9b, 0x3c47, 0x3703, 0x2acf, 0x218b, 0xff37, 0xf473,
    0xe9bf, 0xe2fb, 0xd227, 0xd963, 0xc4af, 0xcfeb, 0xa517, 0xae53, 0xb39f, 0xb8db,
    0x8807, 0x8343, 0x9e8f, 0x95cb, 0x2be6, 0x20a2, 0x3d6e, 0x362a, 0x06f6, 0x0db2,
    0x107e, 0x1b3a, 0x71c6, 0x7a82, 0x674e, 0x6c0a, 0x5cd6, 0x5792, 0x4a5e, 0x411a,
    0x9fa6, 0x94e2, 0x892e, 0x826a, 0xb2b6, 0xb9f2, 0xa43e, 0xaf7a, 0xc586, 0xcec2,
    0xd30e, 0xd84a, 0xe896, 0xe3d2, 0xfe1e, 0xf55a},
   {0x0000, 0x042b, 0x0856, 0x0c7d, 0x10ac, 0x1487, 0x18fa, 0x1cd1, 0x2158, 0x2573,
    0x290e, 0x2d25, 0x31f4, 0x35df, 0x39a2, 0x3d89, 0x42b0, 0x469b, 0x4ae6, 0x4ecd,
    0x521c, 0x5637, 0x5a4a, 0x5e61, 0x63e8, 0x67c3, 0x6bbe, 0x6f95, 0x7344, 0x776f,
    0x7b12, 0x7f39, 0x8560, 0x814b, 0x8d36, 0x891d, 0x95cc, 0x91e7, 0x9d9a, 0x99b1,
    0xa438, 0xa013, 0xac6e, 0xa845, 0xb494, 0xb0bf, 0xbcc2, 0xb8e9, 0xc7d0, 0xc3fb,
    0xcf86, 0xcbad, 0xd77c, 0xd357, 0xdf2a, 0xdb01, 0xe688, 0xe2a3, 0xeede, 0xeaf5,
    0xf624, 0xf20f, 0xfe72, 0xfa59, 0x02d1, 0x06fa, 0x0a87, 0x0eac, 0x127d, 0x1656,
    0x1a2b, 0x1e00, 0x2389, 0x27a2, 0x2bdf, 0x2ff4, 0x3325, 0x370e, 0x3b73, 0x3f58,
    0x4061, 0x444a, 0x4837, 0x4c1c, 0x50cd, 0x54e6, 0x589b, 0x5cb0, 0x6139, 0x6512,
    0x696f, 0x6d44, 0x7195, 0x75be, 0x79c3, 0x7de8, 0x87b1, 0x839a, 0x8fe7, 0x8bcc,
    0x971d, 0x9336, 0x9f4b, 0x9b60, 0xa6e9, 0xa2c2, 0xaebf, 0xaa94, 0xb645, 0xb26e,
    0xbe13, 0xba38, 0xc501, 0xc12a, 0xcd57, 0xc97c, 0xd5ad, 0xd186, 0xddfb, 0xd9d0,
    0xe459, 0xe072, 0xec0f, 0xe824, 0xf4f5, 0xf0de, 0xfca3, 0xf888, 0x05a2, 0x0189,
    0x0df4, 0x09df, 0x150e, 0x1125, 0x1d58, 0x1973, 0x24fa, 0x20d1, 0x2cac, 0x2887,
    0x3456, 0x307d, 0x3c00, 0x382b, 0x4712, 0x4339, 0x4f44, 0x4b6f, 0x57be, 0x5395,
    0x5fe8, 0x5bc3, 0x664a, 0x6261, 0x6e1c, 0x6a37, 0x76e6, 0x72cd, 0x7eb0, 0x7a9b,
    0x80c2, 0x84e9, 0x8894, 0x8cbf, 0x906e, 0x9445, 0x9838, 0x9c13, 0xa19a, 0xa5b1,
    0xa9cc, 0xade7, 0xb136, 0xb51d, 0xb960, 0xbd4b, 0xc272, 0xc659, 0xca24, 0xce0f,
    0xd2de, 0xd6f5, 0xda88, 0xdea3, 0xe32a, 0xe701, 0xeb7c, 0xef57, 0xf386, 0xf7ad,
    0xfbd0, 0xfffb, 0x0773, 0x0358, 0x0f25, 0x0b0e, 0x17df, 0x13f4, 0x1f89, 0x1ba2,
    0x262b, 0x2200, 0x2e7d, 0x2a56, 0x3687, 0x32ac, 0x3ed1, 0x3afa, 0x45c3, 0x41e8,
    0x4d95, 0x49be, 0x556f, 0x5144, 0x5d39, 0x5912, 0x649b, 0x60b0, 0x6ccd, 0x68e6,
    0x7437, 0x701c, 0x7c61, 0x784a, 0x8213, 0x8638, 0x8a45, 0x8e6e, 0x92bf, 0x9694,
    0x9ae9, 0x9ec2, 0xa34b, 0xa760, 0xab1d, 0xaf36, 0xb3e7, 0xb7cc, 0xbbb1, 0xbf9a,
    0xc0a3, 0xc488, 0xc8f5, 0xccde, 0xd00f, 0xd424, 0xd859, 0xdc72, 0xe1fb, 0xe5d0,
    0xe9ad, 0xed86, 0xf157, 0xf57c, 0xf901, 0xfd2a},
   {0x0000, 0x9fd5, 0x37bb, 0xa86e, 0x6f76, 0xf0a3, 0x58cd, 0xc718, 0xdeec, 0x4139,
    0xe957, 0x7682, 0xb19a, 0x2e4f, 0x8621, 0x19f4, 0xb5c9, 0x2a1c, 0x8272, 0x1da7,
    0xdabf, 0x456a, 0xed04, 0x72d1, 0x6b25, 0xf4f0, 0x5c9e, 0xc34b, 0x0453, 0x9b86,
    0x33e8, 0xac3d, 0x6383, 0xfc56, 0x5438, 0xcbed, 0x0cf5, 0x9320, 0x3b4e, 0xa49b,
    0xbd6f, 0x22ba, 0x8ad4, 0x1501, 0xd219, 0x4dcc, 0xe5a2, 0x7a77, 0xd64a, 0x499f,
    0xe1f1, 0x7e24, 0xb93c, 0x26e9, 0x8e87, 0x1152, 0x08a6, 0x9773, 0x3f1d, 0xa0c8,
    0x67d0, 0xf805, 0x506b, 0xcfbe, 0xc706, 0x58d3, 0xf0bd, 0x6f68, 0xa870, 0x37a5,
    0x9fcb, 0x001e, 0x19ea, 0x863f, 0x2e51, 0xb184, 0x769c, 0xe949, 0x4127, 0xdef2,
    0x72cf, 0xed1a, 0x4574, 0xdaa1, 0x1db9, 0x826c, 0x2a02, 0xb5d7, 0xac23, 0x33f6,
    0x9b98, 0x044d, 0xc355, 0x5c80, 0xf4ee, 0x6b3b, 0xa485, 0x3b50, 0x933e, 0x0ceb,
    0xcbf3, 0x5426, 0xfc48, 0x639d, 0x7a69, 0xe5bc, 0x4dd2, 0xd207, 0x151f, 0x8aca,
    0x22a4, 0xbd71, 0x114c, 0x8e99, 0x26f7, 0xb922, 0x7e3a, 0xe1ef, 0x4981, 0xd654,
    0xcfa0, 0x5075, 0xf81b, 0x67ce, 0xa0d6, 0x3f03, 0x976d, 0x08b8, 0x861d, 0x19c8,
    0xb1a6, 0x2e73, 0xe96b, 0x76be, 0xded0, 0x4105, 0x58f1, 0xc724, 0x6f4a, 0xf09f,
    0x3787, 0xa852, 0x003c, 0x9fe9, 0x33d4, 0xac01, 0x046f, 0x9bba, 0x5ca2, 0xc377,
    0x6b19, 0xf4cc, 0xed38, 0x72ed, 0xda83, 0x4556, 0x824e, 0x1d9b, 0xb5f5, 0x2a20,
    0xe59e, 0x7a4b, 0xd225, 0x4df0, 0x8ae8, 0x153d, 0xbd53, 0x2286, 0x3b72, 0xa4a7,
    0x0cc9, 0x931c, 0x5404, 0xcbd1, 0x63bf, 0xfc6a, 0x5057, 0xcf82, 0x67ec, 0xf839,
    0x3f21, 0xa0f4, 0x089a, 0x974f, 0x8ebb, 0x116e, 0xb900, 0x26d5, 0xe1cd, 0x7e18,
    0xd676, 0x49a3, 0x411b, 0xdece, 0x76a0, 0xe975, 0x2e6d, 0xb1b8, 0x19d6, 0x8603,
    0x9ff7, 0x0022, 0xa84c, 0x3799, 0xf081, 0x6f54, 0xc73a, 0x58ef, 0xf4d2, 0x6b07,
    0xc369, 0x5cbc, 0x9ba4, 0x0471, 0xac1f, 0x33ca, 0x2a3e, 0xb5eb, 0x1d85, 0x8250,
    0x4548, 0xda9d, 0x72f3, 0xed26, 0x2298, 0xbd4d, 0x1523, 0x8af6, 0x4dee, 0xd23b,
    0x7a55, 0xe580, 0xfc74, 0x63a1, 0xcbcf, 0x541a, 0x9302, 0x0cd7, 0xa4b9, 0x3b6c,
    0x9751, 0x0884, 0xa0ea, 0x3f3f, 0xf827, 0x67f2, 0xcf9c, 0x5049, 0x49bd, 0xd668,
    0x7e06, 0xe1d3, 0x26cb, 0xb91e, 0x1170, 0x8ea5},
   {0x0000, 0x81bf, 0x0b6f, 0x8ad0, 0x16de, 0x9761, 0x1db1, 0x9c0e, 0x2dbc, 0xac03,
    0x26d3, 0xa76c, 0x3b62, 0xbadd, 0x300d, 0xb1b2, 0x5b78, 0xdac7, 0x5017, 0xd1a8,
    0x4da6, 0xcc19, 0x46c9, 0xc776, 0x76c4, 0xf77b, 0x7dab, 0xfc14, 0x601a, 0xe1a5,
    0x6b75, 0xeaca, 0xb6f0, 0x374f, 0xbd9f, 0x3c20, 0xa02e, 0x2191, 0xab41, 0x2afe,
    0x9b4c, 0x1af3, 0x9023, 0x119c, 0x8d92, 0x0c2d, 0x86fd, 0x0742, 0xed88, 0x6c37,
    0xe6e7, 0x6758, 0xfb56, 0x7ae9, 0xf039, 0x7186, 0xc034, 0x418b, 0xcb5b, 0x4ae4,
    0xd6ea, 0x5755, 0xdd85, 0x5c3a, 0x65f1, 0xe44e, 0x6e9e, 0xef21, 0x732f, 0xf290,
    0x7840, 0xf9ff, 0x484d, 0xc9f2, 0x4322, 0xc29d, 0x5e93, 0xdf2c, 0x55fc, 0xd443,
    0x3e89, 0xbf36, 0x35e6, 0xb459, 0x2857, 0xa9e8, 0x2338, 0xa287, 0x1335, 0x928a,
    0x185a, 0x99e5, 0x05eb, 0x8454, 0x0e84, 0x8f3b, 0xd301, 0x52be, 0xd86e, 0x59d1,
    0xc5df, 0x4460, 0xceb0, 0x4f0f, 0xfebd, 0x7f02, 0xf5d2, 0x746d, 0xe863, 0x69dc,
    0xe30c, 0x62b3, 0x8879, 0x09c6, 0x8316, 0x02a9, 0x9ea7, 0x1f18, 0x95c8, 0x1477,
    0xa5c5, 0x247a, 0xaeaa, 0x2f15, 0xb31b, 0x32a4, 0xb874, 0x39cb, 0xcbe2, 0x4a5d,
    0xc08d, 0x4132, 0xdd3c, 0x5c83, 0xd653, 0x57ec, 0xe65e, 0x67e1, 0xed31, 0x6c8e,
    0xf080, 0x713f, 0xfbef, 0x7a50, 0x909a, 0x1125, 0x9bf5, 0x1a4a, 0x8644, 0x07fb,
    0x8d2b, 0x0c94, 0xbd26, 0x3c99, 0xb649, 0x37f6, 0xabf8, 0x2a47, 0xa097, 0x2128,
    0x7d12, 0xfcad, 0x767d, 0xf7c2, 0x6bcc, 0xea73, 0x60a3, 0xe11c, 0x50ae, 0xd111,
    0x5bc1, 0xda7e, 0x4670, 0xc7cf, 0x4d1f, 0xcca0, 0x266a, 0xa7d5, 0x2d05, 0xacba,
    0x30b4, 0xb10b, 0x3bdb, 0xba64, 0x0bd6, 0x8a69, 0x00b9, 0x8106, 0x1d08, 0x9cb7,
    0x1667, 0x97d8, 0xae13, 0x2fac, 0xa57c, 0x24c3, 0xb8cd, 0x3972, 0xb3a2, 0x321d,
    0x83af, 0x0210, 0x88c0, 0x097f, 0x9571, 0x14ce, 0x9e1e, 0x1fa1, 0xf56b, 0x74d4,
    0xfe04, 0x7fbb, 0xe3b5, 0x620a, 0xe8da, 0x6965, 0xd8d7, 0x5968, 0xd3b8, 0x5207,
    0xce09, 0x4fb6, 0xc566, 0x44d9, 0x18e3, 0x995c, 0x138c, 0x9233, 0x0e3d, 0x8f82,
    0x0552, 0x84ed, 0x355f, 0xb4e0, 0x3e30, 0xbf8f, 0x2381, 0xa23e, 0x28ee, 0xa951,
    0x439b, 0xc224, 0x48f4, 0xc94b, 0x5545, 0xd4fa, 0x5e2a, 0xdf95, 0x6e27, 0xef98,
    0x6548, 0xe4f7, 0x78f9, 0xf946, 0x7396, 0xf229}
};

unsigned crc16iso_iec_14443_3_a_byte(unsigned crc, void const *mem, size_t len) {
    unsigned char const *data = mem;
    if (data == NULL)
        return 0x6363;
    crc &= 0xffff;
    while (len--)
        crc = (crc >> 8) ^
              table_byte[(crc ^ *data++) & 0xff];
    return crc;
}

// This code assumes that integers are stored little-endian.

unsigned crc16iso_iec_14443_3_a_word(unsigned crc, void const *mem, size_t len) {
    unsigned char const *data = mem;
    if (data == NULL)
        return 0x6363;
    crc &= 0xffff;
    while (len && ((ptrdiff_t)data & 0x7)) {
        crc = (crc >> 8) ^
              table_byte[(crc ^ *data++) & 0xff];
        len--;
    }
    if (len >= 8) {
        do {
            uintmax_t word = crc ^ *(uintmax_t const *)data;
            crc = table_word[7][word & 0xff] ^
                  table_word[6][(word >> 8) & 0xff] ^
                  table_word[5][(word >> 16) & 0xff] ^
                  table_word[4][(word >> 24) & 0xff] ^
                  table_word[3][(word >> 32) & 0xff] ^
                  table_word[2][(word >> 40) & 0xff] ^
                  table_word[1][(word >> 48) & 0xff] ^
                  table_word[0][word >> 56];
            data += 8;
            len -= 8;
        } while (len >= 8);
    }
    while (len--)
        crc = (crc >> 8) ^
              table_byte[(crc ^ *data++) & 0xff];
    return crc;
}


text:
Q: How can I put "String" (get from cursor) into an "Array" in android I want to put a "All String" data (get from "Cursor") into an "Array". But I don't know why the "Array" just return one value? I'm get lost here. Can someone help me? This is my code snippet
private String[] getOneColumn(){
    String[] myArray = null;
    Cursor cursor = mDbHelper.fetchAllNotes();
    startManagingCursor(cursor);

    if(cursor.moveToFirst()){
        String myTitle = cursor.getString(cursor.getColumnIndex(SBooksDbAdapter.KEY_TITLE_RAW));
        myArray = myTitle.split(";");
    }

    return myArray;
}

A: I'll suggest you to take a look here or here for some good examples of using cursors and databases (cursors were and still are a little troubling for me too).
As about the problem at hand, I think you forget to iterate through your Cursor's data (cursor.moveToNext(), cursor.moveToPosition(int)).
Good luck.


text:
Q: CDN don't show new image I have small problem with CDN. When I upload new image on my website in background scripts generate smaller version of this image and move it to another folder. When i want to load this file by CDN it's not available but if I delete "cdn." from link image work. Main image work without any problems but smaller version didn't via cdn. Could someone tell me why?
Link to normal version looks like:
http://cdn.example.com/uploads/image.ext - via CDN / Work
http://example.com/uploads/image.ext / Work
Link to smaller version looks like:
http://cdn.example.com/uploads/thumbnails/image.ext - via CDN / Didn't work
http://example.com/uploads/thumbnails/image.ext / Work
To do smaller version I copied normal to thumbnails folder and resizing it by
$image2 = new SimpleImage();
$image2->load('./uploads/thumbnails/image.ext');
$image2->resize(90,140);
$image2->save('./uploads/thumbnails/image.ext');

A: I done it like that: when I load image from my server then cdn cached it and now i can load image from cdn. I need to do this operation once but now if else is done every refresh. Someone have a proposition how to edit that?
$src = 'http://cdn.example.com/uploads/thumbnails/image.ext';
    if (@getimagesize($src))
        $img_prop = array('src' => 'http://cdn.example.com/uploads/thumbnails/image.ext', 'height' => 140, 'width' => 90, 'alt' => htmlspecialchars('title'));
    else
        $img_prop = array('src' => 'http://example.com/uploads/thumbnails/image.ext', 'height' => 140, 'width' => 90, 'alt' => htmlspecialchars('title'));


text:
Q: Why would an app ask another app to initiate closing a TCP connection? I'm going to share an example where I noticed this and would like to know if there is a known pattern of why one would do this.
I have two instances of rsyslog running on different machines. One acts as a receiving server, the other as the sending client.
While there is a connection the following is seen on the server:
receiving-server$  netstat -plant4 | grep 192.168.101
tcp        0      0 192.168.101.180:80      192.168.101.14:50070    ESTABLISHED 4925/rsyslogd

After that a stopping of the client service is triggered:
sending-client$ systemctl stop rsyslog

receiving-server$  netstat -plant4 | grep 192.168.101
tcp        0      0 192.168.101.180:80      192.168.101.14:50070    TIME_WAIT   -

The TIME_WAIT is a state that happens on the side which initiated the connection termination ref.

TIME-WAIT - represents waiting for enough time to pass to be sure

the remote TCP received the acknowledgment of its connection
termination request.

This means that the client is telling the server initiate closing the connections because that same client is stopping. Why wouldn't the client just close the connections?
Why does the complexity of adding another "closing protocol" on top of TCP makes sense as a design choice?

A: This process ensures all parties - client and server - have the same information about the connection state, and is generally in keeping with the design principles of TCP as opposed to UDP.
Without this, what can happen is that a client either stops a connection, or sends a message that it is stopping and that message gets lost, so you end up with a client that thinks the connection is terminated and a server that is thinking the connection is still open. The server can't confidently free-up resources associated with this connection without possibly terminating valid connections without proper notification, and may end up trying to send messages to the client - only to wait for them to time out or be rejected.
Shutting the connection abruptly would be rather selfish of the client, and part of the design of TCP is not to privilege one side of a connection or the other, and to generally make sure every message arrives as expected, and further that the sender knows the message has arrived (thus the acknowledgement).
Doing things the way you've observed ultimately ensures all parties to a communication transparently hold the same information about the state of the connection, and if one party wants to close the connection then they can be sure the other party knows this. In practice this may not be important to you in any given use case, and you still need ways to detect and handle dropped connections (such as with timeouts).
This tends to matter most when some important action should be taken on a closed connection. This could include changing the state of the user (setting them to offline in a messenger app, removing a player from a virtual world, etc), freeing up resources for others to use right away (restricting streaming to a certain number of simultaneous users), discarding temporary encryption keys or otherwise cleaning up state information that only applies to that single connection, etc.


text:
Q: NSAlertPanel problems I am designing an application to connect remotely to another computer. I want to display an NSAlertPanel on connecting however it is 'blocking' the remote side from continuing with the session until OK is pressed with the usual NSAlertPanel setup.
Is there a way to have an NSAlertPanel which is non-blocking? Thanks.

A: When you run your alert panel modally, you block the run loop of the associated thread, which is the main thread in this case.
To display a window on connection, you can use custom sheets. It's easy to use and explained in the documentation page below:
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Sheets/Tasks/UsingCustomSheets.html
However, if you need to run your alert modally, an alert that is blocking interactions with the whole application, you may need to move your connection part to another thread, which is a good practice in both cases.


text:
Q: TypeScript: Override Generic Types in Method that inherit from a Class fallback I prepared a simplified example of an Angular Service, that comes with multiple Generic Types that allows overrides via the methods. The problem I face here is = vs extends and typing within the arguments. For some reason the = works perfect for the return types but the argument types need the extends.
class Service<
    RequestBody,
    ResponseBody,
    CreateRequestBody = RequestBody,
    CreateResponseBody = ResponseBody,
>
{
    public createOne<
        $CreateRequestBody extends CreateRequestBody,
        $CreateResponseBody = CreateResponseBody
     >(body : $CreateRequestBody) : $CreateResponseBody
    {
        return null;
    }

    public createTwo<
        $CreateRequestBody = CreateRequestBody,
        $CreateResponseBody = CreateResponseBody
    >(body : $CreateRequestBody) : $CreateResponseBody
    {
        return null;
    }
}

Here are the examples to reflect the problem, I want to use the createTwo() method once I figured out the issue. At this point it does not validate the type for body.
const service: Service<{ foo: string }, void> = new Service<{ foo: string }, void>();

// working
service.createOne({
    foo: 'test'
});

// not fine as the types are not compatible
service.createOne<void, void>({
    bar: 'test'
});

// not fine as everything can be set for body - typing not working for some reason
service.createTwo({
    bar: 'test'
});

// fine as the local override works
service.createTwo<{ bar: 'test' }, void>({
    bar: 'test'
});

Here is a TypeScript Playground to see what the compiler does.

A: First, let's remove the second two type parameters on Service, since they don't seem to serve a purpose other than to be a "copy" of the existing request/response body types:
class Service<Rq, Rs> { /* ... */ }

Note that I'm using Rq and Rs to represent the original request and response body types, respectively, as I tend to follow the (admittedly had to read sometimes) convention where generic type parameters have short one-or-two character names so they can be distinguished from specific types.

So for the create() method, what you generally want is for the body type to be Rq and for the return type to be Rs.  But, you'd also like to be able to override these types by explicitly specifying types when you call it, like create<NewRequestType, NewResponseType>(body), which would have body be of type NewRequestType and would return a NewResponseType.
Disclaimer: At this point I want to note that it's hard to imagine any implementation of this function which could possibly be type safe, since the implementation at runtime will know nothing about what types were passed in for the compiler.  For example, create<string, number>("hey") should return a number and create<string, boolean>("hey") should return a boolean, but both calls compile to the JavaScript create("hey"), so there's no way even in principle for this to be accurate in all cases.  It seems like you just want to let callers use these type parameters as if they were using type assertions, like create("hey") as number or create("hey") as boolean, which is at least an explicit and well-known way to acknowledge that you're giving up on type safety.  But in the interest of progress, I'll consider type safety of the implementation out of scope and I won't belabor the point further.

So, you want  generic call signature like <RqO, RsO>(body: RqO) => RsO where RqO and RsO are the desired override types, but if you don't specify them they fall back to Rq and Rs respectively.  But the big roadblock you'll have have is that, if you don't specify type parameters, the compiler will try to infer them.  Whatever you pass in for body will cause the compiler to infer that type for RqO, since body is an inference site for RqO.  Also, if you happen to call create() in a place where the return type has an expected contextual type, the compiler will infer that type for RsO, since the contextual return type is an inference site for RsO.  And that's not what you want; you want to disable type inference for RqO and RsO.  It would be nice if you could say that body should not be used to infer RqO and the contextual return type should not be used to infer RsO.
There's no offical way to "turn off" an inference site, but there's a feature request at microsoft/TypeScript#14829 which asks for some way to implement a type function like NoInfer<T> which evaluates to T eventually but cannot be used to infer T.  And luckily, there are some suggestions that work for at least some use cases.  The one I usually use is from this comment:
type NoInfer<T> = [T][T extends any ? 0 : never];

In case it matters: here we use the fact that distributive conditional types that depend on unspecified generics are deferred, so T extends any ? 0 : never is not evaluated until after T is fixed.  Whatever T becomes, T extends any ? 0 : never will eventually evaluate as 0, and [T][0] is just T (because you are indexing into the first element of a single-element tuple type).
And that means we can write create() like this:
    public create<RqO = Rq, RsO = Rs>(
        body: NoInfer<RqO>
    ): NoInfer<RsO> {
        return null!;
    }

We're using generic parameter defaults of Rq and Rs for RqO and RsO, so when the type parameters are not specified and when inference fails (which it definitely will), they will fall back to the defaults.

So, let's try it out:
const service = new Service<{ foo: string }, string>();

First, we will not specify the request and response types, and hopefully the compiler will fall back to the Rq and Rs types from service:
const ret = service.create({
    foo: 'test'
}).toUpperCase(); // okay

service.create({
    bar: 'test'    }); // error, {bar:string} is not {foo: string}

const ret2: number = service.create({
    foo: 'test'
}); // error, number is not string

Looks good.  Now we will specify the types, and hopefully the compiler will use them and not the ones from service:
const ret3 = service.create<{ bar: string }, number>(
    { bar: "test" }).toFixed(2); // okay

const ret4 = service.create<{ bar: string }, number>(
    { foo: "test" }
); // error, {foo:string} is not {bar: string}

const ret5: string = service.create<{ bar: string }, number>(
    { bar: "test" }

Also looks good.  So this is a viable solution.

Note that there are other ways to get non-inferential type parameter usages.  You could add additional type parameters instead:
        public create<
            RqO = Rq,
            RsO = Rs,
            RqI extends RqO = RqO,
            RsI extends RsO = RsO
        >(body: RqI): RsI {
            return null!;
        }

which works because the compiler will use body to infer RqI (think "implicit" override) and the return type to infer RsI, but the constraints are RqI extends RqO and RsI extends RsO and not vice versa.  So the inferences for RqI and RsI will not affect RqO and RsO.  You can verify that this behaves similarly.  I won't go into more detail, but it's an approach that sometimes works when NoInfer<T> does not.

Playground link to code


text:
Q: Applescript Question - Adding Tracks to Playlists Seriously, I'm embarrassed to even be asking this.
I've got an Applescript that is supposed to build a playlist of a bunch of whole albums.  Everything works fine, except for actually adding the tracks to the playlist.  Here's the relevant code:
repeat with theAlbum in randAlbums
    set these_tracks to (tracks of library playlist 1 whose album is theAlbum)
    repeat with the_track in these_tracks
        add the_track to playlist thePlaylist  (* doesn't work *)
    end repeat
end repeat

The error I get is "iTunes got an error: A descriptor type mismatch occurred."
randAlbums is a list of unique album names, and thePlaylist is a playlist that is created earlier in the script.
I've been banging my head against this for what feels like a week and I haven't been able to figure it out.  Thanks in advance for any assistance you can offer :)

A: Duplicate is the command you want. Try this:
repeat with theAlbum in randAlbums
    duplicate (tracks of library playlist 1 whose album is theAlbum) to thePlaylist
end repeat

Within the iTunes interface add is used to add a new track to the iTunes library using a file system path, while duplicate is used to place a reference to an existing track in a playlist.
When the add command is used iTunes will eventually figure out that the track is already part of the library and do what you want, but not before it reads the file's metadata, schedules it for album art retrieval, etc. All of this amounts to a pretty slow operation so if you're using it within a loop for a large number of tracks iTunes will slow to a crawl.
Duplicate performs a native database lookup and adds the results to the playlist all at once so it is very fast.

A: Try:
copy the_track to end of playlist thePlaylist

instead.

A: Applescript is really weird...but checkout the scripts here dougscripts.com
Looks like he uses duplicate and not add when adding to a playlist. I'm looking at the One Song From Each script
Hmmm...how about?
add (a reference to the_track) to playlist thePlaylist

A: Try changing that line to:
add (get location of the_track) to playlist thePlaylist

or, if thePlaylist is already a playlist reference (instead of just the string name of a playlist):
add (get location of the_track) to thePlaylist


text:
Q: Parse nested JSON file, take out specific attributes and create .txt files out of it So I am having here one big JSON file which looks like this:
data = {
    "Module1": {
        "Description": "",
        "Layer": "1",
        "SourceDir": "pathModule1",
        "Attributes": {
            "some",
        },
        "Vendor": "comp",
        "components":{
            "Component1": {
               "path": "pathToCom1",
               "includes": [
                   "include1",
                   "include2",
                   "include3",
                   "include4",
                   "include5"
               ]
               "generated:" "txt"
               "memory:" "txt"
               etc
            },
            "Component2":{
               "path": "pathToCom2",
               "includes": [
                   "include1",
                   "include2",
                   "include3",
                   "include4",
                   "include5"
               ]
               "generated:" "txt"
               "memory:" "txt"
               etc
            }
        }
    },
    "Module2": {
        "Description": "",
        "Layer": "2",
        "SourceDir": "pathModule2",
        "Attributes": {
            "some",
        },
        "Vendor": "comp",
        "components":{
            "Component1": {
               "path": "pathToCom1",
               "includes": [
                   "include1",
                   "include2",
                   "include3",
                   "include4",
                   "include5"
               ]
               "generated:" "txt"
               "memory:" "txt"
               etc
            },
            "Component2":{
               "path": "pathToCom2",
               "includes": [
                   "include1",
                   "include2",
                   "include3",
                   "include4",
                   "include5"
               ]
               "generated:" "txt"
               "memory:" "txt"
               etc
            }
        }
    },
    "Module3": {
        "Description": "",
        "Layer": "3",
        "SourceDir": "path",
        "Attributes": {
            "some",
        },
        "Vendor": "",
    },
    "Module4": {
        "Description": "",
        "Layer": "4",
        "SourceDir": "path",
        "Attributes": {
            "some",
        }
    }
}

Then I filter only ones that have field "Vendor" == "comp" with:
data = {k: v for k,v in data.items() if v.get("Vendor") == "comp"}

And after that I filter out and get final output:
Module1 pathModule1 [('Component1', 'pathToCom1', ['include1', 'include2', 'include3', 'include4', 'include5']), ('Component2', 'pathToCom2', ['include1', 'include2', 'include3', 'include4', 'include5'])]
Module2 pathModule2 [('Component1', 'pathToCom1', ['include1', 'include2', 'include3', 'include4', 'include5']), ('Component2', 'pathToCom2', ['include1', 'include2', 'include3', 'include4', 'include5'])]

code for this:
for k,v in data2.items():
    components = [(comp_name, comp_data["path"], comp_data["includes"]) for comp_name, comp_data in v["components"].items()]
    print(k, v["SourceDir"], components)

Now next thing that I have to do, as final output -> create in folder some .txt files which will be named as Module name, and contain paths to it's components, like this:
Module1.txt should contain only paths to it's components, so
Module1.txt has inside:
pathToCom1
pathToCom2

Module2.txt with:
pathToCom1
pathToCom2

And also, includes should be stored inside of corresponding .txt files, so we would have at the end name of the Component, and it's "includes" fields, so we would have:
Component1.txt with inside:
 include1
 include2
 include3
 include4
 include5

Component2.txt with inside:
 include1
 include2
 include3
 include4
 include5

EDIT:
So I have managed to get this, code is:
for k,v in data.items():
    components = [(comp_name, comp_data["path"], comp_data["includes"]) for comp_name, comp_data in v["components"].items()]
    with open(components_path+k+'.txt', 'w') as f:
        for i,n in v['components '].items():
            path_to_write = n['path']
            f.write(path_to_write+'\n')
        f.close()
        for i,n in v['components'].items():
            with open(path_to_includes+i+'.txt', 'w') as f:
                includes_to_write = n['includes']
                f.write(str(includes_to_write)+'\n')
            f.close()

Now the only problem is that I get includes as one line:
['include1', 'include2', 'include3', 'include4'..]
I need them to be:
 include1
 include2
 include3
 include4
 include5

A: So finally have managed to get this working, here is the code might help someone someday:
for k,v in data.items():
    components = [(comp_name, comp_data["path"], comp_data["includes"]) for comp_name, comp_data in v["components"].items()]
    with open(components_path+k+'.txt', 'w') as f:
        for i,n in v['components '].items():
            path_to_write = n['path']
            f.write(path_to_write+'\n')
        f.close()
        for i,n in v['components'].items():
            with open(path_to_includes+i+'.txt', 'w') as f:
                includes_to_write = n['includes']
                for line in includes_to_write:
                    f.write(line+'\n')
            f.close()


text:
Q: How to Make pom.xml Relative when deployed in AWS EC2? I would like to deploy my app in AWS EC2. How to make the pom.xml file, containing the following, relative? Thanks.
<build>
        <sourceDirectory>/Users/admin/Developers/workspace/my-media-dashboard/src/main/java</sourceDirectory>
        <scriptSourceDirectory>/Users/admin/Developers/workspace/my-media-dashboard/src/main/scripts</scriptSourceDirectory>
        <testSourceDirectory>/Users/admin/Developers/workspace/my-media-dashboard/src/test/java</testSourceDirectory>
        <outputDirectory>/Users/admin/Developers/workspace/my-media-dashboard/target/classes</outputDirectory>
        <testOutputDirectory>/Users/admin/Developers/workspace/my-media-dashboard/target/test-classes</testOutputDirectory>
        <resources>
            <resource>
                <directory>/Users/admin/Developers/workspace/my-media-dashboard/src/main/resources</directory>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>/Users/admin/Developers/workspace/my-media-dashboard/src/test/resources</directory>
            </testResource>
        </testResources>
        <directory>/Users/admin/Developers/workspace/my-media-dashboard/target</directory>
        ...
</build>


text:
Q: Strict windows folder content I'd like to set some content restrictions for folders in Windows 8.
It's the same as in having library for video, audio or picture content but I'd like to control that there isn't any content or disallowed file types.
Likely, there isn't such a Windows Explorer option but maybe somebody knows software that allows one to do this?


text:
Q: How to correctly generate Json without Backslashes Problem:
I get json with backslashes as response from a GET Request
@RequestMapping(value = "repuve/recibe_captcha", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
like this:
{"mensaje":"Proceso ejecutado correctamente.","folio":"1652989601959","resultado":"{\"idSalida\":1,\"descSalida\":\"Proceso Correcto\",\"data\":[.....]}"}

When expected Result is like this:
{"mensaje":"Proceso ejecutado correctamente.","folio":"1652989601959","resultado":"{"idSalida":1,"descSalida":"Proceso Correcto","data":[.....]}"}

(The data array has a b64 image).
This is how json is created:
JSONObject object = new JSONObject();
JSONArray jArray = new JSONArray();
object.put("idSalida", 1);
object.put("descSalida", "Proceso Correcto");
jArray.put(captcha);
object.put("data", jArray);

I've tried some answers from StackOverflow using replace() but none of them seems to work for me.
Is there another way to remove the backslashes and get the correct json format delivered to front?
Thank you.

A: Any JSON generating framework should actually escape the nested quotation marks. If you expect the string to look differently, you will have write code that assembles that JSONary string the way you want.


text:
Q: How can I turn off the setting where intellij automatically creates brackets?
When I type position, then equal, make brackets automatically generated.
I don't want it. Any turn off option or change?

A: Please try setting Add for JSX attributes: to None (or Quotes if you prefer quotes instead of braces being added) in Preferences | Editor | Code Style | HTML | Other; you can also set it to Based on type to have either braces or quotes auto-completed depending on props type


text:
Q: C# Serialization - Could not find the assembly I am working on C# TCP Server-Client programming. My problem is simple but somehow i couldnt figure it out.
I have an object i would like to seriliaze this object send over socket and deserialize client side. But problem is with deserializing. I serialize object with binaryformatter. Actually i am getting the actual byte array i should. But somehow while deserializing i am getting

System.Runtime.Serialization.SerializationException: 'Multi Server,
  Version=1.0.0.0, Culture=neutural, PublicTokenKey=Null' assembly could
  not found.

When i try to deserialize on the server side after serializing it has no problem.
I tried to customize binder which didnt work also. I really appriciate if somebody could help me.

A: If I'm guessing correct, you have 2 projects - "Multi Client" and "Multi Server".
You serialize object defined in "Multi Server" and then you have a copy of that class in "Multi Client".
So you serialize an object "MultiServer.SomeClass" and then you want to make it a "MultiClient.SomeClass". This ain't gonna work.
You need to create a common dll project (let's name it "MultiCommon", where you will put your class, and reference it by both "MultiServer" and "MultiClient". In this way, you will serialize and deserialize not "MultiServer.SomeClass" but "MultiCommon.SomeClass".

A: It sounds like you're using BinaryFormatter, in which case frankly I think the most valuable advice would be: don't do that. The data format of BinaryFormatter is fundamentally tied to your exact implementation details, making it very hard to a: have different code at different ends (meaning: deployment is very hard and brittle - everywhere needs to change at the same time), or b: revise the implementation over time.
Frankly, I would strongly advise looking at alternative serialization tools. I'm hugely biased, but protobuf-net works very well for this type of scenario; it is still "binary" (meaning: not text), but it isn't tied to the internal implementation details. It is fast (usually much faster than BinaryFormatter), efficient (usually much less bandwidth required than BinaryFormatter), free, and is usually very easy to apply to an existing object model; it usually means going from this:
[Serializable]
public class Custom {
    public int Id {get;set;}
    public string Name {get;set;}
    // ...etc
}

to this:
[ProtoContract] // you can keep the [Serializable] for compat if you want
public class Custom {
    [ProtoMember(1)]
    public int Id {get;set;}
    [ProtoMember(2)]
    public string Name {get;set;}
    // ...etc
}


text:
Q: How do I display the character for 1/2 in an NSString in iOS? I'm working on an application for iOS in which I would like to place the fractional value 1/2 as a single character within an NSString for use in an UILabel, is this possible?

A: Try setting the label's text property to the Unicode of 1/2:
label.text = [NSString stringWithFormat:@"%C",0x00bd];

A: You can simply use Mac OS's built-in character viewer: http://docs.info.apple.com/article.html?path=Mac/10.6/en/8164.html
So you can just do label.text = @"½"


text:
Q: How to override a has_many association so it shows default values from a parent model There are three models: Country, City and Plan.
A plan can be associated to a country or a city. If the city has plans, then return those plans. If the city doesn't have plans, then return the city's country's plans.
For example:
United_Kingdom has three plans: uk_default_1, uk_default_2, uk_default_3.
London has two plans: london_1, london_2.
Leeds doesn't have associated plans.
London and Leeds belong to United_Kingdom.
I want to achieve:
London.plans # [london_1, london_2]
Leeds.plans # [uk_default_1, uk_default_2, uk_default_3]

I started defining the following relationships:
class Country < ActiveRecord::Base
  has_many :cities
end

class City < ActiveRecord::Base
  belongs_to :country
  has_many :plans
end

class Plan < ActiveRecord::Base
  belongs_to :country
  belongs_to :city
end

But I don't know how to go from here. How can I do this in the rails way?

A: I'd probably just make and use a new method active_plans in the City model, which would return city plans if present, country plans if not...
class Country < ActiveRecord::Base
  has_many :cities
  has_many :plans # added to support "country.plans in City model"
end

class City < ActiveRecord::Base
  belongs_to :country
  has_many :plans

  def active_plans
    return plans if plans.present?
    return country.plans
  end
end


text:
Q: Command substitution includes the text of a previous echo command I have a script which writes some header info to the screen using 3 echo commands, then is supposed to delete a file that was previously created (and does exist). The file is a 6-digit text file, named with the format ddmmyy.
#!/usr/bin/ksh
clear
echo "******************"
echo "Program name    Version: " $VERSION_NUM
echo "******************"

#Set the tmp directory
export MY_TMP_DIR="$MYPATH/$USER/tmp_$(date +%y%m%d%H%M%S)"

In a future script:
rm -rf $MY_TMP_DIR

These scripts are run by multiple users. 99% of the time it just deletes the temp directory, but in 1% of executions, it fails due to $MY_TMP_DIR being mal-formed.
After logging the command being evaluated. Turns out the value of the variable includes the 3 echo command outputs. Log file shows this is the string being evaluated (with line breaks):
"rm -rf /pathToWorkingAera/User1/tmp_******************
Program name    Version: 3.0.1
************
280220"

This causes mayhem (obviously) with the asterisks resulting in the deletion of all sorts of things. Luckily the system is access controlled to limit the damage.
The interim fix is to change the asterisks in the echo commands, to let the script fail safely and obviously the rm -rf is dangerous, but it's not the root cause of the error.
Can anyone suggest how the echo output might be getting picked up by the assignment of the "date" command output? How to prevent it? I can't fix it as I don't understand how come it's happening in the first place.
The issue is sporadic, not repeatable and not user-specific.
The system is RHEL7.7 bash. (Will try to provide any more details on request, if possible).


text:
Q: Android: How to set Orientation for View I have one service, on started one View appears on top of all views.
If I rotate my mobile to landscape, then the view orientation changes to landscape but I want to make the view portrait only. How can I do this?

A: @Override
public void onCreate(Bundle savedInstanceState) {
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }

or
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

A: To declare that your activity handles a configuration change, edit the appropriate <activity> element in your manifest file to include the android:configChanges attribute with a value that represents the configuration you want to handle.
For example, the following manifest code declares an activity that handles both the screen orientation change and keyboard availability change:
<activity android:name=".MyActivity"
          android:configChanges="orientation|keyboardHidden"
          android:label="@string/app_name">

Now, when one of these configurations change, MyActivity does not restart. Instead, the MyActivity receives a call to onConfigurationChanged(). This method is passed a Configuration object that specifies the new device configuration. By reading fields in the Configuration, you can determine the new configuration and make appropriate changes by updating the resources used in your interface.
For example, the following onConfigurationChanged() implementation checks the current device orientation:
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    // Checks the orientation of the screen
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
        Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
    }
}

Or Simply
The screenOrientation is the attribute of activity element. The orientation of android activity can be portrait, landscape, sensor, unspecified etc. You need to define it in the AndroidManifest.xml file. For example:
<activity
            android:name="com.example.screenorientation.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="landscape"
            >

But as per my experience you need to set For targeting Android 3.2 and above, you need BOTH
android:configChanges="orientation|screenSize"

Reference : http://developer.android.com/guide/topics/resources/runtime-changes.html
EDIT :
Android screen orientation Lifecycle
We might have some confusion on the android screen orientation change lifecycle of an Android activity.  Sometimes you might observe  that your activity getting restarted, while the you rotate the device. Sometimes nothing happens. Below is the simple rule for android screen orientation change lifecycle.
1. If you already @Override the onConfigurationChanged() function in your java code( in your Android activity class) for handle Android Screen Orientation Change. Then your activity will never restart for any screen orientation changes.
2. If you do not @Override onConfigurationChanged() function as above, then your running activity will get restart every time for any screen orientation change happens in your device. That means your activity will destroy first by calling onDestroy() API and then onCreate() method will call again for your running activity to restart it.
3. To properly handle your activity's restart state, you need to restores its previous state through the normal Activity lifecycle, in which Android OS calls onSaveInstanceState() method before it destroys your activity. So that you can save your data(variable values)and your application state. You can then restore the previous state during onCreate() or onRestoreInstanceState() method call of your activity.
Hope it will help you.

A: Please find below an example which give better idea for achieve your task.
public class MainScreenOrientation extends Activity {

    private static final String TAG = "MainScreenOrientation";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mContext = this;

        setContentView(R.layout.main_activity);

        startService(new Intent(this, MyOwnService.class) );
    }
}

In my MyOwnService service class
public class MyOwnService extends Service {
    private static final String TAG = "MyOwnService";
    private static Context mContext;
    private static final String BCAST_CONFIGCHANGED = "android.intent.action.CONFIGURATION_CHANGED";

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        mContext = this;

        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(BCAST_CONFIGCHANGED);
        this.registerReceiver(mBroadcastReceiver, intentFilter);
    }

    @Override
    public void onDestroy() {
        Log.d(TAG, "onDestroy()");
        //Unregister receiver to avoid memory leaks
        mContext.unregisterReceiver(mBroadcastReceiver);
    }

    @Override
    public void onStart(Intent intent, int startid) {

    }

    public BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent myIntent) {

            if (myIntent.getAction().equals( BCAST_CONFIGCHANGED)) {

                Log.d(TAG, "received->" + BCAST_CONFIGCHANGED);

                if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){
                    // it's Landscape
                    Log.d(TAG, "LANDSCAPE");
                }
                else {
                    Log.d(TAG, "PORTRAIT");
                }
            }
        }
    };
}

And at last in manifest file
<service android:enabled="true"  android:name="com.android.example.services.MyOwnService">
            <intent-filter>
                <action android:name="android.intent.action.CONFIGURATION_CHANGED"/>
            </intent-filter>
</service>

Hope it helps you.

A: Try to set the orientation programatically when view is open.
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

A: In your Manifest file make sure to set the right orientation, like this:
<activity android:name=".SomeActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" />

This way Portrait Mode is forced, and your App will not change to Landscape when you rotate your device.

A: If I understand correctly, you want your View to be fixed in Portrait Mode, but the rest of your app to freely rotate whenever you rotate your device.
In this case, you would need to catch orientation changes, and then rotate your View counterwise to the current rotation.
Something like this:
@Override
public void onConfigurationChanged(Configuration newConfig)
{
    super.onConfigurationChanged(newConfig);
    View yourView = ....;

    // Checks the orientation of the screen
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
    {
        yourView.setRotation(-90);
    }
    else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
    {
        yourView.setRotation(90);
    }
}

You also have to edit the appropriate element in your manifest file.
      <activity android:name=".MyActivity"
         android:configChanges="orientation|keyboardHidden"
         android:label="@string/app_name">

I'm not sure on the degree values and can't check this right now, you might have to test this.
Nevertheless, this way you could keep your View always in Portrait mode.


text:
Q: How is sizeof structures found? I am getting 56 bytes for the following. Can anyone explain how is that?
#include <stdio.h>

typedef struct how_many_bytes {
    long s[4];
    char c, e;
    int i[2];
    char *d;
} How_Many_Bytes;

int main(){
    printf("%lu ", sizeof(How_Many_Bytes));
}

Shouldn't it be (4*8) + 1 + 1 + 2(for padding) + 4 + 4 + 8 = 52 bytes

A: Because it's a 64-bit machine, so the padding is 6 instead of 2 in your calculation.
Also, you should use %zu to print size_t.

A: Your analysis is correct, except that there is an additional 4 bytes padding before the char *d member.  This is so that the d member is aligned on an 8-byte boundary.
The pahole output for this structure on x86-64 is:
struct how_many_bytes {
        long int                   s[4];                 /*     0    32 */
        char                       c;                    /*    32     1 */
        char                       e;                    /*    33     1 */

        /* XXX 2 bytes hole, try to pack */

        int                        i[2];                 /*    36     8 */

        /* XXX 4 bytes hole, try to pack */

        char *                     d;                    /*    48     8 */

        /* size: 56, cachelines: 1 */
        /* sum members: 50, holes: 2, sum holes: 6 */
        /* last cacheline: 56 bytes */
};      /* definitions: 1 */

No matter how you rearrange the members of this structure, you won't be able to do better than 6 bytes in total of padding.  The sum of the sizes of the members is 50 bytes, and the maximum alignment of the structure members is 8, so even if you arrange the members in the optimal order there will be 6 bytes of padding at the end of the structure to round its size up to the next biggest multiple of 8.


text:
Q: Python module tkinter :what is best practice and way to access all its class Issue description:
Please see following two example of Code A and Code B.

*

*Code A:
from tkinter import messagebox
messagebox.showinfo("Hello ")

*Code B:
from tkinter import *
tkinter.messagebox.showinfo("Hello ")

Question :
Why Code B doesn't work?
(I do not want to get confused on using short form tk,I am ok writing tkinter)

A: The first is correct for the messagebox.
As with many python packages, not all functionality is automatically imported. Some, such as the messagebox and font modules, must be explicitly imported.
In the second case, you should not use wildcard imports. Even though a lot of tkinter tutorials import tkinter this way, PEP8 is the standard and it discourages wildcard imports.
While it will indeed import many of the tkinter classes and variables, it still won't import the messagebox module.


text:
Q: How can I output saved timezone shorthand (GMT, UTC, EST etc) in Laravel So, basically I have a client that wants the timezone of his event to be displayed based on the timezone selected for the event e.g
Date: April 20, 2020
Location: Canada, Ontario
Time: 7:00pm
Time Zone: US/Eastern
Displayed as: 7:00pm (GMT) - > this should be equivalent to a shorthand of whatever Time Zone is chosen e.g (EST) and so on - and not the UTC equivalent (UTC-06:00)
I made him select timezones using https://github.com/camroncade/timezone
which uses the string representation of a time zone (US/Eastern)
I have these fields in my database to receive the inputs from my client on creation:
    $table->date('eventdate');
    $table->time('eventdaystarttime');
    $table->time('eventdayendtime');
    $table->string('eventtimezone');

My question is how to get the Shorthand of the Time Zone (eventtimezone) my client selected on creating the event (US/Eastern) and display it as this 7:00 pm (GMT) when outputting it in my blade.view file

A: You can get timezone abbreviations / shorthand with php like this
$date = new DateTime('April 20, 2020');
$date->setTimeZone(new DateTimeZone('US/Eastern'));
echo $date->format('T');

if you save supported timezone as listed on link below you can get them with carbon easily because US/Eastern doesn't work with carbon.
$tz = CarbonTimeZone::create('America/New_York');
echo $tz->getAbbr();

American timezone
https://www.php.net/manual/en/timezones.america.php
Rest of World you can find here
https://www.php.net/manual/en/timezones.php


text:
Q: Skipping acquire of configured file for not having the component "sutton.newell" I recently updated Jammy from Focal on my Thinkpad X13 Gen 1 (AMD). After the do-release-upgrade command, I kept receiving the following Skipping acquire of configured file errors:
$ sudo apt update; sudo apt upgrade

--snip--
Reading state information... Done
19 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: Skipping acquire of configured file 'sutton.newell/binary-i386/Packages' as repository 'http://lenovo.archive.canonical.com jammy InRelease' doesn't have the component 'sutton.newell' (component misspelt in sources.list?)
W: Skipping acquire of configured file 'sutton.newell/binary-amd64/Packages' as repository 'http://lenovo.archive.canonical.com jammy InRelease' doesn't have the component 'sutton.newell' (component misspelt in sources.list?)
W: Skipping acquire of configured file 'sutton.newell/i18n/Translation-en_US' as repository 'http://lenovo.archive.canonical.com jammy InRelease' doesn't have the component 'sutton.newell' (component misspelt in sources.list?)
W: Skipping acquire of configured file 'sutton.newell/i18n/Translation-en' as repository 'http://lenovo.archive.canonical.com jammy InRelease' doesn't have the component 'sutton.newell' (component misspelt in sources.list?)
W: Skipping acquire of configured file 'sutton.newell/dep11/Components-amd64.yml' as repository 'http://lenovo.archive.canonical.com jammy InRelease' doesn't have the component 'sutton.newell' (component misspelt in sources.list?)
W: Skipping acquire of configured file 'sutton.newell/dep11/icons-48x48.tar' as repository 'http://lenovo.archive.canonical.com jammy InRelease' doesn't have the component 'sutton.newell' (component misspelt in sources.list?)
W: Skipping acquire of configured file 'sutton.newell/dep11/icons-64x64.tar' as repository 'http://lenovo.archive.canonical.com jammy InRelease' doesn't have the component 'sutton.newell' (component misspelt in sources.list?)
W: Skipping acquire of configured file 'sutton.newell/dep11/icons-64x64@2.tar' as repository 'http://lenovo.archive.canonical.com jammy InRelease' doesn't have the component 'sutton.newell' (component misspelt in sources.list?)
W: Skipping acquire of configured file 'sutton.newell/cnf/Commands-amd64' as repository 'http://lenovo.archive.canonical.com jammy InRelease' doesn't have the component 'sutton.newell' (component misspelt in sources.list?)

I wonder what may cause these warnings.
[Update: Sept 15, 2022]
I compared the content list between focal/ and jammy/ on http://lenovo.archive.canonical.com/dists/. It turns out that Lenovo removed the driver named sutton.newell for the Jammy Jellyfish release. I have no idea why Lenovo removed them, but I'll just turn the existing lines in /etc/apt/source.list.d/ into comments for now.


text:
Q: Neo4J - cypher query match differences Hi guys I am trying to write a cypher query that will include 2 lists and I will then take the difference of them.
At the end of the day I need to actually run a MATCH query to get both lists and I can't figure out how to construct this to work.
So the two queries I need to run to generate the list are:
MATCH (Paper:Paper)<-[:WROTE]-(a:Author)
WHERE Paper.year > 2010 and Paper.year <2012
RETURN a

the 2nd one is the same query just a movement of the years from 2010 to 2011 and 2012 to 2013.
MATCH (Paper:Paper)<-[:WROTE]-(a:Author)
WHERE Paper.year > 2010 and Paper.year <2012
WITH a AS l1,

(Paper:Paper)<-[:WROTE]-(a:Author)
WHERE Paper.year > 2011 and Paper.year <2013
WITH a AS l2

RETURN [Author in l2 WHERE not(Author in l1)]

For some reason I get a skew of errors (not surprising) the one being
Expression in WITH must be aliased (use AS) (line 5, column 1 (offset: 102))
"(Paper:Paper)<-[:WROTE]-(a:Author)"
any help would be appreciated!

A: The reason for the error is you have an extra comma at the end of your first WITH clause.
That said, it would be wiser to collect the results rather than keep all result rows between your queries, since your current queries aren't working with your results as lists.
Some other improvements we can make include using chained inequalities:
MATCH (Paper:Paper)<-[:WROTE]-(a:Author)
WHERE 2010 < Paper.year < 2012
WITH collect(a) AS l1

MATCH (Paper:Paper)<-[:WROTE]-(a:Author)
WHERE 2011 < Paper.year < 2013
WITH l1, collect(a) AS l2

RETURN [Author in l2 WHERE not Author in l1] as authors


text:
Q: C++ Hunter/Prey "C2027 undefined type" compilation error I've been getting weird compile errors all over the place in a simple hunter/prey simulation (mostly because the professor hasn't explained the syntax for inherited classes and virtual functions very well) and I'm completely stuck on one issue.  In this program, "Creatures" (an abstract class with "Hunter" and "Prey" children) walk around a "Grid" class in a Move(), Breed(), Die() cycle.
I'm getting the following errors: "C2027: use of undefined type 'Creature'" and "C2227: left of '->face' must point to class/struct/union/generic type" at the line specified in below (all my code's in the header because several students were getting unresolved externals in another project and the professor told us to just put it all in the headers).  Let me know if I need to post more code.
I've gotten several other errors that I couldn't explain before this that seemed to be solved through a seemingly random combination of adding/removing included headers and pre-declaring classes, but an actual explanation of what's going wrong would be much appreciated so I'm not just flailing in the dark until it works.  I understand the concept of what we're trying to do and even how to go about it for the most part, but as I mentioned, we didn't spend any time on the syntax of how to properly set up multiple files so that everyone works smoothly so any detailed explanation of how this should be done would be greatly appreciated.
Grid.h
#ifndef GRID_H
#define GRID_H

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include "Constants.h"
#include "creature.h"
using namespace std;

class Creature;

class Grid
{
public:
    Creature* grid[MAX_X][MAX_Y];

    Grid() //Initalizes the grid and spawns random creatures
    {
        for(int i = 0; i < MAX_X; i++)
            for(int j = 0; j < MAX_Y; j++)
                grid[i][j] = NULL;

    }

    void Move() //Tells each creature on the grid to move
    {
        //Call creature.Move() on each cell (if not NULL)
    }

    void Breed() //Tells each creature to breed (if it can)
    {
        //Call creature.Breed() on each cell (if not NULL)
    }

    void Kill()  //Tells each creature to die (if it's old)
    {
        //Call creature.Die() on each cell (if not NULL)
    }

    char** Snapshot()  //Creates a char array "snapshot" of the board
    {
        //Produces a 2D char array of the grid for display
    }

    Creature* Get(Coords here)  //Returns a pointer to the object at the specified position
    {
        return grid[here.x][here.y];
    }

    char Occupant(Coords here) //Returns the character of the specified position
    {
        if(!Get(here))
            return FACE_EMPTY;
        Creature* temp = Get(here);
        return temp->face;  //*** ERRORS APPEAR HERE ***
    }

    void Clear(Coords here)  //Deletes the object at the specified position
    {
        if(Get(here))
            delete Get(here);
        grid[here.x][here.y] = NULL;
    }
};

#endif // GRID_H

creature.h
#ifndef CREATURE_H
#define CREATURE_H

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include "Constants.h"
#include "coords.h"
#include "grid.h"
using namespace std;

class Grid;

class Creature
{
public:
    Grid* theGrid;
    Coords position;
    int stepBreed;
    int stepHunger;
    char face;

    Creature(Grid* _grid, Coords _position, char _face)  //Constructor
    {
        theGrid = _grid;
        position = _position;
        face = _face;
        stepBreed = stepHunger = 0;
    }

    virtual Coords Move() = 0;  //Allows the child to define it's own movement
    virtual Coords Breed() = 0;  //Allows the child to define it's own breeding
    virtual bool Starve() = 0;  //Allows the child to starve of its own accord
};

#endif // CREATURE_H

A: Your use of class Creature at the top of the file seems to indicate that you don't have access to the complete definition of Creature in this file.  That makes it impossible for the compiler to do the -> operation on it - it doesn't know what the members of that class are!  You need to have a complete definition of Creature in the same translation unit as this code.  That is, Creature needs to be a complete type if you want to use it in this way.
Edit:  Thanks for posting creature.h.  Your problem (as mentioned in the comments below) is that you have a circular dependency problem.  creature.h includes grid.h and vice versa.  You'll need to break one of those links to get things working properly.  In this case, removing #include "grid.h" from creature.h should do the trick - no code in creature.h depends on Grid being a complete type.


text:
Q: Alternative approach to HTML generation My program generates HTML via stringbuilder.
         sbHTMLHeader.Append("
");
         sbHTMLHeader.Append("
");
         sbHTMLHeader.Append("

");
//...
if (!orderType.Equals("L"))
            {
                sbHTMLHeader.Append("     " + orderData.Tables[0].Rows[0]["carrier"] + "	" + Environment.NewLine);
                //...
            }
            else
            {
                sbHTMLHeader.Append("     	" + Environment.NewLine);
                 //...
            }
//...

380 lines later, I am passionitely against this code.  In the past, I used Altova Stylevision.  At my current job we have no license for the product. I don't need any of the PDF or other templates it provides, just HTML.  Can you suggest a powerful, readable alternative to generate HTML such as above?

A: An alternative would be to store all the data in an XML file and write an XSLT (transformation sheet) that turns it into HTML.

A: As usually I can recommend: Html Agility Pack
In another approach you can use classes from System.Web.UI.HtmlControls namespace to create html.

A: You can definitely use NVelocity to help out with generating such templated HTML. The basic syntax is easy, and you can go quite complicated. Should save you a lot of tedious coding, and it doesn't require that you massage your input data beforehand.


text:
Q: Merits of Entity Framework when not using migrations I've got limited experience with Entity Framework, but the times I've used it I've always taken the code-first migrations approach. I've recently been hired at a job where they use Entity Framework, and they've said that they want to retain control over their SQL table structure by manually creating their tables. However, they also manually create C# classes and their respective EntityTypeConfigurations.
So given my limited experience and understanding of the Entity Framework, this has made me curious of some things. What are some examples of things one might sacrifice or risk by relinquishing control of the SQL table structure to the Entity Framework code-first migrations? And when writing both the code side of things and the database side of things manually, not letting the framework generate either side of the object-relational mapping, is there any merit left in using Entity Framework?

A: This is largely opinion based, and I wouldn't be surprised to see this question closed.
Having said that, your schema generation and maintenance is not what EF (or any ORM) is for. An ORM's main function is to relieve you of writing SQL in your code, and writing the plumbing needed to send it to the database, and extract the results to an object you can work with. An ORM does all that for you. So even at the scenario you described, using EF will still be beneficial.