Skip to content

Instantly share code, notes, and snippets.

View yasirtaher's full-sized avatar
🏠
Working from home

Yasir Taher yasirtaher

🏠
Working from home
View GitHub Profile
@yasirtaher
yasirtaher / PhpJava.java
Created September 2, 2016 04:03 — forked from avafloww/PhpJava.java
This snippet of code is syntactically valid in both PHP and Java, and produces the same output in both.
/*<?php
//*/public class PhpJava { public static void main(String[] args) { System.out.printf("/*%s",
//\u000A\u002F\u002A
class PhpJava {
static function main() {
echo(//\u000A\u002A\u002F
"Hello World!");
}}
//\u000A\u002F\u002A
PhpJava::main();
@yasirtaher
yasirtaher / github-pages-demo-project.sh
Created June 25, 2016 09:11
Show project demo github pages
git checkout --orphan gh-pages
git rm -rf
rm '.gitignore'
git commit -a -m "commit"
git push -f origin gh-pages
@yasirtaher
yasirtaher / draggable-for-touch-device.js
Created June 25, 2016 07:51
JS Drag and Drop for touch devices
//source: http://stackoverflow.com/questions/5186441/javascript-drag-and-drop-for-touch-devices
function touchHandler(event) {
var touch = event.changedTouches[0];
var simulatedEvent = document.createEvent("MouseEvent");
simulatedEvent.initMouseEvent({
touchstart: "mousedown",
touchmove: "mousemove",
touchend: "mouseup"
}[event.type], true, true, window, 1,
$page = ! empty( $_GET['page'] ) ? (int) $_GET['page'] : 1;
$total = count( $yourDataArray ); //total items in array
$limit = 20; //per page
$totalPages = ceil( $total/ $limit ); //calculate total pages
$page = max($page, 1); //get 1 page when $_GET['page'] <= 0
$page = min($page, $totalPages); //get last page when $_GET['page'] > $totalPages
$offset = ($page - 1) * $limit;
if( $offset < 0 ) $offset = 0;
$yourDataArray = array_slice( $yourDataArray, $offset, $limit );
@yasirtaher
yasirtaher / prevent-to-go-back.js
Last active April 28, 2016 09:04
prevent a browser from going back in history
//prevent to go back
history.pushState(null, null, location.href);
window.onpopstate = function(event) {
history.go(1);
};
//convert image binary
function files_to_urls(files, callback) {
if (files.length > 0) {
var promises = [].map.call(files, function (file) {
return new Promise(function (ok, ng) {
var reader = new FileReader();
reader.onload = function (ev) {
ok(reader.result);
};
reader.onabort = function (ev) {
@yasirtaher
yasirtaher / remove-autostart-apache.sh
Created February 3, 2016 04:43
remove autostart of apache on macosx
sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist
@yasirtaher
yasirtaher / run-mysql.sh
Last active January 31, 2016 08:07
start mysql from terminal
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
@yasirtaher
yasirtaher / Install-laravel.sh
Last active February 2, 2016 09:20
Install laravel
Install Composer: curl -sS https://getcomposer.org/installer | php
Move to global: sudo mv composer.phar /usr/local/bin/composer
Check Composer: php composer.phar
Install Laravel: composer create-project laravel/laravel (directory)
cd (directory)
run on port: php -S localhost:8000 -t public
input, textarea {
outline: none;
border:1px solid #ccc !important;
box-shadow:none !important;
}