• Breaking News

    Friday, May 4, 2018

    [C++] What is the fastest method for serialization from string Ask Programming

    [C++] What is the fastest method for serialization from string Ask Programming


    [C++] What is the fastest method for serialization from string

    Posted: 04 May 2018 08:58 PM PDT

    I'm trying to convert objects as fast as possible from string, string is required because it is using a SQL database and retrieving the data via strings.

    The data is write once, read many and my current bottleneck is reading from the database to object. I've used general string parsing and stringstream but they simply aren't fast enough. I've already implemented writing the object to file using .write((char*)object, size) to disk and that is working perfectly fine but that isn't possible to use with the existing implementation for sql queries.

    At this point my approach has been very disk expensive by writing everything to disk and under utilizing the network capability. To disk and back using the above method has been perfect, but it becomes the bottleneck if the drive isn't large enough or fast enough.

    This project is for machine learning so it is using an absurd amount of data and I am currently trying to optimize it as much as possible.

    submitted by /u/Biotot
    [link] [comments]

    Seeking guidance on editing old drivers to run old hardware on Windows 10.

    Posted: 04 May 2018 11:02 AM PDT

    I've got a B.A. in Computer Science, but we never did much beyond discuss some concepts for low level stuff, so I know my way around programming, more or less (probably more less than more ;).

    Any who. I have an old Wacom Bamboo Fun, and I have this issue where it thinks I'm "holding left click" when just hovering. I've got the latest drivers. Everything I find for this online is people talking about the pen being defective, but here's the catch. When I do NOT install the drivers from Wacom, the pen works as intended with the default Win10 drivers -- except pressure sensitivity and the eraser function from flipping the pen. This suggests to me that is, in fact, the drivers and NOT my pen being broken.

    My current idea is that there is a threshold value in the drivers that is accidentally wrong which is causing the pen to always "drag," and I would like to be able to go in and see if I can find this. I've always wanted to (but been sacred of) learning about and messing with drivers. I'm hoping someone here can point me in the right direction of where I can go to learn more about what editor I'd need and whatnot.

    Please note: I understand that this is all going to be low level stuff, and it won't read anywhere near like high level languages. I'm pretty sure I won't be able to find/fix what I think is wrong, but I'd like to give it a shot and save 100$ from buying a new hardware when my hardware appears fine.

    TL;DR: Win10 Drivers "work." Wacom Drivers do not. Possibly a simple threshold value fix in the drivers. Looking for help getting into editing drivers.

    Thanks for your time.

    Edit: Yeah, I'm an idiot. Of course, they're not open source, and of course, they'd need to be signed after editing the binary files. I think I was hoping drivers were like Java byte-code that was interpreted when loaded, but looking back, that was stupid as it'd probably slow down the computer when dealing with plug-in-play/booting.

    Thanks for the replies. I'm gonna bookmark the Linux project, but I'm thinking this will be shelved for a long enough time I'll have the extra 100$ to just throw at a new tablet.

    submitted by /u/programmerHuman
    [link] [comments]

    Script for 'piano tile' like game

    Posted: 04 May 2018 02:23 PM PDT

    Hi there guys,

    I'm having a really bad time working this out.

    This game is kinda like guitar hero but it's a piano (piano tiles).

    The key scrolls down always in the same color. Every time a key reaches the bottom we press it and a soft transparent white light fades in and fades out slowly in the key area.

    The script that I've made following google searches "works" while the keys fall at a slow pace. But when the game starts to go faster it fails to press all the keys.

    The reason is that normally pressed keys are in one color. But when a key is pressed successfully, this soft white light makes the keys whiter, so it's a different color and that is where I fail to create a code that works out.

    Here how it's like when not pressed. LINK1

    Here when pressed. LINK2

    This is made for AutoIt but I just need some logic here.. Hope someone can help me...

    This is what I got so far:

    While 1 $pix1 = PixelSearch(767, 708, 768, 709, 0xE8263A) If IsArray($pix1) = True Then send("a") EndIf $pix2 = PixelSearch(914, 694, 916, 696, 0xE9273B) If IsArray($pix2) = True Then send("s") EndIf $pix3 = PixelSearch(1028, 691, 1030, 693, 0xE9273B) If IsArray($pix3) = True Then send("d") EndIf $pix4 = PixelSearch(1176, 707, 1178, 709, 0xE82639) If IsArray($pix4) = True Then send("f") EndIf WEnd 
    submitted by /u/becosta
    [link] [comments]

    Largest word pair problem

    Posted: 04 May 2018 07:59 PM PDT

    Hey guys,

    I need help on a word pair problem:

    For a given list of words, find the word pair with the largest product of each word length, and no matching letters.

    So like, the pair:

    ['foot','ball'] would have a score of 16: len(foot) * len(ball) = 4*4 = 16

    A brute force approach is a simple nested loop that checks each word combination and keeps track of the largest pair seen.

    That takes O(n2) time.. Can we do better?

    I've thought about reverse sorting the list (largest words first), and doing the same thing - but stopping once we find the first valid pair. This is fast, but there are weird edge cases where it's not the best answer. For instance, if you have a list like:

    ['aaaaabd','bbbbb','ccccd','fffff']

    'aaaaabd', 'fffff' has the highest score of 35, yet bbbbb, ccccd would be chosen because it would be iterated first (and the algorithm would stop).

    ^ Is this the right approach, but I should just figure out those edge cases? Can I use the information I have about the lengths of words I've seen to make some better assumptions?

    submitted by /u/jacove
    [link] [comments]

    Why do people use JavaScript frameworks? I have been a web developer for seven years and I still don't see why.

    Posted: 04 May 2018 07:03 PM PDT

    I'm being 100% honest when I say that I don't get it. I have worked in three different shops over the years (custom server/jquery, asp.net/knockout, custom server/angular).

    Normal JavaScript does everything the frameworks do and it is never deprecated. Instead of putting yourself on a never-ending treadmill of horizontal JavaScript frameworks you could just learn to write good JavaScript and move on to learning something else.

    Angular, in particular, is just absurd. I love how people say it's small and easy to learn. lol. Like, you could do the whole thing with just a few snippets of regular JavaScript. You don't need a transpiler so you can use things like ES6 arrow functions. How about just don't. Write normal code that works and is easy to understand.

    JavaScript frameworks are massive (#1) time sinks after you spend time learning them, finding the right way to do things in them, and working through issues when you need to do something they aren't designed for. Then, after a couple years no one at all wants to work on your code base because it uses the least sexy thing of all, an old JavaScript framework.

    Hipsters, what is wrong with you? When will you see the light and just write normal JavaScript?

    submitted by /u/DueLavishness3
    [link] [comments]

    What makes functional languages more scalable than imperative languages?

    Posted: 04 May 2018 12:44 PM PDT

    I have often read that an advantage with functional programming is that it allows for applications to scale easier. Why is this the case? Is it because it eases development, lessens stress on servers, or what?

    submitted by /u/imatworkbruv
    [link] [comments]

    Best way to learn C after having learned C++?

    Posted: 04 May 2018 12:12 PM PDT

    I just finished a year of university courses in C++ and my next few courses are going to be in C.

    Whats the best way to go about learning C coming from C++?

    I know they are very similar and in some aspects no different, but I also know there are small differences in certain implementations and syntactic statements. Is there any way to learn these over the summer?

    submitted by /u/DaWylecat
    [link] [comments]

    How big part of the C++ standard library is the STL?

    Posted: 04 May 2018 01:31 PM PDT

    This interested me for a fairly long time. I predict it's something between 90 and 95% (the rest are mostly old imports from C).

    Basically this: how many tokens in the std namespace (and it's subnamespaces) are templates (class templates, function templates, alias templates, variable templates, templates of templates) divided by all tokens count (all visible names). (possibly with different results for each standard)

    I found this could be somewhat easily done because cppreference lists all first-depth tokens and differentiates templates, non-templates and nested namespaces. However, I'm not that good with web stuff and don't know to approach such script, but I guess some Python or JS experts here would find a fast way.

    The other question would be somewhat similar - How many tokens in C standard library are MACROS? Unfortunately there is no index site for this case.

    submitted by /u/Xeverous
    [link] [comments]

    Can some in Layman's terms explain how the mechanism of encryption works?

    Posted: 04 May 2018 08:42 AM PDT

    Yup, I'm having some trouble grasping it..also please do what are public and private keys and how are they distributed? What are the current standards used for encryption? Thanks!

    submitted by /u/Freezy_1
    [link] [comments]

    How to insert an element using Tampermonkey?

    Posted: 04 May 2018 09:27 AM PDT

    Suppose I want to insert a button next to the Subscribe button on YouTube, how can I do this using Tampermonkey?

    submitted by /u/jupiter_104
    [link] [comments]

    I want to get the last "n" match id's from table matches.

    Posted: 04 May 2018 03:09 PM PDT

    The query sounds like this: $stmt = $conn->prepare('SELECT mc_id FROM table_matches WHERE mc_hometeam = :idTeam OR mc_awayteam = :idTeam ORDER BY mc_date desc LIMIT '. $num );

    But its returning me only the last "mc_id" whatever i change the "$num" value.
    How can i solve this in order to get all "mc_id" limited by "$num" value ?

    submitted by /u/Don-g9
    [link] [comments]

    Not sure what I am missing in this convolutional neural network?

    Posted: 04 May 2018 06:24 AM PDT

    I am trying to get my cnn to learn the game snake. I am using the keras library.

    I am using reinforcement learning and passing the pixels (80 * 80 grayscale) as the state and it can move up, down, left or right. It gets a +1 reward for eating the apple and -1 for game over. It eventually keeps going a single direction, ignoring the apples and I am not sure why?

    def learn(self): if len(self.memory) < batch_size: return sample = random.sample(self.memory, batch_size) for memory in sample: state, action, reward, next_state, done = memory s1_values = self.model.predict(state)[0] s2_values = self.model.predict(next_state)[0] if done: q_value = reward else: s1_max_ind = np.argmax(s2_values) q_value = reward + self.gamma * (s2_values[s1_max_ind]) s1_values[self.action_space.index(action)] = q_value self.model.fit(state, s1_values.reshape((1, 4)), epochs=1, verbose=0) 

    and the model:

    def build_cnn(shape): model = Sequential() model.add(Conv2D(filters=32, kernel_size=(8, 8), input_shape=(shape), activation='relu')) model.add(Flatten()) model.add(Dense(units=42, activation='relu')) model.add(Dense(units=16, activation='relu')) model.add(Dense(4, activation='linear')) model.compile(optimizer='adam', loss='mse', metrics=['accuracy']) return model 
    submitted by /u/ryanmccauley211
    [link] [comments]

    merge .mov files in batch

    Posted: 04 May 2018 04:44 AM PDT

    Hi, i need an help with a batch program that can make me merge 2 of thousand .mov files into a new one.

    The 1.mov file need to be merged with the 1001.mov file and so on until 533.mov will be merged with 1533.mov

    The syntax is "copy /b "C:\File.mp4" + "C:\File1.mp4" CombinedFile.mp4"

    How do i loop the entire program?

    submitted by /u/giovy567
    [link] [comments]

    Is Scheme pure-functional as claimed? If so, write an infinite-loop in Scheme and debugger-breakpoint during it and copy to some github/sourceforge/etc url and we will inspect into your breakpoint to verify its pure-functional

    Posted: 04 May 2018 04:30 PM PDT

    Need help connecting a mysql DB to an ASP.NET C# MVC project, and making queries from my program

    Posted: 04 May 2018 12:16 AM PDT

    Hello all,

    I am doing a project in ASP.NET C# MVC and need to connect to a mysql DB. I have tried googling for information, and came across the connection string. However it's not working. One thing to note too, is that in order to access my DB, I first need to SSH into my personal account, and then I can log into my mysql account by doing mysql -something something something(privacy purpose). I tried creating an ADO.NET Entity Data Model, and able to select MySQL, but because of what I've mentioned, I can't log into my mysql account directly.

    Does anyone know how I can do this?

    Also, once I am able to connect my project to my mysql DB, how would I do queries from ASP.NET in C#, and some Javascript code?

    thanks!

    submitted by /u/Herrowgayboi
    [link] [comments]

    No comments:

    Post a Comment