Skip to content

Instantly share code, notes, and snippets.

@brock
brock / psql-with-gzip-cheatsheet.sh
Last active May 13, 2024 13:31
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database
@pranid
pranid / compare-images.php
Last active January 24, 2023 07:01 — forked from akosnikhazy/compare-images-class
Compare two images with PHP
<?php
class compareImages
{
private function mimeType($i)
{
/*returns array with mime type and if its jpg or png. Returns false if it isn't jpg or png*/
$mime = getimagesize($i);
$return = array($mime[0],$mime[1]);
switch ($mime['mime'])
@ColinEberhardt
ColinEberhardt / Swift Events
Created February 11, 2015 09:15
An eventing mechanism for Swift
/// An object that has some tear-down logic
public protocol Disposable {
func dispose()
}
/// An event provides a mechanism for raising notifications, together with some
/// associated data. Multiple function handlers can be added, with each being invoked,
/// with the event data, when the event is raised.
public class Event<T> {
@robballou
robballou / someModule.js
Created October 29, 2014 23:04
Testing jQuery code in Mocha
// The hacky bit of this approach is that this module uses
// jQuery, but it is not referenced here. This is because I
// am populating it in the test via global namespace.
//
// In the browser this still works because I am adding jQuery
// via a Browserify transform (browserify-global-shim).
function someModule() {
}
modules.export = someModule;
@kopepasah
kopepasah / filter-infinite-scroll-text.php
Last active January 24, 2017 22:55
Quickly change Jetpack's Infinite Scroll text on button that loads more posts.
<?php
function filter_jetpack_infinite_scroll_js_settings( $settings ) {
$settings['text'] = __( 'Load more...', 'l18n' );
return $settings;
}
add_filter( 'infinite_scroll_js_settings', 'filter_jetpack_infinite_scroll_js_settings' );
@jvandyke
jvandyke / button.html
Created February 26, 2014 22:15
Replace text in an element with CSS
<button class="element">Old text</button>
@eyecatchup
eyecatchup / GetPlusOnesByURL.php
Last active February 13, 2024 16:39
Several PHP functions to get the +1 count from Google+ users for a given URL.
<?php
/**
* GetPlusOnesByURL()
*
* Get the numeric, total count of +1s from Google+ users for a given URL.
*
* Example usage:
* <code>
* $url = 'http://www.facebook.com/';
* printf("The URL '%s' received %s +1s from Google+ users.", $url, GetPlusOnesByURL($url));
@bartholomej
bartholomej / css-media-queries-cheat-sheet.css
Last active May 11, 2024 22:07
CSS Media Query Cheat Sheet (with Foundation)
/*------------------------------------------
Responsive Grid Media Queries - 1280, 1024, 768, 480
1280-1024 - desktop (default grid)
1024-768 - tablet landscape
768-480 - tablet
480-less - phone landscape & smaller
--------------------------------------------*/
@media all and (min-width: 1024px) and (max-width: 1280px) { }
@media all and (min-width: 768px) and (max-width: 1024px) { }
@jaxxreal
jaxxreal / collision.js
Created November 18, 2013 12:57
detect div collision with jQuery
function collision($div1, $div2) {
var x1 = $div1.offset().left;
var y1 = $div1.offset().top;
var h1 = $div1.outerHeight(true);
var w1 = $div1.outerWidth(true);
var b1 = y1 + h1;
var r1 = x1 + w1;
var x2 = $div2.offset().left;
var y2 = $div2.offset().top;
var h2 = $div2.outerHeight(true);
@pmgarman
pmgarman / delete.sql
Created August 1, 2013 22:35
How to find and delete orphaned product variations from WooCommerce sites.
DELETE o FROM `wp_posts` o
LEFT OUTER JOIN `wp_posts` r
ON o.post_parent = r.ID
WHERE r.id IS null AND o.post_type = 'product_variation'