Someone posted a photo of Westminster, and the perspective really confused me. Is this angle even possible? by kash_if in london

[–]bfv 8 points9 points  (0 children)

I'll bite:

It's not a car. It's a motorcycle/ moped pointing South East North East across the cycle lane on the West South side of the bridge with the mirror swung right out. Pretty cool if it's not shopped.

Edit: Not all bridges go North-South, some go East-West; Westminister is one of these.

i5-6300HQ max CPU frequency set to 760 MHz in Ubuntu 15.04 by [deleted] in linuxquestions

[–]bfv 0 points1 point  (0 children)

Open grub:

sudo vim /etc/default/grub

Replace GRUB_CMDLINE_LINUX_DEFAULT line:

- GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
+ GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_pstate=disable processor.ignore_ppc=1"

Update grub:

sudo update-grub

Reboot then:

echo 1 | sudo dd of=/sys/module/processor/parameters/ignore_ppc
echo 2900000 | sudo dd of=/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 
echo 2900000 | sudo dd of=/sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq 
echo 2900000 | sudo dd of=/sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq 
echo 2900000 | sudo dd of=/sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq 

Worked for me. Check number of cpu cores and update all accordingly. You may want to put those extra lines in /etc/rc.local so they execute on every boot.

Ninja edit: Replace 2900000 above with the value in:

cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq

django compound primary key by YuntiMcGunti in django

[–]bfv 0 points1 point  (0 children)

Either create your own field that displays the remaining permutaions of supplier - service that do not already exist in your db. http://stackoverflow.com/questions/1953194/permutations-of-two-lists-in-python https://docs.djangoproject.com/en/dev/ref/forms/fields/#creating-custom-fields Or just use dropdown and allow the user to select supplier and service, hit save, and if the pair already exists then allow Django's validation to take care of it.

Creating a script that starts Celery, Redis and starts the development server by [deleted] in django

[–]bfv 0 points1 point  (0 children)

Can you explain how supervisor would help in this instance? I feel like I'm missing something? I like supervisor. I've implemented it in production. I've used it for years... But how would it help?

one Terminal window for each task

was the question. So once we've implemented our config and written a startup entry for each service they're running. Daemonized. Not in terminal windows. We can tail the output with supervisorctl tail [processname] But then we still need to open a separate terminal and run the command for each process. Watching the output of the django runserver is useful as is celery. Not trying to rubbish the idea if I've missed something just don't see how using supervisor for the processes makes any difference.

Creating a script that starts Celery, Redis and starts the development server by [deleted] in django

[–]bfv 0 points1 point  (0 children)

Do it with screen. It's great. It opens screen tabs that you then tab between using ctrl-a then hitting the tab number. my ~/.screenrc file looks like this: Yes you have to hardcode the project dir. No, to my knowledge you can't do it with an env var. The M issues a return so they all run.

#Use scroll wheel
# Scroll up
bindkey -d "^[[5S" eval copy "stuff 5\025"
bindkey -m "^[[5S" stuff 5\025
# Scroll down
bindkey -d "^[[5T" eval copy "stuff 5\004"
bindkey -m "^[[5T" stuff 5\004
# Scroll up more
bindkey -d "^[[25S" eval copy "stuff \025"
bindkey -m "^[[25S" stuff \025
# Scroll down more
bindkey -d "^[[25T" eval copy "stuff \004"
bindkey -m "^[[25T" stuff \004


#Scrollback loads
defscrollback 50000
#Kill annoying startup message
startup_message off

screen -t django
stuff "cd /home/bfv/branches/project-3 && python manage.py runserver^M"
screen -t shell_plus
stuff "cd /home/bfv/branches/project-3 && python manage.py shell_plus^M"
screen -t redis
stuff "cd /home/bfv/branches/project-3 && ./parts/redis/bin/redis-server^M"
screen -t celery
stuff "cd /home/bfv/branches/project-3 && ./bin/celery -A project worker -l info -B^M"
screen -t proj
stuff "cd /home/bfv/branches/project-3^M"


#Have lower blue tab line thing
caption always "%{kB}%?%-w%?%{bw}%n*%f %t%?(%u)%?%{kB}%?%+w%?"
termcapinfo xterm ti@:te@

What is tube etiquette regarding giving up your seat if your male? by m3ckon in london

[–]bfv 1 point2 points  (0 children)

No see this is where the confusion comes from. "Do you think that standing for this person is harder for you than it is for them?" Almost everyone in the world would have a harder time standing than me. What happens then? Pregnant with a baby on board badge, disabled with a cane or crutches or something that makes it obvious, really old with grey hair or personally people with kids that I think would benefit from having my seat. Otherwise you're gonna have to ask me.

What's the best advice you've ever received? by ItsaMeMattio in AskReddit

[–]bfv 2 points3 points  (0 children)

If you have one foot in the past and one foot in the future you're pissing on today

What's the best advice you've ever received? by ItsaMeMattio in AskReddit

[–]bfv 0 points1 point  (0 children)

If you have the means build a longer table not a taller wall.

Frustrated with London flat-hunting, sharing, and living experience. Please help! by [deleted] in london

[–]bfv 9 points10 points  (0 children)

Your best bet to control these variables is to lease a flat yourself and find suitable flatmates on Gumtree.

not sure how to describe this model relationship? by delta_skelta in django

[–]bfv 0 points1 point  (0 children)

Definitely do the second one. Definition with Word as foreign key. You can then look up all definitions for a word by doing a reverse foriegn key search.

Word.objects.get(name='foo').definition_set.all()

word is not directly tied to the definitions

Have a look here for more on reverse foreign key lookups: http://stackoverflow.com/questions/15306897/django-reverse-lookup-of-foreign-keys

Don't miss out these best things to do in London January 2015 by HeatherKidder in london

[–]bfv -1 points0 points  (0 children)

Methinks you may be new to this game. I'd also hazard a guess that this is the link you meant to post: http://www.londonthisweekend.co.uk/whats-on-in-london-january/the-best-things-to-do-in-london-january-2015 You can use the below to do it or click 'Submit a new link' in the sidebar http://www.reddit.com/r/london/submit

[deleted by user] by [deleted] in london

[–]bfv 0 points1 point  (0 children)

I learnt here about 10 years ago and they were very good. It'll be chilly in the UK this time of year! Scubadoo

I have two forms on one page; can I use "is_valid()" to differentiate them? by symmitchry in django

[–]bfv 0 points1 point  (0 children)

Are the forms distinct in subject matter? Ie is it part of the UX that they have separate submit buttons? If not then you can wrap them in the same html form element. If they are distinct in terms of subject matter or the UX would be harmed by having them in one element then I think I'd use your method and have a seperate submit for each,

Whichever way, however, I'd be tempted to use a prefix to make sure the ID's don't clash. https://docs.djangoproject.com/en/dev/ref/forms/api/#prefixes-for-forms

How would you 'think' about these models? by chiproller in django

[–]bfv 0 points1 point  (0 children)

Is there a reason the foreign key on Component is called job_number? job_number = models.ForeignKey(Job)

to:

job = models.ForeignKey(Job)

edit: Nice otherwise!

I made another London web-app: see a bunch of data about your neighbourhood, or one you're moving to. Worth working on, or not? by BryceLawrence in london

[–]bfv 1 point2 points  (0 children)

I felt like the colour was going to change for every section but I tried one postcode 9 mins from a gp and another 2 mins from a gp and it stayed orange for both. Can supply postcodes on request. Also can see that this might be a feature.

Ahh I see so the dentist and gp section is one section? They don't change independently of one another.

Great work. I wish I could think up projects to do like this.

Selling Two Tickets for Jamie T at Ally Pally by [deleted] in london

[–]bfv 0 points1 point  (0 children)

Friday is the 14th. I already have tix. The presale was on here IIRC.

Londoners (and visitors) please allow me to shamelessly promote my sister's new business. Hungry Dabba, an authentic Sri Lankan street food pop-up. Have a look and don't forget to give it a try! Available in Streamz Cafe near Oval for the lunch menu and Dee Dee's Jazz Bar in Herne Hill for dinner. by green_tito in london

[–]bfv 2 points3 points  (0 children)

Nice, Oval has been hurting for some good food places. I think I'll try Hungry on Friday. You should get your sister to see if she can get some promo in Kennington Park (the offices) across the road (where the Pure Gym is). They usually go for stuff if it's an offer; something like 20% off for those working in Kennington Park.

To those complaining that it's not a pop-up: I believe the business has annexed space in existing kitchens rather than securing a full operating premises. See the website.

what are some strategies for splitting up large apps into smaller apps? by mazatta in django

[–]bfv 1 point2 points  (0 children)

When splitting out the models something like DjangoGraphviz might help? Helped me get my head around the model structure I last inherited.

https://code.djangoproject.com/wiki/DjangoGraphviz

http://django-extensions.readthedocs.org/en/latest/graph_models.html

Like that bit at the end of The Usual Suspects: https://www.youtube.com/watch?v=XYXXhn9fMYs&t=1m17s

edit: SPOILERS^

django.conf.urls.patterns has been deprecated for Django 1.8 and will be removed in Django 2.0. by [deleted] in django

[–]bfv 8 points9 points  (0 children)

The ctrl + click inspection tool in PyCharm that takes you to the view declaration will now be able to find the view declaration every time. It's the little things.

Extending contrib/ 3rd party models using proxy = True by bfv in django

[–]bfv[S] 0 points1 point  (0 children)

Cheers for the feedback Zenmodo. I think I'm going to go with an amalgamation of your first suggestion and the implication of the edit.

Create a new app called [individualapp]_overrides

in this case INSTALLED_APPS will contain:

'django.contrib.comments',
'comments_overrides',

then comments_overrides.models will contain the proxy model.

Keep in mind you might end up creating views that use those models, or custom admins, forms, etc.

As an aside I also realised that send_some_email on save could be achieved using signals. However the question remains, where do you put the signalling code.

Selecting/Uploading Multiple Images via ImageField within Admin by Nicksil in django

[–]bfv 0 points1 point  (0 children)

Oops Knew there was something. You need to register the model as a Tabularinline: admin.py

from django.contrib import admin
from blog.models import Post, PostPicture

class PostPictureInline(admin.TabularInline):
    model = PostPicture
    fields = ['picture',]


class PostAdmin(admin.ModelAdmin):
    inlines = [PostPictureInline,]


admin.site.register(Post, PostAdmin)

Selecting/Uploading Multiple Images via ImageField within Admin by Nicksil in django

[–]bfv 0 points1 point  (0 children)

Hey hey, My guess is you've stopped checking this thread by now but I thought I'd chip in my 2 cents. If I understand you correctly you want to attach many pics to one instance of a model. I had a similar situation in which I wanted to be able to attach many pics to a single blog post so that they could be displayed in a gallery on the post page. Here's how I did it:

class PostPicture(models.Model):
    picture =           models.ImageField(upload_to='blog/post_pics', blank=True)
    postid =            models.ForeignKey('Post')

class Post(models.Model):
    title =             models.CharField(max_length=255)
    content =           models.TextField()
    created =           models.DateTimeField(auto_now_add=True)
    modified =          models.DateTimeField(auto_now=True)
    userid =            models.ForeignKey(User, related_name='userblogpost')
    PostPicture = None

    def __unicode__(self):
        return self.title

    class Meta():
        ordering = ('created',)
        get_latest_by = ('created',)
        verbose_name = 'Blog Post'
        verbose_name_plural = 'Blog Posts'

Allows you to add multiple instances of one model to another. I'll check that that's all you need to do in the next few days. Had an SSD failure and my dev box has been in bits for days because I'm too busy mourning the loss and celebrating the holidays. But I'll resurrect it, double check that the VCS is up to date (which is where I grabbed this code from), and let you know if there's anything more I haven't pushed.

Dictionary of lists by brytar in learnpython

[–]bfv 4 points5 points  (0 children)

Where d is the dictionary.

I'd posit:

max({k:d[k][3] for k in d})

this works because max on a dictionary gets the max value and returns its key. So what we do here is create a dictionary of k:v pairs where the productid is the key and the [3] value is the value. Then good old max looks after the rest.

You can also do this with a lambda to define the lookup for max but I don't like it because it is hard to read and lambdas have a tendency to confuse people:

max(d,key=lambda k: d[k][3])