Skip to content

Instantly share code, notes, and snippets.

View ethanstenis's full-sized avatar

Ethan Stenis ethanstenis

View GitHub Profile
@ethanstenis
ethanstenis / gist:cc6c2f6e85598a83ed6d0348fb1325e6
Created August 22, 2017 19:20
Pluralsight Analytics: Query Strings
?ps_debug=true
// Add to URL and reload page - shows all analytics events being captured by the Data Layer in the console.
&ps_debug=true
// same query string except that it is not be used first.
analytics.debug();
analytics.debug(false);
@ethanstenis
ethanstenis / ReactJS: Play Nine Numbers Game
Last active August 29, 2024 23:10
This is the code for the REACT.JS Play Nine numbers game
// bit.ly/s-pcs
var possibleCombinationSum = function(arr, n) {
if (arr.indexOf(n) >= 0) { return true; }
if (arr[0] > n) { return false; }
if (arr[arr.length - 1] > n) {
arr.pop();
return possibleCombinationSum(arr, n);
}
var listSize = arr.length, combinationsCount = (1 << listSize);
for (var i = 1; i < combinationsCount ; i++ ) {
const Stars = (props) => {
// const numberofStars = 1 + Math.floor(Math.random()*9);
return (
<div className="col-5">
{_.range(props.numberofStars).map(i =>
<i key={i} className="fa fa-star"></i>
)}
</div>
);
const Card = (props) => {
return (
<div style={{margin: '1em'}}>
<img width="75" src={props.avatar_url} />
<div style={{display: 'inline-block', marginLeft: 10}}>
<div style={{fontSize: '1.25em', fontWeight: 'bold'}}>{props.name}</div>
<div>{props.company}</div>
</div>
</div>
);
class Button extends React.Component {
handleClick = () => {
this.props.onClickFunction(this.props.incrementValue);
};
render() {
return (
<button onClick={this.handleClick}>
+{this.props.incrementValue}
</button>
@ethanstenis
ethanstenis / KATA: Square(n)Sum
Created July 17, 2017 16:51
This is the solution to Codewars' KATA: Square(n)Sum
function squareSum(numbers){
var total = 0;
for(var i = 0; i < numbers.length; i++) {
total += numbers[i] * numbers[i];
}
return total;
@ethanstenis
ethanstenis / KATA: Do I get a bonus?
Created July 17, 2017 16:34
This is the solution to Codewars' KATA: Do I get a bonus?
function bonusTime(salary, bonus) {
if(bonus === true){
return '£' + salary * 10;
} else {
return '£' + salary;
}
}
@ethanstenis
ethanstenis / KATA: Basic Mathematical Operations
Created July 17, 2017 16:25
This is the solution to Codewars' KATA: Basical Mathematical Operations
function basicOp(operation, value1, value2)
{
if (operation === '+') {
return value1 + value2;
} else if(operation === '-') {
return value1 - value2;
} else if(operation === '*') {
return value1 * value2;
} else if(operation === '/'){
return value1/value2;
@ethanstenis
ethanstenis / KATA: My Head is at the Wrong End!
Created July 17, 2017 16:17
This is the solution to Codewars' Kata: My head is at the wrong end.
function fixTheMeerkat(arr) {
var end = arr.shift();
var begin = arr.pop();
arr.push(end);
arr.unshift(begin);
return arr;
}
@ethanstenis
ethanstenis / KATA: How Old Will I Be In 2099?
Created July 14, 2017 16:03
This is the solution to the Codewars Kata: How Old Will I be in 2099
function calculateAge(birthDate, otherDate) {
var age = otherDate - birthDate;
if(age === 1) {
return 'You are ' + age + ' year old.';
} else if(age > 1) {
return 'You are ' + age + ' years old.';
} else if (age < -1) {
return 'You will be born in ' + Math.abs(age) + ' years.';