Skip to content

Instantly share code, notes, and snippets.

@Bogdaan
Bogdaan / install-php_7.4.0.sh
Created December 13, 2021 13:30 — forked from abenevaut/# install php 7.4.0.md
Install phpbrew && php 7.4.0 on macOS
xcode-select --install
# You should install brew https://brew.sh/index_fr
brew install automake autoconf curl pcre bison re2c mhash libtool icu4c gettext jpeg openssl libxml2 mcrypt gd gmp libevent zlib libzip bzip2 imagemagick pkg-config oniguruma
brew link --force icu4c
brew link --force openssl
brew link --force libxml2
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew
chmod +x phpbrew
@Bogdaan
Bogdaan / visualization.ipynb
Created February 21, 2020 10:28 — forked from oinume/visualization.ipynb
Visualization MySQL data in Jupyter Notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Bogdaan
Bogdaan / Dockerfile
Created December 2, 2019 14:53 — forked from PurpleBooth/Dockerfile
Create a static binary in go and put it in a from scratch docker container
FROM golang:1.9
WORKDIR /go/src/github.com/purplebooth/example
COPY . .
RUN go build -ldflags "-linkmode external -extldflags -static" -a main.go
FROM scratch
COPY --from=0 /go/src/github.com/purplebooth/example/main /main
CMD ["/main"]
@Bogdaan
Bogdaan / leaky_bucket.lua
Created March 25, 2019 11:06 — forked from florentchauveau/leaky_bucket.lua
Redis script (Lua) to implement a leaky bucket
-- Redis script to implement a leaky bucket
-- see https://medium.com/callr-techblog/rate-limiting-for-distributed-systems-with-redis-and-lua-eeea745cb260
-- (c) Florent CHAUVEAU <[email protected]>
local ts = tonumber(ARGV[1])
local cps = tonumber(ARGV[2])
local key = KEYS[1]
-- remove tokens < min (older than now() -1s)
local min = ts -1
@Bogdaan
Bogdaan / github_oauth_token.md
Created November 22, 2018 11:45 — forked from ozh/github_oauth_token.md
Get a Github OAuth token from the CLI with curl

At the command line:

curl -u ':USERNAME' -d '{"scopes":["public_repo"],"note":"Google Issues to GH"}' https://api.github.com/authorizations
curl -H "Authorization: bearer :TOKEN" https://api.github.com/users/:USERNAME -I

Replace :USERNAME with your Github username and :TOKEN with the oauth token you get from first curl

After that, the token will be listed in your Applications and you can revoke it from there

@Bogdaan
Bogdaan / object-to-form-data.js
Created October 30, 2018 20:34 — forked from ghinda/object-to-form-data.js
JavaScript Object to FormData, with support for nested objects, arrays and File objects. Includes Angular.js usage.
// takes a {} object and returns a FormData object
var objectToFormData = function(obj, form, namespace) {
var fd = form || new FormData();
var formKey;
for(var property in obj) {
if(obj.hasOwnProperty(property)) {
if(namespace) {
@Bogdaan
Bogdaan / reload-nginx.sh
Created September 21, 2018 07:07 — forked from jrumbut/reload-nginx.sh
Reload nginx process manually by sending HUP signal
#!/bin/bash
kill -HUP `cat /var/run/nginx.pid`
@Bogdaan
Bogdaan / varexport.php
Created September 10, 2018 12:31
PHP var_export() with short array syntax (square brackets) indented 4 spaces
<?php
function varexport($expression, $return=FALSE) {
$export = var_export($expression, TRUE);
$export = preg_replace("/^([ ]*)(.*)/m", '$1$1$2', $export);
$array = preg_split("/\r\n|\n|\r/", $export);
$array = preg_replace(["/\s*array\s\($/", "/\)(,)?$/", "/\s=>\s$/"], [NULL, ']$1', ' => ['], $array);
$export = join(PHP_EOL, array_filter(["["] + $array));
if ((bool)$return) return $export; else echo $export;
}
@Bogdaan
Bogdaan / Install AMQP for PHP
Created July 16, 2018 07:20 — forked from TemporaryJam/Install AMQP for PHP
How to install the PHP AMQP library
#install cmake
yum install cmake
#install libtool
yum install libtool
#install a perl pkgconfig requirement
yum install perl-ExtUtils-PkgConfig.noarch
#get rabbitmq-c library
@Bogdaan
Bogdaan / gist:8ed956b1c6b44e4cd607cc473823ae05
Created May 22, 2018 16:44 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote