Skip to content

Instantly share code, notes, and snippets.

View azhtom's full-sized avatar
🏠
Working from home

Dani Soria azhtom

🏠
Working from home
View GitHub Profile
@azhtom
azhtom / Linux Tips
Created November 10, 2013 23:52
Tips para linux, la lista se actualiza en cada momento.
# Limpiar el path
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
@azhtom
azhtom / ImageField Size Validation
Created January 4, 2014 21:21
ImageField Size Validation
class Meta:
model = NameModel
def clean_image(self):
image = self.cleaned_data.get['image']
if image:
from django.core.files.images import get_image_dimensions
w, h = get_image_dimensions(image)
if not image.content_type in settings.VALID_IMAGE_FORMATS:
raise forms.ValidationError(u'Only *.gif, *.jpg and *.png images are allowed.')
@azhtom
azhtom / gist:8588647
Last active January 4, 2016 07:29
Git Pretty Log
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
# git lg:
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@azhtom
azhtom / gist:8830915
Created February 5, 2014 19:12
[LINUX] Find PID
ps -ef | awk '/[k]eyword/{print $2}'
@azhtom
azhtom / newuser
Created February 11, 2014 16:45
Create a new user admin in ActiveAdmin
AdminUser.create!(:email => '[email protected]', :password => 'password', :password_confirmation => 'password')
@azhtom
azhtom / timeout
Created March 5, 2014 15:57
TimeOut in Android
new android.os.Handler().postDelayed(
new Runnable() {
public void run() {
Log.i("tag", "This'll run 300 milliseconds later");
}
}, 300);
@azhtom
azhtom / merge
Created May 12, 2014 17:25
Merge Two objetcs c#
public void CopyValues<T>(T target, T source)
{
Type t = typeof(T);
var properties = t.GetProperties().Where(prop => prop.CanRead && prop.CanWrite);
foreach (var prop in properties)
{
var value = prop.GetValue(source, null);
if (value != null)
mysql -uroot -p --default-character-set=utf8 database < dump.sql
@azhtom
azhtom / hexlist
Created September 14, 2014 16:40
Hex Opacity Values
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
60% — 99
55% — 8C
@azhtom
azhtom / gist:6afc4448887d379f2764
Created November 25, 2014 21:28
Sublime Text command line SUBL
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl