Skip to content

Instantly share code, notes, and snippets.

Avatar
😎
...

Leo M. Peters leompeters

😎
...
View GitHub Profile
@leompeters
leompeters / test.yml
Created Jul 29, 2020 — forked from vvo/test.yml
Rails and PostgreSQL setup for GitHub actions (CI)
View test.yml
name: Test
on: [push]
jobs:
build:
runs-on: ubuntu-latest
# Similar to docker-compose.yml but not the same, 🤷‍♂️
services:
View Dockerfile
FROM ruby:2.6-alpine
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
RUN bundle init
RUN sed -i -e 's/# gem "rails"/gem "rails"/' Gemfile
# For installing Nokogiri (ref: https://copo.jp/blog/2016/03/alpine-%E3%81%AE-ruby-%E3%81%AE%E3%82%A4%E3%83%A1%E3%83%BC%E3%82%B8%E3%81%AB-nokogiri-%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB/ )
RUN apk add --no-cache build-base libxml2-dev libxslt-dev
@leompeters
leompeters / my_custom_error.rb
Last active May 7, 2020
Ruby custom error classes: inheritance of the message attribute.
View my_custom_error.rb
# Ruby custom error classes: inheritance of the message attribute.
#
# Create a custom exception class in Ruby.
#
# ===== Example:
#
# begin
# raise MyCustomError.new(my_object), "a message"
# rescue MyCustomError => e
# puts e.message # => "a message"
@leompeters
leompeters / abstract_interface.rb
Last active Dec 13, 2018
Building Interfaces and Abstract Classes in Ruby.
View abstract_interface.rb
# Object Interface in Ruby.
# Suggestion of implementation for object-oriented interfaces.
#
# ===== Example
#
# bike = AcmeBicycle.new
# bike.change_gear(1)
# # => AbstractInterface::InterfaceNotImplementedError: AcmeBicycle needs to implement 'change_gear' for interface Bicycle!
#
# See:: http://www.metabates.com/2011/02/07/building-interfaces-and-abstract-classes-in-ruby
@leompeters
leompeters / Gemfile
Created Jul 10, 2017 — forked from chrisjacob/Gemfile
Simple guide to integrating Pages v1.0.0 with Rails v4.1.1
View Gemfile
gem 'rails', '4.1.1'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
gem 'jquery-turbolinks'
# Gems for twitter LESS -> CSS and JS support
gem 'execjs'
View Preferences.sublime-setttings.json
{
"always_show_minimap_viewport": true,
"color_scheme": "Packages/User/SublimeLinter/primer.light (SL).tmTheme",
"draw_minimap_border": true,
"ensure_newline_at_eof_on_save": true,
"fade_fold_buttons": false,
"font_size": 12,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
@leompeters
leompeters / appium_settings_android_java.sh
Last active May 7, 2020
When install Appium, probably you will need to make it running fine with this configurations.
View appium_settings_android_java.sh
# When install Appium, probably you will need to make it running fine with this configurations.
# http://stackoverflow.com/a/40168992/2334082
$ <atom|subl|mine> /Applications/Appium.app//Contents/Resources/node_modules/appium/node_modules/appium-support/build/lib/system.js
$ <atom|subl|mine> /Applications/Appium.app//Contents/Resources/node_modules/appium/node_modules/appium-support/lib/system.js
$ <atom|subl|mine> /Applications/Appium.app//Contents/Resources/node_modules/appium-support/build/lib/system.js
$ <atom|subl|mine> /Applications/Appium.app//Contents/Resources/node_modules/appium-support/lib/system.js
# http://stackoverflow.com/a/19986294/2334082
$ export ANDROID_HOME=/Users/leomperes/Library/Android/sdk
@leompeters
leompeters / rubymine-gitflow-init-config-error
Last active Sep 7, 2016
Configuration PREFIX plugin error on initialize the git-flow in a repository on Rubymine (in `/.git/config`).
View rubymine-gitflow-init-config-error
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/fanhero/super-admin-portal.git
fetch = +refs/heads/*:refs/remotes/origin/*
View send-email-gdform.php
// Example got on LinkedIn (https://www.linkedin.com/groups/3242849/3242849-6143986010788216834):
// https://github.com/glondon/signup/blob/master/gdform.php
<?php
if (empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) !== 'xmlhttprequest')
exit(header('Location: http://signupandmakemoney.com/info/ajax-error.html'));
session_start();
/* Don't need this anymore...
$request_method = $_SERVER["REQUEST_METHOD"];
if($request_method == "GET"){
$query_vars = $_GET;
@leompeters
leompeters / ExampleFeature-Cucumber.feature
Last active May 7, 2020
Cucumber example feature in Gherkin.
View ExampleFeature-Cucumber.feature
# Cucumber example feature in Gherkin.
Feature: Example feature
As an user of Cucumber.js
I want to have documentation on Cucumber
So that I can concentrate on building awesome applications
Scenario: Reading documentation
Given I am on the Cucumber.js GitHub repository
When I go to the README file