Skip to content

Instantly share code, notes, and snippets.

View dark-reiser's full-sized avatar

dark-reiser

View GitHub Profile
@dark-reiser
dark-reiser / append-css-link-or-rule.js
Created August 30, 2019 14:50 — forked from chrisyip/append-css-link-or-rule.js
Dynamically add CSS link or rule to DOM w/ pure JavaScript
@dark-reiser
dark-reiser / gist:a086f0df93fae56cea1fec06dd8e9e2e
Created July 13, 2019 14:52 — forked from feulf/gist:4587709
Keep the same PHP session between different domains

a simple idea is to force the session_id between the domains with an ajax call or an hidden iframe.

The concept is simple, you have [A,B,C] domains, where you create a script sid.php:

<?php session_id( $_GET['sid'] );

and a script sid_update.php that you have to place inside the PHP code of the front controller:

@dark-reiser
dark-reiser / formatArrayIntoComma.js
Created January 30, 2019 03:29 — forked from gayanvirajith/formatArrayIntoComma.js
Join the elements in an javascript array, but let the last separator be different eg: `and` / `or`
/*
* Join the elements in an javascript array,
* but let the last separator be different eg: `and` / `or`
* Stackoverflow link: http://stackoverflow.com/questions/15069587/is-there-a-way-to-join-the-elements-in-an-js-array-but-let-the-last-separator-b
* Credit: Chris Barr - http://stackoverflow.com/users/79677/chris-barr
*/
function formatArray(arr){
var outStr = "";
if (arr.length === 1) {
outStr = arr[0];
@dark-reiser
dark-reiser / DESIGN.md
Created April 19, 2018 12:15 — forked from yosriady/DESIGN.md
OAuth2 Authentication Microservices Design

Auth

Disclaimer

Creating an OAuth2 server is not a task that should be taken lightly. There are many security loopholes that could be exploited, and regular examinations are critical to handle possible vulnerabilities.

Introduction

Auth is an authentication microservice based on the OAuth2 identity delegation protocol.

@dark-reiser
dark-reiser / 2017-11-29_15-08-33.jpg
Created April 5, 2018 11:21 — forked from LuisErnestoZamb/2017-11-29_15-08-33.jpg
How setting up mysql as localhost and using this outside docker on Mac OS (accessing localhost mysql from docker) - The missing guide
2017-11-29_15-08-33.jpg
@dark-reiser
dark-reiser / Flask-Restful_S3_File_Upload.py
Created March 9, 2018 08:49 — forked from RishabhVerma/Flask-Restful_S3_File_Upload.py
Uploading a file to S3 while using Flask with Flask-Restful to create a REST API.
# -*- coding: utf-8 -*-
"""
An example flask application showing how to upload a file to S3
while creating a REST API using Flask-Restful.
Note: This method of uploading files is fine for smaller file sizes,
but uploads should be queued using something like celery for
larger ones.
"""
from cStringIO import StringIO
@dark-reiser
dark-reiser / gist:2fbbca70fdcbb1a3e42baa22c449aad6
Created February 26, 2018 08:25
Install Bookworm Ubuntu 16.04
sudo add-apt-repository ppa:elementary-os/daily
sudo add-apt-repository ppa:elementary-os/os-patches
sudo add-apt-repository ppa:bookworm-team/bookworm
sudo apt-get update
sudo apt-get install bookworm
@dark-reiser
dark-reiser / Install-Redis-Desktop-Manager.sh
Created February 26, 2018 07:49 — forked from thiagomgo/Install-Redis-Desktop-Manager.sh
Install Redis Desktop Manager from source on Ubuntu
# Clone the repository from GitHub
git clone --recursive https://github.com/uglide/RedisDesktopManager.git -b 0.8.0 rdm && cd ./rdm
# Compile the source
cd src/
./configure
source /opt/qt56/bin/qt56-env.sh && qmake && make
sudo checkinstall -D --install
sudo gdebi /home/$USER/rdm/src/src_*.deb
cd /usr/share/redis-desktop-manager/bin

Return Json

from flask import Flask, Response,

# return 
dat = ... # your JSON serialized data
resp = Response(response=dat,

status=200, \

@dark-reiser
dark-reiser / github_flask_oauth2.py
Created February 19, 2018 08:16 — forked from ib-lundgren/github_flask_oauth2.py
Example of how to use Flask with requests-oauthlib to fetch a GitHub user profile using an OAuth 2 token.
from requests_oauthlib import OAuth2Session
from flask import Flask, request, redirect, session, url_for
from flask.json import jsonify
import os
app = Flask(__name__)
# This information is obtained upon registration of a new GitHub
client_id = "<your client key>"