I am messing around with one of my databases.. is there away for me to search for a string in ALL the tables.. and replace it with another everywhere it occurs?
I am looking for SQL
Why does the following line "alarm.AlarmEvent += new AlarmEventHandler(alarm_Sound);" gives me "An object reference is required for the non-static field, method, or property 'AlarmClock.Alarm.alarm_Sound(object, System.EventArgs)'"
public static void Main(string[] args)
{
Alarm alarm = new Alarm(new DateTime(2010, 4, 7, 23, 2, 0));
alarm.Set();
alarm.AlarmEvent += new AlarmEventHandler(alarm_Sound);
}
Full source code here:
Program.cs
AlarmEventArgs
This is the model with it's validation:
[MetadataType(typeof(TagValidation))]
public partial class Tag
{
}
public class TagValidation
{
[Editable(false)]
[HiddenInput(DisplayValue = false)]
public int TagId { get; set; }
[Required]
[StringLength(20)]
[DataType(DataType.Text)]
public string Name { get; set; }
//...
}
Here is the view:
<h2>Create</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Tag</legend>
<div>@Html.EditorForModel()</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
And here is what get's renderd:
<form action="/Tag/Create" method="post">
<fieldset>
<legend>Tag</legend>
<div><input data-val="true" data-val-number="The field TagId must be a number." data-val-required="The TagId field is required." id="TagId" name="TagId" type="hidden" value="" />
<div class="editor-label"><label for="Name">Name</label></div>
<div class="editor-field"><input class="text-box single-line" data-val="true" data-val-length="The field Name must be a string with a maximum length of 20." data-val-length-max="20" data-val-required="The Name field is required." id="Name" name="Name" type="text" value="" /> <span class="field-validation-valid" data-valmsg-for="Name" data-valmsg-replace="true"></span></div>
...
</fieldset>
</form>
The problem is that TagId validation gets generated althoug thare is no Required attribute set on TagId property. Because of that I can't even pass the client-side validation in order to create new Tag in db.
What am I missing?
Hello I want to get user from an email address,
eg: [email protected] then output must be sajid
for this is use below mentioned code but an warning occur
$user = strstr($email, '@', true);
Warning: Wrong parameter count for strstr() in /var/www/DataTable/dialog.php on line 3
& in php manul it is clearly define that the 3rd argument true is only valid for PHP 5.3.0
So is there any string function which could solve my problem?
I'm new to Python, as well as SQL Alchemy, but not the underlying development and database concepts. I know what I want to do and how I'd do it manually, but I'm trying to learn how an ORM works.
I have two tables, Images and Keywords. The Images table contains an id column that is its primary key, as well as some other metadata. The Keywords table contains only an id column (foreign key to Images) and a keyword column. I'm trying to properly declare this relationship using the declarative syntax, which I think I've done correctly.
Base = declarative_base()
class Keyword(Base):
__tablename__ = 'Keywords'
__table_args__ = {'mysql_engine' : 'InnoDB'}
id = Column(Integer, ForeignKey('Images.id', ondelete='CASCADE'),
primary_key=True)
keyword = Column(String(32), primary_key=True)
class Image(Base):
__tablename__ = 'Images'
__table_args__ = {'mysql_engine' : 'InnoDB'}
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String(256), nullable=False)
keywords = relationship(Keyword, backref='image')
This represents a many-to-many relationship. One image can have many keywords, and one keyword can relate back to many images.
I want to do a keyword search of my images. I've tried the following with no luck.
Conceptually this would've been nice, but I understand why it doesn't work.
image = session.query(Image).filter(Image.keywords.contains('boy'))
I keep getting errors about no foreign key relationship, which seems clearly defined to me. I saw something about making sure I get the right 'join', and I'm using 'from sqlalchemy.orm import join', but still no luck.
image = session.query(Image).select_from(join(Image, Keyword)).\
filter(Keyword.keyword == 'boy')
I added the specific join clause to the query to help it along, though as I understand it, I shouldn't have to do this.
image = session.query(Image).select_from(join(Image, Keyword,
Image.id==Keyword.id)).filter(Keyword.keyword == 'boy')
So finally I switched tactics and tried querying the keywords and then using the backreference. However, when I try to use the '.images' iterating over the result, I get an error that the 'image' property doesn't exist, even though I did declare it as a backref.
result = session.query(Keyword).filter(Keyword.keyword == 'boy').all()
I want to be able to query a unique set of image matches on a set of keywords. I just can't guess my way to the syntax, and I've spent days reading the SQL Alchemy documentation trying to piece this out myself.
I would very much appreciate anyone who can point out what I'm missing.
Hi,
I want to ask why we use "this" keyword before the parameter in an extension method (C# Language)...........
like this function :
public static int ToInt(this string number)
{
return Int32.Parse(number);
}
I know that we have to use it but I don't know why.
I have a git repository with few branches and dangling commits. I would like to search all such commits in repository for a specific string.
I know how to get a log of all commits in history, but these don't include branches or dangling blobs, just HEAD's history. I want to get them all, to find a specific commit that got misplaced.
I would also like to know how to do this in mercurial, as I'm considering the switch.
I always get confused using regular expressions. Can anyone please suggest me a tutorial?
I need help with checking for a string which,
cannot contain any wild characters except colon, comma, full stop.
It will be better to replace these if found.
Any help?
Thanks.
Hi, I have generated using openssl mycert.pem which contents the certificate. And I converted the base64 text into hex.
I wonder if it's possible to extract the informations from the hex string in c (without using the openssl library). For example, the public key, the issuer, the subject, the validity information, etc.
Thanks.
I have three assemblies: "Framework.DataAccess", "Framework.DataAccess.NHibernateProvider" and "Company.DataAccess". Inside the assembly "Framework.DataAccess", I have my factory (with the wrong implementation of discovery):
public class DaoFactory
{
private static readonly object locker = new object();
private static IWindsorContainer _daoContainer;
protected static IWindsorContainer DaoContainer
{
get
{
if (_daoContainer == null)
{
lock (locker)
{
if (_daoContainer != null)
return _daoContainer;
_daoContainer = new WindsorContainer(new XmlInterpreter());
// THIS IS WRONG! THIS ASSEMBLY CANNOT KNOW ABOUT SPECIALIZATIONS!
_daoContainer.Register(
AllTypes.FromAssemblyNamed("Company.DataAccess")
.BasedOn(typeof(IReadDao<>)).WithService.FromInterface(),
AllTypes.FromAssemblyNamed("Framework.DataAccess.NHibernateProvider")
.BasedOn(typeof(IReadDao<>)).WithService.Base());
}
}
return _daoContainer;
}
}
public static T Create<T>()
where T : IDao
{
return DaoContainer.Resolve<T>();
}
}
This assembly also defines the base interface for data access IReadDao:
public interface IReadDao<T>
{
IEnumerable<T> GetAll();
}
I want to keep this assembly generic and with no references. This is my base data access assembly.
Then I have the NHibernate provider's assembly, which implements the above IReadDao using NHibernate's approach. This assembly references the "Framework.DataAccess" assembly.
public class NHibernateDao<T> : IReadDao<T>
{
public NHibernateDao()
{
}
public virtual IEnumerable<T> GetAll()
{
throw new NotImplementedException();
}
}
At last, I have the "Company.DataAccess" assembly, which can override the default implementation of NHibernate provider and references both previously seen assemblies.
public interface IProductDao : IReadDao<Product>
{
Product GetByName(string name);
}
public class ProductDao : NHibernateDao<Product>, IProductDao
{
public override IEnumerable<Product> GetAll()
{
throw new NotImplementedException("new one!");
}
public Product GetByName(string name)
{
throw new NotImplementedException();
}
}
I want to be able to write...
IRead<Product> dao = DaoFactory.Create<IRead<Product>>();
... and then get the ProductDao implementation. But I can't hold inside my base data access any reference to specific assemblies! My initial idea was to read that from a xml config file.
So, my question is: How can I externally configure this factory to use a specific provider as my default implementation and my client implementation?
When I try to import the System.Linq namespace to Boo compiler, I get this error:
Boo.Lang.Compiler.CompilerError:
Namespace 'System.Linq' not found, maybe you forgot to add an assembly reference?
I use "Rhino.DSL.dll" and my DSL engine code is here:
public class MyDslEngine : DslEngine
{
protected override void CustomizeCompiler(BooCompiler compiler, CompilerPipeline pipeline, string[] urls)
{
pipeline.Insert(1, new AnonymousBaseClassCompilerStep(typeof(DslBase), "Prepare",
"System.Linq",
"Azarakhsh.Framework.Repository" //it's my repository framework
));
pipeline.Insert(2, new UseSymbolsStep());
pipeline.Insert(3, new RunScriptCompilerStep());
}
}
Hi all,
I seem to be having trouble reading preferences from my AppWidgetProvider class. My code works in an Activity, but it does not in an AppWidgetProvider. Here is the code I am using to read back a boolean:
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
boolean autoreplyon = settings.getBoolean("autoreplyon", false);
However, I get the "The method getSharedPreferences(String, int) is undefined for the type widget" error (widget is the name of my AppWidgetProvider class).
Thanks in advance for any suggestions!
public static void main(String[] args) throws Exception {
RSAKeyPairGenerator rsaKeyPairGen = new RSAKeyPairGenerator();
AsymmetricCipherKeyPair keyPair = rsaKeyPairGen.generateKeyPair();
}
the rsaKeyPairGen is not null, but the generateKeyPair() method is throwing NullPointerException. What may be wrong?
Error message:
java.lang.NullPointerException
at org.bouncycastle.crypto.generators.RSAKeyPairGenerator.generateKeyPair(Unknown Source)
at pkg.main(Main.java:154)
How can I design my xsd to ignore the sequence of elements?
<root> <a/> <b/> </root>
<root> <b/> <a/> </root>
I need to use extension for code generation reasons, so I tried the following using all:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.example.com/test"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:t="http://www.example.com/test" >
<xs:complexType name="BaseType">
<xs:all>
<xs:element name="a" type="xs:string" />
</xs:all>
</xs:complexType>
<xs:complexType name="ExtendedType">
<xs:complexContent>
<xs:extension base="t:BaseType">
<xs:all> <!-- ERROR -->
<xs:element name="b" type="xs:string" />
</xs:all>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="root" type="t:ExtendedType"></xs:element>
</xs:schema>
This xsd is not valid though, the following error is reported at <!-- ERROR -->:
cos-all-limited.1.2: An all model group must appear in a particle with {min occurs} = {max occurs} = 1, and that particle must be part of a pair which constitutes the {content type} of a complex type definition.
Documentation of cos-all-limited.1.2 says:
1.2 the {term} property of a particle with {max occurs}=1 which is part of a pair which constitutes the {content type} of a complex type definition.
I don't really understand this (neither xsd nor English native speaker :) ).
Am I doing the wrong thing, am I doing the right thing wrong, or is there no way to achieve this?
Thanks!
Hi, I am facing issues with the special characters like ° and ® which represent the degreee Farenheit sign and the ® represent the registered sign,
when i print the string the contains the special characters, it gives output like this:
Preheat oven to 350° F
Welcome to Lorem Ipsum Inc®
is there a way i can output the exact characters and not their codes ? please let me know.
First off, I'm using Google AppEngine and Guice, but I suspect my problem is not related to these.
When the user connect to my (GWT) webapp, the URL is a direct html page. For example, in development mode, it is: http://127.0.0.1:8888/Puzzlebazar.html?gwt.codesvr=127.0.0.1:9997. Now, I setup my web.xml in the following way:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>PuzzleBazar</display-name>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Puzzlebazar.html</welcome-file>
</welcome-file-list>
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--
This Guice listener hijacks all further filters and servlets. Extra
filters and servlets have to be configured in your
ServletModule#configureServlets() by calling
serve(String).with(Class<? extends HttpServlet>) and
filter(String).through(Class<? extends Filter)
-->
<listener>
<listener-class>com.puzzlebazar.server.guice.MyGuiceServletContextListener
</listener-class>
</listener>
</web-app>
Since I'm using Guice, I have to configure extra filters in my ServletModule, where I do this:
filter("*.html").through( SecurityCookieFilter.class );
But my SecurityCookieFilter.doFilter is never called. I tried things like "*.html*" or <url-pattern>*</url-pattern> but to no avail. Any idea how I should do this?
say I have a function
function myFunction(myValue) {
// do something
}
How would I return a value from this, say a string type after the method is executed?
simple, but I cant find a quick neat example online
cheers
I have a time duration in miliseconds which I ideally would like to format using the formatting functionality present in the boost::date_time library. However, after creating a boost::posix_time::time_duration I can't seem to find a way to actually apply the formatting string to it.
I'm performing this on a string:
var poo = poo
.replace(/[%][<]/g, "'<")
.replace(/[>][%]/g, ">'")
.replace(/[%]\s*[+]/g, "'+")
.replace(/[+]\s*[%]/g, "+'");
Given the similar if these statements, can these regexs be comebined somehow?
Hi,
I have the php backend that displays an xml page with data for flash consuming.
Flash takes it and creates a textfields dynamicaly based on this information.
I have a few items in menu on top and when I click one of them, data is taken from php and everything is displayed in scroll in flash. The problem is that if I click too fast between menu items, then I get buggy layout. The text (only the text) is becoming part of the layout and is displayed no metter what item in menu I am currently in and only refreshing the page helps.
var myXML:XML = new XML();
myXML.ignoreWhite=true;
myXML.load("/getBud1.php");
myXML.onLoad = function(success){
if (success){
var myNode = this.firstChild.childNodes;
var myTxt:Array = Array(0);
for (var i:Number = 0; i<myNode.length; i++) {
myTxt[i] = "text"+i+"content";
createTextField(myTxt[i],i+1,65,3.5,150, 20);
var pole = eval(myTxt[i]);
pole.embedFonts = true;
var styl:TextFormat = new TextFormat();
styl.font = "ArialFont";
pole.setNewTextFormat(styl);
pole.text = String(myNode[i].childNodes[1].firstChild.nodeValue);
pole.wordWrap = true;
pole.autoSize = "left";
if(i > 0) {
var a:Number = eval(myTxt[i-1])._height + eval(myTxt[i-1])._y + 3;
pole._y = a;
}
attachMovie("kropka2", "test"+i+"th", i+1000);
eval("test"+i+"th")._y = pole._y + 5;
eval("test"+i+"th")._x = 52;
}
}
}
I tried to load the info and ceate text fields from top frame and then refer to correct place by instance names string e.g. budData.dataHolder.holder.createTextField , but then when I change between items in menu the text dissapears completely untill I refresh the page.
Please help
How to format a float so it does not containt the remaing zeros? In other words, I want the resulting string to be as short as possible..?
Like:
3 -> "3"
3. -> "3"
3.1 -> "3.1"
3.14 -> "3.14"
3.140 -> "3.14"
I'm creating a data-entry application where users are allowed to create the entry schema.
My first version of this just created a single table per entry schema with each entry spanning a single or multiple columns (for complex types) with the appropriate data type. This allowed for "fast" querying (on small datasets as I didn't index all columns) and simple synchronization where the data-entry was distributed on several databases.
I'm not quite happy with this solution though; the only positive thing is the simplicity...
I can only store a fixed number of columns. I need to create indexes on all columns. I need to recreate the table on schema changes.
Some of my key design criterias are:
Very fast querying (Using a simple domain specific query language)
Writes doesn't have to be fast
Many concurrent users
Schemas will change often
Schemas might contain many thousand columns
The data-entries might be distributed and needs syncronization.
Preferable MySQL and SQLite - Databases like DB2 and Oracle is out of the question.
Using .Net/Mono
I've been thinking of a couple of possible designs, but none of them seems like a good choice.
Solution 1: Union like table containing a Type column and one nullable column per type.
This avoids joins, but will definitly use a lot of space.
Solution 2: Key/value store. All values are stored as string and converted when needed.
Also use a lot of space, and of course, I hate having to convert everything to string.
Solution 3: Use an xml database or store values as xml.
Without any experience I would think this is quite slow (at least for the relational model unless there is some very good xpath support).
I also would like to avoid an xml database as other parts of the application fits better as a relational model, and being able to join the data is helpful.
I cannot help to think that someone has solved (some of) this already, but I'm unable to find anything. Not quite sure what to search for either...
I know market research is doing something like this for their questionnaires, but there are few open source implementations, and the ones I've found doesn't quite fit the bill.
PSPP has much of the logic I'm thinking of; primitive column types, many columns, many rows, fast querying and merging. Too bad it doesn't work against a database.. And of course... I don't need 99% of the provided functionality, but a lot of stuff not included.
I'm not sure this is the right place to ask such a design related question, but I hope someone here has some tips, know of any existing work, or can point me to a better place to ask such a question.
Thanks in advance!
If a SharePoint user (with Regional Settings set to UK) views a calculated date field in a View details form, the field shows incorrectly.
I am using:
ddwrt:FormatDateTime(string(@RenewalDate), 1033, 'dd MMMM yyyy')
Which shows 04 January 2010 for 01/04/2010 and, doesnt show unresolvable dates such as 31-Dec-2010.
This applies even with a simnple =[Modified] formula
The Server is set up in the US for that locale.