Skip to content

Instantly share code, notes, and snippets.

View armandocanals's full-sized avatar
👾
0_0

Armando Canals armandocanals

👾
0_0
View GitHub Profile
@aparrish
aparrish / spacy_intro.ipynb
Last active August 9, 2023 01:41
NLP Concepts with spaCy. Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@itskingori
itskingori / application_controller.rb
Last active March 4, 2024 09:07 — forked from speed-of-light/application_controller.rb
How to handle exceptions like 401, 501, 404 in Rails
# As used with CanCan and Devise
class ApplicationController < ActionController::Base
protect_from_forgery
include ErrorResponseActions
rescue_from CanCan::AccessDenied, :with => :authorization_error
rescue_from ActiveRecord::RecordNotFound, :with => :resource_not_found
before_filter :authenticate!
@allenwb
allenwb / 0Option2ConstructorSummary.md
Last active November 4, 2023 14:39
New ES6 constructor features and semantics: Alternative 2 manual super in derived classes

New ES6 Constructor Semantics and Usage Examples

Manual super: Alternative Design where subclass constructors do not automatically call superclass constructors

This Gist presents a new design of class-based object construction in ES6 that does not require use of the two-phase @@create protocol.

One of the characteristics of this proposal is that subclass constructors must explicitly super invoke their superclass's constructor if they wish to use the base class' object allocation and initialization logic.

An alternative version of this design automatically invokes the base constructor in most situations.

@geranyl
geranyl / pictureblock.md
Last active June 7, 2020 11:15
Picturefill Custom Liquid Tag for Jekyll

What this is:

A custom liquid template block tag that allows you to use the responsive image system Picturefill in Jekyll markdown files.

At the moment this template only has the option of mobile and desktop sizes. I have it hardcoded so that mobile images show up when the screen size has a max-width of 480px. You can adjust this within the function def render(context) in the tag template and add in other options you may desire.

What you need:

  • Jekyll v2 http://jekyllrb.com/
  • Picturefill http://scottjehl.github.io/picturefill/
  • You MUST specify markdown: kramdown in your _config.yml even though it's supposed to be the default markdown processor. This fixed the problem of Jekyll trying to interpret the resulting html as markdown and really messing up the conditional IE9 tags. Edit: I had defined the markdown tag previously with the wrong processor and never noticed.
@anotheruiguy
anotheruiguy / bower-all-things.md
Last active March 18, 2017 08:41
Bower all the things

Having spent the vast majority of my career in the front-end space, there has always been a thirst for better processes and management of resources. For those who have long histories with HTML and CSS, you remember the days of keeping folders of code snippets, our personal library of sorts, the cool code we wrote and wanted to have at the ready for our next project.

Sure there were desktop apps that tried to manage this for us, journler was my tool of choice back in those days. I have also seen some use Google Docs and other document and snippet managers, but they never really worked. And let us never forget all those really crappy websites that were supposed to be our saving grace. In the end, managing assets on the front-end has been nothing but a total fail.

Life meets Ruby, boy meets Git

When I began working with a Rails team, I was introduced to better solutions for managing libraries of reusable front-end code. Not to mention, this was my first exposure to Git and Github

@turadg
turadg / application.rb
Last active May 14, 2019 06:04
Handle only 404s dynamically. It uses a normal controller and route for 404s, letting everything else go to the Rails default /public error pages. In my case it was to use the subdomain logic in my ApplicationController.
module MyApp
class Application < Rails::Application
require Rails.root + 'lib/custom_public_exceptions'
config.exceptions_app = CustomPublicExceptions.new Rails.public_path
end
end
@turadg
turadg / subdomains.rb
Last active January 21, 2024 19:45 — forked from rtekie/subdomains.rb
Drop-in utility to test your app subdomains with Capybara, Rspec, and a Javascript driver (Poltergeist, Webkit, or Selenium)
# Support for Rspec / Capybara subdomain integration testing
# Make sure this file is required by spec_helper.rb
# (e.g. save as spec/support/subdomains.rb)
def switch_to_subdomain(subdomain)
# lvh.me always resolves to 127.0.0.1
hostname = subdomain ? "#{subdomain}.lvh.me" : "lvh.me"
Capybara.app_host = "http://#{hostname}"
end
@capotej
capotej / fabfile.py
Created February 27, 2013 19:08
chef-solo deployer/bootstrapper
from fabric.api import *
from fabric.contrib.files import exists
from fabric.contrib.project import upload_project
## Usage
# Full run, bootstraps if needed
# fab chef:name_of_runlist,hosts=1.1.1.1 --password=1234 --user=foo
# fab chef:name_of_runlist,hosts=1.1.1.1 -i=path/to/pem --user=foo
..='cd ..'
add='git add '
admin='ssh-add && ssh admin'
b='cd ..'
be='bundle exec '
branch='git branch '
cata='cat ~/.dotfiles/bash/aliases'
cdev='cd ~/dev'
checkout='git checkout '
co='git checkout '
@ggilder
ggilder / fizz.rb
Created June 8, 2012 05:14
Fizzbuzz bitwise math
messages = [nil, "Fizz", "Buzz", "FizzBuzz"]
acc = 810092048
(1..100).each do |i|
c = acc & 3
puts messages[c] || i
acc = acc >> 2 | c << 28
end
# Explanation
#