Everything I Plan on Forgetting

notes and cool things on the stupid stuff i do

can't start mysql with bind address

Wow what a nightmare.  I'm trying to grant remote mysql access on my ec2 instance.  So I go though the steps

  1. edit /etc/mysql/my.cnf and change the bind-addess to my server ip
  2. create a new user in mysql, grant privileges and flush privileges
  3. open up mysql port on ec2 console security tab
  4. ok time to restart mysql now with /etc/init.d/mysql restart

Got the error message:

Rather than invoking init scripts through /etc/init.d, use the service(8) utility, e.g. service mysql restart

Ok no problem let's try the new way with 'service mysql restart'

and it hangs..........  Two hours later i'm hating computers.  Ok but here's the trick.

 

In short here's the answer.  The amazon gives out elastic ips and this is what i put as my bind-address back in step one.  Apparently this is not the right address and they don't propery give me an error message to tell me this.  type ifconfig, get the private ip address and set it there.  Voila.  There ya go.

My ubuntu new server checklist

Ok so I setup a new ubuntu server every once in a while and I have a hard time figuring everything out.  So here's my checklist of the stuff I end up painstakingly look up to do over and over again.


  1. Create New User
    • sudo useradd -d /home/NEWUSER -m NEWUSER (the d flag is to set the home directory and the m flag is to create the directory)
  2. Change Password
    • sudo passwd testuser
  3. Add User to admin group OR do #4
    • usermod -g admin NEWUSER
  4. Give Sudo Access in /etc/sudoers (the first is no password asked for sudo, and the 2nd asks for password to sudo)
    • user1  ALL=(ALL) NOPASSWD:ALL 
    • user2  ALL=(ALL) ALL
  5. Enable Bash Script on new user
    • Go to /etc/passwd and change line to something like this: user1:x:1001:1001::/home/user1:/bin/bash
  6. SSH disconnecting?  Well, keep the connection alive.
    • Edit /etc/ssh/sshd_config
    • Add line TCPKeepAlive yes
  7. Bash rc stuff
    • Edit ~/.bashrc
    • grep auto-coloring: export GREP_OPTIONS='--color=auto'
    • rails env: export RAILS_ENV=staging

Tsunami in Emeryville!

So you kno that 8.8 earthquake that hit the eastern coast of japan today?  Well, it caused a tsunami in emeryville, ca where I live!

 

Kinda weak, but also amazing that it traveled all this way from japan.  I hope my shits ok...

Filed under  //   8.8   awesome   earthquake   emeryville   japan   tsunami  

Everything I don't want to kno about freeBSD

Ok, so for the most part I develop on mac and run my apps on ubuntu.

But I have this older project I'm maintaining on a freeBSD distro.  So I had to do some stuff on it.  Here's the log of stuff I did

  1. Update Ports.  I guess this is the debian apt-get eqivalent of freebsd
  2. Uninstall lighttpd
  3. Reinstall lighttpd

 # portsnap fetch
 # portsnap update
 # cd /usr/ports/www/lighttpd
 # make deinstall
 # make reinstall
 

That didn't fix my problem, but had to figure this out anyway. Also the machine was monitoring lighttpd with supervise unable for me to shut down the service. If i try to stop/kill lighttpd, supervise fires it up again to my annoyance. On my machine there is a /service folder with symlinks to other folders. I had to remove the symlink from the /service folder and run a svc -dx /path/to/where/symlink/links/to

Filed under  //   unix freebsd lighttpd install ports  

Rails: View SQL queries in the console

So you see the queries in your rails server log as you are playing with your app, but what about when you are testing in console?  I'm sure there are other ways to do it, but this does the trick.  Just start up your rails console and type this line in. 

ActiveRecord::Base.logger = Logger.new(STDOUT)

Look at the awesomeness.

script/console
Loading development environment (Rails 2.3.10)
>> ActiveRecord::Base.logger = Logger.new(STDOUT)
=> #<Logger:0x103332350 @formatter=nil, @level=0, @default_formatter=#<Logger::Formatter:0x103332300 @datetime_format=nil>, @progname=nil, @logdev=#<Logger::LogDevice:0x1033322b0 @filename=nil, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x103332260 @mon_entering_queue=[], @mon_count=0, @mon_owner=nil, @mon_waiting_queue=[]>, @dev=#<IO:0x100177ba8>, @shift_size=nil, @shift_age=nil>>
>> Campaign.find :first
  SQL (0.2ms)   SET NAMES 'utf8'
  SQL (0.1ms)   SET SQL_AUTO_IS_NULL=0
  Campaign Load (0.4ms)   SELECT * FROM `campaigns` LIMIT 1
  Campaign Columns (9.6ms)   SHOW FIELDS FROM `campaigns`

On the topic on viewing queries, a cool rails 3 tip is the .to_sql method



rails c
Loading development environment (Rails 3.0.5)
ruby-1.9.2-p136 :001 > ExtractionLink.where(:status => 'new').order('name').to_sql
 => "SELECT `extraction_links`.* FROM `extraction_links` WHERE `extraction_links`.`status` = 'new' ORDER BY name"


 

Filed under  //   console   programming   rails   rails2   rails3   ruby   sql  

Hello Blogging World (try number like 302)

Hello blog world filled a bunch of crap.  Time for me to once again try to start blogging.  This site is primarily for me to log everything I learn, because I've been learning a lot and forgetting a lot.  If I put it here, at least I know where to find it.  As a positive side effect, i may be able to help some people with my very random collection of information I plan on posting about.  Here we go!