Print a random row from a mysql query

:I was looking for a way of creating a collaborative translation widget. So I have a mysql database and table (called translations), and a little script to allow users to translate one page at a time.But I'm not quite convinced with my script. I don't t

Delphi Web Script (DWScript) link a script method to an external control event

:I'm wondering if DWScript supports using a script method as an event handler for a control on a Delphi form. For example I want to link a TButton OnClick event to a method that exists in script. I am able to do this with the RemObjects Delphi script en

Validation not working in partial view

:I have an Index page which has two partial views: login and register.I am using data model validation.Login.cshtml@model Project.ViewModel.UserModel@using (Html.BeginForm("_Login", "account")){ @Html.ValidationSumm

Using JavaScript to inflate a blob?

:I'm using a websocket to send a Jpeg image in blob form. I've compressed (gzipped) the blob but I'm unable to find a way to decompress it using JavaScript. Does anyone know how? This is the code I'm using to read the blob and then convert it into a

How to generate SQL Script from MySQL Workbench using Command Line?

:I'm currently using FinalBuilder to create a one-click building n’ generate install, but I faced with MySQL Workbench lack of capacity to generate SQL script from a command line. 1:You can actually automate this task with Python (or Lua) script - MyS

Why are unboxed arrays not an instance of foldable?

:Figuring out the correct data container to use can be a bit tricky in Haskell, for my 2D grid application I thought using UArray would be appropriate. However, as far as I can tell UArray is not an instance of foldable (not in Data.Array.IArray nor Data

ExecuteCore() vs OnActionExecuting(ActionExecutingContext filterContext)?

:Just curious, they sound similar. What are the differences between ExecuteCore() vs OnActionExecuting(ActionExecutingContext filterContext)?In what situations would one be more useful over the other? 1:Actually, they're just different points in MVC e

Page shows code not rendering

:I know this is simple question, but i am fighting with it for few hrs, so its better to ask in forum to get help quickly. I have added the following simple html snippet in a TextEdit program and saved the file as webpage(.html). When I run this file in a

Redefining enum enumerators with #define

:I have spotted something in C header files what I can't figure out what is for. For example in file bits/socket.h there is an enumeration type enum __socket_type, but after every enumerator there is a define macro which defines the same. Example:enum _

Using a generic type argument with `typeof T`

:I have a factory-like function that is meant to return an sub-class instance of BaseApi. It currently looks something like this (trimmed out irrelevant parts):function getApi(apiClass: typeof BaseApi): T { return new apiClass();}And

Creating a dataframe in pandas by multiplying two series together

:Say I have two series in pandas, series A and series B. How do I create a dataframe in which all of those values are multiplied together, i.e. with series A down the left hand side and series B along the top. Basically the same concept as this, where ser

Using a previously defined #define in a new #define in C

:Are there any potential issues/dangers in doing something such as#define SAMPLERATE 32 // Sample rate in hertz#define ONE_MINUTE ( SAMPLERATE * 60 )#define FIVE_MINUTES ( ONE_MINUTE * 5 ) My compiler doesn't issue any errors or warnings. It's very nic

Huge performance differences between sum(column_name), sum(1) and count(*) on a large dataset

:EDIT:Since you guys suggested creating separate tables for player/tournament names and replacing strings with foreign keys I did the following:SELECT DISTINCT tournament INTO tournaments FROM chess_data2ALTER TABLE tournaments ADD COLUMN id SERIAL PRIMAR

How to achieve dynamic UIView masking?

:I'm trying to achieve a sort of dynamic UIView masking effect. Here is a sketch:So as you can see, I'm trying to create a UIView that can effectively cut through an image to reveal the image behind it. I already know how to return an image with a mask

how do I query SQLite database with two conditions?

:I have a table about employee with 3 columns like following code: db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + DEPT + " TEXT NOT NULL," + NAME + " TEXT NOT NULL,"

Express redirecting doesn't change req.url

:I have a route that redirects upon successful'/login', function(req, res){ if(req.body.password === Server.cfg.auth.userPass) { req.session.user = {nick: req.body.username, pass: req.body.password} res.redirect('/chat') } else

What is the @InlineOnly annotation?

:I often see the @InlineOnly annotation when browsing Kotlin's stdlib. As far as I recall the annotation only happens to be on inline functions. What is the purpose of this annotation? Isn't it obvious that inline functions are always inlined? It's doc

bin directory and PATH

:I'm beginner in programming. Can somebody please explain (by simple words) what do I have inside the bin directory of program?What is this PATH environment variable of windows, how does it work (please don't think that I don't know how to use Google,

How to extract current date in watson conversation

:I need to create a condition, in Watson Conversation dialog model, like this:if "today's date" < 04-15-2017 do something.else do something else.I prefer not asking the user for current date and save it.I tried many ways but they don't work, I also tr

NSString stringWithFormat return type, why is it “id”?

:Why does the method [NSString stringWithFormat] return an id type? From the name I'm expecting it returns a NSString, not a generic pointer. Other classes follow this "rule". For example [NSNumber numberWithInt] returns a NSNumber, not an id.I think i

Are multiple calls to string.Replace() less efficient than a single call to a Regex method in .NET?

:I want to replace about 8 characters in a string.Would it be more efficient to use a Regex method or just use multiple calls to string.Replace()I'm replacing about 7 characters that may appear, all to be underscores instead. The characters could appear

How to get around the Coverage Condition for Functional Dependencies without using -XUndecidableInst

:Wen using functional dependencies, I frequently hit the Coverage Condition. It is possible to lift it with UndecidableInstances, but I usually try to stay away from that extension.Here is a somewhat contrived example, that works without UndecidableInsta

Triple join in Ruby on Rails

:I have question regarding associations in Ruby on Rails. In the application there are projects, users, roles and groups. The project belongs to a group with users, a user can belong to many different groups but can only have one specific role within that

JIT optimizer for C/C++

:I was reading about the advantages of JIT over precompiled and one of those mentioned was that a JIT could adjust branch predictions based on actual runtime data. Now it's been a long time since I wrote a compiler in college, but it seems to me that so

Linq - Get the Index of the Last Non-Zero Number of Array

:Is there a Linq expression that returns the index of the last non-zero value in an array? I'm not interested in an extension, only a simple linq expression.I'm imagining something like this pseudo code:int index = {0, 2, 1}.LastOrDefaultAt(i => i > 0);