Skip to content

Instantly share code, notes, and snippets.

@marcialca
marcialca / Creating and Deploying using Git Github and PHP
Created October 2, 2012 06:07
Creating and Deploying using Git, Github and PHP
/** Creating and Deploying using Git, Github and PHP **/
Prerequisites:
Server: SSH Acces, PHP, Git
Local: SSH, Git
0.Create a PHP file in your project called "deploy.php" with this content: /*<?php `git pull`;*/
1. Create Your Github Repo
2. Go to your project folder and initiate a git repository
@marcialca
marcialca / gist:3843274
Created October 6, 2012 00:45
[Ruby] [JS] Nice Rails JSON with Backbone.js
In order to get Rails to play well with Backbone you need to tell Rails not to return the root in the JSON return. This is accomplished by adding the following line to an initializer.
ActiveRecord::Base.include_root_in_json = false
@marcialca
marcialca / hacks.css
Created October 25, 2012 05:15
Selector Hacks by Paul Irish
/***** Selector Hacks ******/
/* IE6 and below */
* html #uno { color: red }
/* IE7 */
*:first-child+html #dos { color: red }
/* IE7, FF, Saf, Opera */
html>body #tres { color: red }
@marcialca
marcialca / gist:4043090
Created November 9, 2012 01:14
[CSS]CSS Count Increment
.box {
counter-increment: boxes;
}
The counter-increment property can accept either one or two properties. The first is an id that you will later use to reference this specific counter. You may also pass a second parameter that refers to the increment. For example, instead of 1, 2, 3, 4, you could switch to 5, 10, 15, 20 by applying: counter-increment: boxes 5.
This code will now store a unique number for each element that has a class of box. But of course, we want to get this number on the page. Hopefully, we’ll, at some point in the future, be able to use the content property within standard selectors, but not quite yet. Instead, we’ll use pseudo elements to apply the content.
.box:after {
content: counter(boxes);
}
@marcialca
marcialca / gist:4043102
Created November 9, 2012 01:17
[Rails] Ruby on Rails XAMPP MySQL config
gem install mysql2 -- --with-mysql-include=C:\xampp\mysql\include --with-mysql-lib=C:\xampp\mysql\lib\opt
@marcialca
marcialca / gist:4043107
Created November 9, 2012 01:18
[CSS] Click Event CSS3
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title></title>
<style>
figure { background: #e3e3e3; display: block; float: left;}
#zoom {
width: 200px;
-webkit-transition: width 1s;
@marcialca
marcialca / gist:4043119
Created November 9, 2012 01:20
[Rails] Rails + XAMPP + Windows + MySQL
gem install mysql2 -- --with-mysql-include=C:\xampp\mysql\include --with-mysql-lib=C:\xampp\mysql\lib\opt
At the time of building this gem, the necessary DLL files where available
in the following download:
http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick
And put lib\libmysql.dll file in your Ruby bin directory, for example
C:\Ruby\bin
@marcialca
marcialca / gist:4043123
Created November 9, 2012 01:22
[Rails] Can’t connect to MySQL server on ‘localhost’
My simple work around was going to config/database.yml file and changing the host to use 127.0.0.1 instead of localhost as follows.
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: quiz_development
pool: 5
username: root
password:
@marcialca
marcialca / gist:4043134
Created November 9, 2012 01:25
[CSS] Full Width Textareas
textarea {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 100%;
}
Setting the box-sizing to border-box allows the textarea to respect its parent container's padding and border, recalculating what 100% actually means. If the box-sizing were content-box, the textarea would continue to stretch outside the parent container as it would have before.
@marcialca
marcialca / gist:4043136
Created November 9, 2012 01:26
[CSS] Px to Em based on Context
target ÷ context = result
If we assume the body’s default type size to be 16px, we can plug each desired font-size value into this formula. So to properly match our header to the comp, we divide the target value (24px) by the font-size of its container (16px):
24 ÷ 16 = 1.5
So the header is 1.5 times the default body size, or 1.5em, which we can plug directly into our stylesheet.
h1 {
font-family: Georgia, serif;
font-size: 1.5em; /* 24px / 16px = 1.5em */
}