Skip to content

Instantly share code, notes, and snippets.

@sdsykes
sdsykes / gist:5c2c0c2a41396aead3b7
Last active December 29, 2022 13:01
Windows on a space (using private CGS)
/// header
id CGSCopyManagedDisplaySpaces(int conn);
int _CGSDefaultConnection();
id CGSCopyWindowsWithOptionsAndTags(int conn, unsigned owner, NSArray *spids, unsigned options, unsigned long long *setTags, unsigned long long *clearTags);
// code
int spaceNumber = 0; // the space you want to get the windows for. numbering starts at 0.
@sdsykes
sdsykes / gist:905230
Created April 6, 2011 06:32
Jumploader applet tag
%applet{:id=>"jumpLoaderApplet", :name=>"jumpLoaderApplet", :code=>"jmaster.jumploader.app.JumpLoaderApplet.class", :archive=>"/java/jumploader_z.jar", :width=>"600", :height=>"400", :mayscript=>true}
%param{:name=>"uc_uploadUrl", :value=>upload_video_path}
%param{:name=>"uc_imageEditorEnabled", :value=>"false"}
%param{:name=>"ac_fireAppletInitialized", :value=>"true"}
- key = Rails.application.config.session_options[:key]
%param{:name=>"uc_requestProperties", :value=>"Cookie=#{key}=#{cookies[key]}"}
@sdsykes
sdsykes / desktop_equaliser.rb
Created November 24, 2017 07:56
Balance desktops after unplugging or plugging in an external monitor using TotalSpaces2
#!/usr/bin/env ruby
require 'totalspaces2'
columns = TotalSpaces2.grid_columns
displays = TotalSpaces2.display_list()
if displays.size == 1
spaces_count = TotalSpaces2.number_of_spaces
if spaces_count > columns && spaces_count % columns == columns - 1
@sdsykes
sdsykes / gist:df43e9ddaba4dabc05dc
Created October 26, 2015 14:33
cmx.io frame about sip
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css">
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg)">
<scene id="scene1" width="300">
<drawing t="translate(0,31)">
@sdsykes
sdsykes / SwapScreens.rb
Created October 12, 2015 10:17
Uses TotalSpaces2 to swap all windows to the other screen
#!/usr/bin/env ruby
require 'totalspaces2'
displays = TotalSpaces2.display_list
if displays.count != 2
puts "Must have 2 displays attached"
exit 1
end
@sdsykes
sdsykes / mongoid.rb
Created October 8, 2011 08:17
Fix for mongoid uninitialized constant errors from loading everything in lib in mongoid.rb in initializers
# initializers/mongoid.rb
# for when files in lib depend on or inherit from other files in lib
def do_require(file)
begin
require file
rescue NameError => e
e.message =~ /constant (\w+::)*(\w+)$/
if $2
do_require($2.underscore)
@sdsykes
sdsykes / gist:1184640
Created August 31, 2011 20:33
scriptingbridge sending keystroke with control key
def four_char_code(s)
(s[0].ord << 24) + (s[1].ord << 16) + (s[2].ord << 8) + s[3].ord
end
system = SBApplication.applicationWithBundleIdentifier("com.apple.SystemEvents")
system.send(:"keystroke:using:", space_number.to_s, four_char_code('Kctl'))
@sdsykes
sdsykes / gist:1184568
Created August 31, 2011 20:06
move space
on run argv
set space_number to item 1 of argv
tell application "System Events"
keystroke space_number using {control down}
end tell
end run
@sdsykes
sdsykes / gist:1047422
Created June 26, 2011 09:04
OSX 10.6.7 python upgrade twisted fails
$ sudo easy_install --upgrade twisted
Password:
install_dir /Library/Python/2.6/site-packages/
Searching for twisted
Reading http://pypi.python.org/simple/twisted/
Reading http://twistedmatrix.com/
Reading http://tmrc.mit.edu/mirror/twisted/Twisted/10.0/
Reading http://www.twistedmatrix.com
Reading http://twistedmatrix.com/products/download
Reading http://tmrc.mit.edu/mirror/twisted/Twisted/8.2/
@sdsykes
sdsykes / gist:913210
Created April 11, 2011 07:53
background jobs
Here's what I do:
This is Rails 2
pid = fork do
%x{RAILS_ENV=#{Rails.env} #{RAILS_ROOT + "/script/runner"} '#{script}'}
exit!
end
Process.detach pid