Skip to content

Instantly share code, notes, and snippets.

View letenkov's full-sized avatar

Eugene Letenkov letenkov

View GitHub Profile
#!/bin/bash
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
# Install stuff #
#################
# Install development tools and some misc. necessary packages
yum -y groupinstall "Development tools"
yum -y install zlib-devel # gen'l reqs
/**
* Filter which adds CSRF information as response headers.
*
* @author Patrick Grimard
* @since 12/31/2013 4:48 PM
*/
public final class CsrfTokenGeneratorFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
CsrfToken token = (CsrfToken) request.getAttribute("_csrf");
/**
* CsrfTokenRepository implementation which duplicates HttpSessionCsrfTokenRepository functionality, but also
* adds the generated token to the response as a header when saving the token.
*
* @author Patrick Grimard
* @since 12/31/2013 3:44 PM
*/
public final class HttpHeaderCsrfTokenRepository implements CsrfTokenRepository {
/* other code left out for brevity */
/*global webapp, Backbone, JST, _*/
webapp.Views = webapp.Views || {};
(function () {
'use strict';
webapp.Views.LoginView = Backbone.View.extend({
template: JST['app/scripts/templates/login.ejs'],
public class AppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(javax.servlet.ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
appContext.register(AppConfig.class);
servletContext.addListener(new ContextLoaderListener(appContext));
AnnotationConfigWebApplicationContext webConfig = new AnnotationConfigWebApplicationContext();
webConfig.register(WebConfig.class);
ServletRegistration.Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(webConfig));
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
/* other code left out for brevity */
/**
* Configure HttpSecurity, adds a CsrfTokenGeneratorFilter after CsrfFilter.
*
* @param http
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
package com.example;
import java.util.concurrent.TimeUnit;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.SubscribableChannel;
import org.springframework.integration.endpoint.PollingConsumer;
@letenkov
letenkov / Python main() functions
Created April 29, 2013 06:41
Python main() functions
import sys
import getopt
class Usage(Exception):
def __init__(self, msg):
self.msg = msg
def main(argv=None):
if argv is None:
argv = sys.argv
@letenkov
letenkov / Red Hat Nginx Init Script
Created April 28, 2013 17:18
Should work on RHEL, Fedora, CentOS. Tested on CentOS 5. Save this file as /etc/init.d/nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx