Skip to content

Instantly share code, notes, and snippets.

View asveloper's full-sized avatar

Arslan Nasir asveloper

View GitHub Profile
@asveloper
asveloper / mongodb-s3-backup.sh
Created February 2, 2018 16:07 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
@asveloper
asveloper / README.md
Last active December 4, 2017 18:10 — forked from SeriousM/.md
Logout all users from meteor application

1 - Get an Ubuntu machine up and running (make sure ports 11011 and 4000 are open)

2 - Install docker + docker-compose (full_install_docker_compose.sh)

3 - Get a docker-compose.yml with mongodb, kadira-ui, kadira-engine and kadira-rma (docker-compose.yml)

3 - Run "sudo docker-compose up" (-d if you want it running on background)

4 - Access http://machineIp:4000 and login as "admin@gmail.com" and "admin" password

5 - Create your APP, get the ID and Secret

6 - Setup kadira in your app by code or settings.json (Config)

7 - Update your app from "free" plan to "paid" to get full access at Kadira ([Update App Plan](https://gist.github.com/6uimorais/1e1de20bbbb2a04fe19fc73f88d6a25f#file-changepl

@asveloper
asveloper / business.rb
Created February 27, 2017 11:42
Business model from Rails app
# == Schema Information
#
# Table name: businesses
#
# id :integer not null, primary key
# name :string(255) not null
# phone :string(255)
# category :string(255) not null
# address :text not null
# city :string(255) not null
@asveloper
asveloper / businesses_controller.rb
Created February 27, 2017 11:41
Controller from Rails App
class BusinessesController < ApplicationController
before_action :check_due_payment, except: [:list]
before_action :set_business, only: [:show, :profile, :edit, :update, :destroy]
before_action :authenticate_user!, except: [:show, :profile, :list]
# GET /businesses
# GET /businesses.json
def index
@businesses = current_user.businesses
authorize @businesses
@asveloper
asveloper / UserProfileContainer.jsx
Created January 25, 2017 21:40
User Profile Container sample Meteor Code
import { Meteor } from 'meteor/meteor';
import { createContainer } from 'meteor/react-meteor-data';
import { Roles } from 'meteor/alanning:roles';
import { Counts } from 'meteor/tmeasday:publish-counts';
import { Ratings } from '../../api/ratings/ratings.js';
import { Favorites } from '../../api/favorites/favorites.js';
import { Subscriptions } from '../../api/subscriptions/subscriptions.js';
import { SubscriptionTypes } from '../../api/subscriptions/enums/types.js';
import { UserRoles } from '../../startup/both/business.js';
@asveloper
asveloper / notifications.jsx
Created January 18, 2017 07:37
React class from app using Meteor + Material-UI
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { FlowRouter } from 'meteor/kadira:flow-router';
import React, { Component } from 'react';
import { NotificationManager } from 'react-notifications';
import autoBind from 'react-autobind';
import {
Paper,
Checkbox,
RaisedButton,
@asveloper
asveloper / fb_bot.js
Created January 18, 2017 07:29
Code Sample for handling messages for Messenger in Node.js
jobs.handleMessaging = function (messaging) {
// only process incoming messages
if (messaging.message || messaging.postback || messaging.optin) {
const senderId = messaging.sender.id;
return User
.findOne({ fbId: senderId })
.then((user) => {
if (!user) {
@asveloper
asveloper / botkit_mongo_storage.js
Created September 8, 2016 20:25
MongoDB storage driver for Howdy Botkit
var db = require('monk');
/*
** MongoDB Driver for Botkit
*/
module.exports = function(config) {
if (!config || !config.mongoUri)
throw new Error('Need to provide mongo url.');
var Teams = db(config.mongoUri).get('teams'),
-module(asveloper_greeting_controller,[Req]).
-compile(export_all).
-title("Asveloper").
hello('GET',[])->
%%{json,[{greeting,"Hello Asveloper.... My First Web App in Erlang!"},{name,"Arslan Nasir"}]}.
{ok,[{greeting,"Hello Asveloper.... My First Web App in Erlang!"},{name,"Arslan Nasir"}]}.