Skip to content

Instantly share code, notes, and snippets.

View vdudouyt's full-sized avatar

Valentin Dudouyt vdudouyt

  • Novosibirsk, Russia
View GitHub Profile
<?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)
{
#!/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
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:]
#!/bin/bash
with_notify_on_fail() {
email=$1
LANG=en_US.UTF-8 date=`date`
shift
$@
if [[ $? != 0 ]]
then
echo Sending notification to $email
-- 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
@vdudouyt
vdudouyt / chunk.c
Created June 10, 2014 15:10 — forked from rgl/chunk.c
/*
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
@vdudouyt
vdudouyt / .htaccess
Created June 9, 2014 09:34
Enable Cross-Domain HTTP requests
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, *"
@vdudouyt
vdudouyt / mplayer_install
Created June 9, 2014 05:00
Install MPlayer on CentOS 6
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
#!/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
import scala.io.Source
val listOfLines = Source.fromFile("filename.txt").getLines.toList