让我们假设我mergegit并且存在合并冲突.
我的问题是:如何强制git始终选择冲突的较新版本的代码,所以我不需要手动解决冲突?
是否有可能以Sublime Text 2(Cmd+ P或Ctrl+ P)的方式打开Emacs中的文件?我非常想念这个功能.
我有一个Django管理员表单.现在我想根据我的模型用数据填充它的初始字段.所以我尝试了这个:
class OrderForm(forms.ModelForm):
class Meta:
model = Order
email = CharField(initial="null", widget=Textarea(attrs={'rows': 30, 'cols': 100}))
def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request', None)
products = kwargs['instance'].products.all()
self.message = purchase_message % (
"".join(["<li>" + p.name + ": " + str(p.price) + "</li>" for p in products]),
reduce(lambda x, y:x + y.price, products, 0)
)
# and here I have a message in self.message variable
super(OrderForm, self).__init__(*args, **kwargs)
Run Code Online (Sandbox Code Playgroud)
此时我不知道如何访问电子邮件字段以在呈现窗口小部件之前设置它的初始值.我怎样才能做到这一点?
我想从c#应用程序(独立flashplayer)打开并在屏幕上将其设置为(0,0).我怎样才能做到这一点?到目前为止,我已经设法打开flashplayer:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace swflauncher
{
class Program
{
static void Main(string[] args)
{
Process flash = new Process();
flash.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
flash.StartInfo.FileName = "D:\\development\\flex4\\runtimes\\player\\10\\win\\FlashPlayer.exe";
flash.Start();
}
}
}
Run Code Online (Sandbox Code Playgroud) 我在django中有一个信号回调:
@receiver(post_save, sender=MediumCategory)
def update_category_descendants(sender, **kwargs):
def children_for(category):
return MediumCategory.objects.filter(parent=category)
def do_update_descendants(category):
children = children_for(category)
descendants = list() + list(children)
for descendants_part in [do_update_descendants(child) for child in children]:
descendants += descendants_part
category.descendants.clear()
for descendant in descendants:
if category and not (descendant in category.descendants.all()):
category.descendants.add(descendant)
category.save()
return list(descendants)
# call it for update
do_update_descendants(None)
Run Code Online (Sandbox Code Playgroud)
但是在函数体中我正在使用.save()的模型MediumCategory可以再次发送信号.我该如何禁用它; 完美的解决方案是with内部有一些"魔法" 的声明.
更新: 如果有人感兴趣,这是最终的解决方案.
class MediumCategory(models.Model):
name = models.CharField(max_length=100)
slug = models.SlugField(blank=True)
parent = models.ForeignKey('self', blank=True, null=True)
parameters = models.ManyToManyField(AdvertisementDescriptonParameter, …Run Code Online (Sandbox Code Playgroud) 假设有如下文件夹结构:
repos
/repo1 <-- here is git repository
Run Code Online (Sandbox Code Playgroud)
我愿意:
cd repos
Run Code Online (Sandbox Code Playgroud)
现在我如何在目录中使用存储/repo1库repos?我不想做
cd repo1
git status (...)
git commit (...)
...
Run Code Online (Sandbox Code Playgroud)
但类似的东西:
git --git-dir=repo1 (...)
Run Code Online (Sandbox Code Playgroud)
或者
git --work-tree=repo1 (...)
Run Code Online (Sandbox Code Playgroud)
我想以这种方式执行所有git initgit 命令, event 。正确的做法是什么?
如何从ClojureScript或Java连接到现有的clojure REPL?
标题问题.有辅助类/库吗?
我在virtualenv中使用python.我有以下模块:
offers/couchdb.py:
from couchdb.client import Server
def get_attributes():
return [i for i in Server()['offers']]
if __name__ == "__main__":
print get_attributes()
Run Code Online (Sandbox Code Playgroud)
当我从文件中运行它时,我得到:
$ python offers/couchdb.py
Traceback (most recent call last):
File "offers/couchdb.py", line 1, in <module>
from couchdb.client import Server
File "/Users/bartekkrupa/D/projects/commercial/echatka/backend/echatka/offers/couchdb.py", line 1, in <module>
from couchdb.client import Server
ImportError: No module named client
Run Code Online (Sandbox Code Playgroud)
但是当我将它粘贴到解释器中时...它有效:
$ python
Python 2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" …Run Code Online (Sandbox Code Playgroud) 看看我的django模型(我只在这里粘贴了一部分):
from django.contrib.auth.models import User as DjangoUser
from django.db import models
class Client(DjangoUser):
address = models.ForeignKey(Address, blank=True, null=True)
Run Code Online (Sandbox Code Playgroud)
我知道如何创建新的客户端和用户:
client = Client(username=name, password=pass)
client.save()
Run Code Online (Sandbox Code Playgroud)
此代码创建两个记录:用户和客户端,客户端使用其外键引用用户.
在我的mysql数据库中已经有一个DjangoUser记录.现在我想基于这个现有用户创建客户端.这该怎么做?
django ×3
git ×2
python ×2
c# ×1
clojure ×1
conflict ×1
django-admin ×1
emacs ×1
file ×1
java ×1
merge ×1
model ×1
signals ×1
sublimetext2 ×1
virtualenv ×1