Skip to content

Instantly share code, notes, and snippets.

@alpap
alpap / _service.md
Created June 20, 2017 23:09 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
local ret_status="%(?:%{$fg_bold[green]%} ▶ :%{$fg_bold[red]%} ▶ )"
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
RPS1="${return_code}" # ❦☙♨☁⚠⛬
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}%{$fg[yellow]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%} %{$fg[red]%}♨"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%}"
@alpap
alpap / index.html
Last active October 9, 2018 09:17
MIthrilJs Test
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script src="//unpkg.com/mithril/mithril.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/randomcolor/0.5.2/randomColor.min.js"></script>
@alpap
alpap / salt-ssh.md
Created September 14, 2018 15:09
Salt-ssh

Salt ssh deployment

Simple

  • Install the salt-ssh.

    sudo apt install salt-ssh
// card reader
document.onkeypress = function(e) {
e = e || window.event;
var charCode = (typeof e.which == "number") ? e.which : e.keyCode;
// store it , in this example, i use localstorage
if(localStorage.getItem("card") && localStorage.getItem("card") != 'null') {
// append on every keypress
localStorage.setItem("card", localStorage.getItem("card") + String.fromCharCode(charCode));
} else {
using System;
using System.Collections;
using System.Collections.Generic;
using Bizzkit.PIM.EndToEndTests.Helper.SeleniumTests.Helper;
using Bizzkit.PIM.EndToEndTests.Pages;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
@alpap
alpap / Untitled-1
Created October 31, 2018 14:28
servicemd
cat <<'EOF' > /etc/systemd/system/beepkg.service
[Unit]
Description=beepkg
AssertPathExists=/usr/local/beepkg
[Service]
WorkingDirectory=/usr/local/beepkg
ExecStart=/usr/local/beepkg/beepkg
@alpap
alpap / preactTest.js
Created April 17, 2019 11:29
preact test
export default class TodoList extends Component {
state = { todos: [], text: '', count: 0 };
setText = e => {
this.setState({ text: e.target.value });
};
addTodo = () => {
let { todos, text, count } = this.state;
todos = todos.concat({ text: text, id: count++ });
this.setState({ todos, text: '', count: count++ });
};
@alpap
alpap / cleanWin.bat
Created June 7, 2019 12:54
Clean your windows installation
@rem *** Disable Some Service ***
sc stop DiagTrack
sc stop diagnosticshub.standardcollector.service
sc stop dmwappushservice
sc stop WMPNetworkSvc
sc stop WSearch
sc config DiagTrack start= disabled
sc config diagnosticshub.standardcollector.service start= disabled
sc config dmwappushservice start= disabled
@alpap
alpap / postgres.sh
Last active July 25, 2019 13:22 — forked from mrw34/postgres.sh
Enabling SSL for PostgreSQL in Docker
#!/bin/bash
set -euo pipefail
openssl req -new -text -passout pass:abcd -subj /CN=localhost -out server.req
openssl rsa -in privkey.pem -passin pass:abcd -out server.key
openssl req -x509 -in server.req -text -key server.key -out server.crt
chmod 600 server.key
chown 70 server.key
docker run -d --name postgres -v $PWD/server.crt:/var/lib/postgresql/server.crt:ro -v $PWD/server.key:/var/lib/postgresql/server.key:ro postgres:11-alpine -c ssl=on -c ssl_cert_file=/var/lib/postgresql/server.crt -c ssl_key_file=/var/lib/postgresql/server.key