Skip to content

Instantly share code, notes, and snippets.

@Dare-NZ
Dare-NZ / jquery_simple_lightbox.js
Last active December 17, 2015 00:49
A super simple lightweight jQuery lightbox function that accepts any HTML. May need some cross browser adjustments.
utilCreateLightbox : function(new_options) {
options = {
box_class : '',
box_content : '',
wrap_css : {
position : 'fixed',
left : 0,
top : 0,
width : '100%',
height : '100%',
@Dare-NZ
Dare-NZ / js_resize.php
Last active December 17, 2015 00:49 — forked from seedprod/vt_resize.php
Still getting the hang of gists apparently
<?php
/*
* Resize images dynamically using wp built in functions
* Based on the script by Victor Teixeira
* - Updated to use wp_get_image_editor()
* - Moves resized files to uploadpath/resized/
* Joe Swann
*
* php 5.2+
*
@Dare-NZ
Dare-NZ / LESS_property_value.less
Last active December 17, 2015 00:49
This LESS snippet lets you use a .pv(@p,@v) class to set a property with a value.
//First version
.pv(@p,@v) {
@{p}:@{v}
}
//Second version
.pv(@p,@v) {
-:~`";@{p}:@{v}".replace(/'/g,"")`;
// -:~`";@{p}:@{v}".replace(/'/g,"")`;
}
@Dare-NZ
Dare-NZ / css3_fontface.less
Last active December 17, 2015 00:49
Some of my most used CSS3 LESS styles, with a bonus @font-face simplifying function
.border-radius(@radius: 3px) {
border-radius: @radius;
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
}
.text-shadow(@color: #fff) {
text-shadow: 1px 1px 1px @color;
filter: dropshadow(color=@color, offx=1, offy=1);
}
@Dare-NZ
Dare-NZ / magic_grid.less
Last active December 17, 2015 00:49
Super simple 12 span grid system in LESS, use with or without media queries!
@wrap: 740px;
@gutter: 20px;
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.gridMake(@gutter : @gutter) {
@Dare-NZ
Dare-NZ / absPos_hList.less
Last active December 17, 2015 00:49
A couple of indespensible LESS functions for tedious CSS jobs
.hList {
list-style:none;
margin:0;
padding:0;
li {
margin:0;
padding:0;
display:inline-block;
*display:inline;
}
@Dare-NZ
Dare-NZ / SSH MYSQL commands
Last active December 17, 2015 00:49
Some SSH functions for backing up a MYSQL DB, zipping it and shipping it off to a remote server.
// Obviously {this} means replace with your version of this
// Dump DB
mysqldump -p -u {username} {dbname} > {dbname.sql}
// Tar DB
tar -cvf {dbname.tar} {dbname.sql}
// Move DB
curl -T {dbname.tar} ftp://{remote path}/{dbname.sql} --user {username}:{password} -v
@Dare-NZ
Dare-NZ / is_dir.php
Last active September 22, 2020 12:25
Connect via FTP and check if directory exists
<?php
// FTP login details
$ftp_server = 'yourserver.com';
$ftp_server_path = '/public_html/';
$ftp_user_name = 'username';
$ftp_user_pass = 'password';
// Connect to the FTP
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
function createLightbox(lightbox_content, lightbox_class) {
$('body').append('<div class="lightbox-wrap" ><div class="lightbox-position"><div class="lightbox ' + lightbox_class + '" /></div></div>');
$lightbox = $('.lightbox');
$lightbox_position = $('.lightbox-position');
$lightbox_wrap = $('.lightbox-wrap');
$lightbox_wrap.css({
position : 'fixed',
left : 0,
@Dare-NZ
Dare-NZ / getAvgLuminance.php
Last active February 13, 2023 07:35
A php function that gets the average brightness of an image
<?php
function getAvgLuminance($filename, $num_samples=30) {
// needs a mimetype check
$img = imagecreatefromjpeg($filename);
$width = imagesx($img);
$height = imagesy($img);
$x_step = intval($width/$num_samples);
$y_step = intval($height/$num_samples);