我正在尝试为表格中的每个单元格创建一个切换按钮.按下时,它将改变图像,再次按下时,它将再次改变图像 - 切换.
在UIButton课堂上,我没有看到一个selected州.
我正在寻找一种方法来创建一个使用UIButton的切换按钮,以便我可以在每次单击时更改状态.
这就是我现在正在rubymotion使用的方式rmq
@fav_button.on(:touch) do |sender|
puts "pressed fav button for id: " + data[:id] + " and name: " + data[:name]
#how do I change the state here?
end
Run Code Online (Sandbox Code Playgroud) 我有一个这样的方法:
def getInformation () {
return [true, "reason why"]
}
Run Code Online (Sandbox Code Playgroud)
我正在使用这个
def (isClear, reason) = getInformation()
Run Code Online (Sandbox Code Playgroud)
有没有办法为这个方法定义一个返回类型,以便在有人通过该方法时更好地阅读?
我正在尝试使用YAML创建应用程序中使用的所有存储过程的列表以及从中调用它们的位置.我设想了类似下面的内容,但我认为YAML不允许多级嵌套.
access_log:
stored_proc: getsomething
uses:
usedin: some->bread->crumb
usedin: something else here
stored_proc: anothersp
uses:
usedin: blahblah
reporting:
stored_proc: reportingsp
uses:
usedin: breadcrumb
Run Code Online (Sandbox Code Playgroud)
有没有办法在YAML中做到这一点,如果没有,还有哪些其他选择?
我作为非root用户在Docker容器中运行我的应用程序.我这样做是因为它是最好的做法之一.但是,在运行容器时,我将主机卷安装到它-v /some/folder:/some/folder.我这样做是因为我在docker容器内运行的应用程序需要将文件写入已安装的主机文件夹.但由于我以非root用户身份运行我的应用程序,因此它无权写入该文件夹
题
是否可以在docker容器中为非root用户提供对托管卷的访问权限?
如果没有,我唯一的选择是以root身份在docker容器中运行该进程吗?
我有下面的图像,文字下面有文字和很多空白区域.我想裁剪白色空间,使它看起来像第二个图像.
裁剪图像
这就是我所做的
>>> img = cv2.imread("pg13_gau.jpg.png")
>>> gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
>>> edged = cv2.Canny(gray, 30,300)
>>> (img,cnts, _) = cv2.findContours(edged.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
>>> cnts = sorted(cnts, key = cv2.contourArea, reverse = True)[:10]
Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的订阅模型
class Subscription(models.Model):
name = models.CharField(max_length=100)
quantity = models.IntegerField(max_length=20)
stripe_id = models.CharField(max_length=100)
user = models.ForeignKey(User)
Run Code Online (Sandbox Code Playgroud)
我想创建一个允许的端点 POST, PATCH, DELETE, GET
所以我做了以下事情
views.py
class SubscriptionDetail(viewsets.ModelViewSet):
serializer_class = SubscriptionSerializer
permission_classes = (IsAuthenticated,)
queryset = Subscription.objects.all()
Run Code Online (Sandbox Code Playgroud)
serializers.py
class SubscriptionSerializer(serializers.ModelSerializer):
class Meta:
model = Subscription
fields = ('name','quantity', 'stripe_id')
def update(self, instance, validated_data):
print "In update"
#how do I write create and delete?
Run Code Online (Sandbox Code Playgroud)
urls.py
subscription = SubscriptionDetail.as_view({
'patch': 'update'
})
url(r'^rest-auth/subscription/$', subscription, name='something'),
Run Code Online (Sandbox Code Playgroud)
问题
PATCH请求时使用上面的内容,我收到一个错误.我怎样才能解决这个问题?使用名为"pk"的URL关键字参数调用预期视图SubscriptionDetail.修复您的URL conf,或
.lookup_field正确设置视图上的属性.
email字段, …我有一个docker-machine,它有一个运行的mysql容器.
~
? boot2docker ip
192.168.59.103
~
? docker-machine ip default
192.168.99.100
~
? docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v1.9.1
~
? docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b14062dd1e25 mysql:5.6 "/entrypoint.sh mysql" 6 hours ago Up 6 hours 3306/tcp, 0.0.0.0:3306->9090/tcp i-mysql
Run Code Online (Sandbox Code Playgroud)
来自 docker logs i-mysql
2016-01-20 04:14:41 1 [Note] InnoDB: Highest supported file format is Barracuda.
2016-01-20 04:14:41 1 [Note] InnoDB: 128 rollback segment(s) are active. …Run Code Online (Sandbox Code Playgroud) 我在运行web.py脚本时遇到问题mod_wsgi.脚本使用numpy和opencv.
以下是我的问题的详细信息.
我在盒子上有两个python版本,但我希望脚本能够运行python2.7.所以从解释器我已经确保我可以导入cv和numpy
$ python
Python 2.7.3 (default, Oct 8 2013, 15:53:09)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> import numpy
>>> import sys
>>> sys.prefix
'/usr/local'
Run Code Online (Sandbox Code Playgroud)
我从源代码下载了mod_wsgi,并使用以下命令对其进行了配置和安装:
./configure --with-python=/usr/local/bin/python2.7 --with-apxs=/usr/sbin/apxs
LD_RUN_PATH=/usr/local/lib/ make
sudo make install
Run Code Online (Sandbox Code Playgroud)
确保正确配置mod_wsgi.
$ ldd /usr/lib64/httpd/modules/mod_wsgi.so
linux-vdso.so.1 => (0x00007fff36dff000)
libpython2.7.so.1.0 => /usr/local/lib/libpython2.7.so.1.0 (0x00007f9462710000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f94624e8000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f94622e4000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007f94620e1000)
libm.so.6 => /lib64/libm.so.6 …Run Code Online (Sandbox Code Playgroud) 我在这个网址上运行了一项服务: http://localhost:8888
我通过调用它来获得此服务的结果:
http://localhost:8888/colors?colorname=red&shade=dark
Run Code Online (Sandbox Code Playgroud)
我在JSON中得到的结果如下:
{
"request#": 55,
"colorname": "red",
"shade": "dark",
"available": "No"
}
Run Code Online (Sandbox Code Playgroud)
题
在grails应用程序中,我可以通过哪些方式使用此服务?
我已将用户名和密码存储为jenkins中的凭据.现在我想在我的Jenkinsfile中使用它们.
我使用withCredentialsDSL,但是,我不知道如何将用户名密码作为单独的变量,所以我可以在我的命令中使用它们.
这就是我正在做的事情:
withCredentials([usernameColonPassword(credentialsId: 'mycreds', variable: 'MYCREDS')]) {
sh 'cf login some.awesome.url -u <user> -p password'
}
Run Code Online (Sandbox Code Playgroud)
我怎么能分别用户名和密码呢?我尝试过,${MYCREDS.split(":")[0]}但似乎没有用.