Skip to content

Instantly share code, notes, and snippets.

@codejockie
codejockie / gist:125b2c78c79c7556c04e9a8a287fe9b5
Created September 9, 2017 10:25 — forked from bsummer4/gist:f02d0c2832dc90c96c1c
Simple Example using ReactJS to manage Bootstrap Modals.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/css/bootstrap.min.css">
</head>
<body>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/js/bootstrap.min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/react/0.11.0/react.js"></script>
@codejockie
codejockie / iterm2-solarized.md
Created October 27, 2017 22:28 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

@codejockie
codejockie / array_iteration_thoughts.md
Created December 10, 2017 16:05 — forked from ljharb/array_iteration_thoughts.md
Array iteration methods summarized

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and

@codejockie
codejockie / authentication.js
Created March 6, 2018 18:38 — forked from marshallswain/authentication.js
Example tools for using querystring redirects with Feathers OAuth login.
'use strict';
const authentication = require('feathers-authentication');
const jwt = require('feathers-authentication-jwt');
const local = require('feathers-authentication-local');
const oauth2 = require('feathers-authentication-oauth2');
const GithubStrategy = require('passport-github');
// Bring in the oauth-handler
const makeHandler = require('./oauth-handler');
@codejockie
codejockie / flatMap.js
Created April 8, 2018 19:09 — forked from samgiles/flatMap.js
Javascript flatMap implementation
// [B](f: (A) ⇒ [B]): [B] ; Although the types in the arrays aren't strict (:
Array.prototype.flatMap = function(lambda) {
return Array.prototype.concat.apply([], this.map(lambda));
};
@codejockie
codejockie / ie-shims.js
Created April 11, 2018 22:33 — forked from djKianoosh/ie-shims.js
IE shims for array indexOf, string startsWith and string trim
// Some common IE shims... indexOf, startsWith, trim
/*
Really? IE8 Doesn't have .indexOf
*/
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
"use strict";
if (this === null) {
throw new TypeError();
@codejockie
codejockie / nodejs_aws_s3_file_upload.js
Created July 18, 2018 17:37 — forked from sarfarazansari/nodejs_aws_s3_file_upload.js
How to upload files to AWS S3 with NodeJS - AWS-SDK? With the help of this library you can upload any kind of file to s3. (NODEJS, AWS-SDK, S3)
/**
* we are going to upload file to s3 via node js by using
* aws-sdk - required
* busboy - required
* uuid - optional - for image renaming purpose
* with this library you can upload any kind of file to s3 via node js.
*/
const AWS = require('aws-sdk');
const UUID = require('uuid/v4');
@codejockie
codejockie / numberToOrdinal.js
Created February 23, 2019 23:56 — forked from jondwx/numberToOrdinal.js
Number to Ordinal Format
function numberToOrdinal(i) {
var j = i % 10,
k = i % 100;
if (j == 1 && k != 11) {
return i + "st";
}
if (j == 2 && k != 12) {
return i + "nd";
}
if (j == 3 && k != 13) {
@codejockie
codejockie / countChange.js
Created February 23, 2019 23:56 — forked from zestime/countChange.js
JavaScript ver. of Counting coins
function countChange(money, coins) {
if (money == 0) return 1;
if (money < 0 || coins.length == 0) return 0;
return countChange(money - coins[0], coins) + countChange(money, coins.slice(1));
}
@codejockie
codejockie / Basic_React_Gotchas.md
Created February 26, 2019 21:31 — forked from joeytwiddle/Basic_React_Gotchas.md
Some things we learned in the first few months of using React

Basic React Gotchas

Note: This document was written for someone who already knows React fairly well, because it was initially a list of suggested talking points for a presentation they were planning. Ideally this document should be expanded to include clear examples for the final target audience, which is React beginners.

setState does not apply the update immediately

// Constructor
this.state = { foo: 0 };