Last active
May 6, 2025 16:39
-
-
Save Mifrill/706a949bfbfa683119909936355fb3f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// all available commands in makefile | |
make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {print $1}' | sort -u | |
sudo su - ec2-user | |
find . -name "*.test.ts" -type f -delete | |
AWS_PROFILE={PROFILE} aws ecs execute-command --cluster cloudos-cluster-sdlc \ | |
--task {TASK_ID} \ | |
--container {CONTAINER_NAME} \ | |
--interactive \ | |
--command "/bin/sh" | |
docker build . -t <name> --progress=plain --no-cache | |
ARG NODE_VERSION=20.12.0 | |
RUN curl https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz | tar -xz -C /usr/local --strip-components 1 | |
shift + l - jump to line in github | |
count - | wc -l | |
first - | head -n 1 | |
last - | tail -n 1 | |
pretty-print: `| python -m json.tool` | |
ls -la | |
dig URL | |
npx run-func dist/utils/randomString.js randomString | |
docker logs --follow {ID} | |
| head -n 3 | |
find app/models -type f | wc -l | |
check last command output | |
echo $? | |
mint-release-upgrade | |
find ./online_admin/*/UTF-8/* -type f -exec grep -H "invalidTemplateName" {} \; # use grep to find in a directory by a regexp | |
git diff --name-only HASH_COMMIT HEAD # For files changed between a given SHA and your current commit | |
git reset --hard master | |
sudo du -h --max-depth=1 | |
# largest file | |
find . -type f -printf "%s\t%p\n" | sort -n | tail -1 | |
du -hs * | sort -h | |
sudo service network-manager restart | |
export PATH="$PATH:$HOME/.config/yarn/global/node_modules/.bin" | |
sudo chown mifrill:mifrill -R ./ | |
ls ~/.rbenv/versions/*/bin/* | grep chromedriver | |
TEST_FAILS=`rbenv exec bundle exec rake test | grep 'Failure:' -o | awk '{print $1}'` | |
pushd /etc | |
popd # return to back to working directory | |
locate fstab | |
sudo updatedb | |
which cal | |
whatis cal | |
history | |
man man | |
cat >> file # create text file quickly | |
more file | |
watch free -h | |
killall firefox | |
stat --format '%a' <file> | |
find DIR_NAME -type f | wc -l # Recursively counting files in a directory | |
____________________________________________________________________________________ | |
exec $SHELL | |
sudo chmod +t /tmp | |
# https://itsfoss.com/switch-xorg-wayland/ | |
echo $XDG_SESSION_TYPE | |
xhost +si:localuser:root # run troublesome program with sudo | |
sudo service vboxadd-service stop | |
sudo service ntp restart | |
sudo service postgresql start | |
sudo ./IntelliJIDEALicenseServer_linux_amd64 | |
lsof -wni tcp:7054 kill -9 <PID> | |
sudo kill -9 $(lsof -t -i:7054) | |
/usr/bin/google-chrome | |
sudo chmod 777 bin/start | |
java -Xmx1g -XX:MaxMetaspaceSize=250M -Djava.awt.headless=true -jar youtrack-2017.2.34279.jar 127.0.0.1:8080/youtrack | |
wine msiexec /i xyz.msi | |
sudo openvpn --config "path to your .ovpn file" | |
sudo dpkg -i downloaded_archive | |
grep response.sync_body crawlers/*/*.rb | |
grep category crawlers/*/*.rb | |
ifconfig | |
rm -fr {some_directory} | |
declare -r ENV_VAR | |
sudo pkill Xvfb | |
sudo service mongod start | |
sudo /etc/init.d/apache2 start | |
sudo /etc/init.d/apache2 stop | |
sudo /etc/init.d/apache2 restart | |
// basic stuff install | |
sudo apt-get install git | |
sudo apt-get install unzip | |
// LAMP | |
sudo apt-get install tasksel | |
sudo tasksel install lamp-server | |
// CURL + Composer | |
sudo apt-get install curl php-curl php-mcrypt php-mbstring php-gettext | |
// enable mods | |
sudo phpenmod mcrypt | |
sudo phpenmod mbstring | |
sudo a2enmod rewrite | |
sudo systemctl restart apache2 | |
touch {DIRNAME.FILENAME} | |
ifconfig -a, ip addr show, hostname -I | |
// version of OS | |
lsb_release -a | |
//ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017 | |
sudo killall -15 mongod | |
curl -sS https://getcomposer.org/installer | php | |
sudo mv composer.phar /usr/local/bin/composer | |
//install phpmyadmin | |
sudo apt-get install phpmyadmin | |
# later accessible through localhost/phpmyadmin | |
//Creating Laravel Project | |
cd /var/www/html/ | |
sudo composer create-project laravel/laravel work --prefer-dist | |
sudo chmod -R 777 work | |
//Creating Virtual Host work.com | |
sudo leafpad /etc/apache2/sites-available/work.com.conf | |
#/etc/apache2/sites-available/work.com.conf contains following lines | |
<VirtualHost *:80> | |
ServerName work.com | |
DocumentRoot /var/www/html/work/public | |
<Directory /var/www/html/work/public> | |
AllowOverride All | |
Require all granted | |
</Directory> | |
</VirtualHost> | |
// enable that site | |
sudo a2ensite work.com | |
service apache2 reload | |
// fix hosts file | |
sudo leafpad /etc/hosts | |
#/etc/hosts contents following lines | |
127.0.0.1 work.com | |
or use this command | |
sudo -- sh -c "echo '\n127.0.0.1 \twork.com'>> /etc/hosts" | |
// make permanent aliases: | |
echo "alias cls='clear'" >> ~/.bash_aliases && source ~/.bash_aliases | |
echo "alias sudo='sudo '" >> ~/.bash_aliases && source ~/.bash_aliases | |
echo "alias fm='pcmanfm'" >> ~/.bash_aliases && source ~/.bash_aliases | |
That's it laravel is installed! | |
########################################################################################################## | |
NOW CONFIGURE WORKING ENVIRONMENT | |
// fix for adding repositories so you can download software from other sources | |
sudo apt-get install software-properties-common | |
// install sublime-text 3 | |
sudo add-apt-repository ppa:webupd8team/sublime-text-3 | |
sudo apt-get update | |
sudo apt-get install sublime-text-installer | |
// install sublime packages | |
Ctrl + ` or View/Show Console | |
import urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by) | |
restart sublime-text | |
then go to Preferences/Package Control and install | |
#Laravel Blade Highlighter | |
#Sidebar-Enhancements | |
#LaravelCollective HTML Form Snippets | |
"CodeComplice", | |
"Laravel Helper Completions", | |
"Terminal" | |
// this is for removing and uninstalling sublime text | |
sudo apt-get purge sublime-text-installer | |
sudo rm -r /opt/sublime_text | |
sudo rm -r /usr/bin/subl | |
sudo rm -r /usr/share/applications/sublime.desktop | |
sudo rm -r /home/laravel/Desktop/sublime-text.desktop | |
sudo rm -r /home/laravel/.config/sublime-text-3 | |
// how to create snippets for html or any code | |
got to Tools/New Snippet | |
<snippet> | |
<content><![CDATA[ | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>$1</title> | |
</head> | |
<body> | |
$2 | |
</body> | |
</html> | |
]]></content> | |
<tabTrigger>html</tabTrigger> | |
</snippet> | |
paste that ^ and save as *.sublime-snippet inside sublime/packages/user folder | |
// change default server directory *OPTIONAL! | |
sudo leafpad /etc/apache2/sites-available/000-default.conf | |
and change the following line to what you want: | |
DocumentRoot /var/www/html | |
Also do a | |
sudo leafpad /etc/apache2/apache2.conf | |
and find this | |
<Directory /var/www/> | |
Options Indexes FollowSymLinks | |
AllowOverride None | |
Require all granted | |
</Directory> | |
and change /var/www/ to your preferred directory //mine is /var/www/html/work/public | |
and save it. | |
After you saved your changes, just restart the apache2 webserver and you'll be done :) | |
sudo service apache2 restart | |
// make laravel app to be the landing (localhost) site instead of apache2 /*optional | |
sudo a2dissite 000-default | |
// this is to enable it | |
sudo a2ensite 000-default | |
######################################################################################################## | |
CONFIGURE SOME EXTRA STUFF TO MAKE CODING EASIER | |
//install form and html and input classes | |
../laravel_folder/composer.json | |
----------------------------------------------------- | |
"require": { | |
"laravelcollective/html": "5.2.*" | |
} | |
----------------------------------------------------- | |
../laravel_folder/config/app.php | |
----------------------------------------------------- | |
'providers' => [ | |
// ... | |
Collective\Html\HtmlServiceProvider::class, | |
// ... | |
], | |
'aliases' => [ | |
// ... | |
'Form' => Collective\Html\FormFacade::class, | |
'Html' => Collective\Html\HtmlFacade::class, | |
// ... | |
], | |
------------------------------------------------------ | |
in terminal go to laravel_app_folder and run | |
sudo composer update | |
That's it everything set for working with Laravel 5.2 | |
################################################################ | |
// install generators for migrations | |
sudo composer require laracasts/generators --dev | |
inside app/Providers/AppServiceProvider.php change public function register | |
public function register() | |
{ | |
if ($this->app->environment() == 'local') { | |
$this->app->register('Laracasts\Generators\GeneratorsServiceProvider'); | |
} | |
} | |
now you can do this | |
sudo php artisan make:migration:schema create_roles_table --schema="name:string" | |
sudo php artisan make:migration:schema remove_user_id_from_posts_table --schema="user_id:integer" | |
sudo php artisan make:migration:pivot tags posts | |
mount /dev/sdb1 /media/hdd | |
umount /media/hdd | |
mount -a | |
ifconfig -a | |
curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//' | |
# Wireshark | |
sudo su | |
cd /home | |
export SSLKEYLOGFILE=~/sslkeylog.log | |
printenv | |
open firefox | |
Screenshots | |
sudo apt-get install wine | |
wget http://app.prntscr.com/build/setup-lightshot.exe | |
wine ./setup-lightshot.exe5 | |
# make frames from gif picturers | |
convert '123.gif[1..49]' 'frames.png' | |
grep -r -l "field :category" crawlers/i18n | |
grep LOC /proc/interrupts | |
sudo !! | |
less +F | |
# remove spaces | |
a b c | td -d '[:space:]' | |
mtr --curses 8.8.8.8 | |
alt . # argument of the last seccessfully comand | |
reset | |
uname -a (-v -r) | |
ip addr show | |
df -ah | |
service udev status | |
systemctl | |
du -sh {folder} | |
sudo netstat -tulpn | |
ps aux | grep nginx | |
top (htop) | |
man {comand} | |
sudo lsof | head | |
sudo lsof -i -n -P | grep TCP | |
lspci | grep VGA | |
require 'yaml'; listings = File.read('/media/mifrill/236bf183-17ec-4844-aea7-e9418f4b1cea/readme/parts.txt'); file = File.new('/media/mifrill/236bf183-17ec-4844-aea7-e9418f4b1cea/readme/parts_domain.txt', "w"); file.write(listings.split("\n").uniq.sort.map { |_| _.sub(/\A.*\//, "") }.join("\n")) | |
require 'yaml'; listings = File.read('/media/mifrill/236bf183-17ec-4844-aea7-e9418f4b1cea/readme/part.yml'); file = File.new('/media/mifrill/236bf183-17ec-4844-aea7-e9418f4b1cea/readme/parts.txt', "w"); file.write(listings.split("\n").uniq.sort.map { |_| _.gsub(/\Acrawlers\/|\.rb\z/, "") }.reject { |_| _[/\A(agdealer|agropool|amsmaschinenmarkt|arinetworkservices|avspare|baupool|bidspotter|commercialwebservices|concessionjd|dealerspiketruck|dealerwebcentral|equipmentlocator|equipmentsales|equipmenttrader|fastline|ironsearch|landwirt|machinefinder|machineseeker|mascus|mobile|mtr|powersportsnetwork|technikboerse|traktorpool)\//] }.join("\n")); | |
grep Attachment -r -l crawlers/*/*.rb | |
grep "field :image" crawlers/*/*.rb --invert-match -r -l | |
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'; | |
_________________________________________________________________ | |
sudo fallocate -l 10G /media/swapfile | |
sudo chmod 600 /media/swapfile | |
sudo mkswap /media/swapfile | |
sudo swapon /media/swapfile | |
sudo swapon --show | |
_________________________________________________________________ | |
sudo fallocate -l 100G /swapfile_100 | |
sudo chmod 600 /swapfile_100 | |
sudo mkswap /swapfile_100 | |
sudo swapon /swapfile_100 | |
sudo swapon --show |
Author
Mifrill
commented
Feb 29, 2024
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer:latest
How to verify ENV variables
aws ssm get-parameters --names /stg/api-server/CONNECT_API_API_KEY --with-decryption --region eu-west-1 --query "Parameters[0]"."Value" --output text > test.txt
get_env_variable_value() {
docker exec -it c10ba0424d63 env | grep ^API_KEY= > test.txt
}
string="$(get_env_variable_value)"
for (( i=0; i<${#string}; i++ )); do
echo "${string:i:1}"
done
for (( i=0; i<${#string}; i++ )); do
char="${string:i:1}"
ascii_val=$(printf "%d" "'$char") # Get the ASCII value of the character
echo "Character: $char, ASCII: $ascii_val"
done
get_env_variable_value() {
echo "$API_KEY"
}
get_env_variable_value() {
docker exec -it c10ba0424d63 env | grep ^API_KEY=
}
get_env_variable_value() {
cat test.txt
}
if [[ "$(get_env_variable_value)" =~ ^\ +.*\ $ ]]; then
echo "The value of ENV_VARIABLE has spaces around it."
else
echo "The value of ENV_VARIABLE does not have spaces around it."
fi
echo "const axios = require('axios');
axios.get('https://stg.cloud-os.test.aws.gel.ac/issuer-clearinghouse/health')
.then((r) => {
console.log('r.status:', r.status);
})
.catch((e) => {
console.log('e:', e);
});
" > script.js
CREDS=$(aws sts assume-role \
--role-arn arn:aws:iam::715333221097:role/echo-developer-role \
--role-session-name DeveloperSession \
--profile echo-dev)
CREDS=$(aws sts assume-role \
--role-arn arn:aws:iam::715333221097:role/echo-cdk-developer-role \
--role-session-name CDKDeveloperSession \
--profile echo-dev)
export AWS_ACCESS_KEY_ID=$(echo $CREDS | jq -r .Credentials.AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(echo $CREDS | jq -r .Credentials.SecretAccessKey)
export AWS_SESSION_TOKEN=$(echo $CREDS | jq -r .Credentials.SessionToken)
aws sts get-caller-identity
aws ssm start-session --target i-0e015ee2badc5e905 --region eu-west-1
aws ssm get-parameter --region eu-west-1 --name "/cex/dev/privatelink/service-name"
aws ecs list-services --cluster echo-dev --profile echo-dev
aws sts assume-role --role-arn arn:aws:iam::715333221097:role/echo-developer-role --role-session-name DeveloperSession
aws ec2 describe-instances --output json | jq -r '.Reservations[].Instances[] | [.InstanceId, .State.Name, .InstanceType, (.Tags[] | select(.Key=="Name") | .Value)] | @tsv'
aws ecs list-tasks --cluster echo-dev --service-name EchoDevStack-BackendApiServiceBackendApiFargateServiceCOPY
aws ecs execute-command \
--cluster echo-dev \
--task arn:aws:ecs:eu-west-1:715333221097:task/echo-dev/6785647da46d49318f37696a717a8fa7 \
--container echo-backend-api \
--interactive \
--command "/bin/sh"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment