This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.
— Erik
on isOptionKeyPressed() | |
return (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSAlternateKeyMask > 1'") is "True" | |
end isOptionKeyPressed |
<?php | |
$countries = array("Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Island |
// http://stackoverflow.com/questions/2107657/mac-cocoa-getting-a-list-of-windows-using-accessibility-api | |
// http://stackoverflow.com/questions/853833/how-can-my-app-detect-a-change-to-another-apps-window | |
// http://cocoatutorial.grapewave.com/tag/axuielementcopyattributevalue/ | |
- (NSDictionary *)axInfoForProcessIdentifier:(NSNumber *)processIdentifier | |
{ | |
NSMutableDictionary *ret = [NSMutableDictionary dictionaryWithCapacity:2]; | |
pid_t pid = (pid_t) [processIdentifier integerValue]; | |
AXUIElementRef app = AXUIElementCreateApplication(pid); | |
AXUIElementRef frontWindow = nil; | |
NSString *title = nil; |
<?php | |
// check that cart items quantities totals are in multiples of 6 | |
add_action( 'woocommerce_check_cart_items', 'woocommerce_check_cart_quantities' ); | |
function woocommerce_check_cart_quantities() { | |
$multiples = 6; | |
$total_products = 0; | |
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) { | |
$total_products += $values['quantity']; | |
} | |
if ( ( $total_products % $multiples ) > 0 ) |
<?php | |
/* | |
* Copyright 2008 Google Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* |
⇐ back to the gist-blog at jrw.fi
Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.
I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.
This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso
# taken from user Albert's answer on StackOverflow | |
# http://stackoverflow.com/questions/5292204/macosx-get-foremost-window-title | |
# tested on Mac OS X 10.7.5 | |
global frontApp, frontAppName, windowTitle | |
set windowTitle to "" | |
tell application "System Events" | |
set frontApp to first application process whose frontmost is true | |
set frontAppName to name of frontApp |
console.reset = function () { | |
return process.stdout.write('\033c'); | |
} |
<?php | |
/** Display verbose errors */ | |
define( 'IMPORT_DEBUG', false ); | |
// Load Importer API | |
require_once ABSPATH . 'wp-admin/includes/import.php'; | |
if ( ! class_exists( 'WP_Importer' ) ) { | |
$class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php'; | |
if ( file_exists( $class_wp_importer ) ) |