Skip to content

Instantly share code, notes, and snippets.

// this is the function being called whenever a page gets loaded, including when you scroll to get the next page
// you need to configure your view in magicollections.py to specify that you want this function to be called
// this function is in main.py, but for some pages that are not loaded often (staff pages, settings) or are
// big enough you can have a file just for this page like `settings.js` (for what you're trying to do main.js is enough)
function loadCardInList() {
...
// Show/hide include_cameos when member_id is set
// $(xxx) is a way to retrieve an HTML element currently on the page
// "#sidebar-wrapper #id_member_id" is the selector to find the elements. it's very similar to CSS selectors.
# Original calendar thingy
@property
def availability_calendar(self):
calendar = [['', 'M', 'T', 'W', 'T', 'F', 'S', 'S']] + [
[self._I_TO_AVAILABILITY[i] if j == 0 else 'no' for j in range(8)]
for i in range(len(self.AVAILABILITY_CHOICES))
]
for a, v in self.availability.items():
if v:
@db0company
db0company / MagiCirclesExamples.py
Last active May 27, 2017 09:23
Examples to illustrate the MagiCircles Documentation
def filterCards(queryset, parameters, request):
if 'promo_only' in parameters:
queryset = queryset.filter(is_promo=True) if 'promo_only'
return queryset
############################################################
def FilterCardsForm(MagiFilter):
class Meta:
model = models.Card
@db0company
db0company / ranking.sh
Created May 18, 2017 02:49
Takes a file with one vote per line, returns a ranking
cat votes.txt | sort | uniq -c | sort -r
1. Introduction and Background
1.1 Statement of Problem Area
1.2 Previous and Current Work, Methods and Procedures
1.3 Background
1.4 Brief Project Description
1.5 Purpose/Objectives/justification of Project
1.6 Team work assignment and accomplished
2. System Functional Specification
2.1 Functions Performed
2.2 User Interface Design
(add-to-list 'load-path "~/.emacs.d/installed/")
(when (fboundp 'electric-indent-mode) (electric-indent-mode -1))
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
@db0company
db0company / twitter-images-rename.sh
Created February 3, 2017 04:45
When you save images from Twitter desktop, they get saved as .png-large or .jpg-large. This script removes the -large so the files are recognized as images.
for img in `ls *-large`; do newimg=`echo $img | rev | cut -d'-' -f2- | rev`; echo $newimg; mv $img $newimg; done
@db0company
db0company / skills_sentences.md
Created October 5, 2016 15:58
Skills sentences

Perfect Lock

notes

For every N notes, there is a N% chance of turning all goods and greats in the next N seconds into perfects. (Level 1)

seconds

Every N seconds, there is a N% chance of turning all goods and greats in the next N seconds into perfects. (Level 1)

@db0company
db0company / generate_magicircles_translations.py
Created September 29, 2016 20:19
Generate a file that combines all the MagiCircles project in one file to import in POEditor
#!/bin/bash
cd ~/Documents/python/MagiCircles/ &&\
source env/bin/activate &&\
rm -f web/locale/ja/LC_MESSAGES/django.po &&\
python manage.py makemessages -l ja --ignore=env/* --ignore=./settings.py --ignore=sample_project/sample_project/settings.py --ignore=web/templates/password/* --ignore=web/django_translated.py &&\
deactivate &&\
cd ~/Documents/python/StardustRun/ &&\
source env/bin/activate &&\
rm -f stardustrun/locale/ja/LC_MESSAGES/django.po &&\
python manage.py makemessages -l ja --ignore=env/* --ignore=stardustrun_project/settings.py &&\
from __future__ import division
import tinify, cStringIO, os
from PIL import Image
from django.conf import settings as django_settings
from django.core.files.temp import NamedTemporaryFile
from django.core.files.images import ImageFile
def shrinkImageFromData(data, filename):
_, extension = os.path.splitext(filename)
extension = extension.lower()