Skip to content

Instantly share code, notes, and snippets.

View MechanisM's full-sized avatar
💩

Eugene MechanisM MechanisM

💩
  • MechanisM
  • Vancouver, BC, Canada
View GitHub Profile
@panurge-ws
panurge-ws / gist:525caef640784a487aa2
Last active May 20, 2016 10:38
A Videgular plugin to emulate background-size CSS property for video (see comment below).
/*
* vg-bkg-size
* A Videogular plugin to emulate background-size CSS property for video: "cover" or "contain"
*
* Use:
* <videogular vg-bkg-size="cover" center="true"></videogular>
* vg-bkg-size => "cover" or "contain"
* center => true or false
*
* Copyright (c) 2014 Panurge Web Studio
@svetlyak40wt
svetlyak40wt / blocks.py
Created August 2, 2014 20:40
Кусок адского мега-фреймворка, по типу БЭМ, но для питона и извращений типа bem-tools :)
# ...
def block(**modifiers):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
"""Этот декоратор реализует отложенный вызов функции, которую он декорирует.
По сути, он возвращает promice, который при вызове, уже зовет реальную функцию.
"""
def ret():
@Nagyman
Nagyman / workflows-in-django.md
Last active June 9, 2024 05:44
Workflows in Django

Workflows (States) in Django

I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.

Common Software Uses

  • Publishing (Draft->Approved->Published->Expired->Deleted)
@readevalprint
readevalprint / serializer.py
Created September 25, 2013 20:39
django-haystack SearchResultSerializer from django-rest-framework
==== SNIP ====
class DistanceSerializer(serializers.Serializer):
km = serializers.FloatField()
m = serializers.FloatField()
mi = serializers.FloatField()
ft = serializers.FloatField()
class SearchResultSerializer(serializers.Serializer):

Moved

Now located at https://github.com/JeffPaine/beautiful_idiomatic_python.

Why it was moved

Github gists don't support Pull Requests or any notifications, which made it impossible for me to maintain this (surprisingly popular) gist with fixes, respond to comments and so on. In the interest of maintaining the quality of this resource for others, I've moved it to a proper repo. Cheers!

@jmdobry
jmdobry / Instructions.md
Last active August 31, 2021 18:21
Nginx reverse-proxy for RethinkDB Admin UI

Start your rethinkdb instance with this flag: --bind all (or bind=all in the configuration file for your instance)

Block external access to the web UI with these two commands: sudo iptables -A INPUT -i eth0 -p tcp --dport 8080 -j DROP sudo iptables -I INPUT -i eth0 -s 127.0.0.1 -p tcp --dport 8080 -j ACCEPT

Install nginx: sudo apt-get install nginx

@egaumer
egaumer / controller.js
Created May 14, 2013 11:20
Elasticsearch/AngularJS Pagination Example
$scope.pager = {
pageChange: function(pageNum) {
$scope.search(resultPager.get(pageNum));
},
next: function() {
this.pageChange(resultPager.next());
},
@YannBrrd
YannBrrd / app.js
Last active December 17, 2015 06:49
Pagination using ElasticJS
// app.js
angular.module('cs_demo', [
'controllers',
'elasticjs.service',
'ui.bootstrap'
]);
@NorthIsUp
NorthIsUp / codeon.sh
Last active December 15, 2015 14:19
subl . should open MyProject.sublime-project if it is in the folder, else just open it as a regular folder
#!/usr/bin/env zsh
# like workon from python virtualenvwrapper
# assumes that you have all your coding projects in ~/src
subl ~/src/*${1}*
@egaumer
egaumer / app.js
Last active July 24, 2018 13:25
Getting Started with elasticsearch and AngularJS
/*jshint globalstrict:true */
/*global angular:true */
'use strict';
angular.module('demo', [
'demo.controllers',
'demo.directives',
'elasticjs.service'
]);