Skip to content

Instantly share code, notes, and snippets.

/*
Minecraft Server Status code for Discord.js
Author: https://github.com/mariolatiffathy
Usage: %mcserver IP:PORT | if PORT is not specified then 25565 will be used.
*/
const { Client, Util } = require('discord.js');
const Discord = require('discord.js');
const client = new Client();
var prefix = "%";
<?php
function ProtectMyCode($html) {
$complex_html = str_replace(array("\r","\n"),"",$html);
$encoded = base64_encode($complex_html);
session_start();
$_SESSION['jsvar'] = chr(rand(65,90)).chr(rand(65,90)).chr(rand(65,90)).chr(rand(65,90)).chr(rand(65,90)).chr(rand(65,90)).chr(rand(65,90)).chr(rand(65,90)).chr(rand(65,90));
$_SESSION['divid'] = chr(rand(65,90)).chr(rand(65,90)).chr(rand(65,90)).chr(rand(65,90)).chr(rand(65,90)).chr(rand(65,90)).chr(rand(65,90)).chr(rand(65,90)).chr(rand(65,90));
echo '
<script>
var '.$_SESSION['jsvar'].' = atob("'.$encoded.'");
@oddmario
oddmario / ThreadSafeWriter.java
Created September 7, 2018 20:36
Thread safe writer for Java
public static void ThreadsafeWriter(String text, String file) throws IOException {
/*
@author: mariolatiffathy
@source: gist.github
@description: A thread-safe writer that you can use to write to the same file through multiple threads.
@usage: ThreadsafeWriter(String: text, String: file)
@example: ThreadsafeWriter("Hello World", "File.txt")
@methodType: public, static
*/
String nodeValue = text;
@oddmario
oddmario / Delete all messages in Discord channel or DM.js
Last active July 28, 2019 17:28
Delete all messages in Discord channel/DM
function sleep(milliseconds) {
var start = new Date().getTime();
while (true) {
if ((new Date().getTime() - start) > milliseconds) {
break;
}
}
}
function deleteMessages() {
@oddmario
oddmario / drive.php
Last active June 17, 2024 16:30
A PHP script to give a direct download link for a Google Drive file. (bypasses the Virus scan warning for big files)
<?php
// NOTE: Also follow this answer: https://stackoverflow.com/a/2429162/8524395
set_time_limit(0);
$requireds = array("fid", "fname");
foreach($requireds as $required) {
if( !isset($_GET[$required]) || empty($_GET[$required]) ) {
die("error.");
}
}
$gdrive_api_key = ""; // Not necessary to be API key for the account which uploaded the file. The file just have to be enabled for sharing with anyone.
@oddmario
oddmario / scrape_numbers.py
Created May 18, 2020 10:50
A Python script to scrape the mobile numbers from the famous SMS receiving sites. You can use this script to block those numbers in your site.
import phonenumbers
import requests
import threading
import time
import string
import random
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
@oddmario
oddmario / server.js
Last active February 23, 2021 17:02
Sample WebSocket server
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 25595 });
wss.on('connection', function connection(ws, req) {
var timer;
var firstMessageSent = false;
var areYouSureAsked = false;
const ip = req.socket.remoteAddress;
"""
https://github.com/0sir1ss/Carbon
"""
import ast
import re
import random
import io
import tokenize
import os
import zlib, base64
@oddmario
oddmario / AndroidManifest.xml
Last active June 27, 2023 13:41
Send push notifications in an Android app (Java) using Firebase Cloud Messaging
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
@oddmario
oddmario / Backend example (NodeJS).js
Last active June 29, 2023 13:00
Send push notifications on your website using Firebase Cloud Messaging
const bodyparser = require("body-parser");
const express = require("express");
var admin = require("firebase-admin");
var serviceAccount = require("./serviceAccountFile.json");
// init
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),