This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fibbonacci = Hash.new do |accumulator, index| | |
| accumulator[index] = fibbonacci[index - 2] + fibbonacci[index - 1] | |
| end.update(0 => 0, 1 => 1) | |
| irb(main)> fibbonacci[100] | |
| => 354224848179261915075 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module W | |
| def foo | |
| "- Mixed in method defined by W\n" + super | |
| end | |
| end | |
| module X | |
| def foo | |
| "- Mixed in method defined by X\n" + super | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Say you have a string field in the DB that needs to be order like numbers | |
| #If you do the following... maybe its not what you want: | |
| Document.order(:number).pluck(:number) | |
| => [ "1", "10591059616", "100", "2", "22"....] | |
| # But if you do...: | |
| Document.order("LENGTH(documents.number), number").pluck(:number) | |
| => ["1", "2", "22", "99", "100", "10591059616"...] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.datepicker.regional['es'] = { | |
| closeText: 'Cerrar', | |
| prevText: '<Ant', | |
| nextText: 'Sig>', | |
| currentText: 'Hoy', | |
| monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'], | |
| monthNamesShort: ['Ene','Feb','Mar','Abr', 'May','Jun','Jul','Ago','Sep', 'Oct','Nov','Dic'], | |
| dayNames: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'], | |
| dayNamesShort: ['Dom','Lun','Mar','Mié','Juv','Vie','Sáb'], | |
| dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','Sá'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # based on Haversine formula | |
| # http://en.wikipedia.org/wiki/Haversine_formula | |
| distance = (lat1, lon1, lat2, lon2) -> | |
| R = 6371 | |
| a = 0.5 - Math.cos((lat2 - lat1) * Math.PI / 180) / 2 + Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) * (1 - Math.cos((lon2 - lon1) * Math.PI / 180)) / 2 | |
| R * 2 * Math.asin(Math.sqrt(a)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ifconfig wlan 2>/dev/null || ifconfig en0) | grep inet | grep -v inet6 | awk '{print $2}' | sed 's/addr://g' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .page-break | |
| display: block | |
| clear: both | |
| page-break-after: always |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #1. Using lynx | |
| brew install lynx | |
| lynx --dump http://ipecho.net/plain | |
| #2. Using curl | |
| curl http://ipecho.net/plain |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| du -sh `rbenv root`/versions/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # app/assets/javascripts/active_admin.js.coffee | |
| #= require active_admin/base | |
| ActiveAdmin = { | |
| dashboard: {}, | |
| user: {} | |
| } | |
| ActiveAdmin.dashboard.index = () -> | |
| console.log 'Hello' |