Skip to content

Instantly share code, notes, and snippets.

Muhammed Demirbaş mmdemirbas

View GitHub Profile
@mmdemirbas
mmdemirbas / CombineIntoPDF.java
Last active Mar 28, 2019
Combine multiple images into a single PDF file using Apache PDFBox 2.0.1
View CombineIntoPDF.java
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;
@mmdemirbas
mmdemirbas / MultiDatePicker.java
Last active Apr 30, 2018
JavaFX Multiple Dates Picker
View MultiDatePicker.java
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 / LogbackUtils.java
Last active Apr 9, 2019
Changing log level for logback-classic using reflection if it is present in the classpath without depending to the JAR.
View LogbackUtils.java
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.
View static_xml.xml
<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>
View main.xml
<?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>
@mmdemirbas
mmdemirbas / battery.ps1
Created Mar 27, 2013
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
View battery.ps1
#########################################################################
# #
# 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 / set-ntfs-ro.ps1
Created Mar 23, 2013
PowerShell script to set or clear NTFS read-only flag of a volume by volume label
View set-ntfs-ro.ps1
#########################################################################
# #
# 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 Oct 8, 2012
Batch script to execute a given command repeatedly. Waits specified amount of time between two executions.
View listen.bat
@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 / grub-use-saved.sh
Created Oct 8, 2012
Configures grub to set last used entry as default automatically in each boot
View grub-use-saved.sh
# @author: mmdemirbas@gmail.com
filename=/etc/default/grub
# Replace GRUB_DEFAULT value to 'saved'
echo :: Setting GRUB_DEFAULT=saved
sudo sed -i 's/GRUB_DEFAULT=.*/GRUB_DEFAULT=saved/g' $filename
# Append GRUB_SAVEDEFAULT=true after deleting old GRUB_SAVEDEFAULT's
echo :: Setting GRUB_SAVEDEFAULT=true
@mmdemirbas
mmdemirbas / beep.bat
Created Sep 23, 2012
Windows batch file to generate a beep sound after a certaion amount of time.
View beep.bat
:: 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
You can’t perform that action at this time.