This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function checkport { | |
if nc -zv -w30 $1 $2 <<< '' &> /dev/null | |
then | |
echo "[+] Port $1/$2 is open" | |
else | |
echo "[-] Port $1/$2 is closed" | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
$userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)'; | |
$target_url = $argv[1] ; | |
if( !$target_url ) { | |
echo PHP_EOL."You'll have to provide a full url".PHP_EOL; | |
exit(1); | |
} | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is an example how to put an arduino board into deep sleep to save on battery power and | |
// periodically wake up to run some logic. Ideal for sensor stations like plant moisture sensors. | |
#include "Arduino.h" | |
#include <avr/sleep.h> | |
#include <avr/power.h> | |
#include <avr/wdt.h> | |
// Blink Before sleeping | |
#define LED_PIN (13) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// An example on how to parse massive XML files with PHP by chunking it up to avoid running out of memory | |
// Open the XML | |
$handle = fopen('file.xml', 'r'); | |
// Get the nodestring incrementally from the xml file by defining a callback | |
// In this case using a anon function. | |
nodeStringFromXMLFile($handle, '<item>', '</item>', function($nodeText){ | |
// Transform the XMLString into an array and |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function HowManyIsEnough(n: number) : number { | |
return n + 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original blog post: <https://mnx.io/blog/a-proper-server-naming-scheme/> | |
# Original word list: <http://web.archive.org/web/20091003023412/http://tothink.com/mnemonic/wordlist.txt> | |
# Sample usage: `curl <gist> | tail --lines +4 | shuf | head --lines 1` | |
acrobat | |
africa | |
alaska | |
albert | |
albino | |
album | |
alcohol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* ContentAwareImage | |
* | |
* @author stig | |
*/ | |
class ContentAwareImage { | |
protected static $start_time = 0.0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Installation: curl -o /usr/bin/diskspace.sh "https://gist.githubusercontent.com/stojg/867224/raw" && chmod +x /usr/bin/diskspace.sh | |
du -xsk ./* | sort -n | awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t",int(x*10)/10,pref[y],$0); } { for (i=2; i<=NF; i++) printf "%s ", $i; printf "\n"; } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This script will drop all the databases that contains this string 'tmpdb'. | |
* Those databases are likely to be left over from a SilverStripe test run | |
* Usage: Make sure you change the db connection string below and run the | |
* script like: | |
* php remove-tmp-db.php | |
*/ | |
// Change this to your db connection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
NewerOlder