Skip to content

Instantly share code, notes, and snippets.

View achmiral's full-sized avatar
🏠
WFH

Miral Achmed achmiral

🏠
WFH
View GitHub Profile
@SunDi3yansyah
SunDi3yansyah / Gemfile
Created February 6, 2018 09:46 — forked from Joseph-N/Gemfile
File upload using dropzone.js, paperclip in rails. Tutorial link http://josephndungu.com/tutorials/ajax-file-upload-with-dropezonejs-and-paperclip-rails
source 'https://rubygems.org'
# default gems here
#---------------------------
# add paperclip and bootstrap
gem "paperclip", "~> 4.1"
gem 'bootstrap-sass', '~> 3.1.1'
@SunDi3yansyah
SunDi3yansyah / application.html.erb
Created September 8, 2017 12:20
Each :notice :error :alert helper
<% [:notice, :error, :alert].each do |level| %>
<% unless flash[level].blank? %>
<div data-alert="alert" class="alert alert-<%= flash_class(level) %> fade in">
<a class="close" data-dismiss="alert" href="#">&times;</a>
<%= content_tag :p, flash[level] %>
</div>
<% end %>
<% end %>
@SunDi3yansyah
SunDi3yansyah / shell.md
Last active November 9, 2018 16:59
MySQL / MariaDB login without SUDO
$ > sudo mysql -uroot
mysql > SELECT User, Host FROM mysql.user;
mysql > DROP USER 'root'@'localhost';
@tinogomes
tinogomes / DNS_TO_LOCALHOST.markdown
Last active December 6, 2025 03:43
Public DNS Pointing to localhost (127.0.0.1)

Available Public Wildcard DNS Domains pointing to localhost (127.0.0.1)

The best way to safely and securely use local domains pointing to 127.0.0.1 is to edit your local settings (/etc/hosts) and add your own settings. Keep in mind if you want to use subdomains, you need to enter all variations.

Example:

# Adding bottom of your current file /etc/hosts
################# MY LOCAL DOMAINS
127.0.0.1 local.com admin.local.com
127.0.0.1 domain1.com
@glebm
glebm / README.md
Last active March 29, 2023 19:56
Rails Link Preload Headers

This lets you set the preload headers for your assets, so that the browser can start fetching them before it begins parsing HTML.

@sidwood
sidwood / Dockerfile
Last active September 26, 2017 04:39
Node.js dockerfile templates
FROM node:7.10-alpine
RUN mkdir -p /opt/app
WORKDIR /opt/app
COPY ./package.json /opt/app
RUN apk add --update --no-cache tini &&\
apk add --virtual .build-dependencies make gcc g++ python &&\
npm install --production &&\
@SunDi3yansyah
SunDi3yansyah / gist:5e5e52e0caf753358f0b04075fd32d21
Created March 19, 2017 15:54 — forked from alex-zige/gist:5795358
Rails Rspec API Testing Notes

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views
@verticalgrain
verticalgrain / app.js
Last active April 26, 2022 15:37
React Router V4 Redirect after form submission
import React, { Component } from 'react'
import { Redirect } from 'react-router'
export default class ContactForm extends Component {
constructor () {
super();
this.state = {
fireRedirect: false
}
}
@SunDi3yansyah
SunDi3yansyah / application_controller.rb
Created January 16, 2017 16:18 — forked from fred/application_controller.rb
Adding Opensearch to my Rails 3.2 app
#app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
def opensearch
response.headers['Content-Type'] = 'application/opensearchdescription+xml; charset=utf-8'
end
@achmiral
achmiral / seeds.rb
Created March 21, 2016 15:36 — forked from seyhunak/seeds.rb
Rails - Import SQL file as seed
unless Rails.env.production?
connection = ActiveRecord::Base.connection
connection.tables.each do |table|
connection.execute("TRUNCATE #{table}") unless table == "schema_migrations"
end
sql = File.read('db/import.sql')
statements = sql.split(/;$/)
statements.pop