Skip to content

Instantly share code, notes, and snippets.

@sedm0784
sedm0784 / _vim_auto_list.markdown
Last active March 28, 2025 20:04
Vim Automatic List Continuation

Vim Auto List Completion

This snippet makes Vim automatically continue/end lists in insert mode, similar to the way word processors do:

  • It automatically adds the bullet/number for the next list item when you press Return at the end of an existing item,
  • When you press Return on an empty list item, it removes the bullet/number, ending the list.

It supports ordered lists with markers like 1. and unordered lists with - markers (because those are the markers I use.)

(It's particularly useful when using an iOS keyboard where punctuation and numerals are slow to access.)

@natecook1000
natecook1000 / operatorCharacters.swift
Last active September 2, 2024 22:07
Allowed characters for Swift operators
import Foundation
extension UnicodeScalar : ForwardIndexType {
public func successor() -> UnicodeScalar {
return UnicodeScalar(value + 1)
}
}
var operatorHeads: [UnicodeScalar] = Array("=-+!*%<>&|^~?".unicodeScalars)
operatorHeads += Array("\u{00A1}" ... "\u{00A7}")
@janko
janko / 01-safe-download.rb
Last active February 18, 2025 08:40
A safe way in Ruby to download a file to disk using open-uri (with/without comments)
require "open-uri"
require "net/http"
Error = Class.new(StandardError)
DOWNLOAD_ERRORS = [
SocketError,
OpenURI::HTTPError,
RuntimeError,
URI::InvalidURIError,
@BenMorel
BenMorel / viewport-units-ios.scss
Last active January 25, 2025 17:53
SCSS mixin to support vh and vw units on all iOS Safari versions. Based on an idea by Patrick Burtchaell's: https://gist.github.com/pburtchaell/e702f441ba9b3f76f587
/**
* Fix for vw, vh, vmin, vmax on iOS 7.
* http://caniuse.com/#feat=viewport-units
*
* This fix works by replacing viewport units with px values on known screen sizes.
*
* iPhone 6 and 6 Plus cannot run iOS 7, so are not targeted by this fix.
* Target devices running iOS 8+ will incidentally execute the media query,
* but this will still produce the expected result; so this is not a problem.
@plumhead
plumhead / StringSize.swift
Created September 15, 2015 13:34
String extension to find the layout size of a String with specified attributes.
extension String {
func size(withAttributes attrs: [String:AnyObject], constrainedTo box: NSSize) -> NSRect {
let storage = NSTextStorage(string: self)
let container = NSTextContainer(containerSize: NSSize(width: box.width, height: box.height))
let layout = NSLayoutManager()
layout.addTextContainer(container)
storage.addLayoutManager(layout)
storage.addAttributes(attrs, range: NSMakeRange(0, storage.length))
container.lineFragmentPadding = 0.0
let _ = layout.glyphRangeForTextContainer(container)

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a
@prenagha
prenagha / compile-applescript.sh
Created September 8, 2015 00:18
Compile .applescript files to .scpt files. Useful for LaunchBar actions and such.
#!/bin/bash
#
# find all launchbar action .applescript scripts and compile them
#
LBDEV=~/Dev/launchbar
find $LBDEV -type f -name '*.applescript' -print0 | while read -d '' -r APPLESCRIPT
do
echo "Compiling $APPLESCRIPT ..."
SCPT="${APPLESCRIPT%.applescript}.scpt"
/usr/bin/osacompile -o "$SCPT" "$APPLESCRIPT"
@henrik
henrik / half_open_struct.rb
Last active March 29, 2019 09:35
HalfOpenStruct for #ruby. Like OpenStruct but doesn't let you read a non-assigned value (raises instead of returning nil). Also see my RecursiveClosedStruct: https://gist.github.com/henrik/5098550
# Like OpenStruct but doesn't let you read a non-assigned value (raises instead of returning nil).
# This avoids issues where you read the wrong value due to a typo and don't notice.
class HalfOpenStruct
def initialize(hash = {})
@hash = hash
end
def include?(name)
@hash.include?(name)
diff --git a/colour.c b/colour.c
index a56ddce..8098f83 100644
--- a/colour.c
+++ b/colour.c
@@ -29,305 +29,85 @@
* of the 256 colour palette.
*/
-struct colour_rgb {
- u_char i;
@maxivak
maxivak / readme.md
Last active February 19, 2025 23:23
Integrating Gem/Engine and Main Rails App