Skip to content

Instantly share code, notes, and snippets.

View devraj's full-sized avatar
🚀
Building

Dev Mukherjee devraj

🚀
Building
View GitHub Profile
@devraj
devraj / helm_install.tf
Last active July 5, 2023 04:19
HCL clip to install your own apps via terraform
# This demonstrates the deployment of our application via a helm chart
# which is hosted in Github container registry
resource "helm_release" "lab-python-mock-server" {
name = "lab-python-mock-server"
repository = "oci://ghcr.io/anomaly/charts"
chart = "lab-python-mock-server"
namespace = "lab-python-mock-server"
create_namespace = true
@devraj
devraj / rename_sequential.sh
Last active September 12, 2023 02:05
Takes the contents a folder and renames them into filenames with sequential file names e.g 001.jpg, 002,jpg
let counter=1;\
for filename in *; do\
new_filename=$(printf "%03d.png" $counter);\
print "$filename -> $new_filename";\
let counter=counter+1;\
mv "${filename}" $new_filename;\
done
@devraj
devraj / celery.py
Last active January 30, 2024 21:08
SQLAlchemy asyncio calls from within a Celery task
# We've been trying to figure out how to run async code from
# Celery until it gets support for it
#
# This is an extracted example which should fit into
# https://github.com/anomaly/lab-python-server
import asyncio
from uuid import UUID
from sqlalchemy.ext.asyncio import AsyncSession
from ...celery import app
@devraj
devraj / Seo.js
Created July 27, 2021 04:55
SEO component for Gatsby with Twitter card
import React from "react"
import PropTypes from "prop-types"
import { Helmet } from "react-helmet"
import { useStaticQuery, graphql } from "gatsby"
function Seo({ description, lang, meta, image: metaImage, title, pathname }) {
const { site } = useStaticQuery(
graphql`
query {
site {
siteMetadata {
@devraj
devraj / migrate_python_project.sh
Last active June 6, 2020 01:45
Changes directory names and package reference of a Docker + Python project
# Created for internal project automation, might not be releveant for others
# except as a learning exercise for bash tricks
# Portions require revision to make it more efficient - produciton like :)
# Please use a template for your own work.
# Change names of directories
FROM="proj1"; TO="proj2"; for FROM_DIR in `find . -name $FROM`; do if [ -d $FROM_DIR ]; then TARGET_DIR=`echo $FROM_DIR | sed "s/$FROM/$TO/g"`; echo $FROM_DIR ">" $TARGET_DIR; mv $FROM_DIR $TARGET_DIR; fi ; done
# Replace references to package names
@devraj
devraj / UIButton+alignTextUnderImage
Last active March 28, 2019 00:55
UIButton with Text Positioned under an image
import UIKit
// https://stackoverflow.com/questions/37915212/storyboard-positioning-text-below-image-inside-a-button/37915362
public extension UIButton
{
func alignTextUnderImage(spacing: CGFloat = 6.0)
{
if let image = self.imageView?.image
{
@devraj
devraj / gist:48c8e2f7aba627ab6449b8c14d3a910b
Created September 7, 2018 05:21
Google Maps places link
https://www.google.com.au/maps/place/Upstairs+Startup+Hub/@-33.4193161,149.5785152,17z/data=!3m1!4b1!4m5!3m4!1s0x6b11e43377353da3:0x82364adf2642ade1!8m2!3d-33.4193161!4d149.5807039
@devraj
devraj / blog-summary.liquid
Created August 21, 2018 04:06
Jekyll Liquid template snippet to list blog items grouped by year and month
<section class="blog-summary">
{% assign postsByYear = site.posts | group_by_exp:"post", "post.date | date: '%Y'" %}
{% for year in postsByYear %}
<h3>{{ year.name }}</h3>
{% assign postsByMonth = year.items | group_by_exp:"post", "post.date | date: '%B'" %}
{% for month in postsByMonth %}
<div class="blog-summary-month">
<h4>{{ month.name }}</h4>
<ol class="blog-post-list">
@devraj
devraj / extract_css_classnames.py
Created March 11, 2018 03:58
Extracts CSS class names using tinycss
import tinycss2
css = open("_source/_assets/css/_webgradients.scss")
rules, encoding = tinycss2.parse_stylesheet_bytes(css_bytes=css.read())
class_names = []
scss_list = "$_webgradients_list: (\n"
for rule in rules:
if type(rule) == tinycss2.ast.QualifiedRule:
class_name = rule.prelude[1].value
@devraj
devraj / graph_configuration_v3.swift
Created July 11, 2017 04:44
Swift configuration for Purple Graph using ScrollableGraphView v3
private func paintGraphView() {
let graphView = ScrollableGraphView(frame: CGRect(x: 0, y: 0, width: 375, height: 350))
let purpleColor = UIColor.colorFromHex("#8D2595")
barPlot.set(data: data, withLabels: labels)
barPlot.topMargin = 80