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 | |
require_once "Mail.php"; // Make sure that you have pear/Mail and pear/Net_SMTP installed | |
$auth_data = array( | |
'username' => '<your_login>@gmail.com', | |
'password' => '<your_pass>' | |
); | |
function send_gmail($auth_data, $to, $subject, $body) | |
{ |
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 | |
killall -9 tailwatchd | |
mkdir -p /root/cpanel-backup/ | |
mv /var/cpanel/ /root/cpanel-backup/var-cpanel | |
mv /usr/local/cpanel/ /root/cpanel-backup/usr-local-cpanel | |
mv /usr/local/apache/ /root/cpanel-backup/usr-local-apache | |
rm /etc/httpd | |
echo|crontab - | |
sed -i '/exclude=/d' /etc/yum.conf |
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 sys, itertools, time | |
# Use the following command to flush: echo 1 > /proc/sys/vm/drop_caches | |
if len(sys.argv) < 2: | |
print "Usage: %s <portion_mb> file1 file2 ..." | |
exit(-1) | |
portion = int(sys.argv[1]) * 2**20 | |
files = sys.argv[2:] |
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 | |
with_notify_on_fail() { | |
email=$1 | |
LANG=en_US.UTF-8 date=`date` | |
shift | |
$@ | |
if [[ $? != 0 ]] | |
then | |
echo Sending notification to $email |
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
-- an abstract helper for 'modify-last-or-add-new' pattern | |
concatFoldl :: (a -> b -> [b]) -> [a] -> b -> [b] | |
concatFoldl f (x:xs) e | null ys = error "Unexpected empty list" | |
| null xs = f x e | |
| otherwise = concatFoldl f xs (head ys) ++ (tail ys) | |
where ys = f x e | |
concatFoldl f [] e = [] | |
-- test | |
data Command = Inc | Push Int |
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 shows how to use HTTP chunked transfer in libevent. It starts an HTTP server on port 8080; when the client connects, it outputs an message every second. After all messages are outputted, the server closes the HTTP connection. | |
It has an unsolved crashing problem though... to see it crash, run the next commands in a shell. | |
See my ML post "after the http client abruptly closes socket libevent (2.0.3-alpha) http server crashes" at http://archives.seul.org/libevent/users/Jan-2010/msg00054.html | |
Compile with: | |
gcc -Wall -g -std=c99 -D_GNU_SOURCE -Iinclude -Llib -levent -o chunk chunk.c |
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
Header add Access-Control-Allow-Origin "*" | |
Header set Access-Control-Allow-Headers "X-Requested-With" | |
Header set Access-Control-Max-Age "60" | |
Header set Access-Control-Allow-Credentials true | |
Header set Access-Control-Allow-Headers "Content-Type, *" |
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
cat >/etc/yum.repos.d/linuxtech.repo <<BLOCK | |
[linuxtech] | |
name=LinuxTECH | |
baseurl=http://pkgrepo.linuxtech.net/el6/release/ | |
enabled=1 | |
gpgcheck=1 | |
gpgkey=http://pkgrepo.linuxtech.net/el6/release/RPM-GPG-KEY-LinuxTECH.NET | |
BLOCK | |
yum install mplayer |
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 | |
=pod | |
Ensures that the password matches against NTLM challenge & response. | |
Synopsis: | |
./src/curl --ntlm -uAdministrator:atomic http://192.168.56.101:/WebDav/ -v | |
WWW-Authenticate: NTLM TlRMTVNTUAACAAAABAAEADgAAAAGgokCv9L+7WR398wAAAAAAAAAAIYAhgA8AAAABQLODgAAAA9ETlMxAgAIAEQATgBTADEAAQAIAEQARQBMAEwABAAcAGQAbgBzADEALgBsAG8AYwBhAGwAaABvAHMAdAADACYAZABlAGwAbAAuAGQAbgBzADEALgBsAG8AYwBhAGwAaABvAHMAdAAFABwAZABuAHMAMQAuAGwAbwBjAGEAbABoAG8AcwB0AAAAAAA= | |
Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAADQANAHAAAAAEAAQAfQAAAAAAAAAAAAAABoKJAtF4FmQok6yvAAAAAAAAAAAAAAAAAAAAAD9xuQoSt6XlCNB3NXHcuv3CQLGP6YgYQUFkbWluaXN0cmF0b3Job21l | |
perl ntlm_check_passwd.pl TlRMTVNTUAACAAAABAAEADgAAAAGgokCv9L+7WR398wAAAAAAAAAAIYAhgA8AAAABQLODgAAAA9ETlMxAgAIAEQATgBTADEAAQAIAEQARQBMAEwABAAcAGQAbgBzADEALgBsAG8AYwBhAGwAaABvAHMAdAADACYAZABlAGwAbAAuAGQAbgBzADEALgBsAG8AYwBhAGwAaABvAHMAdAAFABwAZABuAHMAMQAuAGwAbwBjAGEAbABoAG8AcwB0AAAAAAA= TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAADQANAHAAAAAEAAQAfQAAAAAAAAAAAAAABoKJA |
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 scala.io.Source | |
val listOfLines = Source.fromFile("filename.txt").getLines.toList |