Skip to content

Instantly share code, notes, and snippets.

View mente's full-sized avatar

Alex Vasilenko mente

View GitHub Profile
@mente
mente / engage_init.js
Created November 17, 2011 15:05
janrain login error
<script type="text/javascript">
(function() {
if (typeof window.janrain !== 'object') window.janrain = {};
window.janrain.settings = {};
janrain.settings.tokenUrl = '${tokenUrl}';
function isReady() { janrain.ready = true; };
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", isReady, false);
<bean id="searchNode" class="org.example.factory.ElasticSearchNodeFactoryBean"
p:configLocation="${elasticsearch.configLocation}">
<property name="settings">
<util:map>
<entry key="node.client" value="true" />
</util:map>
</property>
</bean>
<bean id="searchClient" factory-bean="searchNode" factory-method="client" />
string(19) "2011-09-14 18:14:44"
string(19) "2011-09-14 18:39:42"
string(19) "2011-09-14 18:39:43"
string(19) "2011-09-14 18:39:43"
string(19) "2011-09-14 18:41:11"
string(19) "2011-09-14 18:41:13"
string(19) "2011-09-16 16:51:40"
string(19) "2011-09-16 16:51:42"
string(19) "2011-09-20 12:45:11"
string(19) "2011-09-20 12:45:12"
<?php
$pdo = new PDO('mysql:host=127.0.0.1;dbname=baikal', 'root', '');
$stmt = $pdo->query('SELECT created_date FROM carts_articles');
if (!$stmt->execute()) {
die("Unable to complete statement");
}
foreach ($stmt->fetchAll() as $row) {
var_dump($row[0]);
}
//True hardcode to allow to define manager in spring
public class MyWebSecurityManager extends DefaultWebSecurityManager {
private SessionManager savedSessionManager;
@Override
protected SessionManager createSessionManager(String sessionMode) {
return savedSessionManager;
}
public void setSessionMode(String sessionMode) {
String mode = sessionMode;
if (mode == null) {
throw new IllegalArgumentException("sessionMode argument cannot be null.");
}
mode = sessionMode.toLowerCase();
if (!HTTP_SESSION_MODE.equals(mode) && !NATIVE_SESSION_MODE.equals(mode)) {
String msg = "Invalid sessionMode [" + sessionMode + "]. Allowed values are " +
"public static final String constants in the " + getClass().getName() + " class: '"
+ HTTP_SESSION_MODE + "' or '" + NATIVE_SESSION_MODE + "', with '" +
/*
Incorrect initialization
*/
public class MyContextLoaderListener extends ContextLoaderListener {
@Override
protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext) {
applicationContext.setParent(MySingleton.getContext());
}
}
@mente
mente / gist:1201270
Created September 7, 2011 18:02
Smartfox Filter
public class AuthenticationFilter extends SFSExtensionFilter {
@Override
public void destroy() {}
@Override
public FilterAction handleClientRequest(String s, User user, ISFSObject object) throws SFSException {
ThreadState state = new SubjectThreadState(ShiroUtils.getSubject(user.getSession()));
//how to unbind it later?
state.bind();
return FilterAction.CONTINUE;
@mente
mente / gist:1200074
Created September 7, 2011 08:43
web application addition
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod" value="org.apache.shiro.SecurityUtils.setSecurityManager"/>
<property name="arguments" ref="webSecurityManager"/>
</bean>
@mente
mente / gist:1200071
Created September 7, 2011 08:40
web application definition
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"
p:securityManager-ref="webSecurityManager"
p:loginUrl="/login"
p:successUrl="/accounts/profile">