2018-10-22         Lester

Why does the Interpreter Pattern suck?

In Steve Yegge's review of Design Patterns, he calls the Interpreter Pattern an "in-joke". He goes on to talk about how the perception of compilers have changed, yet how interpreted languages are still s*** on, although I can't see how this ties into the pattern.Anyone want to enlighten this ignorant student? That was irony :) Everybody loves interpreted languages nowadays but 10 years earlier people just thought they are too slow for anything practical. Much like today most of people thinks about static vs. dynamic typing. [XXX]The INTERPRETER pattern sucks because i...

 design-patterns                     3 answers                     68 view
 2018-10-22         Lester

Trying to get an image overlay and image zoom to appear at same time on mouse hover

I'm having difficulty trying to get an image overlay and image zoom to appear at the same time on mouse hover. For some reason, the overlay disappears when I added the image zoom. It seems like one webkit transition cancels the other out. Either the zoom will work or the overlay will appear but not both. Any help is greatly appreciated, I've been researching for hours and can't seem to figure it out. HTML Code: <div class="image_wrap"> <div class="caption"> <i class="fa fa-search-plus" aria-hidden="true"></i> <p class="heading">...

 html                     1 answers                     73 view
 2018-10-22         Lester

How to make this a separate function in typescript?

There is an inbuilt method to get the browser width and height in protractor or webdriver APIbrowser.manage().window().getSize().then(function(size) {return size.width;}); How can i convert above in a single method ?I want to use that method in an if condition within my tests e.g. if (width > 500) {it ('test following', () => {expectations goes here});} The manage().window().getSize() has to be executed in the Protractor's control flow which would not be yet initialized if you call it outside of before*(), after*() or it() contexts. Just put your condition into the...

 typescript                     1 answers                     76 view
 2018-10-22         Lester

Enemies in pygame

Hey i'm making this space shooter game in pygame and want to spawn 10 enemies at a time. Here is the code i used: blocks.append([random.randrange(0, display_width),0]) for block in blocks: pygame.draw.rect(game_display, green, (block[0],block[1], 30, 40)) for leng in range(len(blocks)): blocks[leng][1]+=10 for block in blocks: if block[1]<0: blocks.remove(block)Using this code, my screen gets filled with enemies(green rects). Is there any way i can spawn a certain number of enemies at a time and keep spawning more i...

 python                     1 answers                     67 view
 2018-10-22         Lester

Indent, pretty-print code including Django template tags, HTML, CSS, and JavaScript

In dealing with a bunch of crufty Django template files, I want to indent them.The files contain:HTML, the bulk of the file. Maybe a pre tag or two.JavaScript, inside script tags.CSS inside the style tagsDjango template directives inside {% ... %} pairs.Surely there is a tool to do this. Most of the tools do silly things when facing unexpected characters. Which one works?To clarify, what properly indents this code?{% extends 'layout.html' %}{% if admin %}<style type="text/css">body { color: purple; background-color: #d8da3d }</style><p><b>ADMIN...

 javascript                     2 answers                     64 view
 2018-10-22         Lester

UISegmentedControl delegate/Touch Events

I have a UISegmentedControl that has six segments, I want them to call a method when the value changes, but also when each segment gets a UIControlEventTouchDragIn because I want a UILabel to show up with it's name when the person is trying to select something on it and drags their finger across the control, but the segmented control does not sen this call even when I drag into the thing. Please help. Maybe I need to create UIButtons over the control that call methods upon a drag in, but call the value changed method when they recieve a tap. You could just subclass the U...

 iphone                     2 answers                     25 view
 2018-10-22         Lester

in C, a variable doesn't retain the value i assign it and goes back to 0

I am writing a simple game engine in C and I have come across a very odd problem.//SANJIobjs[1].animation = 1;objs[1].pho.h = 52;objs[1].pho.w = 25;objs[1].pho.tmp_pos.x = 190;objs[1].pho.tmp_pos.y = 40;objs[1].pho.gravity = 1;objs[1].hp = 10;printf("%d\n", objs[1].hp);//outputs 0???????It seems no matter what I do the variable (member) hp is refusing to accept the assignment and goes back to 0. I tried searching with Google, but I am afraid I am unable to phrase this problem accurately.EDIT:this is the definition of the OBJ struct:struct OBJ{//animationchar animation;//if...

 c                     1 answers                     61 view
 2018-10-22         Lester

MySQL query to fetch data using date range

This query is giving correct result in MySql workbench -SELECT tbl_visit_info.visitor_id,tbl_visit_info.retailer_id,tbl_retailer.retailer_shop_name, SUM( IF( tbl_visit_info.activity_type = 1 ,1,0)) AS feedback,SUM( IF( tbl_visit_info.activity_type = 2 ,1,0)) AS promise_order,SUM( IF( tbl_visit_info.activity_type = 3 ,1,0)) AS stock,SUM( IF( tbl_visit_info.activity_type = 6 ,1,0)) AS payment,tbl_visit_info.date as visit_dateFROM tbl_visit_info,tbl_retailer where tbl_visit_info.retailer_id=tbl_retailer.retailer_id and tbl_visit_info.visitor_id=80group by visitor_id,retailer_...

 php                     1 answers                     44 view
 2018-10-22         Lester

SQL Get max value for every n rows

Say I have a table with two columns: the time and the value. I want to be able to get a table with the max values during every n seconds. If I want the max value for every 3 seconds, the following table:time value1 62 13 44 25 56 17 18 39 7Should return:time value1 65 59 7These are the rows with the max value for each period of 3 seconds (1-3, 4-6, 7-9). Is there a way to do this directly with an sql query? Ref: https://stackoverflow.com/a/6693606/10240461Querying the max value of a column in S...

 sql                     5 answers                     96 view
 2018-10-22         Lester

Using SSIS to map hard coded values as part of a one-to-many table migration in Visual Studio

Using SQL Server 2005 and Visual Studio 2005, I'm trying to create a SSIS package to merge data from 1 table to several other tables.The source table does not have a several fields that the destination tables do. For example 'CreatedBy' and 'CreatedDate' fields. I would like these to be hard coded (in a sense) as part of the package import process.The problem is not knowing what to use to facilitate this mapping. As a starting point it would be acceptable to have a hard coded '1' and GetDate() for createdBy and createdDate respectively.The "Input and Output Properties" or "...

 sql-server                     2 answers                     101 view
 2018-10-22         Lester

How might I convert Intel 80386 Machine Code to Assembly Language?

I've been given the following task: Consider the following sequence of hexadecimal values: 55 89 E5 83 EC 08 83 E4 F0 31 C9 BA 01 00 00 00 B8 0D 00 00 00 01 D1 01 CA 48 79 F9 31 C0 C9 C3 This sequence of bytes represents a subroutine in Intel 80386 machine language in 32-bit mode. When the instructions in this subroutine are executed, they leave values in the registers %ecx and %edx. What are the values? What is the program in C that carries out the computation done by this subroutine, then prints the values computed by this program of %ecx and %edx as they wou...

 assembly                     6 answers                     94 view
 2018-10-22         Lester

Python - Writing a Large JSON Array To File

I am working on a process that will likely end up attempting to serialize very large json arrays to file. So loading up the entire array in memory and just dumping to file won't work. I need to stream the individual items to file to avoid out of memory issues.Surprisingly, I can't find any examples of doing this. The code snippet below is something I've cobbled together. Is there a better way to do this?first_item = Truewith open('big_json_array.json', 'w') as out: out.write('[') for item in some_very_big_iterator: if first_item: out.write...

 python                     1 answers                     95 view
 2018-10-22         Lester

Unable to push to Azure container registry

While trying to push new containers to the Azure container registry, I get the following errors.Successfully built b5f5a0e4c64bSuccessfully tagged dekkiotest1.azurecr.io:5000/c4module:0.0.1-amd64The push refers to repository [dekkiotest1.azurecr.io:5000/c4module]Get https://dekkiotest1.azurecr.io:5000/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)I have verified that this only occurs for new images I'm trying to push. I can update existing images alright. I have verified that the registry has memory available. ...

 azure                     1 answers                     21 view
 2018-10-22         Lester

SQLite query list objects contain only default property values

I am trying to work with an SQLite database in a Xamarin.Forms Android application. When querying the table I am having issues getting the columns to map to properties in my Game class. All properties are being returned as null.I have a class Game that contains several fields, Name, Type, ...public class Game { public string Name { get; set; } public int MinPlayers { get; set; } public int MaxPlayers { get; set; } public string Type { get; set; } public string IsParty { get; set; }}My table looks like this:Games| Name | MinPlayers | MaxPlayers | Type | IsPar...

 c#                     1 answers                     13 view
 2018-10-22         Lester

How to initialize Multiple List<string> by using a given name List<string>

Is there a function I can use to initialize Multiple List by using a given name List?For example:List<string> nw_TCList = new List<string>();List<string> ia_TCList = new List<string>();List<string> st_TCList = new List<string>();List<string> ud_TCList = new List<string>();List<string> mb_TCList = new List<string>();I would like to create thoese List, right now i have a List contains thoese name:List<string> myNameList = new List<string>() { "nw_TCList", "ia_TCList", "st_TCList", "ud_TCLis...

 c#                     3 answers                     84 view
 2018-10-22         Lester

How to display definition of a class in Python

I was going through this question : How do I return the definition of a class in python?But I am unable to display the class definition. I am getting the below error:>>> class A:... pass...>>> import inspect>>> source_text = inspect.getsource(A)Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\**\Python\Python36\lib\inspect.py", line 968, in getsource lines, lnum = getsourcelines(object) File "C:\Users\**\Python\Python36\lib\inspect.py", line 955, in getsourcelines lines, lnum = findsour...

 python                     1 answers                     38 view

Page 1 of 144  |  Show More Pages:  Top Prev Next Last