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
#include <cs50.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int get_card_length(long card) | |
{ | |
int length = 0; | |
while (card > 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
@media (min-width:320px) { /* smartphones, portrait iPhone, portrait 480x320 phones (Android) */ } | |
@media (min-width:480px) { /* smartphones, Android phones, landscape iPhone */ } | |
@media (min-width:600px) { /* portrait tablets, portrait iPad, e-readers (Nook/Kindle), landscape 800x480 phones (Android) */ } | |
@media (min-width:801px) { /* tablet, landscape iPad, lo-res laptops ands desktops */ } | |
@media (min-width:1025px) { /* big landscape tablets, laptops, and desktops */ } | |
@media (min-width:1281px) { /* hi-res laptops and desktops */ } |
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
/* Write a function solution(A); that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A. | |
For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5. | |
Given A = [1, 2, 3], the function should return 4. | |
Given A = [−1, −3], the function should return 1. | |
Write an efficient algorithm for the following assumptions: | |
N is an integer within the range [1..100,000]; | |
each element of array A is an integer within the range [−1,000,000..1,000,000]. */ | |
const A = [-1, -4]; |
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
CREATE TABLE friends ( | |
id INTEGER, | |
name TEXT, | |
birthday DATE | |
); | |
INSERT INTO friends (id, name, birthday) | |
VALUES | |
(1, 'Jane Doe', '1990-05-30'), | |
(2, 'Richard Stallman', '1953-03-16'), |
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
const Calculate = { | |
factorial(number) { | |
if(number === 0) { | |
return 1; | |
} | |
for(let i = number - 1; i >= 1; i--) { | |
number *= i; | |
} | |
return number; | |
} |
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
// Define a rooster | |
Rooster = {}; | |
// Return a morning rooster call | |
Rooster.announceDawn = () => { | |
return 'moo!'; | |
} | |
// Return hour as string | |
// Throws Error if hour is not between 0 and 23 inclusive |
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
const fs = require('fs'); | |
let readDataCallback = (err, data) => { | |
if (err) { | |
console.log(`Something went wrong: ${err}`); | |
} else { | |
console.log(`Provided file contained: ${data}`); | |
} | |
}; | |
fs.readFile('./finalFile.txt', 'utf-8', readDataCallback); |
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
const api = require('./node-error-api.js'); | |
// Not an error-first callback | |
let callbackFunc = (data) => { | |
console.log(`Something went right. Data: ${data}\n`); | |
}; | |
try { | |
api.naiveErrorProneAsyncFunction('problematic input', callbackFunc); | |
} catch(err) { |
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
let secretValue = Math.floor(1+Math.random()*10).toString(); | |
let numbers = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; | |
module.exports = { | |
testNumber: (input) => { | |
if (input === 'quit') { | |
process.stdout.write('Ok. Bye!\n') | |
process.exit(); | |
} |
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
// Require core events | |
let events = require('events'); | |
// Create Event Callback | |
let listenerCallback = (data) => { | |
console.log('Celebrate ' + data); | |
} | |
// Init EventEmitter method | |
let myEmitter = new events.EventEmitter(); |
NewerOlder