write a scheme function that remove the first top level occurrence of a given item
from a list of items.
eg given list (a b c) item b, result list (a c)
plz help me
I am experimenting with HTML5 local storage functionality, but was frustrated to learn that the browser won't allow local storage when the file is local. My guess is that the browser (Chrome in my case, FF too) wants to see a domain rather than a file location. Has anyone here discovered a workaround for developing locally? Perhaps setting up a local domain? That sounds like too much trouble. There should just be a developer option in the browser, grrrrrr.
We have #1 and #2 spots we would like to keep, but because of the way things were jumbled we have to migrate to a new domain.
We do not want the new domain to be penalized for duplicate content, we want it to naturally take the spot on Google.
?????????????
I'd like get far next value for STL list iterator but it doesn't implement operator+, vector has it though. Why and how can I get the value where I want?
I think I can do that if I call operator++ several times, but isn't that a little bit dirty?
What I want to do is the following:
list<int> l;
...omitted...
list<int>::iterator itr = l.begin() + 3; // but, list iterator does not have
// operator+
What is the best solution for what I want?
i have a List and i m grouping it into different lists.
like:-List("a","b","c","it","as","am","cat","can","bat")
3 list List1:-a,b,c List2:-it,as,am List3:-cat,can,bat
how can i concat the all possible combination from this lists.
output like:
a,it,cat
b,it,cat
c,it,cat
a,am,cat
b,am,cat
c,am,cat
.
.
.
.
etc so on...
I have a List of Java objects on my server which is sent to the client through some serialization mechanism. Once in a while the List of objects gets updated on the server, that is, some objects get added, some get deleted and others just change their place in the List. I want to update the List on the client side as well, but send the least possible data. Especially, I don't want to resend Objects which are already available on the client.
Is there a library available which will produce some sort of diff from the two lists, so that I can only send the difference and the new Objects accross the wire?
I have found several Java implementation of the unix diff command, but this algorithm is unpractical for order changes. ie. [A,B,C] - [C,B,A] could be sent as only place changes [1-3] [3-1], while diff will want to resend the whole A and C objects (as far as I understand).
I'm building a Windows Phone application and my client has given me a list of languages that he would like the App to be localized for.
The problem is that some of those languages are not supported by Windows Phone and I then decided to check out the list of supported langauges which is available here. I noticed that there are two OS option for Windows Phone, i.e. 7.0 and 7.1 but during development I am not sure of how to check for which OS the phone is running so that I know which list of languages to supply to the user.
I'd like to know how to check if the Windows Phone OS is 7.0 or 7.1 (I'm assuming that his caters for later OS versions that might have come after the list was created)
I have a dropdown select list on my page of class="TypeFilter".
I have a jQuery event that fires when a value in that list is selected.
$(".TypeFilter").change(function()
{
// Extract value from TypeFilter and update page accordingly
));
I now have to add another list to the page, and I want to implement functionality which will prevent the .change(function() from running unless both are selected.
In both lists the first option in the list is some text instructing the user to select one of the items, so I was thinking of just writing some logic to test that both lists have a selected index greater than 0.
I think this is a touch unclean though, especially considering that other pages that have a TypeFilter use the same logic.
Is there any nifty functionality in jQuery that can do this?
Alright, here's my problem.
I have a thread that creates another thread in a pool, applies async so I can work with the returned data, which is working GREAT. But I need the current thread to WAIT until the result is returned.
Here is the simplified code, as the current script is over 300 lines. I'm sure i've included everything for you to make sense of what I'm attempting:
from multiprocessing.pool import ThreadPool
import threading
pool = ThreadPool(processes=1)
class MyStreamer(TwythonStreamer):
#[...]
def on_success(self, data): #### Everytime data comes in, this is called
#[...]
#<Pseudocode>
if score >= limit
if list exists: Do stuff
elif list does not exist:
#</Pseudocode>
dic = []
dic.append([k1, v1])
did = dict(dic)
async_result = pool.apply_async(self.list_step, args=(did))
return_val = async_result.get()
slug = return_val[0]
idd = return_val[1]
#[...]
def list_step(self, *args):
## CREATE LIST
## RETURN 2 VALUES
class threadStream (threading.Thread):
def __init__(self, auth):
threading.Thread.__init__(self)
self.auth = auth
def run(self):
stream = MyStreamer(auth = auth[0], *auth[0])
stream.statuses.filter(track=auth[1])
t = threadStream(auth=AuthMe)
t.start()
I receive the results as intended, which is great, but how do I make it so this thread t waits for the async_result to come in?? My problem is everytime new data comes in, it seems that the ## CREATE LIST function is called multiple times if similar data comes in quickly enough. So I'm ending up with many lists of the same name when I have code in place to ensure that a list will never be created if the name already exists.
So to reiterate: How do I make this thread wait on the function to complete before accepting new data / continuing. I don't think time.sleep() works because on_success is called when data enters the stream. I don't think Thread.Join() will work either since I have to use a ThreadPool.apply_async to receive the data I need. Is there a hack I can make in the MyStreamer class somehow? I'm kind of at a loss here. Am I over complicating things and can this be simplified to do what I want?
Trying to figure out how to programmatically access the web pages in the application. Just something simple like a list of them would be awesome. I know I can create a list but I was wondering if there was something that could 'look' at the pages and add a new one to the list if you make a new page for the application.
Example with 7 pages:
Error
Default
Login
Content
Users
ContactUs
Admin
I am half awake so I may be a little unclear. Maybe puting it all in a single question will be easier.
How do you autogenerate a list of all webpages in your current application?
I'm having a problem where one Dictionary in my project is either not serializing or not deserializing. After deserializing, the data I serialized is simply not in the object.
Here's the relevant snip of the class being serialized:
class Person : ISerializable {
private Dictionary<Relation,List<int>> Relationships = new Dictionary<Relation,List<int>>();
public Person(SerializationInfo info, StreamingContext context) {
this.Relationships = (Dictionary<Relation, List<int>>) info.GetValue("Relationships", typeof(Dictionary<Relation, List<int>>));
}
public void GetObjectData(SerializationInfo info, StreamingContext context) {
info.AddValue("Relationships", this.Relationships);
}
}
Note, this is binary serialization. Everything else in the project serializes and deserialzes correctly.
I'm new to programing and I'm having a problem with my scanner class. This code is in a loop and when the loop comes around the second, third whatever time I have it set to it skips the first title input.
I need help please why is it skipping my title scanner input in the beginning?
System.out.println("Title:");
list[i].title=keyboard.nextLine();
System.out.println("Author:");
list[i].author=keyboard.nextLine();
System.out.println("Album:");
list[i].album=keyboard.nextLine();
System.out.println("Filename:");
list[i].filename=keyboard.nextLine();
hi,
I'm passing data to a ListView to display some restaurant names. Now when clicking on an item I'd like to start another activity to display more restaurant data. I'm not sure about how to do it. Shall I pass all the restaurant data in a bundle through the intent object? Or shall I just pass the restaurant id and get the data in the other activity? In that case, how can I access my restaurantList from the other activity? In any case, how can I get data from the restaurant I clicked on (the view only contains the name)?
Any help, pointers welcome!
Thanks
Jul
ListView lv= (ListView)findViewById(R.id.listview);
lv.setAdapter( new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,restaurantList.getRestaurantNames()));
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(Atable.this, RestaurantEdit.class);
Bundle b = new Bundle();
//b.putInt("id", ? );
startActivityForResult(i, ACTIVITY_EDIT);
}
});
RestaurantList.java
package org.digitalfarm.atable;
import java.util.ArrayList;
import java.util.List;
public class RestaurantList {
private List<Restaurant> restaurants = new ArrayList<Restaurant>();
public List<Restaurant> getRestaurants() {
return this.restaurants;
}
public void setRestaurants(List<Restaurant> restaurants) {
this.restaurants = restaurants;
}
public List<String> getRestaurantNames() {
List<String> restaurantNames = new ArrayList<String>();
for (int i=0; i<this.restaurants.size(); i++) {
restaurantNames.add(this.restaurants.get(i).getName());
}
return restaurantNames;
}
}
Restaurant.java
package org.digitalfarm.atable;
public class Restaurant {
private int id;
private String name;
private float latitude;
private float longitude;
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public float getLatitude() {
return this.latitude;
}
public void setLatitude(float latitude) {
this.latitude = latitude;
}
public float getLongitude() {
return this.longitude;
}
public void setLongitude(float longitude) {
this.longitude = longitude;
}
}
Hi,
I've got the following type of SQL:
UPDATE photo AS f
LEFT JOIN car AS c
ON f.car_id=c.car_id
SET f.photo_status=1
, c.photo_count=c.photo_count+1
WHERE f.photo_id IN ($ids)
Basically, two tables (car & photo) are related. The list in $ids contains unique photo ids, such as (34, 87, 98, 12). With the query, I'm setting the status of each photo in that list to "1" in the photo table and simultaneously incrementing the photo count in the car table for the car at hand.
It works but there's one snag: Because the list can contain multiple photo ids that relate to the same car, the photo count only ever gets incremented once. If the list had 10 photos associated with the same car, photo_count would become 1 .... whereas I'd like to increment it to 10.
Is there a way to make the incrementation occur for each photo individually through the join, as opposed to MySQL overthinking it for me?
I hope the above makes sense. Thanks.
hi,
i have to pages:
domain.com/
domain.com/post.php?id=43
Inside the second page i have added Disqus comments... but i need to know the number of comments in that post in the first page (post list). Is it feasible?
I need to pass two array list references to a function and return the reference of merged array list.
how can i do it????
pls help....
public int merge(ArrayList x, ArrayList y)
{
List all = new ArrayList();
all.addAll(x);
all.addAll(y);
System.out.println(all);
return all;
}
is it correct???
I'm preparing for a major overhaul of our shopping cart, which is going to completely change how the urls are structured. For what its worth, this is for Magento 1.7.
An example URL would be:
{domain}/item/sub-domain/sub-sub-domain-5-16-7-16-/8083770?plpver=98&categid=1027&prodid=8090&origin=keyword
and redirect it to {domain}/catalogsearch/result/?q=8083710
My web.config is:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Magento Required" stopProcessing="false">
<match url=".*" ignoreCase="false" /> <conditions>
<add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions> <action type="Rewrite" url="index.php" />
</rule>
<rule name="Item Redirect" stopProcessing="true">
<match url="^item/([_\-a-zA-Z0-9]+)/([_\-a-zA-Z0-9]+)/([_\-a-zA-Z0-9]+)(\?.*)" />
<action type="Redirect" url="catalogsearch/result/?q={R:3}" appendQueryString="true" redirectType="Permanent" />
<conditions trackAllCaptures="true">
</conditions>
</rule>
</rules>
</rewrite>
<httpProtocol allowKeepAlive="false" />
<caching enabled="false" />
<urlCompression doDynamicCompression="true" />
</system.webServer>
</configuration>
Right now it seems the redirect is completely ignored, even though in the IIS GUI the sample url passes the regex test. Is there a better way to redirect or is there something wrong with my web.config?
I have two tables in my database, one contains a list of items with other information on these items. The other table is contains a list of photographs of these items.
The items table gives each item a unique identifier,which is used in the photographs table to identifier which item has been photographed.
I need to output a list of items that are not linked to a photograph in the second table. Any ideas on how I can do this?
I want to implement a hash table in the following manner:
struct list
{
char *string;
struct list *next;
};
struct hash_table
{
int size; /* the size of the table */
struct list **table; /* the table elements */
};
Instead of struct hash_table like above, can I use:
struct hash_table
{
int size; /* the size of the table */
struct list *table; /* the table elements */
};
That is, can I just use a single pointer instead of a double pointer for the hash table elements? If yes, please explain the difference in the way the elements will be stored in the table?
Libev uses three data structures to storage different watchers.
Heap: for watchers that sorted by time, such as ev_timer and ev_periodic.
Linked list: such as ev_io, ev_signal, ev_child and etc.
Array: such as ev_prepare, ev_check, ev_async and etc.
There is no doubt about that uses heap to store timer watcher. But what is the criteria of selecting linked list and array?
The data structure that stores ev_io watchers seems a little complex. It first is an array that with fd as its index and the element in the array is a linked list of ev_io watcher. It is more convenient to allocate space for array if use linked list as element. Is it the reason?
Or just because of the insert or remove operation of ev_io is more frequently and the ev_prepare seems more stable?
Or any other reasons?
Hello
I am trying to make a list of things which can be difficult/surprising to someone who is changing language from PHP to Python.
so far i have rather short list:
forget require / include, learn import (this was most difficult to me - to understand package - module - class - object hierarchy and its mapping to filesystem)
you can't just upload file on server to have webpage (-mod_python, wsgi etc)
learn the python way for use variable class names (new $class() vs import + getattr)
/ operator in python 2.x and all float-related horrors
those were difficult to me, it takes few days before mind adapts a new paradigm
after i found that there is few other areas which could be challenging for someone with (too) many years of php:
everything is an object
you have to live with exceptions
array vs list, set, dictionary, tuple ...
learn (effective) list comprehensions
learn generators
any other ideas / personal experiences ?
I will give some examples and explain. First, I declare some object like
CString* param = new CString[100]
And when I declare this one, my memory would increase a little bit because it's some implemented string. Then I store this object in some list of CString just like
List<CString> myList = new List<CString>; // new list of CString
myList.add(param);
This is my question: I wanna know, when I delete myList, my param isn't deleted, right? And memory in param still exists.
Do I misunderstand?
Is it possible to step into a linq query? I have a linq to entity framework 4 query in it's simplest form:
List = List.Where(f => f.Value.ToString().ToLowerInvariant().Contains(filter.ToLowerInvariant()));
It's a query against an Entity Framework DbContext and I'm having trouble seeing why it works for something like:
List searching for 001 yields no results against the following list
Test001
Test002
Test003
Test004
However any other search yields results (Such as t00 or Test)
I was hoping to figure out a way to see the resulting sql but it appears that I need Intellitrace, which I don't currently have or possibly stepping through the query itself and see each iteration build itself.
Is it possible to use Generics when passing a class to a java function?
I was hoping to do something like this:
public static class DoStuff
{
public <T extends Class<List>> void doStuffToList(T className)
{
System.out.println(className);
}
public void test()
{
doStuffToList(List.class); // compiles
doStuffToList(ArrayList.class); // compiler error (undesired behaviour)
doStuffToList(Integer.class); // compiler error (desired behaviour)
}
}
Ideally the List.class and ArrayList.class lines would work fine, but the Integer.class line would cause a compile error. I could use Class as my type instead of T extends Class<List> but then I won't catch the Integer.class case above.