// This is where we'll save the attachment | |
var tablename = 'incident'; | |
var recordSysId = '8d6353eac0a8016400d8a125ca14fc1f'; | |
var filename = 'snlogo.png'; | |
// Let's download the ServiceNow Logo | |
var logoUrl = 'https://instance.service-now.com/images/logos/logo_service-now.png'; | |
var request = new sn_ws.RESTMessageV2(); | |
request.setHttpMethod('get'); | |
request.setEndpoint(logoUrl); |
- Introduced by [Kent Beck][beck] in the 1990s.
- Part of his software development methodology [Extreme Programming][extreme-programming].
- His exact wording appears in the [White Book][white-book].
The rules can be stated as followed:
Passes all tests
Maximizes clarity
This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)
The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array
it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array
part of it away. So how does that work?
The key here is that objects usually have a predefined set of keys, whereas arrays don't:
javascript:void (async () => { let { default: TD } = await import("https://cdn.skypack.dev/turndown"); let json = [ ...document.querySelectorAll(".text-base"), ].map((i) => ({ html: i.innerHTML, text: i.innerText, markdown: new TD().turndown(i), isPrompt: !i.querySelector(".prose"), })); window.open( URL.createObjectURL( new Blob( [ json .map((i) => i.isPrompt ? `**Prompt**: ${i.text}` : `**ChatGPT**: ${i.markdown}` ) .join("\n\n"), ], { type: "text/plain" } ) ) ); })()
Get a quick answer from google for any question
(async function answer(q) {
var html = await fetch(
`https://cors.explosionscratc.repl.co/google.com/search?q=${encodeURI(q)}`,
[{ | |
"Note": "The first two digits (ranging from 10–43) correspond to the province, while the last two digits correspond either to the city/delivery zone (range 01–50) or to the district/delivery zone (range 51–99). Afghanistan Postal code lookup", | |
"Country": "Afghanistan", | |
"ISO": "AF", | |
"Format": "NNNN", | |
"Regex": "^\\d{4}$" | |
}, { | |
"Note": "With Finland, first two numbers are 22.", | |
"Country": "Åland Islands", | |
"ISO": "AX", |
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
- Follow standard conventions.
- Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
- Boy scout rule. Leave the campground cleaner than you found it.
- Always find root cause. Always look for the root cause of a problem.