Skip to content

Instantly share code, notes, and snippets.

@gleero
gleero / mssh
Last active October 11, 2023 07:56
#!/usr/bin/perl
$iport = int(rand(40000)) + 10000;
$first = 1;
foreach (@ARGV) {
if (/^--port=/) {
$args = "$_";
$args =~ /port=([0-9]+)?/;
$iport = int($1);
@gleero
gleero / uart.sh
Created January 30, 2019 19:50
Mac UART command
#!/bin/bash
echo "Waiting for the UART..."
while true; do
SERIAL="$(ls /dev/tty* | grep usbserial)"
if [ -n "$SERIAL" ]; then
screen "$SERIAL" 115200
fi
sleep 1
done
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Yoba</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@gleero
gleero / gist:5ac2b3340cf0194209ce
Created October 8, 2014 13:57
Чистка и реиндекс
for f in *.db; do sqlite3 $f "VACUUM; REINDEX;"; done
#!/bin/bash
#################################
str="Привет, наркомания"
#################################
# Карта цветов
len=`echo $str | wc -c`
from gi.repository import GLib, Gio, GObject
import time
def slow_stuff(job, cancellable, user_data):
print "Slow!"
for i in xrange(5):
print "doing slow stuff..."
time.sleep(0.5)
print "finished doing slow stuff!"
return False # job completed
@gleero
gleero / gist:7562662
Created November 20, 2013 12:53
Файл: ~/dotfiles/private/bash_profile.sh Либо можно скопировать это добро напрямую в ~/.bash_profile или в ~/.bashrc
# Private Bash Profile
# Can be used for other settings you don’t want to commit
echo ""
echo "$YELLOW Hostname$NOCOLOR: $WHITE`hostname`$NOCOLOR"
echo "$YELLOW Inet IP$NOCOLOR: $WHITE`ip`$NOCOLOR"
echo "$YELLOW Local IP$NOCOLOR: $WHITE`localip`$NOCOLOR"
echo "$YELLOW Uptime$NOCOLOR: $WHITE`uptime | awk -F 'up ' '{ print $2 }' | awk -F ',' '{ print $1 }'`$NOCOLOR"
echo "$YELLOW SSD usage$NOCOLOR: $WHITE`df / | awk '{print $5}' | grep "%"`$NOCOLOR"
echo "$YELLOW HDD usage$NOCOLOR: $WHITE`df /Volumes/HDD | awk '{print $5}' | grep "%"`$NOCOLOR"
#!/bin/bash
if echo "$1" | grep ":" > /dev/null; then
srv="`echo \"$1\" | awk -F\: '{ print \$1}'`"
pth="`echo \"$1\" | awk -F\: '{ print \$2}'`"
cmd="cd $pth;"
else
srv="$1"
fi
cmd="$cmd cat | bash"
cat $2 | ssh "$srv" "$cmd"