Skip to content

Instantly share code, notes, and snippets.

View 3Lowz's full-sized avatar

3lowz 3Lowz

View GitHub Profile
@jonashaag
jonashaag / 0-howto-listfield-django-admin.rst
Created September 7, 2011 09:41
Howto use ListFields in Django's admin

Howto use ListFields in Django's admin

Problem

Consider this blog post model:

models.py

@aheckmann
aheckmann / storeImgInMongoWithMongoose.js
Created April 17, 2012 19:14
store/display an image in mongodb using mongoose/express
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path
@justinzane
justinzane / gist:2571533
Created May 1, 2012 21:25
tastypie problem
#models.py
class StoreType(models.Model):
name = models.CharField(max_length=24, unique=True)
class Meta:
ordering = ["name"]
def __unicode__(self):
return ("%24s" % (self.name))
class Store(models.Model):
name = models.CharField(max_length=24)
@vshjxyz
vshjxyz / Appfog django south migrate.py
Last active December 13, 2015 23:58
This is the content of my __init__.py to perform migrations on appfog I needed this because the django-allauth package need to do some migrations initially to work. The Appfog's lack of post-deploy scripts forced me to create a script that I had to put inside one of the apps in my project django_project/appname/management/__init__.py should make…
from django.core.exceptions import ImproperlyConfigured
from django.core.management import call_command
from django.db.models.signals import post_syncdb
from south.models import MigrationHistory
import pizzanuvola_teaser.settings as settings
def migration_exists(appname, migrationnumber):
appname = appname.split('.')[-1]
return MigrationHistory.objects.filter(app_name=appname, migration__icontains=migrationnumber).exists()
@justinwoo
justinwoo / using-rxjs-instead-of-flux-with-react.md
Last active October 21, 2023 10:16
Using RxJS instead of Flux with React to organize data flow

Reposted from Qiita

For almost a year now, I've been using this "flux" architecture to organize my React applications and to work on other people's projects, and its popularity has grown quite a lot, to the point where it shows up on job listings for React and a lot of people get confused about what it is.

Why I'm tired of using and teaching flux

There are a billion explainations on the internet, so I'll skip explaining the parts. Instead, let's cut to the chase -- the main parts I hate about flux are the Dispatcher and the Store's own updating mechanism.

If you use a setup similar to the examples in facebook/flux, and you use flux.Dispatcher, you probably have this kind of flow:

@ldong
ldong / download_egghead_videos.md
Last active December 7, 2023 16:16
download egghead videos

Download videos from egghead

Go to the egghead website, i.e. Building a React.js App

run

$.each($('h4 a'), function(index, video){
  console.log(video.href);
});
@paulirish
paulirish / what-forces-layout.md
Last active July 5, 2024 08:26
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@0x9090
0x9090 / torrc.examples.txt
Created February 8, 2016 06:47
torrc examples
This file is part of Whonix
Copyright (C) 2012 - 2014 Patrick Schleizer <adrelanos@riseup.net>
See the file COPYING for copying conditions.
**** Do NOT edit this file! ****
This file will show you examples you can copy and paste to /etc/tor/torrc
Additionally, you can read the official Tor Manual at:
https://www.torproject.org/docs/tor-manual.html.en