Skip to content

Instantly share code, notes, and snippets.

@o3bvv
o3bvv / keybase.md
Created July 5, 2017 17:22
keybase.md

Keybase proof

I hereby claim:

  • I am oblalex on github.
  • I am oblalex (https://keybase.io/oblalex) on keybase.
  • I have a public key ASC1jRTbyevO2_U4soHZqV42KdtVoBErzytgEUv5GvKLwgo

To claim this, I am signing this object:

@o3bvv
o3bvv / Default.sublime-keymap
Last active May 7, 2017 13:53
Sublime settings
[
{ "keys": ["alt+c", "alt+up"], "command": "upper_case" },
{ "keys": ["alt+c", "alt+down"], "command": "lower_case" },
{ "keys": ["alt+c", "alt+t"], "command": "title_case" },
{ "keys": ["alt+c", "alt+s"], "command": "convert_to_snake"},
{ "keys": ["alt+c", "alt+m"], "command": "convert_to_camel"},
{ "keys": ["alt+c", "alt+p"], "command": "convert_to_pascal"},
{ "keys": ["alt+c", "alt+."], "command": "convert_to_dot"},
{ "keys": ["alt+c", "alt+-"], "command": "convert_to_dash"},
{ "keys": ["alt+c", "alt+w"], "command": "convert_to_separate_words"},
@o3bvv
o3bvv / console
Last active September 6, 2023 04:05
SSSHHH! Testing Python SSH client with auth via private key
# Install our dependencies
$ pip install -r <(wget -O- http://bit.ly/ssh_test_requirements)
# Generate key pair without password
$ ssh-keygen -t rsa -C "user@unicorn"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/alex/.ssh/id_rsa): user.key
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
@o3bvv
o3bvv / AJAX_CSRF.js
Created January 12, 2015 15:09
Setup Django's CSRF for AJAX
function get_cookie(name) {
var cookieValue = null
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';')
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i])
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1))
@o3bvv
o3bvv / dir-timer.js
Last active August 29, 2015 14:12
jQuery-backward-timer examples
$.backward_timer
methods: Object
_check_leading_zero: function (number) { ...
_is_exhausted: function() { ...
_on_tick: function (previous_delay) { ...
_render_seconds: function () { ...
_seconds_to_dhms: function (seconds) { ...
cancel: function () { ...
init: function (options) { ...
reset: function () { ...
@o3bvv
o3bvv / nginx.conf
Last active August 29, 2015 14:07
Nginx example
server {
listen 80;
server_name localhost;
location /api {
return 497; # Forbid execution of API calls via plain HTTP
}
location / {
rewrite ^ https://$host:443$request_uri? permanent;
@o3bvv
o3bvv / google_drive_api.py
Last active August 29, 2015 14:06
Example Python code for article http://bit.ly/ZekysY
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import httplib2
import os
from apiclient.discovery import build
from apiclient.http import MediaFileUpload
from oauth2client.client import SignedJwtAssertionCredentials
from oauth2client.file import Storage
@o3bvv
o3bvv / autodiscover.py
Last active December 9, 2016 20:17
Django module autodiscover
from imp import find_module
from importlib import import_module
import sys
def autodiscover_module(module_name, installed_apps=None):
if installed_apps is None:
from django.conf import settings
installed_apps = settings.INSTALLED_APPS
# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
AddressFamily any
ListenAddress ::
ListenAddress 0.0.0.0
Protocol 2
@o3bvv
o3bvv / celery-defaults
Last active August 29, 2015 13:56
Example settings for il2ec
# Python interpreter from environment.
ENV_PYTHON="/var/virtualenvs/il2ec/bin/python"
# Name of nodes to start
# here we have a single node
CELERYD_NODES="w1"
# or we could have three nodes:
# CELERYD_NODES="w1 w2 w3"
# Full path to the Django project directory.