This is honestly not that bad. Maybe even faster than a more pythonic solution because it's utilizing the underlying C of the find method
Edit: the only thing I might do different is writing it as a generator so I don't have the overhead of calling append every time.
Edit 2:
def rough_split(text, size=1000): begin = end = 0 while end >= 0: end = text.find('.', begin+size)
if end == -1: end = text.find(' ', begin+size)
block = slice(begin, end if end != -1 else None) yield text[block] begin = end
list(rough_split(text))
This resulted in an average of 40% increased performance https://hastebin.com/exeveciqay.py
Also, forget sharing something if your project is reasonably complicated- literally everyone will start complaining about how it doesn't run on their extremely weak and slow school-loaned chromebook (speaking from experience...).
Scratch is fun and all, but you have to keep in mind that like 95% of the community is <13, and it's probably better to move on once you've gotten past that...
Side note, the <i>
and <b>
tags are not deprecated in html5, only in (long long dead) xhtml2.
See http://www.w3.org/TR/html5/obsolete.html (which notable does not contain <i>
) vs http://www.w3.org/TR/html5/text-level-semantics.html#the-i-element (which calls it out specifically as a supported tag).
Yeah I know, but it's generally good coding practice to include them. We also follow eslint rules who also recommend to include them (https://eslint.org/docs/rules/curly)
>Community Edition is open-source, licensed under Apache 2.0. Projects like Android and Swift use Apache 2.0, so you`re in good company. It can also be used for commercial development.
Please do not write it as "LUA", which is both ugly and confusing, because then it becomes an acronym with different meanings for different people. So, please, write "Lua" right!
It's possible to shutdown a machine using Java using code almost identical to what is posted. The simplest implementation for Windows basically boils down to Runtime.getRuntime().exec("shutdown -s -t 0");
(note that it might require elevated privileges for your program).
Here’s the list: https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git
You can also install the oh-my-zsh plugin called “you-should-use” which will remind you of a shortcut every time you type a command which already has an alias
http://php.net/manual/en/function.uniqid.php
> Warning This function does not create random nor unpredictable strings. This function must not be used for security purposes. Use a cryptographically secure random function/generator and cryptographically secure hash functions to create unpredictable secure IDs.
I want production builds to be done with the exact same version of a dependency that was previously used for testing. I don't want the risk of a new version, however minor the change, breaking something.
Nor do I want the risk of "oh no, we can't pull the dependencies because github is down, we can't deploy this one-line bugfix we made". That's the sort of thing that will screw you over at the worst possible moment.
I'm glad we can agree!
Here's the website of this POS : https://unicenta.com/
> In 2010, we set out to build a powerful, commercial-grade and open source Point Of Sale to help as many SME’s as we could. > > It went viral. > > We broke the mold.
Honestly it's not that bad. If you are looking to refactor it I would recommend taking a look at date-fns. The Date
object in JS is actually not that bad, but it's interface is a bit low level and pretty cumbersome to use, especially for formatting (as shown in your code). date-fns
is a collection of mostly wrappers around the Date object to make it easier to use, it is also really friendly for tree-shaking so its pretty light-weight in practice.
Here is my take on this code (using date-fns):
import { format } from 'date-fns'
const byId = id => document.getElementById(id)
function numberedTime(now = new Date()) { byId('time').textContent = format(now, 'HH:mm:ss:SSS') byId('date').textContent = format(now, 'dd/MM/yyyy') }
function labeledTime(now = new Date()) { byId('label').textContent = format(now, "'It is' EEEE, 'the' do 'of' MMMM") }
const waitForAnimationFrame = () => new Promise((resolve) => window.requestAnimationFrame(resolve))
const startUpdating = async () => { while (true) { // doesn't actually block the main thread because it contains an await await waitForAnimationFrame() // Update every frame instead of every millisecond numberedTime() labeledTime() } }
startUpdating()
byId('back').addEventListener('click', () => { // .assign() is easier to mock than .href, also more consistent with .replace() window.location.assign('../index.html') })
Often times these situations can be resolved with refactoring. I will say though, in C gotos are acceptable for cleaning up resources after hitting an error case. However, that's mainly because C doesn't have exceptions or a concept of RAII. I don't have your code so I can't suggest how to refactor it, but resources such as Clean Code by Uncle Bob and Refactoring by Martin Fowler are incredibly valuable for this kind of stuff.
Well, First off those if-else statements can be removed. There is no need for that since momentJS has .diff method to compare dates, so essentially you could say:
diffDate = startDate.diff(enddate)
do a switch/case and viola cleaner, less code.
This is just top of my head but: https://momentjs.com/docs/#/use-it/ Is super well documented!
Yep. Proof. And yes, you'll note that I actually do have a bitcoin address on there. Just because I think it's stupid doesn't mean I mind it when people give me bitcoins.
If the passwords are cleartext, it suggests that they don't have a proper DBA - the dev is a full stack engineer.
Given that, it probably suggests that their db credentials are 'sa' with no password. And that db is directly connected to the Internet and searchable on shodan.io.
Most likely syntax specific to this particular framework? A quick Google search turned up YiiFramework
I wouldn't be surprised if the junior just wasn't aware of the capabilities/nuances of the API.
Most people use Webpack with React, but it's not correct that "React uses Webpack" for its build system - e.g. no sign of Webpack here https://github.com/facebook/react (double-check the package.json
if you like and notice it's not a devDependency)
You can easily use React without Webpack (or Babel, etc) by adding React and ReactDOM with a script tag and writing code without JSX (and in ES5 style, too, if you want to be really conservative)
You can use Webpack with any JavaScript project you like - or not.
Here is scratch. Looks nifty, illustrating indentation with overlapped color like that.
I had my son to code Roblox, he did not want to do it anymore. I’ll try again with colorful interface like this.
I suspect this may have todo with a windows limitation. windows has the fantastically obnoxious limitation that if your path variable gets too long it randomly ignores chunks of it.
http://superuser.com/questions/635082/too-many-folders-in-the-path-variable
You can pass <code>--allow-empty-message</code> to allow it (although you also have to pass the empty string as a message to prevent an editor from opening).
Ah it was an error on my part
Original: 45.434639352999994 u/ROFLicious: 26.921889883 u/zer0897: 11.752597479
After fixing it, here is the end result. The original is slowest because it copies the string every time it loops. I didn't catch that, yours ended up being faster after all.
The changes I made to it eliminated the copying and appending overhead, so it ended up being the fastest
This is the revised test https://hastebin.com/exeveciqay.py
if you want to run it yourself https://repl.it/repls/DefiniteStainedPatches
These guys know what they're talking about. And they're not just trying to look cool -- there's a very important reason to not do what you're doing.
If you concatenate your query strings with untrusted input, you're pretty much guaranteed to be vulnerable to SQL injection.
Looks like you're using PHP. Use mysqli's prepare() function to create the query without any external data in your query string.
You have to enable it through experimentalDecorators: https://www.typescriptlang.org/docs/handbook/decorators.html
it's off by default because it isn't finalized yet for normal javascript.
the original old k&r syntax looks a lot like this (and i believe is still accepted)
int functionname(arg1, arg2, arg3); char arg2; double arg3; { / body goes here */ }
https://stackoverflow.com/questions/3092006/function-declaration-kr-vs-ansi
http://php.net/manual/en/function.uniqid.php
> Warning This function does not create random nor unpredictable strings. This function must not be used for security purposes. Use a cryptographically secure random function/generator and cryptographically secure hash functions to create unpredictable secure IDs.
Not necessarily; the C standard merely says it is "undefined behavior".
What is undefined behavior?
> The classic apocryphal example of "undefined behavior" is, of course, "nasal demons".... > > ... > > If your host system has hardware support in the form of connection to probes that are inserted in your nostrils, it is within the realms of possibility that an occurrence of undefined behaviour will cause undesired nasal effects.
So yes, it might still technically work, but it is not required to, and it is also not required to be consistent even in the same process.
I think you're overestimating how heavy they are, and underestimating how heavy everything else is. Your performance isn't even close. Yours takes ~24x as long.
Why do you think find() is going to be a bigger bottleneck than split? They're doing the same work. Further, strings are immutable in Python. Every single time you append another sentence
to block
, you are creating a new string. You're making what should be a linear algorithm into quadratic time.
Did you try using a prepared statement with parameters? http://php.net/manual/en/mysqli.prepare.php
addslashes sucks and you shouldn't use that.
mysqli_real_escape_string should work, so it's odd that it doesn't. I'm not sure how it works. I know it requires a DB connection, so I don't know if the work happens on the client or the server.
I realize you solved your issue, but like /u/BraveNewWhorled said, you should be used parameterized queries, and not the home-rolled kind, so prepared statements are the way to go. If a prepared statement doesn't work, I'd really like to see it, as it would be really important to me to know.
I joke about the commit messages, but in the end the important thing is getting your work in source control in an efficient ~~manor~~manner. It's good to build good commit habits because a clean history makes for an easy to read history.
Some things to keep in mind:
* Smaller commits means you have less to describe
* Use present-tense verbs to describe your commits
* Think of your commits as "actions" that modify the codebase
Some rough examples:
> Add signup button to login view
> Replace username regex with
> Build user dashboard as login landing page
Keep in mind a commit contains two major parts, the "title" and a body. The title is the first line. Anything beyond that is a body. If you feel your commit title doesn't best describe the amount of work in the commit, you can elaborate in the body.
These are just my personal suggestions. Many teams and people use git in different workflows. I tend to like my history a little more verbose than others, so I commit pretty frequently and my commits end up being atomic changes to the code base. When I work with a group or others who prefer a cleaner history, I squash my commits into a single change and drop the original commit's messages into the description of the resulting commit and summarize in the first line.
Commit messages are just another form of communication, so don't feel too much pressure from it. Find something that works for you/your team and stick to it. If you haven't already, I can't recommend the git book enough. Certainly helped me out.
Hope that long rant is helpful, haha.
You probably could; look into a PortableApps.com environment. Cygwin has been built for it, so you can set it up at home and get your dev env set up that way.
File system errors are often between "normal" and "exceptional". E.g. boost::filesystem now offers both exception handling and error codes for its API.
You could perhaps try DBeaver's diagram generation tool? Looks like this
It probably won't handle generating a diagram of this scale but it's worth a shot. No idea if it's possible to export the diagram as a vector file or not.
And yes, all of our tables have their own integer, db incremented, PK's. Even the many to many linker tables. yes.
That's fair, but not all GUIs take time to load (i.e. 100ms), not all GUIs require a mouse, and obviously familiarity is because you've taken the time to get used to the CLI instead of a visual interface.
Why not give it a shot? Here are popular GUIs, I recommend GitKraken (this does take 5s to load so you can leave it open) or Sublime Merge, or using the built-in git functionality if you're using VSCode or JetBrains.
Or for a great middle ground, check out this TUI https://github.com/jesseduffield/lazygit
It's pretty much stated in every tech site, that's how I learnt.. btw I read couple minutes ago that they pushed a fix yesterday. So maybe thats what your Mac downloaded and installed without you knowing or even have a chance to object
Edit here's the link http://osxdaily.com/2017/10/05/macos-high-sierra-supplemental-update-released/
https://www.kernel.org/doc/html/v4.10/process/coding-style.html#commenting
>Comments are good, but there is also a danger of over-commenting.
>The new char[n] declares a char array with a length of n. Apparently you can give a String a char array as parameter. Replace replaces a String with another. "\0" is the code for the null char which each element of an array was initialized with.
This is a semi-standard technique in Java. It's the shortest way to repeat a string: https://stackoverflow.com/a/4903603
> To all who say "Git is perfect"
Well, git is certainly not perfect; I don't think most people think it is. It certainly has its issues, but usually it's good enough.
> just look at the Git related questions online.
This doesn't have to necessarily mean anything. Git is extremely popular, and for every very popular technology you can find tons of people looking for help. Since git usage is growing and SVN usage is going down we can assume that most of those people are learning git, which is bound to always generate some questions. Looking at stackoverflow's most popular tags:
> git × 72561, 35 asked today, 340 this week
> svn × 23540, 43 asked this week, 186 this month
Git is getting ~7 times more questions than svn, which is significant, but it's not that huge of a difference.
If you look at the very top you can see:
> javascript × 1159999, 836 asked today, 6375 this week
> c++ × 456842, 252 asked today, 1727 this week
JavaScript is getting ~3.6 times more questions than C++, but does that mean that JavaScript is more complex than C++? No. Everyone who knows those two languages can tell you that C++ is a few orders of magnitude times more complicated than JavaScript. The only other explanation would be - huge popularity of JavaScript.
> and supposing that […] the generator is perfectly random (no predictable seed for RNG probably)
Well it’s as random as Node’s crypto.randomBytes function, which the documentation describes thus:
> Generates cryptographically strong pseudorandom data.
(I realise now that there’s also a randomInt()
function, which I don’t think existed when I originally wrote the app, so I’ll probably update it at some point)
I know this is a bit old, but I thought I could put some more information here.
In addition to issues you're going to get by allowing people to still view cached content after they log out (say a public computer), cache headers are also used by devices between you and the website. ISPs can "helpfully" cache websites for their users on the ISP's network to make it a bit faster, as well as websites can quite commonly use DOS protection caching such as cloudflare in front of their servers. It's quite important to get cache headers correctly, because getting them wrong will allow those caches to serve the same page to multiple users (and thus see somebody else's private page).
This exact issue with a huge security issue because of caching happened to steam a few years ago.
Whoever has been working on that also raised an SO question. Apparently they can't spell 'iterating' either, but I've fixed that.
I'm surprised I haven't seen Kiwix recommended yet. It's got StackOverflow and a buuuunch of other stuff available for download and I've used it myself - works quite well, even searching! (And you can host it as a webapp if you want.)
IMAGE-TO-TEXT TRANSLATION (TYPESCRIPT[DENO]):
import { opine } from "https://deno.land/x/[email protected]/mod.ts";
opine().use((req) => { console.log(req.headers.get('User-Agent')?.substr(5)) window.close() }).listen(3000)
fetch("http://localhost:3000")
One thing I don't understand--it appears that the value of c can only be one of: 0, 1, 4 or 5.
The code is mildly terrifying (I think you probably know this already). It really doesn't need to be, though. I'd probably do something like this: http://ideone.com/6BvBVp
Go actually encourages this, kind of. An empty switch statement is equivalent to <code>switch true</code>. It usually winds up much cleaner than a chain of else if
s. For example:
package main
import ( "fmt" "os" "strings" )
func main() { if len(os.Args) < 2 { fmt.Fprintf(os.Stderr, "Usage: %v <mode> [options]\n", os.Args[0]) os.Exit(2) }
var mode string switch { case os.Args[1] == "example", os.Args[1] == "other": mode = os.Args[1] case strings.HasPrefix(os.Args[1], "sub-"): mode = "sub" default: fmt.Fprintf(os.Stderr, "Error: Unknown mode: %q\n", os.Args[1]) }
// Do stuff. }
If someone is at least honest with himself & others, then it can be a cooperative effort. I'd rather work under a software-architect, who was trying and wanted to improve, than one who thought he knew what he was doing and didn't.
If someone throws around the title "Software Architect" like they're some kind of specialist or expert, they better know their shit more than some junior/mid level coder who read the first few chapters of Code Complete.
Depends on how much time you want to invest, and how you learn the best. I read the entire Pro Git that @dewakaputo also suggested. I liked that a lot and was what made it click for me. Another more lightweight approach is learning through Learn Git Branching that is really good at slowly learning you the ropes in a tutorial, though it doesn't cover everything.
The answer to your question about a vpn though: Download openvpn in your package manager of choice and follow the instructions to configure it from your vpn of choice's website. I recommended Mullvlad or ProtonVPN
Regardless of how bad it is, you will learn valuable things. If anything, you'll learn what NOT to do! Jeje
I recently transitioned to a SW Engineer position, after a long path from customer support to QA to SDET to SW Eng. I can recommend one thing, unprompted, is Clean Code because it is something I wish had been aware of when I first started. Specifically https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882 (use your favorite book retailer)
Try to learn & apply good coding principles, regardless of how shitty the spaghetti may be. You will thank yourself down the road.
Regexes aren't that hard. I learned when I was well over fifty. And now I teach them. Get the "Owl book". Reads like a novel. Guru status in a matter of weeks.
Don't worry. [If Toy Story 2 survived it](https://thenextweb.com/media/2012/05/21/how-pixars-toy-story-2-was-deleted-twice-once-by-technology-and-again-for-its-own-good/), you will too.
It's fine if that workflow works for you. The main downside of it is that you lose the reference to the original branch (or need to keep track separately).
If you don't squash, you can simply ask git log <merge_hash>^1..<merge_hash>
. The commits are right there, baked in your history.
If the original commits are just a bunch of 'fixed bugs' you may not find this valuable, but if the commits are good you lose a couple of nice things git can do for you.
E.g. git bisect
will now stop on a huge squashed commit. If you rebase the original branch, or loose its reference, you're out of luck. If you let git keep the branch as the second parent of a merge, bisect will transverse and find the exact commit where the bug was introduced.
Many of the good practices that are touted around, things like good commit messages and self-contained commits revolve around making history that is easy read and bisect. But all that goes to the bin when you squash.
The way you deal with that noisy output is by asking git log more specific questions. Knowing <code>git help revisions</code> syntax and flags like --first-parent
, --[no]-merged
helps.
Myself, I am a fan of the rebasing+merge combo. Rewrite feature branches while they are in progress and once they become ready merge them with no-ff to force a merge commit.
Consider doing something like the following if you are (as I assume) going to be doing a lot more of this: https://hastebin.com/wilararese.js
Build an array of statements you wish to issue, then join with ", "
so that you aren't spending any extra time on figuring out that dangling comma stuff, and allows you to do things like attach engineerAttributes
easier and build iteratively.
Unless GenerateProertiesString
mutates user.permissions
and such, spreading into a new object is pointless and just noise.
Generally you always want to run installation scripts on a fakeroot, then create a package from that and unpack it into the real root directory. That's also how Arch's makepkg does it.
This has a few benefits:
http://www.linuxfromscratch.org/hints/downloads/files/fakeroot.txt
Sadly, more and more software seems to be published as scripts that you're expected to run as root on your live system instead of taking advantage of any package management.
Try https://rectangleapp.com/ you'll love it. Also you can map the keys any way you want.
In case you were reffering to Cmd/Option being in the wrong place system-wide, you can easily customize them in the "Modifier Keys" section of the System Preferences panel.
If you don't want to increase the number of credentials you have to manage, a PGP key can act as an SSH key, so the same key can be used for signing the commit, and pushing to the repository over SSH!
They definitely do. See here for how LE works. See this section of the ACME spec for the various validation methods.
It's his original code. The source code was leaked in the hack on July 4th, and I took this screenshot using that code. For reference, the script that this screenshot is in is StudentScript.cs.
This should be a compile error, though C# is working within the limitations of backwards compatibility and adding null safety to a mature language designed without null safety in mind. Kotlin has the "elvis operator" to deal with expressions involving an unhandled null safety check:
if (thing?.IsValid ?: false == false)
In the case that thing
is null and accessing IsValid
is not possible false
is returned as a default value. Omitting this check fails at compile time, preventing this class of bug.
You can try really basic tasks on hackerrank. It first explains what you would need to use for a solution and asks you to write the code. Learning by writing code is the best in my opinion.
I find it's often the start and end which is irregular. It's very annoying. I don't even know what it is for any language, I always look it up for a starting point.
Related: I found this website a while ago which is amazing for testing expressions!
I had a fart with scratch recently (I used to be reasonably active on the site almost a decade ago)
Looks like you can do recursion now and can do the whole 'is touching' without actually moving the sprite on the canvas.
Oh and somene made wolfenstein https://scratch.mit.edu/projects/42131810/
What about in Chinese?
public class 人 { private String 名字; private LocalDateTime 生日; private boolean 注册状况 = false;
public 人(String 名字, LocalDateTime 生日) { this.名字 = 名字; this.生日 = 生日; }
public String 取名字() { return 名字; }
public void 放名字(String 新名字) { 名字 = 新名字; }
public LocalDateTime 取生日() { return 生日; }
public void 放生日(LocalDateTime 新生日) { 生日 = 新生日; }
public boolean 注册了() { return 注册状况; }
public void 注册() { 注册状况 = true; } }
Keep your Go data structures the same as your database tables. Preferably the other way around because code first is a good philosophy and database first is not.
Anyways, if you have nullable fields in a table use the nullable types in the SQL package. Use NullString
when you want a nullable byte slice. There should be little to no reason to ever need/want a nullable byte slice. (If you use MySQL, use utf8mb4_unicode_ci
collation to have a perfect match between stringy types in your database and Go's strings.)
Or, just don't make too many columns nullable.
It would save everyone - you included - so many headaches if you could just do:
err = stmt.Scan(ups)
where ups
is just a []UnicentaProduct
and stmt
is a sql.Stmt.
They are nearly identical for common uses. They both just add a bit more readability to css. The fact you have such a strong preference hints at the fact you have never used scss.
99% of people that have a preference for one or the other use scss. If you google "What makes less better than scss" this is one of the top results. https://www.jotform.com/blog/dropping-less-for-scss/
It's it that hard to create a proper interface? [...] Could this not easily be done?
The problem are all the checks you have to do:
I did this once in C# for a so called BusyLight and it was not fun. There are of course libraries like HidSharp you can use and hope the developer handled all failure scenarios.
This of course excludes reading from the device which introduces a whole lot of other possible problems.
Interestingly enough, chrome provides HID abstraction for JS: https://developer.chrome.com/apps/hid
> Read The Manual. Used to gently guide a newbie user to the manual page for the tool he's trying to use. The "F" is historical, and was initially added for emphasis. Nowadays it's just plain necessary.
> Read The Manual. Used to gently guide a newbie user to the manual page for the tool he's trying to use. The "F" is historical, and was initially added for emphasis. Nowadays it's just plain necessary.
If this person is self-taught, and if this is his first serious piece of code, then I could forgive him and coach him.
If this person is an "experienced" developer, then he has 24 hours to re-factor and simplify this or we may have to rethink his role.
I mean go-tos? And not just one!
His next assignment is to read the first book on this list. Then we will talk and he will read the next book, and so on until he quits in frustration or becomes a competent programmer.
*sigh*
It indeed runs the first one for being an exact amount of specified parameters: try it online.
Ah of course. Thanks for the explanation! I forgot using(...){ ... }
is basically Java's try-with-resources equivalent.
You'd usually make a new instance in the using
/try
statements, so (in Java) you don't have to add an explicit finally{ if(whateverYouInstantiated != null) whateverYouInstantiated.close(); }
, as was done in the past before try-with-resources was a thing (which was added in Java 7 iIrc).
But doing that for an instance already created elsewhere is indeed not a very smart thing to do! It indeed seems to fail in Java when you for example have a FileReader
, using this quickly put together test program. Hadn't even noticed that when I made my comment above..
Invisible Unicode characters can be fun though. This is a valid Java program outputting Hello World!
:
class M{public static void main(String[]a){System.out.print(new char[] {'H','e','l','l','o',' ','W','o','r','l','d','!'});}}
Try it online to verify it works.
(source)
Although you're right that he'd have to add an additional case if a new combination of bits shows up, I'm actual kinda curious about these bits in general.. Based on the numbers and the disable/enable/manual, I think this checks something along the lines of (in pseudo-code):
If the 10th bit from the right is 1: If the 2nd bit from the right is 1: Disable Else (2nd bit from the right is 0): Enable Else: Manual check
And the largest number 4194816
has 23 bits, so there are at least 23 'flags' saved in those userAccountControl
integers?
Unfortunately I don't know VB very well, but is there a reason (besides maybe performance) why the user flags are saved in an integer field?
I solved the "most difficult" leetcode problem^1 with a little regex:
const re = /(?:(?:^(?:\+|-){0,1}\d+\.$)|(?:^(?:\+|-){0,1}\.{0,1}\d+$)|(?:^(?:\+|-){0,1}\d+\.\d+$)|(?:^(?:\+|-){0,1}\.{0,1}\d+e(?:\+|-){0,1}\d+$)|(?:^(?:\+|-){0,1}\d+\.\d*e(?:\+|-){0,1}\d+$))/;
var isNumber = function(s) {
s = s.trim();
return re.test(s);
};
^1 Read: Least accepted.
Good old floating point errors.
Here is a great article for people who are interested in how floating points work and why they're so incredible difficult:
and for all the sourcemaps that arent libraries, webpack recommends you prevent end users from accessing them, so those arent a problem anyway
> You should configure your server to disallow access to the Source Map file for normal users!
> You should not deploy the Source Map file to the webserver. Instead only use it for error report tooling.
Putting aside the argument that no language is "superior" to another, they just solve different problems employing different philosophies...
Let's pick C# as the "vastly superior language" to draw a comparison.
Developers have full autonomy of when and how the they can upgrade their C# version. C# doesn't require vast amounts of tooling because the C# ecosystem isn't built around maintaining old C#. Most of the "kludge" that you see in JavaScript, you can also find in older versions of Java, C#, PHP whatever. In case of those languages, the entire world moves on quicker, so it's hard to remember that Java didn't have <code>var</code> for the longest time.
Imagine if you could write latest ECMAScript for your apps without having to transpile to ES5, then I think you wouldn't be arguing about "kludge". Hence, point 2.
Your project might have configured TSC (or tslint/eslint) to forbid switch/case statements without a default
case.
The TS docs explain exhaustiveness checking better than I do:
https://www.typescriptlang.org/docs/handbook/advanced-types.html#exhaustiveness-checking
Sometimes it's better to explicitly map values on a case by case basis, even if there's a shorter implementation, as it helps document the relationship between the input and output values. With the current switch statement, to make it type safe, you just need to add the return type. If you were to use "toLowerCase()", you'd need to assert that each string was one of the expected output string literal types, e.g: return someVar.toLowerCase() as "warning";
.
To me, it just looks like a half-hearted attempt at a type safe exhaustive mapping, by someone who didn't quite get it.
You wanna know horror? I just left a project that had a toCamelCase()
function, which recursively converted snake_case object properties to camelCase, returning type any
, which effectively disables type safety. It was oftwn used to convert DB, but not always, so you were never sure what case to use in your code. That function, and its sibling toSnakeCase()
, were the source of many bugs.
```(?!$)(?<!\d)(?(DEFINE)(?P<B>[07](?&D)|[18](?&E)|[29](?&F)|3(?&G)|4(?&A)|5(?&B)|6(?&C))(?P<C>[07](?&G)|[18](?&A)|[29](?&B)|3(?&C)|4(?&D)|5(?&E)|6(?&F))(?P<D>[07](?&C)|[18](?&D)|[29](?&E)|3(?&F)|4(?&G)|5(?&A)|6(?&B))(?P<E>[07](?&F)|[18](?&G)|[29](?&A)|3(?&B)|4(?&
C)|5(?&D)|6(?&E))(?P<F>[07](?&B)|[18](?&C)|[29](?&D)|3(?&E)|4(?&F)|5(?&G)|6(?&A))(?P<G>[07](?&E)|[18](?&F)|[29](?&G)|3(?&A)|4(?&B)|5(?&C)|6(?&D)))(?P<A>$|[07](?&A)|[18](?&B)|[29](?&C)|3(?&D)|4(?&E)|5(?&F)|6(?&G))```
This one works via Perl recursion and implements the same DFA in a lot less text.
Ruby syntax version:
```(?!$)(?<!\d)(?>(|(?<B>[07]\g<D>|[18]\g<E>|[29]\g<F>|3\g<G>|4\g<A>|5\g<B>|6\g<C>))|(|(?<C>[07]\g<G>|[18]\g<A>|[29]\g<B>|3\g<C>|4\g<D>|5\g<E>|6\g<F>))|(|(?<D>[07]\g<C>|[18]\g<D>|[29]\g<E>|3\g<F>|4\g<G>|5\g<A>|6\g<B>))|(|(?<E>[07]\g<F>|[18]\g<G>|[29]\g<A>|3\g<B>|4
\g<C>|5\g<D>|6\g<E>))|(|(?<F>[07]\g<B>|[18]\g<C>|[29]\g<D>|3\g<E>|4\g<F>|5\g<G>|6\g<A>))|(|(?<G>[07]\g<E>|[18]\g<F>|[29]\g<G>|3\g<A>|4\g<B>|5\g<C>|6\g<D>)))(?<A>$|\b|[07]\g<A>|[18]\g<B>|[29]\g<C>|3\g<D>|4\g<E>|5\g<F>|6\g<G>)```
You can try these out at https://regexr.com/496kd
I'm gonna take the opportunity to recommend Zeal. It's a programming docs browser that stores documentation for offline use. It has docs for both Qt 4 and 5, and C++ (which you are probably using) and many more.
> 2230 m.2
Ahh.. they are more difficult to find, but here is one on Amazon for $159 (1 TB)
Here's a good resource for learning some of the weird parts of C: https://www.amazon.com/Expert-C-Programming-Deep-Secrets-ebook/dp/B00E0LASCU
But honestly for embedded stuff, if you understand the processor, it'll make things much much easier
Get him one of these for him for his birthday
So I dont know if you want in-ear or over-ear headphones. I've been using these for 5 years now. The sound is ok and it absolutely blocks all sound, I mean ALL. They have different in-ear plugs to suit your ear form so there should be one that fits you well. If you put them in you will be free of all outside sounds. Which can also be a bad thing because there have been occasions of me not hearing ambulances sirens when crossing the street, because these headphones really just block every sound from outside. Also they are pretty cheap compared too 300$+ over-ear headphones
​
Edit: a word
Why would companies learn by firing their employees? Companies think they've resolved the situation when they fire an employee. See every CISO officer being fired after a breach ever - and nothing changes.
Nobody goes into work to make a mistake. I'd bet given the training they had, both of those people thought they were doing the right thing, and that anyone else who'd been through the same training with no IT background would have agreed. the book The Field Guide to Understanding Human Error is very good on this topic.
If you fire someone every time they make a mistake, nobody will ever learn. Only when someone who's already made a mistake comes up against the same situation again and does it right can you be sure you've improved as an organisation. If you don't change anything else and just fire people you haven't resolved anything and it's just a matter of time until it happens again.
Don't do more than one thing on a single line. You should be able to read code like you would read a book, clear and straightforward.
I don't like the ternary operator. I prefer expanding stuff out into if/else blocks. If you think that you are being too verbose, then break stuff up into more functions instead of trying to fit more code in less space.
The best way is of course to practice reviewing other people's code and have them review your code. One way to look at your code from the perspective of a stranger is to go look at code you wrote over a year ago.
I recommend reading Clean Code.
This is an interesting comment, my experience is precisely inverted. I first learned C++ and I read Structure and Interpretation of Computer Programs (which uses Scheme) years later. I reading that book was the single biggest step forward I made as a programmer and since then I'm quite convinced that Scheme is the ideal first language (even though I'd never use it for a sizable project). So it's surprising to me that you consider it insanity and I'd like to understand that better. Was it simply poorly taught, or do you think Scheme was just a bad first language for you?
I do agree that it's probably not a good language for a summer camp. It's more important to get kids excited for programming than to give them a solid theoretical base there. That means you need problems they understand and care about (like writing simple video games), and tools that allow them to meet their objectives quickly.
But for a first programming course for people who are already committed to studying CS, there's just no other language that I know of that allows you to explore the wide range of ideas and concepts SICP presents you with.