This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: Rudde | |
* Date: 01.04.2016 | |
* Time: 00.25 | |
*/ | |
function firstDayofFirstWeekinCurrentMonth($date = NULL) { | |
$date = is_null ($date) ? new DateTime('first day of this month') : $date->modify('first day of this month'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
hash pv | |
if [ $? -ne 0 ]; then | |
echo "ERROR: Command pv is not available but required, please run: sudo apt-get install pv" | |
exit 1 | |
fi | |
WORKDIR=$(pwd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function padnum { | |
NUM=$1 | |
if [ $(echo "$NUM < 10" | bc) -ne 0 ] | |
then | |
echo 0$NUM | |
else | |
echo $NUM | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Written by Barand from phpfreaks.com */ | |
function numSuffix($n) { | |
$str = "$n"; | |
$t = $n > 9 ? substr($str,-2,1) : 0; | |
$u = substr($str,-1); | |
if ($t==1) return $str . 'th'; | |
else switch ($u) { | |
case 1: return $str . 'st'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Filtering a array by its keys using a callback. | |
* | |
* @param $array array The array to filter | |
* @param $callback Callback The filter callback, that will get the key as first argument. | |
* | |
* @return array The remaining key => value combinations from $array. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace ConsoleApp1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
while (true) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Format-FileSize() { | |
Param ([long]$size) | |
If ($size -gt 1TB) {[string]::Format("{0:0.00} TB", $size / 1TB)} | |
ElseIf ($size -gt 1GB) {[string]::Format("{0:0.00} GB", $size / 1GB)} | |
ElseIf ($size -gt 1MB) {[string]::Format("{0:0.00} MB", $size / 1MB)} | |
ElseIf ($size -gt 1KB) {[string]::Format("{0:0.00} kB", $size / 1KB)} | |
ElseIf ($size -gt 0) {[string]::Format("{0:0.00} B", $size)} | |
Else {"0 byte"} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Format-Time() { | |
Param ([int]$ms) | |
If ($ms -gt 3600000) {[string]::Format("{0:0.00} hours", $ms / 3600000)} | |
ElseIf ($ms -gt 60000) {[string]::Format("{0:0.00} minutes", $ms / 60000)} | |
ElseIf ($ms -gt 1000) {[string]::Format("{0:0.00} seconds", $ms / 1000)} | |
ElseIf ($ms -gt 0) {[string]::Format("{0:0.00} milliseconds", $ms)} | |
Else {"0 milliseconds"} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConsoleSpinner : IDisposable | |
{ | |
private const string Sequence = @"/-\|"; | |
private int counter = 0; | |
private readonly int? left; | |
private readonly int? top; | |
private readonly int delay; | |
private bool active; | |
private readonly Thread thread; | |
private readonly ConsoleColor? color; |
OlderNewer