text:
Q: PHP "supported scripts" (e.g. Cyrillic, Han etc) - definition of the unicode ranges for these? I see in the PHP online manual (https://www.php.net/manual/en/regexp.reference.unicode.php) that there is a long list of predefined "supported scripts", which is largely helpful in detecting if a string contains, say, Cyrillic, Han or whatever. However, that long list doesn't include a definition of what Unicode, er, "characters" are included in those predefined identities. Many are "obvious" (or one might expect them to overlap with the Unicode blocks (https://en.wikipedia.org/wiki/Unicode_block), but several are not, such as "Common" and "Inherited" (these are mentioned in that Wikipedia page re Unicode blocks, but without the specifics - e.g. "Inherited (2 characters)" in the block range U+0400..U+04FF, but without saying which 2 characters in that range). Outside of the Zend source code, is there a public specification of the ranges covered by these predefined identities?

A: Yes, the data file Scripts.txt in the Unicode Standard.

A: I decided in the end that references to non-PHP documentation, although very helpful (especially given the provenance of Unicode.org), won't necessarily reflect exactly the PHP implementations of its own supported Scripts. So I wrote the following PHP that tests every character in the range 0-0x10ffff
<?php

$scriptNames = array(
    'Arabic',
    'Armenian',
    'Avestan',
    'Balinese',
    'Bamum',
    'Batak',
    'Bengali',
    'Bopomofo',
    'Brahmi',
    'Braille',
    'Buginese',
    'Buhid',
    'Canadian_Aboriginal',
    'Carian',
    'Chakma',
    'Cham',
    'Cherokee',
    'Common',
    'Coptic',
    'Cuneiform',
    'Cypriot',
    'Cyrillic',
    'Deseret',
    'Devanagari',
    'Egyptian_Hieroglyphs',
    'Ethiopic',
    'Georgian',
    'Glagolitic',
    'Gothic',
    'Greek',
    'Gujarati',
    'Gurmukhi',
    'Han',
    'Hangul',
    'Hanunoo',
    'Hebrew',
    'Hiragana',
    'Imperial_Aramaic',
    'Inherited',
    'Inscriptional_Pahlavi',
    'Inscriptional_Parthian',
    'Javanese',
    'Kaithi',
    'Kannada',
    'Katakana',
    'Kayah_Li',
    'Kharoshthi',
    'Khmer',
    'Lao',
    'Latin',
    'Lepcha',
    'Limbu',
    'Linear_B',
    'Lisu',
    'Lycian',
    'Lydian',
    'Malayalam',
    'Mandaic',
    'Meetei_Mayek',
    'Meroitic_Cursive',
    'Meroitic_Hieroglyphs',
    'Miao',
    'Mongolian',
    'Myanmar',
    'New_Tai_Lue',
    'Nko',
    'Ogham',
    'Old_Italic',
    'Old_Persian',
    'Old_South_Arabian',
    'Old_Turkic',
    'Ol_Chiki',
    'Oriya',
    'Osmanya',
    'Phags_Pa',
    'Phoenician',
    'Rejang',
    'Runic',
    'Samaritan',
    'Saurashtra',
    'Sharada',
    'Shavian',
    'Sinhala',
    'Sora_Sompeng',
    'Sundanese',
    'Syloti_Nagri',
    'Syriac',
    'Tagalog',
    'Tagbanwa',
    'Tai_Le',
    'Tai_Tham',
    'Tai_Viet',
    'Takri',
    'Tamil',
    'Telugu',
    'Thaana',
    'Thai',
    'Tibetan',
    'Tifinagh',
    'Ugaritic',
    'Vai',
    'Yi'
);
$scriptTypes = array();
foreach( $scriptNames as $n ) $scriptTypes[ $n ] = array();
for( $i=0; $i <= 0x10ffff; $i++ ) {

    foreach( $scriptNames as $scriptName ) {

        if ( preg_match( '/[\p{'. $scriptName .'}]/u', mb_chr( $i, 'UTF-8') ) ) {

            if (empty( $scriptTypes[ $scriptName ])
                || ( ($i - $scriptTypes[ $scriptName ][ count( $scriptTypes[ $scriptName ] ) - 1 ][1]) > 1)
            ) {

                $scriptTypes[ $scriptName ][] = [$i, $i];

            } else {

                $scriptTypes[ $scriptName ][ count( $scriptTypes[ $scriptName ] ) - 1 ][1] = $i;
            }
        }
    }
}
foreach( $scriptTypes as $scriptName => $unicodeRanges ) {

    $cc ='';
    $n=0;
    foreach( $unicodeRanges as $r ) {

        $cc .= sprintf(
            '\x{%04x}',
            $r[0]
        );
        $n++;
        if ($r[1] > $r[0] ) {

            $cc .= sprintf(
                '-\x{%04x}',
                $r[1]
            );
            $n += $r[1] - $r[0];
        }
    }
    printf(
        '%s(%d)=[%s]'.PHP_EOL,
        $scriptName,
        $n,
        $cc
    );
}

This gives the following output in the form <Name>(<code points covered>)=<PCRE character class>:
Arabic(1281)=[\x{0600}-\x{0604}\x{0606}-\x{060b}\x{060d}-\x{061a}\x{061c}\x{061e}\x{0620}-\x{063f}\x{0641}-\x{064a}\x{0656}-\x{066f}\x{0671}-\x{06dc}\x{06de}-\x{06ff}\x{0750}-\x{077f}\x{08a0}-\x{08b4}\x{08b6}-\x{08bd}\x{08d3}-\x{08e1}\x{08e3}-\x{08ff}\x{fb50}-\x{fbc1}\x{fbd3}-\x{fd3d}\x{fd50}-\x{fd8f}\x{fd92}-\x{fdc7}\x{fdf0}-\x{fdfd}\x{fe70}-\x{fe74}\x{fe76}-\x{fefc}\x{10e60}-\x{10e7e}\x{1ee00}-\x{1ee03}\x{1ee05}-\x{1ee1f}\x{1ee21}-\x{1ee22}\x{1ee24}\x{1ee27}\x{1ee29}-\x{1ee32}\x{1ee34}-\x{1ee37}\x{1ee39}\x{1ee3b}\x{1ee42}\x{1ee47}\x{1ee49}\x{1ee4b}\x{1ee4d}-\x{1ee4f}\x{1ee51}-\x{1ee52}\x{1ee54}\x{1ee57}\x{1ee59}\x{1ee5b}\x{1ee5d}\x{1ee5f}\x{1ee61}-\x{1ee62}\x{1ee64}\x{1ee67}-\x{1ee6a}\x{1ee6c}-\x{1ee72}\x{1ee74}-\x{1ee77}\x{1ee79}-\x{1ee7c}\x{1ee7e}\x{1ee80}-\x{1ee89}\x{1ee8b}-\x{1ee9b}\x{1eea1}-\x{1eea3}\x{1eea5}-\x{1eea9}\x{1eeab}-\x{1eebb}\x{1eef0}-\x{1eef1}]
Armenian(95)=[\x{0531}-\x{0556}\x{0559}-\x{0588}\x{058a}\x{058d}-\x{058f}\x{fb13}-\x{fb17}]
Avestan(61)=[\x{10b00}-\x{10b35}\x{10b39}-\x{10b3f}]
Balinese(121)=[\x{1b00}-\x{1b4b}\x{1b50}-\x{1b7c}]
Bamum(657)=[\x{a6a0}-\x{a6f7}\x{16800}-\x{16a38}]
Batak(56)=[\x{1bc0}-\x{1bf3}\x{1bfc}-\x{1bff}]
Bengali(96)=[\x{0980}-\x{0983}\x{0985}-\x{098c}\x{098f}-\x{0990}\x{0993}-\x{09a8}\x{09aa}-\x{09b0}\x{09b2}\x{09b6}-\x{09b9}\x{09bc}-\x{09c4}\x{09c7}-\x{09c8}\x{09cb}-\x{09ce}\x{09d7}\x{09dc}-\x{09dd}\x{09df}-\x{09e3}\x{09e6}-\x{09fe}]
Bopomofo(72)=[\x{02ea}-\x{02eb}\x{3105}-\x{312f}\x{31a0}-\x{31ba}]
Brahmi(109)=[\x{11000}-\x{1104d}\x{11052}-\x{1106f}\x{1107f}]
Braille(256)=[\x{2800}-\x{28ff}]
Buginese(30)=[\x{1a00}-\x{1a1b}\x{1a1e}-\x{1a1f}]
Buhid(20)=[\x{1740}-\x{1753}]
Canadian_Aboriginal(710)=[\x{1400}-\x{167f}\x{18b0}-\x{18f5}]
Carian(49)=[\x{102a0}-\x{102d0}]
Chakma(70)=[\x{11100}-\x{11134}\x{11136}-\x{11146}]
Cham(83)=[\x{aa00}-\x{aa36}\x{aa40}-\x{aa4d}\x{aa50}-\x{aa59}\x{aa5c}-\x{aa5f}]
Cherokee(172)=[\x{13a0}-\x{13f5}\x{13f8}-\x{13fd}\x{ab70}-\x{abbf}]
Common(7805)=[\x{0000}-\x{0040}\x{005b}-\x{0060}\x{007b}-\x{00a9}\x{00ab}-\x{00b9}\x{00bb}-\x{00bf}\x{00d7}\x{00f7}\x{02b9}-\x{02df}\x{02e5}-\x{02e9}\x{02ec}-\x{02ff}\x{0374}\x{037e}\x{0385}\x{0387}\x{0589}\x{0605}\x{060c}\x{061b}\x{061f}\x{0640}\x{06dd}\x{08e2}\x{0964}-\x{0965}\x{0e3f}\x{0fd5}-\x{0fd8}\x{10fb}\x{16eb}-\x{16ed}\x{1735}-\x{1736}\x{1802}-\x{1803}\x{1805}\x{1cd3}\x{1ce1}\x{1ce9}-\x{1cec}\x{1cee}-\x{1cf3}\x{1cf5}-\x{1cf7}\x{1cfa}\x{2000}-\x{200b}\x{200e}-\x{2064}\x{2066}-\x{2070}\x{2074}-\x{207e}\x{2080}-\x{208e}\x{20a0}-\x{20bf}\x{2100}-\x{2125}\x{2127}-\x{2129}\x{212c}-\x{2131}\x{2133}-\x{214d}\x{214f}-\x{215f}\x{2189}-\x{218b}\x{2190}-\x{2426}\x{2440}-\x{244a}\x{2460}-\x{27ff}\x{2900}-\x{2b73}\x{2b76}-\x{2b95}\x{2b98}-\x{2bff}\x{2e00}-\x{2e4f}\x{2ff0}-\x{2ffb}\x{3000}-\x{3004}\x{3006}\x{3008}-\x{3020}\x{3030}-\x{3037}\x{303c}-\x{303f}\x{309b}-\x{309c}\x{30a0}\x{30fb}-\x{30fc}\x{3190}-\x{319f}\x{31c0}-\x{31e3}\x{3220}-\x{325f}\x{327f}-\x{32cf}\x{32ff}\x{3358}-\x{33ff}\x{4dc0}-\x{4dff}\x{a700}-\x{a721}\x{a788}-\x{a78a}\x{a830}-\x{a839}\x{a92e}\x{a9cf}\x{ab5b}\x{fd3e}-\x{fd3f}\x{fe10}-\x{fe19}\x{fe30}-\x{fe52}\x{fe54}-\x{fe66}\x{fe68}-\x{fe6b}\x{feff}\x{ff01}-\x{ff20}\x{ff3b}-\x{ff40}\x{ff5b}-\x{ff65}\x{ff70}\x{ff9e}-\x{ff9f}\x{ffe0}-\x{ffe6}\x{ffe8}-\x{ffee}\x{fff9}-\x{fffd}\x{10100}-\x{10102}\x{10107}-\x{10133}\x{10137}-\x{1013f}\x{10190}-\x{1019b}\x{101d0}-\x{101fc}\x{102e1}-\x{102fb}\x{16fe2}-\x{16fe3}\x{1bca0}-\x{1bca3}\x{1d000}-\x{1d0f5}\x{1d100}-\x{1d126}\x{1d129}-\x{1d166}\x{1d16a}-\x{1d17a}\x{1d183}-\x{1d184}\x{1d18c}-\x{1d1a9}\x{1d1ae}-\x{1d1e8}\x{1d2e0}-\x{1d2f3}\x{1d300}-\x{1d356}\x{1d360}-\x{1d378}\x{1d400}-\x{1d454}\x{1d456}-\x{1d49c}\x{1d49e}-\x{1d49f}\x{1d4a2}\x{1d4a5}-\x{1d4a6}\x{1d4a9}-\x{1d4ac}\x{1d4ae}-\x{1d4b9}\x{1d4bb}\x{1d4bd}-\x{1d4c3}\x{1d4c5}-\x{1d505}\x{1d507}-\x{1d50a}\x{1d50d}-\x{1d514}\x{1d516}-\x{1d51c}\x{1d51e}-\x{1d539}\x{1d53b}-\x{1d53e}\x{1d540}-\x{1d544}\x{1d546}\x{1d54a}-\x{1d550}\x{1d552}-\x{1d6a5}\x{1d6a8}-\x{1d7cb}\x{1d7ce}-\x{1d7ff}\x{1ec71}-\x{1ecb4}\x{1ed01}-\x{1ed3d}\x{1f000}-\x{1f02b}\x{1f030}-\x{1f093}\x{1f0a0}-\x{1f0ae}\x{1f0b1}-\x{1f0bf}\x{1f0c1}-\x{1f0cf}\x{1f0d1}-\x{1f0f5}\x{1f100}-\x{1f10c}\x{1f110}-\x{1f16c}\x{1f170}-\x{1f1ac}\x{1f1e6}-\x{1f1ff}\x{1f201}-\x{1f202}\x{1f210}-\x{1f23b}\x{1f240}-\x{1f248}\x{1f250}-\x{1f251}\x{1f260}-\x{1f265}\x{1f300}-\x{1f6d5}\x{1f6e0}-\x{1f6ec}\x{1f6f0}-\x{1f6fa}\x{1f700}-\x{1f773}\x{1f780}-\x{1f7d8}\x{1f7e0}-\x{1f7eb}\x{1f800}-\x{1f80b}\x{1f810}-\x{1f847}\x{1f850}-\x{1f859}\x{1f860}-\x{1f887}\x{1f890}-\x{1f8ad}\x{1f900}-\x{1f90b}\x{1f90d}-\x{1f971}\x{1f973}-\x{1f976}\x{1f97a}-\x{1f9a2}\x{1f9a5}-\x{1f9aa}\x{1f9ae}-\x{1f9ca}\x{1f9cd}-\x{1fa53}\x{1fa60}-\x{1fa6d}\x{1fa70}-\x{1fa73}\x{1fa78}-\x{1fa7a}\x{1fa80}-\x{1fa82}\x{1fa90}-\x{1fa95}\x{e0001}\x{e0020}-\x{e007f}]
Coptic(137)=[\x{03e2}-\x{03ef}\x{2c80}-\x{2cf3}\x{2cf9}-\x{2cff}]
Cuneiform(1234)=[\x{12000}-\x{12399}\x{12400}-\x{1246e}\x{12470}-\x{12474}\x{12480}-\x{12543}]
Cypriot(55)=[\x{10800}-\x{10805}\x{10808}\x{1080a}-\x{10835}\x{10837}-\x{10838}\x{1083c}\x{1083f}]
Cyrillic(443)=[\x{0400}-\x{0484}\x{0487}-\x{052f}\x{1c80}-\x{1c88}\x{1d2b}\x{1d78}\x{2de0}-\x{2dff}\x{a640}-\x{a69f}\x{fe2e}-\x{fe2f}]
Deseret(80)=[\x{10400}-\x{1044f}]
Devanagari(154)=[\x{0900}-\x{0950}\x{0955}-\x{0963}\x{0966}-\x{097f}\x{a8e0}-\x{a8ff}]
Egyptian_Hieroglyphs(1080)=[\x{13000}-\x{1342e}\x{13430}-\x{13438}]
Ethiopic(495)=[\x{1200}-\x{1248}\x{124a}-\x{124d}\x{1250}-\x{1256}\x{1258}\x{125a}-\x{125d}\x{1260}-\x{1288}\x{128a}-\x{128d}\x{1290}-\x{12b0}\x{12b2}-\x{12b5}\x{12b8}-\x{12be}\x{12c0}\x{12c2}-\x{12c5}\x{12c8}-\x{12d6}\x{12d8}-\x{1310}\x{1312}-\x{1315}\x{1318}-\x{135a}\x{135d}-\x{137c}\x{1380}-\x{1399}\x{2d80}-\x{2d96}\x{2da0}-\x{2da6}\x{2da8}-\x{2dae}\x{2db0}-\x{2db6}\x{2db8}-\x{2dbe}\x{2dc0}-\x{2dc6}\x{2dc8}-\x{2dce}\x{2dd0}-\x{2dd6}\x{2dd8}-\x{2dde}\x{ab01}-\x{ab06}\x{ab09}-\x{ab0e}\x{ab11}-\x{ab16}\x{ab20}-\x{ab26}\x{ab28}-\x{ab2e}]
Georgian(173)=[\x{10a0}-\x{10c5}\x{10c7}\x{10cd}\x{10d0}-\x{10fa}\x{10fc}-\x{10ff}\x{1c90}-\x{1cba}\x{1cbd}-\x{1cbf}\x{2d00}-\x{2d25}\x{2d27}\x{2d2d}]
Glagolitic(132)=[\x{2c00}-\x{2c2e}\x{2c30}-\x{2c5e}\x{1e000}-\x{1e006}\x{1e008}-\x{1e018}\x{1e01b}-\x{1e021}\x{1e023}-\x{1e024}\x{1e026}-\x{1e02a}]
Gothic(27)=[\x{10330}-\x{1034a}]
Greek(518)=[\x{0370}-\x{0373}\x{0375}-\x{0377}\x{037a}-\x{037d}\x{037f}\x{0384}\x{0386}\x{0388}-\x{038a}\x{038c}\x{038e}-\x{03a1}\x{03a3}-\x{03e1}\x{03f0}-\x{03ff}\x{1d26}-\x{1d2a}\x{1d5d}-\x{1d61}\x{1d66}-\x{1d6a}\x{1dbf}\x{1f00}-\x{1f15}\x{1f18}-\x{1f1d}\x{1f20}-\x{1f45}\x{1f48}-\x{1f4d}\x{1f50}-\x{1f57}\x{1f59}\x{1f5b}\x{1f5d}\x{1f5f}-\x{1f7d}\x{1f80}-\x{1fb4}\x{1fb6}-\x{1fc4}\x{1fc6}-\x{1fd3}\x{1fd6}-\x{1fdb}\x{1fdd}-\x{1fef}\x{1ff2}-\x{1ff4}\x{1ff6}-\x{1ffe}\x{2126}\x{ab65}\x{10140}-\x{1018e}\x{101a0}\x{1d200}-\x{1d245}]
Gujarati(91)=[\x{0a81}-\x{0a83}\x{0a85}-\x{0a8d}\x{0a8f}-\x{0a91}\x{0a93}-\x{0aa8}\x{0aaa}-\x{0ab0}\x{0ab2}-\x{0ab3}\x{0ab5}-\x{0ab9}\x{0abc}-\x{0ac5}\x{0ac7}-\x{0ac9}\x{0acb}-\x{0acd}\x{0ad0}\x{0ae0}-\x{0ae3}\x{0ae6}-\x{0af1}\x{0af9}-\x{0aff}]
Gurmukhi(80)=[\x{0a01}-\x{0a03}\x{0a05}-\x{0a0a}\x{0a0f}-\x{0a10}\x{0a13}-\x{0a28}\x{0a2a}-\x{0a30}\x{0a32}-\x{0a33}\x{0a35}-\x{0a36}\x{0a38}-\x{0a39}\x{0a3c}\x{0a3e}-\x{0a42}\x{0a47}-\x{0a48}\x{0a4b}-\x{0a4d}\x{0a51}\x{0a59}-\x{0a5c}\x{0a5e}\x{0a66}-\x{0a76}]
Han(89233)=[\x{2e80}-\x{2e99}\x{2e9b}-\x{2ef3}\x{2f00}-\x{2fd5}\x{3005}\x{3007}\x{3021}-\x{3029}\x{3038}-\x{303b}\x{3400}-\x{4db5}\x{4e00}-\x{9fef}\x{f900}-\x{fa6d}\x{fa70}-\x{fad9}\x{20000}-\x{2a6d6}\x{2a700}-\x{2b734}\x{2b740}-\x{2b81d}\x{2b820}-\x{2cea1}\x{2ceb0}-\x{2ebe0}\x{2f800}-\x{2fa1d}]
Hangul(11739)=[\x{1100}-\x{11ff}\x{302e}-\x{302f}\x{3131}-\x{318e}\x{3200}-\x{321e}\x{3260}-\x{327e}\x{a960}-\x{a97c}\x{ac00}-\x{d7a3}\x{d7b0}-\x{d7c6}\x{d7cb}-\x{d7fb}\x{ffa0}-\x{ffbe}\x{ffc2}-\x{ffc7}\x{ffca}-\x{ffcf}\x{ffd2}-\x{ffd7}\x{ffda}-\x{ffdc}]
Hanunoo(21)=[\x{1720}-\x{1734}]
Hebrew(134)=[\x{0591}-\x{05c7}\x{05d0}-\x{05ea}\x{05ef}-\x{05f4}\x{fb1d}-\x{fb36}\x{fb38}-\x{fb3c}\x{fb3e}\x{fb40}-\x{fb41}\x{fb43}-\x{fb44}\x{fb46}-\x{fb4f}]
Hiragana(379)=[\x{3041}-\x{3096}\x{309d}-\x{309f}\x{1b001}-\x{1b11e}\x{1b150}-\x{1b152}\x{1f200}]
Imperial_Aramaic(31)=[\x{10840}-\x{10855}\x{10857}-\x{1085f}]
Inherited(571)=[\x{0300}-\x{036f}\x{0485}-\x{0486}\x{064b}-\x{0655}\x{0670}\x{0951}-\x{0954}\x{1ab0}-\x{1abe}\x{1cd0}-\x{1cd2}\x{1cd4}-\x{1ce0}\x{1ce2}-\x{1ce8}\x{1ced}\x{1cf4}\x{1cf8}-\x{1cf9}\x{1dc0}-\x{1df9}\x{1dfb}-\x{1dff}\x{200c}-\x{200d}\x{20d0}-\x{20f0}\x{302a}-\x{302d}\x{3099}-\x{309a}\x{fe00}-\x{fe0f}\x{fe20}-\x{fe2d}\x{101fd}\x{102e0}\x{1133b}\x{1d167}-\x{1d169}\x{1d17b}-\x{1d182}\x{1d185}-\x{1d18b}\x{1d1aa}-\x{1d1ad}\x{e0100}-\x{e01ef}]
Inscriptional_Pahlavi(27)=[\x{10b60}-\x{10b72}\x{10b78}-\x{10b7f}]
Inscriptional_Parthian(30)=[\x{10b40}-\x{10b55}\x{10b58}-\x{10b5f}]
Javanese(90)=[\x{a980}-\x{a9cd}\x{a9d0}-\x{a9d9}\x{a9de}-\x{a9df}]
Kaithi(67)=[\x{11080}-\x{110c1}\x{110cd}]
Kannada(89)=[\x{0c80}-\x{0c8c}\x{0c8e}-\x{0c90}\x{0c92}-\x{0ca8}\x{0caa}-\x{0cb3}\x{0cb5}-\x{0cb9}\x{0cbc}-\x{0cc4}\x{0cc6}-\x{0cc8}\x{0cca}-\x{0ccd}\x{0cd5}-\x{0cd6}\x{0cde}\x{0ce0}-\x{0ce3}\x{0ce6}-\x{0cef}\x{0cf1}-\x{0cf2}]
Katakana(304)=[\x{30a1}-\x{30fa}\x{30fd}-\x{30ff}\x{31f0}-\x{31ff}\x{32d0}-\x{32fe}\x{3300}-\x{3357}\x{ff66}-\x{ff6f}\x{ff71}-\x{ff9d}\x{1b000}\x{1b164}-\x{1b167}]
Kayah_Li(47)=[\x{a900}-\x{a92d}\x{a92f}]
Kharoshthi(68)=[\x{10a00}-\x{10a03}\x{10a05}-\x{10a06}\x{10a0c}-\x{10a13}\x{10a15}-\x{10a17}\x{10a19}-\x{10a35}\x{10a38}-\x{10a3a}\x{10a3f}-\x{10a48}\x{10a50}-\x{10a58}]
Khmer(146)=[\x{1780}-\x{17dd}\x{17e0}-\x{17e9}\x{17f0}-\x{17f9}\x{19e0}-\x{19ff}]
Lao(82)=[\x{0e81}-\x{0e82}\x{0e84}\x{0e86}-\x{0e8a}\x{0e8c}-\x{0ea3}\x{0ea5}\x{0ea7}-\x{0ebd}\x{0ec0}-\x{0ec4}\x{0ec6}\x{0ec8}-\x{0ecd}\x{0ed0}-\x{0ed9}\x{0edc}-\x{0edf}]
Latin(1366)=[\x{0041}-\x{005a}\x{0061}-\x{007a}\x{00aa}\x{00ba}\x{00c0}-\x{00d6}\x{00d8}-\x{00f6}\x{00f8}-\x{02b8}\x{02e0}-\x{02e4}\x{1d00}-\x{1d25}\x{1d2c}-\x{1d5c}\x{1d62}-\x{1d65}\x{1d6b}-\x{1d77}\x{1d79}-\x{1dbe}\x{1e00}-\x{1eff}\x{2071}\x{207f}\x{2090}-\x{209c}\x{212a}-\x{212b}\x{2132}\x{214e}\x{2160}-\x{2188}\x{2c60}-\x{2c7f}\x{a722}-\x{a787}\x{a78b}-\x{a7bf}\x{a7c2}-\x{a7c6}\x{a7f7}-\x{a7ff}\x{ab30}-\x{ab5a}\x{ab5c}-\x{ab64}\x{ab66}-\x{ab67}\x{fb00}-\x{fb06}\x{ff21}-\x{ff3a}\x{ff41}-\x{ff5a}]
Lepcha(74)=[\x{1c00}-\x{1c37}\x{1c3b}-\x{1c49}\x{1c4d}-\x{1c4f}]
Limbu(68)=[\x{1900}-\x{191e}\x{1920}-\x{192b}\x{1930}-\x{193b}\x{1940}\x{1944}-\x{194f}]
Linear_B(211)=[\x{10000}-\x{1000b}\x{1000d}-\x{10026}\x{10028}-\x{1003a}\x{1003c}-\x{1003d}\x{1003f}-\x{1004d}\x{10050}-\x{1005d}\x{10080}-\x{100fa}]
Lisu(48)=[\x{a4d0}-\x{a4ff}]
Lycian(29)=[\x{10280}-\x{1029c}]
Lydian(27)=[\x{10920}-\x{10939}\x{1093f}]
Malayalam(117)=[\x{0d00}-\x{0d03}\x{0d05}-\x{0d0c}\x{0d0e}-\x{0d10}\x{0d12}-\x{0d44}\x{0d46}-\x{0d48}\x{0d4a}-\x{0d4f}\x{0d54}-\x{0d63}\x{0d66}-\x{0d7f}]
Mandaic(29)=[\x{0840}-\x{085b}\x{085e}]
Meetei_Mayek(79)=[\x{aae0}-\x{aaf6}\x{abc0}-\x{abed}\x{abf0}-\x{abf9}]
Meroitic_Cursive(90)=[\x{109a0}-\x{109b7}\x{109bc}-\x{109cf}\x{109d2}-\x{109ff}]
Meroitic_Hieroglyphs(32)=[\x{10980}-\x{1099f}]
Miao(149)=[\x{16f00}-\x{16f4a}\x{16f4f}-\x{16f87}\x{16f8f}-\x{16f9f}]
Mongolian(167)=[\x{1800}-\x{1801}\x{1804}\x{1806}-\x{180e}\x{1810}-\x{1819}\x{1820}-\x{1878}\x{1880}-\x{18aa}\x{11660}-\x{1166c}]
Myanmar(223)=[\x{1000}-\x{109f}\x{a9e0}-\x{a9fe}\x{aa60}-\x{aa7f}]
New_Tai_Lue(83)=[\x{1980}-\x{19ab}\x{19b0}-\x{19c9}\x{19d0}-\x{19da}\x{19de}-\x{19df}]
Nko(62)=[\x{07c0}-\x{07fa}\x{07fd}-\x{07ff}]
Ogham(29)=[\x{1680}-\x{169c}]
Old_Italic(39)=[\x{10300}-\x{10323}\x{1032d}-\x{1032f}]
Old_Persian(50)=[\x{103a0}-\x{103c3}\x{103c8}-\x{103d5}]
Old_South_Arabian(32)=[\x{10a60}-\x{10a7f}]
Old_Turkic(73)=[\x{10c00}-\x{10c48}]
Ol_Chiki(48)=[\x{1c50}-\x{1c7f}]
Oriya(90)=[\x{0b01}-\x{0b03}\x{0b05}-\x{0b0c}\x{0b0f}-\x{0b10}\x{0b13}-\x{0b28}\x{0b2a}-\x{0b30}\x{0b32}-\x{0b33}\x{0b35}-\x{0b39}\x{0b3c}-\x{0b44}\x{0b47}-\x{0b48}\x{0b4b}-\x{0b4d}\x{0b56}-\x{0b57}\x{0b5c}-\x{0b5d}\x{0b5f}-\x{0b63}\x{0b66}-\x{0b77}]
Osmanya(40)=[\x{10480}-\x{1049d}\x{104a0}-\x{104a9}]
Phags_Pa(56)=[\x{a840}-\x{a877}]
Phoenician(29)=[\x{10900}-\x{1091b}\x{1091f}]
Rejang(37)=[\x{a930}-\x{a953}\x{a95f}]
Runic(86)=[\x{16a0}-\x{16ea}\x{16ee}-\x{16f8}]
Samaritan(61)=[\x{0800}-\x{082d}\x{0830}-\x{083e}]
Saurashtra(82)=[\x{a880}-\x{a8c5}\x{a8ce}-\x{a8d9}]
Sharada(94)=[\x{11180}-\x{111cd}\x{111d0}-\x{111df}]
Shavian(48)=[\x{10450}-\x{1047f}]
Sinhala(110)=[\x{0d82}-\x{0d83}\x{0d85}-\x{0d96}\x{0d9a}-\x{0db1}\x{0db3}-\x{0dbb}\x{0dbd}\x{0dc0}-\x{0dc6}\x{0dca}\x{0dcf}-\x{0dd4}\x{0dd6}\x{0dd8}-\x{0ddf}\x{0de6}-\x{0def}\x{0df2}-\x{0df4}\x{111e1}-\x{111f4}]
Sora_Sompeng(35)=[\x{110d0}-\x{110e8}\x{110f0}-\x{110f9}]
Sundanese(72)=[\x{1b80}-\x{1bbf}\x{1cc0}-\x{1cc7}]
Syloti_Nagri(44)=[\x{a800}-\x{a82b}]
Syriac(88)=[\x{0700}-\x{070d}\x{070f}-\x{074a}\x{074d}-\x{074f}\x{0860}-\x{086a}]
Tagalog(20)=[\x{1700}-\x{170c}\x{170e}-\x{1714}]
Tagbanwa(18)=[\x{1760}-\x{176c}\x{176e}-\x{1770}\x{1772}-\x{1773}]
Tai_Le(35)=[\x{1950}-\x{196d}\x{1970}-\x{1974}]
Tai_Tham(127)=[\x{1a20}-\x{1a5e}\x{1a60}-\x{1a7c}\x{1a7f}-\x{1a89}\x{1a90}-\x{1a99}\x{1aa0}-\x{1aad}]
Tai_Viet(72)=[\x{aa80}-\x{aac2}\x{aadb}-\x{aadf}]
Takri(67)=[\x{11680}-\x{116b8}\x{116c0}-\x{116c9}]
Tamil(123)=[\x{0b82}-\x{0b83}\x{0b85}-\x{0b8a}\x{0b8e}-\x{0b90}\x{0b92}-\x{0b95}\x{0b99}-\x{0b9a}\x{0b9c}\x{0b9e}-\x{0b9f}\x{0ba3}-\x{0ba4}\x{0ba8}-\x{0baa}\x{0bae}-\x{0bb9}\x{0bbe}-\x{0bc2}\x{0bc6}-\x{0bc8}\x{0bca}-\x{0bcd}\x{0bd0}\x{0bd7}\x{0be6}-\x{0bfa}\x{11fc0}-\x{11ff1}\x{11fff}]
Telugu(98)=[\x{0c00}-\x{0c0c}\x{0c0e}-\x{0c10}\x{0c12}-\x{0c28}\x{0c2a}-\x{0c39}\x{0c3d}-\x{0c44}\x{0c46}-\x{0c48}\x{0c4a}-\x{0c4d}\x{0c55}-\x{0c56}\x{0c58}-\x{0c5a}\x{0c60}-\x{0c63}\x{0c66}-\x{0c6f}\x{0c77}-\x{0c7f}]
Thaana(50)=[\x{0780}-\x{07b1}]
Thai(86)=[\x{0e01}-\x{0e3a}\x{0e40}-\x{0e5b}]
Tibetan(207)=[\x{0f00}-\x{0f47}\x{0f49}-\x{0f6c}\x{0f71}-\x{0f97}\x{0f99}-\x{0fbc}\x{0fbe}-\x{0fcc}\x{0fce}-\x{0fd4}\x{0fd9}-\x{0fda}]
Tifinagh(59)=[\x{2d30}-\x{2d67}\x{2d6f}-\x{2d70}\x{2d7f}]
Ugaritic(31)=[\x{10380}-\x{1039d}\x{1039f}]
Vai(300)=[\x{a500}-\x{a62b}]
Yi(1220)=[\x{a000}-\x{a48c}\x{a490}-\x{a4c6}]

I've only visually compared the "Inherited" script definition with the Unicode one (https://unicode.org/Public/UCD/latest/ucd/Scripts.txt), but there are discrepancies in that, e.g. 0x1ABF..0x1ACE is covered by the Unicode definition, but not in the PHP implementation I'm using (7.4.3)


text:
Q: Including XML file into LaTeX I am using LaTeX for very first time and have very basic knowledge about it. I am using the template from here to write my thesis. I am using Ubuntu 12.04.
When I try to include a small XML file in LaTeX with the following code, it shows the file just in one line (I am not able to see the full file in line though). But I want it to be displayed as a typical XML file (showing hierarchy).
\lstinputlisting[language=Xml]{Files/Myfile.xml}

Could someone please tell me how I can make LaTeX treat that file as an XML and show properly?

A: Try this code:
\documentclass[12pt]{amsart}
\usepackage{geometry}
\usepackage{listings}
\usepackage{color}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\geometry{a4paper}

\begin{document}

This is a sample file:

    \lstset{
    language=xml,
    tabsize=3,
    %frame=lines,
    caption=Test,
    label=code:sample,
    frame=shadowbox,
    rulesepcolor=\color{gray},
    xleftmargin=20pt,
    framexleftmargin=15pt,
    keywordstyle=\color{blue}\bf,
    commentstyle=\color{OliveGreen},
    stringstyle=\color{red},
    numbers=left,
    numberstyle=\tiny,
    numbersep=5pt,
    breaklines=true,
    showstringspaces=false,
    basicstyle=\footnotesize,
    emph={food,name,price},emphstyle={\color{magenta}}}
    \lstinputlisting{simple.xml}

\end{document}

Using the above code I have results like this:

Please note that the I've added "price", "name" and "food" as keywords.
Credits for sample XML file:
http://www.w3schools.com/xml/xml_examples.asp

redpajama_set_name: RedPajamaStackExchange


text:
Q: how to read after a specific word in a file using bash shell scripting and store in arrays i am new to linux and bash, here is my question :
my file (dff.v) has following lines
input a,b;
input [2:0] c;
output [2:0] d;

I have to read the file and store input variables(a,b,[2:0] c) and output variables ([2:0] d) in two different arrays,so that i can use them for further processing.
I have tried below code to store input variables but i am not getting it as expected.
#!/bin/bash
#assume same directory of file
counta=0;
IFS=','
for i in $(grep -w input dff.v|sed 's/[ ]//1'|sed 's/[;]//g' | sed 's/input//g');
do
 x""$counta"=$i;
 echo $i
 ((counta=counta+1))
done

i thought the variables will be stored as x0,x1,x2...
please help!!

A: You want to dynamically create vars? It's imposible this way x"$counta"=$i, but there are some tricks that may help:
read x"$counta" <<< "$i"

Or
printf -v x"$counta" "$i"

Or
declare x"$counta"="$i"

But i'd suggest use arrays instead:
while read name value; do
    value=${value//[\[\];]}
    case $name in
        input ) input+=("$value");;
        output) output+=("$value");;
    esac
done < dff.v

echo "input:  ${input[@]}"
echo "output: ${output[@]}"

$ ./test
input:  a,b 2:0 c
output: 2:0 d

A: Given the file diff.v and it's content.
baz
input a,b;
blah
input [2:0] c;
foo
output [2:0] d;
more

With a while read loop, and remove the strings that your sed is removing.
#!/usr/bin/env bash

i=0
while read -r input_output lines; do
  [[ $input_output == @(input|output) ]] || continue
  lines=${lines//[][;]}
  printf -v x$i '%s' "$lines"
  ((i++))
done < diff.v

printf '%s\n' "$x0" "$x1" "$x2"

The output
a,b
2:0 c
2:0 d

Storing the values in an associative array.
#!/usr/bin/env bash

i=0
while read -r input_output lines; do
  [[ $input_output == @(input|output) ]] || continue
  lines=${lines//[][;]}
  declare -A array["x$i"]="$lines"
  ((i++))
done < diff.v

printf '%s\n' "${array[x0]}" "${array[x1]}" "${array[x2]}"

Although if you just want to have a quick check what is the value of the array.
declare -p array


text:
Q: 32 bit fast uniform hash function. Use MD5 / SHA1 and cut off 4 bytes?
Possible Duplicate:
What is the best 32bit hash function for short strings (tag names)?

I need to hash many strings to 32bit (uint).
Can I just use MD5 or SHA1 and take 4 bytes from it? Or are there better alternatives?
There is no need for security or to care if one is cracked and so on.
I just need to hash fast and uniform to 32 bit. MD5 and SHA1 should be uniform.
But are there better (faster) build in alternatives I could use? If not, which of both would you use?
Here someone asked which one is better, but not for alternatives and there was a security matter (I don't care for security):
How to Use SHA1 or MD5 in C#?(Which One is Better in Performance and Security for Authentication)

A: Do you need a cryptographic-strength hash? If all you need is 32 bits I bet not.
Try the Fowler-Noll-Vo hash. It's fast, has good distribution and avalanche effect, and is generally acceptable for hashtables, checksums etc:
    public static uint To32BitFnv1aHash(this string toHash,
       bool separateUpperByte = false)
    {
        IEnumerable<byte> bytesToHash;

        if (separateUpperByte)
            bytesToHash = toHash.ToCharArray()
                .Select(c => new[] { (byte)((c - (byte)c) >> 8), (byte)c })
                .SelectMany(c => c);
        else
            bytesToHash = toHash.ToCharArray()
                .Select(Convert.ToByte);

        //this is the actual hash function; very simple
        uint hash = FnvConstants.FnvOffset32;

        foreach (var chunk in bytesToHash)
        {
            hash ^= chunk;
            hash *= FnvConstants.FnvPrime32;
        }

        return hash;
    }

public static class FnvConstants
{
    public static readonly uint FnvPrime32 = 16777619;
    public static readonly ulong FnvPrime64 = 1099511628211;
    public static readonly uint FnvOffset32 = 2166136261;
    public static readonly ulong FnvOffset64 = 14695981039346656037;
}

This is really useful for creating semantically equatable hashes for GetHashCode, based on a string digest of each object (a custom ToString() or otherwise). You can overload this to take any IEnumerable<byte> making it suitable for checksumming stream data etc. If you ever need a 64-bit hash (ulong), just copy the function and replace the constants used with the 64-bit constants. Oh, one more thing; the hash (as most do) rely on unchecked integer overflow; never run this hash in a "checked" block, or it will be virtually guaranteed to throw out exceptions.

A: If security does not play a role, generating a hash with a cryptographic hash function (such as MD5 or SHA1) and taking 4 bytes from it works. But they are slower than various non-cryptographic hash functions, as these functions are primarily designed for security, not speed.
Have a look at non-cryptographic hash functions such as FNV or Murmur.

*

*Non-Cryptographic Hash Function Zoo

*

*Performance Graphs

*MurMurHash3, an ultra fast hash algorithm for C# / .NET
Edit: The floodyberry.com domain is now registered by a domain parking service - removed dead links

A: The easiest and yet good algorithm for strings is as follow:
int Hash(string s)
{
  int res = 0;
  for(int i = 0; i < str.Length; i++)
  {
     res += (i * str[i]) % int.MaxValue;
  }
  return res;
}

Obviously, this is absolutely not a secured hash algorithm but it is fast (really fast) returns 32 bit and as far as I know, is uniform (I've tried it for many algorithmic challenges with good results).
Not for use to hash password or any sensible data.


text:
Q: URL host name returns null I need to get the hostname of a string url
I am trying to create the NSURL object from the string and then using host property of NSURL to get the host name. But Host name is always null.
NSURL *url = [NSURL URLWithString: @"www.google.com"];
NSLog(@"Host name %@", url.host);

but the host name is always null.
can anybody explain why is host name null?
Edit: I am sorry there was a typo i missed a quote and a comma while asking the question. But the problem is still the same.

A: As per Apple documentation,
- (NSString *)host;

Return Value:

The host of the URL. If the receiver does not conform to RFC 1808,
returns nil

So if it is not conforming to RFC 1808, it will return nil. As per definition of RFC 1808,
correct syntax is as follows :
<scheme>://<net_loc>/<path>;<params>?<query>#<fragment>

So you need to add http:// also while forming NSURL.
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
NSLog(@"Host name %@", url.host);

A: Looks like your missing a " after www.google.com? Try adding it in.
NSURL *url = [NSURL URLWithString: @"www.google.com"];
NSLog(@"Host name %@", url.host);                  ^
                     ^

(Notice on the second line I also added a comma, I tried to point at it with a ^ best I could)
EDIT: Ah, okay then it may be the comma on the second line then.

A: This will work better if you do (add http://):
NSURL *url = [NSURL URLWithString: @"http://www.google.com"];
NSLog(@"Host name %@", url.host);


text:
Q: Check if a file exists in the project in WinRT I have a WinRT Metro project which displays images based on a selected item.  However, some of the images selected will not exist.  What I want to be able to do is trap the case where they don't exist and display an alternative.
Here is my code so far:
internal string GetMyImage(string imageDescription)
{
    string myImage = string.Format("Assets/MyImages/{0}.jpg", imageDescription.Replace(" ", ""));

    // Need to check here if the above asset actually exists

    return myImage;
}

Example calls:
GetMyImage("First Picture");
GetMyImage("Second Picture");

So Assets/MyImages/SecondPicture.jpg exists, but Assets/MyImages/FirstPicture.jpg does not.
At first I thought of using the WinRT equivalent of File.Exists(), but there doesn't appear to be one.  Without having to go to the extent of trying to open the file and catching an error, can I simply check if either the file exists, or the file exists in the project?

A: There's two ways you can handle it.
1) Catch the FileNotFoundException when trying to get the file:
 Windows.Storage.StorageFolder installedLocation =
     Windows.ApplicationModel.Package.Current.InstalledLocation;
 try
 {
     // Don't forget to decorate your method or event with async when using await
     var file = await installedLocation.GetFileAsync(fileName);
     // Exception wasn't raised, therefore the file exists
     System.Diagnostics.Debug.WriteLine("We have the file!");
 }
 catch (System.IO.FileNotFoundException fileNotFoundEx)
 {
     System.Diagnostics.Debug.WriteLine("File doesn't exist. Use default.");
 }
 catch (Exception ex)
 {
     // Handle unknown error
 }

2) as mydogisbox recommends, using LINQ. Although the method I tested is slightly different:
 Windows.Storage.StorageFolder installedLocation =
     Windows.ApplicationModel.Package.Current.InstalledLocation;
 var files = await installedLocation.GetFilesAsync(CommonFileQuery.OrderByName);
 var file = files.FirstOrDefault(x => x.Name == fileName);
 if (file != null)
 {
    System.Diagnostics.Debug.WriteLine("We have the file!");
 }
 else
 {
    System.Diagnostics.Debug.WriteLine("No File. Use default.");
 }

A: BitmapImage has an ImageFailed event that fires if the image can't be loaded. This would let you try to load the original image, and then react if it's not there.
Of course, this requires that you instantiate the BitmapImage yourself, rather than just build the Uri.

A: You could use GetFilesAsync from here to enumerate the existing files.  This seems to make sense considering you have multiple files which might not exist.

Gets a list of all files in the current folder and its sub-folders. Files are filtered and sorted based on the specified CommonFileQuery.

var folder = await StorageFolder.GetFolderFromPathAsync("Assets/MyImages/");
var files = await folder.GetFilesAsync(CommonFileQuery.OrderByName);
var file = files.FirstOrDefault(x => x.Name == "fileName");
if (file != null)
{
    //do stuff
}

Edit:
As @Filip Skakun pointed out, the resource manager has a resource mapping on which you can call ContainsKey which has the benefit of checking for qualified resources as well (i.e. localized, scaled etc).
Edit 2:
Windows 8.1 introduced a new method for getting files and folders:
var result = await ApplicationData.Current.LocalFolder.TryGetItemAsync("fileName") as IStorageFile;
if (result != null)
    //file exists
else
    //file doesn't exist

A: Sample checking for resource availability for c++ /cx (tested with Windows Phone 8.1):
std::wstring resPath = L"Img/my.bmp";
std::wstring resKey = L"Files/" + resPath;
bool exists = Windows::ApplicationModel::Resources::Core::ResourceManager::Current->MainResourceMap->HasKey(ref new Platform::String(resKey.c_str()));


text:
Q: #1054 - Unknown column in 'field list' Is minus sign a special character in MySQL? Trying to insert some data:
INSERT INTO `ps_product_check`(`id_product`, `name`, `catalog`)
VALUES  (30767,'CT39-235126','79926330')

The error is
 #1054 - Unknown column 'CT39' in 'field list'

Why does it think CT39 is supposed to be a column when it is (a part) of a value? How to get around this error?

A: I run your query and it works very fine.
INSERT INTO `ps_product_check`(`id_product`, `name`, `catalog`)
VALUES  (30767,'CT39-235126','79926330')

It is possible that you have placed other quotes (backticks) in the query executed.
If I change the quotes like
INSERT INTO `ps_product_check`(`id_product`, `name`, `catalog`)
VALUES  (30767,`CT39-235126`,'79926330')

I get the same error.


text:
Q: How to do Nested Query In a Flow There is already a related question Nested SOQL Query in a Flow. However it is unanswered and out of date, from more than 7 years ago.
With all of the new capabilities of flows, I want to know if there is any way of doing something like SELECT Id, (Select FirstName FROM Contacts) FROM Account, like an inner query or nesed SOQL, with the Get Records element of a flow.

A: You can use the Loop element in the flow to loop through all Contacts in the account, get the Firts Name, store all first names in a variable.
Here is more about loops:
https://www.salesforceben.com/salesforce-flow-loops-best-practices-and-examples/#:~:text=A%20Loop%20is%20a%20Salesforce%20Flow%20element%20that,which%20you%20want%20to%20either%20assess%20or%20action.

A: There is not something out of the box that will make this a clean implementation. I would not suggest a query within a loop as you will hit the SOQL limit fairly question.
You can do 2 separate queries and then loop through each one to create a new collection of the data that you need.
Here is a custom component made by UnofficialSF that seems to solve the problem you are encountering: https://unofficialsf.com/automate-junction-updates-with-getchildcollection-and-getlookupcollection/


text:
Q: Accessing images from network drive is it possible to access image from network drive and show it in a html page.I'm not sure if its possible to go beyond the web application directory in which the html page resides
Thanks
Ravi

A: It's going to depend on the web server and the OS.
For Apache on Linux, you might be able to create a symlink to the network share.
For Windows and IIS, you'll probably have to set up the network share as a web site.
Either way, I don't think it's a good idea.  You have to consider fault tolerance; what if the network share is unavailable?


text:
Q: How should my procedure let the DataWindow know it's not dead? I have an InfoMaker report that gets results from a stored procedure, but this procedure stalls for a few seconds (intentionally) before returning the result set. When I run and view the report, this causes the PowerBuilder application to freeze until the procedure returns.
I have seen other reports that take a long time to run display a status bar inside the application before the procedure completes and the report is displayed. Is there something I should do in my InfoMaker report or T-SQL procedure to make this happen?

A: Normally, once the DW has retrieved the first row, the DW control becomes asynchronous - meaning will allow interference manually or by program. If you want to make the window responsive, before connecting to the DB, set the SQLCA.DBParm property to Async=1. This will make the DW and the Window responsive.
If you have a status bar, you can use the timer event to update the status bar with whatever text you want to display there. Like "Pulling the data in 10s..." and then doing a count down using the timer event.


text:
Q: Laravel complex query I'm re-working an already coded "crafting" system that has is based off a set of database "recipes" which has up to five items and quantities (ex: item1 and item1qty). Now previously it was important to order the items in the recipe in the right order, which made validation easy as it was just looking at what the user put as item1 and item1qty etc and matching them straight across.
We'd like to now have it accept ingredients in any order. I know this can be done with query functions, but I fear I'm off base as the solution I came up with marks it as a valid recipe if the user has even part of a recipe (say a recipe contains 3 ingredients, if they enter only one of those ingredients it will validate even without the other 2 proper ingredients and amounts). My solution is also quite long, is there a way to streamline it a bit?
$recipe = DataRecipe::where(function ($query) use($request) {
        $query->where(function ($q) use($request) {
            $q->where(function($q2) use ($request) {
                $q2->where('item1', $request->item1)->where('item1qty', $request->item1qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item2', $request->item1)->where('item2qty', $request->item1qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item3', $request->item1)->where('item3qty', $request->item1qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item4', $request->item1)->where('item4qty', $request->item1qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item5', $request->item1)->where('item5qty', $request->item1qty);
            });
        })->where(function ($q) use($request) {
            $q->where(function($q2) use ($request) {
                $q2->where('item1', $request->item2)->where('item1qty', $request->item2qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item2', $request->item2)->where('item2qty', $request->item2qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item3', $request->item2)->where('item3qty', $request->item2qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item4', $request->item2)->where('item4qty', $request->item2qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item5', $request->item2)->where('item5qty', $request->item2qty);
            });
        })->where(function ($q) use($request) {
            $q->where(function($q2) use ($request) {
                $q2->where('item1', $request->item3)->where('item1qty', $request->item3qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item2', $request->item3)->where('item2qty', $request->item3qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item3', $request->item3)->where('item3qty', $request->item3qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item4', $request->item3)->where('item4qty', $request->item3qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item5', $request->item3)->where('item5qty', $request->item3qty);
            });
        })->where(function ($q) use($request) {
            $q->where(function($q2) use ($request) {
                $q2->where('item1', $request->item4)->where('item1qty', $request->item4qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item2', $request->item4)->where('item2qty', $request->item4qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item3', $request->item4)->where('item3qty', $request->item4qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item4', $request->item4)->where('item4qty', $request->item4qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item5', $request->item4)->where('item5qty', $request->item4qty);
            });
        })->where(function ($q) use($request) {
            $q->where(function($q2) use ($request) {
                $q2->where('item1', $request->item5)->where('item1qty', $request->item5qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item2', $request->item5)->where('item2qty', $request->item5qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item3', $request->item5)->where('item3qty', $request->item5qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item4', $request->item5)->where('item4qty', $request->item5qty);
            })->orWhere(function($q2) use ($request) {
                $q2->where('item5', $request->item5)->where('item5qty', $request->item5qty);
            });
        });
    })->where('tool', $request->tool)->first();

A: There will more than likely be a better way to do this but as far as making your code more readable you could just use a loop:
$recipe = DataRecipe::where(function ($query) use ($request) {

    foreach (range(1, 5) as $i) {

        $item = $request->{'item' . $i};
        $quantity = $request->{'item' . $i . 'qty'};

        $query->where(function ($q) use ($item, $quantity) {

            $q->where(function ($q2) use ($item, $quantity) {
                $q2->where('item1', $item)->where('item1qty', $quantity);
            })->orWhere(function ($q2) use ($item, $quantity) {
                $q2->where('item2', $item)->where('item2qty', $quantity);
            })->orWhere(function ($q2) use ($item, $quantity) {
                $q2->where('item3', $item)->where('item3qty', $quantity);
            })->orWhere(function ($q2) use ($item, $quantity) {
                $q2->where('item4', $item)->where('item4qty', $quantity);
            })->orWhere(function ($q2) use ($item, $quantity) {
                $q2->where('item5', $item)->where('item5qty', $quantity);
            });
        });
    }

})->where('tool', $request->tool)->first();

If it's possible with your application I would probably look at refactoring you code and database so that you just have a standard one-2-Many relationship between DataRecipe and items. This way you don't have to worry about having item1, item2 etc. and if you can only have a certain number of items then you can just use validation to make sure you never get too many.
Hope this helps!


text:
Q: After upgrade from angular 12 to 13 incremental build is "defect" I am completely desperate cause every small change in e.g. .html (enter a space and save) results in complete build which last 2-4 minutes.
It seem that something prevent that only a incremental build is running.
In angular 12 the incremental build last 2-5 seconds.
I develop with vscode on a windows machine.
package.json
  "name": "XXX",
  "version": "0.1.0",
  "description": "XXX",
  "author": "XXX",
  "builddate": "?",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --port 4311 --configuration development",
    "build": "ng build ",
    "test": "ng test",
    "test-debug": "ng test --browsers ChromeDebug",
    "lint": "eslint -c .eslintrc.js --ext .ts src",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "13.2.0",
    "@angular/cdk": "13.2.0",
    "@angular/common": "13.2.0",
    "@angular/compiler": "13.2.0",
    "@angular/core": "13.2.0",
    "@angular/forms": "13.2.0",
    "@angular/localize": "13.2.0",
    "@angular/platform-browser": "13.2.0",
    "@angular/platform-browser-dynamic": "13.2.0",
    "@angular/router": "13.2.0",
    "@fortawesome/angular-fontawesome": "0.10.1",
    "@fortawesome/fontawesome-svg-core": "1.3.0",
    "@fortawesome/pro-light-svg-icons": "6.0.0",
    "@fortawesome/pro-solid-svg-icons": "6.0.0",
    "@ng-stack/forms": "2.4.0",
    "@ngx-translate/core": "14.0.0",
    "@ngx-translate/http-loader": "7.0.0",
    "@progress/kendo-angular-buttons": "7.0.2",
    "@progress/kendo-angular-charts": "6.0.0",
    "@progress/kendo-angular-common": "2.0.2",
    "@progress/kendo-angular-dateinputs": "6.0.1",
    "@progress/kendo-angular-dialog": "6.0.1",
    "@progress/kendo-angular-dropdowns": "6.0.1",
    "@progress/kendo-angular-excel-export": "4.0.3",
    "@progress/kendo-angular-grid": "6.0.3",
    "@progress/kendo-angular-icons": "1.0.0",
    "@progress/kendo-angular-indicators": "1.1.2",
    "@progress/kendo-angular-inputs": "8.0.5",
    "@progress/kendo-angular-intl": "3.1.2",
    "@progress/kendo-angular-l10n": "3.0.3",
    "@progress/kendo-angular-label": "3.1.2",
    "@progress/kendo-angular-layout": "6.5.0",
    "@progress/kendo-angular-listview": "3.0.0",
    "@progress/kendo-angular-menu": "3.0.4",
    "@progress/kendo-angular-messages": "1.32.2",
    "@progress/kendo-angular-navigation": "1.1.4",
    "@progress/kendo-angular-notification": "3.0.4",
    "@progress/kendo-angular-pager": "3.0.1",
    "@progress/kendo-angular-pdf-export": "3.0.3",
    "@progress/kendo-angular-popup": "4.0.4",
    "@progress/kendo-angular-progressbar": "2.0.3",
    "@progress/kendo-angular-sortable": "4.0.5",
    "@progress/kendo-angular-toolbar": "5.0.0",
    "@progress/kendo-angular-tooltip": "3.1.5",
    "@progress/kendo-angular-treelist": "4.0.3",
    "@progress/kendo-angular-treeview": "6.0.0",
    "@progress/kendo-angular-typography": "1.2.0",
    "@progress/kendo-angular-upload": "8.0.0",
    "@progress/kendo-data-query": "1.5.5",
    "@progress/kendo-drawing": "1.16.2",
    "@progress/kendo-licensing": "1.2.2",
    "@progress/kendo-svg-icons": "0.1.2",
    "@progress/kendo-theme-material": "5.2.0",
    "@tailwindcss/forms": "0.4.0",
    "@tailwindcss/typography": "0.5.1",
    "angular-oauth2-oidc": "13.0.1",
    "angular-svg-icon": "13.0.0",
    "moment": "2.29.1",
    "rxjs": "7.5.2",
    "tslib": "2.3.1",
    "zone.js": "0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "13.2.5",
    "@angular-eslint/builder": "13.1.0",
    "@angular-eslint/eslint-plugin": "13.1.0",
    "@angular-eslint/eslint-plugin-template": "13.1.0",
    "@angular-eslint/schematics": "13.1.0",
    "@angular-eslint/template-parser": "13.1.0",
    "@angular/cli": "13.2.1",
    "@angular/compiler-cli": "13.2.0",
    "@angular/language-service": "13.2.0",
    "@angular/localize": "13.2.0",
    "@types/jasmine": "3.6.2",
    "@types/jasminewd2": "2.0.8",
    "@types/node": "14.14.10",
    "@typescript-eslint/eslint-plugin": "5.11.0",
    "@typescript-eslint/eslint-plugin-tslint": "4.12.0",
    "@typescript-eslint/parser": "5.11.0",
    "codelyzer": "6.0.1",
    "eslint": "^8.2.0",
    "eslint-plugin-import": "2.22.1",
    "eslint-plugin-jsdoc": "30.7.13",
    "eslint-plugin-prefer-arrow": "1.2.2",
    "jasmine-core": "3.6.0",
    "jasmine-spec-reporter": "6.0.0",
    "karma": "6.3.9",
    "karma-chrome-launcher": "3.1.0",
    "karma-coverage": "2.1.0",
    "karma-jasmine": "4.0.1",
    "karma-jasmine-html-reporter": "1.5.4",
    "protractor": "7.0.0",
    "tailwindcss": "3.0.15",
    "ts-node": "9.1.1",
    "typescript": "4.5.4"
  }
}

angular.json
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "param-db": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": true,
            "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/silent-refresh.html"
            ],
            "styles": [
              "src/styles.scss"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": false
            },
            "development": {
              "optimization": false,
              "outputHashing": "none",
              "sourceMap": true,
              "namedChunks": true,
              "extractLicenses": true,
              "vendorChunk": true,
              "buildOptimizer": false
            }
          },
          "defaultConfiguration": "development"
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "param-db:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "param-db:build:production"
            },
            "development": {
              "browserTarget": "param-db:build:development"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "param-db:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss"
            ],
            "scripts": []
          }
        },
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "param-db:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "param-db:serve:production"
            },
            "development": {
              "devServerTarget": "param-db:serve:development"
            }
          }
        },
        "lint": {
          "builder": "@angular-eslint/builder:lint",
          "options": {
            "lintFilePatterns": [
              "src/**/*.ts",
              "src/**/*.html"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "param-db",
  "cli": {
    "warnings": {
      "versionMismatch": true
    },
    "defaultCollection": "@angular-eslint/schematics"
  }
}

Please let me know if more information is needed.
Thanks in advance!

A: It seems I found the problem.
In my styles.scss I included another .scss with my kendo styles for the components I use, like it is described here kendo styling .
I changed this back, and use the import for all components
@import "~@progress/kendo-theme-material/dist/all.scss";
Now my compile time is between 5-7 seconds instead of > 90 sec.


text:
Q: Conditional display knockout js I have a condition where based on the data I have show or hide a span.

If the Name is undefined , other than some value or "" I just need to hide the div. How do I do it knockoutjs?

A: Try this, it uses the visible binding, so see that in the visible i call the observable, so with this we can verify the value of the observable. So in JS undefined, null, 0 and  "" are the same as false, so for more information about that see the False values:

function viewModel(){
  this.text = ko.observable();

}

ko.applyBindings(new viewModel());
span{

  padding: 5px;
  background-color: red;
  color: #fff;
  margin-top: 25px;
}

<input type="text" data-bind="textInput: text"/>

A: Just use the visible binding

A: you could also create a computed result
function ViewModel() {
      this.Name = ko.observable(),
      this.nameHasValue = ko.computed(function() {
            return this.Name !== undefined;
      }, this);
};

A: Assuming that Name is an observable, you can set visibility by simply adding the following:

Moreover, if you want to be specific on the requirements when visibility is true, then you can include conditions as follows:

The above is useful if you want to include a check for strings that contains only white-spaces, or other criteria.


text:
Q: How to do warping of shapefile in GeoTools Can any body give me simple warping example in GeoTools?
I have non georeferenced shapefile with polygons and I need to georeference this shapefile by using warp technique.
Please help me.


text:
Q: How to understand the similarities and differences between $\textbf{subset}$ and $\textbf{subspace}$? Examples? Let me first state my opinions.
Suppose $X$ is a linear space closed with addition and scalar multiplication.

*

*A subspace must be a subset, while a subset may not be a subspace.

*If the subset is closed with the addition and scalar multiplication, then it is a subspace.

*The subspace must contain $\{0\}$.

Example: Let $X=\mathbb{R}^2$, then $\mathbb{R}$ is a subspace and a subset, $y=x$ is a subspace and a subset, $[0,1]\times[0,1]$ is a subset but not a subspace. Any more examples?


text:
Q: Declaring a variable name that contains the contents of another variable in C I am working on a project that requires that I name a structure array variable with a predetermined prefix and then a number.  The program starts off with an array that looks like this:
foo[elements]

and I need to declare something like this:
foo1[elements+1]

I can't just declare foo1[elements+1] because there is no predetermined number of new arrays with larger contents because I will be iterating through a loop.  If I need to present more information, or if I am not clearly presenting my question, please tell me.  I don't know if this is even possible, but if it is, it will certainly shorten things up for me.

A: In C variable names have to be known at compile time. There is no way to create new variable names at run time. Not the right language.
Your best bet will be to allocate an array that will hold your arrays:
int ** foo = calloc(sizeof(*foo), numarrays);
for (i = 0; i < numarrays; i++)
    foo[i] = calloc(sizeof(**foo), elements + i);

A: You have a problem of dynamically allocating memory for an unknown number of elements. The key here is dynamic memory, so you have to keep track of your own memory chunks. You'll have to use at some point malloc() and free().
Depending on your needs, elements type, what you can do is:

*

*If elements are a single value, maybe an integer. A good option is dynamically allocated arrays, see Sergey's answer for a code snippet.

*If elements is a more complex structure, with a few fields. You can use a list or array that holds the references to your N lists. something like:

 foo[0] -> fooN[0] -> ... -> fooN[N]
    .        |                |
    .      element 0         element N
    .
 foo[M] -> fooN[0] -> ... -> fooN[N]
             |                |
           element 0         element N

If M is known before hand, you can use an array. If neither M or N are unknown, you'll be using nested linked lists. That is a linked list of linked lists.
You'll find TONS of C linked list implementations on the web.

A: you can't allocate foo1 statically, like foo1[elements+1], unless the value of elements is not something that you would only know at runtime.
If you do know the number of elements you want than don't use a variable in the declaration:
#define ELEMENTS 10

int foo[ELEMENTS];
   int foo1[ELEMENTS+1];
Or, if it is something you would no at runtime, use dynamic memory allocation
int *foo, *foo1;

foo = (int*)malloc(sizeof(int)* elements);
foo1 = (int*)malloc(sizeof(int)*( elements+1 ) );

and don't forget to free the memory one you are done:
free(foo);
free(foo1);


text:
Q: Update multiple columns of XML column using XQuery I have the below
First Table
Declare @t1 Table(Id int , PaymentXML XML)

    Insert Into @t1
    Select 1, '<CreditCard>
            <cc_display_name />
            <cc_type>MasterCard</cc_type>
            <cc_no>************5811</cc_no>
            <cc_expire_month>4</cc_expire_month>
            <cc_expire_year>2007</cc_expire_year>
          </CreditCard>' Union All
    Select 2 , '<CreditCard>
            <cc_display_name />
            <cc_type>MasterCard</cc_type>
            <cc_no>****1234567890</cc_no>
            <cc_expire_month>3</cc_expire_month>
            <cc_expire_year>2010</cc_expire_year>
          </CreditCard>' Union All
    Select 3 , '<CreditCard>
            <cc_display_name />
            <cc_type>MasterCard</cc_type>
            <cc_no>****45678</cc_no>
            <cc_expire_month>10</cc_expire_month>
            <cc_expire_year>2011</cc_expire_year>
          </CreditCard>' Union All

    Select 4 , '<CreditCard>
            <cc_display_name />
            <cc_type>MasterCard</cc_type>
            <cc_no>****1234567890</cc_no>
            <cc_expire_month>5</cc_expire_month>
            <cc_expire_year>1997</cc_expire_year>
          </CreditCard>'
     Select * From @t1

Second Table
Declare @t2 Table(Id int)
 Insert Into @t2 Select 1 Union All Select 2
 Select * From @t2

I need to write an update statement such that for every matching row of @t1 and @t2 table, the PaymentXML column nodes will be updated as under

a)  will be blank (i.e.  )
b) will be blank (i.e.  )
c)  will be zero(0) (i.e.
  0 )
d)  will be zero(0) (i.e.
  0 )

I have given a very basic shot but need help as I am new to xquery
DECLARE @cc_type VARCHAR(10)
SELECT @cc_type = ''

Update @t1
SET PaymentXML.modify(
'
    replace value of (/CreditCard/@cc_type)[1]
    with sql:variable("@cc_type")
')
From @t1 a
Join @t2 b On a.Id = b.Id

Thanks in advance

A: Well you can update multiple columns like this
update @t1 set
    PaymentXML.modify('replace value of (/CreditCard/cc_type/text())[1] with ""')
from @t1 a
    inner join @t2 b on b.Id = a.Id

update @t1 set
    PaymentXML.modify('replace value of (/CreditCard/cc_no/text())[1] with ""')
from @t1 a
    inner join @t2 b on b.Id = a.Id

update @t1 set
    PaymentXML.modify('replace value of (/CreditCard/cc_expire_month/text())[1] with "0"')
from @t1 a
    inner join @t2 b on b.Id = a.Id

update @t1 set
    PaymentXML.modify('replace value of (/CreditCard/cc_expire_year/text())[1] with "0"')
from @t1 a
    inner join @t2 b on b.Id = a.Id

but for your case easiest way will be
update @t1 set
    PaymentXML =
        '<CreditCard>
             <cc_display_name/>
             <cc_type/>
             <cc_no/>
             <cc_expire_month>0</cc_expire_month>
             <cc_expire_year>0</cc_expire_year>
         </CreditCard>'
from @t1 a
    inner join @t2 b on b.Id = a.Id


text:
Q: Symbolic diff in matlab should return vector If I have a symbolic function p(r,s) = r^3 in MATLAB, I obtain the derivatives dp/dr = 3r^2 and dp/ds = 0, but my goal is to use matlabFunction to convert these expressions to function handles, with vector inputs (r,s). I want something similar to zeros(size(s)), for the  derivative dp/ds so I don't obtain a scalar output if my input (r,s) is a vector.
This code I tried:
syms r s
p = r^3
dpds = diff(p,s)

gives a scalar zero not variable size zero, i.e scalar output if we have vector input.

A: This is the nature of how matlabFunction works.  If you provide an equation that has no independent variables as part of the equation, it will default to giving you an anonymous function with no inputs and give you a scalar result.
For example:
>> syms r s;
>> p = r^3;
>> dpds = diff(p,s);
>> dpdsFunc = matlabFunction(dpds)

dpdsFunc =

    @()0.0

This will only give you a single scalar value each time.  This also applies to any scalar function that gives a non-zero output.  If you'd like to override this behaviour and give a variable length of this scalar that is dependent on the length of the input, you can first detect if there are any input variables in the function by checking how many variables there are.  You can use symvar for that.  You would check if this array has a length of 0, and if it does, you override the function.
Something like this comes to mind:
syms r s;
p = r^3;
dpds = diff(p,s);

if numel(symvar(dpds)) == 0
    dpdsFunc = @(s) ones(size(s))*double(dpds); %// Thanks Daniel!
else
    dpdsFunc = matlabFunction(dpds);
end

This should achieve what you want.
Minor Note
I actually think this variable length of zeroes business is something that should be put into MATLAB by default, rather than defaulting to a single value. It makes vectorizing code a lot easier.  I'm tempted to submit a feature request to MathWorks in the future.


text:
Q: Using jQuery to Highlight (Select) All Text in a Textbox I have an input text box with some text in it , onclick event I want to run a javascript function to select (highlight) all text that is in this box , how I can do that with jquery?

A: You can do this:
$('input').click(function() {
 // the select() function on the DOM element will do what you want
 this.select();
});

Of course, then you can't click on the element to select an arbitrary point in the input, so it might be better to fire that event on focus instead of click
Quick Demo w/ click or w/ focus

A: this works best for me.
$('myTextbox').select();

A: You may take a look at this article:

Let's assume that we have the following text input:
<input type="text" id="txtInput" />

In most cases, we would want to have this feature available to all
  textboxes across our website, so we would create a function to handle
  this, and call it as needed.  Calling this function with the expected
  argument will make execute the highlighting of the text.
function selectAllText(textbox) {
textbox.focus();
textbox.select(); }

Assuming you are developing against DotNetNuke 5, or have jQuery already imported into your website, add the following jQuery to your site for each textbox.  (If you have a lot of textboxes, we could do this differently, but that's for a different post.)
jQuery('#txtInput').click(function() { selectAllText(jQuery(this)) });

A: No need for jQuery, this is simple with the DOM and works in all mainstream browsers:
input.onfocus = function() { this.select(); };

If you must do it with jQuery, there's very little difference:
$(input).focus(function() { this.select(); });

A: I know this isn't jquery, but for completeness of the answers to this question, you can use this on the text input itself:
 onclick="this.select();"

For example:
<input type="text" value="abc" onclick="this.select();"/>

A: Where I typically do this is in
$(document).ready(function () {
    $('#myTextBox').focus();
    $('#myTextBox').select();
}

for the first textbox that I want filled in.
That way if I'm preserving state; and if the user backtracks to the page then it automatically highlights it all for typeover.
Useful technique for things like search boxes...


text:
Q: Check if Variable exists and === true I want to check if:

*

*a field in the array isset

*the field === true

Is it possible to check this with one if statement?
Checking if === would do the trick but a PHP notice is thrown. Do I really have to check if the field is set and then if it is true?

A: If you want it in a single statement:
if (isset($var) && ($var === true)) { ... }

If you want it in a single condition:
Well, you could ignore the notice (aka remove it from display using the error_reporting() function).
Or you could suppress it with the evil @ character:
if (@$var === true) { ... }

This solution is NOT RECOMMENDED

A: I think this should do the trick ...
if( !empty( $arr['field'] ) && $arr['field'] === true ){
    do_something();
}

A: Alternative, just for fun
echo isItSetAndTrue('foo', array('foo' => true))."
\n";
echo isItSetAndTrue('foo', array('foo' => 'hello'))."
\n";
echo isItSetAndTrue('foo', array('bar' => true))."
\n";

function isItSetAndTrue($field = '', $a = array()) {
    return isset($a[$field]) ? $a[$field] === true ? 'it is set and has a true value':'it is set but not true':'does not exist';
}

results:
it is set and has a true value
it is set but not true
does not exist

Alternative Syntax as well:
$field = 'foo';
$array = array(
    'foo' => true,
    'bar' => true,
    'hello' => 'world',
);

if(isItSetAndTrue($field, $array)) {
    echo "Array index: ".$field." is set and has a true value
\n";
}

function isItSetAndTrue($field = '', $a = array()) {
    return isset($a[$field]) ? $a[$field] === true ? true:false:false;
}

Results:
Array index: foo is set and has a true value

A: You can simply use !empty:
if (!empty($arr['field'])) {
   ...
}

This is precisely equivalent to your conditions by DeMorgan's law. From PHP's documentation, empty is true iff a variable is not set or equivalent to FALSE:
  isset(x) && x
  !(!isset(x) || !x)
  !empty(x)

As you can see, all three of these statements are logically equivalent.


text:
Q: Расположит элемент по центру из кода Android Есть код, который убирает Textview, который расположен слева, другой расположен справа. При скрытии левого, правый должен "перемещаться" в центр. Textview находятся в айтеме, который заполняется с адаптера, это не activity. Расположены в одном RelativeLayout.
Сам код скрытия Textview
 if (productList.get(position).getPriceOld().toString().equals("0")){
            holder.price_txt.setVisibility(View.GONE);
        }


text:
Q: ASP.Net MVC - HTTP Status Codes (i.e. 303, 401, 404, etc) In ASP.Net MVC is it possible to use either Redirect or RedirectToAction to call for example a 303 error?
I am working my way through a book titled "ASP.NET MVC 1.0 Website Programming" and the source is making calls such as return this.Redirect(303, FormsAuthentication.DefaultUrl); but this call only functions with an external library, I would like to have the same functionality sans the add-on if possible.

A: You can create custom ActionResults that mimic any http response code you'd like.  By returning those action results, you can easily perform a 303.
I found this quick write-up that you should be able to follow easily.

A: Here's what I came up with based on the advice given in the current answers and the decompiled System.Web.Mvc.RedirectResult code:
public class SeeOtherRedirectResult : ActionResult
{
    public string Url { get; private set; }
    public HttpStatusCode StatusCode { get; private set; }

    public SeeOtherRedirectResult(string url, HttpStatusCode statusCode)
    {
        if (String.IsNullOrEmpty(url))
        {
            throw new ArgumentException("URL can't be null or empty");
        }
        if ((int) statusCode < 300 || (int) statusCode > 399)
        {
            throw new ArgumentOutOfRangeException("statusCode",
                        "Redirection status code must be in the 3xx range");
        }
        Url = url;
        StatusCode = statusCode;
    }

    public override void ExecuteResult(ControllerContext context)
    {
        if (context == null)
        {
            throw new ArgumentNullException("context");
        }
        if (context.IsChildAction)
        {
            throw new InvalidOperationException("Cannot redirect in child action");
        }

        context.Controller.TempData.Keep();
        context.HttpContext.Response.StatusCode = (int) StatusCode;
        context.HttpContext.Response.RedirectLocation =
                     UrlHelper.GenerateContentUrl(Url, context.HttpContext);
    }
}

A: 2 ways about this-
  Response.Redirect(url, false); //status at this point is 302
  Response.StatusCode = 303;

-or-
  Response.RedirectLocation = url;
  Response.StatusCode = 303;

Note that in the first redirect, that the false parameter avoids the threadAbort exception that the redirect(url) normally throws. This is one good reason to use one of these 2 methods.

A: You could also accomplish it with a custom ActionFilter like I mention here. I for one like the ActionFilter a bit more the the ActionResult.


text:
Q: How to send email with not necessary Multiple Attachments from html form in PHP I have get value from html form and send via email with multiple attachments. Attachments are not necessary.
I have got some piece of code to send multiple attachments through mail function in php But my mail sending fails and i dont know why. My attachments are not necessary. This is my code:
<?php
function multi_attach_mail($to, $subject, $message, $senderMail, $senderName, $files){
    $from = $senderName." <".$senderMail.">";
    $headers = "Siuntėjęs: $from";

    // boundary
    $semi_rand = md5(time());
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

    // headers for attachment
    $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";

    // multipart boundary
    $message = "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"utf-8\"\n" .
    "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";

    // preparing attachments
    if(count($files) > 0){
        for($i=0;$i<count($files);$i++){
            if(is_file($files[$i])){
                $message .= "--{$mime_boundary}\n";
                $fp =    @fopen($files[$i],"rb");
                $data =  @fread($fp,filesize($files[$i]));

                @fclose($fp);
                $data = chunk_split(base64_encode($data));
                $message .= "Content-Type: application/octet-stream; name=\"".basename($files[$i])."\"\n" .
                "Content-Description: ".basename($files[$i])."\n" .
                "Content-Disposition: attachment;\n" . " filename=\"".basename($files[$i])."\"; size=".filesize($files[$i]).";\n" .
                "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
            }
        }
    }

    $message .= "--{$mime_boundary}--";
    $returnpath = "-f" . $senderMail;

    //send email
    $mail = @mail($to, $subject, $message, $headers, $returnpath);

    //function return true, if email sent, otherwise return fasle
    if($mail){ return TRUE; } else { return FALSE; }

}

if($_SERVER['REQUEST_METHOD'] == 'POST'
    && !empty($_POST['namecontact'])
    && !empty($_POST['namecarinfo']) ) {

      $contacts = array(
        //"autoperka.info@gmail.com",
        //"automobiliukas24@gmail.com",
      //  "ruslanneviadomskij@gmail.com",
          "gabriele.giniot@gmail.com"
      );

    foreach($contacts as $contact) {

      $to = $contact; // this is your Email address
      $from = $_POST['namecontact']; // this is the sender's Email address
      $carinformation = $_POST['namecarinfo'];
      $coment = $_POST['namecoment'];
      $subject = $from . " SupirkimasPlius.lt";
      $from_name = $_POST['namecontact'];

      //$headers = "Siuntėjas:" . $from;

//attachment files path array
$file_tmp_name  = $_FILES['namephoto']['tmp_name'];
$fileName       = $_FILES['namephoto']['name'];
$fileType       = $_FILES['namephoto']['type'];
$files = $fileType;
// Message
$html_content = '

Automobilio pasiūlymas:

Marke: '.$carinformation.'

Kontaktai: '.$from.'

Komentaras: '.$coment.
'
Nuotraukų kiekis'.count($files);

//call multi_attach_mail() function and pass the required arguments
$send_email = multi_attach_mail($to,$subject,$html_content,$from,$from_name,$files);

//print message after email sent
}
  $myfile = fopen("success.php", "r") or die(fopen("index.php", "r"));
  echo fread($myfile,filesize("success.php"));
  fclose($myfile);
  //mail('gabriele.giniot@gmail.com',$subject,$message,$headers);
  //mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender

  } else {
    $myfile = fopen("failed.php", "r") or die(fopen("index.php", "r"));
    echo fread($myfile,filesize("failed.php"));
    fclose($myfile);
  }
?>

please help me :)


text:
Q: Setting an iterated value for an attribute by counting related items in Core Data I'm trying to set an attribute value to an automatically iterated number based on a to one relationship. I have an entity called "Encounter" that has a to many relationship to "Round" and I need the attribute to simply iterate to the next value and reflect the number of rounds currently related to the Encounter entity. I have the appropriate data model, tabel views, and array controllers bound and set up in interface builder and they all work fine. But when I try to reference the encounter property from my Round subclass fo NSManagedObject, I get just get null.
ex:
- (void) awakeFromInsert{
    [super awakeFromInsert];
    Encounter *enc = [self encounter];
    NSUInteger roundCount = [[enc rounds]count];
    [self setValue:[NSNumber numberWithUnsignedInteger:roundCount] forKey:@"roundNumber"];
    }

I also tried creating a method that executes a fetch request ont he Managed Object Context but I haven't figured out how to write a predicate that only pulls the related records to count. I'm sure this is something simple that I'm missing and I would appreciate any assistance.

A: I figured out a solution that seems to work well. Basically, I subclassed the NSArrayController and overrode the addObject method to look like the following with "Round" being the name of the NSManagedObject subclass:
-(id)newObject{
    Round *round = (Round *)[super newObject];
    round.roundNumber = [NSNumber numberWithUnsignedInteger:[[self arrangedObjects]count]+1];
    return round;
}


text:
Q: GRUB boot error > no such disk: UUID. Grub rescue I had Windows 10 installed on my SSD. After that I decided to install Ubuntu on a Dual-Boot so I can have a Linux also. I installed de GRUB on the SSD with Windows 10 and the Ubuntu system on another disk.
/dev/sda --> Boot GRUB with options to boot Windows or Ubuntu
/dev/sdb
/dev/sdb1 --> Windows partition to storage DATA
/dev/sdb2 --> Windows partition to storage PROGRAMS
/dev/sdb3 --> Linux partition
When I shutdown the PC from windows, and try to boot again the system I get to a black screen like this one:
Black screen
I checked and the UUID shown on the image is the one of the second disk (HDD) where is the linux system and both partitions of DATA and PROGRAMS for windows.
While I'm in this screen, I tried some solutions that I found around internet but I got nothing. When I run the command "ls" in the grub rescue, I get only partitions on HD0, which is the SSD I think.
After I press CTRL+ALT+SUPR I get to the grub menu, and I can boot normally.
Can someone help me to solve the black screen process? Why does GRUB doesn't see the HDD while booting?


text:
Q: How to group windows in gnome overview Is there a way to have windows grouped by application in the gnome shell "overview" (sorry, I don't know the correct term) that appears when pressing the super key?

A: Not an answer, just a set of workarounds.
On my system, the overview opens quite slowly in a "usual" session (a dozen browser windows, other applications, ...) I use overview mainly for the search facility, task switching usually happens via Alt+Tab.

*

*The Gno-Menu extension also has a search bar, the menu can be activated via F2.

*The Window list extension displays the list of currently active tasks at the bottom. It can be configured to show only one button per application.

*The Switcher extension (fairly new) allows selecting another application by typing its name after hitting Super+W.

*I used the Gnome Tweak tool to set the shortcut for switching between overview and desktop (in the "Keyboard and Mouse section") to Super right (which is not present on my keyboard). This is because hitting Super left if I want to open a new app is already in my muscle memory.

This essentially avoids the necessity to open the overview, ever.


text:
Q: How to Change view(XIB) after imagePickerController:didFinishPickingMediaWithInfo? I am new on iphone and objective-c development.
I want to know how i can change the view (XIB File) after the camera takes a picture.
Can anyone help me or share some code? I am searching for this since a week :(
After finishing the app, i am ready to share my project and/or make a tutorial.
Infos about my App: i want to scan barcodes and save the barcodes in my app.
For scanning barcodes iam using the ZBarSDK.
I hava a TabBarController, on the first Tab, i can open the camera.
After the scan process i want to jump to the second tab (another XIB File) and show the results.
Thanks for any help.
Here my code of the first tab (ScanCodeViewController):
.h
#import < UIKit/UIKit.h >

@class OutPutCodeViewController;

@interface ScanCodeViewController : UIViewController <ZBarReaderDelegate> {
 IBOutlet UIImageView *img;
 OutPutCodeViewController *output;
}

@property (nonatomic, retain) IBOutlet UIImageView *img;
@property (nonatomic, retain) OutPutCodeViewController *output;

- (IBAction) scanButton;

@end

.m
#import "ScanCodeViewController.h"

@implementation ScanCodeViewController

@synthesize img;
@synthesize output;

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (void)dealloc {
[img release];
[super dealloc];
}

- (IBAction) scanButton {
 NSLog(@"Scanbutton wurde geklickt!");

 ZBarReaderViewController *reader = [ZBarReaderViewController new];
 reader.readerDelegate = self;

 ZBarImageScanner *scanner = reader.scanner;

 [scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to: 0];

 [self presentModalViewController:reader animated: YES];
 [reader release];
 }

- (void) imagePickerController: (UIImagePickerController*) reader
 didFinishPickingMediaWithInfo: (NSDictionary*) info
{
 NSLog(@"Entered imagePickerController");

 // ADD: get the decode results
 id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];
 ZBarSymbol *symbol = nil;
 for(symbol in results) {
 break;
 }

 img.image = [info objectForKey:UIImagePickerControllerOriginalImage];
 [reader dismissModalViewControllerAnimated: YES];

 //[self presentModalViewController:output animated:YES]; //by using this, app chrashes

}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
 [picker dismissModalViewControllerAnimated: YES];

}

@end

And here the Secong Tab (OutPutCodeViewController)
.h
#import <UIKit/UIKit.h>

@interface OutPutCodeViewController : UIViewController {
 IBOutlet UIImageView *resultImage;
 IBOutlet UITextField *resultText;
}

@property (nonatomic, retain) IBOutlet UIImageView *resultImage;
@property (nonatomic, retain) IBOutlet UITextField *resultText;

@end

.m
#import "OutPutCodeViewController.h"

@implementation OutPutCodeViewController

@synthesize resultImage;
@synthesize resultText;

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (void)dealloc {
 [resultImage release];
 [resultText release];

[super dealloc];
}

@end

A: Got it!
It is not possible to set more animate:YES.
Here is the sample and right code.
I hope it helps others.
- (void) imagePickerController: (UIImagePickerController*) reader
 didFinishPickingMediaWithInfo: (NSDictionary*) info
{

    // ADD: get the decode results
    id<NSFastEnumeration> results =
    [info objectForKey: ZBarReaderControllerResults];
    ZBarSymbol *symbol = nil;
    for(symbol in results)
        break;

[reader dismissModalViewControllerAnimated: NO];

    TableDetailViewController *tc = [[TableDetailViewController alloc]         initWithNibName:@"TableDetailViewController" bundle:nil];
    tc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:tc animated:YES];
    [tc release];

}

brush51

A: In didFinishPickingMediaWithInfo you should call [self.tabBarController setSelectedIndex:1] to switch to the second tab.


text:
Q: How to Store a data From JSON file into a JSON Store Hi i have a JSON file which contains
{
   "result": [
      {
         "urlFeedCategoryValue": "Language",
         "urlFeedName": "DB2",
         "urlId": "language_DB2",
         "urlFeedLink": "http://www-947.ibm.com/systems/support/myfeed/xmlfeeder.wss?feeder.requid=feeder.create_public_feed&feeder.feedtype=RSS&feeder.maxfeed=25&OC=SSEPDU&feeder.subdefkey=swgimgmt&feeder.channel.title=DB2 Connect&feeder.channel.descr=The latest updates about DB2 Connect",
         "urlFeedCategory": "1",
         "urlFeedTimeStamp": "2012-04-17-03:04:27"
      }
   ]
}

Now i want to read this JSON file and store it in the JSONStore of Extjs
Plz help me how to acheive thi

A: This is not especially a problem of Ext.
Do you have any serverside backend? Then I would suggest opening and preparing the JSON-File there.


text:
Q: Get all numbers that add up to a number I'm trying to find a way to display all the possible sets of X integers that add up to a given integer. for example to get all 2 integer sets that make 5 I would have:
1, 4
2, 3

Or for 3 integers that make 6:
1, 1, 4
1, 2, 3
2, 2, 2

I only need whole numbers not including 0 and it only needs to work on up to about 15 in a set and 30 max. number.
I'm not even sure if this has a term mathematically. It's similar to factorisation I guess?

A: Here is one way to solve this problem:
def sum_to_n(n, size, limit=None):
    """Produce all lists of `size` positive integers in decreasing order
    that add up to `n`."""
    if size == 1:
        yield [n]
        return
    if limit is None:
        limit = n
    start = (n + size - 1) // size
    stop = min(limit, n - size + 1) + 1
    for i in range(start, stop):
        for tail in sum_to_n(n - i, size - 1, i):
            yield [i] + tail

You can use it like this.
for partition in sum_to_n(6, 3):
    print partition

[2, 2, 2]
[3, 2, 1]
[4, 1, 1]

A: These are called partitions of the integer in question. Others have provided links to define them.
A trick to do these things is often to do them recursively. For example, suppose I wanted to form all distinct ways to build 10 as the sum of exactly three integers, none of which appears more than once.
Look at the largest possible component in that sum. Can it be 10? No, since if the largest component is a 10, then what remains? I.e., 10 - 10 = 0. It turns out that if the largest element in the sum is a 7, then what remains, to be partitioned into a sum of two positive integers is 3. And we can break 3 into a sum of two distinct integers in exactly one way. So {7,2,1} is such a partition, and the only partition that involves an element as large as 7.
Can 6 be used as the largest element? If so, then we would have 4 remaining. And we can break 4 in exactly one way, to yield the partition {6,3,1}. Further searching will yield other partitions of 10 as {5,4,1}, {5,3,2}. No others can exist.
The point is, this operation can easily be defined as a recursive function. With careful coding, one might even use memoization, to avoid recomputing that which we have seen before.

A: There's a snippet here:
from itertools import combinations, chain

def sum_to_n(n):
    'Generate the series of +ve integer lists which sum to a +ve integer, n.'
    from operator import sub
    b, mid, e = [0], list(range(1, n)), [n]
    splits = (d for i in range(n) for d in combinations(mid, i))
    return (list(map(sub, chain(s, e), chain(b, s))) for s in splits)

Use it like this:
for p in sum_to_n(4):
    print p

Outputs:

[4]
[1, 3]
[2, 2]
[3, 1]
[1, 1, 2]
[1, 2, 1]
[2, 1, 1]
[1, 1, 1, 1]

A: Your question can be rephrased like this :

Given a number N, find all sets [S1, S2, S3 .....] where the sum of each set equals N. The size of the sets are given by the number L.

First let's consider the case of L=2.This means that you can have the following sets
(9,1) , (8,2), (7,3) , (6,4) , (5,5)
I'll call this the base solution and you'll soon see why.
Let's change our L to 3 now and redo our answer :
So let's consider the number 9. Does there exist such a list L such that sum(L) + 9 = 10 ? The obvious answer is No, but what's interesting here is not the answer but the question itself. We are basically asking for a set of 2 elements that can be summed up to be the number 1. This is the same problem that was solved by the base solution.
So therefore for each number x in [9,8,7,6,5,4,3,2,1]  you try to find a set [a,b]such that x+a+b = 10.
This isn't a complete answer, but the idea is that you see the pattern here, and use recursion to calculate the base case as done above and then figure out the recursive call that will complete your solution. Good luck!

A: Thank you @Jason Orendorff - I further developed your function, because I needed a few more options.
It`s now possible to specify min and max summand count, and to permutate the combinations.
Be careful with max_summand_count: If you set it too high, you end up in recursion hell :)
from itertools import permutations

def get_all_possible_summands_to_n(n, min_summand_count=1, max_summand_count=5, min_summand=1, max_summand=None, permutate=False):
    if min_summand_count < 1:
        raise ValueError("min_summand_count may not be below 1")

    if min_summand < 1:
        raise ValueError("min_summand may not be below 1")

    if not max_summand_count:
        max_summand_count = n

    if max_summand is None:
            max_summand = n

    for size in range(min_summand_count, max_summand_count + 1):
        if size == 1 and n <= max_summand:
            yield [n]
            continue

        start = (n + size - 1) // size
        stop = min(max_summand, n - size + 1) + 1

        for i in range(start, stop):
            if (size-1) > 0:
                for tail in get_all_possible_summands_to_n(n - i, size - 1, size - 1, min_summand, i):
                    result = list([i] + list(tail))

                    if [c for c in result if c >=min_summand] == result:
                        if permutate:
                            for combination in list(set(permutations(result, len(result)))):
                                yield list(combination)
                        else:
                            yield result

Here all all the tests it passed:
def test_get_all_possible_summands_to_n(self):

    # BASICS
    self.assertEqual(
        list(get_all_possible_summands_to_n(3)),
        [[3], [2,1], [1,1,1]]
    )

    # permutation
    self.assertEqual(
        list(get_all_possible_summands_to_n(3, permutate=True)),
        [[3], [1,2], [2,1], [1,1,1]]
    )

    # MIN / MAX SUMMAND
    self.assertEqual(
        list(get_all_possible_summands_to_n(4)),
        [[4], [2, 2], [3, 1], [2, 1, 1], [1, 1, 1, 1]]
    )

    # min summand
    self.assertEqual(
        list(get_all_possible_summands_to_n(4, min_summand=2)),
        [[4], [2, 2]]
    )

    self.assertEqual(
        list(get_all_possible_summands_to_n(4, min_summand=3)),
        [[4]]
    )

    # max summand
    self.assertEqual(
        list(get_all_possible_summands_to_n(4, max_summand=2)),
        [[2, 2], [2, 1, 1], [1, 1, 1, 1]]
    )

    self.assertEqual(
        list(get_all_possible_summands_to_n(4, max_summand=3)),
        [[2, 2], [3, 1], [2, 1, 1], [1, 1, 1, 1]]
    )

    # min / max summand combination
    self.assertEqual(
        list(get_all_possible_summands_to_n(5)),
        [[5], [3, 2], [4, 1], [2, 2, 1], [3, 1, 1], [2, 1, 1, 1], [1, 1, 1, 1, 1]]
    )

    self.assertEqual(
        list(get_all_possible_summands_to_n(5, min_summand=2, max_summand=3)),
        [[3, 2]]
    )

    self.assertEqual(
        list(get_all_possible_summands_to_n(6, min_summand=3, max_summand=3)),
        [[3, 3]]
    )

    # MIN / MAX SUMMAND COUND
    self.assertEqual(
        list(get_all_possible_summands_to_n(6)),
        [
            [6],
            [3, 3],
            [4, 2],
            [5, 1],
            [2, 2, 2],
            [3, 2, 1],
            [4, 1, 1],
            [2, 2, 1, 1],
            [3, 1, 1, 1],
            [2, 1, 1, 1, 1]
        ]
    )

    # min summand count
    self.assertEqual(
        list(get_all_possible_summands_to_n(6, min_summand_count=3)),
        [
            [2, 2, 2],
            [3, 2, 1],
            [4, 1, 1],
            [2, 2, 1, 1],
            [3, 1, 1, 1],
            [2, 1, 1, 1, 1]
        ]
    )

    # max summand count
    self.assertEqual(
        list(get_all_possible_summands_to_n(6, max_summand_count=3)),
        [
            [6],
            [3, 3],
            [4, 2],
            [5, 1],
            [2, 2, 2],
            [3, 2, 1],
            [4, 1, 1],
        ]
    )

    # min max summand count combination
    self.assertEqual(
        list(get_all_possible_summands_to_n(6, min_summand_count=2, max_summand_count=3)),
        [
            [3, 3],
            [4, 2],
            [5, 1],
            [2, 2, 2],
            [3, 2, 1],
            [4, 1, 1],
        ]
    )

    self.assertEqual(
        list(get_all_possible_summands_to_n(6, min_summand_count=3, max_summand_count=3)),
        [
            [2, 2, 2],
            [3, 2, 1],
            [4, 1, 1],
        ]
    )

    # ALL COMBINATIONS
    self.assertEqual(
        list(get_all_possible_summands_to_n(12, min_summand_count=2, max_summand_count=3, min_summand=2, max_summand=3)),
        []
    )

    self.assertEqual(
        list(
            get_all_possible_summands_to_n(
                12,
                min_summand_count=4,
                max_summand_count=5,
                min_summand=2,
                max_summand=4
            )
        ),
        [
            [3, 3, 3, 3],
            [4, 3, 3, 2],
            [4, 4, 2, 2],
            [3, 3, 2, 2, 2],
            [4, 2, 2, 2, 2]
        ]
    )

Feel free to optimise it`s performance and elegancy :) - I`m sure there is some potential to do so


text:
Q: Make a fluent transition using sine waves I have following code:
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;

public class Test {
    private static final int MAX_LENGTH = 1000;
    private Random r = new Random();
    protected static final int SAMPLE_RATE = 32 * 1024;

    public static byte[] createSinWaveBuffer(double freq, int ms) {
        int samples = ((ms * SAMPLE_RATE) / 1000);
        byte[] output = new byte[samples];
        double period = (double) SAMPLE_RATE / freq;
        for (int i = 0; i < output.length; i++) {
            double angle = 2.0 * Math.PI * i / period;
            output[i] = (byte) (Math.sin(angle) * 0x7f);
        }
        return output;
    }

    public static void main(String[] args) throws LineUnavailableException {
        List<Double> freqs = new Test().generate();
        System.out.println(freqs);
        final AudioFormat af = new AudioFormat(SAMPLE_RATE, 8, 1, true, true);
        SourceDataLine line = AudioSystem.getSourceDataLine(af);
        line.open(af, SAMPLE_RATE);
        line.start();
        freqs.forEach(a -> {
            byte[] toneBuffer = createSinWaveBuffer(a, 75);
            line.write(toneBuffer, 0, toneBuffer.length);
        });
        line.drain();
        line.close();
    }

    private List<Double> generate() {
        List<Double> frequencies = new ArrayList<>();
        double[] values = new double[] { 4.0/3,1.5,1,2 };
        double current = 440.00;
        frequencies.add(current);
        while (frequencies.size() < MAX_LENGTH) {
            //Generate a frequency in Hz based on harmonics and a bit math.
            boolean goUp = Math.random() > 0.5;
            if (current < 300)
                goUp = true;
            else if (current > 1000)
                goUp = false;
            if (goUp) {
                current *= values[Math.abs(r.nextInt(values.length))];
            } else {
                current *= Math.pow(values[Math.abs(r.nextInt(values.length))], -1);
            }
            frequencies.add(current);
        }
        return frequencies;
    }

}

I want to generate a random "melody", beginning from A(hz=440). I do this using random numbers to determine, whether the tone goes up or down.
My problem:
I can generate the melody, but if I play it, there is always a "knocking" sound between each tone. What could I do to remove it, so it sounds better?

A: At the beginning and ending of each tone, the signal going to your SourceDataLine jumps from volume 0 to the full out sine wave instantaneously. Or, it jumps from some arbitrary value in one sine wave to the beginning value in the next. Large jumps can create many overtones which are often heard as clicks.
To remedy this, in your method createSineWaveBuffer, it would be helpful to smooth out the start and end of the buffer by multiplying the values by a factor that ranges from 0 to 1 for the start of the tone, and 1 to 0 for the end of the tone. The number of frames over which you do this depends mostly on esthetics and the sample rate. I think 1 millisecond transitions might work as a ballpark minimum. A commercial digital synth that I have uses that as the smallest value. For 44100 fps, that comes to dividing the transition into 44 steps, e.g., 0/44, 1/44, 2/44, etc. that you multiply to the data values at the start of the buffer, and the reverse that you multiple against the end of the buffer.
I'd be tempted to prefer 64 or 128 steps. 128 steps at 44100 comes to a note onset that only takes about 0.003 seconds, and it should make the transition smooth enough to eliminate the "discontinuity" in the signal. Of course you can choose longer transitions if it sounds more pleasing.
If you do this (if the transition is long enough) there shouldn't be any need to apply low-pass filtering.


text:
Q: How to access dynamic text field on stage from within the document class I'm trying to access a text input that I've already placed on the stage (inside a movie clip) but with no luck.
I've defined an instance name for this dynamic text field which is currentUserCount
I've got something like this set up in the document class actionscript file:
package {

    import flash.events.Event;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.display.Sprite;
    import flash.display.DisplayObject;
    import flash.display.MovieClip;
    import flash.display.Stage;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;

    public class myProject extends Sprite {

        public function myProject() {
            // Trying stuff like
            trace(currentUserCount);
            trace(movieClipName.currentUserCount);
            trace(root.currentUserCount);
        }
    }
}

What am I missing?
When I run this I get:
1120: Access of undefined property currentUserCount.
1120: Access of undefined property movieClipName.
1119: Access of possibly undefined property movieClipName through a reference with static type flash.display:DisplayObject.
1120: Access of undefined property currentUserCount.

A: If all of the movieclips on the stage had the same nested clip inside of it, you could also just reference the inner clips like so:
for (var i=0; i<stage.numChildren; i++){
  var mc = stage.getChildAt(i)
  mc.subClip.play()
}

A: Make sure the MovieClip and the TextField have instance names in your .fla file.
// MovieClip instance name: mc;
// Textfield instance name: tf;

Then in your document class:
package {

    import flash.events.Event;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.display.Sprite;
    import flash.display.DisplayObject;
    import flash.display.MovieClip;
    import flash.display.Stage;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;

    public class myProject extends Sprite {

        public function myProject() {
            mc.tf.text = "Text you wanna see";
            trace(mc.tf); // [Object TextField]
        }
    }
}

A: My problem was that I was referencing a movie clip within a movie clip and I didn't know I had to create an instance name for each one and work my way in code through each one.
I thought the instance names were a part of a global namespace.
So I was doing something like:
myMovieClip.play();

when I should have been doing:
mainMovieClip.subMovieClip.myMovieClip.play();


text:
Q: submit form in spring MVC by clicking on Link Is there any way to submit the form in spring MVC by clicking on Link or do I need to use the javascript submit method
Thanks

A: Use JQuery on submit function as the event on url click:
$('#formName').submit();


text:
Q: Linear regression function by hand in Python I have written the code below to define a function for regression analysis, however, it does not work.
import numpy as np
import pandas as pd

def linear_regress(y, X):
    X_trp = np.transpose(X)
    b = np.linalg.inv(X_trp@X)@X_trp@y
    e = y - X@b
    e_trp = np.transpose(e)
    sigma_sqr = (e_trp@e) / (X.shape[0] - X.shape[1])
    var_b = sigma_sqr@(np.linalg.inv(X_trp@X))
    SE = np.sqrt(var_b)
    z_score = 1.96
    upper = b+SE*z_score
    lower = b-SE*z_score
    CI = [lower, upper]
    results = {"Regression Coefficients": b,
              "Standard Error (SE)": SE,
              "95% Confidence Interval": CI}
    return results

It returns when I define array and run the function:
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-17-8307755b9bbc> in <module>
----> 1 linear_regress(indt, dept)

<ipython-input-16-a6336ec1997c> in linear_regress(y, X)
      8     e_trp = np.transpose(e)
      9     sigma_sqr = (e_trp@e) / (X.shape[0] - X.shape[1])
---> 10     var_b = sigma_sqr@(np.linalg.inv(X_trp@X))
     11     SE = np.sqrt(var_b)
     12     z_score = 1.96

ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 2 is different from 1)

Can you please help me to figure out what the problem is?
Thanks for your help!

A: It is difficult to tell what you are doing wrong without some proper idea of your data.
But I am guessing you are trying to implement the Normal Equation to get weight.
If that is the case, this seems way too complicated for that, here is a simpler approch.
def LinearRegression(X, y):
    X_t = X.T
    theta = np.dot(np.linalg.inv(np.dot(X.T, X)), np.dot(y,X))
    mean_sqr_error = np.mean((y - np.dot(theta,X.T))**2)
    return theta, mean_sqr_error