This is a simple shell script that is designed to provision both nginx and node on your machine. I primarily wrote it for use with Vagrant and an example Vagrantfile is included in the Gist as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fetch = require("isomorphic-unfetch"); | |
| const querystring = require("querystring"); | |
| class DevTo { | |
| constructor(config) { | |
| this.api_key = config.api_key; | |
| this.basePath = "https://dev.to/api"; | |
| } | |
| request(endpoint = "", options = {}) { | |
| let url = this.basePath + endpoint; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CircuitBreaker { | |
| constructor(request, options = {}) { | |
| const defaults = { | |
| failureThreshold: 3, | |
| successThreshold: 2, | |
| timeout: 6000 | |
| } | |
| Object.assign(this, defaults, options, { | |
| request, | |
| state: "CLOSED", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CircuitBreaker { | |
| constructor(request) { | |
| this.request = request | |
| this.state = "CLOSED" | |
| this.failureThreshold = 3 | |
| this.failureCount = 0 | |
| this.successThreshold = 2 | |
| this.successCount = 0 | |
| this.timeout = 6000 | |
| this.nextAttempt = Date.now() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function applyToKeys(obj, modify) { | |
| let newObj = {} | |
| for (let [key, value] of Object.entries(obj)) { | |
| if (typeof value === 'object') { | |
| newObj[key] = applyToKeys(obj[key], modify) | |
| } else { | |
| newObj[key] = modify(value) | |
| } | |
| } | |
| return newObj |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const gulp = require('gulp') | |
| const sass = require('gulp-sass') | |
| const browserSync = require('browser-sync').create() | |
| const reload = browserSync.reload | |
| gulp.task('sass', ()=> { | |
| return gulp.src('scss/main.scss') | |
| .pipe(sass().on('error', sass.logError)) | |
| .pipe(gulp.dest('css')) | |
| .pipe(reload({stream: true})) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "USD": { | |
| "symbol": "$", | |
| "name": "US Dollar", | |
| "symbol_native": "$", | |
| "decimal_digits": 2, | |
| "rounding": 0, | |
| "code": "USD", | |
| "name_plural": "US dollars" | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.ajax({ | |
| type: 'POST', | |
| url: 'http://kyleschaeffer.com/feed/', | |
| data: { postVar1: 'theValue1', postVar2: 'theValue2' }, | |
| beforeSend:function(){ | |
| // this is where we append a loading image | |
| $('#ajax-panel').html('<div class="loading"><img src="/images/loading.gif" alt="Loading..." /></div>'); | |
| }, | |
| success:function(data){ | |
| // successful request; do something with the data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="logo"> | |
| <div class="pencil"></div> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="article-meta"> | |
| <ul> | |
| <li><time>{{ page.date | date: "%m/%d/%Y" }}</time></li> | |
| <li><a href="http://twitter.com/share?url=http://{{site.url}}{{page.url}}&text={{page.title}} via @markmichon">Tweet<a/></li> | |
| <li><a href="http://www.facebook.com/sharer.php?u=http://{{site.url}}{{ page.url }}&t={{page.title}}">Share on Facebook</a></li> | |
| <!-- <li>Reading time: {{ content | count_minutes }}</li> | |
| </ul> | |
| </div> |
NewerOlder