Skip to content

Instantly share code, notes, and snippets.

@MoriTanosuke
MoriTanosuke / CsvBean.java
Created June 23, 2011 18:58
Unmarshal CSV with Apache Camel and Bindy
package de.kopis.camel.model;
import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
import org.apache.camel.dataformat.bindy.annotation.DataField;
@CsvRecord(separator = ",")
public class CsvBean {
@DataField(pos = 1)
private String first;
@DataField(pos = 2)
@pazdera
pazdera / gist:1098119
Created July 21, 2011 20:25
Singleton example in C++
/*
* Example of a singleton design pattern.
* Copyright (C) 2011 Radek Pazdera
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
@pazdera
pazdera / builder.cpp
Created August 2, 2011 20:33
Example of `builder' design pattern in C++
/*
* Example of `builder' design pattern.
* Copyright (C) 2011 Radek Pazdera
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@mvaz
mvaz / dump_oracle.py
Created March 18, 2012 21:27
Dump Oracle db schema to text
# http://code.activestate.com/recipes/576534-dump-oracle-db-schema-to-text/
#!/usr/bin/env python
# -*- coding: utf8 -*-
__version__ = '$Id: schema_ora.py 928 2012-01-12 19:09:34Z tt $'
# export Oracle schema to text
# usable to compare databases that should be the same
#
@ser1zw
ser1zw / dragdrop.ps1
Created March 22, 2012 17:48
PowerShell Drag & Drop sample
# PowerShell Drag & Drop sample
# Usage:
# powershell -sta -file dragdrop.ps1
# (-sta flag is required)
#
Function DragDropSample() {
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$form = New-Object Windows.Forms.Form
$form.text = "Drag&Drop sample"
$listBox = New-Object Windows.Forms.ListBox
@madan712
madan712 / ReadWriteExcelFile.java
Created October 18, 2012 14:35
Read / Write Excel file (.xls or .xlsx) using Apache POI
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@fabriciocolombo
fabriciocolombo / gist:4279304
Created December 13, 2012 20:00
Capturing console output with Delphi
//Anonymous procedure approach by Lars Fosdal
type
TArg<T> = reference to procedure(const Arg: T);
procedure TForm1.CaptureConsoleOutput(const ACommand, AParameters: String; CallBack: TArg<PAnsiChar>);
const
CReadBuffer = 2400;
var
saSecurity: TSecurityAttributes;
hRead: THandle;
@scturtle
scturtle / maildog.pyw
Last active December 8, 2018 04:42
a mail checker on the system tray (pyqt)
# coding: utf-8
import logging
import os, sys, json
from PyQt4 import QtGui
from PyQt4.QtCore import QTimer
import imaplib, StringIO, rfc822
from email.Header import decode_header
_config = json.load(open('config.json')) # server, user, pasw
locals().update(_config)
@dkstar88
dkstar88 / uImageLoader.pas
Created July 23, 2013 06:43
A ImageLoader for FireMonkey TImage component. I written this when I found I need to load a few images from the Internet. Obviously delphi isn's browser, if I just call download using Indy it will just block my app's UI. ImageLoader is very simple class with a loading queue, and a timer to trigger the work on the queue. You just need to call the…
unit uImageLoader;
interface
uses SysUtils, Classes, System.Generics.Collections,
FMX.Types, FMX.Objects, FMX.Controls, AsyncTask, AsyncTask.HTTP;
type
TLoadQueueItem = record
ImageURL: String;
@garyrussell
garyrussell / Main.java
Last active June 25, 2018 06:00
Quick Start
public class Main {
public static void main(String... args) throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml");
// simple service
TempConverter converter = ctx.getBean("gw1", TempConverter.class);
System.out.println(converter.fahrenheitToCelcius(68.0f));
// web service
converter = ctx.getBean("gw2", TempConverter.class);
System.out.println(converter.fahrenheitToCelcius(68.0f));