Skip to content

Instantly share code, notes, and snippets.

@denitram
denitram / regex
Last active August 28, 2016 22:47
8 Regular Expressions You Should Know
http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/
# insert a new line with '<null\>' as content every 6th line between lines 100 and 2000
100,2000s/\v(.*\n){6}/\0\<null\/\>\r/g
see http://stackoverflow.com/questions/10413906/how-to-add-a-line-after-every-few-lines-in-vim
# delete blank lines
:g/^$/d
# join all lines
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@zdne
zdne / Google Chrome Incognito.applescript
Last active January 31, 2023 19:38
Google Chrome Incognito – AppleScript to always run chrome in incognito mode. Save as an application to your Application folder. Optionally drag a and drop Google Chrome Icon in between Get Info panes (⌘+I)
if application "Google Chrome" is running then
tell application "Google Chrome" to make new window with properties {mode:"incognito"}
else
do shell script "open -a /Applications/Google\\ Chrome.app --args --incognito"
end if
tell application "Google Chrome" to activate
@shirshir
shirshir / gist:8400570
Created January 13, 2014 13:47
Recursive .zip excluding .git and .DS_Store
zip -r files.zip ./directory -x "*.git*" -x "*.DS_Store"
@almostintuitive
almostintuitive / SVGView.h
Created June 8, 2014 15:51
SVGView for iOS (using UIWebView)
//
// SVGView.h
// Just call the loadSVG method with the SVG's NSData to display it with transparent background & scrollbars.
//
// github.com/itchingpixels.
//
#import <UIKit/UIKit.h>
@interface SVGView : UIWebView <UIWebViewDelegate>
@unRob
unRob / iconiza.rb
Last active February 2, 2016 01:38
Convierte una imagen en un archivo .icns
#!/usr/bin/env ruby
# encoding: utf-8
src = ARGV[0]
if src == ''
puts "Usage: ./iconiza take five.jpg"
puts "Convierte una imagen en un archivo .icns"
end
@chendrix
chendrix / prelude.hs
Created September 18, 2014 06:00
"Policy" implementation in haskell
module Policy where
import Data.List
type Reason = String
type Reasons = [Reason]
data Policy = Invalid Reasons | Valid
instance Show Policy where
show Valid = "Valid"
show (Invalid reasons) = "Invalid: " ++ (intercalate ". " reasons) -- intercalate == Ruby's join
@pwittchen
pwittchen / convert_windows_line_endings_to_unix.sh
Created November 6, 2014 08:10
How to convert Windows line endings to Unix
# http://stackoverflow.com/a/19283453
# run the following command in the terminal
sed -i 's/\r//g' file
#!/usr/bin/env bash
size=1024 # MB
mount_point=$HOME/tmp
name=$(basename "$mount_point")
usage() {
echo "usage: $(basename "$0") [mount | umount | remount | check | orphan]" \
"(default: mount)" >&2
}
@ottoradke
ottoradke / Google Chrome Incognito
Created December 9, 2014 06:58
Google Chrome Incognito Window
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
set chrome_running to is_running("Google Chrome")
if chrome_running then
tell application "Google Chrome"
repeat with w in (windows)
if mode of w is "incognito" then
set index of w to 1