Skip to content

Instantly share code, notes, and snippets.

@harmoniemand
harmoniemand / PowerShell-Snippet.ps1
Last active March 12, 2018 14:33
Powershell count lines of code
# Count Lines
(dir -include *.cs -recurse | select-string "^(\s*)//" -notMatch | select-string "^(\s*)$" -notMatch).Count
# Search String
$search = "focusSearchInputfield";
Get-ChildItem -Recurse | Where { ! $_.PSIsContainer } | Select-String $search | select LineNumber, Path, Filename |Format-List
(dir -include * -recurse | select-string "_recurse")
# Count all Files
/**
* Update a json node of an object
* Could create needed nodes, if path not exists
* @param {object} obj - the object that should be updated
* @param {string} path - the path of the node that should be updated
* @param value - the new value for the node
* @param {bool} createNodes - if true, the missing nodes will be created - if false, a error will be thrown if any of the nodes in the path is missing
*/
var updateJson = function (obj, path, value, createNodes) {
if (obj === undefined) { obj = {}; }
angular.module('myApp')
.directive('dateValidation', [function () {
'use strict';
return {
restrict: 'EA',
replace: true,
require: 'ngModel',
link: function (scope, element, attrs, ngModel) {
@harmoniemand
harmoniemand / gist:7b9c7e77d5f3800b3068fd4ba49fb476
Created April 27, 2017 15:23
Create SHA256 Hash in IE and Chrome (others not tested)
function convertArrayBufferToHexaDecimal(buffer) {
var data_view = new DataView(buffer);
var iii, len, hex = "", c;
for ((iii = 0), (len = data_view.byteLength); iii < len; iii += 1) {
c = data_view.getUint8(iii).toString(16);
if (c.length < 2) c = "0" + c;
hex += c;
}
.modal-button {
background: rgb(250,250,250);
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
margin: 6px 8px;
padding: 0;

Keybase proof

I hereby claim:

  • I am harmoniemand on github.
  • I am harmoniemand (https://keybase.io/harmoniemand) on keybase.
  • I have a public key whose fingerprint is 6E22 29B9 5E5A 153C 5397 BF77 1916 1109 E88F 3339

To claim this, I am signing this object:

$machinename = "machinename"
$users = @("user1")
$users | ForEach-Object {
$user = $_
$shares = Get-WmiObject -class Win32_Share -computer $machinename
$shares | ForEach-Object {
using System;
using System.Linq;
using System.Linq.Expressions;
public static class QuerySearchExtensions
{
private static Expression<Func<T, bool>> BuildSearchExpression<T>(string search)
{
Expression baseExpression = null; // Expression.Constant(true);
String.prototype.fizz = function (i) {
return this + (i % 3 == 0 ? 'fizz': '');
};
String.prototype.buzz = function (i) {
return this + (i % 5 == 0 ? 'buzz': '');
};
for (var i = 0; i < 20; i++) {
console.log(i + " :".fizz(i).buzz(i));
@harmoniemand
harmoniemand / GetOffset.ts
Last active June 26, 2018 15:49
Calculate Offset in HTML while using offset and scrolling
/*
License: MIT (https://opensource.org/licenses/MIT)
*/
GetOffset(from: any, to: any): PositionModel {
let pos = new PositionModel();
var parent = from.offsetParent;
pos.X = from.offsetTop;
pos.Y = from.offsetLeft;