this.setState is undefined

I keep seeing answers that say to use => or .bind(this) but neither of those solutions worked.
import React, { Component } from 'react';
import { View, Text, TextInput, StyleSheet } from 'react-native';

export default class MyWeatherApp extends Component {
  constructor(props) {
  super(props);

  this.state = {};
}

getInitialState() {
  return {
    zip: '',
    forecast: null,
  };
}

_handleTextChange(event) {
  var zip = event.nativeEvent.text;
  this.setState({zip: zip});
}
----Answers------------
1.
When you extend React.Component with ES2015 class syntax you need to bind your action handlers to a context of your class.
Try this: onChange={e => _handleTextChange(e)}
Generally, it's better not to use arrow functions or bind methods inside render as it generates a new copy of the function on any render call. Move function declaration to the class constructor.
I personally prefer to use arrow functions as class properties in this case
class MyClass extends React.Component {

  handleClick = () => {
    // your logic
  };

  render() {
    return (
      <button onClick={this.handleClick}>Click me</button>
    );
  }
}
It's not a part of ES2015 specification but babel stage-0 preset supports this syntax
You can read more about context binding in React in this article
2.
i hope the below code may give you the idea
import React, { Component } from 'react';
import { View, Text, TextInput, StyleSheet } from 'react-native';

export default class MyWeatherApp extends Component {
  constructor(props) {
    super(props);
    this.state = {
      zip: '',
      forecast: null
    };
   }

_handleTextChange(event) {
  var zip = event.nativeEvent.text;
  this.setState({zip: zip});
}

render() {
return (
   <button onChange={e => _handleTextChange(e)}>Click me</button>
  );
 }
}
 

Designing Data structure for Firebase

------Question-------
Warning: My query would be more theoretical (sorry programmers, please bear with me). I am trying to get some idea on how to define the database structure for use in Firebase.
I am exploring the use of Firebase as a backend for a Review app (in Android) I am trying to build.
The app provides product details and review for products of different kinds. So here is an example use case.
  1. The products displayed in the app are of same type (say smartphones). In this use case, defining the database structure is easier. For every phone, I simply need to save the phone specs to Firebase and retrieve them into my app.
Root
 |
 +--Smartphone
     |
     +--Manufacturer Name
     +--Screen Size
     +--Screen Density
     +--Processor
     +--RAM,...
  1. The products displayed in the app are of different type (say smartphones, Car, Book,...). In this use case, defining the database structure becomes complex. I can simply define the data structure like
Root
 |
 +--Product
     |
     +--Manufacturer Name
     +--Screen Size
     +--Screen Density
     +--Processor
     +--RAM
     +--Fuel type (Petrol/Diesel/Electric)
     +--Vehicle Type (Sedan/Hatchback)
     +--Vehicle Price,...
However, the problem with above data structure is, when I am trying to make a product review for a smartphone, the data related to Car will remain blank. Same will be the case for a product review of a Car.
This problem can be solved by using Flattening the data structure. This is where I am confused.
Root
 |
 +--Smartphone
 |   |
 |   +--Manufacturer Name
 |   +--Screen Size
 |   +--Screen Density
 |   +--Processor
 |   +--RAM
 |
 +--Car
     |
     +--Fuel type (Petrol/Diesel/Electric)
     +--Vehicle Type (Sedan/Hatchback)
     +--Vehicle Price,...
However, all product reviews will be displayed in a single activity/fragment. Hence, there will not be different activities/fragments for every product type. Could someone provide me a clear picture of using flattened data structures in my use case?
----Answers----
1.
You can structure your database like this:
products: {
    smartphones: {
        smartphone1: {
            name: "Best Phone",
            ram: "6 GB",
            screen: "5.5 inch"
            reviews: {
                review1: true,
                review2: true
            }
        }
    },
    cars: {
        car1: {
            name: "Lightning"
            reviews: {
                review3: true,
                review4: true,
                review5: true
            }
        }
    }
},
product-review: {
    review1: {
        submittedBy: "Conqueror",
        message: "Best phone at this price",
        timestamp: 1472405901
    },
    review2: {
        submittedBy: "Magic Blaster",
        message: "Pros: RAM, Cons: Everything else."
        timestamp: 1472405901
    },
    review3: {
       submittedBy: "Boss",
       message: "Excellent Car",
       timestamp: 1472405901
    },
    ...
}
Every product(smartphone1, car1 etc..) contains a reviews node, so you can easily load the linked reviews of a particular product.
2.
Here is the flattest database structure that I can think of. For the products node, you can also use the third structure in your question, it will only affect the logic on how to map the item in your app.
products: {
    item1: {
        type: "smartphone",
        manufacturer_name: "some value",
        screen_size: "some value",
        screen_density: "some value",
        processor: "some value",
        ram: "some value"
    },
    item2: {
        type: "car",
        fuel_type: "some value",
        vehicle_type: "some value",
        vehicle_price: "some value"
    }
},
users: {
    user1: {
        name: "some value",
        email: "some value"
    },
    user2: {
        name: "some value",
        email: "some value"
    },
},
products_reviews: {
    item1: {
        user1: ewview1,
        user2: review2
    },
    item2: {
        user2: review3
    }
},
users_reviews: {
    user1: {
        item1: review1
    },
    user2: {
        item1: review2,
        item2: review3
    }
},
reviews: {
    review1: {
        text: "this is my review",
        timestamp: 1472488486000
    },
    review2: {
        text: "this is my review",
        timestamp: 1472488486000
    },
    review3: {
        text: "this is my review",
        timestamp: 1472488486000
    }
}
Now you should be able to retrieve all reviews from each user and also retrieve all reviews for each product.
Comment here if you have questions, hope this helps :)

Is it possible to access (read only) the variables captured by a lambda?

Is it possible to access (read only) the variables captured by a lambda?
This doesn't work:
std::function<double  (const double)> plus (const double a) {
    return [a] (const double b) -> double {
        return a+b;
    };
}

auto plus5 = plus(5);
cout << plus5.a << endl;
----Answers------
1. 
auto plus( double a ) {
  using R = struct {
    double a;
    double operator()(double b)const{return b+a;}
  };
  return R{a};
}
live example.
Please note that a std::function is not a lambda, and lambda is not a std::function. They work with each other, but using one term to refer to the other is the opposite of helpful.
2.
This is not how a lambda should be used.
The interface of a lambda is its function signature. Its captures should be considered an implementation detail and not be visible to the user.
If you want explicit access to the captures, write your own function object and expose the respective data members accordingly:
struct MyPlus {
    double a;
    MyPlus(double x) : a(x) {}
    double operator()(const double b)
    {
        return a+b;
    }
};

auto plus5 = MyPlus(5);
std::cout << plus5.a;
 3.
Well let's relieve Yakk's karma; here's a proof of concept of a C++14 solution which you definitely don't want to let loose in the wild:
auto magic = [a, b](auto &&... args) mutable -> decltype(auto) {
    return makeOverload(

        // Capture access boilerplate
        [&](cap_<0>) -> auto& { return a; },
        [&](cap_<1>) -> auto& { return b; },

        // Actual function
        [&](int p) {
            return "[" + std::to_string(a) + ", " + b + "](" + std::to_string(p) + ")";
        }

    )(std::forward<decltype(args)>(args)...);
};
makeOverload takes any number of functors and blends them into a single one. I borrowed the idea from this blog post, with help from the comment section to make it actually work.
The resulting functor is used to tag-dispatch between the cap<N> tags and the actual parameters of the function. Thus, calling magic(cap<0>) causes it to spit out the corresponding captured variable, that is a. The actual behaviour of the function is, of course, still accessible with a normal call to magic(123).
As a bonus, the outer lambda is mutable, and the capture accessors return by reference: you actually have read-write access to the captured variables!
You can observe and interact with this creature in its natural habitat on Coliru right here.
 

Running nasm program on ARM linux

Question

I am trying to teach myself assembly programming with NASM. However I only have a Chromebook with ARM processor. I have xubuntu running on it with crunton. However how can I setup a x86 emulation environment to get myself started? I also want to be able to use insight debugger.
Answers
1.
Try bochs or qemu.
If you're only on a chromebook probably without a lot of RAM, you probably just want to run a very minimal Linux system inside your emulated x86 environment. Not a full xubuntu GUI install inside the emulated x86 environment.
For learning x86, you should start with 32 or 64bit ASM, either for functions you call from C, or as a standalone program. (Either really standalone, where you don't link with the C standard runtime or library, and write your own _start in asm, and make your own system calls, or just write main in asm and end your program with a ret from main.)
bochs has a built-in debugger, but using it would be more appropriate for debugging the kernel, or boot-loader. IDK anything about the Insight debugger, but if it can remote-debug, running an ARM binary of it natively, connected to the target you want to debug, might make sense.
You could write x86 asm that you boot directly (instead of a Linux image), but then you'd only have BIOS calls available, and the CPU would start in 16bit real mode with segmented memory and all that crap that's basically useless to learn except for writing bootloaders.
2.
QEMU has a user mode emulation feature which can be used to run x86 Linux programs on ARM Linux, or any other combination of supported architectures.

Android studio add different size drawable and layout folder

how can i add those folders in my project in android studio
res/drawable-ldpi/
res/drawable-ldpi-v8/
res/drawable-ldpi-v11/
res/drawable-mdpi/
res/drawable-mdpi-v8/
res/drawable-mdpi-v11/
res/drawable-hdpi/
res/drawable-hdpi-v8/
res/drawable-hdpi-v11/
res/drawable-xhdpi/
res/drawable-xhdpi-v8/
res/drawable-xhdpi-v11/
res/drawable-xxhdpi/
res/drawable-xxhdpi-v8/
res/drawable-xxhdpi-v11/
res/layout-land
res/layout-small-port-v4
res/layout-sw600dp-v13
res/layout-w480dp-v13
res/layout-v11
res/layout-port
i just made new project and i cant see any folder of those in my project
this is image of my project folders
enter image description here
------Answers----
1.
you have to create new folder inside res folder
2.
In Android Studio, at the top right where you have your project structure and Android View is selected, choose "Project", and you will be able to see the full hierarchy of your project. From there you can achieve what you are trying to do.
3.
Since these are folders, you can always use Windows Explorer to add them.
In Android Studio, the Project Window is currently in the default Android View. If you want to see the physical directory structure, you need to change it to the Project View by clicking on the drop down menu at the top of the Project Window.
enter image description here
Now you can add folders any where you want similar to how you do in Windows Explorer.







Work around for re-rendering new state in react

      import React, {Component} from 'react';
      import Square from './components/board.js';

      const spaceArr = ()=> {
         const arr =[];
         for (var i=0; i<20; i++){
         arr.push(Math.floor(Math.random()*(400-0)));
         }
         return arr;
      };


      class App extends Component{

        constructor(){
          super();
          this.state={
            spaces: spaceArr(),
            array : new Array(400).fill(false)
          } ;
          var th = this;
          this.state.spaces.map(function(value){  
          th.state.array.splice(value, 1, true)});
            this.click= this.click.bind(this);
          }

          componentDidMount(){
            this.setState({array: this.state.array})
          }

          click(i, live) {  
            this.state.array[i]= !live;
            var array = this.state.array;
            this.setState({array: array}, function(){
             console.log(array[i]) 
          })
          }


         render(){

           var th = this;
          return (
             <div>
               <div className='backboard'>
               <div className='board'>
                 {this.state.array.map(function(live, index){

                   return <Square key={index} living={live} clicker=  
                     {th.click.bind(this, index, live)}/>
                   })

                  }
                </div>
             </div>
           </div>
           )
          }
         }

         export default App;
I am trying to figure out how to re-render the updated state change after setState. the click event is a handler that is passed to a child component. the updated array should re-render an updated rendering of child components.

-----Answers------

1. Try this.
 click(i, live) {  
      var array = this.state.array;
      array[i]=!live
      this.setState({array:array}, function(){
         console.log(this.state.array[i]) 
      })
  }
 2.
You shouldn't mutate this.state directly as mentioned in React docs. Use concat for getting a new array before setting the new state:
click(i, live) {  
  var newArray = this.state.array.concat();
  newArray[i]!=live
  this.setState({array: newArray}, function(){
     console.log(this.state.array[i]);
  })
}

3.

on your return it should be,
return (<Square key={index} living={live} 
  clicker= {th.click.bind(th, index, live)}/>
});
 

Resolving Promises Asynchronously in angularjs

My code:
$q(function (resolve) {
    var imageUploadResults = [];
    fileUploadService.uploadImage($scope.filesUpload, "/api/mailbox/uploadAttachFile", function (result) {
        console.log(result);
        imageUploadResults.push(result.LocalFilePath);
    });
    $scope.mail.Files = imageUploadResults;
    resolve($scope.mail);
}).then(function (mail) {
    console.log(mail);
    apiService.post("/api/mailbox/sendMail", mail, sendMailSucceed, sendMailFailed);
});
Expect:
I want to add value to mail.Files finish,then call apiService.post()
Actual:
But it execute apiService.post() with mail.Files value is [].
When apiService.post() execute finish mail.Files return value.length > 0.

------Answers-----

1.
Without knowing exactly which library you are actually using, it seems clear to me that fileUploadService.uploadImage() is asynchronous.
The function that you give as an argument is a callback and there is no guarantee that it would be executed "on time". In your case the path is added to imageUploadResults after the moment where you set $scope.mail.Files.
you should set $scope.mail.Files and call resolve in your callback function.
$q(function (resolve) {
    var imageUploadResults = [];
    fileUploadService.uploadImage($scope.filesUpload, "/api/mailbox/uploadAttachFile", function (result) {
        console.log(result);
        imageUploadResults.push(result.LocalFilePath);
        $scope.mail.Files = imageUploadResults;
        resolve($scope.mail);
    });
}).then(function (mail) {
    console.log(mail);
    apiService.post("/api/mailbox/sendMail", mail, sendMailSucceed, sendMailFailed);
});
2.
When you assigned $scope.mail.Files = imageUploadResults; and resolved resolve($scope.mail); there are no guarantee that fileUploadService.uploadImage finished request and saved imageUploadResults.push(result.LocalFilePath);
Possible solution is to add resolve($scope.mail); right after imageUploadResults.push(result.LocalFilePath); in function passed to fileUploadService.uploadImage
 

Resize problem in scroll area


Hello everyone, here is my code:
myplot *p = new myplot(gao.structpayloadgraph, 
                       gao1.structpayloadgraph, 
                       gao.structcol-2, "payload");

ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->scrollArea->setWidgetResizable(false);
p->resize(ui->scrollArea->size().width(), ui->scrollArea->size().height());

ui->scrollArea->setWidget(p);

-----Question-----

I want p to take up the full available space of the 
scrollbar area and fit itself. However, the appearance looks 'squeezed' 
even though I called the resize function. What should I do to achieve 
the desired effect? 

-----Answers-----

1.
You have to treat the scroll area content widget as a normal QWidget. If you want automatic resize and you must use layouts in Qt. Try the following :
QVBoxLayout layout = new QVBoxLayout( ui->scrollAreaContent);
layout->setMargin(0);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(0);
ui->scrollAreaContent->setLayout( layout);
layout->addWidget(p);
NOTE: ui->scrollAreaContent is a guess, but I think you are using ui files and default content widget is named like that ...
2.
Go to the top right of the QT creator designer screen (Object, Class), right click on the QScrollArea row and select the "Lay Out" menu item, choose a layout (eg vertical or horizontal layout), make sure that your QWidget has a minimum or above size policy. Your scroll widget should now resize with the layout. 



Angular2 Filter issue

Here's how I am using the filter:
  <ion-item *ngFor="let contact of contacts | isMember">
           <ion-label>{{contact.name}}</ion-label>

           {{contact.phoneNumber}}-{{contact.isMember}}
       </ion-item>
Filter definition below:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'isMember'})
export class IsMemberPipe implements PipeTransform {
    transform(value: any): any {

        if (value.isMember === true) {
            return value;
        }
        return undefined;

    }
}
-----

Question

Goal is to only display rows that have isMember flag set to true.
------

Answers

Just ensure your pipe doesn't explode when null is passed in as value
if (value && value.isMember === true) {

How get ownership property of (Method: TRttiMethod) in TVirtualInterface TVirtualInterfaceInvokeEvent?

how i get ownership property of Method: TRttiMethod in OnInvoke method of TVirtualInterface class?
I have this interface:
IPerson = interface(IInvokable)
   ['{45CE428C-F880-4D61-A2C1-0F3CB47130B5}']
   procedure SetName(const Value: string);
   function GetName(): string;

   [TEntityField('Field Name Here')]
   property Name: string read GetName write SetName;
end;
and this class:
type
   TVirtualEntity<T: IInvokable> = class(TVirtualInterface)
   public
      constructor Create(); reintroduce; overload;
   end;

constructor TVirtualEntity<T>.Create;
begin
   inherited Create(TypeInfo(T));
   Self.OnInvoke :=
      procedure(Method: TRttiMethod; const Args: TArray<TValue>; out Result: TValue)
      var
         attributes: TArray<TCustomAttribute>;
         attributesManager: TAttributesManager;
         entityFieldAttribute: TEntityField;
      begin
         attributesManager := TAttributesManager.Create(Method.GetAttributes);
         try                
            if attributesManager.HasAttribute<TEntityField>() then
            begin
               Result := attributesManager.GetAttribute<TEntityField>.FieldName;
            end;

         finally
            attributesManager.Free;
         end;
      end;
end;
I'd like to get TRttiProperty of Method: TRttiMethod, but how? if i change the interface to:
IPerson = interface(IInvokable)
   ['{45CE428C-F880-4D61-A2C1-0F3CB47130B5}']
   procedure SetName(const Value: string);
   [TEntityField('Field Name Here')]
   function GetName(): string;

   property Name: string read GetName write SetName;
end;
the code works, but i'd like to user interfaces like this:
IPerson = interface(IInvokable)
   ['{45CE428C-F880-4D61-A2C1-0F3CB47130B5}']
   procedure SetName(const Value: string);
   function GetName(): string;

   [TEntityField('Field Name Here')]
   property Name: string read GetName write SetName;
end;
------
Answers
Unfortunately, you can't. There is no RTTI generated for interface 
properties so there's nothing for your custom attribute to be attached 
to. Your decoration of the interface property has no effect, even if 
there's no warning. 

GroupBy after orderBy for complicated query in Laravel

Here is my code for fetching messaging and grouping them for each chat
$query = DB::table('chats');

    $otherUserId= $request->input('loadId');
    if($otherUserId==0){
        $query->join('users as u1', 'u1.id', '=', 'chats.user1_id');
        $query->join('users as u2', 'u2.id', '=', 'chats.user2_id');
        $query->join('messages', 'messages.chat_id', '=', 'chats.id');
        $query->where('chats.user1_id', '=', '{$userId}');
        $query->orWhere('chats.user2_id', '=', '{$userId}');
        $query->select('messages.chat_id', 'messages.from_id', 'u1.id as    user1_id', 'u2.id as user2_id', 'messages.created_at', 'messages.body', 'messages.read', 'u1.name as user1_name', 'u2.name as user2_name', 'u1.picture_url as user1_pic', 'u2.picture_url as user2_pic');

        $query->orderBy('messages.created_at ', 'DESC');
        $query->groupBy('chat_id');
        $messages = $query->paginate(4);
-------
 Question:
When I run the query the result is not as expected OrderBy comes after group by. I've tried a lot but could't find and solution. I tried this solution also but couldn't make it work. Order By before Group By using Eloquent (Laravel)
Please help me I've lost a lot of time trying to sort it out. Thanks in advance for helping me.
--------
Answers 
 1.
One line before the paginate add the following code
dd($query->toSql());
This will return the query string in order to debug the mysql query. If you still can't find out what is happening paste it here to help you.
2.
That's because it's not legal syntax to place the GROUP BY clause after an ORDER BY - note the formal definition in the docs. http://dev.mysql.com/doc/refman/5.7/en/select.html
It's not clear what you're actually trying to accomplish by this - SQL doesn't have particularly good support for ordered data inside an aggregate.
----
The end.
Good luck to you!!!

Firebase run script after retrieving existing data




I have a function in js that needs to refresh after I retrieve data from Firebase.
firebase.database().ref('/users/' + this.userId + '/info')
.on('child_added', function(snapshot){
    this.myFunction();
}.bind(this));
         The problem is that the data in Firebase is very large so I don't what to run the 
function lots of times.   
          This is how I what it to run:
  1. Retrieve ALL EXISTING data from Firebase.
  2. Run the function (once).
  3. Every time more data comes in from Firebase, run the function again.  

    I am guessing you want to retrieve all existing data from firebase at once
     then as more data comes in listen for those data changes. If that is your 
    case look at the method once() in firebase

Would relatively primitive people really confuse technology with magic?

Questions:
It's common for people to say that if a time traveler or an alien displayed advanced technology to ancient or medieval people, that they'd assume it was magic, and either worship him as a god or burn him as a witch.
But if aliens visited the Earth tomorrow and had technology hundreds of years in advance of anything humans have yet invented, I'd think few if any would suppose it was magic. You might say, "Yes, but we are technologically sophisticated people, unlike those medieval people." But people in the Middle Ages built complex clocks and other mechanical devices, and cathedrals and other buildings at least as grand as anything we build today. Ancient people built the Coliseum and the pyramids. The Greeks built complex mechanical devices -- like the Antikythera machine. Would the ancient Greeks have assumed that, say, a flying machine must be magical? Or would they have said, "Ah, like Daedalus built"?
So my question is, Is there any evidence that ancient or medieval people would be unable to distinguish advanced technology from magic? For example, are there documented historical examples of, say, 19th century Europeans encountering a primitive tribe and the primitive people thinking the European's machines were supernatural?
Later Thought
My intent here was not to get into a discussion of whether there really are supernatural forces in the universe. Whether there really is a God who performs miracles, or ghosts, or people with psychic powers, doesn't affect what I was driving at with this question. You may think that people are foolish and gullible to believe in religion, but even if you're right, it's not a matter of confusing technology for the supernatural, it's a debate about whether the supernatural exists.
I admit I may be splitting hairs here, but I think it's a fundamentally different idea. Suppose a con man tries to convince people that he can read minds. The issue isn't that people are confusing technology with magic, but that they are being duped by a con man. Odds are he isn't using any particularly advanced technology, but simple stage magic tricks. Very little stage magic depends on high tech gadgets: it's almost all slight of hand, a box with a hidden compartment, smoke and mirrors. I know some mind-reading tricks, and none of them involve high technology, they're all about having an accomplice who uses code words to pass you information and that sort of thing.
Very Late Update
I see a number of posters here have made comments on the order of, "If you don't understand it, it's the same as magic." No, it's not. It's true that people use the word "magic" colloquially to mean "stuff I don't understand" or even "stuff that's really impressive", as in, "we talked via the magic of cell phones" or "wow, this new cleaning product works like magic!" But my intent with this question was that I meant "magic" in the literal sense: something supernatural, ghosts, psychic phenomena, etc. I'm sure 90+% of the population of America and Europe don't know how cell phones or computers work. But they don't suppose they are literally evil spirits captured in a box.

Answers:
As far as I can determine, the closest we have to hard data on this (which is not that close) would be first contact with people who have been isolated for a long time and have not developed or used technology themselves. This page lists six relatively recent incidents:
Based on that article, (not from a great source, but hey), I searched and read several other sources, like:
Among others. I searched and read a lot, looking for anything along the lines of "the long-isolated tribesmen were amazed at seeing a cell phone for the first time, and asked 'what kind of magic is this?'" But I have not found anything that relates a story of confusing technology with magic. Just to be clear, I can't say that has never happened, just that a fairly lengthy (and work productivity destroying) search of the internet has not turned up any documentation on that.
What is documented multiple times is the mistaken impression of the more "advanced" peoplebeing mistaken for supernatural beings - either gods or devils. What is fascinating about this is it could lead one to a more supported and also surprising maxim: "Any mildly different human morphology is often mistaken for inhumanity". Meaning, just having white skin, thinner noses, and different hair can make one seem to be not even human (at first) to someone who has only ever seen other humans with dark skin, broad noses, and curly dark hair. Rather chilling when you think about it.
Attempting to extrapolate what the long-isolated peoples in these first contact situations might think of about technology, they would likely see it as works of supernatural beings, and maybe not magic so much as miracle (or devilry). I suppose that's a form of magic, but it's interesting that the culture shock experienced by these peoples does not seem to be secular.
Now if we imagine that a group of humans were somehow whisked away from earth 10,000 years ago, have developed on another planet, and now return to earth with no head hair and greenish skin, one good guess at how our current culture would react would be to mistake them as completely alien, and not human at all. From there, most people would probably spare little thought to whether these "aliens" were wielding magic, technology, or anything else, and would instead be more concerned about whether they mean us harm, or will steal our jobs, or threaten our religious beliefs, etc.

A small group recreating modern technology

Questions:
Suppose a group of people get transported back in time (say 2500 years). Then, in a manner reminiscent of A Connecticut Yankee in King Arthur's Court, they try to re-design modern technology. Assume that there's no shortage of labor or materials; the only real lack is knowledge.
What kind of group would have enough knowledge to recreate modern technology within 50 years? Would one average college-educated person be enough, or would it take hundreds of experts? Would there be any particular points that they would get stuck at?
For argument's sake, we can define modern technology as: laptop computers, kidney transplants, DNA sequencing, artificial satellites, and nuclear power plants.
Answers:
Our intrepid time-travelers really have their work cut out for them!
To make this possible, let's hand wave the problem of language and religion, and say they got really lucky and wound up in a country that is eager to learn and listen. This is a big hand wave, but let's at least give them a shot to try before getting executed straight away or having to overcome a language barrier.
The big thing they will need to realize is that it will be simply impossible to jump straight from 500BC to 2000AD all in one straight step! Let's use the Wikipedia handy-handy List of Technologies to see what we can hope for in 500BC!
According to the History of Metallurgy, we can say that our locals have access to iron and have been using it for a while, and a it is pointed out that even steel has been discovered and used! However, until right around 500BC in China no one had a furnace that could actually melt steel, so no cast iron - but that's right when we arrived! Note that the first iron foundry in Europe as put at 1161 AD - 1600 years after China. That could cause us a problem if we land in Europe...
But let's hand wave this little geographic problem and pretend we have actual access to iron, charcoal, and a furnace hot enough to make limited amounts of cast iron and steel.
To further orient ourselves, consider that we have to hope to be in an area where petroleum is available to us for things like tar and asphalt, which is actually possible - hey, China did it! It sure seems easier to land in China in 500BC and get to work there, doesn't it?
Anyway, we've got clean running water, iron, a hot furnace, oil, copper, bronze...holy crap, we don't even have PAPER? We're about 1000 years before the first Persian windmills? Well, we've got papyrus and animal skins and clay tablets for writing, so I guess we'll make do.

Let's Make a Computer!

...right, so remember what I said about not trying to jump ahead? Obviously we are going to need some silicon to get any kind of recognizable computer made, and that stuff is just sand, right?
Well, not exactly. Remember that great iron melting furnace? Iron melts above 1500 Celsius, but to refine even metallurgy grade silicon we need to get over 1900. We now need to make a kiln hot enough to make glass, which the internetz say is way hotter than needed to make cast iron. Which is weird, because the internetz say cast iron was so hard to make because they couldn't get the furnace hot enough to melt iron, and yet they could melt glass? Hm. Hand wave, we build a furnace to melt glass!
Now we could get this far in a few months, with lots of labor help I'm sure. But now we have a problem. We can now make glass and even get ourselves some silicon, but it isn't pure enough to use in even friggin' basic electronics - much less computers! We supposedly need over 95% pure silicon for basic electronics, which was first done seemingly around the early to mid 1900s.
I honestly can't understand half the real technical material, so this college-educated single person with the internet at his hands would fail right here. I think we need to try crushing and putting through an acid bath, but where do we get such pure acids? That will take refinement, and a whole ton of chemistry, I honestly don't know how hard it is or how long it will take to get enough, pure enough, to get even remotely close to pure enough silicon.
And the thing is, that isn't nearly enough. We are going to need a handful of weird elements sourced and purified, from aluminum and boron to gallium. We need a clean room, air filtration, anti-static measures - these people don't have air filters! We will need electricity here, and how can we know without trial and error we got it right and have things pure enough? This is going to soak up a lot of time and specialist man power unless we have special instruments and ultra-precise tools to help us - and guess how much work that will take to build?
I'd say that with a team of specialists, all the worlds combined internet knowledge and the library of congress, we are at least a few years in and don't even have silicon of the proper grade. I don't know that with trial and error alone that it'd be doable, so we probably can't even progress here until we go backwards and invent some pre-requisites.

It's Not All Just Knowledge

Another problem we run into very soon is that it isn't all about knowledge itself, but arts, crafts, and skills. If you want useful chemistry and/or refinement, you're going to need thing like suitable lab equipment, such as test tubes and piping. Using crude metal scruples will contaminate the process and ruin it (or will fail spectacularly as with acids for advanced chemistry in metal or stone containers), as will crude methods of providing heat and flame unless you seal things properly.
When it comes down to it, glass-working and metallurgy are arts too - especially without functioning preprogrammed robots! You'll need skilled craftsmen to even begin to shape stuff resembling what you'll need for crude methods, and without automation or mass production they'll need trained assistants and heavy labor and months or years to handcraft the stuff we're going to need.

This Is Getting Toxic

What's worse, to start moving towards the first electronic devices we start facing some amazingly dangerous substances. Poisons, strong acids, aerosols, particulates, flammable/explosive gasses, toxins - without the right tools, pure hard work and persistence will kill everyone involved.
Safety measures will be needed. We're probably going to need some pretty good plastics to get out of this process alive, and...

We Are Going To Need A Bigger Boat

The thing is, our technology has pre-requisites - a history. It's easy for us not to think about it, but the things we have now are refinements and combinations of things that were invented before, which themselves are refinements and combinations of other things from before that, and on and on...all the way back to ancient history.
While we can certainly speed things up as development didn't take a straight line (and never will), it isn't the result of a few brilliant insights. It took many thousands of smart people, who learned methods from thousands of smart people who came before, who learned from thousands of smart people who came before, who together labored for effectively thousands of life times and drew together the work of hundreds of thousands of people across the last 2500 years just to get from "what's paper?" to "OK, Google".
There are lots of cool stuff we could have known about that others have pointed out (from soap and the importance of washing your hands and the importance of sanitation), but also is might be naive of us to think it's just because people didn't know they shouldn't throw corpses in with the drinking water; it was the result of a lot more than mere ignorance.
Lots of awesome improvements could be made, but fast-forwarding 2500 years in 50 years is going to take a herculean effort from many people, and they are definitely going to need more than the knowledge that they carry around in their head.
This is definitely something you can make an interesting story from, but the ultimate answer to the beginning question is: hundreds or thousands of experts, probably a lot more than 50 years, and they are going to need more than their own knowledge and memory - Wikipedia won't be enough, I assure you!

Popular Posts

Powered by Blogger.