Skip to content

Instantly share code, notes, and snippets.

@niksudan
niksudan / gulpfile.js
Last active August 29, 2015 14:21
Gulpfile [AngularJS]
/**
* gulp-angular
* Nik Sudan
*
* Commands:
* gulp Creates dist files
* gulp watch Continuously creates dist files when files are changed
* gulp styles Compiles SCSS
* gulp app Compiles app Javascript
* gulp components Compiles components
@niksudan
niksudan / example.php
Last active October 21, 2016 04:04
Region categorizer [PHP]
<?php
$regions = new Regions('General');
$regions->add('North', 54.5742270, -1.2349560);
$regions->add('North West', 53.9690089, -2.6276908);
$regions->add('East Anglia', 52.6308859, 1.2973550);
$regions->add('Midlands', 52.6368778, -1.1397592);
$regions->add('Wales', 52.1306607, -3.7837117);
$regions->add('South East', 50.7680350, 0.2904720);
$regions->add('Scotland', 56.4906712, -4.2026458);
$regions->add('South West', 50.7772135, -3.9994610);
@niksudan
niksudan / fuzzyDate.js
Last active August 29, 2015 14:19
Fuzzy Date Filter [AngularJS]
// Makes a date readable
app.filter('fuzzyDate', function() {
return function(input, all) {
var now = new Date();
var now = new Date(now.valueOf() + -now.getTimezoneOffset() * 60000);
var then = Date.parse(input);
if (!then) {
var s = input.replace(' ', 'T');
@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">
@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 / 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 / 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 / README.md
Last active February 11, 2019 17:13
Locator [PHP]

locator

Get location data from a string in PHP.

Note that you can only make a certain amount of requests, so use sparingly.

Usage

@niksudan
niksudan / example.html
Last active August 29, 2015 14:14
Number rolling transition [jQuery]
<h1>£<span class="numberRoll">100</span></h1>
@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();