Skip to content

Instantly share code, notes, and snippets.

View russell310's full-sized avatar

Hamim Al Mahdi Russell russell310

View GitHub Profile
@russell310
russell310 / delete_migrations.py
Created April 20, 2020 14:35
Sometime needs to delete all migration file in django here is how you will reset migrations file
import os
import glob
dot_py = glob.glob('*/migrations/*.py', recursive=True)
for filePath in dot_py:
if not os.path.basename(filePath) == '__init__.py':
try:
os.remove(filePath)
except OSError:
print("Error while deleting file")
@russell310
russell310 / sms_spliter.py
Created November 11, 2019 11:46
Spliting long message into carrier recommended length
def sms_spliter(msg_text):
sms_lst=[]
if len(msg_text) <= 160:
sms_lst.append(msg_text)
return sms_lst
else:
l_m_text = (msg_text.split())
if len(max(l_m_text, key=len))> 160:
return sms_lst
@russell310
russell310 / unicode_slugify.py
Created November 11, 2019 11:35
Bangla slugify for python project
import re
def u_slugify(txt):
"""A custom version of slugify that retains non-ascii characters. The purpose of this
function in the application is to make URLs more readable in a browser, so there are
some added heuristics to retain as much of the title meaning as possible while
excluding characters that are troublesome to read in URLs. For example, question marks
will be seen in the browser URL as %3F and are thereful unreadable. Although non-ascii
characters will also be hex-encoded in the raw URL, most browsers will display them
as human-readable glyphs in the address bar -- those should be kept in the slug."""
txt = txt.strip() # remove trailing whitespace
@russell310
russell310 / money_format.py
Created September 17, 2019 06:41
Bangladeshi money format system in python
def int_to_word(num):
d = {0: 'zero', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five',
6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten',
11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen',
15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen',
19: 'nineteen', 20: 'twenty',
30: 'thirty', 40: 'forty', 50: 'fifty', 60: 'sixty',
70: 'seventy', 80: 'eighty', 90: 'ninety'}
k = 1000
l = k * 100
@russell310
russell310 / facebook group pending post remove
Last active January 20, 2019 19:50
Removing facebook post
/*! jQuery v1.11.3 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.3",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},sl