Skip to content

Instantly share code, notes, and snippets.

View Darksider3's full-sized avatar
:shipit:
Focused

darksider3 Darksider3

:shipit:
Focused
View GitHub Profile
@Darksider3
Darksider3 / trapmine.sh
Created August 11, 2014 00:58
Trapmine in Shellscripts
count=0
things="0 1 0 0 1"
for i in $things;
do
if [ $i == "1" ]; then
(( count++ ))
fi
done
@Darksider3
Darksider3 / up.sh
Created December 9, 2015 15:19
Go N directorys up instantly
#!/bin/bash
#Go N directories up (N=Number)
up()
{
str=""
count=0
while [ "$count" -lt "$1" ];
do
str=$str"../"
let count=count+1

Let's say you have a Bash shell script, and you need to run a series of operations on another system (such as via ssh). There are a couple of ways to do this.

First, you can stage a child script on the remote system, then call it, passing along appropriate parameters. The problem with this is you will need to manually keep the remote script updated whenever you change it -- could be a bit of a challenge when you have something to execute on a number of remote servers (i.e., you have a backup script running on a central host, and it needs to put remote databases in hot backup mode before backing them up).

Another option is to embed the commands you want to run remotely within the ssh command line. But then you run into issues with escaping special characters, quoting, etc. This is ok if you only have a couple commands to run, but if it is a complex piece of Bash code, it can get a bit unwieldy.

So, to solve this, you can use a technique called rpcsh -- rpc in shell script, as follows:

First, place th

@Darksider3
Darksider3 / killer.sh
Last active May 22, 2016 07:51
Kill all Proccess with Name $1.
kill $(ps aux | grep $1 | awk '{print $2}') &> /dev/null
@Darksider3
Darksider3 / Install.md
Last active February 6, 2017 10:38
install.md skeletton for tomatoes

Install Tomateos

Required dependencies

Required dependencies trough Packet-Managers/Manual installation:

If you wan't to install it with RVM, you will need RVM of course too.

Install ruby with RVM(works with nearly all distros)
--- index.js 2017-02-06 19:44:31.735648624 +0100
+++ index.js 2017-02-06 19:41:10.360665296 +0100
@@ -101,7 +101,7 @@
function handleError(err, res) {
let errorMessage;
if (res && res.status === 404) {
- errorMessage = '404: README for the specified repository not found.';
+ errorMessage = '404: File for the specified repository not found.';
} else if (err) {
errorMessage = err;
@Darksider3
Darksider3 / 01-README_MONITOR_TROUGH_HTTP_REQUEST.md
Last active February 17, 2017 21:57
Monitor own internet with frequently downloading a high available website(like google)

Simply launch it.

For the watchdog(changeserv.py), use watchdog.py ./src

On Windows we utilize the kernel32 functions to get a handle&info to our current CMD.exe, and then change the font colors. In detail, we're unpacking all data belonging to the window attributes(wattr) and then change our specific one, wherewith we change the options to display text(SetConsoleTextAttribute)

For Linux ANSI (Escaping Codes/)Color Codes are used. See how simple it could be? Isn't that nice? HEH?!?!

Directory structure:

@Darksider3
Darksider3 / Email Server (Linux, Unix, Mac).md
Created January 27, 2018 09:48 — forked from raelgc/Email Server (Linux, Unix, Mac).md
Setup a Local Only Email Server (Linux, Unix, Mac)

Setup a Local Only Email Server (Linux, Unix, Mac)

1 - Point localhost.com to your machine

Most of programs will not accept an email using just @localhost as domain. So, edit /etc/hosts file to make the domain localhost.com point to your machine, including this content to the file:

127.0.0.1 localhost.com

2 - Install Postfix

@Darksider3
Darksider3 / README.md
Last active March 5, 2018 14:06
Vanessa PC-Parts

Was man im allgemeinen, immer braucht.

"x"=>Vorhanden. Leer=>Nicht vorhanden.

  • Mainboard
  • RAM(spezifische Version, sprich DDR1-4/SDDR)
  • Gehäuse (mein altes, steht im Spielzimmer)
  • Netzteil. Stromzufuhr.^^
  • CPU-Kühler. Sonst brennt die irgendwann unter last durch
  • Grafikkarte.

optional:

if (!document.querySelectorAll) {
document.querySelectorAll = function (selectors) {
var style = document.createElement('style'), elements = [], element;
document.documentElement.firstChild.appendChild(style);
document._qsa = [];
style.styleSheet.cssText = selectors + '{x-qsa:expression(document._qsa && document._qsa.push(this))}';
window.scrollBy(0, 0);
style.parentNode.removeChild(style);