text
stringlengths
454
608k
url
stringlengths
17
896
dump
stringclasses
91 values
source
stringclasses
1 value
word_count
int64
101
114k
flesch_reading_ease
float64
50
104
Use Interface for declaring Constants (10 messages) Hi, - Posted by: Anil Patel - Posted on: May 06 2003 18:04 EDT I use Interface for only declaring Constans. Lot of times my team partners will write class and implement the Interface that has only constants declaration. I don't see this logical. I though of using Class with Private constructor and public static final declaration of varaibles for constants. Any conmments on If this is right to do? Anil Threaded Messages (10) - Yes! by SAF . on May 06 2003 20:49 EDT - Yes! by Aaron Robinson on May 07 2003 02:43 EDT - Why? by SAF . on May 07 2003 09:05 EDT - Because.... by Paul Holser on May 07 2003 09:54 EDT - Don't agree by SAF . on May 07 2003 10:42 EDT - Re: Don't agree by Alan Choy on May 07 2003 01:42 EDT - Because.... by Mike Spille on May 16 2003 11:56 EDT - Don't agree but... by Archimedes Trajano on July 06 2004 16:01 EDT - import static by Archimedes Trajano on July 06 2004 04:21 EDT - don't really know! by Alex Hepp on May 03 2011 04:08 EDT Yes![ Go to top ] Using an interface for declaring constants is a better idea thatn using a regualr class since, if you use a class, then you will need to qualify the constant with the class name, such as MyClass.CONSTANT_NAME. - Posted by: SAF . - Posted on: May 06 2003 20:49 EDT - in response to Anil Patel If you use an interface, any class that needs to obtain access to the constants would simply need to implement the interface. There would be no need to qualify the constant name in this case, you can use CONSTANT_NAME! Less typing :-P SAF Yes![ Go to top ] I think Joshua Bloch covers this in his book on effective Java. If I remember correctly he recommends not using Interfaces for storing constants. - Posted by: Aaron Robinson - Posted on: May 07 2003 02:43 EDT - in response to SAF . Why?[ Go to top ] And the reason for that would be 'what' exactly? Why would using a regular class be better than using an interface? - Posted by: SAF . - Posted on: May 07 2003 09:05 EDT - in response to Aaron Robinson SAF Because....[ Go to top ] And the reason for that would be 'what' exactly? Why would using a regular - Posted by: Paul Holser - Posted on: May 07 2003 09:54 EDT - in response to SAF . > class be better than using an interface? Bloch, p. 89. interface in the Java platform libraries, such as java.io.ObjectStreamConstants. These interfaces should be viewed as anomalies and should not be emulated." i'm not totally against using interfaces to hold constants. i am however, against having users of those constants implement the constant interface just so they don't have to fully qualify the names. sounds wacky, eh--why not just use an uninstantiable class to hold the constants, then? ok, i'm down with that. Don't agree[ Go to top ] I don't agree with Bloch. It sounds like his opinion rather than a 'best practice'. Interfaces can be used for many different things; an implementation policy, where the inteface contains abstract methods. Interfaces can also serve as an identity marker for a class, or a set of classes that have something in common, and a few good examples of this are the Serializable and Clonable interfaces. - Posted by: SAF . - Posted on: May 07 2003 10:42 EDT - in response to Paul Holser If one reason to avoid the use of a constants-only interface can be justified as to not confuse a programmer, then either that programmer needs more experience to become un-confused, or, perhaps we should not use static initializers as well because I remember reading somewhere that they were not used often and are strange to read, which might confuse a programmer as well :-P. Please, Bloch! I think it's safe to safe that patience, tedious work, and sometime a litte confusion, comes with the territory. :-) SAF Re: Don't agree[ Go to top ] I tend to agree with SAF ...... maybe we can ask James Gosling ...... when his team designed Java interface, all attributes defined would automatically interpreted by the Java compiler as final and static, which in the other words is a constant. There must be a reason for this ...... - Posted by: Alan Choy - Posted on: May 07 2003 13:42 EDT - in response to SAF . Because....[ Go to top ] Bloch: ." - Posted by: Mike Spille - Posted on: May 16 2003 11:56 EDT - in response to Paul Holser This is a rather purist view IMHO, and not very useful for people creating software on a day to day basis. Going on further in the quoting... "If a nonfinal class implements a constant interface, all of its subclasses will have their namespaces polluted by the constants in the interface" The fact of the matter is that most classes in a given system are never sub-classed. And when they are, it is most often done within a closed sub-system. Further - in the cases when someone does sub-class, the sub-classer is fully aware that its parent implements the interface, and in fact can take advantage of this fact and use the constants directly itself as well. I can see Bloch's concerns over name space pollution, but in reality it's a rather far fetched proposition. It's only a big concern if you're publishing an API out to a very wide audience, and even then Java APIs tend to expose interfaces more than concrete classes these days, so again it's a non-issue. In fact, Java's single-inheritance of implementation makes this almost a completely moot point. Anyway, my take on it is that using a constants-only interface is a very, very convenient feature which provides some much needed notational convenience to Java. And I'll close with a favorite observation of mine that I've been using alot these days: "just because it's written in a book doesn't make it true". -Mike Don't agree but...[ Go to top ] I don't agree with Bloch either. I prefer code compactness and ease of reading. To that effect I don't agree with "implementing" constant interfaces. - Posted by: Archimedes Trajano - Posted on: July 06 2004 16:01 EDT - in response to SAF . However, this is in from Ant it removed 4 constant interfaces that would have been suggested for 658 variables, from Tomcat it removed 5 constant interfaces that would have been suggested for 855 variables, from J2SDK it removed 1 constant interface that would have been suggested for 1 variable, from Net- Beans it removed 13 constant interfaces that would have been suggested for 4,343 variables, and from Eclipse it removed 4 constant interfaces that would have been suggested for 4,527 variables. I am not sure why they did this, maybe because of Bloch's recommendations. import static[ Go to top ] Not sure, but does 1.5 support import static on interface constants? If not I guess that would be one more reason to use classes to hold constants instead of interfaces. Though its still annoying having to read and type public static final every single time. - Posted by: Archimedes Trajano - Posted on: July 06 2004 16:21 EDT - in response to Archimedes Trajano don't really know![ Go to top ] - Posted by: Alex Hepp - Posted on: May 03 2011 04:08 EDT - in response to Archimedes Trajano 1.) I think we shouldn't consider import static as a feature to be widely used. Why? Try to read a code fragment that makes use of Collections and other APIs static functions and try to determine what the code does! 2.) IMHO constant interfaces misuse the idea of interfaces. Even if this sounds purist or whatever. Just for comfortability we remove readability. An interface should be seen as a blueprint imho that defines what the class offers. We should only uses Constants in interfaces that are really needed for implementation of it's methods.
http://www.theserverside.com/discussions/thread/19221.html
CC-MAIN-2017-26
refinedweb
1,364
71.55
jazzy special1,332 Points square Having trouble figuring out this square challenge. Receiving message <function square at 0x7f65e2eb7e18> def square(number): return (number * number) number = int(input("Give a number to square. " )) print(square) 1 Answer joelearner36,505 Points Hi Jeffrey, Your first two lines look good so I'm guessing you're looking for help on part 2 of the challenge. For part 2, the teacher is looking for you to create a new variable to store a value that comes from using the function you created in part 1. The variable will be called "result" but I don't see that in your code. If you create the result variable, your code should look something like this: def square(number): return number * number result = square(3) Cheers! jazzy special1,332 Points jazzy special1,332 Points Thanks Joe, That helped a ton and I figured it out!
https://teamtreehouse.com/community/square
CC-MAIN-2019-26
refinedweb
148
68.81
Abstract Contents - Abstract - Rationale - Repositories to Migrate - Migration Plan - Requirements for Code-Only Repositories - Requirements for Web-Related Repositories - Requirements for the cpython Repository - Optional, Planned Features - Handling Misc/NEWS - Handling Misc/ACKS - Create - Backup of pull request data - Bot to generate cherry-pick pull requests - Pull request commit queue - A CI service - Test coverage report - Notifying issues of pull request comments - Allow bugs.python.org to use GitHub as a login provider - Web hooks for re-generating web content - Link web content back to files that it is generated from - Splitting out parts of the documentation into their own repositories - Backup of Git repositories - Identify potential new core developers - Status - Open Issues - Rejected Ideas - References Note CPython's development process moved to on 2017-02-10. This PEP outlines the steps required to migrate Python's development process from Mercurial [3] as hosted at hg.python.org [1] to Git [4] on GitHub [2]. Meeting the minimum goals of this PEP should allow for the development process of Python to be as productive as it currently is, and meeting its extended goals should improve the development process from its status quo. Rationale In 2014, it became obvious that Python's custom development process was becoming a hindrance. As an example, for an external contributor to submit a fix for a bug that eventually was committed, the basic steps were: - Open an issue for the bug at bugs.python.org [5]. - Make the fix. - Upload a patch. - Have a core developer review the patch using our fork of the Rietveld code review tool [6]. - Download the patch to make sure it still applies cleanly. - Run the test suite manually. - Update the NEWS, ACKS, and "What's New" document as necessary - Pull changes to avoid a merge race. - Commit the change manually. - If the change was for a bugfix release, merge into the in-development branch. - Run the test suite manually again. - Commit the merge. - Push the changes. This is a very heavy, manual process for core developers. Even in the simple case, you could only possibly skip the code review step, as you would still need to build the documentation. This led to patches languishing on the issue tracker due to core developers not being able to work through the backlog fast enough to keep up with submissions. In turn, that led to a side-effect issue of discouraging outside contribution due to frustration from lack of attention, which is dangerous problem for an open source project with no corporate backing as it runs counter to having a viable future for the project. While allowing patches to be uploaded to bugs.python.org [5] is potentially simple for an external contributor, it is as slow and burdensome as it gets for a core developer to work with. Hence the decision was made in late 2014 that a move to a new development process was needed. A request for PEPs proposing new workflows was made, in the end leading to two: PEP 481 and PEP 507 proposing GitHub [2] and GitLab [7], respectively. The year 2015 was spent off-and-on working on those proposals and trying to tease out details of what made them different from each other on the core-workflow mailing list [8]. PyCon US 2015 also showed that the community was a bit frustrated with our process due to both cognitive overhead for new contributors and how long it was taking for core developers to look at a patch (see the end of Guido van Rossum's keynote at PyCon US 2015 [9] as an example of the frustration). On January 1, 2016, the decision was made by Brett Cannon to move the development process to GitHub. The key reasons for choosing GitHub were [10]: - Maintaining custom infrastructure has been a burden on volunteers (e.g., an unmaintained, custom fork of Rietveld [6] is currently being used). - The custom workflow is very time-consuming for core developers (not enough automated tooling built to help support it). - The custom workflow is a hindrance to external contributors (acts as a barrier of entry due to time required to ramp up on development process unique to CPython itself). - There is no feature differentiating GitLab from GitHub beyond GitLab being open source. - Familiarity with GitHub is far higher among core developers and external contributors than with GitLab. - Our BDFL prefers GitHub (who would be the first person to tell you that his opinion shouldn't matter, but the person making the decision felt it was important that the BDFL feel comfortable with the workflow of his own programming language to encourage his continued participation). There's even already an unofficial logo to represent the migration to GitHub [22]. The overarching goal of this migration is to improve the development process to the extent that a core developer can go from external contribution submission through all the steps leading to committing said contribution from within a browser on a tablet with WiFi using some development process (this does not inherently mean GitHub's default workflow). The final solution will also allow an external contributor to contribute even if they chose not to use GitHub (although there is not guarantee in feature parity). Repositories to Migrate While hg.python.org [1] hosts many repositories, there are only five key repositories that need to move: The devinabox repository is code-only. The peps and devguide repositories involve the generation of webpages. And the cpython repository has special requirements for integration with bugs.python.org [5]. Migration Plan The migration plan is separated into sections based on what is required to migrate the repositories listed in the Repositories to Migrate section. Completion of requirements outlined in each section should unblock the migration of the related repositories. The sections are expected to be completed in order, but not necessarily the requirements within a section. Requirements for Code-Only Repositories Completion of the requirements in this section will allow the devinabox repository to move to GitHub. Create a 'Python core' team To manage permissions, a 'Python core' team will be created as part of the python organization [16]. Any repository that is moved will have the 'Python core' team added to it with write permissions [17]. Anyone who previously had rights to manage SSH keys on hg.python.org will become a team maintainer for the 'Python core' team. Define commands to move a Mercurial repository to Git Since moving to GitHub also entails moving to Git [4], we must decide what tools and commands we will run to translate a Mercurial repository to Git. The tools developed specifically for this migration are hosted at . CLA enforcement A key part of any open source project is making sure that its source code can be properly licensed. This requires making sure all people making contributions have signed a contributor license agreement (CLA) [18]. Up until now, enforcement of CLA signing of contributed code has been enforced by core developers checking whether someone had an * by their username on bugs.python.org [5]. With this migration, the plan is to start off with automated checking and enforcement of contributors signing the CLA. Adding GitHub username support to bugs.python.org To keep tracking of CLA signing under the direct control of the PSF, tracking who has signed the PSF CLA will be continued by marking that fact as part of someone's bugs.python.org user profile. What this means is that an association will be needed between a person's bugs.python.org [5] account and their GitHub account, which will be done through a new field in a user's profile. This does implicitly require that contributors will need both a GitHub [2] and bugs.python.org account in order to sign the CLA and contribute through GitHub. An API is provided to query bugs.python.org to see if a GitHub username corresponds to someone who has signed the CLA. Making a GET request to e.g. returns a JSON dictionary with the keys of the usernames requested and a true value if they have signed the CLA, false if they have not, and null if no corresponding GitHub username was found. A bot to enforce CLA signing With an association between someone's GitHub account and their bugs.python.org [5] account, which has the data as to whether someone has signed the CLA, a bot can monitor pull requests on GitHub and denote whether the contributor has signed the CLA. If the user has signed the CLA, the bot will add a positive label to the issue to denote the pull request has no CLA issues (e.g., a green label stating, "CLA signed"). If the contributor has not signed a CLA, a negative label will be added to the pull request will be blocked using GitHub's status API (e.g., a red label stating, "CLA not signed"). If a contributor lacks a bugs.python.org account, that will lead to the negative label being used as well. Using a label for both positive and negative cases provides a fallback signal if the bot happens to fail, preventing potential false-positives or false-negatives. It also allows for an easy way to trigger the bot again by simply removing a CLA-related label (this is in contrast to using a GitHub status check [40] which is only triggered on code changes). As no pre-existing bot exists to meet our needs, it will be hosted on Heroku [39] and written to target Python 3.5 to act as a showcase for asynchronous programming. The code for the bot is hosted in the Knights Who Say Ni project [41]. Make old repository read-only Updating .hg/hgrc in the now-old Mercurial repository in the [hooks] section with: pretxnchangegroup.reject = echo " * This repo has been migrated to github.com/python/peps and does not accept new commits in Mercurial!" 2>&1; exit 1 will make the repository read-only. Requirements for the cpython Repository Obviously the most active and important repository currently hosted at hg.python.org [1] is the cpython repository [15]. Because of its importance and high- frequency use, it requires more tooling before being moved to GitHub compared to the other repositories mentioned in this PEP. Document steps to commit a pull request During the process of choosing a new development workflow, it was decided that a linear history is desired. People preferred having a single commit representing a single change instead of having a set of unrelated commits lead to a merge commit that represented a single change. This means that the convenient "Merge" button in GitHub pull requests will be set to only do squash commits and not merge commits. A second set of recommended commands will also be written for committing a contribution from a patch file uploaded to bugs.python.org [5]. This will obviously help keep the linear history, but it will need to be made to have attribution to the patch author. The exact sequence of commands that will be given as guidelines to core developers is an open issue: Git CLI commands for committing a pull request to cpython. Linking pull requests to issues Historically, external contributions were attached to an issue on bugs.python.org [5] thanks to the fact that all external contributions were uploaded as a file. For changes committed by a core developer who committed a change directly, the specifying of an issue number in the commit message of the format Issue # at the start of the message led to a comment being posted to the issue linking to the commit. Linking a pull request to an issue An association between a pull request and an issue is needed to track when a fix has been proposed. The association needs to be many-to-one as there can take multiple pull requests to solve a single issue (technically it should be a many-to-many association for when a single fix solves multiple issues, but this is fairly rare and issues can be merged into one using the Superseder field on the issue tracker). The association between a pull request and an issue will be done based on detecting an issue number. If the issue is specified in either the title or in the body of a message on a pull request then connection will be made on bugs.python.org [5]. Some visible notification -- e.g. label or message -- will be made to the pull request to notify that the association was successfully made. Notify the issue if a commit is made Once a commit is made, the corresponding issue should be updated to reflect this fact. This should work regardless of whether the commit came from a pull request or a direct commit. Update the linking service for mapping commit IDs to URLs Currently you can use with a revision ID from either the Subversion or Mercurial copies of the cpython repo [15] to get redirected to the URL for that revision in the Mercurial repository. The URL rewriter will need to be updated to redirect to the Git repository and to support the new revision IDs created for the Git repository. The most likely design is to statically know all the Mercurial changeset numbers once the migration has occurred. The lookup code will then be updated to accept hashes from 7 to 40 hexadecimal digits. Any hexadecimal of length 12 or 40 will be compared against the Mercurial changeset numbers. If the number doesn't match or is of some other length between 7 and 40 then it will be assumed to be a Git hash. The bugs.python.org commit number rewriter will also need to be updated to accept hashes as short as 7 digits as Git will match on hashes that short or longer. Deprecate sys._mercurial Once Python is no longer kept in Mercurial, the sys._mercurial attribute will need to be changed to return ('CPython', '', ''). An equivalent sys._git attribute will be added which fulfills the same use-cases. Update the devguide The devguide will need to be updated with details of the new workflow. Mostly likely work will take place in a separate branch until the migration actually occurs. Optional, Planned Features Once the cpython repository [15] is migrated, all repositories will have been moved to GitHub [2] and the development process should be on equal footing as before the move. But a key reason for this migration is to improve the development process, making it better than it has ever been. This section outlines some plans on how to improve things. It should be mentioned that overall feature planning for bugs.python.org [5] -- which includes plans independent of this migration -- are tracked on their own wiki page [23]. Handling Misc/NEWS Traditionally the Misc/NEWS file [19] has been problematic for changes which spanned Python releases. Oftentimes there will be merge conflicts when committing a change between e.g., 3.5 and 3.6 only in the Misc/NEWS file. It's so common, in fact, that the example instructions in the devguide explicitly mention how to resolve conflicts in the Misc/NEWS file [21]. As part of our tool modernization, working with the Misc/NEWS file will be simplified. The planned approach is to use an individual file per news entry, containing the text for the entry. In this scenario each feature release would have its own directory for news entries and a separate file would be created in that directory that was either named after the issue it closed or a timestamp value (which prevents collisions). Merges across branches would have no issue as the news entry file would still be uniquely named and in the directory of the latest version that contained the fix. A script would collect all news entry files no matter what directory they reside in and create an appropriate news file (the release directory can be ignored as the mere fact that the file exists is enough to represent that the entry belongs to the release). Classification can either be done by keyword in the new entry file itself or by using subdirectories representing each news entry classification in each release directory (or classification of news entries could be dropped since critical information is captured by the "What's New" documents which are organized). The benefit of this approach is that it keeps the changes with the code that was actually changed. It also ties the message to being part of the commit which introduced the change. For a commit made through the CLI, a script could be provided to help generate the file. In a bot-driven scenario, the merge bot could have a way to specify a specific news entry and create the file as part of its flattened commit (while most likely also supporting using the first line of the commit message if no specific news entry was specified). If a web-based workflow is used then a status check could be used to verify that a new entry file is in the pull request to act as a reminder that the file is missing. Code for this approach has been written previously for the Mercurial workflow at. There is also tools from the community like,, and. Discussions at the Sep 2016 Python core-dev sprints led to this decision compared to the rejected approaches outlined in the Rejected Ideas section of this PEP. The separate files approach seems to have the right balance of flexibility and potential tooling out of the various options while solving the motivating problem. Work for this is being tracked at. Handling Misc/ACKS Traditionally the Misc/ACKS file [20] has been managed by hand. But thanks to Git supporting an author value as well as a committer value per commit, authorship of a commit can be part of the history of the code itself. As such, manual management of Misc/ACKS will become optional. A script will be written that will collect all author and committer names and merge them into Misc/ACKS with all of the names listed prior to the move to Git. Running this script will become part of the release process. The script should also generate a list of all people who contributed since the last execution. This will allow having a list of those who contributed to a specific release so they can be explicitly thanked. Work for this is being tracked at. Create Just as hg.python.org [1] currently points to the Mercurial repository for Python, git.python.org should do the equivalent for the Git repository. Backup of pull request data Since GitHub [2] is going to be used for code hosting and code review, those two things need to be backed up. In the case of code hosting, the backup is implicit as all non-shallow Git [4] clones contain the full history of the repository, hence there will be many backups of the repository. The code review history does not have the same implicit backup mechanism as the repository itself. That means a daily backup of code review history should be done so that it is not lost in case of any issues with GitHub. It also helps guarantee that a migration from GitHub to some other code review system is feasible were GitHub to disappear overnight. Bot to generate cherry-pick pull requests Since the decision has been made to work with cherry-picks instead of forward merging of branches, it would be convenient to have a bot that would generate pull requests based on cherry-picking for any pull requests that affect multiple branches. The most likely design is a bot that monitors merged pull requests with key labels applied that delineate what branches the pull request should be cherry-picked into. The bot would then generate cherry-pick pull requests for each label and remove the labels as the pull requests are created (this allows for easy detection when automatic cherry-picking failed). Work for this is being tracked at. Pull request commit queue This would linearly apply accepted pull requests and verify that the commits did not interfere with each other by running the test suite and backing out commits if the test run failed. To help facilitate the speed of testing, all patches committed since the last test run can be applied at once under a single test run as the optimistic assumption is that the patches will work in tandem. Some mechanism to re-run the tests in case of test flakiness will be needed, whether it is from removing a "test failed" label, web interface for core developers to trigger another testing event, etc. Inspiration or basis of the bot could be taken from pre-existig bots such as Homu [31] or Zuul [32]. The name given to this bot in order to give it commands is an open issue: Naming the bots. A CI service There are various CI services that provide free support for open source projects hosted on GitHub [2]. After experimenting with a couple CI services, the decision was made to go with Travis [33]. The current CI service for Python is Pypatcher [38]. A request can be made in IRC to try a patch from bugs.python.org [5]. The results can be viewed at . Work for this is being tracked at. Test coverage report Getting an up-to-date test coverage report for Python's standard library would be extremely beneficial as generating such a report can take quite a while to produce. There are a couple pre-existing services that provide free test coverage for open source projects. In the end, Codecov [37] was chosen as the best option. Work for this is being tracked at. Notifying issues of pull request comments The current development process does not include notifying an issue on bugs.python.org [5] when a review comment is left on Rietveld [6]. It would be nice to fix this so that people can subscribe only to comments at bugs.python.org and not GitHub [2] and yet still know when something occurs on GitHub in terms of review comments on relevant pull requests. Current thinking is to post a comment to bugs.python.org to the relevant issue when at least one review comment has been made over a certain period of time (e.g., 15 or 30 minutes, although with GitHub now supporting reviews the time aspect may be unnecessary). This keeps the email volume down for those that receive both GitHub and bugs.python.org email notifications while still making sure that those only following bugs.python.org know when there might be a review comment to address. Allow bugs.python.org to use GitHub as a login provider As of right now, bugs.python.org [5] allows people to log in using Google, Launchpad, or OpenID credentials. It would be good to expand this to GitHub credentials. Web hooks for re-generating web content The content at,, and are all derived from files kept in one of the repositories to be moved as part of this migration. As such, it would be nice to set up appropriate webhooks to trigger rebuilding the appropriate web content when the files they are based on change instead of having to wait for, e.g., a cronjob to trigger. This can partially be solved if the documentation is a Sphinx project as then the site can have an unofficial mirror on Read the Docs, e.g.. Work for this is being tracked at. Link web content back to files that it is generated from It would be helpful for people who find issues with any of the documentation that is generated from a file to have a link on each page which points back to the file on GitHub [2] that stores the content of the page. That would allow for quick pull requests to fix simple things such as spelling mistakes. Work for this is being tracked at. Splitting out parts of the documentation into their own repositories While certain parts of the documentation at change with the code, other parts are fairly static and are not tightly bound to the CPython code itself. The following sections of the documentation fit this category of slow-changing, loosely-coupled: - Tutorial - Python Setup and Usage - HOWTOs - Installing Python Modules - Distributing Python Modules - Extending and Embedding - FAQs These parts of the documentation could be broken out into their own repositories to simplify their maintenance and to expand who has commit rights to them to ease in their maintenance. It has also been suggested to split out the What's New documents. That would require deciding whether a workflow could be developed where it would be difficult to forget to update What's New (potentially through a label added to PRs, like "What's New needed"). Backup of Git repositories While not necessary, it would be good to have official backups of the various Git repositories for disaster protection. It will be up to the PSF infrastructure committee to decide if this is worthwhile or unnecessary. Identify potential new core developers The Python development team has long-standing guidelines for selecting new core developers. The key part of the guidelines is that a person needs to have contributed multiple patches which have been accepted and are high enough quality and size to demonstrate an understanding of Python's development process. A bot could be written which tracks patch acceptance rates and generates a report to help identify contributors who warrant consideration for becoming core developers. This work doesn't even necessarily require GitHub integration as long as the committer field in all git commits is filled in properly. Work is being tracked at. Status Requirements for migrating the devinabox [12] repository: - Completed - Adding GitHub username support to bugs.python.org (Maciej Szulik and Ezio Melotti) - A bot to enforce CLA signing: (Brett Cannon) - Create a 'Python core' team - Define commands to move a Mercurial repository to Git: (Senthil Kumaran) Repositories whose build steps need updating: cpython repo [15] Required: - Not started - Update PEP 101 (commitment from Ned Deily to do this; non-blocker) - In progress - Deprecate sys._mercurial (; review committal from Ned Deily; non-blocker) - Update the linking service for mapping commit IDs to URLs (code ready, needs deployment once the hg repository is made read-only;; post-migration) - Completed - Notify the issue if a commit is made () - Track PR status in appropriate issue () - Update the devguide, including Document steps to commit a pull request () - Update commit hash detection on b.p.o to support 10- and 11-character hashes () - Linking a pull request to an issue () - Message #python-dev for each commit (PR or direct) () - Get docs built from git ( already updated; to switch) - Migrate buildbots to be triggered and pull from GitHub Optional features: - Not started - Check for whitespace abnormalities as part of CI - Write .github/CONTRIBUTING.md (to prevent PRs that are inappropriate from even showing up and pointing to the devguide) - Create - Backup of pull request data - Handling Misc/NEWS - Handling Misc/ACKS - Pull request commit queue - Bot to generate cherry-pick pull requests - Allow bugs.python.org to use GitHub as a login provider - Web hooks for re-generating web content - Link web content back to files that it is generated from - Splitting out parts of the documentation into their own repositories - Backup of Git repositories - In progress - Notifying issues of pull request comments () - Convert b.p.o patches to GitHub PRs () - Completed Open Issues For this PEP, open issues are ones where a decision needs to be made to how to approach or solve a problem. Open issues do not entail coordination issues such as who is going to write a certain bit of code. The fate of hg.python.org With the code repositories moving over to Git [4], there is no technical need to keep hg.python.org [1] running. Having said that, some in the community would like to have it stay functioning as a Mercurial [3] mirror of the Git repositories. Others have said that they still want a mirror, but one using Git. As maintaining hg.python.org is not necessary, it will be up to the PSF infrastructure committee to decide if they want to spend the time and resources to keep it running. They may also choose whether they want to host a Git mirror on PSF infrastructure. Depending on the decision reached, other ancillary repositories will either be forced to migration or they can choose to simply stay on hg.python.org. Git CLI commands for committing a pull request to cpython Because Git [4] may be a new version control system for core developers, the commands people are expected to run will need to be written down. These commands also need to keep a linear history while giving proper attribution to the pull request author. Another set of commands will also be necessary for when working with a patch file uploaded to bugs.python.org [5]. Here the linear history will be kept implicitly, but it will need to make sure to keep/add attribution. Naming the bots As naming things can lead to bikeshedding of epic proportions, Brett Cannon will choose the final name of the various bots (the name of the project for the bots themselves can be anything, this is purely for the name used in giving commands to the bot or the account name). The names must come from Monty Python, which is only fitting since Python is named after the comedy troupe. Rejected Ideas Separate Python 2 and Python 3 repositories It was discussed whether separate repositories for Python 2 and Python 3 were desired. The thinking was that this would shrink the overall repository size which benefits people with slow Internet connections or small bandwidth caps. In the end it was decided that it was easier logistically to simply keep all of CPython's history in a single repository. Commit multi-release changes in bugfix branch first As the current development process has changes committed in the oldest branch first and then merged up to the default branch, the question came up as to whether this workflow should be perpetuated. In the end it was decided that committing in the newest branch and then cherry-picking changes into older branches would work best as most people will instinctively work off the newest branch and it is a more common workflow when using Git [4]. Cherry-picking is also more bot-friendly for an in-browser workflow. In the merge-up scenario, if you were to request a bot to do a merge and it failed, then you would have to make sure to immediately solve the merge conflicts if you still allowed the main commit, else you would need to postpone the entire commit until all merges could be handled. With a cherry-picking workflow, the main commit could proceed while postponing the merge-failing cherry-picks. This allows for possibly distributing the work of managing conflicting merges. Lastly, cherry-picking should help avoid merge races. Currently, when one is doing work that spans branches, it takes time to commit in the older branch, possibly push to another clone representing the default branch, merge the change, and then push upstream. Cherry-picking should decouple this so that you don't have to rush your multi-branch changes as the cherry-pick can be done separately. Deriving Misc/NEWS from the commit logs As part of the discussion surrounding Handling Misc/NEWS, the suggestion has come up of deriving the file from the commit logs itself. In this scenario, the first line of a commit message would be taken to represent the news entry for the change. Some heuristic to tie in whether a change warranted a news entry would be used, e.g., whether an issue number is listed. This idea has been rejected due to some core developers preferring to write a news entry separate from the commit message. The argument is the first line of a commit message compared to that of a news entry have different requirements in terms of brevity, what should be said, etc. Deriving Misc/NEWS from bugs.python.org A rejected solution to the NEWS file problem was to specify the entry on bugs.python.org [5]. This would mean an issue that is marked as "resolved" could not be closed until a news entry is added in the "news" field in the issue tracker. The benefit of tying the news entry to the issue is it makes sure that all changes worthy of a news entry have an accompanying issue. It also makes classifying a news entry automatic thanks to the Component field of the issue. The Versions field of the issue also ties the news entry to which Python releases were affected. A script would be written to query bugs.python.org for relevant new entries for a release and to produce the output needed to be checked into the code repository. This approach is agnostic to whether a commit was done by CLI or bot. A drawback is that there's a disconnect between the actual commit that made the change and the news entry by having them live in separate places (in this case, GitHub and bugs.python.org). This would mean making a commit would then require remembering to go back to bugs.python.org to add the news entry.
http://docs.activestate.com/activepython/3.5/peps/pep-0512.html
CC-MAIN-2018-39
refinedweb
5,594
59.33
Sending and receiving of C# Serialport preface: Last time, the blogger explained the configuration of serial port control for you. In this issue, we will explain the sending and receiving of serial port. This serial port communication control provides a lot of methods for the communication between host computer and single chip microcomputer. It is convenient for you to use and easy to use. Once a day to prevent puppy love: 1.SerialPort serial port control sending configuration 1.1 take the item of the previous article. I set it based on that item. If I can't, I can see the previous article of the blogger and put a link(... )First, we need to set the interface, including send box, receive box and send button 1.2 let's first learn about the sending of serialPort, which provides several interfaces: public void Write(byte[] buffer, int offset, int count); Writes the specified number of bytes to the serial port using the data in the buffer. // buffer: an array of bytes containing the data to be written to the port. // Offset: the byte offset from zero in the buffer parameter, from which bytes are copied to the port. // count: number of bytes to write. public void Write(string text); Writes the specified string to the serial port. text: Output string. public void Write(char[] buffer, int offset, int count); Writes the specified number of characters to the serial port using the data in the buffer. // buffer: character array containing the data to be written to the port. // Offset: the byte offset from zero in the buffer parameter, from which bytes are copied to the port. // count: the number of characters to write. public void WriteLine(string text); // Writes the specified string and System.IO.Ports.SerialPort.NewLine value to the output buffer. // text: the string to write to the output buffer. - 3. Double click the send button to automatically generate the method function and write the method we sent: 1.4 the code is as follows: it can be used directly, provided that your interface is the same as that of the blogger. Pay attention to whether the controls of the interface correspond to the function trigger of the blogger, not to change the trigger of the interface. For details, refer to the previous article. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO.Ports; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Serilport { public partial class Form1 : Form { public Form1() { InitializeComponent(); System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; } private void SearchAndAddSerialToComboBox(object sender, EventArgs e) { string Buffer; comboBox1.Items.Clear(); //Records scanned before the beginning of the Qing Dynasty for (int i = 0; i < 20; i++) { try { Buffer = "COM" + i.ToString(); //Obtain COM1-20 serialPort1.PortName = Buffer; //Get COM information serialPort1.Open(); //Open serial port comboBox1.Items.Add(Buffer); comboBox1.Text = Buffer; //Add serial port to get Recordset serialPort1.Close(); //Close the serial port } catch { } } } private void button4_Click(object sender, EventArgs e) { try { serialPort1.PortName = comboBox1.Text; serialPort1.BaudRate = Convert.ToInt32(comboBox2.Text, 10); serialPort1.DataBits = Convert.ToInt32(comboBox3.Text, 10); if (comboBox4.Text == "None") { serialPort1.Parity = Parity.None; } else if (comboBox4.Text == "Odd check") { serialPort1.Parity = Parity.Odd; } else if (comboBox4.Text == "Parity check") { serialPort1.Parity = Parity.Even; } else if (comboBox4.Text == "Mark") { serialPort1.Parity = Parity.Mark; } else if (comboBox4.Text == "Space check") { serialPort1.Parity = Parity.Space; } if (comboBox5.Text == "1") { serialPort1.StopBits = StopBits.One; } else if (comboBox5.Text == "1.5") { serialPort1.StopBits = StopBits.OnePointFive; } else if (comboBox5.Text == "1.5") { serialPort1.StopBits = StopBits.Two; } //serialPort1.ReadTimeout(2000); serialPort1.Open(); button2.Enabled = false;//The open serial port button is not available //button3.Enabled = true;// Close the serial port } catch { MessageBox.Show("Port error,Please check the serial port", "error"); } } private void button1_Click(object sender, EventArgs e) { string str = textBox2.Text;//Get the data of the send box byte[] Data = new byte[1];//As a container for sending if (serialPort1.IsOpen)//Judge whether our serial port is open { for (int j = 0; j < str.Length; j++)//Traversing our sending statements, bloggers now send one by one { if (str[j] == ' ')//Our sending statements are separated by spaces. We have to traverse them { continue; } else { try { Data[0] = Convert.ToByte(str.Substring(j, 2), 16);//substring is a hexadecimal number that takes 2 bytes of str string from the position of j } catch { MessageBox.Show("Please check the hexadecimal data format error"); } try { serialPort1.Write(Data, 0, 1);//This means sending data, starting from the position of 0, and taking a value. j++; } catch { MessageBox.Show("Port sending failed. The system will close the current serial port error"); serialPort1.Close();//Close the serial port } } } } } } } 2.SarilPort serial port control receiving configuration 2.1 understanding the interface of SerialPort receiving method public int Read(char[] buffer, int offset, int count); from System.IO.Ports.SerialPort Reads some characters from the input buffer and writes them to the offset specified in the character array. // buffer: an array of bytes to which input is written. // Offset: offset in the buffer to write bytes. // Count: the maximum number of bytes read. If count is greater than the number of bytes in the input buffer, fewer bytes are read. public int Read(byte[] buffer, int offset, int count); from System.IO.Ports.SerialPort The input buffer reads some bytes and writes those bytes to the offset specified in the byte array. // buffer: an array of bytes to which input is written. // Offset: offset in the buffer to write bytes. // Count: the maximum number of bytes read. If count is greater than the number of bytes in the input buffer, fewer bytes are read. public int ReadByte(); from System.IO.Ports.SerialPort A byte is synchronously read from the input buffer. public int ReadChar(); from System.IO.Ports.SerialPort One character is synchronously read from the input buffer. public string ReadExisting(); On the basis of coding, read System.IO.Ports.SerialPort All immediately available bytes in the stream and input buffer of the object. public string ReadLine(); Read all the way to the input buffer System.IO.Ports.SerialPort.NewLine Value. public string ReadTo(string value); Reads up to the specified in the input buffer value String of. value: A value indicating where the read operation stops. 2.2. Create a receiving function according to the screenshot, and SerialPort automatically receives data 2.3 if you don't want to use the loop, you can read the data at one time, so it won't be so troublesome. Read its own interface carefully and find a suitable interface. I'll send my code to you for reference: private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) { byte data = 0; int len = 0; int bufsize = (int)serialPort1.BytesToRead;//Get cache bytes while (len < bufsize)//Get one after another { data = (byte)serialPort1.ReadByte();//Get the value of serial port len++; string str = Convert.ToString(data, 16).ToUpper();//After obtaining, we will output it in TextBox if (str.Length == 1)//If the value we get is a bit, we fill in 0 before it { textBox1.AppendText(" 0" + str); } else { textBox1.AppendText(" " + str);//The two values are separated by a space in front } } textBox1.AppendText(System.Environment.NewLine);//Line feed serialPort1.DiscardInBuffer();//Clear previous cache } 3. Show me the sending and receiving of SerialPort. The blogger happens to have a single chip microcomputer here to show you. If you are interested in this, you can also use the virtual serial port to simulate and play. Note: the blogger reported a thread error C# exception when running: thrown: "invalid inter thread operation: access to the control" textBox1 "from a thread that is not creating it." (System.InvalidOperationException), you need to add the code System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false in Form1; It is forbidden to catch calls to the wrong thread. Summary: The blogger just briefly introduced the sending and receiving of C# SerialPort serial port control and demonstrated it. Students interested in this aspect can learn it. The blogger is only a beginner because he is working on a project recently. Few students learn C# and I hope you don't like it. It's not easy to create, praise, pay attention and comment.
https://programmer.group/sending-and-receiving-of-c-serialport.html
CC-MAIN-2022-40
refinedweb
1,376
52.66
This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project. Here is a (big) patch based on an idea that rth had back in April. Anthony forwarded me the patch, I mostly redid it but I kept the concept. Now that there's a nice testsuite it's time to revive it. > The intent here is to move the bulk of the runtime configury into per-cpu > header files instead of ifdefs in ffi.h. It also cleans up some namespace > issues, such that nothing that doesn't start with FFI_ or ffi_ is seen in > the header files. The only non-FFI_-prefixed symbols that remain are those for the target. Removing them is harder than it looks because some of them are used or even defined by the ffitarget.h files. All machine-dependent directories are modified for the new scheme. Unluckily I only tested on x86. Either the patch can be applied as is, with maintainers trying to fix the failures (if any), or people can send me the reports for failed platforms (or patches to make them build :-) and I can collect them and repost the patch. Of course I'd prefer the former... I have no copyright form for gcc yet, but libffi is not copyrighted FSF anyway. Paolo Attachment: libffi-reorg-patch.diff Description: Binary data
http://gcc.gnu.org/ml/gcc-patches/2003-09/msg01275.html
CC-MAIN-2017-09
refinedweb
230
74.9
Opened 7 years ago Closed 5 years ago #15896 closed Bug (wontfix) unittest docs say import django.utils, should be djanto.test Description At, it says: from django.utils import unittest It should import from django.test, no? It's wrong in the release notes too. The sample tests.py file gets it right. Change History (5) comment:1 Changed 7 years ago by comment:2 Changed 7 years ago by Hmm, OK, I read this a little more carefully and see what had me going. The docs say: from django.utils import unittest but the sample tests.py file says: from django.test import TestCase this is a little confusing. It would be more obvious if the sample and the docs did it the same way. comment:3 Changed 7 years ago by It's a different thing. django.utils.unittest is a copy of the unittest2 package for Python < 2.7. django.test holds Django's special testsuite helpers. In most cases you don't need to import anything from django.utils.unittest. It's just some kind of warning to prevent you from using import unittest. comment:4 Changed 5 years ago by A problem persists. The docs start by samples with from django.utils import unittest, but the example tests.py created by python manage.py startapp says from django.test import TestCase. That might confuse people starting to write tests. The docs do mention something about the difference, but only after a few pagefuls. comment:5 Changed 5 years ago by They really are two different things, used for two different purposes. I'm going to close this again; if you feel strongly, please take it to django-dev for discussion. Ever tried to do so?
https://code.djangoproject.com/ticket/15896
CC-MAIN-2018-30
refinedweb
291
79.26
0 Hello I'm currently working with my Java program here is my code: import java.util.Scanner; public class StringAct{ public static void main(String[]args){ Scanner inp=new Scanner(System.in); System.out.print("Enter string: "); String a= inp.nextLine(); if(a=="angel"){ System.out.print("Valid"); } else{ System.out.print("Not Valid"); } } } this program asks the user to enter a string, the string that the user should enter is equivalent to "angel" to display valid. If the user types other word it should display not valid and that's my problem with this code. Everytime I type angel it still displays not valid please help me with this thing. Thanks.
https://www.daniweb.com/programming/software-development/threads/445461/string-identifier-whether-valid-or-invalid
CC-MAIN-2018-13
refinedweb
113
68.26
Last Updated 19 Nov 2016 This document defines the processes and standards that all FLTK developers must follow when developing and documenting FLTK, and how trouble reports are handled and releases are generated. The purpose of defining formal processes and standards is to organize and focus our development efforts, ensure that all developers communicate and develop software with a common vocabulary/style, and make it possible for us to generate and release a high-quality GUI toolkit which can be used with a high degree of confidence. Much of this file describes the existing practices that have been used up through FLTK 1.1.x, however I have also added some new processes/standards to use for future code and releases. The fltk.coredev google mailing list and newsgroup is the primary means of communication between developers. All major design changes must be discussed prior to implementation. We use STRs (Software Trouble Reports) to manage bugs; please see STR Management for more info on how to manage STRs as a developer. It is wise to monitor these other NNTP based newsgroups as a developer: fltk.bugs -- all STR bug activity is logged here fltk.commit -- all SVN commits on the FLTK website are cc'ed here. Reason: makes it easy to see what other people are doing to the code, and simplifies peer reviewing of code changes fltk.admlog -- (optional) keep an eye on backups of the site files The specific goals of the FLTK are as follows: Many of these goals are satisfied by FLTK 1.1.x (*), and many complex applications have been written using FLTK on a wide range of platforms and devices. Development of the remaining features is proceding for FLTK 2.0 with a new, namespace-based API. While 2.0 offers some limited 1.x source compatibility, the changes to the underlying widget classes are significant enough to prevent full compatibility. All widgets are documented using the Doxygen software; Doxygen comments are placed in the header file for the class comments and any inline methods, while non-inline methods should have their comments placed in the corresponding source file. The purpose of this separation is to place the comments near the implementation to reduce the possibility of the documentation getting out of sync with the code. All widgets must have a corresponding test program which exercises all widget functionality and can be used to generate image(s) for the documentation. Complex widgets must have a written tutorial, either as full text or an outline for later publication The final manuals are formatted using the HTMLDOC software [link updated]. The FLTK build system uses GNU autoconf to tailor the library to the local operating system. Project files for major IDEs are also provided for Microsoft Windows®. To improve portability, makefiles must not make use of the unique features offered by GNU make. See the Makefile Standards FLTK. Source packages are created using the makesrcdist script in the Subversion repository. The script accepts one or two arguments: ./makesrcdist version ./makesrcdist snapshot Version should be of the form "1.1.10rc2". "rc2" in this case describes the second release candidate. The version name "snapshot" creates a snapshot of the Subversion repository without copying the release to the releases directory. Binary packages are not currently distributed by the FLTK team, however the fltk.spec and fltk.list files may be used to create binary packages on Linux, MacOS X, and UNIX. The fltk.spec file produces a binary package using the rpm software: rpmbuild -ta fltk-version-source.tar.gz The fltk.list file is generated by the configure script and produces binary packages for many platforms using the EPM software [link updated]. The portable-dist and native-dist targets of the top-level makefile create portable and native packages, respectively: make portable-dist make native-dist Future releases of FLTK may include files for use with Microsoft Visual Installer to produce .msi files for installation on Microsoft Windows®. FLTK releases are created on a Linux system with the following software installed: To test the release files, three systems will be required (or a single Intel Mac running Mac OS X, Windows, and Linux): Each software release provides three archives: The archives contain the source, ide, and build files, the documentation in a single PDF file, and the same documentation in many HTML files. The following steps are performed to create the release archives: Run the following commands to test the release: rpmbuild -ta fltk-version-source.tar.bz2 tar xvzf fltk-version-source.tar.gz cd fltk-version ./configure make all portable-dist native-dist cd test ./demo tar xvfz fltk-version-source.tar.gz cd fltk-version ./configure make all portable-dist native-dist cd test ./demo Extract the files from the .tar.gz archive and then open the ide/VisualC2010/fltk.sln file in Visual C. Build the demo target in both release and debug modes to confirm that the software compiles, and then run the demo target to test that each of the demo programs is functioning properly. The main fltk.org page should now show your new release in the "Quick Info". Software Trouble Reports ("STRs") are submitted every time a user or vendor experiences a problem with or wants a new feature in the FLTK software. STR reports are maintained in a database with one of the following states: Trouble reports are classified at one of the following levels by the submitter: Level 4 and 5 trouble reports are resolved in the next software release. Level 1 to 3 trouble reports are scheduled for resolution in a specific release at the discretion of the release coordinator. The scope of the problem is also identified as: New STRs are posted to the fltk.bugs forum for priority 2 to 5 and the fltk.development forum for priority 1 STRs. FLTK developers then discuss the STR and vote to form consensus as to a proposed resolution. If a general usage question is posted as a STR, any developer may immediately close the STR without resolution using the canned "support is not available" response which directs users to the fltk.general forum. During discussion, developers propose possible resolutions for the STR and vote to approve them. Each developer posts one vote of +1 (approve), -1 (veto), or 0 (abstain). At least three developers must vote on the proposal, and the total of all votes must be greater than 0. Once consensus is reached, the STR is assigned to a developer that volunteers to resolve the STR. The assigned developer summarizes the proposed changes in the STR and makes the required changes, attaching a diff of the changes to the STR as needed. The developer then notifies the submitter that the change has been applied and closes the STR when the resolution is confirmed by the submitter or after two weeks, whichever comes first. If the proposed changes do not resolve the problem, the developer may unassign the STR to continue discussions on the corresponding forum or privately discuss additional modifications with the submitter in order to resolve the STR. When closing the STR, the developer must set the fix version and the first Subversion revision number which contains the changes. When a developer decides to fix a particular bug in the STR system, the first step is to assign the STR to yourself, so that other developers don't also try to work on it at the same time. If you decide you can no longer work on the STR, unassign yourself from it and add a note accordingly. To assign an STR to yourself, be sure the website has you logged in to your developer account. Then, then when viewing the STR, choose "Modify STR" and modify these fields: Also, check that the following fields are correct according to what's best for this particular STR: When attaching patches, use 'diff -Naur' or 'svn diff', the latter preferred, as it includes FLTK version numbers, useful if years later someone tries to apply your patch. Try to include version#'s in patch filenames (e.g. foo_v1.patch, foo_v2.patch..) so followup patches are clear. When you've applied a fix to SVN, be sure to update the STR: FLTK uses a three-part version number separated by periods to represent the major, minor, and patch release numbers: MAJOR.MINOR.PATCH 2.0.0 2.0.1 2.0.2 2.1.0 Beta-test releases are indentified by appending the letter B to the major and minor release numbers followed by the build number: MAJOR.MINORbBUILD 2.0b1 2.0b2 2.1b1 Release candidates are indentified by appending the letters RC to the major and minor release numbers followed by the build number: MAJOR.MINORrcBUILD 2.0rc1 2.0rc2 2.1rc1 Subversion copies are created for release using the version number in the releases directory: /public/fltk/fltk/releases/release-2.0.0b1 /public/fltk/fltk/releases/release-2.0.0rc1 /public/fltk/fltk/releases/release-2.0.0 Subversion copies are created for every complete major or minor release in the branches directory: /public/fltk/fltk/branches/branch-2.0 /public/fltk/fltk/branches/branch-2.1 New development then continues in the trunk directory with fixes backported to the corresponding branches directory as needed. Each change that corrects a fault in a software sub-system increments the patch release number. If a change affects the overall software design of FLTK then the minor release number will be incremented and the patch release number reset to 0. If FLTK is completely redesigned the major release number will be incremented and the minor and patch release numbers reset to 0: 2.0b1 First beta of 2.0 2.0rc1 First release candidate of 2.0 2.0rc2 Second release candidate of 2.0 2.0.0 Production release of 2.0 2.0.1 First patch release of 2.0 2.0.2 Second patch release of 2.0 2.1b1 First beta of 2.1 2.1rc1 First release candidate of 2.1 2.1rc2 Second release candidate of 2.1 2.1.0 Production release of 2.1 3.0b1 First beta of 3.0 3.0rc1 First release candidate of 3.0 3.0rc2 Second release candidate of 3.0 3.0.0 Production release of 3.0 3.0.1 First patch release of 3.0 Software releases shall be generated for each successfully completed software trouble report. All object and executable files shall be deleted prior to performing a full build to ensure that source files are recompiled. Software testing shall be conducted according to the FLTK Software Test Plan (Editor's note: to be written, along with an automated/semi-automated test framework). Failed tests cause STRs to be generated to correct the problems found. When testing has been completed successfully a new distribution image is created by copying the current trunk or branches directory to the releases directory as specified previously. No release shall contain software that has not passed the appropriate software tests. Four types of releases are used, beta, release candidate, production, and patch, and are released using the following basic schedule: Beta releases are typically used prior to new major and minor version releases. At least one release candidate is generated prior to each production release. Beta releases are generated when substantial changes have been made that may affect the reliability of the software. Beta releases may cause loss of data, functionality, or services and are provided for testing by qualified individuals. Beta releases are an OPTIONAL part of the release process and are generated as deemed appropriate by the release coordinator. Functional changes may be included in subsequent beta releases until the first release candidate. Release candidates are generated at least two weeks prior to a production release. Release candidates are targeted for end-users that wish to test new functionality or bug fixes prior to the production release. While release candidates are intended to be substantially bug-free, they may still contain defects and/or not compile on specific platforms. At least one release candidate is REQUIRED prior to any production release. The distribution of a release candidate marks the end of any functional improvements. Release candidates are generated at weekly intervals until all level 4/5 trouble reports are resolved. Production releases are generated after a successful release candidate and represent a stable release of the software suitable for all users. Major Releases occur when there's a major rewrite of the code, or a significant redefinition of the API. Any FL_ABI_VERSION code should be resolved in Minor Releases. Any code that looks like: #if FL_ABI_VERSION >= 10401 ... new ABI breaking code ... #else ... old non-ABI breaking code ... #endif Patch releases are generated to fix priority 2-5 STRs. Patch releases may not add additional functionality from priority 1 STRs. Patch Releases fix small problems that don't break the ABI, and must be API backwards compatible. ABI breaking fixes/features can be added using FL_ABI_VERSION to #ifdef out the code from default builds, but can be optionally enabled by end users who need it for testing or for static builds. This can be done by using 'configure --with-abiversion=1xxyy' or CMake with its OPTION_ABI_VERSION to set this variable to the right ABI version number and re-building FLTK and their apps. For more information see README.abi-version.txt. This section describes how project files and directories are named and managed. Source files shall be placed under the control of the Subversion ("SVN") software. Source files shall be "checked in" with each change so that modifications can be tracked, and each check in must reference the applicable STRs that are affected, if any. The following format must be used for commit log messages: Summary of the change ("fix OpenGL double-buffer bug") along with corresponding STRs ("STR #1, STR #6") foo.cxx: - Detailed list of changes, by function - Include summary of design changes ("added new foo struct") bar.h: - More detailed changes Documentation on the Subversion software is available on-line. Each source file shall be placed a sub-directory corresponding to the software sub-system it belongs to ("fltk", "OpenGL", etc.) To remain compatible with case-insensitive filesystems, no two directory names shall differ only by the case of the letters in the name. Source files shall be documented and formatted as described in the Coding Standards section. To remain compatible with case-insensitive filesystems, no two filenames shall differ only by the case of the letters in the name. C source files shall have an extension of ".c". C++ source files shall have an extension of ".cxx". Header files shall have an extension of ".h" unless used for FLTK 1.x compatibility. FLTK 1.x compatibility headers shall have an extension of ".H". C++ source files can have any of the following extensions on various platforms: ".C", ".cc", ".cpp", ".cxx". Only the ".cxx" extension is universally recognized by C++ compilers as a C++ source file - ".C" is not usable on MacOS X and Windows, ".cc" is not usable on Windows, and ".cpp" is historically considered C preprocessor output on UNIX. Since not all make programs handle C++ source files with the ".cxx" extension, the FLTK build system explicitly defines makefile rules for compiling C++ source files with an extension of ".cxx". IDE/compiler support source files (project files, workspaces, makefiles, etc.) shall have extensions as required by the IDE/compiler tool. In addition to the source file requirements, all header files must utilitize so-called "guard" definitions to prevent multiple inclusion. The guard definitions are named using the full path in the FLTK source tree, e.g.: Any non-alphanumeric (letters and numbers) characters are replaced with the underscore (_) character, and leading and trailing underscores are added to limit global namespace pollution. Makefiles shall be documented and formatted as described in the Makefile Standards section. Static makefiles are named "Makefile". Makefiles created by the autoconf software are named "Makefile.in". The common include file for all makefiles is named "makeinclude.in". The following is a guide to the coding style that must be used when adding or modifying code in FLTK. Most of this should be obvious from looking at the code, but here it all is in one spot. The FLTK code basically follows the K&R coding style. While many of the developers are not entirely satisfied with this coding style, no one has volunteered to change all of the FLTK source code (currently about 54,000 lines of code!) to a new style. The K&R coding style can be summarized with the following example code: int function(int arg) { if (arg != 10) { printf("arg = %d\n", arg); return (0); } else { return 1; } } int function2(int arg) { for (int i=0; i<arg; i++) { stuff(); } while (something) { stuff(); } switch (arg) { case 0: stuff_here(); break; case 1: { int var; stuff_here(); break; } case 2: stuff(); /* FALLTHROUGH */ case 3: simple_stuff1(); break; case 4: simple_stuff2(); break; default: break; } return (0); } All curley braces must open on the same line as the enclosing statement, and close at the same level of indentation. Each block of code must be indented 2 spaces. If you use tabs, they must be set at every 8 character columns; this is different than the Microsoft standard of 4, but you can change that to match UNIX. A space also follows all reserved words. Each source: // // // or the equivalent comment blocking using the C comment delimiters. The end of each source file must have a comment saying: // // End of "$Id$". // or: /* * End of "$Id$". */ The purpose of the trailer is to indicate the end of the source file so that truncations are immediately obvious. FLTK 2.0 and FLTK 1.3 and up uses Doxygen with the JavaDoc comment style to document all classes, structures, enumerations, methods, and functions. Doxygen comments are mandatory for all FLTK header and source files, and no FLTK release will be made without complete documentation of public APIs. Here is an example of the Doxygen comment style: /** The Foo class implements the Foo widget for FLTK. This description text appears in the documentation for the class and may include HTML tags as desired. */ class FL_EXPORT Foo : public Widget { int private_data_; public: /** Creates a Foo widget with the given position and label. This description text appears in the documentation for the method's implementation. References to parameters \p X, \p Y, \p W, \p H are mentioned this way. \param[in] X,Y,W,H Position and size of widget \param[in] L Optional label (default is 0 for no label) */ Foo(int X, int Y, int W, int H, const char *L = 0) { ..implementation here.. } }; Essentially, a comment starting with /** before the class or method defines the documentation for that class or method. These comments should appear in the header file for classes and inline methods and in the code file for non-inline methods. In addition to Doxygen comments, block comments must be used liberally in the code to describe what is being done. If what you are doing is not "intuitively obvious to a casual observer", add a comment! Remember, you're not the only one that has to read, maintain, and debug the code. Never use C++ comments in C code files or in header files that may be included from a C program. (Otherwise builds on strict platforms like SGI will fail). Normally, fltk C files have ".c" and ".h" file extensions, and C++ have ".cxx" and ".H". Currently there are a few exceptions; filename.H and Fl_Exports.H both get interpreted by C and C++, so you must use C style /** for standard doxygen comments */ ///< for short single line post-declaration doxygen comments /** for standard doxygen comments */ /**< for short single line post-declaration doxygen comments */ /*! beware */ /*@ beware */ //! beware //@ beware /* safe from doxygen */ // safe from doxygen ^ /|\ | Space immediately after comment characters \< -- disambiguates html tags \> -- "" \& -- "" \@ -- disambiguates JavaDoc doxygen comments \$ -- disambiguates environment variable expansions \# -- disambiguates references to documented entities \% -- prevents auto-linking \\ -- escapes the escape character /** Here's a bullet list: - Apples - Oranges Here's a numbered list: -# First thing -# Second thing */ /** Here's a bullet list: <ul> <li> Apples</li> <li> Oranges</li> </ul> Here's a numbered list: <ol> <li> First thing</li> <li> Second thing</li> <ol> */ Temporary code and code that has a known issue MUST be documented in-line with the following (Doxygen) comment style: /** \todo this code is temporary */ \todo items are listed by Doxygen making it easy to locate any code that has an outstanding issue or code that should be removed or commented out prior to a release. Classes and structures start with a comment block that looks like the following: /** A brief description of the class/structure. A complete description of the class/structure. */ class MyClass { }; Enumerations start with a comment block that looks like the following: /** A brief description of the enumeration. A complete description of the enumeration. */ enum MyEnum { ... }; Each enumeration value must be documented in-line next to the corresponding definition as follows: /* C++ STYLE */ enum MyEnum { BLACK, ///< The color black. RED, ///< The color red. GREEN, ///< The color green. YELLOW, ///< The color yellow. BLUE, ///< The color blue. }; If the enum is included in a C file, be sure to use C style commenting: /* C STYLE */ enum MyEnum { BLACK, /**< The color black. */ RED, /**< The color red. */ GREEN, /**< The color green. */ YELLOW, /**< The color yellow. */ BLUE, /**< The color blue. */ }; Functions and methods start with a comment block that looks like the following: /** A brief description of the function/method. A complete description of the function/method. Optional passing mention of parameter \p a and \p out1. Optional code example goes here if needed: \code ..code showing how to use it.. \endcode \param[in] a Description of input variable a \param[in] x,y Description of input variables x and y in one comment \param[out] out1 Description of output variable out1 \param[out] out2 Description of output variable out2 \return 0 on success, -1 on error \see other_func1(), other_func2() */ int my_function(int a, int x, int y, float &out1, float &out2) { ...implementation... } Parameters \param var Some description \param[in|out] var Some description. Note: Doxygen checks your \param variable names against the actual function signatures in your code. It does NOT check \p names for consistency. Return Values Use \see to help the reader find related methods. (Methods are sorted alphabetically by doxygen, so 'related' methods might not appear together) Locate \see references below \param[] and \return as shown in the above example. Be careful not to embed C style comments within \code or it will break the outer doxygen comment block. (A good reason to always test build the code base before commiting documentation-only mods) /** A brief doxygen description of the member/variable. A complete description of the member/variable. More text goes here.. */ int my_variable_; int my_variable1_; ///< C++ file's brief doxygen description of the member/variable int my_variable2_; /**< C file's brief doxygen description of the member/variable */ The goal of FLTK is to provide a robust GUI toolkit that is small, fast, and reliable. All public API functions and methods must be documented with the valid values for all input parameters - NULL pointers, number ranges, etc. - and no public API function may have undefined behaviors. Input validation should be performed only when the function or method is able to return an error to the caller. NULL When solving a particular problem, whether you are writing a widget or adding functionality to the library, please consider the following guidelines: Since FLTK is targeted at platforms which often lack complete ISO C++ support or have limited memory, all C++ code in FLTK must use a subset of ISO C++. FLTK These restrictions shall be reviewed prior to each major release of FLTK. The following C++ features may be not used in FLTK 1.1.x code: The following C++ features may be not used in FLTK 2.0.x code: The static_cast and const_cast keywords must be used in 2.0.x code when casting pointers of different types. The dynamic_cast keyword must not be used since run-time typing features are not be available at all times. The current practice is to use an extension of ".c" for C source files, ".h" for C header files, ".cxx" for C++ source files, and ".H" for C++ header files in the "FL" directory (".h" otherwise.) All public (exported) functions and variables must be placed in the "fltk" namespace. Except for constructor and destructor methods, the names consist of lowercase words separated by the underscore ("_"), e.g. "fltk::some_variable" and "text_color()". Private member variables of classes end with an extra underscore, e.g. "text_size_". All public (exported) structures and classes must be placed in the "fltk" namespace and consist of capitalized words without the underscore, e.g. "fltk::SuperWidget". Private members of classes must end with a trailing underscore ("_") and have corresponding public access methods without the underscore as applicable, e.g. "text_size_" and "text_size()". Public enumerations and constant variables must be placed inside the "fltk" namespace and consist of UPPERCASE WORDS separated by the underscore ("_"), e.g. "ALIGN_LEFT", "COLOR_RED", etc. Enumeration type names consist of capitalized words without underscores, e.g. "MyEnum". #define constants are prohibited aside from the include guard definitions. #if defined(WIN32) #elif defined(__APPLE__) #else .. Xlib specific code ... #endif #if defined(__APPLE__) || defined(FL_DOXYGEN) ... Doxygen-visible, Mac-specific code ... #endif Note: This preprocessor variable was named FLTK_ABI_VERSION in FLTK 1.3.x and was renamed to FL_ABI_VERSION since FLTK 1.4.0. When set, the variable's value is expected to be the integer representation of the FLTK version number, where the Minor and Patch numbers are padded to 2 digits to allow for numbers 1 thru 99, e.g. #define FL_ABI_VERSION 10401 // FLTK version 1.4.1 ..'1' is the major version (no padding; avoids octal issues) ..'04' is the minor version (2 digit padding) ..'01' is the patch version (2 digit padding) Example: If the current patch release is 1.4.0, and the developer adds an ABI-breaking fix to what will be the next 1.4.1 release, then the new code would be implemented as: #if FL_ABI_VERSION >= 10401 // FLTK 1.4.1, the next patch release # ... new ABI breaking code ... #else ... old non-ABI breaking (default builds) ... #endif VERSION MACRO PRODUCT NAME ------- ---------------- -------------------- Visual Studio 7 MSVC++ 6.0 _MSC_VER == 1200 Visual Studio 6 MSVC++ 5.0 _MSC_VER == 1100 Visual Studio 5 #if defined(_MSC_VER) && (_MSC_VER <= 1300) /* VS7 and older */ .. #else /* _MSC_VER */ .. #endif /* _MSC_VER */ These are made available from Apple's AvailabilityMacros.h. For more info on these and other macros, see Apple's "TechNote 2064". VERSION MACRO VALUE PRODUCT NAME ------- --------------------- ----- -------------------- 10.0 MAC_OS_X_VERSION_10_0 1000 Cheetah 10.1 MAC_OS_X_VERSION_10_1 1010 Puma 10.2 MAC_OS_X_VERSION_10_2 1020 Jaguar 10.3 MAC_OS_X_VERSION_10_3 1030 Panther 10.4 MAC_OS_X_VERSION_10_4 1040 Tiger 10.5 MAC_OS_X_VERSION_10_5 1050 Leopard 10.6 MAC_OS_X_VERSION_10_6 1060 Snow Leopard 10.7 MAC_OS_X_VERSION_10_7 1070 Lion 10.8 MAC_OS_X_VERSION_10_8 1080 Mountain Lion 10.9 MAC_OS_X_VERSION_10_9 1090 Mavericks 10.10 MAC_OS_X_VERSION_10_10 101000 Yosemite 10.11 MAC_OS_X_VERSION_10_11 101100 El Capitan 10.12 MAC_OS_X_VERSION_10_12 101200 Sierra etc.. #include <FL/x.H> // defines the MAC_OS_X_VERSION_10_xx macros #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) if (fl_mac_os_version >= 100500) { ..10.5 and newer.. } else #else { ..10.4 and older.. } #endif The following is a guide to the makefile-based build system used by FLTK. These standards have been developed over the years to allow FLTK to be built on as many systems and environments as possible. The FLTK source code is organized functionally into a top-level makefile, include file, and subdirectories each with their own makefile and depedencies files: Makefile.in configh.in configure.in makeinclude.in FL Makefile.in *.H fltk *.h fluid Makefile makedepend *.h *.c *.cxx src Makefile makedepend *.h *.c *.cxx test Makefile makedepend *.h *.c *.cxx The ".in" files are template files for the autoconf software and are used to generate a static version of the corresponding file. Each make: # # # The end of each makefile must have a comment saying: # # End of "$Id$". # The purpose of the trailer is to indicate the end of the makefile so that truncations are immediately obvious. FLTK uses a common subset of make program syntax to ensure that the software can be compiled "out of the box" on as many systems as possible. The following is a list of assumptions we follow when constructing makefiles: target: target commands target: foo bar target commands foo: bla foo commands bar: bar commands bla: bla commands name=value .SUFFIXES: .c .o .c.o: $(CC) $(CFLAGS) -o $@ -c $< include ../makeinclude include makedepend The following variables are defined in the "makeinclude" file generated by the autoconf software: The following standard targets must be defined in each makefile: Object files (the result of compiling a C or C++ source file) have the extension ".o". Program files (the result of linking object files and libraries together to form an executable file) have the extension specified by the $(EXEEXT) variable. A typical program target looks like: program$(EXEEXT): $(OBJECTS) echo Linking $@... $(CXX) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBS) Static libraries have a prefix of "lib" and the extension ".a". A typical static library target looks like: libname.a: $(OBJECTS) echo Creating $@... $(RM) $@ $(AR) $(ARFLAGS) $@ $(OBJECTS) $(RANLIB) $@ Shared libraries have a prefix of "lib" and the extension ".dylib", ".sl", ".so", or "_s.a" depending on the operating system. A typical shared library is composed of several targets that look like: libname.so: $(OBJECTS) echo $(DSOCOMMAND) libname.so.$(DSOVERSION) ... $(DSOCOMMAND) libname.so.$(DSOVERSION) $(OBJECTS) $(RM) libname.so libname.so.$(DSOMAJOR) $(LN) libname.so.$(DSOVERSION) libname.so.$(DSOMAJOR) $(LN) libname.so.$(DSOVERSION) libname.so libname.sl: $(OBJECTS) echo $(DSOCOMMAND) libname.sl.$(DSOVERSION) ... $(DSOCOMMAND) libname.sl.$(DSOVERSION) $(OBJECTS) $(RM) libname.sl libname.sl.$(DSOMAJOR) $(LN) libname.sl.$(DSOVERSION) libname.sl.$(DSOMAJOR) $(LN) libname.sl.$(DSOVERSION) libname.sl libname.dylib: $(OBJECTS) echo $(DSOCOMMAND) libname.$(DSOVERSION).dylib ... $(DSOCOMMAND) libname.$(DSOVERSION).dylib \ -install_name $(libdir)/libname.$(DSOMAJOR).dylib \ -current_version libname.$(DSOVERSION).dylib \ -compatibility_version $(DSOMAJOR).0 \ $(OBJECTS) $(LIBS) $(RM) libname.dylib $(RM) libname.$(DSOMAJOR).dylib $(LN) libname.$(DSOVERSION).dylib libname.$(DSOMAJOR).dylib $(LN) libname.$(DSOVERSION).dylib libname.dylib libname_s.a: $(OBJECTS) echo $(DSOCOMMAND) libname_s.o ... $(DSOCOMMAND) libname_s.o $(OBJECTS) $(LIBS) echo $(LIBCOMMAND) libname_s.a libname_s.o $(RM) $@ $(LIBCOMMAND) libname_s.a libname_s.o $(CHMOD) +x libname_s.a Static dependencies are expressed in each makefile following the target, for example: foo: bar Static dependencies shall only be used when it is not possible to automatically generate them. Automatic dependencies are stored in a file named "makedepend" and included at the end of the makefile. The following "depend" target rule shall be used to create the automatic dependencies: depend: $(CPPFILES) $(CFILES) $(MAKEDEPEND) -Y -I.. -f makedepend $(CPPFILES) $(CFILES) We only regenerate the automatic dependencies on a Linux system and express any non-Linux dependencies statically in the makefile. All makefiles must contain install and uninstall rules which install or remove the corresponding software. These rules must use the $(BUILDROOT) variable as a prefix to any installation directory so that FLTK can be installed in a temporary location for packaging by programs like rpmbuild. The $(INSTALL_BIN), $. erco 3/13/09: I do like when (*)s run down left margin of all comments; easier to differentiate comments from code in large doc blocks. matt 3/14/09: Yes, same here. I usually align them in the second column. erco 3/15/09: Duncan doesn't like (*)s down the left because it complicates paragraph reformatting.. passing that on. erco 3/15/09: Albrecht says this was already discussed and decision was *no stars* down the left, so I modified the examples here to follow this rule. erco 3/15/09: Note: fltk2 uses QT /*! style comments, whereas fltk1 uses /** as described above. Should standard reflect this? erco 07/18/10: We seem to be going with /** style comments, no (*)s running down left margin (as per Duncan's sugg).
http://fltk.org/cmp.php
CC-MAIN-2017-51
refinedweb
5,326
57.06
31 August 2012 07:11 [Source: ICIS news] SINGAPORE (ICIS)--?xml:namespace> The time of the restart will be determined by market conditions and relocation plan of the plant, the company said in a statement to the Shanghai Stock Exchange. The company’s 75%-held subsidiary Jiangsu Danhua Aceticananhydride - also operator of the plant - suffered a 60% year on year drop of both sales and production of acetic anhydride in the first half of the year, the statement said. The subsidiary posted a loss of CNY25.6m ($4m) in the first half of the current year, it added. Due to overall development plan of Danyang city, the company’s acetic anhydride plant will be relocated to the outskirts of its existing urban site. However, timeframe and location have not been finalised yet, a company official told IC
http://www.icis.com/Articles/2012/08/31/9591498/chinas-danhua-chemical-shuts-acetic-anhydride-unit-on-soft-demand.html
CC-MAIN-2014-42
refinedweb
137
61.06
IRC log of tagmem on 2003-08-04 Timestamps are in UTC. 18:55:29 [RRSAgent] RRSAgent has joined #tagmem 18:55:47 [Ian] Ian has changed the topic to: 18:56:13 [Norm] 04-tag.html? Not just 04-tag? 18:58:29 [Ian] You can drop .html 19:00:49 [Ian] zakim, this is TAG 19:00:49 [Zakim] Ian, I see TAG_Weekly()2:30PM in the schedule but not yet started. Perhaps you mean "this will be TAG". 19:00:52 [Ian] zakim, this is TAG 19:00:52 [Zakim] Ian, I see TAG_Weekly()2:30PM in the schedule but not yet started. Perhaps you mean "this will be TAG". 19:00:52 [Ian] zakim, this is TAG 19:00:53 [Zakim] Ian, I see TAG_Weekly()2:30PM in the schedule but not yet started. Perhaps you mean "this will be TAG". 19:00:58 [Ian] zakim, this will be TAG 19:00:58 [Zakim] ok, Ian; I see TAG_Weekly()2:30PM scheduled to start 30 minutes ago 19:01:04 [Ian] zakim, call Ian-BOS 19:01:04 [Zakim] ok, Ian; the call is being made 19:01:05 [Zakim] TAG_Weekly()2:30PM has now started 19:01:07 [Zakim] +Ian 19:01:34 [Zakim] +??P0 19:01:37 [Zakim] -Ian 19:01:38 [Zakim] +Ian 19:01:52 [Ian] zakim, ??P0 is Roy 19:01:52 [Zakim] +Roy; got it 19:02:11 [Zakim] +??P1 19:02:30 [Ian] zakim, ??P1 is TimBray 19:02:30 [Zakim] +TimBray; got it 19:03:04 [Stuart] Stuart has joined #tagmem 19:03:21 [Stuart] Just about to dial in.... 19:03:45 [Zakim] +Norm 19:03:59 [Norm] Zakim, who's on the phone? 19:03:59 [Zakim] On the phone I see Ian, Roy, TimBray, Norm 19:04:16 [Ian] Regrets: DO, DC, PC? 19:04:24 [Ian] NW: Yes 19:04:24 [Zakim] +??P3 19:04:33 [Ian] zakim, ??P3 is Stuart 19:04:33 [Zakim] +Stuart; got it 19:04:42 [Chris] Chris has joined #tagmem 19:04:53 [Chris] I am just joining 19:05:14 [Chris] but will be muted - the cooling fan/air conditioner is load, but also vital 19:05:41 [Chris] zakim, passcode? 19:05:41 [Zakim] the conference code is 0824, Chris 19:05:54 [Zakim] + +1.334.933.aaaa 19:05:59 [Chris] zakim, mute me 19:06:00 [Zakim] sorry, Chris, I do not see a party named 'Chris' 19:06:01 [Norm] Welcome, Chris 19:06:51 [Stuart] zakim, who is here? 19:06:51 [Zakim] On the phone I see Ian, Roy, TimBray, Norm, Stuart, +1.334.933.aaaa 19:06:52 [Ian] zakim, aaaa is Chris 19:06:52 [Zakim] On IRC I see Chris, Stuart, RRSAgent, Norm, Zakim, Ian 19:06:53 [Zakim] sorry, Ian, I do not recognize a party named 'aaaa' 19:07:21 [Chris] zakim, +1.33 is Chris 19:07:21 [Zakim] +Chris; got it 19:07:51 [Chris] zakim, my phone does not start with +1 but +33.... 19:07:51 [Zakim] I don't understand 'my phone does not start with +1 but +33....', Chris 19:08:22 [Ian] Roll call: CL, SW (Chair), NW, IJ, TB, RF. Regrets: DO, DC, PC 19:08:24 [Ian] Missing: TBL 19:08:54 [Ian] Resolved; Accept 19:09:16 [Ian] Action IJ: Make these minutes public. 19:09:28 [Ian] Accept the 28 Jul teleconf minutes? 19:09:35 [Ian] 19:09:35 [Norm] Ian says...oh, nevermind :-) 19:09:59 [Ian] Nobody has read 28 Jul minutes; held over. 19:10:11 [Ian] Agenda: 19:10:44 [Ian] SW: Continue walkthrough where we left off, or review 1 Aug draft? 19:11:09 [Ian] TB: I have dozens of dozens of editorial issues re: 1 Aug draft, but I think that up to about 2.5 it reflects where we got to. 19:12:43 [Zakim] -TimBray 19:13:16 [Ian] ---- 19:13:26 [Ian] Next meeting? 19:13:39 [Ian] SW: Lots of regrets for 11 August. I recall RF and IJ said they might meet at that time. 19:14:31 [Ian] No meeting 14 August. 19:15:02 [Ian] 18 Aug regrets: TBL, IJ; possible regrets from DO, PC. 19:15:17 [Ian] 25 Aug regrets: TBL, IJ, SW; possible regrets from DO, PC. 19:15:36 [Ian] 8 Sep regrets: TBL, IJ 19:15:48 [Zakim] +??P1 19:15:51 [Ian] Next meeting: 18 Aug teleconf. Regrest TBL, IJ. Need a scribe. 19:15:56 [Ian] zakim, P1 is TBray 19:15:56 [Zakim] sorry, Ian, I do not recognize a party named 'P1' 19:16:04 [Ian] zakim, ??P1 is TBray 19:16:04 [Zakim] +TBray; got it 19:16:13 [Ian] ---- 19:16:22 [Ian] Resuming Arch Doc review from where we left off at ftf meeting. 19:17:06 [Ian] Left off in extensibility and versioning section. 19:18:03 [Ian] CL: using screen grab for svg to png. 19:18:15 [Chris] for one offs, yes 19:18:57 [Ian] ---- 19:19:19 [Chris] can anyone hear me? 19:19:22 [Norm] yes 19:19:30 [Ian] SW: I will be organizing ftf meeting in Bristol 6-8 Oct. 19:19:32 [Chris] i can't hear anyone else 19:19:34 [Ian] Chris, we are talking to you. 19:19:37 [Ian] You can't hear us. 19:19:50 [Chris] correct 19:20:00 [Ian] TB: Recall that for ftf meeting we want to set up time for video link (at best) and telephone link (at worst). 19:20:03 [Zakim] -Chris 19:20:04 [Ian] TB: Especially for TBL. 19:20:10 [Ian] (DC sent regrets) 19:20:38 [Zakim] +Chris 19:21:15 [Ian] ---- 19:21:17 [Ian] Action item review 19:25:03 [Ian] Review of open actions; not of which have been completed. 19:25:35 [Ian] ---- 19:26:05 [Ian] Review of effect of completed actions 19:26:17 [Ian] 2.1 19:26:52 [Ian] . 19:26:52 [Ian] " 19:27:07 [Ian] Completed action IJ 2003/07/21: Reword the good practice note with new term for "spelling" based on "character string". 19:27:33 [Ian] "URI characters: If a URI has been assigned to a resource, Web components SHOULD refer to the resource using the same URI, character for character." 19:28:18 [Ian] --- 19:28:30 [Ian] IJ: What about using "Web component" instead of "agent" change? 19:28:32 [Ian] CL: Seems ok to me. 19:28:39 [Ian] TB: I think that's probably worth doing as well. 19:28:51 [Ian] TB: I won't stand for the term human component! These are people! 19:29:48 [Ian] Completed action IJ 2003/07/21: Prune instances of "scheme name" except when referring to string component before ":"; RF calls this "scheme component". 19:30:01 [Ian] Completed action IJ 2003/07/21: Include POST (and other methods) as examples of deref methods at beginning of 2.5. 19:31:41 [Ian] NW's new 4.6 19:31:52 [Ian] 19:32:09 [Ian] Continuing where we left off: 19:33:53 [Stuart] q? 19:34:23 [Ian] We last were talking about extensibility at ftf meeting. 19:35:23 [Ian] CL: Recall that I have an objection to the phrase "final form" 19:36:01 [Ian] (On 4.6) 19:36:01 [Ian] TB: I am more and more nervous about 4.6 since topic of composition is new. 19:36:16 [Ian] CL: I agree, but we need something to work with. We already have some (positive and negative) experience. 19:36:26 [Ian] RF: What about putting this in the "future work" section? 19:36:40 [Ian] TB: I think that it's fine to point out some of the known issues. 19:36:49 [Ian] TB: The issues in XML are not yet worked out. 19:37:04 [Ian] TB: Don't be too sanguine about expanding this much more than is already there. 19:37:28 [Chris] unless its to enumerate more known problems 19:39:07 [Ian] 4.7 extensibility and versioning. 19:39:13 [Ian] CL: Swap 4.6 and 4.7 19:39:38 [Ian] TB: I agree. 19:39:40 [Ian] NW: Yep 19:40:09 [Ian] TB: I disagree with definition "A format is extensible if instances of the format can include terms from other vocabularies. " 19:40:44 [Ian] TB: There is a lot more than than adding elements. 19:40:53 [Ian] CL: There is ambiguity about word "Vocabulary." 19:41:04 [Chris] by that definition xml is not extensible 19:41:14 [Ian] NW: DO and I have a finding in the work on this. I propose that we leave this until the finding has moved along. 19:41:20 [Chris] (which could be fine - xml is a user restrictable vocabulary) 19:41:44 [Ian] TB: However, I think the second and third called out principles are excellent and I wouldn't want to lose them. 19:41:53 [Ian] TB, SW: Delete first principles; it's subsumed. 19:42:21 [Ian] IJ: How is your finding going in terms of defn of compatibility? 19:42:26 [Ian] NW: More prose than algorithm. 19:43:03 [Chris] instead of M and N, perhaps n, n+1, n-1 ? 19:44:19 [Ian] 4.8. Presentation, Content, and Interaction 19:45:15 [Ian] CL: I am still working on text for this section. 19:45:36 [Ian] [Will be a summary of long essay I previously sent.] 19:45:53 [Ian] 4.9. Hyperlinks 19:47:07 [Ian] NW: I'd like to change editorially "Allow Web-wide linking, not just internal document linking." 19:47:14 [Ian] CL: Split in two. 19:47:30 [Ian] TB: Yes, split. 19:48:06 [Ian] TB: Does last good practice note belong here or in XML section? 19:48:35 [Ian] NW: N3 uses qnames as well. 19:49:41 [Ian] SW: Do we need to distinguish hyperlinking from other kinds of linking? 19:49:42 [Ian] CL: Yes. 19:50:04 [Ian] IJ: Do we have a defn of hyperlink v. link that is not a horrible rat hole? 19:50:06 [Ian] TB, CL: No. 19:50:37 [Ian] TB: We should ack the fact that much of this section that much of the text applies to hyperlinks in XML. 19:51:21 [Ian] IJ: +1 to creating a generic hyperlink section and an xml-specific hyperlink section. 19:51:26 [Ian] NW, TB, CL: Yes. 19:52:01 [Ian] IJ: How does hyperlinking connect to "on the Web"? 19:53:14 [Chris] are embedded links (images etc) hyperlinks 19:53:28 [Ian] TB: I don't think we need to have a firm defn of hyperlink in this document. 19:53:38 [Ian] CL: Are embedded images hyperlink? 19:53:48 [Ian] CL: Are all hyper links user-activated? 19:53:51 [Chris] are all hyperlinks user actuated 19:54:44 [Ian] NW: I share SW's concern. I'm happy to break 4.9 in two and take a stab at defining hyperlink as well. 19:56:15 [Ian] TB: I think we can get away with "When you go and implement something you think is a hyperlink, do this..." and we'll be fine. 19:56:25 [Ian] 4.10. XML-Based Data Formats 19:56:29 [Ian] CL: I don't like "XML-based". 19:57:07 [Ian] TB: I have found no better term than XML-based. 19:57:21 [Ian] TB: I suggest leaving title as is and define what we mean in the first paragraph. 19:57:25 [Ian] CL: That's fine by me. 19:57:41 [Ian] Action TB: Write a definition of "XML-based". 19:58:02 [Ian] IJ: Does "XML Application" connote something different? 19:58:07 [Zakim] -Roy 19:58:20 [Ian] TB: Actually, more commonly it's an XML vocabularly. 19:58:41 [Chris] I mainly want to exclude 'similar to' xml, like using * instead of " for delimiting attributes and saying the syntax is 'based on' xml 19:58:45 [Ian] TB: In formal terms in the XML spec, "XML application" means anything that talks to an XML processor. 19:59:03 [Ian] TB: So, SVG is an XML vocabulary not an XML application. 19:59:08 [Chris] yes 19:59:34 [Ian] 4.10.1. When to Use an XML-Based Format 19:59:42 [Ian] Editor's note: Which XML Specifications make up the XML Family? 19:59:51 [Ian] TB: Delete that note; this is not crucial to the arch of the web. 20:00:03 [Ian] Resolved: Delete the note. 20:00:17 [Ian] 4.10.2. XML Namespaces 20:00:30 [Ian] TB: We need a consistent formatting when we drop into story mode. 20:01:32 [Ian] TB: Cite "title" element specifically. 20:02:10 [Ian] IJ: I also deleted a lot of prose I found confusing. 20:02:16 [Ian] IJ: Any good practice notes belong here? 20:02:38 [Zakim] +??P0 20:02:56 [Ian] TB: We need a good practice note in 4.10.2: When designing a new XML vocabularly, put in its own namespace. 20:03:02 [Ian] CL: Much more important for elements than attributes. 20:03:06 [Ian] zakim, ??P0 is Roy 20:03:06 [Zakim] +Roy; got it 20:03:22 [Ian] TB: Given that everyone is wrapping content in SOAP, not having a namespace is a problem. 20:03:36 [Ian] CL: Formatting attribs in xsl:fo should have been given a namespace. 20:03:41 [Zakim] -TBray 20:04:39 [Ian] Action NW: Redraft 4.10.2 to include some good practice notes (e.g., use namespaces!) 20:05:44 [Ian] 4.10.3. Namespace Documents 20:05:56 [Chris] fot attribute values, especially ones that are inherited 20:06:26 [Ian] IJ: I added "machine-readable" to good practice note. 20:07:21 [Chris] Dan googles on the namespace URI and gets back ..... 20:07:24 [Ian] RF: I think "machine-readable" is a meaningless statement. 20:08:03 [Ian] IJ: In UAAG we talked about "content primarily intended for people" v. "primarily intended for processors" 20:08:11 [Ian] RF: Say "optimized for machines." 20:08:21 [Ian] CL: I think the "unattended" part is the key bit. 20:08:29 [Ian] CL: A DTD is suitable for unattended processing. 20:08:46 [Ian] Optimized for processors. 20:10:34 [Ian] IJ: I'd like to find a short phrase AND include "unattended" in a definition. 20:11:07 [Ian] Action IJ: s/machine-readable/something like: optimized for processors, w/ defn that includes notion that it can be processed unattended (by a person). 20:11:22 [Ian] 4.10.4. Fragment identifiers and ID semantics 20:11:56 [Ian] NW: Third para goes to some length to saqy that there is no semantics for +xml media types. We should note that that may change if RFC3023 changes. 20:12:17 [Ian] NW: Allude to the fact that we may someday get there. 20:12:37 [Zakim] +TimBL 20:12:40 [Ian] NW: In para starting "It is common practice...."; s/DTD validation/validation/ 20:13:08 [timbl_] timbl_ has joined #tagmem 20:14:03 [Chris] see finding on xmlid-32 20:14:10 [timbl_] RRSAgent, pointer? 20:14:10 [RRSAgent] See 20:14:11 [Norm] s/DTD// and fix the grammar 20:14:14 [Norm] :-) 20:14:19 [Chris] type ID 20:14:31 [Ian] Action NW: Rewrite para 4 of 4.10.4. 20:14:40 [Ian] 4.10.5. Media Types for XML 20:14:54 [Chris] norm, see the canonical example 20:14:55 [Chris] <?xml version="1.0" encoding="UTF-8"?> 20:14:55 [Chris] <!DOCTYPE foo [ 20:14:55 [Chris] <!ATTLIST foo partnum ID #IMPLIED> ]> 20:14:55 [Chris] <foo partnum="i54321" bar="toto"/> 20:16:38 [Ian] 4.11. Future Directions for Representations and Formats 20:18:00 [Norm] Editorially in 4.10.5, check markup for "text/*" in the good practice note 20:18:36 [Ian] CL: Put 4.10.5 good practice note at the END of the section. 20:18:42 [Ian] NW: Yes, much better. 20:19:40 [Ian] CL: Also be more precise that intermediaries can only transcode in case of text/xml. 20:20:12 [Norm] They can transcode text/*, technically, yes? 20:20:13 [Ian] CL: Furthermore, append "and will cause the document to not be well-formed." 20:20:54 [Ian] 3. Interaction 20:20:56 [Zakim] + +1.949.679.aabb 20:20:58 [Zakim] -Roy 20:21:01 [Ian] 20:21:07 [Ian] zakim, aabb is Roy 20:21:07 [Zakim] sorry, Ian, I do not recognize a party named 'aabb' 20:21:12 [Ian] zakim, +aabb is Roy 20:21:12 [Zakim] sorry, Ian, I do not recognize a party named '+aabb' 20:21:20 [Ian] zakim, +1.949 is Roy 20:21:20 [Zakim] +Roy; got it 20:21:48 [Norm] There are several more places where I think <code> markup would improve things 20:23:01 [Ian] CL: Please shorten 3.0. 20:23:20 [Ian] IJ: It's all story. 20:23:28 [Ian] CL: But it collects things and these need to be brough tout. 20:23:31 [Ian] brought out. 20:23:55 [Ian] CL: There's a diagram here: browser gets octets and media type; can interpret octets given media type. 20:24:29 [Ian] CL: Talk about layers here. 20:24:38 [Ian] IJ: Would these layer be important to the arch? 20:24:40 [Ian] CL: Yes. 20:24:59 [Ian] RF: "Some of the headers (for example, 'Transfer-encoding: identity', which indicates that no compression has been applied)" 20:25:11 [Ian] RF: There is no "identity" encoding. 20:25:23 [Ian] RF: You would simply not see any transfer-encoding header. 20:25:28 [Ian] RF: That header field is not just for compression 20:25:56 [Ian] IJ: What about "(e.g., Transfer-encoding)"? 20:25:58 [Ian] RF: Yes. 20:26:13 [Ian] IJ: Other examples you'd like to see there? 20:26:16 [Ian] RF: No. 20:27:04 [Ian] CL: Fine with only 'Transfer-encoding'. 20:27:20 [Ian] RF: I am wondering whether we need more intro before the story. 20:27:35 [Stuart] s/SW/RF 20:27:56 [Ian] IJ: What about putting 3.1 before the story? 20:28:02 [Ian] CL: Yes, that lets you use the terms in the story. 20:29:00 [Ian] RF: Para 3 of Interaction doesn't talk about resource header fields. E.g., "vary" is about the response, not the representation. 20:29:13 [Ian] TBL: Yes, I think we should make that distinction. 20:30:20 [timbl_] Message, Representation, and Resource 20:30:37 [timbl_] 3 things 20:30:40 [Ian] RF: There are always three things: rep metadata, res metadata, and message metadata. 20:30:53 [Ian] IJ: Where should we talk about resource metadata? 20:31:09 [Ian] RF: Etag is representation. 20:31:19 [Ian] RF: Alternates is resource metadata 20:31:27 [timbl_] Examples of Resource: Alternates, Vary 20:31:42 [timbl_] Examples of Representation; Etag 20:32:41 [Ian] SW: 20:33:01 [Ian] Message contains data and metadata. There are three types of metadata (resource, msg, representation) 20:33:17 [timbl_] 1. Data 2. Metadata 20:33:29 [Ian] IJ: Before we said that representation includes some of the representation metadata. 20:33:39 [timbl_] 2.1 message metadata 2.2. represtentaion metadat 2.3 resourcemetadata 20:33:57 [Chris] message metadata is transitory 20:34:35 [Chris] message metadata is clearly part of the interaction (only) 20:34:54 [Chris] resource metadata is not about the representation, so its in the interaction section also 20:35:22 [Chris] thus, only representation metadata is in the formats section 20:37:09 [timbl_] q+ to say "about" means very little. 20:38:16 [Ian] RF: I'm going to rewrite the whole section anyway... 20:38:37 [Ian] TBL: There are more meanings than "about"; metadata describes relationships. 20:39:39 [Ian] IJ: I'd prefer slightly longer terms than just "data" since that leads to "Which data? Message data or representation data?" 20:39:41 [Ian] ADJOURNED 20:39:42 [Zakim] -Norm 20:39:43 [Zakim] -Roy 20:39:44 [Zakim] -Stuart 20:39:48 [Zakim] -Chris 20:39:49 [Zakim] -Ian 20:39:51 [Zakim] -TimBL 20:39:52 [Zakim] TAG_Weekly()2:30PM has ended 20:42:02 [Stuart] Stuart has left #tagmem 20:42:24 [Chris] rrsagent, bye 20:42:24 [RRSAgent] I see no action items
http://www.w3.org/2003/08/04-tagmem-irc.html
CC-MAIN-2013-48
refinedweb
3,496
75.4
Reflection a method at runtime. To me it opens a door into infinate unknown teritory. It would be possible to write a program without even knowing what it will do, I.e. just write it, run it and see what it does. I digress. Reflection exposes an IEnumerable interface, therefore it is querible from LINQ. You can check out an article I wrote about Generics in the fundamental section in this website. So lets write a small method that loads a .Net assembly and finds all the methods within it. I have recently been checking out ODP.NET so lets use the Oracle.DataAccess.dll assembly and see what methods it exposes for us to use. Be sure to put the Oracle.DataAccess.dll in the working directory of your project, otherwise the program you write can not find it. Or simply add a reference to it. using System; using System.Linq; using System.Reflection; namespace LinqToReflection { class Program { static void Main(string[] args) { Assembly asmembly = Assembly.Load("Oracle.DataAccess"); var ODPTypes = from type in asmembly.GetTypes() where type.IsPublic from method in type.GetMethods() where method.ReturnType.FullName != "System.String" group method.ToString() by type.ToString(); foreach (var ODPMethods in ODPTypes) { Console.WriteLine("Type: {0}", ODPMethods.Key); foreach (var method in ODPMethods) { Console.WriteLine(" {0}", method); } } Console.ReadLine(); } } } We load the assembly using the Assembly.Load method passing it the .dll’s string name. We then loop through all the assembly Types. Types will provide you with the names of the classes that exist within the assembly. Once we get the name of all the class types, we query through classes to get all the methods they expose. If we wanted to, we could then find the parameters for each function and then dynamically use the method.
https://www.thebestcsharpprogrammerintheworld.com/2017/01/29/using-linq-with-reflection-in-c/
CC-MAIN-2020-29
refinedweb
298
63.36
ITT: Relationship red flags. Here, I'll start. You realize the girl you've been dating for the past 4 weeks only has male friends. She has fucked a nigger She has an enema kit under her bathroom sink. >>592335655 Shit nigger that means she's down for anal. Red Flag- Her family is really religious. You find her fucking another guy >>592335998 >she's down for anal. Yep. With anyone >always ready >>592335106 >she has a "just friend" online >she says she is "bored and wishes you both could do more stuff together" >she is a virgin You find out that the name you've been calling her all this time is actually her middle name her mother didn't age well "I am not like other girls." Red flag: she often stares into the abyss with an empty look on her face Protip: she dumb yo She uses you as a punching bag. She refuses to meet/let you meet parents. She was dating someone else when you started fucking her. NO DAD >>592336513 does that mean im dumb? >>592336563 I love those girls. They're easy to fuck and they like old guys. >she complaines about being bored all the time she will expect you to entertaine her, she is a boreing person in general, if you get married she will find other men to entertain her while you work your ass off to pay for shit she demands Was ever raped No dad Your penis burns after banging her Can't wait more than 10-20 minutes between texts >>592336645 Trick question: this anon can't read the response if we answer. she is suspicious even for the small things. >>592335106 She has a penis You catch her going through your locked cell phone. She is he >>592336187 This guy She says things like "Get away from me" and "Who are you" Has a penis >>592336513 Look its the Bad Grandpa kid. ANY mention of the following: Femenism Vegan Patriarchy Red Flag- You hate all of her friends. >"i would never have kids"- means, i want them now >parents dine at hooters >tells stories about being hit as a child >parents are divorced >300 pictures of herself in her bathroom on her phone >instagram/facebook are >50% herself >more than 300 friends on IG >>592336553 This for sure. Also, >2 weeks into relationship >"anon, do you think you could marry me?" >>592336915 >gril w/ no peen das gay bro She only has "guy" friends. Says she gets bored and lonely when you're away for any period of time. Translation: Obsessive and making her whole world revolve around you so she can control every aspect of it. She never initiates sex anymore >>592337066 we're talking about women in ACTUAL relationships >>592336915 kek >>592336563 Oh man I wonder how many of these the chick I'm with has. No Dad Started fucking her before she had backed out of her relationship mom did not age well I'm "the friend" from "online" she was raped once I hate all her friends so far i wonder what else will pop up >>592335106 She's a single mom. >>592337410 ummm... Are your really that fucking retarded or are you just trolling? Op made that point in his post dumb ass. this >>592337413 >>592336744 hell yah homie 34y/o can confirm, banging 19 y/o slutbox >>592336830 im staring into the abyss too much to read it she tries to kill you with knives >>592337743 You aren't the only one banging her. >>592337795 I'm a relationship expert and I can confirm this >>592335106 She blurts out she loves you and YOU DONT LOVE HER BACK. > How I knew my first relationship was at an end. > Broke up a few days later and told her I don't love her back and that it was unfair of me to hold her back > She tried to get me to come over or go out with her for months until I got another GF. >>592335106 "Can we talk"(..about our relationship?) "We need to talk"(..about our relationship) i hate other women 08q345-918345134859q345-123???????? wtf? move on. >>592337743 Currently in a 20 year age gap. I fucking love teenage girls. >>592335106 complains and is proud of being overweight simultaneously. >"I know I'm not a 0, but god damn am I sexy." >>592335106 is this a trap or not? moar? >>592335106 shes ill she takes care of an ill person hen pecking in a cute way, turns into demands def agree with never date a girl thats already seeing someone or just broke up. relationships tire me out honestly, it can all be boiled down to just a few: 1. she doesn't seem excited about you, hanging out with you (insincere) 2. she gets angry, frustrated, sad, or extremely emotional with zero legitimate reason (i.e.; someone died) 3. she has no interests, or requires other people for entertainment (passionless) 4. she has no desire for clear relationship boundaries, and thus doesn't respect you as a person (i'll summarize that as "whore") TL;DR - she's young. sorry kids, you can have either the body of a teenager or the wisdom of an adult. just make your choice and adjust your little online dating profiles to match Turns tv on while talking to you on the phone. Addicted to drugs or alcohol. Fat Believes in Jesus Doesn't like Vidya Shopping all the time Already has a baby Starts conversations by complaining Is mean to everyone. >>592336233 What's wrong with virgins? Also, nice dubs. >>592335106 I also think this would be a red flag. >>592337950 oh god. hep us both. christ. then what right? you thought it was all good and no...... hahah..... oh shit. here we go. >>592335106 she refers to her friends as just a friend. If they were just a friend then she would just call them a friend. >>592337895 >implying im not a cuck >>592337385 >>2 weeks into relationship>"anon, do you think you could marry me?" fuck this happens every time I have anything deeper than a Fwbs with a woman, it doesn't even make any sense to me I'm poor and have thinly covered emotional problems, I shouldn't be showing up at all on the marriage radar. >>592335106 during the part in a movie that opens with lots of shit that will most likely be explained a little later in the film she asks "whats going on?" >>592336231 You dense motherfucker. >HAve condoms in your drawer >don't use condoms with gf not a red flag >>592338405 You could turn a girl that nuts into a willing sex slave within a month. >>592338101 was the ages my dude >>592335106 > she only has male friends oh man. this one hits home. I learned that lesson the hard way. fuck man. She claims to be a feminist. She also does not swallow. >>592338697 me too >>592337895 That's a good one... Red Flag >>592335106 Whats wrong with this OP? >>592338563 >implying cucks aren't worse than fagots because at least fagots have the courage to accept that they are homosexual. Come out of the closet already your fucking coward. >>592338697 >tfw you know that feel Shits weak man >>592338697 >>592338862 Me three, bros. >>592337354 > tons of selfies oh yeah. spot on on that one. I was on my second date with a girl and she was taking selfies of her self while in the passenger seat of my car. Holy shit what a vapid cunt. >>592335106 >You realize the girl you've been dating for the past 4 weeks only has male friends. >red flag >being this insecure Need /b/ honest opinion Gf of fifteen months will not stop going through phone. Keeps getting mad over dumb bs etc. etc. >Solve problem with screen lock >Gf bursts into treats cuz i'm tired of her going through my shit Should I just dump this nosy insecure cunt and get on with my life ?? pic unrelate You're scared to mention your other girlfriends to her. >>592335106 She constantly sees John Redcorn whenever she had a headache. >>592338521 >she refers to her friends as just friends >if they were her friend, she would call them a friend >>592335106 Correction: >You realize the girl you've been dating for the past 4 weeks only has male friends. Because she's a man. >>592338392 They can't duck dick for shit. They can't ride dick for shit. Super boring in bed. Starting from square 1. >>592335106 if she says the words, "if you really care about me you'll..." for real yo >dated some bitch in the summer >had the feminist fist tattooed on her foot >was all for equal rights but liked sub and dom bedroom play. >i brought up the fact that she was a walking contradiction every chance i got >got dumped >doesn't matter had sex >>592338697 so what happened? >>592335106 LOVES disney movies. Insists that you watch them with her. >>592339063 She doesn't trust you, so yes. >>592335998 >Red Flag- Her family is really religious. Naw dude. Women that have repressed their urges and feelings for a long time are massive sluts. >>592339063 Leave her now. Never stick your dick in crazy (and insecure) >>592338966 Oh plz explain to me obi wan about how her fucking other people makes me a faggot. >>592339063 100% Yes. The instant you go through someones phone you might as well plaster, "I don't trust you." on your forehead. Question for you: Will a relationship without trust work in the long term? >>592338408 ok im high right now what the fuck did you just say? >>592338405 Shit, now he has to change his name and leave the state. >>592338697 me too...cheers I have a list of rules about dating, all learned from experience. - Never trust a girl who's fucked someone you don't trust. - Never trust a girl who doesn't go by her real name. - Never trust a ballerina - Never trust a girl who won't make it facebook official - Never trust a girl who uses the word casual at any point to describe your relationship - Never trust a girl from Virginia - Never trust a girl who prioritizes world travel -Never trust a girl with more than 550 facebook friends -Never trust a girl with more guy friends than girl friends - Never trust a girl who offers anal the first sexual interaction or immediately following And the most important: - NEVER, EVER, UNDER ANY CIRCUMSTANCE trust a girl with a tattoo of a dagger... doesnt eat any other meat than chicken >>592337556 Your insanity, believe me >>592338249 omg bro have you dated my baby mama too? >>592336472 Yeah, she started out pretty cool now she's kind of a cunt. It's usually the other way around isn't it? >>592338318 > wants to talk to you on the phone and do other shit at the same time. nope. I had this last chick I dated want me to listen to her as she just went thru her day, like call me and be shopping and shit and I could just hear her in the background hellanope. >>592339450 how often do you find yourself in a relationship with a ballerina? stfu faggot >>592336187 kek >>592339124 try it in a sentence You: So who was that on the phone? >> Oh that was my friend john. >> Oh that was john, we are just friends. You honestly cant understand the different implications here? >>592338697 >In a year long relationship with a girl that believes in "lying to avoid the other person being hurt" who only has male friends. >her excuse is "do you know how hard it is to make female friends" >haven't found any legit evidence to prove she's cheating >have her tell me she doesn't trust me almost weekly Awww shieeet. >>592337477 fuckin A m8 >>592339124 I actually agree with what he's saying. "Who's that?" or "Who are you going out with?" Answer: "Oh it's just [guys name], it's ok we're just friends." That's the red flag. If she normally answers with something like: "Oh I'm going out with [guys name]." it implies less because she's not instantly defending herself by saying, "JUST friends". Once she starts instantly defending herself from a simple question like that, it somewhat implies she knows she's guilty and trying to hide it. >>592339063 yeah dude. I had a nosy ass bitch too. always accused me of cheating. Turns out she was the one that was cheating. Thats why she was so god damn paranoid i dated a girl, who was vegan, ate glutein-free and she also didn't like soya. >>592338929 she probably is accustomed to stringing guys along for attention, and probably fucks around. there are exceptions, there are a minority of tomboyish women who genuinely connect platonically better with males do to having more male interests, but even then they usually have a female friend they do girly shit with on the side. or an actual girlfriend. >>592337066 That's my girlfriend and she's pretty cool, but I'm also a vegan feminist so it's all good if she is super close with her mom >>592339383 haha. im high too. maybe tghat shy i dunno. your bein cool and gettin laid and shes not she want more an im igh... yeah so.. >>592339690 Explained like that it makes sense, but nobody is going to read the first message and understand what the fuck you meant. way too much time spent riding horses >>592339062 >being this whiteknight >>592338124 oh god >>592339063 Yeah, probably dude. Problems like this are only going to get worse down the line. If you're already having trouble with that shit now it's just going to intensify the longer you stay with her. >>592339137 duck dick >>592336817 this. She's completely oblivious to the fact that her "best friend" has a huge crush on her. >>592339621 Several time actually. Do you doubt my wisdom? Trust me on this one. Avoid Ballerina's. All that perfectionist high maintenance bullshit they are trained to do makes them insane. >>592339949 why is that bad? less time for you? >>592339249 This >>592339064 >implying /b/ has >1 girlfriend >implying /b/ has =1 girlfriend >>592339063 Next time you sex her hit it as hard as you can that will shut the bitch up. she refuses to get divorced and/or change her married name >>592335998 This means nothing. If SHE is religious, on the other hand.. My girlfriend was a virgin when I met her. She likes me because I entertain her. She has more guy friends than girl friends. Hates it when I take too long to reply. Gets emotional very easily. She has a hot body though. I think I want to marry her. I would not mind tapping datass for the rest of my life. >>592340096 Naw son, she knows she just doesn't love you back. >>592338318 Lol is the current girl I'm banging. Like 90% of those things. When she carries a whistle >>592339450 who the fuck doesn't have over 550 facebook friends now-a-days? >>592335106 She keeps having her friend Darel hidden in our closet buttnaked whenever I show up. >>592339980 oh this brother. this. listen. lo. <<<<<<<<<<<<<<<<<<<<<<< >>592340359 >2015 >not dating a referee I refuse to date a woman who has male friends. Not because I think she'll cheat on me with them, but because they're going to hit on her all the time and I don't want to have to be kicking asses 24/7. I got shit to do. Honestly the only reason you have a female friend is if you want to fuck her. Any single one of your girl friends you would fuck daily. >>592337066 i wouldn't mind dating a vegan girl. she would probably be caring and compassionate... and healthy from all the fruit n veg eating. long-term vegans are rarely overweight. >>592339063 Femanon here She cheated on you a little while ago and now she's desperately trying to find evidence that you're doing the same so that she can stop feeling guilty. >>592339191 well basically all the male "friends" were men she was either considering dating, or had fucked in the past. This was a woman with a mind of a man. And just wanted to pit all the min against eachother. Like a bidding war at an auction. she was just all around crazy. she was into rape-sex, which is very much a turn-off for me. She just ended up being a crazy cunt, and then told everyone at work that I was some wierdo faggot after I stopped talking to her. Mega game player. just all around a weird incident. and I made the mistake of dipping the pen in company ink so it fucked my life up. Ultimately, the fact that all her friends were men should have been a massive red flag. I mean how fucking wierd is that? It'd be like a guy whose only friends are a flock of women. Something wrong there. >>592340145 um yeah, this girl I'm seeing has forced me to watch some disney movies. Why is this red flag? Doesn't seem to be the worst thing. I watch a shitty movie like frozen then she fucks me for the next two weeks. Don't get the huge problem.... >>592337066 My girlfriend is starting to turn feminazi. I hate it and she always avoids the conversation when I start telling her what's wrong with the stupid shit she's saying. It usually goes "wow, these people are stupid" "no they're not they have a right to blah blah blah false justification" "if it really mattered they'd do logical decision rather than stupid shit they did" "I don't want to start with this, I'll just get mad" I don't think I can ever forgive my cool female friend for showing my girlfriend how to use tumblr. >>592340102 you could easily make that connection without dating them which is why i dont believe you actually dated them. unless you have some connection to a ballerina (studio?) or are one yourself. either way you are a liar or a faggot but im just gonna kill two birds with one stone and say you are a lying faggot. >>592340388 i dont. I keep it to important people only. Which is maybe 12 people >>592339863 >girlfriend yeah, like lesbian life partner level stuff. big red flag. What if I the booty is really really good? Also I've been in love with her for 6 years and I had to go through a really elaborate plot to get her boyfriend fired from his job, addicted to meth, and into prison for domestic assault, in order to free her up. So I mean I should be fine right? >>592335106 She has never masturbated in her life. (protip most likely asexual enjoy your sexual frustration) >fml >>592340454 >kicking asses 24/7 y so insecurr m8 Talks about her Dad all the time. Has a wierd relationship with her dad. >>592339249 I wouldn't call this a red flag. Disney has some great content and it can be fun to watch with someone. Hates Weed. Like fucking hates it. >>592339008 >vapid I like that word, it sounds really harsh and serious. >>592339786 so much this. 3 years of her bs, getting all insecure and playing the victim when you even brush the subject of something as simple as "who is texting you right now?". crying, blaming ect. should have been more obvious, but they make YOU feel like you are being the bad guy by not trusting her, when its really just your instinct trying to get the bitch out. >>592339939 I understood. Not being an autistic nigger helps. >>592335106 MGTOW Men/Man. >>592340657 i had a gf that would masturbate herself for me. shit was fuckin cash. When she's actually a potato with Mac and cheese on it >>592339450 >Never trust a ballerina Why? >>592339939 I'm high fuck off also thanks other guy for correction >>592338966 Moron. Red flags You find out she has had fuck buddies "i didnt enjoy it and dont do it anymore" happened twice a few months before you start dating If shes ever model'd amateur Ever dated a non famous "musician" Has had a "pay pig" ( someone who pays you to sexually humiliate or dom them) Tells you if you broke up shed still try to stick out being friends if you moved on Unfortunatly these were all from the same chick in one relationshit Has physically abused all her ex-bfs. Yeah, I'm scared as fuck. >>592335106 >>592336513 >>592336513 she visits 9fag or posts traps as OP on /b/ >>592340557 damn bra, but I hope you got over it (mostly), sounds like she was legit crazy has an unattractive laugh. >it ruins humor and therefore good times >>592339063 Pro-tip: Girls that don't trust, cannot be trusted. They think you would do, what they would do. Which is cheat. Sad but true. >>592335106 I've been in a few before. 1. She talks about marriage or kids too much in the first year. 2. She "forgets" to take the pill on occasions. My tip is to get her the coil, and maybe go on the male pill too. 3. She acts too quickly as if she's moving herself into your apartment, like taking up clothes drawers for herself without asking. 4. She starts moving your own stuff around your apartment. 5. She starts to become less and less independent, and relies on you more for money. Any two people who can't stand on their own two feet will have a rocky relationship filled with future arguments. 6. She bans your "you time" with friends and consoles. >>592340673 They deserve it. She's not dating them for a reason. When asking about her dad >I'm glad he's dead Annnnnnd that was a can of worms I wasn't about to open. >>592339949 naw, that's a pro, its a hobby that is 95% women and builds great thigh and pelvic muscles. >>592338101 >I love fucking teenage girls FTFY >>592335106 She has a penis >>592340745 Weed is one of the best drugs there is*. How can anyone hate it unless they're willfully ignorant? *personal opinion, faggots. >>592339330 You want to be her. You're fucking the people she's fucking vicariously through her. >>592339063 >>592335106 32 year oldfag here. I'll share a few 1) Multicolored or unnaturally colored hair. Sign of a personality disorder or extreme mental instability. 2) Has 'rebelled' against deeply religious parents or is otherwise estranged from them. 3) Majority of her friends are men. She has fucked or will fuck nearly all of them. They're waiting their turn. 3b) Other women cannot stand her but 'can't quite put their finger on why'. Especially women that you're friends with (Protip: Your buddies' girlfriends/wives are amazing litmus tests to use for potential new women) 4) Any time you point out shady behavior she goes immediately to accusing you of being 'controlling'. She's deflecting. Just outright say what you think she's doing, chances are you're right. That's why she's deflecting. 5) Any woman you can confirm has cheated before. Immediately proves she cannot ever be trusted. 5b) If she'll cheat with you, she'll cheat on you. It's a matter of time and her convenience. 5c) Any time a woman claims she was 'raped' by one of her beta-orbiter men. She fucked him willingly. She'll do it again too if she thinks you won't find out. 6) Compulsive liars. 7) Women who can't hold a job. 8) Women that insist on going with no condom ridiculously early in the relationship (read <6 months). One of the times you try to pull out she's going to leglock you you and refuse to let you. Congratulations, you've just created an 18 year government-mandated stipend for her. 9) Women that were actually raped or molested at an early age. The amount of psychological damage this cause will never fully heal. They're complete emotional nightmares as a result. 10) The ones that say 'I love you' ridiculously early. Bitch you've known me 4 weeks and you love me? 10b) The ones that refuse to say they love you even after a year or more. You're being used. Soon as she finds someone else to fufill the purpose she's assigned to you, you're going to be out on your ass. And that's just the big ones. >>592340674 My gf's dad apparently gets upset if he has a day off work and she's not available to spend the day with him. >mfw my gf's dad's probably getting it in with my girl more than I am >>592340868 >masturbate herself for me wtf are you saying >>592339063 There's clearly a fundamental problem with the way both of you view what a relationship means and that's just as much your fault as hers. I personally wouldn't give a damn if my girlfriend of over a year wanted to looks at everything aside from asking for access to my bank account, passwords, and social security number. If she wants to ask me to look through my phone I take that as a good sign. I'd rather have a girl afraid that I'm too good for her than one that doesn't give a shit. But that's just me. I see relation ships as requiring complete transparency to work. Other people have different opinions. If you don't mesh on the nature of what a relationship fundamentally is then yes, you should leave her. >>592338588 oh god, i used to have to explain that what was hapenning was foreshadowing and that they were building up to something that was gonna happen, like it doesn't make sense yet because the thing they are referring to hasn't even happened yet. be patient give it time. i can't remember but that probably just started another argument because i pointed out... the truth. >>592340657 My current one never came before I came along. She literally doesn't do anything in bed except get fucked silly. Ugh. >>592338572 that's what happens when you date chicks with low self esteem >>592335106 When she wants "eletro therapy" When she hangs out with one guy, and he's just "a friend", or "like a brother". Second one is the worst. You know she's fucking bullshiting, but she keeps saying it. I know he's not "just a friend'. >>592341083 That too. I've had all good relationships actually. The best one >liked anime but kept it away from me >was vegetarian but i didn't know about it for a while >owned one cat and one dog >didn't have a facebook >didn't talk much I still love her so much. I wonder where she went. >>592336817 >Your penis burns after banging her what this? >>592337354 >"i would never have kids"- means, i want them now My gf and I are in agreement that we never want kids. >>592339180 > women > logic they just can't man. and won't. never will. and really when you think about it, why should they? They can think however they want in whatever strange ways they want and men will still want to fuck them. really they run shit when you think about it. We strive to meet their illogical perceptions. >>592339949 >>592341078 It's also not the cheapest thing to get in to. Implies wealth. >>592340976 end it now you dumb fuck its only gonna get worse >>592338101 >>592338101 >>592338644 are you retarded?, thats not a "redflag" thats a fuckin relaitionship ender right there bro. >>592340976 This happened to me recently. >bitch clocks me in face drunk, breaking $400 prescription glasses >fuck it, we're on lease together - forgive it >3 weeks later claws at my face, scraping glasses off durr 'open hands' >fuck you >50% power into fist into torso >bitch flies 5ft back "This is your equality. Fuck you. Next time it will be 100% power." Hate this cunt so much. Can't wait til lease is up. Sucks I'll have to be a master carpenter to repair all the damage I've done here.... (punched a hole in about everything solid b/c typically I don't EVER hit people unless provoked) >>592340903 See: >>592340102 >>592337413 id prefer that over "yeah anon im just hanging out with my guy friend but hes just a friend dont worry :)" Pageant girls >>592339869 >>592340447 >>592340841 weird how it works that way. Ive never cheated on someone. If you dont want to be with someone then fucking leave. I aint keeping you here. I get around when Im single and have broken up with girls when there is another girl i really wanna fuck. Its not hard. I guess some bitches are just crazy. >>592339926 This conversation is the biggest shit show I've ever seen >>592341160 >6) Compulsive liars. Hit the nail right there for me anon. Fucking hate liars. Especially when you call them out on it and they continue to try and feed you bullshit. >>592341350 Super AIDS. >>592341160 >1) Multicolored or unnaturally colored hair. Sign of a personality disorder or extreme mental instability. So you're saying this is a no? >>592335106 She has a facebook. >>592341053 fucking A bro. went out with a girl 3 times in my hometown before she started asking me if i was fucking girls at my college. when i said no, she said its not a big deal if i am. i realized she already had it in her head that i was and i wasnt getting through to her so i ended it right there. didnt realize until you said it anon, but she originally said she had trust issues and i brushed it off >>592339754 Been there my friend. >>592341197 i said masturbate herself as opposed to masturbating me. I know. Masturbation means sexual pleasure of yourself. I get it. But sometimes people are retarded. Like you. >>592340349 i think i just realized my first relationship of nearly 4 years i was getting cheated on left and right. well shit >>592341472 Daddy issues are my bread and butter. I'm pregnant, anon >>592341589 amen brother. >>592341197 That she would get herself off while the dude watched, come on bro. >>592341209 she cheated on him that's why she is looking for evidence of the same simple man. >>592340447 I'm on a different machine so I don't have an appropriate reaction image but fuck that was good. Thanks. >>592335106 When the girl you've been dating is part of a clique of female friends who spend a lot of their time discussing you and trying to convince her to break up with you so they can all be "single gurlzz" together >>592339754 yea shes cheating on you >>592339863 Nailed it. the "tons of guy friends" chick loves stringing men along for kicks. >>592341618 Holy cunts, I know a girl named Angel that looks the exact same minus the hair and she's nuts as fuck. >>592340604 Trial and error. I dated two ballerinas by chance. How is that so unbelievable? You must be a ballerina getting so easily rustled. I'm surprised you didn't call me out on Virginians. I approve. This must mean you're from West Virginia, the one true Virginia. She has a tattoo. Any size, any place. >>592341634 every girl has a fucking facebook account even the shy bookworm girl that I used to know >>592339150 I hate it when a girl can't duck my dick. >>592340388 I have like 60 max, I don't add family or people I'm not close enough that I would hang out with 1v1 >her bestfriend is a guy who was her Ex/someone that she had feelings for at one point/He had feelings for her. >>592341160 2 is okay. Better than being religious >>592341145 underrated post kek She has borderline personality disorder. Run for the fucking hills and never look back. It'll save you from being manipulated, lied to, ignored and being cheated on. >>592336395 fucking underrated post >>592341790 You're better off without her m8. Get yourself a better gf with a bigger penis so the ex knows you traded up. >>592340604 I can back up his claim. I only dated one but I met her friends and there was a common thread that wore me out after two weeks. >>592335106 >>592338697 Fuck this is the girl I am just starting to date. She was a part of our guy friend group for a long time though so maybe it is a bit different? I t's awesome right now though because she is fucking hot, and yes albiet a little crazy in a good way, and she does all the 'manly' things I like to do, like climbing backpacking, drinking, smoking fuckkkkkkk am I getting myself into some shit? >>592341497 >(punched a hole in about everything solid b/c typically I don't EVER hit people unless provoked) That's still not healthy, anon. >>592336395 or her mother is hotter >>592339104 underrated post >>592341160 OH hell I'll throw in a few more. 11) Has no father/absentee father. This woman will crave male attention and approval. How do adult women get this? By fucking as many men as they can. These are the women that end up working graveyard at the C-string stripjoint in their 40s. 12) Has two kids or more that are extremely close in age, and look absolutely nothing alike. They have separate fathers, and she fucked both of their fathers within a very short timeframe. This is a whore. You are her next mark.. 14) any woman that constantly brings up multiple ex-boyfriends in casual conversation. This should tell you her deep-down opinion of men. They're conversation pieces. A means to an end. That's exactly what you'll end up being. 15) Any woman that asks you for any amount of money above $50 within the first 5 months. You know what she's using you for now. 16) If she's a student when you meet her and suddenly isn't after about 6 months of dating.. you're being primed to be her retirement fund. 17) If she insists on going somewhere and when you say you'd like to come along, she actually gets mad while insisting you can't. You're interfering with her ability to wrangle a side-dick. Insist and if she still refuses, tell her to take her shit with her when she leaves. >>592340454 This. I hang out with men because we have things in common. I hang out with women cause i want to get inside them. This just seems like the normal way of things. Why do some women seem to deny this is true? She shaves her eyebrows and gets tattoo replacements. She gets short, more manageable haircut. She doesn't shave her legs or armpits for you, but for special occasions. Socks as gifts. >>592341898 ok james dean 1.She's always sick or hurt. Either she's really fucking whiny or she's poor breeding stock, either way you don't want that. 2.You always have to explain movies to her. Explaining inception is one thing. I had to explain the fucking Princess Bride to a bitch. It's a fucking kids movie dumb cunt, a 3rd grader could follow the plot... >she has a dick >>592339104 >>592342220 . holy,fucking, shit..... this is actually pretty close to what my ex was.... damn it. all that love talk n shit ...why. >her dicks smaller than yours >>592338929 Girls who have all male friends are usually oblivious to the fact that they all just want to fuck her but don't know how to make a move. Dating a girl like that is a nightmare, because all of her friends see you as a rival and all they do is put you down and talk shit about you when your not there. Or worse, she knows they all want to fuck her and she gets a kick out of being desired by so many men and she uses their attention to compensate for the fact that her father left when she was five. >>592339450 welllllllll seems like you are projecting arent cha son? Good advice so far. If she cries first time or regularly during or after sex. Had 2 gfs like this, both crazy. The one was hot as fuck though so you know...held on to her a little longer than I should have >>592335106 When you tell her "you got what I need" but she says he's just a friend >>592339319 >Never stick your dick in crazy (and insecure) yeah, good luck with that, it's amazing how many women out there are severly damaged >>592342554 Biz dat you? >>592340648 >>592339542 shit meant to link >>592339966 >not knowing what the fuck white knighting is >getting double dubs >>592341160 >8) Women that insist on going with no condom ridiculously early in the relationship (read <6 months) This doesn't always have anything to do with: >Congratulations, you've just created an 18 year government-mandated stipend for her. Mostly it means theyre on the pill and want to have sex without a condom. >>592342085 >a little crazy in a good way you can stick your dick in her but don't do anything serious. >>592337743 >>592338101 How'd you guys meet these sluts? 28yo, looking for a youngin'. >>592342110 I don't like to hurt anything. Objects can't feel pain. >was brought up by old school parents where 'beating' meant 'fixing' All I ever feel is hate, resentment, regret, and pain. Job is pure stress, no friends b/c of long-term bitchcunt, the only thing keeping me alive is my prodigy of a child. >bitchcunt 'fiance/gf' thinks we're still going strong >fuck you cunt, installed packet sniffers on network 4 months ago I know everything >she will never, ever, ever win a custody battle I play for keeps. >>592340557 >she was into rape-sex Almost all girls are, most just won't tell you unless they feel 100% sure you aren't going to judge them for it. >>592342235 >She gets short, more manageable haircut. What's the problem with that? >>592342511 mx ex had a best male guy friend. always told me he was "only a friend" and " nothing will happen". yeah fuck me, after 2 years of relationship she breaks up under blameshifting and stupid reasons and gets together with him. wow....just fuckin wow.. she was beautiful, the right mixture of humor, looks,character...and then fucks me over like that >>592341006 thanks im good. i think ultimatelley people know she is a cunt. plus i fucked a bunch of girls right after. whatev. that's life. >You realize the girl you've been dating for the past 4 weeks only has male friends. Implying that a girl can't be anything other than straight when dating your swampass Implying that by having all male friends means she's a slut Implying that if she had all female friends she could be just as slutty if bi fucking christ niggertits >>592342229 They think they're actually interesting. I guess you can have a good time with them, but it will never be beyond a real flirty time. Like, you can't wait to go bowling with your friend. You'll joke and drink and it's good. If you went bowling with her, you'd constantly think about not fucking up because you still want to get your dick in her. It's just not as comfortable, even if you don't like her. >>592342766 Pic related >>592339450 /b/ro i'm feeling the hardship of a GF who keeps begging to travel. To be honest i'm piss poor and a student and it just is not feasible currently. But she goes on like it is her destiny or that her current life is fulfilling. Although she unintentionally is shitting on the relationship the implications are sufficient for me to prepare for the incoming breakup. Also life experience, if she is catholic and wishes to argue with you about the moral nature of sex related topics, it is not worth it.
https://4archive.org/board/b/thread/592335106/itt-relationship-red-flags-here-i-039-ll-start-you-realize-the
CC-MAIN-2018-26
refinedweb
6,838
82.65
errno errno Global error variable Synopsis: #include <errno.h> extern int errno; char * const sys_errlist[]; int sys_nerr; Library: libc Use the -l c option to qcc to link against this library. This library is usually included automatically. Description: The errno variable is set to certain error values by many functions whenever an error has occurred. The errno variable may be implemented as a macro, but you can always examine or set it as if it were a simple integer variable. The following variables are also defined in <errno.h>: - sys_errlist - An array of error messages corresponding to errno. - sys_nerr - The number of entries in the sys_errlist array. The values for errno include at least the following. In QNX Neutrino 6.4.0, like this: #if defined(EALREADY_NEW) && defined(EALREADY_OLD) if (error == EALREADY_NEW || error == EALREADY_OLD) { // deal with EALREADY error cases } #else if (error == EALREADY) { // deal with EALREADY error cases } #endif This will ensure that the code handles EALREADY error cases from any API that returns either the old or new value. -: See also: h_errno, perror(), stderr, strerror()
http://www.qnx.com/developers/docs/6.4.1/neutrino/lib_ref/e/errno.html
CC-MAIN-2016-22
refinedweb
176
57.06
In this case study I am going to describe two streams I developed for use within my C++ testing framework, Aeryn [Aeryn]. Aeryn has two output streams. One is minimal and only reports test failures and the test, pass and failure counts. The other is more verbose and includes all the output from the minimal stream, plus a list of all test sets along with their individual test cases. The minimal stream is intended to be sent to the console and the verbose stream to a more permanent medium such as a log file or database, but either can be sent to any sort of output stream. The use of the two streams introduces two specific problems: The stream sink for both streams must be passed into the function that runs the tests. For example: std::ofstream verbose("testlog.txt"); std::stringstream minimal; testRunner.Run(verbose, minimal); Even if only one of the two outputs is required, both streams must be specified. The same information must be sent to both streams, which results in duplicate code. For example: verbose << "Ran 6 tests, 3 passes, 3 failures"; minimal << "Ran 6 tests, 3 passes, 3 failures"; This is far from ideal as every time the text sent to one stream is modified, the text sent to the other stream must also be modified. It would be all too easy to forget to update one or other of the streams or to update one incorrectly. Both of these problems can be solved by writing a custom stream. Writing custom streams is covered in detail in section 13.13.3 (User-Defined Stream Buffers) of The C++ Standard Library [Josuttis]. As Josuttis does such a good job of describing custom streams and his book is widely distributed, I will only cover the necessary points relevant to this case study. Problem 1 can be easily solved with a null output stream. A null output stream is a type of null object [Null_Object]. Kevlin Henney describes a null object as follows: "The intent of a null object is to encapsulate the absence of an object by providing a substitutable alternative that offers suitable default do nothing behaviour." So basically a null output stream is a stream that does nothing with what is streamed to it. Therefore if either the minimal or verbose stream is not required it can be directed to a null output stream. For example: cnullostream ns; testRunner.Run(ns, std::cout); The key to writing a custom stream is implementing its stream buffer. The functionality for stream buffers is held in the standard library template class std::basic_streambuf. Custom stream buffers can be written by inheriting from std::basic_streambuf and overriding the necessary member functions. It is not necessary for the custom stream buffer to be a template, but it makes life a lot easier if you want your custom stream to work with char, wchar_t and custom character traits. This is also discussed in detail in The C++ Standard Library. template<typename char_type, typename traits = std::char_traits<char_type> > class nulloutbuf : public std::basic_streambuf<char_type, traits> { protected: virtual int_type overflow(int_type c) { return traits::not_eof(c); } }; The code above shows the complete implementation for the null output stream buffer. The overflow member function is all that is needed to handle characters sent to the stream buffer. The traits::not_eof(c) function ensures that the correct character is returned if c is EOF. Now that the stream buffer is complete it needs to be passed to an output stream. The easiest way to do this is to inherit from std::basic_ostream and have the stream buffer as a member of the subclass. template<typename char_type, typename traits = std::char_traits<char_type> > class null_ostream : public std::basic_ostream<char_type, traits> { private: nulloutbuf<char_type, traits> buf_; public: null_ostream() : std::basic_ostream<char_type, traits>(&buf_), buf_() {} }; Notice the constructor initialisation list. The buf_ member of null_ostream is passed to the basic_ostream base class before it has been initialised. In his book Josuttis actually puts buf_ first in the list, but this makes no difference. The base class is still initialised before buf_. This could give rise to a problem where buf_ is accessed by a nullstream base class prior to it being initialised. Some standard library implementations do nothing to avoid this and they don't need to. A library vendor knows their own implementation and if protection was required it would be provided. As the C++ standard gives no guarantee it is sensible for a custom stream to take steps to avoid the stream buffer being accessed before it is created. One way to do this is to put it in a private base class, which is then initialised before basic_ostream: template<typename char_type, typename traits> class nulloutbuf_init { private: nulloutbuf<char_type, traits> buf_; public: nulloutbuf<char_type, traits>* buf() { return &buf_; } }; template<typename char_type, typename traits = std::char_traits<char_type> > class nullostream : private virtual nulloutbuf_init<char_type, traits>, public std::basic_ostream<char_type, traits> { private: typedef nulloutbuf_init<char_type, traits> nulloutbuf_init; public: nullostream() : nulloutbuf_init(), std::basic_ostream<char_type, traits>(nulloutbuf_init::buf()) {} }; The code above shows that as well as being inherited privately, nulloutbuf_init is also inherited virtually. This makes sure that nulloutbuf and nulloutbuf_init are initialised first, avoiding the undefined behaviour described in 27.4.4/2 of the [CppStandard]. The undefined behaviour would occur if nulloutbuf's constructor was to throw in between the construction of basic_ios (a base class of basic_ostream) and the call to basic_ios::init() from basic_ostream's contrustor. See the C++ standard for more details. Now that the implementation of null_ostream is complete two helpful typedefs can be added. One for char and one for wchar_t: typedef null_ostream<char> cnullostream; typedef null_ostream<wchar_t> wnullostream; I always like to unit test the code I write and usually the tests are in place beforehand. Naturally I use Aeryn for unit testing. Testing null_ostream has its own interesting problems. I started by writing two simple tests to make sure that cnullostream and wnullostream compile and accept input: void CharNullOStreamTest() { cnullostream ns; ns << "Hello, World!" << '!' << std::endl; } void WideNullOStreamTest() { wnullostream wns; wns << L"Hello, World!" << '!' << std::endl; } The whole point of a null output stream is that it shouldn't allocate memory when something is streamed to it; otherwise something like a std::stringstream could be used instead. Wanting to test for memory allocation caused me to write, with considerable help from accu-general members, a memory observer library, called Elephant (see sidebar) [Elephant]. Elephant allows me to write an observer (NewDetector) which can detect allocations from within null_ostream's header file, which in this case, also holds its definition. Originally the observer was intended to monitor all allocations that occurred while using null_ostream, but as the standard permits stream base classes to allocate memory to store the current locale, I restricted the observer to allocations from null_ostream itself: class NewDetector : public elephant::IMemoryObserver { private: bool memoryAllocated_; public: NewDetector() : memoryAllocated_(false) { } virtual void OnAllocate(void*, std::size_t, std::size_t, const char* file) { // Crude black list. if(std::strcmp(file, pg::null_ostream_header)) { memoryAllocated_ = true; } } virtual void OnFree(void*) {} bool AllocationsOccurred() const { return memoryAllocated_; } }; In order to get OnAllocate to be called by the Elephant operator new overload that includes the name of the file it was called from, a macro must be introduced into null_ostream's definition. The easiest way to do this is to wrap null_ostream's header file with the macro in the test source file: // nullostreamtest.h #define new ELEPHANTNEW #include "nullostream.h" #undef new In order to make sure that OnAllocate only registers allocations from null_ostream, a variable must be introduced into null_ostream's header file: const char* const null_ostream_header = __FILE__; An ideal solution would not require the null_ostream header to be modified at all for testing. However I could not find a satisfactory alternative. Suggestions will be gratefully received. Moving CharNullOStreamTest and WideNullOStreamTest into a class, and giving them new names to better represent what they now test for, allows NewDetector to be added as a member, and using Aeryn's incarnate function allows a new instance to be created for each test function call. class NullOStreamTest { private: NewDetector newDetector_; public: NullOStreamTest() : newDetector_() { using namespace elephant; MemoryMonitorHolder().Instance(). AddObserver(&newDetector_); } ~NullOStreamTest() { using namespace elephant; MemoryMonitorHolder().Instance(). RemoveObserver(&newDetector_); } void NoMemoryAllocatedTest() { cnullostream ns; ns << testString << testChar << std::endl; IS_FALSE( newDetector_.AllocationsOccurred()); } void NoMemoryAllocatedWideTest() { wnullostream wns; wns << wtestString << wtestChar << std::endl; IS_FALSE( newDetector_.AllocationsOccurred()); } }; Problem 2 can be solved with what I have called a multi output stream. A multi output stream forwards anything that is streamed to it onto any number of other output streams. To solve the problem faced by Aeryn the multi output stream could simply hold references to two streams (one verbose, one minimal) as members, but this could potentially restrict future use when more than two streams may be required. Again, the key is the output buffer. The first element to consider is how the multiple output streams, or at least some sort of reference to them, will be stored and how they will be added to and removed from the store. The easiest way to store the output streams is in a vector of basic_ostream pointers. The original design for the multi output stream I came up with managed the lifetime of the output streams as well. This involved the output streams being created on the heap and managed by a vector of smart pointers. Therefore a smart pointer either had to be written or a dependency on a library such as boost [boost] introduced. As the lifetime of the multi output stream would be the same or very similar to the lifetime of the output streams there was really no need. The easiest way to add and remove output streams is by way of an add function and a remove function. This functionality is shown in the code below. template<typename char_type, typename traits = std::char_traits<char_type> > class multioutbuf : public std::basic_streambuf<char_type, traits> { private: typedef std::vector<std::basic_ostream< char_type, traits>* > stream_container; typedef typename stream_container::iterator iterator; stream_container streams_; public: void add(std::basic_ostream<char_type, traits>& str) { streams_.push_back(&str); } void remove(std::basic_ostream<char_type, traits>& str) { iterator pos = std::find(streams_.begin(), streams_.end(), &str); if(pos != streams_.end()) { streams_.erase(pos); } } }; The add function simply adds a pointer to the specified output stream to the store. The remove function must first check that a pointer to the specified output stream exists in the store, before removing it. Josuttis describes the std::basic_streambuf virtual functions that should be overridden in a custom output buffer: overflow for writing single characters and xsputn for efficient writing of multiple characters. template<typename char_type, typename traits = std::char_traits<char_type> > class multioutbuf : public std::basic_streambuf<char_type, traits> { ... protected: virtual std::streamsize xsputn( const char_type* sequence, std::streamsize num) { iterator current = streams_.begin(); iterator end = streams_.end(); for(; current != end; ++current) { (*current)->write(sequence, num); } return num; } virtual int_type overflow(int_type c) { iterator current = streams_.begin(); iterator end = streams_.end(); for(; current != end; ++current) { (*current)->put(c); } return c; } }; A different approach would be to write three function objects and use for_each to call the appropriate function for each output stream in the store. However, this would not add a lot to the clarity and would not provide any better performance, but would create a lot of extra code. The output buffer must be initialised and passed to an output stream and the output stream needs to have corresponding add and remove functions that forward to the output buffer's functions: template<typename char_type, typename traits> class multioutbuf_init { private: multioutbuf<char_type, traits> buf_; public: multioutbuf<char_type, traits>* buf() { return &buf_; } }; template<typename char_type, typename traits = std::char_traits<char_type> > class multiostream : private multioutbuf_init<char_type, traits>, public std::basic_ostream<char_type, traits> { private: typedef multioutbuf_init<char_type, traits> multioutbuf_init; public: multiostream() : multioutbuf_init(), std::basic_ostream<char_type, traits>(multioutbuf_init::buf()) {} bool add(std::basic_ostream<char_type, traits>& str) { return multioutbuf_init::buf() ->add(str); } bool remove(std::basic_ostream<char_type, traits>& str) { return multioutbuf_init::buf() ->remove(str); } }; All that remains is to provide two convenient typedefs, one for char and one for wchar_t: typedef multi_ostream<char> cmultiostream; typedef multi_ostream<wchar_t> wmultiostream; The multi output stream is quite easy to test and should be tested for the following things: Output streams can be added to the multi output stream. All added output streams receive what is sent to the multi output stream. Streams can be removed from the multi output stream. Although this looks likes three separate tests they are all linked and the easiest thing to do is to write a single test for char: void CharMultiOStreamTest() { std::stringstream os1; std::stringstream os2; cmultiostream ms; ms.add(os1); ms.add(os2); ms << "Hello, World"; IS_EQUAL(os1.str(), "Hello, World"); IS_EQUAL(os2.str(), "Hello, World"); ms.remove(os1); ms << '!' IS_EQUAL(os1.str(), "Hello, World"); IS_EQUAL(os2.str(), "Hello, World!"); } and a single test for wchar_t: void WideMultiOStreamTest() { std::wstringstream wos1; std::wstringstream wos2; wmultiostream wms; wms.add(wos1); wms.add(wos2); wms << L"Hello, World"; IS_EQUAL(wos1.str(), L"Hello, World"); IS_EQUAL(L"Hello, World", wos2.str()); wms.remove(wos1); wms << '!'; IS_EQUAL(L"Hello, World", wos1.str()); IS_EQUAL(L"Hello, World!", wos2.str()); } Streams are a hugely powerful part of the C++ language; which few people seem to make use of and even fewer people customise for their own uses. The null_ostream and multi_ostream are very simple examples of customisation and I have shown here just how easy stream customisation is. Thank you to Jez Higgins, Alan Stokes, Phil Bass, Alan Griffiths, Alisdair Meredith and Kevlin Henney for their comments at various stages of this case study. [Aeryn] Aeryn: C++ Testing Framework. [Null_Object] Kevlin Henney. Null Object, Something for Nothing, papers/europlop/NullObject.pdf [Elephant] Elephant: C++ Memory Observer: [Boost] Boost.
https://accu.org/index.php/journals/260
CC-MAIN-2019-47
refinedweb
2,282
52.9
On Jan 10, 2005, at 7:24 AM, Reinhard Poetz wrote: >> So it seems, flow replaces components? If createNewAccount() gathers >> sends pages, collects information, creates an Account, etc. then why >> not just use cocoon.sendPageAndWait? > > because this is done in the called block, not by the callee. Yes, and when sendPageAndWait returns the calling blocks flow continues with a new account accessible from the session. Maybe we need a new method such as callFunction. <snip/> >> Seems like you want a round peg in a square hole. Just invoke the >> function by loading its file and this problem goes away. >>> >>> >>> If Javascript supported namespaces, I would agree with you. >>> Then the thing to do might be to designate certain javascript files as public and others as private in the block's configuration file. Glen Ezkovich HardBop Consulting glen at hard-bop.com A Proverb for Paranoids: "If they can get you asking the wrong questions, they don't have to worry about answers." - Thomas Pynchon Gravity's Rainbow
http://mail-archives.apache.org/mod_mbox/cocoon-dev/200501.mbox/%3C6D0D565F-6317-11D9-A9E3-000393B3DE96@hard-bop.com%3E
CC-MAIN-2016-18
refinedweb
167
75.91
Hey all, I fall into a small problem with fonts embedding. In my application I have embedded over 50 fonts and all expect one works as expected. That one shows an error "warning: incompatible embedded font 'Algerian-CFF' specified for spark.components::RichEditableText (RichEditableText310) . This component requires that the embedded font be declared with embedAsCFF=true." I have been looking all over the internet for similar problem, without success. Why this font is not working while all the rest does? Any clues? /* CSS file */ @namespace s "library://ns.adobe.com/flex/spark"; /* embedded font */ @font-face { src: url("ttf/ALGER.ttf"); fontFamily: Algerian-CFF; } Thanks. Hi, i face same problem. I have embed a font two times for mx and spark controls . cff= true for spark and cff=false for mx controls but warning message remain same. Warning message for all fonts and controls occure in my application. Please reply me if any solution. That issue is very painful to me. If you use MXFTEText.css and follow the documentation you should only have to embed once Thanks, My issue is not to embed a font twice. Let me describe the issue so this will helpful. I have embed a fonts like below code.And apply LucidaBlackletterSpark font for spark component but it gives me error like "warning: incompatible embedded font 'LucidaBlackletterSpark' specified for spark.components::RichEditableText (RichEditableText2301) . This component requires that the embedded font be declared with embedAsCFF=true". But Font have already embedAsCFF property true. I am not able to find the solution why it is give me this warning.Due to that i am not able to embed a font. @font-face { src: url("assets/fonts/LucidaBlackletter.ttf"); fontFamily: LucidaBlackletterSpark; embedAsCFF: true; } @font-face { src: url("assets/fonts/LucidaBlackletter.ttf"); fontFamily: LucidaBlackletterMX; embedAsCFF: false; } Is this a single SWF app? Could the embed be declared twice in separate files with different embedAsCFF values?
https://forums.adobe.com/thread/942729
CC-MAIN-2017-51
refinedweb
316
52.66
Auth0 — React JS Sample App — Configuring Scopes, Permissions and Roles Today, I was working with one of my student clients, and we were configuring roles and permissions for our .Net 6 WEB API project. I have done this before. In fact, we used the guide that I myself wrote a few months ago. It’s available here. Adding Roles in Auth0, .NET and React JS This week, I am working with one of my clients, guiding him through the process of adding a new role to a full stack… medium.com This post, is like a sequel, to the above post. Make sure, you do all steps in the above post, before coming here. However, I found out that, the Auth0 sample React JS app has changed a bit. So, we struggled to get the correct scopes in our client app, and by extension, the token that was being returned. After hours and hours of researching, we solved it. I am sharing what we found, here. You can get the sample here, from the main Auth0 repository. However, i strongly recommend you download it directly from the Auth0 dashboard. It, automatically includes most settings. GitHub - auth0-samples/auth0-react-samples: Auth0 Integration Samples for React Applications Auth0 Integration Samples for React Applications. Contribute to auth0-samples/auth0-react-samples development by… github.com I lay out the many things we did to get this working. One — Don’t use Upper Case letter in your ‘audience’ Well, this one is silly and odd, but, apparently, we cannot use upper case letters in the audience name. For example, this is NOT GOOD. TheChalakas.com However, this is just fine. thechalakas.com Two — Update your auth_config.json It should look something like this. The default app does not come with the scope property. Add the ‘scope’ property. {"domain": ".us.auth0.com","clientId": "","audience": ".com","scope": "read:current_user update:current_user_metadata read:testperm1 read:testperm2"} Three — Update your config.js Since the scope property is not included by default, the config.js, also does not ‘extract’ it. You will need to extract it and return it. import configJson from "./auth_config.json";export function getConfig() {// Configure the audience here. By default, it will take whatever is in the config// (specified by the `audience` key) unless it's the default value of "YOUR_API_IDENTIFIER" (which// is what you get sometimes by using the Auth0 sample download tool from the quickstart page, if you// don't have an API).// If this resolves to `null`, the API page changes to show some helpful info about what to do// with the audience.const audience =configJson.audience && configJson.audience !== "YOUR_API_IDENTIFIER"? configJson.audience: null;return {domain: configJson.domain,clientId: configJson.clientId,scope: configJson.scope,...(audience ? { audience } : null),};} Four — Update ReactDOM.render Finally, you need to include the scope property to the Auth0Provider ReactDOM.render(<Auth0Providerdomain= {config.domain}clientId={config.clientId}redirectUri={window.location.origin}audience={config.audience}scope={config.scope}><App /></Auth0Provider>,document.getElementById("root")); Final Note Ultimately, a lot of it is common sense for most folks. Unfortunately, I am not a React JS developer. So, what should have been obvious, became tricky. Hopefully, there are others like me, and hope this helps..
https://medium.com/projectwt/auth0-react-js-sample-app-configuring-scopes-permissions-and-roles-a64efe45de5e?source=read_next_recirc---------0---------------------3d529a0f_7778_42b1_b1d2_4a56b5b73d38-------
CC-MAIN-2022-27
refinedweb
531
51.65
This is part 7 of our full-stack GraphQL + React Tutorial that guides you through creating a messaging application. Each part is self-contained and focuses on a few new topics, so you can jump directly into a part that interests you or do the whole series. Here’s what we have covered so far: - Part 1: Setting up a simple client - Part 2: Setting up a simple server - Part 3: Writing mutations and keeping the client in sync - Part 4: Optimistic UI and client side store updates - Part 5: Input Types and Custom Resolvers - Part 6: GraphQL Subscriptions on the Server - Part 7: Client subscriptions (This part!) - Part 8: Pagination In part 6, we implemented the server-side portion of GraphQL Subscriptions for our message channels. Clients can use these subscriptions to be notified whenever a specific event happens — in this case the creation of a message in a specified channel. In this tutorial, we will add GraphQL Subscriptions to our client so that instances of the client can see live updates to messages in a channel. Let’s get started by cloning the Git repo and installing the dependencies: git clone cd graphql-tutorial git checkout t7-start cd server && npm install cd ../client && npm install First, let’s make sure everything works by starting the server and client. In one terminal session we launch the server, which will run on port 4000: cd server npm start And in another session we launch the client, which will run on port 3000: cd client npm start When you navigate your browser to, you should enter the homepage of our messaging app, which has a list of channels that the user has created. Click on one of the channels, and you’ll be taken to the detail view that we created in Part 5, where you can add new messages in the channel. You’ll notice that if you open the same channel in multiple windows, messages added in one window don’t show up in the other. By the end of this tutorial, client syncing will allow multiple users to see each-other’s changes! GraphQL Subscriptions TransportGraphQL Subscriptions Transport. First, let’s add the necessary imports at the top of client/src/App.js import { SubscriptionClient, addGraphQLSubscriptions } from 'subscriptions-transport-ws'; Next, we construct the WebSocket-based subscription client and merge it with our existing network interface const networkInterface = createNetworkInterface({ uri: '' });networkInterface.use([{ applyMiddleware(req, next) { setTimeout(next, 500); }, }]);const wsClient = new SubscriptionClient(`ws://localhost:4000/subscriptions`, { reconnect: true, });const networkInterfaceWithSubscriptions = addGraphQLSubscriptions( networkInterface, wsClient, ); Now all we have to do to enable subscriptions throughout our application is use networkInterfaceWithSubscriptions as the Apollo Client’s network interface const client = new ApolloClient({ networkInterface: networkInterfaceWithSubscriptions, ... }); If you load up the client and look in the “Network” tab of the developer tools (right-click and “Inspect element”), you should see that the client has established a WebSocket connection to the server. Listening for MessagesListening for Messages Now that we can use GraphQL Subscriptions in our client, the next step is to use subscriptions to detect the creation of messages. Our goal here is to use subscriptions to update our React views to see new messages in a channel as they are added. Before we start, we have to refactor our client/src/components/ChannelDetails.js component to be a full ES6 class component instead of just a function, so that we can use the React lifecycle events to set up the subscription. First, we update our import statement to include the Component class. import React, { Component } from 'react'; Then, we refactor our function component into an ES6 class class ChannelDetails extends Component { render() { const { data: {loading, error, channel }, match } = this.props; if (loading) { return <ChannelPreview channelId={match.params.channelId}/>; } if (error) { return <p>{error.message}</p>; } if(channel === null){ return <NotFound /> } return ( <div> <div className="channelName"> {channel.name} </div> <MessageList messages={channel.messages}/> </div>); } } Now that our component is ready to handle subscriptions, we can write out the subscriptions query: const messagesSubscription = gql` subscription messageAdded($channelId: ID!) { messageAdded(channelId: $channelId) { id text } } ` To make the subscription request, we will use Apollo Client’s subscribeToMore function, which lets us update the store when we receive new data. First, we define a componentWillMount in our component, which is where we will start the subscription. class ChannelDetails extends Component { componentWillMount() { } render() { ... } } Inside this React lifecycle function, we set up our subscription to listen for new messages and add them to our local store as they come. Because the updateQuery function is supposed to produce a new instance of a store state based on prev, the previous store state, we use the Object.assign method to create a copy of the store with modifications to add the new message. Also, because we are manually managing our store of messages, it is possible to have duplicate messages. A message can be added once as the result of performing the mutation and again when we receive the subscription notification. To prevent duplicates, we add an extra check to verify that we did not already add the message to our store with a previous mutation. componentWillMount() { this.props.data.subscribeToMore({ document: messagesSubscription, variables: { channelId: this.props.match.params.channelId, }, updateQuery: (prev, {subscriptionData}) => { if (!subscriptionData.data) { return prev; } const newMessage = subscriptionData.data.messageAdded; // don't double add the message if (!prev.channel.messages.find((msg) => msg.id === newMessage.id)) { return Object.assign({}, prev, { channel: Object.assign({}, prev.channel, { messages: [...prev.channel.messages, newMessage], }) }); } else { return prev; } } }); } We’re almost done now! All we have to do is perform the same de-duplication check in the AddMessage component, because when we create a new message we might be notified of creation through the WebSocket before the query returns data. In client/src/components/AddMessage.js , replace data.channel.messages.push(addMessage); with the same statement wrapped in a condition that checks for duplication if (!data.channel.messages.find((msg) => msg.id === addMessage.id)) { // Add our Message from the mutation to the end. data.channel.messages.push(addMessage); } Now we’re ready to test out our subscription-based live updating messages view! Open two windows of the client and select the same channel in both. When you add a message in one client, you should see the same message show up in the other client! ConclusionConclusion Congrats! You’ve now wired up the server-side implementation of GraphQL Subscriptions to your client through Apollo so that users can see live updates of message additions from other clients. With a couple more changes such as pagination, covered in the next tutorial, and auth your application will be ready for real use! If you liked this tutorial and want to keep learning about Apollo and GraphQL, make sure to click the “Follow” button below, and follow us on Twitter at @apollographql and the author at @ShadajL. Thanks to my mentor, Jonas Helfer, for his support as I wrote.
https://www.apollographql.com/blog/apollo-client/subscriptions/tutorial-graphql-subscriptions-client-side
CC-MAIN-2022-27
refinedweb
1,154
51.89
I am makng a program that finds the mouse position then reads it out i have got that working so far but it only works inside the program window so is there any way to fix this without dramaticly changing my code? thanks in advance This is a discussion on Mouse Program within the C++ Programming forums, part of the General Programming Boards category; I am makng a program that finds the mouse position then reads it out i have got that working so ... I am makng a program that finds the mouse position then reads it out i have got that working so far but it only works inside the program window so is there any way to fix this without dramaticly changing my code? thanks in advance Something like this? PHP Code: #include <iostream> #include <windows.h> int main() { while ( EOF ) { POINT Cursor_Pos; GetCursorPos ( & Cursor_Pos ); std :: cout << "\b\b\b\b\b\b\b\b\b\b\b\b\b\b" << Cursor_Pos.x << " " << Cursor_Pos.y << " "; Sleep ( 10 ); } } What OS, and where is your code? Whatever, assumed Windows as above. Code:while(true) { POINT Cursor_Pos; GetCursorPos ( & Cursor_Pos ); std::cout << "\r" << Cursor_Pos.x << "\t" << Cursor_Pos.y; Sleep( 10 ); } Last edited by Tonto; 04-03-2006 at 05:57 PM. To Tonto: The displayed output with the carriage return character and the tab character will be incorrect, you will see something like: 0 06411. You will need another tab character at the end to overwrite the remain characters. What remaining characters? A CR just goes to the beginning of the line. I am using windows xp and a dev C++ compiler and i would try to put this into a window program now because i found out what i needed heres my code so if it is possible can i put this in a window program? Code:#include <stdlib.h> #include <iostream> #include <windows.h> using namespace std; int main () { char str1[ 80 ]; int x = 10; int y = 100; int v; int b; POINT pt; // cursor location cout << "Hello World this is mouse test!" << endl; cout << "Moving to first Position" << endl; while ( x < 150 ) { GetCursorPos(&pt); sprintf( str1,"%d x %d",pt.x,pt.y ); cout << str1; system ("cls"); x++; } cout << "Press ENTER to continue..." << endl; cin.get(); return 0; } Have you seen how much code is needed to make a window? ya i have would you like me to post the window code i want to use? You can if you want...I am sure I will be overwhelmed in noobyness! Ok heres the code i got it from the dev examples so its not completely noobish Code:; } NO I meant my noobness. Then comes gettign your code into that. i also know how to make a static box buttons and a input box(single or multi-line)... with the controls.
http://cboard.cprogramming.com/cplusplus-programming/77668-mouse-program.html
CC-MAIN-2014-10
refinedweb
471
72.66
Weired QAX setProperty() behavior I use Qt's dumpcpp tool dump the msword.olb to cpp files. There is one method dumped as inline void Paragraph::SetWidowControl(int value){ setProperty("WidowControl", QVariant(value)); } And in my code, I tried three different ways Invoke the method with "SetWidowControl(true)", don't work, and the debug shows: QAxBase: Error calling IDispatch member WidowControl: Unknown error Invoke "setProperty("WidowControl", true)" directly, show the same error message (as it's basically same with case 1). Invoke "dynamicCall("SetWidowControl(bool)", true)", no error message showed and all are OK. I've two questions: - Why 1 and 2 not work? I think they are the 'normal' methods, but they don't work. - According to: Paragraph.WidowControl property. It doesn't mentioned there is a method "SetWidowControl" and the dumpcpp tool didn't dump one. So, why case 3 works? I'm not familiar with COM tech, so what Qt's 'setProperty' does? I guess it must use similar ways as 'dynamicCall()' to direct MSWord to do something. My toolchain is Qt 5.7.0 and VS2015, and the word edition is office365 (office 2016). Hi, the reason #3 flavor works but not #1 and #2 I think occurs because you don't have the correct COM interface instantiated in your QAxBase class. If you check the control property of that class does it say IDispatch or Paragraph? It's usually easier (and slower) to call using dynamicCall() to call into COM. You can call directly (e.g. ... ->SetWindowControl(true); but then you have to set that Control property first. (It's a bit like comparing virtual calls or normal function calls in C++). @hskoglund Thanks for your reply. The word.h and word.cpp are dumpped using command line "dumpcpp msword.olb". The tool automatically generates the classes with methods. class WORD_EXPORT Paragraphs : public QAxObject { public: Paragraphs(IDispatch *subobject = 0, QAxObject *parent = 0) : QAxObject((IUnknown*)subobject, parent) { internalRelease(); } ......... inline int WidowControl() const; //Returns the value of WidowControl inline void SetWidowControl(int value); //Sets the value of the WidowControl property .......... } Can you give me more informations about where the property defined? Hi, I think the properties are mostly used from Visual Basic and C# and SetWidowControl() function are used from C++ I also have dumpcpp.exe and msword.olb somewhere in my computer, I can make a simple demo/test program using method #1 (or #2) later tonight if you need. @hskoglund I'm really appreciated if you can have try it for me :). Now I'm not if it's Qt's bug or MS's bug. And I find that Qt's method accept a 'int', it seems MS use 'bool', can this be the reason? BTW, Qt's dumpcpp is not perfect yet, when generating the method, it sometimes omit the class qualifier with the first parameter. such as it generate 'Range' instead of 'Word::Range', so you may need manually add 'Word::' to them :(. Maybe a brute 'using namespace Word;' should work too. Hi, yesterday I tested running dumpcpp on the msword.olb on my computer (I have Office 2010 installed). Sure enough I got a word.cpp and word.h but the generated .cpp file was 60 MB! When I tried to compile in using Qt 5.7+MSVC2015 I got errors on stuff like ListTemplate and Range :-( And trying to edit that 60 MB word.cpp file ---> Qt Creator crashes.. So I spent some time splitting in up and getting it compile cleanly. But try as I might, I could only get #2 and #3 not #1 (which I think is the superior one). Finally I realized that the dumpcpp program had maybe misparsed something in that huge msword.olb. Since the object model for Office has been more or less the same the last 20 years, if I could find an older version of Office perhaps that msword.olb would be a better match for dumpcpp. On my old portable I had Office 2003, run dumpcpp and voila a word.cpp only 30 MB (a midget), and most important no errors when compiling :-) You have Office 2016 perhaps that msword.olb also gives better word.cpp and word.h files? Anyway, I think it doesn't matter what version of Office you use, as long as the compilation runs ok. I'll post now 2 versions of my test program, one using dynamic calls (or rather the usual querySubObject() flavor and the other using more fancy C++ direct calls. First version: create a vanilla Qt widgets app, in the .pro file insert "axcontainer" after "...gui" on the top line. Then in mainwindow.cpp, insert "#include qaxobject.h" at the top and after ui->setupUi(this); insert: auto wApp = new QAxObject("Word.Application"); if (nullptr == wApp) return; wApp->setProperty("Visible",true); auto doc = wApp->querySubObject("Documents")->querySubObject("Add()"); for (int p = 0; (p < 100); ++p) { auto para = doc->querySubObject("Content")->querySubObject("Paragraphs")->querySubObject("Add()"); para->querySubObject("Range")->setProperty("Text","Four score and seven years ago our fathers " "brought forth on this continent a new nation, conceived in liberty, and dedicated to the " "proposition that all men are created equal."); para->querySubObject("Format")->setProperty("SpaceAfter",20); para->setProperty("WidowControl",-1); // for true // para->setProperty("WidowControl",0); // for false para->querySubObject("Range")->querySubObject("InsertParagraphAfter()"); } This is the style I think 99% of QAxObject programs are written. Advantages: you don't need to run dumpcpp and you don't need to include any humongous word.* files in your project. Disadvantage: just like JS, no compile time checks, surprises can await you when you start the program. 2nd version, a bit more fancy, requiring you to run dumpcpp to get 2 files: word.cpp and word.h. Create a vanilla widget app, insert " axcontainer" in the .pro file (same as above). Add word.cpp into your project (so it wil compiled along with main.cpp and mainwindow.cpp. Then in mainwindow.cpp insert "#include word.h" at the top, and after ui->setupUi(this); insert: auto wApp = new Word::Application; if (nullptr == wApp) return; wApp->SetVisible(true); auto doc = wApp->Documents()->Add(); for (int p = 0; (p < 100); ++p) { auto para= doc->Content()->Paragraphs()->Add(); para->Range()->Set."); para->Format()->SetSpaceAfter(20); para->SetWidowControl(0); // for false // para->setWidowControl(-1); // for true para->Range()->InsertParagraphAfter(); } These calls will be changed to dynamic calls inside word.h but it's nice to have command completions and syntax checking by the compiler. Note: when dealing with COM, thanks to it being used first by Visual Basic and VBA for Office, it's sometimes problems with the boolean chaps true and false, so I prefer to use 0 for false and -1 for true, same as in the Visual Basic.
https://forum.qt.io/topic/69058/weired-qax-setproperty-behavior
CC-MAIN-2018-22
refinedweb
1,122
58.58
Parrot - Quick Guide What is Parrot When we feed our program into conventional Perl, it is first compiled into an internal representation, or bytecode; this bytecode is then fed into almost separate subsystem inside Perl to be interpreted. So there are two distinct phases of Perl's operation: Compilation to bytecode and Interpretation of bytecode. This is not unique to Perl. Other languages following this design include Python, Ruby, Tcl and even Java. We also know that there is a Java Virtual Machine (JVM) which is a platform independent execution environment that converts Java bytecode into machine language and executes it. If you understand this concept then you will understand Parrot. Parrot is a virtual machine designed to efficiently compile and execute bytecode for interpreted languages. Parrot is the target for the final Perl 6 compiler, and is used as a backend for Pugs, as well as variety of other languages like Tcl, Ruby, Python etc. Parrot has been written using most popular language "C". Parrot Installation Before we start, let's download one latest copy of Parrot and install it on our machine. Parrot download link is available in Parrot CVS Snapshot. Download the latest version of Parrot and to install it follow the following steps: Unzip and untar the downloaded file. Make sure you already have Perl 5 installed on your machine. Now do the following: % cd parrot % perl Configure.pl Parrot Configure Copyright (C) 2001 Yet Another Society Since you're running this script, you obviously have Perl 5 -- I'll be pulling some defaults from its configuration. ... You'll then be asked a series of questions about your local configuration; you can almost always hit return/enter for each one. Finally, you'll be told to type - make test_prog, and Parrot will successfully build the test interpreter. Now you should run some tests; so type 'make test' and you should see a readout like the following: perl t/harness t/op/basic.....ok,1/2 skipped:label constants unimplemented in assembler t/op/string....ok, 1/4 skipped: I'm unable to write it! All tests successful, 2 subtests skipped. Files=2, Tests=6,...... By the time you read this, there could be more tests, and some of those which skipped might not skip, but make sure that none of them should fail! Once you have a parrot executable installed, you can check out the various types of examples given in Parrot 'Examples' section. Also you can check out the examples directory in the parrot repository. Parrot Instructions Format instruction set. Garbage Collection in Parrot. Parrot Datatypes The Parrot CPU has four basic data types: IV An integer type; guaranteed to be wide enough to hold a pointer. NV An architecture-independent floating-point type. STRING An abstracted, encoding-independent string type. PMC A scalar. The first three types are pretty much self-explanatory; the final type - Parrot Magic Cookies, are slightly more difficult to understand. What are PMCs? PMC stands for Parrot Magic Cookie.. Parrot Operations There are a variety of operations you can perform. For instance, we can print out the contents of a register or a constant: set I1, 10 print "The contents of register I1 is: " print I1 print "\n" The above instructions will result in The contents of register I1 is: 10 We can perform mathematical operations on registers: # Add the contents of I2 to the contents of I1 add I1, I1, I2 # Multiply I2 by I4 and store in I3 mul I3, I2, I4 # Increment I1 by one inc I1 # Decrement N3 by 1.5 dec N3, 1.5 We can even perform some simple string manipulation: set S1, "fish" set S2, "bone" concat S1, S2 # S1 is now "fishbone" set S3, "w" substr S4, S1, 1, 7 concat S3, S4 # S3 is now "wishbone" length I1, S3 # I1 is now 8 Parrot Branches Code gets a little boring without flow control; for starters, Parrot knows about branching and labels. The branch op is equivalent to Perl's goto: branch TERRY JOHN: print "fjords\n" branch END MICHAEL: print " pining" branch GRAHAM TERRY: print "It's" branch MICHAEL GRAHAM: print " for the " branch JOHN END: end It can also perform simple tests to see whether a register contains a true value: set I1, 12 set I2, 5 mod I3, I2, I2 if I3, REMAIND, DIVISOR REMAIND: print "5 divides 12 with remainder " print I3 branch DONE DIVISOR: print "5 is an integer divisor of 12" DONE: print "\n" end Here's what that would look like in Perl, for comparison: $i1 = 12; $i2 = 5; $i3 = $i1 % $i2; if ($i3) { print "5 divides 12 with remainder "; print $i3; } else { print "5 is an integer divisor of 12"; } print "\n"; exit; Parrot Operator We have the full range of numeric comparators: eq, ne, lt, gt, le and ge. Note that you can't use these operators on arguments of disparate types; you may even need to add the suffix _i or _n to the op, to tell it what type of argument you are using, although the assembler ought to divine this for you, by the time you read this. Parrot Programming Examples Parrot programing is similar to assembly language programing and you get a chance to work at lower level. Here is the list of programming examples to make you aware of the various aspects of Parrot Programming. - Classic Hello world! - Using registers - Summing squares - Fibonacci Numbers - Computing factorial - Compiling to PBC - PIR vs. PASM Classic Hello world! Create a file called hello.pir that contains the following code: .sub _main print "Hello world!\n" end .end Then run it by typing: parrot hello.pir As expected, this will display the text 'Hello world!' on the console, followed by a new line (due to the \n). In this above example, '.sub _main' states that the instructions that follow make up a subroutine named '_main', until a '.end' is encountered. The second line contains the print instruction. In this case, we are calling the variant of the instruction that accepts a constant string. The assembler takes care of deciding which variant of the instruction to use for us. The third line contains the 'end' instruction, which causes the interpreter to terminate. Using Registers We can modify hello.pir to first store the string Hello world!\n in a register and then use that register with the print instruction. .sub _main set S1, "Hello world!\n" print S1 end .end Here we have stated exactly which register to use. However, by replacing S1 with $S1 we can delegate the choice of which register to use to Parrot. It is also possible to use an = notation instead of writing the set instruction. .sub _main $S0 = "Hello world!\n" print $S0 end .end To make PIR even more readable, named registers can be used. These are later mapped to real numbered registers. .sub _main .local string hello hello = "Hello world!\n" print hello end .end The '.local' directive indicates that the named register is only needed inside the current compilation unit (that is, between .sub and .end). Following '.local' is a type. This can be int (for I registers), float (for N registers), string (for S registers), pmc (for P registers) or the name of a PMC type. Summing squares This example introduces some more instructions and PIR syntax. Lines starting with a # are comments. .sub _main # State the number of squares to sum. .local int maxnum maxnum = 10 # Some named registers we'll use. # Note how .end PIR provides a bit of syntactic sugar that makes it look more high level than assembly. For example: temp = i * i Is just another way of writing the more assembly-ish: mul temp, i, i And: if i <= maxnum goto loop Is the same as: le i, maxnum, loop And: total += temp Is the same as: add total, temp As a rule, whenever a Parrot instruction modifies the contents of a register, that will be the first register when writing the instruction in assembly form. As is usual in assembly languages, loops and selections are implemented in terms of conditional branch statements and labels, as shown above. Assembly programming is one place where using goto is not a bad form! Fibonacci Numbers The Fibonacci series is defined like this: take two numbers, 1 and 1. Then repeatedly add together the last two numbers in the series to make the next one: 1, 1, 2, 3, 5, 8, 13, and so on. The Fibonacci number fib(n) is the n'th number in the series. Here's a simple Parrot assembler program that finds the first 20 Fibonacci numbers: # Some simple code to print some Fibonacci numbers print "The first 20 fibonacci numbers are:\n" set I1, 0 set I2, 20 set I3, 1 set I4, 1 REDO: eq I1, I2, DONE, NEXT NEXT: set I5, I4 add I4, I3, I4 set I3, I5 print I3 print "\n" inc I1 branch REDO DONE: end This is the equivalent code in Perl: print "The first 20 fibonacci numbers are:\n"; my $i = 0; my $target = 20; my $a = 1; my $b = 1; until ($i == $target) { my $num = $b; $b += $a; $a = $num; print $a,"\n"; $i++; } NOTE: As a fine point of interest, one of the shortest and certainly the most beautiful ways of printing out a Fibonacci series in Perl is perl -le '$b=1; print $a+=$b while print $b+=$a'. Recursively computing factorial In this example we define a factorial function and recursively call it to compute factorial. .sub _fact # Get input parameter. .param int n # return (n > 1 ? n * _fact(n - 1) : 1) .local int result if n > 1 goto recurse result = 1 goto return recurse: $I0 = n - 1 result = _fact($I0) result *= n return: .return (result) .end .sub _main :main .local int f, i # We'll do factorial 0 to 10. i = 0 loop: f = _fact(i) print "Factorial of " print i print " is " print f print ".\n" inc i if i <= 10 goto loop # That's it. end .end Let's look at the _fact sub first. A point that was glossed over earlier is why the names of subroutines, all start with an underscore! This is done simply as a way of showing that the label is global rather than scoped to a particular subroutine. This is significant as the label is then visible to other subroutines.: result = _fact($I0) This single line of PIR actually represents quite a few lines of PASM. First, the value in register $I0 is moved into the appropriate register for it to be received as an integer parameter by the _fact function. Other calling related registers are then set up, followed by _fact being invoked. Then, once _fact returns, the value returned by _fact is placed into the register given the name result. Right before the .end of the _fact sub, a .return directive is used to ensure the value held in the register; named result is placed into the correct register for it to be seen as a return value by the code calling the sub. The call to _fact in main works in just the same way as the recursive call to _fact within the sub _fact PIR vs. PASM PIR can be turned into PASM by running: parrot -o hello.pasm hello.pir The PASM for the final example looks like this: _main: set S30, "Hello world!\n" print S30 end PASM does not handle register allocation or provide support for named registers. It also does not have the .sub and .end directives, instead replacing them with a label at the start of the instructions.
https://www.tutorialspoint.com/parrot/parrot_quick_guide.htm
CC-MAIN-2018-17
refinedweb
1,942
62.88
Hide Forgot Description of problem: The /usr/include/slang/slcurses.h file contains: #include <slang.h> but it does not work because slang-devel uses slang/ subdirectory for all headers. The another problem is that pkg-config --cflags slang does not return -I/usr/include/slang. I think the best way how to fix this problem is to use "#include <slang/slang.h>" in /usr/include/slang/slcurses.h. It would be also nice to add -I/usr/include/slang to slang.pc. The workaround is to explicitly include slang.h in all applications where is necessary slcurses.h, for example: #include <slang/slang.h> #include <slang/slcurses.h> I didn't test it, but I guess that the same problem exists in F-13 rawhide and RHEL6. A better solution might be moving the headers back to /usr/include as they are supposed to be and add symlinks to /usr/include/slang. Fixed in slang-2.2.2-2.fc14.
https://bugzilla.redhat.com/show_bug.cgi?id=609977
CC-MAIN-2019-13
refinedweb
161
70.9
Dat View Complete Post Hi everybody! I'm developing a WPF application that needs a combobox updating another combobox items when selection changes. I isolated the code and the problem is still there, when i change the first selection and then click the other it takes a lot of time (IMHO) namespace TestCombobox { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { private List<string> methodsList; private Dictionary<string, List<string>> dict; public MainWindow() { InitializeComponent(); dict = new Dictionary<string, List<string>>(); for( Setting SelectedValue for ComboBox When you add combobox items inside xaml then SelectedValue of the Combo Box didn't Paul DiLascia codes some Microsoft Office-style dialog box features. Paul DiLascia MSDN Magazine August 2006? How can we bind a value to a combobox or dropdown? What is the property for binding a value? Thanks. Ok, while I am digging and digging myself into the world that's called Sharepoint I come to the next challenge. ÃÂ I have two lists Projects List and Project Issues. They both have an id field (which is not the ID field of the record) and a title. I created two calculated fields for both of the tables which combines the title and the number for displaying in other pages. example: Projects List: ProjectID: 2008-001 Project Name: First Project in 2008 Display Name (which is the calculated field): 2008-001 First Project in 2008 The calculated field formula is: =[ProjectID]&" "&[Project Name] The field returns a string. I also have a Worksheet list where my workers have to fill in their working hours. In this list I have two lookup fields. O I have added a combobox to my page. Listview is updated based on selection from combobox. It is working great except it does not fire when Enter is pressed. User has to click on option from dropdown or has to press tab key to have Listview to populate. I want the user to be able type use arrow key to select option and then press the enter key for event to fire. Using .net 3.5 and c# I am trying to troubleshoot an issue where some users of our SharePoint environment have problems using the open with windows explorer option in a document library.
http://www.dotnetspark.com/links/64658-combobox-selectedvalue-too-slow.aspx
CC-MAIN-2017-04
refinedweb
379
61.36
To. I would recommend starting with some Java tutorials and then switch to Android. If you haven’t programmed before…well that’s though but it’s solvable. Google for some programming tutorials and don’t get discouraged! Then check back here. I will use Android 2.2 as it is the latest at the time of this writing and I suspect it will take a long time till I finish this project so it just might be quite used. Also because we plan to use multi-touch we need version 2.x. First let’s create the AVD (Android Virtual Device). Click on the little Android icon or choose Window -> Android SDK and AVD Manager and click on the New… button. Set the name to MyDevice, the target to Android 2.2 – API Level 8. Set 128 MiB for the SD Card. Set the Skin to Built-in HVGA and the Hardware to Abstracted LCD density to 160. These are the current default settings. Click Create AVD and the virtual device should be created. Now let’s create the project. Select from the menu: New -> Project and choose Android Project. Fill in as per the screen-shot and click Finish. The Application name is the name given to our game. The package name is just the name space to group our classes. Select Android 2.2 for Build Target. The most important is the Create Activity. The Activity is the class instantiated when the application is started. Don’t have to worry about it right now just remember that is the first thing being called. In a nutshell the Activity handles our input (gets the touches on the screen), creates the window where we will display our game and so on. This usually is a full screen window and we will use one as such. Let’s run the created application. Right click on the project and choose Run As -> Android Application. Choose the configured device and wait for it to load. Remember not to close the Virtual Device once it has started as every time you will run your project, eclipse will redeploy it to the currently running device and will save you a lot of time if it’s already started. You should see a screen like the one below. If the device asks you to unlock the screen do it by dragging the unlock button with your mouse. Now let’s examine what has just happened. Open the DroidzActivity.java file. package net.obviam.droidz; import android.app.Activity; import android.os.Bundle; public class DroidzActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } You’ll notice one method. The onCreate() method on line 09. This method is called when the activity is being created at the application launch. It’s sets the view (the display) to be the default R (check R.java) which is the default resource view automatically generated by the android tools behind the scenes. This file feeds on multiple configuration files to provide the activity with the view. It reads the main.xml from the res (which stands for resources) directory and parses it. Let’s open the res/layout/main.xml file: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns: <TextView android: </LinearLayout> You’ll notice that a LinearLayout is used that fills up the whole screen and has a vertical positioning (Line 2). Line 3 tells that our orientation is horizontal while lines 4 and 5 instruct android to use the whole display (currently the parent is the display) for the view. Line 7 defines a TextView which is just a label that takes up a whole line of the contained text’s height. The value is a placeholder read from the @string file. @string is also a placeholder for the strings.xml file and opening this file you’ll immediately notice that this is the place where the actually displayed value comes from. Worth noting that the R.java file is regenerated after we modify strigs.xml and for each resource entry a corresponding constant is generated and it will be used internally. Open the /res/values/strings.xml file: <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, DroidzActivity!</string> <string name="app_name">droidz</string> <string name="warning">Robots are rising</string> </resources> These are the resource strings. Apart from line 5 which I added everything is generated. To add the warning message to the display just after the hello message modify the main.xml file and add a new TextView that will display our @warning message. The new main.xml file looks like this: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns: <TextView android: <TextView android: </LinearLayout> If you run the activity then you should have a screen displaying the new warning message too. Worth noting that eclipse regenerated the R.java file and if you open it you will notice a similar line to this: public static final int warning=0x7f040002; It is generated by the android tooling and it keeps the IDs and pointers to the actual resources that are used in the activity. Go ahead and play with the current setting and see what the options are for different display widgets. Next we will actually load some images and draw them onto the screen.′.
http://www.javacodegeeks.com/2011/07/android-game-development-create-project.html
CC-MAIN-2015-22
refinedweb
901
67.96
#include <hallo.h> * Osamu Aoki [Sun, Nov 10 2002, 02:44:13PM]: > When display manager are installed, script rightfully asks which display > manager to install using install script. Great feature but one more > twist shall make many newbie shut-up crying. here is my suggestion: > > In the dialogue to choose the desired default display manager, please > add a word "console" or "disabled" as an option. > > The content of /etc/X11/default-display-manager can be "null" or > any bogus word like "disabled" if this option is chosen. BUAHAHAHAHA, have fun convincing Branden to make a such USERFRIENDLY change. Similar story to my request to make an alternative for x-session-manager to skip the session manager and load the WM. Gruss/Regards, Eduard. -- Expect the unexpected and expect the expected to be late.
http://lists.debian.org/debian-x/2002/11/msg00174.html
CC-MAIN-2013-48
refinedweb
133
53.81
Introduction In this article we are going to explore how to work with collections of items to bind them into a control in a Metro Style App. Further in this we will discuss all the details of how it is possible to bind them. In this article first of all we will take a generic list in which we will add items information. Further we will create some properties about these items such as Name, Model Name and Price; whatever you want to give you can easily do using properties. Further In this section we will see how to bind a collection of business objects to a data control. We will bind data with a Dropdown list. First, we will create an object called Cars of List<> collection type, which is a strongly typed list. Then we will add class objects to this list collection and finally we will bind the object Cars to a Dropdown list with the help of DataContext. If you want to implement this type of functionality in a Metro Style App then you should follow the steps which is given below. Now let's start to work with these controls; see the steps. Step 1: In this step you will see how to start working with a Metro Style App; let's see the steps, given below: Step 2: In this step we will see a class in which we have defined some properties which is given below. Code: 3: In this step we will see the code for the MainPage.xaml file which is shown below. Code: <UserControl x:Class="Myapp.MainPage" xmlns="" xmlns:x="" xmlns:d="" xmlns:mc="" mc:Ignorable="d" d: <Grid x: <Grid.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="Black"/> <GradientStop Color="#FF20A089" Offset="1"/> </LinearGradientBrush> </Grid.Background> <ComboBox x: <ComboBox.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="Black"/> <GradientStop Color="#FF227DBB" Offset="0.182"/> </LinearGradientBrush> </ComboBox.Background> </ComboBox> </Grid> </UserControl> Step 4: In this step we will see the code for the MainPage.xaml.cs file which is shown below. using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Windows.Foundation; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Data; namespace Myapp { partial class MainPage { public List<MyCar> Cars = new List<MyCar>(); public MainPage() { InitializeComponent(); // Add items to the collection. Cars.Add(new MyCar("Ferrari", "F1", "$222000")); Cars.Add(new MyCar("Tata", "Safari", "630000")); Cars.Add(new MyCar("Hyundai", "Santro", "422000")); Cars.Add(new MyCar("Tata", "Nano", "122000")); Cars.Add(new MyCar("Toyota", "Fortuner", "2322000")); Cars.Add(new MyCar("Honda", "SX4", "622000")); // Set the data context for the combo box. cboCars.DataContext = Cars; } // A Business object of a Car 5: In this step we are going to run the application by pressing F5 and the output regarding it is given below. Output 1: Output 2: Output 3: Output 4: Here are some other resources which may help you Windows 8: Adding Shortcuts to Metro UIIntroduction to Windows 8 Metro Style ApplicationWindows 8 Metro Application DevelopmentBinding and Defining Layout Through XAML in Metro Style Application ©2016 C# Corner. All contents are copyright of their authors.
http://www.c-sharpcorner.com/UploadFile/74f20d/binding-a-collection-of-item-to-a-control-in-metro-style-app/
CC-MAIN-2016-36
refinedweb
535
59.7
Yeah, I just figured this out, for some reason I can swear this didn’t work last week, but perhaps I was lacking coffee Thank you though man Hello, fixed now, so im using templates/namespace/Layout/ContactPage.ss and solve the issue, earlier im using templates/namespace/ContactPage.ss @wmk the global Hi all. Userforms question.... Does anybody know if it’s possible to submit the form to a recipient based on the choice of a radiobutton on the frontend? Should be possible using the “Custom Rules” tab under recipients. You can set it to only send to a recipient based on form values. Hello, any recommendation for CMS color picker?
https://slackarchive.silverstripe.org/slack-archive/message/291836
CC-MAIN-2019-51
refinedweb
112
56.55
retinanet_detection_output¶ - paddle.fluid.layers.detection. retinanet_detection_output ( bboxes, scores, anchors, im_info, score_threshold=0.05, nms_top_k=1000, keep_top_k=100, nms_threshold=0.3, nms_eta=1.0 ) [source] Detection Output Layer for the detector RetinaNet. In the detector RetinaNet , many FPN levels output the category and location predictions, this OP is to get the detection results by performing following steps: For each FPN level, decode box predictions according to the anchor boxes from at most nms_top_ktop-scoring predictions after thresholding detector confidence at score_threshold. Merge top predictions from all levels and apply multi-class non maximum suppression (NMS) on them to get the final detections. - Parameters bboxes (List) – A list of Tensors from multiple FPN levels represents the location prediction for all anchor boxes. Each element is a 3-D Tensor with shape \([N, Mi, 4]\), \(N\) is the batch size, \(Mi\) is the number of bounding boxes from \(i\)-th FPN level and each bounding box has four coordinate values and the layout is [xmin, ymin, xmax, ymax]. The data type of each element is float32 or float64. scores (List) – A list of Tensors from multiple FPN levels represents the category prediction for all anchor boxes. Each element is a 3-D Tensor with shape \([N, Mi, C]\), \(N\) is the batch size, \(C\) is the class number (excluding background), \(Mi\) is the number of bounding boxes from \(i\)-th FPN level. The data type of each element is float32 or float64. anchors (List) – A list of Tensors from multiple FPN levels represents the locations of all anchor boxes. Each element is a 2-D Tensor with shape \([Mi, 4]\), \(Mi\) is the number of bounding boxes from \(i\)-th FPN level, and each bounding box has four coordinate values and the layout is [xmin, ymin, xmax, ymax]. The data type of each element is float32 or float64. im_info (Variable) – A 2-D Tensor with shape \([N, 3]\) represents the size information of input images. \(N\) is the batch size, the size information of each image is a 3-vector which are the height and width of the network input along with the factor scaling the origin image to the network input. The data type of im_infois float32. score_threshold (float) – Threshold to filter out bounding boxes with a confidence score before NMS, default value is set to 0.05. nms_top_k (int) – Maximum number of detections per FPN layer to be kept according to the confidences before NMS, default value is set to 1000. keep_top_k (int) – Number of total bounding boxes to be kept per image after NMS step. Default value is set to 100, -1 means keeping all bounding boxes after NMS step. nms_threshold (float) – The Intersection-over-Union(IoU) threshold used to filter out boxes in NMS. nms_eta (float) – The parameter for adjusting nms_thresholdin NMS. Default value is set to 1., which represents the value of nms_thresholdkeep the same in NMS. If nms_etais set to be lower than 1. and the value of nms_thresholdis set to be higher than 0.5, everytime a bounding box is filtered out, the adjustment for nms_thresholdlike nms_threshold= nms_threshold* nms_etawill not be stopped until the actual value of nms_thresholdis lower than or equal to 0.5. Notice: In some cases where the image sizes are very small, it’s possible that there is no detection if score_thresholdare used at all levels. Hence, this OP do not filter out anchors from the highest FPN level before NMS. And the last element in bboxes:, scoresand anchorsis required to be from the highest FPN level. - Returns The detection output is a 1-level LoDTensor with shape \([No, 6]\). Each row has six values: [label, confidence, xmin, ymin, xmax, ymax]. \(No\) is the total number of detections in this mini-batch. The \(i\)-th image has LoD[i + 1] - LoD[i] detected results, if LoD[i + 1] - LoD[i] is 0, the \(i\)-th image has no detected results. If all images have no detected results, LoD will be set to 0, and the output tensor is empty (None). - Return type Variable(The data type is float32 or float64) Examples import paddle.fluid as fluid bboxes_low = fluid.data( name='bboxes_low', shape=[1, 44, 4], dtype='float32') bboxes_high = fluid.data( name='bboxes_high', shape=[1, 11, 4], dtype='float32') scores_low = fluid.data( name='scores_low', shape=[1, 44, 10], dtype='float32') scores_high = fluid.data( name='scores_high', shape=[1, 11, 10], dtype='float32') anchors_low = fluid.data( name='anchors_low', shape=[44, 4], dtype='float32') anchors_high = fluid.data( name='anchors_high', shape=[11, 4], dtype='float32') im_info = fluid.data( name="im_info", shape=[1, 3], dtype='float32') nmsed_outs = fluid.layers.retinanet_detection_output( bboxes=[bboxes_low, bboxes_high], scores=[scores_low, scores_high], anchors=[anchors_low, anchors_high], im_info=im_info, score_threshold=0.05, nms_top_k=1000, keep_top_k=100, nms_threshold=0.45, nms_eta=1.0)
https://www.paddlepaddle.org.cn/documentation/docs/en/api/paddle/fluid/layers/detection/retinanet_detection_output_en.html
CC-MAIN-2021-31
refinedweb
786
56.25
How to refresh an Angular 2 page using Java to avoid the 404 error You just built your first application using Angular 2 (or 4) and the tester comes to you saying that when he refreshes the page using the browser he get a 404 error. How it comes? Angular doesn’t use anymore the # in the URL. When you refresh the page using the URL showed by Angular the web server doesn’t find any valid match. web.xml solution If you are developing your application with Java EE or Spring the solution is very simple and you don’t have to implement code in your frontend. You can simply add this code snippet in your web.xml <error-page> <error-code>404</error-code> <location>/</location> </error-page> If the page is not found a simple redirection to the frontend page get the work done. The frontend will show the correct page. The Using a controller A different approach uses a Spring @controller on the backend. In this example all the links (controllers) of the frontend are prefixed with ‘app’. The controller receives the request and forward it to the frontend that open the correct page. This solution is implemented in the example: angular.cafe package ch.javaee.demo.angular2.web; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class RouterController { @RequestMapping({"/app-*"}) public String app() { return "forward:/index.html"; } } Using a Filter We only mention the possibility to solve the problem implementing a custom javax.servlet.Filter.
https://javaee.ch/2017/04/12/how-to-solve-the-redirection-404-error-in-angular-using-java/
CC-MAIN-2019-30
refinedweb
256
57.98
Created on 2011-07-07 13:12 by haypo, last changed 2014-07-03 22:00 by BreamoreBoy. The following test fails with an AssertionError('a' != 'b') on the first read. import codecs FILENAME = 'test' with open(FILENAME, 'wb') as f: f.write('abcd'.encode('utf-8')) with codecs.open(FILENAME, 'r+', encoding='utf-8') as f: f.write("1") pos = f.writer.tell() assert pos == 1, "writer pos: %s != 1" % pos pos = f.reader.tell() assert pos == 1, "reader pos: %s != 1" % pos pos = f.stream.tell() assert pos == 1, "stream pos: %s != 1" % pos # read() must call writer.flush() char = f.read(1) assert char == 'b', "%r != 'b'" % (char,) # write() must rewind the raw stream f.write('3') tail = f.read() assert tail == 'd', "%r != 'd'" % (tail,) f.flush() with open(FILENAME, 'rb') as f: assert f.read() == b'1b3d' I suppose that readline(), readlines() and __next__() have also issues. See also issue #12215: similar issue with io.TextIOWrapper. Codecs gurus FYI.
http://bugs.python.org/issue12513
CC-MAIN-2016-18
refinedweb
164
82.71
Java awt - Swing AWT , For solving the problem visit to : Thanks... market chart this code made using "AWT" . in this chart one textbox when user Java Problem Steps - Swing AWT Java Problem Steps How to create a Jar File From the Dos prompt of a Swing program having two classes in the program with one is public class one of themash awt Java AWT Applet example how to display data using JDBC in awt/applet java-swings - Swing AWT java-swings How to move JLabel using Mouse? Here the problem is i have a set of labels in a panel. I want to arrange them in a customized order...:// Thanks. Amardeep Java AWT Package Example Java AWT Package Example In this section you will learn about the AWT package of the Java. Many running examples are provided that will help you master AWT package. Example Multiple session problem - Swing AWT Multiple session problem I am working in a Linux based java swing application. Problem: I have optimized JDialog and JPanel for my use.... This problem is quite critical as UI looks quite unpredictable due awt in java awt in java using awt in java gui programming how to false the maximization property of a frame java image loadin and saving problem - Swing AWT java image loadin and saving problem hey in this code i am trying to load a picture and save it.........but image is only visible whn we maximize the frame savin is nt done plzz help me with this code......... import code - Swing AWT code i want example problem for menubar in swings Hi Friend, Please visit the following links: Java AWT Package Example Problem in card demo example. Problem in card demo example. Hi, I have successfully shows...://... help me, I am using Eclipse and card demo example by following link http AWT Tutorials AWT Tutorials How can i create multiple labels using AWT???? Java Applet Example multiple labels 1)AppletExample.java: import javax.swing.*; import java.applet.*; import java.awt.*; import AWT java how to use JTray in java give the answer with demonstration or example please java - Swing AWT java hello sir.. i want to start the project of chat server in java please help me out how to start it?? urgently.... Hi friend, To solve problem to visit this link....... JAVA Problem JAVA Problem Write a program that takes two parameters 1. a word 2. an array of words It should then remove all instances of the word in the array. For Example: INPUT word="ravi" word_array = ["Chethan Bhagat - Swing AWT the problem to visit...... java - Swing AWT java how can i add items to combobox at runtime from jdbc Hi Friend, Please visit the following link: Thanks Hi Friend question - Swing AWT Java question I want to create two JTable in a frame. The data in one JTable will be shown as a result of a query i.e. the data in a resultset... be displayed. PLEASE SOLVE MY PROBLEM AS SOON AS POSSIBLE. Hi Friend, Try java - Swing AWT What is Java Swing AWT What is Java Swing AWT Authentication of password - Swing AWT information. Thanks... running code. If you have any problem then explain in detail. import java.io. Create a Container in Java awt Create a Container in Java awt Introduction This program illustrates you how to create...; } } Download this example SWINGS - Swing AWT more information,Examples and Tutorials on Swing,AWT visit to : displaying image in awt - Java Beginners to display image using awt from here and when I execute the code I am getting... g.drawImage(image,20,45,this); How can I solve this problem. Thanks... ActionListener{ JFrame fr = new JFrame ("Image loading program Using awt"); Label java problem - Java Beginners java problem Hotel.java This file declares a class of object which... will represent the room number in the hotel. For example room numbered 2... from a small Java program problem problem Hi, what is java key words Hi Friend, Java Keywords are the reserved words that are used by the java compiler for specific... information, visit the following link: Java Keywords Thanks java problem - Java Beginners java problem Room.java This file defines a class of Room objects... with beds, tariff , and is vacant. Example: Room with 2 beds, tariff 100.00... will represent the room number in the hotel. For example room numbered 2 How to save data - Swing AWT to : Thanks...How to save data Hi, I have a problem about how to save data... please help me Hi friend, Code to help in solving the problem problem problem hi'sir mai niit student hu.mujhe java ka program samaj me nhi aata mai kya karu and mai kaise study karu please help me. Learn Java from the given link: Java Tutorials JavaThread AWT-EventQueue-176 - Applet JavaThread "AWT-EventQueue-176 Hello, I am getting some dump files... of sudden. How to prevent Browser from crashing and solve the problem of dumps... # # Java VM: Java HotSpot(TM) Client VM (1.5.0_05-b05 mixed mode) # Problematic frame Event handling in Java AWT Event handling in Java AWT  ... events in java awt. Here, this is done through the java.awt.*; package of java. Events are the integral part of the java platform. You can see the concepts Java Swings-awt - Swing AWT Java Swings-awt Hi, Thanks for posting the Answer... I need to design a tool Bar which looks like a Formating toolbar in MS-Office Winword(Standard & Formating) tool Bar. Please help me... Thanks in Advance java programming problem - Java Beginners /java/java-tips/data/strings/96string_examples/example_count.shtml http.../java-tips/data/strings/96string_examples/example_countVowels.shtml follow...java programming problem Hello..could you please tell me how can I code problem - Java Beginners in Java visit to : Thanks... lines of a particular file i've to display every Line's contains, example- Line1...; Hi friend, Code to help in solving the problem : import java.io. problem - Java Beginners code problem Dear sir, my question was actually how to find a particual line's contain, example if a file contains- hy, how r u? regrd, john... your problem in details. Which keyword search the line. Thanks Java program problem is a path to a directory. Example: java DuplicateFinder c:\Documents...Java program problem Hi, I took the chance to login here in your educational page due to my questions in mind about my java programming assignment Program for Calculator - Swing AWT Program for Calculator write a program for calculator? Hi Friend, Please visit the following link: Hope that it will be helpful Code Problem - Java Beginners java Code Problem Hi Sir. i am creating one java program in which i want to remove unsed variables from java program and store it into another name or same name.for example,my program is as follows. class Prog1 { int Look and Feel - Swing AWT : Hope provide code - Swing AWT ); } } ------------------------------------- visit for more information. Thanks... GAME.....using swings,awt concepts Hi friend, import java.awt. problem - Java Beginners Example! "); System.out.println("Please enter integer number! "); String str..."); } } ------------------------------------- Read for more information. Thanks coding problem - Java Beginners coding problem hi friend! Im new to jasper reports.how can i start that coding inorder to generate reports.can u send some sample programs for reporting?im badly need some clearly mentioned example because im new to jasper java-awt - Java Beginners java-awt how to include picture stored on my machine to a java frame? when i tried to include the path of the file it is showing error. i have... information, Thanks Tree and a desktoppane - Swing AWT Tree and a desktoppane Hi , Iam kind of new to Java. This is the problem scenario where iam stuck. I have a Frame. In that i have a menubar on top, a tree (separate java class outside using JTree and the corresponding slider - Swing AWT :// Thanks... Example"); Container content = frame.getContentPane(); JSlider slider scrolling a drawing..... - Swing AWT information. DrawingCircle - Swing AWT : Thanks java - Swing AWT java How can my java program run a non-java application. Will it be possible to invoke a gui application using java Timer - Swing AWT :// Thanks java - Swing AWT java Write Snake Game using Swings Advertisements If you enjoyed this post then why not add us on Google+? Add us to your Circles
http://www.roseindia.net/tutorialhelp/comment/44978
CC-MAIN-2015-40
refinedweb
1,393
65.52
CodeCon has released the schedule for the conference. Wheat will be demo'd Sunday: Jim, Kragen and I have been working furiously to get the system ready in time for the demo. Nothing like a deadline! There is a new Wheat API for the templating system, some reg-ex support, new work on Farm (the development environment), and improvements in file system layout.... read more It has been way too long since an update about Wheat. For now, I just want to alert you all to two project events: 1) Wheat has been accepted as one of the projects to be demo'd at CodeCon 2005. This is a three day open source project conference held in San Francisco. The web site is: However, they don't seem to have much info up there yet... 2) The wonderful people at CommerceNet's zLab have taken an interest in Wheat and decided to "learn by doing". So, for a whole week in December, their Kragen Sitaker and I pair programmed on and in Wheat. We learned lots, coded lots, and identified what needs more work. Summer has a bit slow, but progress has been made nonetheless. Several areas of infrastructure got worked on: * The server threading architecture has been extensively rewritten as a pre-launched-thread server with a pool of worker threads. It is now thread-safe and signal-safe. * Persistence was improved in that now only modified object mounts are persisted. XMLMedia supports checkpointed storage.... read more The simple blog application for Wheat is now written and running entirely in the native Wheat language. In just a month we have come from being able to execute a simple expression to running a whole application (albeit a simple one). The Wheat code for the blog application can be viewed on-line. See blog.ws: If you check out the latest source from the CVS repository, build and run it, you can then point your browser at the running Wheat server and see the blog application running. It is known to build and run under various unix flavors, Mac OS X, and Windows with cygwin.... read more Wheat executed its first compiled method yesterday! The method was: doit(): { return 3 + 4; } The result was 7. While this doesn't seem like much, it actually tests a surprising amount of the language machinery: Wheat now has a working lexer, parser, compiler, method builder (assembler) and virtual machine. Two months ago, we were working on the Blog application. By the beginning of March we had a skeletal Blog with an RSS feed running. However, this was coded entirely in the C++ syntax for Wheat. We decided that not having the Wheat native text syntax running was an impediment to people understanding and trying out the project. The language and compiler were put ahead of completing the Blog.... read more ...And we can see our first application: A Blog. We now have enough machinery to render and serve real web pages with content drawn from Wheat objects. We hope to have a full running Blog application within a month. Some amusing code stats: Over 20,000 lines of code in 97 files (not counting the included libraries expat or ptypes). About 25% of that is unit tests. There are 72 public classes in header files and another 53 in implementation files.... read more SourceForge seems to have cured the problems with the anonymous CVS access. The anonymous CVS server now has up-to-date copies of the Wheat source. A good build that passes all its unit tests is at the tag markl-gravity-20040102a. If you're feeling adventurous, try the head revision. On Linux or MacOSX you should be able to do this in a shell: mkdir someplace-for-wheat-development cd someplace-for-wheat-development cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/wheat login # just hit return when asked for a password cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/wheat \ co -r markl-gravity-20040102a r1 cd r1 make make # there is a bug, you'll have to make twice the very first time! ./bin/wheat-r1 -t root/config.xml # runs 69 unit tests, all should pass ./bin/wheat-r1 root/config-web-text.xml # runs the Wheat server # Point your browser at... read more It has been a while since the last Wheat update. Quite a bit has happened: Jim Kingdon and I have been working on the rendering module: This lets objects control their mapping to the web server URL space and control their own rendering via XML templates. The code is close, and is capable of rendering some very simple blog entries! Other things that got coded in the last month: - XML Media is now working (Wheat objects stored in XML documents) - Debugging support (displaying object information in gdb) - Build under Linux - Many virtual machine refinements (semantics and implementation of inheritance, stacks, message lookup and sending, primitive installation and execution) - An initial object library (very rudimentary)... read more This week saw lots of work on the XML media implementation. The entire storage system, which is normally the host file system, has been abstracted so that the XML document tree can alternately be stored in memory. This makes unit testing of the XML media very easy: Just mount it on memory storage instead of file storage and then do string compares to make sure it is writing correctly. The XML writer is coming along. It currently can write a Wheat object as a single XML document. Next is supporting objects that persist as collections of XML documents (needed for persisting large object trees). I expect to complete this by the end of this week. When done, Wheat will be persisting all its data.... read more The web site ( ) has been overhauled. The site now features a full set of contact URLs so you should be able to find everything. I've also put the latest news item on the page. A major addition are my notes for my talk at Hackers. Now there are some words to go with those images... Lastly, I realize that the XHTML 1.0 and CSS 1 compliant layout doesn't work perfectly in all browsers (which seem notoriously non-compliant... especially IE...). I think it should all be readable in most browsers. If not, please drop me a line.... read more This past weekend I showed Wheat R1 at the Hackers conference. It got quite a bit of enthusiastic response, and won second place as Best Work-in-Progress. My slides are on the web site (click Home Page) but the commentary is still missing... Give me a few days to catch up on my sleep! - Mark
http://sourceforge.net/p/wheat/news/
CC-MAIN-2015-35
refinedweb
1,118
72.97
In the last post we saw how to use LINQ GroupBy() for relatively simple grouping. GroupBy() is capable of a couple of more advanced features which are worth looking at. Custom equality tests First, we saw before that the key used by GroupBy() to do the grouping could be calculated from the data fields in the objects in the sequence being grouped, rather than being just one of the bare data fields itself. For simple cases, it’s easiest to just place this calculation directly in the call to GroupBy() as we did earlier. However, sometimes the grouping key gets a bit more complex. LINQ allows us to define our own equality test for use in determining how keys are compared. As an example, suppose we wanted to group the terms of office of Canada’s prime ministers according to how many years each of these terms spanned. That is, we’d like all terms less than a year in one group, then those between 1 and 2 years and so on. Since a Terms object contains only the start and end dates of the term as DateTime objects, we need to calculate the difference to get a TimeSpan object and then declare that two such objects that lie within the same span of years are ‘equal’. In order to create an equality test, we need to write a custom class that implements the IEqualityComparer<T> interface, where T is the data type being compared. This interface has two methods, Equals(T, T) and GetHashCode(T). The Equals() method returns a bool which is true if its two arguments are defined as equal and false if not. The GetHashCode() method is needed since grouping is done by storing sequence elements in a hash table, so we need to make sure that the hash codes for two elements that are defined as ‘equal’ are the same. For our example here, we can use the following class: class TermEqualityComparer : IEqualityComparer<TimeSpan> { public bool Equals(TimeSpan x, TimeSpan y) { return x.Days / 365 == y.Days / 365; } public int GetHashCode(TimeSpan obj) { return (obj.Days / 365).GetHashCode(); } } Our equality test divides the number of days in each TimeSpan object by 365 (OK, we’re ignoring leap years) using integer division. If the two TimeSpans are equal in this measure then they represent terms that lie in the same one-year span. For the hash code, we just use the same division and return the built-in hash code for the quotient. This ensures that all TimeSpans within the same year get the same hash code. With this class, we can now write a GroupBy() call that does what we want: TermEqualityComparer termEqualityComparer = new TermEqualityComparer(); var pmList37 = primeMinisters .Join(terms, pm => pm.id, term => term.id, (pm, term) => new { first = pm.firstName, last = pm.lastName, start = term.start, end = term.end }) .OrderBy(pmTerm => pmTerm.start) .GroupBy(pmTerm => pmTerm.end - pmTerm.start, termEqualityComparer) .OrderBy(pmGroup => pmGroup.Key); foreach (var pmGroup in pmList37) { int years = pmGroup.Key.Days / 365; Console.WriteLine("{0} to {1} years:", years, years + 1); foreach (var pmTerm in pmGroup) { Console.WriteLine(" {0} {1}: {2:dd MMM yyyy} to {3:dd MMM yyyy}", pmTerm.first, pmTerm.last, pmTerm.start, pmTerm.end); } } We declare a TermEqualityComparer object first. The LINQ code is much the same as in our earlier example in the last post, up to the GroupBy() call. This time it has two arguments. The first is the quantity to be used as the key, as usual, which in this case is the difference between the start and end of the term. The second argument is the equality testing object, so GroupBy() will pass the first argument to the Equals() method in the equality tester for each sequence element and use that test to sort the elements into groups. You might wonder about the last OrderBy() call, which sorts the groups based on their keys. The actual TimeSpans for each element within a group may all be different, but according to our equality test, all TimeSpans within a single group are ‘equal’, so it doesn’t matter which one is used in the OrderBy(). Where the actual values of the keys does matter though is when we try to use their value in some other calculation. In our example, we want to print out the groups of terms, with each labelled by its key. However, if there is more than one element in a group, the TimeSpan for each element will probably be different, and since only one key is saved for each group, we can’t be sure which element in the group has that key (in fact, it seems to be the first element assigned to the group that has its key used for the group). Thus it’s usually best to use keys only in the same way that the original GroupBy() call did. In our example, we divide pmGroup.Key.Days by 365 to get the year span represented by that key, since we know that value does apply to all elements within that group. The result of the code is: 0 to 1 years: Charles Tupper: 01 May 1896 to 08 Jul 1896 Arthur Meighen: 29 Jun 1926 to 25 Sep 1926 Joe Clark: 04 Jun 1979 to 02 Mar 1980 John Turner: 30 Jun 1984 to 16 Sep 1984 Kim Campbell: 25 Jun 1993 to 03 Nov 1993 1 to 2 years: John Abbott: 16 Jun 1891 to 24 Nov 1892 Mackenzie Bowell: 21 Dec 1894 to 27 Apr 1896 Arthur Meighen: 10 Jul 1920 to 29 Dec 1921 2 to 3 years: John Thompson: 05 Dec 1892 to 12 Dec 1894 Paul Martin: 12 Dec 2003 to 05 Feb 2006 3 to 4 years: William Mackenzie King: 25 Sep 1926 to 07 Aug 1930 4 to 5 years: Alexander Mackenzie: 07 Nov 1873 to 08 Oct 1878 William Mackenzie King: 29 Dec 1921 to 28 Jun 1926 Pierre Trudeau: 03 Mar 1980 to 29 Jun 1984 5 to 6 years: Richard Bennett: 07 Aug 1930 to 23 Oct 1935 John Diefenbaker: 21 Jun 1957 to 22 Apr 1963 Lester Pearson: 22 Apr 1963 to 20 Apr 1968 6 to 7 years: John Macdonald: 01 Jul 1867 to 05 Nov 1873 Stephen Harper: 06 Feb 2006 to 25 May 2012 8 to 9 years: Robert Borden: 10 Oct 1911 to 10 Jul 1920 Louis St. Laurent: 15 Nov 1948 to 21 Jun 1957 Brian Mulroney: 17 Sep 1984 to 24 Jun 1993 10 to 11 years: Jean Chrétien: 04 Nov 1993 to 11 Dec 2003 11 to 12 years: Pierre Trudeau: 20 Apr 1968 to 03 Jun 1979 12 to 13 years: John Macdonald: 17 Oct 1878 to 06 Jun 1891 13 to 14 years: William Mackenzie King: 23 Oct 1935 to 15 Nov 1948 15 to 16 years: Wilfrid Laurier: 11 Jul 1896 to 06 Oct 1911 Custom return types A GroupBy() call also allows you to customize which data fields should be returned, in much the same way as Join() did. For example, if we want to group the terms into the decades in which they started (as we did in the last post), we can have GroupBy() return only the last name and start date for each term. The code is: var pmList38 = primeMinisters .Join(terms, pm => pm.id, term => term.id, (pm, term) => new { first = pm.firstName, last = pm.lastName, start = term.start, end = term.end }) .OrderBy(pmTerm => pmTerm.start) .GroupBy(pmTerm => pmTerm.start.Year / 10, pmTerm => new { last = pmTerm.last, start = pmTerm.start }) .OrderBy(pmGroup => pmGroup.Key); foreach (var pmGroup in pmList38) { Console.WriteLine("{0}s:", (pmGroup.Key * 10)); foreach (var pmTerm in pmGroup) { Console.WriteLine(" {0}: {1:dd MMM yyyy}", pmTerm.last, pmTerm.start); } } In this case, the second argument of GroupBy() is a function that takes a single parameter (pmTerm here) which is used to construct the returned object to be placed in the group. Here, each object in a group will be an anonymous type with two fields: last and start. We use these two fields in the printout, and we get: 1860s: Macdonald: 01 Jul 1867 1870s: Mackenzie: 07 Nov 1873 Macdonald: 17 Oct 1878 1890s: Abbott: 16 Jun 1891 Thompson: 05 Dec 1892 Bowell: 21 Dec 1894 Tupper: 01 May 1896 Laurier: 11 Jul 1896 1910s: Borden: 10 Oct 1911 1920s: Meighen: 10 Jul 1920 Mackenzie King: 29 Dec 1921 Meighen: 29 Jun 1926 Mackenzie King: 25 Sep 1926 1930s: Bennett: 07 Aug 1930 Mackenzie King: 23 Oct 1935 1940s: St. Laurent: 15 Nov 1948 1950s: Diefenbaker: 21 Jun 1957 1960s: Pearson: 22 Apr 1963 Trudeau: 20 Apr 1968 1970s: Clark: 04 Jun 1979 1980s: Trudeau: 03 Mar 1980 Turner: 30 Jun 1984 Mulroney: 17 Sep 1984 1990s: Campbell: 25 Jun 1993 Chrétien: 04 Nov 1993 2000s: Martin: 12 Dec 2003 Harper: 06 Feb 2006 Result selection Finally, we can ask GroupBy() to return a single object for each group, rather than the entire group. For example, suppose we want a count of the number of terms that started in each decade, together with the earliest term in each decade. We can do that as follows: var pmList39 = terms .OrderBy(term => term.start) .GroupBy(term => term.start.Year / 10, (year, termGroup) => new { decade = year * 10, number = termGroup.Count(), earliest = termGroup.Min(term => term.start) }); Console.WriteLine("*** pmList39"); foreach (var term in pmList39) { Console.WriteLine("{0}s:\n {1} terms\n Earliest: {2: dd MMM yyyy}", term.decade, term.number, term.earliest); } In this case, the second argument in GroupBy() is a function which takes two parameters. The first parameter is the key for a given group, and the second parameter is the group itself. We can use this information to construct a summary object for that group. In this example, we create an anonymous object with 3 fields: the decade (calculated from the key ‘year’), the number of terms in that decade (by applying the Count() method to the group), and the earliest term (by applying the Min() method and passing it the start date). This version of GroupBy() produces a list of single objects rather than a list of groups, so only a single loop is needed to iterate through it. The results are: 1860s: 1 terms Earliest: 01 Jul 1867 1870s: 2 terms Earliest: 07 Nov 1873 1890s: 5 terms Earliest: 16 Jun 1891 1910s: 1 terms Earliest: 10 Oct 1911 1920s: 4 terms Earliest: 10 Jul 1920 1930s: 2 terms Earliest: 07 Aug 1930 1940s: 1 terms Earliest: 15 Nov 1948 1950s: 1 terms Earliest: 21 Jun 1957 1960s: 2 terms Earliest: 22 Apr 1963 1970s: 1 terms Earliest: 04 Jun 1979 1980s: 3 terms Earliest: 03 Mar 1980 1990s: 2 terms Earliest: 25 Jun 1993 2000s: 2 terms Earliest: 12 Dec 2003 Note the differences between these calls to GroupBy(). The first argument is always the key to be used in the grouping. If the second argument is an IEqualityComparer object, it is used to compare keys. If this argument is a function with a single parameter, it is used to select fields from each object placed in the group. Finally, if the argument is a function with two parameters, it is used to produce a summary object for each group. These 3 features can be used in any combination (which is why there are 8 prototypes for GroupBy(). Whichever features you want to include, remember that they are placed in the order source.GroupBy(keySelector, elementSelector, resultSelector, equalityComparer).
https://programming-pages.com/tag/equality-testing/
CC-MAIN-2019-43
refinedweb
1,915
65.76
We often get asked about nagios server sizing, so we did some benchmarking. Here are the results. To get proper results all tests were made on the same system: All tests were made with a loaded livestatus module to fetch actual numbers of executed checks. The test setup was based on OMD so it contains some best practice tuning already like using a ram disk, large installation tweaks and disabled environment macros. We created different sites for each test environment: In order to meassure the overhead of different cores, we used several test plugins. Perl plugins were tested with and without embedded perl for cores which support EPN. A simple c plugin: #include <stdio.h> int main(void) { printf("simple c plugin\n"); return 0; } A simple shell plugin: #!/bin/bash echo "simple bash plugin" exit 0 A simple perl plugin: #!/usr/bin/perl print "simple perl plugin\n"; exit 0; A huge perl plugin: #!/usr/bin/perl use warnings; use strict; use Moose; use Catalyst; print "not so simple perl epn plugin\n"; exit 0; For each benchmark the testscript started with a small number of hosts/service (1 minute interval) and increased that number as long as the latency was below 5seconds and the cpu isn’t working at maximum. Graphs werde created including the calculated average number of checks which should run per second (red line) and the actual number of checks per second (blue line). Running the benchmark with a Nagios 3 Core tops out at around 100 Checks per second. Using Mod-Gearman increases the upper limit to almost 400 checks per second. Putting all results into a single graph. There is nearly no difference between small C, Perl or Shell plugins, but when plugins get heavier using embedded perl helps a lot. It’s faster to run perl plugins with embedded perl than running native compiled c plugins. The huge perl check is mainly limited by the underlying disk which is not very fast in our test lab but it shows the power of Embedded Perl. This time we used external worker to just measure how fast the Nagios Core can process result. And as we can see, Nagios 4 processes about 4x times more than Nagios 3. The checks are still active checks but executed on remote workers. The load on your monitoring box is mainly related to what kind of plugin you run. Mod-Gearman helps a lot to reduce some overhead and spread the load over multiple hosts when one is not enough. Mod-Gearman cannot solve all performance problems, for example bad configuration or when using other plugins like ndo, but when doing it right, you can check up to 2000 Services/Hosts per second which is equivalent to 600.000 Services at a 5 Minute interval with a single Nagios core.
https://labs.consol.de/de/mod-gearman/nagios/omd/2012/10/23/monitoring-core-benchmarks.html
CC-MAIN-2017-43
refinedweb
472
61.56
You do this inorder to ensure that your component gets disposed along with the contained Form (logical parent). All Form derived classes come with an IContainer field into which many of the .Net components like ImageList and Timer add themselves to. The Form will dispose the contents of this IContainer from within its Dispose. Scenario 1 In order for your Component to get added to this IContainer list, all you have to do is provide a constructor that takes IContainer as the one and only argument. The design-time will discover this constructor automatically and use it to initialize your component. You should then add yourself to the IContainer in the constructor implementation. Note that for this to work your Component should not have a custom TypeConverter that can convert your type to an InstanceDescriptor. Example: public class MyComponent : Component { public MyComponent() { } public MyComponent(IContainer container) { container.Add(this); } } Scenario 2 Your components might have more constructors besides the default constructor and you might have a custom TypeConverter that provides an InstanceDescriptor to let your designer use a non-default constructor for initializing your component in code. In this case, the above approach will not work because you do not have an IContainer-argument only constructor. You now have to recreate what the design-time did for you. You have to provide a custom IDesignerSerializationProvider to do so. The attached ContainerInsertingSerializationProvider class can be used to get the above effect. Share with
https://www.syncfusion.com/faq/windowsforms/serialization/how-to-make-my-component-add-itself-to-the-contained-forms-icontainer-list
CC-MAIN-2021-39
refinedweb
242
54.42
Jeff Garzik wrote:> > People from time to time point out a wart in ethernet initialization:> They sure do. You were away at the time, but I had a 94 file,140k patch late last year which fixed all this. It'sat the design doc is at a quick look, I think the only substantive differencehere is that my `prepare_etherdev()' function allocatesand reserves the device's name (eth0), but prevents itfrom being available in netdevice namespace lookups. Thiswas done because lots of drivers wanted to do: init_etherdev(); (Replaced with prepare_etherdev()) printk("%s: something", dev->name);The changes to dev.c and net_init.c were fairly subtleand took some thinking about - we should revisit themif you want to go ahead with this.The patch all worked OK, was back-compatible with unaltereddrivers, and indeed altered all the drivers. But it kind ofgot lost. Too big, too late and dev_probe_lock() was there.Now, Arjan says that this race is causing oopses. Thissurprises me, because current kernels have the the dev_probe_lock()hack which I put in. This fixes the problem for PCI and Cardbusdrivers. The ISA drivers generally use the dev->init() techniquewhich is not racy. There isn't a lot left over. Arjan? Which driver?The other reason I'm surprised that it's causing oopses: mostr becausethe open() routine hasn't been called, but it should hangin there. A subsequent close() of the interface *will*call dev->close, and I guess the driver is likely to getupset if its close() routine is called without a correspondingopen().Yes, we can fix this if we want, and kill off dev_probe_lock().It'll only take a few days. Do we want? If not, we canextend the dev_probe_lock() thing to cover probes forother busses. USB, I guess.--To unsubscribe from this list: send the line "unsubscribe linux-kernel" inthe body of a message to majordomo@vger.kernel.orgMore majordomo info at read the FAQ at
http://lkml.org/lkml/2001/3/7/212
CC-MAIN-2015-22
refinedweb
319
75.5
Style and Format of the Quiz Will this be Synchronous or Asynchronous and how much time will I have? The quiz will of a take-home style, just like last time. It will be released on Tuesday 10/20, 4:45 PM Eastern Time and be due at midnight, Tuesday 10/20, 11:59 PM Eastern Time. International students who opted into the 4:45 AM Eastern Time quizzing will begin theirs via the INTL Gradescope account at 08:45 GMT 10/21/2020 and submit by 4:00 PM GMT. On this quiz we will have certain parts due by different times. The memory diagram questions will be due about an hour or so after the quiz opens up, while you will have the rest of the night to finish the code writing. Am I allowed to use notes, VS Code, and/or the Internet? Yes to notes, anything on the course site, and VS Code… you are encouraged to try things out in the REPL! No to using the Internet. While you may think there is no way for us to check whether the Internet was used, it is obvious to tell what methods to program coding were taught in class versus something that was pulled from the Internet. Using obscure methods from the Internet either way will probably get points taken off anyway for not following the conventions we use in class. And NO to collaboration with other students. As you saw, it is very easy to tell when someone has just changed variable names or move small things around. Will I need to hand-write anything? Memory diagrams will be on this quiz, meaning you will have to have some sort of app to take pictures of your diagram to upload to gradescope. What new topics should I know for the quiz? - Always good to refresh quick on what we previously covered for last quiz (see FAQ for quizzes 0 and 1!) - Memory Diagrams - For lists - For objects - For dictionaries - Dictionaries - Classes and Objects - Note: There won’t be any code writing relating to classes and objects. Just know the concepts well enough to interpret them on the memory diagram questions! What is the breakdown of question styles? There will be some questions that are similar to the previous quizzes in that they will ask you to implement some sort of function following the requirements given. In addition to this though, a big focus will be on creating memory diagrams! The bright side of these is that you will not have to worry about writing code, rather you will be given a code snippet and will have to interpret what’s happening, which the diagram should actually help with! There also may be questions about your memory diagram, such as “How many objects are on the heap?” or “What is the value of x in the main frame?”. This is just a matter of interpreting what you drew! Memory diagrams Memory diagrams can be a blessing in the sky if you are trying to interpret programs or even trying to test your own! They are an effective way to essentially keep track of what variable values are as the program runs. With many function calls, it can be complicated to track things like lists and objects in your head. The setup will always be the same. You will have three sections: - Call Stack - Heap - Output The call stack is where the globals frame will go, along with frames representing any function call that gets made. The heap is where functions, lists, objects, and dictionaries would go. Any variable that is ‘primitive’ or simple like strings, integers, floats, or booleans will not need to go on the heap, and can instead be written in the small box within the frame. Output is where printed output gets logged. Only use this section if you see print statements encountered. Here is how drawing it will start off like (every time!): Next, we will put functions declared in the program on the heap. Let’s take this: Main is declared from lines 3-8 and foo is declared from lines 11-14. Let’s put this in our global frame: Then, whenever any function call is made, we add that to our call stack. The number of times a function is called in the running of the program is the amount of frames that should be drawn on the stack. This does NOT mean you count every call that exists in the code, you have to actually check if those calls are reached when the program runs. main() is called on line 18, so we will make a frame for this. One thing to note is that every frame (except for globals) must have a return address and return value declared. Do NOT forget to include these!! Easy points can be given by having the return address and values correct on the frame. Since main was called on line 18, the return address will be marked as 18. As main’s return type is None, we will use a 0 with a slash marked through (which you should do any time a function’s return type is None). Now time to actually run through the main function! In line 4, we have printed output, and in line 5, an int, x, is declared and initialized. We will put the output under the ‘Output’ column and put x in main’s frame. The variable x can now be accessed within the main frame. For the string variable, y, that is declared on line 6, we have a function call to foo whose return value is assigned to it, so we have to create a new frame on the stack to account for this! On this new ‘foo’ frame, we can define the return address as 6 since that is where the call to foo is made. We will leave the return value as blank since we know it will return a string by the end of the call. We can also go ahead and define any parameters within the frame, as they are all local to the function call (you will learn more about this when we discuss scope!) This applies to all functions you may encounter - even though the variables are not declared within the actual block, parameter values are still important to keep track of. Since the argument ‘x’ was passed into this function, we will write in its value 1 as the parameter value within foo, also named ‘x’. Keep in mind, the x in foo is TOTALLY separate from the one in main. But you might wonder, we passed in the x variable from main as the argument, and therefore the x in foo and x in main have to be related. However, think of it this way, I could have defined the parameter within foo as y. The values of x and y will be the same at the start, but they have no relation at all because whatever changes happen to the parameter in foo will NOT reflect in the variable in main, since we are only dealing with an integer. As you see in examples with lists, dicts, and objects, this does NOT hold true for those types because those are reference types. When they are passed into functions, a copy of them is not made, but instead, an arrow is drawn to it, meaning the parameter and variable from main would actually be related! Any changes that happen within these will affect all variables that reference it. In our example though, when the integer gets updated, this change is only made in foo. Now we have a list to declare on line 13! Now we will create a list on the heap to represent this, and we will draw an arrow from ‘values’ to reflect that it references that list. The next line is a return statement that returns the value at index ‘x’ from the values list. We know from the diagram that x is 2, and following the values list reference, we know that the value at this index is “it”. This string will now be our return value! Now we can get out of this frame since we have a return value. This will get assigned to the variable y in main. From there, the value will be printed and so will “End!” to mark the end of the program. Here is what our complete diagram looks like now: This is a very basic example for review of how a memory diagram is made, but please refer to class notes and practice problems under Resources for more difficult practice! Important Note regarding For… in loops in Memory Diagrams Something extremely important to understand about for in loops is that when we define the counter variable within the for statement, that also gets defined on the memory diagram even though no type is explictly declared. in the diagram.. Dictionaries (Dicts) Think back to when we talked about lists. It was a sequence of values of the same type. How do we access elements within a list? Easy! You just use bracket notation and fill it with the appropriate index. Remember, these indices start from 0 and count up from there. However, these indices are not something we see when we, for example, print the list. We just know that the value in the second position for example is at index 1, and this holds true for values in a list that whatever is in the nth position is at index n - 1. We can see the limitations however of using indices to refer to values of a sequence: The index (an integer) does not have any actual significance or relation to the value it represents other than where that value is on the list. It is not practical to remember at which position something on a list exists. If the scores for a class were listed, and we wanted Anna’s grade, we would have to know which position Anna was (in which case we would have to access another list for class names, which we do not even know if the order corresponds with the grades). grades: list[float] = [ 62.5, 97.8, 83.4 ] names: list[str] = [ ‘Kush’, ‘Anna’, ‘Marc’ ] # Here we assume the order corresponds index: int = -1 for i in range(len(names)): if names[i] == ‘Anna’: index = i print(“Anna’s grade is “ + str(grades[index])) Dictionaries fix both of these problems!!! With the power of ‘keys’, values in a sequence actually have a meaning visibly associated with it that can be utilized within brackets: grades: Dict[str, float] = { “Kush”: 62.5, “Anna”: 97.8, “Marc”: 83.4 } print(“Anna’s grade is “ + str(grades[‘Anna’])) Notice how easy it is to just refer to the grades dictionary and look for Anna’s grade by using “Anna” as the key! This is the power of dictionaries! Some trivial things to remember include how to import them and how to declare its type. import Dict from typing grades: Dict[str, float] # First type represents the key type, second type represents the value type One other really cool thing about dictionaries is that adding values to them is very simple! No need to use special functions like append, all we do is just assign a value to a key that doesn’t exist, and Python is chill with it! If you want to remove a value from a dictionary, use the .pop( If you want to check if a key is already in the dictionary, instead of having to use a for loop to find and compare, there is a very simple syntax to check! Please do not waste time and run a for loop to find if a key exists!! Use if <key> in <dict> like we did above! For loops will be useful, however, for finding values. In general, if a function takes in a dictionary, your first thought should be to make a for loop (just like we did with lists) to iterate through the key-value pairs. The for … in syntax is very similar for dictionaries, but instead of the item representing an index or an actual value, the item will represent the key! Classes and Objects One limitation about lists and dicts are that the data within have to be all of the same type, which is whatever is specified upon declaration. What if we wanted to hold data of different types? This is where classes can be very useful! You creating a class essentially is equivalent to you creating a custom data type! The class can hold whatever attributes you want. To define a class with its attributes: class [className]: [atrr_1_name]: [attr_1_type] = [optional default_value] [attr_2_name]: [attr_2_type] = [optional default_value] [attr_3_name]: [attr_3_type] = [optional default_value] An example would be if I wanted to hold data for a student. A student has a name, GPA, and could have a value to represent whether or not they are graduating soon. I can define a Student class to hold these attributes: Notice how I can give a Student a default value for is_graduating if I wanted to! Now that I have a class declared, I can use it to declare many objects of that class type, each to represent a student! You are not required to know this now, but we can even make lists of these objects! Exciting!!! You will learn more in future lectures! The next step is to actually assign values to the attributes of the objects we have created. The way to assign and access attribute values is by using dot notation: A key thing to note is that these objects are reference types. What does that mean? On an memory diagram, this object would go on the heap as we learned earlier. If an object were declared and assigned to a variable, an arrow from that variable name to the object name would be created, so that name references that object. Therefore, if I had something like this: The name student_4 points to, or refers to, the same object as student_1. Thus, any changes that happen to student_4 will also reflect in student_1: Objects being a reference type also implies that if one were to directly pass in an object as an argument to a function, the parameter name in the memory would point to that same object being passed in (a copy is not made). Again, for the quiz you will just have to be able to recognize the syntax and track the object and its attributes in a memory diagram, so do not spend too much time memorizing the syntax. Just understand how to recognize when an attribute of an object is being accessed or updated, and how overall references work when multiple names are pointing to the same object (the concept is the same in lists and dicts). How do I best prepare for the quiz? - For the memory diagrams, definitely work on the practice problems we assign, but also look back at problems done in lecture to ensure you understand the concepts. - Focus on these the most since we have not done quizzes or exercises involving memory diagrams yet so you want to get comfortable knowing how to draw them! - Really understand how to iterate through dictionaries and how to access values within them. Good practice is available under resources! Also review the Shakespeare exercise and project for this! - For classes and objects, as we’ve just talked about them and haven’t had much in terms of practice with those, try to focus on those the most. - We are 5 weeks away from the end of the semester! We are almost there! Pat yourself on the back for making it this far, you all should be really proud of yourselves! It is not easy to take on a skill as novel as programming! You all challenged yourselves by sticking through this course, and no grade can tell you otherwise. That being said, stress less about the grade you will potentially make on this quiz, and focus more on reviewing concepts that you feel you may be struggling with. - TA’s are here to help in office hours, please feel free to go through practice problems with them, they will be glad to walk you through understanding these concepts!
https://20f.comp110.com/students/resources/quiz2-faq.html
CC-MAIN-2021-10
refinedweb
2,730
68.7
Patch for 5.18 Search Criteria Package Details: nvidia-340xx-dkms 340.108-29 Package Actions Dependencies (7) - dkms -) - nvidia-340xx-utils - linux (linux-surfacepro3-git, linux-aarch64-rock64-bin, linux-ec2, linux-galliumos, linux-zest-git, linux-bootsplash, linux-sumavision-q5, linux-tqc-a01, linux-t2-wifi, linux-kernel-ohio, linux-rk3328, linux-phicomm-n1) ) (make) - nvidia-340xx-utils ) (optional) – Build the module for Arch kernel Required by (6) - bumblebee-forceunload (requires nvidia-340xx) (optional) - bumblebee-git (requires nvidia-340xx) (optional) - bumblebee-picasso-git (requires nvidia-340xx) (optional) - conky-lua-nv (requires nvidia-340xx) (optional) - nvfancontrol (requires nvidia-340xx) (optional) - nvfancontrol-git (requires nvidia-340xx) (optional) Sources (11) - - 20-nvidia.conf - Latest Comments Viterzgir commented on 2022-05-14 17:39 (UTC) bigjuck commented on 2022-05-13 06:53 (UTC) @holyArch thanks a lto, works for me witk 5.15.38-1-lts holyArch commented on 2022-05-11 12:18 (UTC) (edited on 2022-05-11 12:46 (UTC) by holyArch) Build fails when upgrading to 5.17.5-arch1-2. sudo env IGNORE_CC_MISMATCH=1 dkms install -m nvidia -v 340.108 -k 5.17.5-arch1-2 did the trick. auriculaire commented on 2022-05-11 09:05 (UTC) You have to reinstall the module nvidia-340xx-dkms 340.108-29 after updating the linux kernel 5.17.5-arch1-2. hackins commented on 2022-04-17 13:59 (UTC) (edited on 2022-04-17 14:19 (UTC) by hackins) I installed Linux 5.17.3 and the latest updates now the system has flashing underscore on left upper corner, the desktop won't boot up, anyone can suggest anything? As FiestaLake suggested IgnoreABI option solved the issue. Thanks! NicolasV commented on 2022-04-02 19:25 (UTC) (edited on 2022-04-02 19:26 (UTC) by NicolasV) I recommand to install core/linux-lts and nvidia-340xx-lts as this package seems not compatible with mainline kernel. Here's the output at the end of installation. ERROR: Kernel configuration is invalid. include/generated/autoconf.h or include/config/auto.conf are missing. Run 'make oldconfig && make prepare' on kernel src to fix it. fvsc commented on 2022-04-01 18:36 (UTC) I used the Viterzgir patch for kernel 17 and build succeeded and all is up and running fvsc commented on 2022-04-01 15:09 (UTC) @Imh69 I overlooked the "download Snapshot" possibility. Thanks for reminding me. lmh69 commented on 2022-04-01 13:41 (UTC) (edited on 2022-04-01 13:49 (UTC) by lmh69) @hias Please try the @Viterzgir one that's working 2 and it's more complete. @fvsc Download the snapshot package, extract it, patch the sources in that directory with the @Viterzgir patch ( ), you should modify the PKGBUILD and add the patch and the b2sum of it, then just compile/make the package and installed it with: makepkg -si You should be running the 5.17 kernel that you want to use with this nvidia driver when you execute the makepkg command. (You can make a function() in bashrc or an .sh file to semi-automatic execute it when you upgrade your kernel version 5.17.* as long as this aur package isn't updated) Regards. fvsc commented on 2022-04-01 12:04 (UTC) Can someone tell me where I can download the kernel patches? Thanks in advance. hias commented on 2022-03-31 21:41 (UTC) (edited on 2022-03-31 21:43 (UTC) by hias) I tried lmh69´s Patch and X starts again. tnx. PKGBUILD I used for linux: # pkgname=(nvidia-340xx nvidia-340xx-dkms); [ -n "$NVIDIA_340XX_DKMS_ONLY" ] && pkgname=(nvidia-340xx-dkms) pkgver=340.108 pkgrel=29 pkgdesc="NVIDIA drivers for linux, 340xx legacy branch" arch=('x86_64') url=" makedepends=("nvidia-340xx-utils=${pkgver}" 'linux>=5.5' 'linux' '8b4a7de6d13d9fa5c5569117a371ba615a967b7a1eb40db81e28433a9775a60a4d665a2e141209c8a62f81ea0c1f9156260686188a2e1de11537d923f2fa97f7') _pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32" # default is 'linux' substitute custom name here _kernelname=linux () { pkgdesc="NVIDIA drivers for linux, 340xx legacy branch" depends=('linux>=5.3.6' "nvidia-340xx-utils=$pkgver" 'libgl') install=nvidia-340xx.conf" install -Dm644 "$srcdir/20-nvidia.conf" "$pkgdir/usr/share/nvidia-340xx/20-nvidia.conf" } package_nvidia-340xx-dkms() { pkgdesc="NVIDIA driver sources for linux, 340xx legacy branch" depends=('dkms' "nvidia-340xx-utils=$pkgver" 'libgl') optdepends=('linux-headers: Build the module for Arch}" cat "${pkgdir}"/usr/src/nvidia-${pkgver}/uvm/dkms.conf.fragment >> "${pkgdir}"/usr/src/nvidia-${pkgver}/dkms.conf: c0mmand0x72 commented on 2022-03-30 17:37 (UTC) thx again @Viterzgir .Im too had no problems and Mate is running fine again calvinh commented on 2022-03-30 13:36 (UTC) Can confirm @Viterzgir's patch works fine. Thanks. Viterzgir commented on 2022-03-30 12:17 (UTC) Patch for kernel 5.17 lmh69 commented on 2022-03-30 06:05 (UTC) (edited on 2022-04-01 13:18 (UTC) by lmh69) i'm using since yesterday the following patch for kernel 5.17 (Tentative fix for NVIDIA 470.94 driver for Linux 5.17-rc1): That I adapted to nvidia-340xx and linux-zen: 0009-kernel-5.17.patch: --- a/kernel/nv-linux.h 2022-03-23 13:48:06.185784509 +0000 +++ b/kernel/nv-linux.h 2022-03-29 13:30:58.733584062 +0000 @@ -12,6 +12,7 @@ #define _NV_LINUX_H_ #include "nv.h" +#include <linux/version.h> #include "conftest.h" #if !defined(NV_VMWARE) @@ -2053,6 +2054,8 @@ #if defined(NV_PDE_DATA_PRESENT) # define NV_PDE_DATA(inode) PDE_DATA(inode) +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)) +# define NV_PDE_DATA(inode) pde_data(inode) #else # define NV_PDE_DATA(inode) PDE(inode)->data #endif PKGBUILD for linux-z-zen pkgname=(nvidia-340xx-zen); pkgver=340.108 pkgrel=28 pkgdesc="NVIDIA drivers for linux-zen, 340xx legacy branch" arch=('x86_64') url=" makedepends=("nvidia-340xx-utils=${pkgver}" 'linux-zen>=5.5' 'linux-zen' '19e41d3d33cf838f30eb085d9d991a55a6dd06fb5435aa3f52740517fc567883eec6446857cde8545be1eca3fac04ddad55bbfd4c9c7449ae37c15c828d9823d') _pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32" # default is 'linux' substitute custom name here _kernelname=linux-zen -zen() { pkgdesc="NVIDIA drivers for linux-zen, 340xx legacy branch" depends=('linux-zen>=5.3.6' "nvidia-340xx-utils=$pkgver" 'libgl') install=nvidia-340xx-zen-zen.conf" install -Dm644 "$srcdir/20-nvidia.conf" "$pkgdir/usr/share/nvidia-340xx-zen/20-nvidia.conf" } # vim:set ts=2 sw=2 et: Regards. PS: I have to say that i didn't try the module compilation without the patch... I don't know if is strictly necessary or not... calvinh commented on 2022-03-29 20:01 (UTC) Need a patch for 5.17 kernel. mauzil commented on 2022-02-18 17:48 (UTC) (edited on 2022-02-20 08:39 (UTC) by mauzil) [Solved with kernel 5.16.10-artix1-1] Hi all. In Artix with latest update I get this error warning: the compiler differs from the one used to build the kernel The kernel was built by: gcc (GCC) 11.2.0 You are using: cc (GCC) 11.2.0 make -f ./scripts/Makefile.build obj=/home/mauro/Scaricati/Artix/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel \ single-build= \ need-builtin=1 need-modorder=1 cc -Wp,-MMD,/home/mauro/Scaricati/Artix/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/.nv.o.d -nostdinc -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -fno-allow-store-data-races -Wframe-larger-than=2048 -fstack-protector-strong -Wimplicit-fallthrough=5 -Wno-main -Wno-unused-but-set-variable -Wno-unused-const-variable -fno-stack-clash-protection -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -Wno-alloc-size-larger-than -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wno-packed-not-aligned -g -gdwarf-4 -fplugin=./scripts/gcc-plugins/structleak_plugin.so -fplugin-arg-structleak_plugin-byref-all -DSTRUCTLEAK_PLUGIN -DNV_MODULE_INSTANCE=0 -DNV_BUILD_MODULE_INSTANCES=0 -UDEBUG -U_DEBUG -DNDEBUG -I/home/mauro/Scaricati/Artix"' -D__KBUILD_MODNAME=kmod_nvidia -c -o /home/mauro/Scaricati/Artix/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/nv.o /home/mauro/Scaricati/Artix/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/nv.c ; ./tools/objtool/objtool orc generate --module --no-fp --retpoline --uaccess /home/mauro/Scaricati/Artix/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/nv.o cc1: error: incompatible gcc/plugin versions cc1: error: failed to initialize plugin ./scripts/gcc-plugins/structleak_plugin.so make[2]: *** [scripts/Makefile.build:287: /home/mauro/Scaricati/Artix/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/nv.o] Errore 1 make[1]: *** [Makefile:1846: /home/mauro/Scaricati/Artix/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel] Errore 2 make[1]: uscita dalla directory «/usr/lib/modules/5.16.8-artix1-2/build» NVIDIA: left KBUILD. nvidia.ko failed to build! make: *** [Makefile:202: nvidia.ko] Errore 1 DAC324 commented on 2022-02-18 08:22 (UTC) (edited on 2022-02-18 09:53 (UTC) by DAC324) @norambna: Manjaro is different from Arch (as you already have encountered). For Manjaro, use this PKGBUILD (you will have to edit the _linuxprefix and _extramodules variables to match the kernel version you are using): # Based on the Arch file> # Maintainer: Philip Müller <philm@manjaro.org> # Maintainer: Roland Singer <roland@manjaro.org> _linuxprefix=linux516 _extramodules=extramodules-5.16-MANJARO pkgname=(nvidia-340xx-dkms) _pkgname=nvidia pkgver=340.108 pkgrel=29 provides=("$_pkgname=$pkgver") groups=("$_linuxprefix-extramodules") pkgdesc="NVIDIA drivers for linux, 340xx legacy branch" arch=('i686' 'x86_64') url=" depends=( "$_linuxprefix" "nvidia-340xx-utils=${pkgver}" ) makedepends=("$_linuxprefix-headers") conflicts=('nvidia-96xx' 'nvidia-183xx' "$_linuxprefix-nvidia" "$_linuxprefix-nvidia-304xx")') _pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32" [[ "$CARCH" = "i686" ]] && _pkg="NVIDIA-Linux-x86-${pkgver}" [[ "$CARCH" = "x86_64" ]] && _pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32" prepare() { # Remove previous builds [ -d "$_pkg" ] && rm -rf "$_pkg" sh "${_pkg}.run" --extract-only cd "${_pkg}" # patches here local src for src in "${source[@]}"; do src="${src%%::*}" src="${src##*/}" [[ $src = 0*.patch ]] || continue echo "Applying patch $src..." patch -Np1 < "../$src" done cd kernel sed -i "s/__VERSION_STRING/${pkgver}/" dkms.conf sed -i 's/__JOBS/`nproc`/' dkms.conf sed -i 's/__DKMS_MODULES//' dkms.conf sed -i '$iBUILT_MODULE_NAME[0]="nvidia"\ DEST_MODULE_LOCATION[0]="/kernel/drivers/video"\ BUILT_MODULE_NAME[1]="nvidia-uvm"\ DEST_MODULE_LOCATION[1]="/kernel/drivers/video"\ BUILT_MODULE_NAME[2]="nvidia-modeset"\ DEST_MODULE_LOCATION[2]="/kernel/drivers/video"\ BUILT_MODULE_NAME[3]="nvidia-drm"\ DEST_MODULE_LOCATION[3]="/kernel/drivers/video"' dkms.conf # Gift for linux-rt guys sed -i 's/NV_EXCLUDE_BUILD_MODULES/IGNORE_PREEMPT_RT_PRESENCE=1 NV_EXCLUDE_BUILD_MODULES/' dkms.conf cd .. cp -a kernel kernel-dkms } build() { _kernver="$(cat /usr/lib/modules/${_extramodules}/version)" cd "${_pkg}"/kernel make SYSSRC=/usr/lib/modules/"${_kernver}/build" module cd uvm make SYSSRC=/usr/lib/modules/"${_kernver}/build" module } package_nvidia-340xx-dkms() { pkgdesc="NVIDIA driver sources for linux, 340xx legacy branch" depends=('dkms' "nvidia-340xx-utils=$pkgver" 'libgl') optdepends=('linux-headers: Build the module for Manjaro: norambna commented on 2022-02-17 13:42 (UTC) (edited on 2022-02-17 15:02 (UTC) by norambna) I'm running a fresh install of Manjaro KDE, Kernel 5.10, Plasma 5.23.5 on a late 2008 Macbook that comes with a GeForce 9400M. When trying to install this package it stops with this error: ==> Starting build()... NVIDIA: calling KBUILD... make[1]: *** /usr/src/linux: No such file or directory. Stop. NVIDIA: left KBUILD. nvidia.ko failed to build! make: *** [Makefile:202: nvidia.ko] Error 1 ==> ERROR: A failure occurred in build(). Aborting... Any hints how to solve this? Thanks in advance. edit: It seems this comment has the solution to this problem! pissbrain commented on 2022-02-16 03:04 (UTC) Can confirm, you do need to reinstall the drivers after the recent gcc update airgap97 commented on 2022-02-15 21:16 (UTC) (edited on 2022-02-16 00:31 (UTC) by airgap97) it does not work after update [gcc] [toolchain] upd : you need to reinstall all the drivers (nvidia-utils, opencl-nvidia), so they pick up the new version of gcc. bigjuck commented on 2022-01-15 11:28 (UTC) Thanks to all keeping the package working with new kernels Viterzgir commented on 2022-01-12 23:23 (UTC) Patch for kernel 5.16 or full archive with PKGBUILD DAC324 commented on 2022-01-04 13:28 (UTC) (edited on 2022-01-04 13:49 (UTC) by DAC324) 0007-kernel-5.15.patch seems to contain DOS instead of Unix line breaks, causing patch to spit out the following: (Stripping trailing CRs from patch; use --binary to disable.) patching file kernel/nv-drm.c patch unexpectedly ends in middle of line For everybody who prefers avoiding such issues, a command like sed -i.bak 's/\r$//' 0007-kernel-5.15.patch or, alternatively, echo "$(tr -d '\r' < 0007-kernel-5.15.patch)" > 0007-kernel-5.15.patch might help. Of course, the checksum in PKGBUILD has to be corrected accordingly. soylent commented on 2022-01-02 08:32 (UTC) Thanks for keeping the package up to date! I appreciate it a lot! nahno commented on 2021-11-26 21:22 (UTC) Thanks for doing the good work and all the comments. Really appreciated! Everything works just fine. pissbrain commented on 2021-11-15 03:10 (UTC) Can confirm, the 5.15 patch also works fine on my end. c0mmand0x72 commented on 2021-11-14 14:19 (UTC) thx for the new patch . everthings works fine :) Viterzgir commented on 2021-11-13 20:10 (UTC) Patch for kernel 5.15 Found here holyArch commented on 2021-11-11 14:45 (UTC) calvinh, one should edit /etc/X11/xorg.conf.d/20-nvidia.conf. calvinh commented on 2021-11-11 13:19 (UTC) Adding the option suggested by @FiestaLake in /usr/share/X11/xorg.conf.d/20-nvidia.conf fixed the issue. poluyan commented on 2021-11-11 08:54 (UTC) FiestaLake, it's very useful, thank you. I have similar problem with 340xx after xorg-server update 1.20.13-3 -> 21.1.1-2 on linux 5.14.16. I didn't have the file xorg.conf at my system, so I created it manually with given section. This fixed the issue. FiestaLake commented on 2021-11-11 07:55 (UTC) (edited on 2021-11-11 07:56 (UTC) by FiestaLake) May be useful for someone. As now Xorg's version of ABI is 25.2 after updating Xorg to 21.1.1 I had to add these lines to xorg.conf to start graphics successfully. Section "ServerFlags" Option "IgnoreABI" "1" EndSection From nvidia-390xx-dkms, but it should work on 340xx too. calvinh commented on 2021-11-10 17:57 (UTC) libevdev 1.12.0-1 works fine in my system. Had to downgrade xf86-input-libinput (1.2.0-1) xorg-server (1.20.13-3) and xorg-server-common (1.20.13-3) holyArch commented on 2021-11-10 17:54 (UTC) (edited on 2021-11-11 14:37 (UTC) by holyArch) After upgrades, Xorg wasn't loading, and mouse and keyboard weren't responding. So I had to boot in single mode and downgrade the following packages: xf86-input-libinput (1.2.0-1) xorg-server (1.20.13-3) xorg-server-common (1.20.13-3) xorg-server-xephyr (1.20.13-3). Edit: no need to downgrade libevdev. Viterzgir commented on 2021-11-10 16:44 (UTC) Driver fails to load with latest xorg-server taz-007 commented on 2021-11-10 15:56 (UTC) Users of this package should block automatic update of their kernel. There is not enough man power to update it as fast as newer kernels are released. auriculaire commented on 2021-11-10 14:27 (UTC) No graphic connection on arch linux-linux and linux-lts. I tried to reinstall the module nvidia-340xx-dkms 340.108-24: no result with lightdm, gdm or sddm. no_like commented on 2021-11-09 07:54 (UTC) Seems the package faced an issue with the patch for linux 5.15 Bang1 commented on 2021-10-06 17:44 (UTC) (edited on 2021-10-06 17:58 (UTC) by Bang1) What xorg-server version is compatible with this driver? I have been trying to install it but I aways get a black screen when starting X server. tioguda commented on 2021-10-03 19:28 (UTC) That's why Manjaro users struggle to get some support here, guys see this laziness to read by some and end up thinking that everyone is like that. AlexJ commented on 2021-10-03 15:29 (UTC) Meganium97, you need to create link with named linux to /lib/modules/5.14.7-2-MANJARO/build (or whatever your kernel version is). That is because Arch and Manjaro have differences. You need to have installed headers first (sudo pamac install linux514-headers). If you have linux file link to an old kernel version then removed it (sudo rm /usr/src/linux). Then run: cd /lib/modules/$(uname -r)/build/ | echo $(uname -r) | sudo tee /lib/modules/$(uname -r)/build/version > /dev/null | sudo ln -s /lib/modules/$(uname -r)/build /usr/src/linux (This will create the link file linux with your current version of the kernel) You need to remove the link file /lib/modules/5.14.7-2-MANJARO/extramodules (sudo rm /lib/modules/5.14.7-2-MANJARO/extramodules), because it will give you an error while installing the nvidia drivers Create a new dir for the extramodules (sudo mkdir /lib/modules/5.14.7-2-MANJARO/extramodules) Copy all files to the new dir from /lib/modules/extramodules-5.14-MANJARO/ (sudo cp /lib/modules/extramodules-5.14-MANJARO/* /lib/modules/5.14.7-2-MANJARO/extramodules/) Then you should run the installer (sudo pamac install nvidia-340xx). After it is done you must copu 20-nvidia.conf to /etc/X11/xorg.conf.d/ (sudo cp /usr/share/nvidia-340xx/20-nvidia.conf /etc/X11/xorg.conf.d/) Then reboot (sudo reboot) That's it (You may have to do this again after a kernel update from a terminal because it may not start in Desktop mode (Ctrl+Alt+F2 to enter terminal). Don't forget to change the kernel version in the path names. (uname -r) Meganium97 commented on 2021-10-02 19:30 (UTC) I've been getting the error that /usr/src/linux doesn't exist. What can I do? Using manjaro with kernel 5.14.7-2 arch4ngel commented on 2021-09-25 09:35 (UTC) (edited on 2021-09-25 09:35 (UTC) by arch4ngel) So, it now works in 5.14.7-arch1-1, but no longer boots (just a blank screen and _ in the top left corner) in 5.10.68-1 (linux lts) I have linux lts installed as stable mainline often breaks (until there's a fix to this package). Given 5.10 will now be supported for many years, it was my mitigation against the instability of mainline non-lts. It's nice 5.14 works but if it breaks in 5.15 at some point, I won't be able to use 5.10 in the interim. Any ideas? vicpt commented on 2021-09-24 08:53 (UTC) Sorry guys for not reply (special in gitlab) but I have been busy in rl. About the b2sum, it was correct to my local revision. Probably during the clone/merge process something escaped to my tired eyes. I'm glad it helped. auriculaire commented on 2021-09-24 07:55 (UTC) Everything works very well. Thanks. However, I never found on the web the answer to this question about Nvidia: why /dev/dri/renderD128 isn't in /dev/dri ? Galard commented on 2021-09-21 10:55 (UTC) Thank you very much! The driver is working. MegaDeKay commented on 2021-09-21 01:14 (UTC) Latest -24 version works great for me on 5.14.6.arch1-1. /dev/drm is present and SDDM works too. My hats off to the devs that are keeping my old laptop going with the latest and greatest! tuxsavvy commented on 2021-09-16 12:41 (UTC) (edited on 2021-09-20 15:39 (UTC) by tuxsavvy) @alou-S You need to manually create the /etc/X11/xorg.conf.d/20-nvidia.conf. The filename 20-nvidia.conf is totally optional here, I personally named it because: It is easier to know exactly what sort of contents would be expected within that file, at a glance; it is pertaining to nvidia of course, and, The prefixing of the numbers indicates that it has a higher priority/preference when Xorg starts. Have a look at Arch Linux wiki, troubleshooting nvidia page. It gives you an idea of why I chose to use that filename, and to have that file there, even though that linked issue does not specifically apply to me. alou-S commented on 2021-09-15 16:19 (UTC) (edited on 2021-09-15 16:29 (UTC) by alou-S) @tuxsavvy Nvm, I figured it out. Just had to add this to my xorg.conf Section "Files" ModulePath "/usr/lib/nvidia/xorg" ModulePath "/usr/lib/xorg/modules" EndSection Also realized that /etc/X11/xorg.conf.d/20-nvidia.conf doesn't exist for me, coping it over from /usr/share/nvidia-340xx doesn't seem to fix the issue so had to add it to xorg.conf tuxsavvy commented on 2021-09-15 15:17 (UTC) @alou-S There's not enough information with regards to your issue. I have found a workaround to ensure that glxinfo -B does show my card. If this does not work, then I do not know how to solve your issue. In my /etc/X11/xorg.conf.d/20-nvidia. # # Section "Files" ModulePath "/usr/lib/nvidia/xorg" ModulePath "/usr/lib/xorg/modules" EndSection Section "Device" Identifier "Nvidia Card" Driver "nvidia" VendorName "NVIDIA Corporation" Option "NoLogo" "1" BoardName "GeForce <censored>" EndSection Perhaps try referring to the links in lines prepended with #character. alou-S commented on 2021-09-15 12:25 (UTC) @tuxsavvy Hmm other than the /dev/dri listing issue and sddm issue. The other problem is that OpenGL doesn't seem to work anymore. glxinfo gives some sort of (NV-GLX) error. tuxsavvy commented on 2021-09-14 15:26 (UTC) @alou-S You might want to check the merge comment by package maintainer. It looks like the required /dev/dri listing may not be implemented due to security risks. Presently the only viable way is to compile a custom kernel with that CONFIG_DRM_LEGACY set. As for sddm, the long story short is that it probably could be avoided if lightdm for instance was used instead (look for the comment by thelinuxfan). alou-S commented on 2021-09-14 14:58 (UTC) The latest version 340.108-23 seem to compile the kernel module right. But the old issue of sddm not able to start has come back.Card not visible in /dev/dri. Problem occurs on kernel 5.14.2 but not on 5.13.13 with the latest nvidia-340xx 340.108-23. Does anybody else have a similar issue? ismaail commented on 2021-09-12 19:43 (UTC) The latest upgrade nvidia-340xx (340.108-22 -> 340.108-23) works fine with Linux 5.14.2-arch1-2 Thank you. c0mmand0x72 commented on 2021-09-12 11:14 (UTC) @vicpt thx for the patch. I change the b2sum too in my pkgbuild and everything works fine. KUDOS to you KrisKorn commented on 2021-09-11 15:35 (UTC) (edited on 2021-09-12 01:35 (UTC) by KrisKorn) can't compile for kernel 5.14, it worked on previous kernels. I leave the output of /var/lib/dkms/nvidia/340.108/build/make.log on this pastebin page hopefully it will work. Thanks!! Loy commented on 2021-09-11 10:52 (UTC) (edited on 2021-09-11 10:52 (UTC) by Loy) @vicpt : Thanks for the last patch (kernel 5.14). But problem with b2sum on it, new sum is : a48a216dc36b104e2703372dc894c310cf6fc1eae99e6c015de1f04b61046d2d70c761531ad5b0acf9f678570688d5237db58711371ada0aed3ce0c776974f9f Maybe the download from gitlab but sum in PKGBUILD was wrong. After that, install works perfectly :) vicpt commented on 2021-09-11 03:36 (UTC) @JerryXiao I tried a resend for another address. If you for some reason don't receive, I will try later link it here directly or open a merge request on gitlab repo. vicpt commented on 2021-09-11 02:18 (UTC) @JerryXiao Sent through email, but apparently email got returned. No idea why. (was sent to the e-mail address in your profile) JerryXiao commented on 2021-09-11 02:03 (UTC) @vicpt I have not received anything yet. The better way would be to send a patch here or to open a merge request at vicpt commented on 2021-09-11 01:44 (UTC) @JerryXiao I'm not sure if you are interested, but I sent you a patch for the new 5.14 Kernel. Viterzgir commented on 2021-09-10 13:38 (UTC) With kernel 5.14 i have an error while building /home/serge/Downloads/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/nv-drm.c:60:10: fatal error: drm/drm_agpsupport.h: No such file or directory 60 | #include <drm/drm_agpsupport.h> | ^~~~~~~~~~~~~~~~~~~~~~ compilation terminated piquer commented on 2021-08-07 11:03 (UTC) Thanks for keeping this package alive! Very much appreciated. MegaDeKay commented on 2021-08-06 01:55 (UTC) @taz-007 Your repo worked perfectly on my laptop running 5.13, including SDDM. This lazy person thanks you :-) taz-007 commented on 2021-07-25 08:30 (UTC) dup line should be fixed now ismaail commented on 2021-07-24 16:35 (UTC) in PKGBUILD, the line 32 is duplicated.' 'a0266d62a742f8ecd96be767b66af169c09428ba3f718efa1e36f2c69303e35b6437503381b041dd3a88fa86eb82909f8cbf209dbba4a5658fd7bb220a852000' ') _pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32" removing the line 33 fixes the issue. bigbruno commented on 2021-07-24 16:15 (UTC) I tested it at that time: Building nvidia-340xx... /var/tmp/pamac-build-bruno/nvidia-340xx/PKGBUILD: line 33: syntax error near unexpected token )' /var/tmp/pamac-build-bruno/nvidia-340xx/PKGBUILD: line 33: ')' ==> ERROR: Failed to source /var/tmp/pamac-build-bruno/nvidia-340xx/PKGBUILD RottenSchnitzel commented on 2021-07-24 15:52 (UTC) (edited on 2021-07-24 16:59 (UTC) by RottenSchnitzel) There is a Syntax Error in the PKGBUILD (line 32 duplicate) taz-007 commented on 2021-07-24 10:08 (UTC) for the lazy people who cant wait (like me), I've updated the repo with the mentioned patch from the comments and pushed it to a temp branch on . Tested the dkms package on 5.13.4 kernel, sddm is working. NSLW commented on 2021-07-18 19:26 (UTC) @piquer Please look at the official repo at and particulary at The maintainer of this repo decided to reformat my two patches into a single patch, but other than that it should be the same content. The patch is already merged and public to all Fedora users, so it works. alou-S commented on 2021-07-18 10:18 (UTC) Okay the patch from the particular nuked commit you gave worked perfectly. Somebody needs to update the AUR package now. piquer commented on 2021-07-18 07:49 (UTC) There seems to have been a force push on master a couple of days after I pulled it. I'm using commit 621934ffcc439c9873e2ebe8acda7ad440813981 (HEAD -> master). which is the file posted below, except editing the diff headers as mentioned in The current head of master is commit 148afb60f2bc4850b50cb8c2cc9455885dff1ac9 (origin/master, origin/HEAD). Code in import-files-from-390.143.patch and conftest.Kbuild comes from NVIDIA-Linux-x86_64-390.143.run. About this change one would have to ask Łukasz I guess. └─> git --no-pager diff --stat 148afb6 621934f 129 < import-files-from-390.143.patch | 7221 -------------------------------------------------------------------------------------------------------------------------------------------------------------------- kernel-5.11.patch | 1490 +++------------------------------- nvidia-340xx-kmod.spec | 11 +- 3 files changed, 122 insertions(+), 8600 deletions(-) alou-S commented on 2021-07-18 05:58 (UTC) @piquer The patch you have mentioned is different from the one found in I also checked the original repo by rpmfusion but even that is not similar to the patch you used. Is it possible for you to give the source you got yours from or just give your particular patch since the one on rpmfusion doesn't work neither does the fork by wojnilowicz. piquer commented on 2021-07-17 14:47 (UTC) (edited on 2021-07-17 14:49 (UTC) by piquer) No, I didn't see rejected hunks. For reference, I used this patch as 0005-kernel-5.11.patch: diff -Naur ./a/kernel/conftest.sh ./b/kernel/conftest.sh --- NVIDIA-Linux-x86_64-340.108-old/kernel/conftest.sh 2021-05-24 20:08:18.743742335 +0200 +++ NVIDIA-Linux-x86_64-340.108-new/kernel/conftest.sh 2021-05-24 20:13:18.019314390 +0200 @@ -1578,21 +1578,21 @@ #include <drm/drm_drv.h> #endif - #if defined(NV_DRM_DRM_PRIME_H_PRESENT) - #include <drm/drm_prime.h> - #endif - #if !defined(CONFIG_DRM) && !defined(CONFIG_DRM_MODULE) #error DRM not enabled #endif + void conftest_drm_available(void) { struct drm_driver drv; - drv.gem_prime_pin = 0; - drv.gem_prime_get_sg_table = 0; - drv.gem_prime_vmap = 0; - drv.gem_prime_vunmap = 0; - (void)drm_gem_prime_import; - (void)drm_gem_prime_export; + + /* 2013-10-02 1bb72532ac260a2d3982b40bdd4c936d779d0d16 */ + (void)drm_dev_alloc; + + /* 2013-10-02 c22f0ace1926da399d9a16dfaf09174c1b03594c */ + (void)drm_dev_register; + + /* 2013-10-02 c3a49737ef7db0bdd4fcf6cf0b7140a883e32b2a */ + (void)drm_dev_unregister; }" compile_check_conftest "$CODE" "NV_DRM_AVAILABLE" "" "generic" diff -Naur ./a/kernel/nv-drm.c ./b/kernel/nv-drm.c --- NVIDIA-Linux-x86_64-340.108-old/kernel/nv-drm.c 2021-05-24 20:08:18.779739237 +0200 +++ NVIDIA-Linux-x86_64-340.108-new/kernel/nv-drm.c 2021-05-24 20:42:13.443288819 +0200 @@ -60,6 +60,8 @@ #else #include <drm/drm_agpsupport.h> +#include "linux/dma-buf.h" + struct nv_drm_agp_head { struct agp_kern_info agp_info; struct list_head memory; @@ -210,8 +212,10 @@ /* No locking needed since shadow-attach is single-threaded since it may * only be called from the per-driver module init hook. */ +#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0) if (drm_core_check_feature(dev, DRIVER_LEGACY)) list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list); +#endif return 0; @@ -239,8 +243,10 @@ if (WARN_ON(!(driver->driver_features & DRIVER_LEGACY))) return -EINVAL; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0) /* If not using KMS, fall back to stealth mode manual scanning. */ INIT_LIST_HEAD(&driver->legacy_dev_list); +#endif for (i = 0; pdriver->id_table[i].vendor != 0; i++) { pid = &pdriver->id_table[i]; @@ -273,11 +279,13 @@ if (!(driver->driver_features & DRIVER_LEGACY)) { WARN_ON(1); } else { +#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0) list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list, legacy_dev_list) { list_del(&dev->legacy_dev_list); drm_put_dev(dev); } +#endif } DRM_INFO("Module unloaded\n"); } @@ -402,6 +410,39 @@ .llseek = noop_llseek, }; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) +struct sg_table *nv_drm_gem_prime_get_sg_table(struct drm_gem_object *gem) +{ + return nv_gem_prime_get_sg_table(gem); +} + +static int nv_drm_gem_vmap(struct drm_gem_object *gem, + struct dma_buf_map *map) +{ + map->vaddr = nv_gem_prime_vmap(gem); + if (map->vaddr == NULL) { + return -ENOMEM; + } + map->is_iomem = true; + return 0; +} + +static void nv_drm_gem_vunmap(struct drm_gem_object *gem, + struct dma_buf_map *map) +{ + nv_gem_prime_vunmap(gem, map->vaddr); + map->vaddr = NULL; +} + +static struct drm_gem_object_funcs nv_drm_gem_object_funcs = { + .free = nv_gem_free, + .export = drm_gem_prime_export, + .get_sg_table = nv_drm_gem_prime_get_sg_table, + .vmap = nv_drm_gem_vmap, + .vunmap = nv_drm_gem_vunmap, +}; +#endif + static struct drm_driver nv_drm_driver = { .driver_features = DRIVER_GEM @@ -420,17 +461,19 @@ .set_busid = drm_pci_set_busid, #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) - .gem_free_object_unlocked = nv_gem_free, -#else +#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 8, 0) .gem_free_object = nv_gem_free, +#elif LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0) + .gem_free_object_unlocked = nv_gem_free, #endif .prime_handle_to_fd = drm_gem_prime_handle_to_fd, +#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 10, 0) .gem_prime_export = drm_gem_prime_export, .gem_prime_get_sg_table = nv_gem_prime_get_sg_table, .gem_prime_vmap = nv_gem_prime_vmap, .gem_prime_vunmap = nv_gem_prime_vunmap, +#endif .name = "nvidia-drm", .desc = "NVIDIA DRM driver", diff -Naur ./a/kernel/nv-linux.h ./b/kernel/nv-linux.h --- NVIDIA-Linux-x86_64-340.108-old/kernel/nv-linux.h 2021-05-24 20:08:18.775739581 +0200 +++ NVIDIA-Linux-x86_64-340.108-new/kernel/nv-linux.h 2021-05-24 20:09:18.748287771 +0200 @@ -119,7 +119,9 @@ #include <asm/tlbflush.h> /* flush_tlb(), flush_tlb_all() */ #include <linux/cpu.h> /* CPU hotplug support */ #endif -#include <asm/kmap_types.h> /* page table entry lookup */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) + #include <asm/kmap_types.h> /* page table entry lookup */ +#endif #include <linux/pci.h> /* pci_find_class, etc */ #include <linux/interrupt.h> /* tasklets, interrupt helpers */ diff -Naur ./a/kernel/uvm/nvidia_uvm_linux.h ./b/kernel/uvm/nvidia_uvm_linux.h --- NVIDIA-Linux-x86_64-340.108-old/kernel/uvm/nvidia_uvm_linux.h 2021-05-24 20:08:18.775739581 +0200 +++ NVIDIA-Linux-x86_64-340.108-new/kernel/uvm/nvidia_uvm_linux.h 2021-05-24 20:09:18.749287739 +0200 @@ -141,7 +141,9 @@ #if !defined(NV_VMWARE) #include <asm/tlbflush.h> /* flush_tlb(), flush_tlb_all() */ #endif -#include <asm/kmap_types.h> /* page table entry lookup */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0) + #include <asm/kmap_types.h> /* page table entry lookup */ +#endif #include <linux/interrupt.h> /* tasklets, interrupt helpers */ #include <linux/timer.h> graysky commented on 2021-07-16 17:19 (UTC) I don't have the hardware nor extra time for this anymore. Someone else can step up to bat. alou-S commented on 2021-07-16 15:21 (UTC) (edited on 2021-07-16 15:51 (UTC) by alou-S) @piquer @NSLW Did you get any errors during the build? During patching I get the following error: Hunk #3 FAILED at 139. 1 out of 9 hunks FAILED -- saving rejects to file kernel/nv-drm.c.rej Ignoring the error and further continuing ends up with it erroring while building the kernel module. johnstef commented on 2021-06-20 03:57 (UTC) (edited on 2021-06-21 13:33 (UTC) by johnstef) I am trying to run a program and I get this Check failed: gl_version_string. The GL proc resolver's glGetString(GL_VERSION) failed But if I switch to nouveau driver the program runs just fine. So I has to be this driver that causing the problem.. Any idea? JerryXiao commented on 2021-06-17 01:23 (UTC) AlexJ commented on 2021-06-16 20:12 (UTC) @tioguda OK. I have removed 2 of my comments and I have found a solution. MANJARO error: " ==> Starting build()... NVIDIA: calling KBUILD... make[1]: Entering directory '/usr/src/linux' make[1]: No rule to make target 'modules'. Stop. make[1]: Leaving directory '/usr/src/linux' NVIDIA: left KBUILD. nvidia.ko failed to build! make: [Makefile:202: nvidia.ko] Error 1 ==> ERROR: A failure occurred in build(). Aborting... " FIX: "cd /lib/modules/$(uname -r)/build/ | echo $(uname -r) | sudo tee version > /dev/null | sudo ln -s /lib/modules/$(uname -r)/build /usr/src/linux" tioguda commented on 2021-06-16 11:47 (UTC) @AlexJ if you read the comments, you'll get to mine where I mention what I change to compile for Manjaro. And remember, AUR is not a forum, so avoid spamming your build errors. Greetings. AlexJ commented on 2021-06-11 09:11 (UTC) @NSLW I suspected so. But now there is another problem. Every time I start a level in "Yamagi Quake II 5.34pre" the game freezes the laptop at certain points in the levels. I mean no input or output and a blank screen (USB, screen, keyboard everything freezes and the screen turns off). I have tried to run it with Tails to test if the drivers are the problem and there is no such problem with Tails (it is slower and there are some strange textures in water but no freeze) it runs fine. NSLW commented on 2021-06-11 06:54 (UTC) @AlexJ it's not an error. Please look at AlexJ commented on 2021-06-08 15:56 (UTC) @JerryXiao I have tried a LOT of things and I have found a solution for the Manjaro. I was not able to try "NVIDIA_340XX_DKMS_ONLY=1 makepkg or, probably NVIDIA_340XX_DKMS_ONLY=1 pamac" because I just saw that. The first error: "Building nvidia-340xx... /var/tmp/pamac-build-alex/nvidia-340xx/PKGBUILD: line 37: /usr/src/linux/version: No such file or directory" Fix that I've found: You have to copy the output of "$ uname -r" inside a file "version" inside /usr/src/linux/ (I've created it with "$sudo touch version", selected with a mouse, copy and the opened the file with "$ sudo vi /usr/src/linux/version" and "i", paste", ":wq!") The second error: "NVIDIA: calling KBUILD... make[1]: *** /usr/src/linux: No such file or directory. Stop." Fix that I've found: "$ sudo ln -s /usr/lib/modules/X.X.XX-X-MANJARO/build/ /usr/src/linux" (X.X.XX-X must be replaced with the version from the output of the "$ uname -r" in my case it was "$ sudo ln -s /usr/lib/modules/5.10.41-1-MANJARO/build/ /usr/src/linux" After that the installation works. There is something new that showed that I am not sure if it is an error: " ==> Starting build()... \ DNV_UVM_ENABLE -D__linux__ -DNV_DEV_NAME="nvidia-uvm"/uvm \ " JerryXiao commented on 2021-06-06 02:32 (UTC) (edited on 2021-06-06 02:40 (UTC) by JerryXiao) @AlexJ please run NVIDIA_340XX_DKMS_ONLY=1 makepkg or, probably NVIDIA_340XX_DKMS_ONLY=1 pamac AlexJ commented on 2021-06-05 13:22 (UTC) Hello. I have a problem installing this package on a Manjaro GNU/Linux distribution: " Preparing... Cloning nvidia-340xx build files... Checking nvidia-340xx-dkms dependencies... Synchronizing package databases... Resolving dependencies... Checking inter-conflicts... Building nvidia-340xx... /var/tmp/pamac-build-alex/nvidia-340xx/PKGBUILD: line 37: /usr/src/linux/version: No such file or directory ==> Making package: nvidia-340xx 340.108-19 ( 5.06.2021 (сб) 10:47:33) ==> Checking runtime dependencies... ==> Checking buildtime dependencies... ==> Retrieving sources... -> Downloading NVIDIA-Linux-x86_64-340.108-no-compat32.run... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 36.9M 0 224k 0 0 421k 0 0:01:29 --:--:-- 0:01:29 421k 3 36.9M 3 1328k 0 0 845k 0 0:00:44 0:00:01 0:00:43 844k 8 36.9M 8 3104k 0 0 1226k 0 0:00:30 0:00:02 0:00:28 1226k 11 36.9M 11 4464k 0 0 1264k 0 0:00:29 0:00:03 0:00:26 1264k 15 36.9M 15 5984k 0 0 1319k 0 0:00:28 0:00:04 0:00:24 1319k 19 36.9M 19 7296k 0 0 1316k 0 0:00:28 0:00:05 0:00:23 1411k 22 36.9M 22 8656k 0 0 1325k 0 0:00:28 0:00:06 0:00:22 1477k 26 36.9M 26 9.7M 0 0 1328k 0 0:00:28 0:00:07 0:00:21 1379k 30 36.9M 30 11.1M 0 0 1332k 0 0:00:28 0:00:08 0:00:20 1380k 34 36.9M 34 12.5M 0 0 1344k 0 0:00:28 0:00:09 0:00:19 1367k 37 36.9M 37 13.7M 0 0 1337k 0 0:00:28 0:00:10 0:00:18 1360k 41 36.9M 41 15.2M 0 0 1354k 0 0:00:27 0:00:11 0:00:16 1391k 44 36.9M 44 16.5M 0 0 1350k 0 0:00:28 0:00:12 0:00:16 1385k 48 36.9M 48 17.8M 0 0 1345k 0 0:00:28 0:00:13 0:00:15 1368k 51 36.9M 51 19.0M 0 0 1336k 0 0:00:28 0:00:14 0:00:14 1322k 54 36.9M 54 20.0M 0 0 1320k 0 0:00:28 0:00:15 0:00:13 1285k 57 36.9M 57 21.3M 0 0 1323k 0 0:00:28 0:00:16 0:00:12 1253k 61 36.9M 61 22.6M 0 0 1322k 0 0:00:28 0:00:17 0:00:11 1251k 65 36.9M 65 24.3M 0 0 1344k 0 0:00:28 0:00:18 0:00:10 1341k 70 36.9M 70 25.9M 0 0 1361k 0 0:00:27 0:00:19 0:00:08 1434k 73 36.9M 73 27.2M 0 0 1359k 0 0:00:27 0:00:20 0:00:07 1480k 77 36.9M 77 28.5M 0 0 1356k 0 0:00:27 0:00:21 0:00:06 1468k 81 36.9M 81 29.9M 0 0 1358k 0 0:00:27 0:00:22 0:00:05 1485k 85 36.9M 85 31.5M 0 0 1374k 0 0:00:27 0:00:23 0:00:04 1486k 89 36.9M 89 32.9M 0 0 1375k 0 0:00:27 0:00:24 0:00:03 1430k 92 36.9M 92 34.0M 0 0 1361k 0 0:00:27 0:00:25 0:00:02 1370k 94 36.9M 94 34.8M 0 0 1345k 0 0:00:28 0:00:26 0:00:02 1296k 96 36.9M 96 35.7M 0 0 1327k 0 0:00:28 0:00:27 0:00:01 1184k 99 36.9M 99 36.8M 0 0 1319k 0 0:00:28 0:00:28 --:--:-- 1063k 100 36.9M 100 36.9M 0 0 1322k 0 0:00:28 0:00:28 --:--:-- 1002k -> Found 20-nvidia.conf -> Found 0001-kernel-5.7.patch -> Found 0002-kernel-5.8.patch -> Found 0003-kernel-5.9.patch -> Found 0004-kernel-5.10.patch -> Found 0005-kernel-5.11.patch ==> Validating source files with b2sums... NVIDIA-Linux-x86_64-340.108-no-compat32.run ... Passed 20-nvidia.conf ... Passed 0001-kernel-5.7.patch ... Passed 0002-kernel-5.8.patch ... Passed 0003-kernel-5.9.patch ... Passed 0004-kernel-5.10.patch ... Passed 0005-kernel-5.11.patch ... Passed ==> Removing existing $srcdir/ directory... ==> Extracting sources... ==> Starting prepare()... Creating directory NVIDIA-Linux-x86_64-340.108-no-compat32 Verifying archive integrity... OK Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 340.108........................................................................................................................................................................................................... Applying patch 0001-kernel-5.7.patch... patching file kernel/Makefile patching file kernel/conftest.sh patching file kernel/dkms.conf patching file kernel/nv-drm.c patching file kernel/nv-linux.h patching file kernel/nv-procfs.c patching file kernel/nv-time.h patching file kernel/nv.c patching file kernel/os-interface.c patching file kernel/uvm/Makefile patching file kernel/uvm/conftest.sh patching file kernel/uvm/nvidia_uvm_lite.c Applying patch 0002-kernel-5.8.patch... patching file kernel/nv-linux.h patching file kernel/nvidia-modules-common.mk patching file kernel/os-mlock.c patching file kernel/uvm/nvidia_uvm_lite_api.c Applying patch 0003-kernel-5.9.patch... patching file kernel/nv-drm.c patching file kernel/nv-linux.h patching file kernel/nv.c patching file kernel/uvm/nvidia_uvm_linux.h Applying patch 0004-kernel-5.10.patch... patching file kernel/nv-drm.c Hunk #1 succeeded at 364 (offset 42 lines). Applying patch 0005-kernel-5.11.patch... patching file kernel/nv-linux.h patching file kernel/uvm/nvidia_uvm_linux.h ==> Starting build()... NVIDIA: calling KBUILD... make[1]: *** /usr/src/linux: No such file or directory. Stop. NVIDIA: left KBUILD. nvidia.ko failed to build! make: *** [Makefile:202: nvidia.ko] Error 1 ==> ERROR: A failure occurred in build(). Aborting... " I've got an answer from JerryXiao that it is because there is no kernel headers installed on my system, which is a prerequisite for ANY dkms packages but I have installed the headers before that error, according to the instructions: " $ uname -r 5.10.36-2-MANJARO $ sudo pacman -S $(mhwd-kernel -li | grep '*' | cut -d ' ' -f5 | awk '{print $0,"-headers"}' | sed s'/ //'g) warning: linux510-headers-5.10.36-2 is up to date -- reinstalling resolving dependencies... looking for conflicting packages... Packages (1) linux510-headers-5.10.36-2 Total Installed Size: 47,74 MiB Net Upgrade Size: 0,00 MiB ... $ pacman -Qkk linux-headers linux510-headers: 20906 total files, 0 altered files" What should I do to install this package without errors? piquer commented on 2021-05-28 11:55 (UTC) (edited on 2021-05-28 11:57 (UTC) by piquer) The patch mentioned by @NSLW works for me as well, thank you very much. Without the patch sddm does not start. Any chance to include it into the PKGBUILD? Here are the steps to test the patch. - clone - clone - copy kernel-5.11.patchto the AUR repository over file 0005-kernel-5.11.patch - replace every occurrence of ./awith NVIDIA-Linux-x86_64-340.108-oldand every occurrence of ./bwith NVIDIA-Linux-x86_64-340.108-newin the patch - calculate the hash of the patch with b2sum 0005-kernel-5.11.patch - update the hash in the last entry of the b2sumsarray in the PKGBUILD - run makepkgand install the resulting package with sudo pacman -U nvidia-340xx-dkms-340.108-19-x86_64.pkg.tar.zst tioguda commented on 2021-05-24 20:42 (UTC) Thank @NSLW, finally i managed to start my Manjaro Plasma (kernel 5.12.5) after your information. Greetings. NSLW commented on 2021-05-24 19:11 (UTC) I improved the patch to work with sddm again and made it available at NSLW commented on 2021-05-23 17:03 (UTC) On 5.11 there is no "kernel: [drm] Initialized nvidia-drm 0.0.0 20150116 for 0000:01:00.0 on minor 0" (drm_drv.c file in kernel) in journalctl, so no "/dev/dri/card0" is created. udev from systemd doesn't see "/dev/dri/card0", so it returns false for the following command "qdbus --system org.freedesktop.login1 /org/freedesktop/login1/seat/seat0 org.freedesktop.DBus.Properties.Get org.freedesktop.login1.Seat CanGraphical" sddm disables the greeter because it receives "false" from the above command. Hardcoding it to "true" shows the greeter. I have already tried to modify "nv-drm.c", but the kernel doesn't even visit that file. Would it be possible to initialize nvidia-drm somehow? Filkolev commented on 2021-05-17 20:12 (UTC) Back when 5.11 came out I was unable to make it work after a bit of fiddling and I downgraded back to 5.10. Now I decided I would look into it more closely and it turned out I had to do 2 things to fix it: - After putting 20-nvidia.confin the xorg config directory, I also had to delete the (empty) Filessection from /etc/X11/xorg.conf. - I had to set IGNORE_CC_MISMATCH=1in /etc/profile. The first time I actually ran sudo -E dkms install ... M4rty commented on 2021-05-17 15:02 (UTC) @auriculaire Thanks, it works ! auriculaire commented on 2021-05-17 13:54 (UTC) M4rty@ Same observation.: ==> Warning, dkms install --no-depmod -m nvidia -v 340.108 -k 5.12.4-arch1-2' returned 10 ==> Warning,dkms install --no-depmod -m nvidia -v 340.108 -k 5.10.37-1-lts' returned 10 You just have to reinstall the module nvidia-340xx-dkms 340.108-19, by ssh for example. M4rty commented on 2021-05-17 13:07 (UTC) Hi ! The driver don't work for me with 5.10.37-1-lts (arch, lightdm). It works perfect with 5.10.36 holyArch commented on 2021-05-16 10:28 (UTC) 340.108-19 seems to be working fine with 5.12.3.arch1-1 (e.g. VDPAU works). I didn't have to change anything in /etc/X11/xorg.conf.d/20-nvidia.conf (I have no /etc/X11/xorg.conf). Section "Files" ModulePath "/usr/lib/nvidia/xorg,/usr/lib/xorg/modules" EndSection also works in 20-nvidia.conf. johnstef commented on 2021-05-14 22:16 (UTC) (edited on 2021-05-14 22:17 (UTC) by johnstef) PROBLEM SOLVED The thing is that it was working perfectly on 5.11 and broke on 5.12 so my xorg.conf couldn't be the reason. The problem is that I ran nvidia-xconfig which ruined my xorg.conf that I had created back when I updated to 5.11. The 20-nvidia.conf is not working, all I had to do is to use this minimal config or just add this Section "Files" ModulePath "/usr/lib64/nvidia/xorg" ModulePath "/usr/lib64/xorg/modules" EndSection at the top of xorg.conf. So I can confirm that it's working perfectly on kernel 5.12 jayache80 commented on 2021-05-14 20:50 (UTC) (edited on 2021-05-14 20:51 (UTC) by jayache80) @johnstef 5.11 would have the same issues as 5.12. If you want to go back to an old kernel, go to 5.10 using linux-lts and point your bootloader at that kernel. However, I'll bet you just have a bad X11 config like I did. I can't tell- are you using Wayland and getting these errors via an Xwayland session? Or just regular X11? I only ask because it seems Wayland and nvidia will never get along. I had essentially identical errors as you, and I was able to fix it by correcting a bad xorg.conf configuration. The nvidia ModulePath needs to be above the default xorg one. Something like: Section "Files" ModulePath "/usr/lib64/nvidia/xorg" ModulePath "/usr/lib64/xorg/modules" EndSection I can't say for sure whether or not you should accomplish this by directly modifying /etc/X11/xorg.conf (like I do) or by placing an "overlay" config file (like the /usr/share/nvidia-340xx/20-nvidia.conf provided in this package) into the /etc/X11/xorg.conf.d directory. It depends on your existing configuration and how any existing ModulePath entries may be stepping on each other. The goal is for X11 to have nvidia-specific hardware acceleration libraries (libEGL, libGL, etc.) available at runtime otherwise you'll get those errors. (It is probably an upstream bug that allows a double free to occur when a library is missing instead of gracefully failing, but I digress). johnstef commented on 2021-05-14 19:45 (UTC) (edited on 2021-05-14 19:47 (UTC) by johnstef) I installed kernel 5.12 and I get the message that EGL could not be initialized on mpv and other apps. [vo/gpu] Probing for best GPU context. [vo/gpu/opengl] Initializing GPU context 'wayland' [vo/gpu/opengl] Initializing GPU context 'x11egl' [vo/gpu/x11] X11 opening display: :0 [vo/gpu/x11] Display 0 (HDMI-0): [0, 0, 1920, 1080] @ 60.000000 FPS [vo/gpu/x11] Current display FPS: 60.000000 [vo/gpu/opengl] Could not initialize EGL. free(): double free detected in tcache 2 I tried downgrading back to 5.11 but that error still exist! Do I have to do anything special to go back to the old kernel? deimon commented on 2021-05-11 01:21 (UTC) It works perfect, I had kernel 5.11 with driver 340.108-18 I did not have to modify anything. graysky commented on 2021-05-10 15:03 (UTC) OK, I honestly forgot that I included an example config file. Since I don't have the hardware for testing, and since I still don't have a sense from users that it is a requirement, I will leave it in the post_install and depend on the user's ability to read pacman's output and manually copy the example over. auriculaire commented on 2021-05-10 14:22 (UTC) @graysky I noted the advice that was given after installing the module on kernel 5.11: "-> You must tell Xorg to use the nvidia driver with kernels >=5.11.0. -> Minimal xorg config example: /usr/share/nvidia-340xx/20-nvidia.conf -> To place in /etc/X11/xorg.conf.d/ " In fact, as @jayache80 pointed out, it is in /etc/X11/xorg.conf (and not in xorg.conf.d/) that the "Files" section must be filled in. However, I am not able to conclude whether 20-nvidia.conf is mandatory or not. I don't remember to create it myself... Thanks to you. Sincerely. Translated with (free version) lucasrizzini commented on 2021-05-10 14:11 (UTC) Not specifically. graysky commented on 2021-05-10 13:45 (UTC) I have not been following this closely. Is 20-nvidia.conf a requirement for all setups of this driver with 5.12? Should the package provide an equivalent? auriculaire commented on 2021-05-10 13:07 (UTC) @jayache80 Thank you so much! ...I just added to my xorg.conf the two lines you mention, and archlinux with the latest kernel (uname -mr = 5.12.2-arch1 x86_64) boots well on lightdm and gdm for xfce, gnome and kde. Only sddm doesn't want to show up... Sincerely jayache80 commented on 2021-05-09 10:09 (UTC) (edited on 2021-05-09 23:36 (UTC) by jayache80) I'm an idiot. The order of ModulePath entries was somehow incorrect in my xorg.conf: As in the provided 20-nvidia.conf, and is nicely called out to the user upon installing this driver, it absolutely needs to be: Section "Files" ModulePath "/usr/lib64/nvidia/xorg" ModulePath "/usr/lib64/xorg/modules" EndSection However, somehow I had it reversed. The following is WRONG: Section "Files" ModulePath "/usr/lib64/xorg/modules" ModulePath "/usr/lib64/nvidia/xorg" EndSection Sorry for all the noise. The following can be ignored as it was totally a red herring. DRM is just different now and you can expect that it will be initialized differently and you won't see the same system log output in 5.11+ as 5.10. I think I know why I'm having problems on 5.11/5.12 but not 5.10. I noticed in the system log on 5.10 that DRM is getting initialized properly: [drm] Initialized nvidia-drm 0.0.0 20150116 for 0000:02:00.0 on minor 0 However, no such output in 5.11/5.12 when using this kernel module. That stuff is taken care of in nv-drm.c starting essentially with the call to nv_drm_pci_initfrom nv_drm_initbut only #if defined(NV_DRM_AVAILABLE). I proved it wasn't being called with some printk's. Something seems a little strange with the build system as that is defined in 5.10 but is not defined when building 5.11/5.12. I even added #define NV_DRM_AVAILABLE to the top of nv-drm.c to no avail. It's probably something really simple and I'll bet this will fix my issues (but I don't know about anyone else's). Anyone know what's up with that define? MegaDeKay commented on 2021-05-08 15:03 (UTC) Back in March on 5.11, people were having luck with GTK based greeters but Qt based ones weren't working (e.g. SDDM). So Googling around the error that @jayache80 reported, I found some references to people having weird problems with Qt that were fixed with setting QT_X11_NO_MITSHM=1 in someplace like /etc/environment. Maybe this explains why some people have luck and some don't? I'll admit that this is far-fetched, but it might be worth a shot given that it is low effort to try. The rabbit hole I went down are in the links below. Disabling the nvidia splash screen with Option "NoLogo" "1" in xorg.conf might not help, but it wouldn't hurt either. auriculaire commented on 2021-05-08 13:46 (UTC) I think that linux arch users who use this module have been running on linux-lts since the arrival of the latest 5.11.x and 5.12.x kernels with which for me this module has never been operational ..... I read the comments every day while waiting for the miracle solution. Have a good day and good luck everyone. tioguda commented on 2021-05-08 11:55 (UTC) graysky commented on 2021-05-08 10:56 (UTC) I'm not sure what I can do with your reply. You're modifying the PKGBUILD I provide to build without dkms on a foreign distro and you're reporting that it works. You're not sharing the code you're using to do this so it's impossible to make a comparison back to help users of Arch build via dkms. What if you uninstall your non-dkms tweaked package and try building with this unmodified. Does that build? If so do it give a functional module? tioguda commented on 2021-05-08 10:53 (UTC) (edited on 2021-05-08 10:54 (UTC) by tioguda) Yes, they abandoned it, but I am using this package as a base to build one for Manjaro. This driver is starting/working with the Manjaro (Gnome) 5.12 kernel and the Zen kernel (compiled locally). As I mentioned before, I use this package as a base, since small changes are needed to compile the non-dkms module in Manjaro. Greetings. graysky commented on 2021-05-08 10:28 (UTC) I am unfamiliar with manjaro but I thought they dropped this driver a while ago. Are you using the 5.12 kernel there where you report a functional driver? Is it this package you're using to build the kernel module? tioguda commented on 2021-05-08 01:17 (UTC) @graysky could you tell me a test to make sure everything is fine with the 5.12 kernel? In Manjaro Gnome the system starts and I don't have the problems reported by @jayache80. In Plasma I can only start via startx on tty2, I haven't tested it with Xfce. Greetings. graysky commented on 2021-05-07 12:39 (UTC) OK, if this doesn't give a functional module for the 5.12 series of kernels, we need to either 1) identify someone else's work to fix it (ie a patch from another distro or person), or 2) we need someone with expertise to fix it for us. I am not that someone nor do I have any hardware for testing. nahno commented on 2021-05-07 03:59 (UTC) I can confirm 2). Tested yesterday. My machine (xfce4) stills runs on Linux 5.11.7 without any issues though. graysky commented on 2021-05-06 18:33 (UTC) So there are two independent issues: 1) The patch shared by @qileilu is for the 460 series of drivers and not applicable to this version. 2) The package is-as does not work under 5.12. Can someone else confirm point #2 is valid? If so, we will need to identify the reason why and see if a known fix is out there. m31aur commented on 2021-05-06 16:09 (UTC) Whilst it builds without errors on 5.12, the system is unusable. At least with xfce4 that I am using. (xfwm fails to start). It works brilliantly on 5.10 lucasrizzini commented on 2021-05-06 12:50 (UTC) The patch below is for 460 version.. graysky commented on 2021-05-06 11:00 (UTC) I thought this worked with 5.12 without patches. It certainly builds which is all I can do testing-wise. qileilu commented on 2021-05-06 04:42 (UTC) (edited on 2021-05-06 04:43 (UTC) by qileilu) jayache80 commented on 2021-05-02 23:31 (UTC) I tried the 5.12 kernel from testing repo and have the same results. X11 starts fine, however graphics acceleration doesn't work properly. I still get the same libEGL-related double free coredump when using mpv (as seen in my previous comment). Some other datapoints: screen tearing exists (where it didn't before) and I cannot start gears, receiving the following error output: X Error of failed request: BadWindow (invalid Window parameter) Major opcode of failed request: 155 (NV-GLX) Minor opcode of failed request: 4 () Resource id in failed request: 0x2400002 Serial number of failed request: 56 Current serial number in output stream: 56 nikola_cz commented on 2021-04-28 10:10 (UTC) The same result in arch with dkms driver. Works without 5.12 patch. tioguda commented on 2021-04-27 13:20 (UTC) (edited on 2021-04-27 17:26 (UTC) by tioguda) I use Manjaro Gnome, and the driver (not dkms) compiled and started at 5.12 as it was starting at 5.11 (there was no need for a patch for 5.12). Greetings. MegaDeKay commented on 2021-04-20 14:18 (UTC) I have not tried this myself, but it seems some Ubuntu users are having success using graysky's patches that I assume are the same as those here. That thread points to this link on editing xorg.conf There also seems to be a patch ready to go for 5.12 Any brave folks want to give this a shot? jayache80 commented on 2021-04-19 00:34 (UTC) (edited on 2021-04-19 04:31 (UTC) by jayache80) Confirming that none of the 5.11.x kernels work well for me with this driver on my machine (mid-2009 macbook pro with 9400M). I moved back to a 5.10 kernel (I had 5.10.16 handy) and that fixed my issue. To be clear, with this driver and a 5.11 kernel, I can start X11 just fine, however I'm having issues with libEGL. mpv can't play movies because a double free crash occurs: free(): double free detected in tcache 2 Aborted (core dumped) With this backtrace: #0 0x00007ff290e62ef5 in raise () from /usr/lib/libc.so.6 #1 0x00007ff290e4c862 in abort () from /usr/lib/libc.so.6 #2 0x00007ff290ea4f38 in __libc_message () from /usr/lib/libc.so.6 #3 0x00007ff290eacbea in malloc_printerr () from /usr/lib/libc.so.6 #4 0x00007ff290eae6c8 in _int_free () from /usr/lib/libc.so.6 #5 0x00007ff290eb1ca8 in free () from /usr/lib/libc.so.6 #6 0x00007ff293b90719 in ?? () from /usr/lib/nvidia/libEGL.so.1 #7 0x00007ff293b90f15 in ?? () from /usr/lib/nvidia/libEGL.so.1 #8 0x00007ff293b98fd6 in ?? () from /usr/lib/nvidia/libEGL.so.1 #9 0x00005561599fd7fc in ?? () #10 0x00005561599db014 in ?? () #11 0x0000556159a077a3 in ?? () #12 0x0000556159a043e1 in ?? () #13 0x00007ff293ea0299 in start_thread () from /usr/lib/libpthread.so.0 #14 0x00007ff290f25053 in clone () from /usr/lib/libc.so.6 lucasrizzini commented on 2021-04-17 17:52 (UTC) Doesn't work on 5.11 here too. JackFrost commented on 2021-04-16 05:52 (UTC) linux-5.11.14.arch1-1-x86_64 with nvidia-340xx 340.108-18 does not work for me (ga-p35-ds3, gtx260, sddm, plasma) mischa commented on 2021-04-13 21:47 (UTC) The driver works with kernel 5.11.13 on my ThinkPad T61p (gdm and plasma), not on my AMD desktop susanne commented on 2021-04-13 08:18 (UTC) "Anyone please can confirm are there troubles or not with this driver and linux 5.11.13.arch1-1" - yes, me, my Thinkpad R61 only works with this driver on lts-kernel hackins commented on 2021-04-12 19:41 (UTC) (edited on 2021-04-12 19:42 (UTC) by hackins) Anyone please can confirm are there troubles or not with this driver and linux 5.11.13.arch1-1 jester commented on 2021-03-27 21:58 (UTC) Today I have updated the system with pacman and I have Graphic mode again. I use XFCE and LXDM, now I can write the password and everything seems Ok, but when I open an application, window manager is not working and I don't have the windows controls. I tried to execute xfwm4 or xfwm4 --replace but I get the error gtk-warning cannot open display: With a ps xfwm4 process does not appear. leopseft commented on 2021-03-27 20:06 (UTC) @tioguda you gave me such a great idea man!! I completely disabled the DM, I changed the default target to multiuser.target (instead of graphical target) then configured a minimal .xinitrc to start properly the KDE and in the end I automatized startx to autostart after login and finally automatized login user with systemd.service!! Got rid off DMS for good!! You Rule man! Keep it simple brothers!! ansgoati commented on 2021-03-27 19:59 (UTC) @leopseft @auriculaire I just trying to get the nvidia package work, on kernel 5.11.8 i was able to switch to nouveau maintaining the nvidia but after the upgrade and installing the lts kernel xinit can't start, i have sddm. auriculaire commented on 2021-03-27 16:13 (UTC) @ansgoati Personally, I didn't try to reinstall "nouveau" because my graphics card (GeForce 9400/integrated/SSE2) is too old, and I know that my pc (mac) often crashed when I first installed archlinux with "nouveau" by default. However, @leopseft gives you a good direction that you can refine by searching the internet. Sorry about that. leopseft commented on 2021-03-27 04:45 (UTC) (edited on 2021-03-27 04:49 (UTC) by leopseft) @ansgoati If you want to use nouveau I assume you have already deleted any nvidia.conf in xorg.d, right? Just tried with the sddm update and the 5.11.10 kernel and still nothing. Should we report a bug in upstream? Or it will be ignored because it is Nvidia related??!! tioguda commented on 2021-03-27 01:56 (UTC) ansgoati commented on 2021-03-27 01:39 (UTC) @auriculaire i've installed the lts kernel, recompile the nvidia package and now i can't even use nouveau. What could happen ? What i need to put on Xorg ?? Thanks auriculaire commented on 2021-03-25 16:25 (UTC) @leopseft : Yes of course. In fact, with lightdm, only xfce can connect but crashes. Maybe because of the background... But the problem is not due to the kernel nor to the cross-desktop but to the package: nvidia-340xx-dkms 340.108-18 on kernel 5.11....Good day. leopseft commented on 2021-03-25 14:48 (UTC) @auriculaire did you add a greeter for Lightdm as well? auriculaire commented on 2021-03-25 14:43 (UTC) Lightdm works...(kernel 5.11...) yes, but then no connection is made for desktops like XFCE, Gnome, Cinnamon, KDE plasma ... (same with gdm or sddm)...... But fortunately on Linux-lts (kernel 5.10....) : everything works. Thanks. thelinuxfan commented on 2021-03-24 05:16 (UTC) @mischa : I switched to lightdm and it worked! There's definitely some bug somewhere with SDDM or maybe some configuration changes that are needed and are missing. mischa commented on 2021-03-23 18:31 (UTC) Just tested kernel 5.11.8 on my two machines that had issues with 5.11.2: One (Intel notebook) worked with gdm, the other (AMD desktop) not, but none of them work with sddm. leopseft commented on 2021-03-23 15:34 (UTC) (edited on 2021-03-23 15:54 (UTC) by leopseft) @thelinuxfan Yes Just tested with lightdm (with gtk-greeter) and it worked!! So indeed it is SDDM guys... thelinuxfan commented on 2021-03-23 03:59 (UTC) @leopseft : Are you using SDDM? leopseft commented on 2021-03-21 16:45 (UTC) @thelinuxfan the thing is that we don't have trace the exact problem. thelinuxfan commented on 2021-03-21 04:59 (UTC) @leopseft : No luck on my setup either. Guess we will have to wait for 5.12? leopseft commented on 2021-03-20 21:17 (UTC) Still nothing with 5.11.7 I tried both with lib64 and with lib path with no luck. Does anyone has any updates for the issue? thelinuxfan commented on 2021-03-15 05:58 (UTC) Anyone got a chance to try this with 5.11.6? leopseft commented on 2021-03-09 13:18 (UTC) (edited on 2021-03-09 14:12 (UTC) by leopseft) (UTC) (edited on 2021-03-09 09:03 (UTC) by thelinuxfan) Gonna try with 5.11.4 Will update on this thread. EDIT: No luck with 5.11.4 either auriculaire commented on 2021-03-08 09:50 (UTC) mischa commented on 2021-03-06 13:11 (UTC) (edited on 2021-03-06 13:12 (UTC) by mischa) @thelinuxfan: the same issues here: the driver does not work with kernel 5.11.2 on two very different machines of mine (AMD desktop and Intel notebook), but it works fine with the lts-kernel (5.10.19-1 and 5.10.20-1) on both. M4rty commented on 2021-03-04 23:59 (UTC) @graysky Thank you very much for this package ! Everything works perfect with 5.11.2 thelinuxfan commented on 2021-03-04 12:34 (UTC) (edited on 2021-03-04 13:28 (UTC) by thelinuxfan) Does anybody know if we still have the same set of issues with 5.11.2? twobooks commented on 2021-03-03 05:22 (UTC) @graysky Thank you very much for your work. my SDDM process works, but found GPU0 stopped ==> /var/log/Xorg.0.log stopped SDDM, and started XDM, everything back to normal thelinuxfan commented on 2021-03-01 04:40 (UTC) (edited on 2021-03-09 04:51 (UTC) by thelinuxfan) @graysky : Thanks a lot for maintaining this and spending time on this. Update : I have tried lxdm, sddm & lightdm. None of them 'work properly' with 5.11. With sddm & lxdm, DMs don't come up. LightDM comes up, lets me log in, but doesn't load the driver, resulting in a broken GUI. I have also tried adding the ModulePath directly to xorg.conf, adding 20-nvidia.conf file to xorg.conf.d in both locations, /etc & /usr. None of them help. With 5.10-lts, things work fine with all three DMs. @tigouda : I tried that too, but didn't help. tioguda commented on 2021-02-28 15:08 (UTC) On my Manjaro Gnome it only worked after i used /usr/lib/ instead of /usr/lib64/ m31aur commented on 2021-02-28 10:22 (UTC) @graysky Thank you very much for your work. Much appreciated. There are a number of reported issues with the driver and 5.11 ie login managers window managers, xfwm4 and possibly other I am not aware of. The driver works fine on lts. Could it be the 5.11 patch? esturiano commented on 2021-02-28 01:47 (UTC) (5.11 + 20-nvidia.conf) I replaced SDDM with lightdm, lightdm started, but after that the plasma session (X11-plasma) did not start - dark screen. Downgraded to linux-lts (5.10). bieel1503 commented on 2021-02-27 20:51 (UTC) (edited on 2021-02-27 20:51 (UTC) by bieel1503) @leopseft SDDM does not work, for some reason. i tried lightdm, just for the sack of it and it worked. try: 'sddm --test-mode' for some output. Like @vicpt said, let's keep this space for the NVIDIA driver, but do share if you find a way to make it work. leopseft commented on 2021-02-27 19:51 (UTC) (edited on 2021-02-27 19:54 (UTC) by leopseft) Downgraded to 5.10 Kernel. With Kernel 5.11 I tried both adding the {{ Section "Files" ModulePath "/usr/lib64/nvidia/xorg" ModulePath "/usr/lib64/xorg/modules" EndSection }} and renaming the identifier in device section as mentioned (from Device0 to Nvidia Card) with no luck at all! Also tried keeping only the minimal config in case that something else on the previous working config breaks but with no luck either. I don't know if it's SDDM problem or Xorgs (I do use SDDM too) but I know for sure that previous kernel works!! vicpt commented on 2021-02-27 05:29 (UTC) Good to know you guys figured it out. But lets remember this thread is not for discussing display managers or window managers. The best would be a wiki entry explaining all your specific DM and WM configs and tweaks. Let's keep this space to talk about the NVIDIA driver. CourteousGeek commented on 2021-02-27 04:59 (UTC) Alright is seems that sddm might be the culprit with 5.11 kernel not showing. I went and disabled sddm login manager and installed lightdm-gtk-greeter and enabled it with systemctl and rebooted to linux 5.11 and works just fine. CourteousGeek commented on 2021-02-27 04:51 (UTC) (edited on 2021-02-27 04:52 (UTC) by CourteousGeek) Update - It seems that sddm desktop manager does want to show up on 5.11 but on 5.10 it works fine. So my idea is what if i just launch plasma desktop without a desktop manager. I stopped sddm with systemctl. I made my ~/.xinitrc i type in "exec startplasma-x11" for xorg and saved and exit. I typed in "startx startplasma-x11" and boom plasma DE worked so i might have a feeling that sddm or something is the cause of the issue. I gonna have to test other login managers or desktop manager to see what up. But i finally managed to get to the desktop with 5.11 kernel. vicpt commented on 2021-02-27 03:04 (UTC) @CourteousGeek without providing dmesg logs or Xorg logs I can't help you. @esturiano I don't use SDDM. I don't want to spam the thread with useless messages. If you guys want I can try help. I'm on Freenode and matrix.org esturiano commented on 2021-02-27 02:52 (UTC) @vicpt I saw your сcomments in step 15 and did everything as you suggested. But the SDDM does not start. Yours starts, but several users report that it does not. CourteousGeek commented on 2021-02-27 01:41 (UTC) @vicpt I've tried but can't to get passed the tty,i have added the xorg config in /etc/X11/xorg.conf.d/20-nvidia.conf correct with syntax and permissions seems normal, i can't get an Xorg log because sddm needs to be started. 5.10 works normal but 5.11 don't. vicpt commented on 2021-02-26 23:52 (UTC) @Zappo-II for older kernels the best approach is building yourself. For 5.4 you have all you need here: vicpt commented on 2021-02-26 23:42 (UTC) @ansgoati it should work, check your config file ownership and permissions (and syntax if you wrote by yourself). If all good and still not work, check your Xorg logs to see whats going on. vicpt commented on 2021-02-26 23:28 (UTC) @esturiano not a driver problem, driver works as expected on 5.11. vicpt commented on 2021-02-26 23:17 (UTC) @graysky -18 works as expected. Message informing the user about the need of config file and a respective minimal (template) config file is the best approach in my opinion. Otherwise if installed automatically can break user specific configurations. So in sum, its all ok and working on kernel 5.11. esturiano commented on 2021-02-26 14:28 (UTC) I temporarily switched to 5.10.18-1-lts. Everything works fine with the nvidia-340xx-lts-dkms. I hope that the driver will start working on 5.11. I'm really looking forward to it. @graysky thanks for your time and work. Zappo-II commented on 2021-02-26 11:09 (UTC) Sorry for dumb asking, will these and later versions continue to work with linux 5.10 or doesn't anybody care for earlier kernels...??? ...as far as I can see it won't work with 5.4 LTS anymore, does it...??? By the way @graysky: Mate, thanx for all your dedication for maintaining this package that I am using for ages with my Lenovo Laptop, you're my hero... graysky commented on 2021-02-26 10:53 (UTC) @esturiano - Yes, only change. Use the 'view changes' to see: fvsc commented on 2021-02-26 10:30 (UTC) I had the same problem sddm not starting. I downgraded to kernel 5.10.16-arch1-1 together with nvidia-340xx-dkms 340.108-18 and sddm is OK now. So maybe the problem is in the kernel patch. esturiano commented on 2021-02-26 02:59 (UTC) Dear @graysky. First thank you for Your work. 17 and 18 differ only in fixing a typo in 'post install'? Now I tried 18. The result is negative - sddm does not start. (I noticed a typo on 'post install' earlier and experienced 17 with the 20-nvidia.conf file in /etc/X11/xorg.conf.d/). graysky commented on 2021-02-25 19:40 (UTC) @bieel1503 - Corrected in -18. Let me know if the example config needs to be tweaked. bieel1503 commented on 2021-02-25 19:31 (UTC) @graysky yep, -17 works just fine. but you mistyped on 'post install', the path should be "/etc/X11/xorg.conf.d/". @holyArch that happened to me as well, i just uninstalled the nvidia packages, rebooted, rebuild it and it worked. ansgoati commented on 2021-02-25 15:27 (UTC) Hi. on 5.10 patch all was working flawless, now with 5.11 i suppose is the config file but the gui does not work well. xinit cannot initialize. CourteousGeek commented on 2021-02-25 14:47 (UTC) Using version 17 and manually typing the config on 20-nvidia.conf on kernel 5.11, not successful. GeForce 9500GT. esturiano commented on 2021-02-25 04:25 (UTC) (edited on 2021-02-25 12:38 (UTC) by esturiano) I have tried different versions (from 14 to 17), with config 20-nvidia.conf, but sddm not started (not further starting systemd). Kernel 5.10 worked well for me earlier. (old iMac - GF 9400 MCP7A) jeroni commented on 2021-02-25 03:14 (UTC) (edited on 2021-02-25 03:15 (UTC) by jeroni) Has anyone had issues with systemd message "a start job is running for /dev/dri/card0"? it ends with a crash and gdm won't start. I already had the 20-nvidia.conf file. I'm trying to boot on an old macbook with a geforce 9400M card and I'm stuck with 5.10 kernel. graysky commented on 2021-02-25 02:35 (UTC) See -17 and let me know if it needs to be tweaked. holyArch commented on 2021-02-25 02:34 (UTC) ==> dkms install --no-depmod -m nvidia -v 340.108 -k 5.11.1-arch1-1 Error! Bad return status for module build on kernel: 5.11.1-arch1-1 (x86_64) Consult /var/lib/dkms/nvidia/340.108/build/make.log for more information. ==> Warning, `dkms install --no-depmod -m nvidia -v 340.108 -k 5.11.1-arch1-1' returned 10 vicpt commented on 2021-02-24 22:43 (UTC) @bieel1503 thank for reporting. @graysky the package is working as it is, now it's up to you how to deal with required config files. If I can help in anything else, please say. Thank you very much for your time maintaining this package. bieel1503 commented on 2021-02-24 22:34 (UTC) @vicpt that's it, it worked. i wonder why tho, all of a sudden. but anyway thanks for this. vicpt commented on 2021-02-24 22:08 (UTC) @bieel1503 please test with that xorg conf and report back just for @graysky confirmation. vicpt commented on 2021-02-24 22:06 (UTC) The minimal xorg config file needed to work with opengl: Section "Files" ModulePath "/usr/lib64/nvidia/xorg" ModulePath "/usr/lib64/xorg/modules" EndSection Section "Device" Identifier "Nvidia Card" Driver "nvidia" VendorName "NVIDIA Corporation" EndSection vicpt commented on 2021-02-24 22:03 (UTC) @graysky as I thought it is indeed a xorg server related problem. The patches in -16 are good, keep the historical patches. So, in sum the package is ok. But a mention to alert users for the need of xorg config file would be good. A post_install message or even a script to install a minimal config file on demand should be the best solution in my opinion. graysky commented on 2021-02-24 21:07 (UTC) OK... I'll leave it to you guys to figure it out. If it is a config option, I will add a post-install and provide an example. Keep me updated. vicpt commented on 2021-02-24 21:07 (UTC) @graysky let the package in -16 with historical patches for now. We need to test different xorg configs just to be sure. vicpt commented on 2021-02-24 21:05 (UTC) Same thing with -16 no OpenGL. It can be xorg server related configs... graysky commented on 2021-02-24 20:59 (UTC) Let me know if the original patches or new patches give different results. I can add a post_install that directs users to create the needed config once you guys tell me which patches to use. vicpt commented on 2021-02-24 20:38 (UTC) (edited on 2021-02-24 20:42 (UTC) by vicpt) @bieel1503 at first I didn't. Now after trying few games that used to work I noticed they stop working. What package are you using, -14 or -15? @graysky reverted the patches he used in -15 to the original ones used in -14 to build the new one -16. I'm gonna test -16 (with historical patches plus the new one for 5.11) and report back. bieel1503 commented on 2021-02-24 19:49 (UTC) @vicpt It worked, thank you very much. But have you noticed a problem with OpenGL? It just won't work, somehow. vicpt commented on 2021-02-24 19:35 (UTC) @graysky having that minimal config file included in the package must cause problems for users that have specific configurations, so maybe informing users they need that file in order to have xorg server loading the correct legacy driver should be useful. Maybe a pinned post? graysky commented on 2021-02-24 19:22 (UTC) @vicpt - OK, I will push -16 which is just -14 (my patches + the new one). Recommend that you share your results on the appropriate wiki page. vicpt commented on 2021-02-24 18:01 (UTC) If anyone want a minimal Xorg configuration file to specify the "nvidia" driver instead "nv" one here it is, in /etc/X11/xorg.conf.d/20-nvidia.conf : Section "Device" Identifier "Nvidia Card" Driver "nvidia" VendorName "NVIDIA Corporation" EndSection vicpt commented on 2021-02-24 17:56 (UTC) Apparently the problem has nothing to do with the driver. After some debugging I noticed the driver is indeed working, the problem is xorg related. After a manual configuration of xorg, specifying the driver to use (nvidia) instead of (nv) my graphics are back again. @graysky the package is ok (probably since -14). Thank you for your time and attention on this package. vicpt commented on 2021-02-24 16:21 (UTC) @graysky as you can see dmesg doesn't report any errors and still the driver doesn't work. @taro_kun do you have the driver working on your setup with the patch you have mentioned in your last comment? esturiano commented on 2021-02-24 16:03 (UTC) does not work for me too graysky commented on 2021-02-24 16:01 (UTC) OK.. at this point I am a glorified packager since I have no hardware for testing. Others out there with 5.11 and legacy hardware confirm that -14 or -15 does not work as @vicpt reports? vicpt commented on 2021-02-24 15:26 (UTC) Relevant dmesg bits after module loading: nvidia 0000:01:00.0: vgaarb: changed VGA decodes: olddecodes=none,decodes=none:owns=io+mem NVRM: loading NVIDIA UNIX x86_64 Kernel Module 340.108 Wed Dec 11 11:06:58 PST 2019 vicpt commented on 2021-02-24 15:07 (UTC) @graysky about 'lsmod | grep nvidia' (in 5.11) as I told you the module is loaded but doesn't work. I can't test in 5.10 (I can't downgrade, my last kernel before 5.11 is much older). About the patches in warpme/minimyth2 repo a quick look reveals they don't seem the same we used to use here, only 5.10 and 5.11 seems the same. So I think more work is needed to get it work here. Meanwhile I will try to load the module again and check dmesg for some clues. graysky commented on 2021-02-24 14:51 (UTC) (edited on 2021-02-24 14:53 (UTC) by graysky) @vicpt - thanks for confirming. 1) What is the output of lsmod | grep nvidia under 5.11? 2) What is the output of lsmod | grep nvidia under 5.10? Any errors in dmesg/journalctl to explain why under 5.11? What about after you try manually loading it, ie modprobe nvidia? vicpt commented on 2021-02-24 14:43 (UTC) Tested -15 and it still doesn't work. graysky commented on 2021-02-24 13:35 (UTC) @vicpt - Alternatively, I can apply all of the patches from that repo rather than the ones we historically shipped. I don't have time to review to see if they are identical. Please try -15 and report back. vicpt commented on 2021-02-24 13:22 (UTC) The package builds fine, module loads, but it doesn't work. Apparently this patch is not enough, I think we need more work to get it work on 5.11. graysky commented on 2021-02-24 11:36 (UTC) @taro_kun - thanks, updated. Please try and report back. Builds find for me in a clean buildroot. taro_kun commented on 2021-02-23 23:53 (UTC) @graysky The source for the most recent patches now has a new one for 5.11: graysky commented on 2021-02-21 12:44 (UTC) Anyone got a patch for 5.11? hackins commented on 2021-02-13 20:17 (UTC) (edited on 2021-02-13 21:14 (UTC) by hackins) during the boot up i should see nvidia logo and then gnome logon screen, but instead my system shows flashing underscore forever until i switch to AltF2 and then switch back to AltF1 the system loads instantly. Can anyone please help me out to make my systeam load automatically. my telegram is hackins Update: found a workaround on reddit If anyone knows better way to solve the problem please contact me wurbelgrumpff commented on 2021-01-21 22:17 (UTC) great work! I've upgraded successfully from 5.9.14-arch to 5.10.9-arch1-1 with xfce 4.16 (with the help of trizen as AUR-helper) and it works stable. Thanks a lot for the patch. Stay healthy and have a happy new year! M4rty commented on 2021-01-13 22:35 (UTC) (edited on 2021-01-13 22:37 (UTC) by M4rty) Thanks for this package, it works perfect ! I just have a small issue with MPV player (celluloid) which does not start (kernel 5.9 & 5.10, arch i3wm) : "free (): double free detected in tcache 2". Does anyone have a solution ? modin5 commented on 2021-01-10 02:55 (UTC) @graysky @JerryXiao i have problem on installing the driver and their patches. i tried building your AUR version but it always fails on first error. and i tried the manjaro forum ( version it did the same error but if continued on but it thinks that i,m using manjaro kernel while i,m not so it fails to apply the patches because it searching for manjaro headers only (as i understood from the installation process). however it installed the driver but it freezes every time i open an normal application (like web browser, games ,etc but not system/preinstalled apps) because the patches aren,t applied. so now i,m stuck with the opensource driver that is slower and sometimes crashes some apps. so please someone help me! modin5 commented on 2021-01-09 03:57 (UTC) sorry for all the comment spaming i was doing i deleted some of my useless comments pls someone help me modin5 commented on 2021-01-09 03:18 (UTC) (edited on 2021-01-09 03:20 (UTC) by modin5) for a reason or another this function can,t find auto.conf even if it exits build() { cd "${_pkg}/kernel" make SYSSRC="/usr/lib/modules/$_kernelname/build" module cd uvm make SYSSRC="/usr/lib/modules/$_kernelname/build" module } jtag commented on 2021-01-05 21:07 (UTC) (edited on 2021-01-05 21:07 (UTC) by jtag) Just updated to nvidia-340.108-13 on Arch with kernel 5.10.4-arch2-1 using makepkg -risc and everything was smooth and no problems so far. SvenX commented on 2021-01-05 20:29 (UTC) @modin5 Just replace each line with "-" with the "+" lines. No need to change anything :-) modin5 commented on 2021-01-05 20:27 (UTC) something really quick in the second part of SvenX patch ⟱ build() { cd "${_pkg}/kernel" - make SYSSRC="/usr/src/$_kernelname" module + make SYSSRC="/usr/lib/modules/$_kernelname/build" module should i change the $_kernelname" to my kernel name or it just represent it in the code? parsal commented on 2021-01-05 17:13 (UTC) (edited on 2021-01-05 17:14 (UTC) by parsal) @damonh I used pamac. After downloading I changed PKGBUILD and ran pamac again. This time it didn't download again and used my modified PKGBUILD file. I'm not sure about yay; Maybe you have to use makepkg. @modin5 Obviously if you want to have this driver while you run kernel 5.10, you have to install it on 5.10! You don't have to be running 5.10 when you're building the driver, but you need to have the kernel-headers for 5.10. graysky commented on 2021-01-05 12:01 (UTC) @damonh - 340.108-13 is not broken. It builds successfully in a clean chroot[1]. Please stop using unsupported AUR helpers like yay. Build with makepkg and report back. If the issue is that you're trying to build this for Manjaro, I do not run that. Manjaro != Arch. damonh commented on 2021-01-05 02:21 (UTC) (edited on 2021-01-05 02:21 (UTC) by damonh) @parsal yay and pamac, both take care of all dependencies, but the PKGBUILD of this package is broken, that's why it doesn't work. We need a mantainer to fix and push it again to AUR. @modin5 I've followed the guide here and it worked with kernel 5.10.2-2 parsal commented on 2021-01-04 15:01 (UTC) (edited on 2021-01-04 15:02 (UTC) by parsal) @damonh Do you install with pamac install nvidia-340xx? Because it takes care of all dependencies. @modin5 It does need kernel >= 5.5 because support for the driver has been dropped since 5.5 (if you want to build for 5.4 or earlier read here. I, personally, updated to 5.10 (I mean why not). BTW, as I said, running `pamac install nvidia-340xx' takes care of all dependencies (asks you which kernel to install). damonh commented on 2021-01-04 14:03 (UTC) Thank you, @parsal. I've already did it, but now yay is trying to update the nvidia-340xx-dkms package. I've got nvidia-340xx-dkms version 340.108-1 and AUR has version 340.108-13 parsal commented on 2021-01-04 13:01 (UTC) (edited on 2021-01-04 13:16 (UTC) by parsal) SvenX commented on 2021-01-04 09:27 (UTC) @parsal @damonh @modin5 The Manjaro team published a How-To if you don't want to apply my patches by hand. Link: modin5 commented on 2021-01-03 23:18 (UTC) (edited on 2021-01-04 03:56 (UTC) by modin5) @parsal @damonh @modin5 (see my comment below) Same error on pacman/pamac damonh commented on 2021-01-03 21:57 (UTC) (edited on 2021-01-03 21:57 (UTC) by damonh) This is the error I'm getting using yay: ==> Sources are ready. ~/.cache/yay/nvidia-340xx/PKGBUILD: line 32: /usr/src/linux/version: No such file or directory ==> Making package: nvidia-340xx 340.108-13 (dom 03 ene 2021 18:52:56) ==> Checking runtime dependencies... ==> Checking buildtime dependencies... ==> WARNING: Using existing $srcdir/ tree ==> Removing existing $pkgdir/ directory... ==> Starting build()... NVIDIA: calling KBUILD... make[1]: *** /usr/src/linux: No such file or directory. Stop. NVIDIA: left KBUILD. nvidia.ko failed to build! make: *** [Makefile:202: nvidia.ko] Error 1 ==> ERROR: A failure occurred in build(). Aborting... error making: nvidia-340xx (nvidia-340xx-dkms) modin5 commented on 2021-01-03 19:07 (UTC) (edited on 2021-01-03 19:09 (UTC) by modin5) @parsal ok i was so lazy that i did make pamac install it for me first it told me it needed >5.5 kernel and >5.5 headers. i thought the patches will do the job so i ignored it the nividia driver failed to install for some reason and the open source graphics driver was disabled and so Xorg so i had no choice other than reinstall arch distro (i tried deleting the disable file module through nano but failed) i think i have to build it through terminal. but how? i,m so new to that "package building" so i think as you could build it it will be easy for you to explain it start with me from 0 to 100 my installation was so wrong i think SvenX commented on 2021-01-03 13:45 (UTC) (edited on 2021-01-03 13:47 (UTC) by SvenX) I was able to build for Manjaro 20.2 with the 5.10.2 kernel with the following changes to the PKGBUILD file. First adapt the kernel variables: # default is 'linux' substitute custom name here -_kernelname=linux -_kernver="$(</usr/src/$_kernelname/version)" -_extradir="/usr/lib/modules/$_kernver/extramodules" +_kernelname=`uname -r` +_kernver="$(</usr/lib/modules/$_kernelname/extramodules/version)" +_extradir="/usr/lib/modules/$_kernelname/extramodules" And after that, change the paths in the build() function: build() { cd "${_pkg}/kernel" - make SYSSRC="/usr/src/$_kernelname" module + make SYSSRC="/usr/lib/modules/$_kernelname/build" module cd uvm - make SYSSRC="/usr/src/$_kernelname" module + make SYSSRC="/usr/lib/modules/$_kernelname/build" module } After these changes, build it with: makepkg -s parsal commented on 2021-01-03 08:37 (UTC) (edited on 2021-01-03 08:39 (UTC) by parsal) @damonh As I said, I would fix it and give a link to a fixed version If I had the technical knowledge of make and install procedure. @modin5 I can but it would be incomplete since I only installed it on my laptop; I'm kind of a newbie myself. So I think it's easier if you tell me exactly where you're having trouble. For starters, exactly what command are you running and what does the error say? modin5 commented on 2021-01-02 22:51 (UTC) (edited on 2021-01-02 23:11 (UTC) by modin5) @parsal can you make a step by step installation guide for newbies like me ? sorry if i,m not patient enough or noisy i,m just worried about it. thanks @parsal for the information anyway. damonh commented on 2021-01-02 20:37 (UTC) Thank you @parsal, but can you please explain how to fix this package? Thank you. parsal commented on 2021-01-02 17:02 (UTC) (edited on 2021-01-02 17:04 (UTC) by parsal) Thank you very much for maintaining this driver. Saved me! I successfully installed it on Manjaro 20.2 kernel 5.10.2-2-Manjaro. However I think some minor changes could be very useful for everyone: - On my linux, /usr/src folder is empty (no linux link to kernel headers) so I had to manually create that. I think replacing that with $(uname -r) would solve this issue. - On my linux, extramodules is not actually in kernel headers folder but in a parent directory (both of them in /usr/lib/modules) and extramodules in kernel headers is symlink to it. After installation on "Cleaning Up" step, I got an error: "/usr/lib/modules/5.10.2-2-MANJARO/extramodules already exists (owned by linux 5.10)" (something like that) and I had to rename the symlink temporarily to be able to install and then copied the files back to the real extramodules folder and created symlink again. I would change the files and give you a link if I had the technical knowledge. Thanks again :) modin5 commented on 2021-01-01 20:55 (UTC) (edited on 2021-01-01 21:03 (UTC) by modin5) i tried installing this on pamac but it failed and i had to reinstall my arch-based distro (now i,m using endeavour os). i,m not saying this isn,t working but i,m having a problem installing it. i maybe a newbie but i have no problem using the terminal if i know what i,m doing / a tutorial. so can someone please make a step by step installation introduction ? i,m using zen kernel 5.9 on endeavour os with lxqt DE. gksudo commented on 2020-12-31 10:20 (UTC) This does not build on kernel 5.10.x, I have updated the PKGBUILD and added the required patch here: graysky commented on 2020-12-16 01:56 (UTC) @papakilo - Thanks for point me to the patch. Not out-of-date until 5.10.x goes into [core]. ansgoati commented on 2020-12-08 18:32 (UTC) Works well to me on Kernel 5.9.12. poluyan commented on 2020-11-23 13:02 (UTC) (edited on 2020-11-23 13:02 (UTC) by poluyan) @MegaDeKay Yes, I'm on 1.20 # Xorg -version X.Org X Server 1.20.9 X Protocol Version 11, Revision 0 Build Operating System: Linux Arch Linux Current Operating System: Linux cursedsun 5.9.9-arch1-1 What do you mean by something newer? According to Nvidia site with gts 250 I must stick with 340xx drivers. MegaDeKay commented on 2020-11-22 22:05 (UTC) @poluyan "Everything works fine" but are you still on xorg-server 1.20 or are you able to use something newer? poluyan commented on 2020-11-22 14:34 (UTC) @wurbelgrumpff, I'm with GeForce GTS 250 and Xfce 4.14. Just updated with nvidia-340xx 340.108-12 and nvidia-340xx-utils 340.108-1 at linux-5.9.9 kernel. Everything works fine. wurbelgrumpff commented on 2020-11-19 23:44 (UTC) Sorry for asking, but I'm a little confused about the situation. So, NVidia told about incompatibility issue with 5.9.x but here is still a driver's patch for 5.9.x. I'm working on a Core2 Duo with an Asus EN210 (Geforce 210) with kernel 5.8.14 and Xfce 4.14 and driver nvidia-340xx-dkms 340.108-9 which is really doing fine. But now I don't know, if it works after upgrading on actual kernel and driver. Anyone who has made experiences with that? Thanks! lgomesf commented on 2020-11-10 14:26 (UTC) Solve , change , .config to : CONFIG_AGP=m CONFIG_AGP_INTEL=m CONFIG_AGP_VIA=m lgomesf commented on 2020-11-10 10:18 (UTC) (edited on 2020-11-10 10:20 (UTC) by lgomesf) Same problem! make[2]: *** [scripts/Makefile.modpost:111: /home/luiz/git-Download/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/Module.symvers] ansgoati commented on 2020-10-25 14:35 (UTC) (edited on 2020-11-11 22:28 (UTC) by ansgoati) Any of you can change the brightness ?? I've tried adding the line: Option "RegistryDwords" "EnableBrightnessControl=1" to /usr/share/X11/xorg.conf.d/10-nvidia-brightness.conf and /etc/X11/xorg.conf without any effect. Solution: Add the follow line: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_osi=Linux" to /etc/default/grub and reboot. pfzim commented on 2020-10-23 20:20 (UTC) Hello! Sound via HDMI stops working after installing this driver on Nvidia MCP7A-ION. Can anyone help me fix the problem? For more details: Missed diff: lpga commented on 2020-10-22 11:29 (UTC) @graysky Everything fine here with the new release (and my old 8800GT), thank you very much graysky commented on 2020-10-22 11:07 (UTC) OK, 340.108-12 builds for me and simplifies things a bit. eugene commented on 2020-10-22 02:17 (UTC) it looks like patches for 5.8 are mandatory, @graysky eugene commented on 2020-10-22 01:39 (UTC) (edited on 2020-10-22 01:41 (UTC) by eugene) Does not work for me still. Fails with drm_pci_init function declaration error graysky commented on 2020-10-22 00:22 (UTC) I just pushed 340.108-11 but it still does not build for me in a buildroot. Can someone confirm that it is working? nmapper commented on 2020-10-21 22:16 (UTC) NVIDIA Corporation G96C [GeForce 9400 GT] (rev a1) here. Can confirm, works for me lpga commented on 2020-10-21 20:46 (UTC) (edited on 2020-10-21 20:48 (UTC) by lpga) first, thank you @speps for the patch; second, I used all the patches that were in the previous version of nvidia-340xx-dkms (for kernel 5.7 and 5.8) together to the new patch for kernel 5.9. obviously I don't make use of OpenCL or CUDA. the b2sum code for the new patch is $ cat nvidia-340.108-fix-5.9-kernel-compile.patch | b2sum and this is the prepare() function in "my PKGBUILD" prepare() { sh "${_pkg}.run" --extract-only cd "${_pkg}" # seems manjaro is keeping this current # (patch -p1 --no-backup-if-mismatch -i "$srcdir"/kernel-5.7.patch) # # the following was extracted from # (cd kernel && patch -p1 --no-backup-if-mismatch -i "$srcdir"/buildfix_kernel_5.8.patch) # patch kernel 5.9 (patch -p1 --no-backup-if-mismatch -i "$srcdir"/kernel-5.9.patch) cp -a kernel kernel-dkms } Filkolev commented on 2020-10-21 20:16 (UTC) (edited on 2020-10-21 20:18 (UTC) by Filkolev) That's the one I used. Now I get implicit declaration of drm_pci_init/drm_pci_exit, if anyone has a fix for this please share. holyArch commented on 2020-10-21 20:00 (UTC) (edited on 2020-10-21 20:03 (UTC) by holyArch) Filkolev commented on 2020-10-21 19:55 (UTC) Patch file was modified on Github on Oct 20, so currently the checksum does not match. The one provided in PKGBUILD corresponds to the previous commit pushed on Aug 26. lgomesf commented on 2020-10-21 19:22 (UTC) (edited on 2020-10-21 19:23 (UTC) by lgomesf) I added the patch and the build errors! aurobe commented on 2020-10-21 17:13 (UTC) @speps THX! works for me! (5.9.1-2-ck) piotro commented on 2020-10-19 18:19 (UTC) @speps: nice catch! Thx! graysky commented on 2020-10-19 16:23 (UTC) @speps - Here is the contents of that file: #define NV_REMAP_PFN_RANGE_PRESENT #define NV_VMAP_PRESENT #define NV_VMAP_ARGUMENT_COUNT 4 #define NV_SET_PAGES_UC_PRESENT #define NV_SET_MEMORY_UC_PRESENT #define NV_SET_MEMORY_ARRAY_UC_PRESENT #undef NV_CHANGE_PAGE_ATTR_PRESENT #define NV_PCI_GET_CLASS_PRESENT #define NV_PCI_CHOOSE_STATE_PRESENT #define NV_VM_INSERT_PAGE_PRESENT #undef NV_ACQUIRE_CONSOLE_SEM_PRESENT #define NV_CONSOLE_LOCK_PRESENT #define NV_KMEM_CACHE_CREATE_PRESENT #define NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT 5 #define NV_ON_EACH_CPU_PRESENT #define NV_ON_EACH_CPU_ARGUMENT_COUNT 3 #define NV_SMP_CALL_FUNCTION_PRESENT #define NV_SMP_CALL_FUNCTION_ARGUMENT_COUNT 3 #define NV_ACPI_EVALUATE_INTEGER_PRESENT typedef unsigned long long nv_acpi_integer_t; #define NV_IOREMAP_CACHE_PRESENT #define NV_IOREMAP_WC_PRESENT #define NV_ACPI_WALK_NAMESPACE_PRESENT #define NV_ACPI_WALK_NAMESPACE_ARGUMENT_COUNT 7 #define NV_PCI_DOMAIN_NR_PRESENT #define NV_PCI_DMA_MAPPING_ERROR_PRESENT #define NV_PCI_DMA_MAPPING_ERROR_ARGUMENT_COUNT 2 #define NV_SG_ALLOC_TABLE_PRESENT #define NV_SG_ALLOC_TABLE_FROM_PAGES_PRESENT #define NV_SG_INIT_TABLE_PRESENT #define NV_PCI_GET_DOMAIN_BUS_AND_SLOT_PRESENT #define NV_GET_NUM_PHYSPAGES_PRESENT #define NV_EFI_ENABLED_PRESENT #define NV_EFI_ENABLED_ARGUMENT_COUNT 1 #define NV_PROC_CREATE_DATA_PRESENT #define NV_PDE_DATA_PRESENT #define NV_PROC_REMOVE_PRESENT #define NV_PM_VT_SWITCH_REQUIRED_PRESENT #define NV_PCI_SAVE_STATE_ARGUMENT_COUNT 1 #undef NV_DRM_PCI_SET_BUSID_PRESENT #undef NV_WRITE_CR4_PRESENT #define NV_FOR_EACH_ONLINE_NODE_PRESENT #define NV_NODE_END_PFN_PRESENT #undef NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS #undef NV_GET_USER_PAGES_HAS_TASK_STRUCT #define NV_GET_USER_PAGES_REMOTE_PRESENT #undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG #undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS #undef NV_REGISTER_CPU_NOTIFIER_PRESENT #define NV_CPUHP_SETUP_STATE_PRESENT #undef NV_DRM_LEGACY_PCI_INIT_PRESENT #define NV_TIMER_SETUP_PRESENT #undef NV_DO_GETTIMEOFDAY_PRESENT #undef NV_DRM_GEM_OBJECT_PUT_UNLOCKED_PRESENT canolucas commented on 2020-10-19 16:10 (UTC) nvidia-340xx-dkms is working fine here using linux 5.9.1-arch1-1 and newly added kernel-5.9.patch lpga commented on 2020-10-19 13:02 (UTC) I'm a owner of a GT 8800 512MB graphic card, and I applied the patch that speps posted and successfully build the module for the kernel 5.9. For now it seems that there's no problem (no OpenCL or CUDA). speps commented on 2020-10-18 21:54 (UTC) @graysky: working and building fine here, in a clean chroot. Seems like, in your setup, the NV_SET_MEMORY_ARRAY_UC_PRESENT is defined, while it should be undef. Can you please check what you get in kernel/conftest/function.h after build? graysky commented on 2020-10-18 20:35 (UTC) @speps - I added the patch and the build errors out (building in a buildroot). ... /build/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/nv-vm.c: In function ‘nv_set_memory_array_type’: /build/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/nv-vm.c:86:13: error: implicit declaration of function ‘set_memory_array_uc’; did you mean ‘set_pages_array_uc’? [-Werror=implicit-function-declaration] 86 | set_memory_array_uc(pages, num_pages); | ^~~~~~~~~~~~~~~~~~~ | set_pages_array_uc ./tools/objtool/objtool orc generate --module --no-fp --retpoline --uaccess /build/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/nv-vtophys.o /build/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/nv-vm.c:89:13: error: implicit declaration of function ‘set_memory_array_wb’; did you mean ‘set_pages_array_wb’? [-Werror=implicit-function-declaration] 89 | set_memory_array_wb(pages, num_pages); | ^~~~~~~~~~~~~~~~~~~ | set_pages_array_wb cc1: some warnings being treated as errors make[2]: *** [scripts/Makefile.build:283: /build/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/nv-procfs.o] Error 1 cc1: some warnings being treated as errors make[2]: *** [scripts/Makefile.build:283: /build/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/nv-vm.o] Error 1 make[1]: *** [Makefile:1784: /build/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel] Error 2 make[1]: Leaving directory '/usr/lib/modules/5.9.1-arch1-1/build' NVIDIA: left KBUILD. nvidia.ko failed to build! make: *** [Makefile:197: nvidia.ko] Error 1 speps commented on 2020-10-18 20:01 (UTC) @graysky: piotro patch is fine but incomplete, the uvm part is missing. Here is a working patch for kernel 5.9: You can use it by adding (patch -p1 --no-backup-if-mismatch -i "$srcdir"/kernel-5.9.patch) to the PKGBUILD and the relative checksum. graysky commented on 2020-10-18 16:38 (UTC) @piorto - Tried applying just your patch and the two I am currently shipping (3 totally) but ran into build errors. How are you recommending usage? piotro commented on 2020-10-18 13:02 (UTC) Hi, You may be interested in 340.108 support on 5.9 kernel I developed for my distro.... graysky commented on 2020-10-18 11:09 (UTC) papakilo commented on 2020-09-15 14:12 (UTC) (edited on 2020-10-03 21:46 (UTC) by papakilo) EDITED ... leopseft commented on 2020-09-12 17:18 (UTC) Update: After full system update and using nouveu in meanwhile, I reinstalled the driver with clenbuild the package and the module built successfully for the 5.8.8 kernel!! jwmartnet commented on 2020-09-07 21:05 (UTC) (edited on 2020-09-07 21:05 (UTC) by jwmartnet) Same error here, running LTS kernel & nvidia LTS drivers. After much headscratching I just: pacman -S linux-lts linux-lts-headers Seemed to fix it. leopseft commented on 2020-09-06 17:31 (UTC) @holyArch Yes, just tried it, the module build successfully with no errors but the driver doesn't work. holyArch commented on 2020-09-05 23:32 (UTC) Have you tried env IGNORE_CC_MISMATCH=1 dkms install -m nvidia -v 340.108 -k 5.8.6-arch1-1 leopseft commented on 2020-09-04 17:46 (UTC) Today I updated with the latest toolchain first, then reboot (just in case), then installed the latest kernel (5.8.5 and tested with 5.8.6 too) and the headers and still nothing. Gave a try to the 5.8.3 too and still nothing. The only combination that works for me as well is linux 5.8.1.arch1-1 with linux-headers 5.8.1.arch1-1 and gcc 10.1.0-2 with gcc-libs 10.1.0-2 and lib32-gcc-libs 10.1.0-2 as mentioned before. fvsc commented on 2020-08-22 19:10 (UTC) @graysky also cat /proc/version gives the info for the installed kernel. Linux version 5.8.2-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35) #1 SMP PREEMPT Thu, 20 Aug 2020 20:45:00 +0000 But I want to know the toolchain of a new kernel before I install it. Downgrading, insert [testing] in pacman.conf, upgrading and so on is a little too time consuming for me. I will see if I find some info and let you know. graysky commented on 2020-08-22 15:23 (UTC) @fvsc - It's rare that the kernel build with an outdated toolchain is offered. I guess you can look in [testing] if you know they updated gcc and see what's there. You can grep dmesg for it on your current kernel and then just see what is in [testing]: % dmesg| grep gcc [ +0.000000] Linux version 5.4.60-1-lts (linux-lts@archlinux) (gcc version 10.2.0 (GCC)) #1 SMP Fri, 21 Aug 2020 16:53:54 +0000 Maybe there's an easier way. fvsc commented on 2020-08-22 14:40 (UTC) @graysky I followed your solution and it is OK now. Many thanks. Do you know how I can check which toolchain was used to build the kernel before upgrading my system. Thanks in advance. graysky commented on 2020-08-22 09:05 (UTC) (edited on 2020-08-22 10:46 (UTC) by graysky) Again, the problem is that 5.8.2 was build with gcc 10.1.0. At that time, gcc 10.2.0 was in [staging] not [testing]. 5.8.2 went into [core] before gcc 10.2.0 went into [testing]. 5.8.3 was build with gcc 10.2.0 and they moved gcc 10.2.0 to [core] before 5.8.3 came out of [testing]. Solution: update your system so you get the new toolchain then pull 5.8.3 and (headers) from [testing] so dkms builds for you. fvsc commented on 2020-08-22 07:52 (UTC) (edited on 2020-08-22 07:54 (UTC) by fvsc) I had the same problem. Version 5.8.3 of the kernel was not working for me. Downgraden the kernel and gcc solved the problem. Combination that works: linux 5.8.1.arch1-1 linux-headers 5.8.1.arch1-1 gcc 10.1.0-2 gcc-libs 10.1.0-2 lib32-gcc-libs 10.1.0-2 wurbelgrumpff commented on 2020-08-21 23:34 (UTC) @graysky: Thanks a lot for your fast response, it works with 5.8.3 from [testing]. Normally I ignore [testing], so I will see, what happens when I comment out testing-repo again and wait for coming of 5.8.3 in [core]. Wouldn't it not also be okay to downgrade gcc to former version while installing 5.8.2? Maybe it would be a better solution for people who don't like [testing]? We'll see.... At least a dkms-issue remains: ==> Unable to remove module nvidia/340.108 for kernel 5.8.2-arch1-1: Not found in dkms status output. Do you know something about it? Despite this, system is working.... oups(!): That was former kernel, maybe a dkms-issue.... @graysky and all others working on this nvidia-patches: I really want to say 'Thank you!' to you for spending so much time and energy on this project. It makes it possible to users like me to run old hardware a little longer time - thanks a lot!! best regards! graysky commented on 2020-08-21 22:42 (UTC) It's because your kernel was build with the earlier version of gcc and 5.8.3 is not yet in [core]. Grab it and the headers from [testing] and it should work. wurbelgrumpff commented on 2020-08-21 21:26 (UTC) (edited on 2020-08-21 21:30 (UTC) by wurbelgrumpff) Hello, I'm sorry, but with updating on Kernel 5.8.2 I encounter some real problems: Together with the kernel also gcc and gcc-libs were updated from 10.1.0-2 to 10.2.0-1, I don't know if this is important.... Messages from pacman.log: ==> dkms install --no-depmod -m nvidia -v 340.108 -k 5.8.2-arch1-1 Error! Bad return status for module build on kernel: 5.8.2-arch1-1 (x86_64) Consult /var/lib/dkms/nvidia/340.108/build/make.log for more information. ==> Warning, `dkms install --no-depmod -m nvidia -v 340.108 -k 5.8.2-arch1-1´ returned 10 ==> depmod 5.8.2-arch1-1 [....] I tried to reinstall nvidia but: ==> Unable to remove module nvidia/340.108 for kernel 5.8.2-arch1-1: Not found in dkms status output. In make.log gcc-version-check failed. (I mentioned gcc was upgraded): DKMS make.log for nvidia-340.108 for kernel 5.8.2-arch1-1 (x86_64) Fr 21. Aug 21:54:01 CEST 2020 gcc-version-check failed: The compiler used to compile the kernel (gcc 10.1) does not exactly match the current compiler (gcc 10.2).] Fehler 1 [Error 1] make: Verzeichnis „/var/lib/dkms/nvidia/340.108/build/uvm“ wird betreten [directory ... is entered] cd ./..; make module SYSSRC=/lib/modules/5.8.2-arch1-1/build SYSOUT=/lib/modules/5.8.2-arch1-1/build KBUILD_EXTMOD=./.. make[1]: Verzeichnis „/var/lib/dkms/nvidia/340.108/build“ wird betreten [directory ... is entered] NVIDIA: calling KBUILD... make[2]: Verzeichnis „/usr/lib/modules/5.8.2-arch1-1/build“ wird betreten [directory ... is entered]:44: ../Makefile: Datei oder Verzeichnis nicht gefunden [:file or directory not found] make[3]: *** Keine Regel, um „../Makefile“ zu erstellen. Schluss. [no rule to build ../Makefile. Exit.] make[2]: *** [Makefile:1756: ..] Fehler 2 [error 2] make[2]: Verzeichnis „/usr/lib/modules/5.8.2-arch1-1/build“ wird verlassen [directory ... is exited] NVIDIA: left KBUILD. nvidia.ko failed to build! make[1]: *** [Makefile:202: nvidia.ko] Fehler 1 [error 1] make[1]: Verzeichnis „/var/lib/dkms/nvidia/340.108/build“ wird verlassen [directory ... is exited] make: *** [Makefile:222: ../Module.symvers] Fehler 2 [error 2] make: Verzeichnis „/var/lib/dkms/nvidia/340.108/build/uvm“ wird verlassen [directory ... is exited] (Translation is appended within []); pls, ignore my english...... Well, I'm badly surprised, because all formerly updates worked without any problems. Patch 5.7 worked really well and also upgrading to 5.8.1 was without any errors. I use an over ten years old machine (core2duo) with Nvidia gt210 and running xfce4 on it. Please, can anyone help with this? Best regards! johnvranos commented on 2020-08-18 03:15 (UTC) (edited on 2020-08-18 03:15 (UTC) by johnvranos) You can try installing flatpak or snapd. They have the latest version of Spotify: graysky commented on 2020-08-15 10:36 (UTC) @fvsc - Thanks for testing. Now that 5.8.1 has moved to [core] I pushed this formally a few min ago. fvsc commented on 2020-08-15 09:05 (UTC) For me is the combination PKGBUILD and PATCH working with kernel linux 5.8.1.arch1-1. NVIDIA Corporation G98 [GeForce 8400 GS Rev. 2] (rev a1) Thanks. graysky commented on 2020-08-12 10:02 (UTC) (edited on 2020-08-12 10:17 (UTC) by graysky) @papakilo - It seems they have a patch for 5.8. Does anyone know how the navigate launchpad? I need to find their source patches to see how to adapt to our package. Towards the end: -rw-r--r-- root/root 2373 2020-08-08 12:55 ./usr/src/nvidia-340-340.108/patches/buildfix_kernel_5.8.patch EDIT: I got it, needed to look at the "available diffs" for example: I now have a package that builds against 5.8. Can someone with supported hardware try it? I don't want to push to AUR until linux-5.8 goes into [core]: papakilo commented on 2020-08-11 22:29 (UTC) Just for info, Ubuntu and derivatives have Nvidia 340 drivers for kernel 5.8 here: graysky commented on 2020-08-10 16:38 (UTC) @papakilo - They aren't ... I cannot build this package against 5.8.0 papakilo commented on 2020-08-10 15:05 (UTC) @graysky - Hi, patches for kernel 5.7 have been around and worked good for some time, as I'm using kernel 5.7.14 and Nvidia 340.108 in Manjaro. So I suppose those patches could be the same for kernel 5.8... graysky commented on 2020-08-09 13:05 (UTC) @papakilo - Thank you for the link, but unless the new patche(s) are also backwards compatible with 5.7 which is currently offered in [core], and until the 5.8 kernel package moves from [testing] to [core], the package is not out-of-date. Also, the link you posted only shows a 1-month-old patch for 5.7. I did not see a modification for 5.8. Perhaps I missed it? papakilo commented on 2020-08-09 12:46 (UTC) Hi, new patches for kernel 5.8 here: piquer commented on 2020-07-12 12:49 (UTC) This looks promising for 5.7 kernels. pgoetz commented on 2020-07-08 18:28 (UTC) I can't get this or the nvidia-340xx-dkms to work with the newest kernel, 5.7.7.arch1-1. Xezlec commented on 2020-06-28 20:06 (UTC) Never mind. Just noticed the GPU fan is not spinning. Guess it's getting to be time to buy a new card. Xezlec commented on 2020-06-27 16:19 (UTC) I'm having lots of bad screen tearing with this driver now. I didn't use to have that problem. I can't even watch videos now, it's so bad. jayache80 commented on 2020-06-26 22:13 (UTC) (edited on 2020-06-26 22:15 (UTC) by jayache80) Does anyone else have a problem with this module coexisting with forcedeth? If I install this module, every time I plug in an Ethernet cable I get a "watchdog: soft lockup" and have to restart my computer. However, if I blacklist forcedeth, and simply modprobe forcedeth whenever I need to use Ethernet, it works and doesn't cause a lockup (though I still sense the computer "stumble" a little bit, but only for a split second). This is with the 9400M chipset on a mid-2009 Macbook Pro (5,5). wurbelgrumpff commented on 2020-06-19 21:14 (UTC) @leopseft: same as for me, but also without any problems. Some days before there was a dkms update, today a new kernel (5.7.4) was in core. Since today this strange error-message vanished and everything is okay. I think, it has nothing to do with nvidia driver or its patches, maybe it has been a dkms issue... Nvidia driver works really well and stable. leopseft commented on 2020-06-16 18:22 (UTC) Hello folks, I receive the following strange error: "Unable to install module nvidia/340.108 for kernel 5.4.3-arch1-1: Missing kernel headers" While I'm using the latest kernel (5.7.2). It has happened again with another kernel versions. I 've tried clean build but I get the same error. The driver works normally though. Any ideas? Nebulosa commented on 2020-06-12 22:03 (UTC) (edited on 2020-06-12 22:03 (UTC) by Nebulosa) Thanks for quick respond! I've changed the lines: makedepends=("nvidia-340xx-utils=${pkgver}" 'linux-ck-atom>=5.5' 'linux-ck-atom-headers>=5.5') and _kernelname=linux-ck-atom and it updated without errors. IsaakAleksandrov commented on 2020-06-12 16:16 (UTC) (edited on 2020-06-12 18:48 (UTC) by IsaakAleksandrov) @Nebulosa Just change the _kernelname=linux line to: _kernelname=linux-ck-atom That should do the trick. Edit: I really should think before I write... Remove 'linux>=5.5' 'linux-headers>=5.5' in makedepends as well, or change to linux-ck-atom. Nebulosa commented on 2020-06-12 13:57 (UTC) I use linux-ck-atom package, not the linux package. Unfortunately it want the linux package for installing or update. How can I change PKBUILD? Ref: Tech1 commented on 2020-05-30 01:05 (UTC) Ok. Thanks! Will give it a try. IsaakAleksandrov commented on 2020-05-30 00:42 (UTC) @Tech1 First, note that if you're going to use this package and not the nvidia-340xx-lts package, then you'll need to use the resulting -dkms package, and will also need to have the linux-lts-headers system package installed. For the error, upgrade your GCC package. The kernel's been built by a different GCC version. Run pacman -Syyu, then try and build the package again. Tech1 commented on 2020-05-30 00:18 (UTC) Appreciate your hard work in producing these packages. I have extremely slow performance with my older NVIDIA card - GeForce 8200M G. Have great hopes that this might really speed things up! Unfortunately I got an error during the makepkg for nvidia-340xx 340.108-7 This is the error message:... [me@hplaptop nvidia-340xx]$ I am using the most current linux-lts kernel (just released yesterday 5/28). uname -a Linux hplaptop 5.4.43-1-lts #1 SMP Wed, 27 May 2020 23:42:34 +0000 x86_64 GNU/Linux I successfully installed these: nvidia-340xx-utils (a dependency to building nvidia-340xx) linux-headers Version 5.6.15.arch1-1 (Required dependency for the makepkg of nvidia- 340xx) More detailed makepkg output: <textarea rows="5 [tech1@hplaptop nvidia-340xx]$ makepkg ==> Making package: nvidia-340xx 340.108-7 (Fri 29 May 2020 02:44:27 PM EDT) ==> Checking runtime dependencies... ==> Checking buildtime dependencies... ==> Retrieving sources... -> Downloading NVIDIA-Linux-x86_64-340.108-no-compat32.run... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 36.9M 100 36.9M 0 0 3570k 0 0:00:10 0:00:10 --:--:-- 3652k -> Found 01-fix_multi_core_build.patch -> Found 02-unfuck-for-340.108-build-fix.patch -> Found 03-unfuck-for-5.5.x.patch -> Found 04-fix_message_in_dmesg.patch -> Found 05-unfuck-for-kernel-5.6.x.patch ==> Validating source files with sha256sums... NVIDIA-Linux-x86_64-340.108-no-compat32.run ... Passed 01-fix_multi_core_build.patch ... Passed 02-unfuck-for-340.108-build-fix.patch ... Passed 03-unfuck-for-5.5.x.patch ... Passed 04-fix_message_in_dmesg.patch ... Passed 05-unfuck-for-kernel-5.6.x.patch ... Passed ==> Extracting sources... ==> Starting prepare()... Creating directory NVIDIA-Linux-x86_64-340.108-no-compat32 Verifying archive integrity... OK Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 340.108........................................................................................................................................................................................................... patching file dkms.conf patching file uvm/nvidia_uvm_lite.c patching file uvm/Makefile patching file nv.c patching file nv-linux.h patching file Makefile patching file conftest.sh patching file nv-drm.c patching file nv-linux.h patching file nv-procfs.c patching file nv-time.h ==> Starting build()... NVIDIA: calling KBUILD... make[1]: Entering directory '/usr/lib/modules/5.6.15-arch1=/home/paul/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel \ single-build= \ need-builtin=1 need-modorder=1 cc -Wp,-MD,/home/paul/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/.nv.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0error=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -DCONFIG_AS_ADX=1 --param=allow-store-data-races=0 -fplugin=./scripts/gcc-plugins/structleak_plugin.so -fplugin-arg-structleak_plugin-byref-all -DSTRUCTLEAK_PLUGIN -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fno-var-tracking-assignments -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -fcf-protection=none -Wno-packed-not-aligned -DNV_MODULE_INSTANCE=0 -DNV_BUILD_MODULE_INSTANCES=0 -UDEBUG -U_DEBUG -DNDEBUG -I/home/tech1"' -c -o /home/paul/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/nv.o /home/paul/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel/nv.c... [tech1@hplaptop nvidia-340xx]$ </textarea> I noticed there were AUR builds for nvidia-340xx-lts and nvidia-340xx-lts-dkms and others with 'lts' included in the package name. Would any of these be useful here? In the comments I noticed references to broken builds and waiting on patches for nvidia-340xx-lts 340.108-2. Another thought was the linux-headers. Wondering if version 5.6.15 might be too new. Any ideas? Thank you! laggykiller commented on 2020-04-12 04:11 (UTC) @osvxos Problem solved! The directory that contains 'nvidia-340xx' has blank space, this explains why the directory looks funny. Solved by renaming directories such that they don't contain blank space. Thank you! osvcos commented on 2020-04-11 21:31 (UTC) (edited on 2020-04-11 21:32 (UTC) by osvcos) @laggykiller - How are you building the package? (makepkg/chroot/aur helper) According to the logs you provided, you seem to be building in the "nvidia-340xx" directory inside your home directory, but this line make[1]: *** No rule to make target 'Nvidia/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel'. Stop. indicates that there is a "Nvidia" directory preceding "nvidia-340xx". The error is because the Makefile in the kernel sources cannot switch back to 'Nvidia/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel' because it is a relative directory. It should be something like '/home/user/nvidia-340xx/src/NVIDIA-Linux-x86_64-340.108-no-compat32/kernel'. laggykiller commented on 2020-04-11 18:21 (UTC) (edited on 2020-04-11 19:07 (UTC) by laggykiller) ~/nvidia-340xx/nvidia-340xx-340.108-7-x86_64-build.log ~/nvidia-340xx/nvidia-340xx-340.108-7-x86_64-prepare.log Also, not sure if related, but installing driver from nvidia ( does not work in linux kernel 5.6.3.arch1-1 as well. The driver installed and ran without any problem in linux kernel 5.5.13-arch2-1. Here is the log file from /var/log/nvidia-installer.log osvcos commented on 2020-04-10 21:43 (UTC) @laggykiller - Builds well here. What is the error? laggykiller commented on 2020-04-10 20:40 (UTC) Does not work on linux 5.6.3.arch1-1 kernel even with the latest patch provided. graysky commented on 2020-04-07 13:21 (UTC) @osvcos - Thanks for the patch! osvcos commented on 2020-04-07 05:30 (UTC) @VijayPleo - Place the patch in the same directory than the PKGBUILD. Then with a text editor edit the PKGBUILD source array: source=(" 01-fix_multi_core_build.patch 02-unfuck-for-340.108-build-fix.patch 03-unfuck-for-5.5.x.patch 04-fix_message_in_dmesg.patch kernel-5.6.patch ) and then in the sha256sum array: sha256sums=('995d44fef587ff5284497a47a95d71adbee0c13020d615e940ac928f180f5b77' '82d14e9e6ec47c345d225d9f398238b7254cd5ae581c70e8521b9157ec747890' '2b7e3ef24846a40f4492e749be946e4f7f70ebed054bc2c9079f6cbdcbfabe57' 'c28d65854dd03e6a9e00d79fa0ca3521c11b2c198882bbd50870c8e71d18d765' '7f90e80be6338f6fc902d257d8ceb09e89b40d008f7a3ad9fe82833cd5b89316' 'SKIP') then save the file and run makepkg VijayPleo commented on 2020-04-07 05:01 (UTC) (edited on 2020-04-07 05:10 (UTC) by VijayPleo) @osvcos - How to apply the fix specified in this ? Sorry I am a newbie to arch I am also getting the error in kernel 5.6.2 arch 1-2 osvcos commented on 2020-04-07 00:14 (UTC) Hello everyone, here is a patch: Manjaro was the first one as far as I know ( to release a patch, but: - It fixes things we fixed before - It modifies more files than this patch - This patch uses tests (conftest) instead of relying on kernel version hackins commented on 2020-04-06 21:53 (UTC) (edited on 2020-04-06 21:59 (UTC) by hackins) Can’t make to work this package on linux 5.6.2-arch1-2 anyone know what to fix? Makepkg finishes with “**** error: implicit declaration of function •drm_pci_exit•; did you mean •drm_dev_exit•? [-Werror=implicit-function-declaration] Some warnings being treated as errors ****” wurbelgrumpff commented on 2020-03-22 22:41 (UTC) with upgrading to kernel 5.5.10-arch1-1 dkms also failed due to the gcc version mismatch. With the altered command from @osvcos sudo env IGNORE_CC_MISMATCH=1 dkms install -m nvidia -v 340.108 -k 5.5.10-arch1-1 the upgrade of kernel and nvidia worked fine again. graysky commented on 2020-03-19 13:20 (UTC) vova7890 commented on 2020-03-19 10:34 (UTC) (edited on 2020-03-19 10:36 (UTC) by vova7890) That simply adds SLAB_USERCOPY flag to kmem_cache_create, that come from some kernel version. You can see that in 390xx kernel module ` nv_memdbg_init(); /* Allocated memory that is used for copying to/from userspace should be * tagged as such, on kernels that support this feature. */ nvidia_stack_t_cache = NV_KMEM_CACHE_CREATE_USERCOPY(nvidia_stack_cache_name, nvidia_stack_t); if (nvidia_stack_t_cache == NULL) { nv_printf(NV_DBG_ERRORS, "NVRM: stack cache allocation failed!\n"); rc = -ENOMEM; goto failed6; } rc = nv_kmem_cache_alloc_stack(&sp); ` And i had tested this on nvidia 210 gpu, work fine. graysky commented on 2020-03-19 08:50 (UTC) (edited on 2020-03-19 08:56 (UTC) by graysky) I have no hardware myself for testing. Does the error in dmesg also cause breakage or is it just a harmless line in dmesg? Can you post a link or two from your searching? Can you verify there are no ill-effects of that patch? vova7890 commented on 2020-03-19 01:01 (UTC) I'm facing this message in dmesg: Bad or missing usercopy whitelist? Kernel memory exposure attempt detected from SLUB object 'nvidia_stack_t' A little search and I had portback this patch to 340xx. Can you please add this? osvcos commented on 2020-03-16 20:51 (UTC) @holyArch As graysky wrote, this is probaly due to the gcc version mismatch. Try with: sudo env IGNORE_CC_MISMATCH=1 dkms install -m nvidia -v 340.108 -k 5.5.9-arch1-2 holyArch commented on 2020-03-16 20:40 (UTC) (edited on 2020-03-17 17:00 (UTC) by holyArch) @graysky The mirrors I use are all listed under Successfully Syncing Mirrors, so that's not the issue. Edit: Thank you, osvcos, the command words (after upgrading kernel). graysky commented on 2020-03-16 19:57 (UTC) Is your mirror out of sync? You need the new toolkit that was used to build the kernel. holyArch commented on 2020-03-16 19:01 (UTC) @graysky DKMS make.log for nvidia-340.108 for kernel 5.5.9-arch1-2 (x86_64) gcc-version-check failed: The compiler used to compile the kernel (gcc 9.2) does not exactly match the current compiler (gcc 9.3).] Error 1 make: Entering directory '/var/lib/dkms/nvidia/340.108/build/uvm' cd ./..; make module SYSSRC=/lib/modules/5.5.9-arch1-2/build SYSOUT=/lib/modules/5.5.9-arch1-2/build KBUILD_EXTMOD=./.. make[1]: Entering directory '/var/lib/dkms/nvidia/340.108/build' NVIDIA: calling KBUILD... make[2]: Entering directory '/usr/lib/modules/5.5.9-arch1:42: ../Makefile: No such file or directory make[3]: No rule to make target '../Makefile'. Stop. make[2]: [Makefile:1693: ..] Error 2 make[2]: Leaving directory '/usr/lib/modules/5.5.9-arch1-2/build' NVIDIA: left KBUILD. nvidia.ko failed to build! make[1]: [Makefile:197: nvidia.ko] Error 1 make[1]: Leaving directory '/var/lib/dkms/nvidia/340.108/build' make: *** [Makefile:222: ../Module.symvers] Error 2 make: Leaving directory '/var/lib/dkms/nvidia/340.108/build/uvm' graysky commented on 2020-03-14 22:23 (UTC) (edited on 2020-03-14 22:25 (UTC) by graysky) @holyArch - Builds fine for me in a clean chroot. Not sure what to tell you. And please do not flag out of date because you ran into a build error. It's out of date when upstream releases something new. holyArch commented on 2020-03-14 21:36 (UTC) (edited on 2020-03-14 21:41 (UTC) by holyArch) ==> dkms install nvidia/340.108 -k 5.5.9-arch1-2 Error! Bad return status for module build on kernel: 5.5.9-arch1-2 (x86_64) Consult /var/lib/dkms/nvidia/340.108/build/make.log for more information. After that, I downgraded gcc, gcc-libs, linux, linux-headers. nmruser commented on 2020-03-11 22:34 (UTC) Thanks everyone, after upgrading to kernel 5.5.8 and the drivers work again without any change, I believe xfce4 etc were also upgraded meanwhile. pissbrain commented on 2020-03-07 21:46 (UTC) @wurbelgrumpff I use xfce4 and it doesn't freeze. sint commented on 2020-03-07 16:20 (UTC) I upgraded to current 5.5.8. With kde all work fine. wurbelgrumpff commented on 2020-03-07 00:22 (UTC) Sorry for this question, but is it meanwhile sure to update to actual kernel with xfce4 as desktop or does it freeze again, like @nmruser described? Any experiences about it? pissbrain commented on 2020-03-06 20:47 (UTC) I just upgraded to kernel 5.5.8 and the drivers still work =P. graysky commented on 2020-03-06 20:44 (UTC) @nmruser - I do not have hardware that uses these drivers for testing. I can only confirm that I am able to build the module against 5.5.8 in a build root. pissbrain commented on 2020-03-06 17:50 (UTC) @Viterzgir Nah, nouveau is slow and unreliable. Kernel patches are all the support these drivers need. Viterzgir commented on 2020-03-06 14:02 (UTC) Nvidia drop support nvidia-340xx. Just replace with nouveau driver. nmruser commented on 2020-03-04 04:22 (UTC) After the latest upgrade today to kernel 5.5.7, I could not startxfce4. The system freezes completely. A clean rebuild does not seem to solve the problem. Everything seems fine but X-server. Any comment? johnhamelink commented on 2020-02-06 10:03 (UTC) NB: I had to cleanbuild to ensure that the correctly compiled module was being installed by DKMS, otherwise I was getting the same error as before. All working now :) graysky commented on 2020-02-05 00:10 (UTC) Got it, thanks. osvcos commented on 2020-02-04 22:12 (UTC) The first patch for 340.108 is missing. This is the file: graysky commented on 2020-02-04 21:37 (UTC) Oops, I bumped too soon: graysky commented on 2020-02-04 21:36 (UTC) @osvcos - Thanks as usual! osvcos commented on 2020-02-04 16:10 (UTC) Hi, this fixes the build: johnhamelink commented on 2020-02-04 10:42 (UTC) (edited on 2020-02-04 11:21 (UTC) by johnhamelink) While trying to upgrade this package after upgrading to 5.5.1-arch-1, the build fails as follows: I have also been receiving a conflicted dependencies error between nvidia-340xx-utils and nvidia-340xx-dkms (yay wants to upgrade them both at once). I removed nvidia-340xx-utils to try and unstick this, resulting in my current problem. I was able to get a working machine again by: - Disabling the nvidia modules from initcpio.conf - Downgrading the linux and linux-headers packages to 5.4.15-arch1-1: sudo pacman -U /var/cache/pacman/pkg/linux-headers-5.4.15.arch1-1-x86_64.pkg.tar.zst sudo pacman -U /var/cache/pacman/pkg/linux-5.4.15.arch1-1-x86_64.pkg.tar.zst - Adding linux and linux-headers to /etc/pacman.conf’s ignored packages list - Upgrade all dependencies - Reboot - Re-enabling the nvidia modules in initcpio.conf - Re-installing nvidia-340xx-dkms and nvidia-340xx-utils - Reboot I hope this is useful/helpful! graysky commented on 2020-02-03 21:44 (UTC) It is ... my mirror was out-of-sync. Need to identify a patch for 5.5.x ... Osvaldo is working on one but if you know of one out there from another distro please share it. wurbelgrumpff commented on 2020-02-03 21:30 (UTC) Thanks for the answer, but as far as I never use any [testing] I'm sure that 5.5.x is in [core] now. graysky commented on 2020-02-03 21:04 (UTC) (edited on 2020-02-03 21:04 (UTC) by graysky) When 5.5.x goes into [core] as there is no [testing] for the AUR... also, someone will need to point me to a patch for 5.5.x if I cannot find one myself. wurbelgrumpff commented on 2020-02-03 20:42 (UTC) Hi, I've updated to arch Linux 5.5.1, but my graphical Interface will not start yet. Is there any chance to get a 5.5.-patch soon? Thanks a lot in advance! taz-007 commented on 2020-01-28 19:06 (UTC) fwiw, it doesn't build anymore with the 5.5.arch1 kernel. (I haven't had time to try to fix it). willianholtz commented on 2020-01-19 00:12 (UTC) Sorry for the ignorance, but even with the update my 9300M card, it does not accept the drive, it goes out as soon as I enter the system. Is there anything to do? pissbrain commented on 2020-01-17 13:58 (UTC) @Zappo-II the linux package is on version 5.4.12, try updating that first. Zappo-II commented on 2020-01-17 12:27 (UTC) For me latest linux-5.4.3 breaks with 340.108-3 (won't switch to gfx in boot anymore, even after rebuilding and stuff), had to revert to linux-5.4.2... Stupid me or anybody else...??? graysky commented on 2020-01-10 23:37 (UTC) Fixed, thanks. wurbelgrumpff commented on 2020-01-10 22:55 (UTC) (edited on 2020-01-10 23:45 (UTC) by wurbelgrumpff) Ok, now it works fine! Thank you very much for your fast response! Hello, I can't update, I think, the checksum (sha256sums) is invalid. -> NVIDIA-Linux-x86_64-340.108-no-compat32.run gefunden -> unfuck-340.108-build-fix.patch gefunden -> fix_multi_core_build.patch gefunden ==> FEHLER: Integritäts-Prüfungen (sha256) unterscheiden sich in der Größe vom Array der Quelle. :: Unable to build nvidia-340xx-dkms - makepkg exited with code: 1 Can you help please? (I think, the "Fehler" means: Integrity-Check differs in size of the Array of the source). So I have uninstalled the former Driver version and now..... pissbrain commented on 2019-12-26 15:34 (UTC) For those who can't update due to broken dependency complaints, just remove the currently installed versions and then update. graysky commented on 2019-12-25 11:30 (UTC) @osvcos - Thanks, just what we needed. All 3 packages bumped. osvcos commented on 2019-12-25 05:21 (UTC) Hi, with this patch 340.108 builds on kernels 5.4.6 and 4.19.91 graysky commented on 2019-12-24 12:27 (UTC) Cannot update until someone identifies a patch/patches to fix broken builds. leejnk commented on 2019-12-24 02:55 (UTC) (edited on 2019-12-24 02:56 (UTC) by leejnk) poluyan commented on 2019-12-03 13:30 (UTC) piotro, thank you! It worked for me. I only removed any '....-old or -new/' prefix from it. piotro commented on 2019-12-03 09:55 (UTC) If anybody is interested: patch for 5.4 kernel. All kudos to Alberto Milone pls! newbthenewbd commented on 2019-12-03 01:15 (UTC) Linux 5.4 just hit the core, patch much pl0x? With that release, I think that it might also be a good idea to limit the maximum linux version supported by the package, as it seems that a new major kernel revision is much more likely to break it than not, and that'd provide some notice to the poor nightly updaters. Per it seems that it is possible like this: makedepends=("nvidia-340xx-utils=${pkgver}" 'linux>=5.3.6' 'linux<5.4.0' 'linux-headers>=5.3.6' 'linux-headers<5.4.0') Except, of course, for the version ought to support 5.4 the values will have to be different. :) Thank You! leejnk commented on 2019-11-27 01:50 (UTC) @graysky thanks fro the update. will wait. graysky commented on 2019-11-26 18:53 (UTC) @leejnk - When linux-5.4 hits [core]... currently 5.3.x is in [core]. leejnk commented on 2019-11-26 10:22 (UTC) Please add support for 5.4 kernel linuxyz commented on 2019-11-19 22:20 (UTC) I can't build this: "NVIDIA: calling KBUILD... make[1]: /usr/src/linux: No such file or directory. Stop. NVIDIA: left KBUILD. nvidia.ko failed to build! make: [Makefile:192: nvidia.ko] Error 1 ==> ERROR: A failure occurred in build(). Aborting... " (I'm on kernel 5.3.11 by the way) piotro commented on 2019-10-28 17:30 (UTC) Guys - is anybody working on 340 compilation on 5.4 kernel? graysky commented on 2019-10-13 11:14 (UTC) (edited on 2019-10-13 11:15 (UTC) by graysky) I have a working PKGBUILD. I will push it once linux-5.3.6-1 comes out of [testing] due to the obvious incompatibility with previous versions. JerryXiao commented on 2019-10-13 02:45 (UTC) @graysky Use dkms or rebuild the package every time you upgrade your kernel. If you would like to bump pkgrel every time kernel updates, I can give you co-maintainer. graysky commented on 2019-10-12 10:49 (UTC) @JerryXiao - You'll need to modify this per kernel package changes. Changes to kernel: See nvidia-390xx as a model: kiffmet commented on 2019-10-08 20:18 (UTC) (edited on 2019-10-08 20:22 (UTC) by kiffmet) Hey can you please add this patch? It fixes the usercopy error in dmesg. Original source: 1802622 yigitdnz commented on 2019-10-07 15:34 (UTC) @osvcos Thank you. It worked. osvcos commented on 2019-10-07 11:55 (UTC) @yigitdnz Try with sudo env IGNORE_CC_MISMATCH=1 dkms install -m nvidia -v 340.107 -k 4.19.77-1-lts yigitdnz commented on 2019-10-06 21:20 (UTC) (edited on 2019-10-06 21:20 (UTC) by yigitdnz) And upgrading to kernel 4.19.77-1-lts broke my nvidia. I timeshifted back to kernel 4.19.76-1-lts. I get this when I try to upgrade: "Error! Bad return status for module build on kernel: 4.19.77-1-lts (x86_64) Consult /var/lib/dkms/nvidia/340.107/build/make.log for more information." make.log file: leopseft commented on 2019-10-06 12:43 (UTC) Upgrading to the latest kernel 5.3.4 broke my nvidia and I had no graphics. Downgrading to the previous one 5.3.1 got error for gcc-version-check failed. Intalling the latest kernel again and removing the nvidia package and reinstalling it again triggerd the dkms hook with no error that time. Really strange. JerryXiao commented on 2019-10-06 05:38 (UTC) @taro_kun You currently have nvidia-340xx-dkms 340.107-90 installed, upgrade to 340.107-91 taro_kun commented on 2019-10-06 02:10 (UTC) (edited on 2019-10-06 02:19 (UTC) by taro_kun) Package won't build for me on 5.3.1 kernel. Not sure if it just needs an update or if the problem is on my end. Here's the log: DavidK commented on 2019-09-19 21:22 (UTC) Needs updated patches for 5.3 kernel, won't compile as is. willianholtz commented on 2019-08-24 15:36 (UTC) if it helps, i have my dmesg with errors. leopseft commented on 2019-08-09 17:35 (UTC) Hello to everyone, im getting this error while compiling: "ERROR: Kernel configuration is invalid."; \ echo >&2 " include/generated/autoconf.h or include/config/auto.conf are missing.";\ echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \ " Should I deal with it, or just ignore it? Thanks!! JerryXiao commented on 2019-07-17 16:25 (UTC) @papakilo You should always rebuild the package on kernel upgrade including minor updates if you're not using dkms. papakilo commented on 2019-07-17 16:08 (UTC) Hi, is there a kernel-5.2.patch? Because driver does NOT work with kernel 5.2 or 5.2.1 causing my computer to stuck on boot message "Started TLP system startup/shutdown"... sacarde commented on 2019-07-01 18:34 (UTC) @JerryXiao , if I use xf86-video-nouveaux some time it freezes system, so I am forced to disinstall xf86-video-nouveaux and use nouveau kernel module (without acceleration) thanks JerryXiao commented on 2019-07-01 17:27 (UTC) (edited on 2019-07-01 17:28 (UTC) by JerryXiao) @sacarde no, use nouveau instead. sacarde commented on 2019-07-01 14:32 (UTC) is this module right for an old: [GeForce 6150SE nForce 430] ? Xezlec commented on 2019-06-23 16:05 (UTC) (edited on 2019-06-23 16:08 (UTC) by Xezlec) I had to do this to get OpenGL to work: sudo mv /usr/lib/xorg/modules/extensions/libglx.so{,.old} sudo ln -s /usr/lib/nvidia/xorg/libglx.so.340.107 /usr/lib/xorg/modules/extensions/libglx.so For more details, see JerryXiao commented on 2019-06-20 05:24 (UTC) It seems that you are using some sort of script to keep old modules during kernel upgrade. Reboot the system and you should be fine. tombusby commented on 2019-06-19 20:44 (UTC) (edited on 2019-06-19 20:44 (UTC) by tombusby) Getting the following error: ==> Making package: nvidia-340xx 340.107-90 (Wed 19 Jun 2019 22:40:54 CEST) ==> Checking runtime dependencies... ==> Checking buildtime dependencies... ==> Retrieving sources... -> Downloading NVIDIA-Linux-x86_64-340.107-no-compat32.run... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 36.9M 100 36.9M 0 0 75.6M 0 --:--:-- --:--:-- --:--:-- 75.4M -> Found kernel-4.11.patch -> Found kernel-5.0.patch -> Found kernel-5.1.patch ==> Validating source files with sha512sums... NVIDIA-Linux-x86_64-340.107-no-compat32.run ... Passed kernel-4.11.patch ... Passed kernel-5.0.patch ... Passed kernel-5.1.patch ... Passed ==> Extracting sources... ==> Starting prepare()... Creating directory NVIDIA-Linux-x86_64-340.107-no-compat32 Verifying archive integrity... OK Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 340.107............................................> patching file kernel/uvm/nvidia_uvm_lite.c patching file kernel/nv-drm.c patching file kernel/os-interface.c patching file kernel/uvm/nvidia_uvm_lite.c patching file kernel/uvm/nvidia_uvm_lite.c patching file kernel/nv-drm.c ==> Starting build()... NVIDIA: calling KBUILD... make[1]: Entering directory '/usr/lib/modules/5.1.9-arch1-1-ARCH/build' make[1]: *** No rule to make target 'modules'. Stop. make[1]: Leaving directory '/usr/lib/modules/5.1.9-arch1-1-ARCH/build' NVIDIA: left KBUILD. nvidia.ko failed to build! make: *** [Makefile:192: nvidia.ko] Error 1 ==> ERROR: A failure occurred in build(). Aborting... Pinned Comments taz-007 commented on 2021-11-10 15:56 (UTC) Users of this package should block automatic update of their kernel. There is not enough man power to update it as fast as newer kernels are released.
https://aur.archlinux.org/packages/nvidia-340xx-dkms
CC-MAIN-2022-21
refinedweb
24,629
59.7
💻 Never leave your terminal for secrets 📟 Create easy and clean workflows for working with cloud environments 🔎 Scan for secrets and fight secret sprawl Teller – the open-source universal secret manager for developers). You can use Teller to tidy your own environment or for your team as a process and best practice. Quick Start with teller (or tlr) You can install teller with homebrew: $ brew tap spectralops/tap && brew install teller You can now use teller or tlr (if you like shortcuts!) in your terminal. teller will pull variables from your various cloud providers, vaults and others, and will populate your current working session (in various ways!, see more below) so you can work safely and much more productively. teller needs a tellerfile. This is a .teller.yml file that lives in your repo, or one that you point teller to with teller -c your-conf.yml. Using a Github Action For those using Github Action, you can have a 1-click experience of installing Teller in your CI: - name: Setup Teller uses: spectralops/[email protected] - name: Run a Teller task (show, scan, run, etc.) run: teller run [args] For more, check our setup teller action on the marketplace. Create your configuration Run teller new and follow the wizard, pick the providers you like and it will generate a .teller.yml for you. Alternatively, you can use the following minimal template or view a full example: project: project_name opts: stage: development # remove if you don't like the prompt confirm: Are you sure you want to run in {{stage}}? providers: # uses environment vars to configure # hashicorp_vault: env_sync: path: secret/data/{{stage}}/services/billing # this will fuse vars with the below .env file # use if you'd like to grab secrets from outside of the project tree dotenv: env_sync: path: ~/billing.env.{{stage}} Now you can just run processes with: $ teller run node src/server.js Service is up. Loaded configuration: Mailgun, SMTP Port: 5050 Behind the scenes: teller fetched the correct variables, placed those (and just those) in ENV for the node process to use. Best practices Go and have a look at a collection of our best practices Features 🏃 Running subprocesses Manually exporting and setting up environment variables for running a process with demo-like / production-like set up? Got bitten by using .env.production and exposing it in the local project itself? Using teller and a .teller.yml file that exposes nothing to the prying eyes, you can work fluently and seamlessly with zero risk, also no need for quotes: $ teller run -- your-process arg1 arg2... --switch1 ... 🔎 Inspecting variables This will output the current variables teller picks up. Only first 2 letters will be shown from each, of course. $ teller show 📺 Local shell population Hardcoding secrets into your shell scripts and dotfiles? In some cases it makes sense to eval variables into your current shell. For example in your .zshrc it makes much more sense to use teller, and not hardcode all those into the .zshrc file itself. In this case, this is what you should add: eval "$(teller sh)" 🐳 Easy Docker environment Tired of grabbing all kinds of variables, setting those up, and worried about these appearing in your shell history as well? Use this one liner from now on: $ docker run --rm -it --env-file <(teller env) alpine sh ⚠️ Scan for secrets Teller can help you fight secret sprawl and hard coded secrets, as well as be the best productivity tool for working with your vault. It can also integrate into your CI and serve as a shift-left security tool for your DevSecOps pipeline. Look for your vault-kept secrets in your code by running: $ teller scan You can run it as a linter in your CI like so: run: teller scan --silent It will break your build if it finds something (returns exit code 1). Use Teller for productively and securely running your processes and you get this for free — nothing to configure. If you have data that you’re bringing that you’re sure isn’t sensitive, flag it in your teller.yml: dotenv: env: FOO: path: ~/my-dot-env.env severity: none # will skip scanning. possible values: high | medium | low | none By default we treat all entries as sensitive, with value high. ♻️ Redact secrets from process outputs, logs, and files You can use teller as a redaction tool across your infrastructure, and run processes while redacting their output as well as clean up logs and live tails of logs. Run a process and redact its output in real time: $ teller run --redact -- your-process arg1 arg2 Pipe any process output, tail or logs into teller to redact those, live: $ cat some.log | teller redact It should also work with tail -f: $ tail -f /var/log/apache.log | teller redact Finally, if you’ve got some files you want to redact, you can do that too: $ teller redact --in dirty.csv --out clean.csv If you omit --in Teller will take stdin, and if you omit --out Teller will output to stdout. 🪲 Detect secrets and value drift You can detect secret drift by comparing values from different providers against each other. It might be that you want to pin a set of keys in different providers to always be the same value; when they aren’t — that means you have a drift. In most cases, keys in providers would be similar which we call mirrored providers. Example: Provider1: MG_PASS=foo*** Provider2: MG_PASS=foo*** # Both keys are called MG_PASS To detected mirror drifts, we use teller mirror-drift. $ teller mirror-drift --source global-dotenv --target my-dotenv Drifts detected: 2 changed [] global-dotenv FOO_BAR "n***** != my-dotenv FOO_BAR ne***** missing [] global-dotenv FB 3***** ?? Use mirror-drift --sync ... in order to declare that the two providers should represent a completely synchronized mirror (all keys, all values). As always, the specific provider definitions are in your teller.yml file. 🪲 Detect secrets and value drift (graph links between providers) Some times you want to check drift between two providers, and two unrelated keys. For example: Provider1: MG_PASS=foo*** Provider2: MAILGUN_PASS=foo*** This poses a challenge. We need some way to “wire” the keys MG_PASS and MAILGUN_PASS and declare a relationship of source ( MG_PASS) and destination, or sink ( MAILGUN_PASS). For this, you can label mappings as source and couple with the appropriate sink as sink, effectively creating a graph of wirings. We call this graph-drift (use same label value for both to wire them together). Then, source values will be compared against sink values in your configuration: providers: dotenv: env_sync: path: ~/my-dot-env.env source: s1 dotenv2: kind: dotenv env_sync: path: ~/other-dot-env.env sink: s1 And run $ teller graph-drift dotenv dotenv2 -c your-config.yml 📜 Populate templates Have a kickstarter project you want to populate quickly with some variables (not secrets though!)? Have a production project that just has to have a file to read that contains your variables? You can use teller to inject variables into your own templates (based on go templates). With this template: Hello, {{.Teller.EnvByKey "FOO_BAR" "default-value" }}! Run: $ teller template my-template.tmpl out.txt Will get you, assuming FOO_BAR=Spock: Hello, Spock! 🔄 Copy/sync data between providers In cases where you want to sync between providers, you can do that with teller copy. Specific mapping key sync $ teller copy --from dotenv1 --to dotenv2,heroku1 This will: - Grab all mapped values from source ( dotenv1) - For each target provider, find the matching mapped key, and copy the value from source into it Full copy sync $ teller copy --sync --from dotenv1 --to dotenv2,heroku1 This will: - Grab all mapped values from source ( dotenv1) - For each target provider, perform a full copy of values from source into the mapped env_synckey Notes: - The mapping per provider is as configured in your teller.yamlfile, in the env_syncor envproperties. - This sync will try to copy all values from the source. 🚲 Write and multi-write to providers Teller providers supporting write use cases which allow writing values into providers. Remember, for this feature it still revolves around definitions in your teller.yml file: $ teller put FOO_BAR=$MY_NEW_PASS --providers dotenv -c .teller.write.yml A few notes: - Values are key-value pair in the format: key=valueand you can specify multiple pairs at once - When you’re specifying a literal sensitive value, make sure to use an ENV variable so that nothing sensitive is recorded in your history - The flag --providerslets you push to one or more providers at once FOO_BARmust be a mapped key in your configuration for each provider you want to update Sometimes you don’t have a mapped key in your configuration file and want to perform an ad-hoc write, you can do that with --path: $ teller put SMTP_PASS=newpass --path secret/data/foo --providers hashicorp_vault A few notes: - The pair SMTP_PASS=newpasswill be pushed to the specified path - While you can push to multiple providers, please make sure the path semantics are the same ✅ Prompts and options There are a few options that you can use: carry_env – carry the environment from the parent process into the child process. By default we isolate the child process from the parent process. (default: false) confirm – an interactive question to prompt the user before taking action (such as running a process). (default: empty) opts – a dict for our own variable/setting substitution mechanism. For example: opts: region: env:AWS_REGION stage: qa And now you can use paths like /{{stage}}/{{region}}/billing-svc where ever you want (this templating is available for the confirm question too). If you prefix a value with env: it will get pulled from your current environment. YAML Export in YAML format You can export in a YAML format, suitable for GCloud: $ teller yaml Example format: FOO: "1" KEY: VALUE JSON Export in JSON format You can export in a JSON format, suitable for piping through jq or other workflows: $ teller json Example format: { "FOO": "1" } Providers For each provider, there are a few points to understand: - Sync – full sync support. Can we provide a path to a whole environment and have it synced (all keys, all values). Some of the providers support this and some don’t. - Key format – some of the providers expect a path-like key, some env-var like, and some don’t care. We’ll specify for each. General provider configuration We use the following general structure to specify sync mapping for all providers: # you can use either `env_sync` or `env` or both env_sync: path: ... # path to mapping remap: PROVIDER_VAR1: VAR3 # Maps PROVIDER_VAR1 to local env var VAR3 env: VAR1: path: ... # path to value or mapping field: <key> # optional: use if path contains a k/v dict decrypt: true | false # optional: use if provider supports encryption at the value side severity: high | medium | low | none # optional: used for secret scanning, default is high. 'none' means not a secret redact_with: "**XXX**" # optional: used as a placeholder swapping the secret with it. default is "**REDACTED**" VAR2: path: ... Remapping Provider Variables Providers which support syncing a list of keys and values can be remapped to different environment variable keys. Typically, when teller syncs paths from env_sync, the key returned from the provider is directly mapped to the environment variable key. In some cases it might be necessary to have the provider key mapped to a different variable without changing the provider settings. This can be useful when using env_sync for Hashicorp Vault Dynamic Database credentials: env_sync: path: database/roles/my-role remap: username: PGUSER password: PGPASSWORD After remapping, the local environment variable PGUSER will contain the provider value for username and PGPASSWORD will contain the provider value for Hashicorp Vault Authentication If you have the Vault CLI configured and working, there’s no special action to take. Configuration is environment based, as defined by client standard. See variables here. Features - Sync – yes - Mapping – yes - Modes – read+write - Key format – path based, usually starts with secret/data/, and more generically [engine name]/data Example Config hashicorp_vault: env_sync: path: secret/data/demo/billing/web/env env: SMTP_PASS: path: secret/data/demo/wordpress field: smtp Consul Authentication If you have the Consul CLI consul: env_sync: path: ops/config env: SLACK_HOOK: path: ops/config/slack Heroku Authentication Requires an API key populated in your environment in: HEROKU_API_KEY (you can fetch it from your ~/.netrc). Generate new token with Heroku cli: heroku authorizations:create then use the TOKEN value. Features - Sync – yes - Mapping – yes - Modes – read+write - Key format env_sync– name of your Heroku app env– the actual env variable name in your Heroku settings Example Config heroku: env_sync: path: my-app-dev env: MG_KEY: path: my-app-dev Etcd Authentication If you have etcdctl already working there’s no special action to take. We follow how etcdctl takes its authentication settings. These environment variables need to be populated ETCDCTL_ENDPOINTS For TLS: ETCDCTL_CA_FILE ETCDCTL_CERT_FILE ETCDCTL_KEY_FILE Features - Sync – yes - Mapping – yes - Modes – read+write - Key format env_sync– path based env– path based Example Config etcd: env_sync: path: /prod/billing-svc env: MG_KEY: path: /prod/billing-svc/vars/mg AWS Secrets Manager Authentication Your standard AWS_DEFAULT_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY need to be populated in your environment Features - Sync – yes - Mapping – yes - Modes – read+write - Key format env_sync– path based env– path based Example Config aws_secretsmanager: env_sync: path: /prod/billing-svc env: MG_KEY: path: /prod/billing-svc/vars/mg AWS Paramstore Authentication Your standard AWS_DEFAULT_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY need to be populated in your environment Features - Sync – no - Mapping – yes - Modes – read, write: accepting PR - Key format env– path based decrypt– available in this provider, will use KMS automatically Example Config aws_ssm: env: FOO_BAR: path: /prod/billing-svc/vars decrypt: true Google Secret Manager Authentication You should populate GOOGLE_APPLICATION_CREDENTIALS=account.json in your environment to your relevant account.json that you get from Google. Features - Sync – no - Mapping – yes - Modes – read, write: accepting PR - Key format env– path based, needs to include a version decrypt– available in this provider, will use KMS automatically Example Config google_secretmanager: env: MG_KEY: # need to supply the relevant version (versions/1) path: projects/44882/secrets/MG_KEY/versions/1 .ENV (dotenv) Authentication No need. You’ll be pointing to a one or more .env files on your disk. Features - Sync – yes - Mapping – yes - Modes – read+write - Key format env– env key like Example Config You can mix and match any number of files, sitting anywhere on your drive. dotenv: env_sync: path: ~/my-dot-env.env env: MG_KEY: path: ~/my-dot-env.env Doppler Authentication Install the doppler cli then run doppler login. You’ll also need to configure your desired “project” for any given directory using doppler configure. Alternatively, you can set a global project by running doppler configure set project <my-project> from your home directory. Features - Sync – yes - Mapping – yes - Modes – read - Key format env– env key like Example Config doppler: env_sync: path: prd env: MG_KEY: path: prd field: OTHER_MG_KEY # (optional) Vercel Authentication Requires an API key populated in your environment in: VERCEL_TOKEN. Features - Sync – yes - Mapping – yes - Modes – read, write: accepting PR - Key format env_sync– name of your Vercel app env– the actual env variable name in your Vercel settings Example Config vercel: env_sync: path: my-app-dev env: MG_KEY: path: my-app-dev CyberArk Conjur Authentication Requires a username and API key populated in your environment: CONJUR_AUTHN_LOGIN CONJUR_AUTHN_API_KEY Requires a .conjurrc file in your User’s home directory: --- account: conjurdemo plugins: [] appliance_url: cert_file: "" accountis the organization account created during initial deployment pluginswill be blank appliance_urlshould be the Base URI for the Conjur service cert_fileshould be the public key certificate if running in self-signed mode Features - Sync – nosync: accepting PR - Mapping – yes - Modes – read+write - Key format env_sync– not supported to comply with least-privilege model env– the secret variable path in Conjur Secrets Manager Example Config cyberark_conjur: env: DB_USERNAME: path: /secrets/prod/pgsql/username DB_PASSWORD: path: /secrets/prod/pgsql/password Cloudflare Workers KV Authentication requires the following environment variables to be set: CLOUDFLARE_API_KEY: Your Cloudflare api key. CLOUDFLARE_API_EMAIL: Your email associated with the api key. CLOUDFLARE_ACCOUNT_ID: Your account ID. Features - Sync – yes - Mapping – yes - Modes – read(write coming soon) - Key format env_sync– The KV namespace ID field– the actual key stored in the KV store env– the actual key stored in the KV store Example Config opts: kv-namespace-id: <YOUR NAMESPACE ID> providers: cloudflare_workers_kv: env_sync: path: "{{kv-namespace-id}}" remap: # looks up the key `test_key` and maps it to `TEST`. test_key: TEST env: SOME_SECRET: path: "{{kv-namespace-id}}" # Accesses the key `SOME_SECRET` in the KV namespace. REMAPPED_KEY: path: "{{kv-namespace-id}}" # Accesses the field `SOME_KEY` in the KV namespace and maps it to REMAPPED_KEY. field: SOME_KEY 1Password Authentication To integrate with the 1Password API, you should have system-to-system secret management running in your infrastructure/localhost more details here. Requires the following environment variables to be set: OP_CONNECT_HOST – The hostname of the 1Password Connect API OP_CONNECT_TOKEN – The API token to be used to authenticate the client to a 1Password Connect API. Features - Sync – no - Mapping – yes, returns all fields on specific secret item - Modes – read+write - Key format env_sync– Will return all the fields under the secret item. path– Mandatory field: Secret item name. (expected unique secret item with the same name) source– Mandatory field: vaultUUID to query env path– Mandatory field: Secret item name. (expected unique secret item with the same name) source– Mandatory field: vaultUUID to query field– Mandatory field: the specific field name (notesPlain, {custom label name}, password, type etc). Example Config 1password: env_sync: path: security-note source: VAULT-ID env: SECURITY_NOTE_TITLE: path: security-note-title source: VAULT-ID field: lable1 NOTE_SECRET: path: login-title source: VAULT-ID field: password CREDIT_CARD: path: credit-card-title source: VAULT-ID field: type Run Example: Example: OP_CONNECT_HOST=" OP_CONNECT_TOKEN="" teller yaml Gopass Authentication If you have the Gopass gopass: env_sync: path: foo env: SLACK_HOOK: path: path: foo/bar Semantics Addressing - Stores that support key-value interfaces: pathis the direct location of the value, no need for the envkey or field. - Stores that support key-valuemap interfaces: pathis the location of the map, while the envkey or field(if exists) will be used to do the additional final addressing. - For env-sync (fetching value map out of a store), path will be a direct pointer at the key-valuemap Errors - Principle of non-recovery: where possible an error is return when it is not recoverable (nothing to do), but when it is — providers should attempt recovery (e.g. retry API call) - Missing key/value: it’s possible that when trying to fetch value in a provider – it’s missing. This is not an error, rather an indication of a missing entry is returned ( EnvEntry#IsFound) Security Model Project Practices - We vendorour dependencies and push them to the repo. This creates an immutable, independent build, that’s also free from risks of fetching unknown code in CI/release time. Providers For every provider, we are federating all authentication and authorization concern to the system of origin. In other words, if for example you connect to your organization’s Hashicorp Vault, we assume you already have a secure way to do that, which is “blessed” by the organization. In addition, we don’t offer any way to specify connection details to these systems in writing (in configuration files or other), and all connection details, to all providers, should be supplied via environment variables. That allows us to keep two important points: - Don’t undermine the user’s security model and threat modeling for the sake of productivity (security AND productivity CAN be attained) - Don’t encourage the user to do what we’re here for — save secrets and sensitive details from being forgotten in various places. Developer Guide - Quick testing as you code: make lint && make test - Checking your work before PR, run also integration tests: make integration Testing Testing is composed of unit tests and integration tests. Integration tests are based on testcontainers as well as live sandbox APIs (where containers are not available) - Unit tests are a mix of pure and mocks based tests, abstracting each provider’s interface with a custom client - View integration tests To run all unit tests without integration: $ make test To run all unit tests including container-based integration: $ make integration To run all unit tests including container and live API based integration (this is effectively all integration tests): $ make integration_api Running all tests: $ make test $ make integration_api Linting Linting is treated as a form of testing (using golangci, configuration here), to run: $ make lint Thanks: To all Contributors – you make this happen, thanks! Code of conduct Teller follows CNCF Code of Conduct
https://golangexample.com/a-secrets-management-tool-for-developers-built-in-go-2/
CC-MAIN-2022-21
refinedweb
3,429
57.2
On 9 Jan 2008, at 17:20, Emmanuel Lecharny wrote: > Thanks a lot for all those reports ! This help us a lot ! Another thing I encountered when starting to use Studio was that it's not readily apparent for the novice user that the schema editor doesn't actually add schema entries to the LDAP server, one needs to import schemas (eg from openldap files), then export as LDIF, then import the LDIF file for the Directory server in use. This could be documented much better. Should I file a Jira issue for this as well? -- Torgeir Veimo torgeir@pobox.com
http://mail-archives.apache.org/mod_mbox/directory-users/200801.mbox/%3CF83E62ED-4017-4781-9ACC-79E1F6BB48FA@pobox.com%3E
CC-MAIN-2016-22
refinedweb
101
72.16
Installing and Using the Kinect Sensor how to set up your development environment. You may find it easier to follow along by downloading the Kinect for Windows SDK Quickstarts samples and slides that have been updated for Beta 2 (Nov, 2011). The video in the Kinect for Windows SDK has not been updated, but the tutorial below has the following changes: Some samples use DirectX and the Microsoft Speech APIs. For these demos to work, you must download the correct pre-requisite software. Kinect for Windows SDK: Visual Studio: DirectX Samples (for C++ Skeletal Viewer) Speech Samples: For Speech samples: Visual Basic / C# – In the Add Reference dialog, switch to the .NET tab, click the Component Name header to sort references alphabetically, then scroll down to select Microsoft.Research.Kinect and click OK. Make sure to select 1.0.0.45. Within your project, you can now add a using statement to reference the Kinect namespaces: C# using Microsoft.Research.Kinect.Nui; using Microsoft.Research.Kinect.Audio; Visual Basic Imports Microsoft.Research.Kinect.Nui Imports Microsoft.Research.Kinect.Audio Go to and download the latest version of the Coding4Fun Kinect Toolkit. This library is filled with useful items to help with a variety of tasks, such as converting the data from the Kinect to a data array or Bitmap. Depending on if you are building a WPF or Windows Form application, we have two different DLLs: C# // if you're using WPF using Coding4Fun.Kinect.Wpf; // if you're using WinForms using Coding4Fun.Kinect.WinForm; Visual Basic ' if you're using WPF Imports Coding4Fun.Kinect.Wpf ' if you're using WinForms Imports Coding4Fun.Kinect.WinForm For NUI, we have to initialize and uninitialize the runtime. In our examples, we typically will initialize on the Loaded event on the Window and we'll uninitialize on the Closed event. Depending on what needs to be done, the Initialize method on the runtime will be tweaked though the concepts stay the same. Go to the properties window (F4), select the MainWindow, select the Events tab, and double click on the Loaded event to create the Window_Loaded event Create a new Runtime variable named “nui” outside of the Window_Loaded event. When the Window_Loaded event fires, we will call the SetupKinect method that checks to see if there is at least one Kinect plugged in, and if there is, it uses the first Kinect (0 representing the first Kinect) and initializes the Runtime (more details on that later). C# //Kinect Runtime Runtime nui; private void Window_Loaded(object sender, RoutedEventArgs e) { SetupKinect(); } private void SetupKinect() { if (Runtime.Kinects.Count == 0) { this.Title = "No Kinect connected"; } else { //use first Kinect nui = Runtime.Kinects[0]; nui.Initialize(RuntimeOptions.UseColor | RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking); } } Visual Basic 'Kinect Runtime Private nui As Runtime Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs) SetupKinect() AddHandler Runtime.Kinects.StatusChanged, AddressOf Kinects_StatusChanged End Sub Private Sub SetupKinect() If Runtime.Kinects.Count = 0 Then Me.Title = "No Kinect connected" Else 'use first Kinect nui = Runtime.Kinects(0) nui.Initialize(RuntimeOptions.UseColor Or RuntimeOptions.UseDepthAndPlayerIndex Or RuntimeOptions.UseSkeletalTracking) End If End Sub You can see how many Kinects are connected by getting the count of Kinects as shown in the code below. Note that for multiple Kinects, you can only have one Kinect do skeletal tracking at a time (color and depth camera work for all) and each Kinect needs to be in its own USB hub, otherwise it won’t have enough USB bandwidth. C# [code lang=”csharp”] int KinectCount = Runtime.Kinects.Count; [/code] Visual Basic [code lang=”vb”] Dim KinectCount as Integer = Runtime.Kinects.Count [/code] You can also handle events when the status changes for Kinects that are plugged in. To do this, first register for the StatusChanged event as shown below. When this event fires, it returns a KinectStatus enum with the following possible values: Connected, Error, Disconnected, NotReady, or NotPowered. C# [code lang=”csharp”] Runtime.Kinects.StatusChanged += new EventHandler<StatusChangedEventArgs>(Kinects_StatusChanged); … void Kinects_StatusChanged(object sender, StatusChangedEventArgs e) { string message = "Status Changed: "; switch (e.Status) { case KinectStatus.Connected: message += "Connected"; break; case KinectStatus.Disconnected: message += "Disconnected"; break; case KinectStatus.Error: message += "Error"; break; case KinectStatus.NotPowered: message += "Not Powered"; break; case KinectStatus.NotReady: message += "Not Ready"; break; default: if (e.Status.HasFlag(KinectStatus.Error)) { message += "Kinect error"; } break; } this.Title = message; } [/code] Visual Basic [code lang=”vb”] AddHandler Runtime.Kinects.StatusChanged, AddressOf Kinects_StatusChanged … Private Sub Kinects_StatusChanged(sender As Object, e As StatusChangedEventArgs) Dim message As String = "Status Changed: " Select Case e.Status Case KinectStatus.Connected message += "Connected" Exit Select Case KinectStatus.Disconnected message += "Disconnected" Exit Select Case KinectStatus.[Error] message += "Error" Exit Select Case KinectStatus.NotPowered message += "Not Powered" Exit Select Case KinectStatus.NotReady message += "Not Ready" Exit Select Case Else If e.Status.HasFlag(KinectStatus.[Error]) Then message += "Kinect error" End If Exit Select End Select Me.Title = message End Sub [/code] In the Window_Loaded event, initialize the runtime with the options you want to use. For this example, set RuntimeOptions.UseColor to use the RGB camera: C# nui.Initialize(RuntimeOptions.UseColor); Visual Basic nui.Initialize(RuntimeOptions.UseColor) RuntimeOptions is a Flag enumeration, this means you can set multiple options as parameters in the Initialize method by separating them with the pipe "|" character (the "or" operator) in c# or the "Or" operator in Visual Basic. The example below sets the runtime to use the color camera, a depth camera, and skeletal tracking: C# nui.Initialize(RuntimeOptions.UseColor | RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking ); Visual Basic nui.Initialize(RuntimeOptions.UseColor Or RuntimeOptions.UseDepthAndPlayerIndex Or RuntimeOptions.UseSkeletalTracking) Remember that when you are done using the Kinect Runtime, you should call the Uninitialize method. For a WPF application, you would typically do this in the Windows_Closed event: C# nui.Uninitialize(); Visual Basic nui.Uninitialize() Is the Microsoft Kinect Speech Platform not available for download yet or something like that. The link above doesn't seem to actually be a link and it's nowhere on the Kinect SDK pages like the SDK sample says. Just a "stupid question"... where should I put the coding4fun files I extracted from the zip file??? Thanks Does the speech recognition platform work if your system locale and UI language are not US/English? Uninitialize does not stop the IR projector. How can I stop the IR - projector? Thanks Runtime error occurs after adding nui: A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll Additional information: 'The invocation of the constructor on type 'WpfApplication1.MainWindow' that matches the specified binding constraints threw an exception.' @Bas: The Kinect for Windows Runtime Language Pack (version 0.9) is the acoustic model for the Kinect for Windows SDK. That is optimized for using Kinect as a microphone and is English only. You should be able to use another recognizer that supports multiple languages, but it won't be as optimized as the Kinect Runtime language pack. I installed SP1 for VS 2010, restarted my system, created a new solution from scratch and no longer receive this error. Thanks. Hi there, Coding4Fun Kinect Toolkit. Where do i place the Extracted files to bring them up in the reference list? Thankyou in advance @Jiggles : Use the browse option tab in the add reference window to find them! et voila. That's what I did and worked fine! I got an error " Could not load file or assembly 'INuiInstanceHelper.dll' or one of its dependencies. The specified module could not be found." I am attempting a WinForms app, but it did the same, I also tried referencing the dll, and rebuilding - no luck. I got it. Needed SP1, If any errors occur Install SP1 from Just a note for a correction: using Coding4Fun.Kinect.WPF; Where it says WPF, actually Wpf should not be capitalized, it's really: using Coding4Fun.Kinect.Wpf; And don't forget to add the reference to the Coding4Fun .dll, which can be done (after downloading the .dll from codeplex) in the Solution Explorer by right clicking References>Add Reference>Browse. @Tom_Anderson: fixed @Austin: Checked with the kinect team, it is a known issue. Hi, Could you post the tutorial for C/C++? Thanks. J'ai un petit soucis. J'ai fait exactement comme cité en haut mais quand je veut générer, tout est blanc et rien n es'affiche. Pouvez-vous m'aidez s'il vous plait? I have done all the things as the page said, but when I debug the program, it always throw an exception which is said "An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.Research.Kinect.dll Additional information: Failed in native DLL. HRESULT=0x80080014." I don't know why. And I can't run the demo(SkeletalViewer and the ShapeGame) which is contained in the SDK normally, everytime I double click it (with the kinect connected to the computer ) ,the computer must crashed and with no response, if I don't connect the computer with kinect, the demo can run , but with no picture. I really want to know the reason, if I didnt install the SDK correctly or I didnt install the speech recognition correctly or something else ? Hey folks, I am getting this error here when trying to follow this tutorial any help or ideas as to why this may be happening would be very much appreciated! David ... I had the same problem as kAh00t !!!! That was really helpful. thank u so much. Could not find the closed event... why is it not available to me? Found the loaded event no problem. Is there any other language pack for this which is not american version ?? Hi, well I have a problem with this line in c#: if (Runtime.Kinects.Count == 0) { this.Title = "No Kinect connected"; } The word Kinects has problem in the compilation, the problem says: Microsoft.kinect.nui.runtime does not mean contain a definition for Kinects Maybe you can help me Regards can i have 1 of the finished source code and the design of kinect application for my computer..??? you should try making a video we can actually see. Its so distorted, i cant see what is on your screen. *edit* i mean the video streaming, some of these videos for download are 500mb's! i already plug in my kinect device to the laptop. but when i debug the app, it appeared "no kinect connected". what is going on? hmmm.... by the way...forget to mention...the kinect works fine....just those kinect camera and sensor.... This simply doesn't work on a windows 7 64 bit machine. My kinect is plugged into the wall with a working outlet. All of the devices are listed correctly in device manager. my computer understands that there is a kinect device connected. The Kinect API however does not. The static Microsoft.Research.Kinect.Nui.Runtime.Kinects call returns an empty KinectDeviceCollection (count = 0). Only the audio samples work. I do not now nor ever have had any other other kinect api(s) installed on this machine. also using vs2010 sp1 with .net 4.0. Any one have any ideas? Thanks in advance. Angelo Graham, i've no idea too...haha Now, running the risk of asking a really stupid question, what is this code supposed show on screen when a kinect is detected? I mean, when there's no kinect conected, it shows the sentence on the window title, just like it's decribed in the code. However, when the kinect is connected, I get an empty white screen. Is it correct? I had stated previously that "This simply doesn't work on a windows 7 64 bit machine." I have since installed the SDK on a Windows 7 64bit desktop. I can now say it actaully does work and it is pretty cool. I am still having trouble getting it to work on my laptop though. I suspect there must be some sort of software or hardware conflict. If I figure out the issue, I will post it here. I dont know if it is related or not but the working computer lists only 1 device icon for the Kinect in the "Devices and Printer" view. The non working environment lists four icons, one for each component (camera, device, hub, and USB composite device). I got kinect working on 64-bit computer also on a laptop. Open ni drivers definitely cause conflict. Hi, Whenever I try to follow this, or any other, tutorial I get the following issue: Any reference to Runtime.Kinects is underlined and the message is: "Kinects is not a member of Microsoft.Research.Kinect.Nui.Runtime" I also get this error when I download the project files from the website and try to run them. Please help. Thanks, Matt I have the same problem as Matt. No definition for Kinects Matt, You have to download beta2 from kinectforwindows.org I actually have the same problem as Matt. All the Runtime stuff is all underlined red. My imports/usings have "exclaimation marks". I have installed everything and still dont work. Quick question..do I need to calibrate first before the head is detected? Is it possible to only detect the upper body and get the skeleton? Ok, im new at all this. but im trying to learn. so when i put all of this in and fix all of the errors, i go to run it. and all i get is a blank white window. how can i fix this? heres my exact imp.Research.Kinect.Audio; using Microsoft.Research.Kinect.Nui; namespace WpfApplication1 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } Runtime nui = new Runtime(); private void Window_Loaded(object sender, RoutedEventArgs e) { nui.Initialize(RuntimeOptions.UseColor); } private void Window_Closed(object sender, EventArgs e) { nui.Uninitialize(); } } } I'm having a problem with adding the c4f CodePlex dll references. As mentioned multiple times in the above posts, I browse to the DLL's but it doesn't show up on the list of other references. I think the problem may be because I'm using Visual Studio 11 Preview on Windows 8. Is this a known issue? How do I add references in VS11? Or is it better if I stick with the rest of the crowd and revert back to 2010? EDIT: Once I browse for a reference DLL file, it automatically adds it to the project - it doesn't show up on the "Reference Manager" window as shown in the video. my kinect is already connected but when i run the program only shows a white window. Help me. @Nozue do you find a solution? i got the same window. All of the demo's that come with it work awesomely for me, and I've been having a lot of fun working with the camera in my own apps. I'm trying to get into working with some of the Speech stuff though and I'm having a lot of trouble. I know my Speech libraries are installed properly because I can build and run the ShapeGame demo that has a Microsoft.Speech dependency. However, when I try and add that as a reference to my own project, I can't find it anywhere. What am I doing wrong? I've installed the kinect sdk correctly but I can't find the refference "Windows.Reaserch.Kinect"? Please help me. i have teh same problem. I can't find the microsoft.research.kinect. pls help Same can't find microsoft.research anywhere, please help Hello, I have the same pb, cannot find microsoft.research anywhere... Thanks for any help :) Hello, I found it finally I had to uninstall the kinect version 1.0 that i had, and install the 1.0-Beta version, then just refer to it from the "references" tab under the project. I have another question, hope someone can help : I have a reference to microsoft.Kinect but it is marqued by an exlamation point (that means I have to refer to it) but I can't have Microsoft.Kinect anymore since I uninstalled the version I had, also I don't think both versions can cohabitate... Thanks Hi, I too cannot find the Microsoft.Research.Kinect reference. I don't want to be installing Beta versions if I can help it. Is there a resolution yet? This tutorial is out of date -- the link at the top sends you to the new Kinect Quickstart quide. The current version of the Kinect SDK uses the Microsoft.Kinect namespace, however the API has changed, so do see:. Hican any one help me.... I cannot find the Microsoft.Research.Kinect reference Thanks in advance ! Go to this website and download the Microsoft.Research.kinect.dll. Put it in your C:\Program Files\Microsoft SDKs\Kinect\v1.5\Assemblies Restart your VB application and then you can find the above mentioned reference.. Can anyone help me with the details that I have the data captured(video files and depth data detail files) for the working but I don't have Kinect currently with me. In a nutshell I want to work on the captured data files offline..What should I do to open file in C#??? can any one help me i cant download microsoft Direct SDK(jun2012) at the end it show error message that said : there is a problem preventing your installation from continuing , error code s0123 i have tried other computers and the the same error apear each time !
https://channel9.msdn.com/Series/KinectSDKQuickstarts/Getting-Started?format=html5
CC-MAIN-2017-51
refinedweb
2,912
67.76
#include <aflibAudioRecorder.h> Inheritance diagram for aflibAudioRecorder:: This is a class that performs audio timer recording. This is derived from the aflibAudio base class so it can be used in an audio chain. This is a complex class that aids the user in developing functionality to their audio application that will perform like a VCR does for video. One creates audio record items. You supply start times, stop times, size limits, and info. Then you form this as part of a chain and loop on the process function of this objects base class. When the start time is reached for an item it will start recording. It will stop on several criteria. One can specify multiple items and in fact they can even overlap in time. ADDING RECORD ITEMS One can add record items by calling addRecordItem. One specifies all the necessary information and then make it part of the audio chain and it is ready to go. If this audio object is destroyed then the record information is lost. If one wants to start recording right away then make the start time before the current time. The recording will stop based upon when one of two criteria is reached. If the stop time is reached then recording will stop. There are also two file size limits that can be set. If these are reached before the stop time then recording will be stopped. There is a max file size limit. This will allow one to set an upper limit on the disk space that will be used by the recording. This is useful when you only have a certain amount of disk space available. There is also an each file size limit. This will allow you to set a limit on how big each audio file will be. When that limit is reached then that file will be closed and a new one will be created. The new name will be called the original name plus _<number> before the extension. As many files will be created until either the stop time is reached or the max file size limit is reached. For each file mode the max file size limit means the total size of all audio files created. Each file mode is useful for portable MP3 players that have a memory limit. If you want to record a long show just set a each file size limit of 30M then the show will be stored to sperate files of 30M each. Just big enough to store on a MP3 player. REMOVING RECORD ITEMS One can delete already stored items by calling removeRecordItem. Just pass the item number. The item number can be obtained from calls to getNumberOfRecordItems, getRecordItem. getNumberOfRecordItems will return the total number of items stored so far. getRecordItem will return all the information for an item. The numbering of items start at one.
http://osalp.sourceforge.net/doc/html/class_aflibAudioRecorder.html
crawl-001
refinedweb
478
83.05
import "github.com/mediocregopher/mediocre-go-lib/mcfg" Package mcfg implements the creation of different types of configuration parameters and various methods of filling those parameters from external configuration sources (e.g. the command line and environment variables). Parameters are registered onto a Component, and that same Component (or one of its ancestors) is used later to collect and fill those parameters. cli.go env.go mcfg.go param.go source.go func AddParam(cmp *mcmp.Component, param Param, opts ...ParamOption) AddParam adds the given Param to the given Component. It will panic if a Param with the same Name already exists in the Component. Bool returns a *bool which will be populated once Populate is run on the Component, and which defaults to false if unconfigured. The default behavior of all Sources is that a boolean parameter will be set to true unless the value is "", 0, or false. In the case of the CLI Source the value will also be true when the parameter is used with no value at all, as would be expected. CLISubCommand establishes a sub-command which can be activated on the command-line. When a sub-command is given on the command-line, the bool returned for that sub-command will be set to true. Additionally, the Component which was passed into Parse (i.e. the one passed into Populate) will be passed into the given callback, and can be modified for subsequent parsing. This allows for setting sub-command specific Params, sub-command specific runtime behavior (via mrun.WithStartHook), support for sub-sub-commands, and more. The callback may be nil. If any sub-commands have been defined on a Component which is passed into Parse, it is assumed that a sub-command is required on the command-line. When parsing the command-line options, it is assumed that sub-commands will be found before any other options. This function panics if not called on a root Component (i.e. a Component which has no parents). Code: var ( cmp *mcmp.Component foo, bar, baz *int aFlag, bFlag *bool ) // resetExample re-initializes all variables used in this example. We'll // call it multiple times to show different behaviors depending on what // arguments are passed in. resetExample := func() { // Create a new Component with a parameter "foo", which can be used across // all sub-commands. cmp = new(mcmp.Component) foo = Int(cmp, "foo") // Create a sub-command "a", which has a parameter "bar" specific to it. aFlag = CLISubCommand(cmp, "a", "Description of a.", func(cmp *mcmp.Component) { bar = Int(cmp, "bar") }) // Create a sub-command "b", which has a parameter "baz" specific to it. bFlag = CLISubCommand(cmp, "b", "Description of b.", func(cmp *mcmp.Component) { baz = Int(cmp, "baz") }) } // Use Populate with manually generated CLI arguments, calling the "a" // sub-command. resetExample() args := []string{"a", "--foo=1", "--bar=2"} if err := Populate(cmp, &SourceCLI{Args: args}); err != nil { panic(err) } fmt.Printf("foo:%d bar:%d aFlag:%v bFlag:%v\n", *foo, *bar, *aFlag, *bFlag) // reset for another Populate, this time calling the "b" sub-command. resetExample() args = []string{"b", "--foo=1", "--baz=3"} if err := Populate(cmp, &SourceCLI{Args: args}); err != nil { panic(err) } fmt.Printf("foo:%d baz:%d aFlag:%v bFlag:%v\n", *foo, *baz, *aFlag, *bFlag) Output: foo:1 bar:2 aFlag:true bFlag:false foo:1 baz:3 aFlag:false bFlag:true CLITail modifies the behavior of SourceCLI's Parse. Normally when SourceCLI encounters an unexpected Arg it will immediately return an error. This function modifies the Component to indicate to Parse that the unexpected Arg, and all subsequent Args (i.e. the tail), should be set to the returned []string value. The descr (optional) will be appended to the "Usage" line which is printed with the help document when "-h" is passed in. This function panics if not called on a root Component (i.e. a Component which has no parents). Code: cmp := new(mcmp.Component) foo := Int(cmp, "foo", ParamDefault(1), ParamUsage("Description of foo.")) tail := CLITail(cmp, "[arg...]") bar := String(cmp, "bar", ParamDefault("defaultVal"), ParamUsage("Description of bar.")) err := Populate(cmp, &SourceCLI{ Args: []string{"--foo=100", "arg1", "arg2", "arg3"}, }) fmt.Printf("err:%v foo:%v bar:%v tail:%#v\n", err, *foo, *bar, *tail) Output: err:<nil> foo:100 bar:defaultVal tail:[]string{"arg1", "arg2", "arg3"} Duration returns an *mtime.Duration which will be populated once Populate is run on the Component. Float64 returns a *float64 which will be populated once Populate is run on the Component Int returns an *int which will be populated once Populate is run on the Component. Int64 returns an *int64 which will be populated once Populate is run on the Component. func JSON(cmp *mcmp.Component, name string, into interface{}, opts ...ParamOption) JSON reads the parameter value as a JSON value and unmarshals it into the given interface{} (which should be a pointer) once Populate is run on the Component. The receiver (into) is also used to determine the default value. ParamDefault should not be used as one of the opts. Populate uses the Source to populate the values of all Params which were added to the given Component, and all of its children. Populate may be called multiple times with the same Component, each time will only affect the values of the Params which were provided by the respective Source. Source may be nil to indicate that no configuration is provided. Only default values will be used, and if any parameters are required this will error. Populating Params can affect the Component itself, for example in the case of sub-commands. String returns a *string which will be populated once Populate is run on the Component. TS returns an *mtime.TS which will be populated once Populate is run on the Component. type Param struct { // How the parameter will be identified within a Component. Name string // A helpful description of how a parameter is expected to be used. Usage string // If the parameter's value is expected to be read as a go string. This is // used for configuration sources like CLI which will automatically add // double-quotes around the value if they aren't already there. IsString bool // If the parameter's value is expected to be a boolean. This is used for // configuration sources like CLI which treat boolean parameters (aka flags) // differently. IsBool bool // If true then the parameter _must_ be set by at least one Source. Required bool // The pointer/interface into which the configuration value will be // json.Unmarshal'd. The value being pointed to also determines the default // value of the parameter. Into interface{} // The Component this Param was added to. NOTE that this will be // automatically filled in by AddParam when the Param is added to the // Component. Component *mcmp.Component } Param is a configuration parameter which can be populated by Populate. The Param will exist as part of a Component. For example, a Param with name "addr" under a Component with path of []string{"foo","bar"} will be setable on the CLI via "--foo-bar-addr". Other configuration Sources may treat the path/name differently, however. Param values are always unmarshaled as JSON values into the Into field of the Param, regardless of the actual Source. CollectParams gathers all Params by recursively retrieving them from the given Component and its children. Returned Params are sorted according to their Path and Name. ParamOption is a modifier which can be passed into most Param-generating functions (e.g. String, Int, etc...) func ParamDefault(value interface{}) ParamOption ParamDefault returns a ParamOption which ensures the parameter uses the given default value when no Sources set a value for it. If not given then mcfg will use the zero value of the Param's type as the default value. If ParamRequired is given then this does nothing. func ParamDefaultOrRequired(value interface{}) ParamOption ParamDefaultOrRequired returns a ParamOption whose behavior depends on the given value. If the given value is the zero value for its type, then this returns ParamRequired(), otherwise this returns ParamDefault(value). func ParamRequired() ParamOption ParamRequired returns a ParamOption which ensures the parameter is required to be set by some configuration source. The default value of the parameter will be ignored. func ParamUsage(usage string) ParamOption ParamUsage returns a ParamOption which sets the usage string on the Param. This is used in some Sources, like SourceCLI, when displaying information about available parameters. type ParamValue struct { Name string Path []string Value json.RawMessage } ParamValue describes a value for a parameter which has been parsed by a Source. type ParamValues []ParamValue ParamValues is simply a slice of ParamValue elements, which implements Parse by always returning itself as-is. func (pvs ParamValues) Parse(*mcmp.Component) ([]ParamValue, error) Parse implements the method for the Source interface. type Source interface { Parse(*mcmp.Component) ([]ParamValue, error) } Source parses ParamValues out of a particular configuration source, given the Component which the Params were added to (via WithInt, WithString, etc...). CollectParams can be used to retrieve these Params. It's possible for Parsing to affect the Component itself, for example in the case of sub-commands. Source should not return ParamValues which were not explicitly set to a value by the configuration source. The returned []ParamValue may contain duplicates of the same Param's value. in which case the latter value takes precedence. It may also contain ParamValues which do not correspond to any of the passed in Params. These will be ignored in Populate. SourceCLI is a Source which will parse configuration from the CLI. Possible CLI options are generated by joining a Param's Path and Name with dashes. For example: cmp := new(mcmp.Component) cmpFoo = cmp.Child("foo") cmpFooBar = foo.Child("bar") addr := mcfg.String(cmpFooBar, "addr", "", "Some address") // the CLI option to fill addr will be "--foo-bar-addr" If the "-h" option is seen then a help page will be printed to stdout and the process will exit. Since all normally-defined parameters must being with double-dash ("--") they won't ever conflict with the help option. SourceCLI behaves a little differently with boolean parameters. Setting the value of a boolean parameter directly _must_ be done with an equals, or with no value at all. For example: `--boolean-flag`, `--boolean-flag=1` or `--boolean-flag=false`. Using the space-separated format will not work. If a boolean has no equal-separated value it is assumed to be setting the value to `true`. Parse implements the method for the Source interface. type SourceEnv struct { // In the format key=value. Defaults to os.Environ() if nil. Env []string // If set then all expected Env options must be prefixed with this string, // which will be uppercased and have dashes replaced with underscores like // all the other parts of the option names. Prefix string } SourceEnv is a Source which will parse configuration from the process environment. Possible Env options are generated by joining a Param's Path and Name with underscores and making all characters uppercase, as well as changing all dashes to underscores. cmp := new(mcmp.Component) cmpFoo := cmp.Child("foo") cmpFooBar := cmp.Child("bar") addr := mcfg.String(cmpFooBar, "srv-addr", "", "Some address") // the Env option to fill addr will be "FOO_BAR_SRV_ADDR" Parse implements the method for the Source interface. Sources combines together multiple Source instances into one. It will call Parse on each element individually. Values from later Sources take precedence over previous ones. Parse implements the method for the Source interface. Package mcfg imports 13 packages (graph) and is imported by 8 packages. Updated 2019-07-10. Refresh now. Tools for package owners.
https://godoc.org/github.com/mediocregopher/mediocre-go-lib/mcfg
CC-MAIN-2020-16
refinedweb
1,923
58.58
In my program, I am trying to copy each argv[i] to keyword[i], but my program fails with a segmentation fault. What am I doing wrong? #include <stdio.h> #include <cs50.h> #include <ctype.h> #include <string.h> int main(int argc, string argv[]) { //prototype string keyword = ""; //int j; for (int i = 0, n = strlen(argv[1]); i < n; i++) { keyword[i] = toupper(argv[1][i]); printf("%i-- printing letters\n", keyword[i]); } } As others have observed, you initialize variable keyword either as an empty string or as a pointer to an empty string literal, depending on the definition of type string. Either way, it is then valid to evaluate keyword[i] only for i equal to zero; any other value -- for read or write -- is out of bounds. Furthermore, in the latter (pointer to string literal) case, you must not attempt to modify the array keyword points to. Note in particular that C does not automatically expand strings if you try to access an out of bounds element. Instead, an attempt to do so produces "undefined behavior", and a common way for that to manifest in such cases is in the form of a segmentation fault. You can view a segmentation fault as the system slapping down your program for attempting to access memory that does not belong to it. Since you don't know a priori how long the argument string will be before you copy it, the most viable type for keyword is char *. I will use that type instead of string in what follows, for clarity. If you indeed do want to make a copy of the argument, then by far the easiest way to do so is via the for-purpose function strdup(): char *keyword = strdup(argv[1]); That allocates enough memory for a copy of its argument, including the terminator, copies it, and returns a pointer to the result. You are then obligated to free the resulting memory via the free() function when you're done with it. Having made a copy in that way, you can then upcase each element in place: for (int i = 0, n = strlen(keyword); i < n; i++) { keyword[i] = toupper(keyword[i]); printf("%c-- printing letters\n", keyword[i]); } Note, by the way, that the printf() format descriptor for a single character is %c, not %i. You must use that to print the characters as characters, rather than their integer values. That's one of the simplest ways to write C code for what you're trying to do, though there are many variations. The only other one I'll offer for your consideration is to not copy the argument at all: char *keyword = argv[1]; If you initialize keyword that way then you do not allocate any memory or make a copy; instead, you set keyword to point to the same string that argv[1] points to. You can modify that string in-place (though you cannot lengthen it), provided that you do not need to retain its original contents. Before I wrap this up, I should also observe that your program does not check whether there actually is an argument. In the event that there is not (i.e. argc < 2), argv[1] either contains a null pointer ( argc == 1) or is undefined ( argc == 0; you're unlikely ever to run into this). Either way, your program produces undefined behavior in that case if it attempts to use argv[1] as if it were a pointer to a valid string. You should test for this case first off, and terminate with a diagnostic message if no program argument is available.
https://codedump.io/share/zH6W0ebw1bY2/1/segmentation-fault-when-trying-to-declare-an-array-of-strings
CC-MAIN-2017-39
refinedweb
605
65.46
21 August 2008 05:18 [Source: ICIS news] SINGAPORE (ICIS news)--Mitsubishi Chemical intends to restart its 476,000 tonne/year No 2 cracker in Kashima, Japan, after a scheduled maintenance shutdown that began in 6 July, a source from the company said on Thursday. The cracker is expected to be operational by Friday, and is expected to be gradually ramped up to 80%, he said. It was unable to run the facility at full rates as two of its eight furnaces were still undergoing repairs following a fire in December last year. Mitsubishi was currently running its other two crackers in ?xml:namespace> The No 1 cracker in Kashima has a nameplate ethylene capacity of 375,000 tonnes/year while the company’s cracker in Mizushima can produce 450,000 tonnes/year of ethylene. The Kashima No 2 plant produces an estimated 240,000 tonnes/year of propylene.
http://www.icis.com/Articles/2008/08/21/9150599/Mitsubishi-to-restart-No-2-Kashima-cracker-on-Fri.html
CC-MAIN-2013-48
refinedweb
149
56.79
i am feel so lucky use arr[3][20] instead of arr[3][12] because strlen("technologies") == 12 !! hi I think you forgot the \0 (null terminated string). your array should have the size 13 and not 12. "technologies\0" Post your Comment array to string array to string hello how to assign value from array to string. nsstring *abc = [array objectAtindex:1]; you can use this code NSString *abc = [NSString stringWithString:[array objectAtIndex:i]]; where i array string array string how to sort strings with out using any functions string array string array Hi hw to print string array element in ascending r... StringArray { public static void main(String[] args) { String arr...); System.out.println("Array Elements in Ascending Order: "); for(int i=0;i< array of string array of string Waht is the problem in this code? import java.util.Scanner; public class LastCheck { public static void main(String args[]){ int a; Scanner s= new Scanner(System.in); a=s.nextInt(); String ar[]=new string array sort string array sort Hi. How to sort a string array php parse string into array php parse string into array How can i parse a string into array and convert an array into string Array /string based problem.... Array /string based problem.... thanx to help me.but again a problem is here that it sorts single char as (a,b,c,n,m)but not the string .and also...("Enter string: "); String[] array = new String[5]; for(int i=0;i<5;i string array based problem string array based problem R/sir, firstly thanks... string: "); String[] array = new String[5]; for(int i=0;i<5;i++){ array[i...++){ System.out.print(array[i]+" "); } } static String[] selectionSort(String[] array string string write a program to accept the string and store the reverse stream into another array and print string "String args[]" can mean a "string array called args which is an array" and the "String[] args" which basically says it?s a "string array called args". Either way...string difference detween "public static void main (String[] args array, index, string array, index, string how can i make dictionary using array...please help JavaScript split string into array ; Description: The split() method is used to split a string into an array...JavaScript split string into array How to split the string into array? <html> <head> <title></title> <script string string program for String reverse and replace in c,c++,java...(String[] args) { String array[]=new String[5]; Scanner input...: "); for(int i=0;i<array.length;i++){ array[i]=input.next Array Array What if i will not declare the limit index of an array, how will I declare an array and store values with it using loop? Hi Friend... { public static void main(String[] args) { Scanner input=new Scanner array and string based problem array and string based problem this program is accepting only... main(String a[]){ Scanner input=new Scanner(System.in); int array[]=new..._srt(int array[],int n){ for (int j = 0; j < n; j++){ int i = j-1 Array Array How do i insert elements into an array up to a limit from...; import java.util.*; class ArrayExample { public static void main(String...("Enter Range: "); int size=input.nextInt(); int array[]=new int[size String Array - Java Beginners String Array From where can I get, all the functions that are needed for me to manipulate a String Array. For Example, I had a String Array ("3d4..., as to by which method can I separate the Integers from this Array of String array array wap to calculate reverse of 10 elements in an array?  ... ArrayReverse { public static void main(String args[]){ int arr[]=new...++ ) { arr[i]=input.nextInt(); } System.out.print("Array array split string array split string array split string class StringSplitExample { public static void main(String[] args) { String st = "Hello_World"; String str[] = st.split("_"); for (int i = 0; i <...(String[] args) throws Exception{ int arr[]=new int[10...]=Integer.parseInt(br.readLine()); } System.out.println("Array Elements String array sort String array sort Hi here is my code. If i run this code I am... result_set=null; String route_number[]=new String[1000]; String route_number1[]=new String[1000]; route_number1[0]=" "; int counter=0,count=0 c array of stringsukhendra September 20, 2011 at 10:51 PM i am feel so lucky C++milad October 10, 2011 at 2:45 AM String overflow errorGuus de leeuw November 4, 2011 at 3:48 PM use arr[3][20] instead of arr[3][12] because strlen("technologies") == 12 !! web page designingrohan March 1, 2013 at 8:20 PM hi Forgot the null charPedro October 5, 2012 at 5:48 AM I think you forgot the \0 (null terminated string). your array should have the size 13 and not 12. "technologies\0" Post your Comment
http://roseindia.net/discussion/23749-C-Array-of-String.html
CC-MAIN-2014-15
refinedweb
806
63.59
Spent the most of easter digging through heaps of sql. So here’s another “in-stinker” which almost had me fooled again. Inside of a component I’m not afraid to work directly with sqlcommands. Setting up a datadapter and a dataset would be an overkill when the database will return just a scalar value. The result returned by the ExecuteScalar method can be somewhat misleading at first sight. Take this code public string CustomerName(int custId) { SqlCommand cmd = new SqlCommand(string.Format(“SELECT Name FROM Customers WHERE idCust = {0}”, custId), sqlConnectionToSchaakBondDB); object result = cmd.ExecuteScalar(); if (result == null) return “Customer not found”; if (result == System.DBNull.Value) return “Customer found but name is null”; return (string) result; Testing the result only against null could give a quite misleading result. In the second case the method does return a value but the content of this value is null. Which is not the same as not returning a value at all. Peter
http://codebetter.com/petervanooijen/2004/04/12/system-dbnull-value-null/
CC-MAIN-2014-42
refinedweb
161
66.03
Library for using the Apple News API Project description kcrw.apple_news kcrw.apple_news is a simple library for using the Apple News API from Python 2 or 3 (>= 2.7 or >= 3.5). Free software: MIT license Documentation:. Features Provides support for making signed API requests to the Apple News Publisher API Includes suport for “Read Channel”, “Create Article”, “Update Article”, “Read Article Information”, “Delete Article” API calls as well making generic signed requests. Provides a command line tool apple_news_api for making API calls directly. History 0.2.6 (2020-04-17) Fix namespace package issues 0.2.4 (2020-03-09) Fix namespace package issues 0.2.3 (2020-02-27) Fixes to support applications that pin six < 1.12.0 0.2.2 (2020-02-26) Include response error codes and data in custom exception. 0.2.1 (2020-02-25) Fix bumpversion error 0.2.0 (2020-02-25) Fix botched package release 0.1.0 (2020-02-24) First release on PyPI Project details Release history Release notifications | RSS feed Download files Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
https://pypi.org/project/kcrw.apple-news/
CC-MAIN-2022-40
refinedweb
195
59.9
This article describes a fast algorithm to pack a series of rectangles of varying widths and heights into a single enclosing rectangle, with no overlap and in a way that minimizes the amount of wasted space in the enclosing rectangle. An implementation of the algorithm is in the download, along with a web site that graphically shows step by step how the algorithm arrives at the optimal enclosing rectangle. Having an algorithm like this is important when generating CSS Sprites, which are used to speed up image loading when loading a web page. With this technique, instead of loading all images on the page one by one, you combine them into a single larger image - called a sprite - and load that in one go. This way, you prevent the overhead of the browser having to request each individual image from the server one by one, which can be significant when loading lots of small images. Using some CSS, you can make the individual images contained within the sprite appear on the page individually. This technique is further described in chapter 12 of my book ASP.NET Site Performance Secrets. It would definitely be possible to combine the images manually with a graphics program. But then each time you add or remove an image, you have to manually redo the sprite. Much better to have the sprite generated automatically, ideally on the fly when the page loads. However, that means you want a fast algorithm to generate the sprite, even if you cache the result for subsequent page loads. Additionally, you want the algorithm to pack the images in the sprite in a way that minimizes the overall size of the sprite - the smaller the size, the less time it takes the browser to load the sprite and the less bandwidth you incur: To simplify things a bit, you can think of the images as rectangles, and of the sprite as an enclosing rectangle. It than becomes a matter of finding the enclosing rectangle with the smallest area (width x height) in which you can pack all the rectangles. The rectangle packing algorithm described in this article is designed to do this relatively quickly so it can be used to generate sprites on the fly, and to do a reasonable job of finding the smallest enclosing rectangle. Note that it isn't guaranteed to generate the absolute best enclosing rectangle every time, because that would take a lot longer. Oh, by the way, if you like this article, please vote for it. That way I know people appreciate my work. The download contains a Visual Studio 2010 solution with: There are a few trivial solutions on how to pack rectangles into an enclosing rectangle: This is very simple and fast, and would actually be optimal if all rectangles had the same height. This is also very simple and fast, and would actually be optimal if all rectangles had the same width. However, these solutions leave a lot of wasted space when the rectangles are of varying width and height. They are also a bit boring. So the rest of this article focuses on a solution that does minimize wasted space when the rectangles are of varying width and height, and that is also reasonably fast and simple. The basic algorithm for packing rectangles into an enclosing rectangle of minimum size is described in, for example, Richard E. Korf's paper: Optimal Rectangle Packing: Initial Results. Note that reducing the width and increasing the height means in effect that we're testing the range of enclosing rectangles from low and wide to high and narrow. For example, after the width has been decreased a few times and the height increased, you may get the following sequence: This algorithm has been implemented in method Mapping in the class MapperOptimalEfficiency in the Mapper project in the download. Mapping MapperOptimalEfficiency Later on, we'll see how this basic algorithm can be made a lot faster. But first, let's see how to actually place the rectangles in the enclosing rectangle, and above all how to keep track of where there already are rectangles so we don't overlap a new rectangle with an existing rectangle. Step 3 of the basic algorithm above says "Place the rectangles in the enclosing rectangle one by one, starting with the highest rectangle and ending with the lowest rectangle. Put each rectangle as far left as possible. If there are several left most locations, use the highest one." In order to find the left most / highest location where a rectangle with given width and height can be placed without overlapping other rectangles, we need to use some data structure to store which areas within the enclosing rectangle are now occupied. And this data structure must make it both simple (that is, less error prone) and fast to find the left most / highest location where the rectangle can be placed. It would be possible to use a two dimensional array of booleans with one cell for every pixel in the enclosing rectangle. Each boolean would indicate whether the pixel is occupied by a rectangle or free. However, you'd need to visit lots of pixels when finding a place for a rectangle, making this option simple but inefficient. An alternative would be to store the width/height and X/Y offsets of each rectangle within the enclosing rectangle. This data structure would have far fewer individual items than the two dimensional pixel array, but working out the left most / highest location with enough room for a given rectangle with this data structure turned out to be either very complex or very slow. The solution I came up with was to use a dynamic two dimensional array of occupied/free booleans, but to store a width with each column and a height with each row, so the number of columns and rows can be kept to a minimum. This minimizes both complexity and the number of cells that need to be visited (and therefore time spent). Here is how this works when adding rectangles (white cells are unoccupied, light green cells are occupied, and dark green cells have just been occupied by the last added rectangle): We now have a cell which is partly occupied and partly unoccupied. However, a cell can be in only one state. To fix that, split the single row and the single column, so we get four cells that are all either occupied or unoccupied: It turns out there is a free cell in the left most column, but there is not enough vertical space there to place the rectangle. So move to the column to the right and go through the same steps as with the left most column. With this second column, the top most cell is free, and it is big enough for the rectangle, so that's easy. Place the rectangle there. As was the case with the very first rectangle, here too the rectangle is smaller than the cell - leading to a cell that is partly occupied, partly unoccupied. So split the row and column where the cell is located to ensure all cells are either occupied or unoccupied again. Note that as a result, the one cell that was occupied by the first rectangle is now split into two, which is fine. In the fourth column, there is a free cell that in itself is neither high nor wide enough for the rectangle. So check the cells to the right of the column and the cells in the row below to see if enough free cells can be combined to accommodate the rectangle. In this case, that turns out to be possible. Again, a row and column split occurs to make sure all cells are either occupied or unoccupied. You can see lots more examples (and rectangles) by running the web site contained in the download. This also shows situations where not every rectangle can be placed. The code that finds the left most / highest cell where a rectangle can be placed and that checks neighboring cells, etc. is in the Canvas class in the Mapper project in the download. The two dimensional dynamic array is implemented in the DynamicTwoDimensionalArray class. Because it is heavily used, that class is highly optimized for performance, especially when splitting rows and columns. Canvas DynamicTwoDimensionalArray While studying the test cases generated by the test site in the download, the following improvements became clear. Those improvements were worked into the code in the download. I didn't find these in the literature, so you read about them here first: Have a look at the following enclosing rectangle that was produced during an iteration of the basic algorithm: According to the basic algorithm, you should reduce the width of the enclosing rectangle by 1 and then try again to place all rectangles. However, if you simply reduce the width by 1, you know that the dark green rectangle that sits against the right hand border of the enclosing rectangle cannot be placed anywhere, so the next try will fail for sure. Additionally, the algorithm says to increase the height of the enclosing rectangle by 1 when that failure happens. However, because the dark green rectangle is 10 pixels high, you know that increasing by 1 will not be enough. So following the basic algorithm will definitely create 10 failed attempts to place all rectangles, which is expensive and unnecessary. The optimization is to record the height of the tallest rectangle that sits against the right hand edge of the enclosing rectangle. If you're successful in placing all rectangles and you reduce the rectangle's width by 1, then also increase the height of the enclosing rectangle by the height of the tallest right flushed rectangle. That gives the algorithm a chance to find a new spot for the tallest right flushed rectangle within the new enclosing rectangle: Have a look at the sequence below. Here the algorithm places 4 rectangles, but then fails to place the fifth rectangle. After this failure, the basic algorithm would increase the height of the enclosing rectangle by 1 and try again to place the rectangles. However, with an increase of only 1, the first 4 rectangles are likely to be placed in the exact same locations, leading again to a failure to place the fifth rectangle. The algorithm would then increase the height by 1 again and try again, possibly creating the same situation, etc. All this fruitless trying takes a lot of time. Instead of increasing the height by 1, it needs to be increased by the smaller of: By picking the minimum of the two, you're more likely to wind up with the smallest possible enclosing rectangle. Figuring out the height mentioned in point 2 above is not all that hard when you realize that the algorithm tries to place each rectangle in the left most column first, and if that fails, moves to the column to the right and tries again, etc. Each time it fails to place the rectangle in a column, that is because the free space in the bottom of that column is lower than the rectangle itself - there is a free height deficit. For example, for the second rectangle, the free height deficit in the first column is 30px: That is, if the enclosing rectangle had been 30px higher, the second rectangle could have been placed in the left most column. Likewise, the free height deficit for the third rectangle in the left most column is 25px, and in the second column it is 15px. So if the enclosing rectangle had been 15px higher, the third rectangle could have been placed differently: The free height deficit for the fourth rectangle in the left most column is 10px. So if the enclosing rectangle had been 10px higher, the fourth rectangle might have been placed in the first column: We want to increase the height of the enclosing rectangle by the minimum required to ensure that the rectangles can be arranged differently. Here, the smallest free height deficit for all rectangles for all columns is 10px (applies to the fourth rectangle in the left most column). Seeing that the fifth rectangle that failed to be placed is higher than 10px, we need to increase the height of the enclosing rectangle by 10px to have any hope of placing the fifth rectangle at the next try: This means that in order to prevent a lot of failed enclosing rectangles, the algorithm simply needs to keep track of the smallest free height deficit when it tries to place a rectangle in a column. Then when it fails to place a rectangle, it needs to increase the height of the enclosing rectangle by that smallest free height deficit - or by the height of the rectangle that couldn't be placed if that is smaller. This optimization is not guaranteed to lead to a successful enclosing rectangle at the next try. For example, at the new height, the enclosing rectangle may be bigger than the best enclosing rectangle so far, in which case the algorithm will start to reduce its width. Because of this, it may fail to place all rectangles at the next try because of the reduced width. What this optimization does do is prevent a lot of tries that have no hope of succeeding. If you decide you can live with a given level of wasted space, one way to reduce the time taken to generate the enclosing rectangle is to tell the code to stop trying to get a smaller enclosing rectangle once it has reached that level. Another way to improve speed is to tell the algorithm to stop after it has found a certain number of successful enclosing rectangles that can contain all rectangles. You would probably set the limit at one or two. That would be attractive if you found that this way you generally get results that are good enough while getting an almost guaranteed speed boost. To allow you to make these choices, a second constructor has been provided for the MapperOptimalEfficiency class, with additional parameters to set these two cut offs. The rectangle packer described in this article has been implemented in the Mapper project in the download. It exposes a well defined interface to the outside world. The test site uses that interface. Below is a description of the interface, to make it easier to study the code or to use the code in your own projects. You'll find that the code refers to images and sprites rather than rectangles and enclosing rectangles. This is because it was written as part of an (as yet unfinished) project to build an automated on-the-fly sprite generator. To make the code easily extensible, the software interface is defined using C# Interfaces. That way, you can provide your own implementation for one class while reusing the other classes. IMapper IImageInfo ISprite IImage System.Drawing Image IMappedImageInfo As a result, the following C# interfaces describe the complete software interface of the rectangle packer: public interface IMapper<S> where S : class, ISprite, new() { S Mapping(IEnumerable<IImageInfo> images); } public interface IImageInfo { int Width { get; } int Height { get; } } public interface ISprite { // Width of the sprite int Width { get; } // Height of the sprite int Height { get; } // Area of the sprite int Area { get; } // Holds the locations of all the individual images (treated as rectangles) // within the sprite (treated as the enclosing rectangle). List<IMappedImageInfo> MappedImages { get; } // Adds an image to the SpriteInfo, and updates // the width and height of the SpriteInfo. void AddMappedImage(IMappedImageInfo mappedImage); } public interface IMappedImageInfo { int X { get; } int Y { get; } IImageInfo ImageInfo { get; } } What this means is that if you want to follow in my footsteps and build your own rectangle packer that works with the test site in the download, all you need to do is implement the C# interface IMapper. If you want to compare the performance of your implementation against mine using the test site, add your implementation to the mappers array defined in method Generate in the file default.aspx.cs. mappers Generate On the other hand, if you want to use the rectangle packer I've done but use your own image class and/or sprite class, simply make sure they implement IImageInfo or ISprite. If you wanted to write a CSS Sprite generator, you'd probably write image and sprite classes that represent real images while still implementing IImageInfo and ISprite. The C# interfaces have been implemented in the Mapper project in the download with these classes: There are three implementations: The constructor of MapperOptimalEfficiency takes a parameter of type ICanvas. That interface has been implemented in the class Canvas, so you could simply instantiate a Canvas object and pass that to the MapperOptimalEfficiency constructor, as shown below. The Canvas object is used to figure out whether a given set of rectangles will fit within an enclosing rectangle of a given fixed size. If you have found a better way to do that, you could build your own class implementing ICanvas and pass that to the MapperOptimalEfficiency constructor. ICanvas MapperHorizontalOnly MapperVerticalOnly ImageInfo MappedImageInfo Sprite To use the rectangle packer software in your own project: using Mapper; Canvas _canvas = new Canvas(); MapperOptimalEfficiency<Sprite> mapper = new MapperOptimalEfficiency<Sprite>(_canvas); IEnumerable<IImageInfo> rectangles Sprite sprite = mapper.Mapping(rectangles); This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL) General News Suggestion Question Bug Answer Joke Rant Admin Man throws away trove of Bitcoin worth $7.5 million
http://www.codeproject.com/Articles/210979/Fast-optimizing-rectangle-packing-algorithm-for-bu?msg=4225567
CC-MAIN-2013-48
refinedweb
2,931
54.36
note Tanktalus <p>"In C you would put these values in a .h file."</p> <p>In C, you wouldn't have multiple namespaces. That's the primary difference here.</p> <p>In C++, if memory serves, you could have multiple namespaces and then in your .cpp (or .cxx or whatever) file, you would have <c>using std; using object1; ...</c> and there's no way to auto-import a bunch of namespaces, and doing so in the header would defeat much of the purpose of namespaces (they don't export just small pieces like we can in Perl).</p> <p.</p> <p <c>use Module;</c> as normal.</p> <p>If you want MyThing to export the stuff from Object1, check out [mod://Import::Into]. This might work: <c> method but uses magic. } #... package Object1; # has to handle its exports here as if it were in its own file. 1; </c> Still more work than normal, but probably will work. Though, again, if you don't know what you're doing, this probably isn't what you want. Use separate files.</p> 997244 997412
http://www.perlmonks.org/?displaytype=xml;node_id=997567
CC-MAIN-2014-52
refinedweb
185
76.62
Oh I have nodding my head whenever Jeremy Foster when he speaks about anonymous functions in JavaScript. And that is all I have been doing, now I need to figure out just what the freaking heck is this anonymous function thingie in HTML 5 for Metro/Windows 8 design. As a C#/C++ programmer I am used to the idea of private functions, in JavaScript there is no such thing and the wrapping of the JavaScript in an anonymous function makes those functions private with in the scope of the anonymous function. So I started with The entire file is an anonymous function, the wrap looks like: (function() { … })(); (function() { … })(); If you look at the default.js you will see that nomenclature. So what in the heck is that last set of parentheses? Did LISP suddenly sneak back into mainstream programming? No, by making the JavaScript an anonymous function the javascript which protects your global variables for the javascript file a function. This also prevents the global namespace from having ambiguous names. JavaScript doesn’t support the idea of a private function and the anonymous wrapping makes it private, a good thing. Legal Note: Restrictions:
http://blogs.msdn.com/b/devschool/archive/2012/06/30/wtf-anonymous-function-in-javascript-what-about-private-functions.aspx
CC-MAIN-2015-06
refinedweb
194
70.84
How would I go about detecting keystrokes on the keyboard? Turns out Pygame isnt just for games. I wrote this script using it and it does exactly what I wanted it to do! You can use the Tkinter GUI toolkit too: # KeyLogger.py # show a character key when pressed without using Enter key # hide the Tkinter GUI window, only console shows import Tkinter as tk def key(event): if event.keysym == 'Escape': root.destroy() print event.char root = tk.Tk() print "Press a key (Escape key to exit):" root.bind_all('<Key>', key) # don't show the tk window root.withdraw() root.mainloop() Thanks for the reply. The program I wrote with pygame did certain actions when keys were pressed. When you held control and g down, google opened up. Can you do the same thing with Tkinter? I wrote a key logger myself. I use pyHook and pythoncom from the pywin module. Here is the link However, pyHook and pythoncom work only on Windows systems. Not too bad, since most computers in this world are using Windows. Tkinter is more cross-platform for the few odd folks that user other OS. The code does not work on my Mac. If I comment out the withdrawing of the root window then it works fine as long as I make the root window focused. Tested for Python 3.2.2 and Python 2.7.2. Updated code in the code snippet (need to put bind before withdraw), the tkinter solution here is correct. Edited 5 Years Ago by pyTony: n/a ...
https://www.daniweb.com/programming/software-development/threads/112975/detecting-key-strokes
CC-MAIN-2017-17
refinedweb
259
78.55
Content-type: text/html atof, strtod - Converts a character string to a double-precision floating-point value Standard C Library (libc.a) #include <stdlib.h> double atof( const char *nptr) ; double strtod( const char *nptr, char **endptr) ; Points to the character string to convert. Specifies either a null value, or a pointer to the character that ended the scan or to a null value. The atof() function converts the string pointed to by the nptr parameter up to the first character that is inconsistent with the format of a floating-point number to a double floating-point value. Leading white-space characters are ignored. A call to this function is equivalent to a call to strtod(nptr, (char **) NULL), except for error handling. When the value cannot be represented, the result is undefined. The strtod() function converts the initial portion of the string pointed to by the nptr parameter to double representation. First the input string is decomposed into the following three parts: An initial, possibly empty, sequence of white-space characters (as specified by the isspace() function). A subject sequence interpreted as a floating-point constant. A final string of one or more unrecognized characters, including the terminating null character of the input string. After decomposition of the string, the subject sequence is converted to a floating-point number, and the resulting value is returned. A subject sequence is defined as the longest initial subsequence of the input string, starting with the first nonwhite-space character, that is of the expected form. The expected form and order of the subject sequence is: An optional plus (+) or minus (-) sign. A sequence of digits optionally containing a radix character. An optional exponent part. An exponent part consists of e or E, followed by an optional sign, which is followed by one or more decimal digits. When the input string is empty or consists entirely of white space, or when the first nonwhite-space character is other than a sign, a digit, or a radix character, the subject sequence contains no characters. For the strtod() function, when the value of the endptr parameter is not (char**) NULL, a pointer to the character that terminated the scan is stored at *endptr. When a floating-point value cannot be formed, *endptr is set to nptr. The setlocale() function may affect the radix character used in the conversion result. Full use When the string is empty or begins with an unrecognized character, +0.0 is returned as the floating-point value. When a correct return value overflows, a properly signed HUGE_VAL (INF) is returned. On underflow, a properly signed 0 (zero) is returned. Upon successful completion, either function returns the converted floating-point value. If the atof() or strtod() function fails, errno may be set to the following value: The input string is out of range (that is, the subject sequence can not be converted to a floating-point value without causing underflow or overflow). Functions: atoi(3), scanf(3) delim off
http://backdrift.org/man/tru64/man3/atof.3.html
CC-MAIN-2017-22
refinedweb
497
54.83
covjson-reader A library that reads CoverageJSON documents and exposes them as Coverage data objects. Usage A browser version of this library is hosted on both jsDelivr and cdnjs, where the latter also hosts the unminified version together with source maps. Usage is simple: <script src=""></script> <script src=""></script> <script> CovJSON.read('').then(function (cov) { // work with Coverage object }).catch(function (e) { // there was an error when loading the coverage console.log(e) }) </script> The library makes use of the following ES2015 features: Promise, Symbol, Map, and Array.from. Depending on which browsers you need to support it may be necessary to include polyfills before loading this library. NPM This library can be used with browserify and similar tools by importing it via npm. ES2015 syntax: import * as CovJSON from 'covjson-reader' CovJSON.read('').then(cov => { // work with Coverage object }).catch(e => { // there was an error when loading the coverage console.log(e) }) Acknowledgments This library has been developed within the MELODIES project and is maintained as open source software.
https://doc.esdoc.org/github.com/Reading-eScience-Centre/covjson-reader/
CC-MAIN-2021-17
refinedweb
171
50.02
onzalo Torres del FierroCourses Plus Student 16,750 Points Hangman project why on the project named Hangman, we have 3 .java, i mean the prompter, the main, and the game?, i can see, this an interaction, but i get lost trying to understand, wich one get the "logic" and when i have to go and make a new function, or method to complete the whole structure.....some times i start coding on the wrong "place.java" ... 3 Answers Shane Robinson7,324 Points Pretty much all Java programs, aside from very small ones (like Hello World), are written with multiple files/classes. It is part of Object Oriented Programming, and just generally is a better way to split up code. It's just something you are going to have to get used to. Edit: Derek beat me with a much better explanation. :p Derek Markman16,291 Points Well, when just writing pure java source code and your project contains more than one java class. The only code that gets invoked is the code inside of the main method. public class Example { public static void main(String[] args) { //only the code inside of this method is ran at compile time. } } When you have more than one class, such as in the Hangman project, each of the classes is meant to handle different logic. You have a Prompter class, a Main class, and the actual Hangman game class. Your Main class will be the class where you have your main method(There can only be one class that includes the main method, in a project that includes more than one class.). It's worth noting, that you could technically have another main method, just not one that takes a String array as the parameter Without seeing the actual code I couldn't tell you what each class is doing exactly. But, the reason I bring up the main method is because your Main class will most likely be the class that contains the main method, in which you invoke each of the required methods from your Prompter and Hangman class to make the game actually run. tl:dr Basically each class does a specific job in your project, while you could technically write all of the code necessary in one class, this quickly becomes very messy due to all of the code. It's much better practice to separate specific logic into their own java class, then invoke those methods inside of the main method to make the game actually run. Let me know if this is confusing and I could try to re-explain a different way.
https://teamtreehouse.com/community/hangman-project
CC-MAIN-2022-27
refinedweb
435
74.32
QSerialPortInfo doesn't return ports and connection doesn't work (Windows 10) Hello, i'm currently developing an application with Qt Quick/QML using the QSerialPort und QSerialPortInfo library. My backend class is written in C++ and connected to QML with signal and slots. In my .pro file i've added "QT += serialport" and my backend class (.cpp) looks like this: #include <QSerialPort> #include <QSerialPortInfo> class { QList<QSerialPortInfo> m_availablePorts; ... void Backend::printAvailablePorts() { emit debugOutput("Available ports:"); for (const auto &info : m_availablePorts) { emit debugOutput(info.portName()); } } The class hierarchy is like this: - Qt Quick/QML - Backend_Adapter (Used as component block in QML) - Backend_Worker (Thread which runs in Backend_Adapter for blocking operations, serial, ...) After sending the signal, i get no listing of ports. Even when running the application as administrator no ports are listed. When trying to connect to the port using the port name (COM7 e.g.), i get "Access denied" as error-string. The strange thing is, an application written as "Qt Core Application" (only console output) does list the ports and connection works as expected. What i am missing here in Qt Quick/QML? Thanks! Best regards, Kevin @kkettinger Are you sure you're not trying to open the port in your GUI app more than once? Did you compare your console app to your GUI app - maybe there are some differences in how you handle COM ports? @kkettinger said in QSerialPortInfo doesn't return ports and connection doesn't work (Windows 10): m_availablePorts How do you initialise/fill it? Oh wow, i forget the initialization.. thanks. With m_availablePorts = QSerialPortInfo::availablePorts();the port listing it is working now. For the connection part, i'm still getting "Access denied". The relevant code part: QSerialPort m_serialPort; ... void cBackendWorker::openSerialPort( QString serialPortName) { // ---- Port configuration m_serialPort.setPortName(serialPortName); m_serialPort.setBaudRate(QSerialPort::Baud9600); emit writeDebugOutput(QString("Open serial port %1...").arg(m_serialPort.portName())); // ---- Opening port if (m_serialPort.open(QIODevice::ReadWrite) == false) { emit writeDebugOutput(QString("Failed to open port %1, error: %2").arg(m_serialPort.portName()).arg(m_serialPort.errorString())); return; } emit writeDebugOutput("Port successfully opened"); } This is the output i get: Without m_serialPort.open(), busy is "No" for COM7. Other ports yield the same error string. Thanks. @kkettinger Do you start your app with elevated permissions? - kkettinger last edited by Yes, I directly start the .exe from the build folder (after using windeployqt.exe) with administrative right (Rightclick -> Run as administrator). The console app doesn't run with administrative right and still works though. @kkettinger Are you sure you're not trying to open the port in your GUI app more than once? Did you compare your console app to your GUI app - maybe there are some differences in how you handle COM ports? Thank you jsulm, that was it. I accidentally had another backend instance for testing in the main.cpp, directly before using qmlRegisterType<BackendAdapter::cBackendAdapter>("com.ex.backend", 1, 0, "Backend");. This way two worker instances were instantiated and two emit signals were sent. But ony one was used in qml and was connected to the debug window, so i only saw one output.
https://forum.qt.io/topic/114118/qserialportinfo-doesn-t-return-ports-and-connection-doesn-t-work-windows-10/?
CC-MAIN-2022-33
refinedweb
511
51.14
The code below is X86 64 bit assembly code to calculate the sum of Fib(0) to Fib(93). It includes a conditional to use either a tight loop or an unfolded loop with a computed jump to enter the unfolded loop similar to C switch / case. Originally, it was meant to see the performance improvement of unfolding a loop, but during the testing, it turns out that the tight loop code is very sensitive to where the code is located. The table with multiples of 37 % 93 is used mostly to vary the jumps on the unfolded code. The code is run 2^20 = 1048576 times for a bench mark, so this is actually a nested loop where the inner loop runs from 0 to 93 times, for an average of ~46 (since 0 and 1 inputs skip the inner loop). Even if the outer and inner loop have a cache conflict, since the inner loop is run an average of ~46 times, it shouldn't have as much impact on the timing that I'm seeing. The times are noted below, but for the tight loop, depending on code location, the tight loop runs as fast as 1.465 seconds, or as slow as 2.000 seconds. The unfolded loop only has slight variation, 1.042 to 1.048 seconds. I removed the printf statements, and switched to using a debugger to check results, and the performance was unaffected (since it's assembly code). I'm using Visual Studio 2015 on Windows 7 Pro 64 bit to do the builds and do the runs. Switching to AT&T syntax for Linux / Posix could take a while, unless there's something MASM syntax compatible for Linux / Posix. I'm wondering if other X86 cpu's have similar performance differences. I'm posting this as a follow up in another thread that included performance of a 4 way merge sort that uses gotos. Sometimes "goto" is useful Code:includelib msvcrtd includelib oldnames .data ; multiples of 37 mod 93 + 93 at the end a dq 0,37,74,18,55,92,36,73,17,54 dq 91,35,72,16,53,90,34,71,15,52 dq 89,33,70,14,51,88,32,69,13,50 dq 87,31,68,12,49,86,30,67,11,48 dq 85,29,66,10,47,84,28,65, 9,46 dq 83,27,64, 8,45,82,26,63, 7,44 dq 81,25,62, 6,43,80,24,61, 5,42 dq 79,23,60, 4,41,78,22,59, 3,40 dq 77,21,58, 2,39,76,20,57, 1,38 dq 75,19,56,93 .data? .code ; parameters rcx,rdx,r8,r9 ; not saved rax,rcx,rdx,r8,r9,r10,r11 ; code starts on 16 byte boundary main proc push r15 push r14 push r13 push r12 push rbp mov rbp,rsp and rsp,0fffffffffffffff0h sub rsp,64 mov r15,offset a xor r14,r14 mov r11,0100000h ; nop padding effect on loop version (with 0 padding in padx below) ; 0 puts main2 on odd 16 byte boundary clk = 0131876622h => 1.465 seconds ; 9 puts main1 on odd 16 byte boundary clk = 01573FE951h => 1.645 seconds rept 0 nop endm rdtsc mov r12,rdx shl r12,32 or r12,rax main0: xor r10,r10 main1: mov rcx,[r10+r15] call fib main2: add r14,rax add r10,8 cmp r10,8*94 jne main1 dec r11 jnz main0 rdtsc mov r13,rdx shl r13,32 or r13,rax sub r13,r12 mov rdx,r14 xor rax,rax mov rsp,rbp pop rbp pop r12 pop r13 pop r14 pop r15 ret main endp align 16 padx proc ; nop padding effect on loop version with 0 padding above ; 0 puts fib on odd 16 byte boundary clk = 0131876622h => 1.465 seconds ; 16 puts fib on even 16 byte boundary clk = 01A13C8CB8h => 2.000 seconds ; nop padding effect on computed jump version with 9 padding above ; 0 puts fib on odd 16 byte boundary clk = 00D979792Dh => 1.042 seconds ; 16 puts fib on even 16 byte boundary clk = 00DA93E04Dh => 1.048 seconds rept 0 nop endm padx endp if 0 ;0 = loop version, 1 = computed jump version fib proc ;rcx == n mov r8,rcx ;set jmp adr mov r9,offset fib0+279 lea r8,[r8+r8*2] neg r8 add r8,r9 mov rax,rcx ;set rax,rdx mov rdx,1 and rax,rdx sub rdx,rax jmp r8 fib0: ; assumes add xxx,xxx takes 3 bytes rept 46 add rax,rdx add rdx,rax endm add rax,rdx ret fib endp else fib proc ;rcx == n mov rax,rcx ;br if < 2 cmp rax,2 jb fib1 mov rdx,1 ;set rax, rdx and rax,rdx sub rdx,rax shr rcx,1 fib0: add rdx,rax add rax,rdx dec rcx jnz fib0 fib1: ret fib endp endif end
https://cboard.cprogramming.com/tech-board/177912-intel-3770k-~35%25-time-difference-tight-loop-depending-location-other-cpus.html
CC-MAIN-2020-45
refinedweb
820
68.64
This function is deprecated. It determines if an attribute in an entry contains a specified value by comparing the specified value as a string with the existing values, and does not compare using the equality matching rule. #include "slapi-plugin.h" int slapi_entry_attr_hasvalue(Slapi_Entry *e, const char *type, const char *value); This function takes the following parameters: Entry that you want to check. Attribute type that you want to test for the value specified. Value that you want to find in the attribute. Returns one of the following values: 1 if the attribute contains the specified value. 0 if the attribute does not contain the specified value. value must not be NULL.
http://docs.oracle.com/cd/E19528-01/820-2492/aaige/index.html
CC-MAIN-2013-48
refinedweb
112
57.67
Who doesn’t like to use cheat codes every now and then when playing video games? They certainly make gaming simpler and more fun. In this tutorial, we are going to show you how to implement some cheat codes for Minecraft using Python, one of many programming languages. Materials - Raspberry Pi - SD Card - Mouse - Keyboard - HDMI Cable - USB 2.0(A Male to Micro B) If you do not already have these parts, then you can simply get this kit that includes all of the cables to get started with the Raspberry Pi: Raspberry Pi Setup The first thing that you need to do is install the operating system for the Pi. If your Pi already has an OS, then you can skip this section. Otherwise, follow the instructions under Operating System for the Raspberry Pi from this tutorial: New Game Once the Pi is ready to be used go to Menu > Games > Minecraft Pi > Start Game > Create New to generate a new world. Use the mouse to look around, and the following keys to move around and do stuff: Python Okay so now we are ready to start programming. First go to Menu > Programming > Python 3 (IDLE) to open a Python Shell. Hello World For testing purposes, let’s make “Hello World” appear on our screen by typing the following code in the Python Shell: from mcpi.minecraft import Minecraft mc=Minecraft.create() mc.postToChat(“Hello World”) You should get something like this: The first line imports the Minecraft library that contains the tools needed to interact with the game. The second line creates a connection between the Python shell and the game. The third line makes the text appear on our screen. You can change the text inside the parenthesis to whatever you want to display. Teleport Now that we know that it works, let’s teleport. In order to be able to teleport, we first need to know our location. When we look at the top left corner of our screen we can see three numbers labeled “pos.” Yes, this is our location in the form of x, y, z, where x and z are walking directions and y refers to the elevation of our character from the ground. Even though we know our position, Python doesn't know it. In order to make Python know where we are located in the map we can use the following command in the Python shell: x,y,z=mc.player.getPos() This command will store each value of our location in the variables x, y, and z. Now if we type x in the shell, we will get the x value that appears on our game screen. The same happens with y and z. Once Python knows our location, we can use the following command to set our new location: mc.player.setPos(x+10,y,z) In this example, we move 10 units to the front in the x direction. We can change the number to whatever number of units we want to advance. This also work for the y and z coordinates. Place Blocks To place a block you can simply use the following command: mc.setBlock(x+1,y,z,1) This places a new block one unit ahead of your current x location. We can see that besides the x, y, and z coordinates, we have a “1” in the argument of the function. In Python, each block is associated with a number. The number “1” is used to tell the program that we want to use stone. Go ahead and try different numbers to see what other blocks are created. Some blocks have special properties that allow you to modify the appearance of the block. For example, if we type the following command: mc.setBlock(x+1,y,z,35,1) An orange wool block is placed one unit ahead of your x position. In this case the number 35 is used to specify that we want a wool block, while the number 1 is used to specify the color of the block. Change the last parameter of the function to see what other colors are available. Some other special blocks are wood (17), grass (31), and torch (50). There are two alternative ways to select the block that we want to use. The first one is to assign the number that identifies a specific block to the actual name of the block, and then use it in the function: wool=35 mc.setBlock(x+1,y,z,wool,1) The second method is to import the following library at the beginning of your code: From mcpi import block This library contains the name of all the blocks, so you can just use their names instead of numbers like in this example: mc.setBlock(x+1,y,z,block.WOOL.id,1) Note that the name is of the form: block.NAME_OF_THE_BLOCK.id We are really just replacing “NAME_OF_THE_BLOCK” with the block’s name that we want to use. If you don’t know the name of the blocks, you can refer to the following link: You want to use the name that is after “minecraft:” exactly the way it is written but in caps. Multiple Blocks To set multiple blocks you can use the following command: stone=1 x,y,z = mc.player.getPos() mc.setBlocks(x+1,y,z+1,x+11,y+10,z+11,1) This creates a 10x10x10 stone cube. The function is telling the program to place a stone at location x+1 and keep filling with stones until it reaches location x+11. The same happens in the y and z directions. Now let’s say that we want to drop blocks as we walk. In the python shell click on File > New Window and type the following code: from mcpi.minecraft import Minecraft from time import sleep mc=Minecraft.create() flower=38 while True: x,y,z =mc.player.getPos() mc.setBlock(x,y,z,flower) sleep (0.1) Now click on Run > Run Module. You will be asked to save the script before being able to run it. Go ahead and save it wherever you want. After you save the script, it will run in the python shell. This is just another way of executing code without having to use the shell’s command line. So now everytime we walk, we leave a flower behind us. The second line of our code imports the library required to use delays, or pauses in the code such as sleep(0.1). Once the code reaches this function, it waits for 0.1s and then keeps executing. The “while True:” is called a while loop. This loop executes whatever code is inside it repeatedly when the value next to “while” is veridic. In this case the value is “True,” therefore the code will keep executing forever. Everything that is indented after “while True:” is considered to be part of the while loop, so this is the code that will be executed repeatedly. First we get our current position, and then we place a flower in that position. Next we wait for 0.1s and repeat the process. As we walk, our position coordinates will be updated every 0.1s, and flowers will be placed in all the locations we have been. If you want to stop dropping flowers everywhere you go, then just hit Ctrl+c. Now let’s drop blocks only when we are in a specific terrain such as grass. Follow the same procedure from the previous example to write the code in a new window and execute it in the shell: from mcpi.minecraft import Minecraft from time import sleep mc=Minecraft.create() grass=2 flower=38 while True: x,y,z = mc.player.getPos() block_beneath=mc.getBlock(x,y-1,z) if block_beneath==grass: mc.setBlock(x,y,z,flower) sleep(0.1) First we identify each block with their respective number. Then we open a while loop that will execute forever. Inside the while loop we get our current position and the id number of the block that we are standing on. The id number gets stored in a variable called “block_beneath.” Notice that we are using y-1 since all the blocks that we stand on are under us so we need to subtract 1 from our current y position. Then we open an if statement. This is a function that executes a part of the code only if “block_beneath,” which is the block id we are standing on, is equal to the block id of grass. When we want to check if one thing is equal to another, such as in this case, we have to use double equal signs “==.” If the case is true, we use the function mc.setBlock(x, y, z, flower) to place a flower in the current location. In other words, we are simply updating our location every 0.1s like in the previous example, and checking what blocks we are standing on. We are also constantly checking if the block we are standing on is grass. If it is not grass, then nothing happens. If it is grass, then a flower is placed in that location. There you go. Now you can use your coding knowledge in Python to make playing Minecraft a little bit easier and faster. If you have any questions about this tutorial, then please do not hesitate to leave a comment, contact us through email, or drop a line in our forum.
http://www.jayconsystems.com/tutorials/pythonprogramminecraft
CC-MAIN-2017-17
refinedweb
1,591
73.07
I’ve been busy working on the plumbing for what will become Builder 3.20. We have a really ambitious cycle ahead of us, so getting these core changes in place as soon as possible will help give us time to stabilize. From the early design phase of Builder, we knew we wanted multi-process plugins. Easier said than done. This cycle we are starting to follow through on that design goal by making it simple for plugins to achieve this. I just landed the multi-process plumbing and ported our Jedi auto-completion engine to use it. Previously we were using Jedi from Python threads. It would occasionally cause the main loop to stall (likely due to GIL) as we have plugins written in Python inside the UI. Now that the work is being done in a worker process, we simply receive a large GVariant of the result set from the worker process over a private GDBus connection. This allows us to allocate/free large memory chunks instead of so many small strings which is nice. There are still a lot of strings created when sizing the completion window, but we can address that later. Since we require GDBus, and PyGObject support for GDBus is not very convenient, we ported some of Martin Pitt’s work into the Builder G-I overrides. This means you can quickly create a GDBus service in Python with a few lines of code. It’s still not ideal, but again, we can iterate now. One thing I’d like to see is the ability to use yield to wait until an asynchronous operation completes. Python Twisted has been doing this for nearly a decade, and it’s quite pleasant to use. Also, we had to go out of our way to use GVariant from Python without unwrapping the variants. We want to avoid doing that until absolutely necessary. The next big step in multi-process is to port the clang and vala plugins to use the same plumbing. After that, we need to get the plugins to recycle when they hit various thresholds such as undue memory consumption. I think our story with plugins is going to become pretty compelling this cycle. Being able to write a single plugin that can take advantage of multiple-processes without destroying your code is an area where we can really shine above the competition. I’ve also started work on distributing Builder as an Xdg-App. We have some unique constraints that will help us push Xdg-App to support some very difficult corner cases. Psuedo terminal support landed last week, so the terminal now works. Although, your terminal is inside of the mount namespace, so it won’t match your host system. That might feel a bit odd at first. Additionally, we need to come up with a good design that allows Builder to run in one xdg-app, while building/running/testing your application from another xdg-app/runtime/sdk. As always, lots to do! If you are interested in contributing to Builder or Xdg-App, this is a great time to get started! Come join us on irc.gimp.net in #gnome-builder and we’ll find a way for you to contribute.
https://blogs.gnome.org/chergert/author/chergert/page/11/
CC-MAIN-2018-34
refinedweb
540
72.16
IMAP network mailbox. More... #include "config.h" #include <limits.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "imap_private.h" #include "mutt/mutt.h" #include "config/lib.h" #include "email/lib.h" #include "core/lib.h" #include "conn/conn.h" #include "gui/lib.h" #include "mutt.h" #include "imap.h" #include "auth.h" #include "commands.h" #include "globals.h" #include "hook.h" #include "message.h" #include "mutt_account.h" #include "mutt_logging.h" #include "mutt_socket.h" #include "muttlib.h" #include "mx.h" #include "pattern.h" #include "progress.h" #include "sort.h" #include <libintl.h> Go to the source code of this file. IMAP network imap.c. Make sure we can log in to this server. Definition at line 76 of file imap.c. Make a simple list out of a FLAGS response. return stream following FLAGS response Definition at line 103 of file imap.c. append str to flags if we currently have permission according to aclflag Definition at line 158 of file imap.c. Make a message set. Definition at line 179 of file imap.c. Compare local flags against the server. The comparison of flags EXCLUDES the deleted flag. Definition at line 279 of file imap.c. Sync flag changes to the server. Definition at line 304 of file imap.c. Perform a search of messages. Count the number of patterns that can be done by the server (are full-text). Definition at line 342 of file imap.c. Convert NeoMutt pattern to IMAP search. Convert neomutt Pattern to IMAP SEARCH command containing only elements that require full-text search (neomutt already has what it needs for most match types, and does a better job (eg server doesn't support regexes). Definition at line 384 of file imap.c. Find longest prefix common to two strings. Trim dest to the length of the longest prefix it shares with src. Definition at line 493 of file imap.c. Look for completion matches for mailboxes. look for IMAP URLs to complete from defined mailboxes. Could be extended to complete over open connections and account/folder hooks too. Definition at line 514 of file imap.c. Create a new mailbox. Definition at line 575 of file imap.c. Check permissions on an IMAP mailbox with a new connection. TODO: ACL checks. Right now we assume if it exists we can mess with it. TODO: This method should take a Mailbox as parameter to be able to reuse the existing connection. Definition at line 601 of file imap.c. Rename a mailbox. Definition at line 616 of file imap.c. Delete a mailbox. Definition at line 643 of file imap.c. Gracefully log out of server. Definition at line 663 of file imap.c. close all open connections Quick and dirty until we can make sure we've got all the context we need. Definition at line 688 of file imap.c. Read bytes bytes from server into file. Not explicitly buffered, relies on FILE buffering. \rfrom \r\n. Apparently even literals use \r\n-terminated strings ?! Definition at line 724 of file imap.c. Purge messages from the server. Purge IMAP portion of expunged messages from the context. Must not be done while something has a handle on any headers (eg inside pager or editor). That is, check IMAP_REOPEN_ALLOW. Definition at line 782 of file imap.c. Open an IMAP connection. Definition at line 853 of file imap.c. Close an IMAP connection. Definition at line 943 of file imap.c. Does the flag exist in the list. Do a caseless comparison of the flag against a flag list, return true if found or flag list has '*'. Definition at line 966 of file imap.c. Compare two Emails by UID - Implements sort_t. Definition at line 987 of file imap.c. Prepare commands for all messages matching conditions. pre/post: commands are of the form "%s %s %s %s", tag, pre, message set, post Prepares commands for all messages matching conditions (must be flushed with imap_exec) Definition at line 1010 of file imap.c. Update server to reflect the flags of a single message. Update the IMAP server to reflect the flags for a single message before performing a "UID COPY". Definition at line 1088 of file imap.c. use the NOOP or IDLE command to poll for new mail Definition at line 1190 of file imap.c. Refresh the number of total and new messages. Definition at line 1256 of file imap.c. Check the Mailbox statistics - Implements MxOps::mbox_check_stats() Definition at line 1299 of file imap.c. Refresh the number of total and new messages. Definition at line 1310 of file imap.c. Refresh the number of total and new messages. Definition at line 1336 of file imap.c. Find a matching mailbox. Definition at line 1352 of file imap.c. Definition at line 1391 of file imap.c. Try to complete an IMAP folder path. Given a partial IMAP folder path, return a string which adds as much to the path as is unique Definition at line 1448 of file imap.c. Use server COPY command to copy deleted messages to trash. Definition at line 1526 of file imap.c. Sync all the changes to the server. Definition at line 1634 of file imap.c. Find an Account that matches a Mailbox path - Implements MxOps::ac_find() Definition at line 1836 of file imap.c. Add a Mailbox to an Account - Implements MxOps::ac_add() Definition at line 1859 of file imap.c. Definition at line 1911 of file imap.c. Open an IMAP connection. Ensure ImapAccountData is connected and logged into the imap server. Definition at line 1940 of file imap.c. Open a mailbox - Implements MxOps::mbox_open() Definition at line 2004 of file imap.c. Open a Mailbox for appending - Implements MxOps::mbox_open_append() Definition at line 2200 of file imap.c. Check for new mail - Implements MxOps::mbox_check() Definition at line 2234 of file imap.c. Close a Mailbox - Implements MxOps::mbox_close() Definition at line 2251 of file imap.c. Open a new message in a Mailbox - Implements MxOps::msg_open_new() Definition at line 2293 of file imap.c. Prompt and validate new messages tags - Implements MxOps::tags_edit() Definition at line 2318 of file imap.c. Save the tags to a message - Implements MxOps::tags_commit() This method update the server flags on the server by removing the last know custom flags of a header and adds the local flags If everything success we push the local flags to the last know custom flags (flags_remote). Also this method check that each flags is support by the server first and remove unsupported one. Definition at line 2407 of file imap.c. Is this an IMAP Mailbox? - Implements MxOps::path_probe() Definition at line 2474 of file imap.c. Canonicalise a Mailbox path - Implements MxOps::path_canon() Definition at line 2491 of file imap.c. Buffer wrapper around imap_path_canon() Definition at line 2520 of file imap.c. Abbreviate a Mailbox path - Implements MxOps::path_pretty() Definition at line 2529 of file imap.c. Find the parent of a Mailbox path - Implements MxOps::path_parent() Definition at line 2541 of file imap.c. IMAP Mailbox - Implements MxOps. Definition at line 2554 of file imap.c.
https://neomutt.org/code/imap_8c.html
CC-MAIN-2020-05
refinedweb
1,200
71.71
START LEARNING FLASH NOW Get instant access to over 45 minutes of FREE Flash tutorials on video and our newsletter. . Create a new Fla. Open the StandardComponent.fla from the C:/Program FilesMacromedia/Flash 8/enConfiguration/ComponentFLA folder. Drag the UIComponent from the StandardComponent.fla library to your new fla library. Its in the Base Classes/FUIComponent Subclasses folder. Create new empty MovieClip. name it widget. Give it the linkage identifier of widget. In the Class box , name the class, Widget. Make sure it is exported for Actionscript and do not tick export in first frame. Open the Component Definitio window and specify the Class name, Widget. In the widget movieclip, create a new frame , call it actions and put the code Flash Tutorials in Video Format - Watch them now at LearnFlash.com stop(); on it. Create a new layer and put a bounding box on it in frame 1. call it boundingBox_mc. Make sure the position of it is (0,0). The bounding box sets the renderable area that the component can use. It needs to be there at authoring time, or else the component cant draw to the stage. Create a layer called assets. Create a second keyframe on that layer only. Drag the UIComponent from the libray onto the stage at frame 2 on the Assets layer. This is because it allows the base classes to be exported when we package them. But the timeline never reaches them. Now we create our Widget class. Go, New - ActionScript File. The AS text editor will open. Start creating your class. init method is used to initialize the component. The bounding box is made invisible and size set to 0. If you are extending the MovieClip class, and not the UIComponent superclass, then you may need to initialize an EventDispatcher instance. createChildren() method attaches and creates objects. draw() method draws and resizes objects within the component. To add parameters to the Component Inspector Panel, then use the [Inspectable] metatag before setter and getter methods. import mx.core.UIComponent; class Widget extends UIComponent{ // static variables required for createClassObject() static var symbolName:String = "Widget"; static var symbolOwner:String = "Widget"; // declare a bounding Box private var boundingBox_mx:MovieClip; // declare a class variable private var myLabel:String; // Constructor function Widget(){} // overwrite the superclass UIComponent init method private function init():Void{ // call superclass init method super.init(); // hide bounding box and make it size 0 boundingBox_mc._visible = false; boundingBox_mc._width = 0; boundingBox_mc._height = 0; } // used to attach movieclips, overwrites super method, only used once. private function createChildren():Void{ } // called every time component is invalidated private function draw():Void{ // change layout, sizes etc } // to resize our component, invalidates and calls draw method private function size():Void{ invalidate(); } // getters and setters. // Inspectable metatag allows properties to be accessed via the components Property Inspector [Inspectable] function set label(text:String):Void{ myLabel = text; } function get label():String{ return myLabel; } } That is only the very basic outline of a standard class for a component. Add to it for your own component.. .
http://www.video-animation.com/flash8_003.shtml
crawl-001
refinedweb
502
60.31
January 22, 2019 by Artur GraphQL is a query language for APIs that was originally built by Facebook. Its biggest advantage is making a lot easier to get the data you actually need from a query. Today we will show you how to set up MongoDB with GraphQL. First you need to install a Homebrew. To do it go to Visual Code Studio and run this line from Brew.sh: /usr/bin/ruby -e "$(curl -fsSL)" Now you should have your Homebrew installed. If you had it already installed, we suggest to do a brew update before proceeding, then you can install MongoDB: $ brew update $ brew install mongo What you need to do now is to go to a root directory, create the directory for the database and set its permissions, then you can star Mongo: $ sudo mkdir -p /data/db $ sudo chmod 777 /data/db $ mongod Et voila! We have it installed and running. Mongoose provides a straight-forward, schema-based solution to model your application data. It includes: So let’s install Mongoos. Make sure you are in the right directory and use $npm install: $ npm install --save mongoose Create a new folder and move your resolvers.js and schema.js files there. Remember to update your index.js file to make sure everything will be correctly imported here. Once we have it done we can create a new file in our fresh folder which we will use to connect Mongo to our databases, let’s call it connect.js. import mongoose from 'mongoose'; mongoose.Promise = global.Promise; mongoose.connect =('mongodb://localhost/users', { useMongoClient: true }); When we have it done we can start creating our schema for Mongo with the same elements as our original schema. const usersSchema = new mongoose.Schema({ name: type: String } }) The next important step is to create a value to our variable with that model inside, passing the schema and export: const Users = mongoose.model('users', usersSchema) export {Users}; Now let’s create some GraphQL resolvers. So let’s go to resolvers.js and start with importing Mongoose and Users into resolvers: import mongoose from 'mongoose'; import { Users } from './connect'; export const resolvers ={ Query: { getUser: ({id}) => { return new User (id, userDatabase[id]); }, }, Mutation: { createUser: (root, { input}) => { const newUser = new Users({ name: input.name, }); newUser.id = newUser._id; return new Promise((resolve, object)) => newUser.save((err) => { if (err) reject (err) else resolve(newUser) }) }) }, }, }; In next part we will create nodejs GraphQL server. Stay tuned! Do you want to try our mock backend from GraphQL app. It is in beta phase and 100% free.
https://blog.graphqleditor.com/installing-graphql-to-mongo/
CC-MAIN-2019-26
refinedweb
428
65.62
hi, I'm trying to optimize the inverse function of my maths lib. I already implemented everything using sse, I'm now trying to validate it works, and make sure it's faster... well most of the time it's really great, I get 5-10x speedups everywhere, except in the mat4 inverse function. code here: (line 397) here's the testcase: #include "mymath/mymath.h" #include "SFML/System.hpp" int main( int argc, char** args ) { using namespace mymath; using namespace std; sf::Clock clock; mat4 m1; int size = 4; for( int x = 0; x < size; ++x ) for( int y = 0; y < size; ++y ) m1[x][y] = atoi( args[x * size + y + 1] ); clock.restart(); for( int c = 0; c < 10e6 + 1; ++c ) m1 = inverse( m1 ); cout << clock.getElapsedTime().asMilliseconds() * 0.001f << endl; cout << m1 << endl; return 0; } with sse enabled I get 5 seconds execution time, without I get only 1 second. So I tried to look at it what is causing this. I used objdump to grab the assembly of the exes. without sse (line 393): with sse (line 763): as you can see when I disable the sse functionality the compiler somehow recognizes the optimization opportunities, and does way better job at generating efficient code. If you look at the sse version you can see that it's poor assembly code with lots of non-sse functions that hinder speed. any idea what am I doing wrong? ps.: I'm not that good at assembly I can barely read it. I think the 'without sse' code is better because there are no non-sse instructions called. ps2.: I have no idea why the compiler isn't inlining the inverse function, and why did it compile other functions into the exe, even though they're not even used. I used 64 bit 12.04 linux (3.2.0-58-generic), gcc 4.6.3 with "-O3 -Wall -Wno-long-long -ansi -pedantic -std=c++0x" objdump for getting the assembly best regards, Yours3!f Edited by Yours3!f, 29 January 2014 - 03:33 PM.
http://www.gamedev.net/topic/652801-mat4-inverse-sse-optimization/
CC-MAIN-2016-18
refinedweb
346
74.19
testing my java applications using jython. I would like to know how a java method which returns an primitive array be used in jython eg) say my java method is public int[] read() I want to do something like this from jarray import array arr = read() # I am not able to do this print arr thanks vasanthi On Tue, Sep 04, 2001 at 05:08:15PM +0100, Vasanthi, N (Nagalingam) wrote: | Hi, | I am testing my java applications using jython. I would like to know | how a java method which returns an primitive array be used in jython | eg) say my java method is | public int[] read() But this is in Java so it *must* be in some sort of class. This signature doesn't include "static" so you need to have an instance of the class to invoke the method on. | I want to do something like this | from jarray import array This line isn't needed. You only need to use the jarray module if you want to create a new array from jython code. | arr = read() # I am not able to do this This line tries to find an object named "read" first in the local scope of the function it is in then in the scope of the module it is in, then checks the builtins. There is no such object so the lookup fails. As noted above, you need to create an instance of the java class so that you can invoke the method on it. HTH, -D I agree to receive quotes, newsletters and other information from sourceforge.net and its partners regarding IT services and products. I understand that I can withdraw my consent at any time. Please refer to our Privacy Policy or Contact Us for more details
https://sourceforge.net/p/jython/mailman/message/7577709/
CC-MAIN-2016-44
refinedweb
296
74.12
C <stdio.h> - feof() Function The C <stdio.h> feof() function checks if the end-of-file indicator associated with the file stream is set. It returns a non-zero value if it is set, else returns 0. The error indicator are generally set by a previous operation on the stream that attempted to read at or past the end-of-file. The indicator gets cleared by calling function like clearerr, rewind, fseek, fsetpos or freopen. Although if the position indicator is not re-positioned by such a call, the next i/o operation is likely to set the indicator again. Syntax int feof (FILE * stream); Parameters Return Value Returns non-zero value if the end-of-file indicator associated with the file stream is set, else returns 0. Example: Lets assume that we have a file called test.txt. This file contains following content: This is a test file. It contains dummy content. In the example below, file is opened using fopen() function. If the return value of calling getc() function is not EOF, it starts reading characters the file one by one and writes the characters to output stream until end-of-file is not reached. #include <stdio.h> int main (){ //open the file in read mode FILE *pFile = fopen("test.txt", "r"); //first character in the file int c = getc(pFile); //if first character is not EOF, reads //and writes characters from the file //until end-of-file is not reached if (c != EOF) { while(!feof(pFile)) { putchar(c); c = getc(pFile); } } //close the file fclose(pFile); return 0; } The output of the above code will be: This is a test file. It contains dummy content. ❮ C <stdio.h> Library
https://www.alphacodingskills.com/c/notes/c-stdio-feof.php
CC-MAIN-2021-43
refinedweb
283
63.7
Details - Type: Bug - Status: Open (View Workflow) - Priority: Critical - Resolution: Unresolved - - - Similar Issues: Description Karls Summary: Polled builds (pipeline) should sync to "@now" when polling occurred not "@now" when sync occurs. Usage case - On a busy system a long running job will pickup components of different ages. Example - - Poll finds latest change 123 - Build is queued - Change 124 added to path1. - Build starts - Path1 synced at 124 - Change 125 and 126 submitted to path2. - Path1 sync completes, path2 sync starts at 126 The desired behavior is path1 and path2 should be synced at 123 (if that is not possible in the Jenkins infrastructure path 1 and path2 should be synced at 124). Original Description: HI we have setup a parallel pipeline and are using SyncOnlyImpl's pin to ensure all parallel stages will build on the same changelist. Our first implementation worked as expected. pin value was empty at first, causing it to sync to head then we extracted this value and propagated to other stages through a field. However other requirements required us to have that change be accessible in other parts of the build pipeline so we start the pipeline with a simple p4 command to get the head CL which is then propagated through the rest of the pipeline normally rather than through a field. Sync behavior is as expected where all stages sync to desired CL BUT polling is now limited by this pin value and will always check for changes using the pinned value as an upper limit. Net effect if this is polling still takes place but never detect any changes effectively nullifying poll behavior beyond the first run. I would expect a way to sync to a specific CL that has no side effect in other parts of the system. Either the pin behavior is broken, or an extra parameter is required beyond pin to separate the two intent : the CL at which we wish to "pin" this job, and the CL at which we wish to sync in the populate implementation. Attachments Activity Hi Eric Daigneault - Ignore that. Disabling implicit doe not change the behavior. P4Jenkins will only build if there is something to sync. This is intended because 'pin' is normally used with a build label and you only need to rebuild if the build label has changed. You dont want a job building if the label has not been updated. If I have two 'p4sync' steps in my pipeline script and only one of them is pinned the job will still build. From the polling log: # Pinned at 4262 P4: Polling with range: 4262,4262 ... p4 changes -m20 //jenkins-master-PinPolledPipeline-Source-TEST/...@4262,4262 ... p4 repos -C P4: Polling no changes found. # Not pinned P4: Polling with range: 4274,now ... p4 changes -m20 //jenkins-master-PinPolledPipeline-Source-TEST-FILES/...@4274,now ... p4 change -o 4276 ... found change: 4276 If after reading this you think its still not working as described please provide me more information about how you strcture everything. Are you syncing any new code in the job? Do you have multiple jobs or just steps? How are they connected to each other? Can you provide me the code? If it is working as described the workaround would be to trigger the jobs from perforce instead of using polling. Our pipeline resembles this pseudo seen below. The code is over-simplified and will likely not run as-is but it does give the essential of what is happening. Basically here we need to ensure that all stages in the parallel to build at the same CL. By default each will sync to head at the time they start, since each gets assigned to a different agent it's quite possible one or more is put in the queue to wait for available resources. During that time it's very likely that new commits occur thus having them all sync to head creates a "staggered" build across multiple changes which is undesirable. We used to do it in the way you suggests where one is not pinned, we struggled a bit to get the information across other stage but eventually made it work. however getting that changelist ID to propagate to other steps prooved to be challenging and it became much simpler to just fetch the change eagerly and pass it along the entire pipeline. Now we have averything working just dandy and all other steps that need access to the changelist can do so naturally... except polling no longer work because of this side effect. And since there are no obvious alternative ways to sync through the plugin that would not generate this side effect we are basically stuck. Temporary solution was to change the polling with a cron and force trigger the job each 30 mins or so. We experimented with perforce triggers and ran in another issue. Since the changelist is not (least wasnot at the time we tried) attached to the job being triggered we ran in situations where each commit woudl trigger a job but build system restrictions caused long queues. To make things worst when a job started it would pick head CL thus many jobs ended running at the same CL because of this which was very wasteful use of resources. Last thing we had not tried yet was to simply do without the populate and run the p4 sync directly with a p4.run. def pinnedchangelist = p4.run("changes", "-s", "submitted", "-m1", "${stream_location}/...")[0]['change'] pipeline{ options{ skipDefaultCheckout() } parallel{ stages{ stage('someplatform'){ agent('able-tagged'){} step('sync'){ //see below for actual code } step('build'){ /// } } stage('someotherplatform'){ agent('able-tagged'){} step('sync'){ //see below for actual code } step('build'){ /// } } stage('yetanother'){ agent('able-tagged'){} step('sync'){ //see below for actual code } step('build'){ /// } } } } } the steps sync contains this code which does the actual sync def popImpl = [$class: "SyncOnlyImpl", force: needs_force_sync(config), have: true, modtime: true, parallel: null, pin: pinnedChangelist, quiet: false, revert: false] echo "== Workspace preparation complete, performing a sync ${popImpl}" checkout([ $class: 'PerforceScm', credential: "${config.p4_credential}".toString(), populate: popImpl, workspace: ws ]) Edit: added skipDefaultCheckout() in option block at start of pipeline reformat pipeline code Hi Eric Daigneault - A quick aplogy. I owe you a response on this one but I'm still working on it. Will get back to you when I have something. Hi Karl Wirth & Eric Daigneault Karl, for general context on how we are currently doing parallel builds & enforcing all parallel machines are synced to the same CL for a given build see this blog post from Riot Games, under the "Multiple Syncs in A Pipeline" section of the article: That's the core idea of what we're currently doing succesfully (with some tradeoffs and limitations that Eric is working on tackling with what he describes above). Run a job with multiple seperate syncs occuring on parallel job parts & ensure they all sync to the same CL regardless of whether new CLs come into Perforce before some of the parallel parts begin (ex: waiting on an available agent). Apologies for the tangent but it gives an idea of what we're aiming for in a broader sense. Cheers. I resolved the same problem by creating a separate polling pipeline, which just does the polling, and triggers the main pipeline with: build(job: 'main_pipeline_job', wait: false) Hi Eric Daigneault - Please get me your pipeline code so I can test here. I'm wondering if disabling implicit sync may be a workaround.
https://issues.jenkins.io/browse/JENKINS-63879
CC-MAIN-2021-04
refinedweb
1,243
67.18
List is an ordered collection and can contain duplicate elements. You can access any element from its index. List is more like array with dynamic length, List is one of the most used Collection type. Similar to library the list collection also stores the objects based on the index number, and it can also store duplicate objects as the access is going to happen through index. List is a interface, and it just provides what should be present if somebody implements the interface, so the list interface will not have any implementations. ArrayList and LinkedList classes provide implementation to the List interface methods, the methods present in the ArrayList and LinkedList are same with little changes There are few frequently used methods in java list, I would be discussing them: This method adds an element/value into the list based on the index. Here the index is calculated automatically based on the number of existing elements In below code, String value will be stored as Object type only and the value will be stored at the last position in the list. obj.add("karthiq") This add method adds the given value and accepts two parameter; one the index where you want to add the value, two Object O is the value to be added. You will face obj.add(2, boolean) Remove method is overloaded method, There are two remove() methods in List. First remove method accepts a index of int type and removes a object at the given position., Second remove() method accepts value of object type and removes the value by searching the total list one by one till it finds the matching element. After removing an element, the element after that index will move one step closer to the beginning of the list. obj.remove(int index) // faster obj.remove(Object o) // slower set method updates the element value at a given index, set method doesnot return any value. obj.set(4, "karthiQ") // sets element at index 4 to "karthiQ" indexOf method retrieves the index of the first matching object o. If the element is not found in the list then this method returns the value -1. indexOf method returns int values obj.indexOf("karthiQ") get fetches the value at a given position, returns Object value. obj.get(2); // retrieves the value at position 2 size() method works based on the number of elements in the list. The size() method returns the counter , so we would have the number of elements present in the list as output. size() method returns int value. obj.size(); // total number of elements in the list contains() method checks whether the given element is present in the list or not. If element is present then contains() method results in true otherwise false obj.contains("karthiQ"); clear() method is used for removing all the elements of the list in one go, this will not delete the list but elements in the list. Complete program for the list operations.Complete program for the list operations. obj.clear(); package cherchertech; import java.util.ArrayList; import java.util.List; public class OverLoading { public static void main(String[] args) { List al = new ArrayList(); al.add("chercher tech"); al.add(true); al.add(10); al.add(new ArrayList()); System.out.println("value at index 2 before Adding value at 2 : " +al.get(2)); al.add(2, 20); System.out.println("value at index 2 after Adding value at 2 : " +al.get(2)); al.remove("chercher tech"); // based on object System.out.println("All values in list : " +al); al.remove(1); // based on index System.out.println("All values in list : " +al); al.set(1, "eee"); System.out.println("Value at index 1 :" +al.get(1)); System.out.println("index of avengers (none present): "+ al.indexOf("Avenger")); System.out.println("get the value at index 0 " +al.get(0)); System.out.println("Number of elements present in the list : "+al.size()); System.out.println("does list contains 'eee' : "+al.contains("eee")); al.clear(); System.out.println("Elements present in list after clearing the list :" +al ); } } Output of the above program is : value at index 2 before Adding value at 2 : 10 value at index 2 after Adding value at 2 : 20 All values in list : [true, 20, 10, []] All values in list : [true, 10, []] Value at index 1 :eee index of avengers (none present): -1 get the value at index 0 true Number of elements present in the list : 3 does list contains 'eee' : true Elements present in list after clearing the list :[] Arraylist class stores the data in an one-dimentional array of java.lang.Object type. Below is the piece of declaration from the ArrayList class: private transient Object[] elementData; All the addition, removal and traversal happens on this array. Initial size of ArrayList is 0. Size of ArrayList is the number of elements it has. It is different from length of the underlying Array. If we are using constructor with argument, then the size of underlying array will be the integer number we are passing as the argument to the constructor. YES. As stated above, ArrayList provides a constructor with argument where we can provide the initial length of the underlying array. public ArrayList (int paramInt) Well, initial or default capacity of ArrayList is 10. Again, see the code excerpt from the ArrayList class which confirms the same: private static final int DEFAULT_CAPACITY = 10; In this case, size of array becomes 10 for the first insertion into the ArrayList. Well, we will discuss the complete logic when we will discuss grow(). The length of underlying array becomes 10. Here is the code excerpt of ArrayList’s add method: public boolean add(E paramE) { ensureCapacityInternal(this.size + 1); this.elementData[(this.size++)] = paramE return true; } First, it ensures the capacity of underlying array, if it can accomocate the ArrayList after adding the current element. For first element, size of arraylist will become 1, so it will ensure the underlying array to be able to accomodate 1 element. Now, let’s see how it ensures that: private void ensureCapacityInternal(int paramInt) { if(this.elementData == EMPTY_ELEMENTDATA) paramInt = Math.max(10,paramInt); ensureExplicitCapacity(paramInt); } if condition above will work only if the ArrayList is constructed from default constructor and we are adding the first element. In other words, if ArrayList is constructed from argumented constructor OR we have already added an element, above if condition will skips. Why? Because, at the time of default constructor, EMPTY_ELEMENTDATA is assigned to elementData array. private static final Object[] EMPTY_ELEMENTDATA = new Object[0]; public ArrayList(){ this.elementData = EMPTY_ELEMENTDATA } Now, the call goes to ensureExplicitCapacity with argement paramInt. Suppose of paramInt as the ‘wanted size’. First insertion with default constructor, paramInt=10. private void ensureExplicitCapacity(int paramInt) { this.modCount+=1; if(paramInt-this.elementData.length<<=0) { return; } grow(paramInt); } if condition above means that if size of the underlying array is greater than ‘wanted size’, the return (do nothing). If not, then GROW. First insertion with default constructor if (10 -0) <=0 => false. GROW. Here is the grow(), in case it goes for grow: private void grow(int paramInt){ int i = this.elementData.length; int j = i+ (i>>1); if(j-paramInt <0) j=paramInt; if(j-2147483639 >0) j=hugeCapacity(paramInt); this.elementdata = Arrays.copyOf(this.elementData,j); } i is size of underlying array. First insertion with default constructor i=0; j is the target size of underlying array. j is 1.5 times i. How? When left shift of 1 will make a number half. i>>1 will make i/2. j= i+i/2 = 1.5i First insertion with default constructor j = 0. if(j-paramInt %lt0) says that if target is still short of wanted size then make make the target size = wanted size. First insertion with default constructor j= 10 Then it checks for MAX Size to which an array could possibly grow. hugeCapacity(), increases the size by 8 of MAX_SIZE. 2147483639. Huge Capacity makes it upto 2147483647. ArrayList uses Arrays.copyOf() to copy the current data to new Array. This function return the array with new size. Internally, Arrays.copyOf() calls System.arraycopy() which is a native function. NO. Length remains same. Target data gets removed and data gets shifted. That’s all. We can initialize an Arraylist in multiple ways, we will learn widely used methods in here: We can convert the Normal Arryas into Arraylists, this method will be useful when we want to grow the Array of elements. ArrayList obj = new ArrayList (Arrays.asList(Object obj1, Object obj2, Object obj3, ....so on)); Full code for converting Array into ArrayList: public static void main(String args[]) { ArrayList obj = new ArrayList<String>(Arrays.asList("google", "chercher tech", "bing")); System.out.println("Elements Present in ArrayList are :"+obj); } We can form an Arraylist using inner class in Arraylist class. public static void main(String[] args) { ArrayList languages = new ArrayList (){{ add("Java"); add("Python"); add("Typescript"); add("Ruby"); }}; System.out.println("Arraylist Elements are:"+languages); } We can create and initialize the Arraylist of elements with same values using Collections.ncopies method, in this way all the Arraylist elements will have only one value. In below example an Arraylist with 3 elements will be crated with values of '1' public static void main(String[] args) { ArrayList<Integer> list = new ArrayList<Integer>(Collections.nCopies(3, 1)); System.out.println("ArrayList items using nCopies: "+list); } We can sort the elements in any collection using public static void main(String args[]){ ArrayList<String> allElements = new ArrayList<String>(); allElements.add("one"); allElements.add("two"); allElements.add("three"); allElements.add("four"); // Unsorted List System.out.println("***Before Sorting***"); for(String element: allElements){ System.out.println(element); } // Sort statement Collections.sort(allElements); // Sorted List System.out.println("***After Sorting***"); for(String element: allElements){ System.out.println(element); } } output of the sorting program ***Before Sorting*** one two three four ***After Sorting*** four one three two We donot have methods to reverse a ArrayList, but we have method to reverse an Arraylist. Are you able to figure out now, how we can reverse the Arraylist. Yes, Your guess is right: Sort the Arraylist(sorts in ascending order), now reverse the Sorted Arraylist, you will descending Arraylist. TADA. public static void main(String[] args) { ArrayList<String> counts = new ArrayList<String>(); counts.add("One"); counts.add("Two"); counts.add("Three"); counts.add("Four"); /*Unsorted List: ArrayList content before sorting*/ System.out.println("===Before Sorting==="); for(String str: counts){ System.out.println(str); } /* Sorting in decreasing order*/ Collections.sort(counts, Collections.reverseOrder()); /* Sorted List in reverse order*/ System.out.println("===ArrayList in descending order==="); for(String str: counts){ System.out.println(str); } } output of descending program. ===Before Sorting=== One Two Three Four ===ArrayList in descending order=== Two Three One Four List stores the element based on the insertion order, but you can shufffle the List. Call the shuffle() static method from the Collections class in Java.Util. public static void main(String[] args) { ArrayList list = new ArrayList (); list.add("Movie"); list.add("Theatre"); list.add("Watch"); Collections.shuffle(list); System.out.println("Elements order after Shuffle :"); for(String str: list){ System.out.println(str); } } Output of the shuffle program. Elements order after Shuffle : Watch Theatre Movie Using subList method we can copy few elements from original ArrayList to sub Arraylist in Java. It excludes the upper limit value, in below example it will copy elements from 0 to 1 but it will exclude upper limit 2. public static void main(String[] args) { ArrayList list = new ArrayList (); list.add("Movie"); list.add("Theatre"); list.add("Watch"); list.add("Avenger"); List abc = list.subList(0, 2); System.out.println("Full ArrayList : "+list); System.out.println("Partial ArrayList : "+abc); } Output of the sub ArrayList program. Full ArrayList : [Movie, Theatre, Watch, Avenger] Partial ArrayList : [Movie, Theatre] We can compare Lists using for loop, but before going through the loop we have to check the number of elements in each of them, if the list size mismatches then we can say bot are not same. public static void main(String[] args) { ArrayList<String> listOne = new ArrayList<String>(); listOne.add("Movie"); listOne.add("Theatre"); listOne.add("Watch"); listOne.add("Avenger"); ArrayList<String> listTwo = new ArrayList<String>(); listTwo.add("Movie"); listTwo.add("Theatre"); listTwo.add("Watch"); listTwo.add("Avengers Infinity War"); boolean flag = true; if(listOne.size() == listTwo.size()) { for (int i = 0; i < listOne.size(); i++) { if(listOne.get(i).equals(listTwo.get(i))) { System.out.println("Elements are same"); }else { flag=false; System.out.println("Element at position "+i+ " " + "are not same value 1 >"+ listOne.get(i) +" value 2> "+listTwo.get(i)); } } } else { System.out.println("Whatt, both are not"); } if(flag) { System.out.println("*******************Lists are same"); }else { System.out.println("*******************Lists are not same"); } } Output of the List comparison Elements are same Elements are same Elements are same Element at position 3 are not same value 1 >Avenger value 2> Avengers Infinity War *******************Lists are not
https://chercher.tech/java/arraylist
CC-MAIN-2019-13
refinedweb
2,151
50.23
Typesetting with groff Macros Groff has a set of about 50 predefined variables called number registers. These are the internal gauges of groff's typesetting machinery. While processing an input file, groff maintains these registers with the current value of such variables as page number, position on page and point size. Number registers are in a separate namespace from strings and macros, and are aliased with their own alias command, as in the following: .ALIAS ALIASNR aln.ALIASNR _PTSIZE .s .ALIASNR _LEADING .v In this example, we first alias the command for aliasing numbers, adapting the methodology we used earlier. Then, we alias the read-only registers for the current point size and vertical line spacing, choosing to use the traditional typesetting terminology—“leading”—for the latter. Although not required, the above example also demonstrates the use of a specific convention we follow, to prefix aliases for system variables with an “_” (underscore character). You can, of course, follow your own heart in these matters. But the use of a naming convention may help to distinguish the variables themselves from the names of the commands that set the variables, such as: .ALIAS PTSIZE ps.ALIAS LEADING vs These might be used in a macro as follows: .MACRO <fontsize:> __END__. PTSIZE \\$1 . IFELSE "\\$2"" \{\ . LEADING ( \\n[_PTSIZE]u * 120/100 ) . \} . ELSE \\{\ . LEADING \\$2 . \} .__END__With usage in a document: .<p>A message to the world: .<p> .<fontsize:> 18p Is groff great or what?The first line of the macro sets the current point size to the value of the first argument to the macro. The second line introduces a compound if/else statement, using groff's string comparison syntax for the logical test. If the second argument is empty, the leading is set by taking the value of the point size now in the numeric register _PTSIZE, and increasing it by 20%. Otherwise, the leading is set to the value provided by the second argument. Parentheses in a numeric expression permit the use of spaces within the expression. Otherwise, in the example above, we would need to use the less legible form without any spaces: .LEADING \\n[_PTSIZE]u*120/100 Numeric expressions are evaluated simply left to right, there are no operator precedence rules, and parentheses are required to explicitly change the order of evaluation. All arithmetic operations and number registers are ultimately integer based. Groff internally translates all dimensional measurements into machine units (based on 72,000 units per inch for PostScript devices), providing a functional “illusion” of fractional dimensions and point sizes. This allows us to specify decimal terms such as 8.5i and 11.5p, which, in fact, evaluate to 612,000 and 11,500 machine units respectively. Numeric values can be specified in any of the units shown in Table 1. In practice, groff's internal use of integral math can have significant consequences for the macro developer. Consider what would happen if the expression above were instead stated: .LEADING (\\n[_PTSIZE]u * (120/100)) Using integer division, the parenthetical term of 120/100 would evaluate to one and the entire expression would then evaluate to the current point size, and not 20% larger as intended. As it turns out, not all predefined number registers are, in fact, numeric. For example, the name of the current file being processed is in the read-only register .F: .ALIAS MESSAGE tm.ALIASNR _LINE .c .ALIASNR _FILE .F .MESSAGE Currently processing file \n[_FILE], line \n[_LINE]. Although both variables are evaluated using the syntax for number registers, _FILE returns the name of the current file as a string. Despite this anomaly, groff permits only numeric expressions in user-defined number registers. The example here, by the way, is one means of inserting debugging messages in your macro file during development. The .tm request—aliased above to .MESSAGE—sends any text that follows to the standard error stream. Observant readers may be wondering why the syntax for evaluating the number registers inside the <p> macro have two backslashes (e.g., \\n[#PARSKIP]u), rather than one (e.g., \n[_LINE]) as are shown above. The difference is subtle but important. The reason for using two backslashes inside macro definitions is that we usually don't want the expression inside the macro to be evaluated at the time the macro is first read. Rather, we would like the expression to be evaluated every time the macro is played back. A double backslash is groff's escape sequence for the backslash character itself, providing the means of getting a single backslash to print in your output. When groff is reading in a macro for the first time—in what is called “copy mode”—it interprets everything as it usually does, including escape sequences. So when a double backslash is encountered in a macro definition, groff converts it to the single backslash the sequence represents. Then, whenever the macro is played back, the single backslash remaining is interpreted in the usual manner. Although we could define macro variables with a single backslash, such as: .MACRO <p>.SKIP \n[#PARSKIP]u \# etcetera This macro would always execute with the amount of paragraph prespace specified in the variable #PARSKIP at the time the macro was first read. You would be stuck with the same #PARSKIP for your whole document. By using two backslashes, as in our original definition of <p>, we can dynamically change the #PARSKIP variable anywhere in the document and as often as we like, for example: \# user interface for setting parskip:.MACRO <parskip:> __END__ . NUMBER #PARSKIP \\$1 .__END__ \# \# tighten spacing between paragraphs: .<parskip:> 0.4vThe new setting will now affect the format of all instances of the <p> macro that follow. As we could expect, groff offers a useful extension in this area as well. The “\E” sequence represents an escape character that will not be interpreted in copy mode. So, our <p> macro could just as easily be written: .MACRO <p>.SKIP \En[#PARSKIP]u \# etcetera The “\E” sequence will provide the same result as the “\\” double backslash
http://www.linuxjournal.com/article/4375?page=0,2&quicktabs_1=2
CC-MAIN-2016-18
refinedweb
1,007
56.35
Well I cannot get the second and third out put to work correctly. // Purpose is to program a simulation for the flight of a cannonball. #include <iostream> #include <cmath> using namespace std; int main () { // Declare variables and constants. double vel_i, x_final=0, x_initial=0, time= 0.01, x_0; const double G = 9.8; const double DELTA_T = 0.01; // Get user input. cout << "Please input initial velocity of the cannonball:\n "; cin >> vel_i; while (vel_i >=0) { x_initial = x_initial + (vel_i * DELTA_T); cout << x_initial;// estimate position of cannon vel_i = vel_i - (G * DELTA_T); // estimate answer. x_0 = -.5 * G * (time * time) +(x_initial * time); //exact position. time =+.01; // Compute new velocity. cout << "The velocity of the cannonball is: " << vel_i << " m/s\n" << endl; // Compute new position of cannonball. cout << "The new position of the cannonball is: " << x_initial << " m\n" << endl; // Compute the exact formula. cout << "The exact position of the cannonball is: " << x_0 << " m\n" << endl; } // Exit Program return 0; The part cout << x_initial;// is just to show us an output before the very end. Any ways and idea what is wrong? Those things in there are supposivly the equations. Homework Four CSci/GE 142 Winter 2006 Reading. Continue reading the textbook, according to the course calendar Projectile Flight (from Horstmann Big C++) Suppose a cannonball is propelled straight into the air with a starting velocity v0. Any calculus book will state that the position of the ball after t seconds is s(t) = (-1/2)g*t2 + v0t, where g = 9.81 m/sec2 is the gravitational force of the earth. No calculus book ever mentions why someone would want to carry out such an obviously dangerous experiment, so we will do it in the safety of the computer. In fact, we will confirm the theorem from calculus by a simulation. In our simulation, we will consider how the ball moves in very short time intervals ∆ t. In a short time interval the velocity v is nearly constant, and we can compute the distance the ball moves as ∆ s = v * ∆t. In our program, we will simply set const double delta_t = 0.01; and update the position by s = s + v * delta_t; The velocity changes constantly—in fact, it is reduced by the gravitational force of the earth. In a short time interval, ∆ v = -g * ∆t, we must keep the velocity updated as v = v – g * delta_t; In the next iteration the new velocity is used to update the distance. Now run the simulation until the cannonball falls back to the earth. Get the initial velocity as an input (100 m/sec is a good value). Update the position and velocity 100 times per second, but print out the position only every full second. Also print out the values from the exact formula s(t) = (-1/2)g*t2 + v0t for comparison. What is the benefit of this kind of simulation when an exact formula is available? Well, the formula from the calculus book is not exact. Actually, the gravitational force diminishes the further the cannonball is away from the surface of the earth. This complicates the algebra sufficiently that it is not possible to give an exact formula for the actual motion, but the computer simulation can simply be extended to apply a variable gravitational force. For cannonballs, the calculus-book formula is actually good enough, but computers are necessary to compute accurate trajectories for higher-flying objects such a ballistic missiles. That is the HW assignment Any help is greatly appreshiated.
https://www.daniweb.com/programming/software-development/threads/39086/simulated-cannon-ball-problem
CC-MAIN-2018-05
refinedweb
578
55.95
Each Answer to this Q is separated by one/two green lines. You can check if a variable is a string or unicode string with - Python 3: isinstance(some_object, str) - Python 2: isinstance(some_object, basestring) This will return True for both strings and unicode strings As you are using python 2.5, isinstance is an option: In [2]: isinstance("a", str) Out[2]: True In [3]: isinstance([], str) Out[3]: False In [4]: isinstance([], list) Out[4]: True In [5]: isinstance("", list) Out[5]: False Type checking: def func(arg): if not isinstance(arg, (list, tuple)): arg = [arg] # process func('abc') func(['abc', '123']) Varargs: def func(*arg): # process func('abc') func('abc', '123') func(*['abc', '123'])") >>> type('abc') is str True >>> type(['abc']) is str False This code is compatible with Python 2 and 3 Check the type with isinstance(arg, basestring) I’m surprised no one gave an answer with duck typing, but gave unclear or highly type-dependent or version-dependent answers. Also, the accepted answer unfortunately has separate code for Python 2 and 3. Python uses and encourages duck typing, so (one line more than sorin’s “shortest form” which is not duck typing) I instead recommend: def is_str(v): return hasattr(v, 'lower') …and whatever other attributes you want to use (remember the quotes). That way, client code using your software can send whatever kind of string they want as long as it has the interface your software requires. Duck typing is more useful in this way for other types, but it is generally the best way. Or you could also do this (or generally check for AttributeError and take some other action): def is_str(v): try: vL = v.lower() except AttributeError: return False return True Have you considered varargs syntax? I’m not really sure if this is what you’re asking, but would something like this question be along your lines? Can’t you do: (i == list (i) or i == tuple (i)) It would reply if the input is tuple or list. The only issue is that it doesn’t work properly with a tuple holding only one variable.
https://techstalking.com/programming/python/check-if-input-is-a-list-tuple-of-strings-or-a-single-string/
CC-MAIN-2022-40
refinedweb
356
60.99
OpSource Cloud API is a RESTful web service interface that allows users to control their OpSource Cloud environment over HTTPS. Goomgum is a .NET library that can be used to simplify access to Opsource Cloud API from .NET applications. Goomgum wraps REST-style API operations in an OOP-style class library that can be used as a base for creating your own Opsource Cloud automation tools in .NET. Goomgum currently features a small but growing subset of the parent API, a set of unit-tests that does not require access to the live API, and a sample command line utility that consumes the library. With OpSourceCloudAPI.dll you can use LINQ and other .NET niceties to manage swarms of VMs with ease: using OpSource; using System.Linq; var c = new Cloud("login", "password"); Account a = c.Authenticate(); var servers = a.GetServers().Where(s => s.Name.StartsWith("test")); foreach(var s in servers) s.Start(); goomgum.exe allows you to start/stop multiple servers at once using * and ? wildcards: >goomgum.exe -c start -n test* -l zvolkov -p [PASSWORD] Connecting to OpSource Cloud as zvolkov... Enumerating the servers... Name IP Address IsStarted ------------------------- --------------- --------- test 10.162.124.37 <-- Sending start request... Feel free to download the binaries and try for yourself. Compiled for .NET Framework 4.0 Client Profile. Goomgum is currently developed in C# using VS 2010. The client library itself does not have any third-party dependencies, but the Unit Tests and the Command Line App depend on a few free libraries & tools such as Rhino Mocks, Command Line Parser Library and ILMerge. If you want to participate I will be glad to give you write access to the repository.
http://code.google.com/p/goomgum/
crawl-003
refinedweb
280
67.55
make generate-plist Expand this list (8 items) Collapse this list.: 368 (showing only 100 on this page) 1 | 2 | 3 | 4 » editors/openoffice-devel: mark BROKEN Approved by: portmgr blanket> framework: convert bsd.gstreamer.mk to Uses/gstreamer.mk - convert bsd.gstreamer.mk to Uses/gstreamer.mk - convert ports tree to make use of USES=gstreamer - remove duplicate dependency lines from the tree Differential Revision: editors/openoffice-devel: make robust against __cxa_exception ABI changes Patch openoffice to replace __cxa_get_globals()->caughtExceptions, which is a pointer to the start of a struct __cxa_exception, with __cxa_current_primary_exception(), which is a pointer to the end. This allows struct __cxa_exception to be extended at the start as was recently done in FreeBSD main and stable/13 on 64-bit architectures. Recently on FreeBSD main and stable/13 __attribute__((__aligned__)) was added to struct _Unwind_Exception which changes its size on 32-bit architectures, and that of __cxa_exception as well. Patch openoffice to detect this so packages built on 13.0 still work on 13.1. Add a build dependency on a recent version of devel/libunwind so we always build with an unwind.h that has the right definition of _Unwind_Exception. The dependency was already pulled in via gstreamer (with default options). editors/openoffice-devel: Update to a newer snapshot Update to a newer snapshot of the upstream code. editors/openoffice-devel: Fix dependency issues Fix an incorrect coinmp-related dependency that was causing spurious rebuilds. It was also reported to break the build of openoffice-4, though I was unable to reproduce the problem, and it did not seem to break the official package build. Add another missing dependency. Both issues were reported by stage-qa. PR: 263238 math/ipopt: Update 3.12.13 -> 3.14.4 math/asl: Update 1.4.4 -> 2.0.0 Reported by: portscout editors/openoffice*: unbreak build with clang 13+ The include file vigra/memory.hxx from the graphics/vigra port has this error: /usr/local/include/vigra/memory.hxx:43:12: fatal error: 'tr1/memory' file not found # include <tr1/memory> ^~~~~~~~~~~~ when compiling with clang 13.0 or newer in -std=gnu++98 mode. MFH: 2021Q4 *:) editors/openoffice-devel: Upgrade to a new snapshot - Fix CVE-2021-33035 - Buffer overflow from a crafted DBF file The CVE-2021-40439 - Billion Laughs issue for the FreeBSD port was fixed some time ago when the textproc/expat2 port was updated. Unlike other distributions, the FreeBSD port uses the system expat2 instead of bundling an old version. Update dependencies, mostly due to math/coinmp refactoring. MFH: 2021Q4 Security: 04d2cf7f-2942-11ec-b48c-1c1b0d9ea7e6: editors/openoffice-devel: Upgrade to a newer upstream snapshot Upgrade to upstream commit 6aec515561 * Fixes CVE-2021-30245 * Misc other fixes The building using the archive format on FreeBSD does not require epm. all: Remove all other $FreeBSD keywords. Remove # $FreeBSD$ from Makefiles. Unbreak build after gnomevfs and gconf removal. Remove dependency on deprecated gnome2 libraries: gnomevfs and gconf graphics graphics/poppler: update to 20.12.0 Changel Upgrade editors/openoffice-devel to a newer snapshot. patch-gmake43 has been upstreamed. Fix LICENSE_MPL11 generation. graphics/poppler: update to 0.89.0 Release 0.89.0: core: * Add support for ResetForm action. Issue #225 * Fix crash in PDFDoc::getSignatureFields when there's no Forms at all * Fix exporting to PS of some files with CID fonts * Use ICC profiles in PS output (if new enough lcms is used) * Allow almost-singular tiling pattern matrices. Issue #894 * Fix memory leak when failing to load some fonts * CairoOutputDev: Use stroke opacity when clipping to a stroke path * CairoOutputDev: Fix tiling patterns when pattern cell is too far. Issue #190 glib: * Add poppler_movie_get_aspect cpp: * Add the font infos to the text_box object Exp-run by: antoine PR: 246848 Fix build with bison 3.6.2 Upgrade to upstream 420-Dev2-m2 development snapshot.): Ports MUST NOT set WITH_DEBUG. WITH_DEBUG is a user facing variable. When a user wants to build a port with debugging symbols enabled, they either set WITH_DEBUG globally, or WITH_DEBUG_PORTS+=category/port. Approved by: bapt With hat: portmgr Differential Revision: Bump revision of poppler dependencies - poppler was updated in r525051, bump revisions Upgrade editors/openoffice-devel to git commit d12e928220 on the upstream AOO420 branch. patch-configure.ac and patch-icu_makefile.mk have been upstreamed. Switch from python2 to python3. Rename my jakarta- ports to apache- devel/boost-*: update to 1.72.0 Changes: PR: 241449 Exp-run by: antoine Differential Revision: Attempt to fix gcc builds on powerpc, that were broken by a boost upgrade. Clang builds using -std=gnu++98 can use the STL headers in /usr/include/c++/v1, but recent versions of the gcc headers forbid this. As a fallback, OpenOffice tries to use the TR1 headers supplied by boost, but recent versions of boost no longer have those headers. In theory the gcc TR1 headers should work, but I was not able to make those work. Solve this problem by doing gcc builds using the "bundled" version of boost which is much older rather that boost from ports. The headers in the ports version of vigra has some C++11 stuff that gcc also complains about, so use the "bundled" version of vigra for gcc builds as well. The icu patch may only be needed for non-default values of LOCALBASE. No PORTREVISION bump since amd64 and i386 builds should be unchanged. Tested by: Curtis Hamilton clhamilto AT g: Upgrade openoffice-devel to a newer snapshot from upstream, git hash 1742cb93dc, which contains some fixes that should help unbreak the powerpc build. Some further changes are needed to the FreeBSD port to complete the fix. Mark as broken on powerpc64. This port has been failing the same way since 20180921. Approved by: portmgr (tier-2 blanket)) Chase jakarta-commons-lang3 -> apache-commons-lang3 rename.: Upgrade editors/openoffice-devel to upstream git hash d871312c80. Since upstream has migrated from svn to git, use seconds from epoch of the last commit as the minor component of PORTVERSION. The build wants to include the git hash value in the build for display on the Help -> About popup, but it can't determine that when building from a source tarball, as opposed to a git checkout. Patch around that issue until upstream implements a way to include this info into the tarball and pick it up from there. Add xorg to USES for correctness. editors/openoffice-devel: Fix spelling of MYSQL_DESC devel/boost-*: update to 1.70.0 Changes: PR: 235956 Exp-run by: antoine Differential Revision: Update to openoffice-devel to AOO420-Dev-m1 developer snapshot. Switch openoffice-devel to the upstream AOO42X branch from trunk and upgrade to svn revision 1853744. This is on the path to the upcoming release of version 4.2.0. Disable the PDFIMPORT option and mark it broken. This extension does not get built unless a compatible version of poppler is available. textproc/hunspell: update to 1.7.0 - Drop const optimization as v2 API moved to nuspell Changes:: Spell CHOSEN_COMPILER_TYPE correctly PR: 199098 With hat: portmgr Silence warnings from the ports framework by adding gl and gnome to USES. Upgrade editors/openoffice-devel to upstream SVN revision r1847189. This contains the fix for the crash in Freetype code, See [1] Ensure that unowinreg.dll is included in DISTFILES when running the makesum and distclean targets. This has been missing from distinfo since r468039 which was committed in April. PR: 233404 [1] MFH: 2018Q4 editors/openoffice-4, editors/openoffice-devel: Fix build with OpenSSL 1.1.x Pet portlint (USES block location) PR: 232265: Upgrade editors/openoffice-devel to upstream svn revision r1838397. Explicitly depend on python2 since the OpenOffice pyuno module fails to build with python3. No PORTREVISION bump since this does not change the package. PR: 229408 Submitted by: Curtis Villamizar <curtis@ipv6.occnc.com> to Apache OpenOffice trunk SVN revsion r1833124. This includes the bug fix in extra-patch-align16 needed for amd64. [1] Instead of symlinking the directory containing the OpenOffice .desktop files under $PREFIX/share/applications, symlink the individual .desktop files. This is what upstream does on Linux and what LibreOffice does as well. The Plasma 5 desktop ignores symlinks to directories when it is scanning for .desktop files. PR: 228030 [1] Reported by: kan Upgrade openoffice-devel to upstream SVN r1829757. The fix for compatibility with boost 1.67 has been upstreamed, so remove BROKEN. Upstream has switched from gstreamer 0.10 to gstreamer 1.x, so change our dependency to match. Don't specify an explicit LIB_DEPENDS in addition to USE_GSTREAMER1. Most of the patches to work around various compiler issues have been upstreamed, so remove them here. Modernize patch-framework_Library__fwk.mk. devel/boost-*: update to 1.67.0 Changes: PR: 227427 Exp-run by: antoine Differential Revision:) Upgrade to upstream svn revision r1822069, which includes the fixes that were in files/patch-security. Follow upstream and disable GNOMEVFS by default, using gio instead. it to the build, similar to what is done by the default do-build target. This passes CCACHE_DIR and HOME (set to WRKDIR) to the build, so the $HOME override in r459363/generate.pl since it has been obsolete for a long while. No PORTREVISION bump since the package should be unchanged. PR: 224276: Fix the table wizard in openoffice-base on FreeBSD 10 amd64. One of the source files triggers a bug in the clang 3.4 code optimizer. MFH: 2017Q4 Add a security patch taken from Apache OpenOffice 4.1.4. Add a LICENSE entry for MPL10. Code containing both MPL10 and MPL11 licenses is bundled. Add CONFLICTS_INSTALL. Move --with-ant-home and -with-jdk-home to Makefile from Makefile.knobs. MFH: 2017Q4 Security: 27229c67-b8ff-11e7-9f79-ac9e174be3af Upgrade openoffice-devel to upstream svn revision r1810071. Make LICENSE more specific by changing MPL to MPL11. Add the REPORT_BUILDER option to enable building that extension, but leave it off and mark it broken until we have a way to install the necessary .jar files. The new PostgreSQL database connector requires jakarta-commons-lang3. Make jakarta-commons-codec, jakarta-commons-httpclient, and jakarta-commons-logging-jar dependencies optional based on the selected port options. patch-sal_qa_osl_mutex_osl__Mutex.cxx and patch-scaddins_source_analysis_analysishelper.hxx have been upstreamed. Pacify portlint by sorting sections. to upstream svn revision r1780246. This incorporates the pointer comparision fixes required to compile with clang 4.0, so delete patch-clang40. Also, patch-lingucomponent_source_spellcheck_spell_sspellimp.cxx has been incorporated upstream. Servers and bandwidth provided by New York Internet, iXsystems, and RootBSD 7 vulnerabilities affecting 73 ports have been reported in the past 14 days * - modified, not new All vulnerabilities Last updated:2022-08-05 19:03:39
https://www.freshports.org/editors/openoffice-devel
CC-MAIN-2022-33
refinedweb
1,777
58.79
Can anyone help with this error?Thank you!! I don't know why I didn't figure that out... so obvious! lol. Thanks again! Can anyone help with this error?Here's what I have: 1 #include <iostream> 2 #include <cmath> 3 4 using namespace std; ... Help with Error in Function?I still don't understand which part is wrong? Help with Error in Function?I have a function written to calculate an integral using rectangles. I get this error: 'cannot conve... Help with Integration functionHey, I was wondering how you declared func_1, func_2, etc. in the rectangle function? I'm doing some... This user does not accept Private Messages
http://www.cplusplus.com/user/jdowning/
CC-MAIN-2015-11
refinedweb
110
80.48
Finding terminal states in markov chain matrix (Simple project) Költségvetés $10-30 USD I want someone to solve this problem in either Java/python. Write a function answer(m) that takes an array of array of nonnegative ints representing how many times that state has gone to the next state and return an array of ints for each terminal state giving the exact probabilities of each terminal state, represented as the numerator for each state, then the denominator for all of them at the end and in simplest form. The matrix is at most 10 by 10. It is guaranteed that no matter which state the elements is in, there is a path from that state to a terminal state. That is, the processing will always eventually end in a stable state. The elements starts in state 0. The denominator will fit within a signed 32-bit integer during the calculation, as long as the fraction is simplified regularly. For example, consider the matrix m: [ [0,1,0,0,0,1], # s0, the initial state, goes to s1 and s5 with equal probability [4,0,0,3,2,0], # s1 can become s0, s3, or s4, but with different probabilities [0,0,0,0,0,0], # s2 is terminal, and unreachable (never observed in practice) [0,0,0,0,0,0], # s3 is terminal [0,0,0,0,0,0], # s4 is terminal [0,0,0,0,0,0], # s5 is terminal ] So, we can consider different paths to terminal states, such as: s0 -> s1 -> s3 s0 -> s1 -> s0 -> s1 -> s0 -> s1 -> s4 s0 -> s1 -> s0 -> s5 Tracing the probabilities of each, we find that s2 has probability 0 s3 has probability 3/14 s4 has probability 1/7 s5 has probability 9/14 Function format: Java: public static int[] calculate(int[][] m) { // Your code goes here. } Python: def answer(m): Your program will be tested for custom inputs. 20 szabadúszó tett, átlagosan $33 összegű árajánlatot erre a projektre. I can write this for you. I like working with markov chains. I have revised this to 20 dollars Thank you
https://www.freelancer.hu/projects/Java/Finding-terminal-states-markov-chain/
CC-MAIN-2017-26
refinedweb
350
55.68
Introduction to (Windows) Azure Dominik Pinter — Mar 10, 2011 cloudcmsdevelopmentwindows azure Hi there, with this post I’m starting a new series here on the DevNet portal about Windows Azure. I will write about Azure in general and also about Azure integration in Kentico CMS. In this first post I will introduce the Azure platform from a development point of view. I will tell you a few words about the capabilities of Windows Azure, what you can use in Azure and what we decided to use when we started to support Kentico CMS on Azure. First of all, I will not explain the basic concepts of cloud computing. If you are completely unfamiliar with cloud computing, you can read some basic info in Michal Neuwirth’s post. Let’s start with terminology. Azure-related terminology is a little bit tricky and one could get confused very easily. Azure – Azure is a term used for Microsoft’s entire cloud computing platform — it consists of Windows Azure, SQL Azure, Azure AppFabric and Azure Marketplace DataMarket. Windows Azure – this term is usually used for computing, storage and network services provided by the Azure platform. We will look at this part a little bit deeper below. SQL Azure – it’s a relational database service similar to MS SQL Server. Azure Appfabric – Supports infrastructure services. Azure Appfabric consists of a general service bus, access control services and a durable cache service. The term “fabric” is the trickiest one in Azure terminology because a service with a very similar name also exists — the Fabric Controller, which is a completely different thing. Microsoft also offers a product called Windows Server AppFabric, which is similar to Azure Appfabric by functionality but it is used on-premise. Azure Marketplace DataMarket – Data as a service. There are two roles: producer –offers some kind of data and consumer – who can use data from producers as a data source. I will use these terms in the rest of this series. As you probably noticed in the list above, I introduced the basic parts of Azure. I personally think that for CMS systems, two services are most critical — Windows Azure and SQL Azure. You need to run your application somewhere (Windows Azure) and store its data (SQL Azure as a database backend, Windows Azure storage for storing physical files). Let’s take a more detailed look at the first one (SQL Azure will be covered in one of the future posts). Windows Azure As you can see, there are four different components in Windows Azure. Let´s start with a description of Windows Azure computing services. Basically, this is only a huge farm of virtual machines. However, there is one difference between standard VM web farms and Windows Azure. You have to put your application into one or more roles. Each role offers a different approach. Web role – designed for interaction with users. A web role is basically a place for hosting your web application or web service. There are three subtypes: ASP.NET web role – for running ASP.NET applications. As .NET developers, you will in most cases use this type of role. WCF Service web role – for your WCF services. CGI web role – this role is meant to be used for platforms/languages other than ASP.NET, such as PHP or Java. Worker role – simply put, everything except for web applications should run as a worker role. You can also run web applications as a worker role but you would do better to go with a web role, which is designed for it. Originally, worker roles were mainly designed for running long complex tasks or scheduled tasks. When you for example need to sort some table every few hours, a worker role is a good place to run this code. But you can run whatever you need there. You want a ftp server hosted on Azure? No problem. You only need to specify an input endpoint for your worker role (you couldn´t do this in the first version of worker roles), change the code of your ftp to bind to the correct port using Azure runtime API (more on that in one of the future posts) and you are ready to go. VM role – VM is a shortcut for virtual machine. As you certainly know, Windows Azure uses the platform as a service model but you can now also use it as infrastructure as a service. The VM role was created for this purpose. To use it, you create a VHD using Hyper-V technology, upload it to your cloud space and that´s it. Unfortunately, with VM you lose some of the benefits of PaaS — you have to take care of your role by yourself, including the installation of new updates to the underlying OS. All your roles are maintained by the Fabric Controller. It creates and deletes virtual machines, monitors the health of your application and so on. All this is fully transparent for you, you only enter the desired configuration into the service definition and service configuration files and the Fabric Controller takes care of everything. Another important part of Windows Azure is storage. There are three types of storages. All storages are highly distributed, durable, highly available and ready for massive scaling. Blob storage – General storage for huge binary files. Blob storage is also a good replacement for a standard file system. Blob storage consists of containers and blobs. Containers are similar to folders in a file system and every blob must be in some container. The only difference is that one container cannot be placed inside another, the hierarchy is flat. On the other hand, the managed client library offers virtual directories for the simulation of a tree structure (this topic will be covered more deeply in the future). There are two types of blobs. Page blobs are designed for random read/write access, ideal for storing text files. Block blobs are intended for everything else. There is one rule — if you don´t have any specific reasons for using page blobs, always use block blobs. Table storage – The ideal place for storing non-relational metadata. Tables don´t have any schema and every row can have a different structure. To get or set data from/into a table you need to use a key. Each key consists of two parts — a row and partition key. You can get the best performance by dividing a table into partitions using different partition keys. Queue storage – this type of storage is usually used for internal communication between roles. Of course, you can use this storage for whatever you want to. Now a few words about Azure networking services. There is a content delivery network, so if you have customers all over the world, this is an ideal solution to decrease latency. There is also a thing called Azure Connect. It allows you to connect your on-premise servers with Azure roles. For example, you can join your Azure role to your domain. Azure Connect is currently in CTP (community technical preview). Differences between On-premise and Windows Azure Let´s take a look at the main differences between an on-premise environment and Windows Azure. This part will be focused only on the differences between standard ASP.NET development and Azure. The application must be stateless In the Azure environment, roles typically have more than one instance. It´s recommended to have at least two instances of each role in order to ensure high availability. Requests between instances are divided by the built-in load balancer. The algorithm behind the load balancer uses the round robin model, so every request goes to a different instance. Where is the catch? If you are storing anything in the memory of your process, you have to synchronize it between instances. As you may know, we have the web farms module in Kentico CMS which takes care of the synchronization of static objects. Another problem is with session state data — you cannot use any of the three standard providers for storing session state data. InProc and StateServer are out of the game because both store data on the current machine. SQL Azure should be usable for this purpose with a few changes (we will discuss it in the post about SQL Azure). A durable standard NTFS file system is missing I have already introduced all durable storages and I didn´t mention a NTFS file system. It´s because the Azure platform doesn´t offer any durable NTFS file system. The reason for this is that NTFS isn´t a distributed file system, which is a basic condition for use in the Azure environment. You could use local storage on a single instance. However, local storage is not durable storage and data aren´t synchronized across instances, so you can use this type of storage only for temporary files or as the cache of the given instance. Also, if you store anything into files in your application using the System.IO namespace and you don´t want to change this, you can use the Azure drive feature. This feature enables you to mount blob storage as a NTFS hard drive that you can use in the standard way. But, you can mount this drive for reading and writing for a single instance only. I’m not saying that you cannot use this feature with multiple instances, but it requires additional work to be done. The last option is to use pure blob storage as replacement for a standard file system — we will talk about this option more in the future. No write access to the application directory Yes, you can use local storage on individual instances but this type of storage is in a different part of the hard drive than the application data. The part with the application is read only. Why is that a problem? For example, in Kentico CMS we write the connection string into the web.config file after installation — you cannot do that on Azure. Why is that? Because you would change data only on one instance. More importantly, even if you created a mechanism for synchronizing data between instances, you still couldn’t change the golden image. A golden image is created when you upload your application to the cloud. If you add a new instance, it´s created from the golden image. Used parts of the Azure platform in Kentico CMS 5.5 R2 and 6.0 Now it´s time to take a look what Kentico CMS needs to run in Azure. Both versions ASP.NET Web role – All of Kentico CMS is one big ASP.NET web role. SQL Azure – as you know, Kentico CMS normally uses MS SQL Server for its database. In the Azure world we use SQL Azure services Kentico CMS 5.5 R2 Blob storage via Windows Azure Drive – the Smart search, Web analytics and Media library modules need to save data to the file system. Because 5.5 R2 is limited to use with one instance only, we decided to support these modules using the Windows Azure Drive feature. Kentico CMS 6.0 Blob storage – for version 6.0, we are preparing a replacement of the standard NTFS file system by blob storage on Azure. We will not use Azure Drive anymore — only the pure blob API. Azure AppFabric cache – We will use this cache service at least for storing session state data. Ok, I think this is quite enough for today. The next post will be dedicated to developing on Azure. Rene Stein commented on Mar 21, 2011 Great post. Thanks. Dominik Pinter commented on Mar 10, 2011 Thank you for your opinion Bryan! Bryan Soltis commented on Mar 10, 2011 Dominik,Excellent post! I think breaking down the terms/concepts will really help people understand the pieces and how Azure works together with Kentico.-Bryan New subscription Leave message Your email:
https://devnet.kentico.com/articles/introduction-to-(windows)-azure
CC-MAIN-2020-29
refinedweb
1,986
65.32
[SOLVED] Function _ExplorerGetSelectedItems for items on Desktop By k4rl3on, in AutoIt General Help and Support Recommended Posts Similar Content - - By copyleft I am trying to create a script to clean up users' desktops by moving all desktop folders and files (except the two hidden "desktop.ini" files and a MyDesktop.lnk shortcut) to a different folder. The script below will move files but not folders. The other issue with the script is that it doesn't seem to execute from a location other than the user's desktop. I would appreciate any suggestions. #include <File.au3> MsgBox(64, "Desktop", "Cleaning up Desktop. This box will close in 4 seconds.", 4) $Files = _FileListToArray(@DesktopDir,"*",1) For $Index = 1 To $Files[0] If StringRight($Files[$Index],4) <> ".ini, MyDesktop.lnk" Then FileMove($Files[$Index],'F:\HOME\Desktop') EndIf Next - - By ozmike running in the kernel” (device drivers) “System Level Software” (anything not running in the user context) “Elevation”, meaning anything that causes a standard user to get a UAC prompt “will be blocked”. Using parts of other apps in your app, at least in version 1. John indicated that they would like to support extensibility and plug-ins, just probably not initially. The implication was that this might be a direct UWA thing and not specific to Project C, but we can’t be sure. following as supported in Project C apps: “COM” “WMI” “Networking” “Anything else a standard app does that isn’t in the system space”. I am guessing that there are a lot of other things that might end up in the ‘not supported’ list that you might have thought falls under the last item in the supported list but turns out is not supported, but we just don’t know yet: WMI Providers Windows Timed and Triggered Events (but they can write new UWA background triggers) Custom ETW Providers COM localsystem (out of process) running as the system to avoid UAC prompts Maybe DCOM Software Clients, Application Capabilities Shell Extensions, Browser Helper Objects, and the like FYI -
https://www.autoitscript.com/forum/topic/179960-solved-function-_explorergetselecteditems-for-items-on-desktop/
CC-MAIN-2019-13
refinedweb
339
58.52
Python 3 GUI: wxPython 4 Tutorial - Urllib & JSON Example In this wxPython 4 tutorial, we'll learn to build a Python 3 GUI app from scratch using wxPython and Urllib. We'll be consuming a third-party news REST API available from newsapi.org which provides breaking news headlines, and allows you to search for articles from over 30,000 news sources and blogs worldwide. We'll use Urllib for sending HTTP requests to the REST API and the json module to parse the response. Throughout this tutorial, you'll understand how to create desktop user interfaces in Python 3, including adding widgets, and managing data. In more details, you'll see: - How to use Urllib to send HTTP requests to fetch JSON data from a third-party REST API. - How to use the jsonmodule to parse JSON data into Python 3 dictionaries. - How to use the webbrowsermodule to open URLs in your default web browser. First of all, head over to the registration page and create a new account then take note of the provided API key which will be using later to access the news data. What is wxPython wxPython is a Python wrapper around wxWidgets - the cross platform C++ library for building desktop apps for macOS, Linux and Windows. wxPython was created by Robin Dunn. Prerequisites You will need to have the following prerequisistes: - Python 3 and pip installed on your system, - A basic knowledge of Python. Installing wxPython 4 Let's start by installing wxPython 4 using pip. Open a new terminal and simply run the following command: $ pip install wxpython If the installation fails, you may be requiring some dependencies depending on your operating system. Check out the prerequisites section in the official GitHub repository for more information. Creating your First wxPython 4 GUI Window After installing wxPython, you can easily create your first GUI window by creating a Python single file and call the wx.App() and the wx.Frame() methods. Inside your working folder, create a newsy.py file and add the following code: import wx app = wx.App() frame = wx.Frame(parent=None, title='Newsy: Read the World News!') frame.Show() app.MainLoop() In this example, we use two essentials classes - wx.App and wx.Frame. The wx.App class is used to instantiate a wxPython application object . From the wx.Appobject, you can call the MainLoop() method which starts the event loop which is used to listen for events in your application. wx.Frame is used to create a window. In our example, we created a window with no parent has the Newsy: Read the World News! title. Now, run your GUI app using the following command from your terminal: $ python newsy.py This is a screenshot of our GUI window: Let's refactor our code and create a menu and status bars. First, we create a MainWindow class that extends the wx.Frame class: class MainWindow(wx.Frame): def __init__(self, parent, title): super(MainWindow, self).__init__(parent, title = title, size = (600,500)) self.Centre() self.CreateStatusBar() self.createMenu() def createMenu(self): menu= wx.Menu() menuExit = menu.Append(wx.ID_EXIT, "E&xit", "Quit application") menuBar = wx.MenuBar() menuBar.Append(menu,"&File") self.SetMenuBar(menuBar) self.Bind(wx.EVT_MENU, self.OnExit, menuExit) def OnExit(self, event): self.Close(True) #Close the frame In the __init__() method, we call the Centre() method of wx.Frame to center the window in the screen. Next, we call the CreateStatusBar() method to create a status bar. Finally, we define and call the createMenu() method which: - Creates a menu using the wx.Menu()method, - Appends a menu item to quit the application, - Creates a menu bar and add the a File menu to it, - Binds the EVT_MENUto the OnExit()method which simply calls the Close()method to close the window. Next, refacor the code for creating the app as follows: if __name__ == '__main__': app = wx.App() window= MainWindow(None, "Newsy - read worldwide news!") window.Show() app.MainLoop() After running the app, this is a screenshot of our window at this point: Adding a wxPython Panel A panel is a window on which controls are placed. It is usually placed within a frame. Its main feature over its parent class wx.Window is code for handling child windows and TABtraversal, which is implemented natively if possible (e.g. in wxGTK) or by wxWidgets itself otherwise. Now, let's create a panel called NewsPanel that extends wxPanel: class NewsPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) self.SetBackgroundColour("gray") Next, let's instantiate the class in the MainWindow constructor for actually adding a panel to our window: class MainWindow(wx.Frame): def __init__(self, parent, title): super(MainWindow, self).__init__(parent, title = title, size = (600,500)) self.Centre() NewsPanel(self) self.createStatusBar() self.createMenu() Adding wxPython Lists for News and Sources A list control presents lists in a number of formats: list view, report view, icon view and small icon view. In any case, elements are numbered from zero. For all these modes, the items are stored in the control and must be added to it using wx.ListCtrl.InsertItemmethod. After creating our panel, let's add two lists which will hold the sources and the news items: class NewsPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) self.SetBackgroundColour("gray") self.sources_list = wx.ListCtrl( self, style=wx.LC_REPORT | wx.BORDER_SUNKEN ) self.sources_list.InsertColumn(0, "Source", width=200) self.news_list = wx.ListCtrl( self, size = (-1 , - 1), style=wx.LC_REPORT | wx.BORDER_SUNKEN ) self.news_list.InsertColumn(0, 'Link') self.news_list.InsertColumn(1, 'Title') We use wx.ListCtrl to create a list in wxPython, next we call the InsertColumn() method for adding columns to our lists. For our first list, we only add one Source column. For the seconf lists we add two Link and Title columns. Creating a Layout with Box Sizer Sizers ... have become the method of choice to define the layout of controls in dialogs in wxPython because of their ability to create visually appealing dialogs independent of the platform, taking into account the differences in size and style of the individual controls. Next, let's place the two lists side by side using the BoxSizer layout. wxPython provides absoulte positioning and also adavanced layout algorithms such as: - wx.BoxSizer - wx.StaticBoxSizer - wx.GridSizer - wx.FlexGridSizer - wx.GridBagSizer wx.BoxSizer allows you to place several widgets into a row or a column. box = wx.BoxSizer(wx.VERTICAL | wx.HORIZONTAL) The orientation can be wx.VERTICAL or wx.HORIZONTAL. You can add widgets into the wx.BoxSizer using the Add() method: box.Add(wx.Window window, integer proportion=0, integer flag = 0, integer border = 0) In the __init__() method of our news panel, add the following code: sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.sources_list, 0, wx.ALL | wx.EXPAND) sizer.Add(self.news_list, 1, wx.ALL | wx.EXPAND) self.SetSizer(sizer) This is a screenshot of our window with two lists: Let's now start by populating the source list. First import the following modules: import urllib.request import json Next, define the API_KEY variable which will hold your API key that you received after creating an account with NewsAPI.org: API_KEY = '' Fetching JSON Data Using Urllib.request Next, in NewsPanel, add a method for grabbing the news sources: def getNewsSources(self): with urllib.request.urlopen("" + API_KEY) as response: response_text = response.read() encoding = response.info().get_content_charset('utf-8') JSON_object = json.loads(response_text.decode(encoding)) for el in JSON_object["sources"]: print(el["description"] + ":") print(el["id"] + ":") print(el["url"] + "\n") self.sources_list.InsertItem(0, el["name"]) Next, call the method in the constructor: class NewsPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) # [...] self.getNewsSources() That's it! If you run the application again, you should see a list of news sources displayed: Now, when we select a news source from the list at left, we want the news from this source to get displayed on the list at the right. We first, need to define a method to fetch the news data. In NewsPanel, add the following method: def getNews(self, source): with urllib.request.urlopen(""+ source + "&apiKey=" + API_KEY) as response: response_text = response.read() encoding = response.info().get_content_charset('utf-8') JSON_object = json.loads(response_text.decode(encoding)) for el in JSON_object["articles"]: index = 0 self.news_list.InsertItem(index, el["url"]) self.news_list.SetItem(index, 1, el["title"]) index += 1 Next, we need to call this method when a source is selected. Here comes the role of wxPython events. Binding wxPython Events In the __init__() constructor of NewsPanel, call the Bind() method on the sources_list object to bind the wx.EVT_LIST_ITEM_SELECTED event of the list to the OnSourceSelected() method: ```py class NewsPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) # [...] self.sources_list.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSourceSelected) Next, define the `OnSourceSelected()` method as follows: ```py def OnSourceSelected(self, event): source = event.GetText().replace(" ", "-") self.getNews(source) Now, run your application and select a news source, you should get a list of news from the select source in the right list: Open External URLs in Web Browsers Now, we want to be able to open the news article, when selected, in the web browser to read the full article. First import the webbrowser module: import webbrowser Next, in NewsPanel define the OnLinkSelected() method as follows: def OnLinkSelected(self, event): webbrowser.open(event.GetText()) Finally, bind the method to the wx.EVT_LIST_ITEM_SELECTED on the news_list object: class NewsPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) # [...] self.news_list.Bind(wx.EVT_LIST_ITEM_SELECTED , self.OnLinkSelected) Now, when you select a news item, its corresponding URL will be opened in your default web browser so you can read the full article. Resizing the Lists when the Window is Resized If your resize your window, you'll notice that the lists are not resized accordingly. You can change this behavior by adding the following method to NewsPanel and bind it to the wx.EVT_PAINT event: def OnPaint(self, evt): width, height = self.news_list.GetSize() for i in range(2): self.news_list.SetColumnWidth(i, width/2) evt.Skip() Next, bind the method as follows: class NewsPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) # [...] self.Bind(wx.EVT_PAINT, self.OnPaint) This is the full code: Conclusion In this tutorial, we've seen how to do desktop GUI development with Python 3 and wxPython. We've also seen: - How to use Urllib to send HTTP requests to fetch JSON data from a third-party REST API. - How to use the json module to parse JSON data into Python 3 dictionaries. - How to use the webbrowsermodule to open URLs in your default web browser. We've also learned how to use wxPython to create windows, panels and lists and how to listen for events.
https://www.techiediaries.com/python-gui-wxpython-tutorial-urllib-json/
CC-MAIN-2020-45
refinedweb
1,805
59.19
Helm, is the package manager for Kubernetes. It allows you to install complex applications and maintain the entire application lifecycle using a lightweight and intuitive CLI. You can think of it as the npm or nuget for Kubernetes. Helm is around for quite some time in the Kubernetes community. The project was started by Deis and Google and is an essential part of CNCF. Since Helm 3 is available as a beta release, it is the right time to look into it. This article summarizes the upcoming changes and illustrates how Helm 3 could be used to build, distribute, and manage applications in Kubernetes. What will change with Helm 3 Helm 3 will introduce some fundamental changes. The team has published already a series of articles on upcoming changes. Let’s quickly summarize those: No more Tiller: Finally, the server-side component of Helm is gone. Tiller was the most significant disadvantage when considering using Helm. Instead, Helm 3 will rely on existing security patterns applied to the given cluster. Chart Registries: Chart Registries will be implemented based on the Docker Distribution Project (aka Docker Registry v2). Helm will benefit from this move dramatically. Users can leverage existing Docker Registry v2 implementations such as Azure Container Registry (ACR) or the Docker Hub to distribute and consume their charts. Hosting Helm Charts in a Docker Registry is possible due to the Open Container Initiative (aka OCI) efforts. Docker Registries can store, maintain, and distribute any data - not just Docker Images. See the ORCAS project for example. Library Charts: Helm 3 will introduce a new type of Charts. Library Charts are small application parts that are used to composite an overall application. Library Charts will be the reusable components of Charts in Helm 3. They don’t contain templates, so they can’t be deployed directly. They will become essential building blocks for developers to craft Application Charts and keep following the Don’t Repeat Yourself principle (DRY). Release Management: In Helm 3, releases will be managed inside of Kubernetes using Release Objects and Kubernetes Secrets. All modifications such as installing, upgrading, downgrading releases will end in having a new version of that Kubernetes Secret. The Release Object acts as a pointer, pointing to the correct Secret for the current Release. Having both (the Release Object and the Secret) in the same Kubernetes Namespace as the actual Deployment allows us to deploy the same Release (with the same name) multiple times to a Kubernetes cluster. Requirements: In 3, dependencies will no longer be maintained using the dedicated requirements.yaml file. Instead, the dependencies are directly listed inside of the Chart.yaml file, which means we as users have to care about fewer files. Hands on Helm 3 First you’ve to install Helm 3. You can grab a precompiled binary from the releases page on GitHub. Once downloaded and extracted, you can either move the binary into your PATH, or create a symlink pointing to the executable. I’ve created a symlink called helm3 which will I use during the upcoming snippets. cd ~/Downloads # Download Helm3 Beta3 wget # verify checksum shasum -a 256 -c <<< "88ef4da17524d427b4725f528036bb91aaed1e3a5c4952427163c3d881e24d77 *helm-v3.0.0-beta.3-darwin-amd64.tar.gz" # extract into ~/Downloads/helm3 mkdir helm3 tar -xzf helm-v3.0.0-beta.3-darwin-amd64.tar.gz --directory helm3 # create a symlink ln -s ~/Downloads/helm3/darwin-amd64/helm /usr/bin/helm3 Verify Helm 3 installation Because Tiller is gone, all you have to verify is the local installation using: helm3 version version.BuildInfo { Version:"v3.0.0-beta.3", GitCommit:"5cb923eecbe80d1ad76399aee234717c11931d9a", GitTreeState:"clean", GoVersion:"go1.12.9" } Create a Chart and deploy it to Kubernetes First let’s use the create sub command to create a new Application Chart. cd ~/dev helm3 create hello-helm3 Take a close look at the generated Chart.yaml it explicitly specifies the type as Application. If you want to create a reusable Library Chart, you have to change the type setting to library and remove the templates. For the sake of this article, let’s stick with the simple Application Chart and bring our application to Kubernetes. Helm3 allows multiple releases having the same name. For separation we will use regular Kubernetes namespaces. # create two sample namespace kubectl create namspace helm3-ns1 kubectl create namespace helm3-ns2 kubectl get ns | grep helm3 helm3-ns1 Active 3s helm3-ns2 Active 2s Having the namspaces in place, use helm3 install to install the previously created Chart to both namespaces. cd ~/dev helm3 install sample-deployment hello-helm3 -n helm3-ns1 helm3 install sample-deployment hello-helm3 -n helm3-ns2 Helm will provide some basic information about the deployment job for every deployment. Verify the releases using helm3 list: helm3 list --all-namespaces Every deployment is tracked using a Kubernetes Secret in the same Namespace. kubectl get secret -n helm3-ns1 NAME TYPE DATA AGE sample-deployment.v1 helm.sh/release 1 1m26s Modify the Chart and perform an upgrade For demonstration purpose, udate the hello-helm3 Chart and set replicaCount: 2 in values.yaml. Remember to bump the version in Chart.yaml helm3 upgrade sample-deployment hello-helm3 -n helm3-ns1 Helm will now upgrade the sample-deployment in Kubernetes Namespace helm3-ns1. As part of the upgrade process, a new Secret ( sample-deployment.v2) will be deployed to the Namespace. In fact, Helm3 secrets contain the entire release in encrypted form. Once again, you can verify the overall state using helm3 list --all-namespaces Clean up the Kubernetes Cluster You can clean up your Kubernetes cluster usign helm3 uninstall, which will remove all Helm 3 artifacts from the currrent namespace. helm3 uninstall sample-deployment -n helm3-ns1 helm3 uninstall sample-deployment -n helm3-ns2 kubectl delete ns helm3-ns1 kubectl delete ns helm3-ns2 Playground: Docker Image If you want to play around with Helm 3 today, you can either install on of the pre-compiled beta binaries on your system, or you can use a tiny Docker Image. I have created and published it to the public Docker Hub at thorstenhans/helm3. You can pull it directly via docker pull thorstenhans/helm3; further instructions are available in the Readme. Recap I am looking forward to the final Helm 3 release. Tiller was always the reason why I avoid using Helm in real-world environments. I can imagine many Kubernetes customers will jump on the Helm track with the upcoming release. HTH
https://thorsten-hans.com/the-state-of-helm3-hands-on
CC-MAIN-2019-47
refinedweb
1,072
55.34
Boxing Value Types in Managed C++ Sometimes things that should be really simple don't feel simple at all when you try to do them. Take, for example, writing the value of a variable to the screen. You know how to do it in "classic" C++, say for example in Visual C++ 6: int x = 3; cout << "x is " << x << endl; No problem. Whatever "Introduction to C++" you took, I'm willing to bet you saw something very much like these two lines of code less than 10% of the way into the course. Right? Writing to the Screen int _tmain(void) { // TODO: Please replace the sample code below // with your own. Console::WriteLine(S"Hello World"); return 0; } Now, you can paste your cout-using code into this main(), and it will work - after you add the usual include statement: #include <iostream.h> // ... Console::WriteLine(S"Hello World"); int x = 3; cout << "x is " << x << endl; You'll get a warning, though: warning C4995: '_OLD_IOSTREAMS_ARE_DEPRECATED': name was marked as #pragma deprecated To get rid of it, just use the iostream code from the STL, and bring in the std namespace: #include <iostream> using namespace std; The code will then build and run just fine. But to me, seeing that Console::WriteLine() in the same program as the cout line is a little confusing. What's more, Console::WriteLine() has neat features. It's more like printf in that it uses placeholders in a string to show where variable values should be put. For example, here's some working code from a C# console application: int x = 3; Console.WriteLine("x is {0}",x); The {0} is a placeholder, and the value of the second parameter will end up wherever that placeholder appears. So I want to use Console::WriteLine throughout my Managed C++ application, just as it's used in C#. But if you copy these lines into your Managed C++ application, and change the . to a ::, the application won't build. The compiler error is: error C2665: 'System::Console::WriteLine' : none of the 19 overloads can convert parameter 2 from type 'int' boxpin.cpp(7): could be 'void System::Console::WriteLine( System::String __gc *,System::Object __gc *)' boxpin.cpp(7): or 'void System::Console::WriteLine( System::String __gc *,System::Object __gc * __gc[])' while trying to match the argument list '(char [9], int)' Now, I'm stubborn, and I expect C++ to be able to do everything the other .NET languages can do - and more. (Some of you may have noticed that already.) So why can't this simple little thing work? Well, if all else fails, read the error messages. I have given it an int for the second parameter, and it would like a pointer. In fact, a pointer to a System::Object (or some class derived from that, of course), a pointer to a __gc object. An int is none of those things. You could try passing &x instead of x, that at least would be a pointer, but it's no help. What WriteLine() wants is a pointer to an object. You can't hand the integer directly to WriteLine(), which (in the interests of genericity) has been written to handle pointers to garbage-collected objects, and nothing else. Why? Everything in the Base Class Library is designed to work with objects, because they can have member functions - not all .NET languages support the idea of casting or of overloading casting operators. For example, objects that inherit from System::Object all have a ToString() method. You don't want to write a class to hold this little not-an-object integer, and write a ToString() overload for it, plus deal with getting your integer into (and possibly out of) the class whenever you pass it to a Base Class Library method like WriteLine(). So how do you get your integer to WriteLine()? The __box keyword Managed C++ is also called Managed Extensions for C++. The word Extensions refers to the extra keywords, all starting with a double underscore, that have been added to the language. Like all keywords that start with a double underscore, they are compiler-specific - don't try these in Visual C++ 6 or a C++ compiler from any other vendor. You've just seen __gc in the error message when trying to compile the WriteLine() call. It stands for Garbage Collected and refers to an object that lives on the managed heap and is managed by the runtime. The __box keyword is the solution to the problem I've just presented about passing an integer to a Base Class Library method that's expecting a System::Object __gc * instead of an int. Here's how to use it: Console::WriteLine("x is {0}",__box(x)); Boxing a value type means putting the value inside a temporary object, an instance of a class that inherits from System::Object and lives on the garbage collected heap, and passing the address of that temporary object to the method call. Whatever was in the original variable is bitwise-copied into the temporary object, and the temporary object provides all the functionality that WriteLine() will want. The __box keyword means that every service the Base Class Library provides will work with value types as well as with managed types. Alternatives to Boxing So boxing allows you to use both value types and managed types with Base Class Library methods that are expecting pointers to managed types. That naturally raises the question: what's the difference between a value type and a managed type? A managed type lives on the garbage collection heap and is managed by the runtime. Here's an example: __gc class Foo { // internals omitted }; // ... Foo* f = new Foo(); The Foo class is a managed type. You can't create instances of it on the stack, like this: Foo f2; If you have a class already, perhaps from some pre-.NET application, it will not be a managed type. It doesn't have the __gc keyword. You could add the keyword (assuming the class meets all the rules for being a managed type - more on that in a future column) but then you would have to find all the places that created instances of the class and make sure they were creating the instance on the heap, like this: OldClass* poc = new OldClass(); //maybe some parameters //to the constructor And everywhere your code was calling methods of the class, you'd have to remember to change . to -> -- how tedious! Better to keep the class as an unmanaged class. You can allocate instances on the stack or the unmanaged heap as you prefer: class notmanaged { private: int val; public: notmanaged(int v) : val(v) {}; }; // ... notmanaged nm(4); notmanaged *p = new notmanaged(5); This is no big deal: it's just how C++ was before Managed Extensions were added with the release of Visual C++ .NET. But let's say you want to pass one of those instances to good old WriteLine(): Console::WriteLine("notmanaged holds {0}",nm); You'll get the same error message as before: WriteLine() is no happier with this old-fashioned style class than it was with the integer. "Aha," you think, "I've learned a new keyword, I know what to do:" Console::WriteLine("notmanaged holds {0}",__box(nm)); This gets you the rather obscure message "only value types can be boxed." Isn't notmanaged a value type? Well it isn't a managed type, but it doesn't inherit from the base class System::ValueType, and that's necessary to be boxed. Now, there is a handy __value keyword, which will cause the class to inherit from System::ValueType and be boxable, but for classes and structures I don't think boxing is the way to go. You don't just want the bits of data that are in your class or structure to be blurted out onto the screen. You want some control over the way your class is represented as a string - or to be accurate, as a System::String. In other words, you want to write a function so that you retain control of the way your class behaves. So why not add a ToString() method? class notmanaged { private: int val; public: notmanaged(int v) : val(v) {}; String* ToString() {return __box(val)->ToString();} }; // ... notmanaged nm(4); Console::WriteLine("notmanaged holds {0}",nm.ToString()); notmanaged *p = new notmanaged(5); Console::WriteLine("notmanaged pointer has {0}",p->ToString()); Note the clever use of __box inside the ToString() method so that it can return a pointer to the managed type System::String* -- and WriteLine() is happy as can be with that as a parameter. You could easily expand this approach for a class with multiple member variables. Of course, you can call the method whatever you like, but calling it ToString will help other .NET programmers, since that's the name throughout the Base Class Library for a method that represents the internals of a class as a single System::String. Unboxing So far, you've only seen the __box keyword used in temporary circumstances, just to pass to a method. But you can create a longer-lived pointer to a managed type, like this: __box int* bx = __box(x); It's important to remember that this is a copy. If you change it, the original is unchanged. These four lines: __box int* bx = __box(x); *bx = 7; Console::WriteLine("bx is {0}", bx); Console::WriteLine("x is still {0}", __box(x)); produce this output: bx is 7 x is still 3 If you want changes in the boxed copy to go back to the original, just dereference the pointer: x = *bx; Then x will contain the new value (7, in this example) that you put into the boxed copy. Summary Well, that was a long walk in the park just to get a handful of integers onto the screen, wasn't it? Understanding the differences between managed and unmanaged types is vital to keeping your sanity when working in Managed C++. Boxing an unmanaged type is a useful way to convert it to a managed pointer, but when your unmanaged type is a class, remember that you're in control and can make managed pointers however you choose to do so - and a member function called ToString is an excellent approach. And you can unbox without any special keywords - just get the value back out. So don't let pesky compiler errors keep you from exploring all the fun of the Base Class Library!. Boxing of non-POD typesPosted by kirants on 08/30/2005 08:28pm Is boxing useful only in case where data is POD type ?Reply
http://www.codeguru.com/columns/kate/article.php/c6577/Boxing-Value-Types-in-Managed-C.htm
CC-MAIN-2014-41
refinedweb
1,780
67.38
Hello, I'm a python beginner and glad I joined this forum :). I'm wanting to make a simple program where the window is hidden for x seconds/minutes and is then shown again. My problem is that using time.sleep() causes the Hide() function to not run until after time.sleep() is complete. Here is my code. HideFrame() is the code with the problem. import wx import time WINDOW_WIDTH = 200 WINDOW_HEIGHT = 100 class MainFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, title = 'Sample GUI App', pos = (200,75), size = (WINDOW_WIDTH, WINDOW_HEIGHT)) self.background = wx.Panel(self) self.HideBtn = wx.Button(self.background, label = 'Hide the Window') self.HideBtn.Bind(wx.EVT_BUTTON, self.HideFrame) self.horizontalBox = wx.BoxSizer() self.horizontalBox.Add(self.HideBtn, proportion = 0, border = 0) self.background.SetSizer(self.horizontalBox) self.Show() def HideFrame(self, event): self.Hide() time.sleep(1) self.Show() print "hi" app = wx.App(redirect=False) window = MainFrame() app.MainLoop() If you run it, you will notice that the button freezes and looks pressed. The program will freeze for 1 second, then you will see the window quickly hide and show. From what I can figure, wxPython is running Hide() as a thread and time.sleep() is freezing the whole frame, including the Hide() function. Is this correct? If so, is there a work around? I don't want to do a while loop to check the time, because I want the frame to be hidden for minutes and hours at a time, a loop in the background would be a lot of wasted processing. A loop like this wouldn't be ideal. def HideFrame(self, event): # This still doesn't allow Hide() to complete self.Hide() counter = 0.1 while( counter < 1 ): print "wasted processing power" time.sleep(0.1) counter += 0.1 print "done" self.Show() Just in case this is a platform specific problem. I'm using Fedora 16 Python 2.7.2 wxPython 2.8.12.0
https://www.daniweb.com/programming/software-development/threads/414135/wxpython-freezes-when-i-use-time-sleep
CC-MAIN-2018-17
refinedweb
330
71.21
Aggregations: Min, Max, and Everything In Between Often when faced with a large amount of data, a first step is to compute summary statistics for the data in question. Perhaps the most common summary statistics are the mean and standard deviation, which allow you to summarize the "typical" values in a dataset, but other aggregates are useful as well (the sum, product, median, minimum and maximum, quantiles, etc.). NumPy has fast built-in aggregation functions for working on arrays; we'll discuss and demonstrate some of them here. import numpy as np L = np.random.random(100) sum(L) 55.61209116604941 The syntax is quite similar to that of NumPy's sum function, and the result is the same in the simplest case: np.sum(L) 55.612091166049424 However, because it executes the operation in compiled code, NumPy's version of the operation is computed much more quickly: big_array = np.random.rand(1000000) %timeit sum(big_array) %timeit np.sum(big_array) 10 loops, best of 3: 104 ms per loop 1000 loops, best of 3: 442 µs per loop Be careful, though: the sum function and the np.sum function are not identical, which can sometimes lead to confusion! In particular, their optional arguments have different meanings, and np.sum is aware of multiple array dimensions, as we will see in the following section. min(big_array), max(big_array) (1.1717128136634614e-06, 0.9999976784968716) NumPy's corresponding functions have similar syntax, and again operate much more quickly: np.min(big_array), np.max(big_array) (1.1717128136634614e-06, 0.9999976784968716) %timeit min(big_array) %timeit np.min(big_array) 10 loops, best of 3: 82.3 ms per loop 1000 loops, best of 3: 497 µs per loop For min, max, sum, and several other NumPy aggregates, a shorter syntax is to use methods of the array object itself: print(big_array.min(), big_array.max(), big_array.sum()) 1.17171281366e-06 0.999997678497 499911.628197 Whenever possible, make sure that you are using the NumPy version of these aggregates when operating on NumPy arrays! M = np.random.random((3, 4)) print(M) [[ 0.8967576 0.03783739 0.75952519 0.06682827] [ 0.8354065 0.99196818 0.19544769 0.43447084] [ 0.66859307 0.15038721 0.37911423 0.6687194 ]] By default, each NumPy aggregation function will return the aggregate over the entire array: M.sum() 6.0850555667307118 Aggregation functions take an additional argument specifying the axis along which the aggregate is computed. For example, we can find the minimum value within each column by specifying axis=0: M.min(axis=0) array([ 0.66859307, 0.03783739, 0.19544769, 0.06682827]) The function returns four values, corresponding to the four columns of numbers. Similarly, we can find the maximum value within each row: M.max(axis=1) array([ 0.8967576 , 0.99196818, 0.6687194 ]) The way the axis is specified here can be confusing to users coming from other languages. The axis keyword specifies the dimension of the array that will be collapsed, rather than the dimension that will be returned. So specifying axis=0 means that the first axis will be collapsed: for two-dimensional arrays, this means that values within each column will be aggregated. Other aggregation functions¶ NumPy provides many other aggregation functions, but we won't discuss them in detail here. Additionally, most aggregates have a NaN-safe counterpart that computes the result while ignoring missing values, which are marked by the special IEEE floating-point NaN value (for a fuller discussion of missing data, see Handling Missing Data). Some of these NaN-safe functions were not added until NumPy 1.8, so they will not be available in older NumPy versions. The following table provides a list of useful aggregation functions available in NumPy: We will see these aggregates often throughout the rest of the book. Aggregates available in NumPy can be extremely useful for summarizing a set of values. As a simple example, let's consider the heights of all US presidents. This data is available in the file president_heights.csv, which is a simple comma-separated list of labels and values: !head -4 data/president_heights.csv order,name,height(cm) 1,George Washington,189 2,John Adams,170 3,Thomas Jefferson,189 import pandas as pd data = pd.read_csv('data/president_heights.csv') heights = np.array(data['height(cm)']) print(heights) [189 170 189 163 183 171 185 168 173 183 173 173 175 178 183 193 178 173 174 183 183 168 170 178 182 180 183 178 182 188 175 179 183 193 182 183 177 185 188 188 182 185] Now that we have this data array, we can compute a variety of summary statistics: print("Mean height: ", heights.mean()) print("Standard deviation:", heights.std()) print("Minimum height: ", heights.min()) print("Maximum height: ", heights.max()) Mean height: 179.738095238 Standard deviation: 6.93184344275 Minimum height: 163 Maximum height: 193 Note that in each case, the aggregation operation reduced the entire array to a single summarizing value, which gives us information about the distribution of values. We may also wish to compute quantiles: print("25th percentile: ", np.percentile(heights, 25)) print("Median: ", np.median(heights)) print("75th percentile: ", np.percentile(heights, 75)) 25th percentile: 174.25 Median: 182.0 75th percentile: 183.0 We see that the median height of US presidents is 182 cm, or just shy of six feet. Of course, sometimes it's more useful to see a visual representation of this data, which we can accomplish using tools in Matplotlib (we'll discuss Matplotlib more fully in Chapter 4). For example, this code generates the following chart: %matplotlib inline import matplotlib.pyplot as plt import seaborn; seaborn.set() # set plot style plt.hist(heights) plt.title('Height Distribution of US Presidents') plt.xlabel('height (cm)') plt.ylabel('number'); These aggregates are some of the fundamental pieces of exploratory data analysis that we'll explore in more depth in later chapters of the book.
https://jakevdp.github.io/PythonDataScienceHandbook/02.04-computation-on-arrays-aggregates.html
CC-MAIN-2019-18
refinedweb
983
57.67
/> In this post I'll write an implementation in Python Python provides the functionality already, but I hope you agree it is a worthwhile programming exercise. There are several versions of the formula, including two sub-versions of each, one for the Gregorian calendar and one for the Julian. This is the Gregorian version of the formula I will be implementing, in an image stolen from Wikipedia./> Note that the symbols like an elongated letter L and it's mirror-image twin denote "floor", ie the result of the term is rounded down to the nearest integer. The full Wikipedia article is here and is worth at least skimming. Rewritten in a more computer-friendly way we get Zeller's Congruence h=(q+((13*(m+1))/5)+Y+(Y/4)-(Y/100)+(Y/400))%7 Starting to Code Create a new folder and within it create the following empty files. You can also download the source code as a zip or clone/download from Github if you prefer. - zeller.py - main.py Source Code Links Open zeller.py and type or copy/paste the imports and first function. zeller.py part 1 import datetime import random import calendar import math def showdatesanddays(): """ Creates a selection of random dates and runs the Zeller Algorithm on them, printing out the date, and then the day according to Python and Zeller. """ # Zeller gives a value 0 to 6 representing Saturday to Friday zellerdays = ["Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] for i in range(0, 19): d = datetime.date.fromtimestamp(random.randint(1, 1000000000)) print("Date: " + str(d)) print("Python: " + calendar.day_name[d.weekday()]) print("Zeller: " + zellerdays[zellergregorian(d)]) print("------------------") The showdatesanddays function firstly creates a list of day names starting with Saturday. These correspond with the values returned by Zeller's Algorithm. We need to do this as "Python Weeks" start on a Monday. After that we enter a for loop which generates a number of random dates using the fromtimestamp and randint functions. The fromtimestamp function creates a date from the number of seconds from 1/1/1970, and using 1 billion as the upper limit of randint will create dates between 1/1/1970 and 9/9/2001, which is adequate to demonstrate the algorithm. After that we just need to print out the date and the corresponding day name using Python's calendar.day_name list. Finally we print out the day name again from the zellerdays list, using a call to our zellergregorian function as the list index. We can now implement that function so enter or paste it into zeller.py. zeller.py part 2 def zellergregorian(d): """ Runs the Zeller algorithm on the given date and returns the day index 0 to 6 for Saturday to Friday. """ q = d.day m = d.month Y = d.year # adjust month to run from 3 to 14 from March to February if m <= 2: m+= 12 # and also adjust year if January or February if d.month <= 2: Y -= 1 h = (q + math.floor((13 * (m + 1)) / 5) + Y + math.floor(Y / 4) - math.floor(Y / 100) + math.floor(Y / 400)) % 7 return h In zellergregorian we first declare three variables for day, month and year, setting them to the values from the date function argument. Of course we could just use the values in the date directly but I wanted to use variable names in the formula which matched those used by Herr Zeller. (I don't know why day is called "q"!) We then need to adjust month and year if the month of our date is January or February as the algorithm uses years running from March to February, indexed 3 to 14. Finally we calculate the day index - if you examine this line carefully you will see it implements the algorithm given above exactly. Note the use of the math.floor function to round down various terms to the nearest integer. Now open main.py and after a line to print the heading we call showdatesanddays. main.py import zeller def main(): """ Zeller's Congruence calculates the day of the week from the given date. """ print("-----------------------------------") print("| codedrome.com |") print("| Zeller's Congruence: |") print("| Calculating the Day of the Week |") print("-----------------------------------") zeller.showdatesanddays() main() Now we can run the program with this command... Run python3.7 main.py ...which will give us this output. Program Output (partial) ----------------------------------- | codedrome.com | | Zeller's Congruence: | | Calculating the Day of the Week | ----------------------------------- Date: 1983-05-07 Python: Saturday Zeller: Saturday ------------------ Date: 1981-02-25 Python: Wednesday Zeller: Wednesday ------------------ Date: 1977-12-04 Python: Sunday Zeller: Sunday ------------------ Date: 1974-08-04 Python: Sunday Zeller: Sunday ------------------ Date: 2000-08-22 Python: Tuesday Zeller: Tuesday ------------------ Date: 1996-07-03 Python: Wednesday Zeller: Wednesday ------------------ You will be pleased to see that Python and Zeller days are the same for all dates.
https://www.codedrome.com/calculating-the-day-of-the-week-with-zellers-congruence-in-python/
CC-MAIN-2021-25
refinedweb
807
63.39
"Less is more" - this is a credo that I try my best to live by every single day. It's both amusing and sad to see how people can complicate the utterly simple to the point of absurdity. I remember a newsgroup post I responded to recently that had some 30 lines of HttpWebRequest / Response code to get an XmlDocument from a remote Uri. I responded with this suggestion:XmlDocument doc = new XmlDocument();doc.Load(RemoteUri); Currently I'm writing an FTP "Concentrator" for extensible future use that will run as a scheduled task and will FTP webserver log files from a number of different sites, preprocess the log files to remove unnecessary lines (WebTrends licensing charges "by the line", so you really don't need to pay for Jpegs, css or whatever), and then it will save the processed log files in specific folders for Webtrends to analyze. Clients will be able to log on and see their specific reports. So the first thing is of course, we need a configuration file that can handle a collection of the same element or node - each node holds the information for a particular FTP session such as, "Name", "HostAddress", "UserName", "Password", "RemotePath", "LocalPath" and so on. You could have 10 of these, each one responsible for concentrating the server log files into a specific local folder on which WebTrends has been configured to use as a Data Source for reports. The "concentrator" app will be a .NET console app that will be run daily via Task Scheduler; it will start, do it's thing, deposit all the files, write status messages to the Application Event Log, and then quit. So I started out thinking that I needed to study up on Custom Configuration handlers and sections. Let me tell you, this is not easy stuff. There is a lot to know, and you have to write custom classes to represent your "stuff". On top of that, if you want to expose collections in the app.config or web.config, you have to write even more code. "But wait a minute", I thought. "Why does this stuff have to be in the standard configuration file? My app can load it from any file, Xml or other." So, being a firm believer in "Less is more", I stopped and put on my Green Thinking Hat (a - la Edward de Bono). I said, "Let's have a little Green Hat (creative) thinking here..." Turns out that the first thing I came up with was the best - our old friend, the DataSet. Here's the deal: if a user needs to be able to edit data, we can provide them with a windows forms utility app that will: 1) create a new DataSet with exactly the schema needed for our application.2) Show this in a DataGridView so the user can easily add rows, edit a row, or even delete a row, and3) Save the DataSet via WriteXml to the filename of the user's choice.4) We can also Load an existing DataSet's Xml representation so it can be edited.At runtime, we can get the DataSet very easily:DataSet configDs = new DataSet();configDs.ReadXml(System.Environment.CurrentDirectory + @"\config.xml");So here's the basic code to pull this off.: using System; using System.Data; using System.Windows.Forms; namespace FtpConfigUtility { public partial class Form1 : Form { private DataSet ds = null; private string fileNameAndPath = null; public Form1() { InitializeComponent(); } private void btnNew_Click(object sender, EventArgs e) { ds = new DataSet(); ds.DataSetName = "config"; DataTable cfgTable = new DataTable(); cfgTable.TableName = "FtpConfig"; cfgTable.Columns.Add("Name"); cfgTable.Columns.Add("HostAddress"); cfgTable.Columns.Add("UserName"); cfgTable.Columns.Add("Password"); cfgTable.Columns.Add("RemotePath"); cfgTable.Columns.Add("LocalPath"); ds.Tables.Add(cfgTable); dataGridView1.DataSource = cfgTable; } private void btnSave_Click(object sender, EventArgs e) { DialogResult res = saveFileDialog1.ShowDialog(); if (res == DialogResult.OK) ds.WriteXml(saveFileDialog1.FileName); } private void btnLoad_Click(object sender, EventArgs e) { webBrowser1.Visible = false; dataGridView1.Visible = true; openFileDialog1.Filter = "Xml files (*.xml)|*.xml|All files (*.*)|*.*"; DialogResult res = openFileDialog1.ShowDialog(); if (res == DialogResult.OK) { fileNameAndPath = openFileDialog1.FileName; ds = new DataSet(); ds.ReadXml(fileNameAndPath); dataGridView1.DataSource = ds.Tables[0]; } } private void button1_Click(object sender, EventArgs e) { webBrowser1.Visible = true; this.dataGridView1.Visible = false; webBrowser1.Navigate("about:blank"); webBrowser1.Navigate(fileNameAndPath); } } }
http://www.eggheadcafe.com/tutorials/aspnet/68461af9-8dcd-4085-803d-329a2cdc9f44/custom-configuration-data.aspx
crawl-001
refinedweb
708
57.37
I pie charts, column charts, and line charts. Some of the charts comes with a 2D and a 3D version. Of course, every good thing must have some drawbacks. Your visitors must have the Flash plugin installed (98% of US users have it installed, according to a study stated in Wikipedia). Moreover, the FusionChart component has a commercial license, but comes with a free trial. If you are not too bothered by that, take a look at TGFusionCharts. Hi, My page show: no data to display controllers.py ### import turbogears as tg from turbogears import controllers, expose, flash, widgets, validators, error_handler, validate from tg_fusion_charts import Column3DChartWidget, Pie2DChartWidget, SingleSeriesChart class Root(controllers.RootController): @expose(template=”gs.templates.first_chart”) def index(self): return dict(chart=Column3DChartWidget(chart_id=’chart1′, width=200, height=200, chart=SingleSeriesChart([3,4,1,5], caption=”New Incoming Links”))) ### Please help, thanks. Try to compare the generated javascript code on your pages to the code that exists at the source of
http://www.thesamet.com/blog/2007/07/25/add-eye-catching-flash-charts-to-your-turbogears-application/
CC-MAIN-2020-16
refinedweb
162
57.06
Map types to solver-specific data-types and enums. More... #include <Amesos2_TypeMap.hpp> Map types to solver-specific data-types and enums. Some direct linear sparse solvers have custom data types that are more commonly represented as other data types. For example, Superlu uses a custom doublecomplex data types to represent double-precision complex data. Such a scalar is more commonly represented by std::complex<double> . Superlu then also uses an enum class called Dtype to flag the data type for certain methods. Amesos2 uses TypeMap to easily access such data types. This class can be template specialized for each Amesos2::Solver subclass and its supported types. This also provides a compile time check for whether a solver can handle a data type. It is up to the programmer/user to determine whether the data-type they have may be safely coerced to a type supported by the ConcreteSolver, perhaps with the help of Teuchos::as<>. Appropriate type conversions may be provided with through template specialization of Teuchos::as<>. The default instance is empty, but specialized instances for each ConcreteSolver should contain at the minimum a typedef called type and other typedefs as appropriate for the ConcreteSolver's needs
http://trilinos.sandia.gov/packages/docs/r11.0/packages/amesos2/doc/html/structAmesos2_1_1TypeMap.html
CC-MAIN-2013-48
refinedweb
199
55.84
19 July 2010 08:32 [Source: ICIS news] SINGAPORE (ICIS news)--India’s Oil and Natural Gas Corp (ONGC) has sold by tender only one 35,000 tonne cargo of naphtha for loading on 10-11 August, instead of 70,000 tonnes as planned, traders said on Monday. The buyer was energy major Shell, they said. The cargo fetched a discount of $5.50/tonne (€4.24/tonne) to ?xml:namespace> Prices fell drastically due to a bearish naphtha market, which was awash in surplus and poor demand, they said. ONGC last sold by tender 35,000 tonnes of naphtha at a premium of $6.00-7.00/tonne
http://www.icis.com/Articles/2010/07/19/9377342/indias-ongc-sells-35000-tonnes-naphtha-for-10-11-aug.html
CC-MAIN-2015-11
refinedweb
109
69.52
MFC Topics: Message Boxes Introduction to Message Boxes Definition A message box is a bordered rectangular window that displays a short message to the user. The message can be made of one sentence, various lines, or a few paragraphs. The user cannot change the text but can only read. A message box is created either to inform the user about something or to request his or her decision about an issue. When a dialog box displays from an application, the user must close it before continuing using the application. This means that, as long as the message box is displaying, the user cannot access any other part of the application until the message box is first dismissed. The simplest message box is used to display a message to the user. This type of message box is equipped with only one button, labeled OK. Here is an example: Figure 34: A Simple Message Box A more elaborate or detailed message box can display an icon and/or can have more than one button: Practical Learning: Starting an MFC Application #include <afxwin.h> class CExerciseApp : public CWinApp { BOOL InitInstance() { return TRUE; } }; CExerciseApp theApp; Creating a Message Box To create a message box, the Win32 library provides a global function called MessageBox. Its syntax is: int MessageBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType); If you want to use this version from Win32, because it is defined outside of MFC, you should start it with the scope access operator “::” as follows: ::MessageBox(. . .); As we will see shortly, the Win32's MessageBox() function requires a handle (not necessarily difficult to provide but still). To make the creation of a message a little easier, the MFC library provides its own version of the MessageBox() function. Its syntax is: int MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption = NULL, UINT nType = MB_OK); To still make it easier, the MFC framework provides the AfxMessageBox function used to create a message box. Although this function is global, its scope is limited to MFC applications. This means that you can use the Win32's global MessageBox() function with any compiler used on the Microsoft Windows operating systems but you cannot use the MFC's global AfxMessageBox() function with any compiler other Visual C++. The AfxMessageBox() function is overloaded with two versions whose syntaxes are: int AfxMessageBox(LPCTSTR lpszText, UINT nType = MB_OK, UINT nIDHelp = 0); int AFXAPI AfxMessageBox(UINT nIDPrompt, UINT nType = MB_OK, UINT nIDHelp = (UINT) -1); Based on the above functions, a message box can be illustrated as follows: The Parameters of a Message Box The Owner of a Message Box As seen above, you have the choice among three functions to create a message. There is no valid reason that makes one of them better than the other. They do exactly the same thing. The choice will be based on your experience and other factors. If you decide to use the Win32's MessageBox() function, you must specify the handle to the application that created the message box. As we will learn eventually when we study controls, you can get a handle to a (CWnd-derived) control with a call to m_hWnd. For example, if a button on a dialog box initiates the message box, you can start this function as follows: ::MessageBox(m_hWnd, …); We also saw that you can get a pointer to the main window by calling the MFC's global AfxGetMainWnd() function. This function only points you to the application. To get a handle to the application, you can call the same m_hWnd member variable. In this case, the message box can be started with: ::MessageBox(AfxGetMainWnd()->m_hWnd, …); If you are creating a message but do not want a particular window to own it, pass this hWnd argument as NULL. Using a String Resource If you decide to call the AfxMessageBox() function, as seen previously, you have two options. You can pass a string as argument. Here is an example: AfxMessageBox(L"Welcome to Microsoft Foundation Class Library."); An alternative is to pass a string identifier from a resource file. Practical Learning: Creating a Message Box #include <afxwin.h> #include "resource.h" class CExerciseApp : public CWinApp { BOOL InitInstance() { AfxMessageBox(IDS_ANNOUNCE); return TRUE; } }; CExerciseApp theApp; The Message of the Box For all the message box functions, the Text argument a null-terminated string. It specifies the text that would be displayed to the user. This argument is required. Here is an example that uses the MessageBox() function: AfxMessageBox(L"The name you entered is not in our records"); If you want to display the message on various lines, you can separate sections with the new line character '\n'. Here is an example: AfxMessageBox(L"If you think there is a mistake,\nplease contact Human Resources"); If the message you are creating is too long to fit on one line, you can separate lines by ending each with a double-quote and starting the next line with a new double-quote. As long as you have not closed the function, the string would be considered as one entity. You can also use string editing and formatting techniques to create a more elaborate message. This means that you can use functions of the C string library to create your message. Practical Learning: Displaying a Message #include <afxwin.h> #include "resource.h" class CExerciseApp : public CWinApp { BOOL InitInstance() { AfxMessageBox(L"The name you entered is not in our records.\n" L"If you think there is a mistake, please contact HR.\n" L"You can also send an email to humanres@functionx.com"); return TRUE; } }; CExerciseApp theApp; The Message's Title The caption of the message box is the text that displays on its title bar. If you create a message box using the AfxMessageBox() function, it allows you to specify only one argument, namely the text to display to the user, which is the value of the Text argument. In this case, the title bar of the message box would display the name of the application that "owns" the message box. If you want to display your own caption on the title bar, call the MessageBox() function. Specify the argument for the caption. The Caption argument is a null-terminated string that would display on the title bar of the message box. Here is an example: MessageBox(NULL, L"Due to an unknown internal error, this application will now close.", L"Regular Warning", 0); Although the Caption argument is optional in the MFC,s MessageBox() and the AfxMessageBox() functions, it is required for the Win32's MessageBox() function. Because it is in fact a pointer, you can pass it as NULL. Here is an example: MessageBox(NULL, L"Due to an unknown internal error, this application will now close.", NULL, 0); In this case, the title bar of the message box would display Error: This caption may not be friendly on most applications and could appear frightening to the user. Therefore, unless you are in a hurry, you should strive to provide a friendly and more appropriate title. Practical Learning: Displaying a Message's Caption #include <afxwin.h> #include "resource.h" class CExerciseApp : public CWinApp { BOOL InitInstance() { MessageBox(NULL, L"The name you entered is not in our records.\n" L"If you think there is a mistake, please contact HR.\n" L"You can also send an email to humanres@functionx.com", L"Failed Logon Attempt", 0); return TRUE; } }; CExerciseApp theApp; Message Box Buttons The uType argument is used to provide some additional options to the message box. First, it is used to display one or a few buttons. The buttons depend on the value specified for the argument. If this argument is not specified, the message box displays (only) OK. Otherwise, you can display a message box with a combination of selected buttons. To display one or more buttons, the uType argument uses a constant value that controls what button(s) to display. The values and their buttons can be specified as follows: Here is an example: AfxMessageBox(L"Due to an unknown internal error, this application will now close.\n" L"Do you want to save the file before closing?", MB_YESNO); Practical Learning: Showing Message Box Buttons #include <afxwin.h> #include "resource.h" class CExerciseApp : public CWinApp { BOOL InitInstance() { ::MessageBox(NULL, L"The username you entered is not in our records.\n" L"Do you wish to contact Human Resources?", L"Failed Logon Attempt", MB_YESNO); return TRUE; } }; CExerciseApp theApp; Message Box Icons Besides the buttons, the message box can also display an icon that accompanies the message. Each icon is displayed by specifying a constant integer. The values and their buttons are as follows: The icons are used in conjunction with the buttons constant. To combine these two flags, use the bitwise OR operator “|”. Here is an example: AfxMessageBox(L"Due to an unknown internal error, this application will now close.\n" L"Do you want to save the file before closing?", MB_YESNO | MB_ICONWARNING); Practical Learning: Showing an Icon on a Message Box #include <afxwin.h> #include "resource.h" class CExerciseApp : public CWinApp { BOOL InitInstance() { MessageBox(NULL, L"The credentials you entered are not in our records.\n" L"What do you want to do? Click:\n" L"Yes\tto contact Human Resources\n" L"No\tto close the application\n" L"Cancel\tto try again\n", L"Failed Logon Attempt", MB_YESNOCANCEL | MB_ICONQUESTION); return TRUE; } }; CExerciseApp theApp; The Default Button When a message box is configured to display more than one button, the operating system is set to decide which button is the default. The default button has a thick border that sets it apart from the other button(s). If the user presses Enter, the message box would behave as if the user had clicked the default button. Fortunately, if the message box has more than one button, you can decide what button would be the default. To specify the default button, add one of the following constants to the uType combination: To specify the default button, use the bitwise OR operator "|" to combine the constant integer of the desired default button with the button's constant and the icon. The Message's Return Value After using the message box, the user must close it by clicking a button on it. Clicking OK usually means that the user acknowledged the message. Clicking Cancel usually means the user is changing his or her mind about the action performed previously. Clicking Yes instead of No usually indicates that the user agrees with whatever is going on. In reality, the message box only displays a message and one or a few buttons. The function used to create the message box returns a natural number that you can use as you see fit. The return value itself is a registered constant integer and can be one of the following: Practical Learning: Returning a Value from on a Message Box #include <afxwin.h> #include "resource.h" class CExerciseApp : public CWinApp { BOOL InitInstance() { int Answer; Answer = AfxMessageBox(L"Due to an unknown internal error, " L"this application will now close.\n" L"Do you want to save the file before closing?", MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2); if( Answer == IDYES ) AfxMessageBox(L"You selected Yes"); else // if( Answer == IDNO ) AfxMessageBox(L"You selected No"); return TRUE; } }; CExerciseApp theApp;
http://functionx.com/visualc/msgboxes/messageboxes.htm
CC-MAIN-2018-30
refinedweb
1,873
53.51
Book Excerpt: Chapter 6: Functions and Functional Programming Read an excerpt from the 4th Edition of the book Python Essential Reference by David Beazley. 6: Functions and Functional Programming Substantial programs are broken up into functions for better modularity and ease of maintenance. Python makes it easy to define functions but also incorporates a surprising number of features from functional programming languages. This chapter describes the basic mechanisms associated with Python functions including scoping rules, closures, decorators, generators, and coroutines. Functions Functions are defined with the def statement: def add(x,y): return x + y The body of a function is simply a sequence of statements that execute when the function is called. You invoke a function by writing the function name followed by a tuple of function arguments, such as a = add(3,4). The order and number of arguments must match those given in the function definition. If a mismatch exists, a TypeError exception is raised. You can attach default arguments to function parameters by assigning values in the function definition. For example: def split(line,delimiter=','): statements When a function defines a parameter with a default value, that parameter and all the parameters that follow are optional. If values are not assigned to all the optional parameters in the function definition, a SyntaxError exception is raised. Default parameter values are always set to the objects that were supplied as values when the function was defined. Here’s an example: a = 10 def foo(x=a): return x a = 5 # Reassign 'a'. foo() # returns 10 (default value not changed) In addition, the use of mutable objects as default values may lead to unintended behavior: def foo(x, items=[]): items.append(x) return items foo(1) # returns [1] foo(2) # returns [1, 2] foo(3) # returns [1, 2, 3] Notice how the default argument retains modifications made from previous invocations. To prevent this, it is better to use None and add a check as follows: def foo(x, items=None): if items is None: items = [] items.append(x) return items A function can accept a variable number of parameters if an asterisk (*) is added to the last parameter name: def fprintf(file, fmt, *args): file.write(fmt % args) # Use fprintf. args gets (42,"hello world", 3.45) fprintf(out,"%d %s %f", 42, "hello world", 3.45) In this case, all the remaining arguments are placed into the args variable as a tuple. To pass a tuple args to a function as if they were parameters, the *args syntax can be used in a function call as follows: def printf(fmt, *args): # Call another function and pass along args fprintf(sys.stdout, fmt, *args) Function arguments can also be supplied by explicitly naming each parameter and specifying a value. These are known as keyword arguments. Here is an example: def foo(w,x,y,z): statements # Keyword argument invocation foo(x=3, y=22, w='hello', z=[1,2]) With keyword arguments, the order of the parameters doesn’t matter. However, unless there are default values, you must explicitly name all of the required function parameters. If you omit any of the required parameters or if the name of a keyword doesn’t match any of the parameter names in the function definition, a TypeError exception is raised. Also, since any Python function can be called using the keyword calling style, it is generally a good idea to define functions with descriptive argument names. Positional arguments and keyword arguments can appear in the same function call, provided that all the positional arguments appear first, values are provided for all non-optional arguments, and no argument value is defined more than once. Here’s an example: foo('hello', 3, z=[1,2], y=22) foo(3, 22, w='hello', z=[1,2]) # TypeError. Multiple values for w If the last argument of a function definition begins with **, all the additional keyword arguments (those that don’t match any of the other parameter names) are placed in a dictionary and passed to the function. This can be a useful way to write functions that accept a large number of potentially open-ended configuration options that would be too unwieldy to list as parameters. Here’s an example: def make_table(data, **parms): # Get configuration parameters from parms (a dict) fgcolor = parms.pop("fgcolor","black") bgcolor = parms.pop("bgcolor","white") width = parms.pop("width",None) ... # No more options if parms: raise TypeError("Unsupported configuration options %s" % list(parms)) make_table(items, fgcolor="black", bgcolor="white", border=1, borderstyle="grooved", cellpadding=10, width=400) You can combine extra keyword arguments with variable-length argument lists, as long as the ** parameter appears last: # Accept variable number of positional or keyword arguments def spam(*args, **kwargs): # args is a tuple of positional args # kwargs is dictionary of keyword args ... Keyword arguments can also be passed to another function using the **kwargs syntax: def callfunc(*args, **kwargs): func(*args,**kwargs) This use of *args and **kwargs is commonly used to write wrappers and proxies for other functions. For example, the callfunc() accepts any combination of arguments and simply passes them through to func(). Parameter Passing and Return Values When a function is invoked, the function parameters are simply names that refer to the passed input objects. The underlying semantics of parameter passing doesn’t neatly fit into any single style, such as “pass by value” or “pass by reference,” that you might know about from other programming languages. For example, if you pass an immutable value, the argument effectively looks like it was passed by value. However, if a mutable object (such as a list or dictionary) is passed to a function where it’s then modified, those changes will be reflected in the original object. Here’s an example: a = [1, 2, 3, 4, 5] def square(items): for i,x in enumerate(items): items[i] = x * x # Modify items in-place square(a) # Changes a to [1, 4, 9, 16, 25] Functions that mutate their input values or change the state of other parts of the program behind the scenes like this are said to have side effects. As a general rule, this is a programming style that is best avoided because such functions can become a source of subtle programming errors as programs grow in size and complexity (for example, it’s not obvious from reading a function call if a function has side effects). Such functions interact poorly with programs involving threads and concurrency because side effects typically need to be protected by locks. The return statement returns a value from a function. If no value is specified or you omit the return statement, the None object is returned. To return multiple values, place them in a tuple: def factor(a): d = 2 while (d <= (a / 2)): if ((a / d) * d == a): return ((a / d), d) d = d + 1 return (a, 1) Multiple return values returned in a tuple can be assigned to individual variables: x, y = factor(1243) # Return values placed in x and y. or (x, y) = factor(1243) # Alternate version. Same behavior. Scoping Rules Each time a function executes, a new local namespace is created. This namespace represents a local environment that contains the names of the function parameters, as well as the names of variables that are assigned inside the function body. When resolving names, the interpreter first searches the local namespace. If no match exists, it searches the global namespace. The global namespace for a function is always the module in which the function was defined. If the interpreter finds no match in the global namespace, it makes a final check in the built-in namespace. If this fails, a NameError exception is raised. One peculiarity of namespaces is the manipulation of global variables within a function. For example, consider the following code: a = 42 def foo(): a = 13 foo() # a is still 42 When this code executes, a retains its value of 42, despite the appearance that we might be modifying the variable a inside the function foo. When variables are assigned inside a function, they’re always bound to the function’s local namespace; as a result, the variable a in the function body refers to an entirely new object containing the value 13, not the outer variable. To alter this behavior, use the global statement. global simply declares names as belonging to the global namespace, and it’s necessary only when global variables will be modified. It can be placed anywhere in a function body and used repeatedly. Here’s an example: a = 42 b = 37 def foo(): global a # 'a' is in global namespace a = 13 b = 0 foo() # a is now 13. b is still 37. Python supports nested function definitions. Here’s an example: def countdown(start): n = start def display(): # Nested function definition print('T-minus %d' % n) while n > 0: display() n -= 1 Variables in nested functions are bound using lexical scoping. That is, names are resolved by first checking the local scope and then all enclosing scopes of outer function definitions from the innermost scope to the outermost scope. If no match is found, the global and built-in namespaces are checked as before. Although names in enclosing scopes are accessible, Python 2 only allows variables to be reassigned in the innermost scope (local variables) and the global namespace (using global). Therefore, an inner function can’t reassign the value of a local variable defined in an outer function. For example, this code does not work: def countdown(start): n = start def display(): print('T-minus %d' % n) def decrement(): n -= 1 # Fails while n > 0: display() decrement() In Python 2, you can work around this by placing values you want to change in a list or dictionary. In Python 3, you can declare n as nonlocal as follows: def countdown(start): n = start def display(): print('T-minus %d' % n) def decrement(): nonlocal n # Bind to outer n (Python 3 only) n -= 1 while n > 0: display() decrement() Functions as Objects and Closures Functions are first-class objects in Python. This means that they can be passed as arguments to other functions, placed in data structures, and returned by a function as a result. Here is an example of a function that accepts another function as input and calls it: # foo.py def callf(func): return func() Here is an example of using the above function: >>> import foo >>> def helloworld(): ... return 'Hello World' ... >>> foo.callf(helloworld) # Pass a function as an argument 'Hello World' >>> When a function is handled as data, it implicitly carries information related to the surrounding environment where the function was defined. This affects how free variables in the function are bound. As an example, consider this modified version foo.py that now contains a variable definition: # foo.py x = 42 def callf(func): return func() Now, observe the behavior of this example: >>> import foo >>> x = 37 >>> def helloworld(): ... return "Hello World. x is %d" % x ... >>> foo.callf(helloworld) # Pass a function as an argument 'Hello World. x is 37' >>> In this example, notice how the function helloworld() uses the value of x that’s defined in the same environment as where helloworld() was defined. Thus, even though there is also an x defined in foo.py and that’s where helloworld() is actually being called, that value of x is not the one that’s used when helloworld() executes. When the statements that make up a function are packaged together with the environment in which they execute, the resulting object is known as a closure. The behavior of the previous example is explained by the fact that all functions have a __globals__ attribute that points to the global namespace in which the function was defined. This always corresponds to the enclosing module in which a function was defined. For the previous example, you get the following: >>> helloworld.__globals__ {'__builtins__': <module '__builtin__' (built-in)>, 'helloworld': <function helloworld at 0x7bb30>, 'x': 37, '__name__': '__main__', '__doc__': None 'foo': <module 'foo' from 'foo.py'>} >>> When nested functions are used, closures capture the entire environment needed for the inner function to execute. Here is an example: import foo def bar(): x = 13 def helloworld(): return "Hello World. x is %d" % x foo.callf(helloworld) # returns 'Hello World, x is 13' Closures and nested functions are especially useful if you want to write code based on the concept of lazy or delayed evaluation. Here is another example: from urllib import urlopen # from urllib.request import urlopen (Python 3) def page(url): def get(): return urlopen(url).read() return get In this example, the page() function doesn’t actually carry out any interesting computation. Instead, it merely creates and returns a function get() that will fetch the contents of a web page when it is called. Thus, the computation carried out in get() is actually delayed until some later point in a program when get() is evaluated. For example: >>> python = page("") >>> jython = page("") >>> python <function get at 0x95d5f0> >>> jython <function get at 0x9735f0> >>> pydata = python() # Fetches >>> jydata = jython() # Fetches >>> In this example, the two variables python and jython are actually two different versions of the get() function. Even though the page() function that created these values is no longer executing, both get() functions implicitly carry the values of the outer variables that were defined when the get() function was created. Thus, when get() executes, it calls urlopen(url) with the value of url that was originally supplied to page(). With a little inspection, you can view the contents of variables that are carried along in a closure. For example: >>> python.__closure__ (<cell at 0x67f50: str object at 0x69230>,) >>> python.__closure__[0].cell_contents '' >>> jython.__closure__[0].cell_contents '' >>> A closure can be a highly efficient way to preserve state across a series of function calls. For example, consider this code that runs a simple counter: def countdown(n): def next(): nonlocal n r = n n -= 1 return r return next # Example use next = countdown(10) while True: v = next() # Get the next value if not v: break In this code, a closure is being used to store the internal counter value n. The inner function next() updates and returns the previous value of this counter variable each time it is called. The fact that closures capture the environment of inner functions also make them useful for applications where you want to wrap existing functions in order to add extra capabilities. This is described next. Decorators A decorator is a function whose primary purpose is to wrap another function. The primary purpose of this wrapping is to transparently alter or enhance the behavior of the object being wrapped. Syntactically, decorators are denoted using the special @ symbol as follows: @trace def square(x): return x*x The preceding code is shorthand for the following: def square(x): return x*x square = trace(square) In the example, a function square() is defined. However, immediately after its definition, the function object itself is passed to the function trace(), which returns an object that replaces the original square. Now, let’s consider an implementation of trace that will clarify how this might be useful: enable_tracing = True if enable_tracing: debug_log = open("debug.log","w") def trace(func): if enable_tracing: def callf(*args,**kwargs): debug_log.write("Calling %s: %s, %s\n" % (func.__name__, args, kwargs)) r = func(*args,**kwargs) debug_log.write("%s returned %s\n" % (func.__name, r)) return r return callf else: return func In this code, trace() creates a wrapper function that writes some debugging output and then calls the original function object. Thus, if you call square(), you will see the output of the write() methods in the wrapper. The function callf that is returned from trace() is a closure that serves as a replacement for the original function. A final interesting aspect of the implementation is that the tracing feature itself is only enabled through the use of a global variable enable_tracing as shown. If set to False, the trace() decorator simply returns the original function unmodified. Thus, when tracing is disabled, there is no added performance penalty associated with using the decorator. When decorators are used, they must appear on their own line immediately prior to a function or class definition. More than one decorator can also be applied. Here’s an example: @foo @bar @spam def grok(x): pass In this case, the decorators are applied in the order listed. The result is the same as this: def grok(x): pass grok = foo(bar(spam(grok))) Decorators can interact strangely with other aspects of functions such as recursion, documentation strings, and function attributes. These issues are described later in this chapter. Generators and yield If a function uses the yield keyword, it defines an object known as a generator. A generator is a function that produces a sequence of values for use in iteration. Here’s an example: def countdown(n): print("Counting down from %d" % n) while n > 0: yield n n -= 1 return If you call this function, you will find that none of its code starts executing. For example: >>> c = countdown(10) >>> Instead, a generator object is returned. The generator object, in turn, executes the function whenever next() is called (or __next__() in Python 3). Here’s an example: >>> c.next() # Use c.__next__() in Python 3 Counting down from 10 10 >>> c.next() 9 When next() is invoked, the generator function executes statements until it reaches a yield statement. The yield statement produces a result at which point execution of the function stops until next() is invoked again. Execution then resumes with the statement following yield. You normally don’t call next() directly on a generator but use it with the for statement, sum(), or some other operation that consumes a sequence. For example: for n in countdown(10): statements a = sum(countdown(10)) A generator function signals completion by returning or raising StopIteration, at which point iteration stops. It is never legal for a generator to return a value other than None upon completion. Coroutines and yield Expressions Inside a function, the yield statement can also be used as an expression that appears on the right side of an assignment operator. For example: def receiver(): print("Ready to receive") while True: n = (yield) print("Got %s" % n) A function that uses yield in this manner is known as a coroutine, and it executes in response to values being sent to it. Its behavior is also very similar to a generator. For example: >>> r = receiver() >>> r.next() # Advance to first yield (r.__next__() in Python 3) Ready to receive >>> r.send(1) Got 1 >>> r.send(2) Got 2 >>> r.send("Hello") Got Hello >>> In this example, the initial call to next() is necessary so that the coroutine executes statements leading to the first yield expression. At this point, the coroutine suspends, waiting for a value to be sent to it using the send() method of the associated generator object r. The value passed to send() is returned by the (yield) expression in the coroutine. Upon receiving a value, a coroutine executes statements until the next yield statement is encountered. The requirement of first calling next() on a coroutine is easily overlooked and a common source of errors. Therefore, it is recommended that coroutines be wrapped with a decorator that automatically takes care of this step. def coroutine(func): def start(*args,**kwargs): g = func(*args,**kwargs) g.next() return g return start Using this decorator, you would write and use coroutines using: @coroutine def receiver(): print("Ready to receive") while True: n = (yield) print("Got %s" % n) # Example use r = receiver() r.send("Hello World") # Note : No initial .next() needed A coroutine will typically run indefinitely unless it is explicitly shut down or it exits on its own. To close the stream of input values, use the close() method like this: >>> r.close() >>> r.send(4) Traceback (most recent call last): File "<stdin>", line 1, in <module> StopIteration Once closed, a StopIteration exception will be raised if further values are sent to a coroutine. The close() operation raises GeneratorExit inside the coroutine For example: def receiver(): print("Ready to receive") try: while True: n = (yield) print("Got %s" % n) except GeneratorExit: print("Receiver done") Exceptions can be raised inside a coroutine using the throw(exctype [, value [, tb]]) method where exctype is an exception type, value is the exception value, and tb is a traceback object. For example: >>> r.throw(RuntimeError,"You're hosed!") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 4, in receiver RuntimeError: You're hosed! Exceptions raised in this manner will originate at the currently executing yield statement in the coroutine. A coroutine can elect to catch exceptions and handle them as appropriate. It is not safe to use throw() as an asynchronous signal to a coroutine—it should never be invoked from a separate execution thread or in a signal handler. Using Generators and Coroutines At first glance, it might not be obvious how to use generators and coroutines for practical problems. However, generators and coroutines can be particularly effective when applied to certain kinds of programming problems in systems, networking, and distributed computation. For example, generator functions are useful if you want to set up a processing pipeline, similar in nature to using a pipe in the UNIX shell. Here is an example involving a set of generator functions related to finding, opening, reading, and processing files: import os import fnmatch def find_files(topdir, pattern): for path, dirname, filelist in os.walk(topdir): for name in filelist: if fnmatch.fnmatch(name, pattern): yield os.path.join(path,name) import gzip, bz2 def opener(filenames): for name in filenames: if name.endswith(".gz"): f = gzip.open(name) elif name.endswith(".bz2"): f = bz2.BZ2File(name) else: f = open(name) yield f def cat(filelist): for f in filelist: for line in f: yield line def grep(pattern, lines): for line in lines: if pattern in line: yield line Here is an example of using these functions to set up a processing pipeline: wwwlogs = find("www","access-log*") files = opener(wwwlogs) lines = cat(files) pylines = grep("python", lines) for line in pylines: sys.stdout.write(line) In this example, the program is processing all lines in all "access-log*" files found within all subdirectories of a top-level directory "www". Each "access-log" is tested for file compression and opened using an appropriate file opener. Lines are concatenated together and processed through a filter that is looking for a substring "python". The entire program is being driven by the for statement at the end. Each iteration of this loop pulls a new value through the pipeline and consumes it. Moreover, the implementation is highly memory-efficient because no temporary lists or other large data structures are ever created. Coroutines can be used to write programs based on data-flow processing. Programs organized in this way look like inverted pipelines. Instead of pulling values through a sequence of generator functions using a for loop, you send values into a collection of linked coroutines. Here is an example of coroutine functions written to mimic the generator functions shown previously: import os import fnmatch @coroutine def find_files(target): while True: topdir, pattern = (yield) for path, dirname, filelist in os.walk(topdir): for name in filelist: if fnmatch.fnmatch(name,pattern): target.send(os.path.join(path,name)) import gzip, bz2 @coroutine def opener(target): while True: name = (yield) if name.endswith(".gz"): f = gzip.open(name) elif name.endswith(".bz2"): f = bz2.BZ2File(name) else: f = open(name) target.send(f) @coroutine def cat(target): while True: f = (yield) for line in f: target.send(line) @coroutine def grep(pattern, target): while True: line = (yield) if pattern in line: target.send(line) @coroutine def printer(): while True: line = (yield) sys.stdout.write(line) Here is how you would link these coroutines to create a dataflow processing pipeline: finder = find_files(opener(cat(grep("python",printer())))) # Now, send a value finder.send(("www","access-log*")) finder.send(("otherwww","access-log*")) In this example, each coroutine sends data to another coroutine specified in the target argument to each coroutine. Unlike the generator example, execution is entirely driven by pushing data into the first coroutine find_files(). This coroutine, in turn, pushes data to the next stage. A critical aspect of this example is that the coroutine pipeline remains active indefinitely or until close() is explicitly called on it. Because of this, a program can continue to feed data into a coroutine for as long as necessary—for example, the two repeated calls to send() shown in the example. Coroutines can be used to implement a form of concurrency. For example, a centralized task manager or event loop can schedule and send data into a large collection of hundreds or even thousands of coroutines that carry out various processing tasks. The fact that input data is “sent” to a coroutine also means that coroutines can often be easily mixed with programs that use message queues and message passing to communicate between program components. Further information on this can be found in Chapter 20, “Threads and Concurrency.” The lambda Operator Anonymous functions in the form of an expression can be created using the lambda statement: lambda args : expression args is a comma-separated list of arguments, and expression is an expression involving those arguments. Here’s an example: a = lambda x,y : x+y r = a(2,3) # r gets 5 The code defined with lambda must be a valid expression. Multiple statements and other non-expression statements, such as for and while, cannot appear in a lambda statement. lambda expressions follow the same scoping rules as functions. The primary use of lambda is in specifying short callback functions. For example, if you wanted to sort a list of names with case-insensitivity, you might write this: names.sort(key=lambda n: n.lower()) Recursion Recursive functions are easily defined. For example: def factorial(n): if n <= 1: return 1 else: return n * factorial(n - 1) However, be aware that there is a limit on the depth of recursive function calls. The function sys.getrecursionlimit() returns the current maximum recursion depth, and the function sys.setrecursionlimit() can be used to change the value. The default value is 1000. Although it is possible to increase the value, programs are still limited by the stack size limits enforced by the host operating system. When the recursion depth is exceeded, a RuntimeError exception is raised. Python does not perform tail-recursion optimization that you often find in functional languages such as Scheme. Recursion does not work as you might expect in generator functions and coroutines. For example, this code prints all items in a nested collection of lists: def flatten(lists): for s in lists: if isinstance(s,list): flatten(s) else: print(s) items = [[1,2,3],[4,5,[5,6]],[7,8,9]] flatten(items) # Prints 1 2 3 4 5 6 7 8 9 However, if you change the print operation to a yield, it no longer works. This is because the recursive call to flatten() merely creates a new generator object without actually iterating over it. Here’s a recursive generator version that works: def genflatten(lists): for s in lists: if isinstance(s,list): for item in genflatten(s): yield item else: yield item Care should also be taken when mixing recursive functions and decorators. If a decorator is applied to a recursive function, all inner recursive calls now get routed through the decorated version. For example: @locked def factorial(n): if n <= 1: return 1 else: return n * factorial(n - 1) # Calls the wrapped version of factorial If the purpose of the decorator was related to some kind of system management such as synchronization or locking, recursion is something probably best avoided. Documentation Strings It is common practice for the first statement of function to be a documentation string describing its usage. For example: def factorial(n): """Computes n factorial. For example: >>> factorial(6) 120 >>> """ if n <= 1: return 1 else: return n*factorial(n-1) The documentation string is stored in the __doc__ attribute of the function that is commonly used by IDEs to provide interactive help. If you are using decorators, be aware that wrapping a function with a decorator can break the help features associated with documentation strings. For example, consider this code: def wrap(func): call(*args,**kwargs): return func(*args,**kwargs) return call @wrap def factorial(n): """Computes n factorial.""" ... If a user requests help on this version of factorial(), he will get a rather cryptic explanation: >>> help(factorial) Help on function call in module __main__: call(*args, **kwargs) (END) >>> To fix this, write decorator functions so that they propagate the function name and documentation string. For example: def wrap(func): call(*args,**kwargs): return func(*args,**kwargs) call.__doc__ = func.__doc__ call.__name__ = func.__name__ return call Because this is a common problem, the functools module provides a function wraps that can automatically copy these attributes. Not surprisingly, it is also a decorator: from functools import wraps def wrap(func): @wraps(func) call(*args,**kwargs): return func(*args,**kwargs) return call The @wraps(func) decorator, defined in functools, propagates attributes from func to the wrapper function that is being defined. Function Attributes Functions can have arbitrary attributes attached to them. Here’s an example: def foo(): statements foo.secure = 1 foo.private = 1 Function attributes are stored in a dictionary that is available as the __dict__ attribute of a function. The primary use of function attributes is in highly specialized applications such as parser generators and application frameworks that would like to attach additional information to function objects. As with documentation strings, care should be given if mixing function attributes with decorators. If a function is wrapped by a decorator, access to the attributes will actually take place on the decorator function, not the original implementation. This may or may not be what you want depending on the application. To propagate already defined function attributes to a decorator function, use the following template or the functools.wraps() decorator as shown in the previous section: def wrap(func): call(*args,**kwargs): return func(*args,**kwargs) call.__doc__ = func.__doc__ call.__name__ = func.__name__ call.__dict__.update(func.__dict__) return Python Very interesting introduction to Python. Yet another great python book ;) That's a very brave attempt to demystify how functions work in python Glad This Book is on order This is a good kind of excerpt to have, especially a discussion on functional programming.
http://www.linuxjournal.com/node/1008843
CC-MAIN-2017-30
refinedweb
5,102
52.7
06 July 2012 11:39 [Source: ICIS news] LONDON (ICIS)--BP and JBF Petrochemicals, a subsidiary of India-based polyester producer JBF Industries, have signed an agreement for licensing of BP’s purified terephthalic acid (PTA) technology, the UK energy giant said on Friday. BP said that JBF intends to build a 1.25m tonne/year unit at the Special Economic Zone in ?xml:namespace> Financial details of the plant and licence agreement were not disclosed. BP added that JBF expects the Mangalore plant to come on stream at the end of 2014. “This first third party, non-affiliate, licence recognises the quality of BP’s technology and builds on the excellent relationship between our companies. JBF is a world-class polyester producer and I’m proud that they’ve chosen BP’s leading technology,” said Nick Elmslie, chief executive of BP’s Global Petrochemicals Business. BP said that over the years the PTA market has continued to grow at a high rate, adding that over 80% of the demand is now in Asia, with around 50% in “The market is now of such a scale – greater than 50m tonnes/year and continuing to grow at close to 7% – that three or four new world-scale plants per year will be needed. This creates a material opportunity for us to add value by way of our technology,” said Elmslie. Chairman of JBF Industries and Director of JBF Petrochemicals, B.C.Arya, said: “This investment is highly strategic for us, fulfilling our captive requirements for PTA at the lowest possible cost. This will make our integrated
http://www.icis.com/Articles/2012/07/06/9575886/uks-bp-and-indias-jbf-petrochemicals-sign-pta-licence-agreement.html
CC-MAIN-2015-14
refinedweb
265
59.03
Reusable React controls for your SharePoint Framework solutions ¶ This repository provides developers with a set of reusable React controls that can be used in SharePoint Framework (SPFx) solutions. The project provides controls for building web parts and extensions. Attention In order to migrate to v2 it is advicded to follow this guide: Migrating from V1. Attention v2 version of the controls project has a minimal dependency on SharePoint Framework version 1.11.0. v1 has a minimal dependency on SharePoint Framework version 1.3.0. Be aware that the controls might not work in solutions your building for SharePoint 2016 with Feature Pack 2 on-premises. As for SharePoint 2016 with Feature Pack 2 version 1.1.0 of the SharePoint framework is the only version that can be used. SharePoint 2019 on-premises uses SharePoint framework v1.4.0 and therefore should be fine to use with these controls..4.0 the localized resource path will automatically be configured during the dependency installing. Once the package is installed, you will have to configure the resource file of the property controls to be used in your project. You can do this by opening the config/config.json and adding the following line to the localizedResources property: "ControlStrings": "node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js" Telemetry¶ All controls gather telemetry to verify the usage. Only the name of the control and related data gets captured. More information about the service that we are using for this can be found here: PnP Telemetry Proxy. Since version 1.17.0 it is possible to opt-out of the telemetry by adding the following code to your web part: import PnPTelemetry from "@pnp/telemetry-js"; ... const telemetry = PnPTelemetry.getInstance(); telemetry.optOut(); Available controls¶ The following controls are currently available: - Accordion (Control to render an accordion) - Carousel (Control displays children elements with 'previous/next element' options) - Charts (makes it easy to integrate Chart.js charts into web part) - ComboBoxListItemPicker (allows to select one or more items from a list) - DateTimePicker (DateTime Picker) - FilePicker (control that allows to browse and select a file from various places) - FileTypeIcon (Control that shows the icon of a specified file path or application) - FolderExplorer (Control that allows to browse the folders and sub-folders from a root folder) - FolderPicker (Control that allows to browse and select a folder) - GridLayout (control that renders a responsive grid layout for your web parts) - IconPicker (control that allows to search and select an icon from office-ui-fabric icons) -) - TreeView (Tree View) - WebPartTitle (Customizable web part title control) Field customizer controls: Note If you want to use these controls in your solution, first check out the start guide for these controls: using the field controls. -)
https://pnp.github.io/sp-dev-fx-controls-react/
CC-MAIN-2020-50
refinedweb
453
52.19
Hello,I have searched the archives for this error message before, but no oneseems to have given a good answer. (Though the question has beenposted before.) I am not sure if this is a kernel problem, a hardwareproblem or a Oracle problem. (Or a combination of them.)One one of our Linux Oracle servers the following messages has startedto appear : Jun 29 07:16:32 blanco kernel: swap_free: Trying to free nonexistent swap-pageJun 29 07:16:32 blanco kernel: swap_free: Trying to free nonexistent swap-pageThey seem to always come in pairs, and usually with about three hoursbetween them. The database had to be restored from backup because of massive tablecorruption recently, but these messages also appeared before we had torestore it. (But we believe they might have caused the corruption.)I also find some of these:Jun 29 06:25:01 blanco kernel: EXT2-fs error (device sd(8,10)): ext2_readdir: bad entry in directory #172258: rec_len %% 4 != 0 - offset=192, inode=812610409, rec_len=11833, name_len=115Jun 29 06:25:32 blanco kernel: EXT2-fs error (device sd(8,10)): ext2_readdir: bad entry in directory #172258: rec_len %% 4 != 0 - offset=192, inode=812610409, rec_len=11833, name_len=115Machine is a 2x933MhZ P3 with 2GB of memory. Kernel version is now2.2.19, but the same problem appeared with 2.2.18 as well. Thedatabase is in moderate to heavy use 24/7 and with a lot (~ 500 - 3000)processes during business hours.The machine has only 128MB of swap, is this to little since it has afull 2GB of memory?[unhandled content-type:application/octet-stream]The kernel is stock 2.2.19 with the following patch applied:--- include/linux/tasks.h~ Wed Jan 17 14:45:54 2001+++ include/linux/tasks.h Wed Jan 17 14:46:39 2001@@ -11,7 +11,7 @@ #define NR_CPUS 1 #endif -#define NR_TASKS 512 /* On x86 Max about 4000 */+#define NR_TASKS 4000 /* On x86 Max about 4000 */ #define MAX_TASKS_PER_USER (NR_TASKS/2) #define MIN_TASKS_LEFT_FOR_ROOT 4--RegardsJohan SelandProgrammerNet Fonds ASA
https://lkml.org/lkml/2001/6/29/38
CC-MAIN-2021-04
refinedweb
336
56.55
NOTE: This enhanced version is released under the same LGPL licence as the original module. Please do not contact the original author (Dan Pascu) regarding to this version. Send your bug reports to python@cx.hu. Thank you. Download How to install on Linux How to install on Windows Example (not as complicated as it seems) Throughput measurement, comparision with simplejson Fixed decoding of JSON string containing escaped slash cjson.decode('{"x": "\/"}') returned {'x': '\\/'} instead of {'x': '/'} Credits go to Tomas Cirip (D-Wave Systems Inc.) for pointing out this issue. Put these batch files right into the extracted source package, the setup.py file must be in the same directory. You need Microsoft Visual C++ 2008 Express and Windows 7 x64 SDK installed. Make sure you restart Windows after installing the above dependencies. It is essential before you can build the extension. BUGFIX: NEW FEATURES: You can always pass unicode objects to the JSON encoder. If you want to pass str objects containing non-ASCII data please add the encoding='name-of-your-encoding' argument to the cjson.encode() function. Failing to do so may raise EncodeError. The default encoding is latin-1 for compatibility with existing python-cjson releases, but this should be changed to ascii in the future. The default behaviour is returning str objects for ASCII strings and unicode object for all other strings. This is for compatibility again. existing python-cjson releases. The cjson.decode() call can return both str and unicode objects depending on the contents of the JSON strings by default. This behaviour can cause nasty bugs in your code when you expect str and got unicode or so. To avoid mixing str and unicode types it's recommended to add all_unicode=True to every cjson.decode() calls, then expect only unicode objects in the output. Alternatvely you can specify an encoding by adding the encoding='name-of-your-encoding' argument to both cjson.encode() and cjson.decode() calls. In this case you will get only str objects with the specified encoding and won't have to handle unicode objects. Decoding a JSON string with characters not found in the specified encoding will raise DecodeError, so do not use fixed encoding for data containing strings with multiple codepages. Tip: Using a fixed encoding helps a lot while prototyping your application and this can be changed to generic unicode later in the release version. Upgrade only if you need the new features above. This version includes new unit tests for the above feature. All existing and new unit tests are passed with python 2.3.5, 2.4.3 and 2.5.1 without problems. But silent bugs may exists..1 without problems. But silent bugs may exists. BUGFIX: When a decoder extension function was called after the failure of an internal decoder (for example after failing to interpret new Date(...) as null) the internal exception was propagated (not cleared) and could be incorrectly raised in the decoder extension function pointing to en otherwise correct statement in that function. This could cause severe confusion to the programmer and prevented execution of such extension functions. You can reproduce this bug with python-cjson-1.0.3x2: Bug #20070401a Make sure to install the following packages: binutils gcc libc6-dev linux-kernel-headers python-dev These are Debian package names. Install the equivalent packages on other distributions. You can compile and install python-cjson by issuing python setup.py installas root or with sudo. There should be no errors. The cjson.so library file will be copied into the site-packages directory. The library file may contain debug symbols depending on your default compiler options. You can strip the library to save a bit memory: strip cjson.soOn Debian it is created to the python's main site-packages directory and not under /usr/local. The library file may be moved to the corresponding site-packages directory under /usr/local. You can test the library by running testjson.py. The build directory can be safely deleted after installation. Please drop me a mail if you need binary releases for older Python releases (2.3 and 2.4) under Windows. Do not forget to write your exact python version. The minimum required Python version is 2.3. To compile C extension modules for Python 2.4 or 2.5 with free tools you can use Giovanni Bajo's GCC 4.1.2 MINGW installer (I haven't tried it) or an older method using the official MinGW installer (this worked for me): For Python 2.4 and 2.5 on Windows: 1. Install MinGW from 2. Add C:\MinGW\bin to the system PATH (use the System applet from the Control panel) 3. Build your extension with --compiler=mingw32 argument: python setup.py build --compiler=mingw32or put a distutils.cfg file under C:\python\lib\distutils dir (or where you installed python) containing the following entries: [build] compiler = mingw32After that you can install extension modules as usual (without the --compiler flag): python setup.py install import re import cjson import datetime # Encoding Date objects: def dateEncoder(d): assert isinstance(d, datetime.date) return 'new Date(Date.UTC(%d,%d,%d))'%(d.year, d.month, d.day) json=cjson.encode([1,datetime.date(2007,1,2),2], extension=dateEncoder) assert json=='[1, new Date(Date.UTC(2007,1,2)), 2]' # Decoding Date objects: re_date=re.compile('^new\sDate\(Date\.UTC\(.*?\)\)') def dateDecoder(json,idx): json=json[idx:] m=re_date.match(json) if not m: raise 'cannot parse JSON string as Date object: %s'%json[idx:] args=cjson.decode('[%s]'%json[18:m.end()-2]) dt=datetime.date(*args) return (dt,m.end()) # must return (object, character_count) tuple data=cjson.decode('[1, new Date(Date.UTC(2007,1,2)), 2]', extension=dateDecoder) assert data==[1,datetime.date(2007,1,2),2] Download example.pyNote the extension keyword arguments. simplejson 1.7.1 Test data: tuples in dicts in a list, 603887 bytes as JSON string Encoder throughput: ~747 kbyte/s Decoder throughput: ~272 kbyte/sTest script modifications required to measure simplejson instead of cjson: simplejson imported, then cjson.encode calls are replaced by simplejson.dumps, cjson.decode calls are replaced by simplejson.loads. NOTE: The simplejson page states, that 1.7.1 contains optional C code to speed up encoding. This is not used in the current test. A comparision including the speedup component will come soon. Stay tuned... python-cjson 1.0.3x5 - compiler: gcc 3.4.2 mingw-special (MinGW 3.81) Test data: tuples in dicts in a list, 603886 bytes as JSON string Encoder throughput: ~9199 kbyte/s Decoder throughput: ~9215 kbyte/s python-cjson 1.0.3x5 - compiler: C compiler from Microsoft Visual C++ Toolkit 2003 Test data: tuples in dicts in a list, 603886 bytes as JSON string Encoder throughput: ~9199 kbyte/s Decoder throughput: ~8776 kbyte/s It's interesting that the free gcc compiler builds a slightly faster decoder than the MS compiler. The striped pyd (DLL) files are 17k for the MS compiler and 22k for gcc, so the MS compiler uses less memory (and possibly less code cache). Decoder throughput may differ due to some loop unrolling optimization or so, but I did not verify it. Please remember, that python-cjson requires a C compiler but simplejson uses only the standard library. Simplejson could be a better choice if you want portability, but I recommend python-cjson for performance critical applications, such as servers and frequent data conversion tasks. NOTE: The results above may not reflect the real-world performance of these packages, but shows a clear difference. Python-cjson is more than 10x faster in encoding and more than 30x in decoding, at least when used against this data. Similar results found when using other realistic data sets. Using extension functions with python-cjson and passing much non-JSON-standard data can affect average performance but does not slow down processing of standard JSON data. I've done performance testing on a dual Xeon 2.8GHz server with Debian Linux, and got excellent results: Test data: tuples in dicts in a list, 603886 bytes as JSON string Encoder throughput: ~9545 kbyte/s Decoder throughput: ~16556 kbyte/s Back to my python goodies page.
http://python.cx.hu/python-cjson/
CC-MAIN-2013-20
refinedweb
1,375
50.94
Yet another passing test to make sure our MutexLock works as expected: 1: public class Given_a_locked_MutexLock : IDisposable 2: { 3: private MutexLock _lock = new MutexLock(); 4: private Thread _thread; 5: private bool _gotLock = false; 6: 7: public Given_a_locked_MutexLock() 8: { 9: _thread = new Thread(() => 10: { 11: _lock.Lock(); 12: _gotLock = true; 13: _lock.Unlock(); 14: }); 15: } 16: 17: public void Dispose() 18: { 19: if (_thread != null) 20: { 21: _thread.Abort(); 22: } 23: } 24: 25: private void TakeLockAndStartThread() 26: { 27: _lock.Lock(); 28: _thread.Start(); 29: } 30: 31: [Fact(Timeout = 1000)] 32: void It_should_not_take_the_lock() 33: { 34: TakeLockAndStartThread(); 35: Assert.False(_thread.Join(250)); 36: Assert.False(_gotLock); 37: } 38: 39: [Fact(Timeout = 1000)] 40: void It_should_take_lock_when_released() 41: { 42: TakeLockAndStartThread(); 43: Assert.False(_thread.Join(250)); 44: _lock.Unlock(); 45: Assert.True(_thread.Join(500)); 46: Assert.True(_gotLock); 47: } 48: } Note that I moved taking the lock from the constructor to a common helper method. This has to do with how xUnit.net runner creates objects and runs tests together with a timeout. Turns out that the object is created in one thread and then the test method is run in a separate thread if a timeout is used. In theory, if everything works as expected I don’t really need the timeout but it is very nice to have it just in case the code doesn’t work as expected.
https://blogs.msdn.microsoft.com/cellfish/2009/12/18/2009-advent-calendar-december-18th/
CC-MAIN-2016-36
refinedweb
228
67.96
Search: Search took 0.02 seconds. - 3 Feb 2009 7:44 AM Thank you for the quick reply Sven. - 3 Feb 2009 7:41 AM Does anyone know if this is getting looked at or is it working as intended? - 29 Jan 2009 7:23 AM Removing all attributes by rewriting a ton of server code "is" a work around, but an expensive one. I am hoping that I don't have to go that way. I don't feel placing more parsing and slowing down... - 28 Jan 2009 2:44 PM The property editor is probably what is preventing the date field from accepting an empty value. I got around my problem by adding a "clear date" icon button. - 28 Jan 2009 8:03 AM /** * @return a date field with no label */ public DateField createDateField() { final DateField field = new DateField(); field.setHideLabel(true); field.addStyleName("dateField");... - 28 Jan 2009 7:45 AM Does anyone know if it's possible to allow a blank entry in a date field? I have tried setting the setAllowBlank() to true, built a property editor, and a validator. Nothing seems to allow a blank... - 28 Jan 2009 6:46 AM type.addField("@id"); That is how you access an XML attribute. It works as it should while in hosted mode. The window dialog box displays the correct result for parsing the id attribute... - 27 Jan 2009 3:04 PM Works perfectly in hosted and fails as expected in a browser. package com.mycompany.project.client; import com.extjs.gxt.ui.client.data.BaseListLoader; import... - 27 Jan 2009 9:28 AM Here is a sample of the xml I am using. Note that some of the names have been changed to protect the innocent. Or at the very least my job. . . <?xml version="1.0"... - 27 Jan 2009 7:52 AM I've narrowed the bug down to parsing xml attributes. I'm not sure if this applies to parsing xml that is using a remote proxy as well as the memory proxy that I am using. Removing attributes from... - 26 Jan 2009 1:30 PM I got the following error in FireFox: Failed to load the store. com.google.gwt.core.client.JavaScriptException: (ReferenceError): attrValue is not defined This seems to be a little... - 26 Jan 2009 8:13 AM Where does the error/stack trace come from? The exception is thrown in client side code. It's a method that is called from a class that implements AsyncCallback. The particular method that loads... - 23 Jan 2009 7:07 AM Thanks for the quick reply. The code is on the client. The exception was sent to the server through an RPC so I could get an idea of where it was having problems. The variable _xmlReader is an... - 22 Jan 2009 4:56 PM I am currently using the following code to load a store from an xml string. This method works perfectly in the hosted browser but fails to work when the site is hosted on a Tomcat server and accessed... Results 1 to 14 of 14
https://www.sencha.com/forum/search.php?s=0ebd2a37fbd9caf67c5f1691725df1e6&searchid=17053217
CC-MAIN-2016-30
refinedweb
514
75.5
Simple Powerful Vue.js Data Table Component – vuetable Please Note! This is the previous version that works with Vue 1.x. The most up-to-date version is the Vuetable-2. If you like it, please star the Vuetable-2 repo instead, or make a small donation to support it. This version is "no longer supported" as I do not have time to maintain different version. vuetable - data table simplify! - No need to render the table yourself - One simple vuetabletag - framework classes to nicely format your table and displayed data - Events to allow control from Vue.js instance programmatically - Capture events from vuetableto manipulate your table and your data - Should work with any pre-defined JSON data structure - Should work with any CSS Framework, e.g. Semantic UI, Twitter's Bootstrap - Optional detail row to display additional data (v.1.2.0) vuetable is only working for Vue 1.x, vuetable-2 is for Vue 2.x. Note on vue-resource version vuetable internally uses vue-resource to request data from the api-url. Prior to v1.5.3, vuetable uses vue-resource v0.7.4 and it retrieves the returned data from response.data object. However, since v0.9.0 the response.data has been renamed to response.body. vuetable v1.5.3 onward has been updated to use vue-resource v1.0.2. This will cause problem with vuetable to display no data because the expected object key is no longer existed and some other related problems as discussed in #100. If you're using vue-resource in your project and the version is 0.9+, please upgrade to use vuetable v1.5.3. Breaking Changes v1.5.0 - deprecated props detail-row-callback: use row-detail-componentinstead v1.3.0 - deprecated props paginateConfig: use paginateConfigCallbackinstead detail-row: use detail-row-callbackinstead v1.2.0 sort-orderoption type was changed from Objectto Arrayto support multi-sort, therefore it should be declared as array. #36 <vuetable //... :</vuetable> ##Live Demo What is vuetable? vuetable is a Vue.js component that will automatically request (JSON) data from the server and display them nicely in html table with swappable/extensible pagination sub-component. You can also add buttons to each row and hook an event to it Please note that all the examples show in here are styling using Semantic UI CSS Framework, but vuetableshould be able to work with any CSS framwork including Twitter's Bootstrap. Please read through and see more info below. You do this: <div id="app" class="ui vertical stripe segment"> <div class="ui container"> <div id="content" class="ui basic segment"> <h3 class="ui header">List of Users</h3> <vuetable api-</vuetable> </div> </div> </div> <script> new Vue({ el: '#app', data: { columns: [ 'name', 'nickname', 'email', 'birthdate', 'gender', '__actions' ], itemActions: [ { name: 'view-item', label: '', icon: 'zoom icon', class: 'ui teal button' }, { name: 'edit-item', label: '', icon: 'edit icon', class: 'ui orange button'}, { name: 'delete-item', label: '', icon: 'delete icon', class: 'ui red button' } ] }, methods: { viewProfile: function(id) { console.log('view profile with id:', id) } }, events: { 'vuetable:action': function(action, data) { console.log('vuetable:action', action, data) if (action == 'view-item') { this.viewProfile(data.id) } }, 'vuetable:load-error': function(response) { console.log('Load Error: ', response) } } }) </script> And you get this! Since I'm mainly using Semantic UI as my default CSS Framework, all the css styles in vuetable are based on Semantic UI. If you're using Twitter's Bootstrap css framework, please see documentation in the Wiki pages. Usage Javascript //vue-table dependencies (vue and vue-resource) <script src=""></script> <script src=""></script> <script type="text/javascript" src=""></script> //or <script type="text/javascript" src=""></script> Bower $ bower install vuetable NPM $ npm install vuetable Vueify version for Browserify and Webpack Just import or require like so, // // firstly, require or import vue and vue-resource // var Vue = require('vue'); var VueResource = require('vue-resource'); Vue.use(VueResource); // // secondly, require or import Vuetable and optional VuetablePagination component // import Vuetable from 'vuetable/src/components/Vuetable.vue'; import VuetablePagination from 'vuetable/src/components/VuetablePagination.vue'; import VuetablePaginationDropdown from 'vuetable/src/components/VuetablePaginationDropdown.vue'; // // thirdly, register components to Vue // Vue.component('vuetable', Vuetable); Vue.component('vuetable-pagination', VuetablePagination) Vue.component('vuetable-pagination-dropdown', VuetablePaginationDropdown) You can combine the second and third steps into one if you like. You need to explicitly register the pagination components using Vue.component() (instead of just declaring them through the components: section); otherwise, the pagination component will not work or swappable or extensible. I guess this is because it is embedded inside vuetable component. Direct include Just import the vue-table.js after vue.js and vue-resource.js library in your page like so. <script src="js/vue.js"></script> <script src="js/vue-resource.js"></script> <script src="js/vue-table.js"></script> Then, reference the vuetable via <vuetable> tag as following <div id="app"> <vuetable api-</vuetable> </div> <script> new Vue({ el: '#app', data: { columns: [ 'firstname', 'lastname', 'nickname', 'birthdate', 'group.name_en', 'gender', 'last_login', '__actions' ] } }) </script> api-urlis the url of the api that vuetableshould request data from. The returned data must be in the form of JSON formatted with at least the number of fields defined in fieldsproperty. fieldsis the fields mapping that will be used to display data in the table. You can provide only the name of the fields to be used. But if you would like to get the true power of vuetable, you must provide some more information. Please see Field Definition section for more detail. For more detail, please see documentation in the Wiki pages. Browser Compatability As I use Chrome almost exclusively, it is gaurantee to work on this browser and it SHOULD also work for other WebKit based browsers as well. But I can't really gaurantee that since I don't use them regularly. However, vuetable will NOT WORK on Internet Explorer (even IE11) due to the use of <template> tag inside <table> according to this. In order to make it work with CSS framework table styling, I have to preserve the use of <table> and <template> tag inside it. It seems to work just fine in Microsoft Edge though. Anyway, if you find that it does not work on any other browser, you can let me know by posting in the Issues. Or if you are able to make it work on those browser, please let me know or create a pull request. Contributions Any contribution to the code (via pull request would be nice) or any part of the documentation (the Wiki always need some love and care) and any idea and/or suggestion are very welcome.. Building Run npm install Then make sure, you have installed browserify: # npm install browserify -g You might need root access for running the above command. Then you can simply run the build script included in the root folder: $ ./build.sh This will compile the vue components in the src directory to one file in the dist folder. You might want to get a minified version, in this case run this: $ ./build.sh production For developement it's useful when it's not needed to recompile manually each time you make a change. If you want this convenience first install watchify globally: # npm install watchify -g then run $ ./build.sh watch Now each time you make a change, the source will be recompiled automatically. License vuetable is open-sourced software licensed under the MIT license.
https://codespots.com/library/item/795
CC-MAIN-2020-40
refinedweb
1,237
57.77
? This behavior is expected given your configuration. You shouldn't have the router's IP set as the secondary DNS for PCs and member servers or they'll always sometimes go there which you don't want. They should only have domain controllers as their DNS so all of their DNS traffic routes through the domain controller. You can then either configure your domain controller to forward to an upstream DNS server for domains it can't resolve (usually this would be your ISP) or just leave it alone and it will use the root hints servers to resolve external queries. Typically you would want two DNS servers on the PCs and member servers and you would get that by having a second domain controller so DNS (and Active Directory) continue to function if the primary goes down. The first thing I would do is to remove the routers IP address from the DNS configuration on the clients (servers included). All AD/DNS clients should use your AD/DNS server for DNS only. I see no valid reason to use any other DNS server and can see that causing intermittent, flaky name resolution problems, such as what you're experiencing.. icky3000 hit the nail on the head. Your fallback proxy DNS servers are providing a different view of the DNS namespace to your principal proxy DNS server, and things are going wrong as a result.
http://serverfault.com/questions/258309/windows-server-2008-strange-dns-resolution-between-clients-and-server
crawl-003
refinedweb
235
65.35
Here's a simple C program with output and proper explanation to generate even and odd numbers up to a specified limit using For Loop. # include <stdio.h> # include <conio.h> void main() { int n, i ; clrscr() ; printf("Enter the limit : ") ; scanf("%d", &n) ; printf("\nThe odd numbers are :\n\n") ; for(i = 1 ; i <= n ; i = i + 2) printf("%d\t", i) ; printf("\n\nThe even numbers are :\n\n") ; for(i = 2 ; i <= n ; i = i + 2) printf("%d\t", i) ; getch() ; } Output of above program - Enter the limit : 10 The odd numbers are : 1 3 5 7 9 The even numbers are : 2 4 6 8 10 Explanation of above program - The program is very simple to understand. First it asks the user to enter a limit "n" up to which even and odd numbers are needed. Then using two for loops (one for calculating even numbers and other for odd numbers) the program calculates and prints the even and odd numbers up to limit "n". Let's take a look at the working of both loops with the help of an example. Suppose the value of limit n is 10. In this case, the program will calculate and print all even and odd numbers separately up to 10. Calculation of odd numbers - The first for loop does the calculation of odd numbers. Notice the syntax of this loop. The starting value of "i" is set to 1 (first odd number) and the loop terminating condition is "i <= n". But after each iteration the value of i is incremented by 2. So the output of this loop for n = 10 is - 1, 3 (1 + 2), 5 (3 + 2), 7 (5 + 2), 9 (7 + 2), Calculation of even numbers - The second for loop does the calculation of even numbers. Again notice the syntax of this loop. The starting value of "i" is set to 2 (first even number) and the loop terminating condition is "i <= n". But after each iteration again the value of i is incremented by 2. So the output of this loop for n = 10 is - 2, 4 (2 + 2), 6 (4 + 2), 8 (6 + 2), 10 (8 + 2), how to find the even numbers from 2 to 20 using if else statement in c? @Savita Kwati: Take a look at this post... Appreciation for nice Updates, I found something new and folks can get useful info about BEST ONLINE TRAINING Hey , I wanted to know how can i find even and odd numbers when i have upper and lower limit Very Nice Post visit nice example also Even odd example in java Visit nice example Even odd logic Hey, Grazie! Grazie! Grazie! Your blog is indeed quite interesting around It's all fundamental C Programming Tutorial.rest just follows it! agree with you on lot of points! Getting memory violation error when I use string function "strlwr", what wrong in step 3, please help, I am new to c language Very useful article, if I run into challenges along the way, I will share them here. Kind Regards, Yamini Nice article . There is good coding example collection visit Top coding program example
http://cprogramming.language-tutorial.com/2012/03/program-to-generate-odd-even-no.html
CC-MAIN-2021-10
refinedweb
528
67.69
Given below the sample code : 1 class Hotel { 2 public int bookings; 3 public void book() { 4 bookings++; 5 } 6 } 7 public class SuperHotel extends Hotel { 8 public void book() { 9 bookings--; 10 } 11 public void book(int size) { 12 book(); 13 super.book(); 14 bookings += size; 15 } 16 public static void main(String args[]) { 17 Hotel hotel = new Hotel(); 18 hotel.book(2); 19 System.out.print(hotel.bookings); 20 }} How can we correct the above code ? 1. By adding argument "int size" to the method book at line number 3. 2. By removing argument '2' at line number 18. 3. By creating object of "SuperHotel" subclass at line 17 & calling book(2) from it at line 18 4. No correction needed. (1) ,(2) &(3). Because the method book() of the type Hotel doesn't have the arguments.
http://www.roseindia.net/tutorial/java/scjp/part4/question20.html
CC-MAIN-2016-30
refinedweb
139
66.94
I’m interested in learning what are the good practices in parallelizing pytorch models over multiple GPUs; more specifically I have two questions. My first question concerns nn.DataParallel and a class that inherits from it, DataParallelPassthrough. More specifically, in this work, a pre-trained GAN generator, G, which has been set to evaluation mode, is used for generating images. This model, as an instance of a specific class is used as: G = DataParallelPassthrough(G) where DataParallelPassthrough is defined as follows: from torch import nn class DataParallelPassthrough(nn.DataParallel): def __getattr__(self, name): try: return super(DataParallelPassthrough, self).__getattr__(name) except AttributeError: return getattr(self.module, name) How is DataParallelPassthrough different than standard nn.DataParallel? Why should one prefer the former over the latter? I have seen it being used in some repos, but I couldn’t find any good explanation why. Could you help me understand? Now, except for the aforementioned generator model G, there is another model (an instance of a different class), which takes G's generated images as input. You may think of it as a ResNet-like model. However, this model is not set as an instance of DataParallelPassthrough. This causes some issues. For instance, while the whole model would fit in a 32GB Tesla V100, it doesn’t in a pair of 16GB V100’s. My second question is how should I parallelize both models. Should I instantiate both models using nn.DataParallel or DataParallelPassthrough? I would like to avoid the case where I load each model to a specific GPU device (e.g., using .to()). Thank you!
https://discuss.pytorch.org/t/parallelizing-models-of-different-classes-over-multiple-gpus/106117
CC-MAIN-2022-21
refinedweb
264
50.63