Skip to content

Instantly share code, notes, and snippets.

View jslnriot's full-sized avatar

James Buczkowski jslnriot

View GitHub Profile
@jslnriot
jslnriot / padLeft.js
Created March 30, 2016 01:13
padLeft
String.prototype.padLeft = function(padding, passedChar) {
if(passedChar === undefined) {
passedChar = " ";
}
var specialChar = passedChar;
var strLength = this.length;
var padLength = padding - strLength;
// Use this to create a generic function that you can specialize later
// This example takes only 1 argument
function add(firstNumber) {
//var addMe = firstNumber;
return function(secondNumber) {
return firstNumber + secondNumber;
}
}
var twenty = add(12)(8);
@jslnriot
jslnriot / maxInArray.js
Created April 8, 2016 01:01
create a function that gets the max number in an array
Array.prototype.max = function(){
return this.reduce(function(prev,curr) {
return Math.max(prev,curr);
});
}
arr = [1,2,4,3,6,3,7,8,2];
console.log(arr.max());
numArr = [1,2,4,5,3,6,10,11,5,20,50,33,29];
sortAscending = numArr.sort(function(a,b) {
return a - b;
});
console.log(sortAscending);
sortDescending = numArr.sort(function(a,b){
return b - a;
@jslnriot
jslnriot / webpack.config.js
Last active February 1, 2017 02:06
webpack 2 example config file
const webpack = require('webpack')
path = require('path'),
ExtractTextPlugin = require("extract-text-webpack-plugin"),
HTMLWebpackPlugin = require('html-webpack-plugin'),
ExtractCSS = new ExtractTextPlugin("css/[name].[chunkhash].css"),
CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = {
entry: {
vendor: [
server {
root /var/www/Sites/jamesbuczkowski.com/public_html/dist;
server_name jamesbuczkowski.com www.jamesbuczkowski.com;
location / {
try_files $uri /index.html;
}
}
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { fetchStuff } from '../actions/index';
class WelcomeContainer extends Component {
render() {
return (
<div className="welcome-container">
Welcome Container
<html>
<head>
<script>
// http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/
var counter = 0;
var limit = 10;
function addNewGradeCheck(e, divName) {
e.preventDefault();
<html>
<head>
<title></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://fb.me/react-0.14.0.js"></script>
<script src="https://fb.me/react-dom-0.14.0.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.25/browser.min.js"></script>
</head>
<body>
<div id="container"></div>
import React, { Component } from 'react';
class Welcome extends Component {
constructor(props) {
super(props);
this.state = { message: 'Welcome to the Welcome Page!'};
}
render() {
return (