Jump to content

sKunKbad

Members
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by sKunKbad

  1. Twilio is the most popular service and can do exactly what you want.

     

    I'll check into it, but a quick look makes it seem really expensive for the custom short code. $3K to $4.5K for three months + per text fee. I wasn't given a budget, so I'm not sure what to expect when I tell my boss about it.

     

    I found one that would be nice, textmarks.com, because they have a perfect API. The problem is that they use a shared shortcode. Because of that, we could only choose a "group" name that isn't already in use, and it's highly unlikely that we could find a great group name that was available, such as "help", "info", etc, etc.

  2. I've been given the task to find a few solutions to what we want to do, and wondering if any of you have used services that you recommend. We basically need potential clients to send a text message to a short code, then we would want the service to send an automated response and send our web server the details of the inbound text message:

     

    1) Person is told to text message us, and we would like to have a short code, but we don't have one now.

     

    So, for instance, they text "KEYWORD" to 13245

     

    2) Service then sends them an automated response, like "Thank you. We will call you soon".

     

    3) Service uses some sort of web hook (Simple HTTP request) with query params or post data to let our web server know of the details of the inbound text message, the phone number that it was sent from, and the contents of the message, in this case "KEYWORD".

     

    That's it. It doesn't seem like much, but there's a lot of crap to wade through on a Google search, and hoping somebody would have some advice or recommendations.

  3. I've been using branches a lot more since I created this thread, and I think this scenario is explained as follows:

     

    When a local repo is fetching from origin, if origin has a repo that local has not yet had, when checking out that new branch for the first time, the branch is automatically current with origin/"branch".

  4. ...No? I don't know what you're seeing but when you do a merge/pull you're only updating the branch you have checked out. Fetch can update all remote branches but any local branch remains where it was.

     

    Well, maybe our versions are different or something. Fetch followed by merge seems to be updating my local develop, even when I'm on the master branch. My git version is 2.7.0, and I'm on Ubuntu 14.04.

  5. Normally you work on one branch at a time. If you want your master to be up-to-date then you would do a fetch/merge (or a pull which is the same thing). Actually, for something like master, you should never be committing to it anything besides merges from other branches so I do a fast-forward merge.

    Normally you would then, later, decide you want to work on the develop branch. You check it out, do a merge, resolve conflicts, and begin working.

     

    No, you cannot merge into multiple branches at once with a single command. The main reason would be the difficulty with conflict resolution.

     

    What you can do is script it yourself: fetch, for each branch { checkout, merge, do something in case of conflicts (eg, pause and wait for the user to resolve), and commit }

     

    Interesting. I thought it would be normal to have a bunch of different branches, so that different things could be worked on separately from other things. For my own purposes,  a single branch is fine.

     

    One thing that seems strange to me is that I am noticing that commits on develop that are not merged with master seem to be automatically merged with the local develop branch when I fetch/merge the master branch. For instance, right now develop is ahead of master by one commit, and when I fetched/merged local master with origin master, local develop was magically merged. So, it would seem that fetch/merge on master automatically brings all of the other branches up to date.

  6. I use git every day, but don't do much with branches because I work alone. I'm curious about something related to the branches, when a new branch is on a remote, and then it needs to be fetched and merged separately from the master branch.

     

    So pretend I'm on the master branch on my machine:

    git checkout -b develop
    # I make changes to files on develop
    git add .
    git commit -am "I have made changes to develop"
    git push origin develop

    Now there is a develop branch on the remote. Somebody else now fetches and merges (they are on master):

    git fetch origin
    # git shows that there is a new branch develop, and merge is also required for origin/master

    Normally without the develop branch, I would run this command from master:

    git merge origin/master

    Do I also need to checkout develop and merge origin/develop?

    # Do I need to do this too?
    git checkout develop
    git merge origin/develop

    Is there a way to merge all branches with their remote counterparts, all in one command?

     

  7. I have a table named d_records:

    +--------------+-----------------------+------+-----+---------+----------------+
    | Field        | Type                  | Null | Key | Default | Extra          |
    +--------------+-----------------------+------+-----+---------+----------------+
    | id           | int(10) unsigned      | NO   | PRI | NULL    | auto_increment |
    | user_id      | int(10) unsigned      | NO   |     | NULL    |                |
    | msg_datetime | datetime              | NO   |     | NULL    |                |
    | msg          | text                  | YES  |     | NULL    |                |
    | status       | enum('open','closed') | NO   |     | open    |                |
    +--------------+-----------------------+------+-----+---------+----------------+

    I have a trigger that is supposed to do an insert on another table, the h_records. On insert into d_records, I need to look up the user's full name, but that requires also looking up their user level in another table. So I tried this:

    DELIMITER $$
    
    DROP TRIGGER IF EXISTS cks_trigger ;
    $$
    CREATE TRIGGER cks__trigger
    AFTER INSERT
       ON `d_records` FOR EACH ROW
    BEGIN
       DECLARE uLevel tinyint(2);
       DECLARE fullName varchar(120);
    
       SELECT user_level
       FROM users
       WHERE user_id = NEW.user_id
       INTO uLevel;
    
       IF uLevel = 1 THEN
           SELECT CONCAT( p.first_name, " " , p.last_name)
           FROM basic_users p
           WHERE p.user_id = NEW.user_id
           INTO fullName;
    
       ELSEIF uLevel = 2 THEN
           SELECT CONCAT( p.first_name, " " , p.last_name)
           FROM employees p
           WHERE p.user_id = NEW.user_id
           INTO fullName;
    
       ELSEIF NEW.user_id = 123456 THEN
           SET fullName = 'skunk';
    
       END IF;
    
       IF fullName IS NOT NULL THEN
           INSERT INTO `h_records` ( user_id, full_name )
           VALUES ( NEW.user_id, fullName );
       END IF;
    
    END;$$
    DELIMITER ;

    But when I do that, MySQL throws an error on insert into d_records, claiming that user_id column doesn't exist in d_records. As soon as I drop the trigger I can do an insert again.

     

    The actual tables and trigger are more complex, but I've simplified the code to make the problem easier to see. What am I doing wrong with the trigger?

     

     

     

  8. I've got a working delete query that removes rows where there is no match in another table. It works fine, but the example I found online made me wonder about something.

    DELETE a
    FROM table_a a
    LEFT JOIN table_c c
    ON c.id = a.id
    WHERE c.id IS NULL

    My question is about the first line, "DELETE a". Does that "a" make the query functionally different than leaving it out, like this:

    DELETE
    FROM table_a a
    LEFT JOIN table_c c
    ON c.id = a.id
    WHERE c.id IS NULL

    Are these two delete queries exactly the same for the intended use? I've just never seen somebody write a delete query like that (including that "a") before.

     

     

  9. Either of these:

     

    https://github.com/mailhog/MailHog

    http://mailcatcher.me/

     

    Super easy to install and configure, and it provides a web interface on an alternate HTTP port for viewing mail. You can send mail to any email address and they will be captured in one big list in the web interface.

     

    I've used a couple different solutions over the years, including Postfix setups with Squirrelmail or some other web client, but this is far, far better.

     

    What I found out the hard way was that by using fake SMTP that I did not see SMTP related errors, and thereby did not have adequate error handling. In your experience, can MailHog or mailcatcher be set up so that it will throw actual errors for testing purposes?

  10. I've been using PHP's crypt function to hash passwords, and specifically using the CRYPT_BLOWFISH hash type. I see where it is the salt, delimited by dollar signs that tells PHP how to hash the password.

     

    $2y$ at the beginning of the salt says to use CRYPT_BLOWFISH, unless on an older version of PHP, and then it's $2a$ or $2x$.

     

    The cost parameter comes next, and setting that is easy, just a number between 04 and 31.

     

    Next the docs say to have a string that is 22 characters, from the alphabet "./0-9A-Za-z". It does mention that characters outside this range will cause crypt to return a zero length string. What it doesn't say is if more than 22 characters can be supplied. It also doesn't mention if the dollar sign at the end is mandatory.

     

    Oddly enough, the example that the PHP docs gives has more than 22 characters (26):

    if (CRYPT_BLOWFISH == 1) {
        // usesomesillystringforsalt is actually 26 characters
        echo 'Blowfish:     ' . crypt('rasmuslerdorf', '$2a$07$usesomesillystringforsalt$') . "\n";
    }
    

    So, what is the deal here? Can I supply 32, 64, etc.? Is it just truncated by PHP? It isn't returning a zero length string when I use 32.

  11. I mostly work from home, and ISP blocks outbound email servers.

     

    I did find a decent solution though. Thunderbird has a .eml import add-on, so after I've "sent" some emails to fakeSMTP, I can just import them in Thunderbird. The downside is that Thunderbird expects an actual email account, so I had to link up to one of my gmail accounts.

  12. For a long time I've been logging emails to the filesystem on dev so that I can make sure they look right. I actually log them as HTML files, which is cool because I can open them up in a browser and see the display. Only thing is, I can't open any attachments, and see if the attachments were good.

     

    So, then I found FakeSMTP, which is a little java program, and it listens for emails and stores them as .eml files. I can look at the .eml files and get an idea if things were good, but still can't open the attachments.

     

    So I'm wondering what others are doing. It would be awesome if there was a way to send emails out and have a program listening that put them in Thunderbird, so I could actually see the HTML and open the attachments. I don't use Thunderbird for normal email, so it could just be dedicated to dev if that matters.

     

    What do you do? How do you do it?

  13. Well, the advice that I was following is in relation to the autocomplete attribute on login form fields, and specifically setting them to "off". For whatever reason, it seems like the browsers don't want to obey when autocomplete is off. So the advice is to set a readonly attribute, and then clear in on focus. It really does seem to work, but I don't want to load jQuery just for this.

  14. If these are user passwords to a site where the login is an email address w/ password, then there really is no harm in deleting everyone's password as long as there is a password reset feature. You'd really want to enforce the new stronger passwords anyway.

  15. Let's say that I have a table for vegetables, and the vegetables are normally sorted by the date they arrived at the store. There is also a status, where the vegetable can be acceptable, good, great, special, rotten, etc.

     

    So if I were to query for the vegetables, sorted by the arrival time, it would be a simple sort by time. What if I always want to ensure that vegetables of a certain status are at the end of the returned set of rows?

     

    Expected result:

    Carrot,     2015-7-10 08:00:00,   rotten
    Broccoli,   2015-7-10 07:00:00,   great
    Radish,     2015-7-10 06:00:00,   good
    Lettuce,    2015-7-10 05:00:00,   acceptable
    Pepper,     2015-7-10 05:00:00,   good
    Potato,     2015-7-10 09:00:00,   expired
    Tomato,     2015-7-10 08:00:00,   expired
    Turnip,     2015-7-10 07:00:00,   expired
    

    I just used vegetables as an example, but what I wanted to show was that although sorted by date, the vegetables with a status of expired are at the end of the list. I can't sort by status, because status is not guaranteed to be alpha or numeric or anything else.

     

    Also, I need to be able to paginate this, so how do I get those with special status (expired in this case) at the end?

     

    Sorry, I'm not especially good with MySQL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.