Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', '.', '.', '.'], | |
['.', '.', '.', '.', '.', '.']] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): |
NewerOlder