Skip to content

Instantly share code, notes, and snippets.

View marta-krzyk-dev's full-sized avatar
Focusing

Marta Krzyk marta-krzyk-dev

Focusing
View GitHub Profile
@marta-krzyk-dev
marta-krzyk-dev / FindDuplicates.cs
Last active October 20, 2019 21:04
Find duplicates in int array with O(n) using Hashtable
//https://leetcode.com/problems/find-all-duplicates-in-an-array/
using System;
using System.Collections;
using System.Collections.Generic;
public class Solution {
public IList<int> FindDuplicates(int[] nums) {
if (nums is null)
@marta-krzyk-dev
marta-krzyk-dev / reverse_linked_list_iterative.cpp
Last active October 20, 2019 18:44
Reverse a linked list
// Solved problem: https://leetcode.com/problems/reverse-linked-list/
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
@marta-krzyk-dev
marta-krzyk-dev / debugApp.js
Last active May 1, 2019 10:16
Debugging in Node JS with debug
/*
* Simple debug example in Node JS :)
*
*/
// 1. Install debug in the folder where your app lives
// npm install debug --save
// 2. Copy and paste this line to your js file to your dependencies, then use debug('My comments'); in your code
// var debug = require('debug')('my_debug_name');
@marta-krzyk-dev
marta-krzyk-dev / ReadDLLVersion.cs
Created April 29, 2019 08:59
Read DLL version
using System;
using System.Diagnostics;
namespace ReadDLLVersion
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(FileVersionInfo.GetVersionInfo(@"C:\SomeDLL.dll").FileVersion);
@marta-krzyk-dev
marta-krzyk-dev / Promises.js
Last active April 27, 2019 20:48
Promises all and race in JS
//From: https://www.youtube.com/watch?v=s6SH72uAn3Q
{ //Declare scope
let cleanRoom = function(message) {
return new Promise(function(resolve, reject) {
resolve(message + ' I cleaned the room!');
});
};
@marta-krzyk-dev
marta-krzyk-dev / SimplestPromise.js
Last active July 3, 2020 03:44
Simplest Promise in JS
//Based on: https://www.youtube.com/watch?v=s6SH72uAn3Q
let promiseToCleanRoom = new Promise(function(resolve, reject) {
//cleaning the room
let isClean = false;
if (isClean)
resolve('Clean');
else
reject('Dirty');
@marta-krzyk-dev
marta-krzyk-dev / nodeJsRequest.js
Created April 21, 2019 19:32
Node JS handler
_some_handler.post = function(data, callback){
var reqDetails = {}; //Some details
var reqData = {}; //Some data
var req = https.request(reqDetails, function(res){
if(200 == res.statusCode) {
callback(200, {'Message' : 'Success'});
} else {
@marta-krzyk-dev
marta-krzyk-dev / UpgradeFrameworkInProjects.cs
Last active April 17, 2019 21:02
Upgrade .NET Framework version in all projects at once
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace UpgradeFrameworkInProjects
{
class Program
{
private const string exitCode = "0";
@marta-krzyk-dev
marta-krzyk-dev / RemoveFolders.cs
Last active April 5, 2019 08:51
Remove all subfolders with given name within a folder
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace RemoveFolders
{
class Program
{
private const string exitCode = "0";
@marta-krzyk-dev
marta-krzyk-dev / DuplicatedJsonProperties.cs
Last active March 16, 2019 09:42
How to detect/ignore duplicated properties in JSON
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace DuplicatedJsonProperties
{
class DuplicatedJsonProperties
{
private const string data =
@"{