Skip to content

Instantly share code, notes, and snippets.

@michael-lu-cn
Forked from selenamarie/plv8x
Created April 28, 2014 14:19
Show Gist options
  • Save michael-lu-cn/11373541 to your computer and use it in GitHub Desktop.
Save michael-lu-cn/11373541 to your computer and use it in GitHub Desktop.

Revisions

  1. @selenamarie selenamarie revised this gist Apr 21, 2013. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion plv8x
    Original file line number Diff line number Diff line change
    @@ -107,4 +107,7 @@ curl -i -X PUT -H "Content-Type: text/csv" --data-binary test.csv http://127.0.0

    PLAN
    --> https://species.wikimedia.org/w/index.php?title=Special:WhatLinksHere/Aves&limit=500
    then go to each page and pull out ea order & family page for detailed information and shove all that into json
    then go to each page and pull out ea order & family page for detailed information and shove all that into json


    # http://demos.kendoui.com/
  2. @selenamarie selenamarie revised this gist Apr 21, 2013. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion plv8x
    Original file line number Diff line number Diff line change
    @@ -99,4 +99,12 @@ curl -i -X PUT -H "Content-Type: application/json" --data-binary @test.json http
    curl -i -X PUT -H "Content-Type: text/csv" --data-binary test.csv http://127.0.0.1:3000/collections/test2

    curl 'http://en.wikipedia.org/w/api.php?action=query&titles=List_of_birds&prop=revisions&rvprop=content&format=json' | sed -e 's/\(.\)\*\+/\1\
    /g' | sed -e 's/\[\[/\{\"/' | sed -e 's/\[\[//g' | sed -e 's/\]\]:/\":/' |sed -e 's/\]\]//g' | sed -e 's/\(\: \)/\1 \"/' | sed -e 's/\\n/\"\},^M/' | sed -e 's/,^M\\n\.\*//' | grep ':' | grep '"' | awk 'NR>3{print $0}' > /tmp/junk
    /g' | sed -e 's/\[\[/\{\"/' | sed -e 's/\[\[//g' | sed -e 's/\]\]:/\":/' |sed -e 's/\]\]//g' | sed -e 's/\(\: \)/\1 \"/' | sed -e 's/\\n/\"\},^M/' | sed -e 's/,^M\\n\.\*//' | grep ':' | grep '"' | awk 'NR>3{print $0}' > /tmp/junk

    ^^ very horrible

    # wikispecies

    PLAN
    --> https://species.wikimedia.org/w/index.php?title=Special:WhatLinksHere/Aves&limit=500
    then go to each page and pull out ea order & family page for detailed information and shove all that into json
  3. @selenamarie selenamarie revised this gist Apr 21, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions plv8x
    Original file line number Diff line number Diff line change
    @@ -97,3 +97,6 @@ EOF
    # curl for creating these
    curl -i -X PUT -H "Content-Type: application/json" --data-binary @test.json http://127.0.0.1:3000/collections/test1
    curl -i -X PUT -H "Content-Type: text/csv" --data-binary test.csv http://127.0.0.1:3000/collections/test2

    curl 'http://en.wikipedia.org/w/api.php?action=query&titles=List_of_birds&prop=revisions&rvprop=content&format=json' | sed -e 's/\(.\)\*\+/\1\
    /g' | sed -e 's/\[\[/\{\"/' | sed -e 's/\[\[//g' | sed -e 's/\]\]:/\":/' |sed -e 's/\]\]//g' | sed -e 's/\(\: \)/\1 \"/' | sed -e 's/\\n/\"\},^M/' | sed -e 's/,^M\\n\.\*//' | grep ':' | grep '"' | awk 'NR>3{print $0}' > /tmp/junk
  4. @selenamarie selenamarie revised this gist Apr 21, 2013. 1 changed file with 18 additions and 0 deletions.
    18 changes: 18 additions & 0 deletions plv8x
    Original file line number Diff line number Diff line change
    @@ -79,3 +79,21 @@ selena=# \q
    # POST MIDDLEWARE middlewares
    # API
    https://support.mongolab.com/entries/20433053-REST-API-for-MongoDB


    # JSON insert
    cat << 'EOF' > test.json
    [ { "x" : 1 }, { "x" : 2 }, { "x" : 3 } ]
    EOF

    # csv insert
    cat << 'EOF' > test.csv
    x
    1
    2
    3
    EOF

    # curl for creating these
    curl -i -X PUT -H "Content-Type: application/json" --data-binary @test.json http://127.0.0.1:3000/collections/test1
    curl -i -X PUT -H "Content-Type: text/csv" --data-binary test.csv http://127.0.0.1:3000/collections/test2
  5. @selenamarie selenamarie revised this gist Apr 21, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions plv8x
    Original file line number Diff line number Diff line change
    @@ -75,3 +75,7 @@ selena=# select fw('askhxoashdxoiahsdx');
    (1 row)

    selena=# \q

    # POST MIDDLEWARE middlewares
    # API
    https://support.mongolab.com/entries/20433053-REST-API-for-MongoDB
  6. @selenamarie selenamarie revised this gist Apr 21, 2013. 1 changed file with 25 additions and 0 deletions.
    25 changes: 25 additions & 0 deletions plv8x
    Original file line number Diff line number Diff line change
    @@ -50,3 +50,28 @@ sudo npm i -g plv8x
    sudo npm i -g uax11


    selena@wuzetian:pgrest #1104 21:57 ♥: lsc -pe 'require \uax11 .toFullwidth \hello-selena'

    # Installing the module into the declared database
    selena@wuzetian:pgrest #1104 21:57 😱: plv8x -i uax11
    selena@wuzetian:pgrest #1105 21:57 ♥: plv8x -l
    pgrest: 80769 bytes
    uax11: 137984 bytes
    plv8x: 716954 bytes
    selena@wuzetian:pgrest #1106 21:57 ♥: plv8x -f 'text fw(text)=uax11:toFullwidth'
    ok text fw(text)
    selena@wuzetian:pgrest #1107 21:58 ♥: psql selena
    psql (9.2.4)
    Type "help" for help.

    selena=# select fw("askhxoashdxoiahsdx");
    ERROR: column "askhxoashdxoiahsdx" does not exist
    LINE 1: select fw("askhxoashdxoiahsdx");
    ^
    selena=# select fw('askhxoashdxoiahsdx');
    fw
    --------------------------------------
    askhxoashdxoiahsdx
    (1 row)

    selena=# \q
  7. @selenamarie selenamarie revised this gist Apr 21, 2013. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions plv8x
    Original file line number Diff line number Diff line change
    @@ -32,6 +32,10 @@ sudo add-apt-repository ppa:chris-lea/node.js
    sudo apt-get update
    sudo apt-get install nodejs

    # Don't know why it is needed, but works on Ubuntu
    # Jesse says: I SEE THIS ON EVERY INSTALL :D
    export NODE_PATH=/usr/lib/node_modules

    #
    sudo npm i -g LiveScript
    sudo npm install [email protected] -g
    @@ -44,3 +48,5 @@ sudo npm i -g plv8x

    # and other stuff in here
    sudo npm i -g uax11


  8. @selenamarie selenamarie revised this gist Apr 21, 2013. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions plv8x
    Original file line number Diff line number Diff line change
    @@ -39,3 +39,8 @@ sudo npm install [email protected] -g
    # Install plv8x

    sudo npm i -g plv8x

    # now we are in audrey's slides

    # and other stuff in here
    sudo npm i -g uax11
  9. @selenamarie selenamarie renamed this gist Apr 21, 2013. 1 changed file with 18 additions and 0 deletions.
    18 changes: 18 additions & 0 deletions gistfile1.txt → plv8x
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,24 @@ cd plv8-1.3.0
    make
    sudo make install

    # Make sure npm is installed
    sudo apt-get install npm

    # create extension

    psql -c "create extension plv8"


    # NODE https://github.com/brianc/node-postgres/issues/335#issuecomment-16707881
    sudo apt-get remove nodejs
    sudo add-apt-repository ppa:chris-lea/node.js
    sudo apt-get update
    sudo apt-get install nodejs

    #
    sudo npm i -g LiveScript
    sudo npm install [email protected] -g

    # Install plv8x

    sudo npm i -g plv8x
  10. @selenamarie selenamarie created this gist Apr 21, 2013.
    23 changes: 23 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    # http://nonantolando.blogspot.tw/2012/10/using-json-on-ubuntu-1204-server-with.html

    sudo apt-get install libv8-3.7.12.22 libv8-dev

    # Install d8
    # http://askubuntu.com/questions/141252/is-there-a-package-for-an-executable-version-of-v8

    svn checkout http://v8.googlecode.com/svn/trunk/ ./v8
    cd v8
    make dependencies
    make native
    sudo ln -s `pwd`/out/native/d8 /usr/local/bin/d8

    # Install plv8
    wget https://plv8js.googlecode.com/files/plv8-1.3.0.zip
    unzip plv8-1.3.0.zip
    cd plv8-1.3.0
    make
    sudo make install

    # create extension

    psql -c "create extension plv8"