Skip to content

Instantly share code, notes, and snippets.

View stej's full-sized avatar

Eska látor! stej

View GitHub Profile
if (type == SType.Noc && method == SMethod.Sequential) return RE.Take(null, value);
if (type == SType.Percentage && method == SMethod.Sequential) return RE.TakePart(null, value);
if (type == SType.Noc && method == SMethod.Random) return RE.Random(null, value, (int)DateTime.Now.Ticks);
if (type == SType.Percentage && method == SMethod.Random) return RE.RandomPart(null, value, (int)DateTime.Now.Ticks);
if (type == SType.Noc && method == SMethod.Sequential) return RE.Take(null, value);
if (type == SType.Percentage && method == SMethod.Sequential) return RE.TakePart(null, value);
if (type == SType.Noc && method == SMethod.Random) return RE.Random(null, value, (int)DateTime.Now.Ticks);
if (type == SType.Percentage && method == SMethod.Random) return RE.RandomPart(null, value, (int)DateTime.Now.Ticks);
if ( $psc -eq $null ) { $psc = $pscmdlet } ; if (-not $PSBoundParameters.psc) {$PSBoundParameters.add("psc",$psc)}
if ( $image.count -gt 1 ) { [Void]$PSBoundParameters.Remove("Image") ; $image | ForEach-object {Save-Image -Image $_ @PSBoundParameters } ; return}
if ($filename -is [scriptblock]) {$fname = Invoke-Expression $(".{$filename}") }
else {$fname = $filename }
if (test-path $fname) {if ($noclobber) {write-warning "$fName exists and WILL NOT be overwritten"; if ($passthru) {$image} ; Return }
elseIF ($pscmdlet.shouldProcess($FName,"Delete file")) {Remove-Item -Path $fname -Force -Confirm:$false }
else {Return}
}
if ((Test-Path -Path $Fname -IsValid) -and ($pscmdlet.shouldProcess($FName,"Write image"))) { $image.SaveFile($FName) }
if ($passthru) {$image}
@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. :)
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
}
$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 $_ }
<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: '......'
}
@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) :)
@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 / 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 / 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