Skip to content

Instantly share code, notes, and snippets.

View juanmanuelramallo's full-sized avatar
:bowtie:
🧙‍♂️

Juan Manuel Ramallo juanmanuelramallo

:bowtie:
🧙‍♂️
View GitHub Profile
@juanmanuelramallo
juanmanuelramallo / md-preview.rb
Created August 30, 2020 16:14
Github styled markdown preview
#!/usr/bin/ruby
# Place this file in /usr/local/bin/
# It uses Github API to generate the HTML from the Markdown
# It includes the Primer CSS stylesheet
# It adds the body class needed and some spacing for the body
# It opens Chrome with the HTML generated
# It deletes the file when you interrupt the process
require 'bundler/inline'
@juanmanuelramallo
juanmanuelramallo / action_cable_client.js
Last active May 17, 2019 15:39
Basic client action cable connection
// somewhere in ./app.js
if (this.state.authenticated) {
this.cable = connectWS(accessToken, client, uid);
}
// ./channels/connection.js
import ActionCable from 'actioncable';
import { env } from '../env_vars';
export function connectWS(accessToken, client, uid) {
@juanmanuelramallo
juanmanuelramallo / vcr_sugar_syntax.rb
Created May 14, 2019 19:22
A simple helper to use vcr in tests
RSpec.configure do |c|
c.around(:each, :vcr) do |example|
name = example.metadata[:full_description].split(/\s+/, 2).join('/').underscore.gsub(%r{/[^\w\/]+/}, '_')
VCR.use_cassette(name) { example.call }
end
end
# Usage
# it 'should create a new credit card with given information', :vcr do
@juanmanuelramallo
juanmanuelramallo / convert_svg_to_ico.sh
Created September 18, 2018 15:23
How to convert a svg to ico
convert -density 384 -background transparent logo.svg -format ico -resize 32x32 favicon.ico
@juanmanuelramallo
juanmanuelramallo / Carousel.html
Created August 17, 2018 00:08
Little carousel object with touch events and slide animation in plain javascript (with a little of jQuery)
@juanmanuelramallo
juanmanuelramallo / URLParameters.js
Last active July 5, 2017 19:21
Handling URL Parameters with plain javascript and Lodash
function URLParameters(str) {
this.queryString = typeof(str) === 'undefined' ? document.location.search : str;
this.params = {};
this.parse = function(string) {
if (string && !_.isEmpty(string)) {
var obj = {};
var pairs = string.replace('?', '').split('&');
pairs = _.map(pairs, function(pair, index) {