Skip to content

Instantly share code, notes, and snippets.

View aznoisib's full-sized avatar

aznoisib aznoisib

View GitHub Profile
@aznoisib
aznoisib / codeiginter-server-config.md
Created April 23, 2019 18:06 — forked from yidas/codeiginter-server-config.md
Codeigniter 3 server configuration for Nginx & Apache

Codeigniter 3 server configuration for Nginx & Apache

Web Server Site Configuration

Recommended Apache Configuration

Use the following configuration in Apache's httpd.conf file or within a virtual host configuration. Note that you should set DocumentRoot and ServerName fit to your environment:

@aznoisib
aznoisib / unzip.php
Created August 1, 2019 23:50 — forked from kirtan403/unzip.php
PHP script to remotely zip/unzip archives of your FTP
<?php
function show($str){
echo $str . "<br/>\n";
flush();
ob_flush();
}
$archiveDir = "temp";
@aznoisib
aznoisib / download_file.php
Created August 2, 2019 02:57 — forked from saleemkce/download_file.php
PHP File Download Script - Download large file in chunks.
<?php
/*ini settings*/
set_time_limit(0);
ini_set('memory_limit', '512M');
//DOWNLOAD SCRIPT
$filePath = "G:/Software/versions/..PATH TO DOWNLOAD FILE...zip"; // set your download file path here.
download($filePath); // calls download function
function download($filePath)
{
@aznoisib
aznoisib / ftp_download.php
Created August 2, 2019 04:48 — forked from staatzstreich/ftp_download.php
Download a directory from an FTP Server
<?php
// ftp_sync - copy directory and file structure
// based on http://www.php.net/manual/es/function.ftp-get.php#90910
// main function witch is called recursivly
function ftp_sync($dir, $conn_id) {
if ($dir !== '.') {
if (ftp_chdir($conn_id, $dir) === FALSE) {
echo 'Change dir failed: ' . $dir . PHP_EOL;
return;
@aznoisib
aznoisib / attachment.php
Created August 2, 2019 09:07 — forked from ssut/attachment.php
UTF-8 file download function, support remote file passing(proxy) with http range header
<?php
/**
* PHP File download function.
* Version 1.4
*
* Copyright (c) 2014 성기진 Kijin Sung
* Modified by ssut
*
* License: MIT License (a.k.a. X11 License)
@aznoisib
aznoisib / gist:00d72915b513c2e6b9a1f35df8427008
Created August 2, 2019 09:07 — forked from voskobovich/gist:15ad5fc71e957bbe87d45cd88295f5b8
Video streamer from remote server by HTTP on PHP (Yii2)
/**
* @param $url
*/
public function actionStreamVideoFromCdn($url)
{
$headersCollection = Yii::$app->request->getHeaders();
$responseHeaders = [];
$chInfo = curl_init();
curl_setopt($chInfo, CURLOPT_URL, $url);
@aznoisib
aznoisib / xhr.js
Last active February 19, 2021 19:42 — forked from EtienneR/user.js
XMLHttpRequest RESTful (GET, POST, PUT, DELETE)
// Get all users
var url = "http://localhost:8080/api/v1/users";
var xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.onload = function () {
var users = JSON.parse(xhr.responseText);
if (xhr.readyState == 4 && xhr.status == "200") {
console.table(users);
} else {
console.error(users);
@aznoisib
aznoisib / browser_detect.js
Created August 29, 2019 10:10 — forked from Fl0pZz/browser_detect.js
JavaScript: Detect Browser
// browser detect
var BrowserDetect = {
init: function(userAgent, appVersion) {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(userAgent) || this.searchVersion(appVersion) || "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function(data) {
for (var i = 0; i < data.length; i++) {
var dataString = data[i].string;
@aznoisib
aznoisib / About.md
Created August 29, 2019 12:37 — forked from edm00se/About.md
Progress bar indicator (jQuery).
@aznoisib
aznoisib / submit.md
Created August 31, 2019 21:23 — forked from tanaikech/submit.md
Upload Files to Google Drive using Javascript

Upload Files to Google Drive using Javascript

This is a sample script for uploading files to Google Drive using Javascript. The files are uploaded by Drive API v3. gapi.client.drive.files.create() can create an empty file on Google Drive. But it cannot directly upload files including contents. I think that this might not be able to upload files and metadata with the multipart/related, although this might be resolved by the future update. So now, as one of workarounds, I use using XMLHttpRequest.

  • This sample uses gapi.
    • Before you use this, please enable Drive API at API console and carry out the installation of gapi.
  • When this script is run, a text file including "sample text" is created to Google Drive.
  • When you use this script, please set fileContent and metadata.

In this sample script, a text file including contents is created under a folder.