Friday, December 30, 2016

Gratitude

I know I wouldn't be where I'm at or know who I do without, struggle, hard work, or the many things that God has allowed. I have no reason to focus on weakness, but instead continue in faith. I'm learning to know Sir Tim Berners-Lee, who is arguably one of the most influential people of
the late 20th century. I'm also learning from the dedicated team around him.

I can't say I'm a failure, but instead on a journey. I can't say I lack uniqueness, or the capacity to contribute. I'm already doing that. I can't say I don't have awesome friends. This whole career ladder thing. Professional roles, what have you. Yeah, I can take things and run with them. I'm thankful for today, and look
forward to tomorrow. It will be a challenge. There will be roadblocks. Otherwise I'd be dead.

There are too many people to name that have been a positive influence in my life. Even those who have set up roadblocks have helped me.

Monday, December 19, 2016

Preliminary notes for Wes Tyler's December talk at okc.js

I was checking out the okc.js website, and I found Wes Tyler was giving a lightning talk on "Node.js document models with Joi and Felicity".

A quick Google search gave me:

https://github.com/xogroup/felicity (Felicity --  Description: Javascript object constructors based on Joi schema.)

 https://github.com/hapijs/joi
(Joi -- Description : Object schema description language and validator for JavaScript objects.)



A few guesses on related stuff:

http://json-schema.org/examples.html (JSON Schema)
http://www.json.org/ (JavaScript Object Notation)
Object Oriented JavaScript :
[Object Oriented JavaScript : https://www.youtube.com/watch?v=O8wwnhdkPE4 , Modular JavaScript # 6 - Classical Inheritance & OOP with JS : https://www.youtube.com/watch?v=sWOXYDBbz0g ,
Modular JavaScript - Prototypal Pattern vs Classical OOP in JS ,
https://www.youtube.com/watch?v=doXpW5AD60Q :
JavaScript object creation patterns tutorial - factory , constructor pattern, prototype pattern  , https://www.youtube.com/watch?v=xizFJHKHdHw ]

Interesting tangent (b/c I want to draw graphs anyway) :
6.4: The Constructor Function in JavaScript - p5.js Tutorial ,
https://www.youtube.com/watch?v=F3GeM_KrGjI] which is from 1-6: Foundations of Programming in JavaScript - p5.js Tutorial , https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA ]

p5.js may be found here: http://p5js.org/



                                            

Saturday, December 17, 2016

Purchase of the CJ SHOP Obstacle Avoidance Sensor in place the OP-AMP and Potentiometer Circuit for the Photogate

We ended up purchasing the "C.J. SHOP® 5PCS IR Infrared Obstacle Avoidance Sensor Module for Arduino Smart Car Robot 3-wire"  on Amazon [1] for construction of our photogate.  To build our photogate, we will need two in tandem. These are represented as the red boxes in the illustration below:

The C.J. Shop Obstacle Avoidance Sensor Module looks like the op-amp receiver circuit and the potentiometer transmitter circuit , except that a comparator is used instead of an op-amp.

According to Wikipedia, the potentiometer works a bit better than an op-amp since the op-amp tends to have a bit more lag. 

"
In practice, using an operational amplifier as a comparator presents several disadvantages as compared to using a dedicated comparator:[5]
  1. Op-amps are designed to operate in the linear mode with negative feedback. Hence, an op-amp typically has a lengthy recovery time from saturation. Almost all op-amps have an internal compensation capacitor which imposes slew rate limitations for high frequency signals. Consequently, an op-amp makes a sloppy comparator with propagation delays that can be as long as tens of microseconds. "
(https://en.wikipedia.org/wiki/Comparator)


Having the comparator is good because we would need to compare the voltage we sampled from the op-amp circuit when a potato is passing and when it is not. The comparator performs this function, outputs a binary 0 or 1 to the arduino (?), and since it allows for high frequency signals it may be able to measure things that happen quickly.


For further documentation for use with the Arduino, compare this obstacle avoidance sensor to the Sunfounder Obstacle Avoidance Sensor [2]. 

If the CJ Avoidance Sensor does not work well, try replacing the LED with a 940 nm IR LED:

Standard LEDs - Through Hole LED PMI 696-SSL-LX5099IEW http://www.mouser.com/ProductDetail/Lumex/SSL-LX5099IEW/?qs=sGAEpiMZZMtmwHDZQCdlqUPJk6OnVfwFh1MnnzvLabs%3d


This uses the logic from the quote in Makezine [3]:

"Older remote controllers used gallium arsenide compensated with silicon (GaAs:Si). These LEDs emit at about 940nm, which makes them ideal for detecting water vapor, but they’ve become very difficult to find."

An ejected potato has a lot of water vapor.

We tried other LEDs like the ones from RadioShack (pictured on the side of the breadboad) and the ones from the Parallax SUMO Bot Kit (pictured in the circuit) . See below:

http://2.bp.blogspot.com/-BxHBYrMAHQk/VaF26LtKiEI/AAAAAAAAAyA/2EykLgB8JEo/s1600/photogatecircuit_breadboardard1e2.JPG

It may not be the LED that was the problem. It may be that we did not use a potentiometer on the transmitter LED and an op-amp or comparator on the receiving LED. The C.J. SHOP purchase provides us with this.


[1]



https://www.amazon.com/C-J-Infrared-Obstacle-Avoidance-Arduino/dp/B00XAGSWR4/ref=redir_mobile_desktop?_encoding=UTF8&keywords=infrared%20sensor&pi=AC_SX236_SY340_FMwebp_QL65&qid=1481943085&ref_=mp_s_a_1_1&sr=8-1

[2]
https://www.sunfounder.com/learn/Sensor-Kit-v2-0-for-Arduino/lesson-31-ir-obstacle-avoidance-sensor-sensor-kit-v2-0-for-arduino.html

[3] http://makezine.com/projects/make-36-boards/how-to-use-leds-to-detect-light/

Potentiometer with and without a 555 timer

Following the led dimmer circuits in the Potato Gun Review for the LED transmitter:

http://www.reuk.co.uk/wordpress/lighting/led-dimmer-circuit/
http://www.electroschematics.com/9730/high-power-led-dimmer/
http://www.555-timer-circuits.com/led-dimmer.html





we have for the most complex:

We can build the simpler circuits with parts from the most complex. A parts list for all possible combinations:




Description Mouser Part # Link
Aluminum Electrolytic Capacitors - Leaded 470uF 16V 667-ECA-1CM471 http://www.mouser.com/ProductDetail/Panasonic/ECA-1CM471/?qs=sGAEpiMZZMvwFf0viD3Y3b8LTtskkwos%252bTZXzcHN%2fcU%3d
Darlington Transistors DARLINGTON TRAN 511-BD679 http://www.mouser.com/ProductDetail/STMicroelectronics/BD679/?qs=Djavi1aLnwpKhd3pF0IRIQ%3D%3D
MOSFET N-Channel 50V 33A 512-BUZ11_NR4941 http://www.mouser.com/ProductDetail/Fairchild-Semiconductor/BUZ11_NR4941/?qs=sGAEpiMZZMshyDBzk1%2fWi7Fu3l2zlAhYfCbfnrSmGYg%3d
Potentiometers Sgl Unit Vert Flat Snap-in 10K Ohms 20% 688-RK09L1140A2U http://www.mouser.com/ProductDetail/ALPS/RK09L1140A2U/?qs=sGAEpiMZZMtC25l1F4XBU3JeeCo7XMTlNRqBfUrZdf0%3d
Diodes - General Purpose, Power, Switching 100V Io/200mA BULK 512-1N4148 http://www.mouser.com/ProductDetail/Fairchild-Semiconductor/1N4148/?qs=sGAEpiMZZMvplms98TlKY2CxbJu22D5%2f%2fpqXqVsMprg%3d
Diodes - General Purpose, Power, Switching 100V Io/200mA BULK 512-1N4148 http://www.mouser.com/ProductDetail/Fairchild-Semiconductor/1N4148/?qs=sGAEpiMZZMvplms98TlKY2CxbJu22D5%2f%2fpqXqVsMprg%3d
Metal Film Resistors - Through Hole 2watts 1Kohms 5% 594-5083NW1K000J http://www.mouser.com/ProductDetail/Vishay-BC-Components/PR02000201001JR500/?qs=sGAEpiMZZMtlubZbdhIBIDWIPK23CRbllZqljMtzpi4%3d
Metal Film Resistors - Through Hole 1/10watt 47ohms .1% 50ppm 71-RN55C-B-47 http://www.mouser.com/ProductDetail/Vishay-Dale/RN55C47R0BB14/?qs=sGAEpiMZZMtlubZbdhIBIOj4GQCFpror65Ok4ODdEZQ%3d
Multilayer Ceramic Capacitors MLCC - Leaded 100000uF 200Volts 598-M30R104M2 http://www.mouser.com/ProductDetail/Cornell-Dubilier-CDE/M30R104M2/?qs=sGAEpiMZZMsh%252b1woXyUXj%2fb0PP%2fSr87QgLKMgW7U1AY%3d
Multilayer Ceramic Capacitors MLCC - Leaded 10000uF 50Volts 598-M15R103M5 http://www.mouser.com/ProductDetail/Cornell-Dubilier-CDE/M15R103M5/?qs=sGAEpiMZZMsh%252b1woXyUXj%2fb0PP%2fSr87QM%252b8hGV4CQBc%3d
Switch Mode Power Rectifiers 16A, 35 and 45 V MBR1635,MBRB1645,NRVBB1645 http://www.onsemi.com/pub_link/Collateral/MBR1635-D.PDF
Standard LEDs - Through Hole LED PMI 696-SSL-LX5099IEW http://www.mouser.com/ProductDetail/Lumex/SSL-LX5099IEW/?qs=sGAEpiMZZMtmwHDZQCdlqUPJk6OnVfwFh1MnnzvLabs%3d


The link describing the most complex 555 dimer circuit mentions the purpose of the 555 timer. It states that the 555 timer is not needed if you do not have more than one LED. Only a potentiometer is needed.

"Typically current is controlled using a resistor in series with the LED, or a current regulator circuit. Supplying more current to an LED increases its intensity, and reducing the current decreases its intensity. One way of dimming an LED is to use a variable resistor (potentiometer) to dynamically adjust the current getting to the LED and therefore increasing or decreasing its intensity. This works very well when just one LED bulb is involved."

"Unfortunately, all LEDs are not made equal – even those of nominally identical specifications from the same batch from the same manufacturer. Although this will not be apparent when strings of LEDs are being driven with the recommended forward current (e.g. 25mA for ultrabright LEDs), as the current is reduced some LEDs will turn off before others, and some will be dim when others are still quite bright etc."

-- http://www.reuk.co.uk/wordpress/lighting/led-dimmer-circuit/

So we could use this circuit instead:


With a subset of only these parts:


Description Mouser Part # Link
Potentiometers Sgl Unit Vert Flat Snap-in 10K Ohms 20% 688-RK09L1140A2U http://www.mouser.com/ProductDetail/ALPS/RK09L1140A2U/?qs=sGAEpiMZZMtC25l1F4XBU3JeeCo7XMTlNRqBfUrZdf0%3d
Standard LEDs - Through Hole LED PMI 696-SSL-LX5099IEW http://www.mouser.com/ProductDetail/Lumex/SSL-LX5099IEW/?qs=sGAEpiMZZMtmwHDZQCdlqUPJk6OnVfwFh1MnnzvLabs%3d




OP-AMP Circuit for Potato Gun Photogate

Following the OP-AMP Circuity in Makezine (http://makezine.com/projects/make-36-boards/how-to-use-leds-to-detect-light/) for using an IR LED as a light detector we have:


With the parts:


Thick Film Resistors - Through Hole 1M ohm 5% 660-RCR60CT52A105J http://www.mouser.com/ProductDetail/KOA-Speer/RCR60CT52A105J/?qs=sGAEpiMZZMu61qfTUdNhG4n4vqkAruQqi5Z%252bqnvcbxA%3d
Ceramic Disc Capacitors 220pF 500V 10% Y5P 6mm LS 594-D221K20Y5PL63L6R http://www.mouser.com/ProductDetail/Vishay-BC-Components/D221K20Y5PL63L6R/?qs=sGAEpiMZZMt1mVBmZSXTPGZfUmf9Bhnh96E7McwC9LY%3d
Standard LEDs - Through Hole LED PMI 696-SSL-LX5099IEW http://www.mouser.com/ProductDetail/Lumex/SSL-LX5099IEW/?qs=sGAEpiMZZMtmwHDZQCdlqUPJk6OnVfwFh1MnnzvLabs%3d
Precision, Single Supply Op Amp LT1006 http://www.futurlec.com/ICLinearOpAmps1.shtml , http://www.futurlec.com/Linear/LT1006.shtml


Saturday, December 3, 2016

Potato Gun Review

We made progress, but we had some bugs. I found it useful to myself to write down what I had done and plan for what to do. I figured I'd share it since yes and no is not that interesting.

We were able to trip the circuit, and use the Arduino code to interpret it (https://github.com/bshambaugh/BWPhotogate/blob/master/photogate.ino). The speed calculation is built in on line 53. The inputs from the receiving circuits should be A1 and A2.

We used some parts from a Parallax sumo-bot kit as pictured in
(http://2.bp.blogspot.com/-BxHBYrMAHQk/VaF26LtKiEI/AAAAAAAAAyA/2EykLgB8JEo/s1600/photogatecircuit_breadboardard1e2.JPG)
and (http://2.bp.blogspot.com/-rZcUpcHWjkU/VaF2tN-ymQI/AAAAAAAAAx4/P93dZ2b9TcA/s1600/photogatecircuit_breadboardard1.JPG)
and pg. 45 - 49 of
(https://www.parallax.com/sites/default/files/downloads/27400-SumoBot-Manual-v2.1.pdf).

I seem to recall, we may have had some occasional issues with sensitivity, so it was a challenge to trip them at times.

We never got the final setup with the pvc pipe and reflectors to work.
I do not think they ever were tripped.
(http://3.bp.blogspot.com/-GsqPJFQFjDQ/VaFypyN-KvI/AAAAAAAAAxI/a5aaA_5lVEo/s400/photogate1.JPG). This appears to be putting the IR transmitter and receiver side by side with communication by bouncing off the reflector (compare photogate1.JPG to
http://2.bp.blogspot.com/--B_ydizyfRU/VaF0FGExSGI/AAAAAAAAAxo/64ECvev5ipA/s1600/photogate2_zoom2.JPG)
It looks like we tried the sumo-bot parts. I may have been worried about transmission loss at the time and also how much a potato may shadow the signal by passing through the parachute shaped gates. The transmitter and receiver may need to face each other within the transmission and reception angle.

I may want to adjust the sensitivity of the receiver with an op-amp and the power of the transmitter with a potentiometer or pwm setup.

I'd like to go back and try it again with the infrared LED emitter and detector package from RadioShack
(https://www.radioshack.com/products/radioshack-infrared-led-emitter-and-detector).
A skilled observer who acted as an electrician / EE consultant thought it was simpler than the sumo-bot circuit. Perhaps it will befriendlier to my partner and I. We got it to light, and our cell phone(?) cameras were able to pick up the emission
(http://2.bp.blogspot.com/-A0P2h0QED1E/VaF8LYPZHgI/AAAAAAAAAyo/j2UimROfVJo/s1600/ir_led_camera_light.JPG).
I think we should amplify the received signal to the two receiving diodes with an op-amp circuit and perhaps adjust the brightness of the two transmitting diodes with pwm or a simple potentiometer. The potentiometer setup already worked with the Sparkfun Redboard
(http://1.bp.blogspot.com/-7klFYxjr1lg/VfOjFCgpqoI/AAAAAAAAA1Y/6AnTyJKNnic/s160 /11800522_10103322872952857_7659406262285231569_n.jpg)
which is an Ardunio knockoff.  I'm treating the receiving LED with the op-amp as a photodiode (https://en.wikipedia.org/wiki/Photodiode). It might be worthwhile to apply the op-amp circuit and pwm / potentiometer to the sumo-bot parts too.

For the op-amp circuit and pwm/potentiometer circuits, I constructed some circuit diagrams in Fritzing (file names in parentheses) that were based off ones I found on the web.

I went online to find some op-amp circuits. I ended up going with this one:
http://makezine.com/projects/make-36-boards/how-to-use-leds-to-detect-light/
(opampdiodenov26_bb.pdf)


I also found some led-dimmer circuits including or excluding a power rectifier and transistor (in order of more parts to less):
http://www.reuk.co.uk/wordpress/lighting/led-dimmer-circuit/
http://www.electroschematics.com/9730/high-power-led-dimmer/
http://www.555-timer-circuits.com/led-dimmer.html
(led555dimcomplex_bb.pdf),(led555dimmedcomp_bb.pdf),(led555dimmedsimple_bb.pdf)


I constructed the circuit for the potentiometer in the video
(https://www.youtube.com/watch?v=DLirSFg2ELo&index=18&list=PLah6faXAgguOeMUIxS22ZU4w5nDvCl5gs)
(potlednove26_bb.pdf) It looks like I already built it with the
Sparkfun Redboard as the battery.


I think we can either use the potentiometer circuit or the pwm circuit
to adjust the brightness of the LED. The potentiometer circuit is a lot simpler. I'm not certain of its limitations. It is a variable resistor. It is all analog, and I recall from the web that it may only be good for a small number of LEDs (although I don't know why this is true). The pwm circuit adds a 555 timer, a few capacitors, resistors, diodes, and perhaps a power rectifier and transistor to the potentiometer. The 555 timer produces a square wave so I call it
digital.

I e-mailed myself with some parts (mostly from mouser.com) that matched the circuit diagrams I found at the links above. I need to construct a purchase order for myself, and make this thinking more formal, mainly so when I go back to Oklahoma I have something to do with my project partner.

My partner was also worried about the lack of a rigorous method for sizing the potato gun. The potato guns had previously been sized empirically and with inspiration from sources such as Burt Latke's studies. I built a spreadsheet to scale based on size ratios if I recall correctly. This is described in a quote from
http://raptorlicious.blogspot.com/2015/05/potato-gun.html :

"Performance in terms of velocity of the potato gun was found to change as various ratios in the geometry changed. Performance was judged by the damage that the gun did to targets.The most damage was done when the chamber diameter was at least twice the barrel diameter with a ratio of length of chamber to diameter of chamber between 3 and 6. It was less apparent, due to limited experimentation, but the chamber volume was usually kept at 1.2 times the barrel volume. This was inspired by a website based on Burnt Latke's studies
(http://www.inpharmix.com/jps/Optimal%20Chamber%20Volume%20for%20a%20Fixed%20Barrel%20Size.html)."

We had no mechanism to measure the exact amount of fuel we put in other than our own sense of time when spraying the propellant. So, even if we got the photogate to work we may not measure a consistent speed due to variance in the propellant amount. If we fix the propellant amount,we might find the maximum speed for a particular potato gun.

Wednesday, November 2, 2016

Thoughts About Fitting In to a Community

To a large part, people measure you by what you contribute to. What you contribute to is what other people in your community understand and support.

Tuesday, July 26, 2016

Throughts on Branding and Joining or Creating a Crowd

People are driven by branding. Most people do not understand what you are doing. In the present distracted society with high levels of information but low levels of focus most people will not take the time to understand what you are doing. You can only get through a snippet. Education manifests itself as a brand, and it is a product that can be sold. Most other people who saw you bought the product get excited, not really knowing what it is, but that it was brought to you by people said to be experts in their field. 

Some people know the people who are said to be experts in the field. They are happy to know other people who are learning from them. They would like to get to know the people who are learning from them and perhaps plug them into what they are doing. Some of these people have the focus to understand what you are doing.

People who are not learning from said experts behind a said brand face a challenge. There is not a standard way of dealing with them by most beyond perhaps losing them in the noise. Others may be not distracted, but focused on something else. Others may be afraid to support you. They have to blaze their own path and make their own brand. Most will not understand what they are doing, but it must be impressive. The skepticism of those that are seen as understanding must not be so loud that it drowns out the impression (if they are fortunate enough to get it). A core group must be formed and sustained that people are drawn to. First it will be the true believers, then it will be those who understand less but are drawn to the brand. The idea should be workable for it to be financed by outsiders, and this is difficult when not working with an established brand. The said experts behind the said education brand will probably not be paying close attention at first, because they will be focusing on themselves and those learning from them.

If you choose to build a brand, you must remain focused. That is what you can control. Hopefully you get a following as well.

Sunday, July 24, 2016

Musings about ISU

To put this on the Open web means it can be found.

I looked at International Space University in France and realized I have found avenues to pursue a lot of this stuff already. The big issue is dealing with the mental weeblies. I am still thinking about it however. As usual, I get haunted
by the up front cost. They like people with higher level degrees, which I have. Being knowledgeable about computers probably does not hurt.

In parallel to their curriculum - 

Potato Gun Construction and Being my Usual Eccentric Self Led to:
[1] Sutton and Bilbarz, Rocket Propulsion Elements
[2] NASA Systems Engineering Handbook
[3] Aerospace Maker - OSHW Spaceflight (tech and legalese)
[4] AlphaCubeSat -- cubesat design and deployment & familiarity with the space business (tech, procedure, and legalese)

Computer interest and space interest in conjunction with the Semantic web and LD led to:
[5] Integrated Space Plan / ISA . . (familiarity with the space business)

Interest in Open Source, the Hacker Philosophy, and want for a dev server led to:
[6] Various OKC Hacker / Makerspaces ...(places projects can be built)

The positive thing I see here is a buy in from a dedicated group of people with a legal backing as well as the focus that comes when you burn all of your ships. Also freedom because you're comfortable b/c you paid someone to put up with you :). I'm uncertain at the moment about how open the buyers in this market would be to radical ideas that to the more informed might involve a lot. I have habit of introducing them to unsuspecting recruiters. I try to normalize myself: sometimes unsuccessfully. (Edit: This would be less of an issue to me if I had the capital up front)

I am a bit past the deadlines on January and April, but I inquired anyways.


For reference:

{1} http://www.isunet.edu/images/ISU/News/brochures/ISU_Admission2015_Brochure.pdf

Saturday, July 23, 2016

Loading Libraries into Drupal

Using Libraries API 2.x (as a module-developer)

 https://www.drupal.org/node/1342238

 

Installing an external library that is required by a contributed module

https://www.drupal.org/node/1440066

 

Loading PHP Libraries and Using Classes using Drupal Libraries module

http://stackoverflow.com/questions/19053676/loading-php-libraries-and-using-classes-using-drupal-libraries-module

  

Autoloading Classes

http://php.net/manual/en/language.oop5.autoload.php

 

3 Tips For Using External Libraries With Drupal

 http://engineeredweb.com/blog/10/5/3-tips-using-external-libraries-drupal/

 

 

 

 

Wednesday, July 20, 2016

Linked Data / RDF at Dataverse 2016

The following involves mention of Linked Data and RDF at the meeting:

Dr. David Ruvolo of the University of Pittsburgh was doing some stuff with linked data with CHIA (http://www.chia.pitt.edu/).

CHIA has been developing something called Col*Fusion which is described as  "Col*Fusion (Collaborative Data Fusion) is an advanced infrastructure for systematic accumulation, integration and utilization of historical data. It aims to support large-scale interdisciplinary research, where a comprehensive picture of the subject requires large amounts of historical data from disparate data sources from a variety of disciplines." (http://colfusion.exp.sis.pitt.edu/colfusion/) . This reminds me of LIMES and the  SILK Framework with Christian Bizer as it seems to have a aim in its data integration attempts.

Datacite offers permanent DOIs which might be useful in RDF work. Trisha Cruse said they would like to work in more of the vein of semantic web / LD but they are buried at the moment (http://projects.iq.harvard.edu/dcm2016/people/trisha-cruse).

Robert Day  with Lab-Ally has done some stuff with RDF (http://elnsoftware.blogspot.com/2011/07/its-all-just-semantics.html).


Wednesday, June 29, 2016

Brexit

Not being European, I tried to understand the issues. Some things that came to mind:

Globalism - the web , information flows across borders , ICT constructs involve highly distributed teams

eurozone - not benefiting everyone - bureaucrats making decisions, inequality in the banking system (Mark Blyth) - leads to challenge at the voting box [ Mark Blyth: "Austerity - The History of a Dangerous Idea" | Talks at Google
http://bit.ly/2933oFo; Mark Blyth--Are the Populists Threatening Democracy? http://bit.ly/29mFS5s ]

easier to do business across europe if grouped as EU (e.g. set up an office in London and do business in other parts of Europe) - Richard Branson, Virgin Group

Tuesday, May 31, 2016

Doing sparql queries with JavaScript

 I tried this:

var $rdf = require('../rdflib.js');

var store = $rdf.graph()
var timeout = 5000 // 5000 ms timeout
var fetcher = new $rdf.Fetcher(store, timeout)
var url = 'http://bshambaugh.rww.io';
var LDP = $rdf.Namespace('http://www.w3.org/ns/ldp#');

fetcher.nowOrWhenFetched(url, function(ok, body, xhr) {
    if (!ok) {
        console.log("Oops, something happened and couldn't fetch data");
    } else {

   var me = $rdf.sym('http://bshambaugh.rww.io');
   var contains = LDP('contains')
   console.log(contains)

   var duh = $rdf.queryToSPARQL('SELECT *  FROM <http://bshambaugh.rww.io> WHERE { ?s ?p ?o . }');

   console.log("I fetched the data");
    }
})
                        
But I am getting issues like:

NamedNode { uri: 'http://www.w3.org/ns/ldp#contains' }
/home/brent/rdflib.js/dist/rdflib-node.js:6276
    for (var i = 0; i < query.vars.length; i++) {
                                  ^

TypeError: Cannot read property 'length' of undefined
    at getSelect (/home/brent/rdflib.js/dist/rdflib-node.js:6276:35)
    at getSPARQL (/home/brent/rdflib.js/dist/rdflib-node.js:6338:12)
    at Object.$rdf.queryToSPARQL (/home/brent/rdflib.js/dist/rdflib-node.js:6341:10)
    at /home/brent/rdflibexperiments/exp7.js:18:19
    at doneFetch (/home/brent/rdflib.js/dist/rdflib-node.js:9783:52)
    at /home/brent/rdflib.js/dist/rdflib-node.js:10479:20
    at xhr.handle (/home/brent/rdflib.js/dist/rdflib-node.js:9365:9)
    at .onreadystatechange (/home/brent/rdflib.js/dist/rdflib-node.js:10478:19)
    at dispatchEvent (/home/brent/rdflib.js/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
    at setState (/home/brent/rdflib.js/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)

I am not really sure what I am supposed to call for rdflib.js for a sparql query. Are there any other javascript libraries that allow me to do sparql queries?

I found https://github.com/antoniogarrote/rdfstore-js .



Experiments with rdflib.js -- Sixth experiment

Create the file for the code:

vim exp6.js

Write the code:

var $rdf = require('../rdflib.js');

var store = $rdf.graph()
var timeout = 5000 // 5000 ms timeout
var fetcher = new $rdf.Fetcher(store, timeout)
var url = 'http://bshambaugh.rww.io';
var LDP = $rdf.Namespace('http://www.w3.org/ns/ldp#');

fetcher.nowOrWhenFetched(url, function(ok, body, xhr) {
    if (!ok) {
        console.log("Oops, something happened and couldn't fetch data");
    } else {

   var me = $rdf.sym('http://bshambaugh.rww.io');
   var contains = LDP('contains')
   console.log(contains)
   var friend = store.each(me, contains, undefined)
     // Any one person
        // do something with the data in the store (see below)
   for (var i=0; i<friend.length;i++) {
     console.log(friend[i])
   }
   console.log("I fetched the data");
    }
})
 


Run the code:

node exp6.js 

To get the results:

NamedNode { uri: 'http://www.w3.org/ns/ldp#contains' }
NamedNode { uri: 'http://bshambaugh.rww.io/.acl' }
NamedNode { uri: 'http://bshambaugh.rww.io/profile/' }
NamedNode { uri: 'http://bshambaugh.rww.io/storage/' }
I fetched the data

Comments about using rdflib.js to backup and migrate ldp server content

I would like to use rdflib.js to recursively create a backup of a linked data platform server.

 - I managed to get the child containers with the sixth experiment with rdflib.js
- I need to also find any contained RDF files (some other term in the ldp vocab.)
 - I need to also pull all the content for each ldp container)

- Then i need to do http requests to ldp server of my choice.
- and rewrite the ldp server uris appropriately (move from one content to another)


Getting started with rdflib.js -- Second experiment

Create a new file in the rdflibexperiments directory:

vim exp2.js

Add the contents:

var $rdf = require('../rdflib.js');

var uri = 'http://bshambaugh.rww.io/profile/card'
var body = '<a> <b> <c> .'
var mimeType = 'text/turtle'
var store = $rdf.graph()

try {
    $rdf.parse(body, store, uri, mimeType)
} catch (err) {
    console.log(err)
}

console.log(store);

Run the contents:

first in vim: wq!

second from the prompt: node exp2.js

To get the results:

var $rdf = require('../rdflib.js');

var uri = 'http://bshambaugh.rww.io/profile/card'
var body = '<a> <b> <c> .'
var mimeType = 'text/turtle'
var store = $rdf.graph()

try {
    $rdf.parse(body, store, uri, mimeType)
} catch (err) {
    console.log(err)
}

console.log(store);



Getting started with rdflib.js -- my first experiment

I cloned the github repository with:

git clone https://github.com/linkeddata/rdflib.js.git

then I followed the following steps:

cd rdflib.js

sudo su

npm install

make all

npm install -g jquery

npm install -g xmlhttprequest

I was inspired by the instructions at:

https://github.com/linkeddata/rdflib.js/

In separate directory at the same level of hierarchy on the directory tree I created a directory with the name "rdflibexperiments":

cd ..

mkdir rdflibexperiments

cd rdflibexperiments

Then I created a file called "exp1.js":

vim exp1.js

With the contents:

var $rdf = require('../rdflib.js');

var FOAF = $rdf.Namespace("http://xmlns.com/foaf/0.1/");

var foafKnows = FOAF('knows');

console.log(foafKnows);
 

Running this with the command

node exp1.js

gave

NamedNode { uri: 'http://xmlns.com/foaf/0.1/knows' }


The contents of the file was inspired by: 

https://github.com/solid/solid-tutorial-rdflib.js

with a friendly reminder from:

https://github.com/okcoders/ok-coders-summer-2014/blob/master/10-node/10-examples/calculator.js


Monday, May 30, 2016

wget and curl on bshambaugh.rww.io

Using curl pulls in the parent container:

curl -i -H "Accept: text/turtle" http://bshambaugh.rww.io

HTTP/1.1 200 OK
Date: Tue, 31 May 2016 01:49:38 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.22
Set-Cookie: SID=a0kehvcpo0pctkrlijd1t2fsb0; expires=Sun, 30-May-2021 01:49:38 GMT; path=/; domain=.rww.io
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: max-age=0
Pragma: no-cache
User: dns:107.196.158.16
Set-Cookie: showMetaFiles=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT
Link: <http://bshambaugh.rww.io/.acl>; rel=acl
MS-Author-Via: DAV, SPARQL
Allow: GET, PUT, POST, OPTIONS, HEAD, MKCOL, DELETE, PATCH
Accept-Patch: application/json, application/sparql-update
Accept-Post: text/turtle;charset=utf-8,text/n3;charset=utf-8,text/nt;charset=utf-8,text/css;charset=utf-8,text/html;charset=utf-8,text/javascript;charset=utf-8,text/plain;charset=utf-8,application/rdf+xml;charset=utf-8,application/json;charset=utf-8,multipart/form-data,image/jpeg,image/jpeg,image/png,image/gif,font/otf
Vary: Accept,Origin,If-Modified-Since,If-None-Match
Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel="type"
Link: <http://www.w3.org/ns/ldp#Resource>; rel="type"
Link: <http://bshambaugh.rww.io/.meta>; rel=meta
Link: <http://bshambaugh.rww.io/?p=1>; rel='first'
Link: <http://bshambaugh.rww.io/?p=1>; rel='last'
ETag: "c6d5ed3581b8c61ff70775a7e43a3cb8"
Last-Modified: Tue, 07 Oct 2014 03:06:33 GMT
Updates-Via: ws://bshambaugh.rww.io:81
Triples: 17
Content-Length: 891
Content-Type: text/turtle

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

<>
    a <http://www.w3.org/ns/ldp#BasicContainer>, <http://www.w3.org/ns/ldp#Container>, <http://www.w3.org/ns/posix/stat#Directory> ;
    <http://www.w3.org/ns/ldp#contains> <.acl>, <profile/>, <storage/> ;
    <http://www.w3.org/ns/posix/stat#mtime> 1412651193 ;
    <http://www.w3.org/ns/posix/stat#size> 4096 .

<.acl>
    a <http://www.w3.org/2000/01/rdf-schema#Resource> ;
    <http://www.w3.org/ns/posix/stat#mtime> 1412651193 ;
    <http://www.w3.org/ns/posix/stat#size> 577 .

<profile/>
    a <http://www.w3.org/ns/posix/stat#Directory> ;
    <http://www.w3.org/ns/posix/stat#mtime> 1412651156 ;
    <http://www.w3.org/ns/posix/stat#size> 4096 .

<storage/>
    a <http://www.w3.org/ns/posix/stat#Directory> ;
    <http://www.w3.org/ns/posix/stat#mtime> 1422986228 ;
    <http://www.w3.org/ns/posix/stat#size> 4096 .


But what about recursively pulling in child containers? A discussion on the marmotta users list tells me this is not supported by the Linked Data Platform standard.
 https://lists.apache.org/thread.html/Zbr0lhfsuf2z183 
In any case,, I tried this with wget in the same way I would target a normal web server. It does not appear to behave the same way.


wget -mkq -np -nH -D bshambaugh.rww.io http://bshambaugh.rww.io

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

<>
    a <http://www.w3.org/ns/ldp#BasicContainer>, <http://www.w3.org/ns/ldp#Container>, <http://www.w3.org/ns/posix/stat#Directory> ;
    <http://www.w3.org/ns/ldp#contains> <.acl>, <profile/>, <storage/> ;
    <http://www.w3.org/ns/posix/stat#mtime> 1412651193 ;
    <http://www.w3.org/ns/posix/stat#size> 4096 .

<.acl>
    a <http://www.w3.org/2000/01/rdf-schema#Resource> ;
    <http://www.w3.org/ns/posix/stat#mtime> 1412651193 ;
    <http://www.w3.org/ns/posix/stat#size> 577 .

<profile/>
    a <http://www.w3.org/ns/posix/stat#Directory> ;
    <http://www.w3.org/ns/posix/stat#mtime> 1412651156 ;
    <http://www.w3.org/ns/posix/stat#size> 4096 .

<storage/>
    a <http://www.w3.org/ns/posix/stat#Directory> ;
    <http://www.w3.org/ns/posix/stat#mtime> 1422986228 ;
    <http://www.w3.org/ns/posix/stat#size> 4096 .