Skip to content

Instantly share code, notes, and snippets.

Avatar

Ethan Stenis ethanstenis

View GitHub Profile
@ethanstenis
ethanstenis / Postman POST PUT Requests.txt
Last active Sep 7, 2020
How to make Postman work with POST/PUT requests in Laravel...
View Postman POST PUT Requests.txt
To make Postman work with POST/PUT requests...
https://laravel.com/docs/5.2/routing#csrf-x-csrf-token
In addition to checking for the CSRF token as a POST parameter, the Laravel VerifyCsrfToken middleware will also check for the X-CSRF-TOKEN request header.
1. Store the token in a "meta" tag at the top of your root view file (layouts/app.blade.php)...
<meta name="csrf-token" content="{{ csrf_token() }}">
** If using jQuery, you can now instruct it to include the token in all request headers.
$.ajaxSetup({
@ethanstenis
ethanstenis / gist:cc6c2f6e85598a83ed6d0348fb1325e6
Created Aug 22, 2017
Pluralsight Analytics: Query Strings
View gist:cc6c2f6e85598a83ed6d0348fb1325e6
?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 Aug 8, 2017
This is the code for the REACT.JS Play Nine numbers game
View ReactJS: 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++ ) {
View Pluralsight React.js: Numbers Selection: Changing the Answer
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>
);
View Pluralsight React.js: Github Card Component
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>
);
View Pluralsight React.js: Getting Started: Your First Component
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 Jul 17, 2017
This is the solution to Codewars' KATA: Square(n)Sum
View 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 Jul 17, 2017
This is the solution to Codewars' KATA: Do I get a bonus?
View 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 Jul 17, 2017
This is the solution to Codewars' KATA: Basical Mathematical Operations
View KATA: Basic 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 Jul 17, 2017
This is the solution to Codewars' Kata: My head is at the wrong end.
View 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;
}
You can’t perform that action at this time.