Skip to content

Instantly share code, notes, and snippets.

View adamwgriffin's full-sized avatar

Adam Griffin adamwgriffin

View GitHub Profile
@adamwgriffin
adamwgriffin / rmempty.rb
Created April 4, 2014 06:27
A one-liner to recursively delete empty directories with Ruby
Dir['**/'].reverse_each { |d| Dir.rmdir d if Dir.entries(d).size == 2 }
@Mikhail-Zakharov
Mikhail-Zakharov / Collapse categories_Ver2.js
Last active December 28, 2015 20:28
Zendesk categories collapse widget
function HideCategory(id, IsAgent) {
// Function hides category
$j("div#category_" + id).hide('blind');
SetDownArrow(id, IsAgent);
$j.cookie('hide_category_' + id, 'yes', { expires: 180 });
$j("div#category_header_" + id).attr("onclick", "ShowCategory(" + id + "," +IsAgent+ ")");
};
@christoomey
christoomey / log.js
Created April 29, 2011 00:29
Wrapper for console.log
// usage: log('inside coolFunc',this,arguments);
// http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
log.history = log.history || []; // store logs to an array for reference
log.history.push(arguments);
if(this.console){
console.log( Array.prototype.slice.call(arguments) );
}
};
@colllin
colllin / backbone-auto-routing-example.html
Last active August 10, 2018 09:03
Automatic Backbone Routing - automatically capture links with relative URLs and route them through your Backbone Router. This method does not break any fallback server-side routing, because you're still using real URLs, i.e. `<a href="/my/app/page/4">See?</a>`. If a link can't be handled by any of your routers, it will fall through so the browse…
...
<nav>
<ul>
<li>
<a href="/my/app">Home</a>
</li><li>
<a href="/my/app/posts">Posts</a>
</li><li>
<a href="/my/app/posts/1">The First Post</a>
</li>
@mhaagens
mhaagens / gist:61f88e3fbfddbe2c00708f3ebd099be4
Last active September 12, 2018 23:56
Transition Motion React Router 4 Route Transition
const FadeRoute = ({ component: Component, ...rest }) => {
return (
<Route {...rest} children={({ location, match }) => (
<TransitionMotion
willEnter={() => {return {opacity: 0, translateX: 24}}}
willLeave={() => {return {opacity: spring(0, animationPresets.out), translateX: spring(24)}}}
defaultStyles={[ {
key: location.pathname,
style: { opacity: 0, translateX: 24},
@NielsLeenheer
NielsLeenheer / Samsung Browser
Last active June 23, 2020 11:33
Samsung Browser
Note: Some older devices such as the Galaxy S III did not get the Chromium based browser with
the update to Android 4.2 or later. When Samsung later introduced the Galaxy S3 Neo it did get
the new browser.
Note: With the Android 4.3 release and version 1.5 of the Chromium browser, Samsung did not
enable WebAudio API for the Note 3. All other devices did get the WebAudio API.
Note: Samsung did not update the browser version with the upgrade from Android 4.3 to 4.4,
but did add getUserMedia and WebRTC functionality.
@kevinpschaaf
kevinpschaaf / 0. Custom Elements + Redux toolbox & examples.md
Last active July 21, 2020 06:48
Custom Elements + Redux toolbox & examples

An approach to binding Redux to custom elements

The code here captures some of the patterns I used in the "real estate" demo app discussed in my talk End to End Apps with Polymer from Polymer Summit 2017.

There are many ways to connect Redux to custom elements, and this demonstrates just one pattern. The most important aspects are to try and lazily-load as much of the otherwise global state management logic along with the components that need them (as shown via the lazyReducerEnhancer and addReducers calls in the connected components), and to consider the tradeoffs you make in terms of coupling components to the store.

The pattern shown here of creating a stateless component and then a subclass that connects it to the store addresses a potential desire to reuse app-level stateless components between more than one application context, so the subclass provides a degree of decoupling from the concrete store, at the expense of more boilerplate. If app com

@erikras
erikras / RichTextMarkdown.js
Created October 28, 2016 12:23
Using react-rte with redux-form
import React, { Component, PropTypes } from 'react'
class RichTextMarkdown extends Component {
static propTypes = {
input: PropTypes.shape({
onChange: PropTypes.func.isRequired,
value: PropTypes.string
}).isRequired
}
@twosixcode
twosixcode / gist:1988097
Created March 6, 2012 18:40
Make "Paste and Indent" the default paste in Sublime Text 2
// swap the keybindings for paste and paste_and_indent
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["super+shift+v"], "command": "paste" }
@ryanc414
ryanc414 / git-rm-merged
Last active July 12, 2022 12:17
Delete merged git branches locally and on remote
#!/bin/bash
# Remove merged git branches locally and on remote(s)
set -e
# Script constants
BRANCH_WHITELIST="(\*|master|other-special-branches)"
REMOTES="origin" # Add more remotes here as space-separated list
echo "Deleting merged branches locally"