Skip to content

Instantly share code, notes, and snippets.

View Dach3r's full-sized avatar
:octocat:
Loading...

David Noreña Dach3r

:octocat:
Loading...
  • Medellín, Colombia
View GitHub Profile
@Dach3r
Dach3r / httparty.rb
Created August 30, 2019 20:25 — forked from jeffdonthemic/httparty.rb
HTTParty Examples
options = { :body =>
{ :username => 'my',
:password => 'password'
}
}
results = HTTParty.post("http://api.topcoder.com/v2/auth", options)
##
## example for post with papertrail and basic auth
##
@Dach3r
Dach3r / countries
Created February 27, 2019 20:54 — forked from kalinchernev/countries
Plain text list of countries
Afghanistan
Albania
Algeria
Andorra
Angola
Antigua & Deps
Argentina
Armenia
Australia
Austria
@Dach3r
Dach3r / gist:ac015a65d9331f7f4fe2664832cdc471
Created February 10, 2019 18:05 — forked from e1024kb/gist:41bf38fdb1a2cb19a781
Country - state list in JSON
{
"countries": [
{
"country": "Afghanistan",
"states": ["Badakhshan", "Badghis", "Baghlan", "Balkh", "Bamian", "Daykondi", "Farah", "Faryab", "Ghazni", "Ghowr", "Helmand", "Herat", "Jowzjan", "Kabul", "Kandahar", "Kapisa", "Khost", "Konar", "Kondoz", "Laghman", "Lowgar", "Nangarhar", "Nimruz", "Nurestan", "Oruzgan", "Paktia", "Paktika", "Panjshir", "Parvan", "Samangan", "Sar-e Pol", "Takhar", "Vardak", "Zabol"]
},
{
"country": "Albania",
"states": ["Berat", "Dibres", "Durres", "Elbasan", "Fier", "Gjirokastre", "Korce", "Kukes", "Lezhe", "Shkoder", "Tirane", "Vlore"]
},
@Dach3r
Dach3r / rails_github_heroku.md
Created July 28, 2018 04:30 — forked from JennDudley/rails_github_heroku.md
Steps to set up a new Rails app, initialize a git repo, push to Github and deploy to Heroku

This is a list of steps to:

  • Setup a new Rails app
  • Initialize a local repository using git
  • Create a new remote repository using GitHub
  • Change README.rdoc
  • Deploy to a cloud service - Heroku

Assumptions:

  • Ruby is installed (v 1.9.3)
  • Rails is installed (v 3.2.3)

Realtime Notifications with ActionCable

In this episode we're going to be adding realtime notifications into your app using ActionCable. We've talked about notifications a few times in the past and we used AJAX polling for that. 95% of the time, polling is the solution that would be recommended for it.

But if you're looking for a good introduction into ActionCable then this is a decent one because we're only really using it for one way from the server side to the client side.

Getting started

So to get started we're starting with an app that has Bootstrap installed and then we created a Main controller with an index view which is where we will list our Notifications as for this example.

Before we generate our channels let's install a few things

@Dach3r
Dach3r / subdomain-localhost-rails-5.md
Created March 30, 2018 07:20 — forked from indiesquidge/subdomain-localhost-rails-5.md
how to access subdomains locally with Rails 5

Subdomaining Localhost with Rails 5

I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api

Rails.application.routes.draw do
  constraints subdomain: "api" do
    scope module: "api" do
@Dach3r
Dach3r / DateTime.txt
Created March 27, 2018 04:56 — forked from matenia/DateTime.txt
strftime options rails:
Format Meaning
%a The abbreviated weekday name (“Sun’’)
%A The full weekday name (“Sunday’’)
%b The abbreviated month name (“Jan’’)
%B The full month name (“January’’)
%c The preferred local date and time representation
%d Day of the month (01..31)
%H Hour of the day, 24-hour clock (00..23)
%I Hour of the day, 12-hour clock (01..12)
%j Day of the year (001..366)
<div class="container">
<div class="row">
<div class="col-md-3">
<%= render 'sidebar' %>
</div>
<div class="col-md-9">
<table class="table table-bordered">
<thead>
<tr>
.navbar.navbar-default
.container-fluid
.navbar-header
button.navbar-toggle.collapsed
span.sr-only
span.icon-bar
span.icon-bar
span.icon-bar
a(href="/" class="navbar-brand") Beker
/* Dropdown */
.dropdown ul.dropdown-menu {
border-radius:4px;
box-shadow:none;
margin-top:20px;
}
.dropdown ul.dropdown-menu:before {
content: "";
border-bottom: 10px solid #fff;
border-right: 10px solid transparent;