build tuple from regex

Uncategorized
Question: I have a group of regexes and I have to map their capture groups to function arguments. It seems to me that the easiest thing would be to build a tuple from the regexes capture groups and use std::apply with that. So I am trying to get a template to convert the regex into a tuple, but I am not getting it to work. Below is what I have. I tried specializing the recursion, but it seems like there is no way to specialize a function template. I am fairly new to templating, so any help is welcome =) template string get_value(std::smatch& rx) { return rx[i]; } template auto tuple_from_rx(std::smatch& rx) { if (i > 0) { return std::tuple_cat(tuple_from_rx(rx), get_value(rx)); } else { return std::tuple(); } } Answer: Read…
Read More

Moving SKSpriteNode to location of the touch

Uncategorized
Question: Above is an image of my game. A top-down game. Wherever on the screen the player touches, I want the bullets to go to that location with a duration. I also want the player to be able to drag around his finger on the screen, and the same thing happens. So that the player doesn't have to touch the screen everytime he wants to shoot. I've tried some different stuff so far but nothing seems to work. First off, I dont know if I should have a separate function for the bullet. But anyway, this is my bullet function. func spawnBullets() { let bullet = SKSpriteNode(imageNamed: "Bullet") bullet.name = "Bullet" bullet.zPosition = 4 bullet.position = CGPoint(x: player.position.x + 19, y: player.position.y) self.addChild(bullet) } I also have a "timer" for…
Read More

SiriKit INSendMessageIntent skip confirm delegate

Uncategorized
Question: I've been working on SiriKit for a while, and the result of my demo was not satisfied by my boss. By reading all the Apple documents & did my best to search online, I still can't find a way to skip the confirm step in SendMessageIntent! This is my purpose: After resolving user comments to Siri, func resolveContent(forSendMessage intent: INSendMessageIntent, with completion: @escaping (INStringResolutionResult) -> Void) { if let text = intent.content, !text.isEmpty { if text == "Login with Touch ID" { completion(INStringResolutionResult.success(with: text)) } else if text == "Change password"{ completion(INStringResolutionResult.success(with: text)) } completion(INStringResolutionResult.disambiguation(with: ["Login with Touch ID", "Change password"])) } else { completion(INStringResolutionResult.disambiguation(with: ["Login with Touch ID", "Change password"])) } } Skip this step "confirm", func confirm(sendMessage intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void) { // Verify…
Read More

Jquery/JS Show dynamic checkbox input group title if at least one or more are checked and vice versa

Uncategorized
Question: I want to show input group title if at least one checkbox is checked, and hide title if no checkboxes checked. Each group has his own title and data-value. There may be 5+ input groups. Here is the codepen: [Example code here][1] [1]: https://codepen.io/anon/pen/JyrQgW $(document).ready(function(){ }); .output { margin-top:45px; } group1 item1 item2 item3 item4 group2 item1 item2 item3 item4 HERE SHOW TITLES enter code here At the end, I'm not so good with JS/Jquery but I was trying to make it work for a few hours and have a feeling that I go very deep but there is a 2 line solution. Thanks for help Answer: I this what you are looking for? $(document).ready(function() { check() }); $("input[type=checkbox]").change(function() { check() }) function check() { $(".group-block").each(function() { $(this).find(".group-title").css("display", $(this).find("input[type=checkbox]:checked").length…
Read More

Chrome extension function from bootstrap library not defined? (Do I need to ‘inject’ it?)

Uncategorized
Question: It seems like I can't access the .popover method inside my script. Unless I screwed up, I should have access to that method from the Bootstrap Native (Jquery-free Bootstrap) file included.(?) What the script does is add links and ideally a popover on that element. Here is my code: Manifest: { "name": "foo", "description": "Work in Progress", "manifest_version": 2, "version": "0.8", "icons": { "16": "icon16.png", "48": "icon48.png", "128": "icon128.png" }, "permissions": [ "activeTab", "http://*/", "https://*/" ], "background": { "scripts": ["background.js"], "persistent": false }, "browser_action": { "default_title": "Click me!" } } Background: (runs on icon click) chrome.browserAction.onClicked.addListener(function(tab) { chrome.tabs.executeScript(tab.id, {file: "bootstrap-native.js" }, function() { chrome.tabs.executeScript(tab.id, {file: "content_script.js"}); }); }); content_script.js: // Handle page's frame (to allow DOM access) var page = top.frames["TargetContent"].document; // Reference every professor listed and modify the…
Read More

Linux tool to detect buffer overflows on shared memory

Uncategorized
Question: I am currently using Valgrind to check for memory leaks and memory corruption on dynamic memory and AddressSanitizer for memory corruption on stack memory. But those tools are not finding memory corruptions on shared memory. Is there a good tool for this purpose ? I am programing in C++ and I have control over the compilation process of the executable that is creating the SHM segment and the executables that are reading and writing on it. Thanks Answer: There is so many ways you can do different things in C and C++, which may or may not violate some memory allocation, or similar. There may be a tool out there that can catch X, Y or Z, but not W, V or U or the rest of the alphabet.…
Read More

Alternative to GetAsyncKeyState on linux

Uncategorized
Question: lately I've been struggling with finding alternative to 'GetAsyncKeyState' on linux... here is my code:bool key_pressed(char key) { #ifdef _WIN32 if(GetAsyncKeyState(key) & 0x8000) { return 1; } else { return 0; } #endif #ifdef __linux__ //What to add Here// #endif } i searched the web and all i can find is using librarys and couldn't understand it... can someone give an example? Answer: Read more
Read More