Skip to content

Instantly share code, notes, and snippets.

View SlyDen's full-sized avatar

Denys Slipetskyy SlyDen

View GitHub Profile
@SlyDen
SlyDen / shell.md
Last active October 16, 2024 08:55
Shell tips

Usefull shell snippets

Set java home

export JAVA_HOME="$(dirname $(dirname $(realpath $(which javac))))"
plugins {
// …
id("org.springframework.boot") version "2.1.5.RELEASE"
}
apply(plugin = "io.spring.dependency-management")
the<DependencyManagementExtension>().apply {
imports {
mavenBom("example:bom:1.0")
@SlyDen
SlyDen / wait-for-container.sh
Created June 4, 2018 13:05
got from bitbucket example - wait for container shell script
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <container-id>"
exit 1
fi
function getContainerHealth {
docker inspect --format "{{json .State.Health.Status }}" $1
}
@SlyDen
SlyDen / getURLParameter.js
Created March 22, 2018 13:15 — forked from daniyalzade/getURLParameter.js
Get URL parameter in javascript
function getURLParameter(name) {
var val = (RegExp('[?|&]' + name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1];
return val ? decodeURI(val) : val;
}
@SlyDen
SlyDen / docker-xenial-copy-paste.sh
Created March 9, 2017 13:08 — forked from BretFisher/docker-xenial-copy-paste.sh
Install Docker PPA on Ubuntu 16.04
# NOT FOR SHELL SCRIPT, but rather just for quick copy paste
# this is a copy-paste version with defaults of the full shell script docker-xenial.sh which is below this one in gist.
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D && \
mkdir -p /etc/apt/sources.list.d && \
echo deb https://apt.dockerproject.org/repo ubuntu-xenial main > /etc/apt/sources.list.d/docker.list && \
service lxcfs stop && apt-get remove -y -q lxc-common lxcfs lxd lxd-client && \
apt-get update -q && apt-get upgrade -y -q && \
apt-get install -y -q docker-engine && \
mkdir -p /etc/systemd/system/docker.service.d && \
@SlyDen
SlyDen / docker-socket.sh
Created March 2, 2017 13:16
Docker for Mac: run ... com.bmuschko.gradle.docker
socat TCP-LISTEN:2375,reuseaddr,fork UNIX-CONNECT:/var/run/docker.sock &
export DOCKER_HOST=tcp://localhost:2375
unset DOCKER_TLS_VERIFY
@SlyDen
SlyDen / xdg.go
Created February 28, 2017 16:24
Most commonly-used modern Linux distributions use the XDG Base Directory Specification http://benaiah.me/posts/configuring-go-apps-with-toml/
import (
"path/filepath"
"os"
"runtime"
"github.com/mitchellh/go-homedir"
)
var configDirName = "example"
// app/models/post.js
export default DS.Model.extend({
body: DS.attr(),
comments: DS.hasMany(),
addComment(commentData) {
let store = Ember.getOwner(this).lookup('service:store');
let comment = store.createRecord('comment', commentData);
this.get('comments').pushObject(comment);
return comment.save().then(() => {
return this.save();
@SlyDen
SlyDen / postgres-notify-trigger.sql
Created February 16, 2017 15:03 — forked from bithavoc/postgres-notify-trigger.sql
I used this trigger to notify table changes via NOTIFY (migrating off RethinkDB)
CREATE OR REPLACE FUNCTION notify_trigger() RETURNS trigger AS $$
DECLARE
channel_name varchar DEFAULT (TG_TABLE_NAME || '_changes');
BEGIN
IF TG_OP = 'INSERT' THEN
PERFORM pg_notify(channel_name, '{"id": "' || NEW.id || '"}');
RETURN NEW;
END IF;
IF TG_OP = 'DELETE' THEN
PERFORM pg_notify(channel_name, '{"id": "' || OLD.id || '"}');
(define-key dired-mode-map (kbd "<M-return>") 'shell-instead-dired)
(define-key dired-mode-map (kbd «K») 'dired-do-kill-lines)
(define-key dired-mode-map (kbd «k») 'dired-previous-line)
(define-key dired-mode-map (kbd «J») 'dired-goto-file)
(define-key dired-mode-map (kbd «j») 'dired-next-line)
(define-key dired-mode-map (kbd «M-p») 'ace-window)
(define-key dired-mode-map (kbd «M-q») 'ace-window)
(define-key dired-mode-map (kbd "/") 'helm-occur)
;; в любом режиме Alt+hjkl ведут себя как обычный vim