Skip to content

Instantly share code, notes, and snippets.

View atiq1589's full-sized avatar

Md. Atiqul Islam atiq1589

View GitHub Profile
@atiq1589
atiq1589 / app.js
Last active August 30, 2015 19:36 — forked from bmatusiak/app.js
express/mongodb socket.io/redis AIO
/**
* Session Storage for multi servers ex.Heroku stacks
* for expressjs socket.io with databases redis and mongodb
* (redis/socket.io)
* (mongodb/expressjs)
*
* Bradley Matusiak @ 2012 bmatusiak@gmail.com
*
* ref:bunch of searches from google
**/
* Reducing executable size:
http://developer.xamarin.com/guides/cross-platform/deployment,_testing,_and_metrics/memory_perf_best_practices/#Reducing_Executable_Size
* Use the linker (iOS [1], Android [2]) to remove unnecessary code from your assemblies
[1] https://developer.xamarin.com/guides/ios/advanced_topics/linker
[2] https://developer.xamarin.com/guides/android/advanced_topics/linking
* Reference third-party libraries judiciously
* Applying constraints to generics may reduce app size, since less code would need to be included (haven’t verified this)
@atiq1589
atiq1589 / gist:3e6469c1a1534b2d3c64eca3ef7f6d05
Created April 5, 2017 07:38 — forked from eparreno/gist:1845561
Install libmagic on Mac OS X via homebrew
$ brew install libmagic
$ brew link libmagic (if the link is already created is going to fail, don't worry about that)
$ env ARCHFLAGS="-arch x86_64" gem install ruby-filemagic -- --with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/
@atiq1589
atiq1589 / custom_command.sh
Created May 8, 2017 03:43
Custom command for Unix
#!/bin/bash
#Create python module command
create_py_module() {
mkdir $1;
touch $1/__init__.py
}
@atiq1589
atiq1589 / 0_reuse_code.js
Created July 22, 2017 08:32
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@atiq1589
atiq1589 / Trie Tree
Created October 31, 2017 00:53
Algorithms (Python)
class Node(object):
def __init__(self, data, next_node=None):
self.data = data
self.next_node = dict()
self._freq = 1
def add(self, data):
if data in self.next_node:
self.next_node[data]._freq += 1
else:
sudo rm /var/lib/apt/lists/lock
@atiq1589
atiq1589 / random_uuid
Created November 26, 2017 09:31
JavaScript supporting function
function _uuid() {
function _() {
var rand = Math.ceil(1e15 + Math.random() * 1e5).toString(16);
return rand.substring(rand.length - 4);
}
return _() + _() + '-' + _() + '-' + _() + '-' + _() + '-' + _() + _();
}
@atiq1589
atiq1589 / class_factory.py
Created January 17, 2018 11:26
Django Dynamic Model
from .db_connections import Database
from django.contrib.gis.db import models
class ClassFactory(object):
DJANGO_MODEL = {
'bigint': models.BigIntegerField,
'character varying': models.CharField,
'integer': models.IntegerField,
'boolean': models.BooleanField,
@atiq1589
atiq1589 / format_data.py
Last active January 21, 2018 15:56
Django Group By Date
def format_data(query=None, model_instance=None, filters=None, exclude=None, order_by=None, extra_field=None):
if model_instance:
query = model_instance.objects.all()
if filters:
query = query.filter(**filters)
if exclude:
query = query.exclude(**exclude)
if order_by:
query = query.order_by(*tuple(order_by))