Skip to content

Instantly share code, notes, and snippets.

View prasann's full-sized avatar
💬
Living by the code

Prasanna V Nagarajan prasann

💬
Living by the code
View GitHub Profile
@prasann
prasann / DynamicSessionIdentifierStrategy.java
Last active June 17, 2017 18:57
Dynamically set session expiry based on the user type
public class DynamicSessionIdentifierStrategy implements HttpSessionStrategy {
private static CookieHttpSessionStrategy cookieHttpSessionStrategy =
new CookieHttpSessionStrategy();
/* Code redacted */
@Override
public void onNewSession(Session session, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
if (!principalManager.isLoggedIn()) {
import org.springframework.security.authentication.CredentialsExpiredException;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
public class SessionExpiryFilter implements Filter {
private final int maxSessionLifeInMinutes;
require 'uri'
require 'net/https'
require 'json'
GITLAB_URL = 'https://gitlab-your-url.com'
USERS_API = '/api/v3/users'
PRIVATE_TOKEN='XXXXXXXXX' #Private token from Git-lab profile.
DEFAULT_PASSWORD = 'some_default_password'
<?xml version="1.0" encoding="UTF-8"?>
<Projects>
<Project name="main :: build" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="0.1008 :: 2" lastBuildTime="2011-08-29T15:22:58" webUrl="http://172.18.20.31:8153/go/pipelines/main/1008/build/2"/>
<Project name="main :: build :: build" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="0.1008 :: 2" lastBuildTime="2011-08-29T15:22:58" webUrl="http://172.18.20.31:8153/go/tab/build/detail/main/1008/build/2/build"/>
<Project name="main :: build :: metrics" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="0.1008 :: 2" lastBuildTime="2011-08-29T15:20:46" webUrl="http://172.18.20.31:8153/go/tab/build/detail/main/1008/build/2/metrics"/>
<Project name="main :: deploy-to-dev" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="0.1008 :: 2" lastBuildTime="2011-08-29T15:25:25" webUrl="http://172.18.20.31:8153/go/pipelines/main/1008/deploy-to-dev/2"/>
<Project name="main :: deploy-to-dev :: deploy-to-dev" activity="Sle
@prasann
prasann / precompile_hook.rake
Created July 29, 2015 14:53
A precompile hook to precompile CKEditor assets.
require 'fileutils'
desc "Create nondigest versions of all ckeditor digest assets"
task "assets:precompile" => :environment do
fingerprint = /\-([0-9a-f]{32})\./
for file in Dir["public/assets/ckeditor/**/*"]
# Skip file unless it has a fingerprint
next unless file =~ fingerprint
# Get filename of this file without the digest
@prasann
prasann / page_load.js
Created March 4, 2015 12:50
Page load time in JS
$(document).ready(function () {
if (typeof(console) !== 'undefined' && console.log) {
var now = new Date().getTime();
var page_load_time = now - performance.timing.navigationStart;
console.log("Page loading time: " + page_load_time + ' ms');
}
});
@prasann
prasann / run-jasmine-2.0.js
Created April 4, 2014 11:38
A Jasmine 2.0 spec runner and prints output in the console. The code is almost the same as it comes along with phantomjs example. Only that the console reporter is been modified to adapt to Jasmine 2.0 style
var system = require('system'),isDebugMode = false;
/**
* Wait until the test condition is true or a timeout occurs. Useful for waiting
* on a server response or for a ui change (fadeIn, etc.) to occur.
*
* @param testFx javascript condition that evaluates to a boolean,
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
* as a callback function.
* @param onReady what to do when testFx condition is fulfilled,
@prasann
prasann / SntpClient.java
Created February 14, 2014 15:47
SntpClient for Android
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software