Skip to content

Instantly share code, notes, and snippets.

// VIEWPORT FIX
documentWidth = $(document).width();
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
viewport = document.querySelector("meta[name=viewport]");
viewport.setAttribute('content', 'width=' + documentWidth);
}
function GetIP()
{
foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key)
{
if (array_key_exists($key, $_SERVER) === true)
{
foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip)
{
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false)
{
<?php
/**
* Youtube API get thumbnail using Youtube username
* @param mixed $client Youtube username
* @return mixed Thumbnail src attribute
*/
public static function get_yt_thumbnail($client)
{
$feed1 = 'https://gdata.youtube.com/feeds/api/users/'.$client.'? fields=media:thumbnail';
<?php
/**
* Display time ago
* @param mixed $time strtotime of timestamp
* @return mixed string containing time ago since passed param
*/
public static function time_ago($time)
{
$periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
<?php $IE6 = (ereg('MSIE 6',$_SERVER['HTTP_USER_AGENT'])) ? true : false;
$IE7 = (ereg('MSIE 7',$_SERVER['HTTP_USER_AGENT'])) ? true : false;
$IE8 = (ereg('MSIE 8',$_SERVER['HTTP_USER_AGENT'])) ? true : false;
if (($IE6 == 1) || ($IE7 == 1) || ($IE8 == 1)) {
// Do fallback stuff that old browsers can do here
echo "Shit its ie!";
} else { ?>
// do stuff that real browsers can handle here
<?
/*************************************************************
Sitemap Crawler and Generator
*************************************************************/
$file = "google.xml"; // output file
$url = "http://www.plop.at"; // url to scan
@gabrysiak
gabrysiak / git-commands-cheatsheet.md
Last active September 18, 2016 04:09
Git Commands Cheatsheet

Git Commands Cheatsheet

A list of commonly used GIT commands.

Create


Clone an existing repo

git clone https://github.com/user/repo.git
@gabrysiak
gabrysiak / HTTPStatusCodes.md
Last active August 29, 2015 14:05
HTTP Status Codes

HTTP Status Codes (Most Used)

This list contains the top 10 HTTP Status codes that are most popular

Code Name Usage
200 OK A successful GET or PUT request
201 Created A successful POST request
204 No content A successful DELETE request
400 Bad request An unsuccessful GET, POST, or PUT request, due to invalid content
@gabrysiak
gabrysiak / LAUNCHLIST.md
Last active September 19, 2015 06:38
Website / App Launch Checklist

Website and Application Launch Checklist

A checklist of items to check when launching a website or application. Some items may be optional.

Website Specific

  • Git Repo Setup
  • Spelling, Grammer, Punctuation
  • Forms
  • Site Speed
  • Multi-browser compatibility
@gabrysiak
gabrysiak / parseUrl.js
Created October 15, 2014 20:42
Javascript function that returns parsed URL object
/**
* Parse url
* @param {string} url Url string
* @return {object} Parsed url object
*
* Example Use:
* var parsedUrl = parseURL('http://drive.google.com/search');
*
* parsedUrl {
* domain: "drive.google.com",