Skip to content

Instantly share code, notes, and snippets.

@kdonald
kdonald / ExampleController.java
Created March 10, 2012 17:54
RestTemplate + Jackson Solr Client Example
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.node.ObjectNode;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@kdonald
kdonald / CorisFilter.java
Created March 29, 2012 01:12
Basic Cross Origin Resource Sharing (CORS) support
package org.springframework.web.servlet.support;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.filter.OncePerRequestFilter;
@jdmr
jdmr / ComponentConfig.java
Last active December 13, 2015 21:58
Spring 3.2 Configuration Files
package org.davidmendoza.demo.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@ComponentScan(basePackages = "org.davidmendoza.demo")
@PropertySource("file:${user.home}/.demo.properties")
public class ComponentConfig {
@bittner
bittner / sqlite2pg.sh
Last active January 23, 2024 08:35 — forked from eclubb/sqlite2pg.sh
#!/bin/bash
# This script will migrate schema and data from a SQLite3 database to PostgreSQL.
# Schema translation based on http://stackoverflow.com/a/4581921/1303625.
# Some column types are not handled (e.g blobs).
#
# See also:
# - http://stackoverflow.com/questions/4581727/convert-sqlite-sql-dump-file-to-postgresql
# - https://gist.github.com/bittner/7368128
@welcoMattic
welcoMattic / IonicCordovaNetwork.js
Last active December 4, 2021 04:33
Async navigator.connection.type service for Ionic Framework
var myApp = angular.module('myApp').service('CordovaNetwork', ['$ionicPlatform', '$q', function($ionicPlatform, $q) {
// Get Cordova's global Connection object or emulate a smilar one
var Connection = window.Connection || {
"CELL" : "cellular",
"CELL_2G" : "2g",
"CELL_3G" : "3g",
"CELL_4G" : "4g",
"ETHERNET" : "ethernet",
"NONE" : "none",
"UNKNOWN" : "unknown",
@gfosco
gfosco / gist:131974d200c5e9fc6c94
Last active April 5, 2022 22:10
parse-jobqueue

README.md:

parse-jobqueue

The Parse Cloud Code job queue. Define, queue, and process work on a constant basis.

USAGE

First, you'll want to define some jobs:

@thomasdarimont
thomasdarimont / App.java
Last active March 16, 2017 16:34
Simple example for using a custom Servlet-Filter to alter the HTTP Request handling thread-name to contain the request URI - to ease debugging.
package demo;
import static java.util.Collections.*;
import java.io.IOException;
import java.util.Map;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
/**
* ================== angular-ios9-uiwebview.patch.js v1.1.1 ==================
*
* This patch works around iOS9 UIWebView regression that causes infinite digest
* errors in Angular.
*
* The patch can be applied to Angular 1.2.0 – 1.4.5. Newer versions of Angular
* have the workaround baked in.
*
* To apply this patch load/bundle this file with your application and add a
@drmalex07
drmalex07 / README-setup-tunnel-as-systemd-service.md
Last active July 18, 2024 07:33
Setup a secure (SSH) tunnel as a systemd service. #systemd #ssh #ssh-tunnel #ssh-forward

README

Create a template service file at /etc/systemd/system/secure-tunnel@.service. The template parameter will correspond to the name of target host:

[Unit]
Description=Setup a secure tunnel to %I
After=network.target
@btroncone
btroncone / authentication.ts
Last active April 10, 2022 06:44
Angular 2 application role access decorator, wrapping built in CanAccess functionality. Prevents view transitions when user roles are not appropriate.
import { Injectable } from 'angular2/core';
import { Storage } from './storage';
import { CurrentUser } from '../interfaces/common';
@Injectable()
export class Authentication{
private _storageService : Storage;
private _userKey : string = "CURRENT_USER";
constructor(storageService : Storage){