Skip to content

Instantly share code, notes, and snippets.

#!bin/bash
DOCKER_PIDS=$(docker ps -a -q)
if [ -n "$DOCKER_PIDS" ]; then
docker stop $DOCKER_PIDS && docker rm $DOCKER_PIDS
fi
@AdnaneX
AdnaneX / nodejs-tcp-example.js
Created February 12, 2019 20:13 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@AdnaneX
AdnaneX / MySQL Replication Check
Created March 3, 2019 20:17
Mysql Replication Check script. You can put this in a cron.
#!/bin/bash
### VARIABLES ### \
EMAIL=""
SERVER=$(hostname)
MYSQL_CHECK=$(mysql -e "SHOW VARIABLES LIKE '%version%';" || echo 1)
LAST_ERRNO=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Last_Errno" | awk '{ print $2 }')
SECONDS_BEHIND_MASTER=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G"| grep "Seconds_Behind_Master" | awk '{ print $2 }')
IO_IS_RUNNING=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Slave_IO_Running" | awk '{ print $2 }')
SQL_IS_RUNNING=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Slave_SQL_Running" | awk '{ print $2 }')
@AdnaneX
AdnaneX / updateOrInstallPostMan.sh
Created July 25, 2019 10:27
sh script for update or install postman latest version
#!/bin/bash
ICON_PATH=~/.local/share/applications/postman.desktop
LN_PATH=/usr/bin/postman
cd ~/Downloads
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
tar -xzf postman.tar.gz -C /opt
@AdnaneX
AdnaneX / Confirm.vue
Created October 21, 2019 16:13 — forked from eolant/Confirm.vue
Vuetify Confirm Dialog component that can be used locally or globally
<template>
<v-dialog v-model="dialog" :max-width="options.width" :style="{ zIndex: options.zIndex }" @keydown.esc="cancel">
<v-card>
<v-toolbar dark :color="options.color" dense flat>
<v-toolbar-title class="white--text">{{ title }}</v-toolbar-title>
</v-toolbar>
<v-card-text v-show="!!message" class="pa-4">{{ message }}</v-card-text>
<v-card-actions class="pt-0">
<v-spacer></v-spacer>
<v-btn color="primary darken-1" text @click.native="agree">Yes</v-btn>
@AdnaneX
AdnaneX / DialogLoader.vue
Created October 21, 2019 16:13 — forked from tripflex/DialogLoader.vue
Vuetify Dialog Loader Component (with SnackBar) component that can be used locally or globally ( https://github.com/tripflex/VuetifyDialogLoader )
<template>
<div>
<!-- Using hide-overlay below allows for clicking while progress showing-->
<v-dialog
v-model="dialog"
persistent
:width="options.width"
v-bind:style="{ zIndex: options.zIndex }"
>
<v-card
DBNAME=<database_name>
TABLE=<table_name>
FNAME=/path/to/output/dir/$(date +%Y.%m.%d)-$DBNAME.csv
#(1)creates empty file and sets up column names using the information_schema
mysql -u <username> -p<password> $DBNAME -B -e "SELECT COLUMN_NAME FROM information_schema.COLUMNS C WHERE table_name = '$TABLE';" | awk '{print $1}' | grep -iv ^COLUMN_NAME$ | sed 's/^/"/g;s/$/"/g' | tr '\n' ',' > $FNAME
#(2)appends newline to mark beginning of data vs. column titles
echo "" >> $FNAME
@AdnaneX
AdnaneX / postman-pre-request-to-get-token.js
Last active July 4, 2020 00:33 — forked from bcnzer/postman-pre-request.js
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: pm.environment.get('api_url'),
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:pm.environment.get('client_id'),
client_secret:pm.environment.get('client_secret'),
@AdnaneX
AdnaneX / FlutterStack.dart
Created August 7, 2020 23:58 — forked from lvh1g15/FlutterStack.dart
Flutter Material Custom Card Stack View
class HousePickerView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new GradientAppBar('Houses',
new ListView(
children: <Widget>[
new HouseListTile(url: [
'https://statusandphoto.weebly.com/uploads/6/0/1/5/60158603/8347592_orig.png',
'http://globalmedicalco.com/photos/globalmedicalco/20/98181.jpg',
'https://allinonetricks.com/wp-content/uploads/2017/08/5-7.png'
@AdnaneX
AdnaneX / time_ago_since_now.dart
Created August 10, 2020 21:47 — forked from DineshKachhot/time_ago_since_now.dart
Flutter Time ago calculator
static String timeAgoSinceDate(String dateString, {bool numericDates = true}) {
DateTime date = DateTime.parse(dateString);
final date2 = DateTime.now();
final difference = date2.difference(date);
if ((difference.inDays / 365).floor() >= 2) {
return '${(difference.inDays / 365).floor()} years ago';
} else if ((difference.inDays / 365).floor() >= 1) {
return (numericDates) ? '1 year ago' : 'Last year';
} else if ((difference.inDays / 30).floor() >= 2) {