Saturday 28 January 2012

Sunday 22 January 2012

aws cdn

http://net.tutsplus.com/articles/general/supercharge-website-performance-with-aws-s3-and-cloudfront/

css3 compressor

http://devilo.us/

Saturday 21 January 2012

sql php script

#!/bin/bash

# this is run by the root crontab

datetime=`date '+%m-%d-%y-%H-%M-%S'`
/opt/lampp/bin/mysqldump -uUSER -pPASSWORD xtec | gzip > /root/backups/backup-$datetime.gz


sql backup with php

sql backup with php


exec("mysqldump -udbuser1 -p12345 --databases db1 db2 > /home/user1/dbbackup-".date('Y-m-d').".sql");

exec("tar -zcvf /home/user1/dbbackup-".date('Y-m-d').".tar.gz /home/user1/dbbackup-".date('Y-m-d').".sql");

unlink("/home/user1/dbbackup-".date('Y-m-d').".sql");

@unlink("/home/user1/dbbackup-".date('Y-m-d', strtotime("now -3 days")).".tar.gz");

exec("s3cmd put /home/user1/dbbackup-".date('Y-m-d').".tar.gz s3://database-backups");


mysqldump ---user admin ---password=password mydatabase > sql.dump





crontab -e

/* backup every day at 00:00:00 */
0 0 * * * mysqldump -u root -ppassword YOUR_DATABASE > /backup/YOUR_DATABASE.sql




auto srat apache
sudo /sbin/chkconfig --levels 235 httpd on
sudo service httpd start

php mailer

http://swiftmailer.org/

Friday 20 January 2012

TODO:

The General Cause

Overall the general cause of all of these problems can be summarized as treating programming as an obsession. You may want to be very good at it, like I did, so you exclude everything else in your life in order to master it. You don't go to the bathroom, you have macho 10 hour coding sessions, you don't eat right, and all manner of mythological beliefs about "real programmers".
Truth is real programmers are kind of idiots. They don't eat right. They don't have sex on a regular basis. They can't run without gasping for breath. They have huge problems with their internal organs not caused by disease. Really, it's just not worth it if you have to kill yourself to be good at something.
So, as you read through each of these problems and how I've cured them, remember that it's all about just having a balanced life and not being obsessed with coding or your business. Trust me when I say you will actually become better if you take it easy on yourself and stay healthy.




First up, if you can, get the best damn bed you can afford. 2000+ dollars is nothing for a great bed. I spent at least 2200 on a sweet Tempur-Pedic. It's totally worth it.
Now with your awesome bed here's how you start practicing getting to sleep easily. It's kind of a self-hypnosis trick:
  1. Make sure that you've killed all sounds and lights that might be in your room.
  2. Lay on your back and put your hands on your body somewhere comfortable, or at your sides.
  3. Start breathing in deeply and slowly and breathing out, as you do this imagine you can see the air flow in and out of your body.
  4. Once you start to see your breath, imagine that you're looking through a window and outside the window is a large huge open space with stars in it.
  5. As you breath feel yourself float through the window and slowly out into the massive expanse of stars, all floating softly around you.
  6. Keep this going and then just let this floating spread into your bed and out around you until there is nothing.




http://sheddingbikes.com/posts/1281257293.html



http://ruby.learncodethehardway.org/book/





TODO:

The same goes for programmers as it goes for pretty much everyone else ... watch your intake (most people today - even the skinny ones - take lots more in then they need) and do some kind of physical activity (swimming, running and cycling for example).
Now, most would say ... I haven't got the time for that. - but it is all questionable. For, programming is first thinking, typing second (or third) - you haven't actually got to be at your computer all of the time to do your work, as long as you can think of it (this has some issues with certain people, but if you show you're good at what you do they usually agree that they don't have to make you sit on your chair all the time, for you to do your job) and have the mental capabilities to visualize it in your head (most do).
... all there is to it, really. People are ment to move and have been moving for several millenia now ... no magic in that area (in regards to food, diets, whatever) will let them stay healthy if they sit on their respected ones all they long.
p.s. Laptops help ... you can work in several places (e.g. from the garden at home, ... can easily rearrange your office at work ... Hell, you can go to the mountains in your car, just find a nice place, lay somewhere and enjoy the scenery and work ...)

http://www.pomodorotechnique.com/

http://www.pomodorotechnique.com/

Thursday 19 January 2012

textmate js import

drag and drop in html file
your scripts or css files :)

texmate will do

                <script src="jquery.numberformatter-1.2.2.min.js" type="text/javascript" charset="utf-8"></script>

backup cloud program

This tutorial is going to walk you through creating your own backup cloud program. The concept and script are very simple, using Amazon Web Service and the S3Tools command line program, we are going to create a script that syncs files to our Amazon S3 bucket, allowing us to create our own backup cloud program. We'll show you how to write the script and create the schedule task using iCal and AppleScript.



http://www.youtube.com/watch?v=LU04P9GpHHc

simple aws route53 domain

route53

1.Install server
2.attach elastic ip to server
3.add new hosting zone to route53 with the domain you own
4.update domain (register) name servers
5.create a new record set
type: IPV4
record type: A
with name www.something.com (www VERY important)
and add the ip

finish :D







http://www.youtube.com/watch?v=qsUKki0TUuc

Multiple Websites on Amazon EC2 Linux with Virtual Hosts



 n my previous article outlining how to setup an instance of WordPress on Amazon’s EC2 Cloud hosting a Linux server with Mac, I described a single website setup for the server. In an addendum to that article, I’m going to give short instructions on setting up multiple websites on that instance using apache’s virtual hosts. The setup is remarkably simple. There are two main steps: 1) Setting up your sites structure, and 2) Setting up your vhost configuration. This tutorial assumes you have terminal and ssh access into your site, for instructions on how to set those up, see the SSH portion of my previous article.

Setup Website Structure

Start by setting up your wordpress (or any) site in the document root folder. Having followed my previous instructions, it will be located at /var/www/html, and you should be able to browse to it via a program like Coda or Transmit.
From this location, copy in new wordpress installations. The easiest way is to download them to your computer and drag them in, however, here are the terminal:
Go to Document Root
cd /var/www/html
Download new version of WP into your document root
wget http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz -C /var/www/html
mv wordpress calebogden.com
From here you’ll want to rename your folder from wordpress to whatever you’re site is called, as shown above mine was called calebogden.com. You should (in a GUI) see a similar structure to this:
NOTE: You may have to give your folders the correct permissions. If you get any permission errors, use these lines:
chown -R apache /var/www/html
chmod -R 755 /var/www/html
Now that you’ve created all the sites you’d like to host, do a quick restart on your apache service:
service httpd restart
Grand! Now that you have your sites setup we can work on apache’s configuration. The config file has tons of options, but my requirements (and thus setup) were quite simple. I’ll show you the baseline setup on how to get these work, and if you have additional questions on advanced configuration you can check out the documentation.
To setup your vhost, browse in SSH to your apache configuration folder:
etc/httpd/conf.d
If you don’t have a file named vhost.conf, you should go ahead and create it. Make sure your file permissions are right (644). This can all be done through VIM, but using a GUI here is going to be a ton easier, as you’ll appreciate the luxury of copy / paste.
The structure of the config is simple, new virtual hosts are setup through creating new nodes in the config files. A node can look like the one below:
<VirtualHost *>
ServerName example.com
DocumentRoot /var/www/html/example.com
</VirtualHost>


The simplest setup is with a name-based approach, although IP approaches are available, since the previous tutorial functions on one elastic IP from Amazon EC2, we’ll stick with name based. To read about the differences, check out this post.
After you have your nodes setup (you can literally just replace example.com with your directories / website), you’ll need to make sure the head of your vhost.conf file has the following directive:
NameVirtualHost *
The NameVirtualHost directive always you to specify the IP address on which the server will receive requests, for our purposes here, accepting them with a * is fine, although you may want to further specify your IP address. If you do specify your IP address, keep in mind you can also specify the port. You read more about the NameVirtualHost directive here.
After you get all your items setup, you should have something similar to the following:
NameVirtualHost *
<VirtualHost *>
ServerName example.com
DocumentRoot /var/www/html/example.com
</VirtualHost>

<VirtualHost *>
ServerName calebogden.com
DocumentRoot /var/www/html/calebogden.com
</VirtualHost>

<VirtualHost *>
ServerName cssbutton.me
DocumentRoot /var/www/html/cssbutton.me
</VirtualHost>


That’s pretty much it! Make sure to restart your apache service and you’re good to go. Enjoy hosting multiple sites from your EC2 Linux instance :-). I’ve opened up comments on this post to answer any questions about the setup.









http://calebogden.com/multiple-websites-amazon-ec2-linux-virtual-hosts/




Wednesday 18 January 2012

css sprite

SpriteMe


<a style="font-size: 1.2em;" href="javascript:(function(){var%20spritemejs=document.createElement('SCRIPT');spritemejs.type='text/javascript';spritemejs.src='http://spriteme.org/spriteme.js';document.getElementsByTagName('head')[0].appendChild(spritemejs);})();">SpriteMe</a>

Tuesday 17 January 2012

EU HTML select

Country of residence (EU ONLY):

PART 2

Friday 13 January 2012

aws

transmit:
http://jeffreysambells.com/posts/2010/08/04/connecting-to-amazon-ec2-using-transmit/


LAMP:
www.calebogden.com/wordpress-on-linux-in-the-amazon-cloud-with-mac/

VH:
http://calebogden.com/multiple-websites-amazon-ec2-linux-virtual-hosts/

videos:
http://aws.amazon.com/resources/webinars/?vid=33oxPUvdR-Y&p=B5E292665ECEAA1F&cue=play&t=How%20to%20Launch%20a%20Website%20in%2010%20Minutes&pass=http://aws.amazon.com/resources/webinars/



buckets:
http://aws.amazon.com/cloudformation/aws-cloudformation-templates/aws-cloudformation-templates-ap-southeast-1/

Wednesday 11 January 2012

AWS simple steps

1.) new instance
2.) download the private key (enterprisedhosts.pem)
3.) ssh -i enterprisedhosts.pem ec2-user@ec2-175-41-160-86.ap-southeast-1.compute.amazonaws.com
4.)   sudo yum -y update
5.)    sudo yum -y install aspell aspell-en aspell-fr aspell-es cvs httpd mysql mysql-server php php-cli php-gd php-intl php-mbstring php-mysql php-pdo php-soap php-xml php-xmlrpc php-pspell
6.)    sudo yum list installed
7.) start services also when machine is restarts
sudo  /sbin/chkconfig httpd on
 sudo   /sbin/chkconfig mysqld on
 sudo  /sbin/service httpd start
 sudo   /sbin/service mysqld start

------------------------------------
change mysql pass:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h ip-10-128-194-183 password 'new-password'

--------------------------------------
If you need to edit httpd.conf it is in /etc/httpd/conf
8.)     sudo  /sbin/service httpd restart


9.) create new elasticIP address and associate it with an instance
10)go to security / groups and open port 80 (depends in witch groups belongs tour instance)

11.) open Public DNS: ec2-46-137-241-215.ap-southeast-1.compute.amazonaws.com

TARaaaaa :D


SOS:
NEXT TIME LOGIN TO:
ec2-46-137-241-215.ap-southeast-1.compute.amazonaws.com
because we change the ip:

msRoot:ssh -i enterprisedhosts.pem ec2-user@ec2-46-137-241-215.ap-southeast-1.compute.amazonaws.com



--install git and clone a repo
edit: sudo vim index.html
and:
http://ec2-46-137-241-215.ap-southeast-1.compute.amazonaws.com/git/html5boilerplate_t/

LAMP on AWS

Rent an ec2 instance

You can set up an account with Amazon Web Services and rent out a ec2 instance here The Amazon Web Service Console
I used an instance of the Amazon Linux AMI based on Elastic Block Store. Using an instance based on an Elastic Block Store gives you more options for backing up your disks later. The "Amazon Linux AMI" is based on CentOS and is a pared down version of linux with only the bare essentials included, that should be more secure. You can use the yum command to install anything extra necessary on your server.

Attach an 'elastic ip' and open necessary ports on firewall

Again through the The Amazon Web Service Console :
  • I created and attached an elastic ip address to the ec2 instance I had launched with the Amazon Linux AMI.
  • I opened ports 22 and 80. For my purposes I did not intend to make the server accessible through https so these were sufficient.
You may want to map a domain name to point to your elastic IP address. You will need a dns provider to do this. Amazon does not provide this service at the time of writing.

Connect to your ec2 instance with putty or another ssh client

Through the The Amazon Web Service Console you can set up an ssh key and attach it to the ec2 instance you have running.
Your username for an ec2 instance using the Linux AMI will be ec2-user and no password will be required if you have the private key set up correctly.

Accessing ec2 instance using putty ssh client

In order for this key to work with putty on Windows you need to import it using puttygen and then save the private key in a safe location possibly with a pass phrase (local password) to protect it. You can then associate the key file with the ssh connection in putty by opening settings in Connection/SSH/Auth and browsing for the correct 'Private Key for Authentication'

Setting up a web server on Amazon Linux AMI

Make sure all your currently installed packages are up to date.
sudo yum -y update
You use yum to install all the software you need on your server. You can use the following command to install apache, mysql and php and the php extensions and all dependencies required by Moodle with this command :
sudo yum -y install aspell aspell-en aspell-fr aspell-es cvs httpd mysql mysql-server php php-cli php-gd php-intl php-mbstring php-mysql php-pdo php-soap php-xml php-xmlrpc php-pspell
You can list all your installed packages (including dependencies) with this command :
sudo yum list installed

Start server services and have them start up automatically on a reboot

Configure the new services to start automatically.
sudo  /sbin/chkconfig httpd on
   sudo   /sbin/chkconfig mysqld on
   
   sudo  /sbin/service httpd start
   sudo   /sbin/service mysqld start

Edit httpd.conf

If you need to edit httpd.conf it is in /etc/httpd/conf
But by default the directory /var/www/html/ is the root web directory and you can install Moodle in there.
If you do edit httpd.conf then you must restart apache using this command for the changes to take effect :
sudo  /sbin/service httpd restart

Set up MYSQL

sudo mysqladmin -u root password 'new-password'
Make additional security-related changes to mysql.
sudo mysql -u root -p
mysql> DROP DATABASE test;                            [removes the test database]
mysql> DELETE FROM mysql.user WHERE user = ;        [Removes anonymous access]
mysql> FLUSH PRIVILEGES;
 
http://docs.moodle.org/22/en/Installation_Guide_for_Installing_on_Amazon_EC2

pusher.com

Pusher is a hosted API for quickly, easily and securely adding scalable realtime functionality to web and mobile apps.


open http://pusher.com/ and after

curl -d "hello world" "http://api.pusherapp.com/apps/1480/channels/CPxk9Zgk/events?name=my_event&body_md5=5eb63bbbe01eeed093cb22bb8f5acdc3&auth_version=1.0&auth_key=765ec374ae0a69f4ce44&auth_timestamp=1326291233&auth_signature=9afcfe73acfad65de21de2b1c8e7c6b5b6dc2350cc9b4d46b04adbea714bfffa"



event posted from terminal with curl to pusherapp.com and display it with javascript