Skip to content

Instantly share code, notes, and snippets.

@Boztown
Boztown / gist:6677666
Created September 23, 2013 22:11
jCrop center selection
var x = 50;
var y = 50;
var x1 = jQuery('#cropper img').width() - 100;
var y1 = jQuery('#cropper img').height() - 100;
jQuery('#cropper img').Jcrop({
aspectRatio: 1,
setSelect: [ x, y, x1, y1 ]
});
@Boztown
Boztown / gist:6490330
Created September 9, 2013 01:29
Remove hard-coded width/height from image thumbnails in Wordpress.
// remove hard-coded width/height
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10, 3 );
function remove_thumbnail_dimensions( $html, $post_id, $post_image_id ) {
$html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
return $html;
}
@Boztown
Boztown / gist:6470351
Created September 6, 2013 21:41
Determine which CSS3 transition events to use (from Modernizr).
function whichTransitionEvent(){
var t;
var el = document.createElement('fakeelement');
var transitions = {
'transition':'transitionend',
'OTransition':'oTransitionEnd',
'MozTransition':'transitionend',
'WebkitTransition':'webkitTransitionEnd'
}
@Boztown
Boztown / compress.php
Created August 21, 2013 16:16
PHP image compress.
function compressImage($source, $destination, $quality) {
$info = getimagesize($source);
switch($info['mime']) {
case "image/jpeg":
$image = imagecreatefromjpeg($source);
imagejpeg($image, $destination, $quality);
break;
case "image/gif":
$image = imagecreatefromgif($source);
imagegif($image, $destination, $quality);
/**
* Determine whether the file loaded from PhoneGap or not
*/
function isPhoneGap() {
return (cordova || PhoneGap || phonegap)
&& /^file:\/{3}[^\/]/i.test(window.location.href)
&& /ios|iphone|ipod|ipad|android/i.test(navigator.userAgent);
}
if ( isPhoneGap() ) {
for (var i = 0; i <= 100; i++) {
if (i % 3 == 0)
console.log(i + ': fizz');
if (i % 5 == 0)
console.log(i + ': buzz');
if ((i % 3 == 0) && (i % 5 == 0))
console.log(i + ': fizzbuzz');
@Boztown
Boztown / GlobalKeyboardHook.cs
Created April 26, 2013 06:19
Global keyboard hook.
#region License_Do_Not_Remove
/*
* Made by TheDarkJoker94.
* Check http://thedarkjoker94.cer33.com/ for more C# Tutorials
* and also SUBSCRIBE to my Youtube Channel http://www.youtube.com/user/TheDarkJoker094
* GlobalKeyboardHook is licensed under a Creative Commons Attribution 3.0 Unported License.(http://creativecommons.org/licenses/by/3.0/)
* This means you can use this Code for whatever you want as long as you credit me! That means...
* DO NOT REMOVE THE LINES ABOVE !!!
*/
#endregion
@Boztown
Boztown / gist:5215707
Created March 21, 2013 19:02
CSS Media Queries for devices
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
<sites>
<site name="WebSite1" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
<site name="BanffCentre.Web" id="2">
@Boztown
Boztown / gist:3503481
Created August 28, 2012 19:57
IIS: Map w3wp.exe to application pool
Run command prompt as "admin" and then do this:
C:\Windows\System32\inetsrv>appcmd list wp
WP "1512" (applicationPool:www)