Skip to content

Instantly share code, notes, and snippets.

View mfyz's full-sized avatar
✌️

Mehmet Fatih Yıldız mfyz

✌️
View GitHub Profile
@mfyz
mfyz / capture.js
Last active August 29, 2015 13:57
Take snapshot of a webpage with phantomjs
// run this with phantomjs
//create new webpage object
//var page = new WebPage();
var page = require('webpage').create();
//load the page
page.open('http://mfyz.com', function (status) {
//fire callback to take screenshot after load complete
page.render('mfyz.png');
@mfyz
mfyz / counter.php
Created March 30, 2014 00:54
Simple Image Counter
<?php
// sample: <img src="counter.php?counter=total_visits">
function hex2rgb($color){
$color = str_replace('#', '', $color);
if (strlen($color) != 6){ return array(0,0,0); }
$rgb = array();
for ($x=0;$x<3;$x++){
$rgb[$x] = hexdec(substr($color,(2*$x),2));
@mfyz
mfyz / social_counts.html
Created March 30, 2014 03:22
Get social counts via javacript
<!doctype html>
<html>
<head>
<title>Page</title>
</head>
<body>
<script type="text/javascript" charset="utf-8">
// Tiny object for getting counts
var socialGetter = (function() {
/* just a utility to do the script injection */
@mfyz
mfyz / website.js
Last active August 29, 2015 14:24
express basic http auth
var express = require('express');
var app = express();
var fs = require('fs');
var auth = express.basicAuth(function(user, pass) {
return user === 'test' && pass === 'pass';
});
app.get('/', auth, function(req, res) {
res.setHeader('Content-Type', 'text/html');
@mfyz
mfyz / framer-tap-fix.js
Last active September 25, 2015 14:56
Framerjs scrollcomponent scroll and tap conflict solution.
var tapStartX, tapStartY;
list_item.on(Events.TouchStart, function(e){ tapStartX = e.pageX; tapStartY = e.pageY; });
list_item.on(Events.TouchEnd, function(e){
if (Math.abs(e.pageX - tapStartX) < 20 && Math.abs(e.pageY - tapStartY) < 20) {
// real tap happened
}
});
@mfyz
mfyz / index.html
Created October 25, 2015 22:15
jQuery Date Range Slider Example with an Angular Web App Wrapper
<!DOCTYPE html>
<html ng-app="webApp">
<head>
<title>Title</title>
<meta charset="utf-8">
<script src="jquery-1.11.3.min.js"></script>
<script src="jquery-ui-1.11.4/jquery-ui.min.js"></script>
<!-- http://ghusse.github.io/jQRangeSlider/ -->
<script src="jQRangeSlider-5.7.1/jQDateRangeSlider-min.js"></script>
@mfyz
mfyz / convert.php
Last active December 15, 2015 00:49
html to pdf conversion using doc converter api
<?php
//set POST variables
$url = 'http://c.docverter.com/convert';
$fields = array('from' => 'html',
'to' => 'pdf',
'input_files[]' => "@/".realpath('input.html').";type=text/html; charset=UTF-8",
);
$ch = curl_init();
@mfyz
mfyz / social_counts.php
Created March 24, 2013 04:04
Getting social (facebook, twitter, +1) counts of a url via php
<?php
function get_tweets($url) {
$json_string = file_get_contents('http://urls.api.twitter.com/1/urls/count.json?url=' . $url);
$json = json_decode($json_string, true);
return intval( $json['count'] );
}
function get_likes($url) {
@mfyz
mfyz / url.php
Created April 9, 2013 04:39
php update url variables
<?
function update_url($_data, $url = NULL){
if (!$url) $url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$_url = parse_url($url);
if (isset($_url['query']) AND $_url['query']) parse_str($_url['query'], $_params);
else $_params = array();
$_updated_params = array_merge($_params, $_data);
@mfyz
mfyz / Change Font.sketchplugin
Last active February 12, 2016 14:17 — forked from bomberstudios/Change Font.sketchplugin
Change font family for all text layers in Sketch
// Change font (ctrl a)
var doc = context.document,
selection = context.selection,
font_name = [doc askForUserInput:"Font name:" initialValue:"SF UI Display"];
function check_layer(layer){
log(layer)
var className = layer.className()
log("Checking layer " + layer + " of klass: " + className)
if (className == "MSTextLayer") {