Skip to content

Instantly share code, notes, and snippets.

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
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).
View PG::ConnectionBad - could not connect to server: Connection refused
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 Mar 17, 2020 — 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
View 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)
View Rails Technical Challenge API.md

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.
View Vim Usage Cheatsheet.txt
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.
View get_responses.rb
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 Aug 25, 2018
Combine data from several csv files
View combine_csvs.py
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)
View integrityng.py
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 Jul 22, 2018
Rails Code Snippet on Creating Objects from CSV data
View CSV_DB.rb
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']
View Nigeria_States.js
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");
@Innarticles
Innarticles / flaskapp.py
Last active Feb 13, 2017
Flask code for Fashion Recognizer
View flaskapp.py
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os.path
import re
import sys
import tarfile
import numpy as np
You can’t perform that action at this time.