Skip to content

Instantly share code, notes, and snippets.

Alexis alxscms

Block or report user

Report or block alxscms

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@alxscms
alxscms / print_model.py
Created Jan 5, 2016
Print all attributes of a django model with colors
View print_model.py
def print_model(object):
print "\033[96m<{0}>\033[0m".format(wp.__class__.__name__)
for field in object._meta.fields:
if field.value_to_string(object) != 'None' and field.value_to_string(object) != '':
print "\033[94m{0:30}\033[0m \033[93m{1}\033[0m".format(field.name, field.value_to_string(object))
else:
print "{0:30} {1}".format(field.name, field.value_to_string(object))
View isVisible.js
// true if display none or visibility hidden
function isVisible(el) {
var style = window.getComputedStyle(el);
return (style.display !== 'none')
}
// return true if element is in the window bounds or false if outside
function isInWindow(el) {
var viewportOffset = el.getBoundingClientRect();
// these are relative to the viewport
@alxscms
alxscms / .bash_profile
Last active Aug 29, 2015
Bash script for gitignore.io with autocompletion, to paste in .bash_profile
View .bash_profile
# gitignore function working with gitignore.io
function gitignore() {
local IFS=",";
if [[ "$#" -eq 0 ]]; then
echo "gitignore: try 'gitignore --help' for more information"
elif [[ "$1" == "--help" || "$1" == "-h" ]]; then
echo "Usage: gitignore [options] <arguments separated by spaces>"
echo " -h, --help: show help"
echo " -l, --list: list all possible arguments"
echo " -s, --save: save the output to a .gitignore file"
@alxscms
alxscms / BlurPicassoTransformation.java
Created Feb 9, 2015
Picasso transformation that crops center the image to the specified dimensions and blurs it
View BlurPicassoTransformation.java
public class BlurPicassoTransformation implements Transformation {
private Context mContext;
private int mWidth;
private int mHeight;
public BlurPicassoTransformation(Context context, int width, int height) {
mContext = context;
mWidth = width;
mHeight = height;
@alxscms
alxscms / AutoResizeTextView.java
Created Feb 9, 2015
TextView that gets its text size refined to fit the available space
View AutoResizeTextView.java
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.RectF;
import android.os.Build;
import android.text.Layout.Alignment;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.SparseIntArray;
@alxscms
alxscms / StrokeOverlayImageView.java
Last active Aug 29, 2015
An image view with an inner stroke overlaying the actual image
View StrokeOverlayImageView.java
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.ImageView;
public class StrokeOverlayImageView extends ImageView {
private final int DEFAULT_BORDER_COLOR = 0x26000000;
@alxscms
alxscms / AbstractView.java
Created Feb 8, 2015
An abstract view simplifying the creation of Android widgets by scaling the canvas to the right size (following the device density), translating it following the set padding and by taking into account the view padding in the measurements
View AbstractView.java
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;
public abstract class AbstractView extends View {
private float mOffsetX;
private float mOffsetY;
@alxscms
alxscms / CollapseAnimation.java
Created Feb 8, 2015
Android expand & collapse animation
View CollapseAnimation.java
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;
public class CollapseAnimation extends Animation implements Animation.AnimationListener {
private View mView;
private int mInitialHeight;
private boolean mAnimating;
@alxscms
alxscms / CircleTransform.java
Last active Aug 29, 2015 — forked from julianshen/CircleTransform.java
Circle transformation for Picasso library, working with GIF files
View CircleTransform.java
/*
* Copyright 2014 Julian Shen
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
You can’t perform that action at this time.