Skip to content

Instantly share code, notes, and snippets.

View adnanhz's full-sized avatar
🎯
Focusing

Adnan Hamzeh adnanhz

🎯
Focusing
View GitHub Profile
public function blobUpload(Request $request){
$pathresolver = new \FileUpload\PathResolver\Simple($_SERVER['DOCUMENT_ROOT'].env('temp_location'));
$filesystem = new \FileUpload\FileSystem\Simple();
$fileupload = new \FileUpload\FileUpload(file_get_contents('php://input'), $_SERVER);
$filenamegenerator = new \FileUpload\FileNameGenerator\Random(5);
$fileupload->setPathResolver($pathresolver);
$fileupload->setFileSystem($filesystem);
$fileupload->setFileNameGenerator($filenamegenerator);
list($files, $headers) = $fileupload->processAll();
import PropTypes from 'prop-types'
import React, { Component } from 'react'
import Flexbox from 'flexbox-react';
import { connect } from 'react-redux';
import { push, goBack } from 'react-router-redux';
import './GetStarted.css';
import Header from "../../../components/Header/Header";
import ActionBar from '../../../components/ActionBar/ActionBar';
import { Container, Button, Icon } from 'semantic-ui-react';
@adnanhz
adnanhz / New NodeJS version on CentOS.md
Last active February 19, 2019 10:14
Install New NodeJS on CentOS

Install New NodeJS on CentOS

So you've probably tried installing node naively via yum install node and got a very old version.

Here's what you should do:

sudo curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
sudo yum install -y nodejs
<?php
error_reporting(E_ALL);
$file = $_GET['file']; // a remote file url
$headers = array_change_key_case(get_headers($file, TRUE));
$filesize = $headers['content-length'];
@adnanhz
adnanhz / App.js
Created March 27, 2019 10:59
React Navigation with paths
import React from "react";
import { createStackNavigator } from "react-navigation";
import { createAppContainer } from 'react-navigation';
import ContentWrappersScreen from "../features/mediaFeatures/contentWrapper/screens/ContentWrappersScreen";
import MediaItemsScreen from "../features/mediaFeatures/mediaItem/screens/MediaItemsScreen";
import MediaItemPdfScreen from "../features/mediaFeatures/mediaItem/screens/MediaItemPdfScreen";
import MediaItemAudioScreen from "../features/mediaFeatures/mediaItem/screens/MediaItemAudioScreen";
import MediaItemVideoScreen from "../features/mediaFeatures/mediaItem/screens/MediaItemVideoScreen";
import MediaItemsFilterScreen from "../features/mediaFeatures/mediaItem/screens/MediaItemsFilterScreen";
<?php
[...]
$user = $this->createUserIfNotExists($request);
Auth::login($user);
$token = $user->createToken("Personal Access Client")->accessToken;
if ($request->custom_content_url) {
return redirect()->away($request->custom_content_url."&username=".Auth::user()->username."&token=".$token);
}
@adnanhz
adnanhz / Laravel + Vue deployment on VPS.md
Last active June 25, 2019 11:25
How to deploy a Laravel+Vue project to a subfolder in a server

How to deploy laravel + vue to production on a subfolder

  1. composer install, check your env, run key:generate, npm install, all that sh!t. (If you need the full steps comment below)
  2. npm run prod, that will build all Vue stuff and put them in the /public laravel folder
  3. open your Vue router file and set the route base to the subdir (without public, with / at start and end, so if you're deploying to /demo/foo/, type "/demo/foo" as the base). 3.1. You can google how to set route base in vue
  4. go back to the Laravel folder, rename server.php to index.php
  5. copy css, js, assets, fonts, favicon.ico and .htaccess from public folder to root of Laravel project folder
  6. that's it, try accessing your site now
@adnanhz
adnanhz / Wordpress relocation.md
Created June 23, 2019 12:16
Relocating Wordpress to a new folder on a server

How to move Wordpress to a new location on a server

  1. Assuming we want to move from /demo/foo/ to /demo/bar
  2. Copy /demo/foo/ to /demo/bar
  3. Make ESPECIALLY sure that the .htaccess file in foo has been copied to bar, because cp might not copy it in some cases.
  4. Open the .htaccess file and change RewriteBase to /demo/bar.
  5. Change the last RewriteRule to RewriteRule . /demo/bar/index.php [L]
  6. Save & exit htaccess.
  7. You should now get a 404 page when you open the website.
  8. Go to your database and open wp_options table, you will find 2 rows containing the website url, change them accordingly.