Skip to content

Instantly share code, notes, and snippets.

@velizarn
velizarn / eclipse-start.bat
Last active August 29, 2015 14:09
Select Java version and then start Eclipse executable file located in the same directory with runtime parameters "-clean" and "-vm" according to selected JDK.
@echo off
:chooseversion
set /p javaVersion=Please choose Java version (type 6, 7, 8 or 0 for exit): %=%
IF "%javaVersion%" == "6" (
start /d %CD% eclipse.exe -clean -vm "C:/Program Files/Java/jdk1.6.0_45/bin/javaw.exe"
) ELSE IF "%javaVersion%" == "7" (
@velizarn
velizarn / validate_email.php
Last active August 29, 2015 14:12
Email address validation with Mailgun
<?php
error_reporting(E_ALL);
function validate_email($email)
{
$key = ''; // Setup Mailgun public key
if (function_exists('filter_var')) {
@velizarn
velizarn / create-css-sprites.php
Last active January 1, 2016 16:39
When you have a number of small images that appear on a page it makes sense to use CSS sprites to speed-up the rendering of your web page. This has two advantages: It reduces the number of HTTP requests a browser has to make to download the images on your page; Speeds up the rendering of the images and the web-page due to limits on the number of…
<?php
error_reporting(E_ALL);
$images_to_load = array(
'C:/img-folder/01.jpg',
'C:/img-folder/02.jpg',
'C:/img-folder/03.jpg',
'C:/img-folder/04.jpg',
'C:/img-folder/05.jpg',
@velizarn
velizarn / yandex_translate.js
Last active June 7, 2016 20:01
Yandex.Translate API request for Node.js
var http = require('http'), https = require('https')
var apiKey = process.argv[2];
var _quSelected = process.argv[3] || '';
var _quPrompt = process.argv[4] || '';
var _lang = process.argv[5] || 'en-bg';
@velizarn
velizarn / delete_dirs.xml
Last active June 13, 2016 20:36
Ant task to delete non-empty directories
<target name="delete.node_modules">
<echo message="Delete node_modules from build directory"/>
<delete verbose="false" includeemptydirs="true">
<fileset dir="${basedir}/build/node_modules" includes="**/*" defaultexcludes="false" />
</delete>
<delete dir="${basedir}/build/node_modules" />
</target>
@velizarn
velizarn / nodejs app.launch
Last active December 9, 2016 19:55
Eclipse External Tool Configurations - run selected nodejs file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
</listAttribute>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE" value="${none}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="D:\programs\nodejs\node.exe"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="${selected_resource_name}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${container_loc}"/>
</launchConfiguration>
@velizarn
velizarn / ecipse.ini
Last active January 9, 2017 13:26
Eclipse INI configuration
-cssTheme
none
-startup
plugins/org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar
-vm
C:/Program Files/Java/jdk1.8.0_60/bin/javaw.exe
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.300.v20150602-1417
-product
org.eclipse.epp.package.committers.product
@velizarn
velizarn / iptables-custom-log.bash
Last active January 18, 2017 17:50
Log iptables messages in a custom file with rsyslog
#!/bin/bash
IPTABLES_CONF_FILE=/etc/rsyslog.d/iptables.conf
echo ':msg, contains, ": IPTables Packet Dropped: " /var/log/iptables.log' > $IPTABLES_CONF_FILE
echo ':msg, contains, ": IPTables Packet Dropped: " ~' >> $IPTABLES_CONF_FILE
systemctl restart rsyslog
# http://blog.stalkr.net/2009/10/logging-iptables-messages-with-rsyslog.html
const crypto = require('crypto'), https = require('https')
// --------------------------------------------------------------------
let setString = (str = '') => {
return new Promise((resolve, reject) => {
let _name = str || 'John Doe';
@velizarn
velizarn / promise.js
Last active December 28, 2017 07:38
JavaScript basic Promise example
let getName = () => {
return new Promise((resolve, reject) => {
let name = "John Doe";
try {
setTimeout (() => {
resolve( name )
}, 1500)