Skip to content

Instantly share code, notes, and snippets.

View hakimkal's full-sized avatar

Abdulhakim Haliru hakimkal

View GitHub Profile
@hakimkal
hakimkal / MySQL_macOS_Sierra.md
Created November 8, 2018 05:47 — forked from nrollr/MySQL_macOS_Sierra.md
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 :

@hakimkal
hakimkal / ConnectorConfig.java
Created November 13, 2018 18:09 — forked from ThomasVitale/ConnectorConfig.java
How to enable HTTPS in a Spring Boot Application
@Configuration
public class ConnectorConfig {
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() {
@Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
@hakimkal
hakimkal / ssl_setup_springboot
Last active November 13, 2018 22:47
SSL Setup for Springboot
Setting up SSL Certificate.
Upon downloading your certificates and key as issued by the CA. Follow the below steps.
Step 1:
openssl pkcs12 -export -in zip/certificate.crt -inkey zip/private.key -name ewersgombe -out zip/ewersgombe-PKCS-12.p12
Step 2:
keytool -importkeystore -deststorepass hotoro -destkeystore zip/ewersgombe-keystore.jks -srckeystore zip/ewersgombe-PKCS-12.p12 -srcstoretype PKCS12
@hakimkal
hakimkal / firewall_ports_open_vps
Last active November 13, 2018 22:48
Firewall port open on VPS
install ufw
ufw allow
ufw allow 443/tcp
ufw allow 80/tcp
ufw enable
ufw disable
ufw logging on
@hakimkal
hakimkal / workdays_calculator.ex
Created March 18, 2019 13:55
Elixir Workdays Calculator Module
defmodule WorkdaysCalculator do
def calculate_workdays(lastday, month \\ Date.utc_today.month, year \\ Date.utc_today.year) do
1..lastday
|> Enum.map(
fn day ->
{:ok, d} = Date.new year, month, day
d
end
)
@hakimkal
hakimkal / sieve_algorithm.js
Last active May 24, 2019 07:52
Sieve of Eratosthenes Method for Test of Primality
#!/usr/bin/env node
/*
* Author : Abdulhakim Haliru
* http://www.leproghrammeen.com
* June, 2013.
* This is a Server Side Javascript written for the nodejs engine to generate
* the first 1000 prime numbers and write it to a file "prime_number.txt" and write t using the sieve of Eratosthenes method(http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes)
* The method is efficient for any number below 10,000,000.
* */
var fs = require('fs');
FROM ubuntu:18.04
WORKDIR /app
RUN apt-get update && apt-get install -y curl locales
# Set locale
RUN locale-gen en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
FROM bitwalker/alpine-elixir:1.9.0
# Set exposed ports
EXPOSE 4010
ENV PORT=4010
ENV MIX_ENV=prod
WORKDIR /app
defp initialize_paystack(user, amount, transaction_reference) do
secret_key =
Application.get_env(:project_name, :paystack_config)[:secret_key]
#public_key =
Application.get_env(:project_name, :paystack_config)[:public_key]
url = "https://api.paystack.co/transaction/initialize"
headers =
["Authorization": "Bearer #{secret_key}", "Accept": "Application/json; Charset=utf-8"]
def pay_with_paystack(conn, params) do
transaction_reference = "AsdRe1234"
amount = floor(params["amount_paid"]
user = conn.assigns[:current_user]
res = initialize_paystack(user, amount, transaction_reference)
{:ok, paystack_trans} = Jason.decode(r.body, [keys: :atoms])