Skip to content

Instantly share code, notes, and snippets.

@gruber
gruber / gist:647224
Created October 26, 2010 16:26 — forked from dpk/gist:646570
Slight tweaks to dpkendal's script. Gives the BBEdit document a name (rather than "untitled <integer>", and skips the \n to \r stuff, which I don't think is necessary in recent versions of BBEdit.
tell application "Safari"
set _source to do JavaScript "window.document.documentElement.outerHTML" in document 1
set _name to name of document 1
end tell
tell application "BBEdit"
make new text window with properties ¬
{contents:_source, source language:"HTML", name:"Generated source: " & _name}
select insertion point before character 1 of text window 1
@mikeash
mikeash / gist:1132620
Created August 8, 2011 20:17
Namespaced constants in C
#import <Foundation/Foundation.h>
// .h file
struct MyConstantsStruct
{
NSString *foo;
NSString *bar;
@cefstat
cefstat / lion-fullscreen.patch
Created November 10, 2011 19:31
Patch for Emacs fullscreen support under Mac OS X 10.7 (Lion)
=== modified file 'lisp/term/ns-win.el'
--- old/lisp/term/ns-win.el 2011-10-01 20:32:01 +0000
+++ new/lisp/term/ns-win.el 2011-11-10 16:22:51 +0000
@@ -928,6 +928,10 @@
(add-to-list 'frame-creation-function-alist '(ns . x-create-frame-with-faces))
(add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
+(declare-function ns-toggle-fullscreen-internal "nsfns.m" ())
+(defun ns-toggle-fullscreen ()
+ (interactive)
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@0xced
0xced / NSObject+ARCZombie.m
Created May 19, 2012 17:52
Solves the problem of .cxx_destruct methods not being called when zombies are enabled
#import <objc/runtime.h>
@implementation NSObject (ARCZombie)
+ (void) load
{
const char *NSZombieEnabled = getenv("NSZombieEnabled");
if (NSZombieEnabled && tolower(NSZombieEnabled[0]) == 'y')
{
Method dealloc = class_getInstanceMethod(self, @selector(dealloc));
@BenedictC
BenedictC / gist:4246759
Created December 9, 2012 20:03
A marco for creating enums with values which can be logged (inspired by http://rentzsch.tumblr.com/post/37512716957/enum-nsstring and long train journey).
#define EMKStringableEnum(ENUM_NAME, ENUM_VALUES...) \
\
typedef enum { \
ENUM_VALUES \
} ENUM_NAME; \
\
\
\
static NSString * ENUM_NAME##ToString(int enumValue) { \
static NSString *enumDescription = @"" #ENUM_VALUES; \
@landonf
landonf / PLSuperInit.m
Last active December 11, 2015 11:48
Avoiding the default [super init] boilerplate:
/**
* @ingroup macros
*
* Call the superclass' default zero-argument initializer, returning nil if the superclass' initializer
* returns nil.
*
* This macro is equivalent to:
*
* @code
* if ((self = [super init]) == nil)
@aras-p
aras-p / lambda.cpp
Last active September 24, 2019 02:40
Lambda art
// C++11 lambdas aren't terribly useful at producing art.
// Source below is valid C++11. VS2013 takes about a minute at it (Release config),
// reaches almost 4GB of memory usage and then gives a
//
// 1>ConsoleApplication1.cpp(34): fatal error C1001: An internal error has occurred in the compiler.
// 1> (compiler file 'msc1.cpp', line 1325)
// 1> To work around this problem, try simplifying or changing the program near the locations listed above.
// 1> Please choose the Technical Support command on the Visual C++
// 1> Help menu, or open the Technical Support help file for more information
// 1> This error occurred in injected text:
@andrejbauer
andrejbauer / topology.v
Last active November 28, 2023 19:40
How to get started with point-set topology in Coq. This is not actually how one would do it, but it is an intuitive setup for a classical mathematician.
(* How do to topology in Coq if you are secretly an HOL fan.
We will not use type classes or canonical structures because they
count as "advanced" technology. But we will use notations.
*)
(* We think of subsets as propositional functions.
Thus, if [A] is a type [x : A] and [U] is a subset of [A],
[U x] means "[x] is an element of [U]".
*)
Definition P (A : Type) := A -> Prop.
@drdrang
drdrang / Alpha Evaluate.py
Last active August 29, 2015 14:03
Evaluate an expression with a numerical answer using Wolfram Alpha and return the result as an equation. Also open the Alpha page in a browser (Mac only). Intended to be used as a BBEdit Text Filter but can be used from the command line. See http://www.leancrew.com/all-this/2014/07/evaluating-latex-with-eddie-and-alpha/
#!/usr/bin/python
from urllib import quote_plus
from sys import stdin
from subprocess import call
import requests
import xml.etree.ElementTree as ET
appID = 'XXXXXX-YYYYYYYYYY' # Placeholder. You'll need to get an ID from http://products.wolframalpha.com/api/