Skip to content

Instantly share code, notes, and snippets.

View flotwig's full-sized avatar

Zach Bloomquist flotwig

View GitHub Profile
<?php
ini_set('xdebug.max_nesting_level', 10000000000000000000000000000000);
$set = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','1','2','3','4','5','6','7','8','9','0','@','!','#','$','%','^','&','*','(',')','-',' ','+','-');
$set = array_merge($set,$set,$set,$set,$set,$set,$set,$set,$set,$set,$set,$set,$set,$set,$set,$set,$set,$set);
$results = array();
gen_nos($set,$results);
function gen_nos(&$set, &$results) {
for($i=0; $i<count($set); $i++) {
$results[] = $set[$i];
$tempset = $set;
@flotwig
flotwig / gist:3591447
Created September 1, 2012 23:44
bool isup(str $server, int $port) // check to see if a server is reachable
function isup($server,$port=80) {
if ($port==80||$port==2222||$port==2083) {
$up = @file_get_contents('http://' . $server . ':' . $port);
if (!$up) {
$up = @file_get_contents('http://' . $server . ':' . $port);
}
} else {
$up = @fsockopen($server, $port, $errno, $errstr, 2);
if (!$up) {
$up = @fsockopen($server, $port, $errno, $errstr, 2);
@flotwig
flotwig / digresults.txt
Created September 19, 2012 20:29
dig -t SRV @ns1.niftyhost.us _minecraft._tcp.seang96.n1fty.com
; <<>> DiG 9.7.3 <<>> -t SRV @ns1.niftyhost.us _minecraft._tcp.seang96.n1fty.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28120
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;_minecraft._tcp.seang96.n1fty.com. IN SRV
@flotwig
flotwig / reddit-function.php
Created October 6, 2012 18:22
A simple function to retrieve results from reddit's API
<?php
// example usage:
// redditApi('user/flotwig'); will return an array with information about me
// redditApi('r/breakingbad'); will return an array of info about r/breakingbad
function redditApi($call,$domain='www.reddit.com') {
$url = 'http://' . $domain . '/' . $call . '.json';
if (function_exists('curl_init')) { // not all PHP installs have cURL
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($ch,CURLOPT_USERAGENT,'/u/flotwig'); // for stats
@flotwig
flotwig / check.php
Last active July 1, 2021 13:54
Minecraft Server List Properties Example A concise, over-commented, efficiently-coded example for pinging a Minecraft server and retrieving its status. No error checking.
<?php
function pingMCServer($server,$port=25565,$timeout=2){
$socket=socket_create(AF_INET,SOCK_STREAM,getprotobyname('tcp')); // set up socket holder
socket_connect($socket,$server,$port); // connect to minecraft server on port 25565
socket_send($socket,chr(254).chr(1),2,null); // send 0xFE 01 -- tells the server we want pinglist info
socket_recv($socket,$buf,3,null); // first 3 bytes indicate the len of the reply. not necessary but i'm not one for hacky socket read loops
$buf=substr($buf,1,2); // always pads it with 0xFF to indicate an EOF message
$len=unpack('n',$buf); // gives us 1/2 the length of the reply
socket_recv($socket,$buf,$len[1]*2,null); // read $len*2 bytes and hang u[
$data=explode(chr(0).chr(0),$buf); // explode on nul-dubs
@flotwig
flotwig / why-snoonet.md
Last active July 28, 2020 16:39
Why should I use Snoonet over a network like Freenode or EFNet?
  • Snoonet is a network run by redditors, for redditors.
  • Thousands of redditors are already on Snoonet every day. Hundreds of subreddits are here as well. It's a centralized hub for redditors.
  • We can provide better security and support, because we focus primarily on reddit users and reddit communities.
  • Channel bots created specifically for redditors.
    • rAnnouncer - automatically posts to the IRC channel when there is a new message in the subreddit
    • RedditBot - allows users to view information about subreddits from IRC - karma, subscribers, mods
    • AutoFalc0n - community-accessible CloudBot, provides Googling, link announcement, and most common bot functions
    • memebot - provides a way to quickly create meme pictures - http://i.imgur.com/GYNG7cK.jpg
  • Priority enforced for reddit nicks and channels - no longer have to use a "#reddit-subredditname" channel format, simply "#subredditname" will do. Also, if you own the username on reddit, you will be able to use it with NickServ on Snoone
@flotwig
flotwig / zncmakepem.sh
Created May 8, 2014 20:37
Make a .pem for ZNC
# because i keep forgetting
rm znc.pem
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3650 -nodes
cat key.pem > znc.pem
cat cert.pem >> znc.pem
#!/usr/bin/env ruby
# encoding: UTF-8
require 'snoo'
reddit = Snoo::Client.new :useragent => '/u/flotwig - Responds to "It is known." with "It is known." http://l.t.tl/1q'
reddit.log_in 'KhaleesiServantGirl', ''
debug = false
latest_id = 0
def base10_reddit_id(base36_id)
return base36_id.split('_',2).last.to_i(36)
end
@flotwig
flotwig / rando.rb
Created July 29, 2014 23:07
irc.snoonet.org ##random
require 'cinch'
require 'open-uri'
require 'json'
require 'date'
class Rando
include Cinch::Plugin
match /raw (.+)/, method: :do_raw
match /refresh/, method: :do_refresh
match /index/, method: :do_index_get
match /index (.+)/, method: :do_index_set
#!/usr/bin/env python3
#!c:/Python35/python3.exe -u
import asyncio
import sys
import cv2
import numpy as np
import cozmo
import time
import os
from glob import glob