Skip to content

Instantly share code, notes, and snippets.

// From:
// http://www.stone.com/The_Cocoa_Files/Thanks_A_Bundle_.html
// here's how we determine the size of the actual image in the ImageView:
// I reused this code from PhotoToWeb, since it worked already!
- (float)photoReduction {
NSSize size = [[self image] size];
NSRect iFrame = [self bounds];
if (NSWidth(iFrame) > size.width && NSHeight(iFrame) > size.height) return 1.0; // it fits
@jdkanani
jdkanani / notepad.html
Last active June 16, 2024 13:44 — forked from jakeonrails/Ruby Notepad Bookmarklet
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">.e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div class="e" id="editor"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("editor");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
<!--
For other language: Instead of `ace/mode/ruby`, Use
Markdown -> `ace/mode/markdown`
Python -> `ace/mode/python`
C/C++ -> `ace/mode/c_cpp`
Javscript -> `ace/mode/javascript`
Java -> `ace/mode/java`
Scala- -> `ace/mode/scala`
@aras-p
aras-p / preprocessor_fun.h
Last active November 20, 2024 02:29
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@amw
amw / assets.rake
Created January 1, 2016 22:56
Capistrano task to verify that asset digests are the same on all hosts
# lib/capistrano/tasks/assets.rake
require "concurrent/hash"
# This task tests that hash digests of generated JS and CSS files are the same on every
# asset server. This should always be the case if Sprockets and Uglifier do their job
# well, but I've once had a problem with that. Once bitten, twice shy.
#
# We do not send compiled CSS&JS files to our asset servers, instead we're asking the
# servers to compile and minify them from source. If the process varies between servers
@scientificRat
scientificRat / keymap.py
Last active October 28, 2024 01:22
Use raspberry pi as Bluetooth HID mouse/keyboard emulator
#
# Taken from https://www.gadgetdaily.xyz/create-a-cool-sliding-and-scrollable-mobile-menu/
#
# Convert value returned from Linux event device ("evdev") to a HID code. This
# is reverse of what's actually hardcoded in the kernel.
#
# Lubomir Rintel <[email protected]>
# License: GPL
#
# Ported to a Python module by Liam Fraser.