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
# Create this file as subdomain.mydomain.tld.conf in /etc/apache2/sites-available/ | |
<IfModule mod_ssl.c> | |
<VirtualHost *:80> | |
ServerName subdomain.mydomain.tld | |
Redirect permanent / https://subdomain.mydomain.tld/ | |
</VirtualHost> | |
<VirtualHost *:443> | |
# Put here your email if you want |
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
def isInteger(x): | |
try: | |
return (int(x) == 0 or int(x) % int(x) == 0) | |
except: | |
return False |
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
#!/usr/bin/env python | |
import sys | |
def isPositiveInteger(x): | |
try: | |
return (int(x) == 0 or int(x) % int(x) == 0 and int(x)>0) | |
except: | |
return False |
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
import json | |
with open('myfile.json') as handle: | |
dictdump = json.loads(handle.read()) | |
for key, value in dictdump.items(): | |
print(key + " " + value) |
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
#!/usr/bin/env python | |
filepath = 'file.txt' | |
with open(filepath) as fp: | |
line = fp.readline() | |
while line: | |
print(line.strip()) | |
line = fp.readline() |
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
########################## | |
# Upgrade to LTS version # | |
########################## | |
sudo apt-get clean | |
sudo apt-get update | |
sudo apt-get dist-upgrade -y | |
sudo do-release-upgrade | |
sudo apt-get autoremove -y | |
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
---------------------------------------------------------------- | |
Redirect ALL traffic | |
---------------------------------------------------------------- | |
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{HTTPS} off | |
RewriteCond %{HTTP:X-Forwarded-Proto} !https | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
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
@PUT | |
@Consumes(MediaType.APPLICATION_JSON) | |
public Response myMethod(Myobject myobject) throws MappingExceptionHandler{ | |
/* code */ | |
} | |
--------------------------------------------------------------------------------------------------- | |
import javax.ws.rs.core.Response; | |
import javax.ws.rs.ext.ExceptionMapper; | |
import javax.ws.rs.ext.Provider; |
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
Options +FollowSymlinks | |
RewriteEngine on | |
RewriteCond %{REQUEST_URI} !/offline.html$ | |
RewriteRule $ /offline.html [R=302,L] |
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
# Add this into your VirtualHost config file | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteRule ^/$ / [R] | |
</IfModule> |