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 / recursive_ftp.py
Created December 31, 2016 18:09
Recursive FTP Upload
import sys,os,zipfile,ftplib, configargparse
from os.path import basename
def ftp_login(user,passwd,host,port=21,timeout=30):
try:
ftp = ftplib.FTP()
ftp.connect(host, port, timeout)
ftp.login(user, passwd)
return ftp
except ftplib.all_errors as e:
@subhashdasyam
subhashdasyam / recursive_ftp_local_remote.py
Created January 1, 2017 05:10
Recursive FTP with Local and remote paths
import sys,os,zipfile,ftplib, configargparse
from os.path import basename
def ftp_login(user,passwd,host,port=21,timeout=30):
try:
ftp = ftplib.FTP()
ftp.connect(host, port, timeout)
ftp.login(user, passwd)
return ftp
except ftplib.all_errors as e:
@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
@subhashdasyam
subhashdasyam / php_ffmpeg.php
Created January 19, 2017 08:25
FFmpeg PHP
<?php
$ffmpegpath = "ffmpeg.exe";
$input = 'wattan.flv';
$output = 'wattan.jpg';
if (make_jpg($input, $output)){
echo 'success';
}else{
echo 'bah!';
}
@subhashdasyam
subhashdasyam / json_to_ul.html
Last active April 14, 2019 17:20
Unordered List to Json
# HTML FILE
<div id="res">
</div>
# JAVASCRIPT