Skip to content

Instantly share code, notes, and snippets.

View pensebien's full-sized avatar

Awokoya Emmanuel pensebien

View GitHub Profile
// Brightness math based on:
// http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx
$red-magic-number: 241;
$green-magic-number: 691;
$blue-magic-number: 68;
$brightness-divisor: $red-magic-number + $green-magic-number + $blue-magic-number;
@function brightness($color) {
// Extract color components
@pensebien
pensebien / git_bash_ssh_auth_win_setup.md
Last active November 28, 2017 20:08
Setup and Test SSH Authentication from Scratch Git Bash on Windows 7

Setup SSH Authentication using GIT BASH on Windows

######################################################

This set is broken down into

  1. Generating a new SSH Key and Adding it to the ssh-agent

    Read more about SSH agent

    And read about Generating a new SSH key from Github help

@pensebien
pensebien / adding_new_user_in_digital_ocean.md
Last active November 29, 2017 01:16
How to add a new user on your Ubuntu Digital Ocean Droplet from a Git Bash Windows System

Adding a user to the System to allow control over the www.data (Web directory of your new droplet)

#############################################################

⋅⋅1. Log in to your server as the root user

`local$ ssh root@server_ip address e.g ssh root@204.55.34.84`

You can learn how to add SSH to your Windows's system from GIT BASH

@pensebien
pensebien / intersecting_rec..rb
Last active October 1, 2016 09:10
This contains a function that finds the intersecting vertices of two rectangles given the rectangles vertices as two arrays. The arrays are given such that the two first elements are the coordinate of the base point of the rectangle, while the third element is the breath and the last element is the height of the rectangle. Example a=[1,1,2,3] x=…
#The function find the intersection point of two lines
def intersect_rec(a, b)
#Function takes the coordinate of horizontal and vertical line #Return the coordinate of the intersection
intersect = []
if a.length !=4 and b.length !=4
return "You did not enter a rectangle vertices"
end
x1 = a[0]
x2 = a[0]+a[2]
y1 = a[1]
@pensebien
pensebien / product_of_array.rb
Last active September 29, 2016 22:17
Find the product of the elements in an Array without the element itself. [1,2,3], newArray = [6,3,2]
def product_of_elements_array(a)
i = 0
prod = 1
while i <= (a.length-1)
prod = prod * a[i]
i+=1
end
prod
end
@pensebien
pensebien / isPrime.rb
Last active September 29, 2016 19:39
This is a ruby code that check if the number you typed is a prime using the fastest method ever. Hint! Use square root algorithm
puts "Enter a number to to check"
number = gets.chomp.to_i
def abs(firstNum,secNum)
if firstNum > secNum
firstNum - secNum
else
secNum - firstNum
puts "Enter a number to find the square"
number = gets.chomp.to_i
puts "Enter the accepted error"
error = gets.chomp.to_i
def abs(firstNum,secNum)
if firstNum>secNum
firstNum-secNum