Your web-browser is very outdated, and as such, this website may not display properly. Please consider upgrading to a modern, faster and more secure browser. Click here to do so.
Sometimes after closing an app the port is still on, and when you start a new project you might get an error:
`start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
To solve this, you want to grab out the ruby process
ps -e | grep "ruby"
This should return some system information. The first number is the process ID that we need to kill:
Let’s say .gitignore lives in the same directory as your current repository. To ignore an entire folder within your directory, just do this:
Folder_2 is a folder in your project’s root directory, and everything inside folder 3 will be ignored.
To ignore every file ending with swp, just write this:
So before I push my code to github, i realized that a passwords.txt file is included in my repo. I must remove it, so I created a .gitignore file in my current folder (root folder of github repo). In this .ignore file I type passwords.txt but when i typed
git status the passwords.txt file is still there.
git rm -r --cached
git add git commit -m "fixed untracked files"
When you use Environment variables in your config files, you will most likely get rake failed error. To fix this, you’ll need to change some settings:
Install Heroku Plugins:
heroku plugins:install https://github.com/heroku/heroku-labs.git
Enable environment compilation
heroku labs:enable user-env-compile -a
In your rails
config/production file, add
To Change Rails Environment, simply type:
Sometimes, you only want to get out a few column data from a database entry. To select only the columns, you can select the columns you like:
Appointment.select("name, website, city")
Set the margin-top to half of the div’s height, Set the margin-left to half of the div’s width!
Got the code form this guy
In the console, here’s a few keyboard shortcuts that can really help:
$ gibberioawigjoawirga //Control-C will clear the gibberish so you don't have to hold on to backspace for a long time $ oiajrg oaeg oia eg //Control-W will delete words backwards, one by one Control-R will recursively search for the last written command, so you don't have to type alot. It's better than using up arrows. Control-L clears everything above your current cursor.
Css3 has a great property called WordWrap. If you have a LOOOOOOOONG word without any space, usually the word will go out of your container, making it look horrible. Wordwrap breaks the long word in to new lines:
word-wrap takes either
Cursor should be on top of a number. Then hit CTRL + A and the number should increment.
To use a database:
To Look at all the Tables in a database:
show tables from database;
To see all the columns in a table:
select name,username,size from user where id=14371911 ORDER BY created_at;
To debug web apps, you have console. Mobile browsers don’t have a console, debugging is hard. Weinre lets your browser become the console so you can easily debug web apps on mobile.
Make sure phone and your computer is on same network. Type
ifconfig in terminal to get your IP address.
weinre --boundHost 0.0.0.0
Copy the script tag, change ‘localhost’ to your computer’s IP address (from ifconfig) and paste it into your mobile web app.
Run your mobile web app, and your mobile client should light up on your browser. Click on it and start debugging!
One mistake that I often do is that I often expose my key/secret combo for APIs to github if I push my project. To solve this, modify your bash profile!
Step 1: Open
Step 2: Add Keys
export FP_KEY_L='....' export TB_KEY='...' export TB_SECRET='...'
Step 3: Save and Exit, then open new Terminal OR refresh your ~/bash_profile
That’s it! In your ruby files, type:
OpenTok_Key = ENV['TB_KEY']
This will automatically pull your environment variables from bash_profile. No need to expose your key anymore when you push to github!
What if you push it to Heroku? How do you update Heroku’s environment variables so you don’t have to change your code?
Type in terminal:
heroku config:add FP_KEY_L='...'
To add multiple keys, just list them with spaces
heroku config:add S3_KEY="..." S3_SECRET="..."
I got the heroku information from their blog
When playing with CSS, sometimes I’d fix the dom object to a certain width. However, this width will change if I add padding to it, and it screws up all design. To solve, this, CSS3 has a property called Box Sizing, which will fix width to exactly how much you specify, and automatically adjust width of content:
Page 1 of 4