Skip to content

Instantly share code, notes, and snippets.

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

sunny sunwicked

🏠
Working from home
View GitHub Profile
@sunwicked
sunwicked / AssetFileReader.kt
Created December 8, 2021 16:12
readFileDataFromAsset
fun readFileDataFromAsset(context: Context, fileName: String): String? {
val data: String? = null
try {
data = context.assets.open(fileName).bufferedReader().use { it.readText() }
} catch (ioException: IOException) {
ioException.printStackTrace()
return null
}
return data
}
1. Ask HN: What books changed the way you think about almost everything? - https://news.ycombinator.com/item?id=19087418
2. Ask HN: What are the best MOOCs you've taken? - https://news.ycombinator.com/item?id=16745042
3. Ask HN: How to self-learn electronics? - https://news.ycombinator.com/item?id=16775744
4. Ask HN: Successful one-person online businesses? - https://news.ycombinator.com/item?id=21332072
5. Ask HN: What's the most valuable thing you can learn in an hour? - https://news.ycombinator.com/item?id=21581361
@sunwicked
sunwicked / social_image
Last active February 23, 2021 18:34
Generate image for sharing to Social sites
from urllib.request import urlopen
from bs4 import BeautifulSoup
from PIL import Image, ImageFont, ImageDraw, ImageEnhance
import requests
def getMeta(link):
external_sites_html = urlopen(link).read()
soup = BeautifulSoup(external_sites_html, "html.parser")
@sunwicked
sunwicked / scrappy_alexa.py
Created July 26, 2020 11:53
Scrape Country rank from alexa for a site
import requests
from bs4 import BeautifulSoup
URL = 'https://alexa.com/siteinfo/theayurveda.org'
page = requests.get(URL)
soup = BeautifulSoup(page.content, 'html.parser')
results = soup.find_all('span', class_='pull-right')
for result in results:
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
@sunwicked
sunwicked / CustomLayoutManager.java
Created November 4, 2017 15:06
Custom LinearLayoutManager for scaling, fading and snapping children to top
class CustomLayoutManager extends LinearLayoutManager {
private final float mShrinkAmount = 0.15f;
private final float mShrinkDistance = 0.9f;
Context mContext;
//Make an instance variable at the top of you LayoutManager
private static final float MILLISECONDS_PER_INCH = 50f;
public CustomLayoutManager(Context context) {
super(context);
mContext = context;
@sunwicked
sunwicked / deployApks.groovy
Created April 24, 2017 18:01 — forked from aquaflamingo/deployApks.groovy
Gradle task to archive APKs once built through android studio by running ./gradlew deployApks
task deployApks(type:Copy) {
description = "Copies APKs and Proguard mappings to the deploy directory"
def appName = "posture";
def versionDir = android.defaultConfig.versionName+"_"+android.defaultConfig.versionCode;
println("Copies APK and Proguard to " + versionDir)
from 'build/outputs/mapping/release/'
include '**/mapping.txt'
into '../.admin/deploy/' + versionDir
@sunwicked
sunwicked / Android.mk
Last active October 12, 2016 09:56
Sample Android make file present inside packages>>apps>>yourapp>>your mk file Links : http://www.cprogramming.com/tutorial/makefiles.html // https://developer.android.com/ndk/guides/android_mk.html
LOCAL_PATH:= $(call my-dir)
# The macro function my-dir, provided by the build system, returns the path of the current directory
include $(CLEAR_VARS)
# The CLEAR_VARS variable points to a special GNU Makefile that clears many LOCAL_XXX variables for you,
# such as LOCAL_MODULE, LOCAL_SRC_FILES, and LOCAL_STATIC_LIBRARIES. Note that it does not clear LOCAL_PATH
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
//Animate views with a nice fadeIn effect before drawing
getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
getViewTreeObserver().removeOnPreDrawListener(this);
if(mPOI.hasFacebookRating())
ViewCompat.animate(mFacebookTv).alpha(1).setDuration(500);
@sunwicked
sunwicked / progaurd.txt
Created December 6, 2015 22:03
Progaurd
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.billing.IInAppBillingService
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);