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 / 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 / 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 / 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 / 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 / new_gist_file
Created July 21, 2013 06:31
View trace() output in JavaScript console
//import ExternalInterface class use this instead of trace() to view output in JavaScript console
public function log(_t:String):void{
if(ExternalInterface.available){
ExternalInterface.call("console.log", _t );
}
}
@RKAN
RKAN / preloader.as
Created July 21, 2013 06:35
Create a Preloader class in Actionscript 3
/*
* main.fla -> main.as
*/
package
{
import flash.display.MovieClip;
import flash.events.Event;
/**
* ...
@RKAN
RKAN / embeed_font.as
Created July 21, 2013 06:36
Font embedding Font embedding and prevention of anti aliasing which is good for bitmap fonts:
//Embedding the font:
[Embed(source="FONT.ttf", fontName = "myFont", mimeType = "application/x-font-truetype", advancedAntiAliasing="true", embedAsCFF="false")]
private var myEmbeddedFont:Class;
//Creating the textformat:
var defaultTextFormat : TextFormat = new TextFormat('myFont');
//Applying the font to a textfield:
myTextField.defaultTextFormat = Config.defaultTextFormat;
myTextField.embedFonts = true;
@RKAN
RKAN / tween_3d.as
Created July 21, 2013 06:38
Tween3D - 3D Deformation Resolver&Helper
package tr.com.gotoandrock.utils
{
import com.greensock.TweenLite;
import flash.display.DisplayObject;
import flash.geom.Matrix;
/**
* Helps 3d tranformation applied target back to normal 2D Matrix and look&feel :)
* Should only use tween ends with if z value equal 0;
@RKAN
RKAN / embed_assets.as
Created July 21, 2013 06:41
Simple Asset Manager with Embed Style
//AssetManager.as
// usage: AssetManager.getInstance.getAssetByName("MonaLisa");
package
{
import flash.utils.describeType;
import flash.utils.getDefinitionByName;
public class AssetManager
{
@RKAN
RKAN / output_flashvars.as
Created July 21, 2013 06:44
Writing FlashVars to TextField
var tf:TextField = new TextField();
tf.autoSize = TextFieldAutoSize.LEFT;
tf.border = true;
addChild(tf);
tf.x = 200;
tf.y = 200;
tf.multiline = true;
tf.height = 200;
tf.appendText("params:" + "\n");