yaml

Twitter incremental backup in YAML format - python, HTML get and parse

I use Twitter primarly as a bookmarking service.

I know that Twitter is not bookmarking service and there are specialized services for such needs. In my case, using this way started as an experiment, but later I found this way very convenient.

I wrote a script that enables me to incrementally backup all my tweets in a textual file in YAML format, by parsing HTML Twitter pages. Explanation and the script follows …

Keep reading

Validating YAML-style Tag Strings with Javascript

This has an admittedly very specific use-case, but recently I needed to validate strings matching the following formats:

[apples, oranges]
[[apples, oranges]]
[apples, oranges, [peaches, grapes]]

The bracket nesting is important as it will later be parsed by a YAML parser to generate nested arrays of strings

[
  "apples",
  "oranges",
  [
    "peaches",
    "grapes"
  ]
]

and then converted to SQL conditions

... WHERE tag1.tag ILIKE "apples" OR tag2.tag ILIKE "oranges" OR (tag3.tag ILIKE "peaches" AND tag4.tag ILIKE "grapes")

The user needed to be prompted as they were entering the strings in this unique format to let them know whether or not their string was valid.

validateTagFormat = function(string){
  var b = 0;
  for (i=0; i<string.length; i++) {
    var c = string[i];
    switch (c) {
      case '[':
        b++;
        break;
      case ']':
        b--;  
        break; 
    }
  }

  if (b != 0) return false;
  if (string.indexOf('[') > string.indexOf(',') && string.indexOf(',') != -1) return false;
  if (string.indexOf(',') > -1 && string.indexOf('[') == -1) return false;
  if (/\]\s*[^\],]/.test(string)) return false;

  string = string.replace(/[\[\]]/g, '');
  string = string.replace(/,\s*/g, ', ');

  return /^[a-zA-Z0\-\ ]+((\,\ )[a-zA-Z0\-\ ]+)*$/.test(string);   
};

This jsFiddle instance shows this in action.

Lately I have been working a lot with YAML data in my HAML templates via Middleman. YAML is great for providing data to display on your site. It allows for easy modification and addition trough separate .yml files instead of having to copy-paste HTML/HAML. YAML is very intuitive to write and work with from Ruby (and templates). But if you are in need of some good documentation, check out this YAML Cookbook.

yo i’ll tell you what i want, what i really really want

i want
i want
i want
i want
i wanna really really really wanna proper documentation on gantry5′s yaml options and capabilities

Rails 2->3 Upgrade Part 2

Ok right off the bat, acts_as_archive… I’m going to say s implementation kind of sucks. I appreciate that they let you use a config file to configure your archive tables…but it doesn’t work. I found a branch that had a fix, but I’m still going to have to update my app code for the new api.

Next, what is up with YAML? You got native yaml, Syck, now Psych? sheesh can we just settle on one please? Anyways, Psych is supposedly our new Leader so make sure all yml’s conform to His/Her One True Structure.

What else…oh yeah cells. Another huge API change here…I’ll be back in a few days once that is all updated and tested.

#yaml #memo - Comparing with JSON & XML (Part 2)

Technically YAML is a superset of JSON. This means that, in theory at least, a YAML parser can understand JSON, but not necessarily the other way around.

See the official specs, in the section entitled “YAML: Relation to JSON”.

In general, there are certain things I like about YAML that are not available in JSON.

  • As @jdupont pointed out, YAML is visually easier to look at. In fact the YAML homepage is itself valid YAML, yet it is easy for a human to read.
  • YAML has the ability to reference other items within a YAML file using “anchors.” Thus it can handle relational information as one might find in a MySQL database.
  • YAML is more robust about embedding other serialization formats such as JSON or XML within a YAML file.

In practice neither of these last two points will likely matter for things that you or I do, but in the long term, I think YAML will be a more robust and viable data serialization format.

Right now, AJAX and other web technologies tend to use JSON. YAML is currently being used more for offline data processes. For example, it is included by default in the C-based OpenCV computer vision package, whereas JSON is not.

You will find C libraries for both JSON and YAML. YAML’s libraries tend to be newer, but I have had no trouble with them in the past. See for example Yaml-cpp.

Symfony2 xml to yaml snippet #2
XML: <services> <service id="sonata.user.admin.user" class="%sonata.user.admin.user.class%"> <tag name="sonata.admin" manager_type="orm" group="%sonata.user.admin.groupname%" label="%sonata.user.admin.user.label%" /> <argument /> <argument>%sonata.user.admin.user.entity%</argument> <argument /> <call method="setUserManager"> <argument type="service" id="fos_user.user_manager" /> </call> </service> </services> Turns to YAML: services: sonata.user.admin.user: class: %sonata.user.admin.user.class% tags: - { name: sonata.admin, manager_type: orm, group: %sonata.user.admin.groupname%, label: %sonata.user.admin.user.label% } arguments: [null, %sonata.user.admin.user.entity%, null] calls: - [setUserManager, [@fos_user.user_manager]]
routing.yml の requirements での正規表現について - symfony1.4

ドキュメントにも載っているやり方。

hoge:
  url: /hoge/:name
  param: { module: hoge, action: fuga }
  requirements: { name: \w+, sf_method: get }

特定のワードのみ許可。

hoge:
  url: /hoge/:name
  param: { module: hoge, action: fuga }
  requirements: { name: (unko|yeah), sf_method: get }

自由に正規表現を書きたい場合。

hoge:
  url: /hoge/:name
  param: { module: hoge, action: fuga }
  requirements: { name: '^(unko|yeah)-[a-z_-]+', sf_method: get }
XML pra quê? Conheça o JSON e o YAML

Por muito tempo o XML dominou a web quando o assunto era serialização de dados. Aos poucos, outras linguagens foram se popularizando e conquistando desenvolvedores por conta das fraquezas desse padrão recomendado pela W3C.

Enquanto isso, poderosas redes sociais, como o Twitter, foram adotando linguagens como o JSON ao fornecer dados através de suas APIs. E com isso, tomando grandes proporções no mercado. 

Keep reading

i am so so frustrated by gantry5′s yaml bullshit

all i want is to enable the font selector for module and article headers. i made them show up on the back end but on the front end nothing happens

Travis CI 入門:GitHub + Travis CI で継続的インテグレーション

1. Travis CI とは

Travis CI はオープンソースコミュニティのためにホストされた CI(継続的インテグレーション)サービスです。

継続的インテグレーションってなんだ?

継続的インテグレーション、CI(英: continuous integration)とは、主にプログラマーのアプリケーション作成時の品質改善や納期の短縮のための習慣のことである。エクストリーム・プログラミング (XP) のプラクティスの一つで、狭義にはビルドやテスト、インスペクションなどを継続的に実行していくことを意味する。特に、近年の開発においては、継続的インテグレーションをサポートするソフトウェアを使用することがある。

引用: 継続的インテグレーション - Wikipedia

Travis CI は GitHub と連携しており、CI したいリポジトリーを接続しておくと、Travis CI がコミットを取得して、設定ファイル通りにビルド・テストしてくれます。そしてビルド・テストに失敗するとメール(他も可)で結果が送られてきます。

以下のような流れでビルド・テストが行われます。

 +---> [Developer] --- (1) ---> [GitHub] <---+
 |                                           |
 +----- (3) ----- [Travis CI] ----- (2) -----+

(1) ソースコミット
(2) 未テストのコミット取得
(3) テスト結果を送信

Keep reading