client.getOutputStream().write(new byte[] {newByte});
byte newByte = new newByte;
Если вам нужно объявить переменную содержащую один байт, то выглядеть это должно так:byte b = 11;
# -*- encoding: utf-8 -*-
import sys
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import (QMainWindow, QApplication, QWidget,
QPushButton, QAction, QLineEdit, QMessageBox)
class App(QMainWindow):
def __init__(self):
super().__init__()
self.title = 'Тест'
self.left = 200
self.top = 200
self.width = 400
self.height = 140
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.textbox = QLineEdit(self)
self.textbox.move(20, 20)
self.textbox.resize(280, 40)
self.button = QPushButton('Показать', self)
self.button.move(20, 80)
self.button.clicked.connect(self.on_click)
self.show()
@pyqtSlot()
def on_click(self):
textboxValue = self.textbox.text()
QMessageBox.question(self, 'Введено', textboxValue, QMessageBox.Ok, QMessageBox.Ok)
self.textbox.setText("")
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = App()
sys.exit(app.exec_())
from django.db.models import Q
# Это лучше хранить где-нибудь в базе, а не в коде
DEFAULTS = {
'name': '',
'age': ['18_24', '24_35', '36_42', '43+', None],
'eye': None,
}
def new_services_search(request):
if request.method=='POST':
filters = []
for k in request.POST:
kwargs = {}
v = request.POST.get(k, DEFAULTS[k])
if v is None:
kwargs[k + '__isnull'] = True
elif isinstance(v, list):
kwargs[k + '__in'] = v
else:
kwargs[k] = v
filters.append(Q(**kwargs))
filter_girls = Profile.objects.filter(filters)
import java.io.File;
import java.awt.Color;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
public class ImageSimilarity {
public static BufferedImage getDifferenceImage(BufferedImage img1, BufferedImage img2) {
final int w = img1.getWidth(),
h = img1.getHeight(),
highlight = Color.MAGENTA.getRGB();
final int[] p1 = img1.getRGB(0, 0, w, h, null, 0, w);
final int[] p2 = img2.getRGB(0, 0, w, h, null, 0, w);
for (int i = 0; i < p1.length; i++) {
if (p1[i] != p2[i]) {
p1[i] = highlight;
}
}
final BufferedImage out = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
out.setRGB(0, 0, w, h, p1, 0, w);
return out;
}
public static void main(String[] args) throws Exception {
ImageIO.write(
getDifferenceImage(
ImageIO.read(new File("img1.png")),
ImageIO.read(new File("img2.png"))),
"png",
new File("diff.png"));
}
}
<p:commandButton value="Скрыть/Показать">
<f:ajax listener="#{exampleBean.toggleVisibility}" event="click" render="somePanel"></f:ajax>
</p:commandButton>
<h:panelGroup id="somePanel" layout="block" rendered="#{exampleBean.visible}">
<div>Трям!</div>
</h:panelGroup>
<h:panelGroup id="somePanel" layout="block" styleClass="#{(exampleBean.visible) ? 'hidden' : ''">
<div>Трям!</div>
</h:panelGroup>
<script>
function toggleVisibility(id) {
var table = document.getElementById(id);
if(table) {
var currentState = table.style.display || 'block';
if (currentState === 'block')
table.style.display = 'none';
else
table.style.display = 'block';
}
return false;
}
</script>
<p:commandButton value="Скрыть/Показать" onclick="toggleVisibility('globalform:visTest:checking');">
</p:commandButton>
from django.conf import settings
from django.core.cache import cache, get_cache
from django.utils.importlib import import_module
class UserRestrictMiddleware(object):
def process_request(self, request):
"""
Checks if different session exists for user and deletes it.
"""
if request.user.is_authenticated():
cache = get_cache('default')
cache_timeout = 86400
cache_key = "user_pk_%s_restrict" % request.user.pk
cache_value = cache.get(cache_key)
if cache_value is not None:
if request.session.session_key != cache_value:
engine = import_module(settings.SESSION_ENGINE)
session = engine.SessionStore(session_key=cache_value)
session.delete()
cache.set(cache_key, request.session.session_key,
cache_timeout)
else:
cache.set(cache_key, request.session.session_key, cache_timeout)
System.loadLibrary()
ищет библиотеку в java.library.path. В разных системах это свойство содержит разное значение по умолчанию: