Skip to content

Instantly share code, notes, and snippets.

View otkrsk's full-sized avatar

Nick Nuing otkrsk

  • Kuala Lumpur, Malaysia
  • 04:09 (UTC +08:00)
View GitHub Profile
@otkrsk
otkrsk / ubuntu_remove_package.sh
Last active February 20, 2020 01:15
Remove apps on Ubuntu
sudo apt-get remove --purge <package_name>
@otkrsk
otkrsk / js_possible_recursion.md
Last active February 20, 2020 01:15
Possible technique for recursive functions
const createDivs = howMany => {
  if (!howMany) return;
  document.body.insertAdjacentHTML("beforeend", "<div></div>");
  return createDivs(howMany - 1);
};
createDivs(5);
public function thisIsRecursive($x) {
@otkrsk
otkrsk / macos_datetimestamp.sh
Last active February 20, 2020 01:16
Insert a Date Time Stamp Into a File and Append a Date Time Stamp to a Filename (in MacOS).
# insert the date into the file
date "+ %Y-%m-%d %H:%M:%S %z" >> filename.fileext
# append the date into the file
mv filename.fileext $(date +"%Y-%m-%d")_filename.fileext
composer create-project --prefer-dist laravel/laravel [app_name] "5.2.*"
@otkrsk
otkrsk / multiple-ssh-authkeys.md
Last active November 13, 2023 08:40
Add multiple SSH keys to the authorized_keys file to enable SSH authentication when connecting to a server.

Step 1: Generate first ssh key Type the following command to generate your first public and private key on a local workstation. Next provide the required input or accept the defaults. Please do not change the filename and directory location.

workstation 1 $ ssh-keygen -t rsa

Finally, copy your public key to your remote server using scp

@otkrsk
otkrsk / send_POST_request_using_cURL.php
Created November 25, 2016 04:54
Send $_POST Request Using PHP cURL
//extract data from the post
//set POST variables
$url = 'http://domain.com/get-post.php';
$fields = array(
'lname' => urlencode($_POST['last_name']),
'fname' => urlencode($_POST['first_name']),
'title' => urlencode($_POST['title']),
'company' => urlencode($_POST['institution']),
'age' => urlencode($_POST['age']),
'email' => urlencode($_POST['email']),
@otkrsk
otkrsk / add_comment_to_column.sql
Last active October 13, 2016 06:50
Add a comment to a column. Use https://gist.github.com/otkrsk/be87a95cb094b4ea42ac390c50be2397 to see your comments.
ALTER TABLE `table_name` CHANGE `column_to_alter` `column_to_alter` INT( 11 ) COMMENT 'your_comment_here'
@otkrsk
otkrsk / show_table_structure_with_comments.sql
Created October 13, 2016 02:39
Snippet to show table structure with column comments
SHOW FULL COLUMNS FROM `table_name`
@otkrsk
otkrsk / kill_detached_screen.sh
Created September 15, 2016 04:03
Kill a detached screen session
screen -X -S [session id you want to kill] quit