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
# convert base-10 integer a to base-b, returning a string | |
def convert(a,b): | |
add = a % b | |
if a <= 1: | |
return str(a) | |
return str(convert(a//b, b)) + str(add) |
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 | |
# restart print queues | |
process() | |
{ | |
host=$1 queue=$2 | |
ping -c 1 ${host} 2>&1 >/dev/null | |
status=$? |
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 | |
# | |
# linux_idleout.sh [idle time] | |
# | |
# Auto-logout process for telnet/ssh sessions | |
# | |
IDLE_TIME=180 | |
LOG_FILE=/tmp/idle.out | |
EXEMPT_PROCESSES="app1|app2|app3|etc" # optional list of apps which can be excluded |
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
import datetime | |
def first_day_of_month(d): | |
return datetime.date(d.year, d.month, 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
import datetime | |
import calendar | |
def last_day_of_month(d): | |
return datetime.datetime(d.year, d.month, calendar.mdays[d.month]).date() |
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/perl -w | |
use strict; | |
use LWP::UserAgent; | |
use HTTP::Request::Common qw(POST); | |
use Net::SSL; | |
use LWP::Protocol::https; | |
use URI::https; | |
my $url = 'https://someurl.com/SubmitCXML'; |
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/perl -w | |
use strict; | |
use LWP::UserAgent; | |
my $url = 'https://someurl.com/einvoice.dll'; | |
my $filename = $ARGV[0]; | |
my $sid = "username"; | |
my $spwd = "password"; |
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 | |
# | |
# Expire and delete inactive linux users | |
# | |
# check this before running! | |
exclude_users="keepme|metoo|daemon|adm|lp|sync|shutdown|halt|mail|news|uucp|operator|man|postmaster|smmsp|portage|nobody|sshd|cron|ntp|messagebus|mysql|apache|haldaemon|ftp|postfix|dhcp|ntop|fetchmail|squid|hsqldb|tomcat" | |
remove_period="548" # 18 months |
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
from itertools import combinations | |
def f(A): | |
for p in combinations(A, 2): | |
return p[0], p[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
def GCD(a, b): | |
if b == 0: | |
return a | |
else: | |
return GCD(b, a%b) | |
gcd = reduce(lambda x, y: GCD(x, y), A) |
OlderNewer