Skip to content

Instantly share code, notes, and snippets.

View vikaskanani's full-sized avatar

Vikas Patel vikaskanani

View GitHub Profile
@vikaskanani
vikaskanani / readImage.cfm
Created August 17, 2013 09:27
ColdFusion Image reading function
<cfscript>
public function readImage(fullpath){
try {
return ImageNew(fullpath);
} catch (any e) {
//trying java imageio
var imageFile = createObject("java", "java.io.File").init(fullpath);
// read the image into a BufferedImage
var ImageIO = createObject("java", "javax.imageio.ImageIO");
try {
<cfdump var="#TimeSlot(Minutslot = 15)#" />
<cffunction name="TimeSlot" output="false" access="public" returntype="any">
<cfargument name="Minutslot" type="numeric" required="true">
<cfif 1440 MOD arguments.Minutslot NEQ 0>
<cfthrow type="user" message="Invalid Minute slot">
</cfif>
<cfset var i = 0>
@vikaskanani
vikaskanani / gp.bat
Last active February 19, 2016 06:18
gp.bat
git checkout development
IF %ERRORLEVEL% neq 0 GOTO error
git merge vikas
IF %ERRORLEVEL% neq 0 GOTO error
git push origin development
IF %ERRORLEVEL% neq 0 GOTO error
git checkout master
IF %ERRORLEVEL% neq 0 GOTO error
git merge development
IF %ERRORLEVEL% neq 0 GOTO error
for /f "delims=" %%d in ('dir /s /b /ad ^| sort /r') do rd "%%d"
SELECT
tbl.name 'Table Name',
c.name 'Column Name',
t.Name 'Data type',
c.max_length 'Max Length',
c.precision,
c.is_nullable,
ISNULL(i.is_primary_key, 0) 'Primary Key'
FROM sys.columns c
INNER JOIN sys.types t ON c.user_type_id = t.user_type_id
SELECT column, expression, column as alias
FROM table1, table2, table3
FOR JSON [AUTO | PATH]
@vikaskanani
vikaskanani / emailreader.js
Created March 16, 2016 03:44
Email reading with node js
var Imap = require('imap');
var config = require('../config')(process.env['NODE_ENV']);
var winston = require('winston');
var path = require("path");
var logger = new (winston.Logger)({
transports: [
new (winston.transports.File)({
filename: path.resolve(__dirname + '/../logs/all-logs.log'),
@vikaskanani
vikaskanani / cleanEmptyFoldersRecursively.js
Last active June 13, 2017 07:19 — forked from jakub-g/cleanEmptyFoldersRecursively.js
nodejs: remove empty directories recursively which are older than 2 days
function cleanEmptyFoldersRecursively(folder) {
var fs = require('fs');
var path = require('path');
var folderStat = fs.statSync(folder);
var isDir = folderStat.isDirectory();
if (!isDir) {
return;
}
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace='http://webservice.example.com/'
xmlns:tns='http://webservice.example.com/'
elementFormDefault="qualified">
<xs:element name="shiporder" type='tns:shiporder' />
<xs:complexType name="shiporder">
<xs:sequence>
<xs:element name="orderperson" type="xs:string"/>
<xs:element name="shipto" type='tns:shipto' />
<cfsavecontent variable="xml_stream"><cfoutput><?xml version="1.0" encoding="UTF-8"?>
<shiporder orderid="889923"
xmlns="http://webservice.example.com/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://webservice.example.com/ https://gist.githubusercontent.com/vikaskanani/016522bc8969008e5efdf6770effc430/raw/5eec95f8eb34c538f1cfd1e543b22027e021eafa/ShipOrder.xsd">
<orderperson>John Smith</orderperson>
<shipto>
<name>Ola Nordmann</name>
<address>Langgt 23</address>
<city>4000 Stavanger</city>