从备份您的代码段snipplr.com网站

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从备份您的代码段snipplr.com网站相关的知识,希望对你有一定的参考价值。

Dumps your snippets (and possibly skips your favourites [British spelling]) to standard output. Requires Frontier::RPC2.
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use Frontier::Client;
  4.  
  5. my $key = ''; # (your API key)
  6. my $user = ''; # used to skip others' snippets (fill with your user name)
  7.  
  8. my $session = Frontier::Client->new( url => 'http://snipplr.com/xml-rpc.php', debug => 0,);
  9.  
  10. $session->call('user.checkkey', $key)
  11. or die "Provided key has been refused! ";
  12.  
  13. my @args = ($key, '');
  14. my $list = $session->call('snippet.list', @args);
  15.  
  16. my @snippets; # in case you need to process data afterwards (sort ...)
  17.  
  18. for (my $i=0 ; defined($_ = $list->[$i]) ; $i++) {
  19. my $data = $session->call('snippet.get', $_->{'id'});
  20. if ($data->{username} !~ /^$user$/) {next}; # skip favorites (back up just your snippets)
  21. $snippets[$i]=$data; # dump for post loop processing
  22. print "##### $data->{title} ";
  23. print "##### $data->{comment} ";
  24. print "##### $data->{language} $data->{tags} ";
  25. print "##### $data->{source} ";
  26. print "##### ";
  27. print "##### ";
  28. }
  29.  
  30. @snippets = sort {$a->{language} cmp $b->{language}} @snippets; # sort by language

以上是关于从备份您的代码段snipplr.com网站的主要内容,如果未能解决你的问题,请参考以下文章

将代码段发布到Snipplr

vs2003:快速片段工具

Xcode 4.6 的备份代码片段

超实用的php代码片段

Codeigniter 助手重复 HTML 代码片段

架构丰富的代码片段也应该用于产品列表吗?