Skip to content

Instantly share code, notes, and snippets.

View mdashti's full-sized avatar

Mohammad Dashti mdashti

View GitHub Profile
package com.example.controller;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
@mdashti
mdashti / gist:2007c6663d055792e509
Last active September 22, 2022 22:49
Bash script for git pull using username and password
#!/bin/bash
path="/var/www/sites/htdocs/wp-content/themes/vip/";
git_path="https://username:password@mdashti.com/DBToaster/";
git_array=( plugins pmc-variety pmc-plugins );
git_path_array=("${git_array[@]}")
@mdashti
mdashti / git_extraction.md
Last active October 30, 2017 16:50 — forked from jamesarosen/git_extraction.md
Extracting a directory from a git project

Recently, I needed to extract a number of directories from a git project each into their own projects. The original directory structure looked like

project/
  subprojects/
    Foo/
    Bar/
    Baz
# use this command to split a file into multiple pages
gsplit -l 7100 -d lineitem.tbl lineitem.tbl.part
@mdashti
mdashti / stacktrace.cxx
Created June 10, 2021 16:59 — forked from fmela/stacktrace.cxx
A C++ function that produces a stack backtrace with demangled function & method names.
/*
* Copyright (c) 2009-2017, Farooq Mela
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
#!/bin/bash
#This script creates a mongodb sharded cluster in a single server
#This cluster can be used for testing and development task and never recommended for production environment :)
#MongoDB sharded cluster has 2 shards for test environment
#Author Pranab Sharma <pranabksharma@gmail.com>
#Create the data directories
echo "Creating data directories"
mkdir -p /data/a0
mkdir -p /data/a1
#!/usr/bin/env bash
set -e
# This script will start three shards, a config server and a mongos, all on the current machine.
#
# It was written for Mongo 3.4, based on https://docs.mongodb.com/manual/tutorial/deploy-shard-cluster/
#
# This script is only for testing purposes. In production, you would run each of these servers on a different machine.
#
# The first time you run it, pass this variable for the initial setup:
function generateRandomString(length) {
var randomString = ''
while (randomString.length < length) {
randomString += Math.random().toString(20).slice(2, length);
if (randomString.length > length) return randomString.slice(0, length);
}
return randomString;
};
function generateRandomInt(min, max) { // min and max included