Skip to content

Instantly share code, notes, and snippets.

View mou55's full-sized avatar

Moussa IDARDAR mou55

View GitHub Profile
@mou55
mou55 / s3_test.py
Created May 25, 2016 18:29 — forked from tomviner/s3_test.py
Simple example of an S3 django storage backend saving a file from local and url
import os
import urllib2
import contextlib
import StringIO
from django.core.files.storage import get_storage_class, FileSystemStorage
from django.core.files import File
from django.conf import settings
from galleries.models import GalleryImage
@mou55
mou55 / gist:82ab00e677b4f969b542248383842639
Created April 13, 2016 00:07 — forked from 0xKD/gist:4745862
Block a MAC address on the D-Link DSL-2750U
# Block a specific MAC address on the D-Link DSL-2750U (using parental control).
# May also work for other/similar D-Link routers (eg; 27xx)
import urllib,urllib2
import random,json,re
import base64
# Modify as necessary
login = base64.b64encode('admin:password') # username:password
mac = '00:00:00:00:00:00' # MAC address to block in the form xx:xx:xx:xx:xx:xx
[Desktop Entry]
Name=Blender_terminal
Comment=Blender_terminal
Exec=gnome-terminal -x sh -c "cd /home/user/Software/blender_270a &&./blender"
Icon=/home/user/Software/blender_270a/icons/48x48/apps/blender.png
Terminal=false
Type=Application
X-Ayatana-Desktop-Shortcuts=Blender1;Blender2;
[Blender1 Shortcut Group]
@mou55
mou55 / writecache.py
Created March 22, 2016 01:46 — forked from tobiasmcnulty/writecache.py
Simple write-through cache for Django querysets
def get_cache_key(model, pk):
"""
Generates a cache key based on ``WRITE_CACHE_PREFIX``, the cache key prefix
defined in the settings file (if any), the Django app and model name, and
the primary key of the object.
"""
params = {
'prefix': getattr(settings, 'WRITE_CACHE_PREFIX', ''),
'app': model._meta.app_label,
'model': model._meta.object_name,
class QuerySetDoubleIteration(Exception):
"A QuerySet was iterated over twice, you probably want to list() it."
pass
# "Skinny" here means we use iterator by default, rather than
# ballooning in memory.
class SkinnyManager(Manager):
def get_query_set(self):
return SkinnyQuerySet(self.model, using=self._db)
@mou55
mou55 / remove-docker-containers.md
Created March 18, 2016 01:40 — forked from ngpestelos/remove-docker-containers.md
How to remove unused Docker containers and images
  1. Delete all containers

     $ docker ps -q -a | xargs docker rm
    

-q prints only the container IDs -a prints all containers

Notice that it uses xargs to issue a remove container command for each container ID

  1. Delete all untagged images
@mou55
mou55 / update-gits.sh
Created March 5, 2016 01:38 — forked from robolson/update-gits.sh
Shell script to check multiple git repositories for updates.
#!/bin/bash
repos=(
"/Users/rob/Library/Application Support/TextMate/Bundles/Git.tmbundle"
"/Users/rob/Library/Application Support/TextMate/Bundles/Ruby.tmbundle"
"/Users/rob/Library/Application Support/TextMate/Bundles/RubyAMP.tmbundle"
"/Users/rob/Library/Application Support/TextMate/Bundles/Ruby Haml.tmbundle"
"/Users/rob/Library/Application Support/TextMate/Bundles/Ruby on Rails.tmbundle"
"/Users/rob/Library/Application Support/TextMate/Bundles/ruby-sass.tmbundle"
"/Users/rob/Library/Application Support/TextMate/Bundles/ruby-shoulda.tmbundle"
@mou55
mou55 / .gitconfig
Created February 8, 2016 23:15 — forked from rab/.gitconfig
A good starting point for ~/.gitconfig
# -*- Conf -*-
[color]
branch = auto
diff = auto
status = auto
showbranch = auto
ui = true
# color.branch
# A boolean to enable/disable color in the output of git-branch(1). May be set to always, false (or
@mou55
mou55 / Git Configs
Created February 8, 2016 23:11 — forked from tacsio/Git Configs
My git config
git config --global user.name "Tarcisio Coutinho"
git config --global user.email "tcs5cin@gmail.com"
git config --global color.ui true
git config --global alias.s status
git config --global alias.c checkout
git config --global alias.b branch
git config --global alias.lol log --oneline --graph --decorate