Skip to content

Instantly share code, notes, and snippets.

View Dev-Dipesh's full-sized avatar

Dipesh Bhardwaj Dev-Dipesh

  • The Contentment Foundation
  • San Francisco, California
View GitHub Profile
@Dev-Dipesh
Dev-Dipesh / cb-views-automate.js
Last active June 16, 2016 09:49
Create Couchbase Views on the fly. Automate the view creation process in Couchbase.
/**
* Create Couchbase Views on the fly
* v1.0.0 June 15, 2016
* Dipesh Bhardwaj
* Code Style - ES6 Javascript | ES Lint | AirBnB Arrow Functions
* This script contains example for sample beer bucket, which comes
* pre-loaded with Couchbase.
* Create a `startupCheck.js` script in your application, if not already exist
* and call this script through it to create all your Couchbase views
* during app initialization. This script first checks if the views are already
@Dev-Dipesh
Dev-Dipesh / node-on-ec2-port-80.md
Created May 24, 2016 12:34 — 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);
@Dev-Dipesh
Dev-Dipesh / .adoc File Syntax
Created May 20, 2016 08:30
ASCII Doctor .adoc file syntax from - http://asciidoctor.org
= AsciiDoc Article Title
Firstname Lastname <author@asciidoctor.org>
1.0, July 29, 2014, Asciidoctor 1.5 article template
:toc:
:icons: font
:quick-uri: http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/
Content entered directly below the header but before the first section heading is called the preamble.
== First level heading
@Dev-Dipesh
Dev-Dipesh / ep_app.js
Created May 12, 2016 05:03 — forked from focusaurus/ep_app.js
Example of how a main express app can mount sub-applications on a mount point with app.use('/mount-point', subapp); If you GET /, you'll see the main_app's '/' response. If you GET /ep_app, you'll see the ep_app's '/' response.
var express = require("express");
var app = express();
app.get('/', function (req, res) {
res.send("This is the '/' route in ep_app");
});
module.exports = app;
```
// Adds whitespace to image at left and right in case of portrait to make it appear as landscape
// Based on FB Image Size for posts shared with app
// Make sure to unlink once done.
// Uploads Images to S3
uploadImage: function (req, res) {
'use strict';
req.files.image = req.files.Filedata || req.files.image || req.files.files[0];
var image = req.files.image;
var fb_cross = req.headers['fb_cross'] || '1';
@Dev-Dipesh
Dev-Dipesh / Javascript Base64_encode_decode.md
Created November 8, 2015 06:20
Javascript Base 64 encoding/decoding
var Base64 = {
    _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

    encode: function(input) {
        var output = "";
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
        var i = 0;

        input = Base64._utf8_encode(input);
@Dev-Dipesh
Dev-Dipesh / Beginner Docker Guide
Created March 27, 2015 08:01
A beginner guide to docker for looking up and setting docker image and container
DOCKER
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
class GitHub
class << self
def download_file_to_string(github_token, setup={}, raw=true, link=nil)
if link
url = link
else
sql_repo_name = setup['repo_name']
sql_repo_owner = setup['repo_owner']
# URI join won't make it:
@Dev-Dipesh
Dev-Dipesh / git add -p: The most powerful git feature you're not using yet
Created September 24, 2013 09:54
git add -p: The most powerful git feature you're not using yet
[git][1] and GitHub have revolutionized not only how I do development, but how we developers share code.
I have two tools I need to do software development: an editor and version control.
[The Pragmatic Programmer][2] advocates you should know your editor inside and out. So why don't you know your version control system just as well?
Hello everyone, today I am demonstrating a little new feature of GITHub that everyone must know about and that feature is **git add patch mode**.
Now I know you are familiar with `>git add` the command that takes an entire file and adds it to the staging area, allowing it to be the part of your commit.
But patch mode is a way to stage only parts of the change file instead of the entire one.
@Dev-Dipesh
Dev-Dipesh / uikit.docs.min.css
Created September 22, 2013 14:47
This is an another css file for UIKIT
article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,video{display:inline-block}audio:not([controls]){display:none;height:0}[hidden]{display:none}html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}a:focus{outline:thin dotted}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}code,kbd,pre,samp{font-family:Consolas,monospace,serif;font-size:1em}pre{white-space:pre-wrap}q{quotes:"\201C" "\201D" "\2018" "\2019"}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:0}fieldset{border:0;margin:0;padding:0}legend{border:0;padding:0}button,input,select,textarea{font-family:inherit;font-size:100%;margin:0;-moz-box-sizing:border-box;-webkit-box-sizing:border-b