Skip to content

Instantly share code, notes, and snippets.

View achmiral's full-sized avatar
🏠
WFH

Miral Achmed achmiral

🏠
WFH
View GitHub Profile
@mrmartineau
mrmartineau / stimulus.md
Last active October 5, 2025 14:09
Stimulus cheatsheet
@jenweber
jenweber / be-loud-be-ready.md
Last active November 29, 2018 17:00
Be loud and be ready - my hopes for Ember.js in 2018

Be loud and be ready - my hopes for Ember.js in 2018

In 2018, I want to see Ember grow. But how could that be done in a strategic way? In this article, I'll take stock of our current resources and suggest how we could focus our efforts.

Sometimes when I am not sure how to achieve a goal, I imagine my future, successful self. I imagine that the goal has been achieved, using the same resources I have today, and I work backwards. What would I guess that those successful people of Future-Ember did?

  1. The people of Future-Ember worked to increase public awareness so that more developers knew about it and considered it for their projects. The Core Team led by example, writing and speaking, and the rest of the community was empowered to do the same.
  2. Future-Ember provided approachable, current, convincing materials for new visitors.

They were LOUD, and they were ready for the moment that they were heard.

@SunDi3yansyah
SunDi3yansyah / manu-active-with.js
Last active November 10, 2018 06:02
Menu Active with JS
var url = window.location;
var element = $(".ui.vertical.menu a.item").filter(function() {
return this.href == url || url.href.indexOf(this.href) == 0;
}).addClass("active").parent().parent().parent();
if (element.is("li")) {
element.addClass("active");
}
@SunDi3yansyah
SunDi3yansyah / find_duplicate.rb
Last active October 1, 2021 14:06
Rails find duplicate records
columns_that_make_record_distinct = [:some_attribute]
distinct_ids = Model.select("MIN(id) as id").group(columns_that_make_record_distinct).map(&:id)
duplicate_records = Model.where.not(id: distinct_ids)
@SunDi3yansyah
SunDi3yansyah / subdomain-localhost-rails-5.md
Created July 6, 2018 22:39 — 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

Setup

Replace IRB with Pry (in your Gemfile) and Byebug with pry-byebug.

gem 'pry-rails', group: [:development, :test]
gem 'pry-byebug', group: [:development, :test]

Using PRY

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

@SunDi3yansyah
SunDi3yansyah / README.md
Created July 19, 2018 09:24 — forked from timcheadle/README.md
Make /robots.txt aware of the Rails environment

Make /robots.txt aware of the Rails environment

You probably don't want Google crawling your development staging app. Here's how to fix that.

$ mv public/robots.txt config/robots.production.txt
$ cp config/robots.production.txt config/robots.development.txt

Now edit config/routes.rb to add a route for /robots.txt, and add the controller code.

@SunDi3yansyah
SunDi3yansyah / .gitlab-ci.yml
Created July 20, 2018 08:29 — forked from bryanbraun/.gitlab-ci.yml
Example Gitlab CI Config for a Rails + Nginx application using Docker Compose
# See how variables work, and a list of predefined ones:
# - https://docs.gitlab.com/ce/ci/variables/
variables:
RAILS_IMAGE: registry.gitlab.com/bryanbraun/gridmaster.io/railsapp:$CI_COMMIT_SHA
NGINX_IMAGE: registry.gitlab.com/bryanbraun/gridmaster.io/nginx:$CI_COMMIT_SHA
DEPLOY_TAG: $CI_COMMIT_SHA
cache:
paths:
- vendor/ruby
@SunDi3yansyah
SunDi3yansyah / rails-singular-or-plural.md
Last active July 24, 2018 03:53
Rails Conventions - Singular or Plural?
Name Singular/Plural Use
Controller Plural rails g controller Users index show
Helper Plural rails g helper Users
Mailer Singular rails g mailer UserMailer
Migration Plural rails g migration AddEmailToUsers email:string
Model Singular rails g model User name:string
Observer Singular rails g observer User
Resource Plural* resources :users, :only => [:index, :show]
Scaffold Singular rails g scaffold User name:string