Skip to content

Instantly share code, notes, and snippets.

@JayPanoz
JayPanoz / user_stylesheet_base.css.tmpl
Created November 25, 2015 17:44
iBooks's default CSS
@namespace epub "http://www.idpf.org/2007/ops";
@namespace svg "http://www.w3.org/2000/svg";
/* Hide soundtrack <audio> tags from ever showing up */
audio[epub|type~="ibooks:soundtrack"] {
display: none !important;
/* display: none; doesn't seem to actually work for some reason, so hide it another way */
height: 0 !important;
}
@DanielSWolf
DanielSWolf / Program.cs
Last active June 13, 2024 17:26
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
using System;
using System.Threading;
static class Program {
static void Main() {
Console.Write("Performing some task... ");
using (var progress = new ProgressBar()) {
for (int i = 0; i <= 100; i++) {
progress.Report((double) i / 100);
@kumatti1
kumatti1 / Module1.bas
Created December 28, 2014 23:26
VBA_Test
Option Explicit
Declare PtrSafe Function DispInvoke Lib "OleAut32" _
(ByVal arg1 As LongPtr, _
ByVal arg2 As LongPtr, _
ByVal arg3 As Long, _
ByVal arg4 As Integer, _
arg5 As Any, _
arg6 As Variant, _
arg7 As Any, _
@adaptivegarage
adaptivegarage / theme-detect.css
Last active January 17, 2023 06:04
Pure CSS ePub theme detection (White / Sepia / Night) in iBooks (Mac OS and iOS included)
/*
Pure CSS ePub theme detection (White / Sepia / Night) in iBooks (Mac OS and iOS included)
Version 1.1
Note that iBooks actually uses internal JavaScript to set the "__ibooks_internal_theme" attribute on :root (html) element
every time the theme is changed, but this happens independently of whether your epub html markup is scripted or not.
Discovered and tested in iBooks on Mac, iPhone and iPad by
https://twitter.com/adaptivegarage
*/
@ashelly
ashelly / getopt.c
Last active November 9, 2023 23:22
"Port of GNU getopt() to Win32 for anyone who's tired of dealing with getopt() calls in Unix-to-Windows ports." Ported by Pete Wilson. Recovered from the Internet Archive's snapshot of www.pwilson.net/sample.html.
/* Getopt for GNU.
NOTE: getopt is now part of the C library, so if you don't know what
"Keep this file name-space clean" means, talk to drepper@gnu.org
before changing it!
Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001
Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@peaeater
peaeater / djvu2tif.ps1
Created November 29, 2013 18:06
Produce a TIF per page from the input DJVU file. The output name is simply the page number of the current page. Requires ddjvu => http://djvu.sourceforge.net/doc/man/ddjvu.html
# extract tif per page from djvu
# requires djvulibre
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0)]
[string]$in
)
process
{
@witwall
witwall / gist:5334142
Created April 8, 2013 03:56
Here’s the code to replace images in PDFs, in Java and C#. It will replace the first image in the first page.
PdfReader pdf = new PdfReader("in.pdf");
PdfStamper stp = new PdfStamper(pdf, new FileOutputStream("c:\\out.pdf"));
PdfWriter writer = stp.getWriter();
Image img = Image.getInstance("image.png");
PdfDictionary pg = pdf.getPageN(1);
PdfDictionary res =
(PdfDictionary)PdfReader.getPdfObject(pg.get(PdfName.RESOURCES));
PdfDictionary xobj =
(PdfDictionary)PdfReader.getPdfObject(res.get(PdfName.XOBJECT));
if (xobj != null) {
@SzymonPobiega
SzymonPobiega / gist:5220595
Last active April 25, 2024 17:19
DDD/CQRS/ES/Architecture videos

If you have two days to learn the very basics of modelling, Domain-Driven Design, CQRS and Event Sourcing, here's what you should do:

In the evenings read the [Domain-Driven Design Quickly Minibook]{http://www.infoq.com/minibooks/domain-driven-design-quickly}. During the day watch following great videos (in this order):

  1. Eric Evans' [What I've learned about DDD since the book]{http://www.infoq.com/presentations/ddd-eric-evans}
  2. Eric Evans' [Strategic Design - Responsibility Traps]{http://www.infoq.com/presentations/design-strategic-eric-evans}
  3. Udi Dahan's [Avoid a Failed SOA: Business & Autonomous Components to the Rescue]{http://www.infoq.com/presentations/SOA-Business-Autonomous-Components}
  4. Udi Dahan's [Command-Query Responsibility Segregation]{http://www.infoq.com/presentations/Command-Query-Responsibility-Segregation}
  5. Greg Young's [Unshackle Your Domain]{http://www.infoq.com/presentations/greg-young-unshackle-qcon08}
  6. Eric Evans' [Acknowledging CAP at the Root -- in the Domain Model]{ht
@ymotchi
ymotchi / clipboardtest.xlsm
Created June 17, 2012 07:43
Monitoring Clipboard in VBA
Option Explicit
Private Declare PtrSafe Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hWnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare PtrSafe Function CallWindowProc Lib "user32.dll" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As LongPtr, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As LongPtr) As LongPtr
Private Declare PtrSafe Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As LongPtr, ByVal Msg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As LongPtr
Private Declare PtrSafe Function SetClipboardViewer Lib "user32.dll" (ByVal hWndNewViewer As LongPtr) As LongPtr
Private Declare PtrSafe Function ChangeClipboardChain Lib "user32.dll" (ByVal hWndRemove As LongPtr, ByVal hWndNewNext As LongPtr) As Long
Private Declare Function IsClip
@precious
precious / pdf-trim-to-djvy.sh
Created December 24, 2011 20:05
This script trims white margins out of PDF document and packs it to DjVu
#!/bin/bash
# vim: set fileencoding=utf-8 ts=2 sw=2 expandtab:
# PUBLIC DOMAIN
# This script trims white margins out of PDF document and packs it to DjVu.
# Author Sergei Astanin http://sovety.blogspot.com/
# Modified by Vsevolod K. https://github.com/precious
### Settings