|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On November 21 2017 10:08 Hanh wrote: Nice! Was it because the credentials were not passed to the transaction 'send funds'? Nope, it turns out that for ECKeys if you pass in the private key it can generate the address. I was putting a fake password in for testing("pass") and it was giving me the wrong address. I just could not wrap my head around why it was getting the wrong address, or how it got an address at all.
Finally I started digging deeper into the code for ECKeys and Credentials(I ended up digging pretty damn deep) and realized that it just... didn't need an address anywhere in there(though you could put one if you wanted). I googled some terms related to ECKeys and found a post that mentioned that you can derive the address from the private key and it all clicked(aha!).
|
As a follow on to that previous post, if you can generate an address from a private key what's to stop you from simply running through a ton of private keys, generating their addresses, and taking that ethereum?
|
On November 21 2017 13:34 WarSame wrote: As a follow on to that previous post, if you can generate an address from a private key what's to stop you from simply running through a ton of private keys, generating their addresses, and taking that ethereum?
There are too many addresses out there, ~2^160 or about the number of atoms in the world. Though it is theoretically possible to have a collision, the odds are so low that there is no practical chance to find a non-empty address by luck.
|
On November 21 2017 09:53 WarSame wrote: I got the code I was working on to finally work muthafuckas!!!
@Blisse, is that because it slots into Java really nicely? I glanced through their pages and didn't see anything that made it a must-have, but then again I also don't know much.
Retrofit and RxJava (together and individually) are better ways to write Android code.
|
On November 21 2017 13:34 WarSame wrote: As a follow on to that previous post, if you can generate an address from a private key what's to stop you from simply running through a ton of private keys, generating their addresses, and taking that ethereum?
I always liked this image.
https://i.imgur.com/MUQoSzy.jpg
|
On November 22 2017 19:56 R1CH wrote:Show nested quote +On November 21 2017 13:34 WarSame wrote: As a follow on to that previous post, if you can generate an address from a private key what's to stop you from simply running through a ton of private keys, generating their addresses, and taking that ethereum? I always liked this image. https://i.imgur.com/MUQoSzy.jpg
Brute forcing the keys won't work but it doesn't mean that other methods can't succeed. For instance, according to https://eprint.iacr.org/2017/598 (p20, table 2), you would need 2330 q-bits to crack Bitcoin ECDSA (it uses secp256k1). So far, IBM has achieved 17 q-bits so we are still way off.
|
Question on C#.NET and Entity Framework.
I'm trying to implement this: https://github.com/mehdime/DbContextScope. Basically an easy way to create and manage DbContext. The problem is that my DbContext requires a connection string to be provided programmatically rather than directly from the config file. He's got a factory interface that I can implement to provide my own DbContext. I can't seem to figure out how to get it to work though. I'm pretty sure this is probably just a problem with my understanding of generic interfaces.
Here's a sample of what I'm trying to do: // This is the DbContext factory. MSEntities is my DbContext, which requires a ConnectionToken. public class MSEntitiesContextFactory : IDbContextFactory<MSEntities> { private ConnectionToken _token;
public MSEntitiesContextFactory(ConnectionToken token) { _token = token; }
public MSEntities Create() { return new MSEntities(_token); } }
public class Test { public void PerformTest(ConnectionToken token) { IDbContextFactory<MSEntities> dbContextFactory = new MSEntitiesContextFactory(token); using (DbContextScope scope = new DbContextScope(dbContextFactory)) { // Do stuff } } }
I get an error on the "using" line saying: "cannot convert from 'System.Data.Entity.Infrastructure.IDbContextFactory<MSEntities>' to 'EntityFramework.Db.ContextScope.Interfaces.IDbContextFactory'".
The constructor for DbContextScope requires just the IDbContextFactory. But the IDbContextFactory is a generic interface. How do I implement that interface using my custom DbContext (MSEntities)?
Here is the IDbContextFactory interface, for reference: public interface IDbContextFactory<out TContext> where TContext : DbContext { // // Summary: // Creates a new instance of a derived System.Data.Entity.DbContext type. // // Returns: // An instance of TContext TContext Create(); }
|
what do I need to become to understand Shor's algorithm as easily as I understand baked chicken with potatoes recipe?
|
On November 23 2017 06:41 mantequilla wrote: what do I need to become to understand Shor's algorithm as easily as I understand baked chicken with potatoes recipe?
Depends on how good of a cook you are, and how deeply you want to understand Shor's. There's a ton of tutorials if you look around--which one you read hinges on how much math you're willing to look at.
|
On November 23 2017 04:42 enigmaticcam wrote:Question on C#.NET and Entity Framework. I'm trying to implement this: https://github.com/mehdime/DbContextScope. Basically an easy way to create and manage DbContext. The problem is that my DbContext requires a connection string to be provided programmatically rather than directly from the config file. He's got a factory interface that I can implement to provide my own DbContext. I can't seem to figure out how to get it to work though. I'm pretty sure this is probably just a problem with my understanding of generic interfaces. Here's a sample of what I'm trying to do: // This is the DbContext factory. MSEntities is my DbContext, which requires a ConnectionToken. public class MSEntitiesContextFactory : IDbContextFactory<MSEntities> { private ConnectionToken _token;
public MSEntitiesContextFactory(ConnectionToken token) { _token = token; }
public MSEntities Create() { return new MSEntities(_token); } }
public class Test { public void PerformTest(ConnectionToken token) { IDbContextFactory<MSEntities> dbContextFactory = new MSEntitiesContextFactory(token); using (DbContextScope scope = new DbContextScope(dbContextFactory)) { // Do stuff } } }
I get an error on the "using" line saying: "cannot convert from 'System.Data.Entity.Infrastructure.IDbContextFactory<MSEntities>' to 'EntityFramework.Db.ContextScope.Interfaces.IDbContextFactory'". The constructor for DbContextScope requires just the IDbContextFactory. But the IDbContextFactory is a generic interface. How do I implement that interface using my custom DbContext (MSEntities)? Here is the IDbContextFactory interface, for reference: public interface IDbContextFactory<out TContext> where TContext : DbContext { // // Summary: // Creates a new instance of a derived System.Data.Entity.DbContext type. // // Returns: // An instance of TContext TContext Create(); }
Looks like it is not the same name space even. Does he have his own definitions of entity framework types?
|
![[image loading]](http://asset-1.soupcdn.com/asset/13943/5217_1171_754.png)
Most awesomest easter egg ever.
|
On November 23 2017 11:20 Hanh wrote:Looks like it is not the same name space even. Does he have his own definitions of entity framework types?
No, I would provide those definitions through the DbContextScope class via generic function. But IDbContextFactory is a generic interface.
His code supports multiple DbContext's. I have the option of providing a single class that uses this generic interface that will instantiate any of the DbContext's. In my case, I just have one. But I don't know how to implement that interface properly to provide the class.
|
On November 23 2017 04:42 enigmaticcam wrote:Question on C#.NET and Entity Framework. I'm trying to implement this: https://github.com/mehdime/DbContextScope. Basically an easy way to create and manage DbContext. The problem is that my DbContext requires a connection string to be provided programmatically rather than directly from the config file. He's got a factory interface that I can implement to provide my own DbContext. I can't seem to figure out how to get it to work though. I'm pretty sure this is probably just a problem with my understanding of generic interfaces. Here's a sample of what I'm trying to do: // This is the DbContext factory. MSEntities is my DbContext, which requires a ConnectionToken. public class MSEntitiesContextFactory : IDbContextFactory<MSEntities> { private ConnectionToken _token;
public MSEntitiesContextFactory(ConnectionToken token) { _token = token; }
public MSEntities Create() { return new MSEntities(_token); } }
public class Test { public void PerformTest(ConnectionToken token) { IDbContextFactory<MSEntities> dbContextFactory = new MSEntitiesContextFactory(token); using (DbContextScope scope = new DbContextScope(dbContextFactory)) { // Do stuff } } }
I get an error on the "using" line saying: "cannot convert from 'System.Data.Entity.Infrastructure.IDbContextFactory<MSEntities>' to 'EntityFramework.Db.ContextScope.Interfaces.IDbContextFactory'". The constructor for DbContextScope requires just the IDbContextFactory. But the IDbContextFactory is a generic interface. How do I implement that interface using my custom DbContext (MSEntities)? Here is the IDbContextFactory interface, for reference: public interface IDbContextFactory<out TContext> where TContext : DbContext { // // Summary: // Creates a new instance of a derived System.Data.Entity.DbContext type. // // Returns: // An instance of TContext TContext Create(); }
I'll start with recommending not using that abstraction. I have some experience with it, but only found it clumsy.
That being said, what you want to do is something like this
public class MSEntitiesContextFactory : IDbContextFactory { private readonly ConnectionToken _token;
public MSEntitiesContextFactory(ConnectionToken token) { _token = token; } public TDbContext CreateDbContext<TDbContext>() where TDbContext : class, IDbContext { return typeof(TDbContext) == typeof(MSEntities) ? new MSEntities(token: _token) as TDbContext : Activator.CreateInstance<TDbContext>(); } } }
public void PerformTest(ConnectionToken token) { var myFactory = new MSEntitiesContextFactory(new ConnectionToken()); var scopeFactory = new DbContextScopeFactory(myFactory); //if you want to use the ambient scope var ambientScope = new DbContextScope(myFactory); using (IDbContextScope scope = scopeFactory.Create()) { var asd = scope.DbContexts.Get<MSEntities>().Persons.Add(new Person()); // Do stuff } }
It seems that in the version I tried this with, you have to let MSEtities implement IDbContext, but you should not have to do anything further other than implementing it.
|
Thank you! That was the syntax I needed, and that works. Really appreciate it!
On November 24 2017 01:55 Fwmeh wrote:I'll start with recommending not using that abstraction. I have some experience with it, but only found it clumsy. You mean not using the DbContextScope? Since I was about to start using it, I'm curious as to why you thought it was clumsy. Any recommendations as to how to manage DbContext correctly?
|
On November 24 2017 02:14 enigmaticcam wrote:Thank you! That was the syntax I needed, and that works. Really appreciate it! Show nested quote +On November 24 2017 01:55 Fwmeh wrote:I'll start with recommending not using that abstraction. I have some experience with it, but only found it clumsy. You mean not using the DbContextScope? Since I was about to start using it, I'm curious as to why you thought it was clumsy. Any recommendations as to how to manage DbContext correctly?
Well, it is hard to give advise even when you know the particulars, and really hard when you don't.
I just feel that this pattern is overly complicated for what it solves. Also, the use of service-location makes it really easy to take on too many dependencies without noticing it. I'm a big proponent of constructor injection, and always refactor when I see them taking too many arguments. With service location, that is more hidden. Plus, I found it really unwieldy to unit test.
I would probably do something like make my DbContext's work as repositories (making sure not to have any "business logic" in there, only CRUD), use a separate Unit of work-abstraction, which creates the DbContext's on demand and in transactions as required. Like one UnitOfWork : IUnitOfWOrk<ContextA>, IUnitOfWork<ContextB>, etc, and letting any service depend on them explicitly. You could even implement that using DbContextScope, confine it to that one class, so you don't end up with IAmbientDbContextLocator's all over the code.
|
On November 23 2017 18:17 Manit0u wrote:
Most awesomest easter egg ever.
Idk I still think that the fully functional flight simulator they built into Excel is a way more awesome and intensive Easter egg.
|
On November 24 2017 03:02 phar wrote:Idk I still think that the fully functional flight simulator they built into Excel is a way more awesome and intensive Easter egg.
You mean this buggy crap that was warping all the time? The dev hunter from Excel 2006 was much better.
|
Ha! I've just created merge request #666 in one of our projects, in which I delete 119 files.
Feels good.
|
I mentioned prolog earlier in the forum and it seems like it got a lot of love from some of you.
After working with it a bit, I can say that this *feels* like the most skill based language I have programmed with it. I am able to cleverly solve my assigned problems, but I just know that each time I do so - there is probably another way that is way shorter.
|
I'd applied for a C++ job and I got test questions. Guess what! ANSI C questions instead. Yay! :D I can manage it, it's just not expected. I feel way more comfortable with C++ though. I'm going to tell recruiter that as well.
|
|
|
|