Skip to content

Instantly share code, notes, and snippets.

View typhonius's full-sized avatar

Adam Malone typhonius

View GitHub Profile
@typhonius
typhonius / bashrc
Created February 23, 2013 03:02
My bashrc
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /etc/profile
# are we an interactive shell?
if [ "$PS1" ]; then
if [ -z "$PROMPT_COMMAND" ]; then
case $TERM in
xterm*)
@typhonius
typhonius / memcached.conf
Created February 23, 2013 03:14
Memcache configuration
# Run memcached as a daemon.
-d
# pidfile
-P /var/run/memcached.pid
# Log memcached's output
logfile /var/log/memcached.log
@typhonius
typhonius / my.cnf
Created February 23, 2013 03:18
A configured my.cnf for a 4GB server also running FPM/Apache
#
# The MySQL database server configuration file.
#
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
@typhonius
typhonius / db_insert.pl
Created February 24, 2013 08:52
Wrapper function for inserting into an sqlite database using perl and prepared statements. The %values array is an associative array of column->value db_insert($table, %values);
sub db_connect() {
our $dbh = DBI->connect("dbi:SQLite:" . $path . '/' . $db,"","") or die "Unable to connect to database: $DBI::errstr";
return $dbh;
}
sub db_prepare($) {
my $dbh = db_connect();
my $query = shift;
my $handle = $dbh->prepare($query);
return $handle;
@typhonius
typhonius / anonymous_comment_delete.module
Created February 26, 2013 07:44
What is essentially a prebuilt module that allows the user to create tokens (perhaps to be sent to an email address) which contain links they can click to delete spammy comments without logging in. Necessity for this was born out of receiving "new comment" notifications on my phone and then being annoyed about having to log in on a device that I…
<?php
/**
* Implements hook_menu()
*/
function mymodule_menu() {
$items['comment/%/fastdelete/%'] = array(
'title' => 'Fast Comment Deletion',
'page callback' => 'mymodule_comment_fastdelete',
'page arguments' => array(1, 3),
@typhonius
typhonius / greentext.module
Last active February 11, 2019 08:23
A filter format for applying greentext correctly to Drupal text. The snippet will provide any filter format with the ability to change any line starting with '>' into a greentext line. >Implying anyone will use it
<?php
function greentext_filter_info() {
$filters['greentext'] = array(
'title' => t('Implying greentext'),
'description' => t('Allows you to alter any lines input starting with \'>\' to appear as greentext.'),
'process callback' => '_greentext_greentext',
'tips callback' => '_greentext_greentext_tips',
);
return $filters;
@typhonius
typhonius / odch_gag_patch.patch
Created April 18, 2013 04:39
patch for odch to allow users to be muted
diff --git a/src/commands.c b/src/commands.c
index 411f944..7af604f 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -480,6 +480,23 @@ void chat(char *buf, struct user_t *user)
logprintf(3, "OP Admin %s at %s added %s to nickban list\n", user->nick, user->hostname, tempstr);
}
}
+
+ else if(((user->permissions & BAN_ALLOW) != 0) && (strncasecmp(temp, "!gag ", 5) == 0))
@typhonius
typhonius / match_users.php
Created April 19, 2013 01:51
when retrieving a list of users from elsewhere with emails as a shared field this will detect if they exist in the db already
<?php
$emails = array(
// fill in emails here or use array from somewhere else
);
foreach ($emails as $mail) {
$query = "SELECT 1 FROM {users} WHERE mail = :mail";
$exists = db_query_range($query, 0, 1, array(':mail' => $mail))->fetchField();
@typhonius
typhonius / ttl.sh
Last active December 17, 2015 04:29
gets the actual TTL rather than the TTL a user's machine has.
#!/bin/bash
if [ -z "${1}" ] ;
then
echo 'Please enter the address the TTL should be found for'
exit 1
fi
NS=`host -t NS $1 | awk {'print $4'}`
arr=$(echo $NS | tr " " "\n")
for x in $arr
@typhonius
typhonius / isup.rb
Created May 16, 2013 13:08
My first ruby script. Is a webserver where you pass the URL like localhost:8080/http://google.com and it'll tell you if google is up and what response given etc. It's terrible but it's a start.
#!/usr/bin/ruby
#require "net/http"
require "net/https"
require "uri"
require "socket"
require "yaml"
$redirects = Array.new