Skip to content

Instantly share code, notes, and snippets.

View jCrip's full-sized avatar
🏠
Working from home

Juan Cristobal Pazos jCrip

🏠
Working from home
  • Modyo
  • Santiago, Chile
View GitHub Profile
@jCrip
jCrip / slugify.js
Created December 23, 2020 13:18 — forked from hagemann/slugify.js
Slugify makes a string URI-friendly
function slugify(string) {
const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;'
const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------'
const p = new RegExp(a.split('').join('|'), 'g')
return string.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
.replace(/&/g, '-and-') // Replace & with 'and'
.replace(/[^\w\-]+/g, '') // Remove all non-word characters
@jCrip
jCrip / bootstrap-4-sass-mixins-cheat-sheet.scss
Last active August 27, 2020 14:59 — forked from anschaef/bootstrap-4-sass-mixins-cheat-sheet.scss
Bootstrap 4 Sass Mixins [Cheat sheet with examples]
/* -------------------------------------------------------------------------- */
// All Bootstrap 4 Sass Mixins [Cheat sheet]
// Updated to Bootstrap v4.5.x
// @author https://anschaef.de
// @see https://github.com/twbs/bootstrap/tree/master/scss/mixins
/* -------------------------------------------------------------------------- */
// Grid variables
$grid-columns: 12;
$grid-gutter-width: 30px;
@jCrip
jCrip / vue-uppercase.js
Created June 12, 2020 17:24 — forked from TheTrigger/vue-uppercase.js
vuejs uppercase directive
Vue.directive("uppercase", {
twoWay: true,
// TODO: unbind
unbind: () => {},
bind: function (el, binding, vnode) {
const findVModelName = vnode => {
try {
// https://forum.vuejs.org/t/solved-how-can-you-update-the-v-model-from-a-custom-directive-in-vue-2/2275
return vnode.data.directives.find(o => {
return o.name === "model";
@jCrip
jCrip / xmlToJson.js
Created April 17, 2018 19:26 — forked from chinchang/xmlToJson.js
Function to convert XML to JSON
// Changes XML to JSON
// Modified version from here: http://davidwalsh.name/convert-xml-json
function xmlToJson(xml) {
// Create the return object
var obj = {};
if (xml.nodeType == 1) { // element
// do attributes
if (xml.attributes.length > 0) {
@jCrip
jCrip / array_dupplicate_counter.js
Created August 18, 2017 19:17 — forked from ralphcrisostomo/array_dupplicate_counter.js
Javascript: Count duplicates in an array
/**
Problem:
You have a javascript array that likely has some duplicate values and you would like a count of those values.
Solution:
Try this schnippet out.
*/
@jCrip
jCrip / commit-msg
Created April 12, 2017 16:33 — forked from wesbos/commit-msg
ESLint 3.0 Git Pre Commit Hook
#!/bin/bash
files=$(git diff --cached --name-only | grep '\.jsx\?$')
# Prevent ESLint help message if no files matched
if [[ $files = "" ]] ; then
exit 0
fi
failed=0
for file in ${files}; do
@jCrip
jCrip / HTML5 Form Validation Fallback.markdown
Last active February 6, 2017 19:44 — forked from ashblue/A-Pen-by-Ash-Blue.markdown
HTML5 Form Validation Fallback (without a library)
@jCrip
jCrip / app.styl
Created October 27, 2016 18:23 — forked from douglascorrea/app.styl
Angular Directive for Particles JS - https://github.com/VincentGarreau/particles.js
.particleJs
background-color transparent
width 35%
height 100%
display block
position absolute
top 0px
left 0px
@jCrip
jCrip / filterable.rb
Created May 12, 2016 18:52 — forked from justinweiss/filterable.rb
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with the same name as the keys in <tt>filtering_params</tt>
# with their associated values. Most useful for calling named scopes from
@jCrip
jCrip / Advanced Classes
Created September 28, 2015 20:27 — forked from JoseJRVazquez/Advanced Classes
My Lesson in Advanced Classes in Ruby
Ok, so Inheritance
its not just for young white dudes waiting for their grandparents to fucking keel over at 82.
In ruby, Inheritance allows one class to inherit from another class attributes and behaviors (methods) that it didnt have before. The inheriter, much like a young white male, is the child class. The class that it inherits from, rather than being his old money grandparents, is the Parent Class. The lesson says Inheritance is designated with a < symbol, for example:
class Daughter < Father
end
wow, quick right. So for that, the daughter is getting methods from the father. Simple right. But lets go deeper and se how fucked up this can really get for those of us in the cheap seats.