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 / resize.as
Created July 21, 2013 06:29
Full screen image resize (proportionate)
image.height = stage.stageHeight;
image.width = stage.stageWidth;
image.scaleX = image.scaleY = Math.max( image.scaleX, image.scaleY );
@RKAN
RKAN / force_download.php
Created July 21, 2013 06:26
force download
<?php
function force_download($filename = '', $data = false, $enable_partial = true, $speedlimit = 0)
{
if ($filename == '')
{
return FALSE;
}
if($data === false && !file_exists($filename))
return FALSE;
@RKAN
RKAN / clean_user_input.php
Created July 21, 2013 06:24
PHP Functions to Clean User Input
<?php
function cleanInput($input) {
$search = array(
'@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments
);
@RKAN
RKAN / xcurl.php
Created July 21, 2013 06:23
Perfect cURL Function
<?php
function xcurl($url,$ref=null,$post=array(),$ua="Mozilla/5.0 (X11; Linux x86_64; rv:2.2a1pre) Gecko/20110324 Firefox/4.2a1pre",$print=false) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
if(!empty($ref)) {
curl_setopt($ch, CURLOPT_REFERER, $ref);
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
@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
@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 / 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 / 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.
// 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 / .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/
?>