Skip to content

Instantly share code, notes, and snippets.

View SergeyKozlov's full-sized avatar

Sergey Kozlov SergeyKozlov

View GitHub Profile
@SergeyKozlov
SergeyKozlov / s3.sh
Created March 22, 2023 17:21 — forked from chrismdp/s3.sh
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@SergeyKozlov
SergeyKozlov / curl.md
Created February 5, 2023 18:56 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@SergeyKozlov
SergeyKozlov / remove.sh
Created February 2, 2023 09:40 — forked from sxiii/remove.sh
Docker Swarm - Remove all Down nodes automatically
#!/bin/bash
# Requirements: linux, docker, grep, awk
# This script removes all "Down" (off) nodes from Docker Swarm
# Useful to clean stuff from time to time, if you have auto-joining nodes for example
sudo docker node rm $(sudo docker node ls | grep Down | awk -F" " '{ print $1 }')
@SergeyKozlov
SergeyKozlov / Makefile
Created December 16, 2022 21:06 — forked from mpneuried/Makefile
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)
@SergeyKozlov
SergeyKozlov / GitLabCIGitRepoCloneDockerfile
Created November 20, 2022 19:10 — forked from jonashackt/GitLabCIGitRepoCloneDockerfile
Clone a GitLab git repository inside a Dockerfile/build run inside GitLab CI
# Add the following key to the 'Deploy Keys' section in Settings/Repository of your GitLab repository
# Dockerfile:
FROM centos:7
ARG SSH_KEY_GITLAB_DEPLOY_KEY
RUN \
### ssh configuration, see https://docs.gitlab.com/ee/ci/ssh_keys/#ssh-keys-when-using-the-docker-executor
# run ssh-agent inside build environment
eval $(ssh-agent -s); \
@SergeyKozlov
SergeyKozlov / xdebug-mac.md
Created November 12, 2022 22:45 — forked from ankurk91/xdebug-mac.md
php xDebug v3 on Ubuntu/Mac and phpStorm

🪲 Install and Configure xDebug v3 on MacOS for PhpStorm 🐘

  • Assuming that you have already installed php and apache via Homebrew

  • Install xDebug php extension

pecl channel-update pecl.php.net
pecl clear-cache

pecl install xdebug
@SergeyKozlov
SergeyKozlov / save.php
Created May 4, 2020 21:14 — forked from techslides/save.php
Save Ajax POST data as a file with PHP
<?php
//error_reporting(E_ALL);
//var_dump($_SERVER);
$post_data = $_POST['data'];
if (!empty($post_data)) {
$dir = 'YOUR-SERVER-DIRECTORY/files';
$file = uniqid().getmypid();
$filename = $dir.$file.'.txt';
$handle = fopen($filename, "w");
fwrite($handle, $post_data);
@SergeyKozlov
SergeyKozlov / template-download
Created March 29, 2019 20:28 — forked from elmariachi111/template-download
JQuery-File-Upload templates written in Mustache / Handlebars
<tr class="template-download fade">
{{#error}}
<td></td>
<td class="name"><span>{{name}}</span></td>
<td class="size"><span></span></td>
<td class="error" colspan="2">
<span class="label label-important">{{error}}</span></td>
{{/error}}
{{^error}}
@SergeyKozlov
SergeyKozlov / gist:ffdcf821c7908d15ef1c6d7316ed9317
Created September 24, 2018 04:59 — forked from danielgwood/gist:1510463
Human formatted time between dates (JavaScript)
/**
* Given two dates (or one date and assume "now" for the second), convert this to
* a human-readable string, like "2 months".
*
* I use this to put "3 months ago" strings into plugins. My use case has the date
* coming in as a seconds-only UNIX epoch, so the params are expected at this.
*
* @param time1 integer Number of seconds since UNIX epoch
* @param time2 integer Number of seconds since UNIX epoch
* @return string
@SergeyKozlov
SergeyKozlov / Rakefile.rb
Created July 6, 2018 08:05 — forked from Epictetus/Rakefile.rb
How to do automatic backup with Heroku PGBackups and Heroku Cron. http://carlhoerberg.com/automatic-backup-of-heroku-database-to-s3
require 'aws/s3'
require 'heroku'
require 'heroku/command'
require 'heroku/command/auth'
require 'heroku/command/pgbackups'
task :cron do
class Heroku::Auth
def self.client
Heroku::Client.new ENV['heroku_login'], ENV['heroku_passwd']