Skip to content

Instantly share code, notes, and snippets.

View mmdemirbas's full-sized avatar

Muhammed Demirbaş mmdemirbas

View GitHub Profile
@mmdemirbas
mmdemirbas / main.xml
Created April 8, 2013 06:45
WSO2 ESB + ClientAccesPolicy.xml + CrossDomain.xml Link: http://www.mmdemirbas.com/2013/04/wso2-esb-clientaccespolicyxml.html
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="main" trace="disable">
<in>
<log level="headers">
<property name="?" value="[main] in: started"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="To"
expression="get-property('To')"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="PAYLOAD" expression="/*"/>
</log>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="main" trace="disable">
<in>
<log level="headers">
<property name="?" value="[main] in: started"/>
<property name="To" expression="get-property('To')"/>
<property name="PAYLOAD" expression="/*"/>
</log>
<script language="js"><![CDATA[
mc.setPayloadXML(<greeting>Hello World</greeting>);
]]></script>
@mmdemirbas
mmdemirbas / gist:3656288
Created September 6, 2012 13:32
Aggresive MySql Stored Procedure Debugging
DECLARE E INT DEFAULT 0;
DECLARE M TEXT DEFAULT NULL;
DECLARE CONTINUE HANDLER FOR 1000 SET E='1000', M="hashchk";
DECLARE CONTINUE HANDLER FOR 1001 SET E='1001', M="isamchk";
DECLARE CONTINUE HANDLER FOR 1002 SET E='1002', M="NO";
DECLARE CONTINUE HANDLER FOR 1003 SET E='1003', M="YES";
DECLARE CONTINUE HANDLER FOR 1004 SET E='1004', M="Can't create file '%s' (errno: %d)";
DECLARE CONTINUE HANDLER FOR 1005 SET E='1005', M="Can't create table '%s' (errno: %d)";
DECLARE CONTINUE HANDLER FOR 1006 SET E='1006', M="Can't create database '%s' (errno: %d)";
@mmdemirbas
mmdemirbas / set-ntfs-ro.ps1
Created March 23, 2013 20:54
PowerShell script to set or clear NTFS read-only flag of a volume by volume label
#########################################################################
# #
# Script to set or clear read-only flag of an NTFS volume. #
# #
# Usage: .\set-ntfs-ro.ps1 set "MY DISK LABEL" #
# .\set-ntfs-ro.ps1 clear "MY DISK LABEL" #
# #
# Author: Muhammed Demirbas, mmdemirbas at gmail dot com #
# Date : 2013-03-23 #
# #
@mmdemirbas
mmdemirbas / listen.bat
Created October 8, 2012 13:29
Batch script to execute a given command repeatedly. Waits specified amount of time between two executions.
@echo off
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: This script executes given command repeatedly.
:: Waits specified amount of time between two executions.
:: First parameter MUST be sleep time.
:: Rest of the parameters will be executed as a command.
:: This script relies on sleep command from GnuWin32 package.
::
@mmdemirbas
mmdemirbas / LogbackUtils.java
Last active November 26, 2021 11:41
Changing log level for logback-classic using reflection if it is present in the classpath without depending to the JAR.
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.MessageFormat;
/**
* Contains methods to access and manipulate logback framework dynamically at run-time. Here 'dynamically' means without
* referencing the logback JAR, but using it if found in the classpath.
@mmdemirbas
mmdemirbas / battery.ps1
Created March 27, 2013 11:21
PowerShell script to help to keep laptop battery level in the specified range. Not automatically! You need to plug-in or unplug cable when you hear alert sound :) See: http://www.mmdemirbas.com/2013/03/monitor-remaining-battery-level-using.html
#########################################################################
# #
# Script to check battery state periodically and alert if it is #
# going to outside of the desired range (%40-%80) by default. #
# #
# Usage: #
# #
# # To alert if x<=40 or x>=80, and check each 15 sec #
# #
# .\battery.ps1 40 80 15 #
@mmdemirbas
mmdemirbas / beep.bat
Created September 23, 2012 10:58
Windows batch file to generate a beep sound after a certaion amount of time.
:: usage:
:: beep -- beeps immediately
:: beep 1 -- beeps after 1 sec
:: beep 1:2 -- beeps after 1 min, 2 sec
:: beep 1:2:3 -- beeps after 1 hour, 2 min, 3 sec
:: beep 1:2:3:4 -- beeps after 1 day, 2 hours, 3 min, 4 sec
::
:: invalid usages:
:: beep 1::2
:: beep :1
@mmdemirbas
mmdemirbas / MultiDatePicker.java
Last active May 31, 2022 22:27
JavaFX Multiple Dates Picker
package com.mmdemirbas.lab;
/**
* Created by md on 5.04.2016.
*/
import javafx.application.Application;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
@mmdemirbas
mmdemirbas / CombineIntoPDF.java
Last active August 17, 2023 10:38
Combine multiple images into a single PDF file using Apache PDFBox 2.0.1
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;