Skip to content

Instantly share code, notes, and snippets.

View countnazgul's full-sized avatar

Stefan Stoichev countnazgul

View GitHub Profile
@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 / Loop_through_all_files_in_current_folder.bat
Last active April 17, 2022 18:51
[Loop through all files in current folder] #terminal
for /r %%i in (*.txt) do echo %%i
@countnazgul
countnazgul / MS-DOS delete folder silently.bat
Last active April 17, 2022 18:51
[MS-DOS delete folder silently (without Y/N prompt)] #terminal
rmdir /S /Q c:\temp
@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 / Update All.js
Last active April 17, 2022 18:53
[Update all rows in MongoDB] #mongo
Model.update({ }, { $set: { status: 'active' }}, { multi: true }, function(err, numAffected) {
console.log(numAffected);
});
@countnazgul
countnazgul / Mongoose filter fields.js
Last active April 17, 2022 18:54
[Filter specific fields in query] #mongo #mongoose
User.find({}, 'first last', function (err, usr) {
//Got the result, saved a few bytes of code
});
@countnazgul
countnazgul / Limit number of MongoDB query.js
Last active April 17, 2022 18:54
[Limit number of returned docs] Limit number of MongoDB query #mongo #mongoose
Posts
.find({})
.sort({})
.limit(5)
.exec(function(err, posts) {
console.log(posts)
});
@countnazgul
countnazgul / psftp_automate_sftp_server.bat
Last active April 17, 2022 18:54
[psftp run commands from file] #psftp #ftp #terminal
psftp username@sftp.server.com -pw password -b commands.txt
commands.txt contain all the psft commands that need to be executed like:
lcd c:\test
mget *.gz
@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