Skip to content

Instantly share code, notes, and snippets.

View zachshallbetter's full-sized avatar

Zach Shallbetter zachshallbetter

View GitHub Profile
@mdigital
mdigital / JsonPExampleinBackbone.js
Created June 7, 2012 02:21 — forked from denisos/JsonPExampleinBackbone.js
Backbone.js model calling jsonp
// backbone.js continues to impress, I needed to get data from a jsonp api
// I really wanted to do this the "right" backbone.js way and create a model and call fetch.
// But the default backbone synch is not jsonp
// Turns out you can override a synch on a per model basis (thanks stackoverflow)
// whats nice is backbone.js continue to work as expected with the override
// here's a snippet (some changes to protect our privacy). An improvement could be to create a jsonp model class which MyModel inherits
// the synch function is most important below, that's what tells backbone it's jsonp
MyModel = Backbone.Model.extend({
(function () {
// ... all vars and functions are in this scope only
// still maintains access to all globals
}());
@thomsbg
thomsbg / compile_templates.js
Last active December 22, 2015 20:29
Loop through all the view prototype objects in a namespace, transforming their templateId into a template function.
var compileTemplates = function() {
_.each(App.Views, function(View) {
if (View.prototype.templateId) {
// The templateId references the id of a DOM element containing
// the content of the template
var html = jQuery('#' + View.prototype.templateId).html() || '';
View.prototype.template = _.template(html);
}
});
}
@philfreo
philfreo / QueryStringTest.php
Created June 22, 2011 19:44
add_querystring_var() and remove_querystring_var() improvements, with tests
<?php
class QueryStringTest extends PHPUnit_Framework_TestCase {
/**
* @covers remove_querystring_var
*/
public function testRemoveQueryStringVar() {
// tests without any other querystring params
@rampantprint
rampantprint / web-dev-links.md
Last active June 9, 2021 08:28
Web Dev Links
@abouthalf
abouthalf / settings.json
Last active September 11, 2021 17:19
Visual Studio Code user settings for Operator Mono
// Place your settings in this file to overwrite the default settings
{
"editor.fontFamily": "Operator Mono SSm",
// Enables font ligatures
"editor.fontLigatures": true,
// Controls whether the editor should render whitespace characters
"editor.renderWhitespace": "all"
}
$ = jQuery
TIMEOUT = 20000
lastTime = (new Date()).getTime()
setInterval ->
currentTime = (new Date()).getTime()
# If timeout was paused (ignoring small
# variations) then trigger the 'wake' event
if currentTime > (lastTime + TIMEOUT + 2000)
@claviska
claviska / pretty-buttons.less
Last active October 21, 2022 22:25
A Less mixin' for pretty buttons with Bootstrap 3
.pretty-buttons(@color, @background, @text-shadow: none) {
color: @color;
#gradient > .vertical(lighten(@background, 5%), darken(@background, 5%), 0%, 100%);
border-color: darken(@background, 10%);
border-bottom-color: darken(@background, 20%);
text-shadow: @text-shadow;
.box-shadow(inset 0 1px 0 rgba(255, 255, 255, .1));
&:hover,
@sumardi
sumardi / nginx.default.conf
Last active November 3, 2023 18:49
Install PHP-FPM, Nginx & MySQL on EC2 with Amazon Linux AMI
# Install linux update, followed by GCC and Make
sudo yum -y update
sudo yum install -y gcc make
# Install Nginx and PHP-FPM
sudo yum install -y nginx php-fpm
# Install PHP extensions
sudo yum install -y php-devel php-mysql php-pdo \
php-pear php-mbstring php-cli php-odbc \
@rvl
rvl / git-pushing-multiple.rst
Created February 9, 2016 11:41
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just