Skip to content

Instantly share code, notes, and snippets.

Muhammad Althaf althaffe

Block or report user

Report or block althaffe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@althaffe
althaffe / index.js
Created Feb 18, 2018
Cosmic JS add to bucket
View index.js
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 Feb 18, 2018
Configuration for vue-stripe-checkout element.
View gist:f9acd57f4cdc8e4a4d48f5eb910c188b
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}}'
View .env
COSMIC_BUCKET=
COSMIC_READ_KEY=
COSMIC_WRITE_KEY=
PORT=
STRIPE_SECRET_KEY=
STRIPE_PUBLIC_KEY=
View server.js
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)
View .env
COSMIC_BUCKET=
COSMIC_READ_KEY=
COSMIC_WRITE_KEY=
PORT=
@althaffe
althaffe / node-on-ec2-port-80.md
Created Dec 1, 2017 — forked from kentbrew/node-on-ec2-port-80.md
How I Got Node.js Talking on EC2's Port 80
View node-on-ec2-port-80.md

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);
View gist:abd84f2509c60052154a

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:

View essential-javascript-links.md
@althaffe
althaffe / rails_resources.md
Created Feb 24, 2014 — forked from jookyboi/rails_resources.md
Rails-related Gems and guides to accelerate your web project.
View rails_resources.md

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
You can’t perform that action at this time.