Skip to content

Instantly share code, notes, and snippets.

Daniel Bergey dbergey

Block or report user

Report or block dbergey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am dbergey on github.
  • I am dbergey (https://keybase.io/dbergey) on keybase.
  • I have a public key ASBfG5XPjljGmWg9kwbljH3cC5_9VUb4cgrlDitDDcJJKwo

To claim this, I am signing this object:

@dbergey
dbergey / gist:2695699
Created May 14, 2012
don't switch chat tabs when switching to chat app
View gist:2695699
tell application "System Events"
if (count of (every application process whose name is "iChat")) > 0 then
activate application "iChat"
else
activate application "Adium"
end if
end tell
View gist:2172335
if (type == 'blah')
var conditionalArea = {
stuff: "nonsense"
};
else {
var conditionalArea = {
fillColor: {
linearGradient: [0, 0, 0, 300],
stops: [
[0, Highcharts.getOptions().colors[0]],
@dbergey
dbergey / gist:1439654
Created Dec 6, 2011
Browser-Specific Classes
View gist:1439654
// add OS-specific classes for targeting a whole set of browser on one OS.
$('html').addClass('browser-os-'+ (
navigator.userAgent.match(/Macintosh/) ? 'macos' :
navigator.userAgent.match(/Windows/) ? 'windows' :
navigator.userAgent.match(/Linux/) ? 'linux' :
'unknown')
)
// now add more general browser classes for targeting all version of any one browser. IE disabled since conditional comments added.
.addClass('browser-'+ (
$.browser.msie ? 'ie' :
View gist:963409
<pre><?php
$herp = true;
$derp = false;
echo "$herp\n"; // --> 1
echo "$derp\n"; // --> [NOTHING]
?></pre>
View gist:918337
// from: http://forum.jquery.com/topic/jquery-reading-comments-from-the-dom
jQuery.fn.comments = function(location) {
var location = location || "inside";
var comments = [];
this.each(function() {
if (location == "inside") {
var children = this.childNodes
for (var i = 0; i < children.length; i++) {
var child = children[i];
@dbergey
dbergey / gist:898689
Created Apr 1, 2011
sneaky spinner JS
View gist:898689
document.body.innerHTML += '<style style="display: none;">@-webkit-keyframes spinner { 0%, 45%, 100% { -webkit-transform: rotate(0deg); } 50%, 95% { -webkit-transform: rotate(180deg); } } body { -webkit-animation: spinner 300s infinite; }</style>';
View snippet.js
// Math.sum.apply(null, [3, 4, 5, 6]) => 18
Math.sum = function() {
var total = 0, x = 0;
while (x < arguments.length) total += arguments[x++];
return total;
};
// Math.avg.apply(null, [3, 4, 5, 6]) => 4.5
Math.avg = function() {
return Math.sum.apply(null, arguments) / arguments.length;
View gist:743732
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<select multiple>
<option value="4" selected>four</option>
<option value="5">five</option>
</select>
<div id="result"></div>
<script>
$('#result').html( String($('select').val()) );
View appify
#!/usr/bin/env bash
#
# url : https://gist.github.com/672684
# version : 2.0.2
# name : appify
# description : Create the simplest possible mac app from a shell script.
# usage : cat my-script.sh | appify MyApp
# platform : Mac OS X
# author : Thomas Aylott <oblivious@subtlegradient.com>
You can’t perform that action at this time.