Skip to content

Instantly share code, notes, and snippets.

@chrisblossom
chrisblossom / gist:8690833
Last active February 23, 2016 07:40
Dynamically set ansible ansible_ssh_port and ansible_ssh_user
---
# 1) Be sure to set the following variables for all hosts:
# vars:
# oldsshport: 22
# sshport: 555
# 2) Might fail without setting remote_tmp = /tmp/ansible/$USER in your ansible.cfg. Includes a fix for this setting below.
# 3) Once host is setup most of the checks are skipped and works very quickly.
# 4) Be sure to set non-standard shells in a different playbook later. Stick with /bin/bash until you can run apt install.
# 5) Assumes root user has sshkey setup already. Not sure how to utilize the --ask-pass option. For now, use ssh-copy-id prior to running playbook on new host for root user (if needed).
@chrisblossom
chrisblossom / gist:8979722
Last active July 16, 2017 06:53
Packer Ansible-from-git-checkout Provisioner
### *** Contains some Ubuntu-specific commands/packages. Modify accordingly. ***
###
# scripts/ansible.sh
###
#!/usr/bin/env bash
# Ansible dependencies
/**
* Parses mixed type values into booleans. This is the same function as filter_var in PHP using boolean validation
* @param {Mixed} value
* @param {Boolean} nullOnFailure = false
* @return {Boolean|Null}
*/
var parseBooleanStyle = function(value, nullOnFailure = false){
switch(value){
case true:
case 'true':
var Promise = require('bluebird');
var promiseWhile = function(condition, action) {
var resolver = Promise.defer();
var loop = function() {
if (!condition()) return resolver.resolve();
return Promise.cast(action())
.then(loop)
.catch(resolver.reject);
@chrisblossom
chrisblossom / Gulpfile.js
Created January 28, 2016 18:03 — forked from webdesserts/Gulpfile.js
Automatically reload your node.js app on file change with Gulp (https://github.com/wearefractal/gulp).
// NOTE: I previously suggested doing this through Grunt, but had plenty of problems with
// my set up. Grunt did some weird things with scope, and I ended up using nodemon. This
// setup is now using Gulp. It works exactly how I expect it to and is WAY more concise.
var gulp = require('gulp'),
spawn = require('child_process').spawn,
node;
/**
* $ gulp server
* description: launch the server. If there's a server already running, kill it.
@chrisblossom
chrisblossom / esnextbin.md
Last active May 4, 2016 14:53
esnextbin sketch
/* iPhone 2G-4S (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
@chrisblossom
chrisblossom / raven-config.html
Created October 7, 2016 12:21 — forked from impressiver/raven-config.html
Raven.js configuration for logging JavaScript exceptions to Sentry (https://getsentry.com/). Without the added ignore options, you'll quickly find yourself swamped with unactionable exceptions due to shoddy browser plugins and 3rd party script errors.
<!-- Raven.js Config -->
<script src="{{ JS_PATH }}/lib/raven.js" type="text/javascript"></script>
<script type="text/javascript">
// Ignore list based off: https://gist.github.com/1878283
var ravenOptions = {
// Will cause a deprecation warning, but the demise of `ignoreErrors` is still under discussion.
// See: https://github.com/getsentry/raven-js/issues/73
ignoreErrors: [
// Random plugins/extensions
'top.GLOBALS',
@chrisblossom
chrisblossom / mini-redux.js
Created November 10, 2016 15:55 — forked from MarcoWorms/mini-redux.js
Redux in a nutshell
function createStore (reducers) {
var state = reducers()
const store = {
dispatch: (action) => {
state = reducers(state, action)
},
getState: () => {
return state
}
}
@chrisblossom
chrisblossom / README.md
Last active April 29, 2020 17:33 — forked from snowkidind/README.md
TDAmeritrade API Notes for Node.js

Access to Ameritrade API

notes that may be helpful for node.js devs

What I've gathered is authorization tokens must be earned first. Authorization tokens are good for three months, once you are setup, you will get two tokens which come as long strings, An access_token and a refresh_token. Access tokens are only valid for 30 minutes so you will need to code to refresh the session using the refresh token frequently. When you refresh, you are given a new access token and that is what you use to "login" or pull from the api for the next period. But in order to get the tokens, you will be required to go through some processes to get a valid token that applies to your app. The following text kind of steers you in that direction...

Making an app

On the api site you will need to make an app, where you pick some random name by using some random numbers. It should be automatically generated but it isnt. For this field item, I simply went to https://www.uuidgenerator.net/ and just grabbed the first