Posts

Showing posts with the label Automation

Alphabetical Sorting Of A Sequence Of Names

Image
Answer : Bubble sorter, which I adapt from my modification to David's answer to my question at Trying to eliminate stack overflow during recursion. The \sortlist macro is the bubble sorter (from the referenced answer, but with and rather than , as the list seperator). However, it leaves the result in the form of Last Name, First and ... . I had to add the \rework macro to make it First Last Name and employ \whichsep to choose whether a , or and should be inserted between names, depending on their placement in the list. No packages required! \documentclass[10pt]{article} \newcommand\alphabubblesort[1]{\def\sortedlist{}% \expandafter\sortlist#1 and \cr and \relax \expandafter\rework\sortedlist and \relax} \def\sortlist#1and #2and #3\relax{% \let\next\relax \ifx\cr#2\relax% \edef\sortedlist{\sortedlist#1}% \else \picknext#1!and #2!\relax% \if F\flipflop% \edef\sortedlist{\sortedlist#1and }% \def\next{\sortlist#2and #3\relax}% \else...

Can Gulp Overwrite All Src Files?

Answer : I can think of two solutions: Add an option for base to your gulp.src like so: gulp.src([...files...], {base: './'}).pipe(...)... This will tell gulp to preserve the entire relative path. Then pass './' into gulp.dest() to overwrite the original files. (Note: this is untested, you should make sure you have a backup in case it doesn't work.) Use functions. Gulp's just JavaScript, so you can do this: [...files...].forEach(function(file) { var path = require('path'); gulp.src(file).pipe(rename(...)).pipe(gulp.dest(path.dirname(file))); } If you need to run these asynchronously, the first will be much easier, as you'll need to use something like event-stream.merge and map the streams into an array. It would look like var es = require('event-stream'); ... var streams = [...files...].map(function(file) { // the same function from above, with a return return gulp.src(file) ... }; return...

Alter Charset And Collation In All Columns In All Tables In MySQL

Answer : Solution 1: First of all, don't just take my word for it! Test my suggestion out with this: select CONCAT('alter table ',TABLE_SCHEMA,'.',TABLE_NAME,' charset=utf8;') from information_schema.TABLES WHERE TABLE_SCHEMA != 'information_schema' limit 10; select CONCAT('alter table ',TABLE_SCHEMA,'.',TABLE_NAME,' alter column ',COLUMN_NAME,' charset=utf8;') from information_schema.COLUMNS WHERE TABLE_SCHEMA != 'information_schema' limit 10; If you feel good with the outcome of that, remove the limit clauses and save the output to an SQL script or, get fancy and pipe the output directly to mysql similar to what I demonstrate here. That would look like this: mysql -B -N --host=prod-db1 --user=admin --password=secret -e "select CONCAT('alter table ',TABLE_SCHEMA,'.',TABLE_NAME,' charset=utf8;') from information_schema.TABLES WHERE TABLE_SCHEMA != 'information_schema...

Convert Microsoft Visio Drawing (vsd) To PDF Automatically

Answer : I found this nice vbs script and adapted it to visio.It can be called via cygwin (works for all kind of Office stuff) Option Explicit Main() Sub Main() If WScript.Arguments.Count > 0 Then Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject") Dim i For i = 0 to wscript.arguments.count - 1 Dim strFilePath : strFilePath = WScript.Arguments.Item(i) Dim dirPath : dirPath = objFSO.GetParentFolderName(strFilePath) Dim fileBaseName : fileBaseName = objFSO.GetBaseName(strFilePath) 'WScript.Echo strFilePath Dim strNewFileName : strNewFileName = dirPath & "\" & fileBaseName & ".pdf" 'WScript.Echo strNewFileName Dim strFileExt : strFileExt = UCase(objFSO.GetExtensionName(strFilePath)) Select Case strFileExt Case "DOC" DOC2PDF strFilePath, strNewFileName Case ...