Skip to main content

Posts

Showing posts from 2017

FOOD : Basic Dipping Sauce (Nuoc Cham)

Basic Dipping Sauce (Nuoc Cham) author andrea nguyen yield 3/4 cup Ingredients3 tablespoons lime juice (1 fat, thin skin lime)2 tablespoons sugar½ cup water2 ½ tablespoons fish sauce Optional additions 1 small garlic clove, finely minced1 or 2 Thai chilis, thinly sliced or 1 teaspoon homemade chili garlic sauce or store bought (tuong ot toi)

Raspbery PI 3 B : Enabling WIFI

pi@raspberrypi:~ $ wpa_passphrase "cgull" "McHammer!" network={     ssid="cgull"     #psk="McHammer!"     psk=453d9ffdc2a884e410ababfb35a2d654ca48d0acf81e70f7f62ce6d374499f8b } pi@raspberrypi:~ $ sudo nano /etc/wpa_supplicant//wpa_supplicant.conf pi@raspberrypi:~ $ sudo reboot Connection to raspberrypi.local closed by remote host. Connection to raspberrypi.local closed. mccrazy@Lenovo-N22:~$ ssh pi@raspberrypi.local pi@raspberrypi.local's password:

Biztalk : Extracting Email Body from a POP3 email file

        private static void Testing_Extracting_Email_Body_From_An_Email_File()         {             CDO.IMessage msg = GetCdoEmail(@"C:\BizTalk_Dropzone\MW\OSM.CrewMail\Process\00 - Emails from somebody (No MIME)\New folder\{2413639D-9F69-4E7F-ADE3-A0835E8821EB}.eml");             Console.WriteLine(msg.TextBody);             msg = null;         }         // Microsoft CDO for Windows 2000 Library         // Microsoft ActiveX Data Objects 6.0 Library         private static CDO.IMessage GetCdoEmail(string sAnEmailFile)         {             CDO.Message msg = new CDO.Message();             // load MIME into CDO             using (FileStream stream = new FileStream(sAnEmailFile, FileMode.Open))             {                 // read file into a byte stream                 byte[] emailData = new byte[stream.Length];                 stream.Read(emailData, 0, (int)stream.Length);                 // load byte stream data into an ADODB stream for CDO                 ADODB.Stream stm =

Ruby : Send email with excel attachment using net/smpt

require 'net/smtp' require 'open-uri' def send_email_with_attachment(subject, body, to_email)  user = ' mailsender@gmail.com '  pwd = 'Mail123Pa55word'  to = to_email  from = ' noreply@baliw.com '  subject = "#{subject}" filename = "Excel_Attachment.xlsx" filename = "xlsTemplate.xls" filename = "xlsxTemplate.xlsx" # Read a file and encode it into base64 format filecontent = File.binread(filename) encodedcontent = [filecontent].pack("m")   # base64 marker = "AUNIQUEMARKER" body = <<EOF This is a test email to send an attachement using net/smpt. EOF # Define the main headers. part1 = <<EOF From: No Reply <#{from}> To: A Test User <#{to}> Subject: Sending Excel Attachement test123 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary = #{marker} --#{marker} EOF # Define the message action part2 = <<EOF Content-Type: text/plain Content-Transfer-Encoding:8bit

T SQL : SMS Validation format

DECLARE  @BDay varchar(15),  @Code varchar(10),  @CusTomerNo varchar(10) DECLARE  @SMS varchar(500)  ,@OutBoundSMS varchar(500)  ,@WordCount int  ,@IsValidSMS bit --SET @SMS = 'FW 01928 12311995' -- valid --SET @SMS = 'FW 101928 12311995' -- valid --SET @SMS = 'QUERY 101928 12311995' -- Invalid --SET @SMS = 'FW 1x1928 12311995' -- Invalid --SET @SMS = 'FW 1x1928 12.31.1995' -- Invalid --SET @SMS = 'FW 1x1928 12.31.1995' -- Invalid SET @SMS = 'FW' -- Invalid --SET @SMS = 'FW 01928' -- Invalid --SET @SMS = 'FW A1928' -- Invalid SET @IsValidSMS = 0 SELECT  IDENTITY(int, 1, 1) AS Id,  splitdata INTO #temp1  FROM dbo.fnSplitString(@SMS,' ') SELECT @WordCount = COUNT(*) FROM #temp1 IF @WordCount = 3 BEGIN  --SELECT 'Valid 3 words format...'  SELECT TOP 1 @Code = splitdata FROM #temp1 WHERE Id = 1  SELECT TOP 1 @CusTomerNo = splitdata FROM #temp1 WHERE Id = 2    SELECT TOP 1 @BDay = splitdata FROM #temp1 W

EPPlus : Reading Excel's dynamic worksheets, dynamic rows and dynamic columns

private static void POC_ReadExcelWorksheetsRowsAndColumns() {     string excelFile = @"C:\Raw Excel.xlsx";     using (ExcelPackage package = new ExcelPackage(new FileInfo(excelFile)))     {         foreach (ExcelWorksheet workSheet in package.Workbook.Worksheets)         {             // Make sure its not a blank sheet:             if (workSheet.Dimension == null) continue;             // Get dynamic row and column count:             int rowCount = workSheet.Dimension.End.Row;             int columnCount = workSheet.Dimension.End.Column;             Console.WriteLine("Worksheet name: {0}, with {1} rows and {2} columns", workSheet.Name, rowCount, columnCount);             Console.WriteLine("workSheet.Dimension.Rows: {0}", workSheet.Dimension.Rows);             Console.WriteLine("workSheet.Dimension.Columns: {0}", workSheet.Dimension.Columns);             Console.WriteLine(string.Format("Cell A1 value is {0}", workSheet.Cells["A1&quo

Heroku push problem : error: src refspec maste does not match any.

> Problem: When issuing command; $ git push heroku maste error: src refspec maste does not match any. error: failed to push some refs to ' https://git.heroku.com/myapp-job.git ' > Resolution: $ git push heroku HEAD:master > Terminal: $ git push heroku maste error: src refspec maste does not match any. error: failed to push some refs to ' https://git.heroku.com/myapp-job.git ' $ git show-ref 830920a24c2c3edbccf9b132a976bf8c72463dc0 refs/heads/master $ git remote -v heroku    https://git.heroku.com/myapp-job.git (fetch) heroku    https://git.heroku.com/myapp-job.git (push) $ git push heroku HEAD:master Counting objects: 11, done. Delta compression using up to 2 threads. Compressing objects: 100% (11/11), done. Writing objects: 100% (11/11), 6.90 KiB | 0 bytes/s, done. Total 11 (delta 0), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Ruby app detected remote: -----> Compiling Ruby/Rack remote:

T SQL : Filename with date string derivation with simple logic

DECLARE  @Filename varchar(100)  ,@FilenameSmall varchar(100)  ,@BatchNameType varchar(50) SET @BatchNameType = SPACE(0) SET @Filename = '05 May 2017_FP.xlsx' SET @Filename = '05 May 2017_FW.xlsx' SET @Filename = '05 May 2017_HA.xlsx' SET @Filename = '05 May 2017_WHO.xlsx' SET @Filename = 'GENERICS-20170531_152713.xlsx' SET @FilenameSmall = LOWER(@Filename) SET @BatchNameType += CASE WHEN PATINDEX('%_fw.xlsx', @FilenameSmall) > 0 THEN 'FINALWAY-' ELSE SPACE(0) END SET @BatchNameType += CASE WHEN PATINDEX('%_fp.xlsx', @FilenameSmall) > 0 THEN 'FINALWAY-' ELSE SPACE(0) END SET @BatchNameType += CASE WHEN PATINDEX('%_ha.xlsx', @FilenameSmall) > 0 THEN 'HOMEALONE-' ELSE SPACE(0) END SET @BatchNameType += CASE WHEN PATINDEX('%_who.xlsx', @FilenameSmall) > 0 THEN 'WHO-' ELSE SPACE(0) END IF( LEN(@BatchNameType) > 0)  BEGIN   SELECT [@Filename] = @Filename, [@FilenameSmall] =

BizTalk 2010 : Sample pipeline with filename extraction

public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg) {     VirtualStream inboundStream = new VirtualStream(pInMsg.BodyPart.GetOriginalDataStream());     VirtualStream outboundStream = new VirtualStream(VirtualStream.MemoryFlag.AutoOverFlowToDisk);     string sBatchName = Path.GetFileNameWithoutExtension(pInMsg.Context.Read("ReceivedFileName", " http://schemas.microsoft.com/BizTalk/2003/file-properties ").ToString());     AccountingEntriesExcelCreator ExcelCreator = new AccountingEntriesExcelCreator();     outboundStream = ExcelCreator.CreateExcel(inboundStream, sBatchName);     if (outboundStream != null)     {         if (outboundStream.Length > 0)         {             outboundStream.Position = 0;             pInMsg.BodyPart.Data = outboundStream;             pContext.ResourceTracker.AddResource(inboundStream);             pContext.ResourceTracker.AddResource(outboundStream);         }         else         {             pInMsg = null;    

BizTalk 2010 : Use Code Page = UTF-8 (65001) to preserved special characters (Unicode) when converting flatfile to xml form

T SQL : String manipulation and DataTime extraction from string

SET @XmlFilename = 'JCA_RB_SP-20170531_152713.txt' SELECT @IndexOfDash = CHARINDEX ( '-' , @XmlFilename ) SELECT @BatchName = LEFT( @XmlFilename , CHARINDEX ( '-' , @XmlFilename ) - 1 ) SELECT @BatchDateStringRaw = SUBSTRING ( @XmlFilename , CHARINDEX ( '-' , @XmlFilename ) + 1 , 15 ) SELECT @BatchDateString = SUBSTRING ( @BatchDateStringRaw , 1 , 4 ) + '-' + SUBSTRING ( @BatchDateStringRaw , 5 , 2 ) + '-' + SUBSTRING ( @BatchDateStringRaw , 7 , 2 ) + ' ' + SUBSTRING ( @BatchDateStringRaw , 10 , 2 ) + ':' + SUBSTRING ( @BatchDateStringRaw , 12 , 2 ) + ':' + SUBSTRING ( @BatchDateStringRaw , 14 , 2 ) SELECT [@XmlFilename] = @XmlFilename , [@IndexOfDash] = @IndexOfDash , [@BatchName] = @BatchName , [@BatchDateStringRaw] = @BatchDateStringRaw , [@BatchDateString] = @BatchDateString , CAST ( @BatchDateString

c# : Getting time in specific zone

> Reference: - https://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11).aspx [TestMethod] public void TestMethod1() {     // Reference : https://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11).asp     DateTime date1 = DateTime.UtcNow;     Console.WriteLine(date1);     DateTime MyTimeInWesternCentralAmerica = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(date1, "Central America Standard Time");     DateTime MyTimeInWesternEurope = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(date1, "W. Europe Standard Time");     DateTime MyTimeInManila = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(date1, "Singapore Standard Time");     DateTime MyTimeInNorway = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(date1, "Central European Standard Time");         Console.WriteLine("MyTimeInWesternEurope: {0}", MyTimeInWesternEurope);     Console.WriteLine("MyTimeInManila: {0}", MyTimeInManila);     Console.WriteLine("MyTimeInNorw

BizTalk - Whole message as parameter input of a MS Sql store procedure

// Extract Filename: varFilename =  MsgExcelFileRequest(FILE.ReceivedFileName); // Using variables to alter values: varXmlTemp = MsgExcelFileRequest.xml; varInnerText  = varXmlTemp.InnerXml; varInnerText =  varXmlTemp.InnerXml.Replace("<", "&#60;"); varInnerText = varInnerText.Replace(">", "&#62;"); // Create xml from the altered values: varXml.LoadXml(System.String.Format("<ns0:usp_Logic_Entries_Insert xmlns:ns0=\" http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo\ "><ns0:XmlFilename>{0}</ns0:XmlFilename><ns0:XmlData>{1}</ns0:XmlData></ns0:usp_Logic_Entries_Insert>", varFilename, varInnerText)); // Assigned created xml to the input message: MsgUspLogicEntriesInsertInput.xml = varXml; // Trace logs: System.Diagnostics.EventLog.WriteEntry("Logic - Step103_01 - SaveExcelFileRecordsToDb.odx", System.String.Format("Saving ExcelFile \"{0}\"."

Ubuntu 16.04 LTS - Installing GIMP

Add GIMP PPA: $ sudo add-apt-repository ppa:otto-kesselgulasch/gimp Update and Install: $ sudo apt-get update $ sudo apt-get install gimp Terminal: mccrazy@Lenovo-N22:~$ sudo add-apt-repository ppa:otto-kesselgulasch/gimp [sudo] password for mccrazy:  This PPA is for Ubuntu >=12.04 and Linux Mint >=13 Installing: open a terminal and type: sudo add-apt-repository ppa:otto-kesselgulasch/gimp sudo apt-get update sudo apt-get install gimp Removing: open a terminal and type: sudo apt-get install ppa-purge sudo ppa-purge ppa:otto-kesselgulasch/gimp Many thanks to David TschumperlĂ© for his masterpiece called G'MIC. http://gmic.eu/ Look for the gmic packages! We should not forget the Gimp crew! http://www.gimp.org/ And many, many thanks to http://siduction.org . They helped me on my first steps making the Gimp packages. I promise as long as I live this PPA will never die and the most recent packages will for ever be. ;-) Regards Otto Meier If you had a really problem: Skype: thorsten

Ubuntu 16.04 LTS - Install rar and unrar

Command: $ sudo apt-get update $ sudo apt-get install rar unrar Terminal: mccrazy@Lenovo-N22:~$ sudo apt-get update [sudo] password for mccrazy:  Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]      Hit:3 http://ppa.launchpad.net/canonical-chromium-builds/stage/ubuntu xenial InRelease Hit:4 http://us.archive.ubuntu.com/ubuntu xenial InRelease                      Get:5 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]     Hit:6 http://ppa.launchpad.net/nemh/systemback/ubuntu xenial InRelease          Hit:1 http://screenshots.getdeb.net xenial-getdeb InRelease                     Hit:7 http://ppa.launchpad.net/wine/wine-builds/ubuntu xenial InRelease         Ign:8 https://cli-assets.heroku.com/branches/stable/apt ./ InRelease            Get:9 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB] Hit:10 https://cli-assets.heroku.com/branches/stable/apt ./ Release Get:11 http://us.archive.ubuntu.com/ubuntu xenial-

T SQL : Replace First or Last occurance of a string to a new one

DECLARE @Name VarChar(MAX) DECLARE @StringToReplace VarChar(MAX) DECLARE @NewString VarChar(MAX) SET @StringToReplace = SPACE(1) SET @NewString = ',' SET @Name = 'MARIJUN P. MASCARINASO' SET @Name = 'MA. BEVELYN D DABILAU' SET @Name = 'SHEERWINE JOEL QUARTIRU' SELECT     [Name] = @Name     ,[First Instance of space] = STUFF(@Name, CHARINDEX(@StringToReplace, @Name), LEN(@StringToReplace), @NewString)     ,[Last Instance of space] = STUFF(@Name, LEN(@Name) - CHARINDEX(@StringToReplace, REVERSE(@Name)) + 1, LEN(@StringToReplace), @NewString)

Ubuntu 16.04 LT - Installing Chromium browser

> Type these commands about this PPA : $ sudo add-apt-repository ppa:canonical-chromium-builds/stage $ sudo apt-get update $ sudo apt-get install chromium-browser > Terminal: mccrazy@Lenovo-N22:~$ sudo add-apt-repository ppa:canonical-chromium-builds/stage [sudo] password for mccrazy:  Testing site just before upload to Ubuntu main. Things here are either broken and not ready to use, or landing in the distro anyway very soon. You shouldn't use this.  More info: https://launchpad.net/~canonical-chromium-builds/+archive/ubuntu/stage Press [ENTER] to continue or ctrl-c to cancel adding it gpg: keyring `/tmp/tmp6cfppy_r/secring.gpg' created gpg: keyring `/tmp/tmp6cfppy_r/pubring.gpg' created gpg: requesting key 5B393194 from hkp server keyserver.ubuntu.com gpg: /tmp/tmp6cfppy_r/trustdb.gpg: trustdb created gpg: key 5B393194: public key "Launchpad PPA for Canonical Chromium Build Team" imported gpg: Total number processed: 1 gpg:               imported: 1  (RSA

Fresh Ubuntu 16.04 LTS - Installing ruby developer tools

> Update ubunut software thru terminal $ sudo apt-get update > Install git $ sudo apt install git > Set user config $ git config --global user.email " you@example.com " $ git config --global user.name "Your Name" * Install Ruby Language thru RVM > Install curl $ sudo apt-get install curl > Install RVM $ gpg2 --keyserver hkp:// keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 $ \curl -L https://get.rvm.io | bash -s stable --ruby > Update RVM to the latest version $ rvm get stable --autolibs=enable > Install specific ruby version for me is ruby-2.2.6 for my alter-ego developer that uses Windows 10 - rvm install 2.2.6 > Integrating RVM to Ubuntu 16.04 terminal - Go to https://rvm.io/integration/gnome-terminal > Setup default ruby version to use $ rvm --default use ruby-2.2.6 > Creating a RVM file $ cd projects\ruby\test-project $ rvm use --create --rvmrc 2.2.6@test-project

Push ruby sinatra project to heroku with rake db:migration

>Terminal: mccrazy@Lenovo-N22:~$ cd Documents/crazynote mccrazy@Lenovo-N22:~/Documents/proyekto/r226$ rake db:create_migration NAME=create_doctors db/migrate/20170506042338_create_doctors.rb mccrazy@Lenovo-N22:~/Documents/proyekto/r226$ rake db:migrate == 20170506042338 CreateDoctors: migrating ==================================== -- adapter_name()    -> 0.0000s -- adapter_name()    -> 0.0000s -- create_table(:doctors, {:id=>:integer})    -> 0.0034s == 20170506042338 CreateDoctors: migrated (0.0041s) =========================== mccrazy@Lenovo-N22:~/Documents/proyekto/r226$ git add . mccrazy@Lenovo-N22:~/Documents/proyekto/r226$ git commit -am "initial project up to db:migrate" [master (root-commit) 3e86239] initial project up to db:migrate  9 files changed, 220 insertions(+)  create mode 100644 .rvmrc  create mode 100644 Gemfile  create mode 100644 Gemfile.lock  create mode 100644 Rakefile  create mode 100644 config/database-config.rb  create mode 100644 db/Dev

Testing RVM setup with Sinatra sample app r226 (with gem install pg problem and solution)

> Terminal: mccrazy@Lenovo-N22:~$ cd Documents/ mccrazy@Lenovo-N22:~/Documents$ cd proyekto/ mccrazy@Lenovo-N22:~/Documents/proyekto$ ls r226 mccrazy@Lenovo-N22:~/Documents/proyekto$ cd r226/ You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers, you can switch to '.ruby-version' using 'rvm rvmrc to ruby-version' or ignore this warning with 'rvm rvmrc warning ignore /home/mccrazy/Documents/proyekto/r226/.rvmrc', '.rvmrc' will continue to be the default project file in RVM 1 and RVM 2, to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'. ******************************************************************************** * NOTICE                                                                       * ******************************************************************************** * RVM has encountered a new or modified .rvmrc file in the current directory,  * *