Skip to content

Instantly share code, notes, and snippets.

View D3strukt0r's full-sized avatar
🎯
Focusing on school

Manuele D3strukt0r

🎯
Focusing on school
View GitHub Profile
44 / 60 * 45 = 32.999
44 / 4 * 3 = 33
@D3strukt0r
D3strukt0r / pagination.php
Last active June 12, 2020 16:17
PHP Pagination
<?php
$iShowPostAmount = isset($_GET['show']) ? (int)$_GET['show'] : 5;
$$iItemLimit = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$iTotalItems = (int) getRepliesCount() + 1;
$iAdjacents = 1;
$iNextPage = $iCurrentPage + 1;
$iPreviousPage = $iCurrentPage - 1;
$iPagesCount = ceil($iTotalItems / $iItemLimit);
public class LanguagesString {
private String en;
private String de;
public String getEn() {
return en;
}
public LanguagesString setEn(String en) {
this.en = en;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;
public class Shop {
public static void main(String[] args) {
// Create the products list
ArrayList<Product> productList = new ArrayList<>();
// Create and add product 1
@D3strukt0r
D3strukt0r / start-spigot.sh
Created March 8, 2020 23:38
Download a Spigot version and run
#!/bin/bash
# Verify versions
echo "[ ] Check if Java is available..."
if java -version 2>&1 >/dev/null | grep -q "openjdk version" ; then
echo -e "\e[1A[ \e[32mOK\e[39m ]"
elif java -version 2>&1 >/dev/null | grep -q "java version"; then
echo -e "\e[1A[ \e[32mOK\e[39m ]"
else
echo -e "\e[1A[\e[31mFAIL\e[39m]" >&2

BACKUP DATA FOLDER /opt

for d in */; do
    dir=${d%/}
@D3strukt0r
D3strukt0r / cloudflare-ddns.sh
Created May 7, 2020 18:34
Automatically update your CloudFlare DNS record to the IP, Dynamic DNS for Cloudflare
#!/usr/bin/env bash
# The zone ID of the domain
CF_ZONE_ID=
# The email of the user and the global api key
CF_USER_EMAIL=
CF_GLOBAL_API_KEY=
# A generated API key with the permission "Zone.DNS"
#!/usr/bin/env bash
# SymfonyCloud CLI installer.
set -euo pipefail
CLI_LATEST_VERSION_URL="https://get.symfony.com/cli/LATEST"
CLI_CONFIG_DIR=".symfony"
CLI_EXECUTABLE="symfony"
CLI_TMP_NAME="$CLI_EXECUTABLE-"`date +"%s"`
CLI_NAME="Symfony CLI"
@D3strukt0r
D3strukt0r / delete-all-deployments.sh
Last active September 20, 2020 18:09
Inactives and deletes all deployments on a repository
#!/bin/bash
REPO=
TOKEN=
# https://starkandwayne.com/blog/bash-for-loop-over-json-array-using-jq/
for deployment in $(curl https://api.github.com/repos/$REPO/deployments | jq -r '.[] | @base64'); do
DEPLOYMENT_ID=$(echo "$deployment" | base64 --decode | jq -r '.id')
echo "$DEPLOYMENT_ID"
curl "https://api.github.com/repos/$REPO/deployments/$DEPLOYMENT_ID/statuses" \