• Content count

  • Joined

  • Last visited

Community Reputation

10853 Excellent

About fastcall22

  • Rank
    Web Developer

Personal Information

  • Interests

Recent Profile Visitors

26241 profile views
  1. Oh boy, it’s that time of year again where all of my terminal settings get reset! Thanks, Windows 10 Fall Creators Update! But this time, I’m prepared !! I’ve made some adjustments to my previous attempt to Unify Windows 10 Terminal Settings. Namely, I’ve fixed the ACL not working as expected. Apparently `set-acl` attempts to reset the owner, which is denied when also removing the write permission. Additionally, the ACL needs to be reloaded in order to get the correct converted ACLs from the item’s parents. The workaround is as follows: # deny current user write permissions $item = get-item $path; $acl = $item.GetAccessControl('access'); # $acl.SetAccessRuleProtection($true, $true); # Disable inheritance, assume inherited $item.SetAccessControl($acl); $acl = $item.GetAccessControl('access'); # Reload ACL to obtain inherited permissions $acl.RemoveAccessRuleAll($rule); # Remove existing rules for the user $acl.AddAccessRule($rule); $item.SetAccessControl($acl); I’ve also added back in the registry fix: $console = (get-item HKCU:\).OpenSubKey("Console", $true) $console.GetSubKeyNames() |% { if ( $pscmdlet.ShouldProcess($_, "Remove Subkey") ) { $console.DeleteSubKey($_); } And after running: remove-consoleprops -StartMenu -AdjustPermissions -Registry -ErrorAction Continue … I was pleased to see that it worked as expected! I will be working toward publishing these scripts as a GitHub gist, so these files are versioned and others can contribute. That’s all for now. Thanks for reading; see you around! :^)
  2. "Windows protected your PC"

    You will need to sign your installers and executables. See also: How do I change "Verified Publisher: Unknown" to "Verified Publisher: [My Name Goes Here]" in the UAC popup.
  3. Encode LUA

    The attached file (since removed) is Lua bytecode, not encrypted source code. That being said, does not encourage reverse engineering. If the game has a plugin system, then it should also have documentation to interface with it.
  4. How to protect yourself and your game?

    Let’s not post knee–jerk reactions here. K, thanks.
  5. Any advice?

    You’re missing the surrounding class :^) using System; public class ExampleComponent { public Vector3 ... public void Start() { // ... } }
  6. google map don´t work

  7. select value with angular problem

    `option[ng-repeat="x in name"]`, but you use use `$` and `$scope.names` in your controller. Which is it?
  8. Hello again! It’s been a while since my last post. I was playing around with color themes for PuTTY and the Windows Terminal, and I thought I’d share some of my recent findings on unifying the terminal experience in Windows. This is a continuation of a previous post I wrote some time ago. The previous post unfortunately did not survive the upgrade. I’ll detail how I have been iterating color palettes in a future post. Unifying Windows 10 Terminal Settings I spend most of my time at work and at home inside a terminal. I was very excited to use the new Windows 10’s terminal. It gave me reason to customize my terminal experience to match my workflow. Unfortunately, this is apparently difficult. It became apparent that over time, I could not reliably expect a certain look or behavior whenever I opened any terminal window. Programs would install and use their own shortcuts with their their own defaults. Windows updates would clear out my user defined settings. Launching the same program in a different way would launch an older version of my settings. If I wanted to adjust these settings, I would have to hunt down and apply the change to every shortcut, every subkey. This is absolutely unacceptable. And so, I set off to answer the question: How could I configure Windows to use only one set of settings? I believe I have this mostly worked out, but it’s not perfect. Let’s begin. About the Terminal Settings in Windows The Windows terminal settings can be stored in a number of different places, which makes unifying them all a huge pain. Understanding Windows Console Host Settings explains in great detail how this works. Here’s a quick rundown of where these settings are stored: HKCU:\Console, the default console settings. These can be accessed from the “defaults” menu item from any terminal’s application menu. HKCU:\Console\*, per–executable overrides using the executable path as subkey. If the terminal was launched from the run dialog, then these settings can be changed from the “properties” menu item from the terminal’s application menu. Shortcut files (*.lnk), where each shortcut may have an embedded `CONSOLE_PROPS` data block with its own terminal settings. If the terminal was launched from a shortcut, then these settings can be changed from the “properties” menu item from the terminal’s application menu. These settings can also be changed from the shortcut’s file properties dialog. The good news is that according to the article, Microsoft plans to release a tool to manage console settings in the future. Until then, this can be used to fix the settings in the meantime. Now, on to unifying all the settings. I advise to proceed with caution as making permission changes may cause unexpected errors. Make backups of your registry settings and shortcuts before proceeding and proceed at your own risk. Normalizing All the Terminal Settings The items listed above describe where we can find terminal settings, and with them we can apply a fix and write rules to prevent them from diverging in the future: Deleting the subkeys and denying your Windows user the ability to create keys in `HKCU:\Console`. This will prevent terminal programs launched from the run dialog from diverging from the master terminal settings. Removing the `CONSOLE_PROPS` from shortcut files. This causes those programs to use the default settings in `HKCU:\Console`, but inspecting the fonts/colors tab on the shortcut’s properties causes them to be re–added. Denying your Windows User write access to shortcut files prevents `CONSOLE_PROPS` from being re–added. Disabling Registry–Level Settings Removing the console subkeys is easy, but preventing them from being created in the future is a little trickier. This can be done by denying the “Create Subkey” permission on `HKCU:\Console`. Note: This may break some installers that expect to create a subkey here. On the advanced security settings for `HKCU:\Console` properties, disable inheritance. Add a permission entry for your Windows user that allows all advanced permissions except “Create subkey”. Add a permission entry for your Windows user that denies “Create subkey”. Check your Windows user on “Effective Access” and confirm that your Windows user cannot create a subkey. Check the “Administrator” user on the effective access tab and confirm that administrators can create subkeys. The MSDN blog post mentions that launching a terminal from the run dialog should use the registry to store its settings, but I haven’t been able to reproduce. It is possible that the permission step is not needed. Disabling Shortcut–Level Settings This is the hard part. First, a bit about how shortcuts are indexed. Windows Search uses a few locations to source your Start Menu: %APPDATA%\Microsoft\Windows\Start Menu %APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu C:\ProgramData\Microsoft\Windows\Start Menu The shortcuts presented in the start menu are grouped by their `Target` shortcut property. If the search index or task bar found more than one shortcut with the same `Target`, then the first is selected, possibly in the order specified above. If they differ, then you will see two entries in your start menu or your task bar. The comparison is case-insensitive with variables unexpanded: `%SYSTEMROOT%\example.exe` is different from `C:\WINDOWS\example.exe`, and `C:\WINDOWS\example.exe` is the same as `C:\windows\example.exe`. All of them are different from `C:\Windows\sample.exe /ABC`. Unlike the start menu, the shortcuts in the task bar are grouped by their `Target` property without arguments and with environment variables expanded. My previous post recommended denying all authenticated users write access to the shortcut, which caused the indexer to skip the shortcut entirely after grouping, effectively removing the shortcut from your start menu search altogether. In this post, we’ll take a different approach. First, a C# shim to handle COM interactions: # space.wtfbox.win32.ShellLink.cs using System; using System.Runtime.InteropServices; namespace space.wtfbox.win32 { [ ComImport() , InterfaceType(ComInterfaceType.InterfaceIsIUnknown) , Guid("0000010B-0000-0000-C000-000000000046") ] public interface IPersistFile { int GetClassID(out Guid pClassID); [PreserveSig()] int IsDirty(); int Load([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, int dwMode); int Save([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, [MarshalAs(UnmanagedType.Bool)] bool fRemember); int SaveCompleted([MarshalAs(UnmanagedType.LPWStr)] string pszFileName); int GetCurFile(out IntPtr ppszFileName); } [ ComImport() , InterfaceType(ComInterfaceType.InterfaceIsIUnknown) , Guid("45E2B4AE-B1C3-11D0-B92F-00A0C90312E1") ] public interface IShellLinkDataList { void AddDataBlock(IntPtr pDataBlock); [PreserveSig()] int CopyDataBlock(uint dwSig, out IntPtr ppDataBlock); void RemoveDataBlock(uint dwSig); void GetFlags(out int dwFlags); void SetFlags(uint dwFlags); } // custom interface public class ShellLink : IDisposable { public ShellLink(object lnk) { _handle = (IPersistFile)lnk; } public ShellLink(object lnk, string path, int mode) { _handle = (IPersistFile)lnk; Load(path,mode); } public void Dispose() { Marshal.ReleaseComObject(_handle); } public void Load(string path, int mode){ _handle.Load(path, mode); } public void RemoveDataBlock(uint signature) { (_handle as IShellLinkDataList).RemoveDataBlock(signature); } public bool HasDataBlock(uint signature) { IntPtr block; int hResult = (_handle as IShellLinkDataList).CopyDataBlock(signature,out block); if ( hResult != 0 ) { return false; } Marshal.FreeHGlobal(block); return true; } public int Save() { return _handle.Save(null,true); } private IPersistFile _handle; public const uint CONSOLE_PROPS = 0xA0000002; } } And an accompanying PowerShell cmdlet: # [CmdLetBinding(SupportsShouldProcess=$true)] param( [Parameter(Mandatory=$false, ValueFromPipeline=$true)] [IO.FileInfo[]] $InputArray, [switch] $StartMenu, [switch] $AdjustPermissions ) # load dependencies try { [space.wtfbox.win32.ShellLink] | out-null; } catch { write-verbose "Compiling helper assembly"; add-type -TypeDefinition (get-content -raw "$PSScriptRoot\space.wtfbox.win32.ShellLink.cs") | out-null; } # setup parameters if ( $StartMenu -and -not $InputArray.Count ) { $InputArray = ( "$env:appdata\microsoft\windows\start menu", "$env:appdata\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar" ) |% { get-childitem $_ -recurse -include *.lnk; } } if ( -not $InputArray ) { # nothing to do return; } if ( $AdjustPermissions ) { $user = [Security.Principal.WindowsIdentity]::GetCurrent(); $rights = [Security.AccessControl.FileSystemRights]"ReadAndExecute, Synchronize"; $rule = new-object Security.AccessControl.FileSystemAccessRule $user.Name, $rights, "Allow"; } # process shortcuts $ShellLink = [space.wtfbox.win32.ShellLink]; $lnk = new-object $ShellLink (new-object -ComObject lnkfile); try { $InputArray |% { $path = $_.FullName; try { # load and check for CONSOLE_PROPS $lnk.Load($path, 2); if ( -not $lnk.HasDataBlock($ShellLink::CONSOLE_PROPS) ) { return; } # remove CONSOLE_PROPS and save if ( $pscmdlet.ShouldProcess($path, "Remove CONSOLE_PROPS") ) { write-verbose "Removing CONSOLE_PROPS from $path"; $lnk.RemoveDataBlock($ShellLink::CONSOLE_PROPS); $hr = $lnk.Save(); } if ( $AdjustPermissions -and $pscmdlet.ShouldProcess($path, "Adjust permissions") ) { # deny current user write permissions $item = get-item $path; $acl = $item.GetAccessControl('access'); # $acl.SetAccessRuleProtection($true, $true); # Disable inheritance, assume inherited $item.SetAccessControl($acl); $acl = $item.GetAccessControl('access'); # Reload ACL to obtain inherited permissions $acl.RemoveAccessRuleAll($rule); $acl.AddAccessRule($rule); $item.SetAccessControl($acl); } $_; } catch { "Failed to process $($path): $_" | write-error; } } } finally { $lnk.Dispose(); } Then run the command as an administrator: Unify-ConsoleProps -FixRegistry -CommonPaths -AdjustPermissions -Verbose -ErrorAction Inquire Afterwards, all custom settings under `HKCU:\Console` will be removed, all shortcuts will be stripped of their `CONSOLE_PROPS` block, and your Windows user will be denied created them. Every terminal hence forth will be using the settings under `HKCU:\Console` as intended. Conclusion Because this is not perfectly future proof, this will need to be run after a major Windows update or a program is installed with shortcuts having CONSOLE_PROPS embedded. At least this is only needed until Microsoft releases the terminal settings tool. Hopefully that day will come soon.
  9. problem with angularjs

    Then you will need to implement that functionality in your API. This is not an angularjs problem, but an API problem. If you were to change angular to only show one result, then you could only do so by changing the pagination options-- the number of items to show per page. The application would still query the full table, but only show one result. The better approach would be to implement a “get products by user” along side your “get all products” on your API. Generally this is done by adding routes. Routes make the connection between your `switch($_GET['action'])` and your `get_product` function. I will be assuming there is a relationship between users and products, due to your “i want show only the data is of one person”. Then: Add parameters to your `get_products` method and connect it with your route: <?php switch($_GET['action']) { case 'get_product': $user_id = array_key_exists('user_id', $_GET) ? $_GET['user_id'] : null; get_product($user_id); break; Modify the `get_product` SQL query to filter results by the `user_id`, if supplied. Prepared statements make this easy, but its not required: <?php $query = <<< SQL select s.* from servicos s, user_servicos us where us.product_id = and ( :user_id is null or us.user_id = :user_id ) SQL; Configure your angular app to query by `user_id`: $scope.get_product_by_user = function(user_id) { $http.get('app/app.php?action=get_product&user_id='+user_id).success(function(data) { // ...
  10. to_lower function entering an infinite loop

    This thread is a great example of why it is important to write tests. We have at least five different implementations in this thread of `findx`, each with varying levels of “correct”. Automated tests can provide an empirical measure of correctness. And since `findx` is a pure function, we can easily write automated tests to help us. First, a crude testing routine for any `findx` implementation: const char* findx(const char*, const char*); void test_findx() { struct test_t { const char* input; const char* subject; const char* expected; test_t(const char* input, const char* subject, const int pos) { this->input = input; this->subject = subject; this->expected = ( pos == -1 ) ? nullptr : (input + pos); } } tests[] = { test_t("abc", "abc", 0), test_t("abcdef", "abc", 0), test_t("ababac", "abac", 2), test_t("ababac-----", "abac", 2), test_t("abc", "xyz", -1), test_t("abc", "", -1), test_t("", "", 0), test_t("", "a", -1), // ... }; int failed = 0; for ( const auto& test : tests ) { const char* result = findx(test.input, test.subject); if ( result != test.expected ) { failed ++; cerr << "Test #" << (&test - tests) << " failed" << endl; } } return failed; } And running the full example test here: Test #0 failed: "abc" in "abc", expected "abc", got nullptr Test #2 failed: "abac" in "ababac", expected "abac", got nullptr Test #5 failed: "" in "abc", expected nullptr, got "abc" Test #6 failed: "" in "", expected "", got nullptr Failed 4 of 8 tests. ... we can see that there are a few cases we’ve missed. And while we continually fix the implementation, we can think of more corner cases to add to the tests. Testing can go along way in helping you write correct code and can also help you keep your sanity in face of bizarre bugs.
  11. I concur; fixing the warnings is the only course of action. And even more so, you are upgrading from OpenGL 2.0 to 3.0. Because this is such a large undertaking, I recommend upgrading your project and continuing development in parallel branches. Use Visual Studio to fix warnings on one branch, and use Dev-C++ on the other branch. Upgrade and refactor in small sprints on the upgrade branch and continue developing your game on the other. Once the project has been fully upgraded, you can take everything you’ve learned from upgrading and migrate your changes on the other branch into your upgraded branch. (Hopefully you are using some form of version control with those 70k+ lines!) Good luck!
  12. It is possible to use CSS with SVG. I have written about my experiences with SVG and CSS in my blog: Automatically Generating Sprites for a Space Shooter. Depending on the workflow for the SVGs, you might consider using an external sytlesheet over injecting an inline style. In any case, you will need to transform your existing SVGs into ones that use your stylesheet. How you decide to proceed from here again depends on the workflow for the SVGs. If it’s a one–time transformation from hardcoded attributes to CSS styles, then I recommend writing a one–off script to batch process each file, transforming matching attributes of each element to CSS attributes. For example, a minimal proof of concept in PowerShell (untested): ls *.svg |% { [xml]$svg = get-content -raw $_; foreach ( $n in $svg.SelectNodes('//[@fill="#5389A4"]') ) { $n.removeAttribute('fill'); $n.setAttribute('class', 'custom-fill'); } $; }
  13. Rotating source vector to destination vector (2D)

    The dot product of the target vector and the normal of the current vector should result in a positive or negative value. This result will determine whether a counter–clockwise or clockwise rotation should be made. See attached. Current direction vector A and its normal, A' And sample target directions B and C:
  14. Topics for Web Development

    As a professional web developer, I often get asked what’s needed to get started with web development or I’ll find questions relating to web development on the forums. But, I find that it is often difficult to answer succinctly, because a “Hello, World!” web server involves so many different, yet vital pieces. Perhaps I’ll detail them out in a series of articles. Until then, I’ve taken some time to summarize the topics involved in developing a web application: Systems administration. How processes work and communicate, how to add users and groups, how to manage file permissions and/or ACLs, how to set up logging, backups, and automated tasks, how to effectively use a terminal to navigate an operating system, how to setup and configure dependencies and 3rd party software. (Bonus points for having Docker or Vagrant do this for you.) Typically Linux–based systems are used, but does not necessarily exclude Microsoft. Additionally: How to spin up a virtual machine, and manage servers over SSH or RDP. HTTP and web servers. Web servers are the glue between the frontend and the backend, and HTTP is the basis of the communication between them: How web servers work, how to configure them to serve both static and dynamic content, and how to leverage HTTP headers and HTTP response codes appropriately. Web servers: apache2, nginx, Microsoft IIS. Backend. This is the actual application or “business logic solution”: How to write a program or script that processes requests, performs work, and prepares proper HTTP responses. How to leverage web frameworks to assist in this process. A backend can be a strict data API to be consumed by one or multiple frontends (web, mobile, console), or a traditional multi–page application (simpler). Languages: Perl, PHP, Python, Ruby, Javascript, and even C/C++. Web frameworks: Laravel, Django, Ruby on Rails, nodejs, ASP.NET MVC, and many more. Also helpful to know: JSON, REST, SOAP. Frontend. This is the user–facing piece of the backend: How HTML works to lay out a page, how CSS works to assist in page layout and theme, how to leverage Javascript to breathe life into the frontend, and how to asynchronously interact with a backend. Languages: HTML5, Javascript, Typescript, CSS, SASS, SCSS. Also helpful: JSON, XML, XPath. Browsers: How to use the developer tools in any browser to tweak styles, debug javascript, and debug HTTP requests made by the browser and HTTP responses made by the web server or the backend. Databases. Relational databases are array–of–structures on steroids: How to setup a (relational/document) database and schema, setup database users and their permissions, how to write queries, and how to write database migrations. Flat files and NoSQL can be okay, too. Version control. Very important in any software project: How to use a version control system, how to write meaningful commits, how to resolve merges, how to submit merge requests, and how to manage branches. Devops: How to configure and build the backend project and/or the frontend project. How to automate builds, run tests, report problems. (Not pictured here: Websockets.) With these in mind, read What happens when you type into your browser and press enter for an example of how a sample request is made. Hopefully, this has been helpful to game developers looking to build a real–time multiplayer web game or even a high score tracking server. Thanks for reading, see you around!
  15. How does this ever work.

    Francoisdiy, I believe you meant to post in this thread: Coding vs Level Design Thread is eight months old; locking.