Skip to content

Instantly share code, notes, and snippets.

View thebapi's full-sized avatar

Sajib Sarkar thebapi

View GitHub Profile
db.customers.aggregate([
{
$lookup: {
from: "events", // field in the items collection
as: "events",
let: { cus_id: "$_id"},
pipeline: [
{ $match:
{ $expr:
{ $and:
#!/bin/sh
echo "Flushing iptables rules..."
sleep 1
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
nano ~/.bash_profile
# insert these
export GOPATH=$HOME/go
export PATH=$PATH:$HOME/go/bin
# Finish and. save file
source ~/.bash_profile
Start the registry as a service on your swarm:
$ docker service create --name registry --publish published=5000,target=5000 registry:2
Check its status with docker service ls:
$ docker service ls
ID NAME REPLICAS IMAGE COMMAND
l7791tpuwkco registry 1/1 registry:2@sha256:1152291c7f93a4ea2ddc95e46d142c31e743b6dd70e194af9e6ebe530f782c17
@thebapi
thebapi / gist:992c949fac286cb1ed1cfebd2db264ed
Last active October 1, 2018 18:38
remove all docker images and containers
#!/bin/bash
# Stop all containers at once
docker kill $(docker ps -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
docker network prune
docker system prune -a
var fieldSchema = new Schema({
sectionId: { type: ObjectId, ref: 'Section',required: false },
type : { type: String, required: true, trim: true, default: 'table'},
name : { type: String, required: true, trim: true, uniq: true},
label : { type: String, required: true, trim: true},
format : { type: 'String'},
decimal : { type: 'Number'},
list : [{ name : { type: String }}],
formula : { type: 'Mixed'}//optional is the field is calculated
@thebapi
thebapi / gist:c1f8f910ab1543576f07bb823a2975eb
Created July 21, 2018 18:25
script to delete all custom fields and values from the DB except, fields with group: name":"Desktop Comments"}, "name":"Surveillance Comments"},
var customFields = db.customfields.find({}).toArray();
var groupIds = [];
customFields = customFields.map(customField => {
customField.collections = customField.collections.map(item => {
item.fieldGroups = item.fieldGroups.filter(groupItem => /Desktop Comments/i.test(groupItem.name) || /Surveillance Comments/i.test(groupItem.name));
item.fieldGroups.forEach(group => groupIds.push(group._id));
return item;
});
return customField;
});
var myScope = angular.element($('cfe-profile-header')).scope().$parent;
myScope.isProfilePrivate = false;
myScope.settings.enableServiceProfiles = true;
@thebapi
thebapi / gist:484078efc7b35f71f1b3d1266ac3c0d0
Created October 25, 2017 09:51
Check if the string is like Mongo ObjectId type??
/^[0-9a-fA-F]{24}$
<div style="padding: 0px" class="row expanded-portfolio-container">
<reorderable-container-component storage-key="vm.reorderableStorageKey"
on-reorder="vm.onReorderCallback(data)"
reorderable-components="vm.portfolioComponents"
class="portfolio-container reorderable-component-container border-top row">
<div style="background-color: #3E3E3E;" ng-if="component.type !== 'custom-group'" static-include="'templates/investments/portfolio/expanded-portfolio/{{component.file}}'"></div>
<div ng-if="component.type === 'custom-group'">
<custom-value-list collection-name="component.data.collectionName" collection-id="component.data.collectionId" group_id="component.data.groupId"></custom-value-list>
</div>
</reorderable-container-component>