Skip to content

Instantly share code, notes, and snippets.

@elw00d
elw00d / Interop.cs
Created January 30, 2012 11:11
Interop with credentials
using System;
using System.Net;
using System.Runtime.InteropServices;
namespace DZ.Opc.Integration.Internal
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct COSERVERINFO
{
public uint dwReserved1;
void
ClearCells(XtermWidget xw, int flags, unsigned len, int row, int col)
{
if (len != 0) {
TScreen *screen = TScreenOf(xw);
LineData *ld;
unsigned n;
ld = getLineData(screen, row);
@echo off
setlocal enabledelayedexpansion
IF [%1]==[] (
echo Missing argument
echo Usage: javakill ^<string^> [/A] [/Q]
echo /A - Kill all found processes
echo /Q - Be quite ^(don't ask if found more than one process^)
goto :exit
)
@elw00d
elw00d / pager.jsp
Created February 27, 2014 11:48
Simple pagination for JSP
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" session="false" %>
<%--@elvariable id="url" type="java.lang.String"--%>
<%--@elvariable id="total_records" type="java.lang.Integer"--%>
<%--@elvariable id="current_page" type="java.lang.Integer"--%>
<%--@elvariable id="page_size" type="java.lang.Integer"--%>
<style type="text/css">
div.pagination {
margin-top: 10px;
@elw00d
elw00d / index.html
Created April 5, 2014 08:50 — forked from kg/index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body onload="onLoad()">
<script type="text/javascript">
var jsilConfig = {
printStackTrace: false,
xna: 4,
package com.playground.myapp.web;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
package su.elwood;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
@elw00d
elw00d / example.jsp
Created April 16, 2014 07:16
Model to Json serializer JSP tag (by Eugene Dolganov)
<%@ taglib tagdir="/WEB-INF/tags/util" prefix="util" %>
<%-- tag should be placed to Web-inf/tags/util/toJson.tag --%>
<script id="scheduleData" type="json-data"><util:toJson source="${schedule}"/></script>
@elw00d
elw00d / import.sh
Created May 22, 2014 05:49
2 scripts: to split mysql dump file to multiple files (one per table) and to import all sql files in current directory to local mysql instance.
#!/bin/bash
for FILE in ./*.sql; do
echo "Importing $FILE"
/cygdrive/c/Program\ Files/MySQL/MySQL\ Server\ 5.6/bin/mysql.exe -u root -padmin --database mydb < $FILE
done
@elw00d
elw00d / group_concat
Created July 17, 2014 09:28
Group_concat for MS SQL
Tables:
a (id, name)
b (id, name)
a_to_b (a_id, b_id)
Outputs:
a_id a_name b_ids_over_comma
select *, STUFF(
(SELECT ',' + LTRIM(RTRIM(b.name))