Skip to content

Instantly share code, notes, and snippets.

View sanjogshrestha's full-sized avatar

Sanjog Shrestha sanjogshrestha

View GitHub Profile
{
"success": true,
"inboxSecions": [
{
"id": "56db7e6a9b0e4dc096bc5be6ab60efda",
"type": "CUSTOM_SECTION",
"title": "Testing ",
"spAccountId": "b485f675e7954eaa86fd2202648be999",
"createdAt": "1644574368527",
"updatedAt": "1676616565805",
@sanjogshrestha
sanjogshrestha / README.md
Created March 21, 2019 10:33 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

All hex value from 100% to 0% alpha:

@sanjogshrestha
sanjogshrestha / gist:75d1a9b43747ee5931501a12fedc85a4
Created September 14, 2018 08:20
Broken pipe error message
Broken pipe java.io.IOException: Broken pipe
at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
at sun.nio.ch.IOUtil.write(IOUtil.java:65)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:524)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:627)
at com.android.ddmlib.SplitApkInstaller.uploadApk(SplitApkInstaller.java:151)
at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:77)
/* class InitDiskCacheTask extends AsyncTask<File, Void, Void> {
@Override
protected Void doInBackground(File... params) {
synchronized (mDiskCacheLock) {
File cacheDir = params[0];
try {
mDiskLruCache = DiskLruCache.open(cacheDir, 1, 1, DISK_CACHE_SIZE);
} catch (IOException e) {
e.printStackTrace();
}
@sanjogshrestha
sanjogshrestha / Android.gitignore
Created March 4, 2018 11:16
GitIgnore Android
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
@sanjogshrestha
sanjogshrestha / VideoView.java
Created December 19, 2017 09:47
Play video using MediaPlayer
private VideoView videoView;
videoView = (VideoView) findViewById(R.id.videoView);
Uri video = Uri.parse("http://www.servername.com/projects/projectname/videos/1361439400.mp4");
videoView.setVideoURI(video);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
@sanjogshrestha
sanjogshrestha / CircleTransform.java
Created December 11, 2017 13:56
CircleTransform for picasso
public class CircleTransform implements Transformation {
@Override
public Bitmap transform(Bitmap source) {
int size = Math.min(source.getWidth(), source.getHeight());
int x = (source.getWidth() - size) / 2;
int y = (source.getHeight() - size) / 2;
Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
if (squaredBitmap != source) {
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
@sanjogshrestha
sanjogshrestha / dummy
Created November 21, 2017 08:47
async doInBackground for ImageDownloader()
@Override
protected Bitmap doInBackground(String... strings) {
Bitmap bitmap = null;
InputStream inputStream;
try {
// Download Image from URL
inputStream = new URL(strings[0]).openStream();
// Decode Bitmap
bitmap = BitmapFactory.decodeStream(inputStream);
} catch (Exception e) {
@sanjogshrestha
sanjogshrestha / gist:04c9fbbdc7764a47b0d656f8f0eaf2e2
Created November 21, 2017 08:46
async doInBackground for JSON
@Override
protected String doInBackground(String... strings) {
try {
URL mUrl = new URL(strings[0]);
HttpURLConnection httpConnection = (HttpURLConnection) mUrl.openConnection();
httpConnection.setRequestMethod("GET");
httpConnection.setUseCaches(false);
httpConnection.setAllowUserInteraction(false);
httpConnection.connect();