This file contains hidden or 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
class Vampire { | |
constructor(name, yearConverted) { | |
this.name = name; | |
this.yearConverted = yearConverted; | |
this.offspring = []; | |
this.creator = null; | |
} | |
/** Simple tree methods **/ |
This file contains hidden or 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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var random = new Random(); | |
var firstnames = female; | |
for (int i = 0; i < 100; i++) | |
{ | |
if (random.Next()%2 == 0) firstnames = male; |
This file contains hidden or 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
/* Returns either the index of the location in the array, | |
or -1 if the array did not contain the targetValue */ | |
var doSearch = function(array, targetValue) { | |
var min = 0; | |
var max = array.length - 1; | |
var guess; | |
var i = 1; | |
while (max >= min){ | |
guess = Math.floor((max + min)/2); |
This file contains hidden or 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 React = require('react'); | |
const App = props => <div id="app"><Notification {...props.notification}/></div> | |
let map = { success: 'success', message: 'info', caution: 'warning', error: 'danger' } | |
class Notification extends React.Component { | |
render() { | |
let props = this.props; | |
let type = map[props.type] || 'info'; |
This file contains hidden or 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
/* mrrena theme <mrrena.blogspot.com> */ | |
pre.code { | |
background-color: #1e2029; | |
padding: 4px; | |
color: #fff; | |
font-family: monospace, consolas, "courier new"; | |
color: #fff; | |
font-size: 12px; | |
margin: 1.0em 40px; | |
overflow-x: auto; |
This file contains hidden or 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 library = { | |
tracks: { | |
t01: { | |
id: "t01", | |
name: "Code Monkey", | |
artist: "Jonathan Coulton", | |
album: "Thing a Week Three" | |
}, | |
t02: { | |
id: "t02", |
This file contains hidden or 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 library = { | |
tracks: { | |
t01: { | |
id: "t01", | |
name: "Code Monkey", | |
artist: "Jonathan Coulton", | |
album: "Thing a Week Three" | |
}, | |
t02: { | |
id: "t02", |
This file contains hidden or 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
bind_searchbar: function() { | |
var cooq = this, | |
input = $("#search"), | |
results = [], | |
results_element = '.live-search-results', | |
current_element = null, | |
show_search_help = null, | |
hide_search_help = null; | |
This file contains hidden or 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
//helper function, checks if parameter only contains honorifics | |
const checkIfOnlyHonorific = function(name, honorific) { | |
return honorific.includes(name); | |
}; | |
//helper function, checks if parameter is empty | |
const isEmpty = function(name) { | |
return name === ''; | |
}; | |
//helper function, gives name in lastName, FirstName |
This file contains hidden or 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
// pass results via callback functions | |
// callback function, argument index | |
// The second argument/parameter is expected to be a (callback) function | |
// expected output "Found Waldo at index 2!" | |
const findWaldo = function(names, found) { | |
for (let i = 0; i < names.length; i++) { | |
// let name = names[i]; | |
if (names[i] === "Waldo") { | |
found(i); // execute callback |
OlderNewer