Skip to content

Instantly share code, notes, and snippets.

View itsmunim's full-sized avatar
💂‍♂️
Extension over Modification...please!

Md Abdul Munim itsmunim

💂‍♂️
Extension over Modification...please!
View GitHub Profile
#!/bin/bash -x
echo Usage: Path of the Directory to be recursively traversed Current Format To Format
#convertion process
sass-convert -R "$1" -F "$2" -T "$3"
#deleting existing files
extention="*.$2"
find "$1" -name $extention -type f -delete
@itsmunim
itsmunim / rename_dirs.sh
Last active August 29, 2015 14:26
Rename all the folders inside current folder(where this shell script will reside) with a specified suffix.
for FILENAME in *
do
a="$FILENAME"
if [[ $a != *"$1"* && -d "$a" ]]
then
mv "$a" "$a$1"
else
"Not renaming $a"
fi
done
@itsmunim
itsmunim / AutoAdjustHeight.js
Created August 28, 2015 09:02
Adjusts the height of a list based on top elements and bottom elements in any display.
'use strict';
angular.module('MunimDibosh.directives')
.directive('adjustListHeight', function ($timeout) {
return {
restrict: 'A',
link: function (scope, element) {
var parent, elemList, parentHeight, elemIndexOnDom;
// Watch for height changes
var _watchForHeightChange = function (elemList) {
- name: set up virtualenv
  shell: chdir={{ DIRECTORY }} if [ ! -d env ]; then virtualenv env; fi
- name: set up python requirements
  command: chdir={{ DIRECTORY }} env/bin/pip install -r requirements.txt
  • Start rabbit mq server: rabbitmq-server
  • Access the web admin at localhost:15672/ and login using u= guest/p= guest
  • Go to exchanges and click on add a new exchange- Give it a name(e.g. download-event), select fanout as type and durabilty to durable
  • Go to queues and click on add a new queue- Give a name(e.g. download-image-event) and durability as durable
  • Publish event message: {"taskId":"569b34d1f79eae72524b4e96","title":"Quick image posts from my_images on 17 January 2016 at 12:29 PM (DHK - GMT+6)","channel":"facebook","createdAt":"2016-01-17T06:30:25.524Z","publishDate":"2016-01-17T06:32:18.167Z","articleGuids":[],"imageGuids":["4d4011c6799da7562111787e4e5fed97"],"organization":"53b8ccedab75641ba57e87c4","ssoId":"53b8cbf01f1582af1a00000f"}
  • Download event message: {imageGuid: <GUID of image in ThePlatform>, organizationId: <PK of CMC organization>, organizationName: <Name of organization to show in the dashboard>, downloadedAt: <ISO date of download from CMC>}
  • Once you pub

Some cool commands that will save your ass in need

Remove sensitive file from your git history

Usecase- There's a SSH file included in your repo; but you want to remove it. Removing it from current commit won't delete from all the history. This command will save your life.

git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA' \
# def ngrams(tokens, n):
# num_tokens = len(tokens)
# if n > num_tokens:
# return
# ngram_list = []
# for i in xrange(num_tokens):
# token_groups = []
# for j in xrange(i, i+n):
# if j < num_tokens:
# token_groups.append(tokens[j])
var sceneObj = (function() {
"use strict";
Physijs.scripts.worker = "scripts/physijs_worker.js";
Physijs.scripts.ammo = "ammo.js";
var scene, camera, renderer
var physijsBox, physijsGround, spawnBox;
var render, _boxes = [],
@itsmunim
itsmunim / storage.service.js
Created November 29, 2016 19:35
A simple angular service wrapper for $localStorage to make things more understandable and manageable.
(function () {
'use strict';
angular.module('storage.service', []);
angular.module('storage.service')
.factory('localStorageService', localStorageService);
function localStorageService($localStorage) {
function retrieve(key) {
return $localStorage.hasOwnProperty(key) ? $localStorage[key] : {};
@itsmunim
itsmunim / views.py
Last active December 2, 2016 09:50
A simple paginated DJango view implementation
def chunks(data, n):
"""Yield successive n-sized chunks from data."""
for i in range(0, len(data), n):
yield data[i:i + n]
def get_page_number_from_request(request):
"""The `page` param will be from 1, 2, 3 ....so on, so we will have to translate it to
an index that makes sense for an array"""
page_no = request.GET.get('page') - 1
return page_no if page_no > 0 else 0