Skip to content

Instantly share code, notes, and snippets.

@temamagic
temamagic / postgres_dump_restore.yml
Created August 9, 2023 10:42
Postgres dump & restore with Ansible
---
- name: Create PostgreSQL database dumps
hosts: host-from
become: yes
vars:
database_names:
- DBNAME
tasks:
- name: Utility present
ansible.builtin.package:
@temamagic
temamagic / pg_exporter_setup.sh
Created July 18, 2023 18:26
Postgres prometheus exporter Installer script (Ubuntu)
#!/bin/bash
# Install required packages curl, jq, and wget if not already installed
sudo apt-get install -y curl jq wget
# Send GET request to GitHub API and retrieve the content
response=$(curl -s "https://api.github.com/repos/prometheus-community/postgres_exporter/releases/latest")
# Use awk to extract the tag_name value from the JSON response
VERSION=$(echo "$response" | awk -F'"' '/tag_name/{print $4}')
@temamagic
temamagic / index.html
Created August 9, 2020 01:59
Vue Funnel Graph JS - Animated Chart
<div id="app">
<div class="controls">
<button @click="getNextSet()">Change Data</button>
<button @click="toggleDirection()">Toggle Direction</button>
<button @click="toggleGradient()">Toggle Gradient Direction</button>
</div>
<div class="funnels">
<vue-funnel-graph :width="width" :height="height" :labels="labels" :values="values" :colors="colors" :sub-labels="subLabels" :direction="direction" :gradient-direction="gradientDirection" :animated="true" :display-percentage="true"></vue-funnel-graph>
</div>
</div>
@temamagic
temamagic / submit.md
Created November 2, 2019 16:17 — forked from tanaikech/submit.md
spreadsheets.values.batchUpdate using Golang

spreadsheets.values.batchUpdate using Golang

Flow :

In my sample script, the script was made using the Quickstart. The flow to use this sample script is as follows.

  1. For Go Quickstart, please do Step 1 and Step 2.
  2. Please put client_secret.json to the same directory with my sample script.
  3. Copy and paste my sample script, and create it as new script file.
  4. Run the script.
  5. When Go to the following link in your browser then type the authorization code: is shown on your terminal, please copy the URL and paste to your browser. And then, please authorize and get code.
  6. Put the code to the terminal.
@temamagic
temamagic / curl.md
Created July 25, 2019 18:51 — 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.

@temamagic
temamagic / testbot.js
Created March 23, 2018 14:29
Тестирование бота на JS с помощью TDLib Telegram
/*
* Автор https://t.me/johnnyidoe
*/
const {Client} = require('tglib');
const client = new Client({
apiId: 'apiId',
apiHash: 'apiHash',
phoneNumber: '7XXXXXXXXXX'
});
@temamagic
temamagic / classify.py
Created March 22, 2018 00:32 — forked from bwbaugh/classify.py
Detecting a Specific Watermark in a Photo with Python Get example training and testing images here: <http://bwbaugh.com/stack-overflow/16222178_watermark.tar> Stack Overflow question: <http://stackoverflow.com/questions/16222178/detecting-a-specific-watermark-in-a-photo-with-python-without-scipy>
# Copyright (C) 2013 Wesley Baugh
"""Tools for text classification.
Extracted from the [infer](https://github.com/bwbaugh/infer) library.
"""
from __future__ import division
import math
from collections import defaultdict, namedtuple, Counter
from fractions import Fraction
@temamagic
temamagic / readme.md
Last active July 20, 2017 18:49 — forked from endolith/readme.md
How to stream a webcam to a web browser in Ubuntu

Grr this took hours to figure out. I was trying to install MJPG-streamer and running VLC command lines and all this crap but nothing worked.

First install motion:

~> sudo apt-get install motion

Then create a config file:

~> mkdir ~/.motion

~> nano ~/.motion/motion.conf

wget https://github.com/wcgallego/pecl-gearman/archive/master.zip
unzip master.zip
cd pecl-gearman-master
phpize
./configure
make install
echo "extension=gearman.so" > /etc/php/7.0/mods-available/gearman.ini
phpenmod -v ALL -s ALL gearman
service php7.0-fpm restart