├── .GitHub ├── CODE_OF_CONDUCT.md └── LICENSE ├── .gitignore ├── API ├── GitHub │ └── user_info.sh ├── OpenVPN │ └── list_users.sh └── Vultr │ └── account_info.sh ├── Asm └── hello_world.s ├── Bash ├── README.md ├── bash_shortcuts.sh ├── battery_percent.sh ├── check_changed_files.sh ├── check_modified_dates.sh ├── clear_dns_cache.sh ├── copy.sh ├── create_swap.sh ├── executable.sh ├── export.sh ├── functions │ └── is_root.sh ├── get_public_ip.sh ├── git_config.sh ├── install_apache2.sh ├── ip_lookup.sh ├── kill-tty.sh ├── kill_window.sh ├── low_battery.sh ├── low_memory_alert.sh ├── memory_alert.sh ├── mx_lookup.sh ├── portscan.sh ├── recent_files.sh ├── sendmail.sh ├── swap_memory_usage.sh ├── time_teller.sh ├── ttyecho │ ├── setup.sh │ └── ttyecho.c └── untrackable_shell.sh ├── C# ├── primeOrFactor.cs └── speak.cs ├── C++ ├── README.md ├── guess_num.cpp ├── isPrime.cpp ├── loading_sign.cpp ├── note_taker.cpp └── prime_finder.cpp ├── C ├── README.md ├── convert_ANSI.c ├── countdown.c ├── create_square.c ├── custom │ ├── get_args.c │ └── sizes.c ├── delete_file.c ├── etc │ └── is_prime.c ├── factor_finder.c ├── fortune.c ├── includes │ ├── default.h │ └── is_prime.h ├── isPrimeCounter.c ├── is_even_odd.c ├── is_prime.c ├── reverse_array.c ├── shell.c ├── simple_matrix.c ├── sort_int.c ├── threedig.c ├── tic-tac-toe.c └── triangle.c ├── Elisp └── isPrime.lisp ├── GUI └── arch_gui_upgrade.py ├── Go ├── README.md ├── even_odd_finder.go ├── file_exists.go ├── hash_input.go ├── isPrime.go └── read_file.go ├── JavaScript ├── price_calc.html └── prime_finder.html ├── LICENSE ├── Lisp ├── fibonacci.lisp └── isPrime.lisp ├── Lua ├── fibonacci.lua ├── print_rectangle.lua └── selection_sort.lua ├── PHP ├── isPrimeCounter.php ├── prime_test.php └── url_encode.php ├── Python ├── Opposite_binary_input.py ├── binary_to_decimal.py ├── crack_md5.py ├── fibonacci.py ├── fortune_teller.py ├── functions │ ├── get_args.py │ └── save_user_details.py ├── hex_to_decimal.py ├── isPrime.py ├── neural_flower.py ├── octal_to_dec.py ├── password_manager.py ├── password_manager_info.txt ├── prime_gen.py ├── quick_hash3.py └── tic-tac-toe.py ├── README.md ├── Ruby ├── Input.rb └── prime.rb └── Swift ├── bubbleSort.swift ├── checkPrime.swift ├── fibonacci.swift ├── genPrime.swift └── sieve-prime.swift /.GitHub/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at team@nerdofcode.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /.GitHub/LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.out* 2 | .* 3 | -------------------------------------------------------------------------------- /API/GitHub/user_info.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Cache directory 4 | dir=".github_cache" 5 | 6 | if [ ! -d ~/$dir ] 7 | then 8 | mkdir ~/$dir 9 | echo "Cache Enabled" 10 | echo "To use the cache, place at least one arguement..." 11 | echo "Ex: ./github_api.sh cache" 12 | fi 13 | 14 | read -p "Enter Github Username: " user 15 | 16 | if [ ! -f ~/$dir/$user.txt ] 17 | then 18 | echo "User not cached" 19 | shift 20 | fi 21 | 22 | #Cache check 23 | if [ $# != 1 ] 24 | then 25 | curl --silent https://api.github.com/users/$user > ~/$dir/$user.txt 26 | else 27 | echo "Using cache" 28 | fi 29 | 30 | 31 | #Shortcut 32 | file=$(cat ~/$dir/$user.txt) 33 | 34 | id=$(echo $file | jq '.id') 35 | type=$(echo $file | jq '.type') 36 | email=$(echo $file | jq '.email') 37 | followers=$(echo $file | jq '.followers') 38 | following=$(echo $file | jq '.following') 39 | bio=$(echo $file | jq '.bio') 40 | public_repos=$(echo $file | jq '.public_repos') 41 | account_created=$(echo $file | jq '.created_at') 42 | account_created=$(echo $account_created | awk -F "T" '{print $1}' | tr -d \") 43 | 44 | 45 | echo "Id: $id" 46 | echo "Type: $type" 47 | 48 | if [ $email != "null" ] 49 | then 50 | echo "Email: $email" 51 | fi 52 | 53 | echo "Followers: $followers" 54 | echo "Following: $following" 55 | echo "Public Repos: $public_repos" 56 | echo "Bio: $bio" 57 | echo "Account created on: $account_created" 58 | -------------------------------------------------------------------------------- /API/OpenVPN/list_users.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # List connected OpenVPN Users and display basic details about their account 4 | # Author: NerdOfCode 5 | # Contact: nerdofcode@nerdofcode.com 6 | 7 | :' 8 | Licensed to the Apache Software Foundation (ASF) under one 9 | or more contributor license agreements. See the NOTICE file 10 | distributed with this work for additional information 11 | regarding copyright ownership. The ASF licenses this file 12 | to you under the Apache License, Version 2.0 (the 13 | "License"); you may not use this file except in compliance 14 | with the License. You may obtain a copy of the License at 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | Unless required by applicable law or agreed to in writing, 17 | software distributed under the License is distributed on an 18 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19 | KIND, either express or implied. See the License for the 20 | specific language governing permissions and limitations 21 | under the License. 22 | ': 23 | 24 | clear 25 | 26 | # Verify all needed software is installed 27 | tools_installed() { 28 | if [[ ! -d "/etc/openvpn/" ]] 29 | then 30 | echo "OpenVPN is NOT installed!" 31 | exit 1 32 | fi 33 | if [[ ! $(command -v "inotifywait") ]] 34 | then 35 | echo "Please install inotify-tools and re-run!" 36 | exit 1 37 | fi 38 | } 39 | 40 | display_user() { 41 | # DO a little math and convert bytes-related info to megabyte units 42 | ((bytes_received = $4 / (1024 * 1024))) 43 | ((bytes_sent = $5 / (1024 * 1024))) 44 | echo -e """ 45 | User: $1 46 | \tInternal IP: $2 47 | \tOriginal IP: $3 48 | \tBytes Received: $bytes_received MB 49 | \tBytes Sent: $bytes_sent MB 50 | """ 51 | } 52 | 53 | if [[ $EUID -ne 0 ]] 54 | then 55 | echo "Sorry, but this script must be run as root!" 56 | exit 1 57 | fi 58 | 59 | tools_installed 60 | 61 | connection_details=$(cat /etc/openvpn/server/openvpn-status.log | grep "^CLIENT_LIST,") 62 | IFS=$'\n' 63 | 64 | echo "CONNECTED USERS:" 65 | for user in $connection_details 66 | do 67 | username=$(echo $user | awk -F ',' '{print $2}') 68 | original_ip=$(echo $user | awk -F ',' '{print $3}' | sed 's/:.*//g') 69 | internal_ip=$(echo $user | awk -F ',' '{print $4}') 70 | bytes_received=$(echo $user | awk -F ',' '{print $6}') 71 | bytes_sent=$(echo $user | awk -F ',' '{print $7}') 72 | 73 | display_user "$username" "$internal_ip" "$original_ip" "$bytes_received" "$bytes_sent" 74 | done 75 | 76 | while inotifywait -e modify /etc/openvpn/server/openvpn-status.log; do bash $0; done 77 | -------------------------------------------------------------------------------- /API/Vultr/account_info.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Please make sure you have API enabled under account in Vultr settings 4 | 5 | #Change variables below 6 | account_storage=".storage" 7 | api_storage=".vultr_api_key" 8 | 9 | #Exit codes: 10 | #0 --> Success 11 | #1 --> Missing software 12 | 13 | 14 | #Check if the required commands are installed 15 | if [ ! $(which jq) ] 16 | then 17 | echo "Please install jq via apt" 18 | exit 1 19 | fi 20 | 21 | if [ ! $(which curl) ] 22 | then 23 | echo "Please install Curl via apt" 24 | exit 1 25 | fi 26 | 27 | if [ ! -f $api_storage ] 28 | then 29 | read -p "Please enter Vultr API key: " api_key 30 | echo $api_key > $api_storage 31 | else 32 | api_key=$(cat $api_storage) 33 | fi 34 | 35 | 36 | 37 | #Get the JSON output and store it to $account_storage 38 | curl --silent -H "API-Key: $api_key" https://api.vultr.com/v1/account/info > $account_storage 39 | 40 | 41 | #Start organizing the information 42 | info=$(cat $account_storage) 43 | 44 | balance=$(echo $info | jq '.balance') 45 | 46 | pending_charges=$(echo $info | jq '.pending_charges') 47 | 48 | last_pay_date=$(echo $info | jq '.last_payment_date') 49 | 50 | last_pay_ammount=$(echo $info | jq '.last_payment_amount') 51 | 52 | 53 | #Actually release the info below 54 | echo "Balance: $balance" | tr -d \" 55 | 56 | echo "Pending Charges: $pending_charges" | tr -d \" 57 | 58 | echo "Last Payment Date: $last_pay_date" | tr -d \" 59 | 60 | echo "Last Payment Ammount: $last_pay_ammount" | tr -d \" 61 | 62 | -------------------------------------------------------------------------------- /Asm/hello_world.s: -------------------------------------------------------------------------------- 1 | # x86 -- Compile with GNU Assembler 2 | 3 | .text 4 | 5 | .global _start 6 | 7 | _start: 8 | mov $1, %rbx # Invoke sys_write 9 | mov $1, %rax # 10 | mov $string, %rsi # Actual string second argument 11 | mov $14, %rdx # Pass the number of bytes as third argument 12 | syscall 13 | 14 | mov $60, %rax # Invoke sys_exit 15 | xor %rdi, %rdi # Set return to 0 16 | syscall 17 | 18 | .data 19 | string: 20 | .ascii "Hello, World!\n" 21 | -------------------------------------------------------------------------------- /Bash/README.md: -------------------------------------------------------------------------------- 1 | ### Setup 2 | 3 | To setup this bash directly quickly, all you have to do is simply run `bash executable.sh`... This will make all the shell scripts executable... 4 | -------------------------------------------------------------------------------- /Bash/bash_shortcuts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #Author: NerdOfCode 3 | #Purpose: Adds a few alias's that improve the efficieny of your terminal 4 | 5 | #Tested: Linux Mint 18.1 Serena | Kernel Version 4.4.0-79-generic 6 | #Tested: Antergos | Kernel Version: 4.15.1 7 | 8 | #Storage for alias's 9 | storage='.1bashrc' 10 | shrt_alias=("content" "kernel") 11 | 12 | 13 | function available_commands(){ 14 | for i in "${shrt_alias[@]}" 15 | do 16 | echo $i 17 | done 18 | 19 | } 20 | 21 | function custom(){ 22 | printf "Enter custom alias: " 23 | read alias 24 | 25 | echo -e "Adding:\n" 26 | echo -e "$alias\n" | tee -a ~/$storage 27 | sleep 2 28 | echo "NOTE: you may need to manually run source ~/$storage..." 29 | source ~/$storage 30 | exit 0 31 | 32 | } 33 | 34 | function add_shortcuts(){ 35 | if [ -f ~/$storage ] 36 | then 37 | echo "Shortcuts already exist..." 38 | echo "Please delete $storage and try again" 39 | exit 1 40 | fi 41 | 42 | 43 | echo -e "Adding\n" 44 | echo -e '#!/bin/bash' | tee -a ~/$storage 45 | echo -e '#Author: NerdOfCode' | tee -a ~/$storage 46 | echo -e '#Auto Generated by bashrc_alias.sh' | tee -a ~/$storage 47 | echo 'alias content="grep -R $1"' | tee -a ~/$storage 48 | echo 'alias kernel="uname -r"' | tee -a ~/$storage 49 | source ~/$storage 50 | sleep 2 51 | echo -e "\nNOTE: You may need to manually run 'source $storage'" 52 | 53 | exit 0;} 54 | 55 | function remove_shortcuts(){ 56 | 57 | if [ -f ~/$storage ] 58 | then 59 | echo -e "Removing\n" 60 | rm ~/$storage 61 | exit 0 62 | fi 63 | echo "The shortcuts aren't installed" 64 | exit 1;} 65 | 66 | function options(){ 67 | case $response in 68 | "1") 69 | add_shortcuts;; 70 | "2") 71 | remove_shortcuts;; 72 | "5") 73 | echo "Good bye";exit;; 74 | "3") 75 | available_commands;; 76 | "4") 77 | custom;; 78 | *) 79 | echo "Unknown option selected";; 80 | esac 81 | } 82 | 83 | 84 | clear 85 | while : 86 | do 87 | echo -e "1)Add the shortcuts \n2)Remove the shortcuts\n3)Show available alias's\n4)Add Custom Alias\n5)Exit" 88 | read -p "Response: " response 89 | options 90 | sleep 3 91 | clear 92 | 93 | done 94 | -------------------------------------------------------------------------------- /Bash/battery_percent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Change variables below to your likings!!! 4 | 5 | #sleep time in seconds 6 | s_time=0 7 | 8 | #Make variable equal to nothing, if you dont want to clear terminal before displaying percent 9 | clear="clear" 10 | 11 | if [ ! $(which acpi) ] 12 | then 13 | echo "Please install acpi..." 14 | exit 1 15 | fi 16 | 17 | percent=$(acpi -b | grep -P -o '[0-9]+(?=%)') 18 | 19 | $clear 20 | 21 | echo "Your battery is currently at: $percent percent" 22 | 23 | sleep $s_time 24 | -------------------------------------------------------------------------------- /Bash/check_changed_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ################################## 4 | #Author: NerdOfCode 5 | #Purpose: Tells user when a file is changed from checksums... 6 | #Updated: 2/28/18 7 | ################################## 8 | 9 | storage_file=".file_listings" 10 | 11 | 12 | check_required_tools(){ 13 | 14 | if [ ! $(which sum) ] 15 | then 16 | echo "Please install the 'sum' command and then re-run..." 17 | exit 1 18 | fi 19 | 20 | return 0 21 | } 22 | 23 | file_listings(){ 24 | count=0 25 | touch ~/$storage_file 26 | #Start json formatting 27 | echo -e "{\n" >> ~/$storage_file 28 | 29 | for file in "$(pwd)"/*.* 30 | do 31 | if [ $(file $file | grep "directory") ] 32 | then 33 | break 34 | fi 35 | sum="$(sum $file | awk -F ' ' '{print $1}')" 36 | echo -e "'file${count}': $file,\n" >> ~/$storage_file 37 | echo -e "'sum${count}': $sum," >> ~/$storage_file 38 | count=$((count=count+1)) 39 | done 40 | 41 | echo -e "\n}" >> ~/$storage_file 42 | } 43 | 44 | check_files(){ 45 | for file in "$(pwd)"/*.* 46 | do 47 | 48 | sum="$(sum $file | awk -F ' ' '{print $1}')" 49 | 50 | if ! grep -q "$sum" ~/"$storage_file" 51 | then 52 | echo "Modified File: $file" 53 | fi 54 | 55 | done 56 | } 57 | 58 | #Check to see if user has required tools 59 | check_required_tools 60 | #Check to see if file listings already exists and if not create 61 | if [ ! -f ~/$storage_file ] 62 | then 63 | echo "Creating file listing file at: ~/$storage_file" 64 | file_listings 65 | fi 66 | 67 | read -p "Would you like to (c)heck for a file change or (u)pdate file records: " choice 68 | 69 | if [ $choice == "u" ] 70 | then 71 | rm ~/$storage_file 72 | file_listings 73 | else 74 | check_files 75 | fi 76 | -------------------------------------------------------------------------------- /Bash/check_modified_dates.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Author: NerdOfCode 4 | 5 | #Purpose: You can use this shell script to check the last modified 6 | #file dates in a month!!! 7 | 8 | #For easier use I recommend using chmod +x check_modified_dates.sh 9 | 10 | date=0 11 | 12 | read -p "Enter first three characters of month(ex: Dec): " month 13 | 14 | while [[ "$date" -lt "31" ]] 15 | do 16 | ((date+=1)) 17 | 18 | 19 | ls -al | grep "$month $date" 20 | 21 | done 22 | -------------------------------------------------------------------------------- /Bash/clear_dns_cache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $(whoami) != "root" ] 4 | then 5 | echo "Please run as root..." 6 | exit 1 7 | fi 8 | 9 | if [ $(which nscd) ] 10 | then 11 | sudo systemctl restart nscd 12 | else 13 | echo "I don't think you have DNS caching" 14 | fi 15 | -------------------------------------------------------------------------------- /Bash/copy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #Author: NerdOfCode 3 | #Purpose: Copy files or directories 4 | 5 | 6 | 7 | if [ $(whoami) != "root" ] 8 | then 9 | echo "This script may not work as expected without sudo powers" 10 | sleep 3 11 | fi 12 | 13 | read -p "Enter path to copy the files/folders: " path1 14 | read -p "Enter path for the files/folders to be saved: " path 15 | 16 | if [ -d $path ] 17 | then 18 | echo -e "Copying files/folders: \n" 19 | cp -r -v $path1/* $path 20 | exit 0 21 | 22 | else 23 | mkdir $path 24 | echo -e "Copying files/folders: \n" 25 | cp -r -v $path1/* $path 26 | exit 0 27 | fi 28 | -------------------------------------------------------------------------------- /Bash/create_swap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Purpose: Creates and enables a swap file interactively 4 | #Tested on: Arch Linux 5 | 6 | swap_dir="/mnt" 7 | swap_name="swapfile" 8 | 9 | if [ "$EUID" -ne 0 ] 10 | then 11 | echo "not root" 12 | exit 1 13 | fi 14 | 15 | fallocate_status=$(which fallocate >/dev/null 2>&1) 16 | 17 | if [ "$?" -ne 0 ] 18 | then 19 | echo "Please install fallocate" 20 | exit 1 21 | fi 22 | 23 | 24 | read -p "Enter size of swap file(Ex: 2GB): " swap_size 25 | read -p "Can I create a swapfile located in /mnt, (y)es/(n)o: " choice 26 | 27 | 28 | if [ "$choice" != "y" ] 29 | then 30 | read -p "Enter directory to store swap(Ex: /mnt): " swap_dir 31 | fi 32 | 33 | fallocate --length $swap_size $swap_dir/$swap_name 34 | 35 | chmod 600 $swap_dir/$swap_name 36 | 37 | mkswap $swap_dir/$swap_name 38 | 39 | read -p "Ready to enable swap (y/n): " choice 40 | 41 | if [ "$choice" == "y" ] 42 | then 43 | swapon $swap_dir/$swap_name 44 | else 45 | exit 0 46 | fi 47 | 48 | read -p "Would you like to enable this swap at boot(y/n): " choice 49 | 50 | if [ "$choice" == "y" ] 51 | then 52 | echo "$swap_dir/$swap_name swap swap defaults 0 0" >> /etc/fstab 53 | exit 0 54 | else 55 | exit 0 56 | fi 57 | -------------------------------------------------------------------------------- /Bash/executable.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Making all shell scripts executable" 4 | 5 | chmod +x *.sh 6 | chmod +x functions/*.sh 7 | -------------------------------------------------------------------------------- /Bash/export.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #Author: NerdOfCode 3 | 4 | read -p "Would you like to completely (c)hange your path or (a)ppend: " opt 5 | sleep 2 6 | clear 7 | read -p "Enter path: " opt1 8 | 9 | if [ $opt == 'c' ] 10 | then 11 | export PATH="$opt1" 12 | exit 0 13 | else 14 | 15 | export PATH="$PATH:$opt1" 16 | exit 0 17 | fi 18 | 19 | exit 1 20 | -------------------------------------------------------------------------------- /Bash/functions/is_root.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #Purpose: Tell if the user is running script via root or not 3 | #If script exits with exit status of 2 then no root 4 | #If zero then root 5 | 6 | 7 | if [ "$EUID" -ne 0 ] 8 | then 9 | exit 2 10 | fi 11 | 12 | exit 0 13 | 14 | -------------------------------------------------------------------------------- /Bash/get_public_ip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | which dig >/dev/null 2>&1 4 | 5 | if [ $? != 0 ] 6 | then 7 | echo "Please install dig command..." 8 | exit 1 9 | fi 10 | 11 | ip=$(dig +short myip.opendns.com @resolver1.opendns.com) 12 | 13 | echo "Your public IP is: $ip" 14 | -------------------------------------------------------------------------------- /Bash/git_config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #Author: NerdOfCode 3 | 4 | editor="nano" 5 | 6 | clear 7 | read -p "Enter Git Name: " git_name 8 | read -p "Enter Git User Email: " git_mail 9 | read -p "Enter editor(nano default): " git_edit 10 | 11 | if [ -z $git_edit ] 12 | then 13 | git_edit='nano' 14 | fi 15 | 16 | 17 | git config --global user.name "$git_name" 18 | git config --global user.email $git_mail 19 | git config --global core.editor $git_edit 20 | 21 | sleep 1 22 | 23 | echo -e "Your git config: \n \n" 24 | git config --list --show-origin 25 | -------------------------------------------------------------------------------- /Bash/install_apache2.sh: -------------------------------------------------------------------------------- 1 | 2 | #!/bin/bash 3 | #Supports: Arch Linux and Debian Based Distro 4 | #Notes: 5 | #System variable --> Basically used to install apache2 6 | 7 | if [ $(whoami) != "root" ] 8 | then 9 | echo "Please run with sudo..." 10 | exit 1 11 | fi 12 | 13 | #Update the system via apt 14 | apt_check=$(which apt >/dev/null 2>&1) 15 | 16 | if [ $? == 0 ] 17 | then 18 | sudo apt update 19 | sudo apt upgrade 20 | system="sudo apt install apache2" 21 | else 22 | status=-1 23 | fi 24 | 25 | #Update the system via Pacman 26 | pacman_check=$(which pacman) 27 | 28 | if [ $? == 0 ] 29 | then 30 | sudo pacman -Syy 31 | sudo pacman -Su 32 | system="sudo pacman -S apache" 33 | #If os is arch, then dont use ufw due to complications 34 | os="arch" 35 | else 36 | status=-2 37 | fi 38 | 39 | if [ $status == -2 ] 40 | then 41 | echo "Unsupported system... Feel free to improve this script and then submit it to https://github.com/NerdOfCode/Scripts/blob/master/bash/install_apache2.sh" 42 | exit 1 43 | fi 44 | 45 | 46 | 47 | apache2_check=$(which apache2 >/dev/null 2>&1) 48 | if [ $? == 0 ] 49 | then 50 | echo "Apache is already installed" 51 | else 52 | $system 53 | ran=1 54 | fi 55 | 56 | apache_check=$(which apache >/dev/null 2>&1) 57 | if [ $? == 0 ] 58 | then 59 | echo "Apache already installed" 60 | else if [ $ran != 1 ] 61 | then 62 | $system 63 | fi 64 | fi 65 | clear 66 | 67 | ufw_check=$(which ufw >/dev/null 2>&1) 68 | 69 | if [ $? == 0 ] && [ $os != "arch" ] 70 | then 71 | #Allow commonly used ports with apache 72 | sudo ufw allow 80 73 | sudo ufw allow 443 74 | 75 | sudo ufw status 76 | sleep 4 77 | sudo service ufw start 78 | else 79 | 80 | echo "Note: Use ufw for easier firewall configuration than iptables" 81 | fi 82 | 83 | 84 | sleep 2 85 | clear 86 | 87 | #Hostame -I only works on Debian based... 88 | if [ $os != "arch" ] 89 | then 90 | echo "Congratulations!!!" 91 | echo "You can visit your new site at $(hostname -I)" 92 | exit 0 93 | fi 94 | exit 0 95 | -------------------------------------------------------------------------------- /Bash/ip_lookup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Change variables below to your likings.... 4 | 5 | #For curl, hides download progress bar 6 | silent="--silent" 7 | 8 | if [ ! $(which curl) ] 9 | then 10 | echo "Please install Curl..." 11 | exit 1 12 | fi 13 | 14 | if [ -z $1 ] 15 | then 16 | read -p "Enter ip: " ip 17 | else 18 | ip=$1 19 | fi 20 | 21 | org=$(curl $silent https://ipapi.co/$ip/org/) 22 | city=$(curl $silent https://ipapi.co/$ip/city) 23 | country=$(curl $silent https://ipapi.co/$ip/country) 24 | 25 | echo "ISP: $org" 26 | echo "City: $city" 27 | echo "Country: $country" 28 | exit 0 29 | -------------------------------------------------------------------------------- /Bash/kill-tty.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Tested on: 4 | #Antergos 5 | 6 | #Check if user has ran this script before 7 | check_file=".killtty" 8 | 9 | #For skipping the check for root 10 | bypass=0 11 | 12 | if [[ ! -f $check_file ]] && [[ $ran != "1" ]] 13 | then 14 | chmod +x $0 15 | touch $check_file 16 | ran=1 17 | fi 18 | 19 | 20 | if [[ $1 == "bypass" ]] 21 | then 22 | bypass=1 23 | shift 24 | fi 25 | 26 | if [[ $1 == "help" ]] || [[ $ran == "1" ]] 27 | then 28 | echo "Please make this script an executable by running: " 29 | echo "chmod +x kill-tty.sh" 30 | echo "Then execute by running ./kill-tty.sh" 31 | echo "" 32 | echo "If you cannot use root, use ./kill-tty.sh bypass" 33 | shift 34 | exit 0 35 | fi 36 | 37 | if [ $(whoami) != "root" ] && [ $bypass == "0" ] 38 | then 39 | echo "Please run as root..." 40 | echo "Or consider using ./kill-tty.sh bypass" 41 | exit 1 42 | fi 43 | 44 | w_test=$(which w) 45 | if [ $? != "0" ] 46 | then 47 | echo "Please install the w command" 48 | exit 1 49 | fi 50 | 51 | 52 | w 53 | 54 | read -p "Enter either a pts or a TTY session to kill (ex: pts/4): " session 55 | 56 | sudo pkill -9 -t $session 57 | -------------------------------------------------------------------------------- /Bash/kill_window.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $(whoami) != "root" ] 4 | then 5 | echo "Please run me as root or with sudo." 6 | exit 1 7 | fi 8 | 9 | if [ $# -gt 0 ] 10 | then 11 | echo "I accept no arguements..." 12 | echo "Simply run, chmod +x kill_window.sh" 13 | echo "Then, sudo ./kill_window.sh" 14 | exit 0 15 | fi 16 | 17 | xdotool_test=$(which xdotool) 18 | if [ $? != 0 ] 19 | then 20 | echo "Please install xdotool" 21 | exit 1 22 | fi 23 | 24 | echo "Select window to kill" 25 | 26 | pid=$(xdotool selectwindow getwindowpid) 27 | 28 | echo "Killing PID: $pid" 29 | 30 | sudo kill -9 $pid 31 | -------------------------------------------------------------------------------- /Bash/low_battery.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #Get battery percent 3 | bat_percent=$(acpi | awk -F ", " '{print $2}' | tr -d %) 4 | 5 | 6 | #When to start showing warnings 7 | low=80 8 | alert="Low battery, $bat_percent% left..." 9 | 10 | notfiy_send_test=$(which notify-send) 11 | if [ $? != 0 ] 12 | then 13 | echo "Please install notify-send..." 14 | exit 1 15 | fi 16 | 17 | acpi_test=$(which acpi) 18 | if [ $? != 0 ] 19 | then 20 | echo "Please install acpi..." 21 | exit 1 22 | fi 23 | 24 | 25 | #Test if cord is plugged in 26 | plugged=$(acpi -a | awk -F ": " '{print $2}') 27 | 28 | if [ $plugged == 'on-line' ] 29 | then 30 | echo "Your computer is connected to a power source..." 31 | echo "Exiting..." 32 | exit 0 33 | fi 34 | 35 | while : 36 | do 37 | 38 | if [ $bat_percent -lt $low ] 39 | then 40 | notify-send "$alert" 41 | sleep 15 42 | else 43 | #Check every fifteen seconds to use less resources... 44 | sleep 15 45 | fi 46 | 47 | done 48 | -------------------------------------------------------------------------------- /Bash/low_memory_alert.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ####################################### 4 | ##Author: NerdOfCode 5 | ##Purpose: Notifies user of low memory 6 | ##Tested: Antergos 2/25/18 7 | ##Updated: 2/25/18 8 | ##NOTE: This script currently uses 100% single CPU core... I am working on a fix 9 | ####################################### 10 | 11 | ##Change variables below instead of using default 12 | config=".low_mem_config" 13 | config_file="config" 14 | 15 | #Change debug='1' for debugging purposes 16 | debug="0" 17 | 18 | ##DO NOT MESS WITH THESE VARIABLES... Unless you are contributing or having fun :) 19 | current_dir="$(pwd)" 20 | count=0 21 | 22 | ##Functions 23 | create_config_file(){ 24 | touch $config_file 25 | customize_config 26 | } 27 | 28 | 29 | customize_config(){ 30 | #Take interval in seconds 31 | read -p "How often would you like to check memory status(Default: 20 seconds): " interval 32 | read -p "What is the threshold for notifiying of low memory(Default: 500MB left): " threshold 33 | read -p "What is the max amount of alerts you would like to receive:(Default: 0 -> unlimited): " alert_max 34 | 35 | #Check if variables fullfilled 36 | if [ -z $interval ] 37 | then 38 | interval="20" 39 | fi 40 | 41 | if [ -z $threshold ] 42 | then 43 | threshold="500MB" 44 | fi 45 | 46 | if [ -z $alert_max ] 47 | then 48 | alert_max="0" 49 | fi 50 | 51 | #Check if threshold variable is right 52 | if [ ! $(echo "$threshold" | grep "MB") ] 53 | then 54 | threshold="${threshold}MB" 55 | fi 56 | 57 | printf "#Config created by NerdOfCode's low_memory_alert.sh script!\n\n" >> $config_file 58 | #Start saving new config variables 59 | printf "#Interval to check memory status in seconds\ninterval=\"$interval\"\n" >> $config_file 60 | printf "#Threshold when to notify user\nthreshold=\"$threshold\"\n" >> $config_file 61 | printf "#Max Amount of alerts to notify user\nmax_alerts=\"$alert_max\"" >> $config_file 62 | } 63 | 64 | #Actually start doing heavy lifting!!! 65 | start_running(){ 66 | if [ ! -f $config/running ] 67 | then 68 | cd $current_dir 69 | touch $config/running 70 | fi 71 | 72 | #Gather variables values 73 | source $config/$config_file 74 | 75 | #Start performing checks 76 | free_memory="$(free -h | grep "Mem: " | awk -F " " '{print $4}')" 77 | 78 | #Prepare variables for mathematical calculations 79 | threshold="$(echo $threshold | tr -d \"MB\")" 80 | 81 | if [ $(echo $free_memory | grep "G") ] 82 | then 83 | free_memory="$(echo $free_memory | tr -d "G")" 84 | free_memory="$(echo "$free_memory * 1000" | bc)" 85 | fi 86 | 87 | 88 | 89 | check_memory_status 90 | } 91 | 92 | check_memory_status(){ 93 | 94 | #Make sure variables are not floats... 95 | free_memory="$(echo $free_memory | cut -f1 -d ".")" 96 | threshold="$(echo $threshold | cut -f1 -d ".")" 97 | 98 | while [ $count -lt $max_alerts ] 99 | do 100 | if (( "${free_memory}" < "${threshold}" )) 101 | then 102 | count+=1 103 | notify-send "Available Memory: $actual_threshold" 104 | sleep $interval 105 | start_running 106 | fi 107 | done & 108 | killall $0 109 | 110 | } 111 | 112 | ##Check for needed commands 113 | if [ ! $(which notify-send) ] 114 | then 115 | echo "Please install notify-send..." 116 | exit 1 117 | fi 118 | 119 | ##Test for config file 120 | if [ ! -d $config ] 121 | then 122 | echo "Creating configuration directory..." 123 | mkdir $config 124 | cd $config 125 | if [ ! -f $config_file ] 126 | then 127 | echo "Creating config file" 128 | create_config_file 129 | fi 130 | else 131 | echo "Using already configured settings at: $config" 132 | cd $config 133 | if [ ! -f $config_file ] 134 | then 135 | read -p "Config not found, create one(y/n): " choice 136 | if [ "$choice" == "y" ] 137 | then 138 | echo "Creating config" 139 | create_config_file 140 | fi 141 | fi 142 | fi 143 | 144 | ##The script is now ready to be used 145 | read -p "Would you like to start this script(y\n): " choice 146 | 147 | if [ "$choice" == "y" ] 148 | then 149 | start_running 150 | else 151 | echo "Well it is ready for next use!!!" 152 | exit 0 153 | fi 154 | -------------------------------------------------------------------------------- /Bash/memory_alert.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ########################## 4 | #Disclaimer: 5 | #Memory Alert is currently a work in progress and is not production ready... 6 | ########################### 7 | 8 | #Change values below 9 | 10 | email="admin@nerdofcode.com" 11 | low_memory="10000" #In KB 12 | 13 | 14 | ############################# 15 | 16 | #Requirement checking below 17 | 18 | if [ ! -f /proc/meminfo ] 19 | then 20 | echo "Sorry but your system is not supported..." 21 | exit 1 22 | fi 23 | 24 | 25 | if [ $(whoami) != root ] 26 | then 27 | echo "This script needs to be run as root" 28 | exit 1 29 | fi 30 | 31 | if [ -f /var/log/memory_alert.log ] 32 | then 33 | echo "Welcome back!!!" 34 | else 35 | 36 | echo "Welcome to memory alert!!!" 37 | touch /var/log/memory_alert.log 38 | fi 39 | 40 | ################################ 41 | 42 | #Magic happens below 43 | 44 | free_mem=$(sudo cat /proc/meminfo | grep MemFree: | tr 'MemFree:' ' ' | tr 'kB' ' ' | sed 's/ //g' ) 45 | if [ $free_mem -lt $low_memory ] 46 | then 47 | echo "Low memory!!! Free memory $free_memkB" | mail -s "Low Memory" $email 48 | echo "Email sent to $email at $(date)" > /var/log/memory_alert.log 49 | fi 50 | 51 | 52 | #Reset timer 53 | sudo -k 54 | 55 | exit 0 56 | -------------------------------------------------------------------------------- /Bash/mx_lookup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #Purpose: Look up MX records using a simple two step process 3 | 4 | #Colors for all warnings and errors 5 | RED='\033[0;31m' 6 | NONE='\033[0m' 7 | 8 | $(which dig >/dev/null 2>&1) 9 | 10 | if [ $? != 0 ] 11 | then 12 | echo "Please install the 'dig' command" 13 | exit 1 14 | fi 15 | 16 | read -p "Enter host domain: " host 17 | 18 | mx_target=$(dig +short MX $host | awk -F " " '{print $2}') 19 | 20 | ip=$(ping -c 1 $mx_target | awk -F " " '{print $5}' | sed 's/[^0-9.]*//g' | xargs) 21 | 22 | 23 | echo "MX record: $mx_target" 24 | 25 | if [ -z $ip ] 26 | then 27 | printf "${RED}NOTE:${NONE} it is likely this IP blocks ICMP or ping requests\n" 28 | fi 29 | echo "IP: $ip" 30 | -------------------------------------------------------------------------------- /Bash/portscan.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | timeout_time=.5 3 | 4 | read -p "Enter hostname: " hostname 5 | read -p "Enter port/ports range(Ex: 1-443 or 443): " ports 6 | 7 | #Seperate input into two seperate variables 8 | high=$(echo $ports| cut -f2 -d"-") 9 | low=$(echo $ports | cut -f1 -d"-") 10 | 11 | est_time=$(echo "$timeout_time * $high" | bc) 12 | 13 | echo "Max Estimated Time: $est_time seconds" 14 | #Create a for loop to scan 15 | for (( i=$low; i <= $high; i++)){ 16 | timeout $timeout_time nc -z -v $hostname $i >/dev/null 17 | if [ $? == 0 ] 18 | then 19 | echo "$i is open!" 20 | fi 21 | } 22 | exit 0 23 | -------------------------------------------------------------------------------- /Bash/recent_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Purpose: Display the most recently appended or altered directory or file 4 | 5 | #Check to see if this was run yet. 6 | run=".recent_files_scripts.txt" 7 | 8 | #How many to display at once 9 | #Please note that the default will not change, unless you change it on the line far below 10 | count=1 11 | 12 | 13 | if [ ! -f ~/.$run ] 14 | then 15 | echo "Please run this script by using ./recent_file_mod.sh [number of files/directories to display[ex: 1]]" 16 | touch ~/.$run 17 | exit 1 18 | fi 19 | 20 | if [ ! -z $1 ] 21 | then 22 | count=$1 23 | else 24 | read -p "Enter Number of Files/Dirs to display(default: 1): " count 25 | if [ -z $count ] 26 | then 27 | count=1 28 | fi 29 | fi 30 | 31 | #Actually get the recent list 32 | Recent=$(ls -t | head -n $count) 33 | 34 | 35 | echo -e "Recent Files: \n$Recent" 36 | -------------------------------------------------------------------------------- /Bash/sendmail.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #Author: NerdOfCode 3 | #Purpose: To send mail from CLI 4 | #Tested on Ubuntu 17.04 5 | #Tested on: Antergos (Arch based) 6 | 7 | #for saving the mail temporarily 8 | random=$RANDOM 9 | 10 | #Mail related functionality 11 | mail=$(which mailutils >/dev/null 2>&1) 12 | mail_status=$? 13 | check_ser=$(which postfix >/dev/null 2>&1) 14 | check_ser_status=$? 15 | temp_d=/tmp/ 16 | mail_ext=.mail 17 | 18 | echo -e "THIS PROGRAM IS OF NO WARRANTY!!! I AM NOT RESPONSIBLE FOR ANY MISUSES OF IT. THIS SCRIPT IS SOLELY FOR EDUCATIONAL PURPOSES \n \n" 19 | sleep 5 20 | clear 21 | 22 | #Check if user meets requirements 23 | if [ $mail_status != 0 ] 24 | then 25 | echo "I am very sorry... But I require the mailutils package to sendmail" 26 | exit 1 27 | fi 28 | 29 | if [ $check_ser_status != 0 ] 30 | then 31 | echo "I am very sorry... But I require the Postfix service" 32 | exit 1 33 | fi 34 | 35 | read -p "Enter from address: " from 36 | read -p "Enter receiving address: " receive 37 | read -p "Enter subject: " subject 38 | echo "Enter message in one second: " 39 | sleep 2 40 | #Open a file to edit the body of a message 41 | nano $temp_d$random$mail_ext 42 | body=$(cat $temp_d$random$mail_ext) 43 | 44 | read -p "Ready to send? (yes): " send 45 | 46 | if [ $send == "yes" ] 47 | then 48 | echo $body | mail -aFrom:$from -s "$subject" $receive 49 | exit 0 50 | else 51 | echo "The body of your message was stored here: $temp_d$random$mail_ext" 52 | exit 0 53 | fi 54 | 55 | -------------------------------------------------------------------------------- /Bash/swap_memory_usage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ########################################################### 4 | ##Purpose: This script gets current swap and memory usage 5 | ##Updated: 2/21/18 6 | ##Tested on: Antergos 7 | ##What actually happens under the hood? 8 | ###Basically glorifies the "free -h" command### 9 | ############################################################ 10 | 11 | input=$(free -h) 12 | 13 | ###RAM related variables 14 | memory_max=$(echo "$input" | grep "Mem: " | awk -F " " '{print $2}') 15 | used_memory=$(echo "$input" | grep "Mem: " | awk -F " " '{print $3}') 16 | shared_memory=$(echo "$input" | grep "Mem: " | awk -F " " '{print $5}') 17 | available_memory=$(echo "$input" | grep "Mem: " | awk -F " " '{print $7}') 18 | 19 | ###SWAP related variables 20 | swap_max=$(echo "$input" | grep "Swap: " | awk -F " " '{print $2}') 21 | swap_used=$(echo "$input" | grep "Swap: " | awk -F " " '{print $3}') 22 | 23 | ##Actually calculate swap free instead of grabbing for efficiency 24 | ##Note: Need to manually remove identifiers so they dont mess up arithmetic 25 | swap_max2=$(echo $swap_max | tr -d "G") 26 | swap_used2=$(echo $swap_used | tr -d "B") 27 | swap_free=$(echo "$swap_max2 - $swap_used2" | bc) 28 | 29 | print_values () { 30 | echo "Max Memory: $memory_max" 31 | echo "Used Memory: $used_memory + $shared_memory" 32 | echo "Available Memory: $available_memory" 33 | echo "Swap Max: $swap_max" 34 | echo "Swap Used: $swap_used" 35 | echo "Swap Free: ${swap_free}G" 36 | } 37 | 38 | print_values 39 | -------------------------------------------------------------------------------- /Bash/time_teller.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #change the wpm in espeak 4 | rate=120 5 | 6 | 7 | $(which espeak >/dev/null 2>&1) 8 | 9 | if [ $? != 0 ] 10 | then 11 | echo "Please install espeak" 12 | exit 1 13 | fi 14 | 15 | time=$(date | awk -F " " '{print $4}') 16 | 17 | read -p "Please enter sleep interval in seconds: " interval 18 | 19 | echo "PID: $PPID" 20 | 21 | while true 22 | do 23 | 24 | espeak $time -s $rate >/dev/null 2>&1 25 | 26 | sleep $interval 27 | 28 | done 29 | -------------------------------------------------------------------------------- /Bash/ttyecho/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #Author: NerdOfCode 3 | 4 | ###ATTENTION### 5 | clear 6 | echo "TTYECHO source code originates from http://www.humbug.in/2010/utility-to-send-commands-or-data-to-other-terminals-ttypts/" 7 | sleep 5 8 | clear 9 | ###END### 10 | 11 | 12 | if [ $(which ttyecho) ] 13 | then 14 | echo "ttyecho is already installed. Would you like to reinstall? (y/n)" 15 | read -p "Response: " response 16 | if [ $response == "n" ] 17 | then 18 | exit 0 19 | fi 20 | fi 21 | 22 | if [ ! $(which gcc) ] 23 | then 24 | echo "Gcc not installed... Attempting to install" 25 | sudo apt install gcc 26 | fi 27 | 28 | if [ ! -z ttyecho.c ] 29 | then 30 | gcc ttyecho.c 31 | else 32 | echo "ttyecho.c not found... Exiting..." 33 | exit 1 34 | fi 35 | 36 | 37 | echo "Would you like to make the ttyecho command global? (y/n)" 38 | read -p "Response: " response 39 | 40 | if [ $response == "y" ] 41 | then 42 | sudo mv a.out /usr/bin/ttyecho 43 | fi 44 | 45 | 46 | echo "Success!!!" 47 | exit 0 48 | -------------------------------------------------------------------------------- /Bash/ttyecho/ttyecho.c: -------------------------------------------------------------------------------- 1 | //Original Source: http://www.humbug.in/2010/utility-to-send-commands-or-data-to-other-terminals-ttypts/ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | void print_help(char *prog_name) { 12 | printf("Usage: %s [-n] DEVNAME COMMAND\n", prog_name); 13 | printf("Usage: '-n' is an optional argument if you want to push a new line at the end of the text\n"); 14 | printf("Usage: Will require 'sudo' to run if the executable is not setuid root\n"); 15 | exit(1); 16 | } 17 | 18 | int main (int argc, char *argv[]) { 19 | char *cmd, *nl = "\n"; 20 | int i, fd; 21 | int devno, commandno, newline; 22 | int mem_len; 23 | devno = 1; commandno = 2; newline = 0; 24 | if (argc < 3) { 25 | print_help(argv[0]); 26 | } 27 | if (argc > 3 && argv[1][0] == '-' && argv[1][1] == 'n') { 28 | devno = 2; commandno = 3; newline=1; 29 | } else if (argc > 3 && argv[1][0] == '-' && argv[1][1] != 'n') { 30 | printf("Invalid Option\n"); 31 | print_help(argv[0]); 32 | } 33 | fd = open(argv[devno],O_RDWR); 34 | if(fd == -1) { 35 | perror("open DEVICE"); 36 | exit(1); 37 | } 38 | mem_len = 0; 39 | for ( i = commandno; i < argc; i++ ) { 40 | mem_len += strlen(argv[i]) + 2; 41 | if ( i > commandno ) { 42 | cmd = (char *)realloc((void *)cmd, mem_len); 43 | } else { //i == commandno 44 | cmd = (char *)malloc(mem_len); 45 | } 46 | 47 | strcat(cmd, argv[i]); 48 | strcat(cmd, " "); 49 | } 50 | if (newline == 0) 51 | usleep(225000); 52 | for (i = 0; cmd[i]; i++) 53 | ioctl (fd, TIOCSTI, cmd+i); 54 | if (newline == 1) 55 | ioctl (fd, TIOCSTI, nl); 56 | close(fd); 57 | free((void *)cmd); 58 | exit (0); 59 | } 60 | -------------------------------------------------------------------------------- /Bash/untrackable_shell.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #A simple script that half-heartedly tries to prevent command logging 3 | 4 | cut=$(which cut >/dev/null 2>&1) 5 | 6 | if [ $? != 0 ] 7 | then 8 | echo "Please install the cut command..." 9 | exit 1 10 | fi 11 | 12 | hostname=$(cat /etc/hostname | cut -f1 -d ".") 13 | 14 | 15 | while true 16 | do 17 | 18 | read -p "$(whoami)@$hostname:$(pwd):~# " shell 19 | 20 | if [ $shell == 'exit' ] || [ $shell == 'quit' ] 21 | then 22 | exit 0 23 | fi 24 | 25 | $shell 26 | 27 | done 28 | -------------------------------------------------------------------------------- /C#/primeOrFactor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | public class PrimeNumber { 5 | /* 6 | Arguments: 7 | [1] => A potential prime number 8 | Returns: 9 | [1] => Bool (true => prime, false => !prime) 10 | */ 11 | public bool isPrime(int potentialPrimeNumber){ 12 | for(int startFactor = 2; startFactor <= potentialPrimeNumber/2; startFactor++){ 13 | if(potentialPrimeNumber % startFactor == 0){ 14 | return false; 15 | } 16 | } 17 | return true; 18 | } 19 | 20 | /* 21 | Arguments: 22 | [1] => A potential prime number 23 | Returns: 24 | [1] => Bool (true => pirme, false => !prime) 25 | [2] => List (factors) 26 | */ 27 | 28 | public Tuple> isPrimeAndFactors(int potentialPrimeNumber){ 29 | if(!isPrime(potentialPrimeNumber)){ 30 | return Tuple.Create(true, factors(potentialPrimeNumber)); 31 | }else{ 32 | return Tuple.Create(false, new List(){ 33 | 1, 34 | potentialPrimeNumber 35 | }); 36 | } 37 | } 38 | /* 39 | Arguments: 40 | [1] => Not a prime number 41 | Returns: 42 | [1] => Literal list of factors of Argument 43 | */ 44 | public List factors(int notPrimeNumber){ 45 | var factors = new List(); 46 | for(int startFactor = 2; startFactor <= notPrimeNumber/2; startFactor++){ 47 | if(notPrimeNumber % startFactor == 0){ 48 | factors.Add(startFactor); 49 | } 50 | } 51 | return factors; 52 | } 53 | } 54 | 55 | class primeOrFactor { 56 | static void Main(string[] args) { 57 | if(args.Length == 0){ 58 | Console.WriteLine("Please pass a number to test: prime.cs 3301"); 59 | }else if(args.Length == 1){ 60 | int number; 61 | if(Int32.TryParse(args[0],out number)){ 62 | PrimeNumber prime = new PrimeNumber(); 63 | Console.WriteLine($"{number} is prime: {prime.isPrime(number)}"); 64 | Console.Write("Factors: "); 65 | foreach(var factor in prime.isPrimeAndFactors(number).Item2) 66 | Console.Write($"{factor} "); 67 | Console.WriteLine(""); 68 | }else{ 69 | Console.WriteLine("Please pass an Int, as an argument!"); 70 | Environment.Exit(1); 71 | } 72 | }else{ 73 | Console.WriteLine("Please only specify one argument."); 74 | Environment.Exit(1); 75 | } 76 | } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /C#/speak.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Speech.Synthesis; 4 | namespace speaktime 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | //Create a new speech synthesizer process and use the name talk 11 | SpeechSynthesizer talk = new SpeechSynthesizer(); 12 | //Write details about dev 13 | Console.WriteLine("Author: NerdOfCode."); 14 | Console.WriteLine("Purpose: Speak time."); 15 | Thread.Sleep(3500); 16 | 17 | //Get users name and store it as a string 18 | Console.Write("Enter Name: "); 19 | string name = Console.ReadLine(); 20 | //if user enters no name Exit program 21 | if (name == "") 22 | { 23 | Console.Write("No name, no play"); 24 | talk.Speak(string.Format("No name... goodbye now")); 25 | System.Environment.Exit(1); 26 | } 27 | 28 | 29 | //Say name and information about date & time 30 | talk.Speak(string.Format("Hello {0}", name)); 31 | DateTime currentTime = DateTime.Now; 32 | talk.Speak(string.Format("The current time is {0}", currentTime)); 33 | 34 | 35 | 36 | //Exit program 37 | System.Environment.Exit(1); 38 | 39 | 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /C++/README.md: -------------------------------------------------------------------------------- 1 | ## Notice 2 | All scripts in this category were compiled with `g++` and are known to be somewhat working on Arch Linux... 3 | 4 | ### File Notes 5 | 6 | ***note_taker.cpp*** 7 | 8 | For this script I recommend turning it into a command (at least on *nix)... It simply asks for a filename, and a message' or body contents... It is useful for taking fast notes if you're in a hurry!!! Be sure too end the message with ***EOF*** when you're finished writing!!! 9 | -------------------------------------------------------------------------------- /C++/guess_num.cpp: -------------------------------------------------------------------------------- 1 | //Author: NerdOfCode 2 | 3 | #include 4 | #include // rand 5 | #include // Srand 6 | #include // obvious 7 | #include // obvious 8 | #include // Printf 9 | #include //Sleep 10 | 11 | using namespace std; 12 | 13 | 14 | //Variable initialization 15 | int guess = 0; 16 | int warning = 0; 17 | int random_gen = 0; 18 | int ran = 0; 19 | int tries = 0; 20 | int wins = 0; 21 | int play; 22 | int rand_one_max = 100; 23 | bool found_rand = false; 24 | //Change this to true if you want the answer to be given out 25 | const bool cheat = false; 26 | //const string escape = 'exit'; 27 | 28 | int randomize(){ 29 | srand(time(NULL)); 30 | 31 | int random_gen = (rand() % rand_one_max); 32 | 33 | if(cheat){cout << "The answer is: " << random_gen << endl;} 34 | 35 | return random_gen; 36 | } 37 | 38 | 39 | 40 | int main(){ 41 | 42 | //Get rid of any previous values 43 | int guess = 0; 44 | 45 | if(!ran){random_gen = randomize();ran+=1;} 46 | if(warning!=0){cout << "You have received a warning, please re-run this program..." << endl; return 1;} 47 | 48 | cout << "Your range is between 1:" << rand_one_max << endl; 49 | cout << "Guess a number: "; 50 | cin >> guess; 51 | 52 | if(guess > random_gen * 200 ){cout << endl << "Calm down there Jim!" << endl << endl;} 53 | 54 | //Escape is currently non functioning 55 | //if(guess == escape){return 0;}false 56 | 57 | if(!guess){cout<<"Enter a number please..."<> play; 71 | if(play == 1){ran--;tries=0;main();}else{return 0;} 72 | 73 | 74 | 75 | }else if(guess != random_gen){ 76 | 77 | if(guess > random_gen){ 78 | 79 | cout << "Try a lower number..." << endl; 80 | 81 | }else if(guess < random_gen){ 82 | 83 | cout << "Try a higher number..." << endl; 84 | 85 | } 86 | if(warning != 1){tries++;main();} 87 | } 88 | 89 | 90 | 91 | 92 | } 93 | -------------------------------------------------------------------------------- /C++/isPrime.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main(){ 7 | 8 | int isPrime; 9 | int guess=2; 10 | 11 | cout << "Enter number to test if it is prime: "; 12 | cin >> isPrime; 13 | 14 | while(isPrime >= guess){ 15 | 16 | if( guess != isPrime && isPrime%guess == 0 ){ 17 | 18 | cout << isPrime << " is not a prime number!" << endl; 19 | break; 20 | 21 | }else if(guess==isPrime){ 22 | 23 | cout << isPrime << " is a prime number!"<< endl; 24 | break; 25 | 26 | }else{ 27 | 28 | guess++; 29 | 30 | } 31 | } 32 | 33 | return 0; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /C++/loading_sign.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include //Sleep function and ms 3 | 4 | using namespace std; 5 | 6 | int main(void){ 7 | 8 | while(true){ 9 | 10 | cout << "\b" << flush; 11 | cout << "|" << flush; 12 | 13 | usleep(7500); 14 | cout << "\b" << flush; 15 | 16 | cout << "/" << flush; 17 | usleep(7500); 18 | 19 | cout << "\b" << flush; 20 | usleep(7500); 21 | 22 | cout << "\b" << flush; 23 | cout << "-" << flush; 24 | usleep(7500); 25 | 26 | cout << "\b" << flush; 27 | cout << "\\" << flush; 28 | usleep(7500); 29 | 30 | 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /C++/note_taker.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | int main(){ 10 | 11 | string filename; 12 | string message; 13 | 14 | printf("Enter filename: "); 15 | cin >> filename; 16 | 17 | if(ifstream(filename)){ 18 | printf("File already exists...\n"); 19 | exit(1); 20 | } 21 | 22 | printf("Enter message: \n"); 23 | 24 | while(1){ 25 | 26 | getline(cin, message); 27 | 28 | if(message != "EOF"){ 29 | //ios::app makes the output appended 30 | ofstream note (filename, ios::app); 31 | 32 | note << message << endl; 33 | 34 | note.close(); 35 | 36 | }else{ 37 | break; 38 | } 39 | 40 | } 41 | 42 | 43 | if(ifstream(filename)){ 44 | printf("File successfully created!!!\n"); 45 | } 46 | 47 | 48 | return 0; 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /C++/prime_finder.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main(int argc, char **argv){ 6 | 7 | int start = 4; 8 | int divide1 = 2; 9 | //Change to 1 to show not prime numbers 10 | int show_not_prime = 0; 11 | //Change to 0 to hide primes 12 | int show_prime = 1; 13 | 14 | while(1){ 15 | if(start % divide1 == 0){ 16 | if(show_not_prime){ 17 | printf("%d is not a prime!\n",start); 18 | } 19 | start++; 20 | divide1 = 2; 21 | }else if(divide1 <= start/2){ 22 | divide1++; 23 | }else if(start % divide1 != 0){ 24 | if(show_prime){ 25 | printf("%d is a prime!!!\n", start); 26 | } 27 | start++; 28 | divide1 = 2; 29 | 30 | } 31 | } 32 | 33 | return 0; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /C/README.md: -------------------------------------------------------------------------------- 1 | ## Note 2 | 3 | It is important to note that all these mini-programs were compiled using `gcc`... 4 | 5 | ### Individual File Notes 6 | 7 | ***convert_ANSI.c*** 8 | 9 | This program excepts no arguments, and is simply meant to be compiled and run! Instructions are given at execution 10 | -------------------------------------------------------------------------------- /C/convert_ANSI.c: -------------------------------------------------------------------------------- 1 | //Purpose: To convert inputted characters into ANSI relations... 2 | 3 | #include 4 | #include 5 | 6 | #define NULL2 1 7 | 8 | int convert(); 9 | 10 | int main( int argc ){ 11 | 12 | 13 | if(argc != NULL2){ 14 | puts("HELP: "); 15 | printf("Note: It is recommended that if you have a space in your string...\nYou put an underscore (_) between the words...\n"); 16 | printf("Also, if you need to use an underscore for some reason, just use the '\\' character... Ex: \\_\n"); 17 | exit(0); 18 | } 19 | 20 | //Give user some background info 21 | printf("Note: It is recommended that if you have a space in your string...\nYou put an underscore (_) between the words...\n"); 22 | printf("Also, if you need to use an underscore for some reason, just use the '\\' character... Ex: \\_\n"); 23 | 24 | convert(); 25 | 26 | return 0; 27 | } 28 | 29 | int convert( void ){ 30 | //Define variables and request memory allocation space 31 | unsigned char *text; 32 | text = (char *) malloc(25 * sizeof(char)); 33 | 34 | if(text == NULL){ 35 | printf("Not enough system resources available...\n"); 36 | exit(1); 37 | } 38 | 39 | printf("Enter text: "); 40 | 41 | scanf("%s",text); 42 | 43 | int i = 0; 44 | 45 | while(text[i] != 48){ 46 | 47 | if(text[i] == 0){ 48 | break; 49 | } 50 | 51 | //Enable the '\' escape character 52 | if(text[i] == 92){ 53 | if(text[i++] == 95){ 54 | 55 | } 56 | }else if(text[i] == 95 || text[i] == 92){ 57 | i++; 58 | } 59 | 60 | if(text[i] != 0){ 61 | printf("For: %c, ANSI code is: %d\n",text[i],text[i]); 62 | } 63 | 64 | i++; 65 | } 66 | 67 | 68 | //Release or 'free' allocated memory 69 | free(text); 70 | 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /C/countdown.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Purpose: A super simple count down timer according to user input 4 | Author: NerdOfCode 5 | Updated: 3/2/18 6 | 7 | */ 8 | 9 | #include 10 | #include //Sleep 11 | #include //atoi 12 | 13 | int main( int argc, char *argv[] ){ 14 | 15 | int countdown_seconds = 0; 16 | 17 | //Accept command line args 18 | if (argc == 1){ 19 | printf("Enter time(unit: s): "); 20 | scanf("%i",&countdown_seconds); 21 | } else { 22 | //Convert string to interger 23 | countdown_seconds = atoi(argv[1]); 24 | } 25 | 26 | //Actual simple countdown mechanism below 27 | for (int i = 0; i < countdown_seconds;) { 28 | printf("%i",countdown_seconds); 29 | --countdown_seconds; 30 | sleep(1); 31 | puts(""); 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /C/create_square.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int print_square(); 5 | 6 | int main(int argc,char *argv[]){ 7 | 8 | if(argc < 3){ 9 | puts("This program requires you to pass args..."); 10 | puts("For example: ./a.out 5 5"); 11 | return -1; 12 | } 13 | 14 | 15 | print_square(atoi(argv[1]),atoi(argv[2])); 16 | 17 | return 0; 18 | 19 | } 20 | 21 | int print_square(int width, int length){ 22 | 23 | printf("Width: %i, Length: %i\n",width,length); 24 | 25 | for(int i = 0; i <= width; ++i){ 26 | 27 | printf("*"); 28 | 29 | } 30 | 31 | puts(""); 32 | 33 | for(int i = 0; i <= length; ++i){ 34 | 35 | printf("*"); 36 | for(int i = 0; i <= width - 2; ++i){ 37 | printf(" "); 38 | } 39 | printf("*\n"); 40 | 41 | } 42 | 43 | 44 | for(int i = 0; i <= width; ++i){ 45 | 46 | printf("*"); 47 | 48 | } 49 | puts(""); 50 | return 0; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /C/custom/get_args.c: -------------------------------------------------------------------------------- 1 | 2 | char get_args(int argc, char *argv[]){ 3 | if(argc == 1){ 4 | //No arguements except the invokation 5 | return 1; 6 | }else{ 7 | for(int i=1;i < argc; i++) 8 | printf("File Execution Arguements involved: %s\n",argv[i]); 9 | return 0; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /C/custom/sizes.c: -------------------------------------------------------------------------------- 1 | //Global Variables 2 | int size_int, 3 | size_char, 4 | size_unsignedc, 5 | size_signedc, 6 | size_unsignedint, 7 | size_short, 8 | size_unsignedshort, 9 | size_long, 10 | size_unsignedlong; 11 | 12 | int sizes(){ 13 | size_int = sizeof(int); 14 | size_char = sizeof(char); 15 | size_unsignedc = sizeof(unsigned char); 16 | size_signedc = sizeof(signed char); 17 | size_unsignedint = sizeof(unsigned int); 18 | size_short = sizeof(short); 19 | size_unsignedshort = sizeof(size_unsignedshort); 20 | size_long = sizeof(long); 21 | size_unsignedlong = sizeof(unsigned long); 22 | 23 | return 24 | size_int, 25 | size_char, 26 | size_unsignedc, 27 | size_signedc, 28 | size_unsignedint, 29 | size_short, 30 | size_unsignedshort, 31 | size_long, 32 | size_unsignedlong; 33 | } 34 | -------------------------------------------------------------------------------- /C/delete_file.c: -------------------------------------------------------------------------------- 1 | /* 2 | Author: NerdOfCode 3 | Purpose: To delete inputted file 4 | Updated: 2/26/18 5 | */ 6 | 7 | #include 8 | #include 9 | #include "includes/default.h" 10 | 11 | int main ( void ) { 12 | 13 | char filename[Sof_INPUT_STRING] = ""; 14 | short int status = 0; 15 | 16 | // Get filename 17 | printf("Enter filename to delete: "); 18 | scanf("%s",filename); 19 | 20 | status = remove(filename); 21 | 22 | if (status == 0) { 23 | printf("File deleted!\n"); 24 | return(1); 25 | } else { 26 | fprintf(stderr,"An error has occurred...\n"); 27 | return(-1); 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /C/etc/is_prime.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../includes/is_prime.h" 4 | 5 | bool is_prime(unsigned long long int n) 6 | { 7 | for (size_t i = 2; i <= n/2 ; i++){ 8 | if (n % i == 0) 9 | return false; 10 | } 11 | return true; 12 | } 13 | -------------------------------------------------------------------------------- /C/factor_finder.c: -------------------------------------------------------------------------------- 1 | // factor_finder.c 2 | // TODO: Fix a memory freeing issue that on rare occassion causes a program crash 3 | 4 | #include 5 | #include 6 | 7 | typedef struct 8 | { 9 | long int numb; 10 | int *factors; 11 | size_t f_len; 12 | } Factor; 13 | 14 | // Return values: 1 => Argument(arg=argv[1]) passed, 0 => No Argument 15 | int parse_args(int argc, char *argv[]); 16 | 17 | void print_array(int *array, size_t len); 18 | void ff_wrapper(int n); 19 | 20 | void find_factors (Factor *factor) { 21 | size_t factor_size = 0, cur_factor = 0; 22 | factor->factors = (int *) calloc(factor_size, sizeof(int)); 23 | 24 | if (!factor->factors) { 25 | return; 26 | } 27 | 28 | for (size_t x = 1; x <= factor->numb; x++) { 29 | if (factor->numb % x == 0) { 30 | factor->factors = (int *) realloc(factor->factors, ++factor_size); 31 | factor->factors[cur_factor++] = x; 32 | } 33 | } 34 | factor->f_len = cur_factor; 35 | } 36 | 37 | int main ( int argc, char *argv[] ) { 38 | 39 | if (parse_args(argc, argv)) { 40 | return 0; 41 | } 42 | 43 | return 0; 44 | } 45 | 46 | int parse_args (int argc, char *argv[]) 47 | { 48 | int number = 0; 49 | 50 | if (argc == 1 || argc > 2) { 51 | printf("Enter number: "); 52 | scanf("%d", &number); 53 | } else { 54 | number = atoi(argv[1]); 55 | } 56 | 57 | ff_wrapper(number); 58 | 59 | return 1; 60 | } 61 | 62 | void ff_wrapper (int n) 63 | { 64 | Factor factor; 65 | Factor *p_factor = &factor; 66 | 67 | p_factor->numb = (long int) n; 68 | 69 | find_factors(p_factor); 70 | print_array(p_factor->factors, p_factor->f_len); 71 | 72 | if (p_factor->factors) { 73 | free(p_factor->factors); 74 | } 75 | 76 | return; 77 | } 78 | 79 | void print_array (int *array, size_t len) 80 | { 81 | for (size_t i = 0; i < len; i++) 82 | printf("%i ", array[i]); 83 | 84 | puts(""); 85 | 86 | return; 87 | } 88 | 89 | 90 | -------------------------------------------------------------------------------- /C/fortune.c: -------------------------------------------------------------------------------- 1 | // Purpose: Generate a pseudo-random fortune using C 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | int main(){ 8 | //Seeds the random time concurrently with time() 9 | srand(time(NULL)); 10 | 11 | //Declare the arrays max size, will also be used for generating the random number 12 | int max_size = 12; 13 | 14 | int random = rand() % (max_size + 1); 15 | 16 | char *fortunes[] = {"Do what's right!","Jolly", "Fantastic", "Possibly", "Definetly","Good Luck!", "What a joke...","Your future is bright.","Hold on tight","Just a few more days...","Keep moving","Not a chance"}; 17 | 18 | printf("Your fortune: %s\n", fortunes[random]); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C/includes/default.h: -------------------------------------------------------------------------------- 1 | /* default.h 2 | * Task: Default values to be used in some of the C scripts 3 | * 4 | */ 5 | 6 | #define Sof_INPUT_STRING 256 7 | 8 | -------------------------------------------------------------------------------- /C/includes/is_prime.h: -------------------------------------------------------------------------------- 1 | #ifndef IS_PR_H 2 | #define IS_PR_H 3 | #include 4 | #include "../etc/is_prime.c" 5 | 6 | extern bool is_prime(unsigned long long int n); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /C/isPrimeCounter.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "includes/is_prime.h" 3 | 4 | void find_prime_numbers (unsigned long int start) 5 | { 6 | puts("PRIME NUMBERS"); 7 | 8 | for (unsigned long int i = start;;i++) { 9 | if (is_prime(i)) 10 | printf("%li\n",i); 11 | } 12 | 13 | return; 14 | } 15 | 16 | int main (int argc, char *argv[]) 17 | { 18 | find_prime_numbers(0); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C/is_even_odd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * is_even_odd.c 3 | * Task: Test if a given long int is an even or odd number and return type bool 4 | * 5 | * 6 | * */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | bool is_even(long int n) 13 | { 14 | if (n % 2 == 0) { 15 | return true; 16 | } else { 17 | return false; 18 | } 19 | } 20 | 21 | int parse_args(int argc, char *argv[]) 22 | { 23 | long int u_x = 0; 24 | 25 | if (argc == 1) { 26 | printf("Enter number: "); 27 | scanf("%li", &u_x); 28 | } else { 29 | u_x = atoi(argv[1]); 30 | } 31 | 32 | if (is_even(u_x)) { 33 | printf("%li is even\n", u_x); 34 | } else { 35 | printf("%li is odd\n", u_x); 36 | } 37 | 38 | return 0; 39 | } 40 | 41 | int main ( int argc, char *argv[] ) 42 | { 43 | parse_args(argc, argv); 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /C/is_prime.c: -------------------------------------------------------------------------------- 1 | // is_prime.c 2 | 3 | #include 4 | #include 5 | #include 6 | #include "includes/is_prime.h" 7 | 8 | void parse_args(int argc, char *argv[]) 9 | { 10 | unsigned long long int n = 0; 11 | 12 | if (argc == 1) { 13 | printf("Enter number: "); 14 | scanf("%llu", &n); 15 | } else { 16 | char *p_argv = ""; 17 | n = strtoull(argv[1], &p_argv, 0); 18 | } 19 | 20 | if (is_prime(n)) { 21 | printf("%llu is prime\n", n); 22 | } else { 23 | printf("%llu is NOT prime\n", n); 24 | } 25 | 26 | return; 27 | } 28 | 29 | int main (int argc, char *argv[]) 30 | { 31 | parse_args(argc, argv); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /C/reverse_array.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Author: NerdOfCode 4 | Date: 8/23/2018 5 | Purpose: Put the given char array in reverse order 6 | 7 | */ 8 | 9 | #include 10 | 11 | int main(void){ 12 | 13 | 14 | //Number of characters in array 15 | #define ARRAY_COUNT 14 16 | 17 | //Word to reverse 18 | char word[ARRAY_COUNT] = {"this is a test"}; 19 | 20 | char reverse_word[ARRAY_COUNT] = {}; 21 | 22 | int i = 0; 23 | 24 | //Used for starting at the end of the array and moving to the beginning 25 | int round_count = ARRAY_COUNT - 1; 26 | 27 | while(i < ARRAY_COUNT){ 28 | 29 | //Began writing to end of array 30 | reverse_word[round_count] = word[i]; 31 | 32 | //Adjust our parameters 33 | --round_count; 34 | ++i; 35 | } 36 | 37 | //Remove trailing newline and any other characters 38 | reverse_word[ARRAY_COUNT] = '\0'; 39 | 40 | //Print the sorted array 41 | printf("Sorted Array: %s\n",reverse_word); 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /C/shell.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Author: NerdOfCode 4 | Purpose: A work in progress shell built in C... Designed to be lightweight and fast... 5 | Updated: 3/8/18 6 | NOTE: THIS SCRIPT HAS BEEN MOVED TO A REPOSITORY UNDER NERDOFCODE'S GITHUB ACCOUNT 7 | 8 | 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include //Access 16 | #include 17 | 18 | //Color Constants 19 | #define RED_TEXT "\033[1;31m" 20 | #define YELLOW_TEXT "\x1B[33m" 21 | //Use 43m for background shading 22 | #define RESET "\x1B[0m" 23 | 24 | //Function Prototypes 25 | void clean_up(); 26 | void help_commands(); 27 | 28 | int parseCommand(); 29 | 30 | int main ( void ){ 31 | 32 | char input[64]; 33 | 34 | while(1){ 35 | printf(YELLOW_TEXT "Command: " RESET, " " ); 36 | scanf("%s",input); 37 | 38 | //TODO 39 | // - logging 40 | 41 | //Convert input to lowercase for unitext 42 | input[0] = tolower(input[0]); 43 | 44 | //Check to see if user wants to exit before re-running loop 45 | if(strcmp(input,"exit") == 0){ 46 | clean_up(); 47 | exit(1); 48 | }else if(strcmp(input,"help") == 0){ 49 | help_commands(); 50 | }else{ 51 | //Actually parse the command here 52 | parseCommand(input); 53 | } 54 | } 55 | 56 | 57 | //Start the clean up b4 exit 58 | clean_up(); 59 | 60 | return 0; 61 | } 62 | 63 | void clean_up(){ 64 | 65 | printf("Cleaning up...\n"); 66 | //Reset color values 67 | printf("%s\n",RESET); 68 | //TODO 69 | // - close any files used for logging 70 | 71 | 72 | } 73 | 74 | void help_commands(){ 75 | printf("Current usage:\n"); 76 | printf("exit --> Exits this shell...\n"); 77 | } 78 | 79 | 80 | int parseCommand(char input[64]){ 81 | 82 | int command_status = 0; 83 | char filename[66]; 84 | 85 | //Check if command exists relative to its filename 86 | 87 | //Add file extension 88 | strcat(filename,input); 89 | strcat(filename,".c"); 90 | 91 | //if(access(filename, F_OK) == 0){ 92 | char version[] = "https://github.com/NerdOfCode/Restricted-Shell"; 93 | printf("Please use the updated version at: %s\n",version); 94 | //} 95 | 96 | return 0; 97 | } 98 | -------------------------------------------------------------------------------- /C/simple_matrix.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | //char spam[64]; 4 | int i; 5 | 6 | int main(){ 7 | #define ANSI_COLOR_GREEN "\x1b[32m" 8 | #define ANSI_COLOR_RESET "\x1b[0m" 9 | 10 | 11 | char alpha_numeric[] = "0123456789" 12 | "abcdefghijklmnopqrstuvwxyz" 13 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 14 | 15 | //printf("Enter character to create loading sign: "); 16 | //fgets(spam,64,stdin); 17 | while(1==1){ 18 | 19 | printf(ANSI_COLOR_GREEN "%c" ANSI_COLOR_RESET,alpha_numeric[rand() % (sizeof(alpha_numeric) - 1)]); 20 | 21 | //Old matrix below 22 | //char random_letter = 'A' + (random() % 26); 23 | //printf(ANSI_COLOR_GREEN "%c" ANSI_COLOR_RESET,random_letter ); 24 | 25 | } 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /C/sort_int.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Author: NerdOfCode 4 | Date: 8/22/2018 5 | Purpose: Sort through given list of numbers and arrange them least to greatest 6 | 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | int main(void){ 13 | 14 | //Amount of integers in our array 15 | #define INT_COUNT 7 16 | 17 | //Safe start is to define a good starting integer to start comparing the list to... 18 | #define SAFE_START -99999 19 | 20 | //Safe number to exit the loop, without skipping anything important 21 | #define SAFE_EXIT 999 22 | 23 | //Define integers to sort 24 | int unsorted_ints[INT_COUNT] = {5, 4, 27, 2, 1, 0, -6}; 25 | 26 | //Empty list for the sorted ints 27 | int sorted_ints[INT_COUNT] = {}; 28 | 29 | //Compare unsorted int to the round count 30 | int round_count = SAFE_START; 31 | 32 | //Element to access 33 | int i = 0; 34 | 35 | //Current pos of new list 36 | int x = 0; 37 | 38 | while(round_count <= SAFE_EXIT){ 39 | if(i < INT_COUNT){ 40 | if(unsorted_ints[i] == round_count){ 41 | sorted_ints[x] = unsorted_ints[i]; 42 | //Increment the current pos of the new list 43 | x += 1; 44 | } 45 | ++i; 46 | }else{ 47 | i = 0; 48 | round_count += 1; 49 | } 50 | } 51 | 52 | for(i=0;i 2 | #include //Exit 3 | 4 | int main(){ 5 | 6 | //Define is deprecated 7 | //#define null 0 8 | //#define MAX_BUFFER 256 9 | int null = 0; 10 | int MAX_BUFFER = 256; 11 | 12 | 13 | 14 | int three; 15 | int copy = 0; 16 | int result; 17 | int seperate; 18 | int count=0; 19 | 20 | 21 | printf("Enter a three digit number: "); 22 | result = scanf("%i", &three); 23 | copy=three; 24 | if(result == 0){ 25 | printf("No input or error or letter input\n"); 26 | exit(1); 27 | } 28 | 29 | if(three!=null){ 30 | while(!(1==8)){ 31 | if(three % 10 == 0){ 32 | printf("Last Digit: 0\n"); 33 | exit(0); 34 | }else{ 35 | while(!(three % 10 == 0)){ 36 | three--; 37 | count++; 38 | } 39 | printf("The last digit: %i\n",count); 40 | three=three/10; 41 | //exit(0); 42 | } 43 | count=0; 44 | if(three % 10 == 0){ 45 | printf("The second digit: 0\n"); 46 | }else{ 47 | while(!(three % 10 == 0)){ 48 | three--; 49 | count++; 50 | } 51 | printf("The second digit: %i\n",count); 52 | three=three/10; 53 | //exit(0); 54 | } 55 | count=0; 56 | if(three % 10 == 0){ 57 | printf("The first digit: 0\n"); 58 | }else{ 59 | while(!(three % 10 == 0)){ 60 | three--; 61 | count++; 62 | } 63 | printf("The first digit: %i\n",count); 64 | exit(0); 65 | 66 | } 67 | 68 | 69 | } 70 | 71 | 72 | exit(0); 73 | 74 | } 75 | 76 | 77 | exit(0); 78 | } 79 | -------------------------------------------------------------------------------- /C/tic-tac-toe.c: -------------------------------------------------------------------------------- 1 | /* 2 | Author: NerdOfCode 3 | Purpose: Play a simple tic tac toe game with two players! 4 | Updated: 2/26/18 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #define S_BOARD 3 11 | //Basically set max checks for winner... Improves efficiency 12 | #define CHECK_COUNT 4 13 | 14 | //char board[3][3] = {{0,0,0},{0,0,0},{0,0,0}}; 15 | char board[S_BOARD][S_BOARD] = {0}; 16 | 17 | //0 --> player x 18 | //1 --> player y 19 | int current_player = 0; 20 | 21 | //If user makes a mistake, dont update to next player 22 | int dont_update_player = 0; 23 | 24 | //Start to check for winner after 3 plays for effiency 25 | int current_plays = 0; 26 | 27 | //Function Prototypes 28 | //////////////////////////////////// 29 | //Obviously displays the board 30 | //No arguements are currently taken... 31 | int display_board(); 32 | 33 | //Shows user coordinates for board 34 | int help_display_board(); 35 | 36 | //Takes user input and saves to the multidimensional array 37 | int make_move(); 38 | 39 | //Determines current user and outputs the char corresponding player 40 | char c_current_player(); 41 | 42 | //Checks for a winning pattern 43 | int check_winner(); 44 | 45 | int main( void ){ 46 | 47 | //Shows user coordinates 48 | help_display_board(); 49 | 50 | //Inform user about board positions 51 | display_board(); 52 | 53 | //Ready to start playing... 54 | make_move(); 55 | 56 | 57 | return(1); 58 | 59 | } 60 | 61 | 62 | int display_board( void ){ 63 | 64 | int i,n; 65 | for(i = 0; i < S_BOARD; i++){ 66 | for(n = 0; n < S_BOARD; n++){ 67 | printf(".%c.", board[i][n]); 68 | } 69 | printf("\n"); 70 | } 71 | 72 | return(1); 73 | } 74 | 75 | //Shows user predrawn coordinates 76 | int help_display_board( void ){ 77 | puts("\nBoard coordinates: "); 78 | for(int i = 0; i < S_BOARD; i++){ 79 | for(int n = 0; n < S_BOARD; n++){ 80 | printf("|%i,%i|", i, n); 81 | } 82 | printf("\n"); 83 | } 84 | 85 | return(1); 86 | } 87 | 88 | //Determines which is current player 89 | //0 --> x 90 | //... 91 | char c_current_player(void){ 92 | if(current_player){ 93 | current_player--; 94 | return('y'); 95 | }else{ 96 | current_player++; 97 | return('x'); 98 | } 99 | } 100 | 101 | //Temporary Shortcut 102 | char local_player; 103 | 104 | //If arguement 1 is passed, the current player will be given another turn 105 | int make_move( int dont_update_player ){ 106 | 107 | //Values to be changed in the main array 108 | int x,y = 0; 109 | 110 | 111 | if( dont_update_player == 0 ){ 112 | //Get current player 113 | local_player = c_current_player(); 114 | //dont_update_player = 0; 115 | } 116 | 117 | //Check to make sure player is not empty 118 | if(! local_player){ 119 | local_player = 'x'; 120 | } 121 | 122 | printf("\nPlayer: %c's turn...\n\n",local_player); 123 | 124 | printf("Enter x location: "); 125 | scanf("%i",&x); 126 | 127 | printf("Enter y location: "); 128 | scanf("%i",&y); 129 | 130 | //Check if space on board is occupied 131 | if(board[x][y] != 0){ 132 | printf("\n\nThat space is occupied already...\n\n"); 133 | display_board(); 134 | //Re-run again 135 | make_move(1); 136 | }else{ 137 | //Actually write values 138 | board[x][y] = local_player; 139 | display_board(); 140 | //Update current_plays to inch towards checking for a check_winner 141 | current_plays++; 142 | 143 | if(current_plays >= 3){ 144 | check_winner(); 145 | } 146 | 147 | make_move(0); 148 | 149 | } 150 | return(1); 151 | } 152 | 153 | int check_winner( void ){ 154 | int x = 0, y = 0, checks = 0; 155 | char winner = '\0'; 156 | 157 | while(checks <= CHECK_COUNT){ 158 | //Current stored value in array 159 | char current_value = board[x][y]; 160 | //printf("Current: %c\n",current_value); 161 | 162 | //x | y 163 | //x | y 164 | //x | y 165 | if(board[x+1][y] == current_value && board[x+2][y] == current_value){ 166 | winner = current_value; 167 | break; 168 | } 169 | //x x x 170 | //y y y 171 | if(board[x][y+1] == current_value && board[x][y+2] == current_value){ 172 | winner = current_value; 173 | break; 174 | } 175 | //x 176 | // x 177 | // x 178 | if(board[x+1][y+1] == current_value && board[x+2][y+2] == current_value){ 179 | winner = current_value; 180 | break; 181 | } 182 | 183 | //Check opposite side of board 184 | current_value = board[x+2][y+2]; 185 | 186 | //x x x 187 | if(board[x+2][y+1] == current_value && board[x+2][y]){ 188 | winner = current_value; 189 | break; 190 | } 191 | 192 | if(board[x][y+2] == current_value && board[x+1][y+2] == current_value){ 193 | winner = current_value; 194 | break; 195 | } 196 | 197 | 198 | //Check middle row and be done 199 | current_value = board[x][y+1]; 200 | 201 | if(board[x+1][y+1] == current_value && board[x+2][y+1]){ 202 | winner = current_value; 203 | break; 204 | } 205 | 206 | 207 | checks++; 208 | } 209 | 210 | if(winner){ 211 | printf("Player %c wins!!!\n", winner); 212 | exit(1); 213 | } 214 | 215 | return(1); 216 | } 217 | -------------------------------------------------------------------------------- /C/triangle.c: -------------------------------------------------------------------------------- 1 | /* 2 | Author: NerdOfCode 3 | Purpose: Print a triangle that varies based on thee number of ROWS specified 4 | Compile Parameters: gcc -O -std=gnu17 triangle.c 5 | Updated: 2/2/19 6 | */ 7 | 8 | #include 9 | 10 | /* Let's build a triangle in C */ 11 | 12 | #define ROWS 15 13 | 14 | #define TRUE 1 15 | #define FALSE 0 16 | 17 | void print_triangle( void ){ 18 | 19 | typedef int bool; 20 | 21 | /* Number of stars to start the first row with */ 22 | int number_of_stars = 1; 23 | int difference = 1; 24 | 25 | bool on = TRUE; 26 | int number_of_spaces = 0; 27 | 28 | for(int row = 0; row <= ROWS ; row++){ 29 | while(number_of_stars > 0){ 30 | if(on){ 31 | /* Print the largest amount of spaces on the first row - and no spaces on the last row (row with largest amount of stars) */ 32 | for(int space = 0; space <= (ROWS - row); space++){ 33 | /* Print the space here */ 34 | printf(" "); 35 | } 36 | /* Only print spaces at the beginning of each row */ 37 | on = FALSE; 38 | } 39 | /* Print the star here */ 40 | printf("*"); 41 | /* We printed one star - next! */ 42 | --number_of_stars; 43 | } 44 | /* Calculate the number of stars in relation to the row and the difference between the number of stars to be printed */ 45 | number_of_stars = (row + 1) + (++difference); 46 | /* Prepare to print the next row */ 47 | on = TRUE; 48 | /* Add one space to calculate the offset of two more stars */ 49 | ++number_of_spaces; 50 | /* Output a newline to create the next row */ 51 | puts(""); 52 | } 53 | 54 | } 55 | 56 | int main( void ) { 57 | print_triangle(); 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /Elisp/isPrime.lisp: -------------------------------------------------------------------------------- 1 | ;; Check if a number is prime or not 2 | ;; Written in: elisp 3 | ;; Updated: 12/19/18 4 | 5 | (defun isPrime(numberToTest) 6 | "Check if a given number is prime or not!" 7 | (setq counter 2) 8 | (while (< counter numberToTest) 9 | (if (equal (% numberToTest counter) 0) 10 | (message "not prime: %d" numberToTest) 11 | (setq counter (+ counter 1)))) 12 | (message "prime: %d" numberToTest)) 13 | 14 | (isPrime 3301) 15 | -------------------------------------------------------------------------------- /GUI/arch_gui_upgrade.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | from tkinter import * 4 | import tkinter, os, sys 5 | 6 | #Try to support python2 and 3 7 | try: 8 | from Tkinter import * 9 | import Tkinter, os, sys 10 | 11 | except ImportError: 12 | from tkinter import * 13 | import tkinter, os, sys 14 | 15 | print("Warning: This script needs sudo access as it upates/upgrades your system via pacman") 16 | 17 | def runCheck(): 18 | 19 | os.system("sudo pacman -Syu") 20 | print("Updating") 21 | root.destroy() 22 | sys.exit(1) 23 | 24 | 25 | #Obviously used for exiting GUI and script! 26 | def exit(): 27 | root.destroy() 28 | sys.exit(1) 29 | 30 | 31 | #Default Button Value 32 | update = 0 33 | #Set root 34 | root = tkinter.Tk() 35 | 36 | #Window size 37 | root.minsize(300,150) 38 | #root.maxsize(750,750) 39 | 40 | #set title 41 | root.title("Arch-Linux Update/Upgrade") 42 | 43 | submit = tkinter.Button(root, text = "Update", command = runCheck) 44 | submit.place(relx=.4, rely=.4) 45 | 46 | cancel = tkinter.Button(root, text = "Cancel ", command = exit) 47 | cancel.place(relx=.4, rely=.6) 48 | 49 | root.mainloop() 50 | -------------------------------------------------------------------------------- /Go/README.md: -------------------------------------------------------------------------------- 1 | ## Installing Go 2 | For your convenience, I have created an `install_go.sh` script for you to easily install Go! Simply run `sudo ./install_go.sh` and it should install! I have currently only tested it on ***Arch*** Linux so it is possible for errors to arise... 3 | 4 | ## Notes 5 | 6 | All executables found within the `bin/x86_64` directory have been compiled on an x86_64 Arch Linux system! 7 | 8 | If you're to unfortunately find any issues, please simply create an issue and I will most likely fix the problem! 9 | -------------------------------------------------------------------------------- /Go/even_odd_finder.go: -------------------------------------------------------------------------------- 1 | /* 2 | Purpose: Finds even or odd numbers depending on Input 3 | */ 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | ) 10 | 11 | func even(limit int) { 12 | for i := 2; limit >= i; i += 2 { 13 | fmt.Println(i) 14 | } 15 | } 16 | 17 | func odd(limit int) { 18 | for i := 1; limit >= i; i += 2 { 19 | fmt.Println(i) 20 | } 21 | } 22 | 23 | func main() { 24 | var decision string 25 | var limit int 26 | 27 | fmt.Print("Would you like to find (e)ven or (o)dd numbers: ") 28 | fmt.Scanln(&decision) 29 | 30 | fmt.Print("Enter maximum limit: ") 31 | fmt.Scanln(&limit) 32 | 33 | switch decision { 34 | case "e": 35 | even(limit) 36 | case "o": 37 | odd(limit) 38 | default: 39 | fmt.Println("Unrecognized value...") 40 | main() 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Go/file_exists.go: -------------------------------------------------------------------------------- 1 | /* 2 | Purpose: Check whether a file exists or not... 3 | */ 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "io/ioutil" 10 | ) 11 | 12 | func file_check(filename string) bool { 13 | _, err := ioutil.ReadFile(filename) 14 | if err != nil { 15 | return false 16 | } else { 17 | return true 18 | } 19 | } 20 | 21 | func main() { 22 | var filename string 23 | 24 | fmt.Print("Enter filename: ") 25 | fmt.Scanln(&filename) 26 | 27 | fileExists := file_check(filename) 28 | 29 | if fileExists { 30 | fmt.Println("File exists!") 31 | } else { 32 | fmt.Println("File is non-existent!") 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Go/hash_input.go: -------------------------------------------------------------------------------- 1 | /* 2 | Author: NerdOfCode 3 | Purpose: Convert an inputted string into MD5 or SHA-1 hash 4 | */ 5 | 6 | package main 7 | 8 | import ( 9 | "bufio" 10 | "crypto/md5" 11 | "crypto/sha1" 12 | "crypto/sha256" 13 | "crypto/sha512" 14 | "fmt" 15 | "io" 16 | "os" 17 | ) 18 | 19 | func md5_hash(u_input string) { 20 | h := md5.New() 21 | 22 | io.WriteString(h, u_input) 23 | 24 | fmt.Printf("%x\n", h.Sum(nil)) 25 | } 26 | 27 | func sha1_hash(u_input string) { 28 | h := sha1.New() 29 | 30 | io.WriteString(h, u_input) 31 | 32 | fmt.Printf("%x\n", h.Sum(nil)) 33 | } 34 | 35 | func sha256_hash(u_input string) { 36 | h := sha256.New() 37 | 38 | io.WriteString(h, u_input) 39 | 40 | fmt.Printf("%x\n", h.Sum(nil)) 41 | } 42 | 43 | func sha512_hash(u_input string) { 44 | h := sha512.New() 45 | 46 | io.WriteString(h, u_input) 47 | 48 | fmt.Printf("%x\n", h.Sum(nil)) 49 | } 50 | 51 | func main() { 52 | var u_input string 53 | var decision string 54 | 55 | reader := bufio.NewReader(os.Stdin) 56 | 57 | fmt.Printf("Pick a hashing algorithm:\n") 58 | fmt.Printf("\t(1)MD5\n") 59 | fmt.Printf("\t(2)SHA-1\n") 60 | fmt.Printf("\t(3)SHA-256\n") 61 | fmt.Printf("\t(4)SHA-512\n") 62 | 63 | fmt.Print("Choice: ") 64 | fmt.Scanln(&decision) 65 | 66 | fmt.Print("Enter string: ") 67 | u_input, _ = reader.ReadString('\n') 68 | 69 | switch decision { 70 | case "1": 71 | md5_hash(u_input) 72 | case "2": 73 | sha1_hash(u_input) 74 | case "3": 75 | sha256_hash(u_input) 76 | case "4": 77 | sha512_hash(u_input) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Go/isPrime.go: -------------------------------------------------------------------------------- 1 | /* 2 | Purpose: Test if an inputted number is prime 3 | */ 4 | 5 | package main 6 | 7 | import "fmt" 8 | 9 | func isPrime(input int) bool { 10 | for divisor := 2; divisor <= input/2; divisor++ { 11 | if input%divisor == 0 { 12 | return false 13 | } 14 | } 15 | return true 16 | } 17 | 18 | func main() { 19 | var input int 20 | 21 | fmt.Print("Enter number: ") 22 | fmt.Scanln(&input) 23 | 24 | isPrime := isPrime(input) 25 | 26 | fmt.Printf("%d is Prime: %v\n", input, isPrime) 27 | } 28 | -------------------------------------------------------------------------------- /Go/read_file.go: -------------------------------------------------------------------------------- 1 | /* 2 | Purpose: To read a file through input and output it... 3 | */ 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "io/ioutil" 10 | ) 11 | 12 | func read_file(filename string) (string, bool) { 13 | file, err := ioutil.ReadFile(filename) 14 | if err != nil { 15 | fmt.Println(err) 16 | return "", true 17 | } 18 | 19 | return string(file), false 20 | } 21 | 22 | func main() { 23 | var filename string 24 | 25 | fmt.Print("Enter filename: ") 26 | fmt.Scanln(&filename) 27 | 28 | fileContents, err := read_file(filename) 29 | 30 | if !err { 31 | fmt.Println(fileContents) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /JavaScript/price_calc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
Enter weekly allowance  

4 | Enter money saved:      

5 | Enter desired cost:        

6 |
7 | 8 | 9 | 10 | 11 | 35 | -------------------------------------------------------------------------------- /JavaScript/prime_finder.html: -------------------------------------------------------------------------------- 1 | 2 | 24 | 25 |

26 | 47 | 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Lisp/fibonacci.lisp: -------------------------------------------------------------------------------- 1 | (defun fib () 2 | (defvar x 1) 3 | (defvar y 1) 4 | (defvar z (+ x y)) 5 | (loop 6 | (format t "~d~%~d~%~d~%" 7 | x y z) 8 | (setq x (+ y z)) 9 | (setq y (+ x z)) 10 | (setq z (+ x y)) 11 | )) 12 | 13 | (fib) 14 | -------------------------------------------------------------------------------- /Lisp/isPrime.lisp: -------------------------------------------------------------------------------- 1 | (defun isPrime (n) 2 | "Determine if n is a prime number or not" 3 | (if (<= n 2) 4 | (return-from isPrime nil)) 5 | (loop for x from 2 to (floor (SQRT n)) 6 | do 7 | (if (equal (mod n x) 0) 8 | (return-from isPrime nil))(return-from isPrime t))) 9 | 10 | (defvar n) 11 | (setq n 1) 12 | (if (isPrime n) 13 | (format t "Prime: ~d~%" 14 | n) 15 | (format t "Not Prime: ~d~%" 16 | n)) 17 | -------------------------------------------------------------------------------- /Lua/fibonacci.lua: -------------------------------------------------------------------------------- 1 | --The Fibonacci Sequence represented in Lua 2 | 3 | local x = 1 4 | local y = 1 5 | 6 | local count = 0 7 | 8 | io.write("Enter number of iterations: ") 9 | local limit=tonumber(io.read()) 10 | 11 | while count < limit do 12 | z = x + y 13 | x = y 14 | y = z 15 | print(z) 16 | count = count + 1 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Lua/print_rectangle.lua: -------------------------------------------------------------------------------- 1 | --Print a rectangle according to the user's input 2 | -- x --> The Length of the Rectangle per-se 3 | -- y --> The Width of the Rectangle I guess :<() 4 | 5 | local x = 5 6 | local y = 5 7 | 8 | if not (arg[1] == nil) then 9 | x=tonumber(arg[1]) 10 | y=tonumber(arg[2]) 11 | end 12 | 13 | for count = 0,x do 14 | io.write("*") 15 | end 16 | 17 | io.write("\n") 18 | 19 | for count = 0,y do 20 | io.write("*") 21 | for count = 0,x-2 do 22 | io.write(" ") 23 | end 24 | --Account for not adding the newline above 25 | io.write("*\n") 26 | end 27 | 28 | for count = 0,x do 29 | io.write("*") 30 | end 31 | io.write("\n") 32 | -------------------------------------------------------------------------------- /Lua/selection_sort.lua: -------------------------------------------------------------------------------- 1 | --Represent selection sort in Lua 2 | 3 | local unsorted_ints = {-30,5, 2, 3, 50, -240, 235, 80, -234, 454, 19,-1, 234} 4 | local sorted_ints ={} 5 | 6 | --used to get the lowest value in array for comparing 7 | function get_low() 8 | local lowest_value = unsorted_ints[1] 9 | local remove_element = 0 10 | for n = 1, #unsorted_ints do 11 | if not (unsorted_ints[n] > lowest_value) then 12 | lowest_value = unsorted_ints[n] 13 | remove_element = n 14 | end 15 | 16 | end 17 | table.remove(unsorted_ints,remove_element) 18 | table.insert(sorted_ints,lowest_value) 19 | return lowest_value 20 | end 21 | 22 | for n = 1, #unsorted_ints do 23 | get_low() 24 | end 25 | 26 | --Iterate and write through sorted table 27 | for n = 1,#sorted_ints do 28 | print(sorted_ints[n]) 29 | end 30 | -------------------------------------------------------------------------------- /PHP/isPrimeCounter.php: -------------------------------------------------------------------------------- 1 | 24 | -------------------------------------------------------------------------------- /PHP/prime_test.php: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | 5 | 31 | -------------------------------------------------------------------------------- /PHP/url_encode.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | Search: 5 |
6 | 7 | 8 | 9 | 20 | -------------------------------------------------------------------------------- /Python/Opposite_binary_input.py: -------------------------------------------------------------------------------- 1 | #Purpose: Enter a few binary characters 2 | #And the opposite will be outputted 3 | 4 | #Built using Python 3.x 5 | 6 | import sys 7 | 8 | u_input = input("Enter binary numbers(ex: 01000101): ") 9 | 10 | u_input = list(u_input) 11 | 12 | length = len(u_input) 13 | 14 | i = length 15 | 16 | while length > 0: 17 | 18 | try: 19 | 20 | if u_input[i-1] == "0": 21 | 22 | print("1",end='') 23 | i -= 1 24 | 25 | else: 26 | 27 | print("0",end='') 28 | i -= 1 29 | 30 | except IndexError: 31 | print("") 32 | sys.exit() 33 | 34 | 35 | 36 | try: 37 | u_input.pop() 38 | 39 | #print("Length: " + str(len(u_input))) 40 | 41 | except IndexError: 42 | 43 | sys.exit(-1) 44 | -------------------------------------------------------------------------------- /Python/binary_to_decimal.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | #Built using Python 3.x 4 | 5 | import sys 6 | 7 | 8 | debug = False 9 | 10 | bin = input("Enter binary: ") 11 | 12 | length = len(bin) 13 | bin_arr = list(bin) 14 | dec_place = 0 15 | math = 0 16 | total = 0 17 | a=-1 18 | 19 | while length > 0: 20 | 21 | #Reset 22 | math = 0 23 | first = 0 24 | 25 | first = bin_arr[a] 26 | 27 | exp = 2 ** dec_place 28 | 29 | math = int(first) * int(exp) 30 | 31 | 32 | total = int(math) + int(total) 33 | 34 | if debug: 35 | print("Total: {} For: {}".format(total,first)) 36 | print("At exponent: ", exp) 37 | 38 | 39 | dec_place = dec_place + 1 40 | 41 | length = length - 1 42 | 43 | a = a - 1 44 | 45 | print("Decimal: " + str(total)) 46 | -------------------------------------------------------------------------------- /Python/crack_md5.py: -------------------------------------------------------------------------------- 1 | #Crack MD5 hash from a password list 2 | #Note: Built using Python 3.x 3 | 4 | import hashlib, sys, os 5 | 6 | ###CHANGE THIS### 7 | #This is the list that this program will use to bruteforce with... 8 | pass_list="example.txt" 9 | 10 | 11 | if not os.path.exists(pass_list): 12 | print("Please provide a password list to use with bruteforce...") 13 | sys.exit(-1) 14 | 15 | 16 | target = input("Enter target MD5 hash: ") 17 | #Starting string 18 | current_str = "" 19 | line_number = 0 20 | total_interations = 0 21 | 22 | if current_str: 23 | h = hashlib.new("md5") 24 | h.update(current_str.encode()) 25 | print(h.hexdigest()) 26 | sys.exit(1) 27 | 28 | while True: 29 | h = hashlib.new("md5") 30 | h.update(current_str.encode()) 31 | if h.hexdigest() == target: 32 | print("Password: ",current_str) 33 | print("Attempts: ",total_interations) 34 | sys.exit(1) 35 | else: 36 | with open(pass_list) as file: 37 | lines = file.readlines() 38 | 39 | total_interations += 1 40 | try: 41 | current_str = lines[line_number].rstrip() 42 | line_number += 1 43 | except: 44 | line_number -= 1 45 | print("Could not find password... Consider using a more precise password list") 46 | print("Tried: ", total_interations-1, "passwords...") 47 | sys.exit(1) 48 | -------------------------------------------------------------------------------- /Python/fibonacci.py: -------------------------------------------------------------------------------- 1 | def fib(): 2 | x = 1 3 | y = 1 4 | z = 2 5 | 6 | while True: 7 | print("%i\n%i\n%i" % (x, y, z)) 8 | x = y + z 9 | y = x + z 10 | z = x + y 11 | 12 | fib() 13 | -------------------------------------------------------------------------------- /Python/fortune_teller.py: -------------------------------------------------------------------------------- 1 | #Author: NerdOfCode 2 | from random import randint 3 | 4 | fortune=[ 5 | "You're a noob","Just no", 6 | "no","yes","maybe","great", 7 | "Sure...","I'm not sure", "Think again" 8 | ] 9 | 10 | #Put max_fortune as one less than actual 11 | #Thanks to arrays starting at 0 12 | max_fortune=len(fortune)-1 13 | 14 | random=randint(0,max_fortune) 15 | 16 | input = raw_input("Enter your tale: ") 17 | 18 | print(fortune[random]) 19 | -------------------------------------------------------------------------------- /Python/functions/get_args.py: -------------------------------------------------------------------------------- 1 | #Author: NerdOfCode 2 | #Tested on Ubuntu Server 17.04 3 | #Python v--> Works on latest 3.x version 4 | 5 | #Documentation: I recommend importing this file then calling function 6 | #get_args into a variable then print the value of that variable 7 | 8 | import sys, os 9 | 10 | #For filesake purposes 11 | 12 | ###################### 13 | max_arg=10 # 14 | arguements=[] # 15 | ###################### 16 | 17 | 18 | #print(sys.argv[1]) 19 | 20 | def get_args(): 21 | length=len(sys.argv) 22 | if length > max_arg: 23 | return "Too many arguements... Goodbye" 24 | sys.exit(1) 25 | 26 | for argu in range(length): 27 | arguements.append(sys.argv[argu]) 28 | if sys.argv[0]: 29 | del arguements[0] 30 | 31 | return arguements 32 | 33 | #Example of call and printing args 34 | values=get_args() 35 | print(values) 36 | -------------------------------------------------------------------------------- /Python/functions/save_user_details.py: -------------------------------------------------------------------------------- 1 | 2 | #Author: NerdOfCode 3 | #Purpose: A function that saves important user details to a file 4 | #Tested: Ubuntu 17.04 5 | #Python V: 2.x 6 | 7 | #How to use: 8 | #Import first by using import "save_user_details.py" 9 | #Ex call Function: 10 | #user_creds_save("nate",1500,"nate.txt") 11 | 12 | 13 | import sys, os 14 | 15 | #Fname --> File name to store creds to 16 | def user_creds_save(name,score,fname): 17 | #print "User is %s and their score is %i" % (name, score) 18 | 19 | #Check if file already exists 20 | if os.path.isfile(fname): 21 | #open file and spill contents 22 | file = open(fname, "r") 23 | for line in file: 24 | if name in line: 25 | name=line 26 | #print name 27 | elif score in line: 28 | score=line 29 | #print score 30 | elif fname in line: 31 | fname=line 32 | #print fname 33 | if name and score and fname: 34 | return (name, score, fname) 35 | else: 36 | file = open(fname, "w") 37 | file.write("Name: %s\n" % name) 38 | file.write("Score: %s\n" % score) 39 | #IFN --> Intended File Name 40 | file.write("IFN: %s\n" % fname) 41 | file.close() 42 | 43 | 44 | #Ex call Function: 45 | func = user_creds_save("NerdOfCode","1500","NerdOfCode.txt") 46 | -------------------------------------------------------------------------------- /Python/hex_to_decimal.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import sys 3 | #Built using Python 3.x 4 | 5 | 6 | #Exit status of 1 means success 7 | 8 | #Variables you should tamper with below 9 | debug = False 10 | 11 | 12 | #Define Possible Amounts 13 | reg_amounts=['1','2','3','4','5','6','7','8','9'] 14 | amounts=['A','10','B','11','C','12','D','13','E','14','F','15'] 15 | 16 | def single_input(hex): 17 | 18 | i=0 19 | 20 | while len(amounts) > 5: 21 | 22 | if hex == amounts[i]: 23 | print(amounts[i+1]) 24 | 25 | elif hex == reg_amounts[i]: 26 | print(reg_amounts[i]) 27 | 28 | if i < 5: 29 | i = i + 1 30 | 31 | 32 | 33 | 34 | 35 | amounts.pop(0) 36 | 37 | def everything_else(hex, char_arr): 38 | 39 | a=-1 40 | i=0 41 | dec_place = 0 42 | math = 0 43 | total = 0 44 | Error_Count = 0 45 | 46 | length = len(hex) 47 | length2 = -len(hex) 48 | 49 | while i <= 12 and a - 1 < length: 50 | 51 | 52 | try: 53 | 54 | if char_arr[a] == reg_amounts[i]: 55 | 56 | 57 | math = int(char_arr[a]) * 16 ** dec_place 58 | total = math + total 59 | a = a - 1 60 | i = -1 61 | dec_place = dec_place + 1 62 | 63 | if char_arr[a] == amounts[i] or char_arr[a] == "F": 64 | 65 | #Because Trying to pull F brings index errors, I'm going 66 | #To take the easy way out and manually set it 67 | 68 | if char_arr[a] == "F": 69 | char_arr[a]=15 70 | i = 12 71 | 72 | 73 | #Laziness always creates more work... But it's easy work :) 74 | if i != 12: 75 | get_actual_value = int(amounts[i+1]) 76 | else: 77 | get_actual_value = 15 78 | 79 | math = get_actual_value * 16 ** dec_place 80 | total = math + total 81 | dec_place = dec_place + 1 82 | i = -1 83 | a = a - 1 84 | 85 | 86 | except IndexError: 87 | 88 | Error_Count = Error_Count + 1 89 | if debug == True: 90 | print("IndexError") 91 | 92 | i = i + 1 93 | 94 | print("Decimal: " + str(total)) 95 | 96 | hex = str(input("Enter Hex Number(s): ")) 97 | 98 | 99 | 100 | length = len(hex) 101 | 102 | char_arr = list(hex) 103 | 104 | if length <= 1: 105 | single_input(hex) 106 | sys.exit(1) 107 | 108 | everything_else(hex, char_arr) 109 | -------------------------------------------------------------------------------- /Python/isPrime.py: -------------------------------------------------------------------------------- 1 | #Important: Built using Python 3.x 2 | 3 | import sys 4 | 5 | def isPrime(number, div): 6 | 7 | while True: 8 | 9 | if number % div != 0 and div <= number/2: 10 | div+=1 11 | 12 | elif number % div != 0: 13 | print("Prime: ", number) 14 | sys.exit(0) 15 | 16 | else: 17 | print("Not prime: ", number) 18 | print("Divisible by: ", div) 19 | 20 | #Send it in for another round 21 | 22 | if div == 2 or div == 4 or div == 5: 23 | div+=1 24 | isPrime(number, div) 25 | sys.exit(0) 26 | 27 | number = int(input("Enter number: ")) 28 | 29 | div = 2 30 | 31 | isPrime(number, div) 32 | -------------------------------------------------------------------------------- /Python/neural_flower.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | #0 = orange || 1 = white 4 | #white + white = white 5 | #White + orange = orange 6 | #orange + orange = orange 7 | 8 | #x=0 9 | #y=1 10 | 11 | print "(0 for orange and 1 for white)" 12 | x=int(raw_input("Enter flower 1: ")) 13 | y=int(raw_input("Enter flower 2: ")) 14 | 15 | w1=1 16 | w2=1 17 | 18 | desired_output=0 19 | 20 | new = (x * w1) + (y * w2) 21 | 22 | newer = 1/(1 + math.exp(-new)) 23 | 24 | error = desired_output - newer 25 | 26 | 27 | print "Output: " + str(newer) 28 | 29 | print "Error: " + str(error) 30 | 31 | 32 | if newer > .75: 33 | print "White flower predicted" 34 | else: 35 | print "Orange flower predicted" 36 | -------------------------------------------------------------------------------- /Python/octal_to_dec.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | #Built using python 3.x 4 | 5 | debug = False 6 | 7 | octal = input("Enter octal input: ") 8 | 9 | length = len(octal) 10 | 11 | octal_arr = list(octal) 12 | 13 | exp_place = 0 14 | 15 | math = 0 16 | 17 | total = 0 18 | 19 | a=-1 20 | 21 | while length > 0: 22 | 23 | first_numb = octal_arr[a] 24 | 25 | exp = 8 ** exp_place 26 | 27 | math = int(first_numb) * int(exp) 28 | 29 | total = math + total 30 | 31 | exp_place = exp_place + 1 32 | 33 | a = a -1 34 | 35 | length = length - 1 36 | 37 | if debug: 38 | print("Total: {}, For {}".format(total, first_numb)) 39 | 40 | print("Decimal: ", str(total)) 41 | -------------------------------------------------------------------------------- /Python/password_manager.py: -------------------------------------------------------------------------------- 1 | import sqlite3, sys 2 | 3 | connection = sqlite3.connect("passwords.db") 4 | cursor = connection.cursor() 5 | 6 | def query(): 7 | new_password=input("Enter new password: ") 8 | new_id=input("Enter id for password: ") 9 | print("Response: ",response) 10 | try: 11 | cursor.execute("INSERT INTO passwords VALUES (?, ?);",(new_id,new_password)) 12 | 13 | except sqlite3.Error as er: 14 | print("An error has occured %s" % er) 15 | 16 | 17 | try: 18 | commands = """ 19 | CREATE TABLE passwords(id INT AUTO_INCREMENT, password VARCHAR(30)); 20 | """ 21 | cursor.execute(commands) 22 | except sqlite3.Error as er: 23 | print("table already exists") 24 | commands = """ 25 | SELECT * FROM passwords; 26 | """ 27 | cursor.execute(commands) 28 | 29 | commands = """ 30 | SELECT * FROM passwords; 31 | """ 32 | cursor.execute(commands) 33 | while True: 34 | print("Would you like to view (p)asswords,(a)dd one, or (e)xit?") 35 | response=input("Response: ") 36 | print("Response: ",response) 37 | if response == "a": 38 | query() 39 | elif response == "p": 40 | cursor.execute("SELECT * FROM passwords") 41 | print("fetchall:") 42 | result = cursor.fetchall() 43 | for r in result: 44 | print(r) 45 | elif response == "exit": 46 | sys.exit(0) 47 | else: 48 | print("Not recognized...") 49 | 50 | 51 | connection.commit() 52 | connection.close() 53 | -------------------------------------------------------------------------------- /Python/password_manager_info.txt: -------------------------------------------------------------------------------- 1 | Please note that the 'password_manager.py' file does not securely contain passwords and it should not be used to store sensitive infomation 2 | -------------------------------------------------------------------------------- /Python/prime_gen.py: -------------------------------------------------------------------------------- 1 | #Important: Built using Python 3.x 2 | 3 | import sys 4 | 5 | sys.setrecursionlimit(999999) 6 | 7 | def isPrime(number, div, count, limit): 8 | 9 | while True: 10 | 11 | if count >= limit: 12 | print("I'm ready to burst...") 13 | sys.exit(1) 14 | 15 | if number % div != 0 and div <= number/2: 16 | div+=1 17 | 18 | elif number % div != 0: 19 | print("Prime: ", number) 20 | number += 1 21 | div = 2 22 | count += 1 23 | isPrime(number,div, count, limit) 24 | 25 | else: 26 | number += 1 27 | div = 2 28 | count += 1 29 | isPrime(number, div, count, limit) 30 | 31 | 32 | 33 | 34 | number = 2 35 | div = 2 36 | count = 0 37 | limit=15000 38 | 39 | isPrime(number, div, count, limit) 40 | -------------------------------------------------------------------------------- /Python/quick_hash3.py: -------------------------------------------------------------------------------- 1 | ################### 2 | #WARNING: This program is not suitable for actually hashing passwords 3 | #In a commericial environment as it uses weak hashing algorithms... 4 | #Even with salts... 5 | #Uses Python 3.x+ 6 | ################## 7 | 8 | import sys 9 | 10 | try: 11 | from crypt import * 12 | except: 13 | print("I do not believe your system has the crypt module") 14 | sys.exit(1) 15 | 16 | message = "" 17 | specified_salt = "" 18 | 19 | if len(sys.argv) > 2: 20 | message = sys.argv[1] 21 | specified_salt = sys.argv[2] 22 | 23 | if not message or not specified_salt: 24 | 25 | message = input("Enter message: ") 26 | specified_salt = input("Please enter salt(More than 2 char at least): "); 27 | 28 | password = crypt(message, specified_salt) 29 | 30 | print(password) 31 | -------------------------------------------------------------------------------- /Python/tic-tac-toe.py: -------------------------------------------------------------------------------- 1 | ################################################3 2 | #In extremely early stages... There is no win checking 3 | ###############################################4 4 | 5 | import sys 6 | from pprint import pprint 7 | 8 | def init(): 9 | global row1 10 | global row2 11 | global row3 12 | row1 = [0, 0, 0] 13 | row2 = [0, 0, 0] 14 | row3 = [0, 0, 0] 15 | pprint(row1) 16 | pprint(row2) 17 | pprint(row3) 18 | 19 | def current_game(): 20 | pprint(row1) 21 | pprint(row2) 22 | pprint(row3) 23 | 24 | def move(): 25 | global count 26 | count = 0 27 | 28 | if count == "0": 29 | turn = user 30 | count += 1 31 | first_play == False 32 | elif first_play == False or count != "0": 33 | turn = user2 34 | count == 1 35 | 36 | new_move = input("Enter move(ex: 1,3): ") 37 | new_move = new_move.split(",") 38 | row = new_move[0] 39 | column = int(new_move[1]) 40 | 41 | #Gurantee no extra whitespaces 42 | row = row.replace(" ", "") 43 | int(row) 44 | 45 | if row == "1": 46 | row1[column] = turn 47 | elif row == "2": 48 | row2[column] = turn 49 | elif row == "3": 50 | row3[column] = turn 51 | else: 52 | print("Unrecognized input...") 53 | 54 | print("This script is not working... I suggest using the one I built in C...") 55 | 56 | print("Only two player mode is currently available...") 57 | init() 58 | 59 | print("Enter user one's character(ex: 'x'): ") 60 | user = input() 61 | 62 | print("Enter user two's character(ex: o): ") 63 | user2 = input() 64 | 65 | #For player switching technique 66 | first_play = True 67 | 68 | while True: 69 | move() 70 | current_game() 71 | 72 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Scripts 2 | This repository is for scripts that I feel are useful... 3 | 4 | # To download all scripts, simply run: 5 | 6 | 7 | ```GIT 8 | git clone git@github.com:NerdOfCode/Scripts.git 9 | ``` 10 | 11 | After running this command you will have full access to all my scripts! 12 | If you want to compile some of my scripts(Ex: C), I recommend using `gcc`... 13 | 14 |
    15 |
  • These scripts were built on glorius Linux platforms... Except for the one CS script...
  • 16 |
17 | -------------------------------------------------------------------------------- /Ruby/Input.rb: -------------------------------------------------------------------------------- 1 | =begin 2 | This Input class was designed to ease the use of interacting with user input 3 | Methods: 4 | public: 5 | 1. get_int_input() => Get integer input and return it 6 | Note : Repeatedly prompts to enter number until valid number is entered 7 | Returns: integer 8 | private: 9 | 1. is_number() => Determine if argument is integer 10 | Returns: Boolean 11 | =end 12 | 13 | class Input 14 | def initialize(show_prompts: false, repeat_prompts: true) 15 | @show_prompts = show_prompts 16 | @repeat_prompts = repeat_prompts 17 | end 18 | 19 | def get_int_args 20 | number_args = [] 21 | for arg in ARGV 22 | if is_number(arg) 23 | number_args.push(arg.to_i) 24 | end 25 | end 26 | return number_args 27 | end 28 | 29 | def get_int_input 30 | loop do 31 | numbers = [] 32 | if @show_prompts 33 | print "Enter number: " 34 | end 35 | u_number = (STDIN.gets.chomp).split(" ") 36 | u_number.each do |x| 37 | if is_number(x) 38 | numbers.push(x.to_i) 39 | else 40 | puts "Enter an integer." 41 | end 42 | end 43 | if !@repeat_prompts 44 | break 45 | end 46 | return numbers 47 | end 48 | end 49 | 50 | 51 | private 52 | def is_number(number) 53 | int_number = Integer(number) rescue false 54 | return number.to_i == int_number 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /Ruby/prime.rb: -------------------------------------------------------------------------------- 1 | # Check if a given number is prime 2 | 3 | require_relative "Input.rb" 4 | 5 | def is_prime(number) 6 | for factor in 2..number/2 7 | if number % factor == 0 8 | return false 9 | end 10 | end 11 | return true 12 | end 13 | 14 | input = Input.new(show_prompts: true, repeat_prompts: true) 15 | if input.get_int_args.length > 0 16 | input.get_int_args.each do |x| 17 | puts "isPrime(#{x}): #{is_prime(x)}" 18 | end 19 | else 20 | input.get_int_input.each do |x| 21 | puts "isPrime(#{x}): #{is_prime(x)}" 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /Swift/bubbleSort.swift: -------------------------------------------------------------------------------- 1 | let unsortedIntegers = [5, 1, 4, 2, 8, 100] 2 | 3 | class Sort { 4 | var sortedIntegers : [Int] = unsortedIntegers 5 | 6 | func swap(Arr : inout [Int], xCoord : Int, yCoord : Int) { 7 | let originalX = Arr[xCoord] 8 | Arr[xCoord] = Arr[yCoord] 9 | Arr[yCoord] = originalX 10 | } 11 | 12 | /* Bubblesort implementation */ 13 | func bubbleSort(Arr: [Int]) { 14 | var pass = 0 15 | var swaps = 0 16 | var totalSwaps = 0 17 | 18 | print("Pass: \(pass), Swaps: \(swaps)/\(totalSwaps), Array: \(sortedIntegers)") 19 | 20 | repeat { 21 | /* Reset swaps and increment pass in order to prepare for upcoming pass */ 22 | swaps = 0 23 | pass += 1 24 | for index in 0 ..< sortedIntegers.count - 1 { 25 | if(sortedIntegers[index] > sortedIntegers[index + 1]) { 26 | swap(Arr : &sortedIntegers, xCoord : index, yCoord : index + 1) 27 | swaps += 1 28 | totalSwaps += 1 29 | } 30 | } 31 | print("Pass: \(pass), Swaps: \(swaps)/\(totalSwaps), Array: \(sortedIntegers)") 32 | } while (swaps != 0) 33 | } 34 | } 35 | 36 | /* Instantiate sort class */ 37 | var sort = Sort() 38 | 39 | /* Invoke bubbleSort method */ 40 | sort.bubbleSort(Arr: sort.sortedIntegers) 41 | 42 | -------------------------------------------------------------------------------- /Swift/checkPrime.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /* 4 | 5 | Purpose: Test whether a number is prime or not... 6 | Note: If no number is supplied, a random number will be generated. 7 | Updated: 12/18/18 8 | 9 | */ 10 | 11 | 12 | func isPrime(n : Int) -> Bool { 13 | guard n > 4 else { fatalError("Error: isPrime(n : Int) --> n ! <= 4 ") } 14 | 15 | for x in 2 ... n/2 { 16 | if n % x == 0 { 17 | return false 18 | } 19 | } 20 | return true 21 | } 22 | 23 | print("Test prime numbers...") 24 | print("Enter Number: ", terminator:"") 25 | 26 | let numberToTest = (Int(readLine()!) ?? Int.random(in: 0 ... 99999)) 27 | 28 | print("The number \(numberToTest) is \(isPrime(n:numberToTest) ? "Prime" : "Not Prime")") 29 | -------------------------------------------------------------------------------- /Swift/fibonacci.swift: -------------------------------------------------------------------------------- 1 | // Fibonacci number sequence represented in Swift 2 | 3 | func fibonacci( _ upperBound : UInt32? = nil ) { 4 | if let upperBound = upperBound { 5 | var x = 1 6 | var y = 1 7 | var z = 2 8 | 9 | while z <= upperBound { 10 | print(x) 11 | x = y 12 | y = z 13 | z = x + y 14 | } 15 | 16 | } else { 17 | print("Please specify upperbound limit! ") 18 | } 19 | } 20 | 21 | fibonacci( 999 ) 22 | -------------------------------------------------------------------------------- /Swift/genPrime.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /* 4 | Purpose: Display a bunch of prime numbers using a recursive method 5 | Note: If no "upperBound" limit is entered. The upperBound will be -> 999 6 | */ 7 | 8 | // func primeList 9 | // Params: 10 | // n => Starting nth digit 11 | // upperBound => Ending nth digit 12 | 13 | func primeList(n: Int, upperBound: Int) { 14 | guard n > 4 else { return primeList(n: n+1, upperBound: upperBound) } 15 | guard n < upperBound else { return } 16 | 17 | for i in 2 ... n/2 { 18 | if n % i == 0 { 19 | return primeList(n: n+1, upperBound: upperBound) 20 | } 21 | } 22 | print("Prime: ", n) 23 | return primeList(n: n+1, upperBound: upperBound) 24 | } 25 | 26 | print("Output prime numbers until nth term...") 27 | print("Enter upper bound limit: ", terminator: "") 28 | 29 | if let upperBound = Int(readLine()!) { 30 | primeList(n: 0, upperBound: upperBound) 31 | } else { 32 | print("Unknown upperBound value") 33 | } 34 | -------------------------------------------------------------------------------- /Swift/sieve-prime.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | //For user input 3 | print("Please enter a number: ") 4 | //Get user input. Unwrap using ! 5 | var userinput: String = readLine()! 6 | //Change userinput to a integer 7 | var change = Int("\(userinput)") 8 | var n: Int = change! 9 | var guess = 1 10 | while(true){ 11 | //If n is disvisble by guess and is not equal to guess and is not 1 12 | if(n % guess == 0) && (n != guess) && (guess != 1){ 13 | //Not prime numbers 14 | //Move on to the next lower number 15 | n=n-1 16 | guess=1 17 | //If n is equal to guess and n is not 1 18 | }else if(n == guess) && (n != 1){ 19 | print("Prime: \(n)") 20 | //Move on to next lower number 21 | n=n-1 22 | //Reset guess 23 | guess=1 24 | //For some reason 2 never shows. Add it manually for now 25 | }else if(n == 2){ 26 | print("Thats about it. Ooops, forgot 2") 27 | exit(0) 28 | }else{ 29 | //No matches, Add one to guess 30 | guess+=1 31 | } 32 | 33 | } 34 | --------------------------------------------------------------------------------