Skip to content

Instantly share code, notes, and snippets.

View parsibox's full-sized avatar

Mohsen Davari parsibox

View GitHub Profile
@johndacosta
johndacosta / get-diskspace.ps1
Created July 25, 2013 14:46
Get Disk Space Information via Powershell in JSON Format
Get-WmiObject win32_volume | Select-Object SystemName,Name, BlockSize, Capacity, FreeSpace, DriveLetter , @{Name="CapacityGB";Expression={[math]::round($_.Capacity/1GB,2)}}, @{Name="FreeSpaceGB";Expression={[math]::round($_.FreeSpace/1GB,2)}} , @{Name="FreeSpacePercent";Expression={[math]::round(($_.FreeSpace/($_.Capacity*1.00))*100.00,2)}} , @{Name="Date";Expression={$(Get-Date -f s)}}| Sort-Object Name | Convertto-JSON
# This format will allow you to filter on drive name and select a remote computer.
# Get-WmiObject win32_volume -ComputerName ServerName | Where-Object {$_.label -match "S\:.*"} | Select-Object SystemName,Name, BlockSize, Capacity, FreeSpace, DriveLetter , @{Name="CapacityGB";Expression={[math]::round($_.Capacity/1GB,2)}}, @{Name="FreeSpaceGB";Expression={[math]::round($_.FreeSpace/1GB,2)}} , @{Name="FreeSpacePercent";Expression={[math]::round(($_.FreeSpace/($_.Capacity*1.00))*100.00,2)}} , @{Name="Date";Expression={$(Get-Date -f s)}}| Sort-Object Name | Convertto-JSON
@RobThree
RobThree / ratelimiter.php
Last active December 16, 2019 21:34
Simple, rude, rate limiter (using memcache).
<?php
/* Very simple, crude, rate limiter */
/*
Assumes _MEMCACHEDSITEPREFIX, _MEMCACHEDHOST and _MEMCACHEDPORT are `defined`:
define('_MEMCACHEDHOST', '127.0.0.1');
define('_MEMCACHEDPORT', 11211);
define('_MEMCACHEDSITEPREFIX', 'mysite');
*/
@skaag
skaag / limt_req_zone_whitelist
Created March 12, 2014 19:17
A way to whitelist certain IP ranges from limit_req_zone in nginx
geo $limited {
default 1;
# Wordpress Jetpack ranges:
192.0.0.0/16 0;
66.135.0.0/16 0;
66.155.0.0/16 0;
76.74.0.0/16 0;
}
@Whitexp
Whitexp / facebok ip list
Last active June 20, 2025 21:35
facebook ip list
31.13.24.0/21
31.13.64.0/19
31.13.64.0/24
31.13.69.0/24
31.13.70.0/24
31.13.71.0/24
31.13.72.0/24
31.13.73.0/24
31.13.75.0/24
31.13.76.0/24
@brandonmwest
brandonmwest / example.cs
Last active January 7, 2025 07:39
Generating base64-encoded Authorization headers in a variety of languages
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", username, password))));
@masbog
masbog / autorreconnect-pptp.sh
Created August 6, 2014 16:45
autoreconnect-pptp
#!/bin/bash
#!/bin/sh
if ping -qnw1 -c1 your_ip_server_from_ppp0 2>&1 >/dev/null
then
echo "Link is up"
else
echo "Link is down, trying to reconnecting..."
pppd call pptp_config_name
fi
package main
import (
"fmt"
"github.com/ugorji/go/codec"
)
var mh = codec.MsgpackHandle{}
@xeoncross
xeoncross / connect-killer.sh
Created February 2, 2015 23:17
Process killer
#!/bin/bash
# loop over the connect processes and kill them
ps -aux | grep "connect[.]js" | awk '{ print $2 " " $3}' | while read -r line; do
line=($line)
A_PID=${line[0]}
A_USAGE=${line[1]%.*}
echo "PID: $A_PID"
@srsbiz
srsbiz / gist:8373451ed3450c0548c3
Last active December 24, 2022 15:01
php AES-128-CBC mcrypt & openssl
<?php
function encrypt_mcrypt($msg, $key, $iv = null) {
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
if (!$iv) {
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
}
$pad = $iv_size - (strlen($msg) % $iv_size);
$msg .= str_repeat(chr($pad), $pad);
$encryptedMessage = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $msg, MCRYPT_MODE_CBC, $iv);
return base64_encode($iv . $encryptedMessage);
@manjeshpv
manjeshpv / pinger
Created June 19, 2015 08:10
Bash Shell Script to Ping a ip/host continuously to keep connectivity
#/bin/sh
# Description: Cyberoam Ping Script
# save in /etc/init.d/pinger
# start : $ server pinger start
# status : $ server pinger status
# stop : $ server pinger stop
# Description: Cyberoam Ping Script
address=192.168.220.250
do_start()
{