Skip to content

Instantly share code, notes, and snippets.

View jimfilippou's full-sized avatar
:shipit:

Dimitrios Filippou jimfilippou

:shipit:
View GitHub Profile
@jimfilippou
jimfilippou / revive.py
Last active September 22, 2017 11:36
Checks if Redis instance is running
from fabric.api import run,settings
import time, datetime
# host="x.x.x.x"
def redis():
with settings(warn_only=True, host_string=host, user="server1", key_filename="cert.pem"):
r = run("redis-cli ping", True)
if r == "PONG":
@jimfilippou
jimfilippou / backend.bat
Last active June 8, 2020 17:49
A list of useful and time saving batch files for rapid Flask application development.
@echo off
cd %USERPROFILE%/Desktop/Projects/Bandicoot 2/env/Scripts
call activate.bat
cd %USERPROFILE%/Desktop/Projects/Bandicoot 2
IF "%1"=="public" GOTO PUBLIC
python manage.py runserver
:PUBLIC:
python manage.py runserver --host 0.0.0.0
@jimfilippou
jimfilippou / hotel-shitty-bed.py
Created October 8, 2017 14:21
No coins arround? figure out who is gonna sleep on the shitty bed at the hotel, using python
import random, os
def main():
while(True):
print "Press enter to choose who is gonna sleep on the shitty bed."
c = raw_input()
if c == ".exit":
break
else:
@jimfilippou
jimfilippou / clean.sh
Created October 15, 2017 12:22
Clear cached ram
# To free pagecache:
# echo 1 > /proc/sys/vm/drop_caches
# To free dentries and inodes:
# echo 2 > /proc/sys/vm/drop_caches
# To free pagecache, dentries and inodes:
# echo 3 > /proc/sys/vm/drop_caches
sudo sync && sudo sysctl -w vm.drop_caches=3
@jimfilippou
jimfilippou / rename.sh
Created October 20, 2017 18:53
Renames all files within directory
for file in *.html; do mv "$file" "${file/.html/.php}"; done
@jimfilippou
jimfilippou / rename.py
Created February 6, 2018 21:17
Convert all PNGs to JPGs in current directory faaaaaaaast
import os
if __name__ == '__main__':
for subdir, dirs, files in os.walk(os.getcwd()):
for file in files:
x = os.path.join(subdir, file)
if x.endswith("png"):
# Convert image
print "Converting {}".format(x)
@jimfilippou
jimfilippou / whatismyip.sh
Created April 4, 2019 17:28
Easily find your IP on a Mac 💻
ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'
@jimfilippou
jimfilippou / ipv4.go
Created December 28, 2019 17:40
Returns IPv4 address iterating through all interfaces
func externalIP() (string, error) {
ifaces, err := net.Interfaces()
if err != nil {
return "", err
}
for _, iface := range ifaces {
if iface.Flags&net.FlagUp == 0 {
continue // interface down
}
if iface.Flags&net.FlagLoopback != 0 {
@jimfilippou
jimfilippou / ds.sh
Created February 12, 2020 11:25
Removes all .DS_Store files from the working directory
# Removes all .DS_Store files from the working directory
find . -name ".DS_Store" -delete
interface Virus {
public fun mutate()
public fun spread() {
println("Spreading the virus...")
}
}
class CoronaVirus: Virus {
override fun mutate() {
println("Mutating the corona virus...")