Skip to content

Instantly share code, notes, and snippets.

@althaffe
althaffe / index.js
Created February 18, 2018 04:23
Cosmic JS add to bucket
let content = ''
items.forEach(item => {
content+= `${item.title} x ${item.count}, `
})
const params = {
type_slug: 'orders',
title: name,
content: content,
metafields: [
{
@althaffe
althaffe / gist:f9acd57f4cdc8e4a4d48f5eb910c188b
Last active February 18, 2018 03:16
Configuration for vue-stripe-checkout element.
import Vue from 'vue';
import VueStripeCheckout from 'vue-stripe-checkout';
const options = {
key: process.env.STRIPE_PUBLIC_KEY,
image: 'https://cosmicjs.com/images/logo.svg',
locale: 'auto',
currency: 'USD',
billingAddress: true,
panelLabel: 'Pay {{amount}}'
COSMIC_BUCKET=
COSMIC_READ_KEY=
COSMIC_WRITE_KEY=
PORT=
STRIPE_SECRET_KEY=
STRIPE_PUBLIC_KEY=
var express = require('express')
var path = require('path')
var serveStatic = require('serve-static')
require('dotenv').config()
app = express()
app.use(serveStatic(__dirname + "/dist"))
var port = process.env.PORT || 5000
app.listen(port)
console.log('server started '+ port)
COSMIC_BUCKET=
COSMIC_READ_KEY=
COSMIC_WRITE_KEY=
PORT=
@althaffe
althaffe / node-on-ec2-port-80.md
Created December 1, 2017 17:43 — forked from kentbrew/node-on-ec2-port-80.md
How I Got Node.js Talking on EC2's Port 80

The Problem

Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)

The temptingly easy but ultimately wrong solution:

Alter the port the script talks to from 8000 to 80:

}).listen(80);
//atom settings

Learn JavaScript concepts with the Chrome DevTools

Authored by Peter Rybin , Chrome DevTools team

In this short guide we'll review some new Chrome DevTools features for "function scope" and "internal properties" by exploring some base JavaScript language concepts.

Closures

Let's start with closures – one of the most famous things in JS. A closure is a function, that uses variables from outside. See an example:

@althaffe
althaffe / rails_resources.md
Created February 24, 2014 08:18 — forked from jookyboi/rails_resources.md
Rails-related Gems and guides to accelerate your web project.

Gems

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second.
  • [factory_girl](h