yosun.me: yosun is me » Tutorials http://yosun.me a diary. maybe. Tue, 30 Sep 2014 22:07:10 +0000 en hourly 1 http://wordpress.org/?v=3.1 Archive.org API in a Box http://yosun.me/2012/07/22/archive-org-api-in-a-box/ http://yosun.me/2012/07/22/archive-org-api-in-a-box/#comments Mon, 23 Jul 2012 05:11:13 +0000 yosun http://yosun.me/?p=218 This weekend I had the pleasure (pain) of working with an API with infinite storage and infinite expanse, except it has little documentation and even littler support community. But, it’s basically free S3, when it works…

Archive.org API is similar to S3, with objects (files) contained in a bucket (organizer) system. The base url is s3.us.archive.org

Putting files on there requires an odd curl syntax, with basic-auth – this may cause issues with some existing S3 wrappers/SDKs.

  • This syntax will both create a bucket and upload a file at the same time.
  • curl --location --header 'x-amz-auto-make-bucket:1'
           --header 'x-archive-meta01-collection:opensource'
           --header 'x-archive-meta-mediatype:texts'
           --header "authorization: LOW [KEY]:[SECRET]"
           --upload-file [/path/to/filename] http://s3.us.archive.org/[bucketname]/[filename]

    After you call this, you should delay() or sleep() for 10 seconds or more, or do a mini-DDOS loop checking if the bucket resource exists, before proceeding to adding more files:

  • This will let you add more files to the above bucket:
  • curl --location --header "authorization: LOW [KEY]:[SECRET]"
           --silent --show-error
           --upload-file [/path/to/filename] http://s3.us.archive.org/[bucketname]/[filename]

    Make sure that a space separates all parameter and values.

  • Once the object is stored…
    • The endpoint to load its page is:


    • The endpoing to download the content is:


  • The server is very unreliable. If you followed the above, and put sleep() or delay() methods in between calls, and things still don’t work, it’s very likely archive.org ran into a blip, usually in retrieval, rather than storage.

    http://yosun.me/2012/07/22/archive-org-api-in-a-box/feed/ 0
    git in a box http://yosun.me/2012/01/20/git-in-a-box/ http://yosun.me/2012/01/20/git-in-a-box/#comments Fri, 20 Jan 2012 11:00:47 +0000 yosun http://yosun.me/?p=167 Here’s the gist of git in a box (Legend: {directions} whereas [replace me]):

    {cd to folder you want git to vc} git init
    {add everything in folder to git} git add .
    git commit -a -m “[notes about this commit]”
    {Stage + Commit via Alias*} git coma “[notes about this commit]“
    {new idea?} git branch [new branch name]
    {back to a prev branch?} git checkout [branch name]
    {cd back to master} git merge [branch to merge]
    gitk – - all {loads a git gui! (note – two dashes no space)}

    * One issue with git is that it does not automatically “git add .”… so if you end up committing adding files and directories to your project after that first “git add .”, you might end up with versions with missing file or directory references!

    Here’s one simple way is to set up an alias that does both the “git add .” and the “git commit -a -m.” Type this into the terminal:

    git config –global alias.coma ‘!git add . && git commit -a -m’

    http://yosun.me/2012/01/20/git-in-a-box/feed/ 0
    Enabling phpMyAdmin Designer Mode for AJAX View of Table Relations http://yosun.me/2011/04/13/enabling-phpmyadmin-designer-mode-for-ajax-view-of-table-relations/ http://yosun.me/2011/04/13/enabling-phpmyadmin-designer-mode-for-ajax-view-of-table-relations/#comments Wed, 13 Apr 2011 09:15:25 +0000 yosun http://yosun.me/?p=56 [I was pleasantly surprised to find the classic web-based interface to MySQL - phpMyAdmin - at #mysqlconf 2011. Though their booth was rather spartan, staffed by one of two developers in North America (alas, no travel comps from O'Reilly), phpMyAdmin's Designer View proves to be a totally neat tidbit to take home. See below for a quick screenshot!]

    phpMyAdmin comes with some more visual gui goodness that is not enabled by default. This includes a MySQL Workbench-like table relations view, and pdf gen. Enabling them is documented in a rather roundabout method on their wiki, so here’s a step-by-step tutorial for taking phpMyAdmin … (finally) to the 21st century! o.O

    Note, for this tutorial: I am using MySQL 5.0.92-community and phpMyAdmin via WHM/cPanel running on CentOS

    N.B. All commands below should be done with root or superuser, and not one particular user’s phpMyAdmin installation.

    1. Create a control user named pma – replace pmapass below with a good password, then copy and paste the SQL into the SQL form field on phpMyAdmin
      GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass';
          Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
          Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
          File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
          Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
          Execute_priv, Repl_slave_priv, Repl_client_priv
          ) ON mysql.user TO 'pma'@'localhost';
      GRANT SELECT ON mysql.db TO 'pma'@'localhost';
      GRANT SELECT ON mysql.host TO 'pma'@'localhost';
      GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv)
          ON mysql.tables_priv TO 'pma'@'localhost';
    2. Create the table structure (and phpmyadmin global db) – You will find a create_tables.sql file via ls in the path to your phpmyadmin scripts. For CentOS, this is @ /usr/local/cpanel/base/3rdparty/phpMyAdmin/scripts … Execute this sql, or copy and paste it and put it in the SQL form field in phpMyAdmin.
    3. Enable usage of db phpmyadmin in config.inc.php
      Replace pmapass below with the password of the pma user you created above. You can use vi (for example) to edit this file. i to insert, delete button to delete, :wq to save and quit

      $cfg['Servers'][$i]['controluser'] = 'pma';
      $cfg['Servers'][$i]['controlpass'] = 'pmapass';
      $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
      $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
      $cfg['Servers'][$i]['relation'] = 'pma_relation';
      $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
      $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
      $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
      $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
      $cfg['Servers'][$i]['history'] = 'pma_history';
      $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';

    Designer View shows MySQL Workbench-like interface in phpMyAdmin 3 and higher

    http://yosun.me/2011/04/13/enabling-phpmyadmin-designer-mode-for-ajax-view-of-table-relations/feed/ 2