Skip to content

Instantly share code, notes, and snippets.

@nmnp
nmnp / export.sh
Created January 1, 2020 22:55
set environment variables from .env file
#GNU systems
export $(grep -v '^#' .env | xargs -d '\n')
# BSD systems
export $(grep -v '^#' .env | xargs -0)
#link
https://stackoverflow.com/questions/19331497/set-environment-variables-from-file-of-key-value-pairs
@nmnp
nmnp / composer-config.md
Last active March 8, 2022 11:08
Could not authenticate against github.com composer error

Could not authenticate against github.com

This could be related to GitHub rate limits being reached. Specify your GitHub API token to avoid it.

For example by the following command:

composer config --global github-oauth.github.com <TOKEN> or inside your composer.json file:

@nmnp
nmnp / opcache_reset.php
Created July 3, 2018 23:09
reset opcache
<?php
opcache_reset();
@nmnp
nmnp / localstack_start.sh
Created June 18, 2018 01:02
start localstack docker with temp dir
TMPDIR=/private$TMPDIR localstack start --docker
@nmnp
nmnp / aws_cli_commands.sh
Last active February 4, 2021 10:17
aws/awslocal cli commands
# create function
# without environment variables
awslocal --endpoint-url=http://localhost:4574 lambda create-function --function-name=f1 --runtime=python3.6 --role=r1 --handler=coupon.handler --zip-file fileb://deployment_bundle.zip
#with environment varibles
awslocal --endpoint-url=http://localhost:4574 lambda create-function --function-name=f1 --runtime=python3.6 --role=r1 --handler=coupon.handler --zip-file fileb://deployment_bundle.zip --environment Variables='{HOST=localhost, USERNAME=root, PASSWORD=promoms, DATABASE=promoms, PORT=3306, REDIS_HOST=localhost, REDIS_PORT=6379, APP_NAME=promoms, APP_ENV=dev, PROMOTIONS_COUPONS_CACHE_KEY=promoms:coupons}'
# invoke function
awslocal lambda --endpoint-url=http://localhost:4574 invoke --function-name f1 --payload '{"coupon":"default"}' result.log
@nmnp
nmnp / pip.sh
Created June 13, 2018 23:22
Freeze PIP requirements
pip freeze -l > requirements.txt
@nmnp
nmnp / pipeline-execute.sh
Last active April 23, 2018 04:29
Execute wercker pipeline in local
#!/bin/bash
wercker --environment ./wercker/.env.wercker.unittest.sample deploy --pipeline unittest
@nmnp
nmnp / envAdder.js
Created February 12, 2018 06:02
Add environment variables to the wercker pipeline
async function getVar(env) {
for (v in env) {
var wait = ms=>new Promise((r,j)=>setTimeout(r, ms));
await wait(500);
var event = new Event('input',{
bubbles: true,
"cancelable": false
});
var click = new Event('click',{
@nmnp
nmnp / envToJSON.js
Created February 12, 2018 06:00
Generate JSON string of environment variables of a wercker pipeline
var envVar = {};
var tr = Array.from(
document.querySelectorAll("table")[0].querySelectorAll('tbody')[0].querySelectorAll('tr'));
tr.map((el)=>{
var tmp = [];
tmp[el.querySelectorAll('.envvarItem_key')[0].querySelectorAll('input')[0].value] = el.querySelectorAll('td')[1].querySelectorAll('.envvarItem_value')[0].querySelectorAll('.envvarItem_value_container')[0].querySelectorAll('textarea')[0].value;
envVar = Object.assign(envVar, tmp);
}
);
@nmnp
nmnp / DefinerRegex
Created May 25, 2015 04:07
mysql definer selector regex
find => DEFINER=`(.*?)`@`(.*?)`
replaceWith => DEFINER=`root`@`localhost`