silly php question...
why cant i do this?
echo Auth::getFullUser()[ 'country' ];
instead you have to do this
$user = Auth::getFullUser();
echo $user[ 'country' ];
Ruby Newbie here,
I understand that everything is an object in Ruby, one thing that I wasn't sure about was understanding Variables. Variables basically give reference to objects (correct me if I'm wrong). During an instructional video, the teacher did a demonstration which went as below:
(irb)
a = 100
==> 100
b = a
==> 100
b
==> 100
This part I get, makes total sense.
Then he did
a = 50
==> 50
b
==> 100
If B is supposed to point to what a was set which was a 100, why does b still point to 100 if a has now been set as 50?
I'm trying desperately to move from VSS to a real source control system. Options include TFS and SVN.
My designers need to keep their ability to modify source files and instantly preview their changes in a browser without having to commit their changes. Using FPSE with VSS, this works flawlessly, since saving a file causes the copy in the working folder on the dev server to be updated, so they can just save and refresh their browser which is pointed at the dev server.
The site in question consists of 350k+ lines of classic ASP code and some new ASP.NET MVC. They only need to be able to modify views within the MVC code, not C#.
Though Expression includes a version of Cassini for local debugging, Cassini does not support classic ASP.
Surely someone has solved this problem before. It can't be necessary to install IIS on each designer's machine (this is absolutely untenable). I need a way to have a common working folder on a dev webserver updated whenever someone saves a file locally, just like using FPSE.
I'd rather not write an FPSE proxy that knows how to talk to TFS/SVN. Any suggestions?
(I know I've asked this question in the past, but I haven't yet found a solution.)
I wasted plenty of hours trying to figure out the problem but no luck. Tried asking the TA at my school, but he was useless. I am a beginner and I know there are a lot of mistakes in it, so it would be great if I can get some detail explanation as well. Anyways, basically what I am trying to do with the following function is:
Use while loop to check and see if random_string is in TEXT, if not
return NoneType
if yes, then use a for loop to read lines from that TEXT and put it
in list, l1.
then, write an if statement to see if random_string is in l1.
if it is, then do some calculations.
else read the next line
Finally, return the calculations as a whole.
TEXT = open('randomfile.txt')
def random (TEXT, random_string):
while random_string in TEXT:
for lines in TEXT:
l1=TEXT.readline().rsplit()
if random_string in l1:
'''
do some calculations
'''
else:
TEXT.readline() #read next line???
return #calculations
return None
So, I'm working with a really old system which uses a person's mysql database credentials to authenticate to a web site (the database was originally only accessed from the command line, but is now accessed from a php frontend). Because of some internal reasons (and to preserve the user's history), I have to leave the old authentication intact. I've been charged with adding openid authentication to this system. Somehow I need to be able to retrieve a users mysql username and password upon logging into the site through openid (using the Zend framework, by the way). I've thought of simply requiring registration at the first login, where the user must provide their mysql credentials, but I'd rather not store the password plain text.
I've also considered blanking everyone's mysql passwords, and just setting the user's mysql username manually (rather than having the user provide this, since they could provide any username).
This is turning into a security nightmare. Does anyone have any suggestions for alternatives?
This is running on a Linux server, by the way. Also, I can't use mysql pluggable authentication because the mysql version is 5.0 (pluggable authentication requires mysql 5.5), and no, I can't update it.
if getChildHtml('product_type_data') ? maps directly to catalog/product/view/type/simple.phtml by default, how do I map to my own file? If I wanted to create a file that would produce a small image to place on the product page, right under "availability" how would I tell magento to map to where I have put the file? From what I understand getChildHtml('product_type_data') ? defaults to the file path: catalog/product/view/type/simple.phtml so how can I customize the magento defaults and tell it to map to my custom files i've created?
I hope I have explained this well enough, if not, please let me know and I will try to explain more. Any help or guidance would be awesome. Thanks.
I need to display an image in a resizable dialog (so far all the specific image popup libraries I have tried do not fit my needs).
All I want to do is maintain the aspect ratio during resizing. Sounds easy, but it's not.
I thought something like this might work, but no dice:
var d = $("").dialog({title:title, width:400, height:400});
d.resizable( "option", "aspectRatio", true );
Any pointers greatly appreciated, tks
I have an existing project that I imported into subversion using TortoiseSVN. Total project size says 1.45MB. Total folder size on my machine is 9.72MB.
Create new folder, right-click, checkout 7.14MB transferred and 19.4MB on my machine.
Can anyone explain this to me? I did a quick KDiff on the folders and they're identical.
What are some key UI design tips that every developer should know?
While there are a number of UI resources for developers (for example, Joel Spolsky's User Interface Design for Programmers), I'm interested in more of a bullet list that can be communicated in 1 to 2 pages.
I'm interested in more tactical, day-to-day UI tips, as opposed to overarching UI design goals that would be covered in a UI design meeting (presumably attended by at least one person with a good UI sense). A collection of these tips might cover about 80% of the cases that an everyday programmer would come across.
I have this widget:
$this->setWidget('slug', new sfWidgetFormDoctrineChoice(array('model'
=> 'MyTable', 'method' => 'myMethod', 'key_method' => 'myMethod',
'add_empty' => 'Select option')));
Ok, what should I do to translate the "Select option"?
I can't use the __() helper inside the form, and adding that string
into my XLIFF file doesn't translate it automatically.
If it can't be done, what workaround should I implement? I can't find
any way, and neither can't find any tip in the official documentation.
Thanks!
I need to split a string (in Java) into individual words ... but I need to preserve spaces.
An example of the text I need to split is something like this:
ABC . . . . DEF . . . . GHI
I need to see "ABC", " . . . .", "DEF", ". . . .", and "GHI".
Obviously splitting on the space character \s isn't going to work, as all the spaces get swallowed up as one space.
Any suggestions?
Thanks
Hi,
I've started to make myself a list of "WPF gotchas": things that bug me and that I had to write down to remember because I fall for them every time....
Now, I'm pretty sure you all stumbled upon similar situations at one point, and I would like you to share your experience on the subject:
What is the gotcha that gets you all the time? the one you find the most annoying?
(I have a few issues that seem to be without explanation, maybe your submissions will explain them)
Here are a few of my "personnal" gotchas (randomly presented):
For a MouseEvent to be fired even when the click is on the "transparent" background of a control (e.g. a label) and not just on the content (the Text in this case), the control's Background has to be set to "Brushes.Transparent" and not just "null" (default value for a label)
A WPF DataGridCell's DataContext is the RowView to whom the cell belong, not the CellView
When inside a ScrollViewer, a Scrollbar is managed by the scrollviewer itself (i.e. setting properties such as ScrollBar.Value is without effect)
Key.F10 is not fired when you press "F10", instead you get Key.System and you have to go look for e.SystemKey to get the Key.F10
... and now you're on.
I use whereis matlab and find:
/usr/local/bin/matlab
, which is a very long bash file.
How can I find where matlab is installed, I mean, its installed folder.
EDIT:
I used the following method:
open matlab and use edit svds.m to open the svds.m file and the editor shows the folder:)
I'm probably missing something pretty basic here, but if the n-body problem yields chaotic results (except in specific highly-symmetric conditions), couldn't it be used as a "true" random number generator (with initial pseudo-random seeds for masses and velocities) given its non-deterministic nature?
I want to create a custom attribute that can be used on a property like:
[TrimInputString]
public string FirstName { get; set; }
that will be functional equivalent of
private string _firstName
public string FirstName {
set {
_firstName = value.Trim();
}
get {
return _firstName;
}
}
So basically every time property is set the value will be trimmed.
How do I get the value parsed, modify that value and then set the property with the new value all from within the attribute?
[AttributeUsage(AttributeTargets.Property)]
public class TrimInputAttribute : Attribute {
public TrimInputAttribute() {
//not sure how to get and modify the property here
}
}
Is there any way to mimic the in operator, but testing for the existence of protected or private fields?
For example, this:
<mx:Script><![CDATA[
public var pub:Boolean = true;
protected var prot:Boolean = true;
private var priv:Boolean = true;
]]></mx:Script>
<mx:creationComplete><![CDATA[
for each (var prop in ["pub", "prot", "priv", "bad"])
trace(prop + ":", prop in this);
]]></mx:creationComplete>
Will trace:
pub: true
prot: false
priv: false
bad: false
When I want to see:
pub: true
prot: true
priv: true
bad: false
I need to construct a long string with javascript. Thats how i tried to do it:
var html = '<div style="balbalblaba"> </div>';
for(i = 1; i <= 400; i++){
html=+html;
};
When i execute that in firefox its taking ages or makes it crash. what is the best way to do that? What is generally the best way to construct big strings in JS.
can someone help me?
I have a web application that can load plugins through reflection. It currently uses Assembly.LoadFrom() and Activator.CreateInstance() to get this done. Right now plugins are loaded into the same AppDomain and have access to anything in my app and anything my app could access.
What I'm looking for is a way to limit what classes and methods the plugin can access for security purposes. I want to have all of my classes and methods throw an exception when called unless they are whitelisted. I'd be whitelisting basically all the functions in an API class and a few data transfer objects.
I also don't want the plugin to be able to access the filesystem or the database on it's own. I think I can do that with trust levels in a separate AppDomain though.
Does anyone out there have any good ideas or resources? Is this something that could be done with Code Access Security or the new Security-Transparent Code features in .net 4?
This line:
used_emails = [row.email for row
in db.execute(select([halo4.c.email], halo4.c.email!=''))]
Returns:
['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']
I use this to find a match:
if recipient in used_emails:
If it finds a match I need to pull another field (halo4.c.code) from the database in the same row. Any suggestions on how to do this?
Hi
I'm working on a weather widget, so in order to optimize it i want to check if jQuery has been loaded in the page, if Not, the widget will load it from my website.
Because not all the websites use jQuery. how to do that?
Example of how to put my widget:
<html>
blah blah blah
.................
<script src="http://www.xxx.com/weather.js"></script>
</body>
</html>
Thank you
I have a div that I want to have the following characteristics:
Width = 50% of its parent element
Height equal to whatever it needs to be in order to maintain a certain aspect ratio.
I need to use percentages because the object will resize left-right when the browser is resized. I want the object to be resized top-bottom to ensure the object maintains the same aspect ratio.
I don't think there's any way to use pure CSS to do this, but does anyone know of a way? Alternatively, is there an easy JavaScript way to do this? (JQuery is fine.)
hi everyone,
I'm creating an app which has more UIImageView on a View, they should move normally from a side to the other. I have an issue: after entering the second image, the two UIImageView start to behave crazy (!) because they don' move freely, but they are like restricted in two different areas not touching each other even if I said different things
the first thing that I want to do, is to let them move normally; this is the code I am using:
`- (void)viewDidLoad {
[super viewDidLoad];
pos = CGPointMake(14.0, 7.0);
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
}`
- (void) onTimer {
pallone.center = CGPointMake(pallone.center.x+pos.x, pallone.center.y+pos.y);
if(pallone.center.x > 320 || pallone.center.x < 0)
pos.x = -pos.x;
if(pallone.center.y > 480 || pallone.center.y < 0)
pos.y = -pos.y;
}
and for the other image that has to enter after:
- (IBAction)spara{
cos = CGPointMake(8.0, 4.0);
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(inTimer) userInfo:nil repeats:YES];
}
- (void)inTimer{
bomba.center = CGPointMake(bomba.center.x+pos.x, bomba.center.y+pos.y);
if(bomba.center.x > 50 || bomba.center.x < 0)
pos.x = -pos.x;
if(bomba.center.y > 480 || bomba.center.y < 0)
pos.y = -pos.y;
}
what should I change ?
and if I'd like the images to move only in one way (y) ? how do I do this ?
I know, I'm a newbie
thanks in advance
I have a java class with a thousand line method of if/else logic like this:
if (userType == "admin") {
if (age > 12) {
if (location == "USA") {
// do stuff
} else if (location == "Mexico") {
// do something slightly different than the US case
}
} else if (age < 12 && age > 4) {
if (location == "USA") {
// do something slightly different than the age > 12 US case
} else if (location == "Mexico") {
// do something slightly different
}
}
} else if (userType == "student") {
if (age > 12) {
if (location == "USA") {
// do stuff
} else if (location == "Mexico") {
// do something slightly different than the US case
}
} else if (age < 12 && age > 4) {
if (location == "USA") {
// do something slightly different than the age > 12 US case
} else if (location == "Mexico") {
// do something slightly different
}
}
How should I refactor this into something more managable?
I am building a part of a simulator. We are building off of a legacy simulator, but going in different direction, incorporating live bits along side of the simulated bits. The piece I am working on has to, effectively route commands from the central controller to the various bits.
In the legacy code, there is a const array populated with an enumerated type. A command comes in, it is looked up in the table, then shipped off to a switch statement keyed by the enumerated type.
The type enumeration has a choice VALID_BUT_NOT_SIMULATED, which is effectively a no-op from the point of the sim. I need to turn those no-ops into commands to actual other things [new simulated bits| live bits]. The new stuff and the live stuff have different interfaces than the old stuff [which makes me laugh about the shill job that it took to make it all happen, but that is a topic for a different discussion].
I like the array because it is a very apt description of the live thing this chunk is simulating [latching circuits by row and column]. I thought that I would try to replace the enumerated types in the array with pointers to functions and call them directly. This would be in lieu of the lookup+switch.
So I've been learning C++ and SDL to make some basic 2d games. I want to create a game sort of like World of Warcraft but a 2D version. I want it to be on-line and use a database or something to start data like amount of Gold, HP, etc. I was wondering though, if I do this in SDL, would it still work on-line or would the user have to download SDL themselves to play?
I just want a game like this but be able to play it with some friends, just for learning purposes you know. I was also looking at DirectX because everyone has that on windows pretty much. Anyways much help is appreciated, thanks!