Use negative indices in the list

Usually in Python if we put lst[-1] we mean the item at the length of lst. But I would like to make it where it means "before index 0". Is such a thing possible? I've looked around but I haven't found anything useful yet. Currently I'm working o

A better way to solve this grid search problem?

I have a grid (not necessarily a square but I drew it as a square to simplify it) and certain values associated with each of the smaller squares. Given a circle of radius x, I am trying to find the region where the sum of the values is the maximum. T

Replace the table of words

x.replace(/old/gi. 'new'); x.replace(/whatever/gi. 'whatevernew'); x.replace(/car/gi. 'boat'); Is there a way to combine those in one regexp statement perhaps and array of old and new words. PHP solution is also welcome.Try this: var regexes = { 'new

Positioning of .NET controls

I want my label "The Top Row" to be positioned near the top row of my gridview as I indicated with yellow below, I tried absolute positioning the lable but when displayed, there are problems with it. What is the best way to do this ? (float righ

DataGridView & ldquo; Enter & rdquo; Managing key events

I have a DataGridView populated with DataTable, have 10 columns. I have a scenario when moving from one row to another when I click on Enter key then I need that row should be selected and need to have that row values. But here when I select n-th row

Completed data sent to subscribers EventMachine pubsub

Stack: Ruby 2.3.1, Rack, thin Simple websocket server: require 'redis' require 'em-hiredis' require 'faye/websocket' require 'json' ws_channel = {} App = lambda do |env| $redis ||= EM::Hiredis.connect('redis://') if Faye::WebSocket.webs

Android tools do not work on IntelliJ

I recently moved from eclipse to Intellij and I have problem with using Android tools. When I click Tools->Android->Monitor(DDMS included) I get error saying: Failed to load the JNI shared library "C:\Program Files\Java\jdk1.7.0_17\bin..\jre\bi

Why is the heap broken in java?

How the performance of the JVM is enhanced by breaking the heap memory in small parts ? such as- 1-Young Generation 2-Old or Tenured Generation 3-Permanent Generation?It is based on the assumption, that you have 3 types of objects in memory: temporar

Divide a large text file with php

I have a big txt file (84mb) with over 1 million lines. I want to split it in seperate 50k lines files. How can i do it? I searched on-line but I found nothing about it.This is a modified version of my script at : Read through huge text files and sto

The Phonegap 3 application does not enter deviceready ()

I've recently managed to upgrade my version of Phonegap from 2.9 to 3.3 and have only just now managed to upgrade my project to work in 3.3 I am now getting an error where my application will not enter the deviceready() state. Prior to changing to +3

How to Use Scanner to Only Accept Valid Inputs

I'm trying to make a small program more robust and I need some help with that. Scanner kb = new Scanner(; int num1; int num2 = 0; System.out.print("Enter number 1: "); num1 = kb.nextInt(); while(num2<num1) { System.out.print("E

Laravel 4: Get Json Database Tables

I have tables festivals, addressess and locations. A festival has one address and a address has one location. Now I want to get json from these 3 tables with laravel. At the moment I get festivals and addresses. How to retrieve the 3th table location

new to mysql question php

I have a table in my database that looks like this: |id|team_name|team_url|xml| I have a cronjob that calls a script. In this script, I want to use my class to check if the url exists, and if it doesn't, delete the entry in the database. Something li

PyODBC producing an unsuitable UTF-16

I'm trying to pull out a list of table names from a MySQL database. The pertinent parts of the code are as follows: conn = pyodbc.connect('...') cursor = conn.cursor() for table in cursor.tables(): print table.table_name For every table it prints a b

C # Change registry settings for all users

I am writing a small program using C# that needs to set set the power settings for all users. This means I will need to change the Hkey Current User, and all the profiles under the Hkey Users hive. I know how to change the power settings registry key

Why is this loop so slow in Cython?

This code rearranges the bits in a 534x713 RGBA4 texture. cpdef bytes toDDSrgba4(bytearray data): cdef bytes new_data = b'' cdef int pixel cdef int red cdef int green cdef int blue cdef int alpha cdef int new_pixel cdef int i for i in range(len(data)

sort by a field

var course = from b in where == "test" select b; DataTable dt = new DataTable(); DataRow dr; dt.Columns.Add(new DataColumn("name", typeof(string))); dt.Columns.Add(new DataColumn("id", typeof(int))); fo

Dividing multiword $ _POST input

I am trying to have a PHP form that takes in a text input, then queries the underlying MySQL table. <form method="GET" action="search.php" name ="SearchBar"> <input type="text" name"search"> &l

TransactionScope and isolation level

we have a problem to use TransactionScope. TransactionScope get to us very good flexibility to use transactions across our Data Access Layer. On this way we can use transactions implicit or explicit. There are some performance boost again ADO.NET tra

How it calls the new design of iOS navigation

I am looking for a template or feature of the design like in facebook. the navigation if you swipe left you can choose another menu point. If you have a name or something else I dont know how can i looking in the internet.Here are two quick links by

Hook event loading object in Entity Framework?

Is there an EF equivalent to LINQ to SQL's OnCreated partial? Several of my objects have XML fields that I would like to parse whenever the object is loaded from the db - I'd like to put the XML data into more friendly strongly-typed collections. I'v

How to compile a standalone OpenCV executable?

I compile my my OpenCV programs as follows: g++ `pkg-config --cflags opencv --libs opencv` <filename>.cpp It works perfectly on my computer. Can I complile the shared libraries alone with the program so that it can be run on other computers which do