Skip to content

Instantly share code, notes, and snippets.

View oxalorg's full-sized avatar
:shipit:
Always Be Coding

Mitesh oxalorg

:shipit:
Always Be Coding
View GitHub Profile
@oxalorg
oxalorg / Example log
Created July 31, 2023 06:20 — forked from dspezia/Example log
Assessing pending activity of a Redis server
> ~/tcp_redis_monitor.py 6379
Timestamp Nb TX bytes RX bytes TX RMA RX RMA
1333983822.943 1 0 0 0.000 0.000
1333983823.193 1 0 0 0.000 0.000
1333983824.194 1 0 0 0.000 0.000
1333983825.195 1 0 0 0.000 0.000
1333983826.196 1 0 0 0.000 0.000
@oxalorg
oxalorg / auto_ssh_keys
Last active February 12, 2021 16:41 — forked from plexus/auto_ssh_keys
#!/usr/bin/env bash
# Import SSH keys from Github to ~/.ssh/authorize_keys for all members of a
# given Github organization.
#
# Will replace authorized_keys, if it looks like authorized_keys was not
# previously created by this script then a backup copy is made.
#
# Depends on jq, will download it if not available (assumes Linux) to ~/bin/jq
#
@oxalorg
oxalorg / emacs lock buffer to window with tabbar
Created December 31, 2020 06:39 — forked from ShingoFukuyama/emacs lock buffer to window with tabbar
Stick/Lock buffer to window, compatible with tabbar.el. Emacs
;; http://lists.gnu.org/archive/html/help-gnu-emacs/2007-05/msg00975.html
(defvar sticky-buffer-previous-header-line-format)
(define-minor-mode sticky-buffer-mode
"Make the current window always display this buffer."
nil " sticky" nil
(if sticky-buffer-mode
(progn
(set (make-local-variable 'sticky-buffer-previous-header-line-format)
@oxalorg
oxalorg / script-template.sh
Created December 15, 2020 08:31 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
trap cleanup SIGINT SIGTERM ERR EXIT
usage() {
cat <<EOF
@oxalorg
oxalorg / views.py
Created August 24, 2020 06:54 — forked from alee/views.py
Django Discourse SSO endpoint adapted from https://meta.discourse.org/t/sso-example-for-django/14258 - depends on settings.py DISCOURSE_BASE_URL and DISCOURSE_SSO_SECRET
import base64
import hmac
import hashlib
from urllib import parse
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseBadRequest, HttpResponseRedirect
from django.conf import settings
@login_required
@oxalorg
oxalorg / Build.xml
Created January 9, 2020 04:24 — forked from NickCraver/Build.xml
Stack Overflow Build Reference Docs
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="PrepareStaticContent" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Passed in Parameters -->
<configuration></configuration>
<workingDir></workingDir>
<buildNumber></buildNumber>
<buildViews>false</buildViews>
<minifyJs>true</minifyJs>
<TargetsDirectory></TargetsDirectory>
@oxalorg
oxalorg / yt-embed.js
Created March 30, 2017 06:58 — forked from do18/yt-embed.js
If you are concerned about web site performance, you probably noticed that embedded YouTube iframes are costly. Instead of iframes, you may embed images that link to the respective videos, and make these links replace themselves with iframes when clicked. (IE 9+ because of getElementsByClassName.)
/*jshint maxlen: 79 */
var MYSITE = MYSITE || {};
/**
* Make YouTube links with .yt-embed replace themselves with YouTube iframes
* when clicked. The first child element is assumed to be the img element
* holding the poster frame. The YouTube URL must contain the "v" parameter,
* but no further parameters. The data-yt-options attribute may hold iframe
* URL parameters.
@oxalorg
oxalorg / template.py
Created March 3, 2017 06:38 — forked from jamescasbon/template.py
Pure python templates using with statement
"""
A really stupid python template language inspired by coffeekup, markaby.
Do not use this code, it will ruin your day. A byproduct of insomnia.
TL;DR
-----
This module defines a template language that allows us to do:
d = Doc()
@oxalorg
oxalorg / mynote.xml
Created October 16, 2016 03:45 — forked from xiaoganghan/mynote.xml
Parsing Evernote export file (.enex) using Python
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export2.dtd">
<en-export export-date="20120727T073610Z" application="Evernote" version="Evernote Mac 3.0.5 (209942)">
<note><title>Vim Tips</title><content><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
<en-note style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
yank for copy, delete for cut, put for parse
<div><br/></div>
<div>Move in context, not position</div>
<div>/ search forward</div>
@oxalorg
oxalorg / reference-markdown-metadata-from-jinja-template.py
Created January 27, 2016 02:16 — forked from glombard/reference-markdown-metadata-from-jinja-template.py
How to use Markdown as a filter in a Jinja2 template, and then extract the Markdown Meta property directly from the template. Assuming you want to use the Meta-data value before rendering the converted Markdown content (e.g. in the html head), the trick is to render the markdown first, save it to a variable (html_content in this example) using a…
from pprint import pprint
import jinja2
import markdown
HTML_TEMPLATE = """{% macro get_html() %}
{{ content | markdown }}
{% endmacro %}
{% set html_content = get_html() %}
Title from Markdown meta-data: {{ get_title() }}