Skip to content

Instantly share code, notes, and snippets.

@daimatz
daimatz / dictionary-app.el
Created September 20, 2011 01:43
Emacs Lisp Tips
;; Mac の Dictionary.app を、 Emacs の popwin.el から使う
;; dict.py is from http://sakito.jp/mac/dictionary.html
(defun dictionary ()
"dictionary.app"
(interactive)
(let ((word (if (and transient-mark-mode mark-active)
(buffer-substring-no-properties (region-beginning) (region-end))
(read-string "Dictionary: ")))
(cur-buffer (current-buffer))
(tmpbuf " * dict-process *"))
@nicferrier
nicferrier / worker-elisp.el
Created October 28, 2011 20:48
Doing worker processing with EmacsLisp
(defmacro worker-elisp (output-stream &rest lisp)
"Evaluate the LISP in a child Emacs sending output to OUTPUT-STREAM.
The child Emacs has a 'load-path' exactly as the 'load-path' of
the parent Emacs at execution.
The OUTPUT-STREAM could be a buffer, a function or a process.
If the OUTPUT-STREAM is a process it may have a process property
@ctanis
ctanis / gist:1432200
Created December 5, 2011 03:40
something to cleanup dired mode (especially in the root of a home dir)
(defun dired-hide-dotfiles()
"reload current dired buffer, hiding dotfiles"
(interactive)
(dired-unmark-all-marks)
(dired-mark-files-regexp "^\\.")
(dired-do-kill-lines))
(add-hook 'dired-mode-hook
'(lambda ()
(local-set-key "h" 'dired-hide-dotfiles)))
@brianlow
brianlow / FindConflictingReferences.cs
Created January 3, 2012 03:04
Find conflicting assembly references
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
namespace MyProject
{
[TestFixture]
module Main where
import qualified Data.ByteString.Char8 as B
import Data.Tree.NTree.TypeDefs
import Data.Maybe
import Text.XML.HXT.XPath
import Text.XML.HXT.Core
import Control.Monad
import Control.Monad.Trans
@klaeufer
klaeufer / Makefile
Created April 2, 2012 17:57
Makefile for F# lexing and parsing example from F# Programming Wikibook
# Makefile for F# lexing and parsing example from
# http://en.wikibooks.org/wiki/F_Sharp_Programming/Lexing_and_Parsing
# Sources available at https://github.com/obeleh/FsYacc-Example
#
# http://laufer.cs.luc.edu/teaching/372
#
# Prerequisites
# make
# http://fsharppowerpack.codeplex.com/ for fslex, fsyacc
# http://fsxplat.codeplex.com/ for fsharpc (and fsharpi)
@takezoe
takezoe / JdbcSample.scala
Created June 30, 2012 01:00
Simple wrapper for JDBC API in Scala
import jp.sf.amateras.scala.util.Imports._
using(DriverManager.getConnection("")){ implicit conn =>
withTransaction { conn =>
// update
val rows = conn.execute(
"INSERT INTO USER_INFO (USER_ID, USER_NAME) VALUES (?, ?)",
1, "takezoe")
@gregorycollins
gregorycollins / Bench.hsc
Created September 5, 2012 10:28
Linux realtime clock Haskell FFI timings
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ForeignFunctionInterface #-}
module Bench where
import Control.Monad
import Criterion.Main
import Foreign
import Foreign.C.Types
@kaa
kaa / AssemblyInformationalVersionExtensions.cs
Created October 19, 2012 08:07
Extension method to extract informational version string from assembly metadata
public static class AssemblyInformationalVersionExtensions {
public static string GetInformationalVersionString(this Assembly assembly) {
return assembly
.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false)
.Cast<AssemblyInformationalVersionAttribute>()
.Select(t=>t.InformationalVersion)
.FirstOrDefault();
}
}
@xandkar
xandkar / concurrent_port_scanner.hs
Created October 20, 2012 05:00
Concurrent port scanner in Haskell
-- http://blog.moertel.com/articles/2004/03/13/concurrent-port-scanner-in-haskell
module Main (main) where
import Control.Concurrent
import Control.Exception
import Data.Maybe
import Network
import Network.BSD
import System.Environment