Could dynamically be got a pointer to a type?
type foo struct {
A uint8
B string
}
func Testing() (*foo) {...}
Using an interface?
func Testing() (*interface{}) {...}
I often have a command that processes one file, and I want to run it on every file in a directory. Is there any built-in way to do this?
For example, say I have a program data which outputs an important number about a file:
./data foo
137
./data bar
42
I want to run it on every file in the directory in some manner like this:
map data `ls *`
ls * | map data
to yield output like this:
foo: 137
bar: 42
There are plenty of questions on stackoverflow from people who have attempted to create an array of generics like so:
ArrayList<Foo>[] poo = new ArrayList<Foo>[5];
And the answer of course is that the Java specification doesn't allow you to declare an array of generics.
My question however is why ? What is the technical reason underlying this restriction in the java language or java vm? It's a technical curiosity I've always wondered about.
In Windows the Dropbox client uses python25.dll and the MS C runtime libraries (msvcp71.dll, etc). On OS X the Python code is compiled bytecode (pyc).
My guess is they are using a common library they have written then just have to use different hooks for the different platforms.
What method of development is this? It clearly isn't IronPython or PyObjC. This paradigm is so appealing to me, but my CS foo and Google foo are failing me.
In Javascript, if an object has lots of properties that are functions:
var obj = { foo: function() { ... },
bar: function() { ... },
...
}
then how can you get an array of names of those functions? That is, an array
["foo", "bar", ... ]
thanks.
How do I find the name of the namespace or module 'Foo' in the filter below?
class ApplicationController < ActionController::Base
def get_module_name
@module_name = ???
end
end
class Foo::BarController < ApplicationController
before_filter :get_module_name
end
Is there a way to remove the scroll bar in a select element with the 'multiple' attribute enabled?
<select name="test" multiple>
<option value="foo">Foo</option>
<option value="bar">Bar</option>
<option value="baz">Baz</option>
</select>
I'm trying to resolve two URIs, but it's not as straightforward as I'd like it to be.
URI a = new URI("http://www.foo.com");
URI b = new URI("bar.html");
The trouble is that a.resolve(b).toString() is now "http://www.foo.combar.html". How can I get away with that?
Given a PyObject* pointing to a python object, how do I invoke one of the object methods? The documentation never gives an example of this:
PyObject* obj = ....
PyObject* args = Py_BuildValue("(s)", "An arg");
PyObject* method = PyWHATGOESHERE(obj, "foo");
PyObject* ret = PyWHATGOESHERE(obj, method, args);
if (!ret) {
// check error...
}
This would be the equivalent of
>>> ret = obj.foo("An arg")
Is there an simple way of turning a string from
Then go to http:/example.com/ and foo the bar!
into
Then go to <a href="http://example.com">example.com</a> and foo the bar!
in Javascript within an existing HTML page?
Wouldn't it make sense if p->m was just syntactic sugar for (*p).m? Essentially, every operator-> that I have ever written could have been implemented as follows:
Foo::Foo* operator->()
{
return &**this;
}
Is there any case where I would want p->m to mean something else than (*p).m?
I have this code:
#include <stdio.h>
#include <wchar.h>
int main()
{
wchar_t *foo = L"ðh";
wprintf(L"[%ls]\n", foo); return 0;
}
And when I compile it, it gives me the implicit declaration of function ‘wprintf’ warning. I know that I should link the wchar library during compilation, but how do I do that?
I want to calculate time elapsed during a function call in C, to the precision of 1 nanosecond.
Is there a timer function available in C to do it?
If yes please provide a sample code-snippet.
Pseudo code
Timer.Start()
foo();
Timer.Stop()
Display time elapsed in execution of foo()
Environment details: - using gcc 3.4 compiler on a RHEL machine
I'd like to list the items in a tuple in Python starting with the back and go to front.
Similar to:
foo_t = tuple(int(f) for f in foo)
print foo, foo_t[len(foo_t)-1] ...
I believe this should be possible without Try ...-4, except ...-3.
Thoughts? suggestions?
how can I use wild cars like '*' when getting a list of files inside a directory in Python? for example, I want something like:
os.listdir('foo/*bar*/*.txt')
which would return a list of all the files ending in .txt in directories that have bar in their name inside of the foo parent directory.
how can I do this?
thanks.
SRC_VAR = test string for variable manipulation.
TEST1_VAR = $(subset for,foo,${SRC_VAR})
all:
@echo original str: ${SRC_VAR}
@echo substitution: ${TEST1_VAR}
This is the output:
original str: test string for variable manipulation.
substitution:
The output should be:
original str: My test string for variable manipulation.
substitution: My test string foo variable manipulation.
I have an array
foo = %w(1 2 3 4 5 6 7 8 9 10)
How can I split or "chunk" this into smaller arrays?
class Array
def chunk(size)
# return array of arrays
end
end
foo.chunk(3)
# => [[1,2,3],[4,5,6],[7,8,9],[10]]
I would like to convert a string into a node. I have a method that is defined to take a node, but the value I have is a string (it is hard coded). How do I turn that string into a node?
So, given an XQuery method:
define function foo($bar as node()*) as node() {
(: unimportant details :)
}
I have a string that I want to pass to the foo method. How do I convert the string to a node so that the method will accept the string.
I have the following objects in a collection:
Transaction:
Type = "Widget"
Date = "3/1/2011"
Name = "Foo"
Transaction:
Type = "Widget"
Date = "3/4/2011"
Name = "Bar"
Transaction:
Type = "Gadget"
Date = "3/2/2011"
Name = "Baz"
Transaction:
Type = "Gizmo"
Date = "3/1/2011"
Name = "Who"
Transaction:
Type = "Gizmo"
Date = "3/2/2011"
Name = "What"
Transaction:
Type = "Gizmo"
Date = "3/6/2011"
Name = "When"
I want to end up with the following, grouped by Type. If there are multiple, return only the first one chronologically by date.
Transaction:
Type = "Widget"
Date = "3/1/2011"
Name = "Foo"
Transaction:
Type = "Gadget"
Date = "3/2/2011"
Name = "Baz"
Transaction:
Type = "Gizmo"
Date = "3/1/2011"
Name = "Who"
Having a bit of difficulty figuring out how to create a named_scope from this SQL query:
select * from foo where id NOT IN (select foo_id from bar) AND foo.category = ? ORDER BY RAND() LIMIT 1;
Category should be variable to change.
What's the most efficient way the named_scope can be written for the problem above?
Hello Iam working in a global int in which a variable will be used later. I've made the global variable like this:
class Foo
{
public static int stream = Bass.BASS_StreamCreateFile(path1.Text, 0, 0, BASSFlag.BASS_DEFAULT);
}
which will be later called like this:
Foo.stream
and it can also contain more then 1 stream for example stream20,30,etc...
The problem here is that it returns me this error:
"An object reference is required for the non-static field, method, or property" where I call the text in path1.Text
How do I fix this?