Wednesday, September 2, 2009

Internet Explorer Does Not Create Session Cookies

Reference: http://genotrance.wordpress.com/2006/11/23/session-cookies-rejected-by-internet-explorer/

Initial encounter (IE and Chrome problem) was a timezone issue.

Timezone issue

A third website suggested that IE was calculating session cookie timeouts incorrectly such that they seemed to expire in the past. As a result, these already expired cookies were rejected immediately. For example, if the server was in Hawaii and the client in Australia and the server requested a session timeout of one hour, the timeout would have already occurred as far as the client in Australia was concerned.

Firefox didn’t have this issue since it converts both the server as well as the client time to UTC and then calculates the timeout. As interesting as this was, this didn’t seem as the problem since both my laptop client as well as my server were in the same timezone.

---

Next encounter (after setting up VirtualHosts) was a hostname issue, where underscores are not accepted by IE.

(In the comments section of the article)

I was just researching a similar issue I had locally on my laptop, running apache and php. Every request was generating a new session file, but only in IE and not in FireFox.

I traced the problem back to the URL used to access the site. As I develop locally I’m using non-existent URL schemes and I enter them in my hosts file manually.
test1.loc
test2.loc
test_3.loc

When using underscores, IE rejects the cookie… Just thought I’d complete your list.

Monday, August 17, 2009

Can't Login in IE7 or Chrome, Cookie Not Set

From https://help.webfaction.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=168:


If you are using Internet Explorer 7 or Google Chrome ( Chromium ) and are unable to log into [some website], make sure that your computer's clock is set to the correct time, as well as the correct time zone.

IE7 and Chrome both handle web browser cookie expiration times based on your local computer's clock. So if your clock is off, your cookies can expire before they are ever even used.

Tuesday, July 28, 2009

Generate Radnom String in Python

Source: http://ostas.blogspot.com/2006/12/python-generate-random-strings.html


import string
import random
"".join(random.sample(string.letters+string.digits, 8))

Wednesday, July 15, 2009

How to Play MIDI files in Ubuntu

Copy-pasta!

Howto: Easy MIDI

I was trying to play scummvm with alsa, and I coudlnt get it to play midis.. So I did a Little research, and found this. He did an excellent job at adding midi in hoary, so this is kind of a translation and a bit of fix.

  1. Install timidity & pmidi:


    sudo apt-get install timidity pmidi






  2. sudo gedit /etc/modules

    and add the following lines:

    snd-seq-device
    snd-seq-midi
    snd-seq-oss
    snd-seq-midi-event
    snd-seq



  3. Download the Unison Soundfont:


    wget ftp://ftp.personalcopy.net/pub/Unison.sf2.gz



  4. Extract it to /etc/sounds:


    sudo mkdir /etc/sounds/
    tar -xzf Unison.sf2.gz
    mv Unison.SF2 Unison.sf2
    sudo mv Unison.sf2 /etc/sounds/






  5. sudo gedit /etc/timidity/timidity.cfg

    It should look like this (No more, no less):

    soundfont /etc/sounds/Unison.sf2






  6. sudo gedit /etc/init.d/timidity

    variable TIM_ALSASEQPARAMS (variable 22 I think), should look like this:

    TIM_ALSASEQPARAMS="-iA -B2,8 -Os1l -s 44100"






  7. sudo gedit /etc/default/timidity

    Uncomment the two TIM variables. It should look like this:

    # Defaults for TiMidity++ scripts
    # sourced by /etc/init.d/timidity
    # installed at /etc/default/timidity by the maintainer scripts
    # $Id: timidity.default,v 1.3 2004/08/07 14:33:26 hmh Exp $

    #
    # This is a POSIX shell fragment
    #

    # Enable MIDI sequencer (ALSA), default is disabled
    TIM_ALSASEQ=true

    # Setting overrides (of /etc/timidity.conf) for the ALSA sequencer daemon
    TIM_ALSASEQPARAMS="-iA -B2,8 -Os1l -s 44100"






  8. gedit ~/.bashrc

    Add the following line (A good idea is to add it after line 9):

    export ALSA_OUTPUT_PORTS="128:0"



  9. Done! Now you can play midis with pmidi. Like this:


    pmidi Song.mid


    If it doesnt work, reboot (just to be sure... Damn windows tick!)



Bonus: SCUMMVM
Now you can play scumm vm through alsa! Just follow these steps:




  1. gedit ~/.bashrc

    Add the following line (Again, after line 9 is a good idea):

    export SCUMMVM_PORT=128:0



  2. (If you want to create a launcher)


    gedit ~/.gnomerc

    Add the folowing lines:

    export ALSA_OUTPUT_PORTS="128:0"
    export SCUMMVM_PORT=128:0



  3. In scummvm, go to options, audio, music driver: ALSA



Good luck.

PD: Thanks to:


Note: I think Ubuntu should have MIDI support by default

Last edited by RastaMahata; August 21st, 2005 at 08:52 PM..

Friday, July 10, 2009

Tips about Ruby / Rails Arrays

Array Subsets and Supersets
http://adzdavies.blogspot.com/2008/02/array-subsets-and-supersets.html
-- useful tip about converting arrays into sets

Understanding Ruby Arrays
http://www.techotopia.com/index.php/Understanding_Ruby_Arrays
-- general info

Range checking -- lesson: KEEP IT SIMPLE, no need to be overly clever about your code
http://stackoverflow.com/questions/699448/ruby-how-do-you-check-whether-a-range-contains-a-subset-of-another-range

Thursday, July 9, 2009

Resetting the Root MySQL Password

(Source: http://www.tech-faq.com/reset-mysql-password.shtml)

  1. Stop the mysqld daemon process.

  2. Start the mysqld daemon process with the --skip-grant-tables option.

  3. Start the mysql client with the -u root option.

  4. Execute: UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';

  5. Execute: FLUSH PRIVILEGES;



These steps reset the password for the "root" account to "password". To change the password for a different account, or to set a different password, just edit the variables in single-quotes in step 4.

If you know your existing MySQL root password, steps 1-3 are not necessary.