技術情報
- 2021年05月07日
- 技術情報
Visual Studio Code for PHP developers
Makes it clean and pretty code each time you open VS Code to help us all become better engineers! I want to share some important VS Code tips and tricks.
Quickly open files
Keyboard Shortcut: Ctrl+P
Access all available commands.
Keyboard Shortcut: Ctrl+Shit+P
Navigate between recently opened folders and workspace
Keyboard Shortcut: Ctrl+R
There are many things you can do to customize your code format.
- Change your theme
Firstly Keyword Shortcut: Ctrl+Shit+P then go to type >theme and select your preference theme.
If you want to add color theme, I recommend Gruvbox Material. It’s totally pretty color theme that I’ve used.
Customize your keyboard shortcuts
Keyboard Shortcut: Ctrl+K Ctrl+S
Search and Install extensions
Keyboard Shortcuts : Ctrl+Shift+X
You can find extensions in the VS Code Marketpalce.
Integrated Terminal
Keyboard Shortcut: Ctrl+`
Toggle SideBar
Keyboard Shordcut: Ctrl+B
Toggle Panel
Keyboard Shordcut: Ctrl+J
Zen mode
Keyboard Shortcut: Ctrl+K Z
Press Esc twice to exit Zen mode.
Move to Explorer window
Keyboard Shortcut: Ctrl+Shit +E
Navigation entire history
Keyboard Shordcut: Ctrl+Tab
Multi Cursor selection
Keyboard Shortcut: Ctrl+Shit+Left
To set cursors above or below the current position use
Keyboard Shortcut: Ctrl+Alt+Up or Ctrl+Alt+Down
Copy line up / down
Keyboard Shortcut: Shift+Alt+Up or Shift+Alt+Down
Code Formatting
Whole document format: Shift+Alt+F
Code Folding
Keyboard Shortcut: Ctrl+Shift+[ or Ctrl+Shift+]
Select Current Line
Keyboard Shortcut: Ctrl+L
Navigate to beginning and end of file
Keyboard Shortcut: Ctrl+Home and Ctrl+End
Move line up and down
Keyboard Shortcut: Alt+Up or Alt+Down
Git integration
Keyboard Shortcut: Ctrl+Shift+G
You can install other SCM providers from the Extension Marketplace. Most of the time I’m preferred GitLens extension. It’s incredible useful.
Diffs
From the Source Control view, select a file to open the diff.
Views
The default view for diffs is the side by side view.
Toggle inline view by clicking the More Actions (…) button in the top right and selecting Toggle Inline View.
Branches
Easily switch between Git branches via the Status Bar.
Staging
Hover over the number of files and click the plus button.
Click the minus button to unstage changes.
Undo Last Commit
Click the (…) button and then select Undo Last Commit to undo the previous commit. The changes are added to the Staged Changes section.
See Git output
VS Code makes it easy to see what Git commands are actually running. This is helpful when learning Git or debugging a difficult source control issue
Use the Toggle Output command (Ctrl+Shift+U) and select Git in the dropdown.
By Ami
asahi at 2021年05月07日 10:00:42
- 2021年04月23日
- 技術情報
How AJAX Works Using the jQuery Library
The jQuery ajax() method provides core functionality of AJAX in jQuery. It sends asynchronous HTTP requests to the server.
The standard way of making an AJAX call using jQuery is rather simple – by using the $.ajax() function:
<script>
$.ajax(
'/jquery/getdata',
{
success: function(data) {
alert('AJAX call was successful!');
alert('Data from the server' + data);
},
error: function() {
alert('There was some error performing the AJAX call!');
}
}
);
</script>
As you already known, the $ sign is used to refer to a jQuery object.
In the above example, the first parameter is string URL to which you want to submit or retrieve the data.
The second parameter is the JSON format. By default, ajax() method performs http GET request if option parameter does not include method option.
In most cases, we will need to specify the success and error callbacks. The success callback will be called after the successful completion of the Ajax call. On the other hand, the failure callback will be called if something goes wrong and there was an issue performing the AJAX call.
Using Promises for AJAX with jQuery
$.ajax method supports JavaScript Promises as well.
.done() as replacement for .success()
.fail() as replacement for .error()
.always() as replacement for .complete()
$.ajax({
data: someData,
dataType: 'json',
url: '/path/to/script'
}).done(function(data) {
// If successful
console.log(data);
}).fail(function(jqXHR, textStatus, errorThrown) {
// If fail
console.log(textStatus + ': ' + errorThrown);
});
Chaining Works
Assign the $.ajax() method to a variable, for which we can chain promise callbacks to. In this example, the $.ajax() method returns a promise object natively, which we can use chaining too:
var ajaxCall = $.ajax({
context: $(element),
data: someData,
dataType: 'json',
url: '/path/to/script'
});
ajaxCall.done(function(data) {
console.log(data);
});
Multiple AJAX calls
We can compound several AJAX calls with their status $.when().
var a1 = $.ajax({...}),
a2 = $.ajax({...});
$.when(a1, a2).done(function(r1, r2) {
console.log(r1[0]);
console.log(r2[0]);
});
Dependence chain of AJAX requests
We can also chain multiple AJAX request. For example, when the second AJAX call relies on returned data on the first call.
var a1 = $.ajax({
url: '/path/to/file',
dataType: 'json'
}),
a2 = a1.then(function(data) {
// .then() returns a new promise
return $.ajax({
url: '/path/to/another/file',
dataType: 'json',
data: data.sessionID
});
});
a2.done(function(data) {
console.log(data);
});
By Ami
asahi at 2021年04月23日 10:05:18
Microsoft buys Nuance for nearly $20 billion deal
Microsoft said it agreed to buy Nuance Communications, a cloud and artificial intelligence (AI) software company, in a cash transaction valued at $ 19.7 billion, including debt on Monday.

So what is Nuance ?
“Nuance provides the artificial intelligence layer at the point of healthcare delivery and is a pioneer in the real-world application of enterprise artificial intelligence” Microsoft CEO Satya Nadella said in a statement. “Artificial intelligence is the highest priority in technology and healthcare is most urgent application.”
Nuance products include multiple clinical speech recognition as a service (SaaS) software offerings built on Microsoft Azure. The company’s solutions work with major healthcare systems and are currently used in 77% of US hospitals, noted in a statement of him.
Beyond healthcare, Nuance provides expertise in artificial intelligence and customer engagement solutions in interactive voice response, virtual assistants, and digital and biometric solutions.
Microsoft’s acquisition of Nuance builds on the existing partnership between the companies announced in 2019 to help transform healthcare delivery. Last year, the software giant introduced Microsoft Cloud for Healthcare to address the needs of the rapidly transforming and growing healthcare industry.
This combination might results solutions and expertise to deliver new cloud and artificial intelligence capabilities in healthcare and other industries, and represent the latest step in Microsoft’s industry-specific cloud strategy, the Redmond-based company noted.
Yuuma
yuuma at 2021年04月19日 11:00:52
- 2021年04月16日
- 技術情報
Creating downloadable CSV file in PHP
This time I would like to share you how to automatically download CSV file using PHP.
To download CSV file, the header() function and the php://output parameter must be used.
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename=myCSV.csv');
header("Content-Transfer-Encoding: UTF-8");
Setting the header is importance when downloading files automatically. In the first line of code, the content-type option is that HTTP header telling the browser that the MIME type of the content is application/csv.
Other particularly important option is in the second line of code, the filename option. This is where we want to name the file that will be generated and downloaded.
The other importance line of code is content transfer encoding ,this encoding method will transform binary email message data into the US-ASCII plain text format.
For populating CSV, fopen() giving us access to PHP’s output buffer. This line of code is that the file pointer connected to the output stream.
$f = fopen('php://output', 'a');
Writing data to the Csv and we can define column headings like this:
fputcsv($f, array('Column 1', 'Column 2', 'Column 3'));
We can fetch data and loop over the rows of data and output them.
mysql_connect('localhost', 'username', 'password');
mysql_select_db('database');
$rows = mysql_query('SELECT field1,field2,field3 FROM table');
while ($row = mysql_fetch_assoc($rows)) fputcsv($f, $row);
By Ami
asahi at 2021年04月16日 10:00:06
- 2021年04月09日
- 技術情報
Prohibited Validation Rules in Laravel
Sometimes we wish to forcefully prevent some of the fields in the request.
Now we just got that. Laravel 8 has three validation added for prohibited fields. Let’s walk through a few examples of where the prohibited validation rules might be useful and look at each one in more detail.
Prohibited Validation Rule
The “prohibited” rule checks if the field under validation must be empty or not present or throw an error otherwise.
// PUT /api/licenses/123-456
// {"name":"hello-world", "key":"random-key"}
$validated = $request->validate([
'name' => 'required|max:255',
'key' => 'prohibited',
]);
// Response: 422
// The key field is prohibited
The above is where a user might expect to update an API key by sending a PUT request to a resource. That field is likely ignored during the request. However, a successful response might lead to the user to believe they were able to update the key when in reality, the API ignored it.
If prohibited validation rule registers, the key field is present in the request it will terminate the request with 422 HTTP code response code and throw the error with the message The key field is prohibited.
Prohibited If and Unless Rules
The “prohibited_if ” rule checks if the field under validation must be empty or not present if the another field is equal to any value.
Validator::validate([
‘is_minor’ => true,
‘tos_accepted’ => true
], [
‘tos_accepted’ => ‘prohibited_if:is_minor, true’
]);
The above example is we’re expecting tos_accepted field will be forbidden if is_minor filed accepts true value. This example means someone accepting terms of service that has identified as a minor. Perhaps the application requires a parental registration to consent on their behalf.
The basic idea of “Prohibited_unless” rule is that a given filed should be prohibited from having data unless another field is equal to any value.
Validator::validate([
‘is_deceased’ => false,
‘date_of_death’ => ‘2021-03-09’
], [
‘date_of_death’ => ‘prohibited_unless:is_deceased,true’
]);
The above example might be initially the is_deceased filed set to false value.If we’re expecting the date_of_death field not to be forbidden, the is_deceased’ field set to true value.The example illustrates perfectly how to use this rule to explicitly prevent contradictory input.
By Ami
asahi at 2021年04月09日 10:00:12