Skip to content

Instantly share code, notes, and snippets.

View melbahja's full-sized avatar
🦇
chmod +x bits

Mohamed El Bahja melbahja

🦇
chmod +x bits
View GitHub Profile
@nethoncho
nethoncho / find_network_test.php
Last active November 8, 2019 00:32
PHP: Find Network and Broadcast for given IP and Subnet
#!/usr/bin/php
<?php
$input = new stdClass();
$input->ip = '70.71.72.73';
$input->netmask = '255.255.255.0';
$input->ip_int = ip2long($input->ip);
$input->netmask_int = ip2long($input->netmask);
// Network is a logical AND between the address and netmask
@kasparsd
kasparsd / popular-wp-plugins.php
Created October 5, 2016 19:30
Top 1000 most popular WordPress plugins
@mikemackintosh
mikemackintosh / method_examples.php
Last active February 6, 2020 21:36
Audit Log Parser
<?php
// Include Parser.php - The LogAudit Source
include('Parser.php');
// Create an instance of the Auth Class
// If an argument is passed, it is expecting
// a username.
// @ $arg Not Required
$Audit = new \LogAudit\Auth('sixeightzero');
@radu-gheorghe
radu-gheorghe / traffic.sh
Created November 16, 2012 14:24
bash script for checking out traffic via /proc/net/dev
#!/bin/bash
#shows traffic on the specified device
function human_readable {
VALUE=$1
BIGGIFIERS=( B K M G )
CURRENT_BIGGIFIER=0
while [ $VALUE -gt 10000 ] ;do
VALUE=$(($VALUE/1000))
@cvzi
cvzi / lru.go
Created November 19, 2019 20:21
A LRU "least recently used" cache in golang
// A LRU "least recently used" cache
package lru
import (
"container/list"
"fmt"
"sync"
)
// Cache represents a LRU consisting of a map as an index and a list to hold data and indicate the last recently used queue.
@adliwahid
adliwahid / mirror.sh
Created April 17, 2016 10:27
httrack for mirroring site on archive.org (waybackmachine)
#this is useful for copying snapshotted sites at archive.org
#copied from http://superuser.com/questions/532036/trouble-using-wget-or-httrack-to-mirror-archived-website
#replace ${wayback_url} with the full URL i.e. http://web.archive.org/web/20020705161639/http://kict.iiu.edu.my/
#replace ${domain_name} with the domain name of the site you'r mirroring without the 'http', so kict.iiu.edu.my
httrack\
${wayback_url}\
'-*'\
'+*/${domain_name}/*'\
-N1005\
--advanced-progressinfo\
@renchap
renchap / README.md
Last active October 12, 2022 17:14
One-line certificate generation/renews with Letsencrypt and nginx

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
@dungsaga
dungsaga / sync-time.sh
Last active December 14, 2022 22:15
sync local clock in without NTP in Linux, MacOS, Windows
# I want to sync the local clock but don't have access to any NTP server.
# Website https://time.is tells me the time difference of my system clock and I can manually adjust the local clock.
# But then I recall that a HTTP response often contains a date header with current time in GMT timezone.
# I'll use it to set the system clock with the precision of 1 or 2 seconds.
# When I need more accurate time, I can use `datetime` (or `utc_datetime`) from `http://worldtimeapi.org/api/ip.txt`
# time from worldtimeapi.org has millisecond precision, you can use it to compare with your system time:
date -uIns && time curl -s http://worldtimeapi.org/api/ip.txt | sed -n 's/^utc_datetime://p'
date -Ins && time curl -s http://worldtimeapi.org/api/ip.txt | sed -n 's/^datetime://p'
@ayubmalik
ayubmalik / gpg-encrypt.go
Last active March 3, 2023 08:49
Golang encrypt file using GPG openpgp. Use standard go libs.
package main
/**
Example hack to encrypt a file using a GPG encryption key. Works with GPG v2.x.
The encrypted file e.g. /tmp/data.txt.gpg can then be decrypted using the standard command
gpg /tmp/data.txt.gpg
Assumes you have **created** an encryption key and exported armored version.
You have to read the armored key directly as Go cannot read pubring.kbx (yet).
@googleinurl
googleinurl / facecheck2.0.php
Last active April 20, 2023 18:59
Verificação de usuários Facebook 2.0
<?php
/*
E d i ç ã o - 2.0 / 29-09-2015
--------------------------------------------------------------------------------
[+] AUTOR: Cleiton Pinheiro / Nick: googleINURL
[+] Blog: http://blog.inurl.com.br
--------------------------------------------------------------------------------
*/