Skip to content

Instantly share code, notes, and snippets.

View otkrsk's full-sized avatar

Nick Nuing otkrsk

  • Kuala Lumpur, Malaysia
  • 02:22 (UTC +08:00)
View GitHub Profile
@otkrsk
otkrsk / gist:32dc43c4417973728aead8e7f42fe5ef
Created April 28, 2020 08:13
Copy Screenshot to Clipboard (Mac OS)
Selection (Control (⌃) + Shift (⇧) + Command (⌘) + 4)
Window (Control (⌃) + Shift (⇧) + Command (⌘) + 4 + Spacebar)
from utils.company.helpers import *
email='[email protected]'
company = get_company_by_email(email)
from employee.models import EmployeeUser
employee_obj = EmployeeUser.objects.filter(email__iexact=email.strip())
# iname is case insensitive
sudo find . -iname "*<search_term>*"
ip addr show

Some Docker Commands to Remember

Stop Containers (oneline)

docker stop $(docker ps -a -q)

Remove Containers (oneline)

docker rm $(docker ps -a -q)
$menuitem = MenuItem::create([
'menu_id' => \Auth::user()->branches()->first()->id,
'name' => $customer->id,
'product_type' => $customer->cars->first()->id,
'status' => 0,
'sales_total' => 0,
'is_cancel' => false
]);
screen -r -d <screen_session_id>
@otkrsk
otkrsk / untar_strip.sh
Created November 27, 2018 18:49
Command to untar a tar file into another directory and strip it's root directories.
tar -zxvf file.tar.gz -C <target_directory> --strip <number_of_directories_to_strip>
@otkrsk
otkrsk / check_if_date.php
Created April 10, 2018 10:43
Check if a given string is in a valid date format
$myString = "2010-10-10 00:00:00";
if (DateTime::createFromFormat('Y-m-d G:i:s', $myString) !== FALSE) {
// it's a date
}
@otkrsk
otkrsk / mem_info.sh
Last active February 23, 2018 03:34
The /proc/meminfo file stores statistics about memory usage on the Linux based system. The same file is used by free and other utilities to report the amount of free and used memory (both physical and swap) on the system as well as the shared memory and buffers used by the kernel.
egrep --color 'Mem|Cache|Swap' /proc/meminfo
@otkrsk
otkrsk / dropbox_bashcurl.sh
Last active February 20, 2020 01:15
Get a list of files in a directory and execute a curl command to upload the files to Dropbox
for file in "."/*
do
curl -X POST https://content.dropboxapi.com/2/files/upload --header "Authorization: Bearer <token>" \
--header "Dropbox-API-Arg: {\"path\": \"/folder1/folder2/${file:2}\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}" \
--header "Content-Type: application/octet-stream" \
--data-binary @${file:2}
done