有没有更简洁的方法来获取HEADGit 的短版本哈希?
我希望看到与我相同的输出:
git log -n 1 | head -n 1 | sed -e 's/^commit //' | head -c 8
Run Code Online (Sandbox Code Playgroud)
我最初使用它来生成版本字符串,但这更好:
git describe --tags
Run Code Online (Sandbox Code Playgroud)
它将输出字符串,如0.1.12(标记提交)或0.1.11-5-g0c85fbc(标记后的五次提交).
这听起来很容易,但我无法在文档中的任何地方找到它.如何{% this %}在没有引擎处理的情况下写入液体模板?
是否有Python内置数据类型,除此之外None:
>>> not foo > None
True
Run Code Online (Sandbox Code Playgroud)
foo这个类型的值在哪里?Python 3怎么样?
我想在服务器启动(开发和生产)上执行这些代码行:
from django.core import management
management.call_command('syncdb', interactive=False)
Run Code Online (Sandbox Code Playgroud)
放入settings.py它不起作用,因为它需要已经加载设置.
将它们放在视图中并从外部访问该视图也不起作用,因为有些中间件使用数据库而这些中间件将失败并且不允许我访问视图.
将它们放在中间件中会起作用,但每次访问我的应用程序时都会调用它.一个可能的解决方案可能是创建一个中间件来完成所有工作,然后将其自身移除,MIDDLEWARE_CLASSES因此不再调用它.如果没有太多的猴子补丁,我可以这样做吗?
我从移动应用程序(最多1000个JSON对象)提交相对大量的数据,我通常会像这样编码:
[{
id: 12,
score: 34,
interval: 5678,
sub: 9012
}, {
id: ...
}, ...]
Run Code Online (Sandbox Code Playgroud)
我可以通过提交数组数组来减小有效负载:
[[12, 34, 5678, 9012], [...], ...]
Run Code Online (Sandbox Code Playgroud)
在属性名称上保存一些空间,并在服务器上重新创建对象(因为模式已修复,或者至少它是服务器和客户端之间的契约).
然后在POST请求中提交有效载荷,最有可能通过3G连接(或可能是wifi).
看起来我通过使用嵌套数组来节省一些带宽,但我不确定应用gzip时它是否明显,我不确定如何精确和客观地测量差异.
在另一方面,嵌套的数组不觉得是个好主意:他们不太容易阅读,因而更难调试时发现错误.此外,由于我们正在冲洗马桶的可读性,我们可以简化阵列,因为每个子阵列都有固定数量的元素,服务器可以将其切片并再次重建对象.
关于这个主题的任何进一步的阅读材料非常感谢.
以下是旋转标记的代码,但是如何旋转自定义标记.任何的想法?
var angleDegrees = 150;
new google.maps.Marker({
position: a,
map: map,
icon: {
path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
scale: 6,
fillColor: "red",
fillOpacity: 0.8,
strokeWeight: 2,
rotation: angleDegrees //this is how to rotate the pointer
}
});
Run Code Online (Sandbox Code Playgroud) 我正在使用Jekyll将我的markdown和Pygments转换为语法高亮.
这是错误maruku显示:
Liquid error: undefined method `join' for "\n song_info = []\n for song in songs:\n song_info.append(song.name) \n":String
Run Code Online (Sandbox Code Playgroud)
标记如下:
{% highlight python %}
song_info = []
for song in songs:
song_info.append(song.name)
{% endhighlight %}
Run Code Online (Sandbox Code Playgroud)
在iPython中测试Pygments不会产生任何错误.
有任何想法吗?O(
提前致谢!
我想告诉urllib2.urlopen(或自定义开启者)使用127.0.0.1(或::1)来解析地址.但是,我不会改变我的/etc/resolv.conf.
一种可能的解决方案是使用类似dnspython查询地址和httplib构建自定义URL开启工具的工具.我更喜欢告诉urlopen使用自定义名称服务器.有什么建议?
我正在尝试从视图中同步我的数据库,如下所示:
from django import http
from django.core import management
def syncdb(request):
management.call_command('syncdb')
return http.HttpResponse('Database synced.')
Run Code Online (Sandbox Code Playgroud)
问题是,它将通过询问终端的用户输入来阻止开发服务器.如何通过它'--noinput'来防止问我什么?
我有其他方法将用户标记为超级用户,因此不需要用户输入,但我真的需要以编程方式调用syncdb(和flush),而无需通过ssh登录到服务器.任何帮助表示赞赏.
我们的项目已经列入白名单用于测试新的GCM 用户通知,允许分组的注册ID,然后到可用于将消息发送到该用户所拥有的所有设备的单一"通知键" API.
但是,当我发送这样的请求时:
POST /gcm/send
Authorization: key=…
Content-Type: application/json
{"notification_key": "…",
"data": {…}
}
Run Code Online (Sandbox Code Playgroud)
我收到错误回复:
400 Bad Request
Missing "registration_ids" field
Run Code Online (Sandbox Code Playgroud)
使用registration_ids字段发送消息而不是notification_key修复问题(以及消息传递),但使用用户通知API的重点是使用notification_key而不是registration_ids.
从文档:
registration_ids:[...]请求必须包含收件人 - 这可以是注册ID,注册ID数组或notification_key.需要.
notification_key:将单个用户映射到与该用户关联的多个注册ID的字符串.这允许第三方服务器将单个消息发送到单个用户拥有的多个应用程序实例(通常在多个设备上).第三方服务器可以使用notification_key作为消息的目标,而不是单个注册ID(或注册ID数组).[…] 可选的.
上面的示例使用HTTP连接服务器https://android.googleapis.com.
到目前为止我试过:
registration_ids,没有帮助notification_key在registration_ids字段中将值作为注册ID 发送,也不起作用project_id标题设置为我们的项目编号(在创建时需要notification_key),仍然没有运气notification_key和notification_key_name在请求中,并没有帮助更新:根据此处的建议,我还尝试将有效负载发布到JSON请求有效负载中包含/gcm/notification的"operation": "send"属性.仍然没有帮助.现在我得到:
{"error":"Missing \"registration_ids\" …Run Code Online (Sandbox Code Playgroud) python ×5
django ×2
liquid ×2
android ×1
bandwidth ×1
django-admin ×1
dns ×1
dnspython ×1
git ×1
google-maps ×1
http ×1
jekyll ×1
json ×1
markdown ×1
performance ×1
pygments ×1
python-3.x ×1
templates ×1
urllib2 ×1
urlopen ×1