Skip to content

Instantly share code, notes, and snippets.

;; Enable editable dired mode.
(add-hook 'dired-mode-hook
(lambda ()
(define-key dired-mode-map
"r" 'wdired-change-to-wdired-mode)
(setq truncate-lines t)))
;; Enable a in dired mode to view a file w/o creating a new buffer.
(put 'dired-find-alternate-file 'disabled nil)
# create new page (or adjust existing page) called 'test'
$ curl https://api.silkapp.com/v1.4.0/site/uri/yoursite.silkapp.com/page/test
-d '<article>...</article>'
-b 'silk_sid=...'
-X PUT
-H 'Content-Type: application/xml'
<!-- page structure showing the title (line 7) and subtitle (line 8) -->
<article>
<section class="body">
<div class="layout meta"> <!-- left column -->
<div class="block header text" data-component-uri="http://silkapp.com/component/block/text">
<h1>Title</h1>
<p>Subtitle</p>
</div>
</div>
@bergmark
bergmark / maybe-remove-newlines
Created August 16, 2013 19:02
If there are two linebreaks at the end of a file, keep them, if there's only one it is kept as is to not add extra changes to commits.
(defun delete-trailing-whitespace-and-extra-nl ()
(interactive)
(let ((two? (ends-with-two-linebreaks?)))
(progn
(delete-trailing-whitespace)
(if (and two? (string-match "silk" (buffer-file-name)))
(save-excursion
(let ((undo-list (undo-copy-list buffer-undo-list)))
(progn
(buffer-disable-undo)
@bergmark
bergmark / A.hs
Last active December 22, 2015 22:19
failing persistent migration
{-# LANGUAGE EmptyDataDecls, FlexibleContexts, GADTs, OverloadedStrings, QuasiQuotes, TemplateHaskell, TypeFamilies #-}
module A where
import Database.Persist.TH
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
A
|]
module Foo
( module Control.Applicative
, g
) where
import Control.Applicative
g :: Int
g = 1
{-# LANGUAGE
EmptyDataDecls
, FlexibleContexts
, GADTs
, OverloadedStrings
, QuasiQuotes
, TemplateHaskell
, TypeFamilies
#-}
module Bar where
{-# LANGUAGE RankNTypes #-}
module Test where
import Data.Data (Data)
import Data.Generics.Uniplate.Data
import Data.Typeable (Typeable)
import Language.Haskell.Exts.Annotated hiding (binds, loc)
import Prelude hiding (exp)
{-# LANGUAGE
FlexibleContexts
, FlexibleInstances
, MultiParamTypeClasses
, TypeSynonymInstances
#-}
module ToStringy (ToStringy (..), fromStringy) where
import Data.String
import qualified Data.ByteString as SB
{-# LANGUAGE RankNTypes, TypeFamilies, ConstraintKinds #-}
import Data.String
import Data.String.ToString
import Text.XML.HXT.Arrow.Pickle
import GHC.Exts
import qualified Data.Map.Strict as SM
f :: (C map key, C map String, XmlPickler (map String value), IsString key, ToString key)
=> (forall k k'. C map k => (k -> k') -> map k value -> map k' value)