Wednesday, November 30, 2011

Resume local file copy

curl -C - -O file:///path/to/file.txt

resumes copying file.txt to the current folder

Monday, November 21, 2011

How to reduce PDF file size from command line

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

-dPDFSETTINGS=/screen (screen-view-only quality, 72 dpi images)
-dPDFSETTINGS=/ebook (low quality, 150 dpi images)
-dPDFSETTINGS=/printer (high quality, 300 dpi images)
-dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)
-dPDFSETTINGS=/default (almost identical to /screen)

Sources:
http://www.ubuntugeek.com/ubuntu-tiphowto-reduce-adobe-acrobat-file-size-from-command-line.html
http://milan.kupcevic.net/ghostscript-ps-pdf/

Wednesday, November 16, 2011

Vulnerability in the WordPress King Size theme

This is the vulnerability: http://catchinternet.com/blog/timthumb-vulnerability-wordpress-security-patch/

Below is a discussion that I have been having with the creators of King Size. I personally find their response unacceptable, but I agree that themeforest is also to blame. I also do not understand why they didn't have an "update notifier" until recently. I also contacted themeforest and waiting for a reply.

-----

Hello King Size Theme team,

My server was cracked using a vulnerability found in timthumb.php, which ships with the King Size Theme.

I checked the theme page on themeforest.net and under version 3.1 it says: "Updated Timthumb (timthumb.php) for security concerns"

Did you send out e-mails to all your customers using King Size < 3.1 about this problem? If not, why not?

Thanks,
Ovi

-----

Ovidiu Dan (Ovi),

A customer support staff member has replied to your support request, #455636 with the following response:

Hello,

I am sorry to hear about your troubles but its not our responsibility to keep you informed of updates. Its yours as a buyers responsibility to occasionally check in and see if updates are available. As of v3.3 we released an "update notifier" which informs buyers when updates are available via their Dashboards.

Kind regards,
Bryce Wisekal

-----

Hello again,

I am sorry but it IS definitely your responsibility, especially when it comes to critical security vulnerabilities.

Please do the right thing and inform your customers or I will do it for you.

Ovi

-----

Ovidiu Dan (Ovi),

A customer support staff member has replied to your support request, #455636 with the following response:

Hello Ovi,

And how do you propose we do that when we do not have CONTACT to our buyers? Come on now, be sensible. When you buy a template from theme forest it IS YOUR responsibility. If you cannot deal with that I am sorry, its not our fault though. We announced this information within our comments, as well released an update. We do not have access to contact buyers due to Theme Forest controlling those rights.

As I had mentioned, I am sorry to hear about your troubles but if you came by Theme Forest from time to time and checked on the template you would have clearly known about the issues. We did our part by addressing the issue, its not your responsibility to update your template - not ours.

So please, do the right thing and accept your responsibility, because its not ours. If you disagree with this, you're more than welcome to take it up with Theme Forest and suggest to them that sellers need the ability to contact their buyers but its not going to happen. It's something authors have been asking Theme Forest for some time now. I'm sorry, but we're only able to do what we can, the rest is up to you as a buyer.

Kind regards,
Bryce Wisekal

-----

Sunday, January 16, 2011

Monday, January 03, 2011

pdflatex on Ubuntu 10.10
sudo apt-get install tetex*
sudo apt-get install texlive

Monday, December 06, 2010

HowTo: Extract an EPS from a PDF file - http://www.dhreutter.de/?q=blog/howto-extract-eps-a-pdf-file

Extract images from a PDF document - http://stefaanlippens.net/extract-images-from-pdf-documents

Thursday, November 04, 2010

Notes on installing Condor on Windows / Win 7

Below you can read about some of the problems I encountered while testing Condor, along with some solutions/workarounds.

1) The Condor keyboard daemon (KBDD) does not work out of the box. If you start the condor_kbdd.exe process as the SYSTEM user (the default configuration), it will fail to register keyboard/mouse activity. Instead, you can configure Condor to not start the KBDD daemon by removing “KBDD” from the DAEMON_LIST in the configuration file. If you want to use the kbdd process you will need to run it as the the local (logged in) user.

2) When installing Condor manually you need to set the CONDOR_CONFIG environment variable *system wide* (not for the current user). Attempting to start the service when the environment variable is not configured yields this error: “Error 1067: The program terminated unexpectedly”. The manual mentions that instead of an environment variable we can also set several registry keys. I found this to be incorrect. Condor seems to completely ignore those registry keys. If I remember correctly, the installer does not even create them.

3) If the Condor service is configured to start at boot time it will sometimes (always?) fail. One theory is that this happens because Condor tries to establish network connections before the networking services are up. So you might want to delay starting the service until the machine booted up properly.

Sunday, September 19, 2010

Compress PDF

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Thursday, December 03, 2009

Null values in Hadoop 0.20.1 Writable

If any of the elements of a custom Writable are NULL, Hadoop will fail silently on my machine. So, make sure you don't try to write NULL variables.

Tuesday, July 07, 2009

Ubuntu Dell XPS M1330 low volume mic/microphone fix

http://ubuntuforums.org/showpost.php?p=6718591&postcount=27

(restart session )

Sunday, July 05, 2009

Untar all files in a folder
for a in `ls -1 *.tar.gz`; do tar -zxvf $a; done
or
for a in `ls -1 *.tgz`; do tar -zxvf $a; done

Friday, June 05, 2009

VMware keyboard bug under Ubuntu/Linux

To reset your keyboard map - setxkbmap

http://experts.missouristate.edu/display/csvhelpdesk/Reset+Keyboard+Map

Sunday, May 31, 2009

Unzip all zip files in the current folder

for f in *.zip;do unzip "$f";done

Wednesday, May 20, 2009

Distributed key-value stores

http://www.metabrew.com/article/anti-rdbms-a-list-of-distributed-key-value-stores/ - Anti-RDBMS: A list of distributed key-value stores

http://randomfoo.net/2009/04/20/some-notes-on-distributed-key-stores - Some Notes on Distributed Key Stores

http://bret.appspot.com/entry/how-friendfeed-uses-mysql - How FriendFeed uses MySQL to store schema-less data

http://anyall.org/blog/2009/04/performance-comparison-keyvalue-stores-for-language-model-counts/ - Performance comparison: key/value stores for language model counts

http://michalfrackowiak.com/blog:redis-performance - Redis Performance on EC2 (aka weekend project coming)

http://labs.gree.jp/Top/OpenSource/Flare-en.html - Flare is distributed, and persistent key-value storage - pluggable storage (currently only Tokyo Cabinet is available, though:)

http://blip.tv/file/1949416/ - Drop ACID and think about data

http://www.igvita.com/2009/02/13/tokyo-cabinet-beyond-key-value-store/ - Tokyo Cabinet: Beyond Key-Value Store

http://www.scribd.com/doc/12016121/Tokyo-Cabinet-and-Tokyo-Tyrant-Presentation - Tokyo Cabinet and Tokyo Tyrant Presentation
Installing Tokyo Tyrant on Ubuntu 9.04 (Jaunty), in custom folders/directories

Tokyo Cabinet - first install this
-------------
cd /usr/local/src/
wget http://tokyocabinet.sourceforge.net/tokyocabinet-1.4.21.tar.gz
tar xvf tokyocabinet-1.4.21.tar.gz
cd tokyocabinet-1.4.21
apt-get install zlib1g-dev
apt-get install libbz2-dev
mkdir /usr/local/tokyocabinet-1.4.21/
./configure --prefix=/usr/local/tokyocabinet-1.4.21/
make
make install

Tokyo Tyrant
------------
cd /usr/local/src/
wget http://tokyocabinet.sourceforge.net/tyrantpkg/tokyotyrant-1.1.27.tar.gz
tar xvf tokyotyrant-1.1.27.tar.gz
cd tokyotyrant-1.1.27
mkdir /usr/local/tokyotyrant-1.1.27
./configure --prefix=/usr/local/tokyotyrant-1.1.27/ --with-tc=/usr/local/tokyocabinet-1.4.21/
make
make install

Fix lib problem
------------
cd /usr/local/tokyotyrant-1.1.27/bin/
./ttserver

You will get this error: ./ttserver: error while loading shared libraries: libtokyocabinet.so.8: cannot open shared object file: No such file or directory

To fix it,
cd /usr/local/tokyotyrant-1.1.27/
ln -s /usr/local/tokyocabinet-1.4.21/lib/libtokyocabinet.so.8 lib/
./bin/ttserver will now work

Thursday, May 14, 2009

Easily changing the timezone in Ubuntu server

dpkg-reconfigure tzdata

Tuesday, March 24, 2009

How to delete a certain line from a file in Linux

sed -i 321d /path/to/file

where 321 is the line number

Thursday, March 12, 2009

Ramdisk in Linux/Ubuntu

sudo mkdir /mnt/ramdisk
sudo mount -t tmpfs tmpfs /mnt/ramdisk -o size=100M,nr_inodes=200k,mode=01777

Monday, February 02, 2009

Pipe Viewer

"Pipe viewer is a terminal-based tool for monitoring the progress of data through a pipeline. It can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion."

http://www.catonmat.net/blog/unix-utilities-pipe-viewer/

Tuesday, January 06, 2009

Protecting from a DDOS SYN FLOOD on port 80 (Apache, Ubuntu)

Other keywords: SYN_RECV, TIME_WAIT

sysctl -w net.ipv4.tcp_synack_retries="1"
sysctl -w net.ipv4.tcp_max_syn_backlog="40000"
sysctl -w net.ipv4.netfilter.ip_conntrack_max="200000"
sysctl -w net.ipv4.tcp_fin_timeout="3"

/sbin/iptables -A INPUT -i eth2 -p tcp --tcp-flags ALL ACK,RST,SYN,FIN -j DROP
/sbin/iptables -A INPUT -i eth2 -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
/sbin/iptables -A INPUT -i eth2 -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
(you can ignore the iptables part, probably doesn't help that much)

In Apache, increase the maximum number of concurrent connections.

I also learned that while in theory putting a squid in reverse proxy on port 80 to protect the Apache behind it is a good idea, squid sucks at it.

Oh, I almost forgot. Make sure syn_cookies is active (if you kernel supports it):
echo 1 > /proc/sys/net/ipv4/tcp_syncookies

Google is your friend for further details on the above settings.

More:
http://tools.ietf.org/html/rfc4987#section-3.5
http://www.cisco.com/web/about/ac123/ac147/archived_issues/ipj_9-4/syn_flooding_attacks.html