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: [
@jslnriot
jslnriot / package.json-webpack2-example
Last active September 11, 2017 17:50
Package.json example for webpack 2 config
{
"name": "react-webpack2-bootstrap4-sass",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"clean": "rimraf dist",
"buildDev": "npm run build && ./node_modules/.bin/webpack-dev-server",
"build": "npm run clean && webpack"
},
server {
root /var/www/Sites/jamesbuczkowski.com/public_html/dist;
server_name jamesbuczkowski.com www.jamesbuczkowski.com;
location / {
try_files $uri /index.html;
}
}
<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();
import React, { Component } from 'react';
class Welcome extends Component {
constructor(props) {
super(props);
this.state = { message: 'Welcome to the Welcome Page!'};
}
render() {
return (
import React from 'react';
const ExampleComponent = ({message}) => {
const showMessage = (event) => {
alert(`The message is: ${message}`);
};
return (
<div>
<a href="#" onClick={showMessage}>show me</a>