Authenticate to AD with Okta? Posted: 16 Apr 2021 08:00 AM PDT Please read this carefully. This is the normal flow of trust (Source) AD -> Okta -> Other application I want something like this (Source) AD -> Okta -> (some middleman application) -> AD (same ad) This middleman would not (preferably) use it's own service account but use the Okta tokens to run commands as the actual user. What I want to achieve with this is to run queries or updates on AD without having to separately put credentials and simply use the token okta provides. Is it something doable? |
How to change a default expression in Zabbix Posted: 16 Apr 2021 08:00 AM PDT by default, zabbix comes with the following rule that alerts you when the server's disk is less than 5GB of free space {Zabbix server:vfs.fs.size[/,pused].last()}>{$VFS.FS.PUSED.MAX.CRIT:"/"} and (({Zabbix server:vfs.fs.size[/,total].last()}-{Zabbix server:vfs.fs.size[/,used].last()})<5G or {Zabbix server:vfs.fs.size[/,pused].timeleft(1h,,100)}<1d) I want to know if there is a way to change these 5GB to a slightly larger number, like 20Gb for example I am new to Zabbix and any help is welcome, thanks. |
Is there a better or more efficiant way of writing this short bit of VBA code? Posted: 16 Apr 2021 07:59 AM PDT The VBA Code below, which is part of a much larger sub that pulls and formats data from various other sheets, is formatting the first row, Range A1:I1 which contains headers. It appears to work as expected but is there a simpler or more efficiant way of doing exactly what this code is doing? Do I really need to include things such as: .Strikethrough = False .Superscript = False .TintAndShade = 0 .ThemeFont = xlThemeFontNone and so on or is it best practice to include them, I would rather do things the correct way. Rows("1:1").RowHeight = 32 Range("A1:I1").Select With Selection.Font .Name = "Arial" .Size = 11 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ThemeColor = xlThemeColorLight1 .TintAndShade = 0 .ThemeFont = xlThemeFontNone End With With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorLight1 .TintAndShade = 0 .PatternTintAndShade = 0 End With With Selection.Font .ThemeColor = xlThemeColorDark1 .TintAndShade = 0 End With Range("A1").Select End Sub |
ZeroMQ: link to message relation Posted: 16 Apr 2021 07:59 AM PDT I am using the ZMQ's Pub-Sub-Pattern. And I know it is possible to connect a subscriber to any number of publishers in order to receive with the ZMQ recv -function all the publisher messages over just one socket. However, I also need the information over which "link" (e.g. ipc:///tmp/link.ipc) I received the current received message. Is there a way to query this information from the ZMQ message? To help understanding what I mean, here a small example: #include <zmq.hpp> int main() { zmq::context_t ctx(1); zmq::socket_t skt(ctx, ZMQ_SUB); skt.setsockopt(ZMQ_SUBSCRIBE, nullptr, 0); skt.connect("ipc:///tmp/link0.ipc"); skt.connect("ipc:///tmp/link1.ipc"); skt.connect("ipc:///tmp/link1.ipc"); zmq::message_t msg; while (1) { if (skt.recv(msg)) { // from which link is the message? } } } |
GitHub Personal Access Token is not set, neither programmatically, nor using env "GH_TOKEN" Posted: 16 Apr 2021 07:59 AM PDT I'm trying to release an electron application using electron builder. My script is simple : "release": "electron-builder", But it keeps saying : GitHub Personal Access Token is not set, neither programmatically, nor using env "GH_TOKEN" Here is the complete log : yarn run v1.22.10 $ electron-builder • electron-builder version=22.9.1 os=5.4.0-65-generic • loaded configuration file=/home/mua/Desktop/picty/electron-builder.js • writing effective config file=dist/builder-effective-config.yaml • packaging platform=linux arch=x64 electron=11.1.1 appOutDir=dist/linux-unpacked • building target=snap arch=x64 file=dist/picty_0.7.1_amd64.snap • building target=AppImage arch=x64 file=dist/Picty-0.7.1.AppImage • application Linux category is set to default "Utility" reason=linux.category is not set and cannot map from macOS docs=https://www.electron.build/configuration/linux • application Linux category is set to default "Utility" reason=linux.category is not set and cannot map from macOS docs=https://www.electron.build/configuration/linux ⨯ GitHub Personal Access Token is not set, neither programmatically, nor using env "GH_TOKEN" error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. And here is reference image, regarding log : And here is reference image, regarding setting up the token : |
Install python shout module in windows 10 (python version 3.9) Posted: 16 Apr 2021 07:59 AM PDT I am trying to install python-shout module in windows 10 but it fails. In the ubuntu works well. I tried pip3 install python-shout. Here is the output: c:\Users\Χρήστος\Desktop\python-shout-0.2.7>pip3 install python-shout Collecting python-shout Using cached python-shout-0.2.7.tar.gz (7.7 kB) WARNING: Subprocess output does not appear to be encoded as cp1253 WARNING: Subprocess output does not appear to be encoded as cp1253 WARNING: Subprocess output does not appear to be encoded as cp1253 ERROR: Command errored out with exit status 1: command: 'c:\python\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Χρήστος\\AppData\\Local\\Temp\\pip-install-xdc2nr1v\\python-shout_c43f3ecaee9a425ca058db0270926357\\setup.py'"'"'; __file__='"'"'C:\\Users\\Χρήστος\\AppData\\Local\\Temp\\pip-install-xdc2nr1v\\python-shout_c43f3ecaee9a425ca058db0270926357\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Χρήστος\AppData\Local\Temp\pip-pip-egg-info-_2jr2gjm' cwd: C:\Users\Χρήστος\AppData\Local\Temp\pip-install-xdc2nr1v\python-shout_c43f3ecaee9a425ca058db0270926357\ Complete output (5 lines): '¦ ©η©«\x9e£\x98 ›\x9c¤ \x9cε¤\x98 ©\x9c \x9fβ©\x9e ¤\x98 \x9c¤«¦§ε©\x9c «\x9e¤ ΅\x98\x9f¦¨ ©£β¤\x9e › \x98›¨¦£γ ›ε©΅¦¬. '¦ ©η©«\x9e£\x98 ›\x9c¤ \x9cε¤\x98 ©\x9c \x9fβ©\x9e ¤\x98 \x9c¤«¦§ε©\x9c «\x9e¤ ΅\x98\x9f¦¨ ©£β¤\x9e › \x98›¨¦£γ ›ε©΅¦¬. '¦ ©η©«\x9e£\x98 ›\x9c¤ \x9cε¤\x98 ©\x9c \x9fβ©\x9e ¤\x98 \x9c¤«¦§ε©\x9c «\x9e¤ ΅\x98\x9f¦¨ ©£β¤\x9e › \x98›¨¦£γ ›ε©΅¦¬. Using PKG_CONFIG_PATH=/usr/local/lib/pkgconfig pkg-config and shout-config unavailable, build terminated ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/ee/2e/1806180c4e930dbc249078ee91d9c96ee8994ca418f112cd19e15727b335/python-shout-0.2.7.tar.gz#sha256=ed6bace305689ab93cecd0c51fa607b712e18b01f54ba28a4d3f131d7d36350a (from https://pypi.org/simple/python-shout/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Using cached python-shout-0.2.6.tar.gz (7.2 kB) WARNING: Subprocess output does not appear to be encoded as cp1253 WARNING: Subprocess output does not appear to be encoded as cp1253 WARNING: Subprocess output does not appear to be encoded as cp1253 ERROR: Command errored out with exit status 1: command: 'c:\python\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Χρήστος\\AppData\\Local\\Temp\\pip-install-xdc2nr1v\\python-shout_c3c7f0eab8484c098025a85f056e573a\\setup.py'"'"'; __file__='"'"'C:\\Users\\Χρήστος\\AppData\\Local\\Temp\\pip-install-xdc2nr1v\\python-shout_c3c7f0eab8484c098025a85f056e573a\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Χρήστος\AppData\Local\Temp\pip-pip-egg-info-rsup6pde' cwd: C:\Users\Χρήστος\AppData\Local\Temp\pip-install-xdc2nr1v\python-shout_c3c7f0eab8484c098025a85f056e573a\ Complete output (5 lines): '¦ ©η©«\x9e£\x98 ›\x9c¤ \x9cε¤\x98 ©\x9c \x9fβ©\x9e ¤\x98 \x9c¤«¦§ε©\x9c «\x9e¤ ΅\x98\x9f¦¨ ©£β¤\x9e › \x98›¨¦£γ ›ε©΅¦¬. '¦ ©η©«\x9e£\x98 ›\x9c¤ \x9cε¤\x98 ©\x9c \x9fβ©\x9e ¤\x98 \x9c¤«¦§ε©\x9c «\x9e¤ ΅\x98\x9f¦¨ ©£β¤\x9e › \x98›¨¦£γ ›ε©΅¦¬. '¦ ©η©«\x9e£\x98 ›\x9c¤ \x9cε¤\x98 ©\x9c \x9fβ©\x9e ¤\x98 \x9c¤«¦§ε©\x9c «\x9e¤ ΅\x98\x9f¦¨ ©£β¤\x9e › \x98›¨¦£γ ›ε©΅¦¬. Using PKG_CONFIG_PATH=/usr/local/lib/pkgconfig pkg-config and shout-config unavailable, build terminated ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/4a/d9/a845873d3fbf57cfecfa88e20eae77ef93f1a6bc68d9e092c8e020d96b88/python-shout-0.2.6.tar.gz#sha256=adc94a15bb7ddc62c1f924c7c0e99b56a9a4a56125a25b9f29d7d7cb0371e1d6 (from https://pypi.org/simple/python-shout/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Using cached python-shout-0.2.5.tar.gz (1.9 kB) WARNING: Subprocess output does not appear to be encoded as cp1253 WARNING: Subprocess output does not appear to be encoded as cp1253 WARNING: Subprocess output does not appear to be encoded as cp1253 ERROR: Command errored out with exit status 1: command: 'c:\python\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Χρήστος\\AppData\\Local\\Temp\\pip-install-xdc2nr1v\\python-shout_79cffca7fed9480aa0be88ccaad9e20b\\setup.py'"'"'; __file__='"'"'C:\\Users\\Χρήστος\\AppData\\Local\\Temp\\pip-install-xdc2nr1v\\python-shout_79cffca7fed9480aa0be88ccaad9e20b\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Χρήστος\AppData\Local\Temp\pip-pip-egg-info-pkieo1oy' cwd: C:\Users\Χρήστος\AppData\Local\Temp\pip-install-xdc2nr1v\python-shout_79cffca7fed9480aa0be88ccaad9e20b\ Complete output (5 lines): '¦ ©η©«\x9e£\x98 ›\x9c¤ \x9cε¤\x98 ©\x9c \x9fβ©\x9e ¤\x98 \x9c¤«¦§ε©\x9c «\x9e¤ ΅\x98\x9f¦¨ ©£β¤\x9e › \x98›¨¦£γ ›ε©΅¦¬. '¦ ©η©«\x9e£\x98 ›\x9c¤ \x9cε¤\x98 ©\x9c \x9fβ©\x9e ¤\x98 \x9c¤«¦§ε©\x9c «\x9e¤ ΅\x98\x9f¦¨ ©£β¤\x9e › \x98›¨¦£γ ›ε©΅¦¬. '¦ ©η©«\x9e£\x98 ›\x9c¤ \x9cε¤\x98 ©\x9c \x9fβ©\x9e ¤\x98 \x9c¤«¦§ε©\x9c «\x9e¤ ΅\x98\x9f¦¨ ©£β¤\x9e › \x98›¨¦£γ ›ε©΅¦¬. Using PKG_CONFIG_PATH=/usr/local/lib/pkgconfig pkg-config and shout-config unavailable, build terminated ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/d9/7b/b2bff360a9e0e322a6565abb3ca9f4b84727ac9f2eb61023734a82463829/python-shout-0.2.5.tar.gz#sha256=603f8e52f170acdfd4933cafefb7ddc6d7090b80fda0169ff7a32f9e7cb76207 (from https://pypi.org/simple/python-shout/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Using cached python-shout-0.2.1.tar.gz (15 kB) ERROR: Command errored out with exit status 1: command: 'c:\python\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Χρήστος\\AppData\\Local\\Temp\\pip-install-xdc2nr1v\\python-shout_49dd53bec1a54b5ea0a97e49ddb5fc61\\setup.py'"'"'; __file__='"'"'C:\\Users\\Χρήστος\\AppData\\Local\\Temp\\pip-install-xdc2nr1v\\python-shout_49dd53bec1a54b5ea0a97e49ddb5fc61\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Χρήστος\AppData\Local\Temp\pip-pip-egg-info-insc490a' cwd: C:\Users\Χρήστος\AppData\Local\Temp\pip-install-xdc2nr1v\python-shout_49dd53bec1a54b5ea0a97e49ddb5fc61\ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\Χρήστος\AppData\Local\Temp\pip-install-xdc2nr1v\python-shout_49dd53bec1a54b5ea0a97e49ddb5fc61\setup.py", line 25 print "pkg-config could not find libshout: check PKG_CONFIG_PATH" ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print("pkg-config could not find libshout: check PKG_CONFIG_PATH")? ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/bd/5d/0cbe041f7d82d5859f2e9725c667633eb52c7313ffe6e6f48611d8413740/python-shout-0.2.1.tar.gz#sha256=2bfb5e29e1d9ef15120df8e37794281e9a1c63cd874e6a3dbccb3078b45182f7 (from https://pypi.org/simple/python-shout/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Using cached python-shout-0.2.tar.gz (15 kB) ERROR: Command errored out with exit status 1: command: 'c:\python\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Χρήστος\\AppData\\Local\\Temp\\pip-install-xdc2nr1v\\python-shout_8f386c02d49a4d419a42ac49aa697a46\\setup.py'"'"'; __file__='"'"'C:\\Users\\Χρήστος\\AppData\\Local\\Temp\\pip-install-xdc2nr1v\\python-shout_8f386c02d49a4d419a42ac49aa697a46\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Χρήστος\AppData\Local\Temp\pip-pip-egg-info-5vkgl1o4' cwd: C:\Users\Χρήστος\AppData\Local\Temp\pip-install-xdc2nr1v\python-shout_8f386c02d49a4d419a42ac49aa697a46\ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\Χρήστος\AppData\Local\Temp\pip-install-xdc2nr1v\python-shout_8f386c02d49a4d419a42ac49aa697a46\setup.py", line 25 print "pkg-config could not find libshout: check PKG_CONFIG_PATH" ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print("pkg-config could not find libshout: check PKG_CONFIG_PATH")? ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/2d/81/19fb4df3ccea7d36e7475309551a7f2f729dc0af7144ff801382936b5400/python-shout-0.2.tar.gz#sha256=7b1871104197db787c2c0f7345b09bcec8b23cac7fca2503a2a093b9e83a4d34 (from https://pypi.org/simple/python-shout/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. ERROR: Could not find a version that satisfies the requirement python-shout ERROR: No matching distribution found for python-shout Is there any way to install it? Thanks in advance, Chris Pappas |
How to add a new pandas column whose value depends on if/then of another column? Posted: 16 Apr 2021 07:59 AM PDT I have a dataframe that looks like this: idx group valA valB ----------------------- 0 A 10 5 1 A 22 7 2 B 9 0 3 B 6 1 I want to add a new column 'val' that takes 'valA' if group = 'A' and takes 'valB' if group = 'B'. idx group valA valB val --------------------------- 0 A 10 5 10 1 A 22 7 22 2 B 9 0 0 3 B 6 1 1 How can I do this? |
Regex to split the first from a "/token1/token2/token3" Posted: 16 Apr 2021 07:59 AM PDT I'm pretty rusty with regex, but I have the requirement to extract the first token of the following string: Input: /token1/token2/token3 Required output: /token1 I have tried: List<String> connectorPath = Splitter.on("^[/\\w+]+") .trimResults() .splitToList(actionPath); Doesn't work for me, any ideas? |
I used the command (code. -r) in the cmd window, but what does -r mean? (vscode) Posted: 16 Apr 2021 07:59 AM PDT While watching the YouTube development video, I used the command (code . -r ) in the cmd window in vscode. What is this function? vscode turned on, but what does -r mean? |
Strings aren't being written to new file Posted: 16 Apr 2021 07:59 AM PDT I have a list of JSON objects stored as a text file, one JSON object per line (total size is 30 GB), and what I'm trying to do is extract elements from those objects and store them in a new list. Here is my code to do that print("Extracting fingerprints...") start = time.time() for jsonObj in open('ctl_records_sample.jsonlines'): temp_dict = {} temp_dict = json.loads(jsonObj) finger = temp_dict['data']['leaf_cert']['fingerprint'] with open("fingerprints.txt", "w") as f: f.write(finger+"\n") finger = "" end = time.time() print("Fingerprint extraction finished in" + str(end-start) +"s") Basically, I'm trying to go line-by-line of the original file and write that line's "fingerprint" to the new text file. However, after letting the code run for several seconds, I open up fingerprints.txt and see that only one fingerprint has been written to the file. Any idea what could be happening? |
The type or namespace name 'Optimization' does not exist in the namespace Posted: 16 Apr 2021 07:59 AM PDT I am running into an issue where The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' when it was already installed(I checked Nuget Package Manager) What I have tried: 1: Directly copy dll to the Bin folder because I notice it was missing. This did not work. 2: Uninstall and re-install it from Nuget Package Manager, after that, the same error still exist. On top of that, I got a new error The pre-application start initialization method Start on type System.Web.Optimization.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.. Package Version: 1.1.3 It is a WebForm Project, not MVC(there are many posts have solutions that's unique to MVC, so it is not applicable in my case) I have installed both packages with the highest stable version, so I am not sure why Infrastructure is yelling at me. |
How to go to another page by clicking on a row of a html-table? Posted: 16 Apr 2021 07:59 AM PDT I have a MVC-application. I want to go to the DetailInfo page by clicking on the row of the Index page. How do you do that? Part of Index.cshtml @for (var item = 0; item < Model.Count; item++) { <tbody> <tr @@click="detailInfo(@Model[item].Id)"> <td>@Html.DisplayFor(Model => Model[item].Message)</td> logmessages.js const app = Vue.createApp({ // data, functions methods: { rowClick(item) { console.log('Dit is regel: ' + item) }, detailInfo(id) { $.ajax({ type: "POST", url: '<% = Url.Action("DetailInfo", "Home") %>', data: { id = id }, succes: function (data) { console.log(id + "is posted."); } }) }, } }) app.mount('#app') ... and in the HomeController [HttpPost] public IActionResult DetailInfo(int id) { var dto = _logboekService.GetLogBerichtById(id); var model = _mapper.Map<LogBerichtDto, LogBerichtModel>(dto); return View(model); } |
Shuffle Array of object in Reactjs [duplicate] Posted: 16 Apr 2021 07:59 AM PDT why the deck is not getting re-rendered when shuffeling happens on button click.Every time I click on shuffle button the deck is displayed as it is instead of shuffled one. const Deck = () => { const [deck , newDeck] = useState(Card) return ( <div> {console.log(deck)} <h2>Deck</h2> <Button type="button" onClick={() =>{newDeck(deck.sort(() => Math.random() - 0.5));}}>Shuffle</Button> {deck.map((card) => ( <p key={Math.random()}>{card.value} of {card.type}</p> ))} </div> ); } export default Deck; |
Find element in Java HashMap<String, String[]> Posted: 16 Apr 2021 07:59 AM PDT I'm having trouble to find an element inside my String array contained inside my HashMap. I have a String that is indeed inside this String[] but doing the following does not work. if (groupOuMap.containsValue("someString")) { groupOu = "someString"; } My goal is to find the corresponding key of my HashMap where the value is found. Exemple with a sample of my map : nedcard.nl -> ["Wijchen account"] mic.ad -> ["Ayutthaya4", "Brazil", "Changi", "Dresden", "Guangzhou"] If I search for the String Brazil , I'd like to have a new Array of String which would be : String[] groupOu = {"mic.ad", "Brazil"}; I have tried to used groupOuMap.values().contains() as well with no success. Am I doing this wrong? Thank you! |
MySQL optimizer not using the best index? Posted: 16 Apr 2021 07:59 AM PDT We have an EAV data model, and adding more than 3 conditions on joined columns causes the query to go from 0.3 seconds to 65+ seconds. The cause appears to be because mysql's optimizer starts using non-optimal indexes, and I want to understand why. The query in question is the following... select e1.RecordID as _id, v1.Value, v2.Value, v3.Value, v4.Value, v5.Value, v6.Value, v7.Value, v8.Value, v9.Value, v10.Value, v11.Value, v12.Value from Record e1 left join TextValue as v1 on (e1.RecordID = v1.RecordID and v1.PropertyID = 1189) left join TextValue as v2 on (e1.RecordID = v2.RecordID and v2.PropertyID = 1190) left join Record as e2 on e2.RecordID = v1.Value left join TextValue as v3 on (v3.RecordID = e2.RecordID and v3.PropertyID = 507) left join TextValue as v4 on (v4.RecordID = e2.RecordID and v4.PropertyID = 522) left join TextValue as v5 on (v5.RecordID = e2.RecordID and v5.PropertyID = 558) left join TextValue as v6 on (v6.RecordID = e2.RecordID and v6.PropertyID = 516) left join TextValue as v7 on (v7.RecordID = e2.RecordID and v7.PropertyID = 518) left join TextValue as v8 on (v8.RecordID = e2.RecordID and v8.PropertyID = 1384) left join TextValue as v9 on (v9.RecordID = e2.RecordID and v9.PropertyID = 659) left join TextValue as v10 on (v10.RecordID = e2.RecordID and v10.PropertyID = 519) left join TextValue as v11 on (v11.RecordID = e2.RecordID and v11.PropertyID = 1614) left join Record as e3 on e3.RecordID = v9.Value left join TextValue as v12 on (v12.RecordID = e3.RecordID and v12.PropertyID = 661) where e1.RecordTypeID = 154 and v2.Value = 'asdfgh' and v5.Value = 'sdfghj' and v10.Value = 'dfghjk' and v11.Value = 'fghjkl' The TextValue table looks like the following. CREATE TABLE `textvalue` ( `TextValueID` int(11) NOT NULL AUTO_INCREMENT, `UID` varchar(64) NOT NULL, `PropertyID` int(11) NOT NULL, `RecordID` int(11) NOT NULL, `Value` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, PRIMARY KEY (`TextValueID`), UNIQUE KEY `UID` (`UID`), UNIQUE KEY `idx_textvalue_RecordID_PropertyID` (`RecordID`,`PropertyID`), KEY `IX_TextValue_PropertyID` (`PropertyID`) ) ENGINE=InnoDB AUTO_INCREMENT=2326526 DEFAULT CHARSET=latin1 The execution plan for the query looks like such and executing the query took 65 seconds. Note the index chosen for the v11 table... HOWEVER if I change all of the TextValue joins to left Join Textvalue as X FORCE INDEX (idx_textvalue_RecordID_PropertyID) I get the following execution plan and the query takes 0.1-0.3 seconds... What's going on here that would explain why the mysql optimizer chooses to use the IX_TextValue_PropertyID index when the idx_textvalue_RecordID_PropertyID index is clearly better in this scenario? |
What's the best way to sort MAP<String, Object> by value in Dart programming? Posted: 16 Apr 2021 08:00 AM PDT I'm new to dart programming, I came from a Javascript environment everything is fresh to me and I really have no Idea how this sorting works in dart. Here's an example from my API List example = [ {"id": "1", "age": "20"}, {"id": "2", "age": "21"}, {"id": "3", "age": "22"}, ] Before I will assign "example" to other variables eg. var example2 = example; I want to sort it by "age", I found libs and other "LONG" solutions out there but feels like there's another way.. Thanks in advance! |
Opacity value displayed as string instead of number Posted: 16 Apr 2021 08:00 AM PDT I have a simple opacity slider using react hooks which looks like this I am setting opacity in a table like this <td> <img src="link" opacity={data.socialOpacity} } /> </td> But when I run my app the opacity in DOM shows as a string like this <img src="https://wp-iframe.icon.webp" color="#000" opacity="1"> Why the opacity value displays as a string and not a number? |
How might I build a negative attribute selector in CSS? Posted: 16 Apr 2021 07:59 AM PDT I am experimenting (might be foolhardy) with reproducing in CSS what Douglas Crockford refers to as a bottom value. What's a bottom value? In Javascript, bottom values are undefined and null . I can take a custom-data attribute: data-my-custom-attribute="" and I can give it a value of null (using Unicode U+2400 ): data-my-custom-attribute="␀" In CSS, I can then reference any custom-data attribute which is null: [data-my-custom-attribute="␀"] { [... CSS PROPERTIES HERE...] } Next up, I'd like to deploy an equivalent to this Javascript: if (myCustomAttribute !== null) { ... } But it seems I can't reference any custom-data which isn't null, because something like this: [data-my-custom-attribute!="␀"] { [... CSS PROPERTIES HERE...] } doesn't work and isn't valid. Having established that: [data-my-custom-attribute!="␀"] doesn't work, it occurs to me that: [data-my-custom-attribute]:not([data-my-custom-attribute="␀"]) actually does work (and if nothing else comes up, I'll stick with that). Working Example: div { display: inline-block; width: 100px; height: 100px; margin-right: 12px; } .rectangle { display: block; width: 450px; height: 60px; margin-top: 12px; background-color: orange; } [data-my-custom-attribute="red"] { background-color: red; } [data-my-custom-attribute="yellow"] { background-color: yellow; } [data-my-custom-attribute="blue"] { background-color: blue; } [data-my-custom-attribute="␀"] { border-radius: 0; background-color: black; } [data-my-custom-attribute]:not([data-my-custom-attribute="␀"]) { border-radius: 50%; } <div data-my-custom-attribute="red"></div> <div data-my-custom-attribute="yellow"></div> <div data-my-custom-attribute="blue"></div> <div data-my-custom-attribute="␀"></div> <div class="rectangle"></div> However, [data-my-custom-attribute]:not([data-my-custom-attribute="␀"]) feels awkward and verbose. Is there really nothing better? |
Bus stops and routes algorithm Posted: 16 Apr 2021 07:59 AM PDT I'm building a mobile app for my country that includes bus stops and route information. All data is stored in three JSON files and fetch to run the program. - Stop data (JSON file) array of values (int: id, String: name, double: latitude, double: longitude)
- The route data (JSON file) is an array of values (int: id, String: name)
- Communication data (JSON file) array of values (int: stop_id, int: route_id, int: seq, bool: turn)
seq - sequence. That defines what is the sequence of the bus stop is. turn - if it's true , way of starting. Or it's ending (turning back to the start point). Now I'm showing all the stops on the map using markers. And showing route data when clicks the stops . What I want is: - User will select two points on the map. (We should find the routes with it)
- Show up to 3 switching routes. And where (bus stop) the user switching a bus.
Using dart, run a few for loops and a few if statements. It took twenty minutes to find the routes. It took twenty minutes to find the routes. The app didn't respond, didn't crash, but still worked. I can develop NodeJS and MySQL servers. But the question is how to find the routes faster. The output I want: [ { "id": 1, "routes": [ { "id": 1, "name": "Lorem ipsum", "stops": [ {"id": 1, "name": "Sit amet"}, {"id": 2, "name": "Dolor um"} ] }, { "id": 3, "name": "Lorem ipsum", "stops": [ {"id": 2, "name": "Dolor um"}, // It is a bus switching point {"id": 4, "name": "Alog mal"} ] } ... ] } ... ] |
How to apply a given directive value to multiple tags in Angular Material? Posted: 16 Apr 2021 07:59 AM PDT I have recently started learning Angular and Material and in my project I realized, that I have to create forms with the same appearance. For instance the registration form's template looks like this: <mat-card> <h2>{{'NAV.REGISTRATION' | translate}}</h2> <form [formGroup]="registrationForm" (ngSubmit)="submitRegistrationForm()"> <div> <mat-form-field appearance="outline"> <input matInput formControlName="fullName" placeholder="{{'REGISTRATION.NAME' | translate}} *"> </mat-form-field> <mat-form-field appearance="outline"> <input matInput formControlName="password" placeholder="{{'REGISTRATION.PASSWORD' | translate}} *" type="password"> </mat-form-field> ... I would like to apply appearance="outline" to all the <mat-form-field> tags in the template. I have tried applying <div class="mat-form-field-appearance-outline"> , but of course it causes the <div> element to appear with the styles, not its children. Also, I can not just simply write mat-form-field{ appearance: outline; } in the template's .scss file. So, in conclusion, in what ways I can apply a Material directive value to a custom set of tags without repeating it in the template? |
Playing music with c++ Posted: 16 Apr 2021 07:59 AM PDT I'm trying to play a song while my program runs, but the issue in here is that when I run the .exe, the only thing that I can hear is the windows default "You messed up something" sound, I already added the '-lwinmm'in the "Linker settings", I'm using CodeBlocks 20.03, hope you can help me out. Here's the code: #include <iostream> #include <conio.h> #include <windows.h> #include <MMsystem.h> using namespace std; void gotoxy(int x, int y) { HANDLE hCon; hCon = GetStdHandle(STD_OUTPUT_HANDLE); COORD dwPos; dwPos.X = x; dwPos.Y = y; SetConsoleCursorPosition(hCon, dwPos); } void hideCursor() { HANDLE hCon; hCon = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_CURSOR_INFO cci; cci.dwSize = 2; cci.bVisible = FALSE; SetConsoleCursorInfo(hCon, &cci); } int main() { PlaySound("J:\\Proyecto\\Juego\\Music\\3.WAV", NULL, SND_ASYNC); //PlaySoundA((LPCSTR) "J:\\Proyecto\\Juego\\Music\\3.WAV", NULL, SND_FILENAME | SND_ASYNC); getch(); hideCursor(); int x = 0; int y = 0; char r = 'a'; gotoxy(x, y); printf("*"); while (r != '.' || r != '.') { //PlaySoundA(TEXT("J:\\Proyecto\\Juego\\Music\\3.WAV"),NULL,SND_SYNC); if (kbhit()) { r = getch(); gotoxy(x, y); printf(" "); if (r == 'w' || r == 72) y--; if (r == 'a' || r == 75) x--; if (r == 's' || r == 80) y++; if (r == 'd' || r == 77) x++; gotoxy(x, y); printf("*"); } } } |
Add Schema to Body in Firebase Rest API Posted: 16 Apr 2021 08:00 AM PDT I have created an API using firebase function, It is a POST API which takes the body values and add them, Here is the code const functions = require('firebase-functions'); const express = require('express'); const cors = require('cors'); const app = express(); app.use(cors({ origin: true })); let myMiddleware = (req, res, next) => { next(); } app.use(myMiddleware); app.get('/', (req, res) => { let response = "Server deployed successfully "; res.send(response); }); app.post('/add', (req, res) => { let num1 = req.body.num1; let num2 = req.body.num1; let response = num1 + num2 res.send(response); }); // Expose Express API as a single Cloud Function: exports.endpoints = functions.https.onRequest(app); When I send the body (number 1, and number 2) in string it is giving me a response by adding two strings, But I want to add them like numbers, How can I give schema to num1 and num2 in order to accept numbers not strings |
CA2101: Specify marshaling for P-Invoke string arguments Posted: 16 Apr 2021 07:59 AM PDT I am trying to expose a C function which takes a UTF-8 string to C# (dotnet 5.0). I am getting a warning which does not make sense to me. Here is a simple way to reproduce it, using fopen(3): [DllImport("libc.so.6", CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr fopen([MarshalAs(UnmanagedType.LPUTF8Str)] string pathname, string mode); Visual Studio 2019 is reporting a warning: From the documentation, it seems I need to set CharSet.Ansi in my case: and use UnmanagedType.LPUTF8Str : What did I misunderstood from the documentation ? |
Are global indexes used when inserting directly into partition? Posted: 16 Apr 2021 07:59 AM PDT In Oracle 12c 12.1, when inserting directly into a specific partition, are any global unique indexes I have across multiple partitions on the same table still used? Will the uniqueness constraint continue to be maintained across partitions? If not, what is the benefit of having the global index in the first place? |
calculate triangle shade from angle between normal and camera vector Posted: 16 Apr 2021 07:59 AM PDT I am currently trying to better understand 3d graphics. My goal is to get a value between 0 and 255 to shade a triangle. I have 2 vectors (as tuples): the normal of a triangle and the camera vector. I can calculate the angle between them with: def calcAngleBetweenVectors(v1, v2): return math.acos(dot(v1, v2) / (calcVectorMagnitude(v1) * calcVectorMagnitude(v2))) * 180 / math.pi def dot(v1, v2): # Dotproduct return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2] def calcVectorMagnitude(v): return math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]) eg.: print(calcAngleBetweenVectors((10, 15, 0), (1, 2, 3))) How can I go from the angle to a grayscale value? I have tried several things like: angle / 180 * 255 But that doesn't seam to work. I use Python, but all help is welcome. |
Update Tkinter progressbar from function called (by button click), function is in separate document Posted: 16 Apr 2021 07:59 AM PDT I am trying to update progressbar in tkinter. First of i have two documents. document 1: conatins GUI document 2: Contains functions, that are called when pressing the button widgets attached to the GUI. When i perform a calculation within document 2 i want to update the progress bar which is in document 1. An exaple of the code is as follows. (just to mention, this is my first script in python, so please correct me if im wrong in any of the coding) #Document 1 from Document2 import * import tkinter as tk from tkinter import * from tkinter import messagebox from tkinter import ttk from tkinter import font as tkfont # python 3 from PIL import ImageTk, Image from tkinter.ttk import Progressbar class kLARTilProjekteringApp(tk.Tk): def __init__(self, *args, **kwargs): tk.Tk.__init__(self, *args, **kwargs) tk.Tk.resizable(self, width=False, height=False) tk.Tk.title(self, "kLAR til projektering 1.0") tk.Tk.iconbitmap(self, filepath_kLAR_icon) tk.Tk.geometry(self, "465x262") #self.title_font = tkfont.Font(family='Helvetica', size=18, weight="bold", slant="italic") # the container is where we'll stack a bunch of frames # on top of each other, then the one we want visible # will be raised above the others container = tk.Frame(self) container.pack(side="top", fill="both", expand=True) container.grid_rowconfigure(0, weight=1) container.grid_columnconfigure(0, weight=1) self.frames = {} for F in (ProjectingPage): page_name = F.__name__ frame = F(parent=container, controller=self) self.frames[page_name] = frame # put all of the pages in the same location; # the one on the top of the stacking order # will be the one that is visible. frame.grid(row=0, column=0, sticky="nsew") self.show_frame("ProjectingPage") def show_frame(self, page_name): '''Show a frame for the given page name''' frame = self.frames[page_name] frame.tkraise() class ProjectingPage(tk.Frame): def __init__(self, parent, controller): tk.Frame.__init__(self, parent, bg=bg_color) self.controller = controller Button_get_TK = Button(self, text="Indsæt terrænkote", font=("Calibri", btn_font_size, "normal"), width=std_button_width, bg=bg_color_button, fg=fg_color_button, borderwidth=size_border_width, activebackground=act_bg, command=Get_TK) Button_get_TK.place(x=12, y=166) Button_get_TK.update() self.progress = Progressbar(self, orient = HORIZONTAL, length = 100, mode = 'determinate') self.progress.pack() def UpdateProgressBar(self, data): self.progress.start() self.progress.update_idletasks() and #Document 2 import Document1 as KTP from Document1 import * def Get_TK(): for i in range(0,100): test_progressbar = KTP.ProjectingPage test_progressbar.UpdateProgressBar(i) I have trimmed down my code to just the relevant part. I need to know the principals of getting my progressbar to update by calling a function from a separate document. I really hope someone can help me. thanks in advance :-) |
Best way to save data structure in Electron app Posted: 16 Apr 2021 07:59 AM PDT I am building an app using Electron. In this app, I am building a data structure using JSON or an simple object. My data structure looks like this: { items: [ { id:1, name:'football' }, { id:2, name:'soccer ball' }, { id:3, name:'basketball' } ] } I want to save this JSON or object because I want to load the data the next time the application starts. Now the question is if I use LocalForage.js and users remove thier browser's data, will the saved data of my application be removed too? or I can be sure the saved data in my app persist for ever...? Note: LocalForage.js wraps indexedDB for local storage in browsers and if user clears the browser's data all the data will be removed. |
React How Can I pass Index outsite of map fuction? Posted: 16 Apr 2021 07:59 AM PDT just working on the carousel. Just trying to disable the button when it ends. disabled={ index === 0 } does not working because out of map scope. Thank you for the help. <Carousel settings={ settings } ref={ ref }> {slides.map((el, index) => ( <SlideGallery key={ index }> <SlideItems style={{ background: el.imgUrl }}> <picture><img src={ el.imgUrl } alt=''></img></picture> <SlideInner> <h3>{el.review}</h3> <p></p> <p>UserName</p> </SlideInner> </SlideItems> </SlideGallery> ))} </Carousel> <ButtonWrapper> <PrevButton onClick={ prevSlide } disabled={ index === 0 }><ChevronLeft/></PrevButton> <NextButton onClick={ nextSlide }><ChevronRigt/></NextButton> </ButtonWrapper> |
Firestore write to document invalid type errors for numpy Posted: 16 Apr 2021 07:59 AM PDT I have a dictionary with over 1000 fields that I'm trying to write to Firestore as a document. However, I keep getting invalid type errors like below: 'Cannot convert to a Firestore Value', 3, 'Invalid type', <class 'numpy.int64'> 'Cannot convert to a Firestore Value', False, 'Invalid type', <class 'numpy.bool_'> Most of my fields are of these numpy types. I'm new to Firestore so I'm not sure if I missing something simple or If I have to convert all my fields? Does the Firestore python library not allow numpy types? I have multiple nested dictionaries within the main dictionary so it won't be easy to convert everything to different types. Here is the python code I'm using to write to Firestore: firestore_db.collection("collection_name").document("doc_name").set(allVarsDict) Here is a sample of the dictionary: { 'price_date': '2020-08-22 00:00:00', 'time_ms': 1598054400000, 'price1min': 11526.32, 'price_open1min': 11529.99, 'volume1min': 12.75662516, 'price': 11526.32, 'price1min_dict': { 'price_date': '2020-08-22 00:00:00', 'ms': 1598054400000, '50ma': 11525.190199999994, '128ma': 11547.188046874997, '200ma': 11569.5485, '200ema': 11552.031164880687, 'heightPer': 0.0013139635732870457, 'pinbarPer': 0.24224422442245286, 'hammer': True, 'star': False, 'green': False, 'pinbar': True, 'height': True, 'rsi': 49.58870472682622, 'Mflow': -3.0986389827593954, 'cmf': -0.39267912421581946, 'obv': 12.09637204, 'stoch': 85.27999999999884, }, Thanks for any help! |
Setup multiple .env configurations (React/Next/Node) Posted: 16 Apr 2021 08:00 AM PDT How to use multiple .env config files correctly for development / stage / production. I realize I need a .env file, use dotenv (at least), but when I start hosting my app (React), I use localhost: 5000 urls, but I have to use some service-host urls which I use. |
No comments:
Post a Comment