Skip to content

Instantly share code, notes, and snippets.

View nikitagashkov's full-sized avatar
🔧
Trust me, I'm an engineer.

Nikita Gashkov nikitagashkov

🔧
Trust me, I'm an engineer.
View GitHub Profile
@com30n
com30n / fix-dns.sh
Last active September 30, 2020 09:44
#!/bin/bash
# Fix DNS recornds after Cisco AnyConnect connection
sudo scutil << EOF
open
get State:/Network/Service/com.cisco.anyconnect/DNS
d.add ServerAddresses * 127.0.0.1
set State:/Network/Service/com.cisco.anyconnect/DNS
quit
#!/bin/bash
# Tanks to: https://gist.github.com/ogrrd/5831371
# Update your homebrew installation
brew up
# Install dnsmasq
brew install dnsmasq
mkdir -pv $(brew --prefix)/etc/
@com30n
com30n / vpn.sh
Last active September 15, 2020 14:55
Cisco AnyConnect Automatic connection script
#!/bin/bash
if [[ -n $DEBUG ]]; then
set -xe
fi
ldap_password_keychain_name=LDAP
second_factor_secret_keychain_name=2Factor
vpn_server=$2
vpn_group_index=$3
-- 1. To authorize via Touch ID you must apply this script: https://gist.github.com/RichardBronosky/31660eb4b0f0ba5e673b9bc3c9148a70
-- 2. Create a new password entry in Keychain Access called "LDAP" with your ldap password
-- 3. Create a new password entry in Keychain Access called "2Factor" with your 2factor token
-- 4. Install oath-toolkit. (brew install oath-toolkit)
-- 5. Open this script in Script Editor (both this and the above are in the Applications->Utilities folder) and "Save as.." an Application (.app) with desired name.
-- 6. Open Security & Privacy System Preferences, go to Privacy, Accessibility.
-- 7. Enable the above .app so it can access Accessibility
-- 8. Add the new .app to /Users/[yourshortname]/Applications with a shortcut to your Dock
-- 9. Enjoy the fast connection with no need to enter password and increased security of not having a sensitive password stored as plain text.
@kirillgashkov
kirillgashkov / README.md
Last active January 21, 2019 18:34
Sublime Text 3 command that creates a new file inheriting the syntax of the active one.

Installation

Manual

  1. Put SugaryNewFileCommand.py under Packages/User
  2. Add new key binding { "keys": ["super+n"], "command": "sugary_new_file" }
  3. Done.
@RichardBronosky
RichardBronosky / touchid_sudo.sh
Last active June 21, 2024 12:00
Use TouchID for sudo on modern MacBook Pro machines
#!/bin/bash
# curl -sL https://gist.githubusercontent.com/RichardBronosky/31660eb4b0f0ba5e673b9bc3c9148a70/raw/touchid_sudo.sh | bash
# This script is ready to copy-paste in whole, or just the line above (without the leading #)
# Use TouchID for sudo on modern MacBook Pro machines
# This script adds a single line to the top of the PAM configuration for sudo
# See: https://apple.stackexchange.com/q/259093/41827 for more info.
touchid_sudo(){
@ar45
ar45 / custom_serializers.py
Last active August 31, 2022 14:23
Dynamic QuerySet serializer
from rest_framework import serializers
from django.db.models.manager import Manager
from django.db.models.query import QuerySet
class LimitQuerySetSerializerFieldMixin:
"""
Serializer mixin with a special `get_queryset()` method that lets you pass
@hirokiky
hirokiky / README.md
Created June 8, 2015 00:31
Dynamic locust tasks

Dynamic tasks for locust.io

Install

pip install locustio

Try it

@shadowmint
shadowmint / gist:7004832
Last active March 23, 2024 22:19
Kivy example using sqlalchemy to build a layout.
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import sessionmaker
from sqlalchemy import ForeignKey
from sqlalchemy.orm import relationship, backref
from kivy.graphics import Rectangle
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.widget import Widget
@jackiekazil
jackiekazil / rounding_decimals.md
Last active January 17, 2024 12:29
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value