Skip to content

Instantly share code, notes, and snippets.

View brunowego's full-sized avatar
🎯
Focusing

Bruno Wego brunowego

🎯
Focusing
View GitHub Profile
@nrollr
nrollr / MySQL_macOS_Sierra.md
Last active January 31, 2024 14:45
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :

Overview

Our app relies entirely on the current_user helper method (found in our ApplicationController) to retrieve the User object associated with the currently logged-in user (if any). You guys are using the devise gem for authentication, but you still have a current_user helper method which is made available to ApplicationController (and all subclasses).

Normally, the current_user method looks something like this:

def current_user
  # do some magic to get the user id from the (encrypted) session cookie…
 user_id = get_user_id_from_session
@brendomaciel
brendomaciel / percent_mask.js
Last active June 8, 2022 18:13
Máscara de porcentagem utilizando o plugin jQuery Mask Plugin (limita o valor máximo a 100)
$('#percent').mask('P', {
translation: {
'P': {
pattern: /[\d\.,]/,
recursive: true
}
},
onKeyPress: function(val, e, field, options) {
var old_value = $(field).data('oldValue') || '';
@rubenrangel
rubenrangel / ImageInput.js
Created July 8, 2016 01:54
Image upload React component.
import React, { Component, PropTypes } from 'react';
export default class ImageInput extends Component {
constructor(props) {
super(props);
this.state = {
src: props.src ? props.src : null,
}
this.handleOnChange = this.handleOnChange.bind(this);

Oh my zsh.

Install with curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Enabling Plugins (zsh-autosuggestions & zsh-syntax-highlighting)

  • Download zsh-autosuggestions by
class Organisation < ApplicationRecord
NUMBER_OF_PERMITTED_USERS = 10
has_many :users, before_add: :validate_user_limit
private
def validate_user_limit(user)
raise Exception.new if users.size >= NUMBER_OF_PERMITTED_USERS
end
end
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active April 15, 2024 02:19
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@dagjaneiro
dagjaneiro / lvh_ssl.md
Last active August 5, 2021 18:00
lvh.me ssl

Install nginx

$ brew install nginx

Edit nginx.conf

$ vim /usr/local/etc/nginx/nginx.conf
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@pablobm
pablobm / README.md
Last active June 3, 2022 10:07
A clear convention for a CRUD with standard Ember + Ember Data

CRUD with Ember (+ Data)

Compatible with Ember 1.13.0+ Compatible with Ember Data 1.13.0+

Ember's official documentation describes a number of low-level APIs, but doesn't talk much about how to put them together. As a result, a simple task such as creating a simple CRUD application is not obvious to a newcomer.