Skip to content

Instantly share code, notes, and snippets.

Jens Rantil JensRantil

Block or report user

Report or block JensRantil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View java_indentation_horror.java
/**
* Get a local cache manager. It's not replicated nor distributed in any
* way.
* @return
*/
public static BasicCacheHandler getCacheManager(){
//We jump through these hoops so we don't have to deploy a ehcache.xml
if (cache_manager==null) {
// Trying not to make the lock
synchronized (CacheHandler.class) {
View draft-petersson-forwarded-for-02-improvements
Hi again,
I stumbled across you "Forwarded http Extension" (http://tools.ietf.org/html/draft-petersson-forwarded-for-02) a week ago and have been thinking about it a bit more; One thing that I think the draft currently is missing is a way to disclose to the backend the full URL that was used for the original request.
There are two things missing:
Which resource was requested in the original request. If a request to http://myserver.com/hello/index.jsp is proxied to http://myserver.com/hello2/index.jsp it would be highly useful for the backend to know that the original request was /hello/index.jsp and not /hello2/index.jsp. While a frontend webserver could potentially correct redirects (301s and 302s, example: http://wiki.nginx.org/HttpProxyModule#proxy_redirect) there are also occasions when the backend would like to know about the original request being made. Examples are to have correct links/URLs to media files (images, CSS, JavaScript etc.).
Which port that was used on the original request. While I hav
@JensRantil
JensRantil / gist:2692996
Created May 14, 2012
A perfect example of unnecessary comments (in default nagios configuration)
View gist:2692996
# 'check_https_hostname_on_port' command definition
define command{
command_name check_https_hostname_on_port
command_line /usr/lib/nagios/plugins/check_http --ssl -H '$HOSTNAME$' -I '$HOSTADDRESS$' -p '$ARG1$'
}
@JensRantil
JensRantil / test_files.py
Created Aug 11, 2012
How to check if all files were closed using Mock
View test_files.py
import mock
files_opened = []
real_open = open # Needed since I will wrap open
def open_wrapper(*args, **kw):
opened_file = mock.MagicMock(wraps=real_open(*args, **kw))
files_opened.append(opened_file)
return opened_file
open_mock = mock.MagicMock(side_effect=open_wrapper)
open_mock.__enter__.side_effect = open_wrapper
@JensRantil
JensRantil / ddfs_xcat_-_less.txt
Created Aug 13, 2012
Recreation of json.loads issue
View ddfs_xcat_-_less.txt
"{\"coordinates\":null,\"in_reply_to_user_id\":159938854,\"truncated\":false,\"text\":\"@dstorna \\n\\u0627\\u062e\\u0648\\u064a \\u0639\\u0628\\u062f\\u0627\\u0644\\u0644\\u0647 \\u0627\\u0644\\u0631\\u0624\\u064a\\u0629 \\u062d\\u0642 \\u0648\\u0627\\u0644\\u062a\\u0641\\u0633\\u064a\\u0631 \\u0627\\u0644\\u0627\\u0648\\u0644 \\u0644\\u0647\\u0627 \\u064a\\u0642\\u0639 \\u0642\\u062f \\u064a\\u0636\\u062d\\u0643 \\u0627\\u062d\\u062f \\u0645\\u0639\\u0643 \\u0648\\u064a\\u0641\\u0633\\u0631\\u0647\\u0627 \\u0628\\u0633\\u0648\\u0621\",\"id_str\":\"234786337595727874\",\"entities\":{\"hashtags\":[],\"urls\":[],\"user_mentions\":[{\"indices\":[0,8],\"id_str\":\"159938854\",\"name\":\"\\u0639\\u0628\\u062f\\u0627\\u0644\\u0644\\u0647 \\u0627\\u0644\\u0634\\u0644\\u0627\\u062d\\u064a\",\"screen_name\":\"dstorna\",\"id\":159938854}]},\"place\":null,\"retweet_count\":0,\"favorited\":false,\"geo\":null,\"source\":\"\\u003Ca href=\\\"http:\\/\\/twitter.com\\/download\\/iphone\\\" rel=\\\"nofollow\\\"\\u003ETwitter
View prune_git_branches.sh
#!/bin/bash
# This has to be run from master
git checkout master
# Update our list of remotes
git fetch
git remote prune origin
# Remove local fully merged branches
@JensRantil
JensRantil / sms_varning.txt
Created Nov 19, 2012
Telavox nya SMS-varning
View sms_varning.txt
Hej! Du har nu förbrukat mer data än vad som ingår i ditt datapaket och detta är därför avstängt. Kontakta vår support så hjälper vi dig att komma igång igen!
View gist:4234416
<!-- begin SnapEngage code -->
<script type="text/javascript">
(function() {
var se = document.createElement('script'); se.type = 'text/javascript'; se.async = true;
se.src = '//commondatastorage.googleapis.com/code.snapengage.com/js/14391f77-8239-4b6f-a2d3-1f31f20d14b1.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(se, s);
})();
SnapABug.allowOffline(false);
</script>
<!-- end SnapEngage code -->
@JensRantil
JensRantil / description.txt
Last active Dec 11, 2015
Example of bottom-aligned text in a left margin. ...it can also be done when having floated div:s.
View description.txt
Two rows. Each row contain two columns.
@JensRantil
JensRantil / active-collapsible.js
Created Feb 1, 2013
Make it possible to style `a.accordion-toggle`-links based on whether the Bootstrap collapse/accordion item is collapsed or not. The CSS-class "active" means that a `accordion-group` is open, the lack of it means it's closed. If it wasn't for the fact that the `.collapsed` class is not added initially to a collapsed `a.accordion-toggle` element,…
View active-collapsible.js
jQuery.ready(function() {
$('.accordion').on('hide', function(e) {
$(e.target).parent().find('.accordion-toggle').first().removeClass('active');
}).on('show', function(e) {
$(e.target).parent().find('.accordion-toggle').first().addClass('active');
});
})
You can’t perform that action at this time.