Skip to content

Instantly share code, notes, and snippets.

View tejuafonja's full-sized avatar

Afonja Tejumade tejuafonja

View GitHub Profile
@tejuafonja
tejuafonja / colab1-for-deeplearn.ipynb
Created March 7, 2019 03:41
Colab1-for-deeplearn.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def is_prime(number):
if number > 1:
if number == 2:
return True
if number % 2 == 0"
return False
for current in range(3, int(math.sqrt(number) +1), 2):
if number % current == 0:
return False
return True
@tejuafonja
tejuafonja / 1 Introduction to sass - scss
Last active April 4, 2018 18:55
Working with Scss / Sass
Sass is CSS pre-processor that allows you to
a. Use variables
b. Nest CSS - this helps you have neat structure
c. Seperate your CSS to modules (partials)
d. Extend some other pre-defined rules e.g using @extend .btn;
e. Use Operators like addition division, logic etc
f. Add functionalities that allow you to use functions called Mixins
@tejuafonja
tejuafonja / setup
Created March 16, 2018 12:44
Running Ghost on github pages
download ghost (see https://medium.com/aishik/publish-with-ghost-on-github-pages-2e5308db90ae)
install node
extract ghost to /home or anywhere you'd remember. maybe /home/my-ghost or /home/ghost. You can use any name you want
run knex-migrator init
run npm install
run npm start
checkout your server on http://localhost:2368/ #everything should work fine
CNTRL-C # kill the server
buster setup YOUR-FORK-REPO
// is a==1&&a==2&&a==3 = true?
const a = {
currentVal: 0,
valueOf: function() {
return this.currentVal += 1;
}
}
if (a==1&&a==2&&a==3) {
function staircase(n) {
for (var i=0; i<n; i++) {
var space = n-i-1
var stairs = ' '.repeat(space) + '#'.repeat(i+1)
console.log(stairs)
}
}
@tejuafonja
tejuafonja / Binary Gap
Created October 13, 2017 16:57
find the max 0's in-between 1's in a binary number
function solution(N) {
var maxGap = 0;
var tempGap = 0;
var count = 0;
var binGap = N.toString(2);
var lastIndex = binGap.length - 1;
for (lastIndex; lastIndex>=0; lastIndex--) {
if (binGap[lastIndex] !== '0') {
@tejuafonja
tejuafonja / Objects and Array
Created October 6, 2017 11:38
How to copy an object or array
var player = {score: 1, name: 'Jeff'};
var newPlayer = Object.assign({}, player, {score: 2});
// Now player is unchanged, but newPlayer is {score: 2, name: 'Jeff'}
// Or if you are using object spread syntax proposal, you can write:
var newPlayer = {...player, score: 2};
// for Arrays
var player = ['Ronaldo', 'Merci', 'Rooney']
grid = [['.', '.', '.', '.', '.', '.'],
['.', 'O', 'O', '.', '.', '.'],
['O', 'O', 'O', 'O', '.', '.'],
['O', 'O', 'O', 'O', 'O', '.'],
['.', 'O', 'O', 'O', 'O', 'O'],
['O', 'O', 'O', 'O', 'O', '.'],
['O', 'O', 'O', 'O', '.', '.'],
['.', 'O', 'O', '.', '.', '.'],
['.', '.', '.', '.', '.', '.']]
# python 2.7
class Celsius(object):
def __init__(self, temperature = 0):
self.temperature = temperature
def to_fahrenheit(self):
return (self.temperature * 1.8) + 32
@property
def temperature(self):