Skip to content

Instantly share code, notes, and snippets.

@backflip
backflip / gist:1257810
Created October 2, 2011 19:23
JavaScript bookmarklet to increase scrolling performance of GitHub code views on the iPhone
// Scrolling GitHub on my iPhone 4 (iOS 4.3.5) is almost impossible since it is extremely laggy / unresponsive.
// Digging through GitHub's code I discovered that unbinding some touch events solved the problem.
// No side effects detected.
javascript:jQuery('body').unbind(%22touchstart%20touchmove%20touchend%20touchcancel%22);
@backflip
backflip / gist:1301544
Created October 20, 2011 16:09
Wayback Machine jQuery Issue
<script src="http://mysite.com/jquery.js"></script>
<script>$.fn.myplugin = function(){}</script>
<script>
console.log($.fn.myplugin);
--> function()
</script>
<script src="http://archive.org/jquery.js"></script>
<script>
@backflip
backflip / gist:1379907
Created November 20, 2011 06:47
WordPress: WPML: Update comments table
UPDATE wp_posts wpp LEFT JOIN (SELECT comment_post_id AS c_post_id, count(*) AS cnt FROM wp_comments WHERE comment_approved = 1 GROUP BY comment_post_id) wpc ON wpp.id=wpc.c_post_id SET wpp.comment_count=wpc.cnt WHERE wpp.post_type IN ('post', 'page') AND (wpp.comment_count!=wpc.cnt OR (wpp.comment_count != 0 AND wpc.cnt IS NULL));
SET @trid = (SELECT MAX(trid) FROM wp_icl_translations);
INSERT INTO wp_icl_translations (element_type, element_id, trid, language_code)
SELECT 'comment', missing_comments.comment_ID, (@trid:=@trid+1) AS trid, language_code
FROM wp_icl_translations
RIGHT JOIN (
SELECT comment_ID, comment_post_ID FROM wp_comments
WHERE NOT EXISTS (
SELECT * FROM wp_icl_translations
@backflip
backflip / gist:1386442
Created November 22, 2011 18:26
OS X Folder Action to make Screenshot either public or not
on adding folder items to theWatchedFolder after receiving theDetectedItems
set _public to "Macintosh HD:Users:me:Dropbox:Public:Screenshots"
set _private to "Macintosh HD:Users:me:Dropbox:Photos:Screenshots"
try
set _choice to button returned of (display dialog "Share on DropBox?" buttons {"No", "Yes"} default button 2 cancel button "No")
if _choice = "Yes" then
@backflip
backflip / gist:1397445
Created November 27, 2011 11:30
WP-Polls Templates
<!--
WP-Polls allows for template settings (/wp-admin/admin.php?page=wp-polls/polls-templates.php). To match the design, the following definitions were used on our dev environment.
Since WP-Polls doesn't play nice with WPML, a custom JavaScript solution was chosen to translate the strings. Every element of a poll which has the class 'localize' is searched for a data attribute with the current language and the text is replaced accordingly.
Example: <button type="submit" class="localize" data-de="Abstimmen">Vote</button>
-->
<!-- Voting Form Header -->
Plugins
Zusätzliche Plugins:
* Subscribe to Comments Reloaded: Kommentar-Abo
* Widget Logic: Steuerung der Widget-Anzeige durch WordPress' Conditional Tags (Bsp: "is_home()" zeigt das Widget nur auf der Startseite an)
* ZigWidgetClass (EDITED): Vergabe von CSS-Klassen an Widgets (Bsp: "bg-inner" setzt den Widget-Inhalt - ohne Titel - in eine graue Box). Dieses Widget wurde insofern angepasst, dass das entsprechende Form-Label nicht mehr "ZigClass", sondern "Classes" heisst, um Verwirrung zu vermeiden.
@backflip
backflip / gist:1397895
Created November 27, 2011 17:51
WPML language switcher: Transform names to language codes
<?php
/**
* WPML language switcher: Transform names to language codes
*
* The language switcher is added to the theme by setting
* 'Den Sprachumschalter im WP-Menü anzeigen' to 'Meta right'.
* However, there is no option to display the language code only.
* Instead, the whole name is displayed (e.g., "Deutsch").
* As a work-around we filter all items of this navigation and
@backflip
backflip / gist:1423699
Created December 2, 2011 15:48
WordPress: Navigations
<?php
/**
* Register navigations
*/
register_nav_menus(array(
'main' => __('Main navigation', THEME_TEXTDOMAIN),
'meta' => __('Meta navigation', THEME_TEXTDOMAIN)
));
@backflip
backflip / gist:1424004
Created December 2, 2011 17:06
WordPress Shortcodes
<?php
/**
* Enable shortcodes in widgets
*/
add_filter('widget_text', 'do_shortcode');
/**
@backflip
backflip / gist:1521070
Created December 26, 2011 12:32
WordPress Polldaddy CSS
/**
* Styles for the Polldaddy widget (not used for now, but who knows...)
* Some definitions were commented out when the design changed
*/
.PDS_Poll {
display: block !important;
}