Skip to content

Instantly share code, notes, and snippets.

View RKAN's full-sized avatar

Serkan Camur RKAN

  • Bitberry GmbH
  • Vienna
View GitHub Profile
@RKAN
RKAN / get_geo_info
Created July 19, 2013 15:51
Get Geo-IP Information
<?php
$ip='94.219.40.96';
print_r(geoCheckIP($ip));
//Array ( [domain] => dslb-094-219-040-096.pools.arcor-ip.net [country] => DE - Germany [state] => Hessen [town] => Erzhausen )
//Get an array with geoip-infodata
function geoCheckIP($ip)
{
//check, if the provided ip is valid
if(!filter_var($ip, FILTER_VALIDATE_IP))
@RKAN
RKAN / slugify_text.php
Created July 19, 2013 15:53
slugify text
<?php
function getSlug($text)
{
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
$text = trim($text, '-');
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
$text = strtolower($text);
$text = preg_replace('~[^-\w]+~', '', $text);
if (empty($text))
{
<?php
//
// this gist takes most of the code from https://gist.github.com/3176917 but adds in form uploading which is just an @ symbol
// this also explores different options for the form data
//
// curl_post_upload.php
// You can modify this script to make PHP use a webpage like a person sitting
// at a computer would use a webpage.
//
// tags: #php #curl #form #upload
@RKAN
RKAN / awesome-php.md
Created July 19, 2013 16:05 — forked from ziadoz/awesome-php.md
# Awesome PHP A list of amazingly awesome PHP libraries, resources and shiny things.

Awesome PHP

A list of amazingly awesome PHP libraries, resources and shiny things.

Composer

Composer Related

@RKAN
RKAN / .php
Created July 19, 2013 16:09
//gets the path to your root directory of your site
<?php
$path = $_SERVER['DOCUMENT_ROOT']; //gets the path to your root directory of your site
//now all links instead of being:
// (images/index.php) and have it be different across all pages, use this:
include_once ($path . '/layout/footer.php'); //and it is now universal across all pages
//found at: http://css-tricks.com/php-include-from-root/
?>
// if (!window.L) { window.L = function () { console.log(arguments);} } // optional EZ quick logging for debugging
/**
* A modified (improved?) version of the jQuery plugin design pattern
* See http://docs.jquery.com/Plugins/Authoring (near the bottom) for details.
*
* ADVANTAGES OF EITHER FRAMEWORK:
* - Encapsulates additional plugin action methods without polluting the jQuery.fn namespace
* - Ensures ability to use '$' even in compat modes
*
@RKAN
RKAN / gist:6040380
Created July 19, 2013 16:12 — forked from davist11/gist:2702312
/* * 'Highly configurable' mutable plugin boilerplate * Author: @markdalgleish * Further changes, comments: @addyosmani * Licensed under the MIT license */
/*
* 'Highly configurable' mutable plugin boilerplate
* Author: @markdalgleish
* Further changes, comments: @addyosmani
* Licensed under the MIT license
*/
// Note that with this pattern, as per Alex Sexton's, the plugin logic
// hasn't been nested in a jQuery plugin. Instead, we just use
// jQuery for its instantiation.
@RKAN
RKAN / jQueryPluginPatterns.js
Created July 19, 2013 16:13 — forked from addyosmani/jQueryPluginPatterns.js
A (very) WIP collection of optimized/recommended jQuery plugin patterns
/*
A (very) WIP collection of optimized/recommended jQuery plugin patterns
from @addyosmani, @cowboy, @ajpiano and others.
Disclaimer:
-----------------------
Whilst the end-goal of this gist is to provide a list of recommended patterns, this
is still very much a work-in-progress. I am not advocating the use of anything here
until we've had sufficient time to tweak and weed out what the most useful patterns
@RKAN
RKAN / find_distance.php
Created July 21, 2013 06:16
find distance between two longtude,latitude in PHP // Published in: PHP
<?php
function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longitude2) {
$theta = $longitude1 - $longitude2;
$miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)));
$miles = acos($miles);
$miles = rad2deg($miles);
$miles = $miles * 60 * 1.1515;
$feet = $miles * 5280;
$yards = $feet / 3;
$kilometers = $miles * 1.609344;
@RKAN
RKAN / facebook_auth.html
Created July 21, 2013 06:21
Facebook app login / authorization entirely client-side
<!--#
A complete HTML page for a Facebook "app" that does login entirely on the client.
1 - Create a Facebook application (see Facebook developer docs.).
2 - Because of a Facebook "bug" the app should have Sandbox Mode
disabled (App Settings - Advanced - Authentication).
3 - Uncomment the appropriate redirectUrl var. 4 - Update the appId and
redirectUrl vars with your Facebook app values. 5 - Make the page available from a server.
Thanks to http://www.guineacode.com/2011/facebook-app-authorization/
for the FB.getLoginStatus example that allows all the Facebook