Skip to content

Instantly share code, notes, and snippets.

View bastula's full-sized avatar
🤠
See you space cowboy...

Aditya Panchal bastula

🤠
See you space cowboy...
View GitHub Profile
@caseydm
caseydm / app.py
Last active September 27, 2021 14:48
Flask API Pagination
from flask import Flask
from flask_marshmallow import Marshmallow
from flask_sqlalchemy import SQLAlchemy
from models import Magazine
from utils import build_link_header, validate_per_page
app = Flask(__name__)
db = SQLAlchemy(app)
ma = Marshmallow(app)
@progrium
progrium / README.md
Last active April 7, 2024 21:42
Setting up M1 Macs for x86 development with Homebrew

Key Points

  • In general, binaries built just for x86 architecture will automatically be run in x86 mode
  • You can force apps in Rosetta 2 / x86 mode by right-clicking app, click Get Info, check "Open using Rosetta"
  • You can force command-line apps by prefixing with arch -x86_64, for example arch -x86_64 go
  • Running a shell in this mode means you don't have to prefix commands: arch -x86_64 zsh then go or whatever
  • Don't just immediately install Homebrew as usual. It should most likely be installed in x86 mode.

Homebrew

Not all toolchains and libraries properly support M1 arm64 chips just yet. Although

@jarbro
jarbro / symantec-vip-access-totp.md
Last active May 31, 2024 15:00
Generate Symantec VIP Access Token as TOTP

Generate Symantec VIP Access Token as OTP

Recently I came across a web service that required two-factor authentication using the Symantec VIP Access App. I already manage all of my OTP tokens in a different app (If you are on iOS I highly recommend using OTP Auth by Roland Moers.) and did not want to have to use yet another app to generate the TOTP.

There is a way to generate a Symantec VIP Access compatible token very easily if you have access to an environment which can run Python PIP. I happen to have Ubuntu Windows Subsystem Linux running on my machine. (If you are running Windows 10 and don't have this you should really check it out.) Let's get started...

hello

Instructions

Here we install python3-pip and qrencode so we can generate our secret, I

@npearce
npearce / install-docker.md
Last active May 28, 2024 20:22
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@brianz
brianz / __init__.py
Last active February 15, 2021 10:29
SQLAchemy helpers and mixins
import contextlib
from contextlib import contextmanager
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.pool import NullPool
from sqlalchemy_utils import database_exists, create_database
@teoliphant
teoliphant / simple_interpolation.py
Last active April 16, 2023 09:30
Vectorized linear interpolation
# The kernel function is
# roughtly equivalent to new[:] = np.interp(xnew, xvals, yvals)
# But this is broadcast so that it can be run many, many times
# quickly.
# Call using ynew = interp1d(xnew, xdata, ydata)
# ynew.shape will be xnew.shape
# Also, ydata.shape[-1] must be xdata.shape[-1]
# and if ydata or xdata have ndim greater than 1, the initial dimensions
# must be xnew.shape:
@ndabAP
ndabAP / App.vue
Last active November 22, 2021 00:42
Vue.js pluralize filter
<template>
<div>
<p>I got {{ amount }} {{ 'cookie' | pluralize(amount) }}</p>
<button @click="decrement">Decrement</button>
</div>
</template>
<script>
export default {
data: () => ({
@tobywf
tobywf / clean_old_lambda_versions.py
Last active April 11, 2024 06:52
A quick script to remove old AWS Lambda function versions
from __future__ import absolute_import, print_function, unicode_literals
import boto3
def clean_old_lambda_versions():
client = boto3.client('lambda')
functions = client.list_functions()['Functions']
for function in functions:
versions = client.list_versions_by_function(FunctionName=function['FunctionArn'])['Versions']
for version in versions:
@dmahugh
dmahugh / comparision.py
Created May 23, 2017 17:21
comparison of asynchronous HTTP requests (aiohttp/asyncio) and traditional sequential requests (with Requests library)
"""Comparison of fetching web pages sequentially vs. asynchronously
Requirements: Python 3.5+, Requests, aiohttp, cchardet
For a walkthrough see this blog post:
http://mahugh.com/2017/05/23/http-requests-asyncio-aiohttp-vs-requests/
"""
import asyncio
from timeit import default_timer
@colophonemes
colophonemes / create_triggers
Last active February 17, 2024 15:15
Postgres TRIGGER to call NOTIFY with a JSON payload
CREATE TRIGGER person_notify AFTER INSERT OR UPDATE OR DELETE ON income
FOR EACH ROW EXECUTE PROCEDURE notify_trigger(
'id',
'email',
'username'
);
CREATE TRIGGER income_notify AFTER INSERT OR UPDATE OR DELETE ON income
FOR EACH ROW EXECUTE PROCEDURE notify_trigger(
'id',