byte[] image is not renderer correctly by HttpServlet - image
I've got this piece of coding which, when displayed in Firefox or Chrome, throws an exception (the image cannot be displayed because it contains errors).
byte[] img2 = { 105, 86, 66, 79, 82, 119, 48, 75, 71, 103, 111, 65, 65, 65, 65, 78, 83, 85, 104, 69, 85, 103,
65, 65, 65, 68, 65, 65, 65, 65, 65, 101, 67, 65, 89, 65, 65, 65, 66, 113, 112, 74, 51, 66, 65, 65, 65,
65, 71, 88, 82, 70, 87, 72, 82, 84, 98, 50, 90, 48, 100, 50, 70, 121, 90, 81, 66, 66, 90, 71, 57, 105,
90, 83, 66, 74, 98, 87, 70, 110, 90, 86, 74, 108, 89, 87, 82, 53, 99, 99, 108, 108, 80, 65, 65, 65, 65,
50, 112, 74, 82, 69, 70, 85, 101, 78, 114, 115, 87, 69, 49, 73, 86, 71, 69, 85, 118, 102, 54, 107, 111,
87, 108, 69, 97, 101, 85, 89, 113, 73, 115, 89, 85, 55, 82, 78, 106, 107, 81, 104, 87, 81, 109, 90,
103, 90, 67, 103, 76, 105, 113, 85, 119, 69, 88, 89, 72, 119, 81, 117, 99, 117, 85, 109, 107, 66, 90,
87, 71, 122, 99, 87, 69, 112, 82, 85, 71, 66, 81, 73, 47, 85, 99, 82, 97, 89, 69, 74, 97, 111, 71, 107,
107, 87, 78, 81, 75, 108, 79, 97, 83, 85, 111, 47, 99, 57, 53, 52, 72, 47, 102, 55, 51, 110, 115, 122,
85, 113, 115, 72, 99, 43, 69, 78, 56, 55, 53, 53, 99, 57, 56, 57, 53, 53, 53, 55, 118, 106, 99, 84,
107, 49, 86, 53, 113, 88, 57, 76, 57, 114, 113, 116, 113, 99, 109, 74, 53, 75, 97, 89, 109, 102, 116,
74, 119, 50, 78, 84, 98, 54, 106, 56, 49, 80, 85, 47, 98, 103, 51, 85, 72, 117, 115, 50, 53, 109, 87,
103, 57, 108, 104, 121, 101, 85, 81, 66, 82, 65, 72, 56, 90, 56, 84, 106, 53, 102, 102, 67, 78, 49,
111, 77, 68, 78, 107, 106, 84, 69, 105, 108, 70, 87, 118, 121, 76, 101, 116, 66, 67, 122, 79, 115, 106,
67, 78, 111, 120, 101, 84, 47, 77, 109, 116, 90, 107, 121, 97, 66, 122, 43, 55, 49, 106, 116, 72, 69,
53, 75, 121, 53, 53, 107, 108, 76, 111, 84, 74, 102, 78, 117, 108, 109, 115, 109, 83, 84, 121, 115, 65,
105, 110, 121, 48, 65, 120, 75, 43, 53, 99, 90, 111, 102, 55, 54, 70, 53, 102, 52, 47, 108, 111, 114,
81, 57, 51, 90, 83, 52, 102, 114, 117, 83, 102, 80, 47, 112, 76, 105, 88, 53, 115, 47, 90, 68, 49, 78,
76, 120, 110, 70, 52, 79, 84, 112, 106, 114, 65, 49, 101, 80, 109, 116, 101, 51, 100, 98, 50, 105, 106,
106, 115, 68, 116, 105, 84, 100, 101, 117, 121, 104, 97, 121, 50, 86, 121, 108, 112, 116, 56, 50, 48,
70, 65, 71, 75, 115, 43, 53, 105, 57, 104, 71, 73, 84, 86, 108, 78, 83, 84, 106, 87, 116, 76, 98, 108,
67, 71, 121, 116, 102, 85, 50, 66, 86, 117, 88, 75, 82, 68, 117, 114, 109, 111, 51, 102, 75, 79, 84,
79, 111, 77, 56, 97, 115, 78, 112, 122, 114, 99, 83, 119, 101, 85, 90, 122, 118, 85, 99, 55, 82, 74,
98, 49, 52, 55, 110, 114, 69, 71, 89, 104, 76, 51, 107, 82, 120, 66, 97, 49, 48, 47, 79, 107, 82, 43,
114, 54, 52, 48, 108, 104, 98, 68, 65, 120, 113, 106, 75, 107, 65, 84, 108, 81, 88, 109, 85, 120, 76,
43, 84, 66, 89, 50, 82, 87, 65, 113, 106, 57, 81, 83, 67, 100, 114, 105, 113, 105, 113, 49, 71, 117,
99, 81, 48, 89, 121, 76, 116, 43, 49, 66, 50, 115, 72, 73, 78, 55, 117, 81, 116, 122, 56, 47, 89, 47,
78, 81, 82, 67, 72, 54, 85, 74, 74, 74, 57, 72, 110, 70, 48, 111, 83, 109, 81, 106, 115, 90, 97, 97,
110, 75, 69, 86, 75, 65, 70, 76, 118, 105, 79, 98, 54, 72, 85, 98, 104, 72, 75, 50, 78, 75, 110, 68,
77, 107, 90, 54, 76, 111, 51, 100, 111, 81, 118, 108, 117, 87, 66, 99, 113, 122, 115, 43, 103, 107, 97,
56, 98, 68, 66, 68, 111, 66, 72, 100, 66, 90, 43, 102, 103, 76, 113, 57, 53, 89, 120, 107, 54, 113,
120, 121, 89, 69, 49, 50, 67, 99, 111, 68, 98, 117, 118, 113, 85, 100, 83, 109, 118, 90, 85, 109, 73,
119, 53, 99, 88, 43, 105, 74, 65, 100, 65, 121, 88, 109, 67, 52, 70, 102, 88, 75, 65, 101, 87, 90, 69,
90, 53, 111, 55, 52, 77, 118, 76, 115, 76, 106, 76, 109, 89, 115, 80, 97, 87, 100, 68, 112, 52, 86,
112, 100, 105, 107, 53, 87, 47, 56, 77, 111, 77, 121, 88, 89, 55, 54, 47, 77, 101, 75, 106, 106, 51,
54, 47, 119, 90, 120, 115, 100, 49, 86, 112, 114, 118, 110, 101, 83, 85, 73, 111, 111, 76, 86, 120,
116, 121, 85, 47, 79, 103, 97, 110, 107, 100, 51, 81, 56, 57, 100, 86, 70, 70, 74, 117, 108, 109, 113,
100, 43, 110, 48, 99, 65, 89, 66, 100, 72, 66, 122, 110, 110, 51, 106, 111, 102, 116, 43, 111, 114, 88,
120, 67, 66, 99, 51, 89, 79, 108, 65, 73, 113, 78, 101, 119, 83, 100, 49, 116, 87, 70, 74, 99, 116, 74,
81, 110, 55, 103, 48, 83, 73, 71, 86, 49, 68, 106, 53, 70, 72, 109, 73, 53, 111, 77, 122, 81, 103, 47,
55, 112, 52, 79, 117, 48, 85, 112, 81, 69, 75, 71, 102, 65, 98, 115, 78, 66, 76, 104, 121, 81, 67, 67,
84, 69, 82, 102, 79, 71, 78, 84, 79, 51, 89, 74, 107, 106, 100, 77, 106, 113, 82, 74, 80, 76, 102, 53,
84, 89, 87, 53, 84, 106, 43, 74, 108, 107, 51, 48, 107, 43, 87, 74, 101, 83, 89, 70, 49, 76, 52, 69,
55, 87, 121, 87, 54, 107, 53, 57, 98, 110, 73, 69, 73, 72, 77, 104, 122, 108, 74, 101, 87, 103, 77, 56,
102, 121, 119, 101, 54, 76, 65, 112, 106, 57, 107, 65, 109, 77, 87, 106, 97, 56, 122, 80, 82, 85, 82,
43, 117, 48, 109, 120, 48, 99, 84, 69, 74, 56, 112, 66, 56, 77, 89, 70, 78, 72, 122, 82, 115, 88, 104,
43, 53, 65, 55, 68, 122, 56, 80, 84, 115, 109, 53, 98, 52, 103, 114, 82, 79, 66, 84, 85, 54, 54, 70,
47, 74, 103, 86, 117, 81, 53, 65, 52, 106, 52, 78, 75, 111, 80, 72, 107, 66, 66, 66, 117, 71, 99, 65,
89, 122, 113, 79, 55, 78, 100, 70, 57, 117, 98, 121, 111, 49, 99, 48, 106, 113, 82, 118, 54, 54, 105,
119, 79, 119, 97, 68, 117, 122, 99, 77, 116, 53, 43, 109, 70, 113, 101, 104, 69, 74, 115, 98, 119, 118,
79, 81, 114, 97, 106, 119, 122, 67, 76, 115, 108, 104, 109, 66, 119, 57, 122, 89, 69, 115, 54, 82, 48,
112, 83, 119, 112, 75, 55, 101, 69, 121, 81, 55, 85, 51, 55, 119, 117, 90, 72, 121, 73, 99, 57, 53,
102, 79, 97, 115, 57, 50, 117, 47, 86, 71, 80, 50, 113, 79, 47, 121, 75, 73, 65, 111, 103, 68, 99, 68,
105, 67, 99, 86, 55, 115, 104, 89, 116, 122, 43, 53, 43, 53, 102, 65, 81, 89, 65, 80, 115, 81, 106,
121, 52, 54, 108, 99, 104, 65, 65, 65, 65, 65, 65, 83, 85, 86, 79, 82, 75, 53, 67, 89, 73, 73, 61 };
response.setContentType("image/jpeg");
response.setContentLength(img2.length);
response.getOutputStream().write(img2, 0, img2.length);
response.getOutputStream().close();
If I embed the same piece in an HTML it all works okay.
Can anybody tell me why?
<img src="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAeCAYAAABqpJ3BAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2pJREFUeNrsWE1IVGEUvf6koWlEaeUYqIsYU7RNjkQhWQmZgZCgLiqUwEXYHwQucuUmkBZWGzcWEpRUGBQI/UcRaYEJaoGkkWNQKlOaSUo/c954H/f73nszUqsHc+EN8755c9895557vjcTk1V5qX9L9rqtqcmJ5KaYmftJw2NTb6j81PU/bg3UHus25mWg9lhyeUQBRAH8Z8Tj5ffCN1oMDNkjTEilFWvyLetBCzOsjCNoxeT/MmtZkyaBz+71jtHE5Ky55klLoTJfNulmsmSTysAiny0AxK+5cZof76F5f4/lorQ93ZS4fruSfP/pLiX5s/ZD1NLxnF4OTpjrA1ePmte3db2ijjsDtiTdeuyhay2Vylpt820FAGKs+5i9hGITVlNSTjWtLblCGytfU2BVuXKRDurmo3fKOTOoM8asNpzrcSweUZzvUc7RJb147nrEGYhL3kRxBa10/OkR+r640lhbDAxqjKkATlQXmUxL+TBY2RWAqj9QSCdriqiq1GucQ0YyLt+1B2sHIN7uQtz8/Y/NQRCH6UJJJ9HnF0oSmQjsZaanKEVKAFLviOb6HUbhHK2NKnDMkZ6Lo3doQvluWBcqzs+gka8bDBDoBHdBZ+fgLq95Yxk6qxyYE12CcoDbuvqUdSmvZUmIw5cX+iJAdAyXmC4FfXKAeWZEZ5o74MvLsLjLmYsPaWdDp4Vpdik5W/8MoMyXY76/MeKjj36/wZxsd1VprvneSUIooLVxtyU/Ogankd3Q89dVFFJulmqd+n0cAYBdHBznn3joft+orXxCBc3YOlAIqNewSd1tWFJctJQn7g0SIGV1Dj5FHmI5oMzQg/7p4Ou0UpQEKGfAbsNBLhyQCCTERfOGNTO3YJkjdMjqRJPLf5TYW5Tj+Jlk30k+WJeSYF1L4E7WyW6k59bnIEIHMhzlJeWgM8fywe6LApj9kAmMWja8zPRUR+u0mx0cTEJ8pB8MYFNHzRsXh+5A7Dz8PTsm5b4grROBTU66F/JgVuQ5A4j4NKoPHkBBBuGcAYzqO7NdF9ubyo1c0jqRv66iwOwaDuzcMt5+mFqehEJsbwvOQrajwzCLslhmBw9zYEs6R0pSwpK7eEyQ7U37wuZHyIc95fOas92u/VGP2qO/yKIAogDcDiCcV7shYtz+5+5fAQYAPsQjy46lchAAAAAASUVORK5CYII="/>
If the byte array is a JPEG, it should start with a standard JPEG signature, but yours doesn't. It's hard to tell what's going on since you didn't provide any information about where these bytes came from, but what you should be looking for is something like this:
255 216 255 224 0 16 74 70 73 70
for the first 9 bytes -- the last 4 of those spell "JFIF"
This can vary, but the first two bytes should definitely be FFC0 - start of image
What's a mystery is why the base64-encoded image displays correctly.
Oh I see now: it's a PNG not a JPEG. Check this answer: PHP : binary image data, checking the image type it should help.
There also seems to be something wrong with your conversion since the first bytes of your array are not the same as the first bytes of the base64 png (those are: 0x89, 0x50, 0x4e, or in decimal: 137, 80, 78)
Related
How to decode socket response?
I am try to decode socket response from web source, but I can to decode only 50% of message. It looks strange, because it should be a full message decompress, if it can decompress some socket response, but maybe I wrong. Any help will be greatly appreciated! require "faye/websocket" require "eventmachine" require "permessage_deflate" require 'zlib' require 'stringio' EM.run do ws = Faye::WebSocket::Client.new("wss://wss.winline.ru/data_ng?", [], :extensions => [PermessageDeflate]) ws.on :open do |event| p [:open] ws.send "lang" ws.send "AQ==" ws.send "data" ws.send "WINLINE" ws.send "getdate" ws.send "no_fordata" end ws.on :message do |event| gz = Zlib::GzipReader.new(StringIO.new(event.data.pack('C*'))) puts gz.read end ws.on :close do |event| p [:close, event.code, event.reason] ws = nil end end I have receive the following data: �$��$^���60.5 �$��$^��62.5'!�$i#�$^����31.5�I�$�6�$^���9.5�3�$^���11.5� �$^��10�3�$$W�$^����80:3ূ$�m���&ާ�$�m�id�rݧ�$�m�t �$''�=�v�p��a��0ȣc�Cincinnati BearcatsDetroit Mercy Titans��}$1'':%���}$1''�G���}$1'n| As u can see, some parts of the message are decodable and other is still not. Without decompress, I have this msg from sock: [242, 204, 179, 144, 33, 112, 239, 219, 8, 118, 124, 89, 134, 218, 170, 173, 183, 173, 126, 59, 167, 131, 63, 254, 48, 115, 255, 123, 7, 161, 157, 64, 184, 79, 95, 202, 7, 203, 254, 172, 245, 49, 72, 63, 3, 5, 128, 62, 243, 77, 202, 4, 219, 80, 245, 92, 169, 237, 174, 85, 242, 165, 252, 180, 73, 54, 149, 19, 245, 163, 88, 212, 49, 186, 65, 111, 156, 215, 136, 53, 70, 54, 205, 33, 147, 72, 255, 36, 246, 167, 135, 253, 65, 163, 224, 36, 28, 78, 38, 227, 165, 7, 191, 246, 98, 255, 235, 195, 126, 55, 101, 38, 246, 68, 188, 252, 63, 92, 112, 93, 239, 36, 118, 2, 0] I think, this source are using pako to compress their data socket.
javascript: from a websocket I receive messages as zlib deflate: how to read OR "unflate" OR "deflate" (not inflate)
This question is about converting a gzip deflate message from a websocket message and convert it to array OR raw text that I can apply JSON.parse on it... *** to be also clear: In this question : i use a websocket from a crypto exchange.... but the question is about the received message NOT about crypto exchange in the documentation they say "please use zlib deflate" HERE THE JAVASCRIPT digifinexopen = '{"id":12312,"method":"trades.subscribe","params":["btc_usdt"]}'; digifinex_market_ws = new WebSocket("wss://openapi.digifinex.com/ws/v1/"); digifinex_market_ws.binaryType = "arraybuffer"; digifinex_market_ws.onmessage = event => digifinex_trades(event.data); digifinex_market_ws.onopen = event => digifinex_market_ws.send(digifinexopen); function fu_bitmex_trades (jsonx) { console.log(jsonx); } I have this in the log object=>[[Int8Array]]: Int8Array(1129) 0 … 99] 0: 120 1: -38 I tried with <script src="https://cdnjs.cloudflare.com/ajax/libs/pako/2.0.4/pako.min.js" ...></script> if I do pako.deflate(jsonx); I get object=> Uint8Array(78) [120, 156, 1, 67, 0, 188, 255, 120, 218, 4, 192, 177, 13, 196, 32, 12, 133, 225, 93, 254, 154, 6, 174, 243, 54, 39, 66, 17, 201, 74, 36, 63, 187, 66, 236, 158, 111, 179, 34, 222, 192, 158, 114, 111, 196, 82, 121, 98, 27, 229, 63, 75, 24, 170, 57, 151, 196, 105, 220, 23, 214, 199, 175, 143, 243, 5, 0, 0, 255, 255, 32, 108, 18, 108, 62, 68, 31, If I add decoder = new TextDecoder("utf8"); and log(decoder.decode(jsonx)); I get string=> x�E��xڜ��n\7����'5���* ���$pƋ Ȼ�*��g��#����|�����������������v\�//�_������������ but, HOW TO RETREIVE the array or raw data that I could json.parse ????
If I decompress your data twice, I get: {"error":null,"result":{"status":"success"},"id":12312} It looks like you compressed instead of decompressed. Use pako.inflate().
d3.layout.histogram() and attributes don't work in v4
I would like to "convert" a D3.js v3 based code to D3.js v4. I don't know what I have to change in the following code that it doesnt display any error: var data = d3.layout.histogram() .bins(resolution) .frequency(0) (results); I know that in d3.js v4 there isn't something like d3.layout.histogram() - I only found d3.histogram() in the API. But how do I change the "syntax" of line 2-4 in order to make it working with v4? Thanks in Advance.
According to this article we have the following list of differences between histogram layout in d3v3 and d3v4: d3.layout.histogram becomes d3.histogram .bins becomes .thresholds d3.scale.linear becomes d3.scaleLinear d.x+d.dx becomes d.x1 d.y becomes d.length d.dx becomes d.x1-d.x0 More detailed explanations from d3v4 changelog: The new d3.histogram API replaces d3.layout.histogram. Rather than exposing bin.x and bin.dx on each returned bin, the histogram exposes bin.x0 and bin.x1, guaranteeing that bin.x0 is exactly equal to bin.x1 on the preceeding bin. The “frequency” and “probability” modes are no longer supported; each bin is simply an array of elements from the input data, so bin.length is equal to D3 3.x’s bin.y in frequency mode. To compute a probability distribution, divide the number of elements in each bin by the total number of elements. The histogram.range method has been renamed histogram.domain for consistency with scales. The histogram.bins method has been renamed histogram.thresholds, and no longer accepts an upper value: n thresholds will produce n + 1 bins. If you specify a desired number of bins rather than thresholds, d3.histogram now uses d3.ticks to compute nice bin thresholds. In addition to the default Sturges’ formula, D3 now implements the Freedman-Diaconis rule and Scott’s normal reference rule. So you should rewrite mentioned code snippet this way: var data = d3.histogram() .thresholds(resolution) (results); But you also need to rewrite other parts of your code and replace: d.x+d.dx to d.x1, d.y to d.length and d.dx to d.x1-d.x0. Example how to create histogram layout with d3v4 see in the hidden snippet below: var data = [ 79, 54, 74, 62, 85, 55, 88, 85, 51, 85, 54, 84, 78, 47, 83, 52, 62, 84, 52, 79, 51, 47, 78, 69, 74, 83, 55, 76, 78, 79, 73, 77, 66, 80, 74, 52, 48, 80, 59, 90, 80, 58, 84, 58, 73, 83, 64, 53, 82, 59, 75, 90, 54, 80, 54, 83, 71, 64, 77, 81, 59, 84, 48, 82, 60, 92, 78, 78, 65, 73, 82, 56, 79, 71, 62, 76, 60, 78, 76, 83, 75, 82, 70, 65, 73, 88, 76, 80, 48, 86, 60, 90, 50, 78, 63, 72, 84, 75, 51, 82, 62, 88, 49, 83, 81, 47, 84, 52, 86, 81, 75, 59, 89, 79, 59, 81, 50, 85, 59, 87, 53, 69, 77, 56, 88, 81, 45, 82, 55, 90, 45, 83, 56, 89, 46, 82, 51, 86, 53, 79, 81, 60, 82, 77, 76, 59, 80, 49, 96, 53, 77, 77, 65, 81, 71, 70, 81, 93, 53, 89, 45, 86, 58, 78, 66, 76, 63, 88, 52, 93, 49, 57, 77, 68, 81, 81, 73, 50, 85, 74, 55, 77, 83, 83, 51, 78, 84, 46, 83, 55, 81, 57, 76, 84, 77, 81, 87, 77, 51, 78, 60, 82, 91, 53, 78, 46, 77, 84, 49, 83, 71, 80, 49, 75, 64, 76, 53, 94, 55, 76, 50, 82, 54, 75, 78, 79, 78, 78, 70, 79, 70, 54, 86, 50, 90, 54, 54, 77, 79, 64, 75, 47, 86, 63, 85, 82, 57, 82, 67, 74, 54, 83, 73, 73, 88, 80, 71, 83, 56, 79, 78, 84, 58, 83, 43, 60, 75, 81, 46, 90, 46, 74 ]; var width = 952; var height = 476; var x = d3.scaleLinear().domain([30, 110]).range([0, width]); var bins = d3.histogram().domain(x.domain()).thresholds(x.ticks(30))(data); var max = d3.max(bins, function(d) { return d.y; }); var y = d3.scaleLinear().domain([0, .1]).range([0, height]); var yForHistogram = d3.scaleLinear() .domain([0, d3.max(bins, function(d) { return d.length; })]) .range([height, 0]); var vis = d3.select("body") .append("svg") .attr("width", width) .attr("height", height); var bars = vis.selectAll("g.bar") .data(bins) .enter().append("g") .attr("class", "bar") .attr("transform", function(d) { return "translate(" + x(d.x0) + "," + yForHistogram(d.length) + ")"; }); bars.append("rect") .attr("fill", "steelblue") .attr("width", x(bins[0].x1) - x(bins[0].x0) - 1) .attr("height", function(d) { return height - yForHistogram(d.length); }); <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.12.0/d3.min.js"></script>
Faster way for randomly chosing a value from list and deleting the chosen value
I was wondering if there is a faster way to randomly choose a value from a list and deleting this value from this list so it cannot be chosen again. This drawing of a value will continue until there aint no values left anymore. The way I did it soved the problem but it takes almost 8 seconds. So I'm wondering if there is a faster way. I am using Jupyter notebook through the Anaconda software. Since this goes through a server, could it be the problem? This is what I did: TotalNumbcol = 266 Column_Numbers = list(np.arange(1,TotalNumbcol+1,1)) # creating a list with all column numbers in it from which can be drawn. #print Column_Numbers ABC = Column_Numbers # Creating a variable for the len command in the for loop below, since the Column Numbers length will change. Chosen_Columns = [[0] for i in range(0,len(Column_Numbers))] for i in range(len(ABC)): RandChoiceCol = int(random.choice(Column_Numbers)) # chosing a random number from the Column_Numbers range Chosen_Columns[i]=(RandChoiceCol) # adding each randomly chosen column number to a list in list showing which column has been chosen. Column_Numbers = [x for x in Column_Numbers if x not in Chosen_Columns] # delete chosen_column from RandChoiceCol print Chosen_Columns print Column_Numbers [21, 131, 145, 218, 153, 60, 201, 15, 158, 189, 230, 210, 18, 103, 69, 76, 226, 180, 67, 187, 238, 20, 157, 24, 48, 11, 47, 117, 101, 51, 122, 155, 109, 225, 86, 243, 146, 30, 58, 7, 66, 132, 22, 110, 1, 142, 234, 245, 266, 129, 232, 39, 184, 49, 114, 182, 162, 144, 92, 126, 5, 254, 150, 102, 135, 173, 36, 52, 42, 26, 228, 63, 17, 8, 163, 40, 78, 174, 222, 205, 183, 140, 221, 70, 125, 72, 247, 237, 64, 246, 185, 130, 248, 90, 197, 53, 107, 77, 108, 256, 207, 139, 176, 192, 2, 164, 4, 124, 241, 113, 188, 178, 235, 265, 190, 212, 99, 175, 79, 231, 257, 202, 50, 242, 181, 46, 161, 133, 104, 28, 251, 213, 204, 59, 149, 252, 179, 43, 137, 195, 160, 220, 119, 74, 87, 255, 98, 208, 105, 239, 170, 203, 167, 136, 250, 134, 32, 165, 229, 9, 258, 13, 141, 240, 262, 34, 227, 148, 41, 111, 54, 71, 61, 94, 249, 29, 75, 10, 193, 152, 73, 123, 65, 6, 116, 68, 91, 56, 25, 233, 156, 261, 35, 171, 211, 215, 186, 154, 138, 200, 44, 112, 57, 166, 120, 147, 89, 31, 106, 118, 199, 198, 81, 223, 83, 12, 214, 45, 121, 244, 95, 168, 55, 37, 206, 263, 93, 196, 115, 169, 217, 236, 82, 143, 96, 33, 209, 14, 100, 216, 128, 259, 219, 151, 16, 177, 159, 23, 38, 84, 80, 27, 19, 264, 62, 85, 127, 97, 224, 172, 191, 88, 253, 3, 260, 194] [] If there is a more efficient way saving time please let me know. Regards,
You may just shuffle the list in place instead of creating a new list and a new number every time: Column_Numbers = list(np.arange(1,TotalNumbcol+1,1)) random.shuffle(Column_Numbers) while Column_Numbers: rand = Column_Numbers.pop() print(rand)
Windows phone 7 hebrew support
I have just downloaded windows phone 7.1 sdk for windows phone 7.5. I have two problems: 1. When i create a new project I doesn't see the option to choose windows phone 7 or 7.5 2. Windows phone 7.5 should be based on Silver light 4 but when I create label at my application and write hebrew words it's backwords. Can I solve the problem at this version?
If you have installed the Mango tools, once you select to create a WP7 application you are prompted on a secondary screen to select whether to target 7.0 or 7.1. Note that the version number of the SDK and tools is 7.1 but phones running Mango are marketed as version 7.5. Note that WP7[.1|5] does not yet currently provide native support for RTL languages. You may find a workaround at http://www.danielmoth.com/Blog/RTL-Arabic-And-Hebrew-Support-For-Windows-Phone-7.aspx
For Windows Phone 7 i wrote a mapping function which maps the Arabic encoding[windows-1256] into default WP7 encoding. public static string ConvertToArabic(string s) { short[] mapping = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 8364, 1662, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 1657, 8249, 338, 1670, 1688, 1672, 1711, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 1705, 8482, 1681, 8250, 339, 8204, 8205, 1722, 160, 1548, 162, 163, 164, 165, 166, 167, 168, 169, 1726, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 1563, 187, 188, 189, 190, 1567, 1729, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 215, 1591, 1592, 1593, 1594, 1600, 1601, 1602, 1603, 224, 1604, 226, 1605, 1606, 1607, 1608, 231, 232, 233, 234, 235, 1609, 1610, 238, 239, 1611, 1612, 1613, 1614, 244, 1615, 1616, 247, 1617, 249, 1618, 251, 252, 8206, 8207, 1746 }; string str = string.Empty; for (int ix = 0; ix < s.Length; ++ix) { str = str + (char)mapping[s[ix]]; } return str; } This worked for me well.