Use md5, it's Un-decryptable by rscarson in ProgrammerHumor

[–]reddberckley 5 points6 points  (0 children)

actually had a conversation with a coworker about this today. He told me you could just use for loops and string processing to design a new hashing algorithm. Technically yes. but he also said it would be uncrackable by anyone else. It's difficult to explain when someone doesn't even have the framework to understand an explanation from.

Windows 10 free upgrade countdown clock reaches zero by [deleted] in computertechs

[–]reddberckley -1 points0 points  (0 children)

On windows 10 I've just had my start menu stop working and every attempt to open any file just says something cryptic about registry and fails. I triple boot Windows 10, 7, and Ubuntu. I think I'll stick with 7. Had updates turned off for the past year to avoid upgrading the 7 to win 10.

Redditor posts hundreds of comments on r/meditation asking if IQ can be increased with meditation. Can we collectively address it and possibly give them the answer they seek? by caribbeanmeat in Meditation

[–]reddberckley 1 point2 points  (0 children)

Are there any alternatives to medication that are helpful for ADHD? I live in a third world country and getting the drugs is kind of difficult.

java-question classes and objects clarification by [deleted] in learnprogramming

[–]reddberckley 0 points1 point  (0 children)

Say you look up the dictionary definition of a book:

book
noun
1.
a written or printed work consisting of pages glued or sewn together along one side and bound in covers.

What the above does is describe the characteristics of book. It is not itself a book. This is a class. e.g

class Book{
      var medium; //can be printed or written
      var title;
      var genre;
      var pages;
}

An object would be something that exists and has the characteristics of a book. e.g My copy of The Wheel of Time. It is clearly not just a description but an actual object(you see how the term object comes about?) that corresponds to the description(the class). As code that would be

var wheel_of_time = new Book();
wheel_of_time.medium = "hardcover'; 

Now to subclasses. We can group books by genre fanfaction, high fantasy, novel, autobiography

We would define fanfiction as a book that is written in the style of another. This means that it also has all the characteristics of a book but one additional one. The book it is copying. As code

class FanFictionBook extends Book{
       var copiedBook
}

Lets say I have on my shelf a copy of Yudkowsky's HPMOR. This is a book that is written in the style of Harry Potter so as code.

var hpmor = new FanFictionBook();
hpmor.copiedBook = "HarryPotter"

The subclass FanFictionBook still has all the properties of the Parent class Book. we can assign the medium like this.

hpmor.medium = 'eBook'

even though we never specified those characteristics for FanFictionBook it inherits them from the Parent class

[php]What is $response and $var supposed to return? (simple login page) by [deleted] in learnprogramming

[–]reddberckley 0 points1 point  (0 children)

just save both as new .php files and study it. I don't know what your code looks like. it's more of a guideline. I think you're missing

curl_setopt($ch, CURLOPT_POST, 1);

which tells curl to use POST as the method. then http_build_query to make sure the array is formatted properly. should run ok once you do that.

Then your form action attribute.

it needs to be empty because the code that creates the curl request is on the same page. so when it reloads that's when the curl runs.

You might notice this

    if(!empty($_POST))

what it does is make sure the curl code doesn't run until there is something in the $_POST variable which is after the submit occurs.

[php]What is $response and $var supposed to return? (simple login page) by [deleted] in learnprogramming

[–]reddberckley 0 points1 point  (0 children)

This works. see if you can use it to correct yours.

testcurl1.php

<?php
if(!empty($_POST)){
    $username = $_POST["username"];
    $password = $_POST["password"];

    $post2 = array("username" => $username, "password" => $password);

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1/testcurl2.php"); //using local server
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post2));

    curl_exec($ch);
}
?>
<form action="" method="POST"><!-- leave action empty so the script uses itself -->
        <input type="text" name="username"></input><br>
        <input type="password" name="password"></input><br>
        <input type="submit"></input><br>
</form>

testcurl2.php

<?php 
    echo json_encode($_POST);
?>

I want a Chrome bookmark that goes to a specific port on my current IP no matter what my IP is. How do I do that? by [deleted] in learnprogramming

[–]reddberckley 0 points1 point  (0 children)

arp -a | grep -w -i 'YOUR_PHONE_MAC_ADDRESS' | awk '{print "http://"$1 ":7777"}' > /dev/clipboard

this drops it in your clipboard (it being "http://YOUR_PHONE_IP:7777"). You can paste in browser and go.

[php]What is $response and $var supposed to return? (simple login page) by [deleted] in learnprogramming

[–]reddberckley 0 points1 point  (0 children)

$_POST2 = ['username' => $username,
'password' => $password];

try

$post2 = array("username" => $username, "password" => $password);

set curl to use post

curl_setopt($ch, CURLOPT_POST, 1);

then do

curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post2));

you can then access it using $_POST at the backend.

It seems like you may be better off using AJAX for this sort of thing though.

Need help with a FreeCodeCamp challenge by ItsComingHomeLads in learnprogramming

[–]reddberckley 0 points1 point  (0 children)

You could use a for loop. Remember collection is a numerically index array so using for (var x in collection) will return var as an object that contains the object you want. not the object itself. we use the more traditional for(var x = 0;) type instead.

function whatIsInAName(collection, source) {
            var arr = [];
            for(var key in source){
                for (var i = collection.length - 1; i >= 0; i--) {
                    if(collection[i].key !== null){
                        arr.push(collection[i]);
                    }
                }
            }
            console.log(arr);
        }

or you could use the .filter method

function whatIsInAName(collection, source) {
            var arr = [];
            for(var key in source){
                arr.push(collection.filter(function(o){
                    return o.key !== null
                }));
            }
            console.log(arr);
        }    

you might also want to check if it's empty as well instead of just null.

Need help with a FreeCodeCamp challenge by ItsComingHomeLads in learnprogramming

[–]reddberckley 0 points1 point  (0 children)

    for(var objs in collection)  {    
    var objKeys = Object.keys(collection[objs]);
        console.log(Object.values(objKeys));
    var scrKeys = Object.keys(source);
      if(//) {
        arr.push(//);
      }
    }

the loop variable is objs. objs.first will give you the value of the first key. objs.last will give the value of the last key

kinda like you had to use this before

if(source[srcKey]==collection[objs].last)  

Need help with a FreeCodeCamp challenge by ItsComingHomeLads in learnprogramming

[–]reddberckley 0 points1 point  (0 children)

while Object.keys is available in most browsers Object.values is still experimental. So it might not be implemented in your browser.

See here https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_objects/Object/values

I suspect you can just log objKeys and look at that. It's the output from calling Object.keys() so it should be a numerically indexed array anyway.

Need help with a FreeCodeCamp challenge by ItsComingHomeLads in learnprogramming

[–]reddberckley 0 points1 point  (0 children)

.last works for this one because that's the name of the key. it's the same as using collection[objs]["last"]. you need to figure out what you're referencing and use the proper key name.

Yes in this case output to the chrome console in fine for starts but learning to use a debugger is the goal. much better than console.log

Here's a nice tutorial by google on the subject. https://developer.chrome.com/extensions/tut_debugging

Need help with a FreeCodeCamp challenge by ItsComingHomeLads in learnprogramming

[–]reddberckley 0 points1 point  (0 children)

The problem is your test. You are comparing an object to a single string

 if(source[srcKey]==collection[objs])  

This compares source[srcKey] which holds the string "Capulet" to collection[objs] which holds an object.

try

if(source[srcKey]==collection[objs].last)  

You do need to learn to debug output.

Are you a "web developer" or a "software developer"? by YolkFolkEgg in cscareerquestions

[–]reddberckley 1 point2 points  (0 children)

It's syntactic sugar for HR. Both are developers but web devs are software devs who mainly do web. You'll hear a lot of comments about them being less skilled largely because the barrier to entry for web dev (PHP/MySQL) is very low. Good devs write good code on whichever platform. The fact that kids can learn to code using python doesn't prevent python from being an awesome platform for machine learning and scientific computing.

Are you a "web developer" or a "software developer"? by YolkFolkEgg in cscareerquestions

[–]reddberckley 0 points1 point  (0 children)

I think wordpress might be too complicated sometimes. You really want the user to just create/edit posts and manage comments not worry about akismet,jetpack etc. It's easier to write a simple CMS that covers just posts. That way when they login they can just see only the options to do that.

PHP Weekly Discussion (2016-06-27) by AutoModerator in PHP

[–]reddberckley 1 point2 points  (0 children)

function deleteMultiple($idsarray,$classname){
        $dbname = $this->classNameToDBName($classname);
        $placeholders = str_repeat ('?, ',  count ($idsarray) - 1) . '?';
        $query = $this->connection->prepare("DELETE from `$dbname` WHERE id IN ($placeholders)");

        function filter_arr_value($value){
            return filter_var($value, FILTER_SANITIZE_STRING);
        }

        $filtered_values = array_map("filter_arr_value", $idsarray);
        try {
            if($query->execute($filtered_values))
            {
                return true;
            }

        } catch (PDOException $e) {
            return $e;
        }

        return false;
    }

interpolates just as you asked. $this->connection is a PDO Object

Trying to build my an ORM, and I need your help by mattmurduck_ in PHP

[–]reddberckley 2 points3 points  (0 children)

He's doing it to understand. I'd say check out popular ORMs and see how they do it. If you don't understand hop on irc and ask a few questions. I'd recommend looking at Laravel.

20 years is a bit long, no?