My solution to question 5 isn't elegant, but it works and I was able to do it in under an hour.
EDIT: Oh, I'm off the mark for 4. Welp, not getting hired any time soon.
My solution to question 5 isn't elegant, but it works and I was able to do it in under an hour.
EDIT: Oh, I'm off the mark for 4. Welp, not getting hired any time soon.
Here's the link for anyone that's interested in those problems.
The guy writing comes off as an ass, but the problems are worth the read.
My mind was blown the first time I saw debugging with watches and call stacks.
Here's the link for anyone that's interested in those problems.
The guy writing comes off as an ass, but the problems are worth the read.
Date is a date, not an int. I can't think of a language that doesn't provide some data type for storing dates (and times)Dumb question. Is "date" an int data type? If so, how would that work in code? I mean how it's supposed to be written? Do I have to have 3 variable naming them "month", "day", and "year"? So I have to make a struct that holds them right? Would my parameter have three variables since I need three integers to make a date?
Dumb question. Is "date" an int data type? If so, how would that work in code? I mean how it's supposed to be written? Do I have to have 3 variable naming them "month", "day", and "year"? So I have to make a struct that holds them right? Would my parameter have three variables since I need three integers to make a date?
You're an idiot. An idiot of the kind I've been before.Jesus Christ, I screwed up and deleted hours of work using git reset --hard. Thank god almost all of it was still visible in my shell, as I had used git diff a few times.
You're an idiot. An idiot of the kind I've been before.
Been rescued by editors caching files before. That's some 'nononoyes' material right there.
No you should persist the access token if you want to make further requests, and it'll eventually expire, at which point you're supposed to demand an access token again if you want to update user data. That's what the token is for (making requests in the name of the related user in the context of your app).
Of course you should persist the User ID -- this is what enables persistence. The access token will make it possible to login the user via Facebook, and log him in again once he's killed his cookies or whatever. Check the Graph API Explorer, for example, when you query /me: https://developers.facebook.com/tools/explorer/?method=GET&path=me&version=v2.3& -- you obtain an app-scoped user ID, which you can look up in your DB and it's good.
So social login works like this, in an abstract manner:
- Obtain the access token (login with POST-back or whatever)
- Query the token's owner at the platform
- Store ID and other stuff, but also the token if you want to make requests in his name without him being on the site
- User's browser gets his cookie, the cookie builds the session when viewing
- The cookie of course relates the viewer to your DB entry
- If applicable, refresh the token autonomously (not all platforms support this; Google+ does, for example)
So if the cookie is gone, you start the same sequence (demand access token), but as soon as the token owner is identified and you discover him in your database, you can build his environment as it was when he last manipulated data or whatever.
#include <string.h>
#include <stdlib.h>
#include <locale.h>
#include <stdio.h>
// the number of characters in a multibyte string is the sum of mblen()'s
// note: the simpler approach is mbstowcs(NULL, str, sz)
size_t strlen_mb(const char* ptr)
{
size_t result = 0;
const char* end = ptr + strlen(ptr);
mblen(NULL, 0); // reset the conversion state
while(ptr < end) {
int next = mblen(ptr, end - ptr);
if(next == -1) {
perror("strlen_mb");
break;
}
ptr += next;
++result;
}
return result;
}
int main(void)
{
setlocale(LC_ALL, "en_US.utf8");
const char* str = "z\u00df\u6c34\U0001f34c";
printf("The string %s consists of %zu bytes, but only %zu characters\n",
str, strlen(str), strlen_mb(str));
}
But I keep getting 10 characters instead. Anyone have any idea what could cause the difference? I do have clang 3.6 installed while on the website they use gcc or clang 3.5, but could that really be causing the issue?The string zß水🍌 consists of 10 bytes, but only 4 characters
You're totally welcome. This is my day-to-day and I enjoy helping others with their first steps into that territory.Thank you, this was really helpful. Really appreciate it.
4 is really simple when you think about it. Just sort the list and provide a custom compare method.
Make sure your solution works not only for the provided list but for a list that also includes numbers like 5, 50, 55, 56, ect.
I saw an article "Five programming problems every Software Engineer should be able to solve in less than 1 hour". I wrote the following three functions for question 1: "Write three functions that compute the sum of the numbers in a given list using a for-loop, a while-loop, and recursion.".
How could I write these better, or optimize them better?
Code:public static int sumOfListRecursive(List<int> numbers) { if (numbers.Count == 0) { return 0; } else { int sum = 0; sum += numbers[0]; numbers.RemoveAt(0); return sum + sumOfListRecursive(numbers); } }
public static int sumOfList(List<int> numbers)
{
return sumOfListRecursive(numbers, 0);
}
public static int sumOfListRecursive(List<int> numbers, int sum)
{
if (numbers.Count == 0)
{
return sum;
}
else
{
sum += numbers[0];
numbers.RemoveAt(0);
return sumOfListRecursive(numbers, sum);
}
}
Can anyone offer me some advice please? Thanks.
awk '/^>/{$0=$0"_Contig_"(++i)}1' input_file.fasta > output_file.fasta
awk '/^>/{print ">Contig_" ++i; next}{print} input_file.fasta > output_file.fasta
Hello everyone, current bio student here. I want to eventually get into bioinformatics, so that requires me to start learning languages like sql and python. What are some good starter projects? I've been to the reddit for beginning projects and seen in the "learning python the hard way" that it culminates in the creation of a website but I was hoping to get some perspective from people more steeped in the field as to what might be a good place to start with python for example.
Jesus Christ, I screwed up and deleted hours of work using git reset --hard. Thank god almost all of it was still visible in my shell, as I had used git diff a few times.
Hello everyone, current bio student here. I want to eventually get into bioinformatics, so that requires me to start learning languages like sql and python. What are some good starter projects? I've been to the reddit for beginning projects and seen in the "learning python the hard way" that it culminates in the creation of a website but I was hoping to get some perspective from people more steeped in the field as to what might be a good place to start with python for example.
Isn't it saved in the reflog?
> git reflog
b0d059c HEAD@{0}: reset: moving to HEAD~1
4bac331 HEAD@{1}: commit: something
> git reset --hard HEAD@{1}
I assume a good way to learn is trying to rewrite/optimize code?
I just got an offer for tutoring, how much should I charge per hour?
First class in CS sequence. I don't know if the student earns an income but their parent contacted me.Tutoring what and at what level? Does the person/people that you plan to tutor earn an income?
First class in CS sequence. I don't know if the student earns an income but their parent contacted me.
I replied telling them the rate was negotiable and asking then give me more info about their circumstances and needs. I want to start at 25
First class in CS sequence. I don't know if the student earns an income but their parent contacted me.
I replied telling them the rate was negotiable and asking then give me more info about their circumstances and needs. I want to start at 25
Does anyone have tips on remember syntax? It's like the only thing that gets me with Java.
Does anyone have tips on remember syntax? It's like the only thing that gets me with Java.
I'm going into the 4th semester of Computer Engineering. My university offers two computer majors, the one I'm studying now and the other one I don't know exactly how to say it in English, but in Spanish is Ingeniería Informática.
We share a lot of classes the first two years (Data Structures, Algorithms, Calculus, DB, etc.). Later on, CE focuses on classes like Computer Architecture, Computer Organization, NOS, mostly hardware stuff I guess.
The other engineering (I think is also called Computer Engineering in the US haha) focuses on the handle of data (Mining, Warehouse), AI, Network and Server Administration. The thing is I can switch to this major next semester without losing any progress, because I find myself a little bit more interested with these classes. But one of the reasons I think that is because I don't have a clear idea about what can be learned on the "hardware" classes and if this knowledge is more looked upon in the industry.
So, what do you think? Which of these two do you find more interesting and relevant to learn?
I'm going into the 4th semester of Computer Engineering. My university offers two computer majors, the one I'm studying now and the other one I don't know exactly how to say it in English, but in Spanish is Ingeniería Informática.
We share a lot of classes the first two years (Data Structures, Algorithms, Calculus, DB, etc.). Later on, CE focuses on classes like Computer Architecture, Computer Organization, NOS, mostly hardware stuff I guess.
The other engineering (I think is also called Computer Engineering in the US haha) focuses on the handle of data (Mining, Warehouse), AI, Network and Server Administration. The thing is I can switch to this major next semester without losing any progress, because I find myself a little bit more interested with these classes. But one of the reasons I think that is because I don't have a clear idea about what can be learned on the "hardware" classes and if this knowledge is more looked upon in the industry.
So, what do you think? Which of these two do you find more interesting and relevant to learn?
I don't understand how this happens: http://stackoverflow.com/a/414890/331041
How can you have over 9000 reputation and answer a simple question so completely wrong? I've seen this multiple times from a variety of different high-rep users. It's weird.
It's a little shocking to me. I don't post something as an answer unless I'm sure. And, you're encouraged to delete your answer if you're wrong. My suspicion is that it's strategic. That is, that you tend to get more rep by quickly guessing than you do by waiting to make informed posts.Not that shocking really, even "experts" can get simple things wrong from time to time. This goes doubly for programming.
I don't understand how this happens: http://stackoverflow.com/a/414890/331041
How can you have over 9000 reputation and answer a simple question so completely wrong? I've seen this multiple times from a variety of different high-rep users. It's weird.
I have simple AWK question in Linux.
>Sequence_name
ATCGCA
>Sequence_name
ATCAGA
awk '/^>/{print ">Contig_" ++i "_"substr($0, 2); next}{print}'
>Contig_1_Sequence_name
ATCGCA
>Contig_2_Sequence_name
ATCAGA
I was shown a program at work last Thursday that I'm required to update. Never seen the code or even used the program before that, and it hasn't been updated in over a year.
I was able to get a bit accomplished yesterday and today, but the constant "magic numbers", absolutely no comments, and hard to read code in general is giving me headaches.
Anyone else ever have this experience? Any tips for me?
Try to write a bunch of tests for it. Then it's easy to verify that the changes you're making are sound, and it also helps you to understand the code at the same time
In reading through this Effective Modern C++ book, a lot (and I mean a lot) of new features use templates. Do y'all have any advice for learning/working with templates in general? I'm pretty weak in that area.
For compile time reasons? Hidden bugs? Too much time to implement with too little gains?My general advice would be to go ahead and use the STL all you want, but try to avoid writing your own templated code as much as possible. Prefer using overloading or polymorphism instead of writing template code when you can.