Skip to content

Instantly share code, notes, and snippets.

@Rigel772
Rigel772 / snipet.css
Last active April 8, 2020 20:09
[Retina images] old snippet for displaying images on retina screens #css
@mixin image-2x($image, $width, $height) {
@media (min--moz-device-pixel-ratio: 1.3),
(-o-min-device-pixel-ratio: 2.6/2),
(-webkit-min-device-pixel-ratio: 1.3),
(min-device-pixel-ratio: 1.3),
(min-resolution: 1.3dppx) {
background-image: url($image);
background-size: $width $height;
}
}
# Views
def two_form_view(request):
context = {}
if request.method == "POST":
question_form = QuestionForm(request.POST)
answer_form = AnswerForm(request.POST)
success = False
if 'q_button' in request.POST and question_form.is_valid()
question_form.save()
@Rigel772
Rigel772 / blog_model.py
Last active April 8, 2020 09:41 — forked from x86ed/blag_model.py
Django blog model #django
import urllib2
import mimetypes
from django.conf import settings
from django.db import models
from django.contrib.auth.models import User
class Category(models.Model):
name = models.CharField(max_length=32)
class Meta:
@Rigel772
Rigel772 / BuildPython36.sh
Created July 24, 2018 15:04 — forked from Wombatpm/BuildPython36.sh
Building and installing Python 3.6 for Ubuntu 16.04 LTS as part of Vagrant Provisioning
#!/usr/bin/env bash
# Script to Build Python 3.6.3 for Ubuntu 16.04
#
# Ubuntu 16.04 is and LTS release with Python for System use locked at 3.5
# This script builds Python3.6 from source and installs it in /usr/local
#
# Called from my VagrnantFile as
# config.vm.provision :shell, inline: "bash /var/www/myproj/VagrantScripts/BuildPython36.sh"
#
# Inspired by the wonderful instructions at
@Rigel772
Rigel772 / gulpfile.js
Created April 15, 2017 09:09 — forked from mlouro/gulpfile.js
gulpfile.js with browserify, jshint, libsass, browserSync for livereload, image optimization and system notifications on errors
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var del = require('del');
var uglify = require('gulp-uglify');
var gulpif = require('gulp-if');
var exec = require('child_process').exec;
var notify = require('gulp-notify');
Standard Python dictionaries are unordered. Even if you sorted the (key,value) pairs, you wouldn't be able to store them in a dict in a way that would preserve the ordering.
The easiest way is to use OrderedDict, which remembers the order in which the elements have been inserted:
In [1]: import collections
In [2]: d = {2:3, 1:89, 4:5, 3:0}
In [3]: od = collections.OrderedDict(sorted(d.items()))
@Rigel772
Rigel772 / Django Haystack Solr Setup
Created March 18, 2017 14:15 — forked from stvbdn/Django Haystack Solr Setup
Django + Haystack + Solr Installation/Setup
### Solr Install ###
Install pysolr and django-haystack and set up django-haystack. Setup for haystack is pretty straight forward:
https://django-haystack.readthedocs.org/en/v1.2.7/tutorial.html
Make sure you follow the haystack instructions for the correct version of haystack that you installed,
as some of the setting variables are different depending on the version.
# SSH into the server that you want to install Solr on
@Rigel772
Rigel772 / bash-cheatsheet.sh
Last active October 10, 2016 05:07 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage: hello bash :)
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@Rigel772
Rigel772 / 0_reuse_code.js
Created October 8, 2016 09:40
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console