Skip to content

Instantly share code, notes, and snippets.

View countnazgul's full-sized avatar

Stefan Stoichev countnazgul

View GitHub Profile
@countnazgul
countnazgul / engine_ref__all_engine_error_codes.js
Last active October 10, 2023 13:46 — forked from theredpea/engine_ref__all_engine_error_codes.js
[Engine error codes] #qlik #qliksense #engine #enigma.js
var engine_js = {
"ErrorCode.-128": "Internal engine error",
"ErrorCode.-1": "Unknown error",
"ErrorCode.0": "Unknown error",
"ErrorCode.1": "Some data is not correctly specified.",
"ErrorCode.2": "The resource could not be found.",
"ErrorCode.3": "Resource already exists.",
"ErrorCode.4": "Invalid path",
"ErrorCode.5": "Access is denied",
"ErrorCode.6": "The system is out of memory.",
@countnazgul
countnazgul / method-decorator-example.ts
Last active April 17, 2022 18:38
[Method decorator] Example how to create method decorator #typescript
// Define the decorator
// if the method parameter is not passed
// then the decorator will return the result of someOtherFunction()
// as value for the parameter
export const decoratorFunction = (index: number) => (
target: any,
key: string,
propDesc: PropertyDescriptor
) => {
let originalFunction: Function = propDesc.value;
@countnazgul
countnazgul / extract-master-items.js
Last active April 17, 2022 06:30
[List Qlik Sense master items] List all master dimensions and measures #qlik #qliksense #enigma
const enigma = require('enigma.js');
const WebSocket = require('ws');
const schema = require('enigma.js/schemas/12.170.2.json');
let qlik = {
session: {},
global: {},
doc: {},
details: {
host: 'localhost',
@countnazgul
countnazgul / Create Master Item Visualisation.js
Last active April 17, 2022 18:31
[Create master visualisation item] #qlik #qliksense #enigma
// The idea is to create a master item visualisation from
// an existing dashboard object
// If the requirement is to create a master item from json (exported from another app)
// the first step is to create the source object first and the use it
// to create the master item and then drop the source (if needed)
// Create empty object with type of masteritem
let myMasterItem = await qDoc.createObject({
"qInfo": {
"qId": "my-id",
@countnazgul
countnazgul / qlikview-c-create-task.cs
Last active April 17, 2022 18:52
[Create reload task] Create new reload task with QlikView management API #qlik #qlikview #csharp
private void CreateTask(string user)
{
QMSClient Client;
string QMS = "http://localhost:4799/QMS/Service";
Client = new QMSClient("BasicHttpBinding_IQMS", QMS);
string key = Client.GetTimeLimitedServiceKey();
ServiceKeyClientMessageInspector.ServiceKey = key;
Client.ClearQVSCache(QVSCacheObjects.UserDocumentList);
@countnazgul
countnazgul / asp.net-active-directory-group-details.cs
Last active April 17, 2022 18:53
[Get details for Active Directory group] #csharp #asp.net
// add reference to System.DirectoryServices.AccountManagement
// using System.DirectoryServices.AccountManagement;
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, "domain\\groupname");
var users = group.GetMembers();
if (group != null)
{
@countnazgul
countnazgul / qv-no-header-to-csv.qvs
Last active April 17, 2022 18:54
[Save table without headers] #qlik #qlikview #qliksense #script
// Save QV table without the headers (or at least without the original headers)
set vNH_SourceTable = Data; // which QV table need to be exported
set vNH_OutputFile = C:\Users\adm-s7729841\Desktop\Headerless.csv; //the path to the result csv/txt file
Qualify *;
Headers:
First 1
Load
*
Resident
@countnazgul
countnazgul / generate-previous-months
Last active April 17, 2022 06:36
[Generate all previous months] For each month in the given months list, generate all previous months #qlik #qliksense #qlikview #script
Raw:
Load * Inline [
Month
2014-01
2014-02
2014-03
2014-04
2014-05
];
@countnazgul
countnazgul / qv-months-diff-count
Last active April 17, 2022 18:32
[Calculate number of months diff between dates] #qlik #qlikview #qliksense #script
= ((year(vDate2)*12)+month(vDate2)) - (((year(vDate1)*12)+month(vDate1)))
@countnazgul
countnazgul / mongodb-batch-update.js
Last active April 17, 2022 18:36
[Batch update records] #mongo
// OrderId = [1,2,3,4,5,6]
BulkUpdate(OrderId, function() {
console.log('done');
});
function BulkUpdate(OrderId, callback) {
Model.update(
{ orderid : { $in: OrderId } },
{ $set: { status: 'complete' } },