Skip to content

Instantly share code, notes, and snippets.

View mayanksha's full-sized avatar
🎯
Focusing

Mayank Sharma mayanksha

🎯
Focusing
View GitHub Profile
@mayanksha
mayanksha / PinConfigOverride_all.txt
Created September 28, 2018 10:38
PinConfigOverride output combined into 1 single file
~~~~PinConfigOverride001.txt~~~~
HDA Verb Converter
<00371C10 00371D40 00371E00 00371F00 00571C20 00571D50 00571E80 00571F00>
~~~~PinConfigOverride002.txt~~~~
HDA Verb Converter
<01271CC0 01271D01 01271EA6 01271FB7 01371C00 01371D00 01371E00 01371F40 01471C10 01471D01 01471E17 01471F90 01671CF0 01671D11 01671E11 01671F41 01771CF0 01771D11 01771E11 01771F41 01871CF0 01871D11 01871E11 01871F41 01971C40 01971D10 01971EA1 01971F03 01A71CF0 01A71D11 01A71E11 01A71F41 01B71CF0 01B71D11 01B71E11 01B71F41 01D71C01 01D71D00 01D71E60 01D71F40 01E71CF0 01E71D11 01E71E11 01E71F41 02171C20 02171D10 02171E21 02171F03>
@mayanksha
mayanksha / docker-setup.md
Last active February 1, 2020 06:51
Docker Cheatsheet for Development in a standard debian environment

Intentions

I wanted to have a light-weight development setup for all my development env so that I can standardize the dev environment across all developers. Earlier, I was using an Ubuntu debootstrap by chrooting into ubuntu's filesystem. Sometimes, an application would crash.

But VMs (or whole OSes) are resource intensive and clunky, plus they have to be configured differently for different systems (if they vary in specs). So, I thought of using a Docker Container as a standard development environment. This is especially useful in case I have to install a lot of dependencies to get a project to work. I don't have to pollute my host at all, and I get the added benefit of being able to edit the file in host, while executing the programs in docker containers.

Steps to do it.

Fetch your favourite distro's Dockerfile from Docker Hub, and then do docker build . in the dir. Once you're done building image, run a container in detached mode (so that it can be later started, and reused). We also want t

@mayanksha
mayanksha / Ubuntu-16.04-Docker-Opencv3.md
Last active July 23, 2019 05:59
Docker image and setup for X11 enabled container for OpenCV3

xhost +

docker pull chennavarri/ubuntu_opencv_python

docker run --network host --ipc host --device=/dev/video0:/dev/video0 -v /tmp/.X11-unix:/tmp/.X11-unix -v $PATH_TO_ASSIGNMENT_CODE_ON_HOST:$PATH_TO_ASSIGNMENT_CODE_IN_CONTAINER -e DISPLAY=$DISPLAY -p 5000:5000 -p 8888:8888 -d -it chennavarri/ubuntu_opencv_python:latest /bin/bash

docker exec -it opencv bash

where opencv is the name of the newly created container.

root@Task-1a $ dmidecode -t cache
# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 2.8 present.
Handle 0x0005, DMI type 7, 19 bytes
Cache Information
Socket Designation: L1 Cache
Configuration: Enabled, Not Socketed, Level 1
Operational Mode: Write Back
typedef struct
{
GAsyncResult *res;
GMainLoop *loop;
} MountData;
static void
volume_mount_cb (GVolume *volume,
@mayanksha
mayanksha / gist:a8817c94437e157bce10539dc0d0d499
Created December 4, 2019 08:45
Create a new dummy test file using GIO and libgdata (for Google Drive)
static GDataDocumentsEntry *
create_dummy_test_file (GDataDocumentsService *service, GDataDocumentsEntry *parent, GError **error)
{
static guint dummy_file_counter = 0;
const gchar *buf = "Foobar";
gssize bytes_written;
GDataDocumentsDocument *new_document = NULL;
GDataUploadStream *ostream = NULL;
g_autofree gchar *counter_buf = NULL;
g_autofree gchar *title = NULL;
+ error = NULL;
+
+ if (!g_file_query_exists (dest, job->cancellable))
+ {
+ const gchar *src_display_name;
+ GFileInfo *info = NULL;
+ g_autoptr (GMount) mount_point = NULL;
+
+ if ((mount_point = g_file_find_enclosing_mount (src, job->cancellable, &error)) != NULL)
+ {
systemctl stop nginx && certbot certonly --standalone --preferred-challenges http -d msharma.in -d www.msharma.in && systemctl start nginx

Workflow for handling migration changes and local development setup

Let's make an initial assumption: We have a staging database that is up to date with production (in terms of schema). Now, a new developer comes to the company and he wants to setup his own dev environment (let's say from the staging database's schema). The code development workflow is pretty standard i.e. develop locally, push to repo

For local database setup, what we need is to perform a migration from the staging database to the local development database. The developer can pull a hasura-postgresql docker image and run Hasura in a container.

For the actual migration, hasura's console comes to our rescue. Firstly, the developer needs to create a new hasura migration or maybe use some existing ones from a git repo, the latter being more favorable. So, assuming that staging database has a git repo which gets updated daily (i.e. a new version of migration gets created every day), the developer can pull this database, simply change t

@mayanksha
mayanksha / bsnl-ftth-gpon-autofill-captcha.js
Created April 17, 2021 15:50
Automatically fills the standard password and captcha for the BSNL GPON router page
(function() {
'use strict';
setTimeout(() => {
document.querySelector("#inputCode").value = code;
document.querySelector("#Password").value = "bsnl@321";
}, 50);
})();