Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@yevrah
yevrah / Upgrade vim
Last active September 25, 2023 05:11
Update to Vim8 on Centos 7
################################################################################
# Method 1: Install using rpm packages (credit to DarkMukke)
#
rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm
rpm --import http://mirror.ghettoforge.org/distributions/gf/RPM-GPG-KEY-gf.el7
# WARNING: removing vim-minimal uninstalls `sudo` if you skip the second step
# make sure to at least run `yum install sudo`
yum -y remove vim-minimal vim-common vim-enhanced
@yevrah
yevrah / distances.py
Created October 14, 2014 01:03
Python using free map tools to calculate distance as the crows fly
import requests
import math
from BeautifulSoup import BeautifulSoup
def distance_on_unit_sphere(lat1, long1, lat2, long2):
"src: http://www.johndcook.com/python_longitude_latitude.html"
degrees_to_radians = math.pi/180.0
phi1 = (90.0 - lat1)*degrees_to_radians
phi2 = (90.0 - lat2)*degrees_to_radians
@yevrah
yevrah / remove-pass.vb
Last active June 8, 2021 02:26
Excel: Remove Excel Password
' src: http://www.mcgimpsey.com/excel/removepwords.html
'
' Removing Internal XL passwords
'
' Note: For a discussion of File or VBA Project password protection, see here.
'
' Internal XL passwords are about as useful for security as tissue paper. The
' reason is that the passwords you enter (i.e., with Tools/Protect/Protect
' Worksheet or /Protect Workbook) are not used directly in protection. Instead
' they are hashed (mathematically transformed) into a much less secure code.
@yevrah
yevrah / nodejs-cheatsheet.js
Created March 14, 2019 05:52 — forked from LeCoupa/nodejs-cheatsheet.js
Complete Node.js CheatSheet --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
/* *******************************************************************************************
* THE UPDATED VERSION IS AVAILABLE AT
* https://github.com/LeCoupa/awesome-cheatsheets
* ******************************************************************************************* */
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@yevrah
yevrah / amazon_sender.py
Created July 15, 2019 06:49 — forked from amix/amazon_sender.py
Amazon SES helper script using boto
# -*- coding: utf-8 -*-
"""
amazon_sender.py
~~~~~~~~
Python helper class that can send emails using Amazon SES and boto.
The biggest feature of this class is that encodings are handled properly.
It can send both text and html emails.
This implementation is using Python's standard library (which opens up for a lot more options).
@yevrah
yevrah / CoreTest.pl
Created November 15, 2015 23:47
Perl: Ovverride core perl routines
#!/usr/bin/env perl
# See my post on http://stackoverflow.com/questions/33725298/perl-disable-shell-access
# Ref: https://github.com/Perl/perl5/blob/blead/lib/CORE.pod
BEGIN {
*CORE::GLOBAL::system = sub {
die('Do not use system calls.');
};
@yevrah
yevrah / log_to_table.sql
Last active September 11, 2018 03:51
MySQL: Log to table
-- Turn on table based logging
set global log_output = 'TABLE';
-- Turn on general log
set global general_log = 'ON';
-- Log everything to slow query log
set global log_slow_queries = 1;
set global long_query_time = 0.000001;
@yevrah
yevrah / flask.py
Created July 6, 2018 00:45
Flask: Annotated Boilerplate.
# A very simple Flask Hello World app for you to get started with...
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello from Flask!'
@yevrah
yevrah / Upgrade vim
Created February 7, 2018 22:10
Update to Vim8 on Centos 7
# You may use this CentOS 7 repository on Fedora Copr for Vim 8 builds.
# https://copr.fedorainfracloud.org/coprs/mcepl/vim8/
#
# Run these commands on CentOS 7.
# Add this repository:
sudo curl -L https://copr.fedorainfracloud.org/coprs/mcepl/vim8/repo/epel-7/mcepl-vim8-epel-7.repo -o /etc/yum.repos.d/mcepl-vim8-epel-7.repo
# Upgrade Vim to vim 8:
@yevrah
yevrah / romanize.py
Last active October 13, 2017 04:40
Roman Numerals
#!/usr/bin/env python3
# encoding: utf-8
class Romanize():
# Values from https://www.math.nmsu.edu/~pmorandi/math111f01/RomanNumerals.html
numbers = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
numeral = [ 'm', 'cm', 'd', 'cd', 'c', 'xc', 'l', 'xl', 'x', 'ix', 'v', 'iv', 'i']
def calculate(number):
out = ""