Skip to content

Instantly share code, notes, and snippets.

@omernaci
omernaci / JavaFXPropertiesSample.java
Created April 13, 2017 09:47
JavaFX Properties and Events Sample
// Counter.java class
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
/**
*
* @author omers
*/
public class Counter {
@omernaci
omernaci / JavaFXObservableListSample.java
Created April 13, 2017 09:51
JavaFX ObservableList Sample
// Main.java class
import java.util.ArrayList;
import java.util.List;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
/**
*
@omernaci
omernaci / JavaFXBindingSample.java
Created April 13, 2017 19:21
JavaFX Binding Sample
// Main.java class
import javafx.beans.binding.NumberBinding;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
/**
*
* @author omers
*/
@omernaci
omernaci / ScreenResolutionDemo.java
Created April 19, 2017 05:56
JavaFX Scene Size with Screen Resolution
import java.awt.Dimension;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
public class ScreenResolutionDemo extends Application {
@omernaci
omernaci / Password.java
Created September 5, 2017 07:07 — forked from craSH/Password.java
A simple example Java class to safely generate and verify bcrypt password hashes for use in authentication systems.
/**
* Author: Ian Gallagher <[email protected]>
*
* This code utilizes jBCrypt, which you need installed to use.
* jBCrypt: http://www.mindrot.org/projects/jBCrypt/
*/
public class Password {
// Define the BCrypt workload to use when generating password hashes. 10-31 is a valid value.
private static int workload = 12;
@omernaci
omernaci / ProxyConfig.java
Created August 2, 2018 12:33
Apache HttpComponents Proxy Config(v4.5.5)
try (ClosableHttpClient httpClient = HttpClients.createDefault()) {
HttpHost proxy = new HttpHost("proxy host", 3128);
RequestConfig config = RequestConfig.custom()
.setProxy(proxy)
.build();
HttpGet httpget = new HttpGet("/path");
httpget.setConfig(config);
@omernaci
omernaci / index.js
Last active August 15, 2018 11:15
JQuery Number Input First Character Disable Zero
...
<input onfocus="disableFirstCharZero('inputId')"></input>
...
function disableFirstCharZero(elementId) {
$ ('#' + elementId).on( 'input propertychange paste', function(e) {
var reg = /^0+/gi;
if ( this.value.match(reg) ) {
this.value = this.value.replace(reg, '');
...
public class CharacterEncodingFilter implements Filter {
public void init(FilterConfig config) throw ServletException {
}
public void doFilter(ServletRequest request, ServletResponse, FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
@omernaci
omernaci / index.html
Created August 15, 2018 08:23
call a function with arguments
<!DOCTYPE html>
<html>
<body>
<p>Click "Try it" to call a function with arguments</p>
<button onclick="myFunction('Harry Potter','Wizard')">Try it</button>
<p id="demo"></p>