Skip to content

Instantly share code, notes, and snippets.

@xeromorph
xeromorph / gist:1495247
Created December 19, 2011 03:25
apache access stats [bash]
#!/bin/bash
filename='/var/log/apache2/pogoda/access.log.1'
SEDFORMAT='s/([0-9]+)\/(.+)\/([0-9]+):([0-9]+:[0-9]+:[0-9]+)/\2 \1 \4 \3/'
PREV_EPOCH=$(date +%s -d "$(head -n1 $filename|grep -P -o '(\d+/\w{3}/\d{4}(:\d{2}){3})'|sed -r -e 's/([0-9]+)\/(.+)\/([0-9]+):([0-9]+:[0-9]+:[0-9]+)/\2 \1 \4 \3/')")
COUNT=0
SUM=0
@xeromorph
xeromorph / gist:1495252
Created December 19, 2011 03:26
apache access stats [ruby]
require 'date'
dates = []
lapses = []
File.open('/var/log/apache2/pogoda/access.log.1').each do |line|
next if line =~ /\.(js|css|gif|png|jpe?g)/i
dates.push(DateTime.strptime(line[/(\d+\/\w{3}\/\d{4}(:\d{2}){3})/,1], '%d/%b/%Y:%k:%M:%S').to_time)
end
dates.each_cons(2) do |pair|
<?php
/**
* Add the field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my_custom_checkout_field"><h3>'.__('My Field').'</h3>';
@xeromorph
xeromorph / GetAsyncEnumerable.cs
Created June 6, 2020 10:11 — forked from Ilchert/GetAsyncEnumerable.cs
Read json array as async enumerable
public class Program
{
public static async Task Main(string[] args)
{
using var dataResponse = await client.GetAsync();
dataResponse.EnsureSuccessStatusCode();
await using var stream = await dataResponse.Content.ReadAsStreamAsync();
var pipe = PipeReader.Create(stream);