Skip to content

Instantly share code, notes, and snippets.

View Innarticles's full-sized avatar
😇
I'm Innocent

Innocent Udeogu Innarticles

😇
I'm Innocent
View GitHub Profile
@Innarticles
Innarticles / PG::ConnectionBad - could not connect to server: Connection refused
Created May 19, 2020 09:20
To fix it remove/rename the PID file. Find the postgres data directory. On macOS using homebrew it is in /usr/local/var/postgres/, or /usr/local/var/log/ other systems it might be /usr/var/postgres/. To make sure this is the problem, look at the log file (server.log).
To fix it remove/rename the PID file. Find the postgres data directory. On macOS using homebrew it is in /usr/local/var/postgres/, or /usr/local/var/log/ other systems it might be /usr/var/postgres/.
To make sure this is the problem, look at the log file (server.log). On the last lines you will see:
```
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 347) running in data directory "/usr/local/var/postgres"?
```
If so, `rm postmaster.pid`
Restart your server. On a mac using launchctl (with homebrew) the following commands will restart the server.
@Innarticles
Innarticles / bucket_sync_service.rb
Created March 17, 2020 06:25 — forked from edwardsharp/bucket_sync_service.rb
ruby class to copy from one aws s3 bucket to another based on bantic/bucket_sync_service.rb
require 'aws-sdk'
class BucketSyncService
attr_reader :from_bucket, :to_bucket, :logger
attr_accessor :debug
DEFAULT_ACL = "public-read"
def initialize(from_bucket, to_bucket)

Challenge Specs:

Using Ruby on Rails we would like you to create a simple blog api-only application. The application should fulfill the requirements below. Any one can create a blog with or without a loggedin account.

  • You can only comment as a authenticated user (logged in).
  • You can not commment on more than 2 blogs in a given day 24 hours period.
  • Your api must be in line with JsonAPI standards.
  • The source code must be placed in a public repo on GitHub.
  • The application should be deployable on Heroku.
h moves the cursor one character to the left.
j moves the cursor down one line.
k moves the cursor up one line.
l moves the cursor one character to the right.
0 moves the cursor to the beginning of the line.
$ moves the cursor to the end of the line.
w move forward one word.
b move backwards one word.
G move to the end of the file.
gg move to the beginning of the file.
max = 0.0
if !QaCorp.where("question like ?", "%#{self.text}%").empty?
# Exact question exist in the database.
answer = QaCorp.where("question like ?", "%#{self.text}%").first.answer
max = 1.0
else
corpus = QaCorp.all.map {|qa| TfIdfSimilarity::Document.new(qa.question)}
d_question = TfIdfSimilarity::Document.new(self.text)
corpus << d_question
model = TfIdfSimilarity::TfIdfModel.new(corpus, :library => :nmatrix)
@Innarticles
Innarticles / combine_csvs.py
Created August 25, 2018 16:02
Combine data from several csv files
import glob
import pandas as pd
path ='/' # use your path
allFiles = glob.glob("*.csv")
frame = pd.DataFrame()
list_ = []
for file_ in allFiles:
df = pd.read_csv(file_,index_col=None, header=None)
list_.append(df)
url = "http://integrity.ng/index.php/units/browse"
from bs4 import BeautifulSoup
import requests
import csv
# Main Coding Sectio
start = 1
with open("Units.csv", 'wb') as save:
while True:
try:
@Innarticles
Innarticles / CSV_DB.rb
Created July 22, 2018 14:43
Rails Code Snippet on Creating Objects from CSV data
csv_text = File.read(Rails.root.join('lib', 'seeds', 'products.csv'))
csv = CSV.parse(csv_text, :headers => true, :encoding => 'ISO-8859-1')
csv.each do |row|
t = Product.new
t.id = row['id']
t.title = row['title']
t.brand = row['brand']
t.description = row['description']
t.main_image = row['picture']
t.condition = row['condition']
@Innarticles
Innarticles / gist:db5f33480d74f5fecc30cedcf613d5f0
Last active February 20, 2018 17:49
Code with Yaw: Oncenout
var state_arr = new Array("Lagos", "Rivers", "FCT", "Abia", "Adamawa", "Akwa Ibom", "Anambra", "Bauchi", "Bayelsa",
"Benue", "Borno", "Cross River", "Delta","Ebonyi", "Edo", "Ekiti", "Enugu", "Gombe", "Imo", "Jigawa", "Kaduna", "Kano","Katsina", "Kebbi", "Kogi", "Kwara", "Nasarawa", "Niger", "Ogun", "Ondo", "Osun", "Oyo", "Plateau", "Sokoto", "Taraba", "Yobe", "Zamfara");