Skip to content

Instantly share code, notes, and snippets.

@niksudan
niksudan / accordion.js
Last active August 29, 2015 14:11
Accordion [jQuery]
/**
* jQuery Accordion
*/
jQuery( document ).ready( function( $ ) {
$( document ).on( 'click', '.accordion .accordion-trigger', function() {
$( this ).closest( '.accordion' ).find( '.accordion-reveal' ).slideToggle();
} );
} );
@niksudan
niksudan / date_difference.php
Last active August 29, 2015 14:11
Get worded difference between two dates [PHP]
<?php
/**
* Get worded difference between two dates
*
* @param string $date
* @return string
*/
function date_difference( $date ) {
$start_date = new DateTime( $date );
@niksudan
niksudan / rotational_matrix.js
Last active August 29, 2015 14:11
Rotational matrix offsets [JS]
function offsetX( parentX, xOffset, yOffset, angle )
{
var a = ( -angle ) * ( Math.PI / 180 ),
val = ( ( xOffset * Math.cos( a ) ) - ( yOffset * Math.sin( a ) ) ) + parentX;
return Math.round( val );
}
function offsetY( parentY, xOffset, yOffset, angle )
{
var a = ( -angle ) * ( Math.PI / 180 ),
@niksudan
niksudan / rotate_destination.gml
Created December 21, 2014 13:33
Rotate to destination [GameMaker]
// rotate_destination( source_angle , destination_angle , rotation_speed , ease_amount(0 to 1) );
return median( -argument2 , argument2 , ( 1 - argument3 ) * ( ( ( ( ( argument0 - argument1 ) mod 360 ) + 540 ) mod 360 ) - 180 ) );
@niksudan
niksudan / url_extractor.php
Last active August 29, 2015 14:13
URL extraction class [PHP]
<?php
/**
* URL extraction class
*
* @author Nik Sudan
*/
class UrlExtractor {
public static $parts = array();
@niksudan
niksudan / example.html
Last active August 29, 2015 14:14
Number rolling transition [jQuery]
<h1>£<span class="numberRoll">100</span></h1>
@niksudan
niksudan / example.html
Last active August 29, 2015 14:15
Fade in element when scrolled to [jQuery]
<div class="fadeWhenScrolledTo">
<h1>Guess what?</h1>
<p>This should fade in when you scroll to it!</p>
</div>
<div class="fadeWhenScrolledTo">
<h1>How is that possible?</h1>
<p>With this adequate jQuery script, that's how!</p>
</div>
@niksudan
niksudan / example.html
Created February 12, 2015 22:06
Cycle through a list of elements [jQuery]
<div class="fadeCycle">
<img src="img1.jpg">
<img src="img2.jpg">
<img src="img2.jpg">
</div>
@niksudan
niksudan / getTarget.unity.js
Created March 8, 2015 12:27
Gets information about where the current camera is facing [Unity]
/**
* Gets information about where the current camera is facing
*
* @return RaycastHit/Boolean
*/
function getTarget()
{
var target : RaycastHit;
if ( Physics.Raycast( transform.position, transform.TransformDirection( Vector3.forward ), target ) ) {
@niksudan
niksudan / functions.php
Created April 13, 2015 13:56
Restyle WordPress login page [WordPress]
<?php
/**
* Restyle login page
*
* @return void
*/
function restyle_login_page()
{ ?>
<style type="text/css">