Skip to content

Instantly share code, notes, and snippets.

Avatar
🚲
bicycles and crutches

Anton Markelov strangeman

🚲
bicycles and crutches
View GitHub Profile
View upload static to AWS
- 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+)
View wipe_sentry_project.py
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)
View distance.rs
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 October 7, 2017 18:02
Semaphore API Call Snippet for Jenkins
View provisionViaSemaphore.groovy
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"
}
View Xml2Yaml.py
#!/usr/bin/env python
import sys, string, re, types
import yaml
from xml.dom import minidom
from xml.dom import Node
#
View keybase.md

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
View delete-files.py
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 / ZabbixApacheUpdater.py
Created October 7, 2013 23:43
Monitoring Apache
View ZabbixApacheUpdater.py
#!/usr/bin/python
""" Fetch Apache stats via mod_status and send to Zabbix
By Paulson McIntyre
Patches by:
Zach Bailey <znbailey@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
@strangeman
strangeman / template_memcache.xml
Created October 7, 2013 23:31
Memcache monitoring
View template_memcache.xml
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export version="1.0" date="09.06.10" time="10.53">
<hosts>
<host name="Template_Memcache">
<proxy_hostid>0</proxy_hostid>
<useip>1</useip>
<dns></dns>
<ip>127.0.0.1</ip>
<port>10050</port>
<status>3</status>
View send_lsws_stats.pl
#!/usr/bin/perl
#
# Get latest LiteSpeed Web Server stats
#
# somewhere from zabbix forums
#
# add to cron:
#* * * * * /etc/zabbix/scripts/send_lsws_stats.pl --host=client.com --server=server.com > /dev/null 2>&1
#
use English '-no_match_vars';