Wednesday, May 31, 2017

Install cacert.pem to use SSL calls

Windows

  1. Download https://curl.haxx.se/ca/cacert.pem into c:\railsinstaller\cacert.pem. Make sure you save it as a .pem file, rather than a text file.
  2. Go to your Computer -> Advanced Settings -> Environment Variables
  3. Create a new System Variable:
  4. Variable: SSL_CERT_FILE Value: C:\RailsInstaller\cacert.pem
  5. Close all your command prompts, including your Rails server command prompt, etc.
  6. Start a new ruby irb prompt, and try the following:
  • $irb>require 'open-uri'
  • $irb>open('https://www.gmail.com')

Linux




Wednesday, May 24, 2017

Tuesday, April 25, 2017

Changing gem source to without https

$ gem sources --add http://rubygems.org
$ gem sources --remove https://rubygems.org
$ gem sources --list

*** CURRENT SOURCES ***
http://rubygems.org

Installing curb on windows

Installing curb (0.7.18) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

1) Download libcurl (under the “Win32 - Generic” section) and extract the contents to C:\ At the time of writing 7.27.0 was the latest. If you download a different version, don’t forget to the update the paths below.
2) Add C:\curl-7.27.0-devel-mingw32\bin to your Windows path
3) Run:

Note :If you can't build using win32 version on your 64bit windows, try 64 bit instead.. Working at 6/8/2020 using 64 bit  curl-7.70.0-win64-mingw

gem install curb --version 0.7.18 -- --with-curl-dir="C:/curl-7.70.0-win64-mingw"

Note : You've to choose SSH Version
Win32 7zip7.54.0binarySSLSSHViktor Szakáts
gem install curb --version 0.7.18 --platform=ruby -- -- --with-curl-lib="C:/curl-7.27.0-devel-mingw32/bin" --with-curl-include="C:/curl-7.27.0-devel-mingw32/include"
If you're getting curb windows %1 is not a valid Win32 application, copy libcurl.dll to C:\Bitnami\rubystack-2.0.0-18\ruby\bin 
then restart the computer

Saturday, March 12, 2016

Make not found

In ubuntu, you need to install make to make sure that it compile some sources..
apt-get install make
$ sudo apt-get install g++
sudo apt-get install build-essential

Wednesday, December 17, 2014

Sending emails from Linux with ssmtp

Install SSMTP

apt-get install ssmtp

Configure the file

nano /etc/ssmtp/ssmtp.conf

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=thetnswe@gmail.com

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.gmail.com:587

# Where will the mail seem to come from?
#rewriteDomain=thetnswe@gmail.com

# The full hostname
hostname=thetnswe@gmail.com

UseSTARTTLS=YES
AuthUser=thetnswe@gmail.com
AuthPass=password

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES

Add the user to allow to send emails

nano /etc/ssmtp/revaliases

# sSMTP aliases
#
# Format:       local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.

root:thetnswe@gmail.com:smtp.gmail.com:587
localusername:thetnswe@gmail.com:smtp.gmail.com:587

Sending email

sudo ssmtp thetnswe@gmail.com

You will then type your message, hit enter and ‘ctrl+d‘

Now that you have a simple outgoing email server setup, you can do all sorts of neat things:

Creating email Form

nano /emails/email_test1.txt
sudo ssmtp thetnswe@gmail.com < /emails/email_test1.txt

Email send form might looks like this

Subject: Terminal Email Send

Email Content line 1
Email Content line 2



Setting up CRON jobs on shell scripts in Linux (Ubutu)

Open the CRON job editor

crontab -e

After that you can format the job as below

*     *     *     *     *  YOURCOMMAND
-     -     -     -     -
|     |     |     |     |
|     |     |     |     +----- Day in Week (0 to 7) (Sunday is 0 and 7)
|     |     |     +------- Month (1 to 12)
|     |     +--------- Day in Month (1 to 31)
|     +----------- Hour (0 to 23)
+------------- Minute (0 to 59)
There are some shorts, too (if you don´t want the *):
@reboot --> only once at startup
@daily ---> once a day
@midnight --> once a day at midnight
@hourly --> once a hour
@weekly --> once a week
@monthly --> once a month
@annually --> once a year
@yearly --> once a year
If you want to use the shorts as cron (because they don´t work or so):
@daily --> 0 0 * * *
@midnight --> 0 0 * * *
@hourly --> 0 * * * *
@weekly --> 0 0 * * 0
@monthly --> 0 0 1 * *
@annually --> 0 0 1 1 *
@yearly --> 0 0 1 1 *

# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/

//Every 4 hours
This will run the job every 4 hours, on the hours of 00:00, 04:00, 08:00 12:00, 16:00, 20:00.

0 0,4,8,12,16,20 * * * /scripts/test.sh

More info @http://serverfault.com/questions/39004/what-is-the-correct-syntax-to-run-cron-every-4-hours

Start/Stop cron service


sudo service cron restart