Skip to content

Instantly share code, notes, and snippets.

View hernanvicente's full-sized avatar

Hernan Maguina hernanvicente

View GitHub Profile
@hernanvicente
hernanvicente / rails_admin.es.yml
Last active September 12, 2018 13:48 — forked from Knack/rails_admin.es.yml
Spanish (Spain) translation for RailsAdmin
es:
admin:
js:
true: Cierto
false: Falso
is_present: Está presente
is_blank: Está en blanco
date: Fecha ...
between_and_: Entre ... y ...
today: Hoy
import DS from 'ember-data';
export default DS.RESTAdapter.extend({
host: 'http://dummy.restapiexample.com/api/v1'
});
@hernanvicente
hernanvicente / convert-UNIX-timestamp.js
Created March 30, 2017 22:19 — forked from kmaida/convert-UNIX-timestamp.js
Convert a UNIX timestamp to user's local time via JavaScript
function convertTimestamp(timestamp) {
var d = new Date(timestamp * 1000), // Convert the passed timestamp to milliseconds
yyyy = d.getFullYear(),
mm = ('0' + (d.getMonth() + 1)).slice(-2), // Months are zero based. Add leading 0.
dd = ('0' + d.getDate()).slice(-2), // Add leading 0.
hh = d.getHours(),
h = hh,
min = ('0' + d.getMinutes()).slice(-2), // Add leading 0.
ampm = 'AM',
time;
@hernanvicente
hernanvicente / move_out_first_image_with_nokogiri.rb
Last active August 29, 2015 14:07
Move out (extract) image with nokogiri
require 'open-uri'
require 'nokogiri'
# set the document's url
my_post_uri = "https://blog.heroku.com/archives/2014/9/23/introducing-heroku-dx"
# get the document to parse
document = Nokogiri::HTML(open(my_post_uri), nil, 'UTF-8')
# parse the element
post_body = document.at_css("div.post_body")
<script type="text/javascript" src="jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function(){
$("#image").change(function(){
var file = document.getElementById("image").files[0];
@hernanvicente
hernanvicente / age.rb
Created February 25, 2014 06:34 — forked from emad-elsaid/age.rb
require 'time'
Date_of_birth = '1988-8-31'
# Credit to : http://stackoverflow.com/questions/4136248/how-to-generate-a-human-readable-time-range-using-ruby-on-rails
# and modified a little bit
def humanize secs
[
[60, :seconds],
[60, :minutes],
@hernanvicente
hernanvicente / recursive-erb2haml
Created May 30, 2011 19:15
recursive erb to haml
for f in `find . -regex '.*\.html\.erb'`; do echo "Converting $f" && html2haml $f > "${f%.erb}.haml" && rm $f; done
TRUNCATE table1, table2, table3 RESTART IDENTITY;
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: mysql
database: database_development
user: root
password:
socket: /tmp/mysql.sock
pool: 5
timeout: 5000
---
:verbose: true
:bulk_threshold: 1000
:benchmark: false
:sources:
- http://rubygems.org/
- http://gems.github.com
gem: --no-ri --no-rdoc
:update_sources: true
:backtrace: false