Skip to content

Instantly share code, notes, and snippets.

View stej's full-sized avatar

Eska látor! stej

View GitHub Profile
This works:
$a = ''
$b = @('')
( $a -eq $b ) -ne ( $b -eq $a )
now, the ( $a -eq $b ) is true, because $b is converted to string -> all the array members are converted to string and then concatenated by $ofs ->
it equals ('' -eq '') which is true
then ( $b -eq $a ) means (@('') -eq '') - this returns all items from array (left operand) that are equal to right operand -> it's array of ''
now array of '' is converted to boolean value
@stej
stej / gist:2988139
Created June 25, 2012 11:46
trivia
$game = New-Object psObject -Property @{
players = @()
places = 0,0,0,0,0,0
purses = 0,0,0,0,0,0
inPenaltyBox = [bool[]](0,0,0,0,0,0)
popQuestions = @()
scienceQuestions = @()
@stej
stej / psaint.jaykul.ps1
Created January 13, 2012 15:41
PSaint test file
# how should I setup $filePath so that the assert (or act) block can see it?
$root = split-path $MyInvocation.MyCommand.Path
. "$root\..\..\..\..\..\Lib\PSaint\init.ps1"
ipmo "$root\..\InstallerPackage.psm1" -DisableNameChecking -Force
$FilePath = "$root\FileList.nsi"
setup {
# or here
@stej
stej / psaint.jaykul.ps1
Created January 13, 2012 15:38
PSaint test file
# how should I setup $filePath so that the assert (or act) block can see it?
$root = split-path $MyInvocation.MyCommand.Path
. "$root\..\..\..\..\..\Lib\PSaint\init.ps1"
ipmo "$root\..\InstallerPackage.psm1" -DisableNameChecking -Force
$FilePath = "$root\FileList.nsi"
setup {
# or here
@stej
stej / gist:1232891
Created September 21, 2011 18:28
clip
## samples:
#1. copy this gist to clipboard (via CTRL+C); the following script will filter only rows that contain 'function' a copy them back to clipboard
(clip -AsLines) -match 'deleted' | clip
# I use it quite often when looking for some info in log files
#2. Quite useful when working with conversion functions. Let's define conversion to base64.
function ToBase64($str) {
[system.convert]::ToBase64String([system.text.encoding]::utf8.getBytes($str))
}
# then just copy a text to clipboard and call
@stej
stej / gist:908513
Created April 7, 2011 19:33
question about PowerShell doc
PowerShell guys,
I answered a question on SO with this code:
Get-ChildItem directory |
Rename-Item -NewName { $_.Name -replace '^filename_+','' -replace '_+',' ' }
Zdan asked me where in the documentation could be found that -NewName accepts scriptblock as a parameter.
Is there anything in the doc about that?
Thx for your answers (here, on Twitter, or even on SO) :)
<a href="#" class="delete" title="Delete - Deletes the item from the system. This will cancel all bla bla bla."
onclick="
var checked = true;
var checkUrl = '/cm/Product/294912/CheckDelete';
var data = {
__RequestVerificationToken : 'fI0pfQC+Ma7GEnqio5q1......',
id: 819200,
returnUrl: '......'
}
$r = [regex]'contentBox=(?<url>http://www.fatrafloor.cz/uploads/thumbnails/thumbnail-800600[^"]*)"'
$d = (new-object Net.WebClient).DownloadString('http://www.fatrafloor.cz/cz/thermofix/kolekce-drevo/')
$r.Matches($d) |
% { $_.Groups["url"].Value } |
% { Start-Process $_ }
function switchtest {
param([switch]$myswitch)
if ($myswitch) { 'switch is on' }
if (!$myswitch) { 'switch if off' }
#same as above
#if ($myswitch) { 'switch is on' } else { 'switch if off' }
write-host switch value is ([bool]$myswitch) and $myswitch
}
@stej
stej / gist:728536
Created December 4, 2010 22:14
Java, C#, closurky
alenkacz konečně někdo, kdo mi vysvětlil, proč bych měla aspoň uvažovat o Ruby nebo Pythonu http://goo.gl/EzRth via @denisalorencova
AugiCZ @alenkacz Btw. všechny ty filtrace a další věci okolo FCF jdou stejně elegantně (spíš ještě líp - např. překlad do SQL) dělat v C# - LINQ :)
alenkacz @AugiCZ ze je C# bestovni vim uz dlouho! ale napsal to pekne :) to ze ve srovnani s javou by asi vyhralo vse (az na perl a phpko) tusim :)
VykrikyDoTmy @alenkacz C#? Myslíš tu odpornost navrhovanou způsobem "každý týden alespoň jedna nová syntaktická konstrukce"? ;)
alesroubicek @VykrikyDoTmy @alenkacz lepší než, v týhle dekádě přidáme closure, ale nevíme jak na to. Tak snad v příští... ;)
VykrikyDoTmy @alesroubicek @alenkacz "hlavně to neuspěchat, abychom to nepos... jak ty generiky před 10 lety". Opačný extrém,ale taky nic moc.
alesroubicek @VykrikyDoTmy @alenkacz Generyka v .net fungujou, v Javě je to jen trapnej pokus... Ano, měli ještě dekádu počkat. :)