Skip to content

Instantly share code, notes, and snippets.

View rodcisal's full-sized avatar

Rodrigo Cisternas Albornoz rodcisal

  • Paris
View GitHub Profile
@rodcisal
rodcisal / gist:2942882
Created June 16, 2012 23:50
Calculadora de IMC on-the-fly
<script type="text/javascript">
function calcular(a,b) {
imc = (a / (b*b));
document.getElementById("resultado").innerHTML = Math.round(imc*10)/10;
if (imc<=19.90) {
document.getElementById("diagnostico").innerHTML= " Desnutrición";
}
else if (imc>19.90 && imc<=25) {
document.getElementById("diagnostico").innerHTML= " Peso Normal";
}
@rodcisal
rodcisal / gist:3851146
Created October 8, 2012 07:10
start/stop postgresql in development
Startup/Shutdown
Next, as the instructions suggest you can set Postgres to start and stop automatically when your mac starts. Run these three commands to have this happen (Postgres will start when you run the last command so there is no need to manually start it if you do this):
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.0.4/org.postgresql.postgres.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
I’ve done this because I use Postgres for all my personal projects. If you’re just experimenting and want to control when it is running you can start and stop Postgres with these commands (perhaps with a shell alias). EDIT: Someone on the Hacker News thread suggested Lunchy for managing launchctl stuff, I’ve not tried it, but it looks useful.
Start Postgres:
@rodcisal
rodcisal / gist:4291685
Created December 15, 2012 06:15
Crear DB en pg
createuser nombre
createdb -Opostre -Eutf8 postre_development
@rodcisal
rodcisal / gist:5754132
Created June 11, 2013 02:32
Smooth Scrolling
$('.menu').bind('click',function(event){
var $anchor = $(this);
$('html, body')
.stop() //stop the animation
.animate({
scrollTop: //scrollTop setea la barra de scroll
$($anchor.attr('href'))
.offset()
.top
@rodcisal
rodcisal / gist:5935024
Created July 5, 2013 14:44
activar clase de elemento en navigation bar
(function activarClase () {
aObj = document.getElementById('nav').getElementsByTagName('a');
for(i=0; i< aObj.length; i++) { if (document.location.href.indexOf( aObj[i].href )>=0 ) { aObj[i].parentNode.className = 'mini-bloque activo'; } }
})();
@rodcisal
rodcisal / gist:6661805
Created September 22, 2013 16:52
media queries
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
guard 'livereload' do
watch(%r{content/pages(/.+)\.(mdown|textile|haml)}) { |match| match[1] }
watch(%r{public(/.+\.(jpe?g|js|png))}) { |match| match[1] }
watch(%r{views/.+\.haml})
watch(%r{views/.+\.html.erb})
watch(%r{assets/stylesheets/(.+)\.s[ac]ss}) do |match|
if match[1] =~ /(mixins|variables)/
["/css/master.css", "/css/layout.css"]
else
"/css/#{match[1]}.css"

Because somehow I always end up trolling the interwebs looking for a reference for these.

Symbol Code Entity Name
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
* html .clearfix { zoom: 1; } /* IE6 */
*:first-child+html .clearfix { zoom: 1; } /* IE7 */
@rodcisal
rodcisal / gist:7419dbc464b1427dd0cf
Created November 27, 2014 19:57
Famous micro clearfix
.element:before,
.element:after {
content: " ";
display: table;
}
.element:after { clear: both }
.element { *zoom: 1 }