Dark Launch

This is a Dark Launch.

Firefox Move Tab Left and Move Tab Right with Wrapping (without requiring focus!)

Geany allows you to reorder the document tabs using ALT+Page Up (Move document left) and ALT+Page Down (Move document right). To mimic this behavior in Firefox, do the following:
1. Install Keyconfig (if not already installed).
2. Open Keyconfig and "Add a new key".
Name: Move Tab Right
Code:
Code
 
if(gBrowser.mCurrentTab.nextSibling){
gBrowser.moveTabTo(gBrowser.mCurrentTab,gBrowser.mCurrentTab._tPos+1);
}
else{
gBrowser.moveTabTo(gBrowser.mCurrentTab,0);
}
 

3. Select the "Move Tab Right" shortcut and assign it the keyboard shortcut of ALT+Page Down. Click Apply.
4. Add another key.
Name: Move Tab Left
Code:
Code
 
if(gBrowser.mCurrentTab.previousSibling){
gBrowser.moveTabTo(gBrowser.mCurrentTab,gBrowser.mCurrentTab._tPos-1);
}
else{
gBrowser.moveTabTo(gBrowser.mCurrentTab,gBrowser.mTabContainer.childNodes.length-1);
}
 

5. Select the "Move Tab Left" shortcut and assign it the keyboard shortcut of ALT+Page Up. Click Apply.
4. Now open a new Firefox window (for changes to take effect) with 3 different tabs open. With the first tab focused, press ALT+Page Down and the tab will move to the right. Move it all the way past the last tab and it will wrap and move to the first tab position.

Ubuntu Windows Key Shortcut; Super Key; Win Key

To use the Windows or Start key in a keyboard shortcut, go to System > Preferences > Keyboard.
In Keyboard Preferences (window) go to Layouts (tab) and click Layout Options... (button).
In Keyboard Layout Options (window) expand Alt/Win key behavior (toggle) and select "Hyper is mapped to Win-keys". Now Custom Keyboard Shortcuts will work with the windows key.
Example:
To get Windows + E to open nautilus open Keyboard Shortcuts in System > Preferences > Keyboard Shortcuts. Click Add (button). In the Custom Shortcut window enter Name: nautilus and Command: nautilus and click Apply. Lastly, select the newly created action at the bottom and press the keyboard combination: the windows key and the letter e. Type the windows key and the letter e to bring up a new nautilus window.

Twitter's Frame Breaker To Stop Clickjacking

Twitter uses a frame breaker to help mitigate clickjacking. Interesting implementation:
Javascript
 
if (window.top !== window.self) {
document.write = '';
window.top.location = window.self.location;
setTimeout(function() {
document.body.innerHTML = '';
},
1);
window.self.onload = function(evt) {
document.body.innerHTML = '';
};
}

Code
 
if top window is not this window{
render the page starting here
refresh the page making me the top window to break out of any frames
remove page content (html including graphics, buttons, etc)
when window loads, again remove page content
}
 

NOTE: i think they meant document.write('');

JavaScript Firebug Console Logging on Production

This adds a global variable named "console" to the page. Even if Firebug or another console is not enabled or found, calling a function like console.log() will not error.

Javascript
 
try {
   console.log("");
}
catch (e) {
   window.console = {};
 
   var names = [
       "log",
       "debug",
       "info",
       "warn",
       "error",
       "assert",
       "clear",
       "dir",
       "dirxml",
       "trace",
       "group",
       "groupCollapsed",
       "groupEnd",
       "time",
       "timeEnd",
       "profile",
       "profileEnd",
       "count",
       "exception",
       "table"
   ];
 
   for (var i = 0; i < names.length; ++i) {
       window.console[names[i]] = function() {}
   }
}

The available console functions for Firebug:

Javascript
 
console.log(object[, object, ...])
console.debug(object[, object, ...])
console.info(object[, object, ...])
console.warn(object[, object, ...])
console.error(object[, object, ...])
console.assert(expression[, object, ...])
console.clear()
console.dir(object)
console.dirxml(node)
console.trace()
console.group(object[, object, ...])
console.groupCollapsed(object[, object, ...])
console.groupEnd()
console.time(name)
console.timeEnd(name)
console.profile([title])
console.profileEnd()
console.count([title])
console.exception(error-object[, object, ...])
console.table(data[, columns])

More about Firebug, the Command Line and the Console API

http://getfirebug.com/commandline

http://getfirebug.com/wiki/index.php/Console_API

Geany Snippets, Autocomplete; Snippet Configuration

Geany snippets configuration file is located in:
Code
 
/usr/share/geany/snippets.conf
 

Edit the file:
Code
 
sudo geany /usr/share/geany/snippets.conf
 

Save and restart geany. Now type the word if and the tab key. This will autocomplete an if statement.
INI
 
# from http://citizen.ovh.org/stuff/snippets.conf
# Geany's snippets configuration file
# use \n or %newline% for a new line (it will be replaced by the used EOL char(s) - LF, CR/LF, CR)
# use \t ot %ws% for an indentation step, if using only spaces for indentation only spaces will be used
# use \s to force whitespace at beginning or end of a value ('key= value' won't work, use 'key=\svalue')
# use %cursor% to define where the cursor should be placed after completion
# use %key% for all keys defined in the [Special] section
# you can define a section for each supported filetype to overwrite default settings, the section
# name must match exactly the internal filetype name, run 'geany --ft-names' for a full list
 
# filetype names:
# C, C++, D, Java, Pascal, ASM, Fortran, CAML, Haskell, VHDL, Perl, PHP, Javascript, Python, Ruby,
# Tcl, Lua, Ferite, Sh, Make, O-Matrix, XML, Docbook, HTML, CSS, SQL, LaTeX, Diff, Conf, None
 
# Default is used for all filetypes and keys can be overwritten by [filetype] sections
[Default]
if=if (%cursor%)%brace_open%\n%brace_close%
else=else%brace_open%%cursor%\n%brace_close%
for=for (i = 0; i < %cursor%; i++)%brace_open%\n%brace_close%
while=while (%cursor%)%brace_open%\n%brace_close%
do=do%brace_open%%cursor%\n%brace_close% while ()
switch=switch (%cursor%)%brace_open%case : break;\n%ws%default: \n%brace_close%
try=try%block_cursor%catch ()%block%
 
# special keys to be used in other snippets, cannot be used "standalone"
# can be used by %key%, e.g. %brace_open%
# nesting of special keys is not supported (e.g. brace_open=\n{\n%brace_close% won't work)
# key "wordchars" is very special, it defines the word delimiting characters when looking for
# a word to auto complete, leave commented to use the default wordchars
[Special]
brace_open=\n{\n\t
brace_close=}\n
block=\n{\n\t\n}\n
block_cursor=\n{\n\t%cursor%\n}\n
#wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
 
[C++]
for=for (int i = 0; i < %cursor%; i++)%brace_open%\n%brace_close%
 
[Java]
for=for (int i = 0; i < %cursor%; i++)%brace_open%\n%brace_close%
 
[PHP]
# Little php snippets written by Atanas Beloborodov <nasko@cod3r.org>
#Some php5 object`s usefull snippets
class=class %cursor% \n{\n\tpublic function __construct()\n\t{\t\n\n\t}\n\n\tpublic function __destruct()\n\t{\t\n\n\t}\n}
interface=interface %cursor% %block%
static=public static function %cursor%() %block%
public=public function %cursor%()%block%
protected=protected function %cursor%()%block%
private=private function %cursor%()%block%
#Control structures :
for=for ($i = 0; $i < %cursor%; $i++ %block%
while=while (%cursor%) %block%
if=if (%cursor%) %block%
switch=switch (%cursor%) {\n\tcase '';\n\n\tbreak;\n\n\tdefault :\n\n\tbreak;\n}\n
else=if (%cursor%) %block%else %block%
elseif=if (%cursor%) {\n\t\n}\nelseif () {\n\t\n}\nelse {\n\t\n}\n
do=do %block%while (%cursor%);
foreach=foreach (%cursor%) %block%
# Include methods
# Note : require and include is not functions ! Not required braces ()
req=require "%cursor%";
reqo=require_once "%cursor%";
inc=include "%cursor%";
inco=include_once "%cursor%";
# Others :
function=function %cursor%() %block%
def=define ('%cursor%','');
throw=throw new Exception ('%cursor%');e%
 
[Python]
for=for i in xrange(%cursor%):\n\t
 
[Ferite]
iferr=iferr%block_cursor%fix%block%
monitor=monitor%block_cursor%handle%block%
 
[HTML]
# by Tomasz Karbownicki <tomasz@karbownicki.com>
# top
html=<html>\n\t%cursor%\n</html>
head=<head>\n\t%cursor%\n</head>
java=<div class="javascript code" style="font-family:monospace;"><div style="">Javascript</div><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">\n\t<span style="color: #339933;">%</span>cursor<span style="color: #339933;">%</span>\n</pre></div>
java2=<script type="text/javascript" src="%cursor%"></script>
css=<style type="text/css">\n\t%cursor%\n</style>
css2=<link rel="stylesheet" type="text/css" href="%cursor%" />
rss=<link rel="alternate" type="application/rss+xml" title="%cursor%" href="" />
title=<title>%cursor%</title>
utf=<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
body=<body>\n\t%cursor%\n</body>
# table
table=<table>\n\t<thead>\n\t\t<tr>\n\t\t\t<th>%cursor%</th>\n\t\t</tr>\n\t</thead>\n\t<tbody>\n\t\t<tr>\n\t\t\t<td></td>\n\t\t</tr>\n\t</tbody>\n</table>
td=<td>%cursor%</td>
tr=<tr>%cursor%</tr>
th=<th>%cursor%</th>
caption=<caption>%cursor%</caption>
# form
form=<form action="%cursor%" method="post">\n\n\t<input type="submit" value="Zapisz" />\n</form>
label=<label for="%cursor%"></label>
input=<input type="text" name="%cursor%" value="" id="" />
pass=<input type="password" name="%cursor%" id="" />
textarea=<textarea name="%cursor%" cols="50" rows="10" id="" ></textarea>
select=<select name="%cursor%" id="">\n\t<option value=""></option>\n</select>
radio=<input type="radio" name="%cursor%" value="" />
checkbox=<input type="checkbox" name="%cursor%" value="" />
# list
ul=<ul class="%cursor%">\n\t<li></li>\n</ul>
ol=<ol class="%cursor%">\n\t<li></li>\n</ol>
li=<li>%cursor%</li>
# inline
span=<span class="%cursor%"></span>
em=<em>%cursor%</em>
cite=<cite>%cursor%</cite>
strong=<strong>%cursor%</strong>
img=<img src="%cursor%" alt="" />
anch=<a name="%cursor%"></a>
thumb=<a href="%cursor%"><img src="" /></a>
# block
div=<div class="%cursor%"></div>
h1=<h1>%cursor%</h1>
h2=<h2>%cursor%</h2>
h3=<h3>%cursor%</h3>
h4=<h4>%cursor%</h4>
h5=<h5>%cursor%</h5>
h6=<h6>%cursor%</h6>
p=<p>%cursor%</p>
pre=<pre>\n%cursor%\n</pre>
code=<div class="code code" style="font-family:monospace;"><div style="">Code</div><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">\n%cursor%\n</pre></div>
quote=<blockquote>\n\t<p>\n\t\t%cursor%\n\t</p>\n</blockquote>
# other
cmt=<!--\n\t%cursor%\n-->
br=
 
hr=
 
1s=&nbsp;
3s=&nbsp;&nbsp;&nbsp;
7s=&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
# Django templates
if={% if %cursor% %}\n\t\n{% endif %}
for={% for sth in %cursor% %}\n\t\n{% endfor %}
# Django variable
dv={{ %cursor% }}
# Django block
db={% %cursor% %}