Skip to content

Instantly share code, notes, and snippets.

View joshwand's full-sized avatar

Josh Wand joshwand

  • San Francisco, CA
View GitHub Profile
@patmcnally
patmcnally / .irbrc
Created March 30, 2011 03:54
.irbrc file that incorporates wirble, hirb, rails 3, and awesome print
# load libraries
require 'rubygems' rescue nil
require 'wirble'
#require 'json'
alias q exit
class Object
def local_methods
(methods - Object.instance_methods).sort
@codingjester
codingjester / oauth_tumblr.py
Created April 3, 2012 23:33
OAuth Tumblr Getting Access Tokens
import urlparse
import oauth2 as oauth
consumer_key = 'consumer_key'
consumer_secret = 'consumer_secret'
request_token_url = 'http://www.tumblr.com/oauth/request_token'
access_token_url = 'http://www.tumblr.com/oauth/access_token'
authorize_url = 'http://www.tumblr.com/oauth/authorize'
class User < ActiveRecord::Base
attr_accessible :name
has_many :admin_memberships, class_name: "Membership", conditions: {role: 'admin'}
has_many :editor_memberships, class_name: "Membership", conditions: {role: 'editor'}
def admin?
admin_memberships.exists?
end
@ttscoff
ttscoff / rmdbc.bash
Created August 2, 2012 17:12
Bash alias to recursively delete Dropbox conflicted files
alias rmdbc="find . -name *\ \(*conflicted* -exec rm {} \;" # recursively delete Dropbox conflicted files
# and/or (smart idea from Gordon Fontenot)
alias rmdbcsafe="find . -name *\ \(*conflicted* -exec mv {} ~/DropboxConflicts/ \;" # recursively move Dropbox conflicted files to temp folder
# or... via TJ Luoma
alias rmdbctrash="find . -name *\ \(*conflicted* -exec mv -v {} ~/.Trash/ \;" # recursively move Dropbox conflicted files to Trash
# More advanced idea combining ideas from @modernscientist and @GFontenot would be
# Hazel or launchd script to move conflicted files to temp folder once a day, and Hazel or launchd script to delete files older than [x]
# Or schedule TJ's idea of moving to Trash and skipping intermediate folder while still maintaining the ability to review
# hmmmm...
@monde
monde / .gitignore
Last active February 19, 2020 19:02
Micro Gem to get an OAuth token and secret for the Tumblr.com API allowing an external application to post Tumblr.com blog.
Gemfile.lock
@ddeyoung
ddeyoung / gist:5502723
Last active July 21, 2017 16:27
Enable comment toggling in Sublime Text 2 for Groovy on OS X
Copy the Java comment config file to the Groovy directory
cp ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Java/Comments.tmPreferences ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Groovy/
Edit ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Groovy/Comments.tmPreferences
Change line 8
<string>source.java</string>
@floriankraft
floriankraft / JcrQueryLibrary.md
Last active May 3, 2024 05:50
Some useful JCR queries (XPATH, SQL2) for AEM/CQ development.

SQL2

All nodes with a specific name

SELECT * FROM [nt:unstructured] AS node
WHERE ISDESCENDANTNODE(node, "/search/in/path")
AND NAME() = "nodeName"

All pages below content path

@jewel-andraia
jewel-andraia / 18788.user.js
Last active February 3, 2017 03:01
Metafilter MultiFavorited Multiwidth for Greasemonkey
// ==UserScript==
// @name Metafilter MultiFavorited Multiwidth
// @author andytuba
// @namespace http://www.metafilter.com/user/25038
// @description https://gist.github.com/andytuba/af19e8db8dde937afb1a/edit
// @include http://www.metafilter.com/*
// @include http://*.metafilter.com/*
// ==/UserScript==
setTimeout(go, 200); // cheat instead of learning about Tampermonkey startup and config
@odrotbohm
odrotbohm / StoreRepository.java
Last active October 22, 2021 09:08
Dynamic, Querydsl-based filter bindings using Spring Data REST
public interface StoreRepository extends PagingAndSortingRepository<Store, String>,
QueryDslPredicateExecutor<Store>, QuerydslBinderCustomizer<QStore> {
@RestResource(rel = "by-location")
Page<Store> findByAddressLocationNear(Point location, Distance distance, Pageable pageable);
default void customize(QuerydslBindings bindings, QStore store) {
bindings.bind(store.address.city).single((path, value) -> path.startsWith(value));
bindings.bind(String.class).single((StringPath path, String value) -> path.contains(value));
}
@Faheetah
Faheetah / Jenkinsfile.groovy
Last active June 17, 2024 15:05
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"