Skip to content

Instantly share code, notes, and snippets.

@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 / 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
<?
/*************************************************************
Sitemap Crawler and Generator
*************************************************************/
$file = "google.xml"; // output file
$url = "http://www.plop.at"; // url to scan
<?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
<?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
/**
* 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';
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)
{
// 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);
}
mysqldump -h DBHOST -u DBUSER -pDBPASS --single-transaction DBNAME > data.sql
mysql -h DBHOST -u DBUSER -pDBPASS DBNAME < backup/data.sql