Skip to content

Instantly share code, notes, and snippets.

View cezarypiatek's full-sized avatar
🎹
Coding

Cezary Piątek cezarypiatek

🎹
Coding
View GitHub Profile
function Search-ItemsRecursive{
[CmdletBinding()]
param($projectItems, $filter, [switch]$recurse=$false)
foreach ($item in $projectItems) {
if($(. $filter $item))
{
$item
}else{
if(($item.ProjectItems -ne $null) -and $recurse){
Search-ItemsRecursive -projectItems $item.ProjectItems -filter $filter -recurse:$recurse
@cezarypiatek
cezarypiatek / DuplicatedIdAttribute.js
Last active February 24, 2016 16:56
Find duplicated id attributes
var ids = {};
var elementsWithId = document.querySelectorAll("[id]");
Array.prototype.forEach.call(elementsWithId, function(el){
var id = el.id;
if(ids[id]){
ids[id]++;
}else{
ids[id]=1;
}
});
function getNewTabId(){
return Math.ceil(Math.random()*1000000000).toString();
}
function deactivateTabSession(){
}
var tabIdKey ="__TAB_ID__";
if(sessionStorage.getItem(tabIdKey) == null)
{
let bigFactorial n=
let rec loop x acc =
match x with
| x when x = 0I || x= 1I -> acc
| _ -> loop (x-1I) (acc*(x-1I))
loop n 1I
[<EntryPoint>]
let main argv =
function Get-KeyPropertyValue($key, $property)
{
if($key.Property -contains $property)
{
Get-ItemProperty $key.PSPath -name $property | select -expand $property
}
}
function Get-VersionName($key)
{
function Create-Parameters{
param([scriptblock]$Params)
$runtimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
$parameters = & $Params
foreach($parameter in $parameters)
{
$runtimeParameterDictionary.Add($parameter.Name, $parameter)
}
$runtimeParameterDictionary
}
@cezarypiatek
cezarypiatek / Forms.js
Created July 16, 2017 13:00
Sample react form
import React from 'react';
import ReactDOM from 'react-dom';
class Editor extends React.Component {
constructor(props) {
super(props);
this.state = { value: props.value };
this.handleChange = this.handleChange.bind(this);
}
handleChange(event) {
@cezarypiatek
cezarypiatek / xx.ps1
Created August 29, 2017 13:47
Remove WebActivatorEx from all projects
function Uninstall-WebActivatorEx{
Get-Project -All |% {Uninstall-Package WebActivatorEx -Force -ProjectName $_.ProjectName}
}
@cezarypiatek
cezarypiatek / ProducerConsumer.cs
Created August 30, 2017 19:44
Producer with single thread consumer
public class ProducerConsumer<T>
{
readonly BlockingCollection<T> dataToProcess = new BlockingCollection<T>();
private readonly Thread workerThread;
public ProducerConsumer(Action<T> action)
{
workerThread = new Thread(() =>
{
foreach (var data in dataToProcess.GetConsumingEnumerable())
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\15.0\OneNote\Options\Other]
"ScreenClippingShortcutKey"=dword:00000059