Skip to content

Instantly share code, notes, and snippets.

View nmenag's full-sized avatar

Nicolas Mena nmenag

View GitHub Profile
@nmenag
nmenag / angularjs_yeoman.md
Last active August 29, 2015 14:07
Angular generate project with yeomanjs

Tools

  • Bowerjs - install dependences
  • Gruntjs - server run
  • yeoman - scaffold generator

Install angularjs

@nmenag
nmenag / install_ruby.md
Last active August 29, 2015 14:07
Install Ruby and Ruby On rails in linux
  1. Install via RVM(Ruby version manager)

install RVM

-sudo apt-get install curl
- gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
-\curl -sSL https://get.rvm.io | bash -s stable

Load RVM

@nmenag
nmenag / youtube.php
Created January 11, 2015 03:50
Captura de videos en una lista de reproducción de youtube
echo '<!DOCTYPE html>
<html lang="es">
<head>
<style type="text/css">
body{font-size: 12px; font-family: monospaced}
ul, li{list-style-type: none}
textarea{
width: 300px;
height: 300px;
}
@nmenag
nmenag / user.rb
Created January 25, 2015 02:01
Creación de métodos dinámicos.
class User
STATUS = {active: "Active", inactive: "Inactive", invited:"Invited"}
STATUS.each_with_index do |(meth, value)|
define_method("is_#{meth}?"){status == value}
end
def initialize(name, email, password, status)
@name = name
@nmenag
nmenag / terminal.rb
Last active August 29, 2015 14:22
Module Jekyll for display a linux terminal
module Jekyll
class Terminal < Liquid::Block
def initialize(tag_name, text, tokens)
super
@text = text
end
def render(context)
text = super.gsub("\n", "<br/>")
var holidays =[]
//holiday model ruby, table that save all the holidays federal
holidays = "<%= Holiday.all.map{ |h| h.date.strftime("%Y-%m-%d") } %>";
/*example "2015-10-12", "2015-11-02", "2015-11-16", "2015-12-08", "2015-12-25", "2016-01-01",
"2016-01-11", "2016-03-21", "2016-03-24", "2016-03-25", "2016-05-01", "2016-05-09", "2016-05-30",
"2016-06-06", "2016-07-04", "2016-07-20", "2016-08-07", "2016-08-15", "2016-10-17", "2016-11-07",
"2016-11-14", "2016-12-08", "2016-12-25"]*/
$('.date').datepicker({
@nmenag
nmenag / date_diff.rb
Created January 22, 2016 16:24
Method for calculate the years and the months between two dates
def date_diff(date1, date2)
month = (date2.year * 12 + date2.month) - (date1.year * 12 + date1.month)
month.divmod(12)
end
#for get the years
date_diff(date, Date.today)[0]
#for get the months
date_diff(date, Date.today)[1]
@nmenag
nmenag / terminal.js
Last active January 22, 2016 16:26
Code javascript for display terminal in html
$(function() {
// Better performance in replacing js in any browsers. http://jsperf.com/encode-html-entities
if($.browser.name != "chrome") {
var tagsToReplace = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
' ': '&nbsp;',
'#': '<root>[root@localhost]# </root>',
'$': '<user>[user@localhost]$ </user>'
@nmenag
nmenag / sortable.js
Last active January 22, 2016 16:27
jQuery plugin sortable
(function ($) {
$.fn.sortable = function (options){
options = $.extend({
url: null
}, options);
return this.each(function (){
var handle = $(this);
var items = handle.children(options.items);
@nmenag
nmenag / gist:ab9cd4f49ddcd54bd3cc
Last active January 30, 2016 19:54 — forked from lttlrck/gist:9628955
Rename branch remote in Git
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote