Skip to content

Instantly share code, notes, and snippets.

View jslnriot's full-sized avatar

James Buczkowski jslnriot

View GitHub Profile
@bradtraversy
bradtraversy / webdev_online_resources.md
Last active May 3, 2024 12:56
Online Resources For Web Developers (No Downloading)
@bjdixon
bjdixon / action.js
Created October 19, 2017 04:49
Alternative to switch statements in reducers
import { LANGUAGE, COUNTRY } from './constants';
export const setLanguage = language => ({
type: LANGUAGE,
language
});
export const setCountry = country => ({
type: COUNTRY,
country
});
@alfonsomunozpomer
alfonsomunozpomer / Fetch.test.js
Created September 28, 2017 12:51
How to test a React component that sets its state in componentDidMount with fetch, and how to mock it, in Jest
// https://github.com/alfonsomunozpomer/react-fetch-mock
import React from 'react'
import fetchMock from 'fetch-mock'
import Enzyme from 'enzyme'
import {shallow, mount, render} from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
Enzyme.configure({ adapter: new Adapter() })
@mrparkers
mrparkers / async-component.spec.js
Created August 4, 2016 00:43
Unit testing an async React component using Mocha, Chai, and Enzyme
import AsyncComponent from './path/to/component';
import request from 'your-request-library';
import React from 'react';
import {shallow} from 'enzyme';
import Chance from 'chance';
import chai, {expect} from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
@nealrs
nealrs / gitatme_demo_i133.js
Created April 13, 2016 01:43
ExcelJS demo for Git@Me
var Excel = require('exceljs');
// create workbook & add worksheet
var workbook = new Excel.Workbook();
var worksheet = workbook.addWorksheet('Discography');
// add column headers
worksheet.columns = [
{ header: 'Album', key: 'album'},
{ header: 'Year', key: 'year'}
@monicao
monicao / react.md
Last active February 23, 2021 19:07
React Lifecycle Cheatsheet

React Component Lifecycle

  • getInitialState
  • getDefaultProps
  • componentWillMount
  • componentDidMount
  • shouldComponentUpdate (Update only)
  • componentWillUpdate (Update only)
  • componentWillReceiveProps (Update only)
  • render
@ricardo-rossi
ricardo-rossi / ElasticSearch.sh
Last active December 1, 2023 04:55
Installing ElasticSearch on Ubuntu 14.04
#!/bin/bash
### USAGE
###
### ./ElasticSearch.sh 1.7 will install Elasticsearch 1.7
### ./ElasticSearch.sh will fail because no version was specified (exit code 1)
###
### CLI options Contributed by @janpieper
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch
@hwdsl2
hwdsl2 / .MOVED.md
Last active May 4, 2024 03:19
IPsec VPN Server Auto Setup Script for Ubuntu and Debian
@skhatri
skhatri / s3.js
Last active October 31, 2022 16:26
NodeJS AWS S3 list/clear/delete buckets.
module.exports = {
deleteObject: function (client, deleteParams) {
client.deleteObject(deleteParams, function (err, data) {
if (err) {
console.log("delete err " + deleteParams.Key);
} else {
console.log("deleted " + deleteParams.Key);
}
});
},
@arvis
arvis / app.js
Created August 15, 2012 08:46
Basic express and mongoose CRUD application
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http')
, mongoose = require('mongoose')
, path = require('path');