Skip to content

Instantly share code, notes, and snippets.

@dynax60
dynax60 / gist:560251
Created September 1, 2010 05:06
Linux startup script for Mojo daemon_prefork app
#!/bin/bash
#
# Init file for Pinger server daemon
#
# chkconfig: 2345 55 25
# description: Pinger server daemon
#
# processname: pinger
# pidfile: /var/run/pinger.pid
@dynax60
dynax60 / jsonp-service.pl
Created September 3, 2010 08:01
An example of JSONP service (cross-domain) on Mojolicious..
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/mojo/lib";
use Mojolicious::Lite;
@dynax60
dynax60 / jsonp.html
Created September 3, 2010 08:10
An example of JSONP usage (cross-domain) with JQuery.
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<SCRIPT>
$(function() {
$('#clickme').click(function() {
$.getJSON('http://domain.tld/test/?foo=bar&callback=?',
@dynax60
dynax60 / gist:640480
Created October 22, 2010 12:43
Паковка и распаковка IP-адреса
$ perl -MSocket -le 'print unpack("N", inet_aton(shift))' 127.0.0.1
2130706433
$ perl -MSocket -le 'print inet_ntoa(pack("N", shift))' 2130706433
127.0.0.1
@dynax60
dynax60 / check_ping.patch
Created December 3, 2010 14:08
Nagios check_ping plugin: Disable warning message "System call sent warnings to stderr"
--- check_ping.c~ 2008-12-01 00:23:18.000000000 +0300
+++ check_ping.c 2010-12-03 16:40:05.000000000 +0300
@@ -487,7 +487,7 @@
if ((result=error_scan(buf, addr)) == STATE_OK) {
result = STATE_WARNING;
if (warn_text == NULL) {
- warn_text = strdup(_("System call sent warnings to stderr "));
+ /* warn_text = strdup(_("System call sent warnings to stderr ")); */
} else {
asprintf(&warn_text, "%s %s", warn_text, _("System call sent warnings to stderr "));
@dynax60
dynax60 / ping_api.rc
Created December 17, 2010 09:37
Example of FreeBSD rc-file for Mojolicious Hypnotoad Server
#!/bin/sh
# PROVIDE: ping_api
# REQUIRE: NETWORKING
# KEYWORD: shutdown
. /etc/rc.subr
name="ping_api"
rcvar=`set_rcvar`
@dynax60
dynax60 / maildirdel.pl
Created January 21, 2011 09:57
Remove helper for Postfixadmin
#!/usr/bin/env perl
use strict;
use warnings;
my $mailhome = '/var/spool/postfix/virtual';
my $domain = shift or die;
my $username = shift or die;
die "Invalid domain: $domain\n" unless $domain =~ m/^[\w\.\-]+$/;
--- delete.orig.php 2011-01-21 12:27:12.000000000 +0300
+++ delete.php 2011-01-21 12:28:38.000000000 +0300
@@ -160,6 +160,8 @@
}
}
+ system("/usr/local/bin/sudo /usr/local/sbin/maildirdel.pl $fDomain $fDelete");
+
if ($error != 1)
{
@dynax60
dynax60 / spamcop-submitter.pl
Created February 2, 2011 07:33
Automate Spamcop Submission
#!/usr/bin/env perl
# Automate Spamcop Submission
use FindBin;
use lib "$FindBin::Bin/mojo/lib";
use Mojo::Client;
$| = 1;
my $client = Mojo::Client->new;
@dynax60
dynax60 / athenians.pl
Created March 9, 2011 05:21
Аффинная система подстановок Цезаря
#!/usr/bin/perl
# Аффинная система подстановок Цезаря
# --dynax60
use strict;
use warnings;
use encoding 'utf8';
use Encode qw(decode);
my ($cmd, $a, $b, $txt) = @ARGV;