Skip to content

Instantly share code, notes, and snippets.

View JoshHrach's full-sized avatar
🏠
Working from home

Josh Hrach JoshHrach

🏠
Working from home
View GitHub Profile
@peteboere
peteboere / wp-bootstrap.php
Created March 9, 2011 17:27
Bootstrap wordpress from any wp installation sub-directory
<?php
if ( !defined( 'ABSPATH' ) ) {
$search = 'wp-load.php';
$limit = 20; // Avoid infinite loop if we're barking up the wrong tree
while ( !file_exists( $search ) and $limit-- ) $search = '../' . $search;
require_once $search;
}
@peteboere
peteboere / jquery.alterclass.js
Created December 24, 2011 12:49
jQuery alterClass plugin: Remove element classes with wildcard matching. Optionally add classes.
/**
* jQuery alterClass plugin
*
* Remove element classes with wildcard matching. Optionally add classes:
* $( '#foo' ).alterClass( 'foo-* bar-*', 'foobar' )
*
* Copyright (c) 2011 Pete Boere (the-echoplex.net)
* Free under terms of the MIT license: http://www.opensource.org/licenses/mit-license.php
*
*/
@mystix
mystix / setup-php-dev.sh
Last active April 27, 2023 15:46
(OSX 10.7.x/10.8.x + Homebrew + nginx + mysql + php 5.4 + php-fpm + apc + xdebug) development environment
#!/bin/bash
# install homebrew's official php tap
brew tap josegonzalez/homebrew-php
# install homebrew-dupes (required to install zlib, php54's dependency)
brew tap homebrew/dupes
# install nginx + mysql + php 5.4 + php-fpm + apc + xdebug
brew install nginx mysql
@sekati
sekati / xcode-build-bump.sh
Created July 24, 2012 20:44
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
@brandonjp
brandonjp / barleyBarHider.js
Created August 21, 2013 18:01
hides the Barley editor until ESC (or whatever key you choose) is pressed 3 times in a sec
function barleyBarHider(keyCode) { // need the keyCode? try whatthekeycode.com
var bb = jQuery('#barley-bar').children('#barley-logo').slideUp().end().hide();
var pressCount = 0;
var keyCode = typeof keyCode==="number" && ~~keyCode>0 ? ~~keyCode : 27; // use ESC key if error or NaN
jQuery(document).keyup(function(e) {
if (e.keyCode == keyCode) {
pressCount++;
if (pressCount==3) bb.show().children('#barley-logo').slideDown();
setTimeout(function(){pressCount=0},1000);
}
@matthiasplappert
matthiasplappert / gist:9493050
Last active August 29, 2015 13:57
QuickLook Debugging for `UIView`
@interface UIView (MPAdditions)
@end
@implementation UIView (MPAdditions)
- (id)debugQuickLookObject {
if (self.bounds.size.width < 0.0f || self.bounds.size.height < 0.0f) {
return nil;
}
var randomNumbers = [42, 12, 88, 62, 63, 56, 1, 77, 88, 97, 97, 20, 45, 91, 62, 2, 15, 31, 59, 5]
func partition(v: Int[], left: Int, right: Int) -> Int {
var i = left
for j in (left + 1)..(right + 1) {
if v[j] < v[left] {
i += 1
(v[i], v[j]) = (v[j], v[i])
}
}
@daniellevass
daniellevass / context_menus_and_modals.md
Last active October 26, 2015 23:29
Making Context Menus and Modal Dialogs in Apple Watch Apps

#Making Context Menus and Modal Dialogs in an Apple Watch App

Another learning curve we faced when creating the Whiskr Apple Watch App was how to use a context menu with modal dialogs. We ideally wanted this menu to display when the user force touched (long press) on a cat picture, so they could chose between showing where the picture was taken on a map, or display additional information about the picture, for example who took it.

Imgur

the context menu inside the Whiskr app when you force press on a photograph.

##1. Context Menu

The first thing we needed to do was to open our storyboard. We need to drag a "menu" object out onto the Interface Controller that the user will force touch on. It's worth noting here, that a context menu is unique only to a screen, you can not make it unique for each item in a table row for example.

@imjasonh
imjasonh / markdown.css
Last active May 17, 2024 07:30
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@malatx
malatx / sample-dash.php
Last active January 28, 2018 06:21
Sample Indie App Dashboard via AppFigures Data
<?php
// This is sample code to draw some of the charts I blogged about here:
// https://medium.com/ios-os-x-development/keeping-your-wits-as-an-indie-app-developer-3b5b14428e1f
//
// A few disclaimers:
// 1. This assumes you have at least 30 days of sales data in order to draw the Trailing 7 Days Chart
// 2. This assumes you have over 52 consecutive weeks of data in order to draw the Trailing Year Chart
// 3. I don't really know PHP. Everything this does, I had to look it up while writing it. If you actually know PHP, sorry. There are surely better ways.
//
// the results of this PHP script is intended to be drawn using the Flot library.