Skip to content

Instantly share code, notes, and snippets.

@bigarabuza
bigarabuza / SAPGUIScripting.bas
Created March 5, 2019 15:52
Working with SAPGUI Scripting API
'Activate SAP GUI Scripting API in references library.
'If unavailable in reference library, locate file at C:\program files (x86)\sap\frontend\sapgui\sapfewse.ocx
'Refer to SAP GUI Scripting API Documentation:
'https://wiki.scn.sap.com/wiki/display/ATopics/SAP+GUI+Scripting
Sub SAPGUIScripting()
Public objGui As GuiApplication
Public objConn As GuiConnection
Public objSess As GuiSession
@marekyggdrasil
marekyggdrasil / README.md
Created February 4, 2019 09:19
How to fix Ruby TLS support

OSX Sierra version 10.12.6

if you are getting error like

ERROR:  Could not find a valid gem '<some package name>' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect retur

test your TLS v1.2 support

@ij96
ij96 / rename_mp3.sh
Last active November 6, 2022 00:26
Rename MP3 files based on metadata
# rename MP3 files based on metadata (named artist and title)
# copy this script in the same directory as the MP3 files and run
# renamed MP3 are copied to renamed/
mkdir renamed;
for f in *.mp3; do
TITLE=`ffmpeg -i "$f" 2>&1 | grep title | sed "s/ \+title \+: //"`;
ARTIST=`ffmpeg -i "$f" 2>&1 | grep artist | sed "s/ \+artist \+: //"`;
TRACK=`ffmpeg -i "$f" 2>&1 | grep track | sed "s/ \+track \+: //"`;
ZERO_TRACK=$(printf %02d ${TRACK}); # zero-padded track number
@HiroNakamura
HiroNakamura / copia.vba
Last active December 8, 2022 22:16
VBA en ejemplos no. 6.
Sub Prueba()
'Visto en: https://es.stackoverflow.com/questions/183891/error-de-subindice-fuera-de-intervalo-en-excel-macros-vda
Dim ss As Workbook
Dim archivo As Workbook
Dim nombreArchivo As Variant
Set ss = ActiveWorkbook
nombreArchivo = Application.GetOpenFilename(FileFilter:="Excel Files,*.xl*;*.xm*")
@diegocasmo
diegocasmo / karatsuba.rb
Last active July 15, 2020 19:09
An implementation of Karatsuba multiplication algorithm in Ruby
class Karatsuba
# Multiply two numbers using the Karatsuba
# multiplication algorithm
def multiply(num_1, num_2)
if num_1 < 10 || num_2 < 10
return num_1 * num_2
end
m_2 = [num_1.to_s.length, num_2.to_s.length].max/2
# Split the digit sequences about the middle
high_1, low_1 = num_1.divmod(10**m_2)
@komasaru
komasaru / prime_number_1.rb
Last active January 18, 2022 23:21
Ruby script to check a prime number.
#! /usr/local/bin/ruby
# coding: utf-8
# --------------------------------------
# Check a prime number
# --------------------------------------
def is_prime(n)
res = (2..Math.sqrt(n)).any? { |i| n % i == 0 }
puts "#{n}: #{res || n == 1 ? '-----' : "PRIME"}"
end
@funkatron
funkatron / get_process_ports.bash
Created September 1, 2014 16:56
Find processes and ports they are using in OS X
lsof -Pnl +M -i4
@3leftturns
3leftturns / SQL pivot query
Created May 28, 2014 01:58
SQL collapse columns to rows. Got a crappy database that has sales data in columns by city tallied up in each column? This will collapse the column into 4 columns: saleDate, saleAmount, city, saleQuantity. See the alternate file for a visual.
SELECT salesTable.saleDate, salesTable.saleAmount, 'Reno' AS city, salesTable.reno AS saleQuantity
FROM salesTable
WHERE salesTable.reno > 0
UNION
SELECT salesTable.saleDate, salesTable.saleAmount, 'Salt Lake City' AS city, salesTable.saltLakeCity AS saleQuantity
FROM salesTable
WHERE salesTable.saltLakeCity > 0
@ansonhoyt
ansonhoyt / excelToJson.rb
Created March 1, 2012 03:03
Convert Excel of Arbitrary Tasks to JSON
#!/usr/bin/env ruby
# Reads an Excel and writes as JSON
# - Assumes header row containing field names, first sheet is read
# - Keeps null values
#
# TODO:
# - accept filename and read based on extension (xlsx, xls, csv).
# - output actual JSON.
# - clean up.