Skip to content

Instantly share code, notes, and snippets.

post_date = post_date.gsub('Today', Time.now.strftime('%d.%m.%Y'))
post_date = post_date.gsub('Yesterday', 1.day.ago.strftime('%d.%m.%Y'))
I have this HTML fragment from a vBulleting board:
<div id="post_message_5344600">
<div style="margin: 5px 20px 20px;">
<div style="margin-bottom: 2px;" class="smallfont">Quote:</div>
<table width="100%" cellspacing="0" cellpadding="8" border="0">
<tbody><tr>
<td style="border: 1px inset;" class="alt2">
<div>
Quote from <strong>Ahnungslos</strong>
<a rel="nofollow" href="showthread.php?
<div id="post_message_5344600">
<div style="margin: 5px 20px 20px;">
<div style="margin-bottom: 2px;" class="smallfont">Quote:</div>
<table width="100%" cellspacing="0" cellpadding="8" border="0">
<tbody><tr>
<td style="border: 1px inset;" class="alt2">
<div>
Quote from <strong>Ahnungslos</strong>
<a rel="nofollow" href="showthread.php?p=5344371#post5344371">Show post</a>
</div>
@pke
pke / sitemap_generator.rb
Created October 21, 2011 07:47
Uses configuration values instead of hardcoded values for url and filename
# Sitemap.xml Generator is a Jekyll plugin that generates a sitemap.xml file by
# traversing all of the available posts and pages.
# pke: modified to use site.config['sitemap']['url'] instead of MY_URL
#
# How To Use:
# 1.) Copy source file into your _plugins folder within your Jekyll project.
# 2.) Change MY_URL to reflect your domain name.
# 3.) Change SITEMAP_FILE_NAME if you want your sitemap to be called something
# other than sitemap.xml.
# 4.) Change the PAGES_INCLUDE_POSTS list to include any pages that are looping
@pke
pke / extconf.rb
Created November 12, 2011 16:05
fixed typhoeus build for win32
ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
# :stopdoc:
require 'mkmf'
ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
specified_curl = ARGV[0] =~ /^--with-curl/ ? ARGV[0].split("=")[1] : nil
LIBDIR = specified_curl ? "#{specified_curl}/lib": Config::CONFIG['libdir']
INCLUDEDIR = specified_curl ? "#{specified_curl}/include" : Config::CONFIG['includedir']
@pke
pke / wtlx.h
Created November 22, 2011 10:28
WTL GDI extensions
template<class T = HGDIOBJ>
class COldObject {
public:
typedef T (WINAPI* restore)(HDC hdc, T old);
COldObject(HDC dc, T old, restore func = SelectObject) : dc(dc), old(old), func(func) {}
~COldObject() {
func(dc, (T)old);
}
@pke
pke / gist:1677550
Created January 25, 2012 17:46
Downloading file in padrino/sinatra
Server.controllers :installer, :parent => :licenses do
before do
puts params.inspect
@license = License.get(params[:license_id])
halt 404, "License not found" unless @license
end
get :index, :with => :token do
halt 404, "File not found" if @license.installer.token != params[:token]
# installer.path is something like c:/installers/install.exe
@pke
pke / gist:1681999
Created January 26, 2012 09:46
slim example
-@title = 'License Slots'
.block
.secondary-navigation
ul.wat-cf
li.first==link_to pat(:list), url(:licenses, :index)
li==link_to pat(:new), url(:licenses, :new)
li==link_to pat(:edit), url(:licenses, :edit, :id => @license.id)
li.active==link_to pat(:slots), url(:licenses, :slots, :id => @license.id)
.content
.secondary-navigation
@pke
pke / gist:3934325
Created October 22, 2012 21:08
unzip component
CreationCollisionOption = Windows.Storage.CreationCollisionOption
describe 'Zip component', ->
it 'should handle OpenDocument containers', ->
spec.async ->
uri = "resource/test1.odt".toAppPackageUri()
stream = Windows.Storage.Streams.RandomAccessStreamReference.createFromUri(uri)
runtime.zip.ZipArchive.createFromStreamReferenceAsync(stream)
.then (archive) ->
expect(archive.files.length).toEqual 17
@pke
pke / analytics.coffee
Created May 23, 2013 11:59
Windows Modern UI Google Analytics helpers
ApplicationView = Windows.UI.ViewManagement.ApplicationView
ApplicationViewState = Windows.UI.ViewManagement.ApplicationViewState
ApplicationLanguages = Windows.Globalization.ApplicationLanguages
CURRENT_RATE_LIMIT = MAX_RATE_LIMIT = 60
RATE_LIMIT_TICK = 2000
RATE_LIMITED_MESSAGE_QUEUE = new Queue()
logger = window.console