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
$today = time(); | |
// days start at 0 (Sunday) to 6 (Saturday) | |
$messages = array( | |
0 => "Sorry we are closed", | |
1 => "We are open between <strong>8am - 6.30pm</strong>", | |
2 => "We are open between <strong>8am - 8pm</strong>", | |
3 => "We are open between <strong>8am - 6.30pm</strong>", | |
4 => "We are open between <strong>8am - 6.30pm</strong>", | |
5 => "We are open between <strong>8am - 6.30pm</strong>", | |
6 => "Sorry we are closed" |
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
protected string FileSize(long size) | |
{ | |
string output = string.Empty; | |
double multiply = Math.Pow(10, 2); | |
string[] units = new string[] { "b", "Kb", "Mb", "Gb", "Tb", "Pb" }; | |
int exponent = (int)Math.Floor(Math.Log(size) / Math.Log(1024)); | |
output = (Math.Round(size / Math.Pow(1024, exponent) * multiply) / multiply) + units[exponent]; |
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.IO; | |
// using System.Text; | |
MyDBContext db = new MyDBContext(); | |
StringWriter w = new StringWriter(); | |
db.Log = w; | |
... do LINQ2SQL stuff | |
string SQL = w.GetStringBuilder().ToString(); |
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.Text; | |
using OfficeOpenXml; | |
using OfficeOpenXml.Style; | |
using OfficeOpenXml.Table; | |
using System.Drawing; | |
using System.Data; | |
public partial class Sample: Page | |
{ | |
protected void GenerateSpreadsheet(object sender, EventArgs e) |
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
Dim oFSO, oFolder, oFiles, oSubFolders | |
Dim oFile | |
Dim days | |
days = 200 | |
Set oFSO = CreateObject("Scripting.FileSystemObject") | |
Set oFolder = oFSO.GetFolder("path to folder") | |
ParseFolder oFolder |
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 FileExtension(oFile) | |
Dim lastDot | |
lastDot = InStrRev(CStr(oFile.Name), ".") | |
If lastDot = 0 Or lastDot = Null Then | |
FileExtension = "" | |
Else | |
FileExtension = Mid(CStr(oFile.Name), lastDot + 1) | |
End If |
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 | |
function pad_number(&$item, $key, $pad = 2) | |
{ | |
$item = sprintf('%0'.$pad.'d', $item); | |
} | |
function build_time_options($hours, $minutes, $time) | |
{ | |
// pad hours and minutes with 0 |
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; | |
public static class CSVExtensions | |
{ | |
public static string ToCSV(this DataTable dt) | |
{ | |
string output = string.Empty; | |
string tmp; | |
char[] special = new char[] { '"', '\n', '\r', ',' }; | |
// loop through all columns |