I hereby claim:
- I am trejo08 on github.
- I am trejo08 (https://keybase.io/trejo08) on keybase.
- I have a public key whose fingerprint is 6F87 5D78 88A8 B2FB F5AC B029 DC4D D929 757D 2C02
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
## Script to send emails through Python to remote email | |
import os | |
import smtplib | |
from email.mime.text import MIMEText | |
from email.mime.imagen import MIMEImage | |
from email.mime.multipart import MIMEMultipart | |
#def SendMail(ImageFileName): | |
def SendMail(): | |
to = "email address" |
#!/bin/bash | |
# Collect DBUS_SESSION_BUS_ADDRESS from running process | |
function set_dbus_adress | |
{ | |
USER=$1 | |
PROCESS=$2 | |
PID=`pgrep -o -u $USER $PROCESS` | |
ENVIRON=/proc/$PID/environ |
This is a Guide to Enable remote access to MySQL Server, allowing remote administration and sharing databases. | |
This guide has been tested in Ubuntu desktop/server 14.04 | |
Run the following commands in a terminal | |
1- sudo apt-get update | |
2- sudo apt-get upgrade | |
3- sudo apt-get install -y mysql-server mysql-common mysql-client libmysqlclient-dev | |
After mysql has been installed and configured successfully and setted 'root' password, change and comment the following file with an editor(nano, emacs, vi, vim) with 'sudo' logged as admin user or root: | |
file: sudo nano /etc/mysql/my.cnf |
When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).
When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.
Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.
So let's go through the one query that's worth memorizing to handle your eager loading.
To get a private GitHub repo to work on Heroku, you can leverage the netrc buildpack in conjunction with the Heroku Ruby buildpack.
When setting up the Gemfile
, make sure to use the https GitHub URL. This mechanism does not work with git+ssh.
gem "some_private_gem", git: "https://github.com/org/some_private_gem.git"
# 1) Create your private key (any password will do, we remove it below) | |
$ cd ~/.ssh | |
$ openssl genrsa -des3 -out server.orig.key 2048 | |
# 2) Remove the password | |
$ openssl rsa -in server.orig.key -out server.key |
# This simple solution open-classes the controller/model in the main app | |
# to add or overwrite methods. | |
# A drawback of this solution is that you won't be able to access the original | |
# method by using +super+. | |
# engine: app/controllers/myengine/my_controller.rb | |
# This is the controller in our engine with a index method defined. | |
module MyEngine | |
class MyController < ApplicationController | |
def index |
Sometimes I want to remove a specific key-value pair from a Ruby hash and get the resulting hash back. If you're using Rails or ActiveSupport you can accomplish this using Hash#except
:
hash = { a: 1, b: 2, c: 3 }
hash.except(:a) # => { b: 2, c: 3 }
# note, the original hash is not modified
hash # => { a: 1, b: 2, c: 3 }
# it also works with multiple key-value pairs