Skip to content

Instantly share code, notes, and snippets.

@randy-ran
randy-ran / install.sh
Created October 9, 2023 08:44 — forked from gffcoutinho/install.sh
Install Chrome, ChromeDriver and Selenium on Ubuntu 18.04
#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c
# http://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver
# http://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception
# http://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal
# http://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04
# Versions
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
@randy-ran
randy-ran / async_await_with_subprocesses.py
Created February 25, 2023 16:12 — forked from eriseven/async_await_with_subprocesses.py
Async and await with subprocesses
"""Async and await example using subprocesses
Note:
Requires Python 3.6.
"""
import sys
import time
import platform
import asyncio
// Created by STRd6
// MIT License
// jquery.paste_image_reader.js
(function($) {
var defaults;
$.event.fix = (function(originalFix) {
return function(event) {
event = originalFix.apply(this, arguments);
if (event.type.indexOf('copy') === 0 || event.type.indexOf('paste') === 0) {
event.clipboardData = event.originalEvent.clipboardData;
@randy-ran
randy-ran / nginx_auto_start.sh
Created October 9, 2021 09:48 — forked from aymanosman/nginx_auto_start.sh
Nginx: Start nginx on boot on Mac
# brew install nginx
sudo ln -s /usr/local/opt/nginx/homebrew.mxcl.nginx.plist /Library/LaunchDaemons/
sudo chown root:wheel /usr/local/opt/nginx/homebrew.mxcl.nginx.plist
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
# Why do you need sudo?
# If you want nginx to be able to bind to port 80, it will need superuser privileges
@randy-ran
randy-ran / php-fpm
Created April 18, 2020 07:46 — forked from dgoujard/php-fpm
/etc/logrotate.d/php-fpm
/var/log/php-fpm/*.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
sharedscripts
postrotate
[ ! -f /var/run/php-fpm/php-fpm.pid ] || kill -USR1 `cat /var/run/php-fpm/php-fpm.pid`
@randy-ran
randy-ran / setup.sh
Created December 11, 2019 05:59 — forked from marulitua/setup.sh
Instal php5.6 with phpbrew on ubuntu 18.04
#!/bin/bash
# Instal php5.6 with phpbrew on ubuntu 18.04
# Install all dependencies
sudo apt update
sudo apt install wget php build-essential libxml2-dev libxslt1-dev libbz2-dev libcurl4-openssl-dev libmcrypt-dev libreadline-dev libssl-dev autoconf
wget https://github.com/phpbrew/phpbrew/raw/master/phpbrew
chmod +x phpbrew
mv phpbrew /usr/local/bin
@randy-ran
randy-ran / rounding_decimals.md
Created March 5, 2018 03:41 — forked from jackiekazil/rounding_decimals.md
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value

test cacher
@randy-ran
randy-ran / nginx_access_log_parser.py
Last active November 21, 2017 09:04 — forked from shenfeng/nginx_access_log_parser.py
[parse nginx access log in python] parse nginx access log in python #log
def seg_access_log(line):
delimiters = {'[': ']', '"': '"'}
idx, start, count, delimiter, results = 0, 0, len(line), ' ', []
while 1:
idx = line.find(delimiter, start)
delimiter = ' ' # reset
if idx < 0:
break
@randy-ran
randy-ran / openssl.ssh
Created November 15, 2017 16:12 — forked from mbejda/openssl.ssh
Installing OpenSSL 1.0.2 on Ubuntu 14
openssl version -a
sudo add-apt-repository ppa:0k53d-karl-f830m/openssl
sudo apt-get update
sudo apt-get install openssl
openssl version -a