Skip to content

Instantly share code, notes, and snippets.

View einnar82's full-sized avatar
🎯
Doing nice things.

Rannie Ollit einnar82

🎯
Doing nice things.
View GitHub Profile
@einnar82
einnar82 / gist:4f8c3054448157db14daf608f35715be
Created October 25, 2021 07:23 — forked from kitek/gist:1579117
NodeJS create md5 hash from string
var data = "do shash'owania";
var crypto = require('crypto');
crypto.createHash('md5').update(data).digest("hex");
<?php
//answer for https://www.testdome.com/questions/php/file-owners/11840?visibility=17&skillId=5
class FileOwners
{
public static function groupByOwners($files)
{
$result=array();
foreach($files as $key=>$value)
{
$result[$value][]=$key;
@einnar82
einnar82 / README.md
Created September 8, 2021 09:01 — forked from hakre/README.md

Extend from SoapClient Examples

Just a collection gist of some assorted example SOAPClients. Code must not be stable or useful under all circumstances, these are examples. Most of the code is outdated, so you won't need to use it any longer in production code. I've just collected and compiled this together out of interest, the information normally is scattered around.

If you need to a start with PHP's SOAPClient start with the PHP manual page of it and read through the comments as well. Double check with exisiting bug-reports if given as many things are fixed since a comment was left.

const axios = require('axios').default;
axios.interceptors.request.use(x => {
const headers = {
...x.headers.common,
...x.headers[x.method],
...x.headers
};
@einnar82
einnar82 / sqlsrv-php7.2.sh
Created May 10, 2021 06:33 — forked from LegitDongo/sqlsrv-php.sh
SQLSRV PHP 7.2 Drivers that work for Laravel Homestead
# Best if added to `after.sh` so that this gets run every time the box is provisioned
# composer won't be able to download updates with an active proxy, and will hang trying to get the newest file
# You may want to comment this out based on your network configuration
sudo bash -c 'echo "export NO_PROXY=*" >> ~/.profile'
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install php7.2-dev php7.2-xml mcrypt php-pear php-mbstring unixodbc unixodbc-dev -y --allow-unauthenticated
@einnar82
einnar82 / laravel-nginx-config-make-http-exception-url-and-make-all-others-https.md Laravel nginx config to redirect all requests to https and an exception URL that can still be accessible via http

Pre-condition

One day in your Laravel app, you were required to redirect all http requests to https but need to make a certain URL route accessible via http for a certain reason; perhaps a portion of your javascript code needs to redirect to http URL but it can't because redirection to secure URL to insecure is prohibited. Therefore, in cases like this, you need to just allow just one URL to make an http connection.

NOTE: There are obvious security implications here so don't just follow this blindly and understand if this is really the solution you're looking for. The nginx config can somehow be improved, I just don't have the time yet. It sure do look redundant.

Understanding and examples

  • Redirect everything from http to https
@einnar82
einnar82 / submit.md
Created December 8, 2020 05:10 — forked from tanaikech/submit.md
Upload Files to Google Drive using Javascript

Upload Files to Google Drive using Javascript

News

At October 11, 2019, I published a Javascript library to to run the resumable upload for Google Drive. When this is used, the large file can be uploaded. You can also use this js library.

Description

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 carr
@einnar82
einnar82 / docker-php-ext-install.md
Created July 8, 2020 23:58 — forked from giansalex/docker-php-ext-install.md
docker-php-ext-install Reference
RUN apt update
RUN apt upgrade -y
RUN apt install -y apt-utils
RUN a2enmod rewrite
RUN apt install -y libmcrypt-dev
RUN apt install -y libicu-dev
RUN docker-php-ext-install -j$(nproc) intl
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ 
@einnar82
einnar82 / django_crash_course.MD
Created April 9, 2020 03:25 — forked from bradtraversy/django_crash_course.MD
Commands for Django 2.x Crash Course

Django Crash Course Commands

# Install pipenv
pip install pipenv
# Create Venv
pipenv shell
@einnar82
einnar82 / stripNamespaceFromClassName.php
Created December 21, 2018 08:12 — forked from jasondmoss/stripNamespaceFromClassName.php
Strip the namespace from the class to get the actual class name
<?php
/**
* Strip the namespace from the class to get the actual class name
*
* @param string $obj Class name with full namespace
*
* @return string
* @access public
*/