Skip to content

Instantly share code, notes, and snippets.

View azat-co's full-sized avatar
🎯
Focusing

Professor Azat Mardan azat-co

🎯
Focusing
View GitHub Profile
const port = process.env.PORT || 3000
require('http')
.createServer((req, res) => {
console.log('url:', req.url)
res.end('hello world')
})
.listen(port, (error)=>{
console.log(`server is running on ${port}`)
})
@azat-co
azat-co / hello-world-server.js
Created April 6, 2017 16:59
Hello World Node HTTP server for AWS User Data
const port = 3000
require('http')
.createServer((req, res) => {
console.log('url:', req.url)
res.end('hello world')
})
.listen(port, (error)=>{
console.log(`server is running on ${port}`)
})
const assert = require('assert')
const solution = (str) => {
const checkSubs = (s, oldResults=[]) => {
let start = s.indexOf('{')
let end = s.indexOf('}', start+1)
// console.log('yo', s, start, end,s.substring(end+1, s.length))
if (start<0 && end <0) {
for (let i = 0; i<oldResults.length; i++) {
oldResults[i] += s
@azat-co
azat-co / server.js
Last active January 28, 2017 03:26
const http = require('http')
http.createServer((req, res)=>{res.end(`Happy Monday America!
Your Node environment is ${process.env.NODE_ENV}
`)}).listen(80)
sudo curl --silent --location https://rpm.nodesource.com/setup_6.x | sudo bash -
sudo yum -y install nodejs
@azat-co
azat-co / derby-app.html
Created May 7, 2013 04:48
Node.js MVC: Express.js and Derby Hello World Tutorial
<Body:>
<input value="{message}"><h1>{message}</h1>
@azat-co
azat-co / asana-hello-world.js
Created November 18, 2014 02:07
Asana Hello World Node API Example
var request = require('request')
var apiKey = process.env.API_KEY
var workspaceId = process.env.WORKSPACE
var assigneeEmail = process.env.ASSIGNEE
var url ='https://app.asana.com/api/1.0/tasks'
// set up the request
var headers = {
'Authorization': 'Basic '+ new Buffer(apiKey).toString('base64')
@azat-co
azat-co / leanpub-tool.js
Created May 29, 2013 23:38
LeanPub Tool — Node.js script for sanitizing and compiling a book's manuscript. LeanPub uses multi-file book format and a special markdown markup (that confuses Marked app). I found that to convert to MS Word (for editing and other needs) this workflow is the best: 1. run leanpub-tool.js with node.js (node leanpub-tool.js) 2. open file in Marked…
var fs = require('fs');
//change these to YOUR filenames
//probably we can read it from Book.txt but I was too lazy to implement it :-) and somebody might want to compile only sertain parts of the book
var book =[
"frontmatter.txt",
"mainmatter.txt",
"part1.txt",
"chapter1.txt",
"part2.txt",
"chapter2.txt",
@azat-co
azat-co / StorifyAPI_GET_stories
Created April 17, 2013 21:37
Example response to a **GET** `v1/stories/storifydev/node-js-news` request.
{ content:
{ sid: '516f1018384ca80000000011',
title: 'node.js news',
slug: 'node-js-news',
status: 'working',
version: 1,
permalink: 'http://storify.com/storify/node-js-news',
description: null,
thumbnail: 'http://storify.com/public/img/default-thumb.gif',
date:
var async = require('async');
var ProgressBar = require('progress');
var monk = require('monk');
var ObjectId=require('mongodb').ObjectID;
var dest = monk('localhost:27017/storify_localhost');
var backup = monk('localhost:27017/storify_backup');
var userId = ObjectId(YOUR-OBJECT-ID); // monk should have auto casting but we need it for queries