Skip to content

Instantly share code, notes, and snippets.

View strangeman's full-sized avatar
🚲
bicycles and crutches

Anton Markelov strangeman

🚲
bicycles and crutches
View GitHub Profile
- name: Generate uniq path
set_fact:
site_tmp_path: "/tmp/npm/{{ ansible_date_time.iso8601_micro | to_uuid }}"
- name: Create a {{ site_tmp_path }} directory if it does not exist
file:
path: '{{ site_tmp_path }}'
state: directory
become: false
@strangeman
strangeman / wipe_sentry_project.py
Created August 17, 2019 00:32
Remove all issues from Sentry project (need Python 3.7+)
import json
import requests
API_KEY="longrandomstring" # Sentry API key with event:admin scope
ORG_SLUG = "organization" # organization slug
PROJECT_SLUG = "nice-project" # project slug
SENTRY_ROOT = "https://sentry.example.com/" # root Sentry URL
BATCH_SIZE = 20 # how many issues deletes by one request (from 1 to 100)
headers = {'Authorization': f'Bearer {API_KEY}'}
@strangeman
strangeman / distance.rs
Created January 14, 2018 04:42
Vincenty formula for distance calculation (rewritten from https://github.com/asmarques/geodist/blob/master/vincenty.go)
use std::f64;
use std::f64::NAN;
fn vincenty_distance(lat1: f64, lon1: f64, lat2: f64, lon2: f64) -> f64 {
let a: f64 = 6378137.0;
let f: f64 = 1.0/298.257223563;
let b: f64 = 6356752.314245;
let epsilon: f64 = 1e-12;
@strangeman
strangeman / provisionViaSemaphore.groovy
Last active November 2, 2023 20:09
Semaphore API Call Snippet for Jenkins
echo "DEBUG: got project_id ${project_id} and template_id ${template_id}"
withCredentials([[$class: 'StringBinding', credentialsId: 'semaphore-token', variable: 'bearer']]) {
httpRequest acceptType: 'APPLICATION_JSON', consoleLogResponseBody: true, contentType: 'APPLICATION_JSON', customHeaders: [[name: 'Authorization', value: "Bearer ${env.bearer}"]], httpMode: 'POST', requestBody: """{
\"template_id\": ${template_id},
\"debug\": false,
\"dry_run\": false,
\"playbook\": \"\",
\"environment\": \"\"
}""", url: "https://ansible.ourdomain.com/api/project/${project_id}/tasks"
}
#!/usr/bin/env python
import sys, string, re, types
import yaml
from xml.dom import minidom
from xml.dom import Node
#

Keybase proof

I hereby claim:

  • I am strangeman on github.
  • I am strangeman (https://keybase.io/strangeman) on keybase.
  • I have a public key whose fingerprint is 10DB 437A 455A AD17 E086 5AFF 815E C530 5632 CC33

To claim this, I am signing this object:

@strangeman
strangeman / delete-files.py
Created July 15, 2016 05:28
Delete many files from nginx cache
from time import sleep
import os
path = '/var/cache/nginx/client_temp/'
for file_name in xrange(0, 9999999999):
file_path = '/var/cache/nginx/client_temp/'+str(file_name).zfill(10)
print 'trying to delete '+file_path
try:
os.remove(file_path)
@strangeman
strangeman / nginx.conf
Created February 4, 2015 06:16
Hiload nginx + php-fpm
worker_processes auto;
events {
use epoll;
worker_connections 1024;
multi_accept on;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
@strangeman
strangeman / varnish_wordpress
Created November 27, 2014 03:59
Varnish example for wordpress
backend default {
.host = "127.0.0.1";
.port = "8080";
}
acl purge {
"127.0.0.1";
"localhost";
}
@strangeman
strangeman / backup-all-databases.sh
Last active August 29, 2015 14:10
another simple script for backup mysql databases
#!/bin/bash
#create user for dump
#mysql> GRANT SHOW DATABASES, SELECT, LOCK TABLES, RELOAD ON *.* to dump@localhost IDENTIFIED BY 'dumppwd';
#mysql> FLUSH PRIVILEGES;
BACKUP_PATH=/mnt/mysqlbackup/dump
# make backup directory
mkdir -p $BACKUP_PATH