background preloader

SQL (Structured Query Language) in one page : SQL.SU

Related:  twimm

Probably Wrong | Avoid Else, Return Early tldr; Return as soon as you know your method cannot do any more meaningful workReduce indentation by using if/return instead of a top-level if/elseTry keep the “meat” of your method at the lowest indentation level.Error handling is noise. Programmers are often taught to have a ‘single exit point’ in their methods, i.e. only return from a single location. function () { var result; if () { result = x } else { if () { result = y } else { result = z } } return result // this return is single and lonely } This is a poor guideline in my opinion: “assign a result” doesn’t explain the intent: “this is the final value, processing stops here”Leaves question open “is the result object finished? Example if/else refactoring Consider this typical node callback code: function(err, results) { if (! There’s a few problems here. Let’s try keep the “meat” of the code at the bottom of the method, and keep any special cases together at the top: function(err, results) { if (err) return void handleError(err) // ... }

Syntax Diagrams For SQLite Syntax Diagrams For SQLite Basic SQLite Statements: All SQLite Statements: sql-stmt-list: References: sql-stmt See also: lang.html sql-stmt: Used by: sql-stmt-list References: alter-table-stmt analyze-stmt attach-stmt begin-stmt commit-stmt create-index-stmt create-table-stmt create-trigger-stmt create-view-stmt create-virtual-table-stmt delete-stmt delete-stmt-limited detach-stmt drop-index-stmt drop-table-stmt drop-trigger-stmt drop-view-stmt insert-stmt pragma-stmt reindex-stmt release-stmt rollback-stmt savepoint-stmt select-stmt update-stmt update-stmt-limited vacuum-stmt See also: lang.html lang_explain.html alter-table-stmt: Used by: sql-stmt References: column-def See also: lang_altertable.html analyze-stmt: Used by: sql-stmt See also: lang_analyze.html attach-stmt: Used by: sql-stmt See also: lang_attach.html begin-stmt: Used by: sql-stmt See also: lang_transaction.html commit-stmt: Used by: sql-stmt See also: lang_transaction.html rollback-stmt: savepoint-stmt: release-stmt: create-index-stmt:

Named Constructors in PHP Don't limit yourself by PHP's single constructor. Use static factory methods. Published on 12 June 2014 by @mathiasverraes PHP allows only a single constructor per class. <? The only correct answer is “it depends”. This is terribly ugly. <? Or if we want to support numeric strings as well as integers? <? (Note: in production code, I would make my Time class a lot more idiot-proof.) Refactor to named constructors Let’s add some public static methods to instantiate Time. Every method now satisfies the Single Responsibility Principle. Well, something is bothering me: __construct($hours, $minutes) kinda sucks: it exposes the internals of the Time value object, and we can’t change the interface because it is public. This is ugly: we go through all the trouble of splitting up the string, only to rebuild it in the constructor. Do we even need a constructor now that we have named constructors? <? <? Ubiquitous Language <? Notice anything? fromString => fromTime fromValues => fromHoursAndMinutes <?

JavaScript in one page : JavaScript.SU Prettier for PHP 0.1: First alpha release □ · Prettier After more than 200 merged pull requests since mid December 2017, we're happy to announce the first alpha release of Prettier for PHP. In this blog post, we'd like to give a short overview of how the plugin works, its philosophy, and what to expect in the future. How does it work? Adding support for a new language to Prettier requires two things: A parser, which turns your source code into an abstract syntax tree (AST). While we could benefit from existing work on the parsing side, the printer had to be developed from scratch to support all of PHP's various AST node types. If you'd like to read more about the plugin API, see the docs. Philosophy When building a code formatter, it can be tempting to add many options to account for all the different code styles there are. From the experience gained with Prettier for JavaScript, we believe that offering as few configuration options as possible is one of Prettier's biggest strengths. What's next Are you excited about Prettier for PHP?

CSS3 Cheat Sheet (PDF) Advertisement Just last week we released an extensive printable HTML 5 Cheat Sheet that lists all currently supported HTML 5 tags, their descriptions, their attributes and their support in HTML 4. In comments to this post we received many requests for a similar CSS 3 cheat sheet that would present the main features of CSS 3 in a handy, printable reference card. So we asked our friend Chris Hanscom from Veign.com (who created the HTML 5 cheat sheet) to create a quick reference card for CSS 3. We already encouraged you to experiment with CSS 3 in our last posts and now you can use this handy cheat sheet to use the new CSS 3 features in some modern browsers (Firefox 3.5, Opera 9.6, Safari 3+, Google Chrome and Co.). The result is a printable CSS 3 scrib sheet, created and released exclusively for the readers of Smashing Magazine. The cheat sheet was done in the same format as the CSS 2 Reference Guide that you may want to use for your projects as well. Thank you very much, Chris Hanscom!

A list of cool Chrome DevTools Tips and Tricks The Chrome DevTools provide an amazing set of tools to help you develop on the Web platform. Here are a few tips you might not know yet Check out the overview of Chrome DevTools if you're new to them Drag and Drop in the Elements panel In the Elements panel you can drag and drop any HTML element and change its position across the page Reference the currently selected element in the Console Select a node in the Elements panel, and type $0 in the console to reference it. Tip: if you're using jQuery, you can enter $($0) to access the jQuery API on this element. Use the value of the last operation in the Console Use $_ to reference the return value of the previous operation executed in the Console Add CSS and edit the element state In the Elements panel there are 2 super useful buttons. The first lets you add a new CSS property, with any selector you want but pre-filling the currently selected element: Find where a CSS property is defined Save to file the modified CSS Screenshot a single element

75 Essential Cheat Sheets for Designers and Programmers 1 Share Share Tweet Email Programming is not an easy job, and requires a lot of concentration and expert reference. You might get struck anytime, anywhere in the code, where you can’t work out the things, but need to finish the code as soon as possible, for your boss sitting hot over your head. Cheat sheets are a collection of notes and facts used for quick reference. Giving a rough idea, about what a cheat sheet includes, is that it contains the information about all the syntaxes and data properties, that are used in that particular coding language. Here, we have a list of the best 75 cheat sheets for the designers and developers. 1) Cheat Sheets – jQuery 2) Cheat Sheets – HTML 3) Cheat Sheets – HTML5 Cheat Sheet 4) Cheat Sheets – CSS 5) Cheat Sheets – CSS2 6) Cheat Sheets – CSS3 7) Cheat Sheets – JavaScript 8) Cheat Sheets – Linux 9) Cheat Sheets – Java 10) Cheat Sheets – Java 8 11) Cheat Sheets – Perl 12) Cheat Sheets – PHP 13) Cheat Sheets – Python 14) Cheat Sheets – Ruby 17) Cheat Sheets – SQL

Our journey to microservices: mono repo vs multiple repositories Microservices are currently the hottest topic in software development. The concept is simple: Break down your application into smaller pieces that each perform a single business function and can be developed and deployed independently. These pieces, commonly called services, can then be assembled into an application using some flavor of service discovery like nginx or consul. The microservices approach is considered the architecture of choice for teams that want to build scalable platforms and efficiently and rapidly innovate on them. As infatuated as I am with this architecture, our journey to microservices was a long and winding road. When you start moving to microservices, the first question before you write a single line of code is: How do you organize your codebase? Multiple Repositories We started out with the first approach with multiple repositories. Better scale Smaller codebases are easier to manage and lead to fewer instances of "merge hell". So did this work for us? 1.

google/guetzli: Perceptual JPEG encoder

Related: