Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / sendgrid-sample.php
Last active December 24, 2021 10:26
Sample script to send email via SendGrid
<?php
require('path-to-lib/httpful/bootstrap.php');
$url = "https://api.sendgrid.com/api/mail.send.json";
$payload = array(
'to' => "m8r-m3r@mailinator.com",
'from' => "m8r-bahfj31@mailinator.com",
'fromname' => "Delivery team",
@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 / 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 / obtain_token.js
Last active October 16, 2019 14:48
Obtain OAuth token in Nodejs for SalesForce Commerce Cloud OCAPI (previously Demandware)
const https = require('https')
const headers = {
'Authorization' : 'Basic YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhOmFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ==',
'Content-Type' : 'application/x-www-form-urlencoded'
}
const optionsget = {
host : 'account.demandware.com',
port : 443,
@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 / ip6tables_setup.bash
Last active March 27, 2024 21:48
Basic setup for ip6tables - drop all traffic except local, ICMP and DHCPv6 traffic.
#!/bin/bash
# http://serverfault.com/questions/410321/debian-ip6tables-rules-setup-for-ipv6/410327#410327
# http://ipset.netfilter.org/iptables.man.html
# https://www.sixxs.net/wiki/IPv6_Firewalling
# https://www.cyberciti.biz/faq/ip6tables-ipv6-firewall-for-linux/
# https://gist.github.com/thomasfr/9712418
# https://gist.github.com/SnakeDrak/f4150f6e517e5a1d525f
# http://www.thegeekstuff.com/2011/06/iptables-rules-examples
# http://www.thegeekstuff.com/scripts/iptables-rules