Archive for the ‘Technology’ Category

Prevent Safari from reopening sessions

septembre 25th, 2012

I like Safari because it is simple and fast. But Apple has added a new feature into it: the navigation sessions. When quitting Safari, your currently opened tabs and windows are saved as a navigation session… and is reopened when you start Safari again. It is very very annoying because it takes hours to start. The worse of this is that Safari has the same behavior when restarting after a crash: this is kind of stupid because it will surely open again the page that pushed Safari to the fault.

Safari seems to ignore the general system preference that allows users from preventing applications to restore their previous states on start. This setting is unchecked on my MacBook but Safari still uses the session feature. How to disable that thing then?

Open Finder and choose « Go to folder » in the app menu (or hit +shift+G). In the box, type « ~/Library/Saved Application State/ ». Locate the « com.apple.Safari.savedState » folder, highlight it. First of all, empty the folder to trash existing sessions. Then we will prevent Safari from saving sessions. Hit +i when the folder is highlighted. This will display the folder informations. Tick the « locked » checkbox. There you go: Safari will not be allowed to access this folder any longer. Sessions cannot be saved and Safari is now much quicker.

Tags: , , , ,
Posted in Miscellaneous, Technology | Comments (0)

VPN protected use of TransmissionBT – AppleScript

février 13th, 2012

It’s been a little while that the Ananoos service exists. Very useful and easy, powerful and cheap VPN service. It works on top of OpenVPN which provides high security and encrypted connections. Besides I’m using Transmission which is a free and efficient BitTorrrent client.

The goal is to make sure the VPN connection is always up when using Transmission. When starting Transmission or when the VPN link fails, the VNP connection is restarted. And if really there is no way to get back the VPN link, the Transmission app is simple closed.

# SET HERE YOUR TUNNELBLICK
# CONNECTION NAME
# IN MY CASE: Ananoos
set VPNConnection to "Ananoos"

repeat
	# If transmission is running
	if appIsRunning("Transmission") then
		set vpn to ""

		if appIsRunning("TunnelBlick") then
			# TunnelBlick is running
			# Checking whether it is connected
			tell application "Tunnelblick"
				set vpn to get state of first configuration where name = VPNConnection
			end tell
		else
			tell application "Tunnelblick" to activate
		end if

		# VPN is connected, all fine
		if vpn = "CONNECTED" then
			#display alert "Transmission is running and protected"
		else
			# VPN is not connected, forcing reconnect
			tell application "Tunnelblick"
				connect VPNConnection
			end tell

			# Waiting for reconnection
			repeat 10 times
				tell application "Tunnelblick"
					# Is VPN connected at last?
					set vpn to get state of first configuration where name = VPNConnection
					# Yes, exiting loop
					if vpn = "CONNECTED" then exit repeat
					do shell script "sleep 3"
				end tell
			end repeat

			# Checking whether TunnelBlick has reconnected
			if vpn = "CONNECTED" then
				display alert "ATTENTION: Transmission was running without VPN protection. We have successfully forced reconnection..."
			else
				# Not reconnected, better quit Transmission
				tell application "Transmission"
					quit
				end tell
				display alert "ATTENTION: Transmission was running unprotected. We were unable to reconnect to VPN therefore we have closed it..."
			end if

		end if
	end if
	do shell script "sleep 1"
end repeat

on appIsRunning(appName)
	tell application "System Events" to (name of processes) contains appName
end appIsRunning

Open the Mac AppleScript Editor. Copy and paste the above code. Save as an application and make sure this app is automatically started on login.
Attention 1: this script works only with TunnelBlick which is a openVPN Mac GUI. Ananoos offers either their own VPN client or the TunnelBlick config files. Prefer 2nd option.
Attention 2: line4, I refer to the « Ananoos » connection. If your have named it differently, update the script.

Tags: , , , , ,
Posted in Development, Technology | Comments (0)

How to handle SVN with Redmine

septembre 15th, 2011

When it comes to project management, Redmine is one of the best tools according to me. Written in Ruby on Rails, it offers a huge amount of features in a clean, really nice and efficient interface. Plus it’s free and open source.

One of these features is related to Subversion. Redmine is able to interact with Subversion:

  • it has a powerful repository browser able to link tasks and commits.
  • it can manage SVN authentication. Redmine users have therefore access to the SVN repository with same username and password

In order to setup up this feature, you must follow this tutorial: http://www.redmine.org/projects/redmine/wiki/HowTo_to_handle_SVN_repositories_creation_and_access_control_with_Redmine

Sadly, this is not that simple. This tutorial doesn’t work on recent versions of Redmine (see post here: http://www.redmine.org/boards/2/topics/24383?r=26204). Redmine has updated it authentication system in adding a salt field. Initially, Redmine passwords were SHA1(password) only. Now passwords are SHA1(salt.SHA1(password)). This format is not supported by pam_mysql out of the box.

I’ve therefore patched pam_mysql.c. Patch is here: http://pastebin.com/4SATdQ8u

In order to use it, you must:

  1. download pam_mysql source here
  2. apply the attached patch on pam_mysql.c using the « patch » command
  3. compile again pam_mysql: « make clean && make && make install »
  4. modify the MySQL ssh_users view running this SQL query:
    CREATE OR REPLACE VIEW ssh_users as
    select login as username, CONCAT(hashed_password, '|', salt) as password
    from users
    where status = 1;
  5. edit /etc/pam.d/sshd and set crypt=5 for the 3 blocks

Auth will now take the salt into account. For pam_mysql-0.7RC1 only.
Let me know whether it works

Tags: , , , , ,
Posted in System, Technology | Comments (0)

WordPress 3 nginx virtualhost configuration

juin 22nd, 2011

Hi there,

another configuration file for WordPress 3 running on Nginx:


server
        {
                listen 80;
                server_name blog.******.com;
                root /var/www/blog;
                index index.php;

                location /
                {
                        try_files $uri $uri/ @wordpress;
                }

                # BLOCKS ACCESS TO . FILES (.svn, .htaccess, ...)
                location ~ /\. {
                        deny  all;
                }

                # FOR PHP FILES
                location ~* \.php$ {
                        try_files $uri $uri/ @wordpress;

                        fastcgi_pass 127.0.0.1:9000;
                        fastcgi_index index.php;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        include fastcgi_params;
                }

                location @wordpress {
                        fastcgi_pass 127.0.0.1:9000;
                        #fastcgi_index index.php;
                        include fastcgi_params;
                        fastcgi_param SCRIPT_FILENAME  $document_root/index.php;
                        break;
                }

                location ~ /\. {
                        deny  all;
                }

                location ~* \.css|\.js|\.jpg|\.jpeg|\.png|\.gif|\.swf|\.svg|\.tiff$ {
                        expires 30d;
                }
}

There you go!

Tags: , , ,
Posted in System, Technology | Comments (0)

Sphinx accentuated characters

septembre 6th, 2010

When indexing like me french content into Sphinx, accentuated and non-accentuated search queries will not return the same results. For instance, searching on « Môle » returns a result unlike a search on « Mole ».
Read the rest of this entry »

Posted in System, Technology | Comments (0)

Kohana with Nginx – VirtualHost configuration

juin 10th, 2010

In order to improve performances, I chose to switch web server for one of my websites. I switched from Apache 2 to Nginx, extremely fast and powerful. It’s not easy to configure though: it took me a really long time to configure Nginx for Kohana 2. Here is my configuration file:

server {
	listen 80;
	server_name www.xxxx.com;
	root /var/www/xxxx/prod/public;
	index index.php;

	# ROUTING TO KOHANA IF REQUIRED
	location / {
		try_files $uri $uri/ @kohana;
	}

	# BLOCKS ACCESS TO . FILES (.svn, .htaccess, ...)
	location ~ /\. {
		deny  all;
	}

	# FOR PHP FILES
	location ~* \.php$ {
	 	# PHP FILES MIGHT BE TO HANDLED BY KOHANA
		try_files $uri $uri/ @kohana;

		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		include fastcgi_params;
	}


	# HANDLES THE REWRITTEN URLS TO KOHANA CONTROLLER
	location @kohana
	{
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index index.php;
		include fastcgi_params;
		fastcgi_param SCRIPT_FILENAME $document_root/index.php;
	}


	# CACHE CONTROL FOR STATIC FILES
	location ~* \.css|\.js|\.jpg|\.jpeg|\.png|\.gif|\.swf|\.svg|\.tiff|\.pdf$ {
		expires 30d;
	}

	# REDIRECTING MEDIAS TO STATIC
	location ^~ /medias/ {
		rewrite ^/medias/(.*) http://static.xxxx.com/$1 permanent;
		break;
	}

}



server {
	listen 80;
	server_name static.xxxx.com;
	root /var/www/xxxx/medias/;    
	expires 90d;

	location /videos/ {
		keepalive_timeout     200 190;

		#limit_conn   videos  2;
		mp4;
		limit_rate_after 512k;
		limit_rate 512k;

		error_page 404 = /videos/video_not_found.png;
	}
}

My homepage now loads in 1,5s instead of 7s before. Thanks to Nginx ;-)

Tags: , , , ,
Posted in System, Technology | Comments (2)

Blocking ads in FF and Safari

mai 26th, 2010
For those (like me) who can’t stand ads any longer:
- and I fuck Internet Explorer

Tags: , , ,
Posted in Technology | Comments (0)

Monitolite improvement

avril 9th, 2010

Monitolite was improved today: it supports now tasks history properly. It means that Monitolite will not send 20 times the same notification for the same issue. Plus it is able to detect a recover status and to send a RECOVERY notification.

Tags: , , ,
Posted in Development, Technology | Comments (0)

Subversion pre-commit hook for PHP

mars 8th, 2010

If you are using Subversion for your development projects, you may know about hooks: these are scripts that are executed on the server at different times. For instance you may want to check that a commit message is not empty before allowing the commit. In this case, this is a pre-commit hook. Read the rest of this entry »

Tags: , , ,
Posted in Development | Comments (0)

Introducing MonitoLite

mars 4th, 2010

I am glad to introduce MonitoLite, a Perl application I’ve been developing the past days. It is a quick, powerful, easy-to-use monitoring tool.

Read the rest of this entry »

Tags: , , , ,
Posted in Development, Technology | Comments (0)