Skip to content

Instantly share code, notes, and snippets.

@inancsevinc
inancsevinc / PortalResourceTopItems.java
Created July 2, 2012 07:18
JAX-RS optional path params example
/**
* Returns most popular(retrieved using records in portal_log) documents opened using portal.
* This rest service responds all these requests:<br/>
* ../log/top ({p:/?} makes / optional)<br/>
* ../log/top/<br/>
* ../log/top/10 (same as ../log/top)<br/>
* ../log/top/20 (any number is fine)<br/>
*
* @param numberOfItems max number of items, default 10
* @return list of items containing cuid, rank and viewCount, ordered by viewCount desc
@inancsevinc
inancsevinc / AdminResourceFilter.java
Created July 2, 2012 06:45
JAX-RS resource filter class used to authorize requests
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.sun.jersey.spi.container.ContainerRequest;
import com.sun.jersey.spi.container.ContainerRequestFilter;
import com.sun.jersey.spi.container.ContainerResponse;
import com.sun.jersey.spi.container.ContainerResponseFilter;
@inancsevinc
inancsevinc / turkish_character_unicode_escapes
Created June 21, 2012 14:02
unicode escapes for turkish chars
* ğ - \u011f
* Ğ - \u011e
* ı - \u0131
* İ - \u0130
* ö - \u00f6
* Ö - \u00d6
* ü - \u00fc
* Ü - \u00dc
* ş - \u015f
* Ş - \u015e
@inancsevinc
inancsevinc / nginx_subfilter_config
Created June 18, 2012 21:07
configuration example of HttpSubModule, replaces "__name__" in the response
server {
listen 80;
server_name localhost;
root D:/Development/public;
sub_filter_once off;
location / {
if ($uri ~* /(\w+)\.html$) {
set $filename "$1";
@inancsevinc
inancsevinc / clearcaseChangeFileType
Created June 14, 2012 11:09
Clearcase command for changing file type to overcome max 8000 char on a single line problem
>cleartool chtype compressed_file jquery-ui. min.js
Change version manager and reconstruct all versions for "jquery-ui.min.js"? [no] yes
Changed type of element "jquery-ui.min.js" to "compressed_file".
@inancsevinc
inancsevinc / contactFind.js
Created June 10, 2012 11:52
Cordova contact find example
navigator.contacts.find(['*'], function(contacts) {
alert("number of contacts: " + contacts.length);
$.each(contacts, function(i, contact) {
alert('contact object: ' + JSON.stringify(contact));
});
}, function(contactError) {
alert(contactError);
}, {"multiple": true});
@inancsevinc
inancsevinc / orientationchange_camera.js
Created June 10, 2012 10:11
jQuery Mobile orientation change handler, using cordova camera api
$(window).on('orientationchange', function(event) {
if (event.orientation) {
if (event.orientation == 'portrait') {
//do something
} else if (event.orientation == 'landscape') {
navigator.camera.getPicture(onSuccess, onFail, {quality: 20});
}
}
);
@inancsevinc
inancsevinc / simpleLiveSearch.html
Created May 16, 2012 09:20
Simple live search example
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
var items = ['javascript','java','html','css','python','perl','c','c++'];
$.each(items,function(i,item){
$('#items').append($('<li>').text(item));
@inancsevinc
inancsevinc / rabbitmqJsonGenerator.html
Created May 11, 2012 11:25
RabbitMq Json Definitions Generator
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>RabbitMq Json Definitions Generator</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('#generateBtn').on('click',function(){
var generatedQueues = ''
@inancsevinc
inancsevinc / svn2cc.bat
Created April 12, 2012 14:01
Batch file for exporting subversion repository and checking in to clearcase
@echo off
SET CC_VOB_DIR=
SET CC_VIEW_TAG=
SET CC_COMPONENT_NAME=
SET CC_VOB_NAME=
SET TMP_SVN_EXPORT_DIR=
SET SVN_URL=
@echo deleting directory %TMP_SVN_EXPORT_DIR%