Twig – The loop Variable

The loop variable

Inside of a for loop block you can access some special variables:

Variable Description
loop.index The current iteration of the loop. (1 indexed)
loop.index0 The current iteration of the loop. (0 indexed)
loop.revindex The number of iterations from the end of the loop (1 indexed)
loop.revindex0 The number of iterations from the end of the loop (0 indexed)
loop.first True if first iteration
loop.last True if last iteration
loop.length The number of items in the sequence
loop.parent The parent context
1
2
3
{% for user in users %}
    {{ loop.index }} - {{ user.username }}
{% endfor %}

Note

The loop.length, loop.revindex, loop.revindex0, and loop.last variables are only available for PHP arrays, or objects that implement the Countable interface. They are also not available when looping with a condition.

Advertisements

Lynx Browser: Commands

  MOVEMENT: Down arrow – Highlight next topic
Up arrow – Highlight previous topic
Right arrow, – Jump to highlighted topic
Return, Enter – Follow selected link
Left arrow – Return to previous topic
  SCROLLING: + – Scroll down to next page (Page-Down)
– Scroll up to previous page (Page-Up)
SPACE – Scroll down to next page (Page-Down)
b – Scroll up to previous page (Page-Up)
CTRL-A – Go to first page of the current document (Home)
CTRL-E – Go to last page of the current document (End)
CTRL-B – Scroll up to previous page (Page-Up)
CTRL-F – Scroll down to next page (Page-Down)
CTRL-N – Go forward two lines in the current document
CTRL-P – Go back two lines in the current document
) – Go forward half a page in the current document
( – Go back half a page in the current document
^ – Go to the first link on the current line
$ – Go to the last link on the current line
< – Go to the previous link in the current column
> – Go to the next link in the current column
# – Go to Toolbar or Banner in the current document
  DIRED: c – Create a new file
d – Download selected file
e – Edit selected file
f – Show a full menu of options for current file
m – Modify the name or location of selected file
r – Remove selected file
t – Tag highlighted file
u – Upload a file into the current directory
  OTHER: ? (or h) – Help (this screen)
a – Add the current link to a bookmark file
c – Send a comment to the document owner
d – Download the current link
e – Edit the current file
E – Edit the current link’s URL (or ACTION) and
use that as a goto URL.
g – Goto a user specified URL or file
G – Edit the current document’s URL and use that
as a goto URL.
i – Show an index of documents
j – Execute a jump operation
k – Show list of actual key mappings
l – List references (links) in current document
m – Return to main screen
o – Set your options
p Print to a file, mail, printers, or other
q – Quit (Capital ‘Q’ for quick quit)
/ – Search for a string within the current document
s – Enter a search string for an external search
n – Go to the next search string
N – Go to the previous search string
v – View a bookmark file
V – Go to the Visited Links Page
x – Force submission of form or link with no-cache
z – Cancel transfer in progress
[backspace] – Go to the History Page
= – Show info about current document, URL and link
\ – Toggle document source/rendered view
! – Spawn your default shell
– Toggle “historical” vs minimal or valid comment
parsing
_ – Clear all authorization info for this session
` – Toggle minimal or valid comment parsing
* – Toggle image_links mode on and off
@ – Toggle raw 8-bit translations or CJK mode
on or off
. – Run external program on the current link.
, – Run external program on the current document.
{ – Shift the screen left.
} – Shift the screen right.
| – Toggle line-wrap mode.  When line-wrap is
off, you may use { and } to shift the screen
left/right.  The screen width is set to 999.
~ – Toggle parsing of nested tables (experimental).
[ – Toggle pseudo_inlines mode on and off
] – Send a HEAD request for the current doc or link
– Toggle valid or “soft” double-quote parsing
CTRL-R – Reload current file and refresh the screen
CTRL-L – Refresh the screen
CTRL-V – Outside of a text input line or field,
switch to alternative parsing of HTML.
– In a form text input field,
CTRL-V prompts for a key command (allows
escaping from the field).
Note that on most UNIX hosts, CTRL-V is bound
via stty to the lnext (literal-next) code but
the exact behavior of that is implementation
specific.  On Solaris you must type CTRL-V
twice to use it, since it quotes the following
keystroke.
CTRL-U – Inside text input line or field,
erase input line (more input line commands)
– Outside of text input or field,
undo returning to previous topic.
CTRL-G – Cancel input or transfer
CTRL-T – Toggle trace mode on and off
; – View the Lynx Trace Log for the current session
CTRL-K – Invoke the Cookie Jar Page
CTRL-X – Invoke the Cache Jar Page
numbers – Invoke the prompt
Follow link (or goto link or page) number:
or the
Select option (or page) number:
prompt

Force VMware vSphere Client to run in English

Steps:

  1. Make sure your OS has the English pack.
  2. Go where you have the vSphere Client icon.
  3. Right-click and click on Properties.
  4. Select the Shortcut tab and add the following into the Target field: “C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\VpxClient.exe” -locale en_US -u Username -p Password
  5. Click on Ok.
  6. Open vSphere with the above modified shortcut.

Remarks:

  • you can force vSphere to run in any language: German (de_DE), Chinese (zh_CN), etc.
  • these are all the arguments:
    • -passthroughAuth = carries on currently logged on user credentials (use in conjunction with -s)
    • -s = server name
    • -u = username
    • -p = password

Learned today: redis-cli command line options

So, it’s just info you can find with redis-cli –help 🙂 but I didn’t find it in the official documentation.

Usage: redis-cli [OPTIONS] [cmd [arg [arg …]]]

  • -h <hostname> Server hostname (default: 127.0.0.1)
  • -p <port> Server port (default: 6379)
  • -s <socket> Server socket (overrides hostname and port)
  • -a <password> Password to use when connecting to the server
  • -r <repeat> Execute specified command N times
  • -i <interval> When -r is used,  waits <interval> seconds per command. It is possible to specify sub-second times like -i 0.1
  • -n <db> Database number
  • -x Read last argument from STDIN
  • -d <delimiter> Multi-bulk delimiter in for raw formatting (default: \n)
  • –raw Use raw formatting for replies (default when STDOUT is not a tty)
  • –help Output this help and exit
  • –version Output version and exit

Examples:
cat /etc/passwd | redis-cli -x set mypasswd
redis-cli get mypasswd
redis-cli -r 100 lpush mylist x
redis-cli -r 100 -i 1 info | grep used_memory_human:

When no command is given, redis-cli starts in interactive mode.
Type “help” in interactive mode for information on available commands.

Some Funny Types of Testing

Types of Testing – from netfunny.com

  • Aggression Testing: If this doesn’t work, I’m gonna kill somebody.
  • Compression Testing: []
  • Confession Testing: Okay, Okay, I did program that bug.
  • Congressional Testing:Are you now, or have you ever been a bug?
  • Depression Testing:If this doesn’t work, I’m gonna kill myself.
  • Egression Testing: Uh-oh, a bug… I’m outta here.
  • Digression Testing: Well, it works, but can I tell you about my truck…
  • Expression Testing: #@%^&*!!!, a bug.
  • Obsession Testing: I’ll find this bug if it’s the last thing I do.
  • Oppression Testing: Test this now!
  • Poission Testing: Alors! Regardez le poission!
  • Repression Testing: It’s not a bug, it’s a feature.
  • Secession Testing: The bug is dead! Long lives the bug!
  • Suggestion Testing: Well, it works but wouldn’t it be better if…

:))

2011 in review

The WordPress.com stats helper monkeys prepared a 2011 annual report for this blog.

Here’s an excerpt:

A San Francisco cable car holds 60 people. This blog was viewed about 3,400 times in 2011. If it were a cable car, it would take about 57 trips to carry that many people.

Click here to see the complete report.