Skip to content

Instantly share code, notes, and snippets.

View Wendersonandes's full-sized avatar

Wenderson Fernandes Wendersonandes

  • Emerge
  • Belo Horizonte, Brazil
View GitHub Profile
@Wendersonandes
Wendersonandes / Readme.md
Created March 8, 2016 04:39 — forked from mrgcohen/Readme.md
Twitter Bootstrap Typeahead autocomplete example

Requirements

  • bootstrap with typeahead
  • jquery

Explanation

This will use bootstrap with typeahead to create an autocomplete search.

@Wendersonandes
Wendersonandes / gist:a5bf93d1fe9e02138160a7f4defc7c30
Created April 11, 2016 16:03
Using MailChimp API to send email campaigns to a dynamic set of email addresses
# Sample code for sending MailChimp Email Campaigns from a Rails App using Gibbon API wrapper v0.3.5
# All recipients must already be on the associated MailChimp list (list_id), for this app we add those via another
# API call every few minutes.
#
# Member function of EmailCampaign.rb model
# See http://labs.saidigital.co/using-mailchimp-api-to-send-email-campaigns-to-a-dynamic-set-of-email-addresses-425/
# for explanation.
def send_campaign(api_key, gb, list_id, template_id, from_name, from_email)
self.reset_unique_id
segment_id = gb.list_static_segment_add(:id => list_id, :name => self.safe_name)
@Wendersonandes
Wendersonandes / doc.md
Created August 3, 2016 02:39 — forked from oelmekki/doc.md
Rails + Browserify + React + es7

1. Gemfile

gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'

Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component (and thus, prerendering).

Note that jquery-rails can be removed from Gemfile, the npm version of jquery and jquery-ujs will be used instead.

@Wendersonandes
Wendersonandes / README.md
Created August 30, 2017 13:22 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@Wendersonandes
Wendersonandes / camphor.scss
Created December 6, 2017 20:00 — forked from bdno86/camphor.scss
camphor
$camphor300:'d09GMgABAAAAAQ5UABIAAAAEn0QAAQ3tAAEZmQAAAAAAAAAAAAAAAAAAAAAAAAAAG4SkahzOKgZgFotgAIosCCIJgnMRCAqLlgCKvTwBNgIkA5lwE4GnDguZdAAEIAW7bwcgDHJb0WS0WUXZkokWaBHx4wKbY7TigANIU/t980QCGzI/IkCsdbqJZwY1ZOgWDngIamw3I43435Dd+zJ1kNmKVp/DvXNAwaNm//////////////////+/NZkMZ5cAl0CpbZ3oiwloFA5GyIWNzOYVLt1bpXPX+pABI2fo5rMZpgVYIzYqgxt92ajECqUKh2G9gaOCVRC23VSRVypHfbvb7wYcwEM25WArF0esm1yKzDixrJRdcBGtcpBZTFbFbIl8LIU4gWOnEdSITqkoGrHWJ8ywn9eVFWWk3lC6m07qp1TXntHaWp6ekYHLrFoyzOXYiQnn2kWX2zqMaFBTca25vHKndPhJV66HRhQzL9lB3OT20KGTXuFHu62wm1qzoV/iTnaiLdc8o/D7B+1O94BrjSE3cia6U1A5XNp0kHmUj8IMBaeiGaiNJV7b1csb0bq8EWYo2h1TuipR+7hmYjxeZsonGLNcmgsKp5EUDCEj9SvRyxX2uMUNfINmfNqglBYNNtjtNmdwWV2ly4uQKheyDyka2RTRoQ3IEfs+0BNcGJ4Z5AnmHNpFbCKW5PsXkAzJ6VVzzVMo0fwIUpQQT67itTNRE946/NxDashl9KuAFUbZ6yW91vObh+WAMZ1mQ1J4wotF6KXHuo65X6wSz406hW/T6XZMf/6W+HGYUxCDfhyjPaoMGcWccmbYM/H35NdHTOd79Jg0ho/BDBvRy2vcg8pHsv07UYiKrDFeqzL0Qk7qCkXLuukl2EKuR3xS6VtsLEaT0BfWoDYoQ1YvEjjT729XNMYoCX3j+2ApedBG/UHLOJ7AAnfPSqdmmePsY+522MpfPaf7kf6fIJMn0/4SE6PmuI3yjyeGjWn+1qj/ukf09DE
@Wendersonandes
Wendersonandes / gist:8a28819915b4200eac37616240db2437
Created January 10, 2018 00:06 — forked from barelyknown/gist:3692433
Send Email From Rails Console
# Simple approach to sending email from the Rails console
# Implementation idea courtesy of Steve Klabnik
# http://blog.steveklabnik.com/posts/2012-09-09-random-ruby-tricks--class-new
# Create the mailer class with a block and assign to a variable
mailer = Class.new(ActionMailer::Base) do
def example_message
mail(to: "test@test.com", from: "test@test.com", subject: "Example Message") do |format|
format.text { render text: "Example message body" }
end
@Wendersonandes
Wendersonandes / reset_primary_key.md
Last active July 3, 2018 20:29 — forked from paulsturgess/reset_primary_key.md
Reset postgres primary key index using Rails
    ActiveRecord::Base.connection.tables.each do |t|
      ActiveRecord::Base.connection.reset_pk_sequence!(t)

end

@Wendersonandes
Wendersonandes / Spree: Filter by brand.md
Created July 4, 2018 14:50 — forked from maxivak/Spree: Filter by brand.md
Spree: Filter Products by properties

Fix 'scoped' error for Rails 4

error: undefined method 'scoped' solution:

# config/initializers/scoped.rb
class ActiveRecord::Base
  # do things the modern way and silence Rails 4 deprecation warnings
 def self.scoped(options=nil)

options ? where(nil).apply_finder_options(options, true) : where(nil)

def ProductFilters.option_with_values(option_scope, option, values)
# get values IDs for Option with name {@option} and value-names in {@values} for use in SQL below
option_values = Spree::OptionValue.where(:presentation => [values].flatten).joins(:option_type).where(OptionType.table_name => {:name => option}).pluck("#{OptionValue.table_name}.id")
return option_scope if option_values.empty?
option_scope = option_scope.where("#{Product.table_name}.id in (select product_id from #{Variant.table_name} v left join spree_option_values_variants ov on ov.variant_id = v.id where ov.option_value_id in (?))", option_values)
option_scope
end
# option scope
@Wendersonandes
Wendersonandes / koken-nginx.conf
Created August 13, 2019 06:36 — forked from spiffin/koken-nginx.conf
Nginx configuration for Koken 0.22.21 (2017)
server {
# General
# Listen on both ipv4 and ipv6
listen 80;
listen [::]:80;
server_name MYDOMAIN.COM;