Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Mobile Detect Library
* =====================
*
* Motto: "Every business should have a mobile detection script to detect mobile readers"
*
* Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets).
* It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
*
@subhashdasyam
subhashdasyam / php_curl_file_upload.php
Last active January 4, 2017 05:37
File Upload via PHP Curl
<?php
# Credit to Weslly
# Based on https://bountify.co/php-curl-api-uploader
// download the zip file
file_put_contents("file_to_upload.zip", fopen("http://someurl/file_to_upload.zip", 'r'));
// set the API Token
$api_token = "APITOKEN";
@subhashdasyam
subhashdasyam / wordpress_per_day_posts_past_30_days.php
Last active January 7, 2017 15:43
Wordpress Get Per Day posts for past 30 days
<?php
//Last 30 days dates
$dates = array();
for($i = 0; $i < 30; $i++) {
$dates[] = array('day'=> date("d", strtotime('-'. $i .' days')), 'month'=>date("m", strtotime('-'. $i .' days')), 'year'=>date("Y", strtotime('-'. $i .' days')));
}
//Vars
@subhashdasyam
subhashdasyam / google_visualization.html
Created January 7, 2017 20:35
Wordpress Post Stats with Google Visualisation
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.charts.load('current', {'packages':['corechart']});
@subhashdasyam
subhashdasyam / maze_recursion.py
Last active January 9, 2017 04:33
Maze Recursion 100x100 n 200x200
import random
import sys
sys.setrecursionlimit(5000)
def make_maze(columns=20, rows=20):
columns = columns / 2
rows = rows / 2
visited = [[0] * columns + [1] for _ in range(rows)] + [[1] * (columns + 1)]
@subhashdasyam
subhashdasyam / optimize.php
Last active January 24, 2017 22:37
Little Utils from bountify
<?php
/*
Make sure that /tmp/check.json has permissions to read and write
It is better to create /tmp/check.json manually
type below commands if you are using only php
sudo echo > /tmp/check.json
sudo chmod 777 /tmp/check.json
sudo chown www-data:www-data /tmp/check.json
<?php
class LittleUtils{
private static $systemRequirementsJsonFilePath;
/**
* Checks if system meets requirements
* @return string If all the requirements are satisfied then it return "Success" else "Error message"
*/
private function __checkSystemRequirements(){
@subhashdasyam
subhashdasyam / kc_fab.js
Created January 30, 2017 19:11
Floating Bubble
/*===================================================================
= KC.FAB : Materialize Floating Action Button =
===================================================================*/
/*
* Copyright 2015 Mark Luk
* Released under the MIT license
* https://github.com/katrincwl/kc_fab/blob/master/LICENSE
*
* @author: Mark Luk
* @version: 1.0
@subhashdasyam
subhashdasyam / kc_fab.css
Created January 30, 2017 19:12
kc_fab.css
.kc_fab_overlay{
z-index: 9998;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 10;
background-color: rgba(255,255,255,0.5); /*dim the background*/
}
@subhashdasyam
subhashdasyam / index.html
Last active January 30, 2017 19:26
Floating Bubble
<html>
<head>
<link rel="stylesheet" href="https://cdn.rawgit.com/subhashdasyam/6504ee6d41ad4ef179308ec49cb76800/raw/87903a06a737590da2d8fdfe754471f0d9b66b65/kc_fab.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://cdn.rawgit.com/subhashdasyam/ba2b8b862c0fc69d343dd1a7f75c51ea/raw/1be1ca66a51c2f5a645d83e3d1b036287793f467/kc_fab.js"></script>
</head>
<body>