Skip to content

Instantly share code, notes, and snippets.

View chandruscm's full-sized avatar
🏠
Working from home

Chandramohan Sudar chandruscm

🏠
Working from home
View GitHub Profile
@chandruscm
chandruscm / upload_image_with_url.py
Created September 13, 2021 21:27
Upload a valid image to an s3 bucket with its url using the requests package. Catches corrupt images using the pillow package.
from copy import deepcopy
import boto3
import requests
import environ
from PIL import Image
import io
env = environ.Env()
# Download an image with the url and store it in s3.
@chandruscm
chandruscm / download-images.sh
Last active September 4, 2021 13:47
Shell script to download images listed in an images.txt folder. Each line has the imageUrl and the fileName to be saved, separated by a space. To run ${zsh download-images.sh}. Reference: https://stackoverflow.com/questions/36192423/wget-download-files-with-filename-from-list-of-urls-using-wget
#!/bin/sh
IFS=$'\n'
for line in $(cat images.txt)
do
url=$(echo $line | awk '{ print $1 }')
out=$(echo $line | awk '{ print $2 }')
wget --user-agent="Mozilla" "$url" -O "$out"
done
/*
* NRLM Scraper by chandruscm
* --------------------------
* - Intended for educational purposes ONLY 📖
* - Use at your own risk ☠️
* - Requires jsoup : https://jsoup.org
*/
import org.jsoup.Connection
import org.jsoup.Jsoup
@chandruscm
chandruscm / activity_menu_app_bar_1.xml
Last active August 14, 2019 13:58
activity_menu_app_bar_1.xml produces the desired effect, but the toolbar moves up: as per the height set in the empty CollapsingToolbarLayout before adding the elevation. activity_menu_app_bar_2.xml does not work, it adds elevation by default without scrolling.
<android.support.design.widget.AppBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:id="@+id/activity_menu_app_bar">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
@chandruscm
chandruscm / ManagingAssetsLibGDx
Created November 3, 2016 13:16
How to manage and scale graphic assets across different screen resolutions in LibGDx, as implemented in Orble https://play.google.com/store/apps/details?id=com.chandruscm.orble.android
/*
3 set of assets are used for targeting 480p, 720p and 1080p+ resolutions
These are packed in TextureAtlases placed in folders SD/, MD/, LD/ respectively inside res/
Each containing the TextureAtlas with the name gameScreen.pack
*/
public static float dpiScale;
public static String dpiPixel;
//Check if the dpiScale has been calculated, if not find it and save it to preference(only for the first run)
import mechanize
import getpass
import time
url = 'https://aums-apps-6.amrita.edu:8443/portal/tool/3193c471-8aec-4c93-b000-66166b6c483b'
br = mechanize.Browser()
br.set_handle_robots(False)
br.set_handle_refresh(False)
@chandruscm
chandruscm / 2048.cpp
Last active November 21, 2022 12:04
A simple implementation of the popular 2048 puzzle in C++ . Visit http://chandruscm.wordpress.com/2014/10/25/2048-in-c-c/ for code explanation.
#include<iostream>
#include<ctime>
#include<unistd.h>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;
int press_enter;