Skip to content

Instantly share code, notes, and snippets.

@omelhus
omelhus / create-voucher.graphql
Created May 24, 2022 07:47
Example creating a voucher
mutation batchCreate {
batch_create(
batch: {
valueDate: 20220101
voucherSeriesNo: 2
voucherLines: [
{
debitAccountNo: 1920
amountInCurrency: 250
text: "demo transaction"
@omelhus
omelhus / Visma.net Customers.js
Last active May 30, 2018 13:40
Google Script to import customers from Visma.net to Google Spreadsheet
function fetchCustomers() {
var url = 'https://integration.visma.net/API/controller/api/v1/customer',
token = '', // You need to set this
companyId = '', // And this...
sheetname = 'Kunder',
options = {
'method': "GET",
'muteHttpExceptions': true,
'headers': {
'Authorization': 'Bearer ' + token,
@omelhus
omelhus / GlobalServerConnection.cs
Last active June 2, 2023 08:46
A Visma Global VAF connection handler
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Cryptography;
using System.Text;
using RG_SRVLib.Interop;
using Serilog;

Keybase proof

I hereby claim:

  • I am omelhus on github.
  • I am omelhus (https://keybase.io/omelhus) on keybase.
  • I have a public key whose fingerprint is 97F3 898B C29D F54F D3D4 3A8F 7779 8E09 F4AC BB08

To claim this, I am signing this object:

public class GlobalServerConnection {
private static readonly LogWriter Log = HostLogger.Get(typeof (GlobalServerConnection));
private IBisComServer _globalServer;
public GlobalServerConnection(string globalClient = "",
string globalUser = "",
string globalPassword = "",
string globalBapi = "") {
GlobalClient = globalClient;
GlobalUser = globalUser;
@omelhus
omelhus / gist:8472290
Created January 17, 2014 11:59
Get rid of if statements for fields in Global AddOn
private readonly Dictionary<int, Action<object, List<int>>> _actions =
new Dictionary<int, Action<object, List<int>>>
{
{
(int) Article_Properties.ART_PLUNo,
(component, changedIds) => {
var articleComponent = (ArticleServerComponent) component;
articleComponent.bcSetValueFromStr((int)Article_Properties.ART_EANNo, articleComponent.bcGetStr((int)Article_Properties.ART_PLUNo));
changedIds.Add((int)Article_Properties.ART_EANNo);
}
@omelhus
omelhus / searchSentence.js
Last active January 3, 2016 05:48
Search a sentence for keywords devided by space
var searchSentence = function(needle, haystack){
var split = needle.toUpperCase().split(' '),
haystack = haystack.toUpperCase(),
pow = 0;
for(var key in split)
if(haystack.indexOf(split[key]) > -1)
pow = pow | Math.pow(2, key);
return pow === Math.pow(2, split.length) - 1;
}
@omelhus
omelhus / postalCode.js
Last active December 22, 2015 00:09
Gist for fetching city for all fields when updating zipcode.
var handleZipCodeUp = function() {
var element = $(this),
value = element.val();
if (value.length === 4 || value.length === 5) {
var elementName = element.attr("name");
var destinationName = elementName.replace("zipcode¤", "city¤");
var destination = $("input[name='" + destinationName + "']");
if (destination.length > 0) {
$.getJSON('//fraktguide.bring.no/fraktguide/api/postalCode.json?pnr=' + value + '&callback=?', function (data) {
@omelhus
omelhus / web.config
Created May 11, 2012 16:04
Web.config maxRequestLength
<httpRuntime shutdownTimeout="864000" waitChangeNotification="864000" maxWaitChangeNotification="864000" executionTimeout="600" maxRequestLength="512000" minFreeThreads="8" minLocalRequestFreeThreads="4" requestValidationMode="2.0" />
@omelhus
omelhus / SearchAutocomplete.aspx
Created April 19, 2012 14:49
Add EANNo to SearchAutocomplete.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SearchAutocomplete.aspx.cs" Inherits="Zpider.eShop.Web.eShop.Pages.Action.SearchAutocomplete" %>
<%@ Import Namespace="Zpider.eShop.Web.Base"%>
<%@ OutputCache VaryByParam="q;limit;fld;gid" Duration="43200" NoStore="true" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
try
{