I was wanting to know how I get the last two ids from the table based on certain conditions
for example, if today is 1st July, I want to get the id of record for today and then the id of the record before this.
Please note that the id for the previous record might be different, as this is sorted by date, so previous_id = current_id - 1...
In my case, every "item" either has a property , or not. The properties can be some hundreds, so I will need , say, max 1000 true/false bits per item.
Is there a way to store those bits in one field of the item ?
...
Hi,
I want to pass many arguments to a shell script which I don't know how many arguments they are going to be and I want to handle them. I did the following code:
int=$1
src=$2
r=$3
string=$4
duration=$5
./start.sh $int $r $src "$string"
sleep $duration
shift; shift; shift; shift; shift
while [ $# -gt 2 ]
do
r=$1
string=$2
...
Hello.
Assume I declared an Array isFind[] like this,
bool[] isFind = new bool[5];
for (int i = 0; i < 5; ++i)
{
isFind[i] = init(); // initialize isFind[]
}
bool init();
{
...; // some code here
}
Is there any quick method (less typing code) to detect there is false element or not in isFind[]?
I don't want to for/foreach Loo...
Hi!
Assume we have an array of length N where the subarrays from 0 to N/2 and N/2 to N elements are sorted. Is it possible to sort the whole array using constant memory in O(N) time?
Example of an array:
10, 20, 30, 40, 1, 2, 35, 60
...
Is there anything bad with this code?
The thing is that the "test" is not displayed in ListView.
Java:
private ListView namesListView;
private ArrayList<String> names;
private ArrayAdapter<String> namesAA;
...
namesListView = (ListView)findViewById(R.id.list);
names = new ArrayList<String>();
names.clear();
names.add(0, "test");
name...
Hello,
Essentially, the situation is as follows:
I have a class template (using one template parameter length of type int) and want to introduce a static array. This array should be of length length and contain the elements 1 to length.
The code looks as follows up to now:
template<int length>
class myClass{
static int array[leng...
This is not a homework. Just an interesting task :)
Given a complete binary search three represensted by array. Sort the array in O(n) using constant memory.
Example:
Tree:
8
/ \
4 12
/\ / \
2 6 10 14
/\ /\ /\ /\
1 3 5 7 9 11 13 15
Array:...
What does $_GET return when the index is not set? (Couldn't find anything in php manual about $_GET.)
I wrote this to check, if the $_GET['id'] isset - and if it is not, set $id to false:
<?php $id = (isset($_GET['id'])) ? $_GET['id'] : false ?>
...
Hey all,
In the below javascript, "this" refers to Car object and search_id refers to the input text field with an id of "search_input". So basically the user types in text in the field and a search occurs based on the input. Now I understand that the val() method is grabbing the user input string from the input field. However, I am not...
So I'm setting up a system that has a lot of emails, and variable replacement within it, so I'm writing a class to manage some variable replacement for templates stored in the database.
Here's a brief example:
// template is stored in db, so that's how this would get loaded in
$template = "Hello, %customer_name%, thank you for contact...
In my database, some field settings are serialized and stored. When I do this:
print_r(unserialized($r['settings']));
I'll get this:
Array (
[prefix] =>
[suffix] =>
[min] =>
[max] =>
[allowed_values] => 1|Common 2|Rare 3|Almost Extinct
)
I'm trying to create an array based on the values for allowed_values like this:
Array (...
I need to swap first n elements from two non repeating sequences(arrays), where n is a random integer.
Seq1: 1 4 5 6 9 8 2 3 7
Seq2: 3 9 1 2 8 7 4 5 6
If n = 4
Seq1: 3 9 1 2 | 9 8 2 3 7
Seq2: 1 4 5 6 | 8 7 4 5 6
Now i need to repair the sequence by replacing the repeated numbers after '|'.
How to do this?
This is my effort..
for...
I thought that if a C# array held reference types it would simply hold references to each of the objects, however the code below tells me otherwise. It appears as if the array is holding a reference to an object of which I thought was set to be garbage collected. I feel like i'm missing something fundamental here. Can anyone tell me w...
I am using CURL to post an array. It didn't work without using http_build_query(). I set one of the rows in the array like this:
$postVars['key']='
<table style="border-style: solid;" width="850" align="center" bgcolor="#e9e9e9" border="3" bordercolor="#999999" cellpadding="0" cellspacing="0">
<tbody><tr>
<td colspa...
I have the following code:
self.itemsCopy = [self.items mutableCopy];
//[self.itemsCopy addObjectsFromArray:self.items];
NSLog(@"------- BEFORE APPEND --------");
NSLog(@"items count: %d",[items count]);
NSLog(@"itemsCopy count: %d",[itemsCopy count]);
My results are:
------- BEFORE APPEND --------
items count:...
I have about 30 different flagged enums that I would like to put into an array for indexing and quick access. Let me also claify that I do not have 1 enum with 30 values but I have 30 enums with differing amounts of values.
The goal would be to add them to an array at a specifed index. This way I can write a functions in which I can pas...
int[] array1 = {1, 2, 3, 4, 5, 6, ,7, 8}; - working
array1 = {1, 1, 1, 1, 2, 5, ,7, 8}; - NOT working
The first line is working, but second line is not working.
How can I make the initialization from the second line in one single line of code?
...
So i have an array that contains 100 elements
foreach($obj as $element){
//do something
}
I want to loop through the first 50 but the problem is sometimes the $obj array maybe less then 50
...
Say I have an array of integers:
arr = [0,5,7,8,11,16]
and I have another integer:
n = 6
I need a function that rounds down to the nearest number from the array:
foo(n) #=> 5
As you can see, the numbers do not have a fixed pattern. What's an elegant way to do this?
Thanks
...