Skip to content

Instantly share code, notes, and snippets.

@jaysonrowe
jaysonrowe / postfix.php
Created March 22, 2012 18:50
Parse e-mail with PHP
#!/usr/bin/php -q
<?php
// get mail via stdin
$email = file_get_contents("php://stdin");
// handle email
$lines = explode("\n", $email);
// set empty vars and explode message to variables
@aamnah
aamnah / lamp.sh
Last active June 22, 2024 16:03
Bash script to install Apache, MySQL and PHP as well as PHPMyAdmin and some tweaks. For Debian and Ubuntu. To run, copy the script to the server and run ``bash lamp.sh``
#!/bin/sh
#######################################
# Bash script to install an AMP stack and PHPMyAdmin plus tweaks. For Debian based systems.
# Written by @AamnahAkram from http://aamnah.com
# In case of any errors (e.g. MySQL) just re-run the script. Nothing will be re-installed except for the packages with errors.
#######################################
#COLORS
@irazasyed
irazasyed / manage-etc-hosts.sh
Created March 7, 2015 09:16
Bash Script to Manage /etc/hosts file for adding/removing hostnames.
#!/bin/sh
# PATH TO YOUR HOSTS FILE
ETC_HOSTS=/etc/hosts
# DEFAULT IP FOR HOSTNAME
IP="127.0.0.1"
# Hostname to add/remove.
HOSTNAME=$1
@bueckl
bueckl / wget
Last active October 11, 2023 08:05
Wget examples
#Spider Websites with Wget – 20 Practical Examples
Wget is extremely powerful, but like with most other command line programs, the plethora of options it supports can be intimidating to new users. Thus what we have here are a collection of wget commands that you can use to accomplish common tasks from downloading single files to mirroring entire websites. It will help if you can read through the wget manual but for the busy souls, these commands are ready to execute.
1. Download a single file from the Internet
wget http://example.com/file.iso
2. Download a file but save it locally under a different name
wget ‐‐output-document=filename.html example.com
@banghasan
banghasan / PertamaBot.php
Last active December 23, 2022 14:52
Sample Bot Telegram - PHP
<?php
/*
BOT PENGANTAR
Materi EBOOK: Membuat Sendiri Bot Telegram dengan PHP
Ebook live http://telegram.banghasan.com/
oleh: bang Hasan HS
@banghasan
banghasan / SendTestBot.php
Last active March 20, 2023 00:30
Test Send Message Pakai PHP - Curl
<?php
/*
Simple File untuk Ngetes Send Pesan ke Bot
Memiliki banyak kegunaan dan tujuan
misalnya ngetes pesan dengan format tertentu, line break, char khusus, dll.
bisa dipergunakan juga untuk test hosting, cronjob, dan segala test lainnya.
Jika menggunakan mode GET :
@weihanglo
weihanglo / draw_gradient_pillow.py
Last active May 8, 2024 09:09
Draw gradient color with Pillow
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from PIL import Image, ImageDraw
im = Image.open('img_original.png')
def interpolate(f_co, t_co, interval):
det_co =[(t - f) / interval for f , t in zip(f_co, t_co)]
for i in range(interval):
@aamnah
aamnah / server.js
Created March 5, 2017 15:01
Basic API using Nodejs + Express + MongoDB (less than 100 lines of code, adds + finds vehicles)
/*
path: server.js
*/
// Require shit
const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
// Let's import our Vehicle model
@harrypujols
harrypujols / execute.js
Created May 9, 2017 19:48
Execute shell command in javascript
#!/usr/bin/env node
function execute(command) {
const exec = require('child_process').exec
exec(command, (err, stdout, stderr) => {
process.stdout.write(stdout)
})
}
@crittermike
crittermike / wget.sh
Last active March 26, 2024 22:49
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.