Skip to content

Instantly share code, notes, and snippets.

Avatar

Adrien adrienlachaize

View GitHub Profile
View Custom Sendbird widget
// Sendbird widget
#sb_widget
.widget
background-color: $primary !important
&:hover
background-color: darken($primary, 10%) !important
.channel-board .board-top
background-color: $primary !important
@adrienlachaize
adrienlachaize / gist:8349814
Created Jan 10, 2014
Get system os struct.
View gist:8349814
import struct
def get_os_struct():
"""Get system os struct."""
return str(struct.calcsize('P') * 8)
@adrienlachaize
adrienlachaize / gist:8349832
Created Jan 10, 2014
Check if the given file is .txt
View gist:8349832
import mimetypes
def is_txt_file(file):
"""Test if the file is a txt file."""
mime = mimetypes.guess_type(file)
if mime[0] == 'text\plan':
return True
@adrienlachaize
adrienlachaize / sync_perms
Last active Sep 29, 2015
Refresh apps permissions
View sync_perms
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.apps import apps
from django.db.models import get_models
from django.core.management.base import BaseCommand
from django.contrib.auth.management import create_permissions
class Command(BaseCommand):
@adrienlachaize
adrienlachaize / gist:47dd796917cd6b7cd1b1
Created Nov 26, 2014
Djang slugify a string to Twitter hashtag format
View gist:47dd796917cd6b7cd1b1
import re
import unicodedata
try:
from django.utils.encoding import smart_unicode as smart_text
except ImportError:
from django.utils.encoding import smart_text
SLUG_OK = '_'
@adrienlachaize
adrienlachaize / gist:e1caa489bad8a96629c6
Created Nov 26, 2014
Wonderfull HTTP response to json format
View gist:e1caa489bad8a96629c6
import json
from django.http import HttpResponse
def json_responder(**kwargs):
"""
Return a HTTP response to json format
"""
return HttpResponse(json.dumps(kwargs), content_type="application/json")
@adrienlachaize
adrienlachaize / gist:11180962
Created Apr 22, 2014
Import settings apps of a Django project
View gist:11180962
"""
Paste the code at the end your main settings.
It will import all settings files of your django project.
It allow to divide settings per app.
"""
import os.path
for d in [d for d in os.listdir(os.path.dirname(__file__)) if os.path.isdir(os.path.join(os.path.dirname(__file__), d))]:
app = __import__(d)
You can’t perform that action at this time.