Skip to content

Instantly share code, notes, and snippets.

View coolharsh55's full-sized avatar

Harshvardhan Pandit coolharsh55

View GitHub Profile
@coolharsh55
coolharsh55 / gcs_signed_urls.py
Created December 15, 2015 19:45
Create signed urls for Google Cloud Storage with JSON file
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Creates a signed URL for accessing Google Cloud Storage objects for the
specified time period"""
import base64
import json
import time
@coolharsh55
coolharsh55 / regex.c
Created December 18, 2015 21:25
Using regex search & extract in C
#include <stdio.h>
#include <string.h>
#include <regex.h>
int main(int argc, char** argv)
{
int regex_error = 0; // error generated in execution of regex
regmatch_t pm[10]; // regex matches
regex_t r_compiled; // compiled regex
@coolharsh55
coolharsh55 / convert_16bits.py
Last active July 12, 2022 08:00
Convert int to 16 bits in python
# using struct
# the 'H' stands for unsigned 2-byte 16bit number
# use 'h' for signed 2-byte 16bit number
# further reference available in python.struct docs
import struct
m16 = lambda x: struct.unpack('H', struct.pack('H', x))[0]
# using bitwise AND
# just AND it with 0XFFFF (max 16-bit value)
@coolharsh55
coolharsh55 / gist:6febedc6069137938829
Created January 27, 2016 10:20
MySQL access denied / plugin not loaded error
// login as root
mysql -uroot -p
// select mysql internal database
select mysql;
// delete relevant user
drop user 'username'@'host';
// create user again
$> touch ~/.ssh/config
//Contents:
Host <convenient_name>
Hostname <ip_address_or_url>
IdentityFile <~/.ssh/pem_key_file>
User <name_of_user>
Host ... [repeat for each ssh config]
@coolharsh55
coolharsh55 / walton_club_car.ino
Last active April 14, 2017 06:23
Arduino code for Walton Club Easter Camp car challenge
/**
__ __ _ _______ ____ _ _ _____ _ _ _ ____
\ \ / /\ | | |__ __/ __ \| \ | | / ____| | | | | | _ \
\ \ /\ / / \ | | | | | | | | \| | | | | | | | | | |_) |
\ \/ \/ / /\ \ | | | | | | | | . ` | | | | | | | | | _ <
\ /\ / ____ \| |____| | | |__| | |\ | | |____| |___| |__| | |_) |
\/ \/_/ \_\______|_| \____/|_| \_| \_____|______\____/|____/
ROBOT CAR CODE
@coolharsh55
coolharsh55 / printjob_status.sh
Last active September 25, 2017 19:17
printer_job_status
#!/usr/bin/env bash
# author Harshvardhan Pandit
# how this works:
# using snmpwalk, the jobstring status is retrieved for the printer using the
# query (found using Lexmark MIB)
# by default, NOJOBRESPONSE is returned.
# If this is not the response, then that means that something is being printed.
# The jobstring contains the IP address of the job (who send that job).
@coolharsh55
coolharsh55 / identity-broken-links.js
Created July 22, 2019 21:18
identify broken internal links on a page
@coolharsh55
coolharsh55 / twitter-pin.css
Last active March 10, 2021 11:38
Replaces Twitter heart 'like' symbols with pin emoji (๐Ÿ“Œ) as 'save' symbol.
/* remove heart on main view and replace with pin */
div.css-1dbjc4n.r-18u37iz.r-1wtj0ep.r-1s2bzr4.r-1mdbhws > div:nth-child(3) > div:first-child > div:first-child > div:nth-child(1) {
visibility: hidden;
}
div.css-1dbjc4n.r-18u37iz.r-1wtj0ep.r-1s2bzr4.r-1mdbhws > div:nth-child(3) > div:first-child > div:after {
content: "๐Ÿ“Œ";
color: transparent;
text-shadow: 0 0 0 #8899a6;
}
@coolharsh55
coolharsh55 / consent-ontology.ttl
Created September 4, 2020 17:33
Earlier iteration of GConsent - shown for demonstration purpose only